@pikku/inspector 0.12.1 → 0.12.2
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 +9 -0
- package/dist/add/add-channel.js +2 -0
- package/dist/add/add-cli.js +23 -7
- package/dist/add/add-gateway.d.ts +2 -0
- package/dist/add/add-gateway.js +57 -0
- package/dist/inspector.js +4 -0
- package/dist/types.d.ts +5 -0
- package/dist/utils/serialize-inspector-state.d.ts +4 -0
- package/dist/utils/serialize-inspector-state.js +8 -0
- package/dist/visit.js +2 -0
- package/package.json +3 -3
- package/src/add/add-channel.ts +3 -7
- package/src/add/add-cli.ts +34 -11
- package/src/add/add-gateway.ts +95 -0
- package/src/inspector.ts +4 -0
- package/src/types.ts +5 -0
- package/src/utils/serialize-inspector-state.ts +12 -0
- package/src/visit.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/dist/add/add-channel.js
CHANGED
|
@@ -366,6 +366,7 @@ export const addChannel = (logger, node, checker, state, options) => {
|
|
|
366
366
|
if (disabled)
|
|
367
367
|
return;
|
|
368
368
|
const query = getPropertyValue(obj, 'query');
|
|
369
|
+
const binary = getPropertyValue(obj, 'binary');
|
|
369
370
|
const connect = getPropertyAssignmentInitializer(obj, 'onConnect', true, checker);
|
|
370
371
|
const disconnect = getPropertyAssignmentInitializer(obj, 'onDisconnect', true, checker);
|
|
371
372
|
// default onMessage handler
|
|
@@ -439,6 +440,7 @@ export const addChannel = (logger, node, checker, state, options) => {
|
|
|
439
440
|
disconnect: disconnectFuncId ? { pikkuFuncId: disconnectFuncId } : null,
|
|
440
441
|
message,
|
|
441
442
|
messageWirings,
|
|
443
|
+
binary: binary === undefined ? undefined : binary,
|
|
442
444
|
summary,
|
|
443
445
|
description,
|
|
444
446
|
errors,
|
package/dist/add/add-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { extractFunctionName } from '../utils/extract-function-name.js';
|
|
2
|
+
import { extractFunctionName, makeContextBasedId, } from '../utils/extract-function-name.js';
|
|
3
3
|
import { resolveMiddleware } from '../utils/middleware.js';
|
|
4
4
|
import { extractWireNames } from '../utils/post-process.js';
|
|
5
5
|
import { getPropertyValue } from '../utils/get-property-value.js';
|
|
@@ -95,10 +95,14 @@ function processCLIConfig(logger, node, sourceFile, typeChecker, inspectorState,
|
|
|
95
95
|
programMeta.options = processOptions(logger, prop.initializer, typeChecker, inspectorState, options);
|
|
96
96
|
}
|
|
97
97
|
break;
|
|
98
|
-
case 'render':
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
case 'render': {
|
|
99
|
+
let renderFuncId = extractFunctionName(prop.initializer, typeChecker, inspectorState.rootDir).pikkuFuncId;
|
|
100
|
+
if (renderFuncId.startsWith('__temp_')) {
|
|
101
|
+
renderFuncId = makeContextBasedId('cli-render', programName);
|
|
102
|
+
}
|
|
103
|
+
programMeta.defaultRenderName = renderFuncId;
|
|
101
104
|
break;
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
return { programName, programMeta };
|
|
@@ -156,8 +160,12 @@ function processCommand(logger, inspectorState, options, name, node, sourceFile,
|
|
|
156
160
|
if (ts.isIdentifier(node) ||
|
|
157
161
|
ts.isArrowFunction(node) ||
|
|
158
162
|
ts.isFunctionExpression(node)) {
|
|
163
|
+
let pikkuFuncId = extractFunctionName(node, typeChecker, inspectorState.rootDir).pikkuFuncId;
|
|
164
|
+
if (pikkuFuncId.startsWith('__temp_')) {
|
|
165
|
+
pikkuFuncId = makeContextBasedId('cli', programName, ...fullPath);
|
|
166
|
+
}
|
|
159
167
|
return {
|
|
160
|
-
pikkuFuncId
|
|
168
|
+
pikkuFuncId,
|
|
161
169
|
positionals: [],
|
|
162
170
|
options: {},
|
|
163
171
|
};
|
|
@@ -195,6 +203,9 @@ function processCommand(logger, inspectorState, options, name, node, sourceFile,
|
|
|
195
203
|
const propName = prop.name.text;
|
|
196
204
|
if (propName === 'func') {
|
|
197
205
|
pikkuFuncId = extractFunctionName(prop.initializer, typeChecker, inspectorState.rootDir).pikkuFuncId;
|
|
206
|
+
if (pikkuFuncId.startsWith('__temp_')) {
|
|
207
|
+
pikkuFuncId = makeContextBasedId('cli', programName, ...fullPath);
|
|
208
|
+
}
|
|
198
209
|
meta.pikkuFuncId = pikkuFuncId;
|
|
199
210
|
}
|
|
200
211
|
else if (propName === 'options' &&
|
|
@@ -238,9 +249,14 @@ function processCommand(logger, inspectorState, options, name, node, sourceFile,
|
|
|
238
249
|
case 'func':
|
|
239
250
|
// Already handled in first pass
|
|
240
251
|
break;
|
|
241
|
-
case 'render':
|
|
242
|
-
|
|
252
|
+
case 'render': {
|
|
253
|
+
let renderFuncId = extractFunctionName(prop.initializer, typeChecker, inspectorState.rootDir).pikkuFuncId;
|
|
254
|
+
if (renderFuncId.startsWith('__temp_')) {
|
|
255
|
+
renderFuncId = makeContextBasedId('cli-render', programName, ...fullPath);
|
|
256
|
+
}
|
|
257
|
+
meta.renderName = renderFuncId;
|
|
243
258
|
break;
|
|
259
|
+
}
|
|
244
260
|
case 'options':
|
|
245
261
|
// Process with pikkuFuncId from first pass
|
|
246
262
|
if (optionsNode) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { getPropertyValue, getCommonWireMetaData, } from '../utils/get-property-value.js';
|
|
3
|
+
import { extractFunctionName, makeContextBasedId, } from '../utils/extract-function-name.js';
|
|
4
|
+
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js';
|
|
5
|
+
import { resolveMiddleware } from '../utils/middleware.js';
|
|
6
|
+
import { extractWireNames } from '../utils/post-process.js';
|
|
7
|
+
import { ErrorCode } from '../error-codes.js';
|
|
8
|
+
export const addGateway = (logger, node, checker, state, _options) => {
|
|
9
|
+
if (!ts.isCallExpression(node)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const args = node.arguments;
|
|
13
|
+
const firstArg = args[0];
|
|
14
|
+
const expression = node.expression;
|
|
15
|
+
if (!ts.isIdentifier(expression) || expression.text !== 'wireGateway') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!firstArg || !ts.isObjectLiteralExpression(firstArg)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const obj = firstArg;
|
|
22
|
+
const nameValue = getPropertyValue(obj, 'name');
|
|
23
|
+
const typeValue = getPropertyValue(obj, 'type');
|
|
24
|
+
const routeValue = getPropertyValue(obj, 'route');
|
|
25
|
+
const { disabled, tags, summary, description, errors } = getCommonWireMetaData(obj, 'Gateway', nameValue, logger);
|
|
26
|
+
if (disabled)
|
|
27
|
+
return;
|
|
28
|
+
const funcInitializer = getPropertyAssignmentInitializer(obj, 'func', true, checker);
|
|
29
|
+
if (!funcInitializer) {
|
|
30
|
+
logger.critical(ErrorCode.MISSING_FUNC, `No valid 'func' property for gateway '${nameValue}'.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const extracted = extractFunctionName(funcInitializer, checker, state.rootDir);
|
|
34
|
+
let pikkuFuncId = extracted.pikkuFuncId;
|
|
35
|
+
if (pikkuFuncId.startsWith('__temp_') && nameValue) {
|
|
36
|
+
pikkuFuncId = makeContextBasedId('gateway', nameValue);
|
|
37
|
+
}
|
|
38
|
+
if (!nameValue || !typeValue) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const middleware = resolveMiddleware(state, obj, tags, checker);
|
|
42
|
+
state.serviceAggregation.usedFunctions.add(pikkuFuncId);
|
|
43
|
+
extractWireNames(middleware).forEach((name) => state.serviceAggregation.usedMiddleware.add(name));
|
|
44
|
+
state.gateways.files.add(node.getSourceFile().fileName);
|
|
45
|
+
state.gateways.meta[nameValue] = {
|
|
46
|
+
pikkuFuncId,
|
|
47
|
+
name: nameValue,
|
|
48
|
+
type: typeValue,
|
|
49
|
+
route: routeValue,
|
|
50
|
+
gateway: true,
|
|
51
|
+
summary,
|
|
52
|
+
description,
|
|
53
|
+
errors,
|
|
54
|
+
tags,
|
|
55
|
+
middleware,
|
|
56
|
+
};
|
|
57
|
+
};
|
package/dist/inspector.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
import type { ChannelsMeta } from '@pikku/core/channel';
|
|
3
|
+
import type { GatewaysMeta } from '@pikku/core/gateway';
|
|
3
4
|
import type { HTTPWiringsMeta } from '@pikku/core/http';
|
|
4
5
|
import type { ScheduledTasksMeta } from '@pikku/core/scheduler';
|
|
5
6
|
import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
|
|
@@ -262,6 +263,10 @@ export interface InspectorState {
|
|
|
262
263
|
http: InspectorHTTPState;
|
|
263
264
|
functions: InspectorFunctionState;
|
|
264
265
|
channels: InspectorChannelState;
|
|
266
|
+
gateways: {
|
|
267
|
+
meta: GatewaysMeta;
|
|
268
|
+
files: Set<string>;
|
|
269
|
+
};
|
|
265
270
|
triggers: {
|
|
266
271
|
meta: TriggerMeta;
|
|
267
272
|
sourceMeta: TriggerSourceMeta;
|
|
@@ -125,6 +125,10 @@ export interface SerializableInspectorState {
|
|
|
125
125
|
files: string[];
|
|
126
126
|
meta: InspectorState['channels']['meta'];
|
|
127
127
|
};
|
|
128
|
+
gateways: {
|
|
129
|
+
meta: InspectorState['gateways']['meta'];
|
|
130
|
+
files: string[];
|
|
131
|
+
};
|
|
128
132
|
triggers: {
|
|
129
133
|
meta: InspectorState['triggers']['meta'];
|
|
130
134
|
sourceMeta: InspectorState['triggers']['sourceMeta'];
|
|
@@ -44,6 +44,10 @@ export function serializeInspectorState(state) {
|
|
|
44
44
|
files: Array.from(state.channels.files),
|
|
45
45
|
meta: state.channels.meta,
|
|
46
46
|
},
|
|
47
|
+
gateways: {
|
|
48
|
+
meta: state.gateways.meta,
|
|
49
|
+
files: Array.from(state.gateways.files),
|
|
50
|
+
},
|
|
47
51
|
triggers: {
|
|
48
52
|
meta: state.triggers.meta,
|
|
49
53
|
sourceMeta: state.triggers.sourceMeta,
|
|
@@ -181,6 +185,10 @@ export function deserializeInspectorState(data) {
|
|
|
181
185
|
files: new Set(data.channels.files),
|
|
182
186
|
meta: data.channels.meta,
|
|
183
187
|
},
|
|
188
|
+
gateways: {
|
|
189
|
+
meta: data.gateways?.meta ?? {},
|
|
190
|
+
files: new Set(data.gateways?.files ?? []),
|
|
191
|
+
},
|
|
184
192
|
triggers: {
|
|
185
193
|
meta: data.triggers?.meta ?? {},
|
|
186
194
|
sourceMeta: data.triggers?.sourceMeta ?? {},
|
package/dist/visit.js
CHANGED
|
@@ -11,6 +11,7 @@ import { addMCPResource } from './add/add-mcp-resource.js';
|
|
|
11
11
|
import { addMCPPrompt } from './add/add-mcp-prompt.js';
|
|
12
12
|
import { addFunctions } from './add/add-functions.js';
|
|
13
13
|
import { addChannel } from './add/add-channel.js';
|
|
14
|
+
import { addGateway } from './add/add-gateway.js';
|
|
14
15
|
import { addRPCInvocations } from './add/add-rpc-invocations.js';
|
|
15
16
|
import { addWireAddon } from './add/add-wire-addon.js';
|
|
16
17
|
import { addMiddleware } from './add/add-middleware.js';
|
|
@@ -46,6 +47,7 @@ export const visitRoutes = (logger, checker, node, state, options) => {
|
|
|
46
47
|
addTrigger(logger, node, checker, state, options);
|
|
47
48
|
addQueueWorker(logger, node, checker, state, options);
|
|
48
49
|
addChannel(logger, node, checker, state, options);
|
|
50
|
+
addGateway(logger, node, checker, state, options);
|
|
49
51
|
addCLI(logger, node, checker, state, options);
|
|
50
52
|
addCLIRenderers(logger, node, checker, state, options);
|
|
51
53
|
addMCPResource(logger, node, checker, state, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/inspector",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@openapi-contrib/json-schema-to-openapi-schema": "^4.3.1",
|
|
37
|
-
"@pikku/core": "^0.12.
|
|
37
|
+
"@pikku/core": "^0.12.2",
|
|
38
38
|
"path-to-regexp": "^8.3.0",
|
|
39
39
|
"ts-json-schema-generator": "^2.5.0",
|
|
40
40
|
"tsx": "^4.21.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"zod-to-ts": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^24.
|
|
46
|
+
"@types/node": "^24.11.0"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18"
|
package/src/add/add-channel.ts
CHANGED
|
@@ -527,6 +527,7 @@ export const addChannel: AddWiring = (
|
|
|
527
527
|
if (disabled) return
|
|
528
528
|
|
|
529
529
|
const query = getPropertyValue(obj, 'query') as string[] | []
|
|
530
|
+
const binary = getPropertyValue(obj, 'binary') as boolean | undefined
|
|
530
531
|
|
|
531
532
|
const connect = getPropertyAssignmentInitializer(
|
|
532
533
|
obj,
|
|
@@ -620,13 +621,7 @@ export const addChannel: AddWiring = (
|
|
|
620
621
|
].filter(Boolean) as string[]
|
|
621
622
|
for (const funcId of handlersToValidate) {
|
|
622
623
|
if (
|
|
623
|
-
!validateAuthSessionless(
|
|
624
|
-
logger,
|
|
625
|
-
obj,
|
|
626
|
-
state,
|
|
627
|
-
funcId,
|
|
628
|
-
`Channel '${name}'`
|
|
629
|
-
)
|
|
624
|
+
!validateAuthSessionless(logger, obj, state, funcId, `Channel '${name}'`)
|
|
630
625
|
) {
|
|
631
626
|
return
|
|
632
627
|
}
|
|
@@ -643,6 +638,7 @@ export const addChannel: AddWiring = (
|
|
|
643
638
|
disconnect: disconnectFuncId ? { pikkuFuncId: disconnectFuncId } : null,
|
|
644
639
|
message,
|
|
645
640
|
messageWirings,
|
|
641
|
+
binary: binary === undefined ? undefined : binary,
|
|
646
642
|
summary,
|
|
647
643
|
description,
|
|
648
644
|
errors,
|
package/src/add/add-cli.ts
CHANGED
|
@@ -7,7 +7,10 @@ import type {
|
|
|
7
7
|
InspectorState,
|
|
8
8
|
} from '../types.js'
|
|
9
9
|
import type { CLIProgramMeta, CLICommandMeta } from '@pikku/core/cli'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
extractFunctionName,
|
|
12
|
+
makeContextBasedId,
|
|
13
|
+
} from '../utils/extract-function-name.js'
|
|
11
14
|
import { resolveMiddleware } from '../utils/middleware.js'
|
|
12
15
|
import { extractWireNames } from '../utils/post-process.js'
|
|
13
16
|
import { getPropertyValue } from '../utils/get-property-value.js'
|
|
@@ -153,14 +156,18 @@ function processCLIConfig(
|
|
|
153
156
|
}
|
|
154
157
|
break
|
|
155
158
|
|
|
156
|
-
case 'render':
|
|
157
|
-
|
|
158
|
-
programMeta.defaultRenderName = extractFunctionName(
|
|
159
|
+
case 'render': {
|
|
160
|
+
let renderFuncId = extractFunctionName(
|
|
159
161
|
prop.initializer,
|
|
160
162
|
typeChecker,
|
|
161
163
|
inspectorState.rootDir
|
|
162
164
|
).pikkuFuncId
|
|
165
|
+
if (renderFuncId.startsWith('__temp_')) {
|
|
166
|
+
renderFuncId = makeContextBasedId('cli-render', programName)
|
|
167
|
+
}
|
|
168
|
+
programMeta.defaultRenderName = renderFuncId
|
|
163
169
|
break
|
|
170
|
+
}
|
|
164
171
|
}
|
|
165
172
|
}
|
|
166
173
|
|
|
@@ -273,12 +280,16 @@ function processCommand(
|
|
|
273
280
|
ts.isArrowFunction(node) ||
|
|
274
281
|
ts.isFunctionExpression(node)
|
|
275
282
|
) {
|
|
283
|
+
let pikkuFuncId = extractFunctionName(
|
|
284
|
+
node,
|
|
285
|
+
typeChecker,
|
|
286
|
+
inspectorState.rootDir
|
|
287
|
+
).pikkuFuncId
|
|
288
|
+
if (pikkuFuncId.startsWith('__temp_')) {
|
|
289
|
+
pikkuFuncId = makeContextBasedId('cli', programName, ...fullPath)
|
|
290
|
+
}
|
|
276
291
|
return {
|
|
277
|
-
pikkuFuncId
|
|
278
|
-
node,
|
|
279
|
-
typeChecker,
|
|
280
|
-
inspectorState.rootDir
|
|
281
|
-
).pikkuFuncId,
|
|
292
|
+
pikkuFuncId,
|
|
282
293
|
positionals: [],
|
|
283
294
|
options: {},
|
|
284
295
|
}
|
|
@@ -338,6 +349,9 @@ function processCommand(
|
|
|
338
349
|
typeChecker,
|
|
339
350
|
inspectorState.rootDir
|
|
340
351
|
).pikkuFuncId
|
|
352
|
+
if (pikkuFuncId.startsWith('__temp_')) {
|
|
353
|
+
pikkuFuncId = makeContextBasedId('cli', programName, ...fullPath)
|
|
354
|
+
}
|
|
341
355
|
meta.pikkuFuncId = pikkuFuncId
|
|
342
356
|
} else if (
|
|
343
357
|
propName === 'options' &&
|
|
@@ -393,13 +407,22 @@ function processCommand(
|
|
|
393
407
|
// Already handled in first pass
|
|
394
408
|
break
|
|
395
409
|
|
|
396
|
-
case 'render':
|
|
397
|
-
|
|
410
|
+
case 'render': {
|
|
411
|
+
let renderFuncId = extractFunctionName(
|
|
398
412
|
prop.initializer,
|
|
399
413
|
typeChecker,
|
|
400
414
|
inspectorState.rootDir
|
|
401
415
|
).pikkuFuncId
|
|
416
|
+
if (renderFuncId.startsWith('__temp_')) {
|
|
417
|
+
renderFuncId = makeContextBasedId(
|
|
418
|
+
'cli-render',
|
|
419
|
+
programName,
|
|
420
|
+
...fullPath
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
meta.renderName = renderFuncId
|
|
402
424
|
break
|
|
425
|
+
}
|
|
403
426
|
|
|
404
427
|
case 'options':
|
|
405
428
|
// Process with pikkuFuncId from first pass
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as ts from 'typescript'
|
|
2
|
+
import {
|
|
3
|
+
getPropertyValue,
|
|
4
|
+
getCommonWireMetaData,
|
|
5
|
+
} from '../utils/get-property-value.js'
|
|
6
|
+
import type { AddWiring } from '../types.js'
|
|
7
|
+
import {
|
|
8
|
+
extractFunctionName,
|
|
9
|
+
makeContextBasedId,
|
|
10
|
+
} from '../utils/extract-function-name.js'
|
|
11
|
+
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
12
|
+
import { resolveMiddleware } from '../utils/middleware.js'
|
|
13
|
+
import { extractWireNames } from '../utils/post-process.js'
|
|
14
|
+
import type { GatewayTransportType } from '@pikku/core/gateway'
|
|
15
|
+
|
|
16
|
+
import { ErrorCode } from '../error-codes.js'
|
|
17
|
+
|
|
18
|
+
export const addGateway: AddWiring = (
|
|
19
|
+
logger,
|
|
20
|
+
node,
|
|
21
|
+
checker,
|
|
22
|
+
state,
|
|
23
|
+
_options
|
|
24
|
+
) => {
|
|
25
|
+
if (!ts.isCallExpression(node)) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const args = node.arguments
|
|
30
|
+
const firstArg = args[0]
|
|
31
|
+
const expression = node.expression
|
|
32
|
+
|
|
33
|
+
if (!ts.isIdentifier(expression) || expression.text !== 'wireGateway') {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!firstArg || !ts.isObjectLiteralExpression(firstArg)) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const obj = firstArg
|
|
42
|
+
|
|
43
|
+
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
44
|
+
const typeValue = getPropertyValue(obj, 'type') as GatewayTransportType | null
|
|
45
|
+
const routeValue = getPropertyValue(obj, 'route') as string | undefined
|
|
46
|
+
const { disabled, tags, summary, description, errors } =
|
|
47
|
+
getCommonWireMetaData(obj, 'Gateway', nameValue, logger)
|
|
48
|
+
|
|
49
|
+
if (disabled) return
|
|
50
|
+
|
|
51
|
+
const funcInitializer = getPropertyAssignmentInitializer(
|
|
52
|
+
obj,
|
|
53
|
+
'func',
|
|
54
|
+
true,
|
|
55
|
+
checker
|
|
56
|
+
)
|
|
57
|
+
if (!funcInitializer) {
|
|
58
|
+
logger.critical(
|
|
59
|
+
ErrorCode.MISSING_FUNC,
|
|
60
|
+
`No valid 'func' property for gateway '${nameValue}'.`
|
|
61
|
+
)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const extracted = extractFunctionName(funcInitializer, checker, state.rootDir)
|
|
66
|
+
let pikkuFuncId = extracted.pikkuFuncId
|
|
67
|
+
if (pikkuFuncId.startsWith('__temp_') && nameValue) {
|
|
68
|
+
pikkuFuncId = makeContextBasedId('gateway', nameValue)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!nameValue || !typeValue) {
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const middleware = resolveMiddleware(state, obj, tags, checker)
|
|
76
|
+
|
|
77
|
+
state.serviceAggregation.usedFunctions.add(pikkuFuncId)
|
|
78
|
+
extractWireNames(middleware).forEach((name) =>
|
|
79
|
+
state.serviceAggregation.usedMiddleware.add(name)
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
state.gateways.files.add(node.getSourceFile().fileName)
|
|
83
|
+
state.gateways.meta[nameValue] = {
|
|
84
|
+
pikkuFuncId,
|
|
85
|
+
name: nameValue,
|
|
86
|
+
type: typeValue,
|
|
87
|
+
route: routeValue,
|
|
88
|
+
gateway: true,
|
|
89
|
+
summary,
|
|
90
|
+
description,
|
|
91
|
+
errors,
|
|
92
|
+
tags,
|
|
93
|
+
middleware,
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/inspector.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as ts from 'typescript'
|
|
2
2
|
import type { ChannelsMeta } from '@pikku/core/channel'
|
|
3
|
+
import type { GatewaysMeta } from '@pikku/core/gateway'
|
|
3
4
|
import type { HTTPWiringsMeta } from '@pikku/core/http'
|
|
4
5
|
import type { ScheduledTasksMeta } from '@pikku/core/scheduler'
|
|
5
6
|
import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger'
|
|
@@ -303,6 +304,10 @@ export interface InspectorState {
|
|
|
303
304
|
http: InspectorHTTPState
|
|
304
305
|
functions: InspectorFunctionState
|
|
305
306
|
channels: InspectorChannelState
|
|
307
|
+
gateways: {
|
|
308
|
+
meta: GatewaysMeta
|
|
309
|
+
files: Set<string>
|
|
310
|
+
}
|
|
306
311
|
triggers: {
|
|
307
312
|
meta: TriggerMeta
|
|
308
313
|
sourceMeta: TriggerSourceMeta
|
|
@@ -116,6 +116,10 @@ export interface SerializableInspectorState {
|
|
|
116
116
|
files: string[]
|
|
117
117
|
meta: InspectorState['channels']['meta']
|
|
118
118
|
}
|
|
119
|
+
gateways: {
|
|
120
|
+
meta: InspectorState['gateways']['meta']
|
|
121
|
+
files: string[]
|
|
122
|
+
}
|
|
119
123
|
triggers: {
|
|
120
124
|
meta: InspectorState['triggers']['meta']
|
|
121
125
|
sourceMeta: InspectorState['triggers']['sourceMeta']
|
|
@@ -315,6 +319,10 @@ export function serializeInspectorState(
|
|
|
315
319
|
files: Array.from(state.channels.files),
|
|
316
320
|
meta: state.channels.meta,
|
|
317
321
|
},
|
|
322
|
+
gateways: {
|
|
323
|
+
meta: state.gateways.meta,
|
|
324
|
+
files: Array.from(state.gateways.files),
|
|
325
|
+
},
|
|
318
326
|
triggers: {
|
|
319
327
|
meta: state.triggers.meta,
|
|
320
328
|
sourceMeta: state.triggers.sourceMeta,
|
|
@@ -479,6 +487,10 @@ export function deserializeInspectorState(
|
|
|
479
487
|
files: new Set(data.channels.files),
|
|
480
488
|
meta: data.channels.meta,
|
|
481
489
|
},
|
|
490
|
+
gateways: {
|
|
491
|
+
meta: data.gateways?.meta ?? {},
|
|
492
|
+
files: new Set(data.gateways?.files ?? []),
|
|
493
|
+
},
|
|
482
494
|
triggers: {
|
|
483
495
|
meta: data.triggers?.meta ?? {},
|
|
484
496
|
sourceMeta: data.triggers?.sourceMeta ?? {},
|
package/src/visit.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
} from './types.js'
|
|
17
17
|
import { addFunctions } from './add/add-functions.js'
|
|
18
18
|
import { addChannel } from './add/add-channel.js'
|
|
19
|
+
import { addGateway } from './add/add-gateway.js'
|
|
19
20
|
import { addRPCInvocations } from './add/add-rpc-invocations.js'
|
|
20
21
|
import { addWireAddon } from './add/add-wire-addon.js'
|
|
21
22
|
import { addMiddleware } from './add/add-middleware.js'
|
|
@@ -111,6 +112,7 @@ export const visitRoutes = (
|
|
|
111
112
|
addTrigger(logger, node, checker, state, options)
|
|
112
113
|
addQueueWorker(logger, node, checker, state, options)
|
|
113
114
|
addChannel(logger, node, checker, state, options)
|
|
115
|
+
addGateway(logger, node, checker, state, options)
|
|
114
116
|
addCLI(logger, node, checker, state, options)
|
|
115
117
|
addCLIRenderers(logger, node, checker, state, options)
|
|
116
118
|
addMCPResource(logger, node, checker, state, options)
|