@atomic-ehr/codegen 0.0.4 → 0.0.5-canary.20251229160950.1f6114f

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/index.d.ts CHANGED
@@ -12,11 +12,13 @@ declare enum LogLevel {
12
12
  ERROR = 3,
13
13
  SILENT = 4
14
14
  }
15
+ type LogLevelString = keyof typeof LogLevel;
15
16
  interface LogOptions {
16
17
  prefix?: string;
17
18
  timestamp?: boolean;
18
- verbose?: boolean;
19
19
  suppressLoggingLevel?: LogLevel[] | "all";
20
+ /** Minimum log level to display. Messages below this level are suppressed. Default: INFO */
21
+ level?: LogLevel;
20
22
  }
21
23
  /**
22
24
  * Simple code generation logger with pretty colors and clean formatting
@@ -25,6 +27,10 @@ declare class CodegenLogger {
25
27
  private options;
26
28
  private dryWarnSet;
27
29
  constructor(options?: LogOptions);
30
+ /**
31
+ * Check if a message at the given level should be logged
32
+ */
33
+ private shouldLog;
28
34
  private static consoleLevelsMap;
29
35
  private formatMessage;
30
36
  private isSuppressed;
@@ -47,7 +53,7 @@ declare class CodegenLogger {
47
53
  */
48
54
  info(message: string): void;
49
55
  /**
50
- * Debug message (only shows in verbose mode)
56
+ * Debug message (only shows when log level is DEBUG or verbose is true)
51
57
  */
52
58
  debug(message: string): void;
53
59
  /**
@@ -74,6 +80,8 @@ declare class CodegenLogger {
74
80
  * Update options
75
81
  */
76
82
  configure(options: Partial<LogOptions>): void;
83
+ getLevel(): LogLevel;
84
+ setLevel(level: LogLevel): void;
77
85
  }
78
86
 
79
87
  interface Element {
@@ -126,6 +134,10 @@ type Name = string & {
126
134
  type CanonicalUrl = string & {
127
135
  readonly __brand: unique symbol;
128
136
  };
137
+ interface PackageMeta {
138
+ name: string;
139
+ version: string;
140
+ }
129
141
  type IdentifierBase = {
130
142
  name: Name;
131
143
  url: CanonicalUrl;
@@ -289,10 +301,38 @@ interface BindingTypeSchema {
289
301
  }
290
302
  type Field = RegularField | ChoiceFieldDeclaration | ChoiceFieldInstance;
291
303
 
292
- type TypeSchemaShakeRule = {
304
+ type TreeShake = Record<string, Record<string, TreeShakeRule>>;
305
+ type TreeShakeRule = {
293
306
  ignoreFields?: string[];
307
+ selectFields?: string[];
308
+ };
309
+
310
+ type FileSystemWriterOptions = {
311
+ outputDir: string;
312
+ inMemoryOnly?: boolean;
313
+ logger?: CodegenLogger;
314
+ resolveAssets?: (fn: string) => string;
315
+ };
316
+ type WriterOptions = FileSystemWriterOptions & {
317
+ tabSize: number;
318
+ withDebugComment?: boolean;
319
+ commentLinePrefix: string;
320
+ generateProfile?: boolean;
321
+ };
322
+
323
+ type CSharpGeneratorOptions = WriterOptions & {
324
+ outputDir: string;
325
+ staticSourceDir?: string;
326
+ rootNamespace: string;
294
327
  };
295
- type TreeShake = Record<string, Record<string, TypeSchemaShakeRule>>;
328
+
329
+ type StringFormatKey = "snake_case" | "PascalCase" | "camelCase";
330
+ interface PythonGeneratorOptions extends WriterOptions {
331
+ allowExtraFields?: boolean;
332
+ staticDir?: string;
333
+ rootPackageName: string;
334
+ fieldFormat: StringFormatKey;
335
+ }
296
336
 
297
337
  /**
298
338
  * New Config Schema for High-Level API
@@ -415,6 +455,8 @@ interface Config {
415
455
  typeSchema?: TypeSchemaConfig;
416
456
  packages?: string[];
417
457
  files?: string[];
458
+ /** Custom FHIR package registry URL (default: https://fs.get-ig.org/pkgs/) */
459
+ registry?: string;
418
460
  $schema?: string;
419
461
  }
420
462
  /**
@@ -513,16 +555,54 @@ declare function isConfig(obj: unknown): obj is Config;
513
555
  */
514
556
  declare function defineConfig(config: Config): Config;
515
557
 
516
- type FileSystemWriterOptions = {
517
- outputDir: string;
518
- inMemoryOnly?: boolean;
519
- logger?: CodegenLogger;
558
+ type NameTransformation = {
559
+ pattern: RegExp | string;
560
+ format: string;
520
561
  };
521
- type WriterOptions = FileSystemWriterOptions & {
522
- tabSize: number;
523
- withDebugComment?: boolean;
524
- commentLinePrefix: string;
525
- generateProfile?: boolean;
562
+ type DistinctNameConfigurationType<T> = {
563
+ common: T;
564
+ enumValue: T;
565
+ type: T;
566
+ field: T;
567
+ };
568
+
569
+ type FilterType = {
570
+ whitelist?: (string | RegExp)[];
571
+ blacklist?: (string | RegExp)[];
572
+ };
573
+ type HookType = {
574
+ cmd: string;
575
+ args?: string[];
576
+ };
577
+ declare const PRIMITIVE_TYPES: readonly ["boolean", "instant", "time", "date", "dateTime", "decimal", "integer", "unsignedInt", "positiveInt", "integer64", "base64Binary", "uri", "url", "canonical", "oid", "uuid", "string", "code", "markdown", "id", "xhtml"];
578
+ type PrimitiveType = (typeof PRIMITIVE_TYPES)[number];
579
+ type Rendering = {
580
+ source: string;
581
+ fileNameFormat: string;
582
+ path: string;
583
+ filter?: FilterType;
584
+ properties?: Record<string, any>;
585
+ };
586
+
587
+ type FileBasedMustacheGeneratorOptions = {
588
+ debug: "OFF" | "FORMATTED" | "COMPACT";
589
+ meta: {
590
+ timestamp?: string;
591
+ generator?: string;
592
+ };
593
+ renderings: {
594
+ utility: Rendering[];
595
+ resource: Rendering[];
596
+ complexType: Rendering[];
597
+ };
598
+ keywords: string[];
599
+ primitiveTypeMap: Partial<Record<PrimitiveType, string>>;
600
+ nameTransformations: DistinctNameConfigurationType<NameTransformation[]>;
601
+ unsaveCharacterPattern: string | RegExp;
602
+ shouldRunHooks: boolean;
603
+ hooks: {
604
+ afterGenerate?: HookType[];
605
+ };
526
606
  };
527
607
 
528
608
  type TypeScriptOptions = {
@@ -547,7 +627,6 @@ type TypeScriptOptions = {
547
627
  */
548
628
  interface APIBuilderOptions {
549
629
  outputDir?: string;
550
- verbose?: boolean;
551
630
  overwrite?: boolean;
552
631
  cache?: boolean;
553
632
  cleanOutput?: boolean;
@@ -558,21 +637,28 @@ interface APIBuilderOptions {
558
637
  throwException?: boolean;
559
638
  exportTypeTree?: string;
560
639
  treeShake?: TreeShake;
640
+ /** Log level for the logger. Default: INFO */
641
+ logLevel?: LogLevel;
642
+ /** Custom FHIR package registry URL (default: https://fs.get-ig.org/pkgs/) */
643
+ registry?: string;
561
644
  }
562
645
  /**
563
646
  * Progress callback for long-running operations
564
647
  */
565
648
  type ProgressCallback = (phase: string, current: number, total: number, message?: string) => void;
566
- /**
567
- * Generation result information
568
- */
569
- interface GenerationResult {
649
+ type GenerationReport = {
570
650
  success: boolean;
571
651
  outputDir: string;
572
- filesGenerated: string[];
652
+ filesGenerated: Record<string, string>;
573
653
  errors: string[];
574
654
  warnings: string[];
575
655
  duration: number;
656
+ };
657
+ declare const prettyReport: (report: GenerationReport) => string;
658
+ interface LocalStructureDefinitionConfig {
659
+ package: PackageMeta;
660
+ path: string;
661
+ dependencies?: PackageMeta[];
576
662
  }
577
663
  /**
578
664
  * High-Level API Builder class
@@ -586,14 +672,25 @@ declare class APIBuilder {
586
672
  private generators;
587
673
  private logger;
588
674
  private packages;
675
+ private localStructurePackages;
676
+ private localTgzArchives;
589
677
  progressCallback: any;
590
678
  private typeSchemaConfig?;
591
679
  constructor(options?: APIBuilderOptions);
592
680
  fromPackage(packageName: string, version?: string): APIBuilder;
593
681
  fromPackageRef(packageRef: string): APIBuilder;
682
+ /**
683
+ * Set a custom FHIR package registry URL
684
+ * @param url The registry URL (default: https://fs.get-ig.org/pkgs/)
685
+ */
686
+ registry(url: string): APIBuilder;
687
+ localStructureDefinitions(config: LocalStructureDefinitionConfig): APIBuilder;
688
+ localTgzPackage(archivePath: string): APIBuilder;
594
689
  fromSchemas(schemas: TypeSchema[]): APIBuilder;
595
690
  typescript(userOpts: Partial<TypeScriptOptions>): this;
596
- csharp(namespace: string, staticSourceDir?: string | undefined): APIBuilder;
691
+ python(userOptions: Partial<PythonGeneratorOptions>): APIBuilder;
692
+ mustache(templatePath: string, userOpts: Partial<FileSystemWriterOptions & FileBasedMustacheGeneratorOptions>): this;
693
+ csharp(userOptions: Partial<CSharpGeneratorOptions>): APIBuilder;
597
694
  /**
598
695
  * Set a progress callback for monitoring generation
599
696
  */
@@ -602,13 +699,13 @@ declare class APIBuilder {
602
699
  * Set the output directory for all generators
603
700
  */
604
701
  outputTo(directory: string): APIBuilder;
605
- verbose(enabled?: boolean): APIBuilder;
702
+ setLogLevel(level: LogLevel | LogLevelString): APIBuilder;
606
703
  throwException(enabled?: boolean): APIBuilder;
607
704
  cleanOutput(enabled?: boolean): APIBuilder;
608
705
  writeTypeTree(filename: string): this;
609
706
  treeShake(tree: TreeShake): this;
610
707
  writeTypeSchemas(target: string): this;
611
- generate(): Promise<GenerationResult>;
708
+ generate(): Promise<GenerationReport>;
612
709
  /**
613
710
  * Clear all configuration and start fresh
614
711
  */
@@ -624,10 +721,4 @@ declare class APIBuilder {
624
721
  private executeGenerators;
625
722
  }
626
723
 
627
- type CSharpGeneratorOptions = WriterOptions & {
628
- outputDir: string;
629
- staticSourceDir?: string;
630
- targetNamespace: string;
631
- };
632
-
633
- export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type CSharpGeneratorOptions, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type TypeSchemaConfig, type TypeScriptGeneratorConfig, type TypeScriptOptions, configLoader, defineConfig, isConfig, loadConfig };
724
+ export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type CSharpGeneratorOptions, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type LocalStructureDefinitionConfig, LogLevel, type TypeSchemaConfig, type TypeScriptGeneratorConfig, type TypeScriptOptions, configLoader, defineConfig, isConfig, loadConfig, prettyReport };