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