59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { type SetupParams, buildCatalogs, buildTransactionManager } from "@erp/core/api";
|
|
import type { IProformaPublicServices } from "@erp/customer-invoices/api";
|
|
import type { ICustomerPublicServices } from "@erp/customers/api";
|
|
|
|
import {
|
|
buildCreateProformaFromFactugesUseCase,
|
|
buildFactugesInputMappers,
|
|
} from "../../application/di";
|
|
import { buildFactuGESFinder } from "../../application/di/factuges-finder.di";
|
|
import { buildFactuGESLinker } from "../../application/di/factuges-linker.di";
|
|
import type { CreateProformaFromFactugesUseCase } from "../../application/use-cases";
|
|
|
|
import { buildFactuGESPersistenceMappers } from "./factuges-persistence-mappers.di";
|
|
import { buildFactugesRepository } from "./factuges-repositories.di";
|
|
|
|
export type FactugesInternalDeps = {
|
|
useCases: {
|
|
createProforma: (publicServices: {
|
|
customerServices: ICustomerPublicServices;
|
|
proformaServices: IProformaPublicServices;
|
|
}) => CreateProformaFromFactugesUseCase;
|
|
};
|
|
};
|
|
|
|
export function buildFactugesDependencies(params: SetupParams): FactugesInternalDeps {
|
|
const { database } = params;
|
|
|
|
// Infrastructure
|
|
const transactionManager = buildTransactionManager(database);
|
|
|
|
const catalogs = buildCatalogs();
|
|
const inputMappers = buildFactugesInputMappers(catalogs);
|
|
const persistenceMappers = buildFactuGESPersistenceMappers();
|
|
|
|
const repository = buildFactugesRepository({ database, mappers: persistenceMappers });
|
|
|
|
// Application helpers
|
|
const finder = buildFactuGESFinder({ repository });
|
|
const linker = buildFactuGESLinker({ repository });
|
|
|
|
// Internal use cases (factories)
|
|
return {
|
|
useCases: {
|
|
createProforma: (publicServices: {
|
|
customerServices: ICustomerPublicServices;
|
|
proformaServices: IProformaPublicServices;
|
|
}) =>
|
|
buildCreateProformaFromFactugesUseCase({
|
|
linker,
|
|
finder,
|
|
dtoMapper: inputMappers.createInputMapper,
|
|
publicServices,
|
|
catalogs,
|
|
transactionManager,
|
|
}),
|
|
},
|
|
};
|
|
}
|