@workflow/world-testing 4.1.0-beta.68 → 4.1.0-beta.69

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.
@@ -30831,6 +30831,20 @@ function parseDurationToDate(param) {
30831
30831
  }
30832
30832
  __name(parseDurationToDate, "parseDurationToDate");
30833
30833
 
30834
+ // ../utils/dist/world-target.js
30835
+ function resolveWorkflowTargetWorld(env = process.env) {
30836
+ const configuredWorld = env.WORKFLOW_TARGET_WORLD;
30837
+ if (configuredWorld) {
30838
+ return configuredWorld;
30839
+ }
30840
+ return env.VERCEL_DEPLOYMENT_ID ? "vercel" : "local";
30841
+ }
30842
+ __name(resolveWorkflowTargetWorld, "resolveWorkflowTargetWorld");
30843
+ function isVercelWorldTarget(targetWorld) {
30844
+ return targetWorld === "vercel" || targetWorld === "@workflow/world-vercel";
30845
+ }
30846
+ __name(isVercelWorldTarget, "isVercelWorldTarget");
30847
+
30834
30848
  // ../errors/dist/index.js
30835
30849
  var BASE_URL = "https://useworkflow.dev/err";
30836
30850
  function isError(value) {
@@ -49078,19 +49092,21 @@ function createQueue(config3) {
49078
49092
  body
49079
49093
  });
49080
49094
  }
49081
- if (response.ok) {
49082
- return;
49083
- }
49084
49095
  const text = await response.text();
49085
- if (response.status === 503) {
49096
+ if (response.ok) {
49086
49097
  try {
49087
49098
  const timeoutSeconds = Number(JSON.parse(text).timeoutSeconds);
49088
- const timeoutMs = Math.min(timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
49089
- await (0, import_promises3.setTimeout)(timeoutMs);
49090
- defaultRetriesLeft++;
49091
- continue;
49099
+ if (Number.isFinite(timeoutSeconds) && timeoutSeconds >= 0) {
49100
+ if (timeoutSeconds > 0) {
49101
+ const timeoutMs = Math.min(timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
49102
+ await (0, import_promises3.setTimeout)(timeoutMs);
49103
+ }
49104
+ defaultRetriesLeft++;
49105
+ continue;
49106
+ }
49092
49107
  } catch {
49093
49108
  }
49109
+ return;
49094
49110
  }
49095
49111
  console.error(`[local world] Failed to queue message`, {
49096
49112
  queueName,
@@ -49143,7 +49159,7 @@ function createQueue(config3) {
49143
49159
  timeoutSeconds = Math.min(result.timeoutSeconds, LOCAL_QUEUE_MAX_VISIBILITY);
49144
49160
  }
49145
49161
  if (timeoutSeconds != null) {
49146
- return Response.json({ timeoutSeconds }, { status: 503 });
49162
+ return Response.json({ timeoutSeconds });
49147
49163
  }
49148
49164
  return Response.json({ ok: true });
49149
49165
  } catch (error48) {
@@ -50618,11 +50634,17 @@ async function fetchRunKey(deploymentId, projectId, runId, options) {
50618
50634
  headers: {
50619
50635
  authorization: `Bearer ${token}`
50620
50636
  },
50637
+ // @ts-expect-error -- undici dispatcher is accepted by Node.js fetch but not in @types/node's RequestInit
50621
50638
  dispatcher: getDispatcher()
50622
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici v7 dispatcher types don't match @types/node's RequestInit
50623
50639
  });
50624
50640
  if (!response.ok) {
50625
- throw new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${response.status}`);
50641
+ let body;
50642
+ try {
50643
+ body = await response.text();
50644
+ } catch {
50645
+ body = "<unable to read response body>";
50646
+ }
50647
+ throw new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
50626
50648
  }
50627
50649
  const data = await response.json();
50628
50650
  const result = object({ key: string2().nullable() }).safeParse(data);
@@ -50638,7 +50660,7 @@ __name(fetchRunKey, "fetchRunKey");
50638
50660
  function createGetEncryptionKeyForRun(projectId, teamId, token) {
50639
50661
  if (!projectId)
50640
50662
  return void 0;
50641
- const currentDeploymentId = process.env.VERCEL_DEPLOYMENT_ID;
50663
+ const isServerlessRuntime = process.env.VERCEL === "1";
50642
50664
  let localDeploymentKey;
50643
50665
  function getLocalDeploymentKey() {
50644
50666
  if (localDeploymentKey)
@@ -50653,12 +50675,16 @@ function createGetEncryptionKeyForRun(projectId, teamId, token) {
50653
50675
  return /* @__PURE__ */ __name(async function getEncryptionKeyForRun(run, context2) {
50654
50676
  const runId = typeof run === "string" ? run : run.runId;
50655
50677
  const deploymentId = typeof run === "string" ? context2?.deploymentId : run.deploymentId;
50656
- if (!deploymentId || deploymentId === currentDeploymentId) {
50657
- const localKey = getLocalDeploymentKey();
50658
- if (!localKey)
50659
- return void 0;
50660
- return deriveRunKey(localKey, projectId, runId);
50678
+ if (isServerlessRuntime) {
50679
+ if (!deploymentId || deploymentId === process.env.VERCEL_DEPLOYMENT_ID) {
50680
+ const localKey = getLocalDeploymentKey();
50681
+ if (!localKey)
50682
+ return void 0;
50683
+ return deriveRunKey(localKey, projectId, runId);
50684
+ }
50661
50685
  }
50686
+ if (!deploymentId)
50687
+ return void 0;
50662
50688
  return fetchRunKey(deploymentId, projectId, runId, { token, teamId });
50663
50689
  }, "getEncryptionKeyForRun");
50664
50690
  }
@@ -53086,7 +53112,7 @@ var RpcService3 = SemanticConvention3("rpc.service");
53086
53112
  var RpcMethod3 = SemanticConvention3("rpc.method");
53087
53113
 
53088
53114
  // ../world-vercel/dist/version.js
53089
- var version2 = "4.1.0-beta.41";
53115
+ var version2 = "4.1.0-beta.42";
53090
53116
 
53091
53117
  // ../world-vercel/dist/utils.js
53092
53118
  var WORKFLOW_SERVER_URL_OVERRIDE = "";
@@ -54268,27 +54294,19 @@ var require2 = (0, import_node_module.createRequire)((0, import_node_path9.join)
54268
54294
  var WorldCache = /* @__PURE__ */ Symbol.for("@workflow/world//cache");
54269
54295
  var StubbedWorldCache = /* @__PURE__ */ Symbol.for("@workflow/world//stubbedCache");
54270
54296
  var globalSymbols = globalThis;
54271
- function defaultWorld() {
54272
- if (process.env.VERCEL_DEPLOYMENT_ID) {
54273
- return "vercel";
54274
- }
54275
- return "local";
54276
- }
54277
- __name(defaultWorld, "defaultWorld");
54278
54297
  var createWorld = /* @__PURE__ */ __name(() => {
54279
- const targetWorld = process.env.WORKFLOW_TARGET_WORLD || defaultWorld();
54280
- if (targetWorld === "vercel") {
54281
- return createVercelWorld({
54282
- token: process.env.WORKFLOW_VERCEL_AUTH_TOKEN,
54283
- projectConfig: {
54284
- environment: process.env.WORKFLOW_VERCEL_ENV,
54285
- projectId: process.env.WORKFLOW_VERCEL_PROJECT,
54286
- // real ID (prj_xxx)
54287
- projectName: process.env.WORKFLOW_VERCEL_PROJECT_NAME,
54288
- // slug (my-app)
54289
- teamId: process.env.WORKFLOW_VERCEL_TEAM
54290
- }
54291
- });
54298
+ const targetWorld = resolveWorkflowTargetWorld();
54299
+ if (isVercelWorldTarget(targetWorld)) {
54300
+ const staleEnvVars = [
54301
+ "WORKFLOW_VERCEL_PROJECT",
54302
+ "WORKFLOW_VERCEL_TEAM",
54303
+ "WORKFLOW_VERCEL_AUTH_TOKEN",
54304
+ "WORKFLOW_VERCEL_ENV"
54305
+ ].filter((key) => process.env[key]);
54306
+ if (staleEnvVars.length > 0) {
54307
+ console.warn(`[workflow] Warning: ${staleEnvVars.join(", ")} env var(s) are set but have no effect at runtime. These are only used by the Workflow CLI. Remove them from your Vercel project environment variables.`);
54308
+ }
54309
+ return createVercelWorld();
54292
54310
  }
54293
54311
  if (targetWorld === "local") {
54294
54312
  return createLocalWorld({
@@ -58994,7 +59012,7 @@ function getWritable(options = {}) {
58994
59012
  __name(getWritable, "getWritable");
58995
59013
 
58996
59014
  // ../workflow/dist/stdlib.js
58997
- var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.67//fetch");
59015
+ var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.68//fetch");
58998
59016
 
58999
59017
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
59000
59018
  var NEVER = Object.freeze({
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
+ "workflow/dist/stdlib.js": {
5
+ "fetch": {
6
+ "stepId": "step//workflow@4.2.0-beta.68//fetch"
7
+ }
8
+ },
4
9
  "workflows/hooks.ts": {
5
10
  "writeEvent": {
6
11
  "stepId": "step//./workflows/hooks//writeEvent"
7
12
  }
8
13
  },
9
- "workflows/noop.ts": {
10
- "noop": {
11
- "stepId": "step//./workflows/noop//noop"
14
+ "workflows/addition.ts": {
15
+ "add": {
16
+ "stepId": "step//./workflows/addition//add"
12
17
  }
13
18
  },
14
19
  "workflows/null-byte.ts": {
@@ -35,14 +40,9 @@
35
40
  "stepId": "__builtin_response_text"
36
41
  }
37
42
  },
38
- "workflows/addition.ts": {
39
- "add": {
40
- "stepId": "step//./workflows/addition//add"
41
- }
42
- },
43
- "workflow/dist/stdlib.js": {
44
- "fetch": {
45
- "stepId": "step//workflow@4.2.0-beta.67//fetch"
43
+ "workflows/noop.ts": {
44
+ "noop": {
45
+ "stepId": "step//./workflows/noop//noop"
46
46
  }
47
47
  }
48
48
  },
@@ -80,16 +80,16 @@
80
80
  }
81
81
  }
82
82
  },
83
- "workflows/noop.ts": {
84
- "brokenWf": {
85
- "workflowId": "workflow//./workflows/noop//brokenWf",
83
+ "workflows/addition.ts": {
84
+ "addition": {
85
+ "workflowId": "workflow//./workflows/addition//addition",
86
86
  "graph": {
87
87
  "nodes": [
88
88
  {
89
89
  "id": "start",
90
90
  "type": "workflowStart",
91
91
  "data": {
92
- "label": "Start: brokenWf",
92
+ "label": "Start: addition",
93
93
  "nodeKind": "workflow_start"
94
94
  }
95
95
  },
@@ -179,16 +179,16 @@
179
179
  }
180
180
  }
181
181
  },
182
- "workflows/addition.ts": {
183
- "addition": {
184
- "workflowId": "workflow//./workflows/addition//addition",
182
+ "workflows/noop.ts": {
183
+ "brokenWf": {
184
+ "workflowId": "workflow//./workflows/noop//brokenWf",
185
185
  "graph": {
186
186
  "nodes": [
187
187
  {
188
188
  "id": "start",
189
189
  "type": "workflowStart",
190
190
  "data": {
191
- "label": "Start: addition",
191
+ "label": "Start: brokenWf",
192
192
  "nodeKind": "workflow_start"
193
193
  }
194
194
  },