@webpieces/api-doc-model 0.4.1011 → 0.4.1012

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.McpIdentities = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const core_util_1 = require("@webpieces/core-util");
7
+ const ApiDocModel_1 = require("../model/ApiDocModel");
8
+ const ApiDocExtractionError_1 = require("./ApiDocExtractionError");
9
+ const CanonicalDecorator_1 = require("./CanonicalDecorator");
10
+ const McpProfiles_1 = require("./McpProfiles");
11
+ const SourceLocation_1 = require("./SourceLocation");
12
+ /** Every authored identity on one method, independent of TypeScript's decorator execution order. */
13
+ class McpIdentities {
14
+ read(member, folder) {
15
+ const tools = [];
16
+ const decorators = ts.canHaveDecorators(member) ? (ts.getDecorators(member) ?? []) : [];
17
+ for (const decorator of decorators) {
18
+ const call = decorator.expression;
19
+ if (!ts.isCallExpression(call))
20
+ continue;
21
+ if (CanonicalDecorator_1.CanonicalDecorator.nameOf(call.expression) !== core_util_1.WpMcpTool.name)
22
+ continue;
23
+ const argument = call.arguments[0];
24
+ const identity = new ApiDocModel_1.DocumentedMcpTool(argument === undefined ? '' : (folder.tryFoldString(argument) ?? ''), new McpProfiles_1.McpProfiles().read(call.arguments[1], folder));
25
+ if (tools.some((tool) => tool.name === identity.name)) {
26
+ throw new ApiDocExtractionError_1.ApiDocExtractionError(`Duplicate @WpMcpTool name '${identity.name}' on one method`, SourceLocation_1.SourceLocation.of(member), 'Declare each identity once, with all its profiles in one profiles array.');
27
+ }
28
+ tools.push(identity);
29
+ }
30
+ return tools.sort((a, b) => a.name.localeCompare(b.name));
31
+ }
32
+ }
33
+ exports.McpIdentities = McpIdentities;
34
+ //# sourceMappingURL=McpIdentities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpIdentities.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3B,8BAA8B,QAAQ,CAAC,IAAI,iBAAiB,EAC5D,+BAAc,CAAC,EAAE,CAAC,MAAM,CAAC,EACzB,0EAA0E,CAC7E,CAAC;YACN,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAoB,EAAE,CAAoB,EAAE,EAAE,CAC7D,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAC/B,CAAC;IACN,CAAC;CACJ;AA1BD,sCA0BC","sourcesContent":["import * as ts from 'typescript';\nimport { WpMcpTool } from '@webpieces/core-util';\nimport { DocumentedMcpTool } from '../model/ApiDocModel';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { ConstantFolder } from './ConstantFolder';\nimport { CanonicalDecorator } from './CanonicalDecorator';\nimport { McpProfiles } from './McpProfiles';\nimport { SourceLocation } from './SourceLocation';\n\n/** Every authored identity on one method, independent of TypeScript's decorator execution order. */\nexport class McpIdentities {\n read(member: ts.Node, folder: ConstantFolder): readonly DocumentedMcpTool[] {\n const tools: DocumentedMcpTool[] = [];\n const decorators = ts.canHaveDecorators(member) ? (ts.getDecorators(member) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (!ts.isCallExpression(call)) continue;\n if (CanonicalDecorator.nameOf(call.expression) !== WpMcpTool.name) continue;\n const argument = call.arguments[0];\n const identity = new DocumentedMcpTool(\n argument === undefined ? '' : (folder.tryFoldString(argument) ?? ''),\n new McpProfiles().read(call.arguments[1], folder),\n );\n if (tools.some((tool: DocumentedMcpTool) => tool.name === identity.name)) {\n throw new ApiDocExtractionError(\n `Duplicate @WpMcpTool name '${identity.name}' on one method`,\n SourceLocation.of(member),\n 'Declare each identity once, with all its profiles in one profiles array.',\n );\n }\n tools.push(identity);\n }\n return tools.sort((a: DocumentedMcpTool, b: DocumentedMcpTool) =>\n a.name.localeCompare(b.name),\n );\n }\n}\n"]}
@@ -29,7 +29,7 @@ const MCP_INVALID = core_util_1.InvalidEndpointForMcp.name;
29
29
  */
30
30
  // webpieces-disable no-function-outside-class -- module entry point, mirrors the extractor's own split-out helpers
31
31
  function assertApiTypeMatchesMcpTools(contract, apiTypes, endpoints) {
32
- const tools = endpoints.filter((e) => e.mcpTool !== undefined);
32
+ const tools = endpoints.filter((e) => e.mcpTools.length > 0);
33
33
  const excluded = endpoints.filter((e) => e.invalidForMcp !== undefined);
34
34
  const declaresMcp = apiTypes.includes(core_util_1.MCP);
35
35
  assertNoToolIsAlsoExcluded(contract, tools);
@@ -1 +1 @@
1
- {"version":3,"file":"McpMembership.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/McpMembership.ts"],"names":[],"mappings":";;AA+BA,oEAkCC;AAhED,oDAAsF;AAEtF,mEAAgE;AAChE,qDAAkD;AAElD;;;GAGG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAChC,MAAM,WAAW,GAAG,iCAAqB,CAAC,IAAI,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,mHAAmH;AACnH,SAAgB,4BAA4B,CACxC,QAA6B,EAC7B,QAA2B,EAC3B,SAAwC;IAExC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;IAC5F,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,eAAG,CAAC,CAAC;IAC3C,0BAA0B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,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,MAAM,KAAK,CAAC;QAAE,OAAO;IAC9B,MAAM,IAAI,6CAAqB,CAC3B,IAAI,QAAQ,SAAS,WAAW,gBAAgB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACjE,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,4FAA4F;QACxF,gEAAgE,CACvE,CAAC;AACN,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { ApiType, InvalidEndpointForMcp, MCP, WpMcpTool } from '@webpieces/core-util';\nimport { DocumentedEndpoint } from '../model/ApiDocModel';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * The decorator names, taken from the REAL SYMBOLS for the reason `ApiDocExtractor`'s constants give\n * at length: a literal that stops matching after a rename empties a document with the build green.\n */\nconst API_TYPE = ApiType.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\n\n/**\n * MCP membership has exactly ONE spelling, and this is the BUILD-TIME half of enforcing it\n * (`assertApiTypeMatchesMcpTools` in `@webpieces/core-util` is the wiring-time half).\n *\n * Declared in two places, the two can disagree — and the disagreement is invisible, because each\n * declaration is individually valid. That is the defect this whole epic exists to remove, so it\n * fails the DOCUMENT build rather than producing one that quietly lists the wrong tools.\n *\n * `@InvalidEndpointForMcp` (#1014) sits OUTSIDE the biconditional and is checked here too. A method\n * declared permanently unusable as a tool is neither required to carry `@WpMcpTool` nor permitted\n * to, and a contract whose every endpoint is so declared must not name MCP at all — the cure there\n * is the opposite one, so it gets its own sentence rather than being folded into \"no method carries\n * @WpMcpTool\".\n *\n * Split out of `ApiDocExtractor`, which owns the walk and is at its file-size limit.\n */\n// webpieces-disable no-function-outside-class -- module entry point, mirrors the extractor's own split-out helpers\nexport function assertApiTypeMatchesMcpTools(\n contract: ts.ClassDeclaration,\n apiTypes: readonly string[],\n endpoints: readonly DocumentedEndpoint[],\n): void {\n const tools = endpoints.filter((e: DocumentedEndpoint) => e.mcpTool !== undefined);\n const excluded = endpoints.filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined);\n const declaresMcp = apiTypes.includes(MCP);\n assertNoToolIsAlsoExcluded(contract, tools);\n if (declaresMcp && tools.length === 0 && excluded.length === endpoints.length) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but EVERY endpoint is @${MCP_INVALID}`,\n SourceLocation.of(contract),\n `Drop MCP from the @${API_TYPE} list — a contract whose every method is permanently ` +\n 'outside MCP does not feed the MCP document.',\n );\n }\n if (declaresMcp && tools.length === 0) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but no method carries @${MCP_TOOL}`,\n SourceLocation.of(contract),\n `Add @${MCP_TOOL}('<stable_tool_name>') to the methods agents may call (each one's ` +\n `@summary JSDoc line is its title), or drop MCP from the @${API_TYPE} list.`,\n );\n }\n if (!declaresMcp && tools.length > 0) {\n const named = tools.map((e: DocumentedEndpoint) => e.methodName).join(', ');\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} is on ${named} but @${API_TYPE} does not name MCP`,\n SourceLocation.of(contract),\n `Add MCP to the @${API_TYPE} list — membership has ONE spelling, so a tool on a ` +\n 'contract nobody published to agents is a contradiction, not a hint.',\n );\n }\n}\n\n/**\n * `@WpMcpTool` and `@InvalidEndpointForMcp` on ONE method is a contradiction, not a precedence rule.\n *\n * Resolving it either way would make the pair a second spelling of a decision that already has one,\n * and whichever way it resolved, half the readers of that method would be wrong about what it does.\n */\n// webpieces-disable no-function-outside-class -- private assert of the entry point above, beside it\nfunction assertNoToolIsAlsoExcluded(\n contract: ts.ClassDeclaration,\n tools: readonly DocumentedEndpoint[],\n): void {\n const both = tools\n .filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined)\n .map((e: DocumentedEndpoint) => e.methodName);\n if (both.length === 0) return;\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} and @${MCP_INVALID} are BOTH on ${both.join(', ')}`,\n SourceLocation.of(contract),\n 'They contradict each other — one publishes the method to agents and the other declares it ' +\n 'permanently unusable as a tool. Delete whichever one is wrong.',\n );\n}\n"]}
1
+ {"version":3,"file":"McpMembership.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/McpMembership.ts"],"names":[],"mappings":";;AA+BA,oEAkCC;AAhED,oDAAsF;AAEtF,mEAAgE;AAChE,qDAAkD;AAElD;;;GAGG;AACH,MAAM,QAAQ,GAAG,mBAAO,CAAC,IAAI,CAAC;AAC9B,MAAM,QAAQ,GAAG,qBAAS,CAAC,IAAI,CAAC;AAChC,MAAM,WAAW,GAAG,iCAAqB,CAAC,IAAI,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,mHAAmH;AACnH,SAAgB,4BAA4B,CACxC,QAA6B,EAC7B,QAA2B,EAC3B,SAAwC;IAExC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjF,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC;IAC5F,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,eAAG,CAAC,CAAC;IAC3C,0BAA0B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QAC5E,MAAM,IAAI,6CAAqB,CAC3B,IAAI,QAAQ,qCAAqC,WAAW,EAAE,EAC9D,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,sBAAsB,QAAQ,uDAAuD;YACjF,6CAA6C,CACpD,CAAC;IACN,CAAC;IACD,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,CA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from '@webpieces/core-util';\nimport { DocumentedEndpoint } from '../model/ApiDocModel';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * The decorator names, taken from the REAL SYMBOLS for the reason `ApiDocExtractor`'s constants give\n * at length: a literal that stops matching after a rename empties a document with the build green.\n */\nconst API_TYPE = ApiType.name;\nconst MCP_TOOL = WpMcpTool.name;\nconst MCP_INVALID = InvalidEndpointForMcp.name;\n\n/**\n * MCP membership has exactly ONE spelling, and this is the BUILD-TIME half of enforcing it\n * (`assertApiTypeMatchesMcpTools` in `@webpieces/core-util` is the wiring-time half).\n *\n * Declared in two places, the two can disagree — and the disagreement is invisible, because each\n * declaration is individually valid. That is the defect this whole epic exists to remove, so it\n * fails the DOCUMENT build rather than producing one that quietly lists the wrong tools.\n *\n * `@InvalidEndpointForMcp` (#1014) sits OUTSIDE the biconditional and is checked here too. A method\n * declared permanently unusable as a tool is neither required to carry `@WpMcpTool` nor permitted\n * to, and a contract whose every endpoint is so declared must not name MCP at all — the cure there\n * is the opposite one, so it gets its own sentence rather than being folded into \"no method carries\n * @WpMcpTool\".\n *\n * Split out of `ApiDocExtractor`, which owns the walk and is at its file-size limit.\n */\n// webpieces-disable no-function-outside-class -- module entry point, mirrors the extractor's own split-out helpers\nexport function assertApiTypeMatchesMcpTools(\n contract: ts.ClassDeclaration,\n apiTypes: readonly string[],\n endpoints: readonly DocumentedEndpoint[],\n): void {\n const tools = endpoints.filter((e: DocumentedEndpoint) => e.mcpTools.length > 0);\n const excluded = endpoints.filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined);\n const declaresMcp = apiTypes.includes(MCP);\n assertNoToolIsAlsoExcluded(contract, tools);\n if (declaresMcp && tools.length === 0 && excluded.length === endpoints.length) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but EVERY endpoint is @${MCP_INVALID}`,\n SourceLocation.of(contract),\n `Drop MCP from the @${API_TYPE} list — a contract whose every method is permanently ` +\n 'outside MCP does not feed the MCP document.',\n );\n }\n if (declaresMcp && tools.length === 0) {\n throw new ApiDocExtractionError(\n `@${API_TYPE} names MCP but no method carries @${MCP_TOOL}`,\n SourceLocation.of(contract),\n `Add @${MCP_TOOL}('<stable_tool_name>') to the methods agents may call (each one's ` +\n `@summary JSDoc line is its title), or drop MCP from the @${API_TYPE} list.`,\n );\n }\n if (!declaresMcp && tools.length > 0) {\n const named = tools.map((e: DocumentedEndpoint) => e.methodName).join(', ');\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} is on ${named} but @${API_TYPE} does not name MCP`,\n SourceLocation.of(contract),\n `Add MCP to the @${API_TYPE} list — membership has ONE spelling, so a tool on a ` +\n 'contract nobody published to agents is a contradiction, not a hint.',\n );\n }\n}\n\n/**\n * `@WpMcpTool` and `@InvalidEndpointForMcp` on ONE method is a contradiction, not a precedence rule.\n *\n * Resolving it either way would make the pair a second spelling of a decision that already has one,\n * and whichever way it resolved, half the readers of that method would be wrong about what it does.\n */\n// webpieces-disable no-function-outside-class -- private assert of the entry point above, beside it\nfunction assertNoToolIsAlsoExcluded(\n contract: ts.ClassDeclaration,\n tools: readonly DocumentedEndpoint[],\n): void {\n const both = tools\n .filter((e: DocumentedEndpoint) => e.invalidForMcp !== undefined)\n .map((e: DocumentedEndpoint) => e.methodName);\n if (both.length === 0) return;\n throw new ApiDocExtractionError(\n `@${MCP_TOOL} and @${MCP_INVALID} are BOTH on ${both.join(', ')}`,\n SourceLocation.of(contract),\n 'They contradict each other — one publishes the method to agents and the other declares it ' +\n 'permanently unusable as a tool. Delete whichever one is wrong.',\n );\n}\n"]}
@@ -426,7 +426,7 @@ export declare class DocumentedEndpoint {
426
426
  readonly additive: boolean;
427
427
  readonly options: DocumentedEndpointOptions;
428
428
  readonly auth: DocumentedAuth | undefined;
429
- readonly mcpTool: DocumentedMcpTool | undefined;
429
+ readonly mcpTools: readonly DocumentedMcpTool[];
430
430
  /**
431
431
  * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint
432
432
  * is PERMANENTLY outside MCP and was never a tool candidate.
@@ -489,7 +489,7 @@ export declare class DocumentedEndpoint {
489
489
  /** `{ openWorld: true }` — this operation may touch systems outside this service. */
490
490
  openWorld: boolean,
491
491
  /** `{ additive: true }` — a write that only adds: MCP `destructiveHint: false` (#1422). */
492
- additive: boolean, options: DocumentedEndpointOptions, auth: DocumentedAuth | undefined, mcpTool: DocumentedMcpTool | undefined,
492
+ additive: boolean, options: DocumentedEndpointOptions, auth: DocumentedAuth | undefined, mcpTools: readonly DocumentedMcpTool[],
493
493
  /**
494
494
  * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint
495
495
  * is PERMANENTLY outside MCP and was never a tool candidate.
@@ -396,7 +396,7 @@ class DocumentedEndpoint {
396
396
  additive;
397
397
  options;
398
398
  auth;
399
- mcpTool;
399
+ mcpTools;
400
400
  invalidForMcp;
401
401
  authorizationText;
402
402
  maskLog;
@@ -434,7 +434,7 @@ class DocumentedEndpoint {
434
434
  /** `{ openWorld: true }` — this operation may touch systems outside this service. */
435
435
  openWorld,
436
436
  /** `{ additive: true }` — a write that only adds: MCP `destructiveHint: false` (#1422). */
437
- additive, options, auth, mcpTool,
437
+ additive, options, auth, mcpTools,
438
438
  /**
439
439
  * `@InvalidEndpointForMcp('<reason>')`'s reason, when the method carries one — this endpoint
440
440
  * is PERMANENTLY outside MCP and was never a tool candidate.
@@ -477,7 +477,7 @@ class DocumentedEndpoint {
477
477
  this.additive = additive;
478
478
  this.options = options;
479
479
  this.auth = auth;
480
- this.mcpTool = mcpTool;
480
+ this.mcpTools = mcpTools;
481
481
  this.invalidForMcp = invalidForMcp;
482
482
  this.authorizationText = authorizationText;
483
483
  this.maskLog = maskLog;
@@ -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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;IACpC,wCAAwC;IAC/B,QAAgB;IACzB,+EAA+E;IACtE,WAAmB,EACnB,SAAwC;IACjD,8FAA8F;IACrF,KAA0C;IACnD,wEAAwE;IAC/D,QAAiC;IAC1C,yFAAyF;IAChF,UAAwC;IACjD,8FAA8F;IACrF,YAAqC;QArBrC,iBAAY,GAAZ,YAAY,CAAQ;QAQpB,aAAQ,GAAR,QAAQ,CAAmB;QAE3B,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAA+B;QAExC,UAAK,GAAL,KAAK,CAAqC;QAE1C,aAAQ,GAAR,QAAQ,CAAyB;QAEjC,eAAU,GAAV,UAAU,CAA8B;QAExC,iBAAY,GAAZ,YAAY,CAAyB;IAC/C,CAAC;CACP;AA1BD,kCA0BC;AAED;;;;;;;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 /** `{ additive: true }` — a write that only adds: MCP `destructiveHint: false` (#1422). */\n readonly additive: 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"]}
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,QAAQ,CAAQ;QAEhB,eAAU,GAAV,UAAU,CAAmB;IACvC,CAAC;CACP;AATD,oCASC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;;;;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 /** `{ additive: true }` — a write that only adds: MCP `destructiveHint: false` (#1422). */\n readonly additive: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTools: readonly DocumentedMcpTool[],\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"]}
@@ -1,5 +1,5 @@
1
1
  import { ApiJsonSchema, McpToolCatalogFile, McpToolDefinition } from '@webpieces/core-util';
2
- import { ApiDocModel, DocumentedEndpoint } from '../model/ApiDocModel';
2
+ import { ApiDocModel, DocumentedEndpoint, DocumentedMcpTool } from '../model/ApiDocModel';
3
3
  import { DocLinkProblem } from '../model/DocLink';
4
4
  import { OperationIds } from '../model/OperationIds';
5
5
  import { TypeRef } from '../model/TypeRef';
@@ -109,7 +109,7 @@ export declare class McpSchemaRenderer {
109
109
  /** Refuse a tool name some OTHER contract of this run already declared: the namespace is flat. */
110
110
  private static claimNames;
111
111
  /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */
112
- tool(endpoint: DocumentedEndpoint): McpToolDefinition;
112
+ tool(endpoint: DocumentedEndpoint, identity: DocumentedMcpTool): McpToolDefinition;
113
113
  /**
114
114
  * `operation` verbatim from the model, mapped back onto the REAL constant.
115
115
  *
@@ -119,8 +119,8 @@ class McpSchemaRenderer {
119
119
  render() {
120
120
  const tools = [];
121
121
  for (const endpoint of this.model.endpoints) {
122
- if (endpoint.mcpTool !== undefined) {
123
- tools.push(this.tool(endpoint));
122
+ for (const identity of endpoint.mcpTools) {
123
+ tools.push(this.tool(endpoint, identity));
124
124
  }
125
125
  }
126
126
  return tools;
@@ -159,18 +159,17 @@ class McpSchemaRenderer {
159
159
  const renderer = new McpSchemaRenderer(model, operationIds);
160
160
  const tools = [];
161
161
  for (const endpoint of model.endpoints) {
162
- if (endpoint.mcpTool === undefined) {
163
- continue;
164
- }
165
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring
166
- try {
167
- tools.push(renderer.tool(endpoint));
168
- }
169
- catch (err) {
170
- //const error = toError(err);
171
- if (!(err instanceof McpRenderError_1.McpRenderError))
172
- throw err;
173
- skipped.push(new SkippedMcpTool(endpoint.mcpTool.name, model.contractName, err.message));
162
+ for (const identity of endpoint.mcpTools) {
163
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring
164
+ try {
165
+ tools.push(renderer.tool(endpoint, identity));
166
+ }
167
+ catch (err) {
168
+ //const error = toError(err);
169
+ if (!(err instanceof McpRenderError_1.McpRenderError))
170
+ throw err;
171
+ skipped.push(new SkippedMcpTool(identity.name, model.contractName, err.message));
172
+ }
174
173
  }
175
174
  }
176
175
  McpSchemaRenderer.claimNames(owners, model.contractName, tools);
@@ -206,7 +205,7 @@ class McpSchemaRenderer {
206
205
  static claimNames(owners, contractName, tools) {
207
206
  for (const tool of tools) {
208
207
  const owner = owners.get(tool.name);
209
- if (owner !== undefined && owner !== contractName) {
208
+ if (owner !== undefined) {
210
209
  throw new core_util_1.McpToolCatalogError(`Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`, 'Tool names are the protocol identity and must be globally unique — rename one ' +
211
210
  "of the two @WpMcpTool('<name>') declarations.");
212
211
  }
@@ -214,7 +213,7 @@ class McpSchemaRenderer {
214
213
  }
215
214
  }
216
215
  /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */
217
- tool(endpoint) {
216
+ tool(endpoint, identity) {
218
217
  const where = `${this.model.contractName}.${endpoint.methodName}`;
219
218
  const description = endpoint.mcpDescription ?? endpoint.description;
220
219
  if (description.trim() === '') {
@@ -229,14 +228,14 @@ class McpSchemaRenderer {
229
228
  throw new McpRenderError_1.McpRenderError(`an MCP tool ${summaryProblem}, so it has no title`, where, `${EndpointSummary_1.EndpointSummary.cure()} tools/list publishes it as title and annotations.title ` +
230
229
  '(#1296); it is never derived from the tool name.');
231
230
  }
232
- const nameProblem = core_util_1.McpToolName.problemWith(endpoint.mcpTool.name);
231
+ const nameProblem = core_util_1.McpToolName.problemWith(identity.name);
233
232
  if (nameProblem !== undefined) {
234
- throw new McpRenderError_1.McpRenderError(`the MCP tool name '${endpoint.mcpTool.name}' ${nameProblem}`, where, core_util_1.McpToolName.cure());
233
+ throw new McpRenderError_1.McpRenderError(`the MCP tool name '${identity.name}' ${nameProblem}`, where, core_util_1.McpToolName.cure());
235
234
  }
236
- return new core_util_1.McpToolDefinition(endpoint.mcpTool.name, this.prose(endpoint.summary), endpoint.methodName, this.prose(description), (0, core_util_1.mcpHintsForOperation)(McpSchemaRenderer.operationOf(endpoint, where), endpoint.openWorld, endpoint.additive), this.rootSchema(endpoint.request, where, 'request', undefined),
235
+ return new core_util_1.McpToolDefinition(identity.name, this.prose(endpoint.summary), endpoint.methodName, this.prose(description), (0, core_util_1.mcpHintsForOperation)(McpSchemaRenderer.operationOf(endpoint, where), endpoint.openWorld, endpoint.additive), this.rootSchema(endpoint.request, where, 'request', undefined),
237
236
  // OPEN for clients (#1441): a client caches the outputSchema at connect and validates
238
237
  // every result against it, so a closed one made ADDING a response field a break.
239
- core_util_1.ApiJsonSchema.openForClients(this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription)), endpoint.mcpTool.profiles);
238
+ core_util_1.ApiJsonSchema.openForClients(this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription)), identity.profiles);
240
239
  }
241
240
  /**
242
241
  * `operation` verbatim from the model, mapped back onto the REAL constant.
@@ -455,7 +454,14 @@ class McpSchemaRenderer {
455
454
  */
456
455
  // webpieces-disable no-function-outside-class -- private static mapping of this class
457
456
  static openJson() {
458
- const schema = new core_util_1.ApiJsonSchema(['string', 'number', 'boolean', 'object', 'array', 'null']);
457
+ const schema = new core_util_1.ApiJsonSchema([
458
+ 'string',
459
+ 'number',
460
+ 'boolean',
461
+ 'object',
462
+ 'array',
463
+ 'null',
464
+ ]);
459
465
  schema.additionalProperties = true;
460
466
  return schema;
461
467
  }