Перейти к основному содержимому

maintenanceRecordMachine

@mineflow/api-schemas


@mineflow/api-schemas / maintenanceRecordMachine

Variable: maintenanceRecordMachine

const maintenanceRecordMachine: StateMachine<MaintenanceContext,
| {
performedBy: string;
type: "START";
}
| {
completedAt: Date;
performedBy: string;
startedAt: Date;
type: "COMPLETE";
}
| {
cancelledBy: string;
reason: string;
type: "CANCEL";
}, {
}, never, never, ToParameterizedObject<{
hasCancelReason: unknown;
isCompletedAfterStart: unknown;
}>, never, "scheduled" | "inProgress" | "completed" | "cancelled", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, ToStateSchema<{
context: {
recordId: "";
};
id: "maintenanceRecord";
initial: "scheduled";
states: {
cancelled: {
type: "final";
};
completed: {
type: "final";
};
inProgress: {
on: {
CANCEL: {
guard: "hasCancelReason";
target: "cancelled";
};
COMPLETE: {
guard: "isCompletedAfterStart";
target: "completed";
};
};
};
scheduled: {
on: {
CANCEL: {
guard: "hasCancelReason";
target: "cancelled";
};
START: "inProgress";
};
};
};
}>>;

Defined in: eam/src/maintenance/state-machine/maintenance-record.machine.ts:24

FSM записи об обслуживании техники (EAM MaintenanceRecord).

Источник истины — maintenance-record.entity.ts; машина — xstate v5 spec (ADR-0022), re-export'ится @mineflow/api-schemas для расчёта доступных действий по статусу записи в UI.

Состояния и переходы:

  • scheduled (начальное) → STARTinProgress
  • scheduledCANCELcancelled (под guard hasCancelReason)
  • inProgressCOMPLETEcompleted (под guard isCompletedAfterStart)
  • inProgressCANCELcancelled (под guard hasCancelReason)
  • completed, cancelled — терминальные состояния.