@upstash/workflow 0.2.18 → 0.2.20
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 +52 -14
- package/astro.mjs +1 -1
- package/{chunk-EHL7SSJF.mjs → chunk-LZGX3WMF.mjs} +52 -14
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +52 -14
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +52 -14
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +52 -14
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +52 -14
- package/hono.mjs +1 -1
- package/index.d.mts +12 -2
- package/index.d.ts +12 -2
- package/index.js +54 -15
- package/index.mjs +3 -2
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +52 -14
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-CEUYWQvV.d.mts → serve-many-BNusWYgt.d.mts} +1 -1
- package/{serve-many-BObe3pdI.d.ts → serve-many-CXqQP3RI.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +52 -14
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +52 -14
- package/svelte.mjs +1 -1
- package/{types-B7_5AkKQ.d.ts → types-Q3dM0UlR.d.mts} +21 -2
- package/{types-B7_5AkKQ.d.mts → types-Q3dM0UlR.d.ts} +21 -2
package/express.js
CHANGED
|
@@ -23485,7 +23485,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
23485
23485
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
23486
23486
|
var NO_CONCURRENCY = 1;
|
|
23487
23487
|
var DEFAULT_RETRIES = 3;
|
|
23488
|
-
var VERSION = "v0.2.
|
|
23488
|
+
var VERSION = "v0.2.20";
|
|
23489
23489
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
23490
23490
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
23491
23491
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -23589,7 +23589,8 @@ var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
|
23589
23589
|
var formatWorkflowError = (error) => {
|
|
23590
23590
|
return error instanceof Error ? {
|
|
23591
23591
|
error: error.name,
|
|
23592
|
-
message: error.message
|
|
23592
|
+
message: error.message,
|
|
23593
|
+
stack: error.stack
|
|
23593
23594
|
} : {
|
|
23594
23595
|
error: "Error",
|
|
23595
23596
|
message: `An error occured while executing workflow: '${typeof error === "string" ? error : JSON.stringify(error)}'`
|
|
@@ -24060,7 +24061,7 @@ var triggerFirstInvocation = async (params) => {
|
|
|
24060
24061
|
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
24061
24062
|
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
24062
24063
|
const invocationBatch = firstInvocationParams.map(
|
|
24063
|
-
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
|
|
24064
|
+
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
|
|
24064
24065
|
const { headers } = getHeaders({
|
|
24065
24066
|
initHeaderValue: "true",
|
|
24066
24067
|
workflowConfig: {
|
|
@@ -24091,7 +24092,8 @@ var triggerFirstInvocation = async (params) => {
|
|
|
24091
24092
|
method: "POST",
|
|
24092
24093
|
body,
|
|
24093
24094
|
url: workflowContext.url,
|
|
24094
|
-
delay
|
|
24095
|
+
delay,
|
|
24096
|
+
notBefore
|
|
24095
24097
|
};
|
|
24096
24098
|
}
|
|
24097
24099
|
);
|
|
@@ -24579,9 +24581,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24579
24581
|
retryDelay;
|
|
24580
24582
|
timeout;
|
|
24581
24583
|
flowControl;
|
|
24584
|
+
stringifyBody;
|
|
24582
24585
|
stepType = "Call";
|
|
24583
24586
|
allowUndefinedOut = false;
|
|
24584
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
24587
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
24585
24588
|
super(stepName);
|
|
24586
24589
|
this.url = url;
|
|
24587
24590
|
this.method = method;
|
|
@@ -24591,6 +24594,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24591
24594
|
this.retryDelay = retryDelay;
|
|
24592
24595
|
this.timeout = timeout;
|
|
24593
24596
|
this.flowControl = flowControl;
|
|
24597
|
+
this.stringifyBody = stringifyBody;
|
|
24594
24598
|
}
|
|
24595
24599
|
getPlanStep(concurrent, targetStep) {
|
|
24596
24600
|
return {
|
|
@@ -24700,10 +24704,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24700
24704
|
};
|
|
24701
24705
|
}
|
|
24702
24706
|
async submitStep({ context, headers }) {
|
|
24707
|
+
let callBody;
|
|
24708
|
+
if (this.stringifyBody) {
|
|
24709
|
+
callBody = JSON.stringify(this.body);
|
|
24710
|
+
} else {
|
|
24711
|
+
if (typeof this.body === "string") {
|
|
24712
|
+
callBody = this.body;
|
|
24713
|
+
} else {
|
|
24714
|
+
throw new WorkflowError(
|
|
24715
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your call step."
|
|
24716
|
+
);
|
|
24717
|
+
}
|
|
24718
|
+
}
|
|
24703
24719
|
return await context.qstashClient.batch([
|
|
24704
24720
|
{
|
|
24705
24721
|
headers,
|
|
24706
|
-
body:
|
|
24722
|
+
body: callBody,
|
|
24707
24723
|
method: this.method,
|
|
24708
24724
|
url: this.url,
|
|
24709
24725
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -24838,7 +24854,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24838
24854
|
workflowRunId,
|
|
24839
24855
|
retries,
|
|
24840
24856
|
retryDelay,
|
|
24841
|
-
flowControl
|
|
24857
|
+
flowControl,
|
|
24858
|
+
stringifyBody = true
|
|
24842
24859
|
}) {
|
|
24843
24860
|
super(stepName);
|
|
24844
24861
|
this.params = {
|
|
@@ -24848,7 +24865,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24848
24865
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
24849
24866
|
retries,
|
|
24850
24867
|
retryDelay,
|
|
24851
|
-
flowControl
|
|
24868
|
+
flowControl,
|
|
24869
|
+
stringifyBody
|
|
24852
24870
|
};
|
|
24853
24871
|
const { workflowId } = workflow;
|
|
24854
24872
|
if (!workflowId) {
|
|
@@ -24901,8 +24919,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24901
24919
|
invokeCount
|
|
24902
24920
|
});
|
|
24903
24921
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
24922
|
+
let invokeBody;
|
|
24923
|
+
if (this.params.stringifyBody) {
|
|
24924
|
+
invokeBody = JSON.stringify(this.params.body);
|
|
24925
|
+
} else {
|
|
24926
|
+
if (typeof this.params.body === "string") {
|
|
24927
|
+
invokeBody = this.params.body;
|
|
24928
|
+
} else {
|
|
24929
|
+
throw new WorkflowError(
|
|
24930
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your invoke step."
|
|
24931
|
+
);
|
|
24932
|
+
}
|
|
24933
|
+
}
|
|
24904
24934
|
const request = {
|
|
24905
|
-
body:
|
|
24935
|
+
body: invokeBody,
|
|
24906
24936
|
headers: Object.fromEntries(
|
|
24907
24937
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
24908
24938
|
),
|
|
@@ -26346,7 +26376,8 @@ var WorkflowContext = class {
|
|
|
26346
26376
|
settings.retries || 0,
|
|
26347
26377
|
settings.retryDelay,
|
|
26348
26378
|
settings.timeout,
|
|
26349
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
26379
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
26380
|
+
settings.stringifyBody ?? true
|
|
26350
26381
|
);
|
|
26351
26382
|
} else {
|
|
26352
26383
|
const {
|
|
@@ -26357,7 +26388,8 @@ var WorkflowContext = class {
|
|
|
26357
26388
|
retries = 0,
|
|
26358
26389
|
retryDelay,
|
|
26359
26390
|
timeout,
|
|
26360
|
-
flowControl
|
|
26391
|
+
flowControl,
|
|
26392
|
+
stringifyBody = true
|
|
26361
26393
|
} = settings;
|
|
26362
26394
|
callStep = new LazyCallStep(
|
|
26363
26395
|
stepName,
|
|
@@ -26368,7 +26400,8 @@ var WorkflowContext = class {
|
|
|
26368
26400
|
retries,
|
|
26369
26401
|
retryDelay,
|
|
26370
26402
|
timeout,
|
|
26371
|
-
flowControl
|
|
26403
|
+
flowControl,
|
|
26404
|
+
stringifyBody
|
|
26372
26405
|
);
|
|
26373
26406
|
}
|
|
26374
26407
|
return await this.addStep(callStep);
|
|
@@ -26732,11 +26765,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
26732
26765
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
26733
26766
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
26734
26767
|
let errorMessage = "";
|
|
26768
|
+
let failStack = "";
|
|
26735
26769
|
try {
|
|
26736
26770
|
const errorPayload = JSON.parse(decodedBody);
|
|
26737
26771
|
if (errorPayload.message) {
|
|
26738
26772
|
errorMessage = errorPayload.message;
|
|
26739
26773
|
}
|
|
26774
|
+
if (errorPayload.stack) {
|
|
26775
|
+
failStack = errorPayload.stack;
|
|
26776
|
+
}
|
|
26740
26777
|
} catch {
|
|
26741
26778
|
}
|
|
26742
26779
|
if (!errorMessage) {
|
|
@@ -26774,7 +26811,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
26774
26811
|
context: workflowContext,
|
|
26775
26812
|
failStatus: status,
|
|
26776
26813
|
failResponse: errorMessage,
|
|
26777
|
-
failHeaders: header
|
|
26814
|
+
failHeaders: header,
|
|
26815
|
+
failStack
|
|
26778
26816
|
});
|
|
26779
26817
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
26780
26818
|
} catch (error) {
|
|
@@ -26791,7 +26829,7 @@ var processOptions = (options) => {
|
|
|
26791
26829
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
26792
26830
|
);
|
|
26793
26831
|
return {
|
|
26794
|
-
qstashClient: new import_qstash11.Client({
|
|
26832
|
+
qstashClient: options?.qstashClient ?? new import_qstash11.Client({
|
|
26795
26833
|
baseUrl: environment.QSTASH_URL,
|
|
26796
26834
|
token: environment.QSTASH_TOKEN
|
|
26797
26835
|
}),
|
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, n as PublicServeOptions,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-Q3dM0UlR.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-BNusWYgt.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,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-Q3dM0UlR.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-CXqQP3RI.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|
package/h3.js
CHANGED
|
@@ -404,7 +404,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
404
404
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
405
405
|
var NO_CONCURRENCY = 1;
|
|
406
406
|
var DEFAULT_RETRIES = 3;
|
|
407
|
-
var VERSION = "v0.2.
|
|
407
|
+
var VERSION = "v0.2.20";
|
|
408
408
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
409
409
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
410
410
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -455,7 +455,8 @@ var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
|
455
455
|
var formatWorkflowError = (error) => {
|
|
456
456
|
return error instanceof Error ? {
|
|
457
457
|
error: error.name,
|
|
458
|
-
message: error.message
|
|
458
|
+
message: error.message,
|
|
459
|
+
stack: error.stack
|
|
459
460
|
} : {
|
|
460
461
|
error: "Error",
|
|
461
462
|
message: `An error occured while executing workflow: '${typeof error === "string" ? error : JSON.stringify(error)}'`
|
|
@@ -926,7 +927,7 @@ var triggerFirstInvocation = async (params) => {
|
|
|
926
927
|
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
927
928
|
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
928
929
|
const invocationBatch = firstInvocationParams.map(
|
|
929
|
-
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
|
|
930
|
+
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
|
|
930
931
|
const { headers } = getHeaders({
|
|
931
932
|
initHeaderValue: "true",
|
|
932
933
|
workflowConfig: {
|
|
@@ -957,7 +958,8 @@ var triggerFirstInvocation = async (params) => {
|
|
|
957
958
|
method: "POST",
|
|
958
959
|
body,
|
|
959
960
|
url: workflowContext.url,
|
|
960
|
-
delay
|
|
961
|
+
delay,
|
|
962
|
+
notBefore
|
|
961
963
|
};
|
|
962
964
|
}
|
|
963
965
|
);
|
|
@@ -1445,9 +1447,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1445
1447
|
retryDelay;
|
|
1446
1448
|
timeout;
|
|
1447
1449
|
flowControl;
|
|
1450
|
+
stringifyBody;
|
|
1448
1451
|
stepType = "Call";
|
|
1449
1452
|
allowUndefinedOut = false;
|
|
1450
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
1453
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1451
1454
|
super(stepName);
|
|
1452
1455
|
this.url = url;
|
|
1453
1456
|
this.method = method;
|
|
@@ -1457,6 +1460,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1457
1460
|
this.retryDelay = retryDelay;
|
|
1458
1461
|
this.timeout = timeout;
|
|
1459
1462
|
this.flowControl = flowControl;
|
|
1463
|
+
this.stringifyBody = stringifyBody;
|
|
1460
1464
|
}
|
|
1461
1465
|
getPlanStep(concurrent, targetStep) {
|
|
1462
1466
|
return {
|
|
@@ -1566,10 +1570,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1566
1570
|
};
|
|
1567
1571
|
}
|
|
1568
1572
|
async submitStep({ context, headers }) {
|
|
1573
|
+
let callBody;
|
|
1574
|
+
if (this.stringifyBody) {
|
|
1575
|
+
callBody = JSON.stringify(this.body);
|
|
1576
|
+
} else {
|
|
1577
|
+
if (typeof this.body === "string") {
|
|
1578
|
+
callBody = this.body;
|
|
1579
|
+
} else {
|
|
1580
|
+
throw new WorkflowError(
|
|
1581
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your call step."
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1569
1585
|
return await context.qstashClient.batch([
|
|
1570
1586
|
{
|
|
1571
1587
|
headers,
|
|
1572
|
-
body:
|
|
1588
|
+
body: callBody,
|
|
1573
1589
|
method: this.method,
|
|
1574
1590
|
url: this.url,
|
|
1575
1591
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -1704,7 +1720,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1704
1720
|
workflowRunId,
|
|
1705
1721
|
retries,
|
|
1706
1722
|
retryDelay,
|
|
1707
|
-
flowControl
|
|
1723
|
+
flowControl,
|
|
1724
|
+
stringifyBody = true
|
|
1708
1725
|
}) {
|
|
1709
1726
|
super(stepName);
|
|
1710
1727
|
this.params = {
|
|
@@ -1714,7 +1731,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1714
1731
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
1715
1732
|
retries,
|
|
1716
1733
|
retryDelay,
|
|
1717
|
-
flowControl
|
|
1734
|
+
flowControl,
|
|
1735
|
+
stringifyBody
|
|
1718
1736
|
};
|
|
1719
1737
|
const { workflowId } = workflow;
|
|
1720
1738
|
if (!workflowId) {
|
|
@@ -1767,8 +1785,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1767
1785
|
invokeCount
|
|
1768
1786
|
});
|
|
1769
1787
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
1788
|
+
let invokeBody;
|
|
1789
|
+
if (this.params.stringifyBody) {
|
|
1790
|
+
invokeBody = JSON.stringify(this.params.body);
|
|
1791
|
+
} else {
|
|
1792
|
+
if (typeof this.params.body === "string") {
|
|
1793
|
+
invokeBody = this.params.body;
|
|
1794
|
+
} else {
|
|
1795
|
+
throw new WorkflowError(
|
|
1796
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your invoke step."
|
|
1797
|
+
);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1770
1800
|
const request = {
|
|
1771
|
-
body:
|
|
1801
|
+
body: invokeBody,
|
|
1772
1802
|
headers: Object.fromEntries(
|
|
1773
1803
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
1774
1804
|
),
|
|
@@ -3212,7 +3242,8 @@ var WorkflowContext = class {
|
|
|
3212
3242
|
settings.retries || 0,
|
|
3213
3243
|
settings.retryDelay,
|
|
3214
3244
|
settings.timeout,
|
|
3215
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
3245
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
3246
|
+
settings.stringifyBody ?? true
|
|
3216
3247
|
);
|
|
3217
3248
|
} else {
|
|
3218
3249
|
const {
|
|
@@ -3223,7 +3254,8 @@ var WorkflowContext = class {
|
|
|
3223
3254
|
retries = 0,
|
|
3224
3255
|
retryDelay,
|
|
3225
3256
|
timeout,
|
|
3226
|
-
flowControl
|
|
3257
|
+
flowControl,
|
|
3258
|
+
stringifyBody = true
|
|
3227
3259
|
} = settings;
|
|
3228
3260
|
callStep = new LazyCallStep(
|
|
3229
3261
|
stepName,
|
|
@@ -3234,7 +3266,8 @@ var WorkflowContext = class {
|
|
|
3234
3266
|
retries,
|
|
3235
3267
|
retryDelay,
|
|
3236
3268
|
timeout,
|
|
3237
|
-
flowControl
|
|
3269
|
+
flowControl,
|
|
3270
|
+
stringifyBody
|
|
3238
3271
|
);
|
|
3239
3272
|
}
|
|
3240
3273
|
return await this.addStep(callStep);
|
|
@@ -3598,11 +3631,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3598
3631
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
3599
3632
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
3600
3633
|
let errorMessage = "";
|
|
3634
|
+
let failStack = "";
|
|
3601
3635
|
try {
|
|
3602
3636
|
const errorPayload = JSON.parse(decodedBody);
|
|
3603
3637
|
if (errorPayload.message) {
|
|
3604
3638
|
errorMessage = errorPayload.message;
|
|
3605
3639
|
}
|
|
3640
|
+
if (errorPayload.stack) {
|
|
3641
|
+
failStack = errorPayload.stack;
|
|
3642
|
+
}
|
|
3606
3643
|
} catch {
|
|
3607
3644
|
}
|
|
3608
3645
|
if (!errorMessage) {
|
|
@@ -3640,7 +3677,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3640
3677
|
context: workflowContext,
|
|
3641
3678
|
failStatus: status,
|
|
3642
3679
|
failResponse: errorMessage,
|
|
3643
|
-
failHeaders: header
|
|
3680
|
+
failHeaders: header,
|
|
3681
|
+
failStack
|
|
3644
3682
|
});
|
|
3645
3683
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
3646
3684
|
} catch (error) {
|
|
@@ -3657,7 +3695,7 @@ var processOptions = (options) => {
|
|
|
3657
3695
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
3658
3696
|
);
|
|
3659
3697
|
return {
|
|
3660
|
-
qstashClient: new import_qstash11.Client({
|
|
3698
|
+
qstashClient: options?.qstashClient ?? new import_qstash11.Client({
|
|
3661
3699
|
baseUrl: environment.QSTASH_URL,
|
|
3662
3700
|
token: environment.QSTASH_TOKEN
|
|
3663
3701
|
}),
|
package/h3.mjs
CHANGED
package/hono.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction, n as PublicServeOptions,
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-Q3dM0UlR.mjs';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-BNusWYgt.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,
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-Q3dM0UlR.js';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-CXqQP3RI.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'ai';
|
package/hono.js
CHANGED
|
@@ -92,7 +92,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
92
92
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
93
93
|
var NO_CONCURRENCY = 1;
|
|
94
94
|
var DEFAULT_RETRIES = 3;
|
|
95
|
-
var VERSION = "v0.2.
|
|
95
|
+
var VERSION = "v0.2.20";
|
|
96
96
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
97
97
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
98
98
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -143,7 +143,8 @@ var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
|
143
143
|
var formatWorkflowError = (error) => {
|
|
144
144
|
return error instanceof Error ? {
|
|
145
145
|
error: error.name,
|
|
146
|
-
message: error.message
|
|
146
|
+
message: error.message,
|
|
147
|
+
stack: error.stack
|
|
147
148
|
} : {
|
|
148
149
|
error: "Error",
|
|
149
150
|
message: `An error occured while executing workflow: '${typeof error === "string" ? error : JSON.stringify(error)}'`
|
|
@@ -614,7 +615,7 @@ var triggerFirstInvocation = async (params) => {
|
|
|
614
615
|
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
615
616
|
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
616
617
|
const invocationBatch = firstInvocationParams.map(
|
|
617
|
-
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay }) => {
|
|
618
|
+
({ workflowContext, useJSONContent, telemetry: telemetry2, invokeCount, delay, notBefore }) => {
|
|
618
619
|
const { headers } = getHeaders({
|
|
619
620
|
initHeaderValue: "true",
|
|
620
621
|
workflowConfig: {
|
|
@@ -645,7 +646,8 @@ var triggerFirstInvocation = async (params) => {
|
|
|
645
646
|
method: "POST",
|
|
646
647
|
body,
|
|
647
648
|
url: workflowContext.url,
|
|
648
|
-
delay
|
|
649
|
+
delay,
|
|
650
|
+
notBefore
|
|
649
651
|
};
|
|
650
652
|
}
|
|
651
653
|
);
|
|
@@ -1133,9 +1135,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1133
1135
|
retryDelay;
|
|
1134
1136
|
timeout;
|
|
1135
1137
|
flowControl;
|
|
1138
|
+
stringifyBody;
|
|
1136
1139
|
stepType = "Call";
|
|
1137
1140
|
allowUndefinedOut = false;
|
|
1138
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
1141
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1139
1142
|
super(stepName);
|
|
1140
1143
|
this.url = url;
|
|
1141
1144
|
this.method = method;
|
|
@@ -1145,6 +1148,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1145
1148
|
this.retryDelay = retryDelay;
|
|
1146
1149
|
this.timeout = timeout;
|
|
1147
1150
|
this.flowControl = flowControl;
|
|
1151
|
+
this.stringifyBody = stringifyBody;
|
|
1148
1152
|
}
|
|
1149
1153
|
getPlanStep(concurrent, targetStep) {
|
|
1150
1154
|
return {
|
|
@@ -1254,10 +1258,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1254
1258
|
};
|
|
1255
1259
|
}
|
|
1256
1260
|
async submitStep({ context, headers }) {
|
|
1261
|
+
let callBody;
|
|
1262
|
+
if (this.stringifyBody) {
|
|
1263
|
+
callBody = JSON.stringify(this.body);
|
|
1264
|
+
} else {
|
|
1265
|
+
if (typeof this.body === "string") {
|
|
1266
|
+
callBody = this.body;
|
|
1267
|
+
} else {
|
|
1268
|
+
throw new WorkflowError(
|
|
1269
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your call step."
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1257
1273
|
return await context.qstashClient.batch([
|
|
1258
1274
|
{
|
|
1259
1275
|
headers,
|
|
1260
|
-
body:
|
|
1276
|
+
body: callBody,
|
|
1261
1277
|
method: this.method,
|
|
1262
1278
|
url: this.url,
|
|
1263
1279
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -1392,7 +1408,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1392
1408
|
workflowRunId,
|
|
1393
1409
|
retries,
|
|
1394
1410
|
retryDelay,
|
|
1395
|
-
flowControl
|
|
1411
|
+
flowControl,
|
|
1412
|
+
stringifyBody = true
|
|
1396
1413
|
}) {
|
|
1397
1414
|
super(stepName);
|
|
1398
1415
|
this.params = {
|
|
@@ -1402,7 +1419,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1402
1419
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
1403
1420
|
retries,
|
|
1404
1421
|
retryDelay,
|
|
1405
|
-
flowControl
|
|
1422
|
+
flowControl,
|
|
1423
|
+
stringifyBody
|
|
1406
1424
|
};
|
|
1407
1425
|
const { workflowId } = workflow;
|
|
1408
1426
|
if (!workflowId) {
|
|
@@ -1455,8 +1473,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1455
1473
|
invokeCount
|
|
1456
1474
|
});
|
|
1457
1475
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
1476
|
+
let invokeBody;
|
|
1477
|
+
if (this.params.stringifyBody) {
|
|
1478
|
+
invokeBody = JSON.stringify(this.params.body);
|
|
1479
|
+
} else {
|
|
1480
|
+
if (typeof this.params.body === "string") {
|
|
1481
|
+
invokeBody = this.params.body;
|
|
1482
|
+
} else {
|
|
1483
|
+
throw new WorkflowError(
|
|
1484
|
+
"When stringifyBody is false, body must be a string. Please check the body type of your invoke step."
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1458
1488
|
const request = {
|
|
1459
|
-
body:
|
|
1489
|
+
body: invokeBody,
|
|
1460
1490
|
headers: Object.fromEntries(
|
|
1461
1491
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
1462
1492
|
),
|
|
@@ -2900,7 +2930,8 @@ var WorkflowContext = class {
|
|
|
2900
2930
|
settings.retries || 0,
|
|
2901
2931
|
settings.retryDelay,
|
|
2902
2932
|
settings.timeout,
|
|
2903
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
2933
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
2934
|
+
settings.stringifyBody ?? true
|
|
2904
2935
|
);
|
|
2905
2936
|
} else {
|
|
2906
2937
|
const {
|
|
@@ -2911,7 +2942,8 @@ var WorkflowContext = class {
|
|
|
2911
2942
|
retries = 0,
|
|
2912
2943
|
retryDelay,
|
|
2913
2944
|
timeout,
|
|
2914
|
-
flowControl
|
|
2945
|
+
flowControl,
|
|
2946
|
+
stringifyBody = true
|
|
2915
2947
|
} = settings;
|
|
2916
2948
|
callStep = new LazyCallStep(
|
|
2917
2949
|
stepName,
|
|
@@ -2922,7 +2954,8 @@ var WorkflowContext = class {
|
|
|
2922
2954
|
retries,
|
|
2923
2955
|
retryDelay,
|
|
2924
2956
|
timeout,
|
|
2925
|
-
flowControl
|
|
2957
|
+
flowControl,
|
|
2958
|
+
stringifyBody
|
|
2926
2959
|
);
|
|
2927
2960
|
}
|
|
2928
2961
|
return await this.addStep(callStep);
|
|
@@ -3286,11 +3319,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3286
3319
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
3287
3320
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
3288
3321
|
let errorMessage = "";
|
|
3322
|
+
let failStack = "";
|
|
3289
3323
|
try {
|
|
3290
3324
|
const errorPayload = JSON.parse(decodedBody);
|
|
3291
3325
|
if (errorPayload.message) {
|
|
3292
3326
|
errorMessage = errorPayload.message;
|
|
3293
3327
|
}
|
|
3328
|
+
if (errorPayload.stack) {
|
|
3329
|
+
failStack = errorPayload.stack;
|
|
3330
|
+
}
|
|
3294
3331
|
} catch {
|
|
3295
3332
|
}
|
|
3296
3333
|
if (!errorMessage) {
|
|
@@ -3328,7 +3365,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3328
3365
|
context: workflowContext,
|
|
3329
3366
|
failStatus: status,
|
|
3330
3367
|
failResponse: errorMessage,
|
|
3331
|
-
failHeaders: header
|
|
3368
|
+
failHeaders: header,
|
|
3369
|
+
failStack
|
|
3332
3370
|
});
|
|
3333
3371
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
3334
3372
|
} catch (error) {
|
|
@@ -3345,7 +3383,7 @@ var processOptions = (options) => {
|
|
|
3345
3383
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
3346
3384
|
);
|
|
3347
3385
|
return {
|
|
3348
|
-
qstashClient: new import_qstash11.Client({
|
|
3386
|
+
qstashClient: options?.qstashClient ?? new import_qstash11.Client({
|
|
3349
3387
|
baseUrl: environment.QSTASH_URL,
|
|
3350
3388
|
token: environment.QSTASH_TOKEN
|
|
3351
3389
|
}),
|
package/hono.mjs
CHANGED
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-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse,
|
|
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-Q3dM0UlR.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, w as CallSettings, D as DetailedFinishCondition, t as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, y as InvokableWorkflow, x as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, z as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, v as StringifyBody, l as SyncStepFunction, u as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, G as WorkflowLogger, B as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types-Q3dM0UlR.mjs';
|
|
3
3
|
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
@@ -416,6 +416,16 @@ type TriggerOptions = {
|
|
|
416
416
|
* Delay to apply before triggering the workflow.
|
|
417
417
|
*/
|
|
418
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"];
|
|
419
429
|
/**
|
|
420
430
|
* Label to apply to the workflow run.
|
|
421
431
|
*
|
package/index.d.ts
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-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse,
|
|
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-Q3dM0UlR.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, w as CallSettings, D as DetailedFinishCondition, t as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, y as InvokableWorkflow, x as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, z as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, v as StringifyBody, l as SyncStepFunction, u as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, G as WorkflowLogger, B as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types-Q3dM0UlR.js';
|
|
3
3
|
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
@@ -416,6 +416,16 @@ type TriggerOptions = {
|
|
|
416
416
|
* Delay to apply before triggering the workflow.
|
|
417
417
|
*/
|
|
418
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"];
|
|
419
429
|
/**
|
|
420
430
|
* Label to apply to the workflow run.
|
|
421
431
|
*
|