@upstash/workflow 0.2.3 → 0.2.4

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.
@@ -63,10 +63,11 @@ declare class AutoExecutor {
63
63
  private readonly nonPlanStepCount;
64
64
  private readonly steps;
65
65
  private indexInCurrentList;
66
+ private telemetry?;
66
67
  stepCount: number;
67
68
  planStepCount: number;
68
69
  protected executingStep: string | false;
69
- constructor(context: WorkflowContext, steps: Step[], debug?: WorkflowLogger);
70
+ constructor(context: WorkflowContext, steps: Step[], telemetry?: Telemetry, debug?: WorkflowLogger);
70
71
  /**
71
72
  * Adds the step function to the list of step functions to run in
72
73
  * parallel. After adding the function, defers the execution, so
@@ -512,7 +513,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
512
513
  * Number of retries
513
514
  */
514
515
  readonly retries: number;
515
- constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, }: {
516
+ constructor({ qstashClient, workflowRunId, headers, steps, url, failureUrl, debug, initialPayload, env, retries, telemetry, }: {
516
517
  qstashClient: WorkflowClient;
517
518
  workflowRunId: string;
518
519
  headers: Headers;
@@ -523,6 +524,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
523
524
  initialPayload: TInitialPayload;
524
525
  env?: Record<string, string | undefined>;
525
526
  retries?: number;
527
+ telemetry?: Telemetry;
526
528
  });
527
529
  /**
528
530
  * Executes a workflow step
@@ -838,7 +840,7 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
838
840
  * @returns void
839
841
  */
840
842
  failureFunction?: (failureData: {
841
- context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify">;
843
+ context: Omit<WorkflowContext<TInitialPayload>, "run" | "sleepUntil" | "sleep" | "call" | "waitForEvent" | "notify" | "cancel" | "api">;
842
844
  failStatus: number;
843
845
  failResponse: string;
844
846
  failHeaders: Record<string, string[]>;
@@ -876,6 +878,26 @@ type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload
876
878
  * Not part of the public API. Only available in serveBase, which is not exported.
877
879
  */
878
880
  useJSONContent?: boolean;
881
+ /**
882
+ * By default, Workflow SDK sends telemetry about SDK version, framework or runtime.
883
+ *
884
+ * Set `disableTelemetry` to disable this behavior.
885
+ */
886
+ disableTelemetry?: boolean;
887
+ };
888
+ type Telemetry = {
889
+ /**
890
+ * sdk version
891
+ */
892
+ sdk: string;
893
+ /**
894
+ * platform (such as nextjs/cloudflare)
895
+ */
896
+ framework: string;
897
+ /**
898
+ * node version
899
+ */
900
+ runtime?: string;
879
901
  };
880
902
  type PublicServeOptions<TInitialPayload = unknown, TResponse extends Response = Response> = Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "onStepFinish" | "useJSONContent">;
881
903
  /**
@@ -971,5 +993,68 @@ type CallSettings<TBody = unknown> = {
971
993
  retries?: number;
972
994
  timeout?: Duration | number;
973
995
  };
996
+ type HeaderParams = {
997
+ /**
998
+ * whether the request is a first invocation request.
999
+ */
1000
+ initHeaderValue: "true" | "false";
1001
+ /**
1002
+ * run id of the workflow
1003
+ */
1004
+ workflowRunId: string;
1005
+ /**
1006
+ * url where the workflow is hosted
1007
+ */
1008
+ workflowUrl: string;
1009
+ /**
1010
+ * user headers which will be forwarded in the request
1011
+ */
1012
+ userHeaders?: Headers;
1013
+ /**
1014
+ * failure url to call incase of failure
1015
+ */
1016
+ failureUrl?: WorkflowServeOptions["failureUrl"];
1017
+ /**
1018
+ * retry setting of requests except context.call
1019
+ */
1020
+ retries?: number;
1021
+ /**
1022
+ * telemetry to include in timeoutHeaders.
1023
+ *
1024
+ * Only needed/used when the step is a waitForEvent step
1025
+ */
1026
+ telemetry?: Telemetry;
1027
+ } & ({
1028
+ /**
1029
+ * step to generate headers for
1030
+ */
1031
+ step: Step;
1032
+ /**
1033
+ * number of retries in context.call
1034
+ */
1035
+ callRetries?: number;
1036
+ /**
1037
+ * timeout duration in context.call
1038
+ */
1039
+ callTimeout?: number | Duration;
1040
+ } | {
1041
+ /**
1042
+ * step not passed. Either first invocation or simply getting headers for
1043
+ * third party callack.
1044
+ */
1045
+ step?: never;
1046
+ /**
1047
+ * number of retries in context.call
1048
+ *
1049
+ * set to never because this is not a context.call step
1050
+ */
1051
+ callRetries?: never;
1052
+ /**
1053
+ * timeout duration in context.call
1054
+ *
1055
+ * set to never because this is not a context.call step
1056
+ */
1057
+ callTimeout?: never;
1058
+ });
974
1059
 
975
- export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type FinishCondition as F, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, 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 };
1060
+ export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, 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 };