mnehmos.trace.mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1662 -0
- package/dist/adapters/bootstrap.d.ts +29 -0
- package/dist/adapters/bootstrap.d.ts.map +1 -0
- package/dist/adapters/bootstrap.js +46 -0
- package/dist/adapters/bootstrap.js.map +1 -0
- package/dist/adapters/errors.d.ts +94 -0
- package/dist/adapters/errors.d.ts.map +1 -0
- package/dist/adapters/errors.js +107 -0
- package/dist/adapters/errors.js.map +1 -0
- package/dist/adapters/graphql/index.d.ts +9 -0
- package/dist/adapters/graphql/index.d.ts.map +1 -0
- package/dist/adapters/graphql/index.js +9 -0
- package/dist/adapters/graphql/index.js.map +1 -0
- package/dist/adapters/graphql/sdl-parser.d.ts +74 -0
- package/dist/adapters/graphql/sdl-parser.d.ts.map +1 -0
- package/dist/adapters/graphql/sdl-parser.js +559 -0
- package/dist/adapters/graphql/sdl-parser.js.map +1 -0
- package/dist/adapters/grpc/adapter.d.ts +76 -0
- package/dist/adapters/grpc/adapter.d.ts.map +1 -0
- package/dist/adapters/grpc/adapter.js +362 -0
- package/dist/adapters/grpc/adapter.js.map +1 -0
- package/dist/adapters/grpc/index.d.ts +10 -0
- package/dist/adapters/grpc/index.d.ts.map +1 -0
- package/dist/adapters/grpc/index.js +12 -0
- package/dist/adapters/grpc/index.js.map +1 -0
- package/dist/adapters/grpc/proto-parser.d.ts +76 -0
- package/dist/adapters/grpc/proto-parser.d.ts.map +1 -0
- package/dist/adapters/grpc/proto-parser.js +523 -0
- package/dist/adapters/grpc/proto-parser.js.map +1 -0
- package/dist/adapters/grpc/type-converter.d.ts +43 -0
- package/dist/adapters/grpc/type-converter.d.ts.map +1 -0
- package/dist/adapters/grpc/type-converter.js +270 -0
- package/dist/adapters/grpc/type-converter.js.map +1 -0
- package/dist/adapters/grpc/types.d.ts +85 -0
- package/dist/adapters/grpc/types.d.ts.map +1 -0
- package/dist/adapters/grpc/types.js +7 -0
- package/dist/adapters/grpc/types.js.map +1 -0
- package/dist/adapters/index.d.ts +39 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +50 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mcp.d.ts +23 -0
- package/dist/adapters/mcp.d.ts.map +1 -0
- package/dist/adapters/mcp.js +293 -0
- package/dist/adapters/mcp.js.map +1 -0
- package/dist/adapters/openapi/adapter.d.ts +213 -0
- package/dist/adapters/openapi/adapter.d.ts.map +1 -0
- package/dist/adapters/openapi/adapter.js +557 -0
- package/dist/adapters/openapi/adapter.js.map +1 -0
- package/dist/adapters/openapi/convert.d.ts +120 -0
- package/dist/adapters/openapi/convert.d.ts.map +1 -0
- package/dist/adapters/openapi/convert.js +363 -0
- package/dist/adapters/openapi/convert.js.map +1 -0
- package/dist/adapters/openapi/index.d.ts +39 -0
- package/dist/adapters/openapi/index.d.ts.map +1 -0
- package/dist/adapters/openapi/index.js +48 -0
- package/dist/adapters/openapi/index.js.map +1 -0
- package/dist/adapters/openapi/parser.d.ts +95 -0
- package/dist/adapters/openapi/parser.d.ts.map +1 -0
- package/dist/adapters/openapi/parser.js +171 -0
- package/dist/adapters/openapi/parser.js.map +1 -0
- package/dist/adapters/registry.d.ts +116 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +246 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/trpc/adapter.d.ts +159 -0
- package/dist/adapters/trpc/adapter.d.ts.map +1 -0
- package/dist/adapters/trpc/adapter.js +223 -0
- package/dist/adapters/trpc/adapter.js.map +1 -0
- package/dist/adapters/trpc/extractor.d.ts +218 -0
- package/dist/adapters/trpc/extractor.d.ts.map +1 -0
- package/dist/adapters/trpc/extractor.js +708 -0
- package/dist/adapters/trpc/extractor.js.map +1 -0
- package/dist/adapters/trpc/index.d.ts +31 -0
- package/dist/adapters/trpc/index.d.ts.map +1 -0
- package/dist/adapters/trpc/index.js +40 -0
- package/dist/adapters/trpc/index.js.map +1 -0
- package/dist/adapters/trpc/parser.d.ts +119 -0
- package/dist/adapters/trpc/parser.d.ts.map +1 -0
- package/dist/adapters/trpc/parser.js +128 -0
- package/dist/adapters/trpc/parser.js.map +1 -0
- package/dist/compare/index.d.ts +33 -0
- package/dist/compare/index.d.ts.map +1 -0
- package/dist/compare/index.js +261 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/core/types.d.ts +188 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +9 -0
- package/dist/core/types.js.map +1 -0
- package/dist/extract/index.d.ts +26 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +44 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +674 -0
- package/dist/index.js.map +1 -0
- package/dist/languages/base.d.ts +57 -0
- package/dist/languages/base.d.ts.map +1 -0
- package/dist/languages/base.js +6 -0
- package/dist/languages/base.js.map +1 -0
- package/dist/languages/bootstrap.d.ts +10 -0
- package/dist/languages/bootstrap.d.ts.map +1 -0
- package/dist/languages/bootstrap.js +25 -0
- package/dist/languages/bootstrap.js.map +1 -0
- package/dist/languages/go/handlers/chi.d.ts +24 -0
- package/dist/languages/go/handlers/chi.d.ts.map +1 -0
- package/dist/languages/go/handlers/chi.js +205 -0
- package/dist/languages/go/handlers/chi.js.map +1 -0
- package/dist/languages/go/handlers/gin.d.ts +24 -0
- package/dist/languages/go/handlers/gin.d.ts.map +1 -0
- package/dist/languages/go/handlers/gin.js +156 -0
- package/dist/languages/go/handlers/gin.js.map +1 -0
- package/dist/languages/go/handlers/stdlib.d.ts +19 -0
- package/dist/languages/go/handlers/stdlib.d.ts.map +1 -0
- package/dist/languages/go/handlers/stdlib.js +112 -0
- package/dist/languages/go/handlers/stdlib.js.map +1 -0
- package/dist/languages/go/index.d.ts +18 -0
- package/dist/languages/go/index.d.ts.map +1 -0
- package/dist/languages/go/index.js +20 -0
- package/dist/languages/go/index.js.map +1 -0
- package/dist/languages/go/parser.d.ts +33 -0
- package/dist/languages/go/parser.d.ts.map +1 -0
- package/dist/languages/go/parser.js +95 -0
- package/dist/languages/go/parser.js.map +1 -0
- package/dist/languages/go/struct-extractor.d.ts +59 -0
- package/dist/languages/go/struct-extractor.d.ts.map +1 -0
- package/dist/languages/go/struct-extractor.js +483 -0
- package/dist/languages/go/struct-extractor.js.map +1 -0
- package/dist/languages/go/tag-parser.d.ts +62 -0
- package/dist/languages/go/tag-parser.d.ts.map +1 -0
- package/dist/languages/go/tag-parser.js +108 -0
- package/dist/languages/go/tag-parser.js.map +1 -0
- package/dist/languages/go/type-converter.d.ts +32 -0
- package/dist/languages/go/type-converter.d.ts.map +1 -0
- package/dist/languages/go/type-converter.js +226 -0
- package/dist/languages/go/type-converter.js.map +1 -0
- package/dist/languages/go/types.d.ts +153 -0
- package/dist/languages/go/types.d.ts.map +1 -0
- package/dist/languages/go/types.js +6 -0
- package/dist/languages/go/types.js.map +1 -0
- package/dist/languages/import-resolver.d.ts +645 -0
- package/dist/languages/import-resolver.d.ts.map +1 -0
- package/dist/languages/import-resolver.js +1278 -0
- package/dist/languages/import-resolver.js.map +1 -0
- package/dist/languages/index.d.ts +34 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +93 -0
- package/dist/languages/index.js.map +1 -0
- package/dist/languages/json-schema.d.ts +40 -0
- package/dist/languages/json-schema.d.ts.map +1 -0
- package/dist/languages/json-schema.js +188 -0
- package/dist/languages/json-schema.js.map +1 -0
- package/dist/languages/python-ast/index.d.ts +8 -0
- package/dist/languages/python-ast/index.d.ts.map +1 -0
- package/dist/languages/python-ast/index.js +7 -0
- package/dist/languages/python-ast/index.js.map +1 -0
- package/dist/languages/python-ast/parser.d.ts +174 -0
- package/dist/languages/python-ast/parser.d.ts.map +1 -0
- package/dist/languages/python-ast/parser.js +1205 -0
- package/dist/languages/python-ast/parser.js.map +1 -0
- package/dist/languages/python-ast/type-resolver.d.ts +75 -0
- package/dist/languages/python-ast/type-resolver.d.ts.map +1 -0
- package/dist/languages/python-ast/type-resolver.js +421 -0
- package/dist/languages/python-ast/type-resolver.js.map +1 -0
- package/dist/languages/python-ast/types.d.ts +216 -0
- package/dist/languages/python-ast/types.d.ts.map +1 -0
- package/dist/languages/python-ast/types.js +6 -0
- package/dist/languages/python-ast/types.js.map +1 -0
- package/dist/languages/python.d.ts +55 -0
- package/dist/languages/python.d.ts.map +1 -0
- package/dist/languages/python.js +311 -0
- package/dist/languages/python.js.map +1 -0
- package/dist/languages/typescript.d.ts +272 -0
- package/dist/languages/typescript.d.ts.map +1 -0
- package/dist/languages/typescript.js +1381 -0
- package/dist/languages/typescript.js.map +1 -0
- package/dist/patterns/base.d.ts +146 -0
- package/dist/patterns/base.d.ts.map +1 -0
- package/dist/patterns/base.js +89 -0
- package/dist/patterns/base.js.map +1 -0
- package/dist/patterns/errors.d.ts +172 -0
- package/dist/patterns/errors.d.ts.map +1 -0
- package/dist/patterns/errors.js +185 -0
- package/dist/patterns/errors.js.map +1 -0
- package/dist/patterns/extractors.d.ts +170 -0
- package/dist/patterns/extractors.d.ts.map +1 -0
- package/dist/patterns/extractors.js +305 -0
- package/dist/patterns/extractors.js.map +1 -0
- package/dist/patterns/graphql/apollo-client.d.ts +80 -0
- package/dist/patterns/graphql/apollo-client.d.ts.map +1 -0
- package/dist/patterns/graphql/apollo-client.js +800 -0
- package/dist/patterns/graphql/apollo-client.js.map +1 -0
- package/dist/patterns/graphql/apollo-server.d.ts +55 -0
- package/dist/patterns/graphql/apollo-server.d.ts.map +1 -0
- package/dist/patterns/graphql/apollo-server.js +523 -0
- package/dist/patterns/graphql/apollo-server.js.map +1 -0
- package/dist/patterns/graphql/index.d.ts +11 -0
- package/dist/patterns/graphql/index.d.ts.map +1 -0
- package/dist/patterns/graphql/index.js +12 -0
- package/dist/patterns/graphql/index.js.map +1 -0
- package/dist/patterns/graphql/types.d.ts +213 -0
- package/dist/patterns/graphql/types.d.ts.map +1 -0
- package/dist/patterns/graphql/types.js +16 -0
- package/dist/patterns/graphql/types.js.map +1 -0
- package/dist/patterns/http-clients/axios.d.ts +148 -0
- package/dist/patterns/http-clients/axios.d.ts.map +1 -0
- package/dist/patterns/http-clients/axios.js +652 -0
- package/dist/patterns/http-clients/axios.js.map +1 -0
- package/dist/patterns/http-clients/fetch.d.ts +88 -0
- package/dist/patterns/http-clients/fetch.d.ts.map +1 -0
- package/dist/patterns/http-clients/fetch.js +364 -0
- package/dist/patterns/http-clients/fetch.js.map +1 -0
- package/dist/patterns/http-clients/index.d.ts +36 -0
- package/dist/patterns/http-clients/index.d.ts.map +1 -0
- package/dist/patterns/http-clients/index.js +50 -0
- package/dist/patterns/http-clients/index.js.map +1 -0
- package/dist/patterns/http-clients/property-access.d.ts +46 -0
- package/dist/patterns/http-clients/property-access.d.ts.map +1 -0
- package/dist/patterns/http-clients/property-access.js +818 -0
- package/dist/patterns/http-clients/property-access.js.map +1 -0
- package/dist/patterns/http-clients/type-inference.d.ts +48 -0
- package/dist/patterns/http-clients/type-inference.d.ts.map +1 -0
- package/dist/patterns/http-clients/type-inference.js +293 -0
- package/dist/patterns/http-clients/type-inference.js.map +1 -0
- package/dist/patterns/http-clients/types.d.ts +168 -0
- package/dist/patterns/http-clients/types.d.ts.map +1 -0
- package/dist/patterns/http-clients/types.js +10 -0
- package/dist/patterns/http-clients/types.js.map +1 -0
- package/dist/patterns/http-clients/url-extractor.d.ts +53 -0
- package/dist/patterns/http-clients/url-extractor.d.ts.map +1 -0
- package/dist/patterns/http-clients/url-extractor.js +338 -0
- package/dist/patterns/http-clients/url-extractor.js.map +1 -0
- package/dist/patterns/index.d.ts +44 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +49 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/python/aiohttp.d.ts +21 -0
- package/dist/patterns/python/aiohttp.d.ts.map +1 -0
- package/dist/patterns/python/aiohttp.js +188 -0
- package/dist/patterns/python/aiohttp.js.map +1 -0
- package/dist/patterns/python/httpx.d.ts +20 -0
- package/dist/patterns/python/httpx.d.ts.map +1 -0
- package/dist/patterns/python/httpx.js +183 -0
- package/dist/patterns/python/httpx.js.map +1 -0
- package/dist/patterns/python/index.d.ts +32 -0
- package/dist/patterns/python/index.d.ts.map +1 -0
- package/dist/patterns/python/index.js +63 -0
- package/dist/patterns/python/index.js.map +1 -0
- package/dist/patterns/python/property-access.d.ts +27 -0
- package/dist/patterns/python/property-access.d.ts.map +1 -0
- package/dist/patterns/python/property-access.js +132 -0
- package/dist/patterns/python/property-access.js.map +1 -0
- package/dist/patterns/python/requests.d.ts +19 -0
- package/dist/patterns/python/requests.d.ts.map +1 -0
- package/dist/patterns/python/requests.js +239 -0
- package/dist/patterns/python/requests.js.map +1 -0
- package/dist/patterns/python/types.d.ts +95 -0
- package/dist/patterns/python/types.d.ts.map +1 -0
- package/dist/patterns/python/types.js +43 -0
- package/dist/patterns/python/types.js.map +1 -0
- package/dist/patterns/registry.d.ts +181 -0
- package/dist/patterns/registry.d.ts.map +1 -0
- package/dist/patterns/registry.js +304 -0
- package/dist/patterns/registry.js.map +1 -0
- package/dist/patterns/rest/express.d.ts +78 -0
- package/dist/patterns/rest/express.d.ts.map +1 -0
- package/dist/patterns/rest/express.js +289 -0
- package/dist/patterns/rest/express.js.map +1 -0
- package/dist/patterns/rest/fastify.d.ts +93 -0
- package/dist/patterns/rest/fastify.d.ts.map +1 -0
- package/dist/patterns/rest/fastify.js +420 -0
- package/dist/patterns/rest/fastify.js.map +1 -0
- package/dist/patterns/rest/index.d.ts +31 -0
- package/dist/patterns/rest/index.d.ts.map +1 -0
- package/dist/patterns/rest/index.js +45 -0
- package/dist/patterns/rest/index.js.map +1 -0
- package/dist/patterns/rest/middleware.d.ts +25 -0
- package/dist/patterns/rest/middleware.d.ts.map +1 -0
- package/dist/patterns/rest/middleware.js +219 -0
- package/dist/patterns/rest/middleware.js.map +1 -0
- package/dist/patterns/rest/path-parser.d.ts +50 -0
- package/dist/patterns/rest/path-parser.d.ts.map +1 -0
- package/dist/patterns/rest/path-parser.js +137 -0
- package/dist/patterns/rest/path-parser.js.map +1 -0
- package/dist/patterns/rest/response-inference.d.ts +44 -0
- package/dist/patterns/rest/response-inference.d.ts.map +1 -0
- package/dist/patterns/rest/response-inference.js +218 -0
- package/dist/patterns/rest/response-inference.js.map +1 -0
- package/dist/patterns/rest/types.d.ts +102 -0
- package/dist/patterns/rest/types.d.ts.map +1 -0
- package/dist/patterns/rest/types.js +10 -0
- package/dist/patterns/rest/types.js.map +1 -0
- package/dist/patterns/types.d.ts +105 -0
- package/dist/patterns/types.d.ts.map +1 -0
- package/dist/patterns/types.js +11 -0
- package/dist/patterns/types.js.map +1 -0
- package/dist/report/index.d.ts +11 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +55 -0
- package/dist/report/index.js.map +1 -0
- package/dist/tools/contract-comments.d.ts +48 -0
- package/dist/tools/contract-comments.d.ts.map +1 -0
- package/dist/tools/contract-comments.js +130 -0
- package/dist/tools/contract-comments.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/scaffold.d.ts +38 -0
- package/dist/tools/scaffold.d.ts.map +1 -0
- package/dist/tools/scaffold.js +373 -0
- package/dist/tools/scaffold.js.map +1 -0
- package/dist/trace/index.d.ts +28 -0
- package/dist/trace/index.d.ts.map +1 -0
- package/dist/trace/index.js +45 -0
- package/dist/trace/index.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/dist/watch/cache.d.ts +41 -0
- package/dist/watch/cache.d.ts.map +1 -0
- package/dist/watch/cache.js +230 -0
- package/dist/watch/cache.js.map +1 -0
- package/dist/watch/index.d.ts +9 -0
- package/dist/watch/index.d.ts.map +1 -0
- package/dist/watch/index.js +7 -0
- package/dist/watch/index.js.map +1 -0
- package/dist/watch/project.d.ts +128 -0
- package/dist/watch/project.d.ts.map +1 -0
- package/dist/watch/project.js +152 -0
- package/dist/watch/project.js.map +1 -0
- package/dist/watch/watcher.d.ts +76 -0
- package/dist/watch/watcher.d.ts.map +1 -0
- package/dist/watch/watcher.js +235 -0
- package/dist/watch/watcher.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Inference
|
|
3
|
+
*
|
|
4
|
+
* Infers response schema from handler function implementations.
|
|
5
|
+
*
|
|
6
|
+
* @module patterns/rest/response-inference
|
|
7
|
+
* @see .context/ADR-P2-2-REST-DETECTION.md
|
|
8
|
+
*/
|
|
9
|
+
import { Node } from 'ts-morph';
|
|
10
|
+
/* ═══════════════════════════════════════════════════════════════════════════
|
|
11
|
+
* 🔍 Public API
|
|
12
|
+
* ═══════════════════════════════════════════════════════════════════════════ */
|
|
13
|
+
/**
|
|
14
|
+
* Infer the response schema from a handler function.
|
|
15
|
+
*
|
|
16
|
+
* Uses multiple strategies:
|
|
17
|
+
* 1. Explicit return type annotation
|
|
18
|
+
* 2. Generic type parameter on res.json<T>()
|
|
19
|
+
* 3. Analysis of res.json() argument structure
|
|
20
|
+
*
|
|
21
|
+
* @param handler - The handler function AST node
|
|
22
|
+
* @returns Response inference result with method and optional schema node
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Handler: (req, res) => res.json<ProfileResponse>({ id: '123', name: 'John' })
|
|
27
|
+
* const inference = inferResponseSchema(handler);
|
|
28
|
+
* // { method: 'generic-param', node: <ProfileResponse node> }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function inferResponseSchema(handler) {
|
|
32
|
+
if (!handler) {
|
|
33
|
+
return { method: 'unknown' };
|
|
34
|
+
}
|
|
35
|
+
// Check for explicit return type annotation
|
|
36
|
+
const returnType = getExplicitReturnType(handler);
|
|
37
|
+
if (returnType) {
|
|
38
|
+
return { method: 'explicit-return', node: returnType };
|
|
39
|
+
}
|
|
40
|
+
// Look for res.json<T>() generic parameter
|
|
41
|
+
const genericParam = findResJsonGenericParam(handler);
|
|
42
|
+
if (genericParam) {
|
|
43
|
+
return { method: 'generic-param', node: genericParam };
|
|
44
|
+
}
|
|
45
|
+
// Analyze body of res.json() calls
|
|
46
|
+
const jsonArg = findResJsonArgument(handler);
|
|
47
|
+
if (jsonArg) {
|
|
48
|
+
return { method: 'body-analysis', node: jsonArg };
|
|
49
|
+
}
|
|
50
|
+
return { method: 'unknown' };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Detect multiple response schemas by status code.
|
|
54
|
+
*
|
|
55
|
+
* @param handler - The handler function AST node
|
|
56
|
+
* @returns Map of status codes to response schema nodes
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Handler with res.status(200).json(ok) and res.status(400).json(error)
|
|
61
|
+
* const responses = detectMultipleResponses(handler);
|
|
62
|
+
* // Map { 200 => <ok node>, 400 => <error node> }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function detectMultipleResponses(handler) {
|
|
66
|
+
const responses = new Map();
|
|
67
|
+
if (!handler) {
|
|
68
|
+
return responses;
|
|
69
|
+
}
|
|
70
|
+
// Find all call expressions in the handler
|
|
71
|
+
handler.forEachDescendant(node => {
|
|
72
|
+
if (!Node.isCallExpression(node))
|
|
73
|
+
return;
|
|
74
|
+
// Check for res.status(code).json(body) or res.json(body)
|
|
75
|
+
const statusAndBody = extractStatusAndBody(node);
|
|
76
|
+
if (statusAndBody) {
|
|
77
|
+
responses.set(statusAndBody.status, statusAndBody.body);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return responses;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get explicit return type annotation from a function
|
|
84
|
+
*/
|
|
85
|
+
function getExplicitReturnType(handler) {
|
|
86
|
+
if (Node.isFunctionDeclaration(handler) ||
|
|
87
|
+
Node.isFunctionExpression(handler) ||
|
|
88
|
+
Node.isArrowFunction(handler) ||
|
|
89
|
+
Node.isMethodDeclaration(handler)) {
|
|
90
|
+
const returnTypeNode = handler.getReturnTypeNode();
|
|
91
|
+
if (returnTypeNode) {
|
|
92
|
+
return returnTypeNode;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Find res.json<T>() generic type parameter
|
|
99
|
+
*/
|
|
100
|
+
function findResJsonGenericParam(handler) {
|
|
101
|
+
let result;
|
|
102
|
+
handler.forEachDescendant(node => {
|
|
103
|
+
if (result)
|
|
104
|
+
return; // Already found
|
|
105
|
+
if (!Node.isCallExpression(node))
|
|
106
|
+
return;
|
|
107
|
+
const expression = node.getExpression();
|
|
108
|
+
if (!Node.isPropertyAccessExpression(expression))
|
|
109
|
+
return;
|
|
110
|
+
const methodName = expression.getName();
|
|
111
|
+
if (methodName !== 'json')
|
|
112
|
+
return;
|
|
113
|
+
// Check if caller is 'res' or a chain containing 'res'
|
|
114
|
+
if (!isResponseObject(expression.getExpression()))
|
|
115
|
+
return;
|
|
116
|
+
// Check for generic type argument
|
|
117
|
+
const typeArgs = node.getTypeArguments();
|
|
118
|
+
if (typeArgs.length > 0) {
|
|
119
|
+
result = typeArgs[0];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Find the argument passed to res.json()
|
|
126
|
+
*/
|
|
127
|
+
function findResJsonArgument(handler) {
|
|
128
|
+
let result;
|
|
129
|
+
handler.forEachDescendant(node => {
|
|
130
|
+
if (result)
|
|
131
|
+
return; // Already found
|
|
132
|
+
if (!Node.isCallExpression(node))
|
|
133
|
+
return;
|
|
134
|
+
const expression = node.getExpression();
|
|
135
|
+
if (!Node.isPropertyAccessExpression(expression))
|
|
136
|
+
return;
|
|
137
|
+
const methodName = expression.getName();
|
|
138
|
+
if (methodName !== 'json' && methodName !== 'send')
|
|
139
|
+
return;
|
|
140
|
+
// Check if caller is 'res' or a chain containing 'res'
|
|
141
|
+
if (!isResponseObject(expression.getExpression()))
|
|
142
|
+
return;
|
|
143
|
+
// Get the first argument
|
|
144
|
+
const args = node.getArguments();
|
|
145
|
+
if (args.length > 0) {
|
|
146
|
+
result = args[0];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Extract status code and body from a response chain
|
|
153
|
+
* Handles: res.status(200).json(body), res.json(body), res.sendStatus(200)
|
|
154
|
+
*/
|
|
155
|
+
function extractStatusAndBody(call) {
|
|
156
|
+
const expression = call.getExpression();
|
|
157
|
+
if (!Node.isPropertyAccessExpression(expression))
|
|
158
|
+
return undefined;
|
|
159
|
+
const methodName = expression.getName();
|
|
160
|
+
const calleeExpr = expression.getExpression();
|
|
161
|
+
// Case: res.json(body) - default 200
|
|
162
|
+
if ((methodName === 'json' || methodName === 'send') && isResponseObject(calleeExpr)) {
|
|
163
|
+
const args = call.getArguments();
|
|
164
|
+
if (args.length > 0) {
|
|
165
|
+
return { status: 200, body: args[0] };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Case: res.status(code).json(body)
|
|
169
|
+
if (methodName === 'json' || methodName === 'send') {
|
|
170
|
+
// Check if callee is a status() call
|
|
171
|
+
if (Node.isCallExpression(calleeExpr)) {
|
|
172
|
+
const statusExpr = calleeExpr.getExpression();
|
|
173
|
+
if (Node.isPropertyAccessExpression(statusExpr) &&
|
|
174
|
+
(statusExpr.getName() === 'status' || statusExpr.getName() === 'code')) {
|
|
175
|
+
const statusArgs = calleeExpr.getArguments();
|
|
176
|
+
if (statusArgs.length > 0) {
|
|
177
|
+
const statusValue = getNumericValue(statusArgs[0]);
|
|
178
|
+
const bodyArgs = call.getArguments();
|
|
179
|
+
if (statusValue !== undefined && bodyArgs.length > 0) {
|
|
180
|
+
return { status: statusValue, body: bodyArgs[0] };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Check if an expression is likely the response object ('res', 'reply')
|
|
190
|
+
*/
|
|
191
|
+
function isResponseObject(expr) {
|
|
192
|
+
if (Node.isIdentifier(expr)) {
|
|
193
|
+
const name = expr.getText();
|
|
194
|
+
return name === 'res' || name === 'reply' || name === 'response';
|
|
195
|
+
}
|
|
196
|
+
// Could be a chain like res.status(200)
|
|
197
|
+
if (Node.isCallExpression(expr)) {
|
|
198
|
+
const callExpr = expr.getExpression();
|
|
199
|
+
if (Node.isPropertyAccessExpression(callExpr)) {
|
|
200
|
+
return isResponseObject(callExpr.getExpression());
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (Node.isPropertyAccessExpression(expr)) {
|
|
204
|
+
return isResponseObject(expr.getExpression());
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Extract numeric value from a literal or identifier
|
|
210
|
+
*/
|
|
211
|
+
function getNumericValue(node) {
|
|
212
|
+
if (Node.isNumericLiteral(node)) {
|
|
213
|
+
return parseInt(node.getText(), 10);
|
|
214
|
+
}
|
|
215
|
+
// Could be a constant reference, but we'd need to resolve it
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=response-inference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-inference.js","sourceRoot":"","sources":["../../../src/patterns/rest/response-inference.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAA8B,MAAM,UAAU,CAAC;AAI5D;;iFAEiF;AAEj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AAgB,CAAC,IAAU;IAClC,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,UAAU,CAAC;IACnE,CAAC;IAED,wCAAwC;IACxC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACtC,IAAI,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9C,OAAO,gBAAgB,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,OAAO,gBAAgB,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,IAAU;IACjC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,6DAA6D;IAC7D,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST Pattern Matcher Types
|
|
3
|
+
*
|
|
4
|
+
* Types for Express and Fastify REST endpoint detection.
|
|
5
|
+
*
|
|
6
|
+
* @module patterns/rest/types
|
|
7
|
+
* @see .context/ADR-P2-2-REST-DETECTION.md
|
|
8
|
+
*/
|
|
9
|
+
import type { Node } from 'ts-morph';
|
|
10
|
+
import type { MatchCaptures } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* HTTP methods supported by REST frameworks
|
|
13
|
+
*/
|
|
14
|
+
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'ALL';
|
|
15
|
+
/**
|
|
16
|
+
* Path parameter extracted from route paths
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* For path `/users/:id(\\d+)?`:
|
|
20
|
+
* ```typescript
|
|
21
|
+
* {
|
|
22
|
+
* name: 'id',
|
|
23
|
+
* position: 1,
|
|
24
|
+
* optional: true,
|
|
25
|
+
* pattern: '\\d+',
|
|
26
|
+
* inferredType: 'number'
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface PathParameter {
|
|
31
|
+
/** Parameter name (without leading :) */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Position in path segments (0-indexed) */
|
|
34
|
+
position: number;
|
|
35
|
+
/** Whether parameter is optional (:id?) */
|
|
36
|
+
optional: boolean;
|
|
37
|
+
/** Regex constraint if present (:id(\\d+)) */
|
|
38
|
+
pattern?: string;
|
|
39
|
+
/** Type inferred from pattern or default to string */
|
|
40
|
+
inferredType: 'string' | 'number' | 'any';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validation middleware detected in route
|
|
44
|
+
*/
|
|
45
|
+
export interface ValidationMiddleware {
|
|
46
|
+
/** Validation library used */
|
|
47
|
+
library: 'zod' | 'joi' | 'celebrate' | 'express-validator' | 'yup' | 'unknown';
|
|
48
|
+
/** What is being validated */
|
|
49
|
+
target: 'body' | 'query' | 'params' | 'headers';
|
|
50
|
+
/** AST node containing the schema */
|
|
51
|
+
schemaNode: Node;
|
|
52
|
+
/** Position in middleware chain */
|
|
53
|
+
middlewareIndex?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fastify schema definition extracted from route options
|
|
57
|
+
*/
|
|
58
|
+
export interface FastifySchemas {
|
|
59
|
+
/** Body schema (for POST, PUT, PATCH) */
|
|
60
|
+
body?: Node;
|
|
61
|
+
/** Query string schema */
|
|
62
|
+
querystring?: Node;
|
|
63
|
+
/** Path params schema */
|
|
64
|
+
params?: Node;
|
|
65
|
+
/** Headers schema */
|
|
66
|
+
headers?: Node;
|
|
67
|
+
/** Response schemas by status code */
|
|
68
|
+
response?: Map<number, Node>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extended captures for REST pattern matches
|
|
72
|
+
*/
|
|
73
|
+
export interface RESTMatchCaptures extends MatchCaptures {
|
|
74
|
+
/** HTTP method for this route */
|
|
75
|
+
httpMethod: HTTPMethod;
|
|
76
|
+
/** Route path (e.g., '/users/:id') */
|
|
77
|
+
routePath: string;
|
|
78
|
+
/** Parsed path parameters */
|
|
79
|
+
pathParameters: PathParameter[];
|
|
80
|
+
/** Router/app instance name (e.g., 'app', 'router', 'userRouter') */
|
|
81
|
+
routerName?: string;
|
|
82
|
+
/** Detected validation middleware */
|
|
83
|
+
validationMiddleware?: ValidationMiddleware[];
|
|
84
|
+
/** The handler function node */
|
|
85
|
+
handlerNode?: Node;
|
|
86
|
+
/** Fastify-specific schemas */
|
|
87
|
+
schemas?: FastifySchemas;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Schema format detected in Fastify routes
|
|
91
|
+
*/
|
|
92
|
+
export type SchemaFormat = 'json-schema' | 'typebox' | 'zod' | 'unknown';
|
|
93
|
+
/**
|
|
94
|
+
* Response inference result
|
|
95
|
+
*/
|
|
96
|
+
export interface ResponseInference {
|
|
97
|
+
/** How the schema was inferred */
|
|
98
|
+
method: 'explicit-return' | 'generic-param' | 'body-analysis' | 'unknown';
|
|
99
|
+
/** The AST node containing the response type (if found) */
|
|
100
|
+
node?: Node;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns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AC,MAAM,EAAE,IAAI,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,iCAAiC;IACjC,UAAU,EAAE,UAAU,CAAC;IAEvB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAElB,6BAA6B;IAC7B,cAAc,EAAE,aAAa,EAAE,CAAC;IAEhC,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAE9C,gCAAgC;IAChC,WAAW,CAAC,EAAE,IAAI,CAAC;IAEnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,MAAM,EAAE,iBAAiB,GAAG,eAAe,GAAG,eAAe,GAAG,SAAS,CAAC;IAE1E,2DAA2D;IAC3D,IAAI,CAAC,EAAE,IAAI,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patterns/rest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Matcher Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the pattern matcher abstraction that enables pluggable
|
|
5
|
+
* framework-agnostic API detection.
|
|
6
|
+
*
|
|
7
|
+
* @module patterns/types
|
|
8
|
+
* @see .context/ADR-P2-1-PATTERN-MATCHER.md
|
|
9
|
+
*/
|
|
10
|
+
import type { Node } from 'ts-morph';
|
|
11
|
+
import type { SourceLocation } from '../core/types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Types of AST patterns that can be matched
|
|
14
|
+
*/
|
|
15
|
+
export type PatternType = 'call' | 'decorator' | 'property' | 'export' | 'chain';
|
|
16
|
+
/**
|
|
17
|
+
* Where to find the schema in the matched pattern
|
|
18
|
+
*/
|
|
19
|
+
export type SchemaLocation = {
|
|
20
|
+
type: 'arg';
|
|
21
|
+
index: number;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'arg-named';
|
|
24
|
+
name: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'return';
|
|
27
|
+
} | {
|
|
28
|
+
type: 'type-param';
|
|
29
|
+
index: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'body';
|
|
32
|
+
} | {
|
|
33
|
+
type: 'chain-method';
|
|
34
|
+
method: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'decorator-arg';
|
|
37
|
+
index: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Definition of a single matchable pattern
|
|
41
|
+
*/
|
|
42
|
+
export interface PatternDef {
|
|
43
|
+
/** Pattern type identifier */
|
|
44
|
+
readonly type: PatternType;
|
|
45
|
+
/**
|
|
46
|
+
* Signature to match against
|
|
47
|
+
* - String: exact method/decorator name (e.g., 'get', 'Get')
|
|
48
|
+
* - RegExp: pattern match (e.g., /^(get|post|put|delete)$/i)
|
|
49
|
+
*/
|
|
50
|
+
readonly signature: string | RegExp;
|
|
51
|
+
/**
|
|
52
|
+
* Optional: Object path prefix (e.g., 'app', 'router', 'server')
|
|
53
|
+
* For method calls, matches the receiver object
|
|
54
|
+
*/
|
|
55
|
+
readonly receiver?: string | RegExp;
|
|
56
|
+
/**
|
|
57
|
+
* Where to extract the input schema from
|
|
58
|
+
*/
|
|
59
|
+
readonly inputSchemaLocation?: SchemaLocation;
|
|
60
|
+
/**
|
|
61
|
+
* Where to extract the output schema from
|
|
62
|
+
*/
|
|
63
|
+
readonly outputSchemaLocation?: SchemaLocation;
|
|
64
|
+
/**
|
|
65
|
+
* Optional: Additional validation predicates
|
|
66
|
+
*/
|
|
67
|
+
readonly validate?: (node: Node) => boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Data captured during pattern matching
|
|
71
|
+
*/
|
|
72
|
+
export interface MatchCaptures {
|
|
73
|
+
/** HTTP method for REST endpoints */
|
|
74
|
+
httpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'ALL';
|
|
75
|
+
/** Route path for REST endpoints */
|
|
76
|
+
routePath?: string;
|
|
77
|
+
/** Procedure type for tRPC */
|
|
78
|
+
procedureType?: 'query' | 'mutation' | 'subscription';
|
|
79
|
+
/** Description from JSDoc or argument */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Input schema AST node (for extraction) */
|
|
82
|
+
inputSchemaNode?: Node;
|
|
83
|
+
/** Output schema AST node (for extraction) */
|
|
84
|
+
outputSchemaNode?: Node;
|
|
85
|
+
/** Additional framework-specific captures */
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Result of a successful pattern match
|
|
90
|
+
*/
|
|
91
|
+
export interface MatchResult {
|
|
92
|
+
/** The pattern that matched */
|
|
93
|
+
readonly pattern: PatternDef;
|
|
94
|
+
/** The AST node that was matched */
|
|
95
|
+
readonly node: Node;
|
|
96
|
+
/** Framework that produced this match */
|
|
97
|
+
readonly framework: string;
|
|
98
|
+
/** Extracted identifier (tool name, route path, etc.) */
|
|
99
|
+
readonly identifier: string;
|
|
100
|
+
/** Source location for error reporting */
|
|
101
|
+
readonly location: SourceLocation;
|
|
102
|
+
/** Captured data from the match */
|
|
103
|
+
readonly captures: MatchCaptures;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/patterns/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,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,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;IAEtF,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;IAEtD,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,IAAI,CAAC;IAEvB,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,IAAI,CAAC;IAExB,6CAA6C;IAC7C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAElC,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;CAClC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Matcher Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the pattern matcher abstraction that enables pluggable
|
|
5
|
+
* framework-agnostic API detection.
|
|
6
|
+
*
|
|
7
|
+
* @module patterns/types
|
|
8
|
+
* @see .context/ADR-P2-1-PATTERN-MATCHER.md
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/patterns/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace MCP - Reporter (Stub)
|
|
3
|
+
* Formats TraceResult into various output formats
|
|
4
|
+
*/
|
|
5
|
+
import type { TraceResult } from '../types.js';
|
|
6
|
+
export type OutputFormat = 'json' | 'markdown' | 'summary';
|
|
7
|
+
/**
|
|
8
|
+
* Format trace results for output
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatResult(result: TraceResult, format?: OutputFormat): string;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAE3D;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,YAAqB,GAC5B,MAAM,CAcR"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace MCP - Reporter (Stub)
|
|
3
|
+
* Formats TraceResult into various output formats
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Format trace results for output
|
|
7
|
+
*/
|
|
8
|
+
export function formatResult(result, format = 'json') {
|
|
9
|
+
switch (format) {
|
|
10
|
+
case 'json':
|
|
11
|
+
return JSON.stringify(result, null, 2);
|
|
12
|
+
case 'markdown':
|
|
13
|
+
return formatMarkdown(result);
|
|
14
|
+
case 'summary':
|
|
15
|
+
return formatSummary(result);
|
|
16
|
+
default:
|
|
17
|
+
return JSON.stringify(result, null, 2);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function formatMarkdown(result) {
|
|
21
|
+
const lines = [
|
|
22
|
+
'# Trace MCP Analysis Report',
|
|
23
|
+
'',
|
|
24
|
+
`**Generated**: ${result.timestamp}`,
|
|
25
|
+
'',
|
|
26
|
+
'## Summary',
|
|
27
|
+
'',
|
|
28
|
+
`| Metric | Count |`,
|
|
29
|
+
`|--------|-------|`,
|
|
30
|
+
`| Total Tools | ${result.summary.totalTools} |`,
|
|
31
|
+
`| Total Calls | ${result.summary.totalCalls} |`,
|
|
32
|
+
`| Matches | ${result.summary.matchCount} |`,
|
|
33
|
+
`| Mismatches | ${result.summary.mismatchCount} |`,
|
|
34
|
+
'',
|
|
35
|
+
];
|
|
36
|
+
if (result.mismatches.length > 0) {
|
|
37
|
+
lines.push('## Mismatches', '');
|
|
38
|
+
for (const m of result.mismatches) {
|
|
39
|
+
lines.push(`### ${m.toolName}`);
|
|
40
|
+
lines.push(`- **Type**: ${m.issueType}`);
|
|
41
|
+
lines.push(`- **Description**: ${m.description}`);
|
|
42
|
+
lines.push(`- **Consumer**: ${m.consumerLocation.file}:${m.consumerLocation.line}`);
|
|
43
|
+
if (m.producerLocation) {
|
|
44
|
+
lines.push(`- **Producer**: ${m.producerLocation.file}:${m.producerLocation.line}`);
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return lines.join('\n');
|
|
50
|
+
}
|
|
51
|
+
function formatSummary(result) {
|
|
52
|
+
const status = result.mismatches.length === 0 ? '✅ PASS' : '❌ FAIL';
|
|
53
|
+
return `${status} - ${result.summary.matchCount} matches, ${result.summary.mismatchCount} mismatches`;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmB,EACnB,SAAuB,MAAM;IAE7B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,I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C;YACpF,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACtF,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,aAAa,CAAC,MAAmB;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACpE,OAAO,GAAG,MAAM,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,aAAa,MAAM,CAAC,OAAO,CAAC,aAAa,aAAa,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Comments Tool
|
|
3
|
+
* Adds cross-reference comments to producer and consumer code
|
|
4
|
+
* when a contract is validated as working.
|
|
5
|
+
*/
|
|
6
|
+
import type { ProducerSchema, ConsumerSchema, Match } from '../types.js';
|
|
7
|
+
export interface ContractCommentOptions {
|
|
8
|
+
/** The validated match to document */
|
|
9
|
+
match: Match;
|
|
10
|
+
/** Producer schema details */
|
|
11
|
+
producer: ProducerSchema;
|
|
12
|
+
/** Consumer schema details */
|
|
13
|
+
consumer: ConsumerSchema;
|
|
14
|
+
/** Comment style */
|
|
15
|
+
style?: 'jsdoc' | 'inline' | 'block';
|
|
16
|
+
/** Include timestamp */
|
|
17
|
+
includeTimestamp?: boolean;
|
|
18
|
+
/** Custom prefix for comments */
|
|
19
|
+
prefix?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CommentResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
producerFile: string;
|
|
24
|
+
consumerFile: string;
|
|
25
|
+
producerComment: string;
|
|
26
|
+
consumerComment: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate cross-reference comments for a validated contract
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateContractComments(options: ContractCommentOptions): {
|
|
33
|
+
producerComment: string;
|
|
34
|
+
consumerComment: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Add contract comments to source files
|
|
38
|
+
* WARNING: This modifies files! Use with caution.
|
|
39
|
+
*/
|
|
40
|
+
export declare function addContractComments(options: ContractCommentOptions): Promise<CommentResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Preview what comments would be added without modifying files
|
|
43
|
+
*/
|
|
44
|
+
export declare function previewContractComments(options: ContractCommentOptions): {
|
|
45
|
+
producerPreview: string;
|
|
46
|
+
consumerPreview: string;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=contract-comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-comments.d.ts","sourceRoot":"","sources":["../../src/tools/contract-comments.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAC;IACb,8BAA8B;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,8BAA8B;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,oBAAoB;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CA+BA;AAmBD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CA+CjG;AAuBD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,sBAAsB,GAAG;IACxE,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAQA"}
|