@pikku/inspector 0.8.0 → 0.8.1
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 +27 -0
- package/dist/add-channel.d.ts +2 -2
- package/dist/add-channel.js +3 -2
- package/dist/add-functions.d.ts +2 -2
- package/dist/add-functions.js +2 -3
- package/dist/add-http-route.d.ts +2 -2
- package/dist/add-http-route.js +3 -2
- package/dist/add-mcp-prompt.d.ts +2 -2
- package/dist/add-mcp-prompt.js +3 -2
- package/dist/add-mcp-resource.d.ts +2 -2
- package/dist/add-mcp-resource.js +3 -2
- package/dist/add-mcp-tool.d.ts +2 -2
- package/dist/add-mcp-tool.js +3 -2
- package/dist/add-queue-worker.d.ts +2 -2
- package/dist/add-queue-worker.js +3 -2
- package/dist/add-schedule.d.ts +2 -2
- package/dist/add-schedule.js +3 -2
- package/dist/inspector.d.ts +2 -2
- package/dist/inspector.js +3 -3
- package/dist/types.d.ts +8 -0
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +40 -5
- package/dist/visit.d.ts +3 -3
- package/dist/visit.js +12 -12
- package/lcov.info +4655 -0
- package/package.json +2 -2
- package/run-tests.sh +0 -0
- package/src/add-channel.ts +15 -3
- package/src/add-functions.ts +4 -6
- package/src/add-http-route.ts +7 -3
- package/src/add-mcp-prompt.ts +7 -3
- package/src/add-mcp-resource.ts +7 -3
- package/src/add-mcp-tool.ts +7 -3
- package/src/add-queue-worker.ts +7 -3
- package/src/add-schedule.ts +7 -3
- package/src/inspector.ts +4 -2
- package/src/types.ts +9 -0
- package/src/utils.test.ts +484 -0
- package/src/utils.ts +56 -6
- package/src/visit.ts +19 -13
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @pikku/inspector
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 44e3ff4: feat: enhance CLI filtering with type and directory filters
|
|
8
|
+
|
|
9
|
+
- Add --types filter to filter by PikkuEventTypes (http, channel, queue, scheduler, rpc, mcp)
|
|
10
|
+
- Add --directories filter to filter by file paths/directories
|
|
11
|
+
- All filters (tags, types, directories) now work together with AND logic
|
|
12
|
+
- Add comprehensive logging interface to inspector package
|
|
13
|
+
- Add comprehensive test suite for matchesFilters function
|
|
14
|
+
- Support cross-platform path handling
|
|
15
|
+
|
|
16
|
+
- 7c592b8: feat: support for required services and improved service configuration
|
|
17
|
+
|
|
18
|
+
This release includes several enhancements to service management and configuration:
|
|
19
|
+
|
|
20
|
+
- Added support for required services configuration
|
|
21
|
+
- Improved service discovery and registration
|
|
22
|
+
- Added typed RPC clients for service communication
|
|
23
|
+
- Updated middleware to run per function
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [3261090]
|
|
26
|
+
- Updated dependencies [7c592b8]
|
|
27
|
+
- Updated dependencies [30a082f]
|
|
28
|
+
- @pikku/core@0.8.1
|
|
29
|
+
|
|
3
30
|
## 0.8.0
|
|
4
31
|
|
|
5
32
|
### Major Features
|
package/dist/add-channel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import type { ChannelMeta } from '@pikku/core/channel';
|
|
3
|
-
import type { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
+
import type { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
4
4
|
/**
|
|
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.
|
|
@@ -10,4 +10,4 @@ export declare function addMessagesRoutes(obj: ts.ObjectLiteralExpression, state
|
|
|
10
10
|
* Inspect addChannel calls, look up all handlers in state.functions.meta,
|
|
11
11
|
* and emit one entry into state.channels.meta.
|
|
12
12
|
*/
|
|
13
|
-
export declare function addChannel(node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters): void;
|
|
13
|
+
export declare function addChannel(node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger): void;
|
package/dist/add-channel.js
CHANGED
|
@@ -267,7 +267,7 @@ export function addMessagesRoutes(obj, state, checker) {
|
|
|
267
267
|
* Inspect addChannel calls, look up all handlers in state.functions.meta,
|
|
268
268
|
* and emit one entry into state.channels.meta.
|
|
269
269
|
*/
|
|
270
|
-
export function addChannel(node, checker, state, filters) {
|
|
270
|
+
export function addChannel(node, checker, state, filters, logger) {
|
|
271
271
|
if (!ts.isCallExpression(node))
|
|
272
272
|
return;
|
|
273
273
|
const { expression, arguments: args } = node;
|
|
@@ -292,7 +292,8 @@ export function addChannel(node, checker, state, filters) {
|
|
|
292
292
|
const docs = getPropertyValue(obj, 'docs');
|
|
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
297
|
return;
|
|
297
298
|
const connect = getPropertyAssignmentInitializer(obj, 'onConnect', false, checker);
|
|
298
299
|
const disconnect = getPropertyAssignmentInitializer(obj, 'onDisconnect', false, checker);
|
package/dist/add-functions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorState, InspectorFilters } from './types.js';
|
|
2
|
+
import { InspectorState, InspectorFilters, InspectorLogger } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Inspect pikkuFunc calls, extract input/output and first-arg destructuring,
|
|
5
5
|
* then push into state.functions.meta.
|
|
6
6
|
*/
|
|
7
|
-
export declare function addFunctions(node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters): void;
|
|
7
|
+
export declare function addFunctions(node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger): void;
|
package/dist/add-functions.js
CHANGED
|
@@ -171,7 +171,7 @@ function unwrapPromise(checker, type) {
|
|
|
171
171
|
* Inspect pikkuFunc calls, extract input/output and first-arg destructuring,
|
|
172
172
|
* then push into state.functions.meta.
|
|
173
173
|
*/
|
|
174
|
-
export function addFunctions(node, checker, state, filters) {
|
|
174
|
+
export function addFunctions(node, checker, state, filters, logger) {
|
|
175
175
|
if (!ts.isCallExpression(node))
|
|
176
176
|
return;
|
|
177
177
|
const { expression, arguments: args, typeArguments } = node;
|
|
@@ -226,8 +226,7 @@ export function addFunctions(node, checker, state, filters) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
else if (ts.isIdentifier(firstParam.name)
|
|
230
|
-
!firstParam.name.text.startsWith('_')) {
|
|
229
|
+
else if (ts.isIdentifier(firstParam.name)) {
|
|
231
230
|
services.optimized = false;
|
|
232
231
|
}
|
|
233
232
|
}
|
package/dist/add-http-route.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorState, InspectorFilters } from './types.js';
|
|
2
|
+
import { InspectorState, InspectorFilters, InspectorLogger } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Populate metaInputTypes for a given route based on method, input type,
|
|
5
5
|
* query and params. Returns undefined (we only mutate metaTypes).
|
|
@@ -13,4 +13,4 @@ export declare const getInputTypes: (metaTypes: Map<string, {
|
|
|
13
13
|
* Simplified addHTTPRoute: re-uses function metadata from state.functions.meta
|
|
14
14
|
* instead of re-inferring types here.
|
|
15
15
|
*/
|
|
16
|
-
export declare const addHTTPRoute: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
16
|
+
export declare const addHTTPRoute: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-http-route.js
CHANGED
|
@@ -23,7 +23,7 @@ export const getInputTypes = (metaTypes, methodType, inputType, queryValues, par
|
|
|
23
23
|
* Simplified addHTTPRoute: re-uses function metadata from state.functions.meta
|
|
24
24
|
* instead of re-inferring types here.
|
|
25
25
|
*/
|
|
26
|
-
export const addHTTPRoute = (node, checker, state, filters) => {
|
|
26
|
+
export const addHTTPRoute = (node, checker, state, filters, logger) => {
|
|
27
27
|
// only look at calls
|
|
28
28
|
if (!ts.isCallExpression(node))
|
|
29
29
|
return;
|
|
@@ -45,7 +45,8 @@ export const addHTTPRoute = (node, checker, state, filters) => {
|
|
|
45
45
|
const docs = getPropertyValue(obj, 'docs') || undefined;
|
|
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
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
// --- find the referenced function ---
|
package/dist/add-mcp-prompt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const addMCPPrompt: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const addMCPPrompt: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-mcp-prompt.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { getPropertyValue } from './get-property-value.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
|
|
5
|
-
export const addMCPPrompt = (node, checker, state, filters) => {
|
|
5
|
+
export const addMCPPrompt = (node, checker, state, filters, logger) => {
|
|
6
6
|
if (!ts.isCallExpression(node)) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -35,7 +35,8 @@ export const addMCPPrompt = (node, checker, state, filters) => {
|
|
|
35
35
|
console.error(`• MCP prompt '${nameValue}' is missing a description.`);
|
|
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
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
// lookup existing function metadata
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const addMCPResource: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const addMCPResource: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-mcp-resource.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { getPropertyValue } from './get-property-value.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
|
|
5
|
-
export const addMCPResource = (node, checker, state, filters) => {
|
|
5
|
+
export const addMCPResource = (node, checker, state, filters, logger) => {
|
|
6
6
|
if (!ts.isCallExpression(node)) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -41,7 +41,8 @@ export const addMCPResource = (node, checker, state, filters) => {
|
|
|
41
41
|
console.error(`• MCP resource '${uriValue}' is missing a description.`);
|
|
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
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
// lookup existing function metadata
|
package/dist/add-mcp-tool.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const addMCPTool: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const addMCPTool: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-mcp-tool.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { getPropertyValue } from './get-property-value.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
|
|
5
|
-
export const addMCPTool = (node, checker, state, filters) => {
|
|
5
|
+
export const addMCPTool = (node, checker, state, filters, logger) => {
|
|
6
6
|
if (!ts.isCallExpression(node)) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -37,7 +37,8 @@ export const addMCPTool = (node, checker, state, filters) => {
|
|
|
37
37
|
console.error(`• MCP tool '${nameValue}' is missing a description.`);
|
|
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
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
// lookup existing function metadata
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const addQueueWorker: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const addQueueWorker: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-queue-worker.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { getPropertyValue } from './get-property-value.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
|
|
5
|
-
export const addQueueWorker = (node, checker, state, filters) => {
|
|
5
|
+
export const addQueueWorker = (node, checker, state, filters, logger) => {
|
|
6
6
|
if (!ts.isCallExpression(node)) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -32,7 +32,8 @@ export const addQueueWorker = (node, checker, state, filters) => {
|
|
|
32
32
|
console.error(`• No 'queueName' provided for queue processor function '${pikkuFuncName}'.`);
|
|
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
37
|
console.info(`• Skipping queue processor '${pikkuFuncName}' for queue '${queueName}' due to filter mismatch.`);
|
|
37
38
|
return;
|
|
38
39
|
}
|
package/dist/add-schedule.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const addSchedule: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const addSchedule: (node: ts.Node, checker: ts.TypeChecker, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/add-schedule.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ts from 'typescript';
|
|
|
2
2
|
import { getPropertyValue } from './get-property-value.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
import { extractFunctionName, getPropertyAssignmentInitializer, matchesFilters, } from './utils.js';
|
|
5
|
-
export const addSchedule = (node, checker, state, filters) => {
|
|
5
|
+
export const addSchedule = (node, checker, state, filters, logger) => {
|
|
6
6
|
if (!ts.isCallExpression(node)) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -31,7 +31,8 @@ export const addSchedule = (node, checker, state, filters) => {
|
|
|
31
31
|
if (!nameValue || !scheduleValue) {
|
|
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
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
state.scheduledTasks.files.add(node.getSourceFile().fileName);
|
package/dist/inspector.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { InspectorState, InspectorHTTPState, InspectorFilters } from './types.js';
|
|
1
|
+
import { InspectorState, InspectorHTTPState, InspectorFilters, InspectorLogger } from './types.js';
|
|
2
2
|
export declare const normalizeHTTPTypes: (httpState: InspectorHTTPState) => InspectorHTTPState;
|
|
3
|
-
export declare const inspect: (routeFiles: string[], filters: InspectorFilters) => InspectorState;
|
|
3
|
+
export declare const inspect: (logger: InspectorLogger, routeFiles: string[], filters: InspectorFilters) => InspectorState;
|
package/dist/inspector.js
CHANGED
|
@@ -4,7 +4,7 @@ import { TypesMap } from './types-map.js';
|
|
|
4
4
|
export const normalizeHTTPTypes = (httpState) => {
|
|
5
5
|
return httpState;
|
|
6
6
|
};
|
|
7
|
-
export const inspect = (routeFiles, filters) => {
|
|
7
|
+
export const inspect = (logger, routeFiles, filters) => {
|
|
8
8
|
const program = ts.createProgram(routeFiles, {
|
|
9
9
|
target: ts.ScriptTarget.ESNext,
|
|
10
10
|
module: ts.ModuleKind.CommonJS,
|
|
@@ -52,11 +52,11 @@ export const inspect = (routeFiles, filters) => {
|
|
|
52
52
|
};
|
|
53
53
|
// First sweep: add all functions
|
|
54
54
|
for (const sourceFile of sourceFiles) {
|
|
55
|
-
ts.forEachChild(sourceFile, (child) => visitSetup(checker, child, state, filters));
|
|
55
|
+
ts.forEachChild(sourceFile, (child) => visitSetup(checker, child, state, filters, logger));
|
|
56
56
|
}
|
|
57
57
|
// Second sweep: add all transports
|
|
58
58
|
for (const sourceFile of sourceFiles) {
|
|
59
|
-
ts.forEachChild(sourceFile, (child) => visitRoutes(checker, child, state, filters));
|
|
59
|
+
ts.forEachChild(sourceFile, (child) => visitRoutes(checker, child, state, filters, logger));
|
|
60
60
|
}
|
|
61
61
|
// Normalise the typesMap
|
|
62
62
|
state.http = normalizeHTTPTypes(state.http);
|
package/dist/types.d.ts
CHANGED
|
@@ -35,7 +35,15 @@ export interface InspectorChannelState {
|
|
|
35
35
|
}
|
|
36
36
|
export type InspectorFilters = {
|
|
37
37
|
tags?: string[];
|
|
38
|
+
types?: string[];
|
|
39
|
+
directories?: string[];
|
|
38
40
|
};
|
|
41
|
+
export interface InspectorLogger {
|
|
42
|
+
info: (message: string) => void;
|
|
43
|
+
error: (message: string) => void;
|
|
44
|
+
warn: (message: string) => void;
|
|
45
|
+
debug: (message: string) => void;
|
|
46
|
+
}
|
|
39
47
|
export interface InspectorState {
|
|
40
48
|
singletonServicesTypeImportMap: PathToNameAndType;
|
|
41
49
|
sessionServicesTypeImportMap: PathToNameAndType;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters } from './types.js';
|
|
2
|
+
import { InspectorFilters, InspectorLogger } from './types.js';
|
|
3
3
|
import { PikkuEventTypes } from '@pikku/core';
|
|
4
4
|
type ExtractedFunctionName = {
|
|
5
5
|
pikkuFuncName: string;
|
|
@@ -30,5 +30,6 @@ export declare const matchesFilters: (filters: InspectorFilters, params: {
|
|
|
30
30
|
}, meta: {
|
|
31
31
|
type: PikkuEventTypes;
|
|
32
32
|
name: string;
|
|
33
|
-
|
|
33
|
+
filePath?: string;
|
|
34
|
+
}, logger: InspectorLogger) => boolean;
|
|
34
35
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -660,13 +660,48 @@ export function getPropertyAssignmentInitializer(obj, propName, followShorthand
|
|
|
660
660
|
}
|
|
661
661
|
return undefined;
|
|
662
662
|
}
|
|
663
|
-
export const matchesFilters = (filters, params, meta) => {
|
|
664
|
-
|
|
663
|
+
export const matchesFilters = (filters, params, meta, logger) => {
|
|
664
|
+
// If no filters are provided, allow everything
|
|
665
|
+
if (Object.keys(filters).length === 0) {
|
|
665
666
|
return true;
|
|
666
667
|
}
|
|
667
|
-
|
|
668
|
+
// If all filter arrays are empty, allow everything
|
|
669
|
+
if ((!filters.tags || filters.tags.length === 0) &&
|
|
670
|
+
(!filters.types || filters.types.length === 0) &&
|
|
671
|
+
(!filters.directories || filters.directories.length === 0)) {
|
|
668
672
|
return true;
|
|
669
673
|
}
|
|
670
|
-
|
|
671
|
-
|
|
674
|
+
// Check type filter
|
|
675
|
+
if (filters.types && filters.types.length > 0) {
|
|
676
|
+
if (!filters.types.includes(meta.type)) {
|
|
677
|
+
logger.debug(`⒡ Filtered by type: ${meta.type}:${meta.name}`);
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
// Check directory filter
|
|
682
|
+
if (filters.directories && filters.directories.length > 0) {
|
|
683
|
+
if (!meta.filePath) {
|
|
684
|
+
logger.debug(`⒡ Filtered by directory: ${meta.type}:${meta.name} (${meta.filePath})`);
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
const matchesDirectory = filters.directories.some((dir) => {
|
|
688
|
+
// Normalize paths for comparison
|
|
689
|
+
const normalizedFilePath = meta.filePath.replace(/\\/g, '/');
|
|
690
|
+
const normalizedDir = dir.replace(/\\/g, '/');
|
|
691
|
+
return normalizedFilePath.includes(normalizedDir);
|
|
692
|
+
});
|
|
693
|
+
if (!matchesDirectory) {
|
|
694
|
+
logger.debug(`⒡ Filtered by directory: ${meta.type}:${meta.name} (${meta.filePath})`);
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
// Check tag filter
|
|
699
|
+
if (filters.tags && filters.tags.length > 0) {
|
|
700
|
+
if (!params.tags ||
|
|
701
|
+
!filters.tags.some((tag) => params.tags.includes(tag))) {
|
|
702
|
+
logger.debug(`⒡ Filtered by tags: ${meta.type}:${meta.name}`);
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return true;
|
|
672
707
|
};
|
package/dist/visit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { InspectorFilters, InspectorState } from './types.js';
|
|
3
|
-
export declare const visitSetup: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState, filters: InspectorFilters) => void;
|
|
4
|
-
export declare const visitRoutes: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState, filters: InspectorFilters) => void;
|
|
2
|
+
import { InspectorFilters, InspectorState, InspectorLogger } from './types.js';
|
|
3
|
+
export declare const visitSetup: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
|
4
|
+
export declare const visitRoutes: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState, filters: InspectorFilters, logger: InspectorLogger) => void;
|
package/dist/visit.js
CHANGED
|
@@ -9,23 +9,23 @@ import { addMCPTool } from './add-mcp-tool.js';
|
|
|
9
9
|
import { addMCPPrompt } from './add-mcp-prompt.js';
|
|
10
10
|
import { addFunctions } from './add-functions.js';
|
|
11
11
|
import { addChannel } from './add-channel.js';
|
|
12
|
-
export const visitSetup = (checker, node, state, filters) => {
|
|
12
|
+
export const visitSetup = (checker, node, state, filters, logger) => {
|
|
13
13
|
addFileExtendsCoreType(node, checker, state.singletonServicesTypeImportMap, 'CoreSingletonServices');
|
|
14
14
|
addFileExtendsCoreType(node, checker, state.sessionServicesTypeImportMap, 'CoreServices');
|
|
15
15
|
addFileExtendsCoreType(node, checker, state.userSessionTypeImportMap, 'CoreUserSession');
|
|
16
16
|
addFileWithFactory(node, checker, state.singletonServicesFactories, 'CreateSingletonServices');
|
|
17
17
|
addFileWithFactory(node, checker, state.sessionServicesFactories, 'CreateSessionServices');
|
|
18
18
|
addFileWithFactory(node, checker, state.configFactories, 'CreateConfig');
|
|
19
|
-
addFunctions(node, checker, state, filters);
|
|
20
|
-
ts.forEachChild(node, (child) => visitSetup(checker, child, state, filters));
|
|
19
|
+
addFunctions(node, checker, state, filters, logger);
|
|
20
|
+
ts.forEachChild(node, (child) => visitSetup(checker, child, state, filters, logger));
|
|
21
21
|
};
|
|
22
|
-
export const visitRoutes = (checker, node, state, filters) => {
|
|
23
|
-
addHTTPRoute(node, checker, state, filters);
|
|
24
|
-
addSchedule(node, checker, state, filters);
|
|
25
|
-
addQueueWorker(node, checker, state, filters);
|
|
26
|
-
addChannel(node, checker, state, filters);
|
|
27
|
-
addMCPResource(node, checker, state, filters);
|
|
28
|
-
addMCPTool(node, checker, state, filters);
|
|
29
|
-
addMCPPrompt(node, checker, state, filters);
|
|
30
|
-
ts.forEachChild(node, (child) => visitRoutes(checker, child, state, filters));
|
|
22
|
+
export const visitRoutes = (checker, node, state, filters, logger) => {
|
|
23
|
+
addHTTPRoute(node, checker, state, filters, logger);
|
|
24
|
+
addSchedule(node, checker, state, filters, logger);
|
|
25
|
+
addQueueWorker(node, checker, state, filters, logger);
|
|
26
|
+
addChannel(node, checker, state, filters, logger);
|
|
27
|
+
addMCPResource(node, checker, state, filters, logger);
|
|
28
|
+
addMCPTool(node, checker, state, filters, logger);
|
|
29
|
+
addMCPPrompt(node, checker, state, filters, logger);
|
|
30
|
+
ts.forEachChild(node, (child) => visitRoutes(checker, child, state, filters, logger));
|
|
31
31
|
};
|