@upstash/workflow 0.2.10-unicode-rc → 0.2.10
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 +63 -142
- package/astro.mjs +1 -1
- package/{chunk-N2WV5VCD.mjs → chunk-GFNR743S.mjs} +63 -142
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +63 -142
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +63 -142
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +63 -142
- package/h3.mjs +1 -1
- package/hono.d.mts +3 -3
- package/hono.d.ts +3 -3
- package/hono.js +63 -142
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +63 -142
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +63 -142
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-wMUWrSIP.d.mts → serve-many-BVDpPsF-.d.mts} +1 -1
- package/{serve-many-jCRazho9.d.ts → serve-many-e4zufyXN.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +63 -142
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +63 -142
- package/svelte.mjs +1 -1
- package/{types-Dg_9L83G.d.ts → types-CYhDXnf8.d.mts} +5 -13
- package/{types-Dg_9L83G.d.mts → types-CYhDXnf8.d.ts} +5 -13
package/express.js
CHANGED
|
@@ -23823,21 +23823,22 @@ function getWorkflowRunId(id) {
|
|
|
23823
23823
|
return `wfr_${id ?? nanoid()}`;
|
|
23824
23824
|
}
|
|
23825
23825
|
function decodeBase64(base64) {
|
|
23826
|
-
const binString = atob(base64);
|
|
23827
23826
|
try {
|
|
23827
|
+
const binString = atob(base64);
|
|
23828
23828
|
const intArray = Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
23829
23829
|
return new TextDecoder().decode(intArray);
|
|
23830
23830
|
} catch (error) {
|
|
23831
23831
|
console.warn(
|
|
23832
23832
|
`Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
|
|
23833
23833
|
);
|
|
23834
|
-
return
|
|
23834
|
+
return atob(base64);
|
|
23835
23835
|
}
|
|
23836
23836
|
}
|
|
23837
23837
|
|
|
23838
23838
|
// src/context/steps.ts
|
|
23839
|
-
var BaseLazyStep = class
|
|
23839
|
+
var BaseLazyStep = class {
|
|
23840
23840
|
stepName;
|
|
23841
|
+
// will be set in the subclasses
|
|
23841
23842
|
constructor(stepName) {
|
|
23842
23843
|
if (!stepName) {
|
|
23843
23844
|
throw new WorkflowError(
|
|
@@ -23846,58 +23847,10 @@ var BaseLazyStep = class _BaseLazyStep {
|
|
|
23846
23847
|
}
|
|
23847
23848
|
this.stepName = stepName;
|
|
23848
23849
|
}
|
|
23849
|
-
/**
|
|
23850
|
-
* parse the out field of a step result.
|
|
23851
|
-
*
|
|
23852
|
-
* will be called when returning the steps to the context from auto executor
|
|
23853
|
-
*
|
|
23854
|
-
* @param out field of the step
|
|
23855
|
-
* @returns parsed out field
|
|
23856
|
-
*/
|
|
23857
|
-
parseOut(out) {
|
|
23858
|
-
if (out === void 0) {
|
|
23859
|
-
if (this.allowUndefinedOut) {
|
|
23860
|
-
return void 0;
|
|
23861
|
-
} else {
|
|
23862
|
-
throw new WorkflowError(
|
|
23863
|
-
`Error while parsing output of ${this.stepType} step. Expected a string, but got: undefined`
|
|
23864
|
-
);
|
|
23865
|
-
}
|
|
23866
|
-
}
|
|
23867
|
-
if (typeof out === "object") {
|
|
23868
|
-
if (this.stepType !== "Wait") {
|
|
23869
|
-
console.warn(
|
|
23870
|
-
`Error while parsing ${this.stepType} step output. Expected a string, but got object. Please reach out to Upstash Support.`
|
|
23871
|
-
);
|
|
23872
|
-
return out;
|
|
23873
|
-
}
|
|
23874
|
-
return {
|
|
23875
|
-
...out,
|
|
23876
|
-
eventData: _BaseLazyStep.tryParsing(out.eventData)
|
|
23877
|
-
};
|
|
23878
|
-
}
|
|
23879
|
-
if (typeof out !== "string") {
|
|
23880
|
-
throw new WorkflowError(
|
|
23881
|
-
`Error while parsing output of ${this.stepType} step. Expected a string or undefined, but got: ${typeof out}`
|
|
23882
|
-
);
|
|
23883
|
-
}
|
|
23884
|
-
return this.safeParseOut(out);
|
|
23885
|
-
}
|
|
23886
|
-
safeParseOut(out) {
|
|
23887
|
-
return _BaseLazyStep.tryParsing(out);
|
|
23888
|
-
}
|
|
23889
|
-
static tryParsing(stepOut) {
|
|
23890
|
-
try {
|
|
23891
|
-
return JSON.parse(stepOut);
|
|
23892
|
-
} catch {
|
|
23893
|
-
return stepOut;
|
|
23894
|
-
}
|
|
23895
|
-
}
|
|
23896
23850
|
};
|
|
23897
23851
|
var LazyFunctionStep = class extends BaseLazyStep {
|
|
23898
23852
|
stepFunction;
|
|
23899
23853
|
stepType = "Run";
|
|
23900
|
-
allowUndefinedOut = true;
|
|
23901
23854
|
constructor(stepName, stepFunction) {
|
|
23902
23855
|
super(stepName);
|
|
23903
23856
|
this.stepFunction = stepFunction;
|
|
@@ -23928,7 +23881,6 @@ var LazyFunctionStep = class extends BaseLazyStep {
|
|
|
23928
23881
|
var LazySleepStep = class extends BaseLazyStep {
|
|
23929
23882
|
sleep;
|
|
23930
23883
|
stepType = "SleepFor";
|
|
23931
|
-
allowUndefinedOut = true;
|
|
23932
23884
|
constructor(stepName, sleep) {
|
|
23933
23885
|
super(stepName);
|
|
23934
23886
|
this.sleep = sleep;
|
|
@@ -23956,7 +23908,6 @@ var LazySleepStep = class extends BaseLazyStep {
|
|
|
23956
23908
|
var LazySleepUntilStep = class extends BaseLazyStep {
|
|
23957
23909
|
sleepUntil;
|
|
23958
23910
|
stepType = "SleepUntil";
|
|
23959
|
-
allowUndefinedOut = true;
|
|
23960
23911
|
constructor(stepName, sleepUntil) {
|
|
23961
23912
|
super(stepName);
|
|
23962
23913
|
this.sleepUntil = sleepUntil;
|
|
@@ -23980,11 +23931,8 @@ var LazySleepUntilStep = class extends BaseLazyStep {
|
|
|
23980
23931
|
concurrent
|
|
23981
23932
|
});
|
|
23982
23933
|
}
|
|
23983
|
-
safeParseOut() {
|
|
23984
|
-
return void 0;
|
|
23985
|
-
}
|
|
23986
23934
|
};
|
|
23987
|
-
var LazyCallStep = class
|
|
23935
|
+
var LazyCallStep = class extends BaseLazyStep {
|
|
23988
23936
|
url;
|
|
23989
23937
|
method;
|
|
23990
23938
|
body;
|
|
@@ -23993,7 +23941,6 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
23993
23941
|
timeout;
|
|
23994
23942
|
flowControl;
|
|
23995
23943
|
stepType = "Call";
|
|
23996
|
-
allowUndefinedOut = false;
|
|
23997
23944
|
constructor(stepName, url, method, body, headers, retries, timeout, flowControl) {
|
|
23998
23945
|
super(stepName);
|
|
23999
23946
|
this.url = url;
|
|
@@ -24025,53 +23972,11 @@ var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
|
24025
23972
|
callHeaders: this.headers
|
|
24026
23973
|
});
|
|
24027
23974
|
}
|
|
24028
|
-
safeParseOut(out) {
|
|
24029
|
-
const { header, status, body } = JSON.parse(out);
|
|
24030
|
-
const responseHeaders = new Headers(header);
|
|
24031
|
-
if (_LazyCallStep.isText(responseHeaders.get("content-type"))) {
|
|
24032
|
-
const bytes = new Uint8Array(out.length);
|
|
24033
|
-
for (let i = 0; i < out.length; i++) {
|
|
24034
|
-
bytes[i] = out.charCodeAt(i);
|
|
24035
|
-
}
|
|
24036
|
-
const processedResult = new TextDecoder().decode(bytes);
|
|
24037
|
-
const newBody = JSON.parse(processedResult).body;
|
|
24038
|
-
return {
|
|
24039
|
-
status,
|
|
24040
|
-
header,
|
|
24041
|
-
body: BaseLazyStep.tryParsing(newBody)
|
|
24042
|
-
};
|
|
24043
|
-
} else {
|
|
24044
|
-
return { header, status, body };
|
|
24045
|
-
}
|
|
24046
|
-
}
|
|
24047
|
-
static applicationHeaders = /* @__PURE__ */ new Set([
|
|
24048
|
-
"application/json",
|
|
24049
|
-
"application/xml",
|
|
24050
|
-
"application/javascript",
|
|
24051
|
-
"application/x-www-form-urlencoded",
|
|
24052
|
-
"application/xhtml+xml",
|
|
24053
|
-
"application/ld+json",
|
|
24054
|
-
"application/rss+xml",
|
|
24055
|
-
"application/atom+xml"
|
|
24056
|
-
]);
|
|
24057
|
-
static isText = (contentTypeHeader) => {
|
|
24058
|
-
if (!contentTypeHeader) {
|
|
24059
|
-
return false;
|
|
24060
|
-
}
|
|
24061
|
-
if (_LazyCallStep.applicationHeaders.has(contentTypeHeader)) {
|
|
24062
|
-
return true;
|
|
24063
|
-
}
|
|
24064
|
-
if (contentTypeHeader.startsWith("text/")) {
|
|
24065
|
-
return true;
|
|
24066
|
-
}
|
|
24067
|
-
return false;
|
|
24068
|
-
};
|
|
24069
23975
|
};
|
|
24070
23976
|
var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
24071
23977
|
eventId;
|
|
24072
23978
|
timeout;
|
|
24073
23979
|
stepType = "Wait";
|
|
24074
|
-
allowUndefinedOut = false;
|
|
24075
23980
|
constructor(stepName, eventId, timeout) {
|
|
24076
23981
|
super(stepName);
|
|
24077
23982
|
this.eventId = eventId;
|
|
@@ -24098,13 +24003,6 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
24098
24003
|
concurrent
|
|
24099
24004
|
});
|
|
24100
24005
|
}
|
|
24101
|
-
safeParseOut(out) {
|
|
24102
|
-
const result = JSON.parse(out);
|
|
24103
|
-
return {
|
|
24104
|
-
...result,
|
|
24105
|
-
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
24106
|
-
};
|
|
24107
|
-
}
|
|
24108
24006
|
};
|
|
24109
24007
|
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
24110
24008
|
stepType = "Notify";
|
|
@@ -24118,18 +24016,10 @@ var LazyNotifyStep = class extends LazyFunctionStep {
|
|
|
24118
24016
|
};
|
|
24119
24017
|
});
|
|
24120
24018
|
}
|
|
24121
|
-
safeParseOut(out) {
|
|
24122
|
-
const result = JSON.parse(out);
|
|
24123
|
-
return {
|
|
24124
|
-
...result,
|
|
24125
|
-
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
24126
|
-
};
|
|
24127
|
-
}
|
|
24128
24019
|
};
|
|
24129
24020
|
var LazyInvokeStep = class extends BaseLazyStep {
|
|
24130
24021
|
stepType = "Invoke";
|
|
24131
24022
|
params;
|
|
24132
|
-
allowUndefinedOut = false;
|
|
24133
24023
|
constructor(stepName, {
|
|
24134
24024
|
workflow,
|
|
24135
24025
|
body,
|
|
@@ -24169,13 +24059,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24169
24059
|
concurrent
|
|
24170
24060
|
});
|
|
24171
24061
|
}
|
|
24172
|
-
safeParseOut(out) {
|
|
24173
|
-
const result = JSON.parse(out);
|
|
24174
|
-
return {
|
|
24175
|
-
...result,
|
|
24176
|
-
body: BaseLazyStep.tryParsing(result.body)
|
|
24177
|
-
};
|
|
24178
|
-
}
|
|
24179
24062
|
};
|
|
24180
24063
|
|
|
24181
24064
|
// node_modules/neverthrow/dist/index.es.js
|
|
@@ -25158,7 +25041,7 @@ var invokeWorkflow = async ({
|
|
|
25158
25041
|
headers: Object.fromEntries(
|
|
25159
25042
|
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
25160
25043
|
),
|
|
25161
|
-
workflowRunId,
|
|
25044
|
+
workflowRunId: context.workflowRunId,
|
|
25162
25045
|
workflowUrl: context.url,
|
|
25163
25046
|
step: invokeStep
|
|
25164
25047
|
};
|
|
@@ -25272,7 +25155,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
25272
25155
|
step,
|
|
25273
25156
|
stepCount: this.stepCount
|
|
25274
25157
|
});
|
|
25275
|
-
return
|
|
25158
|
+
return step.out;
|
|
25276
25159
|
}
|
|
25277
25160
|
const resultStep = await lazyStep.getResultStep(NO_CONCURRENCY, this.stepCount);
|
|
25278
25161
|
await this.debug?.log("INFO", "RUN_SINGLE", {
|
|
@@ -25347,9 +25230,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
25347
25230
|
case "last": {
|
|
25348
25231
|
const parallelResultSteps = sortedSteps.filter((step) => step.stepId >= initialStepCount).slice(0, parallelSteps.length);
|
|
25349
25232
|
validateParallelSteps(parallelSteps, parallelResultSteps);
|
|
25350
|
-
return parallelResultSteps.map(
|
|
25351
|
-
(step, index) => parallelSteps[index].parseOut(step.out)
|
|
25352
|
-
);
|
|
25233
|
+
return parallelResultSteps.map((step) => step.out);
|
|
25353
25234
|
}
|
|
25354
25235
|
}
|
|
25355
25236
|
const fillValue = void 0;
|
|
@@ -26190,7 +26071,7 @@ var WorkflowContext = class {
|
|
|
26190
26071
|
*/
|
|
26191
26072
|
async run(stepName, stepFunction) {
|
|
26192
26073
|
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
26193
|
-
return
|
|
26074
|
+
return this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
26194
26075
|
}
|
|
26195
26076
|
/**
|
|
26196
26077
|
* Stops the execution for the duration provided.
|
|
@@ -26261,27 +26142,43 @@ var WorkflowContext = class {
|
|
|
26261
26142
|
* }
|
|
26262
26143
|
*/
|
|
26263
26144
|
async call(stepName, settings) {
|
|
26264
|
-
const {
|
|
26265
|
-
|
|
26266
|
-
method = "GET",
|
|
26267
|
-
body: requestBody,
|
|
26268
|
-
headers = {},
|
|
26269
|
-
retries = 0,
|
|
26270
|
-
timeout,
|
|
26271
|
-
flowControl
|
|
26272
|
-
} = settings;
|
|
26273
|
-
return await this.addStep(
|
|
26145
|
+
const { url, method = "GET", body, headers = {}, retries = 0, timeout, flowControl } = settings;
|
|
26146
|
+
const result = await this.addStep(
|
|
26274
26147
|
new LazyCallStep(
|
|
26275
26148
|
stepName,
|
|
26276
26149
|
url,
|
|
26277
26150
|
method,
|
|
26278
|
-
|
|
26151
|
+
body,
|
|
26279
26152
|
headers,
|
|
26280
26153
|
retries,
|
|
26281
26154
|
timeout,
|
|
26282
26155
|
flowControl
|
|
26283
26156
|
)
|
|
26284
26157
|
);
|
|
26158
|
+
if (typeof result === "string") {
|
|
26159
|
+
try {
|
|
26160
|
+
const body2 = JSON.parse(result);
|
|
26161
|
+
return {
|
|
26162
|
+
status: 200,
|
|
26163
|
+
header: {},
|
|
26164
|
+
body: body2
|
|
26165
|
+
};
|
|
26166
|
+
} catch {
|
|
26167
|
+
return {
|
|
26168
|
+
status: 200,
|
|
26169
|
+
header: {},
|
|
26170
|
+
body: result
|
|
26171
|
+
};
|
|
26172
|
+
}
|
|
26173
|
+
}
|
|
26174
|
+
try {
|
|
26175
|
+
return {
|
|
26176
|
+
...result,
|
|
26177
|
+
body: JSON.parse(result.body)
|
|
26178
|
+
};
|
|
26179
|
+
} catch {
|
|
26180
|
+
return result;
|
|
26181
|
+
}
|
|
26285
26182
|
}
|
|
26286
26183
|
/**
|
|
26287
26184
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
@@ -26320,7 +26217,15 @@ var WorkflowContext = class {
|
|
|
26320
26217
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
26321
26218
|
const { timeout = "7d" } = options;
|
|
26322
26219
|
const timeoutStr = typeof timeout === "string" ? timeout : `${timeout}s`;
|
|
26323
|
-
|
|
26220
|
+
const result = await this.addStep(new LazyWaitForEventStep(stepName, eventId, timeoutStr));
|
|
26221
|
+
try {
|
|
26222
|
+
return {
|
|
26223
|
+
...result,
|
|
26224
|
+
eventData: JSON.parse(result.eventData)
|
|
26225
|
+
};
|
|
26226
|
+
} catch {
|
|
26227
|
+
return result;
|
|
26228
|
+
}
|
|
26324
26229
|
}
|
|
26325
26230
|
/**
|
|
26326
26231
|
* Notify workflow runs waiting for an event
|
|
@@ -26344,12 +26249,24 @@ var WorkflowContext = class {
|
|
|
26344
26249
|
* @returns notify response which has event id, event data and list of waiters which were notified
|
|
26345
26250
|
*/
|
|
26346
26251
|
async notify(stepName, eventId, eventData) {
|
|
26347
|
-
|
|
26252
|
+
const result = await this.addStep(
|
|
26348
26253
|
new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
|
|
26349
26254
|
);
|
|
26255
|
+
try {
|
|
26256
|
+
return {
|
|
26257
|
+
...result,
|
|
26258
|
+
eventData: JSON.parse(result.eventData)
|
|
26259
|
+
};
|
|
26260
|
+
} catch {
|
|
26261
|
+
return result;
|
|
26262
|
+
}
|
|
26350
26263
|
}
|
|
26351
26264
|
async invoke(stepName, settings) {
|
|
26352
|
-
|
|
26265
|
+
const result = await this.addStep(new LazyInvokeStep(stepName, settings));
|
|
26266
|
+
return {
|
|
26267
|
+
...result,
|
|
26268
|
+
body: result.body ? JSON.parse(result.body) : void 0
|
|
26269
|
+
};
|
|
26353
26270
|
}
|
|
26354
26271
|
/**
|
|
26355
26272
|
* Cancel the current workflow run
|
|
@@ -26508,6 +26425,10 @@ var processRawSteps = (rawSteps) => {
|
|
|
26508
26425
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
26509
26426
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
26510
26427
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
26428
|
+
try {
|
|
26429
|
+
step.out = JSON.parse(step.out);
|
|
26430
|
+
} catch {
|
|
26431
|
+
}
|
|
26511
26432
|
if (step.waitEventId) {
|
|
26512
26433
|
const newOut = {
|
|
26513
26434
|
eventData: step.out ? decodeBase64(step.out) : void 0,
|
package/express.mjs
CHANGED
package/h3.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-CYhDXnf8.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-BVDpPsF-.mjs';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|
package/h3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-CYhDXnf8.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-e4zufyXN.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|