Skip to content

Commit ef038d9

Browse files
committed
Update workflow terminate rollback typing
1 parent 2bbcc3c commit ef038d9

5 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/miniflare/scripts/openapi-filter-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ const config = {
11721172
rollback: {
11731173
type: "boolean",
11741174
description:
1175-
"Run rollback before terminating. Only valid when action is terminate.",
1175+
"The option to trigger rollbacks when terminating the workflow instance.",
11761176
},
11771177
},
11781178
},

packages/miniflare/src/workers/local-explorer/generated/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ export type WorkflowsChangeInstanceStatusData = {
17481748
type?: "do" | "sleep" | "waitForEvent";
17491749
};
17501750
/**
1751-
* Run rollback before terminating. Only valid when action is terminate.
1751+
* The option to trigger rollbacks when terminating the workflow instance.
17521752
*/
17531753
rollback?: boolean;
17541754
};

packages/miniflare/src/workers/local-explorer/openapi.local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@
18131813
},
18141814
"rollback": {
18151815
"type": "boolean",
1816-
"description": "Run rollback before terminating. Only valid when action is terminate."
1816+
"description": "The option to trigger rollbacks when terminating the workflow instance."
18171817
}
18181818
}
18191819
}

packages/miniflare/src/workers/workflows/wrapped-binding.worker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type {
22
WorkflowBinding,
3-
WorkflowHandle,
43
WorkflowInstanceRestartOptions,
54
WorkflowInstanceTerminateOptions,
65
} from "@cloudflare/workflows-shared/src/binding";
@@ -73,8 +72,7 @@ class InstanceImpl implements WorkflowInstance {
7372
) {}
7473

7574
private async getInstance(): Promise<WorkflowInstance & Disposable> {
76-
return (await this.binding.get(this.id)) as unknown as WorkflowInstance &
77-
Disposable;
75+
return (await this.binding.get(this.id)) as WorkflowInstance & Disposable;
7876
}
7977

8078
public async pause(): Promise<void> {
@@ -92,7 +90,11 @@ class InstanceImpl implements WorkflowInstance {
9290
): Promise<void> {
9391
using instance = await this.getInstance();
9492
// TODO(vaish): remove cast once @cloudflare/workers-types ships terminate options
95-
await (instance as unknown as WorkflowHandle).terminate(options);
93+
await (
94+
instance.terminate as (
95+
options?: WorkflowInstanceTerminateOptions
96+
) => Promise<void>
97+
)(options);
9698
}
9799

98100
public async restart(

packages/workflows-shared/src/binding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class WorkflowBinding extends WorkerEntrypoint<Env> {
9999
};
100100
}
101101

102-
public async get(id: string): Promise<WorkflowHandle> {
102+
public async get(id: string): Promise<WorkflowInstance> {
103103
const stubId = this.env.ENGINE.idFromName(id);
104104
const stub = this.env.ENGINE.get(stubId);
105105

0 commit comments

Comments
 (0)