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

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 +48 -124
  2. package/dist/index.d.ts +2121 -62
  3. package/dist/index.js +6076 -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,99 +0,0 @@
1
- /**
2
- * Base Generator Public API
3
- *
4
- * This is the main entry point for the base generator system.
5
- * Import from here to access all base generator functionality with
6
- * clean, well-organized exports.
7
- */
8
- export { BaseGenerator } from "./BaseGenerator";
9
- export { PythonTypeMapper } from "./PythonTypeMapper";
10
- export type { TypeMapperOptions } from "./TypeMapper";
11
- export { TypeMapper } from "./TypeMapper";
12
- export type { TypeScriptTypeMapperOptions } from "./TypeScriptTypeMapper";
13
- export { TypeScriptTypeMapper } from "./TypeScriptTypeMapper";
14
- export type { ConfigValidationResult, GeneratorCapabilities, LanguageType, TemplateContext, } from "./types";
15
- export type { BaseGeneratorOptions, FileBuilderOptions } from "./types";
16
- export type { DirectoryBuilderConfig } from "./builders/DirectoryBuilder";
17
- export { DirectoryBuilder } from "./builders/DirectoryBuilder";
18
- export type { FileBuilderConfig } from "./builders/FileBuilder";
19
- export { FileBuilder } from "./builders/FileBuilder";
20
- export type { IndexBuilderConfig } from "./builders/IndexBuilder";
21
- export { IndexBuilder } from "./builders/IndexBuilder";
22
- export type { FileManagerOptions, WriteFileResult } from "./FileManager";
23
- export { FileManager } from "./FileManager";
24
- export { BatchOperationError, ConfigurationError, createErrorWithContext, FileOperationError, GeneratorError, SchemaValidationError, TemplateError, TypeMappingError, } from "./errors";
25
- export type { AfterSaveHook, BatchResult, BeforeSaveHook, ErrorHook, FileContext, FileStats, GeneratedFile, ProgressCallback, } from "./types";
26
- export type { Identifier, TypeSchema } from "@typeschema/index";
27
- export type { CodegenLogger } from "../../../utils/codegen-logger";
28
- /**
29
- * Helper type for creating generator options with language-specific extensions
30
- *
31
- * @example
32
- * ```typescript
33
- * interface TypeScriptOptions extends GeneratorOptions<{
34
- * moduleFormat: 'esm' | 'cjs';
35
- * generateIndex: boolean;
36
- * }> {}
37
- * ```
38
- */
39
- export type GeneratorOptions<TExtensions = Record<string, unknown>> = import("./types").BaseGeneratorOptions & TExtensions;
40
- /**
41
- * Helper type for generator result arrays
42
- * Useful for typing the return value of generate() methods
43
- */
44
- export type GeneratorResult = import("./types").GeneratedFile[];
45
- /**
46
- * Helper type for async generator functions
47
- */
48
- export type AsyncGenerator<TOptions extends import("./types").BaseGeneratorOptions, TResult extends import("./types").GeneratedFile[]> = (options: TOptions) => Promise<TResult>;
49
- /**
50
- * Type guard to check if an object is a GeneratedFile
51
- */
52
- export declare function isGeneratedFile(obj: unknown): obj is import("./types").GeneratedFile;
53
- /**
54
- * Type guard to check if an error is a GeneratorError
55
- */
56
- export declare function isGeneratorError(error: unknown): error is import("./errors").GeneratorError;
57
- /**
58
- * Base generator system version
59
- * Updated automatically during build process
60
- */
61
- export declare const VERSION = "1.0.0";
62
- /**
63
- * Supported TypeSchema version
64
- */
65
- export declare const SUPPORTED_TYPESCHEMA_VERSION = "1.0.0";
66
- /**
67
- * Create a development logger for testing
68
- * @param prefix - Logger prefix
69
- * @param verbose - Enable verbose logging
70
- */
71
- export declare function createDevLogger(prefix?: string, verbose?: boolean): any;
72
- /**
73
- * Validate generator options before instantiation
74
- * @param options - Options to validate
75
- * @returns Validation result with errors and suggestions
76
- */
77
- export declare function validateGeneratorOptions(options: import("./types").BaseGeneratorOptions): import("./types").ConfigValidationResult;
78
- /**
79
- * Default generator options
80
- */
81
- export declare const DEFAULT_GENERATOR_OPTIONS: Partial<import("./types").BaseGeneratorOptions>;
82
- /**
83
- * Maximum recommended batch size for schema processing
84
- */
85
- export declare const MAX_BATCH_SIZE = 50;
86
- /**
87
- * Default file builder options
88
- */
89
- export declare const DEFAULT_FILE_BUILDER_OPTIONS: Partial<import("./types").FileBuilderOptions>;
90
- /**
91
- * @deprecated Use BaseGenerator instead
92
- * Provided for backwards compatibility only
93
- */
94
- export { BaseGenerator as Generator } from "./BaseGenerator";
95
- /**
96
- * @deprecated Use GeneratorError instead
97
- * Provided for backwards compatibility only
98
- */
99
- export { GeneratorError as BaseError } from "./errors";
@@ -1,160 +0,0 @@
1
- /**
2
- * Base Generator Public API
3
- *
4
- * This is the main entry point for the base generator system.
5
- * Import from here to access all base generator functionality with
6
- * clean, well-organized exports.
7
- */
8
- // ==========================================
9
- // Core Base Generator System
10
- // ==========================================
11
- // Main base generator class
12
- export { BaseGenerator } from "./BaseGenerator";
13
- export { PythonTypeMapper } from "./PythonTypeMapper";
14
- // Type system and mapping
15
- export { TypeMapper } from "./TypeMapper";
16
- export { TypeScriptTypeMapper } from "./TypeScriptTypeMapper";
17
- export { DirectoryBuilder } from "./builders/DirectoryBuilder";
18
- // Fluent builders
19
- export { FileBuilder } from "./builders/FileBuilder";
20
- export { IndexBuilder } from "./builders/IndexBuilder";
21
- // Core file management
22
- export { FileManager } from "./FileManager";
23
- // ==========================================
24
- // Error Handling System
25
- // ==========================================
26
- // All error classes for comprehensive error handling
27
- export { BatchOperationError, ConfigurationError, createErrorWithContext, FileOperationError, GeneratorError, SchemaValidationError, TemplateError, TypeMappingError, } from "./errors";
28
- /**
29
- * Type guard to check if an object is a GeneratedFile
30
- */
31
- export function isGeneratedFile(obj) {
32
- return (typeof obj === "object" &&
33
- obj !== null &&
34
- "path" in obj &&
35
- "filename" in obj &&
36
- "content" in obj &&
37
- "exports" in obj &&
38
- "size" in obj &&
39
- "timestamp" in obj);
40
- }
41
- /**
42
- * Type guard to check if an error is a GeneratorError
43
- */
44
- export function isGeneratorError(error) {
45
- const { GeneratorError } = require("./errors");
46
- return error instanceof GeneratorError;
47
- }
48
- // ==========================================
49
- // Version Information
50
- // ==========================================
51
- /**
52
- * Base generator system version
53
- * Updated automatically during build process
54
- */
55
- export const VERSION = "1.0.0";
56
- /**
57
- * Supported TypeSchema version
58
- */
59
- export const SUPPORTED_TYPESCHEMA_VERSION = "1.0.0";
60
- // ==========================================
61
- // Development Utilities
62
- // ==========================================
63
- /**
64
- * Create a development logger for testing
65
- * @param prefix - Logger prefix
66
- * @param verbose - Enable verbose logging
67
- */
68
- export function createDevLogger(prefix = "Dev", verbose = true) {
69
- const { createLogger } = require("../../../utils/codegen-logger");
70
- return createLogger({ prefix, verbose });
71
- }
72
- /**
73
- * Validate generator options before instantiation
74
- * @param options - Options to validate
75
- * @returns Validation result with errors and suggestions
76
- */
77
- export function validateGeneratorOptions(options) {
78
- const errors = [];
79
- const warnings = [];
80
- const suggestions = [];
81
- // Required field validation
82
- if (!options.outputDir) {
83
- errors.push("outputDir is required");
84
- suggestions.push("Provide a valid output directory path");
85
- }
86
- // Type validation
87
- if (options.outputDir && typeof options.outputDir !== "string") {
88
- errors.push("outputDir must be a string");
89
- }
90
- if (options.overwrite !== undefined && typeof options.overwrite !== "boolean") {
91
- errors.push("overwrite must be a boolean");
92
- }
93
- if (options.validate !== undefined && typeof options.validate !== "boolean") {
94
- errors.push("validate must be a boolean");
95
- }
96
- // Path validation (only if outputDir is a valid string)
97
- if (options.outputDir && typeof options.outputDir === "string") {
98
- const path = require("node:path");
99
- if (!path.isAbsolute(options.outputDir)) {
100
- warnings.push("Using relative path for outputDir - consider using absolute path");
101
- suggestions.push("Use path.resolve() to convert to absolute path");
102
- }
103
- }
104
- // Performance warnings
105
- if (options.validate === false) {
106
- warnings.push("Validation is disabled - this may lead to invalid generated code");
107
- suggestions.push("Consider enabling validation for better code quality");
108
- }
109
- return {
110
- isValid: errors.length === 0,
111
- errors,
112
- warnings,
113
- suggestions,
114
- };
115
- }
116
- // ==========================================
117
- // Constants and Defaults
118
- // ==========================================
119
- /**
120
- * Default generator options
121
- */
122
- export const DEFAULT_GENERATOR_OPTIONS = {
123
- outputDir: "./generated",
124
- overwrite: true,
125
- validate: true,
126
- verbose: false,
127
- beginnerMode: false,
128
- errorFormat: "console",
129
- };
130
- /**
131
- * Maximum recommended batch size for schema processing
132
- */
133
- export const MAX_BATCH_SIZE = 50;
134
- /**
135
- * Default file builder options
136
- */
137
- export const DEFAULT_FILE_BUILDER_OPTIONS = {
138
- importStrategy: "auto",
139
- validation: "strict",
140
- prettify: true,
141
- formatting: {
142
- indentSize: 2,
143
- useTabs: false,
144
- maxLineLength: 100,
145
- },
146
- encoding: "utf-8",
147
- };
148
- // ==========================================
149
- // Backwards Compatibility
150
- // ==========================================
151
- /**
152
- * @deprecated Use BaseGenerator instead
153
- * Provided for backwards compatibility only
154
- */
155
- export { BaseGenerator as Generator } from "./BaseGenerator";
156
- /**
157
- * @deprecated Use GeneratorError instead
158
- * Provided for backwards compatibility only
159
- */
160
- export { GeneratorError as BaseError } from "./errors";
@@ -1,433 +0,0 @@
1
- /**
2
- * Core types and interfaces for the base generator system
3
- *
4
- * This module provides the foundational type definitions that all generators
5
- * build upon, ensuring consistency and type safety across the system.
6
- */
7
- import type { Identifier, TypeSchema } from "@typeschema/index";
8
- import type { CodegenLogger } from "../../../utils/codegen-logger";
9
- /**
10
- * Base configuration options that all generators must support
11
- * These options provide the minimum required configuration for any generator
12
- */
13
- export interface BaseGeneratorOptions {
14
- /** Output directory where generated files will be written */
15
- outputDir: string;
16
- /** Logger instance for tracking generation progress and errors */
17
- logger?: CodegenLogger;
18
- /** Whether to overwrite existing files (default: true) */
19
- overwrite?: boolean;
20
- /** Whether to validate schemas and generated content (default: true) */
21
- validate?: boolean;
22
- /** Enable detailed logging for debugging (default: false) */
23
- verbose?: boolean;
24
- /** Enable beginner-friendly error messages and guidance (default: false) */
25
- beginnerMode?: boolean;
26
- /** Format for error output: console, json, or structured (default: 'console') */
27
- errorFormat?: "console" | "json" | "structured";
28
- }
29
- /**
30
- * Language-specific type representation
31
- * This interface standardizes how FHIR types are mapped to target languages
32
- */
33
- export interface LanguageType {
34
- /** The type string in the target language (e.g., "string", "number", "Patient") */
35
- name: string;
36
- /** Whether this is a primitive type that doesn't need imports */
37
- isPrimitive: boolean;
38
- /** Import path if this type needs to be imported from another module */
39
- importPath?: string;
40
- /** Generic parameters if this is a generic type (e.g., ["T", "K"] for Map<T,K>) */
41
- generics?: string[];
42
- /** Whether this type is nullable/optional in the target language */
43
- nullable?: boolean;
44
- /** Additional metadata specific to the target language */
45
- metadata?: Record<string, unknown>;
46
- }
47
- /**
48
- * Generated file metadata and content
49
- * Represents a single generated file with all its associated information
50
- */
51
- export interface GeneratedFile {
52
- /** Full file system path where the file was/will be written */
53
- path: string;
54
- /** Filename only (without directory path) */
55
- filename: string;
56
- /** The generated content of the file */
57
- content: string;
58
- /** List of symbols exported from this file */
59
- exports: string[];
60
- /** File size in bytes */
61
- size: number;
62
- /** When this file was generated */
63
- timestamp: Date;
64
- /** Additional metadata about the generation process */
65
- metadata?: {
66
- /** Time taken to generate this file in milliseconds */
67
- generationTime?: number;
68
- /** Number of schemas processed for this file */
69
- schemaCount?: number;
70
- /** Template used to generate this file */
71
- templateName?: string;
72
- /** Any warnings generated during processing */
73
- warnings?: string[];
74
- };
75
- }
76
- /**
77
- * Template context provided to template engines
78
- * Contains all the data needed to render templates for code generation
79
- */
80
- export interface TemplateContext {
81
- /** The schema being processed */
82
- schema: TypeSchema;
83
- /** Type mapper for the target language */
84
- typeMapper: TypeMapper;
85
- /** Current file being generated */
86
- filename: string;
87
- /** Target language name (e.g., "TypeScript", "Python") */
88
- language: string;
89
- /** Generation timestamp in ISO format */
90
- timestamp: string;
91
- /** Import map for the current file */
92
- imports?: Map<string, string>;
93
- /** Export set for the current file */
94
- exports?: Set<string>;
95
- /** Additional context data that templates can use */
96
- [key: string]: unknown;
97
- }
98
- /**
99
- * File builder context passed to lifecycle hooks
100
- * Provides access to file generation state during the build process
101
- */
102
- export interface FileContext {
103
- /** Name of the file being generated */
104
- filename: string;
105
- /** Current file content */
106
- content: string;
107
- /** Map of imports (symbol name -> import path) */
108
- imports: Map<string, string>;
109
- /** Set of exported symbols */
110
- exports: Set<string>;
111
- /** Additional metadata about the file */
112
- metadata: Record<string, unknown>;
113
- /** The schema that generated this file (if applicable) */
114
- schema?: TypeSchema;
115
- /** Template name used to generate this file (if applicable) */
116
- templateName?: string;
117
- }
118
- /**
119
- * Statistics about file operations
120
- * Used for performance monitoring and optimization
121
- */
122
- export interface FileStats {
123
- /** File size in bytes */
124
- size: number;
125
- /** Time taken to generate content in milliseconds */
126
- generationTime: number;
127
- /** Time taken to write to disk in milliseconds */
128
- writeTime: number;
129
- /** Memory used during generation in bytes */
130
- memoryUsed?: number;
131
- /** Number of template renders performed */
132
- templateRenders?: number;
133
- }
134
- /**
135
- * Progress callback signature for monitoring generation
136
- * Allows consumers to track progress of long-running operations
137
- */
138
- export type ProgressCallback = (
139
- /** Current phase of generation */
140
- phase: "validation" | "generation" | "writing" | "complete",
141
- /** Current item number being processed */
142
- current: number,
143
- /** Total number of items to process */
144
- total: number,
145
- /** Optional message describing current operation */
146
- message?: string,
147
- /** Schema being processed (if applicable) */
148
- schema?: TypeSchema) => void;
149
- /**
150
- * Lifecycle hook signatures for file operations
151
- * These hooks allow customization of the file generation process
152
- */
153
- /** Hook called before saving a file - can modify content or abort save */
154
- export type BeforeSaveHook = (context: FileContext) => void | Promise<void>;
155
- /** Hook called after successfully saving a file */
156
- export type AfterSaveHook = (filePath: string, stats: FileStats) => void | Promise<void>;
157
- /** Hook called when an error occurs during file operations */
158
- export type ErrorHook = (error: Error, context: FileContext) => void | Promise<void>;
159
- /**
160
- * File builder configuration options
161
- * Controls how files are generated and processed
162
- */
163
- export interface FileBuilderOptions {
164
- /** Template name to use for content generation */
165
- template?: string;
166
- /** Strategy for resolving import paths */
167
- importStrategy?: "auto" | "manual" | "none";
168
- /** Level of content validation to perform */
169
- validation?: "strict" | "loose" | "none";
170
- /** Enable pretty printing of generated content */
171
- prettify?: boolean;
172
- /** Custom formatting options */
173
- formatting?: {
174
- /** Number of spaces for indentation (default: 2) */
175
- indentSize?: number;
176
- /** Use tabs instead of spaces (default: false) */
177
- useTabs?: boolean;
178
- /** Maximum line length before wrapping (default: 100) */
179
- maxLineLength?: number;
180
- };
181
- /** File encoding (default: 'utf-8') */
182
- encoding?: BufferEncoding;
183
- }
184
- /**
185
- * Abstract base class for type mapping between FHIR and target languages
186
- * Each language-specific generator must implement this interface
187
- */
188
- export declare abstract class TypeMapper {
189
- /**
190
- * Map a FHIR primitive type to the target language
191
- * @param fhirType - FHIR primitive type name (e.g., "string", "integer")
192
- * @returns Language-specific type representation
193
- */
194
- abstract mapPrimitive(fhirType: string): LanguageType;
195
- /**
196
- * Map a FHIR reference to the target language
197
- * @param targets - Array of possible reference targets
198
- * @returns Language-specific reference type
199
- */
200
- abstract mapReference(targets: Identifier[]): LanguageType;
201
- /**
202
- * Map an array type in the target language
203
- * @param elementType - The element type name
204
- * @returns Language-specific array type
205
- */
206
- abstract mapArray(elementType: string): LanguageType;
207
- /**
208
- * Map optional/nullable types
209
- * @param type - The base type
210
- * @param required - Whether the field is required
211
- * @returns Language-specific optional type
212
- */
213
- abstract mapOptional(type: string, required: boolean): LanguageType;
214
- /**
215
- * Map enumerated values to the target language
216
- * @param values - Array of possible values
217
- * @param name - Optional name for the enum type
218
- * @returns Language-specific enum type
219
- */
220
- abstract mapEnum(values: string[], name?: string): LanguageType;
221
- /**
222
- * Format a FHIR type name according to target language conventions
223
- * @param name - FHIR type name
224
- * @returns Formatted type name
225
- */
226
- abstract formatTypeName(name: string): string;
227
- /**
228
- * Format a field name according to target language conventions
229
- * @param name - FHIR field name
230
- * @returns Formatted field name
231
- */
232
- abstract formatFieldName(name: string): string;
233
- /**
234
- * Format a filename according to target language conventions
235
- * @param name - Base filename
236
- * @returns Formatted filename (without extension)
237
- */
238
- abstract formatFileName(name: string): string;
239
- /**
240
- * Map a complete TypeSchema identifier to target language type
241
- * @param identifier - FHIR type identifier
242
- * @returns Language-specific type representation
243
- */
244
- abstract mapType(identifier: Identifier): LanguageType;
245
- /**
246
- * Get import statement format for the target language
247
- * @param symbols - Symbols to import
248
- * @param from - Module to import from
249
- * @returns Formatted import statement
250
- */
251
- formatImport?(symbols: string[], from: string): string;
252
- /**
253
- * Get export statement format for the target language
254
- * @param symbols - Symbols to export
255
- * @returns Formatted export statement
256
- */
257
- formatExport?(symbols: string[]): string;
258
- }
259
- /**
260
- * Directory builder configuration
261
- * Used for batch directory operations
262
- */
263
- export interface DirectoryBuilderConfig {
264
- /** Directory path relative to output directory */
265
- path: string;
266
- /** File manager instance for file operations */
267
- fileManager: any;
268
- /** Logger for directory operations */
269
- logger: CodegenLogger;
270
- /** Whether to clean directory before creating files */
271
- clean?: boolean;
272
- }
273
- /**
274
- * Index builder configuration
275
- * Used for generating index/barrel files
276
- */
277
- export interface IndexBuilderConfig {
278
- /** Directory to create index for */
279
- directory: string;
280
- /** File manager instance */
281
- fileManager: any;
282
- /** Template engine for rendering index files */
283
- templateEngine: any;
284
- /** Logger instance */
285
- logger: CodegenLogger;
286
- /** Header to include in index file */
287
- header?: string;
288
- /** Footer to include in index file */
289
- footer?: string;
290
- }
291
- /**
292
- * Batch operation result
293
- * Used for tracking results of operations on multiple items
294
- */
295
- export interface BatchResult<T> {
296
- /** Successful results */
297
- successes: T[];
298
- /** Failed operations with their errors */
299
- failures: Array<{
300
- /** The item that failed */
301
- item: unknown;
302
- /** The error that occurred */
303
- error: Error;
304
- /** Index of the failed item */
305
- index: number;
306
- }>;
307
- /** Total number of items processed */
308
- total: number;
309
- /** Time taken for the entire batch operation */
310
- duration: number;
311
- }
312
- /**
313
- * Template engine interface
314
- * Abstraction for different template engines (Handlebars, etc.)
315
- */
316
- export interface TemplateEngine {
317
- /**
318
- * Render a template with the given context
319
- * @param templateName - Name of the template to render
320
- * @param context - Data to pass to the template
321
- * @returns Rendered content
322
- */
323
- render(templateName: string, context: Record<string, unknown>): string;
324
- /**
325
- * Register a template
326
- * @param name - Template name
327
- * @param template - Template content or compiled template
328
- */
329
- registerTemplate(name: string, template: string | ((...args: any[]) => any)): void;
330
- /**
331
- * Register a helper function
332
- * @param name - Helper name
333
- * @param helper - Helper function
334
- */
335
- registerHelper(name: string, helper: (...args: any[]) => any): void;
336
- /**
337
- * Check if a template exists
338
- * @param name - Template name
339
- * @returns True if template exists
340
- */
341
- hasTemplate(name: string): boolean;
342
- /**
343
- * Get list of available templates
344
- * @returns Array of template names
345
- */
346
- getAvailableTemplates(): string[];
347
- }
348
- /**
349
- * File manager interface
350
- * Abstraction for file system operations
351
- */
352
- export interface FileManager {
353
- /**
354
- * Write a file with automatic directory creation
355
- * @param relativePath - Path relative to output directory
356
- * @param content - File content
357
- * @param options - Write options
358
- * @returns Write result with path and stats
359
- */
360
- writeFile(relativePath: string, content: string, options?: {
361
- encoding?: BufferEncoding;
362
- overwrite?: boolean;
363
- }): Promise<{
364
- path: string;
365
- size: number;
366
- writeTime: number;
367
- }>;
368
- /**
369
- * Write multiple files in batch
370
- * @param files - Map of path to content
371
- * @returns Array of write results
372
- */
373
- writeBatch(files: Map<string, string>): Promise<Array<{
374
- path: string;
375
- size: number;
376
- writeTime: number;
377
- }>>;
378
- /**
379
- * Ensure directory exists
380
- * @param dirPath - Directory path
381
- */
382
- ensureDirectory(dirPath: string): Promise<void>;
383
- /**
384
- * Clean directory contents
385
- * @param relativePath - Path relative to output directory
386
- */
387
- cleanDirectory(relativePath?: string): Promise<void>;
388
- /**
389
- * Get relative import path between files
390
- * @param fromFile - Source file
391
- * @param toFile - Target file
392
- * @returns Relative import path
393
- */
394
- getRelativeImportPath(fromFile: string, toFile: string): string;
395
- }
396
- /**
397
- * Generator configuration validation result
398
- * Used to validate generator options before initialization
399
- */
400
- export interface ConfigValidationResult {
401
- /** Whether the configuration is valid */
402
- isValid: boolean;
403
- /** Validation errors if any */
404
- errors: string[];
405
- /** Non-fatal warnings */
406
- warnings: string[];
407
- /** Suggested fixes for invalid configuration */
408
- suggestions: string[];
409
- }
410
- /**
411
- * Generator capabilities interface
412
- * Describes what a generator can do - used for introspection
413
- */
414
- export interface GeneratorCapabilities {
415
- /** Programming language this generator targets */
416
- language: string;
417
- /** File extensions this generator produces */
418
- fileExtensions: string[];
419
- /** Whether this generator supports templates */
420
- supportsTemplates: boolean;
421
- /** Whether this generator supports custom type mapping */
422
- supportsCustomTypeMapping: boolean;
423
- /** Whether this generator supports incremental generation */
424
- supportsIncrementalGeneration: boolean;
425
- /** Whether this generator supports validation */
426
- supportsValidation: boolean;
427
- /** Supported schema kinds */
428
- supportedSchemaKinds: Array<"resource" | "complex-type" | "profile" | "primitive-type" | "logical">;
429
- /** Version of the generator */
430
- version: string;
431
- /** Additional metadata about capabilities */
432
- metadata?: Record<string, unknown>;
433
- }