@webpieces/api-doc-model 0.4.838 → 0.4.839

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/api-doc-model",
3
- "version": "0.4.838",
3
+ "version": "0.4.839",
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.838",
26
+ "@webpieces/core-util": "0.4.839",
27
27
  "typescript": "5.9.3"
28
28
  }
29
29
  }
@@ -13,6 +13,7 @@ const McpMembership_1 = require("./McpMembership");
13
13
  const ComponentsExtractor_1 = require("./ComponentsExtractor");
14
14
  const PackageOfFile_1 = require("./PackageOfFile");
15
15
  const TypeResolver_1 = require("./TypeResolver");
16
+ const StreamingSignature_1 = require("./StreamingSignature");
16
17
  /**
17
18
  * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as
18
19
  * string literals.
@@ -258,7 +259,8 @@ class ApiDocExtractor {
258
259
  const literal = options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;
259
260
  const doc = JsDoc_1.JsDoc.read(member);
260
261
  const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);
261
- 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, MCP_AUTH)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.mcp, this.requestOf(member, methodName, resolver), this.responseOf(member, methodName, resolver));
262
+ const streaming = new StreamingSignature_1.StreamingSignature().read(member, folder, resolver);
263
+ 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, MCP_AUTH)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.mcp, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming);
262
264
  }
263
265
  /**
264
266
  * 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,uDAAiC;AACjC,oDA2B8B;AAC9B,sDAS8B;AAE9B,mEAAgE;AAChE,qDAAkD;AAClD,mCAAgC;AAChC,qDAAkD;AAClD,mDAA+D;AAC/D,+DAA4D;AAC5D,mDAAgD;AAChD,iDAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;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,M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pAuthJwt,\n WpAuthLocalOnly,\n WpAuthOidc,\n WpAuthPublic,\n WpAuthSharedSecret,\n WpAuthWebhook,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpAuthJwt,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { JsDoc } from './JsDoc';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\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 MCP_AUTH = WpMcpAuthJwt.name;\nconst API_KEY_AUTH = WpAuthApiKey.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 */\nconst AUTH_PREFIX = 'WpAuth';\n\n/** Every credential decorator, by real symbol, so a rename of any of them fails to compile here. */\nconst AUTH_DECORATORS = new Set([\n WpAuthPublic.name,\n WpAuthJwt.name,\n WpAuthOidc.name,\n WpAuthSharedSecret.name,\n WpAuthWebhook.name,\n WpAuthApiKey.name,\n WpAuthLocalOnly.name,\n]);\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 /** 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);\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 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 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 JsDoc.read(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\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 );\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).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 = JsDoc.read(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\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, MCP_AUTH)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.mcp,\n this.requestOf(member, methodName, resolver),\n this.responseOf(member, methodName, resolver),\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 /** `@WpAuthPublic()`, `@WpAuthJwt({...})`, … — recorded verbatim; this package rules on nothing. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const decorators = ts.canHaveDecorators(member) ? (ts.getDecorators(member) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (!ts.isCallExpression(call) || !ts.isIdentifier(call.expression)) {\n continue;\n }\n const name = call.expression.text;\n if (name.startsWith(AUTH_PREFIX) && AUTH_DECORATORS.has(name)) {\n return new DocumentedAuth(\n name,\n call.arguments.map((argument: ts.Expression) => argument.getText()),\n name === API_KEY_AUTH ? ApiDocExtractor.apiKeyOf(call, folder) : undefined,\n );\n }\n }\n return undefined;\n }\n\n /**\n * `@WpAuthApiKey(regime, [{in: 'header', name: 'x-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 '@WpAuthApiKey needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: @WpAuthApiKey('partner', [{ in: 'header', name: 'x-api-key' }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, '@WpAuthApiKey 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 '@WpAuthApiKey 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 @WpAuthApiKey credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', name: 'x-api-key' }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an @WpAuthApiKey credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with a name, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.stringProperty(element, 'name', folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * `@WpMcpTool('search_stores')` — the stable protocol name, which is the ONE fact the source\n * cannot otherwise state.\n *\n * Nothing else is read because nothing else is declared there any more (#984): 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 return new DocumentedMcpTool(folder.tryFoldString(argument) ?? '');\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(\n member: ts.Node,\n folder: ConstantFolder,\n ): 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 ts.isIdentifier(call.expression) &&\n call.expression.text === 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":";;;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AI,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,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;gBAChC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,aAAa,EACxC,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAviBD,0CAuiBC","sourcesContent":["import * 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 WpAuthApiKey,\n WpAuthJwt,\n WpAuthLocalOnly,\n WpAuthOidc,\n WpAuthPublic,\n WpAuthSharedSecret,\n WpAuthWebhook,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpAuthJwt,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { JsDoc } from './JsDoc';\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 MCP_AUTH = WpMcpAuthJwt.name;\nconst API_KEY_AUTH = WpAuthApiKey.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 */\nconst AUTH_PREFIX = 'WpAuth';\n\n/** Every credential decorator, by real symbol, so a rename of any of them fails to compile here. */\nconst AUTH_DECORATORS = new Set([\n WpAuthPublic.name,\n WpAuthJwt.name,\n WpAuthOidc.name,\n WpAuthSharedSecret.name,\n WpAuthWebhook.name,\n WpAuthApiKey.name,\n WpAuthLocalOnly.name,\n]);\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 /** 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);\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 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 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 JsDoc.read(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\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 );\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).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 = JsDoc.read(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, MCP_AUTH)?.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 );\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 /** `@WpAuthPublic()`, `@WpAuthJwt({...})`, … — recorded verbatim; this package rules on nothing. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const decorators = ts.canHaveDecorators(member) ? (ts.getDecorators(member) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (!ts.isCallExpression(call) || !ts.isIdentifier(call.expression)) {\n continue;\n }\n const name = call.expression.text;\n if (name.startsWith(AUTH_PREFIX) && AUTH_DECORATORS.has(name)) {\n return new DocumentedAuth(\n name,\n call.arguments.map((argument: ts.Expression) => argument.getText()),\n name === API_KEY_AUTH ? ApiDocExtractor.apiKeyOf(call, folder) : undefined,\n );\n }\n }\n return undefined;\n }\n\n /**\n * `@WpAuthApiKey(regime, [{in: 'header', name: 'x-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 '@WpAuthApiKey needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: @WpAuthApiKey('partner', [{ in: 'header', name: 'x-api-key' }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, '@WpAuthApiKey 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 '@WpAuthApiKey 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 @WpAuthApiKey credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', name: 'x-api-key' }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an @WpAuthApiKey credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with a name, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.stringProperty(element, 'name', folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * `@WpMcpTool('search_stores')` — the stable protocol name, which is the ONE fact the source\n * cannot otherwise state.\n *\n * Nothing else is read because nothing else is declared there any more (#984): 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 return new DocumentedMcpTool(folder.tryFoldString(argument) ?? '');\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 ts.isIdentifier(call.expression) &&\n call.expression.text === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import * as ts from 'typescript';
2
+ import { TypeResolver } from './TypeResolver';
3
+ import { ConstantFolder } from './ConstantFolder';
4
+ import { DocumentedStreaming } from '../model/DocumentedStreaming';
5
+ /** Derives the four independent schema slots from the declaration, refusing every mismatched form. */
6
+ export declare class StreamingSignature {
7
+ read(method: ts.MethodDeclaration, folder: ConstantFolder, resolver: TypeResolver): DocumentedStreaming | undefined;
8
+ private direction;
9
+ private generic;
10
+ private requireDto;
11
+ private decorator;
12
+ private invalid;
13
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamingSignature = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const core_util_1 = require("@webpieces/core-util");
7
+ const SourceLocation_1 = require("./SourceLocation");
8
+ const ApiDocExtractionError_1 = require("./ApiDocExtractionError");
9
+ const DocumentedStreaming_1 = require("../model/DocumentedStreaming");
10
+ const FORMS = [
11
+ 'FULL: (InitialRequest, ResponseStream<ResponseEvent>) => Promise<RequestStream<InitialResponse, RequestEvent>>',
12
+ 'RESPONSE: (InitialRequest, ResponseStream<ResponseEvent>) => Promise<InitialResponse>',
13
+ 'REQUEST: (InitialRequest) => Promise<RequestStream<InitialResponse, RequestEvent>>',
14
+ ].join('\n');
15
+ /** Derives the four independent schema slots from the declaration, refusing every mismatched form. */
16
+ class StreamingSignature {
17
+ read(method, folder, resolver) {
18
+ const call = this.decorator(method);
19
+ if (!call)
20
+ return undefined;
21
+ const selected = this.direction(method, call, folder);
22
+ const initialRequest = method.parameters[0].type;
23
+ if (!initialRequest ||
24
+ method.parameters[0].questionToken ||
25
+ method.parameters[0].dotDotDotToken) {
26
+ this.invalid(method, selected, 'Parameter 1 must declare a required InitialRequest DTO.');
27
+ }
28
+ const returned = this.generic(method.type, 'Promise', 1, method, selected, 'return type')[0];
29
+ const requestTypes = selected === core_util_1.StreamDirection.RESPONSE
30
+ ? undefined
31
+ : this.generic(returned, 'RequestStream', 2, method, selected, 'return type');
32
+ const initialResponse = requestTypes ? requestTypes[0] : returned;
33
+ if (selected === core_util_1.StreamDirection.RESPONSE &&
34
+ ts.isTypeReferenceNode(returned) &&
35
+ ['RequestStream', 'ResponseStream'].includes(returned.typeName.getText())) {
36
+ this.invalid(method, selected, 'return type must resolve to InitialResponse, not a stream.');
37
+ }
38
+ this.requireDto(initialResponse, method, selected, 'initial response');
39
+ const responseEvent = selected === core_util_1.StreamDirection.REQUEST
40
+ ? undefined
41
+ : this.generic(method.parameters[1].type, 'ResponseStream', 1, method, selected, 'parameter 2')[0];
42
+ this.requireDto(initialRequest, method, selected, 'initial request');
43
+ if (requestTypes)
44
+ this.requireDto(requestTypes[1], method, selected, 'request event');
45
+ if (responseEvent)
46
+ this.requireDto(responseEvent, method, selected, 'response event');
47
+ const owner = method.name.getText();
48
+ return new DocumentedStreaming_1.DocumentedStreaming(selected, resolver.resolve(initialRequest, `${owner}.initialRequest`), resolver.resolve(initialResponse, `${owner}.initialResponse`), requestTypes ? resolver.resolve(requestTypes[1], `${owner}.requestEvent`) : undefined, responseEvent ? resolver.resolve(responseEvent, `${owner}.responseEvent`) : undefined);
49
+ }
50
+ direction(method, call, folder) {
51
+ if (call.arguments.length !== 1)
52
+ this.invalid(method, 'unknown', 'Decorator requires direction only.');
53
+ const direction = folder.foldString(call.arguments[0], '@WpStream direction');
54
+ if (!Object.values(core_util_1.StreamDirection).includes(direction)) {
55
+ this.invalid(method, direction, 'Unknown stream direction.');
56
+ }
57
+ const selected = direction;
58
+ const expected = selected === core_util_1.StreamDirection.REQUEST ? 1 : 2;
59
+ if (method.parameters.length !== expected) {
60
+ this.invalid(method, selected, `Expected ${expected} parameter(s); incorrect parameter ${expected + 1}.`);
61
+ }
62
+ return selected;
63
+ }
64
+ generic(node, name, count, method, direction, position) {
65
+ if (!node ||
66
+ !ts.isTypeReferenceNode(node) ||
67
+ node.typeName.getText() !== name ||
68
+ node.typeArguments?.length !== count) {
69
+ this.invalid(method, direction, `${position} must use ${name} with exactly ${count} generic type(s).`);
70
+ }
71
+ return node.typeArguments;
72
+ }
73
+ requireDto(node, method, direction, slot) {
74
+ if (node.kind === ts.SyntaxKind.VoidKeyword ||
75
+ node.kind === ts.SyntaxKind.NeverKeyword ||
76
+ node.kind === ts.SyntaxKind.AnyKeyword ||
77
+ node.kind === ts.SyntaxKind.UnknownKeyword ||
78
+ (ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword) ||
79
+ (ts.isUnionTypeNode(node) &&
80
+ node.types.some((part) => part.kind === ts.SyntaxKind.UndefinedKeyword ||
81
+ (ts.isLiteralTypeNode(part) &&
82
+ part.literal.kind === ts.SyntaxKind.NullKeyword))))
83
+ this.invalid(method, direction, `${slot} must be a non-null client-defined DTO type.`);
84
+ }
85
+ decorator(method) {
86
+ for (const decorator of ts.getDecorators(method) ?? []) {
87
+ const expression = decorator.expression;
88
+ if (ts.isCallExpression(expression) &&
89
+ expression.expression.getText() === core_util_1.WpStream.name)
90
+ return expression;
91
+ }
92
+ return undefined;
93
+ }
94
+ invalid(method, direction, reason) {
95
+ const owner = ts.isClassDeclaration(method.parent)
96
+ ? method.parent.name?.getText()
97
+ : '<anonymous>';
98
+ throw new ApiDocExtractionError_1.ApiDocExtractionError(`Invalid @WpStream(StreamDirection.${direction.toUpperCase()}) method ${owner}.${method.name.getText()}: ${reason}`, SourceLocation_1.SourceLocation.of(method), `Supported forms:\n${FORMS}`);
99
+ }
100
+ }
101
+ exports.StreamingSignature = StreamingSignature;
102
+ //# sourceMappingURL=StreamingSignature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingSignature.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/StreamingSignature.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,oDAAiE;AAGjE,qDAAkD;AAClD,mEAAgE;AAChE,sEAAmE;AAEnE,MAAM,KAAK,GAAG;IACV,gHAAgH;IAChH,uFAAuF;IACvF,oFAAoF;CACvF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,sGAAsG;AACtG,MAAa,kBAAkB;IAC3B,IAAI,CACA,MAA4B,EAC5B,MAAsB,EACtB,QAAsB;QAEtB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,IACI,CAAC,cAAc;YACf,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa;YAClC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,cAAc,EACrC,CAAC;YACC,IAAI,CAAC,OAAO,CACR,MAAM,EACN,QAAQ,EACR,yDAAyD,CAC5D,CAAC;QACN,CAAC;QAC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DAiKC","sourcesContent":["import * as ts from 'typescript';\nimport { StreamDirection, WpStream } from '@webpieces/core-util';\nimport { TypeResolver } from './TypeResolver';\nimport { ConstantFolder } from './ConstantFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { DocumentedStreaming } from '../model/DocumentedStreaming';\n\nconst FORMS = [\n 'FULL: (InitialRequest, ResponseStream<ResponseEvent>) => Promise<RequestStream<InitialResponse, RequestEvent>>',\n 'RESPONSE: (InitialRequest, ResponseStream<ResponseEvent>) => Promise<InitialResponse>',\n 'REQUEST: (InitialRequest) => Promise<RequestStream<InitialResponse, RequestEvent>>',\n].join('\\n');\n\n/** Derives the four independent schema slots from the declaration, refusing every mismatched form. */\nexport class StreamingSignature {\n read(\n method: ts.MethodDeclaration,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedStreaming | undefined {\n const call = this.decorator(method);\n if (!call) return undefined;\n const selected = this.direction(method, call, folder);\n const initialRequest = method.parameters[0].type;\n if (\n !initialRequest ||\n method.parameters[0].questionToken ||\n method.parameters[0].dotDotDotToken\n ) {\n this.invalid(\n method,\n selected,\n 'Parameter 1 must declare a required InitialRequest DTO.',\n );\n }\n const returned = this.generic(\n method.type,\n 'Promise',\n 1,\n method,\n selected,\n 'return type',\n )[0];\n const requestTypes =\n selected === StreamDirection.RESPONSE\n ? undefined\n : this.generic(returned, 'RequestStream', 2, method, selected, 'return type');\n const initialResponse = requestTypes ? requestTypes[0] : returned;\n if (\n selected === StreamDirection.RESPONSE &&\n ts.isTypeReferenceNode(returned) &&\n ['RequestStream', 'ResponseStream'].includes(returned.typeName.getText())\n ) {\n this.invalid(\n method,\n selected,\n 'return type must resolve to InitialResponse, not a stream.',\n );\n }\n this.requireDto(initialResponse, method, selected, 'initial response');\n const responseEvent =\n selected === StreamDirection.REQUEST\n ? undefined\n : this.generic(\n method.parameters[1].type,\n 'ResponseStream',\n 1,\n method,\n selected,\n 'parameter 2',\n )[0];\n this.requireDto(initialRequest, method, selected, 'initial request');\n if (requestTypes) this.requireDto(requestTypes[1], method, selected, 'request event');\n if (responseEvent) this.requireDto(responseEvent, method, selected, 'response event');\n const owner = method.name.getText();\n return new DocumentedStreaming(\n selected,\n resolver.resolve(initialRequest, `${owner}.initialRequest`),\n resolver.resolve(initialResponse, `${owner}.initialResponse`),\n requestTypes ? resolver.resolve(requestTypes[1], `${owner}.requestEvent`) : undefined,\n responseEvent ? resolver.resolve(responseEvent, `${owner}.responseEvent`) : undefined,\n );\n }\n\n private direction(\n method: ts.MethodDeclaration,\n call: ts.CallExpression,\n folder: ConstantFolder,\n ): StreamDirection {\n if (call.arguments.length !== 1)\n this.invalid(method, 'unknown', 'Decorator requires direction only.');\n const direction = folder.foldString(call.arguments[0], '@WpStream direction');\n if (!Object.values(StreamDirection).includes(direction as StreamDirection)) {\n this.invalid(method, direction, 'Unknown stream direction.');\n }\n const selected = direction as StreamDirection;\n const expected = selected === StreamDirection.REQUEST ? 1 : 2;\n if (method.parameters.length !== expected) {\n this.invalid(\n method,\n selected,\n `Expected ${expected} parameter(s); incorrect parameter ${expected + 1}.`,\n );\n }\n return selected;\n }\n\n private generic(\n node: ts.TypeNode | undefined,\n name: string,\n count: number,\n method: ts.MethodDeclaration,\n direction: string,\n position: string,\n ): readonly ts.TypeNode[] {\n if (\n !node ||\n !ts.isTypeReferenceNode(node) ||\n node.typeName.getText() !== name ||\n node.typeArguments?.length !== count\n ) {\n this.invalid(\n method,\n direction,\n `${position} must use ${name} with exactly ${count} generic type(s).`,\n );\n }\n return node.typeArguments;\n }\n\n private requireDto(\n node: ts.TypeNode,\n method: ts.MethodDeclaration,\n direction: string,\n slot: string,\n ): void {\n if (\n node.kind === ts.SyntaxKind.VoidKeyword ||\n node.kind === ts.SyntaxKind.NeverKeyword ||\n node.kind === ts.SyntaxKind.AnyKeyword ||\n node.kind === ts.SyntaxKind.UnknownKeyword ||\n (ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword) ||\n (ts.isUnionTypeNode(node) &&\n node.types.some(\n (part: ts.TypeNode): boolean =>\n part.kind === ts.SyntaxKind.UndefinedKeyword ||\n (ts.isLiteralTypeNode(part) &&\n part.literal.kind === ts.SyntaxKind.NullKeyword),\n ))\n )\n this.invalid(method, direction, `${slot} must be a non-null client-defined DTO type.`);\n }\n\n private decorator(method: ts.MethodDeclaration): ts.CallExpression | undefined {\n for (const decorator of ts.getDecorators(method) ?? []) {\n const expression = decorator.expression;\n if (\n ts.isCallExpression(expression) &&\n expression.expression.getText() === WpStream.name\n )\n return expression;\n }\n return undefined;\n }\n\n private invalid(method: ts.MethodDeclaration, direction: string, reason: string): never {\n const owner = ts.isClassDeclaration(method.parent)\n ? method.parent.name?.getText()\n : '<anonymous>';\n throw new ApiDocExtractionError(\n `Invalid @WpStream(StreamDirection.${direction.toUpperCase()}) method ${owner}.${method.name.getText()}: ${reason}`,\n SourceLocation.of(method),\n `Supported forms:\\n${FORMS}`,\n );\n }\n}\n"]}
package/src/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export { McpRenderError } from './render/McpRenderError';
16
16
  export { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';
17
17
  export { TypeRef } from './model/TypeRef';
18
18
  export type { PrimitiveKind, TypeRefKind } from './model/TypeRef';
19
+ export { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeRef = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ApiDocExtractionError = exports.ApiDocExtractor = void 0;
3
+ exports.StreamingSchemaRenderer = exports.TypeRef = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ApiDocExtractionError = exports.ApiDocExtractor = void 0;
4
4
  /**
5
5
  * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and
6
6
  * produce ONE in-memory {@link ApiDocModel}.
@@ -40,4 +40,6 @@ Object.defineProperty(exports, "McpSchemaRenderer", { enumerable: true, get: fun
40
40
  Object.defineProperty(exports, "SkippedMcpTool", { enumerable: true, get: function () { return McpSchemaRenderer_1.SkippedMcpTool; } });
41
41
  var TypeRef_1 = require("./model/TypeRef");
42
42
  Object.defineProperty(exports, "TypeRef", { enumerable: true, get: function () { return TypeRef_1.TypeRef; } });
43
+ var StreamingSchemaRenderer_1 = require("./render/StreamingSchemaRenderer");
44
+ Object.defineProperty(exports, "StreamingSchemaRenderer", { enumerable: true, get: function () { return StreamingSchemaRenderer_1.StreamingSchemaRenderer; } });
43
45
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAc6B;AAbzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2CAA0C;AAAjC,kGAAA,OAAO,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAc6B;AAbzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,4EAA2E;AAAlE,kIAAA,uBAAuB,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\nexport { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';\n"]}
@@ -1,4 +1,5 @@
1
1
  import { TypeRef } from './TypeRef';
2
+ import type { DocumentedStreaming } from './DocumentedStreaming';
2
3
  /**
3
4
  * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —
4
5
  * these are data-only structures, and a renderer (#982) builds nothing, it only reads.
@@ -367,6 +368,7 @@ export declare class DocumentedEndpoint {
367
368
  readonly mcpDescription: string | undefined;
368
369
  readonly request: TypeRef | undefined;
369
370
  readonly response: TypeRef | undefined;
371
+ readonly streaming?: DocumentedStreaming | undefined;
370
372
  constructor(methodName: string,
371
373
  /**
372
374
  * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
@@ -407,7 +409,7 @@ export declare class DocumentedEndpoint {
407
409
  /** `@MaskLog({...})` — field name -> mask mode. */
408
410
  maskLog: ReadonlyMap<string, string>, description: string,
409
411
  /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
410
- mcpDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined);
412
+ mcpDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined, streaming?: DocumentedStreaming | undefined);
411
413
  }
412
414
  /** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
413
415
  export declare class ApiDocModel {
@@ -323,6 +323,7 @@ class DocumentedEndpoint {
323
323
  mcpDescription;
324
324
  request;
325
325
  response;
326
+ streaming;
326
327
  constructor(methodName,
327
328
  /**
328
329
  * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
@@ -363,7 +364,7 @@ class DocumentedEndpoint {
363
364
  /** `@MaskLog({...})` — field name -> mask mode. */
364
365
  maskLog, description,
365
366
  /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
366
- mcpDescription, request, response) {
367
+ mcpDescription, request, response, streaming) {
367
368
  this.methodName = methodName;
368
369
  this.httpMethod = httpMethod;
369
370
  this.path = path;
@@ -381,6 +382,7 @@ class DocumentedEndpoint {
381
382
  this.mcpDescription = mcpDescription;
382
383
  this.request = request;
383
384
  this.response = response;
385
+ this.streaming = streaming;
384
386
  }
385
387
  }
386
388
  exports.DocumentedEndpoint = DocumentedEndpoint;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;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,wGAAwG;AACxG,MAAa,kBAAkB;IAGd;IAQA;IAVb;IACI,yCAAyC;IAChC,YAAoB;IAC7B;;;;;;OAMG;IACM,YAAoD;QARpD,iBAAY,GAAZ,YAAY,CAAQ;QAQpB,iBAAY,GAAZ,YAAY,CAAwC;IAC9D,CAAC;CACP;AAbD,gDAaC;AAED,4BAA4B;AAC5B,MAAa,eAAe;IA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;IACpC,yFAAyF;IAChF,KAA0C,EAC1C,QAAiC,EACjC,UAAwC;QARxC,gBAAW,GAAX,WAAW,CAAQ;QAEnB,mBAAc,GAAd,cAAc,CAAQ;QAEtB,aAAQ,GAAR,QAAQ,CAAmB;QAE3B,UAAK,GAAL,KAAK,CAAqC;QAC1C,aAAQ,GAAR,QAAQ,CAAyB;QACjC,eAAU,GAAV,UAAU,CAA8B;IAClD,CAAC;CACP;AAbD,gDAaC","sourcesContent":["import { TypeRef } from './TypeRef';\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/** 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 ) {}\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(name: string, packageName: string | undefined, homePackage: string | undefined): 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')` declaration, when the method carries one — the ONE fact the\n * 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, which left the decorator holding one field, so it takes the\n * name as a plain string.\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}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', name: 'x-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', name: 'x-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 /** The header name. Undefined for `bearer`, whose location IS `Authorization`. */\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/** `@WpAuthApiKey(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/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */\nexport class DocumentedAuth {\n constructor(\n /** The decorator name as written, e.g. `WpAuthJwt`. */\n readonly decorator: string,\n /** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */\n readonly argumentTexts: readonly string[],\n /**\n * The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's\n * argument is prose or a role list that a document quotes rather than restructures, so\n * {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why\n * this one is different.\n */\n readonly apiKey: DocumentedApiKey | undefined,\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 /** `@WpMcpAuthJwt(...)`'s argument text, when present. */\n readonly mcpAuthText: 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 ) {}\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 ) {}\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 ) {}\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,MAAM,CAAQ;IACxB,CAAC;CACP;AATD,oCASC;AAED,wGAAwG;AACxG,MAAa,kBAAkB;IAGd;IAQA;IAVb;IACI,yCAAyC;IAChC,YAAoB;IAC7B;;;;;;OAMG;IACM,YAAoD;QARpD,iBAAY,GAAZ,YAAY,CAAQ;QAQpB,iBAAY,GAAZ,YAAY,CAAwC;IAC9D,CAAC;CACP;AAbD,gDAaC;AAED,4BAA4B;AAC5B,MAAa,eAAe;IAEX;IACA;IAMA;IAEA;IAEA;IAMA;IAEA;IAEA;IAEA;IAUA;IAUA;IA5Cb,YACa,IAAY,EACZ,IAAa;IACtB;;;;OAIG;IACM,QAAiB;IAC1B,sFAAsF;IAC7E,QAAiB;IAC1B,uEAAuE;IAC9D,WAAmB;IAC5B;;;;OAIG;IACM,cAAkC;IAC3C,8EAA8E;IACrE,MAA0B;IACnC,2EAA2E;IAClE,GAAuB;IAChC,2EAA2E;IAClE,GAAuB;IAChC;;;;;;;;OAQG;IACM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C;CACP;AAbD,gDAaC","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/** 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 ) {}\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')` declaration, when the method carries one — the ONE fact the\n * 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, which left the decorator holding one field, so it takes the\n * name as a plain string.\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}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', name: 'x-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', name: 'x-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 /** The header name. Undefined for `bearer`, whose location IS `Authorization`. */\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/** `@WpAuthApiKey(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/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */\nexport class DocumentedAuth {\n constructor(\n /** The decorator name as written, e.g. `WpAuthJwt`. */\n readonly decorator: string,\n /** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */\n readonly argumentTexts: readonly string[],\n /**\n * The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's\n * argument is prose or a role list that a document quotes rather than restructures, so\n * {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why\n * this one is different.\n */\n readonly apiKey: DocumentedApiKey | undefined,\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 /** `@WpMcpAuthJwt(...)`'s argument text, when present. */\n readonly mcpAuthText: 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 ) {}\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 ) {}\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 ) {}\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { StreamDirection } from '@webpieces/core-util';
2
+ import { TypeRef } from './TypeRef';
3
+ /** Direction and DTO slots derived from a streaming declaration, independent of extraction. */
4
+ export declare class DocumentedStreaming {
5
+ readonly direction: StreamDirection;
6
+ readonly initialRequest: TypeRef;
7
+ readonly initialResponse: TypeRef;
8
+ readonly requestEvent: TypeRef | undefined;
9
+ readonly responseEvent: TypeRef | undefined;
10
+ constructor(direction: StreamDirection, initialRequest: TypeRef, initialResponse: TypeRef, requestEvent: TypeRef | undefined, responseEvent: TypeRef | undefined);
11
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentedStreaming = void 0;
4
+ /** Direction and DTO slots derived from a streaming declaration, independent of extraction. */
5
+ class DocumentedStreaming {
6
+ direction;
7
+ initialRequest;
8
+ initialResponse;
9
+ requestEvent;
10
+ responseEvent;
11
+ constructor(direction, initialRequest, initialResponse, requestEvent, responseEvent) {
12
+ this.direction = direction;
13
+ this.initialRequest = initialRequest;
14
+ this.initialResponse = initialResponse;
15
+ this.requestEvent = requestEvent;
16
+ this.responseEvent = responseEvent;
17
+ }
18
+ }
19
+ exports.DocumentedStreaming = DocumentedStreaming;
20
+ //# sourceMappingURL=DocumentedStreaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentedStreaming.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/DocumentedStreaming.ts"],"names":[],"mappings":";;;AAGA,+FAA+F;AAC/F,MAAa,mBAAmB;IAEf;IACA;IACA;IACA;IACA;IALb,YACa,SAA0B,EAC1B,cAAuB,EACvB,eAAwB,EACxB,YAAiC,EACjC,aAAkC;QAJlC,cAAS,GAAT,SAAS,CAAiB;QAC1B,mBAAc,GAAd,cAAc,CAAS;QACvB,oBAAe,GAAf,eAAe,CAAS;QACxB,iBAAY,GAAZ,YAAY,CAAqB;QACjC,kBAAa,GAAb,aAAa,CAAqB;IAC5C,CAAC;CACP;AARD,kDAQC","sourcesContent":["import { StreamDirection } from '@webpieces/core-util';\nimport { TypeRef } from './TypeRef';\n\n/** Direction and DTO slots derived from a streaming declaration, independent of extraction. */\nexport class DocumentedStreaming {\n constructor(\n readonly direction: StreamDirection,\n readonly initialRequest: TypeRef,\n readonly initialResponse: TypeRef,\n readonly requestEvent: TypeRef | undefined,\n readonly responseEvent: TypeRef | undefined,\n ) {}\n}\n"]}
@@ -1,5 +1,6 @@
1
- import { McpToolCatalogFile, McpToolDefinition } from '@webpieces/core-util';
1
+ import { ApiJsonSchema, McpToolCatalogFile, McpToolDefinition } from '@webpieces/core-util';
2
2
  import { ApiDocModel, DocumentedEndpoint } from '../model/ApiDocModel';
3
+ import { TypeRef } from '../model/TypeRef';
3
4
  /** ONE `@WpMcpTool` the build could not give a schema, and why. See {@link McpSchemaRenderer.catalogOf}. */
4
5
  export declare class SkippedMcpTool {
5
6
  /** The stable protocol name it declared. */
@@ -51,7 +52,10 @@ export declare class McpCatalogRender {
51
52
  */
52
53
  export declare class McpSchemaRenderer {
53
54
  private readonly model;
54
- constructor(model: ApiDocModel);
55
+ private readonly requireDescriptions;
56
+ constructor(model: ApiDocModel, requireDescriptions?: boolean);
57
+ /** The shared inline runtime schema projection, also used by streaming catalog generation. */
58
+ schemaFor(ref: TypeRef, where: string): ApiJsonSchema;
55
59
  /** Every `@WpMcpTool` method of the contract, in declaration order. */
56
60
  render(): readonly McpToolDefinition[];
57
61
  /**
@@ -65,8 +65,14 @@ exports.McpCatalogRender = McpCatalogRender;
65
65
  */
66
66
  class McpSchemaRenderer {
67
67
  model;
68
- constructor(model) {
68
+ requireDescriptions;
69
+ constructor(model, requireDescriptions = true) {
69
70
  this.model = model;
71
+ this.requireDescriptions = requireDescriptions;
72
+ }
73
+ /** The shared inline runtime schema projection, also used by streaming catalog generation. */
74
+ schemaFor(ref, where) {
75
+ return this.typeSchema(ref, where, new Set());
70
76
  }
71
77
  /** Every `@WpMcpTool` method of the contract, in declaration order. */
72
78
  render() {
@@ -321,7 +327,7 @@ class McpSchemaRenderer {
321
327
  const where = `${owner.name}.${field.name}`;
322
328
  const schema = this.typeSchema(field.type, where, parents);
323
329
  const description = field.mcpDescription ?? field.description;
324
- if (description.trim() === '') {
330
+ if (this.requireDescriptions && description.trim() === '') {
325
331
  throw new McpRenderError_1.McpRenderError('a published DTO field has no documentation', where, 'Write a JSDoc sentence on the field. It is the only thing an agent is told about ' +
326
332
  'that parameter.');
327
333
  }
@@ -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;IACG;IAA7B,YAA6B,KAAkB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AAC,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;AApdD,8CAodC","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\"]`. `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(private readonly model: ApiDocModel) {}\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('...') 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 return new McpToolDefinition(\n endpoint.mcpTool!.name,\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 );\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).name;\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 (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 }\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.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,K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,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;AA5dD,8CA4dC","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\"]`. `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('...') 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 return new McpToolDefinition(\n endpoint.mcpTool!.name,\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 );\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).name;\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 }\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"]}
@@ -0,0 +1,6 @@
1
+ import { StreamingSchemaCatalog } from '@webpieces/core-util';
2
+ import { ApiDocModel } from '../model/ApiDocModel';
3
+ /** Emits the runtime schemas derived by the same model used for API documentation. */
4
+ export declare class StreamingSchemaRenderer {
5
+ render(model: ApiDocModel): StreamingSchemaCatalog;
6
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamingSchemaRenderer = void 0;
4
+ const core_util_1 = require("@webpieces/core-util");
5
+ const McpSchemaRenderer_1 = require("./McpSchemaRenderer");
6
+ /** Emits the runtime schemas derived by the same model used for API documentation. */
7
+ class StreamingSchemaRenderer {
8
+ render(model) {
9
+ const schemas = new McpSchemaRenderer_1.McpSchemaRenderer(model, false);
10
+ const methods = {};
11
+ for (const endpoint of model.endpoints) {
12
+ const stream = endpoint.streaming;
13
+ if (!stream)
14
+ continue;
15
+ const where = `${model.contractName}.${endpoint.methodName}`;
16
+ methods[endpoint.methodName] = new core_util_1.StreamingEndpointMetadata(stream.direction, schemas.schemaFor(stream.initialRequest, `${where}.initialRequest`), schemas.schemaFor(stream.initialResponse, `${where}.initialResponse`), stream.requestEvent
17
+ ? schemas.schemaFor(stream.requestEvent, `${where}.requestEvent`)
18
+ : undefined, stream.responseEvent
19
+ ? schemas.schemaFor(stream.responseEvent, `${where}.responseEvent`)
20
+ : undefined);
21
+ }
22
+ return new core_util_1.StreamingSchemaCatalog(model.contractName, methods);
23
+ }
24
+ }
25
+ exports.StreamingSchemaRenderer = StreamingSchemaRenderer;
26
+ //# sourceMappingURL=StreamingSchemaRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingSchemaRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/render/StreamingSchemaRenderer.ts"],"names":[],"mappings":";;;AAAA,oDAAyF;AAEzF,2DAAwD;AAExD,sFAAsF;AACtF,MAAa,uBAAuB;IAChC,MAAM,CAAC,KAAkB;QACrB,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpD,MAAM,OAAO,GAA8C,EAAE,CAAC;QAC9D,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC;YAClC,IAAI,CAAC,MAAM;gBAAE,SAAS;YACtB,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC,YAAY,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,qCAAyB,CACxD,MAAM,CAAC,SAAS,EAChB,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,KAAK,iBAAiB,CAAC,EACnE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,GAAG,KAAK,kBAAkB,CAAC,EACrE,MAAM,CAAC,YAAY;gBACf,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,KAAK,eAAe,CAAC;gBACjE,CAAC,CAAC,SAAS,EACf,MAAM,CAAC,aAAa;gBAChB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,KAAK,gBAAgB,CAAC;gBACnE,CAAC,CAAC,SAAS,CAClB,CAAC;QACN,CAAC;QACD,OAAO,IAAI,kCAAsB,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACJ;AAtBD,0DAsBC","sourcesContent":["import { StreamingEndpointMetadata, StreamingSchemaCatalog } from '@webpieces/core-util';\nimport { ApiDocModel } from '../model/ApiDocModel';\nimport { McpSchemaRenderer } from './McpSchemaRenderer';\n\n/** Emits the runtime schemas derived by the same model used for API documentation. */\nexport class StreamingSchemaRenderer {\n render(model: ApiDocModel): StreamingSchemaCatalog {\n const schemas = new McpSchemaRenderer(model, false);\n const methods: Record<string, StreamingEndpointMetadata> = {};\n for (const endpoint of model.endpoints) {\n const stream = endpoint.streaming;\n if (!stream) continue;\n const where = `${model.contractName}.${endpoint.methodName}`;\n methods[endpoint.methodName] = new StreamingEndpointMetadata(\n stream.direction,\n schemas.schemaFor(stream.initialRequest, `${where}.initialRequest`),\n schemas.schemaFor(stream.initialResponse, `${where}.initialResponse`),\n stream.requestEvent\n ? schemas.schemaFor(stream.requestEvent, `${where}.requestEvent`)\n : undefined,\n stream.responseEvent\n ? schemas.schemaFor(stream.responseEvent, `${where}.responseEvent`)\n : undefined,\n );\n }\n return new StreamingSchemaCatalog(model.contractName, methods);\n }\n}\n"]}