@upstash/workflow 0.2.13 → 0.2.15
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/astro.d.mts +2 -2
- package/astro.d.ts +2 -2
- package/astro.js +92 -57
- package/astro.mjs +1 -1
- package/{chunk-XVNSBBDC.mjs → chunk-AC5CQCN3.mjs} +94 -57
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +92 -57
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +92 -57
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +92 -57
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +92 -57
- package/hono.mjs +1 -1
- package/index.d.mts +270 -42
- package/index.d.ts +270 -42
- package/index.js +206 -119
- package/index.mjs +117 -63
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +92 -57
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-BF71QZHQ.d.mts → serve-many-AFwJPR3S.d.mts} +1 -1
- package/{serve-many-BMlN2PAB.d.ts → serve-many-AaKSQyi7.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +92 -57
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +92 -57
- package/svelte.mjs +1 -1
- package/{types-C1WIgVLA.d.ts → types-Dd-3bPoU.d.mts} +39 -4
- package/{types-C1WIgVLA.d.mts → types-Dd-3bPoU.d.ts} +39 -4
package/cloudflare.js
CHANGED
|
@@ -38,7 +38,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
38
38
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
39
39
|
var NO_CONCURRENCY = 1;
|
|
40
40
|
var DEFAULT_RETRIES = 3;
|
|
41
|
-
var VERSION = "v0.2.
|
|
41
|
+
var VERSION = "v0.2.15";
|
|
42
42
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
43
43
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
44
44
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -129,6 +129,16 @@ var WorkflowAbort = class extends Error {
|
|
|
129
129
|
this.cancelWorkflow = cancelWorkflow;
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
+
var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
133
|
+
/**
|
|
134
|
+
* @param message error message to be displayed
|
|
135
|
+
*/
|
|
136
|
+
constructor(message) {
|
|
137
|
+
super("fail", void 0, false);
|
|
138
|
+
this.name = "WorkflowNonRetryableError";
|
|
139
|
+
if (message) this.message = message;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
132
142
|
var formatWorkflowError = (error) => {
|
|
133
143
|
return error instanceof Error ? {
|
|
134
144
|
error: error.name,
|
|
@@ -599,59 +609,72 @@ var StepTypes = [
|
|
|
599
609
|
|
|
600
610
|
// src/workflow-requests.ts
|
|
601
611
|
var import_qstash3 = require("@upstash/qstash");
|
|
602
|
-
var triggerFirstInvocation = async ({
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
try {
|
|
631
|
-
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
632
|
-
const result = await workflowContext.qstashClient.publish({
|
|
633
|
-
headers,
|
|
634
|
-
method: "POST",
|
|
635
|
-
body,
|
|
636
|
-
url: workflowContext.url,
|
|
637
|
-
delay
|
|
638
|
-
});
|
|
639
|
-
if (result.deduplicated) {
|
|
640
|
-
await debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
641
|
-
message: `Workflow run ${workflowContext.workflowRunId} already exists. A new one isn't created.`,
|
|
612
|
+
var triggerFirstInvocation = async (params) => {
|
|
613
|
+
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
614
|
+
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
615
|
+
const invocationBatch = firstInvocationParams.map(
|
|
616
|
+
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
|
|
617
|
+
const { headers } = getHeaders({
|
|
618
|
+
initHeaderValue: "true",
|
|
619
|
+
workflowConfig: {
|
|
620
|
+
workflowRunId: workflowContext.workflowRunId,
|
|
621
|
+
workflowUrl: workflowContext.url,
|
|
622
|
+
failureUrl: workflowContext.failureUrl,
|
|
623
|
+
retries: workflowContext.retries,
|
|
624
|
+
telemetry: telemetry2,
|
|
625
|
+
flowControl: workflowContext.flowControl,
|
|
626
|
+
useJSONContent: useJSONContent ?? false
|
|
627
|
+
},
|
|
628
|
+
invokeCount: invokeCount ?? 0,
|
|
629
|
+
userHeaders: workflowContext.headers
|
|
630
|
+
});
|
|
631
|
+
if (workflowContext.headers.get("content-type")) {
|
|
632
|
+
headers["content-type"] = workflowContext.headers.get("content-type");
|
|
633
|
+
}
|
|
634
|
+
if (useJSONContent) {
|
|
635
|
+
headers["content-type"] = "application/json";
|
|
636
|
+
}
|
|
637
|
+
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
638
|
+
return {
|
|
642
639
|
headers,
|
|
643
|
-
|
|
640
|
+
method: "POST",
|
|
641
|
+
body,
|
|
644
642
|
url: workflowContext.url,
|
|
645
|
-
|
|
646
|
-
}
|
|
643
|
+
delay
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
);
|
|
647
|
+
try {
|
|
648
|
+
const results = await workflowContextClient.batch(invocationBatch);
|
|
649
|
+
const invocationStatuses = [];
|
|
650
|
+
for (let i = 0; i < results.length; i++) {
|
|
651
|
+
const result = results[i];
|
|
652
|
+
const invocationParams = firstInvocationParams[i];
|
|
653
|
+
if (result.deduplicated) {
|
|
654
|
+
await invocationParams.debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
655
|
+
message: `Workflow run ${invocationParams.workflowContext.workflowRunId} already exists. A new one isn't created.`,
|
|
656
|
+
headers: invocationBatch[i].headers,
|
|
657
|
+
requestPayload: invocationParams.workflowContext.requestPayload,
|
|
658
|
+
url: invocationParams.workflowContext.url,
|
|
659
|
+
messageId: result.messageId
|
|
660
|
+
});
|
|
661
|
+
invocationStatuses.push("workflow-run-already-exists");
|
|
662
|
+
} else {
|
|
663
|
+
await invocationParams.debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
664
|
+
headers: invocationBatch[i].headers,
|
|
665
|
+
requestPayload: invocationParams.workflowContext.requestPayload,
|
|
666
|
+
url: invocationParams.workflowContext.url,
|
|
667
|
+
messageId: result.messageId
|
|
668
|
+
});
|
|
669
|
+
invocationStatuses.push("success");
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
const hasAnyDeduplicated = invocationStatuses.some(
|
|
673
|
+
(status) => status === "workflow-run-already-exists"
|
|
674
|
+
);
|
|
675
|
+
if (hasAnyDeduplicated) {
|
|
647
676
|
return ok("workflow-run-already-exists");
|
|
648
677
|
} else {
|
|
649
|
-
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
650
|
-
headers,
|
|
651
|
-
requestPayload: workflowContext.requestPayload,
|
|
652
|
-
url: workflowContext.url,
|
|
653
|
-
messageId: result.messageId
|
|
654
|
-
});
|
|
655
678
|
return ok("success");
|
|
656
679
|
}
|
|
657
680
|
} catch (error) {
|
|
@@ -680,6 +703,8 @@ var triggerRouteFunction = async ({
|
|
|
680
703
|
return ok("workflow-was-finished");
|
|
681
704
|
} else if (!(error_ instanceof WorkflowAbort)) {
|
|
682
705
|
return err(error_);
|
|
706
|
+
} else if (error_ instanceof WorkflowNonRetryableError) {
|
|
707
|
+
return ok(error_);
|
|
683
708
|
} else if (error_.cancelWorkflow) {
|
|
684
709
|
await onCancel();
|
|
685
710
|
return ok("workflow-finished");
|
|
@@ -841,7 +866,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
841
866
|
var getTelemetryHeaders = (telemetry2) => {
|
|
842
867
|
return {
|
|
843
868
|
[TELEMETRY_HEADER_SDK]: telemetry2.sdk,
|
|
844
|
-
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework,
|
|
869
|
+
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework ?? "unknown",
|
|
845
870
|
[TELEMETRY_HEADER_RUNTIME]: telemetry2.runtime ?? "unknown"
|
|
846
871
|
};
|
|
847
872
|
};
|
|
@@ -1141,7 +1166,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1141
1166
|
return { header, status, body };
|
|
1142
1167
|
}
|
|
1143
1168
|
}
|
|
1144
|
-
static
|
|
1169
|
+
static applicationContentTypes = [
|
|
1145
1170
|
"application/json",
|
|
1146
1171
|
"application/xml",
|
|
1147
1172
|
"application/javascript",
|
|
@@ -1150,12 +1175,12 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1150
1175
|
"application/ld+json",
|
|
1151
1176
|
"application/rss+xml",
|
|
1152
1177
|
"application/atom+xml"
|
|
1153
|
-
]
|
|
1178
|
+
];
|
|
1154
1179
|
static isText = (contentTypeHeader) => {
|
|
1155
1180
|
if (!contentTypeHeader) {
|
|
1156
1181
|
return false;
|
|
1157
1182
|
}
|
|
1158
|
-
if (_LazyCallStep.
|
|
1183
|
+
if (_LazyCallStep.applicationContentTypes.some((type) => contentTypeHeader.includes(type))) {
|
|
1159
1184
|
return true;
|
|
1160
1185
|
}
|
|
1161
1186
|
if (contentTypeHeader.startsWith("text/")) {
|
|
@@ -2953,10 +2978,10 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2953
2978
|
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2954
2979
|
}
|
|
2955
2980
|
/**
|
|
2956
|
-
* overwrite cancel method to
|
|
2981
|
+
* overwrite cancel method to throw WorkflowAbort with the disabledMessage
|
|
2957
2982
|
*/
|
|
2958
2983
|
async cancel() {
|
|
2959
|
-
|
|
2984
|
+
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2960
2985
|
}
|
|
2961
2986
|
/**
|
|
2962
2987
|
* copies the passed context to create a DisabledWorkflowContext. Then, runs the
|
|
@@ -2988,7 +3013,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2988
3013
|
try {
|
|
2989
3014
|
await routeFunction(disabledContext);
|
|
2990
3015
|
} catch (error) {
|
|
2991
|
-
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage) {
|
|
3016
|
+
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage || error instanceof WorkflowNonRetryableError) {
|
|
2992
3017
|
return ok("step-found");
|
|
2993
3018
|
}
|
|
2994
3019
|
return err(error);
|
|
@@ -3209,6 +3234,13 @@ var processOptions = (options) => {
|
|
|
3209
3234
|
status: 400
|
|
3210
3235
|
}
|
|
3211
3236
|
);
|
|
3237
|
+
} else if (finishCondition instanceof WorkflowNonRetryableError) {
|
|
3238
|
+
return new Response(JSON.stringify(formatWorkflowError(finishCondition)), {
|
|
3239
|
+
headers: {
|
|
3240
|
+
"Upstash-NonRetryable-Error": "true"
|
|
3241
|
+
},
|
|
3242
|
+
status: 489
|
|
3243
|
+
});
|
|
3212
3244
|
}
|
|
3213
3245
|
return new Response(JSON.stringify({ workflowRunId }), {
|
|
3214
3246
|
status: 200
|
|
@@ -3401,6 +3433,9 @@ var serveBase = (routeFunction, telemetry2, options) => {
|
|
|
3401
3433
|
},
|
|
3402
3434
|
debug
|
|
3403
3435
|
});
|
|
3436
|
+
if (result.isOk() && result.value instanceof WorkflowNonRetryableError) {
|
|
3437
|
+
return onStepFinish(workflowRunId, result.value);
|
|
3438
|
+
}
|
|
3404
3439
|
if (result.isErr()) {
|
|
3405
3440
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
3406
3441
|
throw result.error;
|
package/cloudflare.mjs
CHANGED
package/express.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions,
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.mjs';
|
|
3
3
|
import { Router } from 'express';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-AFwJPR3S.mjs';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'ai';
|
package/express.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions,
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.js';
|
|
3
3
|
import { Router } from 'express';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-AaKSQyi7.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'ai';
|
package/express.js
CHANGED
|
@@ -23710,7 +23710,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
23710
23710
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
23711
23711
|
var NO_CONCURRENCY = 1;
|
|
23712
23712
|
var DEFAULT_RETRIES = 3;
|
|
23713
|
-
var VERSION = "v0.2.
|
|
23713
|
+
var VERSION = "v0.2.15";
|
|
23714
23714
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
23715
23715
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
23716
23716
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -23801,6 +23801,16 @@ var WorkflowAbort = class extends Error {
|
|
|
23801
23801
|
this.cancelWorkflow = cancelWorkflow;
|
|
23802
23802
|
}
|
|
23803
23803
|
};
|
|
23804
|
+
var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
23805
|
+
/**
|
|
23806
|
+
* @param message error message to be displayed
|
|
23807
|
+
*/
|
|
23808
|
+
constructor(message) {
|
|
23809
|
+
super("fail", void 0, false);
|
|
23810
|
+
this.name = "WorkflowNonRetryableError";
|
|
23811
|
+
if (message) this.message = message;
|
|
23812
|
+
}
|
|
23813
|
+
};
|
|
23804
23814
|
var formatWorkflowError = (error) => {
|
|
23805
23815
|
return error instanceof Error ? {
|
|
23806
23816
|
error: error.name,
|
|
@@ -24271,59 +24281,72 @@ var StepTypes = [
|
|
|
24271
24281
|
|
|
24272
24282
|
// src/workflow-requests.ts
|
|
24273
24283
|
var import_qstash3 = require("@upstash/qstash");
|
|
24274
|
-
var triggerFirstInvocation = async ({
|
|
24275
|
-
|
|
24276
|
-
|
|
24277
|
-
|
|
24278
|
-
|
|
24279
|
-
|
|
24280
|
-
|
|
24281
|
-
|
|
24282
|
-
|
|
24283
|
-
|
|
24284
|
-
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
|
|
24297
|
-
|
|
24298
|
-
|
|
24299
|
-
|
|
24300
|
-
|
|
24301
|
-
}
|
|
24302
|
-
try {
|
|
24303
|
-
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
24304
|
-
const result = await workflowContext.qstashClient.publish({
|
|
24305
|
-
headers,
|
|
24306
|
-
method: "POST",
|
|
24307
|
-
body,
|
|
24308
|
-
url: workflowContext.url,
|
|
24309
|
-
delay
|
|
24310
|
-
});
|
|
24311
|
-
if (result.deduplicated) {
|
|
24312
|
-
await debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
24313
|
-
message: `Workflow run ${workflowContext.workflowRunId} already exists. A new one isn't created.`,
|
|
24284
|
+
var triggerFirstInvocation = async (params) => {
|
|
24285
|
+
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
24286
|
+
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
24287
|
+
const invocationBatch = firstInvocationParams.map(
|
|
24288
|
+
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
|
|
24289
|
+
const { headers } = getHeaders({
|
|
24290
|
+
initHeaderValue: "true",
|
|
24291
|
+
workflowConfig: {
|
|
24292
|
+
workflowRunId: workflowContext.workflowRunId,
|
|
24293
|
+
workflowUrl: workflowContext.url,
|
|
24294
|
+
failureUrl: workflowContext.failureUrl,
|
|
24295
|
+
retries: workflowContext.retries,
|
|
24296
|
+
telemetry: telemetry2,
|
|
24297
|
+
flowControl: workflowContext.flowControl,
|
|
24298
|
+
useJSONContent: useJSONContent ?? false
|
|
24299
|
+
},
|
|
24300
|
+
invokeCount: invokeCount ?? 0,
|
|
24301
|
+
userHeaders: workflowContext.headers
|
|
24302
|
+
});
|
|
24303
|
+
if (workflowContext.headers.get("content-type")) {
|
|
24304
|
+
headers["content-type"] = workflowContext.headers.get("content-type");
|
|
24305
|
+
}
|
|
24306
|
+
if (useJSONContent) {
|
|
24307
|
+
headers["content-type"] = "application/json";
|
|
24308
|
+
}
|
|
24309
|
+
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
24310
|
+
return {
|
|
24314
24311
|
headers,
|
|
24315
|
-
|
|
24312
|
+
method: "POST",
|
|
24313
|
+
body,
|
|
24316
24314
|
url: workflowContext.url,
|
|
24317
|
-
|
|
24318
|
-
}
|
|
24315
|
+
delay
|
|
24316
|
+
};
|
|
24317
|
+
}
|
|
24318
|
+
);
|
|
24319
|
+
try {
|
|
24320
|
+
const results = await workflowContextClient.batch(invocationBatch);
|
|
24321
|
+
const invocationStatuses = [];
|
|
24322
|
+
for (let i = 0; i < results.length; i++) {
|
|
24323
|
+
const result = results[i];
|
|
24324
|
+
const invocationParams = firstInvocationParams[i];
|
|
24325
|
+
if (result.deduplicated) {
|
|
24326
|
+
await invocationParams.debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
24327
|
+
message: `Workflow run ${invocationParams.workflowContext.workflowRunId} already exists. A new one isn't created.`,
|
|
24328
|
+
headers: invocationBatch[i].headers,
|
|
24329
|
+
requestPayload: invocationParams.workflowContext.requestPayload,
|
|
24330
|
+
url: invocationParams.workflowContext.url,
|
|
24331
|
+
messageId: result.messageId
|
|
24332
|
+
});
|
|
24333
|
+
invocationStatuses.push("workflow-run-already-exists");
|
|
24334
|
+
} else {
|
|
24335
|
+
await invocationParams.debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
24336
|
+
headers: invocationBatch[i].headers,
|
|
24337
|
+
requestPayload: invocationParams.workflowContext.requestPayload,
|
|
24338
|
+
url: invocationParams.workflowContext.url,
|
|
24339
|
+
messageId: result.messageId
|
|
24340
|
+
});
|
|
24341
|
+
invocationStatuses.push("success");
|
|
24342
|
+
}
|
|
24343
|
+
}
|
|
24344
|
+
const hasAnyDeduplicated = invocationStatuses.some(
|
|
24345
|
+
(status) => status === "workflow-run-already-exists"
|
|
24346
|
+
);
|
|
24347
|
+
if (hasAnyDeduplicated) {
|
|
24319
24348
|
return ok("workflow-run-already-exists");
|
|
24320
24349
|
} else {
|
|
24321
|
-
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
24322
|
-
headers,
|
|
24323
|
-
requestPayload: workflowContext.requestPayload,
|
|
24324
|
-
url: workflowContext.url,
|
|
24325
|
-
messageId: result.messageId
|
|
24326
|
-
});
|
|
24327
24350
|
return ok("success");
|
|
24328
24351
|
}
|
|
24329
24352
|
} catch (error) {
|
|
@@ -24352,6 +24375,8 @@ var triggerRouteFunction = async ({
|
|
|
24352
24375
|
return ok("workflow-was-finished");
|
|
24353
24376
|
} else if (!(error_ instanceof WorkflowAbort)) {
|
|
24354
24377
|
return err(error_);
|
|
24378
|
+
} else if (error_ instanceof WorkflowNonRetryableError) {
|
|
24379
|
+
return ok(error_);
|
|
24355
24380
|
} else if (error_.cancelWorkflow) {
|
|
24356
24381
|
await onCancel();
|
|
24357
24382
|
return ok("workflow-finished");
|
|
@@ -24513,7 +24538,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
24513
24538
|
var getTelemetryHeaders = (telemetry2) => {
|
|
24514
24539
|
return {
|
|
24515
24540
|
[TELEMETRY_HEADER_SDK]: telemetry2.sdk,
|
|
24516
|
-
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework,
|
|
24541
|
+
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework ?? "unknown",
|
|
24517
24542
|
[TELEMETRY_HEADER_RUNTIME]: telemetry2.runtime ?? "unknown"
|
|
24518
24543
|
};
|
|
24519
24544
|
};
|
|
@@ -24813,7 +24838,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24813
24838
|
return { header, status, body };
|
|
24814
24839
|
}
|
|
24815
24840
|
}
|
|
24816
|
-
static
|
|
24841
|
+
static applicationContentTypes = [
|
|
24817
24842
|
"application/json",
|
|
24818
24843
|
"application/xml",
|
|
24819
24844
|
"application/javascript",
|
|
@@ -24822,12 +24847,12 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24822
24847
|
"application/ld+json",
|
|
24823
24848
|
"application/rss+xml",
|
|
24824
24849
|
"application/atom+xml"
|
|
24825
|
-
]
|
|
24850
|
+
];
|
|
24826
24851
|
static isText = (contentTypeHeader) => {
|
|
24827
24852
|
if (!contentTypeHeader) {
|
|
24828
24853
|
return false;
|
|
24829
24854
|
}
|
|
24830
|
-
if (_LazyCallStep.
|
|
24855
|
+
if (_LazyCallStep.applicationContentTypes.some((type) => contentTypeHeader.includes(type))) {
|
|
24831
24856
|
return true;
|
|
24832
24857
|
}
|
|
24833
24858
|
if (contentTypeHeader.startsWith("text/")) {
|
|
@@ -26625,10 +26650,10 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
26625
26650
|
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
26626
26651
|
}
|
|
26627
26652
|
/**
|
|
26628
|
-
* overwrite cancel method to
|
|
26653
|
+
* overwrite cancel method to throw WorkflowAbort with the disabledMessage
|
|
26629
26654
|
*/
|
|
26630
26655
|
async cancel() {
|
|
26631
|
-
|
|
26656
|
+
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
26632
26657
|
}
|
|
26633
26658
|
/**
|
|
26634
26659
|
* copies the passed context to create a DisabledWorkflowContext. Then, runs the
|
|
@@ -26660,7 +26685,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
26660
26685
|
try {
|
|
26661
26686
|
await routeFunction(disabledContext);
|
|
26662
26687
|
} catch (error) {
|
|
26663
|
-
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage) {
|
|
26688
|
+
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage || error instanceof WorkflowNonRetryableError) {
|
|
26664
26689
|
return ok("step-found");
|
|
26665
26690
|
}
|
|
26666
26691
|
return err(error);
|
|
@@ -26881,6 +26906,13 @@ var processOptions = (options) => {
|
|
|
26881
26906
|
status: 400
|
|
26882
26907
|
}
|
|
26883
26908
|
);
|
|
26909
|
+
} else if (finishCondition instanceof WorkflowNonRetryableError) {
|
|
26910
|
+
return new Response(JSON.stringify(formatWorkflowError(finishCondition)), {
|
|
26911
|
+
headers: {
|
|
26912
|
+
"Upstash-NonRetryable-Error": "true"
|
|
26913
|
+
},
|
|
26914
|
+
status: 489
|
|
26915
|
+
});
|
|
26884
26916
|
}
|
|
26885
26917
|
return new Response(JSON.stringify({ workflowRunId }), {
|
|
26886
26918
|
status: 200
|
|
@@ -27073,6 +27105,9 @@ var serveBase = (routeFunction, telemetry2, options) => {
|
|
|
27073
27105
|
},
|
|
27074
27106
|
debug
|
|
27075
27107
|
});
|
|
27108
|
+
if (result.isOk() && result.value instanceof WorkflowNonRetryableError) {
|
|
27109
|
+
return onStepFinish(workflowRunId, result.value);
|
|
27110
|
+
}
|
|
27076
27111
|
if (result.isErr()) {
|
|
27077
27112
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
27078
27113
|
throw result.error;
|
package/express.mjs
CHANGED
package/h3.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { R as RouteFunction,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-AFwJPR3S.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,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-AaKSQyi7.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|