@pikku/inspector 0.9.5 → 0.10.0

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/add/add-channel.d.ts +17 -0
  3. package/dist/{add-channel.js → add/add-channel.js} +60 -34
  4. package/dist/add/add-cli.d.ts +9 -0
  5. package/dist/add/add-cli.js +566 -0
  6. package/dist/{add-file-extends-core-type.d.ts → add/add-file-extends-core-type.d.ts} +2 -2
  7. package/dist/{add-file-extends-core-type.js → add/add-file-extends-core-type.js} +17 -4
  8. package/dist/{add-file-with-config.d.ts → add/add-file-with-config.d.ts} +1 -1
  9. package/dist/{add-file-with-config.js → add/add-file-with-config.js} +1 -1
  10. package/dist/{add-file-with-factory.d.ts → add/add-file-with-factory.d.ts} +2 -2
  11. package/dist/{add-file-with-factory.js → add/add-file-with-factory.js} +38 -5
  12. package/dist/add/add-functions.d.ts +6 -0
  13. package/dist/{add-functions.js → add/add-functions.js} +77 -10
  14. package/dist/{add-http-route.d.ts → add/add-http-route.d.ts} +2 -3
  15. package/dist/{add-http-route.js → add/add-http-route.js} +26 -13
  16. package/dist/add/add-mcp-prompt.d.ts +2 -0
  17. package/dist/add/add-mcp-prompt.js +74 -0
  18. package/dist/add/add-mcp-resource.d.ts +2 -0
  19. package/dist/add/add-mcp-resource.js +84 -0
  20. package/dist/add/add-mcp-tool.d.ts +2 -0
  21. package/dist/add/add-mcp-tool.js +80 -0
  22. package/dist/add/add-middleware.d.ts +5 -0
  23. package/dist/add/add-middleware.js +290 -0
  24. package/dist/add/add-permission.d.ts +5 -0
  25. package/dist/add/add-permission.js +292 -0
  26. package/dist/add/add-queue-worker.d.ts +2 -0
  27. package/dist/add/add-queue-worker.js +52 -0
  28. package/dist/{add-rpc-invocations.d.ts → add/add-rpc-invocations.d.ts} +1 -1
  29. package/dist/add/add-schedule.d.ts +2 -0
  30. package/dist/{add-schedule.js → add/add-schedule.js} +16 -11
  31. package/dist/error-codes.d.ts +35 -0
  32. package/dist/error-codes.js +40 -0
  33. package/dist/index.d.ts +6 -0
  34. package/dist/index.js +4 -0
  35. package/dist/inspector.d.ts +2 -3
  36. package/dist/inspector.js +38 -8
  37. package/dist/types.d.ts +108 -1
  38. package/dist/utils/ensure-function-metadata.d.ts +6 -0
  39. package/dist/utils/ensure-function-metadata.js +18 -0
  40. package/dist/utils/extract-function-name.d.ts +31 -0
  41. package/dist/{utils.js → utils/extract-function-name.js} +35 -149
  42. package/dist/utils/extract-services.d.ts +6 -0
  43. package/dist/utils/extract-services.js +29 -0
  44. package/dist/utils/filter-inspector-state.d.ts +6 -0
  45. package/dist/utils/filter-inspector-state.js +382 -0
  46. package/dist/utils/filter-utils.d.ts +19 -0
  47. package/dist/utils/filter-utils.js +109 -0
  48. package/dist/utils/find-root-dir.d.ts +23 -0
  49. package/dist/utils/find-root-dir.js +55 -0
  50. package/dist/utils/get-files-and-methods.d.ts +22 -0
  51. package/dist/utils/get-files-and-methods.js +61 -0
  52. package/dist/utils/get-property-value.d.ts +12 -0
  53. package/dist/{get-property-value.js → utils/get-property-value.js} +20 -0
  54. package/dist/utils/middleware.d.ts +39 -0
  55. package/dist/utils/middleware.js +157 -0
  56. package/dist/utils/permissions.d.ts +43 -0
  57. package/dist/utils/permissions.js +178 -0
  58. package/dist/utils/post-process.d.ts +16 -0
  59. package/dist/utils/post-process.js +132 -0
  60. package/dist/utils/serialize-inspector-state.d.ts +179 -0
  61. package/dist/utils/serialize-inspector-state.js +170 -0
  62. package/dist/utils/type-utils.d.ts +3 -0
  63. package/dist/utils/type-utils.js +50 -0
  64. package/dist/visit.d.ts +3 -3
  65. package/dist/visit.js +35 -31
  66. package/package.json +5 -6
  67. package/src/{add-channel.ts → add/add-channel.ts} +108 -56
  68. package/src/add/add-cli.ts +822 -0
  69. package/src/{add-file-extends-core-type.ts → add/add-file-extends-core-type.ts} +23 -5
  70. package/src/{add-file-with-config.ts → add/add-file-with-config.ts} +2 -2
  71. package/src/{add-file-with-factory.ts → add/add-file-with-factory.ts} +49 -6
  72. package/src/{add-functions.ts → add/add-functions.ts} +89 -19
  73. package/src/{add-http-route.ts → add/add-http-route.ts} +66 -32
  74. package/src/add/add-mcp-prompt.ts +128 -0
  75. package/src/add/add-mcp-prompt.ts.tmp +0 -0
  76. package/src/add/add-mcp-resource.ts +145 -0
  77. package/src/add/add-mcp-resource.ts.tmp +0 -0
  78. package/src/add/add-mcp-tool.ts +137 -0
  79. package/src/add/add-middleware.ts +385 -0
  80. package/src/add/add-permission.ts +391 -0
  81. package/src/add/add-queue-worker.ts +92 -0
  82. package/src/{add-rpc-invocations.ts → add/add-rpc-invocations.ts} +1 -1
  83. package/src/{add-schedule.ts → add/add-schedule.ts} +30 -28
  84. package/src/error-codes.ts +43 -0
  85. package/src/index.ts +12 -0
  86. package/src/inspector.ts +41 -17
  87. package/src/types.ts +128 -1
  88. package/src/utils/ensure-function-metadata.ts +24 -0
  89. package/src/{utils.ts → utils/extract-function-name.ts} +44 -206
  90. package/src/utils/extract-services.ts +35 -0
  91. package/src/utils/filter-inspector-state.test.ts +1433 -0
  92. package/src/utils/filter-inspector-state.ts +526 -0
  93. package/src/{utils.test.ts → utils/filter-utils.test.ts} +351 -2
  94. package/src/utils/filter-utils.ts +152 -0
  95. package/src/utils/find-root-dir.ts +68 -0
  96. package/src/utils/get-files-and-methods.ts +151 -0
  97. package/src/{get-property-value.ts → utils/get-property-value.ts} +27 -0
  98. package/src/utils/middleware.ts +241 -0
  99. package/src/utils/permissions.test.ts +327 -0
  100. package/src/utils/permissions.ts +262 -0
  101. package/src/utils/post-process.ts +178 -0
  102. package/src/utils/serialize-inspector-state.ts +375 -0
  103. package/src/utils/test-data/inspector-state.json +1680 -0
  104. package/src/utils/type-utils.ts +74 -0
  105. package/src/visit.ts +50 -34
  106. package/tsconfig.tsbuildinfo +1 -1
  107. package/dist/add-channel.d.ts +0 -13
  108. package/dist/add-functions.d.ts +0 -7
  109. package/dist/add-mcp-prompt.d.ts +0 -3
  110. package/dist/add-mcp-prompt.js +0 -61
  111. package/dist/add-mcp-resource.d.ts +0 -3
  112. package/dist/add-mcp-resource.js +0 -68
  113. package/dist/add-mcp-tool.d.ts +0 -3
  114. package/dist/add-mcp-tool.js +0 -64
  115. package/dist/add-middleware.d.ts +0 -7
  116. package/dist/add-middleware.js +0 -35
  117. package/dist/add-permission.d.ts +0 -7
  118. package/dist/add-permission.js +0 -35
  119. package/dist/add-queue-worker.d.ts +0 -3
  120. package/dist/add-queue-worker.js +0 -48
  121. package/dist/add-schedule.d.ts +0 -3
  122. package/dist/get-property-value.d.ts +0 -3
  123. package/dist/utils.d.ts +0 -39
  124. package/src/add-mcp-prompt.ts +0 -104
  125. package/src/add-mcp-resource.ts +0 -116
  126. package/src/add-mcp-tool.ts +0 -107
  127. package/src/add-middleware.ts +0 -51
  128. package/src/add-permission.ts +0 -53
  129. package/src/add-queue-worker.ts +0 -92
  130. /package/dist/{add-rpc-invocations.js → add/add-rpc-invocations.js} +0 -0
  131. /package/dist/{does-type-extend-core-type.d.ts → utils/does-type-extend-core-type.d.ts} +0 -0
  132. /package/dist/{does-type-extend-core-type.js → utils/does-type-extend-core-type.js} +0 -0
  133. /package/src/{does-type-extend-core-type.ts → utils/does-type-extend-core-type.ts} +0 -0
@@ -1,10 +1,11 @@
1
1
  import * as ts from 'typescript';
2
+ import { toRelativePath } from './find-root-dir.js';
2
3
  /**
3
4
  * Generate a deterministic "anonymous" name for any expression node,
4
5
  * but if it's an Identifier pointing to a function, resolve it back
5
6
  * to the function's declaration (so you get the true source location).
6
7
  */
7
- export function makeDeterministicAnonName(start, checker) {
8
+ export function makeDeterministicAnonName(start, checker, rootDir) {
8
9
  let node = start;
9
10
  let target = start;
10
11
  // Handle the case where we're starting with an identifier directly
@@ -27,7 +28,8 @@ export function makeDeterministicAnonName(start, checker) {
27
28
  target = decl.initializer;
28
29
  // Return early - we found the function directly
29
30
  const sf = target.getSourceFile();
30
- const file = sf.fileName.replace(/[^A-Za-z0-9_]/g, '_');
31
+ const relativePath = toRelativePath(sf.fileName, rootDir);
32
+ const file = relativePath.replace(/[^A-Za-z0-9_]/g, '_');
31
33
  const { line, character } = ts.getLineAndCharacterOfPosition(sf, target.getStart());
32
34
  return `pikkuFn_${file}_L${line + 1}C${character + 1}`;
33
35
  }
@@ -62,7 +64,8 @@ export function makeDeterministicAnonName(start, checker) {
62
64
  target = decl.initializer;
63
65
  // Return early - we found the function directly
64
66
  const sf = target.getSourceFile();
65
- const file = sf.fileName.replace(/[^A-Za-z0-9_]/g, '_');
67
+ const relativePath = toRelativePath(sf.fileName, rootDir);
68
+ const file = relativePath.replace(/[^A-Za-z0-9_]/g, '_');
66
69
  const { line, character } = ts.getLineAndCharacterOfPosition(sf, target.getStart());
67
70
  return `pikkuFn_${file}_L${line + 1}C${character + 1}`;
68
71
  }
@@ -72,7 +75,8 @@ export function makeDeterministicAnonName(start, checker) {
72
75
  target = decl;
73
76
  // Return early
74
77
  const sf = target.getSourceFile();
75
- const file = sf.fileName.replace(/[^A-Za-z0-9_]/g, '_');
78
+ const relativePath = toRelativePath(sf.fileName, rootDir);
79
+ const file = relativePath.replace(/[^A-Za-z0-9_]/g, '_');
76
80
  const { line, character } = ts.getLineAndCharacterOfPosition(sf, target.getStart());
77
81
  return `pikkuFn_${file}_L${line + 1}C${character + 1}`;
78
82
  }
@@ -182,7 +186,8 @@ export function makeDeterministicAnonName(start, checker) {
182
186
  break;
183
187
  }
184
188
  const sf = target.getSourceFile();
185
- const file = sf.fileName.replace(/[^A-Za-z0-9_]/g, '_');
189
+ const relativePath = toRelativePath(sf.fileName, rootDir);
190
+ const file = relativePath.replace(/[^A-Za-z0-9_]/g, '_');
186
191
  const { line, character } = ts.getLineAndCharacterOfPosition(sf, target.getStart());
187
192
  return `pikkuFn_${file}_L${line + 1}C${character + 1}`;
188
193
  }
@@ -193,7 +198,7 @@ export function makeDeterministicAnonName(start, checker) {
193
198
  * 2. Exported name
194
199
  * 3. Fallback to deterministic name
195
200
  */
196
- export function extractFunctionName(callExpr, checker) {
201
+ export function extractFunctionName(callExpr, checker, rootDir) {
197
202
  const parent = callExpr.parent;
198
203
  // Initialize the result
199
204
  const result = {
@@ -230,7 +235,7 @@ export function extractFunctionName(callExpr, checker) {
230
235
  (ts.isArrowFunction(firstArg) ||
231
236
  ts.isFunctionExpression(firstArg))) {
232
237
  // Use the function directly for position calculation
233
- result.pikkuFuncName = makeDeterministicAnonName(firstArg, checker);
238
+ result.pikkuFuncName = makeDeterministicAnonName(firstArg, checker, rootDir);
234
239
  // Continue with name extraction
235
240
  if (ts.isIdentifier(parent.name)) {
236
241
  result.propertyName = parent.name.text;
@@ -256,9 +261,8 @@ export function extractFunctionName(callExpr, checker) {
256
261
  }
257
262
  }
258
263
  }
259
- // First, figure out what function we're really dealing with
260
- let mainFunc = callExpr;
261
- let originalCallExpr = callExpr; // Keep track of the original call expression for name extraction
264
+ // Keep track of the original call expression for position-based naming
265
+ let originalCallExpr = callExpr;
262
266
  // For direct pikku function calls where callExpr is the call expression itself
263
267
  if (ts.isCallExpression(callExpr)) {
264
268
  const { expression, arguments: args } = callExpr;
@@ -284,7 +288,7 @@ export function extractFunctionName(callExpr, checker) {
284
288
  const firstArg = args[0];
285
289
  if (ts.isArrowFunction(firstArg) ||
286
290
  ts.isFunctionExpression(firstArg)) {
287
- mainFunc = firstArg; // Use the arrow function directly instead of the call expression
291
+ // mainFunc = firstArg // Use the arrow function directly instead of the call expression
288
292
  }
289
293
  }
290
294
  }
@@ -321,7 +325,7 @@ export function extractFunctionName(callExpr, checker) {
321
325
  if (firstArg &&
322
326
  (ts.isArrowFunction(firstArg) ||
323
327
  ts.isFunctionExpression(firstArg))) {
324
- mainFunc = firstArg;
328
+ // mainFunc = firstArg
325
329
  // Check if the variable is exported
326
330
  if (isNamedExport(funcDecl) &&
327
331
  ts.isIdentifier(funcDecl.name)) {
@@ -336,7 +340,7 @@ export function extractFunctionName(callExpr, checker) {
336
340
  }
337
341
  else if (ts.isFunctionExpression(funcDecl.initializer) ||
338
342
  ts.isArrowFunction(funcDecl.initializer)) {
339
- mainFunc = funcDecl.initializer;
343
+ // mainFunc = funcDecl.initializer
340
344
  // Check if the variable is exported
341
345
  if (isNamedExport(funcDecl) &&
342
346
  ts.isIdentifier(funcDecl.name)) {
@@ -350,7 +354,7 @@ export function extractFunctionName(callExpr, checker) {
350
354
  }
351
355
  }
352
356
  else if (ts.isFunctionDeclaration(funcDecl)) {
353
- mainFunc = funcDecl;
357
+ // mainFunc = funcDecl
354
358
  // Check if the function is exported
355
359
  if (funcDecl.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) &&
356
360
  funcDecl.name &&
@@ -368,14 +372,14 @@ export function extractFunctionName(callExpr, checker) {
368
372
  }
369
373
  else {
370
374
  // If we can't resolve the symbol, use the identifier itself
371
- mainFunc = prop.initializer;
375
+ // mainFunc = prop.initializer
372
376
  }
373
377
  break;
374
378
  }
375
379
  else if (ts.isFunctionExpression(prop.initializer) ||
376
380
  ts.isArrowFunction(prop.initializer)) {
377
381
  // func: () => {} or func: function() {} - use directly
378
- mainFunc = prop.initializer;
382
+ // mainFunc = prop.initializer
379
383
  break;
380
384
  }
381
385
  }
@@ -401,7 +405,7 @@ export function extractFunctionName(callExpr, checker) {
401
405
  if (firstArg &&
402
406
  (ts.isArrowFunction(firstArg) ||
403
407
  ts.isFunctionExpression(firstArg))) {
404
- mainFunc = firstArg;
408
+ // mainFunc = firstArg
405
409
  // Check if the variable is exported
406
410
  if (isNamedExport(shorthandDecl) &&
407
411
  ts.isIdentifier(shorthandDecl.name)) {
@@ -416,7 +420,7 @@ export function extractFunctionName(callExpr, checker) {
416
420
  }
417
421
  else if (ts.isFunctionExpression(shorthandDecl.initializer) ||
418
422
  ts.isArrowFunction(shorthandDecl.initializer)) {
419
- mainFunc = shorthandDecl.initializer;
423
+ // mainFunc = shorthandDecl.initializer
420
424
  // Check if the variable is exported
421
425
  if (isNamedExport(shorthandDecl) &&
422
426
  ts.isIdentifier(shorthandDecl.name)) {
@@ -430,7 +434,7 @@ export function extractFunctionName(callExpr, checker) {
430
434
  }
431
435
  }
432
436
  else if (ts.isFunctionDeclaration(shorthandDecl)) {
433
- mainFunc = shorthandDecl;
437
+ // mainFunc = shorthandDecl
434
438
  // Check if the function is exported
435
439
  if (shorthandDecl.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) &&
436
440
  shorthandDecl.name &&
@@ -468,6 +472,9 @@ export function extractFunctionName(callExpr, checker) {
468
472
  if (ts.isCallExpression(decl.initializer) &&
469
473
  ts.isIdentifier(decl.initializer.expression) &&
470
474
  decl.initializer.expression.text.startsWith('pikku')) {
475
+ // Update originalCallExpr to use the call expression position
476
+ // instead of the variable declaration position
477
+ originalCallExpr = decl.initializer;
471
478
  // Check for object with 'name' property in first argument
472
479
  const firstArg = decl.initializer.arguments[0];
473
480
  if (firstArg && ts.isObjectLiteralExpression(firstArg)) {
@@ -486,7 +493,7 @@ export function extractFunctionName(callExpr, checker) {
486
493
  if (firstArg &&
487
494
  (ts.isArrowFunction(firstArg) ||
488
495
  ts.isFunctionExpression(firstArg))) {
489
- mainFunc = firstArg;
496
+ // mainFunc = firstArg
490
497
  }
491
498
  }
492
499
  // Check if the variable is exported
@@ -502,7 +509,7 @@ export function extractFunctionName(callExpr, checker) {
502
509
  }
503
510
  else if (ts.isFunctionExpression(decl.initializer) ||
504
511
  ts.isArrowFunction(decl.initializer)) {
505
- mainFunc = decl.initializer;
512
+ // mainFunc = decl.initializer
506
513
  // Check if the variable is exported
507
514
  if (isNamedExport(decl) && ts.isIdentifier(decl.name)) {
508
515
  result.exportedName = decl.name.text;
@@ -513,7 +520,7 @@ export function extractFunctionName(callExpr, checker) {
513
520
  }
514
521
  }
515
522
  else if (ts.isFunctionDeclaration(decl)) {
516
- mainFunc = decl;
523
+ // mainFunc = decl
517
524
  // Check if the function is exported
518
525
  if (decl.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) &&
519
526
  decl.name &&
@@ -527,8 +534,10 @@ export function extractFunctionName(callExpr, checker) {
527
534
  }
528
535
  }
529
536
  }
530
- // Now generate the deterministic function name based on the resolved function
531
- result.pikkuFuncName = makeDeterministicAnonName(mainFunc, checker);
537
+ // Generate the deterministic function name based on the original call expression
538
+ // (the config), not the resolved inner function. This ensures the metadata key
539
+ // matches what will be looked up at runtime when referencing the config object.
540
+ result.pikkuFuncName = makeDeterministicAnonName(originalCallExpr, checker, rootDir);
532
541
  // Continue with regular name extraction for remaining cases
533
542
  // 1) const foo = pikkuFunc(...)
534
543
  if (ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name)) {
@@ -577,7 +586,7 @@ export function extractFunctionName(callExpr, checker) {
577
586
  /**
578
587
  * Helper function to populate the 'name' field based on priority
579
588
  */
580
- function populateNameByPriority(result) {
589
+ export function populateNameByPriority(result) {
581
590
  // Priority 1: If we have an explict name, use that
582
591
  if (result.explicitName) {
583
592
  result.name = result.explicitName;
@@ -599,7 +608,7 @@ function populateNameByPriority(result) {
599
608
  /**
600
609
  * Helper function to check if a variable declaration is a named export
601
610
  */
602
- function isNamedExport(declaration) {
611
+ export function isNamedExport(declaration) {
603
612
  let parent = declaration.parent;
604
613
  if (!parent)
605
614
  return false;
@@ -616,126 +625,3 @@ function isNamedExport(declaration) {
616
625
  }
617
626
  return false;
618
627
  }
619
- // Until here
620
- export const extractTypeKeys = (type) => {
621
- return type.getProperties().map((symbol) => symbol.getName());
622
- };
623
- export function getPropertyAssignmentInitializer(obj, propName, followShorthand = false, checker) {
624
- for (const prop of obj.properties) {
625
- // ① foo: () => {}
626
- if (ts.isPropertyAssignment(prop) &&
627
- ts.isIdentifier(prop.name) &&
628
- prop.name.text === propName) {
629
- return prop.initializer;
630
- }
631
- // ② foo() { … }
632
- if (ts.isMethodDeclaration(prop) &&
633
- ts.isIdentifier(prop.name) &&
634
- prop.name.text === propName) {
635
- return prop.name; // the method node *is* the function
636
- }
637
- // ③ { foo } (shorthand)
638
- if (followShorthand &&
639
- ts.isShorthandPropertyAssignment(prop) &&
640
- prop.name.text === propName) {
641
- if (!checker)
642
- return prop.name; // best effort without a checker
643
- let sym = checker.getSymbolAtLocation(prop.name);
644
- if (sym && sym.flags & ts.SymbolFlags.Alias) {
645
- sym = checker.getAliasedSymbol(sym);
646
- }
647
- const decl = sym?.declarations?.[0];
648
- // const foo = () => {}
649
- if (decl &&
650
- ts.isVariableDeclaration(decl) &&
651
- decl.initializer &&
652
- (ts.isArrowFunction(decl.initializer) ||
653
- ts.isFunctionExpression(decl.initializer))) {
654
- return decl.initializer;
655
- }
656
- // function foo() {}
657
- if (decl &&
658
- (ts.isFunctionDeclaration(decl) ||
659
- ts.isArrowFunction(decl) ||
660
- ts.isFunctionExpression(decl))) {
661
- return decl;
662
- }
663
- // fallback – just give back the identifier
664
- return prop.name;
665
- }
666
- }
667
- return undefined;
668
- }
669
- export const matchesFilters = (filters, params, meta, logger) => {
670
- // If no filters are provided, allow everything
671
- if (Object.keys(filters).length === 0) {
672
- return true;
673
- }
674
- // If all filter arrays are empty, allow everything
675
- if ((!filters.tags || filters.tags.length === 0) &&
676
- (!filters.types || filters.types.length === 0) &&
677
- (!filters.directories || filters.directories.length === 0)) {
678
- return true;
679
- }
680
- // Check type filter
681
- if (filters.types && filters.types.length > 0) {
682
- if (!filters.types.includes(meta.type)) {
683
- logger.debug(`⒡ Filtered by type: ${meta.type}:${meta.name}`);
684
- return false;
685
- }
686
- }
687
- // Check directory filter
688
- if (filters.directories && filters.directories.length > 0) {
689
- if (!meta.filePath) {
690
- logger.debug(`⒡ Filtered by directory: ${meta.type}:${meta.name} (${meta.filePath})`);
691
- return false;
692
- }
693
- const matchesDirectory = filters.directories.some((dir) => {
694
- // Normalize paths for comparison
695
- const normalizedFilePath = meta.filePath.replace(/\\/g, '/');
696
- const normalizedDir = dir.replace(/\\/g, '/');
697
- return normalizedFilePath.includes(normalizedDir);
698
- });
699
- if (!matchesDirectory) {
700
- logger.debug(`⒡ Filtered by directory: ${meta.type}:${meta.name} (${meta.filePath})`);
701
- return false;
702
- }
703
- }
704
- // Check tag filter
705
- if (filters.tags && filters.tags.length > 0) {
706
- if (!params.tags ||
707
- !filters.tags.some((tag) => params.tags.includes(tag))) {
708
- logger.debug(`⒡ Filtered by tags: ${meta.type}:${meta.name}`);
709
- return false;
710
- }
711
- }
712
- return true;
713
- };
714
- /**
715
- * Extract services from a function's first parameter destructuring pattern
716
- */
717
- export function extractServicesFromFunction(handlerNode) {
718
- const services = {
719
- optimized: true,
720
- services: [],
721
- };
722
- const firstParam = handlerNode.parameters[0];
723
- if (firstParam) {
724
- if (ts.isObjectBindingPattern(firstParam.name)) {
725
- for (const elem of firstParam.name.elements) {
726
- const original = elem.propertyName && ts.isIdentifier(elem.propertyName)
727
- ? elem.propertyName.text
728
- : ts.isIdentifier(elem.name)
729
- ? elem.name.text
730
- : undefined;
731
- if (original) {
732
- services.services.push(original);
733
- }
734
- }
735
- }
736
- else if (ts.isIdentifier(firstParam.name)) {
737
- services.optimized = false;
738
- }
739
- }
740
- return services;
741
- }
@@ -0,0 +1,6 @@
1
+ import * as ts from 'typescript';
2
+ import { FunctionServicesMeta } from '@pikku/core';
3
+ /**
4
+ * Extract services from a function's first parameter destructuring pattern
5
+ */
6
+ export declare function extractServicesFromFunction(handlerNode: ts.FunctionExpression | ts.ArrowFunction): FunctionServicesMeta;
@@ -0,0 +1,29 @@
1
+ import * as ts from 'typescript';
2
+ /**
3
+ * Extract services from a function's first parameter destructuring pattern
4
+ */
5
+ export function extractServicesFromFunction(handlerNode) {
6
+ const services = {
7
+ optimized: true,
8
+ services: [],
9
+ };
10
+ const firstParam = handlerNode.parameters[0];
11
+ if (firstParam) {
12
+ if (ts.isObjectBindingPattern(firstParam.name)) {
13
+ for (const elem of firstParam.name.elements) {
14
+ const original = elem.propertyName && ts.isIdentifier(elem.propertyName)
15
+ ? elem.propertyName.text
16
+ : ts.isIdentifier(elem.name)
17
+ ? elem.name.text
18
+ : undefined;
19
+ if (original) {
20
+ services.services.push(original);
21
+ }
22
+ }
23
+ }
24
+ else if (ts.isIdentifier(firstParam.name)) {
25
+ services.optimized = false;
26
+ }
27
+ }
28
+ return services;
29
+ }
@@ -0,0 +1,6 @@
1
+ import { InspectorState, InspectorFilters, InspectorLogger } from '../types.js';
2
+ /**
3
+ * Filters inspector state based on provided filters
4
+ * This is applied post-inspection to support the inspect-once, filter-many pattern
5
+ */
6
+ export declare function filterInspectorState(state: InspectorState | Omit<InspectorState, 'typesLookup'>, filters: InspectorFilters, logger: InspectorLogger): typeof state;