@upstash/workflow 0.2.22-rc → 0.2.23-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/tanstack.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-CAQSUCHB.mjs";
5
+ } from "./chunk-KAGTWBLF.mjs";
6
6
 
7
7
  // platforms/tanstack.ts
8
8
  var telemetry = {
@@ -38,6 +38,14 @@ declare class WorkflowNonRetryableError extends WorkflowAbort {
38
38
  */
39
39
  constructor(message?: string);
40
40
  }
41
+ declare class WorkflowRetryAfterError extends WorkflowAbort {
42
+ retryAfter: number | Duration;
43
+ /**
44
+ * @param retryAfter time in seconds after which the workflow should be retried
45
+ * @param message error message to be displayed
46
+ */
47
+ constructor(message: string, retryAfter: number | Duration);
48
+ }
41
49
 
42
50
  declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
43
51
  type LogLevel = (typeof LOG_LEVELS)[number];
@@ -89,7 +97,8 @@ declare abstract class BaseLazyStep<TResult = unknown> {
89
97
  readonly stepName: string;
90
98
  abstract readonly stepType: StepType;
91
99
  protected abstract readonly allowUndefinedOut: boolean;
92
- constructor(stepName: string);
100
+ protected readonly context: WorkflowContext;
101
+ constructor(context: WorkflowContext, stepName: string);
93
102
  /**
94
103
  * plan step to submit when step will run parallel with other
95
104
  * steps (parallel call state `first`)
@@ -112,11 +121,12 @@ declare abstract class BaseLazyStep<TResult = unknown> {
112
121
  *
113
122
  * will be called when returning the steps to the context from auto executor
114
123
  *
115
- * @param out field of the step
124
+ * @param step step
116
125
  * @returns parsed out field
117
126
  */
118
- parseOut(out: unknown): TResult;
119
- protected safeParseOut(out: string): TResult;
127
+ parseOut(step: Step): TResult;
128
+ protected safeParseOut(out: string, step: Step): TResult;
129
+ protected handleUndefinedOut(step: Step): TResult;
120
130
  protected static tryParsing(stepOut: unknown): any;
121
131
  getBody({ step }: GetBodyParams): string;
122
132
  getHeaders({ context, telemetry, invokeCount, step }: GetHeaderParams): HeadersResponse;
@@ -124,6 +134,17 @@ declare abstract class BaseLazyStep<TResult = unknown> {
124
134
  messageId: string;
125
135
  }[]>;
126
136
  }
137
+ type Webhook = {
138
+ webhookUrl: string;
139
+ eventId: string;
140
+ };
141
+ type WaitForWebhookResponse = {
142
+ timeout: false;
143
+ request: Request;
144
+ } | {
145
+ timeout: true;
146
+ request: undefined;
147
+ };
127
148
 
128
149
  declare class AutoExecutor {
129
150
  private context;
@@ -1096,6 +1117,8 @@ declare class WorkflowContext<TInitialPayload = unknown> {
1096
1117
  */
1097
1118
  notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
1098
1119
  invoke<TInitialPayload, TResult>(stepName: string, settings: LazyInvokeStepParams<TInitialPayload, TResult>): Promise<InvokeStepResponse<TResult>>;
1120
+ createWebhook(stepName: string): Promise<Webhook>;
1121
+ waitForWebhook(stepName: string, webhook: Webhook, timeout: Duration): Promise<WaitForWebhookResponse>;
1099
1122
  /**
1100
1123
  * Cancel the current workflow run
1101
1124
  *
@@ -1132,7 +1155,7 @@ type WorkflowClient = {
1132
1155
  type WorkflowReceiver = {
1133
1156
  verify: InstanceType<typeof Receiver>["verify"];
1134
1157
  };
1135
- declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify", "Invoke"];
1158
+ declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify", "Invoke", "CreateWebhook", "WaitForWebhook"];
1136
1159
  type StepType = (typeof StepTypes)[number];
1137
1160
  type ThirdPartyCallFields<TBody = unknown> = {
1138
1161
  /**
@@ -1223,6 +1246,9 @@ type DetailedFinishCondition = {
1223
1246
  } | {
1224
1247
  condition: "non-retryable-error";
1225
1248
  result: WorkflowNonRetryableError;
1249
+ } | {
1250
+ condition: "retry-after-error";
1251
+ result: WorkflowRetryAfterError;
1226
1252
  } | {
1227
1253
  condition: "failure-callback";
1228
1254
  result: string | void;
@@ -1628,4 +1654,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1628
1654
  workflowId?: string;
1629
1655
  };
1630
1656
 
1631
- export { type AsyncStepFunction as A, type WorkflowLoggerOptions as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, WorkflowLogger as G, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type StringifyBody as v, type CallSettings as w, type InvokeStepResponse as x, type InvokableWorkflow as y, type LogLevel as z };
1657
+ export { type AsyncStepFunction as A, type LogLevel as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type WorkflowLoggerOptions as G, type HeaderParams as H, type InvokeWorkflowRequest as I, WorkflowLogger as J, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowRetryAfterError as f, WorkflowTool as g, WorkflowContext as h, type WorkflowClient as i, type WorkflowReceiver as j, StepTypes as k, type Step as l, type SyncStepFunction as m, type StepFunction as n, type PublicServeOptions as o, type FailureFunctionPayload as p, type RequiredExceptFields as q, type WaitRequest as r, type WaitStepResponse as s, type NotifyStepResponse as t, type Duration as u, type WaitEventOptions as v, type StringifyBody as w, type CallSettings as x, type InvokeStepResponse as y, type InvokableWorkflow as z };
@@ -38,6 +38,14 @@ declare class WorkflowNonRetryableError extends WorkflowAbort {
38
38
  */
39
39
  constructor(message?: string);
40
40
  }
41
+ declare class WorkflowRetryAfterError extends WorkflowAbort {
42
+ retryAfter: number | Duration;
43
+ /**
44
+ * @param retryAfter time in seconds after which the workflow should be retried
45
+ * @param message error message to be displayed
46
+ */
47
+ constructor(message: string, retryAfter: number | Duration);
48
+ }
41
49
 
42
50
  declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
43
51
  type LogLevel = (typeof LOG_LEVELS)[number];
@@ -89,7 +97,8 @@ declare abstract class BaseLazyStep<TResult = unknown> {
89
97
  readonly stepName: string;
90
98
  abstract readonly stepType: StepType;
91
99
  protected abstract readonly allowUndefinedOut: boolean;
92
- constructor(stepName: string);
100
+ protected readonly context: WorkflowContext;
101
+ constructor(context: WorkflowContext, stepName: string);
93
102
  /**
94
103
  * plan step to submit when step will run parallel with other
95
104
  * steps (parallel call state `first`)
@@ -112,11 +121,12 @@ declare abstract class BaseLazyStep<TResult = unknown> {
112
121
  *
113
122
  * will be called when returning the steps to the context from auto executor
114
123
  *
115
- * @param out field of the step
124
+ * @param step step
116
125
  * @returns parsed out field
117
126
  */
118
- parseOut(out: unknown): TResult;
119
- protected safeParseOut(out: string): TResult;
127
+ parseOut(step: Step): TResult;
128
+ protected safeParseOut(out: string, step: Step): TResult;
129
+ protected handleUndefinedOut(step: Step): TResult;
120
130
  protected static tryParsing(stepOut: unknown): any;
121
131
  getBody({ step }: GetBodyParams): string;
122
132
  getHeaders({ context, telemetry, invokeCount, step }: GetHeaderParams): HeadersResponse;
@@ -124,6 +134,17 @@ declare abstract class BaseLazyStep<TResult = unknown> {
124
134
  messageId: string;
125
135
  }[]>;
126
136
  }
137
+ type Webhook = {
138
+ webhookUrl: string;
139
+ eventId: string;
140
+ };
141
+ type WaitForWebhookResponse = {
142
+ timeout: false;
143
+ request: Request;
144
+ } | {
145
+ timeout: true;
146
+ request: undefined;
147
+ };
127
148
 
128
149
  declare class AutoExecutor {
129
150
  private context;
@@ -1096,6 +1117,8 @@ declare class WorkflowContext<TInitialPayload = unknown> {
1096
1117
  */
1097
1118
  notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
1098
1119
  invoke<TInitialPayload, TResult>(stepName: string, settings: LazyInvokeStepParams<TInitialPayload, TResult>): Promise<InvokeStepResponse<TResult>>;
1120
+ createWebhook(stepName: string): Promise<Webhook>;
1121
+ waitForWebhook(stepName: string, webhook: Webhook, timeout: Duration): Promise<WaitForWebhookResponse>;
1099
1122
  /**
1100
1123
  * Cancel the current workflow run
1101
1124
  *
@@ -1132,7 +1155,7 @@ type WorkflowClient = {
1132
1155
  type WorkflowReceiver = {
1133
1156
  verify: InstanceType<typeof Receiver>["verify"];
1134
1157
  };
1135
- declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify", "Invoke"];
1158
+ declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify", "Invoke", "CreateWebhook", "WaitForWebhook"];
1136
1159
  type StepType = (typeof StepTypes)[number];
1137
1160
  type ThirdPartyCallFields<TBody = unknown> = {
1138
1161
  /**
@@ -1223,6 +1246,9 @@ type DetailedFinishCondition = {
1223
1246
  } | {
1224
1247
  condition: "non-retryable-error";
1225
1248
  result: WorkflowNonRetryableError;
1249
+ } | {
1250
+ condition: "retry-after-error";
1251
+ result: WorkflowRetryAfterError;
1226
1252
  } | {
1227
1253
  condition: "failure-callback";
1228
1254
  result: string | void;
@@ -1628,4 +1654,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1628
1654
  workflowId?: string;
1629
1655
  };
1630
1656
 
1631
- export { type AsyncStepFunction as A, type WorkflowLoggerOptions as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, WorkflowLogger as G, type HeaderParams as H, type InvokeWorkflowRequest as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowTool as f, WorkflowContext as g, type WorkflowClient as h, type WorkflowReceiver as i, StepTypes as j, type Step as k, type SyncStepFunction as l, type StepFunction as m, type PublicServeOptions as n, type FailureFunctionPayload as o, type RequiredExceptFields as p, type WaitRequest as q, type WaitStepResponse as r, type NotifyStepResponse as s, type Duration as t, type WaitEventOptions as u, type StringifyBody as v, type CallSettings as w, type InvokeStepResponse as x, type InvokableWorkflow as y, type LogLevel as z };
1657
+ export { type AsyncStepFunction as A, type LogLevel as B, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type WorkflowLoggerOptions as G, type HeaderParams as H, type InvokeWorkflowRequest as I, WorkflowLogger as J, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, WorkflowError as c, WorkflowAbort as d, WorkflowNonRetryableError as e, WorkflowRetryAfterError as f, WorkflowTool as g, WorkflowContext as h, type WorkflowClient as i, type WorkflowReceiver as j, StepTypes as k, type Step as l, type SyncStepFunction as m, type StepFunction as n, type PublicServeOptions as o, type FailureFunctionPayload as p, type RequiredExceptFields as q, type WaitRequest as r, type WaitStepResponse as s, type NotifyStepResponse as t, type Duration as u, type WaitEventOptions as v, type StringifyBody as w, type CallSettings as x, type InvokeStepResponse as y, type InvokableWorkflow as z };