@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
package/nextjs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-CrgK5P6p.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-CrLKQpuZ.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'neverthrow';
|
|
@@ -10,21 +10,58 @@ import 'neverthrow';
|
|
|
10
10
|
*
|
|
11
11
|
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
12
12
|
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // app/api/workflow/route.ts
|
|
15
|
+
* import { serve } from "@upstash/workflow/nextjs";
|
|
16
|
+
*
|
|
17
|
+
* export const { POST } = serve(async (context) => { ... });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
21
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
22
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
23
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
24
|
+
* result.
|
|
25
|
+
*
|
|
13
26
|
* @param routeFunction workflow function
|
|
14
27
|
* @param options workflow options
|
|
15
28
|
* @returns
|
|
29
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
30
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/vercel-nextjs.mdx
|
|
16
31
|
*/
|
|
17
32
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => {
|
|
18
33
|
POST: (request: Request) => Promise<Response>;
|
|
19
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
37
|
+
*/
|
|
20
38
|
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
39
|
+
/**
|
|
40
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
41
|
+
*/
|
|
21
42
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
22
43
|
POST: (request: Request) => Promise<any>;
|
|
23
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Code outside steps runs again on every request of the run. Anything it branches on or
|
|
47
|
+
* returns early on (Date.now(), database rows, random values) must give the same answer on
|
|
48
|
+
* every request, or later requests fail with "Incompatible step name" or "Failed to
|
|
49
|
+
* authenticate Workflow request". Read such values inside `context.run` and branch on its
|
|
50
|
+
* result.
|
|
51
|
+
*
|
|
52
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
53
|
+
* @see node_modules/@upstash/workflow/docs/quickstarts/vercel-nextjs.mdx
|
|
54
|
+
*/
|
|
24
55
|
declare const servePagesRouter: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => {
|
|
25
56
|
handler: NextApiHandler;
|
|
26
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
60
|
+
*/
|
|
27
61
|
declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(...params: Parameters<typeof servePagesRouter<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
62
|
+
/**
|
|
63
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
64
|
+
*/
|
|
28
65
|
declare const serveManyPagesRouter: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
29
66
|
handler: (req: NextApiRequest, res: NextApiResponse<any>) => Promise<any>;
|
|
30
67
|
};
|
package/nextjs.js
CHANGED
|
@@ -795,6 +795,10 @@ var triggerFirstInvocation = async (params) => {
|
|
|
795
795
|
workflowConfig: {
|
|
796
796
|
workflowRunId: workflowContext.workflowRunId,
|
|
797
797
|
workflowUrl: workflowContext.url,
|
|
798
|
+
// the run doesn't exist yet, so the trigger time is sent when the creation time
|
|
799
|
+
// is not known. serve and client.trigger set it on the context already, so a
|
|
800
|
+
// retry of this request carries the same value and is deduplicated.
|
|
801
|
+
workflowRunCreatedAt: workflowContext.workflowRunCreatedAt || Date.now(),
|
|
798
802
|
failureUrl,
|
|
799
803
|
retries,
|
|
800
804
|
retryDelay,
|
|
@@ -902,7 +906,10 @@ var triggerWorkflowDelete = async (workflowContext, result, cancel = false, disp
|
|
|
902
906
|
path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
|
|
903
907
|
method: "DELETE",
|
|
904
908
|
parseResponseAsJson: false,
|
|
905
|
-
body: JSON.stringify(result)
|
|
909
|
+
body: JSON.stringify(result),
|
|
910
|
+
// with the creation time, QStash deletes the run only if it is the same run.
|
|
911
|
+
// a late delete of a previous run can't delete a new run with the same id.
|
|
912
|
+
headers: workflowContext.workflowRunCreatedAt ? { [WORKFLOW_CREATED_AT_HEADER]: workflowContext.workflowRunCreatedAt.toString() } : void 0
|
|
906
913
|
});
|
|
907
914
|
await dispatchDebug?.("onInfo", {
|
|
908
915
|
info: `Workflow run ${workflowContext.workflowRunId} deleted from QStash successfully.`
|
|
@@ -979,6 +986,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
979
986
|
const concurrentString = request.headers.get("Upstash-Workflow-Concurrent");
|
|
980
987
|
const contentType = request.headers.get("Upstash-Workflow-ContentType");
|
|
981
988
|
const invokeCount = request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER);
|
|
989
|
+
const workflowRunCreatedAt = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
|
|
982
990
|
if (!(workflowRunId && stepIdString && stepName && StepTypes.includes(stepType) && concurrentString && contentType)) {
|
|
983
991
|
throw new Error(
|
|
984
992
|
`Missing info in callback message source header: ${JSON.stringify({
|
|
@@ -996,6 +1004,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
996
1004
|
workflowConfig: {
|
|
997
1005
|
workflowRunId,
|
|
998
1006
|
workflowUrl,
|
|
1007
|
+
workflowRunCreatedAt: Number(workflowRunCreatedAt ?? "0"),
|
|
999
1008
|
telemetry
|
|
1000
1009
|
},
|
|
1001
1010
|
invokeCount: Number(invokeCount)
|
|
@@ -1170,6 +1179,7 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
1170
1179
|
workflowConfig: {
|
|
1171
1180
|
workflowRunId: context.workflowRunId,
|
|
1172
1181
|
workflowUrl: context.url,
|
|
1182
|
+
workflowRunCreatedAt: context.workflowRunCreatedAt,
|
|
1173
1183
|
useJSONContent: false,
|
|
1174
1184
|
telemetry
|
|
1175
1185
|
},
|
|
@@ -1501,6 +1511,8 @@ var LazyWaitEventStep = class extends BaseLazyStep {
|
|
|
1501
1511
|
) : {},
|
|
1502
1512
|
// note: using WORKFLOW_ID_HEADER doesn't work, because Runid -> RunId:
|
|
1503
1513
|
"Upstash-Workflow-Runid": [context.workflowRunId],
|
|
1514
|
+
// same for WORKFLOW_CREATED_AT_HEADER, because Createdat -> CreatedAt:
|
|
1515
|
+
...context.workflowRunCreatedAt ? { "Upstash-Workflow-Createdat": [context.workflowRunCreatedAt.toString()] } : {},
|
|
1504
1516
|
[WORKFLOW_INIT_HEADER]: ["false"],
|
|
1505
1517
|
[WORKFLOW_URL_HEADER]: [context.url],
|
|
1506
1518
|
"Upstash-Workflow-CallType": ["step"]
|
|
@@ -1603,6 +1615,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1603
1615
|
workflowConfig: {
|
|
1604
1616
|
workflowRunId: context.workflowRunId,
|
|
1605
1617
|
workflowUrl: context.url,
|
|
1618
|
+
workflowRunCreatedAt: context.workflowRunCreatedAt,
|
|
1606
1619
|
telemetry,
|
|
1607
1620
|
useJSONContent: false
|
|
1608
1621
|
},
|
|
@@ -1612,6 +1625,9 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1612
1625
|
invokerHeaders[key] = value;
|
|
1613
1626
|
});
|
|
1614
1627
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
1628
|
+
if (context.workflowRunCreatedAt) {
|
|
1629
|
+
invokerHeaders["Upstash-Workflow-Createdat"] = context.workflowRunCreatedAt.toString();
|
|
1630
|
+
}
|
|
1615
1631
|
const request = {
|
|
1616
1632
|
body: stringifyBody(this.params.body),
|
|
1617
1633
|
headers: Object.fromEntries(
|
|
@@ -1640,6 +1656,9 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1640
1656
|
workflowConfig: {
|
|
1641
1657
|
workflowRunId: getWorkflowRunId(workflowRunId),
|
|
1642
1658
|
workflowUrl: newUrl,
|
|
1659
|
+
// the invoked run doesn't exist yet, so the creation time of the invoker run is sent.
|
|
1660
|
+
// it separates the invocations made by different runs of the invoker.
|
|
1661
|
+
workflowRunCreatedAt: context.workflowRunCreatedAt,
|
|
1643
1662
|
retries,
|
|
1644
1663
|
retryDelay,
|
|
1645
1664
|
telemetry,
|
|
@@ -1809,6 +1828,9 @@ var WorkflowHeaders = class {
|
|
|
1809
1828
|
[WORKFLOW_PROTOCOL_VERSION_HEADER]: WORKFLOW_PROTOCOL_VERSION,
|
|
1810
1829
|
...this.workflowConfig.telemetry ? getTelemetryHeaders(this.workflowConfig.telemetry) : {}
|
|
1811
1830
|
};
|
|
1831
|
+
if (this.workflowConfig.workflowRunCreatedAt) {
|
|
1832
|
+
this.headers.rawHeaders[WORKFLOW_CREATED_AT_HEADER] = this.workflowConfig.workflowRunCreatedAt.toString();
|
|
1833
|
+
}
|
|
1812
1834
|
if (this.stepInfo?.lazyStep.stepType !== "Call") {
|
|
1813
1835
|
this.headers.rawHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
|
|
1814
1836
|
}
|
|
@@ -2007,6 +2029,7 @@ var submitParallelSteps = async ({
|
|
|
2007
2029
|
workflowConfig: {
|
|
2008
2030
|
workflowRunId: context.workflowRunId,
|
|
2009
2031
|
workflowUrl: context.url,
|
|
2032
|
+
workflowRunCreatedAt: context.workflowRunCreatedAt,
|
|
2010
2033
|
telemetry
|
|
2011
2034
|
},
|
|
2012
2035
|
invokeCount,
|
|
@@ -2097,6 +2120,7 @@ var publishStepConfigRequest = async ({
|
|
|
2097
2120
|
initHeaderValue: "false",
|
|
2098
2121
|
workflowConfig: {
|
|
2099
2122
|
workflowRunId: context.workflowRunId,
|
|
2123
|
+
workflowRunCreatedAt: context.workflowRunCreatedAt,
|
|
2100
2124
|
workflowUrl: context.url,
|
|
2101
2125
|
telemetry
|
|
2102
2126
|
},
|
|
@@ -2109,7 +2133,9 @@ var publishStepConfigRequest = async ({
|
|
|
2109
2133
|
const result = await context.qstashClient.publishJSON({
|
|
2110
2134
|
headers: {
|
|
2111
2135
|
...headers,
|
|
2112
|
-
"Upstash-Workflow-CallType": WORKFLOW_STEP_CONFIG_CALL_TYPE
|
|
2136
|
+
"Upstash-Workflow-CallType": WORKFLOW_STEP_CONFIG_CALL_TYPE,
|
|
2137
|
+
"Upstash-Forward-Upstash-Workflow-StepId": targetStep.toString(),
|
|
2138
|
+
"Upstash-Forward-Upstash-Workflow-StepName": lazyStep.stepName
|
|
2113
2139
|
},
|
|
2114
2140
|
method: "POST",
|
|
2115
2141
|
body: { targetStep, invokeCount },
|
|
@@ -2128,6 +2154,19 @@ var publishStepConfigRequest = async ({
|
|
|
2128
2154
|
};
|
|
2129
2155
|
|
|
2130
2156
|
// src/qstash/step-config.ts
|
|
2157
|
+
var normalizeStepSettings = (settings) => {
|
|
2158
|
+
if (settings === void 0) {
|
|
2159
|
+
return void 0;
|
|
2160
|
+
}
|
|
2161
|
+
const { retries, retryDelay } = settings;
|
|
2162
|
+
if (retryDelay !== void 0 && typeof retryDelay !== "string") {
|
|
2163
|
+
throw new WorkflowNonRetryableError("Invalid step retryDelay: must be a string.");
|
|
2164
|
+
}
|
|
2165
|
+
if (retries !== void 0 && (!Number.isInteger(retries) || retries < 0)) {
|
|
2166
|
+
throw new WorkflowNonRetryableError("Invalid step retries: must be a non-negative integer.");
|
|
2167
|
+
}
|
|
2168
|
+
return { ...settings, retryDelay: retryDelay?.trim() || void 0 };
|
|
2169
|
+
};
|
|
2131
2170
|
var DEFAULT_PARALLELISM = 0;
|
|
2132
2171
|
var DEFAULT_RATE = 0;
|
|
2133
2172
|
var DEFAULT_PERIOD_SECONDS = 1;
|
|
@@ -2391,10 +2430,18 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2391
2430
|
dispatchLifecycle: this.dispatchLifecycle
|
|
2392
2431
|
});
|
|
2393
2432
|
if (lazyStep.supportsDeferredSubmission) {
|
|
2394
|
-
|
|
2433
|
+
const serializedOut = JSON.stringify(resultStep.out);
|
|
2434
|
+
this.pendingStep = {
|
|
2435
|
+
status: "held",
|
|
2436
|
+
lazyStep,
|
|
2437
|
+
resultStep: {
|
|
2438
|
+
...resultStep,
|
|
2439
|
+
out: serializedOut === void 0 ? void 0 : JSON.parse(serializedOut)
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2395
2442
|
return lazyStep.parseOut({
|
|
2396
2443
|
...resultStep,
|
|
2397
|
-
out:
|
|
2444
|
+
out: serializedOut
|
|
2398
2445
|
});
|
|
2399
2446
|
}
|
|
2400
2447
|
await submitStepResult({
|
|
@@ -2739,6 +2786,11 @@ var BaseWorkflowApi = class {
|
|
|
2739
2786
|
|
|
2740
2787
|
// src/context/api/anthropic.ts
|
|
2741
2788
|
var AnthropicAPI = class extends BaseWorkflowApi {
|
|
2789
|
+
/**
|
|
2790
|
+
* Runs as a `context.call` step, so the `context.call` caveats apply.
|
|
2791
|
+
*
|
|
2792
|
+
* @see node_modules/@upstash/workflow/docs/integrations/anthropic.mdx
|
|
2793
|
+
*/
|
|
2742
2794
|
async call(stepName, settings) {
|
|
2743
2795
|
const { token, operation, ...parameters } = settings;
|
|
2744
2796
|
return await this.callApi(stepName, {
|
|
@@ -2754,6 +2806,11 @@ var AnthropicAPI = class extends BaseWorkflowApi {
|
|
|
2754
2806
|
// src/context/api/openai.ts
|
|
2755
2807
|
var import_qstash7 = require("@upstash/qstash");
|
|
2756
2808
|
var OpenAIAPI = class extends BaseWorkflowApi {
|
|
2809
|
+
/**
|
|
2810
|
+
* Runs as a `context.call` step, so the `context.call` caveats apply.
|
|
2811
|
+
*
|
|
2812
|
+
* @see node_modules/@upstash/workflow/docs/integrations/openai.mdx
|
|
2813
|
+
*/
|
|
2757
2814
|
async call(stepName, settings) {
|
|
2758
2815
|
const { token, organization, operation, baseURL, ...parameters } = settings;
|
|
2759
2816
|
const useOpenAI = baseURL === void 0;
|
|
@@ -2771,6 +2828,11 @@ var OpenAIAPI = class extends BaseWorkflowApi {
|
|
|
2771
2828
|
// src/context/api/resend.ts
|
|
2772
2829
|
var import_qstash8 = require("@upstash/qstash");
|
|
2773
2830
|
var ResendAPI = class extends BaseWorkflowApi {
|
|
2831
|
+
/**
|
|
2832
|
+
* Runs as a `context.call` step, so the `context.call` caveats apply.
|
|
2833
|
+
*
|
|
2834
|
+
* @see node_modules/@upstash/workflow/docs/integrations/resend.mdx
|
|
2835
|
+
*/
|
|
2774
2836
|
async call(stepName, settings) {
|
|
2775
2837
|
const { token, batch = false, ...parameters } = settings;
|
|
2776
2838
|
return await this.callApi(stepName, {
|
|
@@ -3012,8 +3074,9 @@ var WorkflowContext = class {
|
|
|
3012
3074
|
*
|
|
3013
3075
|
* ```ts
|
|
3014
3076
|
* import { Client } from "@upstash/qstash"
|
|
3077
|
+
* import { serve } from "@upstash/workflow/nextjs"
|
|
3015
3078
|
*
|
|
3016
|
-
* export const POST = serve(
|
|
3079
|
+
* export const { POST } = serve(
|
|
3017
3080
|
* async (context) => {
|
|
3018
3081
|
* ...
|
|
3019
3082
|
* },
|
|
@@ -3038,7 +3101,7 @@ var WorkflowContext = class {
|
|
|
3038
3101
|
* Can be overwritten by passing a `url` parameter in `serve`:
|
|
3039
3102
|
*
|
|
3040
3103
|
* ```ts
|
|
3041
|
-
* export const POST = serve(
|
|
3104
|
+
* export const { POST } = serve(
|
|
3042
3105
|
* async (context) => {
|
|
3043
3106
|
* ...
|
|
3044
3107
|
* },
|
|
@@ -3056,7 +3119,7 @@ var WorkflowContext = class {
|
|
|
3056
3119
|
*
|
|
3057
3120
|
* ```ts
|
|
3058
3121
|
* // set requestPayload type to MyPayload:
|
|
3059
|
-
* export const POST = serve<MyPayload>(
|
|
3122
|
+
* export const { POST } = serve<MyPayload>(
|
|
3060
3123
|
* async (context) => {
|
|
3061
3124
|
* ...
|
|
3062
3125
|
* }
|
|
@@ -3068,7 +3131,7 @@ var WorkflowContext = class {
|
|
|
3068
3131
|
* the `initialPayloadParser` parameter:
|
|
3069
3132
|
*
|
|
3070
3133
|
* ```ts
|
|
3071
|
-
* export const POST = serve<MyPayload>(
|
|
3134
|
+
* export const { POST } = serve<MyPayload>(
|
|
3072
3135
|
* async (context) => {
|
|
3073
3136
|
* ...
|
|
3074
3137
|
* },
|
|
@@ -3077,6 +3140,13 @@ var WorkflowContext = class {
|
|
|
3077
3140
|
* }
|
|
3078
3141
|
* )
|
|
3079
3142
|
* ```
|
|
3143
|
+
*
|
|
3144
|
+
* When a `context.call` response comes back, the route runs up to its first step with this
|
|
3145
|
+
* set to the call-result envelope (and `workflowRunId` set to a random id) before the SDK
|
|
3146
|
+
* recognizes the request. Code before the first step must not dereference, validate or
|
|
3147
|
+
* return early on the payload; read it inside `context.run`.
|
|
3148
|
+
*
|
|
3149
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve/advanced.mdx
|
|
3080
3150
|
*/
|
|
3081
3151
|
requestPayload;
|
|
3082
3152
|
/**
|
|
@@ -3089,7 +3159,7 @@ var WorkflowContext = class {
|
|
|
3089
3159
|
* Can be set using the `env` option of serve:
|
|
3090
3160
|
*
|
|
3091
3161
|
* ```ts
|
|
3092
|
-
* export const POST = serve<MyPayload>(
|
|
3162
|
+
* export const { POST } = serve<MyPayload>(
|
|
3093
3163
|
* async (context) => {
|
|
3094
3164
|
* const key = context.env["API_KEY"];
|
|
3095
3165
|
* },
|
|
@@ -3255,18 +3325,24 @@ var WorkflowContext = class {
|
|
|
3255
3325
|
* )
|
|
3256
3326
|
* ```
|
|
3257
3327
|
*
|
|
3328
|
+
* Do not wrap steps in try/catch or `.catch` without rethrowing `WorkflowAbort`: each step
|
|
3329
|
+
* throws it to end the request. To stop retrying a failed step, throw
|
|
3330
|
+
* `WorkflowNonRetryableError`.
|
|
3331
|
+
*
|
|
3258
3332
|
* @param stepName name of the step
|
|
3259
3333
|
* @param stepFunction step function to be executed
|
|
3260
3334
|
* @param stepSettings step-level settings for this step
|
|
3261
3335
|
* @returns result of the step function
|
|
3336
|
+
* @see node_modules/@upstash/workflow/docs/steps/run.mdx
|
|
3262
3337
|
*/
|
|
3263
3338
|
async run(stepName, stepFunction, stepSettings) {
|
|
3339
|
+
const normalizedSettings = normalizeStepSettings(stepSettings);
|
|
3264
3340
|
if (stepSettings) {
|
|
3265
3341
|
validateFlowControl(stepSettings.flowControl);
|
|
3266
3342
|
}
|
|
3267
3343
|
const wrappedStepFunction = (() => this.executor.wrapStep(stepName, stepFunction));
|
|
3268
3344
|
return await this.addStep(
|
|
3269
|
-
new LazyFunctionStep(this, stepName, wrappedStepFunction,
|
|
3345
|
+
new LazyFunctionStep(this, stepName, wrappedStepFunction, normalizedSettings)
|
|
3270
3346
|
);
|
|
3271
3347
|
}
|
|
3272
3348
|
/**
|
|
@@ -3277,8 +3353,9 @@ var WorkflowContext = class {
|
|
|
3277
3353
|
* ```
|
|
3278
3354
|
*
|
|
3279
3355
|
* @param stepName
|
|
3280
|
-
* @param duration sleep duration in seconds
|
|
3356
|
+
* @param duration sleep duration in seconds, or a duration string such as "10m"
|
|
3281
3357
|
* @returns undefined
|
|
3358
|
+
* @see node_modules/@upstash/workflow/docs/steps/sleep.mdx
|
|
3282
3359
|
*/
|
|
3283
3360
|
async sleep(stepName, duration) {
|
|
3284
3361
|
await this.addStep(new LazySleepStep(this, stepName, duration));
|
|
@@ -3292,8 +3369,11 @@ var WorkflowContext = class {
|
|
|
3292
3369
|
*
|
|
3293
3370
|
* @param stepName
|
|
3294
3371
|
* @param datetime time to sleep until. Can be provided as a number (in unix seconds),
|
|
3295
|
-
* as a Date object or a string (passed to `new Date(datetimeString)`)
|
|
3372
|
+
* as a Date object or a string (passed to `new Date(datetimeString)`).
|
|
3373
|
+
* A millisecond timestamp such as `Date.now()` is too far in the future, so QStash
|
|
3374
|
+
* rejects the step and the run fails. Pass `new Date(ms)` instead.
|
|
3296
3375
|
* @returns undefined
|
|
3376
|
+
* @see node_modules/@upstash/workflow/docs/steps/sleepUntil.mdx
|
|
3297
3377
|
*/
|
|
3298
3378
|
async sleepUntil(stepName, datetime) {
|
|
3299
3379
|
let time;
|
|
@@ -3344,7 +3424,7 @@ var WorkflowContext = class {
|
|
|
3344
3424
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
3345
3425
|
*
|
|
3346
3426
|
*```ts
|
|
3347
|
-
* const result = await
|
|
3427
|
+
* const result = await context.waitForEvent("payment-confirmed", "payment.confirmed", {
|
|
3348
3428
|
* timeout: "5m"
|
|
3349
3429
|
* });
|
|
3350
3430
|
*```
|
|
@@ -3368,11 +3448,14 @@ var WorkflowContext = class {
|
|
|
3368
3448
|
* Alternatively, you can use the `context.notify` method.
|
|
3369
3449
|
*
|
|
3370
3450
|
* @param stepName
|
|
3371
|
-
* @param eventId - Unique identifier for the event to wait for
|
|
3451
|
+
* @param eventId - Unique identifier for the event to wait for. Only letters, digits,
|
|
3452
|
+
* "-", "_" and "." are allowed. QStash rejects other characters, such as ":", which
|
|
3453
|
+
* stops the run with only a "Tried to append to a cancelled workflow" warning.
|
|
3372
3454
|
* @param options - Configuration options.
|
|
3373
3455
|
* @returns `{ timeout: boolean, eventData: TEventData }`.
|
|
3374
3456
|
* The `timeout` property specifies if the workflow has timed out. The `eventData`
|
|
3375
3457
|
* is the data passed when notifying this workflow of an event.
|
|
3458
|
+
* @see node_modules/@upstash/workflow/docs/steps/waitForEvent.mdx
|
|
3376
3459
|
*/
|
|
3377
3460
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
3378
3461
|
const { timeout = "7d" } = options;
|
|
@@ -3394,28 +3477,31 @@ var WorkflowContext = class {
|
|
|
3394
3477
|
* will receive the given event data and resume execution.
|
|
3395
3478
|
*
|
|
3396
3479
|
* The response includes the same eventId and eventData. Additionally, there is
|
|
3397
|
-
* a notifyResponse field which contains a list of `
|
|
3398
|
-
* to a notified workflow run.
|
|
3399
|
-
*
|
|
3400
|
-
* Optionally, you can pass a workflowRunId to enable lookback functionality:
|
|
3401
|
-
*
|
|
3402
|
-
* ```ts
|
|
3403
|
-
* const { eventId, eventData, notifyResponse } = await context.notify(
|
|
3404
|
-
* "notify step", "event-id", "event-data", "wfr_123"
|
|
3405
|
-
* );
|
|
3406
|
-
* ```
|
|
3480
|
+
* a notifyResponse field which contains a list of `NotifyResponse` objects, each corresponding
|
|
3481
|
+
* to a notified workflow run. The notified `Waiter` is under `notifyResponse[i].waiter`.
|
|
3407
3482
|
*
|
|
3408
3483
|
* @param stepName
|
|
3409
|
-
* @param eventId event id to notify
|
|
3484
|
+
* @param eventId event id to notify. Only letters, digits, "-", "_" and "." are allowed.
|
|
3485
|
+
* QStash rejects other characters, such as ":", which stops the run with only a
|
|
3486
|
+
* "Tried to append to a cancelled workflow" warning.
|
|
3410
3487
|
* @param eventData event data to notify with
|
|
3411
|
-
* @param workflowRunId optional workflow run id for lookback
|
|
3412
|
-
*
|
|
3488
|
+
* @param workflowRunId optional workflow run id for lookback: the event is kept for the run
|
|
3489
|
+
* even if it has not reached `waitForEvent` yet
|
|
3490
|
+
* @returns notify response which has event id, event data and list of waiters which were
|
|
3491
|
+
* notified. With `workflowRunId`, QStash returns `notifyResponse` as a single object instead
|
|
3492
|
+
* of an array, despite the type.
|
|
3493
|
+
* @see node_modules/@upstash/workflow/docs/steps/notify.mdx
|
|
3413
3494
|
*/
|
|
3414
3495
|
async notify(stepName, eventId, eventData, workflowRunId) {
|
|
3415
3496
|
return await this.addStep(
|
|
3416
3497
|
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http, workflowRunId)
|
|
3417
3498
|
);
|
|
3418
3499
|
}
|
|
3500
|
+
/**
|
|
3501
|
+
* Starts another workflow run and waits for its result.
|
|
3502
|
+
*
|
|
3503
|
+
* @see node_modules/@upstash/workflow/docs/steps/invoke.mdx
|
|
3504
|
+
*/
|
|
3419
3505
|
async invoke(stepName, settings) {
|
|
3420
3506
|
validateLabel(settings.label);
|
|
3421
3507
|
validateFlowControl(settings.flowControl);
|
|
@@ -3423,9 +3509,15 @@ var WorkflowContext = class {
|
|
|
3423
3509
|
new LazyInvokeStep(this, stepName, settings)
|
|
3424
3510
|
);
|
|
3425
3511
|
}
|
|
3512
|
+
/**
|
|
3513
|
+
* @see node_modules/@upstash/workflow/docs/steps/createWebhook.mdx
|
|
3514
|
+
*/
|
|
3426
3515
|
async createWebhook(stepName) {
|
|
3427
3516
|
return await this.addStep(new LazyCreateWebhookStep(this, stepName));
|
|
3428
3517
|
}
|
|
3518
|
+
/**
|
|
3519
|
+
* @see node_modules/@upstash/workflow/docs/steps/waitForWebhook.mdx
|
|
3520
|
+
*/
|
|
3429
3521
|
async waitForWebhook(stepName, webhook, timeout) {
|
|
3430
3522
|
return await this.addStep(new LazyWaitForWebhookStep(this, stepName, webhook, timeout));
|
|
3431
3523
|
}
|
|
@@ -3434,6 +3526,8 @@ var WorkflowContext = class {
|
|
|
3434
3526
|
*
|
|
3435
3527
|
* Will throw WorkflowCancelAbort to stop workflow execution.
|
|
3436
3528
|
* Shouldn't be inside try/catch.
|
|
3529
|
+
*
|
|
3530
|
+
* @see node_modules/@upstash/workflow/docs/steps/cancel.mdx
|
|
3437
3531
|
*/
|
|
3438
3532
|
async cancel() {
|
|
3439
3533
|
throw new WorkflowCancelAbort();
|
|
@@ -3452,6 +3546,11 @@ var WorkflowContext = class {
|
|
|
3452
3546
|
throw error;
|
|
3453
3547
|
}
|
|
3454
3548
|
}
|
|
3549
|
+
/**
|
|
3550
|
+
* Calls OpenAI, Anthropic or Resend through QStash, like `context.call`.
|
|
3551
|
+
*
|
|
3552
|
+
* @see node_modules/@upstash/workflow/docs/steps/api.mdx
|
|
3553
|
+
*/
|
|
3455
3554
|
get api() {
|
|
3456
3555
|
return new WorkflowApi({
|
|
3457
3556
|
context: this
|
|
@@ -4234,7 +4333,8 @@ var serveBase = (routeFunction, telemetry, options, internalOptions) => {
|
|
|
4234
4333
|
const invokeCount = Number(request.headers.get(WORKFLOW_INVOKE_COUNT_HEADER) ?? "0");
|
|
4235
4334
|
const retried = Number(request.headers.get(WORKFLOW_RETRIED_HEADER) ?? "0");
|
|
4236
4335
|
const label = request.headers.get(WORKFLOW_LABEL_HEADER) ?? void 0;
|
|
4237
|
-
const
|
|
4336
|
+
const workflowRunCreatedAtHeader = request.headers.get(WORKFLOW_CREATED_AT_HEADER);
|
|
4337
|
+
const workflowRunCreatedAt = workflowRunCreatedAtHeader ? Number(workflowRunCreatedAtHeader) : isFirstInvocation ? Date.now() : 0;
|
|
4238
4338
|
const effectiveConfig = getEffectiveConfig(request.headers);
|
|
4239
4339
|
const workflowContext = new WorkflowContext({
|
|
4240
4340
|
qstashClient: regionalClient,
|
|
@@ -4249,7 +4349,7 @@ var serveBase = (routeFunction, telemetry, options, internalOptions) => {
|
|
|
4249
4349
|
invokeCount,
|
|
4250
4350
|
label,
|
|
4251
4351
|
retried,
|
|
4252
|
-
workflowRunCreatedAt
|
|
4352
|
+
workflowRunCreatedAt,
|
|
4253
4353
|
middlewareManager
|
|
4254
4354
|
});
|
|
4255
4355
|
const authCheck = await DisabledWorkflowContext.tryAuthentication(
|
package/nextjs.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/workflow","version":"1.
|
|
1
|
+
{"name":"@upstash/workflow","version":"1.5.0","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*","!src/**/*.test.*","!src/**/*.test-d.*","!src/**/*.spec.*","!src/**/test-utils.*","!src/**/__tests__/**","!src/**/__snapshots__/**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./astro":{"import":"./astro.mjs","require":"./astro.js"},"./express":{"import":"./express.mjs","require":"./express.js"},"./tanstack":{"import":"./tanstack.mjs","require":"./tanstack.js"},"./react-router":{"import":"./react-router.mjs","require":"./react-router.js"}},"scripts":{"build":"tsup && mkdir -p dist/src && cp -R src platforms dist/src/ && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P","prepack":"giget gh:upstash/docs/workflow docs --force-clean 1>&2"},"repository":{"type":"git","url":"git@github.com:upstash/workflow-js.git"},"keywords":["upstash","qstash","workflow","serverless"],"author":"Cahid Arda Oz","license":"MIT","bugs":{"url":"https://github.com/upstash/workflow-ts/issues"},"homepage":"https://github.com/upstash/workflow-ts#readme","devDependencies":{"@commitlint/cli":"^19.5.0","@commitlint/config-conventional":"^19.5.0","@eslint/js":"^9.11.1","@solidjs/start":"^1.0.8","@sveltejs/kit":"^2.6.1","@types/bun":"^1.1.10","@types/express":"^5.0.6","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^5.1.0","giget":"3.3.1","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.20","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsup":"^8.3.0","typescript":"^5.7.2","typescript-eslint":"^8.18.0"},"dependencies":{"@upstash/qstash":"^2.11.3"},"directories":{"example":"examples","doc":"./docs"},"peerDependencies":{"zod":"^3.25.0 || ^4.0.0"}}
|
package/react-router.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
2
|
-
import { s as serveManyBase } from './serve-many-
|
|
1
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-CrgK5P6p.mjs';
|
|
2
|
+
import { s as serveManyBase } from './serve-many-BKukvLNl.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'neverthrow';
|
|
@@ -11,6 +11,12 @@ import 'neverthrow';
|
|
|
11
11
|
*
|
|
12
12
|
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
13
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
|
+
*
|
|
14
20
|
* @example
|
|
15
21
|
* ```tsx
|
|
16
22
|
* import { serve } from "@upstash/workflow/react-router";
|
|
@@ -27,11 +33,18 @@ import 'neverthrow';
|
|
|
27
33
|
* @param routeFunction workflow function
|
|
28
34
|
* @param options workflow options
|
|
29
35
|
* @returns action function compatible with React Router v7
|
|
36
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
30
37
|
*/
|
|
31
38
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => ({ request }: {
|
|
32
39
|
request: Request;
|
|
33
40
|
}) => Promise<Response>;
|
|
41
|
+
/**
|
|
42
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
43
|
+
*/
|
|
34
44
|
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
45
|
+
/**
|
|
46
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
47
|
+
*/
|
|
35
48
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => (params_0: {
|
|
36
49
|
request: Request;
|
|
37
50
|
}) => Promise<any>;
|
package/react-router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-
|
|
2
|
-
import { s as serveManyBase } from './serve-many-
|
|
1
|
+
import { c as RouteFunction, d as WorkflowServeOptions, I as InvokableWorkflow } from './types-CrgK5P6p.js';
|
|
2
|
+
import { s as serveManyBase } from './serve-many-CrLKQpuZ.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'neverthrow';
|
|
@@ -11,6 +11,12 @@ import 'neverthrow';
|
|
|
11
11
|
*
|
|
12
12
|
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
13
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
|
+
*
|
|
14
20
|
* @example
|
|
15
21
|
* ```tsx
|
|
16
22
|
* import { serve } from "@upstash/workflow/react-router";
|
|
@@ -27,11 +33,18 @@ import 'neverthrow';
|
|
|
27
33
|
* @param routeFunction workflow function
|
|
28
34
|
* @param options workflow options
|
|
29
35
|
* @returns action function compatible with React Router v7
|
|
36
|
+
* @see node_modules/@upstash/workflow/docs/basics/serve.mdx
|
|
30
37
|
*/
|
|
31
38
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: WorkflowServeOptions<TInitialPayload, TResult>) => ({ request }: {
|
|
32
39
|
request: Request;
|
|
33
40
|
}) => Promise<Response>;
|
|
41
|
+
/**
|
|
42
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke.mdx
|
|
43
|
+
*/
|
|
34
44
|
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
45
|
+
/**
|
|
46
|
+
* @see node_modules/@upstash/workflow/docs/features/invoke/serveMany.mdx
|
|
47
|
+
*/
|
|
35
48
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => (params_0: {
|
|
36
49
|
request: Request;
|
|
37
50
|
}) => Promise<any>;
|