metis-desk/modules/companies/src/api/application/intervention.repository.ts

33 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-07 11:03:01 +00:00
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";
2026-10-10 10:01:58 +00:00
2026-10-07 11:03:01 +00:00
export type InterventionContext = TicketContext & { interventions: readonly Intervention[] };
2026-10-10 10:01:58 +00:00
2026-10-07 11:03:01 +00:00
export type InterventionLookups = {
context: TicketContext;
lookups: TicketLookups;
templates: readonly InterventionTemplate[];
templateActors: Map<string, string>;
};
2026-10-10 10:01:58 +00:00
2026-10-07 11:03:01 +00:00
export type InterventionSaveContext = InterventionContext &
InterventionLookups & { nextNumber: number; requestIntervention: Intervention | undefined };
2026-10-10 10:01:58 +00:00
2026-10-07 11:03:01 +00:00
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>
>;
}