@upstash/workflow 0.2.22 → 0.2.23-rc
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 +178 -59
- package/astro.mjs +1 -1
- package/{chunk-BON2RKOR.mjs → chunk-KAGTWBLF.mjs} +178 -59
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +178 -59
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +178 -59
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +178 -59
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +178 -59
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +178 -59
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +178 -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 +178 -59
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +178 -59
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +2 -2
- package/tanstack.d.ts +2 -2
- package/tanstack.js +178 -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/nextjs.js
CHANGED
|
@@ -202,8 +202,8 @@ var NANOID_LENGTH = 21;
|
|
|
202
202
|
function getRandomInt() {
|
|
203
203
|
return Math.floor(Math.random() * NANOID_CHARS.length);
|
|
204
204
|
}
|
|
205
|
-
function nanoid() {
|
|
206
|
-
return Array.from({ length
|
|
205
|
+
function nanoid(length = NANOID_LENGTH) {
|
|
206
|
+
return Array.from({ length }).map(() => NANOID_CHARS[getRandomInt()]).join("");
|
|
207
207
|
}
|
|
208
208
|
function getWorkflowRunId(id) {
|
|
209
209
|
return `wfr_${id ?? nanoid()}`;
|
|
@@ -220,6 +220,37 @@ function decodeBase64(base64) {
|
|
|
220
220
|
return binString;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
+
function getUserIdFromToken(qstashClient) {
|
|
224
|
+
try {
|
|
225
|
+
const token = qstashClient.token;
|
|
226
|
+
const decodedToken = decodeBase64(token);
|
|
227
|
+
const tokenPayload = JSON.parse(decodedToken);
|
|
228
|
+
const userId = tokenPayload.UserID;
|
|
229
|
+
if (!userId) {
|
|
230
|
+
throw new WorkflowError("QStash token payload does not contain userId");
|
|
231
|
+
}
|
|
232
|
+
return userId;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
throw new WorkflowError(
|
|
235
|
+
`Failed to decode QStash token while running create webhook step: ${error.message}`
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function getQStashUrl(qstashClient) {
|
|
240
|
+
try {
|
|
241
|
+
const requester = qstashClient.http;
|
|
242
|
+
const baseUrl = requester.baseUrl;
|
|
243
|
+
if (!baseUrl) {
|
|
244
|
+
throw new WorkflowError("QStash client does not have a baseUrl");
|
|
245
|
+
}
|
|
246
|
+
return baseUrl;
|
|
247
|
+
} catch (error) {
|
|
248
|
+
throw new WorkflowError(`Failed to get QStash URL from client: ${error.message}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function getEventId() {
|
|
252
|
+
return `evt_${nanoid(15)}`;
|
|
253
|
+
}
|
|
223
254
|
|
|
224
255
|
// node_modules/neverthrow/dist/index.es.js
|
|
225
256
|
var defaultErrorConfig = {
|
|
@@ -645,7 +676,9 @@ var StepTypes = [
|
|
|
645
676
|
"Call",
|
|
646
677
|
"Wait",
|
|
647
678
|
"Notify",
|
|
648
|
-
"Invoke"
|
|
679
|
+
"Invoke",
|
|
680
|
+
"CreateWebhook",
|
|
681
|
+
"WaitForWebhook"
|
|
649
682
|
];
|
|
650
683
|
|
|
651
684
|
// src/workflow-requests.ts
|
|
@@ -957,7 +990,9 @@ If you want to disable QStash Verification, you should clear env variables QSTAS
|
|
|
957
990
|
// src/context/steps.ts
|
|
958
991
|
var BaseLazyStep = class _BaseLazyStep {
|
|
959
992
|
stepName;
|
|
960
|
-
|
|
993
|
+
context;
|
|
994
|
+
constructor(context, stepName) {
|
|
995
|
+
this.context = context;
|
|
961
996
|
if (!stepName) {
|
|
962
997
|
throw new WorkflowError(
|
|
963
998
|
"A workflow step name cannot be undefined or an empty string. Please provide a name for your workflow step."
|
|
@@ -975,13 +1010,14 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
975
1010
|
*
|
|
976
1011
|
* will be called when returning the steps to the context from auto executor
|
|
977
1012
|
*
|
|
978
|
-
* @param
|
|
1013
|
+
* @param step step
|
|
979
1014
|
* @returns parsed out field
|
|
980
1015
|
*/
|
|
981
|
-
parseOut(
|
|
1016
|
+
parseOut(step) {
|
|
1017
|
+
const out = step.out;
|
|
982
1018
|
if (out === void 0) {
|
|
983
1019
|
if (this.allowUndefinedOut) {
|
|
984
|
-
return
|
|
1020
|
+
return this.handleUndefinedOut(step);
|
|
985
1021
|
} else {
|
|
986
1022
|
throw new WorkflowError(
|
|
987
1023
|
`Error while parsing output of ${this.stepType} step. Expected a string, but got: undefined`
|
|
@@ -989,27 +1025,26 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
989
1025
|
}
|
|
990
1026
|
}
|
|
991
1027
|
if (typeof out === "object") {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
return out;
|
|
997
|
-
}
|
|
998
|
-
return {
|
|
999
|
-
...out,
|
|
1000
|
-
eventData: _BaseLazyStep.tryParsing(out.eventData)
|
|
1001
|
-
};
|
|
1028
|
+
console.warn(
|
|
1029
|
+
`Error while parsing ${this.stepType} step output. Expected a string, but got object. Please reach out to Upstash Support.`
|
|
1030
|
+
);
|
|
1031
|
+
return out;
|
|
1002
1032
|
}
|
|
1003
1033
|
if (typeof out !== "string") {
|
|
1004
1034
|
throw new WorkflowError(
|
|
1005
1035
|
`Error while parsing output of ${this.stepType} step. Expected a string or undefined, but got: ${typeof out}`
|
|
1006
1036
|
);
|
|
1007
1037
|
}
|
|
1008
|
-
return this.safeParseOut(out);
|
|
1038
|
+
return this.safeParseOut(out, step);
|
|
1009
1039
|
}
|
|
1010
|
-
|
|
1040
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1041
|
+
safeParseOut(out, step) {
|
|
1011
1042
|
return _BaseLazyStep.tryParsing(out);
|
|
1012
1043
|
}
|
|
1044
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1045
|
+
handleUndefinedOut(step) {
|
|
1046
|
+
return void 0;
|
|
1047
|
+
}
|
|
1013
1048
|
static tryParsing(stepOut) {
|
|
1014
1049
|
try {
|
|
1015
1050
|
return JSON.parse(stepOut);
|
|
@@ -1060,8 +1095,8 @@ var LazyFunctionStep = class extends BaseLazyStep {
|
|
|
1060
1095
|
stepFunction;
|
|
1061
1096
|
stepType = "Run";
|
|
1062
1097
|
allowUndefinedOut = true;
|
|
1063
|
-
constructor(stepName, stepFunction) {
|
|
1064
|
-
super(stepName);
|
|
1098
|
+
constructor(context, stepName, stepFunction) {
|
|
1099
|
+
super(context, stepName);
|
|
1065
1100
|
this.stepFunction = stepFunction;
|
|
1066
1101
|
}
|
|
1067
1102
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1091,8 +1126,8 @@ var LazySleepStep = class extends BaseLazyStep {
|
|
|
1091
1126
|
sleep;
|
|
1092
1127
|
stepType = "SleepFor";
|
|
1093
1128
|
allowUndefinedOut = true;
|
|
1094
|
-
constructor(stepName, sleep) {
|
|
1095
|
-
super(stepName);
|
|
1129
|
+
constructor(context, stepName, sleep) {
|
|
1130
|
+
super(context, stepName);
|
|
1096
1131
|
this.sleep = sleep;
|
|
1097
1132
|
}
|
|
1098
1133
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1133,8 +1168,8 @@ var LazySleepUntilStep = class extends BaseLazyStep {
|
|
|
1133
1168
|
sleepUntil;
|
|
1134
1169
|
stepType = "SleepUntil";
|
|
1135
1170
|
allowUndefinedOut = true;
|
|
1136
|
-
constructor(stepName, sleepUntil) {
|
|
1137
|
-
super(stepName);
|
|
1171
|
+
constructor(context, stepName, sleepUntil) {
|
|
1172
|
+
super(context, stepName);
|
|
1138
1173
|
this.sleepUntil = sleepUntil;
|
|
1139
1174
|
}
|
|
1140
1175
|
getPlanStep(concurrent, targetStep) {
|
|
@@ -1186,8 +1221,8 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1186
1221
|
stringifyBody;
|
|
1187
1222
|
stepType = "Call";
|
|
1188
1223
|
allowUndefinedOut = false;
|
|
1189
|
-
constructor(stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1190
|
-
super(stepName);
|
|
1224
|
+
constructor(context, stepName, url, method, body, headers, retries, retryDelay, timeout, flowControl, stringifyBody) {
|
|
1225
|
+
super(context, stepName);
|
|
1191
1226
|
this.url = url;
|
|
1192
1227
|
this.method = method;
|
|
1193
1228
|
this.body = body;
|
|
@@ -1331,13 +1366,12 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
1331
1366
|
]);
|
|
1332
1367
|
}
|
|
1333
1368
|
};
|
|
1334
|
-
var
|
|
1369
|
+
var LazyWaitEventStep = class extends BaseLazyStep {
|
|
1335
1370
|
eventId;
|
|
1336
1371
|
timeout;
|
|
1337
|
-
stepType = "Wait";
|
|
1338
1372
|
allowUndefinedOut = false;
|
|
1339
|
-
constructor(stepName, eventId, timeout) {
|
|
1340
|
-
super(stepName);
|
|
1373
|
+
constructor(context, stepName, eventId, timeout) {
|
|
1374
|
+
super(context, stepName);
|
|
1341
1375
|
this.eventId = eventId;
|
|
1342
1376
|
this.timeout = timeout;
|
|
1343
1377
|
}
|
|
@@ -1362,13 +1396,6 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1362
1396
|
concurrent
|
|
1363
1397
|
});
|
|
1364
1398
|
}
|
|
1365
|
-
safeParseOut(out) {
|
|
1366
|
-
const result = JSON.parse(out);
|
|
1367
|
-
return {
|
|
1368
|
-
...result,
|
|
1369
|
-
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
1399
|
getHeaders({ context, telemetry, invokeCount, step }) {
|
|
1373
1400
|
const headers = super.getHeaders({ context, telemetry, invokeCount, step });
|
|
1374
1401
|
headers.headers["Upstash-Workflow-CallType"] = "step";
|
|
@@ -1402,7 +1429,7 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1402
1429
|
timeoutHeaders,
|
|
1403
1430
|
step: {
|
|
1404
1431
|
stepId: step.stepId,
|
|
1405
|
-
stepType:
|
|
1432
|
+
stepType: this.stepType,
|
|
1406
1433
|
stepName: step.stepName,
|
|
1407
1434
|
concurrent: step.concurrent,
|
|
1408
1435
|
targetStep: step.targetStep
|
|
@@ -1423,8 +1450,8 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
1423
1450
|
};
|
|
1424
1451
|
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
1425
1452
|
stepType = "Notify";
|
|
1426
|
-
constructor(stepName, eventId, eventData, requester) {
|
|
1427
|
-
super(stepName, async () => {
|
|
1453
|
+
constructor(context, stepName, eventId, eventData, requester) {
|
|
1454
|
+
super(context, stepName, async () => {
|
|
1428
1455
|
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
|
|
1429
1456
|
return {
|
|
1430
1457
|
eventId,
|
|
@@ -1449,7 +1476,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1449
1476
|
* workflow id of the invoked workflow
|
|
1450
1477
|
*/
|
|
1451
1478
|
workflowId;
|
|
1452
|
-
constructor(stepName, {
|
|
1479
|
+
constructor(context, stepName, {
|
|
1453
1480
|
workflow,
|
|
1454
1481
|
body,
|
|
1455
1482
|
headers = {},
|
|
@@ -1459,7 +1486,7 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1459
1486
|
flowControl,
|
|
1460
1487
|
stringifyBody = true
|
|
1461
1488
|
}) {
|
|
1462
|
-
super(stepName);
|
|
1489
|
+
super(context, stepName);
|
|
1463
1490
|
this.params = {
|
|
1464
1491
|
workflow,
|
|
1465
1492
|
body,
|
|
@@ -1520,6 +1547,9 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1520
1547
|
userHeaders: context.headers,
|
|
1521
1548
|
invokeCount
|
|
1522
1549
|
});
|
|
1550
|
+
context.qstashClient.http.headers?.forEach((value, key) => {
|
|
1551
|
+
invokerHeaders[key] = value;
|
|
1552
|
+
});
|
|
1523
1553
|
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
1524
1554
|
let invokeBody;
|
|
1525
1555
|
if (this.params.stringifyBody) {
|
|
@@ -1591,6 +1621,91 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1591
1621
|
return [result];
|
|
1592
1622
|
}
|
|
1593
1623
|
};
|
|
1624
|
+
var LazyCreateWebhookStep = class extends BaseLazyStep {
|
|
1625
|
+
stepType = "CreateWebhook";
|
|
1626
|
+
allowUndefinedOut = false;
|
|
1627
|
+
getPlanStep(concurrent, targetStep) {
|
|
1628
|
+
return {
|
|
1629
|
+
stepId: 0,
|
|
1630
|
+
stepName: this.stepName,
|
|
1631
|
+
stepType: this.stepType,
|
|
1632
|
+
concurrent,
|
|
1633
|
+
targetStep
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
async getResultStep(concurrent, stepId) {
|
|
1637
|
+
return {
|
|
1638
|
+
stepId,
|
|
1639
|
+
stepName: this.stepName,
|
|
1640
|
+
stepType: this.stepType,
|
|
1641
|
+
out: void 0,
|
|
1642
|
+
concurrent
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
getBody({ step, context }) {
|
|
1646
|
+
const userId = getUserIdFromToken(context.qstashClient);
|
|
1647
|
+
const out = [userId, context.workflowRunId, getEventId()].join("/");
|
|
1648
|
+
return JSON.stringify({
|
|
1649
|
+
...step,
|
|
1650
|
+
out
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
safeParseOut(out) {
|
|
1654
|
+
const [userId, workflowRunId, eventId] = out.split("/");
|
|
1655
|
+
const qstashUrl = getQStashUrl(this.context.qstashClient);
|
|
1656
|
+
return {
|
|
1657
|
+
webhookUrl: `${qstashUrl}/v2/workflows/hooks/${userId}/${workflowRunId}/${eventId}`,
|
|
1658
|
+
eventId
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
|
|
1663
|
+
stepType = "WaitForWebhook";
|
|
1664
|
+
allowUndefinedOut = true;
|
|
1665
|
+
constructor(context, stepName, webhook, timeout) {
|
|
1666
|
+
super(context, stepName, webhook.eventId, timeout);
|
|
1667
|
+
}
|
|
1668
|
+
safeParseOut(out) {
|
|
1669
|
+
const eventData = decodeBase64(out);
|
|
1670
|
+
const parsedEventData = BaseLazyStep.tryParsing(eventData);
|
|
1671
|
+
const body = parsedEventData.body;
|
|
1672
|
+
const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
|
|
1673
|
+
const request = new Request(
|
|
1674
|
+
`${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
|
|
1675
|
+
{
|
|
1676
|
+
method: parsedEventData.method,
|
|
1677
|
+
headers: parsedEventData.header,
|
|
1678
|
+
body: parsedBody
|
|
1679
|
+
}
|
|
1680
|
+
);
|
|
1681
|
+
return {
|
|
1682
|
+
request,
|
|
1683
|
+
timeout: false
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
handleUndefinedOut() {
|
|
1687
|
+
return {
|
|
1688
|
+
timeout: true,
|
|
1689
|
+
request: void 0
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
var LazyWaitForEventStep = class extends LazyWaitEventStep {
|
|
1694
|
+
stepType = "Wait";
|
|
1695
|
+
allowUndefinedOut = true;
|
|
1696
|
+
parseWaitForEventOut(out, waitTimeout) {
|
|
1697
|
+
return {
|
|
1698
|
+
eventData: out ? BaseLazyStep.tryParsing(decodeBase64(out)) : void 0,
|
|
1699
|
+
timeout: waitTimeout ?? false
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
safeParseOut(out, step) {
|
|
1703
|
+
return this.parseWaitForEventOut(out, step.waitTimeout);
|
|
1704
|
+
}
|
|
1705
|
+
handleUndefinedOut(step) {
|
|
1706
|
+
return this.parseWaitForEventOut(void 0, step.waitTimeout);
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1594
1709
|
|
|
1595
1710
|
// src/agents/constants.ts
|
|
1596
1711
|
var AGENT_NAME_HEADER = "upstash-agent-name";
|
|
@@ -1995,7 +2110,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
1995
2110
|
step,
|
|
1996
2111
|
stepCount: this.stepCount
|
|
1997
2112
|
});
|
|
1998
|
-
return lazyStep.parseOut(step
|
|
2113
|
+
return lazyStep.parseOut(step);
|
|
1999
2114
|
}
|
|
2000
2115
|
const resultStep = await submitSingleStep({
|
|
2001
2116
|
context: this.context,
|
|
@@ -2082,7 +2197,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2082
2197
|
const parallelResultSteps = sortedSteps.filter((step) => step.stepId >= initialStepCount).slice(0, parallelSteps.length);
|
|
2083
2198
|
validateParallelSteps(parallelSteps, parallelResultSteps);
|
|
2084
2199
|
return parallelResultSteps.map(
|
|
2085
|
-
(step, index) => parallelSteps[index].parseOut(step
|
|
2200
|
+
(step, index) => parallelSteps[index].parseOut(step)
|
|
2086
2201
|
);
|
|
2087
2202
|
}
|
|
2088
2203
|
}
|
|
@@ -2138,7 +2253,6 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2138
2253
|
* @param index index of the current step
|
|
2139
2254
|
* @returns result[index] if lazyStepList > 1, otherwise result
|
|
2140
2255
|
*/
|
|
2141
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2142
2256
|
static getResult(lazyStepList, result, index) {
|
|
2143
2257
|
if (lazyStepList.length === 1) {
|
|
2144
2258
|
return result;
|
|
@@ -2930,7 +3044,7 @@ var WorkflowContext = class {
|
|
|
2930
3044
|
*/
|
|
2931
3045
|
async run(stepName, stepFunction) {
|
|
2932
3046
|
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
2933
|
-
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
3047
|
+
return await this.addStep(new LazyFunctionStep(this, stepName, wrappedStepFunction));
|
|
2934
3048
|
}
|
|
2935
3049
|
/**
|
|
2936
3050
|
* Stops the execution for the duration provided.
|
|
@@ -2944,7 +3058,7 @@ var WorkflowContext = class {
|
|
|
2944
3058
|
* @returns undefined
|
|
2945
3059
|
*/
|
|
2946
3060
|
async sleep(stepName, duration) {
|
|
2947
|
-
await this.addStep(new LazySleepStep(stepName, duration));
|
|
3061
|
+
await this.addStep(new LazySleepStep(this, stepName, duration));
|
|
2948
3062
|
}
|
|
2949
3063
|
/**
|
|
2950
3064
|
* Stops the execution until the date time provided.
|
|
@@ -2966,13 +3080,14 @@ var WorkflowContext = class {
|
|
|
2966
3080
|
datetime = typeof datetime === "string" ? new Date(datetime) : datetime;
|
|
2967
3081
|
time = Math.round(datetime.getTime() / 1e3);
|
|
2968
3082
|
}
|
|
2969
|
-
await this.addStep(new LazySleepUntilStep(stepName, time));
|
|
3083
|
+
await this.addStep(new LazySleepUntilStep(this, stepName, time));
|
|
2970
3084
|
}
|
|
2971
3085
|
async call(stepName, settings) {
|
|
2972
3086
|
let callStep;
|
|
2973
3087
|
if ("workflow" in settings) {
|
|
2974
3088
|
const url = getNewUrlFromWorkflowId(this.url, settings.workflow.workflowId);
|
|
2975
3089
|
callStep = new LazyCallStep(
|
|
3090
|
+
this,
|
|
2976
3091
|
stepName,
|
|
2977
3092
|
url,
|
|
2978
3093
|
"POST",
|
|
@@ -2997,6 +3112,7 @@ var WorkflowContext = class {
|
|
|
2997
3112
|
stringifyBody = true
|
|
2998
3113
|
} = settings;
|
|
2999
3114
|
callStep = new LazyCallStep(
|
|
3115
|
+
this,
|
|
3000
3116
|
stepName,
|
|
3001
3117
|
url,
|
|
3002
3118
|
method,
|
|
@@ -3048,7 +3164,9 @@ var WorkflowContext = class {
|
|
|
3048
3164
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
3049
3165
|
const { timeout = "7d" } = options;
|
|
3050
3166
|
const timeoutStr = typeof timeout === "string" ? timeout : `${timeout}s`;
|
|
3051
|
-
return await this.addStep(
|
|
3167
|
+
return await this.addStep(
|
|
3168
|
+
new LazyWaitForEventStep(this, stepName, eventId, timeoutStr)
|
|
3169
|
+
);
|
|
3052
3170
|
}
|
|
3053
3171
|
/**
|
|
3054
3172
|
* Notify workflow runs waiting for an event
|
|
@@ -3073,11 +3191,19 @@ var WorkflowContext = class {
|
|
|
3073
3191
|
*/
|
|
3074
3192
|
async notify(stepName, eventId, eventData) {
|
|
3075
3193
|
return await this.addStep(
|
|
3076
|
-
new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
|
|
3194
|
+
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
|
|
3077
3195
|
);
|
|
3078
3196
|
}
|
|
3079
3197
|
async invoke(stepName, settings) {
|
|
3080
|
-
return await this.addStep(
|
|
3198
|
+
return await this.addStep(
|
|
3199
|
+
new LazyInvokeStep(this, stepName, settings)
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
async createWebhook(stepName) {
|
|
3203
|
+
return await this.addStep(new LazyCreateWebhookStep(this, stepName));
|
|
3204
|
+
}
|
|
3205
|
+
async waitForWebhook(stepName, webhook, timeout) {
|
|
3206
|
+
return await this.addStep(new LazyWaitForWebhookStep(this, stepName, webhook, timeout));
|
|
3081
3207
|
}
|
|
3082
3208
|
/**
|
|
3083
3209
|
* Cancel the current workflow run
|
|
@@ -3241,13 +3367,6 @@ var processRawSteps = (rawSteps) => {
|
|
|
3241
3367
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
3242
3368
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
3243
3369
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
3244
|
-
if (step.waitEventId) {
|
|
3245
|
-
const newOut = {
|
|
3246
|
-
eventData: step.out ? decodeBase64(step.out) : void 0,
|
|
3247
|
-
timeout: step.waitTimeout ?? false
|
|
3248
|
-
};
|
|
3249
|
-
step.out = newOut;
|
|
3250
|
-
}
|
|
3251
3370
|
return step;
|
|
3252
3371
|
});
|
|
3253
3372
|
const steps = [initialStep, ...otherSteps];
|
package/nextjs.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/workflow","version":"v0.2.
|
|
1
|
+
{"name":"@upstash/workflow","version":"v0.2.23-rc","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"},"./express":{"import":"./express.mjs","require":"./express.js"},"./tanstack":{"import":"./tanstack.mjs","require":"./tanstack.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":{"@ai-sdk/anthropic":"^1.1.15","@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","@tanstack/react-start":"^1.132.48","@types/bun":"^1.1.10","@types/express":"^5.0.3","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^5.1.0","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.20","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsup":"^8.3.0","typescript":"^5.7.2","typescript-eslint":"^8.18.0"},"dependencies":{"@ai-sdk/openai":"^1.2.1","@upstash/qstash":"^2.8.2","ai":"^4.1.54","zod":"^3.24.1"},"directories":{"example":"examples"}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as PublicServeOptions, R as RouteFunction, z as InvokableWorkflow } from './types-
|
|
1
|
+
import { o as PublicServeOptions, R as RouteFunction, z as InvokableWorkflow } from './types-BD06btU6.mjs';
|
|
2
2
|
|
|
3
3
|
type OmitOptionsInServeMany<TOptions> = Omit<TOptions, "env" | "url" | "schema" | "initialPayloadParser">;
|
|
4
4
|
declare const serveManyBase: <THandler extends (...params: any[]) => any, TOptions extends OmitOptionsInServeMany<PublicServeOptions> = OmitOptionsInServeMany<PublicServeOptions>, TServeParams extends [routeFunction: RouteFunction<any, any>, options: TOptions] = [routeFunction: RouteFunction<any, any>, options: TOptions]>({ workflows, getUrl, serveMethod, options, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as PublicServeOptions, R as RouteFunction, z as InvokableWorkflow } from './types-
|
|
1
|
+
import { o as PublicServeOptions, R as RouteFunction, z as InvokableWorkflow } from './types-BD06btU6.js';
|
|
2
2
|
|
|
3
3
|
type OmitOptionsInServeMany<TOptions> = Omit<TOptions, "env" | "url" | "schema" | "initialPayloadParser">;
|
|
4
4
|
declare const serveManyBase: <THandler extends (...params: any[]) => any, TOptions extends OmitOptionsInServeMany<PublicServeOptions> = OmitOptionsInServeMany<PublicServeOptions>, TServeParams extends [routeFunction: RouteFunction<any, any>, options: TOptions] = [routeFunction: RouteFunction<any, any>, options: TOptions]>({ workflows, getUrl, serveMethod, options, }: {
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, o as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, o as PublicServeOptions } from './types-BD06btU6.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, o as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, o as PublicServeOptions } from './types-BD06btU6.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|