@upstash/workflow 0.2.10-hono-generics → 0.2.10-unicode-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 +141 -62
- package/astro.mjs +1 -1
- package/{chunk-IPXJZU3K.mjs → chunk-N2WV5VCD.mjs} +141 -62
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +141 -62
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +141 -62
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +141 -62
- package/h3.mjs +1 -1
- package/hono.d.mts +3 -3
- package/hono.d.ts +3 -3
- package/hono.js +141 -62
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +141 -62
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +141 -62
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-e4zufyXN.d.ts → serve-many-jCRazho9.d.ts} +1 -1
- package/{serve-many-BVDpPsF-.d.mts → serve-many-wMUWrSIP.d.mts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +141 -62
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +141 -62
- package/svelte.mjs +1 -1
- package/{types-CYhDXnf8.d.ts → types-Dg_9L83G.d.mts} +13 -5
- package/{types-CYhDXnf8.d.mts → types-Dg_9L83G.d.ts} +13 -5
package/express.js
CHANGED
|
@@ -23823,22 +23823,21 @@ function getWorkflowRunId(id) {
|
|
|
23823
23823
|
return `wfr_${id ?? nanoid()}`;
|
|
23824
23824
|
}
|
|
23825
23825
|
function decodeBase64(base64) {
|
|
23826
|
+
const binString = atob(base64);
|
|
23826
23827
|
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 binString;
|
|
23835
23835
|
}
|
|
23836
23836
|
}
|
|
23837
23837
|
|
|
23838
23838
|
// src/context/steps.ts
|
|
23839
|
-
var BaseLazyStep = class {
|
|
23839
|
+
var BaseLazyStep = class _BaseLazyStep {
|
|
23840
23840
|
stepName;
|
|
23841
|
-
// will be set in the subclasses
|
|
23842
23841
|
constructor(stepName) {
|
|
23843
23842
|
if (!stepName) {
|
|
23844
23843
|
throw new WorkflowError(
|
|
@@ -23847,10 +23846,58 @@ var BaseLazyStep = class {
|
|
|
23847
23846
|
}
|
|
23848
23847
|
this.stepName = stepName;
|
|
23849
23848
|
}
|
|
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
|
+
}
|
|
23850
23896
|
};
|
|
23851
23897
|
var LazyFunctionStep = class extends BaseLazyStep {
|
|
23852
23898
|
stepFunction;
|
|
23853
23899
|
stepType = "Run";
|
|
23900
|
+
allowUndefinedOut = true;
|
|
23854
23901
|
constructor(stepName, stepFunction) {
|
|
23855
23902
|
super(stepName);
|
|
23856
23903
|
this.stepFunction = stepFunction;
|
|
@@ -23881,6 +23928,7 @@ var LazyFunctionStep = class extends BaseLazyStep {
|
|
|
23881
23928
|
var LazySleepStep = class extends BaseLazyStep {
|
|
23882
23929
|
sleep;
|
|
23883
23930
|
stepType = "SleepFor";
|
|
23931
|
+
allowUndefinedOut = true;
|
|
23884
23932
|
constructor(stepName, sleep) {
|
|
23885
23933
|
super(stepName);
|
|
23886
23934
|
this.sleep = sleep;
|
|
@@ -23908,6 +23956,7 @@ var LazySleepStep = class extends BaseLazyStep {
|
|
|
23908
23956
|
var LazySleepUntilStep = class extends BaseLazyStep {
|
|
23909
23957
|
sleepUntil;
|
|
23910
23958
|
stepType = "SleepUntil";
|
|
23959
|
+
allowUndefinedOut = true;
|
|
23911
23960
|
constructor(stepName, sleepUntil) {
|
|
23912
23961
|
super(stepName);
|
|
23913
23962
|
this.sleepUntil = sleepUntil;
|
|
@@ -23931,8 +23980,11 @@ var LazySleepUntilStep = class extends BaseLazyStep {
|
|
|
23931
23980
|
concurrent
|
|
23932
23981
|
});
|
|
23933
23982
|
}
|
|
23983
|
+
safeParseOut() {
|
|
23984
|
+
return void 0;
|
|
23985
|
+
}
|
|
23934
23986
|
};
|
|
23935
|
-
var LazyCallStep = class extends BaseLazyStep {
|
|
23987
|
+
var LazyCallStep = class _LazyCallStep extends BaseLazyStep {
|
|
23936
23988
|
url;
|
|
23937
23989
|
method;
|
|
23938
23990
|
body;
|
|
@@ -23941,6 +23993,7 @@ var LazyCallStep = class extends BaseLazyStep {
|
|
|
23941
23993
|
timeout;
|
|
23942
23994
|
flowControl;
|
|
23943
23995
|
stepType = "Call";
|
|
23996
|
+
allowUndefinedOut = false;
|
|
23944
23997
|
constructor(stepName, url, method, body, headers, retries, timeout, flowControl) {
|
|
23945
23998
|
super(stepName);
|
|
23946
23999
|
this.url = url;
|
|
@@ -23972,11 +24025,53 @@ var LazyCallStep = class extends BaseLazyStep {
|
|
|
23972
24025
|
callHeaders: this.headers
|
|
23973
24026
|
});
|
|
23974
24027
|
}
|
|
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
|
+
};
|
|
23975
24069
|
};
|
|
23976
24070
|
var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
23977
24071
|
eventId;
|
|
23978
24072
|
timeout;
|
|
23979
24073
|
stepType = "Wait";
|
|
24074
|
+
allowUndefinedOut = false;
|
|
23980
24075
|
constructor(stepName, eventId, timeout) {
|
|
23981
24076
|
super(stepName);
|
|
23982
24077
|
this.eventId = eventId;
|
|
@@ -24003,6 +24098,13 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
|
24003
24098
|
concurrent
|
|
24004
24099
|
});
|
|
24005
24100
|
}
|
|
24101
|
+
safeParseOut(out) {
|
|
24102
|
+
const result = JSON.parse(out);
|
|
24103
|
+
return {
|
|
24104
|
+
...result,
|
|
24105
|
+
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
24106
|
+
};
|
|
24107
|
+
}
|
|
24006
24108
|
};
|
|
24007
24109
|
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
24008
24110
|
stepType = "Notify";
|
|
@@ -24016,10 +24118,18 @@ var LazyNotifyStep = class extends LazyFunctionStep {
|
|
|
24016
24118
|
};
|
|
24017
24119
|
});
|
|
24018
24120
|
}
|
|
24121
|
+
safeParseOut(out) {
|
|
24122
|
+
const result = JSON.parse(out);
|
|
24123
|
+
return {
|
|
24124
|
+
...result,
|
|
24125
|
+
eventData: BaseLazyStep.tryParsing(result.eventData)
|
|
24126
|
+
};
|
|
24127
|
+
}
|
|
24019
24128
|
};
|
|
24020
24129
|
var LazyInvokeStep = class extends BaseLazyStep {
|
|
24021
24130
|
stepType = "Invoke";
|
|
24022
24131
|
params;
|
|
24132
|
+
allowUndefinedOut = false;
|
|
24023
24133
|
constructor(stepName, {
|
|
24024
24134
|
workflow,
|
|
24025
24135
|
body,
|
|
@@ -24059,6 +24169,13 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
24059
24169
|
concurrent
|
|
24060
24170
|
});
|
|
24061
24171
|
}
|
|
24172
|
+
safeParseOut(out) {
|
|
24173
|
+
const result = JSON.parse(out);
|
|
24174
|
+
return {
|
|
24175
|
+
...result,
|
|
24176
|
+
body: BaseLazyStep.tryParsing(result.body)
|
|
24177
|
+
};
|
|
24178
|
+
}
|
|
24062
24179
|
};
|
|
24063
24180
|
|
|
24064
24181
|
// node_modules/neverthrow/dist/index.es.js
|
|
@@ -25155,7 +25272,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
25155
25272
|
step,
|
|
25156
25273
|
stepCount: this.stepCount
|
|
25157
25274
|
});
|
|
25158
|
-
return step.out;
|
|
25275
|
+
return lazyStep.parseOut(step.out);
|
|
25159
25276
|
}
|
|
25160
25277
|
const resultStep = await lazyStep.getResultStep(NO_CONCURRENCY, this.stepCount);
|
|
25161
25278
|
await this.debug?.log("INFO", "RUN_SINGLE", {
|
|
@@ -25230,7 +25347,9 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
25230
25347
|
case "last": {
|
|
25231
25348
|
const parallelResultSteps = sortedSteps.filter((step) => step.stepId >= initialStepCount).slice(0, parallelSteps.length);
|
|
25232
25349
|
validateParallelSteps(parallelSteps, parallelResultSteps);
|
|
25233
|
-
return parallelResultSteps.map(
|
|
25350
|
+
return parallelResultSteps.map(
|
|
25351
|
+
(step, index) => parallelSteps[index].parseOut(step.out)
|
|
25352
|
+
);
|
|
25234
25353
|
}
|
|
25235
25354
|
}
|
|
25236
25355
|
const fillValue = void 0;
|
|
@@ -26071,7 +26190,7 @@ var WorkflowContext = class {
|
|
|
26071
26190
|
*/
|
|
26072
26191
|
async run(stepName, stepFunction) {
|
|
26073
26192
|
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
26074
|
-
return this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
26193
|
+
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
26075
26194
|
}
|
|
26076
26195
|
/**
|
|
26077
26196
|
* Stops the execution for the duration provided.
|
|
@@ -26142,43 +26261,27 @@ var WorkflowContext = class {
|
|
|
26142
26261
|
* }
|
|
26143
26262
|
*/
|
|
26144
26263
|
async call(stepName, settings) {
|
|
26145
|
-
const {
|
|
26146
|
-
|
|
26264
|
+
const {
|
|
26265
|
+
url,
|
|
26266
|
+
method = "GET",
|
|
26267
|
+
body: requestBody,
|
|
26268
|
+
headers = {},
|
|
26269
|
+
retries = 0,
|
|
26270
|
+
timeout,
|
|
26271
|
+
flowControl
|
|
26272
|
+
} = settings;
|
|
26273
|
+
return await this.addStep(
|
|
26147
26274
|
new LazyCallStep(
|
|
26148
26275
|
stepName,
|
|
26149
26276
|
url,
|
|
26150
26277
|
method,
|
|
26151
|
-
|
|
26278
|
+
requestBody,
|
|
26152
26279
|
headers,
|
|
26153
26280
|
retries,
|
|
26154
26281
|
timeout,
|
|
26155
26282
|
flowControl
|
|
26156
26283
|
)
|
|
26157
26284
|
);
|
|
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
|
-
}
|
|
26182
26285
|
}
|
|
26183
26286
|
/**
|
|
26184
26287
|
* Pauses workflow execution until a specific event occurs or a timeout is reached.
|
|
@@ -26217,15 +26320,7 @@ var WorkflowContext = class {
|
|
|
26217
26320
|
async waitForEvent(stepName, eventId, options = {}) {
|
|
26218
26321
|
const { timeout = "7d" } = options;
|
|
26219
26322
|
const timeoutStr = typeof timeout === "string" ? timeout : `${timeout}s`;
|
|
26220
|
-
|
|
26221
|
-
try {
|
|
26222
|
-
return {
|
|
26223
|
-
...result,
|
|
26224
|
-
eventData: JSON.parse(result.eventData)
|
|
26225
|
-
};
|
|
26226
|
-
} catch {
|
|
26227
|
-
return result;
|
|
26228
|
-
}
|
|
26323
|
+
return await this.addStep(new LazyWaitForEventStep(stepName, eventId, timeoutStr));
|
|
26229
26324
|
}
|
|
26230
26325
|
/**
|
|
26231
26326
|
* Notify workflow runs waiting for an event
|
|
@@ -26249,24 +26344,12 @@ var WorkflowContext = class {
|
|
|
26249
26344
|
* @returns notify response which has event id, event data and list of waiters which were notified
|
|
26250
26345
|
*/
|
|
26251
26346
|
async notify(stepName, eventId, eventData) {
|
|
26252
|
-
|
|
26347
|
+
return await this.addStep(
|
|
26253
26348
|
new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
|
|
26254
26349
|
);
|
|
26255
|
-
try {
|
|
26256
|
-
return {
|
|
26257
|
-
...result,
|
|
26258
|
-
eventData: JSON.parse(result.eventData)
|
|
26259
|
-
};
|
|
26260
|
-
} catch {
|
|
26261
|
-
return result;
|
|
26262
|
-
}
|
|
26263
26350
|
}
|
|
26264
26351
|
async invoke(stepName, settings) {
|
|
26265
|
-
|
|
26266
|
-
return {
|
|
26267
|
-
...result,
|
|
26268
|
-
body: result.body ? JSON.parse(result.body) : void 0
|
|
26269
|
-
};
|
|
26352
|
+
return await this.addStep(new LazyInvokeStep(stepName, settings));
|
|
26270
26353
|
}
|
|
26271
26354
|
/**
|
|
26272
26355
|
* Cancel the current workflow run
|
|
@@ -26425,10 +26508,6 @@ var processRawSteps = (rawSteps) => {
|
|
|
26425
26508
|
const stepsToDecode = encodedSteps.filter((step) => step.callType === "step");
|
|
26426
26509
|
const otherSteps = stepsToDecode.map((rawStep) => {
|
|
26427
26510
|
const step = JSON.parse(decodeBase64(rawStep.body));
|
|
26428
|
-
try {
|
|
26429
|
-
step.out = JSON.parse(step.out);
|
|
26430
|
-
} catch {
|
|
26431
|
-
}
|
|
26432
26511
|
if (step.waitEventId) {
|
|
26433
26512
|
const newOut = {
|
|
26434
26513
|
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-Dg_9L83G.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-wMUWrSIP.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-Dg_9L83G.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-jCRazho9.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|