@atomic-ehr/codegen 0.0.1-canary.20250812081907.f886676 → 0.0.1-canary.20250819094151.a48e310
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.
- package/dist/api/builder.d.ts.map +1 -1
- package/dist/api/generators/base/BaseGenerator.d.ts +186 -0
- package/dist/api/generators/base/BaseGenerator.d.ts.map +1 -0
- package/dist/api/generators/base/FileManager.d.ts +90 -0
- package/dist/api/generators/base/FileManager.d.ts.map +1 -0
- package/dist/api/generators/base/HandlebarsTemplateEngine.d.ts +60 -0
- package/dist/api/generators/base/HandlebarsTemplateEngine.d.ts.map +1 -0
- package/dist/api/generators/base/PythonTypeMapper.d.ts +17 -0
- package/dist/api/generators/base/PythonTypeMapper.d.ts.map +1 -0
- package/dist/api/generators/base/TemplateEngine.d.ts +127 -0
- package/dist/api/generators/base/TemplateEngine.d.ts.map +1 -0
- package/dist/api/generators/base/TypeMapper.d.ts +130 -0
- package/dist/api/generators/base/TypeMapper.d.ts.map +1 -0
- package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +52 -0
- package/dist/api/generators/base/TypeScriptTypeMapper.d.ts.map +1 -0
- package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +100 -0
- package/dist/api/generators/base/builders/DirectoryBuilder.d.ts.map +1 -0
- package/dist/api/generators/base/builders/FileBuilder.d.ts +161 -0
- package/dist/api/generators/base/builders/FileBuilder.d.ts.map +1 -0
- package/dist/api/generators/base/builders/IndexBuilder.d.ts +127 -0
- package/dist/api/generators/base/builders/IndexBuilder.d.ts.map +1 -0
- package/dist/api/generators/base/enhanced-errors.d.ts +85 -0
- package/dist/api/generators/base/enhanced-errors.d.ts.map +1 -0
- package/dist/api/generators/base/error-handler.d.ts +90 -0
- package/dist/api/generators/base/error-handler.d.ts.map +1 -0
- package/dist/api/generators/base/errors.d.ts +252 -0
- package/dist/api/generators/base/errors.d.ts.map +1 -0
- package/dist/api/generators/base/index.d.ts +104 -0
- package/dist/api/generators/base/index.d.ts.map +1 -0
- package/dist/api/generators/base/types.d.ts +434 -0
- package/dist/api/generators/base/types.d.ts.map +1 -0
- package/dist/api/generators/typescript.d.ts +80 -179
- package/dist/api/generators/typescript.d.ts.map +1 -1
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index-vysn9shw.js +14370 -0
- package/dist/index.js +3 -3
- package/package.json +13 -4
- package/dist/index-4p27vhn8.js +0 -6991
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript-specific type mapper implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { TypeSchemaIdentifier } from "../../../typeschema";
|
|
5
|
+
import { type LanguageType, TypeMapper, type TypeMapperOptions } from "./TypeMapper";
|
|
6
|
+
/**
|
|
7
|
+
* TypeScript-specific options
|
|
8
|
+
*/
|
|
9
|
+
export interface TypeScriptTypeMapperOptions extends TypeMapperOptions {
|
|
10
|
+
/** Whether to use 'unknown' or 'any' for unmapped types */
|
|
11
|
+
preferUnknown?: boolean;
|
|
12
|
+
/** Whether to generate branded types for primitives */
|
|
13
|
+
useBrandedTypes?: boolean;
|
|
14
|
+
/** Whether to use 'undefined' or 'null' for optional types */
|
|
15
|
+
preferUndefined?: boolean;
|
|
16
|
+
/** Module format for imports */
|
|
17
|
+
moduleFormat?: "esm" | "commonjs";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* TypeScript type mapper
|
|
21
|
+
*/
|
|
22
|
+
export declare class TypeScriptTypeMapper extends TypeMapper {
|
|
23
|
+
private readonly tsOptions;
|
|
24
|
+
constructor(options?: TypeScriptTypeMapperOptions);
|
|
25
|
+
getLanguageName(): string;
|
|
26
|
+
mapPrimitive(fhirType: string): LanguageType;
|
|
27
|
+
mapReference(targets: TypeSchemaIdentifier[]): LanguageType;
|
|
28
|
+
mapArray(elementType: LanguageType): LanguageType;
|
|
29
|
+
mapOptional(type: LanguageType, required: boolean): LanguageType;
|
|
30
|
+
mapEnum(values: string[], name?: string): LanguageType;
|
|
31
|
+
formatTypeName(name: string): string;
|
|
32
|
+
formatFieldName(name: string): string;
|
|
33
|
+
formatFileName(name: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Generate TypeScript interface field
|
|
36
|
+
* @param fieldName Field name
|
|
37
|
+
* @param fieldType Field type
|
|
38
|
+
* @param required Whether field is required
|
|
39
|
+
*/
|
|
40
|
+
generateInterfaceField(fieldName: string, fieldType: LanguageType, required: boolean): string;
|
|
41
|
+
/**
|
|
42
|
+
* Generate import statement for a type
|
|
43
|
+
* @param type Language type with import info
|
|
44
|
+
*/
|
|
45
|
+
generateImportStatement(type: LanguageType): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get all required imports for a set of types
|
|
48
|
+
* @param types Array of language types
|
|
49
|
+
*/
|
|
50
|
+
getRequiredImports(types: LanguageType[]): string[];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=TypeScriptTypeMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeScriptTypeMapper.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/TypeScriptTypeMapper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACN,KAAK,YAAY,EACjB,UAAU,EACV,KAAK,iBAAiB,EACtB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACrE,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,uDAAuD;IACvD,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;gBAEtD,OAAO,GAAE,2BAAgC;IAarD,eAAe,IAAI,MAAM;IAIzB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY;IAqE5C,YAAY,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,YAAY;IA6C3D,QAAQ,CAAC,WAAW,EAAE,YAAY,GAAG,YAAY;IA4BjD,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAG,YAAY;IAmBhE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;IAkBtD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIpC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAKrC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAKpC;;;;;OAKG;IACH,sBAAsB,CACrB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE,OAAO,GACf,MAAM;IAOT;;;OAGG;IACH,uBAAuB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS;IAY/D;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE;CAYnD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
import type { CodegenLogger } from "../../../../utils/codegen-logger";
|
|
8
|
+
import type { FileManager } from "../FileManager";
|
|
9
|
+
import type { FileBuilder } from "./FileBuilder";
|
|
10
|
+
import type { IndexBuilder } from "./IndexBuilder";
|
|
11
|
+
export interface DirectoryBuilderConfig {
|
|
12
|
+
path: string;
|
|
13
|
+
fileManager: FileManager;
|
|
14
|
+
logger: CodegenLogger;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Fluent builder for directory operations
|
|
18
|
+
*
|
|
19
|
+
* Features:
|
|
20
|
+
* - Subdirectory management
|
|
21
|
+
* - Batch file operations
|
|
22
|
+
* - Index file generation
|
|
23
|
+
* - Directory cleaning
|
|
24
|
+
* - File listing for preview
|
|
25
|
+
*/
|
|
26
|
+
export declare class DirectoryBuilder {
|
|
27
|
+
private readonly config;
|
|
28
|
+
private readonly files;
|
|
29
|
+
private readonly subdirectories;
|
|
30
|
+
private indexBuilder?;
|
|
31
|
+
private shouldClean;
|
|
32
|
+
constructor(config: DirectoryBuilderConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Add a subdirectory
|
|
35
|
+
* @param name Subdirectory name
|
|
36
|
+
*/
|
|
37
|
+
withSubdirectory(name: string): DirectoryBuilder;
|
|
38
|
+
/**
|
|
39
|
+
* Add files to this directory
|
|
40
|
+
* @param files Map of filename to FileBuilder
|
|
41
|
+
*/
|
|
42
|
+
withFiles(files: Record<string, FileBuilder>): DirectoryBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Add a single file
|
|
45
|
+
* @param filename File name
|
|
46
|
+
* @param builder File builder
|
|
47
|
+
*/
|
|
48
|
+
withFile(filename: string, builder: FileBuilder): DirectoryBuilder;
|
|
49
|
+
/**
|
|
50
|
+
* Set index builder for this directory
|
|
51
|
+
* @param builder Index builder
|
|
52
|
+
*/
|
|
53
|
+
withIndex(builder: IndexBuilder): DirectoryBuilder;
|
|
54
|
+
/**
|
|
55
|
+
* Clean directory before creating files
|
|
56
|
+
*/
|
|
57
|
+
clean(): DirectoryBuilder;
|
|
58
|
+
/**
|
|
59
|
+
* Ensure directory exists
|
|
60
|
+
*/
|
|
61
|
+
ensure(): Promise<DirectoryBuilder>;
|
|
62
|
+
/**
|
|
63
|
+
* Save all files in this directory
|
|
64
|
+
*/
|
|
65
|
+
save(): Promise<string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Get all files that would be generated (for preview)
|
|
68
|
+
*/
|
|
69
|
+
getFileList(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Get statistics about this directory
|
|
72
|
+
*/
|
|
73
|
+
getStats(): {
|
|
74
|
+
fileCount: number;
|
|
75
|
+
subdirectoryCount: number;
|
|
76
|
+
hasIndex: boolean;
|
|
77
|
+
totalFiles: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Check if directory would overwrite existing files
|
|
81
|
+
*/
|
|
82
|
+
wouldOverwrite(): Promise<string[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Get the path of this directory
|
|
85
|
+
*/
|
|
86
|
+
getPath(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Get all file builders (for testing/debugging)
|
|
89
|
+
*/
|
|
90
|
+
getFiles(): Map<string, FileBuilder>;
|
|
91
|
+
/**
|
|
92
|
+
* Get all subdirectories (for testing/debugging)
|
|
93
|
+
*/
|
|
94
|
+
getSubdirectories(): Map<string, DirectoryBuilder>;
|
|
95
|
+
/**
|
|
96
|
+
* Get index builder (for testing/debugging)
|
|
97
|
+
*/
|
|
98
|
+
getIndexBuilder(): IndexBuilder | undefined;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=DirectoryBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DirectoryBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/api/generators/base/builders/DirectoryBuilder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MA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CAAC;IAIpC;;OAEG;IACH,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAIlD;;OAEG;IACH,eAAe,IAAI,YAAY,GAAG,SAAS;CAG3C"}
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
}
|
|
161
|
+
//# sourceMappingURL=FileBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/api/generators/base/builders/FileBuilder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,UAAU,EACV,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IAGvD,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,UAAU,CAAmB;IAGrC,OAAO,CAAC,OAAO,CAWb;gBAEU,MAAM,EAAE,iBAAiB;I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AAI,OAAO,CAAC,MAAM,CAAC;IAyD7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8BzB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA6ChC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAKhC;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;YACW,eAAe;IAiD7B;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIjC;;OAEG;IACH,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC;CAGzB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index file builder for automated exports
|
|
3
|
+
*
|
|
4
|
+
* Automatically generates index files that export all types and functions
|
|
5
|
+
* from a directory, with support for grouping and namespaces.
|
|
6
|
+
*/
|
|
7
|
+
import type { CodegenLogger } from "../../../../utils/codegen-logger";
|
|
8
|
+
import type { FileManager } from "../FileManager";
|
|
9
|
+
import type { TemplateEngine } from "../types";
|
|
10
|
+
export interface IndexBuilderConfig {
|
|
11
|
+
directory: string;
|
|
12
|
+
fileManager: FileManager;
|
|
13
|
+
templateEngine: TemplateEngine;
|
|
14
|
+
logger: CodegenLogger;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builder for index files with intelligent export management
|
|
18
|
+
*
|
|
19
|
+
* Features:
|
|
20
|
+
* - Automatic export detection
|
|
21
|
+
* - Namespace support
|
|
22
|
+
* - Export grouping
|
|
23
|
+
* - Custom headers
|
|
24
|
+
* - Template support
|
|
25
|
+
*/
|
|
26
|
+
export declare class IndexBuilder {
|
|
27
|
+
private readonly config;
|
|
28
|
+
private readonly exports;
|
|
29
|
+
private readonly namespaces;
|
|
30
|
+
private readonly reExports;
|
|
31
|
+
private header;
|
|
32
|
+
private footer;
|
|
33
|
+
private groupingFunction?;
|
|
34
|
+
private sortFunction?;
|
|
35
|
+
constructor(config: IndexBuilderConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Add exports from a specific file
|
|
38
|
+
* @param exportNames Export names
|
|
39
|
+
* @param fromPath Path to file (without extension)
|
|
40
|
+
*/
|
|
41
|
+
withExports(exportNames: string[], fromPath: string): IndexBuilder;
|
|
42
|
+
/**
|
|
43
|
+
* Add a single export
|
|
44
|
+
* @param exportName Export name
|
|
45
|
+
* @param fromPath Path to file
|
|
46
|
+
*/
|
|
47
|
+
withExport(exportName: string, fromPath: string): IndexBuilder;
|
|
48
|
+
/**
|
|
49
|
+
* Add namespace exports
|
|
50
|
+
* @param namespaces Map of namespace to path
|
|
51
|
+
*/
|
|
52
|
+
withNamespaces(namespaces: Record<string, string>): IndexBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Add namespace export
|
|
55
|
+
* @param namespace Namespace name
|
|
56
|
+
* @param path Path to export as namespace
|
|
57
|
+
*/
|
|
58
|
+
withNamespace(namespace: string, path: string): IndexBuilder;
|
|
59
|
+
/**
|
|
60
|
+
* Re-export all from paths
|
|
61
|
+
* @param paths Paths to re-export all from
|
|
62
|
+
*/
|
|
63
|
+
withReExports(paths: string[]): IndexBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Add re-export
|
|
66
|
+
* @param path Path to re-export all from
|
|
67
|
+
*/
|
|
68
|
+
withReExport(path: string): IndexBuilder;
|
|
69
|
+
/**
|
|
70
|
+
* Set header content
|
|
71
|
+
* @param header Header content
|
|
72
|
+
*/
|
|
73
|
+
withHeader(header: string): IndexBuilder;
|
|
74
|
+
/**
|
|
75
|
+
* Set footer content
|
|
76
|
+
* @param footer Footer content
|
|
77
|
+
*/
|
|
78
|
+
withFooter(footer: string): IndexBuilder;
|
|
79
|
+
/**
|
|
80
|
+
* Group exports by function
|
|
81
|
+
* @param fn Function that returns group name for export
|
|
82
|
+
*/
|
|
83
|
+
groupBy(fn: (exportName: string) => string): IndexBuilder;
|
|
84
|
+
/**
|
|
85
|
+
* Sort exports by function
|
|
86
|
+
* @param fn Sort function for [exportName, fromPath] tuples
|
|
87
|
+
*/
|
|
88
|
+
sortBy(fn: (a: [string, string], b: [string, string]) => number): IndexBuilder;
|
|
89
|
+
/**
|
|
90
|
+
* Auto-discover exports from directory
|
|
91
|
+
* @param filePattern Pattern to match files (e.g., "*.ts")
|
|
92
|
+
*/
|
|
93
|
+
autoDiscover(filePattern?: string): Promise<IndexBuilder>;
|
|
94
|
+
/**
|
|
95
|
+
* Save the index file
|
|
96
|
+
*/
|
|
97
|
+
save(): Promise<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Build content without saving (for preview)
|
|
100
|
+
*/
|
|
101
|
+
build(): string;
|
|
102
|
+
/**
|
|
103
|
+
* Generate the index file content
|
|
104
|
+
*/
|
|
105
|
+
private generateContent;
|
|
106
|
+
/**
|
|
107
|
+
* Generate simple exports without grouping
|
|
108
|
+
*/
|
|
109
|
+
private generateSimpleExports;
|
|
110
|
+
/**
|
|
111
|
+
* Generate grouped exports
|
|
112
|
+
*/
|
|
113
|
+
private generateGroupedExports;
|
|
114
|
+
/**
|
|
115
|
+
* Get current exports (for testing/debugging)
|
|
116
|
+
*/
|
|
117
|
+
getExports(): Map<string, string>;
|
|
118
|
+
/**
|
|
119
|
+
* Get current namespaces (for testing/debugging)
|
|
120
|
+
*/
|
|
121
|
+
getNamespaces(): Map<string, string>;
|
|
122
|
+
/**
|
|
123
|
+
* Get current re-exports (for testing/debugging)
|
|
124
|
+
*/
|
|
125
|
+
getReExports(): Map<string, string>;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=IndexBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/api/generators/base/builders/IndexBuilder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,C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;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,YAAY;IAKzD;;;OAGG;IACH,MAAM,CACL,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,GACtD,YAAY;IAKf;;;OAGG;IACG,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAkB/D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAU7B;;OAEG;IACH,KAAK,IAAI,MAAM;IAIf;;OAEG;IACH,OAAO,CAAC,eAAe;IAmDvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0C7B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0C9B;;OAEG;IACH,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIjC;;OAEG;IACH,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIpC;;OAEG;IACH,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAGnC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced error handling with rich context and suggestions
|
|
3
|
+
*
|
|
4
|
+
* This module builds on the basic GeneratorError classes to provide
|
|
5
|
+
* even more detailed error context, smarter suggestions, and better
|
|
6
|
+
* user experience for developers at all skill levels.
|
|
7
|
+
*/
|
|
8
|
+
import type { TypeSchema } from "../../../typeschema";
|
|
9
|
+
import { GeneratorError } from "./errors";
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced schema validation error with smart suggestions
|
|
12
|
+
*/
|
|
13
|
+
export declare class EnhancedSchemaValidationError extends GeneratorError {
|
|
14
|
+
readonly schema: TypeSchema;
|
|
15
|
+
readonly validationErrors: string[];
|
|
16
|
+
readonly userContext?: {
|
|
17
|
+
isBeginnerMode?: boolean;
|
|
18
|
+
previousSuccessfulSchemas?: string[];
|
|
19
|
+
commonPatterns?: string[];
|
|
20
|
+
} | undefined;
|
|
21
|
+
constructor(message: string, schema: TypeSchema, validationErrors: string[], userContext?: {
|
|
22
|
+
isBeginnerMode?: boolean;
|
|
23
|
+
previousSuccessfulSchemas?: string[];
|
|
24
|
+
commonPatterns?: string[];
|
|
25
|
+
} | undefined);
|
|
26
|
+
getSuggestions(): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Get formatted error message for display
|
|
29
|
+
*/
|
|
30
|
+
getFormattedMessage(): string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Enhanced file operation error with recovery suggestions
|
|
34
|
+
*/
|
|
35
|
+
export declare class EnhancedFileOperationError extends GeneratorError {
|
|
36
|
+
readonly operation: "create" | "write" | "read" | "delete";
|
|
37
|
+
readonly filePath: string;
|
|
38
|
+
readonly originalError?: Error | undefined;
|
|
39
|
+
readonly recoveryOptions?: {
|
|
40
|
+
canRetry?: boolean;
|
|
41
|
+
alternativePaths?: string[];
|
|
42
|
+
permissionFix?: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
constructor(message: string, operation: "create" | "write" | "read" | "delete", filePath: string, originalError?: Error | undefined, recoveryOptions?: {
|
|
45
|
+
canRetry?: boolean;
|
|
46
|
+
alternativePaths?: string[];
|
|
47
|
+
permissionFix?: string;
|
|
48
|
+
} | undefined);
|
|
49
|
+
getSuggestions(): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Check if this error is recoverable
|
|
52
|
+
*/
|
|
53
|
+
isRecoverable(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Get recovery actions user can take
|
|
56
|
+
*/
|
|
57
|
+
getRecoveryActions(): Array<{
|
|
58
|
+
action: string;
|
|
59
|
+
command?: string;
|
|
60
|
+
automatic?: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Enhanced template error with template debugging info
|
|
65
|
+
*/
|
|
66
|
+
export declare class EnhancedTemplateError extends GeneratorError {
|
|
67
|
+
readonly templateName: string;
|
|
68
|
+
readonly templateContext: Record<string, unknown>;
|
|
69
|
+
readonly debugInfo?: {
|
|
70
|
+
availableTemplates?: string[];
|
|
71
|
+
missingVariables?: string[];
|
|
72
|
+
templateSource?: string;
|
|
73
|
+
lineNumber?: number;
|
|
74
|
+
} | undefined;
|
|
75
|
+
constructor(message: string, templateName: string, templateContext: Record<string, unknown>, debugInfo?: {
|
|
76
|
+
availableTemplates?: string[];
|
|
77
|
+
missingVariables?: string[];
|
|
78
|
+
templateSource?: string;
|
|
79
|
+
lineNumber?: number;
|
|
80
|
+
} | undefined);
|
|
81
|
+
getSuggestions(): string[];
|
|
82
|
+
private findSimilarTemplates;
|
|
83
|
+
private levenshteinDistance;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=enhanced-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-errors.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/enhanced-errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,cAAc;aAG/C,MAAM,EAAE,UAAU;aAClB,gBAAgB,EAAE,MAAM,EAAE;aAC1B,WAAW,CAAC,EAAE;QAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;QACrC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B;gBAPD,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,UAAU,EAClB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,WAAW,CAAC,EAAE;QAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,y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B,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB;gBARD,OAAO,EAAE,MAAM,EACC,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,SAAS,CAAC,EAAE;QAC3B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC9B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,YAAA;IASF,cAAc,IAAI,MAAM,EAAE;IA6C1B,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,mBAAmB;CA2B3B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized error handling and reporting system
|
|
3
|
+
*
|
|
4
|
+
* This module provides a comprehensive error handling solution that:
|
|
5
|
+
* - Handles both generator-specific and unknown errors gracefully
|
|
6
|
+
* - Provides rich, context-aware error reporting
|
|
7
|
+
* - Supports multiple output formats (console, JSON, structured)
|
|
8
|
+
* - Includes batch error handling for multiple failures
|
|
9
|
+
* - Offers smart error recovery suggestions
|
|
10
|
+
*/
|
|
11
|
+
import type { TypeSchema } from "../../../typeschema";
|
|
12
|
+
import type { CodegenLogger } from "../../../utils/codegen-logger";
|
|
13
|
+
export interface ErrorHandlerOptions {
|
|
14
|
+
logger: CodegenLogger;
|
|
15
|
+
verbose?: boolean;
|
|
16
|
+
beginnerMode?: boolean;
|
|
17
|
+
outputFormat?: "console" | "json" | "structured";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Centralized error handler with smart reporting
|
|
21
|
+
*/
|
|
22
|
+
export declare class ErrorHandler {
|
|
23
|
+
private options;
|
|
24
|
+
constructor(options: ErrorHandlerOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Handle a single error with appropriate reporting
|
|
27
|
+
*/
|
|
28
|
+
handleError(error: Error, context?: {
|
|
29
|
+
schema?: TypeSchema;
|
|
30
|
+
filename?: string;
|
|
31
|
+
}): void;
|
|
32
|
+
/**
|
|
33
|
+
* Handle multiple errors in batch
|
|
34
|
+
*/
|
|
35
|
+
handleBatchErrors(errors: Error[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Handle generator-specific errors with rich context
|
|
38
|
+
*/
|
|
39
|
+
private handleGeneratorError;
|
|
40
|
+
/**
|
|
41
|
+
* Handle unknown errors gracefully
|
|
42
|
+
*/
|
|
43
|
+
private handleUnknownError;
|
|
44
|
+
/**
|
|
45
|
+
* Report error to console with formatting
|
|
46
|
+
*/
|
|
47
|
+
private reportErrorToConsole;
|
|
48
|
+
/**
|
|
49
|
+
* Report error as JSON for programmatic consumption
|
|
50
|
+
*/
|
|
51
|
+
private reportErrorAsJson;
|
|
52
|
+
/**
|
|
53
|
+
* Report error in structured format
|
|
54
|
+
*/
|
|
55
|
+
private reportErrorStructured;
|
|
56
|
+
/**
|
|
57
|
+
* Report multiple errors efficiently
|
|
58
|
+
*/
|
|
59
|
+
private reportBatchErrors;
|
|
60
|
+
/**
|
|
61
|
+
* Get common suggestions across similar errors
|
|
62
|
+
*/
|
|
63
|
+
private getCommonSuggestions;
|
|
64
|
+
/**
|
|
65
|
+
* Get recovery actions for an error
|
|
66
|
+
*/
|
|
67
|
+
private getRecoveryActions;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Error boundary for catching and handling all generator errors
|
|
71
|
+
*/
|
|
72
|
+
export declare class GeneratorErrorBoundary {
|
|
73
|
+
private errorHandler;
|
|
74
|
+
constructor(errorHandler: ErrorHandler);
|
|
75
|
+
/**
|
|
76
|
+
* Wrap an async operation with error boundary
|
|
77
|
+
*/
|
|
78
|
+
withErrorBoundary<T>(operation: () => Promise<T>, context?: {
|
|
79
|
+
schema?: TypeSchema;
|
|
80
|
+
filename?: string;
|
|
81
|
+
operationName?: string;
|
|
82
|
+
}): Promise<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Wrap a batch operation with error boundary
|
|
85
|
+
*/
|
|
86
|
+
withBatchErrorBoundary<T>(operations: Array<() => Promise<T>>, context?: {
|
|
87
|
+
operationName?: string;
|
|
88
|
+
}): Promise<T[]>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;CACjD;AAED;;GAEG;AACH,qBAAa,YAAY;IACZ,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,mBAAmB;IAEhD;;OAEG;IACH,WAAW,CACV,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,UAAU,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAClD,IAAI;IAQP;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAexC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAkB7B;;OAEG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