@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.
@@ -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
  */
@@ -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
  */
@@ -13617,28 +13617,16 @@ declare namespace CloudflareWorkersModule {
13617
13617
  attempt: number;
13618
13618
  config: WorkflowStepConfig;
13619
13619
  };
13620
- export interface RollbackContext<T> {
13621
- error: Error;
13622
- output: NonNullable<T> | undefined;
13623
- stepName: string;
13624
- }
13625
- export interface StepPromise<T> extends Promise<T> {
13626
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13627
- rollback(
13628
- config: WorkflowStepConfig,
13629
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13630
- ): StepPromise<T>;
13631
- }
13632
13620
  export abstract class WorkflowStep {
13633
13621
  do<T extends Rpc.Serializable<T>>(
13634
13622
  name: string,
13635
13623
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13636
- ): StepPromise<T>;
13624
+ ): Promise<T>;
13637
13625
  do<T extends Rpc.Serializable<T>>(
13638
13626
  name: string,
13639
13627
  config: WorkflowStepConfig,
13640
13628
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13641
- ): StepPromise<T>;
13629
+ ): Promise<T>;
13642
13630
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13643
13631
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13644
13632
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13647,7 +13635,7 @@ declare namespace CloudflareWorkersModule {
13647
13635
  type: string;
13648
13636
  timeout?: WorkflowTimeoutDuration | number;
13649
13637
  },
13650
- ): StepPromise<WorkflowStepEvent<T>>;
13638
+ ): Promise<WorkflowStepEvent<T>>;
13651
13639
  }
13652
13640
  export type WorkflowInstanceStatus =
13653
13641
  | "queued"
@@ -15149,6 +15137,27 @@ interface WorkflowError {
15149
15137
  code?: number;
15150
15138
  message: string;
15151
15139
  }
15140
+ interface WorkflowInstanceRestartOptions {
15141
+ /**
15142
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15143
+ * The step must exist in the instance's execution history.
15144
+ */
15145
+ from?: {
15146
+ /**
15147
+ * The step name as defined in your workflow code.
15148
+ */
15149
+ name: string;
15150
+ /**
15151
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15152
+ * @default 1
15153
+ */
15154
+ count?: number;
15155
+ /**
15156
+ * Step type filter. Use when different step types share the same name.
15157
+ */
15158
+ type?: "do" | "sleep" | "waitForEvent";
15159
+ };
15160
+ }
15152
15161
  declare abstract class WorkflowInstance {
15153
15162
  public id: string;
15154
15163
  /**
@@ -15164,9 +15173,11 @@ declare abstract class WorkflowInstance {
15164
15173
  */
15165
15174
  public terminate(): Promise<void>;
15166
15175
  /**
15167
- * Restart the instance.
15176
+ * Restart the instance. Optionally restart from a specific step, preserving
15177
+ * cached results for all steps before it.
15178
+ * @param options Options for the restart, including an optional step to restart from.
15168
15179
  */
15169
- public restart(): Promise<void>;
15180
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15170
15181
  /**
15171
15182
  * Returns the current status of the instance.
15172
15183
  */
@@ -13588,28 +13588,16 @@ export declare namespace CloudflareWorkersModule {
13588
13588
  attempt: number;
13589
13589
  config: WorkflowStepConfig;
13590
13590
  };
13591
- export interface RollbackContext<T> {
13592
- error: Error;
13593
- output: NonNullable<T> | undefined;
13594
- stepName: string;
13595
- }
13596
- export interface StepPromise<T> extends Promise<T> {
13597
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13598
- rollback(
13599
- config: WorkflowStepConfig,
13600
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13601
- ): StepPromise<T>;
13602
- }
13603
13591
  export abstract class WorkflowStep {
13604
13592
  do<T extends Rpc.Serializable<T>>(
13605
13593
  name: string,
13606
13594
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13607
- ): StepPromise<T>;
13595
+ ): Promise<T>;
13608
13596
  do<T extends Rpc.Serializable<T>>(
13609
13597
  name: string,
13610
13598
  config: WorkflowStepConfig,
13611
13599
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13612
- ): StepPromise<T>;
13600
+ ): Promise<T>;
13613
13601
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13614
13602
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13615
13603
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13618,7 +13606,7 @@ export declare namespace CloudflareWorkersModule {
13618
13606
  type: string;
13619
13607
  timeout?: WorkflowTimeoutDuration | number;
13620
13608
  },
13621
- ): StepPromise<WorkflowStepEvent<T>>;
13609
+ ): Promise<WorkflowStepEvent<T>>;
13622
13610
  }
13623
13611
  export type WorkflowInstanceStatus =
13624
13612
  | "queued"
@@ -15101,6 +15089,27 @@ export interface WorkflowError {
15101
15089
  code?: number;
15102
15090
  message: string;
15103
15091
  }
15092
+ export interface WorkflowInstanceRestartOptions {
15093
+ /**
15094
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15095
+ * The step must exist in the instance's execution history.
15096
+ */
15097
+ from?: {
15098
+ /**
15099
+ * The step name as defined in your workflow code.
15100
+ */
15101
+ name: string;
15102
+ /**
15103
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15104
+ * @default 1
15105
+ */
15106
+ count?: number;
15107
+ /**
15108
+ * Step type filter. Use when different step types share the same name.
15109
+ */
15110
+ type?: "do" | "sleep" | "waitForEvent";
15111
+ };
15112
+ }
15104
15113
  export declare abstract class WorkflowInstance {
15105
15114
  public id: string;
15106
15115
  /**
@@ -15116,9 +15125,11 @@ export declare abstract class WorkflowInstance {
15116
15125
  */
15117
15126
  public terminate(): Promise<void>;
15118
15127
  /**
15119
- * Restart the instance.
15128
+ * Restart the instance. Optionally restart from a specific step, preserving
15129
+ * cached results for all steps before it.
15130
+ * @param options Options for the restart, including an optional step to restart from.
15120
15131
  */
15121
- public restart(): Promise<void>;
15132
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15122
15133
  /**
15123
15134
  * Returns the current status of the instance.
15124
15135
  */
@@ -13626,28 +13626,16 @@ declare namespace CloudflareWorkersModule {
13626
13626
  attempt: number;
13627
13627
  config: WorkflowStepConfig;
13628
13628
  };
13629
- export interface RollbackContext<T> {
13630
- error: Error;
13631
- output: NonNullable<T> | undefined;
13632
- stepName: string;
13633
- }
13634
- export interface StepPromise<T> extends Promise<T> {
13635
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13636
- rollback(
13637
- config: WorkflowStepConfig,
13638
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13639
- ): StepPromise<T>;
13640
- }
13641
13629
  export abstract class WorkflowStep {
13642
13630
  do<T extends Rpc.Serializable<T>>(
13643
13631
  name: string,
13644
13632
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13645
- ): StepPromise<T>;
13633
+ ): Promise<T>;
13646
13634
  do<T extends Rpc.Serializable<T>>(
13647
13635
  name: string,
13648
13636
  config: WorkflowStepConfig,
13649
13637
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13650
- ): StepPromise<T>;
13638
+ ): Promise<T>;
13651
13639
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13652
13640
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13653
13641
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13656,7 +13644,7 @@ declare namespace CloudflareWorkersModule {
13656
13644
  type: string;
13657
13645
  timeout?: WorkflowTimeoutDuration | number;
13658
13646
  },
13659
- ): StepPromise<WorkflowStepEvent<T>>;
13647
+ ): Promise<WorkflowStepEvent<T>>;
13660
13648
  }
13661
13649
  export type WorkflowInstanceStatus =
13662
13650
  | "queued"
@@ -15158,6 +15146,27 @@ interface WorkflowError {
15158
15146
  code?: number;
15159
15147
  message: string;
15160
15148
  }
15149
+ interface WorkflowInstanceRestartOptions {
15150
+ /**
15151
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15152
+ * The step must exist in the instance's execution history.
15153
+ */
15154
+ from?: {
15155
+ /**
15156
+ * The step name as defined in your workflow code.
15157
+ */
15158
+ name: string;
15159
+ /**
15160
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15161
+ * @default 1
15162
+ */
15163
+ count?: number;
15164
+ /**
15165
+ * Step type filter. Use when different step types share the same name.
15166
+ */
15167
+ type?: "do" | "sleep" | "waitForEvent";
15168
+ };
15169
+ }
15161
15170
  declare abstract class WorkflowInstance {
15162
15171
  public id: string;
15163
15172
  /**
@@ -15173,9 +15182,11 @@ declare abstract class WorkflowInstance {
15173
15182
  */
15174
15183
  public terminate(): Promise<void>;
15175
15184
  /**
15176
- * Restart the instance.
15185
+ * Restart the instance. Optionally restart from a specific step, preserving
15186
+ * cached results for all steps before it.
15187
+ * @param options Options for the restart, including an optional step to restart from.
15177
15188
  */
15178
- public restart(): Promise<void>;
15189
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15179
15190
  /**
15180
15191
  * Returns the current status of the instance.
15181
15192
  */
@@ -13597,28 +13597,16 @@ export declare namespace CloudflareWorkersModule {
13597
13597
  attempt: number;
13598
13598
  config: WorkflowStepConfig;
13599
13599
  };
13600
- export interface RollbackContext<T> {
13601
- error: Error;
13602
- output: NonNullable<T> | undefined;
13603
- stepName: string;
13604
- }
13605
- export interface StepPromise<T> extends Promise<T> {
13606
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13607
- rollback(
13608
- config: WorkflowStepConfig,
13609
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13610
- ): StepPromise<T>;
13611
- }
13612
13600
  export abstract class WorkflowStep {
13613
13601
  do<T extends Rpc.Serializable<T>>(
13614
13602
  name: string,
13615
13603
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13616
- ): StepPromise<T>;
13604
+ ): Promise<T>;
13617
13605
  do<T extends Rpc.Serializable<T>>(
13618
13606
  name: string,
13619
13607
  config: WorkflowStepConfig,
13620
13608
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13621
- ): StepPromise<T>;
13609
+ ): Promise<T>;
13622
13610
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13623
13611
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13624
13612
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13627,7 +13615,7 @@ export declare namespace CloudflareWorkersModule {
13627
13615
  type: string;
13628
13616
  timeout?: WorkflowTimeoutDuration | number;
13629
13617
  },
13630
- ): StepPromise<WorkflowStepEvent<T>>;
13618
+ ): Promise<WorkflowStepEvent<T>>;
13631
13619
  }
13632
13620
  export type WorkflowInstanceStatus =
13633
13621
  | "queued"
@@ -15110,6 +15098,27 @@ export interface WorkflowError {
15110
15098
  code?: number;
15111
15099
  message: string;
15112
15100
  }
15101
+ export interface WorkflowInstanceRestartOptions {
15102
+ /**
15103
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15104
+ * The step must exist in the instance's execution history.
15105
+ */
15106
+ from?: {
15107
+ /**
15108
+ * The step name as defined in your workflow code.
15109
+ */
15110
+ name: string;
15111
+ /**
15112
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15113
+ * @default 1
15114
+ */
15115
+ count?: number;
15116
+ /**
15117
+ * Step type filter. Use when different step types share the same name.
15118
+ */
15119
+ type?: "do" | "sleep" | "waitForEvent";
15120
+ };
15121
+ }
15113
15122
  export declare abstract class WorkflowInstance {
15114
15123
  public id: string;
15115
15124
  /**
@@ -15125,9 +15134,11 @@ export declare abstract class WorkflowInstance {
15125
15134
  */
15126
15135
  public terminate(): Promise<void>;
15127
15136
  /**
15128
- * Restart the instance.
15137
+ * Restart the instance. Optionally restart from a specific step, preserving
15138
+ * cached results for all steps before it.
15139
+ * @param options Options for the restart, including an optional step to restart from.
15129
15140
  */
15130
- public restart(): Promise<void>;
15141
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15131
15142
  /**
15132
15143
  * Returns the current status of the instance.
15133
15144
  */
@@ -13627,28 +13627,16 @@ declare namespace CloudflareWorkersModule {
13627
13627
  attempt: number;
13628
13628
  config: WorkflowStepConfig;
13629
13629
  };
13630
- export interface RollbackContext<T> {
13631
- error: Error;
13632
- output: NonNullable<T> | undefined;
13633
- stepName: string;
13634
- }
13635
- export interface StepPromise<T> extends Promise<T> {
13636
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13637
- rollback(
13638
- config: WorkflowStepConfig,
13639
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13640
- ): StepPromise<T>;
13641
- }
13642
13630
  export abstract class WorkflowStep {
13643
13631
  do<T extends Rpc.Serializable<T>>(
13644
13632
  name: string,
13645
13633
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13646
- ): StepPromise<T>;
13634
+ ): Promise<T>;
13647
13635
  do<T extends Rpc.Serializable<T>>(
13648
13636
  name: string,
13649
13637
  config: WorkflowStepConfig,
13650
13638
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13651
- ): StepPromise<T>;
13639
+ ): Promise<T>;
13652
13640
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13653
13641
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13654
13642
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13657,7 +13645,7 @@ declare namespace CloudflareWorkersModule {
13657
13645
  type: string;
13658
13646
  timeout?: WorkflowTimeoutDuration | number;
13659
13647
  },
13660
- ): StepPromise<WorkflowStepEvent<T>>;
13648
+ ): Promise<WorkflowStepEvent<T>>;
13661
13649
  }
13662
13650
  export type WorkflowInstanceStatus =
13663
13651
  | "queued"
@@ -15159,6 +15147,27 @@ interface WorkflowError {
15159
15147
  code?: number;
15160
15148
  message: string;
15161
15149
  }
15150
+ interface WorkflowInstanceRestartOptions {
15151
+ /**
15152
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15153
+ * The step must exist in the instance's execution history.
15154
+ */
15155
+ from?: {
15156
+ /**
15157
+ * The step name as defined in your workflow code.
15158
+ */
15159
+ name: string;
15160
+ /**
15161
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15162
+ * @default 1
15163
+ */
15164
+ count?: number;
15165
+ /**
15166
+ * Step type filter. Use when different step types share the same name.
15167
+ */
15168
+ type?: "do" | "sleep" | "waitForEvent";
15169
+ };
15170
+ }
15162
15171
  declare abstract class WorkflowInstance {
15163
15172
  public id: string;
15164
15173
  /**
@@ -15174,9 +15183,11 @@ declare abstract class WorkflowInstance {
15174
15183
  */
15175
15184
  public terminate(): Promise<void>;
15176
15185
  /**
15177
- * Restart the instance.
15186
+ * Restart the instance. Optionally restart from a specific step, preserving
15187
+ * cached results for all steps before it.
15188
+ * @param options Options for the restart, including an optional step to restart from.
15178
15189
  */
15179
- public restart(): Promise<void>;
15190
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15180
15191
  /**
15181
15192
  * Returns the current status of the instance.
15182
15193
  */
@@ -13598,28 +13598,16 @@ export declare namespace CloudflareWorkersModule {
13598
13598
  attempt: number;
13599
13599
  config: WorkflowStepConfig;
13600
13600
  };
13601
- export interface RollbackContext<T> {
13602
- error: Error;
13603
- output: NonNullable<T> | undefined;
13604
- stepName: string;
13605
- }
13606
- export interface StepPromise<T> extends Promise<T> {
13607
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13608
- rollback(
13609
- config: WorkflowStepConfig,
13610
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13611
- ): StepPromise<T>;
13612
- }
13613
13601
  export abstract class WorkflowStep {
13614
13602
  do<T extends Rpc.Serializable<T>>(
13615
13603
  name: string,
13616
13604
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13617
- ): StepPromise<T>;
13605
+ ): Promise<T>;
13618
13606
  do<T extends Rpc.Serializable<T>>(
13619
13607
  name: string,
13620
13608
  config: WorkflowStepConfig,
13621
13609
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13622
- ): StepPromise<T>;
13610
+ ): Promise<T>;
13623
13611
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13624
13612
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13625
13613
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13628,7 +13616,7 @@ export declare namespace CloudflareWorkersModule {
13628
13616
  type: string;
13629
13617
  timeout?: WorkflowTimeoutDuration | number;
13630
13618
  },
13631
- ): StepPromise<WorkflowStepEvent<T>>;
13619
+ ): Promise<WorkflowStepEvent<T>>;
13632
13620
  }
13633
13621
  export type WorkflowInstanceStatus =
13634
13622
  | "queued"
@@ -15111,6 +15099,27 @@ export interface WorkflowError {
15111
15099
  code?: number;
15112
15100
  message: string;
15113
15101
  }
15102
+ export interface WorkflowInstanceRestartOptions {
15103
+ /**
15104
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15105
+ * The step must exist in the instance's execution history.
15106
+ */
15107
+ from?: {
15108
+ /**
15109
+ * The step name as defined in your workflow code.
15110
+ */
15111
+ name: string;
15112
+ /**
15113
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15114
+ * @default 1
15115
+ */
15116
+ count?: number;
15117
+ /**
15118
+ * Step type filter. Use when different step types share the same name.
15119
+ */
15120
+ type?: "do" | "sleep" | "waitForEvent";
15121
+ };
15122
+ }
15114
15123
  export declare abstract class WorkflowInstance {
15115
15124
  public id: string;
15116
15125
  /**
@@ -15126,9 +15135,11 @@ export declare abstract class WorkflowInstance {
15126
15135
  */
15127
15136
  public terminate(): Promise<void>;
15128
15137
  /**
15129
- * Restart the instance.
15138
+ * Restart the instance. Optionally restart from a specific step, preserving
15139
+ * cached results for all steps before it.
15140
+ * @param options Options for the restart, including an optional step to restart from.
15130
15141
  */
15131
- public restart(): Promise<void>;
15142
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15132
15143
  /**
15133
15144
  * Returns the current status of the instance.
15134
15145
  */