surveyMachine
@mineflow/api-schemas / surveyMachine
Variable: surveyMachine
const surveyMachine: StateMachine<SurveyContext,
| {
actorId: string;
type: "PUBLISH";
}
| {
actorId: string;
type: "CLOSE";
}
| {
actorId: string;
reason: string;
type: "CANCEL";
}
| {
type: "ARCHIVE";
}, {
}, never, never, {
}, never, "cancelled" | "draft" | "published" | "closed" | "archived", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, ToStateSchema<{
context: {
surveyId: "";
};
id: "survey";
initial: "draft";
states: {
archived: {
type: "final";
};
cancelled: {
type: "final";
};
closed: {
on: {
ARCHIVE: "archived";
};
};
draft: {
on: {
CANCEL: {
guard: "hasReason";
target: "cancelled";
};
PUBLISH: "published";
};
};
published: {
on: {
CANCEL: {
guard: "hasReason";
target: "cancelled";
};
CLOSE: "closed";
};
};
};
}>>;
Defined in: libs/hr/src/surveys/state-machine/survey.machine.ts:25
FSM жизненного цикла опроса (HR Survey).
Источник истины — entity (ADR-0022); машина — xstate v5 spec для расчёта
доступных действий по status в UI и для pnpm fsm:check.
Состояния и переходы:
draft(начальное) →PUBLISH→published(guardhasQuestionsAndAudienceпроверяется в entity)draft | published→CANCEL→cancelled(guardhasReason)published→CLOSE→closedclosed→ARCHIVE→archivedarchived,cancelled— терминальные.