@pikku/inspector 0.10.2 → 0.11.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 +23 -0
- package/dist/add/add-channel.js +11 -10
- package/dist/add/add-file-with-factory.js +10 -10
- package/dist/add/add-functions.js +65 -44
- package/dist/add/add-http-route.js +5 -4
- package/dist/add/add-mcp-prompt.js +6 -5
- package/dist/add/add-mcp-resource.js +6 -5
- package/dist/add/add-mcp-tool.js +6 -5
- package/dist/add/add-middleware.js +1 -1
- package/dist/add/add-permission.js +1 -1
- package/dist/add/add-queue-worker.js +6 -5
- package/dist/add/add-schedule.js +5 -4
- package/dist/add/add-workflow.d.ts +6 -0
- package/dist/add/add-workflow.js +178 -0
- package/dist/error-codes.d.ts +5 -1
- package/dist/error-codes.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/inspector.js +13 -5
- package/dist/types.d.ts +27 -9
- package/dist/utils/extract-function-node.d.ts +10 -0
- package/dist/utils/extract-function-node.js +38 -0
- package/dist/utils/extract-node-value.d.ts +32 -0
- package/dist/utils/extract-node-value.js +103 -0
- package/dist/utils/extract-service-metadata.d.ts +19 -0
- package/dist/utils/extract-service-metadata.js +244 -0
- package/dist/utils/get-files-and-methods.d.ts +3 -3
- package/dist/utils/get-files-and-methods.js +3 -3
- package/dist/utils/get-property-value.d.ts +13 -6
- package/dist/utils/get-property-value.js +51 -43
- package/dist/utils/post-process.d.ts +9 -0
- package/dist/utils/post-process.js +30 -3
- package/dist/utils/serialize-inspector-state.d.ts +21 -4
- package/dist/utils/serialize-inspector-state.js +18 -8
- package/dist/utils/type-utils.d.ts +4 -0
- package/dist/utils/type-utils.js +55 -0
- package/dist/utils/write-service-metadata.d.ts +13 -0
- package/dist/utils/write-service-metadata.js +37 -0
- package/dist/visit.js +4 -2
- package/dist/workflow/extract-simple-workflow.d.ts +15 -0
- package/dist/workflow/extract-simple-workflow.js +803 -0
- package/dist/workflow/patterns.d.ts +39 -0
- package/dist/workflow/patterns.js +138 -0
- package/dist/workflow/validation.d.ts +28 -0
- package/dist/workflow/validation.js +124 -0
- package/package.json +4 -4
- package/src/add/add-channel.ts +37 -17
- package/src/add/add-file-with-factory.ts +10 -10
- package/src/add/add-functions.ts +81 -57
- package/src/add/add-http-route.ts +10 -5
- package/src/add/add-mcp-prompt.ts +11 -7
- package/src/add/add-mcp-resource.ts +11 -7
- package/src/add/add-mcp-tool.ts +11 -7
- package/src/add/add-middleware.ts +1 -1
- package/src/add/add-permission.ts +1 -1
- package/src/add/add-queue-worker.ts +11 -12
- package/src/add/add-schedule.ts +10 -5
- package/src/add/add-workflow.ts +241 -0
- package/src/error-codes.ts +6 -0
- package/src/index.ts +2 -0
- package/src/inspector.ts +19 -5
- package/src/types.ts +24 -9
- package/src/utils/extract-function-node.ts +58 -0
- package/src/utils/extract-node-value.ts +132 -0
- package/src/utils/extract-service-metadata.ts +353 -0
- package/src/utils/filter-inspector-state.test.ts +3 -3
- package/src/utils/filter-utils.test.ts +45 -51
- package/src/utils/get-files-and-methods.ts +11 -11
- package/src/utils/get-property-value.ts +60 -53
- package/src/utils/permissions.test.ts +3 -3
- package/src/utils/post-process.ts +56 -3
- package/src/utils/serialize-inspector-state.ts +37 -15
- package/src/utils/test-data/inspector-state.json +13 -9
- package/src/utils/type-utils.ts +69 -0
- package/src/utils/write-service-metadata.ts +51 -0
- package/src/visit.ts +5 -3
- package/src/workflow/extract-simple-workflow.ts +1035 -0
- package/src/workflow/patterns.ts +182 -0
- package/src/workflow/validation.ts +153 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/add/add-mcp-prompt.ts.tmp +0 -0
- package/src/add/add-mcp-resource.ts.tmp +0 -0
package/src/add/add-functions.ts
CHANGED
|
@@ -2,9 +2,12 @@ import * as ts from 'typescript'
|
|
|
2
2
|
import { AddWiring } from '../types.js'
|
|
3
3
|
import { TypesMap } from '../types-map.js'
|
|
4
4
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
5
|
-
import {
|
|
6
|
-
import { FunctionServicesMeta
|
|
7
|
-
import {
|
|
5
|
+
import { extractFunctionNode } from '../utils/extract-function-node.js'
|
|
6
|
+
import { FunctionServicesMeta } from '@pikku/core'
|
|
7
|
+
import {
|
|
8
|
+
getPropertyValue,
|
|
9
|
+
getCommonWireMetaData,
|
|
10
|
+
} from '../utils/get-property-value.js'
|
|
8
11
|
import { resolveMiddleware } from '../utils/middleware.js'
|
|
9
12
|
|
|
10
13
|
const isValidVariableName = (name: string) => {
|
|
@@ -304,54 +307,43 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
304
307
|
extractFunctionName(node, checker, state.rootDir)
|
|
305
308
|
|
|
306
309
|
let tags: string[] | undefined
|
|
310
|
+
let summary: string | undefined
|
|
311
|
+
let description: string | undefined
|
|
312
|
+
let errors: string[] | undefined
|
|
307
313
|
let expose: boolean | undefined
|
|
308
|
-
let
|
|
314
|
+
let internal: boolean | undefined
|
|
309
315
|
let objectNode: ts.ObjectLiteralExpression | undefined
|
|
310
316
|
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
)
|
|
329
|
-
if (
|
|
330
|
-
!fnProp ||
|
|
331
|
-
(!ts.isArrowFunction(fnProp) && !ts.isFunctionExpression(fnProp))
|
|
332
|
-
) {
|
|
333
|
-
logger.error(`• No valid 'func' property found for ${pikkuFuncName}.`)
|
|
334
|
-
// Create stub metadata to prevent "function not found" errors in wirings
|
|
335
|
-
state.functions.meta[pikkuFuncName] = {
|
|
336
|
-
pikkuFuncName,
|
|
337
|
-
name,
|
|
338
|
-
services: { optimized: false, services: [] },
|
|
339
|
-
inputSchemaName: null,
|
|
340
|
-
outputSchemaName: null,
|
|
341
|
-
inputs: [],
|
|
342
|
-
outputs: [],
|
|
343
|
-
middleware: undefined,
|
|
344
|
-
}
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
handlerNode = fnProp
|
|
317
|
+
// Extract the function node using shared utility
|
|
318
|
+
const firstArg = args[0]!
|
|
319
|
+
const {
|
|
320
|
+
funcNode: handlerNode,
|
|
321
|
+
resolvedFunc,
|
|
322
|
+
isDirectFunction,
|
|
323
|
+
} = extractFunctionNode(firstArg, checker)
|
|
324
|
+
|
|
325
|
+
// Extract config properties if using object form
|
|
326
|
+
if (ts.isObjectLiteralExpression(firstArg)) {
|
|
327
|
+
objectNode = firstArg
|
|
328
|
+
const metadata = getCommonWireMetaData(firstArg, 'Function', name, logger)
|
|
329
|
+
tags = metadata.tags
|
|
330
|
+
summary = metadata.summary
|
|
331
|
+
description = metadata.description
|
|
332
|
+
errors = metadata.errors
|
|
333
|
+
expose = getPropertyValue(firstArg, 'expose') as boolean | undefined
|
|
334
|
+
internal = getPropertyValue(firstArg, 'internal') as boolean | undefined
|
|
348
335
|
}
|
|
349
336
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
337
|
+
// Pick the handler: use resolvedFunc when it exists and is a function, otherwise fall back to handlerNode
|
|
338
|
+
const handler =
|
|
339
|
+
resolvedFunc &&
|
|
340
|
+
(ts.isArrowFunction(resolvedFunc) || ts.isFunctionExpression(resolvedFunc))
|
|
341
|
+
? resolvedFunc
|
|
342
|
+
: handlerNode
|
|
343
|
+
|
|
344
|
+
// Validate that we got a valid function
|
|
345
|
+
if (!ts.isArrowFunction(handler) && !ts.isFunctionExpression(handler)) {
|
|
346
|
+
logger.error(`• No valid 'func' property found for ${pikkuFuncName}.`)
|
|
355
347
|
// Create stub metadata to prevent "function not found" errors in wirings
|
|
356
348
|
state.functions.meta[pikkuFuncName] = {
|
|
357
349
|
pikkuFuncName,
|
|
@@ -371,7 +363,7 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
371
363
|
services: [],
|
|
372
364
|
}
|
|
373
365
|
|
|
374
|
-
const firstParam =
|
|
366
|
+
const firstParam = handler.parameters[0]
|
|
375
367
|
if (firstParam) {
|
|
376
368
|
if (ts.isObjectBindingPattern(firstParam.name)) {
|
|
377
369
|
for (const elem of firstParam.name.elements) {
|
|
@@ -390,6 +382,23 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
390
382
|
}
|
|
391
383
|
}
|
|
392
384
|
|
|
385
|
+
// --- Extract used wires from third parameter ---
|
|
386
|
+
const usedWires: string[] = []
|
|
387
|
+
const thirdParam = handler.parameters[2]
|
|
388
|
+
if (thirdParam && ts.isObjectBindingPattern(thirdParam.name)) {
|
|
389
|
+
for (const elem of thirdParam.name.elements) {
|
|
390
|
+
const propertyName =
|
|
391
|
+
elem.propertyName && ts.isIdentifier(elem.propertyName)
|
|
392
|
+
? elem.propertyName.text
|
|
393
|
+
: ts.isIdentifier(elem.name)
|
|
394
|
+
? elem.name.text
|
|
395
|
+
: undefined
|
|
396
|
+
if (propertyName) {
|
|
397
|
+
usedWires.push(propertyName)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
393
402
|
// --- Generics → ts.Type[], unwrapped from Promise ---
|
|
394
403
|
const genericTypes: ts.Type[] = (typeArguments ?? [])
|
|
395
404
|
.map((tn) => checker.getTypeFromTypeNode(tn))
|
|
@@ -420,7 +429,7 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
420
429
|
genericTypes[1]
|
|
421
430
|
).names
|
|
422
431
|
} else {
|
|
423
|
-
const sig = checker.getSignatureFromDeclaration(
|
|
432
|
+
const sig = checker.getSignatureFromDeclaration(handler)
|
|
424
433
|
if (sig) {
|
|
425
434
|
const rawRet = checker.getReturnTypeOfSignature(sig)
|
|
426
435
|
const unwrapped = unwrapPromise(checker, rawRet)
|
|
@@ -440,6 +449,11 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
440
449
|
)
|
|
441
450
|
}
|
|
442
451
|
|
|
452
|
+
// Store the input type for later use
|
|
453
|
+
if (inputTypes.length > 0) {
|
|
454
|
+
state.typesLookup.set(pikkuFuncName, inputTypes)
|
|
455
|
+
}
|
|
456
|
+
|
|
443
457
|
// --- resolve middleware ---
|
|
444
458
|
const middleware = objectNode
|
|
445
459
|
? resolveMiddleware(state, objectNode, tags, checker)
|
|
@@ -449,20 +463,19 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
449
463
|
pikkuFuncName,
|
|
450
464
|
name,
|
|
451
465
|
services,
|
|
466
|
+
usedWires: usedWires.length > 0 ? usedWires : undefined,
|
|
452
467
|
inputSchemaName: inputNames[0] ?? null,
|
|
453
468
|
outputSchemaName: outputNames[0] ?? null,
|
|
454
469
|
inputs: inputNames.filter((n) => n !== 'void') ?? null,
|
|
455
470
|
outputs: outputNames.filter((n) => n !== 'void') ?? null,
|
|
456
471
|
expose: expose || undefined,
|
|
472
|
+
internal: internal || undefined,
|
|
457
473
|
tags: tags || undefined,
|
|
458
|
-
|
|
459
|
-
|
|
474
|
+
summary,
|
|
475
|
+
description,
|
|
476
|
+
errors,
|
|
460
477
|
middleware,
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
// Store the input type for later use
|
|
464
|
-
if (inputTypes.length > 0) {
|
|
465
|
-
state.typesLookup.set(pikkuFuncName, inputTypes)
|
|
478
|
+
isDirectFunction,
|
|
466
479
|
}
|
|
467
480
|
|
|
468
481
|
// Store function file location for wiring generation
|
|
@@ -473,6 +486,12 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
473
486
|
})
|
|
474
487
|
}
|
|
475
488
|
|
|
489
|
+
// Workflow functions don't get registered as RPC functions,
|
|
490
|
+
// they are their own type handled by add-workdflow
|
|
491
|
+
if (expression.text.includes('Workflow')) {
|
|
492
|
+
return
|
|
493
|
+
}
|
|
494
|
+
|
|
476
495
|
if (exportedName || explicitName) {
|
|
477
496
|
if (!exportedName) {
|
|
478
497
|
logger.error(
|
|
@@ -481,6 +500,11 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
481
500
|
return
|
|
482
501
|
}
|
|
483
502
|
|
|
503
|
+
// Mark internal functions as invoked to force bundling
|
|
504
|
+
if (internal) {
|
|
505
|
+
state.rpc.invokedFunctions.add(pikkuFuncName)
|
|
506
|
+
}
|
|
507
|
+
|
|
484
508
|
if (expose) {
|
|
485
509
|
state.rpc.exposedMeta[name] = pikkuFuncName
|
|
486
510
|
state.rpc.exposedFiles.set(name, {
|
|
@@ -496,8 +520,8 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
496
520
|
|
|
497
521
|
// But we only import the actual function if it's actually invoked to keep
|
|
498
522
|
// bundle size down
|
|
499
|
-
if (state.rpc.invokedFunctions.has(pikkuFuncName) || expose) {
|
|
500
|
-
state.rpc.internalFiles.set(
|
|
523
|
+
if (state.rpc.invokedFunctions.has(pikkuFuncName) || expose || internal) {
|
|
524
|
+
state.rpc.internalFiles.set(pikkuFuncName, {
|
|
501
525
|
path: node.getSourceFile().fileName,
|
|
502
526
|
exportedName,
|
|
503
527
|
})
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { pathToRegexp } from 'path-to-regexp'
|
|
7
7
|
import { HTTPMethod } from '@pikku/core/http'
|
|
8
|
-
import { PikkuDocs } from '@pikku/core'
|
|
9
8
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
10
9
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
11
10
|
import { AddWiring } from '../types.js'
|
|
@@ -71,8 +70,12 @@ export const addHTTPRoute: AddWiring = (
|
|
|
71
70
|
|
|
72
71
|
const method =
|
|
73
72
|
(getPropertyValue(obj, 'method') as string)?.toLowerCase() || 'get'
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
74
|
+
obj,
|
|
75
|
+
'HTTP route',
|
|
76
|
+
route,
|
|
77
|
+
logger
|
|
78
|
+
)
|
|
76
79
|
const query = (getPropertyValue(obj, 'query') as string[]) || []
|
|
77
80
|
|
|
78
81
|
// --- find the referenced function name first for filtering ---
|
|
@@ -155,7 +158,9 @@ export const addHTTPRoute: AddWiring = (
|
|
|
155
158
|
params: params.length > 0 ? params : undefined,
|
|
156
159
|
query: query.length > 0 ? query : undefined,
|
|
157
160
|
inputTypes,
|
|
158
|
-
|
|
161
|
+
summary,
|
|
162
|
+
description,
|
|
163
|
+
errors,
|
|
159
164
|
tags,
|
|
160
165
|
middleware,
|
|
161
166
|
permissions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -40,10 +40,12 @@ export const addMCPPrompt: AddWiring = (
|
|
|
40
40
|
const obj = firstArg
|
|
41
41
|
|
|
42
42
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
44
|
+
obj,
|
|
45
|
+
'MCP prompt',
|
|
46
|
+
nameValue,
|
|
47
|
+
logger
|
|
48
|
+
)
|
|
47
49
|
|
|
48
50
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
49
51
|
obj,
|
|
@@ -76,7 +78,7 @@ export const addMCPPrompt: AddWiring = (
|
|
|
76
78
|
return
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
if (!
|
|
81
|
+
if (!description) {
|
|
80
82
|
logger.critical(
|
|
81
83
|
ErrorCode.MISSING_DESCRIPTION,
|
|
82
84
|
`MCP prompt '${nameValue}' is missing a description.`
|
|
@@ -116,7 +118,9 @@ export const addMCPPrompt: AddWiring = (
|
|
|
116
118
|
state.mcpEndpoints.promptsMeta[nameValue] = {
|
|
117
119
|
pikkuFuncName,
|
|
118
120
|
name: nameValue,
|
|
119
|
-
description
|
|
121
|
+
description,
|
|
122
|
+
summary,
|
|
123
|
+
errors,
|
|
120
124
|
tags,
|
|
121
125
|
inputSchema,
|
|
122
126
|
outputSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -41,11 +41,13 @@ export const addMCPResource: AddWiring = (
|
|
|
41
41
|
|
|
42
42
|
const uriValue = getPropertyValue(obj, 'uri') as string | null
|
|
43
43
|
const titleValue = getPropertyValue(obj, 'title') as string | null
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
45
|
+
obj,
|
|
46
|
+
'MCP resource',
|
|
47
|
+
uriValue,
|
|
48
|
+
logger
|
|
49
|
+
)
|
|
47
50
|
const streamingValue = getPropertyValue(obj, 'streaming') as boolean | null
|
|
48
|
-
const tags = getPropertyTags(obj, 'MCP resource', uriValue, logger)
|
|
49
51
|
|
|
50
52
|
if (streamingValue === true) {
|
|
51
53
|
logger.warn(
|
|
@@ -92,7 +94,7 @@ export const addMCPResource: AddWiring = (
|
|
|
92
94
|
return
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
if (!
|
|
97
|
+
if (!description) {
|
|
96
98
|
logger.critical(
|
|
97
99
|
ErrorCode.MISSING_DESCRIPTION,
|
|
98
100
|
`MCP resource '${uriValue}' is missing a description.`
|
|
@@ -133,7 +135,9 @@ export const addMCPResource: AddWiring = (
|
|
|
133
135
|
pikkuFuncName,
|
|
134
136
|
uri: uriValue,
|
|
135
137
|
title: titleValue,
|
|
136
|
-
description
|
|
138
|
+
description,
|
|
139
|
+
summary,
|
|
140
|
+
errors,
|
|
137
141
|
...(streamingValue !== null && { streaming: streamingValue }),
|
|
138
142
|
tags,
|
|
139
143
|
inputSchema,
|
package/src/add/add-mcp-tool.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
6
|
import { extractWireNames } from '../utils/post-process.js'
|
|
7
7
|
import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
|
|
@@ -41,11 +41,13 @@ export const addMCPTool: AddWiring = (
|
|
|
41
41
|
|
|
42
42
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
43
43
|
const titleValue = getPropertyValue(obj, 'title') as string | null
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
45
|
+
obj,
|
|
46
|
+
'MCP tool',
|
|
47
|
+
nameValue,
|
|
48
|
+
logger
|
|
49
|
+
)
|
|
47
50
|
const streamingValue = getPropertyValue(obj, 'streaming') as boolean | null
|
|
48
|
-
const tags = getPropertyTags(obj, 'MCP tool', nameValue, logger)
|
|
49
51
|
|
|
50
52
|
if (streamingValue === true) {
|
|
51
53
|
logger.warn(
|
|
@@ -84,7 +86,7 @@ export const addMCPTool: AddWiring = (
|
|
|
84
86
|
return
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
if (!
|
|
89
|
+
if (!description) {
|
|
88
90
|
logger.critical(
|
|
89
91
|
ErrorCode.MISSING_DESCRIPTION,
|
|
90
92
|
`MCP tool '${nameValue}' is missing a description.`
|
|
@@ -125,7 +127,9 @@ export const addMCPTool: AddWiring = (
|
|
|
125
127
|
pikkuFuncName,
|
|
126
128
|
name: nameValue,
|
|
127
129
|
title: titleValue || undefined,
|
|
128
|
-
description
|
|
130
|
+
description,
|
|
131
|
+
summary,
|
|
132
|
+
errors,
|
|
129
133
|
...(streamingValue !== null && { streaming: streamingValue }),
|
|
130
134
|
tags,
|
|
131
135
|
inputSchema,
|
|
@@ -125,7 +125,7 @@ export const addMiddleware: AddWiring = (logger, node, checker, state) => {
|
|
|
125
125
|
}
|
|
126
126
|
} else {
|
|
127
127
|
// No pikkuMiddleware wrapper found - extract from factory's return value directly
|
|
128
|
-
// Factory pattern: (config) => (services,
|
|
128
|
+
// Factory pattern: (config) => (services, wire, next) => { ... }
|
|
129
129
|
if (
|
|
130
130
|
ts.isArrowFunction(factoryNode) ||
|
|
131
131
|
ts.isFunctionExpression(factoryNode)
|
|
@@ -125,7 +125,7 @@ export const addPermission: AddWiring = (logger, node, checker, state) => {
|
|
|
125
125
|
}
|
|
126
126
|
} else {
|
|
127
127
|
// No pikkuPermission wrapper found - extract from factory's return value directly
|
|
128
|
-
// Factory pattern: (config) => (services, data,
|
|
128
|
+
// Factory pattern: (config) => (services, data, wire) => { ... }
|
|
129
129
|
if (
|
|
130
130
|
ts.isArrowFunction(factoryNode) ||
|
|
131
131
|
ts.isFunctionExpression(factoryNode)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
|
-
import { PikkuDocs } from '@pikku/core'
|
|
7
6
|
import { AddWiring } from '../types.js'
|
|
8
7
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
9
8
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
@@ -11,13 +10,7 @@ import { resolveMiddleware } from '../utils/middleware.js'
|
|
|
11
10
|
import { extractWireNames } from '../utils/post-process.js'
|
|
12
11
|
import { ErrorCode } from '../error-codes.js'
|
|
13
12
|
|
|
14
|
-
export const addQueueWorker: AddWiring = (
|
|
15
|
-
logger,
|
|
16
|
-
node,
|
|
17
|
-
checker,
|
|
18
|
-
state,
|
|
19
|
-
options
|
|
20
|
-
) => {
|
|
13
|
+
export const addQueueWorker: AddWiring = (logger, node, checker, state) => {
|
|
21
14
|
if (!ts.isCallExpression(node)) {
|
|
22
15
|
return
|
|
23
16
|
}
|
|
@@ -39,8 +32,12 @@ export const addQueueWorker: AddWiring = (
|
|
|
39
32
|
const obj = firstArg
|
|
40
33
|
|
|
41
34
|
const queueName = getPropertyValue(obj, 'queueName') as string | null
|
|
42
|
-
const
|
|
43
|
-
|
|
35
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
36
|
+
obj,
|
|
37
|
+
'Queue worker',
|
|
38
|
+
queueName,
|
|
39
|
+
logger
|
|
40
|
+
)
|
|
44
41
|
|
|
45
42
|
// --- find the referenced function ---
|
|
46
43
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
@@ -84,7 +81,9 @@ export const addQueueWorker: AddWiring = (
|
|
|
84
81
|
state.queueWorkers.meta[queueName] = {
|
|
85
82
|
pikkuFuncName,
|
|
86
83
|
queueName,
|
|
87
|
-
|
|
84
|
+
summary,
|
|
85
|
+
description,
|
|
86
|
+
errors,
|
|
88
87
|
tags,
|
|
89
88
|
middleware,
|
|
90
89
|
}
|
package/src/add/add-schedule.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import {
|
|
3
3
|
getPropertyValue,
|
|
4
|
-
|
|
4
|
+
getCommonWireMetaData,
|
|
5
5
|
} from '../utils/get-property-value.js'
|
|
6
|
-
import { PikkuDocs } from '@pikku/core'
|
|
7
6
|
import { AddWiring } from '../types.js'
|
|
8
7
|
import { extractFunctionName } from '../utils/extract-function-name.js'
|
|
9
8
|
import { getPropertyAssignmentInitializer } from '../utils/type-utils.js'
|
|
@@ -40,8 +39,12 @@ export const addSchedule: AddWiring = (
|
|
|
40
39
|
|
|
41
40
|
const nameValue = getPropertyValue(obj, 'name') as string | null
|
|
42
41
|
const scheduleValue = getPropertyValue(obj, 'schedule') as string | null
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
const { tags, summary, description, errors } = getCommonWireMetaData(
|
|
43
|
+
obj,
|
|
44
|
+
'Scheduler',
|
|
45
|
+
nameValue,
|
|
46
|
+
logger
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
const funcInitializer = getPropertyAssignmentInitializer(
|
|
47
50
|
obj,
|
|
@@ -81,7 +84,9 @@ export const addSchedule: AddWiring = (
|
|
|
81
84
|
pikkuFuncName,
|
|
82
85
|
name: nameValue,
|
|
83
86
|
schedule: scheduleValue,
|
|
84
|
-
|
|
87
|
+
summary,
|
|
88
|
+
description,
|
|
89
|
+
errors,
|
|
85
90
|
tags,
|
|
86
91
|
middleware,
|
|
87
92
|
}
|