@cloudflare/workers-types 4.20260506.1 → 4.20260508.1

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.
@@ -14359,28 +14359,16 @@ declare namespace CloudflareWorkersModule {
14359
14359
  attempt: number;
14360
14360
  config: WorkflowStepConfig;
14361
14361
  };
14362
- export interface RollbackContext<T> {
14363
- error: Error;
14364
- output: NonNullable<T> | undefined;
14365
- stepName: string;
14366
- }
14367
- export interface StepPromise<T> extends Promise<T> {
14368
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
14369
- rollback(
14370
- config: WorkflowStepConfig,
14371
- fn: (ctx: RollbackContext<T>) => Promise<void>,
14372
- ): StepPromise<T>;
14373
- }
14374
14362
  export abstract class WorkflowStep {
14375
14363
  do<T extends Rpc.Serializable<T>>(
14376
14364
  name: string,
14377
14365
  callback: (ctx: WorkflowStepContext) => Promise<T>,
14378
- ): StepPromise<T>;
14366
+ ): Promise<T>;
14379
14367
  do<T extends Rpc.Serializable<T>>(
14380
14368
  name: string,
14381
14369
  config: WorkflowStepConfig,
14382
14370
  callback: (ctx: WorkflowStepContext) => Promise<T>,
14383
- ): StepPromise<T>;
14371
+ ): Promise<T>;
14384
14372
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
14385
14373
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
14386
14374
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -14389,7 +14377,7 @@ declare namespace CloudflareWorkersModule {
14389
14377
  type: string;
14390
14378
  timeout?: WorkflowTimeoutDuration | number;
14391
14379
  },
14392
- ): StepPromise<WorkflowStepEvent<T>>;
14380
+ ): Promise<WorkflowStepEvent<T>>;
14393
14381
  }
14394
14382
  export type WorkflowInstanceStatus =
14395
14383
  | "queued"
@@ -15891,6 +15879,27 @@ interface WorkflowError {
15891
15879
  code?: number;
15892
15880
  message: string;
15893
15881
  }
15882
+ interface WorkflowInstanceRestartOptions {
15883
+ /**
15884
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15885
+ * The step must exist in the instance's execution history.
15886
+ */
15887
+ from?: {
15888
+ /**
15889
+ * The step name as defined in your workflow code.
15890
+ */
15891
+ name: string;
15892
+ /**
15893
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15894
+ * @default 1
15895
+ */
15896
+ count?: number;
15897
+ /**
15898
+ * Step type filter. Use when different step types share the same name.
15899
+ */
15900
+ type?: "do" | "sleep" | "waitForEvent";
15901
+ };
15902
+ }
15894
15903
  declare abstract class WorkflowInstance {
15895
15904
  public id: string;
15896
15905
  /**
@@ -15906,9 +15915,11 @@ declare abstract class WorkflowInstance {
15906
15915
  */
15907
15916
  public terminate(): Promise<void>;
15908
15917
  /**
15909
- * Restart the instance.
15918
+ * Restart the instance. Optionally restart from a specific step, preserving
15919
+ * cached results for all steps before it.
15920
+ * @param options Options for the restart, including an optional step to restart from.
15910
15921
  */
15911
- public restart(): Promise<void>;
15922
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15912
15923
  /**
15913
15924
  * Returns the current status of the instance.
15914
15925
  */
@@ -14330,28 +14330,16 @@ export declare namespace CloudflareWorkersModule {
14330
14330
  attempt: number;
14331
14331
  config: WorkflowStepConfig;
14332
14332
  };
14333
- export interface RollbackContext<T> {
14334
- error: Error;
14335
- output: NonNullable<T> | undefined;
14336
- stepName: string;
14337
- }
14338
- export interface StepPromise<T> extends Promise<T> {
14339
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
14340
- rollback(
14341
- config: WorkflowStepConfig,
14342
- fn: (ctx: RollbackContext<T>) => Promise<void>,
14343
- ): StepPromise<T>;
14344
- }
14345
14333
  export abstract class WorkflowStep {
14346
14334
  do<T extends Rpc.Serializable<T>>(
14347
14335
  name: string,
14348
14336
  callback: (ctx: WorkflowStepContext) => Promise<T>,
14349
- ): StepPromise<T>;
14337
+ ): Promise<T>;
14350
14338
  do<T extends Rpc.Serializable<T>>(
14351
14339
  name: string,
14352
14340
  config: WorkflowStepConfig,
14353
14341
  callback: (ctx: WorkflowStepContext) => Promise<T>,
14354
- ): StepPromise<T>;
14342
+ ): Promise<T>;
14355
14343
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
14356
14344
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
14357
14345
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -14360,7 +14348,7 @@ export declare namespace CloudflareWorkersModule {
14360
14348
  type: string;
14361
14349
  timeout?: WorkflowTimeoutDuration | number;
14362
14350
  },
14363
- ): StepPromise<WorkflowStepEvent<T>>;
14351
+ ): Promise<WorkflowStepEvent<T>>;
14364
14352
  }
14365
14353
  export type WorkflowInstanceStatus =
14366
14354
  | "queued"
@@ -15843,6 +15831,27 @@ export interface WorkflowError {
15843
15831
  code?: number;
15844
15832
  message: string;
15845
15833
  }
15834
+ export interface WorkflowInstanceRestartOptions {
15835
+ /**
15836
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15837
+ * The step must exist in the instance's execution history.
15838
+ */
15839
+ from?: {
15840
+ /**
15841
+ * The step name as defined in your workflow code.
15842
+ */
15843
+ name: string;
15844
+ /**
15845
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15846
+ * @default 1
15847
+ */
15848
+ count?: number;
15849
+ /**
15850
+ * Step type filter. Use when different step types share the same name.
15851
+ */
15852
+ type?: "do" | "sleep" | "waitForEvent";
15853
+ };
15854
+ }
15846
15855
  export declare abstract class WorkflowInstance {
15847
15856
  public id: string;
15848
15857
  /**
@@ -15858,9 +15867,11 @@ export declare abstract class WorkflowInstance {
15858
15867
  */
15859
15868
  public terminate(): Promise<void>;
15860
15869
  /**
15861
- * Restart the instance.
15870
+ * Restart the instance. Optionally restart from a specific step, preserving
15871
+ * cached results for all steps before it.
15872
+ * @param options Options for the restart, including an optional step to restart from.
15862
15873
  */
15863
- public restart(): Promise<void>;
15874
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15864
15875
  /**
15865
15876
  * Returns the current status of the instance.
15866
15877
  */
package/index.d.ts CHANGED
@@ -13550,28 +13550,16 @@ declare namespace CloudflareWorkersModule {
13550
13550
  attempt: number;
13551
13551
  config: WorkflowStepConfig;
13552
13552
  };
13553
- export interface RollbackContext<T> {
13554
- error: Error;
13555
- output: NonNullable<T> | undefined;
13556
- stepName: string;
13557
- }
13558
- export interface StepPromise<T> extends Promise<T> {
13559
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13560
- rollback(
13561
- config: WorkflowStepConfig,
13562
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13563
- ): StepPromise<T>;
13564
- }
13565
13553
  export abstract class WorkflowStep {
13566
13554
  do<T extends Rpc.Serializable<T>>(
13567
13555
  name: string,
13568
13556
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13569
- ): StepPromise<T>;
13557
+ ): Promise<T>;
13570
13558
  do<T extends Rpc.Serializable<T>>(
13571
13559
  name: string,
13572
13560
  config: WorkflowStepConfig,
13573
13561
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13574
- ): StepPromise<T>;
13562
+ ): Promise<T>;
13575
13563
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13576
13564
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13577
13565
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13580,7 +13568,7 @@ declare namespace CloudflareWorkersModule {
13580
13568
  type: string;
13581
13569
  timeout?: WorkflowTimeoutDuration | number;
13582
13570
  },
13583
- ): StepPromise<WorkflowStepEvent<T>>;
13571
+ ): Promise<WorkflowStepEvent<T>>;
13584
13572
  }
13585
13573
  export type WorkflowInstanceStatus =
13586
13574
  | "queued"
@@ -15082,6 +15070,27 @@ interface WorkflowError {
15082
15070
  code?: number;
15083
15071
  message: string;
15084
15072
  }
15073
+ interface WorkflowInstanceRestartOptions {
15074
+ /**
15075
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15076
+ * The step must exist in the instance's execution history.
15077
+ */
15078
+ from?: {
15079
+ /**
15080
+ * The step name as defined in your workflow code.
15081
+ */
15082
+ name: string;
15083
+ /**
15084
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15085
+ * @default 1
15086
+ */
15087
+ count?: number;
15088
+ /**
15089
+ * Step type filter. Use when different step types share the same name.
15090
+ */
15091
+ type?: "do" | "sleep" | "waitForEvent";
15092
+ };
15093
+ }
15085
15094
  declare abstract class WorkflowInstance {
15086
15095
  public id: string;
15087
15096
  /**
@@ -15097,9 +15106,11 @@ declare abstract class WorkflowInstance {
15097
15106
  */
15098
15107
  public terminate(): Promise<void>;
15099
15108
  /**
15100
- * Restart the instance.
15109
+ * Restart the instance. Optionally restart from a specific step, preserving
15110
+ * cached results for all steps before it.
15111
+ * @param options Options for the restart, including an optional step to restart from.
15101
15112
  */
15102
- public restart(): Promise<void>;
15113
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15103
15114
  /**
15104
15115
  * Returns the current status of the instance.
15105
15116
  */
package/index.ts CHANGED
@@ -13521,28 +13521,16 @@ export declare namespace CloudflareWorkersModule {
13521
13521
  attempt: number;
13522
13522
  config: WorkflowStepConfig;
13523
13523
  };
13524
- export interface RollbackContext<T> {
13525
- error: Error;
13526
- output: NonNullable<T> | undefined;
13527
- stepName: string;
13528
- }
13529
- export interface StepPromise<T> extends Promise<T> {
13530
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13531
- rollback(
13532
- config: WorkflowStepConfig,
13533
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13534
- ): StepPromise<T>;
13535
- }
13536
13524
  export abstract class WorkflowStep {
13537
13525
  do<T extends Rpc.Serializable<T>>(
13538
13526
  name: string,
13539
13527
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13540
- ): StepPromise<T>;
13528
+ ): Promise<T>;
13541
13529
  do<T extends Rpc.Serializable<T>>(
13542
13530
  name: string,
13543
13531
  config: WorkflowStepConfig,
13544
13532
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13545
- ): StepPromise<T>;
13533
+ ): Promise<T>;
13546
13534
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13547
13535
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13548
13536
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13551,7 +13539,7 @@ export declare namespace CloudflareWorkersModule {
13551
13539
  type: string;
13552
13540
  timeout?: WorkflowTimeoutDuration | number;
13553
13541
  },
13554
- ): StepPromise<WorkflowStepEvent<T>>;
13542
+ ): Promise<WorkflowStepEvent<T>>;
13555
13543
  }
13556
13544
  export type WorkflowInstanceStatus =
13557
13545
  | "queued"
@@ -15034,6 +15022,27 @@ export interface WorkflowError {
15034
15022
  code?: number;
15035
15023
  message: string;
15036
15024
  }
15025
+ export interface WorkflowInstanceRestartOptions {
15026
+ /**
15027
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15028
+ * The step must exist in the instance's execution history.
15029
+ */
15030
+ from?: {
15031
+ /**
15032
+ * The step name as defined in your workflow code.
15033
+ */
15034
+ name: string;
15035
+ /**
15036
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15037
+ * @default 1
15038
+ */
15039
+ count?: number;
15040
+ /**
15041
+ * Step type filter. Use when different step types share the same name.
15042
+ */
15043
+ type?: "do" | "sleep" | "waitForEvent";
15044
+ };
15045
+ }
15037
15046
  export declare abstract class WorkflowInstance {
15038
15047
  public id: string;
15039
15048
  /**
@@ -15049,9 +15058,11 @@ export declare abstract class WorkflowInstance {
15049
15058
  */
15050
15059
  public terminate(): Promise<void>;
15051
15060
  /**
15052
- * Restart the instance.
15061
+ * Restart the instance. Optionally restart from a specific step, preserving
15062
+ * cached results for all steps before it.
15063
+ * @param options Options for the restart, including an optional step to restart from.
15053
15064
  */
15054
- public restart(): Promise<void>;
15065
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15055
15066
  /**
15056
15067
  * Returns the current status of the instance.
15057
15068
  */
package/latest/index.d.ts CHANGED
@@ -13691,28 +13691,16 @@ declare namespace CloudflareWorkersModule {
13691
13691
  attempt: number;
13692
13692
  config: WorkflowStepConfig;
13693
13693
  };
13694
- export interface RollbackContext<T> {
13695
- error: Error;
13696
- output: NonNullable<T> | undefined;
13697
- stepName: string;
13698
- }
13699
- export interface StepPromise<T> extends Promise<T> {
13700
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13701
- rollback(
13702
- config: WorkflowStepConfig,
13703
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13704
- ): StepPromise<T>;
13705
- }
13706
13694
  export abstract class WorkflowStep {
13707
13695
  do<T extends Rpc.Serializable<T>>(
13708
13696
  name: string,
13709
13697
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13710
- ): StepPromise<T>;
13698
+ ): Promise<T>;
13711
13699
  do<T extends Rpc.Serializable<T>>(
13712
13700
  name: string,
13713
13701
  config: WorkflowStepConfig,
13714
13702
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13715
- ): StepPromise<T>;
13703
+ ): Promise<T>;
13716
13704
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13717
13705
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13718
13706
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13721,7 +13709,7 @@ declare namespace CloudflareWorkersModule {
13721
13709
  type: string;
13722
13710
  timeout?: WorkflowTimeoutDuration | number;
13723
13711
  },
13724
- ): StepPromise<WorkflowStepEvent<T>>;
13712
+ ): Promise<WorkflowStepEvent<T>>;
13725
13713
  }
13726
13714
  export type WorkflowInstanceStatus =
13727
13715
  | "queued"
@@ -15223,6 +15211,27 @@ interface WorkflowError {
15223
15211
  code?: number;
15224
15212
  message: string;
15225
15213
  }
15214
+ interface WorkflowInstanceRestartOptions {
15215
+ /**
15216
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15217
+ * The step must exist in the instance's execution history.
15218
+ */
15219
+ from?: {
15220
+ /**
15221
+ * The step name as defined in your workflow code.
15222
+ */
15223
+ name: string;
15224
+ /**
15225
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15226
+ * @default 1
15227
+ */
15228
+ count?: number;
15229
+ /**
15230
+ * Step type filter. Use when different step types share the same name.
15231
+ */
15232
+ type?: "do" | "sleep" | "waitForEvent";
15233
+ };
15234
+ }
15226
15235
  declare abstract class WorkflowInstance {
15227
15236
  public id: string;
15228
15237
  /**
@@ -15238,9 +15247,11 @@ declare abstract class WorkflowInstance {
15238
15247
  */
15239
15248
  public terminate(): Promise<void>;
15240
15249
  /**
15241
- * Restart the instance.
15250
+ * Restart the instance. Optionally restart from a specific step, preserving
15251
+ * cached results for all steps before it.
15252
+ * @param options Options for the restart, including an optional step to restart from.
15242
15253
  */
15243
- public restart(): Promise<void>;
15254
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15244
15255
  /**
15245
15256
  * Returns the current status of the instance.
15246
15257
  */
package/latest/index.ts CHANGED
@@ -13662,28 +13662,16 @@ export declare namespace CloudflareWorkersModule {
13662
13662
  attempt: number;
13663
13663
  config: WorkflowStepConfig;
13664
13664
  };
13665
- export interface RollbackContext<T> {
13666
- error: Error;
13667
- output: NonNullable<T> | undefined;
13668
- stepName: string;
13669
- }
13670
- export interface StepPromise<T> extends Promise<T> {
13671
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13672
- rollback(
13673
- config: WorkflowStepConfig,
13674
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13675
- ): StepPromise<T>;
13676
- }
13677
13665
  export abstract class WorkflowStep {
13678
13666
  do<T extends Rpc.Serializable<T>>(
13679
13667
  name: string,
13680
13668
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13681
- ): StepPromise<T>;
13669
+ ): Promise<T>;
13682
13670
  do<T extends Rpc.Serializable<T>>(
13683
13671
  name: string,
13684
13672
  config: WorkflowStepConfig,
13685
13673
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13686
- ): StepPromise<T>;
13674
+ ): Promise<T>;
13687
13675
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13688
13676
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13689
13677
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13692,7 +13680,7 @@ export declare namespace CloudflareWorkersModule {
13692
13680
  type: string;
13693
13681
  timeout?: WorkflowTimeoutDuration | number;
13694
13682
  },
13695
- ): StepPromise<WorkflowStepEvent<T>>;
13683
+ ): Promise<WorkflowStepEvent<T>>;
13696
13684
  }
13697
13685
  export type WorkflowInstanceStatus =
13698
13686
  | "queued"
@@ -15175,6 +15163,27 @@ export interface WorkflowError {
15175
15163
  code?: number;
15176
15164
  message: string;
15177
15165
  }
15166
+ export interface WorkflowInstanceRestartOptions {
15167
+ /**
15168
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15169
+ * The step must exist in the instance's execution history.
15170
+ */
15171
+ from?: {
15172
+ /**
15173
+ * The step name as defined in your workflow code.
15174
+ */
15175
+ name: string;
15176
+ /**
15177
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15178
+ * @default 1
15179
+ */
15180
+ count?: number;
15181
+ /**
15182
+ * Step type filter. Use when different step types share the same name.
15183
+ */
15184
+ type?: "do" | "sleep" | "waitForEvent";
15185
+ };
15186
+ }
15178
15187
  export declare abstract class WorkflowInstance {
15179
15188
  public id: string;
15180
15189
  /**
@@ -15190,9 +15199,11 @@ export declare abstract class WorkflowInstance {
15190
15199
  */
15191
15200
  public terminate(): Promise<void>;
15192
15201
  /**
15193
- * Restart the instance.
15202
+ * Restart the instance. Optionally restart from a specific step, preserving
15203
+ * cached results for all steps before it.
15204
+ * @param options Options for the restart, including an optional step to restart from.
15194
15205
  */
15195
- public restart(): Promise<void>;
15206
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15196
15207
  /**
15197
15208
  * Returns the current status of the instance.
15198
15209
  */
package/oldest/index.d.ts CHANGED
@@ -13550,28 +13550,16 @@ declare namespace CloudflareWorkersModule {
13550
13550
  attempt: number;
13551
13551
  config: WorkflowStepConfig;
13552
13552
  };
13553
- export interface RollbackContext<T> {
13554
- error: Error;
13555
- output: NonNullable<T> | undefined;
13556
- stepName: string;
13557
- }
13558
- export interface StepPromise<T> extends Promise<T> {
13559
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13560
- rollback(
13561
- config: WorkflowStepConfig,
13562
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13563
- ): StepPromise<T>;
13564
- }
13565
13553
  export abstract class WorkflowStep {
13566
13554
  do<T extends Rpc.Serializable<T>>(
13567
13555
  name: string,
13568
13556
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13569
- ): StepPromise<T>;
13557
+ ): Promise<T>;
13570
13558
  do<T extends Rpc.Serializable<T>>(
13571
13559
  name: string,
13572
13560
  config: WorkflowStepConfig,
13573
13561
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13574
- ): StepPromise<T>;
13562
+ ): Promise<T>;
13575
13563
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13576
13564
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13577
13565
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13580,7 +13568,7 @@ declare namespace CloudflareWorkersModule {
13580
13568
  type: string;
13581
13569
  timeout?: WorkflowTimeoutDuration | number;
13582
13570
  },
13583
- ): StepPromise<WorkflowStepEvent<T>>;
13571
+ ): Promise<WorkflowStepEvent<T>>;
13584
13572
  }
13585
13573
  export type WorkflowInstanceStatus =
13586
13574
  | "queued"
@@ -15082,6 +15070,27 @@ interface WorkflowError {
15082
15070
  code?: number;
15083
15071
  message: string;
15084
15072
  }
15073
+ interface WorkflowInstanceRestartOptions {
15074
+ /**
15075
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15076
+ * The step must exist in the instance's execution history.
15077
+ */
15078
+ from?: {
15079
+ /**
15080
+ * The step name as defined in your workflow code.
15081
+ */
15082
+ name: string;
15083
+ /**
15084
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15085
+ * @default 1
15086
+ */
15087
+ count?: number;
15088
+ /**
15089
+ * Step type filter. Use when different step types share the same name.
15090
+ */
15091
+ type?: "do" | "sleep" | "waitForEvent";
15092
+ };
15093
+ }
15085
15094
  declare abstract class WorkflowInstance {
15086
15095
  public id: string;
15087
15096
  /**
@@ -15097,9 +15106,11 @@ declare abstract class WorkflowInstance {
15097
15106
  */
15098
15107
  public terminate(): Promise<void>;
15099
15108
  /**
15100
- * Restart the instance.
15109
+ * Restart the instance. Optionally restart from a specific step, preserving
15110
+ * cached results for all steps before it.
15111
+ * @param options Options for the restart, including an optional step to restart from.
15101
15112
  */
15102
- public restart(): Promise<void>;
15113
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15103
15114
  /**
15104
15115
  * Returns the current status of the instance.
15105
15116
  */
package/oldest/index.ts CHANGED
@@ -13521,28 +13521,16 @@ export declare namespace CloudflareWorkersModule {
13521
13521
  attempt: number;
13522
13522
  config: WorkflowStepConfig;
13523
13523
  };
13524
- export interface RollbackContext<T> {
13525
- error: Error;
13526
- output: NonNullable<T> | undefined;
13527
- stepName: string;
13528
- }
13529
- export interface StepPromise<T> extends Promise<T> {
13530
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13531
- rollback(
13532
- config: WorkflowStepConfig,
13533
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13534
- ): StepPromise<T>;
13535
- }
13536
13524
  export abstract class WorkflowStep {
13537
13525
  do<T extends Rpc.Serializable<T>>(
13538
13526
  name: string,
13539
13527
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13540
- ): StepPromise<T>;
13528
+ ): Promise<T>;
13541
13529
  do<T extends Rpc.Serializable<T>>(
13542
13530
  name: string,
13543
13531
  config: WorkflowStepConfig,
13544
13532
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13545
- ): StepPromise<T>;
13533
+ ): Promise<T>;
13546
13534
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13547
13535
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13548
13536
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13551,7 +13539,7 @@ export declare namespace CloudflareWorkersModule {
13551
13539
  type: string;
13552
13540
  timeout?: WorkflowTimeoutDuration | number;
13553
13541
  },
13554
- ): StepPromise<WorkflowStepEvent<T>>;
13542
+ ): Promise<WorkflowStepEvent<T>>;
13555
13543
  }
13556
13544
  export type WorkflowInstanceStatus =
13557
13545
  | "queued"
@@ -15034,6 +15022,27 @@ export interface WorkflowError {
15034
15022
  code?: number;
15035
15023
  message: string;
15036
15024
  }
15025
+ export interface WorkflowInstanceRestartOptions {
15026
+ /**
15027
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15028
+ * The step must exist in the instance's execution history.
15029
+ */
15030
+ from?: {
15031
+ /**
15032
+ * The step name as defined in your workflow code.
15033
+ */
15034
+ name: string;
15035
+ /**
15036
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15037
+ * @default 1
15038
+ */
15039
+ count?: number;
15040
+ /**
15041
+ * Step type filter. Use when different step types share the same name.
15042
+ */
15043
+ type?: "do" | "sleep" | "waitForEvent";
15044
+ };
15045
+ }
15037
15046
  export declare abstract class WorkflowInstance {
15038
15047
  public id: string;
15039
15048
  /**
@@ -15049,9 +15058,11 @@ export declare abstract class WorkflowInstance {
15049
15058
  */
15050
15059
  public terminate(): Promise<void>;
15051
15060
  /**
15052
- * Restart the instance.
15061
+ * Restart the instance. Optionally restart from a specific step, preserving
15062
+ * cached results for all steps before it.
15063
+ * @param options Options for the restart, including an optional step to restart from.
15053
15064
  */
15054
- public restart(): Promise<void>;
15065
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15055
15066
  /**
15056
15067
  * Returns the current status of the instance.
15057
15068
  */
package/package.json CHANGED
@@ -7,5 +7,5 @@
7
7
  },
8
8
  "author": "Cloudflare Workers DevProd Team <workers-devprod@cloudflare.com> (https://workers.cloudflare.com)",
9
9
  "license": "MIT OR Apache-2.0",
10
- "version": "4.20260506.1"
10
+ "version": "4.20260508.1"
11
11
  }