@upstash/workflow 1.4.0 → 1.5.1-canary.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 +375 -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 +575 -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 +114 -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 +2946 -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,575 @@
|
|
|
1
|
+
import type { Err, Ok } from "neverthrow";
|
|
2
|
+
import { err, ok } from "neverthrow";
|
|
3
|
+
import {
|
|
4
|
+
isInstanceOf,
|
|
5
|
+
WorkflowAbort,
|
|
6
|
+
WorkflowCancelAbort,
|
|
7
|
+
WorkflowError,
|
|
8
|
+
WorkflowNonRetryableError,
|
|
9
|
+
WorkflowRetryAfterError,
|
|
10
|
+
} from "./error";
|
|
11
|
+
import type { WorkflowContext } from "./context";
|
|
12
|
+
import type { AutoExecutor } from "./context/auto-executor";
|
|
13
|
+
import {
|
|
14
|
+
TELEMETRY_HEADER_FRAMEWORK,
|
|
15
|
+
TELEMETRY_HEADER_RUNTIME,
|
|
16
|
+
TELEMETRY_HEADER_SDK,
|
|
17
|
+
WORKFLOW_CREATED_AT_HEADER,
|
|
18
|
+
WORKFLOW_ID_HEADER,
|
|
19
|
+
WORKFLOW_INVOKE_COUNT_HEADER,
|
|
20
|
+
WORKFLOW_LABEL_HEADER,
|
|
21
|
+
WORKFLOW_UNKOWN_SDK_TRIGGER_HEADER,
|
|
22
|
+
} from "./constants";
|
|
23
|
+
import type {
|
|
24
|
+
CallResponse,
|
|
25
|
+
Step,
|
|
26
|
+
StepType,
|
|
27
|
+
Telemetry,
|
|
28
|
+
WorkflowClient,
|
|
29
|
+
WorkflowReceiver,
|
|
30
|
+
} from "./types";
|
|
31
|
+
import { StepTypes } from "./types";
|
|
32
|
+
import { PublishBatchRequest, PublishRequest, QstashError } from "@upstash/qstash";
|
|
33
|
+
import { getSteps } from "./client/utils";
|
|
34
|
+
import { getHeaders } from "./qstash/headers";
|
|
35
|
+
import { PublishToUrlResponse } from "@upstash/qstash";
|
|
36
|
+
import { DispatchDebug } from "./middleware/types";
|
|
37
|
+
import { MiddlewareManager } from "./middleware/manager";
|
|
38
|
+
import { serializeLabel } from "./utils";
|
|
39
|
+
import { TriggerOptions } from "./client/types";
|
|
40
|
+
|
|
41
|
+
type TriggerFirstInvocationParams<TInitialPayload> = {
|
|
42
|
+
workflowContext: WorkflowContext<TInitialPayload>;
|
|
43
|
+
useJSONContent?: boolean;
|
|
44
|
+
telemetry?: Telemetry;
|
|
45
|
+
invokeCount?: number;
|
|
46
|
+
delay?: PublishRequest["delay"];
|
|
47
|
+
notBefore?: PublishRequest["notBefore"];
|
|
48
|
+
failureUrl?: TriggerOptions["failureUrl"];
|
|
49
|
+
retries?: TriggerOptions["retries"];
|
|
50
|
+
retryDelay?: TriggerOptions["retryDelay"];
|
|
51
|
+
flowControl?: TriggerOptions["flowControl"];
|
|
52
|
+
redact?: TriggerOptions["redact"];
|
|
53
|
+
middlewareManager?: MiddlewareManager;
|
|
54
|
+
unknownSdk?: boolean;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const triggerFirstInvocation = async <TInitialPayload>(
|
|
58
|
+
params:
|
|
59
|
+
| TriggerFirstInvocationParams<TInitialPayload>
|
|
60
|
+
| TriggerFirstInvocationParams<TInitialPayload>[]
|
|
61
|
+
): Promise<Ok<"success" | "workflow-run-already-exists", never> | Err<never, Error>> => {
|
|
62
|
+
const firstInvocationParams = Array.isArray(params) ? params : [params];
|
|
63
|
+
const workflowContextClient = firstInvocationParams[0].workflowContext.qstashClient;
|
|
64
|
+
|
|
65
|
+
const invocationBatch = firstInvocationParams.map(
|
|
66
|
+
({
|
|
67
|
+
workflowContext,
|
|
68
|
+
useJSONContent,
|
|
69
|
+
telemetry,
|
|
70
|
+
invokeCount,
|
|
71
|
+
delay,
|
|
72
|
+
notBefore,
|
|
73
|
+
failureUrl,
|
|
74
|
+
retries,
|
|
75
|
+
retryDelay,
|
|
76
|
+
flowControl,
|
|
77
|
+
redact,
|
|
78
|
+
unknownSdk,
|
|
79
|
+
}) => {
|
|
80
|
+
const { headers } = getHeaders({
|
|
81
|
+
initHeaderValue: "true",
|
|
82
|
+
workflowConfig: {
|
|
83
|
+
workflowRunId: workflowContext.workflowRunId,
|
|
84
|
+
workflowUrl: workflowContext.url,
|
|
85
|
+
// the run doesn't exist yet, so the trigger time is sent when the creation time
|
|
86
|
+
// is not known. serve and client.trigger set it on the context already, so a
|
|
87
|
+
// retry of this request carries the same value and is deduplicated.
|
|
88
|
+
workflowRunCreatedAt: workflowContext.workflowRunCreatedAt || Date.now(),
|
|
89
|
+
failureUrl,
|
|
90
|
+
retries,
|
|
91
|
+
retryDelay,
|
|
92
|
+
telemetry: telemetry,
|
|
93
|
+
flowControl,
|
|
94
|
+
useJSONContent: useJSONContent ?? false,
|
|
95
|
+
},
|
|
96
|
+
invokeCount: invokeCount ?? 0,
|
|
97
|
+
userHeaders: workflowContext.headers,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// QStash doesn't forward content-type when passed in `upstash-forward-content-type`
|
|
101
|
+
// so we need to pass it in the headers
|
|
102
|
+
if (workflowContext.headers.get("content-type")) {
|
|
103
|
+
headers["content-type"] = workflowContext.headers.get("content-type")!;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (useJSONContent) {
|
|
107
|
+
headers["content-type"] = "application/json";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (unknownSdk) {
|
|
111
|
+
headers[WORKFLOW_UNKOWN_SDK_TRIGGER_HEADER] = "true";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* WORKFLOW_LABEL_HEADER exists in the headers with forward prefix
|
|
116
|
+
* so that it can be passed to the workflow context in subsequent steps.
|
|
117
|
+
*
|
|
118
|
+
* we also need to set it here without the prefix so that server
|
|
119
|
+
* sets the label of the workflow run.
|
|
120
|
+
*/
|
|
121
|
+
if (workflowContext.labels.length > 0) {
|
|
122
|
+
headers[WORKFLOW_LABEL_HEADER] = serializeLabel(workflowContext.labels);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const body =
|
|
126
|
+
typeof workflowContext.requestPayload === "string"
|
|
127
|
+
? workflowContext.requestPayload
|
|
128
|
+
: JSON.stringify(workflowContext.requestPayload);
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
headers,
|
|
132
|
+
method: "POST",
|
|
133
|
+
body,
|
|
134
|
+
url: workflowContext.url,
|
|
135
|
+
delay: delay,
|
|
136
|
+
notBefore: notBefore,
|
|
137
|
+
redact,
|
|
138
|
+
} as PublishBatchRequest;
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const results = (await workflowContextClient.batch(invocationBatch)) as PublishToUrlResponse[];
|
|
144
|
+
|
|
145
|
+
const invocationStatuses: ("success" | "workflow-run-already-exists")[] = [];
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < results.length; i++) {
|
|
148
|
+
const result = results[i];
|
|
149
|
+
const invocationParams = firstInvocationParams[i];
|
|
150
|
+
|
|
151
|
+
invocationParams.middlewareManager?.assignContext(invocationParams.workflowContext);
|
|
152
|
+
|
|
153
|
+
if (result.deduplicated) {
|
|
154
|
+
await invocationParams.middlewareManager?.dispatchDebug("onWarning", {
|
|
155
|
+
warning: `Workflow run ${invocationParams.workflowContext.workflowRunId} already exists. A new one isn't created.`,
|
|
156
|
+
});
|
|
157
|
+
invocationStatuses.push("workflow-run-already-exists");
|
|
158
|
+
} else {
|
|
159
|
+
await invocationParams.middlewareManager?.dispatchDebug("onInfo", {
|
|
160
|
+
info: `Workflow run started successfully with URL ${invocationParams.workflowContext.url}.`,
|
|
161
|
+
});
|
|
162
|
+
invocationStatuses.push("success");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const hasAnyDeduplicated = invocationStatuses.some(
|
|
167
|
+
(status) => status === "workflow-run-already-exists"
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
if (hasAnyDeduplicated) {
|
|
171
|
+
return ok("workflow-run-already-exists");
|
|
172
|
+
} else {
|
|
173
|
+
return ok("success");
|
|
174
|
+
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
const error_ = error as Error;
|
|
177
|
+
return err(error_);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Submits the result of a step which executed but whose submission was
|
|
183
|
+
* held so that the route function could reveal what comes next.
|
|
184
|
+
*
|
|
185
|
+
* Not part of the public API: reaches the protected executor of the
|
|
186
|
+
* context, which is why the cast is needed.
|
|
187
|
+
*
|
|
188
|
+
* @internal
|
|
189
|
+
* @param workflowContext workflow context
|
|
190
|
+
* @returns `submitted-step` with the abort which ends this invocation,
|
|
191
|
+
* or `no-pending-step` when nothing was held and there is nothing to end
|
|
192
|
+
*/
|
|
193
|
+
export const flushPendingStep = async (
|
|
194
|
+
workflowContext: WorkflowContext
|
|
195
|
+
): ReturnType<AutoExecutor["submitPendingStep"]> => {
|
|
196
|
+
const { executor } = workflowContext as unknown as { executor: AutoExecutor };
|
|
197
|
+
return await executor.submitPendingStep();
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Triggers the route function and handles cleanup and cancellation.
|
|
202
|
+
*
|
|
203
|
+
* @param onStep function to execute the step
|
|
204
|
+
* @param onCleanup function to call after successful step execution
|
|
205
|
+
* @param onCancel function to call when workflow is cancelled
|
|
206
|
+
* @param middlewareManager optional middleware manager
|
|
207
|
+
*/
|
|
208
|
+
export const triggerRouteFunction = async <TResult = unknown>({
|
|
209
|
+
onCleanup,
|
|
210
|
+
onStep,
|
|
211
|
+
onCancel,
|
|
212
|
+
middlewareManager,
|
|
213
|
+
}: {
|
|
214
|
+
onStep: () => Promise<TResult>;
|
|
215
|
+
onCleanup: (result: TResult) => Promise<void>;
|
|
216
|
+
onCancel: () => Promise<void>;
|
|
217
|
+
middlewareManager?: MiddlewareManager;
|
|
218
|
+
}): Promise<
|
|
219
|
+
| Ok<
|
|
220
|
+
| "workflow-finished"
|
|
221
|
+
| "step-finished"
|
|
222
|
+
| "workflow-was-finished"
|
|
223
|
+
| WorkflowNonRetryableError
|
|
224
|
+
| WorkflowRetryAfterError,
|
|
225
|
+
never
|
|
226
|
+
>
|
|
227
|
+
| Err<never, Error>
|
|
228
|
+
> => {
|
|
229
|
+
try {
|
|
230
|
+
// When onStep completes successfully, it can throw a `WorkflowAbort` (or a subclass such as
|
|
231
|
+
// `WorkflowCancelAbort`) to signal that the step has finished and control flow should abort.
|
|
232
|
+
// This ensures that onCleanup is only called when no exception is thrown.
|
|
233
|
+
const result = await onStep();
|
|
234
|
+
await onCleanup(result);
|
|
235
|
+
return ok("workflow-finished");
|
|
236
|
+
} catch (error) {
|
|
237
|
+
const error_ = error as Error;
|
|
238
|
+
if (isInstanceOf(error, QstashError) && error.status === 400) {
|
|
239
|
+
await middlewareManager?.dispatchDebug("onWarning", {
|
|
240
|
+
warning: `Tried to append to a cancelled workflow. Exiting without publishing. Error: ${error.message}`,
|
|
241
|
+
});
|
|
242
|
+
return ok("workflow-was-finished");
|
|
243
|
+
} else if (
|
|
244
|
+
isInstanceOf(error_, WorkflowNonRetryableError) ||
|
|
245
|
+
isInstanceOf(error_, WorkflowRetryAfterError)
|
|
246
|
+
) {
|
|
247
|
+
return ok(error_);
|
|
248
|
+
} else if (isInstanceOf(error_, WorkflowCancelAbort)) {
|
|
249
|
+
await onCancel();
|
|
250
|
+
return ok("workflow-finished");
|
|
251
|
+
} else if (isInstanceOf(error_, WorkflowAbort)) {
|
|
252
|
+
return ok("step-finished");
|
|
253
|
+
} else {
|
|
254
|
+
return err(error_);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Deletes a workflow run from QStash.
|
|
261
|
+
*
|
|
262
|
+
* @param workflowContext workflow context
|
|
263
|
+
* @param result result to send with the delete request
|
|
264
|
+
* @param cancel whether to cancel the workflow
|
|
265
|
+
* @param dispatchDebug optional debug dispatcher
|
|
266
|
+
*/
|
|
267
|
+
export const triggerWorkflowDelete = async <TInitialPayload>(
|
|
268
|
+
workflowContext: WorkflowContext<TInitialPayload>,
|
|
269
|
+
result: unknown,
|
|
270
|
+
cancel = false,
|
|
271
|
+
dispatchDebug?: DispatchDebug
|
|
272
|
+
): Promise<void> => {
|
|
273
|
+
await dispatchDebug?.("onInfo", {
|
|
274
|
+
info:
|
|
275
|
+
`Deleting workflow run ${workflowContext.workflowRunId} from QStash` +
|
|
276
|
+
(cancel ? " with cancel=true." : "."),
|
|
277
|
+
});
|
|
278
|
+
await workflowContext.qstashClient.http.request({
|
|
279
|
+
path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
|
|
280
|
+
method: "DELETE",
|
|
281
|
+
parseResponseAsJson: false,
|
|
282
|
+
body: JSON.stringify(result),
|
|
283
|
+
// with the creation time, QStash deletes the run only if it is the same run.
|
|
284
|
+
// a late delete of a previous run can't delete a new run with the same id.
|
|
285
|
+
headers: workflowContext.workflowRunCreatedAt
|
|
286
|
+
? { [WORKFLOW_CREATED_AT_HEADER]: workflowContext.workflowRunCreatedAt.toString() }
|
|
287
|
+
: undefined,
|
|
288
|
+
});
|
|
289
|
+
await dispatchDebug?.("onInfo", {
|
|
290
|
+
info: `Workflow run ${workflowContext.workflowRunId} deleted from QStash successfully.`,
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Removes headers starting with `Upstash-Workflow-` from the headers
|
|
296
|
+
*
|
|
297
|
+
* @param headers incoming headers
|
|
298
|
+
* @returns headers with `Upstash-Workflow-` headers removed
|
|
299
|
+
*/
|
|
300
|
+
export const recreateUserHeaders = (headers: Headers): Headers => {
|
|
301
|
+
const filteredHeaders = new Headers();
|
|
302
|
+
|
|
303
|
+
const pairs = headers.entries() as unknown as [string, string][];
|
|
304
|
+
for (const [header, value] of pairs) {
|
|
305
|
+
const headerLowerCase = header.toLowerCase();
|
|
306
|
+
|
|
307
|
+
const isUserHeader =
|
|
308
|
+
(headerLowerCase !== "upstash-region" &&
|
|
309
|
+
!headerLowerCase.startsWith("upstash-workflow-") &&
|
|
310
|
+
// https://vercel.com/docs/edge-network/headers/request-headers#x-vercel-id
|
|
311
|
+
!headerLowerCase.startsWith("x-vercel-") &&
|
|
312
|
+
!headerLowerCase.startsWith("x-forwarded-") &&
|
|
313
|
+
// https://blog.cloudflare.com/preventing-request-loops-using-cdn-loop/
|
|
314
|
+
headerLowerCase !== "cf-connecting-ip" &&
|
|
315
|
+
headerLowerCase !== "cdn-loop" &&
|
|
316
|
+
headerLowerCase !== "cf-ew-via" &&
|
|
317
|
+
headerLowerCase !== "cf-ray" &&
|
|
318
|
+
// For Render https://render.com
|
|
319
|
+
headerLowerCase !== "render-proxy-ttl") ||
|
|
320
|
+
headerLowerCase === WORKFLOW_LABEL_HEADER.toLocaleLowerCase();
|
|
321
|
+
|
|
322
|
+
if (isUserHeader) {
|
|
323
|
+
filteredHeaders.append(header, value);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return filteredHeaders as Headers;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Checks if the incoming request is a third party call result coming from QStash
|
|
332
|
+
* by looking for the `Upstash-Workflow-Callback` header.
|
|
333
|
+
*
|
|
334
|
+
* @param request incoming request
|
|
335
|
+
* @returns true if the request is a third party call result, false otherwise
|
|
336
|
+
*/
|
|
337
|
+
export const isThirdPartyCallResult = (request: Request): boolean => {
|
|
338
|
+
return request.headers.get("Upstash-Workflow-Callback") !== null;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Checks if the request is from a third party call result. If so,
|
|
343
|
+
* calls QStash to add the result to the ongoing workflow.
|
|
344
|
+
*
|
|
345
|
+
* Otherwise, does nothing.
|
|
346
|
+
*
|
|
347
|
+
* ### How third party calls work
|
|
348
|
+
*
|
|
349
|
+
* In third party calls, we publish a message to the third party API.
|
|
350
|
+
* the result is then returned back to the workflow endpoint.
|
|
351
|
+
*
|
|
352
|
+
* Whenever the workflow endpoint receives a request, we first check
|
|
353
|
+
* if the incoming request is a third party call result coming from QStash.
|
|
354
|
+
* If so, we send back the result to QStash as a result step.
|
|
355
|
+
*
|
|
356
|
+
* @param request Incoming request
|
|
357
|
+
* @param client QStash client
|
|
358
|
+
* @returns
|
|
359
|
+
*/
|
|
360
|
+
export const handleThirdPartyCallResult = async ({
|
|
361
|
+
request,
|
|
362
|
+
requestPayload,
|
|
363
|
+
client,
|
|
364
|
+
workflowUrl,
|
|
365
|
+
telemetry,
|
|
366
|
+
middlewareManager,
|
|
367
|
+
}: {
|
|
368
|
+
request: Request;
|
|
369
|
+
requestPayload: string;
|
|
370
|
+
client: WorkflowClient;
|
|
371
|
+
workflowUrl: string;
|
|
372
|
+
telemetry?: Telemetry;
|
|
373
|
+
middlewareManager?: MiddlewareManager;
|
|
374
|
+
}): Promise<
|
|
375
|
+
| Ok<"is-call-return" | "continue-workflow" | "call-will-retry" | "workflow-ended", never>
|
|
376
|
+
| Err<never, Error>
|
|
377
|
+
> => {
|
|
378
|
+
try {
|
|
379
|
+
if (isThirdPartyCallResult(request)) {
|
|
380
|
+
let callbackPayload: string;
|
|
381
|
+
if (requestPayload) {
|
|
382
|
+
callbackPayload = requestPayload;
|
|
383
|
+
} else {
|
|
384
|
+
const workflowRunId = request.headers.get("upstash-workflow-runid");
|
|
385
|
+
const messageId = request.headers.get("upstash-message-id");
|
|
386
|
+
|
|
387
|
+
if (!workflowRunId)
|
|
388
|
+
throw new WorkflowError("workflow run id missing in context.call lazy fetch.");
|
|
389
|
+
if (!messageId) throw new WorkflowError("message id missing in context.call lazy fetch.");
|
|
390
|
+
|
|
391
|
+
const { steps, workflowRunEnded } = await getSteps(
|
|
392
|
+
client.http,
|
|
393
|
+
workflowRunId,
|
|
394
|
+
messageId,
|
|
395
|
+
middlewareManager?.dispatchDebug.bind(middlewareManager)
|
|
396
|
+
);
|
|
397
|
+
if (workflowRunEnded) {
|
|
398
|
+
return ok("workflow-ended");
|
|
399
|
+
}
|
|
400
|
+
const failingStep = steps.find((step) => step.messageId === messageId);
|
|
401
|
+
|
|
402
|
+
if (!failingStep)
|
|
403
|
+
throw new WorkflowError(
|
|
404
|
+
"Failed to submit the context.call. " +
|
|
405
|
+
(steps.length === 0
|
|
406
|
+
? "No steps found."
|
|
407
|
+
: `No step was found with matching messageId ${messageId} out of ${steps.length} steps.`)
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
callbackPayload = atob(failingStep.body);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const callbackMessage = JSON.parse(callbackPayload) as {
|
|
414
|
+
status: number;
|
|
415
|
+
body?: string;
|
|
416
|
+
retried?: number; // only set after the first try
|
|
417
|
+
maxRetries: number;
|
|
418
|
+
header: Record<string, string[]>;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
if (
|
|
422
|
+
!(callbackMessage.status >= 200 && callbackMessage.status < 300) &&
|
|
423
|
+
callbackMessage.maxRetries &&
|
|
424
|
+
callbackMessage.retried !== callbackMessage.maxRetries
|
|
425
|
+
) {
|
|
426
|
+
await middlewareManager?.dispatchDebug("onWarning", {
|
|
427
|
+
warning: `Third party call returned status ${callbackMessage.status}. Retrying (${callbackMessage.retried} out of ${callbackMessage.maxRetries}).`,
|
|
428
|
+
});
|
|
429
|
+
// this callback will be retried by the QStash, we just ignore it
|
|
430
|
+
console.warn(
|
|
431
|
+
`Workflow Warning: "context.call" failed with status ${callbackMessage.status}` +
|
|
432
|
+
` and will retry (retried ${callbackMessage.retried ?? 0} out of ${callbackMessage.maxRetries} times).` +
|
|
433
|
+
` Error Message:\n${atob(callbackMessage.body ?? "")}`
|
|
434
|
+
);
|
|
435
|
+
return ok("call-will-retry");
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const workflowRunId = request.headers.get(WORKFLOW_ID_HEADER);
|
|
439
|
+
const stepIdString = request.headers.get("Upstash-Workflow-StepId");
|
|
440
|
+
const stepName = request.headers.get("Upstash-Workflow-StepName");
|
|
441
|
+
const stepType = request.headers.get("Upstash-Workflow-StepType") as StepType;
|
|
442
|
+
const concurrentString = request.headers.get("Upstash-Workflow-Concurrent");
|
|
443
|
+
const contentType = request.headers.get("Upstash-Workflow-ContentType");
|
|
444
|
+
const invokeCount = request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER);
|
|
445
|
+
const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
|
|
446
|
+
|
|
447
|
+
if (
|
|
448
|
+
!(
|
|
449
|
+
(
|
|
450
|
+
workflowRunId &&
|
|
451
|
+
stepIdString &&
|
|
452
|
+
stepName &&
|
|
453
|
+
StepTypes.includes(stepType) &&
|
|
454
|
+
concurrentString &&
|
|
455
|
+
contentType
|
|
456
|
+
)
|
|
457
|
+
// not adding invokeCount to required for backwards compatibility.
|
|
458
|
+
)
|
|
459
|
+
) {
|
|
460
|
+
throw new Error(
|
|
461
|
+
`Missing info in callback message source header: ${JSON.stringify({
|
|
462
|
+
workflowRunId,
|
|
463
|
+
stepIdString,
|
|
464
|
+
stepName,
|
|
465
|
+
stepType,
|
|
466
|
+
concurrentString,
|
|
467
|
+
contentType,
|
|
468
|
+
})}`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const { headers: requestHeaders } = getHeaders({
|
|
473
|
+
initHeaderValue: "false",
|
|
474
|
+
workflowConfig: {
|
|
475
|
+
workflowRunId,
|
|
476
|
+
workflowUrl,
|
|
477
|
+
workflowRunCreatedAt: Number(workflowRunCreatedAt ?? "0"),
|
|
478
|
+
telemetry,
|
|
479
|
+
},
|
|
480
|
+
invokeCount: Number(invokeCount),
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
const callResponse: CallResponse = {
|
|
484
|
+
status: callbackMessage.status,
|
|
485
|
+
body: atob(callbackMessage.body ?? ""),
|
|
486
|
+
header: callbackMessage.header,
|
|
487
|
+
};
|
|
488
|
+
const callResultStep: Step<string> = {
|
|
489
|
+
stepId: Number(stepIdString),
|
|
490
|
+
stepName,
|
|
491
|
+
stepType,
|
|
492
|
+
out: JSON.stringify(callResponse),
|
|
493
|
+
concurrent: Number(concurrentString),
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
await middlewareManager?.dispatchDebug("onInfo", {
|
|
497
|
+
info: `Submitting third party call result, step ${stepName} (${stepIdString}).`,
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
await client.publishJSON({
|
|
501
|
+
headers: requestHeaders,
|
|
502
|
+
method: "POST",
|
|
503
|
+
body: callResultStep,
|
|
504
|
+
url: workflowUrl,
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
await middlewareManager?.dispatchDebug("onInfo", {
|
|
508
|
+
info: `Third party call result submitted successfully, step ${stepName} (${stepIdString}).`,
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
return ok("is-call-return");
|
|
512
|
+
} else {
|
|
513
|
+
return ok("continue-workflow");
|
|
514
|
+
}
|
|
515
|
+
} catch (error) {
|
|
516
|
+
const isCallReturn = request.headers.get("Upstash-Workflow-Callback");
|
|
517
|
+
return err(
|
|
518
|
+
new WorkflowError(`Error when handling call return (isCallReturn=${isCallReturn}): ${error}`)
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
export type HeadersResponse = {
|
|
524
|
+
headers: Record<string, string>;
|
|
525
|
+
contentType: string;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Converts telemetry object to headers.
|
|
530
|
+
*
|
|
531
|
+
* @param telemetry telemetry object with SDK, framework, and runtime info
|
|
532
|
+
*/
|
|
533
|
+
export const getTelemetryHeaders = (telemetry: Telemetry) => {
|
|
534
|
+
return {
|
|
535
|
+
[TELEMETRY_HEADER_SDK]: telemetry.sdk,
|
|
536
|
+
[TELEMETRY_HEADER_FRAMEWORK]: telemetry.framework ?? "unknown",
|
|
537
|
+
[TELEMETRY_HEADER_RUNTIME]: telemetry.runtime ?? "unknown",
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Verifies that a request comes from QStash using signature verification.
|
|
543
|
+
*
|
|
544
|
+
* @param body request body
|
|
545
|
+
* @param signature signature from the header
|
|
546
|
+
* @param verifier optional workflow receiver for verification
|
|
547
|
+
*/
|
|
548
|
+
export const verifyRequest = async (
|
|
549
|
+
body: string,
|
|
550
|
+
signature: string | null,
|
|
551
|
+
verifier?: WorkflowReceiver
|
|
552
|
+
) => {
|
|
553
|
+
if (!verifier) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
try {
|
|
558
|
+
if (!signature) {
|
|
559
|
+
throw new Error("`Upstash-Signature` header is not passed.");
|
|
560
|
+
}
|
|
561
|
+
const isValid = await verifier.verify({
|
|
562
|
+
body,
|
|
563
|
+
signature,
|
|
564
|
+
});
|
|
565
|
+
if (!isValid) {
|
|
566
|
+
throw new Error("Signature in `Upstash-Signature` header is not valid");
|
|
567
|
+
}
|
|
568
|
+
} catch (error) {
|
|
569
|
+
throw new WorkflowError(
|
|
570
|
+
`Failed to verify that the Workflow request comes from QStash: ${error}\n\n` +
|
|
571
|
+
"If signature is missing, trigger the workflow endpoint by publishing your request to QStash instead of calling it directly.\n\n" +
|
|
572
|
+
"If you want to disable QStash Verification, you should clear env variables QSTASH_CURRENT_SIGNING_KEY and QSTASH_NEXT_SIGNING_KEY"
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
};
|
package/svelte.d.mts
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import * as _sveltejs_kit from '@sveltejs/kit';
|
|
2
2
|
import { RequestHandler } from '@sveltejs/kit';
|
|
3
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
3
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-CrgK5P6p.mjs';
|
|
4
|
+
import { s as serveManyBase } from './serve-many-BKukvLNl.mjs';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
|
+
import 'neverthrow';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Serve method to serve a Upstash Workflow in a Svelte project
|
|
10
11
|
*
|
|
11
12
|
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
12
13
|
*
|
|
14
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
15
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
16
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
17
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
18
|
+
* result.
|
|
19
|
+
*
|
|
13
20
|
* @param routeFunction workflow function
|
|
14
21
|
* @param options workflow options
|
|
15
22
|
* @returns
|
|
23
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
24
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/svelte.mdx
|
|
16
25
|
*/
|
|
17
26
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options: WorkflowServeOptions<TInitialPayload, TResult> & {
|
|
18
27
|
env: WorkflowServeOptions["env"];
|
|
19
28
|
}) => {
|
|
20
29
|
POST: RequestHandler;
|
|
21
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
33
|
+
*/
|
|
22
34
|
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
35
|
+
/**
|
|
36
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
37
|
+
*/
|
|
23
38
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
24
39
|
POST: (event: _sveltejs_kit.RequestEvent<Record<string, string>, string | null>) => Promise<any>;
|
|
25
40
|
};
|
package/svelte.d.ts
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import * as _sveltejs_kit from '@sveltejs/kit';
|
|
2
2
|
import { RequestHandler } from '@sveltejs/kit';
|
|
3
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
3
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-CrgK5P6p.js';
|
|
4
|
+
import { s as serveManyBase } from './serve-many-CrLKQpuZ.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
|
+
import 'neverthrow';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Serve method to serve a Upstash Workflow in a Svelte project
|
|
10
11
|
*
|
|
11
12
|
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
12
13
|
*
|
|
14
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
15
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
16
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
17
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
18
|
+
* result.
|
|
19
|
+
*
|
|
13
20
|
* @param routeFunction workflow function
|
|
14
21
|
* @param options workflow options
|
|
15
22
|
* @returns
|
|
23
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
24
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/svelte.mdx
|
|
16
25
|
*/
|
|
17
26
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options: WorkflowServeOptions<TInitialPayload, TResult> & {
|
|
18
27
|
env: WorkflowServeOptions["env"];
|
|
19
28
|
}) => {
|
|
20
29
|
POST: RequestHandler;
|
|
21
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
33
|
+
*/
|
|
22
34
|
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
35
|
+
/**
|
|
36
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
37
|
+
*/
|
|
23
38
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
24
39
|
POST: (event: _sveltejs_kit.RequestEvent<Record<string, string>, string | null>) => Promise<any>;
|
|
25
40
|
};
|