@webpieces/api-doc-model 0.4.957 → 0.4.958

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.957",
3
+ "version": "0.4.958",
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.957",
26
+ "@webpieces/core-util": "0.4.958",
27
27
  "typescript": "5.9.3",
28
28
  "minimatch": "10.0.1"
29
29
  }
@@ -111,8 +111,17 @@ export declare class ApiDocExtractor {
111
111
  * like a contract somebody deliberately kept internal.
112
112
  */
113
113
  private declaredApiTypes;
114
- /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */
114
+ /**
115
+ * The request BODY: the one argument WITHOUT a URL binding (`@PathParam` / `@QueryParam` /
116
+ * `@QueryString`) — the
117
+ * same rule the router uses. An endpoint whose every argument is URL-bound has no request
118
+ * document. A single-argument contract is unchanged: its one argument is the body.
119
+ */
115
120
  private requestOf;
121
+ /** Every URL-bound argument, in declaration order — an OpenAPI `parameters` list. */
122
+ private parametersOf;
123
+ /** The `@PathParam(...)` / `@QueryParam(...)` call on one argument, if it has one. */
124
+ private static urlBindingOf;
116
125
  /** The declared return type, unwrapped from `Promise<...>` by the resolver. */
117
126
  private responseOf;
118
127
  /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */
@@ -54,9 +54,15 @@ const API_TYPE = core_util_1.ApiType.name;
54
54
  * quietly matching nothing.
55
55
  */
56
56
  /** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */
57
- const ENDPOINT_KINDS = [core_util_1.RPC, core_util_1.CLOUDTASKS, core_util_1.CRON, core_util_1.EXTERNAL];
57
+ const ENDPOINT_KINDS = [core_util_1.RPC, core_util_1.CLOUDTASKS, core_util_1.CRON, core_util_1.EXTERNAL_INBOUND, core_util_1.EXTERNAL_OUTBOUND];
58
58
  const ENDPOINT_OPERATIONS = [core_util_1.READ, core_util_1.WRITE_IDEMPOTENT, core_util_1.WRITE];
59
- const HTTP_METHODS = [core_util_1.GET, core_util_1.POST];
59
+ const HTTP_METHODS = core_util_1.HTTP_METHODS;
60
+ /** The parameter decorators that bind an argument to the URL; every other argument is the body. */
61
+ const PATH_PARAM = core_util_1.PathParam.name;
62
+ const QUERY_PARAM = core_util_1.QueryParam.name;
63
+ /** `@QueryString()` binds the WHOLE query string (a free-form multimap) — never a body, never a named parameter. */
64
+ const QUERY_STRING = core_util_1.QueryString.name;
65
+ const URL_BINDINGS = [PATH_PARAM, QUERY_PARAM, QUERY_STRING];
60
66
  /** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */
61
67
  const ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];
62
68
  /** The allowed values of each required position, in the same order, for the same failure. */
@@ -299,7 +305,7 @@ class ApiDocExtractor {
299
305
  const doc = resolver.readDoc(member);
300
306
  const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);
301
307
  const streaming = new StreamingSignature_1.StreamingSignature().read(member, folder, resolver);
302
- return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.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);
308
+ return new ApiDocModel_1.DocumentedEndpoint(methodName, httpMethod, path, operation, kind, ApiDocExtractor.booleanProperty(literal, 'hidden'), ApiDocExtractor.booleanProperty(literal, 'openWorld'), new ApiDocModel_1.DocumentedEndpointOptions(ApiDocExtractor.booleanProperty(literal, 'formPost'), ApiDocExtractor.stringProperty(literal, 'calledBy', folder), ApiDocExtractor.stringProperty(literal, 'callerKind', folder)), ApiDocExtractor.authOf(member, folder), mcpTool, ApiDocExtractor.invalidForMcpOf(member, folder), ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(), ApiDocExtractor.maskLogOf(member), doc.description, doc.summary, doc.mcp, doc.returns, this.requestOf(member, methodName, resolver), streaming?.initialResponse ?? this.responseOf(member, methodName, resolver), streaming, ApiDocExtractor.decoratorCall(member, core_util_1.WpLocalOnly.name) !== undefined, this.parametersOf(member, methodName, folder, resolver));
303
309
  }
304
310
  /**
305
311
  * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.
@@ -343,14 +349,53 @@ class ApiDocExtractor {
343
349
  }
344
350
  return declared.length === 0 ? DEFAULT_API_TYPES : declared;
345
351
  }
346
- /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */
352
+ /**
353
+ * The request BODY: the one argument WITHOUT a URL binding (`@PathParam` / `@QueryParam` /
354
+ * `@QueryString`) — the
355
+ * same rule the router uses. An endpoint whose every argument is URL-bound has no request
356
+ * document. A single-argument contract is unchanged: its one argument is the body.
357
+ */
347
358
  requestOf(member, methodName, resolver) {
348
- const parameter = member.parameters[0];
359
+ const parameter = member.parameters.find((candidate) => ApiDocExtractor.urlBindingOf(candidate) === undefined);
349
360
  if (parameter?.type === undefined) {
350
361
  return undefined;
351
362
  }
352
363
  return resolver.resolve(parameter.type, `${methodName}.request`);
353
364
  }
365
+ /** Every URL-bound argument, in declaration order — an OpenAPI `parameters` list. */
366
+ parametersOf(member, methodName, folder, resolver) {
367
+ const parameters = [];
368
+ for (const parameter of member.parameters) {
369
+ const binding = ApiDocExtractor.urlBindingOf(parameter);
370
+ if (binding === undefined)
371
+ continue;
372
+ // A free-form query string documents no named parameter: the vendor's grammar is the vendor's.
373
+ if (ApiDocExtractor.canonicalCallName(binding.expression) === QUERY_STRING)
374
+ continue;
375
+ const wireArgument = binding.arguments[0];
376
+ if (wireArgument === undefined) {
377
+ throw new ApiDocExtractionError_1.ApiDocExtractionError(`a URL parameter of '${methodName}' declares no wire name`, SourceLocation_1.SourceLocation.of(binding), "Name the wire key: @PathParam('id') / @QueryParam('limit').");
378
+ }
379
+ const name = folder.foldString(wireArgument, `URL parameter name on '${methodName}'`);
380
+ const isPath = ApiDocExtractor.canonicalCallName(binding.expression) === PATH_PARAM;
381
+ const type = parameter.type === undefined
382
+ ? undefined
383
+ : resolver.resolve(parameter.type, `${methodName}.${name}`);
384
+ const optional = parameter.questionToken !== undefined || parameter.initializer !== undefined;
385
+ parameters.push(new ApiDocModel_1.DocumentedParameter(isPath ? 'path' : 'query', name, isPath || !optional, type));
386
+ }
387
+ return parameters;
388
+ }
389
+ /** The `@PathParam(...)` / `@QueryParam(...)` call on one argument, if it has one. */
390
+ // webpieces-disable no-function-outside-class -- private static declaration reader
391
+ static urlBindingOf(parameter) {
392
+ for (const name of URL_BINDINGS) {
393
+ const call = ApiDocExtractor.decoratorCall(parameter, name);
394
+ if (call !== undefined)
395
+ return call;
396
+ }
397
+ return undefined;
398
+ }
354
399
  /** The declared return type, unwrapped from `Promise<...>` by the resolver. */
355
400
  responseOf(member, methodName, resolver) {
356
401
  if (member.type === undefined) {
@@ -379,9 +424,9 @@ class ApiDocExtractor {
379
424
  if (!ts.isCallExpression(element))
380
425
  throw new ApiDocExtractionError_1.ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation_1.SourceLocation.of(element), 'Use canonical credential descriptors.');
381
426
  const name = this.canonicalCallName(element.expression);
382
- const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');
427
+ const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['vendorAuth', 'vendorAuth'], ['apiKey', 'apikey']]).get(name ?? '');
383
428
  if (!kind)
384
- throw new ApiDocExtractionError_1.ApiDocExtractionError('Unknown authentication descriptor', SourceLocation_1.SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');
429
+ throw new ApiDocExtractionError_1.ApiDocExtractionError('Unknown authentication descriptor', SourceLocation_1.SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/vendorAuth/apiKey from core-util.');
385
430
  methods.push(new ApiDocModel_1.DocumentedAuthMethod(kind, element.arguments.map((argument) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));
386
431
  }
387
432
  return new ApiDocModel_1.DocumentedAuth(undefined, methods);
@@ -1 +1 @@
1
- {"version":3,"file":"ApiDocExtractor.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/ApiDocExtractor.ts"],"names":[],"mappings":";;;;AAAA,sDAAmD;AACnD,+CAA4C;AAC5C,uDAAiC;AACjC,oDAqB8B;AAC9B,sDAU8B;AAE9B,mEAAgE;AAChE,qDAAkD;AAClD,qEAAwF;AACxF,qDAAkD;AAClD,mDAA+D;AAC/D,+DAA4D;AAC5D,mDAAgD;AAChD,iDAA8C;AAC9C,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,oBAAQ,CAAC,IAAI,CA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,CAAC,CAAC,EAAE,CAAC;QACpF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC;YAClC,IACI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,aAAa,EACtE,CAAC;gBACC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAtqBD,0CAsqBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport { McpProfiles } from './McpProfiles';\nimport * as ts from 'typescript';\nimport {\n ApiPath,\n CLOUDTASKS,\n CRON,\n Endpoint,\n EXTERNAL,\n GET,\n MaskLog,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n WpAuthPublic,\n WpAuth, WpAuthorization, WpLocalOnly, apiKey,\n ApiType,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n InvalidEndpointForMcp,\n WpMcpTool,\n} from '@webpieces/core-util';\nimport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedMcpTool,\n} from '../model/ApiDocModel';\nimport { TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ContextKeyHeaderFolder, ContextKeyHeaderSlot } from './ContextKeyHeaderFolder';\nimport { SourceLocation } from './SourceLocation';\nimport { assertApiTypeMatchesMcpTools } from './McpMembership';\nimport { ComponentsExtractor } from './ComponentsExtractor';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeResolver } from './TypeResolver';\nimport { StreamingSignature } from './StreamingSignature';\n\n/**\n * The decorator names this extractor matches on, taken from the REAL SYMBOLS rather than re-typed as\n * string literals.\n *\n * ## Why `.name` and not `'Endpoint'`\n *\n * The extractor matches decorators by NAME on the syntax — it must, because it reads a contract with\n * the compiler and never executes it. The question is only where that name comes from, and a literal\n * has a silent failure mode that a symbol does not: rename `@WpMcpTool` in `core-util` and a literal\n * simply stops matching. The extractor then finds zero MCP tools, the MCP document is correctly not\n * written because it has no tools in it, and the BUILD IS GREEN. A partner-facing document silently\n * loses a section with nothing red anywhere (issue #1001).\n *\n * `Endpoint.name` makes that rename a COMPILE ERROR here, which in this repo is the delivery\n * mechanism for a migration rather than an obstacle to one: a compile break names the new spelling\n * and an agent applies it in one pass, where a green build teaches nobody anything.\n *\n * ## Why importing `@webpieces/core-util` is not the coupling it looks like\n *\n * Any contract carrying `@Endpoint` already depends on `core-util` by definition, so there is no\n * upstream project this import could shut out. It is build-time only, it creates no cycle, and it\n * costs a browser bundle nothing because nothing in a bundle imports this package. The direction that\n * WOULD be fatal is `core-util` depending on the TypeScript compiler, and that is not this.\n */\nconst API_PATH = ApiPath.name;\nconst ENDPOINT = Endpoint.name;\nconst MASK_LOG = MaskLog.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\nconst AUTHORIZATION = WpAuthorization.name;\nconst API_KEY_AUTH = apiKey.name;\nconst API_TYPE = ApiType.name;\n\n/**\n * The prefix shared by every credential decorator. A PREFIX genuinely has no symbol to take a name\n * from, so it stays a literal — but the set it selects is pinned below, which is what stops it\n * quietly matching nothing.\n */\n/** The REAL trigger kinds and side-effect contracts, so a contract cannot declare one that is not. */\nconst ENDPOINT_KINDS: readonly string[] = [RPC, CLOUDTASKS, CRON, EXTERNAL];\nconst ENDPOINT_OPERATIONS: readonly string[] = [READ, WRITE_IDEMPOTENT, WRITE];\nconst HTTP_METHODS: readonly string[] = [GET, POST];\n\n/** `@Endpoint`'s four required positions, named so a failure can say which one is missing. */\nconst ARGUMENT_NAMES = ['http method', 'path', 'operation', 'trigger kind'];\n\n/** The allowed values of each required position, in the same order, for the same failure. */\nconst ARGUMENT_VALUES: readonly (readonly string[])[] = [\n HTTP_METHODS,\n [],\n ENDPOINT_OPERATIONS,\n ENDPOINT_KINDS,\n];\n\n/** The REAL document types, so a contract cannot name a document that does not exist. */\nconst API_TYPES: readonly string[] = [SVC_TO_SVC, EXTERNAL_CUSTOMER, MCP];\n\n/** The fail-closed default: a contract that declares nothing feeds only the internal document. */\nconst DEFAULT_API_TYPES: readonly string[] = [SVC_TO_SVC];\n\n/**\n * ONE contract file -> ONE {@link ApiDocModel}. The single extraction pass both the OpenAPI documents\n * and the MCP tool list (#982) are rendered from.\n *\n * ## Why the compiler API at all\n *\n * A DTO field's TYPE IS ERASED AT RUNTIME. Reflection can see that `save` takes one argument; it\n * cannot see that the argument has a `deliveryWindow` that is a discriminated union of two shapes,\n * one of which carries an ISO timestamp. Those are precisely the shapes a partner-grade document is\n * made of, so the only place they exist is the source, and the only honest way to read the source is\n * the compiler.\n *\n * ## Why it IMPORTS `@webpieces/core-util`\n *\n * Decorators are matched BY NAME on the syntax — they must be, because this reads a contract and\n * never executes it. The NAMES come from the real symbols (`Endpoint.name`), so a rename in\n * `core-util` is a compile error here instead of a literal that quietly stops matching. The full\n * argument, and why the import is not the coupling it looks like, is at those constants.\n *\n * ## What it does NOT do\n *\n * It emits nothing. No OpenAPI, no MCP tool definitions, no file — that is #982, and keeping the\n * render out means the two renderers cannot drift apart about what the contract SAYS.\n */\nexport class ApiDocExtractor {\n constructor(private readonly schemaNames: SchemaNames = new SchemaNames([])) {}\n /** Which package declares each file — the owner of every schema (#1058). Cached per directory. */\n private readonly packages = new PackageOfFile();\n /** A resolver whose HOME is the package declaring `source` — see {@link TypeResolver}. */\n private resolverFor(program: ts.Program, source: ts.SourceFile): TypeResolver {\n const home = this.packages.of(source.fileName)?.name;\n return new TypeResolver(program.getTypeChecker(), this.packages, home, this.schemaNames);\n }\n\n /**\n * Extract the contract in `entryFile`.\n *\n * @param entryFile absolute path to the `.ts` file holding the `@ApiPath` class.\n * @param compilerOptions handed straight to `ts.createProgram`; the caller owns them because\n * only the caller knows its own `paths` / `lib` setup.\n * @throws ApiDocExtractionError when the file holds no `@ApiPath` class, or when something that\n * must be exact (a path constant, a numeric bound) cannot be established.\n */\n extractFile(entryFile: string, compilerOptions: ts.CompilerOptions = {}): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extract(program, source);\n }\n\n /**\n * EVERY `@ApiPath` contract in one file, in declaration order.\n *\n * {@link extractFile} answers \"what is THE contract in this file\", which is the shape a manifest\n * entry and a generated document have: one contract, one file. This answers a different question\n * — \"what does this file declare\" — and it exists because a REPO does not obey that convention.\n * `McpRemoteFixtures.ts` in `@webpieces/mcp-server` declares seven contracts, and the runtime\n * registers MCP tools from all seven; a sweep that read only the first would report green while\n * six contracts' worth of tools had never been looked at, which is the exact shape of silent miss\n * this epic exists to remove.\n *\n * A file with no contract yields an EMPTY list rather than throwing: \"this file has none\" is an\n * ordinary answer to this question, where it is a failure to answer {@link extractFile}'s.\n */\n extractAll(\n entryFile: string,\n compilerOptions: ts.CompilerOptions = {},\n ): readonly ApiDocModel[] {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n return this.extractAllFrom(program, source);\n }\n\n /** {@link extractAll} against a program the caller already built. */\n extractAllFrom(program: ts.Program, source: ts.SourceFile): readonly ApiDocModel[] {\n // Binding establishes AST parent links used by canonical import resolution.\n program.getTypeChecker();\n const models: ApiDocModel[] = [];\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n models.push(this.extractContract(program, statement));\n }\n }\n return models;\n }\n\n /** The same extraction against a program the caller already built. */\n extract(program: ts.Program, source: ts.SourceFile): ApiDocModel {\n program.getTypeChecker();\n return this.extractContract(program, this.findContract(source));\n }\n\n /** ONE contract class -> ONE model. The single place the walk actually happens. */\n private extractContract(program: ts.Program, contract: ts.ClassDeclaration): ApiDocModel {\n const checker = program.getTypeChecker();\n const folder = new ConstantFolder(checker);\n const resolver = this.resolverFor(program, contract.getSourceFile());\n\n const pathDecorator = ApiDocExtractor.decoratorCall(contract, API_PATH)!;\n const basePathArgument = pathDecorator.arguments[0];\n const basePath =\n basePathArgument === undefined\n ? ''\n : folder.foldString(basePathArgument, '@ApiPath argument');\n\n const apiTypes = this.declaredApiTypes(contract, folder);\n const endpoints: DocumentedEndpoint[] = [];\n for (const member of contract.members) {\n const endpoint = this.endpointOf(member, folder, resolver);\n if (endpoint !== undefined) {\n endpoints.push(endpoint);\n }\n }\n assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints);\n\n return new ApiDocModel(\n contract.name?.text ?? '<anonymous>',\n apiTypes,\n basePath,\n resolver.readDoc(contract).description,\n endpoints,\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * Extract ONE named type and everything it reaches, from a file that holds NO contract.\n *\n * This exists for a type nothing in a contract points at but a document still publishes — the\n * document-wide error body a renderer's manifest names. Reading it with the SAME resolver is the\n * point: a second reader would be a second answer to \"what shape is this type\", and the two\n * would drift the first time a field changed.\n *\n * @throws ApiDocExtractionError when the file does not declare that name.\n */\n extractType(\n entryFile: string,\n typeName: string,\n compilerOptions: ts.CompilerOptions = {},\n ): ApiDocModel {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const resolver = this.resolverFor(program, source);\n const declaration = ApiDocExtractor.declarationNamed(source, typeName);\n if (declaration === undefined) {\n throw new ApiDocExtractionError(\n `no type named '${typeName}' is declared in this file`,\n entryFile,\n `Declare and export '${typeName}' there, or name the file that does.`,\n );\n }\n resolver.resolveDeclaration(typeName, declaration, typeName);\n return new ApiDocModel(\n typeName,\n DEFAULT_API_TYPES,\n '',\n '',\n [],\n resolver.collectedTypes(),\n resolver.collectedUnmapped(),\n resolver.collectedCollisions(),\n resolver.collectedStackedJsDoc(),\n );\n }\n\n /**\n * The header name an EXPORTED ContextKey rides under — what a manifest's response header names\n * instead of a string (#1249). `exportPath` is the export's name, or a dotted path into one\n * (`OneTabletKey.TX_ID`, a class's `static readonly` or an object's property).\n *\n * @throws ApiDocExtractionError naming the export when it is missing or cannot be followed to a\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` call declaring that header.\n */\n extractContextKeyHeader(\n entryFile: string,\n exportPath: string,\n slot: ContextKeyHeaderSlot,\n compilerOptions: ts.CompilerOptions = {},\n ): string {\n const program = ts.createProgram([entryFile], compilerOptions);\n const source = program.getSourceFile(entryFile);\n if (source === undefined) {\n throw new ApiDocExtractionError(\n 'entry file is not part of the program',\n entryFile,\n 'Pass an absolute path to a .ts file that exists.',\n );\n }\n const checker = program.getTypeChecker();\n const symbol = this.exportedMember(checker, source, exportPath);\n if (symbol === undefined) {\n throw new ApiDocExtractionError(\n `'${exportPath}' is not exported by this file`,\n entryFile,\n `Export the ContextKey there — e.g. \\`export const ${exportPath.split('.')[0]} = MyKeys.SOME_KEY;\\` — ` +\n 'or name the file that does.',\n );\n }\n return new ContextKeyHeaderFolder(new ConstantFolder(checker)).foldSymbol(\n symbol,\n exportPath,\n entryFile,\n slot,\n 'the manifest response header',\n );\n }\n\n /** `A` or `A.B.C`: the export `A`, then each property of its value in turn. */\n private exportedMember(\n checker: ts.TypeChecker,\n source: ts.SourceFile,\n exportPath: string,\n ): ts.Symbol | undefined {\n const moduleSymbol = checker.getSymbolAtLocation(source);\n if (moduleSymbol === undefined) {\n return undefined;\n }\n const segments = exportPath.split('.');\n let symbol: ts.Symbol | undefined = checker\n .getExportsOfModule(moduleSymbol)\n .find((exported: ts.Symbol) => exported.name === segments[0]);\n for (const segment of segments.slice(1)) {\n if (symbol === undefined) {\n return undefined;\n }\n const unaliased =\n (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;\n symbol = checker.getTypeOfSymbolAtLocation(unaliased, source).getProperty(segment);\n }\n return symbol;\n }\n\n /** A DTO library's exported types, for its components document (#1058). */\n extractComponents(\n entryFiles: readonly string[],\n compilerOptions: ts.CompilerOptions = {},\n ): ApiComponentsModel {\n return new ComponentsExtractor(this.packages, this.schemaNames).extract(entryFiles, compilerOptions);\n }\n\n /** The interface / class / type alias / enum declared under `name` at the file's top level. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static declarationNamed(\n source: ts.SourceFile,\n name: string,\n ): ts.Declaration | undefined {\n for (const statement of source.statements) {\n const named =\n ts.isInterfaceDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement);\n if (named && statement.name?.text === name) {\n return statement;\n }\n }\n return undefined;\n }\n\n /** The one `@ApiPath` class in the file. Zero is a hard failure; the FIRST wins if there are two. */\n private findContract(source: ts.SourceFile): ts.ClassDeclaration {\n for (const statement of source.statements) {\n if (\n ts.isClassDeclaration(statement) &&\n ApiDocExtractor.decoratorCall(statement, API_PATH) !== undefined\n ) {\n return statement;\n }\n }\n throw new ApiDocExtractionError(\n 'no @ApiPath class in this file',\n source.fileName,\n 'Point the extractor at the contract file — the one whose class carries @ApiPath.',\n );\n }\n\n /** One `@Endpoint` method. Members without the decorator are not part of the contract. */\n private endpointOf(\n member: ts.ClassElement,\n folder: ConstantFolder,\n resolver: TypeResolver,\n ): DocumentedEndpoint | undefined {\n if (!ts.isMethodDeclaration(member) || !ts.isIdentifier(member.name)) {\n return undefined;\n }\n const call = ApiDocExtractor.decoratorCall(member, ENDPOINT);\n if (call === undefined) {\n return undefined;\n }\n const methodName = member.name.text;\n\n // `@Endpoint(httpMethod, path, operation, kind, options?)` — METHOD-FIRST, five positions.\n // The positions are read here and nowhere else, so the one place that has to change when the\n // decorator changes is this block plus `ARGUMENT_NAMES` beside it.\n const httpMethod = this.requiredArgument(call, methodName, 0, folder);\n const path = this.requiredArgument(call, methodName, 1, folder);\n const operation = this.requiredArgument(call, methodName, 2, folder);\n const kind = this.requiredArgument(call, methodName, 3, folder);\n\n const options = call.arguments[4];\n const literal =\n options !== undefined && ts.isObjectLiteralExpression(options) ? options : undefined;\n\n const doc = resolver.readDoc(member);\n const mcpTool = ApiDocExtractor.mcpToolOf(member, folder);\n const streaming = new StreamingSignature().read(member, folder, resolver);\n return new DocumentedEndpoint(\n methodName,\n httpMethod,\n path,\n operation,\n kind,\n ApiDocExtractor.booleanProperty(literal, 'hidden'),\n ApiDocExtractor.booleanProperty(literal, 'openWorld'),\n new DocumentedEndpointOptions(\n ApiDocExtractor.booleanProperty(literal, 'formPost'),\n ApiDocExtractor.stringProperty(literal, 'calledBy', folder),\n ApiDocExtractor.stringProperty(literal, 'callerKind', folder),\n ),\n ApiDocExtractor.authOf(member, folder),\n mcpTool,\n ApiDocExtractor.invalidForMcpOf(member, folder),\n ApiDocExtractor.decoratorCall(member, AUTHORIZATION)?.arguments[0]?.getText(),\n ApiDocExtractor.maskLogOf(member),\n doc.description,\n doc.summary,\n doc.mcp,\n doc.returns,\n this.requestOf(member, methodName, resolver),\n streaming?.initialResponse ?? this.responseOf(member, methodName, resolver),\n streaming,\n ApiDocExtractor.decoratorCall(member, WpLocalOnly.name) !== undefined,\n );\n }\n\n /**\n * One REQUIRED positional argument of `@Endpoint`, folded to the string it denotes.\n *\n * Every one of the four is an enum member (`POST`, `READ`, `RPC`) as often as it is a literal,\n * and the folder resolves both — a document that printed `RPC` where the trigger goes would be\n * worse than no document. A missing one is a hard failure naming the position, because the\n * alternative is a document quietly missing a verb.\n */\n private requiredArgument(\n call: ts.CallExpression,\n methodName: string,\n index: number,\n folder: ConstantFolder,\n ): string {\n const argument = call.arguments[index];\n const what = ARGUMENT_NAMES[index];\n if (argument === undefined) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares no ${what}`,\n SourceLocation.of(call),\n \"Write all four: @Endpoint(POST, '/thing', READ, RPC).\",\n );\n }\n const value = folder.foldString(argument, `@Endpoint ${what} on '${methodName}'`);\n const allowed = ARGUMENT_VALUES[index]!;\n if (allowed.length > 0 && !allowed.includes(value)) {\n throw new ApiDocExtractionError(\n `@Endpoint on '${methodName}' declares ${what} '${value}', which is not one of ` +\n allowed.join(', '),\n SourceLocation.of(argument),\n `Use one of the exported constants: ${allowed.join(', ')}.`,\n );\n }\n return value;\n }\n\n /**\n * `@ApiType(...)` on the contract, folded to the real values.\n *\n * A value that is not one of the three documents is a HARD FAILURE rather than a silent drop: a\n * contract that named `CUSTOMER` by mistake would otherwise feed nothing, which looks exactly\n * like a contract somebody deliberately kept internal.\n */\n private declaredApiTypes(node: ts.Node, folder: ConstantFolder): readonly string[] {\n const call = ApiDocExtractor.decoratorCall(node, API_TYPE);\n if (call === undefined) {\n return DEFAULT_API_TYPES;\n }\n const declared = call.arguments.map((argument: ts.Expression) =>\n folder.foldString(argument, `@${API_TYPE} argument`),\n );\n for (const apiType of declared) {\n if (!API_TYPES.includes(apiType)) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names '${apiType}', which is not a generated document`,\n SourceLocation.of(call),\n `Use one of the exported constants: ${API_TYPES.join(', ')}.`,\n );\n }\n }\n return declared.length === 0 ? DEFAULT_API_TYPES : declared;\n }\n\n /** The FIRST parameter's declared type. An endpoint with no parameter has no request document. */\n private requestOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n const parameter = member.parameters[0];\n if (parameter?.type === undefined) {\n return undefined;\n }\n return resolver.resolve(parameter.type, `${methodName}.request`);\n }\n\n /** The declared return type, unwrapped from `Promise<...>` by the resolver. */\n private responseOf(\n member: ts.MethodDeclaration,\n methodName: string,\n resolver: TypeResolver,\n ): TypeRef | undefined {\n if (member.type === undefined) {\n return undefined;\n }\n return resolver.resolve(member.type, `${methodName}.response`);\n }\n\n /** Read OR alternatives structurally rather than preserving an opaque WpAuth array. */\n // webpieces-disable no-function-outside-class -- private static declaration reader\n private static authOf(member: ts.Node, folder: ConstantFolder): DocumentedAuth | undefined {\n const publicCall = this.decoratorCall(member, WpAuthPublic.name);\n if (publicCall) {\n const reason = publicCall.arguments[0];\n if (!reason) throw new ApiDocExtractionError('Public authentication requires a reason', SourceLocation.of(publicCall), \"Declare @WpAuthPublic('reason').\");\n return new DocumentedAuth(folder.foldString(reason, 'public auth reason'), []);\n }\n const protectedCall = this.decoratorCall(member, WpAuth.name);\n if (!protectedCall) return undefined;\n const array = protectedCall.arguments[0];\n if (!array || !ts.isArrayLiteralExpression(array) || !array.elements.length) throw new ApiDocExtractionError('WpAuth requires a nonempty descriptor array', SourceLocation.of(protectedCall), 'Use @WpAuth([jwt(), oidcSameProject()]).');\n const methods: DocumentedAuthMethod[] = [];\n for (const element of array.elements) {\n if (!ts.isCallExpression(element)) throw new ApiDocExtractionError('Auth method is not a descriptor call', SourceLocation.of(element), 'Use canonical credential descriptors.');\n const name = this.canonicalCallName(element.expression);\n const kind = new Map([['jwt', 'jwt'], ['oidcSameProject', 'oidc'], ['oidcSvcs', 'oidc'], ['sharedSecret', 'shared-secret'], ['webhook', 'webhook'], ['apiKey', 'apikey']]).get(name ?? '');\n if (!kind) throw new ApiDocExtractionError('Unknown authentication descriptor', SourceLocation.of(element), 'Import jwt/oidcSameProject/oidcSvcs/sharedSecret/webhook/apiKey from core-util.');\n methods.push(new DocumentedAuthMethod(kind, element.arguments.map((argument: ts.Expression) => argument.getText()), name === API_KEY_AUTH ? this.apiKeyOf(element, folder) : undefined));\n }\n return new DocumentedAuth(undefined, methods);\n }\n\n // webpieces-disable no-function-outside-class -- canonical import-aware AST name resolution\n static canonicalCallName(expression: ts.Expression): string | undefined {\n for (const statement of expression.getSourceFile().statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const module = statement.moduleSpecifier.text;\n if (!['@webpieces/core-util', '@webpieces/http-routing', '@webpieces/http-client-browser'].includes(module) && !module.endsWith('/core-util/src/http/decorators') && !module.endsWith('/core-util/src/http/auth-mode') && !module.endsWith('/core-util/src/http/authorization')) continue;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && ts.isNamedImports(bindings) && ts.isIdentifier(expression)) {\n const imported = bindings.elements.find((entry: ts.ImportSpecifier) => entry.name.text === expression.text);\n if (imported) return imported.propertyName?.text ?? imported.name.text;\n }\n if (bindings && ts.isNamespaceImport(bindings) && ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && expression.expression.text === bindings.name.text) return expression.name.text;\n }\n return undefined;\n }\n\n /**\n * `apiKey(regime, [{in: 'header', key: MyKeys.API_KEY, description: '…'}, …])`, parsed.\n *\n * A malformed declaration FAILS rather than yielding a half-parsed regime: the credentials are\n * what a published document's security block is made of, and a document that silently omitted\n * one would tell a partner they need fewer credentials than the running hook demands.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static apiKeyOf(call: ts.CallExpression, folder: ConstantFolder): DocumentedApiKey {\n const regimeArgument = call.arguments[0];\n const credentialsArgument = call.arguments[1];\n if (regimeArgument === undefined || credentialsArgument === undefined) {\n throw new ApiDocExtractionError(\n 'apiKey(...) needs a regime AND its credentials',\n SourceLocation.of(call),\n \"Write both: apiKey('partner', [{ in: 'header', key: MyKeys.API_KEY }]).\",\n );\n }\n const regime = folder.foldString(regimeArgument, 'apiKey(...) regime');\n // FOLLOW a name first: a credential list shared by every method of a contract is written\n // once as a `const` and named per method, which is better source than a copy per method.\n const credentialsLiteral = folder.follow(credentialsArgument);\n if (!ts.isArrayLiteralExpression(credentialsLiteral)) {\n throw new ApiDocExtractionError(\n 'apiKey(...) credentials is not an array literal',\n SourceLocation.of(credentialsArgument),\n 'Write the credentials as an array literal, inline or in a `const`; a value ' +\n 'assembled at runtime cannot appear in a published security scheme.',\n );\n }\n const credentials: DocumentedApiKeyCredential[] = [];\n for (const element of credentialsLiteral.elements) {\n credentials.push(ApiDocExtractor.credentialOf(element, folder));\n }\n return new DocumentedApiKey(regime, credentials);\n }\n\n /** ONE `{ in: …, name?: …, description?: … }` credential. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static credentialOf(\n expression: ts.Expression,\n folder: ConstantFolder,\n ): DocumentedApiKeyCredential {\n const element = folder.follow(expression);\n if (!ts.isObjectLiteralExpression(element)) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential is not an object literal',\n SourceLocation.of(element),\n \"Write it inline: { in: 'header', key: MyKeys.API_KEY }.\",\n );\n }\n const location = ApiDocExtractor.stringProperty(element, 'in', folder);\n if (location === undefined) {\n throw new ApiDocExtractionError(\n 'an apiKey(...) credential declares no `in`',\n SourceLocation.of(element),\n \"Say where it rides: `in: 'header'` with its ContextKey, or `in: 'bearer'`.\",\n );\n }\n return new DocumentedApiKeyCredential(\n location,\n ApiDocExtractor.headerOf(element, location, folder),\n ApiDocExtractor.stringProperty(element, 'description', folder),\n );\n }\n\n /**\n * A header credential's wire name, read off the ContextKey its `key` names (#1249) — never a\n * string. Undefined for any other location, which {@link SecurityDeriver}-style renderers judge.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static headerOf(\n element: ts.ObjectLiteralExpression,\n location: string,\n folder: ConstantFolder,\n ): string | undefined {\n if (location !== 'header') {\n return undefined;\n }\n const key = ApiDocExtractor.findProperty(element, 'key');\n if (key === undefined) {\n throw new ApiDocExtractionError(\n \"a header apiKey(...) credential names no ContextKey in 'key'\",\n SourceLocation.of(element),\n \"Name the ContextKey carrying it: { in: 'header', key: MyKeys.API_KEY }. The header-name \" +\n 'string spelling (`name:`) is deleted; the key is the one definition of the header.',\n );\n }\n return new ContextKeyHeaderFolder(folder).fold(\n key,\n ContextKeyHeaderSlot.REQUEST,\n \"the apiKey(...) header credential's key\",\n );\n }\n\n /**\n * `@WpMcpTool('search_stores')` — the stable protocol name, the one fact the source cannot\n * otherwise state. The tool's title is the method's `@summary` JSDoc tag (#1296), read with the rest\n * of its prose; the decorator carries none.\n *\n * Profile membership is read from the optional second argument (#1187). Otherwise, the method's JSDoc\n * is the description for the agent and the partner alike, the three side-effect hints are computed\n * from the endpoint's `operation`, and `openWorldHint` is `@Endpoint`'s `openWorld`. See\n * {@link DocumentedMcpTool}.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static mcpToolOf(\n member: ts.Node,\n folder: ConstantFolder,\n ): DocumentedMcpTool | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_TOOL);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n return new DocumentedMcpTool(\n folder.tryFoldString(argument) ?? '',\n new McpProfiles().read(call?.arguments[1], folder),\n );\n }\n\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, or undefined.\n *\n * A reason that will not fold is read as the EMPTY STRING rather than as \"no decorator\": the\n * method is still permanently outside MCP, and losing that fact because the argument was written\n * as a cross-module constant would silently put the endpoint back in the candidate set.\n */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static invalidForMcpOf(member: ts.Node, folder: ConstantFolder): string | undefined {\n const call = ApiDocExtractor.decoratorCall(member, MCP_INVALID);\n if (call === undefined) {\n return undefined;\n }\n const argument = call.arguments[0];\n return argument === undefined ? '' : (folder.tryFoldString(argument) ?? '');\n }\n\n /** `@MaskLog({ refreshToken: 'full' })` -> field name -> mask mode. */\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static maskLogOf(member: ts.Node): ReadonlyMap<string, string> {\n const fields = new Map<string, string>();\n const argument = ApiDocExtractor.decoratorCall(member, MASK_LOG)?.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) {\n return fields;\n }\n for (const property of argument.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n ts.isStringLiteralLike(property.initializer)\n ) {\n fields.set(property.name.text, property.initializer.text);\n }\n }\n return fields;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static booleanProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n ): boolean {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value?.kind === ts.SyntaxKind.TrueKeyword;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static stringProperty(\n literal: ts.ObjectLiteralExpression | undefined,\n name: string,\n folder: ConstantFolder,\n ): string | undefined {\n const value =\n literal === undefined ? undefined : ApiDocExtractor.findProperty(literal, name);\n return value === undefined ? undefined : folder.tryFoldString(value);\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static findProperty(\n literal: ts.ObjectLiteralExpression,\n name: string,\n ): ts.Expression | undefined {\n for (const property of literal.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === name\n ) {\n return property.initializer;\n }\n }\n return undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static reader of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ApiDocExtractor.canonicalCallName(call.expression) === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n}\n"]}
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,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,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;AA5tBD,0CA4tBC","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 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"]}
package/src/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { SchemaNames, SchemaNameEntry } from './model/SchemaNames';
13
13
  export { ApiDocExtractionError } from './extract/ApiDocExtractionError';
14
14
  export { ContextKeyHeaderSlot } from './extract/ContextKeyHeaderFolder';
15
15
  export { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';
16
- export { ApiComponentsModel, ApiDocModel, DocumentedApiKey, DocumentedApiKeyCredential, DocumentedAuth, DocumentedAuthMethod, DocumentedEndpoint, DocumentedEndpointOptions, DocumentedField, DocumentedMcpTool, DocumentedType, StackedJsDoc, TypeNameCollision, UnionDiscriminator, UnmappedType, } from './model/ApiDocModel';
16
+ export { ApiComponentsModel, ApiDocModel, DocumentedApiKey, DocumentedApiKeyCredential, DocumentedAuth, DocumentedAuthMethod, DocumentedEndpoint, DocumentedEndpointOptions, DocumentedParameter, DocumentedField, DocumentedMcpTool, DocumentedType, StackedJsDoc, TypeNameCollision, UnionDiscriminator, UnmappedType, } from './model/ApiDocModel';
17
17
  export { McpRenderError } from './render/McpRenderError';
18
18
  export { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';
19
19
  export { EndpointSummary } from './model/EndpointSummary';
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamingSchemaRenderer = exports.TypeRef = exports.OperationIdStyle = exports.OperationIds = exports.DocLinkText = exports.DocLinkProblem = exports.DocLinkKind = exports.DocLink = exports.EndpointSummary = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.StackedJsDoc = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuthMethod = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ContextKeyHeaderSlot = exports.ApiDocExtractionError = exports.SchemaNameEntry = exports.SchemaNames = exports.ApiDocExtractor = void 0;
3
+ exports.StreamingSchemaRenderer = exports.TypeRef = exports.OperationIdStyle = exports.OperationIds = exports.DocLinkText = exports.DocLinkProblem = exports.DocLinkKind = exports.DocLink = exports.EndpointSummary = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.StackedJsDoc = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedParameter = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuthMethod = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ContextKeyHeaderSlot = exports.ApiDocExtractionError = exports.SchemaNameEntry = exports.SchemaNames = exports.ApiDocExtractor = void 0;
4
4
  /**
5
5
  * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and
6
6
  * produce ONE in-memory {@link ApiDocModel}.
@@ -32,6 +32,7 @@ Object.defineProperty(exports, "DocumentedAuth", { enumerable: true, get: functi
32
32
  Object.defineProperty(exports, "DocumentedAuthMethod", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedAuthMethod; } });
33
33
  Object.defineProperty(exports, "DocumentedEndpoint", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedEndpoint; } });
34
34
  Object.defineProperty(exports, "DocumentedEndpointOptions", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedEndpointOptions; } });
35
+ Object.defineProperty(exports, "DocumentedParameter", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedParameter; } });
35
36
  Object.defineProperty(exports, "DocumentedField", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedField; } });
36
37
  Object.defineProperty(exports, "DocumentedMcpTool", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedMcpTool; } });
37
38
  Object.defineProperty(exports, "DocumentedType", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedType; } });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,mDAAmE;AAA1D,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AACrC,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,2EAAwE;AAA/D,8HAAA,oBAAoB,OAAA;AAC7B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAgB6B;AAfzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,2CAAoF;AAA3E,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,sGAAA,WAAW,OAAA;AAE1D,qDAAsE;AAA7D,4GAAA,YAAY,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACvC,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,4EAA2E;AAAlE,kIAAA,uBAAuB,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { SchemaNames, SchemaNameEntry } from './model/SchemaNames';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { ContextKeyHeaderSlot } from './extract/ContextKeyHeaderFolder';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { EndpointSummary } from './model/EndpointSummary';\nexport { DocLink, DocLinkKind, DocLinkProblem, DocLinkText } from './model/DocLink';\nexport type { DocLinkNaming } from './model/DocLink';\nexport { OperationIds, OperationIdStyle } from './model/OperationIds';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\nexport { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,mDAAmE;AAA1D,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AACrC,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,2EAAwE;AAA/D,8HAAA,oBAAoB,OAAA;AAC7B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAiB6B;AAhBzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,kHAAA,mBAAmB,OAAA;AACnB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,2CAAoF;AAA3E,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,sGAAA,WAAW,OAAA;AAE1D,qDAAsE;AAA7D,4GAAA,YAAY,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACvC,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,4EAA2E;AAAlE,kIAAA,uBAAuB,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { SchemaNames, SchemaNameEntry } from './model/SchemaNames';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { ContextKeyHeaderSlot } from './extract/ContextKeyHeaderFolder';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedParameter,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { EndpointSummary } from './model/EndpointSummary';\nexport { DocLink, DocLinkKind, DocLinkProblem, DocLinkText } from './model/DocLink';\nexport type { DocLinkNaming } from './model/DocLink';\nexport { OperationIds, OperationIdStyle } from './model/OperationIds';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\nexport { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';\n"]}
@@ -375,11 +375,32 @@ export declare class DocumentedAuth {
375
375
  readonly methods: readonly DocumentedAuthMethod[];
376
376
  constructor(publicReason: string | undefined, methods: readonly DocumentedAuthMethod[]);
377
377
  }
378
+ /**
379
+ * ONE `@PathParam` / `@QueryParam` argument of an endpoint: an OpenAPI `parameters` entry. A path
380
+ * parameter is always required; a query one is required unless its argument is optional (`?`) or
381
+ * its type admits `undefined`.
382
+ */
383
+ export declare class DocumentedParameter {
384
+ /** `path` or `query` — the OpenAPI `in`. */
385
+ readonly location: string;
386
+ /** The wire name, folded from the decorator argument. */
387
+ readonly name: string;
388
+ readonly required: boolean;
389
+ /** The argument's declared type (`string`, `number`, `string[]`, a string enum, ...). */
390
+ readonly type: TypeRef | undefined;
391
+ constructor(
392
+ /** `path` or `query` — the OpenAPI `in`. */
393
+ location: string,
394
+ /** The wire name, folded from the decorator argument. */
395
+ name: string, required: boolean,
396
+ /** The argument's declared type (`string`, `number`, `string[]`, a string enum, ...). */
397
+ type: TypeRef | undefined);
398
+ }
378
399
  /** One `@Endpoint` method of one contract. */
379
400
  export declare class DocumentedEndpoint {
380
401
  readonly methodName: string;
381
402
  /**
382
- * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
403
+ * `GET`, `POST`, `PUT`, `PATCH` or `DELETE`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
383
404
  * written without it — the verb is the key an operation hangs under in `paths`.
384
405
  */
385
406
  readonly httpMethod: string;
@@ -391,7 +412,7 @@ export declare class DocumentedEndpoint {
391
412
  * inferring safety from the verb, which for this framework would be wrong.
392
413
  */
393
414
  readonly operation: string;
394
- /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
415
+ /** `rpc` | `cloudtasks` | `cron` | `external-inbound` | `external-outbound`, verbatim — this package invents no taxonomy. */
395
416
  readonly kind: string;
396
417
  /**
397
418
  * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
@@ -439,9 +460,11 @@ export declare class DocumentedEndpoint {
439
460
  readonly response: TypeRef | undefined;
440
461
  readonly streaming?: DocumentedStreaming | undefined;
441
462
  readonly localOnly: boolean;
463
+ /** Every `@PathParam` / `@QueryParam` argument, in declaration order. */
464
+ readonly parameters: readonly DocumentedParameter[];
442
465
  constructor(methodName: string,
443
466
  /**
444
- * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
467
+ * `GET`, `POST`, `PUT`, `PATCH` or `DELETE`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
445
468
  * written without it — the verb is the key an operation hangs under in `paths`.
446
469
  */
447
470
  httpMethod: string,
@@ -453,7 +476,7 @@ export declare class DocumentedEndpoint {
453
476
  * inferring safety from the verb, which for this framework would be wrong.
454
477
  */
455
478
  operation: string,
456
- /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
479
+ /** `rpc` | `cloudtasks` | `cron` | `external-inbound` | `external-outbound`, verbatim — this package invents no taxonomy. */
457
480
  kind: string,
458
481
  /**
459
482
  * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
@@ -492,7 +515,9 @@ export declare class DocumentedEndpoint {
492
515
  * (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any
493
516
  * operation whose response has a body, rather than publishing a filler sentence.
494
517
  */
495
- returnsDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined, streaming?: DocumentedStreaming | undefined, localOnly?: boolean);
518
+ returnsDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined, streaming?: DocumentedStreaming | undefined, localOnly?: boolean,
519
+ /** Every `@PathParam` / `@QueryParam` argument, in declaration order. */
520
+ parameters?: readonly DocumentedParameter[]);
496
521
  }
497
522
  /** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
498
523
  export declare class ApiDocModel {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiComponentsModel = exports.ApiDocModel = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedAuthMethod = exports.DocumentedApiKey = exports.DocumentedApiKeyCredential = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.TypeNameCollision = exports.DocumentedType = exports.DocumentedField = exports.UnionDiscriminator = exports.StackedJsDoc = exports.UnmappedType = void 0;
3
+ exports.ApiComponentsModel = exports.ApiDocModel = exports.DocumentedEndpoint = exports.DocumentedParameter = exports.DocumentedAuth = exports.DocumentedAuthMethod = exports.DocumentedApiKey = exports.DocumentedApiKeyCredential = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.TypeNameCollision = exports.DocumentedType = exports.DocumentedField = exports.UnionDiscriminator = exports.StackedJsDoc = exports.UnmappedType = void 0;
4
4
  /**
5
5
  * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —
6
6
  * these are data-only structures, and a renderer (#982) builds nothing, it only reads.
@@ -360,6 +360,30 @@ class DocumentedAuth {
360
360
  }
361
361
  }
362
362
  exports.DocumentedAuth = DocumentedAuth;
363
+ /**
364
+ * ONE `@PathParam` / `@QueryParam` argument of an endpoint: an OpenAPI `parameters` entry. A path
365
+ * parameter is always required; a query one is required unless its argument is optional (`?`) or
366
+ * its type admits `undefined`.
367
+ */
368
+ class DocumentedParameter {
369
+ location;
370
+ name;
371
+ required;
372
+ type;
373
+ constructor(
374
+ /** `path` or `query` — the OpenAPI `in`. */
375
+ location,
376
+ /** The wire name, folded from the decorator argument. */
377
+ name, required,
378
+ /** The argument's declared type (`string`, `number`, `string[]`, a string enum, ...). */
379
+ type) {
380
+ this.location = location;
381
+ this.name = name;
382
+ this.required = required;
383
+ this.type = type;
384
+ }
385
+ }
386
+ exports.DocumentedParameter = DocumentedParameter;
363
387
  /** One `@Endpoint` method of one contract. */
364
388
  class DocumentedEndpoint {
365
389
  methodName;
@@ -383,9 +407,10 @@ class DocumentedEndpoint {
383
407
  response;
384
408
  streaming;
385
409
  localOnly;
410
+ parameters;
386
411
  constructor(methodName,
387
412
  /**
388
- * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
413
+ * `GET`, `POST`, `PUT`, `PATCH` or `DELETE`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
389
414
  * written without it — the verb is the key an operation hangs under in `paths`.
390
415
  */
391
416
  httpMethod,
@@ -397,7 +422,7 @@ class DocumentedEndpoint {
397
422
  * inferring safety from the verb, which for this framework would be wrong.
398
423
  */
399
424
  operation,
400
- /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
425
+ /** `rpc` | `cloudtasks` | `cron` | `external-inbound` | `external-outbound`, verbatim — this package invents no taxonomy. */
401
426
  kind,
402
427
  /**
403
428
  * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
@@ -436,7 +461,9 @@ class DocumentedEndpoint {
436
461
  * (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any
437
462
  * operation whose response has a body, rather than publishing a filler sentence.
438
463
  */
439
- returnsDescription, request, response, streaming, localOnly = false) {
464
+ returnsDescription, request, response, streaming, localOnly = false,
465
+ /** Every `@PathParam` / `@QueryParam` argument, in declaration order. */
466
+ parameters = []) {
440
467
  this.methodName = methodName;
441
468
  this.httpMethod = httpMethod;
442
469
  this.path = path;
@@ -458,6 +485,7 @@ class DocumentedEndpoint {
458
485
  this.response = response;
459
486
  this.streaming = streaming;
460
487
  this.localOnly = localOnly;
488
+ this.parameters = parameters;
461
489
  }
462
490
  }
463
491
  exports.DocumentedEndpoint = DocumentedEndpoint;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,qEAAqE;IAC5D,QAAgB;IACzB,sDAAsD;IAC7C,QAAgB;IACzB,wEAAwE;IAC/D,MAAc;QAJd,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,WAAM,GAAN,MAAM,CAA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AA2B;IACpC,yFAAyF;IAChF,KAA0C,EAC1C,QAAiC,EACjC,UAAwC;IACjD,8FAA8F;IACrF,YAAqC;QAVrC,gBAAW,GAAX,WAAW,CAAQ;QAEnB,mBAAc,GAAd,cAAc,CAAQ;QAEtB,aAAQ,GAAR,QAAQ,CAAmB;QAE3B,UAAK,GAAL,KAAK,CAAqC;QAC1C,aAAQ,GAAR,QAAQ,CAAyB;QACjC,eAAU,GAAV,UAAU,CAA8B;QAExC,iBAAY,GAAZ,YAAY,CAAyB;IAC/C,CAAC;CACP;AAfD,gDAeC","sourcesContent":["import { TypeRef } from './TypeRef';\nimport type { DocumentedStreaming } from './DocumentedStreaming';\n\n/**\n * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —\n * these are data-only structures, and a renderer (#982) builds nothing, it only reads.\n *\n * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and\n * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import\n * here would end that, which is why `responsibilities.md` states the constraint rather than leaving\n * it to be discovered.\n */\n\n/** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */\nexport class UnmappedType {\n constructor(\n /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */\n readonly typeText: string,\n /** Pointer-style location: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** Why it could not be mapped, in one sentence a renderer can print. */\n readonly reason: string,\n ) {}\n}\n\n/**\n * A declaration with MORE THAN ONE JSDoc block stacked above it (#1286). RECORDED, never resolved:\n * no choice of block is right, so a renderer's guard refuses and names it.\n *\n * TypeScript attaches every `/** *\\/` comment in a declaration's leading trivia, so two shapes land\n * here and both publish the wrong description — a FILE or SECTION header written as `/** *\\/` above\n * the first declaration, and a doc STRANDED on top of another declaration's own by a refactor that\n * inserted something between a declaration and its JSDoc. \"Nearest wins\" would hide the second shape:\n * the declaration the stranded doc belonged to silently loses it. Only the author knows which shape\n * this is, so the fix is theirs.\n */\nexport class StackedJsDoc {\n constructor(\n /** What carries the blocks — `MenuPublicationStatusDto`, `Widget.name`, `save`. */\n readonly declaration: string,\n /** Pointer-style location of the DECLARATION: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** The 1-based line each stacked JSDoc block starts on, in source order. */\n readonly blockLines: readonly number[],\n ) {}\n}\n\n/** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */\nexport class UnionDiscriminator {\n constructor(\n /** The property every branch carries. */\n readonly propertyName: string,\n /**\n * branch type name -> EVERY string value that branch's property may hold. One value for\n * `mode: 'fixed'` / `mode: VoiceMode.FIXED`; several for `mode: 'a' | 'b'` or\n * `mode: VoiceMode.A | VoiceMode.B` (#1023). No value appears under two branches — that is\n * what makes the property a discriminator, and an OpenAPI `mapping` point several values at\n * one schema.\n */\n readonly branchValues: ReadonlyMap<string, readonly string[]>,\n ) {}\n}\n\n/** One field of one DTO. */\nexport class DocumentedField {\n constructor(\n readonly name: string,\n readonly type: TypeRef,\n /**\n * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from\n * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a\n * renderer that conflates them emits a schema that rejects one of them.\n */\n readonly optional: boolean,\n /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */\n readonly nullable: boolean,\n /** The JSDoc body, each `{@link}` encoded (`DocLinkText`). Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means \"no override\",\n * and a renderer falls back to {@link description}; the fallback is NOT applied here so a\n * renderer can tell a deliberate agent-facing sentence from a reused human one.\n */\n readonly mcpDescription: string | undefined,\n /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */\n readonly format: string | undefined,\n /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */\n readonly min: number | undefined,\n /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */\n readonly max: number | undefined,\n /**\n * The `@mcpHeader <token>` JSDoc tag — the MCP 2026 SEP-2243 header this PRIMITIVE field is\n * mirrored into (`Mcp-Param-{token}`). Undefined for every field that is not mirrored, which\n * is nearly all of them.\n *\n * It is documentation and therefore lives in JSDoc, next to the sentence describing the\n * field, rather than in a decorator argument — and since #984 it is the only spelling of the\n * fact at all.\n */\n readonly mcpHeader: string | undefined,\n /**\n * Pointer-style `path/to/File.ts:12:5` for the property declaration itself.\n *\n * A renderer never needs it — it publishes a schema, not a file offset. The build RULES do:\n * `api-rules-for-openapi` refuses a field whose value type is `unknown`, and a refusal that\n * cannot say WHERE costs the author a grep over every DTO the contract reaches. It is\n * carried on the FIELD rather than recomputed because only the extractor still has the\n * syntax node, and a second reader deriving it would be a second answer to \"where is this\".\n */\n readonly location: string,\n /**\n * The `@hidden` JSDoc tag (#1246) — this field is withheld from the CUSTOMER document\n * (`public-openapi.json` and its bundled sibling). The field-level twin of\n * {@link DocumentedEndpoint.hidden}, and audienced exactly like it: it stays in the private\n * document, and in the MCP document and tool catalogs, which keep hidden methods too.\n *\n * A documentation decision, never an access-control one: the server still accepts and returns\n * the field. It is for a field that was NEVER published — hiding one a partner already reads\n * is a removal from their point of view.\n */\n readonly hidden: boolean,\n /**\n * The `@hidden` tag's text — WHY it is withheld (`not announced yet; ships with …`).\n * Undefined when the tag has no text. Never published anywhere: it is the author's note.\n */\n readonly hiddenReason: string | undefined,\n ) {}\n}\n\n/** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */\nexport class DocumentedType {\n constructor(\n readonly name: string,\n readonly description: string,\n /** Object shape. Empty for an enum or a union. */\n readonly fields: readonly DocumentedField[],\n /** Set for a string-literal union that has a name. */\n readonly enumValues: readonly string[],\n /** Set for a union of named object types. */\n readonly unionRefNames: readonly string[],\n /** Set only when EVERY branch carries the same property typed as one string literal. */\n readonly discriminator: UnionDiscriminator | undefined,\n /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */\n readonly indexSignatureValue: TypeRef | undefined,\n /**\n * The npm package whose source DECLARES this type — the nearest `package.json` above the\n * declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract\n * document defines the schemas its own package declares and `$ref`s every other one into\n * that package's `components.openapi.json`. Undefined when the file belongs to no package.\n *\n * The MCP projection ignores it: a tool schema is always fully inlined.\n */\n readonly packageName: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */\n readonly location: string,\n /** Published schema name; the source name stays in name for validation and diagnostics. */\n readonly schemaName: string,\n ) {}\n\n /**\n * The key this type is registered under in {@link ApiDocModel.types} and named by every\n * {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and\n * `<package>:<name>` for every other one, so two packages' same-named types are two entries.\n */\n // webpieces-disable no-function-outside-class -- static helper on the class whose key it computes\n static keyOf(\n name: string,\n packageName: string | undefined,\n homePackage: string | undefined,\n ): string {\n return packageName === homePackage ? name : `${packageName ?? '<no package>'}:${name}`;\n }\n}\n\n/**\n * Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).\n *\n * Recorded rather than thrown, because the MCP projection inlines every schema and never cared which\n * of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each\n * schema of a package under its bare name, so it REFUSES a model carrying one of these: the second\n * declaration would be published as the first one's shape.\n */\nexport class TypeNameCollision {\n constructor(\n readonly name: string,\n readonly packageName: string | undefined,\n /** Where the declaration that won the name is. */\n readonly firstLocation: string,\n /** Where the declaration that was conflated into it is. */\n readonly secondLocation: string,\n ) {}\n}\n\n/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */\nexport class DocumentedEndpointOptions {\n constructor(\n readonly formPost: boolean,\n /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */\n readonly calledBy: string | undefined,\n readonly callerKind: string | undefined,\n ) {}\n}\n\n/**\n * The `@WpMcpTool('search_stores')` declaration, when the method carries one — the ONE fact the source\n * cannot otherwise state, plus the profile groups it is listed in.\n *\n * `description` used to sit on the decorator too. The method's JSDoc is the description, for the\n * agent and for the partner alike, byte-identical: two authored copies of one paragraph is the\n * two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI\n * document while the agent reads the decorator string in `tools/list`, and they drift the first time\n * somebody edits one. #984 deleted it. The `title` argument #1180 added went the same way in #1296:\n * the tool's title is the method's `@summary` ({@link DocumentedEndpoint.summary}), the same line the\n * OpenAPI operation publishes as its `summary`.\n *\n * The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`\n * in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |\n * WRITE` already says whether repeating a call is safe, so a hand-declared hint would be a second\n * answer to a question the contract has answered. `openWorldHint` is `@Endpoint`'s `openWorld`.\n */\nexport class DocumentedMcpTool {\n constructor(\n /**\n * The STABLE protocol name. Deliberately independent of the method name, because renaming a\n * method must not break a saved agent workflow.\n */\n readonly name: string,\n readonly profiles: readonly string[],\n ) {}\n}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', key: MyKeys.API_KEY }` or\n * `{ in: 'bearer' }`.\n *\n * Parsed rather than left as source text because it is the one auth argument a renderer must turn\n * into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or\n * `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string\n * `\"{ in: 'header', key: MyKeys.API_KEY }\"` would have to parse TypeScript to emit either one, which\n * is this package's job and not a renderer's.\n */\nexport class DocumentedApiKeyCredential {\n constructor(\n /** `header` or `bearer`, verbatim from the declaration. */\n readonly location: string,\n /**\n * The header name, read off the `httpHeader` of the ContextKey the credential's `key` names\n * (#1249). Undefined for `bearer`, whose location IS `Authorization`.\n */\n readonly name: string | undefined,\n /** The prose a docs site renders on its authorization card. */\n readonly description: string | undefined,\n ) {}\n}\n\n/** `apiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */\nexport class DocumentedApiKey {\n constructor(\n readonly regime: string,\n /**\n * Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them\n * are presented together — and the order is the order a published document lists them in.\n */\n readonly credentials: readonly DocumentedApiKeyCredential[],\n ) {}\n}\n\n/** Structurally extracted credential alternatives, with OR semantics. */\nexport class DocumentedAuthMethod {\n constructor(\n readonly kind: string,\n readonly argumentTexts: readonly string[],\n readonly apiKey: DocumentedApiKey | undefined,\n ) {}\n}\n\nexport class DocumentedAuth {\n constructor(\n readonly publicReason: string | undefined,\n readonly methods: readonly DocumentedAuthMethod[],\n ) {}\n}\n\n/** One `@Endpoint` method of one contract. */\nexport class DocumentedEndpoint {\n constructor(\n readonly methodName: string,\n /**\n * `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be\n * written without it — the verb is the key an operation hangs under in `paths`.\n */\n readonly httpMethod: string,\n /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */\n readonly path: string,\n /**\n * `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is\n * independent of the verb: webpieces POSTs a read. A renderer publishes it rather than\n * inferring safety from the verb, which for this framework would be wrong.\n */\n readonly operation: string,\n /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */\n readonly kind: string,\n /**\n * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the\n * private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at\n * all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.\n */\n readonly hidden: boolean,\n /** `{ openWorld: true }` — this operation may touch systems outside this service. */\n readonly openWorld: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTool: DocumentedMcpTool | undefined,\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint\n * is PERMANENTLY outside MCP and was never a tool candidate.\n *\n * Distinct from \"has no `@WpMcpTool`\", which only says \"not a tool yet\". A renderer must not\n * report one of these as a SKIPPED tool, and `api-rules-for-mcp` stops asking a method with\n * one whether it could be served — the declaration is the answer. Carrying the reason rather\n * than a boolean is the point: the rule restates the list of exclusions with their arguments\n * on every run.\n */\n readonly invalidForMcp: string | undefined,\n /** The common @WpAuthorization declaration, shared by every surface. */\n readonly authorizationText: string | undefined,\n /** `@MaskLog({...})` — field name -> mask mode. */\n readonly maskLog: ReadonlyMap<string, string>,\n readonly description: string,\n /**\n * The method's `@summary` text — its one-line short title (#1296): the OpenAPI operation's\n * `summary` and, for a tool, MCP `Tool.title` AND `annotations.title`. Undefined when the method\n * has none; the OpenAPI generator refuses that for every published operation, and the MCP\n * renderer refuses a tool without one.\n */\n readonly summary: string | undefined,\n /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */\n readonly mcpDescription: string | undefined,\n /**\n * The method's `@returns` text — the SUCCESS response's `description` in a published document\n * (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any\n * operation whose response has a body, rather than publishing a filler sentence.\n */\n readonly returnsDescription: string | undefined,\n readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\n readonly streaming?: DocumentedStreaming,\n readonly localOnly: boolean = false,\n ) {}\n}\n\n/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */\nexport class ApiDocModel {\n constructor(\n /** The contract class name, e.g. `SaveApi`. */\n readonly contractName: string,\n /**\n * WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,\n * verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.\n *\n * A named list rather than a falsy default, because the grant has to be the TOKEN: a default\n * that reached customers would publish a contract whose author typed nothing about it.\n */\n readonly apiTypes: readonly string[],\n /** `@ApiPath(...)`, constant-folded. */\n readonly basePath: string,\n /** The JSDoc on the contract class, each `{@link}` encoded (`DocLinkText`). */\n readonly description: string,\n readonly endpoints: readonly DocumentedEndpoint[],\n /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n /** Everything that could not be represented — recorded, not dropped. */\n readonly unmapped: readonly UnmappedType[],\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n\n/**\n * ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the\n * components-only OpenAPI document it publishes (#1058). Data-only.\n *\n * A components document contains EVERY exported type the library declares — not only the ones some\n * contract reaches — so its contents are a property of the library alone and do not move when a\n * downstream contract changes.\n */\nexport class ApiComponentsModel {\n constructor(\n /** The library's package name — every type in {@link exported} is declared by it. */\n readonly packageName: string,\n /** The library's package version, published as the document's `info.version`. */\n readonly packageVersion: string,\n /** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */\n readonly exported: readonly string[],\n /** Every named type reached from the exports — the library's own and other packages'. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n readonly unmapped: readonly UnmappedType[],\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n"]}
1
+ {"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,qEAAqE;IAC5D,QAAgB;IACzB,sDAAsD;IAC7C,QAAgB;IACzB,wEAAwE;IAC/D,MAAc;QAJd,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,WAAM,GAAN,MAAM,CAAQ;IACxB,CAAC;CACP;AATD,oCASC;AAED;;;;;;;;;;GAUG;AACH,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,mFAAmF;IAC1E,WAAmB;IAC5B,yEAAyE;IAChE,QAAgB;IACzB,4EAA4E;IACnE,UAA6B;QAJ7B,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR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AED;;;;;;;GAOG;AACH,MAAa,kBAAkB;IAGd;IAEA;IAEA;IAEA;IACA;IACA;IAEA;IAZb;IACI,qFAAqF;IAC5E,WAAmB;IAC5B,iFAAiF;IACxE,cAAsB;IAC/B,wFAAwF;IAC/E,QAA2B;IACpC,yFAAyF;IAChF,KAA0C,EAC1C,QAAiC,EACjC,UAAwC;IACjD,8FAA8F;IACrF,YAAqC;QAVrC,gBAAW,GAAX,WAAW,CAAQ;QAEnB,mBAAc,GAAd,cAAc,CAAQ;QAEtB,aAAQ,GAAR,QAAQ,CAAmB;QAE3B,UAAK,GAAL,KAAK,CAAqC;QAC1C,aAAQ,GAAR,QAAQ,CAAyB;QACjC,eAAU,GAAV,UAAU,CAA8B;QAExC,iBAAY,GAAZ,YAAY,CAAyB;IAC/C,CAAC;CACP;AAfD,gDAeC","sourcesContent":["import { TypeRef } from './TypeRef';\nimport type { DocumentedStreaming } from './DocumentedStreaming';\n\n/**\n * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —\n * these are data-only structures, and a renderer (#982) builds nothing, it only reads.\n *\n * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and\n * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import\n * here would end that, which is why `responsibilities.md` states the constraint rather than leaving\n * it to be discovered.\n */\n\n/** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */\nexport class UnmappedType {\n constructor(\n /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */\n readonly typeText: string,\n /** Pointer-style location: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** Why it could not be mapped, in one sentence a renderer can print. */\n readonly reason: string,\n ) {}\n}\n\n/**\n * A declaration with MORE THAN ONE JSDoc block stacked above it (#1286). RECORDED, never resolved:\n * no choice of block is right, so a renderer's guard refuses and names it.\n *\n * TypeScript attaches every `/** *\\/` comment in a declaration's leading trivia, so two shapes land\n * here and both publish the wrong description — a FILE or SECTION header written as `/** *\\/` above\n * the first declaration, and a doc STRANDED on top of another declaration's own by a refactor that\n * inserted something between a declaration and its JSDoc. \"Nearest wins\" would hide the second shape:\n * the declaration the stranded doc belonged to silently loses it. Only the author knows which shape\n * this is, so the fix is theirs.\n */\nexport class StackedJsDoc {\n constructor(\n /** What carries the blocks — `MenuPublicationStatusDto`, `Widget.name`, `save`. */\n readonly declaration: string,\n /** Pointer-style location of the DECLARATION: `path/to/File.ts:12:5`. */\n readonly location: string,\n /** The 1-based line each stacked JSDoc block starts on, in source order. */\n readonly blockLines: readonly number[],\n ) {}\n}\n\n/** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */\nexport class UnionDiscriminator {\n constructor(\n /** The property every branch carries. */\n readonly propertyName: string,\n /**\n * branch type name -> EVERY string value that branch's property may hold. One value for\n * `mode: 'fixed'` / `mode: VoiceMode.FIXED`; several for `mode: 'a' | 'b'` or\n * `mode: VoiceMode.A | VoiceMode.B` (#1023). No value appears under two branches — that is\n * what makes the property a discriminator, and an OpenAPI `mapping` point several values at\n * one schema.\n */\n readonly branchValues: ReadonlyMap<string, readonly string[]>,\n ) {}\n}\n\n/** One field of one DTO. */\nexport class DocumentedField {\n constructor(\n readonly name: string,\n readonly type: TypeRef,\n /**\n * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from\n * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a\n * renderer that conflates them emits a schema that rejects one of them.\n */\n readonly optional: boolean,\n /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */\n readonly nullable: boolean,\n /** The JSDoc body, each `{@link}` encoded (`DocLinkText`). Empty string when undocumented. */\n readonly description: string,\n /**\n * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means \"no override\",\n * and a renderer falls back to {@link description}; the fallback is NOT applied here so a\n * renderer can tell a deliberate agent-facing sentence from a reused human one.\n */\n readonly mcpDescription: string | undefined,\n /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */\n readonly format: string | undefined,\n /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */\n readonly min: number | undefined,\n /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */\n readonly max: number | undefined,\n /**\n * The `@mcpHeader <token>` JSDoc tag — the MCP 2026 SEP-2243 header this PRIMITIVE field is\n * mirrored into (`Mcp-Param-{token}`). Undefined for every field that is not mirrored, which\n * is nearly all of them.\n *\n * It is documentation and therefore lives in JSDoc, next to the sentence describing the\n * field, rather than in a decorator argument — and since #984 it is the only spelling of the\n * fact at all.\n */\n readonly mcpHeader: string | undefined,\n /**\n * Pointer-style `path/to/File.ts:12:5` for the property declaration itself.\n *\n * A renderer never needs it — it publishes a schema, not a file offset. The build RULES do:\n * `api-rules-for-openapi` refuses a field whose value type is `unknown`, and a refusal that\n * cannot say WHERE costs the author a grep over every DTO the contract reaches. It is\n * carried on the FIELD rather than recomputed because only the extractor still has the\n * syntax node, and a second reader deriving it would be a second answer to \"where is this\".\n */\n readonly location: string,\n /**\n * The `@hidden` JSDoc tag (#1246) — this field is withheld from the CUSTOMER document\n * (`public-openapi.json` and its bundled sibling). The field-level twin of\n * {@link DocumentedEndpoint.hidden}, and audienced exactly like it: it stays in the private\n * document, and in the MCP document and tool catalogs, which keep hidden methods too.\n *\n * A documentation decision, never an access-control one: the server still accepts and returns\n * the field. It is for a field that was NEVER published — hiding one a partner already reads\n * is a removal from their point of view.\n */\n readonly hidden: boolean,\n /**\n * The `@hidden` tag's text — WHY it is withheld (`not announced yet; ships with …`).\n * Undefined when the tag has no text. Never published anywhere: it is the author's note.\n */\n readonly hiddenReason: string | undefined,\n ) {}\n}\n\n/** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */\nexport class DocumentedType {\n constructor(\n readonly name: string,\n readonly description: string,\n /** Object shape. Empty for an enum or a union. */\n readonly fields: readonly DocumentedField[],\n /** Set for a string-literal union that has a name. */\n readonly enumValues: readonly string[],\n /** Set for a union of named object types. */\n readonly unionRefNames: readonly string[],\n /** Set only when EVERY branch carries the same property typed as one string literal. */\n readonly discriminator: UnionDiscriminator | undefined,\n /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */\n readonly indexSignatureValue: TypeRef | undefined,\n /**\n * The npm package whose source DECLARES this type — the nearest `package.json` above the\n * declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract\n * document defines the schemas its own package declares and `$ref`s every other one into\n * that package's `components.openapi.json`. Undefined when the file belongs to no package.\n *\n * The MCP projection ignores it: a tool schema is always fully inlined.\n */\n readonly packageName: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */\n readonly location: string,\n /** Published schema name; the source name stays in name for validation and diagnostics. */\n readonly schemaName: string,\n ) {}\n\n /**\n * The key this type is registered under in {@link ApiDocModel.types} and named by every\n * {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and\n * `<package>:<name>` for every other one, so two packages' same-named types are two entries.\n */\n // webpieces-disable no-function-outside-class -- static helper on the class whose key it computes\n static keyOf(\n name: string,\n packageName: string | undefined,\n homePackage: string | undefined,\n ): string {\n return packageName === homePackage ? name : `${packageName ?? '<no package>'}:${name}`;\n }\n}\n\n/**\n * Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).\n *\n * Recorded rather than thrown, because the MCP projection inlines every schema and never cared which\n * of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each\n * schema of a package under its bare name, so it REFUSES a model carrying one of these: the second\n * declaration would be published as the first one's shape.\n */\nexport class TypeNameCollision {\n constructor(\n readonly name: string,\n readonly packageName: string | undefined,\n /** Where the declaration that won the name is. */\n readonly firstLocation: string,\n /** Where the declaration that was conflated into it is. */\n readonly secondLocation: string,\n ) {}\n}\n\n/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */\nexport class DocumentedEndpointOptions {\n constructor(\n readonly formPost: boolean,\n /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */\n readonly calledBy: string | undefined,\n readonly callerKind: string | undefined,\n ) {}\n}\n\n/**\n * The `@WpMcpTool('search_stores')` declaration, when the method carries one — the ONE fact the source\n * cannot otherwise state, plus the profile groups it is listed in.\n *\n * `description` used to sit on the decorator too. The method's JSDoc is the description, for the\n * agent and for the partner alike, byte-identical: two authored copies of one paragraph is the\n * two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI\n * document while the agent reads the decorator string in `tools/list`, and they drift the first time\n * somebody edits one. #984 deleted it. The `title` argument #1180 added went the same way in #1296:\n * the tool's title is the method's `@summary` ({@link DocumentedEndpoint.summary}), the same line the\n * OpenAPI operation publishes as its `summary`.\n *\n * The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`\n * in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |\n * WRITE` already says whether repeating a call is safe, so a hand-declared hint would be a second\n * answer to a question the contract has answered. `openWorldHint` is `@Endpoint`'s `openWorld`.\n */\nexport class DocumentedMcpTool {\n constructor(\n /**\n * The STABLE protocol name. Deliberately independent of the method name, because renaming a\n * method must not break a saved agent workflow.\n */\n readonly name: string,\n readonly profiles: readonly string[],\n ) {}\n}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', key: MyKeys.API_KEY }` or\n * `{ in: 'bearer' }`.\n *\n * Parsed rather than left as source text because it is the one auth argument a renderer must turn\n * into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or\n * `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string\n * `\"{ in: 'header', key: MyKeys.API_KEY }\"` would have to parse TypeScript to emit either one, which\n * is this package's job and not a renderer's.\n */\nexport class DocumentedApiKeyCredential {\n constructor(\n /** `header` or `bearer`, verbatim from the declaration. */\n readonly location: string,\n /**\n * The header name, read off the `httpHeader` of the ContextKey the credential's `key` names\n * (#1249). Undefined for `bearer`, whose location IS `Authorization`.\n */\n readonly name: string | undefined,\n /** The prose a docs site renders on its authorization card. */\n readonly description: string | undefined,\n ) {}\n}\n\n/** `apiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */\nexport class DocumentedApiKey {\n constructor(\n readonly regime: string,\n /**\n * Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them\n * are presented together — and the order is the order a published document lists them in.\n */\n readonly credentials: readonly DocumentedApiKeyCredential[],\n ) {}\n}\n\n/** Structurally extracted credential alternatives, with OR semantics. */\nexport class DocumentedAuthMethod {\n constructor(\n readonly kind: string,\n readonly argumentTexts: readonly string[],\n readonly apiKey: DocumentedApiKey | undefined,\n ) {}\n}\n\nexport class DocumentedAuth {\n constructor(\n readonly publicReason: string | undefined,\n readonly methods: readonly DocumentedAuthMethod[],\n ) {}\n}\n\n/**\n * ONE `@PathParam` / `@QueryParam` argument of an endpoint: an OpenAPI `parameters` entry. A path\n * parameter is always required; a query one is required unless its argument is optional (`?`) or\n * its type admits `undefined`.\n */\nexport class DocumentedParameter {\n constructor(\n /** `path` or `query` — the OpenAPI `in`. */\n readonly location: string,\n /** The wire name, folded from the decorator argument. */\n readonly name: string,\n readonly required: boolean,\n /** The argument's declared type (`string`, `number`, `string[]`, a string enum, ...). */\n readonly type: TypeRef | undefined,\n ) {}\n}\n\n/** One `@Endpoint` method of one contract. */\nexport class DocumentedEndpoint {\n constructor(\n readonly methodName: string,\n /**\n * `GET`, `POST`, `PUT`, `PATCH` or `DELETE`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be\n * written without it — the verb is the key an operation hangs under in `paths`.\n */\n readonly httpMethod: string,\n /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */\n readonly path: string,\n /**\n * `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is\n * independent of the verb: webpieces POSTs a read. A renderer publishes it rather than\n * inferring safety from the verb, which for this framework would be wrong.\n */\n readonly operation: string,\n /** `rpc` | `cloudtasks` | `cron` | `external-inbound` | `external-outbound`, verbatim — this package invents no taxonomy. */\n readonly kind: string,\n /**\n * `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the\n * private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at\n * all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.\n */\n readonly hidden: boolean,\n /** `{ openWorld: true }` — this operation may touch systems outside this service. */\n readonly openWorld: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTool: DocumentedMcpTool | undefined,\n /**\n * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint\n * is PERMANENTLY outside MCP and was never a tool candidate.\n *\n * Distinct from \"has no `@WpMcpTool`\", which only says \"not a tool yet\". A renderer must not\n * report one of these as a SKIPPED tool, and `api-rules-for-mcp` stops asking a method with\n * one whether it could be served — the declaration is the answer. Carrying the reason rather\n * than a boolean is the point: the rule restates the list of exclusions with their arguments\n * on every run.\n */\n readonly invalidForMcp: string | undefined,\n /** The common @WpAuthorization declaration, shared by every surface. */\n readonly authorizationText: string | undefined,\n /** `@MaskLog({...})` — field name -> mask mode. */\n readonly maskLog: ReadonlyMap<string, string>,\n readonly description: string,\n /**\n * The method's `@summary` text — its one-line short title (#1296): the OpenAPI operation's\n * `summary` and, for a tool, MCP `Tool.title` AND `annotations.title`. Undefined when the method\n * has none; the OpenAPI generator refuses that for every published operation, and the MCP\n * renderer refuses a tool without one.\n */\n readonly summary: string | undefined,\n /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */\n readonly mcpDescription: string | undefined,\n /**\n * The method's `@returns` text — the SUCCESS response's `description` in a published document\n * (#1292). Undefined when the method has none; the OpenAPI generator refuses that for any\n * operation whose response has a body, rather than publishing a filler sentence.\n */\n readonly returnsDescription: string | undefined,\n readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\n readonly streaming?: DocumentedStreaming,\n readonly localOnly: boolean = false,\n /** Every `@PathParam` / `@QueryParam` argument, in declaration order. */\n readonly parameters: readonly DocumentedParameter[] = [],\n ) {}\n}\n\n/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */\nexport class ApiDocModel {\n constructor(\n /** The contract class name, e.g. `SaveApi`. */\n readonly contractName: string,\n /**\n * WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,\n * verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.\n *\n * A named list rather than a falsy default, because the grant has to be the TOKEN: a default\n * that reached customers would publish a contract whose author typed nothing about it.\n */\n readonly apiTypes: readonly string[],\n /** `@ApiPath(...)`, constant-folded. */\n readonly basePath: string,\n /** The JSDoc on the contract class, each `{@link}` encoded (`DocLinkText`). */\n readonly description: string,\n readonly endpoints: readonly DocumentedEndpoint[],\n /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n /** Everything that could not be represented — recorded, not dropped. */\n readonly unmapped: readonly UnmappedType[],\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n\n/**\n * ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the\n * components-only OpenAPI document it publishes (#1058). Data-only.\n *\n * A components document contains EVERY exported type the library declares — not only the ones some\n * contract reaches — so its contents are a property of the library alone and do not move when a\n * downstream contract changes.\n */\nexport class ApiComponentsModel {\n constructor(\n /** The library's package name — every type in {@link exported} is declared by it. */\n readonly packageName: string,\n /** The library's package version, published as the document's `info.version`. */\n readonly packageVersion: string,\n /** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */\n readonly exported: readonly string[],\n /** Every named type reached from the exports — the library's own and other packages'. */\n readonly types: ReadonlyMap<string, DocumentedType>,\n readonly unmapped: readonly UnmappedType[],\n readonly collisions: readonly TypeNameCollision[],\n /** Every reached declaration carrying two or more JSDoc blocks — see {@link StackedJsDoc}. */\n readonly stackedJsDoc: readonly StackedJsDoc[],\n ) {}\n}\n"]}