@webpieces/api-doc-model 0.4.934 → 0.4.935
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/README.md +1 -1
- package/package.json +2 -2
- package/src/extract/ApiDocExtractor.d.ts +4 -4
- package/src/extract/ApiDocExtractor.js +6 -8
- package/src/extract/ApiDocExtractor.js.map +1 -1
- package/src/extract/JsDoc.d.ts +16 -4
- package/src/extract/JsDoc.js +29 -6
- package/src/extract/JsDoc.js.map +1 -1
- package/src/extract/McpMembership.js +2 -2
- package/src/extract/McpMembership.js.map +1 -1
- package/src/extract/McpProfiles.js +7 -0
- package/src/extract/McpProfiles.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +20 -15
- package/src/model/ApiDocModel.js +15 -12
- package/src/model/ApiDocModel.js.map +1 -1
- package/src/model/EndpointSummary.d.ts +20 -0
- package/src/model/EndpointSummary.js +44 -0
- package/src/model/EndpointSummary.js.map +1 -0
- package/src/render/McpSchemaRenderer.js +11 -7
- package/src/render/McpSchemaRenderer.js.map +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ const models = new ApiDocExtractor().extractAll('/abs/path/to/Fixtures.ts', opti
|
|
|
39
39
|
|
|
40
40
|
const tools = new McpSchemaRenderer(models[0]).render();
|
|
41
41
|
tools[0].name; // the stable protocol name from @WpMcpTool
|
|
42
|
-
tools[0].title; // the REQUIRED human-readable title
|
|
42
|
+
tools[0].title; // the REQUIRED human-readable title: the method's @summary JSDoc tag (#1296)
|
|
43
43
|
tools[0].description; // the method's JSDoc body, or its `@mcp` tag
|
|
44
44
|
tools[0].hints; // three computed from `operation`, openWorldHint from @Endpoint's options
|
|
45
45
|
tools[0].inputSchema; // ApiJsonSchema — what tools/list publishes and the server validates against
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/api-doc-model",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.935",
|
|
4
4
|
"description": "TypeScript-compiler-API extractor producing one in-memory ApiDocModel from a webpieces API contract. No renderer, no runtime, no app-specific import.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
26
|
+
"@webpieces/core-util": "0.4.935",
|
|
27
27
|
"typescript": "5.9.3",
|
|
28
28
|
"minimatch": "10.0.1"
|
|
29
29
|
}
|
|
@@ -134,11 +134,11 @@ export declare class ApiDocExtractor {
|
|
|
134
134
|
*/
|
|
135
135
|
private static headerOf;
|
|
136
136
|
/**
|
|
137
|
-
* `@WpMcpTool('search_stores'
|
|
138
|
-
*
|
|
139
|
-
*
|
|
137
|
+
* `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot
|
|
138
|
+
* otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest
|
|
139
|
+
* of its prose; the decorator carries none.
|
|
140
140
|
*
|
|
141
|
-
* Profile membership is read from the optional
|
|
141
|
+
* Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc
|
|
142
142
|
* is the description for the agent and the partner alike, the three side-effect hints are computed
|
|
143
143
|
* from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See
|
|
144
144
|
* {@link DocumentedMcpTool}.
|
|
@@ -299,7 +299,7 @@ class ApiDocExtractor {
|
|
|
299
299
|
const doc = resolver.readDoc(member);
|
|
300
300
|
const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);
|
|
301
301
|
const streaming = new StreamingSignature_1.StreamingSignature().read(member, folder, resolver);
|
|
302
|
-
return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.mcp, doc.returns, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming, ApiDocExtractor.decoratorCall(member, core_util_1.WpLocalOnly.name) !== undefined);
|
|
302
|
+
return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.summary, doc.mcp, doc.returns, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming, ApiDocExtractor.decoratorCall(member, core_util_1.WpLocalOnly.name) !== undefined);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
* One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.
|
|
@@ -463,11 +463,11 @@ class ApiDocExtractor {
|
|
|
463
463
|
return new ContextKeyHeaderFolder_1.ContextKeyHeaderFolder(folder).fold(key, ContextKeyHeaderFolder_1.ContextKeyHeaderSlot.REQUEST, "the apiKey(...) header credential's key");
|
|
464
464
|
}
|
|
465
465
|
/**
|
|
466
|
-
* `@WpMcpTool('search_stores'
|
|
467
|
-
*
|
|
468
|
-
*
|
|
466
|
+
* `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot
|
|
467
|
+
* otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest
|
|
468
|
+
* of its prose; the decorator carries none.
|
|
469
469
|
*
|
|
470
|
-
* Profile membership is read from the optional
|
|
470
|
+
* Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc
|
|
471
471
|
* is the description for the agent and the partner alike, the three side-effect hints are computed
|
|
472
472
|
* from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See
|
|
473
473
|
* {@link DocumentedMcpTool}.
|
|
@@ -479,9 +479,7 @@ class ApiDocExtractor {
|
|
|
479
479
|
if (argument === undefined) {
|
|
480
480
|
return undefined;
|
|
481
481
|
}
|
|
482
|
-
|
|
483
|
-
const title = titleArgument === undefined ? '' : (folder.tryFoldString(titleArgument) ?? '');
|
|
484
|
-
return new ApiDocModel_1.DocumentedMcpTool(folder.tryFoldString(argument) ?? '', title, new McpProfiles_1.McpProfiles().read(call?.arguments[2], folder));
|
|
482
|
+
return new ApiDocModel_1.DocumentedMcpTool(folder.tryFoldString(argument) ?? '', new McpProfiles_1.McpProfiles().read(call?.arguments[1], folder));
|
|
485
483
|
}
|
|
486
484
|
/**
|
|
487
485
|
* `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,sDAAmD;AACnD,+CAA4C;AAC5C,uDAAiC;AACjC,oDAqB8B;AAC9B,sDAU8B;AAE9B,mEAAgE;AAChE,qDAAkD;AAClD,qEAAwF;AACxF,qDAAkD;AAClD,mDAA+D;AAC/D,+DAA4D;AAC5D,mDAAgD;AAChD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CAAC;gBACrE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAC7B,CAAC;gBACC,OAAO,QAAQ,CAAC,WAAW,CAAC;YAChC,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,aAAa,CACxB,IAAa,EACb,aAAqB;QAErB,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC;YAClC,IACI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,aAAa,EACtE,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AApqBD,0CAoqBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport { McpProfiles } from './McpProfiles';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL,\n GET,\n MaskLog,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n WpAuthPublic,\n WpAuth, WpAuthorization, WpLocalOnly, apiKey,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ContextKeyHeaderFolder, ContextKeyHeaderSlot } from './ContextKeyHeaderFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\nimport { StreamingSignature } from './StreamingSignature';\n\n/**\n * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as\n * string literals.\n *\n * ## Why `.name` and not `'Endpoint'`\n *\n * The extractor matches decorators by NAME on the syntax — it must, because it reads a contract with\n * the compiler and never executes it. The question is only where that name comes from, and a literal\n * has a silent failure mode that a symbol does not: rename `@WpMcpTool` in `core-util` and a literal\n * simply stops matching. The extractor then finds zero MCP tools, the MCP document is correctly not\n * written because it has no tools in it, and the BUILD IS GREEN. A partner-facing document silently\n * loses a section with nothing red anywhere (issue #1001).\n *\n * `Endpoint.name` makes that rename a COMPILE ERROR here, which in this repo is the delivery\n * mechanism for a migration rather than an obstacle to one: a compile break names the new spelling\n * and an agent applies it in one pass, where a green build teaches nobody anything.\n *\n * ## Why importing `@webpieces/core-util` is not the coupling it looks like\n *\n * Any contract carrying `@Endpoint` already depends on `core-util` by definition, so there is no\n * upstream project this import could shut out. It is build-time only, it creates no cycle, and it\n * costs a browser bundle nothing because nothing in a bundle imports this package. The direction that\n * WOULD be fatal is `core-util` depending on the TypeScript compiler, and that is not this.\n */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MASK_LOG = MaskLog.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\nconst AUTHORIZATION = WpAuthorization.name;\nconst API_KEY_AUTH = apiKey.name;\nconst API_TYPE = ApiType.name;\n\n/**\n * The prefix shared by every credential decorator. A PREFIX genuinely has no symbol to take a name\n * from, so it stays a literal — but the set it selects is pinned below, which is what stops it\n * quietly matching nothing.\n */\n/** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */\nconst ENDPOINT_KINDS: readonly string[] = [RPC, CLOUDTASKS, CRON, EXTERNAL];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = [GET, POST];\n\n/** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */\nconst ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];\n\n/** The allowed values of each required position, in the same order, for the same failure. */\nconst ARGUMENT_VALUES: readonly (readonly string[])[] = [\n HTTP_METHODS,\n [],\n ENDPOINT_OPERATIONS,\n ENDPOINT_KINDS,\n];\n\n/** The REAL document types, so a contract cannot name a document that does not exist. */\nconst API_TYPES: readonly string[] = [SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP];\n\n/** The fail-closed default: a contract that declares nothing feeds only the internal document. */\nconst DEFAULT_API_TYPES: readonly string[] = [SVC_TO_SVC];\n\n/**\n * ONE contract file -> ONE {@link ApiDocModel}. The single extraction pass both the OpenAPI documents\n * and the MCP tool list (#982) are rendered from.\n *\n * ## Why the compiler API at all\n *\n * A DTO field's TYPE IS ERASED AT RUNTIME. Reflection can see that `save` takes one argument; it\n * cannot see that the argument has a `deliveryWindow` that is a discriminated union of two shapes,\n * one of which carries an ISO timestamp. Those are precisely the shapes a partner-grade document is\n * made of, so the only place they exist is the source, and the only honest way to read the source is\n * the compiler.\n *\n * ## Why it IMPORTS `@webpieces/core-util`\n *\n * Decorators are matched BY NAME on the syntax — they must be, because this reads a contract and\n * never executes it. The NAMES come from the real symbols (`Endpoint.name`), so a rename in\n * `core-util` is a compile error here instead of a literal that quietly stops matching. The full\n * argument, and why the import is not the coupling it looks like, is at those constants.\n *\n * ## What it does NOT do\n *\n * It emits nothing. No OpenAPI, no MCP tool definitions, no file — that is #982, and keeping the\n * render out means the two renderers cannot drift apart about what the contract SAYS.\n */\nexport class ApiDocExtractor {\n constructor(private readonly schemaNames: SchemaNames = new SchemaNames([])) {}\n /** Which package declares each file — the owner of every schema (#1058). Cached per directory. */\n private readonly packages = new PackageOfFile();\n /** A resolver whose HOME is the package declaring `source` — see {@link TypeResolver}. */\n private resolverFor(program: ts.Program, source: ts.SourceFile): TypeResolver {\n const home = this.packages.of(source.fileName)?.name;\n return new TypeResolver(program.getTypeChecker(), this.packages, home, this.schemaNames);\n }\n\n /**\n * Extract the contract in `entryFile`.\n *\n * @param entryFile absolute path to the `.ts` file holding the `@ApiPath` class.\n * @param compilerOptions handed straight to `ts.createProgram`; the caller owns them because\n * only the caller knows its own `paths` / `lib` setup.\n * @throws ApiDocExtractionError when the file holds no `@ApiPath` class, or when something that\n * must be exact (a path constant, a numeric bound) cannot be established.\n */\n extractFile(entryFile: string, compilerOptions: ts.CompilerOptions = {}): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extract(program, source);\n }\n\n /**\n * EVERY `@ApiPath` contract in one file, in declaration order.\n *\n * {@link extractFile} answers \"what is THE contract in this file\", which is the shape a manifest\n * entry and a generated document have: one contract, one file. This answers a different question\n * — \"what does this file declare\" — and it exists because a REPO does not obey that convention.\n * `McpRemoteFixtures.ts` in `@webpieces/mcp-server` declares seven contracts, and the runtime\n * registers MCP tools from all seven; a sweep that read only the first would report green while\n * six contracts' worth of tools had never been looked at, which is the exact shape of silent miss\n * this epic exists to remove.\n *\n * A file with no contract yields an EMPTY list rather than throwing: \"this file has none\" is an\n * ordinary answer to this question, where it is a failure to answer {@link extractFile}'s.\n */\n extractAll(\n entryFile: string,\n compilerOptions: ts.CompilerOptions = {},\n ): readonly ApiDocModel[] {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extractAllFrom(program, source);\n }\n\n /** {@link extractAll} against a program the caller already built. */\n extractAllFrom(program: ts.Program, source: ts.SourceFile): readonly ApiDocModel[] {\n // Binding establishes AST parent links used by canonical import resolution.\n program.getTypeChecker();\n const models: ApiDocModel[] = [];\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n models.push(this.extractContract(program, statement));\n }\n }\n return models;\n }\n\n /** The same extraction against a program the caller already built. */\n extract(program: ts.Program, source: ts.SourceFile): ApiDocModel {\n program.getTypeChecker();\n return this.extractContract(program, this.findContract(source));\n }\n\n /** ONE contract class -> ONE model. The single place the walk actually happens. */\n private extractContract(program: ts.Program, contract: ts.ClassDeclaration): ApiDocModel {\n const checker = program.getTypeChecker();\n const folder = new ConstantFolder(checker);\n const resolver = this.resolverFor(program, contract.getSourceFile());\n\n const pathDecorator = ApiDocExtractor.decoratorCall(contract, API_PATH)!;\n const basePathArgument = pathDecorator.arguments[0];\n const basePath =\n basePathArgument === undefined\n ? ''\n : folder.foldString(basePathArgument, '@ApiPath argument');\n\n const apiTypes = this.declaredApiTypes(contract, folder);\n const endpoints: DocumentedEndpoint[] = [];\n for (const member of contract.members) {\n const endpoint = this.endpointOf(member, folder, resolver);\n if (endpoint !== undefined) {\n endpoints.push(endpoint);\n }\n }\n assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints);\n\n return new ApiDocModel(\n contract.name?.text ?? '<anonymous>',\n apiTypes,\n basePath,\n resolver.readDoc(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * Extract ONE named type and everything it reaches, from a file that holds NO contract.\n *\n * This exists for a type nothing in a contract points at but a document still publishes — the\n * document-wide error body a renderer's manifest names. Reading it with the SAME resolver is the\n * point: a second reader would be a second answer to \"what shape is this type\", and the two\n * would drift the first time a field changed.\n *\n * @throws ApiDocExtractionError when the file does not declare that name.\n */\n extractType(\n entryFile: string,\n typeName: string,\n compilerOptions: ts.CompilerOptions = {},\n ): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const resolver = this.resolverFor(program, source);\n const declaration = ApiDocExtractor.declarationNamed(source, typeName);\n if (declaration === undefined) {\n throw new ApiDocExtractionError(\n `no type named '${typeName}' is declared in this file`,\n entryFile,\n `Declare and export '${typeName}' there, or name the file that does.`,\n );\n }\n resolver.resolveDeclaration(typeName, declaration, typeName);\n return new ApiDocModel(\n typeName,\n DEFAULT_API_TYPES,\n '',\n '',\n [],\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * The header name an EXPORTED ContextKey rides under — what a manifest's response header names\n * instead of a string (#1249). `exportPath` is the export's name, or a dotted path into one\n * (`OneTabletKey.TX_ID`, a class's `static readonly` or an object's property).\n *\n * @throws ApiDocExtractionError naming the export when it is missing or cannot be followed to a\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` call declaring that header.\n */\n extractContextKeyHeader(\n entryFile: string,\n exportPath: string,\n slot: ContextKeyHeaderSlot,\n compilerOptions: ts.CompilerOptions = {},\n ): string {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const checker = program.getTypeChecker();\n const symbol = this.exportedMember(checker, source, exportPath);\n if (symbol === undefined) {\n throw new ApiDocExtractionError(\n `'${exportPath}' is not exported by this file`,\n entryFile,\n `Export the ContextKey there — e.g. \\`export const ${exportPath.split('.')[0]} = MyKeys.SOME_KEY;\\` — ` +\n 'or name the file that does.',\n );\n }\n return new ContextKeyHeaderFolder(new ConstantFolder(checker)).foldSymbol(\n symbol,\n exportPath,\n entryFile,\n slot,\n 'the manifest response header',\n );\n }\n\n /** `A` or `A.B.C`: the export `A`, then each property of its value in turn. */\n private exportedMember(\n checker: ts.TypeChecker,\n source: ts.SourceFile,\n exportPath: string,\n ): ts.Symbol | undefined {\n const moduleSymbol = checker.getSymbolAtLocation(source);\n if (moduleSymbol === undefined) {\n return undefined;\n }\n const segments = exportPath.split('.');\n let symbol: ts.Symbol | undefined = checker\n .getExportsOfModule(moduleSymbol)\n .find((exported: ts.Symbol) => exported.name === segments[0]);\n for (const segment of segments.slice(1)) {\n if (symbol === undefined) {\n return undefined;\n }\n const unaliased =\n (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;\n symbol = checker.getTypeOfSymbolAtLocation(unaliased, source).getProperty(segment);\n }\n return symbol;\n }\n\n /** A DTO library's exported types, for its components document (#1058). */\n extractComponents(\n entryFiles: readonly string[],\n compilerOptions: ts.CompilerOptions = {},\n ): ApiComponentsModel {\n return new ComponentsExtractor(this.packages, this.schemaNames).extract(entryFiles, compilerOptions);\n }\n\n /** The interface / class / type alias / enum declared under `name` at the file's top level. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static declarationNamed(\n source: ts.SourceFile,\n name: string,\n ): ts.Declaration | undefined {\n for (const statement of source.statements) {\n const named =\n ts.isInterfaceDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement);\n if (named && statement.name?.text === name) {\n return statement;\n }\n }\n return undefined;\n }\n\n /** The one `@ApiPath` class in the file. Zero is a hard failure; the FIRST wins if there are two. */\n private findContract(source: ts.SourceFile): ts.ClassDeclaration {\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n return statement;\n }\n }\n throw new ApiDocExtractionError(\n 'no @ApiPath class in this file',\n source.fileName,\n 'Point the extractor at the contract file — the one whose class carries @ApiPath.',\n );\n }\n\n /** One `@Endpoint` method. Members without the decorator are not part of the contract. */\n private endpointOf(\n member: ts.ClassElement,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedEndpoint | undefined {\n if (!ts.isMethodDeclaration(member) || !ts.isIdentifier(member.name)) {\n return undefined;\n }\n const call = ApiDocExtractor.decoratorCall(member, ENDPOINT);\n if (call === undefined) {\n return undefined;\n }\n const methodName = member.name.text;\n\n // `@Endpoint(httpMethod, path, operation, kind, options?)` — METHOD-FIRST, five positions.\n // The positions are read here and nowhere else, so the one place that has to change when the\n // decorator changes is this block plus `ARGUMENT_NAMES` beside it.\n const httpMethod = this.requiredArgument(call, methodName, 0, folder);\n const path = this.requiredArgument(call, methodName, 1, folder);\n const operation = this.requiredArgument(call, methodName, 2, folder);\n const kind = this.requiredArgument(call, methodName, 3, folder);\n\n const options = call.arguments[4];\n const literal =\n options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;\n\n const doc = resolver.readDoc(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\n const streaming = new StreamingSignature().read(member, folder, resolver);\n return new DocumentedEndpoint(\n methodName,\n httpMethod,\n path,\n operation,\n kind,\n ApiDocExtractor.booleanProperty(literal, 'hidden'),\n ApiDocExtractor.booleanProperty(literal, 'openWorld'),\n new DocumentedEndpointOptions(\n ApiDocExtractor.booleanProperty(literal, 'formPost'),\n ApiDocExtractor.stringProperty(literal, 'calledBy', folder),\n ApiDocExtractor.stringProperty(literal, 'callerKind', folder),\n ),\n ApiDocExtractor.authOf(member, folder),\n mcpTool,\n ApiDocExtractor.invalidForMcpOf(member, folder),\n ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.mcp,\n doc.returns,\n this.requestOf(member, methodName, resolver),\n streaming?.initialResponse ?? this.responseOf(member, methodName, resolver),\n streaming,\n ApiDocExtractor.decoratorCall(member, WpLocalOnly.name) !== undefined,\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters[0];\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** The declared return type, unwrapped from `Promise<...>` by the resolver. */\n private responseOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n if (member.type === undefined) {\n return undefined;\n }\n return resolver.resolve(member.type, `${methodName}.response`);\n }\n\n /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const publicCall = this.decoratorCall(member, WpAuthPublic.name);\n if (publicCall) {\n const reason = publicCall.arguments[0];\n if (!reason) throw new ApiDocExtractionError('Public authentication requires a reason', SourceLocation.of(publicCall), \"Declare @WpAuthPublic('reason').\");\n return new DocumentedAuth(folder.foldString(reason, 'public auth reason'), []);\n }\n const protectedCall = this.decoratorCall(member, WpAuth.name);\n if (!protectedCall) return undefined;\n const array = protectedCall.arguments[0];\n if (!array || !ts.isArrayLiteralExpression(array) || !array.elements.length) throw new ApiDocExtractionError('WpAuth requires a nonempty descriptor array', SourceLocation.of(protectedCall), 'Use @WpAuth([jwt(), oidcSameProject()]).');\n const methods: DocumentedAuthMethod[] = [];\n for (const element of array.elements) {\n if (!ts.isCallExpression(element)) throw new ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation.of(element), 'Use canonical credential descriptors.');\n const name = this.canonicalCallName(element.expression);\n const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');\n methods.push(new DocumentedAuthMethod(kind, element.arguments.map((argument: ts.Expression) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));\n }\n return new DocumentedAuth(undefined, methods);\n }\n\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static canonicalCallName(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const module = statement.moduleSpecifier.text;\n if (!['@webpieces/core-util', '@webpieces/http-routing', '@webpieces/http-client-browser'].includes(module) && !module.endsWith('/core-util/src/http/decorators') && !module.endsWith('/core-util/src/http/auth-mode') && !module.endsWith('/core-util/src/http/authorization')) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find((entry: ts.ImportSpecifier) => entry.name.text === expression.text);\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text) return expression.name.text;\n }\n return undefined;\n }\n\n /**\n * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.\n *\n * A malformed declaration FAILS rather than yielding a half-parsed regime: the credentials are\n * what a published document's security block is made of, and a document that silently omitted\n * one would tell a partner they need fewer credentials than the running hook demands.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static apiKeyOf(call: ts.CallExpression, folder: ConstantFolder): DocumentedApiKey {\n const regimeArgument = call.arguments[0];\n const credentialsArgument = call.arguments[1];\n if (regimeArgument === undefined || credentialsArgument === undefined) {\n throw new ApiDocExtractionError(\n 'apiKey(...) needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: apiKey('partner', [{ in: 'header', key: MyKeys.API_KEY }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, 'apiKey(...) regime');\n // FOLLOW a name first: a credential list shared by every method of a contract is written\n // once as a `const` and named per method, which is better source than a copy per method.\n const credentialsLiteral = folder.follow(credentialsArgument);\n if (!ts.isArrayLiteralExpression(credentialsLiteral)) {\n throw new ApiDocExtractionError(\n 'apiKey(...) credentials is not an array literal',\n SourceLocation.of(credentialsArgument),\n 'Write the credentials as an array literal, inline or in a `const`; a value ' +\n 'assembled at runtime cannot appear in a published security scheme.',\n );\n }\n const credentials: DocumentedApiKeyCredential[] = [];\n for (const element of credentialsLiteral.elements) {\n credentials.push(ApiDocExtractor.credentialOf(element, folder));\n }\n return new DocumentedApiKey(regime, credentials);\n }\n\n /** ONE `{ in: …, name?: …, description?: … }` credential. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static credentialOf(\n expression: ts.Expression,\n folder: ConstantFolder,\n ): DocumentedApiKeyCredential {\n const element = folder.follow(expression);\n if (!ts.isObjectLiteralExpression(element)) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', key: MyKeys.API_KEY }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with its ContextKey, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.headerOf(element, location, folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * A header credential's wire name, read off the ContextKey its `key` names (#1249) — never a\n * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static headerOf(\n element: ts.ObjectLiteralExpression,\n location: string,\n folder: ConstantFolder,\n ): string | undefined {\n if (location !== 'header') {\n return undefined;\n }\n const key = ApiDocExtractor.findProperty(element, 'key');\n if (key === undefined) {\n throw new ApiDocExtractionError(\n \"a header apiKey(...) credential names no ContextKey in 'key'\",\n SourceLocation.of(element),\n \"Name the ContextKey carrying it: { in: 'header', key: MyKeys.API_KEY }. The header-name \" +\n 'string spelling (`name:`) is deleted; the key is the one definition of the header.',\n );\n }\n return new ContextKeyHeaderFolder(folder).fold(\n key,\n ContextKeyHeaderSlot.REQUEST,\n \"the apiKey(...) header credential's key\",\n );\n }\n\n /**\n * `@WpMcpTool('search_stores', 'Search stores')` — the stable protocol name and the REQUIRED\n * human-readable title (#1180), the two facts the source cannot otherwise state. A title that\n * does not fold to a string is read as the empty string, which the MCP renderer refuses.\n *\n * Profile membership is read from the optional third argument (#1187). Otherwise, the method's JSDoc\n * is the description for the agent and the partner alike, the three side-effect hints are computed\n * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See\n * {@link DocumentedMcpTool}.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static mcpToolOf(\n member: ts.Node,\n folder: ConstantFolder,\n ): DocumentedMcpTool | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n const titleArgument = call?.arguments[1];\n const title = titleArgument === undefined ? '' : (folder.tryFoldString(titleArgument) ?? '');\n return new DocumentedMcpTool(folder.tryFoldString(argument) ?? '', title, new McpProfiles().read(call?.arguments[2], folder));\n }\n\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.\n *\n * A reason that will not fold is read as the EMPTY STRING rather than as \"no decorator\": the\n * method is still permanently outside MCP, and losing that fact because the argument was written\n * as a cross-module constant would silently put the endpoint back in the candidate set.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static invalidForMcpOf(member: ts.Node, folder: ConstantFolder): string | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_INVALID);\n if (call === undefined) {\n return undefined;\n }\n const argument = call.arguments[0];\n return argument === undefined ? '' : (folder.tryFoldString(argument) ?? '');\n }\n\n /** `@MaskLog({ refreshToken: 'full' })` -> field name -> mask mode. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static maskLogOf(member: ts.Node): ReadonlyMap<string, string> {\n const fields = new Map<string, string>();\n const argument = ApiDocExtractor.decoratorCall(member, MASK_LOG)?.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) {\n return fields;\n }\n for (const property of argument.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n ts.isStringLiteralLike(property.initializer)\n ) {\n fields.set(property.name.text, property.initializer.text);\n }\n }\n return fields;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static booleanProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n ): boolean {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value?.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static stringProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n folder: ConstantFolder,\n ): string | undefined {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value === undefined ? undefined : folder.tryFoldString(value);\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static findProperty(\n literal: ts.ObjectLiteralExpression,\n name: string,\n ): ts.Expression | undefined {\n for (const property of literal.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === name\n ) {\n return property.initializer;\n }\n }\n return undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ApiDocExtractor.canonicalCallName(call.expression) === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,sDAAmD;AACnD,+CAA4C;AAC5C,uDAAiC;AACjC,oDAqB8B;AAC9B,sDAU8B;AAE9B,mEAAgE;AAChE,qDAAkD;AAClD,qEAAwF;AACxF,qDAAkD;AAClD,mDAA+D;AAC/D,+DAA4D;AAC5D,mDAAgD;AAChD,iDAA8C;AAC9C,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,oBAAQ,CAAC,IAAI,CAAC;AAC/B,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAChC,MAAM,WAAW,GAAG,iCAAqB,CAAC,IAAI,CAAC;AAC/C,MAAM,aAAa,GAAG,2BAAe,CAAC,IAAI,CAAC;AAC3C,MAAM,YAAY,GAAG,kBAAM,CAAC,IAAI,CAAC;AACjC,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAE9B;;;;GAIG;AACH,sGAAsG;AACtG,MAAM,cAAc,GAAsB,CAAC,eAAG,EAAE,sBAAU,EAAE,gBAAI,EAAE,oBAAQ,CAAC,CAAC;AAC5E,MAAM,mBAAmB,GAAsB,CAAC,gBAAI,EAAE,4BAAgB,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SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,YAAY,CACvB,OAAmC,EACnC,IAAY;QAEZ,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACxC,IACI,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;gBACjC,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACrE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAC7B,CAAC;gBACC,OAAO,QAAQ,CAAC,WAAW,CAAC;YAChC,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,aAAa,CACxB,IAAa,EACb,aAAqB;QAErB,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC;YAClC,IACI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,aAAa,EACtE,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAtqBD,0CAsqBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport { McpProfiles } from './McpProfiles';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL,\n GET,\n MaskLog,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n WpAuthPublic,\n WpAuth, WpAuthorization, WpLocalOnly, apiKey,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ContextKeyHeaderFolder, ContextKeyHeaderSlot } from './ContextKeyHeaderFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\nimport { StreamingSignature } from './StreamingSignature';\n\n/**\n * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as\n * string literals.\n *\n * ## Why `.name` and not `'Endpoint'`\n *\n * The extractor matches decorators by NAME on the syntax — it must, because it reads a contract with\n * the compiler and never executes it. The question is only where that name comes from, and a literal\n * has a silent failure mode that a symbol does not: rename `@WpMcpTool` in `core-util` and a literal\n * simply stops matching. The extractor then finds zero MCP tools, the MCP document is correctly not\n * written because it has no tools in it, and the BUILD IS GREEN. A partner-facing document silently\n * loses a section with nothing red anywhere (issue #1001).\n *\n * `Endpoint.name` makes that rename a COMPILE ERROR here, which in this repo is the delivery\n * mechanism for a migration rather than an obstacle to one: a compile break names the new spelling\n * and an agent applies it in one pass, where a green build teaches nobody anything.\n *\n * ## Why importing `@webpieces/core-util` is not the coupling it looks like\n *\n * Any contract carrying `@Endpoint` already depends on `core-util` by definition, so there is no\n * upstream project this import could shut out. It is build-time only, it creates no cycle, and it\n * costs a browser bundle nothing because nothing in a bundle imports this package. The direction that\n * WOULD be fatal is `core-util` depending on the TypeScript compiler, and that is not this.\n */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MASK_LOG = MaskLog.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\nconst AUTHORIZATION = WpAuthorization.name;\nconst API_KEY_AUTH = apiKey.name;\nconst API_TYPE = ApiType.name;\n\n/**\n * The prefix shared by every credential decorator. A PREFIX genuinely has no symbol to take a name\n * from, so it stays a literal — but the set it selects is pinned below, which is what stops it\n * quietly matching nothing.\n */\n/** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */\nconst ENDPOINT_KINDS: readonly string[] = [RPC, CLOUDTASKS, CRON, EXTERNAL];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = [GET, POST];\n\n/** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */\nconst ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];\n\n/** The allowed values of each required position, in the same order, for the same failure. */\nconst ARGUMENT_VALUES: readonly (readonly string[])[] = [\n HTTP_METHODS,\n [],\n ENDPOINT_OPERATIONS,\n ENDPOINT_KINDS,\n];\n\n/** The REAL document types, so a contract cannot name a document that does not exist. */\nconst API_TYPES: readonly string[] = [SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP];\n\n/** The fail-closed default: a contract that declares nothing feeds only the internal document. */\nconst DEFAULT_API_TYPES: readonly string[] = [SVC_TO_SVC];\n\n/**\n * ONE contract file -> ONE {@link ApiDocModel}. The single extraction pass both the OpenAPI documents\n * and the MCP tool list (#982) are rendered from.\n *\n * ## Why the compiler API at all\n *\n * A DTO field's TYPE IS ERASED AT RUNTIME. Reflection can see that `save` takes one argument; it\n * cannot see that the argument has a `deliveryWindow` that is a discriminated union of two shapes,\n * one of which carries an ISO timestamp. Those are precisely the shapes a partner-grade document is\n * made of, so the only place they exist is the source, and the only honest way to read the source is\n * the compiler.\n *\n * ## Why it IMPORTS `@webpieces/core-util`\n *\n * Decorators are matched BY NAME on the syntax — they must be, because this reads a contract and\n * never executes it. The NAMES come from the real symbols (`Endpoint.name`), so a rename in\n * `core-util` is a compile error here instead of a literal that quietly stops matching. The full\n * argument, and why the import is not the coupling it looks like, is at those constants.\n *\n * ## What it does NOT do\n *\n * It emits nothing. No OpenAPI, no MCP tool definitions, no file — that is #982, and keeping the\n * render out means the two renderers cannot drift apart about what the contract SAYS.\n */\nexport class ApiDocExtractor {\n constructor(private readonly schemaNames: SchemaNames = new SchemaNames([])) {}\n /** Which package declares each file — the owner of every schema (#1058). Cached per directory. */\n private readonly packages = new PackageOfFile();\n /** A resolver whose HOME is the package declaring `source` — see {@link TypeResolver}. */\n private resolverFor(program: ts.Program, source: ts.SourceFile): TypeResolver {\n const home = this.packages.of(source.fileName)?.name;\n return new TypeResolver(program.getTypeChecker(), this.packages, home, this.schemaNames);\n }\n\n /**\n * Extract the contract in `entryFile`.\n *\n * @param entryFile absolute path to the `.ts` file holding the `@ApiPath` class.\n * @param compilerOptions handed straight to `ts.createProgram`; the caller owns them because\n * only the caller knows its own `paths` / `lib` setup.\n * @throws ApiDocExtractionError when the file holds no `@ApiPath` class, or when something that\n * must be exact (a path constant, a numeric bound) cannot be established.\n */\n extractFile(entryFile: string, compilerOptions: ts.CompilerOptions = {}): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extract(program, source);\n }\n\n /**\n * EVERY `@ApiPath` contract in one file, in declaration order.\n *\n * {@link extractFile} answers \"what is THE contract in this file\", which is the shape a manifest\n * entry and a generated document have: one contract, one file. This answers a different question\n * — \"what does this file declare\" — and it exists because a REPO does not obey that convention.\n * `McpRemoteFixtures.ts` in `@webpieces/mcp-server` declares seven contracts, and the runtime\n * registers MCP tools from all seven; a sweep that read only the first would report green while\n * six contracts' worth of tools had never been looked at, which is the exact shape of silent miss\n * this epic exists to remove.\n *\n * A file with no contract yields an EMPTY list rather than throwing: \"this file has none\" is an\n * ordinary answer to this question, where it is a failure to answer {@link extractFile}'s.\n */\n extractAll(\n entryFile: string,\n compilerOptions: ts.CompilerOptions = {},\n ): readonly ApiDocModel[] {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extractAllFrom(program, source);\n }\n\n /** {@link extractAll} against a program the caller already built. */\n extractAllFrom(program: ts.Program, source: ts.SourceFile): readonly ApiDocModel[] {\n // Binding establishes AST parent links used by canonical import resolution.\n program.getTypeChecker();\n const models: ApiDocModel[] = [];\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n models.push(this.extractContract(program, statement));\n }\n }\n return models;\n }\n\n /** The same extraction against a program the caller already built. */\n extract(program: ts.Program, source: ts.SourceFile): ApiDocModel {\n program.getTypeChecker();\n return this.extractContract(program, this.findContract(source));\n }\n\n /** ONE contract class -> ONE model. The single place the walk actually happens. */\n private extractContract(program: ts.Program, contract: ts.ClassDeclaration): ApiDocModel {\n const checker = program.getTypeChecker();\n const folder = new ConstantFolder(checker);\n const resolver = this.resolverFor(program, contract.getSourceFile());\n\n const pathDecorator = ApiDocExtractor.decoratorCall(contract, API_PATH)!;\n const basePathArgument = pathDecorator.arguments[0];\n const basePath =\n basePathArgument === undefined\n ? ''\n : folder.foldString(basePathArgument, '@ApiPath argument');\n\n const apiTypes = this.declaredApiTypes(contract, folder);\n const endpoints: DocumentedEndpoint[] = [];\n for (const member of contract.members) {\n const endpoint = this.endpointOf(member, folder, resolver);\n if (endpoint !== undefined) {\n endpoints.push(endpoint);\n }\n }\n assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints);\n\n return new ApiDocModel(\n contract.name?.text ?? '<anonymous>',\n apiTypes,\n basePath,\n resolver.readDoc(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * Extract ONE named type and everything it reaches, from a file that holds NO contract.\n *\n * This exists for a type nothing in a contract points at but a document still publishes — the\n * document-wide error body a renderer's manifest names. Reading it with the SAME resolver is the\n * point: a second reader would be a second answer to \"what shape is this type\", and the two\n * would drift the first time a field changed.\n *\n * @throws ApiDocExtractionError when the file does not declare that name.\n */\n extractType(\n entryFile: string,\n typeName: string,\n compilerOptions: ts.CompilerOptions = {},\n ): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const resolver = this.resolverFor(program, source);\n const declaration = ApiDocExtractor.declarationNamed(source, typeName);\n if (declaration === undefined) {\n throw new ApiDocExtractionError(\n `no type named '${typeName}' is declared in this file`,\n entryFile,\n `Declare and export '${typeName}' there, or name the file that does.`,\n );\n }\n resolver.resolveDeclaration(typeName, declaration, typeName);\n return new ApiDocModel(\n typeName,\n DEFAULT_API_TYPES,\n '',\n '',\n [],\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * The header name an EXPORTED ContextKey rides under — what a manifest's response header names\n * instead of a string (#1249). `exportPath` is the export's name, or a dotted path into one\n * (`OneTabletKey.TX_ID`, a class's `static readonly` or an object's property).\n *\n * @throws ApiDocExtractionError naming the export when it is missing or cannot be followed to a\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` call declaring that header.\n */\n extractContextKeyHeader(\n entryFile: string,\n exportPath: string,\n slot: ContextKeyHeaderSlot,\n compilerOptions: ts.CompilerOptions = {},\n ): string {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const checker = program.getTypeChecker();\n const symbol = this.exportedMember(checker, source, exportPath);\n if (symbol === undefined) {\n throw new ApiDocExtractionError(\n `'${exportPath}' is not exported by this file`,\n entryFile,\n `Export the ContextKey there — e.g. \\`export const ${exportPath.split('.')[0]} = MyKeys.SOME_KEY;\\` — ` +\n 'or name the file that does.',\n );\n }\n return new ContextKeyHeaderFolder(new ConstantFolder(checker)).foldSymbol(\n symbol,\n exportPath,\n entryFile,\n slot,\n 'the manifest response header',\n );\n }\n\n /** `A` or `A.B.C`: the export `A`, then each property of its value in turn. */\n private exportedMember(\n checker: ts.TypeChecker,\n source: ts.SourceFile,\n exportPath: string,\n ): ts.Symbol | undefined {\n const moduleSymbol = checker.getSymbolAtLocation(source);\n if (moduleSymbol === undefined) {\n return undefined;\n }\n const segments = exportPath.split('.');\n let symbol: ts.Symbol | undefined = checker\n .getExportsOfModule(moduleSymbol)\n .find((exported: ts.Symbol) => exported.name === segments[0]);\n for (const segment of segments.slice(1)) {\n if (symbol === undefined) {\n return undefined;\n }\n const unaliased =\n (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;\n symbol = checker.getTypeOfSymbolAtLocation(unaliased, source).getProperty(segment);\n }\n return symbol;\n }\n\n /** A DTO library's exported types, for its components document (#1058). */\n extractComponents(\n entryFiles: readonly string[],\n compilerOptions: ts.CompilerOptions = {},\n ): ApiComponentsModel {\n return new ComponentsExtractor(this.packages, this.schemaNames).extract(entryFiles, compilerOptions);\n }\n\n /** The interface / class / type alias / enum declared under `name` at the file's top level. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static declarationNamed(\n source: ts.SourceFile,\n name: string,\n ): ts.Declaration | undefined {\n for (const statement of source.statements) {\n const named =\n ts.isInterfaceDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement);\n if (named && statement.name?.text === name) {\n return statement;\n }\n }\n return undefined;\n }\n\n /** The one `@ApiPath` class in the file. Zero is a hard failure; the FIRST wins if there are two. */\n private findContract(source: ts.SourceFile): ts.ClassDeclaration {\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n return statement;\n }\n }\n throw new ApiDocExtractionError(\n 'no @ApiPath class in this file',\n source.fileName,\n 'Point the extractor at the contract file — the one whose class carries @ApiPath.',\n );\n }\n\n /** One `@Endpoint` method. Members without the decorator are not part of the contract. */\n private endpointOf(\n member: ts.ClassElement,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedEndpoint | undefined {\n if (!ts.isMethodDeclaration(member) || !ts.isIdentifier(member.name)) {\n return undefined;\n }\n const call = ApiDocExtractor.decoratorCall(member, ENDPOINT);\n if (call === undefined) {\n return undefined;\n }\n const methodName = member.name.text;\n\n // `@Endpoint(httpMethod, path, operation, kind, options?)` — METHOD-FIRST, five positions.\n // The positions are read here and nowhere else, so the one place that has to change when the\n // decorator changes is this block plus `ARGUMENT_NAMES` beside it.\n const httpMethod = this.requiredArgument(call, methodName, 0, folder);\n const path = this.requiredArgument(call, methodName, 1, folder);\n const operation = this.requiredArgument(call, methodName, 2, folder);\n const kind = this.requiredArgument(call, methodName, 3, folder);\n\n const options = call.arguments[4];\n const literal =\n options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;\n\n const doc = resolver.readDoc(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\n const streaming = new StreamingSignature().read(member, folder, resolver);\n return new DocumentedEndpoint(\n methodName,\n httpMethod,\n path,\n operation,\n kind,\n ApiDocExtractor.booleanProperty(literal, 'hidden'),\n ApiDocExtractor.booleanProperty(literal, 'openWorld'),\n new DocumentedEndpointOptions(\n ApiDocExtractor.booleanProperty(literal, 'formPost'),\n ApiDocExtractor.stringProperty(literal, 'calledBy', folder),\n ApiDocExtractor.stringProperty(literal, 'callerKind', folder),\n ),\n ApiDocExtractor.authOf(member, folder),\n mcpTool,\n ApiDocExtractor.invalidForMcpOf(member, folder),\n ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.summary,\n doc.mcp,\n doc.returns,\n this.requestOf(member, methodName, resolver),\n streaming?.initialResponse ?? this.responseOf(member, methodName, resolver),\n streaming,\n ApiDocExtractor.decoratorCall(member, WpLocalOnly.name) !== undefined,\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters[0];\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** The declared return type, unwrapped from `Promise<...>` by the resolver. */\n private responseOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n if (member.type === undefined) {\n return undefined;\n }\n return resolver.resolve(member.type, `${methodName}.response`);\n }\n\n /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const publicCall = this.decoratorCall(member, WpAuthPublic.name);\n if (publicCall) {\n const reason = publicCall.arguments[0];\n if (!reason) throw new ApiDocExtractionError('Public authentication requires a reason', SourceLocation.of(publicCall), \"Declare @WpAuthPublic('reason').\");\n return new DocumentedAuth(folder.foldString(reason, 'public auth reason'), []);\n }\n const protectedCall = this.decoratorCall(member, WpAuth.name);\n if (!protectedCall) return undefined;\n const array = protectedCall.arguments[0];\n if (!array || !ts.isArrayLiteralExpression(array) || !array.elements.length) throw new ApiDocExtractionError('WpAuth requires a nonempty descriptor array', SourceLocation.of(protectedCall), 'Use @WpAuth([jwt(), oidcSameProject()]).');\n const methods: DocumentedAuthMethod[] = [];\n for (const element of array.elements) {\n if (!ts.isCallExpression(element)) throw new ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation.of(element), 'Use canonical credential descriptors.');\n const name = this.canonicalCallName(element.expression);\n const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');\n methods.push(new DocumentedAuthMethod(kind, element.arguments.map((argument: ts.Expression) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));\n }\n return new DocumentedAuth(undefined, methods);\n }\n\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static canonicalCallName(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const module = statement.moduleSpecifier.text;\n if (!['@webpieces/core-util', '@webpieces/http-routing', '@webpieces/http-client-browser'].includes(module) && !module.endsWith('/core-util/src/http/decorators') && !module.endsWith('/core-util/src/http/auth-mode') && !module.endsWith('/core-util/src/http/authorization')) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find((entry: ts.ImportSpecifier) => entry.name.text === expression.text);\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text) return expression.name.text;\n }\n return undefined;\n }\n\n /**\n * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.\n *\n * A malformed declaration FAILS rather than yielding a half-parsed regime: the credentials are\n * what a published document's security block is made of, and a document that silently omitted\n * one would tell a partner they need fewer credentials than the running hook demands.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static apiKeyOf(call: ts.CallExpression, folder: ConstantFolder): DocumentedApiKey {\n const regimeArgument = call.arguments[0];\n const credentialsArgument = call.arguments[1];\n if (regimeArgument === undefined || credentialsArgument === undefined) {\n throw new ApiDocExtractionError(\n 'apiKey(...) needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: apiKey('partner', [{ in: 'header', key: MyKeys.API_KEY }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, 'apiKey(...) regime');\n // FOLLOW a name first: a credential list shared by every method of a contract is written\n // once as a `const` and named per method, which is better source than a copy per method.\n const credentialsLiteral = folder.follow(credentialsArgument);\n if (!ts.isArrayLiteralExpression(credentialsLiteral)) {\n throw new ApiDocExtractionError(\n 'apiKey(...) credentials is not an array literal',\n SourceLocation.of(credentialsArgument),\n 'Write the credentials as an array literal, inline or in a `const`; a value ' +\n 'assembled at runtime cannot appear in a published security scheme.',\n );\n }\n const credentials: DocumentedApiKeyCredential[] = [];\n for (const element of credentialsLiteral.elements) {\n credentials.push(ApiDocExtractor.credentialOf(element, folder));\n }\n return new DocumentedApiKey(regime, credentials);\n }\n\n /** ONE `{ in: …, name?: …, description?: … }` credential. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static credentialOf(\n expression: ts.Expression,\n folder: ConstantFolder,\n ): DocumentedApiKeyCredential {\n const element = folder.follow(expression);\n if (!ts.isObjectLiteralExpression(element)) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', key: MyKeys.API_KEY }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with its ContextKey, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.headerOf(element, location, folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * A header credential's wire name, read off the ContextKey its `key` names (#1249) — never a\n * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static headerOf(\n element: ts.ObjectLiteralExpression,\n location: string,\n folder: ConstantFolder,\n ): string | undefined {\n if (location !== 'header') {\n return undefined;\n }\n const key = ApiDocExtractor.findProperty(element, 'key');\n if (key === undefined) {\n throw new ApiDocExtractionError(\n \"a header apiKey(...) credential names no ContextKey in 'key'\",\n SourceLocation.of(element),\n \"Name the ContextKey carrying it: { in: 'header', key: MyKeys.API_KEY }. The header-name \" +\n 'string spelling (`name:`) is deleted; the key is the one definition of the header.',\n );\n }\n return new ContextKeyHeaderFolder(folder).fold(\n key,\n ContextKeyHeaderSlot.REQUEST,\n \"the apiKey(...) header credential's key\",\n );\n }\n\n /**\n * `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot\n * otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest\n * of its prose; the decorator carries none.\n *\n * Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc\n * is the description for the agent and the partner alike, the three side-effect hints are computed\n * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See\n * {@link DocumentedMcpTool}.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static mcpToolOf(\n member: ts.Node,\n folder: ConstantFolder,\n ): DocumentedMcpTool | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n return new DocumentedMcpTool(\n folder.tryFoldString(argument) ?? '',\n new McpProfiles().read(call?.arguments[1], folder),\n );\n }\n\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.\n *\n * A reason that will not fold is read as the EMPTY STRING rather than as \"no decorator\": the\n * method is still permanently outside MCP, and losing that fact because the argument was written\n * as a cross-module constant would silently put the endpoint back in the candidate set.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static invalidForMcpOf(member: ts.Node, folder: ConstantFolder): string | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_INVALID);\n if (call === undefined) {\n return undefined;\n }\n const argument = call.arguments[0];\n return argument === undefined ? '' : (folder.tryFoldString(argument) ?? '');\n }\n\n /** `@MaskLog({ refreshToken: 'full' })` -> field name -> mask mode. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static maskLogOf(member: ts.Node): ReadonlyMap<string, string> {\n const fields = new Map<string, string>();\n const argument = ApiDocExtractor.decoratorCall(member, MASK_LOG)?.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) {\n return fields;\n }\n for (const property of argument.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n ts.isStringLiteralLike(property.initializer)\n ) {\n fields.set(property.name.text, property.initializer.text);\n }\n }\n return fields;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static booleanProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n ): boolean {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value?.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static stringProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n folder: ConstantFolder,\n ): string | undefined {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value === undefined ? undefined : folder.tryFoldString(value);\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static findProperty(\n literal: ts.ObjectLiteralExpression,\n name: string,\n ): ts.Expression | undefined {\n for (const property of literal.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === name\n ) {\n return property.initializer;\n }\n }\n return undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ApiDocExtractor.canonicalCallName(call.expression) === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
|
package/src/extract/JsDoc.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
import { StackedJsDoc } from '../model/ApiDocModel';
|
|
3
3
|
/**
|
|
4
|
-
* The PROSE half of the model: the JSDoc body, the `@
|
|
5
|
-
* override.
|
|
4
|
+
* The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`
|
|
5
|
+
* tag and the `@mcp` override.
|
|
6
6
|
*
|
|
7
7
|
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
8
8
|
*
|
|
9
|
-
* The body and the
|
|
9
|
+
* The body and the five tags named here are the ONLY text read out of a block. Every other block tag
|
|
10
10
|
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
11
11
|
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
12
12
|
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
@@ -19,8 +19,20 @@ import { StackedJsDoc } from '../model/ApiDocModel';
|
|
|
19
19
|
* tag grammar and each get it slightly differently wrong. One flattening, at extraction.
|
|
20
20
|
*/
|
|
21
21
|
export declare class JsDoc {
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The body text, links flattened, trimmed. Empty string when undocumented. A block TAG is never
|
|
24
|
+
* part of it — `@summary`, `@returns` and the rest are read into their own fields (or dropped),
|
|
25
|
+
* so the short title never repeats inside the description it heads.
|
|
26
|
+
*/
|
|
23
27
|
readonly description: string;
|
|
28
|
+
/**
|
|
29
|
+
* The `@summary` block tag's text — the endpoint's one-line short title (#1296), published as
|
|
30
|
+
* the OpenAPI operation `summary` and as MCP `Tool.title` AND `annotations.title`. Undefined
|
|
31
|
+
* when the author wrote none (or wrote the tag with no text); the OpenAPI generator refuses
|
|
32
|
+
* that for every published operation. Kept VERBATIM (trimmed): a second line is the author's
|
|
33
|
+
* mistake to be told about, not something to silently join or cut.
|
|
34
|
+
*/
|
|
35
|
+
readonly summary: string | undefined;
|
|
24
36
|
/**
|
|
25
37
|
* The `@returns` block tag's text — what a method's success response carries, published as
|
|
26
38
|
* that response's `description` (#1292). Undefined when the author wrote none (or wrote the
|
package/src/extract/JsDoc.js
CHANGED
|
@@ -11,12 +11,17 @@ const SourceLocation_1 = require("./SourceLocation");
|
|
|
11
11
|
*/
|
|
12
12
|
const RETURNS_TAG = 'returns';
|
|
13
13
|
/**
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
14
|
+
* The standard JSDoc tag for an endpoint's one-line short title (#1296), published as OpenAPI
|
|
15
|
+
* `summary` and MCP `title` / `annotations.title`.
|
|
16
|
+
*/
|
|
17
|
+
const SUMMARY_TAG = 'summary';
|
|
18
|
+
/**
|
|
19
|
+
* The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`
|
|
20
|
+
* tag and the `@mcp` override.
|
|
16
21
|
*
|
|
17
22
|
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
18
23
|
*
|
|
19
|
-
* The body and the
|
|
24
|
+
* The body and the five tags named here are the ONLY text read out of a block. Every other block tag
|
|
20
25
|
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
21
26
|
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
22
27
|
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
@@ -30,13 +35,26 @@ const RETURNS_TAG = 'returns';
|
|
|
30
35
|
*/
|
|
31
36
|
class JsDoc {
|
|
32
37
|
description;
|
|
38
|
+
summary;
|
|
33
39
|
returns;
|
|
34
40
|
format;
|
|
35
41
|
mcp;
|
|
36
42
|
mcpHeader;
|
|
37
43
|
constructor(
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* The body text, links flattened, trimmed. Empty string when undocumented. A block TAG is never
|
|
46
|
+
* part of it — `@summary`, `@returns` and the rest are read into their own fields (or dropped),
|
|
47
|
+
* so the short title never repeats inside the description it heads.
|
|
48
|
+
*/
|
|
39
49
|
description,
|
|
50
|
+
/**
|
|
51
|
+
* The `@summary` block tag's text — the endpoint's one-line short title (#1296), published as
|
|
52
|
+
* the OpenAPI operation `summary` and as MCP `Tool.title` AND `annotations.title`. Undefined
|
|
53
|
+
* when the author wrote none (or wrote the tag with no text); the OpenAPI generator refuses
|
|
54
|
+
* that for every published operation. Kept VERBATIM (trimmed): a second line is the author's
|
|
55
|
+
* mistake to be told about, not something to silently join or cut.
|
|
56
|
+
*/
|
|
57
|
+
summary,
|
|
40
58
|
/**
|
|
41
59
|
* The `@returns` block tag's text — what a method's success response carries, published as
|
|
42
60
|
* that response's `description` (#1292). Undefined when the author wrote none (or wrote the
|
|
@@ -63,6 +81,7 @@ class JsDoc {
|
|
|
63
81
|
*/
|
|
64
82
|
mcpHeader) {
|
|
65
83
|
this.description = description;
|
|
84
|
+
this.summary = summary;
|
|
66
85
|
this.returns = returns;
|
|
67
86
|
this.format = format;
|
|
68
87
|
this.mcp = mcp;
|
|
@@ -74,6 +93,7 @@ class JsDoc {
|
|
|
74
93
|
const symbolLike = node;
|
|
75
94
|
const blocks = symbolLike.jsDoc ?? [];
|
|
76
95
|
const bodies = [];
|
|
96
|
+
let summary;
|
|
77
97
|
let returns;
|
|
78
98
|
let format;
|
|
79
99
|
let mcp;
|
|
@@ -85,7 +105,10 @@ class JsDoc {
|
|
|
85
105
|
const text = JsDoc.flatten(tag.comment);
|
|
86
106
|
// `@privateRemarks` (and every tag not named below) is skipped with its text — see
|
|
87
107
|
// the class doc: it is never published anywhere.
|
|
88
|
-
if (name ===
|
|
108
|
+
if (name === SUMMARY_TAG && text !== '') {
|
|
109
|
+
summary = text;
|
|
110
|
+
}
|
|
111
|
+
else if (name === RETURNS_TAG && text !== '') {
|
|
89
112
|
returns = text;
|
|
90
113
|
}
|
|
91
114
|
else if (name === 'format' && text !== '') {
|
|
@@ -99,7 +122,7 @@ class JsDoc {
|
|
|
99
122
|
}
|
|
100
123
|
}
|
|
101
124
|
}
|
|
102
|
-
return new JsDoc(bodies.join('\n').trim(), returns, format, mcp, mcpHeader);
|
|
125
|
+
return new JsDoc(bodies.join('\n').trim(), summary, returns, format, mcp, mcpHeader);
|
|
103
126
|
}
|
|
104
127
|
/**
|
|
105
128
|
* The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else
|
package/src/extract/JsDoc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,sDAAoD;AACpD,qDAAkD;AAQlD;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,KAAK;IAGD;IAMA;IAEA;IAOA;IAUA;IA3Bb;IACI,+EAA+E;IACtE,WAAmB;IAC5B;;;;OAIG;IACM,OAA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AK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AA9HD,sBA8HC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one\n * spelling per fact, and a refusal naming `@returns` is how an author finds out.\n */\nconst RETURNS_TAG = 'returns';\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@returns` tag, the `@format` tag and the `@mcp`\n * override.\n *\n * ## Every `/** *\\/` is published — except `@privateRemarks` (#1292)\n *\n * The body and the four tags named here are the ONLY text read out of a block. Every other block tag\n * is dropped together with its text, and `@privateRemarks` — TSDoc's standard \"inside the doc block,\n * never published\" tag — is the one an author writes ON PURPOSE to keep a note out of every document:\n * OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no\n * renderer can ever reach it — the same reason `{@link}` is flattened here (below). `//` and `/* *\\/`\n * comments are private by construction: the compiler attaches no JSDoc for them.\n *\n * `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the\n * point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI\n * `description`, an MCP tool description, an HTML page — would otherwise each have to know the inline\n * tag grammar and each get it slightly differently wrong. One flattening, at extraction.\n */\nexport class JsDoc {\n private constructor(\n /** The body text, links flattened, trimmed. Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@returns` block tag's text — what a method's success response carries, published as\n * that response's `description` (#1292). Undefined when the author wrote none (or wrote the\n * tag with no text), which an OpenAPI renderer refuses for an operation with a body.\n */\n readonly returns: string | undefined,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let returns: string | undefined;\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment);\n // `@privateRemarks` (and every tag not named below) is skipped with its text — see\n // the class doc: it is never published anywhere.\n if (name === RETURNS_TAG && text !== '') {\n returns = text;\n } else if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n }\n }\n }\n\n return new JsDoc(bodies.join('\\n').trim(), returns, format, mcp, mcpHeader);\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember = parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline tag replaced by its own text: `{@link Foo.bar}` -> `Foo.bar`,\n * `{@link Foo.bar|the widget}` -> `the widget`.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(comment: string | ts.NodeArray<ts.JSDocComment> | undefined): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n // `text` is whatever followed the target ('|the widget'); the NAME is the target.\n const label = part.text.replace(/^[|\\s]+/, '').trim();\n const target = part.name ? part.name.getText() : '';\n parts.push(label !== '' ? label : target);\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,sDAAoD;AACpD,qDAAkD;AAQlD;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,KAAK;IAOD;IAQA;IAMA;IAEA;IAOA;IAUA;IAvCb;IACI;;;;OAIG;IACM,WAAmB;IAC5B;;;;;;OAMG;IACM,OAA2B;IACpC;;;;OAIG;IACM,OAA2B;IACpC,kEAAkE;IACzD,MAA0B;IACnC;;;;;OAKG;IACM,GAAuB;IAChC;;;;;;;;OAQG;IACM,SAA6B;QAjC7B,gBAAW,GAAX,WAAW,CAAQ;QAQnB,YAAO,GAAP,OAAO,CAAoB;QAM3B,YAAO,GAAP,OAAO,CAAoB;QAE3B,WAAM,GAAN,MAAM,CAAoB;QAO1B,QAAG,GAAH,GAAG,CAAoB;QAUvB,cAAS,GAAT,SAAS,CAAoB;IACvC,CAAC;IAEJ,kDAAkD;IAClD,iIAAiI;IACjI,MAAM,CAAC,IAAI,CAAC,IAAa;QACrB,MAAM,UAAU,GAAG,IAAoB,CAAC;QACxC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;QACtC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,OAA2B,CAAC;QAChC,IAAI,OAA2B,CAAC;QAChC,IAAI,MAA0B,CAAC;QAC/B,IAA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,CAAC,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3F,CAAC;IAED;;;;;;OAMG;IACH,qFAAqF;IAC7E,MAAM,CAAC,OAAO,CAAC,OAA2D;QAC9E,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACd,CAAC;QACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChF,kFAAkF;gBAClF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBACtD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpD,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AA7ID,sBA6IC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one\n * spelling per fact, and a refusal naming `@returns` is how an author finds out.\n */\nconst RETURNS_TAG = 'returns';\n\n/**\n * The standard JSDoc tag for an endpoint's one-line short title (#1296), published as OpenAPI\n * `summary` and MCP `title` / `annotations.title`.\n */\nconst SUMMARY_TAG = 'summary';\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`\n * tag and the `@mcp` override.\n *\n * ## Every `/** *\\/` is published — except `@privateRemarks` (#1292)\n *\n * The body and the five tags named here are the ONLY text read out of a block. Every other block tag\n * is dropped together with its text, and `@privateRemarks` — TSDoc's standard \"inside the doc block,\n * never published\" tag — is the one an author writes ON PURPOSE to keep a note out of every document:\n * OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no\n * renderer can ever reach it — the same reason `{@link}` is flattened here (below). `//` and `/* *\\/`\n * comments are private by construction: the compiler attaches no JSDoc for them.\n *\n * `{@link Foo.bar}` is flattened to `Foo.bar` HERE, at this boundary, and that placement is the\n * point: a link is a TypeScript editor affordance, and every downstream renderer — OpenAPI\n * `description`, an MCP tool description, an HTML page — would otherwise each have to know the inline\n * tag grammar and each get it slightly differently wrong. One flattening, at extraction.\n */\nexport class JsDoc {\n private constructor(\n /**\n * The body text, links flattened, trimmed. Empty string when undocumented. A block TAG is never\n * part of it — `@summary`, `@returns` and the rest are read into their own fields (or dropped),\n * so the short title never repeats inside the description it heads.\n */\n readonly description: string,\n /**\n * The `@summary` block tag's text — the endpoint's one-line short title (#1296), published as\n * the OpenAPI operation `summary` and as MCP `Tool.title` AND `annotations.title`. Undefined\n * when the author wrote none (or wrote the tag with no text); the OpenAPI generator refuses\n * that for every published operation. Kept VERBATIM (trimmed): a second line is the author's\n * mistake to be told about, not something to silently join or cut.\n */\n readonly summary: string | undefined,\n /**\n * The `@returns` block tag's text — what a method's success response carries, published as\n * that response's `description` (#1292). Undefined when the author wrote none (or wrote the\n * tag with no text), which an OpenAPI renderer refuses for an operation with a body.\n */\n readonly returns: string | undefined,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let summary: string | undefined;\n let returns: string | undefined;\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment);\n // `@privateRemarks` (and every tag not named below) is skipped with its text — see\n // the class doc: it is never published anywhere.\n if (name === SUMMARY_TAG && text !== '') {\n summary = text;\n } else if (name === RETURNS_TAG && text !== '') {\n returns = text;\n } else if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n }\n }\n }\n\n return new JsDoc(bodies.join('\\n').trim(), summary, returns, format, mcp, mcpHeader);\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember = parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline tag replaced by its own text: `{@link Foo.bar}` -> `Foo.bar`,\n * `{@link Foo.bar|the widget}` -> `the widget`.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(comment: string | ts.NodeArray<ts.JSDocComment> | undefined): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n // `text` is whatever followed the target ('|the widget'); the NAME is the target.\n const label = part.text.replace(/^[|\\s]+/, '').trim();\n const target = part.name ? part.name.getText() : '';\n parts.push(label !== '' ? label : target);\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
@@ -38,8 +38,8 @@ function assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints) {
|
|
|
38
38
|
'outside MCP does not feed the MCP document.');
|
|
39
39
|
}
|
|
40
40
|
if (declaresMcp && tools.length === 0) {
|
|
41
|
-
throw new ApiDocExtractionError_1.ApiDocExtractionError(`@${API_TYPE} names MCP but no method carries @${MCP_TOOL}`, SourceLocation_1.SourceLocation.of(contract), `Add @${MCP_TOOL}('<stable_tool_name>'
|
|
42
|
-
|
|
41
|
+
throw new ApiDocExtractionError_1.ApiDocExtractionError(`@${API_TYPE} names MCP but no method carries @${MCP_TOOL}`, SourceLocation_1.SourceLocation.of(contract), `Add @${MCP_TOOL}('<stable_tool_name>') to the methods agents may call (each one's ` +
|
|
42
|
+
`@summary JSDoc line is its title), or drop MCP from the @${API_TYPE} list.`);
|
|
43
43
|
}
|
|
44
44
|
if (!declaresMcp && tools.length > 0) {
|
|
45
45
|
const named = tools.map((e) => e.methodName).join(', ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpMembership.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/McpMembership.ts"],"names":[],"mappings":";;AA+BA,oEAkCC;AAhED,oDAAsF;AAEtF,mEAAgE;AAChE,qDAAkD;AAElD;;;GAGG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAChC,MAAM,WAAW,GAAG,iCAAqB,CAAC,IA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CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5E,MAAM,IAAI,6CAAqB,CAC3B,IAAI,QAAQ,UAAU,KAAK,SAAS,QAAQ,oBAAoB,EAChE,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,mBAAmB,QAAQ,sDAAsD;YAC7E,qEAAqE,CAC5E,CAAC;IACN,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,oGAAoG;AACpG,SAAS,0BAA0B,CAC/B,QAA6B,EAC7B,KAAoC;IAEpC,MAAM,IAAI,GAAG,KAAK;SACb,MAAM,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC;SAChE,GAAG,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC9B,MAAM,IAAI,6CAAqB,CAC3B,IAAI,QAAQ,SAAS,WAAW,gBAAgB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACjE,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,4FAA4F;QACxF,gEAAgE,CACvE,CAAC;AACN,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { ApiType, InvalidEndpointForMcp, MCP, WpMcpTool } from '@webpieces/core-util';\nimport { DocumentedEndpoint } from '../model/ApiDocModel';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * The decorator names, taken from the REAL SYMBOLS for the reason `ApiDocExtractor`'s constants give\n * at length: a literal that stops matching after a rename empties a document with the build green.\n */\nconst API_TYPE = ApiType.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\n\n/**\n * MCP membership has exactly ONE spelling, and this is the BUILD-TIME half of enforcing it\n * (`assertApiTypeMatchesMcpTools` in `@webpieces/core-util` is the wiring-time half).\n *\n * Declared in two places, the two can disagree — and the disagreement is invisible, because each\n * declaration is individually valid. That is the defect this whole epic exists to remove, so it\n * fails the DOCUMENT build rather than producing one that quietly lists the wrong tools.\n *\n * `@InvalidEndpointForMcp` (#1014) sits OUTSIDE the biconditional and is checked here too. A method\n * declared permanently unusable as a tool is neither required to carry `@WpMcpTool` nor permitted\n * to, and a contract whose every endpoint is so declared must not name MCP at all — the cure there\n * is the opposite one, so it gets its own sentence rather than being folded into \"no method carries\n * @WpMcpTool\".\n *\n * Split out of `ApiDocExtractor`, which owns the walk and is at its file-size limit.\n */\n// webpieces-disable no-function-outside-class -- module entry point, mirrors the extractor's own split-out helpers\nexport function assertApiTypeMatchesMcpTools(\n contract: ts.ClassDeclaration,\n apiTypes: readonly string[],\n endpoints: readonly DocumentedEndpoint[],\n): void {\n const tools = endpoints.filter((e: DocumentedEndpoint) => e.mcpTool !== undefined);\n const excluded = endpoints.filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined);\n const declaresMcp = apiTypes.includes(MCP);\n assertNoToolIsAlsoExcluded(contract, tools);\n if (declaresMcp && tools.length === 0 && excluded.length === endpoints.length) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but EVERY endpoint is @${MCP_INVALID}`,\n SourceLocation.of(contract),\n `Drop MCP from the @${API_TYPE} list — a contract whose every method is permanently ` +\n 'outside MCP does not feed the MCP document.',\n );\n }\n if (declaresMcp && tools.length === 0) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but no method carries @${MCP_TOOL}`,\n SourceLocation.of(contract),\n `Add @${MCP_TOOL}('<stable_tool_name>') to the methods agents may call (each one's ` +\n `@summary JSDoc line is its title), or drop MCP from the @${API_TYPE} list.`,\n );\n }\n if (!declaresMcp && tools.length > 0) {\n const named = tools.map((e: DocumentedEndpoint) => e.methodName).join(', ');\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} is on ${named} but @${API_TYPE} does not name MCP`,\n SourceLocation.of(contract),\n `Add MCP to the @${API_TYPE} list — membership has ONE spelling, so a tool on a ` +\n 'contract nobody published to agents is a contradiction, not a hint.',\n );\n }\n}\n\n/**\n * `@WpMcpTool` and `@InvalidEndpointForMcp` on ONE method is a contradiction, not a precedence rule.\n *\n * Resolving it either way would make the pair a second spelling of a decision that already has one,\n * and whichever way it resolved, half the readers of that method would be wrong about what it does.\n */\n// webpieces-disable no-function-outside-class -- private assert of the entry point above, beside it\nfunction assertNoToolIsAlsoExcluded(\n contract: ts.ClassDeclaration,\n tools: readonly DocumentedEndpoint[],\n): void {\n const both = tools\n .filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined)\n .map((e: DocumentedEndpoint) => e.methodName);\n if (both.length === 0) return;\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} and @${MCP_INVALID} are BOTH on ${both.join(', ')}`,\n SourceLocation.of(contract),\n 'They contradict each other — one publishes the method to agents and the other declares it ' +\n 'permanently unusable as a tool. Delete whichever one is wrong.',\n );\n}\n"]}
|