@sdk-it/core 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/deriver.ts"],
4
+ "sourcesContent": ["import ts, { TypeFlags, symbolName } from 'typescript';\n\ntype Collector = Record<string, any>;\nexport const deriveSymbol = Symbol.for('serialize');\nexport const $types = Symbol.for('types');\nconst defaults: Record<string, string> = {\n Readable: 'any',\n ReadableStream: 'any',\n DateConstructor: 'string',\n ArrayBufferConstructor: 'any',\n SharedArrayBufferConstructor: 'any',\n Int8ArrayConstructor: 'any',\n Uint8Array: 'any',\n};\nexport class TypeDeriver {\n public readonly collector: Collector = {};\n public readonly checker: ts.TypeChecker;\n constructor(checker: ts.TypeChecker) {\n this.checker = checker;\n }\n\n serializeType(type: ts.Type): any {\n const indexType = type.getStringIndexType();\n if (indexType) {\n return {\n [deriveSymbol]: true,\n kind: 'record',\n optional: false,\n [$types]: [this.serializeType(indexType)],\n };\n }\n if (type.flags & TypeFlags.Any) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.flags & TypeFlags.Unknown) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [],\n };\n }\n if (type.isStringLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['string'],\n };\n }\n if (type.isNumberLiteral()) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: type.value,\n [$types]: ['number'],\n };\n }\n if (type.flags & TypeFlags.BooleanLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n\n if (type.flags & TypeFlags.TemplateLiteral) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.String) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['string'],\n };\n }\n if (type.flags & TypeFlags.Number) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['number'],\n };\n }\n if (type.flags & ts.TypeFlags.Boolean) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (type.flags & TypeFlags.Null) {\n return {\n [deriveSymbol]: true,\n optional: true,\n [$types]: ['null'],\n };\n }\n if (type.isIntersection()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(unionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'intersection',\n optional,\n [$types]: types,\n };\n }\n if (type.isUnion()) {\n let optional: boolean | undefined;\n const types: any[] = [];\n for (const unionType of type.types) {\n if (optional === undefined) {\n // ignore undefined\n optional = (unionType.flags & ts.TypeFlags.Undefined) !== 0;\n if (optional) {\n continue;\n }\n }\n\n types.push(this.serializeType(unionType));\n }\n return {\n [deriveSymbol]: true,\n kind: 'union',\n optional,\n [$types]: types,\n };\n }\n if (this.checker.isArrayLikeType(type)) {\n const [argType] = this.checker.getTypeArguments(type as ts.TypeReference);\n if (!argType) {\n const typeName = type.symbol?.getName() || '<unknown>';\n console.warn(\n `Could not find generic type argument for array type ${typeName}`,\n );\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: ['any'],\n };\n }\n const typeSymbol = argType.getSymbol();\n if (!typeSymbol) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'array',\n [$types]: [this.serializeType(argType)],\n };\n }\n\n if (typeSymbol.valueDeclaration) {\n return {\n kind: 'array',\n [deriveSymbol]: true,\n [$types]: [this.serializeNode(typeSymbol.valueDeclaration)],\n };\n }\n const maybeDeclaration = typeSymbol.declarations?.[0];\n if (maybeDeclaration) {\n if (ts.isMappedTypeNode(maybeDeclaration)) {\n const resolvedType = this.checker\n .getPropertiesOfType(argType)\n .reduce<Record<string, unknown>>((acc, prop) => {\n const propType = this.checker.getTypeOfSymbol(prop);\n acc[prop.name] = this.serializeType(propType);\n return acc;\n }, {});\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: [resolvedType],\n };\n } else {\n return {\n kind: 'array',\n ...this.serializeNode(maybeDeclaration),\n };\n }\n }\n\n return {\n kind: 'array',\n optional: false,\n [deriveSymbol]: true,\n [$types]: ['any'],\n };\n }\n if (type.isClass()) {\n const declaration = type.symbol?.valueDeclaration;\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n if (isInterfaceType(type)) {\n const valueDeclaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!valueDeclaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(valueDeclaration);\n }\n if (type.flags & TypeFlags.Object) {\n if (defaults[symbolName(type.symbol)]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[type.symbol.name]],\n };\n }\n const properties = this.checker.getPropertiesOfType(type);\n if (properties.length > 0) {\n const serializedProps: Record<string, any> = {};\n for (const prop of properties) {\n const propAssingment = (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertyAssignment(it),\n );\n // get literal properties values if any\n if (propAssingment) {\n const type = this.checker.getTypeAtLocation(\n propAssingment.initializer,\n );\n serializedProps[prop.name] = this.serializeType(type);\n }\n if (\n (prop.getDeclarations() ?? []).find((it) =>\n ts.isPropertySignature(it),\n )\n ) {\n const propType = this.checker.getTypeOfSymbol(prop);\n serializedProps[prop.name] = this.serializeType(propType);\n }\n }\n return {\n [deriveSymbol]: true,\n kind: 'object',\n optional: false,\n [$types]: [serializedProps],\n };\n }\n const declaration =\n type.symbol.valueDeclaration ?? type.symbol.declarations?.[0];\n if (!declaration) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [type.symbol.getName()],\n };\n }\n return this.serializeNode(declaration);\n }\n console.warn(`Unhandled type: ${type.flags} ${ts.TypeFlags[type.flags]}`);\n\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [\n this.checker.typeToString(\n type,\n undefined,\n ts.TypeFormatFlags.NoTruncation,\n ),\n ],\n };\n }\n\n serializeNode(node: ts.Node): any {\n if (ts.isObjectLiteralExpression(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, any> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n\n // get literal properties values if any\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const type = this.checker.getTypeAtLocation(prop.initializer);\n props[prop.name.getText()] = this.serializeType(type);\n }\n }\n\n return props;\n }\n if (ts.isPropertyAccessExpression(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertySignature(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isPropertyDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n const type = this.checker.getTypeOfSymbol(symbol);\n return this.serializeType(type);\n }\n if (ts.isInterfaceDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Interface has no name');\n }\n if (defaults[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[node.name.text]],\n };\n }\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, any> = {};\n for (const member of node.members.filter(ts.isPropertySignature)) {\n members[member.name.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = members;\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n };\n }\n if (ts.isClassDeclaration(node)) {\n if (!node.name?.text) {\n throw new Error('Class has no name');\n }\n if (defaults[node.name.text]) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [defaults[node.name.text]],\n };\n }\n\n if (!this.collector[node.name.text]) {\n this.collector[node.name.text] = {};\n const members: Record<string, unknown> = {};\n for (const member of node.members.filter(ts.isPropertyDeclaration)) {\n members[member.name!.getText()] = this.serializeNode(member);\n }\n this.collector[node.name.text] = members;\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [`#/components/schemas/${node.name.text}`],\n $ref: `#/components/schemas/${node.name.text}`,\n };\n }\n if (ts.isVariableDeclaration(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.name);\n if (!symbol) {\n console.warn(`No symbol found for ${node.name.getText()}`);\n return null;\n }\n if (!node.type) {\n console.warn(`No type found for ${node.name.getText()}`);\n return 'any';\n }\n const type = this.checker.getTypeFromTypeNode(node.type);\n return this.serializeType(type);\n }\n if (ts.isIdentifier(node)) {\n const symbol = this.checker.getSymbolAtLocation(node);\n if (!symbol) {\n console.warn(`Identifer: No symbol found for ${node.getText()}`);\n return null;\n }\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAwaitExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isCallExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isAsExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n if (ts.isTypeLiteralNode(node)) {\n const symbolType = this.checker.getTypeAtLocation(node);\n const props: Record<string, unknown> = {};\n for (const symbol of symbolType.getProperties()) {\n const type = this.checker.getTypeOfSymbol(symbol);\n props[symbol.name] = this.serializeType(type);\n }\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: [props],\n };\n }\n if (node.kind === ts.SyntaxKind.NullKeyword) {\n return {\n [deriveSymbol]: true,\n optional: true,\n [$types]: ['null'],\n };\n }\n if (node.kind === ts.SyntaxKind.BooleanKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.TrueKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: true,\n [$types]: ['boolean'],\n };\n }\n if (node.kind === ts.SyntaxKind.FalseKeyword) {\n return {\n [deriveSymbol]: true,\n optional: false,\n kind: 'literal',\n value: false,\n [$types]: ['boolean'],\n };\n }\n if (ts.isArrayLiteralExpression(node)) {\n const type = this.checker.getTypeAtLocation(node);\n return this.serializeType(type);\n }\n\n console.warn(`Unhandled node: ${ts.SyntaxKind[node.kind]} ${node.flags}`);\n return {\n [deriveSymbol]: true,\n optional: false,\n [$types]: ['any'],\n };\n }\n}\n\nfunction isInterfaceType(type: ts.Type): boolean {\n if (type.isClassOrInterface()) {\n // Check if it's an interface\n return !!(type.symbol.flags & ts.SymbolFlags.Interface);\n }\n return false;\n}\n"],
5
+ "mappings": "AAAA,OAAO,MAAM,WAAW,kBAAkB;AAGnC,MAAM,eAAe,OAAO,IAAI,WAAW;AAC3C,MAAM,SAAS,OAAO,IAAI,OAAO;AACxC,MAAM,WAAmC;AAAA,EACvC,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,sBAAsB;AAAA,EACtB,YAAY;AACd;AACO,MAAM,YAAY;AAAA,EACP,YAAuB,CAAC;AAAA,EACxB;AAAA,EAChB,YAAY,SAAyB;AACnC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,cAAc,MAAoB;AAChC,UAAM,YAAY,KAAK,mBAA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AAAA,MACtB;AAAA,IACF;AACA,QAAI,KAAK,SAAS,GAAG,WAAW,cAAc;AAC5C,aAAO;AAAA,QACL,CAAC,YAAY,GAAG;AAAA,QAChB,UAAU;AAAA,QACV,MAAM;AAAA,QACN,OAAO;AAAA,QACP,CAAC,MAAM,GAAG,CAAC,SAAS;AAAA,MACtB;AAAA,IACF;AACA,QAAI,GAAG,yBAAyB,IAAI,GAAG;AACrC,YAAM,OAAO,KAAK,QAAQ,kBAAkB,IAAI;AAChD,aAAO,KAAK,cAAc,IAAI;AAAA,IAChC;AAEA,YAAQ,KAAK,mBAAmB,GAAG,WAAW,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;AACxE,WAAO;AAAA,MACL,CAAC,YAAY,GAAG;AAAA,MAChB,UAAU;AAAA,MACV,CAAC,MAAM,GAAG,CAAC,KAAK;AAAA,IAClB;AAAA,EACF;AACF;AAEA,SAAS,gBAAgB,MAAwB;AAC/C,MAAI,KAAK,mBAAmB,GAAG;AAE7B,WAAO,CAAC,EAAE,KAAK,OAAO,QAAQ,GAAG,YAAY;AAAA,EAC/C;AACA,SAAO;AACT;",
6
+ "names": ["type"]
7
+ }
@@ -0,0 +1,417 @@
1
+ import { describe, it } from "node:test";
2
+ import ts from "typescript";
3
+ describe("TypeDeriver Class", () => {
4
+ describe("Initialization and Core Properties", () => {
5
+ it.todo("instantiates with a TypeScript TypeChecker instance", () => {
6
+ });
7
+ it.todo("initializes the `collector` property as an empty object", () => {
8
+ });
9
+ it.todo(
10
+ "exposes the `deriveSymbol` constant for marking serialized objects",
11
+ () => {
12
+ }
13
+ );
14
+ it.todo(
15
+ "exposes the `$types` symbol constant for holding serialized type information",
16
+ () => {
17
+ }
18
+ );
19
+ });
20
+ describe("serializeType: Basic Primitive and Special Types", () => {
21
+ it.todo("serializes `any` type to an empty type list", () => {
22
+ });
23
+ it.todo("serializes `unknown` type to an empty type list", () => {
24
+ });
25
+ it.todo("serializes `string` type", () => {
26
+ });
27
+ it.todo("serializes `number` type", () => {
28
+ });
29
+ it.todo("serializes `boolean` type", () => {
30
+ });
31
+ it.todo("serializes `null` type as optional", () => {
32
+ });
33
+ it.todo(
34
+ "serializes `void` type (likely falls back to Any/Unknown or unhandled)",
35
+ () => {
36
+ }
37
+ );
38
+ it.todo(
39
+ "serializes `never` type (likely falls back to Any/Unknown or unhandled)",
40
+ () => {
41
+ }
42
+ );
43
+ it.todo(
44
+ "serializes `undefined` type implicitly via union/intersection optional flag",
45
+ () => {
46
+ }
47
+ );
48
+ });
49
+ describe("serializeType: Literal Types", () => {
50
+ it.todo("serializes string literal types with their value", () => {
51
+ });
52
+ it.todo("serializes numeric literal types with their value", () => {
53
+ });
54
+ it.todo("serializes boolean literal `true` type", () => {
55
+ });
56
+ it.todo("serializes boolean literal `false` type", () => {
57
+ });
58
+ it.todo("serializes template literal types as base `string`", () => {
59
+ });
60
+ });
61
+ describe("serializeType: Enum Types", () => {
62
+ it.todo(
63
+ "serializes an Enum type (e.g., `enum Color {}`) potentially via unhandled path",
64
+ () => {
65
+ }
66
+ );
67
+ it.todo(
68
+ "serializes an EnumLiteral type (e.g., `Color.Red`) potentially via unhandled path or base type",
69
+ () => {
70
+ }
71
+ );
72
+ });
73
+ describe("serializeType: Union Types (`|`)", () => {
74
+ it.todo(
75
+ "serializes a union of primitive types (e.g., string | number)",
76
+ () => {
77
+ }
78
+ );
79
+ it.todo(
80
+ "serializes a union type including `null` (e.g., string | null)",
81
+ () => {
82
+ }
83
+ );
84
+ it.todo(
85
+ "serializes a union type including `undefined`, setting optional flag and filtering `undefined`",
86
+ () => {
87
+ }
88
+ );
89
+ it.todo(
90
+ "serializes a union type including both `null` and `undefined`",
91
+ () => {
92
+ }
93
+ );
94
+ it.todo('serializes a union of literal types (e.g., "a" | "b" | 1)', () => {
95
+ });
96
+ it.todo(
97
+ "serializes a union including complex types (e.g., string | MyInterface)",
98
+ () => {
99
+ }
100
+ );
101
+ it.todo("serializes a union containing only `undefined`", () => {
102
+ });
103
+ it.todo("serializes a union containing only `null`", () => {
104
+ });
105
+ });
106
+ describe("serializeType: Intersection Types (`&`)", () => {
107
+ it.todo(
108
+ "serializes an intersection of object/interface types (e.g., A & B)",
109
+ () => {
110
+ }
111
+ );
112
+ it.todo(
113
+ "serializes an intersection type including `undefined`, setting optional flag and filtering `undefined`",
114
+ () => {
115
+ }
116
+ );
117
+ it.todo("serializes an intersection containing only `undefined`", () => {
118
+ });
119
+ });
120
+ describe("serializeType: Array and Tuple Types", () => {
121
+ it.todo("serializes a simple array type (e.g., string[])", () => {
122
+ });
123
+ it.todo("serializes readonly array types (e.g., readonly number[])", () => {
124
+ });
125
+ it.todo(
126
+ "serializes an array type with object elements (e.g., MyInterface[])",
127
+ () => {
128
+ }
129
+ );
130
+ it.todo(
131
+ "serializes an array type with union elements (e.g., (string | number)[])",
132
+ () => {
133
+ }
134
+ );
135
+ it.todo("serializes an array type where element type has no symbol", () => {
136
+ });
137
+ it.todo(
138
+ "serializes an array type where element symbol has no value declaration but has declarations",
139
+ () => {
140
+ }
141
+ );
142
+ it.todo(
143
+ "serializes an array type with a mapped type element (e.g., MappedType[])",
144
+ () => {
145
+ }
146
+ );
147
+ it.todo(
148
+ "handles array-like types with missing type arguments gracefully (e.g., Array)",
149
+ () => {
150
+ }
151
+ );
152
+ it.todo(
153
+ "serializes tuple types (e.g., [string, number]) potentially as array of union",
154
+ () => {
155
+ }
156
+ );
157
+ });
158
+ describe("serializeType: Record/Index Types", () => {
159
+ it.todo(
160
+ "serializes a string index signature type (Record<string, number>)",
161
+ () => {
162
+ }
163
+ );
164
+ it.todo(
165
+ "serializes a string index signature type with complex value (Record<string, MyInterface>)",
166
+ () => {
167
+ }
168
+ );
169
+ it.todo(
170
+ "serializes a type with only a number index signature ([key: number]: boolean)",
171
+ () => {
172
+ }
173
+ );
174
+ });
175
+ describe("serializeType: Object Types (Interfaces, Classes, Inline, Mapped)", () => {
176
+ it.todo("serializes an inline object type literal (passed as type)", () => {
177
+ });
178
+ it.todo(
179
+ "serializes a mapped type directly (e.g., type M = { [K in keyof T]: T[K] })",
180
+ () => {
181
+ }
182
+ );
183
+ it.todo(
184
+ "serializes an object type using literal property assignments from declarations",
185
+ () => {
186
+ }
187
+ );
188
+ it.todo(
189
+ "serializes an object type with mixed declared types (PropertySignature) and literal assignments (PropertyAssignment)",
190
+ () => {
191
+ }
192
+ );
193
+ it.todo(
194
+ "serializes an empty object type `{}` potentially falling back to name or generic",
195
+ () => {
196
+ }
197
+ );
198
+ it.todo(
199
+ "handles object types matching default overrides (e.g., DateConstructor -> string)",
200
+ () => {
201
+ }
202
+ );
203
+ it.todo(
204
+ "handles known object types NOT in defaults (e.g., RegExp) by attempting standard object serialization",
205
+ () => {
206
+ }
207
+ );
208
+ it.todo(
209
+ "serializes an interface type by deferring to serializeNode for reference/collection",
210
+ () => {
211
+ }
212
+ );
213
+ it.todo(
214
+ "serializes a class type by deferring to serializeNode for reference/collection",
215
+ () => {
216
+ }
217
+ );
218
+ it.todo(
219
+ "serializes an interface type using its name when its declaration cannot be found",
220
+ () => {
221
+ }
222
+ );
223
+ it.todo(
224
+ "serializes a class type using its name when its declaration cannot be found",
225
+ () => {
226
+ }
227
+ );
228
+ });
229
+ describe("serializeType: Unhandled Types", () => {
230
+ it.todo(
231
+ "handles an unhandled type flag by using checker.typeToString and warns",
232
+ () => {
233
+ }
234
+ );
235
+ });
236
+ describe("serializeNode: Object Literal Expressions (`{ ... }`)", () => {
237
+ it.todo(
238
+ "serializes an object literal node with various primitive property types",
239
+ () => {
240
+ }
241
+ );
242
+ it.todo(
243
+ "serializes an object literal node with nested object/array literals",
244
+ () => {
245
+ }
246
+ );
247
+ it.todo("serializes an empty object literal node `{}`", () => {
248
+ });
249
+ });
250
+ describe("serializeNode: Property Access/Signature/Declaration", () => {
251
+ it.todo(
252
+ "serializes a PropertyAccessExpression node (e.g., `obj.prop`) by resolving its type",
253
+ () => {
254
+ }
255
+ );
256
+ it.todo(
257
+ "serializes a PropertySignature node (e.g., `prop: string;`) by resolving its type",
258
+ () => {
259
+ }
260
+ );
261
+ it.todo(
262
+ "serializes a PropertyDeclaration node (e.g., `prop: number;`) by resolving its type",
263
+ () => {
264
+ }
265
+ );
266
+ it.todo(
267
+ "handles property nodes where symbol cannot be found for the property name and warns",
268
+ () => {
269
+ }
270
+ );
271
+ });
272
+ describe("serializeNode: Interface Declarations (`interface ...`) and Collector Interaction", () => {
273
+ it.todo(
274
+ "serializes a new interface declaration, adding its structure to the collector",
275
+ () => {
276
+ }
277
+ );
278
+ it.todo(
279
+ "returns only a reference for an already serialized interface declaration (present in collector)",
280
+ () => {
281
+ }
282
+ );
283
+ it.todo(
284
+ "handles interface declarations matching default overrides without adding to collector",
285
+ () => {
286
+ }
287
+ );
288
+ it.todo(
289
+ "throws an error for an interface declaration without a name",
290
+ () => {
291
+ }
292
+ );
293
+ it.todo(
294
+ "handles interfaces with no members correctly (adds empty object to collector)",
295
+ () => {
296
+ }
297
+ );
298
+ it.todo(
299
+ "handles interfaces extending other interfaces (serialization includes only own properties)",
300
+ () => {
301
+ }
302
+ );
303
+ });
304
+ describe("serializeNode: Class Declarations (`class ...`) and Collector Interaction", () => {
305
+ it.todo(
306
+ "serializes a new class declaration, adding its property structure to the collector",
307
+ () => {
308
+ }
309
+ );
310
+ it.todo(
311
+ "returns only a reference for an already serialized class declaration (present in collector)",
312
+ () => {
313
+ }
314
+ );
315
+ it.todo(
316
+ "handles class declarations matching default overrides without adding to collector",
317
+ () => {
318
+ }
319
+ );
320
+ it.todo(
321
+ "throws an error for a class declaration without a name (e.g., anonymous default export)",
322
+ () => {
323
+ }
324
+ );
325
+ it.todo(
326
+ "handles classes with no property declarations (only methods/constructor) correctly (adds empty object to collector)",
327
+ () => {
328
+ }
329
+ );
330
+ it.todo(
331
+ "handles classes implementing interfaces (serialization includes only own properties)",
332
+ () => {
333
+ }
334
+ );
335
+ it.todo(
336
+ "handles classes extending other classes (serialization includes only own properties)",
337
+ () => {
338
+ }
339
+ );
340
+ });
341
+ describe("serializeNode: Other Node Types", () => {
342
+ it.todo(
343
+ "serializes a VariableDeclaration node with an explicit type annotation",
344
+ () => {
345
+ }
346
+ );
347
+ it.todo(
348
+ "handles VariableDeclaration node without a type annotation and warns",
349
+ () => {
350
+ }
351
+ );
352
+ it.todo(
353
+ "handles VariableDeclaration node where symbol cannot be found for the variable name and warns",
354
+ () => {
355
+ }
356
+ );
357
+ it.todo(
358
+ "serializes an Identifier node by resolving its type at that location",
359
+ () => {
360
+ }
361
+ );
362
+ it.todo(
363
+ "handles Identifier node where symbol cannot be found and warns",
364
+ () => {
365
+ }
366
+ );
367
+ it.todo(
368
+ "serializes an AwaitExpression node by resolving the awaited type",
369
+ () => {
370
+ }
371
+ );
372
+ it.todo(
373
+ "serializes a CallExpression node by resolving its return type",
374
+ () => {
375
+ }
376
+ );
377
+ it.todo(
378
+ "serializes an AsExpression node by resolving the asserted type",
379
+ () => {
380
+ }
381
+ );
382
+ it.todo(
383
+ "serializes a TypeLiteralNode (`{ ... }` used as a type) by resolving its properties",
384
+ () => {
385
+ }
386
+ );
387
+ it.todo("serializes NullKeyword node", () => {
388
+ });
389
+ it.todo("serializes BooleanKeyword node", () => {
390
+ });
391
+ it.todo("serializes TrueKeyword node as boolean literal", () => {
392
+ });
393
+ it.todo("serializes FalseKeyword node as boolean literal", () => {
394
+ });
395
+ it.todo(
396
+ "serializes an ArrayLiteralExpression node by resolving its inferred type",
397
+ () => {
398
+ }
399
+ );
400
+ it.todo(
401
+ "handles an unhandled node kind by returning `any` and warns",
402
+ () => {
403
+ }
404
+ );
405
+ });
406
+ describe("Helper Function: isInterfaceType", () => {
407
+ it.todo("returns true for a type whose symbol is an Interface", () => {
408
+ });
409
+ it.todo("returns false for a type whose symbol is a Class", () => {
410
+ });
411
+ it.todo("returns false for a type that is not a class or interface", () => {
412
+ });
413
+ it.todo("returns false if the type has no symbol", () => {
414
+ });
415
+ });
416
+ });
417
+ //# sourceMappingURL=deriver.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/deriver.test.ts"],
4
+ "sourcesContent": ["import { describe, it } from 'node:test';\nimport ts from 'typescript';\n\n// Assuming necessary imports for context\n\n// Mock TypeChecker and related TS objects would be needed for actual tests\n// For now, we focus on describing the behaviors and test cases.\n\ndescribe('TypeDeriver Class', () => {\n describe('Initialization and Core Properties', () => {\n it.todo('instantiates with a TypeScript TypeChecker instance', () => {\n // Verify the 'checker' property holds the provided TypeChecker.\n });\n it.todo('initializes the `collector` property as an empty object', () => {\n // Verify 'collector' is an empty object `{}` upon instantiation.\n });\n it.todo(\n 'exposes the `deriveSymbol` constant for marking serialized objects',\n () => {\n // Verify `deriveSymbol` is exported and accessible.\n },\n );\n it.todo(\n 'exposes the `$types` symbol constant for holding serialized type information',\n () => {\n // Verify `$types` is exported and accessible.\n },\n );\n });\n\n // --- serializeType Functionality ---\n\n describe('serializeType: Basic Primitive and Special Types', () => {\n it.todo('serializes `any` type to an empty type list', () => {\n // Input: ts.Type with TypeFlags.Any\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [] }\n });\n it.todo('serializes `unknown` type to an empty type list', () => {\n // Input: ts.Type with TypeFlags.Unknown\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [] }\n });\n it.todo('serializes `string` type', () => {\n // Input: ts.Type with TypeFlags.String\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['string'] }\n });\n it.todo('serializes `number` type', () => {\n // Input: ts.Type with TypeFlags.Number\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['number'] }\n });\n it.todo('serializes `boolean` type', () => {\n // Input: ts.Type with TypeFlags.Boolean\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['boolean'] }\n });\n it.todo('serializes `null` type as optional', () => {\n // Input: ts.Type with TypeFlags.Null\n // Output: { [deriveSymbol]: true, optional: true, [$types]: ['null'] }\n });\n it.todo(\n 'serializes `void` type (likely falls back to Any/Unknown or unhandled)',\n () => {\n // Input: ts.Type with TypeFlags.Void (or VoidLike)\n // Determine expected output based on how TS checker presents this type and how the unhandled path works. Likely results in `[$types]: []` or `[$types]: ['void']`.\n },\n );\n it.todo(\n 'serializes `never` type (likely falls back to Any/Unknown or unhandled)',\n () => {\n // Input: ts.Type with TypeFlags.Never\n // Determine expected output. Likely results in `[$types]: []` or `[$types]: ['never']`.\n },\n );\n it.todo(\n 'serializes `undefined` type implicitly via union/intersection optional flag',\n () => {\n // Note: Undefined itself isn't directly serialized as a standalone type by this logic.\n // Its presence in unions/intersections correctly sets the `optional` flag. Tests are under Union/Intersection sections.\n },\n );\n });\n\n describe('serializeType: Literal Types', () => {\n it.todo('serializes string literal types with their value', () => {\n // Input: ts.StringLiteralType (e.g., type of \"constant\")\n // Output: { [deriveSymbol]: true, optional: false, kind: 'literal', value: 'constant', [$types]: ['string'] }\n });\n it.todo('serializes numeric literal types with their value', () => {\n // Input: ts.NumberLiteralType (e.g., type of 123)\n // Output: { [deriveSymbol]: true, optional: false, kind: 'literal', value: 123, [$types]: ['number'] }\n });\n it.todo('serializes boolean literal `true` type', () => {\n // Input: ts.BooleanLiteralType (true) checked via TypeFlags.BooleanLiteral\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['boolean'] }\n // Note: Current code identifies it's boolean but doesn't store the literal `true` value.\n });\n it.todo('serializes boolean literal `false` type', () => {\n // Input: ts.BooleanLiteralType (false) checked via TypeFlags.BooleanLiteral\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['boolean'] }\n // Note: Current code identifies it's boolean but doesn't store the literal `false` value.\n });\n it.todo('serializes template literal types as base `string`', () => {\n // Input: ts.Type with TypeFlags.TemplateLiteral (e.g. type of `ID-${number}`)\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['string'] }\n });\n // Note: BigIntLiteral is not explicitly handled, would fall under unhandled.\n });\n\n describe('serializeType: Enum Types', () => {\n it.todo(\n 'serializes an Enum type (e.g., `enum Color {}`) potentially via unhandled path',\n () => {\n // Input: ts.Type with TypeFlags.Enum (representing the enum itself, e.g., `Color`)\n // Expect it to fall into the unhandled path, likely using checker.typeToString.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['Color'] } or similar based on typeToString. Check console warning.\n },\n );\n it.todo(\n 'serializes an EnumLiteral type (e.g., `Color.Red`) potentially via unhandled path or base type',\n () => {\n // Input: ts.Type with TypeFlags.EnumLiteral (representing the enum member, e.g., `Color.Red`)\n // Check if TS resolves this to its base type (string/number) or if it falls to unhandled.\n // If number enum: Potentially { [deriveSymbol]: true, optional: false, [$types]: ['number'] }\n // If string enum: Potentially { [deriveSymbol]: true, optional: false, [$types]: ['string'] } or a literal string.\n // If unhandled: { [deriveSymbol]: true, optional: false, [$types]: ['Color.Red'] } or similar. Check console warning.\n },\n );\n });\n\n describe('serializeType: Union Types (`|`)', () => {\n it.todo(\n 'serializes a union of primitive types (e.g., string | number)',\n () => {\n // Input: ts.UnionType with string and number types\n // Output: { [deriveSymbol]: true, kind: 'union', optional: false, [$types]: [serializedString, serializedNumber] }\n },\n );\n it.todo(\n 'serializes a union type including `null` (e.g., string | null)',\n () => {\n // Input: ts.UnionType with string and null types\n // Output: { [deriveSymbol]: true, kind: 'union', optional: false, [$types]: [serializedString, serializedNull] }\n // Note: `optional` remains false because `null` is treated as a distinct type here.\n },\n );\n it.todo(\n 'serializes a union type including `undefined`, setting optional flag and filtering `undefined`',\n () => {\n // Input: ts.UnionType with string and undefined types\n // Output: { [deriveSymbol]: true, kind: 'union', optional: true, [$types]: [serializedString] } // undefined is filtered out, optional set to true\n },\n );\n it.todo(\n 'serializes a union type including both `null` and `undefined`',\n () => {\n // Input: ts.UnionType with string, null, and undefined types\n // Output: { [deriveSymbol]: true, kind: 'union', optional: true, [$types]: [serializedString, serializedNull] } // undefined filtered, optional true\n },\n );\n it.todo('serializes a union of literal types (e.g., \"a\" | \"b\" | 1)', () => {\n // Input: ts.UnionType with \"a\", \"b\", 1 types\n // Output: { [deriveSymbol]: true, kind: 'union', optional: false, [$types]: [serializedLiteralA, serializedLiteralB, serializedLiteral1] }\n });\n it.todo(\n 'serializes a union including complex types (e.g., string | MyInterface)',\n () => {\n // Input: ts.UnionType with string and an interface type\n // Output: { [deriveSymbol]: true, kind: 'union', optional: false, [$types]: [serializedString, serializedInterfaceRef] }\n },\n );\n it.todo('serializes a union containing only `undefined`', () => {\n // Input: ts.UnionType with only undefined type\n // Output: { [deriveSymbol]: true, kind: 'union', optional: true, [$types]: [] }\n });\n it.todo('serializes a union containing only `null`', () => {\n // Input: ts.UnionType with only null type\n // Output: { [deriveSymbol]: true, kind: 'union', optional: false, [$types]: [serializedNull] }\n });\n });\n\n describe('serializeType: Intersection Types (`&`)', () => {\n it.todo(\n 'serializes an intersection of object/interface types (e.g., A & B)',\n () => {\n // Input: ts.IntersectionType with two interface types A and B\n // Output: { [deriveSymbol]: true, kind: 'intersection', optional: false, [$types]: [serializedInterfaceA, serializedInterfaceB] }\n },\n );\n it.todo(\n 'serializes an intersection type including `undefined`, setting optional flag and filtering `undefined`',\n () => {\n // Input: ts.IntersectionType with an interface type A and undefined\n // Output: { [deriveSymbol]: true, kind: 'intersection', optional: true, [$types]: [serializedInterfaceA] }\n },\n );\n it.todo('serializes an intersection containing only `undefined`', () => {\n // Input: ts.IntersectionType with only undefined type\n // Output: { [deriveSymbol]: true, kind: 'intersection', optional: true, [$types]: [] }\n });\n // Note: Intersections of primitives often resolve to `never`. The serialization of `never` itself is tested separately.\n });\n\n describe('serializeType: Array and Tuple Types', () => {\n it.todo('serializes a simple array type (e.g., string[])', () => {\n // Input: ts.TypeReference to Array<string>\n // Mock checker.isArrayLikeType -> true, checker.getTypeArguments -> [stringType]\n // Output: { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedString] }\n });\n it.todo('serializes readonly array types (e.g., readonly number[])', () => {\n // Input: ts.TypeReference to ReadonlyArray<number>\n // Mock checker.isArrayLikeType -> true, checker.getTypeArguments -> [numberType]\n // Output: { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedNumber] }\n });\n it.todo(\n 'serializes an array type with object elements (e.g., MyInterface[])',\n () => {\n // Input: ts.TypeReference to Array<MyInterface>\n // Mock checker.getTypeArguments -> [interfaceType], interfaceType.symbol.valueDeclaration -> InterfaceDeclaration Node\n // Output: { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedInterfaceRef] } // Relies on serializeNode call\n },\n );\n it.todo(\n 'serializes an array type with union elements (e.g., (string | number)[])',\n () => {\n // Input: ts.TypeReference to Array<string | number>\n // Mock checker.getTypeArguments -> [unionType]\n // Output: { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedUnionStringNumber] }\n },\n );\n it.todo('serializes an array type where element type has no symbol', () => {\n // Input: ts.TypeReference to Array<{inline: boolean}>\n // Mock checker.getTypeArguments -> [inlineObjectType], inlineObjectType.getSymbol() -> undefined\n // Output: { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedInlineObject] } // Relies on serializeType(inlineObjectType)\n });\n it.todo(\n 'serializes an array type where element symbol has no value declaration but has declarations',\n () => {\n // Input: ts.TypeReference to Array<SomeType>\n // Mock checker.getTypeArguments -> [someType], someType.symbol.valueDeclaration -> undefined, someType.symbol.declarations -> [TypeAliasDeclaration Node?]\n // Expect serializeNode to be called with declarations[0]. Verify output based on that node type.\n },\n );\n it.todo(\n 'serializes an array type with a mapped type element (e.g., MappedType[])',\n () => {\n // Input: ts.TypeReference to Array<MappedType>\n // Mock checker.getTypeArguments -> [mappedType], mappedType symbol has declarations[0] as MappedTypeNode\n // Mock checker.getPropertiesOfType for mappedType\n // Output: { kind: 'array', optional: false, [deriveSymbol]: true, [$types]: [resolvedMappedObject] }\n },\n );\n it.todo(\n 'handles array-like types with missing type arguments gracefully (e.g., Array)',\n () => {\n // Input: ts.TypeReference to Array (no <T>)\n // Mock checker.getTypeArguments -> undefined or []\n // Output: { [deriveSymbol]: true, optional: false, kind: 'array', [$types]: ['any'] } // Check console warning\n },\n );\n it.todo(\n 'serializes tuple types (e.g., [string, number]) potentially as array of union',\n () => {\n // Input: ts.TupleTypeReference for [string, number]\n // Mock checker.isArrayLikeType -> true. Check what checker.getTypeArguments returns (likely the tuple element types).\n // Current code likely serializes as Array<string | number>.\n // Expected Output (based on current code): { [deriveSymbol]: true, kind: 'array', optional: false, [$types]: [serializedUnionStringNumber] } or similar union.\n // Note: A more precise tuple serialization would require specific handling of ts.TupleTypeReference.\n },\n );\n });\n\n describe('serializeType: Record/Index Types', () => {\n it.todo(\n 'serializes a string index signature type (Record<string, number>)',\n () => {\n // Input: ts.Type where type.getStringIndexType() returns numberType\n // Output: { [deriveSymbol]: true, kind: 'record', optional: false, [$types]: [serializedNumber] }\n },\n );\n it.todo(\n 'serializes a string index signature type with complex value (Record<string, MyInterface>)',\n () => {\n // Input: ts.Type where type.getStringIndexType() returns interfaceType\n // Output: { [deriveSymbol]: true, kind: 'record', optional: false, [$types]: [serializedInterfaceRef] }\n },\n );\n it.todo(\n 'serializes a type with only a number index signature ([key: number]: boolean)',\n () => {\n // Input: ts.Type where type.getStringIndexType() is undefined, but type.getNumberIndexType() exists.\n // Expect this to *not* take the `getStringIndexType` path.\n // It should fall into the `TypeFlags.Object` path.\n // Mock checker.getPropertiesOfType (might be empty or special symbol).\n // Mock type.symbol.declarations to include the IndexSignature node.\n // Expected Output: Likely falls back to generic object or potentially unhandled `{ [deriveSymbol]: true, optional: false, [$types]: ['<some object representation>'] }`. Needs verification against actual TS behavior.\n },\n );\n });\n\n describe('serializeType: Object Types (Interfaces, Classes, Inline, Mapped)', () => {\n it.todo('serializes an inline object type literal (passed as type)', () => {\n // Input: ts.Type representing `{ a: string; b?: number }` (TypeFlags.Object)\n // Mock checker.getPropertiesOfType -> [symbolA, symbolB]\n // Mock checker.getTypeOfSymbol for 'a' (string) and 'b' (number | undefined)\n // Output: { [deriveSymbol]: true, kind: 'object', optional: false, [$types]: [{ a: serializedString, b: serializedUnionNumberUndefined }] }\n });\n it.todo(\n 'serializes a mapped type directly (e.g., type M = { [K in keyof T]: T[K] })',\n () => {\n // Input: ts.Type representing a mapped type (TypeFlags.Object, potentially others)\n // Mock checker.getPropertiesOfType to return the mapped properties.\n // Mock checker.getTypeOfSymbol for each mapped property.\n // Output: { [deriveSymbol]: true, kind: 'object', optional: false, [$types]: [{ /* serialized mapped properties */ }] }\n },\n );\n it.todo(\n 'serializes an object type using literal property assignments from declarations',\n () => {\n // Input: ts.Type representing an object like `const x = { val: 123 }`\n // Mock checker.getPropertiesOfType -> [symbolVal]\n // Mock symbolVal.getDeclarations() -> [PropertyAssignment node with literal 123]\n // Mock checker.getTypeAtLocation for the literal initializer -> numberLiteralType(123)\n // Output: { [deriveSymbol]: true, kind: 'object', optional: false, [$types]: [{ val: serializedLiteral123 }] }\n },\n );\n it.todo(\n 'serializes an object type with mixed declared types (PropertySignature) and literal assignments (PropertyAssignment)',\n () => {\n // Input: ts.Type representing `{ prop: string; literal: \"hello\" }` where `prop` comes from signature and `literal` from assignment.\n // Ensure both `isPropertyAssignment` and `isPropertySignature` paths within the loop are tested.\n // Output: { [deriveSymbol]: true, kind: 'object', optional: false, [$types]: [{ prop: serializedString, literal: serializedLiteralHello }] }\n },\n );\n it.todo(\n 'serializes an empty object type `{}` potentially falling back to name or generic',\n () => {\n // Input: ts.Type representing `{}` (TypeFlags.Object)\n // Mock checker.getPropertiesOfType -> []\n // Mock type.symbol.valueDeclaration / declarations -> undefined\n // Mock type.symbol.getName() -> 'Object' or similar\n // Expected Output: Depends on fallback logic. Potentially `{ [deriveSymbol]: true, optional: false, [$types]: ['Object'] }` or a generic object representation if name is unhelpful.\n },\n );\n it.todo(\n 'handles object types matching default overrides (e.g., DateConstructor -> string)',\n () => {\n // Input: ts.Type whose symbol name is 'DateConstructor' (present in `defaults`)\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['string'] } // Value from `defaults` map\n },\n );\n it.todo(\n 'handles known object types NOT in defaults (e.g., RegExp) by attempting standard object serialization',\n () => {\n // Input: ts.Type for RegExp (not in `defaults`)\n // Mock checker.getPropertiesOfType (likely empty or methods)\n // Mock symbol.valueDeclaration / declarations (likely points to lib.d.ts)\n // Expect standard object serialization attempt, possibly resulting in an empty object or reference if declaration is found.\n // Output: { [deriveSymbol]: true, kind: 'object', optional: false, [$types]: [{ /* properties or empty */ }] } or a reference via serializeNode.\n },\n );\n it.todo(\n 'serializes an interface type by deferring to serializeNode for reference/collection',\n () => {\n // Input: ts.InterfaceType (isInterfaceType returns true)\n // Mock type.symbol.valueDeclaration or declarations[0] -> InterfaceDeclaration node\n // Verify serializeNode is called with the declaration node.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyInterface`] }\n },\n );\n it.todo(\n 'serializes a class type by deferring to serializeNode for reference/collection',\n () => {\n // Input: ts.Type representing a class (isClass returns true)\n // Mock type.symbol.valueDeclaration -> ClassDeclaration node\n // Verify serializeNode is called with the declaration node.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyClass`], $ref: `#/components/schemas/MyClass` }\n },\n );\n it.todo(\n 'serializes an interface type using its name when its declaration cannot be found',\n () => {\n // Input: ts.InterfaceType where type.symbol has no valueDeclaration or declarations[0]\n // Mock type.symbol.getName() -> 'MyInterface'\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['MyInterface'] }\n },\n );\n it.todo(\n 'serializes a class type using its name when its declaration cannot be found',\n () => {\n // Input: ts.Type for a class where type.symbol has no valueDeclaration\n // Mock type.symbol.getName() -> 'MyClass'\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['MyClass'] }\n },\n );\n });\n\n describe('serializeType: Unhandled Types', () => {\n it.todo(\n 'handles an unhandled type flag by using checker.typeToString and warns',\n () => {\n // Input: A ts.Type with flags not explicitly handled (e.g., potentially Enum, Index, IndexedAccess if not resolved)\n // Mock checker.typeToString -> '<specific unhandled representation>'\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['<specific unhandled representation>'] } // Check console warning\n },\n );\n // Note: Complex types like ConditionalType, IndexedAccessType are expected to be resolved by the checker *before* this function sees them.\n // We serialize the *result* of the resolution, not the conditional/indexed access type itself.\n });\n\n // --- serializeNode Functionality ---\n\n describe('serializeNode: Object Literal Expressions (`{ ... }`)', () => {\n it.todo(\n 'serializes an object literal node with various primitive property types',\n () => {\n // Input: ts.ObjectLiteralExpression node `{ a: 1, b: \"s\", c: true, d: null, e: undefined }`\n // Mock checker.getTypeAtLocation for the node itself\n // Mock checker.getTypeOfSymbol for properties 'a', 'b', 'c', 'd', 'e'\n // Mock checker.getTypeAtLocation for literal initializers (1, \"s\", true, null, undefined)\n // Output: { a: serializedLiteral1, b: serializedLiteralS, c: serializedLiteralTrue, d: serializedNull, e: serializedUndefined } // Note: undefined serialization depends on serializeType\n },\n );\n it.todo(\n 'serializes an object literal node with nested object/array literals',\n () => {\n // Input: ts.ObjectLiteralExpression node `{ data: { values: [1, 2] } }`\n // Ensure recursive serialization via serializeType/serializeNode works.\n // Output: { data: { values: serializedArrayLiteral12 } }\n },\n );\n it.todo('serializes an empty object literal node `{}`', () => {\n // Input: ts.ObjectLiteralExpression node `{}`\n // Mock checker.getTypeAtLocation -> empty object type\n // Output: {}\n });\n });\n\n describe('serializeNode: Property Access/Signature/Declaration', () => {\n it.todo(\n 'serializes a PropertyAccessExpression node (e.g., `obj.prop`) by resolving its type',\n () => {\n // Input: ts.PropertyAccessExpression node `obj.prop`\n // Mock checker.getSymbolAtLocation for `prop` -> symbolProp\n // Mock checker.getTypeOfSymbol(symbolProp) -> typeProp\n // Verify serializeType is called with typeProp.\n // Output: Result of serializeType(typeProp)\n },\n );\n it.todo(\n 'serializes a PropertySignature node (e.g., `prop: string;`) by resolving its type',\n () => {\n // Input: ts.PropertySignature node `prop: string;` (within an InterfaceDeclaration or TypeLiteral)\n // Mock checker.getSymbolAtLocation for `prop` -> symbolProp\n // Mock checker.getTypeOfSymbol(symbolProp) -> stringType\n // Verify serializeType is called with stringType.\n // Output: Result of serializeType(stringType)\n },\n );\n it.todo(\n 'serializes a PropertyDeclaration node (e.g., `prop: number;`) by resolving its type',\n () => {\n // Input: ts.PropertyDeclaration node `prop: number;` (within a ClassDeclaration)\n // Mock checker.getSymbolAtLocation for `prop` -> symbolProp\n // Mock checker.getTypeOfSymbol(symbolProp) -> numberType\n // Verify serializeType is called with numberType.\n // Output: Result of serializeType(numberType)\n },\n );\n it.todo(\n 'handles property nodes where symbol cannot be found for the property name and warns',\n () => {\n // Input: A PropertySignature/Declaration/Access node where checker.getSymbolAtLocation(node.name) returns undefined\n // Output: null // Check console warning\n },\n );\n });\n\n describe('serializeNode: Interface Declarations (`interface ...`) and Collector Interaction', () => {\n it.todo(\n 'serializes a new interface declaration, adding its structure to the collector',\n () => {\n // Input: ts.InterfaceDeclaration node `interface MyInterface { id: number; name?: string; }`\n // Ensure collector['MyInterface'] is initially empty/undefined.\n // Mock members `id` and `name` and their serialization via serializeNode(PropertySignature).\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyInterface`] }\n // Verify collector['MyInterface'] now contains { id: serializedNumber, name: serializedUnionStringUndefined }\n },\n );\n it.todo(\n 'returns only a reference for an already serialized interface declaration (present in collector)',\n () => {\n // Input: ts.InterfaceDeclaration node `interface MyInterface { ... }`\n // Pre-populate collector['MyInterface'] with a placeholder or previous result.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyInterface`] }\n // Verify collector['MyInterface'] was not overwritten if already fully populated.\n },\n );\n it.todo(\n 'handles interface declarations matching default overrides without adding to collector',\n () => {\n // Input: ts.InterfaceDeclaration node `interface Readable { ... }` (name is in `defaults`)\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['any'] } // Value from `defaults` map\n // Verify collector['Readable'] remains undefined or unchanged.\n },\n );\n it.todo(\n 'throws an error for an interface declaration without a name',\n () => {\n // Input: An InterfaceDeclaration node where node.name is undefined.\n // Expect the function to throw 'Interface has no name'.\n },\n );\n it.todo(\n 'handles interfaces with no members correctly (adds empty object to collector)',\n () => {\n // Input: ts.InterfaceDeclaration node `interface Empty {}`\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/Empty`] }\n // Verify collector['Empty'] is `{}`.\n },\n );\n it.todo(\n 'handles interfaces extending other interfaces (serialization includes only own properties)',\n () => {\n // Input: `interface B extends A { propB: string; }` (where A is `interface A { propA: number }`)\n // Serialize B.\n // Output: Reference `#/components/schemas/B`\n // Verify collector['B'] contains only `{ propB: serializedString }`. (Inherited props are resolved by tools consuming the schema, not duplicated here).\n // Note: Actual inheritance representation might need adjustment based on target schema format (e.g., OpenAPI `allOf`). This test verifies the *collector* content based on current code.\n },\n );\n });\n\n describe('serializeNode: Class Declarations (`class ...`) and Collector Interaction', () => {\n it.todo(\n 'serializes a new class declaration, adding its property structure to the collector',\n () => {\n // Input: ts.ClassDeclaration node `class MyClass { id: number; private secret: string; constructor() {} }`\n // Ensure collector['MyClass'] is initially empty/undefined.\n // Mock members `id` and `secret` and their serialization via serializeNode(PropertyDeclaration). Ignore constructor/methods.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyClass`], $ref: `#/components/schemas/MyClass` }\n // Verify collector['MyClass'] now contains { id: serializedNumber, secret: serializedString } (Includes private members)\n },\n );\n it.todo(\n 'returns only a reference for an already serialized class declaration (present in collector)',\n () => {\n // Input: ts.ClassDeclaration node `class MyClass { ... }`\n // Pre-populate collector['MyClass'] with a placeholder or previous result.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/MyClass`], $ref: `#/components/schemas/MyClass` }\n // Verify collector['MyClass'] was not overwritten if already fully populated.\n },\n );\n it.todo(\n 'handles class declarations matching default overrides without adding to collector',\n () => {\n // Input: ts.ClassDeclaration node `class Uint8Array { ... }` (name is in `defaults`)\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['any'] } // Value from `defaults` map\n // Verify collector['Uint8Array'] remains undefined or unchanged.\n },\n );\n it.todo(\n 'throws an error for a class declaration without a name (e.g., anonymous default export)',\n () => {\n // Input: A ClassDeclaration node where node.name is undefined.\n // Expect the function to throw 'Class has no name'.\n },\n );\n it.todo(\n 'handles classes with no property declarations (only methods/constructor) correctly (adds empty object to collector)',\n () => {\n // Input: ts.ClassDeclaration node `class Service { constructor() {} process() {} }`\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [`#/components/schemas/Service`], $ref: `#/components/schemas/Service` }\n // Verify collector['Service'] is `{}`.\n },\n );\n it.todo(\n 'handles classes implementing interfaces (serialization includes only own properties)',\n () => {\n // Input: `class B implements A { propB: string; }` (where A is `interface A { propA: number }`)\n // Serialize B.\n // Output: Reference `#/components/schemas/B`\n // Verify collector['B'] contains only `{ propB: serializedString }`.\n },\n );\n it.todo(\n 'handles classes extending other classes (serialization includes only own properties)',\n () => {\n // Input: `class D extends C { propD: string; }` (where C is `class C { propC: number }`)\n // Serialize D.\n // Output: Reference `#/components/schemas/D`\n // Verify collector['D'] contains only `{ propD: serializedString }`.\n },\n );\n });\n\n describe('serializeNode: Other Node Types', () => {\n it.todo(\n 'serializes a VariableDeclaration node with an explicit type annotation',\n () => {\n // Input: ts.VariableDeclaration node `const user: IUser;`\n // Mock node.type to be a TypeReference node pointing to IUser\n // Mock checker.getTypeFromTypeNode -> interfaceType IUser\n // Verify serializeType is called with interfaceType IUser.\n // Output: Result of serializeType(interfaceType IUser) -> likely interface reference\n },\n );\n it.todo(\n 'handles VariableDeclaration node without a type annotation and warns',\n () => {\n // Input: ts.VariableDeclaration node `const count = 5;` (node.type is undefined)\n // Output: 'any' // Check console warning\n },\n );\n it.todo(\n 'handles VariableDeclaration node where symbol cannot be found for the variable name and warns',\n () => {\n // Input: ts.VariableDeclaration node where checker.getSymbolAtLocation(node.name) returns undefined\n // Output: null // Check console warning\n },\n );\n it.todo(\n 'serializes an Identifier node by resolving its type at that location',\n () => {\n // Input: ts.Identifier node `myVar` (where myVar is declared as string)\n // Mock checker.getSymbolAtLocation for the identifier -> symbolMyVar\n // Mock checker.getTypeAtLocation for the identifier node -> stringType\n // Verify serializeType is called with stringType.\n // Output: Result of serializeType(stringType)\n },\n );\n it.todo(\n 'handles Identifier node where symbol cannot be found and warns',\n () => {\n // Input: ts.Identifier node where checker.getSymbolAtLocation returns undefined\n // Output: null // Check console warning\n },\n );\n it.todo(\n 'serializes an AwaitExpression node by resolving the awaited type',\n () => {\n // Input: ts.AwaitExpression node `await getUser()` where getUser returns Promise<User>\n // Mock checker.getTypeAtLocation(node) -> User type (checker resolves the Promise)\n // Verify serializeType is called with the User type.\n // Output: Result of serializeType(User type)\n },\n );\n it.todo(\n 'serializes a CallExpression node by resolving its return type',\n () => {\n // Input: ts.CallExpression node `calculateTotal()` where calculateTotal returns number\n // Mock checker.getTypeAtLocation(node) -> numberType\n // Verify serializeType is called with numberType.\n // Output: Result of serializeType(numberType)\n },\n );\n it.todo(\n 'serializes an AsExpression node by resolving the asserted type',\n () => {\n // Input: ts.AsExpression node `data as Product`\n // Mock checker.getTypeAtLocation(node) -> Product type (the asserted type)\n // Verify serializeType is called with the Product type.\n // Output: Result of serializeType(Product type)\n },\n );\n it.todo(\n 'serializes a TypeLiteralNode (`{ ... }` used as a type) by resolving its properties',\n () => {\n // Input: ts.TypeLiteralNode node `{ id: number; value: string }`\n // Mock checker.getTypeAtLocation(node) -> objectType\n // Mock checker.getPropertiesOfType(objectType) -> [symbolId, symbolValue]\n // Mock checker.getTypeOfSymbol for each property.\n // Output: { [deriveSymbol]: true, optional: false, [$types]: [{ id: serializedNumber, value: serializedString }] }\n },\n );\n it.todo('serializes NullKeyword node', () => {\n // Input: Node with kind ts.SyntaxKind.NullKeyword\n // Output: { [deriveSymbol]: true, optional: true, [$types]: ['null'] }\n });\n it.todo('serializes BooleanKeyword node', () => {\n // Input: Node with kind ts.SyntaxKind.BooleanKeyword\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['boolean'] }\n });\n it.todo('serializes TrueKeyword node as boolean literal', () => {\n // Input: Node with kind ts.SyntaxKind.TrueKeyword\n // Output: { [deriveSymbol]: true, optional: false, kind: 'literal', value: true, [$types]: ['boolean'] }\n });\n it.todo('serializes FalseKeyword node as boolean literal', () => {\n // Input: Node with kind ts.SyntaxKind.FalseKeyword\n // Output: { [deriveSymbol]: true, optional: false, kind: 'literal', value: false, [$types]: ['boolean'] }\n });\n it.todo(\n 'serializes an ArrayLiteralExpression node by resolving its inferred type',\n () => {\n // Input: ts.ArrayLiteralExpression node `[1, \"a\", null]`\n // Mock checker.getTypeAtLocation(node) -> inferred array type (e.g., (number | string | null)[])\n // Verify serializeType is called with the inferred type.\n // Output: Result of serializeType(inferred array type) -> likely array of union\n },\n );\n it.todo(\n 'handles an unhandled node kind by returning `any` and warns',\n () => {\n // Input: A node with a kind not explicitly handled (e.g., ts.SyntaxKind.IfStatement)\n // Output: { [deriveSymbol]: true, optional: false, [$types]: ['any'] } // Check console warning\n },\n );\n });\n\n describe('Helper Function: isInterfaceType', () => {\n it.todo('returns true for a type whose symbol is an Interface', () => {\n // Input: ts.Type where type.isClassOrInterface() is true and type.symbol.flags includes ts.SymbolFlags.Interface\n // Output: true\n });\n it.todo('returns false for a type whose symbol is a Class', () => {\n // Input: ts.Type where type.isClassOrInterface() is true and type.symbol.flags includes ts.SymbolFlags.Class but not Interface\n // Output: false\n });\n it.todo('returns false for a type that is not a class or interface', () => {\n // Input: ts.Type for string, number, etc. where type.isClassOrInterface() is false\n // Output: false\n });\n it.todo('returns false if the type has no symbol', () => {\n // Input: ts.Type where type.symbol is undefined (e.g., some primitive types)\n // Output: false (as it won't have the Interface flag)\n });\n });\n});\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,UAAU;AAC7B,OAAO,QAAQ;AAOf,SAAS,qBAAqB,MAAM;AAClC,WAAS,sCAAsC,MAAM;AACnD,OAAG,KAAK,uDAAuD,MAAM;AAAA,IAErE,CAAC;AACD,OAAG,KAAK,2DAA2D,MAAM;AAAA,IAEzE,CAAC;AACD,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAEN;AAAA,IACF;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AAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAGN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAMN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAGN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAKN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAKN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAKN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAMN;AAAA,IACF;AACA,OAAG,KAAK,+BAA+B,MAAM;AAAA,IAG7C,CAAC;AACD,OAAG,KAAK,kCAAkC,MAAM;AAAA,IAGhD,CAAC;AACD,OAAG,KAAK,kDAAkD,MAAM;AAAA,IAGhE,CAAC;AACD,OAAG,KAAK,mDAAmD,MAAM;AAAA,IAGjE,CAAC;AACD,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAKN;AAAA,IACF;AACA,OAAG;AAAA,MACD;AAAA,MACA,MAAM;AAAA,MAGN;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,oCAAoC,MAAM;AACjD,OAAG,KAAK,wDAAwD,MAAM;AAAA,IAGtE,CAAC;AACD,OAAG,KAAK,oDAAoD,MAAM;AAAA,IAGlE,CAAC;AACD,OAAG,KAAK,6DAA6D,MAAM;AAAA,IAG3E,CAAC;AACD,OAAG,KAAK,2CAA2C,MAAM;AAAA,IAGzD,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -2,10 +2,11 @@ import type { Dirent } from 'node:fs';
2
2
  export declare function getFile(filePath: string): Promise<string | null>;
3
3
  export declare function exist(file: string): Promise<boolean>;
4
4
  export declare function readFolder(path: string): Promise<string[]>;
5
- export declare function writeFiles(dir: string, contents: Record<string, null | string | {
5
+ export type WriteContent = Record<string, null | string | {
6
6
  content: string;
7
7
  ignoreIfExists?: boolean;
8
- }>): Promise<void>;
8
+ }>;
9
+ export declare function writeFiles(dir: string, contents: WriteContent): Promise<void>;
9
10
  export declare function getFolderExports(folder: string, includeExtension?: boolean, extensions?: string[], ignore?: (dirent: Dirent) => boolean): Promise<string>;
10
11
  export declare function getFolderExportsV2(folder: string, options?: {
11
12
  includeExtension?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../src/lib/file-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,0BAK7C;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1D;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,qBAK5C;AAED,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,CACd,MAAM,EACN,IAAI,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAC9D,iBAsBF;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,gBAAgB,UAAO,EACvB,UAAU,WAAS,EACnB,MAAM,GAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAqB,mBAwBlD;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;CAMtB,mBAgCF;AAED,eAAO,MAAM,MAAM,GAAI,WAAW,MAAM,W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