@upstash/workflow 1.4.0-rc → 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 +18 -2
- package/astro.d.ts +18 -2
- package/astro.js +129 -29
- package/astro.mjs +1 -1
- package/{chunk-UH6O5IJY.mjs → chunk-J3PXPHSB.mjs} +129 -29
- package/cloudflare.d.mts +16 -2
- package/cloudflare.d.ts +16 -2
- package/cloudflare.js +129 -29
- 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 +18 -2
- package/express.d.ts +18 -2
- package/express.js +129 -29
- package/express.mjs +1 -1
- package/h3.d.mts +18 -2
- package/h3.d.ts +18 -2
- package/h3.js +129 -29
- package/h3.mjs +1 -1
- package/hono.d.mts +16 -2
- package/hono.d.ts +16 -2
- package/hono.js +129 -29
- package/hono.mjs +1 -1
- package/index.d.mts +49 -21
- package/index.d.ts +49 -21
- package/index.js +145 -41
- package/index.mjs +17 -13
- package/nextjs.d.mts +39 -2
- package/nextjs.d.ts +39 -2
- package/nextjs.js +129 -29
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/react-router.d.mts +15 -2
- package/react-router.d.ts +15 -2
- package/react-router.js +129 -29
- package/react-router.mjs +1 -1
- package/{serve-many-CbIV7145.d.mts → serve-many-BKukvLNl.d.mts} +1 -1
- package/{serve-many-BCtZg31b.d.ts → serve-many-CrLKQpuZ.d.ts} +1 -1
- package/solidjs.d.mts +9 -1
- package/solidjs.d.ts +9 -1
- package/solidjs.js +129 -29
- 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 +16 -2
- package/svelte.d.ts +16 -2
- package/svelte.js +129 -29
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +14 -2
- package/tanstack.d.ts +14 -2
- package/tanstack.js +129 -29
- package/tanstack.mjs +1 -1
- package/{types-ffLPVG5_.d.ts → types-CrgK5P6p.d.mts} +124 -24
- package/{types-ffLPVG5_.d.mts → types-CrgK5P6p.d.ts} +124 -24
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "client.dlq.resume"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `dlq.resume` method resumes one or more workflow runs from the **Dead Letter Queue (DLQ)** at the point where they previously failed.
|
|
6
|
+
This allows you to continue execution from the failed step instead of restarting the workflow from the beginning.
|
|
7
|
+
|
|
8
|
+
## Arguments
|
|
9
|
+
|
|
10
|
+
The first argument specifies which DLQ entries to resume. The optional second argument provides flow control and retry settings.
|
|
11
|
+
|
|
12
|
+
### By DLQ ID
|
|
13
|
+
|
|
14
|
+
Pass a single DLQ ID or an array of IDs directly:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
await client.dlq.resume("dlq-12345");
|
|
18
|
+
await client.dlq.resume(["dlq-12345", "dlq-67890"]);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### By filters
|
|
22
|
+
|
|
23
|
+
Pass an object with a `filter` field:
|
|
24
|
+
|
|
25
|
+
<ParamField body="filter" type="object">
|
|
26
|
+
<Expandable defaultOpen>
|
|
27
|
+
<ParamField body="workflowUrl" type="string" optional>
|
|
28
|
+
Filter by exact workflow URL.
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField body="workflowRunId" type="string" optional>
|
|
32
|
+
Filter by workflow run ID.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
<ParamField body="label" type="string | string[]" optional>
|
|
36
|
+
Resume workflows with this label. Pass an array to match runs that
|
|
37
|
+
have any of the given labels (OR semantics).
|
|
38
|
+
</ParamField>
|
|
39
|
+
|
|
40
|
+
<ParamField body="fromDate" type="Date | number" optional>
|
|
41
|
+
Resume workflows created after this date.
|
|
42
|
+
</ParamField>
|
|
43
|
+
|
|
44
|
+
<ParamField body="toDate" type="Date | number" optional>
|
|
45
|
+
Resume workflows created before this date.
|
|
46
|
+
</ParamField>
|
|
47
|
+
|
|
48
|
+
<ParamField body="callerIp" type="string" optional>
|
|
49
|
+
Filter by the IP address that triggered the workflow.
|
|
50
|
+
</ParamField>
|
|
51
|
+
|
|
52
|
+
<ParamField body="flowControlKey" type="string" optional>
|
|
53
|
+
Filter by flow control key.
|
|
54
|
+
</ParamField>
|
|
55
|
+
|
|
56
|
+
<ParamField body="workflowCreatedAt" type="number" optional>
|
|
57
|
+
Filter by workflow creation time (Unix timestamp in ms).
|
|
58
|
+
</ParamField>
|
|
59
|
+
|
|
60
|
+
<ParamField body="failureFunctionState" type="string" optional>
|
|
61
|
+
Filter by failure callback state.
|
|
62
|
+
</ParamField>
|
|
63
|
+
</Expandable>
|
|
64
|
+
</ParamField>
|
|
65
|
+
|
|
66
|
+
<ParamField body="count" type="number" optional>
|
|
67
|
+
Maximum number of messages to process per call. Defaults to `100`.
|
|
68
|
+
</ParamField>
|
|
69
|
+
|
|
70
|
+
<ParamField body="cursor" type="string" optional>
|
|
71
|
+
A pagination cursor from a previous request.
|
|
72
|
+
</ParamField>
|
|
73
|
+
|
|
74
|
+
### Resume all
|
|
75
|
+
|
|
76
|
+
<ParamField body="all" type="boolean">
|
|
77
|
+
Set to `true` to resume all DLQ entries.
|
|
78
|
+
</ParamField>
|
|
79
|
+
|
|
80
|
+
### Options (second argument)
|
|
81
|
+
|
|
82
|
+
<ParamField body="flowControl" type="object" optional>
|
|
83
|
+
An optional flow control configuration to limit concurrency and execution rate
|
|
84
|
+
of resumed workflow runs.
|
|
85
|
+
|
|
86
|
+
See [Flow Control](/workflow/features/flow-control) for details.
|
|
87
|
+
|
|
88
|
+
<Expandable title="properties">
|
|
89
|
+
<ParamField body="key" type="string">
|
|
90
|
+
A logical grouping key that identifies which resumed runs share the same flow control limits.
|
|
91
|
+
</ParamField>
|
|
92
|
+
|
|
93
|
+
<ParamField body="rate" type="number">
|
|
94
|
+
The maximum number of allowed resumption requests per second.
|
|
95
|
+
</ParamField>
|
|
96
|
+
|
|
97
|
+
<ParamField body="parallelism" type="number">
|
|
98
|
+
The maximum number of resumed runs that can execute concurrently.
|
|
99
|
+
</ParamField>
|
|
100
|
+
|
|
101
|
+
<ParamField body="period" type="string|number">
|
|
102
|
+
The time window used to enforce the defined rate limit. Default is `1s`.
|
|
103
|
+
</ParamField>
|
|
104
|
+
</Expandable>
|
|
105
|
+
</ParamField>
|
|
106
|
+
|
|
107
|
+
<ParamField body="retries" type="number" optional>
|
|
108
|
+
Number of retry attempts to apply when resuming the workflow run.
|
|
109
|
+
Defaults to `3` if not provided.
|
|
110
|
+
</ParamField>
|
|
111
|
+
|
|
112
|
+
## Response
|
|
113
|
+
|
|
114
|
+
<ResponseField name="cursor" type="string">
|
|
115
|
+
A pagination cursor. If not returned, all matching entries have been processed.
|
|
116
|
+
</ResponseField>
|
|
117
|
+
|
|
118
|
+
<ResponseField name="workflowRuns" type="object[]">
|
|
119
|
+
<Expandable defaultOpen>
|
|
120
|
+
<ResponseField name="workflowRunId" type="string">
|
|
121
|
+
The ID of the workflow run resumed from the DLQ message.
|
|
122
|
+
</ResponseField>
|
|
123
|
+
|
|
124
|
+
<ResponseField name="workflowCreatedAt" type="number">
|
|
125
|
+
The Unix timestamp (in milliseconds) when the resumed run was created.
|
|
126
|
+
</ResponseField>
|
|
127
|
+
</Expandable>
|
|
128
|
+
</ResponseField>
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
<CodeGroup>
|
|
133
|
+
```ts Single
|
|
134
|
+
const { messages } = await client.dlq.list();
|
|
135
|
+
|
|
136
|
+
const response = await client.dlq.resume(messages[0].dlqId, {
|
|
137
|
+
flowControl: {
|
|
138
|
+
key: "my-flow-control-key",
|
|
139
|
+
parallelism: 10,
|
|
140
|
+
},
|
|
141
|
+
retries: 3,
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
```ts Multiple
|
|
145
|
+
const response = await client.dlq.resume(["dlq-12345", "dlq-67890"]);
|
|
146
|
+
```
|
|
147
|
+
```ts By filters
|
|
148
|
+
let cursor: string | undefined;
|
|
149
|
+
do {
|
|
150
|
+
const result = await client.dlq.resume({
|
|
151
|
+
filter: {
|
|
152
|
+
label: "my-label",
|
|
153
|
+
workflowUrl: "https://example.com/workflow",
|
|
154
|
+
},
|
|
155
|
+
cursor,
|
|
156
|
+
});
|
|
157
|
+
cursor = result.cursor;
|
|
158
|
+
} while (cursor);
|
|
159
|
+
```
|
|
160
|
+
```ts All
|
|
161
|
+
let cursor: string | undefined;
|
|
162
|
+
do {
|
|
163
|
+
const result = await client.dlq.resume({ all: true, cursor });
|
|
164
|
+
cursor = result.cursor;
|
|
165
|
+
} while (cursor);
|
|
166
|
+
```
|
|
167
|
+
</CodeGroup>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "client.logs"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `logs` method retrieves workflow run logs using the [List Workflow Runs API](/workflow/api-reference/logs/list-workflow-run-logs).
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
<ParamField body="cursor" type="string" optional>
|
|
10
|
+
A pagination cursor from a previous request.
|
|
11
|
+
Use this to fetch the next set of results.
|
|
12
|
+
</ParamField>
|
|
13
|
+
|
|
14
|
+
<ParamField body="count" type="number" optional>
|
|
15
|
+
Maximum number of runs to return. Defaults to a system-defined value if not specified.
|
|
16
|
+
</ParamField>
|
|
17
|
+
|
|
18
|
+
<ParamField body="filter" type="object" optional>
|
|
19
|
+
Filter options for narrowing down workflow run logs.
|
|
20
|
+
|
|
21
|
+
<Expandable defaultOpen>
|
|
22
|
+
<ParamField body="workflowRunId" type="string" optional>
|
|
23
|
+
Filter by a specific workflow run ID.
|
|
24
|
+
</ParamField>
|
|
25
|
+
|
|
26
|
+
<ParamField body="state" type="string" optional>
|
|
27
|
+
Filter workflow runs by execution state.
|
|
28
|
+
|
|
29
|
+
| State | Description |
|
|
30
|
+
|--------------|--------------------------------------------|
|
|
31
|
+
| `RUN_STARTED` | The workflow run is in progress. |
|
|
32
|
+
| `RUN_SUCCESS` | The workflow run completed successfully. |
|
|
33
|
+
| `RUN_FAILED` | The run failed after all retries. |
|
|
34
|
+
| `RUN_CANCELED` | The run was manually canceled. |
|
|
35
|
+
</ParamField>
|
|
36
|
+
|
|
37
|
+
<ParamField body="workflowUrl" type="string" optional>
|
|
38
|
+
Filter by the exact workflow URL.
|
|
39
|
+
</ParamField>
|
|
40
|
+
|
|
41
|
+
<ParamField body="label" type="string | string[]" optional>
|
|
42
|
+
Filter by workflow label. Pass an array to match runs that have any
|
|
43
|
+
of the given labels (OR semantics).
|
|
44
|
+
</ParamField>
|
|
45
|
+
|
|
46
|
+
<ParamField body="workflowCreatedAt" type="number" optional>
|
|
47
|
+
Filter by the workflow creation time (Unix timestamp).
|
|
48
|
+
</ParamField>
|
|
49
|
+
|
|
50
|
+
<ParamField body="messageId" type="string" optional>
|
|
51
|
+
Filter by a specific message ID.
|
|
52
|
+
</ParamField>
|
|
53
|
+
|
|
54
|
+
<ParamField body="fromDate" type="Date | number" optional>
|
|
55
|
+
Filter workflow runs created after this date.
|
|
56
|
+
</ParamField>
|
|
57
|
+
|
|
58
|
+
<ParamField body="toDate" type="Date | number" optional>
|
|
59
|
+
Filter workflow runs created before this date.
|
|
60
|
+
</ParamField>
|
|
61
|
+
|
|
62
|
+
<ParamField body="callerIp" type="string" optional>
|
|
63
|
+
Filter by the IP address that triggered the workflow.
|
|
64
|
+
</ParamField>
|
|
65
|
+
|
|
66
|
+
<ParamField body="flowControlKey" type="string" optional>
|
|
67
|
+
Filter by flow control key.
|
|
68
|
+
</ParamField>
|
|
69
|
+
</Expandable>
|
|
70
|
+
</ParamField>
|
|
71
|
+
|
|
72
|
+
## Response
|
|
73
|
+
|
|
74
|
+
<ResponseField name="cursor" type="string">
|
|
75
|
+
A cursor to use for pagination.
|
|
76
|
+
If no cursor is returned, there are no more workflow runs.
|
|
77
|
+
</ResponseField>
|
|
78
|
+
|
|
79
|
+
<Snippet file="workflow/logs.mdx" />
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { Client } from "@upstash/workflow";
|
|
87
|
+
|
|
88
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" })
|
|
89
|
+
|
|
90
|
+
const { runs, cursor } = await client.logs()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Paginate with cursor
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const allRuns = [];
|
|
97
|
+
let cursor: string | undefined;
|
|
98
|
+
do {
|
|
99
|
+
const result = await client.logs({ cursor });
|
|
100
|
+
allRuns.push(...result.runs);
|
|
101
|
+
cursor = result.cursor;
|
|
102
|
+
} while (cursor);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Filter by state
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const { runs } = await client.logs({
|
|
109
|
+
filter: {
|
|
110
|
+
state: "RUN_FAILED",
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Filter by label and date range
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const { runs } = await client.logs({
|
|
119
|
+
filter: {
|
|
120
|
+
label: "my-workflow",
|
|
121
|
+
fromDate: new Date("2024-01-01"),
|
|
122
|
+
toDate: new Date("2024-06-01"),
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Filter by multiple labels
|
|
128
|
+
|
|
129
|
+
Passing an array matches runs that have any of the given labels (OR semantics).
|
|
130
|
+
For example, with runs labelled `["label-1", "label-2"]` and `["label-2", "label-3"]`,
|
|
131
|
+
filtering by `["label-1", "label-2"]` returns both.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const { runs } = await client.logs({
|
|
135
|
+
filter: {
|
|
136
|
+
label: ["label-1", "label-2"],
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "client.notify"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `notify` method notifies workflows that are waiting for a specific event.
|
|
6
|
+
|
|
7
|
+
Workflows paused at a [`context.waitForEvent`](/workflow/basics/context/waitForEvent) step with the matching `eventId` will be resumed, and the provided `eventData` will be passed back to them.
|
|
8
|
+
|
|
9
|
+
## Arguments
|
|
10
|
+
|
|
11
|
+
<ParamField body="eventId" type="string" required>
|
|
12
|
+
The identifier of the event to notify.
|
|
13
|
+
</ParamField>
|
|
14
|
+
|
|
15
|
+
<ParamField body="eventData" type="any" optional>
|
|
16
|
+
Data to deliver to the waiting workflow(s).
|
|
17
|
+
This value will be returned in the `eventData` field of `context.waitForEvent`.
|
|
18
|
+
</ParamField>
|
|
19
|
+
|
|
20
|
+
<ParamField body="workflowRunId" type="string" optional>
|
|
21
|
+
The workflow run ID to notify. When provided, enables **lookback functionality** - the notification will be stored and delivered even if `notify` is called before `waitForEvent`.
|
|
22
|
+
|
|
23
|
+
This solves race conditions where notifications might be sent before a workflow reaches its wait step.
|
|
24
|
+
</ParamField>
|
|
25
|
+
|
|
26
|
+
## Response
|
|
27
|
+
|
|
28
|
+
<ResponseField name="response" type="NotifyResponse[]">
|
|
29
|
+
A list of `NotifyResponse` objects, one for each workflow that was waiting on the event.
|
|
30
|
+
An empty list means no workflow was waiting.
|
|
31
|
+
|
|
32
|
+
<Expandable defaultOpen>
|
|
33
|
+
<ResponseField name="messageId" type="string">
|
|
34
|
+
The ID of the notification message delivered to the workflow.
|
|
35
|
+
This is unique to every notification.
|
|
36
|
+
</ResponseField>
|
|
37
|
+
|
|
38
|
+
<ResponseField name="error" type="string">
|
|
39
|
+
Error message if delivering the notification to this waiter failed.
|
|
40
|
+
</ResponseField>
|
|
41
|
+
|
|
42
|
+
<Snippet file="qstash/waiter.mdx" />
|
|
43
|
+
</Expandable>
|
|
44
|
+
</ResponseField>
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
### Basic Notification
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
import { Client } from "@upstash/workflow";
|
|
52
|
+
|
|
53
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" });
|
|
54
|
+
|
|
55
|
+
await client.notify({
|
|
56
|
+
eventId: "my-event-id",
|
|
57
|
+
eventData: "my-data", // data passed to the workflow run
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Notification with Lookback
|
|
62
|
+
|
|
63
|
+
To prevent race conditions where a notification might arrive before the workflow reaches `waitForEvent`, you can provide a `workflowRunId`. This enables lookback - the notification will be stored and delivered even if sent before the wait step:
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
import { Client } from "@upstash/workflow";
|
|
67
|
+
|
|
68
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" });
|
|
69
|
+
|
|
70
|
+
// Notify a specific workflow run with lookback support
|
|
71
|
+
await client.notify({
|
|
72
|
+
eventId: "payment-processed",
|
|
73
|
+
eventData: { amount: 100, status: "success" },
|
|
74
|
+
workflowRunId: "wfr_abc123", // Enables lookback for this workflow run
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This is particularly useful when you know which specific workflow run should receive the notification, such as after triggering a workflow and immediately sending it an event.
|
|
79
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "client.trigger"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `trigger` method starts a new workflow run and returns its `workflowRunId`.
|
|
6
|
+
|
|
7
|
+
You can also trigger multiple workflow runs in a single call by passing an array of arguments instead of a single object.
|
|
8
|
+
|
|
9
|
+
## Arguments
|
|
10
|
+
|
|
11
|
+
<ParamField body="url" type="string" required>
|
|
12
|
+
The public URL of the workflow endpoint.
|
|
13
|
+
</ParamField>
|
|
14
|
+
|
|
15
|
+
<ParamField body="workflowRunId" type="string" optional>
|
|
16
|
+
A custom identifier for the workflow run.
|
|
17
|
+
Each run must use a unique ID.
|
|
18
|
+
|
|
19
|
+
The final ID will be prefixed with `wfr_`.
|
|
20
|
+
For example: passing `my-workflow` results in `wfr_my-workflow`.
|
|
21
|
+
|
|
22
|
+
If omitted, a run ID will be generated automatically.
|
|
23
|
+
</ParamField>
|
|
24
|
+
|
|
25
|
+
<ParamField body="body" type="string | object" optional>
|
|
26
|
+
The request payload to pass into the workflow run.
|
|
27
|
+
Accessible as `context.requestPayload` inside the workflow.
|
|
28
|
+
</ParamField>
|
|
29
|
+
|
|
30
|
+
<ParamField body="headers" type="object" optional>
|
|
31
|
+
HTTP headers to pass into the workflow run.
|
|
32
|
+
Accessible as `context.headers` inside the workflow.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
<ParamField body="retries" type="string">
|
|
36
|
+
Number of retry attempts for workflow steps. Default is 3.
|
|
37
|
+
</ParamField>
|
|
38
|
+
|
|
39
|
+
<ParamField body="retryDelay" type="string">
|
|
40
|
+
Delay between retries. Can use expressions like "1000 * (1 + retried)".
|
|
41
|
+
</ParamField>
|
|
42
|
+
|
|
43
|
+
<ParamField body="flowControl" type="object" optional>
|
|
44
|
+
An optional flow control configuration to limit concurrency and execution rate of the workflow runs.
|
|
45
|
+
|
|
46
|
+
See [Flow Control](/workflow/features/flow-control) for details.
|
|
47
|
+
|
|
48
|
+
<Expandable title="properties">
|
|
49
|
+
<ParamField body="key" type="string">
|
|
50
|
+
A logical grouping key that identifies which requests share the same flow control limits.
|
|
51
|
+
</ParamField>
|
|
52
|
+
|
|
53
|
+
<ParamField body="rate" type="number">
|
|
54
|
+
The maximum number of allowed requests per second.
|
|
55
|
+
</ParamField>
|
|
56
|
+
|
|
57
|
+
<ParamField body="parallelism" type="number">
|
|
58
|
+
The maximum number of concurrent requests allowed.
|
|
59
|
+
</ParamField>
|
|
60
|
+
|
|
61
|
+
<ParamField body="period" type="string|number">
|
|
62
|
+
The time window used to enforce the defined rate limit. Default is `1s`.
|
|
63
|
+
</ParamField>
|
|
64
|
+
</Expandable>
|
|
65
|
+
</ParamField>
|
|
66
|
+
|
|
67
|
+
<ParamField body="delay" type="string">
|
|
68
|
+
Delay for the workflow run. This is used to delay the execution of the workflow run. The delay is in seconds or can be passed as a string with a time unit (e.g. "1h", "30m", "15s").
|
|
69
|
+
</ParamField>
|
|
70
|
+
|
|
71
|
+
<ParamField body="notBefore" type="number">
|
|
72
|
+
Optionally set the absolute delay of this message.
|
|
73
|
+
This will override the delay option.
|
|
74
|
+
The message will not delivered until the specified time.
|
|
75
|
+
|
|
76
|
+
Unix timestamp in seconds.
|
|
77
|
+
</ParamField>
|
|
78
|
+
|
|
79
|
+
<ParamField body="label" type="string | string[]">
|
|
80
|
+
An optional label to assign to the workflow run.
|
|
81
|
+
This can be useful for identifying and filtering runs in the dashboard or logs.
|
|
82
|
+
|
|
83
|
+
Pass an array to attach multiple labels to a single workflow run. The run will
|
|
84
|
+
then match a [logs](/workflow/basics/client/logs) or DLQ filter for any of its
|
|
85
|
+
labels (OR semantics).
|
|
86
|
+
</ParamField>
|
|
87
|
+
|
|
88
|
+
<ParamField body="disableTelemetry" type="boolean">
|
|
89
|
+
If set to true, telemetry data collection for this workflow run will be disabled.
|
|
90
|
+
By default, telemetry is enabled to help improve Upstash services.
|
|
91
|
+
|
|
92
|
+
See the [`disableTelemetry` parameter in serve options](/workflow/basics/serve/advanced#param-disable-telemetry) for more details.
|
|
93
|
+
</ParamField>
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
<CodeGroup>
|
|
97
|
+
```ts Single Workflow
|
|
98
|
+
import { Client } from "@upstash/workflow";
|
|
99
|
+
|
|
100
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" })
|
|
101
|
+
|
|
102
|
+
const { workflowRunId } = await client.trigger({
|
|
103
|
+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
|
|
104
|
+
body: "hello there!", // optional body
|
|
105
|
+
headers: { ... }, // optional headers
|
|
106
|
+
workflowRunId: "my-workflow", // optional workflow run id
|
|
107
|
+
retries: 3, // optional retries
|
|
108
|
+
retryDelay: "1000 * (1 + retried)", // optional delay between retries
|
|
109
|
+
delay: "10s" // optional delay value
|
|
110
|
+
failureUrl: "https://<YOUR_FAILURE_URL>", // optional failure url
|
|
111
|
+
flowControl: { // optional flow control
|
|
112
|
+
key: "USER_GIVEN_KEY",
|
|
113
|
+
rate: 10,
|
|
114
|
+
parallelism: 5,
|
|
115
|
+
period: "10m"
|
|
116
|
+
},
|
|
117
|
+
label: ["team-a", "high-priority"], // optional label(s); single string or array
|
|
118
|
+
})
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```ts Multiple Workflows
|
|
122
|
+
import { Client } from "@upstash/workflow";
|
|
123
|
+
|
|
124
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" })
|
|
125
|
+
const results = await client.trigger([
|
|
126
|
+
{
|
|
127
|
+
url: "<YOUR_WORKFLOW_ENDPOINT>",
|
|
128
|
+
// other options...
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
url: "<YOUR_WORKFLOW_ENDPOINT>",
|
|
132
|
+
// other options...
|
|
133
|
+
},
|
|
134
|
+
])
|
|
135
|
+
|
|
136
|
+
console.log(results[0].workflowRunId)
|
|
137
|
+
// prints wfr_my-workflow
|
|
138
|
+
```
|
|
139
|
+
</CodeGroup>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "client.getWaiters"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `getWaiters` method retrieves all waiters that are currently listening for a given event.
|
|
6
|
+
|
|
7
|
+
A **waiter** represents a workflow run that is paused at a `context.waitForEvent` step and is waiting for the specified `eventId`.
|
|
8
|
+
|
|
9
|
+
## Arguments
|
|
10
|
+
|
|
11
|
+
<ParamField body="eventId" type="string" required>
|
|
12
|
+
The identifier of the event to look up.
|
|
13
|
+
</ParamField>
|
|
14
|
+
|
|
15
|
+
## Response
|
|
16
|
+
|
|
17
|
+
Returns a list of `Waiter` objects describing workflows that are waiting on the given event.
|
|
18
|
+
|
|
19
|
+
<Snippet file="qstash/waiter.mdx" />
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { Client } from "@upstash/workflow";
|
|
25
|
+
|
|
26
|
+
const client = new Client({ token: "<QSTASH_TOKEN>" });
|
|
27
|
+
|
|
28
|
+
const result = await client.getWaiters({
|
|
29
|
+
eventId: "my-event-id",
|
|
30
|
+
});
|
|
31
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Workflow Client Overview
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The Workflow Client lets you programmatically interact with your workflow runs.
|
|
7
|
+
You can use it from the same application that hosts your workflows, or from any external service.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Initialization
|
|
11
|
+
|
|
12
|
+
Initialize a new client with your credentials:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
import { Client } from "@upstash/workflow"
|
|
16
|
+
|
|
17
|
+
const client = new Client({
|
|
18
|
+
baseUrl: process.env.QSTASH_URL!,
|
|
19
|
+
token: process.env.QSTASH_TOKEN!
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The client is lightweight and stateless. You can safely reuse a single instance across your application.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Functionality
|
|
27
|
+
|
|
28
|
+
The client exposes a set of functions to manage workflow runs and inspect their state:
|
|
29
|
+
|
|
30
|
+
- [client.trigger](/workflow/basics/client/trigger)
|
|
31
|
+
- [client.cancel](/workflow/basics/client/cancel)
|
|
32
|
+
- [client.notify](/workflow/basics/client/notify)
|
|
33
|
+
- [client.logs](/workflow/basics/client/logs)
|
|
34
|
+
- [client.getWaiters](/workflow/basics/client/waiters)
|
|
35
|
+
- client.dlq
|
|
36
|
+
- [client.dlq.list](/workflow/basics/client/dlq/list)
|
|
37
|
+
- [client.dlq.restart](/workflow/basics/client/dlq/restart)
|
|
38
|
+
- [client.dlq.resume](/workflow/basics/client/dlq/resume)
|
|
39
|
+
- [client.dlq.delete](/workflow/basics/client/dlq/delete)
|
|
40
|
+
- [client.dlq.retryFailureFunction](/workflow/basics/client/dlq/callback)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "How Workflow Works"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Upstash Workflow is an orchestration layer that allows you to write **multi‑step workflows** which are:
|
|
6
|
+
|
|
7
|
+
- **Durable** – steps automatically recover from errors or outages
|
|
8
|
+
- **Scalable** – steps run independently and in parallel when possible
|
|
9
|
+
- **Cost‑efficient** – idle waiting (delays, sleeps, external calls) does not consume compute resources
|
|
10
|
+
|
|
11
|
+
Upstash Workflow is built on top of Upstash QStash, our serverless messaging and scheduling solution, to achieve these features.
|
|
12
|
+
|
|
13
|
+
## The Core Idea
|
|
14
|
+
|
|
15
|
+
Traditionally, backend functions are built in one of two ways: either everything is executed inside a single API function—which is difficult to maintain and prone to failures—or the flow is split across multiple APIs connected by a queueing system, which adds significant infrastructure and state‑management overhead.
|
|
16
|
+
|
|
17
|
+
These approaches can work, but they often fail to handle production load reliably or become increasingly difficult to maintain over time:
|
|
18
|
+
|
|
19
|
+
- **Timeouts** – the whole function runs inside one execution window. A slow API can easily exceed serverless limits (often 10–60 seconds).
|
|
20
|
+
- **Temporary issues** – slow or unreliable external services can exceed serverless limits or cause the entire request to fail.
|
|
21
|
+
- **Failures** – if a step fails, the whole request fails. You either restart everything or you must write custom retry logic.
|
|
22
|
+
- **Rate limits** – calling external APIs in bulk requires careful concurrency control, which is difficult to implement manually.
|
|
23
|
+
- **Complexity** – to address these issues, teams often build custom queues, schedulers, or state trackers, adding unnecessary infrastructure overhead.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## How Upstash Workflow Solves This
|
|
28
|
+
|
|
29
|
+
Upstash Workflow takes a different approach:
|
|
30
|
+
instead of treating your entire function as one continuous execution, **it splits your logic into multiple steps in a workflow endpoint**, each managed and retried by the orchestration engine.
|
|
31
|
+
|
|
32
|
+
- Each step is executed in its own **HTTP call** to your application.
|
|
33
|
+
- After a step finishes, its result is **stored in durable state** inside Upstash Workflow.
|
|
34
|
+
- On the next execution, Workflow **skips completed steps** and **resumes exactly where it left off by restoring the previous step results**.
|
|
35
|
+
- If a step fails, it is retried automatically based on your retry configuration.
|
|
36
|
+
|
|
37
|
+
This means you no longer need custom queues, retry logic, or manual state management. You just define your workflow once, and the orchestration layer ensures that **every step runs once, in order, with full reliability.**
|
|
38
|
+
|
|
39
|
+
<Frame>
|
|
40
|
+
<img src="/img/qstash-workflow/workflow-concept.png" alt="Workflow execution diagram" />
|
|
41
|
+
</Frame>
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Extended Features
|
|
46
|
+
|
|
47
|
+
Upstash Workflow extends the basic step model with additional primitives:
|
|
48
|
+
|
|
49
|
+
- **Parallel Steps**
|
|
50
|
+
Define multiple steps (e.g. inside a `Promise.all()`). The engine detects independent work and runs steps concurrently as separate HTTP executions.
|
|
51
|
+
|
|
52
|
+
- **Delays / Sleep**
|
|
53
|
+
`context.sleep` and `context.sleepUntil` allow pausing a workflow for hours, days, or even months. No compute is held during the wait time; execution resumes when the delay has expired.
|
|
54
|
+
|
|
55
|
+
- **External Event Handling**
|
|
56
|
+
`context.waitForEvent` pauses execution until you notify the workflow externally (e.g. via webhook or user action). State is persisted until the event arrives.
|
|
57
|
+
|
|
58
|
+
- **External Calls**
|
|
59
|
+
Use `context.call` to have Upstash perform slow or unreliable HTTP calls. Instead of blocking your function, the call is handled by Upstash. When it completes, the workflow resumes with the response.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
This architecture makes your serverless functions durable, reliable, and performance‑optimized, even in the face of runtime errors or temporary service outages.
|
|
64
|
+
|
|
65
|
+
It's quick and easy to get started: follow the [Quickstarts](/workflow/quickstarts/platforms) to define your first workflow in minutes.
|