@pikku/inspector 0.8.1 → 0.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/inspector",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "test:coverage": "bash run-tests.sh --coverage"
18
18
  },
19
19
  "dependencies": {
20
- "@pikku/core": "^0.8.1",
20
+ "@pikku/core": "^0.9.0",
21
21
  "path-to-regexp": "^8.2.0",
22
22
  "typescript": "^5.6"
23
23
  },
@@ -1,7 +1,7 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
3
  import { pathToRegexp } from 'path-to-regexp'
4
- import { APIDocs, PikkuEventTypes } from '@pikku/core'
4
+ import { APIDocs, PikkuWiringTypes } from '@pikku/core'
5
5
  import {
6
6
  extractFunctionName,
7
7
  getPropertyAssignmentInitializer,
@@ -107,11 +107,11 @@ export function addMessagesRoutes(
107
107
  obj: ts.ObjectLiteralExpression,
108
108
  state: InspectorState,
109
109
  checker: ts.TypeChecker
110
- ): ChannelMeta['messageRoutes'] {
111
- const result: ChannelMeta['messageRoutes'] = {}
110
+ ): ChannelMeta['messageWirings'] {
111
+ const result: ChannelMeta['messageWirings'] = {}
112
112
  const onMsgRouteProp = getPropertyAssignmentInitializer(
113
113
  obj,
114
- 'onMessageRoute',
114
+ 'onMessageWiring',
115
115
  true,
116
116
  checker
117
117
  )
@@ -372,7 +372,7 @@ export function addChannel(
372
372
  ) {
373
373
  if (!ts.isCallExpression(node)) return
374
374
  const { expression, arguments: args } = node
375
- if (!ts.isIdentifier(expression) || expression.text !== 'addChannel') return
375
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireChannel') return
376
376
  const first = args[0]
377
377
  if (!first || !ts.isObjectLiteralExpression(first)) return
378
378
 
@@ -402,7 +402,7 @@ export function addChannel(
402
402
  !matchesFilters(
403
403
  filters,
404
404
  { tags },
405
- { type: PikkuEventTypes.channel, name, filePath },
405
+ { type: PikkuWiringTypes.channel, name, filePath },
406
406
  logger
407
407
  )
408
408
  )
@@ -448,7 +448,7 @@ export function addChannel(
448
448
  }
449
449
 
450
450
  // nested message-routes
451
- const messageRoutes = addMessagesRoutes(obj, state, checker)
451
+ const messageWirings = addMessagesRoutes(obj, state, checker)
452
452
 
453
453
  // record into state
454
454
  state.channels.files.add(node.getSourceFile().fileName)
@@ -475,7 +475,7 @@ export function addChannel(
475
475
  }
476
476
  : null,
477
477
  message,
478
- messageRoutes,
478
+ messageWirings,
479
479
  docs: docs ?? undefined,
480
480
  tags: tags ?? undefined,
481
481
  }
@@ -1,8 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { PathToNameAndType } from './types.js'
3
3
 
4
- // const VRAMEWORK_TYPES = ['CoreConfig', 'CoreService', 'CoreServices', 'CoreSingletonService', 'CoreSessionService']
5
-
6
4
  export const addFileExtendsCoreType = (
7
5
  node: ts.Node,
8
6
  checker: ts.TypeChecker,
@@ -2,7 +2,7 @@ import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
3
  import { pathToRegexp } from 'path-to-regexp'
4
4
  import { HTTPMethod } from '@pikku/core/http'
5
- import { APIDocs, PikkuEventTypes } from '@pikku/core'
5
+ import { APIDocs, PikkuWiringTypes } from '@pikku/core'
6
6
  import {
7
7
  extractFunctionName,
8
8
  getPropertyAssignmentInitializer,
@@ -36,7 +36,7 @@ export const getInputTypes = (
36
36
  }
37
37
 
38
38
  /**
39
- * Simplified addHTTPRoute: re-uses function metadata from state.functions.meta
39
+ * Simplified wireHTTP: re-uses function metadata from state.functions.meta
40
40
  * instead of re-inferring types here.
41
41
  */
42
42
  export const addHTTPRoute = (
@@ -50,7 +50,7 @@ export const addHTTPRoute = (
50
50
  if (!ts.isCallExpression(node)) return
51
51
 
52
52
  const { expression, arguments: args } = node
53
- if (!ts.isIdentifier(expression) || expression.text !== 'addHTTPRoute') return
53
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireHTTP') return
54
54
 
55
55
  // must pass an object literal
56
56
  const firstArg = args[0]
@@ -76,7 +76,7 @@ export const addHTTPRoute = (
76
76
  !matchesFilters(
77
77
  filters,
78
78
  { tags },
79
- { type: PikkuEventTypes.http, name: route, filePath },
79
+ { type: PikkuWiringTypes.http, name: route, filePath },
80
80
  logger
81
81
  )
82
82
  ) {
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
- import { PikkuEventTypes } from '@pikku/core'
3
+ import { PikkuWiringTypes } from '@pikku/core'
4
4
  import { InspectorFilters, InspectorState, InspectorLogger } from './types.js'
5
5
  import {
6
6
  extractFunctionName,
@@ -23,8 +23,8 @@ export const addMCPPrompt = (
23
23
  const firstArg = args[0]
24
24
  const expression = node.expression
25
25
 
26
- // Check if the call is to addMCPPrompt
27
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPPrompt') {
26
+ // Check if the call is to wireMCPPrompt
27
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPPrompt') {
28
28
  return
29
29
  }
30
30
 
@@ -73,7 +73,7 @@ export const addMCPPrompt = (
73
73
  !matchesFilters(
74
74
  filters,
75
75
  { tags },
76
- { type: PikkuEventTypes.mcp, name: nameValue, filePath },
76
+ { type: PikkuWiringTypes.mcp, name: nameValue, filePath },
77
77
  logger
78
78
  )
79
79
  ) {
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
- import { PikkuEventTypes } from '@pikku/core'
3
+ import { PikkuWiringTypes } from '@pikku/core'
4
4
  import { InspectorFilters, InspectorState, InspectorLogger } from './types.js'
5
5
  import {
6
6
  extractFunctionName,
@@ -23,8 +23,8 @@ export const addMCPResource = (
23
23
  const firstArg = args[0]
24
24
  const expression = node.expression
25
25
 
26
- // Check if the call is to addMCPResource
27
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPResource') {
26
+ // Check if the call is to wireMCPResource
27
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPResource') {
28
28
  return
29
29
  }
30
30
 
@@ -84,7 +84,7 @@ export const addMCPResource = (
84
84
  !matchesFilters(
85
85
  filters,
86
86
  { tags },
87
- { type: PikkuEventTypes.mcp, name: uriValue, filePath },
87
+ { type: PikkuWiringTypes.mcp, name: uriValue, filePath },
88
88
  logger
89
89
  )
90
90
  ) {
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
- import { PikkuEventTypes } from '@pikku/core'
3
+ import { PikkuWiringTypes } from '@pikku/core'
4
4
  import { InspectorFilters, InspectorState, InspectorLogger } from './types.js'
5
5
  import {
6
6
  extractFunctionName,
@@ -23,8 +23,8 @@ export const addMCPTool = (
23
23
  const firstArg = args[0]
24
24
  const expression = node.expression
25
25
 
26
- // Check if the call is to addMCPTool
27
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPTool') {
26
+ // Check if the call is to wireMCPTool
27
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPTool') {
28
28
  return
29
29
  }
30
30
 
@@ -75,7 +75,7 @@ export const addMCPTool = (
75
75
  !matchesFilters(
76
76
  filters,
77
77
  { tags },
78
- { type: PikkuEventTypes.mcp, name: nameValue, filePath },
78
+ { type: PikkuWiringTypes.mcp, name: nameValue, filePath },
79
79
  logger
80
80
  )
81
81
  ) {
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
- import { APIDocs, PikkuEventTypes } from '@pikku/core'
3
+ import { APIDocs, PikkuWiringTypes } from '@pikku/core'
4
4
  import { InspectorFilters, InspectorState, InspectorLogger } from './types.js'
5
5
  import {
6
6
  extractFunctionName,
@@ -24,7 +24,7 @@ export const addQueueWorker = (
24
24
  const expression = node.expression
25
25
 
26
26
  // Check if the call is to addQueueWorker
27
- if (!ts.isIdentifier(expression) || expression.text !== 'addQueueWorker') {
27
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireQueueWorker') {
28
28
  return
29
29
  }
30
30
 
@@ -71,7 +71,7 @@ export const addQueueWorker = (
71
71
  !matchesFilters(
72
72
  filters,
73
73
  { tags },
74
- { type: PikkuEventTypes.queue, name: queueName, filePath },
74
+ { type: PikkuWiringTypes.queue, name: queueName, filePath },
75
75
  logger
76
76
  )
77
77
  ) {
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
- import { APIDocs, PikkuEventTypes } from '@pikku/core'
3
+ import { APIDocs, PikkuWiringTypes } from '@pikku/core'
4
4
  import { InspectorFilters, InspectorState, InspectorLogger } from './types.js'
5
5
  import {
6
6
  extractFunctionName,
@@ -24,7 +24,7 @@ export const addSchedule = (
24
24
  const expression = node.expression
25
25
 
26
26
  // Check if the call is to addScheduledTask
27
- if (!ts.isIdentifier(expression) || expression.text !== 'addScheduledTask') {
27
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireScheduler') {
28
28
  return
29
29
  }
30
30
 
@@ -68,7 +68,7 @@ export const addSchedule = (
68
68
  !matchesFilters(
69
69
  filters,
70
70
  { tags },
71
- { type: PikkuEventTypes.scheduler, name: nameValue, filePath },
71
+ { type: PikkuWiringTypes.scheduler, name: nameValue, filePath },
72
72
  logger
73
73
  )
74
74
  ) {
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ChannelsMeta } from '@pikku/core/channel'
2
- import { HTTPRoutesMeta } from '@pikku/core/http'
2
+ import { HTTPWiringsMeta } from '@pikku/core/http'
3
3
  import { ScheduledTasksMeta } from '@pikku/core/scheduler'
4
4
  import { queueWorkersMeta } from '@pikku/core/queue'
5
5
  import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core'
@@ -23,7 +23,7 @@ export type MetaInputTypes = Map<
23
23
 
24
24
  export interface InspectorHTTPState {
25
25
  metaInputTypes: MetaInputTypes
26
- meta: HTTPRoutesMeta
26
+ meta: HTTPWiringsMeta
27
27
  files: Set<string>
28
28
  }
29
29
 
package/src/utils.test.ts CHANGED
@@ -2,7 +2,7 @@ import { test, describe } from 'node:test'
2
2
  import { strict as assert } from 'node:assert'
3
3
  import { matchesFilters } from './utils.js'
4
4
  import { InspectorFilters } from './types.js'
5
- import { PikkuEventTypes } from '@pikku/core'
5
+ import { PikkuWiringTypes } from '@pikku/core'
6
6
 
7
7
  describe('matchesFilters', () => {
8
8
  // Mock logger for testing
@@ -20,7 +20,7 @@ describe('matchesFilters', () => {
20
20
  const result = matchesFilters(
21
21
  filters,
22
22
  { tags: ['test'] },
23
- { type: PikkuEventTypes.http, name: 'test-route' },
23
+ { type: PikkuWiringTypes.http, name: 'test-route' },
24
24
  mockLogger
25
25
  )
26
26
 
@@ -37,7 +37,7 @@ describe('matchesFilters', () => {
37
37
  const result = matchesFilters(
38
38
  filters,
39
39
  { tags: ['test'] },
40
- { type: PikkuEventTypes.http, name: 'test-route' },
40
+ { type: PikkuWiringTypes.http, name: 'test-route' },
41
41
  mockLogger
42
42
  )
43
43
 
@@ -54,7 +54,7 @@ describe('matchesFilters', () => {
54
54
  const result = matchesFilters(
55
55
  filters,
56
56
  { tags: ['api', 'internal'] },
57
- { type: PikkuEventTypes.http, name: 'test-route' },
57
+ { type: PikkuWiringTypes.http, name: 'test-route' },
58
58
  mockLogger
59
59
  )
60
60
 
@@ -69,7 +69,7 @@ describe('matchesFilters', () => {
69
69
  const result = matchesFilters(
70
70
  filters,
71
71
  { tags: ['internal', 'private'] },
72
- { type: PikkuEventTypes.http, name: 'test-route' },
72
+ { type: PikkuWiringTypes.http, name: 'test-route' },
73
73
  mockLogger
74
74
  )
75
75
 
@@ -84,7 +84,7 @@ describe('matchesFilters', () => {
84
84
  const result = matchesFilters(
85
85
  filters,
86
86
  { tags: undefined },
87
- { type: PikkuEventTypes.http, name: 'test-route' },
87
+ { type: PikkuWiringTypes.http, name: 'test-route' },
88
88
  mockLogger
89
89
  )
90
90
 
@@ -99,7 +99,7 @@ describe('matchesFilters', () => {
99
99
  const result = matchesFilters(
100
100
  filters,
101
101
  { tags: [] },
102
- { type: PikkuEventTypes.http, name: 'test-route' },
102
+ { type: PikkuWiringTypes.http, name: 'test-route' },
103
103
  mockLogger
104
104
  )
105
105
 
@@ -116,7 +116,7 @@ describe('matchesFilters', () => {
116
116
  const result = matchesFilters(
117
117
  filters,
118
118
  { tags: ['test'] },
119
- { type: PikkuEventTypes.http, name: 'test-route' },
119
+ { type: PikkuWiringTypes.http, name: 'test-route' },
120
120
  mockLogger
121
121
  )
122
122
 
@@ -131,21 +131,21 @@ describe('matchesFilters', () => {
131
131
  const result = matchesFilters(
132
132
  filters,
133
133
  { tags: ['test'] },
134
- { type: PikkuEventTypes.http, name: 'test-route' },
134
+ { type: PikkuWiringTypes.http, name: 'test-route' },
135
135
  mockLogger
136
136
  )
137
137
 
138
138
  assert.equal(result, false)
139
139
  })
140
140
 
141
- test('should handle all PikkuEventTypes correctly', () => {
141
+ test('should handle all PikkuWiringTypes correctly', () => {
142
142
  const eventTypes = [
143
- PikkuEventTypes.http,
144
- PikkuEventTypes.channel,
145
- PikkuEventTypes.queue,
146
- PikkuEventTypes.scheduler,
147
- PikkuEventTypes.rpc,
148
- PikkuEventTypes.mcp,
143
+ PikkuWiringTypes.http,
144
+ PikkuWiringTypes.channel,
145
+ PikkuWiringTypes.queue,
146
+ PikkuWiringTypes.scheduler,
147
+ PikkuWiringTypes.rpc,
148
+ PikkuWiringTypes.mcp,
149
149
  ]
150
150
 
151
151
  eventTypes.forEach((eventType) => {
@@ -175,7 +175,7 @@ describe('matchesFilters', () => {
175
175
  filters,
176
176
  { tags: ['test'] },
177
177
  {
178
- type: PikkuEventTypes.http,
178
+ type: PikkuWiringTypes.http,
179
179
  name: 'test-route',
180
180
  filePath: '/project/src/api/routes.ts',
181
181
  },
@@ -194,7 +194,7 @@ describe('matchesFilters', () => {
194
194
  filters,
195
195
  { tags: ['test'] },
196
196
  {
197
- type: PikkuEventTypes.http,
197
+ type: PikkuWiringTypes.http,
198
198
  name: 'test-route',
199
199
  filePath: '/project/src/public/routes.ts',
200
200
  },
@@ -213,7 +213,7 @@ describe('matchesFilters', () => {
213
213
  filters,
214
214
  { tags: ['test'] },
215
215
  {
216
- type: PikkuEventTypes.http,
216
+ type: PikkuWiringTypes.http,
217
217
  name: 'test-route',
218
218
  filePath: 'C:\\project\\src\\api\\routes.ts',
219
219
  },
@@ -232,7 +232,7 @@ describe('matchesFilters', () => {
232
232
  filters,
233
233
  { tags: ['test'] },
234
234
  {
235
- type: PikkuEventTypes.http,
235
+ type: PikkuWiringTypes.http,
236
236
  name: 'test-route',
237
237
  filePath: 'C:\\project\\src\\api\\routes.ts',
238
238
  },
@@ -250,7 +250,7 @@ describe('matchesFilters', () => {
250
250
  const result = matchesFilters(
251
251
  filters,
252
252
  { tags: ['test'] },
253
- { type: PikkuEventTypes.http, name: 'test-route' }, // no filePath
253
+ { type: PikkuWiringTypes.http, name: 'test-route' }, // no filePath
254
254
  mockLogger
255
255
  )
256
256
 
@@ -266,7 +266,7 @@ describe('matchesFilters', () => {
266
266
  filters,
267
267
  { tags: ['test'] },
268
268
  {
269
- type: PikkuEventTypes.http,
269
+ type: PikkuWiringTypes.http,
270
270
  name: 'test-route',
271
271
  filePath: '/project/src/api/v1/routes.ts',
272
272
  },
@@ -289,7 +289,7 @@ describe('matchesFilters', () => {
289
289
  filters,
290
290
  { tags: ['api', 'public'] },
291
291
  {
292
- type: PikkuEventTypes.http,
292
+ type: PikkuWiringTypes.http,
293
293
  name: 'test-route',
294
294
  filePath: '/project/src/api/routes.ts',
295
295
  },
@@ -310,7 +310,7 @@ describe('matchesFilters', () => {
310
310
  filters,
311
311
  { tags: ['api', 'public'] },
312
312
  {
313
- type: PikkuEventTypes.http,
313
+ type: PikkuWiringTypes.http,
314
314
  name: 'test-route',
315
315
  filePath: '/project/src/api/routes.ts',
316
316
  },
@@ -331,7 +331,7 @@ describe('matchesFilters', () => {
331
331
  filters,
332
332
  { tags: ['api', 'public'] },
333
333
  {
334
- type: PikkuEventTypes.http,
334
+ type: PikkuWiringTypes.http,
335
335
  name: 'test-route',
336
336
  filePath: '/project/src/api/routes.ts',
337
337
  },
@@ -352,7 +352,7 @@ describe('matchesFilters', () => {
352
352
  filters,
353
353
  { tags: ['api', 'public'] },
354
354
  {
355
- type: PikkuEventTypes.http,
355
+ type: PikkuWiringTypes.http,
356
356
  name: 'test-route',
357
357
  filePath: '/project/src/api/routes.ts',
358
358
  },
@@ -372,7 +372,7 @@ describe('matchesFilters', () => {
372
372
  const result = matchesFilters(
373
373
  filters,
374
374
  { tags: undefined },
375
- { type: PikkuEventTypes.http, name: 'test-route' },
375
+ { type: PikkuWiringTypes.http, name: 'test-route' },
376
376
  mockLogger
377
377
  )
378
378
 
@@ -387,7 +387,7 @@ describe('matchesFilters', () => {
387
387
  const result = matchesFilters(
388
388
  filters,
389
389
  { tags: ['test'] },
390
- { type: PikkuEventTypes.http, name: '' },
390
+ { type: PikkuWiringTypes.http, name: '' },
391
391
  mockLogger
392
392
  )
393
393
 
@@ -403,7 +403,7 @@ describe('matchesFilters', () => {
403
403
  filters,
404
404
  { tags: ['test'] },
405
405
  {
406
- type: PikkuEventTypes.http,
406
+ type: PikkuWiringTypes.http,
407
407
  name: 'test-route',
408
408
  filePath: '/project/src/api-v2/routes.ts',
409
409
  },
@@ -422,7 +422,7 @@ describe('matchesFilters', () => {
422
422
  filters,
423
423
  { tags: ['test'] },
424
424
  {
425
- type: PikkuEventTypes.http,
425
+ type: PikkuWiringTypes.http,
426
426
  name: 'test-route',
427
427
  filePath: '/project/src/api/routes.ts',
428
428
  },
@@ -440,7 +440,7 @@ describe('matchesFilters', () => {
440
440
  const result = matchesFilters(
441
441
  filters,
442
442
  { tags: ['api', 'public', 'v1'] },
443
- { type: PikkuEventTypes.http, name: 'test-route' },
443
+ { type: PikkuWiringTypes.http, name: 'test-route' },
444
444
  mockLogger
445
445
  )
446
446
 
@@ -455,7 +455,7 @@ describe('matchesFilters', () => {
455
455
  const result = matchesFilters(
456
456
  filters,
457
457
  { tags: ['test'] },
458
- { type: PikkuEventTypes.channel, name: 'test-channel' },
458
+ { type: PikkuWiringTypes.channel, name: 'test-channel' },
459
459
  mockLogger
460
460
  )
461
461
 
@@ -471,7 +471,7 @@ describe('matchesFilters', () => {
471
471
  filters,
472
472
  { tags: ['test'] },
473
473
  {
474
- type: PikkuEventTypes.http,
474
+ type: PikkuWiringTypes.http,
475
475
  name: 'test-route',
476
476
  filePath: '/project/src/internal/routes.ts',
477
477
  },
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript'
2
2
  import { InspectorFilters, InspectorLogger } from './types.js'
3
- import { PikkuEventTypes } from '@pikku/core'
3
+ import { PikkuWiringTypes } from '@pikku/core'
4
4
 
5
5
  type ExtractedFunctionName = {
6
6
  pikkuFuncName: string
@@ -271,7 +271,7 @@ export function extractFunctionName(
271
271
  explicitName: null,
272
272
  }
273
273
 
274
- // Special case for addHTTPRoute: if this is an identifier within an object literal,
274
+ // Special case for wireHTTP: if this is an identifier within an object literal,
275
275
  // it might be coming from the HTTP route handling flow
276
276
  if (
277
277
  ts.isIdentifier(callExpr) &&
@@ -845,7 +845,7 @@ export const matchesFilters = (
845
845
  filters: InspectorFilters,
846
846
  params: { tags?: string[] },
847
847
  meta: {
848
- type: PikkuEventTypes
848
+ type: PikkuWiringTypes
849
849
  name: string
850
850
  filePath?: string
851
851
  },