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

supplierMachine

@mineflow/api-schemas


@mineflow/api-schemas / supplierMachine

Variable: supplierMachine

const supplierMachine: StateMachine<SupplierContext,
| {
hasPrimaryBank: boolean;
hasPrimaryContact: boolean;
submittedBy: string;
type: "SUBMIT";
}
| {
approvedBy: string;
submittedBy: string;
type: "APPROVE";
}
| {
comment: string;
sentBackBy: string;
type: "SEND_BACK";
}
| {
reason: string;
suspendedBy: string;
type: "SUSPEND";
}
| {
hasPrimaryBank: boolean;
hasPrimaryContact: boolean;
reactivatedBy: string;
reason: string;
type: "REACTIVATE";
}
| {
archivedBy: string;
coApprovedBy: string | null;
reason: string;
type: "ARCHIVE";
}, {
}, never, never, ToParameterizedObject<{
approverDiffersFromSubmitter: unknown;
archiveDualApprovalSatisfied: unknown;
hasComment: unknown;
hasPrimaryContactAndBank: unknown;
hasReason: unknown;
}>, never, "draft" | "active" | "suspended" | "archived" | "under_review", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, ToStateSchema<{
context: {
supplierId: "";
};
id: "supplier";
initial: "draft";
states: {
active: {
on: {
ARCHIVE: {
guard: "archiveDualApprovalSatisfied";
target: "archived";
};
SUSPEND: {
guard: "hasReason";
target: "suspended";
};
};
};
archived: {
type: "final";
};
draft: {
on: {
ARCHIVE: {
guard: "hasReason";
target: "archived";
};
SUBMIT: {
guard: "hasPrimaryContactAndBank";
target: "under_review";
};
};
};
suspended: {
on: {
ARCHIVE: {
guard: "archiveDualApprovalSatisfied";
target: "archived";
};
REACTIVATE: {
guard: (__namedParameters: GuardArgs<SupplierContext, {
hasPrimaryBank: boolean;
hasPrimaryContact: boolean;
reactivatedBy: string;
reason: string;
type: "REACTIVATE";
}>) => boolean;
target: "active";
};
};
};
under_review: {
on: {
APPROVE: {
guard: "approverDiffersFromSubmitter";
target: "active";
};
ARCHIVE: {
guard: "hasReason";
target: "archived";
};
SEND_BACK: {
guard: "hasComment";
target: "draft";
};
};
};
};
}>>;

Defined in: scm/src/suppliers/state-machine/supplier.machine.ts:42

FSM поставщика (SCM Supplier) — жизненный цикл карточки контрагента от черновика до архива.

Источник истины — entity (ADR-0022); машина — xstate v5 spec для FSM drift detector и model-based тестов. Re-export'ится @mineflow/api-schemas для FSM-кнопок в UI.

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

  • draft (начальное) → SUBMITunder_review (под guard hasPrimaryContactAndBank)
  • under_reviewAPPROVEactive (под guard approverDiffersFromSubmitter)
  • under_reviewSEND_BACKdraft (под guard hasComment)
  • activeSUSPENDsuspended (под guard hasReason)
  • suspendedREACTIVATEactive (причина + первичные контакт/банк)
  • draft | under_reviewARCHIVEarchived (под guard hasReason)
  • active | suspendedARCHIVEarchived (под guard archiveDualApprovalSatisfied)
  • archived — терминальное состояние.