@upstash/workflow 0.2.14 → 0.2.15
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 +27 -5
- package/astro.mjs +1 -1
- package/{chunk-RMS2NQ3K.mjs → chunk-AC5CQCN3.mjs} +29 -5
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +27 -5
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +27 -5
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +27 -5
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +27 -5
- package/hono.mjs +1 -1
- package/index.d.mts +159 -34
- package/index.d.ts +159 -34
- package/index.js +114 -9
- package/index.mjs +90 -5
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +27 -5
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-BF71QZHQ.d.mts → serve-many-AFwJPR3S.d.mts} +1 -1
- package/{serve-many-BMlN2PAB.d.ts → serve-many-AaKSQyi7.d.ts} +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +27 -5
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +27 -5
- package/svelte.mjs +1 -1
- package/{types-C1WIgVLA.d.ts → types-Dd-3bPoU.d.mts} +39 -4
- package/{types-C1WIgVLA.d.mts → types-Dd-3bPoU.d.ts} +39 -4
package/hono.js
CHANGED
|
@@ -91,7 +91,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
91
91
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
92
92
|
var NO_CONCURRENCY = 1;
|
|
93
93
|
var DEFAULT_RETRIES = 3;
|
|
94
|
-
var VERSION = "v0.2.
|
|
94
|
+
var VERSION = "v0.2.15";
|
|
95
95
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
96
96
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
97
97
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -129,6 +129,16 @@ var WorkflowAbort = class extends Error {
|
|
|
129
129
|
this.cancelWorkflow = cancelWorkflow;
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
+
var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
133
|
+
/**
|
|
134
|
+
* @param message error message to be displayed
|
|
135
|
+
*/
|
|
136
|
+
constructor(message) {
|
|
137
|
+
super("fail", void 0, false);
|
|
138
|
+
this.name = "WorkflowNonRetryableError";
|
|
139
|
+
if (message) this.message = message;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
132
142
|
var formatWorkflowError = (error) => {
|
|
133
143
|
return error instanceof Error ? {
|
|
134
144
|
error: error.name,
|
|
@@ -693,6 +703,8 @@ var triggerRouteFunction = async ({
|
|
|
693
703
|
return ok("workflow-was-finished");
|
|
694
704
|
} else if (!(error_ instanceof WorkflowAbort)) {
|
|
695
705
|
return err(error_);
|
|
706
|
+
} else if (error_ instanceof WorkflowNonRetryableError) {
|
|
707
|
+
return ok(error_);
|
|
696
708
|
} else if (error_.cancelWorkflow) {
|
|
697
709
|
await onCancel();
|
|
698
710
|
return ok("workflow-finished");
|
|
@@ -854,7 +866,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
854
866
|
var getTelemetryHeaders = (telemetry2) => {
|
|
855
867
|
return {
|
|
856
868
|
[TELEMETRY_HEADER_SDK]: telemetry2.sdk,
|
|
857
|
-
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework,
|
|
869
|
+
[TELEMETRY_HEADER_FRAMEWORK]: telemetry2.framework ?? "unknown",
|
|
858
870
|
[TELEMETRY_HEADER_RUNTIME]: telemetry2.runtime ?? "unknown"
|
|
859
871
|
};
|
|
860
872
|
};
|
|
@@ -2966,10 +2978,10 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2966
2978
|
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2967
2979
|
}
|
|
2968
2980
|
/**
|
|
2969
|
-
* overwrite cancel method to
|
|
2981
|
+
* overwrite cancel method to throw WorkflowAbort with the disabledMessage
|
|
2970
2982
|
*/
|
|
2971
2983
|
async cancel() {
|
|
2972
|
-
|
|
2984
|
+
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2973
2985
|
}
|
|
2974
2986
|
/**
|
|
2975
2987
|
* copies the passed context to create a DisabledWorkflowContext. Then, runs the
|
|
@@ -3001,7 +3013,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
3001
3013
|
try {
|
|
3002
3014
|
await routeFunction(disabledContext);
|
|
3003
3015
|
} catch (error) {
|
|
3004
|
-
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage) {
|
|
3016
|
+
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage || error instanceof WorkflowNonRetryableError) {
|
|
3005
3017
|
return ok("step-found");
|
|
3006
3018
|
}
|
|
3007
3019
|
return err(error);
|
|
@@ -3222,6 +3234,13 @@ var processOptions = (options) => {
|
|
|
3222
3234
|
status: 400
|
|
3223
3235
|
}
|
|
3224
3236
|
);
|
|
3237
|
+
} else if (finishCondition instanceof WorkflowNonRetryableError) {
|
|
3238
|
+
return new Response(JSON.stringify(formatWorkflowError(finishCondition)), {
|
|
3239
|
+
headers: {
|
|
3240
|
+
"Upstash-NonRetryable-Error": "true"
|
|
3241
|
+
},
|
|
3242
|
+
status: 489
|
|
3243
|
+
});
|
|
3225
3244
|
}
|
|
3226
3245
|
return new Response(JSON.stringify({ workflowRunId }), {
|
|
3227
3246
|
status: 200
|
|
@@ -3414,6 +3433,9 @@ var serveBase = (routeFunction, telemetry2, options) => {
|
|
|
3414
3433
|
},
|
|
3415
3434
|
debug
|
|
3416
3435
|
});
|
|
3436
|
+
if (result.isOk() && result.value instanceof WorkflowNonRetryableError) {
|
|
3437
|
+
return onStepFinish(workflowRunId, result.value);
|
|
3438
|
+
}
|
|
3417
3439
|
if (result.isErr()) {
|
|
3418
3440
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
3419
3441
|
throw result.error;
|
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse,
|
|
3
|
-
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter } from './types-Dd-3bPoU.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, u as CallSettings, D as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, w as InvokableWorkflow, v as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, x as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, l as SyncStepFunction, t as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, z as WorkflowLogger, y as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types-Dd-3bPoU.mjs';
|
|
3
|
+
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
6
6
|
import '@ai-sdk/openai';
|
|
@@ -60,6 +60,10 @@ type BaseStepLog = {
|
|
|
60
60
|
* will be undefined for an unfinished parallel step.
|
|
61
61
|
*/
|
|
62
62
|
out: unknown;
|
|
63
|
+
/**
|
|
64
|
+
* number of retries for the step
|
|
65
|
+
*/
|
|
66
|
+
retries: number;
|
|
63
67
|
/**
|
|
64
68
|
* number of parallel steps
|
|
65
69
|
*
|
|
@@ -78,10 +82,6 @@ type BaseStepLog = {
|
|
|
78
82
|
* headers
|
|
79
83
|
*/
|
|
80
84
|
headers: Record<string, string[]>;
|
|
81
|
-
/**
|
|
82
|
-
* retries
|
|
83
|
-
*/
|
|
84
|
-
retries: number;
|
|
85
85
|
};
|
|
86
86
|
type CallUrlGroup = {
|
|
87
87
|
/**
|
|
@@ -368,6 +368,156 @@ type TriggerOptions = {
|
|
|
368
368
|
*/
|
|
369
369
|
useFailureFunction?: never;
|
|
370
370
|
});
|
|
371
|
+
type DLQResumeRestartOptions<TDLQId extends string | string[] = string | string[]> = {
|
|
372
|
+
dlqId: TDLQId;
|
|
373
|
+
} & Pick<TriggerOptions, "flowControl" | "retries">;
|
|
374
|
+
type DLQResumeRestartResponse = {
|
|
375
|
+
/**
|
|
376
|
+
* id of the workflow run created to resume or restart the DLQ message
|
|
377
|
+
*/
|
|
378
|
+
workflowRunId: string;
|
|
379
|
+
/**
|
|
380
|
+
* Time when the new workflow run was created
|
|
381
|
+
*/
|
|
382
|
+
workflowCreatedAt: string;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
type QStashDLQFilterOptions = NonNullable<Required<Parameters<Client$1["dlq"]["listMessages"]>[0]>>["filter"];
|
|
386
|
+
type DLQFilterOptions = Pick<QStashDLQFilterOptions, "fromDate" | "toDate" | "url" | "responseStatus">;
|
|
387
|
+
type DLQMessage = {
|
|
388
|
+
messageId: string;
|
|
389
|
+
url: string;
|
|
390
|
+
method: string;
|
|
391
|
+
header: Record<string, string[]>;
|
|
392
|
+
body: string;
|
|
393
|
+
maxRetries: number;
|
|
394
|
+
notBefore: number;
|
|
395
|
+
createdAt: number;
|
|
396
|
+
callerIP: string;
|
|
397
|
+
workflowRunId: string;
|
|
398
|
+
workflowCreatedAt: number;
|
|
399
|
+
workflowUrl: string;
|
|
400
|
+
responseStatus: number;
|
|
401
|
+
responseHeader: Record<string, string[]>;
|
|
402
|
+
responseBody: string;
|
|
403
|
+
dlqId: string;
|
|
404
|
+
};
|
|
405
|
+
type PublicDLQMessage = Pick<DLQMessage, "header" | "body" | "maxRetries" | "notBefore" | "createdAt" | "callerIP" | "workflowRunId" | "workflowCreatedAt" | "workflowUrl" | "responseStatus" | "responseHeader" | "responseBody" | "dlqId">;
|
|
406
|
+
declare class DLQ {
|
|
407
|
+
private client;
|
|
408
|
+
constructor(client: Client$1);
|
|
409
|
+
/**
|
|
410
|
+
* list the items in the DLQ
|
|
411
|
+
*
|
|
412
|
+
* @param cursor - Optional cursor for pagination.
|
|
413
|
+
* @param count - Optional number of items to return.
|
|
414
|
+
* @param filter - Optional filter options to apply to the DLQ items.
|
|
415
|
+
* The available filter options are:
|
|
416
|
+
* - `fromDate`: Filter items which entered the DLQ after this date.
|
|
417
|
+
* - `toDate`: Filter items which entered the DLQ before this date.
|
|
418
|
+
* - `url`: Filter items by the URL they were sent to.
|
|
419
|
+
* - `responseStatus`: Filter items by the response status code.
|
|
420
|
+
* @returns
|
|
421
|
+
*/
|
|
422
|
+
list(parameters?: {
|
|
423
|
+
cursor?: string;
|
|
424
|
+
count?: number;
|
|
425
|
+
filter?: DLQFilterOptions;
|
|
426
|
+
}): Promise<{
|
|
427
|
+
messages: PublicDLQMessage[];
|
|
428
|
+
cursor?: string;
|
|
429
|
+
}>;
|
|
430
|
+
/**
|
|
431
|
+
* Resumes the workflow run for the given DLQ message(s).
|
|
432
|
+
*
|
|
433
|
+
* Resuming means that the new workflow run will start executing from where
|
|
434
|
+
* the original workflow run failed, using the same input and context.
|
|
435
|
+
*
|
|
436
|
+
* If you want to restart the workflow run from the beginning, use
|
|
437
|
+
* `restart` method instead.
|
|
438
|
+
*
|
|
439
|
+
* Example with a single DLQ ID:
|
|
440
|
+
* ```ts
|
|
441
|
+
* const response = await client.dlq.resume({
|
|
442
|
+
* dlqId: "dlq-12345",
|
|
443
|
+
* flowControl: {
|
|
444
|
+
* key: "my-flow-control-key",
|
|
445
|
+
* value: "my-flow-control-value",
|
|
446
|
+
* },
|
|
447
|
+
* retries: 3,
|
|
448
|
+
* });
|
|
449
|
+
*
|
|
450
|
+
* console.log(response.workflowRunId); // ID of the new workflow run
|
|
451
|
+
* ```
|
|
452
|
+
*
|
|
453
|
+
* Example with multiple DLQ IDs:
|
|
454
|
+
* ```ts
|
|
455
|
+
* const response = await client.dlq.resume({
|
|
456
|
+
* dlqId: ["dlq-12345", "dlq-67890"],
|
|
457
|
+
* // other parameters...
|
|
458
|
+
* });
|
|
459
|
+
* console.log(response[0].workflowRunId); // ID of the first workflow run
|
|
460
|
+
* console.log(response[1].workflowRunId); // ID of the second workflow run
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* if the dlqId is not found, throws an error.
|
|
464
|
+
*
|
|
465
|
+
* @param dlqId - The ID(s) of the DLQ message(s) to resume.
|
|
466
|
+
* @param flowControl - Optional flow control parameters. If not passed, flow
|
|
467
|
+
* control of the failing workflow will be used
|
|
468
|
+
* @param retries - Optional number of retries to perform if the request fails.
|
|
469
|
+
* If not passed, retries settings of the failing workflow will be used.
|
|
470
|
+
* @returns run id and creation time of the new workflow run(s).
|
|
471
|
+
*/
|
|
472
|
+
resume(parameters: DLQResumeRestartOptions<string>): Promise<DLQResumeRestartResponse>;
|
|
473
|
+
resume(parameters: DLQResumeRestartOptions<string[]>): Promise<DLQResumeRestartResponse[]>;
|
|
474
|
+
/**
|
|
475
|
+
* Restarts the workflow run for the given DLQ message(s).
|
|
476
|
+
*
|
|
477
|
+
* Restarting means that the new workflow run will start executing from the
|
|
478
|
+
* beginning with the same initial payload and configuration.
|
|
479
|
+
*
|
|
480
|
+
* If you want to resume the workflow run from where it failed, use
|
|
481
|
+
* `resume` method instead.
|
|
482
|
+
*
|
|
483
|
+
* Example with a single DLQ ID:
|
|
484
|
+
* ```ts
|
|
485
|
+
* const response = await client.dlq.restart({
|
|
486
|
+
* dlqId: "dlq-12345",
|
|
487
|
+
* flowControl: {
|
|
488
|
+
* key: "my-flow-control-key",
|
|
489
|
+
* value: "my-flow-control-value",
|
|
490
|
+
* },
|
|
491
|
+
* retries: 3,
|
|
492
|
+
* });
|
|
493
|
+
*
|
|
494
|
+
* console.log(response.workflowRunId); // ID of the new workflow run
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* Example with multiple DLQ IDs:
|
|
498
|
+
* ```ts
|
|
499
|
+
* const response = await client.dlq.restart({
|
|
500
|
+
* dlqId: ["dlq-12345", "dlq-67890"],
|
|
501
|
+
* // other parameters...
|
|
502
|
+
* });
|
|
503
|
+
* console.log(response[0].workflowRunId); // ID of the first workflow run
|
|
504
|
+
* console.log(response[1].workflowRunId); // ID of the second workflow run
|
|
505
|
+
* ```
|
|
506
|
+
*
|
|
507
|
+
* if the dlqId is not found, throws an error.
|
|
508
|
+
*
|
|
509
|
+
* @param dlqId - The ID(s) of the DLQ message(s) to restart.
|
|
510
|
+
* @param flowControl - Optional flow control parameters. If not passed, flow
|
|
511
|
+
* control of the failing workflow will be used
|
|
512
|
+
* @param retries - Optional number of retries to perform if the request fails.
|
|
513
|
+
* If not passed, retries settings of the failing workflow will be used.
|
|
514
|
+
* @returns run id and creation time of the new workflow run(s).
|
|
515
|
+
*/
|
|
516
|
+
restart(parameters: DLQResumeRestartOptions<string>): Promise<DLQResumeRestartResponse>;
|
|
517
|
+
restart(parameters: DLQResumeRestartOptions<string[]>): Promise<DLQResumeRestartResponse[]>;
|
|
518
|
+
private static handleDLQOptions;
|
|
519
|
+
private static getDlqIdQueryParameter;
|
|
520
|
+
}
|
|
371
521
|
|
|
372
522
|
type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
373
523
|
/**
|
|
@@ -579,32 +729,7 @@ declare class Client {
|
|
|
579
729
|
workflowUrl?: WorkflowRunLog["workflowUrl"];
|
|
580
730
|
workflowCreatedAt?: WorkflowRunLog["workflowRunCreatedAt"];
|
|
581
731
|
}): Promise<WorkflowRunLogs>;
|
|
732
|
+
get dlq(): DLQ;
|
|
582
733
|
}
|
|
583
734
|
|
|
584
|
-
|
|
585
|
-
* Error raised during Workflow execution
|
|
586
|
-
*/
|
|
587
|
-
declare class WorkflowError extends QstashError {
|
|
588
|
-
constructor(message: string);
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Raised when the workflow executes a function successfully
|
|
592
|
-
* and aborts to end the execution
|
|
593
|
-
*/
|
|
594
|
-
declare class WorkflowAbort extends Error {
|
|
595
|
-
stepInfo?: Step;
|
|
596
|
-
stepName: string;
|
|
597
|
-
/**
|
|
598
|
-
* whether workflow is to be canceled on abort
|
|
599
|
-
*/
|
|
600
|
-
cancelWorkflow: boolean;
|
|
601
|
-
/**
|
|
602
|
-
*
|
|
603
|
-
* @param stepName name of the aborting step
|
|
604
|
-
* @param stepInfo step information
|
|
605
|
-
* @param cancelWorkflow
|
|
606
|
-
*/
|
|
607
|
-
constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, type TriggerOptions, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
|
735
|
+
export { Client, type DLQResumeRestartOptions, type DLQResumeRestartResponse, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, type StepLog, StepType, Telemetry, type TriggerOptions, Waiter, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse,
|
|
3
|
-
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter } from './types-Dd-3bPoU.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, u as CallSettings, D as Duration, o as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, w as InvokableWorkflow, v as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, x as LogLevel, s as NotifyStepResponse, P as ParallelCallState, n as PublicServeOptions, p as RequiredExceptFields, k as Step, m as StepFunction, j as StepTypes, l as SyncStepFunction, t as WaitEventOptions, q as WaitRequest, r as WaitStepResponse, d as WorkflowAbort, h as WorkflowClient, g as WorkflowContext, c as WorkflowError, z as WorkflowLogger, y as WorkflowLoggerOptions, e as WorkflowNonRetryableError, i as WorkflowReceiver, f as WorkflowTool } from './types-Dd-3bPoU.js';
|
|
3
|
+
import { FlowControl, PublishRequest, HTTPMethods, State, Client as Client$1 } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
6
6
|
import '@ai-sdk/openai';
|
|
@@ -60,6 +60,10 @@ type BaseStepLog = {
|
|
|
60
60
|
* will be undefined for an unfinished parallel step.
|
|
61
61
|
*/
|
|
62
62
|
out: unknown;
|
|
63
|
+
/**
|
|
64
|
+
* number of retries for the step
|
|
65
|
+
*/
|
|
66
|
+
retries: number;
|
|
63
67
|
/**
|
|
64
68
|
* number of parallel steps
|
|
65
69
|
*
|
|
@@ -78,10 +82,6 @@ type BaseStepLog = {
|
|
|
78
82
|
* headers
|
|
79
83
|
*/
|
|
80
84
|
headers: Record<string, string[]>;
|
|
81
|
-
/**
|
|
82
|
-
* retries
|
|
83
|
-
*/
|
|
84
|
-
retries: number;
|
|
85
85
|
};
|
|
86
86
|
type CallUrlGroup = {
|
|
87
87
|
/**
|
|
@@ -368,6 +368,156 @@ type TriggerOptions = {
|
|
|
368
368
|
*/
|
|
369
369
|
useFailureFunction?: never;
|
|
370
370
|
});
|
|
371
|
+
type DLQResumeRestartOptions<TDLQId extends string | string[] = string | string[]> = {
|
|
372
|
+
dlqId: TDLQId;
|
|
373
|
+
} & Pick<TriggerOptions, "flowControl" | "retries">;
|
|
374
|
+
type DLQResumeRestartResponse = {
|
|
375
|
+
/**
|
|
376
|
+
* id of the workflow run created to resume or restart the DLQ message
|
|
377
|
+
*/
|
|
378
|
+
workflowRunId: string;
|
|
379
|
+
/**
|
|
380
|
+
* Time when the new workflow run was created
|
|
381
|
+
*/
|
|
382
|
+
workflowCreatedAt: string;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
type QStashDLQFilterOptions = NonNullable<Required<Parameters<Client$1["dlq"]["listMessages"]>[0]>>["filter"];
|
|
386
|
+
type DLQFilterOptions = Pick<QStashDLQFilterOptions, "fromDate" | "toDate" | "url" | "responseStatus">;
|
|
387
|
+
type DLQMessage = {
|
|
388
|
+
messageId: string;
|
|
389
|
+
url: string;
|
|
390
|
+
method: string;
|
|
391
|
+
header: Record<string, string[]>;
|
|
392
|
+
body: string;
|
|
393
|
+
maxRetries: number;
|
|
394
|
+
notBefore: number;
|
|
395
|
+
createdAt: number;
|
|
396
|
+
callerIP: string;
|
|
397
|
+
workflowRunId: string;
|
|
398
|
+
workflowCreatedAt: number;
|
|
399
|
+
workflowUrl: string;
|
|
400
|
+
responseStatus: number;
|
|
401
|
+
responseHeader: Record<string, string[]>;
|
|
402
|
+
responseBody: string;
|
|
403
|
+
dlqId: string;
|
|
404
|
+
};
|
|
405
|
+
type PublicDLQMessage = Pick<DLQMessage, "header" | "body" | "maxRetries" | "notBefore" | "createdAt" | "callerIP" | "workflowRunId" | "workflowCreatedAt" | "workflowUrl" | "responseStatus" | "responseHeader" | "responseBody" | "dlqId">;
|
|
406
|
+
declare class DLQ {
|
|
407
|
+
private client;
|
|
408
|
+
constructor(client: Client$1);
|
|
409
|
+
/**
|
|
410
|
+
* list the items in the DLQ
|
|
411
|
+
*
|
|
412
|
+
* @param cursor - Optional cursor for pagination.
|
|
413
|
+
* @param count - Optional number of items to return.
|
|
414
|
+
* @param filter - Optional filter options to apply to the DLQ items.
|
|
415
|
+
* The available filter options are:
|
|
416
|
+
* - `fromDate`: Filter items which entered the DLQ after this date.
|
|
417
|
+
* - `toDate`: Filter items which entered the DLQ before this date.
|
|
418
|
+
* - `url`: Filter items by the URL they were sent to.
|
|
419
|
+
* - `responseStatus`: Filter items by the response status code.
|
|
420
|
+
* @returns
|
|
421
|
+
*/
|
|
422
|
+
list(parameters?: {
|
|
423
|
+
cursor?: string;
|
|
424
|
+
count?: number;
|
|
425
|
+
filter?: DLQFilterOptions;
|
|
426
|
+
}): Promise<{
|
|
427
|
+
messages: PublicDLQMessage[];
|
|
428
|
+
cursor?: string;
|
|
429
|
+
}>;
|
|
430
|
+
/**
|
|
431
|
+
* Resumes the workflow run for the given DLQ message(s).
|
|
432
|
+
*
|
|
433
|
+
* Resuming means that the new workflow run will start executing from where
|
|
434
|
+
* the original workflow run failed, using the same input and context.
|
|
435
|
+
*
|
|
436
|
+
* If you want to restart the workflow run from the beginning, use
|
|
437
|
+
* `restart` method instead.
|
|
438
|
+
*
|
|
439
|
+
* Example with a single DLQ ID:
|
|
440
|
+
* ```ts
|
|
441
|
+
* const response = await client.dlq.resume({
|
|
442
|
+
* dlqId: "dlq-12345",
|
|
443
|
+
* flowControl: {
|
|
444
|
+
* key: "my-flow-control-key",
|
|
445
|
+
* value: "my-flow-control-value",
|
|
446
|
+
* },
|
|
447
|
+
* retries: 3,
|
|
448
|
+
* });
|
|
449
|
+
*
|
|
450
|
+
* console.log(response.workflowRunId); // ID of the new workflow run
|
|
451
|
+
* ```
|
|
452
|
+
*
|
|
453
|
+
* Example with multiple DLQ IDs:
|
|
454
|
+
* ```ts
|
|
455
|
+
* const response = await client.dlq.resume({
|
|
456
|
+
* dlqId: ["dlq-12345", "dlq-67890"],
|
|
457
|
+
* // other parameters...
|
|
458
|
+
* });
|
|
459
|
+
* console.log(response[0].workflowRunId); // ID of the first workflow run
|
|
460
|
+
* console.log(response[1].workflowRunId); // ID of the second workflow run
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* if the dlqId is not found, throws an error.
|
|
464
|
+
*
|
|
465
|
+
* @param dlqId - The ID(s) of the DLQ message(s) to resume.
|
|
466
|
+
* @param flowControl - Optional flow control parameters. If not passed, flow
|
|
467
|
+
* control of the failing workflow will be used
|
|
468
|
+
* @param retries - Optional number of retries to perform if the request fails.
|
|
469
|
+
* If not passed, retries settings of the failing workflow will be used.
|
|
470
|
+
* @returns run id and creation time of the new workflow run(s).
|
|
471
|
+
*/
|
|
472
|
+
resume(parameters: DLQResumeRestartOptions<string>): Promise<DLQResumeRestartResponse>;
|
|
473
|
+
resume(parameters: DLQResumeRestartOptions<string[]>): Promise<DLQResumeRestartResponse[]>;
|
|
474
|
+
/**
|
|
475
|
+
* Restarts the workflow run for the given DLQ message(s).
|
|
476
|
+
*
|
|
477
|
+
* Restarting means that the new workflow run will start executing from the
|
|
478
|
+
* beginning with the same initial payload and configuration.
|
|
479
|
+
*
|
|
480
|
+
* If you want to resume the workflow run from where it failed, use
|
|
481
|
+
* `resume` method instead.
|
|
482
|
+
*
|
|
483
|
+
* Example with a single DLQ ID:
|
|
484
|
+
* ```ts
|
|
485
|
+
* const response = await client.dlq.restart({
|
|
486
|
+
* dlqId: "dlq-12345",
|
|
487
|
+
* flowControl: {
|
|
488
|
+
* key: "my-flow-control-key",
|
|
489
|
+
* value: "my-flow-control-value",
|
|
490
|
+
* },
|
|
491
|
+
* retries: 3,
|
|
492
|
+
* });
|
|
493
|
+
*
|
|
494
|
+
* console.log(response.workflowRunId); // ID of the new workflow run
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* Example with multiple DLQ IDs:
|
|
498
|
+
* ```ts
|
|
499
|
+
* const response = await client.dlq.restart({
|
|
500
|
+
* dlqId: ["dlq-12345", "dlq-67890"],
|
|
501
|
+
* // other parameters...
|
|
502
|
+
* });
|
|
503
|
+
* console.log(response[0].workflowRunId); // ID of the first workflow run
|
|
504
|
+
* console.log(response[1].workflowRunId); // ID of the second workflow run
|
|
505
|
+
* ```
|
|
506
|
+
*
|
|
507
|
+
* if the dlqId is not found, throws an error.
|
|
508
|
+
*
|
|
509
|
+
* @param dlqId - The ID(s) of the DLQ message(s) to restart.
|
|
510
|
+
* @param flowControl - Optional flow control parameters. If not passed, flow
|
|
511
|
+
* control of the failing workflow will be used
|
|
512
|
+
* @param retries - Optional number of retries to perform if the request fails.
|
|
513
|
+
* If not passed, retries settings of the failing workflow will be used.
|
|
514
|
+
* @returns run id and creation time of the new workflow run(s).
|
|
515
|
+
*/
|
|
516
|
+
restart(parameters: DLQResumeRestartOptions<string>): Promise<DLQResumeRestartResponse>;
|
|
517
|
+
restart(parameters: DLQResumeRestartOptions<string[]>): Promise<DLQResumeRestartResponse[]>;
|
|
518
|
+
private static handleDLQOptions;
|
|
519
|
+
private static getDlqIdQueryParameter;
|
|
520
|
+
}
|
|
371
521
|
|
|
372
522
|
type ClientConfig = ConstructorParameters<typeof Client$1>[0];
|
|
373
523
|
/**
|
|
@@ -579,32 +729,7 @@ declare class Client {
|
|
|
579
729
|
workflowUrl?: WorkflowRunLog["workflowUrl"];
|
|
580
730
|
workflowCreatedAt?: WorkflowRunLog["workflowRunCreatedAt"];
|
|
581
731
|
}): Promise<WorkflowRunLogs>;
|
|
732
|
+
get dlq(): DLQ;
|
|
582
733
|
}
|
|
583
734
|
|
|
584
|
-
|
|
585
|
-
* Error raised during Workflow execution
|
|
586
|
-
*/
|
|
587
|
-
declare class WorkflowError extends QstashError {
|
|
588
|
-
constructor(message: string);
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Raised when the workflow executes a function successfully
|
|
592
|
-
* and aborts to end the execution
|
|
593
|
-
*/
|
|
594
|
-
declare class WorkflowAbort extends Error {
|
|
595
|
-
stepInfo?: Step;
|
|
596
|
-
stepName: string;
|
|
597
|
-
/**
|
|
598
|
-
* whether workflow is to be canceled on abort
|
|
599
|
-
*/
|
|
600
|
-
cancelWorkflow: boolean;
|
|
601
|
-
/**
|
|
602
|
-
*
|
|
603
|
-
* @param stepName name of the aborting step
|
|
604
|
-
* @param stepInfo step information
|
|
605
|
-
* @param cancelWorkflow
|
|
606
|
-
*/
|
|
607
|
-
constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, type TriggerOptions, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
|
735
|
+
export { Client, type DLQResumeRestartOptions, type DLQResumeRestartResponse, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, type StepLog, StepType, Telemetry, type TriggerOptions, Waiter, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|