74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
|
|
import { type ModuleParams, buildCatalogs, buildTransactionManager } from "@erp/core/api";
|
||
|
|
|
||
|
|
export type CustomersInternalDeps = {
|
||
|
|
useCases: {
|
||
|
|
listCustomers: () => ListCustomersUseCase;
|
||
|
|
getCustomerById: () => GetCustomerByIdUseCase;
|
||
|
|
reportCustomer: () => ReportCustomerUseCase;
|
||
|
|
createCustomer: () => CreateCustomerUseCase;
|
||
|
|
|
||
|
|
/*
|
||
|
|
updateCustomer: () => UpdateCustomerUseCase;
|
||
|
|
deleteCustomer: () => DeleteCustomerUseCase;
|
||
|
|
issueCustomer: () => IssueCustomerUseCase;
|
||
|
|
changeStatusCustomer: () => ChangeStatusCustomerUseCase;*/
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
export function buildCustomersDependencies(params: ModuleParams): CustomersInternalDeps {
|
||
|
|
const { database } = params;
|
||
|
|
|
||
|
|
// Infrastructure
|
||
|
|
const transactionManager = buildTransactionManager(database);
|
||
|
|
const catalogs = buildCatalogs();
|
||
|
|
const persistenceMappers = buildCustomerPersistenceMappers(catalogs);
|
||
|
|
|
||
|
|
const repository = buildCustomerRepository({ database, mappers: persistenceMappers });
|
||
|
|
const numberService = buildCustomerNumberGenerator();
|
||
|
|
|
||
|
|
// Application helpers
|
||
|
|
const inputMappers = buildCustomerInputMappers(catalogs);
|
||
|
|
const finder = buildCustomerFinder(repository);
|
||
|
|
const creator = buildCustomerCreator({ numberService, repository });
|
||
|
|
|
||
|
|
const snapshotBuilders = buildCustomersnapshotBuilders();
|
||
|
|
const documentGeneratorPipeline = buildCustomerDocumentService(params);
|
||
|
|
|
||
|
|
// Internal use cases (factories)
|
||
|
|
return {
|
||
|
|
useCases: {
|
||
|
|
listCustomers: () =>
|
||
|
|
buildListCustomersUseCase({
|
||
|
|
finder,
|
||
|
|
itemSnapshotBuilder: snapshotBuilders.list,
|
||
|
|
transactionManager,
|
||
|
|
}),
|
||
|
|
|
||
|
|
getCustomerById: () =>
|
||
|
|
buildGetCustomerByIdUseCase({
|
||
|
|
finder,
|
||
|
|
fullSnapshotBuilder: snapshotBuilders.full,
|
||
|
|
transactionManager,
|
||
|
|
}),
|
||
|
|
|
||
|
|
reportCustomer: () =>
|
||
|
|
buildReportCustomerUseCase({
|
||
|
|
finder,
|
||
|
|
fullSnapshotBuilder: snapshotBuilders.full,
|
||
|
|
reportSnapshotBuilder: snapshotBuilders.report,
|
||
|
|
documentService: documentGeneratorPipeline,
|
||
|
|
transactionManager,
|
||
|
|
}),
|
||
|
|
|
||
|
|
createCustomer: () =>
|
||
|
|
buildCreateCustomerUseCase({
|
||
|
|
creator,
|
||
|
|
dtoMapper: inputMappers.createInputMapper,
|
||
|
|
fullSnapshotBuilder: snapshotBuilders.full,
|
||
|
|
transactionManager,
|
||
|
|
}),
|
||
|
|
},
|
||
|
|
};
|
||
|
|
}
|