@upstash/workflow 0.2.7 → 0.2.8-rc-invoke

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.
@@ -33,6 +33,11 @@ declare abstract class BaseLazyStep<TResult = unknown> {
33
33
  */
34
34
  abstract getResultStep(concurrent: number, stepId: number): Promise<Step<TResult>>;
35
35
  }
36
+ type LazyInvokeStepParams<TInitiaPayload, TResult> = {
37
+ workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult, unknown[]>, "callback" | "workflowId">;
38
+ body: TInitiaPayload;
39
+ workflowRunId?: string;
40
+ } & Pick<CallSettings, "retries" | "headers">;
36
41
 
37
42
  declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
38
43
  type LogLevel = (typeof LOG_LEVELS)[number];
@@ -917,6 +922,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
917
922
  * @returns notify response which has event id, event data and list of waiters which were notified
918
923
  */
919
924
  notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
925
+ invoke<TInitialPayload, TResult>(stepName: string, settings: LazyInvokeStepParams<TInitialPayload, TResult>): Promise<{
926
+ body: any;
927
+ isCanceled?: boolean;
928
+ isFailed?: boolean;
929
+ }>;
920
930
  /**
921
931
  * Cancel the current workflow run
922
932
  *
@@ -952,7 +962,7 @@ type WorkflowClient = {
952
962
  type WorkflowReceiver = {
953
963
  verify: InstanceType<typeof Receiver>["verify"];
954
964
  };
955
- declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify"];
965
+ declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify", "Invoke"];
956
966
  type StepType = (typeof StepTypes)[number];
957
967
  type ThirdPartyCallFields<TBody = unknown> = {
958
968
  /**
@@ -1035,7 +1045,7 @@ type SyncStepFunction<TResult> = () => TResult;
1035
1045
  type AsyncStepFunction<TResult> = () => Promise<TResult>;
1036
1046
  type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResult>;
1037
1047
  type ParallelCallState = "first" | "partial" | "discard" | "last";
1038
- type RouteFunction<TInitialPayload> = (context: WorkflowContext<TInitialPayload>) => Promise<void>;
1048
+ type RouteFunction<TInitialPayload, TResult = unknown> = (context: WorkflowContext<TInitialPayload>) => Promise<TResult>;
1039
1049
  type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended";
1040
1050
  type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
1041
1051
  /**
@@ -1312,5 +1322,23 @@ type HeaderParams = {
1312
1322
  */
1313
1323
  callTimeout?: never;
1314
1324
  });
1325
+ type InvokeWorkflowRequest = {
1326
+ workflowUrl: string;
1327
+ workflowRunId: string;
1328
+ headers: Record<string, string[]>;
1329
+ step: Step;
1330
+ body: string;
1331
+ };
1332
+ type InvokeStepResponse<TBody> = {
1333
+ body: TBody;
1334
+ isCanceled?: boolean;
1335
+ isFailed?: boolean;
1336
+ };
1337
+ type InvokeCallback<TInitiaPayload, TResult> = (settings: LazyInvokeStepParams<TInitiaPayload, TResult>, invokeStep: Step, context: WorkflowContext) => Promise<TResult>;
1338
+ type InvokableWorkflow<TInitialPayload, TResult, THandlerParams extends unknown[]> = {
1339
+ handler: (...args: THandlerParams) => any;
1340
+ callback: InvokeCallback<TInitialPayload, TResult>;
1341
+ workflowId?: string;
1342
+ };
1315
1343
 
1316
- export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type Telemetry as T, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type WorkflowLoggerOptions as r, WorkflowLogger as s };
1344
+ export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type InvokeWorkflowRequest as I, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type Telemetry as T, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type PublicServeOptions as j, type FailureFunctionPayload as k, type RequiredExceptFields as l, type WaitRequest as m, type WaitStepResponse as n, type NotifyStepResponse as o, type WaitEventOptions as p, type CallSettings as q, type InvokeStepResponse as r, type InvokeCallback as s, type InvokableWorkflow as t, type WorkflowLoggerOptions as u, WorkflowLogger as v };