Interface: LifecycleEngine
Defined in: server/lifecycle/engine.ts:91
Properties
entityType
readonly entityType: string;Defined in: server/lifecycle/engine.ts:93
machine
readonly machine: CompiledMachine;Defined in: server/lifecycle/engine.ts:92
Methods
availableEvents()
availableEvents(input: {
actorId?: string | null;
actorType?: string | null;
entityId: string;
metadata?: Record<string, unknown> | null;
reason?: string | null;
source?: string | null;
}): Promise<string[]>;Defined in: server/lifecycle/engine.ts:99
Events legal from the entity's current state, after guards.
Parameters
| Parameter | Type |
|---|---|
input | { actorId?: string | null; actorType?: string | null; entityId: string; metadata?: Record<string, unknown> | null; reason?: string | null; source?: string | null; } |
input.actorId? | string | null |
input.actorType? | string | null |
input.entityId | string |
input.metadata? | Record<string, unknown> | null |
input.reason? | string | null |
input.source? | string | null |
Returns
Promise<string[]>
can()
can(input: {
actorId?: string | null;
actorType?: string | null;
entityId: string;
metadata?: Record<string, unknown> | null;
reason?: string | null;
source?: string | null;
} & {
event: string;
}): Promise<boolean>;Defined in: server/lifecycle/engine.ts:101
Whether a specific event would be accepted right now (no write).
Parameters
| Parameter | Type |
|---|---|
input | { actorId?: string | null; actorType?: string | null; entityId: string; metadata?: Record<string, unknown> | null; reason?: string | null; source?: string | null; } & { event: string; } |
Returns
Promise<boolean>
currentState()
currentState(entityId: string): Promise<string | null>;Defined in: server/lifecycle/engine.ts:97
The entity's current state, or null if it has no recorded state.
Parameters
| Parameter | Type |
|---|---|
entityId | string |
Returns
Promise<string | null>
history()
history(entityId: string, page?: OffsetPaginationParams): Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: unknown;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>;Defined in: server/lifecycle/engine.ts:103
Paginated transition history, ordered by sequence ascending.
Parameters
| Parameter | Type |
|---|---|
entityId | string |
page? | OffsetPaginationParams |
Returns
Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: unknown;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>
send()
send(input: {
actorId?: string | null;
actorType?: string | null;
entityId: string;
event: string;
idempotencyKey?: string | null;
metadata?: Record<string, unknown> | null;
reason?: string | null;
source?: string | null;
}): Promise<SendResult>;Defined in: server/lifecycle/engine.ts:95
Apply an event, transactionally. See the class docs for the ordered flow.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | { actorId?: string | null; actorType?: string | null; entityId: string; event: string; idempotencyKey?: string | null; metadata?: Record<string, unknown> | null; reason?: string | null; source?: string | null; } | - |
input.actorId? | string | null | - |
input.actorType? | string | null | - |
input.entityId | string | - |
input.event | string | - |
input.idempotencyKey? | string | null | Optional idempotency key. When supplied, a replay with the SAME key + a matching request fingerprint returns the prior result; a mismatch throws TransitionIdempotencyConflictError. |
input.metadata? | Record<string, unknown> | null | - |
input.reason? | string | null | - |
input.source? | string | null | - |
Returns
Promise<SendResult>