@pikku/inspector 0.11.0 → 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 +16 -1
- package/dist/add/add-channel.js +11 -10
- package/dist/add/add-file-with-factory.js +10 -10
- package/dist/add/add-functions.js +57 -43
- 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 +1 -1
- package/dist/add/add-workflow.js +92 -66
- package/dist/error-codes.d.ts +1 -0
- package/dist/error-codes.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/inspector.js +10 -6
- package/dist/types.d.ts +21 -8
- 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 +8 -0
- package/dist/utils/extract-node-value.js +24 -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 +18 -5
- package/dist/utils/serialize-inspector-state.js +12 -10
- package/dist/utils/write-service-metadata.d.ts +13 -0
- package/dist/utils/write-service-metadata.js +37 -0
- package/dist/visit.js +2 -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 +72 -56
- 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 +120 -110
- package/src/error-codes.ts +1 -0
- package/src/index.ts +2 -0
- package/src/inspector.ts +16 -6
- package/src/types.ts +18 -8
- package/src/utils/extract-function-node.ts +58 -0
- package/src/utils/extract-node-value.ts +31 -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 +28 -18
- package/src/utils/test-data/inspector-state.json +9 -9
- package/src/utils/write-service-metadata.ts +51 -0
- package/src/visit.ts +3 -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-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,56 +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
314
|
let internal: boolean | undefined
|
|
309
|
-
let docs: PikkuDocs | undefined
|
|
310
315
|
let objectNode: ts.ObjectLiteralExpression | undefined
|
|
311
316
|
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
)
|
|
331
|
-
if (
|
|
332
|
-
!fnProp ||
|
|
333
|
-
(!ts.isArrowFunction(fnProp) && !ts.isFunctionExpression(fnProp))
|
|
334
|
-
) {
|
|
335
|
-
logger.error(`• No valid 'func' property found for ${pikkuFuncName}.`)
|
|
336
|
-
// Create stub metadata to prevent "function not found" errors in wirings
|
|
337
|
-
state.functions.meta[pikkuFuncName] = {
|
|
338
|
-
pikkuFuncName,
|
|
339
|
-
name,
|
|
340
|
-
services: { optimized: false, services: [] },
|
|
341
|
-
inputSchemaName: null,
|
|
342
|
-
outputSchemaName: null,
|
|
343
|
-
inputs: [],
|
|
344
|
-
outputs: [],
|
|
345
|
-
middleware: undefined,
|
|
346
|
-
}
|
|
347
|
-
return
|
|
348
|
-
}
|
|
349
|
-
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
|
|
350
335
|
}
|
|
351
336
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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}.`)
|
|
357
347
|
// Create stub metadata to prevent "function not found" errors in wirings
|
|
358
348
|
state.functions.meta[pikkuFuncName] = {
|
|
359
349
|
pikkuFuncName,
|
|
@@ -373,7 +363,7 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
373
363
|
services: [],
|
|
374
364
|
}
|
|
375
365
|
|
|
376
|
-
const firstParam =
|
|
366
|
+
const firstParam = handler.parameters[0]
|
|
377
367
|
if (firstParam) {
|
|
378
368
|
if (ts.isObjectBindingPattern(firstParam.name)) {
|
|
379
369
|
for (const elem of firstParam.name.elements) {
|
|
@@ -392,6 +382,23 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
392
382
|
}
|
|
393
383
|
}
|
|
394
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
|
+
|
|
395
402
|
// --- Generics → ts.Type[], unwrapped from Promise ---
|
|
396
403
|
const genericTypes: ts.Type[] = (typeArguments ?? [])
|
|
397
404
|
.map((tn) => checker.getTypeFromTypeNode(tn))
|
|
@@ -422,7 +429,7 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
422
429
|
genericTypes[1]
|
|
423
430
|
).names
|
|
424
431
|
} else {
|
|
425
|
-
const sig = checker.getSignatureFromDeclaration(
|
|
432
|
+
const sig = checker.getSignatureFromDeclaration(handler)
|
|
426
433
|
if (sig) {
|
|
427
434
|
const rawRet = checker.getReturnTypeOfSignature(sig)
|
|
428
435
|
const unwrapped = unwrapPromise(checker, rawRet)
|
|
@@ -442,6 +449,11 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
442
449
|
)
|
|
443
450
|
}
|
|
444
451
|
|
|
452
|
+
// Store the input type for later use
|
|
453
|
+
if (inputTypes.length > 0) {
|
|
454
|
+
state.typesLookup.set(pikkuFuncName, inputTypes)
|
|
455
|
+
}
|
|
456
|
+
|
|
445
457
|
// --- resolve middleware ---
|
|
446
458
|
const middleware = objectNode
|
|
447
459
|
? resolveMiddleware(state, objectNode, tags, checker)
|
|
@@ -451,6 +463,7 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
451
463
|
pikkuFuncName,
|
|
452
464
|
name,
|
|
453
465
|
services,
|
|
466
|
+
usedWires: usedWires.length > 0 ? usedWires : undefined,
|
|
454
467
|
inputSchemaName: inputNames[0] ?? null,
|
|
455
468
|
outputSchemaName: outputNames[0] ?? null,
|
|
456
469
|
inputs: inputNames.filter((n) => n !== 'void') ?? null,
|
|
@@ -458,14 +471,11 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
458
471
|
expose: expose || undefined,
|
|
459
472
|
internal: internal || undefined,
|
|
460
473
|
tags: tags || undefined,
|
|
461
|
-
|
|
462
|
-
|
|
474
|
+
summary,
|
|
475
|
+
description,
|
|
476
|
+
errors,
|
|
463
477
|
middleware,
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
// Store the input type for later use
|
|
467
|
-
if (inputTypes.length > 0) {
|
|
468
|
-
state.typesLookup.set(pikkuFuncName, inputTypes)
|
|
478
|
+
isDirectFunction,
|
|
469
479
|
}
|
|
470
480
|
|
|
471
481
|
// Store function file location for wiring generation
|
|
@@ -476,6 +486,12 @@ export const addFunctions: AddWiring = (logger, node, checker, state) => {
|
|
|
476
486
|
})
|
|
477
487
|
}
|
|
478
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
|
+
|
|
479
495
|
if (exportedName || explicitName) {
|
|
480
496
|
if (!exportedName) {
|
|
481
497
|
logger.error(
|
|
@@ -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
|
}
|