@workflow/world-testing 5.0.0-beta.31 → 5.0.0-beta.33

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.
@@ -17090,7 +17090,7 @@ var init_waits = __esm({
17090
17090
  });
17091
17091
 
17092
17092
  // ../world/dist/analytics.js
17093
- var NullableDateSchema, NullableStringSchema, NullableBooleanSchema, AnalyticsRunSchema, AnalyticsStepSchema, AnalyticsEventSchema, AnalyticsHookSchema, AnalyticsWaitSchema;
17093
+ var NAIVE_DATETIME, UTCDateSchema, NullableDateSchema, NullableStringSchema, NullableBooleanSchema, AnalyticsRunSchema, AnalyticsStepSchema, AnalyticsEventSchema, AnalyticsHookSchema, AnalyticsWaitSchema, AnalyticsAttributeKeySchema;
17094
17094
  var init_analytics = __esm({
17095
17095
  "../world/dist/analytics.js"() {
17096
17096
  "use strict";
@@ -17099,7 +17099,14 @@ var init_analytics = __esm({
17099
17099
  init_runs();
17100
17100
  init_steps();
17101
17101
  init_waits();
17102
- NullableDateSchema = external_exports.coerce.date().nullable().optional();
17102
+ NAIVE_DATETIME = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/;
17103
+ UTCDateSchema = external_exports.preprocess((value) => {
17104
+ if (typeof value === "string" && NAIVE_DATETIME.test(value)) {
17105
+ return `${value.replace(" ", "T")}Z`;
17106
+ }
17107
+ return value;
17108
+ }, external_exports.coerce.date());
17109
+ NullableDateSchema = UTCDateSchema.nullable().optional();
17103
17110
  NullableStringSchema = external_exports.string().nullable().optional();
17104
17111
  NullableBooleanSchema = external_exports.boolean().nullable().optional();
17105
17112
  AnalyticsRunSchema = external_exports.object({
@@ -17109,8 +17116,8 @@ var init_analytics = __esm({
17109
17116
  workflowName: external_exports.string(),
17110
17117
  specVersion: external_exports.coerce.number().optional(),
17111
17118
  attributes: external_exports.record(external_exports.string(), external_exports.string()).default({}),
17112
- createdAt: external_exports.coerce.date(),
17113
- updatedAt: external_exports.coerce.date(),
17119
+ createdAt: UTCDateSchema,
17120
+ updatedAt: UTCDateSchema,
17114
17121
  startedAt: NullableDateSchema,
17115
17122
  completedAt: NullableDateSchema,
17116
17123
  errorCode: NullableStringSchema,
@@ -17123,8 +17130,8 @@ var init_analytics = __esm({
17123
17130
  stepName: NullableStringSchema,
17124
17131
  status: StepStatusSchema,
17125
17132
  attempt: external_exports.number().optional(),
17126
- createdAt: external_exports.coerce.date(),
17127
- updatedAt: external_exports.coerce.date(),
17133
+ createdAt: UTCDateSchema,
17134
+ updatedAt: UTCDateSchema,
17128
17135
  startedAt: NullableDateSchema,
17129
17136
  completedAt: NullableDateSchema,
17130
17137
  retryAfter: NullableDateSchema,
@@ -17142,8 +17149,8 @@ var init_analytics = __esm({
17142
17149
  workflowName: external_exports.string(),
17143
17150
  deploymentId: external_exports.string(),
17144
17151
  specVersion: external_exports.coerce.number().optional(),
17145
- runCreatedAt: external_exports.coerce.date(),
17146
- createdAt: external_exports.coerce.date(),
17152
+ runCreatedAt: UTCDateSchema,
17153
+ createdAt: UTCDateSchema,
17147
17154
  region: NullableStringSchema,
17148
17155
  vercelId: NullableStringSchema,
17149
17156
  requestId: NullableStringSchema,
@@ -17164,8 +17171,8 @@ var init_analytics = __esm({
17164
17171
  "disposed",
17165
17172
  "conflict"
17166
17173
  ]),
17167
- createdAt: external_exports.coerce.date(),
17168
- updatedAt: external_exports.coerce.date(),
17174
+ createdAt: UTCDateSchema,
17175
+ updatedAt: UTCDateSchema,
17169
17176
  receivedAt: NullableDateSchema,
17170
17177
  disposedAt: NullableDateSchema,
17171
17178
  isWebhook: NullableBooleanSchema,
@@ -17178,12 +17185,18 @@ var init_analytics = __esm({
17178
17185
  waitId: external_exports.string(),
17179
17186
  status: WaitStatusSchema,
17180
17187
  resumeAt: NullableDateSchema,
17181
- createdAt: external_exports.coerce.date(),
17182
- updatedAt: external_exports.coerce.date(),
17188
+ createdAt: UTCDateSchema,
17189
+ updatedAt: UTCDateSchema,
17183
17190
  completedAt: NullableDateSchema,
17184
17191
  workflowCoreVersion: NullableStringSchema,
17185
17192
  workflowEncryptionEnabled: NullableBooleanSchema
17186
17193
  });
17194
+ AnalyticsAttributeKeySchema = external_exports.object({
17195
+ key: external_exports.string(),
17196
+ runCount: external_exports.coerce.number(),
17197
+ firstSeenAt: external_exports.coerce.date(),
17198
+ lastSeenAt: external_exports.coerce.date()
17199
+ });
17187
17200
  }
17188
17201
  });
17189
17202
 
@@ -24374,7 +24387,7 @@ var version2;
24374
24387
  var init_version = __esm({
24375
24388
  "../core/dist/version.js"() {
24376
24389
  "use strict";
24377
- version2 = "5.0.0-beta.31";
24390
+ version2 = "5.0.0-beta.33";
24378
24391
  }
24379
24392
  });
24380
24393
 
@@ -24464,7 +24477,7 @@ function parseHealthCheckResponse(chunks) {
24464
24477
  }
24465
24478
  async function healthCheck(world, endpoint, options) {
24466
24479
  const timeout = options?.timeout ?? DEFAULT_HEALTH_CHECK_TIMEOUT;
24467
- const correlationId = generateId();
24480
+ const correlationId = world.createRunId?.() ?? generateId();
24468
24481
  const streamName = getHealthCheckStreamName(correlationId);
24469
24482
  const queueName = `${getQueueTopicPrefix(endpoint, resolveQueueNamespace(options?.namespace))}health_check`;
24470
24483
  const startTime = Date.now();
@@ -26220,6 +26233,21 @@ function createReconnectingFramedStream(runId, name, startIndex) {
26220
26233
  }, "cancel")
26221
26234
  });
26222
26235
  }
26236
+ function recordStreamWriteFlush(startEpochMs, dispatchEpochMs, runId, name, chunkCount, byteCount) {
26237
+ void (async () => {
26238
+ await recordElapsedSpan("workflow.stream.flush", startEpochMs, {
26239
+ kind: await getSpanKind("CLIENT"),
26240
+ attributes: {
26241
+ "workflow.run.id": runId,
26242
+ "workflow.stream.name": name,
26243
+ "workflow.stream.operation": "flush",
26244
+ "workflow.stream.flush.buffer_dwell_ms": dispatchEpochMs - startEpochMs,
26245
+ "workflow.stream.flush.chunks": chunkCount,
26246
+ "workflow.stream.flush.bytes": byteCount
26247
+ }
26248
+ });
26249
+ })();
26250
+ }
26223
26251
  function getAllBaseReducers(global2 = globalThis) {
26224
26252
  return {
26225
26253
  ...getClassReducers(),
@@ -27147,6 +27175,7 @@ var init_serialization2 = __esm({
27147
27175
  getStreamFlushIntervalMs = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS, {
27148
27176
  integer: true
27149
27177
  }), "getStreamFlushIntervalMs");
27178
+ __name(recordStreamWriteFlush, "recordStreamWriteFlush");
27150
27179
  WorkflowServerWritableStream = class extends WritableStream {
27151
27180
  static {
27152
27181
  __name(this, "WorkflowServerWritableStream");
@@ -27182,6 +27211,7 @@ var init_serialization2 = __esm({
27182
27211
  let flushTimer = null;
27183
27212
  let flushPromise = null;
27184
27213
  let resolvedFlushIntervalMs;
27214
+ let batchStartAt;
27185
27215
  const flush = /* @__PURE__ */ __name(async () => {
27186
27216
  if (flushTimer) {
27187
27217
  clearTimeout(flushTimer);
@@ -27190,16 +27220,29 @@ var init_serialization2 = __esm({
27190
27220
  if (buffer2.length === 0) return;
27191
27221
  await ensureRunReady();
27192
27222
  const chunksToFlush = buffer2.slice();
27223
+ const batchStart = batchStartAt;
27224
+ batchStartAt = void 0;
27225
+ const dispatchAt = Date.now();
27193
27226
  const world = await worldPromise;
27194
27227
  if (resolvedFlushIntervalMs === void 0) {
27195
27228
  resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs();
27196
27229
  }
27197
- if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27198
- await world.streams.writeMulti(runId, name, chunksToFlush);
27199
- } else {
27200
- for (const chunk of chunksToFlush) {
27201
- await world.streams.write(runId, name, chunk);
27230
+ try {
27231
+ if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27232
+ await world.streams.writeMulti(runId, name, chunksToFlush);
27233
+ } else {
27234
+ for (const chunk of chunksToFlush) {
27235
+ await world.streams.write(runId, name, chunk);
27236
+ }
27237
+ }
27238
+ } catch (error48) {
27239
+ if (batchStart !== void 0) {
27240
+ batchStartAt = batchStartAt === void 0 ? batchStart : Math.min(batchStartAt, batchStart);
27202
27241
  }
27242
+ throw error48;
27243
+ }
27244
+ if (batchStart !== void 0) {
27245
+ recordStreamWriteFlush(batchStart, dispatchAt, runId, name, chunksToFlush.length, chunksToFlush.reduce((sum, c) => sum + c.byteLength, 0));
27203
27246
  }
27204
27247
  buffer2 = [];
27205
27248
  }, "flush");
@@ -27219,6 +27262,7 @@ var init_serialization2 = __esm({
27219
27262
  }, "scheduleFlush");
27220
27263
  super({
27221
27264
  async write(chunk) {
27265
+ if (batchStartAt === void 0) batchStartAt = Date.now();
27222
27266
  if (flushPromise) {
27223
27267
  await flushPromise;
27224
27268
  flushPromise = null;
@@ -27547,7 +27591,7 @@ async function start(workflow, argsOrOptions, options) {
27547
27591
  targetSupportsCompression = capabilities.supportedFormats.has(SerializationFormat.GZIP);
27548
27592
  }
27549
27593
  const ops = [];
27550
- const runId = `wrun_${ulid3()}`;
27594
+ const runId = `wrun_${world.createRunId ? world.createRunId(opts) : ulid3()}`;
27551
27595
  const traceCarrier = await serializeTraceCarrier();
27552
27596
  const specVersion = opts.specVersion ?? world.specVersion;
27553
27597
  const v1Compat = isLegacySpecVersion(specVersion);
@@ -27625,7 +27669,14 @@ async function start(workflow, argsOrOptions, options) {
27625
27669
  } : {}
27626
27670
  }, {
27627
27671
  deploymentId,
27628
- specVersion
27672
+ specVersion,
27673
+ // Forward any caller-supplied region hint so worlds with
27674
+ // per-region queue routing (e.g. world-vercel) can target the
27675
+ // matching queue. Worlds without a regional dimension ignore
27676
+ // this field.
27677
+ ...opts.region !== void 0 ? {
27678
+ region: opts.region
27679
+ } : {}
27629
27680
  })
27630
27681
  ]);
27631
27682
  if (queueResult.status === "rejected") {
@@ -27679,7 +27730,7 @@ __name(start, "start");
27679
27730
  value: "start",
27680
27731
  configurable: true
27681
27732
  });
27682
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.31//start");
27733
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.33//start");
27683
27734
 
27684
27735
  // ../core/dist/runtime/runs.js
27685
27736
  async function wakeUpRun(world, runId, options) {
@@ -28015,7 +28066,7 @@ var Run = class _Run {
28015
28066
  value: "wakeUp",
28016
28067
  configurable: true
28017
28068
  });
28018
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#wakeUp");
28069
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#wakeUp");
28019
28070
  (function(__wf_fn, __wf_id) {
28020
28071
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28021
28072
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28024,7 +28075,7 @@ var Run = class _Run {
28024
28075
  value: "cancel",
28025
28076
  configurable: true
28026
28077
  });
28027
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#cancel");
28078
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#cancel");
28028
28079
  (function(__wf_fn, __wf_id) {
28029
28080
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28030
28081
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28033,7 +28084,7 @@ var Run = class _Run {
28033
28084
  value: "getReadable",
28034
28085
  configurable: true
28035
28086
  });
28036
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#getReadable");
28087
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#getReadable");
28037
28088
  (function(__wf_fn, __wf_id) {
28038
28089
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28039
28090
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28042,7 +28093,7 @@ var Run = class _Run {
28042
28093
  value: "exists",
28043
28094
  configurable: true
28044
28095
  });
28045
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#exists");
28096
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#exists");
28046
28097
  (function(__wf_fn, __wf_id) {
28047
28098
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28048
28099
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28051,7 +28102,7 @@ var Run = class _Run {
28051
28102
  value: "status",
28052
28103
  configurable: true
28053
28104
  });
28054
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#status");
28105
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#status");
28055
28106
  (function(__wf_fn, __wf_id) {
28056
28107
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28057
28108
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28060,7 +28111,7 @@ var Run = class _Run {
28060
28111
  value: "returnValue",
28061
28112
  configurable: true
28062
28113
  });
28063
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#returnValue");
28114
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#returnValue");
28064
28115
  (function(__wf_fn, __wf_id) {
28065
28116
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28066
28117
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28069,7 +28120,7 @@ var Run = class _Run {
28069
28120
  value: "workflowName",
28070
28121
  configurable: true
28071
28122
  });
28072
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#workflowName");
28123
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#workflowName");
28073
28124
  (function(__wf_fn, __wf_id) {
28074
28125
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28075
28126
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28078,7 +28129,7 @@ var Run = class _Run {
28078
28129
  value: "createdAt",
28079
28130
  configurable: true
28080
28131
  });
28081
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#createdAt");
28132
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#createdAt");
28082
28133
  (function(__wf_fn, __wf_id) {
28083
28134
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28084
28135
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28087,7 +28138,7 @@ var Run = class _Run {
28087
28138
  value: "startedAt",
28088
28139
  configurable: true
28089
28140
  });
28090
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#startedAt");
28141
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#startedAt");
28091
28142
  (function(__wf_fn, __wf_id) {
28092
28143
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28093
28144
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28096,7 +28147,7 @@ var Run = class _Run {
28096
28147
  value: "completedAt",
28097
28148
  configurable: true
28098
28149
  });
28099
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#completedAt");
28150
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.33//Run#completedAt");
28100
28151
  (function(__wf_cls, __wf_id) {
28101
28152
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28102
28153
  __wf_reg.set(__wf_id, __wf_cls);
@@ -28106,7 +28157,7 @@ var Run = class _Run {
28106
28157
  enumerable: false,
28107
28158
  configurable: false
28108
28159
  });
28109
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.31//Run");
28160
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.33//Run");
28110
28161
 
28111
28162
  // ../workflow/dist/stdlib.js
28112
28163
  async function fetch2(...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/world-testing",
3
- "version": "5.0.0-beta.31",
3
+ "version": "5.0.0-beta.33",
4
4
  "description": "Testing utilities and World implementation for Workflow SDK",
5
5
  "main": "dist/src/index.mjs",
6
6
  "files": [
@@ -21,16 +21,17 @@
21
21
  "hono": "4.12.25",
22
22
  "jsonlines": "0.1.1",
23
23
  "zod": "~4.3.6",
24
- "@workflow/cli": "5.0.0-beta.31",
25
- "@workflow/core": "5.0.0-beta.31",
24
+ "@workflow/cli": "5.0.0-beta.33",
25
+ "@workflow/core": "5.0.0-beta.33",
26
26
  "@workflow/utils": "5.0.0-beta.6",
27
- "@workflow/world": "5.0.0-beta.19",
28
- "@workflow/world-local": "5.0.0-beta.27",
29
- "workflow": "5.0.0-beta.31"
27
+ "@workflow/world": "5.0.0-beta.20",
28
+ "@workflow/world-local": "5.0.0-beta.28",
29
+ "workflow": "5.0.0-beta.33"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jsonlines": "0.1.5",
33
33
  "@types/node": "22.19.0",
34
+ "typescript": "^6.0.3",
34
35
  "vitest": "^4.0.18",
35
36
  "@workflow/tsconfig": "5.0.0-beta.0"
36
37
  },