@upstash/workflow 0.1.1 → 0.1.2-omit-errors
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 +4 -4
- package/astro.d.mts +9 -0
- package/astro.d.ts +9 -0
- package/astro.js +2160 -0
- package/astro.mjs +18 -0
- package/{chunk-XPMFG3Q4.mjs → chunk-ZPVH5ACW.mjs} +70 -24
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +76 -30
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +79 -30
- package/h3.mjs +4 -1
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +76 -30
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +77 -31
- package/index.mjs +1 -1
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +76 -30
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +76 -30
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +76 -30
- package/svelte.mjs +1 -1
- package/{types-p7sxktVE.d.mts → types-CI-2skYU.d.mts} +5 -4
- package/{types-p7sxktVE.d.ts → types-CI-2skYU.d.ts} +5 -4
package/index.js
CHANGED
|
@@ -499,6 +499,7 @@ var StepTypes = [
|
|
|
499
499
|
];
|
|
500
500
|
|
|
501
501
|
// src/workflow-requests.ts
|
|
502
|
+
var import_qstash2 = require("@upstash/qstash");
|
|
502
503
|
var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
503
504
|
const { headers } = getHeaders(
|
|
504
505
|
"true",
|
|
@@ -509,27 +510,37 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
509
510
|
workflowContext.failureUrl,
|
|
510
511
|
retries
|
|
511
512
|
);
|
|
512
|
-
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
513
|
-
headers,
|
|
514
|
-
requestPayload: workflowContext.requestPayload,
|
|
515
|
-
url: workflowContext.url
|
|
516
|
-
});
|
|
517
513
|
try {
|
|
518
|
-
await workflowContext.qstashClient.publishJSON({
|
|
514
|
+
const result = await workflowContext.qstashClient.publishJSON({
|
|
519
515
|
headers,
|
|
520
516
|
method: "POST",
|
|
521
517
|
body: workflowContext.requestPayload,
|
|
522
518
|
url: workflowContext.url
|
|
523
519
|
});
|
|
520
|
+
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
521
|
+
headers,
|
|
522
|
+
requestPayload: workflowContext.requestPayload,
|
|
523
|
+
url: workflowContext.url,
|
|
524
|
+
messageId: result.messageId
|
|
525
|
+
});
|
|
524
526
|
return ok("success");
|
|
525
527
|
} catch (error) {
|
|
526
528
|
const error_ = error;
|
|
529
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("a workflow already exists, can not initialize a new one with same id")) {
|
|
530
|
+
await debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
531
|
+
message: `Workflow run ${workflowContext.workflowRunId} already exists.`,
|
|
532
|
+
name: error.name,
|
|
533
|
+
originalMessage: error.message
|
|
534
|
+
});
|
|
535
|
+
return ok("workflow-run-already-exists");
|
|
536
|
+
}
|
|
527
537
|
return err(error_);
|
|
528
538
|
}
|
|
529
539
|
};
|
|
530
540
|
var triggerRouteFunction = async ({
|
|
531
541
|
onCleanup,
|
|
532
|
-
onStep
|
|
542
|
+
onStep,
|
|
543
|
+
debug
|
|
533
544
|
}) => {
|
|
534
545
|
try {
|
|
535
546
|
await onStep();
|
|
@@ -537,6 +548,14 @@ var triggerRouteFunction = async ({
|
|
|
537
548
|
return ok("workflow-finished");
|
|
538
549
|
} catch (error) {
|
|
539
550
|
const error_ = error;
|
|
551
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("can not append to a a cancelled workflow")) {
|
|
552
|
+
await debug?.log("WARN", "RESPONSE_WORKFLOW", {
|
|
553
|
+
message: `tried to append to a cancelled workflow. exiting without publishing.`,
|
|
554
|
+
name: error.name,
|
|
555
|
+
originalMessage: error.message
|
|
556
|
+
});
|
|
557
|
+
return ok("workflow-was-finished");
|
|
558
|
+
}
|
|
540
559
|
return error_ instanceof QStashWorkflowAbort ? ok("step-finished") : err(error_);
|
|
541
560
|
}
|
|
542
561
|
};
|
|
@@ -544,12 +563,29 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
|
|
|
544
563
|
await debug?.log("SUBMIT", "SUBMIT_CLEANUP", {
|
|
545
564
|
deletedWorkflowRunId: workflowContext.workflowRunId
|
|
546
565
|
});
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
566
|
+
try {
|
|
567
|
+
await workflowContext.qstashClient.http.request({
|
|
568
|
+
path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
|
|
569
|
+
method: "DELETE",
|
|
570
|
+
parseResponseAsJson: false
|
|
571
|
+
});
|
|
572
|
+
await debug?.log(
|
|
573
|
+
"SUBMIT",
|
|
574
|
+
"SUBMIT_CLEANUP",
|
|
575
|
+
`workflow run ${workflowContext.workflowRunId} deleted.`
|
|
576
|
+
);
|
|
577
|
+
return { deleted: true };
|
|
578
|
+
} catch (error) {
|
|
579
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes(`workflowRun ${workflowContext.workflowRunId} not found`)) {
|
|
580
|
+
await debug?.log("WARN", "SUBMIT_CLEANUP", {
|
|
581
|
+
message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
|
|
582
|
+
name: error.name,
|
|
583
|
+
originalMessage: error.message
|
|
584
|
+
});
|
|
585
|
+
return { deleted: false };
|
|
586
|
+
}
|
|
587
|
+
throw error;
|
|
588
|
+
}
|
|
553
589
|
};
|
|
554
590
|
var recreateUserHeaders = (headers) => {
|
|
555
591
|
const filteredHeaders = new Headers();
|
|
@@ -605,15 +641,16 @@ ${atob(callbackMessage.body)}`
|
|
|
605
641
|
failureUrl,
|
|
606
642
|
retries
|
|
607
643
|
);
|
|
644
|
+
const callResponse = {
|
|
645
|
+
status: callbackMessage.status,
|
|
646
|
+
body: atob(callbackMessage.body),
|
|
647
|
+
header: callbackMessage.header
|
|
648
|
+
};
|
|
608
649
|
const callResultStep = {
|
|
609
650
|
stepId: Number(stepIdString),
|
|
610
651
|
stepName,
|
|
611
652
|
stepType,
|
|
612
|
-
out:
|
|
613
|
-
status: callbackMessage.status,
|
|
614
|
-
body: atob(callbackMessage.body),
|
|
615
|
-
header: callbackMessage.header
|
|
616
|
-
},
|
|
653
|
+
out: JSON.stringify(callResponse),
|
|
617
654
|
concurrent: Number(concurrentString)
|
|
618
655
|
};
|
|
619
656
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
@@ -647,10 +684,11 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
647
684
|
const baseHeaders = {
|
|
648
685
|
[WORKFLOW_INIT_HEADER]: initHeaderValue,
|
|
649
686
|
[WORKFLOW_ID_HEADER]: workflowRunId,
|
|
650
|
-
[WORKFLOW_URL_HEADER]: workflowUrl
|
|
651
|
-
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
|
|
652
|
-
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
|
|
687
|
+
[WORKFLOW_URL_HEADER]: workflowUrl
|
|
653
688
|
};
|
|
689
|
+
if (!step?.callUrl) {
|
|
690
|
+
baseHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
|
|
691
|
+
}
|
|
654
692
|
if (failureUrl) {
|
|
655
693
|
if (!step?.callUrl) {
|
|
656
694
|
baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
|
|
@@ -659,6 +697,7 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
659
697
|
}
|
|
660
698
|
if (step?.callUrl) {
|
|
661
699
|
baseHeaders["Upstash-Retries"] = "0";
|
|
700
|
+
baseHeaders[WORKFLOW_FEATURE_HEADER] = "WF_NoDelete";
|
|
662
701
|
if (retries) {
|
|
663
702
|
baseHeaders["Upstash-Callback-Retries"] = retries.toString();
|
|
664
703
|
baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
|
|
@@ -1022,6 +1061,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
1022
1061
|
this.context.retries
|
|
1023
1062
|
);
|
|
1024
1063
|
const willWait = singleStep.concurrent === NO_CONCURRENCY || singleStep.stepId === 0;
|
|
1064
|
+
singleStep.out = JSON.stringify(singleStep.out);
|
|
1025
1065
|
return singleStep.callUrl ? (
|
|
1026
1066
|
// if the step is a third party call, we call the third party
|
|
1027
1067
|
// url (singleStep.callUrl) and pass information about the workflow
|
|
@@ -1690,7 +1730,8 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
1690
1730
|
}
|
|
1691
1731
|
writeToConsole(logEntry) {
|
|
1692
1732
|
const JSON_SPACING = 2;
|
|
1693
|
-
console.
|
|
1733
|
+
const logMethod = logEntry.logLevel === "ERROR" ? console.error : logEntry.logLevel === "WARN" ? console.warn : console.log;
|
|
1734
|
+
logMethod(JSON.stringify(logEntry, void 0, JSON_SPACING));
|
|
1694
1735
|
}
|
|
1695
1736
|
shouldLog(level) {
|
|
1696
1737
|
return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.options.logLevel);
|
|
@@ -1747,9 +1788,13 @@ var parsePayload = (rawPayload) => {
|
|
|
1747
1788
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
1748
1789
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
1749
1790
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
1791
|
+
try {
|
|
1792
|
+
step.out = JSON.parse(step.out);
|
|
1793
|
+
} catch {
|
|
1794
|
+
}
|
|
1750
1795
|
if (step.waitEventId) {
|
|
1751
1796
|
const newOut = {
|
|
1752
|
-
eventData: step.out,
|
|
1797
|
+
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
1753
1798
|
timeout: step.waitTimeout ?? false
|
|
1754
1799
|
};
|
|
1755
1800
|
step.out = newOut;
|
|
@@ -1879,7 +1924,7 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
1879
1924
|
};
|
|
1880
1925
|
|
|
1881
1926
|
// src/serve/authorization.ts
|
|
1882
|
-
var
|
|
1927
|
+
var import_qstash3 = require("@upstash/qstash");
|
|
1883
1928
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
1884
1929
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
1885
1930
|
/**
|
|
@@ -1904,7 +1949,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1904
1949
|
*/
|
|
1905
1950
|
static async tryAuthentication(routeFunction, context) {
|
|
1906
1951
|
const disabledContext = new _DisabledWorkflowContext({
|
|
1907
|
-
qstashClient: new
|
|
1952
|
+
qstashClient: new import_qstash3.Client({
|
|
1908
1953
|
baseUrl: "disabled-client",
|
|
1909
1954
|
token: "disabled-client"
|
|
1910
1955
|
}),
|
|
@@ -1931,15 +1976,15 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1931
1976
|
};
|
|
1932
1977
|
|
|
1933
1978
|
// src/serve/options.ts
|
|
1934
|
-
var import_qstash3 = require("@upstash/qstash");
|
|
1935
1979
|
var import_qstash4 = require("@upstash/qstash");
|
|
1980
|
+
var import_qstash5 = require("@upstash/qstash");
|
|
1936
1981
|
var processOptions = (options) => {
|
|
1937
1982
|
const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
|
|
1938
1983
|
const receiverEnvironmentVariablesSet = Boolean(
|
|
1939
1984
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
1940
1985
|
);
|
|
1941
1986
|
return {
|
|
1942
|
-
qstashClient: new
|
|
1987
|
+
qstashClient: new import_qstash5.Client({
|
|
1943
1988
|
baseUrl: environment.QSTASH_URL,
|
|
1944
1989
|
token: environment.QSTASH_TOKEN
|
|
1945
1990
|
}),
|
|
@@ -1960,7 +2005,7 @@ var processOptions = (options) => {
|
|
|
1960
2005
|
throw error;
|
|
1961
2006
|
}
|
|
1962
2007
|
},
|
|
1963
|
-
receiver: receiverEnvironmentVariablesSet ? new
|
|
2008
|
+
receiver: receiverEnvironmentVariablesSet ? new import_qstash4.Receiver({
|
|
1964
2009
|
currentSigningKey: environment.QSTASH_CURRENT_SIGNING_KEY,
|
|
1965
2010
|
nextSigningKey: environment.QSTASH_NEXT_SIGNING_KEY
|
|
1966
2011
|
}) : void 0,
|
|
@@ -2082,7 +2127,8 @@ var serve = (routeFunction, options) => {
|
|
|
2082
2127
|
onStep: async () => routeFunction(workflowContext),
|
|
2083
2128
|
onCleanup: async () => {
|
|
2084
2129
|
await triggerWorkflowDelete(workflowContext, debug);
|
|
2085
|
-
}
|
|
2130
|
+
},
|
|
2131
|
+
debug
|
|
2086
2132
|
});
|
|
2087
2133
|
if (result.isErr()) {
|
|
2088
2134
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
@@ -2108,14 +2154,14 @@ var serve = (routeFunction, options) => {
|
|
|
2108
2154
|
};
|
|
2109
2155
|
|
|
2110
2156
|
// src/client/index.ts
|
|
2111
|
-
var
|
|
2157
|
+
var import_qstash6 = require("@upstash/qstash");
|
|
2112
2158
|
var Client3 = class {
|
|
2113
2159
|
client;
|
|
2114
2160
|
constructor(clientConfig) {
|
|
2115
2161
|
if (!clientConfig.token) {
|
|
2116
2162
|
console.warn("[Upstash Workflow] url or the token is not set. client will not work.");
|
|
2117
2163
|
}
|
|
2118
|
-
this.client = new
|
|
2164
|
+
this.client = new import_qstash6.Client(clientConfig);
|
|
2119
2165
|
}
|
|
2120
2166
|
/**
|
|
2121
2167
|
* Cancel an ongoing workflow
|
package/index.mjs
CHANGED
package/nextjs.d.mts
CHANGED
package/nextjs.d.ts
CHANGED
package/nextjs.js
CHANGED
|
@@ -494,6 +494,7 @@ var StepTypes = [
|
|
|
494
494
|
];
|
|
495
495
|
|
|
496
496
|
// src/workflow-requests.ts
|
|
497
|
+
var import_qstash2 = require("@upstash/qstash");
|
|
497
498
|
var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
498
499
|
const { headers } = getHeaders(
|
|
499
500
|
"true",
|
|
@@ -504,27 +505,37 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
504
505
|
workflowContext.failureUrl,
|
|
505
506
|
retries
|
|
506
507
|
);
|
|
507
|
-
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
508
|
-
headers,
|
|
509
|
-
requestPayload: workflowContext.requestPayload,
|
|
510
|
-
url: workflowContext.url
|
|
511
|
-
});
|
|
512
508
|
try {
|
|
513
|
-
await workflowContext.qstashClient.publishJSON({
|
|
509
|
+
const result = await workflowContext.qstashClient.publishJSON({
|
|
514
510
|
headers,
|
|
515
511
|
method: "POST",
|
|
516
512
|
body: workflowContext.requestPayload,
|
|
517
513
|
url: workflowContext.url
|
|
518
514
|
});
|
|
515
|
+
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
516
|
+
headers,
|
|
517
|
+
requestPayload: workflowContext.requestPayload,
|
|
518
|
+
url: workflowContext.url,
|
|
519
|
+
messageId: result.messageId
|
|
520
|
+
});
|
|
519
521
|
return ok("success");
|
|
520
522
|
} catch (error) {
|
|
521
523
|
const error_ = error;
|
|
524
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("a workflow already exists, can not initialize a new one with same id")) {
|
|
525
|
+
await debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
526
|
+
message: `Workflow run ${workflowContext.workflowRunId} already exists.`,
|
|
527
|
+
name: error.name,
|
|
528
|
+
originalMessage: error.message
|
|
529
|
+
});
|
|
530
|
+
return ok("workflow-run-already-exists");
|
|
531
|
+
}
|
|
522
532
|
return err(error_);
|
|
523
533
|
}
|
|
524
534
|
};
|
|
525
535
|
var triggerRouteFunction = async ({
|
|
526
536
|
onCleanup,
|
|
527
|
-
onStep
|
|
537
|
+
onStep,
|
|
538
|
+
debug
|
|
528
539
|
}) => {
|
|
529
540
|
try {
|
|
530
541
|
await onStep();
|
|
@@ -532,6 +543,14 @@ var triggerRouteFunction = async ({
|
|
|
532
543
|
return ok("workflow-finished");
|
|
533
544
|
} catch (error) {
|
|
534
545
|
const error_ = error;
|
|
546
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("can not append to a a cancelled workflow")) {
|
|
547
|
+
await debug?.log("WARN", "RESPONSE_WORKFLOW", {
|
|
548
|
+
message: `tried to append to a cancelled workflow. exiting without publishing.`,
|
|
549
|
+
name: error.name,
|
|
550
|
+
originalMessage: error.message
|
|
551
|
+
});
|
|
552
|
+
return ok("workflow-was-finished");
|
|
553
|
+
}
|
|
535
554
|
return error_ instanceof QStashWorkflowAbort ? ok("step-finished") : err(error_);
|
|
536
555
|
}
|
|
537
556
|
};
|
|
@@ -539,12 +558,29 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
|
|
|
539
558
|
await debug?.log("SUBMIT", "SUBMIT_CLEANUP", {
|
|
540
559
|
deletedWorkflowRunId: workflowContext.workflowRunId
|
|
541
560
|
});
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
561
|
+
try {
|
|
562
|
+
await workflowContext.qstashClient.http.request({
|
|
563
|
+
path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
|
|
564
|
+
method: "DELETE",
|
|
565
|
+
parseResponseAsJson: false
|
|
566
|
+
});
|
|
567
|
+
await debug?.log(
|
|
568
|
+
"SUBMIT",
|
|
569
|
+
"SUBMIT_CLEANUP",
|
|
570
|
+
`workflow run ${workflowContext.workflowRunId} deleted.`
|
|
571
|
+
);
|
|
572
|
+
return { deleted: true };
|
|
573
|
+
} catch (error) {
|
|
574
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes(`workflowRun ${workflowContext.workflowRunId} not found`)) {
|
|
575
|
+
await debug?.log("WARN", "SUBMIT_CLEANUP", {
|
|
576
|
+
message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
|
|
577
|
+
name: error.name,
|
|
578
|
+
originalMessage: error.message
|
|
579
|
+
});
|
|
580
|
+
return { deleted: false };
|
|
581
|
+
}
|
|
582
|
+
throw error;
|
|
583
|
+
}
|
|
548
584
|
};
|
|
549
585
|
var recreateUserHeaders = (headers) => {
|
|
550
586
|
const filteredHeaders = new Headers();
|
|
@@ -600,15 +636,16 @@ ${atob(callbackMessage.body)}`
|
|
|
600
636
|
failureUrl,
|
|
601
637
|
retries
|
|
602
638
|
);
|
|
639
|
+
const callResponse = {
|
|
640
|
+
status: callbackMessage.status,
|
|
641
|
+
body: atob(callbackMessage.body),
|
|
642
|
+
header: callbackMessage.header
|
|
643
|
+
};
|
|
603
644
|
const callResultStep = {
|
|
604
645
|
stepId: Number(stepIdString),
|
|
605
646
|
stepName,
|
|
606
647
|
stepType,
|
|
607
|
-
out:
|
|
608
|
-
status: callbackMessage.status,
|
|
609
|
-
body: atob(callbackMessage.body),
|
|
610
|
-
header: callbackMessage.header
|
|
611
|
-
},
|
|
648
|
+
out: JSON.stringify(callResponse),
|
|
612
649
|
concurrent: Number(concurrentString)
|
|
613
650
|
};
|
|
614
651
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
@@ -642,10 +679,11 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
642
679
|
const baseHeaders = {
|
|
643
680
|
[WORKFLOW_INIT_HEADER]: initHeaderValue,
|
|
644
681
|
[WORKFLOW_ID_HEADER]: workflowRunId,
|
|
645
|
-
[WORKFLOW_URL_HEADER]: workflowUrl
|
|
646
|
-
[WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
|
|
647
|
-
[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
|
|
682
|
+
[WORKFLOW_URL_HEADER]: workflowUrl
|
|
648
683
|
};
|
|
684
|
+
if (!step?.callUrl) {
|
|
685
|
+
baseHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
|
|
686
|
+
}
|
|
649
687
|
if (failureUrl) {
|
|
650
688
|
if (!step?.callUrl) {
|
|
651
689
|
baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
|
|
@@ -654,6 +692,7 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
654
692
|
}
|
|
655
693
|
if (step?.callUrl) {
|
|
656
694
|
baseHeaders["Upstash-Retries"] = "0";
|
|
695
|
+
baseHeaders[WORKFLOW_FEATURE_HEADER] = "WF_NoDelete";
|
|
657
696
|
if (retries) {
|
|
658
697
|
baseHeaders["Upstash-Callback-Retries"] = retries.toString();
|
|
659
698
|
baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
|
|
@@ -1017,6 +1056,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
1017
1056
|
this.context.retries
|
|
1018
1057
|
);
|
|
1019
1058
|
const willWait = singleStep.concurrent === NO_CONCURRENCY || singleStep.stepId === 0;
|
|
1059
|
+
singleStep.out = JSON.stringify(singleStep.out);
|
|
1020
1060
|
return singleStep.callUrl ? (
|
|
1021
1061
|
// if the step is a third party call, we call the third party
|
|
1022
1062
|
// url (singleStep.callUrl) and pass information about the workflow
|
|
@@ -1678,7 +1718,8 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
1678
1718
|
}
|
|
1679
1719
|
writeToConsole(logEntry) {
|
|
1680
1720
|
const JSON_SPACING = 2;
|
|
1681
|
-
console.
|
|
1721
|
+
const logMethod = logEntry.logLevel === "ERROR" ? console.error : logEntry.logLevel === "WARN" ? console.warn : console.log;
|
|
1722
|
+
logMethod(JSON.stringify(logEntry, void 0, JSON_SPACING));
|
|
1682
1723
|
}
|
|
1683
1724
|
shouldLog(level) {
|
|
1684
1725
|
return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.options.logLevel);
|
|
@@ -1735,9 +1776,13 @@ var parsePayload = (rawPayload) => {
|
|
|
1735
1776
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
1736
1777
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
1737
1778
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
1779
|
+
try {
|
|
1780
|
+
step.out = JSON.parse(step.out);
|
|
1781
|
+
} catch {
|
|
1782
|
+
}
|
|
1738
1783
|
if (step.waitEventId) {
|
|
1739
1784
|
const newOut = {
|
|
1740
|
-
eventData: step.out,
|
|
1785
|
+
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
1741
1786
|
timeout: step.waitTimeout ?? false
|
|
1742
1787
|
};
|
|
1743
1788
|
step.out = newOut;
|
|
@@ -1867,7 +1912,7 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
1867
1912
|
};
|
|
1868
1913
|
|
|
1869
1914
|
// src/serve/authorization.ts
|
|
1870
|
-
var
|
|
1915
|
+
var import_qstash3 = require("@upstash/qstash");
|
|
1871
1916
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
1872
1917
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
1873
1918
|
/**
|
|
@@ -1892,7 +1937,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1892
1937
|
*/
|
|
1893
1938
|
static async tryAuthentication(routeFunction, context) {
|
|
1894
1939
|
const disabledContext = new _DisabledWorkflowContext({
|
|
1895
|
-
qstashClient: new
|
|
1940
|
+
qstashClient: new import_qstash3.Client({
|
|
1896
1941
|
baseUrl: "disabled-client",
|
|
1897
1942
|
token: "disabled-client"
|
|
1898
1943
|
}),
|
|
@@ -1919,15 +1964,15 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1919
1964
|
};
|
|
1920
1965
|
|
|
1921
1966
|
// src/serve/options.ts
|
|
1922
|
-
var import_qstash3 = require("@upstash/qstash");
|
|
1923
1967
|
var import_qstash4 = require("@upstash/qstash");
|
|
1968
|
+
var import_qstash5 = require("@upstash/qstash");
|
|
1924
1969
|
var processOptions = (options) => {
|
|
1925
1970
|
const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
|
|
1926
1971
|
const receiverEnvironmentVariablesSet = Boolean(
|
|
1927
1972
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
1928
1973
|
);
|
|
1929
1974
|
return {
|
|
1930
|
-
qstashClient: new
|
|
1975
|
+
qstashClient: new import_qstash5.Client({
|
|
1931
1976
|
baseUrl: environment.QSTASH_URL,
|
|
1932
1977
|
token: environment.QSTASH_TOKEN
|
|
1933
1978
|
}),
|
|
@@ -1948,7 +1993,7 @@ var processOptions = (options) => {
|
|
|
1948
1993
|
throw error;
|
|
1949
1994
|
}
|
|
1950
1995
|
},
|
|
1951
|
-
receiver: receiverEnvironmentVariablesSet ? new
|
|
1996
|
+
receiver: receiverEnvironmentVariablesSet ? new import_qstash4.Receiver({
|
|
1952
1997
|
currentSigningKey: environment.QSTASH_CURRENT_SIGNING_KEY,
|
|
1953
1998
|
nextSigningKey: environment.QSTASH_NEXT_SIGNING_KEY
|
|
1954
1999
|
}) : void 0,
|
|
@@ -2070,7 +2115,8 @@ var serve = (routeFunction, options) => {
|
|
|
2070
2115
|
onStep: async () => routeFunction(workflowContext),
|
|
2071
2116
|
onCleanup: async () => {
|
|
2072
2117
|
await triggerWorkflowDelete(workflowContext, debug);
|
|
2073
|
-
}
|
|
2118
|
+
},
|
|
2119
|
+
debug
|
|
2074
2120
|
});
|
|
2075
2121
|
if (result.isErr()) {
|
|
2076
2122
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
@@ -2096,7 +2142,7 @@ var serve = (routeFunction, options) => {
|
|
|
2096
2142
|
};
|
|
2097
2143
|
|
|
2098
2144
|
// src/client/index.ts
|
|
2099
|
-
var
|
|
2145
|
+
var import_qstash6 = require("@upstash/qstash");
|
|
2100
2146
|
|
|
2101
2147
|
// platforms/nextjs.ts
|
|
2102
2148
|
var serve2 = (routeFunction, options) => {
|
package/nextjs.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/workflow","version":"v0.1.
|
|
1
|
+
{"name":"@upstash/workflow","version":"v0.1.2-omit-errors","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"},"./astro":{"import":"./astro.mjs","require":"./astro.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","astro":"^4.16.7","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
package/solidjs.d.ts
CHANGED