@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.
- package/README.md +1 -0
- package/astro.d.mts +2 -2
- package/astro.d.ts +2 -2
- package/astro.js +41 -21
- package/astro.mjs +1 -1
- package/{chunk-QRCGBBFJ.mjs → chunk-V5ZUHMAF.mjs} +35 -15
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +41 -21
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +41 -21
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +41 -21
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +41 -21
- package/hono.mjs +1 -1
- package/index.d.mts +28 -3
- package/index.d.ts +28 -3
- package/index.js +59 -26
- package/index.mjs +17 -4
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +41 -21
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/react-router.d.mts +2 -2
- package/react-router.d.ts +2 -2
- package/react-router.js +41 -21
- package/react-router.mjs +1 -1
- package/{serve-many-BP-8Ytbc.d.ts → serve-many-B-fe7bh7.d.ts} +1 -1
- package/{serve-many-BsycEL_d.d.mts → serve-many-C6sa_DxN.d.mts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +41 -21
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +41 -21
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +2 -2
- package/tanstack.d.ts +2 -2
- package/tanstack.js +41 -21
- package/tanstack.mjs +1 -1
- package/{types-B90SJYZV.d.ts → types-B2S08hRU.d.mts} +10 -1
- package/{types-B90SJYZV.d.mts → types-B2S08hRU.d.ts} +10 -1
package/express.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.js';
|
|
3
3
|
import { Router } from 'express';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-B-fe7bh7.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/express.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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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/express.mjs
CHANGED
package/h3.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-C6sa_DxN.mjs';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
package/h3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-B-fe7bh7.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
package/h3.js
CHANGED
|
@@ -435,9 +435,10 @@ function isInstanceOf(v, ctor) {
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
// src/client/utils.ts
|
|
438
|
-
var makeNotifyRequest = async (requester, eventId, eventData) => {
|
|
438
|
+
var makeNotifyRequest = async (requester, eventId, eventData, workflowRunId) => {
|
|
439
|
+
const path = workflowRunId ? ["v2", "notify", workflowRunId, eventId] : ["v2", "notify", eventId];
|
|
439
440
|
const result = await requester.request({
|
|
440
|
-
path
|
|
441
|
+
path,
|
|
441
442
|
method: "POST",
|
|
442
443
|
body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
|
|
443
444
|
});
|
|
@@ -1031,6 +1032,7 @@ var triggerFirstInvocation = async (params) => {
|
|
|
1031
1032
|
retries,
|
|
1032
1033
|
retryDelay,
|
|
1033
1034
|
flowControl,
|
|
1035
|
+
redact,
|
|
1034
1036
|
unknownSdk
|
|
1035
1037
|
}) => {
|
|
1036
1038
|
const { headers } = getHeaders({
|
|
@@ -1067,7 +1069,8 @@ var triggerFirstInvocation = async (params) => {
|
|
|
1067
1069
|
body,
|
|
1068
1070
|
url: workflowContext.url,
|
|
1069
1071
|
delay,
|
|
1070
|
-
notBefore
|
|
1072
|
+
notBefore,
|
|
1073
|
+
redact
|
|
1071
1074
|
};
|
|
1072
1075
|
}
|
|
1073
1076
|
);
|
|
@@ -1226,7 +1229,6 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
1226
1229
|
})}`
|
|
1227
1230
|
);
|
|
1228
1231
|
}
|
|
1229
|
-
const userHeaders = recreateUserHeaders(request.headers);
|
|
1230
1232
|
const { headers: requestHeaders } = getHeaders({
|
|
1231
1233
|
initHeaderValue: "false",
|
|
1232
1234
|
workflowConfig: {
|
|
@@ -1234,7 +1236,6 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
1234
1236
|
workflowUrl,
|
|
1235
1237
|
telemetry: telemetry2
|
|
1236
1238
|
},
|
|
1237
|
-
userHeaders,
|
|
1238
1239
|
invokeCount: Number(invokeCount)
|
|
1239
1240
|
});
|
|
1240
1241
|
const callResponse = {
|
|
@@ -1383,7 +1384,6 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
1383
1384
|
useJSONContent: false,
|
|
1384
1385
|
telemetry: telemetry2
|
|
1385
1386
|
},
|
|
1386
|
-
userHeaders: context.headers,
|
|
1387
1387
|
invokeCount,
|
|
1388
1388
|
stepInfo: {
|
|
1389
1389
|
step,
|
|
@@ -1741,9 +1741,9 @@ var LazyWaitEventStep = class extends BaseLazyStep {
|
|
|
1741
1741
|
};
|
|
1742
1742
|
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
1743
1743
|
stepType = "Notify";
|
|
1744
|
-
constructor(context, stepName, eventId, eventData, requester) {
|
|
1744
|
+
constructor(context, stepName, eventId, eventData, requester, workflowRunId) {
|
|
1745
1745
|
super(context, stepName, async () => {
|
|
1746
|
-
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
|
|
1746
|
+
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData, workflowRunId);
|
|
1747
1747
|
return {
|
|
1748
1748
|
eventId,
|
|
1749
1749
|
eventData,
|
|
@@ -1813,7 +1813,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1813
1813
|
telemetry: telemetry2,
|
|
1814
1814
|
useJSONContent: false
|
|
1815
1815
|
},
|
|
1816
|
-
userHeaders: context.headers,
|
|
1817
1816
|
invokeCount
|
|
1818
1817
|
});
|
|
1819
1818
|
context.qstashClient.http.headers?.forEach((value, key) => {
|
|
@@ -1922,12 +1921,14 @@ var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
|
|
|
1922
1921
|
const parsedEventData = BaseLazyStep.tryParsing(eventData);
|
|
1923
1922
|
const body = parsedEventData.body;
|
|
1924
1923
|
const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
|
|
1924
|
+
const methodUpper = parsedEventData.method.toUpperCase();
|
|
1925
|
+
const canHaveBody = methodUpper !== "GET" && methodUpper !== "HEAD";
|
|
1925
1926
|
const request = new Request(
|
|
1926
1927
|
`${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
|
|
1927
1928
|
{
|
|
1928
1929
|
method: parsedEventData.method,
|
|
1929
1930
|
headers: parsedEventData.header,
|
|
1930
|
-
body: parsedBody
|
|
1931
|
+
body: canHaveBody ? parsedBody : void 0
|
|
1931
1932
|
}
|
|
1932
1933
|
);
|
|
1933
1934
|
return {
|
|
@@ -2061,6 +2062,9 @@ var WorkflowHeaders = class {
|
|
|
2061
2062
|
}
|
|
2062
2063
|
}
|
|
2063
2064
|
addUserHeaders() {
|
|
2065
|
+
if (!this.userHeaders) {
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2064
2068
|
for (const [key, value] of this.userHeaders.entries()) {
|
|
2065
2069
|
const forwardKey = `Forward-${key}`;
|
|
2066
2070
|
this.headers.workflowHeaders[forwardKey] = value;
|
|
@@ -2167,7 +2171,6 @@ var submitParallelSteps = async ({
|
|
|
2167
2171
|
workflowUrl: context.url,
|
|
2168
2172
|
telemetry: telemetry2
|
|
2169
2173
|
},
|
|
2170
|
-
userHeaders: context.headers,
|
|
2171
2174
|
invokeCount
|
|
2172
2175
|
});
|
|
2173
2176
|
return {
|
|
@@ -2420,7 +2423,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2420
2423
|
});
|
|
2421
2424
|
throw new WorkflowAbort(parallelStep.stepName, resultStep);
|
|
2422
2425
|
} catch (error) {
|
|
2423
|
-
if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400) {
|
|
2426
|
+
if (isInstanceOf(error, WorkflowAbort) || isInstanceOf(error, import_qstash5.QstashError) && error.status === 400 || isInstanceOf(error, import_qstash5.QstashError) && error.status === 412) {
|
|
2424
2427
|
throw error;
|
|
2425
2428
|
}
|
|
2426
2429
|
throw new WorkflowError(
|
|
@@ -2894,6 +2897,7 @@ var MiddlewareManager = class {
|
|
|
2894
2897
|
};
|
|
2895
2898
|
|
|
2896
2899
|
// src/context/context.ts
|
|
2900
|
+
var import_qstash9 = require("@upstash/qstash");
|
|
2897
2901
|
var WorkflowContext = class {
|
|
2898
2902
|
executor;
|
|
2899
2903
|
steps;
|
|
@@ -3203,14 +3207,23 @@ var WorkflowContext = class {
|
|
|
3203
3207
|
* a notifyResponse field which contains a list of `Waiter` objects, each corresponding
|
|
3204
3208
|
* to a notified workflow run.
|
|
3205
3209
|
*
|
|
3210
|
+
* Optionally, you can pass a workflowRunId to enable lookback functionality:
|
|
3211
|
+
*
|
|
3212
|
+
* ```ts
|
|
3213
|
+
* const { eventId, eventData, notifyResponse } = await context.notify(
|
|
3214
|
+
* "notify step", "event-id", "event-data", "wfr_123"
|
|
3215
|
+
* );
|
|
3216
|
+
* ```
|
|
3217
|
+
*
|
|
3206
3218
|
* @param stepName
|
|
3207
3219
|
* @param eventId event id to notify
|
|
3208
3220
|
* @param eventData event data to notify with
|
|
3221
|
+
* @param workflowRunId optional workflow run id for lookback support
|
|
3209
3222
|
* @returns notify response which has event id, event data and list of waiters which were notified
|
|
3210
3223
|
*/
|
|
3211
|
-
async notify(stepName, eventId, eventData) {
|
|
3224
|
+
async notify(stepName, eventId, eventData, workflowRunId) {
|
|
3212
3225
|
return await this.addStep(
|
|
3213
|
-
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
|
|
3226
|
+
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http, workflowRunId)
|
|
3214
3227
|
);
|
|
3215
3228
|
}
|
|
3216
3229
|
async invoke(stepName, settings) {
|
|
@@ -3238,7 +3251,14 @@ var WorkflowContext = class {
|
|
|
3238
3251
|
* DisabledWorkflowContext.
|
|
3239
3252
|
*/
|
|
3240
3253
|
async addStep(step) {
|
|
3241
|
-
|
|
3254
|
+
try {
|
|
3255
|
+
return await this.executor.addStep(step);
|
|
3256
|
+
} catch (error) {
|
|
3257
|
+
if (isInstanceOf(error, import_qstash9.QstashError) && error.status === 412) {
|
|
3258
|
+
throw new WorkflowNonRetryableError(error.message);
|
|
3259
|
+
}
|
|
3260
|
+
throw error;
|
|
3261
|
+
}
|
|
3242
3262
|
}
|
|
3243
3263
|
get api() {
|
|
3244
3264
|
return new WorkflowApi({
|
|
@@ -3248,7 +3268,7 @@ var WorkflowContext = class {
|
|
|
3248
3268
|
};
|
|
3249
3269
|
|
|
3250
3270
|
// src/serve/authorization.ts
|
|
3251
|
-
var
|
|
3271
|
+
var import_qstash10 = require("@upstash/qstash");
|
|
3252
3272
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
3253
3273
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
3254
3274
|
disabled = true;
|
|
@@ -3280,7 +3300,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
3280
3300
|
*/
|
|
3281
3301
|
static async tryAuthentication(routeFunction, context) {
|
|
3282
3302
|
const disabledContext = new _DisabledWorkflowContext({
|
|
3283
|
-
qstashClient: new
|
|
3303
|
+
qstashClient: new import_qstash10.Client({
|
|
3284
3304
|
baseUrl: "disabled-client",
|
|
3285
3305
|
token: "disabled-client"
|
|
3286
3306
|
}),
|
|
@@ -3547,7 +3567,7 @@ var handleFailure = async ({
|
|
|
3547
3567
|
};
|
|
3548
3568
|
|
|
3549
3569
|
// src/serve/multi-region/handlers.ts
|
|
3550
|
-
var
|
|
3570
|
+
var import_qstash11 = require("@upstash/qstash");
|
|
3551
3571
|
|
|
3552
3572
|
// src/serve/multi-region/utils.ts
|
|
3553
3573
|
var VALID_REGIONS = ["EU_CENTRAL_1", "US_EAST_1"];
|
|
@@ -3612,7 +3632,7 @@ var getHandlersForRequest = (qstashHandlers, regionHeader, isFirstInvocation) =>
|
|
|
3612
3632
|
};
|
|
3613
3633
|
var createRegionalHandler = (environment, receiverConfig, region, clientOptions) => {
|
|
3614
3634
|
const clientEnv = readClientEnvironmentVariables(environment, region);
|
|
3615
|
-
const client = new
|
|
3635
|
+
const client = new import_qstash11.Client({
|
|
3616
3636
|
...clientOptions,
|
|
3617
3637
|
baseUrl: clientEnv.QSTASH_URL,
|
|
3618
3638
|
token: clientEnv.QSTASH_TOKEN
|
|
@@ -3662,7 +3682,7 @@ var getQStashHandlers = ({
|
|
|
3662
3682
|
return {
|
|
3663
3683
|
mode: "single-region",
|
|
3664
3684
|
handlers: {
|
|
3665
|
-
client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new
|
|
3685
|
+
client: qstashClientOption && "http" in qstashClientOption ? qstashClientOption : new import_qstash11.Client({
|
|
3666
3686
|
...qstashClientOption,
|
|
3667
3687
|
baseUrl: environment.QSTASH_URL,
|
|
3668
3688
|
token: environment.QSTASH_TOKEN
|
|
@@ -3678,7 +3698,7 @@ var getReceiver = (environment, receiverConfig, region) => {
|
|
|
3678
3698
|
return void 0;
|
|
3679
3699
|
}
|
|
3680
3700
|
const receiverEnv = readReceiverEnvironmentVariables(environment, region);
|
|
3681
|
-
return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new
|
|
3701
|
+
return receiverEnv.QSTASH_CURRENT_SIGNING_KEY && receiverEnv.QSTASH_NEXT_SIGNING_KEY ? new import_qstash11.Receiver({
|
|
3682
3702
|
currentSigningKey: receiverEnv.QSTASH_CURRENT_SIGNING_KEY,
|
|
3683
3703
|
nextSigningKey: receiverEnv.QSTASH_NEXT_SIGNING_KEY
|
|
3684
3704
|
}) : void 0;
|
package/h3.mjs
CHANGED
package/hono.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.mjs';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-C6sa_DxN.mjs';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/hono.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-B2S08hRU.js';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-B-fe7bh7.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|