@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/testing/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { x as Duration, X as WorkflowRetryOptions, v as DurableWorkflow, h as ActivityImplementation, i as ActivityInboundInterceptor, e as ActivityDefinition, c as ActivityContext, O as Operation, U as UpdateDefinition, Q as QueryDefinition, G as SignalDefinition } from '../workflow-DS32Gtws.cjs';
|
|
2
|
+
import { k as WorkflowInterceptorsFactory, M as MarkedInterceptorsFactory } from '../interceptors-CqkNZVfI.cjs';
|
|
3
|
+
import { C as CommandGate, p as HistoryFile, x as RunState } from '../file-BxYpwjRQ.cjs';
|
|
4
|
+
import { b as WorkflowInfoSnapshot, ay as WorkflowIdReusePolicy, ax as WorkflowIdConflictPolicy, at as VersioningBehavior, M as Headers, az as WorkflowTaskRequest, aA as WorkflowTaskResult, F as Failure, aj as SinkCall, R as RunEventRecord, U as UnfinishedHandler, ac as RunEventType } from '../types-Bv2i4cBX.cjs';
|
|
5
|
+
import { a as Json, J as JsonObject, W as WorkflowDefinition, m as WorkflowNode } from '../types-V7jEEUaL.cjs';
|
|
6
|
+
import { x as Tier1Workflow } from '../workflow-BJPFv3cp.cjs';
|
|
6
7
|
import { E as EsbuildApi } from '../lower-types-DQNBfWQn.cjs';
|
|
7
8
|
import { WorkflowRegistry } from '../runtime/index.cjs';
|
|
8
9
|
import 'esbuild';
|
|
9
|
-
import '../activation-
|
|
10
|
+
import '../activation-DqUfpHzk.cjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* `TestWorkflowEnvironment` (spec 10 §1): an in-process engine for tier-2
|
|
@@ -18,24 +19,50 @@ import '../activation-BBh1p82z.cjs';
|
|
|
18
19
|
* the conformance fixtures are recorded with it and then replayed in QuickJS
|
|
19
20
|
* and in `vm`.
|
|
20
21
|
*
|
|
22
|
+
* R2 adds local activities (run through `mock`, retried inside the task),
|
|
23
|
+
* start delay, run and execution timeouts and run-level retry on the fake
|
|
24
|
+
* clock, workflow-id policies and workflow-id targets, held activity queues
|
|
25
|
+
* for schedule-to-start timeouts, heartbeat details on retry, and the handler
|
|
26
|
+
* drain check (`failOnUnfinishedHandlers`, default true).
|
|
27
|
+
*
|
|
28
|
+
* C-R1 (Phase C) adds updates (`update`, update-with-start), custom queries
|
|
29
|
+
* (`query`), reset (`reset`, a forked run with signals and updates
|
|
30
|
+
* re-applied), user activities (`registerActivity`, `mockActivity`, async
|
|
31
|
+
* completion), search attributes and headers at the start, workflow
|
|
32
|
+
* interceptors, activity interceptors and sinks.
|
|
33
|
+
*
|
|
21
34
|
* Divergences from the service (documented, accepted for Phase B):
|
|
22
35
|
* - Workflow tasks run in this process without the determinism shims.
|
|
23
36
|
* - A failed workflow task is not retried forever: the run stops, and
|
|
24
37
|
* `result()` rejects with {@link WorkflowTaskFailedError}.
|
|
25
38
|
* - Every task is a first attempt (no transient attempts), and activity
|
|
26
39
|
* start-to-close and heartbeat timeouts are not timed; a mock may throw a
|
|
27
|
-
* `TimeoutFailure` to simulate one. Schedule-to-close is honoured
|
|
40
|
+
* `TimeoutFailure` to simulate one. Schedule-to-close is honoured, and
|
|
41
|
+
* schedule-to-start while a node type is held (`holdActivities`).
|
|
42
|
+
* - Local-activity retries do not wait for their backoff: the task's clock
|
|
43
|
+
* is its start time, as in the worker, and the fake clock does not move.
|
|
44
|
+
* - The workflow-task timeout is recorded, not enforced.
|
|
28
45
|
* - Graph child runs are mocks (`mockChild`).
|
|
46
|
+
* - Task queues are not checked: a user activity runs on any queue (the
|
|
47
|
+
* service refuses one on `managed`), and paused activities, pause rules
|
|
48
|
+
* and activity options updates are service operations without a test form.
|
|
29
49
|
*/
|
|
30
50
|
|
|
31
51
|
/** What a mock receives besides the activity's args. */
|
|
32
52
|
interface ActivityMockInfo {
|
|
33
53
|
runId: string;
|
|
54
|
+
/** `a<n>` for an activity, `l<n>` for a local activity. */
|
|
34
55
|
activityId: string;
|
|
35
56
|
attempt: number;
|
|
36
57
|
nodeType: string;
|
|
37
58
|
operation: string;
|
|
38
59
|
connection?: string;
|
|
60
|
+
/** True when the call is a local activity (`ctx.localActivity`). */
|
|
61
|
+
local?: boolean;
|
|
62
|
+
/** Details the previous attempt recorded with `heartbeat` (11 §2.4); activities only. */
|
|
63
|
+
heartbeatDetails?: Json;
|
|
64
|
+
/** Record heartbeat details for the next attempt (activities only). */
|
|
65
|
+
heartbeat?: (details?: unknown) => void;
|
|
39
66
|
}
|
|
40
67
|
type ActivityMock = (args: Json, info: ActivityMockInfo) => unknown;
|
|
41
68
|
type ChildMock = (input: Json, info: {
|
|
@@ -49,8 +76,21 @@ interface TestEnvironmentOptions {
|
|
|
49
76
|
startTime?: number | string | Date;
|
|
50
77
|
/** Tier-2 functions by export name, for `ctx.child(fn)` and by-name starts. */
|
|
51
78
|
workflows?: Readonly<Record<string, DurableWorkflow<never, unknown>>>;
|
|
52
|
-
/** Command set the environment accepts; default `parity`. */
|
|
53
|
-
enabled?:
|
|
79
|
+
/** Command set the environment accepts: a feature set or a release level; default `parity`. */
|
|
80
|
+
enabled?: CommandGate;
|
|
81
|
+
/**
|
|
82
|
+
* Turn the drain warning (a workflow that finishes while a signal handler
|
|
83
|
+
* with policy `WARN_AND_ABANDON` still runs, 11 §2.18) into a failure of
|
|
84
|
+
* `result()` (`UnfinishedHandlersError`). Default true.
|
|
85
|
+
*/
|
|
86
|
+
failOnUnfinishedHandlers?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The runtime release whose history fields the environment writes (default
|
|
89
|
+
* {@link RUNTIME_RELEASE}). Release 1 omits the R2 start fields that the
|
|
90
|
+
* Phase B core service never wrote (`lastCompletionResult` on a
|
|
91
|
+
* continue-as-new), so R1 conformance histories record unchanged.
|
|
92
|
+
*/
|
|
93
|
+
historyRelease?: number;
|
|
54
94
|
/** Workspace id written into run info. */
|
|
55
95
|
workspaceId?: string;
|
|
56
96
|
/**
|
|
@@ -61,6 +101,61 @@ interface TestEnvironmentOptions {
|
|
|
61
101
|
taskExecutor?: (request: WorkflowTaskRequest) => Promise<WorkflowTaskResult> | WorkflowTaskResult;
|
|
62
102
|
/** Workflow keys of tier-2 functions (key -> export name), for `ctx.child('<key>')` with a task executor. */
|
|
63
103
|
workflowKeys?: Readonly<Record<string, string>>;
|
|
104
|
+
/** Workflow interceptors, as a bundle would export them as `interceptors` (in-process tasks only). */
|
|
105
|
+
interceptors?: WorkflowInterceptorsFactory | MarkedInterceptorsFactory;
|
|
106
|
+
/** User-activity implementations (`implementActivity`, `defineActivity`, `dynamicActivity`). */
|
|
107
|
+
activities?: ReadonlyArray<ActivityImplementation<never, unknown>>;
|
|
108
|
+
/** Activity inbound interceptors around every user activity, first outermost. */
|
|
109
|
+
activityInterceptors?: readonly ActivityInboundInterceptor[];
|
|
110
|
+
/** Connections `ActivityContext.connection(name)` returns. */
|
|
111
|
+
connections?: Readonly<Record<string, Record<string, Json>>>;
|
|
112
|
+
/** Sink implementations called with each task's sink calls after the task completes. */
|
|
113
|
+
sinks?: Readonly<Record<string, Readonly<Record<string, (...args: Json[]) => void>>>>;
|
|
114
|
+
}
|
|
115
|
+
/** The state of an update (Phase C, 05 §6). */
|
|
116
|
+
type UpdateStatus = 'PENDING' | 'ACCEPTED' | 'REJECTED' | 'COMPLETED';
|
|
117
|
+
/** What `update` returns (`UpdateResult` of `updateWorkflowRun`). */
|
|
118
|
+
interface UpdateResult {
|
|
119
|
+
updateId: string;
|
|
120
|
+
status: UpdateStatus;
|
|
121
|
+
result?: Json;
|
|
122
|
+
failure?: Failure;
|
|
123
|
+
}
|
|
124
|
+
/** Options of `update`. */
|
|
125
|
+
interface UpdateOptions {
|
|
126
|
+
/** Idempotency: a repeat with the same id returns the first result. Default `u<n>`. */
|
|
127
|
+
updateId?: string;
|
|
128
|
+
/** `COMPLETED` (default) runs until idle, `ACCEPTED` returns once the update is accepted. */
|
|
129
|
+
waitFor?: 'ACCEPTED' | 'COMPLETED';
|
|
130
|
+
headers?: Headers;
|
|
131
|
+
}
|
|
132
|
+
/** Options of `reset` (11 §2.7). */
|
|
133
|
+
interface ResetOptions {
|
|
134
|
+
/** The last `WORKFLOW_TASK_COMPLETED` at or before this seq is the reset point. */
|
|
135
|
+
toSeq?: number;
|
|
136
|
+
/** `FIRST_TASK` or `LAST_TASK` (default) instead of a seq. */
|
|
137
|
+
to?: 'FIRST_TASK' | 'LAST_TASK';
|
|
138
|
+
reason?: string;
|
|
139
|
+
/** Re-append signals received after the reset point (default true). */
|
|
140
|
+
reapplySignals?: boolean;
|
|
141
|
+
/** Re-append updates accepted after the reset point as `UPDATE_ADMITTED` (default true). */
|
|
142
|
+
reapplyUpdates?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/** A query found no handler (`rejected`, `VALIDATION`). */
|
|
145
|
+
declare class QueryRejectedError extends Error {
|
|
146
|
+
readonly runId: string;
|
|
147
|
+
readonly queryName: string;
|
|
148
|
+
constructor(runId: string, queryName: string, message: string);
|
|
149
|
+
}
|
|
150
|
+
/** A query handler threw, or the replay failed. */
|
|
151
|
+
declare class QueryFailedError extends Error {
|
|
152
|
+
readonly runId: string;
|
|
153
|
+
readonly queryName: string;
|
|
154
|
+
constructor(runId: string, queryName: string, message: string);
|
|
155
|
+
}
|
|
156
|
+
/** An update to a run that is not open, or an update-with-start on a delayed start. */
|
|
157
|
+
declare class UpdateRefusedError extends Error {
|
|
158
|
+
constructor(message: string);
|
|
64
159
|
}
|
|
65
160
|
interface StartOptions {
|
|
66
161
|
input?: unknown;
|
|
@@ -71,6 +166,57 @@ interface StartOptions {
|
|
|
71
166
|
payload?: unknown;
|
|
72
167
|
}>;
|
|
73
168
|
info?: Partial<WorkflowInfoSnapshot>;
|
|
169
|
+
/** The workflow key for workflow-id policies and targets; default the declaration's name. */
|
|
170
|
+
workflowKey?: string;
|
|
171
|
+
/** The business id (11 §2.1); unique among the open runs of the workflow key. */
|
|
172
|
+
workflowId?: string;
|
|
173
|
+
/** Default `ALLOW_DUPLICATE`. */
|
|
174
|
+
idReusePolicy?: WorkflowIdReusePolicy;
|
|
175
|
+
/** Default `FAIL`. */
|
|
176
|
+
idConflictPolicy?: WorkflowIdConflictPolicy;
|
|
177
|
+
/** Delay the first workflow task (11 §2.23); a signal ends the delay. */
|
|
178
|
+
startDelay?: Duration;
|
|
179
|
+
/** Bounds the whole chain; default the declaration's `executionTimeout`. */
|
|
180
|
+
executionTimeout?: Duration;
|
|
181
|
+
/** Bounds one run; default the declaration's `runTimeout`. */
|
|
182
|
+
runTimeout?: Duration;
|
|
183
|
+
/** Recorded only; default the declaration's `workflowTaskTimeout`. */
|
|
184
|
+
workflowTaskTimeout?: Duration;
|
|
185
|
+
/** Run-level retry; default the declaration's `retry`. */
|
|
186
|
+
retry?: WorkflowRetryOptions;
|
|
187
|
+
summary?: string;
|
|
188
|
+
details?: string;
|
|
189
|
+
/** The run's memo (`ctx.info.context`). */
|
|
190
|
+
memo?: JsonObject;
|
|
191
|
+
/** Default the declaration's `versioningBehavior`. */
|
|
192
|
+
versioningBehavior?: VersioningBehavior;
|
|
193
|
+
/** Headers of the start (`WORKFLOW_STARTED.headers`, interceptors). */
|
|
194
|
+
headers?: Headers;
|
|
195
|
+
/** Search attributes at the start (Phase C). */
|
|
196
|
+
searchAttributes?: JsonObject;
|
|
197
|
+
/** Fairness of the run's tasks (Phase C). */
|
|
198
|
+
fairnessKey?: string;
|
|
199
|
+
fairnessWeight?: number;
|
|
200
|
+
/** Update-with-start (11 §2.6): admitted right after `WORKFLOW_STARTED`. */
|
|
201
|
+
update?: {
|
|
202
|
+
name: string;
|
|
203
|
+
args?: unknown;
|
|
204
|
+
updateId?: string;
|
|
205
|
+
headers?: Headers;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/** A start found an open run with the same workflow id (`idConflictPolicy: FAIL`) or a refused closed one. */
|
|
209
|
+
declare class WorkflowAlreadyStartedError extends Error {
|
|
210
|
+
readonly workflowKey: string;
|
|
211
|
+
readonly workflowId: string;
|
|
212
|
+
readonly existingRunId: string;
|
|
213
|
+
constructor(workflowKey: string, workflowId: string, existingRunId: string);
|
|
214
|
+
}
|
|
215
|
+
/** The workflow finished while signal handlers still ran (`failOnUnfinishedHandlers`). */
|
|
216
|
+
declare class UnfinishedHandlersError extends Error {
|
|
217
|
+
readonly runId: string;
|
|
218
|
+
readonly handlers: UnfinishedHandler[];
|
|
219
|
+
constructor(runId: string, handlers: UnfinishedHandler[]);
|
|
74
220
|
}
|
|
75
221
|
/** A run's workflow failed (`WORKFLOW_FAILED`). */
|
|
76
222
|
declare class WorkflowFailedError extends Error {
|
|
@@ -104,6 +250,14 @@ declare class TestRunHandle<Out = Json> {
|
|
|
104
250
|
cancel(reason?: string): Promise<void>;
|
|
105
251
|
/** Terminate the run without running code. */
|
|
106
252
|
terminate(reason?: string): Promise<void>;
|
|
253
|
+
/** Send an update and run until idle (Phase C). */
|
|
254
|
+
update<Args, Result>(update: UpdateDefinition<Args, Result> | string, args?: Args, options?: UpdateOptions): Promise<UpdateResult>;
|
|
255
|
+
/** Answer a query from the run's history (Phase C custom queries and the built-ins). */
|
|
256
|
+
query<Result, Args>(query: QueryDefinition<Result, Args> | string, args?: Args): Promise<Result>;
|
|
257
|
+
/** Reset the run (11 §2.7): a new run forked at a completed task; this one is terminated. */
|
|
258
|
+
reset(options?: ResetOptions): Promise<TestRunHandle<Out>>;
|
|
259
|
+
/** Sink calls the run's tasks made (Phase C). */
|
|
260
|
+
sinkCalls(): SinkCall[];
|
|
107
261
|
/** Run until this run (or the last run of its continue-as-new chain) ends; its output. */
|
|
108
262
|
result(): Promise<Out>;
|
|
109
263
|
/** The projected state of the run. */
|
|
@@ -114,6 +268,12 @@ declare class TestWorkflowEnvironment {
|
|
|
114
268
|
private clock;
|
|
115
269
|
private readonly timeSkipping;
|
|
116
270
|
private readonly enabled;
|
|
271
|
+
/** The bundle features the gate's flags enable, sent with every task (`request.features`). */
|
|
272
|
+
private readonly codeFeatures;
|
|
273
|
+
private readonly failOnUnfinishedHandlers;
|
|
274
|
+
private readonly historyRelease;
|
|
275
|
+
private dues;
|
|
276
|
+
private readonly held;
|
|
117
277
|
private readonly workspaceId;
|
|
118
278
|
private readonly runs;
|
|
119
279
|
private readonly runOrder;
|
|
@@ -125,19 +285,89 @@ declare class TestWorkflowEnvironment {
|
|
|
125
285
|
private timers;
|
|
126
286
|
private mockedChildren;
|
|
127
287
|
private runCounter;
|
|
288
|
+
private updateCounter;
|
|
128
289
|
private readonly executor;
|
|
129
290
|
private readonly workflowKeys;
|
|
291
|
+
private readonly interceptors;
|
|
292
|
+
private readonly activityImpls;
|
|
293
|
+
private readonly activityInterceptors;
|
|
294
|
+
private readonly connections;
|
|
295
|
+
private readonly sinks;
|
|
296
|
+
/** Attempts that handed their completion to an outside system (`completeAsync`), by token. */
|
|
297
|
+
private readonly asyncAttempts;
|
|
130
298
|
private constructor();
|
|
299
|
+
/** Register a user-activity implementation (Phase C). A later one replaces an earlier of the same name. */
|
|
300
|
+
registerActivity(implementation: ActivityImplementation<never, unknown>): void;
|
|
301
|
+
/** Mock a user activity by name or declaration (Phase C). */
|
|
302
|
+
mockActivity<In, Out>(activity: ActivityDefinition<In, Out> | string, fn: (args: In, ctx: ActivityContext) => Out | Promise<Out>): void;
|
|
131
303
|
/** Create an environment. */
|
|
132
304
|
static create(options?: TestEnvironmentOptions): Promise<TestWorkflowEnvironment>;
|
|
133
305
|
/** The fake clock, in epoch milliseconds. */
|
|
134
306
|
now(): number;
|
|
135
307
|
/** Mock a node operation (by node type, and operation when given). */
|
|
136
308
|
mock<In, Out>(operation: Operation<In, Out> | string, impl: (args: In, info: ActivityMockInfo) => Out | Promise<Out>, operationName?: string): void;
|
|
309
|
+
/**
|
|
310
|
+
* Hold the activity queue of a node type (every node type when omitted):
|
|
311
|
+
* attempts wait instead of starting, and a `scheduleToStartTimeout` expires
|
|
312
|
+
* (`ACTIVITY_TIMED_OUT { timeoutType: SCHEDULE_TO_START }`, not retried).
|
|
313
|
+
*/
|
|
314
|
+
holdActivities(nodeType?: string): void;
|
|
315
|
+
/** Release held activity queues (all when no node type is given). */
|
|
316
|
+
releaseActivities(nodeType?: string): void;
|
|
317
|
+
/** The hold key of an attempt: its node type, or the task queue of a user activity. */
|
|
318
|
+
private holdKeyOf;
|
|
319
|
+
private isHeld;
|
|
137
320
|
/** Mock a child workflow started by key (graph or durable). */
|
|
138
321
|
mockChild(workflowKey: string, impl: ChildMock): void;
|
|
139
322
|
/** Start a run of a tier-2 function (by declaration, or by export name with a task executor). */
|
|
140
323
|
start<In, Out>(definition: DurableWorkflow<In, Out> | string, options?: StartOptions): Promise<TestRunHandle<Out>>;
|
|
324
|
+
/**
|
|
325
|
+
* Update-with-start (11 §2.6): start the run (or, with
|
|
326
|
+
* `idConflictPolicy: USE_EXISTING`, reach the open one) and deliver the
|
|
327
|
+
* update before any other task runs.
|
|
328
|
+
*/
|
|
329
|
+
startWithUpdate<In, Out>(definition: DurableWorkflow<In, Out> | string, options: StartOptions & {
|
|
330
|
+
update: NonNullable<StartOptions['update']>;
|
|
331
|
+
}): Promise<{
|
|
332
|
+
handle: TestRunHandle<Out>;
|
|
333
|
+
update: UpdateResult;
|
|
334
|
+
}>;
|
|
335
|
+
private nextUpdateId;
|
|
336
|
+
/** A new update row (not attached to a run yet). */
|
|
337
|
+
private newUpdate;
|
|
338
|
+
/** Record an update on a run: pending (delivered by the next task) or admitted into history. */
|
|
339
|
+
private addUpdate;
|
|
340
|
+
/** Schedule a workflow task for a run that has none (an update needs no input event). */
|
|
341
|
+
private scheduleTask;
|
|
342
|
+
/**
|
|
343
|
+
* Send an update to a run and run until idle (Phase C, 05 §6). The result
|
|
344
|
+
* is `REJECTED` (the validator refused it or no handler took it; nothing is
|
|
345
|
+
* written to history), `COMPLETED`, or `ACCEPTED` while its handler still
|
|
346
|
+
* waits (for a timer without time skipping, or with `waitFor: ACCEPTED`).
|
|
347
|
+
*/
|
|
348
|
+
update<Args, Result>(runId: string, update: UpdateDefinition<Args, Result> | string, args?: Args, options?: UpdateOptions): Promise<UpdateResult>;
|
|
349
|
+
/** The current result of an update. */
|
|
350
|
+
updateResultOf(runId: string, updateId: string): UpdateResult;
|
|
351
|
+
/** Answer a query from the run's history (a replay-only `query` task). */
|
|
352
|
+
query(runId: string, query: QueryDefinition<unknown, unknown> | string, args?: unknown): Promise<Json>;
|
|
353
|
+
/** Sink calls the run's tasks made. */
|
|
354
|
+
sinkCallsOf(runId: string): SinkCall[];
|
|
355
|
+
/**
|
|
356
|
+
* Reset a run (11 §2.7): a new run whose history is the original's up to
|
|
357
|
+
* and including the chosen completed workflow task (with its commands),
|
|
358
|
+
* then `WORKFLOW_RESET`, then the signals (and, as `UPDATE_ADMITTED`, the
|
|
359
|
+
* accepted updates) received after that point. The original is terminated
|
|
360
|
+
* with reason `RESET`; children it started before the point follow the new
|
|
361
|
+
* run, the others get their parent-close policy. Returns the new run id.
|
|
362
|
+
*/
|
|
363
|
+
reset(runId: string, options?: ResetOptions): Promise<string>;
|
|
364
|
+
private durationConfig;
|
|
365
|
+
/**
|
|
366
|
+
* The workflow-id policies of a start (11 §2.1): the open run to use, or
|
|
367
|
+
* undefined to start a new run (after terminating the open one for
|
|
368
|
+
* `TERMINATE_EXISTING`). Throws {@link WorkflowAlreadyStartedError}.
|
|
369
|
+
*/
|
|
370
|
+
private useExisting;
|
|
141
371
|
/** Advance the clock by `duration`, firing timers and running work as it comes due. */
|
|
142
372
|
sleep(duration: Duration): Promise<void>;
|
|
143
373
|
/** Every run, in start order. */
|
|
@@ -150,20 +380,68 @@ declare class TestWorkflowEnvironment {
|
|
|
150
380
|
private ensureRegistered;
|
|
151
381
|
private run;
|
|
152
382
|
private createRun;
|
|
383
|
+
/** The R2 fields of `WORKFLOW_STARTED`, each written only when it is set. */
|
|
384
|
+
private startedFields;
|
|
153
385
|
private append;
|
|
154
|
-
|
|
386
|
+
/** End a start delay: the first workflow task is scheduled now. */
|
|
387
|
+
private endDelay;
|
|
388
|
+
deliverSignal(runId: string, name: string, payload: unknown, headers?: Headers): boolean;
|
|
155
389
|
requestCancel(runId: string, reason?: string): boolean;
|
|
156
390
|
terminate(runId: string, reason: string): void;
|
|
157
391
|
/** Run every runnable task and activity; skip time when allowed and idle. */
|
|
158
392
|
runUntilIdle(skipTime: boolean): Promise<void>;
|
|
393
|
+
/** When a held attempt's schedule-to-start timeout expires, if it has one. */
|
|
394
|
+
private heldDeadline;
|
|
159
395
|
private nextDue;
|
|
396
|
+
/** Expire held attempts whose schedule-to-start timeout passed (not retried, 11 §2.3). */
|
|
397
|
+
private expireHeld;
|
|
398
|
+
/** Fire run-level deadlines: the end of a start delay, run and execution timeouts. */
|
|
399
|
+
private fireRunDues;
|
|
160
400
|
private fireDue;
|
|
161
401
|
private runTask;
|
|
402
|
+
/** What a task's update replies mean for the run's update rows. */
|
|
403
|
+
private recordUpdateReplies;
|
|
404
|
+
/** Keep a task's sink calls and call the configured sinks with them. */
|
|
405
|
+
private runSinks;
|
|
406
|
+
private execute;
|
|
407
|
+
/**
|
|
408
|
+
* Run a workflow task as the worker does (11 §2.12): while it asks for
|
|
409
|
+
* local activities, run each through its mock and run the same task again
|
|
410
|
+
* with the outcomes, up to 1,000 rounds.
|
|
411
|
+
*/
|
|
412
|
+
private executeWithLocalActivities;
|
|
413
|
+
private runLocalActivity;
|
|
162
414
|
private afterCommand;
|
|
415
|
+
/** What a successor of a run inherits (continue-as-new, run retry). */
|
|
416
|
+
private chainConfig;
|
|
417
|
+
/** Start the next run of a chain; the closed run's parent and handles follow it. */
|
|
418
|
+
private startSuccessor;
|
|
163
419
|
private resolveTarget;
|
|
420
|
+
/** The open run of a workflow id, else its latest run (11 §2.1). */
|
|
421
|
+
private resolveWorkflowId;
|
|
164
422
|
private startChild;
|
|
165
423
|
private runMockedChild;
|
|
166
424
|
private runAttempt;
|
|
425
|
+
/** The `ActivityContext` of one user-activity attempt. */
|
|
426
|
+
private activityContext;
|
|
427
|
+
/** Complete an activity that called `completeAsync()` (`completeActivityAsync`). */
|
|
428
|
+
completeActivityAsync(token: string, result?: unknown): Promise<void>;
|
|
429
|
+
/** Fail an activity that called `completeAsync()` (`failActivityAsync`); the retry policy applies. */
|
|
430
|
+
failActivityAsync(token: string, error: unknown): Promise<void>;
|
|
431
|
+
private takeAsync;
|
|
432
|
+
/** Record an attempt's outcome: completion, a final failure or timeout, or the next attempt. */
|
|
433
|
+
private finishAttempt;
|
|
434
|
+
/**
|
|
435
|
+
* Run-level retry (11 §2.17): a failed or run-timed-out run whose policy
|
|
436
|
+
* allows another attempt is followed by a new run of the chain after the
|
|
437
|
+
* backoff, with `runAttempt + 1` and the failure as `lastFailure`.
|
|
438
|
+
*/
|
|
439
|
+
private retryRun;
|
|
440
|
+
/**
|
|
441
|
+
* A run closed: drop its pending work, retry it, apply the parent-close
|
|
442
|
+
* policy to its children (except `keptChildren`, which follow a reset
|
|
443
|
+
* fork), settle its open updates and notify its parent.
|
|
444
|
+
*/
|
|
167
445
|
private onClosed;
|
|
168
446
|
resultOf(runId: string): Promise<Json>;
|
|
169
447
|
/** Every tier-2 function registered, by export name. */
|
|
@@ -297,9 +575,12 @@ declare function runWorkflowTaskInVm(script: string, request: WorkflowTaskReques
|
|
|
297
575
|
|
|
298
576
|
/** Let every queued promise job run. */
|
|
299
577
|
declare function drainJobs(): Promise<void>;
|
|
300
|
-
/**
|
|
301
|
-
|
|
578
|
+
/**
|
|
579
|
+
* A registry from export names to workflow functions, with the workflow
|
|
580
|
+
* interceptors a bundle would export as `interceptors`.
|
|
581
|
+
*/
|
|
582
|
+
declare function registryOf(workflows: Readonly<Record<string, DurableWorkflow<never, unknown>>>, interceptors?: WorkflowInterceptorsFactory | MarkedInterceptorsFactory): WorkflowRegistry;
|
|
302
583
|
/** Run one workflow task in process. */
|
|
303
584
|
declare function runWorkflowTaskInProcess(registry: WorkflowRegistry, request: WorkflowTaskRequest): Promise<WorkflowTaskResult>;
|
|
304
585
|
|
|
305
|
-
export { type ActivityMock, type ActivityMockInfo, type ChildMock, type ExpectedEvent, HistoryAssertionError, type IRSnapshot, type NodeMock, type NodeMockResult, ReplayError, type ReplayInput, RunBlockedError, type SimulateOptions, type SimulatedStep, type SimulationResult, type StartOptions, type TestEnvironmentOptions, TestRunHandle, TestWorkflowEnvironment, WorkflowFailedError, WorkflowTaskFailedError, assertHistory, bundleToScript, drainJobs, expectIR, jsonCopy, registryOf, replay, replayRequest, runWorkflowTaskInProcess, runWorkflowTaskInVm, simulate };
|
|
586
|
+
export { type ActivityMock, type ActivityMockInfo, type ChildMock, type ExpectedEvent, HistoryAssertionError, type IRSnapshot, type NodeMock, type NodeMockResult, QueryFailedError, QueryRejectedError, ReplayError, type ReplayInput, type ResetOptions, RunBlockedError, type SimulateOptions, type SimulatedStep, type SimulationResult, type StartOptions, type TestEnvironmentOptions, TestRunHandle, TestWorkflowEnvironment, UnfinishedHandlersError, type UpdateOptions, UpdateRefusedError, type UpdateResult, type UpdateStatus, WorkflowAlreadyStartedError, WorkflowFailedError, WorkflowTaskFailedError, assertHistory, bundleToScript, drainJobs, expectIR, jsonCopy, registryOf, replay, replayRequest, runWorkflowTaskInProcess, runWorkflowTaskInVm, simulate };
|