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

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

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

import type { IFeedRepository } from '@core/social/domain/repositories/IFeedRepository';
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';

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): IFeedRepository =>
        new InMemoryFeedRepository(logger, { drivers: [], friendships: [], feedEvents: [] }),
      inject: ['Logger'],
    },
    {
      provide: SOCIAL_GRAPH_REPOSITORY_TOKEN,
      useFactory: (logger: Logger): ISocialGraphRepository =>
        new InMemorySocialGraphRepository(logger, { drivers: [], friendships: [], feedEvents: [] }),
      inject: ['Logger'],
    },
  ],
  exports: [SOCIAL_FEED_REPOSITORY_TOKEN, SOCIAL_GRAPH_REPOSITORY_TOKEN],
})
export class InMemorySocialPersistenceModule {}