personnelMachine
@mineflow/api-schemas / personnelMachine
Variable: personnelMachine
const personnelMachine: StateMachine<PersonnelContext,
| {
actorId: string;
type: "START_WATCH";
}
| {
actorId: string;
type: "END_WATCH";
}
| {
actorId: string;
type: "START_VACATION";
}
| {
actorId: string;
type: "END_VACATION";
}
| {
actorId: string;
reason: string;
type: "TERMINATE";
}, {
}, never, never, {
}, never, "active" | "onWatch" | "onVacation" | "terminated", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, ToStateSchema<{
context: {
personnelId: "";
};
id: "personnel";
initial: "active";
states: {
active: {
on: {
START_VACATION: "onVacation";
START_WATCH: "onWatch";
TERMINATE: {
guard: "hasReason";
target: "terminated";
};
};
};
onVacation: {
on: {
END_VACATION: "active";
TERMINATE: {
guard: "hasReason";
target: "terminated";
};
};
};
onWatch: {
on: {
END_WATCH: "active";
TERMINATE: {
guard: "hasReason";
target: "terminated";
};
};
};
terminated: {
type: "final";
};
};
}>>;
Defined in: hr/src/personnel/state-machine/personnel.machine.ts:26
FSM жизненного цикла сотрудника (HR Personnel).
Источник истины — entity (ADR-0022); машина — xstate v5 spec, re-export'ится
@mineflow/api-schemas для расчёта доступных действий по status сотрудника
в UI.
Состояния и переходы:
active(начальное) ⇄onWatch(START_WATCH/END_WATCH— заезд/отъезд на вахту)active⇄onVacation(START_VACATION/END_VACATION— отпуск)active | onWatch | onVacation→TERMINATE→terminated(увольнение, под guardhasReason)terminated— терминальное состояние.