@webpieces/api-doc-model 0.4.1010 → 0.4.1012

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/api-doc-model",
3
- "version": "0.4.1010",
3
+ "version": "0.4.1012",
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.1010",
26
+ "@webpieces/core-util": "0.4.1012",
27
27
  "typescript": "5.9.3",
28
28
  "minimatch": "10.0.1"
29
29
  }
@@ -142,17 +142,6 @@ export declare class ApiDocExtractor {
142
142
  * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.
143
143
  */
144
144
  private static headerOf;
145
- /**
146
- * `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot
147
- * otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest
148
- * of its prose; the decorator carries none.
149
- *
150
- * Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc
151
- * is the description for the agent and the partner alike, the three side-effect hints are computed
152
- * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See
153
- * {@link DocumentedMcpTool}.
154
- */
155
- private static mcpToolOf;
156
145
  /**
157
146
  * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.
158
147
  *
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiDocExtractor = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const CanonicalDecorator_1 = require("./CanonicalDecorator");
5
6
  const SchemaNames_1 = require("../model/SchemaNames");
6
- const McpProfiles_1 = require("./McpProfiles");
7
+ const McpIdentities_1 = require("./McpIdentities");
7
8
  const ts = tslib_1.__importStar(require("typescript"));
8
9
  const core_util_1 = require("@webpieces/core-util");
9
10
  const ApiDocModel_1 = require("../model/ApiDocModel");
@@ -43,7 +44,6 @@ const StreamingSignature_1 = require("./StreamingSignature");
43
44
  const API_PATH = core_util_1.ApiPath.name;
44
45
  const ENDPOINT = core_util_1.Endpoint.name;
45
46
  const MASK_LOG = core_util_1.MaskLog.name;
46
- const MCP_TOOL = core_util_1.WpMcpTool.name;
47
47
  const MCP_INVALID = core_util_1.InvalidEndpointForMcp.name;
48
48
  const AUTHORIZATION = core_util_1.WpAuthorization.name;
49
49
  const API_KEY_AUTH = core_util_1.apiKey.name;
@@ -303,9 +303,9 @@ class ApiDocExtractor {
303
303
  const options = call.arguments[4];
304
304
  const literal = options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;
305
305
  const doc = resolver.readDoc(member);
306
- const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);
306
+ const mcpTools = new McpIdentities_1.McpIdentities().read(member, folder);
307
307
  const streaming = new StreamingSignature_1.StreamingSignature().read(member, folder, resolver);
308
- return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), ApiDocExtractor.booleanProperty(literal, 'additive'), 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, this.parametersOf(member, methodName, folder, resolver));
308
+ return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), ApiDocExtractor.booleanProperty(literal, 'additive'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTools, 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, this.parametersOf(member, methodName, folder, resolver));
309
309
  }
310
310
  /**
311
311
  * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.
@@ -433,22 +433,7 @@ class ApiDocExtractor {
433
433
  }
434
434
  // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution
435
435
  static canonicalCallName(expression) {
436
- for (const statement of expression.getSourceFile().statements) {
437
- if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
438
- continue;
439
- const module = statement.moduleSpecifier.text;
440
- 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'))
441
- continue;
442
- const bindings = statement.importClause?.namedBindings;
443
- if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {
444
- const imported = bindings.elements.find((entry) => entry.name.text === expression.text);
445
- if (imported)
446
- return imported.propertyName?.text ?? imported.name.text;
447
- }
448
- if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text)
449
- return expression.name.text;
450
- }
451
- return undefined;
436
+ return CanonicalDecorator_1.CanonicalDecorator.nameOf(expression);
452
437
  }
453
438
  /**
454
439
  * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.
@@ -507,25 +492,6 @@ class ApiDocExtractor {
507
492
  }
508
493
  return new ContextKeyHeaderFolder_1.ContextKeyHeaderFolder(folder).fold(key, ContextKeyHeaderFolder_1.ContextKeyHeaderSlot.REQUEST, "the apiKey(...) header credential's key");
509
494
  }
510
- /**
511
- * `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot
512
- * otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest
513
- * of its prose; the decorator carries none.
514
- *
515
- * Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc
516
- * is the description for the agent and the partner alike, the three side-effect hints are computed
517
- * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See
518
- * {@link DocumentedMcpTool}.
519
- */
520
- // webpieces-disable no-function-outside-class -- private static reader of this class
521
- static mcpToolOf(member, folder) {
522
- const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);
523
- const argument = call?.arguments[0];
524
- if (argument === undefined) {
525
- return undefined;
526
- }
527
- return new ApiDocModel_1.DocumentedMcpTool(folder.tryFoldString(argument) ?? '', new McpProfiles_1.McpProfiles().read(call?.arguments[1], folder));
528
- }
529
495
  /**
530
496
  * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.
531
497
  *
@@ -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,oDAwB8B;AAC9B,sDAW8B;AAE9B,mE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C,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;AA7tBD,0CA6tBC","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_INBOUND,\n EXTERNAL_OUTBOUND,\n HTTP_METHODS as CONTRACT_HTTP_METHODS,\n MaskLog,\n PathParam,\n QueryParam,\n QueryString,\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 DocumentedParameter,\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_INBOUND, EXTERNAL_OUTBOUND];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = CONTRACT_HTTP_METHODS;\n\n/** The parameter decorators that bind an argument to the URL; every other argument is the body. */\nconst PATH_PARAM = PathParam.name;\nconst QUERY_PARAM = QueryParam.name;\n/** `@QueryString()` binds the WHOLE query string (a free-form multimap) — never a body, never a named parameter. */\nconst QUERY_STRING = QueryString.name;\nconst URL_BINDINGS: readonly string[] = [PATH_PARAM, QUERY_PARAM, QUERY_STRING];\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 ApiDocExtractor.booleanProperty(literal, 'additive'),\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 this.parametersOf(member, methodName, folder, resolver),\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /**\n * The request BODY: the one argument WITHOUT a URL binding (`@PathParam` / `@QueryParam` /\n * `@QueryString`) — the\n * same rule the router uses. An endpoint whose every argument is URL-bound has no request\n * document. A single-argument contract is unchanged: its one argument is the body.\n */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters.find(\n (candidate: ts.ParameterDeclaration) => ApiDocExtractor.urlBindingOf(candidate) === undefined,\n );\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** Every URL-bound argument, in declaration order — an OpenAPI `parameters` list. */\n private parametersOf(\n member: ts.MethodDeclaration,\n methodName: string,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedParameter[] {\n const parameters: DocumentedParameter[] = [];\n for (const parameter of member.parameters) {\n const binding = ApiDocExtractor.urlBindingOf(parameter);\n if (binding === undefined) continue;\n // A free-form query string documents no named parameter: the vendor's grammar is the vendor's.\n if (ApiDocExtractor.canonicalCallName(binding.expression) === QUERY_STRING) continue;\n const wireArgument = binding.arguments[0];\n if (wireArgument === undefined) {\n throw new ApiDocExtractionError(\n `a URL parameter of '${methodName}' declares no wire name`,\n SourceLocation.of(binding),\n \"Name the wire key: @PathParam('id') / @QueryParam('limit').\",\n );\n }\n const name = folder.foldString(wireArgument, `URL parameter name on '${methodName}'`);\n const isPath = ApiDocExtractor.canonicalCallName(binding.expression) === PATH_PARAM;\n const type =\n parameter.type === undefined\n ? undefined\n : resolver.resolve(parameter.type, `${methodName}.${name}`);\n const optional =\n parameter.questionToken !== undefined || parameter.initializer !== undefined;\n parameters.push(\n new DocumentedParameter(isPath ? 'path' : 'query', name, isPath || !optional, type),\n );\n }\n return parameters;\n }\n\n /** The `@PathParam(...)` / `@QueryParam(...)` call on one argument, if it has one. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static urlBindingOf(parameter: ts.ParameterDeclaration): ts.CallExpression | undefined {\n for (const name of URL_BINDINGS) {\n const call = ApiDocExtractor.decoratorCall(parameter, name);\n if (call !== undefined) return call;\n }\n return undefined;\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'], ['vendorAuth', 'vendorAuth'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/vendorAuth/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"]}
1
+ {"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,6DAA0D;AAC1D,sDAAmD;AACnD,mDAAgD;AAChD,uDAAiC;AACjC,oDAuB8B;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,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,4BAAgB,EAAE,6BAAiB,CAAC,CAAC;AACvG,MAAM,mBAAmB,GAAsB,CAAC,gBAAI,EAAE,4BAAgB,EAAE,iBAAK,CAAC,CAAC;AAC/E,MAAM,YAAY,GAAsB,wBAAqB,CAAC;AAE9D,mGAAmG;AACnG,MAAM,UAAU,GAAG,qBAAS,CAAC,IAAI,CAAC;AAClC,MAAM,WAAW,GAAG,sBAAU,CAAC,IAAI,CAAC;AACpC,oHAAoH;AACpH,MAAM,YAAY,GAAG,uBAAW,CAAC,IAAI,CAAC;AACtC,MAAM,Y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nimport { McpIdentities } from './McpIdentities';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL_INBOUND,\n EXTERNAL_OUTBOUND,\n HTTP_METHODS as CONTRACT_HTTP_METHODS,\n MaskLog,\n PathParam,\n QueryParam,\n QueryString,\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} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedParameter,\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_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_INBOUND, EXTERNAL_OUTBOUND];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = CONTRACT_HTTP_METHODS;\n\n/** The parameter decorators that bind an argument to the URL; every other argument is the body. */\nconst PATH_PARAM = PathParam.name;\nconst QUERY_PARAM = QueryParam.name;\n/** `@QueryString()` binds the WHOLE query string (a free-form multimap) — never a body, never a named parameter. */\nconst QUERY_STRING = QueryString.name;\nconst URL_BINDINGS: readonly string[] = [PATH_PARAM, QUERY_PARAM, QUERY_STRING];\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 mcpTools = new McpIdentities().read(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 ApiDocExtractor.booleanProperty(literal, 'additive'),\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 mcpTools,\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 this.parametersOf(member, methodName, folder, resolver),\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /**\n * The request BODY: the one argument WITHOUT a URL binding (`@PathParam` / `@QueryParam` /\n * `@QueryString`) — the\n * same rule the router uses. An endpoint whose every argument is URL-bound has no request\n * document. A single-argument contract is unchanged: its one argument is the body.\n */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters.find(\n (candidate: ts.ParameterDeclaration) => ApiDocExtractor.urlBindingOf(candidate) === undefined,\n );\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** Every URL-bound argument, in declaration order — an OpenAPI `parameters` list. */\n private parametersOf(\n member: ts.MethodDeclaration,\n methodName: string,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedParameter[] {\n const parameters: DocumentedParameter[] = [];\n for (const parameter of member.parameters) {\n const binding = ApiDocExtractor.urlBindingOf(parameter);\n if (binding === undefined) continue;\n // A free-form query string documents no named parameter: the vendor's grammar is the vendor's.\n if (ApiDocExtractor.canonicalCallName(binding.expression) === QUERY_STRING) continue;\n const wireArgument = binding.arguments[0];\n if (wireArgument === undefined) {\n throw new ApiDocExtractionError(\n `a URL parameter of '${methodName}' declares no wire name`,\n SourceLocation.of(binding),\n \"Name the wire key: @PathParam('id') / @QueryParam('limit').\",\n );\n }\n const name = folder.foldString(wireArgument, `URL parameter name on '${methodName}'`);\n const isPath = ApiDocExtractor.canonicalCallName(binding.expression) === PATH_PARAM;\n const type =\n parameter.type === undefined\n ? undefined\n : resolver.resolve(parameter.type, `${methodName}.${name}`);\n const optional =\n parameter.questionToken !== undefined || parameter.initializer !== undefined;\n parameters.push(\n new DocumentedParameter(isPath ? 'path' : 'query', name, isPath || !optional, type),\n );\n }\n return parameters;\n }\n\n /** The `@PathParam(...)` / `@QueryParam(...)` call on one argument, if it has one. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static urlBindingOf(parameter: ts.ParameterDeclaration): ts.CallExpression | undefined {\n for (const name of URL_BINDINGS) {\n const call = ApiDocExtractor.decoratorCall(parameter, name);\n if (call !== undefined) return call;\n }\n return undefined;\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'], ['vendorAuth', 'vendorAuth'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/vendorAuth/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 return CanonicalDecorator.nameOf(expression);\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 * `@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"]}
@@ -0,0 +1,5 @@
1
+ import * as ts from 'typescript';
2
+ /** Import-aware decorator names shared by endpoint and multi-identity extraction. */
3
+ export declare class CanonicalDecorator {
4
+ static nameOf(expression: ts.Expression): string | undefined;
5
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanonicalDecorator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ /** Import-aware decorator names shared by endpoint and multi-identity extraction. */
7
+ class CanonicalDecorator {
8
+ // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution
9
+ static nameOf(expression) {
10
+ for (const statement of expression.getSourceFile().statements) {
11
+ if (!ts.isImportDeclaration(statement) ||
12
+ !ts.isStringLiteral(statement.moduleSpecifier))
13
+ continue;
14
+ const module = statement.moduleSpecifier.text;
15
+ if (![
16
+ '@webpieces/core-util',
17
+ '@webpieces/http-routing',
18
+ '@webpieces/http-client-browser',
19
+ ].includes(module) &&
20
+ !module.endsWith('/core-util/src/http/decorators') &&
21
+ !module.endsWith('/core-util/src/http/auth-mode') &&
22
+ !module.endsWith('/core-util/src/http/authorization'))
23
+ continue;
24
+ const bindings = statement.importClause?.namedBindings;
25
+ if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {
26
+ const imported = bindings.elements.find((entry) => entry.name.text === expression.text);
27
+ if (imported)
28
+ return imported.propertyName?.text ?? imported.name.text;
29
+ }
30
+ if (bindings &&
31
+ ts.isNamespaceImport(bindings) &&
32
+ ts.isPropertyAccessExpression(expression) &&
33
+ ts.isIdentifier(expression.expression) &&
34
+ expression.expression.text === bindings.name.text)
35
+ return expression.name.text;
36
+ }
37
+ return undefined;
38
+ }
39
+ }
40
+ exports.CanonicalDecorator = CanonicalDecorator;
41
+ //# sourceMappingURL=CanonicalDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CanonicalDecorator.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/CanonicalDecorator.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AAEjC,qFAAqF;AACrF,MAAa,kBAAkB;IAC3B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C,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI;gBAEjD,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAvCD,gDAuCC","sourcesContent":["import * as ts from 'typescript';\n\n/** Import-aware decorator names shared by endpoint and multi-identity extraction. */\nexport class CanonicalDecorator {\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static nameOf(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (\n !ts.isImportDeclaration(statement) ||\n !ts.isStringLiteral(statement.moduleSpecifier)\n )\n continue;\n const module = statement.moduleSpecifier.text;\n if (\n ![\n '@webpieces/core-util',\n '@webpieces/http-routing',\n '@webpieces/http-client-browser',\n ].includes(module) &&\n !module.endsWith('/core-util/src/http/decorators') &&\n !module.endsWith('/core-util/src/http/auth-mode') &&\n !module.endsWith('/core-util/src/http/authorization')\n )\n continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find(\n (entry: ts.ImportSpecifier) => entry.name.text === expression.text,\n );\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (\n bindings &&\n ts.isNamespaceImport(bindings) &&\n ts.isPropertyAccessExpression(expression) &&\n ts.isIdentifier(expression.expression) &&\n expression.expression.text === bindings.name.text\n )\n return expression.name.text;\n }\n return undefined;\n }\n}\n"]}
@@ -8,10 +8,10 @@ const DocLink_1 = require("../model/DocLink");
8
8
  const ConstantFolder_1 = require("./ConstantFolder");
9
9
  const FieldDecorators_1 = require("./FieldDecorators");
10
10
  const SourceLocation_1 = require("./SourceLocation");
11
+ const McpIdentities_1 = require("./McpIdentities");
11
12
  /** The decorator names, from the REAL SYMBOLS — see `ApiDocExtractor`'s constants (#1001). */
12
13
  const API_PATH = core_util_1.ApiPath.name;
13
14
  const ENDPOINT = core_util_1.Endpoint.name;
14
- const MCP_TOOL = core_util_1.WpMcpTool.name;
15
15
  /** `https://…`, `mailto:` and friends: a link to the web, not to a declaration. */
16
16
  const URL_TARGET = /^[a-z][a-z0-9+.-]*:\S*/i;
17
17
  /**
@@ -99,8 +99,10 @@ class DocLinkReader {
99
99
  if (!ts.isMethodDeclaration(member) || !FieldDecorators_1.FieldDecorators.hasDecorator(member, ENDPOINT)) {
100
100
  return DocLinkReader.unresolved(written, label, location, `it names a member of contract ${contract.name?.text ?? '<anonymous>'} that is not an @${ENDPOINT} method`);
101
101
  }
102
- const tool = FieldDecorators_1.FieldDecorators.decoratorCall(member, MCP_TOOL)?.arguments[0];
103
- return new DocLink_1.DocLink(DocLink_1.DocLinkKind.OPERATION, written, label, location, contract.name?.text ?? '<anonymous>', member.name.getText(), '', tool === undefined ? undefined : this.folder.tryFoldString(tool), '');
102
+ const tools = new McpIdentities_1.McpIdentities().read(member, this.folder);
103
+ return new DocLink_1.DocLink(DocLink_1.DocLinkKind.OPERATION, written, label, location, contract.name?.text ?? '<anonymous>', member.name.getText(), '', tools.length === 0
104
+ ? undefined
105
+ : tools.map((tool) => tool.name).join(' / '), '');
104
106
  }
105
107
  /** The declaration's symbol, through an import alias; a `#member` resolves on its right side. */
106
108
  symbolOf(name) {
@@ -1 +1 @@
1
- {"version":3,"file":"DocLinkReader.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/DocLinkReader.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,oDAAoE;AACpE,8CAAqE;AAErE,qDAAkD;AAClD,uDAAoD;AACpD,qDAAkD;AAGlD,8FAA8F;AAC9F,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,oBAAQ,CAAC,IAAI,CAAC;AAC/B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAEhC,mFAAmF;AACnF,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAK7C;;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K,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,UAAU,CACrB,OAAe,EACf,KAAyB,EACzB,QAAgB,EAChB,MAAc;QAEd,OAAO,IAAI,iBAAO,CACd,qBAAW,CAAC,UAAU,EACtB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,EAAE,EACF,EAAE,EACF,EAAE,EACF,SAAS,EACT,MAAM,CACT,CAAC;IACN,CAAC;CACJ;AAhQD,sCAgQC","sourcesContent":["import * as ts from 'typescript';\nimport { ApiPath, Endpoint, WpMcpTool } from '@webpieces/core-util';\nimport { DocLink, DocLinkKind, DocLinkText } from '../model/DocLink';\nimport { SchemaNames } from '../model/SchemaNames';\nimport { ConstantFolder } from './ConstantFolder';\nimport { FieldDecorators } from './FieldDecorators';\nimport { SourceLocation } from './SourceLocation';\nimport { TypeRegistry } from './TypeRegistry';\n\n/** The decorator names, from the REAL SYMBOLS — see `ApiDocExtractor`'s constants (#1001). */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MCP_TOOL = WpMcpTool.name;\n\n/** `https://…`, `mailto:` and friends: a link to the web, not to a declaration. */\nconst URL_TARGET = /^[a-z][a-z0-9+.-]*:\\S*/i;\n\n/** Any of TypeScript's three inline link tags. */\ntype LinkPart = ts.JSDocLink | ts.JSDocLinkCode | ts.JSDocLinkPlain;\n\n/**\n * One JSDoc `{@link}` -> the text that stands for it in model prose (#1284).\n *\n * The COMPILER resolves the target, so a link means what the editor says it means — an import alias,\n * a qualified name and a `#member` all land on the declaration itself. What it lands on decides what\n * is recorded:\n *\n * | target | recorded as |\n * |---|---|\n * | a class, interface, enum or type alias | {@link DocLinkKind.TYPE}: its model key and published schema name |\n * | a member of one (`MenuDto.items`, `Gender.F`) | {@link DocLinkKind.TYPE} of the owner, the `.member` tail kept as written |\n * | a member written BARE (`{@link storeId}` in a sibling's JSDoc) | {@link DocLinkKind.MEMBER}: the member's published name, no owner prefix |\n * | an `@Endpoint` method of an `@ApiPath` contract | {@link DocLinkKind.OPERATION}: contract, method, `@WpMcpTool` name |\n * | a URL (`{@link https://…}`) | a markdown link, written out here — it names no declaration |\n * | anything else, or nothing | {@link DocLinkKind.UNRESOLVED}, with the reason |\n *\n * Nothing is refused HERE: whether a target is published is a question about one rendered output, so\n * every renderer refuses what it cannot name, naming every offender in one run.\n */\nexport class DocLinkReader {\n private readonly folder: ConstantFolder;\n\n constructor(\n private readonly checker: ts.TypeChecker,\n private readonly registry: TypeRegistry,\n private readonly schemaNames: SchemaNames,\n ) {\n this.folder = new ConstantFolder(checker);\n }\n\n /** The text `part` contributes to a prose string. */\n textOf(part: LinkPart): string {\n const written = part.name?.getText() ?? '';\n const url = DocLinkReader.urlOf(written, part.text);\n if (url !== undefined) {\n return url;\n }\n const label = DocLinkReader.labelOf(part.text);\n return DocLinkText.encode(this.linkOf(part, written, label));\n }\n\n private linkOf(part: LinkPart, written: string, label: string | undefined): DocLink {\n const location = SourceLocation.of(part);\n const symbol = part.name === undefined ? undefined : this.symbolOf(part.name);\n const declaration = symbol?.declarations?.[0];\n if (declaration === undefined) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'the compiler cannot resolve it — import the target into this file, or fix the name',\n );\n }\n if (DocLinkReader.isNamedType(declaration)) {\n return this.typeLink(declaration, written, label, location, '');\n }\n const owner = DocLinkReader.ownerOf(declaration);\n if (DocLinkReader.isNamedType(owner)) {\n if (ts.isClassDeclaration(owner) && FieldDecorators.hasDecorator(owner, API_PATH)) {\n return this.operationLink(owner, declaration, written, label, location);\n }\n const bare = DocLinkReader.bareMemberName(part.name!, declaration);\n if (bare !== undefined) {\n return this.memberLink(owner, bare, written, label, location);\n }\n return this.typeLink(owner, written, label, location, DocLinkReader.tailOf(part.name!));\n }\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'it names neither a published type nor a contract operation',\n );\n }\n\n private typeLink(\n declaration: NamedTypeDeclaration,\n written: string,\n label: string | undefined,\n location: string,\n member: string,\n ): DocLink {\n if (\n ts.isClassDeclaration(declaration) &&\n FieldDecorators.hasDecorator(declaration, API_PATH)\n ) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'a contract class is not published under its own name — link one of its methods',\n );\n }\n const name = declaration.name!.text;\n return new DocLink(\n DocLinkKind.TYPE,\n written,\n label,\n location,\n this.registry.keyFor(name, declaration),\n this.schemaNames.nameOf(name, declaration.getSourceFile().fileName),\n member,\n undefined,\n '',\n );\n }\n\n /**\n * A member written bare (#1308). TypeScript resolves `{@link storeId}` in a member's JSDoc to the\n * property of the enclosing class or interface — its own, or one it inherits — so the owner here is\n * the type that DECLARES it, which may be a base the document flattens away. Nothing about that\n * owner is checked: the published name is the member's own, read the way the field is.\n */\n private memberLink(\n owner: NamedTypeDeclaration,\n member: string,\n written: string,\n label: string | undefined,\n location: string,\n ): DocLink {\n const name = owner.name.text;\n return new DocLink(\n DocLinkKind.MEMBER,\n written,\n label,\n location,\n this.registry.keyFor(name, owner),\n this.schemaNames.nameOf(name, owner.getSourceFile().fileName),\n member,\n undefined,\n '',\n );\n }\n\n private operationLink(\n contract: ts.ClassDeclaration,\n member: ts.Declaration,\n written: string,\n label: string | undefined,\n location: string,\n ): DocLink {\n if (!ts.isMethodDeclaration(member) || !FieldDecorators.hasDecorator(member, ENDPOINT)) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n `it names a member of contract ${contract.name?.text ?? '<anonymous>'} that is not an @${ENDPOINT} method`,\n );\n }\n const tool = FieldDecorators.decoratorCall(member, MCP_TOOL)?.arguments[0];\n return new DocLink(\n DocLinkKind.OPERATION,\n written,\n label,\n location,\n contract.name?.text ?? '<anonymous>',\n member.name.getText(),\n '',\n tool === undefined ? undefined : this.folder.tryFoldString(tool),\n '',\n );\n }\n\n /** The declaration's symbol, through an import alias; a `#member` resolves on its right side. */\n private symbolOf(name: ts.EntityName | ts.JSDocMemberName): ts.Symbol | undefined {\n const symbol =\n this.checker.getSymbolAtLocation(name) ??\n (ts.isJSDocMemberName(name) ? this.checker.getSymbolAtLocation(name.right) : undefined);\n if (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0) {\n return this.checker.getAliasedSymbol(symbol);\n }\n return symbol;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static isNamedType(node: ts.Node | undefined): node is NamedTypeDeclaration {\n return (\n node !== undefined &&\n (ts.isClassDeclaration(node) ||\n ts.isInterfaceDeclaration(node) ||\n ts.isEnumDeclaration(node) ||\n ts.isTypeAliasDeclaration(node)) &&\n node.name !== undefined\n );\n }\n\n /** The type a member belongs to — through a type literal to the alias that names it. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static ownerOf(member: ts.Declaration): ts.Node | undefined {\n const parent = member.parent;\n return ts.isTypeLiteralNode(parent) && ts.isTypeAliasDeclaration(parent.parent)\n ? parent.parent\n : parent;\n }\n\n /**\n * The published name of a member the link names BARE — an identifier, not `Type.member` /\n * `Type#member` — read exactly as `TypeResolver` names a field (an identifier's or a quoted\n * name's text; nothing renames a property on the wire). Undefined when the link is qualified or\n * the member has no such name.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static bareMemberName(\n name: ts.EntityName | ts.JSDocMemberName,\n member: ts.Declaration,\n ): string | undefined {\n if (!ts.isIdentifier(name)) {\n return undefined;\n }\n const memberName = (member as ts.NamedDeclaration).name;\n if (\n memberName === undefined ||\n (!ts.isIdentifier(memberName) && !ts.isStringLiteral(memberName))\n ) {\n return undefined;\n }\n return memberName.text;\n }\n\n /** `.items` of `MenuDto.items`, `#items` of `MenuDto#items` — the tail exactly as written. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static tailOf(name: ts.EntityName | ts.JSDocMemberName): string {\n if (ts.isQualifiedName(name)) {\n return `.${name.right.text}`;\n }\n if (ts.isJSDocMemberName(name)) {\n return `#${name.right.text}`;\n }\n return '';\n }\n\n /**\n * `{@link https://x | Example}` -> `[Example](https://x)`, `{@link https://x}` -> `<https://x>`.\n * TypeScript reads the scheme as the link's NAME and the rest as its text, so the URL is rebuilt.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static urlOf(written: string, text: string): string | undefined {\n const raw = `${written}${text}`.trim();\n if (!URL_TARGET.test(raw) || !raw.startsWith(`${written}:`)) {\n return undefined;\n }\n const pipe = raw.indexOf('|');\n const url = pipe >= 0 ? raw.slice(0, pipe).trim() : (raw.split(/\\s/)[0] ?? raw);\n const label = DocLinkReader.labelOf(\n pipe >= 0 ? raw.slice(pipe + 1) : raw.slice(url.length),\n );\n return label === undefined ? `<${url}>` : `[${label}](${url})`;\n }\n\n /** `| the label` / ` the label` -> `the label`; nothing -> undefined. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static labelOf(text: string): string | undefined {\n const label = text.replace(/^[|\\s]+/, '').trim();\n return label === '' ? undefined : label;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static unresolved(\n written: string,\n label: string | undefined,\n location: string,\n reason: string,\n ): DocLink {\n return new DocLink(\n DocLinkKind.UNRESOLVED,\n written,\n label,\n location,\n '',\n '',\n '',\n undefined,\n reason,\n );\n }\n}\n\n/** A declaration that names a type a document can publish. */\ntype NamedTypeDeclaration = (\n | ts.ClassDeclaration\n | ts.InterfaceDeclaration\n | ts.EnumDeclaration\n | ts.TypeAliasDeclaration\n) & { name: ts.Identifier };\n"]}
1
+ {"version":3,"file":"DocLinkReader.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/DocLinkReader.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,oDAAyD;AACzD,8CAAqE;AAErE,qDAAkD;AAClD,uDAAoD;AACpD,qDAAkD;AAClD,mDAAgD;AAIhD,8FAA8F;AAC9F,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,oBAAQ,CAAC,IAAI,CAAC;AAE/B,mFA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Y;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,UAAU,CACrB,OAAe,EACf,KAAyB,EACzB,QAAgB,EAChB,MAAc;QAEd,OAAO,IAAI,iBAAO,CACd,qBAAW,CAAC,UAAU,EACtB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,EAAE,EACF,EAAE,EACF,EAAE,EACF,SAAS,EACT,MAAM,CACT,CAAC;IACN,CAAC;CACJ;AAlQD,sCAkQC","sourcesContent":["import * as ts from 'typescript';\nimport { ApiPath, Endpoint } from '@webpieces/core-util';\nimport { DocLink, DocLinkKind, DocLinkText } from '../model/DocLink';\nimport { SchemaNames } from '../model/SchemaNames';\nimport { ConstantFolder } from './ConstantFolder';\nimport { FieldDecorators } from './FieldDecorators';\nimport { SourceLocation } from './SourceLocation';\nimport { McpIdentities } from './McpIdentities';\nimport { DocumentedMcpTool } from '../model/ApiDocModel';\nimport { TypeRegistry } from './TypeRegistry';\n\n/** The decorator names, from the REAL SYMBOLS — see `ApiDocExtractor`'s constants (#1001). */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\n\n/** `https://…`, `mailto:` and friends: a link to the web, not to a declaration. */\nconst URL_TARGET = /^[a-z][a-z0-9+.-]*:\\S*/i;\n\n/** Any of TypeScript's three inline link tags. */\ntype LinkPart = ts.JSDocLink | ts.JSDocLinkCode | ts.JSDocLinkPlain;\n\n/**\n * One JSDoc `{@link}` -> the text that stands for it in model prose (#1284).\n *\n * The COMPILER resolves the target, so a link means what the editor says it means — an import alias,\n * a qualified name and a `#member` all land on the declaration itself. What it lands on decides what\n * is recorded:\n *\n * | target | recorded as |\n * |---|---|\n * | a class, interface, enum or type alias | {@link DocLinkKind.TYPE}: its model key and published schema name |\n * | a member of one (`MenuDto.items`, `Gender.F`) | {@link DocLinkKind.TYPE} of the owner, the `.member` tail kept as written |\n * | a member written BARE (`{@link storeId}` in a sibling's JSDoc) | {@link DocLinkKind.MEMBER}: the member's published name, no owner prefix |\n * | an `@Endpoint` method of an `@ApiPath` contract | {@link DocLinkKind.OPERATION}: contract, method, `@WpMcpTool` name |\n * | a URL (`{@link https://…}`) | a markdown link, written out here — it names no declaration |\n * | anything else, or nothing | {@link DocLinkKind.UNRESOLVED}, with the reason |\n *\n * Nothing is refused HERE: whether a target is published is a question about one rendered output, so\n * every renderer refuses what it cannot name, naming every offender in one run.\n */\nexport class DocLinkReader {\n private readonly folder: ConstantFolder;\n\n constructor(\n private readonly checker: ts.TypeChecker,\n private readonly registry: TypeRegistry,\n private readonly schemaNames: SchemaNames,\n ) {\n this.folder = new ConstantFolder(checker);\n }\n\n /** The text `part` contributes to a prose string. */\n textOf(part: LinkPart): string {\n const written = part.name?.getText() ?? '';\n const url = DocLinkReader.urlOf(written, part.text);\n if (url !== undefined) {\n return url;\n }\n const label = DocLinkReader.labelOf(part.text);\n return DocLinkText.encode(this.linkOf(part, written, label));\n }\n\n private linkOf(part: LinkPart, written: string, label: string | undefined): DocLink {\n const location = SourceLocation.of(part);\n const symbol = part.name === undefined ? undefined : this.symbolOf(part.name);\n const declaration = symbol?.declarations?.[0];\n if (declaration === undefined) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'the compiler cannot resolve it — import the target into this file, or fix the name',\n );\n }\n if (DocLinkReader.isNamedType(declaration)) {\n return this.typeLink(declaration, written, label, location, '');\n }\n const owner = DocLinkReader.ownerOf(declaration);\n if (DocLinkReader.isNamedType(owner)) {\n if (ts.isClassDeclaration(owner) && FieldDecorators.hasDecorator(owner, API_PATH)) {\n return this.operationLink(owner, declaration, written, label, location);\n }\n const bare = DocLinkReader.bareMemberName(part.name!, declaration);\n if (bare !== undefined) {\n return this.memberLink(owner, bare, written, label, location);\n }\n return this.typeLink(owner, written, label, location, DocLinkReader.tailOf(part.name!));\n }\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'it names neither a published type nor a contract operation',\n );\n }\n\n private typeLink(\n declaration: NamedTypeDeclaration,\n written: string,\n label: string | undefined,\n location: string,\n member: string,\n ): DocLink {\n if (\n ts.isClassDeclaration(declaration) &&\n FieldDecorators.hasDecorator(declaration, API_PATH)\n ) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n 'a contract class is not published under its own name — link one of its methods',\n );\n }\n const name = declaration.name!.text;\n return new DocLink(\n DocLinkKind.TYPE,\n written,\n label,\n location,\n this.registry.keyFor(name, declaration),\n this.schemaNames.nameOf(name, declaration.getSourceFile().fileName),\n member,\n undefined,\n '',\n );\n }\n\n /**\n * A member written bare (#1308). TypeScript resolves `{@link storeId}` in a member's JSDoc to the\n * property of the enclosing class or interface — its own, or one it inherits — so the owner here is\n * the type that DECLARES it, which may be a base the document flattens away. Nothing about that\n * owner is checked: the published name is the member's own, read the way the field is.\n */\n private memberLink(\n owner: NamedTypeDeclaration,\n member: string,\n written: string,\n label: string | undefined,\n location: string,\n ): DocLink {\n const name = owner.name.text;\n return new DocLink(\n DocLinkKind.MEMBER,\n written,\n label,\n location,\n this.registry.keyFor(name, owner),\n this.schemaNames.nameOf(name, owner.getSourceFile().fileName),\n member,\n undefined,\n '',\n );\n }\n\n private operationLink(\n contract: ts.ClassDeclaration,\n member: ts.Declaration,\n written: string,\n label: string | undefined,\n location: string,\n ): DocLink {\n if (!ts.isMethodDeclaration(member) || !FieldDecorators.hasDecorator(member, ENDPOINT)) {\n return DocLinkReader.unresolved(\n written,\n label,\n location,\n `it names a member of contract ${contract.name?.text ?? '<anonymous>'} that is not an @${ENDPOINT} method`,\n );\n }\n const tools = new McpIdentities().read(member, this.folder);\n return new DocLink(\n DocLinkKind.OPERATION,\n written,\n label,\n location,\n contract.name?.text ?? '<anonymous>',\n member.name.getText(),\n '',\n tools.length === 0\n ? undefined\n : tools.map((tool: DocumentedMcpTool) => tool.name).join(' / '),\n '',\n );\n }\n\n /** The declaration's symbol, through an import alias; a `#member` resolves on its right side. */\n private symbolOf(name: ts.EntityName | ts.JSDocMemberName): ts.Symbol | undefined {\n const symbol =\n this.checker.getSymbolAtLocation(name) ??\n (ts.isJSDocMemberName(name) ? this.checker.getSymbolAtLocation(name.right) : undefined);\n if (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0) {\n return this.checker.getAliasedSymbol(symbol);\n }\n return symbol;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static isNamedType(node: ts.Node | undefined): node is NamedTypeDeclaration {\n return (\n node !== undefined &&\n (ts.isClassDeclaration(node) ||\n ts.isInterfaceDeclaration(node) ||\n ts.isEnumDeclaration(node) ||\n ts.isTypeAliasDeclaration(node)) &&\n node.name !== undefined\n );\n }\n\n /** The type a member belongs to — through a type literal to the alias that names it. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static ownerOf(member: ts.Declaration): ts.Node | undefined {\n const parent = member.parent;\n return ts.isTypeLiteralNode(parent) && ts.isTypeAliasDeclaration(parent.parent)\n ? parent.parent\n : parent;\n }\n\n /**\n * The published name of a member the link names BARE — an identifier, not `Type.member` /\n * `Type#member` — read exactly as `TypeResolver` names a field (an identifier's or a quoted\n * name's text; nothing renames a property on the wire). Undefined when the link is qualified or\n * the member has no such name.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static bareMemberName(\n name: ts.EntityName | ts.JSDocMemberName,\n member: ts.Declaration,\n ): string | undefined {\n if (!ts.isIdentifier(name)) {\n return undefined;\n }\n const memberName = (member as ts.NamedDeclaration).name;\n if (\n memberName === undefined ||\n (!ts.isIdentifier(memberName) && !ts.isStringLiteral(memberName))\n ) {\n return undefined;\n }\n return memberName.text;\n }\n\n /** `.items` of `MenuDto.items`, `#items` of `MenuDto#items` — the tail exactly as written. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static tailOf(name: ts.EntityName | ts.JSDocMemberName): string {\n if (ts.isQualifiedName(name)) {\n return `.${name.right.text}`;\n }\n if (ts.isJSDocMemberName(name)) {\n return `#${name.right.text}`;\n }\n return '';\n }\n\n /**\n * `{@link https://x | Example}` -> `[Example](https://x)`, `{@link https://x}` -> `<https://x>`.\n * TypeScript reads the scheme as the link's NAME and the rest as its text, so the URL is rebuilt.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static urlOf(written: string, text: string): string | undefined {\n const raw = `${written}${text}`.trim();\n if (!URL_TARGET.test(raw) || !raw.startsWith(`${written}:`)) {\n return undefined;\n }\n const pipe = raw.indexOf('|');\n const url = pipe >= 0 ? raw.slice(0, pipe).trim() : (raw.split(/\\s/)[0] ?? raw);\n const label = DocLinkReader.labelOf(\n pipe >= 0 ? raw.slice(pipe + 1) : raw.slice(url.length),\n );\n return label === undefined ? `<${url}>` : `[${label}](${url})`;\n }\n\n /** `| the label` / ` the label` -> `the label`; nothing -> undefined. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static labelOf(text: string): string | undefined {\n const label = text.replace(/^[|\\s]+/, '').trim();\n return label === '' ? undefined : label;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static unresolved(\n written: string,\n label: string | undefined,\n location: string,\n reason: string,\n ): DocLink {\n return new DocLink(\n DocLinkKind.UNRESOLVED,\n written,\n label,\n location,\n '',\n '',\n '',\n undefined,\n reason,\n );\n }\n}\n\n/** A declaration that names a type a document can publish. */\ntype NamedTypeDeclaration = (\n | ts.ClassDeclaration\n | ts.InterfaceDeclaration\n | ts.EnumDeclaration\n | ts.TypeAliasDeclaration\n) & { name: ts.Identifier };\n"]}
@@ -0,0 +1,7 @@
1
+ import * as ts from 'typescript';
2
+ import { DocumentedMcpTool } from '../model/ApiDocModel';
3
+ import { ConstantFolder } from './ConstantFolder';
4
+ /** Every authored identity on one method, independent of TypeScript's decorator execution order. */
5
+ export declare class McpIdentities {
6
+ read(member: ts.Node, folder: ConstantFolder): readonly DocumentedMcpTool[];
7
+ }