userAccountMachine
@mineflow/api-schemas / userAccountMachine
Variable: userAccountMachine
const userAccountMachine: StateMachine<UserAccountContext,
| {
actorId: string;
reason: string;
type: "LOCK_MANUAL";
}
| {
actorId: string;
type: "AUTO_FAILED_LOGIN";
}
| {
actorId: string;
type: "UNLOCK_MANUAL";
}
| {
actorId: string;
type: "AUTO_UNLOCK_AT_LOCKED_UNTIL";
}
| {
actorId: string;
reason: string;
type: "DEACTIVATE_MANUAL";
}
| {
actorId: string;
type: "PERSONNEL_DEACTIVATED";
}, {
}, never, never, {
}, never, "active" | "locked" | "deactivated", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, ToStateSchema<{
context: {
userAccountId: "";
};
id: "user-account";
initial: "active";
states: {
active: {
on: {
AUTO_FAILED_LOGIN: "locked";
DEACTIVATE_MANUAL: {
guard: "hasReason";
target: "deactivated";
};
LOCK_MANUAL: {
guard: "hasReason";
target: "locked";
};
PERSONNEL_DEACTIVATED: "deactivated";
};
};
deactivated: {
type: "final";
};
locked: {
on: {
AUTO_UNLOCK_AT_LOCKED_UNTIL: "active";
DEACTIVATE_MANUAL: {
guard: "hasReason";
target: "deactivated";
};
PERSONNEL_DEACTIVATED: "deactivated";
UNLOCK_MANUAL: "active";
};
};
};
}>>;
Defined in: hr/src/user-accounts/state-machine/user-account.machine.ts:30
FSM учётной записи пользователя (HR UserAccount).
Источник истины — entity (ADR-0022); машина — xstate v5 spec, re-export'ится
@mineflow/api-schemas для FSM-кнопок (блокировка/разблокировка/деактивация)
в UI.
Состояния и переходы:
active(начальное) →LOCK_MANUAL(под guardhasReason) |AUTO_FAILED_LOGIN→lockedlocked→UNLOCK_MANUAL|AUTO_UNLOCK_AT_LOCKED_UNTIL→activeactive | locked→DEACTIVATE_MANUAL(под guardhasReason) |PERSONNEL_DEACTIVATED→deactivateddeactivated— терминальное состояние.
Смена ролей — НЕ FSM-переход: это атомарная операция updateRoles() на entity.
Защита HR-UA-INV-04 (нельзя удалить последнего admin) — application guard, не FSM.