zinfer 0.0.1 → 0.1.2

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.
Files changed (79) hide show
  1. package/README.md +477 -28
  2. package/bin/zinfer +2 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +486 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/core/brand-detector.d.ts +32 -0
  8. package/dist/core/brand-detector.d.ts.map +1 -0
  9. package/dist/core/brand-detector.js +121 -0
  10. package/dist/core/brand-detector.js.map +1 -0
  11. package/dist/core/config-loader.d.ts +87 -0
  12. package/dist/core/config-loader.d.ts.map +1 -0
  13. package/dist/core/config-loader.js +105 -0
  14. package/dist/core/config-loader.js.map +1 -0
  15. package/dist/core/description-extractor.d.ts +54 -0
  16. package/dist/core/description-extractor.d.ts.map +1 -0
  17. package/dist/core/description-extractor.js +180 -0
  18. package/dist/core/description-extractor.js.map +1 -0
  19. package/dist/core/errors.d.ts +35 -0
  20. package/dist/core/errors.d.ts.map +1 -0
  21. package/dist/core/errors.js +96 -0
  22. package/dist/core/errors.js.map +1 -0
  23. package/dist/core/extractor.d.ts +121 -0
  24. package/dist/core/extractor.d.ts.map +1 -0
  25. package/dist/core/extractor.js +504 -0
  26. package/dist/core/extractor.js.map +1 -0
  27. package/dist/core/file-resolver.d.ts +41 -0
  28. package/dist/core/file-resolver.d.ts.map +1 -0
  29. package/dist/core/file-resolver.js +95 -0
  30. package/dist/core/file-resolver.js.map +1 -0
  31. package/dist/core/getter-resolver.d.ts +67 -0
  32. package/dist/core/getter-resolver.d.ts.map +1 -0
  33. package/dist/core/getter-resolver.js +234 -0
  34. package/dist/core/getter-resolver.js.map +1 -0
  35. package/dist/core/import-resolver.d.ts +51 -0
  36. package/dist/core/import-resolver.d.ts.map +1 -0
  37. package/dist/core/import-resolver.js +158 -0
  38. package/dist/core/import-resolver.js.map +1 -0
  39. package/dist/core/index.d.ts +14 -0
  40. package/dist/core/index.d.ts.map +1 -0
  41. package/dist/core/index.js +13 -0
  42. package/dist/core/index.js.map +1 -0
  43. package/dist/core/logger.d.ts +20 -0
  44. package/dist/core/logger.d.ts.map +1 -0
  45. package/dist/core/logger.js +36 -0
  46. package/dist/core/logger.js.map +1 -0
  47. package/dist/core/name-mapper.d.ts +45 -0
  48. package/dist/core/name-mapper.d.ts.map +1 -0
  49. package/dist/core/name-mapper.js +82 -0
  50. package/dist/core/name-mapper.js.map +1 -0
  51. package/dist/core/normalizer.d.ts +24 -0
  52. package/dist/core/normalizer.d.ts.map +1 -0
  53. package/dist/core/normalizer.js +50 -0
  54. package/dist/core/normalizer.js.map +1 -0
  55. package/dist/core/schema-detector.d.ts +49 -0
  56. package/dist/core/schema-detector.d.ts.map +1 -0
  57. package/dist/core/schema-detector.js +272 -0
  58. package/dist/core/schema-detector.js.map +1 -0
  59. package/dist/core/schema-reference-analyzer.d.ts +77 -0
  60. package/dist/core/schema-reference-analyzer.d.ts.map +1 -0
  61. package/dist/core/schema-reference-analyzer.js +269 -0
  62. package/dist/core/schema-reference-analyzer.js.map +1 -0
  63. package/dist/core/test-generator.d.ts +97 -0
  64. package/dist/core/test-generator.d.ts.map +1 -0
  65. package/dist/core/test-generator.js +177 -0
  66. package/dist/core/test-generator.js.map +1 -0
  67. package/dist/core/type-printer.d.ts +46 -0
  68. package/dist/core/type-printer.d.ts.map +1 -0
  69. package/dist/core/type-printer.js +519 -0
  70. package/dist/core/type-printer.js.map +1 -0
  71. package/dist/core/types.d.ts +124 -0
  72. package/dist/core/types.d.ts.map +1 -0
  73. package/dist/core/types.js +5 -0
  74. package/dist/core/types.js.map +1 -0
  75. package/dist/index.d.ts +66 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +79 -0
  78. package/dist/index.js.map +1 -0
  79. package/package.json +63 -7
@@ -0,0 +1,121 @@
1
+ import type { ExtractResult, FileExtractResult } from "./types.js";
2
+ export type { ExtractResult } from "./types.js";
3
+ /**
4
+ * Options for type extraction.
5
+ */
6
+ export interface ExtractOptions {
7
+ /** Absolute or relative path to the TypeScript file containing the Zod schema */
8
+ filePath: string;
9
+ /** Name of the exported Zod schema (e.g., "UserSchema") */
10
+ schemaName: string;
11
+ /** Optional path to tsconfig.json for project configuration */
12
+ tsconfigPath?: string;
13
+ }
14
+ /**
15
+ * Extracts input and output types from Zod schemas using TypeScript Compiler API.
16
+ */
17
+ export declare class ZodTypeExtractor {
18
+ private project;
19
+ private schemaDetector;
20
+ private getterResolver;
21
+ private referenceAnalyzer;
22
+ private importResolver;
23
+ private brandDetector;
24
+ /**
25
+ * Creates a new ZodTypeExtractor instance.
26
+ *
27
+ * @param tsconfigPath - Optional path to tsconfig.json. If not provided,
28
+ * default compiler options will be used.
29
+ */
30
+ constructor(tsconfigPath?: string);
31
+ /**
32
+ * Extracts input and output types from a Zod schema.
33
+ *
34
+ * @param options - Extraction options including file path and schema name
35
+ * @returns The extracted input and output types as strings
36
+ */
37
+ extract(options: ExtractOptions): ExtractResult;
38
+ /**
39
+ * Extracts types from all exported Zod schemas in a file.
40
+ *
41
+ * @param filePath - Path to the TypeScript file
42
+ * @returns Array of extraction results for each schema
43
+ */
44
+ extractAll(filePath: string): ExtractResult[];
45
+ /**
46
+ * Extracts types from specific schemas in a file.
47
+ *
48
+ * @param filePath - Path to the TypeScript file
49
+ * @param schemaNames - Names of schemas to extract
50
+ * @returns Array of extraction results
51
+ */
52
+ extractMultiple(filePath: string, schemaNames: string[]): ExtractResult[];
53
+ /**
54
+ * Extracts types from all exported schemas and returns file-level result.
55
+ *
56
+ * @param filePath - Path to the TypeScript file
57
+ * @returns File extraction result with all schemas
58
+ */
59
+ extractFile(filePath: string): FileExtractResult;
60
+ /**
61
+ * Gets the list of detected schema names in a file.
62
+ *
63
+ * @param filePath - Path to the TypeScript file
64
+ * @returns Array of schema names
65
+ */
66
+ getSchemaNames(filePath: string): string[];
67
+ /**
68
+ * Gets or adds a source file to the project.
69
+ */
70
+ private getOrAddSourceFile;
71
+ /**
72
+ * Internal method to extract multiple schemas from a source file.
73
+ */
74
+ private extractMultipleFromSourceFile;
75
+ /**
76
+ * Replaces an inline schema reference with a type name.
77
+ */
78
+ private replaceSchemaReference;
79
+ /**
80
+ * Injects temporary type for explicit type (without normalization for circular refs).
81
+ */
82
+ private injectExplicitType;
83
+ /**
84
+ * Cleans up explicit type temporaries.
85
+ */
86
+ private cleanupExplicitType;
87
+ /**
88
+ * Creates a ts-morph Project with appropriate compiler options.
89
+ */
90
+ private createProject;
91
+ /**
92
+ * Injects the Normalize type and temporary type aliases into the source file.
93
+ * These are added in-memory only and never saved to disk.
94
+ */
95
+ private injectTemporaryTypes;
96
+ /**
97
+ * Resolves a type alias and returns its fully expanded string representation.
98
+ */
99
+ private resolveType;
100
+ /**
101
+ * Simplifies Zod internal function types to Function.
102
+ * Replaces patterns like z.core.$InferInnerFunctionType<...> with Function.
103
+ * Handles nested type parameters properly.
104
+ */
105
+ private simplifyZodFunctionTypes;
106
+ /**
107
+ * Removes the temporary types that were injected during extraction.
108
+ * This ensures the original file remains unmodified.
109
+ */
110
+ private cleanupTemporaryTypes;
111
+ /**
112
+ * Escapes special characters in a string for use in a RegExp.
113
+ */
114
+ private escapeRegExp;
115
+ /**
116
+ * Checks if a string is a valid TypeScript identifier.
117
+ * Used to determine if a type name can be safely used in regex replacement.
118
+ */
119
+ private isValidIdentifier;
120
+ }
121
+ //# sourceMappingURL=extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/core/extractor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAGnF,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,UA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,504 @@
1
+ import { Project, TypeFormatFlags, ts } from "ts-morph";
2
+ import { NORMALIZE_TYPE_DEFINITION, createTempTypeAlias, TEMP_TYPE_NAMES } from "./normalizer.js";
3
+ import { SchemaDetector } from "./schema-detector.js";
4
+ import { GetterResolver } from "./getter-resolver.js";
5
+ import { SchemaReferenceAnalyzer } from "./schema-reference-analyzer.js";
6
+ import { ImportResolver } from "./import-resolver.js";
7
+ import { BrandDetector } from "./brand-detector.js";
8
+ import { logDebugError } from "./logger.js";
9
+ /**
10
+ * Extracts input and output types from Zod schemas using TypeScript Compiler API.
11
+ */
12
+ export class ZodTypeExtractor {
13
+ project;
14
+ schemaDetector;
15
+ getterResolver;
16
+ referenceAnalyzer;
17
+ importResolver;
18
+ brandDetector;
19
+ /**
20
+ * Creates a new ZodTypeExtractor instance.
21
+ *
22
+ * @param tsconfigPath - Optional path to tsconfig.json. If not provided,
23
+ * default compiler options will be used.
24
+ */
25
+ constructor(tsconfigPath) {
26
+ this.project = this.createProject(tsconfigPath);
27
+ this.schemaDetector = new SchemaDetector();
28
+ this.getterResolver = new GetterResolver();
29
+ this.referenceAnalyzer = new SchemaReferenceAnalyzer();
30
+ this.importResolver = new ImportResolver();
31
+ this.brandDetector = new BrandDetector();
32
+ }
33
+ /**
34
+ * Extracts input and output types from a Zod schema.
35
+ *
36
+ * @param options - Extraction options including file path and schema name
37
+ * @returns The extracted input and output types as strings
38
+ */
39
+ extract(options) {
40
+ const { filePath, schemaName } = options;
41
+ // Use extractMultiple to handle explicit type annotations properly
42
+ const results = this.extractMultiple(filePath, [schemaName]);
43
+ if (results.length === 0) {
44
+ throw new Error(`Schema "${schemaName}" not found in ${filePath}`);
45
+ }
46
+ return results[0];
47
+ }
48
+ /**
49
+ * Extracts types from all exported Zod schemas in a file.
50
+ *
51
+ * @param filePath - Path to the TypeScript file
52
+ * @returns Array of extraction results for each schema
53
+ */
54
+ extractAll(filePath) {
55
+ const sourceFile = this.getOrAddSourceFile(filePath);
56
+ const schemas = this.schemaDetector.detectExportedSchemas(sourceFile);
57
+ return this.extractMultipleFromSourceFile(sourceFile, schemas);
58
+ }
59
+ /**
60
+ * Extracts types from specific schemas in a file.
61
+ *
62
+ * @param filePath - Path to the TypeScript file
63
+ * @param schemaNames - Names of schemas to extract
64
+ * @returns Array of extraction results
65
+ */
66
+ extractMultiple(filePath, schemaNames) {
67
+ const sourceFile = this.getOrAddSourceFile(filePath);
68
+ const allSchemas = this.schemaDetector.detectExportedSchemas(sourceFile);
69
+ const schemas = schemaNames.map((name) => {
70
+ const found = allSchemas.find((s) => s.name === name);
71
+ return found || { name, isExported: true, line: 0 };
72
+ });
73
+ return this.extractMultipleFromSourceFile(sourceFile, schemas);
74
+ }
75
+ /**
76
+ * Extracts types from all exported schemas and returns file-level result.
77
+ *
78
+ * @param filePath - Path to the TypeScript file
79
+ * @returns File extraction result with all schemas
80
+ */
81
+ extractFile(filePath) {
82
+ return {
83
+ filePath,
84
+ schemas: this.extractAll(filePath),
85
+ };
86
+ }
87
+ /**
88
+ * Gets the list of detected schema names in a file.
89
+ *
90
+ * @param filePath - Path to the TypeScript file
91
+ * @returns Array of schema names
92
+ */
93
+ getSchemaNames(filePath) {
94
+ return this.schemaDetector.getSchemaNames(this.getOrAddSourceFile(filePath));
95
+ }
96
+ /**
97
+ * Gets or adds a source file to the project.
98
+ */
99
+ getOrAddSourceFile(filePath) {
100
+ return this.project.getSourceFile(filePath) ?? this.project.addSourceFileAtPath(filePath);
101
+ }
102
+ /**
103
+ * Internal method to extract multiple schemas from a source file.
104
+ */
105
+ extractMultipleFromSourceFile(sourceFile, schemas) {
106
+ const results = [];
107
+ // Find and resolve imported schemas
108
+ const importedSchemas = this.importResolver.findImportedSchemas(sourceFile, this.project);
109
+ // Analyze getter fields for all schemas
110
+ const getterFieldMap = this.getterResolver.analyzeGetterFields(sourceFile);
111
+ // Build schema names set including imports
112
+ const schemaNames = new Set(schemas.map((s) => s.name));
113
+ for (const localName of importedSchemas.keys()) {
114
+ schemaNames.add(localName);
115
+ }
116
+ // Analyze cross-schema references
117
+ const referenceMap = this.referenceAnalyzer.analyzeReferences(sourceFile, schemaNames);
118
+ // Analyze union schema references
119
+ const unionReferenceMap = this.referenceAnalyzer.analyzeUnionReferences(sourceFile, schemaNames);
120
+ // Detect branded types
121
+ const brandMap = this.brandDetector.detectBrands(sourceFile, schemaNames);
122
+ // First pass: extract raw types for all schemas
123
+ const rawTypes = new Map();
124
+ // Extract types from imported schemas first
125
+ for (const [localName, importInfo] of importedSchemas) {
126
+ if (!importInfo.resolved)
127
+ continue;
128
+ const importedSourceFile = this.project.getSourceFile(importInfo.sourceFilePath);
129
+ if (!importedSourceFile)
130
+ continue;
131
+ try {
132
+ this.injectTemporaryTypes(importedSourceFile, importInfo.originalName);
133
+ const inputType = this.resolveType(importedSourceFile, "__TempInput");
134
+ const outputType = this.resolveType(importedSourceFile, "__TempOutput");
135
+ // Use local name as the key (how it's referenced in current file)
136
+ rawTypes.set(localName, {
137
+ input: inputType,
138
+ output: outputType,
139
+ isExported: false, // Imported schemas won't be re-exported
140
+ });
141
+ }
142
+ catch (error) {
143
+ logDebugError(`Failed to extract imported schema "${localName}"`, error);
144
+ }
145
+ finally {
146
+ this.cleanupTemporaryTypes(importedSourceFile);
147
+ }
148
+ }
149
+ // Extract types from local schemas
150
+ for (const schema of schemas) {
151
+ const { name: schemaName, explicitType, isExported } = schema;
152
+ if (explicitType) {
153
+ this.injectExplicitType(sourceFile, explicitType);
154
+ try {
155
+ const resolvedType = this.resolveType(sourceFile, "__TempExplicit");
156
+ rawTypes.set(schemaName, {
157
+ input: resolvedType,
158
+ output: resolvedType,
159
+ isExported,
160
+ });
161
+ }
162
+ finally {
163
+ this.cleanupExplicitType(sourceFile);
164
+ }
165
+ continue;
166
+ }
167
+ this.injectTemporaryTypes(sourceFile, schemaName);
168
+ try {
169
+ let inputType = this.resolveType(sourceFile, "__TempInput");
170
+ let outputType = this.resolveType(sourceFile, "__TempOutput");
171
+ // Resolve getter-based self-references
172
+ const getterFields = getterFieldMap.get(schemaName);
173
+ if (getterFields && this.getterResolver.hasSelfReferences(getterFields)) {
174
+ const inputTypeName = `${schemaName}Input`;
175
+ const outputTypeName = `${schemaName}Output`;
176
+ const originalInputType = inputType;
177
+ inputType = this.getterResolver.resolveAnyTypes(inputType, getterFields, inputTypeName);
178
+ if (outputType === "any") {
179
+ outputType = this.getterResolver.resolveAnyTypes(originalInputType, getterFields, outputTypeName);
180
+ }
181
+ else {
182
+ outputType = this.getterResolver.resolveAnyTypes(outputType, getterFields, outputTypeName);
183
+ }
184
+ }
185
+ rawTypes.set(schemaName, { input: inputType, output: outputType, isExported });
186
+ }
187
+ finally {
188
+ this.cleanupTemporaryTypes(sourceFile);
189
+ }
190
+ }
191
+ // Add imported schemas to results first (so they're defined before use)
192
+ for (const [localName] of importedSchemas) {
193
+ const raw = rawTypes.get(localName);
194
+ if (!raw)
195
+ continue;
196
+ results.push({
197
+ schemaName: localName,
198
+ input: raw.input,
199
+ output: raw.output,
200
+ isExported: false, // Imported schemas are not re-exported
201
+ });
202
+ }
203
+ // Second pass: replace cross-schema references with type names
204
+ for (const schema of schemas) {
205
+ const schemaName = schema.name;
206
+ const raw = rawTypes.get(schemaName);
207
+ if (!raw)
208
+ continue;
209
+ // Get brand information for this schema
210
+ const brands = brandMap.get(schemaName);
211
+ // Check if this schema is a union with member references
212
+ const unionRef = unionReferenceMap.get(schemaName);
213
+ if (unionRef && unionRef.memberSchemas.length > 0) {
214
+ // Only use named references for exported members; inline non-exported ones
215
+ const exportedMembers = unionRef.memberSchemas.filter((member) => {
216
+ const memberRaw = rawTypes.get(member);
217
+ return memberRaw?.isExported;
218
+ });
219
+ if (exportedMembers.length === unionRef.memberSchemas.length) {
220
+ // All members are exported, use named references
221
+ const inputMembers = unionRef.memberSchemas.map((member) => `${member}Input`).join(" | ");
222
+ const outputMembers = unionRef.memberSchemas
223
+ .map((member) => `${member}Output`)
224
+ .join(" | ");
225
+ results.push({
226
+ schemaName,
227
+ input: inputMembers,
228
+ output: outputMembers,
229
+ isExported: raw.isExported,
230
+ brands,
231
+ });
232
+ continue;
233
+ }
234
+ // Some members are non-exported; fall through to inline extraction
235
+ }
236
+ let { input, output } = raw;
237
+ const refs = referenceMap.get(schemaName) || [];
238
+ // Replace references to other schemas with type names
239
+ // Only replace references to exported schemas
240
+ for (const ref of refs) {
241
+ const refRaw = rawTypes.get(ref.refSchema);
242
+ if (!refRaw)
243
+ continue;
244
+ // Skip replacement if the referenced schema is not exported
245
+ // Non-exported schemas should remain inlined
246
+ if (!refRaw.isExported)
247
+ continue;
248
+ input = this.replaceSchemaReference(input, ref, refRaw.input, `${ref.refSchema}Input`);
249
+ output = this.replaceSchemaReference(output, ref, refRaw.output, `${ref.refSchema}Output`);
250
+ }
251
+ // For explicit types, replace self-references with typed names
252
+ if (schema.explicitType) {
253
+ // schema.explicitType already contains just the type name (e.g., "JsonValue")
254
+ const typeName = schema.explicitType;
255
+ // Only replace if the type name is a valid identifier (not a complex type)
256
+ if (this.isValidIdentifier(typeName)) {
257
+ // Escape special regex characters in the type name
258
+ const escapedTypeName = this.escapeRegExp(typeName);
259
+ // Replace type name with self-referencing Input/Output types
260
+ const typeNamePattern = new RegExp(`\\b${escapedTypeName}\\b`, "g");
261
+ input = input.replace(typeNamePattern, `${schemaName}Input`);
262
+ output = output.replace(typeNamePattern, `${schemaName}Output`);
263
+ }
264
+ }
265
+ results.push({
266
+ schemaName,
267
+ input,
268
+ output,
269
+ isExported: raw.isExported,
270
+ brands,
271
+ });
272
+ }
273
+ return results;
274
+ }
275
+ /**
276
+ * Replaces an inline schema reference with a type name.
277
+ */
278
+ replaceSchemaReference(typeStr, ref, refTypeStr, refTypeName) {
279
+ const { fieldPath, isArray, isRecord } = ref;
280
+ // Build the replacement type
281
+ let replacement = refTypeName;
282
+ if (isArray) {
283
+ replacement = `${refTypeName}[]`;
284
+ }
285
+ // Find the field and replace its value
286
+ const fieldPatterns = [`${fieldPath}: `, `${fieldPath}?: `];
287
+ for (const pattern of fieldPatterns) {
288
+ const idx = typeStr.indexOf(pattern);
289
+ if (idx === -1)
290
+ continue;
291
+ const valueStart = idx + pattern.length;
292
+ // Find the end of the field value by tracking braces/brackets
293
+ let depth = 0;
294
+ let endIdx = valueStart;
295
+ let inString = false;
296
+ while (endIdx < typeStr.length) {
297
+ const char = typeStr[endIdx];
298
+ if (char === '"' || char === "'") {
299
+ inString = !inString;
300
+ }
301
+ else if (!inString) {
302
+ if (char === "{" || char === "[" || char === "(") {
303
+ depth++;
304
+ }
305
+ else if (char === "}" || char === "]" || char === ")") {
306
+ if (depth === 0)
307
+ break;
308
+ depth--;
309
+ }
310
+ else if (char === ";" && depth === 0) {
311
+ break;
312
+ }
313
+ }
314
+ endIdx++;
315
+ }
316
+ // Extract the current value
317
+ const currentValue = typeStr.substring(valueStart, endIdx).trim();
318
+ // Check if this looks like an expanded type that should be replaced
319
+ // Handle: { ... }, readonly { ... }[], SomeType, etc.
320
+ const valueToCheck = currentValue
321
+ .replace(/^readonly\s+/, "")
322
+ .replace(/\[\]$/, "")
323
+ .trim();
324
+ if (valueToCheck.startsWith("{") ||
325
+ valueToCheck === refTypeStr ||
326
+ currentValue.includes("[x: string]:")) {
327
+ // Handle record type
328
+ if (isRecord) {
329
+ replacement = `{ [x: string]: ${refTypeName} }`;
330
+ }
331
+ // Preserve readonly prefix for arrays
332
+ if (isArray && currentValue.startsWith("readonly ")) {
333
+ replacement = `readonly ${replacement}`;
334
+ }
335
+ return typeStr.substring(0, valueStart) + replacement + typeStr.substring(endIdx);
336
+ }
337
+ }
338
+ return typeStr;
339
+ }
340
+ /**
341
+ * Injects temporary type for explicit type (without normalization for circular refs).
342
+ */
343
+ injectExplicitType(sourceFile, explicitType) {
344
+ // Don't normalize - use the type directly to preserve circular references
345
+ sourceFile.addStatements([`type __TempExplicit = ${explicitType};`]);
346
+ }
347
+ /**
348
+ * Cleans up explicit type temporaries.
349
+ */
350
+ cleanupExplicitType(sourceFile) {
351
+ const typeAlias = sourceFile.getTypeAlias("__TempExplicit");
352
+ if (typeAlias) {
353
+ typeAlias.remove();
354
+ }
355
+ }
356
+ /**
357
+ * Creates a ts-morph Project with appropriate compiler options.
358
+ */
359
+ createProject(tsconfigPath) {
360
+ if (tsconfigPath) {
361
+ return new Project({
362
+ tsConfigFilePath: tsconfigPath,
363
+ skipAddingFilesFromTsConfig: true,
364
+ });
365
+ }
366
+ return new Project({
367
+ compilerOptions: {
368
+ strict: true,
369
+ target: ts.ScriptTarget.ESNext,
370
+ module: ts.ModuleKind.ESNext,
371
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
372
+ esModuleInterop: true,
373
+ skipLibCheck: true,
374
+ },
375
+ });
376
+ }
377
+ /**
378
+ * Injects the Normalize type and temporary type aliases into the source file.
379
+ * These are added in-memory only and never saved to disk.
380
+ */
381
+ injectTemporaryTypes(sourceFile, schemaName) {
382
+ // Add the Normalize type definition and temporary type aliases at the end of the file
383
+ sourceFile.addStatements([
384
+ NORMALIZE_TYPE_DEFINITION,
385
+ createTempTypeAlias(schemaName, "input"),
386
+ createTempTypeAlias(schemaName, "output"),
387
+ ]);
388
+ }
389
+ /**
390
+ * Resolves a type alias and returns its fully expanded string representation.
391
+ */
392
+ resolveType(sourceFile, typeName) {
393
+ const typeAlias = sourceFile.getTypeAlias(typeName);
394
+ if (!typeAlias) {
395
+ throw new Error(`Failed to find type alias: ${typeName}`);
396
+ }
397
+ const type = typeAlias.getType();
398
+ // Use TypeFormatFlags to get the fully expanded type without truncation
399
+ // Don't use UseAliasDefinedOutsideCurrentScope to expand enum types
400
+ const formatFlags = TypeFormatFlags.NoTruncation | TypeFormatFlags.InTypeAlias;
401
+ let rawType = type.getText(typeAlias, formatFlags);
402
+ // Remove trailing spaces from each line (ts-morph 27+ may add them)
403
+ rawType = rawType
404
+ .split("\n")
405
+ .map((line) => line.trimEnd())
406
+ .join("\n");
407
+ // Expand enum types: if the type is a single identifier, check if it's an enum
408
+ if (/^[A-Z][a-zA-Z0-9]*$/.test(rawType)) {
409
+ const enumDecl = sourceFile.getEnum(rawType);
410
+ if (enumDecl) {
411
+ // Extract enum values
412
+ const members = enumDecl.getMembers();
413
+ const values = members
414
+ .map((member) => {
415
+ const value = member.getValue();
416
+ if (typeof value === "string") {
417
+ return `"${value}"`;
418
+ }
419
+ else if (typeof value === "number") {
420
+ return value.toString();
421
+ }
422
+ return null;
423
+ })
424
+ .filter(Boolean);
425
+ if (values.length > 0) {
426
+ rawType = values.join(" | ");
427
+ }
428
+ }
429
+ }
430
+ // Post-process to simplify Zod internal function types
431
+ return this.simplifyZodFunctionTypes(rawType);
432
+ }
433
+ /**
434
+ * Simplifies Zod internal function types to Function.
435
+ * Replaces patterns like z.core.$InferInnerFunctionType<...> with Function.
436
+ * Handles nested type parameters properly.
437
+ */
438
+ simplifyZodFunctionTypes(typeStr) {
439
+ // Pattern prefixes for Zod internal function types
440
+ const zodFunctionPrefixes = [
441
+ "z.core.$InferInnerFunctionType<",
442
+ "z.core.$InferOuterFunctionType<",
443
+ ];
444
+ let result = typeStr;
445
+ let modified = true;
446
+ // Loop until no more replacements are made (handles nested cases)
447
+ while (modified) {
448
+ modified = false;
449
+ for (const prefix of zodFunctionPrefixes) {
450
+ const idx = result.indexOf(prefix);
451
+ if (idx === -1)
452
+ continue;
453
+ // Find the matching closing bracket using bracket counting
454
+ const startIdx = idx + prefix.length;
455
+ let depth = 1;
456
+ let endIdx = startIdx;
457
+ while (endIdx < result.length && depth > 0) {
458
+ const char = result[endIdx];
459
+ if (char === "<") {
460
+ depth++;
461
+ }
462
+ else if (char === ">") {
463
+ depth--;
464
+ }
465
+ endIdx++;
466
+ }
467
+ if (depth === 0) {
468
+ // Replace the entire pattern with "Function"
469
+ result = result.substring(0, idx) + "Function" + result.substring(endIdx);
470
+ modified = true;
471
+ break; // Start over to handle any new matches
472
+ }
473
+ // If depth > 0, the bracket is unbalanced - skip this match
474
+ }
475
+ }
476
+ return result;
477
+ }
478
+ /**
479
+ * Removes the temporary types that were injected during extraction.
480
+ * This ensures the original file remains unmodified.
481
+ */
482
+ cleanupTemporaryTypes(sourceFile) {
483
+ for (const name of TEMP_TYPE_NAMES) {
484
+ const typeAlias = sourceFile.getTypeAlias(name);
485
+ if (typeAlias) {
486
+ typeAlias.remove();
487
+ }
488
+ }
489
+ }
490
+ /**
491
+ * Escapes special characters in a string for use in a RegExp.
492
+ */
493
+ escapeRegExp(str) {
494
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
495
+ }
496
+ /**
497
+ * Checks if a string is a valid TypeScript identifier.
498
+ * Used to determine if a type name can be safely used in regex replacement.
499
+ */
500
+ isValidIdentifier(str) {
501
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str);
502
+ }
503
+ }
504
+ //# sourceMappingURL=extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../src/core/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,eAAe,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAA4B,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAkB5C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAU;IACjB,cAAc,CAAiB;IAC/B,cAAc,CAAiB;IAC/B,iBAAiB,CAA0B;IAC3C,cAAc,CAAiB;IAC/B,aAAa,CAAgB;IAErC;;;;;OAKG;IACH,YAA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