import { IRepositoryManager, RepositoryManager } from "@/contexts/common/domain";
import {
  ISequelizeAdapter,
  createSequelizeAdapter,
} from "@/contexts/common/infrastructure/sequelize";

export interface ICatalogContext {
  adapter: ISequelizeAdapter;
  repositoryManager: IRepositoryManager;
  //services: IApplicationService;
}

export class CatalogContext {
  private static instance: CatalogContext | null = null;

  public static getInstance(): ICatalogContext {
    if (!CatalogContext.instance) {
      CatalogContext.instance = new CatalogContext({
        adapter: createSequelizeAdapter(),
        repositoryManager: RepositoryManager.getInstance(),
      });
    }

    return CatalogContext.instance.context;
  }

  private context: ICatalogContext;

  private constructor(context: ICatalogContext) {
    this.context = context;
  }
}
