@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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @pikku/inspector
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Breaking Changes
6
+
7
+ - Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
8
+
3
9
  ## 0.8.1
4
10
 
5
11
  ### Patch Changes
@@ -5,7 +5,7 @@ import type { InspectorFilters, InspectorState, InspectorLogger } from './types.
5
5
  * Build out the nested message-routes by looking up each handler
6
6
  * in state.functions.meta instead of re-inferring it here.
7
7
  */
8
- export declare function addMessagesRoutes(obj: ts.ObjectLiteralExpression, state: InspectorState, checker: ts.TypeChecker): ChannelMeta['messageRoutes'];
8
+ export declare function addMessagesRoutes(obj: ts.ObjectLiteralExpression, state: InspectorState, checker: ts.TypeChecker): ChannelMeta['messageWirings'];
9
9
  /**
10
10
  * Inspect addChannel calls, look up all handlers in state.functions.meta,
11
11
  * and emit one entry into state.channels.meta.
@@ -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 { PikkuEventTypes } from '@pikku/core';
4
+ import { PikkuWiringTypes } from '@pikku/core';
5
5
  import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
6
6
  /**
7
7
  * Safely get the “initializer” expression of a property-like AST node:
@@ -76,7 +76,7 @@ function getHandlerNameFromExpression(expr, checker) {
76
76
  */
77
77
  export function addMessagesRoutes(obj, state, checker) {
78
78
  const result = {};
79
- const onMsgRouteProp = getPropertyAssignmentInitializer(obj, 'onMessageRoute', true, checker);
79
+ const onMsgRouteProp = getPropertyAssignmentInitializer(obj, 'onMessageWiring', true, checker);
80
80
  if (!onMsgRouteProp)
81
81
  return result;
82
82
  if (!onMsgRouteProp || !ts.isObjectLiteralExpression(onMsgRouteProp))
@@ -271,7 +271,7 @@ export function addChannel(node, checker, state, filters, logger) {
271
271
  if (!ts.isCallExpression(node))
272
272
  return;
273
273
  const { expression, arguments: args } = node;
274
- if (!ts.isIdentifier(expression) || expression.text !== 'addChannel')
274
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireChannel')
275
275
  return;
276
276
  const first = args[0];
277
277
  if (!first || !ts.isObjectLiteralExpression(first))
@@ -293,7 +293,7 @@ export function addChannel(node, checker, state, filters, logger) {
293
293
  const tags = getPropertyValue(obj, 'tags');
294
294
  const query = getPropertyValue(obj, 'query');
295
295
  const filePath = node.getSourceFile().fileName;
296
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.channel, name, filePath }, logger))
296
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.channel, name, filePath }, logger))
297
297
  return;
298
298
  const connect = getPropertyAssignmentInitializer(obj, 'onConnect', false, checker);
299
299
  const disconnect = getPropertyAssignmentInitializer(obj, 'onDisconnect', false, checker);
@@ -315,7 +315,7 @@ export function addChannel(node, checker, state, filters, logger) {
315
315
  }
316
316
  }
317
317
  // nested message-routes
318
- const messageRoutes = addMessagesRoutes(obj, state, checker);
318
+ const messageWirings = addMessagesRoutes(obj, state, checker);
319
319
  // record into state
320
320
  state.channels.files.add(node.getSourceFile().fileName);
321
321
  state.channels.meta[name] = {
@@ -341,7 +341,7 @@ export function addChannel(node, checker, state, filters, logger) {
341
341
  }
342
342
  : null,
343
343
  message,
344
- messageRoutes,
344
+ messageWirings,
345
345
  docs: docs ?? undefined,
346
346
  tags: tags ?? undefined,
347
347
  };
@@ -1,5 +1,4 @@
1
1
  import * as ts from 'typescript';
2
- // const VRAMEWORK_TYPES = ['CoreConfig', 'CoreService', 'CoreServices', 'CoreSingletonService', 'CoreSessionService']
3
2
  export const addFileExtendsCoreType = (node, checker, methods, expectedTypeName) => {
4
3
  if (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) {
5
4
  const fileName = node.getSourceFile().fileName;
@@ -10,7 +10,7 @@ export declare const getInputTypes: (metaTypes: Map<string, {
10
10
  body?: string[];
11
11
  }>, methodType: string, inputType: string | null, queryValues: string[], paramsValues: string[]) => undefined;
12
12
  /**
13
- * Simplified addHTTPRoute: re-uses function metadata from state.functions.meta
13
+ * Simplified wireHTTP: re-uses function metadata from state.functions.meta
14
14
  * instead of re-inferring types here.
15
15
  */
16
16
  export declare const addHTTPRoute: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
@@ -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 { PikkuEventTypes } from '@pikku/core';
4
+ import { PikkuWiringTypes } from '@pikku/core';
5
5
  import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
6
6
  /**
7
7
  * Populate metaInputTypes for a given route based on method, input type,
@@ -20,7 +20,7 @@ export const getInputTypes = (metaTypes, methodType, inputType, queryValues, par
20
20
  return;
21
21
  };
22
22
  /**
23
- * Simplified addHTTPRoute: re-uses function metadata from state.functions.meta
23
+ * Simplified wireHTTP: re-uses function metadata from state.functions.meta
24
24
  * instead of re-inferring types here.
25
25
  */
26
26
  export const addHTTPRoute = (node, checker, state, filters, logger) => {
@@ -28,7 +28,7 @@ export const addHTTPRoute = (node, checker, state, filters, logger) => {
28
28
  if (!ts.isCallExpression(node))
29
29
  return;
30
30
  const { expression, arguments: args } = node;
31
- if (!ts.isIdentifier(expression) || expression.text !== 'addHTTPRoute')
31
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireHTTP')
32
32
  return;
33
33
  // must pass an object literal
34
34
  const firstArg = args[0];
@@ -46,7 +46,7 @@ export const addHTTPRoute = (node, checker, state, filters, logger) => {
46
46
  const tags = getPropertyValue(obj, 'tags') || undefined;
47
47
  const query = getPropertyValue(obj, 'query') || [];
48
48
  const filePath = node.getSourceFile().fileName;
49
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.http, name: route, filePath }, logger)) {
49
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.http, name: route, filePath }, logger)) {
50
50
  return;
51
51
  }
52
52
  // --- find the referenced function ---
@@ -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 { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
5
5
  export const addMCPPrompt = (node, checker, state, filters, logger) => {
6
6
  if (!ts.isCallExpression(node)) {
@@ -9,8 +9,8 @@ export const addMCPPrompt = (node, checker, state, filters, logger) => {
9
9
  const args = node.arguments;
10
10
  const firstArg = args[0];
11
11
  const expression = node.expression;
12
- // Check if the call is to addMCPPrompt
13
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPPrompt') {
12
+ // Check if the call is to wireMCPPrompt
13
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPPrompt') {
14
14
  return;
15
15
  }
16
16
  if (!firstArg) {
@@ -36,7 +36,7 @@ export const addMCPPrompt = (node, checker, state, filters, logger) => {
36
36
  return;
37
37
  }
38
38
  const filePath = node.getSourceFile().fileName;
39
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.mcp, name: nameValue, filePath }, logger)) {
39
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.mcp, name: nameValue, filePath }, logger)) {
40
40
  return;
41
41
  }
42
42
  // lookup existing function metadata
@@ -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 { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
5
5
  export const addMCPResource = (node, checker, state, filters, logger) => {
6
6
  if (!ts.isCallExpression(node)) {
@@ -9,8 +9,8 @@ export const addMCPResource = (node, checker, state, filters, logger) => {
9
9
  const args = node.arguments;
10
10
  const firstArg = args[0];
11
11
  const expression = node.expression;
12
- // Check if the call is to addMCPResource
13
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPResource') {
12
+ // Check if the call is to wireMCPResource
13
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPResource') {
14
14
  return;
15
15
  }
16
16
  if (!firstArg) {
@@ -42,7 +42,7 @@ export const addMCPResource = (node, checker, state, filters, logger) => {
42
42
  return;
43
43
  }
44
44
  const filePath = node.getSourceFile().fileName;
45
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.mcp, name: uriValue, filePath }, logger)) {
45
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.mcp, name: uriValue, filePath }, logger)) {
46
46
  return;
47
47
  }
48
48
  // lookup existing function metadata
@@ -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 { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
5
5
  export const addMCPTool = (node, checker, state, filters, logger) => {
6
6
  if (!ts.isCallExpression(node)) {
@@ -9,8 +9,8 @@ export const addMCPTool = (node, checker, state, filters, logger) => {
9
9
  const args = node.arguments;
10
10
  const firstArg = args[0];
11
11
  const expression = node.expression;
12
- // Check if the call is to addMCPTool
13
- if (!ts.isIdentifier(expression) || expression.text !== 'addMCPTool') {
12
+ // Check if the call is to wireMCPTool
13
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireMCPTool') {
14
14
  return;
15
15
  }
16
16
  if (!firstArg) {
@@ -38,7 +38,7 @@ export const addMCPTool = (node, checker, state, filters, logger) => {
38
38
  return;
39
39
  }
40
40
  const filePath = node.getSourceFile().fileName;
41
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.mcp, name: nameValue, filePath }, logger)) {
41
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.mcp, name: nameValue, filePath }, logger)) {
42
42
  return;
43
43
  }
44
44
  // lookup existing function metadata
@@ -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 { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
5
5
  export const addQueueWorker = (node, checker, state, filters, logger) => {
6
6
  if (!ts.isCallExpression(node)) {
@@ -10,7 +10,7 @@ export const addQueueWorker = (node, checker, state, filters, logger) => {
10
10
  const firstArg = args[0];
11
11
  const expression = node.expression;
12
12
  // Check if the call is to addQueueWorker
13
- if (!ts.isIdentifier(expression) || expression.text !== 'addQueueWorker') {
13
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireQueueWorker') {
14
14
  return;
15
15
  }
16
16
  if (!firstArg) {
@@ -33,7 +33,7 @@ export const addQueueWorker = (node, checker, state, filters, logger) => {
33
33
  return;
34
34
  }
35
35
  const filePath = node.getSourceFile().fileName;
36
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.queue, name: queueName, filePath }, logger)) {
36
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.queue, name: queueName, filePath }, logger)) {
37
37
  console.info(`• Skipping queue processor '${pikkuFuncName}' for queue '${queueName}' due to filter mismatch.`);
38
38
  return;
39
39
  }
@@ -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 { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
5
5
  export const addSchedule = (node, checker, state, filters, logger) => {
6
6
  if (!ts.isCallExpression(node)) {
@@ -10,7 +10,7 @@ export const addSchedule = (node, checker, state, filters, logger) => {
10
10
  const firstArg = args[0];
11
11
  const expression = node.expression;
12
12
  // Check if the call is to addScheduledTask
13
- if (!ts.isIdentifier(expression) || expression.text !== 'addScheduledTask') {
13
+ if (!ts.isIdentifier(expression) || expression.text !== 'wireScheduler') {
14
14
  return;
15
15
  }
16
16
  if (!firstArg) {
@@ -32,7 +32,7 @@ export const addSchedule = (node, checker, state, filters, logger) => {
32
32
  return;
33
33
  }
34
34
  const filePath = node.getSourceFile().fileName;
35
- if (!matchesFilters(filters, { tags }, { type: PikkuEventTypes.scheduler, name: nameValue, filePath }, logger)) {
35
+ if (!matchesFilters(filters, { tags }, { type: PikkuWiringTypes.scheduler, name: nameValue, filePath }, logger)) {
36
36
  return;
37
37
  }
38
38
  state.scheduledTasks.files.add(node.getSourceFile().fileName);
package/dist/types.d.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';
@@ -18,7 +18,7 @@ export type MetaInputTypes = Map<string, {
18
18
  }>;
19
19
  export interface InspectorHTTPState {
20
20
  metaInputTypes: MetaInputTypes;
21
- meta: HTTPRoutesMeta;
21
+ meta: HTTPWiringsMeta;
22
22
  files: Set<string>;
23
23
  }
24
24
  export interface InspectorFunctionState {
package/dist/utils.d.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
  type ExtractedFunctionName = {
5
5
  pikkuFuncName: string;
6
6
  name: string;
@@ -28,7 +28,7 @@ export declare function getPropertyAssignmentInitializer(obj: ts.ObjectLiteralEx
28
28
  export declare const matchesFilters: (filters: InspectorFilters, params: {
29
29
  tags?: string[];
30
30
  }, meta: {
31
- type: PikkuEventTypes;
31
+ type: PikkuWiringTypes;
32
32
  name: string;
33
33
  filePath?: string;
34
34
  }, logger: InspectorLogger) => boolean;
package/dist/utils.js CHANGED
@@ -204,7 +204,7 @@ export function extractFunctionName(callExpr, checker) {
204
204
  propertyName: null,
205
205
  explicitName: null,
206
206
  };
207
- // Special case for addHTTPRoute: if this is an identifier within an object literal,
207
+ // Special case for wireHTTP: if this is an identifier within an object literal,
208
208
  // it might be coming from the HTTP route handling flow
209
209
  if (ts.isIdentifier(callExpr) &&
210
210
  callExpr.parent &&