@webpieces/api-doc-model 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,202 @@
1
+ import { TypeRef } from './TypeRef';
2
+ /**
3
+ * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —
4
+ * these are data-only structures, and a renderer (#982) builds nothing, it only reads.
5
+ *
6
+ * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and
7
+ * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import
8
+ * here would end that, which is why `responsibilities.md` states the constraint rather than leaving
9
+ * it to be discovered.
10
+ */
11
+ /** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */
12
+ export declare class UnmappedType {
13
+ /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */
14
+ readonly typeText: string;
15
+ /** Pointer-style location: `path/to/File.ts:12:5`. */
16
+ readonly location: string;
17
+ /** Why it could not be mapped, in one sentence a renderer can print. */
18
+ readonly reason: string;
19
+ constructor(
20
+ /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */
21
+ typeText: string,
22
+ /** Pointer-style location: `path/to/File.ts:12:5`. */
23
+ location: string,
24
+ /** Why it could not be mapped, in one sentence a renderer can print. */
25
+ reason: string);
26
+ }
27
+ /** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */
28
+ export declare class UnionDiscriminator {
29
+ /** The property every branch carries. */
30
+ readonly propertyName: string;
31
+ /** branch type name -> the single string literal that branch's property holds. */
32
+ readonly branchValues: ReadonlyMap<string, string>;
33
+ constructor(
34
+ /** The property every branch carries. */
35
+ propertyName: string,
36
+ /** branch type name -> the single string literal that branch's property holds. */
37
+ branchValues: ReadonlyMap<string, string>);
38
+ }
39
+ /** One field of one DTO. */
40
+ export declare class DocumentedField {
41
+ readonly name: string;
42
+ readonly type: TypeRef;
43
+ /**
44
+ * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from
45
+ * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a
46
+ * renderer that conflates them emits a schema that rejects one of them.
47
+ */
48
+ readonly optional: boolean;
49
+ /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */
50
+ readonly nullable: boolean;
51
+ /** The JSDoc body, links flattened. Empty string when undocumented. */
52
+ readonly description: string;
53
+ /**
54
+ * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means "no override",
55
+ * and a renderer falls back to {@link description}; the fallback is NOT applied here so a
56
+ * renderer can tell a deliberate agent-facing sentence from a reused human one.
57
+ */
58
+ readonly mcpDescription: string | undefined;
59
+ /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */
60
+ readonly format: string | undefined;
61
+ /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */
62
+ readonly min: number | undefined;
63
+ /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */
64
+ readonly max: number | undefined;
65
+ constructor(name: string, type: TypeRef,
66
+ /**
67
+ * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from
68
+ * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a
69
+ * renderer that conflates them emits a schema that rejects one of them.
70
+ */
71
+ optional: boolean,
72
+ /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */
73
+ nullable: boolean,
74
+ /** The JSDoc body, links flattened. Empty string when undocumented. */
75
+ description: string,
76
+ /**
77
+ * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means "no override",
78
+ * and a renderer falls back to {@link description}; the fallback is NOT applied here so a
79
+ * renderer can tell a deliberate agent-facing sentence from a reused human one.
80
+ */
81
+ mcpDescription: string | undefined,
82
+ /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */
83
+ format: string | undefined,
84
+ /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */
85
+ min: number | undefined,
86
+ /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */
87
+ max: number | undefined);
88
+ }
89
+ /** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */
90
+ export declare class DocumentedType {
91
+ readonly name: string;
92
+ readonly description: string;
93
+ /** Object shape. Empty for an enum or a union. */
94
+ readonly fields: readonly DocumentedField[];
95
+ /** Set for a string-literal union that has a name. */
96
+ readonly enumValues: readonly string[];
97
+ /** Set for a union of named object types. */
98
+ readonly unionRefNames: readonly string[];
99
+ /** Set only when EVERY branch carries the same property typed as one string literal. */
100
+ readonly discriminator: UnionDiscriminator | undefined;
101
+ /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
102
+ readonly indexSignatureValue: TypeRef | undefined;
103
+ constructor(name: string, description: string,
104
+ /** Object shape. Empty for an enum or a union. */
105
+ fields: readonly DocumentedField[],
106
+ /** Set for a string-literal union that has a name. */
107
+ enumValues: readonly string[],
108
+ /** Set for a union of named object types. */
109
+ unionRefNames: readonly string[],
110
+ /** Set only when EVERY branch carries the same property typed as one string literal. */
111
+ discriminator: UnionDiscriminator | undefined,
112
+ /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
113
+ indexSignatureValue: TypeRef | undefined);
114
+ }
115
+ /** `@Endpoint(path, kind, options?)`'s third argument, as far as a document cares. */
116
+ export declare class DocumentedEndpointOptions {
117
+ readonly formPost: boolean;
118
+ /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */
119
+ readonly calledBy: string | undefined;
120
+ readonly callerKind: string | undefined;
121
+ constructor(formPost: boolean,
122
+ /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */
123
+ calledBy: string | undefined, callerKind: string | undefined);
124
+ }
125
+ /** The `@WpMcpTool(...)` declaration, when the method carries one. */
126
+ export declare class DocumentedMcpTool {
127
+ readonly name: string;
128
+ /** The tool hints an agent reads — `readOnly`, `destructive`, `idempotent`, `openWorld`. */
129
+ readonly hints: ReadonlyMap<string, boolean>;
130
+ constructor(name: string,
131
+ /** The tool hints an agent reads — `readOnly`, `destructive`, `idempotent`, `openWorld`. */
132
+ hints: ReadonlyMap<string, boolean>);
133
+ }
134
+ /** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */
135
+ export declare class DocumentedAuth {
136
+ /** The decorator name as written, e.g. `WpAuthJwt`. */
137
+ readonly decorator: string;
138
+ /** Its argument text, verbatim, when it took one. Undefined for `@WpAuthPublic()`. */
139
+ readonly argumentText: string | undefined;
140
+ constructor(
141
+ /** The decorator name as written, e.g. `WpAuthJwt`. */
142
+ decorator: string,
143
+ /** Its argument text, verbatim, when it took one. Undefined for `@WpAuthPublic()`. */
144
+ argumentText: string | undefined);
145
+ }
146
+ /** One `@Endpoint` method of one contract. */
147
+ export declare class DocumentedEndpoint {
148
+ readonly methodName: string;
149
+ /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
150
+ readonly path: string;
151
+ /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
152
+ readonly kind: string;
153
+ readonly hidden: boolean;
154
+ readonly options: DocumentedEndpointOptions;
155
+ readonly auth: DocumentedAuth | undefined;
156
+ readonly mcpTool: DocumentedMcpTool | undefined;
157
+ /** `@WpMcpAuthJwt(...)`'s argument text, when present. */
158
+ readonly mcpAuthText: string | undefined;
159
+ /** `@MaskLog({...})` — field name -> mask mode. */
160
+ readonly maskLog: ReadonlyMap<string, string>;
161
+ readonly description: string;
162
+ /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
163
+ readonly mcpDescription: string | undefined;
164
+ readonly request: TypeRef | undefined;
165
+ readonly response: TypeRef | undefined;
166
+ constructor(methodName: string,
167
+ /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
168
+ path: string,
169
+ /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
170
+ kind: string, hidden: boolean, options: DocumentedEndpointOptions, auth: DocumentedAuth | undefined, mcpTool: DocumentedMcpTool | undefined,
171
+ /** `@WpMcpAuthJwt(...)`'s argument text, when present. */
172
+ mcpAuthText: string | undefined,
173
+ /** `@MaskLog({...})` — field name -> mask mode. */
174
+ maskLog: ReadonlyMap<string, string>, description: string,
175
+ /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
176
+ mcpDescription: string | undefined, request: TypeRef | undefined, response: TypeRef | undefined);
177
+ }
178
+ /** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
179
+ export declare class ApiDocModel {
180
+ /** The contract class name, e.g. `SaveApi`. */
181
+ readonly contractName: string;
182
+ /** `@ApiPath(...)`, constant-folded. */
183
+ readonly basePath: string;
184
+ /** The JSDoc on the contract class, links flattened. */
185
+ readonly description: string;
186
+ readonly endpoints: readonly DocumentedEndpoint[];
187
+ /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */
188
+ readonly types: ReadonlyMap<string, DocumentedType>;
189
+ /** Everything that could not be represented — recorded, not dropped. */
190
+ readonly unmapped: readonly UnmappedType[];
191
+ constructor(
192
+ /** The contract class name, e.g. `SaveApi`. */
193
+ contractName: string,
194
+ /** `@ApiPath(...)`, constant-folded. */
195
+ basePath: string,
196
+ /** The JSDoc on the contract class, links flattened. */
197
+ description: string, endpoints: readonly DocumentedEndpoint[],
198
+ /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */
199
+ types: ReadonlyMap<string, DocumentedType>,
200
+ /** Everything that could not be represented — recorded, not dropped. */
201
+ unmapped: readonly UnmappedType[]);
202
+ }
@@ -0,0 +1,231 @@
1
+ "use strict";
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;
4
+ /**
5
+ * The model classes. Every one of them is a CLASS with an explicit constructor per `CLAUDE.md` §1 —
6
+ * these are data-only structures, and a renderer (#982) builds nothing, it only reads.
7
+ *
8
+ * Nothing in this file imports anything but {@link TypeRef}: the package depends on `typescript` and
9
+ * NOTHING else, so it can be pointed at any upstream project's contract. One app-specific import
10
+ * here would end that, which is why `responsibilities.md` states the constraint rather than leaving
11
+ * it to be discovered.
12
+ */
13
+ /** A type the extractor could not represent. RECORDED, never dropped — #982's guard needs a name. */
14
+ class UnmappedType {
15
+ typeText;
16
+ location;
17
+ reason;
18
+ constructor(
19
+ /** The verbatim TypeScript type text, e.g. `Map<string, Widget>`. */
20
+ typeText,
21
+ /** Pointer-style location: `path/to/File.ts:12:5`. */
22
+ location,
23
+ /** Why it could not be mapped, in one sentence a renderer can print. */
24
+ reason) {
25
+ this.typeText = typeText;
26
+ this.location = location;
27
+ this.reason = reason;
28
+ }
29
+ }
30
+ exports.UnmappedType = UnmappedType;
31
+ /** The DERIVED discriminator of a union — never invented, only observed. See {@link DocumentedType}. */
32
+ class UnionDiscriminator {
33
+ propertyName;
34
+ branchValues;
35
+ constructor(
36
+ /** The property every branch carries. */
37
+ propertyName,
38
+ /** branch type name -> the single string literal that branch's property holds. */
39
+ branchValues) {
40
+ this.propertyName = propertyName;
41
+ this.branchValues = branchValues;
42
+ }
43
+ }
44
+ exports.UnionDiscriminator = UnionDiscriminator;
45
+ /** One field of one DTO. */
46
+ class DocumentedField {
47
+ name;
48
+ type;
49
+ optional;
50
+ nullable;
51
+ description;
52
+ mcpDescription;
53
+ format;
54
+ min;
55
+ max;
56
+ constructor(name, type,
57
+ /**
58
+ * OPTIONAL (`name?: string`) — the property may be ABSENT. Distinguished from
59
+ * {@link nullable} on purpose: `{}` and `{name: null}` are different wire documents, and a
60
+ * renderer that conflates them emits a schema that rejects one of them.
61
+ */
62
+ optional,
63
+ /** NULLABLE (`name: string | null`) — the property is present and may hold `null`. */
64
+ nullable,
65
+ /** The JSDoc body, links flattened. Empty string when undocumented. */
66
+ description,
67
+ /**
68
+ * The `@mcp` block tag — an OPTIONAL agent-facing override. Undefined means "no override",
69
+ * and a renderer falls back to {@link description}; the fallback is NOT applied here so a
70
+ * renderer can tell a deliberate agent-facing sentence from a reused human one.
71
+ */
72
+ mcpDescription,
73
+ /** The `@format` tag, lifted onto the SCALAR (on an array, onto the ITEM). */
74
+ format,
75
+ /** `@WpMin(n)` — numeric fields only; anything else is a build failure. */
76
+ min,
77
+ /** `@WpMax(n)` — numeric fields only; anything else is a build failure. */
78
+ max) {
79
+ this.name = name;
80
+ this.type = type;
81
+ this.optional = optional;
82
+ this.nullable = nullable;
83
+ this.description = description;
84
+ this.mcpDescription = mcpDescription;
85
+ this.format = format;
86
+ this.min = min;
87
+ this.max = max;
88
+ }
89
+ }
90
+ exports.DocumentedField = DocumentedField;
91
+ /** One named type reachable from a contract: an object DTO, a string-literal enum, or a union. */
92
+ class DocumentedType {
93
+ name;
94
+ description;
95
+ fields;
96
+ enumValues;
97
+ unionRefNames;
98
+ discriminator;
99
+ indexSignatureValue;
100
+ constructor(name, description,
101
+ /** Object shape. Empty for an enum or a union. */
102
+ fields,
103
+ /** Set for a string-literal union that has a name. */
104
+ enumValues,
105
+ /** Set for a union of named object types. */
106
+ unionRefNames,
107
+ /** Set only when EVERY branch carries the same property typed as one string literal. */
108
+ discriminator,
109
+ /** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
110
+ indexSignatureValue) {
111
+ this.name = name;
112
+ this.description = description;
113
+ this.fields = fields;
114
+ this.enumValues = enumValues;
115
+ this.unionRefNames = unionRefNames;
116
+ this.discriminator = discriminator;
117
+ this.indexSignatureValue = indexSignatureValue;
118
+ }
119
+ }
120
+ exports.DocumentedType = DocumentedType;
121
+ /** `@Endpoint(path, kind, options?)`'s third argument, as far as a document cares. */
122
+ class DocumentedEndpointOptions {
123
+ formPost;
124
+ calledBy;
125
+ callerKind;
126
+ constructor(formPost,
127
+ /** `calledBy` — REQUIRED by the decorator for `external`, absent otherwise. */
128
+ calledBy, callerKind) {
129
+ this.formPost = formPost;
130
+ this.calledBy = calledBy;
131
+ this.callerKind = callerKind;
132
+ }
133
+ }
134
+ exports.DocumentedEndpointOptions = DocumentedEndpointOptions;
135
+ /** The `@WpMcpTool(...)` declaration, when the method carries one. */
136
+ class DocumentedMcpTool {
137
+ name;
138
+ hints;
139
+ constructor(name,
140
+ /** The tool hints an agent reads — `readOnly`, `destructive`, `idempotent`, `openWorld`. */
141
+ hints) {
142
+ this.name = name;
143
+ this.hints = hints;
144
+ }
145
+ }
146
+ exports.DocumentedMcpTool = DocumentedMcpTool;
147
+ /** WHICH credential an endpoint demands — `@WpAuthPublic`, `@WpAuthJwt`, … — verbatim from the source. */
148
+ class DocumentedAuth {
149
+ decorator;
150
+ argumentText;
151
+ constructor(
152
+ /** The decorator name as written, e.g. `WpAuthJwt`. */
153
+ decorator,
154
+ /** Its argument text, verbatim, when it took one. Undefined for `@WpAuthPublic()`. */
155
+ argumentText) {
156
+ this.decorator = decorator;
157
+ this.argumentText = argumentText;
158
+ }
159
+ }
160
+ exports.DocumentedAuth = DocumentedAuth;
161
+ /** One `@Endpoint` method of one contract. */
162
+ class DocumentedEndpoint {
163
+ methodName;
164
+ path;
165
+ kind;
166
+ hidden;
167
+ options;
168
+ auth;
169
+ mcpTool;
170
+ mcpAuthText;
171
+ maskLog;
172
+ description;
173
+ mcpDescription;
174
+ request;
175
+ response;
176
+ constructor(methodName,
177
+ /** The path, constant-folded. A const that cannot be folded is a HARD FAILURE, never a guess. */
178
+ path,
179
+ /** `rpc` | `cloudtasks` | `cron` | `external`, verbatim — this package invents no taxonomy. */
180
+ kind, hidden, options, auth, mcpTool,
181
+ /** `@WpMcpAuthJwt(...)`'s argument text, when present. */
182
+ mcpAuthText,
183
+ /** `@MaskLog({...})` — field name -> mask mode. */
184
+ maskLog, description,
185
+ /** The `@mcp` override. See {@link DocumentedField.mcpDescription}. */
186
+ mcpDescription, request, response) {
187
+ this.methodName = methodName;
188
+ this.path = path;
189
+ this.kind = kind;
190
+ this.hidden = hidden;
191
+ this.options = options;
192
+ this.auth = auth;
193
+ this.mcpTool = mcpTool;
194
+ this.mcpAuthText = mcpAuthText;
195
+ this.maskLog = maskLog;
196
+ this.description = description;
197
+ this.mcpDescription = mcpDescription;
198
+ this.request = request;
199
+ this.response = response;
200
+ }
201
+ }
202
+ exports.DocumentedEndpoint = DocumentedEndpoint;
203
+ /** ONE extraction pass over ONE contract file. Both #982's renderers read exactly this. */
204
+ class ApiDocModel {
205
+ contractName;
206
+ basePath;
207
+ description;
208
+ endpoints;
209
+ types;
210
+ unmapped;
211
+ constructor(
212
+ /** The contract class name, e.g. `SaveApi`. */
213
+ contractName,
214
+ /** `@ApiPath(...)`, constant-folded. */
215
+ basePath,
216
+ /** The JSDoc on the contract class, links flattened. */
217
+ description, endpoints,
218
+ /** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */
219
+ types,
220
+ /** Everything that could not be represented — recorded, not dropped. */
221
+ unmapped) {
222
+ this.contractName = contractName;
223
+ this.basePath = basePath;
224
+ this.description = description;
225
+ this.endpoints = endpoints;
226
+ this.types = types;
227
+ this.unmapped = unmapped;
228
+ }
229
+ }
230
+ exports.ApiDocModel = ApiDocModel;
231
+ //# sourceMappingURL=ApiDocModel.js.map
@@ -0,0 +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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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;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"]}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * How a single declared type was RESOLVED. This is the leaf of the model: every field, every request
3
+ * and every response points at one of these.
4
+ *
5
+ * It is a CLASS with static factories rather than a discriminated union of interfaces, per
6
+ * `CLAUDE.md` §1 — it is data, it is constructed explicitly, and a renderer pattern-matches on
7
+ * `kind`. The factories exist because the combinations are not free-form: an `array` always has
8
+ * `items`, an `openMap` always has `values`, a `ref` always has `refName`, and a constructor taking
9
+ * eight optional fields would let a caller build a shape no resolver can produce.
10
+ */
11
+ export type TypeRefKind = 'primitive' | 'ref' | 'array' | 'openMap' | 'enum' | 'union' | 'unmapped';
12
+ /** The scalar kinds a renderer can emit without any further lookup. */
13
+ export type PrimitiveKind = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
14
+ export declare class TypeRef {
15
+ readonly kind: TypeRefKind;
16
+ /** Set when `kind === 'primitive'`. */
17
+ readonly primitive: PrimitiveKind | undefined;
18
+ /** Set when `kind === 'ref'` — the name of a {@link DocumentedType} in the model. */
19
+ readonly refName: string | undefined;
20
+ /** Set when `kind === 'array'` — the ITEM type. */
21
+ readonly items: TypeRef | undefined;
22
+ /** Set when `kind === 'openMap'` — the VALUE type of an index signature. */
23
+ readonly values: TypeRef | undefined;
24
+ /** Set when `kind === 'enum'` — the string-literal members, in declaration order. */
25
+ readonly enumValues: readonly string[];
26
+ /** Set when `kind === 'union'` — the branch type names, in declaration order. */
27
+ readonly unionRefNames: readonly string[];
28
+ /**
29
+ * INTEGER-ness, which TypeScript itself cannot express: it has one numeric type. Declared by
30
+ * writing `Integer` (preferred — it composes: `Integer[]`, `Record<string, Integer>`) or by
31
+ * putting `@WpInt()` on the field. Both produce this same flag; see `responsibilities.md`.
32
+ */
33
+ readonly integer: boolean;
34
+ /** Set when `kind === 'unmapped'` — the verbatim TS type text, for a renderer's guard. */
35
+ readonly unmappedText: string | undefined;
36
+ private constructor();
37
+ static primitiveOf(primitive: PrimitiveKind, integer?: boolean): TypeRef;
38
+ static ref(refName: string): TypeRef;
39
+ static array(items: TypeRef): TypeRef;
40
+ static openMap(values: TypeRef): TypeRef;
41
+ static enumOf(enumValues: readonly string[]): TypeRef;
42
+ static union(unionRefNames: readonly string[]): TypeRef;
43
+ static unmapped(unmappedText: string): TypeRef;
44
+ /** The same ref, marked integer. Used by `@WpInt()`, which decorates the FIELD, not the type. */
45
+ asInteger(): TypeRef;
46
+ /** True for a numeric leaf — what `@WpMin` / `@WpMax` are allowed to constrain. */
47
+ isNumeric(): boolean;
48
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeRef = void 0;
4
+ class TypeRef {
5
+ kind;
6
+ primitive;
7
+ refName;
8
+ items;
9
+ values;
10
+ enumValues;
11
+ unionRefNames;
12
+ integer;
13
+ unmappedText;
14
+ constructor(kind,
15
+ /** Set when `kind === 'primitive'`. */
16
+ primitive,
17
+ /** Set when `kind === 'ref'` — the name of a {@link DocumentedType} in the model. */
18
+ refName,
19
+ /** Set when `kind === 'array'` — the ITEM type. */
20
+ items,
21
+ /** Set when `kind === 'openMap'` — the VALUE type of an index signature. */
22
+ values,
23
+ /** Set when `kind === 'enum'` — the string-literal members, in declaration order. */
24
+ enumValues,
25
+ /** Set when `kind === 'union'` — the branch type names, in declaration order. */
26
+ unionRefNames,
27
+ /**
28
+ * INTEGER-ness, which TypeScript itself cannot express: it has one numeric type. Declared by
29
+ * writing `Integer` (preferred — it composes: `Integer[]`, `Record<string, Integer>`) or by
30
+ * putting `@WpInt()` on the field. Both produce this same flag; see `responsibilities.md`.
31
+ */
32
+ integer,
33
+ /** Set when `kind === 'unmapped'` — the verbatim TS type text, for a renderer's guard. */
34
+ unmappedText) {
35
+ this.kind = kind;
36
+ this.primitive = primitive;
37
+ this.refName = refName;
38
+ this.items = items;
39
+ this.values = values;
40
+ this.enumValues = enumValues;
41
+ this.unionRefNames = unionRefNames;
42
+ this.integer = integer;
43
+ this.unmappedText = unmappedText;
44
+ }
45
+ // webpieces-disable no-function-outside-class -- static factories on the class itself; the private constructor is what stops an impossible combination being built
46
+ static primitiveOf(primitive, integer = false) {
47
+ return new TypeRef('primitive', primitive, undefined, undefined, undefined, [], [], integer, undefined);
48
+ }
49
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
50
+ static ref(refName) {
51
+ return new TypeRef('ref', undefined, refName, undefined, undefined, [], [], false, undefined);
52
+ }
53
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
54
+ static array(items) {
55
+ return new TypeRef('array', undefined, undefined, items, undefined, [], [], false, undefined);
56
+ }
57
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
58
+ static openMap(values) {
59
+ return new TypeRef('openMap', undefined, undefined, undefined, values, [], [], false, undefined);
60
+ }
61
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
62
+ static enumOf(enumValues) {
63
+ return new TypeRef('enum', undefined, undefined, undefined, undefined, enumValues, [], false, undefined);
64
+ }
65
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
66
+ static union(unionRefNames) {
67
+ return new TypeRef('union', undefined, undefined, undefined, undefined, [], unionRefNames, false, undefined);
68
+ }
69
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built
70
+ static unmapped(unmappedText) {
71
+ return new TypeRef('unmapped', undefined, undefined, undefined, undefined, [], [], false, unmappedText);
72
+ }
73
+ /** The same ref, marked integer. Used by `@WpInt()`, which decorates the FIELD, not the type. */
74
+ asInteger() {
75
+ return new TypeRef(this.kind, this.primitive, this.refName, this.items, this.values, this.enumValues, this.unionRefNames, true, this.unmappedText);
76
+ }
77
+ /** True for a numeric leaf — what `@WpMin` / `@WpMax` are allowed to constrain. */
78
+ isNumeric() {
79
+ return this.kind === 'primitive' && this.primitive === 'number';
80
+ }
81
+ }
82
+ exports.TypeRef = TypeRef;
83
+ //# sourceMappingURL=TypeRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeRef.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/model/TypeRef.ts"],"names":[],"mappings":";;;AAeA,MAAa,OAAO;IAEH;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAMA;IAEA;IArBb,YACa,IAAiB;IAC1B,uCAAuC;IAC9B,SAAoC;IAC7C,qFAAqF;IAC5E,OAA2B;IACpC,mDAAmD;IAC1C,KAA0B;IACnC,4EAA4E;IACnE,MAA2B;IACpC,qFAAqF;IAC5E,UAA6B;IACtC,iFAAiF;IACxE,aAAgC;IACzC;;;;OAIG;IACM,OAAgB;IACzB,0FAA0F;IACjF,YAAgC;QApBhC,SAAI,GAAJ,IAAI,CAAa;QAEjB,cAAS,GAAT,SAAS,CAA2B;QAEpC,YAAO,GAAP,OAAO,CAAoB;QAE3B,UAAK,GAAL,KAAK,CAAqB;QAE1B,WAAM,GAAN,MAAM,CAAqB;QAE3B,eAAU,GAAV,UAAU,CAAmB;QAE7B,kBAAa,GAAb,aAAa,CAAmB;QAMhC,YAAO,GAAP,OAAO,CAAS;QAEhB,iBAAY,GAAZ,YAAY,CAAoB;IAC1C,CAAC;IAEJ,mKAAmK;IACnK,MAAM,CAAC,WAAW,CAAC,SAAwB,EAAE,OAAO,GAAG,KAAK;QACxD,OAAO,IAAI,OAAO,CACd,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,EAAE,EACF,EAAE,EACF,OAAO,EACP,SAAS,CACZ,CAAC;IACN,CAAC;IAED,6IAA6I;IAC7I,MAAM,CAAC,GAAG,CAAC,OAAe;QACtB,OAAO,IAAI,OAAO,CACd,KAAK,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,SAAS,EACT,EAAE,EACF,EAAE,EACF,KAAK,EACL,SAAS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AAI,CAAC,YAAY,CACpB,CAAC;IACN,CAAC;IAED,mFAAmF;IACnF,SAAS;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC;IACpE,CAAC;CACJ;AArJD,0BAqJC","sourcesContent":["/**\n * How a single declared type was RESOLVED. This is the leaf of the model: every field, every request\n * and every response points at one of these.\n *\n * It is a CLASS with static factories rather than a discriminated union of interfaces, per\n * `CLAUDE.md` §1 — it is data, it is constructed explicitly, and a renderer pattern-matches on\n * `kind`. The factories exist because the combinations are not free-form: an `array` always has\n * `items`, an `openMap` always has `values`, a `ref` always has `refName`, and a constructor taking\n * eight optional fields would let a caller build a shape no resolver can produce.\n */\nexport type TypeRefKind = 'primitive' | 'ref' | 'array' | 'openMap' | 'enum' | 'union' | 'unmapped';\n\n/** The scalar kinds a renderer can emit without any further lookup. */\nexport type PrimitiveKind = 'string' | 'number' | 'boolean' | 'null' | 'unknown';\n\nexport class TypeRef {\n private constructor(\n readonly kind: TypeRefKind,\n /** Set when `kind === 'primitive'`. */\n readonly primitive: PrimitiveKind | undefined,\n /** Set when `kind === 'ref'` — the name of a {@link DocumentedType} in the model. */\n readonly refName: string | undefined,\n /** Set when `kind === 'array'` — the ITEM type. */\n readonly items: TypeRef | undefined,\n /** Set when `kind === 'openMap'` — the VALUE type of an index signature. */\n readonly values: TypeRef | undefined,\n /** Set when `kind === 'enum'` — the string-literal members, in declaration order. */\n readonly enumValues: readonly string[],\n /** Set when `kind === 'union'` — the branch type names, in declaration order. */\n readonly unionRefNames: readonly string[],\n /**\n * INTEGER-ness, which TypeScript itself cannot express: it has one numeric type. Declared by\n * writing `Integer` (preferred — it composes: `Integer[]`, `Record<string, Integer>`) or by\n * putting `@WpInt()` on the field. Both produce this same flag; see `responsibilities.md`.\n */\n readonly integer: boolean,\n /** Set when `kind === 'unmapped'` — the verbatim TS type text, for a renderer's guard. */\n readonly unmappedText: string | undefined,\n ) {}\n\n // webpieces-disable no-function-outside-class -- static factories on the class itself; the private constructor is what stops an impossible combination being built\n static primitiveOf(primitive: PrimitiveKind, integer = false): TypeRef {\n return new TypeRef(\n 'primitive',\n primitive,\n undefined,\n undefined,\n undefined,\n [],\n [],\n integer,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static ref(refName: string): TypeRef {\n return new TypeRef(\n 'ref',\n undefined,\n refName,\n undefined,\n undefined,\n [],\n [],\n false,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static array(items: TypeRef): TypeRef {\n return new TypeRef(\n 'array',\n undefined,\n undefined,\n items,\n undefined,\n [],\n [],\n false,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static openMap(values: TypeRef): TypeRef {\n return new TypeRef(\n 'openMap',\n undefined,\n undefined,\n undefined,\n values,\n [],\n [],\n false,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static enumOf(enumValues: readonly string[]): TypeRef {\n return new TypeRef(\n 'enum',\n undefined,\n undefined,\n undefined,\n undefined,\n enumValues,\n [],\n false,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static union(unionRefNames: readonly string[]): TypeRef {\n return new TypeRef(\n 'union',\n undefined,\n undefined,\n undefined,\n undefined,\n [],\n unionRefNames,\n false,\n undefined,\n );\n }\n\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops an impossible combination being built\n static unmapped(unmappedText: string): TypeRef {\n return new TypeRef(\n 'unmapped',\n undefined,\n undefined,\n undefined,\n undefined,\n [],\n [],\n false,\n unmappedText,\n );\n }\n\n /** The same ref, marked integer. Used by `@WpInt()`, which decorates the FIELD, not the type. */\n asInteger(): TypeRef {\n return new TypeRef(\n this.kind,\n this.primitive,\n this.refName,\n this.items,\n this.values,\n this.enumValues,\n this.unionRefNames,\n true,\n this.unmappedText,\n );\n }\n\n /** True for a numeric leaf — what `@WpMin` / `@WpMax` are allowed to constrain. */\n isNumeric(): boolean {\n return this.kind === 'primitive' && this.primitive === 'number';\n }\n}\n"]}