@webpieces/api-doc-model 0.4.829 → 0.4.830
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/extract/ApiDocExtractor.d.ts +7 -1
- package/src/extract/ApiDocExtractor.js +17 -4
- package/src/extract/ApiDocExtractor.js.map +1 -1
- package/src/extract/ComponentsExtractor.d.ts +33 -0
- package/src/extract/ComponentsExtractor.js +123 -0
- package/src/extract/ComponentsExtractor.js.map +1 -0
- package/src/extract/FieldDecorators.d.ts +22 -0
- package/src/extract/FieldDecorators.js +93 -0
- package/src/extract/FieldDecorators.js.map +1 -0
- package/src/extract/PackageOfFile.d.ts +41 -0
- package/src/extract/PackageOfFile.js +73 -0
- package/src/extract/PackageOfFile.js.map +1 -0
- package/src/extract/TypeRegistry.d.ts +35 -0
- package/src/extract/TypeRegistry.js +66 -0
- package/src/extract/TypeRegistry.js.map +1 -0
- package/src/extract/TypeResolver.d.ts +25 -19
- package/src/extract/TypeResolver.js +79 -107
- package/src/extract/TypeResolver.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +6 -1
- package/src/index.js.map +1 -1
- package/src/model/ApiDocModel.d.ts +84 -2
- package/src/model/ApiDocModel.js +89 -3
- package/src/model/ApiDocModel.js.map +1 -1
- package/src/render/McpSchemaRenderer.js +4 -1
- package/src/render/McpSchemaRenderer.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeResolver.js","sourceRoot":"","sources":["../../../../../../packages/docs/api-doc-model/src/extract/TypeResolver.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,oDAA2D;AAC3D,sDAK8B;AAC9B,8CAA0D;AAC1D,mEAAgE;AAChE,mCAAgC;AAChC,yDAAmE;AACnE,qDAAkD;AAClD,uDAAoD;AAEpD;;;;GAIG;AACH,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,i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AAE,CAAC,uBAAuB,CAAC,QAAQ,CAAC;YACpC,QAAQ,CAAC,QAAQ,KAAK,EAAE,CAAC,UAAU,CAAC,UAAU;YAC9C,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EACvC,CAAC;YACC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,IAAI,6CAAqB,CAC3B,IAAI,aAAa,wCAAwC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAC9E,+BAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAC3B,0FAA0F,CAC7F,CAAC;IACN,CAAC;IAED,0EAA0E;IAClE,aAAa,CAAC,IAAmB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEO,cAAc,CAAC,IAAa,EAAE,MAAc;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,0BAAY,CAAC,IAAI,EAAE,+BAAc,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5E,OAAO,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAnnBD,oCAmnBC","sourcesContent":["import * as ts from 'typescript';\nimport { WpInt, WpMax, WpMin } from '@webpieces/core-util';\nimport {\n DocumentedField,\n DocumentedType,\n UnionDiscriminator,\n UnmappedType,\n} from '../model/ApiDocModel';\nimport { PrimitiveKind, TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { JsDoc } from './JsDoc';\nimport { ObjectShape, ObjectShapeBases } from './ObjectShapeBases';\nimport { SourceLocation } from './SourceLocation';\nimport { StringValueSets } from './StringValueSets';\n\n/**\n * The decorators this resolver reads off a DTO property, named from the REAL SYMBOLS — a rename in\n * `core-util` is a compile error here rather than a literal that quietly stops matching. See\n * {@link ApiDocExtractor}'s constants for the full argument (issue #1001).\n */\nconst INT_DECORATOR = WpInt.name;\nconst MIN_DECORATOR = WpMin.name;\nconst MAX_DECORATOR = WpMax.name;\n\n/**\n * The type-alias name that DECLARES integer-ness.\n *\n * This one is a LITERAL and cannot be anything else: `Integer` is a TYPE ALIAS, so there is no\n * runtime symbol whose `.name` could be read — `.name` is a property of a function, and a type has\n * erased by then. It is the one name in this package that a rename in `core-util` would not break at\n * compile time; the cure if that ever bites is to make integer-ness a decorator here too, not to\n * pretend a type has a runtime identity. See {@link ApiDocExtractor}'s constants for the argument\n * everywhere else (issue #1001).\n */\nconst INTEGER_ALIAS = 'Integer';\n\n/**\n * Resolve declared TypeScript types into {@link TypeRef}s, registering every NAMED type it meets as\n * a {@link DocumentedType} a renderer can `$ref`.\n *\n * ## It walks TYPE NODES, not checker types, and that is load-bearing\n *\n * `type Integer = number` resolves, in the checker, to `number` — the alias is gone. Integer-ness is\n * therefore invisible to a checker-driven walk, and the whole reason `Integer` is the PREFERRED\n * spelling is that it COMPOSES: `Integer[]` and `Record<string, Integer>` say exactly which thing is\n * an integer, where a decorator on `counts?: number[]` cannot (the same ambiguity the deleted\n * `arrayItems` argument had). Walking the written syntax is what keeps that composition readable.\n *\n * ## Cycles terminate BY CONSTRUCTION\n *\n * Every named type is ONE entry in the model, registered before its fields are walked, so a type\n * that refers back to itself resolves to a `$ref` at the second visit and stops. There is NO depth\n * counter anywhere — a deep-but-finite graph of 7, 20 or 200 named hops is fully expanded, because\n * truncating one would silently publish an incomplete document. The ONLY thing that is cut is a\n * self-referential ANONYMOUS type, and it is cut by NODE IDENTITY (it has no name to `$ref`), with an\n * {@link UnmappedType} recorded so #982's guard has something to name.\n */\nexport class TypeResolver {\n private readonly types = new Map<string, DocumentedType>();\n private readonly unmapped: UnmappedType[] = [];\n /** Named types already registered (or mid-registration) — the cycle stop for the NAMED case. */\n private readonly registered = new Set<string>();\n /** Anonymous type literals currently being expanded — the cycle stop for the ANONYMOUS case. */\n private readonly expandingAnonymous = new Set<ts.TypeNode>();\n\n private readonly bases: ObjectShapeBases;\n\n constructor(checker: ts.TypeChecker) {\n this.bases = new ObjectShapeBases(checker);\n }\n\n /** Every named type reached so far, by name. */\n collectedTypes(): ReadonlyMap<string, DocumentedType> {\n return this.types;\n }\n\n /** Everything that could not be represented — recorded, never dropped. */\n collectedUnmapped(): readonly UnmappedType[] {\n return this.unmapped;\n }\n\n /** Resolve one written type, registering whatever named types it reaches. */\n resolve(node: ts.TypeNode, ownerName: string): TypeRef {\n if (ts.isParenthesizedTypeNode(node)) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isArrayTypeNode(node)) {\n return TypeRef.array(this.resolve(node.elementType, ownerName));\n }\n // `readonly X[]` is a TypeOperator wrapping the array. `readonly` is a compile-time promise\n // about the HOLDER, not the wire: the JSON is the same array, so it resolves exactly like\n // `X[]` — as `ReadonlyArray<X>` already does in resolveReference (#1055).\n if (\n ts.isTypeOperatorNode(node) &&\n node.operator === ts.SyntaxKind.ReadonlyKeyword &&\n ts.isArrayTypeNode(node.type)\n ) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isUnionTypeNode(node)) {\n return this.resolveUnion(node, ownerName);\n }\n if (ts.isTypeLiteralNode(node)) {\n return this.resolveAnonymousObject(node, ownerName);\n }\n if (ts.isLiteralTypeNode(node)) {\n return this.resolveLiteral(node);\n }\n if (ts.isTypeReferenceNode(node)) {\n return this.resolveReference(node, ownerName);\n }\n const primitive = TypeResolver.keywordOf(node.kind);\n if (primitive !== undefined) {\n return TypeRef.primitiveOf(primitive);\n }\n return this.recordUnmapped(node, 'no model representation for this type form');\n }\n\n /** `string` / `number` / `boolean` / `null` / `unknown`, or undefined for anything else. */\n // webpieces-disable no-function-outside-class -- private static lookup table of this class\n private static keywordOf(kind: ts.SyntaxKind): PrimitiveKind | undefined {\n switch (kind) {\n case ts.SyntaxKind.StringKeyword:\n return 'string';\n case ts.SyntaxKind.NumberKeyword:\n return 'number';\n case ts.SyntaxKind.BooleanKeyword:\n return 'boolean';\n case ts.SyntaxKind.NullKeyword:\n return 'null';\n case ts.SyntaxKind.UnknownKeyword:\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.VoidKeyword:\n return 'unknown';\n default:\n return undefined;\n }\n }\n\n private resolveLiteral(node: ts.LiteralTypeNode): TypeRef {\n if (ts.isStringLiteral(node.literal)) {\n return TypeRef.enumOf([node.literal.text]);\n }\n if (node.literal.kind === ts.SyntaxKind.NullKeyword) {\n return TypeRef.primitiveOf('null');\n }\n if (\n node.literal.kind === ts.SyntaxKind.TrueKeyword ||\n node.literal.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return TypeRef.primitiveOf('boolean');\n }\n if (ts.isNumericLiteral(node.literal)) {\n return TypeRef.primitiveOf('number');\n }\n return this.recordUnmapped(\n node,\n 'literal type is neither a string, a number nor a boolean',\n );\n }\n\n /**\n * A union, after `null` / `undefined` have been dropped (the FIELD records those as nullable /\n * optional — see {@link fieldOf} — because `{}` and `{x: null}` are different wire documents).\n *\n * The outcomes, in this order:\n * - every branch a string literal -> an ENUM\n * - one branch left -> that branch\n * - every branch a string VALUE -> an ENUM of all of them: string literals, string-enum\n * (literal, enum member, or members (`VoiceMode.A | VoiceMode.B`) and whole string\n * whole string enum) enums, in declaration order (#1023)\n * - every branch a named object -> a UNION, with a DERIVED discriminator when every branch\n * carries the same property typed as string VALUES — one\n * literal / enum member, or a union of them — and no value\n * is claimed by two branches\n * - anything else -> an {@link UnmappedType}. No invented discriminator, ever:\n * a union TypeScript itself cannot narrow is not one a\n * renderer may claim to.\n */\n private resolveUnion(node: ts.UnionTypeNode, ownerName: string): TypeRef {\n const branches = node.types.filter((t: ts.TypeNode) => !TypeResolver.isNullish(t));\n\n const literals = branches.filter(\n (t: ts.TypeNode) => ts.isLiteralTypeNode(t) && ts.isStringLiteral(t.literal),\n );\n if (literals.length === branches.length && branches.length > 0) {\n return TypeRef.enumOf(\n literals.map(\n (t: ts.TypeNode) =>\n ((t as ts.LiteralTypeNode).literal as ts.StringLiteral).text,\n ),\n );\n }\n\n if (branches.length === 1) {\n return this.resolve(branches[0], ownerName);\n }\n if (branches.length === 0) {\n return TypeRef.primitiveOf('null');\n }\n\n const refs: TypeRef[] = branches.map((t: ts.TypeNode) => this.resolve(t, ownerName));\n const values = new StringValueSets(this.types).valuesOfAll(refs);\n if (values !== undefined) {\n return TypeRef.enumOf(values);\n }\n if (!refs.every((r: TypeRef) => r.kind === 'ref')) {\n return this.recordUnmapped(\n node,\n 'a union whose branches are not all NAMED object types has no discriminator a renderer could narrow on',\n );\n }\n\n const names = refs.map((r: TypeRef) => r.refName!);\n const discriminator = new StringValueSets(this.types).derive(names);\n if (discriminator === undefined) {\n return this.recordUnmapped(\n node,\n 'no property is typed as string values (a literal, a string-enum member, or a union of them) on EVERY ' +\n 'branch with no value shared by two branches, so this union has no derivable discriminator',\n );\n }\n this.registerUnionAlias(node, names, discriminator);\n return TypeRef.union(names);\n }\n\n /** `null` and `undefined` branches — recorded as nullable/optional on the FIELD, not in the union. */\n // webpieces-disable no-function-outside-class -- private static predicate of this class\n private static isNullish(node: ts.TypeNode): boolean {\n if (\n node.kind === ts.SyntaxKind.UndefinedKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword\n ) {\n return true;\n }\n return ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword;\n }\n\n /** A union written as a named `type X = A | B` becomes its own model entry, so #982 can `$ref` it. */\n private registerUnionAlias(\n node: ts.UnionTypeNode,\n branchNames: readonly string[],\n discriminator: UnionDiscriminator,\n ): void {\n const alias = node.parent;\n if (!ts.isTypeAliasDeclaration(alias)) {\n return;\n }\n const name = alias.name.text;\n if (this.registered.has(name)) {\n return;\n }\n this.registered.add(name);\n this.types.set(\n name,\n new DocumentedType(\n name,\n JsDoc.read(alias).description,\n [],\n [],\n branchNames,\n discriminator,\n undefined,\n ),\n );\n }\n\n /**\n * `Integer`, `Array<T>`, `Record<string, V>`, `Promise<T>`, and everything named — an interface,\n * a class, or a type alias. Anything else (a `Map`, a `Date`, a generic parameter) is recorded\n * rather than guessed at.\n */\n private resolveReference(node: ts.TypeReferenceNode, ownerName: string): TypeRef {\n const name = ts.isIdentifier(node.typeName) ? node.typeName.text : node.typeName.right.text;\n const args = node.typeArguments ?? [];\n\n if (name === INTEGER_ALIAS) {\n return TypeRef.primitiveOf('number', /*integer*/ true);\n }\n if ((name === 'Array' || name === 'ReadonlyArray') && args.length === 1) {\n return TypeRef.array(this.resolve(args[0], ownerName));\n }\n if ((name === 'Record' || name === 'Partial') && args.length === 2) {\n return TypeRef.openMap(this.resolve(args[1], ownerName));\n }\n if (name === 'Promise' && args.length === 1) {\n return this.resolve(args[0], ownerName);\n }\n\n // `VoiceMode.RANDOM` is a QualifiedName; the member's symbol is the one on its RIGHT side.\n const declaration = this.declarationOf(\n ts.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName,\n );\n if (declaration === undefined) {\n return this.recordUnmapped(node, `no declaration found for '${name}'`);\n }\n return this.resolveDeclaration(name, declaration, ownerName);\n }\n\n /**\n * Resolve a type by its DECLARATION rather than by a reference to it.\n *\n * The reference path above is the normal one — a field says `Customer` and the resolver follows\n * it. This entry point exists for a type that is named from OUTSIDE the source: a manifest naming\n * the document-wide error body, which no field in the contract points at. Same registration, same\n * cycle story, so the two cannot disagree about what a type IS.\n */\n resolveDeclaration(name: string, declaration: ts.Declaration, ownerName: string): TypeRef {\n if (ts.isInterfaceDeclaration(declaration) || ts.isClassDeclaration(declaration)) {\n return this.registerNamedObject(name, declaration);\n }\n if (ts.isTypeAliasDeclaration(declaration)) {\n return this.resolveAlias(name, declaration, ownerName);\n }\n if (ts.isEnumDeclaration(declaration)) {\n return this.registerStringEnum(name, declaration);\n }\n if (ts.isEnumMember(declaration)) {\n return this.resolveEnumMember(name, declaration);\n }\n return this.recordUnmapped(\n declaration,\n `'${name}' is declared as something with no document shape`,\n );\n }\n\n /** `type X = ...` — registered under X when it has a shape of its own, else transparent. */\n private resolveAlias(name: string, alias: ts.TypeAliasDeclaration, ownerName: string): TypeRef {\n if (this.registered.has(name)) {\n return this.types.get(name)?.unionRefNames.length\n ? TypeRef.union(this.types.get(name)!.unionRefNames)\n : TypeRef.ref(name);\n }\n\n if (ts.isUnionTypeNode(alias.type)) {\n const resolved = this.resolve(alias.type, ownerName);\n if (resolved.kind === 'enum') {\n this.registered.add(name);\n this.types.set(\n name,\n new DocumentedType(\n name,\n JsDoc.read(alias).description,\n [],\n resolved.enumValues,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(name);\n }\n return resolved;\n }\n\n if (ts.isTypeLiteralNode(alias.type)) {\n return this.registerNamedObject(name, alias.type, alias);\n }\n return this.resolve(alias.type, ownerName);\n }\n\n /**\n * ONE member of a string enum used as a type — `mode: VoiceMode.RANDOM` — which holds exactly\n * that member's VALUE on the wire. It is what a union branch's discriminator is written as once\n * the enum is the one spelling of a fixed set (#1023), so it resolves to a one-value enum exactly\n * like `mode: 'random'` does.\n */\n private resolveEnumMember(name: string, member: ts.EnumMember): TypeRef {\n if (member.initializer !== undefined && ts.isStringLiteral(member.initializer)) {\n return TypeRef.enumOf([member.initializer.text]);\n }\n return this.recordUnmapped(\n member,\n `enum member '${name}' is not initialised with a string literal, so it has no string value to publish`,\n );\n }\n\n /** A TS `enum` of string members — the one non-union enum shape a document can carry. */\n private registerStringEnum(name: string, declaration: ts.EnumDeclaration): TypeRef {\n if (this.registered.has(name)) {\n return TypeRef.ref(name);\n }\n const values: string[] = [];\n for (const member of declaration.members) {\n if (member.initializer && ts.isStringLiteral(member.initializer)) {\n values.push(member.initializer.text);\n }\n }\n if (values.length !== declaration.members.length) {\n return this.recordUnmapped(\n declaration,\n `enum '${name}' has members that are not string literals`,\n );\n }\n this.registered.add(name);\n this.types.set(\n name,\n new DocumentedType(\n name,\n JsDoc.read(declaration).description,\n [],\n values,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(name);\n }\n\n /**\n * Register a named object shape, RESERVING THE NAME BEFORE walking its fields. That order is the\n * whole cycle story: a type that refers back to itself meets `registered.has(name)` on the second\n * visit and resolves to a `$ref`, so the walk terminates with no counter and no truncation.\n *\n * The fields are the shape's WHOLE document — every field it inherits through `extends` as well\n * as its own. See {@link collectFields}.\n */\n private registerNamedObject(name: string, shape: ObjectShape, docSource?: ts.Node): TypeRef {\n if (this.registered.has(name)) {\n return TypeRef.ref(name);\n }\n this.registered.add(name);\n\n const fields = new Map<string, DocumentedField>();\n const indexSignature = this.collectFields(shape, name, fields, new Set<ObjectShape>());\n\n this.types.set(\n name,\n new DocumentedType(\n name,\n JsDoc.read(docSource ?? shape).description,\n Array.from(fields.values()),\n [],\n [],\n undefined,\n indexSignature,\n ),\n );\n return TypeRef.ref(name);\n }\n\n /**\n * Collect `shape`'s fields into `fields`, FLATTENING every base it `extends` (#1055).\n *\n * A subclass's JSON carries its base's fields, so a document that published only the subclass's\n * own members was a CLOSED schema (`additionalProperties: false`) that refused every real call.\n * The rules are TypeScript's own:\n *\n * - bases first, in `extends` order (`interface X extends A, B`), each walked recursively, so a\n * two-level chain flattens completely;\n * - a redeclared field WINS — `Map.set` replaces the inherited entry in its original position —\n * and it is the redeclaration's type, optionality, prose and bounds that publish, because\n * required/optional belongs to whichever type DECLARES the field;\n * - a base may live in another file or package (source or a published `.d.ts`); its JSDoc is\n * read from there.\n *\n * Flattened, not `allOf: [{$ref: Base}, {...}]`: an MCP client reads `properties` + `required`\n * directly, and a base is an implementation detail of the TypeScript, not a wire concept. So a\n * base is NOT registered as a model entry of its own; it appears only if something refers to it.\n *\n * Which bases count, and why an unresolvable one is a build failure, is {@link ObjectShapeBases}.\n */\n private collectFields(\n shape: ObjectShape,\n ownerName: string,\n fields: Map<string, DocumentedField>,\n visiting: Set<ObjectShape>,\n ): TypeRef | undefined {\n visiting.add(shape);\n let indexSignature: TypeRef | undefined;\n for (const baseShape of this.bases.of(shape)) {\n if (visiting.has(baseShape)) {\n continue;\n }\n indexSignature =\n this.collectFields(baseShape, ownerName, fields, visiting) ?? indexSignature;\n }\n for (const member of shape.members) {\n if (ts.isIndexSignatureDeclaration(member)) {\n indexSignature = this.resolve(member.type, ownerName);\n continue;\n }\n const field = this.fieldOf(member, ownerName);\n if (field !== undefined) {\n fields.set(field.name, field);\n }\n }\n visiting.delete(shape);\n return indexSignature;\n }\n\n /**\n * An inline `{ ... }`. It has no name to `$ref`, so it is registered under an OWNER-DERIVED one\n * (`Parent.field`) — a renderer needs a target, and a name derived from where the shape is\n * written is the only honest one available.\n *\n * A self-referential anonymous type is cut HERE, by NODE IDENTITY. It cannot be a `$ref` (there\n * is no declared name to point at) and it cannot be expanded (it would never end), so it is\n * recorded as unmapped and the walk returns.\n */\n private resolveAnonymousObject(node: ts.TypeLiteralNode, ownerName: string): TypeRef {\n if (this.expandingAnonymous.has(node)) {\n return this.recordUnmapped(\n node,\n 'a self-referential ANONYMOUS object type has no name a renderer could $ref; give it a name',\n );\n }\n const indexOnly =\n node.members.length === 1 && ts.isIndexSignatureDeclaration(node.members[0]);\n if (indexOnly) {\n const signature = node.members[0] as ts.IndexSignatureDeclaration;\n return TypeRef.openMap(this.resolve(signature.type, ownerName));\n }\n\n this.expandingAnonymous.add(node);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- the stack entry must be dropped whatever the walk does\n try {\n return this.registerNamedObject(ownerName, node);\n } finally {\n this.expandingAnonymous.delete(node);\n }\n }\n\n /** ONE property of a DTO — its type, its optionality, its prose and its numeric constraints. */\n private fieldOf(\n member: ts.TypeElement | ts.ClassElement,\n ownerName: string,\n ): DocumentedField | undefined {\n if (!ts.isPropertySignature(member) && !ts.isPropertyDeclaration(member)) {\n return undefined;\n }\n if (!ts.isIdentifier(member.name) && !ts.isStringLiteral(member.name)) {\n return undefined;\n }\n const name = member.name.text;\n if (member.type === undefined) {\n return undefined;\n }\n\n const optional =\n member.questionToken !== undefined || TypeResolver.declaresUndefined(member.type);\n const nullable = TypeResolver.declaresNull(member.type);\n\n let type = this.resolve(member.type, `${ownerName}.${name}`);\n if (TypeResolver.hasDecorator(member, INT_DECORATOR)) {\n type = TypeResolver.markInteger(type);\n }\n\n const doc = JsDoc.read(member);\n const min = this.numericArgument(member, MIN_DECORATOR);\n const max = this.numericArgument(member, MAX_DECORATOR);\n this.assertNumericConstraintsFit(member, name, type, min, max);\n\n return new DocumentedField(\n name,\n type,\n optional,\n nullable,\n doc.description,\n doc.mcp,\n doc.format,\n min,\n max,\n doc.mcpHeader,\n SourceLocation.of(member),\n );\n }\n\n /**\n * `@WpMin` / `@WpMax` on a non-numeric field is a BUILD FAILURE, not a warning. A minimum on a\n * string is not something a renderer can emit sensibly, and a document that silently dropped it\n * would publish a contract weaker than the one its author wrote down.\n */\n private assertNumericConstraintsFit(\n member: ts.Node,\n name: string,\n type: TypeRef,\n min: number | undefined,\n max: number | undefined,\n ): void {\n if (min === undefined && max === undefined) {\n return;\n }\n const numeric = type.isNumeric() || (type.kind === 'array' && type.items!.isNumeric());\n if (numeric) {\n return;\n }\n throw new ApiDocExtractionError(\n `@${MIN_DECORATOR}/@${MAX_DECORATOR} on non-numeric field '${name}'`,\n SourceLocation.of(member),\n 'Put the constraint on a `number` / `Integer` field, or drop it.',\n );\n }\n\n /** `@WpInt()` decorates the FIELD, so the integer flag is pushed onto the right leaf. */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static markInteger(type: TypeRef): TypeRef {\n if (type.kind === 'array') {\n return TypeRef.array(type.items!.asInteger());\n }\n if (type.kind === 'openMap') {\n return TypeRef.openMap(type.values!.asInteger());\n }\n return type.asInteger();\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static declaresUndefined(node: ts.TypeNode): boolean {\n return (\n ts.isUnionTypeNode(node) &&\n node.types.some((t: ts.TypeNode) => t.kind === ts.SyntaxKind.UndefinedKeyword)\n );\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static declaresNull(node: ts.TypeNode): boolean {\n return (\n ts.isUnionTypeNode(node) &&\n node.types.some(\n (t: ts.TypeNode) =>\n t.kind === ts.SyntaxKind.NullKeyword ||\n (ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword),\n )\n );\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static hasDecorator(node: ts.Node, decoratorName: string): boolean {\n return TypeResolver.decoratorCall(node, decoratorName) !== undefined;\n }\n\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static decoratorCall(\n node: ts.Node,\n decoratorName: string,\n ): ts.CallExpression | undefined {\n const decorators = ts.canHaveDecorators(node) ? (ts.getDecorators(node) ?? []) : [];\n for (const decorator of decorators) {\n const call = decorator.expression;\n if (\n ts.isCallExpression(call) &&\n ts.isIdentifier(call.expression) &&\n call.expression.text === decoratorName\n ) {\n return call;\n }\n }\n return undefined;\n }\n\n private numericArgument(node: ts.Node, decoratorName: string): number | undefined {\n const call = TypeResolver.decoratorCall(node, decoratorName);\n const argument = call?.arguments[0];\n if (argument === undefined) {\n return undefined;\n }\n if (ts.isNumericLiteral(argument)) {\n return Number(argument.text);\n }\n if (\n ts.isPrefixUnaryExpression(argument) &&\n argument.operator === ts.SyntaxKind.MinusToken &&\n ts.isNumericLiteral(argument.operand)\n ) {\n return -Number(argument.operand.text);\n }\n throw new ApiDocExtractionError(\n `@${decoratorName} argument is not a numeric literal: '${argument.getText()}'`,\n SourceLocation.of(argument),\n 'Write the bound as a numeric literal. A value only known at runtime cannot be published.',\n );\n }\n\n /** The declaration a type name points at, through imports and aliases. */\n private declarationOf(name: ts.EntityName): ts.Declaration | undefined {\n return this.bases.declarationOf(name);\n }\n\n private recordUnmapped(node: ts.Node, reason: string): TypeRef {\n const text = node.getText();\n this.unmapped.push(new UnmappedType(text, SourceLocation.of(node), reason));\n return TypeRef.unmapped(text);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypeResolver.js","sourceR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GAAG,iCAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,GAAG,GAAG,aAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,iCAAe,CAAC,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,iCAAe,CAAC,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACnE,iCAAe,CAAC,2BAA2B,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAE1E,OAAO,IAAI,6BAAe,CACtB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,GAAG,EACP,GAAG,CAAC,MAAM,EACV,GAAG,EACH,GAAG,EACH,GAAG,CAAC,SAAS,EACb,+BAAc,CAAC,EAAE,CAAC,MAAM,CAAC,CAC5B,CAAC;IACN,CAAC;IAED,0EAA0E;IAClE,aAAa,CAAC,IAAmB;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEO,cAAc,CAAC,IAAa,EAAE,MAAc;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,0BAAY,CAAC,IAAI,EAAE,+BAAc,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5E,OAAO,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AA1jBD,oCA0jBC","sourcesContent":["import * as ts from 'typescript';\nimport { WpInt, WpMax, WpMin } from '@webpieces/core-util';\nimport {\n DocumentedField,\n DocumentedType,\n TypeNameCollision,\n UnionDiscriminator,\n UnmappedType,\n} from '../model/ApiDocModel';\nimport { PrimitiveKind, TypeRef } from '../model/TypeRef';\nimport { ApiDocExtractionError } from './ApiDocExtractionError';\nimport { JsDoc } from './JsDoc';\nimport { ObjectShape, ObjectShapeBases } from './ObjectShapeBases';\nimport { FieldDecorators } from './FieldDecorators';\nimport { PackageOfFile } from './PackageOfFile';\nimport { TypeRegistry } from './TypeRegistry';\nimport { SourceLocation } from './SourceLocation';\nimport { StringValueSets } from './StringValueSets';\n\n/**\n * The decorators this resolver reads off a DTO property, named from the REAL SYMBOLS — a rename in\n * `core-util` is a compile error here rather than a literal that quietly stops matching. See\n * {@link ApiDocExtractor}'s constants for the full argument (issue #1001).\n */\nconst INT_DECORATOR = WpInt.name;\nconst MIN_DECORATOR = WpMin.name;\nconst MAX_DECORATOR = WpMax.name;\n\n/**\n * The type-alias name that DECLARES integer-ness.\n *\n * This one is a LITERAL and cannot be anything else: `Integer` is a TYPE ALIAS, so there is no\n * runtime symbol whose `.name` could be read — `.name` is a property of a function, and a type has\n * erased by then. It is the one name in this package that a rename in `core-util` would not break at\n * compile time; the cure if that ever bites is to make integer-ness a decorator here too, not to\n * pretend a type has a runtime identity. See {@link ApiDocExtractor}'s constants for the argument\n * everywhere else (issue #1001).\n */\nconst INTEGER_ALIAS = 'Integer';\n\n/**\n * Resolve declared TypeScript types into {@link TypeRef}s, registering every NAMED type it meets as\n * a {@link DocumentedType} a renderer can `$ref`.\n *\n * ## It walks TYPE NODES, not checker types, and that is load-bearing\n *\n * `type Integer = number` resolves, in the checker, to `number` — the alias is gone. Integer-ness is\n * therefore invisible to a checker-driven walk, and the whole reason `Integer` is the PREFERRED\n * spelling is that it COMPOSES: `Integer[]` and `Record<string, Integer>` say exactly which thing is\n * an integer, where a decorator on `counts?: number[]` cannot (the same ambiguity the deleted\n * `arrayItems` argument had). Walking the written syntax is what keeps that composition readable.\n *\n * ## Cycles terminate BY CONSTRUCTION\n *\n * Every named type is ONE entry in the model, registered before its fields are walked, so a type\n * that refers back to itself resolves to a `$ref` at the second visit and stops. There is NO depth\n * counter anywhere — a deep-but-finite graph of 7, 20 or 200 named hops is fully expanded, because\n * truncating one would silently publish an incomplete document. The ONLY thing that is cut is a\n * self-referential ANONYMOUS type, and it is cut by NODE IDENTITY (it has no name to `$ref`), with an\n * {@link UnmappedType} recorded so #982's guard has something to name.\n *\n * ## Every type is keyed by its DECLARING PACKAGE too (#1058)\n *\n * A type is registered under {@link DocumentedType.keyOf}: its bare name when the HOME package (the\n * one whose file is being extracted) declares it, `<package>:<name>` otherwise. Two packages'\n * same-named types are therefore two entries rather than one silently standing in for the other, and\n * a renderer can tell which document owns each schema. The name is always the DECLARATION's own, never\n * an import alias, so one type reached under two spellings is still one entry.\n */\nexport class TypeResolver {\n private readonly unmapped: UnmappedType[] = [];\n /** Every named type, its key and the declaration that claimed it — see {@link TypeRegistry}. */\n private readonly registry: TypeRegistry;\n /** Anonymous type literals currently being expanded — the cycle stop for the ANONYMOUS case. */\n private readonly expandingAnonymous = new Set<ts.TypeNode>();\n\n private readonly bases: ObjectShapeBases;\n\n constructor(\n checker: ts.TypeChecker,\n packages: PackageOfFile,\n /** The package of the file being extracted — its types are keyed by their bare name. */\n homePackage: string | undefined,\n ) {\n this.bases = new ObjectShapeBases(checker);\n this.registry = new TypeRegistry(packages, homePackage);\n }\n\n /** Every named type reached so far, by key — see {@link DocumentedType.keyOf}. */\n collectedTypes(): ReadonlyMap<string, DocumentedType> {\n return this.registry.types;\n }\n\n /** Everything that could not be represented — recorded, never dropped. */\n collectedUnmapped(): readonly UnmappedType[] {\n return this.unmapped;\n }\n\n /** Same-named, different declarations in one package — see {@link TypeNameCollision}. */\n collectedCollisions(): readonly TypeNameCollision[] {\n return this.registry.collisions;\n }\n\n /** The key `name`, declared at `node`, is registered under. */\n keyFor(name: string, node: ts.Node): string {\n return this.registry.keyFor(name, node);\n }\n\n /** Resolve one written type, registering whatever named types it reaches. */\n resolve(node: ts.TypeNode, ownerName: string): TypeRef {\n if (ts.isParenthesizedTypeNode(node)) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isArrayTypeNode(node)) {\n return TypeRef.array(this.resolve(node.elementType, ownerName));\n }\n // `readonly X[]` is a TypeOperator wrapping the array. `readonly` is a compile-time promise\n // about the HOLDER, not the wire: the JSON is the same array, so it resolves exactly like\n // `X[]` — as `ReadonlyArray<X>` already does in resolveReference (#1055).\n if (\n ts.isTypeOperatorNode(node) &&\n node.operator === ts.SyntaxKind.ReadonlyKeyword &&\n ts.isArrayTypeNode(node.type)\n ) {\n return this.resolve(node.type, ownerName);\n }\n if (ts.isUnionTypeNode(node)) {\n return this.resolveUnion(node, ownerName);\n }\n if (ts.isTypeLiteralNode(node)) {\n return this.resolveAnonymousObject(node, ownerName);\n }\n if (ts.isLiteralTypeNode(node)) {\n return this.resolveLiteral(node);\n }\n if (ts.isTypeReferenceNode(node)) {\n return this.resolveReference(node, ownerName);\n }\n const primitive = TypeResolver.keywordOf(node.kind);\n if (primitive !== undefined) {\n return TypeRef.primitiveOf(primitive);\n }\n return this.recordUnmapped(node, 'no model representation for this type form');\n }\n\n /** `string` / `number` / `boolean` / `null` / `unknown`, or undefined for anything else. */\n // webpieces-disable no-function-outside-class -- private static lookup table of this class\n private static keywordOf(kind: ts.SyntaxKind): PrimitiveKind | undefined {\n switch (kind) {\n case ts.SyntaxKind.StringKeyword:\n return 'string';\n case ts.SyntaxKind.NumberKeyword:\n return 'number';\n case ts.SyntaxKind.BooleanKeyword:\n return 'boolean';\n case ts.SyntaxKind.NullKeyword:\n return 'null';\n case ts.SyntaxKind.UnknownKeyword:\n case ts.SyntaxKind.AnyKeyword:\n case ts.SyntaxKind.VoidKeyword:\n return 'unknown';\n default:\n return undefined;\n }\n }\n\n private resolveLiteral(node: ts.LiteralTypeNode): TypeRef {\n if (ts.isStringLiteral(node.literal)) {\n return TypeRef.enumOf([node.literal.text]);\n }\n if (node.literal.kind === ts.SyntaxKind.NullKeyword) {\n return TypeRef.primitiveOf('null');\n }\n if (\n node.literal.kind === ts.SyntaxKind.TrueKeyword ||\n node.literal.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return TypeRef.primitiveOf('boolean');\n }\n if (ts.isNumericLiteral(node.literal)) {\n return TypeRef.primitiveOf('number');\n }\n return this.recordUnmapped(\n node,\n 'literal type is neither a string, a number nor a boolean',\n );\n }\n\n /**\n * A union, after `null` / `undefined` have been dropped (the FIELD records those as nullable /\n * optional — see {@link fieldOf} — because `{}` and `{x: null}` are different wire documents).\n *\n * The outcomes, in this order:\n * - every branch a string literal -> an ENUM\n * - one branch left -> that branch\n * - every branch a string VALUE -> an ENUM of all of them: string literals, string-enum\n * (literal, enum member, or members (`VoiceMode.A | VoiceMode.B`) and whole string\n * whole string enum) enums, in declaration order (#1023)\n * - every branch a named object -> a UNION, with a DERIVED discriminator when every branch\n * carries the same property typed as string VALUES — one\n * literal / enum member, or a union of them — and no value\n * is claimed by two branches\n * - anything else -> an {@link UnmappedType}. No invented discriminator, ever:\n * a union TypeScript itself cannot narrow is not one a\n * renderer may claim to.\n */\n private resolveUnion(node: ts.UnionTypeNode, ownerName: string): TypeRef {\n const branches = node.types.filter((t: ts.TypeNode) => !TypeResolver.isNullish(t));\n\n const literals = branches.filter(\n (t: ts.TypeNode) => ts.isLiteralTypeNode(t) && ts.isStringLiteral(t.literal),\n );\n if (literals.length === branches.length && branches.length > 0) {\n return TypeRef.enumOf(\n literals.map(\n (t: ts.TypeNode) =>\n ((t as ts.LiteralTypeNode).literal as ts.StringLiteral).text,\n ),\n );\n }\n\n if (branches.length === 1) {\n return this.resolve(branches[0], ownerName);\n }\n if (branches.length === 0) {\n return TypeRef.primitiveOf('null');\n }\n\n const refs: TypeRef[] = branches.map((t: ts.TypeNode) => this.resolve(t, ownerName));\n const values = new StringValueSets(this.registry.types).valuesOfAll(refs);\n if (values !== undefined) {\n return TypeRef.enumOf(values);\n }\n if (!refs.every((r: TypeRef) => r.kind === 'ref')) {\n return this.recordUnmapped(\n node,\n 'a union whose branches are not all NAMED object types has no discriminator a renderer could narrow on',\n );\n }\n\n const names = refs.map((r: TypeRef) => r.refName!);\n const discriminator = new StringValueSets(this.registry.types).derive(names);\n if (discriminator === undefined) {\n return this.recordUnmapped(\n node,\n 'no property is typed as string values (a literal, a string-enum member, or a union of them) on EVERY ' +\n 'branch with no value shared by two branches, so this union has no derivable discriminator',\n );\n }\n this.registerUnionAlias(node, names, discriminator);\n return TypeRef.union(names);\n }\n\n /** `null` and `undefined` branches — recorded as nullable/optional on the FIELD, not in the union. */\n // webpieces-disable no-function-outside-class -- private static predicate of this class\n private static isNullish(node: ts.TypeNode): boolean {\n if (\n node.kind === ts.SyntaxKind.UndefinedKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword\n ) {\n return true;\n }\n return ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword;\n }\n\n /** A union written as a named `type X = A | B` becomes its own model entry, so #982 can `$ref` it. */\n private registerUnionAlias(\n node: ts.UnionTypeNode,\n branchNames: readonly string[],\n discriminator: UnionDiscriminator,\n ): void {\n const alias = node.parent;\n if (!ts.isTypeAliasDeclaration(alias)) {\n return;\n }\n const name = alias.name.text;\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return;\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n JsDoc.read(alias).description,\n [],\n [],\n branchNames,\n discriminator,\n undefined,\n ),\n );\n }\n\n /**\n * `Integer`, `Array<T>`, `Record<string, V>`, `Promise<T>`, and everything named — an interface,\n * a class, or a type alias. Anything else (a `Map`, a `Date`, a generic parameter) is recorded\n * rather than guessed at.\n */\n private resolveReference(node: ts.TypeReferenceNode, ownerName: string): TypeRef {\n const name = ts.isIdentifier(node.typeName) ? node.typeName.text : node.typeName.right.text;\n const args = node.typeArguments ?? [];\n\n if (name === INTEGER_ALIAS) {\n return TypeRef.primitiveOf('number', /*integer*/ true);\n }\n if ((name === 'Array' || name === 'ReadonlyArray') && args.length === 1) {\n return TypeRef.array(this.resolve(args[0], ownerName));\n }\n if ((name === 'Record' || name === 'Partial') && args.length === 2) {\n return TypeRef.openMap(this.resolve(args[1], ownerName));\n }\n if (name === 'Promise' && args.length === 1) {\n return this.resolve(args[0], ownerName);\n }\n\n // `VoiceMode.RANDOM` is a QualifiedName; the member's symbol is the one on its RIGHT side.\n const declaration = this.declarationOf(\n ts.isQualifiedName(node.typeName) ? node.typeName.right : node.typeName,\n );\n if (declaration === undefined) {\n return this.recordUnmapped(node, `no declaration found for '${name}'`);\n }\n return this.resolveDeclaration(\n TypeResolver.declaredName(declaration, name),\n declaration,\n ownerName,\n );\n }\n\n /**\n * The DECLARATION's own name, not the spelling at the use site: `import { Foo as Bar }` still\n * reaches the type `Foo`, which is what its owning package's document calls it (#1058).\n */\n // webpieces-disable no-function-outside-class -- private static helper of this class\n private static declaredName(declaration: ts.Declaration, written: string): string {\n const named =\n ts.isInterfaceDeclaration(declaration) ||\n ts.isClassDeclaration(declaration) ||\n ts.isTypeAliasDeclaration(declaration) ||\n ts.isEnumDeclaration(declaration);\n return named && declaration.name !== undefined ? declaration.name.text : written;\n }\n\n /**\n * Resolve a type by its DECLARATION rather than by a reference to it.\n *\n * The reference path above is the normal one — a field says `Customer` and the resolver follows\n * it. This entry point exists for a type that is named from OUTSIDE the source: a manifest naming\n * the document-wide error body, which no field in the contract points at. Same registration, same\n * cycle story, so the two cannot disagree about what a type IS.\n */\n resolveDeclaration(name: string, declaration: ts.Declaration, ownerName: string): TypeRef {\n if (ts.isInterfaceDeclaration(declaration) || ts.isClassDeclaration(declaration)) {\n return this.registerNamedObject(name, declaration);\n }\n if (ts.isTypeAliasDeclaration(declaration)) {\n return this.resolveAlias(name, declaration, ownerName);\n }\n if (ts.isEnumDeclaration(declaration)) {\n return this.registerStringEnum(name, declaration);\n }\n if (ts.isEnumMember(declaration)) {\n return this.resolveEnumMember(name, declaration);\n }\n return this.recordUnmapped(\n declaration,\n `'${name}' is declared as something with no document shape`,\n );\n }\n\n /** `type X = ...` — registered under X when it has a shape of its own, else transparent. */\n private resolveAlias(name: string, alias: ts.TypeAliasDeclaration, ownerName: string): TypeRef {\n const key = this.registry.keyFor(name, alias);\n if (this.registry.alreadyRegistered(key, name, alias)) {\n return this.registry.types.get(key)?.unionRefNames.length\n ? TypeRef.union(this.registry.types.get(key)!.unionRefNames)\n : TypeRef.ref(key);\n }\n\n if (ts.isUnionTypeNode(alias.type)) {\n const resolved = this.resolve(alias.type, ownerName);\n if (resolved.kind === 'enum') {\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n alias,\n JsDoc.read(alias).description,\n [],\n resolved.enumValues,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n return resolved;\n }\n\n if (ts.isTypeLiteralNode(alias.type)) {\n return this.registerNamedObject(name, alias.type, alias);\n }\n return this.resolve(alias.type, ownerName);\n }\n\n /**\n * ONE member of a string enum used as a type — `mode: VoiceMode.RANDOM` — which holds exactly\n * that member's VALUE on the wire. It is what a union branch's discriminator is written as once\n * the enum is the one spelling of a fixed set (#1023), so it resolves to a one-value enum exactly\n * like `mode: 'random'` does.\n */\n private resolveEnumMember(name: string, member: ts.EnumMember): TypeRef {\n if (member.initializer !== undefined && ts.isStringLiteral(member.initializer)) {\n return TypeRef.enumOf([member.initializer.text]);\n }\n return this.recordUnmapped(\n member,\n `enum member '${name}' is not initialised with a string literal, so it has no string value to publish`,\n );\n }\n\n /** A TS `enum` of string members — the one non-union enum shape a document can carry. */\n private registerStringEnum(name: string, declaration: ts.EnumDeclaration): TypeRef {\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.alreadyRegistered(key, name, declaration)) {\n return TypeRef.ref(key);\n }\n const values: string[] = [];\n for (const member of declaration.members) {\n if (member.initializer && ts.isStringLiteral(member.initializer)) {\n values.push(member.initializer.text);\n }\n }\n if (values.length !== declaration.members.length) {\n return this.recordUnmapped(\n declaration,\n `enum '${name}' has members that are not string literals`,\n );\n }\n this.registry.registered.add(key);\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n JsDoc.read(declaration).description,\n [],\n values,\n [],\n undefined,\n undefined,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Register a named object shape, RESERVING THE NAME BEFORE walking its fields. That order is the\n * whole cycle story: a type that refers back to itself meets `registered.has(name)` on the second\n * visit and resolves to a `$ref`, so the walk terminates with no counter and no truncation.\n *\n * The fields are the shape's WHOLE document — every field it inherits through `extends` as well\n * as its own. See {@link collectFields}.\n */\n private registerNamedObject(name: string, shape: ObjectShape, docSource?: ts.Node): TypeRef {\n const declaration = docSource ?? shape;\n const key = this.registry.keyFor(name, declaration);\n if (this.registry.registered.has(key)) {\n // An ANONYMOUS `{ ... }` is named after where it is written, so two of them can share an\n // owner-derived name; that was never a declared-name collision and is not recorded as one.\n if (!ts.isTypeLiteralNode(declaration)) {\n this.registry.alreadyRegistered(key, name, declaration);\n }\n return TypeRef.ref(key);\n }\n this.registry.claimedBy.set(key, declaration);\n this.registry.registered.add(key);\n\n const fields = new Map<string, DocumentedField>();\n const indexSignature = this.collectFields(shape, name, fields, new Set<ObjectShape>());\n\n this.registry.types.set(\n key,\n this.registry.documented(\n name,\n declaration,\n JsDoc.read(declaration).description,\n Array.from(fields.values()),\n [],\n [],\n undefined,\n indexSignature,\n ),\n );\n return TypeRef.ref(key);\n }\n\n /**\n * Collect `shape`'s fields into `fields`, FLATTENING every base it `extends` (#1055).\n *\n * A subclass's JSON carries its base's fields, so a document that published only the subclass's\n * own members was a CLOSED schema (`additionalProperties: false`) that refused every real call.\n * The rules are TypeScript's own:\n *\n * - bases first, in `extends` order (`interface X extends A, B`), each walked recursively, so a\n * two-level chain flattens completely;\n * - a redeclared field WINS — `Map.set` replaces the inherited entry in its original position —\n * and it is the redeclaration's type, optionality, prose and bounds that publish, because\n * required/optional belongs to whichever type DECLARES the field;\n * - a base may live in another file or package (source or a published `.d.ts`); its JSDoc is\n * read from there.\n *\n * Flattened, not `allOf: [{$ref: Base}, {...}]`: an MCP client reads `properties` + `required`\n * directly, and a base is an implementation detail of the TypeScript, not a wire concept. So a\n * base is NOT registered as a model entry of its own; it appears only if something refers to it.\n *\n * Which bases count, and why an unresolvable one is a build failure, is {@link ObjectShapeBases}.\n */\n private collectFields(\n shape: ObjectShape,\n ownerName: string,\n fields: Map<string, DocumentedField>,\n visiting: Set<ObjectShape>,\n ): TypeRef | undefined {\n visiting.add(shape);\n let indexSignature: TypeRef | undefined;\n for (const baseShape of this.bases.of(shape)) {\n if (visiting.has(baseShape)) {\n continue;\n }\n indexSignature =\n this.collectFields(baseShape, ownerName, fields, visiting) ?? indexSignature;\n }\n for (const member of shape.members) {\n if (ts.isIndexSignatureDeclaration(member)) {\n indexSignature = this.resolve(member.type, ownerName);\n continue;\n }\n const field = this.fieldOf(member, ownerName);\n if (field !== undefined) {\n fields.set(field.name, field);\n }\n }\n visiting.delete(shape);\n return indexSignature;\n }\n\n /**\n * An inline `{ ... }`. It has no name to `$ref`, so it is registered under an OWNER-DERIVED one\n * (`Parent.field`) — a renderer needs a target, and a name derived from where the shape is\n * written is the only honest one available.\n *\n * A self-referential anonymous type is cut HERE, by NODE IDENTITY. It cannot be a `$ref` (there\n * is no declared name to point at) and it cannot be expanded (it would never end), so it is\n * recorded as unmapped and the walk returns.\n */\n private resolveAnonymousObject(node: ts.TypeLiteralNode, ownerName: string): TypeRef {\n if (this.expandingAnonymous.has(node)) {\n return this.recordUnmapped(\n node,\n 'a self-referential ANONYMOUS object type has no name a renderer could $ref; give it a name',\n );\n }\n const indexOnly =\n node.members.length === 1 && ts.isIndexSignatureDeclaration(node.members[0]);\n if (indexOnly) {\n const signature = node.members[0] as ts.IndexSignatureDeclaration;\n return TypeRef.openMap(this.resolve(signature.type, ownerName));\n }\n\n this.expandingAnonymous.add(node);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- the stack entry must be dropped whatever the walk does\n try {\n return this.registerNamedObject(ownerName, node);\n } finally {\n this.expandingAnonymous.delete(node);\n }\n }\n\n /** ONE property of a DTO — its type, its optionality, its prose and its numeric constraints. */\n private fieldOf(\n member: ts.TypeElement | ts.ClassElement,\n ownerName: string,\n ): DocumentedField | undefined {\n if (!ts.isPropertySignature(member) && !ts.isPropertyDeclaration(member)) {\n return undefined;\n }\n if (!ts.isIdentifier(member.name) && !ts.isStringLiteral(member.name)) {\n return undefined;\n }\n const name = member.name.text;\n if (member.type === undefined) {\n return undefined;\n }\n\n const optional =\n member.questionToken !== undefined || FieldDecorators.declaresUndefined(member.type);\n const nullable = FieldDecorators.declaresNull(member.type);\n\n let type = this.resolve(member.type, `${ownerName}.${name}`);\n if (FieldDecorators.hasDecorator(member, INT_DECORATOR)) {\n type = FieldDecorators.markInteger(type);\n }\n\n const doc = JsDoc.read(member);\n const min = FieldDecorators.numericArgument(member, MIN_DECORATOR);\n const max = FieldDecorators.numericArgument(member, MAX_DECORATOR);\n FieldDecorators.assertNumericConstraintsFit(member, name, type, min, max);\n\n return new DocumentedField(\n name,\n type,\n optional,\n nullable,\n doc.description,\n doc.mcp,\n doc.format,\n min,\n max,\n doc.mcpHeader,\n SourceLocation.of(member),\n );\n }\n\n /** The declaration a type name points at, through imports and aliases. */\n private declarationOf(name: ts.EntityName): ts.Declaration | undefined {\n return this.bases.declarationOf(name);\n }\n\n private recordUnmapped(node: ts.Node, reason: string): TypeRef {\n const text = node.getText();\n this.unmapped.push(new UnmappedType(text, SourceLocation.of(node), reason));\n return TypeRef.unmapped(text);\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { ApiDocExtractor } from './extract/ApiDocExtractor';
|
|
12
12
|
export { ApiDocExtractionError } from './extract/ApiDocExtractionError';
|
|
13
|
-
export {
|
|
13
|
+
export { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';
|
|
14
|
+
export { ApiComponentsModel, ApiDocModel, DocumentedApiKey, DocumentedApiKeyCredential, DocumentedAuth, DocumentedEndpoint, DocumentedEndpointOptions, DocumentedField, DocumentedMcpTool, DocumentedType, TypeNameCollision, UnionDiscriminator, UnmappedType, } from './model/ApiDocModel';
|
|
14
15
|
export { McpRenderError } from './render/McpRenderError';
|
|
15
16
|
export { McpCatalogRender, McpSchemaRenderer, SkippedMcpTool } from './render/McpSchemaRenderer';
|
|
16
17
|
export { TypeRef } from './model/TypeRef';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeRef = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiDocExtractionError = exports.ApiDocExtractor = void 0;
|
|
3
|
+
exports.TypeRef = exports.SkippedMcpTool = exports.McpSchemaRenderer = exports.McpCatalogRender = exports.McpRenderError = exports.UnmappedType = exports.UnionDiscriminator = exports.TypeNameCollision = exports.DocumentedType = exports.DocumentedMcpTool = exports.DocumentedField = exports.DocumentedEndpointOptions = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKeyCredential = exports.DocumentedApiKey = exports.ApiDocModel = exports.ApiComponentsModel = exports.PackageOfFile = exports.DeclaringPackage = exports.ApiDocExtractionError = 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}.
|
|
@@ -15,7 +15,11 @@ var ApiDocExtractor_1 = require("./extract/ApiDocExtractor");
|
|
|
15
15
|
Object.defineProperty(exports, "ApiDocExtractor", { enumerable: true, get: function () { return ApiDocExtractor_1.ApiDocExtractor; } });
|
|
16
16
|
var ApiDocExtractionError_1 = require("./extract/ApiDocExtractionError");
|
|
17
17
|
Object.defineProperty(exports, "ApiDocExtractionError", { enumerable: true, get: function () { return ApiDocExtractionError_1.ApiDocExtractionError; } });
|
|
18
|
+
var PackageOfFile_1 = require("./extract/PackageOfFile");
|
|
19
|
+
Object.defineProperty(exports, "DeclaringPackage", { enumerable: true, get: function () { return PackageOfFile_1.DeclaringPackage; } });
|
|
20
|
+
Object.defineProperty(exports, "PackageOfFile", { enumerable: true, get: function () { return PackageOfFile_1.PackageOfFile; } });
|
|
18
21
|
var ApiDocModel_1 = require("./model/ApiDocModel");
|
|
22
|
+
Object.defineProperty(exports, "ApiComponentsModel", { enumerable: true, get: function () { return ApiDocModel_1.ApiComponentsModel; } });
|
|
19
23
|
Object.defineProperty(exports, "ApiDocModel", { enumerable: true, get: function () { return ApiDocModel_1.ApiDocModel; } });
|
|
20
24
|
Object.defineProperty(exports, "DocumentedApiKey", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedApiKey; } });
|
|
21
25
|
Object.defineProperty(exports, "DocumentedApiKeyCredential", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedApiKeyCredential; } });
|
|
@@ -25,6 +29,7 @@ Object.defineProperty(exports, "DocumentedEndpointOptions", { enumerable: true,
|
|
|
25
29
|
Object.defineProperty(exports, "DocumentedField", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedField; } });
|
|
26
30
|
Object.defineProperty(exports, "DocumentedMcpTool", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedMcpTool; } });
|
|
27
31
|
Object.defineProperty(exports, "DocumentedType", { enumerable: true, get: function () { return ApiDocModel_1.DocumentedType; } });
|
|
32
|
+
Object.defineProperty(exports, "TypeNameCollision", { enumerable: true, get: function () { return ApiDocModel_1.TypeNameCollision; } });
|
|
28
33
|
Object.defineProperty(exports, "UnionDiscriminator", { enumerable: true, get: function () { return ApiDocModel_1.UnionDiscriminator; } });
|
|
29
34
|
Object.defineProperty(exports, "UnmappedType", { enumerable: true, get: function () { return ApiDocModel_1.UnmappedType; } });
|
|
30
35
|
var McpRenderError_1 = require("./render/McpRenderError");
|
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,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,
|
|
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,yEAAwE;AAA/D,8HAAA,qBAAqB,OAAA;AAC9B,yDAA0E;AAAjE,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,mDAc6B;AAbzB,iHAAA,kBAAkB,OAAA;AAClB,0GAAA,WAAW,OAAA;AACX,+GAAA,gBAAgB,OAAA;AAChB,yHAAA,0BAA0B,OAAA;AAC1B,6GAAA,cAAc,OAAA;AACd,iHAAA,kBAAkB,OAAA;AAClB,wHAAA,yBAAyB,OAAA;AACzB,8GAAA,eAAe,OAAA;AACf,gHAAA,iBAAiB,OAAA;AACjB,6GAAA,cAAc,OAAA;AACd,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","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 { ApiDocExtractionError } from './extract/ApiDocExtractionError';\nexport { DeclaringPackage, PackageOfFile } from './extract/PackageOfFile';\nexport {\n ApiComponentsModel,\n ApiDocModel,\n DocumentedApiKey,\n DocumentedApiKeyCredential,\n DocumentedAuth,\n DocumentedEndpoint,\n DocumentedEndpointOptions,\n DocumentedField,\n DocumentedMcpTool,\n DocumentedType,\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';\n"]}
|
|
@@ -152,6 +152,17 @@ export declare class DocumentedType {
|
|
|
152
152
|
readonly discriminator: UnionDiscriminator | undefined;
|
|
153
153
|
/** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
|
|
154
154
|
readonly indexSignatureValue: TypeRef | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* The npm package whose source DECLARES this type — the nearest `package.json` above the
|
|
157
|
+
* declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract
|
|
158
|
+
* document defines the schemas its own package declares and `$ref`s every other one into
|
|
159
|
+
* that package's `components.openapi.json`. Undefined when the file belongs to no package.
|
|
160
|
+
*
|
|
161
|
+
* The MCP projection ignores it: a tool schema is always fully inlined.
|
|
162
|
+
*/
|
|
163
|
+
readonly packageName: string | undefined;
|
|
164
|
+
/** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */
|
|
165
|
+
readonly location: string;
|
|
155
166
|
constructor(name: string, description: string,
|
|
156
167
|
/** Object shape. Empty for an enum or a union. */
|
|
157
168
|
fields: readonly DocumentedField[],
|
|
@@ -162,7 +173,45 @@ export declare class DocumentedType {
|
|
|
162
173
|
/** Set only when EVERY branch carries the same property typed as one string literal. */
|
|
163
174
|
discriminator: UnionDiscriminator | undefined,
|
|
164
175
|
/** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
|
|
165
|
-
indexSignatureValue: TypeRef | undefined
|
|
176
|
+
indexSignatureValue: TypeRef | undefined,
|
|
177
|
+
/**
|
|
178
|
+
* The npm package whose source DECLARES this type — the nearest `package.json` above the
|
|
179
|
+
* declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract
|
|
180
|
+
* document defines the schemas its own package declares and `$ref`s every other one into
|
|
181
|
+
* that package's `components.openapi.json`. Undefined when the file belongs to no package.
|
|
182
|
+
*
|
|
183
|
+
* The MCP projection ignores it: a tool schema is always fully inlined.
|
|
184
|
+
*/
|
|
185
|
+
packageName: string | undefined,
|
|
186
|
+
/** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */
|
|
187
|
+
location: string);
|
|
188
|
+
/**
|
|
189
|
+
* The key this type is registered under in {@link ApiDocModel.types} and named by every
|
|
190
|
+
* {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and
|
|
191
|
+
* `<package>:<name>` for every other one, so two packages' same-named types are two entries.
|
|
192
|
+
*/
|
|
193
|
+
static keyOf(name: string, packageName: string | undefined, homePackage: string | undefined): string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).
|
|
197
|
+
*
|
|
198
|
+
* Recorded rather than thrown, because the MCP projection inlines every schema and never cared which
|
|
199
|
+
* of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each
|
|
200
|
+
* schema of a package under its bare name, so it REFUSES a model carrying one of these: the second
|
|
201
|
+
* declaration would be published as the first one's shape.
|
|
202
|
+
*/
|
|
203
|
+
export declare class TypeNameCollision {
|
|
204
|
+
readonly name: string;
|
|
205
|
+
readonly packageName: string | undefined;
|
|
206
|
+
/** Where the declaration that won the name is. */
|
|
207
|
+
readonly firstLocation: string;
|
|
208
|
+
/** Where the declaration that was conflated into it is. */
|
|
209
|
+
readonly secondLocation: string;
|
|
210
|
+
constructor(name: string, packageName: string | undefined,
|
|
211
|
+
/** Where the declaration that won the name is. */
|
|
212
|
+
firstLocation: string,
|
|
213
|
+
/** Where the declaration that was conflated into it is. */
|
|
214
|
+
secondLocation: string);
|
|
166
215
|
}
|
|
167
216
|
/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */
|
|
168
217
|
export declare class DocumentedEndpointOptions {
|
|
@@ -381,6 +430,8 @@ export declare class ApiDocModel {
|
|
|
381
430
|
readonly types: ReadonlyMap<string, DocumentedType>;
|
|
382
431
|
/** Everything that could not be represented — recorded, not dropped. */
|
|
383
432
|
readonly unmapped: readonly UnmappedType[];
|
|
433
|
+
/** Same-named, different declarations in one package — see {@link TypeNameCollision}. */
|
|
434
|
+
readonly collisions: readonly TypeNameCollision[];
|
|
384
435
|
constructor(
|
|
385
436
|
/** The contract class name, e.g. `SaveApi`. */
|
|
386
437
|
contractName: string,
|
|
@@ -399,5 +450,36 @@ export declare class ApiDocModel {
|
|
|
399
450
|
/** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */
|
|
400
451
|
types: ReadonlyMap<string, DocumentedType>,
|
|
401
452
|
/** Everything that could not be represented — recorded, not dropped. */
|
|
402
|
-
unmapped: readonly UnmappedType[]
|
|
453
|
+
unmapped: readonly UnmappedType[],
|
|
454
|
+
/** Same-named, different declarations in one package — see {@link TypeNameCollision}. */
|
|
455
|
+
collisions: readonly TypeNameCollision[]);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the
|
|
459
|
+
* components-only OpenAPI document it publishes (#1058). Data-only.
|
|
460
|
+
*
|
|
461
|
+
* A components document contains EVERY exported type the library declares — not only the ones some
|
|
462
|
+
* contract reaches — so its contents are a property of the library alone and do not move when a
|
|
463
|
+
* downstream contract changes.
|
|
464
|
+
*/
|
|
465
|
+
export declare class ApiComponentsModel {
|
|
466
|
+
/** The library's package name — every type in {@link exported} is declared by it. */
|
|
467
|
+
readonly packageName: string;
|
|
468
|
+
/** The library's package version, published as the document's `info.version`. */
|
|
469
|
+
readonly packageVersion: string;
|
|
470
|
+
/** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */
|
|
471
|
+
readonly exported: readonly string[];
|
|
472
|
+
/** Every named type reached from the exports — the library's own and other packages'. */
|
|
473
|
+
readonly types: ReadonlyMap<string, DocumentedType>;
|
|
474
|
+
readonly unmapped: readonly UnmappedType[];
|
|
475
|
+
readonly collisions: readonly TypeNameCollision[];
|
|
476
|
+
constructor(
|
|
477
|
+
/** The library's package name — every type in {@link exported} is declared by it. */
|
|
478
|
+
packageName: string,
|
|
479
|
+
/** The library's package version, published as the document's `info.version`. */
|
|
480
|
+
packageVersion: string,
|
|
481
|
+
/** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */
|
|
482
|
+
exported: readonly string[],
|
|
483
|
+
/** Every named type reached from the exports — the library's own and other packages'. */
|
|
484
|
+
types: ReadonlyMap<string, DocumentedType>, unmapped: readonly UnmappedType[], collisions: readonly TypeNameCollision[]);
|
|
403
485
|
}
|
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.DocumentedApiKey = exports.DocumentedApiKeyCredential = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.DocumentedType = exports.DocumentedField = exports.UnionDiscriminator = exports.UnmappedType = void 0;
|
|
3
|
+
exports.ApiComponentsModel = exports.ApiDocModel = exports.DocumentedEndpoint = exports.DocumentedAuth = exports.DocumentedApiKey = exports.DocumentedApiKeyCredential = exports.DocumentedMcpTool = exports.DocumentedEndpointOptions = exports.TypeNameCollision = 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.
|
|
@@ -127,6 +127,8 @@ class DocumentedType {
|
|
|
127
127
|
unionRefNames;
|
|
128
128
|
discriminator;
|
|
129
129
|
indexSignatureValue;
|
|
130
|
+
packageName;
|
|
131
|
+
location;
|
|
130
132
|
constructor(name, description,
|
|
131
133
|
/** Object shape. Empty for an enum or a union. */
|
|
132
134
|
fields,
|
|
@@ -137,7 +139,18 @@ class DocumentedType {
|
|
|
137
139
|
/** Set only when EVERY branch carries the same property typed as one string literal. */
|
|
138
140
|
discriminator,
|
|
139
141
|
/** An index signature (`[k: string]: X`) — the OPEN-MAP half of an object that also has fields. */
|
|
140
|
-
indexSignatureValue
|
|
142
|
+
indexSignatureValue,
|
|
143
|
+
/**
|
|
144
|
+
* The npm package whose source DECLARES this type — the nearest `package.json` above the
|
|
145
|
+
* declaring file (#1058). It decides which OpenAPI document OWNS the schema: a contract
|
|
146
|
+
* document defines the schemas its own package declares and `$ref`s every other one into
|
|
147
|
+
* that package's `components.openapi.json`. Undefined when the file belongs to no package.
|
|
148
|
+
*
|
|
149
|
+
* The MCP projection ignores it: a tool schema is always fully inlined.
|
|
150
|
+
*/
|
|
151
|
+
packageName,
|
|
152
|
+
/** Pointer-style `path/to/File.ts:12:5` of the declaration, for a refusal that names it. */
|
|
153
|
+
location) {
|
|
141
154
|
this.name = name;
|
|
142
155
|
this.description = description;
|
|
143
156
|
this.fields = fields;
|
|
@@ -145,9 +158,45 @@ class DocumentedType {
|
|
|
145
158
|
this.unionRefNames = unionRefNames;
|
|
146
159
|
this.discriminator = discriminator;
|
|
147
160
|
this.indexSignatureValue = indexSignatureValue;
|
|
161
|
+
this.packageName = packageName;
|
|
162
|
+
this.location = location;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The key this type is registered under in {@link ApiDocModel.types} and named by every
|
|
166
|
+
* {@link TypeRef.refName}: the bare name for a type its model's HOME package declares, and
|
|
167
|
+
* `<package>:<name>` for every other one, so two packages' same-named types are two entries.
|
|
168
|
+
*/
|
|
169
|
+
// webpieces-disable no-function-outside-class -- static helper on the class whose key it computes
|
|
170
|
+
static keyOf(name, packageName, homePackage) {
|
|
171
|
+
return packageName === homePackage ? name : `${packageName ?? '<no package>'}:${name}`;
|
|
148
172
|
}
|
|
149
173
|
}
|
|
150
174
|
exports.DocumentedType = DocumentedType;
|
|
175
|
+
/**
|
|
176
|
+
* Two DIFFERENT declarations of one name in one package, both reached by one model (#1058).
|
|
177
|
+
*
|
|
178
|
+
* Recorded rather than thrown, because the MCP projection inlines every schema and never cared which
|
|
179
|
+
* of the two it was handed — it keeps rendering exactly as before. An OpenAPI document defines each
|
|
180
|
+
* schema of a package under its bare name, so it REFUSES a model carrying one of these: the second
|
|
181
|
+
* declaration would be published as the first one's shape.
|
|
182
|
+
*/
|
|
183
|
+
class TypeNameCollision {
|
|
184
|
+
name;
|
|
185
|
+
packageName;
|
|
186
|
+
firstLocation;
|
|
187
|
+
secondLocation;
|
|
188
|
+
constructor(name, packageName,
|
|
189
|
+
/** Where the declaration that won the name is. */
|
|
190
|
+
firstLocation,
|
|
191
|
+
/** Where the declaration that was conflated into it is. */
|
|
192
|
+
secondLocation) {
|
|
193
|
+
this.name = name;
|
|
194
|
+
this.packageName = packageName;
|
|
195
|
+
this.firstLocation = firstLocation;
|
|
196
|
+
this.secondLocation = secondLocation;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.TypeNameCollision = TypeNameCollision;
|
|
151
200
|
/** `@Endpoint(httpMethod, path, operation, kind, options?)`'s LAST argument, as a document sees it. */
|
|
152
201
|
class DocumentedEndpointOptions {
|
|
153
202
|
formPost;
|
|
@@ -344,6 +393,7 @@ class ApiDocModel {
|
|
|
344
393
|
endpoints;
|
|
345
394
|
types;
|
|
346
395
|
unmapped;
|
|
396
|
+
collisions;
|
|
347
397
|
constructor(
|
|
348
398
|
/** The contract class name, e.g. `SaveApi`. */
|
|
349
399
|
contractName,
|
|
@@ -362,7 +412,9 @@ class ApiDocModel {
|
|
|
362
412
|
/** Every named type reachable from the endpoints, by name. A `$ref` target for a renderer. */
|
|
363
413
|
types,
|
|
364
414
|
/** Everything that could not be represented — recorded, not dropped. */
|
|
365
|
-
unmapped
|
|
415
|
+
unmapped,
|
|
416
|
+
/** Same-named, different declarations in one package — see {@link TypeNameCollision}. */
|
|
417
|
+
collisions) {
|
|
366
418
|
this.contractName = contractName;
|
|
367
419
|
this.apiTypes = apiTypes;
|
|
368
420
|
this.basePath = basePath;
|
|
@@ -370,7 +422,41 @@ class ApiDocModel {
|
|
|
370
422
|
this.endpoints = endpoints;
|
|
371
423
|
this.types = types;
|
|
372
424
|
this.unmapped = unmapped;
|
|
425
|
+
this.collisions = collisions;
|
|
373
426
|
}
|
|
374
427
|
}
|
|
375
428
|
exports.ApiDocModel = ApiDocModel;
|
|
429
|
+
/**
|
|
430
|
+
* ONE extraction pass over a DTO LIBRARY: every type it exports and declares, for the
|
|
431
|
+
* components-only OpenAPI document it publishes (#1058). Data-only.
|
|
432
|
+
*
|
|
433
|
+
* A components document contains EVERY exported type the library declares — not only the ones some
|
|
434
|
+
* contract reaches — so its contents are a property of the library alone and do not move when a
|
|
435
|
+
* downstream contract changes.
|
|
436
|
+
*/
|
|
437
|
+
class ApiComponentsModel {
|
|
438
|
+
packageName;
|
|
439
|
+
packageVersion;
|
|
440
|
+
exported;
|
|
441
|
+
types;
|
|
442
|
+
unmapped;
|
|
443
|
+
collisions;
|
|
444
|
+
constructor(
|
|
445
|
+
/** The library's package name — every type in {@link exported} is declared by it. */
|
|
446
|
+
packageName,
|
|
447
|
+
/** The library's package version, published as the document's `info.version`. */
|
|
448
|
+
packageVersion,
|
|
449
|
+
/** The {@link ApiDocModel.types} keys of the exported declarations, in export order. */
|
|
450
|
+
exported,
|
|
451
|
+
/** Every named type reached from the exports — the library's own and other packages'. */
|
|
452
|
+
types, unmapped, collisions) {
|
|
453
|
+
this.packageName = packageName;
|
|
454
|
+
this.packageVersion = packageVersion;
|
|
455
|
+
this.exported = exported;
|
|
456
|
+
this.types = types;
|
|
457
|
+
this.unmapped = unmapped;
|
|
458
|
+
this.collisions = collisions;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
exports.ApiComponentsModel = ApiComponentsModel;
|
|
376
462
|
//# sourceMappingURL=ApiDocModel.js.map
|