@fluidgrids/workflows 2026.1028.2 → 2026.1030.1
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/README.md +181 -11
- package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
- package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
- package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
- package/dist/chunk-3U2NU7YC.cjs +124 -0
- package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
- package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
- package/dist/chunk-5HIVIV53.js +330 -0
- package/dist/chunk-5MFVJM76.js +1222 -0
- package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
- package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
- package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
- package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
- package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
- package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
- package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
- package/dist/chunk-C4F5KJTI.js +293 -0
- package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
- package/dist/chunk-GEQDGUGB.cjs +2719 -0
- package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
- package/dist/chunk-HMZUGSMU.cjs +1554 -0
- package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
- package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
- package/dist/chunk-JSC75O5C.cjs +167 -0
- package/dist/chunk-M272AHEX.js +25 -0
- package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
- package/dist/chunk-ODZ2IAR2.cjs +1247 -0
- package/dist/chunk-Q4MWQNJK.cjs +28 -0
- package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
- package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
- package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
- package/dist/chunk-VA4OFR72.cjs +324 -0
- package/dist/chunk-VU5S5A7V.js +150 -0
- package/dist/chunk-YEHR4NNE.js +1522 -0
- package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/collect-6NIEufHd.d.ts +103 -0
- package/dist/collect-CcTCKqx6.d.cts +103 -0
- package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
- package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
- package/dist/history/index.cjs +375 -86
- package/dist/history/index.d.cts +590 -12
- package/dist/history/index.d.ts +590 -12
- package/dist/history/index.js +50 -4
- package/dist/index.cjs +156 -50
- package/dist/index.d.cts +38 -58
- package/dist/index.d.ts +38 -58
- package/dist/index.js +6 -4
- package/dist/interceptors-CNcr2dlk.d.ts +159 -0
- package/dist/interceptors-CqkNZVfI.d.cts +159 -0
- package/dist/ir/index.cjs +362 -38
- package/dist/ir/index.d.cts +282 -7
- package/dist/ir/index.d.ts +282 -7
- package/dist/ir/index.js +329 -23
- package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
- package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
- package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
- package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
- package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
- package/dist/node-evaluator-LEEVD7H7.js +14 -0
- package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
- package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
- package/dist/quickjs/index.cjs +28 -27
- package/dist/quickjs/index.d.cts +6 -6
- package/dist/quickjs/index.d.ts +6 -6
- package/dist/quickjs/index.js +10 -9
- package/dist/roundtrip/index.cjs +259 -51
- package/dist/roundtrip/index.d.cts +100 -9
- package/dist/roundtrip/index.d.ts +100 -9
- package/dist/roundtrip/index.js +177 -11
- package/dist/runtime/index.cjs +21 -20
- package/dist/runtime/index.d.cts +184 -15
- package/dist/runtime/index.d.ts +184 -15
- package/dist/runtime/index.js +8 -7
- package/dist/testing/index.cjs +1122 -115
- package/dist/testing/index.d.cts +294 -13
- package/dist/testing/index.d.ts +294 -13
- package/dist/testing/index.js +1086 -84
- package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
- package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
- package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
- package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
- package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
- package/dist/workflow-BGnv8SS6.d.ts +803 -0
- package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
- package/dist/workflow-DS32Gtws.d.cts +803 -0
- package/fixtures/histories/activity-options-updated.history.json +159 -0
- package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
- package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
- package/fixtures/histories/benign-failure.history.json +146 -0
- package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
- package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
- package/fixtures/histories/child-options-roundtrip.history.json +192 -0
- package/fixtures/histories/codec-opaque.history.json +229 -0
- package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
- package/fixtures/histories/continue-as-new-options.history.json +99 -0
- package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
- package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
- package/fixtures/histories/dynamic-workflow.history.json +150 -0
- package/fixtures/histories/execution-timeout-chain.history.json +98 -0
- package/fixtures/histories/external-cancel-resolved.history.json +123 -0
- package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
- package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
- package/fixtures/histories/handler-drain-warn.history.json +222 -0
- package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
- package/fixtures/histories/interceptor-headers.history.json +339 -0
- package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
- package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
- package/fixtures/histories/local-activity-completed.history.json +157 -0
- package/fixtures/histories/local-activity-failed.history.json +93 -0
- package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
- package/fixtures/histories/query-custom.history.json +213 -0
- package/fixtures/histories/query-default-handler.history.json +120 -0
- package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
- package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
- package/fixtures/histories/run-retry-last-failure.history.json +90 -0
- package/fixtures/histories/run-timeout.history.json +159 -0
- package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
- package/fixtures/histories/search-attributes-upserted.history.json +177 -0
- package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
- package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
- package/fixtures/histories/update-accepted-completed.history.json +45 -30
- package/fixtures/histories/update-default-handler.history.json +246 -0
- package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
- package/fixtures/histories/update-not-handled.history.json +138 -0
- package/fixtures/histories/update-rejected-no-event.history.json +190 -0
- package/fixtures/histories/update-with-start-admitted.history.json +150 -0
- package/fixtures/histories/user-activity-cancel.history.json +149 -0
- package/fixtures/histories/user-activity-retry.history.json +143 -0
- package/fixtures/histories/user-activity.history.json +149 -0
- package/package.json +1 -1
- package/schema/bridge-v2.schema.json +1062 -0
- package/schema/history-file.schema.json +538 -83
- package/schema/ir-v2.schema.json +290 -0
- package/schema/payload-fields.json +162 -0
- package/schema/run-event.schema.json +503 -82
- package/schema/workflow-command.schema.json +372 -69
- package/schema/workflow-task.schema.json +924 -171
- package/dist/assemble-BLqQ8lSu.d.cts +0 -39
- package/dist/assemble-DWgaXHd-.d.ts +0 -39
- package/dist/chunk-DHTLALBL.cjs +0 -80
- package/dist/chunk-DJYMDLV5.js +0 -227
- package/dist/chunk-I5LR3D2K.js +0 -869
- package/dist/chunk-M4BBAERY.cjs +0 -1635
- package/dist/chunk-N23SKIG4.js +0 -73
- package/dist/chunk-PZCVF76Q.cjs +0 -868
- package/dist/chunk-QQ6ULXHI.cjs +0 -885
- package/dist/chunk-UK3WM7YZ.cjs +0 -75
- package/dist/chunk-VOKMAAJP.js +0 -848
- package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
- package/dist/node-evaluator-SX4LEYQC.js +0 -12
- package/dist/workflow-C2a05WUJ.d.ts +0 -444
- package/dist/workflow-J-yYixny.d.cts +0 -444
package/dist/runtime/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { a as
|
|
1
|
+
import { k as WorkflowInterceptorsFactory } from '../interceptors-CqkNZVfI.cjs';
|
|
2
|
+
import { W as WorkflowContext, v as DurableWorkflow, U as UpdateDefinition, K as UpdateHandlerOptions, t as DefaultUpdateHandlerOptions, Q as QueryDefinition, C as CancellationScope, O as Operation, R as RunOptions, e as ActivityDefinition, k as ActivityOptions, z as LocalActivityOptions, x as Duration, G as SignalDefinition, I as SignalHandlerOptions, y as ExternalRunTarget, E as ExternalRunHandle, q as ChildTarget, p as ChildOptions, o as ChildHandle, r as ContinueAsNewOptions, n as CancellationScopeOptions } from '../workflow-DS32Gtws.cjs';
|
|
3
|
+
export { A as Activation, s as splitActivations } from '../activation-DqUfpHzk.cjs';
|
|
4
|
+
import { W as WorkflowCommand, R as RunEventRecord, az as WorkflowTaskRequest, aA as WorkflowTaskResult, a as WorkflowTaskFailureCause, ad as RunTarget, M as Headers } from '../types-Bv2i4cBX.cjs';
|
|
5
|
+
import { a as Json, J as JsonObject } from '../types-V7jEEUaL.cjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Determinism shims for workflow tasks (C-ABI, spec 04 §4).
|
|
@@ -51,10 +52,12 @@ declare function uuidFrom(random: () => number): string;
|
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
54
|
* Replay matching (spec 04 §4): each command a replayed activation issues must
|
|
54
|
-
* match the command event recorded at the same position.
|
|
55
|
-
* id and `nodeType + operation`,
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* match the command event recorded at the same position. Node activities
|
|
56
|
+
* match on id and `nodeType + operation`, user activities (Phase C) on id,
|
|
57
|
+
* `kind` and `activityName`, children on id and target, updates on id,
|
|
58
|
+
* everything else on type and id. A recorded patch marker that the code no
|
|
59
|
+
* longer issues is skipped (the patch was deprecated and removed, spec 06 §4).
|
|
60
|
+
* `REJECT_UPDATE` appends no event (11 §2.39), so it is not matched.
|
|
58
61
|
*/
|
|
59
62
|
|
|
60
63
|
/** Why `command` does not match `event`, or undefined when it does. */
|
|
@@ -71,9 +74,10 @@ declare function matchActivation(commands: readonly WorkflowCommand[], recorded:
|
|
|
71
74
|
/**
|
|
72
75
|
* Command ids (C-HIST): one counter per kind, in issue order, so a replay that
|
|
73
76
|
* issues the same commands in the same order derives the same ids, and a
|
|
74
|
-
* reordered await is caught as a mismatch. Patch markers use `patch:<id
|
|
77
|
+
* reordered await is caught as a mismatch. Patch markers use `patch:<id>`;
|
|
78
|
+
* local activities (R2) use `l<n>`.
|
|
75
79
|
*/
|
|
76
|
-
type CommandIdKind = 'a' | 't' | 'c' | 's' | 'x' | 'm';
|
|
80
|
+
type CommandIdKind = 'a' | 't' | 'c' | 's' | 'x' | 'm' | 'l';
|
|
77
81
|
declare class CommandIds {
|
|
78
82
|
private readonly counters;
|
|
79
83
|
/** The next id of a kind: `a1`, `a2`, ... */
|
|
@@ -96,6 +100,14 @@ declare function isPatchMarkerId(markerId: string): boolean;
|
|
|
96
100
|
* finishes it: a replayed activation must have issued exactly the commands it
|
|
97
101
|
* recorded, and the open activation's commands are the task's result.
|
|
98
102
|
*
|
|
103
|
+
* Updates (C-ABI-H, spec 04 §2): the updates of activation k are delivered
|
|
104
|
+
* after its input events. A replayed activation re-delivers the updates its
|
|
105
|
+
* task accepted (`UPDATE_ACCEPTED` in its command block) without running
|
|
106
|
+
* their validators; the open activation delivers the lease's pending updates
|
|
107
|
+
* (`request.updates`) with validation. `UPDATE_ADMITTED` is an input event and
|
|
108
|
+
* is validated like a live request. An update no handler takes by the end of
|
|
109
|
+
* its activation is rejected (`UpdateNotHandled`).
|
|
110
|
+
*
|
|
99
111
|
* Pure JavaScript; it runs inside the isolate.
|
|
100
112
|
*/
|
|
101
113
|
|
|
@@ -105,7 +117,8 @@ declare const SDK_NAME = "@fluidgrids/workflows";
|
|
|
105
117
|
declare class ContinueAsNewRequest {
|
|
106
118
|
readonly input: Json;
|
|
107
119
|
readonly options: JsonObject;
|
|
108
|
-
|
|
120
|
+
readonly headers: Headers;
|
|
121
|
+
constructor(input: Json, options: JsonObject, headers?: Headers);
|
|
109
122
|
}
|
|
110
123
|
declare class Scope implements CancellationScope {
|
|
111
124
|
readonly parent: Scope | undefined;
|
|
@@ -132,6 +145,8 @@ interface ExecutionInput {
|
|
|
132
145
|
exportNames: ReadonlyMap<DurableWorkflow<never, unknown>, string>;
|
|
133
146
|
request: WorkflowTaskRequest;
|
|
134
147
|
sdkVersion: string;
|
|
148
|
+
/** The bundle's workflow interceptors (`interceptors` exports), in module order. */
|
|
149
|
+
interceptors?: readonly WorkflowInterceptorsFactory[];
|
|
135
150
|
}
|
|
136
151
|
/** One workflow task in progress. */
|
|
137
152
|
declare class WorkflowExecution {
|
|
@@ -144,7 +159,7 @@ declare class WorkflowExecution {
|
|
|
144
159
|
private activationOpen;
|
|
145
160
|
private replaying;
|
|
146
161
|
private clock;
|
|
147
|
-
private readonly
|
|
162
|
+
private readonly randomSource;
|
|
148
163
|
private readonly ids;
|
|
149
164
|
private commands;
|
|
150
165
|
private newCommands;
|
|
@@ -183,7 +198,34 @@ declare class WorkflowExecution {
|
|
|
183
198
|
private readonly signalHandlers;
|
|
184
199
|
private readonly signalWaiters;
|
|
185
200
|
private defaultSignalHandler;
|
|
201
|
+
private defaultSignalPolicy;
|
|
202
|
+
private readonly signalPolicies;
|
|
186
203
|
private runningHandlers;
|
|
204
|
+
/** Running asynchronous handlers by name, for the drain warning (11 §2.18). */
|
|
205
|
+
private readonly running;
|
|
206
|
+
private unfinished;
|
|
207
|
+
/** Updates delivered so far, by id (an update is delivered at most once per task). */
|
|
208
|
+
private readonly deliveredUpdates;
|
|
209
|
+
/** Updates delivered in the current activation without a handler yet. */
|
|
210
|
+
private bufferedUpdates;
|
|
211
|
+
private readonly updateHandlers;
|
|
212
|
+
private defaultUpdateHandler;
|
|
213
|
+
private readonly queryHandlers;
|
|
214
|
+
private defaultQueryHandler;
|
|
215
|
+
/** Set while a query handler or an update validator runs: commands and sinks throw. */
|
|
216
|
+
private readOnly;
|
|
217
|
+
/** The first state-changing call a read-only handler made, even when it caught the error. */
|
|
218
|
+
private readOnlyViolation;
|
|
219
|
+
private searchAttributes;
|
|
220
|
+
private readonly startHeaders;
|
|
221
|
+
private readonly inbound;
|
|
222
|
+
private readonly outbound;
|
|
223
|
+
private sinkCalls;
|
|
224
|
+
private sinkCallsDropped;
|
|
225
|
+
private readonly recordedLocalActivities;
|
|
226
|
+
private readonly localActivityResults;
|
|
227
|
+
private readonly localActivities;
|
|
228
|
+
private memo;
|
|
187
229
|
private conditions;
|
|
188
230
|
private currentDetails;
|
|
189
231
|
readonly context: WorkflowContext;
|
|
@@ -192,23 +234,93 @@ declare class WorkflowExecution {
|
|
|
192
234
|
private continueAsNewSuggested;
|
|
193
235
|
/** The workflow clock. */
|
|
194
236
|
now(): number;
|
|
195
|
-
/** The next deterministic random number. */
|
|
237
|
+
/** The next deterministic random number (`Math.random()` and `crypto.getRandomValues()`). */
|
|
196
238
|
nextRandom(): number;
|
|
239
|
+
/** `ctx.random()`: advances the run's random source, so read-only handlers may not call it. */
|
|
240
|
+
private random;
|
|
241
|
+
/**
|
|
242
|
+
* Throw `QueryHandlerSideEffect` when a query handler or an update validator
|
|
243
|
+
* calls something that changes the run's deterministic state (the random
|
|
244
|
+
* source, the command id counters, patches, details). Validators are not run
|
|
245
|
+
* again on replay, and a worker that keeps a run's state between tasks keeps
|
|
246
|
+
* whatever a query handler changed, so either would make the next replay
|
|
247
|
+
* diverge. The violation is remembered, so catching the error does not hide it.
|
|
248
|
+
*/
|
|
249
|
+
private assertWritable;
|
|
250
|
+
/** The next command id of a kind; refused in read-only handlers (it advances a counter). */
|
|
251
|
+
private nextId;
|
|
197
252
|
/** Begin or finish an activation; `done` when there is nothing left to do. */
|
|
198
253
|
step(): 'more' | 'done';
|
|
199
254
|
/** The task's result. Call after `step()` returned `done` and jobs were drained. */
|
|
200
255
|
complete(): WorkflowTaskResult;
|
|
256
|
+
/**
|
|
257
|
+
* The local activities the open activation waits for, when the task is a
|
|
258
|
+
* workflow task that has not failed or closed the run (a run that ends
|
|
259
|
+
* abandons a local activity it did not await).
|
|
260
|
+
*/
|
|
261
|
+
private pendingLocalActivityRequests;
|
|
201
262
|
/** Fail the task (the runtime's own failures and code errors). */
|
|
202
263
|
failTask(cause: WorkflowTaskFailureCause, message: string, stackTrace?: string, seq?: number, errorType?: string): void;
|
|
203
264
|
private beginActivation;
|
|
265
|
+
/**
|
|
266
|
+
* The updates an activation delivers after its inputs (C-ABI-H): a replayed
|
|
267
|
+
* activation re-delivers the updates its task accepted (validators
|
|
268
|
+
* skipped); the open activation of a workflow task delivers the lease's
|
|
269
|
+
* pending updates. Updates history admitted (`UPDATE_ADMITTED`) arrive as
|
|
270
|
+
* inputs instead.
|
|
271
|
+
*/
|
|
272
|
+
private updatesOf;
|
|
204
273
|
private finishActivation;
|
|
274
|
+
/**
|
|
275
|
+
* A local activity issued on a replayed activation without a recorded
|
|
276
|
+
* outcome is fine only when the first execution dropped it in that same
|
|
277
|
+
* activation: its scope was cancelled (the entry is gone) or the run closed.
|
|
278
|
+
* One still waiting means the first execution would have requested and
|
|
279
|
+
* recorded it, so the code diverged from the history.
|
|
280
|
+
*/
|
|
281
|
+
private checkReplayedLocalActivities;
|
|
205
282
|
private deliver;
|
|
206
283
|
private expectIssued;
|
|
207
284
|
private settleActivity;
|
|
208
285
|
private settleChild;
|
|
286
|
+
/** Run a signal handler through the inbound `handleSignal` interceptors. */
|
|
287
|
+
private signalCall;
|
|
209
288
|
private dispatchSignal;
|
|
210
289
|
private takeBuffered;
|
|
211
290
|
private runHandler;
|
|
291
|
+
/** Count a running asynchronous handler (drain check, `allHandlersFinished`); returns its end. */
|
|
292
|
+
private trackHandler;
|
|
293
|
+
private deliverUpdate;
|
|
294
|
+
private updateHandlerFor;
|
|
295
|
+
/**
|
|
296
|
+
* Run `fn` with commands, sinks and every other change to the run's
|
|
297
|
+
* deterministic state refused (query handlers, update validators). A
|
|
298
|
+
* refused call fails the whole call with `QueryHandlerSideEffect`, even
|
|
299
|
+
* when the code caught the error it threw.
|
|
300
|
+
*/
|
|
301
|
+
private readOnlyCall;
|
|
302
|
+
/**
|
|
303
|
+
* Validate, accept and run one update. A validator error rejects it
|
|
304
|
+
* (`REJECT_UPDATE`, no history); otherwise `ACCEPT_UPDATE` is issued and
|
|
305
|
+
* the handler's result or failure completes it (`COMPLETE_UPDATE`). A
|
|
306
|
+
* handler that throws something other than a failure class fails the task,
|
|
307
|
+
* as a signal handler does.
|
|
308
|
+
*/
|
|
309
|
+
private runUpdate;
|
|
310
|
+
private completeUpdate;
|
|
311
|
+
/** Reject the updates of this activation that no handler took (`UpdateNotHandled`). */
|
|
312
|
+
private rejectUnhandledUpdates;
|
|
313
|
+
handleUpdate(update: UpdateDefinition<unknown, unknown> | string, handler: (args: unknown) => unknown, options?: UpdateHandlerOptions<unknown>): void;
|
|
314
|
+
setDefaultUpdateHandler(first: ((name: string, args: unknown) => unknown) | DefaultUpdateHandlerOptions, second?: ((name: string, args: unknown) => unknown) | DefaultUpdateHandlerOptions): void;
|
|
315
|
+
private dispatchBufferedUpdates;
|
|
316
|
+
handleQuery(query: QueryDefinition<unknown, unknown> | string, handler: (args: unknown) => unknown): void;
|
|
317
|
+
setDefaultQueryHandler(handler: (name: string, args: unknown) => unknown): void;
|
|
318
|
+
/**
|
|
319
|
+
* The drain check of 11 §2.18 when the workflow finishes: handlers still
|
|
320
|
+
* running with policy `WARN_AND_ABANDON` give one warning line and
|
|
321
|
+
* `unfinishedHandlers` in the result. A replay never reports them.
|
|
322
|
+
*/
|
|
323
|
+
private checkUnfinishedHandlers;
|
|
212
324
|
private startFunction;
|
|
213
325
|
private onReturn;
|
|
214
326
|
private isFailureType;
|
|
@@ -227,6 +339,24 @@ declare class WorkflowExecution {
|
|
|
227
339
|
private stack;
|
|
228
340
|
private never;
|
|
229
341
|
scheduleActivity<In, Out>(scope: Scope, operation: Operation<In, Out>, options: RunOptions<In>): Promise<Out>;
|
|
342
|
+
/**
|
|
343
|
+
* `ctx.activity` (Phase C): a user activity on a self-hosted task queue
|
|
344
|
+
* (`SCHEDULE_ACTIVITY` of kind `user`). The queue is the option, else the
|
|
345
|
+
* declaration's, else the run's own.
|
|
346
|
+
*/
|
|
347
|
+
userActivity<In, Out>(scope: Scope, activity: ActivityDefinition<In, Out> | string, options: ActivityOptions<In>): Promise<Out>;
|
|
348
|
+
/** Run the outbound `scheduleActivity` interceptors, then issue the command. */
|
|
349
|
+
private issueActivity;
|
|
350
|
+
private pushActivity;
|
|
351
|
+
/**
|
|
352
|
+
* `ctx.localActivity` (11 §2.12). A replayed activation returns the outcome
|
|
353
|
+
* its history recorded; the open activation takes the outcome the worker
|
|
354
|
+
* passed in `localActivityResults`, or asks for the local activity
|
|
355
|
+
* (`localActivityRequested`) and waits for the same task to run again.
|
|
356
|
+
* Either way the outcome is recorded with `RECORD_LOCAL_ACTIVITY` at the
|
|
357
|
+
* call, so a replay issues the same command at the same position.
|
|
358
|
+
*/
|
|
359
|
+
localActivity<In, Out>(scope: Scope, operation: unknown, options: LocalActivityOptions<In> | undefined): Promise<Out>;
|
|
230
360
|
startTimer(scope: Scope, durationMs: number, summary: string | undefined): Promise<void>;
|
|
231
361
|
/** Start a durable timer; `timerId` is undefined when no timer was needed or issued. */
|
|
232
362
|
private timer;
|
|
@@ -236,38 +366,71 @@ declare class WorkflowExecution {
|
|
|
236
366
|
/** Resolve conditions whose predicate now holds; true when any did. */
|
|
237
367
|
private checkConditions;
|
|
238
368
|
signalReceived<P>(scope: Scope, signal: SignalDefinition<P> | string): Promise<P>;
|
|
239
|
-
onSignal(signal: SignalDefinition<unknown> | string, handler: (payload: unknown) => unknown): void;
|
|
369
|
+
onSignal(signal: SignalDefinition<unknown> | string, handler: (payload: unknown) => unknown, options?: SignalHandlerOptions): void;
|
|
240
370
|
setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
|
|
371
|
+
/** The command target of a run handle (11 §2.1, §2.24). */
|
|
372
|
+
externalTarget(target: ExternalRunTarget): RunTarget;
|
|
373
|
+
runHandle(target: ExternalRunTarget): ExternalRunHandle;
|
|
241
374
|
private childTarget;
|
|
242
375
|
private childCommand;
|
|
376
|
+
/**
|
|
377
|
+
* Run the outbound `startChild` interceptors around a child start. `go`
|
|
378
|
+
* starts the child with the options the interceptors leave (input and
|
|
379
|
+
* headers).
|
|
380
|
+
*/
|
|
381
|
+
private interceptChild;
|
|
243
382
|
private startChildRun;
|
|
244
383
|
/** What cancelling the scope of a child's awaitable does (see `ChildOptions.cancellationType`). */
|
|
245
384
|
private onChildCancel;
|
|
246
385
|
child<Out>(scope: Scope, target: ChildTarget<Out>, options: ChildOptions): Promise<Out>;
|
|
247
386
|
private childResult;
|
|
248
387
|
startChild<Out>(scope: Scope, target: ChildTarget<Out>, options: ChildOptions): Promise<ChildHandle<Out>>;
|
|
388
|
+
private startChildHandle;
|
|
249
389
|
signalExternal(target: RunTarget, name: string, payload: unknown): Promise<void>;
|
|
390
|
+
private pushSignal;
|
|
250
391
|
cancelExternal(target: RunTarget): Promise<void>;
|
|
392
|
+
private pushCancel;
|
|
251
393
|
sideEffect<T extends Json>(fn: () => T): T;
|
|
394
|
+
private recordSideEffect;
|
|
252
395
|
patched(patchId: string, deprecated: boolean): boolean;
|
|
253
396
|
setCurrentDetails(markdown: string): void;
|
|
254
397
|
upsertContext(entries: JsonObject): void;
|
|
398
|
+
/** `ctx.upsertSearchAttributes` (Phase C): a null value removes an attribute. */
|
|
399
|
+
upsertSearchAttributes(attributes: JsonObject): void;
|
|
400
|
+
/** A `ctx.sinks.<sink>.<fn>(...args)` call: recorded once, never on replay (11 §2.31). */
|
|
401
|
+
private callSink;
|
|
402
|
+
private sinksProxy;
|
|
403
|
+
/** `ctx.continueAsNew`: a rejection with the request, after the outbound interceptors. */
|
|
404
|
+
continueAsNewCall(input: unknown, options: ContinueAsNewOptions): Promise<never>;
|
|
255
405
|
/** The request a `ctx.continueAsNew` call throws; the run ends with `CONTINUE_AS_NEW`. */
|
|
256
406
|
continueAsNew(input: unknown, options: ContinueAsNewOptions): ContinueAsNewRequest;
|
|
257
407
|
cancellationScope<T>(parent: Scope, fn: (ctx: WorkflowContext) => Promise<T>, options: CancellationScopeOptions): Promise<T>;
|
|
258
408
|
/** Waits for the signal handlers regardless of cancellation, as Temporal does. */
|
|
259
409
|
allHandlersFinished(): Promise<void>;
|
|
260
410
|
private pendingStacks;
|
|
411
|
+
/**
|
|
412
|
+
* Answer a custom query (Phase C): the handler registered for the name, else
|
|
413
|
+
* the default handler, run read-only through the inbound `handleQuery`
|
|
414
|
+
* interceptors. No handler gives `rejected`.
|
|
415
|
+
*/
|
|
416
|
+
private answerCustomQuery;
|
|
261
417
|
private answerQueries;
|
|
262
418
|
private contextFor;
|
|
263
419
|
}
|
|
264
420
|
|
|
265
421
|
/** The global a tier-2 bundle defines. */
|
|
266
422
|
declare const RUNTIME_GLOBAL = "__fluidgridsRuntime";
|
|
267
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* The runtime ABI, protocol 1. `capabilities` (C-ABI-H, from C-R1) lists what
|
|
425
|
+
* the runtime answers beyond Phase B: `updates`, `queries` (custom and default
|
|
426
|
+
* handlers) and `dynamic` (dynamic workflows and default handlers). A bundle
|
|
427
|
+
* built before C-R1 has none, and the service refuses updates and custom
|
|
428
|
+
* queries for its runs (DC4).
|
|
429
|
+
*/
|
|
268
430
|
interface FluidgridsRuntimeAbi {
|
|
269
431
|
readonly protocol: 1;
|
|
270
432
|
readonly sdkVersion: string;
|
|
433
|
+
readonly capabilities?: readonly string[];
|
|
271
434
|
start(requestJson: string): void;
|
|
272
435
|
step(): 'more' | 'done';
|
|
273
436
|
complete(): string;
|
|
@@ -278,6 +441,12 @@ interface WorkflowRegistry {
|
|
|
278
441
|
exportNames: ReadonlyMap<DurableWorkflow<never, unknown>, string>;
|
|
279
442
|
/** Export names declared by more than one module; starting one fails the task. */
|
|
280
443
|
ambiguous: ReadonlySet<string>;
|
|
444
|
+
/** The bundle's dynamic workflow (Phase C), which serves names no export has. */
|
|
445
|
+
dynamic?: DurableWorkflow<never, unknown>;
|
|
446
|
+
/** True when more than one dynamic workflow is exported; a dynamic start fails the task. */
|
|
447
|
+
dynamicAmbiguous?: boolean;
|
|
448
|
+
/** Workflow interceptor factories (`interceptors` exports), in module order. */
|
|
449
|
+
interceptors?: readonly WorkflowInterceptorsFactory[];
|
|
281
450
|
}
|
|
282
451
|
/** Build the registry from the bundle's modules (`[path, namespace]` pairs). */
|
|
283
452
|
declare function buildWorkflowRegistry(modules: ReadonlyArray<readonly [string, Record<string, unknown>]>): WorkflowRegistry;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { a as
|
|
1
|
+
import { k as WorkflowInterceptorsFactory } from '../interceptors-CNcr2dlk.js';
|
|
2
|
+
import { W as WorkflowContext, v as DurableWorkflow, U as UpdateDefinition, K as UpdateHandlerOptions, t as DefaultUpdateHandlerOptions, Q as QueryDefinition, C as CancellationScope, O as Operation, R as RunOptions, e as ActivityDefinition, k as ActivityOptions, z as LocalActivityOptions, x as Duration, G as SignalDefinition, I as SignalHandlerOptions, y as ExternalRunTarget, E as ExternalRunHandle, q as ChildTarget, p as ChildOptions, o as ChildHandle, r as ContinueAsNewOptions, n as CancellationScopeOptions } from '../workflow-BGnv8SS6.js';
|
|
3
|
+
export { A as Activation, s as splitActivations } from '../activation-xpx1oWuo.js';
|
|
4
|
+
import { W as WorkflowCommand, R as RunEventRecord, az as WorkflowTaskRequest, aA as WorkflowTaskResult, a as WorkflowTaskFailureCause, ad as RunTarget, M as Headers } from '../types-DGx-b9eq.js';
|
|
5
|
+
import { a as Json, J as JsonObject } from '../types-V7jEEUaL.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Determinism shims for workflow tasks (C-ABI, spec 04 §4).
|
|
@@ -51,10 +52,12 @@ declare function uuidFrom(random: () => number): string;
|
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
54
|
* Replay matching (spec 04 §4): each command a replayed activation issues must
|
|
54
|
-
* match the command event recorded at the same position.
|
|
55
|
-
* id and `nodeType + operation`,
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* match the command event recorded at the same position. Node activities
|
|
56
|
+
* match on id and `nodeType + operation`, user activities (Phase C) on id,
|
|
57
|
+
* `kind` and `activityName`, children on id and target, updates on id,
|
|
58
|
+
* everything else on type and id. A recorded patch marker that the code no
|
|
59
|
+
* longer issues is skipped (the patch was deprecated and removed, spec 06 §4).
|
|
60
|
+
* `REJECT_UPDATE` appends no event (11 §2.39), so it is not matched.
|
|
58
61
|
*/
|
|
59
62
|
|
|
60
63
|
/** Why `command` does not match `event`, or undefined when it does. */
|
|
@@ -71,9 +74,10 @@ declare function matchActivation(commands: readonly WorkflowCommand[], recorded:
|
|
|
71
74
|
/**
|
|
72
75
|
* Command ids (C-HIST): one counter per kind, in issue order, so a replay that
|
|
73
76
|
* issues the same commands in the same order derives the same ids, and a
|
|
74
|
-
* reordered await is caught as a mismatch. Patch markers use `patch:<id
|
|
77
|
+
* reordered await is caught as a mismatch. Patch markers use `patch:<id>`;
|
|
78
|
+
* local activities (R2) use `l<n>`.
|
|
75
79
|
*/
|
|
76
|
-
type CommandIdKind = 'a' | 't' | 'c' | 's' | 'x' | 'm';
|
|
80
|
+
type CommandIdKind = 'a' | 't' | 'c' | 's' | 'x' | 'm' | 'l';
|
|
77
81
|
declare class CommandIds {
|
|
78
82
|
private readonly counters;
|
|
79
83
|
/** The next id of a kind: `a1`, `a2`, ... */
|
|
@@ -96,6 +100,14 @@ declare function isPatchMarkerId(markerId: string): boolean;
|
|
|
96
100
|
* finishes it: a replayed activation must have issued exactly the commands it
|
|
97
101
|
* recorded, and the open activation's commands are the task's result.
|
|
98
102
|
*
|
|
103
|
+
* Updates (C-ABI-H, spec 04 §2): the updates of activation k are delivered
|
|
104
|
+
* after its input events. A replayed activation re-delivers the updates its
|
|
105
|
+
* task accepted (`UPDATE_ACCEPTED` in its command block) without running
|
|
106
|
+
* their validators; the open activation delivers the lease's pending updates
|
|
107
|
+
* (`request.updates`) with validation. `UPDATE_ADMITTED` is an input event and
|
|
108
|
+
* is validated like a live request. An update no handler takes by the end of
|
|
109
|
+
* its activation is rejected (`UpdateNotHandled`).
|
|
110
|
+
*
|
|
99
111
|
* Pure JavaScript; it runs inside the isolate.
|
|
100
112
|
*/
|
|
101
113
|
|
|
@@ -105,7 +117,8 @@ declare const SDK_NAME = "@fluidgrids/workflows";
|
|
|
105
117
|
declare class ContinueAsNewRequest {
|
|
106
118
|
readonly input: Json;
|
|
107
119
|
readonly options: JsonObject;
|
|
108
|
-
|
|
120
|
+
readonly headers: Headers;
|
|
121
|
+
constructor(input: Json, options: JsonObject, headers?: Headers);
|
|
109
122
|
}
|
|
110
123
|
declare class Scope implements CancellationScope {
|
|
111
124
|
readonly parent: Scope | undefined;
|
|
@@ -132,6 +145,8 @@ interface ExecutionInput {
|
|
|
132
145
|
exportNames: ReadonlyMap<DurableWorkflow<never, unknown>, string>;
|
|
133
146
|
request: WorkflowTaskRequest;
|
|
134
147
|
sdkVersion: string;
|
|
148
|
+
/** The bundle's workflow interceptors (`interceptors` exports), in module order. */
|
|
149
|
+
interceptors?: readonly WorkflowInterceptorsFactory[];
|
|
135
150
|
}
|
|
136
151
|
/** One workflow task in progress. */
|
|
137
152
|
declare class WorkflowExecution {
|
|
@@ -144,7 +159,7 @@ declare class WorkflowExecution {
|
|
|
144
159
|
private activationOpen;
|
|
145
160
|
private replaying;
|
|
146
161
|
private clock;
|
|
147
|
-
private readonly
|
|
162
|
+
private readonly randomSource;
|
|
148
163
|
private readonly ids;
|
|
149
164
|
private commands;
|
|
150
165
|
private newCommands;
|
|
@@ -183,7 +198,34 @@ declare class WorkflowExecution {
|
|
|
183
198
|
private readonly signalHandlers;
|
|
184
199
|
private readonly signalWaiters;
|
|
185
200
|
private defaultSignalHandler;
|
|
201
|
+
private defaultSignalPolicy;
|
|
202
|
+
private readonly signalPolicies;
|
|
186
203
|
private runningHandlers;
|
|
204
|
+
/** Running asynchronous handlers by name, for the drain warning (11 §2.18). */
|
|
205
|
+
private readonly running;
|
|
206
|
+
private unfinished;
|
|
207
|
+
/** Updates delivered so far, by id (an update is delivered at most once per task). */
|
|
208
|
+
private readonly deliveredUpdates;
|
|
209
|
+
/** Updates delivered in the current activation without a handler yet. */
|
|
210
|
+
private bufferedUpdates;
|
|
211
|
+
private readonly updateHandlers;
|
|
212
|
+
private defaultUpdateHandler;
|
|
213
|
+
private readonly queryHandlers;
|
|
214
|
+
private defaultQueryHandler;
|
|
215
|
+
/** Set while a query handler or an update validator runs: commands and sinks throw. */
|
|
216
|
+
private readOnly;
|
|
217
|
+
/** The first state-changing call a read-only handler made, even when it caught the error. */
|
|
218
|
+
private readOnlyViolation;
|
|
219
|
+
private searchAttributes;
|
|
220
|
+
private readonly startHeaders;
|
|
221
|
+
private readonly inbound;
|
|
222
|
+
private readonly outbound;
|
|
223
|
+
private sinkCalls;
|
|
224
|
+
private sinkCallsDropped;
|
|
225
|
+
private readonly recordedLocalActivities;
|
|
226
|
+
private readonly localActivityResults;
|
|
227
|
+
private readonly localActivities;
|
|
228
|
+
private memo;
|
|
187
229
|
private conditions;
|
|
188
230
|
private currentDetails;
|
|
189
231
|
readonly context: WorkflowContext;
|
|
@@ -192,23 +234,93 @@ declare class WorkflowExecution {
|
|
|
192
234
|
private continueAsNewSuggested;
|
|
193
235
|
/** The workflow clock. */
|
|
194
236
|
now(): number;
|
|
195
|
-
/** The next deterministic random number. */
|
|
237
|
+
/** The next deterministic random number (`Math.random()` and `crypto.getRandomValues()`). */
|
|
196
238
|
nextRandom(): number;
|
|
239
|
+
/** `ctx.random()`: advances the run's random source, so read-only handlers may not call it. */
|
|
240
|
+
private random;
|
|
241
|
+
/**
|
|
242
|
+
* Throw `QueryHandlerSideEffect` when a query handler or an update validator
|
|
243
|
+
* calls something that changes the run's deterministic state (the random
|
|
244
|
+
* source, the command id counters, patches, details). Validators are not run
|
|
245
|
+
* again on replay, and a worker that keeps a run's state between tasks keeps
|
|
246
|
+
* whatever a query handler changed, so either would make the next replay
|
|
247
|
+
* diverge. The violation is remembered, so catching the error does not hide it.
|
|
248
|
+
*/
|
|
249
|
+
private assertWritable;
|
|
250
|
+
/** The next command id of a kind; refused in read-only handlers (it advances a counter). */
|
|
251
|
+
private nextId;
|
|
197
252
|
/** Begin or finish an activation; `done` when there is nothing left to do. */
|
|
198
253
|
step(): 'more' | 'done';
|
|
199
254
|
/** The task's result. Call after `step()` returned `done` and jobs were drained. */
|
|
200
255
|
complete(): WorkflowTaskResult;
|
|
256
|
+
/**
|
|
257
|
+
* The local activities the open activation waits for, when the task is a
|
|
258
|
+
* workflow task that has not failed or closed the run (a run that ends
|
|
259
|
+
* abandons a local activity it did not await).
|
|
260
|
+
*/
|
|
261
|
+
private pendingLocalActivityRequests;
|
|
201
262
|
/** Fail the task (the runtime's own failures and code errors). */
|
|
202
263
|
failTask(cause: WorkflowTaskFailureCause, message: string, stackTrace?: string, seq?: number, errorType?: string): void;
|
|
203
264
|
private beginActivation;
|
|
265
|
+
/**
|
|
266
|
+
* The updates an activation delivers after its inputs (C-ABI-H): a replayed
|
|
267
|
+
* activation re-delivers the updates its task accepted (validators
|
|
268
|
+
* skipped); the open activation of a workflow task delivers the lease's
|
|
269
|
+
* pending updates. Updates history admitted (`UPDATE_ADMITTED`) arrive as
|
|
270
|
+
* inputs instead.
|
|
271
|
+
*/
|
|
272
|
+
private updatesOf;
|
|
204
273
|
private finishActivation;
|
|
274
|
+
/**
|
|
275
|
+
* A local activity issued on a replayed activation without a recorded
|
|
276
|
+
* outcome is fine only when the first execution dropped it in that same
|
|
277
|
+
* activation: its scope was cancelled (the entry is gone) or the run closed.
|
|
278
|
+
* One still waiting means the first execution would have requested and
|
|
279
|
+
* recorded it, so the code diverged from the history.
|
|
280
|
+
*/
|
|
281
|
+
private checkReplayedLocalActivities;
|
|
205
282
|
private deliver;
|
|
206
283
|
private expectIssued;
|
|
207
284
|
private settleActivity;
|
|
208
285
|
private settleChild;
|
|
286
|
+
/** Run a signal handler through the inbound `handleSignal` interceptors. */
|
|
287
|
+
private signalCall;
|
|
209
288
|
private dispatchSignal;
|
|
210
289
|
private takeBuffered;
|
|
211
290
|
private runHandler;
|
|
291
|
+
/** Count a running asynchronous handler (drain check, `allHandlersFinished`); returns its end. */
|
|
292
|
+
private trackHandler;
|
|
293
|
+
private deliverUpdate;
|
|
294
|
+
private updateHandlerFor;
|
|
295
|
+
/**
|
|
296
|
+
* Run `fn` with commands, sinks and every other change to the run's
|
|
297
|
+
* deterministic state refused (query handlers, update validators). A
|
|
298
|
+
* refused call fails the whole call with `QueryHandlerSideEffect`, even
|
|
299
|
+
* when the code caught the error it threw.
|
|
300
|
+
*/
|
|
301
|
+
private readOnlyCall;
|
|
302
|
+
/**
|
|
303
|
+
* Validate, accept and run one update. A validator error rejects it
|
|
304
|
+
* (`REJECT_UPDATE`, no history); otherwise `ACCEPT_UPDATE` is issued and
|
|
305
|
+
* the handler's result or failure completes it (`COMPLETE_UPDATE`). A
|
|
306
|
+
* handler that throws something other than a failure class fails the task,
|
|
307
|
+
* as a signal handler does.
|
|
308
|
+
*/
|
|
309
|
+
private runUpdate;
|
|
310
|
+
private completeUpdate;
|
|
311
|
+
/** Reject the updates of this activation that no handler took (`UpdateNotHandled`). */
|
|
312
|
+
private rejectUnhandledUpdates;
|
|
313
|
+
handleUpdate(update: UpdateDefinition<unknown, unknown> | string, handler: (args: unknown) => unknown, options?: UpdateHandlerOptions<unknown>): void;
|
|
314
|
+
setDefaultUpdateHandler(first: ((name: string, args: unknown) => unknown) | DefaultUpdateHandlerOptions, second?: ((name: string, args: unknown) => unknown) | DefaultUpdateHandlerOptions): void;
|
|
315
|
+
private dispatchBufferedUpdates;
|
|
316
|
+
handleQuery(query: QueryDefinition<unknown, unknown> | string, handler: (args: unknown) => unknown): void;
|
|
317
|
+
setDefaultQueryHandler(handler: (name: string, args: unknown) => unknown): void;
|
|
318
|
+
/**
|
|
319
|
+
* The drain check of 11 §2.18 when the workflow finishes: handlers still
|
|
320
|
+
* running with policy `WARN_AND_ABANDON` give one warning line and
|
|
321
|
+
* `unfinishedHandlers` in the result. A replay never reports them.
|
|
322
|
+
*/
|
|
323
|
+
private checkUnfinishedHandlers;
|
|
212
324
|
private startFunction;
|
|
213
325
|
private onReturn;
|
|
214
326
|
private isFailureType;
|
|
@@ -227,6 +339,24 @@ declare class WorkflowExecution {
|
|
|
227
339
|
private stack;
|
|
228
340
|
private never;
|
|
229
341
|
scheduleActivity<In, Out>(scope: Scope, operation: Operation<In, Out>, options: RunOptions<In>): Promise<Out>;
|
|
342
|
+
/**
|
|
343
|
+
* `ctx.activity` (Phase C): a user activity on a self-hosted task queue
|
|
344
|
+
* (`SCHEDULE_ACTIVITY` of kind `user`). The queue is the option, else the
|
|
345
|
+
* declaration's, else the run's own.
|
|
346
|
+
*/
|
|
347
|
+
userActivity<In, Out>(scope: Scope, activity: ActivityDefinition<In, Out> | string, options: ActivityOptions<In>): Promise<Out>;
|
|
348
|
+
/** Run the outbound `scheduleActivity` interceptors, then issue the command. */
|
|
349
|
+
private issueActivity;
|
|
350
|
+
private pushActivity;
|
|
351
|
+
/**
|
|
352
|
+
* `ctx.localActivity` (11 §2.12). A replayed activation returns the outcome
|
|
353
|
+
* its history recorded; the open activation takes the outcome the worker
|
|
354
|
+
* passed in `localActivityResults`, or asks for the local activity
|
|
355
|
+
* (`localActivityRequested`) and waits for the same task to run again.
|
|
356
|
+
* Either way the outcome is recorded with `RECORD_LOCAL_ACTIVITY` at the
|
|
357
|
+
* call, so a replay issues the same command at the same position.
|
|
358
|
+
*/
|
|
359
|
+
localActivity<In, Out>(scope: Scope, operation: unknown, options: LocalActivityOptions<In> | undefined): Promise<Out>;
|
|
230
360
|
startTimer(scope: Scope, durationMs: number, summary: string | undefined): Promise<void>;
|
|
231
361
|
/** Start a durable timer; `timerId` is undefined when no timer was needed or issued. */
|
|
232
362
|
private timer;
|
|
@@ -236,38 +366,71 @@ declare class WorkflowExecution {
|
|
|
236
366
|
/** Resolve conditions whose predicate now holds; true when any did. */
|
|
237
367
|
private checkConditions;
|
|
238
368
|
signalReceived<P>(scope: Scope, signal: SignalDefinition<P> | string): Promise<P>;
|
|
239
|
-
onSignal(signal: SignalDefinition<unknown> | string, handler: (payload: unknown) => unknown): void;
|
|
369
|
+
onSignal(signal: SignalDefinition<unknown> | string, handler: (payload: unknown) => unknown, options?: SignalHandlerOptions): void;
|
|
240
370
|
setDefaultSignalHandler(handler: (name: string, payload: unknown) => unknown): void;
|
|
371
|
+
/** The command target of a run handle (11 §2.1, §2.24). */
|
|
372
|
+
externalTarget(target: ExternalRunTarget): RunTarget;
|
|
373
|
+
runHandle(target: ExternalRunTarget): ExternalRunHandle;
|
|
241
374
|
private childTarget;
|
|
242
375
|
private childCommand;
|
|
376
|
+
/**
|
|
377
|
+
* Run the outbound `startChild` interceptors around a child start. `go`
|
|
378
|
+
* starts the child with the options the interceptors leave (input and
|
|
379
|
+
* headers).
|
|
380
|
+
*/
|
|
381
|
+
private interceptChild;
|
|
243
382
|
private startChildRun;
|
|
244
383
|
/** What cancelling the scope of a child's awaitable does (see `ChildOptions.cancellationType`). */
|
|
245
384
|
private onChildCancel;
|
|
246
385
|
child<Out>(scope: Scope, target: ChildTarget<Out>, options: ChildOptions): Promise<Out>;
|
|
247
386
|
private childResult;
|
|
248
387
|
startChild<Out>(scope: Scope, target: ChildTarget<Out>, options: ChildOptions): Promise<ChildHandle<Out>>;
|
|
388
|
+
private startChildHandle;
|
|
249
389
|
signalExternal(target: RunTarget, name: string, payload: unknown): Promise<void>;
|
|
390
|
+
private pushSignal;
|
|
250
391
|
cancelExternal(target: RunTarget): Promise<void>;
|
|
392
|
+
private pushCancel;
|
|
251
393
|
sideEffect<T extends Json>(fn: () => T): T;
|
|
394
|
+
private recordSideEffect;
|
|
252
395
|
patched(patchId: string, deprecated: boolean): boolean;
|
|
253
396
|
setCurrentDetails(markdown: string): void;
|
|
254
397
|
upsertContext(entries: JsonObject): void;
|
|
398
|
+
/** `ctx.upsertSearchAttributes` (Phase C): a null value removes an attribute. */
|
|
399
|
+
upsertSearchAttributes(attributes: JsonObject): void;
|
|
400
|
+
/** A `ctx.sinks.<sink>.<fn>(...args)` call: recorded once, never on replay (11 §2.31). */
|
|
401
|
+
private callSink;
|
|
402
|
+
private sinksProxy;
|
|
403
|
+
/** `ctx.continueAsNew`: a rejection with the request, after the outbound interceptors. */
|
|
404
|
+
continueAsNewCall(input: unknown, options: ContinueAsNewOptions): Promise<never>;
|
|
255
405
|
/** The request a `ctx.continueAsNew` call throws; the run ends with `CONTINUE_AS_NEW`. */
|
|
256
406
|
continueAsNew(input: unknown, options: ContinueAsNewOptions): ContinueAsNewRequest;
|
|
257
407
|
cancellationScope<T>(parent: Scope, fn: (ctx: WorkflowContext) => Promise<T>, options: CancellationScopeOptions): Promise<T>;
|
|
258
408
|
/** Waits for the signal handlers regardless of cancellation, as Temporal does. */
|
|
259
409
|
allHandlersFinished(): Promise<void>;
|
|
260
410
|
private pendingStacks;
|
|
411
|
+
/**
|
|
412
|
+
* Answer a custom query (Phase C): the handler registered for the name, else
|
|
413
|
+
* the default handler, run read-only through the inbound `handleQuery`
|
|
414
|
+
* interceptors. No handler gives `rejected`.
|
|
415
|
+
*/
|
|
416
|
+
private answerCustomQuery;
|
|
261
417
|
private answerQueries;
|
|
262
418
|
private contextFor;
|
|
263
419
|
}
|
|
264
420
|
|
|
265
421
|
/** The global a tier-2 bundle defines. */
|
|
266
422
|
declare const RUNTIME_GLOBAL = "__fluidgridsRuntime";
|
|
267
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* The runtime ABI, protocol 1. `capabilities` (C-ABI-H, from C-R1) lists what
|
|
425
|
+
* the runtime answers beyond Phase B: `updates`, `queries` (custom and default
|
|
426
|
+
* handlers) and `dynamic` (dynamic workflows and default handlers). A bundle
|
|
427
|
+
* built before C-R1 has none, and the service refuses updates and custom
|
|
428
|
+
* queries for its runs (DC4).
|
|
429
|
+
*/
|
|
268
430
|
interface FluidgridsRuntimeAbi {
|
|
269
431
|
readonly protocol: 1;
|
|
270
432
|
readonly sdkVersion: string;
|
|
433
|
+
readonly capabilities?: readonly string[];
|
|
271
434
|
start(requestJson: string): void;
|
|
272
435
|
step(): 'more' | 'done';
|
|
273
436
|
complete(): string;
|
|
@@ -278,6 +441,12 @@ interface WorkflowRegistry {
|
|
|
278
441
|
exportNames: ReadonlyMap<DurableWorkflow<never, unknown>, string>;
|
|
279
442
|
/** Export names declared by more than one module; starting one fails the task. */
|
|
280
443
|
ambiguous: ReadonlySet<string>;
|
|
444
|
+
/** The bundle's dynamic workflow (Phase C), which serves names no export has. */
|
|
445
|
+
dynamic?: DurableWorkflow<never, unknown>;
|
|
446
|
+
/** True when more than one dynamic workflow is exported; a dynamic start fails the task. */
|
|
447
|
+
dynamicAmbiguous?: boolean;
|
|
448
|
+
/** Workflow interceptor factories (`interceptors` exports), in module order. */
|
|
449
|
+
interceptors?: readonly WorkflowInterceptorsFactory[];
|
|
281
450
|
}
|
|
282
451
|
/** Build the registry from the bundle's modules (`[path, namespace]` pairs). */
|
|
283
452
|
declare function buildWorkflowRegistry(modules: ReadonlyArray<readonly [string, Record<string, unknown>]>): WorkflowRegistry;
|