@upstash/workflow 1.2.0-demo-rc.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 +72 -69
  5. package/astro.mjs +1 -1
  6. package/{chunk-NZCQPOPR.mjs → chunk-V5ZUHMAF.mjs} +66 -257
  7. package/cloudflare.d.mts +2 -2
  8. package/cloudflare.d.ts +2 -2
  9. package/cloudflare.js +72 -69
  10. package/cloudflare.mjs +1 -1
  11. package/express.d.mts +2 -2
  12. package/express.d.ts +2 -2
  13. package/express.js +72 -69
  14. package/express.mjs +1 -1
  15. package/h3.d.mts +2 -2
  16. package/h3.d.ts +2 -2
  17. package/h3.js +76 -73
  18. package/h3.mjs +5 -5
  19. package/hono.d.mts +2 -2
  20. package/hono.d.ts +2 -2
  21. package/hono.js +73 -265
  22. package/hono.mjs +2 -7
  23. package/index.d.mts +30 -12
  24. package/index.d.ts +30 -12
  25. package/index.js +93 -298
  26. package/index.mjs +21 -41
  27. package/nextjs.d.mts +2 -2
  28. package/nextjs.d.ts +2 -2
  29. package/nextjs.js +72 -263
  30. package/nextjs.mjs +1 -5
  31. package/package.json +1 -1
  32. package/react-router.d.mts +38 -0
  33. package/react-router.d.ts +38 -0
  34. package/react-router.js +3881 -0
  35. package/react-router.mjs +45 -0
  36. package/{serve-many-Bi8XaOyq.d.ts → serve-many-B-fe7bh7.d.ts} +1 -1
  37. package/{serve-many-CppVPJrh.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 +72 -69
  41. package/solidjs.mjs +1 -1
  42. package/svelte.d.mts +2 -2
  43. package/svelte.d.ts +2 -2
  44. package/svelte.js +72 -69
  45. package/svelte.mjs +1 -1
  46. package/tanstack.d.mts +2 -2
  47. package/tanstack.d.ts +2 -2
  48. package/tanstack.js +72 -69
  49. package/tanstack.mjs +1 -1
  50. package/{types-CUwgrpCM.d.ts → types-B2S08hRU.d.mts} +18 -3
  51. package/{types-CUwgrpCM.d.mts → types-B2S08hRU.d.ts} +18 -3
package/hono.js CHANGED
@@ -126,9 +126,10 @@ function isInstanceOf(v, ctor) {
126
126
  }
127
127
 
128
128
  // src/client/utils.ts
129
- var makeNotifyRequest = async (requester, eventId, eventData) => {
129
+ var makeNotifyRequest = async (requester, eventId, eventData, workflowRunId) => {
130
+ const path = workflowRunId ? ["v2", "notify", workflowRunId, eventId] : ["v2", "notify", eventId];
130
131
  const result = await requester.request({
131
- path: ["v2", "notify", eventId],
132
+ path,
132
133
  method: "POST",
133
134
  body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
134
135
  });
@@ -186,6 +187,7 @@ var getSteps = async (requester, workflowRunId, messageId, dispatchDebug) => {
186
187
  var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
187
188
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
188
189
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
190
+ var WORKFLOW_CREATED_AT_HEADER = "Upstash-Workflow-CreatedAt";
189
191
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
190
192
  var WORKFLOW_FAILURE_CALLBACK_HEADER = "Upstash-Workflow-Failure-Callback";
191
193
  var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
@@ -721,6 +723,7 @@ var triggerFirstInvocation = async (params) => {
721
723
  retries,
722
724
  retryDelay,
723
725
  flowControl,
726
+ redact,
724
727
  unknownSdk
725
728
  }) => {
726
729
  const { headers } = getHeaders({
@@ -757,7 +760,8 @@ var triggerFirstInvocation = async (params) => {
757
760
  body,
758
761
  url: workflowContext.url,
759
762
  delay,
760
- notBefore
763
+ notBefore,
764
+ redact
761
765
  };
762
766
  }
763
767
  );
@@ -916,7 +920,6 @@ ${atob(callbackMessage.body ?? "")}`
916
920
  })}`
917
921
  );
918
922
  }
919
- const userHeaders = recreateUserHeaders(request.headers);
920
923
  const { headers: requestHeaders } = getHeaders({
921
924
  initHeaderValue: "false",
922
925
  workflowConfig: {
@@ -924,7 +927,6 @@ ${atob(callbackMessage.body ?? "")}`
924
927
  workflowUrl,
925
928
  telemetry: telemetry2
926
929
  },
927
- userHeaders,
928
930
  invokeCount: Number(invokeCount)
929
931
  });
930
932
  const callResponse = {
@@ -1073,7 +1075,6 @@ var BaseLazyStep = class _BaseLazyStep {
1073
1075
  useJSONContent: false,
1074
1076
  telemetry: telemetry2
1075
1077
  },
1076
- userHeaders: context.headers,
1077
1078
  invokeCount,
1078
1079
  stepInfo: {
1079
1080
  step,
@@ -1431,9 +1432,9 @@ var LazyWaitEventStep = class extends BaseLazyStep {
1431
1432
  };
1432
1433
  var LazyNotifyStep = class extends LazyFunctionStep {
1433
1434
  stepType = "Notify";
1434
- constructor(context, stepName, eventId, eventData, requester) {
1435
+ constructor(context, stepName, eventId, eventData, requester, workflowRunId) {
1435
1436
  super(context, stepName, async () => {
1436
- const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
1437
+ const notifyResponse = await makeNotifyRequest(requester, eventId, eventData, workflowRunId);
1437
1438
  return {
1438
1439
  eventId,
1439
1440
  eventData,
@@ -1503,7 +1504,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
1503
1504
  telemetry: telemetry2,
1504
1505
  useJSONContent: false
1505
1506
  },
1506
- userHeaders: context.headers,
1507
1507
  invokeCount
1508
1508
  });
1509
1509
  context.qstashClient.http.headers?.forEach((value, key) => {
@@ -1516,6 +1516,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
1516
1516
  Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
1517
1517
  ),
1518
1518
  workflowRunId: context.workflowRunId,
1519
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
1519
1520
  workflowUrl: context.url,
1520
1521
  step
1521
1522
  };
@@ -1611,12 +1612,14 @@ var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
1611
1612
  const parsedEventData = BaseLazyStep.tryParsing(eventData);
1612
1613
  const body = parsedEventData.body;
1613
1614
  const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
1615
+ const methodUpper = parsedEventData.method.toUpperCase();
1616
+ const canHaveBody = methodUpper !== "GET" && methodUpper !== "HEAD";
1614
1617
  const request = new Request(
1615
1618
  `${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
1616
1619
  {
1617
1620
  method: parsedEventData.method,
1618
1621
  headers: parsedEventData.header,
1619
- body: parsedBody
1622
+ body: canHaveBody ? parsedBody : void 0
1620
1623
  }
1621
1624
  );
1622
1625
  return {
@@ -1750,6 +1753,9 @@ var WorkflowHeaders = class {
1750
1753
  }
1751
1754
  }
1752
1755
  addUserHeaders() {
1756
+ if (!this.userHeaders) {
1757
+ return;
1758
+ }
1753
1759
  for (const [key, value] of this.userHeaders.entries()) {
1754
1760
  const forwardKey = `Forward-${key}`;
1755
1761
  this.headers.workflowHeaders[forwardKey] = value;
@@ -1856,7 +1862,6 @@ var submitParallelSteps = async ({
1856
1862
  workflowUrl: context.url,
1857
1863
  telemetry: telemetry2
1858
1864
  },
1859
- userHeaders: context.headers,
1860
1865
  invokeCount
1861
1866
  });
1862
1867
  return {
@@ -2109,7 +2114,7 @@ var AutoExecutor = class _AutoExecutor {
2109
2114
  });
2110
2115
  throw new WorkflowAbort(parallelStep.stepName, resultStep);
2111
2116
  } catch (error) {
2112
- 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) {
2113
2118
  throw error;
2114
2119
  }
2115
2120
  throw new WorkflowError(
@@ -2583,6 +2588,7 @@ var MiddlewareManager = class {
2583
2588
  };
2584
2589
 
2585
2590
  // src/context/context.ts
2591
+ var import_qstash9 = require("@upstash/qstash");
2586
2592
  var WorkflowContext = class {
2587
2593
  executor;
2588
2594
  steps;
@@ -2609,6 +2615,10 @@ var WorkflowContext = class {
2609
2615
  * Run id of the workflow
2610
2616
  */
2611
2617
  workflowRunId;
2618
+ /**
2619
+ * Creation time of the workflow run
2620
+ */
2621
+ workflowRunCreatedAt;
2612
2622
  /**
2613
2623
  * URL of the workflow
2614
2624
  *
@@ -2700,6 +2710,7 @@ var WorkflowContext = class {
2700
2710
  constructor({
2701
2711
  qstashClient,
2702
2712
  workflowRunId,
2713
+ workflowRunCreatedAt,
2703
2714
  headers,
2704
2715
  steps,
2705
2716
  url,
@@ -2712,6 +2723,7 @@ var WorkflowContext = class {
2712
2723
  }) {
2713
2724
  this.qstashClient = qstashClient;
2714
2725
  this.workflowRunId = workflowRunId;
2726
+ this.workflowRunCreatedAt = workflowRunCreatedAt;
2715
2727
  this.steps = steps;
2716
2728
  this.url = url;
2717
2729
  this.headers = headers;
@@ -2886,14 +2898,23 @@ var WorkflowContext = class {
2886
2898
  * a notifyResponse field which contains a list of `Waiter` objects, each corresponding
2887
2899
  * to a notified workflow run.
2888
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
+ *
2889
2909
  * @param stepName
2890
2910
  * @param eventId event id to notify
2891
2911
  * @param eventData event data to notify with
2912
+ * @param workflowRunId optional workflow run id for lookback support
2892
2913
  * @returns notify response which has event id, event data and list of waiters which were notified
2893
2914
  */
2894
- async notify(stepName, eventId, eventData) {
2915
+ async notify(stepName, eventId, eventData, workflowRunId) {
2895
2916
  return await this.addStep(
2896
- new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
2917
+ new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http, workflowRunId)
2897
2918
  );
2898
2919
  }
2899
2920
  async invoke(stepName, settings) {
@@ -2921,7 +2942,14 @@ var WorkflowContext = class {
2921
2942
  * DisabledWorkflowContext.
2922
2943
  */
2923
2944
  async addStep(step) {
2924
- 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
+ }
2925
2953
  }
2926
2954
  get api() {
2927
2955
  return new WorkflowApi({
@@ -2930,214 +2958,8 @@ var WorkflowContext = class {
2930
2958
  }
2931
2959
  };
2932
2960
 
2933
- // src/dev-server.ts
2934
- var import_child_process = require("child_process");
2935
- var import_fs = require("fs");
2936
- var import_https = require("https");
2937
- var import_http = require("http");
2938
- var import_path = require("path");
2939
- var import_os = require("os");
2940
- var DEV_QSTASH_TOKEN = "eyJVc2VySUQiOiJkZWZhdWx0VXNlciIsIlBhc3N3b3JkIjoiZGVmYXVsdFBhc3N3b3JkIn0=";
2941
- var DEV_QSTASH_CURRENT_SIGNING_KEY = "sig_7kYjw48mhY7kAjqNGcy6cr29RJ6r";
2942
- var DEV_QSTASH_NEXT_SIGNING_KEY = "sig_5ZB6DVzB1wjE8S6rZ7eenA8Pdnhs";
2943
- function getDevCredentials(port) {
2944
- return {
2945
- QSTASH_URL: `http://localhost:${port}`,
2946
- QSTASH_TOKEN: DEV_QSTASH_TOKEN,
2947
- QSTASH_CURRENT_SIGNING_KEY: DEV_QSTASH_CURRENT_SIGNING_KEY,
2948
- QSTASH_NEXT_SIGNING_KEY: DEV_QSTASH_NEXT_SIGNING_KEY
2949
- };
2950
- }
2951
- var CACHE_DIR = (0, import_path.join)("node_modules", ".cache", "upstash");
2952
- function getPlatformArch() {
2953
- const platform = process.platform === "darwin" ? "darwin" : "linux";
2954
- const arch = process.arch === "arm64" ? "arm64" : "amd64";
2955
- return { platform, arch };
2956
- }
2957
- function httpsGet(url) {
2958
- return new Promise((resolve, reject) => {
2959
- const request = (currentUrl) => {
2960
- (0, import_https.get)(currentUrl, { headers: { "User-Agent": "upstash-workflow" } }, (res) => {
2961
- if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
2962
- request(res.headers.location);
2963
- return;
2964
- }
2965
- if (res.statusCode && res.statusCode >= 400) {
2966
- reject(new Error(`HTTP ${res.statusCode} fetching ${currentUrl}`));
2967
- return;
2968
- }
2969
- const chunks = [];
2970
- res.on("data", (chunk) => chunks.push(chunk));
2971
- res.on("end", () => resolve(Buffer.concat(chunks)));
2972
- res.on("error", reject);
2973
- }).on("error", reject);
2974
- };
2975
- request(url);
2976
- });
2977
- }
2978
- function downloadToFile(url, dest) {
2979
- return new Promise((resolve, reject) => {
2980
- const request = (currentUrl) => {
2981
- (0, import_https.get)(currentUrl, { headers: { "User-Agent": "upstash-workflow" } }, (res) => {
2982
- if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
2983
- request(res.headers.location);
2984
- return;
2985
- }
2986
- if (res.statusCode && res.statusCode >= 400) {
2987
- reject(new Error(`HTTP ${res.statusCode} downloading ${currentUrl}`));
2988
- return;
2989
- }
2990
- const file = (0, import_fs.createWriteStream)(dest);
2991
- res.pipe(file);
2992
- file.on("finish", () => {
2993
- file.close(() => resolve());
2994
- });
2995
- file.on("error", reject);
2996
- }).on("error", reject);
2997
- };
2998
- request(url);
2999
- });
3000
- }
3001
- async function resolveLatestVersion() {
3002
- const data = await httpsGet("https://api.github.com/repos/upstash/qstash-cli/releases/latest");
3003
- const json = JSON.parse(data.toString());
3004
- return json.tag_name;
3005
- }
3006
- async function ensureBinary() {
3007
- const version = await resolveLatestVersion();
3008
- const cacheDir = (0, import_path.join)(CACHE_DIR, `qstash-server-${version}`);
3009
- const binaryPath = (0, import_path.join)(cacheDir, "qstash");
3010
- if ((0, import_fs.existsSync)(binaryPath)) {
3011
- return binaryPath;
3012
- }
3013
- const { platform, arch } = getPlatformArch();
3014
- const downloadUrl = `https://artifacts.upstash.com/qstash/versions/${version}/qstash-server_${version}_${platform}_${arch}.tar.gz`;
3015
- console.log(`[workflow-dev] Downloading QStash server...`);
3016
- (0, import_fs.mkdirSync)(cacheDir, { recursive: true });
3017
- const tempFile = (0, import_path.join)((0, import_os.tmpdir)(), `qstash-server-${version}-${Date.now()}.tar.gz`);
3018
- await downloadToFile(downloadUrl, tempFile);
3019
- (0, import_child_process.execSync)(`tar -xzf "${tempFile}" -C "${cacheDir}"`);
3020
- (0, import_fs.chmodSync)(binaryPath, 493);
3021
- return binaryPath;
3022
- }
3023
- function startServer(binaryPath, port) {
3024
- return new Promise((resolve, reject) => {
3025
- const child = (0, import_child_process.spawn)(binaryPath, ["dev", "-port", String(port)], {
3026
- stdio: ["ignore", "pipe", "pipe"]
3027
- });
3028
- let resolved = false;
3029
- const cleanup = () => {
3030
- if (!child.killed) {
3031
- child.kill("SIGTERM");
3032
- }
3033
- };
3034
- process.on("exit", cleanup);
3035
- process.on("SIGINT", () => {
3036
- cleanup();
3037
- process.exit(0);
3038
- });
3039
- process.on("SIGTERM", () => {
3040
- cleanup();
3041
- process.exit(0);
3042
- });
3043
- let stdoutBuffer = "";
3044
- child.stdout.on("data", (data) => {
3045
- const text = data.toString();
3046
- stdoutBuffer += text;
3047
- const lines = stdoutBuffer.split("\n");
3048
- stdoutBuffer = lines.pop() ?? "";
3049
- for (const line of lines) {
3050
- if (line.match(/runn+ing at/) && !resolved) {
3051
- resolved = true;
3052
- const creds = getDevCredentials(port);
3053
- console.log(`[workflow-dev] QStash server running at ${creds.QSTASH_URL}`);
3054
- console.log(
3055
- `[workflow-dev] View logs at \x1B[1;32mhttps://console.upstash.com/workflow/local-mode-user/logs\x1B[0m`
3056
- );
3057
- resolve(cleanup);
3058
- }
3059
- }
3060
- });
3061
- child.stderr.on("data", (data) => {
3062
- const text = data.toString();
3063
- if (!resolved) {
3064
- process.stderr.write(`[workflow-dev] ${text}`);
3065
- }
3066
- });
3067
- child.on("error", (err2) => {
3068
- if (!resolved) {
3069
- reject(new Error(`[workflow-dev] Failed to start QStash server: ${err2.message}`));
3070
- }
3071
- });
3072
- child.on("exit", (code) => {
3073
- if (!resolved) {
3074
- reject(
3075
- new Error(`[workflow-dev] QStash server exited with code ${code} before becoming ready`)
3076
- );
3077
- }
3078
- });
3079
- setTimeout(() => {
3080
- if (!resolved) {
3081
- cleanup();
3082
- reject(new Error("[workflow-dev] QStash server did not become ready within 30 seconds"));
3083
- }
3084
- }, 3e4);
3085
- });
3086
- }
3087
- function isDevServerRunning(port) {
3088
- return new Promise((resolve) => {
3089
- const req = (0, import_http.get)(
3090
- `http://127.0.0.1:${port}/v2/keys`,
3091
- {
3092
- headers: { Authorization: `Bearer ${DEV_QSTASH_TOKEN}` },
3093
- timeout: 2e3
3094
- },
3095
- (res) => {
3096
- if (res.statusCode !== 200) {
3097
- resolve(false);
3098
- return;
3099
- }
3100
- const chunks = [];
3101
- res.on("data", (chunk) => chunks.push(chunk));
3102
- res.on("end", () => {
3103
- try {
3104
- const body = JSON.parse(Buffer.concat(chunks).toString());
3105
- resolve(
3106
- body.current === DEV_QSTASH_CURRENT_SIGNING_KEY && body.next === DEV_QSTASH_NEXT_SIGNING_KEY
3107
- );
3108
- } catch {
3109
- resolve(false);
3110
- }
3111
- });
3112
- res.on("error", () => resolve(false));
3113
- }
3114
- );
3115
- req.on("error", () => resolve(false));
3116
- req.on("timeout", () => {
3117
- req.destroy();
3118
- resolve(false);
3119
- });
3120
- });
3121
- }
3122
- var serverPromise = null;
3123
- var serverCleanup = null;
3124
- function ensureDevServer(environment) {
3125
- if (!serverPromise) {
3126
- const port = Number(environment.WORKFLOW_DEV_PORT) || 8080;
3127
- serverPromise = isDevServerRunning(port).then((alreadyRunning) => {
3128
- if (alreadyRunning) {
3129
- return;
3130
- }
3131
- return ensureBinary().then((binaryPath) => startServer(binaryPath, port)).then((cleanup) => {
3132
- serverCleanup = cleanup;
3133
- });
3134
- });
3135
- }
3136
- return serverPromise;
3137
- }
3138
-
3139
2961
  // src/serve/authorization.ts
3140
- var import_qstash9 = require("@upstash/qstash");
2962
+ var import_qstash10 = require("@upstash/qstash");
3141
2963
  var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
3142
2964
  static disabledMessage = "disabled-qstash-worklfow-run";
3143
2965
  disabled = true;
@@ -3169,11 +2991,12 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
3169
2991
  */
3170
2992
  static async tryAuthentication(routeFunction, context) {
3171
2993
  const disabledContext = new _DisabledWorkflowContext({
3172
- qstashClient: new import_qstash9.Client({
2994
+ qstashClient: new import_qstash10.Client({
3173
2995
  baseUrl: "disabled-client",
3174
2996
  token: "disabled-client"
3175
2997
  }),
3176
2998
  workflowRunId: context.workflowRunId,
2999
+ workflowRunCreatedAt: context.workflowRunCreatedAt,
3177
3000
  headers: context.headers,
3178
3001
  steps: [],
3179
3002
  url: context.url,
@@ -3375,7 +3198,9 @@ var handleFailure = async ({
3375
3198
  return ok({ result: "failure-function-undefined" });
3376
3199
  }
3377
3200
  try {
3378
- const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
3201
+ const { status, header, body, url, sourceBody, workflowRunId, workflowCreatedAt } = JSON.parse(
3202
+ requestPayload
3203
+ );
3379
3204
  const decodedBody = body ? decodeBase64(body) : "{}";
3380
3205
  let errorMessage = "";
3381
3206
  let failStack = "";
@@ -3404,6 +3229,7 @@ var handleFailure = async ({
3404
3229
  telemetry: void 0,
3405
3230
  // not going to make requests in authentication check
3406
3231
  label: userHeaders.get(WORKFLOW_LABEL_HEADER) ?? void 0,
3232
+ workflowRunCreatedAt: workflowCreatedAt,
3407
3233
  middlewareManager: void 0
3408
3234
  });
3409
3235
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
@@ -3432,7 +3258,7 @@ var handleFailure = async ({
3432
3258
  };
3433
3259
 
3434
3260
  // src/serve/multi-region/handlers.ts
3435
- var import_qstash10 = require("@upstash/qstash");
3261
+ var import_qstash11 = require("@upstash/qstash");
3436
3262
 
3437
3263
  // src/serve/multi-region/utils.ts
3438
3264
  var VALID_REGIONS = ["EU_CENTRAL_1", "US_EAST_1"];
@@ -3497,7 +3323,7 @@ var getHandlersForRequest = (qstashHandlers, regionHeader, isFirstInvocation) =>
3497
3323
  };
3498
3324
  var createRegionalHandler = (environment, receiverConfig, region, clientOptions) => {
3499
3325
  const clientEnv = readClientEnvironmentVariables(environment, region);
3500
- const client = new import_qstash10.Client({
3326
+ const client = new import_qstash11.Client({
3501
3327
  ...clientOptions,
3502
3328
  baseUrl: clientEnv.QSTASH_URL,
3503
3329
  token: clientEnv.QSTASH_TOKEN
@@ -3547,7 +3373,7 @@ var getQStashHandlers = ({
3547
3373
  return {
3548
3374
  mode: "single-region",
3549
3375
  handlers: {
3550
- client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash10.Client({
3376
+ client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash11.Client({
3551
3377
  ...qstashClientOption,
3552
3378
  baseUrl: environment.QSTASH_URL,
3553
3379
  token: environment.QSTASH_TOKEN
@@ -3563,7 +3389,7 @@ var getReceiver = (environment, receiverConfig, region) => {
3563
3389
  return void 0;
3564
3390
  }
3565
3391
  const receiverEnv = readReceiverEnvironmentVariables(environment, region);
3566
- 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({
3567
3393
  currentSigningKey: receiverEnv.QSTASH_CURRENT_SIGNING_KEY,
3568
3394
  nextSigningKey: receiverEnv.QSTASH_NEXT_SIGNING_KEY
3569
3395
  }) : void 0;
@@ -3789,33 +3615,19 @@ var AUTH_FAIL_MESSAGE = `Failed to authenticate Workflow request. If this is une
3789
3615
 
3790
3616
  // src/serve/index.ts
3791
3617
  var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3792
- const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
3793
- const devMode = environment.WORKFLOW_DEV === "true";
3794
- if (devMode) {
3795
- const port = Number(environment.WORKFLOW_DEV_PORT) || 8080;
3796
- const creds = getDevCredentials(port);
3797
- for (const [k, v] of Object.entries(creds)) {
3798
- if (!environment[k]) {
3799
- environment[k] = v;
3800
- }
3801
- }
3802
- }
3803
- const resolvedOptions = processOptions(
3804
- options,
3805
- internalOptions
3806
- );
3618
+ const {
3619
+ initialPayloadParser,
3620
+ url,
3621
+ failureFunction,
3622
+ baseUrl,
3623
+ env,
3624
+ disableTelemetry,
3625
+ middlewares,
3626
+ internal
3627
+ } = processOptions(options, internalOptions);
3628
+ telemetry2 = disableTelemetry ? void 0 : telemetry2;
3629
+ const { generateResponse: responseGenerator, useJSONContent } = internal;
3807
3630
  const handler = async (request, middlewareManager) => {
3808
- const {
3809
- initialPayloadParser,
3810
- url,
3811
- failureFunction,
3812
- baseUrl,
3813
- env,
3814
- disableTelemetry: optDisableTelemetry,
3815
- internal
3816
- } = resolvedOptions;
3817
- const currentTelemetry = optDisableTelemetry ? void 0 : telemetry2;
3818
- const { generateResponse: responseGenerator, useJSONContent } = internal;
3819
3631
  await middlewareManager.dispatchDebug("onInfo", {
3820
3632
  info: `Received request for workflow execution.`
3821
3633
  });
@@ -3895,6 +3707,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3895
3707
  }
3896
3708
  const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
3897
3709
  const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
3710
+ const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
3898
3711
  const workflowContext = new WorkflowContext({
3899
3712
  qstashClient: regionalClient,
3900
3713
  workflowRunId,
@@ -3903,9 +3716,10 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3903
3716
  steps,
3904
3717
  url: workflowUrl,
3905
3718
  env,
3906
- telemetry: currentTelemetry,
3719
+ telemetry: telemetry2,
3907
3720
  invokeCount,
3908
3721
  label,
3722
+ workflowRunCreatedAt: Number(workflowRunCreatedAt),
3909
3723
  middlewareManager
3910
3724
  });
3911
3725
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
@@ -3929,7 +3743,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3929
3743
  requestPayload: rawInitialPayload,
3930
3744
  client: regionalClient,
3931
3745
  workflowUrl,
3932
- telemetry: currentTelemetry,
3746
+ telemetry: telemetry2,
3933
3747
  middlewareManager
3934
3748
  });
3935
3749
  if (callReturnCheck.isErr()) {
@@ -3938,7 +3752,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
3938
3752
  const result = isFirstInvocation ? await triggerFirstInvocation({
3939
3753
  workflowContext,
3940
3754
  useJSONContent,
3941
- telemetry: currentTelemetry,
3755
+ telemetry: telemetry2,
3942
3756
  invokeCount,
3943
3757
  middlewareManager,
3944
3758
  unknownSdk
@@ -4006,9 +3820,7 @@ var serveBase = (routeFunction, telemetry2, options, internalOptions) => {
4006
3820
  );
4007
3821
  };
4008
3822
  const safeHandler = async (request) => {
4009
- const middlewareManager = new MiddlewareManager(
4010
- resolvedOptions.middlewares
4011
- );
3823
+ const middlewareManager = new MiddlewareManager(middlewares);
4012
3824
  try {
4013
3825
  return await handler(request, middlewareManager);
4014
3826
  } catch (error) {
@@ -4033,17 +3845,13 @@ var telemetry = {
4033
3845
  framework: "hono"
4034
3846
  };
4035
3847
  var serve = (routeFunction, options) => {
4036
- const processEnv = typeof process === "undefined" ? {} : process.env;
4037
- if (processEnv.WORKFLOW_DEV === "true") {
4038
- ensureDevServer(processEnv);
4039
- }
4040
3848
  const handler = async (context) => {
4041
3849
  const environment = context.env ? context.env : typeof process === "undefined" ? {} : process.env;
4042
3850
  const request = context.req.raw;
4043
3851
  const { handler: serveHandler } = serveBase(routeFunction, telemetry, {
4044
3852
  // when hono is used without cf workers, it sends a DebugHTTPServer
4045
3853
  // object in `context.env`. don't pass env if this is the case:
4046
- env: "QSTASH_TOKEN" in environment || "WORKFLOW_DEV" in environment ? environment : void 0,
3854
+ env: "QSTASH_TOKEN" in environment ? environment : void 0,
4047
3855
  ...options
4048
3856
  });
4049
3857
  return await serveHandler(request);
package/hono.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  SDK_TELEMETRY,
3
- ensureDevServer,
4
3
  serveBase,
5
4
  serveManyBase
6
- } from "./chunk-NZCQPOPR.mjs";
5
+ } from "./chunk-V5ZUHMAF.mjs";
7
6
 
8
7
  // platforms/hono.ts
9
8
  var telemetry = {
@@ -11,17 +10,13 @@ var telemetry = {
11
10
  framework: "hono"
12
11
  };
13
12
  var serve = (routeFunction, options) => {
14
- const processEnv = typeof process === "undefined" ? {} : process.env;
15
- if (processEnv.WORKFLOW_DEV === "true") {
16
- ensureDevServer(processEnv);
17
- }
18
13
  const handler = async (context) => {
19
14
  const environment = context.env ? context.env : typeof process === "undefined" ? {} : process.env;
20
15
  const request = context.req.raw;
21
16
  const { handler: serveHandler } = serveBase(routeFunction, telemetry, {
22
17
  // when hono is used without cf workers, it sends a DebugHTTPServer
23
18
  // object in `context.env`. don't pass env if this is the case:
24
- env: "QSTASH_TOKEN" in environment || "WORKFLOW_DEV" in environment ? environment : void 0,
19
+ env: "QSTASH_TOKEN" in environment ? environment : void 0,
25
20
  ...options
26
21
  });
27
22
  return await serveHandler(request);