@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/svelte.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/svelte.mjs
CHANGED
|
@@ -1286,6 +1286,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1286
1286
|
failStatus: number;
|
|
1287
1287
|
failResponse: string;
|
|
1288
1288
|
failHeaders: Record<string, string[]>;
|
|
1289
|
+
failStack: string;
|
|
1289
1290
|
}) => Promise<void | string> | void | string;
|
|
1290
1291
|
/**
|
|
1291
1292
|
* Base Url of the workflow endpoint
|
|
@@ -1403,6 +1404,10 @@ type FailureFunctionPayload = {
|
|
|
1403
1404
|
* error message
|
|
1404
1405
|
*/
|
|
1405
1406
|
message: string;
|
|
1407
|
+
/**
|
|
1408
|
+
* error stack trace if available
|
|
1409
|
+
*/
|
|
1410
|
+
stack?: string;
|
|
1406
1411
|
};
|
|
1407
1412
|
/**
|
|
1408
1413
|
* Makes all fields except the ones selected required
|
|
@@ -1476,15 +1481,29 @@ interface WaitEventOptions {
|
|
|
1476
1481
|
*/
|
|
1477
1482
|
timeout?: number | Duration;
|
|
1478
1483
|
}
|
|
1484
|
+
type StringifyBody<TBody = unknown> = TBody extends string ? boolean : true;
|
|
1479
1485
|
type CallSettings<TBody = unknown> = {
|
|
1480
1486
|
url: string;
|
|
1481
1487
|
method?: HTTPMethods$1;
|
|
1488
|
+
/**
|
|
1489
|
+
* Request body.
|
|
1490
|
+
*
|
|
1491
|
+
* By default, the body is stringified with `JSON.stringify`. If you want
|
|
1492
|
+
* to send a string body without stringifying it, you need to set
|
|
1493
|
+
* `stringifyBody` to false.
|
|
1494
|
+
*/
|
|
1482
1495
|
body?: TBody;
|
|
1483
1496
|
headers?: Record<string, string>;
|
|
1484
1497
|
retries?: number;
|
|
1485
1498
|
retryDelay?: string;
|
|
1486
1499
|
timeout?: Duration | number;
|
|
1487
1500
|
flowControl?: FlowControl;
|
|
1501
|
+
/**
|
|
1502
|
+
* Whether the body field should be stringified when making the request.
|
|
1503
|
+
*
|
|
1504
|
+
* @default true
|
|
1505
|
+
*/
|
|
1506
|
+
stringifyBody?: StringifyBody<TBody>;
|
|
1488
1507
|
};
|
|
1489
1508
|
type HeaderParams = {
|
|
1490
1509
|
/**
|
|
@@ -1597,7 +1616,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
|
1597
1616
|
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
|
|
1598
1617
|
body: TInitiaPayload;
|
|
1599
1618
|
workflowRunId?: string;
|
|
1600
|
-
} & Pick<CallSettings
|
|
1619
|
+
} & Pick<CallSettings<TInitiaPayload>, "retries" | "headers" | "flowControl" | "retryDelay" | "stringifyBody">;
|
|
1601
1620
|
type InvokeStepResponse<TBody> = {
|
|
1602
1621
|
body: TBody;
|
|
1603
1622
|
isCanceled?: boolean;
|
|
@@ -1609,4 +1628,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
|
|
|
1609
1628
|
workflowId?: string;
|
|
1610
1629
|
};
|
|
1611
1630
|
|
|
1612
|
-
export { type AsyncStepFunction as A,
|
|
1631
|
+
export { type AsyncStepFunction as A, type WorkflowLoggerOptions as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, WorkflowLogger as G, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type StringifyBody as v, type CallSettings as w, type InvokeStepResponse as x, type InvokableWorkflow as y, type LogLevel as z };
|
|
@@ -1286,6 +1286,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1286
1286
|
failStatus: number;
|
|
1287
1287
|
failResponse: string;
|
|
1288
1288
|
failHeaders: Record<string, string[]>;
|
|
1289
|
+
failStack: string;
|
|
1289
1290
|
}) => Promise<void | string> | void | string;
|
|
1290
1291
|
/**
|
|
1291
1292
|
* Base Url of the workflow endpoint
|
|
@@ -1403,6 +1404,10 @@ type FailureFunctionPayload = {
|
|
|
1403
1404
|
* error message
|
|
1404
1405
|
*/
|
|
1405
1406
|
message: string;
|
|
1407
|
+
/**
|
|
1408
|
+
* error stack trace if available
|
|
1409
|
+
*/
|
|
1410
|
+
stack?: string;
|
|
1406
1411
|
};
|
|
1407
1412
|
/**
|
|
1408
1413
|
* Makes all fields except the ones selected required
|
|
@@ -1476,15 +1481,29 @@ interface WaitEventOptions {
|
|
|
1476
1481
|
*/
|
|
1477
1482
|
timeout?: number | Duration;
|
|
1478
1483
|
}
|
|
1484
|
+
type StringifyBody<TBody = unknown> = TBody extends string ? boolean : true;
|
|
1479
1485
|
type CallSettings<TBody = unknown> = {
|
|
1480
1486
|
url: string;
|
|
1481
1487
|
method?: HTTPMethods$1;
|
|
1488
|
+
/**
|
|
1489
|
+
* Request body.
|
|
1490
|
+
*
|
|
1491
|
+
* By default, the body is stringified with `JSON.stringify`. If you want
|
|
1492
|
+
* to send a string body without stringifying it, you need to set
|
|
1493
|
+
* `stringifyBody` to false.
|
|
1494
|
+
*/
|
|
1482
1495
|
body?: TBody;
|
|
1483
1496
|
headers?: Record<string, string>;
|
|
1484
1497
|
retries?: number;
|
|
1485
1498
|
retryDelay?: string;
|
|
1486
1499
|
timeout?: Duration | number;
|
|
1487
1500
|
flowControl?: FlowControl;
|
|
1501
|
+
/**
|
|
1502
|
+
* Whether the body field should be stringified when making the request.
|
|
1503
|
+
*
|
|
1504
|
+
* @default true
|
|
1505
|
+
*/
|
|
1506
|
+
stringifyBody?: StringifyBody<TBody>;
|
|
1488
1507
|
};
|
|
1489
1508
|
type HeaderParams = {
|
|
1490
1509
|
/**
|
|
@@ -1597,7 +1616,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
|
1597
1616
|
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
|
|
1598
1617
|
body: TInitiaPayload;
|
|
1599
1618
|
workflowRunId?: string;
|
|
1600
|
-
} & Pick<CallSettings
|
|
1619
|
+
} & Pick<CallSettings<TInitiaPayload>, "retries" | "headers" | "flowControl" | "retryDelay" | "stringifyBody">;
|
|
1601
1620
|
type InvokeStepResponse<TBody> = {
|
|
1602
1621
|
body: TBody;
|
|
1603
1622
|
isCanceled?: boolean;
|
|
@@ -1609,4 +1628,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
|
|
|
1609
1628
|
workflowId?: string;
|
|
1610
1629
|
};
|
|
1611
1630
|
|
|
1612
|
-
export { type AsyncStepFunction as A,
|
|
1631
|
+
export { type AsyncStepFunction as A, type WorkflowLoggerOptions as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, WorkflowLogger as G, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type StringifyBody as v, type CallSettings as w, type InvokeStepResponse as x, type InvokableWorkflow as y, type LogLevel as z };
|