@fabricorg/platform-temporal 4.2.2 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.cjs +315 -297
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +250 -250
- package/dist/index.d.ts +250 -250
- package/dist/index.js +299 -257
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { ActorType } from
|
|
2
|
-
import { WorkflowClient } from
|
|
3
|
-
|
|
1
|
+
import { ActorType } from "@fabricorg/platform";
|
|
2
|
+
import { WorkflowClient } from "@temporalio/client";
|
|
3
|
+
//#region index.d.ts
|
|
4
4
|
/** Serializable input passed from deterministic workflows to a Platform activity. */
|
|
5
|
-
interface GovernedActionActivityInput {
|
|
5
|
+
export interface GovernedActionActivityInput {
|
|
6
|
+
actionId: string;
|
|
7
|
+
parameters: Record<string, unknown>;
|
|
8
|
+
tenantId: string;
|
|
9
|
+
spaceId: string;
|
|
10
|
+
actorId: string;
|
|
11
|
+
actorType: ActorType;
|
|
12
|
+
workflowId: string;
|
|
13
|
+
runId: string;
|
|
14
|
+
stepId: string;
|
|
15
|
+
parentInvocationId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface GovernedActionInvoker {
|
|
18
|
+
invoke(input: {
|
|
6
19
|
actionId: string;
|
|
7
20
|
parameters: Record<string, unknown>;
|
|
8
21
|
tenantId: string;
|
|
9
22
|
spaceId: string;
|
|
10
23
|
actorId: string;
|
|
11
24
|
actorType: ActorType;
|
|
12
|
-
workflowId: string;
|
|
13
|
-
runId: string;
|
|
14
|
-
stepId: string;
|
|
15
|
-
parentInvocationId?: string;
|
|
16
|
-
}
|
|
17
|
-
interface GovernedActionInvoker {
|
|
18
|
-
invoke(input: {
|
|
19
|
-
actionId: string;
|
|
20
|
-
parameters: Record<string, unknown>;
|
|
21
|
-
tenantId: string;
|
|
22
|
-
spaceId: string;
|
|
23
|
-
actorId: string;
|
|
24
|
-
actorType: ActorType;
|
|
25
|
-
idempotencyKey: string;
|
|
26
|
-
correlationId: string;
|
|
27
|
-
causationId?: string;
|
|
28
|
-
executionEvidence: {
|
|
29
|
-
temporalWorkflowId: string;
|
|
30
|
-
temporalRunId: string;
|
|
31
|
-
temporalStepId: string;
|
|
32
|
-
};
|
|
33
|
-
}): Promise<unknown>;
|
|
34
|
-
}
|
|
35
|
-
declare function temporalInvocationIdentity(input: Pick<GovernedActionActivityInput, "workflowId" | "stepId">): {
|
|
36
25
|
idempotencyKey: string;
|
|
37
26
|
correlationId: string;
|
|
27
|
+
causationId?: string;
|
|
28
|
+
executionEvidence: {
|
|
29
|
+
temporalWorkflowId: string;
|
|
30
|
+
temporalRunId: string;
|
|
31
|
+
temporalStepId: string;
|
|
32
|
+
};
|
|
33
|
+
}): Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
export declare function temporalInvocationIdentity(input: Pick<GovernedActionActivityInput, "workflowId" | "stepId">): {
|
|
36
|
+
idempotencyKey: string;
|
|
37
|
+
correlationId: string;
|
|
38
38
|
};
|
|
39
39
|
/** Activity implementation. It always enters through the governed Host; handlers are never called directly. */
|
|
40
|
-
declare function createGovernedActionActivities(invoker: GovernedActionInvoker): {
|
|
41
|
-
|
|
40
|
+
export declare function createGovernedActionActivities(invoker: GovernedActionInvoker): {
|
|
41
|
+
invokeGovernedAction: (input: GovernedActionActivityInput) => Promise<unknown>;
|
|
42
42
|
};
|
|
43
|
-
interface SagaSignalEnvelope<T = unknown> {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
export interface SagaSignalEnvelope<T = unknown> {
|
|
44
|
+
sagaId: string;
|
|
45
|
+
signal: string;
|
|
46
|
+
payload: T;
|
|
47
|
+
actorId: string;
|
|
48
|
+
receivedAt: string;
|
|
49
|
+
/**
|
|
50
|
+
* Identifies one logical signal. A sender should reuse the same value on each
|
|
51
|
+
* redelivery of that signal, for example a webhook delivery ID or an approval
|
|
52
|
+
* decision ID, so a retried `client.signal()` after a timeout carries the
|
|
53
|
+
* same `signalId` as the first attempt.
|
|
54
|
+
*
|
|
55
|
+
* A receiver built on {@link createSagaSignalInbox} drops an envelope whose
|
|
56
|
+
* `signalId` it has already received. Envelopes without a `signalId` are not
|
|
57
|
+
* deduplicated. {@link createSagaSignalDispatcher} throws on a blank value
|
|
58
|
+
* before sending.
|
|
59
|
+
*/
|
|
60
|
+
signalId?: string;
|
|
61
61
|
}
|
|
62
|
-
interface TemporalSignalClient {
|
|
63
|
-
|
|
62
|
+
export interface TemporalSignalClient {
|
|
63
|
+
signal(workflowId: string, signalName: string, payload: unknown): Promise<void>;
|
|
64
64
|
}
|
|
65
|
-
declare function createSagaSignalDispatcher(client: TemporalSignalClient): (workflowId: string, envelope: SagaSignalEnvelope) => Promise<void>;
|
|
65
|
+
export declare function createSagaSignalDispatcher(client: TemporalSignalClient): (workflowId: string, envelope: SagaSignalEnvelope) => Promise<void>;
|
|
66
66
|
/** Serializable inbox state, as returned by {@link SagaSignalInbox.snapshot}. */
|
|
67
|
-
interface SagaSignalInboxSnapshot {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
export interface SagaSignalInboxSnapshot {
|
|
68
|
+
/** Signal IDs already received, so a redelivery after the handover is still dropped. */
|
|
69
|
+
seenSignalIds: string[];
|
|
70
|
+
/** Envelopes received but not yet taken, FIFO within each signal name. */
|
|
71
|
+
pending: SagaSignalEnvelope[];
|
|
72
72
|
}
|
|
73
|
-
interface SagaSignalInboxOptions {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
export interface SagaSignalInboxOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Signal IDs already received by an earlier run of this saga. Prefer passing a
|
|
76
|
+
* whole {@link SagaSignalInbox.snapshot}: carrying IDs without `pending` drops
|
|
77
|
+
* any envelope that was accepted but not yet taken.
|
|
78
|
+
*/
|
|
79
|
+
seenSignalIds?: readonly string[];
|
|
80
|
+
/**
|
|
81
|
+
* Envelopes an earlier run accepted but did not take. They are buffered again
|
|
82
|
+
* in order without a dedup check, since they were already accepted once.
|
|
83
|
+
*/
|
|
84
|
+
pending?: readonly SagaSignalEnvelope[];
|
|
85
85
|
}
|
|
86
|
-
interface SagaSignalInbox {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
export interface SagaSignalInbox {
|
|
87
|
+
/**
|
|
88
|
+
* Buffers the envelope at the back of the queue for its signal name and returns
|
|
89
|
+
* `true`. Returns `false` and drops the envelope when its `signalId` was already
|
|
90
|
+
* received by this inbox under any signal name. An envelope without a `signalId`
|
|
91
|
+
* (or with a blank one) is buffered and not remembered.
|
|
92
|
+
*/
|
|
93
|
+
receive(envelope: SagaSignalEnvelope): boolean;
|
|
94
|
+
/** Removes and returns the oldest buffered envelope for `signalName`, or `undefined` when none is buffered. */
|
|
95
|
+
take<T = unknown>(signalName: string): SagaSignalEnvelope<T> | undefined;
|
|
96
|
+
/** Number of envelopes buffered for `signalName`, for use in `condition(() => inbox.pending(name) > 0, timeout)`. */
|
|
97
|
+
pending(signalName: string): number;
|
|
98
|
+
/** Signal IDs received so far, carried-forward ones first, in the order they were first received. */
|
|
99
|
+
seenSignalIds(): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Copies the seen IDs and every buffered envelope. Pass it into the next run across
|
|
102
|
+
* continue-as-new and hand it back to `createSagaSignalInbox()`, so neither a
|
|
103
|
+
* redelivery nor an accepted-but-untaken signal is lost.
|
|
104
|
+
*/
|
|
105
|
+
snapshot(): SagaSignalInboxSnapshot;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Deterministic receiver for saga signals. It has no Temporal dependency and reads
|
|
@@ -117,121 +117,121 @@ interface SagaSignalInbox {
|
|
|
117
117
|
* with each distinct `signalId` and is not pruned, including across
|
|
118
118
|
* continue-as-new, because forgetting an ID would let its redelivery through.
|
|
119
119
|
*/
|
|
120
|
-
declare function createSagaSignalInbox(options?: SagaSignalInboxOptions): SagaSignalInbox;
|
|
121
|
-
interface WorkflowStartClient<THandle = unknown> {
|
|
122
|
-
|
|
123
|
-
workflowType: string;
|
|
124
|
-
workflowId: string;
|
|
125
|
-
taskQueue: string;
|
|
126
|
-
args: unknown[];
|
|
127
|
-
idConflictPolicy: "use_existing";
|
|
128
|
-
}): Promise<THandle>;
|
|
129
|
-
}
|
|
130
|
-
declare function startGovernedWorkflow<THandle>(client: WorkflowStartClient<THandle>, input: {
|
|
120
|
+
export declare function createSagaSignalInbox(options?: SagaSignalInboxOptions): SagaSignalInbox;
|
|
121
|
+
export interface WorkflowStartClient<THandle = unknown> {
|
|
122
|
+
start(input: {
|
|
131
123
|
workflowType: string;
|
|
132
124
|
workflowId: string;
|
|
133
125
|
taskQueue: string;
|
|
134
126
|
args: unknown[];
|
|
127
|
+
idConflictPolicy: "use_existing";
|
|
128
|
+
}): Promise<THandle>;
|
|
129
|
+
}
|
|
130
|
+
export declare function startGovernedWorkflow<THandle>(client: WorkflowStartClient<THandle>, input: {
|
|
131
|
+
workflowType: string;
|
|
132
|
+
workflowId: string;
|
|
133
|
+
taskQueue: string;
|
|
134
|
+
args: unknown[];
|
|
135
135
|
}): Promise<THandle>;
|
|
136
|
-
interface SagaWorkflowBinding {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
export interface SagaWorkflowBinding {
|
|
137
|
+
actionId: `${string}.${string}`;
|
|
138
|
+
workflowType: string;
|
|
139
|
+
taskQueue: string;
|
|
140
140
|
}
|
|
141
141
|
/** Instance-scoped registry; registration order never changes resolution. */
|
|
142
|
-
declare class SagaWorkflowRegistry {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
export declare class SagaWorkflowRegistry {
|
|
143
|
+
private readonly bindings;
|
|
144
|
+
constructor(bindings?: readonly SagaWorkflowBinding[]);
|
|
145
|
+
register(binding: SagaWorkflowBinding): void;
|
|
146
|
+
require(actionId: string): SagaWorkflowBinding;
|
|
147
147
|
}
|
|
148
|
-
interface TemporalSagaDispatchInput {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
export interface TemporalSagaDispatchInput {
|
|
149
|
+
actionInvocationId: string;
|
|
150
|
+
actionId: `${string}.${string}`;
|
|
151
|
+
tenantId: string;
|
|
152
|
+
spaceId: string;
|
|
153
|
+
workflowId: string;
|
|
154
154
|
}
|
|
155
155
|
/** Starts the registered parent workflow with an invocation-only durable identity. */
|
|
156
|
-
declare function createTemporalSagaDispatcher<THandle>(client: WorkflowStartClient<THandle>, registry: SagaWorkflowRegistry): {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
export declare function createTemporalSagaDispatcher<THandle>(client: WorkflowStartClient<THandle>, registry: SagaWorkflowRegistry): {
|
|
157
|
+
dispatch: (input: TemporalSagaDispatchInput) => Promise<{
|
|
158
|
+
runId?: string | undefined;
|
|
159
|
+
workflowId: string;
|
|
160
|
+
}>;
|
|
161
161
|
};
|
|
162
162
|
/** Durable record of a single step completing within a saga parent. */
|
|
163
|
-
interface SagaParentProgressRecord {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
export interface SagaParentProgressRecord {
|
|
164
|
+
/** The step that just completed. */
|
|
165
|
+
stepId: string;
|
|
166
|
+
/** Zero-based position of this step in the declared sequence. */
|
|
167
|
+
index: number;
|
|
168
|
+
/** Total steps declared for this saga. */
|
|
169
|
+
total: number;
|
|
170
|
+
/** ISO-8601 timestamp the progress was recorded. */
|
|
171
|
+
completedAt: string;
|
|
172
172
|
}
|
|
173
|
-
interface SagaParentProgressInput {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
export interface SagaParentProgressInput {
|
|
174
|
+
parentInvocationId: string;
|
|
175
|
+
tenantId: string;
|
|
176
|
+
spaceId: string;
|
|
177
|
+
/** Stable identity shared by every retry of this lifecycle transition. */
|
|
178
|
+
lifecycleId?: string;
|
|
179
|
+
progress: SagaParentProgressRecord;
|
|
180
180
|
}
|
|
181
|
-
interface SagaParentApprovalInput {
|
|
181
|
+
export interface SagaParentApprovalInput {
|
|
182
|
+
parentInvocationId: string;
|
|
183
|
+
tenantId: string;
|
|
184
|
+
spaceId: string;
|
|
185
|
+
/** Stable identity shared by every retry of this lifecycle transition. */
|
|
186
|
+
lifecycleId?: string;
|
|
187
|
+
/** The step at which the saga paused for human approval. */
|
|
188
|
+
stepId: string;
|
|
189
|
+
/** Stable identifier for the approval gate, so a later signal can resume it. */
|
|
190
|
+
approvalId: string;
|
|
191
|
+
reason: string;
|
|
192
|
+
}
|
|
193
|
+
export interface SagaParentCancellationInput {
|
|
194
|
+
parentInvocationId: string;
|
|
195
|
+
tenantId: string;
|
|
196
|
+
spaceId: string;
|
|
197
|
+
/** Stable identity shared by every retry of this lifecycle transition. */
|
|
198
|
+
lifecycleId?: string;
|
|
199
|
+
reason: string;
|
|
200
|
+
/** Actor requesting the cancellation, for audit attribution. */
|
|
201
|
+
actorId: string;
|
|
202
|
+
}
|
|
203
|
+
export interface SagaParentLifecycle {
|
|
204
|
+
/** Record durable progress as each step completes. */
|
|
205
|
+
recordProgress(input: SagaParentProgressInput): Promise<void>;
|
|
206
|
+
/** Park the parent for human approval at a specific step. */
|
|
207
|
+
parkApproval(input: SagaParentApprovalInput): Promise<void>;
|
|
208
|
+
/** Cancel the parent saga with an attributable reason. */
|
|
209
|
+
cancel(input: SagaParentCancellationInput): Promise<void>;
|
|
210
|
+
/** Complete the parent saga with its final result. */
|
|
211
|
+
complete(input: {
|
|
182
212
|
parentInvocationId: string;
|
|
183
213
|
tenantId: string;
|
|
184
214
|
spaceId: string;
|
|
185
|
-
/** Stable identity shared by every retry of this lifecycle transition. */
|
|
186
215
|
lifecycleId?: string;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
reason: string;
|
|
192
|
-
}
|
|
193
|
-
interface SagaParentCancellationInput {
|
|
216
|
+
result: Record<string, unknown>;
|
|
217
|
+
}): Promise<void>;
|
|
218
|
+
/** Fail the parent saga, surfacing any compensation records. */
|
|
219
|
+
fail(input: {
|
|
194
220
|
parentInvocationId: string;
|
|
195
221
|
tenantId: string;
|
|
196
222
|
spaceId: string;
|
|
197
|
-
/** Stable identity shared by every retry of this lifecycle transition. */
|
|
198
223
|
lifecycleId?: string;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
interface SagaParentLifecycle {
|
|
204
|
-
/** Record durable progress as each step completes. */
|
|
205
|
-
recordProgress(input: SagaParentProgressInput): Promise<void>;
|
|
206
|
-
/** Park the parent for human approval at a specific step. */
|
|
207
|
-
parkApproval(input: SagaParentApprovalInput): Promise<void>;
|
|
208
|
-
/** Cancel the parent saga with an attributable reason. */
|
|
209
|
-
cancel(input: SagaParentCancellationInput): Promise<void>;
|
|
210
|
-
/** Complete the parent saga with its final result. */
|
|
211
|
-
complete(input: {
|
|
212
|
-
parentInvocationId: string;
|
|
213
|
-
tenantId: string;
|
|
214
|
-
spaceId: string;
|
|
215
|
-
lifecycleId?: string;
|
|
216
|
-
result: Record<string, unknown>;
|
|
217
|
-
}): Promise<void>;
|
|
218
|
-
/** Fail the parent saga, surfacing any compensation records. */
|
|
219
|
-
fail(input: {
|
|
220
|
-
parentInvocationId: string;
|
|
221
|
-
tenantId: string;
|
|
222
|
-
spaceId: string;
|
|
223
|
-
lifecycleId?: string;
|
|
224
|
-
error: string;
|
|
225
|
-
compensation: CompensationRecord[];
|
|
226
|
-
}): Promise<void>;
|
|
224
|
+
error: string;
|
|
225
|
+
compensation: CompensationRecord[];
|
|
226
|
+
}): Promise<void>;
|
|
227
227
|
}
|
|
228
228
|
/** Parent lifecycle remains explicit durable activities, never workflow-local state. */
|
|
229
|
-
declare function createSagaParentActivities(lifecycle: SagaParentLifecycle): {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
229
|
+
export declare function createSagaParentActivities(lifecycle: SagaParentLifecycle): {
|
|
230
|
+
recordSagaProgress: (input: SagaParentProgressInput) => Promise<void>;
|
|
231
|
+
parkSagaApproval: (input: SagaParentApprovalInput) => Promise<void>;
|
|
232
|
+
cancelSagaParent: (input: SagaParentCancellationInput) => Promise<void>;
|
|
233
|
+
completeSagaParent: (input: Parameters<SagaParentLifecycle["complete"]>[0]) => Promise<void>;
|
|
234
|
+
failSagaParent: (input: Parameters<SagaParentLifecycle["fail"]>[0]) => Promise<void>;
|
|
235
235
|
};
|
|
236
236
|
/**
|
|
237
237
|
* Stable identity for a saga parent's own lifecycle activity (progress,
|
|
@@ -239,96 +239,96 @@ declare function createSagaParentActivities(lifecycle: SagaParentLifecycle): {
|
|
|
239
239
|
* is namespaced under `parent:` so it can never collide with a forward step or
|
|
240
240
|
* a `compensate:` reversal.
|
|
241
241
|
*/
|
|
242
|
-
declare function sagaParentActivityIdentity(workflowId: string, activity: SagaParentActivityKind, discriminator?: string): {
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
export declare function sagaParentActivityIdentity(workflowId: string, activity: SagaParentActivityKind, discriminator?: string): {
|
|
243
|
+
idempotencyKey: string;
|
|
244
|
+
correlationId: string;
|
|
245
245
|
};
|
|
246
|
-
type SagaParentActivityKind = "progress" | "approval" | "cancel" | "complete" | "fail";
|
|
246
|
+
export type SagaParentActivityKind = "progress" | "approval" | "cancel" | "complete" | "fail";
|
|
247
247
|
/**
|
|
248
248
|
* Stable causation identity linking a child step to its parent invocation.
|
|
249
249
|
* The parent invocation ID becomes the causation ID; the step keeps its own
|
|
250
250
|
* deterministic idempotency key and shares the workflow correlation ID.
|
|
251
251
|
*/
|
|
252
|
-
declare function sagaChildCausation(workflowId: string, parentInvocationId: string, stepId: string): {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
export declare function sagaChildCausation(workflowId: string, parentInvocationId: string, stepId: string): {
|
|
253
|
+
causationId: string;
|
|
254
|
+
idempotencyKey: string;
|
|
255
|
+
correlationId: string;
|
|
256
256
|
};
|
|
257
257
|
/** Stable signal names a saga workflow may register handlers for. */
|
|
258
|
-
declare const SAGA_SIGNALS: {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
export declare const SAGA_SIGNALS: {
|
|
259
|
+
readonly proceed: "saga.proceed";
|
|
260
|
+
readonly cancel: "saga.cancel";
|
|
261
|
+
readonly approval: "saga.approval";
|
|
262
262
|
};
|
|
263
263
|
/** Adapts the official Temporal TypeScript `WorkflowClient` to the narrow testable binding seam. */
|
|
264
|
-
declare function temporalWorkflowStartClient(client: WorkflowClient): WorkflowStartClient;
|
|
265
|
-
interface WorkerVersionEvidence {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
export declare function temporalWorkflowStartClient(client: WorkflowClient): WorkflowStartClient;
|
|
265
|
+
export interface WorkerVersionEvidence {
|
|
266
|
+
buildId: string;
|
|
267
|
+
deploymentName: string;
|
|
268
|
+
rampPercent?: number;
|
|
269
269
|
}
|
|
270
|
-
declare function assertWorkerVersionEvidence(value: WorkerVersionEvidence): void;
|
|
271
|
-
interface CompensatedStep {
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
export declare function assertWorkerVersionEvidence(value: WorkerVersionEvidence): void;
|
|
271
|
+
export interface CompensatedStep {
|
|
272
|
+
/** Workflow-local step identity. Must match the compensation declared in the module manifest. */
|
|
273
|
+
stepId: string;
|
|
274
|
+
actionId: string;
|
|
275
|
+
parameters: Record<string, unknown>;
|
|
276
|
+
/**
|
|
277
|
+
* Governed action that reverses this step's effect. Omit for a step with
|
|
278
|
+
* nothing to undo; a step whose effect is externally visible should declare one.
|
|
279
|
+
*/
|
|
280
|
+
compensateWith?: {
|
|
274
281
|
actionId: string;
|
|
275
|
-
parameters
|
|
276
|
-
|
|
277
|
-
* Governed action that reverses this step's effect. Omit for a step with
|
|
278
|
-
* nothing to undo; a step whose effect is externally visible should declare one.
|
|
279
|
-
*/
|
|
280
|
-
compensateWith?: {
|
|
281
|
-
actionId: string;
|
|
282
|
-
parameters?: Record<string, unknown>;
|
|
283
|
-
};
|
|
282
|
+
parameters?: Record<string, unknown>;
|
|
283
|
+
};
|
|
284
284
|
}
|
|
285
|
-
interface CompensatedSagaInput {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
285
|
+
export interface CompensatedSagaInput {
|
|
286
|
+
workflowId: string;
|
|
287
|
+
runId: string;
|
|
288
|
+
steps: CompensatedStep[];
|
|
289
|
+
tenantId: string;
|
|
290
|
+
spaceId: string;
|
|
291
|
+
actorId: string;
|
|
292
|
+
actorType: ActorType;
|
|
293
|
+
parentInvocationId?: string;
|
|
294
|
+
/** When supplied, every step's reversal must match what the manifest declares. */
|
|
295
|
+
workflow?: DeclaredWorkflow;
|
|
296
296
|
}
|
|
297
|
-
interface CompensationRecord {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
export interface CompensationRecord {
|
|
298
|
+
stepId: string;
|
|
299
|
+
actionId: string;
|
|
300
|
+
/** Present when the reversal itself failed; the saga surfaces it rather than swallowing it. */
|
|
301
|
+
error?: string;
|
|
302
302
|
}
|
|
303
|
-
interface CompensatedSagaResult {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
303
|
+
export interface CompensatedSagaResult {
|
|
304
|
+
completed: string[];
|
|
305
|
+
compensated: CompensationRecord[];
|
|
306
|
+
failedStep?: {
|
|
307
|
+
stepId: string;
|
|
308
|
+
error: string;
|
|
309
|
+
};
|
|
310
310
|
}
|
|
311
311
|
/** Reversals are governed invocations too, so they carry their own stable identity. */
|
|
312
|
-
declare function compensationInvocationIdentity(input: {
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
export declare function compensationInvocationIdentity(input: {
|
|
313
|
+
workflowId: string;
|
|
314
|
+
stepId: string;
|
|
315
315
|
}): {
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
idempotencyKey: string;
|
|
317
|
+
correlationId: string;
|
|
318
318
|
};
|
|
319
|
-
declare class SagaCompensationError extends Error {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
export declare class SagaCompensationError extends Error {
|
|
320
|
+
readonly result: CompensatedSagaResult;
|
|
321
|
+
readonly name = "SagaCompensationError";
|
|
322
|
+
constructor(result: CompensatedSagaResult);
|
|
323
323
|
}
|
|
324
324
|
type GovernedActivity = ReturnType<typeof createGovernedActionActivities>["invokeGovernedAction"];
|
|
325
325
|
/** The manifest declaration this saga is expected to honour, when one is supplied. */
|
|
326
|
-
interface DeclaredWorkflow {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
326
|
+
export interface DeclaredWorkflow {
|
|
327
|
+
name: string;
|
|
328
|
+
compensations?: Array<{
|
|
329
|
+
step: string;
|
|
330
|
+
actionId: string;
|
|
331
|
+
}>;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
334
|
* Runs steps in order, accumulating reversals as each succeeds. On failure the
|
|
@@ -336,6 +336,6 @@ interface DeclaredWorkflow {
|
|
|
336
336
|
* Every forward step and every reversal enters through the governed Host with a
|
|
337
337
|
* deterministic idempotency key, so a retried or replayed unwind is not double-applied.
|
|
338
338
|
*/
|
|
339
|
-
declare function runCompensatedSaga(activity: GovernedActivity, input: CompensatedSagaInput): Promise<CompensatedSagaResult>;
|
|
340
|
-
|
|
341
|
-
export {
|
|
339
|
+
export declare function runCompensatedSaga(activity: GovernedActivity, input: CompensatedSagaInput): Promise<CompensatedSagaResult>;
|
|
340
|
+
//#endregion
|
|
341
|
+
export {};
|