@webpieces/api-doc-model 0.4.934 → 0.4.935
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/extract/ApiDocExtractor.d.ts +4 -4
- package/src/extract/ApiDocExtractor.js +6 -8
- package/src/extract/ApiDocExtractor.js.map +1 -1
- package/src/extract/JsDoc.d.ts +16 -4
- package/src/extract/JsDoc.js +29 -6
- package/src/extract/JsDoc.js.map +1 -1
- package/src/extract/McpMembership.js +2 -2
- package/src/extract/McpMembership.js.map +1 -1
- package/src/extract/McpProfiles.js +7 -0
- package/src/extract/McpProfiles.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +20 -15
- package/src/model/ApiDocModel.js +15 -12
- package/src/model/ApiDocModel.js.map +1 -1
- package/src/model/EndpointSummary.d.ts +20 -0
- package/src/model/EndpointSummary.js +44 -0
- package/src/model/EndpointSummary.js.map +1 -0
- package/src/render/McpSchemaRenderer.js +11 -7
- package/src/render/McpSchemaRenderer.js.map +1 -1
|
@@ -11,6 +11,13 @@ class McpProfiles {
|
|
|
11
11
|
read(argument, folder) {
|
|
12
12
|
if (argument === undefined)
|
|
13
13
|
return [core_util_1.Mcp.DEFAULT];
|
|
14
|
+
if (ts.isStringLiteralLike(argument)) {
|
|
15
|
+
// The pre-#1296 spelling `@WpMcpTool(name, title)`. It no longer compiles; say where the
|
|
16
|
+
// title went rather than calling a title "malformed profile options".
|
|
17
|
+
throw new ApiDocExtractionError_1.ApiDocExtractionError('@WpMcpTool takes no title argument (#1296)', SourceLocation_1.SourceLocation.of(argument), "Delete the second argument and write the title as the method's JSDoc `@summary` line " +
|
|
18
|
+
'— one line, at most 100 characters. It is published as OpenAPI summary and MCP ' +
|
|
19
|
+
'title / annotations.title.');
|
|
20
|
+
}
|
|
14
21
|
const options = folder.follow(argument);
|
|
15
22
|
if (!ts.isObjectLiteralExpression(options))
|
|
16
23
|
return this.invalid(argument);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpProfiles.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/McpProfiles.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,oDAA2C;AAE3C,mEAAgE;AAChE,qDAAkD;AAElD,4FAA4F;AAC5F,MAAa,WAAW;IACpB,IAAI,CAAC,QAAmC,EAAE,MAAsB;QAC5D,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,eAAG,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAI,QAAmC,CAAC;QACxC,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACxC,IACI,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;gBACjC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,UAAU,EAC7D,CAAC;gBACC,IAAI,QAAQ,KAAK,SAAS;oBAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC;YACpC,CAAC;iBAAM,IACH,EAAE,CAAC,6BAA6B,CAAC,QAAQ,CAAC;gBAC1C,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EACnC,CAAC;gBACC,IAAI,QAAQ,KAAK,SAAS;oBAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC7B,CA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AC;QACrC,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtE,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAoB,EAAE,EAAE,CACrD,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAC1C,CAAC;QACF,OAAO,eAAG,CAAC,QAAQ,CACf,KAAK,EACL,YAAY,EACZ,CAAC,OAAe,EAAE,EAAE,CAChB,IAAI,6CAAqB,CACrB,OAAO,EACP,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,wHAAwH,CAC3H,CACR,CAAC;IACN,CAAC;IAEO,OAAO,CAAC,IAAa;QACzB,MAAM,IAAI,6CAAqB,CAC3B,sCAAsC,EACtC,+BAAc,CAAC,EAAE,CAAC,IAAI,CAAC,EACvB,0GAA0G,CAC7G,CAAC;IACN,CAAC;CACJ;AAzDD,kCAyDC","sourcesContent":["import * as ts from 'typescript';\nimport { Mcp } from '@webpieces/core-util';\nimport { ConstantFolder } from './ConstantFolder';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { SourceLocation } from './SourceLocation';\n\n/** Reads authored membership without executing contract code or guessing runtime values. */\nexport class McpProfiles {\n read(argument: ts.Expression | undefined, folder: ConstantFolder): readonly string[] {\n if (argument === undefined) return [Mcp.DEFAULT];\n if (ts.isStringLiteralLike(argument)) {\n // The pre-#1296 spelling `@WpMcpTool(name, title)`. It no longer compiles; say where the\n // title went rather than calling a title \"malformed profile options\".\n throw new ApiDocExtractionError(\n '@WpMcpTool takes no title argument (#1296)',\n SourceLocation.of(argument),\n \"Delete the second argument and write the title as the method's JSDoc `@summary` line \" +\n '— one line, at most 100 characters. It is published as OpenAPI summary and MCP ' +\n 'title / annotations.title.',\n );\n }\n const options = folder.follow(argument);\n if (!ts.isObjectLiteralExpression(options)) return this.invalid(argument);\n let profiles: ts.Expression | undefined;\n for (const property of options.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n property.name.getText().replace(/['\"]/g, '') === 'profiles'\n ) {\n if (profiles !== undefined) return this.invalid(property);\n profiles = property.initializer;\n } else if (\n ts.isShorthandPropertyAssignment(property) &&\n property.name.text === 'profiles'\n ) {\n if (profiles !== undefined) return this.invalid(property);\n profiles = property.name;\n } else return this.invalid(property);\n }\n if (profiles === undefined) return [Mcp.DEFAULT];\n const list = folder.follow(profiles);\n if (!ts.isArrayLiteralExpression(list)) return this.invalid(profiles);\n const names = list.elements.map((entry: ts.Expression) =>\n folder.foldString(entry, 'MCP profile'),\n );\n return Mcp.profiles(\n names,\n '@WpMcpTool',\n (message: string) =>\n new ApiDocExtractionError(\n message,\n SourceLocation.of(argument),\n 'Use a non-empty array of unique profile identifiers matching [a-z][a-z0-9-]{0,63}; use Mcp.DEFAULT for the base group.',\n ),\n );\n }\n\n private invalid(node: ts.Node): never {\n throw new ApiDocExtractionError(\n 'Malformed @WpMcpTool profile options',\n SourceLocation.of(node),\n \"Write { profiles: [Mcp.DEFAULT, 'admin'] } with constant identifiers; omit options for only Mcp.DEFAULT.\",\n );\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';
|
|
|
16
16
|
export { ApiComponentsModel, ApiDocModel, DocumentedApiKey, DocumentedApiKeyCredential, DocumentedAuth, DocumentedAuthMethod, DocumentedEndpoint, DocumentedEndpointOptions, DocumentedField, DocumentedMcpTool, DocumentedType, StackedJsDoc, TypeNameCollision, UnionDiscriminator, UnmappedType, } from './model/ApiDocModel';
|
|
17
17
|
export { McpRenderError } from './render/McpRenderError';
|
|
18
18
|
export { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';
|
|
19
|
+
export { EndpointSummary } from './model/EndpointSummary';
|
|
19
20
|
export { TypeRef } from './model/TypeRef';
|
|
20
21
|
export type { PrimitiveKind, TypeRefKind } from './model/TypeRef';
|
|
21
22
|
export { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamingSchemaRenderer = exports.TypeRef = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.StackedJsDoc = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuthMethod = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ContextKeyHeaderSlot = exports.ApiDocExtractionError = exports.SchemaNameEntry = exports.SchemaNames = exports.ApiDocExtractor = void 0;
|
|
3
|
+
exports.StreamingSchemaRenderer = exports.TypeRef = exports.EndpointSummary = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.StackedJsDoc = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuthMethod = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ContextKeyHeaderSlot = exports.ApiDocExtractionError = exports.SchemaNameEntry = exports.SchemaNames = exports.ApiDocExtractor = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and
|
|
6
6
|
* produce ONE in-memory {@link ApiDocModel}.
|
|
@@ -45,6 +45,8 @@ var McpSchemaRenderer_1 = require("./render/McpSchemaRenderer");
|
|
|
45
45
|
Object.defineProperty(exports, "McpCatalogRender", { enumerable: true, get: function () { return McpSchemaRenderer_1.McpCatalogRender; } });
|
|
46
46
|
Object.defineProperty(exports, "McpSchemaRenderer", { enumerable: true, get: function () { return McpSchemaRenderer_1.McpSchemaRenderer; } });
|
|
47
47
|
Object.defineProperty(exports, "SkippedMcpTool", { enumerable: true, get: function () { return McpSchemaRenderer_1.SkippedMcpTool; } });
|
|
48
|
+
var EndpointSummary_1 = require("./model/EndpointSummary");
|
|
49
|
+
Object.defineProperty(exports, "EndpointSummary", { enumerable: true, get: function () { return EndpointSummary_1.EndpointSummary; } });
|
|
48
50
|
var TypeRef_1 = require("./model/TypeRef");
|
|
49
51
|
Object.defineProperty(exports, "TypeRef", { enumerable: true, get: function () { return TypeRef_1.TypeRef; } });
|
|
50
52
|
var StreamingSchemaRenderer_1 = require("./render/StreamingSchemaRenderer");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,mDAAmE;AAA1D,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AACrC,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,2EAAwE;AAA/D,8HAAA,oBAAoB,OAAA;AAC7B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAgB6B;AAfzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,4EAA2E;AAAlE,kIAAA,uBAAuB,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { SchemaNames, SchemaNameEntry } from './model/SchemaNames';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { ContextKeyHeaderSlot } from './extract/ContextKeyHeaderFolder';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\nexport { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/api-doc-model/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,6DAA4D;AAAnD,kHAAA,eAAe,OAAA;AACxB,mDAAmE;AAA1D,0GAAA,WAAW,OAAA;AAAE,8GAAA,eAAe,OAAA;AACrC,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,2EAAwE;AAA/D,8HAAA,oBAAoB,OAAA;AAC7B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAgB6B;AAfzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,2GAAA,YAAY,OAAA;AAEhB,0DAAyD;AAAhD,gHAAA,cAAc,OAAA;AACvB,gEAAiG;AAAxF,qHAAA,gBAAgB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAAE,mHAAA,cAAc,OAAA;AAC5D,2DAA0D;AAAjD,kHAAA,eAAe,OAAA;AACxB,2CAA0C;AAAjC,kGAAA,OAAO,OAAA;AAEhB,4EAA2E;AAAlE,kIAAA,uBAAuB,OAAA","sourcesContent":["/**\n * `@webpieces/api-doc-model` — read a webpieces API contract with the TypeScript compiler API and\n * produce ONE in-memory {@link ApiDocModel}.\n *\n * This is the single extraction pass both the OpenAPI documents and the MCP tool list (#982) are\n * rendered from. It emits nothing itself, and it takes every decorator NAME it matches on from the\n * real `@webpieces/core-util` symbol — so renaming a decorator is a compile error here rather than a\n * literal that quietly stops matching and empties a document (issue #1001). See\n * `responsibilities.md` for why that import is not the coupling it looks like.\n */\nexport { ApiDocExtractor } from './extract/ApiDocExtractor';\nexport { SchemaNames, SchemaNameEntry } from './model/SchemaNames';\nexport { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { ContextKeyHeaderSlot } from './extract/ContextKeyHeaderFolder';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\n StackedJsDoc,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from './model/ApiDocModel';\nexport { McpRenderError } from './render/McpRenderError';\nexport { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';\nexport { EndpointSummary } from './model/EndpointSummary';\nexport { TypeRef } from './model/TypeRef';\nexport type { PrimitiveKind, TypeRefKind } from './model/TypeRef';\nexport { StreamingSchemaRenderer } from './render/StreamingSchemaRenderer';\n"]}
|
|
@@ -255,15 +255,16 @@ export declare class DocumentedEndpointOptions {
|
|
|
255
255
|
calledBy: string | undefined, callerKind: string | undefined);
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
|
-
* The `@WpMcpTool('search_stores'
|
|
259
|
-
*
|
|
258
|
+
* The `@WpMcpTool('search_stores')` declaration, when the method carries one — the ONE fact the source
|
|
259
|
+
* cannot otherwise state, plus the profile groups it is listed in.
|
|
260
260
|
*
|
|
261
261
|
* `description` used to sit on the decorator too. The method's JSDoc is the description, for the
|
|
262
262
|
* agent and for the partner alike, byte-identical: two authored copies of one paragraph is the
|
|
263
263
|
* two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI
|
|
264
264
|
* document while the agent reads the decorator string in `tools/list`, and they drift the first time
|
|
265
|
-
* somebody edits one. #984 deleted it. #1180 added the
|
|
266
|
-
*
|
|
265
|
+
* somebody edits one. #984 deleted it. The `title` argument #1180 added went the same way in #1296:
|
|
266
|
+
* the tool's title is the method's `@summary` ({@link DocumentedEndpoint.summary}), the same line the
|
|
267
|
+
* OpenAPI operation publishes as its `summary`.
|
|
267
268
|
*
|
|
268
269
|
* The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`
|
|
269
270
|
* in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |
|
|
@@ -276,23 +277,13 @@ export declare class DocumentedMcpTool {
|
|
|
276
277
|
* method must not break a saved agent workflow.
|
|
277
278
|
*/
|
|
278
279
|
readonly name: string;
|
|
279
|
-
/**
|
|
280
|
-
* The human-readable display name, published as `Tool.title` and `annotations.title`. The
|
|
281
|
-
* EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.
|
|
282
|
-
*/
|
|
283
|
-
readonly title: string;
|
|
284
280
|
readonly profiles: readonly string[];
|
|
285
281
|
constructor(
|
|
286
282
|
/**
|
|
287
283
|
* The STABLE protocol name. Deliberately independent of the method name, because renaming a
|
|
288
284
|
* method must not break a saved agent workflow.
|
|
289
285
|
*/
|
|
290
|
-
name: string,
|
|
291
|
-
/**
|
|
292
|
-
* The human-readable display name, published as `Tool.title` and `annotations.title`. The
|
|
293
|
-
* EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.
|
|
294
|
-
*/
|
|
295
|
-
title: string, profiles: readonly string[]);
|
|
286
|
+
name: string, profiles: readonly string[]);
|
|
296
287
|
}
|
|
297
288
|
/**
|
|
298
289
|
* ONE credential of an api-key regime, PARSED — `{ in: 'header', key: MyKeys.API_KEY }` or
|
|
@@ -397,6 +388,13 @@ export declare class DocumentedEndpoint {
|
|
|
397
388
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
398
389
|
readonly maskLog: ReadonlyMap<string, string>;
|
|
399
390
|
readonly description: string;
|
|
391
|
+
/**
|
|
392
|
+
* The method's `@summary` text — its one-line short title (#1296): the OpenAPI operation's
|
|
393
|
+
* `summary` and, for a tool, MCP `Tool.title` AND `annotations.title`. Undefined when the method
|
|
394
|
+
* has none; the OpenAPI generator refuses that for every published operation, and the MCP
|
|
395
|
+
* renderer refuses a tool without one.
|
|
396
|
+
*/
|
|
397
|
+
readonly summary: string | undefined;
|
|
400
398
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
401
399
|
readonly mcpDescription: string | undefined;
|
|
402
400
|
/**
|
|
@@ -448,6 +446,13 @@ export declare class DocumentedEndpoint {
|
|
|
448
446
|
authorizationText: string | undefined,
|
|
449
447
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
450
448
|
maskLog: ReadonlyMap<string, string>, description: string,
|
|
449
|
+
/**
|
|
450
|
+
* The method's `@summary` text — its one-line short title (#1296): the OpenAPI operation's
|
|
451
|
+
* `summary` and, for a tool, MCP `Tool.title` AND `annotations.title`. Undefined when the method
|
|
452
|
+
* has none; the OpenAPI generator refuses that for every published operation, and the MCP
|
|
453
|
+
* renderer refuses a tool without one.
|
|
454
|
+
*/
|
|
455
|
+
summary: string | undefined,
|
|
451
456
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
452
457
|
mcpDescription: string | undefined,
|
|
453
458
|
/**
|
package/src/model/ApiDocModel.js
CHANGED
|
@@ -244,15 +244,16 @@ class DocumentedEndpointOptions {
|
|
|
244
244
|
}
|
|
245
245
|
exports.DocumentedEndpointOptions = DocumentedEndpointOptions;
|
|
246
246
|
/**
|
|
247
|
-
* The `@WpMcpTool('search_stores'
|
|
248
|
-
*
|
|
247
|
+
* The `@WpMcpTool('search_stores')` declaration, when the method carries one — the ONE fact the source
|
|
248
|
+
* cannot otherwise state, plus the profile groups it is listed in.
|
|
249
249
|
*
|
|
250
250
|
* `description` used to sit on the decorator too. The method's JSDoc is the description, for the
|
|
251
251
|
* agent and for the partner alike, byte-identical: two authored copies of one paragraph is the
|
|
252
252
|
* two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI
|
|
253
253
|
* document while the agent reads the decorator string in `tools/list`, and they drift the first time
|
|
254
|
-
* somebody edits one. #984 deleted it. #1180 added the
|
|
255
|
-
*
|
|
254
|
+
* somebody edits one. #984 deleted it. The `title` argument #1180 added went the same way in #1296:
|
|
255
|
+
* the tool's title is the method's `@summary` ({@link DocumentedEndpoint.summary}), the same line the
|
|
256
|
+
* OpenAPI operation publishes as its `summary`.
|
|
256
257
|
*
|
|
257
258
|
* The three side-effect hints are COMPUTED from the endpoint's `operation` by `mcpHintsForOperation`
|
|
258
259
|
* in `@webpieces/core-util`, which is the one place that mapping lives — `READ | WRITE_IDEMPOTENT |
|
|
@@ -261,21 +262,14 @@ exports.DocumentedEndpointOptions = DocumentedEndpointOptions;
|
|
|
261
262
|
*/
|
|
262
263
|
class DocumentedMcpTool {
|
|
263
264
|
name;
|
|
264
|
-
title;
|
|
265
265
|
profiles;
|
|
266
266
|
constructor(
|
|
267
267
|
/**
|
|
268
268
|
* The STABLE protocol name. Deliberately independent of the method name, because renaming a
|
|
269
269
|
* method must not break a saved agent workflow.
|
|
270
270
|
*/
|
|
271
|
-
name,
|
|
272
|
-
/**
|
|
273
|
-
* The human-readable display name, published as `Tool.title` and `annotations.title`. The
|
|
274
|
-
* EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.
|
|
275
|
-
*/
|
|
276
|
-
title, profiles) {
|
|
271
|
+
name, profiles) {
|
|
277
272
|
this.name = name;
|
|
278
|
-
this.title = title;
|
|
279
273
|
this.profiles = profiles;
|
|
280
274
|
}
|
|
281
275
|
}
|
|
@@ -362,6 +356,7 @@ class DocumentedEndpoint {
|
|
|
362
356
|
authorizationText;
|
|
363
357
|
maskLog;
|
|
364
358
|
description;
|
|
359
|
+
summary;
|
|
365
360
|
mcpDescription;
|
|
366
361
|
returnsDescription;
|
|
367
362
|
request;
|
|
@@ -407,6 +402,13 @@ class DocumentedEndpoint {
|
|
|
407
402
|
authorizationText,
|
|
408
403
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
409
404
|
maskLog, description,
|
|
405
|
+
/**
|
|
406
|
+
* The method's `@summary` text — its one-line short title (#1296): the OpenAPI operation's
|
|
407
|
+
* `summary` and, for a tool, MCP `Tool.title` AND `annotations.title`. Undefined when the method
|
|
408
|
+
* has none; the OpenAPI generator refuses that for every published operation, and the MCP
|
|
409
|
+
* renderer refuses a tool without one.
|
|
410
|
+
*/
|
|
411
|
+
summary,
|
|
410
412
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
411
413
|
mcpDescription,
|
|
412
414
|
/**
|
|
@@ -429,6 +431,7 @@ class DocumentedEndpoint {
|
|
|
429
431
|
this.authorizationText = authorizationText;
|
|
430
432
|
this.maskLog = maskLog;
|
|
431
433
|
this.description = description;
|
|
434
|
+
this.summary = summary;
|
|
432
435
|
this.mcpDescription = mcpDescription;
|
|
433
436
|
this.returnsDescription = returnsDescription;
|
|
434
437
|
this.request = request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;GAQG;AAEH,qGAAqG;AACrG,MAAa,YAAY;IAGR;IAEA;IAEA;IANb;IACI,qEAAqE;IAC5D,QAAgB;IACzB,sDAAsD;IAC7C,QAAgB;IACzB,wEAAwE;IAC/D,MAAc;QAJd,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,WAAM,GAAN,MAAM,CAAQ;IACxB,CAAC;CACP;AATD,oCASC;AAED;;;;;;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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, links flattened. 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', 'Search stores')` declaration, when the method carries one — the\n * TWO facts the source cannot otherwise state, and nothing else.\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. #1180 added the REQUIRED `title`, the short display name\n * clients and the Claude Connectors Directory show — a name, not a second copy of the description.\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 /**\n * The human-readable display name, published as `Tool.title` and `annotations.title`. The\n * EMPTY STRING when the argument does not fold to a string; the MCP renderer refuses that.\n */\n readonly title: 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 /** 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, links flattened. */\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/doc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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, links flattened. 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, links flattened. */\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"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE rule for an endpoint's `@summary` JSDoc tag (#1296): present, one line, at most 100 characters.
|
|
3
|
+
*
|
|
4
|
+
* The summary is the endpoint's short title. It is published as the OpenAPI operation `summary` — what
|
|
5
|
+
* a docs site heads the page with and labels the sidebar with — and as MCP `Tool.title` and
|
|
6
|
+
* `annotations.title`, which clients and the Claude Connectors Directory show. A heading and a sidebar
|
|
7
|
+
* label is one line, so a second line is refused rather than joined, and 100 characters is a house
|
|
8
|
+
* rule (no spec sets one) that keeps it a label rather than a sentence.
|
|
9
|
+
*
|
|
10
|
+
* It is here, beside the model, so the OpenAPI generator's guard, the MCP renderer and
|
|
11
|
+
* `api-rules-for-mcp` all ask the SAME question of the same text.
|
|
12
|
+
*/
|
|
13
|
+
export declare class EndpointSummary {
|
|
14
|
+
/** The longest summary a heading or sidebar label should carry. */
|
|
15
|
+
static readonly MAX_LENGTH = 100;
|
|
16
|
+
/** What is wrong with `summary`, in one clause, or undefined when it is a legal summary. */
|
|
17
|
+
static problemWith(summary: string | undefined): string | undefined;
|
|
18
|
+
/** The one cure every refusal of a summary prints. */
|
|
19
|
+
static cure(): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointSummary = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* THE rule for an endpoint's `@summary` JSDoc tag (#1296): present, one line, at most 100 characters.
|
|
6
|
+
*
|
|
7
|
+
* The summary is the endpoint's short title. It is published as the OpenAPI operation `summary` — what
|
|
8
|
+
* a docs site heads the page with and labels the sidebar with — and as MCP `Tool.title` and
|
|
9
|
+
* `annotations.title`, which clients and the Claude Connectors Directory show. A heading and a sidebar
|
|
10
|
+
* label is one line, so a second line is refused rather than joined, and 100 characters is a house
|
|
11
|
+
* rule (no spec sets one) that keeps it a label rather than a sentence.
|
|
12
|
+
*
|
|
13
|
+
* It is here, beside the model, so the OpenAPI generator's guard, the MCP renderer and
|
|
14
|
+
* `api-rules-for-mcp` all ask the SAME question of the same text.
|
|
15
|
+
*/
|
|
16
|
+
class EndpointSummary {
|
|
17
|
+
/** The longest summary a heading or sidebar label should carry. */
|
|
18
|
+
static MAX_LENGTH = 100;
|
|
19
|
+
/** What is wrong with `summary`, in one clause, or undefined when it is a legal summary. */
|
|
20
|
+
// webpieces-disable no-function-outside-class -- static helper of this class; the rule has no state
|
|
21
|
+
static problemWith(summary) {
|
|
22
|
+
if (summary === undefined || summary.trim() === '') {
|
|
23
|
+
return 'has no @summary';
|
|
24
|
+
}
|
|
25
|
+
if (/[\r\n]/.test(summary)) {
|
|
26
|
+
return '@summary spans more than one line';
|
|
27
|
+
}
|
|
28
|
+
if (summary.length > EndpointSummary.MAX_LENGTH) {
|
|
29
|
+
return `@summary is ${summary.length} characters, over the ${EndpointSummary.MAX_LENGTH}-character limit`;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The one cure every refusal of a summary prints. */
|
|
34
|
+
// webpieces-disable no-function-outside-class -- static helper of this class; the rule has no state
|
|
35
|
+
static cure() {
|
|
36
|
+
return ("Write a `@summary <short title>` line in the method's JSDoc: one line, at most " +
|
|
37
|
+
`${EndpointSummary.MAX_LENGTH} characters, e.g. \`@summary Fetch your orders\`. It is ` +
|
|
38
|
+
"published as the OpenAPI operation's summary (a docs site's page heading and sidebar " +
|
|
39
|
+
'label) and as the MCP tool title and annotations.title; the rest of the JSDoc stays the ' +
|
|
40
|
+
'description.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.EndpointSummary = EndpointSummary;
|
|
44
|
+
//# sourceMappingURL=EndpointSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointSummary.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/EndpointSummary.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,MAAa,eAAe;IACxB,mEAAmE;IACnE,MAAM,CAAU,UAAU,GAAG,GAAG,CAAC;IAEjC,4FAA4F;IAC5F,oGAAoG;IACpG,MAAM,CAAC,WAAW,CAAC,OAA2B;QAC1C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACjD,OAAO,iBAAiB,CAAC;QAC7B,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,OAAO,mCAAmC,CAAC;QAC/C,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC,UAAU,EAAE,CAAC;YAC9C,OAAO,eAAe,OAAO,CAAC,MAAM,yBAAyB,eAAe,CAAC,UAAU,kBAAkB,CAAC;QAC9G,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,sDAAsD;IACtD,oGAAoG;IACpG,MAAM,CAAC,IAAI;QACP,OAAO,CACH,iFAAiF;YACjF,GAAG,eAAe,CAAC,UAAU,0DAA0D;YACvF,uFAAuF;YACvF,0FAA0F;YAC1F,cAAc,CACjB,CAAC;IACN,CAAC;;AA7BL,0CA8BC","sourcesContent":["/**\n * THE rule for an endpoint's `@summary` JSDoc tag (#1296): present, one line, at most 100 characters.\n *\n * The summary is the endpoint's short title. It is published as the OpenAPI operation `summary` — what\n * a docs site heads the page with and labels the sidebar with — and as MCP `Tool.title` and\n * `annotations.title`, which clients and the Claude Connectors Directory show. A heading and a sidebar\n * label is one line, so a second line is refused rather than joined, and 100 characters is a house\n * rule (no spec sets one) that keeps it a label rather than a sentence.\n *\n * It is here, beside the model, so the OpenAPI generator's guard, the MCP renderer and\n * `api-rules-for-mcp` all ask the SAME question of the same text.\n */\nexport class EndpointSummary {\n /** The longest summary a heading or sidebar label should carry. */\n static readonly MAX_LENGTH = 100;\n\n /** What is wrong with `summary`, in one clause, or undefined when it is a legal summary. */\n // webpieces-disable no-function-outside-class -- static helper of this class; the rule has no state\n static problemWith(summary: string | undefined): string | undefined {\n if (summary === undefined || summary.trim() === '') {\n return 'has no @summary';\n }\n if (/[\\r\\n]/.test(summary)) {\n return '@summary spans more than one line';\n }\n if (summary.length > EndpointSummary.MAX_LENGTH) {\n return `@summary is ${summary.length} characters, over the ${EndpointSummary.MAX_LENGTH}-character limit`;\n }\n return undefined;\n }\n\n /** The one cure every refusal of a summary prints. */\n // webpieces-disable no-function-outside-class -- static helper of this class; the rule has no state\n static cure(): string {\n return (\n \"Write a `@summary <short title>` line in the method's JSDoc: one line, at most \" +\n `${EndpointSummary.MAX_LENGTH} characters, e.g. \\`@summary Fetch your orders\\`. It is ` +\n \"published as the OpenAPI operation's summary (a docs site's page heading and sidebar \" +\n 'label) and as the MCP tool title and annotations.title; the rest of the JSDoc stays the ' +\n 'description.'\n );\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.McpSchemaRenderer = exports.McpCatalogRender = exports.SkippedMcpTool = void 0;
|
|
4
4
|
const core_util_1 = require("@webpieces/core-util");
|
|
5
|
+
const EndpointSummary_1 = require("../model/EndpointSummary");
|
|
5
6
|
const McpRenderError_1 = require("./McpRenderError");
|
|
6
7
|
/** RFC 9110 token, which is what an `Mcp-Param-{name}` header name has to be. */
|
|
7
8
|
const HEADER_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
@@ -145,7 +146,7 @@ class McpSchemaRenderer {
|
|
|
145
146
|
const owner = owners.get(tool.name);
|
|
146
147
|
if (owner !== undefined && owner !== contractName) {
|
|
147
148
|
throw new core_util_1.McpToolCatalogError(`Duplicate MCP tool name '${tool.name}': declared by both ${owner} and ${contractName}.`, 'Tool names are the protocol identity and must be globally unique — rename one ' +
|
|
148
|
-
"of the two @WpMcpTool('<name>'
|
|
149
|
+
"of the two @WpMcpTool('<name>') declarations.");
|
|
149
150
|
}
|
|
150
151
|
owners.set(tool.name, contractName);
|
|
151
152
|
}
|
|
@@ -161,13 +162,16 @@ class McpSchemaRenderer {
|
|
|
161
162
|
if (endpoint.request === undefined || endpoint.response === undefined) {
|
|
162
163
|
throw new McpRenderError_1.McpRenderError('an MCP tool has no declared request or response type', where, 'Declare both: one request parameter and a Promise<Response> return type.');
|
|
163
164
|
}
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
throw new McpRenderError_1.McpRenderError(
|
|
167
|
-
|
|
168
|
-
'(#1180); never derive it from the name.');
|
|
165
|
+
const summaryProblem = EndpointSummary_1.EndpointSummary.problemWith(endpoint.summary);
|
|
166
|
+
if (summaryProblem !== undefined) {
|
|
167
|
+
throw new McpRenderError_1.McpRenderError(`an MCP tool ${summaryProblem}, so it has no title`, where, `${EndpointSummary_1.EndpointSummary.cure()} tools/list publishes it as title and annotations.title ` +
|
|
168
|
+
'(#1296); it is never derived from the tool name.');
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
const nameProblem = core_util_1.McpToolName.problemWith(endpoint.mcpTool.name);
|
|
171
|
+
if (nameProblem !== undefined) {
|
|
172
|
+
throw new McpRenderError_1.McpRenderError(`the MCP tool name '${endpoint.mcpTool.name}' ${nameProblem}`, where, core_util_1.McpToolName.cure());
|
|
173
|
+
}
|
|
174
|
+
return new core_util_1.McpToolDefinition(endpoint.mcpTool.name, endpoint.summary, endpoint.methodName, description, (0, core_util_1.mcpHintsForOperation)(McpSchemaRenderer.operationOf(endpoint, where), endpoint.openWorld), this.rootSchema(endpoint.request, where, 'request', undefined), this.rootSchema(endpoint.response, where, 'response', endpoint.returnsDescription), endpoint.mcpTool.profiles);
|
|
171
175
|
}
|
|
172
176
|
/**
|
|
173
177
|
* `operation` verbatim from the model, mapped back onto the REAL constant.
|