@upstash/workflow 0.2.15 → 0.2.17
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 +178 -36
- package/astro.mjs +1 -1
- package/{chunk-AC5CQCN3.mjs → chunk-RP7G4UD5.mjs} +178 -36
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +178 -36
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +7060 -7193
- package/express.mjs +6706 -6981
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +178 -36
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +178 -36
- package/hono.mjs +1 -1
- package/index.d.mts +115 -11
- package/index.d.ts +115 -11
- package/index.js +186 -35
- package/index.mjs +17 -2
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +181 -36
- package/nextjs.mjs +4 -1
- package/package.json +1 -1
- package/{serve-many-AaKSQyi7.d.ts → serve-many-B3DfoTFt.d.ts} +1 -1
- package/{serve-many-AFwJPR3S.d.mts → serve-many-DgDSOvQs.d.mts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +170 -34
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +178 -36
- package/svelte.mjs +1 -1
- package/{types-Dd-3bPoU.d.ts → types--R_3XZXz.d.mts} +101 -14
- package/{types-Dd-3bPoU.d.mts → types--R_3XZXz.d.ts} +101 -14
|
@@ -620,7 +620,7 @@ type MultiAgentTaskParams = TaskParams & {
|
|
|
620
620
|
background?: string;
|
|
621
621
|
};
|
|
622
622
|
type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
|
|
623
|
-
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
|
|
623
|
+
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout" | "retryDelay">;
|
|
624
624
|
type CustomModelSettings = ModelParams["1"] & {
|
|
625
625
|
baseURL?: string;
|
|
626
626
|
apiKey?: string;
|
|
@@ -747,9 +747,7 @@ declare class WorkflowAgents {
|
|
|
747
747
|
context: WorkflowContext;
|
|
748
748
|
provider: TProvider;
|
|
749
749
|
providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
|
|
750
|
-
agentCallParams
|
|
751
|
-
* creates an openai model for agents
|
|
752
|
-
*/: AgentCallParams;
|
|
750
|
+
agentCallParams?: AgentCallParams;
|
|
753
751
|
}) => ReturnType<TProvider>;
|
|
754
752
|
}
|
|
755
753
|
|
|
@@ -879,12 +877,43 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
879
877
|
* Number of retries
|
|
880
878
|
*/
|
|
881
879
|
readonly retries: number;
|
|
880
|
+
/**
|
|
881
|
+
* Delay between retries.
|
|
882
|
+
*
|
|
883
|
+
* By default, the `retryDelay` is exponential backoff.
|
|
884
|
+
* More details can be found in: https://upstash.com/docs/qstash/features/retry.
|
|
885
|
+
*
|
|
886
|
+
* The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
|
|
887
|
+
*
|
|
888
|
+
* You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
|
|
889
|
+
* The special variable `retried` represents the current retry attempt count (starting from 0).
|
|
890
|
+
*
|
|
891
|
+
* Supported functions:
|
|
892
|
+
* - `pow`
|
|
893
|
+
* - `sqrt`
|
|
894
|
+
* - `abs`
|
|
895
|
+
* - `exp`
|
|
896
|
+
* - `floor`
|
|
897
|
+
* - `ceil`
|
|
898
|
+
* - `round`
|
|
899
|
+
* - `min`
|
|
900
|
+
* - `max`
|
|
901
|
+
*
|
|
902
|
+
* Examples of valid `retryDelay` values:
|
|
903
|
+
* ```ts
|
|
904
|
+
* 1000 // 1 second
|
|
905
|
+
* 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
|
|
906
|
+
* pow(2, retried) // 2 to the power of the current retry attempt
|
|
907
|
+
* max(10, pow(2, retried)) // The greater of 10 or 2^retried
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
readonly retryDelay?: string;
|
|
882
911
|
/**
|
|
883
912
|
* Settings for controlling the number of active requests
|
|
884
913
|
* and number of requests per second with the same key.
|
|
885
914
|
*/
|
|
886
915
|
readonly flowControl?: FlowControl;
|
|
887
|
-
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, invokeCount, flowControl, }: {
|
|
916
|
+
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, retryDelay, telemetry, invokeCount, flowControl, }: {
|
|
888
917
|
qstashClient: WorkflowClient;
|
|
889
918
|
workflowRunId: string;
|
|
890
919
|
headers: Headers;
|
|
@@ -895,6 +924,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
895
924
|
initialPayload: TInitialPayload;
|
|
896
925
|
env?: Record<string, string | undefined>;
|
|
897
926
|
retries?: number;
|
|
927
|
+
retryDelay?: string;
|
|
898
928
|
telemetry?: Telemetry;
|
|
899
929
|
invokeCount?: number;
|
|
900
930
|
flowControl?: FlowControl;
|
|
@@ -977,6 +1007,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
977
1007
|
* @param body call body
|
|
978
1008
|
* @param headers call headers
|
|
979
1009
|
* @param retries number of call retries. 0 by default
|
|
1010
|
+
* @param retryDelay delay / time gap between retries.
|
|
980
1011
|
* @param timeout max duration to wait for the endpoint to respond. in seconds.
|
|
981
1012
|
* @returns call result as {
|
|
982
1013
|
* status: number;
|
|
@@ -994,7 +1025,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
994
1025
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
995
1026
|
*
|
|
996
1027
|
*```ts
|
|
997
|
-
* const result = await workflow.waitForEvent("payment-confirmed", {
|
|
1028
|
+
* const result = await workflow.waitForEvent("payment-confirmed", "payment.confirmed", {
|
|
998
1029
|
* timeout: "5m"
|
|
999
1030
|
* });
|
|
1000
1031
|
*```
|
|
@@ -1020,11 +1051,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
1020
1051
|
* @param stepName
|
|
1021
1052
|
* @param eventId - Unique identifier for the event to wait for
|
|
1022
1053
|
* @param options - Configuration options.
|
|
1023
|
-
* @returns `{ timeout: boolean, eventData:
|
|
1054
|
+
* @returns `{ timeout: boolean, eventData: TEventData }`.
|
|
1024
1055
|
* The `timeout` property specifies if the workflow has timed out. The `eventData`
|
|
1025
1056
|
* is the data passed when notifying this workflow of an event.
|
|
1026
1057
|
*/
|
|
1027
|
-
waitForEvent(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse
|
|
1058
|
+
waitForEvent<TEventData = unknown>(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse<TEventData>>;
|
|
1028
1059
|
/**
|
|
1029
1060
|
* Notify workflow runs waiting for an event
|
|
1030
1061
|
*
|
|
@@ -1169,6 +1200,16 @@ type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResu
|
|
|
1169
1200
|
type ParallelCallState = "first" | "partial" | "discard" | "last";
|
|
1170
1201
|
type RouteFunction<TInitialPayload, TResult = unknown> = (context: WorkflowContext<TInitialPayload>) => Promise<TResult>;
|
|
1171
1202
|
type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended" | WorkflowNonRetryableError;
|
|
1203
|
+
type DetailedFinishCondition = {
|
|
1204
|
+
condition: Exclude<FinishCondition, WorkflowNonRetryableError | "failure-callback">;
|
|
1205
|
+
result?: never;
|
|
1206
|
+
} | {
|
|
1207
|
+
condition: "non-retryable-error";
|
|
1208
|
+
result: WorkflowNonRetryableError;
|
|
1209
|
+
} | {
|
|
1210
|
+
condition: "failure-callback";
|
|
1211
|
+
result: string | void;
|
|
1212
|
+
};
|
|
1172
1213
|
type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
|
|
1173
1214
|
/**
|
|
1174
1215
|
* QStash client
|
|
@@ -1180,7 +1221,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1180
1221
|
* @param workflowRunId
|
|
1181
1222
|
* @returns response
|
|
1182
1223
|
*/
|
|
1183
|
-
onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition) => TResponse;
|
|
1224
|
+
onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition, detailedFinishCondition?: DetailedFinishCondition) => TResponse;
|
|
1184
1225
|
/**
|
|
1185
1226
|
* Url of the endpoint where the workflow is set up.
|
|
1186
1227
|
*
|
|
@@ -1228,7 +1269,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1228
1269
|
failStatus: number;
|
|
1229
1270
|
failResponse: string;
|
|
1230
1271
|
failHeaders: Record<string, string[]>;
|
|
1231
|
-
}) => Promise<void> | void;
|
|
1272
|
+
}) => Promise<void | string> | void | string;
|
|
1232
1273
|
/**
|
|
1233
1274
|
* Base Url of the workflow endpoint
|
|
1234
1275
|
*
|
|
@@ -1255,6 +1296,37 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1255
1296
|
* @default 3
|
|
1256
1297
|
*/
|
|
1257
1298
|
retries?: number;
|
|
1299
|
+
/**
|
|
1300
|
+
* Delay between retries.
|
|
1301
|
+
*
|
|
1302
|
+
* By default, the `retryDelay` is exponential backoff.
|
|
1303
|
+
* More details can be found in: https://upstash.com/docs/qstash/features/retry.
|
|
1304
|
+
*
|
|
1305
|
+
* The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
|
|
1306
|
+
*
|
|
1307
|
+
* You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
|
|
1308
|
+
* The special variable `retried` represents the current retry attempt count (starting from 0).
|
|
1309
|
+
*
|
|
1310
|
+
* Supported functions:
|
|
1311
|
+
* - `pow`
|
|
1312
|
+
* - `sqrt`
|
|
1313
|
+
* - `abs`
|
|
1314
|
+
* - `exp`
|
|
1315
|
+
* - `floor`
|
|
1316
|
+
* - `ceil`
|
|
1317
|
+
* - `round`
|
|
1318
|
+
* - `min`
|
|
1319
|
+
* - `max`
|
|
1320
|
+
*
|
|
1321
|
+
* Examples of valid `retryDelay` values:
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* 1000 // 1 second
|
|
1324
|
+
* 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
|
|
1325
|
+
* pow(2, retried) // 2 to the power of the current retry attempt
|
|
1326
|
+
* max(10, pow(2, retried)) // The greater of 10 or 2^retried
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
retryDelay?: string;
|
|
1258
1330
|
/**
|
|
1259
1331
|
* Whether the framework should use `content-type: application/json`
|
|
1260
1332
|
* in `triggerFirstInvocation`.
|
|
@@ -1340,7 +1412,7 @@ type WaitRequest = {
|
|
|
1340
1412
|
timeoutBody?: string;
|
|
1341
1413
|
timeoutHeaders?: Record<string, string[]>;
|
|
1342
1414
|
};
|
|
1343
|
-
type WaitStepResponse = {
|
|
1415
|
+
type WaitStepResponse<TEventData = unknown> = {
|
|
1344
1416
|
/**
|
|
1345
1417
|
* whether the wait for event step timed out. false if
|
|
1346
1418
|
* the step is notified
|
|
@@ -1349,7 +1421,7 @@ type WaitStepResponse = {
|
|
|
1349
1421
|
/**
|
|
1350
1422
|
* body passed in notify request
|
|
1351
1423
|
*/
|
|
1352
|
-
eventData:
|
|
1424
|
+
eventData: TEventData;
|
|
1353
1425
|
};
|
|
1354
1426
|
type NotifyStepResponse = {
|
|
1355
1427
|
/**
|
|
@@ -1393,6 +1465,7 @@ type CallSettings<TBody = unknown> = {
|
|
|
1393
1465
|
body?: TBody;
|
|
1394
1466
|
headers?: Record<string, string>;
|
|
1395
1467
|
retries?: number;
|
|
1468
|
+
retryDelay?: string;
|
|
1396
1469
|
timeout?: Duration | number;
|
|
1397
1470
|
flowControl?: FlowControl;
|
|
1398
1471
|
};
|
|
@@ -1421,6 +1494,10 @@ type HeaderParams = {
|
|
|
1421
1494
|
* retry setting of requests except context.call
|
|
1422
1495
|
*/
|
|
1423
1496
|
retries?: number;
|
|
1497
|
+
/**
|
|
1498
|
+
* retry delay to include in headers.
|
|
1499
|
+
*/
|
|
1500
|
+
retryDelay?: string;
|
|
1424
1501
|
/**
|
|
1425
1502
|
* telemetry to include in timeoutHeaders.
|
|
1426
1503
|
*
|
|
@@ -1445,6 +1522,10 @@ type HeaderParams = {
|
|
|
1445
1522
|
* number of retries in context.call
|
|
1446
1523
|
*/
|
|
1447
1524
|
callRetries?: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* retry delay to include in headers.
|
|
1527
|
+
*/
|
|
1528
|
+
callRetryDelay?: string;
|
|
1448
1529
|
/**
|
|
1449
1530
|
* timeout duration in context.call
|
|
1450
1531
|
*/
|
|
@@ -1468,6 +1549,12 @@ type HeaderParams = {
|
|
|
1468
1549
|
* set to never because this is not a context.call step
|
|
1469
1550
|
*/
|
|
1470
1551
|
callRetries?: never;
|
|
1552
|
+
/**
|
|
1553
|
+
* retry delay to include in headers.
|
|
1554
|
+
*
|
|
1555
|
+
* set to never because this is not a context.call step
|
|
1556
|
+
*/
|
|
1557
|
+
callRetryDelay?: never;
|
|
1471
1558
|
/**
|
|
1472
1559
|
* timeout duration in context.call
|
|
1473
1560
|
*
|
|
@@ -1493,7 +1580,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
|
1493
1580
|
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
|
|
1494
1581
|
body: TInitiaPayload;
|
|
1495
1582
|
workflowRunId?: string;
|
|
1496
|
-
} & Pick<CallSettings, "retries" | "headers" | "flowControl">;
|
|
1583
|
+
} & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay">;
|
|
1497
1584
|
type InvokeStepResponse<TBody> = {
|
|
1498
1585
|
body: TBody;
|
|
1499
1586
|
isCanceled?: boolean;
|
|
@@ -1505,4 +1592,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
|
|
|
1505
1592
|
workflowId?: string;
|
|
1506
1593
|
};
|
|
1507
1594
|
|
|
1508
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type
|
|
1595
|
+
export { type AsyncStepFunction as A, WorkflowLogger as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, 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 CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x, type LogLevel as y, type WorkflowLoggerOptions as z };
|
|
@@ -620,7 +620,7 @@ type MultiAgentTaskParams = TaskParams & {
|
|
|
620
620
|
background?: string;
|
|
621
621
|
};
|
|
622
622
|
type ModelParams = Parameters<ReturnType<typeof createOpenAI>>;
|
|
623
|
-
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout">;
|
|
623
|
+
type AgentCallParams = Pick<CallSettings, "flowControl" | "retries" | "timeout" | "retryDelay">;
|
|
624
624
|
type CustomModelSettings = ModelParams["1"] & {
|
|
625
625
|
baseURL?: string;
|
|
626
626
|
apiKey?: string;
|
|
@@ -747,9 +747,7 @@ declare class WorkflowAgents {
|
|
|
747
747
|
context: WorkflowContext;
|
|
748
748
|
provider: TProvider;
|
|
749
749
|
providerParams?: Omit<Required<Parameters<TProvider>>[0], "fetch">;
|
|
750
|
-
agentCallParams
|
|
751
|
-
* creates an openai model for agents
|
|
752
|
-
*/: AgentCallParams;
|
|
750
|
+
agentCallParams?: AgentCallParams;
|
|
753
751
|
}) => ReturnType<TProvider>;
|
|
754
752
|
}
|
|
755
753
|
|
|
@@ -879,12 +877,43 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
879
877
|
* Number of retries
|
|
880
878
|
*/
|
|
881
879
|
readonly retries: number;
|
|
880
|
+
/**
|
|
881
|
+
* Delay between retries.
|
|
882
|
+
*
|
|
883
|
+
* By default, the `retryDelay` is exponential backoff.
|
|
884
|
+
* More details can be found in: https://upstash.com/docs/qstash/features/retry.
|
|
885
|
+
*
|
|
886
|
+
* The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
|
|
887
|
+
*
|
|
888
|
+
* You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
|
|
889
|
+
* The special variable `retried` represents the current retry attempt count (starting from 0).
|
|
890
|
+
*
|
|
891
|
+
* Supported functions:
|
|
892
|
+
* - `pow`
|
|
893
|
+
* - `sqrt`
|
|
894
|
+
* - `abs`
|
|
895
|
+
* - `exp`
|
|
896
|
+
* - `floor`
|
|
897
|
+
* - `ceil`
|
|
898
|
+
* - `round`
|
|
899
|
+
* - `min`
|
|
900
|
+
* - `max`
|
|
901
|
+
*
|
|
902
|
+
* Examples of valid `retryDelay` values:
|
|
903
|
+
* ```ts
|
|
904
|
+
* 1000 // 1 second
|
|
905
|
+
* 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
|
|
906
|
+
* pow(2, retried) // 2 to the power of the current retry attempt
|
|
907
|
+
* max(10, pow(2, retried)) // The greater of 10 or 2^retried
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
readonly retryDelay?: string;
|
|
882
911
|
/**
|
|
883
912
|
* Settings for controlling the number of active requests
|
|
884
913
|
* and number of requests per second with the same key.
|
|
885
914
|
*/
|
|
886
915
|
readonly flowControl?: FlowControl;
|
|
887
|
-
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, invokeCount, flowControl, }: {
|
|
916
|
+
constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, retryDelay, telemetry, invokeCount, flowControl, }: {
|
|
888
917
|
qstashClient: WorkflowClient;
|
|
889
918
|
workflowRunId: string;
|
|
890
919
|
headers: Headers;
|
|
@@ -895,6 +924,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
895
924
|
initialPayload: TInitialPayload;
|
|
896
925
|
env?: Record<string, string | undefined>;
|
|
897
926
|
retries?: number;
|
|
927
|
+
retryDelay?: string;
|
|
898
928
|
telemetry?: Telemetry;
|
|
899
929
|
invokeCount?: number;
|
|
900
930
|
flowControl?: FlowControl;
|
|
@@ -977,6 +1007,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
977
1007
|
* @param body call body
|
|
978
1008
|
* @param headers call headers
|
|
979
1009
|
* @param retries number of call retries. 0 by default
|
|
1010
|
+
* @param retryDelay delay / time gap between retries.
|
|
980
1011
|
* @param timeout max duration to wait for the endpoint to respond. in seconds.
|
|
981
1012
|
* @returns call result as {
|
|
982
1013
|
* status: number;
|
|
@@ -994,7 +1025,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
994
1025
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
995
1026
|
*
|
|
996
1027
|
*```ts
|
|
997
|
-
* const result = await workflow.waitForEvent("payment-confirmed", {
|
|
1028
|
+
* const result = await workflow.waitForEvent("payment-confirmed", "payment.confirmed", {
|
|
998
1029
|
* timeout: "5m"
|
|
999
1030
|
* });
|
|
1000
1031
|
*```
|
|
@@ -1020,11 +1051,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
1020
1051
|
* @param stepName
|
|
1021
1052
|
* @param eventId - Unique identifier for the event to wait for
|
|
1022
1053
|
* @param options - Configuration options.
|
|
1023
|
-
* @returns `{ timeout: boolean, eventData:
|
|
1054
|
+
* @returns `{ timeout: boolean, eventData: TEventData }`.
|
|
1024
1055
|
* The `timeout` property specifies if the workflow has timed out. The `eventData`
|
|
1025
1056
|
* is the data passed when notifying this workflow of an event.
|
|
1026
1057
|
*/
|
|
1027
|
-
waitForEvent(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse
|
|
1058
|
+
waitForEvent<TEventData = unknown>(stepName: string, eventId: string, options?: WaitEventOptions): Promise<WaitStepResponse<TEventData>>;
|
|
1028
1059
|
/**
|
|
1029
1060
|
* Notify workflow runs waiting for an event
|
|
1030
1061
|
*
|
|
@@ -1169,6 +1200,16 @@ type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResu
|
|
|
1169
1200
|
type ParallelCallState = "first" | "partial" | "discard" | "last";
|
|
1170
1201
|
type RouteFunction<TInitialPayload, TResult = unknown> = (context: WorkflowContext<TInitialPayload>) => Promise<TResult>;
|
|
1171
1202
|
type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended" | WorkflowNonRetryableError;
|
|
1203
|
+
type DetailedFinishCondition = {
|
|
1204
|
+
condition: Exclude<FinishCondition, WorkflowNonRetryableError | "failure-callback">;
|
|
1205
|
+
result?: never;
|
|
1206
|
+
} | {
|
|
1207
|
+
condition: "non-retryable-error";
|
|
1208
|
+
result: WorkflowNonRetryableError;
|
|
1209
|
+
} | {
|
|
1210
|
+
condition: "failure-callback";
|
|
1211
|
+
result: string | void;
|
|
1212
|
+
};
|
|
1172
1213
|
type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
|
|
1173
1214
|
/**
|
|
1174
1215
|
* QStash client
|
|
@@ -1180,7 +1221,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1180
1221
|
* @param workflowRunId
|
|
1181
1222
|
* @returns response
|
|
1182
1223
|
*/
|
|
1183
|
-
onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition) => TResponse;
|
|
1224
|
+
onStepFinish?: (workflowRunId: string, finishCondition: FinishCondition, detailedFinishCondition?: DetailedFinishCondition) => TResponse;
|
|
1184
1225
|
/**
|
|
1185
1226
|
* Url of the endpoint where the workflow is set up.
|
|
1186
1227
|
*
|
|
@@ -1228,7 +1269,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1228
1269
|
failStatus: number;
|
|
1229
1270
|
failResponse: string;
|
|
1230
1271
|
failHeaders: Record<string, string[]>;
|
|
1231
|
-
}) => Promise<void> | void;
|
|
1272
|
+
}) => Promise<void | string> | void | string;
|
|
1232
1273
|
/**
|
|
1233
1274
|
* Base Url of the workflow endpoint
|
|
1234
1275
|
*
|
|
@@ -1255,6 +1296,37 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
|
|
|
1255
1296
|
* @default 3
|
|
1256
1297
|
*/
|
|
1257
1298
|
retries?: number;
|
|
1299
|
+
/**
|
|
1300
|
+
* Delay between retries.
|
|
1301
|
+
*
|
|
1302
|
+
* By default, the `retryDelay` is exponential backoff.
|
|
1303
|
+
* More details can be found in: https://upstash.com/docs/qstash/features/retry.
|
|
1304
|
+
*
|
|
1305
|
+
* The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
|
|
1306
|
+
*
|
|
1307
|
+
* You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
|
|
1308
|
+
* The special variable `retried` represents the current retry attempt count (starting from 0).
|
|
1309
|
+
*
|
|
1310
|
+
* Supported functions:
|
|
1311
|
+
* - `pow`
|
|
1312
|
+
* - `sqrt`
|
|
1313
|
+
* - `abs`
|
|
1314
|
+
* - `exp`
|
|
1315
|
+
* - `floor`
|
|
1316
|
+
* - `ceil`
|
|
1317
|
+
* - `round`
|
|
1318
|
+
* - `min`
|
|
1319
|
+
* - `max`
|
|
1320
|
+
*
|
|
1321
|
+
* Examples of valid `retryDelay` values:
|
|
1322
|
+
* ```ts
|
|
1323
|
+
* 1000 // 1 second
|
|
1324
|
+
* 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
|
|
1325
|
+
* pow(2, retried) // 2 to the power of the current retry attempt
|
|
1326
|
+
* max(10, pow(2, retried)) // The greater of 10 or 2^retried
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
retryDelay?: string;
|
|
1258
1330
|
/**
|
|
1259
1331
|
* Whether the framework should use `content-type: application/json`
|
|
1260
1332
|
* in `triggerFirstInvocation`.
|
|
@@ -1340,7 +1412,7 @@ type WaitRequest = {
|
|
|
1340
1412
|
timeoutBody?: string;
|
|
1341
1413
|
timeoutHeaders?: Record<string, string[]>;
|
|
1342
1414
|
};
|
|
1343
|
-
type WaitStepResponse = {
|
|
1415
|
+
type WaitStepResponse<TEventData = unknown> = {
|
|
1344
1416
|
/**
|
|
1345
1417
|
* whether the wait for event step timed out. false if
|
|
1346
1418
|
* the step is notified
|
|
@@ -1349,7 +1421,7 @@ type WaitStepResponse = {
|
|
|
1349
1421
|
/**
|
|
1350
1422
|
* body passed in notify request
|
|
1351
1423
|
*/
|
|
1352
|
-
eventData:
|
|
1424
|
+
eventData: TEventData;
|
|
1353
1425
|
};
|
|
1354
1426
|
type NotifyStepResponse = {
|
|
1355
1427
|
/**
|
|
@@ -1393,6 +1465,7 @@ type CallSettings<TBody = unknown> = {
|
|
|
1393
1465
|
body?: TBody;
|
|
1394
1466
|
headers?: Record<string, string>;
|
|
1395
1467
|
retries?: number;
|
|
1468
|
+
retryDelay?: string;
|
|
1396
1469
|
timeout?: Duration | number;
|
|
1397
1470
|
flowControl?: FlowControl;
|
|
1398
1471
|
};
|
|
@@ -1421,6 +1494,10 @@ type HeaderParams = {
|
|
|
1421
1494
|
* retry setting of requests except context.call
|
|
1422
1495
|
*/
|
|
1423
1496
|
retries?: number;
|
|
1497
|
+
/**
|
|
1498
|
+
* retry delay to include in headers.
|
|
1499
|
+
*/
|
|
1500
|
+
retryDelay?: string;
|
|
1424
1501
|
/**
|
|
1425
1502
|
* telemetry to include in timeoutHeaders.
|
|
1426
1503
|
*
|
|
@@ -1445,6 +1522,10 @@ type HeaderParams = {
|
|
|
1445
1522
|
* number of retries in context.call
|
|
1446
1523
|
*/
|
|
1447
1524
|
callRetries?: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* retry delay to include in headers.
|
|
1527
|
+
*/
|
|
1528
|
+
callRetryDelay?: string;
|
|
1448
1529
|
/**
|
|
1449
1530
|
* timeout duration in context.call
|
|
1450
1531
|
*/
|
|
@@ -1468,6 +1549,12 @@ type HeaderParams = {
|
|
|
1468
1549
|
* set to never because this is not a context.call step
|
|
1469
1550
|
*/
|
|
1470
1551
|
callRetries?: never;
|
|
1552
|
+
/**
|
|
1553
|
+
* retry delay to include in headers.
|
|
1554
|
+
*
|
|
1555
|
+
* set to never because this is not a context.call step
|
|
1556
|
+
*/
|
|
1557
|
+
callRetryDelay?: never;
|
|
1471
1558
|
/**
|
|
1472
1559
|
* timeout duration in context.call
|
|
1473
1560
|
*
|
|
@@ -1493,7 +1580,7 @@ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
|
1493
1580
|
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult>, "routeFunction" | "workflowId" | "options">;
|
|
1494
1581
|
body: TInitiaPayload;
|
|
1495
1582
|
workflowRunId?: string;
|
|
1496
|
-
} & Pick<CallSettings, "retries" | "headers" | "flowControl">;
|
|
1583
|
+
} & Pick<CallSettings, "retries" | "headers" | "flowControl" | "retryDelay">;
|
|
1497
1584
|
type InvokeStepResponse<TBody> = {
|
|
1498
1585
|
body: TBody;
|
|
1499
1586
|
isCanceled?: boolean;
|
|
@@ -1505,4 +1592,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
|
|
|
1505
1592
|
workflowId?: string;
|
|
1506
1593
|
};
|
|
1507
1594
|
|
|
1508
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type
|
|
1595
|
+
export { type AsyncStepFunction as A, WorkflowLogger as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, 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 CallSettings as v, type InvokeStepResponse as w, type InvokableWorkflow as x, type LogLevel as y, type WorkflowLoggerOptions as z };
|