@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.
@@ -13647,28 +13647,16 @@ declare namespace CloudflareWorkersModule {
13647
13647
  attempt: number;
13648
13648
  config: WorkflowStepConfig;
13649
13649
  };
13650
- export interface RollbackContext<T> {
13651
- error: Error;
13652
- output: NonNullable<T> | undefined;
13653
- stepName: string;
13654
- }
13655
- export interface StepPromise<T> extends Promise<T> {
13656
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13657
- rollback(
13658
- config: WorkflowStepConfig,
13659
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13660
- ): StepPromise<T>;
13661
- }
13662
13650
  export abstract class WorkflowStep {
13663
13651
  do<T extends Rpc.Serializable<T>>(
13664
13652
  name: string,
13665
13653
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13666
- ): StepPromise<T>;
13654
+ ): Promise<T>;
13667
13655
  do<T extends Rpc.Serializable<T>>(
13668
13656
  name: string,
13669
13657
  config: WorkflowStepConfig,
13670
13658
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13671
- ): StepPromise<T>;
13659
+ ): Promise<T>;
13672
13660
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13673
13661
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13674
13662
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13677,7 +13665,7 @@ declare namespace CloudflareWorkersModule {
13677
13665
  type: string;
13678
13666
  timeout?: WorkflowTimeoutDuration | number;
13679
13667
  },
13680
- ): StepPromise<WorkflowStepEvent<T>>;
13668
+ ): Promise<WorkflowStepEvent<T>>;
13681
13669
  }
13682
13670
  export type WorkflowInstanceStatus =
13683
13671
  | "queued"
@@ -15179,6 +15167,27 @@ interface WorkflowError {
15179
15167
  code?: number;
15180
15168
  message: string;
15181
15169
  }
15170
+ interface WorkflowInstanceRestartOptions {
15171
+ /**
15172
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15173
+ * The step must exist in the instance's execution history.
15174
+ */
15175
+ from?: {
15176
+ /**
15177
+ * The step name as defined in your workflow code.
15178
+ */
15179
+ name: string;
15180
+ /**
15181
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15182
+ * @default 1
15183
+ */
15184
+ count?: number;
15185
+ /**
15186
+ * Step type filter. Use when different step types share the same name.
15187
+ */
15188
+ type?: "do" | "sleep" | "waitForEvent";
15189
+ };
15190
+ }
15182
15191
  declare abstract class WorkflowInstance {
15183
15192
  public id: string;
15184
15193
  /**
@@ -15194,9 +15203,11 @@ declare abstract class WorkflowInstance {
15194
15203
  */
15195
15204
  public terminate(): Promise<void>;
15196
15205
  /**
15197
- * Restart the instance.
15206
+ * Restart the instance. Optionally restart from a specific step, preserving
15207
+ * cached results for all steps before it.
15208
+ * @param options Options for the restart, including an optional step to restart from.
15198
15209
  */
15199
- public restart(): Promise<void>;
15210
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15200
15211
  /**
15201
15212
  * Returns the current status of the instance.
15202
15213
  */
@@ -13618,28 +13618,16 @@ export declare namespace CloudflareWorkersModule {
13618
13618
  attempt: number;
13619
13619
  config: WorkflowStepConfig;
13620
13620
  };
13621
- export interface RollbackContext<T> {
13622
- error: Error;
13623
- output: NonNullable<T> | undefined;
13624
- stepName: string;
13625
- }
13626
- export interface StepPromise<T> extends Promise<T> {
13627
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13628
- rollback(
13629
- config: WorkflowStepConfig,
13630
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13631
- ): StepPromise<T>;
13632
- }
13633
13621
  export abstract class WorkflowStep {
13634
13622
  do<T extends Rpc.Serializable<T>>(
13635
13623
  name: string,
13636
13624
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13637
- ): StepPromise<T>;
13625
+ ): Promise<T>;
13638
13626
  do<T extends Rpc.Serializable<T>>(
13639
13627
  name: string,
13640
13628
  config: WorkflowStepConfig,
13641
13629
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13642
- ): StepPromise<T>;
13630
+ ): Promise<T>;
13643
13631
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13644
13632
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13645
13633
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13648,7 +13636,7 @@ export declare namespace CloudflareWorkersModule {
13648
13636
  type: string;
13649
13637
  timeout?: WorkflowTimeoutDuration | number;
13650
13638
  },
13651
- ): StepPromise<WorkflowStepEvent<T>>;
13639
+ ): Promise<WorkflowStepEvent<T>>;
13652
13640
  }
13653
13641
  export type WorkflowInstanceStatus =
13654
13642
  | "queued"
@@ -15131,6 +15119,27 @@ export interface WorkflowError {
15131
15119
  code?: number;
15132
15120
  message: string;
15133
15121
  }
15122
+ export interface WorkflowInstanceRestartOptions {
15123
+ /**
15124
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15125
+ * The step must exist in the instance's execution history.
15126
+ */
15127
+ from?: {
15128
+ /**
15129
+ * The step name as defined in your workflow code.
15130
+ */
15131
+ name: string;
15132
+ /**
15133
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15134
+ * @default 1
15135
+ */
15136
+ count?: number;
15137
+ /**
15138
+ * Step type filter. Use when different step types share the same name.
15139
+ */
15140
+ type?: "do" | "sleep" | "waitForEvent";
15141
+ };
15142
+ }
15134
15143
  export declare abstract class WorkflowInstance {
15135
15144
  public id: string;
15136
15145
  /**
@@ -15146,9 +15155,11 @@ export declare abstract class WorkflowInstance {
15146
15155
  */
15147
15156
  public terminate(): Promise<void>;
15148
15157
  /**
15149
- * Restart the instance.
15158
+ * Restart the instance. Optionally restart from a specific step, preserving
15159
+ * cached results for all steps before it.
15160
+ * @param options Options for the restart, including an optional step to restart from.
15150
15161
  */
15151
- public restart(): Promise<void>;
15162
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15152
15163
  /**
15153
15164
  * Returns the current status of the instance.
15154
15165
  */
@@ -13652,28 +13652,16 @@ declare namespace CloudflareWorkersModule {
13652
13652
  attempt: number;
13653
13653
  config: WorkflowStepConfig;
13654
13654
  };
13655
- export interface RollbackContext<T> {
13656
- error: Error;
13657
- output: NonNullable<T> | undefined;
13658
- stepName: string;
13659
- }
13660
- export interface StepPromise<T> extends Promise<T> {
13661
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13662
- rollback(
13663
- config: WorkflowStepConfig,
13664
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13665
- ): StepPromise<T>;
13666
- }
13667
13655
  export abstract class WorkflowStep {
13668
13656
  do<T extends Rpc.Serializable<T>>(
13669
13657
  name: string,
13670
13658
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13671
- ): StepPromise<T>;
13659
+ ): Promise<T>;
13672
13660
  do<T extends Rpc.Serializable<T>>(
13673
13661
  name: string,
13674
13662
  config: WorkflowStepConfig,
13675
13663
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13676
- ): StepPromise<T>;
13664
+ ): Promise<T>;
13677
13665
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13678
13666
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13679
13667
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13682,7 +13670,7 @@ declare namespace CloudflareWorkersModule {
13682
13670
  type: string;
13683
13671
  timeout?: WorkflowTimeoutDuration | number;
13684
13672
  },
13685
- ): StepPromise<WorkflowStepEvent<T>>;
13673
+ ): Promise<WorkflowStepEvent<T>>;
13686
13674
  }
13687
13675
  export type WorkflowInstanceStatus =
13688
13676
  | "queued"
@@ -15184,6 +15172,27 @@ interface WorkflowError {
15184
15172
  code?: number;
15185
15173
  message: string;
15186
15174
  }
15175
+ interface WorkflowInstanceRestartOptions {
15176
+ /**
15177
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15178
+ * The step must exist in the instance's execution history.
15179
+ */
15180
+ from?: {
15181
+ /**
15182
+ * The step name as defined in your workflow code.
15183
+ */
15184
+ name: string;
15185
+ /**
15186
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15187
+ * @default 1
15188
+ */
15189
+ count?: number;
15190
+ /**
15191
+ * Step type filter. Use when different step types share the same name.
15192
+ */
15193
+ type?: "do" | "sleep" | "waitForEvent";
15194
+ };
15195
+ }
15187
15196
  declare abstract class WorkflowInstance {
15188
15197
  public id: string;
15189
15198
  /**
@@ -15199,9 +15208,11 @@ declare abstract class WorkflowInstance {
15199
15208
  */
15200
15209
  public terminate(): Promise<void>;
15201
15210
  /**
15202
- * Restart the instance.
15211
+ * Restart the instance. Optionally restart from a specific step, preserving
15212
+ * cached results for all steps before it.
15213
+ * @param options Options for the restart, including an optional step to restart from.
15203
15214
  */
15204
- public restart(): Promise<void>;
15215
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15205
15216
  /**
15206
15217
  * Returns the current status of the instance.
15207
15218
  */
@@ -13623,28 +13623,16 @@ export declare namespace CloudflareWorkersModule {
13623
13623
  attempt: number;
13624
13624
  config: WorkflowStepConfig;
13625
13625
  };
13626
- export interface RollbackContext<T> {
13627
- error: Error;
13628
- output: NonNullable<T> | undefined;
13629
- stepName: string;
13630
- }
13631
- export interface StepPromise<T> extends Promise<T> {
13632
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13633
- rollback(
13634
- config: WorkflowStepConfig,
13635
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13636
- ): StepPromise<T>;
13637
- }
13638
13626
  export abstract class WorkflowStep {
13639
13627
  do<T extends Rpc.Serializable<T>>(
13640
13628
  name: string,
13641
13629
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13642
- ): StepPromise<T>;
13630
+ ): Promise<T>;
13643
13631
  do<T extends Rpc.Serializable<T>>(
13644
13632
  name: string,
13645
13633
  config: WorkflowStepConfig,
13646
13634
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13647
- ): StepPromise<T>;
13635
+ ): Promise<T>;
13648
13636
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13649
13637
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13650
13638
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13653,7 +13641,7 @@ export declare namespace CloudflareWorkersModule {
13653
13641
  type: string;
13654
13642
  timeout?: WorkflowTimeoutDuration | number;
13655
13643
  },
13656
- ): StepPromise<WorkflowStepEvent<T>>;
13644
+ ): Promise<WorkflowStepEvent<T>>;
13657
13645
  }
13658
13646
  export type WorkflowInstanceStatus =
13659
13647
  | "queued"
@@ -15136,6 +15124,27 @@ export interface WorkflowError {
15136
15124
  code?: number;
15137
15125
  message: string;
15138
15126
  }
15127
+ export interface WorkflowInstanceRestartOptions {
15128
+ /**
15129
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15130
+ * The step must exist in the instance's execution history.
15131
+ */
15132
+ from?: {
15133
+ /**
15134
+ * The step name as defined in your workflow code.
15135
+ */
15136
+ name: string;
15137
+ /**
15138
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15139
+ * @default 1
15140
+ */
15141
+ count?: number;
15142
+ /**
15143
+ * Step type filter. Use when different step types share the same name.
15144
+ */
15145
+ type?: "do" | "sleep" | "waitForEvent";
15146
+ };
15147
+ }
15139
15148
  export declare abstract class WorkflowInstance {
15140
15149
  public id: string;
15141
15150
  /**
@@ -15151,9 +15160,11 @@ export declare abstract class WorkflowInstance {
15151
15160
  */
15152
15161
  public terminate(): Promise<void>;
15153
15162
  /**
15154
- * Restart the instance.
15163
+ * Restart the instance. Optionally restart from a specific step, preserving
15164
+ * cached results for all steps before it.
15165
+ * @param options Options for the restart, including an optional step to restart from.
15155
15166
  */
15156
- public restart(): Promise<void>;
15167
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15157
15168
  /**
15158
15169
  * Returns the current status of the instance.
15159
15170
  */
@@ -13658,28 +13658,16 @@ declare namespace CloudflareWorkersModule {
13658
13658
  attempt: number;
13659
13659
  config: WorkflowStepConfig;
13660
13660
  };
13661
- export interface RollbackContext<T> {
13662
- error: Error;
13663
- output: NonNullable<T> | undefined;
13664
- stepName: string;
13665
- }
13666
- export interface StepPromise<T> extends Promise<T> {
13667
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13668
- rollback(
13669
- config: WorkflowStepConfig,
13670
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13671
- ): StepPromise<T>;
13672
- }
13673
13661
  export abstract class WorkflowStep {
13674
13662
  do<T extends Rpc.Serializable<T>>(
13675
13663
  name: string,
13676
13664
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13677
- ): StepPromise<T>;
13665
+ ): Promise<T>;
13678
13666
  do<T extends Rpc.Serializable<T>>(
13679
13667
  name: string,
13680
13668
  config: WorkflowStepConfig,
13681
13669
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13682
- ): StepPromise<T>;
13670
+ ): Promise<T>;
13683
13671
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13684
13672
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13685
13673
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13688,7 +13676,7 @@ declare namespace CloudflareWorkersModule {
13688
13676
  type: string;
13689
13677
  timeout?: WorkflowTimeoutDuration | number;
13690
13678
  },
13691
- ): StepPromise<WorkflowStepEvent<T>>;
13679
+ ): Promise<WorkflowStepEvent<T>>;
13692
13680
  }
13693
13681
  export type WorkflowInstanceStatus =
13694
13682
  | "queued"
@@ -15190,6 +15178,27 @@ interface WorkflowError {
15190
15178
  code?: number;
15191
15179
  message: string;
15192
15180
  }
15181
+ interface WorkflowInstanceRestartOptions {
15182
+ /**
15183
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15184
+ * The step must exist in the instance's execution history.
15185
+ */
15186
+ from?: {
15187
+ /**
15188
+ * The step name as defined in your workflow code.
15189
+ */
15190
+ name: string;
15191
+ /**
15192
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15193
+ * @default 1
15194
+ */
15195
+ count?: number;
15196
+ /**
15197
+ * Step type filter. Use when different step types share the same name.
15198
+ */
15199
+ type?: "do" | "sleep" | "waitForEvent";
15200
+ };
15201
+ }
15193
15202
  declare abstract class WorkflowInstance {
15194
15203
  public id: string;
15195
15204
  /**
@@ -15205,9 +15214,11 @@ declare abstract class WorkflowInstance {
15205
15214
  */
15206
15215
  public terminate(): Promise<void>;
15207
15216
  /**
15208
- * Restart the instance.
15217
+ * Restart the instance. Optionally restart from a specific step, preserving
15218
+ * cached results for all steps before it.
15219
+ * @param options Options for the restart, including an optional step to restart from.
15209
15220
  */
15210
- public restart(): Promise<void>;
15221
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15211
15222
  /**
15212
15223
  * Returns the current status of the instance.
15213
15224
  */
@@ -13629,28 +13629,16 @@ export declare namespace CloudflareWorkersModule {
13629
13629
  attempt: number;
13630
13630
  config: WorkflowStepConfig;
13631
13631
  };
13632
- export interface RollbackContext<T> {
13633
- error: Error;
13634
- output: NonNullable<T> | undefined;
13635
- stepName: string;
13636
- }
13637
- export interface StepPromise<T> extends Promise<T> {
13638
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13639
- rollback(
13640
- config: WorkflowStepConfig,
13641
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13642
- ): StepPromise<T>;
13643
- }
13644
13632
  export abstract class WorkflowStep {
13645
13633
  do<T extends Rpc.Serializable<T>>(
13646
13634
  name: string,
13647
13635
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13648
- ): StepPromise<T>;
13636
+ ): Promise<T>;
13649
13637
  do<T extends Rpc.Serializable<T>>(
13650
13638
  name: string,
13651
13639
  config: WorkflowStepConfig,
13652
13640
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13653
- ): StepPromise<T>;
13641
+ ): Promise<T>;
13654
13642
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13655
13643
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13656
13644
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13659,7 +13647,7 @@ export declare namespace CloudflareWorkersModule {
13659
13647
  type: string;
13660
13648
  timeout?: WorkflowTimeoutDuration | number;
13661
13649
  },
13662
- ): StepPromise<WorkflowStepEvent<T>>;
13650
+ ): Promise<WorkflowStepEvent<T>>;
13663
13651
  }
13664
13652
  export type WorkflowInstanceStatus =
13665
13653
  | "queued"
@@ -15142,6 +15130,27 @@ export interface WorkflowError {
15142
15130
  code?: number;
15143
15131
  message: string;
15144
15132
  }
15133
+ export interface WorkflowInstanceRestartOptions {
15134
+ /**
15135
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15136
+ * The step must exist in the instance's execution history.
15137
+ */
15138
+ from?: {
15139
+ /**
15140
+ * The step name as defined in your workflow code.
15141
+ */
15142
+ name: string;
15143
+ /**
15144
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15145
+ * @default 1
15146
+ */
15147
+ count?: number;
15148
+ /**
15149
+ * Step type filter. Use when different step types share the same name.
15150
+ */
15151
+ type?: "do" | "sleep" | "waitForEvent";
15152
+ };
15153
+ }
15145
15154
  export declare abstract class WorkflowInstance {
15146
15155
  public id: string;
15147
15156
  /**
@@ -15157,9 +15166,11 @@ export declare abstract class WorkflowInstance {
15157
15166
  */
15158
15167
  public terminate(): Promise<void>;
15159
15168
  /**
15160
- * Restart the instance.
15169
+ * Restart the instance. Optionally restart from a specific step, preserving
15170
+ * cached results for all steps before it.
15171
+ * @param options Options for the restart, including an optional step to restart from.
15161
15172
  */
15162
- public restart(): Promise<void>;
15173
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15163
15174
  /**
15164
15175
  * Returns the current status of the instance.
15165
15176
  */
@@ -13658,28 +13658,16 @@ declare namespace CloudflareWorkersModule {
13658
13658
  attempt: number;
13659
13659
  config: WorkflowStepConfig;
13660
13660
  };
13661
- export interface RollbackContext<T> {
13662
- error: Error;
13663
- output: NonNullable<T> | undefined;
13664
- stepName: string;
13665
- }
13666
- export interface StepPromise<T> extends Promise<T> {
13667
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13668
- rollback(
13669
- config: WorkflowStepConfig,
13670
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13671
- ): StepPromise<T>;
13672
- }
13673
13661
  export abstract class WorkflowStep {
13674
13662
  do<T extends Rpc.Serializable<T>>(
13675
13663
  name: string,
13676
13664
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13677
- ): StepPromise<T>;
13665
+ ): Promise<T>;
13678
13666
  do<T extends Rpc.Serializable<T>>(
13679
13667
  name: string,
13680
13668
  config: WorkflowStepConfig,
13681
13669
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13682
- ): StepPromise<T>;
13670
+ ): Promise<T>;
13683
13671
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13684
13672
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13685
13673
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13688,7 +13676,7 @@ declare namespace CloudflareWorkersModule {
13688
13676
  type: string;
13689
13677
  timeout?: WorkflowTimeoutDuration | number;
13690
13678
  },
13691
- ): StepPromise<WorkflowStepEvent<T>>;
13679
+ ): Promise<WorkflowStepEvent<T>>;
13692
13680
  }
13693
13681
  export type WorkflowInstanceStatus =
13694
13682
  | "queued"
@@ -15190,6 +15178,27 @@ interface WorkflowError {
15190
15178
  code?: number;
15191
15179
  message: string;
15192
15180
  }
15181
+ interface WorkflowInstanceRestartOptions {
15182
+ /**
15183
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15184
+ * The step must exist in the instance's execution history.
15185
+ */
15186
+ from?: {
15187
+ /**
15188
+ * The step name as defined in your workflow code.
15189
+ */
15190
+ name: string;
15191
+ /**
15192
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15193
+ * @default 1
15194
+ */
15195
+ count?: number;
15196
+ /**
15197
+ * Step type filter. Use when different step types share the same name.
15198
+ */
15199
+ type?: "do" | "sleep" | "waitForEvent";
15200
+ };
15201
+ }
15193
15202
  declare abstract class WorkflowInstance {
15194
15203
  public id: string;
15195
15204
  /**
@@ -15205,9 +15214,11 @@ declare abstract class WorkflowInstance {
15205
15214
  */
15206
15215
  public terminate(): Promise<void>;
15207
15216
  /**
15208
- * Restart the instance.
15217
+ * Restart the instance. Optionally restart from a specific step, preserving
15218
+ * cached results for all steps before it.
15219
+ * @param options Options for the restart, including an optional step to restart from.
15209
15220
  */
15210
- public restart(): Promise<void>;
15221
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15211
15222
  /**
15212
15223
  * Returns the current status of the instance.
15213
15224
  */
@@ -13629,28 +13629,16 @@ export declare namespace CloudflareWorkersModule {
13629
13629
  attempt: number;
13630
13630
  config: WorkflowStepConfig;
13631
13631
  };
13632
- export interface RollbackContext<T> {
13633
- error: Error;
13634
- output: NonNullable<T> | undefined;
13635
- stepName: string;
13636
- }
13637
- export interface StepPromise<T> extends Promise<T> {
13638
- rollback(fn: (ctx: RollbackContext<T>) => Promise<void>): StepPromise<T>;
13639
- rollback(
13640
- config: WorkflowStepConfig,
13641
- fn: (ctx: RollbackContext<T>) => Promise<void>,
13642
- ): StepPromise<T>;
13643
- }
13644
13632
  export abstract class WorkflowStep {
13645
13633
  do<T extends Rpc.Serializable<T>>(
13646
13634
  name: string,
13647
13635
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13648
- ): StepPromise<T>;
13636
+ ): Promise<T>;
13649
13637
  do<T extends Rpc.Serializable<T>>(
13650
13638
  name: string,
13651
13639
  config: WorkflowStepConfig,
13652
13640
  callback: (ctx: WorkflowStepContext) => Promise<T>,
13653
- ): StepPromise<T>;
13641
+ ): Promise<T>;
13654
13642
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13655
13643
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13656
13644
  waitForEvent<T extends Rpc.Serializable<T>>(
@@ -13659,7 +13647,7 @@ export declare namespace CloudflareWorkersModule {
13659
13647
  type: string;
13660
13648
  timeout?: WorkflowTimeoutDuration | number;
13661
13649
  },
13662
- ): StepPromise<WorkflowStepEvent<T>>;
13650
+ ): Promise<WorkflowStepEvent<T>>;
13663
13651
  }
13664
13652
  export type WorkflowInstanceStatus =
13665
13653
  | "queued"
@@ -15142,6 +15130,27 @@ export interface WorkflowError {
15142
15130
  code?: number;
15143
15131
  message: string;
15144
15132
  }
15133
+ export interface WorkflowInstanceRestartOptions {
15134
+ /**
15135
+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
15136
+ * The step must exist in the instance's execution history.
15137
+ */
15138
+ from?: {
15139
+ /**
15140
+ * The step name as defined in your workflow code.
15141
+ */
15142
+ name: string;
15143
+ /**
15144
+ * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15145
+ * @default 1
15146
+ */
15147
+ count?: number;
15148
+ /**
15149
+ * Step type filter. Use when different step types share the same name.
15150
+ */
15151
+ type?: "do" | "sleep" | "waitForEvent";
15152
+ };
15153
+ }
15145
15154
  export declare abstract class WorkflowInstance {
15146
15155
  public id: string;
15147
15156
  /**
@@ -15157,9 +15166,11 @@ export declare abstract class WorkflowInstance {
15157
15166
  */
15158
15167
  public terminate(): Promise<void>;
15159
15168
  /**
15160
- * Restart the instance.
15169
+ * Restart the instance. Optionally restart from a specific step, preserving
15170
+ * cached results for all steps before it.
15171
+ * @param options Options for the restart, including an optional step to restart from.
15161
15172
  */
15162
- public restart(): Promise<void>;
15173
+ public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15163
15174
  /**
15164
15175
  * Returns the current status of the instance.
15165
15176
  */