@webpieces/api-doc-model 0.4.932 → 0.4.934
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/package.json +2 -2
- package/src/extract/ApiDocExtractor.js +1 -1
- package/src/extract/ApiDocExtractor.js.map +1 -1
- package/src/extract/JsDoc.d.ts +17 -1
- package/src/extract/JsDoc.js +32 -3
- package/src/extract/JsDoc.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +13 -1
- package/src/model/ApiDocModel.js +9 -1
- package/src/model/ApiDocModel.js.map +1 -1
- package/src/render/McpSchemaRenderer.d.ts +10 -0
- package/src/render/McpSchemaRenderer.js +20 -3
- package/src/render/McpSchemaRenderer.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/api-doc-model",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.934",
|
|
4
4
|
"description": "TypeScript-compiler-API extractor producing one in-memory ApiDocModel from a webpieces API contract. No renderer, no runtime, no app-specific import.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
26
|
+
"@webpieces/core-util": "0.4.934",
|
|
27
27
|
"typescript": "5.9.3",
|
|
28
28
|
"minimatch": "10.0.1"
|
|
29
29
|
}
|
|
@@ -299,7 +299,7 @@ class ApiDocExtractor {
|
|
|
299
299
|
const doc = resolver.readDoc(member);
|
|
300
300
|
const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);
|
|
301
301
|
const streaming = new StreamingSignature_1.StreamingSignature().read(member, folder, resolver);
|
|
302
|
-
return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.mcp, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming, ApiDocExtractor.decoratorCall(member, core_util_1.WpLocalOnly.name) !== undefined);
|
|
302
|
+
return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.mcp, doc.returns, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming, ApiDocExtractor.decoratorCall(member, core_util_1.WpLocalOnly.name) !== undefined);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
* One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,sDAAmD;AACnD,+CAA4C;AAC5C,uDAAiC;AACjC,oDAqB8B;AAC9B,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C,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACrE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAC7B,CAAC;gBACC,OAAO,QAAQ,CAAC,WAAW,CAAC;YAChC,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,aAAa,CACxB,IAAa,EACb,aAAqB;QAErB,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC;YAClC,IACI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,aAAa,EACtE,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAnqBD,0CAmqBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport { McpProfiles } from './McpProfiles';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL,\n GET,\n MaskLog,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n WpAuthPublic,\n WpAuth, WpAuthorization, WpLocalOnly, apiKey,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ContextKeyHeaderFolder, ContextKeyHeaderSlot } from './ContextKeyHeaderFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\nimport { StreamingSignature } from './StreamingSignature';\n\n/**\n * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as\n * string literals.\n *\n * ## Why `.name` and not `'Endpoint'`\n *\n * The extractor matches decorators by NAME on the syntax — it must, because it reads a contract with\n * the compiler and never executes it. The question is only where that name comes from, and a literal\n * has a silent failure mode that a symbol does not: rename `@WpMcpTool` in `core-util` and a literal\n * simply stops matching. The extractor then finds zero MCP tools, the MCP document is correctly not\n * written because it has no tools in it, and the BUILD IS GREEN. A partner-facing document silently\n * loses a section with nothing red anywhere (issue #1001).\n *\n * `Endpoint.name` makes that rename a COMPILE ERROR here, which in this repo is the delivery\n * mechanism for a migration rather than an obstacle to one: a compile break names the new spelling\n * and an agent applies it in one pass, where a green build teaches nobody anything.\n *\n * ## Why importing `@webpieces/core-util` is not the coupling it looks like\n *\n * Any contract carrying `@Endpoint` already depends on `core-util` by definition, so there is no\n * upstream project this import could shut out. It is build-time only, it creates no cycle, and it\n * costs a browser bundle nothing because nothing in a bundle imports this package. The direction that\n * WOULD be fatal is `core-util` depending on the TypeScript compiler, and that is not this.\n */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MASK_LOG = MaskLog.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\nconst AUTHORIZATION = WpAuthorization.name;\nconst API_KEY_AUTH = apiKey.name;\nconst API_TYPE = ApiType.name;\n\n/**\n * The prefix shared by every credential decorator. A PREFIX genuinely has no symbol to take a name\n * from, so it stays a literal — but the set it selects is pinned below, which is what stops it\n * quietly matching nothing.\n */\n/** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */\nconst ENDPOINT_KINDS: readonly string[] = [RPC, CLOUDTASKS, CRON, EXTERNAL];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = [GET, POST];\n\n/** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */\nconst ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];\n\n/** The allowed values of each required position, in the same order, for the same failure. */\nconst ARGUMENT_VALUES: readonly (readonly string[])[] = [\n HTTP_METHODS,\n [],\n ENDPOINT_OPERATIONS,\n ENDPOINT_KINDS,\n];\n\n/** The REAL document types, so a contract cannot name a document that does not exist. */\nconst API_TYPES: readonly string[] = [SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP];\n\n/** The fail-closed default: a contract that declares nothing feeds only the internal document. */\nconst DEFAULT_API_TYPES: readonly string[] = [SVC_TO_SVC];\n\n/**\n * ONE contract file -> ONE {@link ApiDocModel}. The single extraction pass both the OpenAPI documents\n * and the MCP tool list (#982) are rendered from.\n *\n * ## Why the compiler API at all\n *\n * A DTO field's TYPE IS ERASED AT RUNTIME. Reflection can see that `save` takes one argument; it\n * cannot see that the argument has a `deliveryWindow` that is a discriminated union of two shapes,\n * one of which carries an ISO timestamp. Those are precisely the shapes a partner-grade document is\n * made of, so the only place they exist is the source, and the only honest way to read the source is\n * the compiler.\n *\n * ## Why it IMPORTS `@webpieces/core-util`\n *\n * Decorators are matched BY NAME on the syntax — they must be, because this reads a contract and\n * never executes it. The NAMES come from the real symbols (`Endpoint.name`), so a rename in\n * `core-util` is a compile error here instead of a literal that quietly stops matching. The full\n * argument, and why the import is not the coupling it looks like, is at those constants.\n *\n * ## What it does NOT do\n *\n * It emits nothing. No OpenAPI, no MCP tool definitions, no file — that is #982, and keeping the\n * render out means the two renderers cannot drift apart about what the contract SAYS.\n */\nexport class ApiDocExtractor {\n constructor(private readonly schemaNames: SchemaNames = new SchemaNames([])) {}\n /** Which package declares each file — the owner of every schema (#1058). Cached per directory. */\n private readonly packages = new PackageOfFile();\n /** A resolver whose HOME is the package declaring `source` — see {@link TypeResolver}. */\n private resolverFor(program: ts.Program, source: ts.SourceFile): TypeResolver {\n const home = this.packages.of(source.fileName)?.name;\n return new TypeResolver(program.getTypeChecker(), this.packages, home, this.schemaNames);\n }\n\n /**\n * Extract the contract in `entryFile`.\n *\n * @param entryFile absolute path to the `.ts` file holding the `@ApiPath` class.\n * @param compilerOptions handed straight to `ts.createProgram`; the caller owns them because\n * only the caller knows its own `paths` / `lib` setup.\n * @throws ApiDocExtractionError when the file holds no `@ApiPath` class, or when something that\n * must be exact (a path constant, a numeric bound) cannot be established.\n */\n extractFile(entryFile: string, compilerOptions: ts.CompilerOptions = {}): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extract(program, source);\n }\n\n /**\n * EVERY `@ApiPath` contract in one file, in declaration order.\n *\n * {@link extractFile} answers \"what is THE contract in this file\", which is the shape a manifest\n * entry and a generated document have: one contract, one file. This answers a different question\n * — \"what does this file declare\" — and it exists because a REPO does not obey that convention.\n * `McpRemoteFixtures.ts` in `@webpieces/mcp-server` declares seven contracts, and the runtime\n * registers MCP tools from all seven; a sweep that read only the first would report green while\n * six contracts' worth of tools had never been looked at, which is the exact shape of silent miss\n * this epic exists to remove.\n *\n * A file with no contract yields an EMPTY list rather than throwing: \"this file has none\" is an\n * ordinary answer to this question, where it is a failure to answer {@link extractFile}'s.\n */\n extractAll(\n entryFile: string,\n compilerOptions: ts.CompilerOptions = {},\n ): readonly ApiDocModel[] {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extractAllFrom(program, source);\n }\n\n /** {@link extractAll} against a program the caller already built. */\n extractAllFrom(program: ts.Program, source: ts.SourceFile): readonly ApiDocModel[] {\n // Binding establishes AST parent links used by canonical import resolution.\n program.getTypeChecker();\n const models: ApiDocModel[] = [];\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n models.push(this.extractContract(program, statement));\n }\n }\n return models;\n }\n\n /** The same extraction against a program the caller already built. */\n extract(program: ts.Program, source: ts.SourceFile): ApiDocModel {\n program.getTypeChecker();\n return this.extractContract(program, this.findContract(source));\n }\n\n /** ONE contract class -> ONE model. The single place the walk actually happens. */\n private extractContract(program: ts.Program, contract: ts.ClassDeclaration): ApiDocModel {\n const checker = program.getTypeChecker();\n const folder = new ConstantFolder(checker);\n const resolver = this.resolverFor(program, contract.getSourceFile());\n\n const pathDecorator = ApiDocExtractor.decoratorCall(contract, API_PATH)!;\n const basePathArgument = pathDecorator.arguments[0];\n const basePath =\n basePathArgument === undefined\n ? ''\n : folder.foldString(basePathArgument, '@ApiPath argument');\n\n const apiTypes = this.declaredApiTypes(contract, folder);\n const endpoints: DocumentedEndpoint[] = [];\n for (const member of contract.members) {\n const endpoint = this.endpointOf(member, folder, resolver);\n if (endpoint !== undefined) {\n endpoints.push(endpoint);\n }\n }\n assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints);\n\n return new ApiDocModel(\n contract.name?.text ?? '<anonymous>',\n apiTypes,\n basePath,\n resolver.readDoc(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * Extract ONE named type and everything it reaches, from a file that holds NO contract.\n *\n * This exists for a type nothing in a contract points at but a document still publishes — the\n * document-wide error body a renderer's manifest names. Reading it with the SAME resolver is the\n * point: a second reader would be a second answer to \"what shape is this type\", and the two\n * would drift the first time a field changed.\n *\n * @throws ApiDocExtractionError when the file does not declare that name.\n */\n extractType(\n entryFile: string,\n typeName: string,\n compilerOptions: ts.CompilerOptions = {},\n ): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const resolver = this.resolverFor(program, source);\n const declaration = ApiDocExtractor.declarationNamed(source, typeName);\n if (declaration === undefined) {\n throw new ApiDocExtractionError(\n `no type named '${typeName}' is declared in this file`,\n entryFile,\n `Declare and export '${typeName}' there, or name the file that does.`,\n );\n }\n resolver.resolveDeclaration(typeName, declaration, typeName);\n return new ApiDocModel(\n typeName,\n DEFAULT_API_TYPES,\n '',\n '',\n [],\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * The header name an EXPORTED ContextKey rides under — what a manifest's response header names\n * instead of a string (#1249). `exportPath` is the export's name, or a dotted path into one\n * (`OneTabletKey.TX_ID`, a class's `static readonly` or an object's property).\n *\n * @throws ApiDocExtractionError naming the export when it is missing or cannot be followed to a\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` call declaring that header.\n */\n extractContextKeyHeader(\n entryFile: string,\n exportPath: string,\n slot: ContextKeyHeaderSlot,\n compilerOptions: ts.CompilerOptions = {},\n ): string {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const checker = program.getTypeChecker();\n const symbol = this.exportedMember(checker, source, exportPath);\n if (symbol === undefined) {\n throw new ApiDocExtractionError(\n `'${exportPath}' is not exported by this file`,\n entryFile,\n `Export the ContextKey there — e.g. \\`export const ${exportPath.split('.')[0]} = MyKeys.SOME_KEY;\\` — ` +\n 'or name the file that does.',\n );\n }\n return new ContextKeyHeaderFolder(new ConstantFolder(checker)).foldSymbol(\n symbol,\n exportPath,\n entryFile,\n slot,\n 'the manifest response header',\n );\n }\n\n /** `A` or `A.B.C`: the export `A`, then each property of its value in turn. */\n private exportedMember(\n checker: ts.TypeChecker,\n source: ts.SourceFile,\n exportPath: string,\n ): ts.Symbol | undefined {\n const moduleSymbol = checker.getSymbolAtLocation(source);\n if (moduleSymbol === undefined) {\n return undefined;\n }\n const segments = exportPath.split('.');\n let symbol: ts.Symbol | undefined = checker\n .getExportsOfModule(moduleSymbol)\n .find((exported: ts.Symbol) => exported.name === segments[0]);\n for (const segment of segments.slice(1)) {\n if (symbol === undefined) {\n return undefined;\n }\n const unaliased =\n (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;\n symbol = checker.getTypeOfSymbolAtLocation(unaliased, source).getProperty(segment);\n }\n return symbol;\n }\n\n /** A DTO library's exported types, for its components document (#1058). */\n extractComponents(\n entryFiles: readonly string[],\n compilerOptions: ts.CompilerOptions = {},\n ): ApiComponentsModel {\n return new ComponentsExtractor(this.packages, this.schemaNames).extract(entryFiles, compilerOptions);\n }\n\n /** The interface / class / type alias / enum declared under `name` at the file's top level. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static declarationNamed(\n source: ts.SourceFile,\n name: string,\n ): ts.Declaration | undefined {\n for (const statement of source.statements) {\n const named =\n ts.isInterfaceDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement);\n if (named && statement.name?.text === name) {\n return statement;\n }\n }\n return undefined;\n }\n\n /** The one `@ApiPath` class in the file. Zero is a hard failure; the FIRST wins if there are two. */\n private findContract(source: ts.SourceFile): ts.ClassDeclaration {\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n return statement;\n }\n }\n throw new ApiDocExtractionError(\n 'no @ApiPath class in this file',\n source.fileName,\n 'Point the extractor at the contract file — the one whose class carries @ApiPath.',\n );\n }\n\n /** One `@Endpoint` method. Members without the decorator are not part of the contract. */\n private endpointOf(\n member: ts.ClassElement,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedEndpoint | undefined {\n if (!ts.isMethodDeclaration(member) || !ts.isIdentifier(member.name)) {\n return undefined;\n }\n const call = ApiDocExtractor.decoratorCall(member, ENDPOINT);\n if (call === undefined) {\n return undefined;\n }\n const methodName = member.name.text;\n\n // `@Endpoint(httpMethod, path, operation, kind, options?)` — METHOD-FIRST, five positions.\n // The positions are read here and nowhere else, so the one place that has to change when the\n // decorator changes is this block plus `ARGUMENT_NAMES` beside it.\n const httpMethod = this.requiredArgument(call, methodName, 0, folder);\n const path = this.requiredArgument(call, methodName, 1, folder);\n const operation = this.requiredArgument(call, methodName, 2, folder);\n const kind = this.requiredArgument(call, methodName, 3, folder);\n\n const options = call.arguments[4];\n const literal =\n options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;\n\n const doc = resolver.readDoc(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\n const streaming = new StreamingSignature().read(member, folder, resolver);\n return new DocumentedEndpoint(\n methodName,\n httpMethod,\n path,\n operation,\n kind,\n ApiDocExtractor.booleanProperty(literal, 'hidden'),\n ApiDocExtractor.booleanProperty(literal, 'openWorld'),\n new DocumentedEndpointOptions(\n ApiDocExtractor.booleanProperty(literal, 'formPost'),\n ApiDocExtractor.stringProperty(literal, 'calledBy', folder),\n ApiDocExtractor.stringProperty(literal, 'callerKind', folder),\n ),\n ApiDocExtractor.authOf(member, folder),\n mcpTool,\n ApiDocExtractor.invalidForMcpOf(member, folder),\n ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.mcp,\n this.requestOf(member, methodName, resolver),\n streaming?.initialResponse ?? this.responseOf(member, methodName, resolver),\n streaming,\n ApiDocExtractor.decoratorCall(member, WpLocalOnly.name) !== undefined,\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters[0];\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** The declared return type, unwrapped from `Promise<...>` by the resolver. */\n private responseOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n if (member.type === undefined) {\n return undefined;\n }\n return resolver.resolve(member.type, `${methodName}.response`);\n }\n\n /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const publicCall = this.decoratorCall(member, WpAuthPublic.name);\n if (publicCall) {\n const reason = publicCall.arguments[0];\n if (!reason) throw new ApiDocExtractionError('Public authentication requires a reason', SourceLocation.of(publicCall), \"Declare @WpAuthPublic('reason').\");\n return new DocumentedAuth(folder.foldString(reason, 'public auth reason'), []);\n }\n const protectedCall = this.decoratorCall(member, WpAuth.name);\n if (!protectedCall) return undefined;\n const array = protectedCall.arguments[0];\n if (!array || !ts.isArrayLiteralExpression(array) || !array.elements.length) throw new ApiDocExtractionError('WpAuth requires a nonempty descriptor array', SourceLocation.of(protectedCall), 'Use @WpAuth([jwt(), oidcSameProject()]).');\n const methods: DocumentedAuthMethod[] = [];\n for (const element of array.elements) {\n if (!ts.isCallExpression(element)) throw new ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation.of(element), 'Use canonical credential descriptors.');\n const name = this.canonicalCallName(element.expression);\n const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');\n methods.push(new DocumentedAuthMethod(kind, element.arguments.map((argument: ts.Expression) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));\n }\n return new DocumentedAuth(undefined, methods);\n }\n\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static canonicalCallName(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const module = statement.moduleSpecifier.text;\n if (!['@webpieces/core-util', '@webpieces/http-routing', '@webpieces/http-client-browser'].includes(module) && !module.endsWith('/core-util/src/http/decorators') && !module.endsWith('/core-util/src/http/auth-mode') && !module.endsWith('/core-util/src/http/authorization')) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find((entry: ts.ImportSpecifier) => entry.name.text === expression.text);\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text) return expression.name.text;\n }\n return undefined;\n }\n\n /**\n * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.\n *\n * A malformed declaration FAILS rather than yielding a half-parsed regime: the credentials are\n * what a published document's security block is made of, and a document that silently omitted\n * one would tell a partner they need fewer credentials than the running hook demands.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static apiKeyOf(call: ts.CallExpression, folder: ConstantFolder): DocumentedApiKey {\n const regimeArgument = call.arguments[0];\n const credentialsArgument = call.arguments[1];\n if (regimeArgument === undefined || credentialsArgument === undefined) {\n throw new ApiDocExtractionError(\n 'apiKey(...) needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: apiKey('partner', [{ in: 'header', key: MyKeys.API_KEY }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, 'apiKey(...) regime');\n // FOLLOW a name first: a credential list shared by every method of a contract is written\n // once as a `const` and named per method, which is better source than a copy per method.\n const credentialsLiteral = folder.follow(credentialsArgument);\n if (!ts.isArrayLiteralExpression(credentialsLiteral)) {\n throw new ApiDocExtractionError(\n 'apiKey(...) credentials is not an array literal',\n SourceLocation.of(credentialsArgument),\n 'Write the credentials as an array literal, inline or in a `const`; a value ' +\n 'assembled at runtime cannot appear in a published security scheme.',\n );\n }\n const credentials: DocumentedApiKeyCredential[] = [];\n for (const element of credentialsLiteral.elements) {\n credentials.push(ApiDocExtractor.credentialOf(element, folder));\n }\n return new DocumentedApiKey(regime, credentials);\n }\n\n /** ONE `{ in: …, name?: …, description?: … }` credential. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static credentialOf(\n expression: ts.Expression,\n folder: ConstantFolder,\n ): DocumentedApiKeyCredential {\n const element = folder.follow(expression);\n if (!ts.isObjectLiteralExpression(element)) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', key: MyKeys.API_KEY }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with its ContextKey, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.headerOf(element, location, folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * A header credential's wire name, read off the ContextKey its `key` names (#1249) — never a\n * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static headerOf(\n element: ts.ObjectLiteralExpression,\n location: string,\n folder: ConstantFolder,\n ): string | undefined {\n if (location !== 'header') {\n return undefined;\n }\n const key = ApiDocExtractor.findProperty(element, 'key');\n if (key === undefined) {\n throw new ApiDocExtractionError(\n \"a header apiKey(...) credential names no ContextKey in 'key'\",\n SourceLocation.of(element),\n \"Name the ContextKey carrying it: { in: 'header', key: MyKeys.API_KEY }. The header-name \" +\n 'string spelling (`name:`) is deleted; the key is the one definition of the header.',\n );\n }\n return new ContextKeyHeaderFolder(folder).fold(\n key,\n ContextKeyHeaderSlot.REQUEST,\n \"the apiKey(...) header credential's key\",\n );\n }\n\n /**\n * `@WpMcpTool('search_stores', 'Search stores')` — the stable protocol name and the REQUIRED\n * human-readable title (#1180), the two facts the source cannot otherwise state. A title that\n * does not fold to a string is read as the empty string, which the MCP renderer refuses.\n *\n * Profile membership is read from the optional third argument (#1187). Otherwise, the method's JSDoc\n * is the description for the agent and the partner alike, the three side-effect hints are computed\n * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See\n * {@link DocumentedMcpTool}.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static mcpToolOf(\n member: ts.Node,\n folder: ConstantFolder,\n ): DocumentedMcpTool | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n const titleArgument = call?.arguments[1];\n const title = titleArgument === undefined ? '' : (folder.tryFoldString(titleArgument) ?? '');\n return new DocumentedMcpTool(folder.tryFoldString(argument) ?? '', title, new McpProfiles().read(call?.arguments[2], folder));\n }\n\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.\n *\n * A reason that will not fold is read as the EMPTY STRING rather than as \"no decorator\": the\n * method is still permanently outside MCP, and losing that fact because the argument was written\n * as a cross-module constant would silently put the endpoint back in the candidate set.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static invalidForMcpOf(member: ts.Node, folder: ConstantFolder): string | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_INVALID);\n if (call === undefined) {\n return undefined;\n }\n const argument = call.arguments[0];\n return argument === undefined ? '' : (folder.tryFoldString(argument) ?? '');\n }\n\n /** `@MaskLog({ refreshToken: 'full' })` -> field name -> mask mode. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static maskLogOf(member: ts.Node): ReadonlyMap<string, string> {\n const fields = new Map<string, string>();\n const argument = ApiDocExtractor.decoratorCall(member, MASK_LOG)?.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) {\n return fields;\n }\n for (const property of argument.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n ts.isStringLiteralLike(property.initializer)\n ) {\n fields.set(property.name.text, property.initializer.text);\n }\n }\n return fields;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static booleanProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n ): boolean {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value?.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static stringProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n folder: ConstantFolder,\n ): string | undefined {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value === undefined ? undefined : folder.tryFoldString(value);\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static findProperty(\n literal: ts.ObjectLiteralExpression,\n name: string,\n ): ts.Expression | undefined {\n for (const property of literal.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === name\n ) {\n return property.initializer;\n }\n }\n return undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ApiDocExtractor.canonicalCallName(call.expression) === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,sDAAmD;AACnD,+CAA4C;AAC5C,uDAAiC;AACjC,oDAqB8B;AAC9B,sDAU8B;AAE9B,mEAAgE;AAChE,qDAAkD;AAClD,qEAAwF;AACxF,qDAAkD;AAClD,mDAA+D;AAC/D,+DAA4D;AAC5D,mDAAgD;AAChD,iDAA8C;AAC9C,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,oBAAQ,CAAC,IAAI,CAAC;AAC/B,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAChC,MAAM,WAAW,GAAG,iCAAqB,CAAC,IAAI,CAAC;AAC/C,MAAM,aAAa,GAAG,2BAAe,CAAC,IAAI,CAAC;AAC3C,MAAM,YAAY,GAAG,kBAAM,CAAC,IAAI,CAAC;AACjC,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAE9B;;;;GAIG;AACH,sGAAsG;AACtG,MAAM,cAAc,GAAsB,CAAC,eAAG,EAAE,sBAAU,EAAE,gBA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BAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,aAAa,EACtE,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AApqBD,0CAoqBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport { McpProfiles } from './McpProfiles';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL,\n GET,\n MaskLog,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n WpAuthPublic,\n WpAuth, WpAuthorization, WpLocalOnly, apiKey,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ContextKeyHeaderFolder, ContextKeyHeaderSlot } from './ContextKeyHeaderFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\nimport { StreamingSignature } from './StreamingSignature';\n\n/**\n * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as\n * string literals.\n *\n * ## Why `.name` and not `'Endpoint'`\n *\n * The extractor matches decorators by NAME on the syntax — it must, because it reads a contract with\n * the compiler and never executes it. The question is only where that name comes from, and a literal\n * has a silent failure mode that a symbol does not: rename `@WpMcpTool` in `core-util` and a literal\n * simply stops matching. The extractor then finds zero MCP tools, the MCP document is correctly not\n * written because it has no tools in it, and the BUILD IS GREEN. A partner-facing document silently\n * loses a section with nothing red anywhere (issue #1001).\n *\n * `Endpoint.name` makes that rename a COMPILE ERROR here, which in this repo is the delivery\n * mechanism for a migration rather than an obstacle to one: a compile break names the new spelling\n * and an agent applies it in one pass, where a green build teaches nobody anything.\n *\n * ## Why importing `@webpieces/core-util` is not the coupling it looks like\n *\n * Any contract carrying `@Endpoint` already depends on `core-util` by definition, so there is no\n * upstream project this import could shut out. It is build-time only, it creates no cycle, and it\n * costs a browser bundle nothing because nothing in a bundle imports this package. The direction that\n * WOULD be fatal is `core-util` depending on the TypeScript compiler, and that is not this.\n */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MASK_LOG = MaskLog.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\nconst AUTHORIZATION = WpAuthorization.name;\nconst API_KEY_AUTH = apiKey.name;\nconst API_TYPE = ApiType.name;\n\n/**\n * The prefix shared by every credential decorator. A PREFIX genuinely has no symbol to take a name\n * from, so it stays a literal — but the set it selects is pinned below, which is what stops it\n * quietly matching nothing.\n */\n/** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */\nconst ENDPOINT_KINDS: readonly string[] = [RPC, CLOUDTASKS, CRON, EXTERNAL];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = [GET, POST];\n\n/** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */\nconst ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];\n\n/** The allowed values of each required position, in the same order, for the same failure. */\nconst ARGUMENT_VALUES: readonly (readonly string[])[] = [\n HTTP_METHODS,\n [],\n ENDPOINT_OPERATIONS,\n ENDPOINT_KINDS,\n];\n\n/** The REAL document types, so a contract cannot name a document that does not exist. */\nconst API_TYPES: readonly string[] = [SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP];\n\n/** The fail-closed default: a contract that declares nothing feeds only the internal document. */\nconst DEFAULT_API_TYPES: readonly string[] = [SVC_TO_SVC];\n\n/**\n * ONE contract file -> ONE {@link ApiDocModel}. The single extraction pass both the OpenAPI documents\n * and the MCP tool list (#982) are rendered from.\n *\n * ## Why the compiler API at all\n *\n * A DTO field's TYPE IS ERASED AT RUNTIME. Reflection can see that `save` takes one argument; it\n * cannot see that the argument has a `deliveryWindow` that is a discriminated union of two shapes,\n * one of which carries an ISO timestamp. Those are precisely the shapes a partner-grade document is\n * made of, so the only place they exist is the source, and the only honest way to read the source is\n * the compiler.\n *\n * ## Why it IMPORTS `@webpieces/core-util`\n *\n * Decorators are matched BY NAME on the syntax — they must be, because this reads a contract and\n * never executes it. The NAMES come from the real symbols (`Endpoint.name`), so a rename in\n * `core-util` is a compile error here instead of a literal that quietly stops matching. The full\n * argument, and why the import is not the coupling it looks like, is at those constants.\n *\n * ## What it does NOT do\n *\n * It emits nothing. No OpenAPI, no MCP tool definitions, no file — that is #982, and keeping the\n * render out means the two renderers cannot drift apart about what the contract SAYS.\n */\nexport class ApiDocExtractor {\n constructor(private readonly schemaNames: SchemaNames = new SchemaNames([])) {}\n /** Which package declares each file — the owner of every schema (#1058). Cached per directory. */\n private readonly packages = new PackageOfFile();\n /** A resolver whose HOME is the package declaring `source` — see {@link TypeResolver}. */\n private resolverFor(program: ts.Program, source: ts.SourceFile): TypeResolver {\n const home = this.packages.of(source.fileName)?.name;\n return new TypeResolver(program.getTypeChecker(), this.packages, home, this.schemaNames);\n }\n\n /**\n * Extract the contract in `entryFile`.\n *\n * @param entryFile absolute path to the `.ts` file holding the `@ApiPath` class.\n * @param compilerOptions handed straight to `ts.createProgram`; the caller owns them because\n * only the caller knows its own `paths` / `lib` setup.\n * @throws ApiDocExtractionError when the file holds no `@ApiPath` class, or when something that\n * must be exact (a path constant, a numeric bound) cannot be established.\n */\n extractFile(entryFile: string, compilerOptions: ts.CompilerOptions = {}): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extract(program, source);\n }\n\n /**\n * EVERY `@ApiPath` contract in one file, in declaration order.\n *\n * {@link extractFile} answers \"what is THE contract in this file\", which is the shape a manifest\n * entry and a generated document have: one contract, one file. This answers a different question\n * — \"what does this file declare\" — and it exists because a REPO does not obey that convention.\n * `McpRemoteFixtures.ts` in `@webpieces/mcp-server` declares seven contracts, and the runtime\n * registers MCP tools from all seven; a sweep that read only the first would report green while\n * six contracts' worth of tools had never been looked at, which is the exact shape of silent miss\n * this epic exists to remove.\n *\n * A file with no contract yields an EMPTY list rather than throwing: \"this file has none\" is an\n * ordinary answer to this question, where it is a failure to answer {@link extractFile}'s.\n */\n extractAll(\n entryFile: string,\n compilerOptions: ts.CompilerOptions = {},\n ): readonly ApiDocModel[] {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extractAllFrom(program, source);\n }\n\n /** {@link extractAll} against a program the caller already built. */\n extractAllFrom(program: ts.Program, source: ts.SourceFile): readonly ApiDocModel[] {\n // Binding establishes AST parent links used by canonical import resolution.\n program.getTypeChecker();\n const models: ApiDocModel[] = [];\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n models.push(this.extractContract(program, statement));\n }\n }\n return models;\n }\n\n /** The same extraction against a program the caller already built. */\n extract(program: ts.Program, source: ts.SourceFile): ApiDocModel {\n program.getTypeChecker();\n return this.extractContract(program, this.findContract(source));\n }\n\n /** ONE contract class -> ONE model. The single place the walk actually happens. */\n private extractContract(program: ts.Program, contract: ts.ClassDeclaration): ApiDocModel {\n const checker = program.getTypeChecker();\n const folder = new ConstantFolder(checker);\n const resolver = this.resolverFor(program, contract.getSourceFile());\n\n const pathDecorator = ApiDocExtractor.decoratorCall(contract, API_PATH)!;\n const basePathArgument = pathDecorator.arguments[0];\n const basePath =\n basePathArgument === undefined\n ? ''\n : folder.foldString(basePathArgument, '@ApiPath argument');\n\n const apiTypes = this.declaredApiTypes(contract, folder);\n const endpoints: DocumentedEndpoint[] = [];\n for (const member of contract.members) {\n const endpoint = this.endpointOf(member, folder, resolver);\n if (endpoint !== undefined) {\n endpoints.push(endpoint);\n }\n }\n assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints);\n\n return new ApiDocModel(\n contract.name?.text ?? '<anonymous>',\n apiTypes,\n basePath,\n resolver.readDoc(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * Extract ONE named type and everything it reaches, from a file that holds NO contract.\n *\n * This exists for a type nothing in a contract points at but a document still publishes — the\n * document-wide error body a renderer's manifest names. Reading it with the SAME resolver is the\n * point: a second reader would be a second answer to \"what shape is this type\", and the two\n * would drift the first time a field changed.\n *\n * @throws ApiDocExtractionError when the file does not declare that name.\n */\n extractType(\n entryFile: string,\n typeName: string,\n compilerOptions: ts.CompilerOptions = {},\n ): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const resolver = this.resolverFor(program, source);\n const declaration = ApiDocExtractor.declarationNamed(source, typeName);\n if (declaration === undefined) {\n throw new ApiDocExtractionError(\n `no type named '${typeName}' is declared in this file`,\n entryFile,\n `Declare and export '${typeName}' there, or name the file that does.`,\n );\n }\n resolver.resolveDeclaration(typeName, declaration, typeName);\n return new ApiDocModel(\n typeName,\n DEFAULT_API_TYPES,\n '',\n '',\n [],\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * The header name an EXPORTED ContextKey rides under — what a manifest's response header names\n * instead of a string (#1249). `exportPath` is the export's name, or a dotted path into one\n * (`OneTabletKey.TX_ID`, a class's `static readonly` or an object's property).\n *\n * @throws ApiDocExtractionError naming the export when it is missing or cannot be followed to a\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` call declaring that header.\n */\n extractContextKeyHeader(\n entryFile: string,\n exportPath: string,\n slot: ContextKeyHeaderSlot,\n compilerOptions: ts.CompilerOptions = {},\n ): string {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const checker = program.getTypeChecker();\n const symbol = this.exportedMember(checker, source, exportPath);\n if (symbol === undefined) {\n throw new ApiDocExtractionError(\n `'${exportPath}' is not exported by this file`,\n entryFile,\n `Export the ContextKey there — e.g. \\`export const ${exportPath.split('.')[0]} = MyKeys.SOME_KEY;\\` — ` +\n 'or name the file that does.',\n );\n }\n return new ContextKeyHeaderFolder(new ConstantFolder(checker)).foldSymbol(\n symbol,\n exportPath,\n entryFile,\n slot,\n 'the manifest response header',\n );\n }\n\n /** `A` or `A.B.C`: the export `A`, then each property of its value in turn. */\n private exportedMember(\n checker: ts.TypeChecker,\n source: ts.SourceFile,\n exportPath: string,\n ): ts.Symbol | undefined {\n const moduleSymbol = checker.getSymbolAtLocation(source);\n if (moduleSymbol === undefined) {\n return undefined;\n }\n const segments = exportPath.split('.');\n let symbol: ts.Symbol | undefined = checker\n .getExportsOfModule(moduleSymbol)\n .find((exported: ts.Symbol) => exported.name === segments[0]);\n for (const segment of segments.slice(1)) {\n if (symbol === undefined) {\n return undefined;\n }\n const unaliased =\n (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;\n symbol = checker.getTypeOfSymbolAtLocation(unaliased, source).getProperty(segment);\n }\n return symbol;\n }\n\n /** A DTO library's exported types, for its components document (#1058). */\n extractComponents(\n entryFiles: readonly string[],\n compilerOptions: ts.CompilerOptions = {},\n ): ApiComponentsModel {\n return new ComponentsExtractor(this.packages, this.schemaNames).extract(entryFiles, compilerOptions);\n }\n\n /** The interface / class / type alias / enum declared under `name` at the file's top level. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static declarationNamed(\n source: ts.SourceFile,\n name: string,\n ): ts.Declaration | undefined {\n for (const statement of source.statements) {\n const named =\n ts.isInterfaceDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement);\n if (named && statement.name?.text === name) {\n return statement;\n }\n }\n return undefined;\n }\n\n /** The one `@ApiPath` class in the file. Zero is a hard failure; the FIRST wins if there are two. */\n private findContract(source: ts.SourceFile): ts.ClassDeclaration {\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n return statement;\n }\n }\n throw new ApiDocExtractionError(\n 'no @ApiPath class in this file',\n source.fileName,\n 'Point the extractor at the contract file — the one whose class carries @ApiPath.',\n );\n }\n\n /** One `@Endpoint` method. Members without the decorator are not part of the contract. */\n private endpointOf(\n member: ts.ClassElement,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedEndpoint | undefined {\n if (!ts.isMethodDeclaration(member) || !ts.isIdentifier(member.name)) {\n return undefined;\n }\n const call = ApiDocExtractor.decoratorCall(member, ENDPOINT);\n if (call === undefined) {\n return undefined;\n }\n const methodName = member.name.text;\n\n // `@Endpoint(httpMethod, path, operation, kind, options?)` — METHOD-FIRST, five positions.\n // The positions are read here and nowhere else, so the one place that has to change when the\n // decorator changes is this block plus `ARGUMENT_NAMES` beside it.\n const httpMethod = this.requiredArgument(call, methodName, 0, folder);\n const path = this.requiredArgument(call, methodName, 1, folder);\n const operation = this.requiredArgument(call, methodName, 2, folder);\n const kind = this.requiredArgument(call, methodName, 3, folder);\n\n const options = call.arguments[4];\n const literal =\n options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;\n\n const doc = resolver.readDoc(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\n const streaming = new StreamingSignature().read(member, folder, resolver);\n return new DocumentedEndpoint(\n methodName,\n httpMethod,\n path,\n operation,\n kind,\n ApiDocExtractor.booleanProperty(literal, 'hidden'),\n ApiDocExtractor.booleanProperty(literal, 'openWorld'),\n new DocumentedEndpointOptions(\n ApiDocExtractor.booleanProperty(literal, 'formPost'),\n ApiDocExtractor.stringProperty(literal, 'calledBy', folder),\n ApiDocExtractor.stringProperty(literal, 'callerKind', folder),\n ),\n ApiDocExtractor.authOf(member, folder),\n mcpTool,\n ApiDocExtractor.invalidForMcpOf(member, folder),\n ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.mcp,\n doc.returns,\n this.requestOf(member, methodName, resolver),\n streaming?.initialResponse ?? this.responseOf(member, methodName, resolver),\n streaming,\n ApiDocExtractor.decoratorCall(member, WpLocalOnly.name) !== undefined,\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters[0];\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** The declared return type, unwrapped from `Promise<...>` by the resolver. */\n private responseOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n if (member.type === undefined) {\n return undefined;\n }\n return resolver.resolve(member.type, `${methodName}.response`);\n }\n\n /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const publicCall = this.decoratorCall(member, WpAuthPublic.name);\n if (publicCall) {\n const reason = publicCall.arguments[0];\n if (!reason) throw new ApiDocExtractionError('Public authentication requires a reason', SourceLocation.of(publicCall), \"Declare @WpAuthPublic('reason').\");\n return new DocumentedAuth(folder.foldString(reason, 'public auth reason'), []);\n }\n const protectedCall = this.decoratorCall(member, WpAuth.name);\n if (!protectedCall) return undefined;\n const array = protectedCall.arguments[0];\n if (!array || !ts.isArrayLiteralExpression(array) || !array.elements.length) throw new ApiDocExtractionError('WpAuth requires a nonempty descriptor array', SourceLocation.of(protectedCall), 'Use @WpAuth([jwt(), oidcSameProject()]).');\n const methods: DocumentedAuthMethod[] = [];\n for (const element of array.elements) {\n if (!ts.isCallExpression(element)) throw new ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation.of(element), 'Use canonical credential descriptors.');\n const name = this.canonicalCallName(element.expression);\n const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');\n methods.push(new DocumentedAuthMethod(kind, element.arguments.map((argument: ts.Expression) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));\n }\n return new DocumentedAuth(undefined, methods);\n }\n\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static canonicalCallName(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const module = statement.moduleSpecifier.text;\n if (!['@webpieces/core-util', '@webpieces/http-routing', '@webpieces/http-client-browser'].includes(module) && !module.endsWith('/core-util/src/http/decorators') && !module.endsWith('/core-util/src/http/auth-mode') && !module.endsWith('/core-util/src/http/authorization')) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find((entry: ts.ImportSpecifier) => entry.name.text === expression.text);\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text) return expression.name.text;\n }\n return undefined;\n }\n\n /**\n * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.\n *\n * A malformed declaration FAILS rather than yielding a half-parsed regime: the credentials are\n * what a published document's security block is made of, and a document that silently omitted\n * one would tell a partner they need fewer credentials than the running hook demands.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static apiKeyOf(call: ts.CallExpression, folder: ConstantFolder): DocumentedApiKey {\n const regimeArgument = call.arguments[0];\n const credentialsArgument = call.arguments[1];\n if (regimeArgument === undefined || credentialsArgument === undefined) {\n throw new ApiDocExtractionError(\n 'apiKey(...) needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: apiKey('partner', [{ in: 'header', key: MyKeys.API_KEY }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, 'apiKey(...) regime');\n // FOLLOW a name first: a credential list shared by every method of a contract is written\n // once as a `const` and named per method, which is better source than a copy per method.\n const credentialsLiteral = folder.follow(credentialsArgument);\n if (!ts.isArrayLiteralExpression(credentialsLiteral)) {\n throw new ApiDocExtractionError(\n 'apiKey(...) credentials is not an array literal',\n SourceLocation.of(credentialsArgument),\n 'Write the credentials as an array literal, inline or in a `const`; a value ' +\n 'assembled at runtime cannot appear in a published security scheme.',\n );\n }\n const credentials: DocumentedApiKeyCredential[] = [];\n for (const element of credentialsLiteral.elements) {\n credentials.push(ApiDocExtractor.credentialOf(element, folder));\n }\n return new DocumentedApiKey(regime, credentials);\n }\n\n /** ONE `{ in: …, name?: …, description?: … }` credential. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static credentialOf(\n expression: ts.Expression,\n folder: ConstantFolder,\n ): DocumentedApiKeyCredential {\n const element = folder.follow(expression);\n if (!ts.isObjectLiteralExpression(element)) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', key: MyKeys.API_KEY }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with its ContextKey, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.headerOf(element, location, folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * A header credential's wire name, read off the ContextKey its `key` names (#1249) — never a\n * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static headerOf(\n element: ts.ObjectLiteralExpression,\n location: string,\n folder: ConstantFolder,\n ): string | undefined {\n if (location !== 'header') {\n return undefined;\n }\n const key = ApiDocExtractor.findProperty(element, 'key');\n if (key === undefined) {\n throw new ApiDocExtractionError(\n \"a header apiKey(...) credential names no ContextKey in 'key'\",\n SourceLocation.of(element),\n \"Name the ContextKey carrying it: { in: 'header', key: MyKeys.API_KEY }. The header-name \" +\n 'string spelling (`name:`) is deleted; the key is the one definition of the header.',\n );\n }\n return new ContextKeyHeaderFolder(folder).fold(\n key,\n ContextKeyHeaderSlot.REQUEST,\n \"the apiKey(...) header credential's key\",\n );\n }\n\n /**\n * `@WpMcpTool('search_stores', 'Search stores')` — the stable protocol name and the REQUIRED\n * human-readable title (#1180), the two facts the source cannot otherwise state. A title that\n * does not fold to a string is read as the empty string, which the MCP renderer refuses.\n *\n * Profile membership is read from the optional third argument (#1187). Otherwise, the method's JSDoc\n * is the description for the agent and the partner alike, the three side-effect hints are computed\n * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See\n * {@link DocumentedMcpTool}.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static mcpToolOf(\n member: ts.Node,\n folder: ConstantFolder,\n ): DocumentedMcpTool | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n const titleArgument = call?.arguments[1];\n const title = titleArgument === undefined ? '' : (folder.tryFoldString(titleArgument) ?? '');\n return new DocumentedMcpTool(folder.tryFoldString(argument) ?? '', title, new McpProfiles().read(call?.arguments[2], folder));\n }\n\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.\n *\n * A reason that will not fold is read as the EMPTY STRING rather than as \"no decorator\": the\n * method is still permanently outside MCP, and losing that fact because the argument was written\n * as a cross-module constant would silently put the endpoint back in the candidate set.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static invalidForMcpOf(member: ts.Node, folder: ConstantFolder): string | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_INVALID);\n if (call === undefined) {\n return undefined;\n }\n const argument = call.arguments[0];\n return argument === undefined ? '' : (folder.tryFoldString(argument) ?? '');\n }\n\n /** `@MaskLog({ refreshToken: 'full' })` -> field name -> mask mode. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static maskLogOf(member: ts.Node): ReadonlyMap<string, string> {\n const fields = new Map<string, string>();\n const argument = ApiDocExtractor.decoratorCall(member, MASK_LOG)?.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) {\n return fields;\n }\n for (const property of argument.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n ts.isStringLiteralLike(property.initializer)\n ) {\n fields.set(property.name.text, property.initializer.text);\n }\n }\n return fields;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static booleanProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n ): boolean {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value?.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static stringProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n folder: ConstantFolder,\n ): string | undefined {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value === undefined ? undefined : folder.tryFoldString(value);\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static findProperty(\n literal: ts.ObjectLiteralExpression,\n name: string,\n ): ts.Expression | undefined {\n for (const property of literal.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === name\n ) {\n return property.initializer;\n }\n }\n return undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ApiDocExtractor.canonicalCallName(call.expression) === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
|
package/src/extract/JsDoc.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import { StackedJsDoc } from '../model/ApiDocModel';
|
|
3
3
|
/**
|
|
4
|
-
* The PROSE half of the model: the JSDoc body, the `@format` tag and the `@mcp`
|
|
4
|
+
* The PROSE half of the model: the JSDoc body, the `@returns` tag, the `@format` tag and the `@mcp`
|
|
5
|
+
* override.
|
|
6
|
+
*
|
|
7
|
+
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
8
|
+
*
|
|
9
|
+
* The body and the four tags named here are the ONLY text read out of a block. Every other block tag
|
|
10
|
+
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
11
|
+
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
12
|
+
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
13
|
+
* renderer can ever reach it — the same reason `{@link}` is flattened here (below). `//` and `/* *\/`
|
|
14
|
+
* comments are private by construction: the compiler attaches no JSDoc for them.
|
|
5
15
|
*
|
|
6
16
|
* `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the
|
|
7
17
|
* point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI
|
|
@@ -11,6 +21,12 @@ import { StackedJsDoc } from '../model/ApiDocModel';
|
|
|
11
21
|
export declare class JsDoc {
|
|
12
22
|
/** The body text, links flattened, trimmed. Empty string when undocumented. */
|
|
13
23
|
readonly description: string;
|
|
24
|
+
/**
|
|
25
|
+
* The `@returns` block tag's text — what a method's success response carries, published as
|
|
26
|
+
* that response's `description` (#1292). Undefined when the author wrote none (or wrote the
|
|
27
|
+
* tag with no text), which an OpenAPI renderer refuses for an operation with a body.
|
|
28
|
+
*/
|
|
29
|
+
readonly returns: string | undefined;
|
|
14
30
|
/** The `@format` block tag's text, e.g. `email` / `date-time`. */
|
|
15
31
|
readonly format: string | undefined;
|
|
16
32
|
/**
|
package/src/extract/JsDoc.js
CHANGED
|
@@ -6,7 +6,22 @@ const ts = tslib_1.__importStar(require("typescript"));
|
|
|
6
6
|
const ApiDocModel_1 = require("../model/ApiDocModel");
|
|
7
7
|
const SourceLocation_1 = require("./SourceLocation");
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one
|
|
10
|
+
* spelling per fact, and a refusal naming `@returns` is how an author finds out.
|
|
11
|
+
*/
|
|
12
|
+
const RETURNS_TAG = 'returns';
|
|
13
|
+
/**
|
|
14
|
+
* The PROSE half of the model: the JSDoc body, the `@returns` tag, the `@format` tag and the `@mcp`
|
|
15
|
+
* override.
|
|
16
|
+
*
|
|
17
|
+
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
18
|
+
*
|
|
19
|
+
* The body and the four tags named here are the ONLY text read out of a block. Every other block tag
|
|
20
|
+
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
21
|
+
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
22
|
+
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
23
|
+
* renderer can ever reach it — the same reason `{@link}` is flattened here (below). `//` and `/* *\/`
|
|
24
|
+
* comments are private by construction: the compiler attaches no JSDoc for them.
|
|
10
25
|
*
|
|
11
26
|
* `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the
|
|
12
27
|
* point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI
|
|
@@ -15,12 +30,19 @@ const SourceLocation_1 = require("./SourceLocation");
|
|
|
15
30
|
*/
|
|
16
31
|
class JsDoc {
|
|
17
32
|
description;
|
|
33
|
+
returns;
|
|
18
34
|
format;
|
|
19
35
|
mcp;
|
|
20
36
|
mcpHeader;
|
|
21
37
|
constructor(
|
|
22
38
|
/** The body text, links flattened, trimmed. Empty string when undocumented. */
|
|
23
39
|
description,
|
|
40
|
+
/**
|
|
41
|
+
* The `@returns` block tag's text — what a method's success response carries, published as
|
|
42
|
+
* that response's `description` (#1292). Undefined when the author wrote none (or wrote the
|
|
43
|
+
* tag with no text), which an OpenAPI renderer refuses for an operation with a body.
|
|
44
|
+
*/
|
|
45
|
+
returns,
|
|
24
46
|
/** The `@format` block tag's text, e.g. `email` / `date-time`. */
|
|
25
47
|
format,
|
|
26
48
|
/**
|
|
@@ -41,6 +63,7 @@ class JsDoc {
|
|
|
41
63
|
*/
|
|
42
64
|
mcpHeader) {
|
|
43
65
|
this.description = description;
|
|
66
|
+
this.returns = returns;
|
|
44
67
|
this.format = format;
|
|
45
68
|
this.mcp = mcp;
|
|
46
69
|
this.mcpHeader = mcpHeader;
|
|
@@ -51,6 +74,7 @@ class JsDoc {
|
|
|
51
74
|
const symbolLike = node;
|
|
52
75
|
const blocks = symbolLike.jsDoc ?? [];
|
|
53
76
|
const bodies = [];
|
|
77
|
+
let returns;
|
|
54
78
|
let format;
|
|
55
79
|
let mcp;
|
|
56
80
|
let mcpHeader;
|
|
@@ -59,7 +83,12 @@ class JsDoc {
|
|
|
59
83
|
for (const tag of block.tags ?? []) {
|
|
60
84
|
const name = tag.tagName.text;
|
|
61
85
|
const text = JsDoc.flatten(tag.comment);
|
|
62
|
-
|
|
86
|
+
// `@privateRemarks` (and every tag not named below) is skipped with its text — see
|
|
87
|
+
// the class doc: it is never published anywhere.
|
|
88
|
+
if (name === RETURNS_TAG && text !== '') {
|
|
89
|
+
returns = text;
|
|
90
|
+
}
|
|
91
|
+
else if (name === 'format' && text !== '') {
|
|
63
92
|
format = text;
|
|
64
93
|
}
|
|
65
94
|
else if (name === 'mcp' && text !== '') {
|
|
@@ -70,7 +99,7 @@ class JsDoc {
|
|
|
70
99
|
}
|
|
71
100
|
}
|
|
72
101
|
}
|
|
73
|
-
return new JsDoc(bodies.join('\n').trim(), format, mcp, mcpHeader);
|
|
102
|
+
return new JsDoc(bodies.join('\n').trim(), returns, format, mcp, mcpHeader);
|
|
74
103
|
}
|
|
75
104
|
/**
|
|
76
105
|
* The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else
|
package/src/extract/JsDoc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;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AC,MAAM,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AAnHD,sBAmHC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@format` tag and the `@mcp` override.\n *\n * `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the\n * point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI\n * `description`, an MCP tool description, an HTML page — would otherwise each have to know the inline\n * tag grammar and each get it slightly differently wrong. One flattening, at extraction.\n */\nexport class JsDoc {\n private constructor(\n /** The body text, links flattened, trimmed. Empty string when undocumented. */\n readonly description: string,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment);\n if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n }\n }\n }\n\n return new JsDoc(bodies.join('\\n').trim(), format, mcp, mcpHeader);\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember = parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline tag replaced by its own text: `{@link Foo.bar}` -> `Foo.bar`,\n * `{@link Foo.bar|the widget}` -> `the widget`.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(comment: string | ts.NodeArray<ts.JSDocComment> | undefined): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n // `text` is whatever followed the target ('|the widget'); the NAME is the target.\n const label = part.text.replace(/^[|\\s]+/, '').trim();\n const target = part.name ? part.name.getText() : '';\n parts.push(label !== '' ? label : target);\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,sDAAoD;AACpD,qDAAkD;AAQlD;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,KAAK;IAGD;IAMA;IAEA;IAOA;IAUA;IA3Bb;IACI,+EAA+E;IACtE,WAAmB;IAC5B;;;;OAIG;IACM,OAA2B;IACpC,kEAAkE;IACzD,MAA0B;IACnC;;;;;OAKG;IACM,GAAuB;IAChC;;;;;;;;OAQG;IACM,SAA6B;QAzB7B,gBAAW,GAAX,WAAW,CAAQ;QAMnB,YAAO,GAAP,OAAO,CAAoB;QAE3B,WAAM,GAAN,MAAM,CAAoB;QAO1B,QAAG,GAAH,G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ACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AA9HD,sBA8HC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one\n * spelling per fact, and a refusal naming `@returns` is how an author finds out.\n */\nconst RETURNS_TAG = 'returns';\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@returns` tag, the `@format` tag and the `@mcp`\n * override.\n *\n * ## Every `/** *\\/` is published — except `@privateRemarks` (#1292)\n *\n * The body and the four tags named here are the ONLY text read out of a block. Every other block tag\n * is dropped together with its text, and `@privateRemarks` — TSDoc's standard \"inside the doc block,\n * never published\" tag — is the one an author writes ON PURPOSE to keep a note out of every document:\n * OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no\n * renderer can ever reach it — the same reason `{@link}` is flattened here (below). `//` and `/* *\\/`\n * comments are private by construction: the compiler attaches no JSDoc for them.\n *\n * `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the\n * point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI\n * `description`, an MCP tool description, an HTML page — would otherwise each have to know the inline\n * tag grammar and each get it slightly differently wrong. One flattening, at extraction.\n */\nexport class JsDoc {\n private constructor(\n /** The body text, links flattened, trimmed. Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@returns` block tag's text — what a method's success response carries, published as\n * that response's `description` (#1292). Undefined when the author wrote none (or wrote the\n * tag with no text), which an OpenAPI renderer refuses for an operation with a body.\n */\n readonly returns: string | undefined,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let returns: string | undefined;\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment);\n // `@privateRemarks` (and every tag not named below) is skipped with its text — see\n // the class doc: it is never published anywhere.\n if (name === RETURNS_TAG && text !== '') {\n returns = text;\n } else if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n }\n }\n }\n\n return new JsDoc(bodies.join('\\n').trim(), returns, format, mcp, mcpHeader);\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember = parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline tag replaced by its own text: `{@link Foo.bar}` -> `Foo.bar`,\n * `{@link Foo.bar|the widget}` -> `the widget`.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(comment: string | ts.NodeArray<ts.JSDocComment> | undefined): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n // `text` is whatever followed the target ('|the widget'); the NAME is the target.\n const label = part.text.replace(/^[|\\s]+/, '').trim();\n const target = part.name ? part.name.getText() : '';\n parts.push(label !== '' ? label : target);\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
@@ -399,6 +399,12 @@ export declare class DocumentedEndpoint {
|
|
|
399
399
|
readonly description: string;
|
|
400
400
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
401
401
|
readonly mcpDescription: string | undefined;
|
|
402
|
+
/**
|
|
403
|
+
* The method's `@returns` text — the SUCCESS response's `description` in a published document
|
|
404
|
+
* (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any
|
|
405
|
+
* operation whose response has a body, rather than publishing a filler sentence.
|
|
406
|
+
*/
|
|
407
|
+
readonly returnsDescription: string | undefined;
|
|
402
408
|
readonly request: TypeRef | undefined;
|
|
403
409
|
readonly response: TypeRef | undefined;
|
|
404
410
|
readonly streaming?: DocumentedStreaming | undefined;
|
|
@@ -443,7 +449,13 @@ export declare class DocumentedEndpoint {
|
|
|
443
449
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
444
450
|
maskLog: ReadonlyMap<string, string>, description: string,
|
|
445
451
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
446
|
-
mcpDescription: string | undefined,
|
|
452
|
+
mcpDescription: string | undefined,
|
|
453
|
+
/**
|
|
454
|
+
* The method's `@returns` text — the SUCCESS response's `description` in a published document
|
|
455
|
+
* (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any
|
|
456
|
+
* operation whose response has a body, rather than publishing a filler sentence.
|
|
457
|
+
*/
|
|
458
|
+
returnsDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined, streaming?: DocumentedStreaming | undefined, localOnly?: boolean);
|
|
447
459
|
}
|
|
448
460
|
/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
|
|
449
461
|
export declare class ApiDocModel {
|
package/src/model/ApiDocModel.js
CHANGED
|
@@ -363,6 +363,7 @@ class DocumentedEndpoint {
|
|
|
363
363
|
maskLog;
|
|
364
364
|
description;
|
|
365
365
|
mcpDescription;
|
|
366
|
+
returnsDescription;
|
|
366
367
|
request;
|
|
367
368
|
response;
|
|
368
369
|
streaming;
|
|
@@ -407,7 +408,13 @@ class DocumentedEndpoint {
|
|
|
407
408
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
408
409
|
maskLog, description,
|
|
409
410
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
410
|
-
mcpDescription,
|
|
411
|
+
mcpDescription,
|
|
412
|
+
/**
|
|
413
|
+
* The method's `@returns` text — the SUCCESS response's `description` in a published document
|
|
414
|
+
* (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any
|
|
415
|
+
* operation whose response has a body, rather than publishing a filler sentence.
|
|
416
|
+
*/
|
|
417
|
+
returnsDescription, request, response, streaming, localOnly = false) {
|
|
411
418
|
this.methodName = methodName;
|
|
412
419
|
this.httpMethod = httpMethod;
|
|
413
420
|
this.path = path;
|
|
@@ -423,6 +430,7 @@ class DocumentedEndpoint {
|
|
|
423
430
|
this.maskLog = maskLog;
|
|
424
431
|
this.description = description;
|
|
425
432
|
this.mcpDescription = mcpDescription;
|
|
433
|
+
this.returnsDescription = returnsDescription;
|
|
426
434
|
this.request = request;
|
|
427
435
|
this.response = response;
|
|
428
436
|
this.streaming = streaming;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,qEAAqE;IAC5D,QAAgB;IACzB,sDAAsD;IAC7C,QAAgB;IACzB,wEAAwE;IAC/D,MAAc;QAJd,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,WAAM,GAAN,MAAM,CAAQ;IACxB,CAAC;CACP;AATD,oCASC;AAED;;;;;;;;;;GAUG;AACH,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,mFAAmF;IAC1E,WAAmB;IAC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C;CACP;AAfD,gDAeC","sourcesContent":["import { TypeRef } from './TypeRef';\nimport type { DocumentedStreaming } from './DocumentedStreaming';\n\n/**\n * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —\n * these are data-only structures, and a renderer (#982) builds nothing, it only reads.\n *\n * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and\n * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import\n * here would end that, which is why `responsibilities.md` states the constraint rather than leaving\n * it to be discovered.\n */\n\n/** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */\nexport class UnmappedType {\n constructor(\n /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */\n readonly typeText: string,\n /** Pointer-style location: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** Why it could not be mapped, in one sentence a renderer can print. */\n readonly reason: string,\n ) {}\n}\n\n/**\n * A declaration with MORE THAN ONE JSDoc block stacked above it (#1286). RECORDED, never resolved:\n * no choice of block is right, so a renderer's guard refuses and names it.\n *\n * TypeScript attaches every `/** *\\/` comment in a declaration's leading trivia, so two shapes land\n * here and both publish the wrong description — a FILE or SECTION header written as `/** *\\/` above\n * the first declaration, and a doc STRANDED on top of another declaration's own by a refactor that\n * inserted something between a declaration and its JSDoc. \"Nearest wins\" would hide the second shape:\n * the declaration the stranded doc belonged to silently loses it. Only the author knows which shape\n * this is, so the fix is theirs.\n */\nexport class StackedJsDoc {\n constructor(\n /** What carries the blocks — `MenuPublicationStatusDto`, `Widget.name`, `save`. */\n readonly declaration: string,\n /** Pointer-style location of the DECLARATION: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** The 1-based line each stacked JSDoc block starts on, in source order. */\n readonly blockLines: readonly number[],\n ) {}\n}\n\n/** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */\nexport class UnionDiscriminator {\n constructor(\n /** The property every branch carries. */\n readonly propertyName: string,\n /**\n * branch type name -> EVERY string value that branch's property may hold. One value for\n * `mode: 'fixed'` / `mode: VoiceMode.FIXED`; several for `mode: 'a' | 'b'` or\n * `mode: VoiceMode.A | VoiceMode.B` (#1023). No value appears under two branches — that is\n * what makes the property a discriminator, and an OpenAPI `mapping` point several values at\n * one schema.\n */\n readonly branchValues: ReadonlyMap<string, readonly string[]>,\n ) {}\n}\n\n/** One field of one DTO. */\nexport class DocumentedField {\n constructor(\n readonly name: string,\n readonly type: TypeRef,\n /**\n * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from\n * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a\n * renderer that conflates them emits a schema that rejects one of them.\n */\n readonly optional: boolean,\n /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */\n readonly nullable: boolean,\n /** The JSDoc body, links flattened. Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means \"no override\",\n * and a renderer falls back to {@link description}; the fallback is NOT applied here so a\n * renderer can tell a deliberate agent-facing sentence from a reused human one.\n */\n readonly mcpDescription: string | undefined,\n /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */\n readonly format: string | undefined,\n /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */\n readonly min: number | undefined,\n /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */\n readonly max: number | undefined,\n /**\n * The `@mcpHeader <token>` JSDoc tag — the MCP 2026 SEP-2243 header this PRIMITIVE field is\n * mirrored into (`Mcp-Param-{token}`). Undefined for every field that is not mirrored, which\n * is nearly all of them.\n *\n * It is documentation and therefore lives in JSDoc, next to the sentence describing the\n * field, rather than in a decorator argument — and since #984 it is the only spelling of the\n * fact at all.\n */\n readonly mcpHeader: string | undefined,\n /**\n * Pointer-style `path/to/File.ts:12:5` for the property declaration itself.\n *\n * A renderer never needs it — it publishes a schema, not a file offset. The build RULES do:\n * `api-rules-for-openapi` refuses a field whose value type is `unknown`, and a refusal that\n * cannot say WHERE costs the author a grep over every DTO the contract reaches. It is\n * carried on the FIELD rather than recomputed because only the extractor still has the\n * syntax node, and a second reader deriving it would be a second answer to \"where is this\".\n */\n readonly location: string,\n ) {}\n}\n\n/** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */\nexport class DocumentedType {\n constructor(\n readonly name: string,\n readonly description: string,\n /** Object shape. Empty for an enum or a union. */\n readonly fields: readonly DocumentedField[],\n /** Set for a string-literal union that has a name. */\n readonly enumValues: readonly string[],\n /** Set for a union of named object types. */\n readonly unionRefNames: readonly string[],\n /** Set only when EVERY branch carries the same property typed as one string literal. */\n readonly discriminator: UnionDiscriminator | undefined,\n /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */\n readonly indexSignatureValue: TypeRef | undefined,\n /**\n * The npm package whose source DECLARES this type — the nearest `package.json` above the\n * declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract\n * document defines the schemas its own package declares and `$ref`s every other one into\n * that package's `components.openapi.json`. Undefined when the file belongs to no package.\n *\n * The MCP projection ignores it: a tool schema is always fully inlined.\n */\n readonly packageName: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */\n readonly location: string,\n /** Published schema name; the source name stays in name for validation and diagnostics. */\n readonly schemaName: string,\n ) {}\n\n /**\n * The key this type is registered under in {@link ApiDocModel.types} and named by every\n * {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and\n * `<package>:<name>` for every other one, so two packages' same-named types are two entries.\n */\n // webpieces-disable no-function-outside-class -- static helper on the class whose key it computes\n static keyOf(\n name: string,\n packageName: string | undefined,\n homePackage: string | undefined,\n ): string {\n return packageName === homePackage ? name : `${packageName ?? '<no package>'}:${name}`;\n }\n}\n\n/**\n * Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).\n *\n * Recorded rather than thrown, because the MCP projection inlines every schema and never cared which\n * of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each\n * schema of a package under its bare name, so it REFUSES a model carrying one of these: the second\n * declaration would be published as the first one's shape.\n */\nexport class TypeNameCollision {\n constructor(\n readonly name: string,\n readonly packageName: string | undefined,\n /** Where the declaration that won the name is. */\n readonly firstLocation: string,\n /** Where the declaration that was conflated into it is. */\n readonly secondLocation: string,\n ) {}\n}\n\n/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */\nexport class DocumentedEndpointOptions {\n constructor(\n readonly formPost: boolean,\n /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */\n readonly calledBy: string | undefined,\n readonly callerKind: string | undefined,\n ) {}\n}\n\n/**\n * The `@WpMcpTool('search_stores', 'Search stores')` declaration, when the method carries one — the\n * TWO facts the source cannot otherwise state, and nothing else.\n *\n * `description` used to sit on the decorator too. The method's JSDoc is the description, for the\n * agent and for the partner alike, byte-identical: two authored copies of one paragraph is the\n * two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI\n * document while the agent reads the decorator string in `tools/list`, and they drift the first time\n * somebody edits one. #984 deleted it. #1180 added the REQUIRED `title`, the short display name\n * clients and the Claude Connectors Directory show — a name, not a second copy of the description.\n *\n * The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`\n * in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |\n * WRITE` already says whether repeating a call is safe, so a hand-declared hint would be a second\n * answer to a question the contract has answered. `openWorldHint` is `@Endpoint`'s `openWorld`.\n */\nexport class DocumentedMcpTool {\n constructor(\n /**\n * The STABLE protocol name. Deliberately independent of the method name, because renaming a\n * method must not break a saved agent workflow.\n */\n readonly name: string,\n /**\n * The human-readable display name, published as `Tool.title` and `annotations.title`. The\n * EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.\n */\n readonly title: string,\n readonly profiles: readonly string[],\n ) {}\n}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', key: MyKeys.API_KEY }` or\n * `{ in: 'bearer' }`.\n *\n * Parsed rather than left as source text because it is the one auth argument a renderer must turn\n * into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or\n * `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string\n * `\"{ in: 'header', key: MyKeys.API_KEY }\"` would have to parse TypeScript to emit either one, which\n * is this package's job and not a renderer's.\n */\nexport class DocumentedApiKeyCredential {\n constructor(\n /** `header` or `bearer`, verbatim from the declaration. */\n readonly location: string,\n /**\n * The header name, read off the `httpHeader` of the ContextKey the credential's `key` names\n * (#1249). Undefined for `bearer`, whose location IS `Authorization`.\n */\n readonly name: string | undefined,\n /** The prose a docs site renders on its authorization card. */\n readonly description: string | undefined,\n ) {}\n}\n\n/** `apiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */\nexport class DocumentedApiKey {\n constructor(\n readonly regime: string,\n /**\n * Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them\n * are presented together — and the order is the order a published document lists them in.\n */\n readonly credentials: readonly DocumentedApiKeyCredential[],\n ) {}\n}\n\n/** Structurally extracted credential alternatives, with OR semantics. */\nexport class DocumentedAuthMethod {\n constructor(\n readonly kind: string,\n readonly argumentTexts: readonly string[],\n readonly apiKey: DocumentedApiKey | undefined,\n ) {}\n}\n\nexport class DocumentedAuth {\n constructor(\n readonly publicReason: string | undefined,\n readonly methods: readonly DocumentedAuthMethod[],\n ) {}\n}\n\n/** One `@Endpoint` method of one contract. */\nexport class DocumentedEndpoint {\n constructor(\n readonly methodName: string,\n /**\n * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be\n * written without it — the verb is the key an operation hangs under in `paths`.\n */\n readonly httpMethod: string,\n /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */\n readonly path: string,\n /**\n * `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is\n * independent of the verb: webpieces POSTs a read. A renderer publishes it rather than\n * inferring safety from the verb, which for this framework would be wrong.\n */\n readonly operation: string,\n /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */\n readonly kind: string,\n /**\n * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the\n * private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at\n * all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.\n */\n readonly hidden: boolean,\n /** `{ openWorld: true }` — this operation may touch systems outside this service. */\n readonly openWorld: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTool: DocumentedMcpTool | undefined,\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint\n * is PERMANENTLY outside MCP and was never a tool candidate.\n *\n * Distinct from \"has no `@WpMcpTool`\", which only says \"not a tool yet\". A renderer must not\n * report one of these as a SKIPPED tool, and `api-rules-for-mcp` stops asking a method with\n * one whether it could be served — the declaration is the answer. Carrying the reason rather\n * than a boolean is the point: the rule restates the list of exclusions with their arguments\n * on every run.\n */\n readonly invalidForMcp: string | undefined,\n /** The common @WpAuthorization declaration, shared by every surface. */\n readonly authorizationText: string | undefined,\n /** `@MaskLog({...})` — field name -> mask mode. */\n readonly maskLog: ReadonlyMap<string, string>,\n readonly description: string,\n /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */\n readonly mcpDescription: string | undefined,\n readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\n readonly streaming?: DocumentedStreaming,\n readonly localOnly: boolean = false,\n ) {}\n}\n\n/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */\nexport class ApiDocModel {\n constructor(\n /** The contract class name, e.g. `SaveApi`. */\n readonly contractName: string,\n /**\n * WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,\n * verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.\n *\n * A named list rather than a falsy default, because the grant has to be the TOKEN: a default\n * that reached customers would publish a contract whose author typed nothing about it.\n */\n readonly apiTypes: readonly string[],\n /** `@ApiPath(...)`, constant-folded. */\n readonly basePath: string,\n /** The JSDoc on the contract class, links flattened. */\n readonly description: string,\n readonly endpoints: readonly DocumentedEndpoint[],\n /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n /** Everything that could not be represented — recorded, not dropped. */\n readonly unmapped: readonly UnmappedType[],\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n\n/**\n * ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the\n * components-only OpenAPI document it publishes (#1058). Data-only.\n *\n * A components document contains EVERY exported type the library declares — not only the ones some\n * contract reaches — so its contents are a property of the library alone and do not move when a\n * downstream contract changes.\n */\nexport class ApiComponentsModel {\n constructor(\n /** The library's package name — every type in {@link exported} is declared by it. */\n readonly packageName: string,\n /** The library's package version, published as the document's `info.version`. */\n readonly packageVersion: string,\n /** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */\n readonly exported: readonly string[],\n /** Every named type reached from the exports — the library's own and other packages'. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n readonly unmapped: readonly UnmappedType[],\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,qEAAqE;IAC5D,QAAgB;IACzB,sDAAsD;IAC7C,QAAgB;IACzB,wEAAwE;IAC/D,MAAc;QAJd,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,WAAM,GAAN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AEnB,mBAAc,GAAd,cAAc,CAAQ;QAEtB,aAAQ,GAAR,QAAQ,CAAmB;QAE3B,UAAK,GAAL,KAAK,CAAqC;QAC1C,aAAQ,GAAR,QAAQ,CAAyB;QACjC,eAAU,GAAV,UAAU,CAA8B;QAExC,iBAAY,GAAZ,YAAY,CAAyB;IAC/C,CAAC;CACP;AAfD,gDAeC","sourcesContent":["import { TypeRef } from './TypeRef';\nimport type { DocumentedStreaming } from './DocumentedStreaming';\n\n/**\n * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —\n * these are data-only structures, and a renderer (#982) builds nothing, it only reads.\n *\n * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and\n * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import\n * here would end that, which is why `responsibilities.md` states the constraint rather than leaving\n * it to be discovered.\n */\n\n/** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */\nexport class UnmappedType {\n constructor(\n /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */\n readonly typeText: string,\n /** Pointer-style location: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** Why it could not be mapped, in one sentence a renderer can print. */\n readonly reason: string,\n ) {}\n}\n\n/**\n * A declaration with MORE THAN ONE JSDoc block stacked above it (#1286). RECORDED, never resolved:\n * no choice of block is right, so a renderer's guard refuses and names it.\n *\n * TypeScript attaches every `/** *\\/` comment in a declaration's leading trivia, so two shapes land\n * here and both publish the wrong description — a FILE or SECTION header written as `/** *\\/` above\n * the first declaration, and a doc STRANDED on top of another declaration's own by a refactor that\n * inserted something between a declaration and its JSDoc. \"Nearest wins\" would hide the second shape:\n * the declaration the stranded doc belonged to silently loses it. Only the author knows which shape\n * this is, so the fix is theirs.\n */\nexport class StackedJsDoc {\n constructor(\n /** What carries the blocks — `MenuPublicationStatusDto`, `Widget.name`, `save`. */\n readonly declaration: string,\n /** Pointer-style location of the DECLARATION: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** The 1-based line each stacked JSDoc block starts on, in source order. */\n readonly blockLines: readonly number[],\n ) {}\n}\n\n/** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */\nexport class UnionDiscriminator {\n constructor(\n /** The property every branch carries. */\n readonly propertyName: string,\n /**\n * branch type name -> EVERY string value that branch's property may hold. One value for\n * `mode: 'fixed'` / `mode: VoiceMode.FIXED`; several for `mode: 'a' | 'b'` or\n * `mode: VoiceMode.A | VoiceMode.B` (#1023). No value appears under two branches — that is\n * what makes the property a discriminator, and an OpenAPI `mapping` point several values at\n * one schema.\n */\n readonly branchValues: ReadonlyMap<string, readonly string[]>,\n ) {}\n}\n\n/** One field of one DTO. */\nexport class DocumentedField {\n constructor(\n readonly name: string,\n readonly type: TypeRef,\n /**\n * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from\n * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a\n * renderer that conflates them emits a schema that rejects one of them.\n */\n readonly optional: boolean,\n /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */\n readonly nullable: boolean,\n /** The JSDoc body, links flattened. Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means \"no override\",\n * and a renderer falls back to {@link description}; the fallback is NOT applied here so a\n * renderer can tell a deliberate agent-facing sentence from a reused human one.\n */\n readonly mcpDescription: string | undefined,\n /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */\n readonly format: string | undefined,\n /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */\n readonly min: number | undefined,\n /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */\n readonly max: number | undefined,\n /**\n * The `@mcpHeader <token>` JSDoc tag — the MCP 2026 SEP-2243 header this PRIMITIVE field is\n * mirrored into (`Mcp-Param-{token}`). Undefined for every field that is not mirrored, which\n * is nearly all of them.\n *\n * It is documentation and therefore lives in JSDoc, next to the sentence describing the\n * field, rather than in a decorator argument — and since #984 it is the only spelling of the\n * fact at all.\n */\n readonly mcpHeader: string | undefined,\n /**\n * Pointer-style `path/to/File.ts:12:5` for the property declaration itself.\n *\n * A renderer never needs it — it publishes a schema, not a file offset. The build RULES do:\n * `api-rules-for-openapi` refuses a field whose value type is `unknown`, and a refusal that\n * cannot say WHERE costs the author a grep over every DTO the contract reaches. It is\n * carried on the FIELD rather than recomputed because only the extractor still has the\n * syntax node, and a second reader deriving it would be a second answer to \"where is this\".\n */\n readonly location: string,\n ) {}\n}\n\n/** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */\nexport class DocumentedType {\n constructor(\n readonly name: string,\n readonly description: string,\n /** Object shape. Empty for an enum or a union. */\n readonly fields: readonly DocumentedField[],\n /** Set for a string-literal union that has a name. */\n readonly enumValues: readonly string[],\n /** Set for a union of named object types. */\n readonly unionRefNames: readonly string[],\n /** Set only when EVERY branch carries the same property typed as one string literal. */\n readonly discriminator: UnionDiscriminator | undefined,\n /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */\n readonly indexSignatureValue: TypeRef | undefined,\n /**\n * The npm package whose source DECLARES this type — the nearest `package.json` above the\n * declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract\n * document defines the schemas its own package declares and `$ref`s every other one into\n * that package's `components.openapi.json`. Undefined when the file belongs to no package.\n *\n * The MCP projection ignores it: a tool schema is always fully inlined.\n */\n readonly packageName: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */\n readonly location: string,\n /** Published schema name; the source name stays in name for validation and diagnostics. */\n readonly schemaName: string,\n ) {}\n\n /**\n * The key this type is registered under in {@link ApiDocModel.types} and named by every\n * {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and\n * `<package>:<name>` for every other one, so two packages' same-named types are two entries.\n */\n // webpieces-disable no-function-outside-class -- static helper on the class whose key it computes\n static keyOf(\n name: string,\n packageName: string | undefined,\n homePackage: string | undefined,\n ): string {\n return packageName === homePackage ? name : `${packageName ?? '<no package>'}:${name}`;\n }\n}\n\n/**\n * Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).\n *\n * Recorded rather than thrown, because the MCP projection inlines every schema and never cared which\n * of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each\n * schema of a package under its bare name, so it REFUSES a model carrying one of these: the second\n * declaration would be published as the first one's shape.\n */\nexport class TypeNameCollision {\n constructor(\n readonly name: string,\n readonly packageName: string | undefined,\n /** Where the declaration that won the name is. */\n readonly firstLocation: string,\n /** Where the declaration that was conflated into it is. */\n readonly secondLocation: string,\n ) {}\n}\n\n/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */\nexport class DocumentedEndpointOptions {\n constructor(\n readonly formPost: boolean,\n /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */\n readonly calledBy: string | undefined,\n readonly callerKind: string | undefined,\n ) {}\n}\n\n/**\n * The `@WpMcpTool('search_stores', 'Search stores')` declaration, when the method carries one — the\n * TWO facts the source cannot otherwise state, and nothing else.\n *\n * `description` used to sit on the decorator too. The method's JSDoc is the description, for the\n * agent and for the partner alike, byte-identical: two authored copies of one paragraph is the\n * two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI\n * document while the agent reads the decorator string in `tools/list`, and they drift the first time\n * somebody edits one. #984 deleted it. #1180 added the REQUIRED `title`, the short display name\n * clients and the Claude Connectors Directory show — a name, not a second copy of the description.\n *\n * The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`\n * in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |\n * WRITE` already says whether repeating a call is safe, so a hand-declared hint would be a second\n * answer to a question the contract has answered. `openWorldHint` is `@Endpoint`'s `openWorld`.\n */\nexport class DocumentedMcpTool {\n constructor(\n /**\n * The STABLE protocol name. Deliberately independent of the method name, because renaming a\n * method must not break a saved agent workflow.\n */\n readonly name: string,\n /**\n * The human-readable display name, published as `Tool.title` and `annotations.title`. The\n * EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.\n */\n readonly title: string,\n readonly profiles: readonly string[],\n ) {}\n}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', key: MyKeys.API_KEY }` or\n * `{ in: 'bearer' }`.\n *\n * Parsed rather than left as source text because it is the one auth argument a renderer must turn\n * into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or\n * `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string\n * `\"{ in: 'header', key: MyKeys.API_KEY }\"` would have to parse TypeScript to emit either one, which\n * is this package's job and not a renderer's.\n */\nexport class DocumentedApiKeyCredential {\n constructor(\n /** `header` or `bearer`, verbatim from the declaration. */\n readonly location: string,\n /**\n * The header name, read off the `httpHeader` of the ContextKey the credential's `key` names\n * (#1249). Undefined for `bearer`, whose location IS `Authorization`.\n */\n readonly name: string | undefined,\n /** The prose a docs site renders on its authorization card. */\n readonly description: string | undefined,\n ) {}\n}\n\n/** `apiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */\nexport class DocumentedApiKey {\n constructor(\n readonly regime: string,\n /**\n * Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them\n * are presented together — and the order is the order a published document lists them in.\n */\n readonly credentials: readonly DocumentedApiKeyCredential[],\n ) {}\n}\n\n/** Structurally extracted credential alternatives, with OR semantics. */\nexport class DocumentedAuthMethod {\n constructor(\n readonly kind: string,\n readonly argumentTexts: readonly string[],\n readonly apiKey: DocumentedApiKey | undefined,\n ) {}\n}\n\nexport class DocumentedAuth {\n constructor(\n readonly publicReason: string | undefined,\n readonly methods: readonly DocumentedAuthMethod[],\n ) {}\n}\n\n/** One `@Endpoint` method of one contract. */\nexport class DocumentedEndpoint {\n constructor(\n readonly methodName: string,\n /**\n * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be\n * written without it — the verb is the key an operation hangs under in `paths`.\n */\n readonly httpMethod: string,\n /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */\n readonly path: string,\n /**\n * `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is\n * independent of the verb: webpieces POSTs a read. A renderer publishes it rather than\n * inferring safety from the verb, which for this framework would be wrong.\n */\n readonly operation: string,\n /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */\n readonly kind: string,\n /**\n * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the\n * private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at\n * all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.\n */\n readonly hidden: boolean,\n /** `{ openWorld: true }` — this operation may touch systems outside this service. */\n readonly openWorld: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTool: DocumentedMcpTool | undefined,\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint\n * is PERMANENTLY outside MCP and was never a tool candidate.\n *\n * Distinct from \"has no `@WpMcpTool`\", which only says \"not a tool yet\". A renderer must not\n * report one of these as a SKIPPED tool, and `api-rules-for-mcp` stops asking a method with\n * one whether it could be served — the declaration is the answer. Carrying the reason rather\n * than a boolean is the point: the rule restates the list of exclusions with their arguments\n * on every run.\n */\n readonly invalidForMcp: string | undefined,\n /** The common @WpAuthorization declaration, shared by every surface. */\n readonly authorizationText: string | undefined,\n /** `@MaskLog({...})` — field name -> mask mode. */\n readonly maskLog: ReadonlyMap<string, string>,\n readonly description: string,\n /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */\n readonly mcpDescription: string | undefined,\n /**\n * The method's `@returns` text — the SUCCESS response's `description` in a published document\n * (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any\n * operation whose response has a body, rather than publishing a filler sentence.\n */\n readonly returnsDescription: string | undefined,\n readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\n readonly streaming?: DocumentedStreaming,\n readonly localOnly: boolean = false,\n ) {}\n}\n\n/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */\nexport class ApiDocModel {\n constructor(\n /** The contract class name, e.g. `SaveApi`. */\n readonly contractName: string,\n /**\n * WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,\n * verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.\n *\n * A named list rather than a falsy default, because the grant has to be the TOKEN: a default\n * that reached customers would publish a contract whose author typed nothing about it.\n */\n readonly apiTypes: readonly string[],\n /** `@ApiPath(...)`, constant-folded. */\n readonly basePath: string,\n /** The JSDoc on the contract class, links flattened. */\n readonly description: string,\n readonly endpoints: readonly DocumentedEndpoint[],\n /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n /** Everything that could not be represented — recorded, not dropped. */\n readonly unmapped: readonly UnmappedType[],\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n\n/**\n * ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the\n * components-only OpenAPI document it publishes (#1058). Data-only.\n *\n * A components document contains EVERY exported type the library declares — not only the ones some\n * contract reaches — so its contents are a property of the library alone and do not move when a\n * downstream contract changes.\n */\nexport class ApiComponentsModel {\n constructor(\n /** The library's package name — every type in {@link exported} is declared by it. */\n readonly packageName: string,\n /** The library's package version, published as the document's `info.version`. */\n readonly packageVersion: string,\n /** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */\n readonly exported: readonly string[],\n /** Every named type reached from the exports — the library's own and other packages'. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n readonly unmapped: readonly UnmappedType[],\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n"]}
|
|
@@ -107,6 +107,16 @@ export declare class McpSchemaRenderer {
|
|
|
107
107
|
* can never carry one even if it is reached some other way.
|
|
108
108
|
*/
|
|
109
109
|
private rootSchema;
|
|
110
|
+
/**
|
|
111
|
+
* The ROOT schema's `description` (#1292): the request DTO's JSDoc on `inputSchema`, and the
|
|
112
|
+
* method's `@returns` sentence on `outputSchema` — the one slot a tool catalog has for "what this
|
|
113
|
+
* tool returns", so an agent reads the same sentence a partner reads as the OpenAPI success
|
|
114
|
+
* response's description. Falls back to the response DTO's own JSDoc when the method has no
|
|
115
|
+
* `@returns`, which only a caller outside `wp-openapi` can reach: the generator refuses a tool
|
|
116
|
+
* without one before any catalog is written. Nested DTOs keep the FIELD's prose (see
|
|
117
|
+
* {@link fieldSchema}); only the root has no field to take it from.
|
|
118
|
+
*/
|
|
119
|
+
private static describeRoot;
|
|
110
120
|
private namedType;
|
|
111
121
|
/**
|
|
112
122
|
* One object DTO. CLOSED (`additionalProperties: false`), with `required` written only when it is
|
|
@@ -167,7 +167,7 @@ class McpSchemaRenderer {
|
|
|
167
167
|
"'<Human-readable title>'). tools/list publishes it as title and annotations.title " +
|
|
168
168
|
'(#1180); never derive it from the name.');
|
|
169
169
|
}
|
|
170
|
-
return new core_util_1.McpToolDefinition(endpoint.mcpTool.name, title, endpoint.methodName, description, (0, core_util_1.mcpHintsForOperation)(McpSchemaRenderer.operationOf(endpoint, where), endpoint.openWorld), this.rootSchema(endpoint.request, where, 'request'), this.rootSchema(endpoint.response, where, 'response'), endpoint.mcpTool.profiles);
|
|
170
|
+
return new core_util_1.McpToolDefinition(endpoint.mcpTool.name, title, endpoint.methodName, description, (0, core_util_1.mcpHintsForOperation)(McpSchemaRenderer.operationOf(endpoint, where), endpoint.openWorld), this.rootSchema(endpoint.request, where, 'request', undefined), this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription), endpoint.mcpTool.profiles);
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* `operation` verbatim from the model, mapped back onto the REAL constant.
|
|
@@ -200,7 +200,7 @@ class McpSchemaRenderer {
|
|
|
200
200
|
* contract in the workspace, `@ApiType` or not. This is the renderer's own backstop, so a catalog
|
|
201
201
|
* can never carry one even if it is reached some other way.
|
|
202
202
|
*/
|
|
203
|
-
rootSchema(ref, where, side) {
|
|
203
|
+
rootSchema(ref, where, side, returns) {
|
|
204
204
|
if (ref.kind === 'union') {
|
|
205
205
|
throw new McpRenderError_1.McpRenderError(`an MCP tool's ${side} is itself a union`, where, `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +
|
|
206
206
|
'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +
|
|
@@ -216,7 +216,24 @@ class McpSchemaRenderer {
|
|
|
216
216
|
'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +
|
|
217
217
|
'request in the session.');
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
const schema = this.objectSchema(type, new Set());
|
|
220
|
+
McpSchemaRenderer.describeRoot(schema, returns ?? type.description);
|
|
221
|
+
return schema;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The ROOT schema's `description` (#1292): the request DTO's JSDoc on `inputSchema`, and the
|
|
225
|
+
* method's `@returns` sentence on `outputSchema` — the one slot a tool catalog has for "what this
|
|
226
|
+
* tool returns", so an agent reads the same sentence a partner reads as the OpenAPI success
|
|
227
|
+
* response's description. Falls back to the response DTO's own JSDoc when the method has no
|
|
228
|
+
* `@returns`, which only a caller outside `wp-openapi` can reach: the generator refuses a tool
|
|
229
|
+
* without one before any catalog is written. Nested DTOs keep the FIELD's prose (see
|
|
230
|
+
* {@link fieldSchema}); only the root has no field to take it from.
|
|
231
|
+
*/
|
|
232
|
+
// webpieces-disable no-function-outside-class -- private static helper of this class
|
|
233
|
+
static describeRoot(schema, prose) {
|
|
234
|
+
if (prose.trim() !== '') {
|
|
235
|
+
schema.description = prose;
|
|
236
|
+
}
|
|
220
237
|
}
|
|
221
238
|
namedType(name, where) {
|
|
222
239
|
const type = this.model.types.get(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpSchemaRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/render/McpSchemaRenderer.ts"],"names":[],"mappings":";;;AAAA,oDAY8B;AAQ9B,qDAAkD;AAElD,iFAAiF;AACjF,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAEtD,4GAA4G;AAC5G,MAAa,cAAc;IAGV;IACA;IAEA;IALb;IACI,4CAA4C;IACnC,IAAY,EACZ,YAAoB;IAC7B,4EAA4E;IACnE,MAAc;QAHd,SAAI,GAAJ,IAAI,CAAQ;QACZ,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,WAAM,GAAN,MAAM,CAAQ;IACxB,CAAC;IAEJ,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC;CACJ;AAZD,wCAYC;AAED;;;GAGG;AACH,MAAa,gBAAgB;IAEZ;IACA;IAFb,YACa,QAAuC,EACvC,OAAkC;QADlC,aAAQ,GAAR,QAAQ,CAA+B;QACvC,YAAO,GAAP,OAAO,CAA2B;IAC5C,CAAC;CACP;AALD,4CAKC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,iBAAiB;IAEL;IACA;IAFrB,YACqB,KAAkB,EAClB,sBAAsB,IAAI;QAD1B,UAAK,GAAL,KAAK,CAAa;QAClB,wBAAmB,GAAnB,mBAAmB,CAAO;IAC5C,CAAC;IAEJ,8FAA8F;IAC9F,SAAS,CAAC,GAAY,EAAE,KAAa;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;IAC1D,CAAC;IAED,uEAAuE;IACvE,MAAM;QACF,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,KAAK,MAAM,QAAQ,IAAI,IAA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C,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,yBAAa,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,sFAAsF;IAC9E,MAAM,CAAC,SAAS,CAAC,GAAY,EAAE,KAAa;QAChD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5D,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,IAAI,+BAAc,CACpB,IAAI,GAAG,CAAC,SAAS,qBAAqB,EACtC,KAAK,EACL,wFAAwF;YACpF,4CAA4C,CACnD,CAAC;IACN,CAAC;CACJ;AA9eD,8CA8eC","sourcesContent":["import {\n ApiJsonSchema,\n ApiJsonSchemaDiscriminator,\n ApiJsonSchemaType,\n EndpointOperation,\n McpToolCatalogError,\n McpToolCatalogFile,\n McpToolDefinition,\n mcpHintsForOperation,\n READ,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport {\n ApiDocModel,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { McpRenderError } from './McpRenderError';\n\n/** RFC 9110 token, which is what an `Mcp-Param-{name}` header name has to be. */\nconst HEADER_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** ONE `@WpMcpTool` the build could not give a schema, and why. See {@link McpSchemaRenderer.catalogOf}. */\nexport class SkippedMcpTool {\n constructor(\n /** The stable protocol name it declared. */\n readonly name: string,\n readonly contractName: string,\n /** The render refusal, verbatim, including the declaration it points at. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.contractName}/${this.name}: ${this.reason}`;\n }\n}\n\n/**\n * What one catalog render produced: ONE catalog per contract that has at least one renderable tool\n * (`mcp-<ContractClass>-tools.json` each), and the tools it could not produce.\n */\nexport class McpCatalogRender {\n constructor(\n readonly catalogs: readonly McpToolCatalogFile[],\n readonly skipped: readonly SkippedMcpTool[],\n ) {}\n}\n\n/**\n * `ApiDocModel` -> the MCP tool list an agent is shown, and the server accepts calls against.\n *\n * ## It is the ONLY source of an MCP schema\n *\n * It was written for #983 as a MEASUREMENT: it rendered the same `ApiJsonSchema` the reflect-metadata\n * runtime built, so the two could be compared field by field. They matched for every DTO shape the\n * runtime could build, which is what licensed #984 to delete `@WpDtoField` and its erasure-repair\n * arguments — `required`, `arrayItems`, `integer`, `minimum`, `maximum`, `enumValues`, `mapValues`,\n * `mcpHeader` — along with `DtoSchemaBuilder` itself. There is now one schema, built here, written to\n * one `mcp-<ContractClass>-tools.json` per contract by `wp-openapi`, and read at boot by\n * `McpToolRegistry`.\n *\n * ## Where it now goes FURTHER than the deleted runtime could\n *\n * The three reproductions #983 documented were runtime capability gaps, and two of them are closed:\n *\n * - **NULLABLE is rendered**, as `type: [T, \"null\"]` — and, on an enum, with `null` added to `enum` too. `ApiJsonSchema.type` used to hold one string,\n * so the runtime could not write it down even where the compiler could see `externalId: string | null`\n * — and `{}` and `{externalId: null}` are different wire documents. `type` is now\n * `ApiJsonSchemaType | readonly ApiJsonSchemaType[]` and the union is emitted.\n * - **A bound on an ARRAY of numbers** lands on the ITEM, where OpenAPI puts it. `@WpDtoField`\n * rejected numeric constraints on a non-`Number` field, so it had nowhere to go at all.\n * - **A nested DTO is INLINED**, with the FIELD's prose on it — not a gap but the protocol: MCP tool\n * schemas are inline and have no `$ref`.\n */\nexport class McpSchemaRenderer {\n constructor(\n private readonly model: ApiDocModel,\n private readonly requireDescriptions = true,\n ) {}\n\n /** The shared inline runtime schema projection, also used by streaming catalog generation. */\n schemaFor(ref: TypeRef, where: string): ApiJsonSchema {\n return this.typeSchema(ref, where, new Set<string>());\n }\n\n /** Every `@WpMcpTool` method of the contract, in declaration order. */\n render(): readonly McpToolDefinition[] {\n const tools: McpToolDefinition[] = [];\n for (const endpoint of this.model.endpoints) {\n if (endpoint.mcpTool !== undefined) {\n tools.push(this.tool(endpoint));\n }\n }\n return tools;\n }\n\n /**\n * The tools of SEVERAL contracts as ONE CATALOG PER CONTRACT — the artifacts a server boots from,\n * one `mcp-<ContractClass>-tools.json` each — plus every tool that could not be rendered and why.\n *\n * Per contract because a server binds contracts, and checks each `McpApiBinding` against the file\n * generated from exactly that contract (#1021). The protocol namespace is still FLAT, though: two\n * contracts declaring one tool name is a collision an agent would see, so it is refused here, at\n * build time, across every contract of the run, rather than at somebody's boot.\n *\n * ## Why an unrenderable tool is REPORTED here rather than throwing\n *\n * Some shapes have no MCP schema at all — a recursive DTO, an undocumented tool, a request that\n * is not a named object — and the first of those is a limit of the PROTOCOL rather than a defect\n * in a contract that is otherwise perfectly good HTTP. (A DISCRIMINATED UNION used to be on this\n * list and no longer is: #1009 taught `ApiJsonSchema` `oneOf`, so one publishes.) Such a\n * tool was never servable: the reflect-metadata runtime refused it too, for its own reasons. So\n * failing the whole document build over one would stop a repo publishing its OpenAPI over a tool\n * nobody could ever have called.\n *\n * It is not silence either. The build NAMES every skipped tool with its reason, and\n * `McpToolRegistry` REFUSES TO BOOT when a registered `@WpMcpTool` is missing from the catalog —\n * which is the right place for that failure, because that is the process actually claiming to\n * serve it.\n */\n // webpieces-disable no-function-outside-class -- static factory over this class\n static catalogOf(models: readonly ApiDocModel[]): McpCatalogRender {\n const catalogs: McpToolCatalogFile[] = [];\n const skipped: SkippedMcpTool[] = [];\n const owners = new Map<string, string>();\n for (const model of models) {\n const renderer = new McpSchemaRenderer(model);\n const tools: McpToolDefinition[] = [];\n for (const endpoint of model.endpoints) {\n if (endpoint.mcpTool === undefined) {\n continue;\n }\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring\n try {\n tools.push(renderer.tool(endpoint));\n } catch (err: unknown) {\n //const error = toError(err);\n if (!(err instanceof McpRenderError)) throw err;\n skipped.push(\n new SkippedMcpTool(endpoint.mcpTool.name, model.contractName, err.message),\n );\n }\n }\n McpSchemaRenderer.claimNames(owners, model.contractName, tools);\n if (tools.length > 0) {\n catalogs.push(new McpToolCatalogFile(model.contractName, tools));\n }\n }\n return new McpCatalogRender(catalogs, skipped);\n }\n\n /** Refuse a tool name some OTHER contract of this run already declared: the namespace is flat. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static claimNames(\n owners: Map<string, string>,\n contractName: string,\n tools: readonly McpToolDefinition[],\n ): void {\n for (const tool of tools) {\n const owner = owners.get(tool.name);\n if (owner !== undefined && owner !== contractName) {\n throw new McpToolCatalogError(\n `Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`,\n 'Tool names are the protocol identity and must be globally unique — rename one ' +\n \"of the two @WpMcpTool('<name>', '<title>') declarations.\",\n );\n }\n owners.set(tool.name, contractName);\n }\n }\n\n /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */\n tool(endpoint: DocumentedEndpoint): McpToolDefinition {\n const where = `${this.model.contractName}.${endpoint.methodName}`;\n const description = endpoint.mcpDescription ?? endpoint.description;\n if (description.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no documentation',\n where,\n 'Write a JSDoc block on the method, or an @mcp tag for agent-facing wording. It is ' +\n 'published verbatim by tools/list, so an agent has nothing else to go on.',\n );\n }\n if (endpoint.request === undefined || endpoint.response === undefined) {\n throw new McpRenderError(\n 'an MCP tool has no declared request or response type',\n where,\n 'Declare both: one request parameter and a Promise<Response> return type.',\n );\n }\n const title = endpoint.mcpTool!.title;\n if (title.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no human-readable title',\n where,\n `Write it as the second argument, a string literal: @WpMcpTool('${endpoint.mcpTool!.name}', ` +\n \"'<Human-readable title>'). tools/list publishes it as title and annotations.title \" +\n '(#1180); never derive it from the name.',\n );\n }\n return new McpToolDefinition(\n endpoint.mcpTool!.name,\n title,\n endpoint.methodName,\n description,\n mcpHintsForOperation(\n McpSchemaRenderer.operationOf(endpoint, where),\n endpoint.openWorld,\n ),\n this.rootSchema(endpoint.request, where, 'request'),\n this.rootSchema(endpoint.response, where, 'response'),\n endpoint.mcpTool!.profiles,\n );\n }\n\n /**\n * `operation` verbatim from the model, mapped back onto the REAL constant.\n *\n * A `switch` and not a cast, because the model carries the operation as a string and a cast would\n * hand `mcpHintsForOperation` a value it has no case for — which, for a function whose three arms\n * are exhaustive, means falling off the end and publishing a tool with NO hints.\n */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static operationOf(endpoint: DocumentedEndpoint, where: string): EndpointOperation {\n switch (endpoint.operation) {\n case READ:\n return READ;\n case WRITE_IDEMPOTENT:\n return WRITE_IDEMPOTENT;\n case WRITE:\n return WRITE;\n default:\n throw new McpRenderError(\n `@Endpoint declares operation '${endpoint.operation}', which has no MCP hints`,\n where,\n `Use one of the exported constants: ${READ}, ${WRITE_IDEMPOTENT}, ${WRITE}.`,\n );\n }\n }\n\n /**\n * A tool's input/output schema: always a CLOSED OBJECT, because MCP publishes objects — and\n * because a union at the ROOT of a tool schema is refused by the function-calling APIs that\n * consume it. Both OpenAI and Anthropic reject a top-level `oneOf`/`anyOf`/`allOf`, and a server\n * sends its WHOLE tool list on every request, so one such tool makes every request 400 and bricks\n * the session — not just that tool. Nested composition, inside a property, is fine.\n *\n * The build-time rule `no-root-union-api-type` refuses the same shape across every `@ApiPath`\n * contract in the workspace, `@ApiType` or not. This is the renderer's own backstop, so a catalog\n * can never carry one even if it is reached some other way.\n */\n private rootSchema(ref: TypeRef, where: string, side: string): ApiJsonSchema {\n if (ref.kind === 'union') {\n throw new McpRenderError(\n `an MCP tool's ${side} is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n if (ref.kind !== 'ref') {\n throw new McpRenderError(\n `an MCP tool's ${side} is not a named DTO`,\n where,\n 'Give it a named interface or class. An inline or primitive ' +\n `${side} has no object schema, and MCP publishes objects.`,\n );\n }\n const type = this.namedType(ref.refName!, where);\n if (type.unionRefNames.length > 0) {\n throw new McpRenderError(\n `an MCP tool's ${side} '${type.name}' is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n return this.objectSchema(type, new Set<string>());\n }\n\n private namedType(name: string, where: string): DocumentedType {\n const type = this.model.types.get(name);\n if (type === undefined) {\n throw new McpRenderError(\n `no model entry for type '${name}'`,\n where,\n 'Declare the type in a file the extractor reaches from this contract.',\n );\n }\n return type;\n }\n\n /**\n * One object DTO. CLOSED (`additionalProperties: false`), with `required` written only when it is\n * non-empty, so an all-optional DTO carries no empty list.\n *\n * The cycle stop is `parents`, and it THROWS rather than truncating: an inline schema cannot\n * express a recursive DTO, and one that silently stopped a level down would publish a shape the\n * server does not accept.\n */\n private objectSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n if (parents.has(type.name)) {\n throw new McpRenderError(\n `recursive DTO '${type.name}' cannot use an inline MCP schema`,\n type.name,\n 'Break the cycle, or keep this DTO out of the MCP document — a tool schema is ' +\n 'inline and has no $ref to close a loop with.',\n );\n }\n if (type.unionRefNames.length > 0) {\n return this.unionSchema(type, parents);\n }\n if (type.indexSignatureValue !== undefined && type.fields.length > 0) {\n throw new McpRenderError(\n `'${type.name}' has both named fields and an index signature`,\n type.name,\n 'Split the open map into a field of its own: a schema is either closed or a typed ' +\n 'map, and MCP has no spelling for half of each.',\n );\n }\n const nested = new Set(parents);\n nested.add(type.name);\n\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of type.fields) {\n schema.properties[field.name] = this.fieldSchema(type, field, nested);\n if (!field.optional) {\n required.push(field.name);\n }\n }\n if (required.length > 0) {\n schema.required = required;\n }\n return schema;\n }\n\n /**\n * A UNION, as `oneOf` with its branches INLINE and its DERIVED discriminator.\n *\n * MCP tool schemas are JSON Schema 2020-12 — the same dialect OpenAPI 3.1 uses — so `oneOf` was\n * never the obstacle; the obstacle was this repo's own subset, which had no spelling for it\n * (#1009). The shape written here MIRRORS `SchemaRenderer.union` in `@webpieces/openapi-generator`\n * branch for branch, because a union has ONE published spelling and that renderer is the\n * reference implementation of it. The only difference is the absence of `$ref`: a tool schema is\n * inline, so each branch is rendered in full and the discriminator maps to branch NAMES.\n *\n * `discriminator` is written ONLY when the model DERIVED one. A union TypeScript itself cannot\n * narrow is published as a bare `oneOf` rather than with an invented discriminator — claiming a\n * narrowing the source does not have is worse than admitting there is none.\n */\n private unionSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n const nested = new Set(parents);\n nested.add(type.name);\n const schema = new ApiJsonSchema();\n schema.oneOf = type.unionRefNames.map((name: string) =>\n this.objectSchema(this.namedType(name, type.name), nested),\n );\n if (type.description.trim() !== '') {\n schema.description = type.description;\n }\n if (type.discriminator !== undefined) {\n const mapping: Record<string, string> = {};\n for (const branch of type.unionRefNames) {\n // The branch's NAME, never its model key: a branch declared by another package is\n // keyed `<package>:<name>` (#1058), and the published mapping names the type.\n const branchName = this.namedType(branch, type.name).schemaName;\n for (const value of type.discriminator.branchValues.get(branch) ?? []) {\n mapping[value] = branchName;\n }\n }\n schema.discriminator = new ApiJsonSchemaDiscriminator(\n type.discriminator.propertyName,\n mapping,\n );\n }\n return schema;\n }\n\n /**\n * A FIELD whose type is a union: the model registers `type X = A | B` as its OWN entry carrying\n * the derived discriminator, while the field holds a bare list of branch names. Rendering that\n * list directly would publish the `oneOf` and silently DROP the discriminator — the one part of a\n * union a client needs to narrow on — so the alias is looked up by its branch list first. This is\n * the same lookup `SchemaRenderer.namedUnion` does to emit its `$ref`.\n */\n private fieldUnion(\n branchNames: readonly string[],\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const key = branchNames.join(',');\n for (const name of this.model.types.keys()) {\n const candidate = this.model.types.get(name)!;\n if (candidate.unionRefNames.length > 0 && candidate.unionRefNames.join(',') === key) {\n return this.unionSchema(candidate, parents);\n }\n }\n const schema = new ApiJsonSchema();\n schema.oneOf = branchNames.map((name: string) =>\n this.objectSchema(this.namedType(name, where), parents),\n );\n return schema;\n }\n\n /**\n * One FIELD: its type, then the prose and the constraints that hang off the field.\n *\n * The ORDER matters: the type is built first and `description` is written over whatever the type\n * produced, so a nested DTO carries the FIELD's sentence rather than the DTO's. `@WpMin` /\n * `@WpMax` land on the numeric LEAF — on an array, on the item — for the same reason\n * `SchemaRenderer` puts them there: a `minimum` on an array means nothing.\n *\n * NULLABLE widens the type to `[T, \"null\"]` and is deliberately NOT the same thing as OPTIONAL,\n * which is an absent entry in the object's `required` list. `{}` and `{externalId: null}` are\n * different wire documents, and an agent told only \"optional\" would send the wrong one.\n */\n private fieldSchema(\n owner: DocumentedType,\n field: DocumentedField,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const where = `${owner.name}.${field.name}`;\n const schema = this.typeSchema(field.type, where, parents);\n const description = field.mcpDescription ?? field.description;\n if (this.requireDescriptions && description.trim() === '') {\n throw new McpRenderError(\n 'a published DTO field has no documentation',\n where,\n 'Write a JSDoc sentence on the field. It is the only thing an agent is told about ' +\n 'that parameter.',\n );\n }\n schema.description = description;\n\n const leaf = field.type.kind === 'array' ? schema.items! : schema;\n if (field.min !== undefined) {\n leaf.minimum = field.min;\n }\n if (field.max !== undefined) {\n leaf.maximum = field.max;\n }\n if (field.mcpHeader !== undefined) {\n McpSchemaRenderer.assertHeaderFits(field, schema, where);\n schema['x-mcp-header'] = field.mcpHeader;\n }\n if (field.nullable) {\n schema.type = McpSchemaRenderer.nullable(schema, where);\n if (schema.enum !== undefined && !schema.enum.includes(null)) {\n // JSON Schema checks `enum` independently of `type`: without `null` here the widened\n // type admits null and the enum still rejects it, so a nullable string enum\n // (`x: SomeEnumDto | null`, or `'a' | 'b' | null`) failed output validation (#1197).\n schema.enum = [...schema.enum, null];\n }\n }\n return schema;\n }\n\n /** `T` -> `[T, \"null\"]`, refusing a field with no type at all rather than publishing `[\"null\"]`. */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static nullable(schema: ApiJsonSchema, where: string): readonly ApiJsonSchemaType[] {\n const base = ApiJsonSchema.baseTypeOf(schema);\n if (base === undefined) {\n throw new McpRenderError(\n 'a nullable field has no other type',\n where,\n 'A field typed only `null` carries no information — give it a real type beside it.',\n );\n }\n return [base, 'null'];\n }\n\n /**\n * `@mcpHeader` mirrors a PRIMITIVE parameter into `Mcp-Param-{name}` (MCP 2026 SEP-2243). The\n * three conditions are the runtime's, restated against the compiler's view of the field, so a\n * declaration the server would reject at boot fails the document build instead.\n */\n // webpieces-disable no-function-outside-class -- private static validator of this class\n private static assertHeaderFits(\n field: DocumentedField,\n schema: ApiJsonSchema,\n where: string,\n ): void {\n if (!HEADER_TOKEN.test(field.mcpHeader!)) {\n throw new McpRenderError(\n `@mcpHeader '${field.mcpHeader}' is not an RFC 9110 token`,\n where,\n 'Use letters, digits and the token punctuation only — it becomes an HTTP header name.',\n );\n }\n if (schema.type !== 'string' && schema.type !== 'boolean' && schema.type !== 'integer') {\n throw new McpRenderError(\n '@mcpHeader is on a field that is not a primitive an MCP header can carry',\n where,\n 'Mirror a string, a boolean or an Integer. A non-integer number and every object ' +\n 'shape are excluded by MCP 2026-07-28.',\n );\n }\n }\n\n /** One resolved type, with no field-level prose or constraints on it. */\n private typeSchema(ref: TypeRef, where: string, parents: ReadonlySet<string>): ApiJsonSchema {\n switch (ref.kind) {\n case 'primitive':\n return McpSchemaRenderer.primitive(ref, where);\n case 'enum': {\n const schema = new ApiJsonSchema('string');\n schema.enum = ref.enumValues.slice();\n return schema;\n }\n case 'array': {\n const schema = new ApiJsonSchema('array');\n schema.items = this.typeSchema(ref.items!, where, parents);\n return schema;\n }\n case 'openMap': {\n const schema = new ApiJsonSchema('object');\n schema.additionalProperties = this.typeSchema(ref.values!, where, parents);\n return schema;\n }\n case 'ref':\n return this.referencedSchema(ref.refName!, where, parents);\n case 'union':\n return this.fieldUnion(ref.unionRefNames, where, parents);\n default:\n throw new McpRenderError(\n `no MCP schema for the declared type '${ref.unmappedText ?? '<unknown>'}'`,\n where,\n 'Give the field a shape the model can represent — a named DTO, an array of one, ' +\n 'a string-literal union, a Record, or a primitive.',\n );\n }\n }\n\n /** A named type: a string enum becomes `enum`, an object DTO is INLINED (MCP has no `$ref`). */\n private referencedSchema(\n name: string,\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const type = this.namedType(name, where);\n if (type.enumValues.length > 0) {\n const schema = new ApiJsonSchema('string');\n schema.enum = type.enumValues.slice();\n return schema;\n }\n return this.objectSchema(type, parents);\n }\n\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static primitive(ref: TypeRef, where: string): ApiJsonSchema {\n if (ref.primitive === 'string' || ref.primitive === 'boolean') {\n return new ApiJsonSchema(ref.primitive);\n }\n if (ref.primitive === 'number') {\n return new ApiJsonSchema(ref.integer ? 'integer' : 'number');\n }\n throw new McpRenderError(\n `'${ref.primitive}' has no MCP schema`,\n where,\n 'Give the field a concrete type. `unknown`, `any`, `void` and a bare `null` publish as ' +\n '\"anything\", which an agent cannot fill in.',\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"McpSchemaRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/render/McpSchemaRenderer.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AiF;oBAC7E,mDAAmD,CAC1D,CAAC;QACV,CAAC;IACL,CAAC;IAED,gGAAgG;IACxF,gBAAgB,CACpB,IAAY,EACZ,KAAa,EACb,OAA4B;QAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,IAAI,yBAAa,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,sFAAsF;IAC9E,MAAM,CAAC,SAAS,CAAC,GAAY,EAAE,KAAa;QAChD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5D,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,IAAI,+BAAc,CACpB,IAAI,GAAG,CAAC,SAAS,qBAAqB,EACtC,KAAK,EACL,wFAAwF;YACpF,4CAA4C,CACnD,CAAC;IACN,CAAC;CACJ;AArgBD,8CAqgBC","sourcesContent":["import {\n ApiJsonSchema,\n ApiJsonSchemaDiscriminator,\n ApiJsonSchemaType,\n EndpointOperation,\n McpToolCatalogError,\n McpToolCatalogFile,\n McpToolDefinition,\n mcpHintsForOperation,\n READ,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport {\n ApiDocModel,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { McpRenderError } from './McpRenderError';\n\n/** RFC 9110 token, which is what an `Mcp-Param-{name}` header name has to be. */\nconst HEADER_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** ONE `@WpMcpTool` the build could not give a schema, and why. See {@link McpSchemaRenderer.catalogOf}. */\nexport class SkippedMcpTool {\n constructor(\n /** The stable protocol name it declared. */\n readonly name: string,\n readonly contractName: string,\n /** The render refusal, verbatim, including the declaration it points at. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.contractName}/${this.name}: ${this.reason}`;\n }\n}\n\n/**\n * What one catalog render produced: ONE catalog per contract that has at least one renderable tool\n * (`mcp-<ContractClass>-tools.json` each), and the tools it could not produce.\n */\nexport class McpCatalogRender {\n constructor(\n readonly catalogs: readonly McpToolCatalogFile[],\n readonly skipped: readonly SkippedMcpTool[],\n ) {}\n}\n\n/**\n * `ApiDocModel` -> the MCP tool list an agent is shown, and the server accepts calls against.\n *\n * ## It is the ONLY source of an MCP schema\n *\n * It was written for #983 as a MEASUREMENT: it rendered the same `ApiJsonSchema` the reflect-metadata\n * runtime built, so the two could be compared field by field. They matched for every DTO shape the\n * runtime could build, which is what licensed #984 to delete `@WpDtoField` and its erasure-repair\n * arguments — `required`, `arrayItems`, `integer`, `minimum`, `maximum`, `enumValues`, `mapValues`,\n * `mcpHeader` — along with `DtoSchemaBuilder` itself. There is now one schema, built here, written to\n * one `mcp-<ContractClass>-tools.json` per contract by `wp-openapi`, and read at boot by\n * `McpToolRegistry`.\n *\n * ## Where it now goes FURTHER than the deleted runtime could\n *\n * The three reproductions #983 documented were runtime capability gaps, and two of them are closed:\n *\n * - **NULLABLE is rendered**, as `type: [T, \"null\"]` — and, on an enum, with `null` added to `enum` too. `ApiJsonSchema.type` used to hold one string,\n * so the runtime could not write it down even where the compiler could see `externalId: string | null`\n * — and `{}` and `{externalId: null}` are different wire documents. `type` is now\n * `ApiJsonSchemaType | readonly ApiJsonSchemaType[]` and the union is emitted.\n * - **A bound on an ARRAY of numbers** lands on the ITEM, where OpenAPI puts it. `@WpDtoField`\n * rejected numeric constraints on a non-`Number` field, so it had nowhere to go at all.\n * - **A nested DTO is INLINED**, with the FIELD's prose on it — not a gap but the protocol: MCP tool\n * schemas are inline and have no `$ref`.\n */\nexport class McpSchemaRenderer {\n constructor(\n private readonly model: ApiDocModel,\n private readonly requireDescriptions = true,\n ) {}\n\n /** The shared inline runtime schema projection, also used by streaming catalog generation. */\n schemaFor(ref: TypeRef, where: string): ApiJsonSchema {\n return this.typeSchema(ref, where, new Set<string>());\n }\n\n /** Every `@WpMcpTool` method of the contract, in declaration order. */\n render(): readonly McpToolDefinition[] {\n const tools: McpToolDefinition[] = [];\n for (const endpoint of this.model.endpoints) {\n if (endpoint.mcpTool !== undefined) {\n tools.push(this.tool(endpoint));\n }\n }\n return tools;\n }\n\n /**\n * The tools of SEVERAL contracts as ONE CATALOG PER CONTRACT — the artifacts a server boots from,\n * one `mcp-<ContractClass>-tools.json` each — plus every tool that could not be rendered and why.\n *\n * Per contract because a server binds contracts, and checks each `McpApiBinding` against the file\n * generated from exactly that contract (#1021). The protocol namespace is still FLAT, though: two\n * contracts declaring one tool name is a collision an agent would see, so it is refused here, at\n * build time, across every contract of the run, rather than at somebody's boot.\n *\n * ## Why an unrenderable tool is REPORTED here rather than throwing\n *\n * Some shapes have no MCP schema at all — a recursive DTO, an undocumented tool, a request that\n * is not a named object — and the first of those is a limit of the PROTOCOL rather than a defect\n * in a contract that is otherwise perfectly good HTTP. (A DISCRIMINATED UNION used to be on this\n * list and no longer is: #1009 taught `ApiJsonSchema` `oneOf`, so one publishes.) Such a\n * tool was never servable: the reflect-metadata runtime refused it too, for its own reasons. So\n * failing the whole document build over one would stop a repo publishing its OpenAPI over a tool\n * nobody could ever have called.\n *\n * It is not silence either. The build NAMES every skipped tool with its reason, and\n * `McpToolRegistry` REFUSES TO BOOT when a registered `@WpMcpTool` is missing from the catalog —\n * which is the right place for that failure, because that is the process actually claiming to\n * serve it.\n */\n // webpieces-disable no-function-outside-class -- static factory over this class\n static catalogOf(models: readonly ApiDocModel[]): McpCatalogRender {\n const catalogs: McpToolCatalogFile[] = [];\n const skipped: SkippedMcpTool[] = [];\n const owners = new Map<string, string>();\n for (const model of models) {\n const renderer = new McpSchemaRenderer(model);\n const tools: McpToolDefinition[] = [];\n for (const endpoint of model.endpoints) {\n if (endpoint.mcpTool === undefined) {\n continue;\n }\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring\n try {\n tools.push(renderer.tool(endpoint));\n } catch (err: unknown) {\n //const error = toError(err);\n if (!(err instanceof McpRenderError)) throw err;\n skipped.push(\n new SkippedMcpTool(endpoint.mcpTool.name, model.contractName, err.message),\n );\n }\n }\n McpSchemaRenderer.claimNames(owners, model.contractName, tools);\n if (tools.length > 0) {\n catalogs.push(new McpToolCatalogFile(model.contractName, tools));\n }\n }\n return new McpCatalogRender(catalogs, skipped);\n }\n\n /** Refuse a tool name some OTHER contract of this run already declared: the namespace is flat. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static claimNames(\n owners: Map<string, string>,\n contractName: string,\n tools: readonly McpToolDefinition[],\n ): void {\n for (const tool of tools) {\n const owner = owners.get(tool.name);\n if (owner !== undefined && owner !== contractName) {\n throw new McpToolCatalogError(\n `Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`,\n 'Tool names are the protocol identity and must be globally unique — rename one ' +\n \"of the two @WpMcpTool('<name>', '<title>') declarations.\",\n );\n }\n owners.set(tool.name, contractName);\n }\n }\n\n /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */\n tool(endpoint: DocumentedEndpoint): McpToolDefinition {\n const where = `${this.model.contractName}.${endpoint.methodName}`;\n const description = endpoint.mcpDescription ?? endpoint.description;\n if (description.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no documentation',\n where,\n 'Write a JSDoc block on the method, or an @mcp tag for agent-facing wording. It is ' +\n 'published verbatim by tools/list, so an agent has nothing else to go on.',\n );\n }\n if (endpoint.request === undefined || endpoint.response === undefined) {\n throw new McpRenderError(\n 'an MCP tool has no declared request or response type',\n where,\n 'Declare both: one request parameter and a Promise<Response> return type.',\n );\n }\n const title = endpoint.mcpTool!.title;\n if (title.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no human-readable title',\n where,\n `Write it as the second argument, a string literal: @WpMcpTool('${endpoint.mcpTool!.name}', ` +\n \"'<Human-readable title>'). tools/list publishes it as title and annotations.title \" +\n '(#1180); never derive it from the name.',\n );\n }\n return new McpToolDefinition(\n endpoint.mcpTool!.name,\n title,\n endpoint.methodName,\n description,\n mcpHintsForOperation(\n McpSchemaRenderer.operationOf(endpoint, where),\n endpoint.openWorld,\n ),\n this.rootSchema(endpoint.request, where, 'request', undefined),\n this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription),\n endpoint.mcpTool!.profiles,\n );\n }\n\n /**\n * `operation` verbatim from the model, mapped back onto the REAL constant.\n *\n * A `switch` and not a cast, because the model carries the operation as a string and a cast would\n * hand `mcpHintsForOperation` a value it has no case for — which, for a function whose three arms\n * are exhaustive, means falling off the end and publishing a tool with NO hints.\n */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static operationOf(endpoint: DocumentedEndpoint, where: string): EndpointOperation {\n switch (endpoint.operation) {\n case READ:\n return READ;\n case WRITE_IDEMPOTENT:\n return WRITE_IDEMPOTENT;\n case WRITE:\n return WRITE;\n default:\n throw new McpRenderError(\n `@Endpoint declares operation '${endpoint.operation}', which has no MCP hints`,\n where,\n `Use one of the exported constants: ${READ}, ${WRITE_IDEMPOTENT}, ${WRITE}.`,\n );\n }\n }\n\n /**\n * A tool's input/output schema: always a CLOSED OBJECT, because MCP publishes objects — and\n * because a union at the ROOT of a tool schema is refused by the function-calling APIs that\n * consume it. Both OpenAI and Anthropic reject a top-level `oneOf`/`anyOf`/`allOf`, and a server\n * sends its WHOLE tool list on every request, so one such tool makes every request 400 and bricks\n * the session — not just that tool. Nested composition, inside a property, is fine.\n *\n * The build-time rule `no-root-union-api-type` refuses the same shape across every `@ApiPath`\n * contract in the workspace, `@ApiType` or not. This is the renderer's own backstop, so a catalog\n * can never carry one even if it is reached some other way.\n */\n private rootSchema(\n ref: TypeRef,\n where: string,\n side: string,\n returns: string | undefined,\n ): ApiJsonSchema {\n if (ref.kind === 'union') {\n throw new McpRenderError(\n `an MCP tool's ${side} is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n if (ref.kind !== 'ref') {\n throw new McpRenderError(\n `an MCP tool's ${side} is not a named DTO`,\n where,\n 'Give it a named interface or class. An inline or primitive ' +\n `${side} has no object schema, and MCP publishes objects.`,\n );\n }\n const type = this.namedType(ref.refName!, where);\n if (type.unionRefNames.length > 0) {\n throw new McpRenderError(\n `an MCP tool's ${side} '${type.name}' is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n const schema = this.objectSchema(type, new Set<string>());\n McpSchemaRenderer.describeRoot(schema, returns ?? type.description);\n return schema;\n }\n\n /**\n * The ROOT schema's `description` (#1292): the request DTO's JSDoc on `inputSchema`, and the\n * method's `@returns` sentence on `outputSchema` — the one slot a tool catalog has for \"what this\n * tool returns\", so an agent reads the same sentence a partner reads as the OpenAPI success\n * response's description. Falls back to the response DTO's own JSDoc when the method has no\n * `@returns`, which only a caller outside `wp-openapi` can reach: the generator refuses a tool\n * without one before any catalog is written. Nested DTOs keep the FIELD's prose (see\n * {@link fieldSchema}); only the root has no field to take it from.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static describeRoot(schema: ApiJsonSchema, prose: string): void {\n if (prose.trim() !== '') {\n schema.description = prose;\n }\n }\n\n private namedType(name: string, where: string): DocumentedType {\n const type = this.model.types.get(name);\n if (type === undefined) {\n throw new McpRenderError(\n `no model entry for type '${name}'`,\n where,\n 'Declare the type in a file the extractor reaches from this contract.',\n );\n }\n return type;\n }\n\n /**\n * One object DTO. CLOSED (`additionalProperties: false`), with `required` written only when it is\n * non-empty, so an all-optional DTO carries no empty list.\n *\n * The cycle stop is `parents`, and it THROWS rather than truncating: an inline schema cannot\n * express a recursive DTO, and one that silently stopped a level down would publish a shape the\n * server does not accept.\n */\n private objectSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n if (parents.has(type.name)) {\n throw new McpRenderError(\n `recursive DTO '${type.name}' cannot use an inline MCP schema`,\n type.name,\n 'Break the cycle, or keep this DTO out of the MCP document — a tool schema is ' +\n 'inline and has no $ref to close a loop with.',\n );\n }\n if (type.unionRefNames.length > 0) {\n return this.unionSchema(type, parents);\n }\n if (type.indexSignatureValue !== undefined && type.fields.length > 0) {\n throw new McpRenderError(\n `'${type.name}' has both named fields and an index signature`,\n type.name,\n 'Split the open map into a field of its own: a schema is either closed or a typed ' +\n 'map, and MCP has no spelling for half of each.',\n );\n }\n const nested = new Set(parents);\n nested.add(type.name);\n\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of type.fields) {\n schema.properties[field.name] = this.fieldSchema(type, field, nested);\n if (!field.optional) {\n required.push(field.name);\n }\n }\n if (required.length > 0) {\n schema.required = required;\n }\n return schema;\n }\n\n /**\n * A UNION, as `oneOf` with its branches INLINE and its DERIVED discriminator.\n *\n * MCP tool schemas are JSON Schema 2020-12 — the same dialect OpenAPI 3.1 uses — so `oneOf` was\n * never the obstacle; the obstacle was this repo's own subset, which had no spelling for it\n * (#1009). The shape written here MIRRORS `SchemaRenderer.union` in `@webpieces/openapi-generator`\n * branch for branch, because a union has ONE published spelling and that renderer is the\n * reference implementation of it. The only difference is the absence of `$ref`: a tool schema is\n * inline, so each branch is rendered in full and the discriminator maps to branch NAMES.\n *\n * `discriminator` is written ONLY when the model DERIVED one. A union TypeScript itself cannot\n * narrow is published as a bare `oneOf` rather than with an invented discriminator — claiming a\n * narrowing the source does not have is worse than admitting there is none.\n */\n private unionSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n const nested = new Set(parents);\n nested.add(type.name);\n const schema = new ApiJsonSchema();\n schema.oneOf = type.unionRefNames.map((name: string) =>\n this.objectSchema(this.namedType(name, type.name), nested),\n );\n if (type.description.trim() !== '') {\n schema.description = type.description;\n }\n if (type.discriminator !== undefined) {\n const mapping: Record<string, string> = {};\n for (const branch of type.unionRefNames) {\n // The branch's NAME, never its model key: a branch declared by another package is\n // keyed `<package>:<name>` (#1058), and the published mapping names the type.\n const branchName = this.namedType(branch, type.name).schemaName;\n for (const value of type.discriminator.branchValues.get(branch) ?? []) {\n mapping[value] = branchName;\n }\n }\n schema.discriminator = new ApiJsonSchemaDiscriminator(\n type.discriminator.propertyName,\n mapping,\n );\n }\n return schema;\n }\n\n /**\n * A FIELD whose type is a union: the model registers `type X = A | B` as its OWN entry carrying\n * the derived discriminator, while the field holds a bare list of branch names. Rendering that\n * list directly would publish the `oneOf` and silently DROP the discriminator — the one part of a\n * union a client needs to narrow on — so the alias is looked up by its branch list first. This is\n * the same lookup `SchemaRenderer.namedUnion` does to emit its `$ref`.\n */\n private fieldUnion(\n branchNames: readonly string[],\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const key = branchNames.join(',');\n for (const name of this.model.types.keys()) {\n const candidate = this.model.types.get(name)!;\n if (candidate.unionRefNames.length > 0 && candidate.unionRefNames.join(',') === key) {\n return this.unionSchema(candidate, parents);\n }\n }\n const schema = new ApiJsonSchema();\n schema.oneOf = branchNames.map((name: string) =>\n this.objectSchema(this.namedType(name, where), parents),\n );\n return schema;\n }\n\n /**\n * One FIELD: its type, then the prose and the constraints that hang off the field.\n *\n * The ORDER matters: the type is built first and `description` is written over whatever the type\n * produced, so a nested DTO carries the FIELD's sentence rather than the DTO's. `@WpMin` /\n * `@WpMax` land on the numeric LEAF — on an array, on the item — for the same reason\n * `SchemaRenderer` puts them there: a `minimum` on an array means nothing.\n *\n * NULLABLE widens the type to `[T, \"null\"]` and is deliberately NOT the same thing as OPTIONAL,\n * which is an absent entry in the object's `required` list. `{}` and `{externalId: null}` are\n * different wire documents, and an agent told only \"optional\" would send the wrong one.\n */\n private fieldSchema(\n owner: DocumentedType,\n field: DocumentedField,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const where = `${owner.name}.${field.name}`;\n const schema = this.typeSchema(field.type, where, parents);\n const description = field.mcpDescription ?? field.description;\n if (this.requireDescriptions && description.trim() === '') {\n throw new McpRenderError(\n 'a published DTO field has no documentation',\n where,\n 'Write a JSDoc sentence on the field. It is the only thing an agent is told about ' +\n 'that parameter.',\n );\n }\n schema.description = description;\n\n const leaf = field.type.kind === 'array' ? schema.items! : schema;\n if (field.min !== undefined) {\n leaf.minimum = field.min;\n }\n if (field.max !== undefined) {\n leaf.maximum = field.max;\n }\n if (field.mcpHeader !== undefined) {\n McpSchemaRenderer.assertHeaderFits(field, schema, where);\n schema['x-mcp-header'] = field.mcpHeader;\n }\n if (field.nullable) {\n schema.type = McpSchemaRenderer.nullable(schema, where);\n if (schema.enum !== undefined && !schema.enum.includes(null)) {\n // JSON Schema checks `enum` independently of `type`: without `null` here the widened\n // type admits null and the enum still rejects it, so a nullable string enum\n // (`x: SomeEnumDto | null`, or `'a' | 'b' | null`) failed output validation (#1197).\n schema.enum = [...schema.enum, null];\n }\n }\n return schema;\n }\n\n /** `T` -> `[T, \"null\"]`, refusing a field with no type at all rather than publishing `[\"null\"]`. */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static nullable(schema: ApiJsonSchema, where: string): readonly ApiJsonSchemaType[] {\n const base = ApiJsonSchema.baseTypeOf(schema);\n if (base === undefined) {\n throw new McpRenderError(\n 'a nullable field has no other type',\n where,\n 'A field typed only `null` carries no information — give it a real type beside it.',\n );\n }\n return [base, 'null'];\n }\n\n /**\n * `@mcpHeader` mirrors a PRIMITIVE parameter into `Mcp-Param-{name}` (MCP 2026 SEP-2243). The\n * three conditions are the runtime's, restated against the compiler's view of the field, so a\n * declaration the server would reject at boot fails the document build instead.\n */\n // webpieces-disable no-function-outside-class -- private static validator of this class\n private static assertHeaderFits(\n field: DocumentedField,\n schema: ApiJsonSchema,\n where: string,\n ): void {\n if (!HEADER_TOKEN.test(field.mcpHeader!)) {\n throw new McpRenderError(\n `@mcpHeader '${field.mcpHeader}' is not an RFC 9110 token`,\n where,\n 'Use letters, digits and the token punctuation only — it becomes an HTTP header name.',\n );\n }\n if (schema.type !== 'string' && schema.type !== 'boolean' && schema.type !== 'integer') {\n throw new McpRenderError(\n '@mcpHeader is on a field that is not a primitive an MCP header can carry',\n where,\n 'Mirror a string, a boolean or an Integer. A non-integer number and every object ' +\n 'shape are excluded by MCP 2026-07-28.',\n );\n }\n }\n\n /** One resolved type, with no field-level prose or constraints on it. */\n private typeSchema(ref: TypeRef, where: string, parents: ReadonlySet<string>): ApiJsonSchema {\n switch (ref.kind) {\n case 'primitive':\n return McpSchemaRenderer.primitive(ref, where);\n case 'enum': {\n const schema = new ApiJsonSchema('string');\n schema.enum = ref.enumValues.slice();\n return schema;\n }\n case 'array': {\n const schema = new ApiJsonSchema('array');\n schema.items = this.typeSchema(ref.items!, where, parents);\n return schema;\n }\n case 'openMap': {\n const schema = new ApiJsonSchema('object');\n schema.additionalProperties = this.typeSchema(ref.values!, where, parents);\n return schema;\n }\n case 'ref':\n return this.referencedSchema(ref.refName!, where, parents);\n case 'union':\n return this.fieldUnion(ref.unionRefNames, where, parents);\n default:\n throw new McpRenderError(\n `no MCP schema for the declared type '${ref.unmappedText ?? '<unknown>'}'`,\n where,\n 'Give the field a shape the model can represent — a named DTO, an array of one, ' +\n 'a string-literal union, a Record, or a primitive.',\n );\n }\n }\n\n /** A named type: a string enum becomes `enum`, an object DTO is INLINED (MCP has no `$ref`). */\n private referencedSchema(\n name: string,\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const type = this.namedType(name, where);\n if (type.enumValues.length > 0) {\n const schema = new ApiJsonSchema('string');\n schema.enum = type.enumValues.slice();\n return schema;\n }\n return this.objectSchema(type, parents);\n }\n\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static primitive(ref: TypeRef, where: string): ApiJsonSchema {\n if (ref.primitive === 'string' || ref.primitive === 'boolean') {\n return new ApiJsonSchema(ref.primitive);\n }\n if (ref.primitive === 'number') {\n return new ApiJsonSchema(ref.integer ? 'integer' : 'number');\n }\n throw new McpRenderError(\n `'${ref.primitive}' has no MCP schema`,\n where,\n 'Give the field a concrete type. `unknown`, `any`, `void` and a bare `null` publish as ' +\n '\"anything\", which an agent cannot fill in.',\n );\n }\n}\n"]}
|