@workflow/world-testing 4.1.0-beta.67 → 4.1.0-beta.68
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.
|
@@ -50142,6 +50142,16 @@ function createEventsStorage(basedir) {
|
|
|
50142
50142
|
wait
|
|
50143
50143
|
};
|
|
50144
50144
|
},
|
|
50145
|
+
async get(runId, eventId, params) {
|
|
50146
|
+
const compositeKey = `${runId}-${eventId}`;
|
|
50147
|
+
const eventPath = import_node_path5.default.join(basedir, "events", `${compositeKey}.json`);
|
|
50148
|
+
const event = await readJSON(eventPath, EventSchema);
|
|
50149
|
+
if (!event) {
|
|
50150
|
+
throw new Error(`Event ${eventId} in run ${runId} not found`);
|
|
50151
|
+
}
|
|
50152
|
+
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
50153
|
+
return filterEventData(event, resolveData);
|
|
50154
|
+
},
|
|
50145
50155
|
async list(params) {
|
|
50146
50156
|
const { runId } = params;
|
|
50147
50157
|
const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
@@ -53076,7 +53086,7 @@ var RpcService3 = SemanticConvention3("rpc.service");
|
|
|
53076
53086
|
var RpcMethod3 = SemanticConvention3("rpc.method");
|
|
53077
53087
|
|
|
53078
53088
|
// ../world-vercel/dist/version.js
|
|
53079
|
-
var version2 = "4.1.0-beta.
|
|
53089
|
+
var version2 = "4.1.0-beta.41";
|
|
53080
53090
|
|
|
53081
53091
|
// ../world-vercel/dist/utils.js
|
|
53082
53092
|
var WORKFLOW_SERVER_URL_OVERRIDE = "";
|
|
@@ -53852,6 +53862,22 @@ async function hydrateEventRefs(events, config3, refResolveConcurrency) {
|
|
|
53852
53862
|
});
|
|
53853
53863
|
}
|
|
53854
53864
|
__name(hydrateEventRefs, "hydrateEventRefs");
|
|
53865
|
+
async function getEvent(runId, eventId, params, config3) {
|
|
53866
|
+
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION2;
|
|
53867
|
+
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
53868
|
+
const searchParams = new URLSearchParams();
|
|
53869
|
+
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53870
|
+
const queryString = searchParams.toString();
|
|
53871
|
+
const endpoint = `/v2/runs/${runId}/events/${eventId}${queryString ? `?${queryString}` : ""}`;
|
|
53872
|
+
const event = await makeRequest({
|
|
53873
|
+
endpoint,
|
|
53874
|
+
options: { method: "GET" },
|
|
53875
|
+
config: config3,
|
|
53876
|
+
schema: resolveData === "none" ? EventWithRefsSchema : EventSchema
|
|
53877
|
+
});
|
|
53878
|
+
return filterEventData2(event, resolveData);
|
|
53879
|
+
}
|
|
53880
|
+
__name(getEvent, "getEvent");
|
|
53855
53881
|
async function getWorkflowRunEvents(params, config3) {
|
|
53856
53882
|
const searchParams = new URLSearchParams();
|
|
53857
53883
|
const { pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION2 } = params;
|
|
@@ -54109,6 +54135,7 @@ function createStorage2(config3) {
|
|
|
54109
54135
|
},
|
|
54110
54136
|
events: {
|
|
54111
54137
|
create: /* @__PURE__ */ __name((runId, data, params) => createWorkflowRunEvent(runId, data, params, config3), "create"),
|
|
54138
|
+
get: /* @__PURE__ */ __name((runId, eventId, params) => getEvent(runId, eventId, params, config3), "get"),
|
|
54112
54139
|
list: /* @__PURE__ */ __name((params) => getWorkflowRunEvents(params, config3), "list"),
|
|
54113
54140
|
listByCorrelationId: /* @__PURE__ */ __name((params) => getWorkflowRunEvents(params, config3), "listByCorrelationId")
|
|
54114
54141
|
},
|
|
@@ -55303,6 +55330,19 @@ function getStepFunction(stepId) {
|
|
|
55303
55330
|
return void 0;
|
|
55304
55331
|
}
|
|
55305
55332
|
__name(getStepFunction, "getStepFunction");
|
|
55333
|
+
function scheduleWhenIdle(ctx, fn) {
|
|
55334
|
+
const check2 = /* @__PURE__ */ __name(() => {
|
|
55335
|
+
if (ctx.pendingDeliveries > 0) {
|
|
55336
|
+
ctx.promiseQueue.then(() => {
|
|
55337
|
+
setTimeout(check2, 0);
|
|
55338
|
+
});
|
|
55339
|
+
} else {
|
|
55340
|
+
fn();
|
|
55341
|
+
}
|
|
55342
|
+
}, "check");
|
|
55343
|
+
setTimeout(check2, 0);
|
|
55344
|
+
}
|
|
55345
|
+
__name(scheduleWhenIdle, "scheduleWhenIdle");
|
|
55306
55346
|
|
|
55307
55347
|
// ../core/dist/serialization.js
|
|
55308
55348
|
var SerializationFormat = {
|
|
@@ -57161,7 +57201,7 @@ function createUseStep(ctx) {
|
|
|
57161
57201
|
});
|
|
57162
57202
|
ctx.eventsConsumer.subscribe((event) => {
|
|
57163
57203
|
if (!event) {
|
|
57164
|
-
ctx
|
|
57204
|
+
scheduleWhenIdle(ctx, () => {
|
|
57165
57205
|
ctx.onWorkflowError(new WorkflowSuspension(ctx.invocationsQueue, ctx.globalThis));
|
|
57166
57206
|
});
|
|
57167
57207
|
return EventConsumerResult.NotConsumed;
|
|
@@ -57211,12 +57251,15 @@ function createUseStep(ctx) {
|
|
|
57211
57251
|
}
|
|
57212
57252
|
if (event.eventType === "step_completed") {
|
|
57213
57253
|
ctx.invocationsQueue.delete(event.correlationId);
|
|
57254
|
+
ctx.pendingDeliveries++;
|
|
57214
57255
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
57215
57256
|
try {
|
|
57216
57257
|
const hydratedResult = await hydrateStepReturnValue(event.eventData.result, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
57217
57258
|
resolve3(hydratedResult);
|
|
57218
57259
|
} catch (error48) {
|
|
57219
57260
|
reject(error48);
|
|
57261
|
+
} finally {
|
|
57262
|
+
ctx.pendingDeliveries--;
|
|
57220
57263
|
}
|
|
57221
57264
|
});
|
|
57222
57265
|
return EventConsumerResult.Finished;
|
|
@@ -57380,8 +57423,8 @@ function createCreateHook(ctx) {
|
|
|
57380
57423
|
ctx.eventsConsumer.subscribe((event) => {
|
|
57381
57424
|
if (!event) {
|
|
57382
57425
|
eventLogEmpty = true;
|
|
57383
|
-
if (promises.length > 0) {
|
|
57384
|
-
ctx
|
|
57426
|
+
if (promises.length > 0 && payloadsQueue.length === 0) {
|
|
57427
|
+
scheduleWhenIdle(ctx, () => {
|
|
57385
57428
|
ctx.onWorkflowError(new WorkflowSuspension(ctx.invocationsQueue, ctx.globalThis));
|
|
57386
57429
|
});
|
|
57387
57430
|
}
|
|
@@ -57416,12 +57459,15 @@ function createCreateHook(ctx) {
|
|
|
57416
57459
|
if (promises.length > 0) {
|
|
57417
57460
|
const next2 = promises.shift();
|
|
57418
57461
|
if (next2) {
|
|
57462
|
+
ctx.pendingDeliveries++;
|
|
57419
57463
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
57420
57464
|
try {
|
|
57421
57465
|
const payload = await hydrateStepReturnValue(event.eventData.payload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
57422
57466
|
next2.resolve(payload);
|
|
57423
57467
|
} catch (error48) {
|
|
57424
57468
|
next2.reject(error48);
|
|
57469
|
+
} finally {
|
|
57470
|
+
ctx.pendingDeliveries--;
|
|
57425
57471
|
}
|
|
57426
57472
|
});
|
|
57427
57473
|
}
|
|
@@ -57452,19 +57498,22 @@ function createCreateHook(ctx) {
|
|
|
57452
57498
|
if (payloadsQueue.length > 0) {
|
|
57453
57499
|
const nextPayload = payloadsQueue.shift();
|
|
57454
57500
|
if (nextPayload) {
|
|
57501
|
+
ctx.pendingDeliveries++;
|
|
57455
57502
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
57456
57503
|
try {
|
|
57457
57504
|
const payload = await hydrateStepReturnValue(nextPayload.eventData.payload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
57458
57505
|
resolvers.resolve(payload);
|
|
57459
57506
|
} catch (error48) {
|
|
57460
57507
|
resolvers.reject(error48);
|
|
57508
|
+
} finally {
|
|
57509
|
+
ctx.pendingDeliveries--;
|
|
57461
57510
|
}
|
|
57462
57511
|
});
|
|
57463
57512
|
return resolvers.promise;
|
|
57464
57513
|
}
|
|
57465
57514
|
}
|
|
57466
57515
|
if (eventLogEmpty) {
|
|
57467
|
-
ctx
|
|
57516
|
+
scheduleWhenIdle(ctx, () => {
|
|
57468
57517
|
ctx.onWorkflowError(new WorkflowSuspension(ctx.invocationsQueue, ctx.globalThis));
|
|
57469
57518
|
});
|
|
57470
57519
|
}
|
|
@@ -57486,7 +57535,7 @@ function createCreateHook(ctx) {
|
|
|
57486
57535
|
}
|
|
57487
57536
|
if (promises.length > 0) {
|
|
57488
57537
|
promises.length = 0;
|
|
57489
|
-
ctx
|
|
57538
|
+
scheduleWhenIdle(ctx, () => {
|
|
57490
57539
|
ctx.onWorkflowError(new WorkflowSuspension(ctx.invocationsQueue, ctx.globalThis));
|
|
57491
57540
|
});
|
|
57492
57541
|
}
|
|
@@ -57531,7 +57580,7 @@ function createSleep(ctx) {
|
|
|
57531
57580
|
ctx.invocationsQueue.set(correlationId, waitItem);
|
|
57532
57581
|
ctx.eventsConsumer.subscribe((event) => {
|
|
57533
57582
|
if (!event) {
|
|
57534
|
-
ctx
|
|
57583
|
+
scheduleWhenIdle(ctx, () => {
|
|
57535
57584
|
ctx.onWorkflowError(new WorkflowSuspension(ctx.invocationsQueue, ctx.globalThis));
|
|
57536
57585
|
});
|
|
57537
57586
|
return EventConsumerResult.NotConsumed;
|
|
@@ -57628,7 +57677,8 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
|
57628
57677
|
},
|
|
57629
57678
|
set promiseQueue(value) {
|
|
57630
57679
|
promiseQueueHolder.current = value;
|
|
57631
|
-
}
|
|
57680
|
+
},
|
|
57681
|
+
pendingDeliveries: 0
|
|
57632
57682
|
};
|
|
57633
57683
|
workflowContext.eventsConsumer.subscribe((event) => {
|
|
57634
57684
|
const createdAt = event?.createdAt;
|
|
@@ -57658,6 +57708,7 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
|
57658
57708
|
vmGlobalThis[WORKFLOW_GET_STREAM_ID] = (namespace) => getWorkflowRunStreamId(workflowRun.runId, namespace);
|
|
57659
57709
|
const url2 = isVercel ? `https://${process.env.VERCEL_URL}` : `http://localhost:${port ?? 3e3}`;
|
|
57660
57710
|
const ctx = {
|
|
57711
|
+
workflowName: workflowRun.workflowName,
|
|
57661
57712
|
workflowRunId: workflowRun.runId,
|
|
57662
57713
|
workflowStartedAt: new vmGlobalThis.Date(+startedAt),
|
|
57663
57714
|
url: url2
|
|
@@ -58255,11 +58306,13 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
58255
58306
|
result = await trace2("step.execute", {}, async () => {
|
|
58256
58307
|
return await contextStorage.run({
|
|
58257
58308
|
stepMetadata: {
|
|
58309
|
+
stepName,
|
|
58258
58310
|
stepId,
|
|
58259
58311
|
stepStartedAt: /* @__PURE__ */ new Date(+stepStartedAt),
|
|
58260
58312
|
attempt
|
|
58261
58313
|
},
|
|
58262
58314
|
workflowMetadata: {
|
|
58315
|
+
workflowName,
|
|
58263
58316
|
workflowRunId,
|
|
58264
58317
|
workflowStartedAt: /* @__PURE__ */ new Date(+workflowStartedAt),
|
|
58265
58318
|
// TODO: there should be a getUrl method on the world interface itself. This
|
|
@@ -58941,7 +58994,7 @@ function getWritable(options = {}) {
|
|
|
58941
58994
|
__name(getWritable, "getWritable");
|
|
58942
58995
|
|
|
58943
58996
|
// ../workflow/dist/stdlib.js
|
|
58944
|
-
var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.
|
|
58997
|
+
var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.67//fetch");
|
|
58945
58998
|
|
|
58946
58999
|
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
58947
59000
|
var NEVER = Object.freeze({
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"steps": {
|
|
4
|
+
"workflows/hooks.ts": {
|
|
5
|
+
"writeEvent": {
|
|
6
|
+
"stepId": "step//./workflows/hooks//writeEvent"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"workflows/noop.ts": {
|
|
10
|
+
"noop": {
|
|
11
|
+
"stepId": "step//./workflows/noop//noop"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"workflows/null-byte.ts": {
|
|
15
|
+
"nullByteStep": {
|
|
16
|
+
"stepId": "step//./workflows/null-byte//nullByteStep"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"workflows/retriable-and-fatal.ts": {
|
|
20
|
+
"stepThatFails": {
|
|
21
|
+
"stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
|
|
22
|
+
},
|
|
23
|
+
"stepThatThrowsRetryableError": {
|
|
24
|
+
"stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
4
27
|
"workflow/dist/internal/builtins.js": {
|
|
5
28
|
"__builtin_response_array_buffer": {
|
|
6
29
|
"stepId": "__builtin_response_array_buffer"
|
|
@@ -17,46 +40,23 @@
|
|
|
17
40
|
"stepId": "step//./workflows/addition//add"
|
|
18
41
|
}
|
|
19
42
|
},
|
|
20
|
-
"workflows/null-byte.ts": {
|
|
21
|
-
"nullByteStep": {
|
|
22
|
-
"stepId": "step//./workflows/null-byte//nullByteStep"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
43
|
"workflow/dist/stdlib.js": {
|
|
26
44
|
"fetch": {
|
|
27
|
-
"stepId": "step//workflow@4.2.0-beta.
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"workflows/hooks.ts": {
|
|
31
|
-
"writeEvent": {
|
|
32
|
-
"stepId": "step//./workflows/hooks//writeEvent"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"workflows/noop.ts": {
|
|
36
|
-
"noop": {
|
|
37
|
-
"stepId": "step//./workflows/noop//noop"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"workflows/retriable-and-fatal.ts": {
|
|
41
|
-
"stepThatFails": {
|
|
42
|
-
"stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
|
|
43
|
-
},
|
|
44
|
-
"stepThatThrowsRetryableError": {
|
|
45
|
-
"stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
|
|
45
|
+
"stepId": "step//workflow@4.2.0-beta.67//fetch"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"workflows": {
|
|
50
|
-
"workflows/
|
|
51
|
-
"
|
|
52
|
-
"workflowId": "workflow//./workflows/
|
|
50
|
+
"workflows/hooks.ts": {
|
|
51
|
+
"collectWithHook": {
|
|
52
|
+
"workflowId": "workflow//./workflows/hooks//collectWithHook",
|
|
53
53
|
"graph": {
|
|
54
54
|
"nodes": [
|
|
55
55
|
{
|
|
56
56
|
"id": "start",
|
|
57
57
|
"type": "workflowStart",
|
|
58
58
|
"data": {
|
|
59
|
-
"label": "Start:
|
|
59
|
+
"label": "Start: collectWithHook",
|
|
60
60
|
"nodeKind": "workflow_start"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
@@ -80,16 +80,16 @@
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
-
"workflows/
|
|
84
|
-
"
|
|
85
|
-
"workflowId": "workflow//./workflows/
|
|
83
|
+
"workflows/noop.ts": {
|
|
84
|
+
"brokenWf": {
|
|
85
|
+
"workflowId": "workflow//./workflows/noop//brokenWf",
|
|
86
86
|
"graph": {
|
|
87
87
|
"nodes": [
|
|
88
88
|
{
|
|
89
89
|
"id": "start",
|
|
90
90
|
"type": "workflowStart",
|
|
91
91
|
"data": {
|
|
92
|
-
"label": "Start:
|
|
92
|
+
"label": "Start: brokenWf",
|
|
93
93
|
"nodeKind": "workflow_start"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
@@ -113,16 +113,16 @@
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
|
-
"workflows/
|
|
117
|
-
"
|
|
118
|
-
"workflowId": "workflow//./workflows/
|
|
116
|
+
"workflows/null-byte.ts": {
|
|
117
|
+
"nullByteWorkflow": {
|
|
118
|
+
"workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
|
|
119
119
|
"graph": {
|
|
120
120
|
"nodes": [
|
|
121
121
|
{
|
|
122
122
|
"id": "start",
|
|
123
123
|
"type": "workflowStart",
|
|
124
124
|
"data": {
|
|
125
|
-
"label": "Start:
|
|
125
|
+
"label": "Start: nullByteWorkflow",
|
|
126
126
|
"nodeKind": "workflow_start"
|
|
127
127
|
}
|
|
128
128
|
},
|
|
@@ -146,16 +146,16 @@
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
|
-
"workflows/
|
|
150
|
-
"
|
|
151
|
-
"workflowId": "workflow//./workflows/
|
|
149
|
+
"workflows/retriable-and-fatal.ts": {
|
|
150
|
+
"retryableAndFatalErrorWorkflow": {
|
|
151
|
+
"workflowId": "workflow//./workflows/retriable-and-fatal//retryableAndFatalErrorWorkflow",
|
|
152
152
|
"graph": {
|
|
153
153
|
"nodes": [
|
|
154
154
|
{
|
|
155
155
|
"id": "start",
|
|
156
156
|
"type": "workflowStart",
|
|
157
157
|
"data": {
|
|
158
|
-
"label": "Start:
|
|
158
|
+
"label": "Start: retryableAndFatalErrorWorkflow",
|
|
159
159
|
"nodeKind": "workflow_start"
|
|
160
160
|
}
|
|
161
161
|
},
|
|
@@ -179,16 +179,16 @@
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
"workflows/
|
|
183
|
-
"
|
|
184
|
-
"workflowId": "workflow//./workflows/
|
|
182
|
+
"workflows/addition.ts": {
|
|
183
|
+
"addition": {
|
|
184
|
+
"workflowId": "workflow//./workflows/addition//addition",
|
|
185
185
|
"graph": {
|
|
186
186
|
"nodes": [
|
|
187
187
|
{
|
|
188
188
|
"id": "start",
|
|
189
189
|
"type": "workflowStart",
|
|
190
190
|
"data": {
|
|
191
|
-
"label": "Start:
|
|
191
|
+
"label": "Start: addition",
|
|
192
192
|
"nodeKind": "workflow_start"
|
|
193
193
|
}
|
|
194
194
|
},
|