@upstash/workflow 0.1.3-crpyto-canary-2 → 0.1.3
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 +1 -1
- package/astro.d.ts +1 -1
- package/astro.js +217 -203
- package/astro.mjs +1 -1
- package/{chunk-3FILROVK.mjs → chunk-35GJPVE2.mjs} +275 -209
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +217 -203
- package/cloudflare.mjs +1 -1
- package/express.d.mts +1 -1
- package/express.d.ts +1 -1
- package/express.js +217 -203
- package/express.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +217 -203
- package/h3.mjs +1 -1
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +217 -203
- package/hono.mjs +1 -1
- package/index.d.mts +39 -2
- package/index.d.ts +39 -2
- package/index.js +276 -210
- package/index.mjs +1 -1
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +218 -205
- package/nextjs.mjs +2 -3
- package/package.json +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +217 -203
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +217 -203
- package/svelte.mjs +1 -1
- package/{types-CI-2skYU.d.mts → types-CQuc-j8n.d.mts} +14 -9
- package/{types-CI-2skYU.d.ts → types-CQuc-j8n.d.ts} +14 -9
package/express.js
CHANGED
|
@@ -23577,6 +23577,190 @@ var formatWorkflowError = (error) => {
|
|
|
23577
23577
|
};
|
|
23578
23578
|
};
|
|
23579
23579
|
|
|
23580
|
+
// src/client/utils.ts
|
|
23581
|
+
var makeNotifyRequest = async (requester, eventId, eventData) => {
|
|
23582
|
+
const result = await requester.request({
|
|
23583
|
+
path: ["v2", "notify", eventId],
|
|
23584
|
+
method: "POST",
|
|
23585
|
+
body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
|
|
23586
|
+
});
|
|
23587
|
+
return result;
|
|
23588
|
+
};
|
|
23589
|
+
|
|
23590
|
+
// src/context/steps.ts
|
|
23591
|
+
var BaseLazyStep = class {
|
|
23592
|
+
stepName;
|
|
23593
|
+
// will be set in the subclasses
|
|
23594
|
+
constructor(stepName) {
|
|
23595
|
+
this.stepName = stepName;
|
|
23596
|
+
}
|
|
23597
|
+
};
|
|
23598
|
+
var LazyFunctionStep = class extends BaseLazyStep {
|
|
23599
|
+
stepFunction;
|
|
23600
|
+
stepType = "Run";
|
|
23601
|
+
constructor(stepName, stepFunction) {
|
|
23602
|
+
super(stepName);
|
|
23603
|
+
this.stepFunction = stepFunction;
|
|
23604
|
+
}
|
|
23605
|
+
getPlanStep(concurrent, targetStep) {
|
|
23606
|
+
return {
|
|
23607
|
+
stepId: 0,
|
|
23608
|
+
stepName: this.stepName,
|
|
23609
|
+
stepType: this.stepType,
|
|
23610
|
+
concurrent,
|
|
23611
|
+
targetStep
|
|
23612
|
+
};
|
|
23613
|
+
}
|
|
23614
|
+
async getResultStep(concurrent, stepId) {
|
|
23615
|
+
let result = this.stepFunction();
|
|
23616
|
+
if (result instanceof Promise) {
|
|
23617
|
+
result = await result;
|
|
23618
|
+
}
|
|
23619
|
+
return {
|
|
23620
|
+
stepId,
|
|
23621
|
+
stepName: this.stepName,
|
|
23622
|
+
stepType: this.stepType,
|
|
23623
|
+
out: result,
|
|
23624
|
+
concurrent
|
|
23625
|
+
};
|
|
23626
|
+
}
|
|
23627
|
+
};
|
|
23628
|
+
var LazySleepStep = class extends BaseLazyStep {
|
|
23629
|
+
sleep;
|
|
23630
|
+
stepType = "SleepFor";
|
|
23631
|
+
constructor(stepName, sleep) {
|
|
23632
|
+
super(stepName);
|
|
23633
|
+
this.sleep = sleep;
|
|
23634
|
+
}
|
|
23635
|
+
getPlanStep(concurrent, targetStep) {
|
|
23636
|
+
return {
|
|
23637
|
+
stepId: 0,
|
|
23638
|
+
stepName: this.stepName,
|
|
23639
|
+
stepType: this.stepType,
|
|
23640
|
+
sleepFor: this.sleep,
|
|
23641
|
+
concurrent,
|
|
23642
|
+
targetStep
|
|
23643
|
+
};
|
|
23644
|
+
}
|
|
23645
|
+
async getResultStep(concurrent, stepId) {
|
|
23646
|
+
return await Promise.resolve({
|
|
23647
|
+
stepId,
|
|
23648
|
+
stepName: this.stepName,
|
|
23649
|
+
stepType: this.stepType,
|
|
23650
|
+
sleepFor: this.sleep,
|
|
23651
|
+
concurrent
|
|
23652
|
+
});
|
|
23653
|
+
}
|
|
23654
|
+
};
|
|
23655
|
+
var LazySleepUntilStep = class extends BaseLazyStep {
|
|
23656
|
+
sleepUntil;
|
|
23657
|
+
stepType = "SleepUntil";
|
|
23658
|
+
constructor(stepName, sleepUntil) {
|
|
23659
|
+
super(stepName);
|
|
23660
|
+
this.sleepUntil = sleepUntil;
|
|
23661
|
+
}
|
|
23662
|
+
getPlanStep(concurrent, targetStep) {
|
|
23663
|
+
return {
|
|
23664
|
+
stepId: 0,
|
|
23665
|
+
stepName: this.stepName,
|
|
23666
|
+
stepType: this.stepType,
|
|
23667
|
+
sleepUntil: this.sleepUntil,
|
|
23668
|
+
concurrent,
|
|
23669
|
+
targetStep
|
|
23670
|
+
};
|
|
23671
|
+
}
|
|
23672
|
+
async getResultStep(concurrent, stepId) {
|
|
23673
|
+
return await Promise.resolve({
|
|
23674
|
+
stepId,
|
|
23675
|
+
stepName: this.stepName,
|
|
23676
|
+
stepType: this.stepType,
|
|
23677
|
+
sleepUntil: this.sleepUntil,
|
|
23678
|
+
concurrent
|
|
23679
|
+
});
|
|
23680
|
+
}
|
|
23681
|
+
};
|
|
23682
|
+
var LazyCallStep = class extends BaseLazyStep {
|
|
23683
|
+
url;
|
|
23684
|
+
method;
|
|
23685
|
+
body;
|
|
23686
|
+
headers;
|
|
23687
|
+
stepType = "Call";
|
|
23688
|
+
retries;
|
|
23689
|
+
constructor(stepName, url, method, body, headers, retries) {
|
|
23690
|
+
super(stepName);
|
|
23691
|
+
this.url = url;
|
|
23692
|
+
this.method = method;
|
|
23693
|
+
this.body = body;
|
|
23694
|
+
this.headers = headers;
|
|
23695
|
+
this.retries = retries;
|
|
23696
|
+
}
|
|
23697
|
+
getPlanStep(concurrent, targetStep) {
|
|
23698
|
+
return {
|
|
23699
|
+
stepId: 0,
|
|
23700
|
+
stepName: this.stepName,
|
|
23701
|
+
stepType: this.stepType,
|
|
23702
|
+
concurrent,
|
|
23703
|
+
targetStep
|
|
23704
|
+
};
|
|
23705
|
+
}
|
|
23706
|
+
async getResultStep(concurrent, stepId) {
|
|
23707
|
+
return await Promise.resolve({
|
|
23708
|
+
stepId,
|
|
23709
|
+
stepName: this.stepName,
|
|
23710
|
+
stepType: this.stepType,
|
|
23711
|
+
concurrent,
|
|
23712
|
+
callUrl: this.url,
|
|
23713
|
+
callMethod: this.method,
|
|
23714
|
+
callBody: this.body,
|
|
23715
|
+
callHeaders: this.headers
|
|
23716
|
+
});
|
|
23717
|
+
}
|
|
23718
|
+
};
|
|
23719
|
+
var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
23720
|
+
eventId;
|
|
23721
|
+
timeout;
|
|
23722
|
+
stepType = "Wait";
|
|
23723
|
+
constructor(stepName, eventId, timeout) {
|
|
23724
|
+
super(stepName);
|
|
23725
|
+
this.eventId = eventId;
|
|
23726
|
+
this.timeout = timeout;
|
|
23727
|
+
}
|
|
23728
|
+
getPlanStep(concurrent, targetStep) {
|
|
23729
|
+
return {
|
|
23730
|
+
stepId: 0,
|
|
23731
|
+
stepName: this.stepName,
|
|
23732
|
+
stepType: this.stepType,
|
|
23733
|
+
waitEventId: this.eventId,
|
|
23734
|
+
timeout: this.timeout,
|
|
23735
|
+
concurrent,
|
|
23736
|
+
targetStep
|
|
23737
|
+
};
|
|
23738
|
+
}
|
|
23739
|
+
async getResultStep(concurrent, stepId) {
|
|
23740
|
+
return await Promise.resolve({
|
|
23741
|
+
stepId,
|
|
23742
|
+
stepName: this.stepName,
|
|
23743
|
+
stepType: this.stepType,
|
|
23744
|
+
waitEventId: this.eventId,
|
|
23745
|
+
timeout: this.timeout,
|
|
23746
|
+
concurrent
|
|
23747
|
+
});
|
|
23748
|
+
}
|
|
23749
|
+
};
|
|
23750
|
+
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
23751
|
+
stepType = "Notify";
|
|
23752
|
+
constructor(stepName, eventId, eventData, requester) {
|
|
23753
|
+
super(stepName, async () => {
|
|
23754
|
+
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
|
|
23755
|
+
return {
|
|
23756
|
+
eventId,
|
|
23757
|
+
eventData,
|
|
23758
|
+
notifyResponse
|
|
23759
|
+
};
|
|
23760
|
+
});
|
|
23761
|
+
}
|
|
23762
|
+
};
|
|
23763
|
+
|
|
23580
23764
|
// node_modules/neverthrow/dist/index.es.js
|
|
23581
23765
|
var defaultErrorConfig = {
|
|
23582
23766
|
withStackTrace: false
|
|
@@ -24032,10 +24216,11 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
24032
24216
|
url: workflowContext.url
|
|
24033
24217
|
});
|
|
24034
24218
|
try {
|
|
24035
|
-
|
|
24219
|
+
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
24220
|
+
await workflowContext.qstashClient.publish({
|
|
24036
24221
|
headers,
|
|
24037
24222
|
method: "POST",
|
|
24038
|
-
body
|
|
24223
|
+
body,
|
|
24039
24224
|
url: workflowContext.url
|
|
24040
24225
|
});
|
|
24041
24226
|
return ok("success");
|
|
@@ -24161,7 +24346,7 @@ ${atob(callbackMessage.body)}`
|
|
|
24161
24346
|
);
|
|
24162
24347
|
}
|
|
24163
24348
|
};
|
|
24164
|
-
var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step, failureUrl, retries) => {
|
|
24349
|
+
var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step, failureUrl, retries, callRetries) => {
|
|
24165
24350
|
const baseHeaders = {
|
|
24166
24351
|
[WORKFLOW_INIT_HEADER]: initHeaderValue,
|
|
24167
24352
|
[WORKFLOW_ID_HEADER]: workflowRunId,
|
|
@@ -24177,7 +24362,7 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
24177
24362
|
baseHeaders["Upstash-Failure-Callback"] = failureUrl;
|
|
24178
24363
|
}
|
|
24179
24364
|
if (step?.callUrl) {
|
|
24180
|
-
baseHeaders["Upstash-Retries"] = "0";
|
|
24365
|
+
baseHeaders["Upstash-Retries"] = callRetries?.toString() ?? "0";
|
|
24181
24366
|
baseHeaders[WORKFLOW_FEATURE_HEADER] = "WF_NoDelete";
|
|
24182
24367
|
if (retries) {
|
|
24183
24368
|
baseHeaders["Upstash-Callback-Retries"] = retries.toString();
|
|
@@ -24185,6 +24370,7 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
24185
24370
|
}
|
|
24186
24371
|
} else if (retries !== void 0) {
|
|
24187
24372
|
baseHeaders["Upstash-Retries"] = retries.toString();
|
|
24373
|
+
baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
|
|
24188
24374
|
}
|
|
24189
24375
|
if (userHeaders) {
|
|
24190
24376
|
for (const header of userHeaders.keys()) {
|
|
@@ -24193,6 +24379,7 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
|
|
|
24193
24379
|
} else {
|
|
24194
24380
|
baseHeaders[`Upstash-Forward-${header}`] = userHeaders.get(header);
|
|
24195
24381
|
}
|
|
24382
|
+
baseHeaders[`Upstash-Failure-Callback-Forward-${header}`] = userHeaders.get(header);
|
|
24196
24383
|
}
|
|
24197
24384
|
}
|
|
24198
24385
|
const contentType = (userHeaders ? userHeaders.get("Content-Type") : void 0) ?? DEFAULT_CONTENT_TYPE;
|
|
@@ -24376,7 +24563,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24376
24563
|
step: resultStep,
|
|
24377
24564
|
stepCount: this.stepCount
|
|
24378
24565
|
});
|
|
24379
|
-
await this.submitStepsToQStash([resultStep]);
|
|
24566
|
+
await this.submitStepsToQStash([resultStep], [lazyStep]);
|
|
24380
24567
|
return resultStep.out;
|
|
24381
24568
|
}
|
|
24382
24569
|
/**
|
|
@@ -24408,7 +24595,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24408
24595
|
const planSteps = parallelSteps.map(
|
|
24409
24596
|
(parallelStep, index) => parallelStep.getPlanStep(parallelSteps.length, initialStepCount + index)
|
|
24410
24597
|
);
|
|
24411
|
-
await this.submitStepsToQStash(planSteps);
|
|
24598
|
+
await this.submitStepsToQStash(planSteps, parallelSteps);
|
|
24412
24599
|
break;
|
|
24413
24600
|
}
|
|
24414
24601
|
case "partial": {
|
|
@@ -24421,11 +24608,12 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24421
24608
|
const stepIndex = planStep.targetStep - initialStepCount;
|
|
24422
24609
|
validateStep(parallelSteps[stepIndex], planStep);
|
|
24423
24610
|
try {
|
|
24424
|
-
const
|
|
24611
|
+
const parallelStep = parallelSteps[stepIndex];
|
|
24612
|
+
const resultStep = await parallelStep.getResultStep(
|
|
24425
24613
|
parallelSteps.length,
|
|
24426
24614
|
planStep.targetStep
|
|
24427
24615
|
);
|
|
24428
|
-
await this.submitStepsToQStash([resultStep]);
|
|
24616
|
+
await this.submitStepsToQStash([resultStep], [parallelStep]);
|
|
24429
24617
|
} catch (error) {
|
|
24430
24618
|
if (error instanceof QStashWorkflowAbort) {
|
|
24431
24619
|
throw error;
|
|
@@ -24486,7 +24674,7 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24486
24674
|
*
|
|
24487
24675
|
* @param steps steps to send
|
|
24488
24676
|
*/
|
|
24489
|
-
async submitStepsToQStash(steps) {
|
|
24677
|
+
async submitStepsToQStash(steps, lazySteps) {
|
|
24490
24678
|
if (steps.length === 0) {
|
|
24491
24679
|
throw new QStashWorkflowError(
|
|
24492
24680
|
`Unable to submit steps to QStash. Provided list is empty. Current step: ${this.stepCount}`
|
|
@@ -24531,7 +24719,8 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24531
24719
|
throw new QStashWorkflowAbort(steps[0].stepName, steps[0]);
|
|
24532
24720
|
}
|
|
24533
24721
|
const result = await this.context.qstashClient.batchJSON(
|
|
24534
|
-
steps.map((singleStep) => {
|
|
24722
|
+
steps.map((singleStep, index) => {
|
|
24723
|
+
const lazyStep = lazySteps[index];
|
|
24535
24724
|
const { headers } = getHeaders(
|
|
24536
24725
|
"false",
|
|
24537
24726
|
this.context.workflowRunId,
|
|
@@ -24539,7 +24728,8 @@ var AutoExecutor = class _AutoExecutor {
|
|
|
24539
24728
|
this.context.headers,
|
|
24540
24729
|
singleStep,
|
|
24541
24730
|
this.context.failureUrl,
|
|
24542
|
-
this.context.retries
|
|
24731
|
+
this.context.retries,
|
|
24732
|
+
lazyStep instanceof LazyCallStep ? lazyStep.retries : void 0
|
|
24543
24733
|
);
|
|
24544
24734
|
const willWait = singleStep.concurrent === NO_CONCURRENCY || singleStep.stepId === 0;
|
|
24545
24735
|
singleStep.out = JSON.stringify(singleStep.out);
|
|
@@ -24652,188 +24842,6 @@ var sortSteps = (steps) => {
|
|
|
24652
24842
|
return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
|
|
24653
24843
|
};
|
|
24654
24844
|
|
|
24655
|
-
// src/client/utils.ts
|
|
24656
|
-
var makeNotifyRequest = async (requester, eventId, eventData) => {
|
|
24657
|
-
const result = await requester.request({
|
|
24658
|
-
path: ["v2", "notify", eventId],
|
|
24659
|
-
method: "POST",
|
|
24660
|
-
body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
|
|
24661
|
-
});
|
|
24662
|
-
return result;
|
|
24663
|
-
};
|
|
24664
|
-
|
|
24665
|
-
// src/context/steps.ts
|
|
24666
|
-
var BaseLazyStep = class {
|
|
24667
|
-
stepName;
|
|
24668
|
-
// will be set in the subclasses
|
|
24669
|
-
constructor(stepName) {
|
|
24670
|
-
this.stepName = stepName;
|
|
24671
|
-
}
|
|
24672
|
-
};
|
|
24673
|
-
var LazyFunctionStep = class extends BaseLazyStep {
|
|
24674
|
-
stepFunction;
|
|
24675
|
-
stepType = "Run";
|
|
24676
|
-
constructor(stepName, stepFunction) {
|
|
24677
|
-
super(stepName);
|
|
24678
|
-
this.stepFunction = stepFunction;
|
|
24679
|
-
}
|
|
24680
|
-
getPlanStep(concurrent, targetStep) {
|
|
24681
|
-
return {
|
|
24682
|
-
stepId: 0,
|
|
24683
|
-
stepName: this.stepName,
|
|
24684
|
-
stepType: this.stepType,
|
|
24685
|
-
concurrent,
|
|
24686
|
-
targetStep
|
|
24687
|
-
};
|
|
24688
|
-
}
|
|
24689
|
-
async getResultStep(concurrent, stepId) {
|
|
24690
|
-
let result = this.stepFunction();
|
|
24691
|
-
if (result instanceof Promise) {
|
|
24692
|
-
result = await result;
|
|
24693
|
-
}
|
|
24694
|
-
return {
|
|
24695
|
-
stepId,
|
|
24696
|
-
stepName: this.stepName,
|
|
24697
|
-
stepType: this.stepType,
|
|
24698
|
-
out: result,
|
|
24699
|
-
concurrent
|
|
24700
|
-
};
|
|
24701
|
-
}
|
|
24702
|
-
};
|
|
24703
|
-
var LazySleepStep = class extends BaseLazyStep {
|
|
24704
|
-
sleep;
|
|
24705
|
-
stepType = "SleepFor";
|
|
24706
|
-
constructor(stepName, sleep) {
|
|
24707
|
-
super(stepName);
|
|
24708
|
-
this.sleep = sleep;
|
|
24709
|
-
}
|
|
24710
|
-
getPlanStep(concurrent, targetStep) {
|
|
24711
|
-
return {
|
|
24712
|
-
stepId: 0,
|
|
24713
|
-
stepName: this.stepName,
|
|
24714
|
-
stepType: this.stepType,
|
|
24715
|
-
sleepFor: this.sleep,
|
|
24716
|
-
concurrent,
|
|
24717
|
-
targetStep
|
|
24718
|
-
};
|
|
24719
|
-
}
|
|
24720
|
-
async getResultStep(concurrent, stepId) {
|
|
24721
|
-
return await Promise.resolve({
|
|
24722
|
-
stepId,
|
|
24723
|
-
stepName: this.stepName,
|
|
24724
|
-
stepType: this.stepType,
|
|
24725
|
-
sleepFor: this.sleep,
|
|
24726
|
-
concurrent
|
|
24727
|
-
});
|
|
24728
|
-
}
|
|
24729
|
-
};
|
|
24730
|
-
var LazySleepUntilStep = class extends BaseLazyStep {
|
|
24731
|
-
sleepUntil;
|
|
24732
|
-
stepType = "SleepUntil";
|
|
24733
|
-
constructor(stepName, sleepUntil) {
|
|
24734
|
-
super(stepName);
|
|
24735
|
-
this.sleepUntil = sleepUntil;
|
|
24736
|
-
}
|
|
24737
|
-
getPlanStep(concurrent, targetStep) {
|
|
24738
|
-
return {
|
|
24739
|
-
stepId: 0,
|
|
24740
|
-
stepName: this.stepName,
|
|
24741
|
-
stepType: this.stepType,
|
|
24742
|
-
sleepUntil: this.sleepUntil,
|
|
24743
|
-
concurrent,
|
|
24744
|
-
targetStep
|
|
24745
|
-
};
|
|
24746
|
-
}
|
|
24747
|
-
async getResultStep(concurrent, stepId) {
|
|
24748
|
-
return await Promise.resolve({
|
|
24749
|
-
stepId,
|
|
24750
|
-
stepName: this.stepName,
|
|
24751
|
-
stepType: this.stepType,
|
|
24752
|
-
sleepUntil: this.sleepUntil,
|
|
24753
|
-
concurrent
|
|
24754
|
-
});
|
|
24755
|
-
}
|
|
24756
|
-
};
|
|
24757
|
-
var LazyCallStep = class extends BaseLazyStep {
|
|
24758
|
-
url;
|
|
24759
|
-
method;
|
|
24760
|
-
body;
|
|
24761
|
-
headers;
|
|
24762
|
-
stepType = "Call";
|
|
24763
|
-
constructor(stepName, url, method, body, headers) {
|
|
24764
|
-
super(stepName);
|
|
24765
|
-
this.url = url;
|
|
24766
|
-
this.method = method;
|
|
24767
|
-
this.body = body;
|
|
24768
|
-
this.headers = headers;
|
|
24769
|
-
}
|
|
24770
|
-
getPlanStep(concurrent, targetStep) {
|
|
24771
|
-
return {
|
|
24772
|
-
stepId: 0,
|
|
24773
|
-
stepName: this.stepName,
|
|
24774
|
-
stepType: this.stepType,
|
|
24775
|
-
concurrent,
|
|
24776
|
-
targetStep
|
|
24777
|
-
};
|
|
24778
|
-
}
|
|
24779
|
-
async getResultStep(concurrent, stepId) {
|
|
24780
|
-
return await Promise.resolve({
|
|
24781
|
-
stepId,
|
|
24782
|
-
stepName: this.stepName,
|
|
24783
|
-
stepType: this.stepType,
|
|
24784
|
-
concurrent,
|
|
24785
|
-
callUrl: this.url,
|
|
24786
|
-
callMethod: this.method,
|
|
24787
|
-
callBody: this.body,
|
|
24788
|
-
callHeaders: this.headers
|
|
24789
|
-
});
|
|
24790
|
-
}
|
|
24791
|
-
};
|
|
24792
|
-
var LazyWaitForEventStep = class extends BaseLazyStep {
|
|
24793
|
-
eventId;
|
|
24794
|
-
timeout;
|
|
24795
|
-
stepType = "Wait";
|
|
24796
|
-
constructor(stepName, eventId, timeout) {
|
|
24797
|
-
super(stepName);
|
|
24798
|
-
this.eventId = eventId;
|
|
24799
|
-
this.timeout = timeout;
|
|
24800
|
-
}
|
|
24801
|
-
getPlanStep(concurrent, targetStep) {
|
|
24802
|
-
return {
|
|
24803
|
-
stepId: 0,
|
|
24804
|
-
stepName: this.stepName,
|
|
24805
|
-
stepType: this.stepType,
|
|
24806
|
-
waitEventId: this.eventId,
|
|
24807
|
-
timeout: this.timeout,
|
|
24808
|
-
concurrent,
|
|
24809
|
-
targetStep
|
|
24810
|
-
};
|
|
24811
|
-
}
|
|
24812
|
-
async getResultStep(concurrent, stepId) {
|
|
24813
|
-
return await Promise.resolve({
|
|
24814
|
-
stepId,
|
|
24815
|
-
stepName: this.stepName,
|
|
24816
|
-
stepType: this.stepType,
|
|
24817
|
-
waitEventId: this.eventId,
|
|
24818
|
-
timeout: this.timeout,
|
|
24819
|
-
concurrent
|
|
24820
|
-
});
|
|
24821
|
-
}
|
|
24822
|
-
};
|
|
24823
|
-
var LazyNotifyStep = class extends LazyFunctionStep {
|
|
24824
|
-
stepType = "Notify";
|
|
24825
|
-
constructor(stepName, eventId, eventData, requester) {
|
|
24826
|
-
super(stepName, async () => {
|
|
24827
|
-
const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
|
|
24828
|
-
return {
|
|
24829
|
-
eventId,
|
|
24830
|
-
eventData,
|
|
24831
|
-
notifyResponse
|
|
24832
|
-
};
|
|
24833
|
-
});
|
|
24834
|
-
}
|
|
24835
|
-
};
|
|
24836
|
-
|
|
24837
24845
|
// src/context/context.ts
|
|
24838
24846
|
var WorkflowContext = class {
|
|
24839
24847
|
executor;
|
|
@@ -25049,11 +25057,13 @@ var WorkflowContext = class {
|
|
|
25049
25057
|
* network call without consuming any runtime.
|
|
25050
25058
|
*
|
|
25051
25059
|
* ```ts
|
|
25052
|
-
* const
|
|
25060
|
+
* const { status, body } = await context.call<string>(
|
|
25053
25061
|
* "post call step",
|
|
25054
|
-
*
|
|
25055
|
-
*
|
|
25056
|
-
*
|
|
25062
|
+
* {
|
|
25063
|
+
* url: `https://www.some-endpoint.com/api`,
|
|
25064
|
+
* method: "POST",
|
|
25065
|
+
* body: "my-payload"
|
|
25066
|
+
* }
|
|
25057
25067
|
* );
|
|
25058
25068
|
* ```
|
|
25059
25069
|
*
|
|
@@ -25063,9 +25073,10 @@ var WorkflowContext = class {
|
|
|
25063
25073
|
*
|
|
25064
25074
|
* @param stepName
|
|
25065
25075
|
* @param url url to call
|
|
25066
|
-
* @param method call method
|
|
25076
|
+
* @param method call method. "GET" by default.
|
|
25067
25077
|
* @param body call body
|
|
25068
25078
|
* @param headers call headers
|
|
25079
|
+
* @param retries number of call retries. 0 by default
|
|
25069
25080
|
* @returns call result as {
|
|
25070
25081
|
* status: number;
|
|
25071
25082
|
* body: unknown;
|
|
@@ -25073,9 +25084,9 @@ var WorkflowContext = class {
|
|
|
25073
25084
|
* }
|
|
25074
25085
|
*/
|
|
25075
25086
|
async call(stepName, settings) {
|
|
25076
|
-
const { url, method = "GET", body, headers = {} } = settings;
|
|
25087
|
+
const { url, method = "GET", body, headers = {}, retries = 0 } = settings;
|
|
25077
25088
|
const result = await this.addStep(
|
|
25078
|
-
new LazyCallStep(stepName, url, method, body, headers
|
|
25089
|
+
new LazyCallStep(stepName, url, method, body, headers, retries)
|
|
25079
25090
|
);
|
|
25080
25091
|
if (typeof result === "string") {
|
|
25081
25092
|
try {
|
|
@@ -25222,11 +25233,14 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
25222
25233
|
};
|
|
25223
25234
|
|
|
25224
25235
|
// src/utils.ts
|
|
25225
|
-
var
|
|
25236
|
+
var import_node_crypto = __toESM(require("crypto"));
|
|
25226
25237
|
var NANOID_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
|
|
25227
25238
|
var NANOID_LENGTH = 21;
|
|
25228
25239
|
function nanoid() {
|
|
25229
|
-
return [...
|
|
25240
|
+
return [...import_node_crypto.default.getRandomValues(new Uint8Array(NANOID_LENGTH))].map((x) => NANOID_CHARS[x % NANOID_CHARS.length]).join("");
|
|
25241
|
+
}
|
|
25242
|
+
function getWorkflowRunId(id) {
|
|
25243
|
+
return `wfr_${id ?? nanoid()}`;
|
|
25230
25244
|
}
|
|
25231
25245
|
function decodeBase64(base64) {
|
|
25232
25246
|
try {
|
|
@@ -25332,7 +25346,7 @@ var validateRequest = (request) => {
|
|
|
25332
25346
|
`Incompatible workflow sdk protocol version. Expected ${WORKFLOW_PROTOCOL_VERSION}, got ${versionHeader} from the request.`
|
|
25333
25347
|
);
|
|
25334
25348
|
}
|
|
25335
|
-
const workflowRunId = isFirstInvocation ?
|
|
25349
|
+
const workflowRunId = isFirstInvocation ? getWorkflowRunId() : request.headers.get(WORKFLOW_ID_HEADER) ?? "";
|
|
25336
25350
|
if (workflowRunId.length === 0) {
|
|
25337
25351
|
throw new QStashWorkflowError("Couldn't get workflow id from header");
|
|
25338
25352
|
}
|
package/express.mjs
CHANGED
package/h3.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CQuc-j8n.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|
package/h3.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
|
-
import { R as RouteFunction, W as WorkflowServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CQuc-j8n.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => {
|