1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | import type * as M from "../models/index.js";
|
32 | import type { IfInternal } from "../utils/index.js";
|
33 |
|
34 |
|
35 |
|
36 | export type ModelToObject<T> = [T] extends [Array<infer U>] ? ModelToObject<U>[] : [M.SomeType] extends [T] ? SomeType : _ModelToObject<T>;
|
37 | type _ModelToObject<T> = T extends Primitive ? T : Required<T> extends Required<M.ReflectionGroup> ? ReflectionGroup : Required<T> extends Required<M.ReflectionCategory> ? ReflectionCategory : T extends M.ReflectionVariant[keyof M.ReflectionVariant] ? ReflectionVariantMap[T["variant"]] : T extends M.SomeType ? TypeKindMap[T["type"]] : T extends M.Type ? SomeType : T extends M.Comment ? Comment : T extends M.CommentTag ? CommentTag : T extends M.CommentDisplayPart ? CommentDisplayPart : T extends M.SourceReference ? SourceReference : T extends M.FileRegistry ? FileRegistry : never;
|
38 | type Primitive = string | number | undefined | null | boolean;
|
39 | type ToSerialized<T> = T extends Primitive ? T : T extends bigint ? {
|
40 | value: string;
|
41 | negative: boolean;
|
42 | } : ModelToObject<T>;
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | type S<T, K extends keyof T> = {
|
50 | -readonly [K2 in K]: ToSerialized<T[K2]>;
|
51 | };
|
52 | export interface ReflectionSymbolId {
|
53 | sourceFileName: string;
|
54 | qualifiedName: string;
|
55 | }
|
56 | export interface ReflectionGroup extends S<M.ReflectionGroup, "title" | "description" | "categories"> {
|
57 | children?: M.ReflectionGroup["children"][number]["id"][];
|
58 | }
|
59 | export interface ReflectionCategory extends S<M.ReflectionCategory, "title" | "description"> {
|
60 | children?: M.ReflectionCategory["children"][number]["id"][];
|
61 | }
|
62 |
|
63 | export interface ReflectionVariantMap {
|
64 | declaration: DeclarationReflection;
|
65 | param: ParameterReflection;
|
66 | project: ProjectReflection;
|
67 | reference: ReferenceReflection;
|
68 | signature: SignatureReflection;
|
69 | typeParam: TypeParameterReflection;
|
70 | document: DocumentReflection;
|
71 | }
|
72 |
|
73 | export type SomeReflection = ReflectionVariantMap[keyof ReflectionVariantMap];
|
74 |
|
75 | export interface DocumentReflection extends Omit<Reflection, "variant">, S<M.DocumentReflection, "variant" | "content" | "relevanceBoost" | "children"> {
|
76 | frontmatter: Record<string, unknown>;
|
77 | }
|
78 |
|
79 | export interface ReferenceReflection extends Omit<DeclarationReflection, "variant">, S<M.ReferenceReflection, "variant"> {
|
80 | |
81 |
|
82 |
|
83 |
|
84 | target: number;
|
85 | }
|
86 |
|
87 | export interface SignatureReflection extends Omit<Reflection, "variant">, S<M.SignatureReflection, "variant" | "sources" | "parameters" | "typeParameters" | "type" | "overwrites" | "inheritedFrom" | "implementationOf"> {
|
88 |
|
89 | typeParameter?: ModelToObject<M.TypeParameterReflection[]>;
|
90 | }
|
91 |
|
92 | export interface ParameterReflection extends Omit<Reflection, "variant">, S<M.ParameterReflection, "variant" | "type" | "defaultValue"> {
|
93 | variant: "param";
|
94 | }
|
95 |
|
96 | export interface DeclarationReflection extends Omit<ContainerReflection, "variant">, S<M.DeclarationReflection, "variant" | "packageVersion" | "sources" | "relevanceBoost" | "type" | "signatures" | "indexSignatures" | "defaultValue" | "overwrites" | "inheritedFrom" | "implementationOf" | "extendedTypes" | "extendedBy" | "implementedTypes" | "implementedBy" | "getSignature" | "setSignature" | "typeParameters" | "readme"> {
|
97 |
|
98 | indexSignature?: SignatureReflection;
|
99 | }
|
100 |
|
101 | export interface TypeParameterReflection extends Omit<Reflection, "variant">, S<M.TypeParameterReflection, "variant" | "type" | "default" | "varianceModifier"> {
|
102 | }
|
103 |
|
104 | export interface ProjectReflection extends Omit<ContainerReflection, "variant">, S<M.ProjectReflection, "variant" | "packageName" | "packageVersion" | "readme"> {
|
105 | symbolIdMap: Record<number, ReflectionSymbolId> | IfInternal<undefined, never>;
|
106 | files: FileRegistry;
|
107 | }
|
108 |
|
109 | export interface ContainerReflection extends Reflection, S<M.ContainerReflection, "children" | "documents" | "groups" | "categories"> {
|
110 | childrenIncludingDocuments?: number[];
|
111 | }
|
112 |
|
113 | export interface Reflection extends S<M.Reflection, "id" | "variant" | "name" | "kind" | "comment"> {
|
114 | flags: ReflectionFlags;
|
115 | }
|
116 |
|
117 | export type SomeType = TypeKindMap[keyof TypeKindMap];
|
118 |
|
119 | export type TypeKindMap = {
|
120 | array: ArrayType;
|
121 | conditional: ConditionalType;
|
122 | indexedAccess: IndexedAccessType;
|
123 | inferred: InferredType;
|
124 | intersection: IntersectionType;
|
125 | intrinsic: IntrinsicType;
|
126 | literal: LiteralType;
|
127 | mapped: MappedType;
|
128 | optional: OptionalType;
|
129 | predicate: PredicateType;
|
130 | query: QueryType;
|
131 | reference: ReferenceType;
|
132 | reflection: ReflectionType;
|
133 | rest: RestType;
|
134 | templateLiteral: TemplateLiteralType;
|
135 | tuple: TupleType;
|
136 | namedTupleMember: NamedTupleMemberType;
|
137 | typeOperator: TypeOperatorType;
|
138 | union: UnionType;
|
139 | unknown: UnknownType;
|
140 | };
|
141 |
|
142 | export interface ArrayType extends Type, S<M.ArrayType, "type" | "elementType"> {
|
143 | }
|
144 |
|
145 | export interface ConditionalType extends Type, S<M.ConditionalType, "type" | "checkType" | "extendsType" | "trueType" | "falseType"> {
|
146 | }
|
147 |
|
148 | export interface IndexedAccessType extends Type, S<M.IndexedAccessType, "type" | "indexType" | "objectType"> {
|
149 | }
|
150 |
|
151 | export interface InferredType extends Type, S<M.InferredType, "type" | "name" | "constraint"> {
|
152 | }
|
153 |
|
154 | export interface IntersectionType extends Type, S<M.IntersectionType, "type" | "types"> {
|
155 | }
|
156 |
|
157 | export interface IntrinsicType extends Type, S<M.IntrinsicType, "type" | "name"> {
|
158 | }
|
159 |
|
160 | export interface OptionalType extends Type, S<M.OptionalType, "type" | "elementType"> {
|
161 | }
|
162 |
|
163 | export interface PredicateType extends Type, S<M.PredicateType, "type" | "name" | "asserts" | "targetType"> {
|
164 | }
|
165 |
|
166 | export interface QueryType extends Type, S<M.QueryType, "type" | "queryType"> {
|
167 | }
|
168 |
|
169 | export interface ReferenceType extends Type, S<M.ReferenceType, "type" | "name" | "typeArguments" | "package" | "externalUrl"> {
|
170 | target: number | ReflectionSymbolId;
|
171 | qualifiedName?: string;
|
172 | refersToTypeParameter?: boolean;
|
173 | preferValues?: boolean;
|
174 | highlightedProperties?: Record<string, CommentDisplayPart[]>;
|
175 | }
|
176 |
|
177 | export interface ReflectionType extends Type, S<M.ReflectionType, "type" | "declaration"> {
|
178 | }
|
179 |
|
180 | export interface RestType extends Type, S<M.RestType, "type" | "elementType"> {
|
181 | }
|
182 |
|
183 | export interface LiteralType extends Type, S<M.LiteralType, "type" | "value"> {
|
184 | }
|
185 |
|
186 | export interface TupleType extends Type, S<M.TupleType, "type"> {
|
187 | elements?: ModelToObject<M.TupleType["elements"]>;
|
188 | }
|
189 |
|
190 | export interface NamedTupleMemberType extends Type, S<M.NamedTupleMember, "type" | "name" | "isOptional" | "element"> {
|
191 | }
|
192 |
|
193 | export interface TemplateLiteralType extends Type, S<M.TemplateLiteralType, "type" | "head"> {
|
194 | tail: [SomeType, string][];
|
195 | }
|
196 |
|
197 | export interface MappedType extends Type, S<M.MappedType, "type" | "parameter" | "parameterType" | "templateType" | "readonlyModifier" | "optionalModifier" | "nameType"> {
|
198 | }
|
199 |
|
200 | export interface TypeOperatorType extends Type, S<M.TypeOperatorType, "type" | "operator" | "target"> {
|
201 | }
|
202 |
|
203 | export interface UnionType extends Type, S<M.UnionType, "type" | "types" | "elementSummaries"> {
|
204 | }
|
205 |
|
206 | export interface UnknownType extends Type, S<M.UnknownType, "type" | "name"> {
|
207 | }
|
208 |
|
209 | export interface Type {
|
210 | }
|
211 | type BoolKeys<T> = {
|
212 | [K in keyof T]-?: T[K] extends boolean ? K : never;
|
213 | }[keyof T];
|
214 | export interface ReflectionFlags extends Partial<S<M.ReflectionFlags, BoolKeys<M.ReflectionFlags>>> {
|
215 | }
|
216 |
|
217 | export interface Comment extends Partial<S<M.Comment, "blockTags" | "label">> {
|
218 | summary: CommentDisplayPart[];
|
219 | modifierTags?: `@${string}`[];
|
220 | }
|
221 |
|
222 | export interface CommentTag extends S<M.CommentTag, "tag" | "name"> {
|
223 | content: CommentDisplayPart[];
|
224 | }
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | export type CommentDisplayPart = {
|
230 | kind: "text";
|
231 | text: string;
|
232 | } | {
|
233 | kind: "code";
|
234 | text: string;
|
235 | } | InlineTagDisplayPart | RelativeLinkDisplayPart;
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | export interface InlineTagDisplayPart {
|
242 | kind: "inline-tag";
|
243 | tag: `@${string}`;
|
244 | text: string;
|
245 | target?: string | number | ReflectionSymbolId;
|
246 | tsLinkText?: string;
|
247 | }
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | export interface RelativeLinkDisplayPart {
|
254 | kind: "relative-link";
|
255 | |
256 |
|
257 |
|
258 | text: string;
|
259 | |
260 |
|
261 |
|
262 | target?: number;
|
263 | |
264 |
|
265 |
|
266 | targetAnchor?: string;
|
267 | }
|
268 | export interface SourceReference extends S<M.SourceReference, "fileName" | "line" | "character" | "url"> {
|
269 | }
|
270 | export interface FileRegistry {
|
271 |
|
272 | entries: Record<number, string>;
|
273 |
|
274 | reflections: Record<number, number>;
|
275 | }
|
276 | export {};
|