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,158 @@
1
+ import { join } from "pathe";
2
+ import { SchemaDetector } from "./schema-detector.js";
3
+ import { logDebugError } from "./logger.js";
4
+ /**
5
+ * Resolves imported schemas from other files.
6
+ */
7
+ export class ImportResolver {
8
+ schemaDetector;
9
+ constructor() {
10
+ this.schemaDetector = new SchemaDetector();
11
+ }
12
+ /**
13
+ * Finds all imported schemas in a source file.
14
+ *
15
+ * @param sourceFile - The source file to analyze
16
+ * @param project - The ts-morph project for module resolution
17
+ * @returns Map of local names to imported schema info
18
+ */
19
+ findImportedSchemas(sourceFile, project) {
20
+ const result = new Map();
21
+ const imports = sourceFile.getImportDeclarations();
22
+ for (const importDecl of imports) {
23
+ const moduleSpecifier = importDecl.getModuleSpecifierValue();
24
+ // Skip node_modules imports
25
+ if (!moduleSpecifier.startsWith(".") && !moduleSpecifier.startsWith("/")) {
26
+ continue;
27
+ }
28
+ // Resolve the module to a source file
29
+ const resolvedSourceFile = this.resolveImportedFile(importDecl, sourceFile, project);
30
+ if (!resolvedSourceFile) {
31
+ continue;
32
+ }
33
+ // Check named imports
34
+ const namedImports = importDecl.getNamedImports();
35
+ for (const namedImport of namedImports) {
36
+ const importedName = namedImport.getName();
37
+ const localName = namedImport.getAliasNode()?.getText() || importedName;
38
+ // Find the actual source file containing the schema definition
39
+ // This handles re-exports from index.ts files
40
+ const actualSource = this.findSchemaSource(resolvedSourceFile, importedName, project);
41
+ if (actualSource) {
42
+ result.set(localName, {
43
+ localName,
44
+ originalName: actualSource.schemaName,
45
+ sourceFilePath: actualSource.sourceFile.getFilePath(),
46
+ resolved: true,
47
+ });
48
+ }
49
+ }
50
+ }
51
+ return result;
52
+ }
53
+ /**
54
+ * Finds the actual source file containing a schema definition.
55
+ * Follows re-exports (export * from "./other") to find the original.
56
+ */
57
+ findSchemaSource(sourceFile, schemaName, project, visited = new Set()) {
58
+ const filePath = sourceFile.getFilePath();
59
+ // Prevent infinite loops
60
+ if (visited.has(filePath)) {
61
+ return undefined;
62
+ }
63
+ visited.add(filePath);
64
+ // Check if the schema is defined directly in this file
65
+ const schemas = this.schemaDetector.detectExportedSchemas(sourceFile);
66
+ if (schemas.some((s) => s.name === schemaName)) {
67
+ return { sourceFile, schemaName };
68
+ }
69
+ // Check export declarations for re-exports
70
+ const exportDecls = sourceFile.getExportDeclarations();
71
+ for (const exportDecl of exportDecls) {
72
+ const moduleSpecifier = exportDecl.getModuleSpecifierValue();
73
+ if (!moduleSpecifier)
74
+ continue;
75
+ // Check if this is "export * from" or "export { name } from"
76
+ const namedExports = exportDecl.getNamedExports();
77
+ if (namedExports.length === 0) {
78
+ // This is "export * from './module'" - follow it
79
+ const reExportedFile = this.resolveModuleSpecifier(sourceFile, moduleSpecifier, project);
80
+ if (reExportedFile) {
81
+ const found = this.findSchemaSource(reExportedFile, schemaName, project, visited);
82
+ if (found) {
83
+ return found;
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ // Check named exports
89
+ for (const namedExport of namedExports) {
90
+ const exportedName = namedExport.getAliasNode()?.getText() || namedExport.getName();
91
+ if (exportedName === schemaName) {
92
+ const originalName = namedExport.getName();
93
+ const reExportedFile = this.resolveModuleSpecifier(sourceFile, moduleSpecifier, project);
94
+ if (reExportedFile) {
95
+ return this.findSchemaSource(reExportedFile, originalName, project, visited);
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return undefined;
102
+ }
103
+ /**
104
+ * Resolves a module specifier to a source file.
105
+ */
106
+ resolveModuleSpecifier(fromFile, moduleSpecifier, project) {
107
+ const sourceDir = fromFile.getDirectoryPath();
108
+ return this.resolveFromPossiblePaths(sourceDir, moduleSpecifier, project);
109
+ }
110
+ /**
111
+ * Generates possible file paths for a module specifier and resolves to a source file.
112
+ */
113
+ resolveFromPossiblePaths(sourceDir, moduleSpecifier, project) {
114
+ const possiblePaths = [
115
+ join(sourceDir, `${moduleSpecifier}.ts`),
116
+ join(sourceDir, moduleSpecifier, "index.ts"),
117
+ join(sourceDir, `${moduleSpecifier}.js`),
118
+ join(sourceDir, moduleSpecifier, "index.js"),
119
+ ];
120
+ for (const possiblePath of possiblePaths) {
121
+ let resolved = project.getSourceFile(possiblePath);
122
+ if (!resolved) {
123
+ try {
124
+ resolved = project.addSourceFileAtPathIfExists(possiblePath);
125
+ }
126
+ catch (error) {
127
+ logDebugError(`Failed to add source file at ${possiblePath}`, error);
128
+ continue;
129
+ }
130
+ }
131
+ if (resolved) {
132
+ return resolved;
133
+ }
134
+ }
135
+ return undefined;
136
+ }
137
+ /**
138
+ * Resolves an import declaration to its source file.
139
+ */
140
+ resolveImportedFile(importDecl, sourceFile, project) {
141
+ const moduleSpecifier = importDecl.getModuleSpecifierValue();
142
+ try {
143
+ // Get the module specifier source file
144
+ const moduleSourceFile = importDecl.getModuleSpecifierSourceFile();
145
+ if (moduleSourceFile) {
146
+ return moduleSourceFile;
147
+ }
148
+ // Try to resolve manually for index.ts patterns
149
+ const sourceDir = sourceFile.getDirectoryPath();
150
+ return this.resolveFromPossiblePaths(sourceDir, moduleSpecifier, project);
151
+ }
152
+ catch (error) {
153
+ logDebugError(`Module resolution failed for ${moduleSpecifier}`, error);
154
+ }
155
+ return undefined;
156
+ }
157
+ }
158
+ //# sourceMappingURL=import-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-resolver.js","sourceRoot":"","sources":["../../src/core/import-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqB5C;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,cAAc,CAAiB;IAEvC;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,UAAsB,EAAE,OAAgB;QAC1D,MAAM,MAAM,GAAsB,IAAI,GAAG,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;QAEnD,KAAK,MAA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2BAA2B,CAAC,YAAY,CAAC,CAAC;gBAC/D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,aAAa,CAAC,gCAAgC,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC;oBACrE,SAAS;gBACX,CAAC;YACH,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,mBAAmB,CACzB,UAA6B,EAC7B,UAAsB,EACtB,OAAgB;QAEhB,MAAM,eAAe,GAAG,UAAU,CAAC,uBAAuB,EAAE,CAAC;QAE7D,IAAI,CAAC;YACH,uCAAuC;YACvC,MAAM,gBAAgB,GAAG,UAAU,CAAC,4BAA4B,EAAE,CAAC;YAEnE,IAAI,gBAAgB,EAAE,CAAC;gBACrB,OAAO,gBAAgB,CAAC;YAC1B,CAAC;YAED,gDAAgD;YAChD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC,wBAAwB,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,gCAAgC,eAAe,EAAE,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export { NORMALIZE_TYPE_DEFINITION, createTempTypeAlias, TEMP_TYPE_NAMES } from "./normalizer.js";
2
+ export { ZodTypeExtractor, type ExtractOptions } from "./extractor.js";
3
+ export { formatResult, formatInputOnly, formatOutputOnly, formatAsDeclaration, formatMultipleAsDeclarations, generateDeclarationFile, type PrintOptions, } from "./type-printer.js";
4
+ export { SchemaDetector } from "./schema-detector.js";
5
+ export { NameMapper, createNameMapper } from "./name-mapper.js";
6
+ export { FileResolver } from "./file-resolver.js";
7
+ export { DescriptionExtractor } from "./description-extractor.js";
8
+ export { ZinferError, NoSchemasFoundError, NoFilesMatchedError, InvalidOptionError, formatError, } from "./errors.js";
9
+ export { setVerbose, logVerbose, logDebugError, logProgress } from "./logger.js";
10
+ export { ConfigLoader, defineConfig, type ZinferConfig, type ConfigLoadResult, } from "./config-loader.js";
11
+ export { BrandDetector, type SchemaBrandMap } from "./brand-detector.js";
12
+ export { TestGenerator, generateTypeTests, generateImportPrefix, createTestSchemaInfo, toPascalCase, type TestSchemaInfo, type TestFileInfo, type TestGeneratorOptions, } from "./test-generator.js";
13
+ export type { ExtractResult, FileExtractResult, DetectedSchema, MappedTypeName, NameMappingOptions, OutputOptions, GeneratedFile, DeclarationOptions, FieldDescription, BrandInfo, } from "./types.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElG,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,4BAA4B,EAC5B,uBAAuB,EACvB,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { NORMALIZE_TYPE_DEFINITION, createTempTypeAlias, TEMP_TYPE_NAMES } from "./normalizer.js";
2
+ export { ZodTypeExtractor } from "./extractor.js";
3
+ export { formatResult, formatInputOnly, formatOutputOnly, formatAsDeclaration, formatMultipleAsDeclarations, generateDeclarationFile, } from "./type-printer.js";
4
+ export { SchemaDetector } from "./schema-detector.js";
5
+ export { NameMapper, createNameMapper } from "./name-mapper.js";
6
+ export { FileResolver } from "./file-resolver.js";
7
+ export { DescriptionExtractor } from "./description-extractor.js";
8
+ export { ZinferError, NoSchemasFoundError, NoFilesMatchedError, InvalidOptionError, formatError, } from "./errors.js";
9
+ export { setVerbose, logVerbose, logDebugError, logProgress } from "./logger.js";
10
+ export { ConfigLoader, defineConfig, } from "./config-loader.js";
11
+ export { BrandDetector } from "./brand-detector.js";
12
+ export { TestGenerator, generateTypeTests, generateImportPrefix, createTestSchemaInfo, toPascalCase, } from "./test-generator.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElG,OAAO,EAAE,gBAAgB,EAAuB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,OAAO,EACL,YAAY,EACZ,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,GAIb,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Simple logger for zinfer with verbose mode support.
3
+ */
4
+ /**
5
+ * Enables or disables verbose logging.
6
+ */
7
+ export declare function setVerbose(enabled: boolean): void;
8
+ /**
9
+ * Logs a verbose message (only when verbose mode is enabled).
10
+ */
11
+ export declare function logVerbose(message: string, ...args: unknown[]): void;
12
+ /**
13
+ * Logs a debug message about a non-critical error (only when verbose mode is enabled).
14
+ */
15
+ export declare function logDebugError(context: string, error: unknown): void;
16
+ /**
17
+ * Logs progress information (only when verbose mode is enabled).
18
+ */
19
+ export declare function logProgress(current: number, total: number, message: string): void;
20
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAIpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAKnE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIjF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Simple logger for zinfer with verbose mode support.
3
+ */
4
+ let verboseEnabled = false;
5
+ /**
6
+ * Enables or disables verbose logging.
7
+ */
8
+ export function setVerbose(enabled) {
9
+ verboseEnabled = enabled;
10
+ }
11
+ /**
12
+ * Logs a verbose message (only when verbose mode is enabled).
13
+ */
14
+ export function logVerbose(message, ...args) {
15
+ if (verboseEnabled) {
16
+ console.log(`[verbose] ${message}`, ...args);
17
+ }
18
+ }
19
+ /**
20
+ * Logs a debug message about a non-critical error (only when verbose mode is enabled).
21
+ */
22
+ export function logDebugError(context, error) {
23
+ if (verboseEnabled) {
24
+ const errorMessage = error instanceof Error ? error.message : String(error);
25
+ console.log(`[verbose] ${context}: ${errorMessage}`);
26
+ }
27
+ }
28
+ /**
29
+ * Logs progress information (only when verbose mode is enabled).
30
+ */
31
+ export function logProgress(current, total, message) {
32
+ if (verboseEnabled) {
33
+ console.log(`[${current}/${total}] ${message}`);
34
+ }
35
+ }
36
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,GAAG,IAAe;IAC5D,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,KAAc;IAC3D,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,KAAK,YAAY,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAa,EAAE,OAAe;IACzE,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { NameMappingOptions, MappedTypeName } from "./types.js";
2
+ /**
3
+ * Maps Zod schema names to TypeScript type names.
4
+ */
5
+ export declare class NameMapper {
6
+ private options;
7
+ /**
8
+ * Creates a new NameMapper instance.
9
+ *
10
+ * @param options - Name mapping options
11
+ */
12
+ constructor(options?: NameMappingOptions);
13
+ /**
14
+ * Maps a schema name to input, output, and unified type names.
15
+ *
16
+ * @param schemaName - The original schema name (e.g., "UserSchema")
17
+ * @returns The mapped type names
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const mapper = new NameMapper({ removeSuffix: "Schema" });
22
+ * mapper.map("UserSchema");
23
+ * // Returns: { originalName: "UserSchema", inputName: "UserInput", outputName: "UserOutput", unifiedName: "User" }
24
+ * ```
25
+ */
26
+ map(schemaName: string): MappedTypeName;
27
+ /**
28
+ * Creates the full mapped names object from a base name.
29
+ */
30
+ private createMappedNames;
31
+ /**
32
+ * Creates a mapping function for use with formatMultipleAsDeclarations.
33
+ *
34
+ * @returns A function that maps schema names to type names
35
+ */
36
+ createMapFunction(): (schemaName: string) => MappedTypeName;
37
+ }
38
+ /**
39
+ * Creates a simple name mapper with the given options.
40
+ *
41
+ * @param options - Name mapping options
42
+ * @returns A function that maps schema names to type names
43
+ */
44
+ export declare function createNameMapper(options?: NameMappingOptions): (schemaName: string) => MappedTypeName;
45
+ //# sourceMappingURL=name-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-mapper.d.ts","sourceRoot":"","sources":["../../src/core/name-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUrE;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAqB;IAEpC;;;;OAIG;gBACS,OAAO,GAAE,kBAAuB;IAO5C;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc;IAgBvC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;;;OAIG;IACH,iBAAiB,IAAI,CAAC,UAAU,EAAE,MAAM,KAAK,cAAc;CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,kBAAuB,GAC/B,CAAC,UAAU,EAAE,MAAM,KAAK,cAAc,CAGxC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Default options for name mapping.
3
+ */
4
+ const DEFAULT_OPTIONS = {
5
+ inputSuffix: "Input",
6
+ outputSuffix: "Output",
7
+ };
8
+ /**
9
+ * Maps Zod schema names to TypeScript type names.
10
+ */
11
+ export class NameMapper {
12
+ options;
13
+ /**
14
+ * Creates a new NameMapper instance.
15
+ *
16
+ * @param options - Name mapping options
17
+ */
18
+ constructor(options = {}) {
19
+ this.options = {
20
+ ...DEFAULT_OPTIONS,
21
+ ...options,
22
+ };
23
+ }
24
+ /**
25
+ * Maps a schema name to input, output, and unified type names.
26
+ *
27
+ * @param schemaName - The original schema name (e.g., "UserSchema")
28
+ * @returns The mapped type names
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const mapper = new NameMapper({ removeSuffix: "Schema" });
33
+ * mapper.map("UserSchema");
34
+ * // Returns: { originalName: "UserSchema", inputName: "UserInput", outputName: "UserOutput", unifiedName: "User" }
35
+ * ```
36
+ */
37
+ map(schemaName) {
38
+ // Check for custom mapping first
39
+ if (this.options.customMap?.[schemaName]) {
40
+ const baseName = this.options.customMap[schemaName];
41
+ return this.createMappedNames(schemaName, baseName);
42
+ }
43
+ // Remove suffix if specified
44
+ let baseName = schemaName;
45
+ if (this.options.removeSuffix && schemaName.endsWith(this.options.removeSuffix)) {
46
+ baseName = schemaName.slice(0, -this.options.removeSuffix.length);
47
+ }
48
+ return this.createMappedNames(schemaName, baseName);
49
+ }
50
+ /**
51
+ * Creates the full mapped names object from a base name.
52
+ */
53
+ createMappedNames(originalName, baseName) {
54
+ const inputSuffix = this.options.inputSuffix ?? DEFAULT_OPTIONS.inputSuffix;
55
+ const outputSuffix = this.options.outputSuffix ?? DEFAULT_OPTIONS.outputSuffix;
56
+ return {
57
+ originalName,
58
+ inputName: baseName + inputSuffix,
59
+ outputName: baseName + outputSuffix,
60
+ unifiedName: baseName,
61
+ };
62
+ }
63
+ /**
64
+ * Creates a mapping function for use with formatMultipleAsDeclarations.
65
+ *
66
+ * @returns A function that maps schema names to type names
67
+ */
68
+ createMapFunction() {
69
+ return this.map.bind(this);
70
+ }
71
+ }
72
+ /**
73
+ * Creates a simple name mapper with the given options.
74
+ *
75
+ * @param options - Name mapping options
76
+ * @returns A function that maps schema names to type names
77
+ */
78
+ export function createNameMapper(options = {}) {
79
+ const mapper = new NameMapper(options);
80
+ return (schemaName) => mapper.map(schemaName);
81
+ }
82
+ //# sourceMappingURL=name-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-mapper.js","sourceRoot":"","sources":["../../src/core/name-mapper.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,eAAe,GAAqE;IACxF,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,QAAQ;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,OAAO,CAAqB;IAEpC;;;;OAIG;IACH,YAAY,UAA8B,EAAE;QAC1C,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,eAAe;YAClB,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,UAAkB;QACpB,iCAAiC;QACjC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC;QAED,6BAA6B;QAC7B,IAAI,QAAQ,GAAG,UAAU,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAChF,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,YAAoB,EAAE,QAAgB;QAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,eAAe,CAAC,WAAW,CAAC;QAC5E,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,eAAe,CAAC,YAAY,CAAC;QAE/E,OAAO;YACL,YAAY;YACZ,SAAS,EAAE,QAAQ,GAAG,WAAW;YACjC,UAAU,EAAE,QAAQ,GAAG,YAAY;YACnC,WAAW,EAAE,QAAQ;SACtB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,UAA8B,EAAE;IAEhC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,UAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Normalize type definition for expanding utility types, intersections, and conditional types.
3
+ *
4
+ * This type template is injected in-memory to expand complex type structures
5
+ * into their fully evaluated form.
6
+ *
7
+ * Built-in types like Date, Array, Map, Set, Promise, Function, etc. are preserved without expansion.
8
+ * Symbol-keyed properties (like Zod's [BRAND]) are filtered out from object types.
9
+ */
10
+ export declare const NORMALIZE_TYPE_DEFINITION = "\ntype __Normalize<T> =\n T extends Date | RegExp | Error | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Function\n ? T\n : T extends (...args: infer A) => infer R\n ? (...args: __Normalize<A>) => __Normalize<R>\n : T extends (infer U)[]\n ? __Normalize<U>[]\n : T extends readonly (infer U)[]\n ? readonly __Normalize<U>[]\n : T extends string\n ? T extends object ? string : T\n : T extends number\n ? T extends object ? number : T\n : T extends boolean\n ? T extends object ? boolean : T\n : T extends bigint\n ? T extends object ? bigint : T\n : T extends object\n ? T extends infer O\n ? { [K in keyof O as K extends symbol ? never : K]: __Normalize<O[K]> }\n : never\n : T;\n";
11
+ /**
12
+ * Creates a temporary type alias for extracting input or output type from a Zod schema.
13
+ *
14
+ * @param schemaName - The name of the exported Zod schema (e.g., "UserSchema")
15
+ * @param typeKind - Either 'input' or 'output' to specify which type to extract
16
+ * @returns A TypeScript type alias string to be injected in-memory
17
+ */
18
+ export declare function createTempTypeAlias(schemaName: string, typeKind: "input" | "output"): string;
19
+ /**
20
+ * Names of temporary types that are injected during extraction.
21
+ * These should be cleaned up after extraction is complete.
22
+ */
23
+ export declare const TEMP_TYPE_NAMES: readonly ["__Normalize", "__TempInput", "__TempOutput"];
24
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/core/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,+7BAuBrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAG5F;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,yDAA0D,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Normalize type definition for expanding utility types, intersections, and conditional types.
3
+ *
4
+ * This type template is injected in-memory to expand complex type structures
5
+ * into their fully evaluated form.
6
+ *
7
+ * Built-in types like Date, Array, Map, Set, Promise, Function, etc. are preserved without expansion.
8
+ * Symbol-keyed properties (like Zod's [BRAND]) are filtered out from object types.
9
+ */
10
+ export const NORMALIZE_TYPE_DEFINITION = `
11
+ type __Normalize<T> =
12
+ T extends Date | RegExp | Error | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Promise<any> | Function
13
+ ? T
14
+ : T extends (...args: infer A) => infer R
15
+ ? (...args: __Normalize<A>) => __Normalize<R>
16
+ : T extends (infer U)[]
17
+ ? __Normalize<U>[]
18
+ : T extends readonly (infer U)[]
19
+ ? readonly __Normalize<U>[]
20
+ : T extends string
21
+ ? T extends object ? string : T
22
+ : T extends number
23
+ ? T extends object ? number : T
24
+ : T extends boolean
25
+ ? T extends object ? boolean : T
26
+ : T extends bigint
27
+ ? T extends object ? bigint : T
28
+ : T extends object
29
+ ? T extends infer O
30
+ ? { [K in keyof O as K extends symbol ? never : K]: __Normalize<O[K]> }
31
+ : never
32
+ : T;
33
+ `;
34
+ /**
35
+ * Creates a temporary type alias for extracting input or output type from a Zod schema.
36
+ *
37
+ * @param schemaName - The name of the exported Zod schema (e.g., "UserSchema")
38
+ * @param typeKind - Either 'input' or 'output' to specify which type to extract
39
+ * @returns A TypeScript type alias string to be injected in-memory
40
+ */
41
+ export function createTempTypeAlias(schemaName, typeKind) {
42
+ const typeName = typeKind === "input" ? "__TempInput" : "__TempOutput";
43
+ return `type ${typeName} = __Normalize<z.${typeKind}<typeof ${schemaName}>>;`;
44
+ }
45
+ /**
46
+ * Names of temporary types that are injected during extraction.
47
+ * These should be cleaned up after extraction is complete.
48
+ */
49
+ export const TEMP_TYPE_NAMES = ["__Normalize", "__TempInput", "__TempOutput"];
50
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../../src/core/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuBxC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAkB,EAAE,QAA4B;IAClF,MAAM,QAAQ,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC;IACvE,OAAO,QAAQ,QAAQ,oBAAoB,QAAQ,WAAW,UAAU,KAAK,CAAC;AAChF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,cAAc,CAAU,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { SourceFile } from "ts-morph";
2
+ import type { DetectedSchema } from "./types.js";
3
+ /**
4
+ * Detects Zod schemas in TypeScript source files.
5
+ */
6
+ export declare class SchemaDetector {
7
+ /**
8
+ * Detects all Zod schemas in a source file.
9
+ *
10
+ * @param sourceFile - The ts-morph SourceFile to analyze
11
+ * @returns Array of detected schema information (including non-exported schemas)
12
+ */
13
+ detectExportedSchemas(sourceFile: SourceFile): DetectedSchema[];
14
+ /**
15
+ * Known Zod schema builder functions that follow the z. prefix.
16
+ */
17
+ private static readonly ZOD_SCHEMA_BUILDERS;
18
+ /**
19
+ * Checks if a variable declaration is a Zod schema.
20
+ *
21
+ * @param declaration - The variable declaration to check
22
+ * @returns true if the declaration is a Zod schema
23
+ */
24
+ private isZodSchema;
25
+ /**
26
+ * Gets all schema names from a source file.
27
+ *
28
+ * @param sourceFile - The ts-morph SourceFile to analyze
29
+ * @returns Array of schema names
30
+ */
31
+ getSchemaNames(sourceFile: SourceFile): string[];
32
+ /**
33
+ * Extracts explicit type annotation from z.ZodType<T> or z.ZodSchema<T>.
34
+ *
35
+ * @param declaration - The variable declaration to check
36
+ * @returns The explicit type string if found, undefined otherwise
37
+ */
38
+ private extractExplicitType;
39
+ /**
40
+ * Extracts the first type parameter from a generic type string.
41
+ * Handles nested brackets properly.
42
+ *
43
+ * @param typeText - The full type text (e.g., "ZodType<{ a: string }, ZodTypeDef>")
44
+ * @param startIdx - The index after the opening "<"
45
+ * @returns The first type parameter, or undefined if parsing fails
46
+ */
47
+ private extractFirstTypeParameter;
48
+ }
49
+ //# sourceMappingURL=schema-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-detector.d.ts","sourceRoot":"","sources":["../../src/core/schema-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;OAKG;IACH,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,EAAE;IAiE/D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAwCxC;IAEH;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAyEnB;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE;IAIhD;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAmC3B;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;CAyClC"}