@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/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,88 @@ 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 workflowRunId = context.workflowRunId;
|
|
1648
|
+
const eventId = getEventId();
|
|
1649
|
+
const qstashUrl = getQStashUrl(this.context.qstashClient);
|
|
1650
|
+
return JSON.stringify({
|
|
1651
|
+
...step,
|
|
1652
|
+
out: JSON.stringify({
|
|
1653
|
+
webhookUrl: `${qstashUrl}/v2/workflows/hooks/${userId}/${workflowRunId}/${eventId}`,
|
|
1654
|
+
eventId
|
|
1655
|
+
})
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
var LazyWaitForWebhookStep = class extends LazyWaitEventStep {
|
|
1660
|
+
stepType = "WaitForWebhook";
|
|
1661
|
+
allowUndefinedOut = true;
|
|
1662
|
+
constructor(context, stepName, webhook, timeout) {
|
|
1663
|
+
super(context, stepName, webhook.eventId, timeout);
|
|
1664
|
+
}
|
|
1665
|
+
safeParseOut(out) {
|
|
1666
|
+
const eventData = decodeBase64(out);
|
|
1667
|
+
const parsedEventData = BaseLazyStep.tryParsing(eventData);
|
|
1668
|
+
const body = parsedEventData.body;
|
|
1669
|
+
const parsedBody = typeof body === "string" ? decodeBase64(body) : void 0;
|
|
1670
|
+
const request = new Request(
|
|
1671
|
+
`${parsedEventData.proto}://${parsedEventData.host}${parsedEventData.url}`,
|
|
1672
|
+
{
|
|
1673
|
+
method: parsedEventData.method,
|
|
1674
|
+
headers: parsedEventData.header,
|
|
1675
|
+
body: parsedBody
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
return {
|
|
1679
|
+
request,
|
|
1680
|
+
timeout: false
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
handleUndefinedOut() {
|
|
1684
|
+
return {
|
|
1685
|
+
timeout: true,
|
|
1686
|
+
request: void 0
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
var LazyWaitForEventStep = class extends LazyWaitEventStep {
|
|
1691
|
+
stepType = "Wait";
|
|
1692
|
+
allowUndefinedOut = true;
|
|
1693
|
+
parseWaitForEventOut(out, waitTimeout) {
|
|
1694
|
+
return {
|
|
1695
|
+
eventData: out ? BaseLazyStep.tryParsing(decodeBase64(out)) : void 0,
|
|
1696
|
+
timeout: waitTimeout ?? false
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
safeParseOut(out, step) {
|
|
1700
|
+
return this.parseWaitForEventOut(out, step.waitTimeout);
|
|
1701
|
+
}
|
|
1702
|
+
handleUndefinedOut(step) {
|
|
1703
|
+
return this.parseWaitForEventOut(void 0, step.waitTimeout);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1594
1706
|
|
|
1595
1707
|
// src/agents/constants.ts
|
|
1596
1708
|
var AGENT_NAME_HEADER = "upstash-agent-name";
|
|
@@ -1995,7 +2107,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
1995
2107
|
step,
|
|
1996
2108
|
stepCount: this.stepCount
|
|
1997
2109
|
});
|
|
1998
|
-
return lazyStep.parseOut(step
|
|
2110
|
+
return lazyStep.parseOut(step);
|
|
1999
2111
|
}
|
|
2000
2112
|
const resultStep = await submitSingleStep({
|
|
2001
2113
|
context: this.context,
|
|
@@ -2082,7 +2194,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2082
2194
|
const parallelResultSteps = sortedSteps.filter((step) => step.stepId >= initialStepCount).slice(0, parallelSteps.length);
|
|
2083
2195
|
validateParallelSteps(parallelSteps, parallelResultSteps);
|
|
2084
2196
|
return parallelResultSteps.map(
|
|
2085
|
-
(step, index) => parallelSteps[index].parseOut(step
|
|
2197
|
+
(step, index) => parallelSteps[index].parseOut(step)
|
|
2086
2198
|
);
|
|
2087
2199
|
}
|
|
2088
2200
|
}
|
|
@@ -2138,7 +2250,6 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
2138
2250
|
* @param index index of the current step
|
|
2139
2251
|
* @returns result[index] if lazyStepList > 1, otherwise result
|
|
2140
2252
|
*/
|
|
2141
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
2142
2253
|
static getResult(lazyStepList, result, index) {
|
|
2143
2254
|
if (lazyStepList.length === 1) {
|
|
2144
2255
|
return result;
|
|
@@ -2930,7 +3041,7 @@ var WorkflowContext = class {
|
|
|
2930
3041
|
*/
|
|
2931
3042
|
async run(stepName, stepFunction) {
|
|
2932
3043
|
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
2933
|
-
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
3044
|
+
return await this.addStep(new LazyFunctionStep(this, stepName, wrappedStepFunction));
|
|
2934
3045
|
}
|
|
2935
3046
|
/**
|
|
2936
3047
|
* Stops the execution for the duration provided.
|
|
@@ -2944,7 +3055,7 @@ var WorkflowContext = class {
|
|
|
2944
3055
|
* @returns undefined
|
|
2945
3056
|
*/
|
|
2946
3057
|
async sleep(stepName, duration) {
|
|
2947
|
-
await this.addStep(new LazySleepStep(stepName, duration));
|
|
3058
|
+
await this.addStep(new LazySleepStep(this, stepName, duration));
|
|
2948
3059
|
}
|
|
2949
3060
|
/**
|
|
2950
3061
|
* Stops the execution until the date time provided.
|
|
@@ -2966,13 +3077,14 @@ var WorkflowContext = class {
|
|
|
2966
3077
|
datetime = typeof datetime === "string" ? new Date(datetime) : datetime;
|
|
2967
3078
|
time = Math.round(datetime.getTime() / 1e3);
|
|
2968
3079
|
}
|
|
2969
|
-
await this.addStep(new LazySleepUntilStep(stepName, time));
|
|
3080
|
+
await this.addStep(new LazySleepUntilStep(this, stepName, time));
|
|
2970
3081
|
}
|
|
2971
3082
|
async call(stepName, settings) {
|
|
2972
3083
|
let callStep;
|
|
2973
3084
|
if ("workflow" in settings) {
|
|
2974
3085
|
const url = getNewUrlFromWorkflowId(this.url, settings.workflow.workflowId);
|
|
2975
3086
|
callStep = new LazyCallStep(
|
|
3087
|
+
this,
|
|
2976
3088
|
stepName,
|
|
2977
3089
|
url,
|
|
2978
3090
|
"POST",
|
|
@@ -2997,6 +3109,7 @@ var WorkflowContext = class {
|
|
|
2997
3109
|
stringifyBody = true
|
|
2998
3110
|
} = settings;
|
|
2999
3111
|
callStep = new LazyCallStep(
|
|
3112
|
+
this,
|
|
3000
3113
|
stepName,
|
|
3001
3114
|
url,
|
|
3002
3115
|
method,
|
|
@@ -3048,7 +3161,9 @@ var WorkflowContext = class {
|
|
|
3048
3161
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
3049
3162
|
const { timeout = "7d" } = options;
|
|
3050
3163
|
const timeoutStr = typeof timeout === "string" ? timeout : `${timeout}s`;
|
|
3051
|
-
return await this.addStep(
|
|
3164
|
+
return await this.addStep(
|
|
3165
|
+
new LazyWaitForEventStep(this, stepName, eventId, timeoutStr)
|
|
3166
|
+
);
|
|
3052
3167
|
}
|
|
3053
3168
|
/**
|
|
3054
3169
|
* Notify workflow runs waiting for an event
|
|
@@ -3073,11 +3188,19 @@ var WorkflowContext = class {
|
|
|
3073
3188
|
*/
|
|
3074
3189
|
async notify(stepName, eventId, eventData) {
|
|
3075
3190
|
return await this.addStep(
|
|
3076
|
-
new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
|
|
3191
|
+
new LazyNotifyStep(this, stepName, eventId, eventData, this.qstashClient.http)
|
|
3077
3192
|
);
|
|
3078
3193
|
}
|
|
3079
3194
|
async invoke(stepName, settings) {
|
|
3080
|
-
return await this.addStep(
|
|
3195
|
+
return await this.addStep(
|
|
3196
|
+
new LazyInvokeStep(this, stepName, settings)
|
|
3197
|
+
);
|
|
3198
|
+
}
|
|
3199
|
+
async createWebhook(stepName) {
|
|
3200
|
+
return await this.addStep(new LazyCreateWebhookStep(this, stepName));
|
|
3201
|
+
}
|
|
3202
|
+
async waitForWebhook(stepName, webhook, timeout) {
|
|
3203
|
+
return await this.addStep(new LazyWaitForWebhookStep(this, stepName, webhook, timeout));
|
|
3081
3204
|
}
|
|
3082
3205
|
/**
|
|
3083
3206
|
* Cancel the current workflow run
|
|
@@ -3241,13 +3364,6 @@ var processRawSteps = (rawSteps) => {
|
|
|
3241
3364
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
3242
3365
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
3243
3366
|
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
3367
|
return step;
|
|
3252
3368
|
});
|
|
3253
3369
|
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","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';
|