@upstash/workflow 0.1.2-canary-astro → 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/astro.d.mts +1 -1
- package/astro.d.ts +1 -1
- package/astro.js +76 -44
- package/astro.mjs +1 -1
- package/{chunk-EKVRVBHL.mjs → chunk-ZPVH5ACW.mjs} +70 -38
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +76 -44
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +76 -44
- package/h3.mjs +1 -1
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +76 -44
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +77 -45
- package/index.mjs +1 -1
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +76 -44
- 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 -44
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +76 -44
- 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/hono.js
CHANGED
|
@@ -493,6 +493,7 @@ var StepTypes = [
|
|
|
493
493
|
];
|
|
494
494
|
|
|
495
495
|
// src/workflow-requests.ts
|
|
496
|
+
var import_qstash2 = require("@upstash/qstash");
|
|
496
497
|
var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
497
498
|
const { headers } = getHeaders(
|
|
498
499
|
"true",
|
|
@@ -503,27 +504,37 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
503
504
|
workflowContext.failureUrl,
|
|
504
505
|
retries
|
|
505
506
|
);
|
|
506
|
-
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
507
|
-
headers,
|
|
508
|
-
requestPayload: workflowContext.requestPayload,
|
|
509
|
-
url: workflowContext.url
|
|
510
|
-
});
|
|
511
507
|
try {
|
|
512
|
-
await workflowContext.qstashClient.publishJSON({
|
|
508
|
+
const result = await workflowContext.qstashClient.publishJSON({
|
|
513
509
|
headers,
|
|
514
510
|
method: "POST",
|
|
515
511
|
body: workflowContext.requestPayload,
|
|
516
512
|
url: workflowContext.url
|
|
517
513
|
});
|
|
514
|
+
await debug?.log("SUBMIT", "SUBMIT_FIRST_INVOCATION", {
|
|
515
|
+
headers,
|
|
516
|
+
requestPayload: workflowContext.requestPayload,
|
|
517
|
+
url: workflowContext.url,
|
|
518
|
+
messageId: result.messageId
|
|
519
|
+
});
|
|
518
520
|
return ok("success");
|
|
519
521
|
} catch (error) {
|
|
520
522
|
const error_ = error;
|
|
523
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("a workflow already exists, can not initialize a new one with same id")) {
|
|
524
|
+
await debug?.log("WARN", "SUBMIT_FIRST_INVOCATION", {
|
|
525
|
+
message: `Workflow run ${workflowContext.workflowRunId} already exists.`,
|
|
526
|
+
name: error.name,
|
|
527
|
+
originalMessage: error.message
|
|
528
|
+
});
|
|
529
|
+
return ok("workflow-run-already-exists");
|
|
530
|
+
}
|
|
521
531
|
return err(error_);
|
|
522
532
|
}
|
|
523
533
|
};
|
|
524
534
|
var triggerRouteFunction = async ({
|
|
525
535
|
onCleanup,
|
|
526
|
-
onStep
|
|
536
|
+
onStep,
|
|
537
|
+
debug
|
|
527
538
|
}) => {
|
|
528
539
|
try {
|
|
529
540
|
await onStep();
|
|
@@ -531,6 +542,14 @@ var triggerRouteFunction = async ({
|
|
|
531
542
|
return ok("workflow-finished");
|
|
532
543
|
} catch (error) {
|
|
533
544
|
const error_ = error;
|
|
545
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes("can not append to a a cancelled workflow")) {
|
|
546
|
+
await debug?.log("WARN", "RESPONSE_WORKFLOW", {
|
|
547
|
+
message: `tried to append to a cancelled workflow. exiting without publishing.`,
|
|
548
|
+
name: error.name,
|
|
549
|
+
originalMessage: error.message
|
|
550
|
+
});
|
|
551
|
+
return ok("workflow-was-finished");
|
|
552
|
+
}
|
|
534
553
|
return error_ instanceof QStashWorkflowAbort ? ok("step-finished") : err(error_);
|
|
535
554
|
}
|
|
536
555
|
};
|
|
@@ -538,12 +557,29 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
|
|
|
538
557
|
await debug?.log("SUBMIT", "SUBMIT_CLEANUP", {
|
|
539
558
|
deletedWorkflowRunId: workflowContext.workflowRunId
|
|
540
559
|
});
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
560
|
+
try {
|
|
561
|
+
await workflowContext.qstashClient.http.request({
|
|
562
|
+
path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
|
|
563
|
+
method: "DELETE",
|
|
564
|
+
parseResponseAsJson: false
|
|
565
|
+
});
|
|
566
|
+
await debug?.log(
|
|
567
|
+
"SUBMIT",
|
|
568
|
+
"SUBMIT_CLEANUP",
|
|
569
|
+
`workflow run ${workflowContext.workflowRunId} deleted.`
|
|
570
|
+
);
|
|
571
|
+
return { deleted: true };
|
|
572
|
+
} catch (error) {
|
|
573
|
+
if (error instanceof import_qstash2.QstashError && error.message.includes(`workflowRun ${workflowContext.workflowRunId} not found`)) {
|
|
574
|
+
await debug?.log("WARN", "SUBMIT_CLEANUP", {
|
|
575
|
+
message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
|
|
576
|
+
name: error.name,
|
|
577
|
+
originalMessage: error.message
|
|
578
|
+
});
|
|
579
|
+
return { deleted: false };
|
|
580
|
+
}
|
|
581
|
+
throw error;
|
|
582
|
+
}
|
|
547
583
|
};
|
|
548
584
|
var recreateUserHeaders = (headers) => {
|
|
549
585
|
const filteredHeaders = new Headers();
|
|
@@ -1681,7 +1717,8 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
1681
1717
|
}
|
|
1682
1718
|
writeToConsole(logEntry) {
|
|
1683
1719
|
const JSON_SPACING = 2;
|
|
1684
|
-
console.
|
|
1720
|
+
const logMethod = logEntry.logLevel === "ERROR" ? console.error : logEntry.logLevel === "WARN" ? console.warn : console.log;
|
|
1721
|
+
logMethod(JSON.stringify(logEntry, void 0, JSON_SPACING));
|
|
1685
1722
|
}
|
|
1686
1723
|
shouldLog(level) {
|
|
1687
1724
|
return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.options.logLevel);
|
|
@@ -1725,7 +1762,7 @@ var getPayload = async (request) => {
|
|
|
1725
1762
|
return;
|
|
1726
1763
|
}
|
|
1727
1764
|
};
|
|
1728
|
-
var parsePayload =
|
|
1765
|
+
var parsePayload = (rawPayload) => {
|
|
1729
1766
|
const [encodedInitialPayload, ...encodedSteps] = JSON.parse(rawPayload);
|
|
1730
1767
|
const rawInitialPayload = decodeBase64(encodedInitialPayload.body);
|
|
1731
1768
|
const initialStep = {
|
|
@@ -1736,27 +1773,21 @@ var parsePayload = async (rawPayload, debug) => {
|
|
|
1736
1773
|
concurrent: NO_CONCURRENCY
|
|
1737
1774
|
};
|
|
1738
1775
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
1739
|
-
const otherSteps =
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
};
|
|
1755
|
-
step.out = newOut;
|
|
1756
|
-
}
|
|
1757
|
-
return step;
|
|
1758
|
-
})
|
|
1759
|
-
);
|
|
1776
|
+
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
1777
|
+
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
1778
|
+
try {
|
|
1779
|
+
step.out = JSON.parse(step.out);
|
|
1780
|
+
} catch {
|
|
1781
|
+
}
|
|
1782
|
+
if (step.waitEventId) {
|
|
1783
|
+
const newOut = {
|
|
1784
|
+
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
1785
|
+
timeout: step.waitTimeout ?? false
|
|
1786
|
+
};
|
|
1787
|
+
step.out = newOut;
|
|
1788
|
+
}
|
|
1789
|
+
return step;
|
|
1790
|
+
});
|
|
1760
1791
|
const steps = [initialStep, ...otherSteps];
|
|
1761
1792
|
return {
|
|
1762
1793
|
rawInitialPayload,
|
|
@@ -1828,7 +1859,7 @@ var parseRequest = async (requestPayload, isFirstInvocation, debug) => {
|
|
|
1828
1859
|
if (!requestPayload) {
|
|
1829
1860
|
throw new QStashWorkflowError("Only first call can have an empty body");
|
|
1830
1861
|
}
|
|
1831
|
-
const { rawInitialPayload, steps } =
|
|
1862
|
+
const { rawInitialPayload, steps } = parsePayload(requestPayload);
|
|
1832
1863
|
const isLastDuplicate = await checkIfLastOneIsDuplicate(steps, debug);
|
|
1833
1864
|
const deduplicatedSteps = deduplicateSteps(steps);
|
|
1834
1865
|
return {
|
|
@@ -1880,7 +1911,7 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
1880
1911
|
};
|
|
1881
1912
|
|
|
1882
1913
|
// src/serve/authorization.ts
|
|
1883
|
-
var
|
|
1914
|
+
var import_qstash3 = require("@upstash/qstash");
|
|
1884
1915
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
1885
1916
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
1886
1917
|
/**
|
|
@@ -1905,7 +1936,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1905
1936
|
*/
|
|
1906
1937
|
static async tryAuthentication(routeFunction, context) {
|
|
1907
1938
|
const disabledContext = new _DisabledWorkflowContext({
|
|
1908
|
-
qstashClient: new
|
|
1939
|
+
qstashClient: new import_qstash3.Client({
|
|
1909
1940
|
baseUrl: "disabled-client",
|
|
1910
1941
|
token: "disabled-client"
|
|
1911
1942
|
}),
|
|
@@ -1932,15 +1963,15 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1932
1963
|
};
|
|
1933
1964
|
|
|
1934
1965
|
// src/serve/options.ts
|
|
1935
|
-
var import_qstash3 = require("@upstash/qstash");
|
|
1936
1966
|
var import_qstash4 = require("@upstash/qstash");
|
|
1967
|
+
var import_qstash5 = require("@upstash/qstash");
|
|
1937
1968
|
var processOptions = (options) => {
|
|
1938
1969
|
const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
|
|
1939
1970
|
const receiverEnvironmentVariablesSet = Boolean(
|
|
1940
1971
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
1941
1972
|
);
|
|
1942
1973
|
return {
|
|
1943
|
-
qstashClient: new
|
|
1974
|
+
qstashClient: new import_qstash5.Client({
|
|
1944
1975
|
baseUrl: environment.QSTASH_URL,
|
|
1945
1976
|
token: environment.QSTASH_TOKEN
|
|
1946
1977
|
}),
|
|
@@ -1961,7 +1992,7 @@ var processOptions = (options) => {
|
|
|
1961
1992
|
throw error;
|
|
1962
1993
|
}
|
|
1963
1994
|
},
|
|
1964
|
-
receiver: receiverEnvironmentVariablesSet ? new
|
|
1995
|
+
receiver: receiverEnvironmentVariablesSet ? new import_qstash4.Receiver({
|
|
1965
1996
|
currentSigningKey: environment.QSTASH_CURRENT_SIGNING_KEY,
|
|
1966
1997
|
nextSigningKey: environment.QSTASH_NEXT_SIGNING_KEY
|
|
1967
1998
|
}) : void 0,
|
|
@@ -2083,7 +2114,8 @@ var serve = (routeFunction, options) => {
|
|
|
2083
2114
|
onStep: async () => routeFunction(workflowContext),
|
|
2084
2115
|
onCleanup: async () => {
|
|
2085
2116
|
await triggerWorkflowDelete(workflowContext, debug);
|
|
2086
|
-
}
|
|
2117
|
+
},
|
|
2118
|
+
debug
|
|
2087
2119
|
});
|
|
2088
2120
|
if (result.isErr()) {
|
|
2089
2121
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
@@ -2109,7 +2141,7 @@ var serve = (routeFunction, options) => {
|
|
|
2109
2141
|
};
|
|
2110
2142
|
|
|
2111
2143
|
// src/client/index.ts
|
|
2112
|
-
var
|
|
2144
|
+
var import_qstash6 = require("@upstash/qstash");
|
|
2113
2145
|
|
|
2114
2146
|
// platforms/hono.ts
|
|
2115
2147
|
var serve2 = (routeFunction, options) => {
|
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CI-2skYU.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, D as Duration, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CI-2skYU.mjs';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CI-2skYU.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, D as Duration, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CI-2skYU.js';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
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();
|
|
@@ -1694,7 +1730,8 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
1694
1730
|
}
|
|
1695
1731
|
writeToConsole(logEntry) {
|
|
1696
1732
|
const JSON_SPACING = 2;
|
|
1697
|
-
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));
|
|
1698
1735
|
}
|
|
1699
1736
|
shouldLog(level) {
|
|
1700
1737
|
return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(this.options.logLevel);
|
|
@@ -1738,7 +1775,7 @@ var getPayload = async (request) => {
|
|
|
1738
1775
|
return;
|
|
1739
1776
|
}
|
|
1740
1777
|
};
|
|
1741
|
-
var parsePayload =
|
|
1778
|
+
var parsePayload = (rawPayload) => {
|
|
1742
1779
|
const [encodedInitialPayload, ...encodedSteps] = JSON.parse(rawPayload);
|
|
1743
1780
|
const rawInitialPayload = decodeBase64(encodedInitialPayload.body);
|
|
1744
1781
|
const initialStep = {
|
|
@@ -1749,27 +1786,21 @@ var parsePayload = async (rawPayload, debug) => {
|
|
|
1749
1786
|
concurrent: NO_CONCURRENCY
|
|
1750
1787
|
};
|
|
1751
1788
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
1752
|
-
const otherSteps =
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
};
|
|
1768
|
-
step.out = newOut;
|
|
1769
|
-
}
|
|
1770
|
-
return step;
|
|
1771
|
-
})
|
|
1772
|
-
);
|
|
1789
|
+
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
1790
|
+
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
1791
|
+
try {
|
|
1792
|
+
step.out = JSON.parse(step.out);
|
|
1793
|
+
} catch {
|
|
1794
|
+
}
|
|
1795
|
+
if (step.waitEventId) {
|
|
1796
|
+
const newOut = {
|
|
1797
|
+
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
1798
|
+
timeout: step.waitTimeout ?? false
|
|
1799
|
+
};
|
|
1800
|
+
step.out = newOut;
|
|
1801
|
+
}
|
|
1802
|
+
return step;
|
|
1803
|
+
});
|
|
1773
1804
|
const steps = [initialStep, ...otherSteps];
|
|
1774
1805
|
return {
|
|
1775
1806
|
rawInitialPayload,
|
|
@@ -1841,7 +1872,7 @@ var parseRequest = async (requestPayload, isFirstInvocation, debug) => {
|
|
|
1841
1872
|
if (!requestPayload) {
|
|
1842
1873
|
throw new QStashWorkflowError("Only first call can have an empty body");
|
|
1843
1874
|
}
|
|
1844
|
-
const { rawInitialPayload, steps } =
|
|
1875
|
+
const { rawInitialPayload, steps } = parsePayload(requestPayload);
|
|
1845
1876
|
const isLastDuplicate = await checkIfLastOneIsDuplicate(steps, debug);
|
|
1846
1877
|
const deduplicatedSteps = deduplicateSteps(steps);
|
|
1847
1878
|
return {
|
|
@@ -1893,7 +1924,7 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
1893
1924
|
};
|
|
1894
1925
|
|
|
1895
1926
|
// src/serve/authorization.ts
|
|
1896
|
-
var
|
|
1927
|
+
var import_qstash3 = require("@upstash/qstash");
|
|
1897
1928
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
1898
1929
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
1899
1930
|
/**
|
|
@@ -1918,7 +1949,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1918
1949
|
*/
|
|
1919
1950
|
static async tryAuthentication(routeFunction, context) {
|
|
1920
1951
|
const disabledContext = new _DisabledWorkflowContext({
|
|
1921
|
-
qstashClient: new
|
|
1952
|
+
qstashClient: new import_qstash3.Client({
|
|
1922
1953
|
baseUrl: "disabled-client",
|
|
1923
1954
|
token: "disabled-client"
|
|
1924
1955
|
}),
|
|
@@ -1945,15 +1976,15 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1945
1976
|
};
|
|
1946
1977
|
|
|
1947
1978
|
// src/serve/options.ts
|
|
1948
|
-
var import_qstash3 = require("@upstash/qstash");
|
|
1949
1979
|
var import_qstash4 = require("@upstash/qstash");
|
|
1980
|
+
var import_qstash5 = require("@upstash/qstash");
|
|
1950
1981
|
var processOptions = (options) => {
|
|
1951
1982
|
const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
|
|
1952
1983
|
const receiverEnvironmentVariablesSet = Boolean(
|
|
1953
1984
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
1954
1985
|
);
|
|
1955
1986
|
return {
|
|
1956
|
-
qstashClient: new
|
|
1987
|
+
qstashClient: new import_qstash5.Client({
|
|
1957
1988
|
baseUrl: environment.QSTASH_URL,
|
|
1958
1989
|
token: environment.QSTASH_TOKEN
|
|
1959
1990
|
}),
|
|
@@ -1974,7 +2005,7 @@ var processOptions = (options) => {
|
|
|
1974
2005
|
throw error;
|
|
1975
2006
|
}
|
|
1976
2007
|
},
|
|
1977
|
-
receiver: receiverEnvironmentVariablesSet ? new
|
|
2008
|
+
receiver: receiverEnvironmentVariablesSet ? new import_qstash4.Receiver({
|
|
1978
2009
|
currentSigningKey: environment.QSTASH_CURRENT_SIGNING_KEY,
|
|
1979
2010
|
nextSigningKey: environment.QSTASH_NEXT_SIGNING_KEY
|
|
1980
2011
|
}) : void 0,
|
|
@@ -2096,7 +2127,8 @@ var serve = (routeFunction, options) => {
|
|
|
2096
2127
|
onStep: async () => routeFunction(workflowContext),
|
|
2097
2128
|
onCleanup: async () => {
|
|
2098
2129
|
await triggerWorkflowDelete(workflowContext, debug);
|
|
2099
|
-
}
|
|
2130
|
+
},
|
|
2131
|
+
debug
|
|
2100
2132
|
});
|
|
2101
2133
|
if (result.isErr()) {
|
|
2102
2134
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
@@ -2122,14 +2154,14 @@ var serve = (routeFunction, options) => {
|
|
|
2122
2154
|
};
|
|
2123
2155
|
|
|
2124
2156
|
// src/client/index.ts
|
|
2125
|
-
var
|
|
2157
|
+
var import_qstash6 = require("@upstash/qstash");
|
|
2126
2158
|
var Client3 = class {
|
|
2127
2159
|
client;
|
|
2128
2160
|
constructor(clientConfig) {
|
|
2129
2161
|
if (!clientConfig.token) {
|
|
2130
2162
|
console.warn("[Upstash Workflow] url or the token is not set. client will not work.");
|
|
2131
2163
|
}
|
|
2132
|
-
this.client = new
|
|
2164
|
+
this.client = new import_qstash6.Client(clientConfig);
|
|
2133
2165
|
}
|
|
2134
2166
|
/**
|
|
2135
2167
|
* Cancel an ongoing workflow
|
package/index.mjs
CHANGED
package/nextjs.d.mts
CHANGED
package/nextjs.d.ts
CHANGED