@atomic-ehr/codegen 0.0.1 → 0.0.2-canary.20251114095108.8d8e927

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,40 @@ declare class TypeSchemaParser {
731
757
  private matchesIdentifier;
732
758
  }
733
759
 
760
+ type TypeSchemaShakeRule = {
761
+ ignoreFields?: string[];
762
+ };
763
+ type TreeShake = Record<string, Record<string, TypeSchemaShakeRule>>;
764
+ interface TypeRelation {
765
+ parent: Identifier;
766
+ child: Identifier;
767
+ }
768
+ type PackageName = string;
769
+ type TypeSchemaIndex = {
770
+ _schemaIndex: Record<CanonicalUrl, Record<PackageName, TypeSchema>>;
771
+ _relations: TypeRelation[];
772
+ collectComplexTypes: () => RegularTypeSchema[];
773
+ collectResources: () => RegularTypeSchema[];
774
+ collectLogicalModels: () => RegularTypeSchema[];
775
+ collectProfiles: () => ProfileTypeSchema[];
776
+ resolve: (id: Identifier) => TypeSchema | undefined;
777
+ resolveByUrl: (pkgName: PackageName, url: CanonicalUrl) => TypeSchema | undefined;
778
+ resourceChildren: (id: Identifier) => Identifier[];
779
+ tryHierarchy: (schema: TypeSchema) => TypeSchema[] | undefined;
780
+ hierarchy: (schema: TypeSchema) => TypeSchema[];
781
+ findLastSpecialization: (schema: TypeSchema) => TypeSchema;
782
+ findLastSpecializationByIdentifier: (id: Identifier) => Identifier;
783
+ flatProfile: (schema: ProfileTypeSchema) => ProfileTypeSchema;
784
+ isWithMetaField: (profile: ProfileTypeSchema) => boolean;
785
+ exportTree: (filename: string) => Promise<void>;
786
+ };
787
+
734
788
  interface WriterOptions {
735
789
  outputDir: string;
736
790
  tabSize: number;
737
791
  withDebugComment?: boolean;
738
792
  commentLinePrefix: string;
793
+ generateProfile?: boolean;
739
794
  logger?: CodegenLogger;
740
795
  }
741
796
 
@@ -760,6 +815,8 @@ interface APIBuilderOptions {
760
815
  manager?: ReturnType<typeof CanonicalManager> | null;
761
816
  typeSchemaOutputDir?: string /** if .ndjson -- put in one file, else -- split into separated files*/;
762
817
  throwException?: boolean;
818
+ exportTypeTree?: string;
819
+ treeShake?: TreeShake;
763
820
  }
764
821
  /**
765
822
  * Progress callback for long-running operations
@@ -795,15 +852,10 @@ declare class APIBuilder {
795
852
  private typeSchemaConfig?;
796
853
  constructor(options?: APIBuilderOptions);
797
854
  fromPackage(packageName: string, version?: string): APIBuilder;
798
- /**
799
- * Load TypeSchema from files
800
- */
855
+ fromPackageRef(packageRef: string): APIBuilder;
801
856
  fromFiles(...filePaths: string[]): APIBuilder;
802
- /**
803
- * Load TypeSchema from TypeSchema objects
804
- */
805
857
  fromSchemas(schemas: TypeSchema[]): APIBuilder;
806
- typescript(options?: {
858
+ typescriptDepricated(options?: {
807
859
  moduleFormat?: "esm" | "cjs";
808
860
  generateIndex?: boolean;
809
861
  includeDocuments?: boolean;
@@ -816,7 +868,7 @@ declare class APIBuilder {
816
868
  valueSetMode?: "all" | "required-only" | "custom";
817
869
  valueSetDirectory?: string;
818
870
  }): APIBuilder;
819
- typescript2(opts: Partial<WriterOptions>): this;
871
+ typescript(opts: Partial<WriterOptions>): this;
820
872
  csharp(namespace: string, staticSourceDir?: string | undefined): APIBuilder;
821
873
  /**
822
874
  * Set a progress callback for monitoring generation
@@ -829,11 +881,9 @@ declare class APIBuilder {
829
881
  verbose(enabled?: boolean): APIBuilder;
830
882
  throwException(enabled?: boolean): APIBuilder;
831
883
  cleanOutput(enabled?: boolean): APIBuilder;
884
+ writeTypeTree(filename: string): this;
885
+ treeShake(tree: TreeShake): this;
832
886
  writeTypeSchemas(target: string): this;
833
- private static isIdenticalTo;
834
- private writeTypeSchemasToSeparateFiles;
835
- private writeTypeSchemasToSingleFile;
836
- private tryWriteTypeSchema;
837
887
  generate(): Promise<GenerationResult>;
838
888
  /**
839
889
  * Generate and return the results without writing to files
@@ -859,29 +909,10 @@ declare class APIBuilder {
859
909
  private loadFromFiles;
860
910
  private executeGenerators;
861
911
  }
862
- /**
863
- * Create a new API builder instance
864
- */
865
- declare function createAPI(options?: APIBuilderOptions): APIBuilder;
866
912
  /**
867
913
  * Create an API builder instance from a configuration object
868
914
  */
869
915
  declare function createAPIFromConfig(config: Config): APIBuilder;
870
- /**
871
- * Convenience function for quick TypeScript generation from a package
872
- */
873
- declare function generateTypesFromPackage(packageName: string, outputDir: string, options?: {
874
- version?: string;
875
- verbose?: boolean;
876
- validate?: boolean;
877
- }): Promise<GenerationResult>;
878
- /**
879
- * Convenience function for quick TypeScript generation from files
880
- */
881
- declare function generateTypesFromFiles(inputFiles: string[], outputDir: string, options?: {
882
- verbose?: boolean;
883
- validate?: boolean;
884
- }): Promise<GenerationResult>;
885
916
 
886
917
  /**
887
918
  * Core types and interfaces for the base generator system
@@ -1759,6 +1790,10 @@ declare class GeneratorErrorBoundary {
1759
1790
  }): Promise<T[]>;
1760
1791
  }
1761
1792
 
1793
+ type GeneratorInput = {
1794
+ schemas: TypeSchema[];
1795
+ index: TypeSchemaIndex;
1796
+ };
1762
1797
  /**
1763
1798
  * Abstract base generator class with comprehensive functionality
1764
1799
  *
@@ -1841,7 +1876,7 @@ declare abstract class BaseGenerator<TOptions extends BaseGeneratorOptions = Bas
1841
1876
  * This is the main method that orchestrates the entire generation process
1842
1877
  * @param schemas - Array of TypeSchema documents
1843
1878
  */
1844
- generate(schemas: TypeSchema[]): Promise<TResult>;
1879
+ generate({ schemas }: GeneratorInput): Promise<TResult>;
1845
1880
  /**
1846
1881
  * Generate and return content without writing files (useful for testing)
1847
1882
  * @param schemas - Array of TypeSchema documents
@@ -2136,7 +2171,7 @@ declare class TypeScriptGenerator extends BaseGenerator<TypeScriptGeneratorOptio
2136
2171
  /**
2137
2172
  * Override generate to clean directory first
2138
2173
  */
2139
- generate(schemas: TypeSchema[]): Promise<GeneratedFile[]>;
2174
+ generate(input: GeneratorInput): Promise<GeneratedFile[]>;
2140
2175
  /**
2141
2176
  * Run post-generation hooks - generate utility files
2142
2177
  */
@@ -2163,4 +2198,4 @@ declare class TypeScriptGenerator extends BaseGenerator<TypeScriptGeneratorOptio
2163
2198
  private generateMainIndexFile;
2164
2199
  }
2165
2200
 
2166
- export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type GeneratedFile, type GenerationResult, type PackageMeta as PackageInfo, type ProgressCallback$1 as ProgressCallback, type TypeSchema, TypeSchemaCache, type TypeSchemaConfig, type Field as TypeSchemaField, TypeSchemaGenerator, type Identifier as TypeSchemaIdentifier, TypeSchemaParser, TypeScriptGenerator, type TypeScriptGeneratorConfig, type TypeScriptGeneratorOptions, configLoader, createAPI, createAPIFromConfig, defineConfig, generateTypesFromFiles, generateTypesFromPackage, isConfig, loadConfig };
2201
+ export { APIBuilder, type APIBuilderOptions, CONFIG_FILE_NAMES, type Config, ConfigLoader, type ConfigValidationError, type ConfigValidationResult, ConfigValidator, DEFAULT_CONFIG, type GeneratedFile, type GenerationResult, type PackageMeta as PackageInfo, type ProgressCallback$1 as ProgressCallback, type TypeSchema, TypeSchemaCache, type TypeSchemaConfig, type Field as TypeSchemaField, TypeSchemaGenerator, type Identifier as TypeSchemaIdentifier, TypeSchemaParser, TypeScriptGenerator, type TypeScriptGeneratorConfig, type TypeScriptGeneratorOptions, configLoader, createAPIFromConfig, defineConfig, isConfig, loadConfig };