@pikku/inspector 0.12.28 → 0.12.29

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.
@@ -7,6 +7,7 @@ import type {
7
7
  ParallelGroupStepMeta,
8
8
  FanoutStepMeta,
9
9
  CancelStepMeta,
10
+ SuspendStepMeta,
10
11
  SetStepMeta,
11
12
  SwitchStepMeta,
12
13
  SwitchCaseMeta,
@@ -21,6 +22,7 @@ import type {
21
22
  import {
22
23
  isWorkflowDoCall,
23
24
  isWorkflowSleepCall,
25
+ isWorkflowSuspendCall,
24
26
  isThrowCancelException,
25
27
  extractCancelReason,
26
28
  isParallelFanout,
@@ -512,6 +514,10 @@ function extractExpressionStatement(
512
514
  return extractSleepStep(call, context)
513
515
  }
514
516
 
517
+ if (isWorkflowSuspendCall(call, context.checker)) {
518
+ return extractSuspendStep(call, context)
519
+ }
520
+
515
521
  // Check for parallel group or fanout
516
522
  if (isParallelFanout(call)) {
517
523
  return extractParallelFanout(call, context)
@@ -698,6 +704,31 @@ function extractSleepStep(
698
704
  }
699
705
  }
700
706
 
707
+ /**
708
+ * Extract suspend step from workflow.suspend() call
709
+ */
710
+ function extractSuspendStep(
711
+ call: ts.CallExpression,
712
+ context: ExtractionContext
713
+ ): SuspendStepMeta | null {
714
+ const args = call.arguments
715
+ if (args.length < 1) return null
716
+
717
+ try {
718
+ const reason = extractStringLiteral(args[0], context.checker)
719
+ return {
720
+ type: 'suspend',
721
+ reason,
722
+ }
723
+ } catch (error) {
724
+ context.errors.push({
725
+ message: `Failed to extract suspend step: ${error instanceof Error ? error.message : String(error)}`,
726
+ node: call,
727
+ })
728
+ return null
729
+ }
730
+ }
731
+
701
732
  /**
702
733
  * Extract cancel step from throw WorkflowCancelledException statement
703
734
  */
@@ -42,6 +42,25 @@ export function isWorkflowSleepCall(
42
42
  )
43
43
  }
44
44
 
45
+ /**
46
+ * Check if a call expression is workflow.suspend()
47
+ */
48
+ export function isWorkflowSuspendCall(
49
+ node: ts.CallExpression,
50
+ _checker: ts.TypeChecker
51
+ ): boolean {
52
+ if (!ts.isPropertyAccessExpression(node.expression)) {
53
+ return false
54
+ }
55
+
56
+ const propAccess = node.expression
57
+ return (
58
+ propAccess.name.text === 'suspend' &&
59
+ ts.isIdentifier(propAccess.expression) &&
60
+ propAccess.expression.text === 'workflow'
61
+ )
62
+ }
63
+
45
64
  /**
46
65
  * Check if a throw statement throws WorkflowCancelledException
47
66
  * Matches: throw new WorkflowCancelledException(...) or throw WorkflowCancelledException(...)
package/src/visit.ts CHANGED
@@ -87,6 +87,12 @@ export const visitSetup = (
87
87
  )
88
88
 
89
89
  addFileWithFactory(node, checker, state.configFactories, 'CreateConfig')
90
+ addFileWithFactory(
91
+ node,
92
+ checker,
93
+ state.serverLifecycleFactories,
94
+ 'ServerLifecycle'
95
+ )
90
96
 
91
97
  addRPCInvocations(node, state, logger)
92
98
  addWireAddon(node, state, logger)