@@ -215,44 +215,51 @@ export class StepExecutor<DataModel extends GenericDataModel> {
215215 startedAt : this . now ,
216216 completedAt : runResult ? this . now : undefined ,
217217 } satisfies Omit < Step , "kind" > ;
218- const step =
219- target . kind === "inline"
220- ? {
221- kind : "function" as const ,
222- functionType : "mutation" as const ,
223- handle : "inline" ,
224- ...commonFields ,
225- }
226- : target . kind === "function"
227- ? {
228- kind : "function" as const ,
229- functionType : target . functionType ,
230- handle : await createFunctionHandle ( target . function ) ,
231- ...commonFields ,
232- }
233- : target . kind === "workflow"
234- ? {
235- kind : "workflow" as const ,
236- handle : await createFunctionHandle ( target . function ) ,
237- ...commonFields ,
238- }
239- : target . kind === "event"
240- ? {
241- kind : "event" as const ,
242- eventId : target . args . eventId ,
243- ...commonFields ,
244- args : target . args ,
245- }
246- : target . kind === "sleep"
247- ? {
248- kind : "sleep" as const ,
249- ...commonFields ,
250- }
251- : ( ( ) : never => {
252- throw new Error (
253- `Unknown step kind: ${ ( target as any ) . kind } ` ,
254- ) ;
255- } ) ( ) ;
218+ let step : Step ;
219+ switch ( target . kind ) {
220+ case "inline" :
221+ step = {
222+ kind : "function" ,
223+ functionType : "mutation" ,
224+ handle : "inline" ,
225+ ...commonFields ,
226+ } ;
227+ break ;
228+ case "function" :
229+ step = {
230+ kind : "function" ,
231+ functionType : target . functionType ,
232+ handle : await createFunctionHandle ( target . function ) ,
233+ ...commonFields ,
234+ } ;
235+ break ;
236+ case "workflow" :
237+ step = {
238+ kind : "workflow" ,
239+ handle : await createFunctionHandle ( target . function ) ,
240+ ...commonFields ,
241+ } ;
242+ break ;
243+ case "event" :
244+ step = {
245+ kind : "event" ,
246+ // EventId (branded string) → Id<"events"> for the component schema
247+ eventId : target . args . eventId ,
248+ ...commonFields ,
249+ args : target . args ,
250+ } as Step ;
251+ break ;
252+ case "sleep" :
253+ step = {
254+ kind : "sleep" ,
255+ ...commonFields ,
256+ } ;
257+ break ;
258+ default :
259+ throw new Error (
260+ `Unknown step kind: ${ ( target as any ) . kind } ` ,
261+ ) ;
262+ }
256263 return {
257264 retry : message . retry ,
258265 schedulerOptions : message . schedulerOptions ,
0 commit comments