@upstash/workflow 0.2.17 → 0.2.19

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.
package/express.js CHANGED
@@ -23479,12 +23479,13 @@ var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
23479
23479
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
23480
23480
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
23481
23481
  var WORKFLOW_INVOKE_COUNT_HEADER = "Upstash-Workflow-Invoke-Count";
23482
+ var WORKFLOW_LABEL_HEADER = "Upstash-Label";
23482
23483
  var WORKFLOW_PROTOCOL_VERSION = "1";
23483
23484
  var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
23484
23485
  var DEFAULT_CONTENT_TYPE = "application/json";
23485
23486
  var NO_CONCURRENCY = 1;
23486
23487
  var DEFAULT_RETRIES = 3;
23487
- var VERSION = "v0.2.17";
23488
+ var VERSION = "v0.2.18";
23488
23489
  var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
23489
23490
  var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
23490
23491
  var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
@@ -24059,7 +24060,7 @@ var triggerFirstInvocation = async (params) => {
24059
24060
  const firstInvocationParams = Array.isArray(params) ? params : [params];
24060
24061
  const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
24061
24062
  const invocationBatch = firstInvocationParams.map(
24062
- ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
24063
+ ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
24063
24064
  const { headers } = getHeaders({
24064
24065
  initHeaderValue: "true",
24065
24066
  workflowConfig: {
@@ -24081,13 +24082,17 @@ var triggerFirstInvocation = async (params) => {
24081
24082
  if (useJSONContent) {
24082
24083
  headers["content-type"] = "application/json";
24083
24084
  }
24085
+ if (workflowContext.label) {
24086
+ headers[WORKFLOW_LABEL_HEADER] = workflowContext.label;
24087
+ }
24084
24088
  const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
24085
24089
  return {
24086
24090
  headers,
24087
24091
  method: "POST",
24088
24092
  body,
24089
24093
  url: workflowContext.url,
24090
- delay
24094
+ delay,
24095
+ notBefore
24091
24096
  };
24092
24097
  }
24093
24098
  );
@@ -24181,10 +24186,11 @@ var recreateUserHeaders = (headers) => {
24181
24186
  const pairs = headers.entries();
24182
24187
  for (const [header, value] of pairs) {
24183
24188
  const headerLowerCase = header.toLowerCase();
24184
- if (!headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
24189
+ const isUserHeader = !headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
24185
24190
  !headerLowerCase.startsWith("x-vercel-") && !headerLowerCase.startsWith("x-forwarded-") && // https://blog.cloudflare.com/preventing-request-loops-using-cdn-loop/
24186
24191
  headerLowerCase !== "cf-connecting-ip" && headerLowerCase !== "cdn-loop" && headerLowerCase !== "cf-ew-via" && headerLowerCase !== "cf-ray" && // For Render https://render.com
24187
- headerLowerCase !== "render-proxy-ttl") {
24192
+ headerLowerCase !== "render-proxy-ttl" || headerLowerCase === WORKFLOW_LABEL_HEADER.toLocaleLowerCase();
24193
+ if (isUserHeader) {
24188
24194
  filteredHeaders.append(header, value);
24189
24195
  }
24190
24196
  }
@@ -26214,6 +26220,22 @@ var WorkflowContext = class {
26214
26220
  * and number of requests per second with the same key.
26215
26221
  */
26216
26222
  flowControl;
26223
+ /**
26224
+ * Label to apply to the workflow run.
26225
+ *
26226
+ * Can be used to filter the workflow run logs.
26227
+ *
26228
+ * Can be set by passing a `label` parameter when triggering the workflow
26229
+ * with `client.trigger`:
26230
+ *
26231
+ * ```ts
26232
+ * await client.trigger({
26233
+ * url: "https://workflow-endpoint.com",
26234
+ * label: "my-label"
26235
+ * });
26236
+ * ```
26237
+ */
26238
+ label;
26217
26239
  constructor({
26218
26240
  qstashClient,
26219
26241
  workflowRunId,
@@ -26228,7 +26250,8 @@ var WorkflowContext = class {
26228
26250
  retryDelay,
26229
26251
  telemetry: telemetry2,
26230
26252
  invokeCount,
26231
- flowControl
26253
+ flowControl,
26254
+ label
26232
26255
  }) {
26233
26256
  this.qstashClient = qstashClient;
26234
26257
  this.workflowRunId = workflowRunId;
@@ -26241,6 +26264,7 @@ var WorkflowContext = class {
26241
26264
  this.retries = retries ?? DEFAULT_RETRIES;
26242
26265
  this.retryDelay = retryDelay;
26243
26266
  this.flowControl = flowControl;
26267
+ this.label = label;
26244
26268
  this.executor = new AutoExecutor(this, this.steps, telemetry2, invokeCount, debug);
26245
26269
  }
26246
26270
  /**
@@ -26541,7 +26565,8 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
26541
26565
  env: context.env,
26542
26566
  retries: context.retries,
26543
26567
  retryDelay: context.retryDelay,
26544
- flowControl: context.flowControl
26568
+ flowControl: context.flowControl,
26569
+ label: context.label
26545
26570
  });
26546
26571
  try {
26547
26572
  await routeFunction(disabledContext);
@@ -26718,11 +26743,12 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
26718
26743
  if (!errorMessage) {
26719
26744
  errorMessage = `Couldn't parse 'failResponse' in 'failureFunction', received: '${decodedBody}'`;
26720
26745
  }
26746
+ const userHeaders = recreateUserHeaders(request.headers);
26721
26747
  const workflowContext = new WorkflowContext({
26722
26748
  qstashClient,
26723
26749
  workflowRunId,
26724
26750
  initialPayload: sourceBody ? initialPayloadParser(decodeBase64(sourceBody)) : void 0,
26725
- headers: recreateUserHeaders(request.headers),
26751
+ headers: userHeaders,
26726
26752
  steps: [],
26727
26753
  url,
26728
26754
  failureUrl: url,
@@ -26731,8 +26757,9 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
26731
26757
  retries,
26732
26758
  retryDelay,
26733
26759
  flowControl,
26734
- telemetry: void 0
26760
+ telemetry: void 0,
26735
26761
  // not going to make requests in authentication check
26762
+ label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0
26736
26763
  });
26737
26764
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
26738
26765
  routeFunction,
@@ -26765,7 +26792,7 @@ var processOptions = (options) => {
26765
26792
  environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
26766
26793
  );
26767
26794
  return {
26768
- qstashClient: new import_qstash11.Client({
26795
+ qstashClient: options?.qstashClient ?? new import_qstash11.Client({
26769
26796
  baseUrl: environment.QSTASH_URL,
26770
26797
  token: environment.QSTASH_TOKEN
26771
26798
  }),
@@ -26941,6 +26968,7 @@ var serveBase = (routeFunction, telemetry2, options) => {
26941
26968
  });
26942
26969
  }
26943
26970
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
26971
+ const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
26944
26972
  const workflowContext = new WorkflowContext({
26945
26973
  qstashClient,
26946
26974
  workflowRunId,
@@ -26955,7 +26983,8 @@ var serveBase = (routeFunction, telemetry2, options) => {
26955
26983
  retryDelay,
26956
26984
  telemetry: telemetry2,
26957
26985
  invokeCount,
26958
- flowControl
26986
+ flowControl,
26987
+ label
26959
26988
  });
26960
26989
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
26961
26990
  routeFunction,
package/express.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  __toESM,
6
6
  serveBase,
7
7
  serveManyBase
8
- } from "./chunk-RP7G4UD5.mjs";
8
+ } from "./chunk-37XOXDLZ.mjs";
9
9
 
10
10
  // node_modules/depd/index.js
11
11
  var require_depd = __commonJS({
package/h3.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as h3 from 'h3';
2
- import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types--R_3XZXz.mjs';
3
- import { s as serveManyBase } from './serve-many-DgDSOvQs.mjs';
2
+ import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types-B7_5AkKQ.mjs';
3
+ import { s as serveManyBase } from './serve-many-CEUYWQvV.mjs';
4
4
  import '@upstash/qstash';
5
5
  import 'zod';
6
6
  import 'ai';
package/h3.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as h3 from 'h3';
2
- import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types--R_3XZXz.js';
3
- import { s as serveManyBase } from './serve-many-B3DfoTFt.js';
2
+ import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types-B7_5AkKQ.js';
3
+ import { s as serveManyBase } from './serve-many-BObe3pdI.js';
4
4
  import '@upstash/qstash';
5
5
  import 'zod';
6
6
  import 'ai';
package/h3.js CHANGED
@@ -398,12 +398,13 @@ var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
398
398
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
399
399
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
400
400
  var WORKFLOW_INVOKE_COUNT_HEADER = "Upstash-Workflow-Invoke-Count";
401
+ var WORKFLOW_LABEL_HEADER = "Upstash-Label";
401
402
  var WORKFLOW_PROTOCOL_VERSION = "1";
402
403
  var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
403
404
  var DEFAULT_CONTENT_TYPE = "application/json";
404
405
  var NO_CONCURRENCY = 1;
405
406
  var DEFAULT_RETRIES = 3;
406
- var VERSION = "v0.2.17";
407
+ var VERSION = "v0.2.18";
407
408
  var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
408
409
  var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
409
410
  var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
@@ -925,7 +926,7 @@ var triggerFirstInvocation = async (params) => {
925
926
  const firstInvocationParams = Array.isArray(params) ? params : [params];
926
927
  const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
927
928
  const invocationBatch = firstInvocationParams.map(
928
- ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
929
+ ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
929
930
  const { headers } = getHeaders({
930
931
  initHeaderValue: "true",
931
932
  workflowConfig: {
@@ -947,13 +948,17 @@ var triggerFirstInvocation = async (params) => {
947
948
  if (useJSONContent) {
948
949
  headers["content-type"] = "application/json";
949
950
  }
951
+ if (workflowContext.label) {
952
+ headers[WORKFLOW_LABEL_HEADER] = workflowContext.label;
953
+ }
950
954
  const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
951
955
  return {
952
956
  headers,
953
957
  method: "POST",
954
958
  body,
955
959
  url: workflowContext.url,
956
- delay
960
+ delay,
961
+ notBefore
957
962
  };
958
963
  }
959
964
  );
@@ -1047,10 +1052,11 @@ var recreateUserHeaders = (headers) => {
1047
1052
  const pairs = headers.entries();
1048
1053
  for (const [header, value] of pairs) {
1049
1054
  const headerLowerCase = header.toLowerCase();
1050
- if (!headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
1055
+ const isUserHeader = !headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
1051
1056
  !headerLowerCase.startsWith("x-vercel-") && !headerLowerCase.startsWith("x-forwarded-") && // https://blog.cloudflare.com/preventing-request-loops-using-cdn-loop/
1052
1057
  headerLowerCase !== "cf-connecting-ip" && headerLowerCase !== "cdn-loop" && headerLowerCase !== "cf-ew-via" && headerLowerCase !== "cf-ray" && // For Render https://render.com
1053
- headerLowerCase !== "render-proxy-ttl") {
1058
+ headerLowerCase !== "render-proxy-ttl" || headerLowerCase === WORKFLOW_LABEL_HEADER.toLocaleLowerCase();
1059
+ if (isUserHeader) {
1054
1060
  filteredHeaders.append(header, value);
1055
1061
  }
1056
1062
  }
@@ -3080,6 +3086,22 @@ var WorkflowContext = class {
3080
3086
  * and number of requests per second with the same key.
3081
3087
  */
3082
3088
  flowControl;
3089
+ /**
3090
+ * Label to apply to the workflow run.
3091
+ *
3092
+ * Can be used to filter the workflow run logs.
3093
+ *
3094
+ * Can be set by passing a `label` parameter when triggering the workflow
3095
+ * with `client.trigger`:
3096
+ *
3097
+ * ```ts
3098
+ * await client.trigger({
3099
+ * url: "https://workflow-endpoint.com",
3100
+ * label: "my-label"
3101
+ * });
3102
+ * ```
3103
+ */
3104
+ label;
3083
3105
  constructor({
3084
3106
  qstashClient,
3085
3107
  workflowRunId,
@@ -3094,7 +3116,8 @@ var WorkflowContext = class {
3094
3116
  retryDelay,
3095
3117
  telemetry: telemetry2,
3096
3118
  invokeCount,
3097
- flowControl
3119
+ flowControl,
3120
+ label
3098
3121
  }) {
3099
3122
  this.qstashClient = qstashClient;
3100
3123
  this.workflowRunId = workflowRunId;
@@ -3107,6 +3130,7 @@ var WorkflowContext = class {
3107
3130
  this.retries = retries ?? DEFAULT_RETRIES;
3108
3131
  this.retryDelay = retryDelay;
3109
3132
  this.flowControl = flowControl;
3133
+ this.label = label;
3110
3134
  this.executor = new AutoExecutor(this, this.steps, telemetry2, invokeCount, debug);
3111
3135
  }
3112
3136
  /**
@@ -3407,7 +3431,8 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
3407
3431
  env: context.env,
3408
3432
  retries: context.retries,
3409
3433
  retryDelay: context.retryDelay,
3410
- flowControl: context.flowControl
3434
+ flowControl: context.flowControl,
3435
+ label: context.label
3411
3436
  });
3412
3437
  try {
3413
3438
  await routeFunction(disabledContext);
@@ -3584,11 +3609,12 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
3584
3609
  if (!errorMessage) {
3585
3610
  errorMessage = `Couldn't parse 'failResponse' in 'failureFunction', received: '${decodedBody}'`;
3586
3611
  }
3612
+ const userHeaders = recreateUserHeaders(request.headers);
3587
3613
  const workflowContext = new WorkflowContext({
3588
3614
  qstashClient,
3589
3615
  workflowRunId,
3590
3616
  initialPayload: sourceBody ? initialPayloadParser(decodeBase64(sourceBody)) : void 0,
3591
- headers: recreateUserHeaders(request.headers),
3617
+ headers: userHeaders,
3592
3618
  steps: [],
3593
3619
  url,
3594
3620
  failureUrl: url,
@@ -3597,8 +3623,9 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
3597
3623
  retries,
3598
3624
  retryDelay,
3599
3625
  flowControl,
3600
- telemetry: void 0
3626
+ telemetry: void 0,
3601
3627
  // not going to make requests in authentication check
3628
+ label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0
3602
3629
  });
3603
3630
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
3604
3631
  routeFunction,
@@ -3631,7 +3658,7 @@ var processOptions = (options) => {
3631
3658
  environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
3632
3659
  );
3633
3660
  return {
3634
- qstashClient: new import_qstash11.Client({
3661
+ qstashClient: options?.qstashClient ?? new import_qstash11.Client({
3635
3662
  baseUrl: environment.QSTASH_URL,
3636
3663
  token: environment.QSTASH_TOKEN
3637
3664
  }),
@@ -3807,6 +3834,7 @@ var serveBase = (routeFunction, telemetry2, options) => {
3807
3834
  });
3808
3835
  }
3809
3836
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3837
+ const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3810
3838
  const workflowContext = new WorkflowContext({
3811
3839
  qstashClient,
3812
3840
  workflowRunId,
@@ -3821,7 +3849,8 @@ var serveBase = (routeFunction, telemetry2, options) => {
3821
3849
  retryDelay,
3822
3850
  telemetry: telemetry2,
3823
3851
  invokeCount,
3824
- flowControl
3852
+ flowControl,
3853
+ label
3825
3854
  });
3826
3855
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
3827
3856
  routeFunction,
package/h3.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-RP7G4UD5.mjs";
5
+ } from "./chunk-37XOXDLZ.mjs";
6
6
 
7
7
  // node_modules/defu/dist/defu.mjs
8
8
  function isPlainObject(value) {
package/hono.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context } from 'hono';
2
- import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types--R_3XZXz.mjs';
2
+ import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types-B7_5AkKQ.mjs';
3
3
  import { Variables } from 'hono/types';
4
- import { s as serveManyBase } from './serve-many-DgDSOvQs.mjs';
4
+ import { s as serveManyBase } from './serve-many-CEUYWQvV.mjs';
5
5
  import '@upstash/qstash';
6
6
  import 'zod';
7
7
  import 'ai';
package/hono.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context } from 'hono';
2
- import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types--R_3XZXz.js';
2
+ import { R as RouteFunction, n as PublicServeOptions, x as InvokableWorkflow } from './types-B7_5AkKQ.js';
3
3
  import { Variables } from 'hono/types';
4
- import { s as serveManyBase } from './serve-many-B3DfoTFt.js';
4
+ import { s as serveManyBase } from './serve-many-BObe3pdI.js';
5
5
  import '@upstash/qstash';
6
6
  import 'zod';
7
7
  import 'ai';
package/hono.js CHANGED
@@ -86,12 +86,13 @@ var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
86
86
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
87
87
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
88
88
  var WORKFLOW_INVOKE_COUNT_HEADER = "Upstash-Workflow-Invoke-Count";
89
+ var WORKFLOW_LABEL_HEADER = "Upstash-Label";
89
90
  var WORKFLOW_PROTOCOL_VERSION = "1";
90
91
  var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
91
92
  var DEFAULT_CONTENT_TYPE = "application/json";
92
93
  var NO_CONCURRENCY = 1;
93
94
  var DEFAULT_RETRIES = 3;
94
- var VERSION = "v0.2.17";
95
+ var VERSION = "v0.2.18";
95
96
  var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
96
97
  var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
97
98
  var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
@@ -613,7 +614,7 @@ var triggerFirstInvocation = async (params) => {
613
614
  const firstInvocationParams = Array.isArray(params) ? params : [params];
614
615
  const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
615
616
  const invocationBatch = firstInvocationParams.map(
616
- ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
617
+ ({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
617
618
  const { headers } = getHeaders({
618
619
  initHeaderValue: "true",
619
620
  workflowConfig: {
@@ -635,13 +636,17 @@ var triggerFirstInvocation = async (params) => {
635
636
  if (useJSONContent) {
636
637
  headers["content-type"] = "application/json";
637
638
  }
639
+ if (workflowContext.label) {
640
+ headers[WORKFLOW_LABEL_HEADER] = workflowContext.label;
641
+ }
638
642
  const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
639
643
  return {
640
644
  headers,
641
645
  method: "POST",
642
646
  body,
643
647
  url: workflowContext.url,
644
- delay
648
+ delay,
649
+ notBefore
645
650
  };
646
651
  }
647
652
  );
@@ -735,10 +740,11 @@ var recreateUserHeaders = (headers) => {
735
740
  const pairs = headers.entries();
736
741
  for (const [header, value] of pairs) {
737
742
  const headerLowerCase = header.toLowerCase();
738
- if (!headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
743
+ const isUserHeader = !headerLowerCase.startsWith("upstash-workflow-") && // https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
739
744
  !headerLowerCase.startsWith("x-vercel-") && !headerLowerCase.startsWith("x-forwarded-") && // https://blog.cloudflare.com/preventing-request-loops-using-cdn-loop/
740
745
  headerLowerCase !== "cf-connecting-ip" && headerLowerCase !== "cdn-loop" && headerLowerCase !== "cf-ew-via" && headerLowerCase !== "cf-ray" && // For Render https://render.com
741
- headerLowerCase !== "render-proxy-ttl") {
746
+ headerLowerCase !== "render-proxy-ttl" || headerLowerCase === WORKFLOW_LABEL_HEADER.toLocaleLowerCase();
747
+ if (isUserHeader) {
742
748
  filteredHeaders.append(header, value);
743
749
  }
744
750
  }
@@ -2768,6 +2774,22 @@ var WorkflowContext = class {
2768
2774
  * and number of requests per second with the same key.
2769
2775
  */
2770
2776
  flowControl;
2777
+ /**
2778
+ * Label to apply to the workflow run.
2779
+ *
2780
+ * Can be used to filter the workflow run logs.
2781
+ *
2782
+ * Can be set by passing a `label` parameter when triggering the workflow
2783
+ * with `client.trigger`:
2784
+ *
2785
+ * ```ts
2786
+ * await client.trigger({
2787
+ * url: "https://workflow-endpoint.com",
2788
+ * label: "my-label"
2789
+ * });
2790
+ * ```
2791
+ */
2792
+ label;
2771
2793
  constructor({
2772
2794
  qstashClient,
2773
2795
  workflowRunId,
@@ -2782,7 +2804,8 @@ var WorkflowContext = class {
2782
2804
  retryDelay,
2783
2805
  telemetry: telemetry2,
2784
2806
  invokeCount,
2785
- flowControl
2807
+ flowControl,
2808
+ label
2786
2809
  }) {
2787
2810
  this.qstashClient = qstashClient;
2788
2811
  this.workflowRunId = workflowRunId;
@@ -2795,6 +2818,7 @@ var WorkflowContext = class {
2795
2818
  this.retries = retries ?? DEFAULT_RETRIES;
2796
2819
  this.retryDelay = retryDelay;
2797
2820
  this.flowControl = flowControl;
2821
+ this.label = label;
2798
2822
  this.executor = new AutoExecutor(this, this.steps, telemetry2, invokeCount, debug);
2799
2823
  }
2800
2824
  /**
@@ -3095,7 +3119,8 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
3095
3119
  env: context.env,
3096
3120
  retries: context.retries,
3097
3121
  retryDelay: context.retryDelay,
3098
- flowControl: context.flowControl
3122
+ flowControl: context.flowControl,
3123
+ label: context.label
3099
3124
  });
3100
3125
  try {
3101
3126
  await routeFunction(disabledContext);
@@ -3272,11 +3297,12 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
3272
3297
  if (!errorMessage) {
3273
3298
  errorMessage = `Couldn't parse 'failResponse' in 'failureFunction', received: '${decodedBody}'`;
3274
3299
  }
3300
+ const userHeaders = recreateUserHeaders(request.headers);
3275
3301
  const workflowContext = new WorkflowContext({
3276
3302
  qstashClient,
3277
3303
  workflowRunId,
3278
3304
  initialPayload: sourceBody ? initialPayloadParser(decodeBase64(sourceBody)) : void 0,
3279
- headers: recreateUserHeaders(request.headers),
3305
+ headers: userHeaders,
3280
3306
  steps: [],
3281
3307
  url,
3282
3308
  failureUrl: url,
@@ -3285,8 +3311,9 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
3285
3311
  retries,
3286
3312
  retryDelay,
3287
3313
  flowControl,
3288
- telemetry: void 0
3314
+ telemetry: void 0,
3289
3315
  // not going to make requests in authentication check
3316
+ label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0
3290
3317
  });
3291
3318
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
3292
3319
  routeFunction,
@@ -3319,7 +3346,7 @@ var processOptions = (options) => {
3319
3346
  environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
3320
3347
  );
3321
3348
  return {
3322
- qstashClient: new import_qstash11.Client({
3349
+ qstashClient: options?.qstashClient ?? new import_qstash11.Client({
3323
3350
  baseUrl: environment.QSTASH_URL,
3324
3351
  token: environment.QSTASH_TOKEN
3325
3352
  }),
@@ -3495,6 +3522,7 @@ var serveBase = (routeFunction, telemetry2, options) => {
3495
3522
  });
3496
3523
  }
3497
3524
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3525
+ const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3498
3526
  const workflowContext = new WorkflowContext({
3499
3527
  qstashClient,
3500
3528
  workflowRunId,
@@ -3509,7 +3537,8 @@ var serveBase = (routeFunction, telemetry2, options) => {
3509
3537
  retryDelay,
3510
3538
  telemetry: telemetry2,
3511
3539
  invokeCount,
3512
- flowControl
3540
+ flowControl,
3541
+ label
3513
3542
  });
3514
3543
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
3515
3544
  routeFunction,
package/hono.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-RP7G4UD5.mjs";
5
+ } from "./chunk-37XOXDLZ.mjs";
6
6
 
7
7
  // platforms/hono.ts
8
8
  var telemetry = {
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter } from './types--R_3XZXz.mjs';
2
- export { A as AsyncStepFunction, C as CallResponse, v as CallSettings, D as DetailedFinishCondition, t as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, x as InvokableWorkflow, w as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, y as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, l as SyncStepFunction, u as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, B as WorkflowLogger, z as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types--R_3XZXz.mjs';
1
+ import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter } from './types-B7_5AkKQ.mjs';
2
+ export { A as AsyncStepFunction, C as CallResponse, v as CallSettings, D as DetailedFinishCondition, t as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, x as InvokableWorkflow, w as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, y as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, l as SyncStepFunction, u as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, B as WorkflowLogger, z as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types-B7_5AkKQ.mjs';
3
3
  import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1 } from '@upstash/qstash';
4
4
  import 'zod';
5
5
  import 'ai';
@@ -343,6 +343,10 @@ type WorkflowRunLog = {
343
343
  * If the workflow run has failed, id of the run in DLQ
344
344
  */
345
345
  dlqId?: string;
346
+ /**
347
+ * Label of the workflow run
348
+ */
349
+ label?: string;
346
350
  };
347
351
  type WorkflowRunLogs = {
348
352
  cursor: string;
@@ -412,6 +416,22 @@ type TriggerOptions = {
412
416
  * Delay to apply before triggering the workflow.
413
417
  */
414
418
  delay?: PublishRequest["delay"];
419
+ /**
420
+ * Optionally set the absolute delay of this message.
421
+ * This will override the delay option.
422
+ * The message will not delivered until the specified time.
423
+ *
424
+ * Unix timestamp in seconds.
425
+ *
426
+ * @default undefined
427
+ */
428
+ notBefore?: PublishRequest["notBefore"];
429
+ /**
430
+ * Label to apply to the workflow run.
431
+ *
432
+ * Can be used to filter the workflow run logs.
433
+ */
434
+ label?: string;
415
435
  } & ({
416
436
  /**
417
437
  * URL to call if the first request to the workflow endpoint fails
@@ -456,6 +476,7 @@ type DLQFilterOptions = Pick<QStashDLQFilterOptions, "fromDate" | "toDate" | "ur
456
476
  workflowRunId?: string;
457
477
  workflowCreatedAt?: string;
458
478
  failureFunctionState?: FailureCallbackInfo["state"];
479
+ label?: string;
459
480
  };
460
481
  type FailureCallbackInfo = {
461
482
  state?: "CALLBACK_FAIL" | "CALLBACK_SUCCESS" | "CALLBACK_INPROGRESS";
@@ -491,8 +512,12 @@ type DLQMessage = {
491
512
  * status of the failure callback
492
513
  */
493
514
  failureCallbackInfo?: FailureCallbackInfo;
515
+ /**
516
+ * label passed when triggering workflow
517
+ */
518
+ label?: string;
494
519
  };
495
- type PublicDLQMessage = Pick<DLQMessage, "header" | "body" | "maxRetries" | "notBefore" | "createdAt" | "callerIP" | "workflowRunId" | "workflowCreatedAt" | "workflowUrl" | "responseStatus" | "responseHeader" | "responseBody" | "dlqId" | "failureCallback" | "failureCallbackInfo">;
520
+ type PublicDLQMessage = Pick<DLQMessage, "header" | "body" | "maxRetries" | "notBefore" | "createdAt" | "callerIP" | "workflowRunId" | "workflowCreatedAt" | "workflowUrl" | "responseStatus" | "responseHeader" | "responseBody" | "dlqId" | "failureCallback" | "failureCallbackInfo" | "label">;
496
521
  declare class DLQ {
497
522
  private client;
498
523
  constructor(client: Client$1);
@@ -832,6 +857,7 @@ declare class Client {
832
857
  state?: WorkflowRunLog["workflowState"];
833
858
  workflowUrl?: WorkflowRunLog["workflowUrl"];
834
859
  workflowCreatedAt?: WorkflowRunLog["workflowRunCreatedAt"];
860
+ label?: WorkflowRunLog["label"];
835
861
  }): Promise<WorkflowRunLogs>;
836
862
  get dlq(): DLQ;
837
863
  }