metis-desk/modules/companies/src/api/application/intervention.repository.ts
2026-10-10 12:01:58 +02:00

33 lines
1.3 KiB
TypeScript

import type { UniqueID } from "@repo/rdx-ddd";
import type { Result } from "@repo/rdx-utils";
import type { Intervention } from "../domain/intervention.aggregate";
import type { InterventionTemplate } from "../domain/intervention-template.aggregate";
import type { InterventionError } from "../domain/intervention-values";
import type { TicketContext, TicketLookups } from "./ticket.repository";
export type InterventionContext = TicketContext & { interventions: readonly Intervention[] };
export type InterventionLookups = {
context: TicketContext;
lookups: TicketLookups;
templates: readonly InterventionTemplate[];
templateActors: Map<string, string>;
};
export type InterventionSaveContext = InterventionContext &
InterventionLookups & { nextNumber: number; requestIntervention: Intervention | undefined };
export interface IInterventionRepository {
list(company?: UniqueID): Promise<Result<InterventionContext, InterventionError>>;
lookups(company: UniqueID): Promise<Result<InterventionLookups, InterventionError>>;
save(
company: UniqueID,
requestKey: UniqueID,
action: (context: InterventionSaveContext) => Result<Intervention, InterventionError>
): Promise<
Result<{ intervention: Intervention; context: InterventionContext }, InterventionError>
>;
}