import { Module } from '@nestjs/common';

import { LoggingModule } from '../../domain/logging/LoggingModule';

import type { Logger } from '@core/shared/domain/Logger';

import type { FeedRepository } from '@core/social/domain/repositories/FeedRepository';
import type { SocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository';

import {
    InMemoryFeedRepository,
    InMemorySocialGraphRepository,
} from '@adapters/social/persistence/inmemory/InMemorySocialAndFeed';

import { SOCIAL_FEED_REPOSITORY_TOKEN, SOCIAL_GRAPH_REPOSITORY_TOKEN } from '../social/SocialPersistenceTokens';

@Module({
  imports: [LoggingModule],
  providers: [
    {
      provide: SOCIAL_FEED_REPOSITORY_TOKEN,
      useFactory: (logger: Logger): FeedRepository =>
        new InMemoryFeedRepository(logger, { drivers: [], friendships: [], feedEvents: [] }),
      inject: ['Logger'],
    },
    {
      provide: SOCIAL_GRAPH_REPOSITORY_TOKEN,
      useFactory: (logger: Logger): SocialGraphRepository =>
        new InMemorySocialGraphRepository(logger, { drivers: [], friendships: [], feedEvents: [] }),
      inject: ['Logger'],
    },
  ],
  exports: [SOCIAL_FEED_REPOSITORY_TOKEN, SOCIAL_GRAPH_REPOSITORY_TOKEN],
})
export class InMemorySocialPersistenceModule {}