@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.
- package/CHANGELOG.md +14 -0
- package/dist/add/add-channel.d.ts +17 -0
- package/dist/{add-channel.js → add/add-channel.js} +60 -34
- package/dist/add/add-cli.d.ts +9 -0
- package/dist/add/add-cli.js +566 -0
- package/dist/{add-file-extends-core-type.d.ts → add/add-file-extends-core-type.d.ts} +2 -2
- package/dist/{add-file-extends-core-type.js → add/add-file-extends-core-type.js} +17 -4
- package/dist/{add-file-with-config.d.ts → add/add-file-with-config.d.ts} +1 -1
- package/dist/{add-file-with-config.js → add/add-file-with-config.js} +1 -1
- package/dist/{add-file-with-factory.d.ts → add/add-file-with-factory.d.ts} +2 -2
- package/dist/{add-file-with-factory.js → add/add-file-with-factory.js} +38 -5
- package/dist/add/add-functions.d.ts +6 -0
- package/dist/{add-functions.js → add/add-functions.js} +77 -10
- package/dist/{add-http-route.d.ts → add/add-http-route.d.ts} +2 -3
- package/dist/{add-http-route.js → add/add-http-route.js} +26 -13
- package/dist/add/add-mcp-prompt.d.ts +2 -0
- package/dist/add/add-mcp-prompt.js +74 -0
- package/dist/add/add-mcp-resource.d.ts +2 -0
- package/dist/add/add-mcp-resource.js +84 -0
- package/dist/add/add-mcp-tool.d.ts +2 -0
- package/dist/add/add-mcp-tool.js +80 -0
- package/dist/add/add-middleware.d.ts +5 -0
- package/dist/add/add-middleware.js +290 -0
- package/dist/add/add-permission.d.ts +5 -0
- package/dist/add/add-permission.js +292 -0
- package/dist/add/add-queue-worker.d.ts +2 -0
- package/dist/add/add-queue-worker.js +52 -0
- package/dist/{add-rpc-invocations.d.ts → add/add-rpc-invocations.d.ts} +1 -1
- package/dist/add/add-schedule.d.ts +2 -0
- package/dist/{add-schedule.js → add/add-schedule.js} +16 -11
- package/dist/error-codes.d.ts +35 -0
- package/dist/error-codes.js +40 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/inspector.d.ts +2 -3
- package/dist/inspector.js +38 -8
- package/dist/types.d.ts +108 -1
- package/dist/utils/ensure-function-metadata.d.ts +6 -0
- package/dist/utils/ensure-function-metadata.js +18 -0
- package/dist/utils/extract-function-name.d.ts +31 -0
- package/dist/{utils.js → utils/extract-function-name.js} +35 -149
- package/dist/utils/extract-services.d.ts +6 -0
- package/dist/utils/extract-services.js +29 -0
- package/dist/utils/filter-inspector-state.d.ts +6 -0
- package/dist/utils/filter-inspector-state.js +382 -0
- package/dist/utils/filter-utils.d.ts +19 -0
- package/dist/utils/filter-utils.js +109 -0
- package/dist/utils/find-root-dir.d.ts +23 -0
- package/dist/utils/find-root-dir.js +55 -0
- package/dist/utils/get-files-and-methods.d.ts +22 -0
- package/dist/utils/get-files-and-methods.js +61 -0
- package/dist/utils/get-property-value.d.ts +12 -0
- package/dist/{get-property-value.js → utils/get-property-value.js} +20 -0
- package/dist/utils/middleware.d.ts +39 -0
- package/dist/utils/middleware.js +157 -0
- package/dist/utils/permissions.d.ts +43 -0
- package/dist/utils/permissions.js +178 -0
- package/dist/utils/post-process.d.ts +16 -0
- package/dist/utils/post-process.js +132 -0
- package/dist/utils/serialize-inspector-state.d.ts +179 -0
- package/dist/utils/serialize-inspector-state.js +170 -0
- package/dist/utils/type-utils.d.ts +3 -0
- package/dist/utils/type-utils.js +50 -0
- package/dist/visit.d.ts +3 -3
- package/dist/visit.js +35 -31
- package/package.json +5 -6
- package/src/{add-channel.ts → add/add-channel.ts} +108 -56
- package/src/add/add-cli.ts +822 -0
- package/src/{add-file-extends-core-type.ts → add/add-file-extends-core-type.ts} +23 -5
- package/src/{add-file-with-config.ts → add/add-file-with-config.ts} +2 -2
- package/src/{add-file-with-factory.ts → add/add-file-with-factory.ts} +49 -6
- package/src/{add-functions.ts → add/add-functions.ts} +89 -19
- package/src/{add-http-route.ts → add/add-http-route.ts} +66 -32
- package/src/add/add-mcp-prompt.ts +128 -0
- package/src/add/add-mcp-prompt.ts.tmp +0 -0
- package/src/add/add-mcp-resource.ts +145 -0
- package/src/add/add-mcp-resource.ts.tmp +0 -0
- package/src/add/add-mcp-tool.ts +137 -0
- package/src/add/add-middleware.ts +385 -0
- package/src/add/add-permission.ts +391 -0
- package/src/add/add-queue-worker.ts +92 -0
- package/src/{add-rpc-invocations.ts → add/add-rpc-invocations.ts} +1 -1
- package/src/{add-schedule.ts → add/add-schedule.ts} +30 -28
- package/src/error-codes.ts +43 -0
- package/src/index.ts +12 -0
- package/src/inspector.ts +41 -17
- package/src/types.ts +128 -1
- package/src/utils/ensure-function-metadata.ts +24 -0
- package/src/{utils.ts → utils/extract-function-name.ts} +44 -206
- package/src/utils/extract-services.ts +35 -0
- package/src/utils/filter-inspector-state.test.ts +1433 -0
- package/src/utils/filter-inspector-state.ts +526 -0
- package/src/{utils.test.ts → utils/filter-utils.test.ts} +351 -2
- package/src/utils/filter-utils.ts +152 -0
- package/src/utils/find-root-dir.ts +68 -0
- package/src/utils/get-files-and-methods.ts +151 -0
- package/src/{get-property-value.ts → utils/get-property-value.ts} +27 -0
- package/src/utils/middleware.ts +241 -0
- package/src/utils/permissions.test.ts +327 -0
- package/src/utils/permissions.ts +262 -0
- package/src/utils/post-process.ts +178 -0
- package/src/utils/serialize-inspector-state.ts +375 -0
- package/src/utils/test-data/inspector-state.json +1680 -0
- package/src/utils/type-utils.ts +74 -0
- package/src/visit.ts +50 -34
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/add-channel.d.ts +0 -13
- package/dist/add-functions.d.ts +0 -7
- package/dist/add-mcp-prompt.d.ts +0 -3
- package/dist/add-mcp-prompt.js +0 -61
- package/dist/add-mcp-resource.d.ts +0 -3
- package/dist/add-mcp-resource.js +0 -68
- package/dist/add-mcp-tool.d.ts +0 -3
- package/dist/add-mcp-tool.js +0 -64
- package/dist/add-middleware.d.ts +0 -7
- package/dist/add-middleware.js +0 -35
- package/dist/add-permission.d.ts +0 -7
- package/dist/add-permission.js +0 -35
- package/dist/add-queue-worker.d.ts +0 -3
- package/dist/add-queue-worker.js +0 -48
- package/dist/add-schedule.d.ts +0 -3
- package/dist/get-property-value.d.ts +0 -3
- package/dist/utils.d.ts +0 -39
- package/src/add-mcp-prompt.ts +0 -104
- package/src/add-mcp-resource.ts +0 -116
- package/src/add-mcp-tool.ts +0 -107
- package/src/add-middleware.ts +0 -51
- package/src/add-permission.ts +0 -53
- package/src/add-queue-worker.ts +0 -92
- /package/dist/{add-rpc-invocations.js → add/add-rpc-invocations.js} +0 -0
- /package/dist/{does-type-extend-core-type.d.ts → utils/does-type-extend-core-type.d.ts} +0 -0
- /package/dist/{does-type-extend-core-type.js → utils/does-type-extend-core-type.js} +0 -0
- /package/src/{does-type-extend-core-type.ts → utils/does-type-extend-core-type.ts} +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { InspectorState } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Serializable version of InspectorState that can be saved to JSON
|
|
4
|
+
* Omits typesLookup (contains non-serializable ts.Type objects) and converts Maps/Sets to arrays
|
|
5
|
+
*/
|
|
6
|
+
export interface SerializableInspectorState {
|
|
7
|
+
rootDir: string;
|
|
8
|
+
singletonServicesTypeImportMap: Array<[
|
|
9
|
+
string,
|
|
10
|
+
{
|
|
11
|
+
variable: string;
|
|
12
|
+
type: string | null;
|
|
13
|
+
typePath: string | null;
|
|
14
|
+
}[]
|
|
15
|
+
]>;
|
|
16
|
+
sessionServicesTypeImportMap: Array<[
|
|
17
|
+
string,
|
|
18
|
+
{
|
|
19
|
+
variable: string;
|
|
20
|
+
type: string | null;
|
|
21
|
+
typePath: string | null;
|
|
22
|
+
}[]
|
|
23
|
+
]>;
|
|
24
|
+
userSessionTypeImportMap: Array<[
|
|
25
|
+
string,
|
|
26
|
+
{
|
|
27
|
+
variable: string;
|
|
28
|
+
type: string | null;
|
|
29
|
+
typePath: string | null;
|
|
30
|
+
}[]
|
|
31
|
+
]>;
|
|
32
|
+
configTypeImportMap: Array<[
|
|
33
|
+
string,
|
|
34
|
+
{
|
|
35
|
+
variable: string;
|
|
36
|
+
type: string | null;
|
|
37
|
+
typePath: string | null;
|
|
38
|
+
}[]
|
|
39
|
+
]>;
|
|
40
|
+
singletonServicesFactories: Array<[
|
|
41
|
+
string,
|
|
42
|
+
{
|
|
43
|
+
variable: string;
|
|
44
|
+
type: string | null;
|
|
45
|
+
typePath: string | null;
|
|
46
|
+
}[]
|
|
47
|
+
]>;
|
|
48
|
+
sessionServicesFactories: Array<[
|
|
49
|
+
string,
|
|
50
|
+
{
|
|
51
|
+
variable: string;
|
|
52
|
+
type: string | null;
|
|
53
|
+
typePath: string | null;
|
|
54
|
+
}[]
|
|
55
|
+
]>;
|
|
56
|
+
sessionServicesMeta: Array<[string, string[]]>;
|
|
57
|
+
configFactories: Array<[
|
|
58
|
+
string,
|
|
59
|
+
{
|
|
60
|
+
variable: string;
|
|
61
|
+
type: string | null;
|
|
62
|
+
typePath: string | null;
|
|
63
|
+
}[]
|
|
64
|
+
]>;
|
|
65
|
+
filesAndMethods: InspectorState['filesAndMethods'];
|
|
66
|
+
filesAndMethodsErrors: Array<[
|
|
67
|
+
string,
|
|
68
|
+
Array<[
|
|
69
|
+
string,
|
|
70
|
+
{
|
|
71
|
+
variable: string;
|
|
72
|
+
type: string | null;
|
|
73
|
+
typePath: string | null;
|
|
74
|
+
}[]
|
|
75
|
+
]>
|
|
76
|
+
]>;
|
|
77
|
+
functions: {
|
|
78
|
+
typesMap: {
|
|
79
|
+
map: Array<[string, {
|
|
80
|
+
originalName: string;
|
|
81
|
+
path: string | null;
|
|
82
|
+
}]>;
|
|
83
|
+
customTypes: Array<[string, {
|
|
84
|
+
type: string;
|
|
85
|
+
references: string[];
|
|
86
|
+
}]>;
|
|
87
|
+
};
|
|
88
|
+
meta: InspectorState['functions']['meta'];
|
|
89
|
+
files: Array<[string, {
|
|
90
|
+
path: string;
|
|
91
|
+
exportedName: string;
|
|
92
|
+
}]>;
|
|
93
|
+
};
|
|
94
|
+
http: {
|
|
95
|
+
metaInputTypes: Array<[
|
|
96
|
+
string,
|
|
97
|
+
{
|
|
98
|
+
query: string[] | undefined;
|
|
99
|
+
params: string[] | undefined;
|
|
100
|
+
body: string[] | undefined;
|
|
101
|
+
}
|
|
102
|
+
]>;
|
|
103
|
+
meta: InspectorState['http']['meta'];
|
|
104
|
+
files: string[];
|
|
105
|
+
routeMiddleware: Array<[
|
|
106
|
+
string,
|
|
107
|
+
InspectorState['http']['routeMiddleware'] extends Map<string, infer V> ? V : never
|
|
108
|
+
]>;
|
|
109
|
+
routePermissions: Array<[
|
|
110
|
+
string,
|
|
111
|
+
InspectorState['http']['routePermissions'] extends Map<string, infer V> ? V : never
|
|
112
|
+
]>;
|
|
113
|
+
};
|
|
114
|
+
channels: {
|
|
115
|
+
files: string[];
|
|
116
|
+
meta: InspectorState['channels']['meta'];
|
|
117
|
+
};
|
|
118
|
+
scheduledTasks: {
|
|
119
|
+
meta: InspectorState['scheduledTasks']['meta'];
|
|
120
|
+
files: string[];
|
|
121
|
+
};
|
|
122
|
+
queueWorkers: {
|
|
123
|
+
meta: InspectorState['queueWorkers']['meta'];
|
|
124
|
+
files: string[];
|
|
125
|
+
};
|
|
126
|
+
rpc: {
|
|
127
|
+
internalMeta: InspectorState['rpc']['internalMeta'];
|
|
128
|
+
internalFiles: Array<[string, {
|
|
129
|
+
path: string;
|
|
130
|
+
exportedName: string;
|
|
131
|
+
}]>;
|
|
132
|
+
exposedMeta: InspectorState['rpc']['exposedMeta'];
|
|
133
|
+
exposedFiles: Array<[string, {
|
|
134
|
+
path: string;
|
|
135
|
+
exportedName: string;
|
|
136
|
+
}]>;
|
|
137
|
+
invokedFunctions: string[];
|
|
138
|
+
};
|
|
139
|
+
mcpEndpoints: {
|
|
140
|
+
resourcesMeta: InspectorState['mcpEndpoints']['resourcesMeta'];
|
|
141
|
+
toolsMeta: InspectorState['mcpEndpoints']['toolsMeta'];
|
|
142
|
+
promptsMeta: InspectorState['mcpEndpoints']['promptsMeta'];
|
|
143
|
+
files: string[];
|
|
144
|
+
};
|
|
145
|
+
cli: {
|
|
146
|
+
meta: InspectorState['cli']['meta'];
|
|
147
|
+
files: string[];
|
|
148
|
+
};
|
|
149
|
+
middleware: {
|
|
150
|
+
meta: InspectorState['middleware']['meta'];
|
|
151
|
+
tagMiddleware: Array<[
|
|
152
|
+
string,
|
|
153
|
+
InspectorState['middleware']['tagMiddleware'] extends Map<string, infer V> ? V : never
|
|
154
|
+
]>;
|
|
155
|
+
};
|
|
156
|
+
permissions: {
|
|
157
|
+
meta: InspectorState['permissions']['meta'];
|
|
158
|
+
tagPermissions: Array<[
|
|
159
|
+
string,
|
|
160
|
+
InspectorState['permissions']['tagPermissions'] extends Map<string, infer V> ? V : never
|
|
161
|
+
]>;
|
|
162
|
+
};
|
|
163
|
+
serviceAggregation: {
|
|
164
|
+
requiredServices: string[];
|
|
165
|
+
usedFunctions: string[];
|
|
166
|
+
usedMiddleware: string[];
|
|
167
|
+
usedPermissions: string[];
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Serializes InspectorState to a JSON-compatible format
|
|
172
|
+
* Omits typesLookup (not needed for filtering/generation) and converts Maps/Sets to arrays
|
|
173
|
+
*/
|
|
174
|
+
export declare function serializeInspectorState(state: InspectorState): SerializableInspectorState;
|
|
175
|
+
/**
|
|
176
|
+
* Deserializes JSON data back to InspectorState
|
|
177
|
+
* Creates a partial state suitable for filtering/generation (without typesLookup)
|
|
178
|
+
*/
|
|
179
|
+
export declare function deserializeInspectorState(data: SerializableInspectorState): Omit<InspectorState, 'typesLookup'>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { TypesMap } from '../types-map.js';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes InspectorState to a JSON-compatible format
|
|
4
|
+
* Omits typesLookup (not needed for filtering/generation) and converts Maps/Sets to arrays
|
|
5
|
+
*/
|
|
6
|
+
export function serializeInspectorState(state) {
|
|
7
|
+
// Helper to serialize TypesMap
|
|
8
|
+
const serializeTypesMap = (typesMap) => {
|
|
9
|
+
// Access private map via type assertion
|
|
10
|
+
const mapEntries = Array.from(typesMap.map.entries());
|
|
11
|
+
const customTypesEntries = Array.from(typesMap.customTypes.entries());
|
|
12
|
+
return {
|
|
13
|
+
map: mapEntries,
|
|
14
|
+
customTypes: customTypesEntries,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
rootDir: state.rootDir,
|
|
19
|
+
singletonServicesTypeImportMap: Array.from(state.singletonServicesTypeImportMap.entries()),
|
|
20
|
+
sessionServicesTypeImportMap: Array.from(state.sessionServicesTypeImportMap.entries()),
|
|
21
|
+
userSessionTypeImportMap: Array.from(state.userSessionTypeImportMap.entries()),
|
|
22
|
+
configTypeImportMap: Array.from(state.configTypeImportMap.entries()),
|
|
23
|
+
singletonServicesFactories: Array.from(state.singletonServicesFactories.entries()),
|
|
24
|
+
sessionServicesFactories: Array.from(state.sessionServicesFactories.entries()),
|
|
25
|
+
sessionServicesMeta: Array.from(state.sessionServicesMeta.entries()),
|
|
26
|
+
configFactories: Array.from(state.configFactories.entries()),
|
|
27
|
+
filesAndMethods: state.filesAndMethods,
|
|
28
|
+
filesAndMethodsErrors: Array.from(state.filesAndMethodsErrors.entries()).map(([key, mapValue]) => [key, Array.from(mapValue.entries())]),
|
|
29
|
+
functions: {
|
|
30
|
+
typesMap: serializeTypesMap(state.functions.typesMap),
|
|
31
|
+
meta: state.functions.meta,
|
|
32
|
+
files: Array.from(state.functions.files.entries()),
|
|
33
|
+
},
|
|
34
|
+
http: {
|
|
35
|
+
metaInputTypes: Array.from(state.http.metaInputTypes.entries()),
|
|
36
|
+
meta: state.http.meta,
|
|
37
|
+
files: Array.from(state.http.files),
|
|
38
|
+
routeMiddleware: Array.from(state.http.routeMiddleware.entries()),
|
|
39
|
+
routePermissions: Array.from(state.http.routePermissions.entries()),
|
|
40
|
+
},
|
|
41
|
+
channels: {
|
|
42
|
+
files: Array.from(state.channels.files),
|
|
43
|
+
meta: state.channels.meta,
|
|
44
|
+
},
|
|
45
|
+
scheduledTasks: {
|
|
46
|
+
meta: state.scheduledTasks.meta,
|
|
47
|
+
files: Array.from(state.scheduledTasks.files),
|
|
48
|
+
},
|
|
49
|
+
queueWorkers: {
|
|
50
|
+
meta: state.queueWorkers.meta,
|
|
51
|
+
files: Array.from(state.queueWorkers.files),
|
|
52
|
+
},
|
|
53
|
+
rpc: {
|
|
54
|
+
internalMeta: state.rpc.internalMeta,
|
|
55
|
+
internalFiles: Array.from(state.rpc.internalFiles.entries()),
|
|
56
|
+
exposedMeta: state.rpc.exposedMeta,
|
|
57
|
+
exposedFiles: Array.from(state.rpc.exposedFiles.entries()),
|
|
58
|
+
invokedFunctions: Array.from(state.rpc.invokedFunctions),
|
|
59
|
+
},
|
|
60
|
+
mcpEndpoints: {
|
|
61
|
+
resourcesMeta: state.mcpEndpoints.resourcesMeta,
|
|
62
|
+
toolsMeta: state.mcpEndpoints.toolsMeta,
|
|
63
|
+
promptsMeta: state.mcpEndpoints.promptsMeta,
|
|
64
|
+
files: Array.from(state.mcpEndpoints.files),
|
|
65
|
+
},
|
|
66
|
+
cli: {
|
|
67
|
+
meta: state.cli.meta,
|
|
68
|
+
files: Array.from(state.cli.files),
|
|
69
|
+
},
|
|
70
|
+
middleware: {
|
|
71
|
+
meta: state.middleware.meta,
|
|
72
|
+
tagMiddleware: Array.from(state.middleware.tagMiddleware.entries()),
|
|
73
|
+
},
|
|
74
|
+
permissions: {
|
|
75
|
+
meta: state.permissions.meta,
|
|
76
|
+
tagPermissions: Array.from(state.permissions.tagPermissions.entries()),
|
|
77
|
+
},
|
|
78
|
+
serviceAggregation: {
|
|
79
|
+
requiredServices: Array.from(state.serviceAggregation.requiredServices),
|
|
80
|
+
usedFunctions: Array.from(state.serviceAggregation.usedFunctions),
|
|
81
|
+
usedMiddleware: Array.from(state.serviceAggregation.usedMiddleware),
|
|
82
|
+
usedPermissions: Array.from(state.serviceAggregation.usedPermissions),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Deserializes JSON data back to InspectorState
|
|
88
|
+
* Creates a partial state suitable for filtering/generation (without typesLookup)
|
|
89
|
+
*/
|
|
90
|
+
export function deserializeInspectorState(data) {
|
|
91
|
+
// Helper to deserialize TypesMap
|
|
92
|
+
const deserializeTypesMap = (serialized) => {
|
|
93
|
+
const typesMap = new TypesMap();
|
|
94
|
+
typesMap.map = new Map(serialized.map);
|
|
95
|
+
// Restore public customTypes
|
|
96
|
+
typesMap.customTypes = new Map(serialized.customTypes);
|
|
97
|
+
return typesMap;
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
rootDir: data.rootDir,
|
|
101
|
+
singletonServicesTypeImportMap: new Map(data.singletonServicesTypeImportMap),
|
|
102
|
+
sessionServicesTypeImportMap: new Map(data.sessionServicesTypeImportMap),
|
|
103
|
+
userSessionTypeImportMap: new Map(data.userSessionTypeImportMap),
|
|
104
|
+
configTypeImportMap: new Map(data.configTypeImportMap),
|
|
105
|
+
singletonServicesFactories: new Map(data.singletonServicesFactories),
|
|
106
|
+
sessionServicesFactories: new Map(data.sessionServicesFactories),
|
|
107
|
+
sessionServicesMeta: new Map(data.sessionServicesMeta),
|
|
108
|
+
configFactories: new Map(data.configFactories),
|
|
109
|
+
filesAndMethods: data.filesAndMethods,
|
|
110
|
+
filesAndMethodsErrors: new Map(data.filesAndMethodsErrors.map(([key, entries]) => [
|
|
111
|
+
key,
|
|
112
|
+
new Map(entries),
|
|
113
|
+
])),
|
|
114
|
+
functions: {
|
|
115
|
+
typesMap: deserializeTypesMap(data.functions.typesMap),
|
|
116
|
+
meta: data.functions.meta,
|
|
117
|
+
files: new Map(data.functions.files),
|
|
118
|
+
},
|
|
119
|
+
http: {
|
|
120
|
+
metaInputTypes: new Map(data.http.metaInputTypes),
|
|
121
|
+
meta: data.http.meta,
|
|
122
|
+
files: new Set(data.http.files),
|
|
123
|
+
routeMiddleware: new Map(data.http.routeMiddleware),
|
|
124
|
+
routePermissions: new Map(data.http.routePermissions),
|
|
125
|
+
},
|
|
126
|
+
channels: {
|
|
127
|
+
files: new Set(data.channels.files),
|
|
128
|
+
meta: data.channels.meta,
|
|
129
|
+
},
|
|
130
|
+
scheduledTasks: {
|
|
131
|
+
meta: data.scheduledTasks.meta,
|
|
132
|
+
files: new Set(data.scheduledTasks.files),
|
|
133
|
+
},
|
|
134
|
+
queueWorkers: {
|
|
135
|
+
meta: data.queueWorkers.meta,
|
|
136
|
+
files: new Set(data.queueWorkers.files),
|
|
137
|
+
},
|
|
138
|
+
rpc: {
|
|
139
|
+
internalMeta: data.rpc.internalMeta,
|
|
140
|
+
internalFiles: new Map(data.rpc.internalFiles),
|
|
141
|
+
exposedMeta: data.rpc.exposedMeta,
|
|
142
|
+
exposedFiles: new Map(data.rpc.exposedFiles),
|
|
143
|
+
invokedFunctions: new Set(data.rpc.invokedFunctions),
|
|
144
|
+
},
|
|
145
|
+
mcpEndpoints: {
|
|
146
|
+
resourcesMeta: data.mcpEndpoints.resourcesMeta,
|
|
147
|
+
toolsMeta: data.mcpEndpoints.toolsMeta,
|
|
148
|
+
promptsMeta: data.mcpEndpoints.promptsMeta,
|
|
149
|
+
files: new Set(data.mcpEndpoints.files),
|
|
150
|
+
},
|
|
151
|
+
cli: {
|
|
152
|
+
meta: data.cli.meta,
|
|
153
|
+
files: new Set(data.cli.files),
|
|
154
|
+
},
|
|
155
|
+
middleware: {
|
|
156
|
+
meta: data.middleware.meta,
|
|
157
|
+
tagMiddleware: new Map(data.middleware.tagMiddleware),
|
|
158
|
+
},
|
|
159
|
+
permissions: {
|
|
160
|
+
meta: data.permissions.meta,
|
|
161
|
+
tagPermissions: new Map(data.permissions.tagPermissions),
|
|
162
|
+
},
|
|
163
|
+
serviceAggregation: {
|
|
164
|
+
requiredServices: new Set(data.serviceAggregation.requiredServices),
|
|
165
|
+
usedFunctions: new Set(data.serviceAggregation.usedFunctions),
|
|
166
|
+
usedMiddleware: new Set(data.serviceAggregation.usedMiddleware),
|
|
167
|
+
usedPermissions: new Set(data.serviceAggregation.usedPermissions),
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
export declare const extractTypeKeys: (type: ts.Type) => string[];
|
|
3
|
+
export declare function getPropertyAssignmentInitializer(obj: ts.ObjectLiteralExpression, propName: string, followShorthand?: boolean, checker?: ts.TypeChecker): ts.Expression | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
export const extractTypeKeys = (type) => {
|
|
3
|
+
return type.getProperties().map((symbol) => symbol.getName());
|
|
4
|
+
};
|
|
5
|
+
export function getPropertyAssignmentInitializer(obj, propName, followShorthand = false, checker) {
|
|
6
|
+
for (const prop of obj.properties) {
|
|
7
|
+
// ① foo: () => {}
|
|
8
|
+
if (ts.isPropertyAssignment(prop) &&
|
|
9
|
+
ts.isIdentifier(prop.name) &&
|
|
10
|
+
prop.name.text === propName) {
|
|
11
|
+
return prop.initializer;
|
|
12
|
+
}
|
|
13
|
+
// ② foo() { … }
|
|
14
|
+
if (ts.isMethodDeclaration(prop) &&
|
|
15
|
+
ts.isIdentifier(prop.name) &&
|
|
16
|
+
prop.name.text === propName) {
|
|
17
|
+
return prop.name; // the method node *is* the function
|
|
18
|
+
}
|
|
19
|
+
// ③ { foo } (shorthand)
|
|
20
|
+
if (followShorthand &&
|
|
21
|
+
ts.isShorthandPropertyAssignment(prop) &&
|
|
22
|
+
prop.name.text === propName) {
|
|
23
|
+
if (!checker)
|
|
24
|
+
return prop.name; // best effort without a checker
|
|
25
|
+
let sym = checker.getSymbolAtLocation(prop.name);
|
|
26
|
+
if (sym && sym.flags & ts.SymbolFlags.Alias) {
|
|
27
|
+
sym = checker.getAliasedSymbol(sym);
|
|
28
|
+
}
|
|
29
|
+
const decl = sym?.declarations?.[0];
|
|
30
|
+
// const foo = () => {}
|
|
31
|
+
if (decl &&
|
|
32
|
+
ts.isVariableDeclaration(decl) &&
|
|
33
|
+
decl.initializer &&
|
|
34
|
+
(ts.isArrowFunction(decl.initializer) ||
|
|
35
|
+
ts.isFunctionExpression(decl.initializer))) {
|
|
36
|
+
return decl.initializer;
|
|
37
|
+
}
|
|
38
|
+
// function foo() {}
|
|
39
|
+
if (decl &&
|
|
40
|
+
(ts.isFunctionDeclaration(decl) ||
|
|
41
|
+
ts.isArrowFunction(decl) ||
|
|
42
|
+
ts.isFunctionExpression(decl))) {
|
|
43
|
+
return decl;
|
|
44
|
+
}
|
|
45
|
+
// fallback – just give back the identifier
|
|
46
|
+
return prop.name;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
package/dist/visit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import {
|
|
3
|
-
export declare const visitSetup: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState,
|
|
4
|
-
export declare const visitRoutes: (checker: ts.TypeChecker, node: ts.Node, state: InspectorState,
|
|
2
|
+
import { InspectorState, InspectorLogger, InspectorOptions } from './types.js';
|
|
3
|
+
export declare const visitSetup: (logger: InspectorLogger, checker: ts.TypeChecker, node: ts.Node, state: InspectorState, options: InspectorOptions) => void;
|
|
4
|
+
export declare const visitRoutes: (logger: InspectorLogger, checker: ts.TypeChecker, node: ts.Node, state: InspectorState, options: InspectorOptions) => void;
|
package/dist/visit.js
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { addFileWithFactory } from './add-file-with-factory.js';
|
|
3
|
-
import { addFileExtendsCoreType } from './add-file-extends-core-type.js';
|
|
4
|
-
import { addHTTPRoute } from './add-http-route.js';
|
|
5
|
-
import { addSchedule } from './add-schedule.js';
|
|
6
|
-
import { addQueueWorker } from './add-queue-worker.js';
|
|
7
|
-
import { addMCPResource } from './add-mcp-resource.js';
|
|
8
|
-
import { addMCPTool } from './add-mcp-tool.js';
|
|
9
|
-
import { addMCPPrompt } from './add-mcp-prompt.js';
|
|
10
|
-
import { addFunctions } from './add-functions.js';
|
|
11
|
-
import { addChannel } from './add-channel.js';
|
|
12
|
-
import { addRPCInvocations } from './add-rpc-invocations.js';
|
|
13
|
-
import { addMiddleware } from './add-middleware.js';
|
|
14
|
-
import { addPermission } from './add-permission.js';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
addFileExtendsCoreType(node, checker, state.
|
|
18
|
-
addFileExtendsCoreType(node, checker, state.
|
|
2
|
+
import { addFileWithFactory } from './add/add-file-with-factory.js';
|
|
3
|
+
import { addFileExtendsCoreType } from './add/add-file-extends-core-type.js';
|
|
4
|
+
import { addHTTPRoute } from './add/add-http-route.js';
|
|
5
|
+
import { addSchedule } from './add/add-schedule.js';
|
|
6
|
+
import { addQueueWorker } from './add/add-queue-worker.js';
|
|
7
|
+
import { addMCPResource } from './add/add-mcp-resource.js';
|
|
8
|
+
import { addMCPTool } from './add/add-mcp-tool.js';
|
|
9
|
+
import { addMCPPrompt } from './add/add-mcp-prompt.js';
|
|
10
|
+
import { addFunctions } from './add/add-functions.js';
|
|
11
|
+
import { addChannel } from './add/add-channel.js';
|
|
12
|
+
import { addRPCInvocations } from './add/add-rpc-invocations.js';
|
|
13
|
+
import { addMiddleware } from './add/add-middleware.js';
|
|
14
|
+
import { addPermission } from './add/add-permission.js';
|
|
15
|
+
import { addCLI, addCLIRenderers } from './add/add-cli.js';
|
|
16
|
+
export const visitSetup = (logger, checker, node, state, options) => {
|
|
17
|
+
addFileExtendsCoreType(node, checker, state.singletonServicesTypeImportMap, 'CoreSingletonServices', state);
|
|
18
|
+
addFileExtendsCoreType(node, checker, state.sessionServicesTypeImportMap, 'CoreServices', state);
|
|
19
|
+
addFileExtendsCoreType(node, checker, state.userSessionTypeImportMap, 'CoreUserSession', state);
|
|
20
|
+
addFileExtendsCoreType(node, checker, state.configTypeImportMap, 'CoreConfig', state);
|
|
19
21
|
addFileWithFactory(node, checker, state.singletonServicesFactories, 'CreateSingletonServices');
|
|
20
|
-
addFileWithFactory(node, checker, state.sessionServicesFactories, 'CreateSessionServices');
|
|
22
|
+
addFileWithFactory(node, checker, state.sessionServicesFactories, 'CreateSessionServices', state);
|
|
21
23
|
addFileWithFactory(node, checker, state.configFactories, 'CreateConfig');
|
|
22
24
|
addRPCInvocations(node, state, logger);
|
|
23
|
-
|
|
25
|
+
addMiddleware(logger, node, checker, state, options);
|
|
26
|
+
addPermission(logger, node, checker, state, options);
|
|
27
|
+
ts.forEachChild(node, (child) => visitSetup(logger, checker, child, state, options));
|
|
24
28
|
};
|
|
25
|
-
export const visitRoutes = (checker, node, state,
|
|
26
|
-
addFunctions(node, checker, state,
|
|
27
|
-
addHTTPRoute(node, checker, state,
|
|
28
|
-
addSchedule(node, checker, state,
|
|
29
|
-
addQueueWorker(node, checker, state,
|
|
30
|
-
addChannel(node, checker, state,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ts.forEachChild(node, (child) => visitRoutes(checker, child, state,
|
|
29
|
+
export const visitRoutes = (logger, checker, node, state, options) => {
|
|
30
|
+
addFunctions(logger, node, checker, state, options);
|
|
31
|
+
addHTTPRoute(logger, node, checker, state, options);
|
|
32
|
+
addSchedule(logger, node, checker, state, options);
|
|
33
|
+
addQueueWorker(logger, node, checker, state, options);
|
|
34
|
+
addChannel(logger, node, checker, state, options);
|
|
35
|
+
addCLI(logger, node, checker, state, options);
|
|
36
|
+
addCLIRenderers(logger, node, checker, state, options);
|
|
37
|
+
addMCPResource(logger, node, checker, state, options);
|
|
38
|
+
addMCPTool(logger, node, checker, state, options);
|
|
39
|
+
addMCPPrompt(logger, node, checker, state, options);
|
|
40
|
+
ts.forEachChild(node, (child) => visitRoutes(logger, checker, child, state, options));
|
|
37
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"tsc": "tsc",
|
|
11
|
-
"build
|
|
12
|
-
"build": "yarn build:esm",
|
|
11
|
+
"build": "tsc -b",
|
|
13
12
|
"ncu": "npx npm-check-updates -x '/.*glob.*/'",
|
|
14
13
|
"release": "yarn build && npm test",
|
|
15
14
|
"test": "bash run-tests.sh",
|
|
@@ -17,12 +16,12 @@
|
|
|
17
16
|
"test:coverage": "bash run-tests.sh --coverage"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
|
-
"@pikku/core": "^0.
|
|
21
|
-
"path-to-regexp": "^8.
|
|
19
|
+
"@pikku/core": "^0.10.0",
|
|
20
|
+
"path-to-regexp": "^8.3.0",
|
|
22
21
|
"typescript": "^5.9"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^24.
|
|
24
|
+
"@types/node": "^24.9.1"
|
|
26
25
|
},
|
|
27
26
|
"engines": {
|
|
28
27
|
"node": ">=18"
|