@upstash/workflow 1.1.0 → 1.1.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.
Files changed (50) hide show
  1. package/astro.d.mts +2 -2
  2. package/astro.d.ts +2 -2
  3. package/astro.js +28 -2
  4. package/astro.mjs +1 -1
  5. package/{chunk-C5HFGF7Q.mjs → chunk-QRCGBBFJ.mjs} +28 -2
  6. package/cloudflare.d.mts +2 -2
  7. package/cloudflare.d.ts +2 -2
  8. package/cloudflare.js +28 -2
  9. package/cloudflare.mjs +1 -1
  10. package/express.d.mts +2 -2
  11. package/express.d.ts +2 -2
  12. package/express.js +28 -2
  13. package/express.mjs +1 -1
  14. package/h3.d.mts +2 -2
  15. package/h3.d.ts +2 -2
  16. package/h3.js +32 -6
  17. package/h3.mjs +5 -5
  18. package/hono.d.mts +2 -2
  19. package/hono.d.ts +2 -2
  20. package/hono.js +28 -2
  21. package/hono.mjs +1 -1
  22. package/index.d.mts +3 -3
  23. package/index.d.ts +3 -3
  24. package/index.js +31 -3
  25. package/index.mjs +4 -2
  26. package/nextjs.d.mts +2 -2
  27. package/nextjs.d.ts +2 -2
  28. package/nextjs.js +28 -2
  29. package/nextjs.mjs +1 -1
  30. package/package.json +1 -1
  31. package/react-router.d.mts +38 -0
  32. package/react-router.d.ts +38 -0
  33. package/react-router.js +3861 -0
  34. package/react-router.mjs +45 -0
  35. package/{serve-many-qnfynN1x.d.ts → serve-many-BP-8Ytbc.d.ts} +1 -1
  36. package/{serve-many-DhB8-zPD.d.mts → serve-many-BsycEL_d.d.mts} +1 -1
  37. package/solidjs.d.mts +1 -1
  38. package/solidjs.d.ts +1 -1
  39. package/solidjs.js +28 -2
  40. package/solidjs.mjs +1 -1
  41. package/svelte.d.mts +2 -2
  42. package/svelte.d.ts +2 -2
  43. package/svelte.js +28 -2
  44. package/svelte.mjs +1 -1
  45. package/tanstack.d.mts +2 -2
  46. package/tanstack.d.ts +2 -2
  47. package/tanstack.js +28 -2
  48. package/tanstack.mjs +1 -1
  49. package/{types-pEje3VEB.d.ts → types-B90SJYZV.d.mts} +9 -2
  50. package/{types-pEje3VEB.d.mts → types-B90SJYZV.d.ts} +9 -2
@@ -0,0 +1,45 @@
1
+ import {
2
+ SDK_TELEMETRY,
3
+ serveBase,
4
+ serveManyBase
5
+ } from "./chunk-QRCGBBFJ.mjs";
6
+
7
+ // platforms/react-router.ts
8
+ var telemetry = {
9
+ sdk: SDK_TELEMETRY,
10
+ framework: "react-router",
11
+ runtime: process.versions.bun ? `bun@${process.versions.bun}/node@${process.version}` : `node@${process.version}`
12
+ };
13
+ var serve = (routeFunction, options) => {
14
+ const { handler: serveHandler } = serveBase(
15
+ routeFunction,
16
+ telemetry,
17
+ options
18
+ );
19
+ return async ({ request }) => {
20
+ return await serveHandler(request);
21
+ };
22
+ };
23
+ var createWorkflow = (...params) => {
24
+ const [routeFunction, options = {}] = params;
25
+ return {
26
+ routeFunction,
27
+ options,
28
+ workflowId: void 0
29
+ };
30
+ };
31
+ var serveMany = (workflows, options) => {
32
+ return serveManyBase({
33
+ workflows,
34
+ getUrl(params) {
35
+ return params.request.url;
36
+ },
37
+ serveMethod: (...params) => serve(...params),
38
+ options
39
+ }).handler;
40
+ };
41
+ export {
42
+ createWorkflow,
43
+ serve,
44
+ serveMany
45
+ };
@@ -1,4 +1,4 @@
1
- import { d as WorkflowServeOptions, c as RouteFunction, x as InvokableWorkflow } from './types-pEje3VEB.js';
1
+ import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B90SJYZV.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, x as InvokableWorkflow } from './types-pEje3VEB.mjs';
1
+ import { d as WorkflowServeOptions, c as RouteFunction, I as InvokableWorkflow } from './types-B90SJYZV.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-pEje3VEB.mjs';
2
+ import { c as RouteFunction, d as WorkflowServeOptions } from './types-B90SJYZV.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-pEje3VEB.js';
2
+ import { c as RouteFunction, d as WorkflowServeOptions } from './types-B90SJYZV.js';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/solidjs.js CHANGED
@@ -184,6 +184,7 @@ var getSteps = async (requester, workflowRunId, messageId, dispatchDebug) => {
184
184
  var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
185
185
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
186
186
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
187
+ var WORKFLOW_CREATED_AT_HEADER = "Upstash-Workflow-CreatedAt";
187
188
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
188
189
  var WORKFLOW_FAILURE_CALLBACK_HEADER = "Upstash-Workflow-Failure-Callback";
189
190
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
@@ -1514,13 +1515,22 @@ var LazyInvokeStep = class extends BaseLazyStep {
1514
1515
  Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
1515
1516
  ),
1516
1517
  workflowRunId: context.workflowRunId,
1518
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
1517
1519
  workflowUrl: context.url,
1518
1520
  step
1519
1521
  };
1520
1522
  return JSON.stringify(request);
1521
1523
  }
1522
1524
  getHeaders({ context, telemetry, invokeCount }) {
1523
- const { workflow, headers = {}, workflowRunId, retries, retryDelay, flowControl } = this.params;
1525
+ const {
1526
+ workflow,
1527
+ headers = {},
1528
+ workflowRunId,
1529
+ retries,
1530
+ retryDelay,
1531
+ flowControl,
1532
+ label
1533
+ } = this.params;
1524
1534
  const newUrl = context.url.replace(/[^/]+$/, this.workflowId);
1525
1535
  const { headers: triggerHeaders, contentType } = getHeaders({
1526
1536
  initHeaderValue: "true",
@@ -1538,6 +1548,10 @@ var LazyInvokeStep = class extends BaseLazyStep {
1538
1548
  userHeaders: new Headers(headers)
1539
1549
  });
1540
1550
  triggerHeaders["Upstash-Workflow-Invoke"] = "true";
1551
+ if (label) {
1552
+ triggerHeaders[WORKFLOW_LABEL_HEADER] = label;
1553
+ triggerHeaders[`upstash-forward-${WORKFLOW_LABEL_HEADER}`] = label;
1554
+ }
1541
1555
  return { headers: triggerHeaders, contentType };
1542
1556
  }
1543
1557
  async submitStep({ context, body, headers }) {
@@ -2528,6 +2542,10 @@ var WorkflowContext = class {
2528
2542
  * Run id of the workflow
2529
2543
  */
2530
2544
  workflowRunId;
2545
+ /**
2546
+ * Creation time of the workflow run
2547
+ */
2548
+ workflowRunCreatedAt;
2531
2549
  /**
2532
2550
  * URL of the workflow
2533
2551
  *
@@ -2619,6 +2637,7 @@ var WorkflowContext = class {
2619
2637
  constructor({
2620
2638
  qstashClient,
2621
2639
  workflowRunId,
2640
+ workflowRunCreatedAt,
2622
2641
  headers,
2623
2642
  steps,
2624
2643
  url,
@@ -2631,6 +2650,7 @@ var WorkflowContext = class {
2631
2650
  }) {
2632
2651
  this.qstashClient = qstashClient;
2633
2652
  this.workflowRunId = workflowRunId;
2653
+ this.workflowRunCreatedAt = workflowRunCreatedAt;
2634
2654
  this.steps = steps;
2635
2655
  this.url = url;
2636
2656
  this.headers = headers;
@@ -2887,6 +2907,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
2887
2907
  token: "disabled-client"
2888
2908
  }),
2889
2909
  workflowRunId: context.workflowRunId,
2910
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
2890
2911
  headers: context.headers,
2891
2912
  steps: [],
2892
2913
  url: context.url,
@@ -3088,7 +3109,9 @@ var handleFailure = async ({
3088
3109
  return ok({ result: "failure-function-undefined" });
3089
3110
  }
3090
3111
  try {
3091
- const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
3112
+ const { status, header, body, url, sourceBody, workflowRunId, workflowCreatedAt } = JSON.parse(
3113
+ requestPayload
3114
+ );
3092
3115
  const decodedBody = body ? decodeBase64(body) : "{}";
3093
3116
  let errorMessage = "";
3094
3117
  let failStack = "";
@@ -3117,6 +3140,7 @@ var handleFailure = async ({
3117
3140
  telemetry: void 0,
3118
3141
  // not going to make requests in authentication check
3119
3142
  label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0,
3143
+ workflowRunCreatedAt: workflowCreatedAt,
3120
3144
  middlewareManager: void 0
3121
3145
  });
3122
3146
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
@@ -3594,6 +3618,7 @@ var serveBase = (routeFunction, telemetry, options, internalOptions) => {
3594
3618
  }
3595
3619
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3596
3620
  const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3621
+ const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
3597
3622
  const workflowContext = new WorkflowContext({
3598
3623
  qstashClient: regionalClient,
3599
3624
  workflowRunId,
@@ -3605,6 +3630,7 @@ var serveBase = (routeFunction, telemetry, options, internalOptions) => {
3605
3630
  telemetry,
3606
3631
  invokeCount,
3607
3632
  label,
3633
+ workflowRunCreatedAt: Number(workflowRunCreatedAt),
3608
3634
  middlewareManager
3609
3635
  });
3610
3636
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
package/solidjs.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase
4
- } from "./chunk-C5HFGF7Q.mjs";
4
+ } from "./chunk-QRCGBBFJ.mjs";
5
5
 
6
6
  // platforms/solidjs.ts
7
7
  var serve = (routeFunction, options) => {
package/svelte.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _sveltejs_kit from '@sveltejs/kit';
2
2
  import { RequestHandler } from '@sveltejs/kit';
3
- import { c as RouteFunction, d as WorkflowServeOptions, x as InvokableWorkflow } from './types-pEje3VEB.mjs';
4
- import { s as serveManyBase } from './serve-many-DhB8-zPD.mjs';
3
+ import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B90SJYZV.mjs';
4
+ import { s as serveManyBase } from './serve-many-BsycEL_d.mjs';
5
5
  import '@upstash/qstash';
6
6
  import 'zod';
7
7
 
package/svelte.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _sveltejs_kit from '@sveltejs/kit';
2
2
  import { RequestHandler } from '@sveltejs/kit';
3
- import { c as RouteFunction, d as WorkflowServeOptions, x as InvokableWorkflow } from './types-pEje3VEB.js';
4
- import { s as serveManyBase } from './serve-many-qnfynN1x.js';
3
+ import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B90SJYZV.js';
4
+ import { s as serveManyBase } from './serve-many-BP-8Ytbc.js';
5
5
  import '@upstash/qstash';
6
6
  import 'zod';
7
7
 
package/svelte.js CHANGED
@@ -186,6 +186,7 @@ var getSteps = async (requester, workflowRunId, messageId, dispatchDebug) => {
186
186
  var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
187
187
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
188
188
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
189
+ var WORKFLOW_CREATED_AT_HEADER = "Upstash-Workflow-CreatedAt";
189
190
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
190
191
  var WORKFLOW_FAILURE_CALLBACK_HEADER = "Upstash-Workflow-Failure-Callback";
191
192
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
@@ -1516,13 +1517,22 @@ var LazyInvokeStep = class extends BaseLazyStep {
1516
1517
  Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
1517
1518
  ),
1518
1519
  workflowRunId: context.workflowRunId,
1520
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
1519
1521
  workflowUrl: context.url,
1520
1522
  step
1521
1523
  };
1522
1524
  return JSON.stringify(request);
1523
1525
  }
1524
1526
  getHeaders({ context, telemetry: telemetry2, invokeCount }) {
1525
- const { workflow, headers = {}, workflowRunId, retries, retryDelay, flowControl } = this.params;
1527
+ const {
1528
+ workflow,
1529
+ headers = {},
1530
+ workflowRunId,
1531
+ retries,
1532
+ retryDelay,
1533
+ flowControl,
1534
+ label
1535
+ } = this.params;
1526
1536
  const newUrl = context.url.replace(/[^/]+$/, this.workflowId);
1527
1537
  const { headers: triggerHeaders, contentType } = getHeaders({
1528
1538
  initHeaderValue: "true",
@@ -1540,6 +1550,10 @@ var LazyInvokeStep = class extends BaseLazyStep {
1540
1550
  userHeaders: new Headers(headers)
1541
1551
  });
1542
1552
  triggerHeaders["Upstash-Workflow-Invoke"] = "true";
1553
+ if (label) {
1554
+ triggerHeaders[WORKFLOW_LABEL_HEADER] = label;
1555
+ triggerHeaders[`upstash-forward-${WORKFLOW_LABEL_HEADER}`] = label;
1556
+ }
1543
1557
  return { headers: triggerHeaders, contentType };
1544
1558
  }
1545
1559
  async submitStep({ context, body, headers }) {
@@ -2597,6 +2611,10 @@ var WorkflowContext = class {
2597
2611
  * Run id of the workflow
2598
2612
  */
2599
2613
  workflowRunId;
2614
+ /**
2615
+ * Creation time of the workflow run
2616
+ */
2617
+ workflowRunCreatedAt;
2600
2618
  /**
2601
2619
  * URL of the workflow
2602
2620
  *
@@ -2688,6 +2706,7 @@ var WorkflowContext = class {
2688
2706
  constructor({
2689
2707
  qstashClient,
2690
2708
  workflowRunId,
2709
+ workflowRunCreatedAt,
2691
2710
  headers,
2692
2711
  steps,
2693
2712
  url,
@@ -2700,6 +2719,7 @@ var WorkflowContext = class {
2700
2719
  }) {
2701
2720
  this.qstashClient = qstashClient;
2702
2721
  this.workflowRunId = workflowRunId;
2722
+ this.workflowRunCreatedAt = workflowRunCreatedAt;
2703
2723
  this.steps = steps;
2704
2724
  this.url = url;
2705
2725
  this.headers = headers;
@@ -2956,6 +2976,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
2956
2976
  token: "disabled-client"
2957
2977
  }),
2958
2978
  workflowRunId: context.workflowRunId,
2979
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
2959
2980
  headers: context.headers,
2960
2981
  steps: [],
2961
2982
  url: context.url,
@@ -3157,7 +3178,9 @@ var handleFailure = async ({
3157
3178
  return ok({ result: "failure-function-undefined" });
3158
3179
  }
3159
3180
  try {
3160
- const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
3181
+ const { status, header, body, url, sourceBody, workflowRunId, workflowCreatedAt } = JSON.parse(
3182
+ requestPayload
3183
+ );
3161
3184
  const decodedBody = body ? decodeBase64(body) : "{}";
3162
3185
  let errorMessage = "";
3163
3186
  let failStack = "";
@@ -3186,6 +3209,7 @@ var handleFailure = async ({
3186
3209
  telemetry: void 0,
3187
3210
  // not going to make requests in authentication check
3188
3211
  label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0,
3212
+ workflowRunCreatedAt: workflowCreatedAt,
3189
3213
  middlewareManager: void 0
3190
3214
  });
3191
3215
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
@@ -3663,6 +3687,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3663
3687
  }
3664
3688
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3665
3689
  const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3690
+ const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
3666
3691
  const workflowContext = new WorkflowContext({
3667
3692
  qstashClient: regionalClient,
3668
3693
  workflowRunId,
@@ -3674,6 +3699,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3674
3699
  telemetry: telemetry2,
3675
3700
  invokeCount,
3676
3701
  label,
3702
+ workflowRunCreatedAt: Number(workflowRunCreatedAt),
3677
3703
  middlewareManager
3678
3704
  });
3679
3705
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
package/svelte.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-C5HFGF7Q.mjs";
5
+ } from "./chunk-QRCGBBFJ.mjs";
6
6
 
7
7
  // platforms/svelte.ts
8
8
  var telemetry = {
package/tanstack.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as RouteFunction, d as WorkflowServeOptions, E as ExclusiveValidationOptions, x as InvokableWorkflow } from './types-pEje3VEB.mjs';
2
- import { s as serveManyBase } from './serve-many-DhB8-zPD.mjs';
1
+ import { c as RouteFunction, d as WorkflowServeOptions, E as ExclusiveValidationOptions, I as InvokableWorkflow } from './types-B90SJYZV.mjs';
2
+ import { s as serveManyBase } from './serve-many-BsycEL_d.mjs';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/tanstack.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as RouteFunction, d as WorkflowServeOptions, E as ExclusiveValidationOptions, x as InvokableWorkflow } from './types-pEje3VEB.js';
2
- import { s as serveManyBase } from './serve-many-qnfynN1x.js';
1
+ import { c as RouteFunction, d as WorkflowServeOptions, E as ExclusiveValidationOptions, I as InvokableWorkflow } from './types-B90SJYZV.js';
2
+ import { s as serveManyBase } from './serve-many-BP-8Ytbc.js';
3
3
  import '@upstash/qstash';
4
4
  import 'zod';
5
5
 
package/tanstack.js CHANGED
@@ -186,6 +186,7 @@ var getSteps = async (requester, workflowRunId, messageId, dispatchDebug) => {
186
186
  var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
187
187
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
188
188
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
189
+ var WORKFLOW_CREATED_AT_HEADER = "Upstash-Workflow-CreatedAt";
189
190
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
190
191
  var WORKFLOW_FAILURE_CALLBACK_HEADER = "Upstash-Workflow-Failure-Callback";
191
192
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
@@ -1516,13 +1517,22 @@ var LazyInvokeStep = class extends BaseLazyStep {
1516
1517
  Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
1517
1518
  ),
1518
1519
  workflowRunId: context.workflowRunId,
1520
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
1519
1521
  workflowUrl: context.url,
1520
1522
  step
1521
1523
  };
1522
1524
  return JSON.stringify(request);
1523
1525
  }
1524
1526
  getHeaders({ context, telemetry: telemetry2, invokeCount }) {
1525
- const { workflow, headers = {}, workflowRunId, retries, retryDelay, flowControl } = this.params;
1527
+ const {
1528
+ workflow,
1529
+ headers = {},
1530
+ workflowRunId,
1531
+ retries,
1532
+ retryDelay,
1533
+ flowControl,
1534
+ label
1535
+ } = this.params;
1526
1536
  const newUrl = context.url.replace(/[^/]+$/, this.workflowId);
1527
1537
  const { headers: triggerHeaders, contentType } = getHeaders({
1528
1538
  initHeaderValue: "true",
@@ -1540,6 +1550,10 @@ var LazyInvokeStep = class extends BaseLazyStep {
1540
1550
  userHeaders: new Headers(headers)
1541
1551
  });
1542
1552
  triggerHeaders["Upstash-Workflow-Invoke"] = "true";
1553
+ if (label) {
1554
+ triggerHeaders[WORKFLOW_LABEL_HEADER] = label;
1555
+ triggerHeaders[`upstash-forward-${WORKFLOW_LABEL_HEADER}`] = label;
1556
+ }
1543
1557
  return { headers: triggerHeaders, contentType };
1544
1558
  }
1545
1559
  async submitStep({ context, body, headers }) {
@@ -2597,6 +2611,10 @@ var WorkflowContext = class {
2597
2611
  * Run id of the workflow
2598
2612
  */
2599
2613
  workflowRunId;
2614
+ /**
2615
+ * Creation time of the workflow run
2616
+ */
2617
+ workflowRunCreatedAt;
2600
2618
  /**
2601
2619
  * URL of the workflow
2602
2620
  *
@@ -2688,6 +2706,7 @@ var WorkflowContext = class {
2688
2706
  constructor({
2689
2707
  qstashClient,
2690
2708
  workflowRunId,
2709
+ workflowRunCreatedAt,
2691
2710
  headers,
2692
2711
  steps,
2693
2712
  url,
@@ -2700,6 +2719,7 @@ var WorkflowContext = class {
2700
2719
  }) {
2701
2720
  this.qstashClient = qstashClient;
2702
2721
  this.workflowRunId = workflowRunId;
2722
+ this.workflowRunCreatedAt = workflowRunCreatedAt;
2703
2723
  this.steps = steps;
2704
2724
  this.url = url;
2705
2725
  this.headers = headers;
@@ -2956,6 +2976,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
2956
2976
  token: "disabled-client"
2957
2977
  }),
2958
2978
  workflowRunId: context.workflowRunId,
2979
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
2959
2980
  headers: context.headers,
2960
2981
  steps: [],
2961
2982
  url: context.url,
@@ -3157,7 +3178,9 @@ var handleFailure = async ({
3157
3178
  return ok({ result: "failure-function-undefined" });
3158
3179
  }
3159
3180
  try {
3160
- const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
3181
+ const { status, header, body, url, sourceBody, workflowRunId, workflowCreatedAt } = JSON.parse(
3182
+ requestPayload
3183
+ );
3161
3184
  const decodedBody = body ? decodeBase64(body) : "{}";
3162
3185
  let errorMessage = "";
3163
3186
  let failStack = "";
@@ -3186,6 +3209,7 @@ var handleFailure = async ({
3186
3209
  telemetry: void 0,
3187
3210
  // not going to make requests in authentication check
3188
3211
  label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0,
3212
+ workflowRunCreatedAt: workflowCreatedAt,
3189
3213
  middlewareManager: void 0
3190
3214
  });
3191
3215
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
@@ -3663,6 +3687,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3663
3687
  }
3664
3688
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3665
3689
  const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3690
+ const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
3666
3691
  const workflowContext = new WorkflowContext({
3667
3692
  qstashClient: regionalClient,
3668
3693
  workflowRunId,
@@ -3674,6 +3699,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3674
3699
  telemetry: telemetry2,
3675
3700
  invokeCount,
3676
3701
  label,
3702
+ workflowRunCreatedAt: Number(workflowRunCreatedAt),
3677
3703
  middlewareManager
3678
3704
  });
3679
3705
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
package/tanstack.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-C5HFGF7Q.mjs";
5
+ } from "./chunk-QRCGBBFJ.mjs";
6
6
 
7
7
  // platforms/tanstack.ts
8
8
  var telemetry = {
@@ -608,6 +608,10 @@ declare class WorkflowContext<TInitialPayload = unknown> {
608
608
  * Run id of the workflow
609
609
  */
610
610
  readonly workflowRunId: string;
611
+ /**
612
+ * Creation time of the workflow run
613
+ */
614
+ readonly workflowRunCreatedAt: number;
611
615
  /**
612
616
  * URL of the workflow
613
617
  *
@@ -696,9 +700,10 @@ declare class WorkflowContext<TInitialPayload = unknown> {
696
700
  * ```
697
701
  */
698
702
  readonly label?: string;
699
- constructor({ qstashClient, workflowRunId, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, middlewareManager, }: {
703
+ constructor({ qstashClient, workflowRunId, workflowRunCreatedAt, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, middlewareManager, }: {
700
704
  qstashClient: WorkflowClient;
701
705
  workflowRunId: string;
706
+ workflowRunCreatedAt: number;
702
707
  headers: Headers;
703
708
  steps: Step[];
704
709
  url: string;
@@ -1281,6 +1286,7 @@ type HeaderParams = {
1281
1286
  type InvokeWorkflowRequest = {
1282
1287
  workflowUrl: string;
1283
1288
  workflowRunId: string;
1289
+ workflowRunCreatedAt: number;
1284
1290
  headers: Record<string, string[]>;
1285
1291
  step: Step;
1286
1292
  body?: string;
@@ -1288,6 +1294,7 @@ type InvokeWorkflowRequest = {
1288
1294
  type LazyInvokeStepParams<TInitiaPayload, TResult> = {
1289
1295
  workflow: InvokableWorkflow<TInitiaPayload, TResult>;
1290
1296
  workflowRunId?: string;
1297
+ label?: string;
1291
1298
  } & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay"> & (TInitiaPayload extends undefined ? {
1292
1299
  body?: undefined;
1293
1300
  } : {
@@ -1310,4 +1317,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1310
1317
  useJSONContent?: boolean;
1311
1318
  };
1312
1319
 
1313
- export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, WorkflowError as f, WorkflowAbort as g, WorkflowNonRetryableError as h, WorkflowRetryAfterError as i, WorkflowContext as j, StepTypes as k, type Step as l, type SyncStepFunction as m, type StepFunction as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x };
1320
+ export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FailureFunctionPayload as F, type HeaderParams as H, type InvokableWorkflow as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, type CallSettings as f, type Duration as g, type FinishCondition as h, type InvokeStepResponse as i, type InvokeWorkflowRequest as j, type NotifyStepResponse as k, type RequiredExceptFields as l, type Step as m, type StepFunction as n, StepTypes as o, type SyncStepFunction as p, type WaitEventOptions as q, type WaitRequest as r, type WaitStepResponse as s, WorkflowAbort as t, WorkflowContext as u, WorkflowError as v, WorkflowNonRetryableError as w, WorkflowRetryAfterError as x };
@@ -608,6 +608,10 @@ declare class WorkflowContext<TInitialPayload = unknown> {
608
608
  * Run id of the workflow
609
609
  */
610
610
  readonly workflowRunId: string;
611
+ /**
612
+ * Creation time of the workflow run
613
+ */
614
+ readonly workflowRunCreatedAt: number;
611
615
  /**
612
616
  * URL of the workflow
613
617
  *
@@ -696,9 +700,10 @@ declare class WorkflowContext<TInitialPayload = unknown> {
696
700
  * ```
697
701
  */
698
702
  readonly label?: string;
699
- constructor({ qstashClient, workflowRunId, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, middlewareManager, }: {
703
+ constructor({ qstashClient, workflowRunId, workflowRunCreatedAt, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, middlewareManager, }: {
700
704
  qstashClient: WorkflowClient;
701
705
  workflowRunId: string;
706
+ workflowRunCreatedAt: number;
702
707
  headers: Headers;
703
708
  steps: Step[];
704
709
  url: string;
@@ -1281,6 +1286,7 @@ type HeaderParams = {
1281
1286
  type InvokeWorkflowRequest = {
1282
1287
  workflowUrl: string;
1283
1288
  workflowRunId: string;
1289
+ workflowRunCreatedAt: number;
1284
1290
  headers: Record<string, string[]>;
1285
1291
  step: Step;
1286
1292
  body?: string;
@@ -1288,6 +1294,7 @@ type InvokeWorkflowRequest = {
1288
1294
  type LazyInvokeStepParams<TInitiaPayload, TResult> = {
1289
1295
  workflow: InvokableWorkflow<TInitiaPayload, TResult>;
1290
1296
  workflowRunId?: string;
1297
+ label?: string;
1291
1298
  } & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay"> & (TInitiaPayload extends undefined ? {
1292
1299
  body?: undefined;
1293
1300
  } : {
@@ -1310,4 +1317,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1310
1317
  useJSONContent?: boolean;
1311
1318
  };
1312
1319
 
1313
- export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, WorkflowError as f, WorkflowAbort as g, WorkflowNonRetryableError as h, WorkflowRetryAfterError as i, WorkflowContext as j, StepTypes as k, type Step as l, type SyncStepFunction as m, type StepFunction as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x };
1320
+ export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FailureFunctionPayload as F, type HeaderParams as H, type InvokableWorkflow as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, type CallSettings as f, type Duration as g, type FinishCondition as h, type InvokeStepResponse as i, type InvokeWorkflowRequest as j, type NotifyStepResponse as k, type RequiredExceptFields as l, type Step as m, type StepFunction as n, StepTypes as o, type SyncStepFunction as p, type WaitEventOptions as q, type WaitRequest as r, type WaitStepResponse as s, WorkflowAbort as t, WorkflowContext as u, WorkflowError as v, WorkflowNonRetryableError as w, WorkflowRetryAfterError as x };