@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
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StepType, R as RawStep, W as WorkflowMiddleware, a as WorkflowClient, b as WorkflowReceiver, c as RouteFunction, d as WorkflowServeOptions, T as Telemetry, N as NotifyResponse, e as Waiter } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, f as CallSettings, D as DetailedFinishCondition, g as Duration, E as ExclusiveValidationOptions, F as FailureFunctionPayload, h as FinishCondition, H as HeaderParams, I as InvokableWorkflow, i as InvokeStepResponse, j as InvokeWorkflowRequest, L as LazyInvokeStepParams, k as NotifyStepResponse, P as ParallelCallState, Q as QStashClientExtraConfig, l as RequiredExceptFields, m as Step, n as StepFunction, o as
|
|
1
|
+
import { S as StepType, R as RawStep, W as WorkflowMiddleware, a as WorkflowClient, b as WorkflowReceiver, c as RouteFunction, d as WorkflowServeOptions, T as Telemetry, N as NotifyResponse, e as Waiter } from './types-CrgK5P6p.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, f as CallSettings, D as DetailedFinishCondition, g as Duration, E as ExclusiveValidationOptions, F as FailureFunctionPayload, h as FinishCondition, H as HeaderParams, I as InvokableWorkflow, i as InvokeStepResponse, j as InvokeWorkflowRequest, L as LazyInvokeStepParams, k as NotifyStepResponse, P as ParallelCallState, Q as QStashClientExtraConfig, l as RequiredExceptFields, m as Step, n as StepFunction, o as StepSettings, p as StepTypes, q as SyncStepFunction, r as WaitEventOptions, s as WaitRequest, t as WaitStepResponse, u as WorkflowAbort, v as WorkflowContext, w as WorkflowError, x as WorkflowNonRetryableError, y as WorkflowRetryAfterError } from './types-CrgK5P6p.mjs';
|
|
3
3
|
import { FlowControl, PublishRequest, HTTPMethods, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
|
+
import 'neverthrow';
|
|
5
6
|
|
|
6
7
|
type BaseStepLog = {
|
|
7
8
|
/**
|
|
@@ -347,6 +348,9 @@ type WorkflowRunLogs = {
|
|
|
347
348
|
cursor: string;
|
|
348
349
|
runs: WorkflowRunLog[];
|
|
349
350
|
};
|
|
351
|
+
/**
|
|
352
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/trigger.mdx
|
|
353
|
+
*/
|
|
350
354
|
type TriggerOptions = {
|
|
351
355
|
/**
|
|
352
356
|
* URL of the workflow to trigger
|
|
@@ -363,10 +367,13 @@ type TriggerOptions = {
|
|
|
363
367
|
/**
|
|
364
368
|
* Workflow run id to use for the workflow run.
|
|
365
369
|
* If not provided, a random workflow run id will be generated.
|
|
370
|
+
*
|
|
371
|
+
* "wfr_" is prepended (and doubled if you include it). Use the returned
|
|
372
|
+
* `workflowRunId` for notify, cancel and logs.
|
|
366
373
|
*/
|
|
367
374
|
workflowRunId?: string;
|
|
368
375
|
/**
|
|
369
|
-
* Number of
|
|
376
|
+
* Number of times each failed step of the run is retried.
|
|
370
377
|
*
|
|
371
378
|
* @default 3
|
|
372
379
|
*/
|
|
@@ -405,6 +412,8 @@ type TriggerOptions = {
|
|
|
405
412
|
/**
|
|
406
413
|
* Flow control to use for the workflow run.
|
|
407
414
|
* If not provided, no flow control will be used.
|
|
415
|
+
*
|
|
416
|
+
* @see node_modules/@upstash/workflow/docs/features/flow-control.mdx
|
|
408
417
|
*/
|
|
409
418
|
flowControl?: FlowControl;
|
|
410
419
|
/**
|
|
@@ -537,9 +546,17 @@ declare const serveBase: <TInitialPayload = unknown, TRequest extends Request =
|
|
|
537
546
|
* Creates an async method that handles incoming requests and runs the provided
|
|
538
547
|
* route function as a workflow.
|
|
539
548
|
*
|
|
549
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
550
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
551
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
552
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
553
|
+
* result.
|
|
554
|
+
*
|
|
540
555
|
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
541
556
|
* @param options - Options including the client and initialPayloadParser.
|
|
542
557
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
558
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
559
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/platforms.mdx
|
|
543
560
|
*/
|
|
544
561
|
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
|
|
545
562
|
|
|
@@ -756,6 +773,7 @@ declare class DLQ {
|
|
|
756
773
|
* - `workflowCreatedAt`: Filter items by workflow creation time.
|
|
757
774
|
* - `failureFunctionState`: Filter items by failure callback state.
|
|
758
775
|
* - `label`: Filter items by label.
|
|
776
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/list.mdx
|
|
759
777
|
*/
|
|
760
778
|
list(parameters?: {
|
|
761
779
|
cursor?: string;
|
|
@@ -790,6 +808,7 @@ declare class DLQ {
|
|
|
790
808
|
* cursor = result.cursor;
|
|
791
809
|
* } while (cursor);
|
|
792
810
|
* ```
|
|
811
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/resume.mdx
|
|
793
812
|
*/
|
|
794
813
|
resume(request: string | string[] | WorkflowDLQActionFilters, options?: ResumeRestartOptions): Promise<{
|
|
795
814
|
cursor?: string;
|
|
@@ -824,6 +843,7 @@ declare class DLQ {
|
|
|
824
843
|
* cursor = result.cursor;
|
|
825
844
|
* } while (cursor);
|
|
826
845
|
* ```
|
|
846
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/restart.mdx
|
|
827
847
|
*/
|
|
828
848
|
restart(request: string | string[] | WorkflowDLQActionFilters, options?: ResumeRestartOptions): Promise<{
|
|
829
849
|
cursor?: string;
|
|
@@ -839,6 +859,7 @@ declare class DLQ {
|
|
|
839
859
|
*
|
|
840
860
|
* @param dlqId - The ID of the DLQ message to retry
|
|
841
861
|
* @returns response with workflow run information
|
|
862
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/callback.mdx
|
|
842
863
|
*/
|
|
843
864
|
retryFailureFunction({ dlqId }: Pick<DLQResumeRestartOptions<string>, "dlqId">): Promise<DLQResumeRestartResponse & {
|
|
844
865
|
error?: string;
|
|
@@ -871,6 +892,7 @@ declare class DLQ {
|
|
|
871
892
|
* cursor = result.cursor;
|
|
872
893
|
* } while (cursor);
|
|
873
894
|
* ```
|
|
895
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/delete.mdx
|
|
874
896
|
*/
|
|
875
897
|
delete(request: string | string[] | WorkflowDLQActionFilters): Promise<{
|
|
876
898
|
cursor?: string;
|
|
@@ -889,6 +911,8 @@ type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
|
889
911
|
* import { Client } from "@upstash/workflow";
|
|
890
912
|
* const client = new Client({ token: "<QSTASH_TOKEN>" })
|
|
891
913
|
* ```
|
|
914
|
+
*
|
|
915
|
+
* @see node_modules/@upstash/workflow/docs/basics/client.mdx
|
|
892
916
|
*/
|
|
893
917
|
declare class Client {
|
|
894
918
|
private client;
|
|
@@ -914,6 +938,8 @@ declare class Client {
|
|
|
914
938
|
* ```ts
|
|
915
939
|
* const result = await client.cancel({ all: true, count: 50 });
|
|
916
940
|
* ```
|
|
941
|
+
*
|
|
942
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/cancel.mdx
|
|
917
943
|
*/
|
|
918
944
|
cancel(request: string | string[] | WorkflowRunCancelFilters): Promise<{
|
|
919
945
|
cancelled: number;
|
|
@@ -939,19 +965,14 @@ declare class Client {
|
|
|
939
965
|
* });
|
|
940
966
|
* ```
|
|
941
967
|
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
* ```ts
|
|
945
|
-
* await client.notify({
|
|
946
|
-
* eventId: "my-event-id",
|
|
947
|
-
* eventData: "my-data",
|
|
948
|
-
* workflowRunId: "wfr_123" // enables lookback
|
|
949
|
-
* });
|
|
950
|
-
* ```
|
|
951
|
-
*
|
|
952
|
-
* @param eventId event id to notify
|
|
968
|
+
* @param eventId event id to notify. Only letters, digits, "-", "_" and "." are allowed;
|
|
969
|
+
* QStash rejects other characters, such as ":".
|
|
953
970
|
* @param eventData data to provide to the workflow
|
|
954
|
-
* @param workflowRunId optional workflow run id for lookback
|
|
971
|
+
* @param workflowRunId optional workflow run id for lookback: the event is kept for the run
|
|
972
|
+
* even if it has not reached `waitForEvent` yet
|
|
973
|
+
* @returns the notified waiters. With `workflowRunId`, QStash returns a single object
|
|
974
|
+
* instead of an array, despite the type.
|
|
975
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/notify.mdx
|
|
955
976
|
*/
|
|
956
977
|
notify({ eventId, eventData, workflowRunId, }: {
|
|
957
978
|
eventId: string;
|
|
@@ -971,6 +992,7 @@ declare class Client {
|
|
|
971
992
|
* ```
|
|
972
993
|
*
|
|
973
994
|
* @param eventId event id to check
|
|
995
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/waiters.mdx
|
|
974
996
|
*/
|
|
975
997
|
getWaiters({ eventId }: {
|
|
976
998
|
eventId: string;
|
|
@@ -985,7 +1007,7 @@ declare class Client {
|
|
|
985
1007
|
* body: "hello there!", // Optional body
|
|
986
1008
|
* headers: { ... }, // Optional headers
|
|
987
1009
|
* workflowRunId: "my-workflow", // Optional workflow run ID
|
|
988
|
-
* retries: 3
|
|
1010
|
+
* retries: 3, // Optional retries for each step
|
|
989
1011
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
990
1012
|
* });
|
|
991
1013
|
*
|
|
@@ -1000,7 +1022,7 @@ declare class Client {
|
|
|
1000
1022
|
* body: "hello there!", // Optional body
|
|
1001
1023
|
* headers: { ... }, // Optional headers
|
|
1002
1024
|
* workflowRunId: "my-workflow", // Optional workflow run ID
|
|
1003
|
-
* retries: 3
|
|
1025
|
+
* retries: 3, // Optional retries for each step
|
|
1004
1026
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
1005
1027
|
* },
|
|
1006
1028
|
* {
|
|
@@ -1008,7 +1030,7 @@ declare class Client {
|
|
|
1008
1030
|
* body: "hello world!", // Optional body
|
|
1009
1031
|
* headers: { ... }, // Optional headers
|
|
1010
1032
|
* workflowRunId: "my-workflow-2", // Optional workflow run ID
|
|
1011
|
-
* retries: 5
|
|
1033
|
+
* retries: 5, // Optional retries for each step
|
|
1012
1034
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
1013
1035
|
* },
|
|
1014
1036
|
* ]);
|
|
@@ -1027,9 +1049,10 @@ declare class Client {
|
|
|
1027
1049
|
* you should pass different workflow run ids for different runs.
|
|
1028
1050
|
* The final workflowRunId will be `wfr_${workflowRunId}`, in
|
|
1029
1051
|
* other words: the workflow run id you pass will be prefixed
|
|
1030
|
-
* with `wfr_
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1052
|
+
* with `wfr_` (twice if it already starts with `wfr_`). Use the
|
|
1053
|
+
* returned workflowRunId for notify, cancel and logs.
|
|
1054
|
+
* @param retries number of times each failed step of the run is
|
|
1055
|
+
* retried. 3 by default.
|
|
1033
1056
|
* @param retryDelay delay between retries.
|
|
1034
1057
|
* @param flowControl Settings for controlling the number of active requests
|
|
1035
1058
|
* and number of requests per second with the same key.
|
|
@@ -1037,6 +1060,7 @@ declare class Client {
|
|
|
1037
1060
|
* execution of the workflow run. The delay is in seconds or can be passed
|
|
1038
1061
|
* as a string with a time unit (e.g. "1h", "30m", "15s").
|
|
1039
1062
|
* @returns workflow run id or an array of workflow run ids
|
|
1063
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/trigger.mdx
|
|
1040
1064
|
*/
|
|
1041
1065
|
trigger(params: TriggerOptions): Promise<{
|
|
1042
1066
|
workflowRunId: string;
|
|
@@ -1070,6 +1094,8 @@ declare class Client {
|
|
|
1070
1094
|
*
|
|
1071
1095
|
* const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
|
|
1072
1096
|
* ```
|
|
1097
|
+
*
|
|
1098
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/logs.mdx
|
|
1073
1099
|
*/
|
|
1074
1100
|
logs(params?: {
|
|
1075
1101
|
cursor?: string;
|
|
@@ -1086,6 +1112,9 @@ declare class Client {
|
|
|
1086
1112
|
/** @deprecated Use `filter.workflowCreatedAt` instead. */
|
|
1087
1113
|
workflowCreatedAt?: number;
|
|
1088
1114
|
}): Promise<WorkflowRunLogs>;
|
|
1115
|
+
/**
|
|
1116
|
+
* @see node_modules/@upstash/workflow/docs/features/dlq.mdx
|
|
1117
|
+
*/
|
|
1089
1118
|
get dlq(): DLQ;
|
|
1090
1119
|
}
|
|
1091
1120
|
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StepType, R as RawStep, W as WorkflowMiddleware, a as WorkflowClient, b as WorkflowReceiver, c as RouteFunction, d as WorkflowServeOptions, T as Telemetry, N as NotifyResponse, e as Waiter } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, f as CallSettings, D as DetailedFinishCondition, g as Duration, E as ExclusiveValidationOptions, F as FailureFunctionPayload, h as FinishCondition, H as HeaderParams, I as InvokableWorkflow, i as InvokeStepResponse, j as InvokeWorkflowRequest, L as LazyInvokeStepParams, k as NotifyStepResponse, P as ParallelCallState, Q as QStashClientExtraConfig, l as RequiredExceptFields, m as Step, n as StepFunction, o as
|
|
1
|
+
import { S as StepType, R as RawStep, W as WorkflowMiddleware, a as WorkflowClient, b as WorkflowReceiver, c as RouteFunction, d as WorkflowServeOptions, T as Telemetry, N as NotifyResponse, e as Waiter } from './types-CrgK5P6p.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, f as CallSettings, D as DetailedFinishCondition, g as Duration, E as ExclusiveValidationOptions, F as FailureFunctionPayload, h as FinishCondition, H as HeaderParams, I as InvokableWorkflow, i as InvokeStepResponse, j as InvokeWorkflowRequest, L as LazyInvokeStepParams, k as NotifyStepResponse, P as ParallelCallState, Q as QStashClientExtraConfig, l as RequiredExceptFields, m as Step, n as StepFunction, o as StepSettings, p as StepTypes, q as SyncStepFunction, r as WaitEventOptions, s as WaitRequest, t as WaitStepResponse, u as WorkflowAbort, v as WorkflowContext, w as WorkflowError, x as WorkflowNonRetryableError, y as WorkflowRetryAfterError } from './types-CrgK5P6p.js';
|
|
3
3
|
import { FlowControl, PublishRequest, HTTPMethods, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
|
+
import 'neverthrow';
|
|
5
6
|
|
|
6
7
|
type BaseStepLog = {
|
|
7
8
|
/**
|
|
@@ -347,6 +348,9 @@ type WorkflowRunLogs = {
|
|
|
347
348
|
cursor: string;
|
|
348
349
|
runs: WorkflowRunLog[];
|
|
349
350
|
};
|
|
351
|
+
/**
|
|
352
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/trigger.mdx
|
|
353
|
+
*/
|
|
350
354
|
type TriggerOptions = {
|
|
351
355
|
/**
|
|
352
356
|
* URL of the workflow to trigger
|
|
@@ -363,10 +367,13 @@ type TriggerOptions = {
|
|
|
363
367
|
/**
|
|
364
368
|
* Workflow run id to use for the workflow run.
|
|
365
369
|
* If not provided, a random workflow run id will be generated.
|
|
370
|
+
*
|
|
371
|
+
* "wfr_" is prepended (and doubled if you include it). Use the returned
|
|
372
|
+
* `workflowRunId` for notify, cancel and logs.
|
|
366
373
|
*/
|
|
367
374
|
workflowRunId?: string;
|
|
368
375
|
/**
|
|
369
|
-
* Number of
|
|
376
|
+
* Number of times each failed step of the run is retried.
|
|
370
377
|
*
|
|
371
378
|
* @default 3
|
|
372
379
|
*/
|
|
@@ -405,6 +412,8 @@ type TriggerOptions = {
|
|
|
405
412
|
/**
|
|
406
413
|
* Flow control to use for the workflow run.
|
|
407
414
|
* If not provided, no flow control will be used.
|
|
415
|
+
*
|
|
416
|
+
* @see node_modules/@upstash/workflow/docs/features/flow-control.mdx
|
|
408
417
|
*/
|
|
409
418
|
flowControl?: FlowControl;
|
|
410
419
|
/**
|
|
@@ -537,9 +546,17 @@ declare const serveBase: <TInitialPayload = unknown, TRequest extends Request =
|
|
|
537
546
|
* Creates an async method that handles incoming requests and runs the provided
|
|
538
547
|
* route function as a workflow.
|
|
539
548
|
*
|
|
549
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
550
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
551
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
552
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
553
|
+
* result.
|
|
554
|
+
*
|
|
540
555
|
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
541
556
|
* @param options - Options including the client and initialPayloadParser.
|
|
542
557
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
558
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
559
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/platforms.mdx
|
|
543
560
|
*/
|
|
544
561
|
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
|
|
545
562
|
|
|
@@ -756,6 +773,7 @@ declare class DLQ {
|
|
|
756
773
|
* - `workflowCreatedAt`: Filter items by workflow creation time.
|
|
757
774
|
* - `failureFunctionState`: Filter items by failure callback state.
|
|
758
775
|
* - `label`: Filter items by label.
|
|
776
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/list.mdx
|
|
759
777
|
*/
|
|
760
778
|
list(parameters?: {
|
|
761
779
|
cursor?: string;
|
|
@@ -790,6 +808,7 @@ declare class DLQ {
|
|
|
790
808
|
* cursor = result.cursor;
|
|
791
809
|
* } while (cursor);
|
|
792
810
|
* ```
|
|
811
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/resume.mdx
|
|
793
812
|
*/
|
|
794
813
|
resume(request: string | string[] | WorkflowDLQActionFilters, options?: ResumeRestartOptions): Promise<{
|
|
795
814
|
cursor?: string;
|
|
@@ -824,6 +843,7 @@ declare class DLQ {
|
|
|
824
843
|
* cursor = result.cursor;
|
|
825
844
|
* } while (cursor);
|
|
826
845
|
* ```
|
|
846
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/restart.mdx
|
|
827
847
|
*/
|
|
828
848
|
restart(request: string | string[] | WorkflowDLQActionFilters, options?: ResumeRestartOptions): Promise<{
|
|
829
849
|
cursor?: string;
|
|
@@ -839,6 +859,7 @@ declare class DLQ {
|
|
|
839
859
|
*
|
|
840
860
|
* @param dlqId - The ID of the DLQ message to retry
|
|
841
861
|
* @returns response with workflow run information
|
|
862
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/callback.mdx
|
|
842
863
|
*/
|
|
843
864
|
retryFailureFunction({ dlqId }: Pick<DLQResumeRestartOptions<string>, "dlqId">): Promise<DLQResumeRestartResponse & {
|
|
844
865
|
error?: string;
|
|
@@ -871,6 +892,7 @@ declare class DLQ {
|
|
|
871
892
|
* cursor = result.cursor;
|
|
872
893
|
* } while (cursor);
|
|
873
894
|
* ```
|
|
895
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/dlq/delete.mdx
|
|
874
896
|
*/
|
|
875
897
|
delete(request: string | string[] | WorkflowDLQActionFilters): Promise<{
|
|
876
898
|
cursor?: string;
|
|
@@ -889,6 +911,8 @@ type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
|
889
911
|
* import { Client } from "@upstash/workflow";
|
|
890
912
|
* const client = new Client({ token: "<QSTASH_TOKEN>" })
|
|
891
913
|
* ```
|
|
914
|
+
*
|
|
915
|
+
* @see node_modules/@upstash/workflow/docs/basics/client.mdx
|
|
892
916
|
*/
|
|
893
917
|
declare class Client {
|
|
894
918
|
private client;
|
|
@@ -914,6 +938,8 @@ declare class Client {
|
|
|
914
938
|
* ```ts
|
|
915
939
|
* const result = await client.cancel({ all: true, count: 50 });
|
|
916
940
|
* ```
|
|
941
|
+
*
|
|
942
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/cancel.mdx
|
|
917
943
|
*/
|
|
918
944
|
cancel(request: string | string[] | WorkflowRunCancelFilters): Promise<{
|
|
919
945
|
cancelled: number;
|
|
@@ -939,19 +965,14 @@ declare class Client {
|
|
|
939
965
|
* });
|
|
940
966
|
* ```
|
|
941
967
|
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
* ```ts
|
|
945
|
-
* await client.notify({
|
|
946
|
-
* eventId: "my-event-id",
|
|
947
|
-
* eventData: "my-data",
|
|
948
|
-
* workflowRunId: "wfr_123" // enables lookback
|
|
949
|
-
* });
|
|
950
|
-
* ```
|
|
951
|
-
*
|
|
952
|
-
* @param eventId event id to notify
|
|
968
|
+
* @param eventId event id to notify. Only letters, digits, "-", "_" and "." are allowed;
|
|
969
|
+
* QStash rejects other characters, such as ":".
|
|
953
970
|
* @param eventData data to provide to the workflow
|
|
954
|
-
* @param workflowRunId optional workflow run id for lookback
|
|
971
|
+
* @param workflowRunId optional workflow run id for lookback: the event is kept for the run
|
|
972
|
+
* even if it has not reached `waitForEvent` yet
|
|
973
|
+
* @returns the notified waiters. With `workflowRunId`, QStash returns a single object
|
|
974
|
+
* instead of an array, despite the type.
|
|
975
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/notify.mdx
|
|
955
976
|
*/
|
|
956
977
|
notify({ eventId, eventData, workflowRunId, }: {
|
|
957
978
|
eventId: string;
|
|
@@ -971,6 +992,7 @@ declare class Client {
|
|
|
971
992
|
* ```
|
|
972
993
|
*
|
|
973
994
|
* @param eventId event id to check
|
|
995
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/waiters.mdx
|
|
974
996
|
*/
|
|
975
997
|
getWaiters({ eventId }: {
|
|
976
998
|
eventId: string;
|
|
@@ -985,7 +1007,7 @@ declare class Client {
|
|
|
985
1007
|
* body: "hello there!", // Optional body
|
|
986
1008
|
* headers: { ... }, // Optional headers
|
|
987
1009
|
* workflowRunId: "my-workflow", // Optional workflow run ID
|
|
988
|
-
* retries: 3
|
|
1010
|
+
* retries: 3, // Optional retries for each step
|
|
989
1011
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
990
1012
|
* });
|
|
991
1013
|
*
|
|
@@ -1000,7 +1022,7 @@ declare class Client {
|
|
|
1000
1022
|
* body: "hello there!", // Optional body
|
|
1001
1023
|
* headers: { ... }, // Optional headers
|
|
1002
1024
|
* workflowRunId: "my-workflow", // Optional workflow run ID
|
|
1003
|
-
* retries: 3
|
|
1025
|
+
* retries: 3, // Optional retries for each step
|
|
1004
1026
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
1005
1027
|
* },
|
|
1006
1028
|
* {
|
|
@@ -1008,7 +1030,7 @@ declare class Client {
|
|
|
1008
1030
|
* body: "hello world!", // Optional body
|
|
1009
1031
|
* headers: { ... }, // Optional headers
|
|
1010
1032
|
* workflowRunId: "my-workflow-2", // Optional workflow run ID
|
|
1011
|
-
* retries: 5
|
|
1033
|
+
* retries: 5, // Optional retries for each step
|
|
1012
1034
|
* retryDelay: "1000" // Optional retry delay for the delay between retries
|
|
1013
1035
|
* },
|
|
1014
1036
|
* ]);
|
|
@@ -1027,9 +1049,10 @@ declare class Client {
|
|
|
1027
1049
|
* you should pass different workflow run ids for different runs.
|
|
1028
1050
|
* The final workflowRunId will be `wfr_${workflowRunId}`, in
|
|
1029
1051
|
* other words: the workflow run id you pass will be prefixed
|
|
1030
|
-
* with `wfr_
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1052
|
+
* with `wfr_` (twice if it already starts with `wfr_`). Use the
|
|
1053
|
+
* returned workflowRunId for notify, cancel and logs.
|
|
1054
|
+
* @param retries number of times each failed step of the run is
|
|
1055
|
+
* retried. 3 by default.
|
|
1033
1056
|
* @param retryDelay delay between retries.
|
|
1034
1057
|
* @param flowControl Settings for controlling the number of active requests
|
|
1035
1058
|
* and number of requests per second with the same key.
|
|
@@ -1037,6 +1060,7 @@ declare class Client {
|
|
|
1037
1060
|
* execution of the workflow run. The delay is in seconds or can be passed
|
|
1038
1061
|
* as a string with a time unit (e.g. "1h", "30m", "15s").
|
|
1039
1062
|
* @returns workflow run id or an array of workflow run ids
|
|
1063
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/trigger.mdx
|
|
1040
1064
|
*/
|
|
1041
1065
|
trigger(params: TriggerOptions): Promise<{
|
|
1042
1066
|
workflowRunId: string;
|
|
@@ -1070,6 +1094,8 @@ declare class Client {
|
|
|
1070
1094
|
*
|
|
1071
1095
|
* const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
|
|
1072
1096
|
* ```
|
|
1097
|
+
*
|
|
1098
|
+
* @see node_modules/@upstash/workflow/docs/basics/client/logs.mdx
|
|
1073
1099
|
*/
|
|
1074
1100
|
logs(params?: {
|
|
1075
1101
|
cursor?: string;
|
|
@@ -1086,6 +1112,9 @@ declare class Client {
|
|
|
1086
1112
|
/** @deprecated Use `filter.workflowCreatedAt` instead. */
|
|
1087
1113
|
workflowCreatedAt?: number;
|
|
1088
1114
|
}): Promise<WorkflowRunLogs>;
|
|
1115
|
+
/**
|
|
1116
|
+
* @see node_modules/@upstash/workflow/docs/features/dlq.mdx
|
|
1117
|
+
*/
|
|
1089
1118
|
get dlq(): DLQ;
|
|
1090
1119
|
}
|
|
1091
1120
|
|