11import { WORKFLOW_ENGINE_BINDING } from "../shared/workflows" ;
22import { internalEnv } from "./env" ;
3- // import type { InstanceStatus } from "@cloudflare/workflows-shared/src/instance";
43import type { InstanceModifier } from "@cloudflare/workflows-shared/src/modifier" ;
54
65export type StepSelector = {
@@ -36,13 +35,11 @@ export async function introspectWorkflowInstance(
3635 `[Vitest-Workflows] Introspecting workflow instance: ${ instanceId } `
3736 ) ;
3837
39- //await workflow.create({ id: instanceId });
40-
4138 // @ts -expect-error getWorkflowName() not exposed
4239 const engineBindingName = `${ WORKFLOW_ENGINE_BINDING } ${ ( await workflow . getWorkflowName ( ) ) . toUpperCase ( ) } ` ;
43- // @ts -expect-error binding created at in runner worker start
40+ // @ts -expect-error DO binding created in runner worker start
4441 const engineStubId = internalEnv [ engineBindingName ] . idFromName ( instanceId ) ;
45- // @ts -expect-error binding created at in runner worker start
42+ // @ts -expect-error DO binding created in runner worker start
4643 const engineStub = internalEnv [ engineBindingName ] . get ( engineStubId ) ;
4744
4845 const instanceModifier = await engineStub . getInstanceModifier ( ) ;
@@ -63,15 +60,15 @@ class WorkflowInstanceIntrospectorHandle
6360 this . instanceModifier = instanceModifier ;
6461 }
6562
66- public async modify (
63+ async modify (
6764 fn : ( m : InstanceModifier ) => Promise < void >
6865 ) : Promise < WorkflowInstanceIntrospector > {
6966 console . log ( "[Vitest-Workflows] I should go call a modifier" ) ;
7067 await fn ( this . instanceModifier ) ;
7168 return this ;
7269 }
7370
74- public async waitForStepResult ( step : StepSelector ) : Promise < unknown > {
71+ async waitForStepResult ( step : StepSelector ) : Promise < unknown > {
7572 console . log ( "waiting for step result of step" , step . name ) ;
7673 // @ts -expect-error waitForStepResult not exposed
7774 const stepResult = await this . engineStub . waitForStepResult (
@@ -83,18 +80,19 @@ class WorkflowInstanceIntrospectorHandle
8380 return stepResult ;
8481 }
8582
86- public async waitForStatus ( status : string ) : Promise < void > {
83+ async waitForStatus ( status : string ) : Promise < void > {
8784 console . log ( "[Vitest-Workflows] waiting for status" ) ;
8885 // @ts -expect-error waitForStatus not exposed
8986 await this . engineStub . waitForStatus ( status ) ;
9087
9188 console . log ( "[Vitest-Workflows] status awaited" ) ;
9289 }
9390
94- public async cleanUp ( ) : Promise < void > {
91+ async cleanUp ( ) : Promise < void > {
9592 // works with isolatedStorage = false
9693 try {
97- await this . engineStub . abort ( "user called delete" ) ;
94+ // @ts -expect-error DO binding created in runner worker start
95+ await this . engineStub . unsafeAbort ( "user called delete" ) ;
9896 } catch {
9997 // do nothing because we want to clean up this instance
10098 }
0 commit comments