@pikku/inspector 0.11.2 → 0.12.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 +36 -1
- package/OPTIMIZATION-PLAN.md +195 -0
- package/dist/add/add-ai-agent.d.ts +2 -0
- package/dist/add/add-ai-agent.js +314 -0
- package/dist/add/add-channel.js +81 -61
- package/dist/add/add-cli.d.ts +1 -1
- package/dist/add/add-cli.js +42 -19
- package/dist/add/add-file-extends-core-type.d.ts +1 -1
- package/dist/add/add-file-with-config.d.ts +1 -1
- package/dist/add/add-file-with-factory.d.ts +1 -1
- package/dist/add/add-file-with-factory.js +2 -0
- package/dist/add/add-functions.d.ts +1 -1
- package/dist/add/add-functions.js +256 -82
- package/dist/add/add-http-route.d.ts +20 -10
- package/dist/add/add-http-route.js +156 -66
- package/dist/add/add-http-routes.d.ts +5 -0
- package/dist/add/add-http-routes.js +160 -0
- package/dist/add/add-keyed-wiring.d.ts +12 -0
- package/dist/add/add-keyed-wiring.js +97 -0
- package/dist/add/add-mcp-prompt.d.ts +1 -1
- package/dist/add/add-mcp-prompt.js +14 -9
- package/dist/add/add-mcp-resource.d.ts +1 -1
- package/dist/add/add-mcp-resource.js +14 -9
- package/dist/add/add-middleware.d.ts +1 -4
- package/dist/add/add-middleware.js +364 -79
- package/dist/add/add-permission.d.ts +1 -1
- package/dist/add/add-permission.js +152 -40
- package/dist/add/add-queue-worker.d.ts +1 -1
- package/dist/add/add-queue-worker.js +18 -12
- package/dist/add/add-rpc-invocations.d.ts +3 -3
- package/dist/add/add-rpc-invocations.js +24 -10
- package/dist/add/add-schedule.d.ts +1 -1
- package/dist/add/add-schedule.js +11 -5
- package/dist/add/add-secret.d.ts +3 -0
- package/dist/add/add-secret.js +82 -0
- package/dist/add/add-trigger.d.ts +2 -0
- package/dist/add/add-trigger.js +87 -0
- package/dist/add/add-variable.d.ts +1 -0
- package/dist/add/add-variable.js +8 -0
- package/dist/add/add-wire-addon.d.ts +7 -0
- package/dist/add/add-wire-addon.js +70 -0
- package/dist/add/add-workflow-graph.d.ts +3 -2
- package/dist/add/add-workflow-graph.js +143 -406
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/add/add-workflow.js +6 -4
- package/dist/error-codes.d.ts +15 -1
- package/dist/error-codes.js +20 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -4
- package/dist/inspector.d.ts +2 -2
- package/dist/inspector.js +95 -15
- package/dist/schema-generator.d.ts +1 -0
- package/dist/schema-generator.js +1 -0
- package/dist/types-map.js +10 -1
- package/dist/types.d.ts +180 -50
- package/dist/utils/compute-required-schemas.d.ts +4 -0
- package/dist/utils/compute-required-schemas.js +40 -0
- package/dist/utils/contract-hashes.d.ts +52 -0
- package/dist/utils/contract-hashes.js +269 -0
- package/dist/utils/custom-types-generator.d.ts +9 -0
- package/dist/utils/custom-types-generator.js +71 -0
- package/dist/utils/detect-schema-vendor.d.ts +22 -0
- package/dist/utils/detect-schema-vendor.js +76 -0
- package/dist/utils/does-type-extend-core-type.d.ts +1 -1
- package/dist/utils/ensure-function-metadata.d.ts +6 -3
- package/dist/utils/ensure-function-metadata.js +220 -6
- package/dist/utils/extract-function-name.d.ts +5 -16
- package/dist/utils/extract-function-name.js +86 -291
- package/dist/utils/extract-services.d.ts +2 -1
- package/dist/utils/extract-services.js +25 -1
- package/dist/utils/filter-inspector-state.d.ts +1 -1
- package/dist/utils/filter-inspector-state.js +107 -23
- package/dist/utils/filter-utils.d.ts +2 -2
- package/dist/utils/get-files-and-methods.d.ts +1 -1
- package/dist/utils/get-property-value.d.ts +6 -1
- package/dist/utils/get-property-value.js +28 -3
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +23 -0
- package/dist/utils/middleware.d.ts +9 -32
- package/dist/utils/middleware.js +80 -66
- package/dist/utils/permissions.d.ts +4 -4
- package/dist/utils/permissions.js +10 -10
- package/dist/utils/post-process.d.ts +11 -11
- package/dist/utils/post-process.js +247 -24
- package/dist/utils/resolve-addon-package.d.ts +16 -0
- package/dist/utils/resolve-addon-package.js +34 -0
- package/dist/utils/resolve-function-types.d.ts +6 -0
- package/dist/utils/resolve-function-types.js +29 -0
- package/dist/utils/resolve-identifier.d.ts +10 -0
- package/dist/utils/resolve-identifier.js +36 -0
- package/dist/utils/resolve-versions.d.ts +2 -0
- package/dist/utils/resolve-versions.js +78 -0
- package/dist/utils/schema-generator.d.ts +9 -0
- package/dist/utils/schema-generator.js +209 -0
- package/dist/utils/serialize-inspector-state.d.ts +70 -23
- package/dist/utils/serialize-inspector-state.js +98 -22
- package/dist/utils/serialize-mcp-json.d.ts +2 -0
- package/dist/utils/serialize-mcp-json.js +99 -0
- package/dist/utils/serialize-middleware-groups-meta.d.ts +12 -0
- package/dist/utils/serialize-middleware-groups-meta.js +28 -0
- package/dist/utils/serialize-openapi-json.d.ts +85 -0
- package/dist/utils/serialize-openapi-json.js +151 -0
- package/dist/utils/serialize-permissions-groups-meta.d.ts +6 -0
- package/dist/utils/serialize-permissions-groups-meta.js +31 -0
- package/dist/utils/validate-auth-sessionless.d.ts +3 -0
- package/dist/utils/validate-auth-sessionless.js +14 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +34 -102
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +23 -4
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +12 -10
- package/dist/utils/workflow/graph/finalize-workflow-wires.d.ts +3 -0
- package/dist/utils/workflow/graph/finalize-workflow-wires.js +276 -0
- package/dist/utils/workflow/graph/finalize-workflows.d.ts +2 -0
- package/dist/utils/workflow/graph/finalize-workflows.js +75 -0
- package/dist/utils/workflow/graph/index.d.ts +2 -0
- package/dist/utils/workflow/graph/index.js +2 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +0 -8
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +1 -3
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +53 -79
- package/dist/utils/workflow/graph/workflow-graph.types.js +1 -1
- package/dist/visit.d.ts +1 -1
- package/dist/visit.js +13 -6
- package/package.json +14 -4
- package/src/add/add-ai-agent.ts +468 -0
- package/src/add/add-channel.ts +103 -79
- package/src/add/add-cli.ts +68 -24
- package/src/add/add-file-extends-core-type.ts +1 -1
- package/src/add/add-file-with-config.ts +1 -1
- package/src/add/add-file-with-factory.ts +3 -1
- package/src/add/add-functions.ts +349 -103
- package/src/add/add-http-route.ts +263 -89
- package/src/add/add-http-routes.ts +229 -0
- package/src/add/add-keyed-wiring.ts +151 -0
- package/src/add/add-mcp-prompt.ts +27 -16
- package/src/add/add-mcp-resource.ts +28 -16
- package/src/add/add-middleware.ts +482 -80
- package/src/add/add-permission.ts +199 -40
- package/src/add/add-queue-worker.ts +25 -20
- package/src/add/add-rpc-invocations.ts +28 -11
- package/src/add/add-schedule.ts +17 -12
- package/src/add/add-secret.ts +140 -0
- package/src/add/add-trigger.ts +154 -0
- package/src/add/add-variable.ts +9 -0
- package/src/add/add-wire-addon.ts +80 -0
- package/src/add/add-workflow-graph.ts +180 -522
- package/src/add/add-workflow.ts +7 -6
- package/src/error-codes.ts +25 -1
- package/src/index.ts +23 -13
- package/src/inspector.ts +139 -19
- package/src/schema-generator.ts +1 -0
- package/src/types-map.ts +12 -1
- package/src/types.ts +199 -69
- package/src/utils/compute-required-schemas.ts +48 -0
- package/src/utils/contract-hashes.test.ts +553 -0
- package/src/utils/contract-hashes.ts +386 -0
- package/src/utils/custom-types-generator.ts +88 -0
- package/src/utils/detect-schema-vendor.ts +90 -0
- package/src/utils/does-type-extend-core-type.ts +1 -1
- package/src/utils/ensure-function-metadata.ts +325 -8
- package/src/utils/extract-function-name.ts +101 -351
- package/src/utils/extract-services.ts +35 -2
- package/src/utils/filter-inspector-state.test.ts +37 -25
- package/src/utils/filter-inspector-state.ts +146 -32
- package/src/utils/filter-utils.test.ts +1 -1
- package/src/utils/filter-utils.ts +2 -2
- package/src/utils/get-files-and-methods.ts +1 -1
- package/src/utils/get-property-value.ts +42 -4
- package/src/utils/hash.ts +26 -0
- package/src/utils/middleware.test.ts +204 -0
- package/src/utils/middleware.ts +131 -69
- package/src/utils/permissions.test.ts +35 -12
- package/src/utils/permissions.ts +12 -12
- package/src/utils/post-process.ts +306 -44
- package/src/utils/resolve-addon-package.ts +49 -0
- package/src/utils/resolve-function-types.ts +42 -0
- package/src/utils/resolve-identifier.ts +46 -0
- package/src/utils/resolve-versions.test.ts +249 -0
- package/src/utils/resolve-versions.ts +105 -0
- package/src/utils/schema-generator.ts +329 -0
- package/src/utils/serialize-inspector-state.ts +184 -43
- package/src/utils/serialize-mcp-json.ts +145 -0
- package/src/utils/serialize-middleware-groups-meta.ts +33 -0
- package/src/utils/serialize-openapi-json.ts +277 -0
- package/src/utils/serialize-permissions-groups-meta.ts +35 -0
- package/src/utils/test-data/inspector-state.json +69 -66
- package/src/utils/validate-auth-sessionless.ts +29 -0
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +43 -119
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +26 -6
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +17 -10
- package/src/utils/workflow/graph/finalize-workflow-wires.ts +310 -0
- package/src/utils/workflow/graph/finalize-workflows.ts +100 -0
- package/src/utils/workflow/graph/index.ts +5 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +1 -8
- package/src/utils/workflow/graph/workflow-graph.types.ts +29 -78
- package/src/visit.ts +19 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/add/add-forge-credential.d.ts +0 -8
- package/dist/add/add-forge-credential.js +0 -77
- package/dist/add/add-forge-node.d.ts +0 -7
- package/dist/add/add-forge-node.js +0 -77
- package/dist/add/add-mcp-tool.d.ts +0 -2
- package/dist/add/add-mcp-tool.js +0 -81
- package/dist/utils/extract-service-metadata.d.ts +0 -19
- package/dist/utils/extract-service-metadata.js +0 -244
- package/dist/utils/write-service-metadata.d.ts +0 -13
- package/dist/utils/write-service-metadata.js +0 -37
- package/src/add/add-forge-credential.ts +0 -119
- package/src/add/add-forge-node.ts +0 -132
- package/src/add/add-mcp-tool.ts +0 -141
- package/src/utils/extract-service-metadata.ts +0 -353
- package/src/utils/write-service-metadata.ts +0 -51
package/dist/add/add-workflow.js
CHANGED
|
@@ -169,7 +169,7 @@ export const addWorkflow = (logger, node, checker, state) => {
|
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
// Extract workflow name and metadata using same logic as add-functions
|
|
172
|
-
const {
|
|
172
|
+
const { pikkuFuncId, name, exportedName } = extractFunctionName(node, checker, state.rootDir);
|
|
173
173
|
const workflowName = exportedName || name;
|
|
174
174
|
if (!workflowName) {
|
|
175
175
|
logger.critical(ErrorCode.MISSING_NAME, `Could not determine workflow name from export.`);
|
|
@@ -184,6 +184,8 @@ export const addWorkflow = (logger, node, checker, state) => {
|
|
|
184
184
|
let errors;
|
|
185
185
|
if (ts.isObjectLiteralExpression(firstArg)) {
|
|
186
186
|
const metadata = getCommonWireMetaData(firstArg, 'Workflow', workflowName, logger);
|
|
187
|
+
if (metadata.disabled)
|
|
188
|
+
return;
|
|
187
189
|
tags = metadata.tags;
|
|
188
190
|
summary = metadata.summary;
|
|
189
191
|
description = metadata.description;
|
|
@@ -201,7 +203,7 @@ export const addWorkflow = (logger, node, checker, state) => {
|
|
|
201
203
|
}
|
|
202
204
|
// Track workflow file for wiring generation
|
|
203
205
|
if (exportedName) {
|
|
204
|
-
state.workflows.files.set(
|
|
206
|
+
state.workflows.files.set(pikkuFuncId, {
|
|
205
207
|
path: node.getSourceFile().fileName,
|
|
206
208
|
exportedName,
|
|
207
209
|
});
|
|
@@ -261,8 +263,8 @@ export const addWorkflow = (logger, node, checker, state) => {
|
|
|
261
263
|
getWorkflowInvocations(resolvedFunc, checker, state, workflowName, steps);
|
|
262
264
|
}
|
|
263
265
|
state.workflows.meta[workflowName] = {
|
|
264
|
-
|
|
265
|
-
workflowName,
|
|
266
|
+
pikkuFuncId,
|
|
267
|
+
name: workflowName,
|
|
266
268
|
steps,
|
|
267
269
|
context,
|
|
268
270
|
dsl,
|
package/dist/error-codes.d.ts
CHANGED
|
@@ -26,9 +26,12 @@ export declare enum ErrorCode {
|
|
|
26
26
|
SCHEMA_NO_ROOT = "PKU431",
|
|
27
27
|
SCHEMA_GENERATION_ERROR = "PKU456",
|
|
28
28
|
SCHEMA_LOAD_ERROR = "PKU488",
|
|
29
|
-
|
|
29
|
+
INLINE_SCHEMA = "PKU489",
|
|
30
30
|
FUNCTION_METADATA_NOT_FOUND = "PKU559",
|
|
31
31
|
HANDLER_NOT_RESOLVED = "PKU568",
|
|
32
|
+
ROUTE_PARAM_MISMATCH = "PKU571",
|
|
33
|
+
ROUTE_QUERY_MISMATCH = "PKU572",
|
|
34
|
+
AUTH_DISABLED_REQUIRES_SESSIONLESS = "PKU573",
|
|
32
35
|
MIDDLEWARE_HANDLER_INVALID = "PKU685",
|
|
33
36
|
MIDDLEWARE_TAG_INVALID = "PKU715",
|
|
34
37
|
MIDDLEWARE_EMPTY_ARRAY = "PKU736",
|
|
@@ -37,5 +40,16 @@ export declare enum ErrorCode {
|
|
|
37
40
|
PERMISSION_TAG_INVALID = "PKU836",
|
|
38
41
|
PERMISSION_EMPTY_ARRAY = "PKU937",
|
|
39
42
|
PERMISSION_PATTERN_INVALID = "PKU975",
|
|
43
|
+
DUPLICATE_FUNCTION_VERSION = "PKU850",
|
|
44
|
+
MANIFEST_MISSING = "PKU860",
|
|
45
|
+
FUNCTION_VERSION_MODIFIED = "PKU861",
|
|
46
|
+
CONTRACT_CHANGED_REQUIRES_BUMP = "PKU862",
|
|
47
|
+
VERSION_REGRESSION_OR_CONFLICT = "PKU863",
|
|
48
|
+
VERSION_GAP_NOT_ALLOWED = "PKU864",
|
|
49
|
+
MANIFEST_INTEGRITY_ERROR = "PKU865",
|
|
50
|
+
MISSING_MODEL = "PKU145",
|
|
51
|
+
INVALID_MODEL = "PKU146",
|
|
52
|
+
SERVICES_NOT_DESTRUCTURED = "PKU410",
|
|
53
|
+
WIRES_NOT_DESTRUCTURED = "PKU411",
|
|
40
54
|
WORKFLOW_MULTI_QUEUE_NOT_SUPPORTED = "PKU901"
|
|
41
55
|
}
|
package/dist/error-codes.js
CHANGED
|
@@ -29,10 +29,14 @@ export var ErrorCode;
|
|
|
29
29
|
ErrorCode["SCHEMA_NO_ROOT"] = "PKU431";
|
|
30
30
|
ErrorCode["SCHEMA_GENERATION_ERROR"] = "PKU456";
|
|
31
31
|
ErrorCode["SCHEMA_LOAD_ERROR"] = "PKU488";
|
|
32
|
-
ErrorCode["
|
|
32
|
+
ErrorCode["INLINE_SCHEMA"] = "PKU489";
|
|
33
33
|
// Function errors
|
|
34
34
|
ErrorCode["FUNCTION_METADATA_NOT_FOUND"] = "PKU559";
|
|
35
35
|
ErrorCode["HANDLER_NOT_RESOLVED"] = "PKU568";
|
|
36
|
+
// HTTP Route errors
|
|
37
|
+
ErrorCode["ROUTE_PARAM_MISMATCH"] = "PKU571";
|
|
38
|
+
ErrorCode["ROUTE_QUERY_MISMATCH"] = "PKU572";
|
|
39
|
+
ErrorCode["AUTH_DISABLED_REQUIRES_SESSIONLESS"] = "PKU573";
|
|
36
40
|
// Middleware/Permission errors
|
|
37
41
|
ErrorCode["MIDDLEWARE_HANDLER_INVALID"] = "PKU685";
|
|
38
42
|
ErrorCode["MIDDLEWARE_TAG_INVALID"] = "PKU715";
|
|
@@ -42,6 +46,21 @@ export var ErrorCode;
|
|
|
42
46
|
ErrorCode["PERMISSION_TAG_INVALID"] = "PKU836";
|
|
43
47
|
ErrorCode["PERMISSION_EMPTY_ARRAY"] = "PKU937";
|
|
44
48
|
ErrorCode["PERMISSION_PATTERN_INVALID"] = "PKU975";
|
|
49
|
+
// Versioning errors
|
|
50
|
+
ErrorCode["DUPLICATE_FUNCTION_VERSION"] = "PKU850";
|
|
51
|
+
// Contract versioning errors
|
|
52
|
+
ErrorCode["MANIFEST_MISSING"] = "PKU860";
|
|
53
|
+
ErrorCode["FUNCTION_VERSION_MODIFIED"] = "PKU861";
|
|
54
|
+
ErrorCode["CONTRACT_CHANGED_REQUIRES_BUMP"] = "PKU862";
|
|
55
|
+
ErrorCode["VERSION_REGRESSION_OR_CONFLICT"] = "PKU863";
|
|
56
|
+
ErrorCode["VERSION_GAP_NOT_ALLOWED"] = "PKU864";
|
|
57
|
+
ErrorCode["MANIFEST_INTEGRITY_ERROR"] = "PKU865";
|
|
58
|
+
// Model configuration errors
|
|
59
|
+
ErrorCode["MISSING_MODEL"] = "PKU145";
|
|
60
|
+
ErrorCode["INVALID_MODEL"] = "PKU146";
|
|
61
|
+
// Optimization diagnostics
|
|
62
|
+
ErrorCode["SERVICES_NOT_DESTRUCTURED"] = "PKU410";
|
|
63
|
+
ErrorCode["WIRES_NOT_DESTRUCTURED"] = "PKU411";
|
|
45
64
|
// Feature Flag
|
|
46
65
|
ErrorCode["WORKFLOW_MULTI_QUEUE_NOT_SUPPORTED"] = "PKU901";
|
|
47
66
|
})(ErrorCode || (ErrorCode = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { inspect, getInitialInspectorState } from './inspector.js';
|
|
2
|
-
export { getFilesAndMethods } from './utils/get-files-and-methods.js';
|
|
3
2
|
export type { TypesMap } from './types-map.js';
|
|
4
3
|
export type * from './types.js';
|
|
5
|
-
export type {
|
|
6
|
-
export type { FilesAndMethods, FilesAndMethodsErrors, } from './utils/get-files-and-methods.js';
|
|
4
|
+
export type { FilesAndMethodsErrors } from './utils/get-files-and-methods.js';
|
|
7
5
|
export { ErrorCode } from './error-codes.js';
|
|
8
6
|
export { serializeInspectorState, deserializeInspectorState, } from './utils/serialize-inspector-state.js';
|
|
9
7
|
export type { SerializableInspectorState } from './utils/serialize-inspector-state.js';
|
|
10
8
|
export { filterInspectorState } from './utils/filter-inspector-state.js';
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
9
|
+
export { generateCustomTypes, sanitizeTypeName, } from './utils/custom-types-generator.js';
|
|
10
|
+
export { createEmptyManifest, serializeManifest, } from './utils/contract-hashes.js';
|
|
11
|
+
export type { ContractEntry, VersionHashEntry, VersionValidateError, VersionManifest, VersionManifestEntry, } from './utils/contract-hashes.js';
|
|
12
|
+
export { serializeMCPJson } from './utils/serialize-mcp-json.js';
|
|
13
|
+
export type { OpenAPISpecInfo } from './utils/serialize-openapi-json.js';
|
|
14
|
+
export { deserializeDslWorkflow, deserializeGraphWorkflow, deserializeAllDslWorkflows, } from './utils/workflow/dsl/index.js';
|
|
15
|
+
export { getFilesAndMethods } from './utils/get-files-and-methods.js';
|
|
16
|
+
export type { SerializedWorkflowGraph, SerializedWorkflowGraphs, } from './utils/workflow/graph/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { inspect, getInitialInspectorState } from './inspector.js';
|
|
2
|
-
export { getFilesAndMethods } from './utils/get-files-and-methods.js';
|
|
3
2
|
export { ErrorCode } from './error-codes.js';
|
|
4
3
|
export { serializeInspectorState, deserializeInspectorState, } from './utils/serialize-inspector-state.js';
|
|
5
4
|
export { filterInspectorState } from './utils/filter-inspector-state.js';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
5
|
+
export { generateCustomTypes, sanitizeTypeName, } from './utils/custom-types-generator.js';
|
|
6
|
+
export { createEmptyManifest, serializeManifest, } from './utils/contract-hashes.js';
|
|
7
|
+
export { serializeMCPJson } from './utils/serialize-mcp-json.js';
|
|
8
|
+
export { deserializeDslWorkflow, deserializeGraphWorkflow, deserializeAllDslWorkflows, } from './utils/workflow/dsl/index.js';
|
|
9
|
+
export { getFilesAndMethods } from './utils/get-files-and-methods.js';
|
package/dist/inspector.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { InspectorState, InspectorLogger, InspectorOptions } from './types.js';
|
|
1
|
+
import type { InspectorState, InspectorLogger, InspectorOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates an initial/empty inspector state with all required properties initialized
|
|
4
4
|
* @param rootDir - The root directory for the project
|
|
5
5
|
* @returns A fresh InspectorState with empty collections
|
|
6
6
|
*/
|
|
7
7
|
export declare function getInitialInspectorState(rootDir: string): InspectorState;
|
|
8
|
-
export declare const inspect: (logger: InspectorLogger, routeFiles: string[], options?: InspectorOptions) => InspectorState
|
|
8
|
+
export declare const inspect: (logger: InspectorLogger, routeFiles: string[], options?: InspectorOptions) => Promise<InspectorState>;
|
package/dist/inspector.js
CHANGED
|
@@ -4,7 +4,14 @@ import { visitSetup, visitRoutes } from './visit.js';
|
|
|
4
4
|
import { TypesMap } from './types-map.js';
|
|
5
5
|
import { getFilesAndMethods } from './utils/get-files-and-methods.js';
|
|
6
6
|
import { findCommonAncestor } from './utils/find-root-dir.js';
|
|
7
|
-
import { aggregateRequiredServices,
|
|
7
|
+
import { aggregateRequiredServices, validateAgentModels, validateAgentOverrides, validateSecretOverrides, validateVariableOverrides, computeResolvedIOTypes, computeMiddlewareGroupsMeta, computePermissionsGroupsMeta, computeRequiredSchemas, computeDiagnostics, } from './utils/post-process.js';
|
|
8
|
+
import { generateOpenAPISpec } from './utils/serialize-openapi-json.js';
|
|
9
|
+
import { pikkuState } from '@pikku/core/internal';
|
|
10
|
+
import { resolveLatestVersions } from './utils/resolve-versions.js';
|
|
11
|
+
import { finalizeWorkflows } from './utils/workflow/graph/finalize-workflows.js';
|
|
12
|
+
import { finalizeWorkflowHelperTypes, finalizeWorkflowWires, } from './utils/workflow/graph/finalize-workflow-wires.js';
|
|
13
|
+
import { generateAllSchemas } from './utils/schema-generator.js';
|
|
14
|
+
import { computeContractHashes, extractContractsFromMeta, updateManifest, createEmptyManifest, validateContracts, } from './utils/contract-hashes.js';
|
|
8
15
|
/**
|
|
9
16
|
* Creates an initial/empty inspector state with all required properties initialized
|
|
10
17
|
* @param rootDir - The root directory for the project
|
|
@@ -24,7 +31,8 @@ export function getInitialInspectorState(rootDir) {
|
|
|
24
31
|
filesAndMethods: {},
|
|
25
32
|
filesAndMethodsErrors: new Map(),
|
|
26
33
|
typesLookup: new Map(),
|
|
27
|
-
|
|
34
|
+
schemaLookup: new Map(),
|
|
35
|
+
schemas: {},
|
|
28
36
|
functions: {
|
|
29
37
|
typesMap: new TypesMap(),
|
|
30
38
|
meta: {},
|
|
@@ -49,6 +57,11 @@ export function getInitialInspectorState(rootDir) {
|
|
|
49
57
|
files: new Set(),
|
|
50
58
|
meta: {},
|
|
51
59
|
},
|
|
60
|
+
triggers: {
|
|
61
|
+
meta: {},
|
|
62
|
+
sourceMeta: {},
|
|
63
|
+
files: new Set(),
|
|
64
|
+
},
|
|
52
65
|
scheduledTasks: {
|
|
53
66
|
meta: {},
|
|
54
67
|
files: new Set(),
|
|
@@ -62,6 +75,7 @@ export function getInitialInspectorState(rootDir) {
|
|
|
62
75
|
files: new Map(),
|
|
63
76
|
graphMeta: {},
|
|
64
77
|
graphFiles: new Map(),
|
|
78
|
+
invokedWorkflows: new Set(),
|
|
65
79
|
},
|
|
66
80
|
rpc: {
|
|
67
81
|
internalMeta: {},
|
|
@@ -69,7 +83,9 @@ export function getInitialInspectorState(rootDir) {
|
|
|
69
83
|
exposedMeta: {},
|
|
70
84
|
exposedFiles: new Map(),
|
|
71
85
|
invokedFunctions: new Set(),
|
|
72
|
-
|
|
86
|
+
usedAddons: new Set(),
|
|
87
|
+
wireAddonDeclarations: new Map(),
|
|
88
|
+
wireAddonFiles: new Set(),
|
|
73
89
|
},
|
|
74
90
|
mcpEndpoints: {
|
|
75
91
|
resourcesMeta: {},
|
|
@@ -77,6 +93,10 @@ export function getInitialInspectorState(rootDir) {
|
|
|
77
93
|
promptsMeta: {},
|
|
78
94
|
files: new Set(),
|
|
79
95
|
},
|
|
96
|
+
agents: {
|
|
97
|
+
agentsMeta: {},
|
|
98
|
+
files: new Map(),
|
|
99
|
+
},
|
|
80
100
|
cli: {
|
|
81
101
|
meta: {
|
|
82
102
|
programs: {},
|
|
@@ -84,20 +104,39 @@ export function getInitialInspectorState(rootDir) {
|
|
|
84
104
|
},
|
|
85
105
|
files: new Set(),
|
|
86
106
|
},
|
|
87
|
-
|
|
107
|
+
nodes: {
|
|
88
108
|
meta: {},
|
|
89
109
|
files: new Set(),
|
|
90
110
|
},
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
secrets: {
|
|
112
|
+
definitions: [],
|
|
113
|
+
files: new Set(),
|
|
114
|
+
},
|
|
115
|
+
variables: {
|
|
116
|
+
definitions: [],
|
|
93
117
|
files: new Set(),
|
|
94
118
|
},
|
|
119
|
+
manifest: {
|
|
120
|
+
initial: null,
|
|
121
|
+
current: null,
|
|
122
|
+
errors: [],
|
|
123
|
+
},
|
|
95
124
|
middleware: {
|
|
96
|
-
|
|
125
|
+
definitions: {},
|
|
126
|
+
instances: {},
|
|
97
127
|
tagMiddleware: new Map(),
|
|
98
128
|
},
|
|
129
|
+
channelMiddleware: {
|
|
130
|
+
definitions: {},
|
|
131
|
+
instances: {},
|
|
132
|
+
tagMiddleware: new Map(),
|
|
133
|
+
},
|
|
134
|
+
aiMiddleware: {
|
|
135
|
+
definitions: {},
|
|
136
|
+
},
|
|
99
137
|
permissions: {
|
|
100
|
-
|
|
138
|
+
definitions: {},
|
|
139
|
+
instances: {},
|
|
101
140
|
tagPermissions: new Map(),
|
|
102
141
|
},
|
|
103
142
|
serviceAggregation: {
|
|
@@ -108,17 +147,36 @@ export function getInitialInspectorState(rootDir) {
|
|
|
108
147
|
allSingletonServices: [],
|
|
109
148
|
allWireServices: [],
|
|
110
149
|
},
|
|
111
|
-
|
|
150
|
+
resolvedIOTypes: {},
|
|
151
|
+
middlewareGroupsMeta: {
|
|
152
|
+
definitions: {},
|
|
153
|
+
instances: {},
|
|
154
|
+
httpGroups: {},
|
|
155
|
+
tagGroups: {},
|
|
156
|
+
channelMiddleware: {
|
|
157
|
+
definitions: {},
|
|
158
|
+
instances: {},
|
|
159
|
+
tagGroups: {},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
permissionsGroupsMeta: {
|
|
163
|
+
definitions: {},
|
|
164
|
+
httpGroups: {},
|
|
165
|
+
tagGroups: {},
|
|
166
|
+
},
|
|
167
|
+
requiredSchemas: new Set(),
|
|
168
|
+
openAPISpec: null,
|
|
169
|
+
diagnostics: [],
|
|
112
170
|
};
|
|
113
171
|
}
|
|
114
|
-
export const inspect = (logger, routeFiles, options = {}) => {
|
|
172
|
+
export const inspect = async (logger, routeFiles, options = {}) => {
|
|
115
173
|
const startProgram = performance.now();
|
|
116
174
|
const program = ts.createProgram(routeFiles, {
|
|
117
175
|
target: ts.ScriptTarget.ESNext,
|
|
118
|
-
module: ts.ModuleKind.
|
|
176
|
+
module: ts.ModuleKind.Node16,
|
|
119
177
|
skipLibCheck: true,
|
|
120
178
|
skipDefaultLibCheck: true,
|
|
121
|
-
moduleResolution: ts.ModuleResolutionKind.
|
|
179
|
+
moduleResolution: ts.ModuleResolutionKind.Node16,
|
|
122
180
|
types: [],
|
|
123
181
|
allowJs: false,
|
|
124
182
|
checkJs: false,
|
|
@@ -150,6 +208,20 @@ export const inspect = (logger, routeFiles, options = {}) => {
|
|
|
150
208
|
ts.forEachChild(sourceFile, (child) => visitRoutes(logger, checker, child, state, options));
|
|
151
209
|
}
|
|
152
210
|
logger.debug(`Visit routes phase completed in ${(performance.now() - startRoutes).toFixed(2)}ms`);
|
|
211
|
+
resolveLatestVersions(state, logger);
|
|
212
|
+
if (options.schemaConfig) {
|
|
213
|
+
state.schemas = await generateAllSchemas(logger, options.schemaConfig, state);
|
|
214
|
+
computeContractHashes(state.schemas, state.functions.typesMap, state.functions.meta);
|
|
215
|
+
computeRequiredSchemas(state, options);
|
|
216
|
+
}
|
|
217
|
+
state.manifest.initial = options.manifest ?? null;
|
|
218
|
+
const contracts = extractContractsFromMeta(state.functions.meta);
|
|
219
|
+
const baseManifest = state.manifest.initial ?? createEmptyManifest();
|
|
220
|
+
state.manifest.current = updateManifest(baseManifest, contracts);
|
|
221
|
+
state.manifest.errors = validateContracts(baseManifest, contracts).errors;
|
|
222
|
+
finalizeWorkflows(state);
|
|
223
|
+
finalizeWorkflowHelperTypes(state);
|
|
224
|
+
finalizeWorkflowWires(state);
|
|
153
225
|
}
|
|
154
226
|
// Populate filesAndMethods
|
|
155
227
|
const startFilesAndMethods = performance.now();
|
|
@@ -161,9 +233,17 @@ export const inspect = (logger, routeFiles, options = {}) => {
|
|
|
161
233
|
const startAggregate = performance.now();
|
|
162
234
|
aggregateRequiredServices(state);
|
|
163
235
|
logger.debug(`Aggregate required services completed in ${(performance.now() - startAggregate).toFixed(2)}ms`);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
236
|
+
computeResolvedIOTypes(state);
|
|
237
|
+
computeMiddlewareGroupsMeta(state);
|
|
238
|
+
computePermissionsGroupsMeta(state);
|
|
239
|
+
computeDiagnostics(state);
|
|
240
|
+
if (options.openAPI) {
|
|
241
|
+
state.openAPISpec = await generateOpenAPISpec(logger, state.functions.meta, state.http.meta, state.schemas, options.openAPI.additionalInfo, pikkuState(null, 'misc', 'errors'));
|
|
242
|
+
}
|
|
243
|
+
validateAgentModels(logger, state, options.modelConfig);
|
|
244
|
+
validateAgentOverrides(logger, state, options.modelConfig);
|
|
245
|
+
validateSecretOverrides(logger, state);
|
|
246
|
+
validateVariableOverrides(logger, state);
|
|
167
247
|
}
|
|
168
248
|
return state;
|
|
169
249
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateAllSchemas } from './utils/schema-generator.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateAllSchemas } from './utils/schema-generator.js';
|
package/dist/types-map.js
CHANGED
|
@@ -17,7 +17,16 @@ export class TypesMap {
|
|
|
17
17
|
return meta.uniqueName;
|
|
18
18
|
}
|
|
19
19
|
getTypeMeta(name) {
|
|
20
|
-
if ([
|
|
20
|
+
if ([
|
|
21
|
+
'string',
|
|
22
|
+
'number',
|
|
23
|
+
'boolean',
|
|
24
|
+
'null',
|
|
25
|
+
'undefined',
|
|
26
|
+
'void',
|
|
27
|
+
'unknown',
|
|
28
|
+
'never',
|
|
29
|
+
].includes(name)) {
|
|
21
30
|
return {
|
|
22
31
|
originalName: name,
|
|
23
32
|
uniqueName: name,
|