@webpieces/api-doc-model 0.4.802 → 0.4.804
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 -1
- package/src/extract/ApiDocExtractor.d.ts +61 -7
- package/src/extract/ApiDocExtractor.js +235 -39
- package/src/extract/ApiDocExtractor.js.map +1 -1
- package/src/extract/ConstantFolder.d.ts +16 -3
- package/src/extract/ConstantFolder.js +42 -3
- package/src/extract/ConstantFolder.js.map +1 -1
- package/src/extract/TypeResolver.d.ts +9 -0
- package/src/extract/TypeResolver.js +31 -6
- package/src/extract/TypeResolver.js.map +1 -1
- package/src/index.d.ts +5 -4
- package/src/index.js +7 -4
- package/src/index.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +139 -12
- package/src/model/ApiDocModel.js +115 -13
- package/src/model/ApiDocModel.js.map +1 -1
|
@@ -112,7 +112,7 @@ export declare class DocumentedType {
|
|
|
112
112
|
/** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
|
|
113
113
|
indexSignatureValue: TypeRef | undefined);
|
|
114
114
|
}
|
|
115
|
-
/** `@Endpoint(path, kind, options?)`'s
|
|
115
|
+
/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */
|
|
116
116
|
export declare class DocumentedEndpointOptions {
|
|
117
117
|
readonly formPost: boolean;
|
|
118
118
|
/** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */
|
|
@@ -122,35 +122,127 @@ export declare class DocumentedEndpointOptions {
|
|
|
122
122
|
/** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */
|
|
123
123
|
calledBy: string | undefined, callerKind: string | undefined);
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* The `@WpMcpTool(...)` declaration, when the method carries one — the TWO facts the source cannot
|
|
127
|
+
* otherwise state, and nothing else.
|
|
128
|
+
*
|
|
129
|
+
* `description` is deliberately NOT read off the decorator. The method's JSDoc is the description, for
|
|
130
|
+
* the agent and for the partner alike, byte-identical: two authored copies of one paragraph is the
|
|
131
|
+
* two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI
|
|
132
|
+
* document while the agent reads the decorator string in `tools/list`, and they drift the first time
|
|
133
|
+
* somebody edits one. (The field still exists on the decorator; #984 deletes it across its 29 call
|
|
134
|
+
* sites. Nothing here reads it, so nothing here depends on a field that is about to disappear.)
|
|
135
|
+
*
|
|
136
|
+
* The three side-effect hints are not read either: they are COMPUTED from the endpoint's `operation`
|
|
137
|
+
* by `mcpHintsForOperation` in `@webpieces/core-util`, which is the one place that mapping lives.
|
|
138
|
+
* `READ | WRITE_IDEMPOTENT | WRITE` already says whether repeating a call is safe, so a hand-declared
|
|
139
|
+
* hint would be a second answer to a question the contract has answered.
|
|
140
|
+
*/
|
|
126
141
|
export declare class DocumentedMcpTool {
|
|
142
|
+
/**
|
|
143
|
+
* The STABLE protocol name. Deliberately independent of the method name, because renaming a
|
|
144
|
+
* method must not break a saved agent workflow.
|
|
145
|
+
*/
|
|
127
146
|
readonly name: string;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
constructor(
|
|
148
|
+
/**
|
|
149
|
+
* The STABLE protocol name. Deliberately independent of the method name, because renaming a
|
|
150
|
+
* method must not break a saved agent workflow.
|
|
151
|
+
*/
|
|
152
|
+
name: string);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* ONE credential of an api-key regime, PARSED — `{ in: 'header', name: 'x-api-key' }` or
|
|
156
|
+
* `{ in: 'bearer' }`.
|
|
157
|
+
*
|
|
158
|
+
* Parsed rather than left as source text because it is the one auth argument a renderer must turn
|
|
159
|
+
* into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or
|
|
160
|
+
* `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string
|
|
161
|
+
* `"{ in: 'header', name: 'x-api-key' }"` would have to parse TypeScript to emit either one, which
|
|
162
|
+
* is this package's job and not a renderer's.
|
|
163
|
+
*/
|
|
164
|
+
export declare class DocumentedApiKeyCredential {
|
|
165
|
+
/** `header` or `bearer`, verbatim from the declaration. */
|
|
166
|
+
readonly location: string;
|
|
167
|
+
/** The header name. Undefined for `bearer`, whose location IS `Authorization`. */
|
|
168
|
+
readonly name: string | undefined;
|
|
169
|
+
/** The prose a docs site renders on its authorization card. */
|
|
170
|
+
readonly description: string | undefined;
|
|
171
|
+
constructor(
|
|
172
|
+
/** `header` or `bearer`, verbatim from the declaration. */
|
|
173
|
+
location: string,
|
|
174
|
+
/** The header name. Undefined for `bearer`, whose location IS `Authorization`. */
|
|
175
|
+
name: string | undefined,
|
|
176
|
+
/** The prose a docs site renders on its authorization card. */
|
|
177
|
+
description: string | undefined);
|
|
178
|
+
}
|
|
179
|
+
/** `@WpAuthApiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */
|
|
180
|
+
export declare class DocumentedApiKey {
|
|
181
|
+
readonly regime: string;
|
|
182
|
+
/**
|
|
183
|
+
* Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them
|
|
184
|
+
* are presented together — and the order is the order a published document lists them in.
|
|
185
|
+
*/
|
|
186
|
+
readonly credentials: readonly DocumentedApiKeyCredential[];
|
|
187
|
+
constructor(regime: string,
|
|
188
|
+
/**
|
|
189
|
+
* Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them
|
|
190
|
+
* are presented together — and the order is the order a published document lists them in.
|
|
191
|
+
*/
|
|
192
|
+
credentials: readonly DocumentedApiKeyCredential[]);
|
|
133
193
|
}
|
|
134
194
|
/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */
|
|
135
195
|
export declare class DocumentedAuth {
|
|
136
196
|
/** The decorator name as written, e.g. `WpAuthJwt`. */
|
|
137
197
|
readonly decorator: string;
|
|
138
|
-
/**
|
|
139
|
-
readonly
|
|
198
|
+
/** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */
|
|
199
|
+
readonly argumentTexts: readonly string[];
|
|
200
|
+
/**
|
|
201
|
+
* The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's
|
|
202
|
+
* argument is prose or a role list that a document quotes rather than restructures, so
|
|
203
|
+
* {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why
|
|
204
|
+
* this one is different.
|
|
205
|
+
*/
|
|
206
|
+
readonly apiKey: DocumentedApiKey | undefined;
|
|
140
207
|
constructor(
|
|
141
208
|
/** The decorator name as written, e.g. `WpAuthJwt`. */
|
|
142
209
|
decorator: string,
|
|
143
|
-
/**
|
|
144
|
-
|
|
210
|
+
/** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */
|
|
211
|
+
argumentTexts: readonly string[],
|
|
212
|
+
/**
|
|
213
|
+
* The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's
|
|
214
|
+
* argument is prose or a role list that a document quotes rather than restructures, so
|
|
215
|
+
* {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why
|
|
216
|
+
* this one is different.
|
|
217
|
+
*/
|
|
218
|
+
apiKey: DocumentedApiKey | undefined);
|
|
145
219
|
}
|
|
146
220
|
/** One `@Endpoint` method of one contract. */
|
|
147
221
|
export declare class DocumentedEndpoint {
|
|
148
222
|
readonly methodName: string;
|
|
223
|
+
/**
|
|
224
|
+
* `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
|
|
225
|
+
* written without it — the verb is the key an operation hangs under in `paths`.
|
|
226
|
+
*/
|
|
227
|
+
readonly httpMethod: string;
|
|
149
228
|
/** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
|
|
150
229
|
readonly path: string;
|
|
230
|
+
/**
|
|
231
|
+
* `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is
|
|
232
|
+
* independent of the verb: webpieces POSTs a read. A renderer publishes it rather than
|
|
233
|
+
* inferring safety from the verb, which for this framework would be wrong.
|
|
234
|
+
*/
|
|
235
|
+
readonly operation: string;
|
|
151
236
|
/** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
|
|
152
237
|
readonly kind: string;
|
|
238
|
+
/**
|
|
239
|
+
* `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
|
|
240
|
+
* private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at
|
|
241
|
+
* all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.
|
|
242
|
+
*/
|
|
153
243
|
readonly hidden: boolean;
|
|
244
|
+
/** `{ openWorld: true }` — this operation may touch systems outside this service. */
|
|
245
|
+
readonly openWorld: boolean;
|
|
154
246
|
readonly options: DocumentedEndpointOptions;
|
|
155
247
|
readonly auth: DocumentedAuth | undefined;
|
|
156
248
|
readonly mcpTool: DocumentedMcpTool | undefined;
|
|
@@ -164,10 +256,29 @@ export declare class DocumentedEndpoint {
|
|
|
164
256
|
readonly request: TypeRef | undefined;
|
|
165
257
|
readonly response: TypeRef | undefined;
|
|
166
258
|
constructor(methodName: string,
|
|
259
|
+
/**
|
|
260
|
+
* `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
|
|
261
|
+
* written without it — the verb is the key an operation hangs under in `paths`.
|
|
262
|
+
*/
|
|
263
|
+
httpMethod: string,
|
|
167
264
|
/** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
|
|
168
265
|
path: string,
|
|
266
|
+
/**
|
|
267
|
+
* `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is
|
|
268
|
+
* independent of the verb: webpieces POSTs a read. A renderer publishes it rather than
|
|
269
|
+
* inferring safety from the verb, which for this framework would be wrong.
|
|
270
|
+
*/
|
|
271
|
+
operation: string,
|
|
169
272
|
/** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
|
|
170
|
-
kind: string,
|
|
273
|
+
kind: string,
|
|
274
|
+
/**
|
|
275
|
+
* `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
|
|
276
|
+
* private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at
|
|
277
|
+
* all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.
|
|
278
|
+
*/
|
|
279
|
+
hidden: boolean,
|
|
280
|
+
/** `{ openWorld: true }` — this operation may touch systems outside this service. */
|
|
281
|
+
openWorld: boolean, options: DocumentedEndpointOptions, auth: DocumentedAuth | undefined, mcpTool: DocumentedMcpTool | undefined,
|
|
171
282
|
/** `@WpMcpAuthJwt(...)`'s argument text, when present. */
|
|
172
283
|
mcpAuthText: string | undefined,
|
|
173
284
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
@@ -179,6 +290,14 @@ export declare class DocumentedEndpoint {
|
|
|
179
290
|
export declare class ApiDocModel {
|
|
180
291
|
/** The contract class name, e.g. `SaveApi`. */
|
|
181
292
|
readonly contractName: string;
|
|
293
|
+
/**
|
|
294
|
+
* WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,
|
|
295
|
+
* verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.
|
|
296
|
+
*
|
|
297
|
+
* A named list rather than a falsy default, because the grant has to be the TOKEN: a default
|
|
298
|
+
* that reached customers would publish a contract whose author typed nothing about it.
|
|
299
|
+
*/
|
|
300
|
+
readonly apiTypes: readonly string[];
|
|
182
301
|
/** `@ApiPath(...)`, constant-folded. */
|
|
183
302
|
readonly basePath: string;
|
|
184
303
|
/** The JSDoc on the contract class, links flattened. */
|
|
@@ -191,6 +310,14 @@ export declare class ApiDocModel {
|
|
|
191
310
|
constructor(
|
|
192
311
|
/** The contract class name, e.g. `SaveApi`. */
|
|
193
312
|
contractName: string,
|
|
313
|
+
/**
|
|
314
|
+
* WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,
|
|
315
|
+
* verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.
|
|
316
|
+
*
|
|
317
|
+
* A named list rather than a falsy default, because the grant has to be the TOKEN: a default
|
|
318
|
+
* that reached customers would publish a contract whose author typed nothing about it.
|
|
319
|
+
*/
|
|
320
|
+
apiTypes: readonly string[],
|
|
194
321
|
/** `@ApiPath(...)`, constant-folded. */
|
|
195
322
|
basePath: string,
|
|
196
323
|
/** The JSDoc on the contract class, links flattened. */
|
package/src/model/ApiDocModel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiDocModel = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.DocumentedType = exports.DocumentedField = exports.UnionDiscriminator = exports.UnmappedType = void 0;
|
|
3
|
+
exports.ApiDocModel = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKey = exports.DocumentedApiKeyCredential = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.DocumentedType = exports.DocumentedField = exports.UnionDiscriminator = exports.UnmappedType = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —
|
|
6
6
|
* these are data-only structures, and a renderer (#982) builds nothing, it only reads.
|
|
@@ -118,7 +118,7 @@ class DocumentedType {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
exports.DocumentedType = DocumentedType;
|
|
121
|
-
/** `@Endpoint(path, kind, options?)`'s
|
|
121
|
+
/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */
|
|
122
122
|
class DocumentedEndpointOptions {
|
|
123
123
|
formPost;
|
|
124
124
|
calledBy;
|
|
@@ -132,38 +132,108 @@ class DocumentedEndpointOptions {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
exports.DocumentedEndpointOptions = DocumentedEndpointOptions;
|
|
135
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* The `@WpMcpTool(...)` declaration, when the method carries one — the TWO facts the source cannot
|
|
137
|
+
* otherwise state, and nothing else.
|
|
138
|
+
*
|
|
139
|
+
* `description` is deliberately NOT read off the decorator. The method's JSDoc is the description, for
|
|
140
|
+
* the agent and for the partner alike, byte-identical: two authored copies of one paragraph is the
|
|
141
|
+
* two-spellings shim, and its failure mode is concrete — the partner reads the JSDoc in the OpenAPI
|
|
142
|
+
* document while the agent reads the decorator string in `tools/list`, and they drift the first time
|
|
143
|
+
* somebody edits one. (The field still exists on the decorator; #984 deletes it across its 29 call
|
|
144
|
+
* sites. Nothing here reads it, so nothing here depends on a field that is about to disappear.)
|
|
145
|
+
*
|
|
146
|
+
* The three side-effect hints are not read either: they are COMPUTED from the endpoint's `operation`
|
|
147
|
+
* by `mcpHintsForOperation` in `@webpieces/core-util`, which is the one place that mapping lives.
|
|
148
|
+
* `READ | WRITE_IDEMPOTENT | WRITE` already says whether repeating a call is safe, so a hand-declared
|
|
149
|
+
* hint would be a second answer to a question the contract has answered.
|
|
150
|
+
*/
|
|
136
151
|
class DocumentedMcpTool {
|
|
137
152
|
name;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
constructor(
|
|
154
|
+
/**
|
|
155
|
+
* The STABLE protocol name. Deliberately independent of the method name, because renaming a
|
|
156
|
+
* method must not break a saved agent workflow.
|
|
157
|
+
*/
|
|
158
|
+
name) {
|
|
142
159
|
this.name = name;
|
|
143
|
-
this.hints = hints;
|
|
144
160
|
}
|
|
145
161
|
}
|
|
146
162
|
exports.DocumentedMcpTool = DocumentedMcpTool;
|
|
163
|
+
/**
|
|
164
|
+
* ONE credential of an api-key regime, PARSED — `{ in: 'header', name: 'x-api-key' }` or
|
|
165
|
+
* `{ in: 'bearer' }`.
|
|
166
|
+
*
|
|
167
|
+
* Parsed rather than left as source text because it is the one auth argument a renderer must turn
|
|
168
|
+
* into a STRUCTURE: an OpenAPI `securityScheme` is `{type: apiKey, in, name}` or
|
|
169
|
+
* `{type: http, scheme: bearer}`, and those are different documents. A renderer handed the string
|
|
170
|
+
* `"{ in: 'header', name: 'x-api-key' }"` would have to parse TypeScript to emit either one, which
|
|
171
|
+
* is this package's job and not a renderer's.
|
|
172
|
+
*/
|
|
173
|
+
class DocumentedApiKeyCredential {
|
|
174
|
+
location;
|
|
175
|
+
name;
|
|
176
|
+
description;
|
|
177
|
+
constructor(
|
|
178
|
+
/** `header` or `bearer`, verbatim from the declaration. */
|
|
179
|
+
location,
|
|
180
|
+
/** The header name. Undefined for `bearer`, whose location IS `Authorization`. */
|
|
181
|
+
name,
|
|
182
|
+
/** The prose a docs site renders on its authorization card. */
|
|
183
|
+
description) {
|
|
184
|
+
this.location = location;
|
|
185
|
+
this.name = name;
|
|
186
|
+
this.description = description;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.DocumentedApiKeyCredential = DocumentedApiKeyCredential;
|
|
190
|
+
/** `@WpAuthApiKey(regime, credentials)`, parsed. See {@link DocumentedApiKeyCredential}. */
|
|
191
|
+
class DocumentedApiKey {
|
|
192
|
+
regime;
|
|
193
|
+
credentials;
|
|
194
|
+
constructor(regime,
|
|
195
|
+
/**
|
|
196
|
+
* Every credential the regime requires, IN DECLARATION ORDER. They are an AND — all of them
|
|
197
|
+
* are presented together — and the order is the order a published document lists them in.
|
|
198
|
+
*/
|
|
199
|
+
credentials) {
|
|
200
|
+
this.regime = regime;
|
|
201
|
+
this.credentials = credentials;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.DocumentedApiKey = DocumentedApiKey;
|
|
147
205
|
/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */
|
|
148
206
|
class DocumentedAuth {
|
|
149
207
|
decorator;
|
|
150
|
-
|
|
208
|
+
argumentTexts;
|
|
209
|
+
apiKey;
|
|
151
210
|
constructor(
|
|
152
211
|
/** The decorator name as written, e.g. `WpAuthJwt`. */
|
|
153
212
|
decorator,
|
|
154
|
-
/**
|
|
155
|
-
|
|
213
|
+
/** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */
|
|
214
|
+
argumentTexts,
|
|
215
|
+
/**
|
|
216
|
+
* The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's
|
|
217
|
+
* argument is prose or a role list that a document quotes rather than restructures, so
|
|
218
|
+
* {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why
|
|
219
|
+
* this one is different.
|
|
220
|
+
*/
|
|
221
|
+
apiKey) {
|
|
156
222
|
this.decorator = decorator;
|
|
157
|
-
this.
|
|
223
|
+
this.argumentTexts = argumentTexts;
|
|
224
|
+
this.apiKey = apiKey;
|
|
158
225
|
}
|
|
159
226
|
}
|
|
160
227
|
exports.DocumentedAuth = DocumentedAuth;
|
|
161
228
|
/** One `@Endpoint` method of one contract. */
|
|
162
229
|
class DocumentedEndpoint {
|
|
163
230
|
methodName;
|
|
231
|
+
httpMethod;
|
|
164
232
|
path;
|
|
233
|
+
operation;
|
|
165
234
|
kind;
|
|
166
235
|
hidden;
|
|
236
|
+
openWorld;
|
|
167
237
|
options;
|
|
168
238
|
auth;
|
|
169
239
|
mcpTool;
|
|
@@ -174,10 +244,29 @@ class DocumentedEndpoint {
|
|
|
174
244
|
request;
|
|
175
245
|
response;
|
|
176
246
|
constructor(methodName,
|
|
247
|
+
/**
|
|
248
|
+
* `GET` or `POST`, constant-folded from `@Endpoint`'s FIRST argument. A document cannot be
|
|
249
|
+
* written without it — the verb is the key an operation hangs under in `paths`.
|
|
250
|
+
*/
|
|
251
|
+
httpMethod,
|
|
177
252
|
/** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
|
|
178
253
|
path,
|
|
254
|
+
/**
|
|
255
|
+
* `read` | `write-idempotent` | `write`, verbatim. The SIDE-EFFECT contract, which is
|
|
256
|
+
* independent of the verb: webpieces POSTs a read. A renderer publishes it rather than
|
|
257
|
+
* inferring safety from the verb, which for this framework would be wrong.
|
|
258
|
+
*/
|
|
259
|
+
operation,
|
|
179
260
|
/** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
|
|
180
|
-
kind,
|
|
261
|
+
kind,
|
|
262
|
+
/**
|
|
263
|
+
* `{ hidden: true }` — this method is absent from the CUSTOMER document. It stays in the
|
|
264
|
+
* private one, and in the MCP one when it is a tool. WHICH documents the CONTRACT feeds at
|
|
265
|
+
* all is a different, class-level decision; see {@link ApiDocModel.apiTypes}.
|
|
266
|
+
*/
|
|
267
|
+
hidden,
|
|
268
|
+
/** `{ openWorld: true }` — this operation may touch systems outside this service. */
|
|
269
|
+
openWorld, options, auth, mcpTool,
|
|
181
270
|
/** `@WpMcpAuthJwt(...)`'s argument text, when present. */
|
|
182
271
|
mcpAuthText,
|
|
183
272
|
/** `@MaskLog({...})` — field name -> mask mode. */
|
|
@@ -185,9 +274,12 @@ class DocumentedEndpoint {
|
|
|
185
274
|
/** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
|
|
186
275
|
mcpDescription, request, response) {
|
|
187
276
|
this.methodName = methodName;
|
|
277
|
+
this.httpMethod = httpMethod;
|
|
188
278
|
this.path = path;
|
|
279
|
+
this.operation = operation;
|
|
189
280
|
this.kind = kind;
|
|
190
281
|
this.hidden = hidden;
|
|
282
|
+
this.openWorld = openWorld;
|
|
191
283
|
this.options = options;
|
|
192
284
|
this.auth = auth;
|
|
193
285
|
this.mcpTool = mcpTool;
|
|
@@ -203,6 +295,7 @@ exports.DocumentedEndpoint = DocumentedEndpoint;
|
|
|
203
295
|
/** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
|
|
204
296
|
class ApiDocModel {
|
|
205
297
|
contractName;
|
|
298
|
+
apiTypes;
|
|
206
299
|
basePath;
|
|
207
300
|
description;
|
|
208
301
|
endpoints;
|
|
@@ -211,6 +304,14 @@ class ApiDocModel {
|
|
|
211
304
|
constructor(
|
|
212
305
|
/** The contract class name, e.g. `SaveApi`. */
|
|
213
306
|
contractName,
|
|
307
|
+
/**
|
|
308
|
+
* WHICH generated documents this contract feeds — `svc-to-svc`, `external-customer`, `mcp`,
|
|
309
|
+
* verbatim from `@ApiType(...)`, defaulting to `svc-to-svc` alone when it declares nothing.
|
|
310
|
+
*
|
|
311
|
+
* A named list rather than a falsy default, because the grant has to be the TOKEN: a default
|
|
312
|
+
* that reached customers would publish a contract whose author typed nothing about it.
|
|
313
|
+
*/
|
|
314
|
+
apiTypes,
|
|
214
315
|
/** `@ApiPath(...)`, constant-folded. */
|
|
215
316
|
basePath,
|
|
216
317
|
/** The JSDoc on the contract class, links flattened. */
|
|
@@ -220,6 +321,7 @@ class ApiDocModel {
|
|
|
220
321
|
/** Everything that could not be represented — recorded, not dropped. */
|
|
221
322
|
unmapped) {
|
|
222
323
|
this.contractName = contractName;
|
|
324
|
+
this.apiTypes = apiTypes;
|
|
223
325
|
this.basePath = basePath;
|
|
224
326
|
this.description = description;
|
|
225
327
|
this.endpoints = endpoints;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;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,wGAAwG;AACxG,MAAa,kBAAkB;IAGd;IAEA;IAJb;IACI,yCAAyC;IAChC,YAAoB;IAC7B,kFAAkF;IACzE,YAAyC;QAFzC,iBAAY,GAAZ,YAAY,CAAQ;QA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,CAAoB;QAE/B,YAAO,GAAP,OAAO,CAA6B;QACpC,gBAAW,GAAX,WAAW,CAAQ;QAEnB,mBAAc,GAAd,cAAc,CAAoB;QAClC,YAAO,GAAP,OAAO,CAAqB;QAC5B,aAAQ,GAAR,QAAQ,CAAqB;IACvC,CAAC;CACP;AArBD,gDAqBC;AAED,2FAA2F;AAC3F,MAAa,WAAW;IAGP;IAEA;IAEA;IACA;IAEA;IAEA;IAXb;IACI,+CAA+C;IACtC,YAAoB;IAC7B,wCAAwC;IAC/B,QAAgB;IACzB,wDAAwD;IAC/C,WAAmB,EACnB,SAAwC;IACjD,8FAA8F;IACrF,KAA0C;IACnD,wEAAwE;IAC/D,QAAiC;QATjC,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,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;IAC3C,CAAC;CACP;AAdD,kCAcC","sourcesContent":["import { TypeRef } from './TypeRef';\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/** 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 /** branch type name -> the single string literal that branch's property holds. */\n readonly branchValues: ReadonlyMap<string, 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}\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}\n\n/** `@Endpoint(path, kind, options?)`'s third argument, as far as a document cares. */\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/** The `@WpMcpTool(...)` declaration, when the method carries one. */\nexport class DocumentedMcpTool {\n constructor(\n readonly name: string,\n /** The tool hints an agent reads — `readOnly`, `destructive`, `idempotent`, `openWorld`. */\n readonly hints: ReadonlyMap<string, boolean>,\n ) {}\n}\n\n/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */\nexport class DocumentedAuth {\n constructor(\n /** The decorator name as written, e.g. `WpAuthJwt`. */\n readonly decorator: string,\n /** Its argument text, verbatim, when it took one. Undefined for `@WpAuthPublic()`. */\n readonly argumentText: string | undefined,\n ) {}\n}\n\n/** One `@Endpoint` method of one contract. */\nexport class DocumentedEndpoint {\n constructor(\n readonly methodName: string,\n /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */\n readonly path: string,\n /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */\n readonly kind: string,\n readonly hidden: boolean,\n readonly options: DocumentedEndpointOptions,\n readonly auth: DocumentedAuth | undefined,\n readonly mcpTool: DocumentedMcpTool | undefined,\n /** `@WpMcpAuthJwt(...)`'s argument text, when present. */\n readonly mcpAuthText: 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 readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\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 /** `@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 ) {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiDocModel.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/ApiDocModel.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;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,wGAAwG;AACxG,MAAa,kBAAkB;IAGd;IAEA;IAJb;IACI,yCAAyC;IAChC,YAAoB;IAC7B,kFAAkF;IACzE,YAAyC;QAFzC,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,iBAAY,GAAZ,YAAY,CAA6B;IACnD,CAAC;CACP;AAPD,gDAOC;AAED,4BAA4B;AAC5B,MAAa,eAAe;IAEX;IACA;IAMA;IAEA;IAEA;IAMA;IAEA;IAEA;IAEA;IAxBb,YACa,IAAY,EACZ,IAAa;IACtB;;;;OAIG;IACM,QAAiB;IAC1B,sFAAsF;IAC7E,QAAiB;IAC1B,uEAAuE;IAC9D,WAAmB;IAC5B;;;;OAIG;IACM,cAAkC;IAC3C,8EAA8E;IACrE,MAA0B;IACnC,2EAA2E;IAClE,GAAuB;IAChC,2EAA2E;IAClE,GAAuB;QAvBvB,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAS;QAMb,aAAQ,GAAR,QAAQ,CAAS;QAEjB,aAAQ,GAAR,QAAQ,CAAS;QAEjB,gBAAW,GAAX,WAAW,CAAQ;QAMnB,mBAAc,GAAd,cAAc,CAAoB;QAElC,WAAM,GAAN,MAAM,CAA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QAClC,SAAI,GAAJ,IAAI,CAA4B;QAChC,YAAO,GAAP,OAAO,CAA+B;QAEtC,gBAAW,GAAX,WAAW,CAAoB;QAE/B,YAAO,GAAP,OAAO,CAA6B;QACpC,gBAAW,GAAX,WAAW,CAAQ;QAEnB,mBAAc,GAAd,cAAc,CAAoB;QAClC,YAAO,GAAP,OAAO,CAAqB;QAC5B,aAAQ,GAAR,QAAQ,CAAqB;IACvC,CAAC;CACP;AAvCD,gDAuCC;AAED,2FAA2F;AAC3F,MAAa,WAAW;IAGP;IAQA;IAEA;IAEA;IACA;IAEA;IAEA;IAnBb;IACI,+CAA+C;IACtC,YAAoB;IAC7B;;;;;;OAMG;IACM,QAA2B;IACpC,wCAAwC;IAC/B,QAAgB;IACzB,wDAAwD;IAC/C,WAAmB,EACnB,SAAwC;IACjD,8FAA8F;IACrF,KAA0C;IACnD,wEAAwE;IAC/D,QAAiC;QAjBjC,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;IAC3C,CAAC;CACP;AAtBD,kCAsBC","sourcesContent":["import { TypeRef } from './TypeRef';\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/** 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 /** branch type name -> the single string literal that branch's property holds. */\n readonly branchValues: ReadonlyMap<string, 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}\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}\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(...)` declaration, when the method carries one — the TWO facts the source cannot\n * otherwise state, and nothing else.\n *\n * `description` is deliberately NOT read off the decorator. The method's JSDoc is the description, for\n * the 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. (The field still exists on the decorator; #984 deletes it across its 29 call\n * sites. Nothing here reads it, so nothing here depends on a field that is about to disappear.)\n *\n * The three side-effect hints are not read either: they are COMPUTED from the endpoint's `operation`\n * by `mcpHintsForOperation` in `@webpieces/core-util`, which is the one place that mapping lives.\n * `READ | WRITE_IDEMPOTENT | WRITE` already says whether repeating a call is safe, so a hand-declared\n * hint would be a second answer to a question the contract has answered.\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}\n\n/**\n * ONE credential of an api-key regime, PARSED — `{ in: 'header', name: 'x-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', name: 'x-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 /** The header name. Undefined for `bearer`, whose location IS `Authorization`. */\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/** `@WpAuthApiKey(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/** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */\nexport class DocumentedAuth {\n constructor(\n /** The decorator name as written, e.g. `WpAuthJwt`. */\n readonly decorator: string,\n /** Every argument's text, verbatim and in order. Empty for `@WpAuthPublic()`. */\n readonly argumentTexts: readonly string[],\n /**\n * The PARSED api-key declaration, set only for `@WpAuthApiKey`. Every other decorator's\n * argument is prose or a role list that a document quotes rather than restructures, so\n * {@link argumentTexts} is all they need — see {@link DocumentedApiKeyCredential} for why\n * this one is different.\n */\n readonly apiKey: DocumentedApiKey | undefined,\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 /** `@WpMcpAuthJwt(...)`'s argument text, when present. */\n readonly mcpAuthText: 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 readonly request: TypeRef | undefined,\n readonly response: TypeRef | undefined,\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 ) {}\n}\n"]}
|