@upstash/workflow 0.2.14 → 0.2.16
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 +39 -7
- package/astro.mjs +1 -1
- package/{chunk-RMS2NQ3K.mjs → chunk-TGEGSOSN.mjs} +41 -7
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +39 -7
- package/cloudflare.mjs +1 -1
- package/express.d.mts +2 -2
- package/express.d.ts +2 -2
- package/express.js +39 -7
- package/express.mjs +1 -1
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +39 -7
- package/h3.mjs +1 -1
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +39 -7
- package/hono.mjs +1 -1
- package/index.d.mts +159 -34
- package/index.d.ts +159 -34
- package/index.js +126 -11
- package/index.mjs +90 -5
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +39 -7
- 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 +39 -7
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +39 -7
- 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/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 };
|
package/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(src_exports, {
|
|
|
26
26
|
WorkflowContext: () => WorkflowContext,
|
|
27
27
|
WorkflowError: () => WorkflowError,
|
|
28
28
|
WorkflowLogger: () => WorkflowLogger,
|
|
29
|
+
WorkflowNonRetryableError: () => WorkflowNonRetryableError,
|
|
29
30
|
WorkflowTool: () => WorkflowTool,
|
|
30
31
|
serve: () => serve
|
|
31
32
|
});
|
|
@@ -103,7 +104,7 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
103
104
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
104
105
|
var NO_CONCURRENCY = 1;
|
|
105
106
|
var DEFAULT_RETRIES = 3;
|
|
106
|
-
var VERSION = "v0.2.
|
|
107
|
+
var VERSION = "v0.2.15";
|
|
107
108
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
108
109
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
109
110
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
@@ -141,6 +142,16 @@ var WorkflowAbort = class extends Error {
|
|
|
141
142
|
this.cancelWorkflow = cancelWorkflow;
|
|
142
143
|
}
|
|
143
144
|
};
|
|
145
|
+
var WorkflowNonRetryableError = class extends WorkflowAbort {
|
|
146
|
+
/**
|
|
147
|
+
* @param message error message to be displayed
|
|
148
|
+
*/
|
|
149
|
+
constructor(message) {
|
|
150
|
+
super("fail", void 0, false);
|
|
151
|
+
this.name = "WorkflowNonRetryableError";
|
|
152
|
+
if (message) this.message = message;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
144
155
|
var formatWorkflowError = (error) => {
|
|
145
156
|
return error instanceof Error ? {
|
|
146
157
|
error: error.name,
|
|
@@ -705,6 +716,8 @@ var triggerRouteFunction = async ({
|
|
|
705
716
|
return ok("workflow-was-finished");
|
|
706
717
|
} else if (!(error_ instanceof WorkflowAbort)) {
|
|
707
718
|
return err(error_);
|
|
719
|
+
} else if (error_ instanceof WorkflowNonRetryableError) {
|
|
720
|
+
return ok(error_);
|
|
708
721
|
} else if (error_.cancelWorkflow) {
|
|
709
722
|
await onCancel();
|
|
710
723
|
return ok("workflow-finished");
|
|
@@ -866,7 +879,7 @@ ${atob(callbackMessage.body ?? "")}`
|
|
|
866
879
|
var getTelemetryHeaders = (telemetry) => {
|
|
867
880
|
return {
|
|
868
881
|
[TELEMETRY_HEADER_SDK]: telemetry.sdk,
|
|
869
|
-
[TELEMETRY_HEADER_FRAMEWORK]: telemetry.framework,
|
|
882
|
+
[TELEMETRY_HEADER_FRAMEWORK]: telemetry.framework ?? "unknown",
|
|
870
883
|
[TELEMETRY_HEADER_RUNTIME]: telemetry.runtime ?? "unknown"
|
|
871
884
|
};
|
|
872
885
|
};
|
|
@@ -2948,10 +2961,10 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2948
2961
|
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2949
2962
|
}
|
|
2950
2963
|
/**
|
|
2951
|
-
* overwrite cancel method to
|
|
2964
|
+
* overwrite cancel method to throw WorkflowAbort with the disabledMessage
|
|
2952
2965
|
*/
|
|
2953
2966
|
async cancel() {
|
|
2954
|
-
|
|
2967
|
+
throw new WorkflowAbort(_DisabledWorkflowContext.disabledMessage);
|
|
2955
2968
|
}
|
|
2956
2969
|
/**
|
|
2957
2970
|
* copies the passed context to create a DisabledWorkflowContext. Then, runs the
|
|
@@ -2983,7 +2996,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2983
2996
|
try {
|
|
2984
2997
|
await routeFunction(disabledContext);
|
|
2985
2998
|
} catch (error) {
|
|
2986
|
-
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage) {
|
|
2999
|
+
if (error instanceof WorkflowAbort && error.stepName === this.disabledMessage || error instanceof WorkflowNonRetryableError) {
|
|
2987
3000
|
return ok("step-found");
|
|
2988
3001
|
}
|
|
2989
3002
|
return err(error);
|
|
@@ -3141,7 +3154,17 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3141
3154
|
try {
|
|
3142
3155
|
const { status, header, body, url, sourceBody, workflowRunId } = JSON.parse(requestPayload);
|
|
3143
3156
|
const decodedBody = body ? decodeBase64(body) : "{}";
|
|
3144
|
-
|
|
3157
|
+
let errorMessage = "";
|
|
3158
|
+
try {
|
|
3159
|
+
const errorPayload = JSON.parse(decodedBody);
|
|
3160
|
+
if (errorPayload.message) {
|
|
3161
|
+
errorMessage = errorPayload.message;
|
|
3162
|
+
}
|
|
3163
|
+
} catch {
|
|
3164
|
+
}
|
|
3165
|
+
if (!errorMessage) {
|
|
3166
|
+
errorMessage = `Couldn't parse 'failResponse' in 'failureFunction', received: '${decodedBody}'`;
|
|
3167
|
+
}
|
|
3145
3168
|
const workflowContext = new WorkflowContext({
|
|
3146
3169
|
qstashClient,
|
|
3147
3170
|
workflowRunId,
|
|
@@ -3170,7 +3193,7 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
3170
3193
|
await failureFunction({
|
|
3171
3194
|
context: workflowContext,
|
|
3172
3195
|
failStatus: status,
|
|
3173
|
-
failResponse:
|
|
3196
|
+
failResponse: errorMessage,
|
|
3174
3197
|
failHeaders: header
|
|
3175
3198
|
});
|
|
3176
3199
|
} catch (error) {
|
|
@@ -3204,6 +3227,13 @@ var processOptions = (options) => {
|
|
|
3204
3227
|
status: 400
|
|
3205
3228
|
}
|
|
3206
3229
|
);
|
|
3230
|
+
} else if (finishCondition instanceof WorkflowNonRetryableError) {
|
|
3231
|
+
return new Response(JSON.stringify(formatWorkflowError(finishCondition)), {
|
|
3232
|
+
headers: {
|
|
3233
|
+
"Upstash-NonRetryable-Error": "true"
|
|
3234
|
+
},
|
|
3235
|
+
status: 489
|
|
3236
|
+
});
|
|
3207
3237
|
}
|
|
3208
3238
|
return new Response(JSON.stringify({ workflowRunId }), {
|
|
3209
3239
|
status: 200
|
|
@@ -3396,6 +3426,9 @@ var serveBase = (routeFunction, telemetry, options) => {
|
|
|
3396
3426
|
},
|
|
3397
3427
|
debug
|
|
3398
3428
|
});
|
|
3429
|
+
if (result.isOk() && result.value instanceof WorkflowNonRetryableError) {
|
|
3430
|
+
return onStepFinish(workflowRunId, result.value);
|
|
3431
|
+
}
|
|
3399
3432
|
if (result.isErr()) {
|
|
3400
3433
|
await debug?.log("ERROR", "ERROR", { error: result.error.message });
|
|
3401
3434
|
throw result.error;
|
|
@@ -3444,6 +3477,86 @@ var serve = (routeFunction, options) => {
|
|
|
3444
3477
|
|
|
3445
3478
|
// src/client/index.ts
|
|
3446
3479
|
var import_qstash12 = require("@upstash/qstash");
|
|
3480
|
+
|
|
3481
|
+
// src/client/dlq.ts
|
|
3482
|
+
var DLQ = class _DLQ {
|
|
3483
|
+
constructor(client) {
|
|
3484
|
+
this.client = client;
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* list the items in the DLQ
|
|
3488
|
+
*
|
|
3489
|
+
* @param cursor - Optional cursor for pagination.
|
|
3490
|
+
* @param count - Optional number of items to return.
|
|
3491
|
+
* @param filter - Optional filter options to apply to the DLQ items.
|
|
3492
|
+
* The available filter options are:
|
|
3493
|
+
* - `fromDate`: Filter items which entered the DLQ after this date.
|
|
3494
|
+
* - `toDate`: Filter items which entered the DLQ before this date.
|
|
3495
|
+
* - `url`: Filter items by the URL they were sent to.
|
|
3496
|
+
* - `responseStatus`: Filter items by the response status code.
|
|
3497
|
+
* @returns
|
|
3498
|
+
*/
|
|
3499
|
+
async list(parameters) {
|
|
3500
|
+
const { cursor, count, filter } = parameters || {};
|
|
3501
|
+
return await this.client.http.request({
|
|
3502
|
+
path: ["v2", "dlq"],
|
|
3503
|
+
method: "GET",
|
|
3504
|
+
query: {
|
|
3505
|
+
cursor,
|
|
3506
|
+
count,
|
|
3507
|
+
...filter,
|
|
3508
|
+
source: "workflow"
|
|
3509
|
+
}
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
async resume(parameters) {
|
|
3513
|
+
const { headers, queryParams } = _DLQ.handleDLQOptions(parameters);
|
|
3514
|
+
const { workflowRuns } = await this.client.http.request({
|
|
3515
|
+
path: ["v2", "workflows", "dlq", `resume?${queryParams}`],
|
|
3516
|
+
headers,
|
|
3517
|
+
method: "POST"
|
|
3518
|
+
});
|
|
3519
|
+
if (Array.isArray(parameters.dlqId)) {
|
|
3520
|
+
return workflowRuns;
|
|
3521
|
+
}
|
|
3522
|
+
return workflowRuns[0];
|
|
3523
|
+
}
|
|
3524
|
+
async restart(parameters) {
|
|
3525
|
+
const { headers, queryParams } = _DLQ.handleDLQOptions(parameters);
|
|
3526
|
+
const { workflowRuns } = await this.client.http.request({
|
|
3527
|
+
path: ["v2", "workflows", "dlq", `restart?${queryParams}`],
|
|
3528
|
+
headers,
|
|
3529
|
+
method: "POST"
|
|
3530
|
+
});
|
|
3531
|
+
if (Array.isArray(parameters.dlqId)) {
|
|
3532
|
+
return workflowRuns;
|
|
3533
|
+
}
|
|
3534
|
+
return workflowRuns[0];
|
|
3535
|
+
}
|
|
3536
|
+
static handleDLQOptions(options) {
|
|
3537
|
+
const { dlqId, flowControl, retries } = options;
|
|
3538
|
+
const headers = {};
|
|
3539
|
+
if (flowControl) {
|
|
3540
|
+
const { flowControlKey, flowControlValue } = prepareFlowControl(flowControl);
|
|
3541
|
+
headers["Upstash-Flow-Control-Key"] = flowControlKey;
|
|
3542
|
+
headers["Upstash-Flow-Control-Value"] = flowControlValue;
|
|
3543
|
+
}
|
|
3544
|
+
if (retries !== void 0) {
|
|
3545
|
+
headers["Upstash-Retries"] = retries.toString();
|
|
3546
|
+
}
|
|
3547
|
+
return {
|
|
3548
|
+
queryParams: _DLQ.getDlqIdQueryParameter(dlqId),
|
|
3549
|
+
headers
|
|
3550
|
+
};
|
|
3551
|
+
}
|
|
3552
|
+
static getDlqIdQueryParameter(dlqId) {
|
|
3553
|
+
const dlqIds = Array.isArray(dlqId) ? dlqId : [dlqId];
|
|
3554
|
+
const paramsArray = dlqIds.map((id) => ["dlqIds", id]);
|
|
3555
|
+
return new URLSearchParams(paramsArray).toString();
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
|
|
3559
|
+
// src/client/index.ts
|
|
3447
3560
|
var Client4 = class {
|
|
3448
3561
|
client;
|
|
3449
3562
|
constructor(clientConfig) {
|
|
@@ -3585,15 +3698,13 @@ var Client4 = class {
|
|
|
3585
3698
|
url: option.url,
|
|
3586
3699
|
workflowRunId: finalWorkflowRunId,
|
|
3587
3700
|
retries: option.retries,
|
|
3588
|
-
telemetry:
|
|
3589
|
-
// can't know workflow telemetry here
|
|
3701
|
+
telemetry: { sdk: SDK_TELEMETRY },
|
|
3590
3702
|
flowControl: option.flowControl,
|
|
3591
3703
|
failureUrl
|
|
3592
3704
|
});
|
|
3593
3705
|
return {
|
|
3594
3706
|
workflowContext: context,
|
|
3595
|
-
telemetry:
|
|
3596
|
-
// can't know workflow telemetry here
|
|
3707
|
+
telemetry: { sdk: SDK_TELEMETRY },
|
|
3597
3708
|
delay: option.delay
|
|
3598
3709
|
};
|
|
3599
3710
|
});
|
|
@@ -3660,6 +3771,9 @@ var Client4 = class {
|
|
|
3660
3771
|
});
|
|
3661
3772
|
return result;
|
|
3662
3773
|
}
|
|
3774
|
+
get dlq() {
|
|
3775
|
+
return new DLQ(this.client);
|
|
3776
|
+
}
|
|
3663
3777
|
};
|
|
3664
3778
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3665
3779
|
0 && (module.exports = {
|
|
@@ -3669,6 +3783,7 @@ var Client4 = class {
|
|
|
3669
3783
|
WorkflowContext,
|
|
3670
3784
|
WorkflowError,
|
|
3671
3785
|
WorkflowLogger,
|
|
3786
|
+
WorkflowNonRetryableError,
|
|
3672
3787
|
WorkflowTool,
|
|
3673
3788
|
serve
|
|
3674
3789
|
});
|
package/index.mjs
CHANGED
|
@@ -1,19 +1,102 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SDK_TELEMETRY,
|
|
2
3
|
StepTypes,
|
|
3
4
|
WorkflowAbort,
|
|
4
5
|
WorkflowContext,
|
|
5
6
|
WorkflowError,
|
|
6
7
|
WorkflowLogger,
|
|
8
|
+
WorkflowNonRetryableError,
|
|
7
9
|
WorkflowTool,
|
|
8
10
|
getWorkflowRunId,
|
|
9
11
|
makeGetWaitersRequest,
|
|
10
12
|
makeNotifyRequest,
|
|
13
|
+
prepareFlowControl,
|
|
11
14
|
serve,
|
|
12
15
|
triggerFirstInvocation
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-TGEGSOSN.mjs";
|
|
14
17
|
|
|
15
18
|
// src/client/index.ts
|
|
16
19
|
import { Client as QStashClient } from "@upstash/qstash";
|
|
20
|
+
|
|
21
|
+
// src/client/dlq.ts
|
|
22
|
+
var DLQ = class _DLQ {
|
|
23
|
+
constructor(client) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* list the items in the DLQ
|
|
28
|
+
*
|
|
29
|
+
* @param cursor - Optional cursor for pagination.
|
|
30
|
+
* @param count - Optional number of items to return.
|
|
31
|
+
* @param filter - Optional filter options to apply to the DLQ items.
|
|
32
|
+
* The available filter options are:
|
|
33
|
+
* - `fromDate`: Filter items which entered the DLQ after this date.
|
|
34
|
+
* - `toDate`: Filter items which entered the DLQ before this date.
|
|
35
|
+
* - `url`: Filter items by the URL they were sent to.
|
|
36
|
+
* - `responseStatus`: Filter items by the response status code.
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
async list(parameters) {
|
|
40
|
+
const { cursor, count, filter } = parameters || {};
|
|
41
|
+
return await this.client.http.request({
|
|
42
|
+
path: ["v2", "dlq"],
|
|
43
|
+
method: "GET",
|
|
44
|
+
query: {
|
|
45
|
+
cursor,
|
|
46
|
+
count,
|
|
47
|
+
...filter,
|
|
48
|
+
source: "workflow"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async resume(parameters) {
|
|
53
|
+
const { headers, queryParams } = _DLQ.handleDLQOptions(parameters);
|
|
54
|
+
const { workflowRuns } = await this.client.http.request({
|
|
55
|
+
path: ["v2", "workflows", "dlq", `resume?${queryParams}`],
|
|
56
|
+
headers,
|
|
57
|
+
method: "POST"
|
|
58
|
+
});
|
|
59
|
+
if (Array.isArray(parameters.dlqId)) {
|
|
60
|
+
return workflowRuns;
|
|
61
|
+
}
|
|
62
|
+
return workflowRuns[0];
|
|
63
|
+
}
|
|
64
|
+
async restart(parameters) {
|
|
65
|
+
const { headers, queryParams } = _DLQ.handleDLQOptions(parameters);
|
|
66
|
+
const { workflowRuns } = await this.client.http.request({
|
|
67
|
+
path: ["v2", "workflows", "dlq", `restart?${queryParams}`],
|
|
68
|
+
headers,
|
|
69
|
+
method: "POST"
|
|
70
|
+
});
|
|
71
|
+
if (Array.isArray(parameters.dlqId)) {
|
|
72
|
+
return workflowRuns;
|
|
73
|
+
}
|
|
74
|
+
return workflowRuns[0];
|
|
75
|
+
}
|
|
76
|
+
static handleDLQOptions(options) {
|
|
77
|
+
const { dlqId, flowControl, retries } = options;
|
|
78
|
+
const headers = {};
|
|
79
|
+
if (flowControl) {
|
|
80
|
+
const { flowControlKey, flowControlValue } = prepareFlowControl(flowControl);
|
|
81
|
+
headers["Upstash-Flow-Control-Key"] = flowControlKey;
|
|
82
|
+
headers["Upstash-Flow-Control-Value"] = flowControlValue;
|
|
83
|
+
}
|
|
84
|
+
if (retries !== void 0) {
|
|
85
|
+
headers["Upstash-Retries"] = retries.toString();
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
queryParams: _DLQ.getDlqIdQueryParameter(dlqId),
|
|
89
|
+
headers
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static getDlqIdQueryParameter(dlqId) {
|
|
93
|
+
const dlqIds = Array.isArray(dlqId) ? dlqId : [dlqId];
|
|
94
|
+
const paramsArray = dlqIds.map((id) => ["dlqIds", id]);
|
|
95
|
+
return new URLSearchParams(paramsArray).toString();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/client/index.ts
|
|
17
100
|
var Client = class {
|
|
18
101
|
client;
|
|
19
102
|
constructor(clientConfig) {
|
|
@@ -155,15 +238,13 @@ var Client = class {
|
|
|
155
238
|
url: option.url,
|
|
156
239
|
workflowRunId: finalWorkflowRunId,
|
|
157
240
|
retries: option.retries,
|
|
158
|
-
telemetry:
|
|
159
|
-
// can't know workflow telemetry here
|
|
241
|
+
telemetry: { sdk: SDK_TELEMETRY },
|
|
160
242
|
flowControl: option.flowControl,
|
|
161
243
|
failureUrl
|
|
162
244
|
});
|
|
163
245
|
return {
|
|
164
246
|
workflowContext: context,
|
|
165
|
-
telemetry:
|
|
166
|
-
// can't know workflow telemetry here
|
|
247
|
+
telemetry: { sdk: SDK_TELEMETRY },
|
|
167
248
|
delay: option.delay
|
|
168
249
|
};
|
|
169
250
|
});
|
|
@@ -230,6 +311,9 @@ var Client = class {
|
|
|
230
311
|
});
|
|
231
312
|
return result;
|
|
232
313
|
}
|
|
314
|
+
get dlq() {
|
|
315
|
+
return new DLQ(this.client);
|
|
316
|
+
}
|
|
233
317
|
};
|
|
234
318
|
export {
|
|
235
319
|
Client,
|
|
@@ -238,6 +322,7 @@ export {
|
|
|
238
322
|
WorkflowContext,
|
|
239
323
|
WorkflowError,
|
|
240
324
|
WorkflowLogger,
|
|
325
|
+
WorkflowNonRetryableError,
|
|
241
326
|
WorkflowTool,
|
|
242
327
|
serve
|
|
243
328
|
};
|
package/nextjs.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { R as RouteFunction,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-AFwJPR3S.mjs';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|
package/nextjs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { R as RouteFunction,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, w as InvokableWorkflow } from './types-Dd-3bPoU.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-AaKSQyi7.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'ai';
|