@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/chunk-VOKMAAJP.js
DELETED
|
@@ -1,848 +0,0 @@
|
|
|
1
|
-
import { isRecord } from './chunk-PMCM2OH4.js';
|
|
2
|
-
import { isWorkflowCommandEnabled } from './chunk-ABFZWYHT.js';
|
|
3
|
-
import { CHILD_CANCELLATION_TYPES, PARENT_CLOSE_POLICIES, ERROR_TYPES, ACTIVITY_CANCELLATION_TYPES, TASK_FAILURE_CAUSES, EVENT_TYPES, COMMAND_TYPES, BUILT_IN_QUERIES, HISTORY_PROTOCOL, TERMINAL_COMMANDS } from './chunk-DJYMDLV5.js';
|
|
4
|
-
import { isActivityNodeTypeAllowed } from './chunk-BO6OVILK.js';
|
|
5
|
-
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
6
|
-
|
|
7
|
-
// src/history/schema.ts
|
|
8
|
-
var BASE = "https://docs.fluidgrids.ai/schemas";
|
|
9
|
-
var RUN_EVENT_SCHEMA_ID = `${BASE}/run-event.schema.json`;
|
|
10
|
-
var WORKFLOW_COMMAND_SCHEMA_ID = `${BASE}/workflow-command.schema.json`;
|
|
11
|
-
var WORKFLOW_TASK_SCHEMA_ID = `${BASE}/workflow-task.schema.json`;
|
|
12
|
-
var HISTORY_FILE_SCHEMA_ID = `${BASE}/history-file.schema.json`;
|
|
13
|
-
var HISTORY_FILE_FORMAT = "fluidgrids.history";
|
|
14
|
-
var ID = { type: "string", minLength: 1, maxLength: 256 };
|
|
15
|
-
var NON_NEGATIVE_MS = { type: "integer", minimum: 0 };
|
|
16
|
-
var STRING_MAP = { type: "object", additionalProperties: { type: "string" } };
|
|
17
|
-
var SHARED_DEFS = {
|
|
18
|
-
json: {
|
|
19
|
-
description: "Any JSON value."
|
|
20
|
-
},
|
|
21
|
-
failure: {
|
|
22
|
-
type: "object",
|
|
23
|
-
required: ["errorType", "message"],
|
|
24
|
-
properties: {
|
|
25
|
-
errorType: { enum: [...ERROR_TYPES] },
|
|
26
|
-
message: { type: "string" },
|
|
27
|
-
type: { type: "string" },
|
|
28
|
-
details: {},
|
|
29
|
-
nonRetryable: { type: "boolean" },
|
|
30
|
-
nextRetryDelayMs: NON_NEGATIVE_MS,
|
|
31
|
-
category: { const: "BENIGN" },
|
|
32
|
-
timeoutType: { type: "string" },
|
|
33
|
-
cause: { $ref: "#/$defs/failure" },
|
|
34
|
-
stackTrace: { type: "string" },
|
|
35
|
-
source: { type: "string" }
|
|
36
|
-
},
|
|
37
|
-
additionalProperties: false
|
|
38
|
-
},
|
|
39
|
-
retryPolicy: {
|
|
40
|
-
type: "object",
|
|
41
|
-
required: ["retryDelay"],
|
|
42
|
-
description: "maxRetries absent means unlimited attempts, bounded by scheduleToCloseTimeout.",
|
|
43
|
-
properties: {
|
|
44
|
-
maxRetries: { type: "integer", minimum: 0 },
|
|
45
|
-
retryDelay: NON_NEGATIVE_MS,
|
|
46
|
-
backoffMultiplier: { type: "number", minimum: 1 },
|
|
47
|
-
maxDelay: NON_NEGATIVE_MS,
|
|
48
|
-
retryOnErrorTypes: { type: "array", items: { enum: [...ERROR_TYPES] } },
|
|
49
|
-
nonRetryableErrorTypes: { type: "array", items: { type: "string" } }
|
|
50
|
-
},
|
|
51
|
-
additionalProperties: false
|
|
52
|
-
},
|
|
53
|
-
runTarget: {
|
|
54
|
-
oneOf: [
|
|
55
|
-
{
|
|
56
|
-
type: "object",
|
|
57
|
-
required: ["runId"],
|
|
58
|
-
properties: { runId: ID },
|
|
59
|
-
additionalProperties: false
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
type: "object",
|
|
63
|
-
required: ["parent"],
|
|
64
|
-
properties: { parent: { const: true } },
|
|
65
|
-
additionalProperties: false
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
type: "object",
|
|
69
|
-
required: ["childId"],
|
|
70
|
-
properties: { childId: ID },
|
|
71
|
-
additionalProperties: false
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
type: "object",
|
|
75
|
-
required: ["workflowKey", "workflowId"],
|
|
76
|
-
properties: { workflowKey: ID, workflowId: ID },
|
|
77
|
-
additionalProperties: false
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
childOptions: {
|
|
82
|
-
type: "object",
|
|
83
|
-
required: ["parentClosePolicy"],
|
|
84
|
-
properties: {
|
|
85
|
-
parentClosePolicy: { enum: [...PARENT_CLOSE_POLICIES] },
|
|
86
|
-
cancellationType: { enum: [...CHILD_CANCELLATION_TYPES] },
|
|
87
|
-
taskQueue: ID,
|
|
88
|
-
workflowId: ID,
|
|
89
|
-
priority: { type: "integer", minimum: 1, maximum: 5 },
|
|
90
|
-
summary: { type: "string", maxLength: 200 },
|
|
91
|
-
details: { type: "string" },
|
|
92
|
-
context: { type: "object" },
|
|
93
|
-
executionTimeout: NON_NEGATIVE_MS,
|
|
94
|
-
runTimeout: NON_NEGATIVE_MS,
|
|
95
|
-
workflowTaskTimeout: NON_NEGATIVE_MS,
|
|
96
|
-
startDelay: NON_NEGATIVE_MS
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
headers: STRING_MAP
|
|
100
|
-
};
|
|
101
|
-
function command(type, required, properties) {
|
|
102
|
-
return {
|
|
103
|
-
type: "object",
|
|
104
|
-
required: ["type", ...required],
|
|
105
|
-
properties: { type: { const: type }, headers: { $ref: "#/$defs/headers" }, ...properties },
|
|
106
|
-
additionalProperties: false
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
var COMMAND_DEFS = {
|
|
110
|
-
SCHEDULE_ACTIVITY: command(
|
|
111
|
-
"SCHEDULE_ACTIVITY",
|
|
112
|
-
["activityId", "kind", "nodeType", "operation", "args", "retry"],
|
|
113
|
-
{
|
|
114
|
-
activityId: ID,
|
|
115
|
-
kind: { const: "node" },
|
|
116
|
-
nodeType: ID,
|
|
117
|
-
nodeVersion: { type: "string" },
|
|
118
|
-
operation: ID,
|
|
119
|
-
args: {},
|
|
120
|
-
connection: ID,
|
|
121
|
-
retry: { $ref: "#/$defs/retryPolicy" },
|
|
122
|
-
startToCloseTimeout: NON_NEGATIVE_MS,
|
|
123
|
-
scheduleToCloseTimeout: NON_NEGATIVE_MS,
|
|
124
|
-
scheduleToStartTimeout: NON_NEGATIVE_MS,
|
|
125
|
-
heartbeatTimeout: NON_NEGATIVE_MS,
|
|
126
|
-
cancellationType: { enum: [...ACTIVITY_CANCELLATION_TYPES] },
|
|
127
|
-
priority: { type: "integer", minimum: 1, maximum: 5 },
|
|
128
|
-
summary: { type: "string", maxLength: 200 },
|
|
129
|
-
runOn: { type: "string" }
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
REQUEST_CANCEL_ACTIVITY: command("REQUEST_CANCEL_ACTIVITY", ["activityId"], { activityId: ID }),
|
|
133
|
-
START_TIMER: command("START_TIMER", ["timerId", "durationMs"], {
|
|
134
|
-
timerId: ID,
|
|
135
|
-
durationMs: { type: "integer", minimum: 1 },
|
|
136
|
-
summary: { type: "string", maxLength: 200 }
|
|
137
|
-
}),
|
|
138
|
-
CANCEL_TIMER: command("CANCEL_TIMER", ["timerId"], { timerId: ID }),
|
|
139
|
-
START_CHILD_RUN: {
|
|
140
|
-
...command("START_CHILD_RUN", ["childId", "input", "options"], {
|
|
141
|
-
childId: ID,
|
|
142
|
-
workflowKey: ID,
|
|
143
|
-
workflowFn: ID,
|
|
144
|
-
version: { type: "string", minLength: 1 },
|
|
145
|
-
input: {},
|
|
146
|
-
options: { $ref: "#/$defs/childOptions" }
|
|
147
|
-
}),
|
|
148
|
-
oneOf: [{ required: ["workflowKey"] }, { required: ["workflowFn"] }]
|
|
149
|
-
},
|
|
150
|
-
SIGNAL_RUN: command("SIGNAL_RUN", ["externalId", "target", "name", "payload"], {
|
|
151
|
-
externalId: ID,
|
|
152
|
-
target: { $ref: "#/$defs/runTarget" },
|
|
153
|
-
name: ID,
|
|
154
|
-
payload: {}
|
|
155
|
-
}),
|
|
156
|
-
RECORD_SIDE_EFFECT: command("RECORD_SIDE_EFFECT", ["sideEffectId", "value"], {
|
|
157
|
-
sideEffectId: ID,
|
|
158
|
-
value: {}
|
|
159
|
-
}),
|
|
160
|
-
RECORD_MARKER: command("RECORD_MARKER", ["markerId", "data"], { markerId: ID, data: {} }),
|
|
161
|
-
COMPLETE_WORKFLOW: command("COMPLETE_WORKFLOW", ["output"], { output: {} }),
|
|
162
|
-
FAIL_WORKFLOW: command("FAIL_WORKFLOW", ["failure"], {
|
|
163
|
-
failure: { $ref: "#/$defs/failure" }
|
|
164
|
-
}),
|
|
165
|
-
CANCEL_WORKFLOW: command("CANCEL_WORKFLOW", [], {}),
|
|
166
|
-
UPSERT_CONTEXT: command("UPSERT_CONTEXT", ["entries"], { entries: { type: "object" } }),
|
|
167
|
-
RECORD_LOCAL_ACTIVITY: {
|
|
168
|
-
...command("RECORD_LOCAL_ACTIVITY", ["localActivityId", "attempts"], {
|
|
169
|
-
localActivityId: ID,
|
|
170
|
-
result: {},
|
|
171
|
-
failure: { $ref: "#/$defs/failure" },
|
|
172
|
-
attempts: { type: "integer", minimum: 1 }
|
|
173
|
-
}),
|
|
174
|
-
oneOf: [{ required: ["result"] }, { required: ["failure"] }]
|
|
175
|
-
},
|
|
176
|
-
CONTINUE_AS_NEW: command("CONTINUE_AS_NEW", ["input", "options"], {
|
|
177
|
-
input: {},
|
|
178
|
-
options: { type: "object" }
|
|
179
|
-
}),
|
|
180
|
-
REQUEST_CANCEL_EXTERNAL_RUN: command("REQUEST_CANCEL_EXTERNAL_RUN", ["externalId", "target"], {
|
|
181
|
-
externalId: ID,
|
|
182
|
-
target: { $ref: "#/$defs/runTarget" }
|
|
183
|
-
}),
|
|
184
|
-
UPSERT_SEARCH_ATTRIBUTES: command("UPSERT_SEARCH_ATTRIBUTES", ["attributes"], {
|
|
185
|
-
attributes: { type: "object" }
|
|
186
|
-
}),
|
|
187
|
-
ACCEPT_UPDATE: command("ACCEPT_UPDATE", ["updateId"], { updateId: ID }),
|
|
188
|
-
REJECT_UPDATE: command("REJECT_UPDATE", ["updateId", "failure"], {
|
|
189
|
-
updateId: ID,
|
|
190
|
-
failure: { $ref: "#/$defs/failure" }
|
|
191
|
-
}),
|
|
192
|
-
COMPLETE_UPDATE: command("COMPLETE_UPDATE", ["updateId"], {
|
|
193
|
-
updateId: ID,
|
|
194
|
-
result: {},
|
|
195
|
-
failure: { $ref: "#/$defs/failure" }
|
|
196
|
-
})
|
|
197
|
-
};
|
|
198
|
-
function payload(required, properties) {
|
|
199
|
-
return { type: "object", required, properties };
|
|
200
|
-
}
|
|
201
|
-
var FAILURE_REF = { $ref: "#/$defs/failure" };
|
|
202
|
-
var EVENT_PAYLOADS = {
|
|
203
|
-
WORKFLOW_STARTED: payload(["workflowFn", "input"], {
|
|
204
|
-
workflowFn: ID,
|
|
205
|
-
input: {},
|
|
206
|
-
workflowKey: { type: "string" },
|
|
207
|
-
version: {},
|
|
208
|
-
buildId: { type: "string" },
|
|
209
|
-
taskQueue: { type: "string" },
|
|
210
|
-
parentRunId: { type: ["string", "null"] },
|
|
211
|
-
rootRunId: { type: ["string", "null"] },
|
|
212
|
-
firstRunId: { type: ["string", "null"] },
|
|
213
|
-
continuedFromRunId: { type: ["string", "null"] },
|
|
214
|
-
parentClosePolicy: { enum: [...PARENT_CLOSE_POLICIES] },
|
|
215
|
-
startDelay: NON_NEGATIVE_MS,
|
|
216
|
-
lastCompletionResult: {},
|
|
217
|
-
lastFailure: { oneOf: [{ type: "null" }, FAILURE_REF] },
|
|
218
|
-
summary: { type: "string" },
|
|
219
|
-
details: { type: "string" },
|
|
220
|
-
context: { type: "object" },
|
|
221
|
-
executionTimeout: NON_NEGATIVE_MS,
|
|
222
|
-
runTimeout: NON_NEGATIVE_MS,
|
|
223
|
-
workflowTaskTimeout: NON_NEGATIVE_MS,
|
|
224
|
-
versioningBehavior: { enum: ["PINNED", "AUTO_UPGRADE"] },
|
|
225
|
-
/** Seed of `ctx.random()`/`ctx.uuid()`; the service writes the run id. Absent: `info.runId`. */
|
|
226
|
-
randomnessSeed: ID
|
|
227
|
-
}),
|
|
228
|
-
WORKFLOW_TASK_SCHEDULED: payload(["taskId"], {
|
|
229
|
-
taskId: ID,
|
|
230
|
-
attempt: { type: "integer", minimum: 1 }
|
|
231
|
-
}),
|
|
232
|
-
WORKFLOW_TASK_STARTED: payload(["taskId", "attempt"], {
|
|
233
|
-
taskId: ID,
|
|
234
|
-
attempt: { type: "integer", minimum: 1 },
|
|
235
|
-
workerId: { type: "string" },
|
|
236
|
-
buildId: { type: "string" },
|
|
237
|
-
startedAt: {
|
|
238
|
-
type: "string",
|
|
239
|
-
description: "When the attempt started, if different from the event time (a transient attempt is recorded at completion). This is the clock the task saw: nowMs of its request."
|
|
240
|
-
},
|
|
241
|
-
historyLength: {
|
|
242
|
-
type: "integer",
|
|
243
|
-
minimum: 1,
|
|
244
|
-
description: "The history length the attempt was leased with (run.taskStartedSeq), when it is not this event's own seq. Required on the WORKFLOW_TASK_STARTED of a transient attempt: input events with a higher seq that precede this event arrived during the attempt and belong to the next activation."
|
|
245
|
-
}
|
|
246
|
-
}),
|
|
247
|
-
WORKFLOW_TASK_COMPLETED: payload(["taskId"], {
|
|
248
|
-
taskId: ID,
|
|
249
|
-
buildId: { type: "string" },
|
|
250
|
-
workerId: { type: "string" }
|
|
251
|
-
}),
|
|
252
|
-
WORKFLOW_TASK_FAILED: payload(["taskId", "attempt", "cause"], {
|
|
253
|
-
taskId: ID,
|
|
254
|
-
attempt: { type: "integer", minimum: 1 },
|
|
255
|
-
cause: { enum: [...TASK_FAILURE_CAUSES] },
|
|
256
|
-
message: { type: "string" },
|
|
257
|
-
stackTrace: { type: "string" },
|
|
258
|
-
buildId: { type: "string" }
|
|
259
|
-
}),
|
|
260
|
-
WORKFLOW_TASK_TIMED_OUT: payload(["taskId", "attempt"], {
|
|
261
|
-
taskId: ID,
|
|
262
|
-
attempt: { type: "integer", minimum: 1 }
|
|
263
|
-
}),
|
|
264
|
-
ACTIVITY_SCHEDULED: payload(["activityId", "kind", "nodeType", "operation", "args", "retry"], {
|
|
265
|
-
...COMMAND_DEFS.SCHEDULE_ACTIVITY.properties,
|
|
266
|
-
type: void 0
|
|
267
|
-
}),
|
|
268
|
-
ACTIVITY_STARTED: payload(["activityId", "attempt"], {
|
|
269
|
-
activityId: ID,
|
|
270
|
-
attempt: { type: "integer", minimum: 1 },
|
|
271
|
-
workerId: { type: "string" }
|
|
272
|
-
}),
|
|
273
|
-
ACTIVITY_HEARTBEAT: payload(["activityId"], { activityId: ID, details: {} }),
|
|
274
|
-
ACTIVITY_COMPLETED: payload(["activityId", "attempt"], {
|
|
275
|
-
activityId: ID,
|
|
276
|
-
attempt: { type: "integer", minimum: 1 },
|
|
277
|
-
result: {}
|
|
278
|
-
}),
|
|
279
|
-
ACTIVITY_FAILED: payload(["activityId", "attempt", "failure"], {
|
|
280
|
-
activityId: ID,
|
|
281
|
-
attempt: { type: "integer", minimum: 1 },
|
|
282
|
-
failure: FAILURE_REF
|
|
283
|
-
}),
|
|
284
|
-
ACTIVITY_TIMED_OUT: payload(["activityId", "attempt", "timeoutType"], {
|
|
285
|
-
activityId: ID,
|
|
286
|
-
attempt: { type: "integer", minimum: 1 },
|
|
287
|
-
timeoutType: {
|
|
288
|
-
enum: ["START_TO_CLOSE", "SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE", "HEARTBEAT"]
|
|
289
|
-
},
|
|
290
|
-
failure: FAILURE_REF
|
|
291
|
-
}),
|
|
292
|
-
ACTIVITY_CANCEL_REQUESTED: payload(["activityId"], { activityId: ID }),
|
|
293
|
-
ACTIVITY_CANCELLED: payload(["activityId"], { activityId: ID, details: {} }),
|
|
294
|
-
ACTIVITY_PAUSED: payload(["activityId"], { activityId: ID, reason: { type: "string" } }),
|
|
295
|
-
ACTIVITY_UNPAUSED: payload(["activityId"], { activityId: ID }),
|
|
296
|
-
ACTIVITY_RESET: payload(["activityId"], { activityId: ID }),
|
|
297
|
-
ACTIVITY_OPTIONS_UPDATED: payload(["activityId"], {
|
|
298
|
-
activityId: ID,
|
|
299
|
-
options: { type: "object" }
|
|
300
|
-
}),
|
|
301
|
-
TIMER_STARTED: payload(["timerId", "durationMs", "fireAt"], {
|
|
302
|
-
timerId: ID,
|
|
303
|
-
durationMs: { type: "integer", minimum: 1 },
|
|
304
|
-
fireAt: { type: "string" },
|
|
305
|
-
summary: { type: "string" }
|
|
306
|
-
}),
|
|
307
|
-
TIMER_FIRED: payload(["timerId"], { timerId: ID }),
|
|
308
|
-
TIMER_CANCELLED: payload(["timerId"], { timerId: ID }),
|
|
309
|
-
SIGNAL_RECEIVED: payload(["name"], {
|
|
310
|
-
name: ID,
|
|
311
|
-
payload: {},
|
|
312
|
-
receivedAt: { type: "string" },
|
|
313
|
-
actor: {},
|
|
314
|
-
idempotencyKey: { type: "string" }
|
|
315
|
-
}),
|
|
316
|
-
UPDATE_ADMITTED: payload(["updateId", "name"], { updateId: ID, name: ID, args: {} }),
|
|
317
|
-
UPDATE_ACCEPTED: payload(["updateId", "name"], { updateId: ID, name: ID, args: {} }),
|
|
318
|
-
UPDATE_COMPLETED: payload(["updateId"], { updateId: ID, result: {}, failure: FAILURE_REF }),
|
|
319
|
-
CHILD_RUN_INITIATED: payload(["childId", "input", "options"], {
|
|
320
|
-
childId: ID,
|
|
321
|
-
workflowKey: ID,
|
|
322
|
-
workflowFn: ID,
|
|
323
|
-
version: { type: "string" },
|
|
324
|
-
input: {},
|
|
325
|
-
options: { $ref: "#/$defs/childOptions" },
|
|
326
|
-
childRunId: { type: "string" },
|
|
327
|
-
executionKind: { enum: ["GRAPH", "DURABLE_FN"] }
|
|
328
|
-
}),
|
|
329
|
-
CHILD_RUN_STARTED: payload(["childId", "childRunId"], {
|
|
330
|
-
childId: ID,
|
|
331
|
-
childRunId: ID,
|
|
332
|
-
executionKind: { enum: ["GRAPH", "DURABLE_FN"] }
|
|
333
|
-
}),
|
|
334
|
-
CHILD_RUN_COMPLETED: payload(["childId"], { childId: ID, childRunId: ID, result: {} }),
|
|
335
|
-
CHILD_RUN_FAILED: payload(["childId", "failure"], {
|
|
336
|
-
childId: ID,
|
|
337
|
-
childRunId: ID,
|
|
338
|
-
failure: FAILURE_REF
|
|
339
|
-
}),
|
|
340
|
-
CHILD_RUN_CANCELLED: payload(["childId"], { childId: ID, childRunId: ID }),
|
|
341
|
-
CHILD_RUN_TERMINATED: payload(["childId"], {
|
|
342
|
-
childId: ID,
|
|
343
|
-
childRunId: ID,
|
|
344
|
-
reason: { type: "string" }
|
|
345
|
-
}),
|
|
346
|
-
CHILD_RUN_TIMED_OUT: payload(["childId"], {
|
|
347
|
-
childId: ID,
|
|
348
|
-
childRunId: ID,
|
|
349
|
-
timeoutType: { enum: ["WORKFLOW_RUN", "WORKFLOW_EXECUTION"] }
|
|
350
|
-
}),
|
|
351
|
-
EXTERNAL_RUN_CANCEL_REQUESTED: payload(["externalId", "target"], {
|
|
352
|
-
externalId: ID,
|
|
353
|
-
target: { $ref: "#/$defs/runTarget" }
|
|
354
|
-
}),
|
|
355
|
-
EXTERNAL_RUN_CANCEL_RESOLVED: payload(["externalId", "ok"], {
|
|
356
|
-
externalId: ID,
|
|
357
|
-
ok: { type: "boolean" },
|
|
358
|
-
targetRunId: { type: "string" },
|
|
359
|
-
failure: FAILURE_REF
|
|
360
|
-
}),
|
|
361
|
-
EXTERNAL_RUN_SIGNALED: {
|
|
362
|
-
type: "object",
|
|
363
|
-
required: ["externalId"],
|
|
364
|
-
description: "Two forms. Initiated (appended for the SIGNAL_RUN command): {externalId, target, name, payload}. Resolved (appended by the service after delivery, dedupeKey signal-out:<runId>:<externalId>): {externalId, resolved: true, ok, failure?, targetRunId?}.",
|
|
365
|
-
properties: {
|
|
366
|
-
externalId: ID,
|
|
367
|
-
target: { $ref: "#/$defs/runTarget" },
|
|
368
|
-
name: ID,
|
|
369
|
-
payload: {},
|
|
370
|
-
resolved: { const: true },
|
|
371
|
-
ok: { type: "boolean" },
|
|
372
|
-
targetRunId: { type: "string" },
|
|
373
|
-
failure: FAILURE_REF
|
|
374
|
-
},
|
|
375
|
-
if: { required: ["resolved"] },
|
|
376
|
-
then: { required: ["ok"] },
|
|
377
|
-
else: { required: ["target", "name"] }
|
|
378
|
-
},
|
|
379
|
-
SIDE_EFFECT_RECORDED: payload(["sideEffectId", "value"], { sideEffectId: ID, value: {} }),
|
|
380
|
-
LOCAL_ACTIVITY_COMPLETED: payload(["localActivityId", "attempts"], {
|
|
381
|
-
localActivityId: ID,
|
|
382
|
-
result: {},
|
|
383
|
-
attempts: { type: "integer", minimum: 1 }
|
|
384
|
-
}),
|
|
385
|
-
LOCAL_ACTIVITY_FAILED: payload(["localActivityId", "attempts", "failure"], {
|
|
386
|
-
localActivityId: ID,
|
|
387
|
-
failure: FAILURE_REF,
|
|
388
|
-
attempts: { type: "integer", minimum: 1 }
|
|
389
|
-
}),
|
|
390
|
-
SEARCH_ATTRIBUTES_UPSERTED: payload(["attributes"], { attributes: { type: "object" } }),
|
|
391
|
-
CONTEXT_UPSERTED: payload(["entries"], { entries: { type: "object" } }),
|
|
392
|
-
MARKER_RECORDED: payload(["markerId", "data"], {
|
|
393
|
-
markerId: ID,
|
|
394
|
-
data: {}
|
|
395
|
-
}),
|
|
396
|
-
WORKFLOW_CANCEL_REQUESTED: payload([], { actor: {}, reason: { type: "string" } }),
|
|
397
|
-
WORKFLOW_RESET: payload(["fromRunId", "toSeq"], {
|
|
398
|
-
fromRunId: ID,
|
|
399
|
-
toSeq: { type: "integer", minimum: 1 },
|
|
400
|
-
reason: { type: "string" }
|
|
401
|
-
}),
|
|
402
|
-
VERSIONING_OVERRIDE_SET: payload(["override"], { override: {} }),
|
|
403
|
-
WORKFLOW_COMPLETED: payload(["output"], { output: {} }),
|
|
404
|
-
WORKFLOW_FAILED: payload(["failure"], { failure: FAILURE_REF }),
|
|
405
|
-
WORKFLOW_CANCELLED: payload([], { details: {} }),
|
|
406
|
-
WORKFLOW_TERMINATED: payload([], { reason: { type: "string" }, actor: {} }),
|
|
407
|
-
WORKFLOW_TIMED_OUT: payload(["timeoutType"], {
|
|
408
|
-
timeoutType: { enum: ["WORKFLOW_RUN", "WORKFLOW_EXECUTION"] }
|
|
409
|
-
}),
|
|
410
|
-
WORKFLOW_CONTINUED_AS_NEW: payload(["input", "options"], {
|
|
411
|
-
input: {},
|
|
412
|
-
options: { type: "object" },
|
|
413
|
-
newRunId: { type: "string" }
|
|
414
|
-
})
|
|
415
|
-
};
|
|
416
|
-
function compact(value) {
|
|
417
|
-
const out = {};
|
|
418
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
419
|
-
if (entry === void 0) continue;
|
|
420
|
-
out[key] = typeof entry === "object" && entry !== null && !Array.isArray(entry) ? compact(entry) : entry;
|
|
421
|
-
}
|
|
422
|
-
return out;
|
|
423
|
-
}
|
|
424
|
-
var RUN_EVENT_RECORD = {
|
|
425
|
-
type: "object",
|
|
426
|
-
required: ["seq", "type", "payload", "createdAt"],
|
|
427
|
-
properties: {
|
|
428
|
-
seq: { type: "integer", minimum: 1 },
|
|
429
|
-
type: { enum: [...EVENT_TYPES] },
|
|
430
|
-
taskId: { type: ["string", "null"] },
|
|
431
|
-
payload: { type: "object" },
|
|
432
|
-
createdAt: { type: "string", minLength: 1 },
|
|
433
|
-
dedupeKey: { type: ["string", "null"] }
|
|
434
|
-
},
|
|
435
|
-
allOf: EVENT_TYPES.map((type) => ({
|
|
436
|
-
if: { properties: { type: { const: type } }, required: ["type"] },
|
|
437
|
-
then: { properties: { payload: { $ref: `#/$defs/payload_${type}` } } }
|
|
438
|
-
}))
|
|
439
|
-
};
|
|
440
|
-
function payloadDefs() {
|
|
441
|
-
const defs = {};
|
|
442
|
-
for (const type of EVENT_TYPES) defs[`payload_${type}`] = compact(EVENT_PAYLOADS[type]);
|
|
443
|
-
return defs;
|
|
444
|
-
}
|
|
445
|
-
function commandDefs() {
|
|
446
|
-
const defs = {};
|
|
447
|
-
for (const type of COMMAND_TYPES) defs[`command_${type}`] = COMMAND_DEFS[type];
|
|
448
|
-
return defs;
|
|
449
|
-
}
|
|
450
|
-
var COMMAND_ONE_OF = {
|
|
451
|
-
type: "object",
|
|
452
|
-
required: ["type"],
|
|
453
|
-
properties: { type: { enum: [...COMMAND_TYPES] } },
|
|
454
|
-
allOf: COMMAND_TYPES.map((type) => ({
|
|
455
|
-
if: { properties: { type: { const: type } }, required: ["type"] },
|
|
456
|
-
then: { $ref: `#/$defs/command_${type}` }
|
|
457
|
-
}))
|
|
458
|
-
};
|
|
459
|
-
var RUN_EVENT_SCHEMA = {
|
|
460
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
461
|
-
$id: RUN_EVENT_SCHEMA_ID,
|
|
462
|
-
title: "FluidGrids durable-function history event",
|
|
463
|
-
description: "One row of workflow_run_events as the service returns it (offloaded payloads inlined). type is UPPER_SNAKE.",
|
|
464
|
-
...RUN_EVENT_RECORD,
|
|
465
|
-
$defs: { ...SHARED_DEFS, ...payloadDefs() }
|
|
466
|
-
};
|
|
467
|
-
var WORKFLOW_COMMAND_SCHEMA = {
|
|
468
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
469
|
-
$id: WORKFLOW_COMMAND_SCHEMA_ID,
|
|
470
|
-
title: "FluidGrids workflow-task command",
|
|
471
|
-
description: "A flat object discriminated by an UPPER_SNAKE type. Commands travel as [JSON!]! (DB4). UPSERT_SEARCH_ATTRIBUTES, ACCEPT_UPDATE, REJECT_UPDATE and COMPLETE_UPDATE are defined but refused in Phase B.",
|
|
472
|
-
...COMMAND_ONE_OF,
|
|
473
|
-
$defs: { ...SHARED_DEFS, ...commandDefs() }
|
|
474
|
-
};
|
|
475
|
-
var WORKFLOW_TASK_SCHEMA = {
|
|
476
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
477
|
-
$id: WORKFLOW_TASK_SCHEMA_ID,
|
|
478
|
-
title: "FluidGrids workflow task (runtime ABI protocol 1)",
|
|
479
|
-
description: 'globalThis.__fluidgridsRuntime: start(JSON of request); while (step() === "more") drain jobs; complete() returns JSON of result.',
|
|
480
|
-
oneOf: [{ $ref: "#/$defs/request" }, { $ref: "#/$defs/result" }],
|
|
481
|
-
$defs: {
|
|
482
|
-
...SHARED_DEFS,
|
|
483
|
-
...payloadDefs(),
|
|
484
|
-
...commandDefs(),
|
|
485
|
-
event: RUN_EVENT_RECORD,
|
|
486
|
-
command: COMMAND_ONE_OF,
|
|
487
|
-
info: {
|
|
488
|
-
type: "object",
|
|
489
|
-
required: ["runId", "workspaceId"],
|
|
490
|
-
properties: {
|
|
491
|
-
runId: ID,
|
|
492
|
-
workspaceId: ID,
|
|
493
|
-
workflowKey: { type: "string" },
|
|
494
|
-
version: {},
|
|
495
|
-
buildId: { type: "string" },
|
|
496
|
-
businessId: { type: "string" },
|
|
497
|
-
attempt: { type: "integer", minimum: 1 },
|
|
498
|
-
taskQueue: { type: "string" },
|
|
499
|
-
parentRunId: { type: ["string", "null"] },
|
|
500
|
-
rootRunId: { type: ["string", "null"] },
|
|
501
|
-
firstRunId: { type: ["string", "null"] },
|
|
502
|
-
continuedFromRunId: { type: ["string", "null"] },
|
|
503
|
-
lastResult: {},
|
|
504
|
-
lastFailure: { oneOf: [{ type: "null" }, FAILURE_REF] },
|
|
505
|
-
startedAt: { type: "string" },
|
|
506
|
-
runStartedAt: { type: "string" },
|
|
507
|
-
historyLimit: {
|
|
508
|
-
type: "object",
|
|
509
|
-
required: ["events", "bytes"],
|
|
510
|
-
properties: {
|
|
511
|
-
events: { type: "integer", minimum: 1 },
|
|
512
|
-
bytes: { type: "integer", minimum: 1 }
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
timeouts: { type: "object" },
|
|
516
|
-
headers: { $ref: "#/$defs/headers" },
|
|
517
|
-
priority: { type: "integer", minimum: 1, maximum: 5 },
|
|
518
|
-
summary: { type: "string" },
|
|
519
|
-
details: { type: "string" },
|
|
520
|
-
context: { type: "object" }
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
request: {
|
|
524
|
-
type: "object",
|
|
525
|
-
required: ["protocol", "kind", "workflowFn", "info", "history", "nowMs"],
|
|
526
|
-
properties: {
|
|
527
|
-
protocol: { const: HISTORY_PROTOCOL },
|
|
528
|
-
kind: { enum: ["task", "query", "verify"] },
|
|
529
|
-
workflowFn: ID,
|
|
530
|
-
info: { $ref: "#/$defs/info" },
|
|
531
|
-
history: { type: "array", items: { $ref: "#/$defs/event" } },
|
|
532
|
-
nowMs: { type: "number" },
|
|
533
|
-
localActivityResults: {
|
|
534
|
-
type: "array",
|
|
535
|
-
items: {
|
|
536
|
-
type: "object",
|
|
537
|
-
required: ["localActivityId", "attempts"],
|
|
538
|
-
properties: {
|
|
539
|
-
localActivityId: ID,
|
|
540
|
-
result: {},
|
|
541
|
-
failure: FAILURE_REF,
|
|
542
|
-
attempts: { type: "integer", minimum: 1 }
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
queries: {
|
|
547
|
-
type: "array",
|
|
548
|
-
items: {
|
|
549
|
-
type: "object",
|
|
550
|
-
required: ["queryId", "name"],
|
|
551
|
-
properties: {
|
|
552
|
-
queryId: ID,
|
|
553
|
-
name: { enum: [...BUILT_IN_QUERIES] },
|
|
554
|
-
args: {}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
result: {
|
|
561
|
-
type: "object",
|
|
562
|
-
required: ["protocol", "outcome", "commands", "logs"],
|
|
563
|
-
properties: {
|
|
564
|
-
protocol: { const: HISTORY_PROTOCOL },
|
|
565
|
-
outcome: { enum: ["commands", "failed", "localActivityRequested"] },
|
|
566
|
-
commands: { type: "array", items: { $ref: "#/$defs/command" } },
|
|
567
|
-
localActivityRequests: { type: "array", items: { type: "object" } },
|
|
568
|
-
queryResults: {
|
|
569
|
-
type: "array",
|
|
570
|
-
items: {
|
|
571
|
-
type: "object",
|
|
572
|
-
required: ["queryId"],
|
|
573
|
-
properties: { queryId: ID, value: {}, error: { type: "string" } }
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
failure: {
|
|
577
|
-
type: "object",
|
|
578
|
-
required: ["cause", "message"],
|
|
579
|
-
properties: {
|
|
580
|
-
cause: { enum: [...TASK_FAILURE_CAUSES] },
|
|
581
|
-
message: { type: "string" },
|
|
582
|
-
stackTrace: { type: "string" },
|
|
583
|
-
seq: { type: "integer" },
|
|
584
|
-
errorType: { type: "string" }
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
logs: {
|
|
588
|
-
type: "array",
|
|
589
|
-
items: {
|
|
590
|
-
type: "object",
|
|
591
|
-
required: ["level", "message"],
|
|
592
|
-
properties: {
|
|
593
|
-
level: { enum: ["debug", "info", "warn", "error"] },
|
|
594
|
-
message: { type: "string" },
|
|
595
|
-
data: {}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
stackTrace: { type: "string" }
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
var HISTORY_FILE_SCHEMA = {
|
|
605
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
606
|
-
$id: HISTORY_FILE_SCHEMA_ID,
|
|
607
|
-
title: "FluidGrids durable-function history file",
|
|
608
|
-
type: "object",
|
|
609
|
-
required: ["format", "formatVersion", "workflowFn", "events"],
|
|
610
|
-
properties: {
|
|
611
|
-
format: { const: HISTORY_FILE_FORMAT },
|
|
612
|
-
formatVersion: { const: HISTORY_PROTOCOL },
|
|
613
|
-
name: { type: "string" },
|
|
614
|
-
description: { type: "string" },
|
|
615
|
-
workflowFn: ID,
|
|
616
|
-
source: { type: "string", description: "Fixture source module, relative to the file." },
|
|
617
|
-
replaySource: {
|
|
618
|
-
type: "string",
|
|
619
|
-
description: "Fixture module the replay check runs instead of source (a hotfix or a patched() version)."
|
|
620
|
-
},
|
|
621
|
-
replay: {
|
|
622
|
-
type: "boolean",
|
|
623
|
-
description: "False for histories that use Phase C features (updates); they are parsed and projected but not replayed."
|
|
624
|
-
},
|
|
625
|
-
info: { $ref: "#/$defs/info" },
|
|
626
|
-
nowMs: {
|
|
627
|
-
type: "number",
|
|
628
|
-
description: "nowMs of the replay request for the conformance check."
|
|
629
|
-
},
|
|
630
|
-
events: { type: "array", items: { $ref: "#/$defs/event" } },
|
|
631
|
-
expected: {
|
|
632
|
-
type: "object",
|
|
633
|
-
description: "The replay result the conformance check must reproduce."
|
|
634
|
-
}
|
|
635
|
-
},
|
|
636
|
-
$defs: {
|
|
637
|
-
...SHARED_DEFS,
|
|
638
|
-
...payloadDefs(),
|
|
639
|
-
event: RUN_EVENT_RECORD,
|
|
640
|
-
info: WORKFLOW_TASK_SCHEMA.$defs.info
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
var HISTORY_SCHEMA_FILES = [
|
|
644
|
-
["run-event.schema.json", RUN_EVENT_SCHEMA],
|
|
645
|
-
["workflow-command.schema.json", WORKFLOW_COMMAND_SCHEMA],
|
|
646
|
-
["workflow-task.schema.json", WORKFLOW_TASK_SCHEMA],
|
|
647
|
-
["history-file.schema.json", HISTORY_FILE_SCHEMA]
|
|
648
|
-
];
|
|
649
|
-
var tools;
|
|
650
|
-
function schemaTools() {
|
|
651
|
-
if (!tools) {
|
|
652
|
-
const ajv = new Ajv2020({ allErrors: true, strict: false });
|
|
653
|
-
tools = {
|
|
654
|
-
ajv,
|
|
655
|
-
command: ajv.compile(WORKFLOW_COMMAND_SCHEMA),
|
|
656
|
-
event: ajv.compile(RUN_EVENT_SCHEMA),
|
|
657
|
-
file: ajv.compile(HISTORY_FILE_SCHEMA)
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
return tools;
|
|
661
|
-
}
|
|
662
|
-
function issuesOf(index, errors) {
|
|
663
|
-
const real = (errors ?? []).filter((error) => error.keyword !== "if");
|
|
664
|
-
return real.map((error) => ({
|
|
665
|
-
index,
|
|
666
|
-
code: `schema.${error.keyword}`,
|
|
667
|
-
message: `${error.instancePath || "/"} ${error.message ?? "is invalid"}`,
|
|
668
|
-
path: error.instancePath
|
|
669
|
-
}));
|
|
670
|
-
}
|
|
671
|
-
function validateCommand(command2, index = 0) {
|
|
672
|
-
const { command: validate } = schemaTools();
|
|
673
|
-
if (validate(command2)) {
|
|
674
|
-
return { ok: true, command: command2 };
|
|
675
|
-
}
|
|
676
|
-
return { ok: false, issues: issuesOf(index, validate.errors) };
|
|
677
|
-
}
|
|
678
|
-
function idOf(command2) {
|
|
679
|
-
switch (command2.type) {
|
|
680
|
-
case "SCHEDULE_ACTIVITY":
|
|
681
|
-
return `activity:${command2.activityId}`;
|
|
682
|
-
case "START_TIMER":
|
|
683
|
-
return `timer:${command2.timerId}`;
|
|
684
|
-
case "START_CHILD_RUN":
|
|
685
|
-
return `child:${command2.childId}`;
|
|
686
|
-
case "SIGNAL_RUN":
|
|
687
|
-
case "REQUEST_CANCEL_EXTERNAL_RUN":
|
|
688
|
-
return `external:${command2.externalId}`;
|
|
689
|
-
case "RECORD_SIDE_EFFECT":
|
|
690
|
-
return `sideEffect:${command2.sideEffectId}`;
|
|
691
|
-
case "RECORD_MARKER":
|
|
692
|
-
return `marker:${command2.markerId}`;
|
|
693
|
-
case "RECORD_LOCAL_ACTIVITY":
|
|
694
|
-
return `local:${command2.localActivityId}`;
|
|
695
|
-
default:
|
|
696
|
-
return void 0;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
function validateCommands(commands, options = {}) {
|
|
700
|
-
const max = options.maxCommands ?? 1e3;
|
|
701
|
-
if (!Array.isArray(commands))
|
|
702
|
-
return {
|
|
703
|
-
ok: false,
|
|
704
|
-
cause: "INVALID_REQUEST",
|
|
705
|
-
issues: [{ index: 0, code: "commands.notArray", message: "commands must be an array" }]
|
|
706
|
-
};
|
|
707
|
-
if (commands.length > max)
|
|
708
|
-
return {
|
|
709
|
-
ok: false,
|
|
710
|
-
cause: "INVALID_REQUEST",
|
|
711
|
-
issues: [
|
|
712
|
-
{
|
|
713
|
-
index: max,
|
|
714
|
-
code: "commands.tooMany",
|
|
715
|
-
message: `A task may return at most ${max} commands; it returned ${commands.length}`
|
|
716
|
-
}
|
|
717
|
-
]
|
|
718
|
-
};
|
|
719
|
-
const issues = [];
|
|
720
|
-
const valid = [];
|
|
721
|
-
const ids = /* @__PURE__ */ new Set();
|
|
722
|
-
let unsupported = false;
|
|
723
|
-
commands.forEach((raw, index) => {
|
|
724
|
-
const checked = validateCommand(raw, index);
|
|
725
|
-
if (!checked.ok) {
|
|
726
|
-
issues.push(...checked.issues);
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
const command2 = checked.command;
|
|
730
|
-
if (!isWorkflowCommandEnabled(command2, options.enabled)) {
|
|
731
|
-
unsupported = true;
|
|
732
|
-
issues.push({
|
|
733
|
-
index,
|
|
734
|
-
code: "commands.unsupported",
|
|
735
|
-
message: `${command2.type} is not supported in this release`
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
const id = idOf(command2);
|
|
739
|
-
if (id !== void 0) {
|
|
740
|
-
if (ids.has(id))
|
|
741
|
-
issues.push({ index, code: "commands.duplicateId", message: `${id} is used twice` });
|
|
742
|
-
ids.add(id);
|
|
743
|
-
}
|
|
744
|
-
if (TERMINAL_COMMANDS.has(command2.type) && index !== commands.length - 1)
|
|
745
|
-
issues.push({
|
|
746
|
-
index,
|
|
747
|
-
code: "commands.terminalNotLast",
|
|
748
|
-
message: `${command2.type} must be the last command of the batch`
|
|
749
|
-
});
|
|
750
|
-
if (command2.type === "SCHEDULE_ACTIVITY" && !isActivityNodeTypeAllowed(command2.nodeType))
|
|
751
|
-
issues.push({
|
|
752
|
-
index,
|
|
753
|
-
code: "durable.activityTypeNotAllowed",
|
|
754
|
-
message: `${command2.nodeType} cannot run as a durable activity`,
|
|
755
|
-
path: "/nodeType"
|
|
756
|
-
});
|
|
757
|
-
valid.push(command2);
|
|
758
|
-
});
|
|
759
|
-
if (issues.length > 0)
|
|
760
|
-
return { ok: false, cause: unsupported ? "UNSUPPORTED_COMMAND" : "INVALID_REQUEST", issues };
|
|
761
|
-
return { ok: true, commands: valid };
|
|
762
|
-
}
|
|
763
|
-
function validateHistory(events) {
|
|
764
|
-
const { event: validate } = schemaTools();
|
|
765
|
-
if (!Array.isArray(events))
|
|
766
|
-
return {
|
|
767
|
-
ok: false,
|
|
768
|
-
issues: [{ index: 0, code: "history.notArray", message: "history must be an array" }]
|
|
769
|
-
};
|
|
770
|
-
const issues = [];
|
|
771
|
-
events.forEach((event, index) => {
|
|
772
|
-
if (!validate(event)) {
|
|
773
|
-
issues.push(...issuesOf(index, validate.errors));
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
if (isRecord(event) && event["seq"] !== index + 1)
|
|
777
|
-
issues.push({
|
|
778
|
-
index,
|
|
779
|
-
code: "history.seqGap",
|
|
780
|
-
message: `event ${index + 1} has seq ${String(event["seq"])}`
|
|
781
|
-
});
|
|
782
|
-
});
|
|
783
|
-
return { ok: issues.length === 0, issues };
|
|
784
|
-
}
|
|
785
|
-
function validateHistoryFile(value) {
|
|
786
|
-
const { file: validate } = schemaTools();
|
|
787
|
-
if (validate(value)) return validateHistory(isRecord(value) ? value["events"] : void 0);
|
|
788
|
-
return { ok: false, issues: issuesOf(0, validate.errors) };
|
|
789
|
-
}
|
|
790
|
-
function compilePayloadValidator(schema) {
|
|
791
|
-
const { ajv } = schemaTools();
|
|
792
|
-
const validate = ajv.compile(schema);
|
|
793
|
-
return (value) => {
|
|
794
|
-
if (validate(value)) return { ok: true };
|
|
795
|
-
return {
|
|
796
|
-
ok: false,
|
|
797
|
-
errors: (validate.errors ?? []).map(
|
|
798
|
-
(error) => `${error.instancePath || "/"} ${error.message ?? "is invalid"}`
|
|
799
|
-
)
|
|
800
|
-
};
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// src/history/file.ts
|
|
805
|
-
var HistoryFileError = class extends Error {
|
|
806
|
-
constructor(message, issues = []) {
|
|
807
|
-
super(message);
|
|
808
|
-
this.issues = issues;
|
|
809
|
-
this.name = "HistoryFileError";
|
|
810
|
-
}
|
|
811
|
-
issues;
|
|
812
|
-
};
|
|
813
|
-
function parseHistoryFile(input) {
|
|
814
|
-
let value = input;
|
|
815
|
-
if (typeof input === "string") {
|
|
816
|
-
try {
|
|
817
|
-
value = JSON.parse(input);
|
|
818
|
-
} catch (error) {
|
|
819
|
-
throw new HistoryFileError(
|
|
820
|
-
`Not JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
if (!isRecord(value) || value["format"] !== HISTORY_FILE_FORMAT)
|
|
825
|
-
throw new HistoryFileError(`Not a ${HISTORY_FILE_FORMAT} document`);
|
|
826
|
-
const checked = validateHistoryFile(value);
|
|
827
|
-
if (!checked.ok)
|
|
828
|
-
throw new HistoryFileError(
|
|
829
|
-
"The history file does not match history-file.schema.json",
|
|
830
|
-
checked.issues.map((issue) => `#${issue.index}: ${issue.message}`)
|
|
831
|
-
);
|
|
832
|
-
return value;
|
|
833
|
-
}
|
|
834
|
-
function createHistoryFile(workflowFn, events, extra = {}) {
|
|
835
|
-
return {
|
|
836
|
-
format: HISTORY_FILE_FORMAT,
|
|
837
|
-
formatVersion: HISTORY_PROTOCOL,
|
|
838
|
-
...extra,
|
|
839
|
-
workflowFn,
|
|
840
|
-
events
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
function serializeHistoryFile(file) {
|
|
844
|
-
return `${JSON.stringify(file, null, 2)}
|
|
845
|
-
`;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
export { HISTORY_FILE_FORMAT, HISTORY_FILE_SCHEMA, HISTORY_FILE_SCHEMA_ID, HISTORY_SCHEMA_FILES, HistoryFileError, RUN_EVENT_SCHEMA, RUN_EVENT_SCHEMA_ID, WORKFLOW_COMMAND_SCHEMA, WORKFLOW_COMMAND_SCHEMA_ID, WORKFLOW_TASK_SCHEMA, WORKFLOW_TASK_SCHEMA_ID, compilePayloadValidator, createHistoryFile, parseHistoryFile, serializeHistoryFile, validateCommand, validateCommands, validateHistory, validateHistoryFile };
|