@atomic-ehr/codegen 0.0.1-canary.20251006092200.fdb4a88 → 0.0.1-canary.20251006094042.7f0be72

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 (90) hide show
  1. package/dist/cli/index.js +45 -124
  2. package/dist/index.d.ts +2130 -62
  3. package/dist/index.js +5865 -84
  4. package/dist/index.js.map +1 -0
  5. package/package.json +3 -7
  6. package/dist/api/builder.d.ts +0 -154
  7. package/dist/api/builder.js +0 -341
  8. package/dist/api/generators/base/BaseGenerator.d.ts +0 -186
  9. package/dist/api/generators/base/BaseGenerator.js +0 -565
  10. package/dist/api/generators/base/FileManager.d.ts +0 -88
  11. package/dist/api/generators/base/FileManager.js +0 -202
  12. package/dist/api/generators/base/PythonTypeMapper.d.ts +0 -16
  13. package/dist/api/generators/base/PythonTypeMapper.js +0 -71
  14. package/dist/api/generators/base/TemplateEngine.d.ts +0 -126
  15. package/dist/api/generators/base/TemplateEngine.js +0 -133
  16. package/dist/api/generators/base/TypeMapper.d.ts +0 -129
  17. package/dist/api/generators/base/TypeMapper.js +0 -153
  18. package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +0 -51
  19. package/dist/api/generators/base/TypeScriptTypeMapper.js +0 -232
  20. package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +0 -99
  21. package/dist/api/generators/base/builders/DirectoryBuilder.js +0 -215
  22. package/dist/api/generators/base/builders/FileBuilder.d.ts +0 -160
  23. package/dist/api/generators/base/builders/FileBuilder.js +0 -406
  24. package/dist/api/generators/base/builders/IndexBuilder.d.ts +0 -126
  25. package/dist/api/generators/base/builders/IndexBuilder.js +0 -290
  26. package/dist/api/generators/base/enhanced-errors.d.ts +0 -84
  27. package/dist/api/generators/base/enhanced-errors.js +0 -259
  28. package/dist/api/generators/base/error-handler.d.ts +0 -89
  29. package/dist/api/generators/base/error-handler.js +0 -243
  30. package/dist/api/generators/base/errors.d.ts +0 -251
  31. package/dist/api/generators/base/errors.js +0 -692
  32. package/dist/api/generators/base/index.d.ts +0 -99
  33. package/dist/api/generators/base/index.js +0 -160
  34. package/dist/api/generators/base/types.d.ts +0 -433
  35. package/dist/api/generators/base/types.js +0 -12
  36. package/dist/api/generators/types.d.ts +0 -53
  37. package/dist/api/generators/types.js +0 -4
  38. package/dist/api/generators/typescript.d.ts +0 -190
  39. package/dist/api/generators/typescript.js +0 -819
  40. package/dist/api/index.d.ts +0 -51
  41. package/dist/api/index.js +0 -50
  42. package/dist/cli/commands/generate/typescript.d.ts +0 -10
  43. package/dist/cli/commands/generate/typescript.js +0 -52
  44. package/dist/cli/commands/generate.d.ts +0 -15
  45. package/dist/cli/commands/generate.js +0 -159
  46. package/dist/cli/commands/index.d.ts +0 -29
  47. package/dist/cli/commands/index.js +0 -100
  48. package/dist/cli/commands/typeschema/generate.d.ts +0 -19
  49. package/dist/cli/commands/typeschema/generate.js +0 -124
  50. package/dist/cli/commands/typeschema.d.ts +0 -10
  51. package/dist/cli/commands/typeschema.js +0 -47
  52. package/dist/cli/index.d.ts +0 -9
  53. package/dist/cli/utils/log.d.ts +0 -10
  54. package/dist/cli/utils/log.js +0 -23
  55. package/dist/cli/utils/prompts.d.ts +0 -56
  56. package/dist/cli/utils/prompts.js +0 -202
  57. package/dist/cli/utils/spinner.d.ts +0 -110
  58. package/dist/cli/utils/spinner.js +0 -266
  59. package/dist/config.d.ts +0 -217
  60. package/dist/config.js +0 -591
  61. package/dist/logger.d.ts +0 -157
  62. package/dist/logger.js +0 -281
  63. package/dist/typeschema/cache.d.ts +0 -80
  64. package/dist/typeschema/cache.js +0 -239
  65. package/dist/typeschema/core/binding.d.ts +0 -11
  66. package/dist/typeschema/core/binding.js +0 -143
  67. package/dist/typeschema/core/field-builder.d.ts +0 -12
  68. package/dist/typeschema/core/field-builder.js +0 -123
  69. package/dist/typeschema/core/identifier.d.ts +0 -13
  70. package/dist/typeschema/core/identifier.js +0 -94
  71. package/dist/typeschema/core/nested-types.d.ts +0 -9
  72. package/dist/typeschema/core/nested-types.js +0 -93
  73. package/dist/typeschema/core/transformer.d.ts +0 -11
  74. package/dist/typeschema/core/transformer.js +0 -235
  75. package/dist/typeschema/generator.d.ts +0 -36
  76. package/dist/typeschema/generator.js +0 -243
  77. package/dist/typeschema/index.d.ts +0 -15
  78. package/dist/typeschema/index.js +0 -15
  79. package/dist/typeschema/parser.d.ts +0 -79
  80. package/dist/typeschema/parser.js +0 -274
  81. package/dist/typeschema/profile/processor.d.ts +0 -14
  82. package/dist/typeschema/profile/processor.js +0 -261
  83. package/dist/typeschema/register.d.ts +0 -21
  84. package/dist/typeschema/register.js +0 -117
  85. package/dist/typeschema/types.d.ts +0 -240
  86. package/dist/typeschema/types.js +0 -19
  87. package/dist/utils/codegen-logger.d.ts +0 -102
  88. package/dist/utils/codegen-logger.js +0 -196
  89. package/dist/utils.d.ts +0 -22
  90. package/dist/utils.js +0 -42
@@ -1,215 +0,0 @@
1
- /**
2
- * Directory builder for batch file operations
3
- *
4
- * Provides a fluent API for managing entire directories of files,
5
- * including subdirectories, index files, and batch operations.
6
- */
7
- /**
8
- * Fluent builder for directory operations
9
- *
10
- * Features:
11
- * - Subdirectory management
12
- * - Batch file operations
13
- * - Index file generation
14
- * - Directory cleaning
15
- * - File listing for preview
16
- */
17
- export class DirectoryBuilder {
18
- config;
19
- files = new Map();
20
- subdirectories = new Map();
21
- indexBuilder;
22
- shouldClean = false;
23
- constructor(config) {
24
- this.config = config;
25
- }
26
- /**
27
- * Add a subdirectory
28
- * @param name Subdirectory name
29
- */
30
- withSubdirectory(name) {
31
- const subdirPath = `${this.config.path}/${name}`;
32
- const subdir = new DirectoryBuilder({
33
- path: subdirPath,
34
- fileManager: this.config.fileManager,
35
- logger: this.config.logger.child(`Dir:${name}`),
36
- });
37
- this.subdirectories.set(name, subdir);
38
- return subdir;
39
- }
40
- /**
41
- * Add files to this directory
42
- * @param files Map of filename to FileBuilder
43
- */
44
- withFiles(files) {
45
- for (const [filename, builder] of Object.entries(files)) {
46
- this.files.set(filename, builder);
47
- }
48
- return this;
49
- }
50
- /**
51
- * Add a single file
52
- * @param filename File name
53
- * @param builder File builder
54
- */
55
- withFile(filename, builder) {
56
- this.files.set(filename, builder);
57
- return this;
58
- }
59
- /**
60
- * Set index builder for this directory
61
- * @param builder Index builder
62
- */
63
- withIndex(builder) {
64
- this.indexBuilder = builder;
65
- return this;
66
- }
67
- /**
68
- * Clean directory before creating files
69
- */
70
- clean() {
71
- this.shouldClean = true;
72
- return this;
73
- }
74
- /**
75
- * Ensure directory exists
76
- */
77
- async ensure() {
78
- await this.config.fileManager.ensureDirectory(this.config.path);
79
- return this;
80
- }
81
- /**
82
- * Save all files in this directory
83
- */
84
- async save() {
85
- const savedPaths = [];
86
- // Clean directory if requested
87
- if (this.shouldClean) {
88
- await this.config.fileManager.cleanDirectory(this.config.path);
89
- }
90
- // Ensure directory exists
91
- await this.ensure();
92
- // Save all files in parallel for better performance
93
- const filePromises = Array.from(this.files.entries()).map(async ([filename, builder]) => {
94
- try {
95
- const path = await builder.save();
96
- savedPaths.push(path);
97
- return path;
98
- }
99
- catch (error) {
100
- this.config.logger.error(`Failed to save file ${filename}:`, error instanceof Error ? error : undefined);
101
- throw error;
102
- }
103
- });
104
- await Promise.all(filePromises);
105
- // Save subdirectories recursively
106
- for (const [name, subdir] of this.subdirectories) {
107
- try {
108
- const subdirPaths = await subdir.save();
109
- savedPaths.push(...subdirPaths);
110
- }
111
- catch (error) {
112
- this.config.logger.error(`Failed to save subdirectory ${name}:`, error instanceof Error ? error : undefined);
113
- throw error;
114
- }
115
- }
116
- // Generate index if provided
117
- if (this.indexBuilder) {
118
- try {
119
- const indexPath = await this.indexBuilder.save();
120
- savedPaths.push(indexPath);
121
- }
122
- catch (error) {
123
- this.config.logger.error("Failed to save index file:", error instanceof Error ? error : undefined);
124
- throw error;
125
- }
126
- }
127
- this.config.logger.info(`Saved directory ${this.config.path} with ${savedPaths.length} files`);
128
- return savedPaths;
129
- }
130
- /**
131
- * Get all files that would be generated (for preview)
132
- */
133
- getFileList() {
134
- const files = [];
135
- for (const filename of this.files.keys()) {
136
- files.push(`${this.config.path}/${filename}`);
137
- }
138
- for (const [_name, subdir] of this.subdirectories) {
139
- const subdirFiles = subdir.getFileList();
140
- files.push(...subdirFiles);
141
- }
142
- if (this.indexBuilder) {
143
- files.push(`${this.config.path}/index.ts`); // Assuming TypeScript
144
- }
145
- return files.sort();
146
- }
147
- /**
148
- * Get statistics about this directory
149
- */
150
- getStats() {
151
- let totalFiles = this.files.size;
152
- for (const subdir of this.subdirectories.values()) {
153
- totalFiles += subdir.getStats().totalFiles;
154
- }
155
- if (this.indexBuilder) {
156
- totalFiles += 1;
157
- }
158
- return {
159
- fileCount: this.files.size,
160
- subdirectoryCount: this.subdirectories.size,
161
- hasIndex: !!this.indexBuilder,
162
- totalFiles,
163
- };
164
- }
165
- /**
166
- * Check if directory would overwrite existing files
167
- */
168
- async wouldOverwrite() {
169
- const conflicts = [];
170
- // Check files in this directory
171
- for (const filename of this.files.keys()) {
172
- const filePath = `${this.config.path}/${filename}`;
173
- if (await this.config.fileManager.wouldOverwrite(filePath)) {
174
- conflicts.push(filePath);
175
- }
176
- }
177
- // Check subdirectories
178
- for (const subdir of this.subdirectories.values()) {
179
- const subdirConflicts = await subdir.wouldOverwrite();
180
- conflicts.push(...subdirConflicts);
181
- }
182
- // Check index file
183
- if (this.indexBuilder) {
184
- const indexPath = `${this.config.path}/index.ts`;
185
- if (await this.config.fileManager.wouldOverwrite(indexPath)) {
186
- conflicts.push(indexPath);
187
- }
188
- }
189
- return conflicts;
190
- }
191
- /**
192
- * Get the path of this directory
193
- */
194
- getPath() {
195
- return this.config.path;
196
- }
197
- /**
198
- * Get all file builders (for testing/debugging)
199
- */
200
- getFiles() {
201
- return new Map(this.files);
202
- }
203
- /**
204
- * Get all subdirectories (for testing/debugging)
205
- */
206
- getSubdirectories() {
207
- return new Map(this.subdirectories);
208
- }
209
- /**
210
- * Get index builder (for testing/debugging)
211
- */
212
- getIndexBuilder() {
213
- return this.indexBuilder;
214
- }
215
- }
@@ -1,160 +0,0 @@
1
- /**
2
- * Fluent file builder with lifecycle hooks and validation
3
- *
4
- * This provides a clean, chainable API for building files with imports,
5
- * exports, content generation, and lifecycle hooks for customization.
6
- */
7
- import type { CodegenLogger } from "../../../../utils/codegen-logger";
8
- import type { FileManager } from "../FileManager";
9
- import type { AfterSaveHook, BeforeSaveHook, ErrorHook, FileBuilderOptions, FileContext, TemplateEngine, TypeMapper } from "../types";
10
- export interface FileBuilderConfig {
11
- filename: string;
12
- fileManager: FileManager;
13
- templateEngine?: TemplateEngine;
14
- typeMapper: TypeMapper;
15
- logger: CodegenLogger;
16
- }
17
- /**
18
- * Fluent builder for creating files with lifecycle hooks
19
- *
20
- * Features:
21
- * - Fluent API for content building
22
- * - Template integration
23
- * - Import/export management
24
- * - Lifecycle hooks (before/after save, error handling)
25
- * - Content validation
26
- * - Automatic import path resolution
27
- */
28
- export declare class FileBuilder {
29
- private readonly config;
30
- private content;
31
- private readonly imports;
32
- private readonly exports;
33
- private readonly metadata;
34
- private beforeSaveHooks;
35
- private afterSaveHooks;
36
- private errorHooks;
37
- private options;
38
- constructor(config: FileBuilderConfig);
39
- /**
40
- * Set content directly
41
- * @param content File content
42
- */
43
- withContent(content: string | (() => string)): FileBuilder;
44
- /**
45
- * Generate content from template
46
- * @param templateName Template to use
47
- * @param context Template context
48
- */
49
- withTemplate(templateName: string, context: Record<string, unknown>): FileBuilder;
50
- /**
51
- * Append content to existing content
52
- * @param content Content to append
53
- */
54
- appendContent(content: string): FileBuilder;
55
- /**
56
- * Prepend content to existing content
57
- * @param content Content to prepend
58
- */
59
- prependContent(content: string): FileBuilder;
60
- /**
61
- * Set all imports at once
62
- * @param imports Map of symbol name to import path
63
- */
64
- withImports(imports: Map<string, string>): FileBuilder;
65
- /**
66
- * Add a single import
67
- * @param symbol Symbol to import
68
- * @param from Import path
69
- */
70
- addImport(symbol: string, from: string): FileBuilder;
71
- /**
72
- * Add multiple imports from the same path
73
- * @param symbols Symbols to import
74
- * @param from Import path
75
- */
76
- addImports(symbols: string[], from: string): FileBuilder;
77
- /**
78
- * Set all exports at once
79
- * @param exports Array of export names
80
- */
81
- withExports(exports: string[]): FileBuilder;
82
- /**
83
- * Add a single export
84
- * @param name Export name
85
- */
86
- addExport(name: string): FileBuilder;
87
- /**
88
- * Add multiple exports
89
- * @param names Export names
90
- */
91
- addExports(names: string[]): FileBuilder;
92
- /**
93
- * Set metadata for the file
94
- * @param key Metadata key
95
- * @param value Metadata value
96
- */
97
- withMetadata(key: string, value: unknown): FileBuilder;
98
- /**
99
- * Set file builder options
100
- * @param options Options to set
101
- */
102
- withOptions(options: Partial<FileBuilderOptions>): FileBuilder;
103
- /**
104
- * Add hook to run before saving
105
- * @param hook Hook function
106
- */
107
- onBeforeSave(hook: BeforeSaveHook): FileBuilder;
108
- /**
109
- * Add hook to run after successful save
110
- * @param hook Hook function
111
- */
112
- onAfterSave(hook: AfterSaveHook): FileBuilder;
113
- /**
114
- * Add hook to run when error occurs
115
- * @param hook Hook function
116
- */
117
- onError(hook: ErrorHook): FileBuilder;
118
- /**
119
- * Build final content without saving
120
- * @returns File context with final content
121
- */
122
- build(): FileContext;
123
- /**
124
- * Save the file
125
- * @returns Promise resolving to file path
126
- */
127
- save(): Promise<string>;
128
- /**
129
- * Build final content with imports and exports
130
- */
131
- private buildFinalContent;
132
- /**
133
- * Generate import statements
134
- */
135
- private generateImportStatements;
136
- /**
137
- * Generate export statements
138
- */
139
- private generateExportStatements;
140
- /**
141
- * Prettify content (basic implementation)
142
- */
143
- private prettifyContent;
144
- /**
145
- * Validate generated content
146
- */
147
- private validateContent;
148
- /**
149
- * Get current content (for testing/debugging)
150
- */
151
- getContent(): string;
152
- /**
153
- * Get current imports (for testing/debugging)
154
- */
155
- getImports(): Map<string, string>;
156
- /**
157
- * Get current exports (for testing/debugging)
158
- */
159
- getExports(): Set<string>;
160
- }