import { config } from "@/config";
import { RepositoryManager } from "@/contexts/common/domain";
import { createSequelizeAdapter } from "@/contexts/common/infrastructure/sequelize";

import { AuthUser } from "@/contexts/auth/domain";
import { IRepositoryManager } from "../domain";
import { ISequelizeAdapter } from "./sequelize";

export interface IContext {}

export interface ICommonContext extends IContext {
  adapter: ISequelizeAdapter;
  repositoryManager: IRepositoryManager;
  defaults: Record<string, any>;
  user?: AuthUser;
}

export const createCommonContext = () => ({
  defaults: config.defaults,
  adapter: createSequelizeAdapter(),
  repositoryManager: RepositoryManager.getInstance(),
});
