@upstash/workflow 0.1.0 → 0.1.1-canary
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/{chunk-JDMP6KKR.mjs → chunk-YW5KUHA2.mjs} +34 -20
- package/cloudflare.d.mts +4 -2
- package/cloudflare.d.ts +4 -2
- package/cloudflare.js +37 -23
- package/cloudflare.mjs +4 -4
- package/h3.d.mts +7 -5
- package/h3.d.ts +7 -5
- package/h3.js +36 -22
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +35 -21
- package/hono.mjs +2 -2
- package/index.d.mts +5 -3
- package/index.d.ts +5 -3
- package/index.js +34 -20
- package/index.mjs +1 -1
- package/nextjs.d.mts +7 -4
- package/nextjs.d.ts +7 -4
- package/nextjs.js +44 -28
- package/nextjs.mjs +11 -9
- package/package.json +1 -99
- package/solidjs.d.mts +4 -2
- package/solidjs.d.ts +4 -2
- package/solidjs.js +36 -22
- package/solidjs.mjs +3 -3
- package/svelte.d.mts +4 -2
- package/svelte.d.ts +4 -2
- package/svelte.js +37 -23
- package/svelte.mjs +4 -4
- package/{types-CfN1Epuj.d.mts → types-D8FBKkto.d.mts} +12 -2
- package/{types-CfN1Epuj.d.ts → types-D8FBKkto.d.ts} +12 -2
package/hono.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
serve
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YW5KUHA2.mjs";
|
|
4
4
|
|
|
5
5
|
// platforms/hono.ts
|
|
6
6
|
var serve2 = (routeFunction, options) => {
|
|
7
7
|
const handler = async (context) => {
|
|
8
8
|
const environment = context.env;
|
|
9
9
|
const request = context.req.raw;
|
|
10
|
-
const serveHandler = serve(routeFunction, {
|
|
10
|
+
const { handler: serveHandler } = serve(routeFunction, {
|
|
11
11
|
// when hono is used without cf workers, it sends a DebugHTTPServer
|
|
12
12
|
// object in `context.env`. don't pass env if this is the case:
|
|
13
13
|
env: "QSTASH_TOKEN" in environment ? environment : void 0,
|
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-D8FBKkto.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-D8FBKkto.mjs';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,7 +10,9 @@ import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
|
10
10
|
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
11
11
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
12
12
|
*/
|
|
13
|
-
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) =>
|
|
13
|
+
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
|
|
14
|
+
handler: (request: TRequest) => Promise<TResponse>;
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
16
18
|
declare class Client {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-D8FBKkto.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-D8FBKkto.js';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,7 +10,9 @@ import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
|
10
10
|
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
11
11
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
12
12
|
*/
|
|
13
|
-
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) =>
|
|
13
|
+
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
|
|
14
|
+
handler: (request: TRequest) => Promise<TResponse>;
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
16
18
|
declare class Client {
|
package/index.js
CHANGED
|
@@ -480,6 +480,7 @@ var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
|
|
|
480
480
|
var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
|
|
481
481
|
var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
|
|
482
482
|
var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
|
|
483
|
+
var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
|
|
483
484
|
var WORKFLOW_PROTOCOL_VERSION = "1";
|
|
484
485
|
var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
485
486
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
@@ -565,13 +566,13 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
|
|
|
565
566
|
try {
|
|
566
567
|
if (request.headers.get("Upstash-Workflow-Callback")) {
|
|
567
568
|
const callbackMessage = JSON.parse(requestPayload);
|
|
568
|
-
if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
|
|
569
|
+
if (!(callbackMessage.status >= 200 && callbackMessage.status < 300) && callbackMessage.maxRetries && callbackMessage.retried !== callbackMessage.maxRetries) {
|
|
569
570
|
await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
570
571
|
status: callbackMessage.status,
|
|
571
572
|
body: atob(callbackMessage.body)
|
|
572
573
|
});
|
|
573
574
|
console.warn(
|
|
574
|
-
`Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (
|
|
575
|
+
`Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (retried ${callbackMessage.retried ?? 0} out of ${callbackMessage.maxRetries} times). Error Message:
|
|
575
576
|
${atob(callbackMessage.body)}`
|
|
576
577
|
);
|
|
577
578
|
return ok("call-will-retry");
|
|
@@ -608,7 +609,11 @@ ${atob(callbackMessage.body)}`
|
|
|
608
609
|
stepId: Number(stepIdString),
|
|
609
610
|
stepName,
|
|
610
611
|
stepType,
|
|
611
|
-
out:
|
|
612
|
+
out: {
|
|
613
|
+
status: callbackMessage.status,
|
|
614
|
+
body: atob(callbackMessage.body),
|
|
615
|
+
header: callbackMessage.header
|
|
616
|
+
},
|
|
612
617
|
concurrent: Number(concurrentString)
|
|
613
618
|
};
|
|
614
619
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
@@ -643,15 +648,24 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
643
648
|
[WORKFLOW_INIT_HEADER]: initHeaderValue,
|
|
644
649
|
[WORKFLOW_ID_HEADER]: workflowRunId,
|
|
645
650
|
[WORKFLOW_URL_HEADER]: workflowUrl,
|
|
646
|
-
[
|
|
647
|
-
|
|
648
|
-
[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`]: "true",
|
|
649
|
-
"Upstash-Failure-Callback": failureUrl
|
|
650
|
-
} : {},
|
|
651
|
-
...retries === void 0 ? {} : {
|
|
652
|
-
"Upstash-Retries": retries.toString()
|
|
653
|
-
}
|
|
651
|
+
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
|
|
652
|
+
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
|
|
654
653
|
};
|
|
654
|
+
if (failureUrl) {
|
|
655
|
+
if (!step?.callUrl) {
|
|
656
|
+
baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
|
|
657
|
+
}
|
|
658
|
+
baseHeaders["Upstash-Failure-Callback"] = failureUrl;
|
|
659
|
+
}
|
|
660
|
+
if (step?.callUrl) {
|
|
661
|
+
baseHeaders["Upstash-Retries"] = "0";
|
|
662
|
+
if (retries) {
|
|
663
|
+
baseHeaders["Upstash-Callback-Retries"] = retries.toString();
|
|
664
|
+
baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
|
|
665
|
+
}
|
|
666
|
+
} else if (retries !== void 0) {
|
|
667
|
+
baseHeaders["Upstash-Retries"] = retries.toString();
|
|
668
|
+
}
|
|
655
669
|
if (userHeaders) {
|
|
656
670
|
for (const header of userHeaders.keys()) {
|
|
657
671
|
if (step?.callHeaders) {
|
|
@@ -1510,15 +1524,12 @@ var WorkflowContext = class {
|
|
|
1510
1524
|
* @returns call result (parsed as JSON if possible)
|
|
1511
1525
|
*/
|
|
1512
1526
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
1513
|
-
async call(stepName,
|
|
1527
|
+
async call(stepName, callSettings) {
|
|
1528
|
+
const { url, method = "GET", body, headers = {} } = callSettings;
|
|
1514
1529
|
const result = await this.addStep(
|
|
1515
|
-
new LazyCallStep(stepName, url, method, body, headers
|
|
1530
|
+
new LazyCallStep(stepName, url, method, body, headers)
|
|
1516
1531
|
);
|
|
1517
|
-
|
|
1518
|
-
return JSON.parse(result);
|
|
1519
|
-
} catch {
|
|
1520
|
-
return result;
|
|
1521
|
-
}
|
|
1532
|
+
return result;
|
|
1522
1533
|
}
|
|
1523
1534
|
async waitForEvent(stepName, eventId, timeout) {
|
|
1524
1535
|
const result = await this.addStep(
|
|
@@ -1886,6 +1897,7 @@ var serve = (routeFunction, options) => {
|
|
|
1886
1897
|
} = processOptions(options);
|
|
1887
1898
|
const debug = WorkflowLogger.getLogger(verbose);
|
|
1888
1899
|
const handler = async (request) => {
|
|
1900
|
+
await debug?.log("INFO", "ENDPOINT_START");
|
|
1889
1901
|
const { workflowUrl, workflowFailureUrl } = await determineUrls(
|
|
1890
1902
|
request,
|
|
1891
1903
|
url,
|
|
@@ -1929,7 +1941,8 @@ var serve = (routeFunction, options) => {
|
|
|
1929
1941
|
url: workflowUrl,
|
|
1930
1942
|
failureUrl: workflowFailureUrl,
|
|
1931
1943
|
debug,
|
|
1932
|
-
env
|
|
1944
|
+
env,
|
|
1945
|
+
retries
|
|
1933
1946
|
});
|
|
1934
1947
|
const authCheck = await DisabledWorkflowContext.tryAuthentication(
|
|
1935
1948
|
routeFunction,
|
|
@@ -1972,7 +1985,7 @@ var serve = (routeFunction, options) => {
|
|
|
1972
1985
|
await debug?.log("INFO", "RESPONSE_DEFAULT");
|
|
1973
1986
|
return onStepFinish("no-workflow-id", "fromCallback");
|
|
1974
1987
|
};
|
|
1975
|
-
|
|
1988
|
+
const safeHandler = async (request) => {
|
|
1976
1989
|
try {
|
|
1977
1990
|
return await handler(request);
|
|
1978
1991
|
} catch (error) {
|
|
@@ -1982,6 +1995,7 @@ var serve = (routeFunction, options) => {
|
|
|
1982
1995
|
});
|
|
1983
1996
|
}
|
|
1984
1997
|
};
|
|
1998
|
+
return { handler: safeHandler };
|
|
1985
1999
|
};
|
|
1986
2000
|
|
|
1987
2001
|
// src/client/index.ts
|
package/index.mjs
CHANGED
package/nextjs.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CfN1Epuj.mjs';
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.mjs';
|
|
4
3
|
import '@upstash/qstash';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -12,7 +11,11 @@ import '@upstash/qstash';
|
|
|
12
11
|
* @param options workflow options
|
|
13
12
|
* @returns
|
|
14
13
|
*/
|
|
15
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<
|
|
16
|
-
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
15
|
+
POST: (request: Request) => Promise<Response>;
|
|
16
|
+
};
|
|
17
|
+
declare const servePagesRouter: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
18
|
+
handler: NextApiHandler;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
export { serve, servePagesRouter };
|
package/nextjs.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CfN1Epuj.js';
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.js';
|
|
4
3
|
import '@upstash/qstash';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -12,7 +11,11 @@ import '@upstash/qstash';
|
|
|
12
11
|
* @param options workflow options
|
|
13
12
|
* @returns
|
|
14
13
|
*/
|
|
15
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<
|
|
16
|
-
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
15
|
+
POST: (request: Request) => Promise<Response>;
|
|
16
|
+
};
|
|
17
|
+
declare const servePagesRouter: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
18
|
+
handler: NextApiHandler;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
export { serve, servePagesRouter };
|
package/nextjs.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(nextjs_exports, {
|
|
|
24
24
|
servePagesRouter: () => servePagesRouter
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(nextjs_exports);
|
|
27
|
-
var import_server = require("next/server");
|
|
28
27
|
|
|
29
28
|
// src/error.ts
|
|
30
29
|
var import_qstash = require("@upstash/qstash");
|
|
@@ -476,6 +475,7 @@ var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
|
|
|
476
475
|
var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
|
|
477
476
|
var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
|
|
478
477
|
var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
|
|
478
|
+
var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
|
|
479
479
|
var WORKFLOW_PROTOCOL_VERSION = "1";
|
|
480
480
|
var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
481
481
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
@@ -561,13 +561,13 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
|
|
|
561
561
|
try {
|
|
562
562
|
if (request.headers.get("Upstash-Workflow-Callback")) {
|
|
563
563
|
const callbackMessage = JSON.parse(requestPayload);
|
|
564
|
-
if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
|
|
564
|
+
if (!(callbackMessage.status >= 200 && callbackMessage.status < 300) && callbackMessage.maxRetries && callbackMessage.retried !== callbackMessage.maxRetries) {
|
|
565
565
|
await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
566
566
|
status: callbackMessage.status,
|
|
567
567
|
body: atob(callbackMessage.body)
|
|
568
568
|
});
|
|
569
569
|
console.warn(
|
|
570
|
-
`Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (
|
|
570
|
+
`Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (retried ${callbackMessage.retried ?? 0} out of ${callbackMessage.maxRetries} times). Error Message:
|
|
571
571
|
${atob(callbackMessage.body)}`
|
|
572
572
|
);
|
|
573
573
|
return ok("call-will-retry");
|
|
@@ -604,7 +604,11 @@ ${atob(callbackMessage.body)}`
|
|
|
604
604
|
stepId: Number(stepIdString),
|
|
605
605
|
stepName,
|
|
606
606
|
stepType,
|
|
607
|
-
out:
|
|
607
|
+
out: {
|
|
608
|
+
status: callbackMessage.status,
|
|
609
|
+
body: atob(callbackMessage.body),
|
|
610
|
+
header: callbackMessage.header
|
|
611
|
+
},
|
|
608
612
|
concurrent: Number(concurrentString)
|
|
609
613
|
};
|
|
610
614
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
@@ -639,15 +643,24 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
639
643
|
[WORKFLOW_INIT_HEADER]: initHeaderValue,
|
|
640
644
|
[WORKFLOW_ID_HEADER]: workflowRunId,
|
|
641
645
|
[WORKFLOW_URL_HEADER]: workflowUrl,
|
|
642
|
-
[
|
|
643
|
-
|
|
644
|
-
[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`]: "true",
|
|
645
|
-
"Upstash-Failure-Callback": failureUrl
|
|
646
|
-
} : {},
|
|
647
|
-
...retries === void 0 ? {} : {
|
|
648
|
-
"Upstash-Retries": retries.toString()
|
|
649
|
-
}
|
|
646
|
+
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
|
|
647
|
+
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
|
|
650
648
|
};
|
|
649
|
+
if (failureUrl) {
|
|
650
|
+
if (!step?.callUrl) {
|
|
651
|
+
baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
|
|
652
|
+
}
|
|
653
|
+
baseHeaders["Upstash-Failure-Callback"] = failureUrl;
|
|
654
|
+
}
|
|
655
|
+
if (step?.callUrl) {
|
|
656
|
+
baseHeaders["Upstash-Retries"] = "0";
|
|
657
|
+
if (retries) {
|
|
658
|
+
baseHeaders["Upstash-Callback-Retries"] = retries.toString();
|
|
659
|
+
baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
|
|
660
|
+
}
|
|
661
|
+
} else if (retries !== void 0) {
|
|
662
|
+
baseHeaders["Upstash-Retries"] = retries.toString();
|
|
663
|
+
}
|
|
651
664
|
if (userHeaders) {
|
|
652
665
|
for (const header of userHeaders.keys()) {
|
|
653
666
|
if (step?.callHeaders) {
|
|
@@ -1506,15 +1519,12 @@ var WorkflowContext = class {
|
|
|
1506
1519
|
* @returns call result (parsed as JSON if possible)
|
|
1507
1520
|
*/
|
|
1508
1521
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
1509
|
-
async call(stepName,
|
|
1522
|
+
async call(stepName, callSettings) {
|
|
1523
|
+
const { url, method = "GET", body, headers = {} } = callSettings;
|
|
1510
1524
|
const result = await this.addStep(
|
|
1511
|
-
new LazyCallStep(stepName, url, method, body, headers
|
|
1525
|
+
new LazyCallStep(stepName, url, method, body, headers)
|
|
1512
1526
|
);
|
|
1513
|
-
|
|
1514
|
-
return JSON.parse(result);
|
|
1515
|
-
} catch {
|
|
1516
|
-
return result;
|
|
1517
|
-
}
|
|
1527
|
+
return result;
|
|
1518
1528
|
}
|
|
1519
1529
|
async waitForEvent(stepName, eventId, timeout) {
|
|
1520
1530
|
const result = await this.addStep(
|
|
@@ -1882,6 +1892,7 @@ var serve = (routeFunction, options) => {
|
|
|
1882
1892
|
} = processOptions(options);
|
|
1883
1893
|
const debug = WorkflowLogger.getLogger(verbose);
|
|
1884
1894
|
const handler = async (request) => {
|
|
1895
|
+
await debug?.log("INFO", "ENDPOINT_START");
|
|
1885
1896
|
const { workflowUrl, workflowFailureUrl } = await determineUrls(
|
|
1886
1897
|
request,
|
|
1887
1898
|
url,
|
|
@@ -1925,7 +1936,8 @@ var serve = (routeFunction, options) => {
|
|
|
1925
1936
|
url: workflowUrl,
|
|
1926
1937
|
failureUrl: workflowFailureUrl,
|
|
1927
1938
|
debug,
|
|
1928
|
-
env
|
|
1939
|
+
env,
|
|
1940
|
+
retries
|
|
1929
1941
|
});
|
|
1930
1942
|
const authCheck = await DisabledWorkflowContext.tryAuthentication(
|
|
1931
1943
|
routeFunction,
|
|
@@ -1968,7 +1980,7 @@ var serve = (routeFunction, options) => {
|
|
|
1968
1980
|
await debug?.log("INFO", "RESPONSE_DEFAULT");
|
|
1969
1981
|
return onStepFinish("no-workflow-id", "fromCallback");
|
|
1970
1982
|
};
|
|
1971
|
-
|
|
1983
|
+
const safeHandler = async (request) => {
|
|
1972
1984
|
try {
|
|
1973
1985
|
return await handler(request);
|
|
1974
1986
|
} catch (error) {
|
|
@@ -1978,6 +1990,7 @@ var serve = (routeFunction, options) => {
|
|
|
1978
1990
|
});
|
|
1979
1991
|
}
|
|
1980
1992
|
};
|
|
1993
|
+
return { handler: safeHandler };
|
|
1981
1994
|
};
|
|
1982
1995
|
|
|
1983
1996
|
// src/client/index.ts
|
|
@@ -1985,17 +1998,19 @@ var import_qstash5 = require("@upstash/qstash");
|
|
|
1985
1998
|
|
|
1986
1999
|
// platforms/nextjs.ts
|
|
1987
2000
|
var serve2 = (routeFunction, options) => {
|
|
1988
|
-
const handler = serve(routeFunction, {
|
|
1989
|
-
onStepFinish: (workflowRunId) => new
|
|
2001
|
+
const { handler: serveHandler } = serve(routeFunction, {
|
|
2002
|
+
onStepFinish: (workflowRunId) => new Response(JSON.stringify({ workflowRunId }), { status: 200 }),
|
|
1990
2003
|
...options
|
|
1991
2004
|
});
|
|
1992
|
-
return
|
|
1993
|
-
|
|
2005
|
+
return {
|
|
2006
|
+
POST: async (request) => {
|
|
2007
|
+
return await serveHandler(request);
|
|
2008
|
+
}
|
|
1994
2009
|
};
|
|
1995
2010
|
};
|
|
1996
2011
|
var servePagesRouter = (routeFunction, options) => {
|
|
1997
|
-
const handler = serve(routeFunction, options);
|
|
1998
|
-
|
|
2012
|
+
const { handler: serveHandler } = serve(routeFunction, options);
|
|
2013
|
+
const handler = async (request_, res) => {
|
|
1999
2014
|
if (request_.method?.toUpperCase() !== "POST") {
|
|
2000
2015
|
res.status(405).json("Only POST requests are allowed in worklfows");
|
|
2001
2016
|
return;
|
|
@@ -2011,9 +2026,10 @@ var servePagesRouter = (routeFunction, options) => {
|
|
|
2011
2026
|
headers: new Headers(request_.headersDistinct),
|
|
2012
2027
|
method: "POST"
|
|
2013
2028
|
});
|
|
2014
|
-
const response = await
|
|
2029
|
+
const response = await serveHandler(request);
|
|
2015
2030
|
res.status(response.status).json(await response.json());
|
|
2016
2031
|
};
|
|
2032
|
+
return { handler };
|
|
2017
2033
|
};
|
|
2018
2034
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2019
2035
|
0 && (module.exports = {
|
package/nextjs.mjs
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
serve
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YW5KUHA2.mjs";
|
|
4
4
|
|
|
5
5
|
// platforms/nextjs.ts
|
|
6
|
-
import { NextResponse } from "next/server";
|
|
7
6
|
var serve2 = (routeFunction, options) => {
|
|
8
|
-
const handler = serve(routeFunction, {
|
|
9
|
-
onStepFinish: (workflowRunId) => new
|
|
7
|
+
const { handler: serveHandler } = serve(routeFunction, {
|
|
8
|
+
onStepFinish: (workflowRunId) => new Response(JSON.stringify({ workflowRunId }), { status: 200 }),
|
|
10
9
|
...options
|
|
11
10
|
});
|
|
12
|
-
return
|
|
13
|
-
|
|
11
|
+
return {
|
|
12
|
+
POST: async (request) => {
|
|
13
|
+
return await serveHandler(request);
|
|
14
|
+
}
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
var servePagesRouter = (routeFunction, options) => {
|
|
17
|
-
const handler = serve(routeFunction, options);
|
|
18
|
-
|
|
18
|
+
const { handler: serveHandler } = serve(routeFunction, options);
|
|
19
|
+
const handler = async (request_, res) => {
|
|
19
20
|
if (request_.method?.toUpperCase() !== "POST") {
|
|
20
21
|
res.status(405).json("Only POST requests are allowed in worklfows");
|
|
21
22
|
return;
|
|
@@ -31,9 +32,10 @@ var servePagesRouter = (routeFunction, options) => {
|
|
|
31
32
|
headers: new Headers(request_.headersDistinct),
|
|
32
33
|
method: "POST"
|
|
33
34
|
});
|
|
34
|
-
const response = await
|
|
35
|
+
const response = await serveHandler(request);
|
|
35
36
|
res.status(response.status).json(await response.json());
|
|
36
37
|
};
|
|
38
|
+
return { handler };
|
|
37
39
|
};
|
|
38
40
|
export {
|
|
39
41
|
serve2 as serve,
|
package/package.json
CHANGED
|
@@ -1,99 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@upstash/workflow",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Durable, Reliable and Performant Serverless Functions",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"module": "./index.mjs",
|
|
7
|
-
"types": "./index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"./*"
|
|
10
|
-
],
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./index.mjs",
|
|
14
|
-
"require": "./index.js"
|
|
15
|
-
},
|
|
16
|
-
"./dist/nextjs": {
|
|
17
|
-
"import": "./nextjs.mjs",
|
|
18
|
-
"require": "./nextjs.js"
|
|
19
|
-
},
|
|
20
|
-
"./nextjs": {
|
|
21
|
-
"import": "./nextjs.mjs",
|
|
22
|
-
"require": "./nextjs.js"
|
|
23
|
-
},
|
|
24
|
-
"./h3": {
|
|
25
|
-
"import": "./h3.mjs",
|
|
26
|
-
"require": "./h3.js"
|
|
27
|
-
},
|
|
28
|
-
"./svelte": {
|
|
29
|
-
"import": "./svelte.mjs",
|
|
30
|
-
"require": "./svelte.js"
|
|
31
|
-
},
|
|
32
|
-
"./solidjs": {
|
|
33
|
-
"import": "./solidjs.mjs",
|
|
34
|
-
"require": "./solidjs.js"
|
|
35
|
-
},
|
|
36
|
-
"./workflow": {
|
|
37
|
-
"import": "./workflow.mjs",
|
|
38
|
-
"require": "./workflow.js"
|
|
39
|
-
},
|
|
40
|
-
"./hono": {
|
|
41
|
-
"import": "./hono.mjs",
|
|
42
|
-
"require": "./hono.js"
|
|
43
|
-
},
|
|
44
|
-
"./cloudflare": {
|
|
45
|
-
"import": "./cloudflare.mjs",
|
|
46
|
-
"require": "./cloudflare.js"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/",
|
|
51
|
-
"test": "bun test src",
|
|
52
|
-
"fmt": "prettier --write .",
|
|
53
|
-
"lint": "tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix",
|
|
54
|
-
"check-exports": "bun run build && cd dist && attw -P",
|
|
55
|
-
"prepare": "husky"
|
|
56
|
-
},
|
|
57
|
-
"repository": {
|
|
58
|
-
"type": "git",
|
|
59
|
-
"url": "git+https://github.com/upstash/workflow-ts.git"
|
|
60
|
-
},
|
|
61
|
-
"keywords": [
|
|
62
|
-
"upstash",
|
|
63
|
-
"qstash",
|
|
64
|
-
"workflow",
|
|
65
|
-
"serverless"
|
|
66
|
-
],
|
|
67
|
-
"author": "Cahid Arda Oz",
|
|
68
|
-
"license": "MIT",
|
|
69
|
-
"bugs": {
|
|
70
|
-
"url": "https://github.com/upstash/workflow-ts/issues"
|
|
71
|
-
},
|
|
72
|
-
"homepage": "https://github.com/upstash/workflow-ts#readme",
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"@commitlint/cli": "^19.5.0",
|
|
75
|
-
"@commitlint/config-conventional": "^19.5.0",
|
|
76
|
-
"@eslint/js": "^9.11.1",
|
|
77
|
-
"@solidjs/start": "^1.0.8",
|
|
78
|
-
"@sveltejs/kit": "^2.6.1",
|
|
79
|
-
"@types/bun": "^1.1.10",
|
|
80
|
-
"eslint": "^9.11.1",
|
|
81
|
-
"eslint-plugin-unicorn": "^55.0.0",
|
|
82
|
-
"globals": "^15.10.0",
|
|
83
|
-
"h3": "^1.12.0",
|
|
84
|
-
"hono": "^4.6.3",
|
|
85
|
-
"husky": "^9.1.6",
|
|
86
|
-
"next": "^14.2.14",
|
|
87
|
-
"prettier": "3.3.3",
|
|
88
|
-
"tsc": "^2.0.4",
|
|
89
|
-
"tsup": "^8.3.0",
|
|
90
|
-
"typescript": "5.4.5",
|
|
91
|
-
"typescript-eslint": "^8.8.0"
|
|
92
|
-
},
|
|
93
|
-
"dependencies": {
|
|
94
|
-
"@upstash/qstash": "^2.7.12"
|
|
95
|
-
},
|
|
96
|
-
"directories": {
|
|
97
|
-
"example": "examples"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
{"name":"@upstash/workflow","version":"v0.1.1-canary","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"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"}},"scripts":{"build":"tsup && 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"},"repository":{"type":"git","url":"git+https://github.com/upstash/workflow-ts.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","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.3","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsc":"^2.0.4","tsup":"^8.3.0","typescript":"5.4.5","typescript-eslint":"^8.8.0"},"dependencies":{"@upstash/qstash":"^2.7.12"},"directories":{"example":"examples"}}
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,6 +11,8 @@ import '@upstash/qstash';
|
|
|
11
11
|
* @param options workflow options
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) =>
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
15
|
+
POST: (event: APIEvent) => Promise<Response>;
|
|
16
|
+
};
|
|
15
17
|
|
|
16
18
|
export { serve };
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,6 +11,8 @@ import '@upstash/qstash';
|
|
|
11
11
|
* @param options workflow options
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) =>
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
|
15
|
+
POST: (event: APIEvent) => Promise<Response>;
|
|
16
|
+
};
|
|
15
17
|
|
|
16
18
|
export { serve };
|