@upstash/workflow 1.4.0-rc → 1.4.0

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.
Files changed (50) hide show
  1. package/astro.d.mts +2 -3
  2. package/astro.d.ts +2 -3
  3. package/astro.js +164 -575
  4. package/astro.mjs +1 -1
  5. package/{chunk-UH6O5IJY.mjs → chunk-DRHEHWMS.mjs} +326 -737
  6. package/cloudflare.d.mts +2 -3
  7. package/cloudflare.d.ts +2 -3
  8. package/cloudflare.js +164 -575
  9. package/cloudflare.mjs +1 -1
  10. package/express.d.mts +2 -3
  11. package/express.d.ts +2 -3
  12. package/express.js +164 -575
  13. package/express.mjs +1 -1
  14. package/h3.d.mts +2 -3
  15. package/h3.d.ts +2 -3
  16. package/h3.js +164 -575
  17. package/h3.mjs +1 -1
  18. package/hono.d.mts +2 -3
  19. package/hono.d.ts +2 -3
  20. package/hono.js +164 -575
  21. package/hono.mjs +1 -1
  22. package/index.d.mts +2 -3
  23. package/index.d.ts +2 -3
  24. package/index.js +164 -575
  25. package/index.mjs +1 -1
  26. package/nextjs.d.mts +2 -3
  27. package/nextjs.d.ts +2 -3
  28. package/nextjs.js +164 -575
  29. package/nextjs.mjs +1 -1
  30. package/package.json +1 -1
  31. package/react-router.d.mts +2 -3
  32. package/react-router.d.ts +2 -3
  33. package/react-router.js +164 -575
  34. package/react-router.mjs +1 -1
  35. package/{serve-many-CbIV7145.d.mts → serve-many-CG3BFvO3.d.mts} +1 -1
  36. package/{serve-many-BCtZg31b.d.ts → serve-many-iJF1IUXk.d.ts} +1 -1
  37. package/solidjs.d.mts +1 -2
  38. package/solidjs.d.ts +1 -2
  39. package/solidjs.js +164 -575
  40. package/solidjs.mjs +1 -1
  41. package/svelte.d.mts +2 -3
  42. package/svelte.d.ts +2 -3
  43. package/svelte.js +164 -575
  44. package/svelte.mjs +1 -1
  45. package/tanstack.d.mts +2 -3
  46. package/tanstack.d.ts +2 -3
  47. package/tanstack.js +164 -575
  48. package/tanstack.mjs +1 -1
  49. package/{types-ffLPVG5_.d.ts → types-CekOpKvz.d.mts} +8 -248
  50. package/{types-ffLPVG5_.d.mts → types-CekOpKvz.d.ts} +8 -248
@@ -1,6 +1,5 @@
1
1
  import { QstashError, PublishRequest, HTTPMethods as HTTPMethods$1, FlowControl, Client, Receiver } from '@upstash/qstash';
2
2
  import { z } from 'zod';
3
- import { Ok, Err } from 'neverthrow';
4
3
 
5
4
  /**
6
5
  * Error raised during Workflow execution
@@ -171,14 +170,7 @@ type HeadersResponse = {
171
170
  type StepParams = {
172
171
  context: WorkflowContext;
173
172
  } & Pick<HeaderParams, "telemetry"> & Required<Pick<HeaderParams, "step" | "invokeCount">>;
174
- type GetHeaderParams = StepParams & {
175
- /**
176
- * step-level settings to apply to the message being published. Set
177
- * when the next step has settings and this step's submission is what
178
- * will produce the delivery that executes it.
179
- */
180
- stepSettings?: StepSettings;
181
- };
173
+ type GetHeaderParams = StepParams;
182
174
  type GetBodyParams = StepParams & Omit<HeadersResponse, "contentType">;
183
175
  type SubmitStepParams = StepParams & Pick<HeadersResponse, "headers"> & {
184
176
  body: string;
@@ -196,27 +188,7 @@ declare abstract class BaseLazyStep<TResult = unknown> {
196
188
  abstract readonly stepType: StepType;
197
189
  protected abstract readonly allowUndefinedOut: boolean;
198
190
  protected readonly context: WorkflowContext;
199
- /**
200
- * step-level settings (flow control, retries etc.) which override the
201
- * settings the workflow run was triggered with, for this step only.
202
- */
203
- readonly stepSettings?: StepSettings;
204
- /**
205
- * whether this step's result can be submitted after the route function
206
- * has moved on, instead of right away.
207
- *
208
- * Enabled for steps whose `getResultStep` produces the final `out` —
209
- * which is not the same as "needs no server round trip":
210
- * `LazyCreateWebhookStep` builds its result in `getBody` and returns
211
- * `out: undefined` from `getResultStep`, so deferring it would hand
212
- * `undefined` to the route function.
213
- *
214
- * Deferring lets the route function continue and reveal the next step,
215
- * so that step's settings can ride on this step's submission instead
216
- * of needing a step config request of their own.
217
- */
218
- readonly supportsDeferredSubmission: boolean;
219
- constructor(context: WorkflowContext, stepName: string, stepSettings?: StepSettings);
191
+ constructor(context: WorkflowContext, stepName: string);
220
192
  /**
221
193
  * plan step to submit when step will run parallel with other
222
194
  * steps (parallel call state `first`)
@@ -247,7 +219,7 @@ declare abstract class BaseLazyStep<TResult = unknown> {
247
219
  protected handleUndefinedOut(step: Step): TResult;
248
220
  protected static tryParsing(stepOut: unknown): any;
249
221
  getBody({ step }: GetBodyParams): string;
250
- getHeaders({ context, telemetry, invokeCount, step, stepSettings, }: GetHeaderParams): HeadersResponse;
222
+ getHeaders({ context, telemetry, invokeCount, step }: GetHeaderParams): HeadersResponse;
251
223
  submitStep({ context, body, headers }: SubmitStepParams): Promise<{
252
224
  messageId: string;
253
225
  }[]>;
@@ -264,63 +236,6 @@ type WaitForWebhookResponse = {
264
236
  request: undefined;
265
237
  };
266
238
 
267
- /**
268
- * The configuration QStash applied to the delivery in hand.
269
- *
270
- * Reported on every delivery through the `Upstash-Flow-Control-*`,
271
- * `Upstash-Retries` and `Upstash-Retry-Delay` headers. For an ordinary delivery this is the configuration the run was triggered with; for a
272
- * step-configured delivery it is that step's own configuration, which
273
- * delivery is meant to execute.
274
- */
275
- type EffectiveConfig = {
276
- /**
277
- * flow control applied to this delivery, if any
278
- */
279
- flowControl?: NormalizedFlowControl;
280
- /**
281
- * retry limit of this delivery, or undefined when QStash did not
282
- * report one (a version which predates the header)
283
- */
284
- retries?: number;
285
- /**
286
- * retry delay expression applied to this delivery, if any
287
- */
288
- retryDelay?: string;
289
- /**
290
- * whether the message of this delivery was published with step-level
291
- * settings (the guard marker).
292
- */
293
- hasStepConfig: boolean;
294
- };
295
- /**
296
- * Flow control reduced to a form both sides of the protocol agree on.
297
- *
298
- * Needed because the SDK and QStash format the same values differently:
299
- * the SDK joins the control value with ", " and writes durations
300
- * (`period=1m`), QStash joins with "," and writes whole seconds
301
- * (`period=60`). `rate` and `ratePerSecond` are aliases on the SDK side.
302
- * Comparing the header strings would report a mismatch for values which
303
- * are in fact identical, so both sides are parsed into this shape first.
304
- */
305
- type NormalizedFlowControl = {
306
- key: string;
307
- parallelism: number;
308
- rate: number;
309
- /**
310
- * period in whole seconds
311
- */
312
- period: number;
313
- };
314
-
315
- /**
316
- * What came of submitting the step being held, if one was.
317
- */
318
- type PendingStepOutcome = {
319
- result: "submitted-step";
320
- abort: WorkflowAbort;
321
- } | {
322
- result: "no-pending-step";
323
- };
324
239
  declare class AutoExecutor {
325
240
  private context;
326
241
  private promises;
@@ -335,25 +250,6 @@ declare class AutoExecutor {
335
250
  stepCount: number;
336
251
  planStepCount: number;
337
252
  protected executingStep: string | false;
338
- /**
339
- * an executed step whose result hasn't been submitted to QStash yet.
340
- *
341
- * Set when a step which can produce its result in-process executes. The
342
- * submission waits so that the route function can continue and reveal
343
- * what comes next: if that is a single step with step-level settings,
344
- * the settings ride on this submission and no step config request is
345
- * needed, since the delivery of the submission is what executes it.
346
- *
347
- * Flushed when the next step is reached (see `addStep`) or when the
348
- * route function ends (see `flushPendingStep` in `serve`).
349
- */
350
- private pendingStep?;
351
- /**
352
- * configuration QStash applied to the delivery being handled. A step
353
- * with step-level settings is settled by comparing its settings against
354
- * this.
355
- */
356
- private readonly effectiveConfig;
357
253
  /**
358
254
  * @param context workflow context
359
255
  * @param steps list of steps
@@ -361,10 +257,8 @@ declare class AutoExecutor {
361
257
  * @param dispatchLifecycle lifecycle event dispatcher
362
258
  * @param telemetry optional telemetry information
363
259
  * @param invokeCount optional invoke count
364
- * @param effectiveConfig configuration QStash applied to the delivery
365
- * being handled
366
260
  */
367
- constructor(context: WorkflowContext, steps: Step[], dispatchDebug: DispatchDebug, dispatchLifecycle: DispatchLifecycle, telemetry?: Telemetry, invokeCount?: number, effectiveConfig?: EffectiveConfig);
261
+ constructor(context: WorkflowContext, steps: Step[], dispatchDebug: DispatchDebug, dispatchLifecycle: DispatchLifecycle, telemetry?: Telemetry, invokeCount?: number);
368
262
  /**
369
263
  * Adds the step function to the list of step functions to run in
370
264
  * parallel. After adding the function, defers the execution, so
@@ -406,31 +300,6 @@ declare class AutoExecutor {
406
300
  * @returns step result
407
301
  */
408
302
  protected runSingle<TResult>(lazyStep: BaseLazyStep<TResult>): Promise<TResult>;
409
- /**
410
- * Submits the result of the step being held, if there is one, and
411
- * returns the abort the caller has to throw to end the invocation.
412
- *
413
- * Returns undefined when no step is being held, which is the caller's
414
- * signal that there is nothing to end. Throws instead of returning
415
- * when the submission itself fails, so that error reaches the caller
416
- * rather than an abort claiming the step was submitted.
417
- *
418
- * Callers which arrive while a submission is already under way (the
419
- * steps of a parallel group, added together) wait for that one and get
420
- * the same abort, rather than submitting a second time.
421
- *
422
- * The next step's settings are attached whenever it has any, without
423
- * checking them against the current delivery: the executor only knows
424
- * the configuration of the delivery in hand, which inside a
425
- * delivery is the *previous* step's, so such a check would be wrong
426
- * exactly when two steps with settings follow each other.
427
- *
428
- * @param nextStepSettings step-level settings of the next step
429
- * @returns `submitted-step` with the abort which ends this invocation,
430
- * or `no-pending-step` when nothing was held and there is nothing to
431
- * end
432
- */
433
- submitPendingStep(nextStepSettings?: StepSettings): Promise<Ok<PendingStepOutcome, never> | Err<never, Error>>;
434
303
  /**
435
304
  * Runs steps in parallel.
436
305
  *
@@ -846,41 +715,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
846
715
  * `1` on the first retry, `2` on the second, and so on.
847
716
  */
848
717
  readonly retried: number;
849
- /**
850
- * Configuration QStash applied to the request being handled.
851
- *
852
- * This is the configuration of *this delivery*, not of the run: it is
853
- * the configuration the run was triggered with, except inside the
854
- * delivery which executes a step that has step-level settings, where
855
- * it is that step's settings. The fields below expose it; the executor
856
- * gets it directly rather than reaching through the context.
857
- */
858
- private readonly effectiveConfig;
859
- /**
860
- * Flow control QStash applied to the request being handled, if any.
861
- *
862
- * This is the flow control of the request in hand, which is the one the
863
- * run was triggered with except inside a step carrying its own.
864
- */
865
- get flowControl(): NormalizedFlowControl | undefined;
866
- /**
867
- * Retry limit QStash applied to the request being handled, if it
868
- * reported one.
869
- *
870
- * Not to be confused with {@link retried}, which is how many retries
871
- * have already happened.
872
- *
873
- * @see {@link flowControl} for what "the request being handled" means
874
- */
875
- get retries(): number | undefined;
876
- /**
877
- * Retry delay expression QStash applied to the request being handled,
878
- * if any.
879
- *
880
- * @see {@link flowControl} for what "the request being handled" means
881
- */
882
- get retryDelay(): string | undefined;
883
- constructor({ qstashClient, workflowRunId, workflowRunCreatedAt, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, retried, middlewareManager, effectiveConfig, }: {
718
+ constructor({ qstashClient, workflowRunId, workflowRunCreatedAt, headers, steps, url, initialPayload, env, telemetry, invokeCount, label, retried, middlewareManager, }: {
884
719
  qstashClient: WorkflowClient;
885
720
  workflowRunId: string;
886
721
  workflowRunCreatedAt: number;
@@ -894,12 +729,6 @@ declare class WorkflowContext<TInitialPayload = unknown> {
894
729
  label?: string | string[];
895
730
  retried?: number;
896
731
  middlewareManager?: MiddlewareManager<TInitialPayload>;
897
- /**
898
- * configuration QStash applied to the delivery being handled, read
899
- * from its headers. Defaults to no flow control and no retries,
900
- * which is what a context created outside a delivery observes.
901
- */
902
- effectiveConfig?: EffectiveConfig;
903
732
  });
904
733
  /**
905
734
  * Executes a workflow step
@@ -924,28 +753,11 @@ declare class WorkflowContext<TInitialPayload = unknown> {
924
753
  * ])
925
754
  * ```
926
755
  *
927
- * Step-level settings can be passed as a third argument, overriding
928
- * the settings the workflow run was triggered with for this step only:
929
- *
930
- * ```typescript
931
- * const result = await context.run(
932
- * "step 1",
933
- * () => {
934
- * return "result"
935
- * },
936
- * {
937
- * flowControl: { key: "custom-key", parallelism: 3 },
938
- * retries: 5,
939
- * }
940
- * )
941
- * ```
942
- *
943
756
  * @param stepName name of the step
944
757
  * @param stepFunction step function to be executed
945
- * @param stepSettings step-level settings for this step
946
758
  * @returns result of the step function
947
759
  */
948
- run<TResult>(stepName: string, stepFunction: StepFunction<TResult>, stepSettings?: StepSettings): Promise<TResult>;
760
+ run<TResult>(stepName: string, stepFunction: StepFunction<TResult>): Promise<TResult>;
949
761
  /**
950
762
  * Stops the execution for the duration provided.
951
763
  *
@@ -1191,7 +1003,7 @@ type Step<TResult = unknown, TBody = unknown> = {
1191
1003
  type RawStep = {
1192
1004
  messageId: string;
1193
1005
  body: string;
1194
- callType: "step" | "toCallback" | "fromCallback" | "stepConfig";
1006
+ callType: "step" | "toCallback" | "fromCallback";
1195
1007
  };
1196
1008
  type SyncStepFunction<TResult> = () => TResult;
1197
1009
  type AsyncStepFunction<TResult> = () => Promise<TResult>;
@@ -1403,58 +1215,6 @@ interface WaitEventOptions {
1403
1215
  */
1404
1216
  timeout?: number | Duration;
1405
1217
  }
1406
- /**
1407
- * Step-level settings which override the workflow run settings
1408
- * passed in `client.trigger` for the execution of a single step.
1409
- *
1410
- * Passed as the third argument of `context.run`:
1411
- *
1412
- * ```ts
1413
- * const result = await context.run(
1414
- * "step",
1415
- * () => { ... },
1416
- * { flowControl: { key: "custom-key", parallelism: 3 }, retries: 5 }
1417
- * );
1418
- * ```
1419
- *
1420
- * The settings must be applied to the request whose delivery executes
1421
- * the step:
1422
- *
1423
- * - a step running in parallel with others carries its settings on its
1424
- * own plan step, whose delivery is what executes the step. No extra
1425
- * request is made.
1426
- * - otherwise, the SDK can only learn about the step once the workflow
1427
- * function has been replayed, which happens in a delivery that was
1428
- * published before the step was known. So instead of executing the
1429
- * step in that delivery, a hidden request carrying the
1430
- * settings is published and the step executes when QStash delivers it.
1431
- * This costs one extra message and one extra endpoint invocation per
1432
- * step which carries settings. QStash hides the request from the
1433
- * step logs.
1434
- */
1435
- type StepSettings = {
1436
- /**
1437
- * Settings for controlling the number of active requests
1438
- * and number of requests per second with the same key
1439
- * while executing this step.
1440
- *
1441
- * Overrides the flow control settings passed when triggering
1442
- * the workflow for this step only.
1443
- */
1444
- flowControl?: FlowControl;
1445
- /**
1446
- * Number of times QStash will retry the delivery which executes
1447
- * this step.
1448
- *
1449
- * Overrides the retries passed when triggering the workflow for
1450
- * this step only.
1451
- */
1452
- retries?: number;
1453
- /**
1454
- * Delay between retries of the delivery which executes this step.
1455
- */
1456
- retryDelay?: string;
1457
- };
1458
1218
  type CallSettings = {
1459
1219
  url: string;
1460
1220
  method?: HTTPMethods$1;
@@ -1582,4 +1342,4 @@ type InvokableWorkflow<TInitialPayload, TResult> = {
1582
1342
  useJSONContent?: boolean;
1583
1343
  };
1584
1344
 
1585
- export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FailureFunctionPayload as F, type HeaderParams as H, type InvokableWorkflow as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, type CallSettings as f, type Duration as g, type FinishCondition as h, type InvokeStepResponse as i, type InvokeWorkflowRequest as j, type NotifyStepResponse as k, type RequiredExceptFields as l, type Step as m, type StepFunction as n, type StepSettings as o, StepTypes as p, type SyncStepFunction as q, type WaitEventOptions as r, type WaitRequest as s, type WaitStepResponse as t, WorkflowAbort as u, WorkflowContext as v, WorkflowError as w, WorkflowNonRetryableError as x, WorkflowRetryAfterError as y };
1345
+ export { type AsyncStepFunction as A, type CallResponse as C, type DetailedFinishCondition as D, type ExclusiveValidationOptions as E, type FailureFunctionPayload as F, type HeaderParams as H, type InvokableWorkflow as I, type LazyInvokeStepParams as L, type NotifyResponse as N, type ParallelCallState as P, type QStashClientExtraConfig as Q, type RawStep as R, type StepType as S, type Telemetry as T, WorkflowMiddleware as W, type WorkflowClient as a, type WorkflowReceiver as b, type RouteFunction as c, type WorkflowServeOptions as d, type Waiter as e, type CallSettings as f, type Duration as g, type FinishCondition as h, type InvokeStepResponse as i, type InvokeWorkflowRequest as j, type NotifyStepResponse as k, type RequiredExceptFields as l, type Step as m, type StepFunction as n, StepTypes as o, type SyncStepFunction as p, type WaitEventOptions as q, type WaitRequest as r, type WaitStepResponse as s, WorkflowAbort as t, WorkflowContext as u, WorkflowError as v, WorkflowNonRetryableError as w, WorkflowRetryAfterError as x };