@upstash/workflow 1.4.0 → 1.5.0
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/README.md +9 -0
- package/astro.d.mts +19 -2
- package/astro.d.ts +19 -2
- package/astro.js +670 -159
- package/astro.mjs +1 -1
- package/{chunk-DRHEHWMS.mjs → chunk-J3PXPHSB.mjs} +828 -317
- package/cloudflare.d.mts +17 -2
- package/cloudflare.d.ts +17 -2
- package/cloudflare.js +670 -159
- package/cloudflare.mjs +1 -1
- package/docs/agents/examples.mdx +8 -0
- package/docs/agents/features.mdx +374 -0
- package/docs/agents/getting-started.mdx +139 -0
- package/docs/agents/overview.mdx +40 -0
- package/docs/agents/patterns/evaluator-optimizer.mdx +72 -0
- package/docs/agents/patterns/orchestrator-workers.mdx +95 -0
- package/docs/agents/patterns/parallelization.mdx +77 -0
- package/docs/agents/patterns/prompt-chaining.mdx +84 -0
- package/docs/basics/best-practices/at-least-one-step.mdx +57 -0
- package/docs/basics/best-practices/business-logic-in-steps.mdx +52 -0
- package/docs/basics/best-practices/deterministic-code.mdx +132 -0
- package/docs/basics/best-practices/idempotency.mdx +38 -0
- package/docs/basics/best-practices/nested-context-methods.mdx +38 -0
- package/docs/basics/best-practices/overview.mdx +35 -0
- package/docs/basics/best-practices/promise-any.mdx +9 -0
- package/docs/basics/best-practices/return-step-results.mdx +80 -0
- package/docs/basics/best-practices/workflow-limits.mdx +62 -0
- package/docs/basics/client/cancel.mdx +137 -0
- package/docs/basics/client/dlq/callback.mdx +21 -0
- package/docs/basics/client/dlq/delete.mdx +120 -0
- package/docs/basics/client/dlq/list.mdx +96 -0
- package/docs/basics/client/dlq/restart.mdx +164 -0
- package/docs/basics/client/dlq/resume.mdx +167 -0
- package/docs/basics/client/logs.mdx +139 -0
- package/docs/basics/client/notify.mdx +79 -0
- package/docs/basics/client/trigger.mdx +139 -0
- package/docs/basics/client/waiters.mdx +31 -0
- package/docs/basics/client.mdx +40 -0
- package/docs/basics/how.mdx +65 -0
- package/docs/basics/serve/advanced.mdx +435 -0
- package/docs/basics/serve.mdx +142 -0
- package/docs/changelog.mdx +174 -0
- package/docs/examples/allInOne.mdx +377 -0
- package/docs/examples/authWebhook.mdx +567 -0
- package/docs/examples/customRetry.mdx +309 -0
- package/docs/examples/customerOnboarding.mdx +230 -0
- package/docs/examples/dynamicWorkflow.mdx +203 -0
- package/docs/examples/eCommerceOrderFulfillment.mdx +281 -0
- package/docs/examples/imageProcessing.mdx +339 -0
- package/docs/examples/paymentRetry.mdx +438 -0
- package/docs/examples/waitForEvent.mdx +201 -0
- package/docs/features/dlq/callback.mdx +42 -0
- package/docs/features/dlq/delete.mdx +29 -0
- package/docs/features/dlq/restart.mdx +33 -0
- package/docs/features/dlq/resume.mdx +37 -0
- package/docs/features/dlq.mdx +39 -0
- package/docs/features/failure-callback.mdx +102 -0
- package/docs/features/failureFunction/advanced.mdx +36 -0
- package/docs/features/failureFunction/reliability.mdx +33 -0
- package/docs/features/flow-control/monitor.mdx +22 -0
- package/docs/features/flow-control/parallelism.mdx +45 -0
- package/docs/features/flow-control/rate-period.mdx +46 -0
- package/docs/features/flow-control.mdx +164 -0
- package/docs/features/invoke/serveMany.mdx +109 -0
- package/docs/features/invoke.mdx +39 -0
- package/docs/features/notify.mdx +127 -0
- package/docs/features/parallel-steps.mdx +41 -0
- package/docs/features/retries/prevent-retries.mdx +140 -0
- package/docs/features/retries.mdx +93 -0
- package/docs/features/wait-for-event.mdx +104 -0
- package/docs/features/wait.mdx +44 -0
- package/docs/features/webhooks.mdx +116 -0
- package/docs/getstarted.mdx +200 -0
- package/docs/howto/cancel.mdx +50 -0
- package/docs/howto/changes.mdx +33 -0
- package/docs/howto/configure.mdx +42 -0
- package/docs/howto/failures.mdx +185 -0
- package/docs/howto/get-token.mdx +18 -0
- package/docs/howto/local-development/development-server.mdx +130 -0
- package/docs/howto/local-development/local-tunnel.mdx +73 -0
- package/docs/howto/middlewares.mdx +263 -0
- package/docs/howto/migrations.mdx +335 -0
- package/docs/howto/multi-region.mdx +107 -0
- package/docs/howto/parallel-runs.mdx +52 -0
- package/docs/howto/readonly-token.mdx +19 -0
- package/docs/howto/realtime/basic.mdx +315 -0
- package/docs/howto/realtime/human-in-the-loop.mdx +454 -0
- package/docs/howto/redact-fields.mdx +61 -0
- package/docs/howto/retry-now.mdx +41 -0
- package/docs/howto/schedule.mdx +104 -0
- package/docs/howto/security.mdx +143 -0
- package/docs/howto/singleton.mdx +137 -0
- package/docs/howto/start.mdx +69 -0
- package/docs/howto/use-webhooks.mdx +256 -0
- package/docs/integrations/aisdk.mdx +316 -0
- package/docs/integrations/anthropic.mdx +51 -0
- package/docs/integrations/datadog.mdx +69 -0
- package/docs/integrations/openai.mdx +87 -0
- package/docs/integrations/prometheus.mdx +65 -0
- package/docs/integrations/resend.mdx +82 -0
- package/docs/llms-txt.mdx +4 -0
- package/docs/openapi.yaml +2944 -0
- package/docs/pricing.mdx +22 -0
- package/docs/quickstarts/astro.mdx +185 -0
- package/docs/quickstarts/cloudflare-workers.mdx +190 -0
- package/docs/quickstarts/express.mdx +190 -0
- package/docs/quickstarts/fastapi.mdx +282 -0
- package/docs/quickstarts/flask.mdx +282 -0
- package/docs/quickstarts/hono.mdx +221 -0
- package/docs/quickstarts/nextjs-fastapi.mdx +147 -0
- package/docs/quickstarts/nextjs-flask.mdx +147 -0
- package/docs/quickstarts/nuxt.mdx +169 -0
- package/docs/quickstarts/platforms.mdx +78 -0
- package/docs/quickstarts/solidjs.mdx +161 -0
- package/docs/quickstarts/svelte.mdx +170 -0
- package/docs/quickstarts/tanstack-start.mdx +205 -0
- package/docs/quickstarts/vercel-nextjs.mdx +233 -0
- package/docs/roadmap.mdx +8 -0
- package/docs/sdk/workflow-js.mdx +4 -0
- package/docs/sdk/workflow-py.mdx +4 -0
- package/docs/steps/api.mdx +64 -0
- package/docs/steps/call.mdx +183 -0
- package/docs/steps/cancel.mdx +25 -0
- package/docs/steps/createWebhook.mdx +40 -0
- package/docs/steps/invoke.mdx +100 -0
- package/docs/steps/notify.mdx +105 -0
- package/docs/steps/run.mdx +150 -0
- package/docs/steps/sleep.mdx +97 -0
- package/docs/steps/sleepUntil.mdx +88 -0
- package/docs/steps/waitForEvent.mdx +60 -0
- package/docs/steps/waitForWebhook.mdx +78 -0
- package/docs/steps.mdx +108 -0
- package/docs/troubleshooting/general.mdx +331 -0
- package/docs/troubleshooting/vercel.mdx +82 -0
- package/express.d.mts +19 -2
- package/express.d.ts +19 -2
- package/express.js +670 -159
- package/express.mjs +1 -1
- package/h3.d.mts +19 -2
- package/h3.d.ts +19 -2
- package/h3.js +670 -159
- package/h3.mjs +1 -1
- package/hono.d.mts +17 -2
- package/hono.d.ts +17 -2
- package/hono.js +670 -159
- package/hono.mjs +1 -1
- package/index.d.mts +50 -21
- package/index.d.ts +50 -21
- package/index.js +686 -171
- package/index.mjs +17 -13
- package/nextjs.d.mts +40 -2
- package/nextjs.d.ts +40 -2
- package/nextjs.js +670 -159
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/react-router.d.mts +16 -2
- package/react-router.d.ts +16 -2
- package/react-router.js +670 -159
- package/react-router.mjs +1 -1
- package/{serve-many-CG3BFvO3.d.mts → serve-many-BKukvLNl.d.mts} +1 -1
- package/{serve-many-iJF1IUXk.d.ts → serve-many-CrLKQpuZ.d.ts} +1 -1
- package/solidjs.d.mts +10 -1
- package/solidjs.d.ts +10 -1
- package/solidjs.js +670 -159
- package/solidjs.mjs +1 -1
- package/src/platforms/astro.ts +84 -0
- package/src/platforms/cloudflare.ts +127 -0
- package/src/platforms/express.ts +147 -0
- package/src/platforms/h3.ts +105 -0
- package/src/platforms/hono.ts +103 -0
- package/src/platforms/nextjs.ts +193 -0
- package/src/platforms/react-router.ts +92 -0
- package/src/platforms/solidjs.ts +59 -0
- package/src/platforms/svelte.ts +99 -0
- package/src/platforms/tanstack.ts +96 -0
- package/src/src/client/dlq.ts +387 -0
- package/src/src/client/filter-types.ts +166 -0
- package/src/src/client/index.ts +350 -0
- package/src/src/client/types.ts +501 -0
- package/src/src/client/utils.ts +307 -0
- package/src/src/constants.ts +82 -0
- package/src/src/context/api/anthropic.ts +58 -0
- package/src/src/context/api/base.ts +52 -0
- package/src/src/context/api/index.ts +24 -0
- package/src/src/context/api/openai.ts +125 -0
- package/src/src/context/api/resend.ts +57 -0
- package/src/src/context/auto-executor.ts +707 -0
- package/src/src/context/context.ts +681 -0
- package/src/src/context/index.ts +1 -0
- package/src/src/context/provider.ts +37 -0
- package/src/src/context/steps.ts +965 -0
- package/src/src/error.ts +203 -0
- package/src/src/index.ts +13 -0
- package/src/src/middleware/default-callbacks.ts +20 -0
- package/src/src/middleware/index.ts +2 -0
- package/src/src/middleware/logging.ts +39 -0
- package/src/src/middleware/manager.ts +148 -0
- package/src/src/middleware/middleware.ts +46 -0
- package/src/src/middleware/types.ts +72 -0
- package/src/src/qstash/headers.ts +397 -0
- package/src/src/qstash/step-config.ts +268 -0
- package/src/src/qstash/submit-steps.ts +284 -0
- package/src/src/serve/authorization.ts +118 -0
- package/src/src/serve/index.ts +475 -0
- package/src/src/serve/multi-region/handlers.ts +225 -0
- package/src/src/serve/multi-region/utils.ts +88 -0
- package/src/src/serve/options.ts +241 -0
- package/src/src/serve/serve-many.ts +117 -0
- package/src/src/serve/utils.ts +11 -0
- package/src/src/types.ts +590 -0
- package/src/src/utils.ts +141 -0
- package/src/src/workflow-parser.ts +472 -0
- package/src/src/workflow-requests.ts +575 -0
- package/svelte.d.mts +17 -2
- package/svelte.d.ts +17 -2
- package/svelte.js +670 -159
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +15 -2
- package/tanstack.d.ts +15 -2
- package/tanstack.js +670 -159
- package/tanstack.mjs +1 -1
- package/{types-CekOpKvz.d.ts → types-CrgK5P6p.d.mts} +372 -32
- package/{types-CekOpKvz.d.mts → types-CrgK5P6p.d.ts} +372 -32
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { FlowControl, HTTPMethods, PublishRequest } from "@upstash/qstash";
|
|
2
|
+
import { RawStep, StepType } from "../types";
|
|
3
|
+
|
|
4
|
+
type BaseStepLog = {
|
|
5
|
+
/**
|
|
6
|
+
* id of the step
|
|
7
|
+
*/
|
|
8
|
+
stepId?: number;
|
|
9
|
+
/**
|
|
10
|
+
* name of the step
|
|
11
|
+
*/
|
|
12
|
+
stepName: string;
|
|
13
|
+
/**
|
|
14
|
+
* type of the step (example: "call", "wait", "invoke")
|
|
15
|
+
*/
|
|
16
|
+
stepType: StepType;
|
|
17
|
+
/**
|
|
18
|
+
* call type of the step.
|
|
19
|
+
*
|
|
20
|
+
* in most cases it's `step`. For context.call, it will become `toCallback` and `fromCallback`
|
|
21
|
+
* as the step executes.
|
|
22
|
+
*/
|
|
23
|
+
callType: RawStep["callType"];
|
|
24
|
+
/**
|
|
25
|
+
* message id of the step
|
|
26
|
+
*/
|
|
27
|
+
messageId: string;
|
|
28
|
+
/**
|
|
29
|
+
* result of the step
|
|
30
|
+
*
|
|
31
|
+
* will be undefined for an unfinished parallel step.
|
|
32
|
+
*/
|
|
33
|
+
out: unknown;
|
|
34
|
+
/**
|
|
35
|
+
* number of retries for the step
|
|
36
|
+
*/
|
|
37
|
+
retries: number;
|
|
38
|
+
/**
|
|
39
|
+
* retry delay parameter for the step if it was set
|
|
40
|
+
*/
|
|
41
|
+
retryDelay?: string;
|
|
42
|
+
/**
|
|
43
|
+
* number of parallel steps
|
|
44
|
+
*
|
|
45
|
+
* if the step is sequential (non-parallel), will be 1.
|
|
46
|
+
*/
|
|
47
|
+
concurrent: number;
|
|
48
|
+
/**
|
|
49
|
+
* state of the step
|
|
50
|
+
*/
|
|
51
|
+
state: "STEP_PROGRESS" | "STEP_SUCCESS" | "STEP_RETRY" | "STEP_FAILED";
|
|
52
|
+
/**
|
|
53
|
+
* time when the step was created
|
|
54
|
+
*/
|
|
55
|
+
createdAt: number;
|
|
56
|
+
/**
|
|
57
|
+
* headers
|
|
58
|
+
*/
|
|
59
|
+
headers: Record<string, string[]>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type CallUrlGroup = {
|
|
63
|
+
/**
|
|
64
|
+
* URL called in context.call
|
|
65
|
+
*/
|
|
66
|
+
callUrl: string;
|
|
67
|
+
/**
|
|
68
|
+
* Method used in context.call
|
|
69
|
+
*/
|
|
70
|
+
callMethod: HTTPMethods;
|
|
71
|
+
/**
|
|
72
|
+
* headers sent in context.call
|
|
73
|
+
*/
|
|
74
|
+
callHeaders: Record<string, string[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Body sent in context.call
|
|
77
|
+
*/
|
|
78
|
+
callBody: unknown;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type CallResponseStatusGroup = {
|
|
82
|
+
/**
|
|
83
|
+
* Status code of the context.call response
|
|
84
|
+
*/
|
|
85
|
+
callResponseStatus: number;
|
|
86
|
+
/**
|
|
87
|
+
* Response body of the context.call response
|
|
88
|
+
*/
|
|
89
|
+
callResponseBody: unknown;
|
|
90
|
+
/**
|
|
91
|
+
* Headers received from the context.call response
|
|
92
|
+
*/
|
|
93
|
+
callResponseHeaders: Record<string, string[]>;
|
|
94
|
+
} & CallUrlGroup;
|
|
95
|
+
|
|
96
|
+
type InvokedWorkflowGroup = {
|
|
97
|
+
/**
|
|
98
|
+
* id of the workflow run invoked in context.invoke
|
|
99
|
+
*/
|
|
100
|
+
invokedWorkflowRunId: string;
|
|
101
|
+
/**
|
|
102
|
+
* URL of the workflow invoked in context.invoke
|
|
103
|
+
*/
|
|
104
|
+
invokedWorkflowUrl: string;
|
|
105
|
+
/**
|
|
106
|
+
* Time when the workflow was invoked
|
|
107
|
+
*/
|
|
108
|
+
invokedWorkflowCreatedAt: number;
|
|
109
|
+
/**
|
|
110
|
+
* Body sent in context.invoke
|
|
111
|
+
*/
|
|
112
|
+
invokedWorkflowRunBody: unknown;
|
|
113
|
+
/**
|
|
114
|
+
* Headers sent in context.invoke
|
|
115
|
+
*/
|
|
116
|
+
invokedWorkflowRunHeaders: Record<string, string[]>;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type WaitEventGroup = {
|
|
120
|
+
/**
|
|
121
|
+
* id of the event waited in context.waitForEvent
|
|
122
|
+
*/
|
|
123
|
+
waitEventId: string;
|
|
124
|
+
/**
|
|
125
|
+
* Duration until the time when the event will be triggered due to timeout
|
|
126
|
+
*/
|
|
127
|
+
waitTimeoutDuration: string;
|
|
128
|
+
/**
|
|
129
|
+
* Time when the event will be triggered due to timeout
|
|
130
|
+
*/
|
|
131
|
+
waitTimeoutDeadline: number;
|
|
132
|
+
/**
|
|
133
|
+
* Whether the event was triggered due to timeout
|
|
134
|
+
*/
|
|
135
|
+
waitTimeout: boolean;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
type AsOptional<TType> = TType | { [P in keyof TType]?: never };
|
|
139
|
+
|
|
140
|
+
export type StepLog = BaseStepLog &
|
|
141
|
+
AsOptional<CallUrlGroup> &
|
|
142
|
+
AsOptional<CallResponseStatusGroup> &
|
|
143
|
+
AsOptional<InvokedWorkflowGroup> &
|
|
144
|
+
AsOptional<{ sleepFor: number }> &
|
|
145
|
+
AsOptional<{ sleepUntil: number }> &
|
|
146
|
+
AsOptional<WaitEventGroup>;
|
|
147
|
+
|
|
148
|
+
export type StepError = {
|
|
149
|
+
/**
|
|
150
|
+
* error message associated with the request
|
|
151
|
+
*
|
|
152
|
+
* example:
|
|
153
|
+
* ```
|
|
154
|
+
* detected a non-workflow destination for trigger/invoke.
|
|
155
|
+
* make sure you are sending the request to the correct endpoint
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
error: string;
|
|
159
|
+
/**
|
|
160
|
+
* response body returned in the request which resulted in an error
|
|
161
|
+
*/
|
|
162
|
+
body: string;
|
|
163
|
+
headers: Record<string, string[]>;
|
|
164
|
+
status: number;
|
|
165
|
+
time: number;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
type StepLogGroup =
|
|
169
|
+
| {
|
|
170
|
+
/**
|
|
171
|
+
* Log which belongs to a single step
|
|
172
|
+
*/
|
|
173
|
+
steps: [StepLog];
|
|
174
|
+
/**
|
|
175
|
+
* Log which belongs to a single step
|
|
176
|
+
*/
|
|
177
|
+
type: "sequential";
|
|
178
|
+
}
|
|
179
|
+
| {
|
|
180
|
+
/**
|
|
181
|
+
* Log which belongs to parallel steps
|
|
182
|
+
*/
|
|
183
|
+
steps: StepLog[];
|
|
184
|
+
/**
|
|
185
|
+
* Log which belongs to parallel steps
|
|
186
|
+
*/
|
|
187
|
+
type: "parallel";
|
|
188
|
+
}
|
|
189
|
+
| {
|
|
190
|
+
/**
|
|
191
|
+
* Log which belongs to the next step
|
|
192
|
+
*/
|
|
193
|
+
steps: {
|
|
194
|
+
messageId: string;
|
|
195
|
+
/**
|
|
196
|
+
* name of the step being run.
|
|
197
|
+
*
|
|
198
|
+
* only available when the SDK reported it while the step was failing
|
|
199
|
+
* (via the `Upstash-Error-Step-Name` response header).
|
|
200
|
+
*/
|
|
201
|
+
stepName?: string;
|
|
202
|
+
state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED" | "STEP_CANCELED";
|
|
203
|
+
/**
|
|
204
|
+
* retries
|
|
205
|
+
*/
|
|
206
|
+
retries: number;
|
|
207
|
+
/**
|
|
208
|
+
* retry delay parameter for the step if it was set
|
|
209
|
+
*/
|
|
210
|
+
retryDelay?: string;
|
|
211
|
+
/**
|
|
212
|
+
* errors which occured in the step
|
|
213
|
+
*/
|
|
214
|
+
errors?: StepError[];
|
|
215
|
+
}[];
|
|
216
|
+
/**
|
|
217
|
+
* Log which belongs to the next step
|
|
218
|
+
*/
|
|
219
|
+
type: "next";
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* State of the failure function (`failureUrl`/`failureFunction`) call of a
|
|
224
|
+
* failed workflow run.
|
|
225
|
+
*/
|
|
226
|
+
export type FailureFunctionState =
|
|
227
|
+
| "CALLBACK_INPROGRESS"
|
|
228
|
+
| "CALLBACK_SUCCESS"
|
|
229
|
+
| "CALLBACK_FAIL"
|
|
230
|
+
| "CALLBACK_CANCELED";
|
|
231
|
+
|
|
232
|
+
type FailureFunctionLog = {
|
|
233
|
+
/**
|
|
234
|
+
* messageId of the message published for handling the failure
|
|
235
|
+
*/
|
|
236
|
+
messageId: string;
|
|
237
|
+
/**
|
|
238
|
+
* URL of the function that handles the failure
|
|
239
|
+
*/
|
|
240
|
+
url: string;
|
|
241
|
+
/**
|
|
242
|
+
* State of the message published for failure
|
|
243
|
+
*/
|
|
244
|
+
state: FailureFunctionState;
|
|
245
|
+
/**
|
|
246
|
+
* Headers received from the step which caused the workflow to fail
|
|
247
|
+
*/
|
|
248
|
+
failHeaders: Record<string, string[]>;
|
|
249
|
+
/**
|
|
250
|
+
* Status code of the step which caused the workflow to fail
|
|
251
|
+
*/
|
|
252
|
+
failStatus: number;
|
|
253
|
+
/**
|
|
254
|
+
* Response body of the step which caused the workflow to fail
|
|
255
|
+
*/
|
|
256
|
+
failResponse: string;
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated use dlqId field of the workflow run itself
|
|
259
|
+
*/
|
|
260
|
+
dlqId: string;
|
|
261
|
+
/**
|
|
262
|
+
* Errors received while running failure function
|
|
263
|
+
*/
|
|
264
|
+
errors?: StepError[];
|
|
265
|
+
/**
|
|
266
|
+
* String body returned from the failure function
|
|
267
|
+
*/
|
|
268
|
+
responseBody?: string;
|
|
269
|
+
/**
|
|
270
|
+
* Headers received from the failure function
|
|
271
|
+
*/
|
|
272
|
+
responseHeaders?: Record<string, string[]>;
|
|
273
|
+
/**
|
|
274
|
+
* Status code of the response from the failure function
|
|
275
|
+
*/
|
|
276
|
+
responseStatus?: number;
|
|
277
|
+
nextDeliveryTime?: number;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export type WorkflowRunLog = {
|
|
281
|
+
/**
|
|
282
|
+
* Unique identifier for the workflow run
|
|
283
|
+
*/
|
|
284
|
+
workflowRunId: string;
|
|
285
|
+
/**
|
|
286
|
+
* URL of the workflow that was run
|
|
287
|
+
*/
|
|
288
|
+
workflowUrl: string;
|
|
289
|
+
/**
|
|
290
|
+
* State of the workflow run
|
|
291
|
+
*
|
|
292
|
+
* - RUN_STARTED: Workflow run has started and is in progress
|
|
293
|
+
* - RUN_SUCCESS: Workflow run has completed successfully
|
|
294
|
+
* - RUN_FAILED: Workflow run has failed
|
|
295
|
+
*/
|
|
296
|
+
workflowState: "RUN_STARTED" | "RUN_SUCCESS" | "RUN_FAILED" | "RUN_CANCELED";
|
|
297
|
+
/**
|
|
298
|
+
* Time when the workflow run was created
|
|
299
|
+
*
|
|
300
|
+
* in unix milliseconds format
|
|
301
|
+
*/
|
|
302
|
+
workflowRunCreatedAt: number;
|
|
303
|
+
/**
|
|
304
|
+
* Time when the workflow run was completed
|
|
305
|
+
*
|
|
306
|
+
* in unix milliseconds format
|
|
307
|
+
*/
|
|
308
|
+
workflowRunCompletedAt?: number;
|
|
309
|
+
/**
|
|
310
|
+
* Message published when the workflow fails if failureUrl or failureFunction
|
|
311
|
+
* are set.
|
|
312
|
+
*/
|
|
313
|
+
failureFunction?: FailureFunctionLog;
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
*/
|
|
317
|
+
steps: StepLogGroup[];
|
|
318
|
+
/**
|
|
319
|
+
* If the workflow returned a response, the stringified state of this
|
|
320
|
+
* response will be available in the workflowRunResponse field.
|
|
321
|
+
*
|
|
322
|
+
* To restore it to its original format, use JSON.parse.
|
|
323
|
+
*/
|
|
324
|
+
workflowRunResponse?: string;
|
|
325
|
+
/**
|
|
326
|
+
* Information on the invoker workflow run, if any
|
|
327
|
+
*/
|
|
328
|
+
invoker?: {
|
|
329
|
+
/**
|
|
330
|
+
* run id of the invoker workflow
|
|
331
|
+
*/
|
|
332
|
+
workflowRunId: string;
|
|
333
|
+
/**
|
|
334
|
+
* URL of the invoker workflow
|
|
335
|
+
*/
|
|
336
|
+
workflowUrl: string;
|
|
337
|
+
/**
|
|
338
|
+
* Time when the invoker workflow run was created
|
|
339
|
+
*
|
|
340
|
+
* in unix milliseconds format
|
|
341
|
+
*/
|
|
342
|
+
workflowRunCreatedAt: number;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* If the workflow run has failed, id of the run in DLQ
|
|
346
|
+
*/
|
|
347
|
+
dlqId?: string;
|
|
348
|
+
/**
|
|
349
|
+
* Label of the workflow run.
|
|
350
|
+
*
|
|
351
|
+
* @deprecated Use `labels` instead. When a run has multiple labels, this
|
|
352
|
+
* field only contains the first one.
|
|
353
|
+
*/
|
|
354
|
+
label?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Labels attached to the workflow run.
|
|
357
|
+
*
|
|
358
|
+
* A run can have multiple labels when triggered with `label: string[]`.
|
|
359
|
+
*/
|
|
360
|
+
labels?: string[];
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export type WorkflowRunLogs = {
|
|
364
|
+
cursor: string;
|
|
365
|
+
runs: WorkflowRunLog[];
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/trigger.mdx
|
|
370
|
+
*/
|
|
371
|
+
export type TriggerOptions = {
|
|
372
|
+
/**
|
|
373
|
+
* URL of the workflow to trigger
|
|
374
|
+
*/
|
|
375
|
+
url: string;
|
|
376
|
+
/**
|
|
377
|
+
* Body to send to the workflow
|
|
378
|
+
*/
|
|
379
|
+
body?: unknown;
|
|
380
|
+
/**
|
|
381
|
+
* Headers to send to the workflow
|
|
382
|
+
*/
|
|
383
|
+
headers?: Record<string, string>;
|
|
384
|
+
/**
|
|
385
|
+
* Workflow run id to use for the workflow run.
|
|
386
|
+
* If not provided, a random workflow run id will be generated.
|
|
387
|
+
*
|
|
388
|
+
* "wfr_" is prepended (and doubled if you include it). Use the returned
|
|
389
|
+
* `workflowRunId` for notify, cancel and logs.
|
|
390
|
+
*/
|
|
391
|
+
workflowRunId?: string;
|
|
392
|
+
/**
|
|
393
|
+
* Number of times each failed step of the run is retried.
|
|
394
|
+
*
|
|
395
|
+
* @default 3
|
|
396
|
+
*/
|
|
397
|
+
retries?: number;
|
|
398
|
+
/**
|
|
399
|
+
* Delay between retries.
|
|
400
|
+
*
|
|
401
|
+
* By default, the `retryDelay` is exponential backoff.
|
|
402
|
+
* More details can be found in: https://upstash.com/docs/qstash/features/retry.
|
|
403
|
+
*
|
|
404
|
+
* The `retryDelay` option allows you to customize the delay (in milliseconds) between retry attempts when message delivery fails.
|
|
405
|
+
*
|
|
406
|
+
* You can use mathematical expressions and the following built-in functions to calculate the delay dynamically.
|
|
407
|
+
* The special variable `retried` represents the current retry attempt count (starting from 0).
|
|
408
|
+
*
|
|
409
|
+
* Supported functions:
|
|
410
|
+
* - `pow`
|
|
411
|
+
* - `sqrt`
|
|
412
|
+
* - `abs`
|
|
413
|
+
* - `exp`
|
|
414
|
+
* - `floor`
|
|
415
|
+
* - `ceil`
|
|
416
|
+
* - `round`
|
|
417
|
+
* - `min`
|
|
418
|
+
* - `max`
|
|
419
|
+
*
|
|
420
|
+
* Examples of valid `retryDelay` values:
|
|
421
|
+
* ```ts
|
|
422
|
+
* 1000 // 1 second
|
|
423
|
+
* 1000 * (1 + retried) // 1 second multiplied by the current retry attempt
|
|
424
|
+
* pow(2, retried) // 2 to the power of the current retry attempt
|
|
425
|
+
* max(10, pow(2, retried)) // The greater of 10 or 2^retried
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
retryDelay?: string;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Flow control to use for the workflow run.
|
|
432
|
+
* If not provided, no flow control will be used.
|
|
433
|
+
*
|
|
434
|
+
* @see node_modules/@upstash/workflow/docs/features/flow-control.mdx
|
|
435
|
+
*/
|
|
436
|
+
flowControl?: FlowControl;
|
|
437
|
+
/**
|
|
438
|
+
* Delay to apply before triggering the workflow.
|
|
439
|
+
*/
|
|
440
|
+
delay?: PublishRequest["delay"];
|
|
441
|
+
/**
|
|
442
|
+
* Optionally set the absolute delay of this message.
|
|
443
|
+
* This will override the delay option.
|
|
444
|
+
* The message will not delivered until the specified time.
|
|
445
|
+
*
|
|
446
|
+
* Unix timestamp in seconds.
|
|
447
|
+
*
|
|
448
|
+
* @default undefined
|
|
449
|
+
*/
|
|
450
|
+
notBefore?: PublishRequest["notBefore"];
|
|
451
|
+
/**
|
|
452
|
+
* Label to apply to the workflow run.
|
|
453
|
+
*
|
|
454
|
+
* Can be used to filter the workflow run logs.
|
|
455
|
+
*
|
|
456
|
+
* Pass an array to attach multiple labels to a single workflow run; they are
|
|
457
|
+
* sent as a comma-separated value in the `Upstash-Label` header.
|
|
458
|
+
*/
|
|
459
|
+
label?: string | string[];
|
|
460
|
+
/**
|
|
461
|
+
* By default, Workflow SDK sends telemetry about SDK version, framework or runtime.
|
|
462
|
+
*
|
|
463
|
+
* Set `disableTelemetry` to disable this behavior.
|
|
464
|
+
*
|
|
465
|
+
* @default false
|
|
466
|
+
*/
|
|
467
|
+
disableTelemetry?: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* URL to call if the first request to the workflow endpoint fails
|
|
470
|
+
*/
|
|
471
|
+
failureUrl?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Configure which fields should be redacted in logs.
|
|
474
|
+
*
|
|
475
|
+
* - `{ body: true }` to redact the request body
|
|
476
|
+
* - `{ header: true }` to redact all headers
|
|
477
|
+
* - `{ header: ["Authorization"] }` to redact specific headers
|
|
478
|
+
*
|
|
479
|
+
* @default undefined
|
|
480
|
+
*/
|
|
481
|
+
redact?: {
|
|
482
|
+
body?: true;
|
|
483
|
+
header?: true | string[];
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/** @deprecated Use `resume(dlqId)` or `resume([dlqId1, dlqId2])` instead of `resume({ dlqId })` */
|
|
488
|
+
export type DLQResumeRestartOptions<TDLQId extends string | string[] = string | string[]> = {
|
|
489
|
+
dlqId: TDLQId;
|
|
490
|
+
} & Pick<TriggerOptions, "flowControl" | "retries">;
|
|
491
|
+
|
|
492
|
+
export type DLQResumeRestartResponse = {
|
|
493
|
+
/**
|
|
494
|
+
* id of the workflow run created to resume or restart the DLQ message
|
|
495
|
+
*/
|
|
496
|
+
workflowRunId: string;
|
|
497
|
+
/**
|
|
498
|
+
* Time when the new workflow run was created
|
|
499
|
+
*/
|
|
500
|
+
workflowCreatedAt: string;
|
|
501
|
+
};
|