@atomic-ehr/codegen 0.0.1-canary.20251006094042.7f0be72 → 0.0.1-canary.20251007114955.88a8afc
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/cli/index.js +22 -19
- package/dist/index.d.ts +250 -257
- package/dist/index.js +1027 -603
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,224 +2,6 @@ import { CanonicalManager } from '@atomic-ehr/fhir-canonical-manager';
|
|
|
2
2
|
import * as FS from '@atomic-ehr/fhirschema';
|
|
3
3
|
import { FHIRSchema, StructureDefinition } from '@atomic-ehr/fhirschema';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* New Config Schema for High-Level API
|
|
7
|
-
*
|
|
8
|
-
* Simple configuration system compatible ONLY with the new high-level APIBuilder.
|
|
9
|
-
* All legacy config functionality has been removed.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* TypeScript generator configuration options
|
|
13
|
-
*/
|
|
14
|
-
interface TypeScriptGeneratorConfig {
|
|
15
|
-
moduleFormat?: "esm" | "cjs";
|
|
16
|
-
generateIndex?: boolean;
|
|
17
|
-
includeDocuments?: boolean;
|
|
18
|
-
namingConvention?: "PascalCase" | "camelCase";
|
|
19
|
-
strictMode?: boolean;
|
|
20
|
-
includeProfiles?: boolean;
|
|
21
|
-
includeExtensions?: boolean;
|
|
22
|
-
includeCodeSystems?: boolean;
|
|
23
|
-
includeOperations?: boolean;
|
|
24
|
-
/** Generate individual TypeScript files for value sets (default: false) */
|
|
25
|
-
generateValueSets?: boolean;
|
|
26
|
-
/** Include helper validation functions in value set files (default: false) */
|
|
27
|
-
includeValueSetHelpers?: boolean;
|
|
28
|
-
/** Which binding strengths to generate value sets for (default: ['required']) */
|
|
29
|
-
valueSetStrengths?: ("required" | "preferred" | "extensible" | "example")[];
|
|
30
|
-
/** Directory name for value set files (relative to outputDir) (default: 'valuesets') */
|
|
31
|
-
valueSetDirectory?: string;
|
|
32
|
-
/** Value set generation mode (default: 'required-only') */
|
|
33
|
-
valueSetMode?: "all" | "required-only" | "custom";
|
|
34
|
-
fhirVersion?: "R4" | "R5";
|
|
35
|
-
resourceTypes?: string[];
|
|
36
|
-
maxDepth?: number;
|
|
37
|
-
profileOptions?: {
|
|
38
|
-
generateKind?: "interface" | "type" | "both";
|
|
39
|
-
includeConstraints?: boolean;
|
|
40
|
-
includeDocumentation?: boolean;
|
|
41
|
-
strictMode?: boolean;
|
|
42
|
-
subfolder?: string;
|
|
43
|
-
};
|
|
44
|
-
generateBuilders?: boolean;
|
|
45
|
-
builderOptions?: {
|
|
46
|
-
includeValidation?: boolean;
|
|
47
|
-
includeFactoryMethods?: boolean;
|
|
48
|
-
includeInterfaces?: boolean;
|
|
49
|
-
generateNestedBuilders?: boolean;
|
|
50
|
-
includeHelperMethods?: boolean;
|
|
51
|
-
supportPartialBuild?: boolean;
|
|
52
|
-
includeJSDoc?: boolean;
|
|
53
|
-
generateFactories?: boolean;
|
|
54
|
-
includeTypeGuards?: boolean;
|
|
55
|
-
handleChoiceTypes?: boolean;
|
|
56
|
-
generateArrayHelpers?: boolean;
|
|
57
|
-
};
|
|
58
|
-
validatorOptions?: {
|
|
59
|
-
includeCardinality?: boolean;
|
|
60
|
-
includeTypes?: boolean;
|
|
61
|
-
includeConstraints?: boolean;
|
|
62
|
-
includeInvariants?: boolean;
|
|
63
|
-
validateRequired?: boolean;
|
|
64
|
-
allowAdditional?: boolean;
|
|
65
|
-
strictValidation?: boolean;
|
|
66
|
-
collectMetrics?: boolean;
|
|
67
|
-
generateAssertions?: boolean;
|
|
68
|
-
generatePartialValidators?: boolean;
|
|
69
|
-
optimizePerformance?: boolean;
|
|
70
|
-
includeJSDoc?: boolean;
|
|
71
|
-
generateCompositeValidators?: boolean;
|
|
72
|
-
};
|
|
73
|
-
guardOptions?: {
|
|
74
|
-
includeRuntimeValidation?: boolean;
|
|
75
|
-
includeErrorMessages?: boolean;
|
|
76
|
-
treeShakeable?: boolean;
|
|
77
|
-
targetTSVersion?: "3.8" | "4.0" | "4.5" | "5.0";
|
|
78
|
-
strictGuards?: boolean;
|
|
79
|
-
includeNullChecks?: boolean;
|
|
80
|
-
verbose?: boolean;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* TypeSchema Configuration
|
|
85
|
-
* Controls TypeSchema generation and caching behavior
|
|
86
|
-
*/
|
|
87
|
-
interface TypeSchemaConfig {
|
|
88
|
-
/** Enable persistent caching of generated TypeSchemas */
|
|
89
|
-
enablePersistence?: boolean;
|
|
90
|
-
/** Directory to store cached TypeSchemas (relative to outputDir) */
|
|
91
|
-
cacheDir?: string;
|
|
92
|
-
/** Maximum age of cached schemas in milliseconds before regeneration */
|
|
93
|
-
maxAge?: number;
|
|
94
|
-
/** Whether to validate cached schemas before reuse */
|
|
95
|
-
validateCached?: boolean;
|
|
96
|
-
/** Force regeneration of schemas even if cached */
|
|
97
|
-
forceRegenerate?: boolean;
|
|
98
|
-
/** Share cache across multiple codegen runs */
|
|
99
|
-
shareCache?: boolean;
|
|
100
|
-
/** Cache key prefix for namespacing */
|
|
101
|
-
cacheKeyPrefix?: string;
|
|
102
|
-
/** Only generate TypeSchemas for specific ResourceTypes (treeshaking) */
|
|
103
|
-
treeshake?: string[];
|
|
104
|
-
/** Generate single TypeSchema file instead of multiple files */
|
|
105
|
-
singleFile?: boolean;
|
|
106
|
-
/** Profile packages configuration */
|
|
107
|
-
profiles?: {
|
|
108
|
-
/** Auto-detect profiles in packages */
|
|
109
|
-
autoDetect?: boolean;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Main configuration schema for the new high-level API
|
|
114
|
-
*/
|
|
115
|
-
interface Config {
|
|
116
|
-
outputDir?: string;
|
|
117
|
-
verbose?: boolean;
|
|
118
|
-
overwrite?: boolean;
|
|
119
|
-
validate?: boolean;
|
|
120
|
-
cache?: boolean;
|
|
121
|
-
typescript?: TypeScriptGeneratorConfig;
|
|
122
|
-
typeSchema?: TypeSchemaConfig;
|
|
123
|
-
packages?: string[];
|
|
124
|
-
files?: string[];
|
|
125
|
-
$schema?: string;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Default configuration values
|
|
129
|
-
*/
|
|
130
|
-
declare const DEFAULT_CONFIG: Required<Config>;
|
|
131
|
-
/**
|
|
132
|
-
* Configuration file names to search for
|
|
133
|
-
*/
|
|
134
|
-
declare const CONFIG_FILE_NAMES: string[];
|
|
135
|
-
/**
|
|
136
|
-
* Validation error interface
|
|
137
|
-
*/
|
|
138
|
-
interface ConfigValidationError {
|
|
139
|
-
path: string;
|
|
140
|
-
message: string;
|
|
141
|
-
value?: unknown;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Configuration validation result
|
|
145
|
-
*/
|
|
146
|
-
interface ConfigValidationResult {
|
|
147
|
-
valid: boolean;
|
|
148
|
-
errors: ConfigValidationError[];
|
|
149
|
-
warnings: string[];
|
|
150
|
-
config?: Config;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Simple configuration validator
|
|
154
|
-
*/
|
|
155
|
-
declare class ConfigValidator {
|
|
156
|
-
/**
|
|
157
|
-
* Validate a configuration object
|
|
158
|
-
*/
|
|
159
|
-
validate(config: unknown): ConfigValidationResult;
|
|
160
|
-
private validateTypeScriptConfig;
|
|
161
|
-
private validateValidatorOptions;
|
|
162
|
-
private validateGuardOptions;
|
|
163
|
-
private validateProfileOptions;
|
|
164
|
-
private validateTypeSchemaConfig;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Configuration loader with autoloading capabilities
|
|
168
|
-
*/
|
|
169
|
-
declare class ConfigLoader {
|
|
170
|
-
private validator;
|
|
171
|
-
/**
|
|
172
|
-
* Auto-load configuration from the current working directory
|
|
173
|
-
*/
|
|
174
|
-
autoload(workingDir?: string): Promise<Config>;
|
|
175
|
-
/**
|
|
176
|
-
* Load configuration from a specific file
|
|
177
|
-
*/
|
|
178
|
-
loadFromFile(filePath: string): Promise<Config>;
|
|
179
|
-
/**
|
|
180
|
-
* Find configuration file in the given directory
|
|
181
|
-
*/
|
|
182
|
-
private findConfigFile;
|
|
183
|
-
/**
|
|
184
|
-
* Merge user config with defaults
|
|
185
|
-
*/
|
|
186
|
-
private mergeWithDefaults;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Global config loader instance
|
|
190
|
-
*/
|
|
191
|
-
declare const configLoader: ConfigLoader;
|
|
192
|
-
/**
|
|
193
|
-
* Convenience function to auto-load configuration
|
|
194
|
-
*/
|
|
195
|
-
declare function loadConfig(workingDir?: string): Promise<Config>;
|
|
196
|
-
/**
|
|
197
|
-
* Type guard to check if an object is a valid Config
|
|
198
|
-
*/
|
|
199
|
-
declare function isConfig(obj: unknown): obj is Config;
|
|
200
|
-
/**
|
|
201
|
-
* Define configuration with type safety and IntelliSense support.
|
|
202
|
-
* Similar to Vite's defineConfig function pattern.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```typescript
|
|
206
|
-
* import { defineConfig } from "@atomic-ehr/codegen";
|
|
207
|
-
*
|
|
208
|
-
* export default defineConfig({
|
|
209
|
-
* outputDir: "./generated",
|
|
210
|
-
* packages: [
|
|
211
|
-
* "hl7.fhir.r4.core@4.0.1",
|
|
212
|
-
* "hl7.fhir.us.core@6.1.0"
|
|
213
|
-
* ],
|
|
214
|
-
* typescript: {
|
|
215
|
-
* generateIndex: true,
|
|
216
|
-
* strictMode: true
|
|
217
|
-
* }
|
|
218
|
-
* });
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
declare function defineConfig(config: Config): Config;
|
|
222
|
-
|
|
223
5
|
/**
|
|
224
6
|
* CodeGen Logger
|
|
225
7
|
*
|
|
@@ -235,6 +17,7 @@ interface LogOptions {
|
|
|
235
17
|
*/
|
|
236
18
|
declare class CodegenLogger {
|
|
237
19
|
private options;
|
|
20
|
+
private dryWarnSet;
|
|
238
21
|
constructor(options?: LogOptions);
|
|
239
22
|
private formatMessage;
|
|
240
23
|
/**
|
|
@@ -249,6 +32,7 @@ declare class CodegenLogger {
|
|
|
249
32
|
* Warning message with warning sign
|
|
250
33
|
*/
|
|
251
34
|
warn(message: string): void;
|
|
35
|
+
dry_warn(message: string): void;
|
|
252
36
|
/**
|
|
253
37
|
* Info message with info icon
|
|
254
38
|
*/
|
|
@@ -507,6 +291,238 @@ type RichValueSet = Omit<ValueSet, "name" | "url"> & {
|
|
|
507
291
|
url?: CanonicalUrl;
|
|
508
292
|
};
|
|
509
293
|
|
|
294
|
+
type Register = {
|
|
295
|
+
appendFs(fs: FHIRSchema): void;
|
|
296
|
+
ensureCanonicalUrl(name: string | Name | CanonicalUrl): CanonicalUrl;
|
|
297
|
+
resolveSd(canonicalUrl: CanonicalUrl): StructureDefinition | undefined;
|
|
298
|
+
resolveFs(canonicalUrl: CanonicalUrl): RichFHIRSchema | undefined;
|
|
299
|
+
resolveFsGenealogy(canonicalUrl: CanonicalUrl): RichFHIRSchema[];
|
|
300
|
+
allSd(): StructureDefinition[];
|
|
301
|
+
allFs(): RichFHIRSchema[];
|
|
302
|
+
allVs(): RichValueSet[];
|
|
303
|
+
resolveVs(canonicalUrl: CanonicalUrl): RichValueSet | undefined;
|
|
304
|
+
complexTypeDict(): Record<string, RichFHIRSchema>;
|
|
305
|
+
resolveAny(canonicalUrl: CanonicalUrl): any | undefined;
|
|
306
|
+
} & ReturnType<typeof CanonicalManager>;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* New Config Schema for High-Level API
|
|
310
|
+
*
|
|
311
|
+
* Simple configuration system compatible ONLY with the new high-level APIBuilder.
|
|
312
|
+
* All legacy config functionality has been removed.
|
|
313
|
+
*/
|
|
314
|
+
/**
|
|
315
|
+
* TypeScript generator configuration options
|
|
316
|
+
*/
|
|
317
|
+
interface TypeScriptGeneratorConfig {
|
|
318
|
+
moduleFormat?: "esm" | "cjs";
|
|
319
|
+
generateIndex?: boolean;
|
|
320
|
+
includeDocuments?: boolean;
|
|
321
|
+
namingConvention?: "PascalCase" | "camelCase";
|
|
322
|
+
strictMode?: boolean;
|
|
323
|
+
includeProfiles?: boolean;
|
|
324
|
+
includeExtensions?: boolean;
|
|
325
|
+
includeCodeSystems?: boolean;
|
|
326
|
+
includeOperations?: boolean;
|
|
327
|
+
/** Generate individual TypeScript files for value sets (default: false) */
|
|
328
|
+
generateValueSets?: boolean;
|
|
329
|
+
/** Include helper validation functions in value set files (default: false) */
|
|
330
|
+
includeValueSetHelpers?: boolean;
|
|
331
|
+
/** Which binding strengths to generate value sets for (default: ['required']) */
|
|
332
|
+
valueSetStrengths?: ("required" | "preferred" | "extensible" | "example")[];
|
|
333
|
+
/** Directory name for value set files (relative to outputDir) (default: 'valuesets') */
|
|
334
|
+
valueSetDirectory?: string;
|
|
335
|
+
/** Value set generation mode (default: 'required-only') */
|
|
336
|
+
valueSetMode?: "all" | "required-only" | "custom";
|
|
337
|
+
fhirVersion?: "R4" | "R5";
|
|
338
|
+
resourceTypes?: string[];
|
|
339
|
+
maxDepth?: number;
|
|
340
|
+
profileOptions?: {
|
|
341
|
+
generateKind?: "interface" | "type" | "both";
|
|
342
|
+
includeConstraints?: boolean;
|
|
343
|
+
includeDocumentation?: boolean;
|
|
344
|
+
strictMode?: boolean;
|
|
345
|
+
subfolder?: string;
|
|
346
|
+
};
|
|
347
|
+
generateBuilders?: boolean;
|
|
348
|
+
builderOptions?: {
|
|
349
|
+
includeValidation?: boolean;
|
|
350
|
+
includeFactoryMethods?: boolean;
|
|
351
|
+
includeInterfaces?: boolean;
|
|
352
|
+
generateNestedBuilders?: boolean;
|
|
353
|
+
includeHelperMethods?: boolean;
|
|
354
|
+
supportPartialBuild?: boolean;
|
|
355
|
+
includeJSDoc?: boolean;
|
|
356
|
+
generateFactories?: boolean;
|
|
357
|
+
includeTypeGuards?: boolean;
|
|
358
|
+
handleChoiceTypes?: boolean;
|
|
359
|
+
generateArrayHelpers?: boolean;
|
|
360
|
+
};
|
|
361
|
+
validatorOptions?: {
|
|
362
|
+
includeCardinality?: boolean;
|
|
363
|
+
includeTypes?: boolean;
|
|
364
|
+
includeConstraints?: boolean;
|
|
365
|
+
includeInvariants?: boolean;
|
|
366
|
+
validateRequired?: boolean;
|
|
367
|
+
allowAdditional?: boolean;
|
|
368
|
+
strictValidation?: boolean;
|
|
369
|
+
collectMetrics?: boolean;
|
|
370
|
+
generateAssertions?: boolean;
|
|
371
|
+
generatePartialValidators?: boolean;
|
|
372
|
+
optimizePerformance?: boolean;
|
|
373
|
+
includeJSDoc?: boolean;
|
|
374
|
+
generateCompositeValidators?: boolean;
|
|
375
|
+
};
|
|
376
|
+
guardOptions?: {
|
|
377
|
+
includeRuntimeValidation?: boolean;
|
|
378
|
+
includeErrorMessages?: boolean;
|
|
379
|
+
treeShakeable?: boolean;
|
|
380
|
+
targetTSVersion?: "3.8" | "4.0" | "4.5" | "5.0";
|
|
381
|
+
strictGuards?: boolean;
|
|
382
|
+
includeNullChecks?: boolean;
|
|
383
|
+
verbose?: boolean;
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* TypeSchema Configuration
|
|
388
|
+
* Controls TypeSchema generation and caching behavior
|
|
389
|
+
*/
|
|
390
|
+
interface TypeSchemaConfig {
|
|
391
|
+
/** Enable persistent caching of generated TypeSchemas */
|
|
392
|
+
enablePersistence?: boolean;
|
|
393
|
+
/** Directory to store cached TypeSchemas (relative to outputDir) */
|
|
394
|
+
cacheDir?: string;
|
|
395
|
+
/** Maximum age of cached schemas in milliseconds before regeneration */
|
|
396
|
+
maxAge?: number;
|
|
397
|
+
/** Whether to validate cached schemas before reuse */
|
|
398
|
+
validateCached?: boolean;
|
|
399
|
+
/** Force regeneration of schemas even if cached */
|
|
400
|
+
forceRegenerate?: boolean;
|
|
401
|
+
/** Share cache across multiple codegen runs */
|
|
402
|
+
shareCache?: boolean;
|
|
403
|
+
/** Cache key prefix for namespacing */
|
|
404
|
+
cacheKeyPrefix?: string;
|
|
405
|
+
/** Only generate TypeSchemas for specific ResourceTypes (treeshaking) */
|
|
406
|
+
treeshake?: string[];
|
|
407
|
+
/** Generate single TypeSchema file instead of multiple files */
|
|
408
|
+
singleFile?: boolean;
|
|
409
|
+
/** Profile packages configuration */
|
|
410
|
+
profiles?: {
|
|
411
|
+
/** Auto-detect profiles in packages */
|
|
412
|
+
autoDetect?: boolean;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Main configuration schema for the new high-level API
|
|
417
|
+
*/
|
|
418
|
+
interface Config {
|
|
419
|
+
outputDir?: string;
|
|
420
|
+
verbose?: boolean;
|
|
421
|
+
overwrite?: boolean;
|
|
422
|
+
validate?: boolean;
|
|
423
|
+
cache?: boolean;
|
|
424
|
+
typescript?: TypeScriptGeneratorConfig;
|
|
425
|
+
typeSchema?: TypeSchemaConfig;
|
|
426
|
+
packages?: string[];
|
|
427
|
+
files?: string[];
|
|
428
|
+
$schema?: string;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Default configuration values
|
|
432
|
+
*/
|
|
433
|
+
declare const DEFAULT_CONFIG: Required<Config>;
|
|
434
|
+
/**
|
|
435
|
+
* Configuration file names to search for
|
|
436
|
+
*/
|
|
437
|
+
declare const CONFIG_FILE_NAMES: string[];
|
|
438
|
+
/**
|
|
439
|
+
* Validation error interface
|
|
440
|
+
*/
|
|
441
|
+
interface ConfigValidationError {
|
|
442
|
+
path: string;
|
|
443
|
+
message: string;
|
|
444
|
+
value?: unknown;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Configuration validation result
|
|
448
|
+
*/
|
|
449
|
+
interface ConfigValidationResult {
|
|
450
|
+
valid: boolean;
|
|
451
|
+
errors: ConfigValidationError[];
|
|
452
|
+
warnings: string[];
|
|
453
|
+
config?: Config;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Simple configuration validator
|
|
457
|
+
*/
|
|
458
|
+
declare class ConfigValidator {
|
|
459
|
+
/**
|
|
460
|
+
* Validate a configuration object
|
|
461
|
+
*/
|
|
462
|
+
validate(config: unknown): ConfigValidationResult;
|
|
463
|
+
private validateTypeScriptConfig;
|
|
464
|
+
private validateValidatorOptions;
|
|
465
|
+
private validateGuardOptions;
|
|
466
|
+
private validateProfileOptions;
|
|
467
|
+
private validateTypeSchemaConfig;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Configuration loader with autoloading capabilities
|
|
471
|
+
*/
|
|
472
|
+
declare class ConfigLoader {
|
|
473
|
+
private validator;
|
|
474
|
+
/**
|
|
475
|
+
* Auto-load configuration from the current working directory
|
|
476
|
+
*/
|
|
477
|
+
autoload(workingDir?: string): Promise<Config>;
|
|
478
|
+
/**
|
|
479
|
+
* Load configuration from a specific file
|
|
480
|
+
*/
|
|
481
|
+
loadFromFile(filePath: string): Promise<Config>;
|
|
482
|
+
/**
|
|
483
|
+
* Find configuration file in the given directory
|
|
484
|
+
*/
|
|
485
|
+
private findConfigFile;
|
|
486
|
+
/**
|
|
487
|
+
* Merge user config with defaults
|
|
488
|
+
*/
|
|
489
|
+
private mergeWithDefaults;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Global config loader instance
|
|
493
|
+
*/
|
|
494
|
+
declare const configLoader: ConfigLoader;
|
|
495
|
+
/**
|
|
496
|
+
* Convenience function to auto-load configuration
|
|
497
|
+
*/
|
|
498
|
+
declare function loadConfig(workingDir?: string): Promise<Config>;
|
|
499
|
+
/**
|
|
500
|
+
* Type guard to check if an object is a valid Config
|
|
501
|
+
*/
|
|
502
|
+
declare function isConfig(obj: unknown): obj is Config;
|
|
503
|
+
/**
|
|
504
|
+
* Define configuration with type safety and IntelliSense support.
|
|
505
|
+
* Similar to Vite's defineConfig function pattern.
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* import { defineConfig } from "@atomic-ehr/codegen";
|
|
510
|
+
*
|
|
511
|
+
* export default defineConfig({
|
|
512
|
+
* outputDir: "./generated",
|
|
513
|
+
* packages: [
|
|
514
|
+
* "hl7.fhir.r4.core@4.0.1",
|
|
515
|
+
* "hl7.fhir.us.core@6.1.0"
|
|
516
|
+
* ],
|
|
517
|
+
* typescript: {
|
|
518
|
+
* generateIndex: true,
|
|
519
|
+
* strictMode: true
|
|
520
|
+
* }
|
|
521
|
+
* });
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
declare function defineConfig(config: Config): Config;
|
|
525
|
+
|
|
510
526
|
/**
|
|
511
527
|
* TypeSchema Cache System
|
|
512
528
|
*
|
|
@@ -587,20 +603,6 @@ declare class TypeSchemaCache {
|
|
|
587
603
|
clearDisk(): Promise<void>;
|
|
588
604
|
}
|
|
589
605
|
|
|
590
|
-
type Register = {
|
|
591
|
-
appendFs(fs: FHIRSchema): void;
|
|
592
|
-
ensureCanonicalUrl(name: string | Name | CanonicalUrl): CanonicalUrl;
|
|
593
|
-
resolveSd(canonicalUrl: CanonicalUrl): StructureDefinition | undefined;
|
|
594
|
-
resolveFs(canonicalUrl: CanonicalUrl): RichFHIRSchema | undefined;
|
|
595
|
-
resolveFsGenealogy(canonicalUrl: CanonicalUrl): RichFHIRSchema[];
|
|
596
|
-
allSd(): StructureDefinition[];
|
|
597
|
-
allFs(): RichFHIRSchema[];
|
|
598
|
-
allVs(): RichValueSet[];
|
|
599
|
-
resolveVs(canonicalUrl: CanonicalUrl): RichValueSet | undefined;
|
|
600
|
-
complexTypeDict(): Record<string, RichFHIRSchema>;
|
|
601
|
-
resolveAny(canonicalUrl: CanonicalUrl): any | undefined;
|
|
602
|
-
} & ReturnType<typeof CanonicalManager>;
|
|
603
|
-
|
|
604
606
|
/**
|
|
605
607
|
* TypeSchema Generator
|
|
606
608
|
*
|
|
@@ -619,13 +621,13 @@ declare class TypeSchemaGenerator {
|
|
|
619
621
|
private options;
|
|
620
622
|
private cacheConfig?;
|
|
621
623
|
private cache?;
|
|
622
|
-
private logger
|
|
624
|
+
private logger?;
|
|
623
625
|
constructor(options?: TypeschemaGeneratorOptions, cacheConfig?: TypeSchemaConfig);
|
|
624
626
|
private initializeCache;
|
|
625
627
|
registerFromPackageMetas(packageMetas: PackageMeta[]): Promise<Register>;
|
|
626
628
|
generateFhirSchemas(structureDefinitions: StructureDefinition[]): FHIRSchema[];
|
|
627
|
-
generateValueSetSchemas(valueSets:
|
|
628
|
-
generateFromPackage(packageName: string, packageVersion?:
|
|
629
|
+
generateValueSetSchemas(valueSets: RichValueSet[], logger?: CodegenLogger): Promise<TypeSchema[]>;
|
|
630
|
+
generateFromPackage(packageName: string, packageVersion: string | undefined, logger?: CodegenLogger): Promise<TypeSchema[]>;
|
|
629
631
|
/**
|
|
630
632
|
* Apply treeshaking to StructureDefinitions before FHIR schema transformation
|
|
631
633
|
* This is more efficient and includes smart reference handling
|
|
@@ -715,6 +717,14 @@ declare class TypeSchemaParser {
|
|
|
715
717
|
private matchesIdentifier;
|
|
716
718
|
}
|
|
717
719
|
|
|
720
|
+
interface WriterOptions {
|
|
721
|
+
outputDir: string;
|
|
722
|
+
tabSize: number;
|
|
723
|
+
withDebugComment?: boolean;
|
|
724
|
+
commentLinePrefix: string;
|
|
725
|
+
logger?: CodegenLogger;
|
|
726
|
+
}
|
|
727
|
+
|
|
718
728
|
/**
|
|
719
729
|
* High-Level API Builder
|
|
720
730
|
*
|
|
@@ -729,11 +739,11 @@ interface APIBuilderOptions {
|
|
|
729
739
|
outputDir?: string;
|
|
730
740
|
verbose?: boolean;
|
|
731
741
|
overwrite?: boolean;
|
|
732
|
-
validate?: boolean;
|
|
733
742
|
cache?: boolean;
|
|
734
743
|
typeSchemaConfig?: TypeSchemaConfig;
|
|
735
744
|
logger?: CodegenLogger;
|
|
736
745
|
manager?: ReturnType<typeof CanonicalManager> | null;
|
|
746
|
+
throwException?: boolean;
|
|
737
747
|
}
|
|
738
748
|
/**
|
|
739
749
|
* Progress callback for long-running operations
|
|
@@ -760,16 +770,14 @@ declare class APIBuilder {
|
|
|
760
770
|
private schemas;
|
|
761
771
|
private options;
|
|
762
772
|
private generators;
|
|
763
|
-
private progressCallback?;
|
|
764
773
|
private cache?;
|
|
765
774
|
private pendingOperations;
|
|
766
775
|
private typeSchemaGenerator?;
|
|
767
776
|
private logger;
|
|
777
|
+
private packages;
|
|
778
|
+
progressCallback: any;
|
|
768
779
|
private typeSchemaConfig?;
|
|
769
780
|
constructor(options?: APIBuilderOptions);
|
|
770
|
-
/**
|
|
771
|
-
* Load TypeSchema from a FHIR package
|
|
772
|
-
*/
|
|
773
781
|
fromPackage(packageName: string, version?: string): APIBuilder;
|
|
774
782
|
/**
|
|
775
783
|
* Load TypeSchema from files
|
|
@@ -779,9 +787,6 @@ declare class APIBuilder {
|
|
|
779
787
|
* Load TypeSchema from TypeSchema objects
|
|
780
788
|
*/
|
|
781
789
|
fromSchemas(schemas: TypeSchema[]): APIBuilder;
|
|
782
|
-
/**
|
|
783
|
-
* Configure TypeScript generation
|
|
784
|
-
*/
|
|
785
790
|
typescript(options?: {
|
|
786
791
|
moduleFormat?: "esm" | "cjs";
|
|
787
792
|
generateIndex?: boolean;
|
|
@@ -795,6 +800,7 @@ declare class APIBuilder {
|
|
|
795
800
|
valueSetMode?: "all" | "required-only" | "custom";
|
|
796
801
|
valueSetDirectory?: string;
|
|
797
802
|
}): APIBuilder;
|
|
803
|
+
typescript2(opts: Partial<WriterOptions>): this;
|
|
798
804
|
/**
|
|
799
805
|
* Set a progress callback for monitoring generation
|
|
800
806
|
*/
|
|
@@ -803,17 +809,8 @@ declare class APIBuilder {
|
|
|
803
809
|
* Set the output directory for all generators
|
|
804
810
|
*/
|
|
805
811
|
outputTo(directory: string): APIBuilder;
|
|
806
|
-
/**
|
|
807
|
-
* Enable/disable verbose logging
|
|
808
|
-
*/
|
|
809
812
|
verbose(enabled?: boolean): APIBuilder;
|
|
810
|
-
|
|
811
|
-
* Enable/disable validation
|
|
812
|
-
*/
|
|
813
|
-
validate(enabled?: boolean): APIBuilder;
|
|
814
|
-
/**
|
|
815
|
-
* Execute the generation process
|
|
816
|
-
*/
|
|
813
|
+
throwException(enabled?: boolean): APIBuilder;
|
|
817
814
|
generate(): Promise<GenerationResult>;
|
|
818
815
|
/**
|
|
819
816
|
* Generate and return the results without writing to files
|
|
@@ -836,12 +833,8 @@ declare class APIBuilder {
|
|
|
836
833
|
* Get configured generators (for inspection)
|
|
837
834
|
*/
|
|
838
835
|
getGenerators(): string[];
|
|
839
|
-
private loadFromPackage;
|
|
840
836
|
private loadFromFiles;
|
|
841
|
-
private resolveSchemas;
|
|
842
|
-
private validateSchemas;
|
|
843
837
|
private executeGenerators;
|
|
844
|
-
private reportProgress;
|
|
845
838
|
}
|
|
846
839
|
/**
|
|
847
840
|
* Create a new API builder instance
|