@atomic-ehr/codegen 0.0.1-canary.20251106145509.e3b1f82 → 0.0.1-canary.20251107091824.7605d36

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
@@ -291,6 +291,16 @@ type ValueSetCompose = {
291
291
  filter?: {}[];
292
292
  }[];
293
293
  };
294
+ type CodeSystem = {
295
+ resourceType: "CodeSystem";
296
+ url: CanonicalUrl;
297
+ concept: CodeSystemConcept[];
298
+ };
299
+ type CodeSystemConcept = {
300
+ concept: CodeSystemConcept[];
301
+ code: string;
302
+ display: string;
303
+ };
294
304
  type RichValueSet = Omit<ValueSet, "name" | "url"> & {
295
305
  package_meta: PackageMeta;
296
306
  name: Name;
@@ -304,8 +314,8 @@ interface TypeschemaGeneratorOptions {
304
314
  }
305
315
 
306
316
  type Register = {
307
- unsafeAppendFs(fs: FHIRSchema): void;
308
- ensureSpecializationCanonicalUrl(pkg: PackageMeta, name: string | Name | CanonicalUrl): CanonicalUrl;
317
+ testAppendFs(fs: FHIRSchema): void;
318
+ ensureSpecializationCanonicalUrl(name: string | Name | CanonicalUrl): CanonicalUrl;
309
319
  resolveSd(pkg: PackageMeta, canonicalUrl: CanonicalUrl): StructureDefinition | undefined;
310
320
  resolveFs(pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichFHIRSchema | undefined;
311
321
  resolveFsGenealogy(pkg: PackageMeta, canonicalUrl: CanonicalUrl): RichFHIRSchema[];
@@ -316,7 +326,23 @@ type Register = {
316
326
  resolveAny(canonicalUrl: CanonicalUrl): any | undefined;
317
327
  resolveElementSnapshot(fhirSchema: RichFHIRSchema, path: string[]): FHIRSchemaElement;
318
328
  getAllElementKeys(elems: Record<string, FHIRSchemaElement>): string[];
329
+ resolver: PackageAwareResolver;
319
330
  } & ReturnType<typeof CanonicalManager>;
331
+ type PkgId = string;
332
+ type FocusedResource = StructureDefinition | ValueSet | CodeSystem;
333
+ type CanonicalResolution<T> = {
334
+ deep: number;
335
+ pkg: PackageMeta;
336
+ pkgId: PkgId;
337
+ resource: T;
338
+ };
339
+ type PackageIndex = {
340
+ pkg: PackageMeta;
341
+ canonicalResolution: Record<CanonicalUrl, CanonicalResolution<FocusedResource>[]>;
342
+ fhirSchemas: Record<CanonicalUrl, RichFHIRSchema>;
343
+ valueSets: Record<CanonicalUrl, RichValueSet>;
344
+ };
345
+ type PackageAwareResolver = Record<PkgId, PackageIndex>;
320
346
 
321
347
  /**
322
348
  * New Config Schema for High-Level API
@@ -731,11 +757,35 @@ declare class TypeSchemaParser {
731
757
  private matchesIdentifier;
732
758
  }
733
759
 
760
+ interface TypeRelation {
761
+ parent: Identifier;
762
+ child: Identifier;
763
+ }
764
+ type PackageName = string;
765
+ type TypeSchemaIndex = {
766
+ _schemaIndex: Record<CanonicalUrl, Record<PackageName, TypeSchema>>;
767
+ _relations: TypeRelation[];
768
+ collectComplexTypes: () => RegularTypeSchema[];
769
+ collectResources: () => RegularTypeSchema[];
770
+ collectLogicalModels: () => RegularTypeSchema[];
771
+ collectProfiles: () => ProfileTypeSchema[];
772
+ resolve: (id: Identifier) => TypeSchema | undefined;
773
+ resourceChildren: (id: Identifier) => Identifier[];
774
+ tryHierarchy: (schema: TypeSchema) => TypeSchema[] | undefined;
775
+ hierarchy: (schema: TypeSchema) => TypeSchema[];
776
+ findLastSpecialization: (schema: TypeSchema) => TypeSchema;
777
+ findLastSpecializationByIdentifier: (id: Identifier) => Identifier;
778
+ flatProfile: (schema: ProfileTypeSchema) => ProfileTypeSchema;
779
+ isWithMetaField: (profile: ProfileTypeSchema) => boolean;
780
+ exportTree: (filename: string) => Promise<void>;
781
+ };
782
+
734
783
  interface WriterOptions {
735
784
  outputDir: string;
736
785
  tabSize: number;
737
786
  withDebugComment?: boolean;
738
787
  commentLinePrefix: string;
788
+ writeTypeTree?: string;
739
789
  logger?: CodegenLogger;
740
790
  }
741
791
 
@@ -760,6 +810,7 @@ interface APIBuilderOptions {
760
810
  manager?: ReturnType<typeof CanonicalManager> | null;
761
811
  typeSchemaOutputDir?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
762
812
  throwException?: boolean;
813
+ exportTypeTree?: string;
763
814
  }
764
815
  /**
765
816
  * Progress callback for long-running operations
@@ -795,15 +846,9 @@ declare class APIBuilder {
795
846
  private typeSchemaConfig?;
796
847
  constructor(options?: APIBuilderOptions);
797
848
  fromPackage(packageName: string, version?: string): APIBuilder;
798
- /**
799
- * Load TypeSchema from files
800
- */
801
849
  fromFiles(...filePaths: string[]): APIBuilder;
802
- /**
803
- * Load TypeSchema from TypeSchema objects
804
- */
805
850
  fromSchemas(schemas: TypeSchema[]): APIBuilder;
806
- typescript(options?: {
851
+ typescriptDepricated(options?: {
807
852
  moduleFormat?: "esm" | "cjs";
808
853
  generateIndex?: boolean;
809
854
  includeDocuments?: boolean;
@@ -816,7 +861,7 @@ declare class APIBuilder {
816
861
  valueSetMode?: "all" | "required-only" | "custom";
817
862
  valueSetDirectory?: string;
818
863
  }): APIBuilder;
819
- typescript2(opts: Partial<WriterOptions>): this;
864
+ typescript(opts: Partial<WriterOptions>): this;
820
865
  csharp(namespace: string, staticSourceDir?: string | undefined): APIBuilder;
821
866
  /**
822
867
  * Set a progress callback for monitoring generation
@@ -829,8 +874,8 @@ declare class APIBuilder {
829
874
  verbose(enabled?: boolean): APIBuilder;
830
875
  throwException(enabled?: boolean): APIBuilder;
831
876
  cleanOutput(enabled?: boolean): APIBuilder;
877
+ writeTypeTree(filename: string): this;
832
878
  writeTypeSchemas(target: string): this;
833
- private static isIdenticalTo;
834
879
  private writeTypeSchemasToSeparateFiles;
835
880
  private writeTypeSchemasToSingleFile;
836
881
  private tryWriteTypeSchema;
@@ -1759,6 +1804,10 @@ declare class GeneratorErrorBoundary {
1759
1804
  }): Promise<T[]>;
1760
1805
  }
1761
1806
 
1807
+ type GeneratorInput = {
1808
+ schemas: TypeSchema[];
1809
+ index: TypeSchemaIndex;
1810
+ };
1762
1811
  /**
1763
1812
  * Abstract base generator class with comprehensive functionality
1764
1813
  *
@@ -1841,7 +1890,7 @@ declare abstract class BaseGenerator<TOptions extends BaseGeneratorOptions = Bas
1841
1890
  * This is the main method that orchestrates the entire generation process
1842
1891
  * @param schemas - Array of TypeSchema documents
1843
1892
  */
1844
- generate(schemas: TypeSchema[]): Promise<TResult>;
1893
+ generate({ schemas }: GeneratorInput): Promise<TResult>;
1845
1894
  /**
1846
1895
  * Generate and return content without writing files (useful for testing)
1847
1896
  * @param schemas - Array of TypeSchema documents
@@ -2136,7 +2185,7 @@ declare class TypeScriptGenerator extends BaseGenerator<TypeScriptGeneratorOptio
2136
2185
  /**
2137
2186
  * Override generate to clean directory first
2138
2187
  */
2139
- generate(schemas: TypeSchema[]): Promise<GeneratedFile[]>;
2188
+ generate(input: GeneratorInput): Promise<GeneratedFile[]>;
2140
2189
  /**
2141
2190
  * Run post-generation hooks - generate utility files
2142
2191
  */