@upstash/workflow 1.1.1 → 1.2.0

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.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/astro.d.mts +2 -2
  3. package/astro.d.ts +2 -2
  4. package/astro.js +41 -21
  5. package/astro.mjs +1 -1
  6. package/{chunk-QRCGBBFJ.mjs → chunk-V5ZUHMAF.mjs} +35 -15
  7. package/cloudflare.d.mts +2 -2
  8. package/cloudflare.d.ts +2 -2
  9. package/cloudflare.js +41 -21
  10. package/cloudflare.mjs +1 -1
  11. package/express.d.mts +2 -2
  12. package/express.d.ts +2 -2
  13. package/express.js +41 -21
  14. package/express.mjs +1 -1
  15. package/h3.d.mts +2 -2
  16. package/h3.d.ts +2 -2
  17. package/h3.js +41 -21
  18. package/h3.mjs +1 -1
  19. package/hono.d.mts +2 -2
  20. package/hono.d.ts +2 -2
  21. package/hono.js +41 -21
  22. package/hono.mjs +1 -1
  23. package/index.d.mts +28 -3
  24. package/index.d.ts +28 -3
  25. package/index.js +59 -26
  26. package/index.mjs +17 -4
  27. package/nextjs.d.mts +2 -2
  28. package/nextjs.d.ts +2 -2
  29. package/nextjs.js +41 -21
  30. package/nextjs.mjs +1 -1
  31. package/package.json +1 -1
  32. package/react-router.d.mts +2 -2
  33. package/react-router.d.ts +2 -2
  34. package/react-router.js +41 -21
  35. package/react-router.mjs +1 -1
  36. package/{serve-many-BP-8Ytbc.d.ts → serve-many-B-fe7bh7.d.ts} +1 -1
  37. package/{serve-many-BsycEL_d.d.mts → serve-many-C6sa_DxN.d.mts} +1 -1
  38. package/solidjs.d.mts +1 -1
  39. package/solidjs.d.ts +1 -1
  40. package/solidjs.js +41 -21
  41. package/solidjs.mjs +1 -1
  42. package/svelte.d.mts +2 -2
  43. package/svelte.d.ts +2 -2
  44. package/svelte.js +41 -21
  45. package/svelte.mjs +1 -1
  46. package/tanstack.d.mts +2 -2
  47. package/tanstack.d.ts +2 -2
  48. package/tanstack.js +41 -21
  49. package/tanstack.mjs +1 -1
  50. package/{types-B90SJYZV.d.ts → types-B2S08hRU.d.mts} +10 -1
  51. package/{types-B90SJYZV.d.mts → types-B2S08hRU.d.ts} +10 -1
package/nextjs.js CHANGED
@@ -129,9 +129,10 @@ function isInstanceOf(v, ctor) {
129
129
  }
130
130
 
131
131
  // src/client/utils.ts
132
- var makeNotifyRequest = async (requester, eventId, eventData) => {
132
+ var makeNotifyRequest = async (requester, eventId, eventData, workflowRunId) => {
133
+ const path = workflowRunId ? ["v2", "notify", workflowRunId, eventId] : ["v2", "notify", eventId];
133
134
  const result = await requester.request({
134
- path: ["v2", "notify", eventId],
135
+ path,
135
136
  method: "POST",
136
137
  body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
137
138
  });
@@ -725,6 +726,7 @@ var triggerFirstInvocation = async (params) => {
725
726
  retries,
726
727
  retryDelay,
727
728
  flowControl,
729
+ redact,
728
730
  unknownSdk
729
731
  }) => {
730
732
  const { headers } = getHeaders({
@@ -761,7 +763,8 @@ var triggerFirstInvocation = async (params) => {
761
763
  body,
762
764
  url: workflowContext.url,
763
765
  delay,
764
- notBefore
766
+ notBefore,
767
+ redact
765
768
  };
766
769
  }
767
770
  );
@@ -920,7 +923,6 @@ ${atob(callbackMessage.body ?? "")}`
920
923
  })}`
921
924
  );
922
925
  }
923
- const userHeaders = recreateUserHeaders(request.headers);
924
926
  const { headers: requestHeaders } = getHeaders({
925
927
  initHeaderValue: "false",
926
928
  workflowConfig: {
@@ -928,7 +930,6 @@ ${atob(callbackMessage.body ?? "")}`
928
930
  workflowUrl,
929
931
  telemetry
930
932
  },
931
- userHeaders,
932
933
  invokeCount: Number(invokeCount)
933
934
  });
934
935
  const callResponse = {
@@ -1077,7 +1078,6 @@ var BaseLazyStep = class _BaseLazyStep {
1077
1078
  useJSONContent: false,
1078
1079
  telemetry
1079
1080
  },
1080
- userHeaders: context.headers,
1081
1081
  invokeCount,
1082
1082
  stepInfo: {
1083
1083
  step,
@@ -1435,9 +1435,9 @@ var LazyWaitEventStep = class extends BaseLazyStep {
1435
1435
  };
1436
1436
  var LazyNotifyStep = class extends LazyFunctionStep {
1437
1437
  stepType = "Notify";
1438
- constructor(context, stepName, eventId, eventData, requester) {
1438
+ constructor(context, stepName, eventId, eventData, requester, workflowRunId) {
1439
1439
  super(context, stepName, async () => {
1440
- const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
1440
+ const notifyResponse = await makeNotifyRequest(requester, eventId, eventData, workflowRunId);
1441
1441
  return {
1442
1442
  eventId,
1443
1443
  eventData,
@@ -1507,7 +1507,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
1507
1507
  telemetry,
1508
1508
  useJSONContent: false
1509
1509
  },
1510
- userHeaders: context.headers,
1511
1510
  invokeCount
1512
1511
  });
1513
1512
  context.qstashClient.http.headers?.forEach((value, key) => {
@@ -1616,12 +1615,14 @@ var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
1616
1615
  const parsedEventData = BaseLazyStep.tryParsing(eventData);
1617
1616
  const body = parsedEventData.body;
1618
1617
  const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
1618
+ const methodUpper = parsedEventData.method.toUpperCase();
1619
+ const canHaveBody = methodUpper !== "GET" && methodUpper !== "HEAD";
1619
1620
  const request = new Request(
1620
1621
  `${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
1621
1622
  {
1622
1623
  method: parsedEventData.method,
1623
1624
  headers: parsedEventData.header,
1624
- body: parsedBody
1625
+ body: canHaveBody ? parsedBody : void 0
1625
1626
  }
1626
1627
  );
1627
1628
  return {
@@ -1755,6 +1756,9 @@ var WorkflowHeaders = class {
1755
1756
  }
1756
1757
  }
1757
1758
  addUserHeaders() {
1759
+ if (!this.userHeaders) {
1760
+ return;
1761
+ }
1758
1762
  for (const [key, value] of this.userHeaders.entries()) {
1759
1763
  const forwardKey = `Forward-${key}`;
1760
1764
  this.headers.workflowHeaders[forwardKey] = value;
@@ -1861,7 +1865,6 @@ var submitParallelSteps = async ({
1861
1865
  workflowUrl: context.url,
1862
1866
  telemetry
1863
1867
  },
1864
- userHeaders: context.headers,
1865
1868
  invokeCount
1866
1869
  });
1867
1870
  return {
@@ -2114,7 +2117,7 @@ var AutoExecutor = class _AutoExecutor {
2114
2117
  });
2115
2118
  throw new WorkflowAbort(parallelStep.stepName, resultStep);
2116
2119
  } catch (error) {
2117
- if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400) {
2120
+ if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400 || isInstanceOf(error, import_qstash5.QstashError) && error.status === 412) {
2118
2121
  throw error;
2119
2122
  }
2120
2123
  throw new WorkflowError(
@@ -2588,6 +2591,7 @@ var MiddlewareManager = class {
2588
2591
  };
2589
2592
 
2590
2593
  // src/context/context.ts
2594
+ var import_qstash9 = require("@upstash/qstash");
2591
2595
  var WorkflowContext = class {
2592
2596
  executor;
2593
2597
  steps;
@@ -2897,14 +2901,23 @@ var WorkflowContext = class {
2897
2901
  * a notifyResponse field which contains a list of `Waiter` objects, each corresponding
2898
2902
  * to a notified workflow run.
2899
2903
  *
2904
+ * Optionally, you can pass a workflowRunId to enable lookback functionality:
2905
+ *
2906
+ * ```ts
2907
+ * const { eventId, eventData, notifyResponse } = await context.notify(
2908
+ * "notify step", "event-id", "event-data", "wfr_123"
2909
+ * );
2910
+ * ```
2911
+ *
2900
2912
  * @param stepName
2901
2913
  * @param eventId event id to notify
2902
2914
  * @param eventData event data to notify with
2915
+ * @param workflowRunId optional workflow run id for lookback support
2903
2916
  * @returns notify response which has event id, event data and list of waiters which were notified
2904
2917
  */
2905
- async notify(stepName, eventId, eventData) {
2918
+ async notify(stepName, eventId, eventData, workflowRunId) {
2906
2919
  return await this.addStep(
2907
- new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
2920
+ new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http, workflowRunId)
2908
2921
  );
2909
2922
  }
2910
2923
  async invoke(stepName, settings) {
@@ -2932,7 +2945,14 @@ var WorkflowContext = class {
2932
2945
  * DisabledWorkflowContext.
2933
2946
  */
2934
2947
  async addStep(step) {
2935
- return await this.executor.addStep(step);
2948
+ try {
2949
+ return await this.executor.addStep(step);
2950
+ } catch (error) {
2951
+ if (isInstanceOf(error, import_qstash9.QstashError) && error.status === 412) {
2952
+ throw new WorkflowNonRetryableError(error.message);
2953
+ }
2954
+ throw error;
2955
+ }
2936
2956
  }
2937
2957
  get api() {
2938
2958
  return new WorkflowApi({
@@ -2942,7 +2962,7 @@ var WorkflowContext = class {
2942
2962
  };
2943
2963
 
2944
2964
  // src/serve/authorization.ts
2945
- var import_qstash9 = require("@upstash/qstash");
2965
+ var import_qstash10 = require("@upstash/qstash");
2946
2966
  var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
2947
2967
  static disabledMessage = "disabled-qstash-worklfow-run";
2948
2968
  disabled = true;
@@ -2974,7 +2994,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
2974
2994
  */
2975
2995
  static async tryAuthentication(routeFunction, context) {
2976
2996
  const disabledContext = new _DisabledWorkflowContext({
2977
- qstashClient: new import_qstash9.Client({
2997
+ qstashClient: new import_qstash10.Client({
2978
2998
  baseUrl: "disabled-client",
2979
2999
  token: "disabled-client"
2980
3000
  }),
@@ -3241,7 +3261,7 @@ var handleFailure = async ({
3241
3261
  };
3242
3262
 
3243
3263
  // src/serve/multi-region/handlers.ts
3244
- var import_qstash10 = require("@upstash/qstash");
3264
+ var import_qstash11 = require("@upstash/qstash");
3245
3265
 
3246
3266
  // src/serve/multi-region/utils.ts
3247
3267
  var VALID_REGIONS = ["EU_CENTRAL_1", "US_EAST_1"];
@@ -3306,7 +3326,7 @@ var getHandlersForRequest = (qstashHandlers, regionHeader, isFirstInvocation) =>
3306
3326
  };
3307
3327
  var createRegionalHandler = (environment, receiverConfig, region, clientOptions) => {
3308
3328
  const clientEnv = readClientEnvironmentVariables(environment, region);
3309
- const client = new import_qstash10.Client({
3329
+ const client = new import_qstash11.Client({
3310
3330
  ...clientOptions,
3311
3331
  baseUrl: clientEnv.QSTASH_URL,
3312
3332
  token: clientEnv.QSTASH_TOKEN
@@ -3356,7 +3376,7 @@ var getQStashHandlers = ({
3356
3376
  return {
3357
3377
  mode: "single-region",
3358
3378
  handlers: {
3359
- client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash10.Client({
3379
+ client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash11.Client({
3360
3380
  ...qstashClientOption,
3361
3381
  baseUrl: environment.QSTASH_URL,
3362
3382
  token: environment.QSTASH_TOKEN
@@ -3372,7 +3392,7 @@ var getReceiver = (environment, receiverConfig, region) => {
3372
3392
  return void 0;
3373
3393
  }
3374
3394
  const receiverEnv = readReceiverEnvironmentVariables(environment, region);
3375
- return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new import_qstash10.Receiver({
3395
+ return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new import_qstash11.Receiver({
3376
3396
  currentSigningKey: receiverEnv.QSTASH_CURRENT_SIGNING_KEY,
3377
3397
  nextSigningKey: receiverEnv.QSTASH_NEXT_SIGNING_KEY
3378
3398
  }) : void 0;
package/nextjs.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-QRCGBBFJ.mjs";
5
+ } from "./chunk-V5ZUHMAF.mjs";
6
6
 
7
7
  // platforms/nextjs.ts
8
8
  var appTelemetry = {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/workflow","version":"v1.1.1","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./astro":{"import":"./astro.mjs","require":"./astro.js"},"./express":{"import":"./express.mjs","require":"./express.js"},"./tanstack":{"import":"./tanstack.mjs","require":"./tanstack.js"},"./react-router":{"import":"./react-router.mjs","require":"./react-router.js"}},"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"repository":{"type":"git","url":"git@github.com:upstash/workflow-js.git"},"keywords":["upstash","qstash","workflow","serverless"],"author":"Cahid Arda Oz","license":"MIT","bugs":{"url":"https://github.com/upstash/workflow-ts/issues"},"homepage":"https://github.com/upstash/workflow-ts#readme","devDependencies":{"@commitlint/cli":"^19.5.0","@commitlint/config-conventional":"^19.5.0","@eslint/js":"^9.11.1","@solidjs/start":"^1.0.8","@sveltejs/kit":"^2.6.1","@types/bun":"^1.1.10","@types/express":"^5.0.6","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^5.1.0","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.20","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsup":"^8.3.0","typescript":"^5.7.2","typescript-eslint":"^8.18.0"},"dependencies":{"@upstash/qstash":"2.9.0-rc"},"directories":{"example":"examples"},"peerDependencies":{"zod":"^3.25.0 || ^4.0.0"}}
1
+ {"name":"@upstash/workflow","version":"1.2.0","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./astro":{"import":"./astro.mjs","require":"./astro.js"},"./express":{"import":"./express.mjs","require":"./express.js"},"./tanstack":{"import":"./tanstack.mjs","require":"./tanstack.js"},"./react-router":{"import":"./react-router.mjs","require":"./react-router.js"}},"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"repository":{"type":"git","url":"git@github.com:upstash/workflow-js.git"},"keywords":["upstash","qstash","workflow","serverless"],"author":"Cahid Arda Oz","license":"MIT","bugs":{"url":"https://github.com/upstash/workflow-ts/issues"},"homepage":"https://github.com/upstash/workflow-ts#readme","devDependencies":{"@commitlint/cli":"^19.5.0","@commitlint/config-conventional":"^19.5.0","@eslint/js":"^9.11.1","@solidjs/start":"^1.0.8","@sveltejs/kit":"^2.6.1","@types/bun":"^1.1.10","@types/express":"^5.0.6","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^5.1.0","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.20","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsup":"^8.3.0","typescript":"^5.7.2","typescript-eslint":"^8.18.0"},"dependencies":{"@upstash/qstash":"^2.10.1"},"directories":{"example":"examples"},"peerDependencies":{"zod":"^3.25.0 || ^4.0.0"}}
@@ -1,5 +1,5 @@
1
- import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B90SJYZV.mjs';
2
- import { s as serveManyBase } from './serve-many-BsycEL_d.mjs';
1
+ import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.mjs';
2
+ import { s as serveManyBase } from './serve-many-C6sa_DxN.mjs';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/react-router.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B90SJYZV.js';
2
- import { s as serveManyBase } from './serve-many-BP-8Ytbc.js';
1
+ import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.js';
2
+ import { s as serveManyBase } from './serve-many-B-fe7bh7.js';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/react-router.js CHANGED
@@ -149,9 +149,10 @@ function isInstanceOf(v, ctor) {
149
149
  }
150
150
 
151
151
  // src/client/utils.ts
152
- var makeNotifyRequest = async (requester, eventId, eventData) => {
152
+ var makeNotifyRequest = async (requester, eventId, eventData, workflowRunId) => {
153
+ const path = workflowRunId ? ["v2", "notify", workflowRunId, eventId] : ["v2", "notify", eventId];
153
154
  const result = await requester.request({
154
- path: ["v2", "notify", eventId],
155
+ path,
155
156
  method: "POST",
156
157
  body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
157
158
  });
@@ -722,6 +723,7 @@ var triggerFirstInvocation = async (params) => {
722
723
  retries,
723
724
  retryDelay,
724
725
  flowControl,
726
+ redact,
725
727
  unknownSdk
726
728
  }) => {
727
729
  const { headers } = getHeaders({
@@ -758,7 +760,8 @@ var triggerFirstInvocation = async (params) => {
758
760
  body,
759
761
  url: workflowContext.url,
760
762
  delay,
761
- notBefore
763
+ notBefore,
764
+ redact
762
765
  };
763
766
  }
764
767
  );
@@ -917,7 +920,6 @@ ${atob(callbackMessage.body ?? "")}`
917
920
  })}`
918
921
  );
919
922
  }
920
- const userHeaders = recreateUserHeaders(request.headers);
921
923
  const { headers: requestHeaders } = getHeaders({
922
924
  initHeaderValue: "false",
923
925
  workflowConfig: {
@@ -925,7 +927,6 @@ ${atob(callbackMessage.body ?? "")}`
925
927
  workflowUrl,
926
928
  telemetry: telemetry2
927
929
  },
928
- userHeaders,
929
930
  invokeCount: Number(invokeCount)
930
931
  });
931
932
  const callResponse = {
@@ -1074,7 +1075,6 @@ var BaseLazyStep = class _BaseLazyStep {
1074
1075
  useJSONContent: false,
1075
1076
  telemetry: telemetry2
1076
1077
  },
1077
- userHeaders: context.headers,
1078
1078
  invokeCount,
1079
1079
  stepInfo: {
1080
1080
  step,
@@ -1432,9 +1432,9 @@ var LazyWaitEventStep = class extends BaseLazyStep {
1432
1432
  };
1433
1433
  var LazyNotifyStep = class extends LazyFunctionStep {
1434
1434
  stepType = "Notify";
1435
- constructor(context, stepName, eventId, eventData, requester) {
1435
+ constructor(context, stepName, eventId, eventData, requester, workflowRunId) {
1436
1436
  super(context, stepName, async () => {
1437
- const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
1437
+ const notifyResponse = await makeNotifyRequest(requester, eventId, eventData, workflowRunId);
1438
1438
  return {
1439
1439
  eventId,
1440
1440
  eventData,
@@ -1504,7 +1504,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
1504
1504
  telemetry: telemetry2,
1505
1505
  useJSONContent: false
1506
1506
  },
1507
- userHeaders: context.headers,
1508
1507
  invokeCount
1509
1508
  });
1510
1509
  context.qstashClient.http.headers?.forEach((value, key) => {
@@ -1613,12 +1612,14 @@ var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
1613
1612
  const parsedEventData = BaseLazyStep.tryParsing(eventData);
1614
1613
  const body = parsedEventData.body;
1615
1614
  const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
1615
+ const methodUpper = parsedEventData.method.toUpperCase();
1616
+ const canHaveBody = methodUpper !== "GET" && methodUpper !== "HEAD";
1616
1617
  const request = new Request(
1617
1618
  `${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
1618
1619
  {
1619
1620
  method: parsedEventData.method,
1620
1621
  headers: parsedEventData.header,
1621
- body: parsedBody
1622
+ body: canHaveBody ? parsedBody : void 0
1622
1623
  }
1623
1624
  );
1624
1625
  return {
@@ -1752,6 +1753,9 @@ var WorkflowHeaders = class {
1752
1753
  }
1753
1754
  }
1754
1755
  addUserHeaders() {
1756
+ if (!this.userHeaders) {
1757
+ return;
1758
+ }
1755
1759
  for (const [key, value] of this.userHeaders.entries()) {
1756
1760
  const forwardKey = `Forward-${key}`;
1757
1761
  this.headers.workflowHeaders[forwardKey] = value;
@@ -1858,7 +1862,6 @@ var submitParallelSteps = async ({
1858
1862
  workflowUrl: context.url,
1859
1863
  telemetry: telemetry2
1860
1864
  },
1861
- userHeaders: context.headers,
1862
1865
  invokeCount
1863
1866
  });
1864
1867
  return {
@@ -2111,7 +2114,7 @@ var AutoExecutor = class _AutoExecutor {
2111
2114
  });
2112
2115
  throw new WorkflowAbort(parallelStep.stepName, resultStep);
2113
2116
  } catch (error) {
2114
- if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400) {
2117
+ if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400 || isInstanceOf(error, import_qstash5.QstashError) && error.status === 412) {
2115
2118
  throw error;
2116
2119
  }
2117
2120
  throw new WorkflowError(
@@ -2585,6 +2588,7 @@ var MiddlewareManager = class {
2585
2588
  };
2586
2589
 
2587
2590
  // src/context/context.ts
2591
+ var import_qstash9 = require("@upstash/qstash");
2588
2592
  var WorkflowContext = class {
2589
2593
  executor;
2590
2594
  steps;
@@ -2894,14 +2898,23 @@ var WorkflowContext = class {
2894
2898
  * a notifyResponse field which contains a list of `Waiter` objects, each corresponding
2895
2899
  * to a notified workflow run.
2896
2900
  *
2901
+ * Optionally, you can pass a workflowRunId to enable lookback functionality:
2902
+ *
2903
+ * ```ts
2904
+ * const { eventId, eventData, notifyResponse } = await context.notify(
2905
+ * "notify step", "event-id", "event-data", "wfr_123"
2906
+ * );
2907
+ * ```
2908
+ *
2897
2909
  * @param stepName
2898
2910
  * @param eventId event id to notify
2899
2911
  * @param eventData event data to notify with
2912
+ * @param workflowRunId optional workflow run id for lookback support
2900
2913
  * @returns notify response which has event id, event data and list of waiters which were notified
2901
2914
  */
2902
- async notify(stepName, eventId, eventData) {
2915
+ async notify(stepName, eventId, eventData, workflowRunId) {
2903
2916
  return await this.addStep(
2904
- new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
2917
+ new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http, workflowRunId)
2905
2918
  );
2906
2919
  }
2907
2920
  async invoke(stepName, settings) {
@@ -2929,7 +2942,14 @@ var WorkflowContext = class {
2929
2942
  * DisabledWorkflowContext.
2930
2943
  */
2931
2944
  async addStep(step) {
2932
- return await this.executor.addStep(step);
2945
+ try {
2946
+ return await this.executor.addStep(step);
2947
+ } catch (error) {
2948
+ if (isInstanceOf(error, import_qstash9.QstashError) && error.status === 412) {
2949
+ throw new WorkflowNonRetryableError(error.message);
2950
+ }
2951
+ throw error;
2952
+ }
2933
2953
  }
2934
2954
  get api() {
2935
2955
  return new WorkflowApi({
@@ -2939,7 +2959,7 @@ var WorkflowContext = class {
2939
2959
  };
2940
2960
 
2941
2961
  // src/serve/authorization.ts
2942
- var import_qstash9 = require("@upstash/qstash");
2962
+ var import_qstash10 = require("@upstash/qstash");
2943
2963
  var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
2944
2964
  static disabledMessage = "disabled-qstash-worklfow-run";
2945
2965
  disabled = true;
@@ -2971,7 +2991,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
2971
2991
  */
2972
2992
  static async tryAuthentication(routeFunction, context) {
2973
2993
  const disabledContext = new _DisabledWorkflowContext({
2974
- qstashClient: new import_qstash9.Client({
2994
+ qstashClient: new import_qstash10.Client({
2975
2995
  baseUrl: "disabled-client",
2976
2996
  token: "disabled-client"
2977
2997
  }),
@@ -3238,7 +3258,7 @@ var handleFailure = async ({
3238
3258
  };
3239
3259
 
3240
3260
  // src/serve/multi-region/handlers.ts
3241
- var import_qstash10 = require("@upstash/qstash");
3261
+ var import_qstash11 = require("@upstash/qstash");
3242
3262
 
3243
3263
  // src/serve/multi-region/utils.ts
3244
3264
  var VALID_REGIONS = ["EU_CENTRAL_1", "US_EAST_1"];
@@ -3303,7 +3323,7 @@ var getHandlersForRequest = (qstashHandlers, regionHeader, isFirstInvocation) =>
3303
3323
  };
3304
3324
  var createRegionalHandler = (environment, receiverConfig, region, clientOptions) => {
3305
3325
  const clientEnv = readClientEnvironmentVariables(environment, region);
3306
- const client = new import_qstash10.Client({
3326
+ const client = new import_qstash11.Client({
3307
3327
  ...clientOptions,
3308
3328
  baseUrl: clientEnv.QSTASH_URL,
3309
3329
  token: clientEnv.QSTASH_TOKEN
@@ -3353,7 +3373,7 @@ var getQStashHandlers = ({
3353
3373
  return {
3354
3374
  mode: "single-region",
3355
3375
  handlers: {
3356
- client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash10.Client({
3376
+ client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash11.Client({
3357
3377
  ...qstashClientOption,
3358
3378
  baseUrl: environment.QSTASH_URL,
3359
3379
  token: environment.QSTASH_TOKEN
@@ -3369,7 +3389,7 @@ var getReceiver = (environment, receiverConfig, region) => {
3369
3389
  return void 0;
3370
3390
  }
3371
3391
  const receiverEnv = readReceiverEnvironmentVariables(environment, region);
3372
- return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new import_qstash10.Receiver({
3392
+ return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new import_qstash11.Receiver({
3373
3393
  currentSigningKey: receiverEnv.QSTASH_CURRENT_SIGNING_KEY,
3374
3394
  nextSigningKey: receiverEnv.QSTASH_NEXT_SIGNING_KEY
3375
3395
  }) : void 0;
package/react-router.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-QRCGBBFJ.mjs";
5
+ } from "./chunk-V5ZUHMAF.mjs";
6
6
 
7
7
  // platforms/react-router.ts
8
8
  var telemetry = {
@@ -1,4 +1,4 @@
1
- import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B90SJYZV.js';
1
+ import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B2S08hRU.js';
2
2
 
3
3
  type OmitOptionsInServeMany<TOptions> = Omit<TOptions, "env" | "url" | "schema" | "initialPayloadParser">;
4
4
  declare const serveManyBase: <THandler extends (...params: any[]) => any, TOptions extends OmitOptionsInServeMany<WorkflowServeOptions> = OmitOptionsInServeMany<WorkflowServeOptions>, TServeParams extends [routeFunction: RouteFunction<any, any>, options: TOptions] = [routeFunction: RouteFunction<any, any>, options: TOptions]>({ workflows, getUrl, serveMethod, options, }: {
@@ -1,4 +1,4 @@
1
- import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B90SJYZV.mjs';
1
+ import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B2S08hRU.mjs';
2
2
 
3
3
  type OmitOptionsInServeMany<TOptions> = Omit<TOptions, "env" | "url" | "schema" | "initialPayloadParser">;
4
4
  declare const serveManyBase: <THandler extends (...params: any[]) => any, TOptions extends OmitOptionsInServeMany<WorkflowServeOptions> = OmitOptionsInServeMany<WorkflowServeOptions>, TServeParams extends [routeFunction: RouteFunction<any, any>, options: TOptions] = [routeFunction: RouteFunction<any, any>, options: TOptions]>({ workflows, getUrl, serveMethod, options, }: {
package/solidjs.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIEvent } from '@solidjs/start/server';
2
- import { c as RouteFunction, d as WorkflowServeOptions } from './types-B90SJYZV.mjs';
2
+ import { c as RouteFunction, d as WorkflowServeOptions } from './types-B2S08hRU.mjs';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/solidjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIEvent } from '@solidjs/start/server';
2
- import { c as RouteFunction, d as WorkflowServeOptions } from './types-B90SJYZV.js';
2
+ import { c as RouteFunction, d as WorkflowServeOptions } from './types-B2S08hRU.js';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5