@upstash/workflow 0.2.19 → 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 +48 -11
- package/astro.mjs +1 -1
- package/{chunk-37XOXDLZ.mjs → chunk-LZGX3WMF.mjs} +48 -11
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +48 -11
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +48 -11
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +48 -11
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +48 -11
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +48 -11
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +48 -11
- 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 +48 -11
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +48 -11
- 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)}'`
|
|
@@ -24580,9 +24581,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24580
24581
|
retryDelay;
|
|
24581
24582
|
timeout;
|
|
24582
24583
|
flowControl;
|
|
24584
|
+
stringifyBody;
|
|
24583
24585
|
stepType = "Call";
|
|
24584
24586
|
allowUndefinedOut = false;
|
|
24585
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
24587
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
24586
24588
|
super(stepName);
|
|
24587
24589
|
this.url = url;
|
|
24588
24590
|
this.method = method;
|
|
@@ -24592,6 +24594,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24592
24594
|
this.retryDelay = retryDelay;
|
|
24593
24595
|
this.timeout = timeout;
|
|
24594
24596
|
this.flowControl = flowControl;
|
|
24597
|
+
this.stringifyBody = stringifyBody;
|
|
24595
24598
|
}
|
|
24596
24599
|
getPlanStep(concurrent, targetStep) {
|
|
24597
24600
|
return {
|
|
@@ -24701,10 +24704,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24701
24704
|
};
|
|
24702
24705
|
}
|
|
24703
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
|
+
}
|
|
24704
24719
|
return await context.qstashClient.batch([
|
|
24705
24720
|
{
|
|
24706
24721
|
headers,
|
|
24707
|
-
body:
|
|
24722
|
+
body: callBody,
|
|
24708
24723
|
method: this.method,
|
|
24709
24724
|
url: this.url,
|
|
24710
24725
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -24839,7 +24854,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24839
24854
|
workflowRunId,
|
|
24840
24855
|
retries,
|
|
24841
24856
|
retryDelay,
|
|
24842
|
-
flowControl
|
|
24857
|
+
flowControl,
|
|
24858
|
+
stringifyBody = true
|
|
24843
24859
|
}) {
|
|
24844
24860
|
super(stepName);
|
|
24845
24861
|
this.params = {
|
|
@@ -24849,7 +24865,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24849
24865
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
24850
24866
|
retries,
|
|
24851
24867
|
retryDelay,
|
|
24852
|
-
flowControl
|
|
24868
|
+
flowControl,
|
|
24869
|
+
stringifyBody
|
|
24853
24870
|
};
|
|
24854
24871
|
const { workflowId } = workflow;
|
|
24855
24872
|
if (!workflowId) {
|
|
@@ -24902,8 +24919,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24902
24919
|
invokeCount
|
|
24903
24920
|
});
|
|
24904
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
|
+
}
|
|
24905
24934
|
const request = {
|
|
24906
|
-
body:
|
|
24935
|
+
body: invokeBody,
|
|
24907
24936
|
headers: Object.fromEntries(
|
|
24908
24937
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
24909
24938
|
),
|
|
@@ -26347,7 +26376,8 @@ var WorkflowContext = class {
|
|
|
26347
26376
|
settings.retries || 0,
|
|
26348
26377
|
settings.retryDelay,
|
|
26349
26378
|
settings.timeout,
|
|
26350
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
26379
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
26380
|
+
settings.stringifyBody ?? true
|
|
26351
26381
|
);
|
|
26352
26382
|
} else {
|
|
26353
26383
|
const {
|
|
@@ -26358,7 +26388,8 @@ var WorkflowContext = class {
|
|
|
26358
26388
|
retries = 0,
|
|
26359
26389
|
retryDelay,
|
|
26360
26390
|
timeout,
|
|
26361
|
-
flowControl
|
|
26391
|
+
flowControl,
|
|
26392
|
+
stringifyBody = true
|
|
26362
26393
|
} = settings;
|
|
26363
26394
|
callStep = new LazyCallStep(
|
|
26364
26395
|
stepName,
|
|
@@ -26369,7 +26400,8 @@ var WorkflowContext = class {
|
|
|
26369
26400
|
retries,
|
|
26370
26401
|
retryDelay,
|
|
26371
26402
|
timeout,
|
|
26372
|
-
flowControl
|
|
26403
|
+
flowControl,
|
|
26404
|
+
stringifyBody
|
|
26373
26405
|
);
|
|
26374
26406
|
}
|
|
26375
26407
|
return await this.addStep(callStep);
|
|
@@ -26733,11 +26765,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
26733
26765
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
26734
26766
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
26735
26767
|
let errorMessage = "";
|
|
26768
|
+
let failStack = "";
|
|
26736
26769
|
try {
|
|
26737
26770
|
const errorPayload = JSON.parse(decodedBody);
|
|
26738
26771
|
if (errorPayload.message) {
|
|
26739
26772
|
errorMessage = errorPayload.message;
|
|
26740
26773
|
}
|
|
26774
|
+
if (errorPayload.stack) {
|
|
26775
|
+
failStack = errorPayload.stack;
|
|
26776
|
+
}
|
|
26741
26777
|
} catch {
|
|
26742
26778
|
}
|
|
26743
26779
|
if (!errorMessage) {
|
|
@@ -26775,7 +26811,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
26775
26811
|
context: workflowContext,
|
|
26776
26812
|
failStatus: status,
|
|
26777
26813
|
failResponse: errorMessage,
|
|
26778
|
-
failHeaders: header
|
|
26814
|
+
failHeaders: header,
|
|
26815
|
+
failStack
|
|
26779
26816
|
});
|
|
26780
26817
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
26781
26818
|
} catch (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, 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)}'`
|
|
@@ -1446,9 +1447,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1446
1447
|
retryDelay;
|
|
1447
1448
|
timeout;
|
|
1448
1449
|
flowControl;
|
|
1450
|
+
stringifyBody;
|
|
1449
1451
|
stepType = "Call";
|
|
1450
1452
|
allowUndefinedOut = false;
|
|
1451
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
1453
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1452
1454
|
super(stepName);
|
|
1453
1455
|
this.url = url;
|
|
1454
1456
|
this.method = method;
|
|
@@ -1458,6 +1460,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1458
1460
|
this.retryDelay = retryDelay;
|
|
1459
1461
|
this.timeout = timeout;
|
|
1460
1462
|
this.flowControl = flowControl;
|
|
1463
|
+
this.stringifyBody = stringifyBody;
|
|
1461
1464
|
}
|
|
1462
1465
|
getPlanStep(concurrent, targetStep) {
|
|
1463
1466
|
return {
|
|
@@ -1567,10 +1570,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1567
1570
|
};
|
|
1568
1571
|
}
|
|
1569
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
|
+
}
|
|
1570
1585
|
return await context.qstashClient.batch([
|
|
1571
1586
|
{
|
|
1572
1587
|
headers,
|
|
1573
|
-
body:
|
|
1588
|
+
body: callBody,
|
|
1574
1589
|
method: this.method,
|
|
1575
1590
|
url: this.url,
|
|
1576
1591
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -1705,7 +1720,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1705
1720
|
workflowRunId,
|
|
1706
1721
|
retries,
|
|
1707
1722
|
retryDelay,
|
|
1708
|
-
flowControl
|
|
1723
|
+
flowControl,
|
|
1724
|
+
stringifyBody = true
|
|
1709
1725
|
}) {
|
|
1710
1726
|
super(stepName);
|
|
1711
1727
|
this.params = {
|
|
@@ -1715,7 +1731,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1715
1731
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
1716
1732
|
retries,
|
|
1717
1733
|
retryDelay,
|
|
1718
|
-
flowControl
|
|
1734
|
+
flowControl,
|
|
1735
|
+
stringifyBody
|
|
1719
1736
|
};
|
|
1720
1737
|
const { workflowId } = workflow;
|
|
1721
1738
|
if (!workflowId) {
|
|
@@ -1768,8 +1785,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1768
1785
|
invokeCount
|
|
1769
1786
|
});
|
|
1770
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
|
+
}
|
|
1771
1800
|
const request = {
|
|
1772
|
-
body:
|
|
1801
|
+
body: invokeBody,
|
|
1773
1802
|
headers: Object.fromEntries(
|
|
1774
1803
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
1775
1804
|
),
|
|
@@ -3213,7 +3242,8 @@ var WorkflowContext = class {
|
|
|
3213
3242
|
settings.retries || 0,
|
|
3214
3243
|
settings.retryDelay,
|
|
3215
3244
|
settings.timeout,
|
|
3216
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
3245
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
3246
|
+
settings.stringifyBody ?? true
|
|
3217
3247
|
);
|
|
3218
3248
|
} else {
|
|
3219
3249
|
const {
|
|
@@ -3224,7 +3254,8 @@ var WorkflowContext = class {
|
|
|
3224
3254
|
retries = 0,
|
|
3225
3255
|
retryDelay,
|
|
3226
3256
|
timeout,
|
|
3227
|
-
flowControl
|
|
3257
|
+
flowControl,
|
|
3258
|
+
stringifyBody = true
|
|
3228
3259
|
} = settings;
|
|
3229
3260
|
callStep = new LazyCallStep(
|
|
3230
3261
|
stepName,
|
|
@@ -3235,7 +3266,8 @@ var WorkflowContext = class {
|
|
|
3235
3266
|
retries,
|
|
3236
3267
|
retryDelay,
|
|
3237
3268
|
timeout,
|
|
3238
|
-
flowControl
|
|
3269
|
+
flowControl,
|
|
3270
|
+
stringifyBody
|
|
3239
3271
|
);
|
|
3240
3272
|
}
|
|
3241
3273
|
return await this.addStep(callStep);
|
|
@@ -3599,11 +3631,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3599
3631
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
3600
3632
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
3601
3633
|
let errorMessage = "";
|
|
3634
|
+
let failStack = "";
|
|
3602
3635
|
try {
|
|
3603
3636
|
const errorPayload = JSON.parse(decodedBody);
|
|
3604
3637
|
if (errorPayload.message) {
|
|
3605
3638
|
errorMessage = errorPayload.message;
|
|
3606
3639
|
}
|
|
3640
|
+
if (errorPayload.stack) {
|
|
3641
|
+
failStack = errorPayload.stack;
|
|
3642
|
+
}
|
|
3607
3643
|
} catch {
|
|
3608
3644
|
}
|
|
3609
3645
|
if (!errorMessage) {
|
|
@@ -3641,7 +3677,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3641
3677
|
context: workflowContext,
|
|
3642
3678
|
failStatus: status,
|
|
3643
3679
|
failResponse: errorMessage,
|
|
3644
|
-
failHeaders: header
|
|
3680
|
+
failHeaders: header,
|
|
3681
|
+
failStack
|
|
3645
3682
|
});
|
|
3646
3683
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
3647
3684
|
} catch (error) {
|
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)}'`
|
|
@@ -1134,9 +1135,10 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1134
1135
|
retryDelay;
|
|
1135
1136
|
timeout;
|
|
1136
1137
|
flowControl;
|
|
1138
|
+
stringifyBody;
|
|
1137
1139
|
stepType = "Call";
|
|
1138
1140
|
allowUndefinedOut = false;
|
|
1139
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl) {
|
|
1141
|
+
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1140
1142
|
super(stepName);
|
|
1141
1143
|
this.url = url;
|
|
1142
1144
|
this.method = method;
|
|
@@ -1146,6 +1148,7 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1146
1148
|
this.retryDelay = retryDelay;
|
|
1147
1149
|
this.timeout = timeout;
|
|
1148
1150
|
this.flowControl = flowControl;
|
|
1151
|
+
this.stringifyBody = stringifyBody;
|
|
1149
1152
|
}
|
|
1150
1153
|
getPlanStep(concurrent, targetStep) {
|
|
1151
1154
|
return {
|
|
@@ -1255,10 +1258,22 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1255
1258
|
};
|
|
1256
1259
|
}
|
|
1257
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
|
+
}
|
|
1258
1273
|
return await context.qstashClient.batch([
|
|
1259
1274
|
{
|
|
1260
1275
|
headers,
|
|
1261
|
-
body:
|
|
1276
|
+
body: callBody,
|
|
1262
1277
|
method: this.method,
|
|
1263
1278
|
url: this.url,
|
|
1264
1279
|
retries: DEFAULT_RETRIES === this.retries ? void 0 : this.retries,
|
|
@@ -1393,7 +1408,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1393
1408
|
workflowRunId,
|
|
1394
1409
|
retries,
|
|
1395
1410
|
retryDelay,
|
|
1396
|
-
flowControl
|
|
1411
|
+
flowControl,
|
|
1412
|
+
stringifyBody = true
|
|
1397
1413
|
}) {
|
|
1398
1414
|
super(stepName);
|
|
1399
1415
|
this.params = {
|
|
@@ -1403,7 +1419,8 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1403
1419
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
1404
1420
|
retries,
|
|
1405
1421
|
retryDelay,
|
|
1406
|
-
flowControl
|
|
1422
|
+
flowControl,
|
|
1423
|
+
stringifyBody
|
|
1407
1424
|
};
|
|
1408
1425
|
const { workflowId } = workflow;
|
|
1409
1426
|
if (!workflowId) {
|
|
@@ -1456,8 +1473,20 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1456
1473
|
invokeCount
|
|
1457
1474
|
});
|
|
1458
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
|
+
}
|
|
1459
1488
|
const request = {
|
|
1460
|
-
body:
|
|
1489
|
+
body: invokeBody,
|
|
1461
1490
|
headers: Object.fromEntries(
|
|
1462
1491
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
1463
1492
|
),
|
|
@@ -2901,7 +2930,8 @@ var WorkflowContext = class {
|
|
|
2901
2930
|
settings.retries || 0,
|
|
2902
2931
|
settings.retryDelay,
|
|
2903
2932
|
settings.timeout,
|
|
2904
|
-
settings.flowControl ?? settings.workflow.options.flowControl
|
|
2933
|
+
settings.flowControl ?? settings.workflow.options.flowControl,
|
|
2934
|
+
settings.stringifyBody ?? true
|
|
2905
2935
|
);
|
|
2906
2936
|
} else {
|
|
2907
2937
|
const {
|
|
@@ -2912,7 +2942,8 @@ var WorkflowContext = class {
|
|
|
2912
2942
|
retries = 0,
|
|
2913
2943
|
retryDelay,
|
|
2914
2944
|
timeout,
|
|
2915
|
-
flowControl
|
|
2945
|
+
flowControl,
|
|
2946
|
+
stringifyBody = true
|
|
2916
2947
|
} = settings;
|
|
2917
2948
|
callStep = new LazyCallStep(
|
|
2918
2949
|
stepName,
|
|
@@ -2923,7 +2954,8 @@ var WorkflowContext = class {
|
|
|
2923
2954
|
retries,
|
|
2924
2955
|
retryDelay,
|
|
2925
2956
|
timeout,
|
|
2926
|
-
flowControl
|
|
2957
|
+
flowControl,
|
|
2958
|
+
stringifyBody
|
|
2927
2959
|
);
|
|
2928
2960
|
}
|
|
2929
2961
|
return await this.addStep(callStep);
|
|
@@ -3287,11 +3319,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3287
3319
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
3288
3320
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
3289
3321
|
let errorMessage = "";
|
|
3322
|
+
let failStack = "";
|
|
3290
3323
|
try {
|
|
3291
3324
|
const errorPayload = JSON.parse(decodedBody);
|
|
3292
3325
|
if (errorPayload.message) {
|
|
3293
3326
|
errorMessage = errorPayload.message;
|
|
3294
3327
|
}
|
|
3328
|
+
if (errorPayload.stack) {
|
|
3329
|
+
failStack = errorPayload.stack;
|
|
3330
|
+
}
|
|
3295
3331
|
} catch {
|
|
3296
3332
|
}
|
|
3297
3333
|
if (!errorMessage) {
|
|
@@ -3329,7 +3365,8 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3329
3365
|
context: workflowContext,
|
|
3330
3366
|
failStatus: status,
|
|
3331
3367
|
failResponse: errorMessage,
|
|
3332
|
-
failHeaders: header
|
|
3368
|
+
failHeaders: header,
|
|
3369
|
+
failStack
|
|
3333
3370
|
});
|
|
3334
3371
|
return ok({ result: "is-failure-callback", response: failureResponse });
|
|
3335
3372
|
} catch (error) {
|
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';
|
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';
|