@webpieces/api-doc-model 0.4.945 → 0.4.947
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 +2 -2
- package/src/extract/JsDoc.d.ts +13 -3
- package/src/extract/JsDoc.js +30 -5
- package/src/extract/JsDoc.js.map +1 -1
- package/src/extract/TypeResolver.js +1 -1
- package/src/extract/TypeResolver.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +33 -1
- package/src/model/ApiDocModel.js +21 -1
- package/src/model/ApiDocModel.js.map +1 -1
- package/src/model/DocLink.d.ts +2 -1
- package/src/model/DocLink.js +7 -5
- package/src/model/DocLink.js.map +1 -1
- package/src/render/McpSchemaRenderer.js +3 -1
- package/src/render/McpSchemaRenderer.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/api-doc-model",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.947",
|
|
4
4
|
"description": "TypeScript-compiler-API extractor producing one in-memory ApiDocModel from a webpieces API contract. No renderer, no runtime, no app-specific import.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
26
|
+
"@webpieces/core-util": "0.4.947",
|
|
27
27
|
"typescript": "5.9.3",
|
|
28
28
|
"minimatch": "10.0.1"
|
|
29
29
|
}
|
package/src/extract/JsDoc.d.ts
CHANGED
|
@@ -3,15 +3,17 @@ import { StackedJsDoc } from '../model/ApiDocModel';
|
|
|
3
3
|
import { DocLinkReader } from './DocLinkReader';
|
|
4
4
|
/**
|
|
5
5
|
* The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`
|
|
6
|
-
* tag and the `@
|
|
6
|
+
* tag, the `@mcp` override and the field-level `@hidden` flag (#1246).
|
|
7
7
|
*
|
|
8
8
|
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
9
9
|
*
|
|
10
|
-
* The body and the
|
|
10
|
+
* The body and the tags named here are the ONLY text read out of a block. Every other block tag
|
|
11
11
|
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
12
12
|
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
13
13
|
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
14
|
-
* renderer can ever reach it — the same reason `{@link}` is read here (below).
|
|
14
|
+
* renderer can ever reach it — the same reason `{@link}` is read here (below). `@hidden`'s text (#1246)
|
|
15
|
+
* is read, but only into its own field: it is the author's reason for withholding a field, and like
|
|
16
|
+
* `@privateRemarks` it is published nowhere. `//` and `/* *\/`
|
|
15
17
|
* comments are private by construction: the compiler attaches no JSDoc for them.
|
|
16
18
|
*
|
|
17
19
|
* `{@link Foo.bar}` is RESOLVED here, by the compiler, into a `DocLink` encoded in the prose (#1284):
|
|
@@ -61,6 +63,14 @@ export declare class JsDoc {
|
|
|
61
63
|
* same thing, and #984 deleted it.
|
|
62
64
|
*/
|
|
63
65
|
readonly mcpHeader: string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* True when the block carries the `@hidden` tag (#1246). Only a FIELD's is read into the
|
|
68
|
+
* model (`DocumentedField.hidden`); the tag and its text are, like every other tag, never part
|
|
69
|
+
* of {@link description}, so the reason an author gives cannot leak into a published document.
|
|
70
|
+
*/
|
|
71
|
+
readonly hidden: boolean;
|
|
72
|
+
/** The `@hidden` tag's text, trimmed; undefined when the tag has none or is absent. */
|
|
73
|
+
readonly hiddenReason: string | undefined;
|
|
64
74
|
private constructor();
|
|
65
75
|
/** Read the JSDoc attached to one declaration, resolving every `{@link}` with `links`. */
|
|
66
76
|
static read(node: ts.Node, links: DocLinkReader): JsDoc;
|
package/src/extract/JsDoc.js
CHANGED
|
@@ -15,17 +15,24 @@ const RETURNS_TAG = 'returns';
|
|
|
15
15
|
* `summary` and MCP `title` / `annotations.title`.
|
|
16
16
|
*/
|
|
17
17
|
const SUMMARY_TAG = 'summary';
|
|
18
|
+
/**
|
|
19
|
+
* The field-level visibility tag (#1246): the field is withheld from the CUSTOMER document. Read by
|
|
20
|
+
* PRESENCE — a bare `@hidden` hides exactly like one with a reason — and its text is never published.
|
|
21
|
+
*/
|
|
22
|
+
const HIDDEN_TAG = 'hidden';
|
|
18
23
|
/**
|
|
19
24
|
* The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`
|
|
20
|
-
* tag and the `@
|
|
25
|
+
* tag, the `@mcp` override and the field-level `@hidden` flag (#1246).
|
|
21
26
|
*
|
|
22
27
|
* ## Every `/** *\/` is published — except `@privateRemarks` (#1292)
|
|
23
28
|
*
|
|
24
|
-
* The body and the
|
|
29
|
+
* The body and the tags named here are the ONLY text read out of a block. Every other block tag
|
|
25
30
|
* is dropped together with its text, and `@privateRemarks` — TSDoc's standard "inside the doc block,
|
|
26
31
|
* never published" tag — is the one an author writes ON PURPOSE to keep a note out of every document:
|
|
27
32
|
* OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no
|
|
28
|
-
* renderer can ever reach it — the same reason `{@link}` is read here (below).
|
|
33
|
+
* renderer can ever reach it — the same reason `{@link}` is read here (below). `@hidden`'s text (#1246)
|
|
34
|
+
* is read, but only into its own field: it is the author's reason for withholding a field, and like
|
|
35
|
+
* `@privateRemarks` it is published nowhere. `//` and `/* *\/`
|
|
29
36
|
* comments are private by construction: the compiler attaches no JSDoc for them.
|
|
30
37
|
*
|
|
31
38
|
* `{@link Foo.bar}` is RESOLVED here, by the compiler, into a `DocLink` encoded in the prose (#1284):
|
|
@@ -42,6 +49,8 @@ class JsDoc {
|
|
|
42
49
|
format;
|
|
43
50
|
mcp;
|
|
44
51
|
mcpHeader;
|
|
52
|
+
hidden;
|
|
53
|
+
hiddenReason;
|
|
45
54
|
constructor(
|
|
46
55
|
/**
|
|
47
56
|
* The body text, links encoded (see the class doc), trimmed. Empty string when undocumented.
|
|
@@ -81,13 +90,23 @@ class JsDoc {
|
|
|
81
90
|
* ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the
|
|
82
91
|
* same thing, and #984 deleted it.
|
|
83
92
|
*/
|
|
84
|
-
mcpHeader
|
|
93
|
+
mcpHeader,
|
|
94
|
+
/**
|
|
95
|
+
* True when the block carries the `@hidden` tag (#1246). Only a FIELD's is read into the
|
|
96
|
+
* model (`DocumentedField.hidden`); the tag and its text are, like every other tag, never part
|
|
97
|
+
* of {@link description}, so the reason an author gives cannot leak into a published document.
|
|
98
|
+
*/
|
|
99
|
+
hidden,
|
|
100
|
+
/** The `@hidden` tag's text, trimmed; undefined when the tag has none or is absent. */
|
|
101
|
+
hiddenReason) {
|
|
85
102
|
this.description = description;
|
|
86
103
|
this.summary = summary;
|
|
87
104
|
this.returns = returns;
|
|
88
105
|
this.format = format;
|
|
89
106
|
this.mcp = mcp;
|
|
90
107
|
this.mcpHeader = mcpHeader;
|
|
108
|
+
this.hidden = hidden;
|
|
109
|
+
this.hiddenReason = hiddenReason;
|
|
91
110
|
}
|
|
92
111
|
/** Read the JSDoc attached to one declaration, resolving every `{@link}` with `links`. */
|
|
93
112
|
// webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose
|
|
@@ -100,6 +119,8 @@ class JsDoc {
|
|
|
100
119
|
let format;
|
|
101
120
|
let mcp;
|
|
102
121
|
let mcpHeader;
|
|
122
|
+
let hidden = false;
|
|
123
|
+
let hiddenReason;
|
|
103
124
|
for (const block of blocks) {
|
|
104
125
|
bodies.push(JsDoc.flatten(block.comment, links));
|
|
105
126
|
for (const tag of block.tags ?? []) {
|
|
@@ -122,9 +143,13 @@ class JsDoc {
|
|
|
122
143
|
else if (name === 'mcpHeader' && text !== '') {
|
|
123
144
|
mcpHeader = text;
|
|
124
145
|
}
|
|
146
|
+
else if (name === HIDDEN_TAG) {
|
|
147
|
+
hidden = true;
|
|
148
|
+
hiddenReason = text === '' ? hiddenReason : text;
|
|
149
|
+
}
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
|
-
return new JsDoc(bodies.join('\n').trim(), summary, returns, format, mcp, mcpHeader);
|
|
152
|
+
return new JsDoc(bodies.join('\n').trim(), summary, returns, format, mcp, mcpHeader, hidden, hiddenReason);
|
|
128
153
|
}
|
|
129
154
|
/**
|
|
130
155
|
* The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else
|
package/src/extract/JsDoc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,sDAAoD;AAEpD,qDAAkD;AAQlD;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,KAAK;IAOD;IAQA;IAMA;IAEA;IAOA;IAUA;IAvCb;IACI;;;;OAIG;IACM,WAAmB;IAC5B;;;;;;OAMG;IACM,OAA2B;IACpC;;;;OAIG;IACM,OAA2B;IACpC,kEAAkE;IACzD,MAA0B;IACnC;;;;;OAKG;IACM,GAAuB;IAChC;;;;;;;;OAQG;IACM,SAA6B;QAjC7B,gBAAW,GAAX,WAAW,CAAQ;QAQnB,YAAO,GAAP,OAAO,CAAoB;QAM3B,YAAO,GAAP,OAAO,CAAoB;QAE3B,WAAM,GAAN,MAAM,CAAoB;QAO1B,QAAG,GAAH,GAAG,CAAoB;QAUvB,cAAS,GAAT,SAAS,CAAoB;IACvC,CAAC;IAEJ,0FAA0F;IAC1F,iIAAiI;IACjI,MAAM,CAAC,IAAI,CAAC,IAAa,EAAE,KAAoB;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;QAC9D,MAAM,QAAQ,GACV,MAAM,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,OAAO,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3F,CAAC;IAED;;;;;OAKG;IACH,qFAAqF;IAC7E,MAAM,CAAC,OAAO,CAClB,OAA2D,EAC3D,KAAoB;QAEpB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACd,CAAC;QACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACnC,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AA7ID,sBA6IC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { DocLinkReader } from './DocLinkReader';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one\n * spelling per fact, and a refusal naming `@returns` is how an author finds out.\n */\nconst RETURNS_TAG = 'returns';\n\n/**\n * The standard JSDoc tag for an endpoint's one-line short title (#1296), published as OpenAPI\n * `summary` and MCP `title` / `annotations.title`.\n */\nconst SUMMARY_TAG = 'summary';\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`\n * tag and the `@mcp` override.\n *\n * ## Every `/** *\\/` is published — except `@privateRemarks` (#1292)\n *\n * The body and the five tags named here are the ONLY text read out of a block. Every other block tag\n * is dropped together with its text, and `@privateRemarks` — TSDoc's standard \"inside the doc block,\n * never published\" tag — is the one an author writes ON PURPOSE to keep a note out of every document:\n * OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no\n * renderer can ever reach it — the same reason `{@link}` is read here (below). `//` and `/* *\\/`\n * comments are private by construction: the compiler attaches no JSDoc for them.\n *\n * `{@link Foo.bar}` is RESOLVED here, by the compiler, into a `DocLink` encoded in the prose (#1284):\n * what it points at — a type and its model key, a contract operation, or nothing publishable. It is\n * not flattened to its source text, because the source name is exactly what must not be published:\n * a renderer names it as it publishes — the stripped schema name, the operationId, an MCP tool's\n * name — as a markdown code span, through the one grammar `DocLinkText` owns. Nothing downstream\n * parses the inline tag grammar.\n */\nexport class JsDoc {\n private constructor(\n /**\n * The body text, links encoded (see the class doc), trimmed. Empty string when undocumented.\n * A block TAG is never part of it — `@summary`, `@returns` and the rest are read into their\n * own fields (or dropped), so the short title never repeats inside the description it heads.\n */\n readonly description: string,\n /**\n * The `@summary` block tag's text — the endpoint's one-line short title (#1296), published as\n * the OpenAPI operation `summary` and as MCP `Tool.title` AND `annotations.title`. Undefined\n * when the author wrote none (or wrote the tag with no text); the OpenAPI generator refuses\n * that for every published operation. Kept VERBATIM (trimmed): a second line is the author's\n * mistake to be told about, not something to silently join or cut.\n */\n readonly summary: string | undefined,\n /**\n * The `@returns` block tag's text — what a method's success response carries, published as\n * that response's `description` (#1292). Undefined when the author wrote none (or wrote the\n * tag with no text), which an OpenAPI renderer refuses for an operation with a body.\n */\n readonly returns: string | undefined,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration, resolving every `{@link}` with `links`. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node, links: DocLinkReader): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let summary: string | undefined;\n let returns: string | undefined;\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment, links));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment, links);\n // `@privateRemarks` (and every tag not named below) is skipped with its text — see\n // the class doc: it is never published anywhere.\n if (name === SUMMARY_TAG && text !== '') {\n summary = text;\n } else if (name === RETURNS_TAG && text !== '') {\n returns = text;\n } else if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n }\n }\n }\n\n return new JsDoc(bodies.join('\\n').trim(), summary, returns, format, mcp, mcpHeader);\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember =\n parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline link replaced by what {@link DocLinkReader} makes of it.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(\n comment: string | ts.NodeArray<ts.JSDocComment> | undefined,\n links: DocLinkReader,\n ): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n parts.push(links.textOf(part));\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JsDoc.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/JsDoc.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,sDAAoD;AAEpD,qDAAkD;AAQlD;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,GAAG,QAAQ,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,KAAK;IAOD;IAQA;IAMA;IAEA;IAOA;IAUA;IAMA;IAEA;IA/Cb;IACI;;;;OAIG;IACM,WAAmB;IAC5B;;;;;;OAMG;IACM,OAA2B;IACpC;;;;OAIG;IACM,OAA2B;IACpC,kEAAkE;IACzD,MAA0B;IACnC;;;;;OAKG;IACM,GAAuB;IAChC;;;;;;;;OAQG;IACM,SAA6B;IACtC;;;;OAIG;IACM,MAAe;IACxB,uFAAuF;IAC9E,YAAgC;QAzChC,gBAAW,GAAX,WAAW,CAAQ;QAQnB,YAAO,GAAP,OAAO,CAAoB;QAM3B,YAAO,GAAP,OAAO,CAAoB;QAE3B,WAAM,GAAN,MAAM,CAAoB;QAO1B,QAAG,GAAH,GAAG,CAAoB;QAUvB,cAAS,GAAT,SAAS,CAAoB;QAM7B,WAAM,GAAN,MAAM,CAAS;QAEf,iBAAY,GAAZ,YAAY,CAAoB;IAC1C,CAAC;IAEJ,0FAA0F;IAC1F,iIAAiI;IACjI,MAAM,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,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AAnKD,sBAmKC","sourcesContent":["import * as ts from 'typescript';\nimport { StackedJsDoc } from '../model/ApiDocModel';\nimport { DocLinkReader } from './DocLinkReader';\nimport { SourceLocation } from './SourceLocation';\n\n/**\n * A node the compiler has attached JSDoc blocks to. `jsDoc` is internal to the TypeScript API and is\n * therefore not on `ts.Node`, so it is named HERE, once, instead of being cast at the use site.\n */\ntype JsDocCarrier = ts.Node & { jsDoc?: ts.JSDoc[] };\n\n/**\n * TSDoc's spelling of the success-response tag. JSDoc's older `@return` is deliberately NOT read: one\n * spelling per fact, and a refusal naming `@returns` is how an author finds out.\n */\nconst RETURNS_TAG = 'returns';\n\n/**\n * The standard JSDoc tag for an endpoint's one-line short title (#1296), published as OpenAPI\n * `summary` and MCP `title` / `annotations.title`.\n */\nconst SUMMARY_TAG = 'summary';\n\n/**\n * The field-level visibility tag (#1246): the field is withheld from the CUSTOMER document. Read by\n * PRESENCE — a bare `@hidden` hides exactly like one with a reason — and its text is never published.\n */\nconst HIDDEN_TAG = 'hidden';\n\n/**\n * The PROSE half of the model: the JSDoc body, the `@summary` tag, the `@returns` tag, the `@format`\n * tag, the `@mcp` override and the field-level `@hidden` flag (#1246).\n *\n * ## Every `/** *\\/` is published — except `@privateRemarks` (#1292)\n *\n * The body and the tags named here are the ONLY text read out of a block. Every other block tag\n * is dropped together with its text, and `@privateRemarks` — TSDoc's standard \"inside the doc block,\n * never published\" tag — is the one an author writes ON PURPOSE to keep a note out of every document:\n * OpenAPI, MCP tool catalogs, tag and schema descriptions. It is dropped HERE, at extraction, so no\n * renderer can ever reach it — the same reason `{@link}` is read here (below). `@hidden`'s text (#1246)\n * is read, but only into its own field: it is the author's reason for withholding a field, and like\n * `@privateRemarks` it is published nowhere. `//` and `/* *\\/`\n * comments are private by construction: the compiler attaches no JSDoc for them.\n *\n * `{@link Foo.bar}` is RESOLVED here, by the compiler, into a `DocLink` encoded in the prose (#1284):\n * what it points at — a type and its model key, a contract operation, or nothing publishable. It is\n * not flattened to its source text, because the source name is exactly what must not be published:\n * a renderer names it as it publishes — the stripped schema name, the operationId, an MCP tool's\n * name — as a markdown code span, through the one grammar `DocLinkText` owns. Nothing downstream\n * parses the inline tag grammar.\n */\nexport class JsDoc {\n private constructor(\n /**\n * The body text, links encoded (see the class doc), trimmed. Empty string when undocumented.\n * A block TAG is never part of it — `@summary`, `@returns` and the rest are read into their\n * own fields (or dropped), so the short title never repeats inside the description it heads.\n */\n readonly description: string,\n /**\n * The `@summary` block tag's text — the endpoint's one-line short title (#1296), published as\n * the OpenAPI operation `summary` and as MCP `Tool.title` AND `annotations.title`. Undefined\n * when the author wrote none (or wrote the tag with no text); the OpenAPI generator refuses\n * that for every published operation. Kept VERBATIM (trimmed): a second line is the author's\n * mistake to be told about, not something to silently join or cut.\n */\n readonly summary: string | undefined,\n /**\n * The `@returns` block tag's text — what a method's success response carries, published as\n * that response's `description` (#1292). Undefined when the author wrote none (or wrote the\n * tag with no text), which an OpenAPI renderer refuses for an operation with a body.\n */\n readonly returns: string | undefined,\n /** The `@format` block tag's text, e.g. `email` / `date-time`. */\n readonly format: string | undefined,\n /**\n * The `@mcp` block tag's text — the OPTIONAL agent-facing override. Undefined means the\n * author wrote none, which a renderer answers by falling back to {@link description}. The\n * fallback is NOT applied here: \"the author wrote an agent-facing sentence\" and \"we reused\n * the human one\" are different facts, and only the first is worth trusting.\n */\n readonly mcp: string | undefined,\n /**\n * The `@mcpHeader <token>` block tag — the MCP 2026 SEP-2243 header a PRIMITIVE tool\n * parameter is mirrored into (`Mcp-Param-{token}`).\n *\n * It is a JSDoc tag and not a decorator because it is a DOCUMENTATION fact about one field\n * of one wire document, and this epic's rule is that documentation has one source. It is the\n * ONLY spelling: the equivalence gate (#983) proved the deleted decorator argument said the\n * same thing, and #984 deleted it.\n */\n readonly mcpHeader: string | undefined,\n /**\n * True when the block carries the `@hidden` tag (#1246). Only a FIELD's is read into the\n * model (`DocumentedField.hidden`); the tag and its text are, like every other tag, never part\n * of {@link description}, so the reason an author gives cannot leak into a published document.\n */\n readonly hidden: boolean,\n /** The `@hidden` tag's text, trimmed; undefined when the tag has none or is absent. */\n readonly hiddenReason: string | undefined,\n ) {}\n\n /** Read the JSDoc attached to one declaration, resolving every `{@link}` with `links`. */\n // webpieces-disable no-function-outside-class -- static factory; JsDoc has a private constructor so a caller cannot invent prose\n static read(node: ts.Node, links: DocLinkReader): JsDoc {\n const symbolLike = node as JsDocCarrier;\n const blocks = symbolLike.jsDoc ?? [];\n const bodies: string[] = [];\n let summary: string | undefined;\n let returns: string | undefined;\n let format: string | undefined;\n let mcp: string | undefined;\n let mcpHeader: string | undefined;\n let hidden = false;\n let hiddenReason: string | undefined;\n\n for (const block of blocks) {\n bodies.push(JsDoc.flatten(block.comment, links));\n for (const tag of block.tags ?? []) {\n const name = tag.tagName.text;\n const text = JsDoc.flatten(tag.comment, links);\n // `@privateRemarks` (and every tag not named below) is skipped with its text — see\n // the class doc: it is never published anywhere.\n if (name === SUMMARY_TAG && text !== '') {\n summary = text;\n } else if (name === RETURNS_TAG && text !== '') {\n returns = text;\n } else if (name === 'format' && text !== '') {\n format = text;\n } else if (name === 'mcp' && text !== '') {\n mcp = text;\n } else if (name === 'mcpHeader' && text !== '') {\n mcpHeader = text;\n } else if (name === HIDDEN_TAG) {\n hidden = true;\n hiddenReason = text === '' ? hiddenReason : text;\n }\n }\n }\n\n return new JsDoc(\n bodies.join('\\n').trim(),\n summary,\n returns,\n format,\n mcp,\n mcpHeader,\n hidden,\n hiddenReason,\n );\n }\n\n /**\n * The {@link StackedJsDoc} record for `node` when it carries TWO OR MORE JSDoc blocks, else\n * undefined (#1286).\n *\n * A declaration under `node_modules` is never recorded: it is a published package's to own, its\n * author cannot be handed the cure from here, and that package's own generation is what refuses it\n * — the same line the wire closure draws.\n */\n // webpieces-disable no-function-outside-class -- static reader beside read(); both interpret the same jsDoc array\n static stackedAt(node: ts.Node): StackedJsDoc | undefined {\n const blocks = (node as JsDocCarrier).jsDoc ?? [];\n if (blocks.length < 2) {\n return undefined;\n }\n const file = node.getSourceFile();\n if (file.fileName.includes('/node_modules/')) {\n return undefined;\n }\n const blockLines = blocks.map(\n (block: ts.JSDoc) => file.getLineAndCharacterOfPosition(block.getStart(file)).line + 1,\n );\n return new StackedJsDoc(JsDoc.nameOf(node), SourceLocation.of(node), blockLines);\n }\n\n /** `Widget`, `Widget.name`, `save` — what an author searches the file for. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static nameOf(node: ts.Node): string {\n const name = (node as ts.NamedDeclaration).name;\n const own = name !== undefined ? name.getText() : ts.SyntaxKind[node.kind];\n const parent = node.parent as ts.NamedDeclaration | undefined;\n const isMember =\n parent !== undefined && (ts.isClassLike(parent) || ts.isInterfaceDeclaration(parent));\n return isMember && parent.name !== undefined ? `${parent.name.getText()}.${own}` : own;\n }\n\n /**\n * A comment's text with every inline link replaced by what {@link DocLinkReader} makes of it.\n *\n * TypeScript hands a commented node either a plain string or an array of parts, and the link\n * parts are the ones with structure. Both shapes are handled here so no caller has to.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static flatten(\n comment: string | ts.NodeArray<ts.JSDocComment> | undefined,\n links: DocLinkReader,\n ): string {\n if (comment === undefined) {\n return '';\n }\n if (typeof comment === 'string') {\n return comment.trim();\n }\n const parts: string[] = [];\n for (const part of comment) {\n if (ts.isJSDocLink(part) || ts.isJSDocLinkCode(part) || ts.isJSDocLinkPlain(part)) {\n parts.push(links.textOf(part));\n } else {\n parts.push(part.text);\n }\n }\n return parts.join('').trim();\n }\n}\n"]}
|
|
@@ -491,7 +491,7 @@ class TypeResolver {
|
|
|
491
491
|
const min = FieldDecorators_1.FieldDecorators.numericArgument(member, MIN_DECORATOR);
|
|
492
492
|
const max = FieldDecorators_1.FieldDecorators.numericArgument(member, MAX_DECORATOR);
|
|
493
493
|
FieldDecorators_1.FieldDecorators.assertNumericConstraintsFit(member, name, type, min, max);
|
|
494
|
-
return new ApiDocModel_1.DocumentedField(name, type, optional, nullable, doc.description, doc.mcp, doc.format, min, max, doc.mcpHeader, SourceLocation_1.SourceLocation.of(member));
|
|
494
|
+
return new ApiDocModel_1.DocumentedField(name, type, optional, nullable, doc.description, doc.mcp, doc.format, min, max, doc.mcpHeader, SourceLocation_1.SourceLocation.of(member), doc.hidden, doc.hiddenReason);
|
|
495
495
|
}
|
|
496
496
|
/** The declaration a type name points at, through imports and aliases. */
|
|
497
497
|
declarationOf(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeResolver.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/TypeResolver.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,oDAA2D;AAC3D,sDAO8B;AAC9B,8CAA0D;AAE1D,mDAAgD;AAChD,mCAAgC;AAChC,yDAAmE;AACnE,uDAAoD;AAEpD,iDAA8C;AAC9C,qDAAkD;AAClD,uDAAoD;AAEpD;;;;GAIG;AACH,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IAqBA;IApBJ,QAAQ,GAAmB,EAAE,CAAC;IAC/C;;;OAGG;IACc,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3D,gGAAgG;IAC/E,QAAQ,CAAe;IACxC,gGAAgG;IAC/E,kBAAkB,GAAG,IAAI,GAAG,EAAe,CAAC;IAE5C,KAAK,CAAmB;IACzC,yEAAy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;AAtlBD,oCAslBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport * as ts from 'typescript';\nimport { WpInt, WpMax, WpMin } from '@webpieces/core-util';\nimport {\n DocumentedField,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from '../model/ApiDocModel';\nimport { PrimitiveKind, TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { DocLinkReader } from './DocLinkReader';\nimport { JsDoc } from './JsDoc';\nimport { ObjectShape, ObjectShapeBases } from './ObjectShapeBases';\nimport { FieldDecorators } from './FieldDecorators';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeRegistry } from './TypeRegistry';\nimport { SourceLocation } from './SourceLocation';\nimport { StringValueSets } from './StringValueSets';\n\n/**\n * The decorators this resolver reads off a DTO property, named from the REAL SYMBOLS — a rename in\n * `core-util` is a compile error here rather than a literal that quietly stops matching. See\n * {@link ApiDocExtractor}'s constants for the full argument (issue #1001).\n */\nconst INT_DECORATOR = WpInt.name;\nconst MIN_DECORATOR = WpMin.name;\nconst MAX_DECORATOR = WpMax.name;\n\n/**\n * The type-alias name that DECLARES integer-ness.\n *\n * This one is a LITERAL and cannot be anything else: `Integer` is a TYPE ALIAS, so there is no\n * runtime symbol whose `.name` could be read — `.name` is a property of a function, and a type has\n * erased by then. It is the one name in this package that a rename in `core-util` would not break at\n * compile time; the cure if that ever bites is to make integer-ness a decorator here too, not to\n * pretend a type has a runtime identity. See {@link ApiDocExtractor}'s constants for the argument\n * everywhere else (issue #1001).\n */\nconst INTEGER_ALIAS = 'Integer';\n\n/**\n * Resolve declared TypeScript types into {@link TypeRef}s, registering every NAMED type it meets as\n * a {@link DocumentedType} a renderer can `$ref`.\n *\n * ## It walks TYPE NODES, not checker types, and that is load-bearing\n *\n * `type Integer = number` resolves, in the checker, to `number` — the alias is gone. Integer-ness is\n * therefore invisible to a checker-driven walk, and the whole reason `Integer` is the PREFERRED\n * spelling is that it COMPOSES: `Integer[]` and `Record<string, Integer>` say exactly which thing is\n * an integer, where a decorator on `counts?: number[]` cannot (the same ambiguity the deleted\n * `arrayItems` argument had). Walking the written syntax is what keeps that composition readable.\n *\n * ## Cycles terminate BY CONSTRUCTION\n *\n * Every named type is ONE entry in the model, registered before its fields are walked, so a type\n * that refers back to itself resolves to a `$ref` at the second visit and stops. There is NO depth\n * counter anywhere — a deep-but-finite graph of 7, 20 or 200 named hops is fully expanded, because\n * truncating one would silently publish an incomplete document. The ONLY thing that is cut is a\n * self-referential ANONYMOUS type, and it is cut by NODE IDENTITY (it has no name to `$ref`), with an\n * {@link UnmappedType} recorded so #982's guard has something to name.\n *\n * ## Every type is keyed by its DECLARING PACKAGE too (#1058)\n *\n * A type is registered under {@link DocumentedType.keyOf}: its bare name when the HOME package (the\n * one whose file is being extracted) declares it, `<package>:<name>` otherwise. Two packages'\n * same-named types are therefore two entries rather than one silently standing in for the other, and\n * a renderer can tell which document owns each schema. The name is always the DECLARATION's own, never\n * an import alias, so one type reached under two spellings is still one entry.\n */\nexport class TypeResolver {\n private readonly unmapped: UnmappedType[] = [];\n /**\n * Declarations carrying stacked JSDoc, by location — keyed so a base field flattened into two\n * subclasses is ONE record, not two (#1286).\n */\n private readonly stacked = new Map<string, StackedJsDoc>();\n /** Every named type, its key and the declaration that claimed it — see {@link TypeRegistry}. */\n private readonly registry: TypeRegistry;\n /** Anonymous type literals currently being expanded — the cycle stop for the ANONYMOUS case. */\n private readonly expandingAnonymous = new Set<ts.TypeNode>();\n\n private readonly bases: ObjectShapeBases;\n /** Resolves every `{@link}` in the prose this resolver reads (#1284). */\n private readonly links: DocLinkReader;\n\n constructor(\n checker: ts.TypeChecker,\n packages: PackageOfFile,\n /** The package of the file being extracted — its types are keyed by their bare name. */\n homePackage: string | undefined,\n private readonly schemaNames: SchemaNames,\n ) {\n this.bases = new ObjectShapeBases(checker);\n this.registry = new TypeRegistry(packages, homePackage, schemaNames);\n this.links = new DocLinkReader(checker, this.registry, schemaNames);\n }\n\n /** Every named type reached so far, by key — see {@link DocumentedType.keyOf}. */\n collectedTypes(): ReadonlyMap<string, DocumentedType> {\n this.schemaNames.validate(this.registry.types.values());\n return this.registry.types;\n }\n\n /** Everything that could not be represented — recorded, never dropped. */\n collectedUnmapped(): readonly UnmappedType[] {\n return this.unmapped;\n }\n\n /** Every reached declaration with two or more JSDoc blocks, in the order they were met. */\n collectedStackedJsDoc(): readonly StackedJsDoc[] {\n return Array.from(this.stacked.values());\n }\n\n /**\n * Read `node`'s JSDoc AND record it when blocks are stacked on it (#1286). Every JSDoc read of a\n * declaration an extraction reaches goes through here — the contract and its methods too — so the\n * record cannot miss a declaration whose prose a document publishes.\n */\n readDoc(node: ts.Node): JsDoc {\n const stacked = JsDoc.stackedAt(node);\n if (stacked !== undefined && !this.stacked.has(stacked.location)) {\n this.stacked.set(stacked.location, stacked);\n }\n return JsDoc.read(node, this.links);\n }\n\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n collectedCollisions(): readonly TypeNameCollision[] {\n return this.registry.collisions;\n }\n\n /** The key `name`, declared at `node`, is registered under. */\n keyFor(name: string, node: ts.Node): string {\n return this.registry.keyFor(name, node);\n }\n\n /** Resolve one written type, registering whatever named types it reaches. */\n resolve(node: ts.TypeNode, ownerName: string): TypeRef {\n if (ts.isParenthesizedTypeNode(node)) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isArrayTypeNode(node)) {\n return TypeRef.array(this.resolve(node.elementType, ownerName));\n }\n // `readonly X[]` is a TypeOperator wrapping the array. `readonly` is a compile-time promise\n // about the HOLDER, not the wire: the JSON is the same array, so it resolves exactly like\n // `X[]` — as `ReadonlyArray<X>` already does in resolveReference (#1055).\n if (\n ts.isTypeOperatorNode(node) &&\n node.operator === ts.SyntaxKind.ReadonlyKeyword &&\n ts.isArrayTypeNode(node.type)\n ) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isUnionTypeNode(node)) {\n return this.resolveUnion(node, ownerName);\n }\n if (ts.isTypeLiteralNode(node)) {\n return this.resolveAnonymousObject(node, ownerName);\n }\n if (ts.isLiteralTypeNode(node)) {\n return this.resolveLiteral(node);\n }\n if (ts.isTypeReferenceNode(node)) {\n return this.resolveReference(node, ownerName);\n }\n const primitive = TypeResolver.keywordOf(node.kind);\n if (primitive !== undefined) {\n return TypeRef.primitiveOf(primitive);\n }\n return this.recordUnmapped(node, 'no model representation for this type form');\n }\n\n /** `string` / `number` / `boolean` / `null` / `unknown`, or undefined for anything else. */\n // webpieces-disable no-function-outside-class -- private static lookup table of this class\n private static keywordOf(kind: ts.SyntaxKind): PrimitiveKind | undefined {\n switch (kind) {\n case ts.SyntaxKind.StringKeyword:\n return 'string';\n case ts.SyntaxKind.NumberKeyword:\n return 'number';\n case ts.SyntaxKind.BooleanKeyword:\n return 'boolean';\n case ts.SyntaxKind.NullKeyword:\n return 'null';\n case ts.SyntaxKind.UnknownKeyword:\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.VoidKeyword:\n return 'unknown';\n default:\n return undefined;\n }\n }\n\n private resolveLiteral(node: ts.LiteralTypeNode): TypeRef {\n if (ts.isStringLiteral(node.literal)) {\n return TypeRef.enumOf([node.literal.text]);\n }\n if (node.literal.kind === ts.SyntaxKind.NullKeyword) {\n return TypeRef.primitiveOf('null');\n }\n if (\n node.literal.kind === ts.SyntaxKind.TrueKeyword ||\n node.literal.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return TypeRef.primitiveOf('boolean');\n }\n if (ts.isNumericLiteral(node.literal)) {\n return TypeRef.primitiveOf('number');\n }\n return this.recordUnmapped(\n node,\n 'literal type is neither a string, a number nor a boolean',\n );\n }\n\n /**\n * A union, after `null` / `undefined` have been dropped (the FIELD records those as nullable /\n * optional — see {@link fieldOf} — because `{}` and `{x: null}` are different wire documents).\n *\n * The outcomes, in this order:\n * - every branch a string literal -> an ENUM\n * - one branch left -> that branch\n * - every branch a string VALUE -> an ENUM of all of them: string literals, string-enum\n * (literal, enum member, or members (`VoiceMode.A | VoiceMode.B`) and whole string\n * whole string enum) enums, in declaration order (#1023)\n * - every branch a named object -> a UNION, with a DERIVED discriminator when every branch\n * carries the same property typed as string VALUES — one\n * literal / enum member, or a union of them — and no value\n * is claimed by two branches\n * - anything else -> an {@link UnmappedType}. No invented discriminator, ever:\n * a union TypeScript itself cannot narrow is not one a\n * renderer may claim to.\n */\n private resolveUnion(node: ts.UnionTypeNode, ownerName: string): TypeRef {\n const branches = node.types.filter((t: ts.TypeNode) => !TypeResolver.isNullish(t));\n\n const literals = branches.filter(\n (t: ts.TypeNode) => ts.isLiteralTypeNode(t) && ts.isStringLiteral(t.literal),\n );\n if (literals.length === branches.length && branches.length > 0) {\n return TypeRef.enumOf(\n literals.map(\n (t: ts.TypeNode) =>\n ((t as ts.LiteralTypeNode).literal as ts.StringLiteral).text,\n ),\n );\n }\n\n if (branches.length === 1) {\n return this.resolve(branches[0], ownerName);\n }\n if (branches.length === 0) {\n return TypeRef.primitiveOf('null');\n }\n\n const refs: TypeRef[] = branches.map((t: ts.TypeNode) => this.resolve(t, ownerName));\n const values = new StringValueSets(this.registry.types).valuesOfAll(refs);\n if (values !== undefined) {\n return TypeRef.enumOf(values);\n }\n if (!refs.every((r: TypeRef) => r.kind === 'ref')) {\n return this.recordUnmapped(\n node,\n 'a union whose branches are not all NAMED object types has no discriminator a renderer could narrow on',\n );\n }\n\n const names = refs.map((r: TypeRef) => r.refName!);\n const discriminator = new StringValueSets(this.registry.types).derive(names);\n if (discriminator === undefined) {\n return this.recordUnmapped(\n node,\n 'no property is typed as string values (a literal, a string-enum member, or a union of them) on EVERY ' +\n 'branch with no value shared by two branches, so this union has no derivable discriminator',\n );\n }\n this.registerUnionAlias(node, names, discriminator);\n return TypeRef.union(names);\n }\n\n /** `null` and `undefined` branches — recorded as nullable/optional on the FIELD, not in the union. */\n // webpieces-disable no-function-outside-class -- private static predicate of this class\n private static isNullish(node: ts.TypeNode): boolean {\n if (\n node.kind === ts.SyntaxKind.UndefinedKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword\n ) {\n return true;\n }\n return ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword;\n }\n\n /** A union written as a named `type X = A | B` becomes its own model entry, so #982 can `$ref` it. */\n private registerUnionAlias(\n node: ts.UnionTypeNode,\n branchNames: readonly string[],\n discriminator: UnionDiscriminator,\n ): void {\n const alias = node.parent;\n if (!ts.isTypeAliasDeclaration(alias)) {\n return;\n }\n const name = alias.name.text;\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return;\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n this.readDoc(alias).description,\n [],\n [],\n branchNames,\n discriminator,\n undefined,\n ),\n );\n }\n\n /**\n * `Integer`, `Array<T>`, `Record<string, V>`, `Promise<T>`, and everything named — an interface,\n * a class, or a type alias. Anything else (a `Map`, a `Date`, a generic parameter) is recorded\n * rather than guessed at.\n */\n private resolveReference(node: ts.TypeReferenceNode, ownerName: string): TypeRef {\n const name = ts.isIdentifier(node.typeName) ? node.typeName.text : node.typeName.right.text;\n const args = node.typeArguments ?? [];\n\n if (name === INTEGER_ALIAS) {\n return TypeRef.primitiveOf('number', /*integer*/ true);\n }\n if ((name === 'Array' || name === 'ReadonlyArray') && args.length === 1) {\n return TypeRef.array(this.resolve(args[0], ownerName));\n }\n if ((name === 'Record' || name === 'Partial') && args.length === 2) {\n return TypeRef.openMap(this.resolve(args[1], ownerName));\n }\n if (name === 'Promise' && args.length === 1) {\n return this.resolve(args[0], ownerName);\n }\n\n // `VoiceMode.RANDOM` is a QualifiedName; the member's symbol is the one on its RIGHT side.\n const declaration = this.declarationOf(\n ts.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName,\n );\n if (declaration === undefined) {\n return this.recordUnmapped(node, `no declaration found for '${name}'`);\n }\n return this.resolveDeclaration(\n TypeResolver.declaredName(declaration, name),\n declaration,\n ownerName,\n );\n }\n\n /**\n * The DECLARATION's own name, not the spelling at the use site: `import { Foo as Bar }` still\n * reaches the type `Foo`, which is what its owning package's document calls it (#1058).\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static declaredName(declaration: ts.Declaration, written: string): string {\n const named =\n ts.isInterfaceDeclaration(declaration) ||\n ts.isClassDeclaration(declaration) ||\n ts.isTypeAliasDeclaration(declaration) ||\n ts.isEnumDeclaration(declaration);\n return named && declaration.name !== undefined ? declaration.name.text : written;\n }\n\n /**\n * Resolve a type by its DECLARATION rather than by a reference to it.\n *\n * The reference path above is the normal one — a field says `Customer` and the resolver follows\n * it. This entry point exists for a type that is named from OUTSIDE the source: a manifest naming\n * the document-wide error body, which no field in the contract points at. Same registration, same\n * cycle story, so the two cannot disagree about what a type IS.\n */\n resolveDeclaration(name: string, declaration: ts.Declaration, ownerName: string): TypeRef {\n if (ts.isInterfaceDeclaration(declaration) || ts.isClassDeclaration(declaration)) {\n return this.registerNamedObject(name, declaration);\n }\n if (ts.isTypeAliasDeclaration(declaration)) {\n return this.resolveAlias(name, declaration, ownerName);\n }\n if (ts.isEnumDeclaration(declaration)) {\n return this.registerStringEnum(name, declaration);\n }\n if (ts.isEnumMember(declaration)) {\n return this.resolveEnumMember(name, declaration);\n }\n return this.recordUnmapped(\n declaration,\n `'${name}' is declared as something with no document shape`,\n );\n }\n\n /** `type X = ...` — registered under X when it has a shape of its own, else transparent. */\n private resolveAlias(name: string, alias: ts.TypeAliasDeclaration, ownerName: string): TypeRef {\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return this.registry.types.get(key)?.unionRefNames.length\n ? TypeRef.union(this.registry.types.get(key)!.unionRefNames)\n : TypeRef.ref(key);\n }\n\n if (ts.isUnionTypeNode(alias.type)) {\n const resolved = this.resolve(alias.type, ownerName);\n if (resolved.kind === 'enum') {\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n this.readDoc(alias).description,\n [],\n resolved.enumValues,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n return resolved;\n }\n\n if (ts.isTypeLiteralNode(alias.type)) {\n return this.registerNamedObject(name, alias.type, alias);\n }\n return this.resolve(alias.type, ownerName);\n }\n\n /**\n * ONE member of a string enum used as a type — `mode: VoiceMode.RANDOM` — which holds exactly\n * that member's VALUE on the wire. It is what a union branch's discriminator is written as once\n * the enum is the one spelling of a fixed set (#1023), so it resolves to a one-value enum exactly\n * like `mode: 'random'` does.\n */\n private resolveEnumMember(name: string, member: ts.EnumMember): TypeRef {\n if (member.initializer !== undefined && ts.isStringLiteral(member.initializer)) {\n return TypeRef.enumOf([member.initializer.text]);\n }\n return this.recordUnmapped(\n member,\n `enum member '${name}' is not initialised with a string literal, so it has no string value to publish`,\n );\n }\n\n /** A TS `enum` of string members — the one non-union enum shape a document can carry. */\n private registerStringEnum(name: string, declaration: ts.EnumDeclaration): TypeRef {\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.alreadyRegistered(key, name, declaration)) {\n return TypeRef.ref(key);\n }\n const values: string[] = [];\n for (const member of declaration.members) {\n if (member.initializer && ts.isStringLiteral(member.initializer)) {\n values.push(member.initializer.text);\n }\n }\n if (values.length !== declaration.members.length) {\n return this.recordUnmapped(\n declaration,\n `enum '${name}' has members that are not string literals`,\n );\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n this.readDoc(declaration).description,\n [],\n values,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Register a named object shape, RESERVING THE NAME BEFORE walking its fields. That order is the\n * whole cycle story: a type that refers back to itself meets `registered.has(name)` on the second\n * visit and resolves to a `$ref`, so the walk terminates with no counter and no truncation.\n *\n * The fields are the shape's WHOLE document — every field it inherits through `extends` as well\n * as its own. See {@link collectFields}.\n */\n private registerNamedObject(name: string, shape: ObjectShape, docSource?: ts.Node): TypeRef {\n const declaration = docSource ?? shape;\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.registered.has(key)) {\n // An ANONYMOUS `{ ... }` is named after where it is written, so two of them can share an\n // owner-derived name; that was never a declared-name collision and is not recorded as one.\n if (!ts.isTypeLiteralNode(declaration)) {\n this.registry.alreadyRegistered(key, name, declaration);\n }\n return TypeRef.ref(key);\n }\n this.registry.claimedBy.set(key, declaration);\n this.registry.registered.add(key);\n\n const fields = new Map<string, DocumentedField>();\n const indexSignature = this.collectFields(shape, name, fields, new Set<ObjectShape>());\n\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n this.readDoc(declaration).description,\n Array.from(fields.values()),\n [],\n [],\n undefined,\n indexSignature,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Collect `shape`'s fields into `fields`, FLATTENING every base it `extends` (#1055).\n *\n * A subclass's JSON carries its base's fields, so a document that published only the subclass's\n * own members was a CLOSED schema (`additionalProperties: false`) that refused every real call.\n * The rules are TypeScript's own:\n *\n * - bases first, in `extends` order (`interface X extends A, B`), each walked recursively, so a\n * two-level chain flattens completely;\n * - a redeclared field WINS — `Map.set` replaces the inherited entry in its original position —\n * and it is the redeclaration's type, optionality, prose and bounds that publish, because\n * required/optional belongs to whichever type DECLARES the field;\n * - a base may live in another file or package (source or a published `.d.ts`); its JSDoc is\n * read from there.\n *\n * Flattened, not `allOf: [{$ref: Base}, {...}]`: an MCP client reads `properties` + `required`\n * directly, and a base is an implementation detail of the TypeScript, not a wire concept. So a\n * base is NOT registered as a model entry of its own; it appears only if something refers to it.\n *\n * Which bases count, and why an unresolvable one is a build failure, is {@link ObjectShapeBases}.\n */\n private collectFields(\n shape: ObjectShape,\n ownerName: string,\n fields: Map<string, DocumentedField>,\n visiting: Set<ObjectShape>,\n ): TypeRef | undefined {\n visiting.add(shape);\n let indexSignature: TypeRef | undefined;\n for (const baseShape of this.bases.of(shape)) {\n if (visiting.has(baseShape)) {\n continue;\n }\n indexSignature =\n this.collectFields(baseShape, ownerName, fields, visiting) ?? indexSignature;\n }\n for (const member of shape.members) {\n if (ts.isIndexSignatureDeclaration(member)) {\n indexSignature = this.resolve(member.type, ownerName);\n continue;\n }\n const field = this.fieldOf(member, ownerName);\n if (field !== undefined) {\n fields.set(field.name, field);\n }\n }\n visiting.delete(shape);\n return indexSignature;\n }\n\n /**\n * An inline `{ ... }`. It has no name to `$ref`, so it is registered under an OWNER-DERIVED one\n * (`Parent.field`) — a renderer needs a target, and a name derived from where the shape is\n * written is the only honest one available.\n *\n * A self-referential anonymous type is cut HERE, by NODE IDENTITY. It cannot be a `$ref` (there\n * is no declared name to point at) and it cannot be expanded (it would never end), so it is\n * recorded as unmapped and the walk returns.\n */\n private resolveAnonymousObject(node: ts.TypeLiteralNode, ownerName: string): TypeRef {\n if (this.expandingAnonymous.has(node)) {\n return this.recordUnmapped(\n node,\n 'a self-referential ANONYMOUS object type has no name a renderer could $ref; give it a name',\n );\n }\n const indexOnly =\n node.members.length === 1 && ts.isIndexSignatureDeclaration(node.members[0]);\n if (indexOnly) {\n const signature = node.members[0] as ts.IndexSignatureDeclaration;\n return TypeRef.openMap(this.resolve(signature.type, ownerName));\n }\n\n this.expandingAnonymous.add(node);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- the stack entry must be dropped whatever the walk does\n try {\n return this.registerNamedObject(ownerName, node);\n } finally {\n this.expandingAnonymous.delete(node);\n }\n }\n\n /** ONE property of a DTO — its type, its optionality, its prose and its numeric constraints. */\n private fieldOf(\n member: ts.TypeElement | ts.ClassElement,\n ownerName: string,\n ): DocumentedField | undefined {\n if (!ts.isPropertySignature(member) && !ts.isPropertyDeclaration(member)) {\n return undefined;\n }\n if (!ts.isIdentifier(member.name) && !ts.isStringLiteral(member.name)) {\n return undefined;\n }\n const name = member.name.text;\n if (member.type === undefined) {\n return undefined;\n }\n\n const optional =\n member.questionToken !== undefined || FieldDecorators.declaresUndefined(member.type);\n const nullable = FieldDecorators.declaresNull(member.type);\n\n let type = this.resolve(member.type, `${ownerName}.${name}`);\n if (FieldDecorators.hasDecorator(member, INT_DECORATOR)) {\n type = FieldDecorators.markInteger(type);\n }\n\n const doc = this.readDoc(member);\n const min = FieldDecorators.numericArgument(member, MIN_DECORATOR);\n const max = FieldDecorators.numericArgument(member, MAX_DECORATOR);\n FieldDecorators.assertNumericConstraintsFit(member, name, type, min, max);\n\n return new DocumentedField(\n name,\n type,\n optional,\n nullable,\n doc.description,\n doc.mcp,\n doc.format,\n min,\n max,\n doc.mcpHeader,\n SourceLocation.of(member),\n );\n }\n\n /** The declaration a type name points at, through imports and aliases. */\n private declarationOf(name: ts.EntityName): ts.Declaration | undefined {\n return this.bases.declarationOf(name);\n }\n\n private recordUnmapped(node: ts.Node, reason: string): TypeRef {\n const text = node.getText();\n this.unmapped.push(new UnmappedType(text, SourceLocation.of(node), reason));\n return TypeRef.unmapped(text);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeResolver.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/TypeResolver.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,oDAA2D;AAC3D,sDAO8B;AAC9B,8CAA0D;AAE1D,mDAAgD;AAChD,mCAAgC;AAChC,yDAAmE;AACnE,uDAAoD;AAEpD,iDAA8C;AAC9C,qDAAkD;AAClD,uDAAoD;AAEpD;;;;GAIG;AACH,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IAqBA;IApBJ,QAAQ,GAAmB,EAAE,CAAC;IAC/C;;;OAGG;IACc,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3D,gGAAgG;IAC/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,IAAI,EAAE,+BAAc,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5E,OAAO,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAxlBD,oCAwlBC","sourcesContent":["import { SchemaNames } from '../model/SchemaNames';\nimport * as ts from 'typescript';\nimport { WpInt, WpMax, WpMin } from '@webpieces/core-util';\nimport {\n DocumentedField,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from '../model/ApiDocModel';\nimport { PrimitiveKind, TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { DocLinkReader } from './DocLinkReader';\nimport { JsDoc } from './JsDoc';\nimport { ObjectShape, ObjectShapeBases } from './ObjectShapeBases';\nimport { FieldDecorators } from './FieldDecorators';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeRegistry } from './TypeRegistry';\nimport { SourceLocation } from './SourceLocation';\nimport { StringValueSets } from './StringValueSets';\n\n/**\n * The decorators this resolver reads off a DTO property, named from the REAL SYMBOLS — a rename in\n * `core-util` is a compile error here rather than a literal that quietly stops matching. See\n * {@link ApiDocExtractor}'s constants for the full argument (issue #1001).\n */\nconst INT_DECORATOR = WpInt.name;\nconst MIN_DECORATOR = WpMin.name;\nconst MAX_DECORATOR = WpMax.name;\n\n/**\n * The type-alias name that DECLARES integer-ness.\n *\n * This one is a LITERAL and cannot be anything else: `Integer` is a TYPE ALIAS, so there is no\n * runtime symbol whose `.name` could be read — `.name` is a property of a function, and a type has\n * erased by then. It is the one name in this package that a rename in `core-util` would not break at\n * compile time; the cure if that ever bites is to make integer-ness a decorator here too, not to\n * pretend a type has a runtime identity. See {@link ApiDocExtractor}'s constants for the argument\n * everywhere else (issue #1001).\n */\nconst INTEGER_ALIAS = 'Integer';\n\n/**\n * Resolve declared TypeScript types into {@link TypeRef}s, registering every NAMED type it meets as\n * a {@link DocumentedType} a renderer can `$ref`.\n *\n * ## It walks TYPE NODES, not checker types, and that is load-bearing\n *\n * `type Integer = number` resolves, in the checker, to `number` — the alias is gone. Integer-ness is\n * therefore invisible to a checker-driven walk, and the whole reason `Integer` is the PREFERRED\n * spelling is that it COMPOSES: `Integer[]` and `Record<string, Integer>` say exactly which thing is\n * an integer, where a decorator on `counts?: number[]` cannot (the same ambiguity the deleted\n * `arrayItems` argument had). Walking the written syntax is what keeps that composition readable.\n *\n * ## Cycles terminate BY CONSTRUCTION\n *\n * Every named type is ONE entry in the model, registered before its fields are walked, so a type\n * that refers back to itself resolves to a `$ref` at the second visit and stops. There is NO depth\n * counter anywhere — a deep-but-finite graph of 7, 20 or 200 named hops is fully expanded, because\n * truncating one would silently publish an incomplete document. The ONLY thing that is cut is a\n * self-referential ANONYMOUS type, and it is cut by NODE IDENTITY (it has no name to `$ref`), with an\n * {@link UnmappedType} recorded so #982's guard has something to name.\n *\n * ## Every type is keyed by its DECLARING PACKAGE too (#1058)\n *\n * A type is registered under {@link DocumentedType.keyOf}: its bare name when the HOME package (the\n * one whose file is being extracted) declares it, `<package>:<name>` otherwise. Two packages'\n * same-named types are therefore two entries rather than one silently standing in for the other, and\n * a renderer can tell which document owns each schema. The name is always the DECLARATION's own, never\n * an import alias, so one type reached under two spellings is still one entry.\n */\nexport class TypeResolver {\n private readonly unmapped: UnmappedType[] = [];\n /**\n * Declarations carrying stacked JSDoc, by location — keyed so a base field flattened into two\n * subclasses is ONE record, not two (#1286).\n */\n private readonly stacked = new Map<string, StackedJsDoc>();\n /** Every named type, its key and the declaration that claimed it — see {@link TypeRegistry}. */\n private readonly registry: TypeRegistry;\n /** Anonymous type literals currently being expanded — the cycle stop for the ANONYMOUS case. */\n private readonly expandingAnonymous = new Set<ts.TypeNode>();\n\n private readonly bases: ObjectShapeBases;\n /** Resolves every `{@link}` in the prose this resolver reads (#1284). */\n private readonly links: DocLinkReader;\n\n constructor(\n checker: ts.TypeChecker,\n packages: PackageOfFile,\n /** The package of the file being extracted — its types are keyed by their bare name. */\n homePackage: string | undefined,\n private readonly schemaNames: SchemaNames,\n ) {\n this.bases = new ObjectShapeBases(checker);\n this.registry = new TypeRegistry(packages, homePackage, schemaNames);\n this.links = new DocLinkReader(checker, this.registry, schemaNames);\n }\n\n /** Every named type reached so far, by key — see {@link DocumentedType.keyOf}. */\n collectedTypes(): ReadonlyMap<string, DocumentedType> {\n this.schemaNames.validate(this.registry.types.values());\n return this.registry.types;\n }\n\n /** Everything that could not be represented — recorded, never dropped. */\n collectedUnmapped(): readonly UnmappedType[] {\n return this.unmapped;\n }\n\n /** Every reached declaration with two or more JSDoc blocks, in the order they were met. */\n collectedStackedJsDoc(): readonly StackedJsDoc[] {\n return Array.from(this.stacked.values());\n }\n\n /**\n * Read `node`'s JSDoc AND record it when blocks are stacked on it (#1286). Every JSDoc read of a\n * declaration an extraction reaches goes through here — the contract and its methods too — so the\n * record cannot miss a declaration whose prose a document publishes.\n */\n readDoc(node: ts.Node): JsDoc {\n const stacked = JsDoc.stackedAt(node);\n if (stacked !== undefined && !this.stacked.has(stacked.location)) {\n this.stacked.set(stacked.location, stacked);\n }\n return JsDoc.read(node, this.links);\n }\n\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n collectedCollisions(): readonly TypeNameCollision[] {\n return this.registry.collisions;\n }\n\n /** The key `name`, declared at `node`, is registered under. */\n keyFor(name: string, node: ts.Node): string {\n return this.registry.keyFor(name, node);\n }\n\n /** Resolve one written type, registering whatever named types it reaches. */\n resolve(node: ts.TypeNode, ownerName: string): TypeRef {\n if (ts.isParenthesizedTypeNode(node)) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isArrayTypeNode(node)) {\n return TypeRef.array(this.resolve(node.elementType, ownerName));\n }\n // `readonly X[]` is a TypeOperator wrapping the array. `readonly` is a compile-time promise\n // about the HOLDER, not the wire: the JSON is the same array, so it resolves exactly like\n // `X[]` — as `ReadonlyArray<X>` already does in resolveReference (#1055).\n if (\n ts.isTypeOperatorNode(node) &&\n node.operator === ts.SyntaxKind.ReadonlyKeyword &&\n ts.isArrayTypeNode(node.type)\n ) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isUnionTypeNode(node)) {\n return this.resolveUnion(node, ownerName);\n }\n if (ts.isTypeLiteralNode(node)) {\n return this.resolveAnonymousObject(node, ownerName);\n }\n if (ts.isLiteralTypeNode(node)) {\n return this.resolveLiteral(node);\n }\n if (ts.isTypeReferenceNode(node)) {\n return this.resolveReference(node, ownerName);\n }\n const primitive = TypeResolver.keywordOf(node.kind);\n if (primitive !== undefined) {\n return TypeRef.primitiveOf(primitive);\n }\n return this.recordUnmapped(node, 'no model representation for this type form');\n }\n\n /** `string` / `number` / `boolean` / `null` / `unknown`, or undefined for anything else. */\n // webpieces-disable no-function-outside-class -- private static lookup table of this class\n private static keywordOf(kind: ts.SyntaxKind): PrimitiveKind | undefined {\n switch (kind) {\n case ts.SyntaxKind.StringKeyword:\n return 'string';\n case ts.SyntaxKind.NumberKeyword:\n return 'number';\n case ts.SyntaxKind.BooleanKeyword:\n return 'boolean';\n case ts.SyntaxKind.NullKeyword:\n return 'null';\n case ts.SyntaxKind.UnknownKeyword:\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.VoidKeyword:\n return 'unknown';\n default:\n return undefined;\n }\n }\n\n private resolveLiteral(node: ts.LiteralTypeNode): TypeRef {\n if (ts.isStringLiteral(node.literal)) {\n return TypeRef.enumOf([node.literal.text]);\n }\n if (node.literal.kind === ts.SyntaxKind.NullKeyword) {\n return TypeRef.primitiveOf('null');\n }\n if (\n node.literal.kind === ts.SyntaxKind.TrueKeyword ||\n node.literal.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return TypeRef.primitiveOf('boolean');\n }\n if (ts.isNumericLiteral(node.literal)) {\n return TypeRef.primitiveOf('number');\n }\n return this.recordUnmapped(\n node,\n 'literal type is neither a string, a number nor a boolean',\n );\n }\n\n /**\n * A union, after `null` / `undefined` have been dropped (the FIELD records those as nullable /\n * optional — see {@link fieldOf} — because `{}` and `{x: null}` are different wire documents).\n *\n * The outcomes, in this order:\n * - every branch a string literal -> an ENUM\n * - one branch left -> that branch\n * - every branch a string VALUE -> an ENUM of all of them: string literals, string-enum\n * (literal, enum member, or members (`VoiceMode.A | VoiceMode.B`) and whole string\n * whole string enum) enums, in declaration order (#1023)\n * - every branch a named object -> a UNION, with a DERIVED discriminator when every branch\n * carries the same property typed as string VALUES — one\n * literal / enum member, or a union of them — and no value\n * is claimed by two branches\n * - anything else -> an {@link UnmappedType}. No invented discriminator, ever:\n * a union TypeScript itself cannot narrow is not one a\n * renderer may claim to.\n */\n private resolveUnion(node: ts.UnionTypeNode, ownerName: string): TypeRef {\n const branches = node.types.filter((t: ts.TypeNode) => !TypeResolver.isNullish(t));\n\n const literals = branches.filter(\n (t: ts.TypeNode) => ts.isLiteralTypeNode(t) && ts.isStringLiteral(t.literal),\n );\n if (literals.length === branches.length && branches.length > 0) {\n return TypeRef.enumOf(\n literals.map(\n (t: ts.TypeNode) =>\n ((t as ts.LiteralTypeNode).literal as ts.StringLiteral).text,\n ),\n );\n }\n\n if (branches.length === 1) {\n return this.resolve(branches[0], ownerName);\n }\n if (branches.length === 0) {\n return TypeRef.primitiveOf('null');\n }\n\n const refs: TypeRef[] = branches.map((t: ts.TypeNode) => this.resolve(t, ownerName));\n const values = new StringValueSets(this.registry.types).valuesOfAll(refs);\n if (values !== undefined) {\n return TypeRef.enumOf(values);\n }\n if (!refs.every((r: TypeRef) => r.kind === 'ref')) {\n return this.recordUnmapped(\n node,\n 'a union whose branches are not all NAMED object types has no discriminator a renderer could narrow on',\n );\n }\n\n const names = refs.map((r: TypeRef) => r.refName!);\n const discriminator = new StringValueSets(this.registry.types).derive(names);\n if (discriminator === undefined) {\n return this.recordUnmapped(\n node,\n 'no property is typed as string values (a literal, a string-enum member, or a union of them) on EVERY ' +\n 'branch with no value shared by two branches, so this union has no derivable discriminator',\n );\n }\n this.registerUnionAlias(node, names, discriminator);\n return TypeRef.union(names);\n }\n\n /** `null` and `undefined` branches — recorded as nullable/optional on the FIELD, not in the union. */\n // webpieces-disable no-function-outside-class -- private static predicate of this class\n private static isNullish(node: ts.TypeNode): boolean {\n if (\n node.kind === ts.SyntaxKind.UndefinedKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword\n ) {\n return true;\n }\n return ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword;\n }\n\n /** A union written as a named `type X = A | B` becomes its own model entry, so #982 can `$ref` it. */\n private registerUnionAlias(\n node: ts.UnionTypeNode,\n branchNames: readonly string[],\n discriminator: UnionDiscriminator,\n ): void {\n const alias = node.parent;\n if (!ts.isTypeAliasDeclaration(alias)) {\n return;\n }\n const name = alias.name.text;\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return;\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n this.readDoc(alias).description,\n [],\n [],\n branchNames,\n discriminator,\n undefined,\n ),\n );\n }\n\n /**\n * `Integer`, `Array<T>`, `Record<string, V>`, `Promise<T>`, and everything named — an interface,\n * a class, or a type alias. Anything else (a `Map`, a `Date`, a generic parameter) is recorded\n * rather than guessed at.\n */\n private resolveReference(node: ts.TypeReferenceNode, ownerName: string): TypeRef {\n const name = ts.isIdentifier(node.typeName) ? node.typeName.text : node.typeName.right.text;\n const args = node.typeArguments ?? [];\n\n if (name === INTEGER_ALIAS) {\n return TypeRef.primitiveOf('number', /*integer*/ true);\n }\n if ((name === 'Array' || name === 'ReadonlyArray') && args.length === 1) {\n return TypeRef.array(this.resolve(args[0], ownerName));\n }\n if ((name === 'Record' || name === 'Partial') && args.length === 2) {\n return TypeRef.openMap(this.resolve(args[1], ownerName));\n }\n if (name === 'Promise' && args.length === 1) {\n return this.resolve(args[0], ownerName);\n }\n\n // `VoiceMode.RANDOM` is a QualifiedName; the member's symbol is the one on its RIGHT side.\n const declaration = this.declarationOf(\n ts.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName,\n );\n if (declaration === undefined) {\n return this.recordUnmapped(node, `no declaration found for '${name}'`);\n }\n return this.resolveDeclaration(\n TypeResolver.declaredName(declaration, name),\n declaration,\n ownerName,\n );\n }\n\n /**\n * The DECLARATION's own name, not the spelling at the use site: `import { Foo as Bar }` still\n * reaches the type `Foo`, which is what its owning package's document calls it (#1058).\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static declaredName(declaration: ts.Declaration, written: string): string {\n const named =\n ts.isInterfaceDeclaration(declaration) ||\n ts.isClassDeclaration(declaration) ||\n ts.isTypeAliasDeclaration(declaration) ||\n ts.isEnumDeclaration(declaration);\n return named && declaration.name !== undefined ? declaration.name.text : written;\n }\n\n /**\n * Resolve a type by its DECLARATION rather than by a reference to it.\n *\n * The reference path above is the normal one — a field says `Customer` and the resolver follows\n * it. This entry point exists for a type that is named from OUTSIDE the source: a manifest naming\n * the document-wide error body, which no field in the contract points at. Same registration, same\n * cycle story, so the two cannot disagree about what a type IS.\n */\n resolveDeclaration(name: string, declaration: ts.Declaration, ownerName: string): TypeRef {\n if (ts.isInterfaceDeclaration(declaration) || ts.isClassDeclaration(declaration)) {\n return this.registerNamedObject(name, declaration);\n }\n if (ts.isTypeAliasDeclaration(declaration)) {\n return this.resolveAlias(name, declaration, ownerName);\n }\n if (ts.isEnumDeclaration(declaration)) {\n return this.registerStringEnum(name, declaration);\n }\n if (ts.isEnumMember(declaration)) {\n return this.resolveEnumMember(name, declaration);\n }\n return this.recordUnmapped(\n declaration,\n `'${name}' is declared as something with no document shape`,\n );\n }\n\n /** `type X = ...` — registered under X when it has a shape of its own, else transparent. */\n private resolveAlias(name: string, alias: ts.TypeAliasDeclaration, ownerName: string): TypeRef {\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return this.registry.types.get(key)?.unionRefNames.length\n ? TypeRef.union(this.registry.types.get(key)!.unionRefNames)\n : TypeRef.ref(key);\n }\n\n if (ts.isUnionTypeNode(alias.type)) {\n const resolved = this.resolve(alias.type, ownerName);\n if (resolved.kind === 'enum') {\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n this.readDoc(alias).description,\n [],\n resolved.enumValues,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n return resolved;\n }\n\n if (ts.isTypeLiteralNode(alias.type)) {\n return this.registerNamedObject(name, alias.type, alias);\n }\n return this.resolve(alias.type, ownerName);\n }\n\n /**\n * ONE member of a string enum used as a type — `mode: VoiceMode.RANDOM` — which holds exactly\n * that member's VALUE on the wire. It is what a union branch's discriminator is written as once\n * the enum is the one spelling of a fixed set (#1023), so it resolves to a one-value enum exactly\n * like `mode: 'random'` does.\n */\n private resolveEnumMember(name: string, member: ts.EnumMember): TypeRef {\n if (member.initializer !== undefined && ts.isStringLiteral(member.initializer)) {\n return TypeRef.enumOf([member.initializer.text]);\n }\n return this.recordUnmapped(\n member,\n `enum member '${name}' is not initialised with a string literal, so it has no string value to publish`,\n );\n }\n\n /** A TS `enum` of string members — the one non-union enum shape a document can carry. */\n private registerStringEnum(name: string, declaration: ts.EnumDeclaration): TypeRef {\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.alreadyRegistered(key, name, declaration)) {\n return TypeRef.ref(key);\n }\n const values: string[] = [];\n for (const member of declaration.members) {\n if (member.initializer && ts.isStringLiteral(member.initializer)) {\n values.push(member.initializer.text);\n }\n }\n if (values.length !== declaration.members.length) {\n return this.recordUnmapped(\n declaration,\n `enum '${name}' has members that are not string literals`,\n );\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n this.readDoc(declaration).description,\n [],\n values,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Register a named object shape, RESERVING THE NAME BEFORE walking its fields. That order is the\n * whole cycle story: a type that refers back to itself meets `registered.has(name)` on the second\n * visit and resolves to a `$ref`, so the walk terminates with no counter and no truncation.\n *\n * The fields are the shape's WHOLE document — every field it inherits through `extends` as well\n * as its own. See {@link collectFields}.\n */\n private registerNamedObject(name: string, shape: ObjectShape, docSource?: ts.Node): TypeRef {\n const declaration = docSource ?? shape;\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.registered.has(key)) {\n // An ANONYMOUS `{ ... }` is named after where it is written, so two of them can share an\n // owner-derived name; that was never a declared-name collision and is not recorded as one.\n if (!ts.isTypeLiteralNode(declaration)) {\n this.registry.alreadyRegistered(key, name, declaration);\n }\n return TypeRef.ref(key);\n }\n this.registry.claimedBy.set(key, declaration);\n this.registry.registered.add(key);\n\n const fields = new Map<string, DocumentedField>();\n const indexSignature = this.collectFields(shape, name, fields, new Set<ObjectShape>());\n\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n this.readDoc(declaration).description,\n Array.from(fields.values()),\n [],\n [],\n undefined,\n indexSignature,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Collect `shape`'s fields into `fields`, FLATTENING every base it `extends` (#1055).\n *\n * A subclass's JSON carries its base's fields, so a document that published only the subclass's\n * own members was a CLOSED schema (`additionalProperties: false`) that refused every real call.\n * The rules are TypeScript's own:\n *\n * - bases first, in `extends` order (`interface X extends A, B`), each walked recursively, so a\n * two-level chain flattens completely;\n * - a redeclared field WINS — `Map.set` replaces the inherited entry in its original position —\n * and it is the redeclaration's type, optionality, prose and bounds that publish, because\n * required/optional belongs to whichever type DECLARES the field;\n * - a base may live in another file or package (source or a published `.d.ts`); its JSDoc is\n * read from there.\n *\n * Flattened, not `allOf: [{$ref: Base}, {...}]`: an MCP client reads `properties` + `required`\n * directly, and a base is an implementation detail of the TypeScript, not a wire concept. So a\n * base is NOT registered as a model entry of its own; it appears only if something refers to it.\n *\n * Which bases count, and why an unresolvable one is a build failure, is {@link ObjectShapeBases}.\n */\n private collectFields(\n shape: ObjectShape,\n ownerName: string,\n fields: Map<string, DocumentedField>,\n visiting: Set<ObjectShape>,\n ): TypeRef | undefined {\n visiting.add(shape);\n let indexSignature: TypeRef | undefined;\n for (const baseShape of this.bases.of(shape)) {\n if (visiting.has(baseShape)) {\n continue;\n }\n indexSignature =\n this.collectFields(baseShape, ownerName, fields, visiting) ?? indexSignature;\n }\n for (const member of shape.members) {\n if (ts.isIndexSignatureDeclaration(member)) {\n indexSignature = this.resolve(member.type, ownerName);\n continue;\n }\n const field = this.fieldOf(member, ownerName);\n if (field !== undefined) {\n fields.set(field.name, field);\n }\n }\n visiting.delete(shape);\n return indexSignature;\n }\n\n /**\n * An inline `{ ... }`. It has no name to `$ref`, so it is registered under an OWNER-DERIVED one\n * (`Parent.field`) — a renderer needs a target, and a name derived from where the shape is\n * written is the only honest one available.\n *\n * A self-referential anonymous type is cut HERE, by NODE IDENTITY. It cannot be a `$ref` (there\n * is no declared name to point at) and it cannot be expanded (it would never end), so it is\n * recorded as unmapped and the walk returns.\n */\n private resolveAnonymousObject(node: ts.TypeLiteralNode, ownerName: string): TypeRef {\n if (this.expandingAnonymous.has(node)) {\n return this.recordUnmapped(\n node,\n 'a self-referential ANONYMOUS object type has no name a renderer could $ref; give it a name',\n );\n }\n const indexOnly =\n node.members.length === 1 && ts.isIndexSignatureDeclaration(node.members[0]);\n if (indexOnly) {\n const signature = node.members[0] as ts.IndexSignatureDeclaration;\n return TypeRef.openMap(this.resolve(signature.type, ownerName));\n }\n\n this.expandingAnonymous.add(node);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- the stack entry must be dropped whatever the walk does\n try {\n return this.registerNamedObject(ownerName, node);\n } finally {\n this.expandingAnonymous.delete(node);\n }\n }\n\n /** ONE property of a DTO — its type, its optionality, its prose and its numeric constraints. */\n private fieldOf(\n member: ts.TypeElement | ts.ClassElement,\n ownerName: string,\n ): DocumentedField | undefined {\n if (!ts.isPropertySignature(member) && !ts.isPropertyDeclaration(member)) {\n return undefined;\n }\n if (!ts.isIdentifier(member.name) && !ts.isStringLiteral(member.name)) {\n return undefined;\n }\n const name = member.name.text;\n if (member.type === undefined) {\n return undefined;\n }\n\n const optional =\n member.questionToken !== undefined || FieldDecorators.declaresUndefined(member.type);\n const nullable = FieldDecorators.declaresNull(member.type);\n\n let type = this.resolve(member.type, `${ownerName}.${name}`);\n if (FieldDecorators.hasDecorator(member, INT_DECORATOR)) {\n type = FieldDecorators.markInteger(type);\n }\n\n const doc = this.readDoc(member);\n const min = FieldDecorators.numericArgument(member, MIN_DECORATOR);\n const max = FieldDecorators.numericArgument(member, MAX_DECORATOR);\n FieldDecorators.assertNumericConstraintsFit(member, name, type, min, max);\n\n return new DocumentedField(\n name,\n type,\n optional,\n nullable,\n doc.description,\n doc.mcp,\n doc.format,\n min,\n max,\n doc.mcpHeader,\n SourceLocation.of(member),\n doc.hidden,\n doc.hiddenReason,\n );\n }\n\n /** The declaration a type name points at, through imports and aliases. */\n private declarationOf(name: ts.EntityName): ts.Declaration | undefined {\n return this.bases.declarationOf(name);\n }\n\n private recordUnmapped(node: ts.Node, reason: string): TypeRef {\n const text = node.getText();\n this.unmapped.push(new UnmappedType(text, SourceLocation.of(node), reason));\n return TypeRef.unmapped(text);\n }\n}\n"]}
|
|
@@ -121,6 +121,22 @@ export declare class DocumentedField {
|
|
|
121
121
|
* syntax node, and a second reader deriving it would be a second answer to "where is this".
|
|
122
122
|
*/
|
|
123
123
|
readonly location: string;
|
|
124
|
+
/**
|
|
125
|
+
* The `@hidden` JSDoc tag (#1246) — this field is withheld from the CUSTOMER document
|
|
126
|
+
* (`public-openapi.json` and its bundled sibling). The field-level twin of
|
|
127
|
+
* {@link DocumentedEndpoint.hidden}, and audienced exactly like it: it stays in the private
|
|
128
|
+
* document, and in the MCP document and tool catalogs, which keep hidden methods too.
|
|
129
|
+
*
|
|
130
|
+
* A documentation decision, never an access-control one: the server still accepts and returns
|
|
131
|
+
* the field. It is for a field that was NEVER published — hiding one a partner already reads
|
|
132
|
+
* is a removal from their point of view.
|
|
133
|
+
*/
|
|
134
|
+
readonly hidden: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* The `@hidden` tag's text — WHY it is withheld (`not announced yet; ships with …`).
|
|
137
|
+
* Undefined when the tag has no text. Never published anywhere: it is the author's note.
|
|
138
|
+
*/
|
|
139
|
+
readonly hiddenReason: string | undefined;
|
|
124
140
|
constructor(name: string, type: TypeRef,
|
|
125
141
|
/**
|
|
126
142
|
* OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from
|
|
@@ -163,7 +179,23 @@ export declare class DocumentedField {
|
|
|
163
179
|
* carried on the FIELD rather than recomputed because only the extractor still has the
|
|
164
180
|
* syntax node, and a second reader deriving it would be a second answer to "where is this".
|
|
165
181
|
*/
|
|
166
|
-
location: string
|
|
182
|
+
location: string,
|
|
183
|
+
/**
|
|
184
|
+
* The `@hidden` JSDoc tag (#1246) — this field is withheld from the CUSTOMER document
|
|
185
|
+
* (`public-openapi.json` and its bundled sibling). The field-level twin of
|
|
186
|
+
* {@link DocumentedEndpoint.hidden}, and audienced exactly like it: it stays in the private
|
|
187
|
+
* document, and in the MCP document and tool catalogs, which keep hidden methods too.
|
|
188
|
+
*
|
|
189
|
+
* A documentation decision, never an access-control one: the server still accepts and returns
|
|
190
|
+
* the field. It is for a field that was NEVER published — hiding one a partner already reads
|
|
191
|
+
* is a removal from their point of view.
|
|
192
|
+
*/
|
|
193
|
+
hidden: boolean,
|
|
194
|
+
/**
|
|
195
|
+
* The `@hidden` tag's text — WHY it is withheld (`not announced yet; ships with …`).
|
|
196
|
+
* Undefined when the tag has no text. Never published anywhere: it is the author's note.
|
|
197
|
+
*/
|
|
198
|
+
hiddenReason: string | undefined);
|
|
167
199
|
}
|
|
168
200
|
/** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */
|
|
169
201
|
export declare class DocumentedType {
|
package/src/model/ApiDocModel.js
CHANGED
|
@@ -89,6 +89,8 @@ class DocumentedField {
|
|
|
89
89
|
max;
|
|
90
90
|
mcpHeader;
|
|
91
91
|
location;
|
|
92
|
+
hidden;
|
|
93
|
+
hiddenReason;
|
|
92
94
|
constructor(name, type,
|
|
93
95
|
/**
|
|
94
96
|
* OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from
|
|
@@ -131,7 +133,23 @@ class DocumentedField {
|
|
|
131
133
|
* carried on the FIELD rather than recomputed because only the extractor still has the
|
|
132
134
|
* syntax node, and a second reader deriving it would be a second answer to "where is this".
|
|
133
135
|
*/
|
|
134
|
-
location
|
|
136
|
+
location,
|
|
137
|
+
/**
|
|
138
|
+
* The `@hidden` JSDoc tag (#1246) — this field is withheld from the CUSTOMER document
|
|
139
|
+
* (`public-openapi.json` and its bundled sibling). The field-level twin of
|
|
140
|
+
* {@link DocumentedEndpoint.hidden}, and audienced exactly like it: it stays in the private
|
|
141
|
+
* document, and in the MCP document and tool catalogs, which keep hidden methods too.
|
|
142
|
+
*
|
|
143
|
+
* A documentation decision, never an access-control one: the server still accepts and returns
|
|
144
|
+
* the field. It is for a field that was NEVER published — hiding one a partner already reads
|
|
145
|
+
* is a removal from their point of view.
|
|
146
|
+
*/
|
|
147
|
+
hidden,
|
|
148
|
+
/**
|
|
149
|
+
* The `@hidden` tag's text — WHY it is withheld (`not announced yet; ships with …`).
|
|
150
|
+
* Undefined when the tag has no text. Never published anywhere: it is the author's note.
|
|
151
|
+
*/
|
|
152
|
+
hiddenReason) {
|
|
135
153
|
this.name = name;
|
|
136
154
|
this.type = type;
|
|
137
155
|
this.optional = optional;
|
|
@@ -143,6 +161,8 @@ class DocumentedField {
|
|
|
143
161
|
this.max = max;
|
|
144
162
|
this.mcpHeader = mcpHeader;
|
|
145
163
|
this.location = location;
|
|
164
|
+
this.hidden = hidden;
|
|
165
|
+
this.hiddenReason = hiddenReason;
|
|
146
166
|
}
|
|
147
167
|
}
|
|
148
168
|
exports.DocumentedField = DocumentedField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-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ED;;;;;;;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}\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,QAAQ,CAAQ;QAEhB,eAAU,GAAV,UAAU,CAAmB;IACvC,CAAC;CACP;AATD,oCASC;AAED,wGAAwG;AACxG,MAAa,kBAAkB;IAGd;IAQA;IAVb;IACI,yCAAyC;IAChC,YAAoB;IAC7B;;;;;;OAMG;IACM,YAAoD;QARpD,iBAAY,GAAZ,YAAY,CAA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EA;IAEA;IACA;IAEA;IAEA;IAEA;IAEA;IAvBb;IACI,+CAA+C;IACtC,YAAoB;IAC7B;;;;;;OAMG;IACM,QAA2B;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/** 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"]}
|
package/src/model/DocLink.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export declare enum DocLinkKind {
|
|
|
17
17
|
* A member — property or enum member — written BARE (`{@link storeId}`), as TypeScript resolves
|
|
18
18
|
* it inside a member's own JSDoc: a sibling, or one its type inherits (#1308). Published as the
|
|
19
19
|
* member's own name, with no type prefix, because the reader is already on that schema — the one
|
|
20
|
-
* the member is a field of, its inherited fields flattened in. Every output publishes it
|
|
20
|
+
* the member is a field of, its inherited fields flattened in. Every output publishes it — except
|
|
21
|
+
* a customer document, when the member is a `@hidden` field it omits (#1246).
|
|
21
22
|
*/
|
|
22
23
|
MEMBER = "member",
|
|
23
24
|
/** A method of an `@ApiPath` contract: a published operation. */
|
package/src/model/DocLink.js
CHANGED
|
@@ -21,7 +21,8 @@ var DocLinkKind;
|
|
|
21
21
|
* A member — property or enum member — written BARE (`{@link storeId}`), as TypeScript resolves
|
|
22
22
|
* it inside a member's own JSDoc: a sibling, or one its type inherits (#1308). Published as the
|
|
23
23
|
* member's own name, with no type prefix, because the reader is already on that schema — the one
|
|
24
|
-
* the member is a field of, its inherited fields flattened in. Every output publishes it
|
|
24
|
+
* the member is a field of, its inherited fields flattened in. Every output publishes it — except
|
|
25
|
+
* a customer document, when the member is a `@hidden` field it omits (#1246).
|
|
25
26
|
*/
|
|
26
27
|
DocLinkKind["MEMBER"] = "member";
|
|
27
28
|
/** A method of an `@ApiPath` contract: a published operation. */
|
|
@@ -170,9 +171,6 @@ class DocLinkText {
|
|
|
170
171
|
static resolve(text, naming, output, problems) {
|
|
171
172
|
return text.replace(ENCODED, (_all, body) => {
|
|
172
173
|
const link = DocLinkText.decode(body);
|
|
173
|
-
if (link.kind === DocLinkKind.MEMBER) {
|
|
174
|
-
return DocLinkText.spell(link, link.member);
|
|
175
|
-
}
|
|
176
174
|
const name = link.kind === DocLinkKind.UNRESOLVED ? undefined : naming.publishedName(link);
|
|
177
175
|
if (name === undefined) {
|
|
178
176
|
problems.push(new DocLinkProblem(link.location, link.written, DocLinkText.why(link, output)));
|
|
@@ -191,7 +189,11 @@ class DocLinkText {
|
|
|
191
189
|
static why(link, output) {
|
|
192
190
|
switch (link.kind) {
|
|
193
191
|
case DocLinkKind.TYPE:
|
|
194
|
-
return
|
|
192
|
+
return link.member === ''
|
|
193
|
+
? `type ${link.ownerName} is not published in ${output}`
|
|
194
|
+
: `${link.ownerName}${link.member} is not published in ${output}`;
|
|
195
|
+
case DocLinkKind.MEMBER:
|
|
196
|
+
return `field ${link.ownerName}.${link.member} is not published in ${output}`;
|
|
195
197
|
case DocLinkKind.OPERATION:
|
|
196
198
|
return `operation ${link.owner}.${link.ownerName} is not published in ${output}`;
|
|
197
199
|
default:
|
package/src/model/DocLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocLink.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/DocLink.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,IAAY,WAcX;AAdD,WAAY,WAAW;IACnB,yFAAyF;IACzF,4BAAa,CAAA;IACb;;;;;OAKG;IACH,gCAAiB,CAAA;IACjB,iEAAiE;IACjE,sCAAuB,CAAA;IACvB,wFAAwF;IACxF,wCAAyB,CAAA;AAC7B,CAAC,EAdW,WAAW,2BAAX,WAAW,QActB;AAED,0FAA0F;AAC1F,MAAa,OAAO;IAEH;IAEA;IAEA;IAEA;IAMA;IACA;IAMA;IAEA;IAEA;IAxBb,YACa,IAAiB;IAC1B,gFAAgF;IACvE,OAAe;IACxB,6FAA6F;IACpF,KAAyB;IAClC,4FAA4F;IACnF,QAAgB;IACzB;;;;OAIG;IACM,KAAa,EACb,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IAAI;gBACjB,OAAO,QAAQ,IAAI,CAAC,SAAS,wBAAwB,MAAM,EAAE,CAAC;YAClE,KAAK,WAAW,CAAC,SAAS;gBACtB,OAAO,aAAa,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,wBAAwB,MAAM,EAAE,CAAC;YACrF;gBACI,OAAO,IAAI,CAAC,MAAM,CAAC;QAC3B,CAAC;IACL,CAAC;IAED,qFAAqF;IAC7E,MAAM,CAAC,MAAM,CAAC,IAAY;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAC;QAChD,OAAO,IAAI,OAAO,CACd,CAAC,CAAC,CAAC,CAAgB,EACnB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,EACjB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,EACjB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CACb,CAAC;IACN,CAAC;CACJ;AA5GD,kCA4GC","sourcesContent":["/**\n * What a JSDoc `{@link X}` names, as the COMPILER resolved it at extraction (#1284).\n *\n * A link is a reference, and a reference is published under the target's PUBLISHED identity — never\n * its source name. `{@link MenuDto}` must publish the schema name `Menu` when `schemaNames` strips\n * `Dto`, and `{@link OrdersApi.fetchOrders}` must publish the operation, not leak the contract class\n * name to a partner. Neither name is known where the JSDoc is read: the schema name of a type in a\n * bundled document depends on what else that document reaches, the operationId on the manifest's\n * `operationIds` style, and an MCP catalog names a tool by its `@WpMcpTool` name. So extraction\n * records WHAT the link points at, as one of these, and each renderer names it — see\n * {@link DocLinkText}.\n */\nexport enum DocLinkKind {\n /** A named type — class, interface, enum or alias — optionally with a `.member` tail. */\n TYPE = 'type',\n /**\n * A member — property or enum member — written BARE (`{@link storeId}`), as TypeScript resolves\n * it inside a member's own JSDoc: a sibling, or one its type inherits (#1308). Published as the\n * member's own name, with no type prefix, because the reader is already on that schema — the one\n * the member is a field of, its inherited fields flattened in. Every output publishes it.\n */\n MEMBER = 'member',\n /** A method of an `@ApiPath` contract: a published operation. */\n OPERATION = 'operation',\n /** A target that names nothing any document publishes. Always refused by a renderer. */\n UNRESOLVED = 'unresolved',\n}\n\n/** One resolved `{@link}`. Data only: a renderer reads it through {@link DocLinkText}. */\nexport class DocLink {\n constructor(\n readonly kind: DocLinkKind,\n /** The target exactly as written — `MenuDto.items`, `OrdersApi.fetchOrders`. */\n readonly written: string,\n /** `{@link X | the label}` / `{@link X the label}`'s label; undefined when there is none. */\n readonly label: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the link itself, for a refusal that names it. */\n readonly location: string,\n /**\n * {@link DocLinkKind.TYPE}: the {@link ApiDocModel.types} key of the type, and its\n * schemaNames-stripped published name. {@link DocLinkKind.OPERATION}: the contract class and\n * method name. Empty for the other kinds.\n */\n readonly owner: string,\n readonly ownerName: string,\n /**\n * {@link DocLinkKind.TYPE}: the `.member` tail exactly as written (`.items`), else empty.\n * {@link DocLinkKind.MEMBER}: the member's published name (`storeId`), the type it is\n * declared on in `owner` / `ownerName`.\n */\n readonly member: string,\n /** {@link DocLinkKind.OPERATION}: the method's `@WpMcpTool` name, when it is a tool. */\n readonly mcpToolName: string | undefined,\n /** {@link DocLinkKind.UNRESOLVED}: why it names nothing publishable, in one clause. */\n readonly reason: string,\n ) {}\n}\n\n/** One `{@link}` a rendered output could not name. A renderer refuses every one, in one run. */\nexport class DocLinkProblem {\n constructor(\n /** Pointer-style `path/to/File.ts:12:5` of the link. */\n readonly location: string,\n /** The target as written. */\n readonly written: string,\n /** Why, in one clause. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.location} {@link ${this.written}} — ${this.reason}`;\n }\n}\n\n/**\n * How ONE rendered output names a link's target: the published schema name in THIS document, the\n * operationId, an MCP tool name. Undefined means the output does not publish the target, which the\n * resolver records as a {@link DocLinkProblem}.\n */\nexport interface DocLinkNaming {\n publishedName(link: DocLink): string | undefined;\n}\n\n/** Brackets one encoded link inside a model string. Private-use code points: no author types them. */\nconst OPEN = '';\nconst CLOSE = '';\nconst ENCODED = /([^]*)/g;\n\n/**\n * The ONE grammar for a `{@link}` inside model prose (#1284).\n *\n * Every prose string the model carries — a description, a `@summary`, a `@returns`, an `@mcp` — holds\n * each link ENCODED in place, so concatenation, trimming and joining by any renderer cannot separate a\n * link from the sentence it sits in. A renderer resolves the string as it publishes it, with its own\n * {@link DocLinkNaming}, and every renderer emits the SAME spelling:\n *\n * | written | published |\n * |---|---|\n * | `{@link MenuDto}` | `` `Menu` `` (the published schema name) |\n * | `{@link MenuDto.items}` | `` `Menu.items` `` (the tail kept as written) |\n * | `{@link storeId}`, from a sibling field's JSDoc | `` `storeId` `` (the field's own name — no type prefix) |\n * | `{@link OrdersApi.fetchOrders}` | `` `fetchOrders` `` (the operationId; an MCP tool's name in a tool catalog) |\n * | `{@link OrdersApi.fetchOrders \\| the order list}` | `the order list (`fetchOrders`)` |\n *\n * A markdown CODE SPAN, because OpenAPI descriptions are CommonMark: every renderer shows it as code,\n * and a docs site can turn a code span naming a known operationId or schema into a link. A labelled\n * link keeps the author's words AND the identity, so the reference survives into a site's hyperlink.\n *\n * A model string must never reach a published output unresolved; a renderer that forgets is caught by\n * {@link hasLinks}, which every published output is checked with.\n */\nexport class DocLinkText {\n /** `link`, encoded for a place in a model string. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static encode(link: DocLink): string {\n const fields = [\n link.kind,\n link.written,\n link.label ?? null,\n link.location,\n link.owner,\n link.ownerName,\n link.member,\n link.mcpToolName ?? null,\n link.reason,\n ];\n return `${OPEN}${JSON.stringify(fields)}${CLOSE}`;\n }\n\n /** True when `text` still holds an encoded link — a published output never may. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static hasLinks(text: string): boolean {\n return text.includes(OPEN);\n }\n\n /**\n * Every link in `text` as WRITTEN, in the published spelling: for a measurement that must not count\n * the encoding (a `@summary`'s length) and for a reader that publishes nothing.\n */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static asWritten(text: string): string {\n return text.replace(ENCODED, (_all: string, body: string) => {\n const link = DocLinkText.decode(body);\n return DocLinkText.spell(link, link.written);\n });\n }\n\n /** Every encoded link in `text`, in order. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static linksIn(text: string): readonly DocLink[] {\n const links: DocLink[] = [];\n for (const match of text.matchAll(ENCODED)) {\n links.push(DocLinkText.decode(match[1] ?? ''));\n }\n return links;\n }\n\n /** `text` with every link published under the name `naming` gives it; misses go to `problems`. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static resolve(\n text: string,\n naming: DocLinkNaming,\n output: string,\n problems: DocLinkProblem[],\n ): string {\n return text.replace(ENCODED, (_all: string, body: string) => {\n const link = DocLinkText.decode(body);\n if (link.kind === DocLinkKind.MEMBER) {\n return DocLinkText.spell(link, link.member);\n }\n const name =\n link.kind === DocLinkKind.UNRESOLVED ? undefined : naming.publishedName(link);\n if (name === undefined) {\n problems.push(\n new DocLinkProblem(link.location, link.written, DocLinkText.why(link, output)),\n );\n return DocLinkText.spell(link, link.written);\n }\n return DocLinkText.spell(\n link,\n link.kind === DocLinkKind.TYPE ? `${name}${link.member}` : name,\n );\n });\n }\n\n /** The one published spelling — see the class doc. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static spell(link: DocLink, name: string): string {\n const code = `\\`${name}\\``;\n return link.label === undefined ? code : `${link.label} (${code})`;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static why(link: DocLink, output: string): string {\n switch (link.kind) {\n case DocLinkKind.TYPE:\n return `type ${link.ownerName} is not published in ${output}`;\n case DocLinkKind.OPERATION:\n return `operation ${link.owner}.${link.ownerName} is not published in ${output}`;\n default:\n return link.reason;\n }\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static decode(body: string): DocLink {\n const f = JSON.parse(body) as (string | null)[];\n return new DocLink(\n f[0] as DocLinkKind,\n f[1] ?? '',\n f[2] ?? undefined,\n f[3] ?? '',\n f[4] ?? '',\n f[5] ?? '',\n f[6] ?? '',\n f[7] ?? undefined,\n f[8] ?? '',\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DocLink.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/DocLink.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,IAAY,WAeX;AAfD,WAAY,WAAW;IACnB,yFAAyF;IACzF,4BAAa,CAAA;IACb;;;;;;OAMG;IACH,gCAAiB,CAAA;IACjB,iEAAiE;IACjE,sCAAuB,CAAA;IACvB,wFAAwF;IACxF,wCAAyB,CAAA;AAC7B,CAAC,EAfW,WAAW,2BAAX,WAAW,QAetB;AAED,0FAA0F;AAC1F,MAAa,OAAO;IAEH;IAEA;IAEA;IAEA;IAMA;IACA;IAMA;IAEA;IAEA;IAxBb,YACa,IAAiB;IAC1B,gFAAgF;IACvE,OAAe;IACxB,6FAA6F;IACpF,KAAyB;IAClC,4FAA4F;IACnF,QAAgB;IACzB;;;;OAIG;IACM,KAAa,EACb,SAAiB;IAC1B;;;;OAIG;IACM,MAAc;IACvB,wFAAwF;IAC/E,WAA+B;IACxC,uFAAuF;IAC9E,MAAc;QAvBd,SAAI,GAAJ,IAAI,CAAa;QAEjB,YAAO,GAAP,OAAO,CAAQ;QAEf,UAAK,GAAL,KAAK,CAAoB;QAEzB,aAAQ,GAAR,QAAQ,CAAQ;QAMhB,UAAK,GAAL,KAAK,CAAQ;QACb,cAAS,GAAT,SAAS,CAAQ;QAMjB,WAAM,GAAN,MAAM,CAAQ;QAEd,gBAAW,GAAX,WAAW,CAAoB;QAE/B,WAAM,GAAN,MAAM,CAAQ;IAC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C,MAAM,CAAC,IAAY;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAC;QAChD,OAAO,IAAI,OAAO,CACd,CAAC,CAAC,CAAC,CAAgB,EACnB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,EACjB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EACV,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,EACjB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CACb,CAAC;IACN,CAAC;CACJ;AA7GD,kCA6GC","sourcesContent":["/**\n * What a JSDoc `{@link X}` names, as the COMPILER resolved it at extraction (#1284).\n *\n * A link is a reference, and a reference is published under the target's PUBLISHED identity — never\n * its source name. `{@link MenuDto}` must publish the schema name `Menu` when `schemaNames` strips\n * `Dto`, and `{@link OrdersApi.fetchOrders}` must publish the operation, not leak the contract class\n * name to a partner. Neither name is known where the JSDoc is read: the schema name of a type in a\n * bundled document depends on what else that document reaches, the operationId on the manifest's\n * `operationIds` style, and an MCP catalog names a tool by its `@WpMcpTool` name. So extraction\n * records WHAT the link points at, as one of these, and each renderer names it — see\n * {@link DocLinkText}.\n */\nexport enum DocLinkKind {\n /** A named type — class, interface, enum or alias — optionally with a `.member` tail. */\n TYPE = 'type',\n /**\n * A member — property or enum member — written BARE (`{@link storeId}`), as TypeScript resolves\n * it inside a member's own JSDoc: a sibling, or one its type inherits (#1308). Published as the\n * member's own name, with no type prefix, because the reader is already on that schema — the one\n * the member is a field of, its inherited fields flattened in. Every output publishes it — except\n * a customer document, when the member is a `@hidden` field it omits (#1246).\n */\n MEMBER = 'member',\n /** A method of an `@ApiPath` contract: a published operation. */\n OPERATION = 'operation',\n /** A target that names nothing any document publishes. Always refused by a renderer. */\n UNRESOLVED = 'unresolved',\n}\n\n/** One resolved `{@link}`. Data only: a renderer reads it through {@link DocLinkText}. */\nexport class DocLink {\n constructor(\n readonly kind: DocLinkKind,\n /** The target exactly as written — `MenuDto.items`, `OrdersApi.fetchOrders`. */\n readonly written: string,\n /** `{@link X | the label}` / `{@link X the label}`'s label; undefined when there is none. */\n readonly label: string | undefined,\n /** Pointer-style `path/to/File.ts:12:5` of the link itself, for a refusal that names it. */\n readonly location: string,\n /**\n * {@link DocLinkKind.TYPE}: the {@link ApiDocModel.types} key of the type, and its\n * schemaNames-stripped published name. {@link DocLinkKind.OPERATION}: the contract class and\n * method name. Empty for the other kinds.\n */\n readonly owner: string,\n readonly ownerName: string,\n /**\n * {@link DocLinkKind.TYPE}: the `.member` tail exactly as written (`.items`), else empty.\n * {@link DocLinkKind.MEMBER}: the member's published name (`storeId`), the type it is\n * declared on in `owner` / `ownerName`.\n */\n readonly member: string,\n /** {@link DocLinkKind.OPERATION}: the method's `@WpMcpTool` name, when it is a tool. */\n readonly mcpToolName: string | undefined,\n /** {@link DocLinkKind.UNRESOLVED}: why it names nothing publishable, in one clause. */\n readonly reason: string,\n ) {}\n}\n\n/** One `{@link}` a rendered output could not name. A renderer refuses every one, in one run. */\nexport class DocLinkProblem {\n constructor(\n /** Pointer-style `path/to/File.ts:12:5` of the link. */\n readonly location: string,\n /** The target as written. */\n readonly written: string,\n /** Why, in one clause. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.location} {@link ${this.written}} — ${this.reason}`;\n }\n}\n\n/**\n * How ONE rendered output names a link's target: the published schema name in THIS document, the\n * operationId, an MCP tool name. Undefined means the output does not publish the target, which the\n * resolver records as a {@link DocLinkProblem}.\n */\nexport interface DocLinkNaming {\n publishedName(link: DocLink): string | undefined;\n}\n\n/** Brackets one encoded link inside a model string. Private-use code points: no author types them. */\nconst OPEN = '';\nconst CLOSE = '';\nconst ENCODED = /([^]*)/g;\n\n/**\n * The ONE grammar for a `{@link}` inside model prose (#1284).\n *\n * Every prose string the model carries — a description, a `@summary`, a `@returns`, an `@mcp` — holds\n * each link ENCODED in place, so concatenation, trimming and joining by any renderer cannot separate a\n * link from the sentence it sits in. A renderer resolves the string as it publishes it, with its own\n * {@link DocLinkNaming}, and every renderer emits the SAME spelling:\n *\n * | written | published |\n * |---|---|\n * | `{@link MenuDto}` | `` `Menu` `` (the published schema name) |\n * | `{@link MenuDto.items}` | `` `Menu.items` `` (the tail kept as written) |\n * | `{@link storeId}`, from a sibling field's JSDoc | `` `storeId` `` (the field's own name — no type prefix) |\n * | `{@link OrdersApi.fetchOrders}` | `` `fetchOrders` `` (the operationId; an MCP tool's name in a tool catalog) |\n * | `{@link OrdersApi.fetchOrders \\| the order list}` | `the order list (`fetchOrders`)` |\n *\n * A markdown CODE SPAN, because OpenAPI descriptions are CommonMark: every renderer shows it as code,\n * and a docs site can turn a code span naming a known operationId or schema into a link. A labelled\n * link keeps the author's words AND the identity, so the reference survives into a site's hyperlink.\n *\n * A model string must never reach a published output unresolved; a renderer that forgets is caught by\n * {@link hasLinks}, which every published output is checked with.\n */\nexport class DocLinkText {\n /** `link`, encoded for a place in a model string. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static encode(link: DocLink): string {\n const fields = [\n link.kind,\n link.written,\n link.label ?? null,\n link.location,\n link.owner,\n link.ownerName,\n link.member,\n link.mcpToolName ?? null,\n link.reason,\n ];\n return `${OPEN}${JSON.stringify(fields)}${CLOSE}`;\n }\n\n /** True when `text` still holds an encoded link — a published output never may. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static hasLinks(text: string): boolean {\n return text.includes(OPEN);\n }\n\n /**\n * Every link in `text` as WRITTEN, in the published spelling: for a measurement that must not count\n * the encoding (a `@summary`'s length) and for a reader that publishes nothing.\n */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static asWritten(text: string): string {\n return text.replace(ENCODED, (_all: string, body: string) => {\n const link = DocLinkText.decode(body);\n return DocLinkText.spell(link, link.written);\n });\n }\n\n /** Every encoded link in `text`, in order. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static linksIn(text: string): readonly DocLink[] {\n const links: DocLink[] = [];\n for (const match of text.matchAll(ENCODED)) {\n links.push(DocLinkText.decode(match[1] ?? ''));\n }\n return links;\n }\n\n /** `text` with every link published under the name `naming` gives it; misses go to `problems`. */\n // webpieces-disable no-function-outside-class -- static codec of the grammar this class owns\n static resolve(\n text: string,\n naming: DocLinkNaming,\n output: string,\n problems: DocLinkProblem[],\n ): string {\n return text.replace(ENCODED, (_all: string, body: string) => {\n const link = DocLinkText.decode(body);\n const name =\n link.kind === DocLinkKind.UNRESOLVED ? undefined : naming.publishedName(link);\n if (name === undefined) {\n problems.push(\n new DocLinkProblem(link.location, link.written, DocLinkText.why(link, output)),\n );\n return DocLinkText.spell(link, link.written);\n }\n return DocLinkText.spell(\n link,\n link.kind === DocLinkKind.TYPE ? `${name}${link.member}` : name,\n );\n });\n }\n\n /** The one published spelling — see the class doc. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static spell(link: DocLink, name: string): string {\n const code = `\\`${name}\\``;\n return link.label === undefined ? code : `${link.label} (${code})`;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static why(link: DocLink, output: string): string {\n switch (link.kind) {\n case DocLinkKind.TYPE:\n return link.member === ''\n ? `type ${link.ownerName} is not published in ${output}`\n : `${link.ownerName}${link.member} is not published in ${output}`;\n case DocLinkKind.MEMBER:\n return `field ${link.ownerName}.${link.member} is not published in ${output}`;\n case DocLinkKind.OPERATION:\n return `operation ${link.owner}.${link.ownerName} is not published in ${output}`;\n default:\n return link.reason;\n }\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static decode(body: string): DocLink {\n const f = JSON.parse(body) as (string | null)[];\n return new DocLink(\n f[0] as DocLinkKind,\n f[1] ?? '',\n f[2] ?? undefined,\n f[3] ?? '',\n f[4] ?? '',\n f[5] ?? '',\n f[6] ?? '',\n f[7] ?? undefined,\n f[8] ?? '',\n );\n }\n}\n"]}
|
|
@@ -45,7 +45,9 @@ class McpLinkNaming {
|
|
|
45
45
|
if (link.kind === DocLink_1.DocLinkKind.OPERATION) {
|
|
46
46
|
return link.mcpToolName ?? this.operationIds.of(link.owner, link.ownerName);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
// A bare member is its own name. A `@hidden` field is published to MCP (#1246), as a
|
|
49
|
+
// hidden method is, so a link to one is never refused here.
|
|
50
|
+
return link.kind === DocLink_1.DocLinkKind.MEMBER ? link.member : undefined;
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpSchemaRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/render/McpSchemaRenderer.ts"],"names":[],"mappings":";;;AAAA,oDAa8B;AAO9B,8CAAoG;AACpG,8DAA2D;AAG3D,qDAAkD;AAElD,iFAAiF;AACjF,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAEtD,4GAA4G;AAC5G,MAAa,cAAc;IAGV;IACA;IAEA;IALb;IACI,4CAA4C;IACnC,IAAY,EACZ,YAAoB;IAC7B,4EAA4E;IACnE,MAAc;QAHd,SAAI,GAAJ,IAAI,CAAQ;QACZ,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,WAAM,GAAN,MAAM,CAAQ;IACxB,CAAC;IAEJ,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC;CACJ;AAZD,wCAYC;AAED,oDAAoD;AACpD,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,aAAa;IACc;IAA7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAE3D,aAAa,CA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ointOperation,\n McpToolCatalogError,\n McpToolCatalogFile,\n McpToolDefinition,\n McpToolName,\n mcpHintsForOperation,\n READ,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport {\n ApiDocModel,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n} from '../model/ApiDocModel';\nimport { DocLink, DocLinkKind, DocLinkNaming, DocLinkProblem, DocLinkText } from '../model/DocLink';\nimport { EndpointSummary } from '../model/EndpointSummary';\nimport { OperationIds } from '../model/OperationIds';\nimport { TypeRef } from '../model/TypeRef';\nimport { McpRenderError } from './McpRenderError';\n\n/** RFC 9110 token, which is what an `Mcp-Param-{name}` header name has to be. */\nconst HEADER_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** ONE `@WpMcpTool` the build could not give a schema, and why. See {@link McpSchemaRenderer.catalogOf}. */\nexport class SkippedMcpTool {\n constructor(\n /** The stable protocol name it declared. */\n readonly name: string,\n readonly contractName: string,\n /** The render refusal, verbatim, including the declaration it points at. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.contractName}/${this.name}: ${this.reason}`;\n }\n}\n\n/** The output name every MCP link refusal names. */\nconst MCP_OUTPUT = 'the MCP tool catalog';\n\n/**\n * How an MCP tool catalog names a `{@link}` target (#1284). A tool schema is fully inline, so a type\n * is named by its published schema name; a contract method that IS a tool by its tool `name` — the\n * one thing an MCP client can call — and any other method by its operationId.\n */\nclass McpLinkNaming implements DocLinkNaming {\n constructor(private readonly operationIds: OperationIds) {}\n\n publishedName(link: DocLink): string | undefined {\n if (link.kind === DocLinkKind.TYPE) {\n return link.ownerName;\n }\n if (link.kind === DocLinkKind.OPERATION) {\n return link.mcpToolName ?? this.operationIds.of(link.owner, link.ownerName);\n }\n return undefined;\n }\n}\n\n/**\n * What one catalog render produced: ONE catalog per contract that has at least one renderable tool\n * (`mcp-<ContractClass>-tools.json` each), and the tools it could not produce.\n */\nexport class McpCatalogRender {\n constructor(\n readonly catalogs: readonly McpToolCatalogFile[],\n readonly skipped: readonly SkippedMcpTool[],\n ) {}\n}\n\n/**\n * `ApiDocModel` -> the MCP tool list an agent is shown, and the server accepts calls against.\n *\n * ## It is the ONLY source of an MCP schema\n *\n * It was written for #983 as a MEASUREMENT: it rendered the same `ApiJsonSchema` the reflect-metadata\n * runtime built, so the two could be compared field by field. They matched for every DTO shape the\n * runtime could build, which is what licensed #984 to delete `@WpDtoField` and its erasure-repair\n * arguments — `required`, `arrayItems`, `integer`, `minimum`, `maximum`, `enumValues`, `mapValues`,\n * `mcpHeader` — along with `DtoSchemaBuilder` itself. There is now one schema, built here, written to\n * one `mcp-<ContractClass>-tools.json` per contract by `wp-openapi`, and read at boot by\n * `McpToolRegistry`.\n *\n * ## Where it now goes FURTHER than the deleted runtime could\n *\n * The three reproductions #983 documented were runtime capability gaps, and two of them are closed:\n *\n * - **NULLABLE is rendered**, as `type: [T, \"null\"]` — and, on an enum, with `null` added to `enum` too. `ApiJsonSchema.type` used to hold one string,\n * so the runtime could not write it down even where the compiler could see `externalId: string | null`\n * — and `{}` and `{externalId: null}` are different wire documents. `type` is now\n * `ApiJsonSchemaType | readonly ApiJsonSchemaType[]` and the union is emitted.\n * - **A bound on an ARRAY of numbers** lands on the ITEM, where OpenAPI puts it. `@WpDtoField`\n * rejected numeric constraints on a non-`Number` field, so it had nowhere to go at all.\n * - **A nested DTO is INLINED**, with the FIELD's prose on it — not a gap but the protocol: MCP tool\n * schemas are inline and have no `$ref`.\n */\nexport class McpSchemaRenderer {\n private readonly naming: McpLinkNaming;\n private readonly problems: DocLinkProblem[] = [];\n\n constructor(\n private readonly model: ApiDocModel,\n /**\n * The manifest's operationId spelling — what a `{@link}` to a contract method that is NOT a\n * tool publishes as (#1284).\n */\n operationIds: OperationIds,\n private readonly requireDescriptions = true,\n ) {\n this.naming = new McpLinkNaming(operationIds);\n }\n\n /**\n * Every `{@link}` this renderer could not name, so far. A caller that PUBLISHES what it rendered\n * refuses when this is non-empty — {@link catalogOf} does.\n */\n linkProblems(): readonly DocLinkProblem[] {\n return this.problems;\n }\n\n /** The shared inline runtime schema projection, also used by streaming catalog generation. */\n schemaFor(ref: TypeRef, where: string): ApiJsonSchema {\n return this.typeSchema(ref, where, new Set<string>());\n }\n\n /** Every `@WpMcpTool` method of the contract, in declaration order. */\n render(): readonly McpToolDefinition[] {\n const tools: McpToolDefinition[] = [];\n for (const endpoint of this.model.endpoints) {\n if (endpoint.mcpTool !== undefined) {\n tools.push(this.tool(endpoint));\n }\n }\n return tools;\n }\n\n /**\n * The tools of SEVERAL contracts as ONE CATALOG PER CONTRACT — the artifacts a server boots from,\n * one `mcp-<ContractClass>-tools.json` each — plus every tool that could not be rendered and why.\n *\n * Per contract because a server binds contracts, and checks each `McpApiBinding` against the file\n * generated from exactly that contract (#1021). The protocol namespace is still FLAT, though: two\n * contracts declaring one tool name is a collision an agent would see, so it is refused here, at\n * build time, across every contract of the run, rather than at somebody's boot.\n *\n * ## Why an unrenderable tool is REPORTED here rather than throwing\n *\n * Some shapes have no MCP schema at all — a recursive DTO, an undocumented tool, a request that\n * is not a named object — and the first of those is a limit of the PROTOCOL rather than a defect\n * in a contract that is otherwise perfectly good HTTP. (A DISCRIMINATED UNION used to be on this\n * list and no longer is: #1009 taught `ApiJsonSchema` `oneOf`, so one publishes.) Such a\n * tool was never servable: the reflect-metadata runtime refused it too, for its own reasons. So\n * failing the whole document build over one would stop a repo publishing its OpenAPI over a tool\n * nobody could ever have called.\n *\n * It is not silence either. The build NAMES every skipped tool with its reason, and\n * `McpToolRegistry` REFUSES TO BOOT when a registered `@WpMcpTool` is missing from the catalog —\n * which is the right place for that failure, because that is the process actually claiming to\n * serve it.\n */\n // webpieces-disable no-function-outside-class -- static factory over this class\n static catalogOf(models: readonly ApiDocModel[], operationIds: OperationIds): McpCatalogRender {\n const catalogs: McpToolCatalogFile[] = [];\n const skipped: SkippedMcpTool[] = [];\n const owners = new Map<string, string>();\n const problems: DocLinkProblem[] = [];\n for (const model of models) {\n const renderer = new McpSchemaRenderer(model, operationIds);\n const tools: McpToolDefinition[] = [];\n for (const endpoint of model.endpoints) {\n if (endpoint.mcpTool === undefined) {\n continue;\n }\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring\n try {\n tools.push(renderer.tool(endpoint));\n } catch (err: unknown) {\n //const error = toError(err);\n if (!(err instanceof McpRenderError)) throw err;\n skipped.push(\n new SkippedMcpTool(endpoint.mcpTool.name, model.contractName, err.message),\n );\n }\n }\n McpSchemaRenderer.claimNames(owners, model.contractName, tools);\n problems.push(...renderer.linkProblems());\n if (tools.length > 0) {\n catalogs.push(new McpToolCatalogFile(model.contractName, tools));\n }\n }\n McpSchemaRenderer.refuseLinks(problems);\n return new McpCatalogRender(catalogs, skipped);\n }\n\n /**\n * A `{@link}` no catalog can name is REFUSED, not skipped (#1284): it is a defect in prose, not a\n * protocol limit, and a tool published with a dangling reference tells an agent about something it\n * cannot find. Every offender is named in one run. `wp-openapi` refuses the same links in\n * `mcp-openapi.json` first; this is the catalog's own backstop.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static refuseLinks(problems: readonly DocLinkProblem[]): void {\n if (problems.length === 0) {\n return;\n }\n throw new McpToolCatalogError(\n `${problems.length} {@link} reference(s) in MCP tool prose name nothing the catalog ` +\n `publishes: ${problems.map((each: DocLinkProblem) => each.toString()).join('; ')}.`,\n 'Point each {@link} at a published type or an @Endpoint method of an @ApiPath contract, ' +\n 'imported into the file the JSDoc is in, or write the name as plain text.',\n );\n }\n\n /** `text` as published: every `{@link}` named, every miss recorded — see {@link linkProblems}. */\n private prose(text: string): string {\n return DocLinkText.resolve(text, this.naming, MCP_OUTPUT, this.problems);\n }\n\n /** Refuse a tool name some OTHER contract of this run already declared: the namespace is flat. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static claimNames(\n owners: Map<string, string>,\n contractName: string,\n tools: readonly McpToolDefinition[],\n ): void {\n for (const tool of tools) {\n const owner = owners.get(tool.name);\n if (owner !== undefined && owner !== contractName) {\n throw new McpToolCatalogError(\n `Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`,\n 'Tool names are the protocol identity and must be globally unique — rename one ' +\n \"of the two @WpMcpTool('<name>') declarations.\",\n );\n }\n owners.set(tool.name, contractName);\n }\n }\n\n /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */\n tool(endpoint: DocumentedEndpoint): McpToolDefinition {\n const where = `${this.model.contractName}.${endpoint.methodName}`;\n const description = endpoint.mcpDescription ?? endpoint.description;\n if (description.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no documentation',\n where,\n 'Write a JSDoc block on the method, or an @mcp tag for agent-facing wording. It is ' +\n 'published verbatim by tools/list, so an agent has nothing else to go on.',\n );\n }\n if (endpoint.request === undefined || endpoint.response === undefined) {\n throw new McpRenderError(\n 'an MCP tool has no declared request or response type',\n where,\n 'Declare both: one request parameter and a Promise<Response> return type.',\n );\n }\n const summaryProblem = EndpointSummary.problemWith(endpoint.summary);\n if (summaryProblem !== undefined) {\n throw new McpRenderError(\n `an MCP tool ${summaryProblem}, so it has no title`,\n where,\n `${EndpointSummary.cure()} tools/list publishes it as title and annotations.title ` +\n '(#1296); it is never derived from the tool name.',\n );\n }\n const nameProblem = McpToolName.problemWith(endpoint.mcpTool!.name);\n if (nameProblem !== undefined) {\n throw new McpRenderError(\n `the MCP tool name '${endpoint.mcpTool!.name}' ${nameProblem}`,\n where,\n McpToolName.cure(),\n );\n }\n return new McpToolDefinition(\n endpoint.mcpTool!.name,\n this.prose(endpoint.summary!),\n endpoint.methodName,\n this.prose(description),\n mcpHintsForOperation(\n McpSchemaRenderer.operationOf(endpoint, where),\n endpoint.openWorld,\n ),\n this.rootSchema(endpoint.request, where, 'request', undefined),\n this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription),\n endpoint.mcpTool!.profiles,\n );\n }\n\n /**\n * `operation` verbatim from the model, mapped back onto the REAL constant.\n *\n * A `switch` and not a cast, because the model carries the operation as a string and a cast would\n * hand `mcpHintsForOperation` a value it has no case for — which, for a function whose three arms\n * are exhaustive, means falling off the end and publishing a tool with NO hints.\n */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static operationOf(endpoint: DocumentedEndpoint, where: string): EndpointOperation {\n switch (endpoint.operation) {\n case READ:\n return READ;\n case WRITE_IDEMPOTENT:\n return WRITE_IDEMPOTENT;\n case WRITE:\n return WRITE;\n default:\n throw new McpRenderError(\n `@Endpoint declares operation '${endpoint.operation}', which has no MCP hints`,\n where,\n `Use one of the exported constants: ${READ}, ${WRITE_IDEMPOTENT}, ${WRITE}.`,\n );\n }\n }\n\n /**\n * A tool's input/output schema: always a CLOSED OBJECT, because MCP publishes objects — and\n * because a union at the ROOT of a tool schema is refused by the function-calling APIs that\n * consume it. Both OpenAI and Anthropic reject a top-level `oneOf`/`anyOf`/`allOf`, and a server\n * sends its WHOLE tool list on every request, so one such tool makes every request 400 and bricks\n * the session — not just that tool. Nested composition, inside a property, is fine.\n *\n * The build-time rule `no-root-union-api-type` refuses the same shape across every `@ApiPath`\n * contract in the workspace, `@ApiType` or not. This is the renderer's own backstop, so a catalog\n * can never carry one even if it is reached some other way.\n */\n private rootSchema(\n ref: TypeRef,\n where: string,\n side: string,\n returns: string | undefined,\n ): ApiJsonSchema {\n if (ref.kind === 'union') {\n throw new McpRenderError(\n `an MCP tool's ${side} is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n if (ref.kind !== 'ref') {\n throw new McpRenderError(\n `an MCP tool's ${side} is not a named DTO`,\n where,\n 'Give it a named interface or class. An inline or primitive ' +\n `${side} has no object schema, and MCP publishes objects.`,\n );\n }\n const type = this.namedType(ref.refName!, where);\n if (type.unionRefNames.length > 0) {\n throw new McpRenderError(\n `an MCP tool's ${side} '${type.name}' is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n const schema = this.objectSchema(type, new Set<string>());\n McpSchemaRenderer.describeRoot(schema, this.prose(returns ?? type.description));\n return schema;\n }\n\n /**\n * The ROOT schema's `description` (#1292): the request DTO's JSDoc on `inputSchema`, and the\n * method's `@returns` sentence on `outputSchema` — the one slot a tool catalog has for \"what this\n * tool returns\", so an agent reads the same sentence a partner reads as the OpenAPI success\n * response's description. Falls back to the response DTO's own JSDoc when the method has no\n * `@returns`, which only a caller outside `wp-openapi` can reach: the generator refuses a tool\n * without one before any catalog is written. Nested DTOs keep the FIELD's prose (see\n * {@link fieldSchema}); only the root has no field to take it from.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static describeRoot(schema: ApiJsonSchema, prose: string): void {\n if (prose.trim() !== '') {\n schema.description = prose;\n }\n }\n\n private namedType(name: string, where: string): DocumentedType {\n const type = this.model.types.get(name);\n if (type === undefined) {\n throw new McpRenderError(\n `no model entry for type '${name}'`,\n where,\n 'Declare the type in a file the extractor reaches from this contract.',\n );\n }\n return type;\n }\n\n /**\n * One object DTO. CLOSED (`additionalProperties: false`), with `required` written only when it is\n * non-empty, so an all-optional DTO carries no empty list.\n *\n * The cycle stop is `parents`, and it THROWS rather than truncating: an inline schema cannot\n * express a recursive DTO, and one that silently stopped a level down would publish a shape the\n * server does not accept.\n */\n private objectSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n if (parents.has(type.name)) {\n throw new McpRenderError(\n `recursive DTO '${type.name}' cannot use an inline MCP schema`,\n type.name,\n 'Break the cycle, or keep this DTO out of the MCP document — a tool schema is ' +\n 'inline and has no $ref to close a loop with.',\n );\n }\n if (type.unionRefNames.length > 0) {\n return this.unionSchema(type, parents);\n }\n if (type.indexSignatureValue !== undefined && type.fields.length > 0) {\n throw new McpRenderError(\n `'${type.name}' has both named fields and an index signature`,\n type.name,\n 'Split the open map into a field of its own: a schema is either closed or a typed ' +\n 'map, and MCP has no spelling for half of each.',\n );\n }\n const nested = new Set(parents);\n nested.add(type.name);\n\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of type.fields) {\n schema.properties[field.name] = this.fieldSchema(type, field, nested);\n if (!field.optional) {\n required.push(field.name);\n }\n }\n if (required.length > 0) {\n schema.required = required;\n }\n return schema;\n }\n\n /**\n * A UNION, as `oneOf` with its branches INLINE and its DERIVED discriminator.\n *\n * MCP tool schemas are JSON Schema 2020-12 — the same dialect OpenAPI 3.1 uses — so `oneOf` was\n * never the obstacle; the obstacle was this repo's own subset, which had no spelling for it\n * (#1009). The shape written here MIRRORS `SchemaRenderer.union` in `@webpieces/openapi-generator`\n * branch for branch, because a union has ONE published spelling and that renderer is the\n * reference implementation of it. The only difference is the absence of `$ref`: a tool schema is\n * inline, so each branch is rendered in full and the discriminator maps to branch NAMES.\n *\n * `discriminator` is written ONLY when the model DERIVED one. A union TypeScript itself cannot\n * narrow is published as a bare `oneOf` rather than with an invented discriminator — claiming a\n * narrowing the source does not have is worse than admitting there is none.\n */\n private unionSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n const nested = new Set(parents);\n nested.add(type.name);\n const schema = new ApiJsonSchema();\n schema.oneOf = type.unionRefNames.map((name: string) =>\n this.objectSchema(this.namedType(name, type.name), nested),\n );\n if (type.description.trim() !== '') {\n schema.description = this.prose(type.description);\n }\n if (type.discriminator !== undefined) {\n const mapping: Record<string, string> = {};\n for (const branch of type.unionRefNames) {\n // The branch's NAME, never its model key: a branch declared by another package is\n // keyed `<package>:<name>` (#1058), and the published mapping names the type.\n const branchName = this.namedType(branch, type.name).schemaName;\n for (const value of type.discriminator.branchValues.get(branch) ?? []) {\n mapping[value] = branchName;\n }\n }\n schema.discriminator = new ApiJsonSchemaDiscriminator(\n type.discriminator.propertyName,\n mapping,\n );\n }\n return schema;\n }\n\n /**\n * A FIELD whose type is a union: the model registers `type X = A | B` as its OWN entry carrying\n * the derived discriminator, while the field holds a bare list of branch names. Rendering that\n * list directly would publish the `oneOf` and silently DROP the discriminator — the one part of a\n * union a client needs to narrow on — so the alias is looked up by its branch list first. This is\n * the same lookup `SchemaRenderer.namedUnion` does to emit its `$ref`.\n */\n private fieldUnion(\n branchNames: readonly string[],\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const key = branchNames.join(',');\n for (const name of this.model.types.keys()) {\n const candidate = this.model.types.get(name)!;\n if (candidate.unionRefNames.length > 0 && candidate.unionRefNames.join(',') === key) {\n return this.unionSchema(candidate, parents);\n }\n }\n const schema = new ApiJsonSchema();\n schema.oneOf = branchNames.map((name: string) =>\n this.objectSchema(this.namedType(name, where), parents),\n );\n return schema;\n }\n\n /**\n * One FIELD: its type, then the prose and the constraints that hang off the field.\n *\n * The ORDER matters: the type is built first and `description` is written over whatever the type\n * produced, so a nested DTO carries the FIELD's sentence rather than the DTO's. `@WpMin` /\n * `@WpMax` land on the numeric LEAF — on an array, on the item — for the same reason\n * `SchemaRenderer` puts them there: a `minimum` on an array means nothing.\n *\n * NULLABLE widens the type to `[T, \"null\"]` and is deliberately NOT the same thing as OPTIONAL,\n * which is an absent entry in the object's `required` list. `{}` and `{externalId: null}` are\n * different wire documents, and an agent told only \"optional\" would send the wrong one.\n */\n private fieldSchema(\n owner: DocumentedType,\n field: DocumentedField,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const where = `${owner.name}.${field.name}`;\n const schema = this.typeSchema(field.type, where, parents);\n const description = field.mcpDescription ?? field.description;\n if (this.requireDescriptions && description.trim() === '') {\n throw new McpRenderError(\n 'a published DTO field has no documentation',\n where,\n 'Write a JSDoc sentence on the field. It is the only thing an agent is told about ' +\n 'that parameter.',\n );\n }\n schema.description = this.prose(description);\n\n const leaf = field.type.kind === 'array' ? schema.items! : schema;\n if (field.min !== undefined) {\n leaf.minimum = field.min;\n }\n if (field.max !== undefined) {\n leaf.maximum = field.max;\n }\n if (field.mcpHeader !== undefined) {\n McpSchemaRenderer.assertHeaderFits(field, schema, where);\n schema['x-mcp-header'] = field.mcpHeader;\n }\n if (field.nullable) {\n schema.type = McpSchemaRenderer.nullable(schema, where);\n if (schema.enum !== undefined && !schema.enum.includes(null)) {\n // JSON Schema checks `enum` independently of `type`: without `null` here the widened\n // type admits null and the enum still rejects it, so a nullable string enum\n // (`x: SomeEnumDto | null`, or `'a' | 'b' | null`) failed output validation (#1197).\n schema.enum = [...schema.enum, null];\n }\n }\n return schema;\n }\n\n /** `T` -> `[T, \"null\"]`, refusing a field with no type at all rather than publishing `[\"null\"]`. */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static nullable(schema: ApiJsonSchema, where: string): readonly ApiJsonSchemaType[] {\n const base = ApiJsonSchema.baseTypeOf(schema);\n if (base === undefined) {\n throw new McpRenderError(\n 'a nullable field has no other type',\n where,\n 'A field typed only `null` carries no information — give it a real type beside it.',\n );\n }\n return [base, 'null'];\n }\n\n /**\n * `@mcpHeader` mirrors a PRIMITIVE parameter into `Mcp-Param-{name}` (MCP 2026 SEP-2243). The\n * three conditions are the runtime's, restated against the compiler's view of the field, so a\n * declaration the server would reject at boot fails the document build instead.\n */\n // webpieces-disable no-function-outside-class -- private static validator of this class\n private static assertHeaderFits(\n field: DocumentedField,\n schema: ApiJsonSchema,\n where: string,\n ): void {\n if (!HEADER_TOKEN.test(field.mcpHeader!)) {\n throw new McpRenderError(\n `@mcpHeader '${field.mcpHeader}' is not an RFC 9110 token`,\n where,\n 'Use letters, digits and the token punctuation only — it becomes an HTTP header name.',\n );\n }\n if (schema.type !== 'string' && schema.type !== 'boolean' && schema.type !== 'integer') {\n throw new McpRenderError(\n '@mcpHeader is on a field that is not a primitive an MCP header can carry',\n where,\n 'Mirror a string, a boolean or an Integer. A non-integer number and every object ' +\n 'shape are excluded by MCP 2026-07-28.',\n );\n }\n }\n\n /** One resolved type, with no field-level prose or constraints on it. */\n private typeSchema(ref: TypeRef, where: string, parents: ReadonlySet<string>): ApiJsonSchema {\n switch (ref.kind) {\n case 'primitive':\n return McpSchemaRenderer.primitive(ref, where);\n case 'enum': {\n const schema = new ApiJsonSchema('string');\n schema.enum = ref.enumValues.slice();\n return schema;\n }\n case 'array': {\n const schema = new ApiJsonSchema('array');\n schema.items = this.typeSchema(ref.items!, where, parents);\n return schema;\n }\n case 'openMap': {\n const schema = new ApiJsonSchema('object');\n schema.additionalProperties = this.typeSchema(ref.values!, where, parents);\n return schema;\n }\n case 'ref':\n return this.referencedSchema(ref.refName!, where, parents);\n case 'union':\n return this.fieldUnion(ref.unionRefNames, where, parents);\n default:\n throw new McpRenderError(\n `no MCP schema for the declared type '${ref.unmappedText ?? '<unknown>'}'`,\n where,\n 'Give the field a shape the model can represent — a named DTO, an array of one, ' +\n 'a string-literal union, a Record, or a primitive.',\n );\n }\n }\n\n /** A named type: a string enum becomes `enum`, an object DTO is INLINED (MCP has no `$ref`). */\n private referencedSchema(\n name: string,\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const type = this.namedType(name, where);\n if (type.enumValues.length > 0) {\n const schema = new ApiJsonSchema('string');\n schema.enum = type.enumValues.slice();\n return schema;\n }\n return this.objectSchema(type, parents);\n }\n\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static primitive(ref: TypeRef, where: string): ApiJsonSchema {\n if (ref.primitive === 'string' || ref.primitive === 'boolean') {\n return new ApiJsonSchema(ref.primitive);\n }\n if (ref.primitive === 'number') {\n return new ApiJsonSchema(ref.integer ? 'integer' : 'number');\n }\n throw new McpRenderError(\n `'${ref.primitive}' has no MCP schema`,\n where,\n 'Give the field a concrete type. `unknown`, `any`, `void` and a bare `null` publish as ' +\n '\"anything\", which an agent cannot fill in.',\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"McpSchemaRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/render/McpSchemaRen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C3C,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,sFAAsF;IAC9E,MAAM,CAAC,SAAS,CAAC,GAAY,EAAE,KAAa;QAChD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5D,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,GAAG,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,yBAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,IAAI,+BAAc,CACpB,IAAI,GAAG,CAAC,SAAS,qBAAqB,EACtC,KAAK,EACL,wFAAwF;YACpF,4CAA4C,CACnD,CAAC;IACN,CAAC;CACJ;AAzjBD,8CAyjBC","sourcesContent":["import {\n ApiJsonSchema,\n ApiJsonSchemaDiscriminator,\n ApiJsonSchemaType,\n EndpointOperation,\n McpToolCatalogError,\n McpToolCatalogFile,\n McpToolDefinition,\n McpToolName,\n mcpHintsForOperation,\n READ,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport {\n ApiDocModel,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n} from '../model/ApiDocModel';\nimport { DocLink, DocLinkKind, DocLinkNaming, DocLinkProblem, DocLinkText } from '../model/DocLink';\nimport { EndpointSummary } from '../model/EndpointSummary';\nimport { OperationIds } from '../model/OperationIds';\nimport { TypeRef } from '../model/TypeRef';\nimport { McpRenderError } from './McpRenderError';\n\n/** RFC 9110 token, which is what an `Mcp-Param-{name}` header name has to be. */\nconst HEADER_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n\n/** ONE `@WpMcpTool` the build could not give a schema, and why. See {@link McpSchemaRenderer.catalogOf}. */\nexport class SkippedMcpTool {\n constructor(\n /** The stable protocol name it declared. */\n readonly name: string,\n readonly contractName: string,\n /** The render refusal, verbatim, including the declaration it points at. */\n readonly reason: string,\n ) {}\n\n toString(): string {\n return `${this.contractName}/${this.name}: ${this.reason}`;\n }\n}\n\n/** The output name every MCP link refusal names. */\nconst MCP_OUTPUT = 'the MCP tool catalog';\n\n/**\n * How an MCP tool catalog names a `{@link}` target (#1284). A tool schema is fully inline, so a type\n * is named by its published schema name; a contract method that IS a tool by its tool `name` — the\n * one thing an MCP client can call — and any other method by its operationId.\n */\nclass McpLinkNaming implements DocLinkNaming {\n constructor(private readonly operationIds: OperationIds) {}\n\n publishedName(link: DocLink): string | undefined {\n if (link.kind === DocLinkKind.TYPE) {\n return link.ownerName;\n }\n if (link.kind === DocLinkKind.OPERATION) {\n return link.mcpToolName ?? this.operationIds.of(link.owner, link.ownerName);\n }\n // A bare member is its own name. A `@hidden` field is published to MCP (#1246), as a\n // hidden method is, so a link to one is never refused here.\n return link.kind === DocLinkKind.MEMBER ? link.member : undefined;\n }\n}\n\n/**\n * What one catalog render produced: ONE catalog per contract that has at least one renderable tool\n * (`mcp-<ContractClass>-tools.json` each), and the tools it could not produce.\n */\nexport class McpCatalogRender {\n constructor(\n readonly catalogs: readonly McpToolCatalogFile[],\n readonly skipped: readonly SkippedMcpTool[],\n ) {}\n}\n\n/**\n * `ApiDocModel` -> the MCP tool list an agent is shown, and the server accepts calls against.\n *\n * ## It is the ONLY source of an MCP schema\n *\n * It was written for #983 as a MEASUREMENT: it rendered the same `ApiJsonSchema` the reflect-metadata\n * runtime built, so the two could be compared field by field. They matched for every DTO shape the\n * runtime could build, which is what licensed #984 to delete `@WpDtoField` and its erasure-repair\n * arguments — `required`, `arrayItems`, `integer`, `minimum`, `maximum`, `enumValues`, `mapValues`,\n * `mcpHeader` — along with `DtoSchemaBuilder` itself. There is now one schema, built here, written to\n * one `mcp-<ContractClass>-tools.json` per contract by `wp-openapi`, and read at boot by\n * `McpToolRegistry`.\n *\n * ## Where it now goes FURTHER than the deleted runtime could\n *\n * The three reproductions #983 documented were runtime capability gaps, and two of them are closed:\n *\n * - **NULLABLE is rendered**, as `type: [T, \"null\"]` — and, on an enum, with `null` added to `enum` too. `ApiJsonSchema.type` used to hold one string,\n * so the runtime could not write it down even where the compiler could see `externalId: string | null`\n * — and `{}` and `{externalId: null}` are different wire documents. `type` is now\n * `ApiJsonSchemaType | readonly ApiJsonSchemaType[]` and the union is emitted.\n * - **A bound on an ARRAY of numbers** lands on the ITEM, where OpenAPI puts it. `@WpDtoField`\n * rejected numeric constraints on a non-`Number` field, so it had nowhere to go at all.\n * - **A nested DTO is INLINED**, with the FIELD's prose on it — not a gap but the protocol: MCP tool\n * schemas are inline and have no `$ref`.\n */\nexport class McpSchemaRenderer {\n private readonly naming: McpLinkNaming;\n private readonly problems: DocLinkProblem[] = [];\n\n constructor(\n private readonly model: ApiDocModel,\n /**\n * The manifest's operationId spelling — what a `{@link}` to a contract method that is NOT a\n * tool publishes as (#1284).\n */\n operationIds: OperationIds,\n private readonly requireDescriptions = true,\n ) {\n this.naming = new McpLinkNaming(operationIds);\n }\n\n /**\n * Every `{@link}` this renderer could not name, so far. A caller that PUBLISHES what it rendered\n * refuses when this is non-empty — {@link catalogOf} does.\n */\n linkProblems(): readonly DocLinkProblem[] {\n return this.problems;\n }\n\n /** The shared inline runtime schema projection, also used by streaming catalog generation. */\n schemaFor(ref: TypeRef, where: string): ApiJsonSchema {\n return this.typeSchema(ref, where, new Set<string>());\n }\n\n /** Every `@WpMcpTool` method of the contract, in declaration order. */\n render(): readonly McpToolDefinition[] {\n const tools: McpToolDefinition[] = [];\n for (const endpoint of this.model.endpoints) {\n if (endpoint.mcpTool !== undefined) {\n tools.push(this.tool(endpoint));\n }\n }\n return tools;\n }\n\n /**\n * The tools of SEVERAL contracts as ONE CATALOG PER CONTRACT — the artifacts a server boots from,\n * one `mcp-<ContractClass>-tools.json` each — plus every tool that could not be rendered and why.\n *\n * Per contract because a server binds contracts, and checks each `McpApiBinding` against the file\n * generated from exactly that contract (#1021). The protocol namespace is still FLAT, though: two\n * contracts declaring one tool name is a collision an agent would see, so it is refused here, at\n * build time, across every contract of the run, rather than at somebody's boot.\n *\n * ## Why an unrenderable tool is REPORTED here rather than throwing\n *\n * Some shapes have no MCP schema at all — a recursive DTO, an undocumented tool, a request that\n * is not a named object — and the first of those is a limit of the PROTOCOL rather than a defect\n * in a contract that is otherwise perfectly good HTTP. (A DISCRIMINATED UNION used to be on this\n * list and no longer is: #1009 taught `ApiJsonSchema` `oneOf`, so one publishes.) Such a\n * tool was never servable: the reflect-metadata runtime refused it too, for its own reasons. So\n * failing the whole document build over one would stop a repo publishing its OpenAPI over a tool\n * nobody could ever have called.\n *\n * It is not silence either. The build NAMES every skipped tool with its reason, and\n * `McpToolRegistry` REFUSES TO BOOT when a registered `@WpMcpTool` is missing from the catalog —\n * which is the right place for that failure, because that is the process actually claiming to\n * serve it.\n */\n // webpieces-disable no-function-outside-class -- static factory over this class\n static catalogOf(models: readonly ApiDocModel[], operationIds: OperationIds): McpCatalogRender {\n const catalogs: McpToolCatalogFile[] = [];\n const skipped: SkippedMcpTool[] = [];\n const owners = new Map<string, string>();\n const problems: DocLinkProblem[] = [];\n for (const model of models) {\n const renderer = new McpSchemaRenderer(model, operationIds);\n const tools: McpToolDefinition[] = [];\n for (const endpoint of model.endpoints) {\n if (endpoint.mcpTool === undefined) {\n continue;\n }\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a per-tool render refusal is REPORTED, see the docstring\n try {\n tools.push(renderer.tool(endpoint));\n } catch (err: unknown) {\n //const error = toError(err);\n if (!(err instanceof McpRenderError)) throw err;\n skipped.push(\n new SkippedMcpTool(endpoint.mcpTool.name, model.contractName, err.message),\n );\n }\n }\n McpSchemaRenderer.claimNames(owners, model.contractName, tools);\n problems.push(...renderer.linkProblems());\n if (tools.length > 0) {\n catalogs.push(new McpToolCatalogFile(model.contractName, tools));\n }\n }\n McpSchemaRenderer.refuseLinks(problems);\n return new McpCatalogRender(catalogs, skipped);\n }\n\n /**\n * A `{@link}` no catalog can name is REFUSED, not skipped (#1284): it is a defect in prose, not a\n * protocol limit, and a tool published with a dangling reference tells an agent about something it\n * cannot find. Every offender is named in one run. `wp-openapi` refuses the same links in\n * `mcp-openapi.json` first; this is the catalog's own backstop.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static refuseLinks(problems: readonly DocLinkProblem[]): void {\n if (problems.length === 0) {\n return;\n }\n throw new McpToolCatalogError(\n `${problems.length} {@link} reference(s) in MCP tool prose name nothing the catalog ` +\n `publishes: ${problems.map((each: DocLinkProblem) => each.toString()).join('; ')}.`,\n 'Point each {@link} at a published type or an @Endpoint method of an @ApiPath contract, ' +\n 'imported into the file the JSDoc is in, or write the name as plain text.',\n );\n }\n\n /** `text` as published: every `{@link}` named, every miss recorded — see {@link linkProblems}. */\n private prose(text: string): string {\n return DocLinkText.resolve(text, this.naming, MCP_OUTPUT, this.problems);\n }\n\n /** Refuse a tool name some OTHER contract of this run already declared: the namespace is flat. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static claimNames(\n owners: Map<string, string>,\n contractName: string,\n tools: readonly McpToolDefinition[],\n ): void {\n for (const tool of tools) {\n const owner = owners.get(tool.name);\n if (owner !== undefined && owner !== contractName) {\n throw new McpToolCatalogError(\n `Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`,\n 'Tool names are the protocol identity and must be globally unique — rename one ' +\n \"of the two @WpMcpTool('<name>') declarations.\",\n );\n }\n owners.set(tool.name, contractName);\n }\n }\n\n /** ONE tool. Visible to {@link catalogOf}, which renders tool by tool so it can report one. */\n tool(endpoint: DocumentedEndpoint): McpToolDefinition {\n const where = `${this.model.contractName}.${endpoint.methodName}`;\n const description = endpoint.mcpDescription ?? endpoint.description;\n if (description.trim() === '') {\n throw new McpRenderError(\n 'an MCP tool has no documentation',\n where,\n 'Write a JSDoc block on the method, or an @mcp tag for agent-facing wording. It is ' +\n 'published verbatim by tools/list, so an agent has nothing else to go on.',\n );\n }\n if (endpoint.request === undefined || endpoint.response === undefined) {\n throw new McpRenderError(\n 'an MCP tool has no declared request or response type',\n where,\n 'Declare both: one request parameter and a Promise<Response> return type.',\n );\n }\n const summaryProblem = EndpointSummary.problemWith(endpoint.summary);\n if (summaryProblem !== undefined) {\n throw new McpRenderError(\n `an MCP tool ${summaryProblem}, so it has no title`,\n where,\n `${EndpointSummary.cure()} tools/list publishes it as title and annotations.title ` +\n '(#1296); it is never derived from the tool name.',\n );\n }\n const nameProblem = McpToolName.problemWith(endpoint.mcpTool!.name);\n if (nameProblem !== undefined) {\n throw new McpRenderError(\n `the MCP tool name '${endpoint.mcpTool!.name}' ${nameProblem}`,\n where,\n McpToolName.cure(),\n );\n }\n return new McpToolDefinition(\n endpoint.mcpTool!.name,\n this.prose(endpoint.summary!),\n endpoint.methodName,\n this.prose(description),\n mcpHintsForOperation(\n McpSchemaRenderer.operationOf(endpoint, where),\n endpoint.openWorld,\n ),\n this.rootSchema(endpoint.request, where, 'request', undefined),\n this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription),\n endpoint.mcpTool!.profiles,\n );\n }\n\n /**\n * `operation` verbatim from the model, mapped back onto the REAL constant.\n *\n * A `switch` and not a cast, because the model carries the operation as a string and a cast would\n * hand `mcpHintsForOperation` a value it has no case for — which, for a function whose three arms\n * are exhaustive, means falling off the end and publishing a tool with NO hints.\n */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static operationOf(endpoint: DocumentedEndpoint, where: string): EndpointOperation {\n switch (endpoint.operation) {\n case READ:\n return READ;\n case WRITE_IDEMPOTENT:\n return WRITE_IDEMPOTENT;\n case WRITE:\n return WRITE;\n default:\n throw new McpRenderError(\n `@Endpoint declares operation '${endpoint.operation}', which has no MCP hints`,\n where,\n `Use one of the exported constants: ${READ}, ${WRITE_IDEMPOTENT}, ${WRITE}.`,\n );\n }\n }\n\n /**\n * A tool's input/output schema: always a CLOSED OBJECT, because MCP publishes objects — and\n * because a union at the ROOT of a tool schema is refused by the function-calling APIs that\n * consume it. Both OpenAI and Anthropic reject a top-level `oneOf`/`anyOf`/`allOf`, and a server\n * sends its WHOLE tool list on every request, so one such tool makes every request 400 and bricks\n * the session — not just that tool. Nested composition, inside a property, is fine.\n *\n * The build-time rule `no-root-union-api-type` refuses the same shape across every `@ApiPath`\n * contract in the workspace, `@ApiType` or not. This is the renderer's own backstop, so a catalog\n * can never carry one even if it is reached some other way.\n */\n private rootSchema(\n ref: TypeRef,\n where: string,\n side: string,\n returns: string | undefined,\n ): ApiJsonSchema {\n if (ref.kind === 'union') {\n throw new McpRenderError(\n `an MCP tool's ${side} is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n if (ref.kind !== 'ref') {\n throw new McpRenderError(\n `an MCP tool's ${side} is not a named DTO`,\n where,\n 'Give it a named interface or class. An inline or primitive ' +\n `${side} has no object schema, and MCP publishes objects.`,\n );\n }\n const type = this.namedType(ref.refName!, where);\n if (type.unionRefNames.length > 0) {\n throw new McpRenderError(\n `an MCP tool's ${side} '${type.name}' is itself a union`,\n where,\n `Wrap it in a property of an object ${side} — a top-level oneOf is rejected by the ` +\n 'OpenAI and Anthropic function-calling APIs, and one such tool 400s every ' +\n 'request in the session.',\n );\n }\n const schema = this.objectSchema(type, new Set<string>());\n McpSchemaRenderer.describeRoot(schema, this.prose(returns ?? type.description));\n return schema;\n }\n\n /**\n * The ROOT schema's `description` (#1292): the request DTO's JSDoc on `inputSchema`, and the\n * method's `@returns` sentence on `outputSchema` — the one slot a tool catalog has for \"what this\n * tool returns\", so an agent reads the same sentence a partner reads as the OpenAPI success\n * response's description. Falls back to the response DTO's own JSDoc when the method has no\n * `@returns`, which only a caller outside `wp-openapi` can reach: the generator refuses a tool\n * without one before any catalog is written. Nested DTOs keep the FIELD's prose (see\n * {@link fieldSchema}); only the root has no field to take it from.\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static describeRoot(schema: ApiJsonSchema, prose: string): void {\n if (prose.trim() !== '') {\n schema.description = prose;\n }\n }\n\n private namedType(name: string, where: string): DocumentedType {\n const type = this.model.types.get(name);\n if (type === undefined) {\n throw new McpRenderError(\n `no model entry for type '${name}'`,\n where,\n 'Declare the type in a file the extractor reaches from this contract.',\n );\n }\n return type;\n }\n\n /**\n * One object DTO. CLOSED (`additionalProperties: false`), with `required` written only when it is\n * non-empty, so an all-optional DTO carries no empty list.\n *\n * The cycle stop is `parents`, and it THROWS rather than truncating: an inline schema cannot\n * express a recursive DTO, and one that silently stopped a level down would publish a shape the\n * server does not accept.\n */\n private objectSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n if (parents.has(type.name)) {\n throw new McpRenderError(\n `recursive DTO '${type.name}' cannot use an inline MCP schema`,\n type.name,\n 'Break the cycle, or keep this DTO out of the MCP document — a tool schema is ' +\n 'inline and has no $ref to close a loop with.',\n );\n }\n if (type.unionRefNames.length > 0) {\n return this.unionSchema(type, parents);\n }\n if (type.indexSignatureValue !== undefined && type.fields.length > 0) {\n throw new McpRenderError(\n `'${type.name}' has both named fields and an index signature`,\n type.name,\n 'Split the open map into a field of its own: a schema is either closed or a typed ' +\n 'map, and MCP has no spelling for half of each.',\n );\n }\n const nested = new Set(parents);\n nested.add(type.name);\n\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of type.fields) {\n schema.properties[field.name] = this.fieldSchema(type, field, nested);\n if (!field.optional) {\n required.push(field.name);\n }\n }\n if (required.length > 0) {\n schema.required = required;\n }\n return schema;\n }\n\n /**\n * A UNION, as `oneOf` with its branches INLINE and its DERIVED discriminator.\n *\n * MCP tool schemas are JSON Schema 2020-12 — the same dialect OpenAPI 3.1 uses — so `oneOf` was\n * never the obstacle; the obstacle was this repo's own subset, which had no spelling for it\n * (#1009). The shape written here MIRRORS `SchemaRenderer.union` in `@webpieces/openapi-generator`\n * branch for branch, because a union has ONE published spelling and that renderer is the\n * reference implementation of it. The only difference is the absence of `$ref`: a tool schema is\n * inline, so each branch is rendered in full and the discriminator maps to branch NAMES.\n *\n * `discriminator` is written ONLY when the model DERIVED one. A union TypeScript itself cannot\n * narrow is published as a bare `oneOf` rather than with an invented discriminator — claiming a\n * narrowing the source does not have is worse than admitting there is none.\n */\n private unionSchema(type: DocumentedType, parents: ReadonlySet<string>): ApiJsonSchema {\n const nested = new Set(parents);\n nested.add(type.name);\n const schema = new ApiJsonSchema();\n schema.oneOf = type.unionRefNames.map((name: string) =>\n this.objectSchema(this.namedType(name, type.name), nested),\n );\n if (type.description.trim() !== '') {\n schema.description = this.prose(type.description);\n }\n if (type.discriminator !== undefined) {\n const mapping: Record<string, string> = {};\n for (const branch of type.unionRefNames) {\n // The branch's NAME, never its model key: a branch declared by another package is\n // keyed `<package>:<name>` (#1058), and the published mapping names the type.\n const branchName = this.namedType(branch, type.name).schemaName;\n for (const value of type.discriminator.branchValues.get(branch) ?? []) {\n mapping[value] = branchName;\n }\n }\n schema.discriminator = new ApiJsonSchemaDiscriminator(\n type.discriminator.propertyName,\n mapping,\n );\n }\n return schema;\n }\n\n /**\n * A FIELD whose type is a union: the model registers `type X = A | B` as its OWN entry carrying\n * the derived discriminator, while the field holds a bare list of branch names. Rendering that\n * list directly would publish the `oneOf` and silently DROP the discriminator — the one part of a\n * union a client needs to narrow on — so the alias is looked up by its branch list first. This is\n * the same lookup `SchemaRenderer.namedUnion` does to emit its `$ref`.\n */\n private fieldUnion(\n branchNames: readonly string[],\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const key = branchNames.join(',');\n for (const name of this.model.types.keys()) {\n const candidate = this.model.types.get(name)!;\n if (candidate.unionRefNames.length > 0 && candidate.unionRefNames.join(',') === key) {\n return this.unionSchema(candidate, parents);\n }\n }\n const schema = new ApiJsonSchema();\n schema.oneOf = branchNames.map((name: string) =>\n this.objectSchema(this.namedType(name, where), parents),\n );\n return schema;\n }\n\n /**\n * One FIELD: its type, then the prose and the constraints that hang off the field.\n *\n * The ORDER matters: the type is built first and `description` is written over whatever the type\n * produced, so a nested DTO carries the FIELD's sentence rather than the DTO's. `@WpMin` /\n * `@WpMax` land on the numeric LEAF — on an array, on the item — for the same reason\n * `SchemaRenderer` puts them there: a `minimum` on an array means nothing.\n *\n * NULLABLE widens the type to `[T, \"null\"]` and is deliberately NOT the same thing as OPTIONAL,\n * which is an absent entry in the object's `required` list. `{}` and `{externalId: null}` are\n * different wire documents, and an agent told only \"optional\" would send the wrong one.\n */\n private fieldSchema(\n owner: DocumentedType,\n field: DocumentedField,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const where = `${owner.name}.${field.name}`;\n const schema = this.typeSchema(field.type, where, parents);\n const description = field.mcpDescription ?? field.description;\n if (this.requireDescriptions && description.trim() === '') {\n throw new McpRenderError(\n 'a published DTO field has no documentation',\n where,\n 'Write a JSDoc sentence on the field. It is the only thing an agent is told about ' +\n 'that parameter.',\n );\n }\n schema.description = this.prose(description);\n\n const leaf = field.type.kind === 'array' ? schema.items! : schema;\n if (field.min !== undefined) {\n leaf.minimum = field.min;\n }\n if (field.max !== undefined) {\n leaf.maximum = field.max;\n }\n if (field.mcpHeader !== undefined) {\n McpSchemaRenderer.assertHeaderFits(field, schema, where);\n schema['x-mcp-header'] = field.mcpHeader;\n }\n if (field.nullable) {\n schema.type = McpSchemaRenderer.nullable(schema, where);\n if (schema.enum !== undefined && !schema.enum.includes(null)) {\n // JSON Schema checks `enum` independently of `type`: without `null` here the widened\n // type admits null and the enum still rejects it, so a nullable string enum\n // (`x: SomeEnumDto | null`, or `'a' | 'b' | null`) failed output validation (#1197).\n schema.enum = [...schema.enum, null];\n }\n }\n return schema;\n }\n\n /** `T` -> `[T, \"null\"]`, refusing a field with no type at all rather than publishing `[\"null\"]`. */\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static nullable(schema: ApiJsonSchema, where: string): readonly ApiJsonSchemaType[] {\n const base = ApiJsonSchema.baseTypeOf(schema);\n if (base === undefined) {\n throw new McpRenderError(\n 'a nullable field has no other type',\n where,\n 'A field typed only `null` carries no information — give it a real type beside it.',\n );\n }\n return [base, 'null'];\n }\n\n /**\n * `@mcpHeader` mirrors a PRIMITIVE parameter into `Mcp-Param-{name}` (MCP 2026 SEP-2243). The\n * three conditions are the runtime's, restated against the compiler's view of the field, so a\n * declaration the server would reject at boot fails the document build instead.\n */\n // webpieces-disable no-function-outside-class -- private static validator of this class\n private static assertHeaderFits(\n field: DocumentedField,\n schema: ApiJsonSchema,\n where: string,\n ): void {\n if (!HEADER_TOKEN.test(field.mcpHeader!)) {\n throw new McpRenderError(\n `@mcpHeader '${field.mcpHeader}' is not an RFC 9110 token`,\n where,\n 'Use letters, digits and the token punctuation only — it becomes an HTTP header name.',\n );\n }\n if (schema.type !== 'string' && schema.type !== 'boolean' && schema.type !== 'integer') {\n throw new McpRenderError(\n '@mcpHeader is on a field that is not a primitive an MCP header can carry',\n where,\n 'Mirror a string, a boolean or an Integer. A non-integer number and every object ' +\n 'shape are excluded by MCP 2026-07-28.',\n );\n }\n }\n\n /** One resolved type, with no field-level prose or constraints on it. */\n private typeSchema(ref: TypeRef, where: string, parents: ReadonlySet<string>): ApiJsonSchema {\n switch (ref.kind) {\n case 'primitive':\n return McpSchemaRenderer.primitive(ref, where);\n case 'enum': {\n const schema = new ApiJsonSchema('string');\n schema.enum = ref.enumValues.slice();\n return schema;\n }\n case 'array': {\n const schema = new ApiJsonSchema('array');\n schema.items = this.typeSchema(ref.items!, where, parents);\n return schema;\n }\n case 'openMap': {\n const schema = new ApiJsonSchema('object');\n schema.additionalProperties = this.typeSchema(ref.values!, where, parents);\n return schema;\n }\n case 'ref':\n return this.referencedSchema(ref.refName!, where, parents);\n case 'union':\n return this.fieldUnion(ref.unionRefNames, where, parents);\n default:\n throw new McpRenderError(\n `no MCP schema for the declared type '${ref.unmappedText ?? '<unknown>'}'`,\n where,\n 'Give the field a shape the model can represent — a named DTO, an array of one, ' +\n 'a string-literal union, a Record, or a primitive.',\n );\n }\n }\n\n /** A named type: a string enum becomes `enum`, an object DTO is INLINED (MCP has no `$ref`). */\n private referencedSchema(\n name: string,\n where: string,\n parents: ReadonlySet<string>,\n ): ApiJsonSchema {\n const type = this.namedType(name, where);\n if (type.enumValues.length > 0) {\n const schema = new ApiJsonSchema('string');\n schema.enum = type.enumValues.slice();\n return schema;\n }\n return this.objectSchema(type, parents);\n }\n\n // webpieces-disable no-function-outside-class -- private static mapping of this class\n private static primitive(ref: TypeRef, where: string): ApiJsonSchema {\n if (ref.primitive === 'string' || ref.primitive === 'boolean') {\n return new ApiJsonSchema(ref.primitive);\n }\n if (ref.primitive === 'number') {\n return new ApiJsonSchema(ref.integer ? 'integer' : 'number');\n }\n throw new McpRenderError(\n `'${ref.primitive}' has no MCP schema`,\n where,\n 'Give the field a concrete type. `unknown`, `any`, `void` and a bare `null` publish as ' +\n '\"anything\", which an agent cannot fill in.',\n );\n }\n}\n"]}
|