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; }; export type InterventionSaveContext = InterventionContext & InterventionLookups & { nextNumber: number; requestIntervention: Intervention | undefined }; export interface IInterventionRepository { list(company?: UniqueID): Promise>; lookups(company: UniqueID): Promise>; save( company: UniqueID, requestKey: UniqueID, action: (context: InterventionSaveContext) => Result ): Promise< Result<{ intervention: Intervention; context: InterventionContext }, InterventionError> >; }