@upstash/workflow 0.2.22 → 0.2.23
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 +2 -2
- package/astro.d.ts +2 -2
- package/astro.js +175 -59
- package/astro.mjs +1 -1
- package/{chunk-BON2RKOR.mjs → chunk-GZRDB6Z5.mjs} +175 -59
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +175 -59
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +175 -59
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +175 -59
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +175 -59
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +175 -59
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +175 -59
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-CctdYIfB.d.mts → serve-many-B5Vbacm6.d.mts} +1 -1
- package/{serve-many-BXDr30rl.d.ts → serve-many-BCV7INWe.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +175 -59
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +175 -59
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +2 -2
- package/tanstack.d.ts +2 -2
- package/tanstack.js +175 -59
- package/tanstack.mjs +1 -1
- package/{types-9nCq6bRP.d.ts → types-BD06btU6.d.mts} +20 -5
- package/{types-9nCq6bRP.d.mts → types-BD06btU6.d.ts} +20 -5
package/h3.js
CHANGED
|
@@ -511,8 +511,8 @@ var NANOID_LENGTH = 21;
|
|
|
511
511
|
function getRandomInt() {
|
|
512
512
|
return Math.floor(Math.random() * NANOID_CHARS.length);
|
|
513
513
|
}
|
|
514
|
-
function nanoid() {
|
|
515
|
-
return Array.from({ length
|
|
514
|
+
function nanoid(length = NANOID_LENGTH) {
|
|
515
|
+
return Array.from({ length }).map(() => NANOID_CHARS[getRandomInt()]).join("");
|
|
516
516
|
}
|
|
517
517
|
function getWorkflowRunId(id) {
|
|
518
518
|
return `wfr_${id ?? nanoid()}`;
|
|
@@ -529,6 +529,37 @@ function decodeBase64(base64) {
|
|
|
529
529
|
return binString;
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
|
+
function getUserIdFromToken(qstashClient) {
|
|
533
|
+
try {
|
|
534
|
+
const token = qstashClient.token;
|
|
535
|
+
const decodedToken = decodeBase64(token);
|
|
536
|
+
const tokenPayload = JSON.parse(decodedToken);
|
|
537
|
+
const userId = tokenPayload.UserID;
|
|
538
|
+
if (!userId) {
|
|
539
|
+
throw new WorkflowError("QStash token payload does not contain userId");
|
|
540
|
+
}
|
|
541
|
+
return userId;
|
|
542
|
+
} catch (error) {
|
|
543
|
+
throw new WorkflowError(
|
|
544
|
+
`Failed to decode QStash token while running create webhook step: ${error.message}`
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function getQStashUrl(qstashClient) {
|
|
549
|
+
try {
|
|
550
|
+
const requester = qstashClient.http;
|
|
551
|
+
const baseUrl = requester.baseUrl;
|
|
552
|
+
if (!baseUrl) {
|
|
553
|
+
throw new WorkflowError("QStash client does not have a baseUrl");
|
|
554
|
+
}
|
|
555
|
+
return baseUrl;
|
|
556
|
+
} catch (error) {
|
|
557
|
+
throw new WorkflowError(`Failed to get QStash URL from client: ${error.message}`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function getEventId() {
|
|
561
|
+
return `evt_${nanoid(15)}`;
|
|
562
|
+
}
|
|
532
563
|
|
|
533
564
|
// node_modules/neverthrow/dist/index.es.js
|
|
534
565
|
var defaultErrorConfig = {
|
|
@@ -954,7 +985,9 @@ var StepTypes = [
|
|
|
954
985
|
"Call",
|
|
955
986
|
"Wait",
|
|
956
987
|
"Notify",
|
|
957
|
-
"Invoke"
|
|
988
|
+
"Invoke",
|
|
989
|
+
"CreateWebhook",
|
|
990
|
+
"WaitForWebhook"
|
|
958
991
|
];
|
|
959
992
|
|
|
960
993
|
// src/workflow-requests.ts
|
|
@@ -1266,7 +1299,9 @@ If you want to disable QStash Verification, you should clear env variables QSTAS
|
|
|
1266
1299
|
// src/context/steps.ts
|
|
1267
1300
|
var BaseLazyStep = class _BaseLazyStep {
|
|
1268
1301
|
stepName;
|
|
1269
|
-
|
|
1302
|
+
context;
|
|
1303
|
+
constructor(context, stepName) {
|
|
1304
|
+
this.context = context;
|
|
1270
1305
|
if (!stepName) {
|
|
1271
1306
|
throw new WorkflowError(
|
|
1272
1307
|
"A workflow step name cannot be undefined or an empty string. Please provide a name for your workflow step."
|
|
@@ -1284,13 +1319,14 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
1284
1319
|
*
|
|
1285
1320
|
* will be called when returning the steps to the context from auto executor
|
|
1286
1321
|
*
|
|
1287
|
-
* @param
|
|
1322
|
+
* @param step step
|
|
1288
1323
|
* @returns parsed out field
|
|
1289
1324
|
*/
|
|
1290
|
-
parseOut(
|
|
1325
|
+
parseOut(step) {
|
|
1326
|
+
const out = step.out;
|
|
1291
1327
|
if (out === void 0) {
|
|
1292
1328
|
if (this.allowUndefinedOut) {
|
|
1293
|
-
return
|
|
1329
|
+
return this.handleUndefinedOut(step);
|
|
1294
1330
|
} else {
|
|
1295
1331
|
throw new WorkflowError(
|
|
1296
1332
|
`Error while parsing output of ${this.stepType} step. Expected a string, but got: undefined`
|
|
@@ -1298,27 +1334,26 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
1298
1334
|
}
|
|
1299
1335
|
}
|
|
1300
1336
|
if (typeof out === "object") {
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
return out;
|
|
1306
|
-
}
|
|
1307
|
-
return {
|
|
1308
|
-
...out,
|
|
1309
|
-
eventData: _BaseLazyStep.tryParsing(out.eventData)
|
|
1310
|
-
};
|
|
1337
|
+
console.warn(
|
|
1338
|
+
`Error while parsing ${this.stepType} step output. Expected a string, but got object. Please reach out to Upstash Support.`
|
|
1339
|
+
);
|
|
1340
|
+
return out;
|
|
1311
1341
|
}
|
|
1312
1342
|
if (typeof out !== "string") {
|
|
1313
1343
|
throw new WorkflowError(
|
|
1314
1344
|
`Error while parsing output of ${this.stepType} step. Expected a string or undefined, but got: ${typeof out}`
|
|
1315
1345
|
);
|
|
1316
1346
|
}
|
|
1317
|
-
return this.safeParseOut(out);
|
|
1347
|
+
return this.safeParseOut(out, step);
|
|
1318
1348
|
}
|
|
1319
|
-
|
|
1349
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1350
|
+
safeParseOut(out, step) {
|
|
1320
1351
|
return _BaseLazyStep.tryParsing(out);
|
|
1321
1352
|
}
|
|
1353
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1354
|
+
handleUndefinedOut(step) {
|
|
1355
|
+
return void 0;
|
|
1356
|
+
}
|
|
1322
1357
|
static tryParsing(stepOut) {
|
|
1323
1358
|
try {
|
|
1324
1359
|
return JSON.parse(stepOut);
|
|
@@ -1369,8 +1404,8 @@ var LazyFunctionStep = class extends BaseLazyStep {
|
|
|
1369
1404
|
stepFunction;
|
|
1370
1405
|
stepType = "Run";
|
|
1371
1406
|
allowUndefinedOut = true;
|
|
1372
|
-
constructor(stepName, stepFunction) {
|
|
1373
|
-
super(stepName);
|
|
1407
|
+
constructor(context, stepName, stepFunction) {
|
|
1408
|
+
super(context, stepName);
|
|
1374
1409
|
this.stepFunction = stepFunction;
|
|
1375
1410
|
}
|
|
1376
1411
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1400,8 +1435,8 @@ var LazySleepStep = class extends BaseLazyStep {
|
|
|
1400
1435
|
sleep;
|
|
1401
1436
|
stepType = "SleepFor";
|
|
1402
1437
|
allowUndefinedOut = true;
|
|
1403
|
-
constructor(stepName, sleep) {
|
|
1404
|
-
super(stepName);
|
|
1438
|
+
constructor(context, stepName, sleep) {
|
|
1439
|
+
super(context, stepName);
|
|
1405
1440
|
this.sleep = sleep;
|
|
1406
1441
|
}
|
|
1407
1442
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1442,8 +1477,8 @@ var LazySleepUntilStep = class extends BaseLazyStep {
|
|
|
1442
1477
|
sleepUntil;
|
|
1443
1478
|
stepType = "SleepUntil";
|
|
1444
1479
|
allowUndefinedOut = true;
|
|
1445
|
-
constructor(stepName, sleepUntil) {
|
|
1446
|
-
super(stepName);
|
|
1480
|
+
constructor(context, stepName, sleepUntil) {
|
|
1481
|
+
super(context, stepName);
|
|
1447
1482
|
this.sleepUntil = sleepUntil;
|
|
1448
1483
|
}
|
|
1449
1484
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1495,8 +1530,8 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1495
1530
|
stringifyBody;
|
|
1496
1531
|
stepType = "Call";
|
|
1497
1532
|
allowUndefinedOut = false;
|
|
1498
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1499
|
-
super(stepName);
|
|
1533
|
+
constructor(context, stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1534
|
+
super(context, stepName);
|
|
1500
1535
|
this.url = url;
|
|
1501
1536
|
this.method = method;
|
|
1502
1537
|
this.body = body;
|
|
@@ -1640,13 +1675,12 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1640
1675
|
]);
|
|
1641
1676
|
}
|
|
1642
1677
|
};
|
|
1643
|
-
var
|
|
1678
|
+
var LazyWaitEventStep = class extends BaseLazyStep {
|
|
1644
1679
|
eventId;
|
|
1645
1680
|
timeout;
|
|
1646
|
-
stepType = "Wait";
|
|
1647
1681
|
allowUndefinedOut = false;
|
|
1648
|
-
constructor(stepName, eventId, timeout) {
|
|
1649
|
-
super(stepName);
|
|
1682
|
+
constructor(context, stepName, eventId, timeout) {
|
|
1683
|
+
super(context, stepName);
|
|
1650
1684
|
this.eventId = eventId;
|
|
1651
1685
|
this.timeout = timeout;
|
|
1652
1686
|
}
|
|
@@ -1671,13 +1705,6 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1671
1705
|
concurrent
|
|
1672
1706
|
});
|
|
1673
1707
|
}
|
|
1674
|
-
safeParseOut(out) {
|
|
1675
|
-
const result = JSON.parse(out);
|
|
1676
|
-
return {
|
|
1677
|
-
...result,
|
|
1678
|
-
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
1679
|
-
};
|
|
1680
|
-
}
|
|
1681
1708
|
getHeaders({ context, telemetry: telemetry2, invokeCount, step }) {
|
|
1682
1709
|
const headers = super.getHeaders({ context, telemetry: telemetry2, invokeCount, step });
|
|
1683
1710
|
headers.headers["Upstash-Workflow-CallType"] = "step";
|
|
@@ -1711,7 +1738,7 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1711
1738
|
timeoutHeaders,
|
|
1712
1739
|
step: {
|
|
1713
1740
|
stepId: step.stepId,
|
|
1714
|
-
stepType:
|
|
1741
|
+
stepType: this.stepType,
|
|
1715
1742
|
stepName: step.stepName,
|
|
1716
1743
|
concurrent: step.concurrent,
|
|
1717
1744
|
targetStep: step.targetStep
|
|
@@ -1732,8 +1759,8 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1732
1759
|
};
|
|
1733
1760
|
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
1734
1761
|
stepType = "Notify";
|
|
1735
|
-
constructor(stepName, eventId, eventData, requester) {
|
|
1736
|
-
super(stepName, async () => {
|
|
1762
|
+
constructor(context, stepName, eventId, eventData, requester) {
|
|
1763
|
+
super(context, stepName, async () => {
|
|
1737
1764
|
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
|
|
1738
1765
|
return {
|
|
1739
1766
|
eventId,
|
|
@@ -1758,7 +1785,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1758
1785
|
* workflow id of the invoked workflow
|
|
1759
1786
|
*/
|
|
1760
1787
|
workflowId;
|
|
1761
|
-
constructor(stepName, {
|
|
1788
|
+
constructor(context, stepName, {
|
|
1762
1789
|
workflow,
|
|
1763
1790
|
body,
|
|
1764
1791
|
headers = {},
|
|
@@ -1768,7 +1795,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1768
1795
|
flowControl,
|
|
1769
1796
|
stringifyBody = true
|
|
1770
1797
|
}) {
|
|
1771
|
-
super(stepName);
|
|
1798
|
+
super(context, stepName);
|
|
1772
1799
|
this.params = {
|
|
1773
1800
|
workflow,
|
|
1774
1801
|
body,
|
|
@@ -1829,6 +1856,9 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1829
1856
|
userHeaders: context.headers,
|
|
1830
1857
|
invokeCount
|
|
1831
1858
|
});
|
|
1859
|
+
context.qstashClient.http.headers?.forEach((value, key) => {
|
|
1860
|
+
invokerHeaders[key] = value;
|
|
1861
|
+
});
|
|
1832
1862
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
1833
1863
|
let invokeBody;
|
|
1834
1864
|
if (this.params.stringifyBody) {
|
|
@@ -1900,6 +1930,88 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1900
1930
|
return [result];
|
|
1901
1931
|
}
|
|
1902
1932
|
};
|
|
1933
|
+
var LazyCreateWebhookStep = class extends BaseLazyStep {
|
|
1934
|
+
stepType = "CreateWebhook";
|
|
1935
|
+
allowUndefinedOut = false;
|
|
1936
|
+
getPlanStep(concurrent, targetStep) {
|
|
1937
|
+
return {
|
|
1938
|
+
stepId: 0,
|
|
1939
|
+
stepName: this.stepName,
|
|
1940
|
+
stepType: this.stepType,
|
|
1941
|
+
concurrent,
|
|
1942
|
+
targetStep
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
async getResultStep(concurrent, stepId) {
|
|
1946
|
+
return {
|
|
1947
|
+
stepId,
|
|
1948
|
+
stepName: this.stepName,
|
|
1949
|
+
stepType: this.stepType,
|
|
1950
|
+
out: void 0,
|
|
1951
|
+
concurrent
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
getBody({ step, context }) {
|
|
1955
|
+
const userId = getUserIdFromToken(context.qstashClient);
|
|
1956
|
+
const workflowRunId = context.workflowRunId;
|
|
1957
|
+
const eventId = getEventId();
|
|
1958
|
+
const qstashUrl = getQStashUrl(this.context.qstashClient);
|
|
1959
|
+
return JSON.stringify({
|
|
1960
|
+
...step,
|
|
1961
|
+
out: JSON.stringify({
|
|
1962
|
+
webhookUrl: `${qstashUrl}/v2/workflows/hooks/${userId}/${workflowRunId}/${eventId}`,
|
|
1963
|
+
eventId
|
|
1964
|
+
})
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
|
|
1969
|
+
stepType = "WaitForWebhook";
|
|
1970
|
+
allowUndefinedOut = true;
|
|
1971
|
+
constructor(context, stepName, webhook, timeout) {
|
|
1972
|
+
super(context, stepName, webhook.eventId, timeout);
|
|
1973
|
+
}
|
|
1974
|
+
safeParseOut(out) {
|
|
1975
|
+
const eventData = decodeBase64(out);
|
|
1976
|
+
const parsedEventData = BaseLazyStep.tryParsing(eventData);
|
|
1977
|
+
const body = parsedEventData.body;
|
|
1978
|
+
const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
|
|
1979
|
+
const request = new Request(
|
|
1980
|
+
`${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
|
|
1981
|
+
{
|
|
1982
|
+
method: parsedEventData.method,
|
|
1983
|
+
headers: parsedEventData.header,
|
|
1984
|
+
body: parsedBody
|
|
1985
|
+
}
|
|
1986
|
+
);
|
|
1987
|
+
return {
|
|
1988
|
+
request,
|
|
1989
|
+
timeout: false
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
handleUndefinedOut() {
|
|
1993
|
+
return {
|
|
1994
|
+
timeout: true,
|
|
1995
|
+
request: void 0
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
var LazyWaitForEventStep = class extends LazyWaitEventStep {
|
|
2000
|
+
stepType = "Wait";
|
|
2001
|
+
allowUndefinedOut = true;
|
|
2002
|
+
parseWaitForEventOut(out, waitTimeout) {
|
|
2003
|
+
return {
|
|
2004
|
+
eventData: out ? BaseLazyStep.tryParsing(decodeBase64(out)) : void 0,
|
|
2005
|
+
timeout: waitTimeout ?? false
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
safeParseOut(out, step) {
|
|
2009
|
+
return this.parseWaitForEventOut(out, step.waitTimeout);
|
|
2010
|
+
}
|
|
2011
|
+
handleUndefinedOut(step) {
|
|
2012
|
+
return this.parseWaitForEventOut(void 0, step.waitTimeout);
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
1903
2015
|
|
|
1904
2016
|
// src/agents/constants.ts
|
|
1905
2017
|
var AGENT_NAME_HEADER = "upstash-agent-name";
|
|
@@ -2304,7 +2416,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2304
2416
|
step,
|
|
2305
2417
|
stepCount: this.stepCount
|
|
2306
2418
|
});
|
|
2307
|
-
return lazyStep.parseOut(step
|
|
2419
|
+
return lazyStep.parseOut(step);
|
|
2308
2420
|
}
|
|
2309
2421
|
const resultStep = await submitSingleStep({
|
|
2310
2422
|
context: this.context,
|
|
@@ -2391,7 +2503,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2391
2503
|
const parallelResultSteps = sortedSteps.filter((step) => step.stepId >= initialStepCount).slice(0, parallelSteps.length);
|
|
2392
2504
|
validateParallelSteps(parallelSteps, parallelResultSteps);
|
|
2393
2505
|
return parallelResultSteps.map(
|
|
2394
|
-
(step, index) => parallelSteps[index].parseOut(step
|
|
2506
|
+
(step, index) => parallelSteps[index].parseOut(step)
|
|
2395
2507
|
);
|
|
2396
2508
|
}
|
|
2397
2509
|
}
|
|
@@ -2447,7 +2559,6 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2447
2559
|
* @param index index of the current step
|
|
2448
2560
|
* @returns result[index] if lazyStepList > 1, otherwise result
|
|
2449
2561
|
*/
|
|
2450
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2451
2562
|
static getResult(lazyStepList, result, index) {
|
|
2452
2563
|
if (lazyStepList.length === 1) {
|
|
2453
2564
|
return result;
|
|
@@ -3239,7 +3350,7 @@ var WorkflowContext = class {
|
|
|
3239
3350
|
*/
|
|
3240
3351
|
async run(stepName, stepFunction) {
|
|
3241
3352
|
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
3242
|
-
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
3353
|
+
return await this.addStep(new LazyFunctionStep(this, stepName, wrappedStepFunction));
|
|
3243
3354
|
}
|
|
3244
3355
|
/**
|
|
3245
3356
|
* Stops the execution for the duration provided.
|
|
@@ -3253,7 +3364,7 @@ var WorkflowContext = class {
|
|
|
3253
3364
|
* @returns undefined
|
|
3254
3365
|
*/
|
|
3255
3366
|
async sleep(stepName, duration) {
|
|
3256
|
-
await this.addStep(new LazySleepStep(stepName, duration));
|
|
3367
|
+
await this.addStep(new LazySleepStep(this, stepName, duration));
|
|
3257
3368
|
}
|
|
3258
3369
|
/**
|
|
3259
3370
|
* Stops the execution until the date time provided.
|
|
@@ -3275,13 +3386,14 @@ var WorkflowContext = class {
|
|
|
3275
3386
|
datetime = typeof datetime === "string" ? new Date(datetime) : datetime;
|
|
3276
3387
|
time = Math.round(datetime.getTime() / 1e3);
|
|
3277
3388
|
}
|
|
3278
|
-
await this.addStep(new LazySleepUntilStep(stepName, time));
|
|
3389
|
+
await this.addStep(new LazySleepUntilStep(this, stepName, time));
|
|
3279
3390
|
}
|
|
3280
3391
|
async call(stepName, settings) {
|
|
3281
3392
|
let callStep;
|
|
3282
3393
|
if ("workflow" in settings) {
|
|
3283
3394
|
const url = getNewUrlFromWorkflowId(this.url, settings.workflow.workflowId);
|
|
3284
3395
|
callStep = new LazyCallStep(
|
|
3396
|
+
this,
|
|
3285
3397
|
stepName,
|
|
3286
3398
|
url,
|
|
3287
3399
|
"POST",
|
|
@@ -3306,6 +3418,7 @@ var WorkflowContext = class {
|
|
|
3306
3418
|
stringifyBody = true
|
|
3307
3419
|
} = settings;
|
|
3308
3420
|
callStep = new LazyCallStep(
|
|
3421
|
+
this,
|
|
3309
3422
|
stepName,
|
|
3310
3423
|
url,
|
|
3311
3424
|
method,
|
|
@@ -3357,7 +3470,9 @@ var WorkflowContext = class {
|
|
|
3357
3470
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
3358
3471
|
const { timeout = "7d" } = options;
|
|
3359
3472
|
const timeoutStr = typeof timeout === "string" ? timeout : `${timeout}s`;
|
|
3360
|
-
return await this.addStep(
|
|
3473
|
+
return await this.addStep(
|
|
3474
|
+
new LazyWaitForEventStep(this, stepName, eventId, timeoutStr)
|
|
3475
|
+
);
|
|
3361
3476
|
}
|
|
3362
3477
|
/**
|
|
3363
3478
|
* Notify workflow runs waiting for an event
|
|
@@ -3382,11 +3497,19 @@ var WorkflowContext = class {
|
|
|
3382
3497
|
*/
|
|
3383
3498
|
async notify(stepName, eventId, eventData) {
|
|
3384
3499
|
return await this.addStep(
|
|
3385
|
-
new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
|
|
3500
|
+
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
|
|
3386
3501
|
);
|
|
3387
3502
|
}
|
|
3388
3503
|
async invoke(stepName, settings) {
|
|
3389
|
-
return await this.addStep(
|
|
3504
|
+
return await this.addStep(
|
|
3505
|
+
new LazyInvokeStep(this, stepName, settings)
|
|
3506
|
+
);
|
|
3507
|
+
}
|
|
3508
|
+
async createWebhook(stepName) {
|
|
3509
|
+
return await this.addStep(new LazyCreateWebhookStep(this, stepName));
|
|
3510
|
+
}
|
|
3511
|
+
async waitForWebhook(stepName, webhook, timeout) {
|
|
3512
|
+
return await this.addStep(new LazyWaitForWebhookStep(this, stepName, webhook, timeout));
|
|
3390
3513
|
}
|
|
3391
3514
|
/**
|
|
3392
3515
|
* Cancel the current workflow run
|
|
@@ -3550,13 +3673,6 @@ var processRawSteps = (rawSteps) => {
|
|
|
3550
3673
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
3551
3674
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
3552
3675
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
3553
|
-
if (step.waitEventId) {
|
|
3554
|
-
const newOut = {
|
|
3555
|
-
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
3556
|
-
timeout: step.waitTimeout ?? false
|
|
3557
|
-
};
|
|
3558
|
-
step.out = newOut;
|
|
3559
|
-
}
|
|
3560
3676
|
return step;
|
|
3561
3677
|
});
|
|
3562
3678
|
const steps = [initialStep, ...otherSteps];
|
package/h3.mjs
CHANGED
package/hono.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction, o as PublicServeOptions, z as InvokableWorkflow } from './types-
|
|
2
|
+
import { R as RouteFunction, o as PublicServeOptions, z as InvokableWorkflow } from './types-BD06btU6.mjs';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-B5Vbacm6.mjs';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'ai';
|
package/hono.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction, o as PublicServeOptions, z as InvokableWorkflow } from './types-
|
|
2
|
+
import { R as RouteFunction, o as PublicServeOptions, z as InvokableWorkflow } from './types-BD06btU6.js';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-BCV7INWe.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'ai';
|