@atomic-ehr/codegen 0.0.1-canary.20250811235950.67a72a5 → 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 +81 -135
- 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-m60p8fkc.js +0 -6709
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/api/builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,UAAU,EAIf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK7D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,MAAM,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACz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BAAiB;IA2B/B,OAAO,CAAC,cAAc;CActB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAEjE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAkC9D;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC7C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACd,GACJ,OAAO,CAAC,gBAAgB,CAAC,CAS3B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACR,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACd,GACJ,OAAO,CAAC,gBAAgB,CAAC,CAS3B"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base generator class
|
|
3
|
+
*
|
|
4
|
+
* This is the foundation of the generator system. All language-specific generators
|
|
5
|
+
* extend this class to inherit common functionality while implementing their own
|
|
6
|
+
* specific logic for type mapping, content generation, and validation.
|
|
7
|
+
*/
|
|
8
|
+
import type { TypeSchema } from "../../../typeschema";
|
|
9
|
+
import type { CodegenLogger } from "../../../utils/codegen-logger";
|
|
10
|
+
import { ErrorHandler, GeneratorErrorBoundary } from "./error-handler";
|
|
11
|
+
import { FileManager } from "./FileManager";
|
|
12
|
+
import type { BaseGeneratorOptions, GeneratedFile, GeneratorCapabilities, ProgressCallback, TemplateContext, TemplateEngine, TypeMapper } from "./types";
|
|
13
|
+
/**
|
|
14
|
+
* Abstract base generator class with comprehensive functionality
|
|
15
|
+
*
|
|
16
|
+
* Provides common functionality for all generators including:
|
|
17
|
+
* - Schema validation and processing
|
|
18
|
+
* - File management with fluent API
|
|
19
|
+
* - Template processing
|
|
20
|
+
* - Error handling and recovery
|
|
21
|
+
* - Progress monitoring
|
|
22
|
+
* - Performance optimization
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class BaseGenerator<TOptions extends BaseGeneratorOptions = BaseGeneratorOptions, TResult extends GeneratedFile[] = GeneratedFile[]> {
|
|
25
|
+
/** Validated and merged options */
|
|
26
|
+
protected options: Required<TOptions>;
|
|
27
|
+
/** Logger instance for this generator */
|
|
28
|
+
protected readonly logger: CodegenLogger;
|
|
29
|
+
/** File manager for all file operations */
|
|
30
|
+
protected readonly fileManager: FileManager;
|
|
31
|
+
/** Template engine for content generation */
|
|
32
|
+
protected readonly templateEngine: TemplateEngine;
|
|
33
|
+
/** Language-specific type mapper */
|
|
34
|
+
protected readonly typeMapper: TypeMapper;
|
|
35
|
+
/** Enhanced error handler for comprehensive error reporting */
|
|
36
|
+
protected readonly errorHandler: ErrorHandler;
|
|
37
|
+
/** Error boundary for catching and handling all generator errors */
|
|
38
|
+
protected readonly errorBoundary: GeneratorErrorBoundary;
|
|
39
|
+
/** Progress callback if provided */
|
|
40
|
+
private progressCallback?;
|
|
41
|
+
/** Generated files tracking */
|
|
42
|
+
private generatedFiles;
|
|
43
|
+
/** Generation start time for performance metrics */
|
|
44
|
+
private generationStartTime;
|
|
45
|
+
/** Cache for expensive operations */
|
|
46
|
+
private readonly cache;
|
|
47
|
+
constructor(options: TOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Get the name of the target language (e.g., "TypeScript", "Python", "Rust")
|
|
50
|
+
*/
|
|
51
|
+
protected abstract getLanguageName(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get the file extension for the target language (e.g., ".ts", ".py", ".rs")
|
|
54
|
+
*/
|
|
55
|
+
protected abstract getFileExtension(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Create a language-specific type mapper
|
|
58
|
+
*/
|
|
59
|
+
protected abstract createTypeMapper(): TypeMapper;
|
|
60
|
+
/**
|
|
61
|
+
* Generate content for a single schema
|
|
62
|
+
* @param schema - The TypeSchema to generate code for
|
|
63
|
+
* @param context - Additional context for generation
|
|
64
|
+
*/
|
|
65
|
+
protected abstract generateSchemaContent(schema: TypeSchema, context: TemplateContext): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Validate generated content before writing
|
|
68
|
+
* @param content - The generated content
|
|
69
|
+
* @param context - The generation context
|
|
70
|
+
*/
|
|
71
|
+
protected abstract validateContent(content: string, context: TemplateContext): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Filter and sort schemas with language-specific logic
|
|
74
|
+
* @param schemas - Input schemas
|
|
75
|
+
*/
|
|
76
|
+
protected abstract filterAndSortSchemas(schemas: TypeSchema[]): TypeSchema[];
|
|
77
|
+
/**
|
|
78
|
+
* Get generator capabilities - can be overridden for introspection
|
|
79
|
+
*/
|
|
80
|
+
getCapabilities(): GeneratorCapabilities;
|
|
81
|
+
/**
|
|
82
|
+
* Create file manager instance - can be overridden for custom file handling
|
|
83
|
+
*/
|
|
84
|
+
protected createFileManager(): FileManager;
|
|
85
|
+
/**
|
|
86
|
+
* Create template engine instance - can be overridden for custom templates
|
|
87
|
+
*/
|
|
88
|
+
protected createTemplateEngine(): TemplateEngine;
|
|
89
|
+
/**
|
|
90
|
+
* Generate code from TypeSchema documents
|
|
91
|
+
* This is the main method that orchestrates the entire generation process
|
|
92
|
+
* @param schemas - Array of TypeSchema documents
|
|
93
|
+
*/
|
|
94
|
+
generate(schemas: TypeSchema[]): Promise<TResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Generate and return content without writing files (useful for testing)
|
|
97
|
+
* @param schemas - Array of TypeSchema documents
|
|
98
|
+
*/
|
|
99
|
+
build(schemas: TypeSchema[]): Promise<TResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Create a file builder for fluent file generation
|
|
102
|
+
* @param filename - Name of the file to create
|
|
103
|
+
*/
|
|
104
|
+
file(filename: string): import("./builders/FileBuilder").FileBuilder;
|
|
105
|
+
/**
|
|
106
|
+
* Create a directory builder for batch operations
|
|
107
|
+
* @param path - Directory path relative to output directory
|
|
108
|
+
*/
|
|
109
|
+
directory(path: string): import("./builders/DirectoryBuilder").DirectoryBuilder;
|
|
110
|
+
/**
|
|
111
|
+
* Create an index file builder
|
|
112
|
+
* @param directory - Directory to create index for
|
|
113
|
+
*/
|
|
114
|
+
index(directory?: string): import("./builders/IndexBuilder").IndexBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Set progress callback for monitoring generation
|
|
117
|
+
* @param callback - Progress callback function
|
|
118
|
+
*/
|
|
119
|
+
onProgress(callback: ProgressCallback): this;
|
|
120
|
+
/**
|
|
121
|
+
* Validate generator configuration
|
|
122
|
+
*/
|
|
123
|
+
private validateConfiguration;
|
|
124
|
+
/**
|
|
125
|
+
* Merge options with defaults
|
|
126
|
+
*/
|
|
127
|
+
private mergeWithDefaults;
|
|
128
|
+
/**
|
|
129
|
+
* Validate schemas before processing
|
|
130
|
+
*/
|
|
131
|
+
private validateSchemas;
|
|
132
|
+
/**
|
|
133
|
+
* Validate individual schema
|
|
134
|
+
*/
|
|
135
|
+
protected validateSchema(schema: TypeSchema): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Detect circular references in schema dependencies
|
|
138
|
+
*/
|
|
139
|
+
private detectCircularReferences;
|
|
140
|
+
/**
|
|
141
|
+
* Generate files from processed schemas
|
|
142
|
+
*/
|
|
143
|
+
private generateFiles;
|
|
144
|
+
/**
|
|
145
|
+
* Generate a single file from a schema
|
|
146
|
+
*/
|
|
147
|
+
private generateFileForSchema;
|
|
148
|
+
/**
|
|
149
|
+
* Ensure filename has correct extension
|
|
150
|
+
*/
|
|
151
|
+
private ensureFileExtension;
|
|
152
|
+
/**
|
|
153
|
+
* Extract exported symbols from generated content
|
|
154
|
+
* Can be overridden by language-specific implementations
|
|
155
|
+
*/
|
|
156
|
+
protected extractExports(content: string): string[];
|
|
157
|
+
/**
|
|
158
|
+
* Report progress to callback if provided
|
|
159
|
+
*/
|
|
160
|
+
protected reportProgress(phase: "validation" | "generation" | "writing" | "complete", current: number, total: number, message?: string, schema?: TypeSchema): void;
|
|
161
|
+
/**
|
|
162
|
+
* Run post-generation hooks
|
|
163
|
+
* Can be overridden to add custom post-processing
|
|
164
|
+
*/
|
|
165
|
+
protected runPostGenerationHooks(): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Get cached value or compute and cache it
|
|
168
|
+
*/
|
|
169
|
+
protected getCachedOrCompute<T>(key: string, computeFn: () => T | Promise<T>): T | Promise<T>;
|
|
170
|
+
/**
|
|
171
|
+
* Clear internal cache
|
|
172
|
+
*/
|
|
173
|
+
protected clearCache(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Get generation statistics
|
|
176
|
+
*/
|
|
177
|
+
getGenerationStats(): {
|
|
178
|
+
filesGenerated: number;
|
|
179
|
+
totalSize: number;
|
|
180
|
+
averageFileSize: number;
|
|
181
|
+
generationTime: number;
|
|
182
|
+
averageTimePerFile: number;
|
|
183
|
+
cacheHitRate: number;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=BaseGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseGenerator.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/BaseGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EACX,oBAAoB,EAEpB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,c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AAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IA6BnD;;OAEG;IACH,SAAS,CAAC,cAAc,CACvB,KAAK,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,EAC3D,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,UAAU,GACjB,IAAI;IAUP;;;OAGG;cACa,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvD;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAC7B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAC7B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBjB;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI;IAI5B;;OAEG;IACI,kBAAkB,IAAI;QAC5B,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,YAAY,EAAE,MAAM,CAAC;KACrB;CAsBD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core file management system with batching and performance optimizations
|
|
3
|
+
*
|
|
4
|
+
* This replaces scattered writeFile calls with a comprehensive file management
|
|
5
|
+
* system that provides better error handling, performance, and maintainability.
|
|
6
|
+
*/
|
|
7
|
+
import type { CodegenLogger } from "../../../utils/codegen-logger";
|
|
8
|
+
import type { FileStats } from "./types";
|
|
9
|
+
export interface FileManagerOptions {
|
|
10
|
+
outputDir: string;
|
|
11
|
+
logger: CodegenLogger;
|
|
12
|
+
overwrite?: boolean;
|
|
13
|
+
batchSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface WriteFileResult {
|
|
16
|
+
path: string;
|
|
17
|
+
size: number;
|
|
18
|
+
writeTime: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* High-performance file manager with batching and error recovery
|
|
22
|
+
*
|
|
23
|
+
* Features:
|
|
24
|
+
* - Automatic directory creation
|
|
25
|
+
* - Batch operations for better performance
|
|
26
|
+
* - Comprehensive error handling with recovery suggestions
|
|
27
|
+
* - Import path resolution
|
|
28
|
+
* - File existence checks
|
|
29
|
+
*/
|
|
30
|
+
export declare class FileManager {
|
|
31
|
+
private readonly options;
|
|
32
|
+
private readonly logger;
|
|
33
|
+
private readonly pendingOperations;
|
|
34
|
+
constructor(options: FileManagerOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Write a file with automatic directory creation
|
|
37
|
+
* @param relativePath Path relative to output directory
|
|
38
|
+
* @param content File content
|
|
39
|
+
* @param options Write options
|
|
40
|
+
*/
|
|
41
|
+
writeFile(relativePath: string, content: string, options?: {
|
|
42
|
+
encoding?: BufferEncoding;
|
|
43
|
+
overwrite?: boolean;
|
|
44
|
+
}): Promise<WriteFileResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Write multiple files in batch for better performance
|
|
47
|
+
* @param files Map of relative path to content
|
|
48
|
+
*/
|
|
49
|
+
writeBatch(files: Map<string, string>): Promise<WriteFileResult[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Ensure directory exists, creating parent directories as needed
|
|
52
|
+
* @param dirPath Full directory path
|
|
53
|
+
*/
|
|
54
|
+
ensureDirectory(dirPath: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Clean directory by removing all contents
|
|
57
|
+
* @param relativePath Path relative to output directory
|
|
58
|
+
*/
|
|
59
|
+
cleanDirectory(relativePath?: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Get relative import path between two files
|
|
62
|
+
* @param fromFile Source file path
|
|
63
|
+
* @param toFile Target file path
|
|
64
|
+
*/
|
|
65
|
+
getRelativeImportPath(fromFile: string, toFile: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a file would be overwritten
|
|
68
|
+
* @param relativePath Path relative to output directory
|
|
69
|
+
*/
|
|
70
|
+
wouldOverwrite(relativePath: string): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* Get file statistics
|
|
73
|
+
* @param relativePath Path relative to output directory
|
|
74
|
+
*/
|
|
75
|
+
getFileStats(relativePath: string): Promise<FileStats | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Get output directory
|
|
78
|
+
*/
|
|
79
|
+
getOutputDirectory(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Set batch size for operations
|
|
82
|
+
* @param size Batch size
|
|
83
|
+
*/
|
|
84
|
+
setBatchSize(size: number): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get current batch size
|
|
87
|
+
*/
|
|
88
|
+
getBatchSize(): number;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=FileManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/FileManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;gBAEQ,OAAO,EAAE,kBAAkB;IASvC;;;;;OAKG;IACG,SAAS,CACd,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GAC9D,OAAO,CAAC,eAAe,CAAC;IAyD3B;;;OAGG;IACG,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAyBxE;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrD;;;OAGG;IACG,cAAc,CAAC,YAAY,GAAE,MAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB/D;;;;OAIG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAe/D;;;OAGG;IACG,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5D;;;OAGG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAcnE;;OAEG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACH,YAAY,IAAI,MAAM;CAGtB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handlebars-based template engine implementation
|
|
3
|
+
*/
|
|
4
|
+
import Handlebars from "handlebars";
|
|
5
|
+
import type { CodegenLogger } from "../../../utils/codegen-logger";
|
|
6
|
+
import { type TemplateContext, TemplateEngine, type TemplateOptions } from "./TemplateEngine";
|
|
7
|
+
export interface HandlebarsTemplateEngineOptions {
|
|
8
|
+
logger: CodegenLogger;
|
|
9
|
+
/** Directory containing template files */
|
|
10
|
+
templateDirectory?: string;
|
|
11
|
+
/** Whether to automatically load templates from directory */
|
|
12
|
+
autoLoadTemplates?: boolean;
|
|
13
|
+
/** Custom Handlebars options */
|
|
14
|
+
handlebarsOptions?: Handlebars.RuntimeOptions;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Handlebars template engine implementation
|
|
18
|
+
*/
|
|
19
|
+
export declare class HandlebarsTemplateEngine extends TemplateEngine {
|
|
20
|
+
private readonly handlebars;
|
|
21
|
+
private readonly options;
|
|
22
|
+
constructor(options: HandlebarsTemplateEngineOptions);
|
|
23
|
+
render(templateName: string, context: TemplateContext): Promise<string>;
|
|
24
|
+
registerTemplate(name: string, template: string | Function, options?: TemplateOptions): void;
|
|
25
|
+
loadTemplatesFromDirectory(directory: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get compiled template from cache or templates
|
|
28
|
+
*/
|
|
29
|
+
private getCompiledTemplate;
|
|
30
|
+
/**
|
|
31
|
+
* Setup Handlebars with custom helpers
|
|
32
|
+
*/
|
|
33
|
+
private setupHandlebars;
|
|
34
|
+
/**
|
|
35
|
+
* Discover template files in directory
|
|
36
|
+
*/
|
|
37
|
+
private discoverTemplateFiles;
|
|
38
|
+
/**
|
|
39
|
+
* Check if file is a template file
|
|
40
|
+
*/
|
|
41
|
+
private isTemplateFile;
|
|
42
|
+
/**
|
|
43
|
+
* Load a single template file
|
|
44
|
+
*/
|
|
45
|
+
private loadTemplateFile;
|
|
46
|
+
/**
|
|
47
|
+
* Extract template name from file path
|
|
48
|
+
*/
|
|
49
|
+
private getTemplateNameFromPath;
|
|
50
|
+
/**
|
|
51
|
+
* Find templates with similar names
|
|
52
|
+
*/
|
|
53
|
+
private findSimilarTemplates;
|
|
54
|
+
/**
|
|
55
|
+
* Calculate Levenshtein distance for template suggestions
|
|
56
|
+
*/
|
|
57
|
+
private levenshteinDistance;
|
|
58
|
+
}
|
|
59
|
+
export type { TemplateContext, TemplateOptions } from "./TemplateEngine";
|
|
60
|
+
//# sourceMappingURL=HandlebarsTemplateEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandlebarsTemplateEngine.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/HandlebarsTemplateEngine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,eAAe,EACpB,cAAc,EACd,KAAK,eAAe,EACpB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,+BAA+B;IAC/C,MAAM,EAAE,aAAa,CAAC;IAEtB,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,gCAAgC;IAChC,iBAAiB,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC;CAC9C;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;IAC3D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4C;gBAExD,OAAO,EAAE,+BAA+B;IAyB9C,MAAM,CACX,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAqClB,gBAAgB,CACf,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAC3B,OAAO,GAAE,eAAoB,GAC3B,IAAI;IAwCD,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmClE;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IA6EvB;;OAEG;YACW,qBAAqB;IA2BnC;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;YACW,gBAAgB;IAgB9B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAM/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAqB3B;AAGD,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python type mapper implementation (basic version)
|
|
3
|
+
*/
|
|
4
|
+
import type { TypeSchemaIdentifier } from "../../../typeschema";
|
|
5
|
+
import { type LanguageType, TypeMapper } from "./TypeMapper";
|
|
6
|
+
export declare class PythonTypeMapper extends TypeMapper {
|
|
7
|
+
getLanguageName(): string;
|
|
8
|
+
mapPrimitive(fhirType: string): LanguageType;
|
|
9
|
+
mapReference(targets: TypeSchemaIdentifier[]): LanguageType;
|
|
10
|
+
mapArray(elementType: LanguageType): LanguageType;
|
|
11
|
+
mapOptional(type: LanguageType, required: boolean): LanguageType;
|
|
12
|
+
mapEnum(values: string[], name?: string): LanguageType;
|
|
13
|
+
formatTypeName(name: string): string;
|
|
14
|
+
formatFieldName(name: string): string;
|
|
15
|
+
formatFileName(name: string): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=PythonTypeMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PythonTypeMapper.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/PythonTypeMapper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,qBAAa,gBAAiB,SAAQ,UAAU;IAC/C,eAAe,IAAI,MAAM;IAIzB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY;IAkB5C,YAAY,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,YAAY;IAS3D,QAAQ,CAAC,WAAW,EAAE,YAAY,GAAG,YAAY;IAUjD,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAG,YAAY;IAUhE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;IAQtD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIpC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQrC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAGpC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract template engine for code generation
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple template formats:
|
|
5
|
+
* - Handlebars templates (.hbs)
|
|
6
|
+
* - String templates (.template)
|
|
7
|
+
* - Function templates (TypeScript functions)
|
|
8
|
+
* - Inline templates (template literals)
|
|
9
|
+
*/
|
|
10
|
+
import type { CodegenLogger } from "../../../utils/codegen-logger";
|
|
11
|
+
/**
|
|
12
|
+
* Template context passed to templates
|
|
13
|
+
*/
|
|
14
|
+
export interface TemplateContext {
|
|
15
|
+
/** The schema being processed */
|
|
16
|
+
schema?: any;
|
|
17
|
+
/** Type mapper for language-specific types */
|
|
18
|
+
typeMapper?: any;
|
|
19
|
+
/** File name being generated */
|
|
20
|
+
filename?: string;
|
|
21
|
+
/** Target language */
|
|
22
|
+
language?: string;
|
|
23
|
+
/** Timestamp for generation */
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
/** Import statements */
|
|
26
|
+
imports?: Map<string, string>;
|
|
27
|
+
/** Export names */
|
|
28
|
+
exports?: Set<string>;
|
|
29
|
+
/** Any additional context */
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Template registration options
|
|
34
|
+
*/
|
|
35
|
+
export interface TemplateOptions {
|
|
36
|
+
/** Template format */
|
|
37
|
+
format?: "handlebars" | "string" | "function";
|
|
38
|
+
/** Whether to cache compiled templates */
|
|
39
|
+
cache?: boolean;
|
|
40
|
+
/** Custom helpers for the template */
|
|
41
|
+
helpers?: Record<string, Function>;
|
|
42
|
+
/** Template-specific options */
|
|
43
|
+
options?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Template metadata
|
|
47
|
+
*/
|
|
48
|
+
export interface TemplateInfo {
|
|
49
|
+
name: string;
|
|
50
|
+
format: string;
|
|
51
|
+
path?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
examples?: Array<{
|
|
54
|
+
context: TemplateContext;
|
|
55
|
+
expected: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Abstract template engine
|
|
60
|
+
*/
|
|
61
|
+
export declare abstract class TemplateEngine {
|
|
62
|
+
protected readonly logger: CodegenLogger;
|
|
63
|
+
protected readonly templates: Map<string, any>;
|
|
64
|
+
protected readonly templateCache: Map<string, any>;
|
|
65
|
+
protected readonly helpers: Map<string, Function>;
|
|
66
|
+
constructor(options: {
|
|
67
|
+
logger: CodegenLogger;
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Render a template with context
|
|
71
|
+
* @param templateName Name of template to render
|
|
72
|
+
* @param context Template context
|
|
73
|
+
*/
|
|
74
|
+
abstract render(templateName: string, context: TemplateContext): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Register a template
|
|
77
|
+
* @param name Template name
|
|
78
|
+
* @param template Template content or function
|
|
79
|
+
* @param options Template options
|
|
80
|
+
*/
|
|
81
|
+
abstract registerTemplate(name: string, template: string | Function, options?: TemplateOptions): void;
|
|
82
|
+
/**
|
|
83
|
+
* Load templates from directory
|
|
84
|
+
* @param directory Directory containing templates
|
|
85
|
+
*/
|
|
86
|
+
abstract loadTemplatesFromDirectory(directory: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Register a template helper function
|
|
89
|
+
* @param name Helper name
|
|
90
|
+
* @param helper Helper function
|
|
91
|
+
*/
|
|
92
|
+
registerHelper(name: string, helper: Function): void;
|
|
93
|
+
/**
|
|
94
|
+
* Get available template names
|
|
95
|
+
*/
|
|
96
|
+
getAvailableTemplates(): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Get template information
|
|
99
|
+
* @param templateName Template name
|
|
100
|
+
*/
|
|
101
|
+
getTemplateInfo(templateName: string): TemplateInfo | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Check if template exists
|
|
104
|
+
* @param templateName Template name
|
|
105
|
+
*/
|
|
106
|
+
hasTemplate(templateName: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Remove a template
|
|
109
|
+
* @param templateName Template name
|
|
110
|
+
*/
|
|
111
|
+
unregisterTemplate(templateName: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Clear all templates and cache
|
|
114
|
+
*/
|
|
115
|
+
clearTemplates(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Validate template context
|
|
118
|
+
* @param context Template context
|
|
119
|
+
* @param requiredFields Required context fields
|
|
120
|
+
*/
|
|
121
|
+
protected validateContext(context: TemplateContext, requiredFields?: string[]): void;
|
|
122
|
+
/**
|
|
123
|
+
* Register default template helpers
|
|
124
|
+
*/
|
|
125
|
+
protected registerDefaultHelpers(): void;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=TemplateEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEngine.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/TemplateEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,iCAAiC;IACjC,MAAM,CAAC,EAAE,GAAG,CAAC;IAEb,8CAA8C;IAC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QAAQ,CAAC,OAAO,wBAA+B;gBAE7C,OAAO,EAAE;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE;IAS9C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CACd,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAC3B,OAAO,CAAC,EAAE,eAAe,GACvB,IAAI;IAEP;;;OAGG;IACH,QAAQ,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAKpD;;OAEG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;;OAGG;IACH,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAa/D;;;OAGG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAI1C;;;OAGG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IASjD;;OAEG;IACH,cAAc,IAAI,IAAI;IAMtB;;;;OAIG;IACH,SAAS,CAAC,eAAe,CACxB,OAAO,EAAE,eAAe,EACxB,cAAc,GAAE,MAAM,EAAO,GAC3B,IAAI;IAgBP;;OAEG;IACH,SAAS,CAAC,sBAAsB,IAAI,IAAI;CAwDxC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for language-specific type mapping
|
|
3
|
+
*
|
|
4
|
+
* This provides the interface that all language generators must implement
|
|
5
|
+
* to convert FHIR TypeSchema types into their target language types.
|
|
6
|
+
*/
|
|
7
|
+
import type { TypeSchemaIdentifier } from "../../../typeschema";
|
|
8
|
+
/**
|
|
9
|
+
* Represents a type in the target language
|
|
10
|
+
*/
|
|
11
|
+
export interface LanguageType {
|
|
12
|
+
/** The type name in the target language */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Whether this is a primitive type (doesn't need imports) */
|
|
15
|
+
isPrimitive: boolean;
|
|
16
|
+
/** Import path if this type needs to be imported */
|
|
17
|
+
importPath?: string;
|
|
18
|
+
/** Generic type parameters if applicable */
|
|
19
|
+
generics?: string[];
|
|
20
|
+
/** Whether this type can be null/undefined */
|
|
21
|
+
nullable?: boolean;
|
|
22
|
+
/** Whether this is an array type */
|
|
23
|
+
isArray?: boolean;
|
|
24
|
+
/** Additional metadata for language-specific features */
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for type mapping behavior
|
|
29
|
+
*/
|
|
30
|
+
export interface TypeMapperOptions {
|
|
31
|
+
/** Whether to generate nullable types (e.g., T | null) */
|
|
32
|
+
generateNullable?: boolean;
|
|
33
|
+
/** Whether to use strict type checking */
|
|
34
|
+
strictTypes?: boolean;
|
|
35
|
+
/** Custom type mappings */
|
|
36
|
+
customMappings?: Record<string, string>;
|
|
37
|
+
/** Whether to generate array types or use generic collections */
|
|
38
|
+
preferArraySyntax?: boolean;
|
|
39
|
+
/** Naming convention strategy */
|
|
40
|
+
namingConvention?: "camelCase" | "PascalCase" | "snake_case" | "kebab-case";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Abstract type mapper for language-specific type conversion
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class TypeMapper {
|
|
46
|
+
protected readonly options: Required<TypeMapperOptions>;
|
|
47
|
+
constructor(options?: TypeMapperOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Get the target language name (e.g., "TypeScript", "Python")
|
|
50
|
+
*/
|
|
51
|
+
abstract getLanguageName(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Map a FHIR primitive type to target language
|
|
54
|
+
* @param fhirType FHIR primitive type (string, integer, boolean, etc.)
|
|
55
|
+
*/
|
|
56
|
+
abstract mapPrimitive(fhirType: string): LanguageType;
|
|
57
|
+
/**
|
|
58
|
+
* Map a reference type to target language
|
|
59
|
+
* @param targets Array of possible reference targets
|
|
60
|
+
*/
|
|
61
|
+
abstract mapReference(targets: TypeSchemaIdentifier[]): LanguageType;
|
|
62
|
+
/**
|
|
63
|
+
* Map an array type to target language
|
|
64
|
+
* @param elementType The type of array elements
|
|
65
|
+
*/
|
|
66
|
+
abstract mapArray(elementType: LanguageType): LanguageType;
|
|
67
|
+
/**
|
|
68
|
+
* Map an optional/nullable type
|
|
69
|
+
* @param type The base type
|
|
70
|
+
* @param required Whether the field is required
|
|
71
|
+
*/
|
|
72
|
+
abstract mapOptional(type: LanguageType, required: boolean): LanguageType;
|
|
73
|
+
/**
|
|
74
|
+
* Map an enum/coded type
|
|
75
|
+
* @param values Possible enum values
|
|
76
|
+
* @param name Optional enum name
|
|
77
|
+
*/
|
|
78
|
+
abstract mapEnum(values: string[], name?: string): LanguageType;
|
|
79
|
+
/**
|
|
80
|
+
* Format a type name according to language conventions
|
|
81
|
+
* @param name Raw type name
|
|
82
|
+
*/
|
|
83
|
+
abstract formatTypeName(name: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Format a field name according to language conventions
|
|
86
|
+
* @param name Raw field name
|
|
87
|
+
*/
|
|
88
|
+
abstract formatFieldName(name: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Format a file name according to language conventions
|
|
91
|
+
* @param name Raw file name (without extension)
|
|
92
|
+
*/
|
|
93
|
+
abstract formatFileName(name: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Main entry point for type mapping
|
|
96
|
+
* @param schemaType Type from TypeSchema
|
|
97
|
+
*/
|
|
98
|
+
mapType(schemaType: any): LanguageType;
|
|
99
|
+
/**
|
|
100
|
+
* Map a complex type (resource, complex-type)
|
|
101
|
+
* @param schemaType Complex type from schema
|
|
102
|
+
*/
|
|
103
|
+
protected mapComplexType(schemaType: any): LanguageType;
|
|
104
|
+
/**
|
|
105
|
+
* Handle unknown/unmapped types
|
|
106
|
+
* @param schemaType Unknown type
|
|
107
|
+
*/
|
|
108
|
+
protected mapUnknownType(schemaType: any): LanguageType;
|
|
109
|
+
/**
|
|
110
|
+
* Calculate import path for a type
|
|
111
|
+
* @param schemaType Type to calculate import for
|
|
112
|
+
*/
|
|
113
|
+
protected calculateImportPath(schemaType: any): string | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Apply naming convention to a string
|
|
116
|
+
* @param name Input name
|
|
117
|
+
*/
|
|
118
|
+
protected applyNamingConvention(name: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Get custom mapping if available
|
|
121
|
+
* @param type Original type name
|
|
122
|
+
*/
|
|
123
|
+
protected getCustomMapping(type: string): string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Check if type should be nullable
|
|
126
|
+
* @param required Whether field is required
|
|
127
|
+
*/
|
|
128
|
+
protected shouldBeNullable(required: boolean): boolean;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=TypeMapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeMapper.d.ts","sourceRoot":"","sources":["../../../../src/api/generators/base/TypeMapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAc,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IAEb,8DAA8D;IAC9D,WAAW,EAAE,OAAO,CAAC;IAErB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,yDA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