@atomic-ehr/codegen 0.0.1-canary.20250831211734.bb1536b → 0.0.1-canary.20250924082247.588e04a

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.
@@ -15,8 +15,4 @@ export declare function transformElements(fhirSchema: FHIRSchema, parentPath: st
15
15
  * Transform a single FHIRSchema to TypeSchema(s) with enhanced categorization
16
16
  * Returns the main schema plus any binding schemas
17
17
  */
18
- export declare function transformFHIRSchema(fhirSchema: FHIRSchema, manager: ReturnType<typeof CanonicalManager>, packageInfo?: PackageInfo): Promise<TypeSchema[]>;
19
- /**
20
- * Transform multiple FHIRSchemas
21
- */
22
- export declare function transformFHIRSchemas(fhirSchemas: FHIRSchema[], manager: ReturnType<typeof CanonicalManager>, packageInfo?: PackageInfo): Promise<TypeSchema[]>;
18
+ export declare function transformFHIRSchema(manager: ReturnType<typeof CanonicalManager>, fhirSchema: FHIRSchema, packageInfo: PackageInfo): Promise<TypeSchema[]>;
@@ -191,7 +191,7 @@ async function transformExtension(fhirSchema, manager, packageInfo) {
191
191
  * Transform a single FHIRSchema to TypeSchema(s) with enhanced categorization
192
192
  * Returns the main schema plus any binding schemas
193
193
  */
194
- export async function transformFHIRSchema(fhirSchema, manager, packageInfo) {
194
+ export async function transformFHIRSchema(manager, fhirSchema, packageInfo) {
195
195
  const results = [];
196
196
  // Extract package info from schema if not provided
197
197
  if (!packageInfo && (fhirSchema.package_name || fhirSchema.package_id)) {
@@ -332,14 +332,3 @@ export async function transformFHIRSchema(fhirSchema, manager, packageInfo) {
332
332
  results.push(...bindingSchemas);
333
333
  return results;
334
334
  }
335
- /**
336
- * Transform multiple FHIRSchemas
337
- */
338
- export async function transformFHIRSchemas(fhirSchemas, manager, packageInfo) {
339
- const allResults = [];
340
- for (const fhirSchema of fhirSchemas) {
341
- const results = await transformFHIRSchema(fhirSchema, manager, packageInfo);
342
- allResults.push(...results);
343
- }
344
- return allResults;
345
- }
@@ -4,7 +4,7 @@
4
4
  * Generates TypeSchema documents from FHIR packages using fhrischema.
5
5
  * Provides high-level API for converting FHIR Structure Definitions to TypeSchema format.
6
6
  */
7
- import { type FHIRSchema } from "@atomic-ehr/fhirschema";
7
+ import { type FHIRSchema, type StructureDefinition } from "@atomic-ehr/fhirschema";
8
8
  import type { TypeSchemaConfig } from "../config.js";
9
9
  import type { TypeSchema } from "./type-schema.types.js";
10
10
  import type { PackageInfo, TypeschemaGeneratorOptions } from "./types.js";
@@ -17,31 +17,19 @@ import type { PackageInfo, TypeschemaGeneratorOptions } from "./types.js";
17
17
  export declare class TypeSchemaGenerator {
18
18
  private manager;
19
19
  private options;
20
- private cache;
21
20
  private cacheConfig?;
21
+ private cache?;
22
22
  private logger;
23
23
  constructor(options?: TypeschemaGeneratorOptions, cacheConfig?: TypeSchemaConfig);
24
- /**
25
- * Initialize the cache if configured
26
- */
27
24
  private initializeCache;
28
- /**
29
- * Generate TypeSchema from a FHIR package name
30
- */
25
+ fetchPackage(packageName: string, packageVersion?: string): Promise<{
26
+ structureDefinitions: StructureDefinition[];
27
+ valueSets: any[];
28
+ }>;
29
+ generateFhirSchemas(structureDefinitions: StructureDefinition[]): FHIRSchema[];
30
+ generateValueSetSchemas(valueSets: any[], packageInfo: PackageInfo): Promise<TypeSchema[]>;
31
31
  generateFromPackage(packageName: string, packageVersion?: string): Promise<TypeSchema[]>;
32
- /**
33
- * Generate TypeSchema from individual FHIR schema
34
- */
35
- generateFromSchema(fhirSchema: FHIRSchema, packageInfo?: PackageInfo): Promise<TypeSchema[]>;
36
- /**
37
- * Generate TypeSchema from multiple FHIR schemas with FHIR-specific enhancements
38
- */
39
- generateFromSchemas(fhirSchemas: FHIRSchema[], packageInfo?: PackageInfo): Promise<TypeSchema[]>;
40
- private groupTypeSchemas;
41
- private enhanceProfiles;
42
- private enhanceExtensions;
43
- private enhanceValueSets;
44
- private enhanceCodeSystems;
32
+ generateFromSchemas(packageInfo: PackageInfo, fhirSchemas: FHIRSchema[]): Promise<TypeSchema[]>;
45
33
  /**
46
34
  * Apply treeshaking to StructureDefinitions before FHIR schema transformation
47
35
  * This is more efficient and includes smart reference handling
@@ -57,15 +45,3 @@ export declare class TypeSchemaGenerator {
57
45
  */
58
46
  private extractResourceNameFromUrl;
59
47
  }
60
- /**
61
- * Convenience function to generate TypeSchema from a package
62
- */
63
- export declare function generateTypeSchemaFromPackage(packageName: string, options?: TypeschemaGeneratorOptions): Promise<TypeSchema[]>;
64
- /**
65
- * Convenience function to generate TypeSchema from FHIR schemas
66
- */
67
- export declare function generateTypeSchemaFromSchemas(fhirSchemas: FHIRSchema[], packageInfo?: PackageInfo, options?: TypeschemaGeneratorOptions): Promise<TypeSchema[]>;
68
- /**
69
- * Convenience function to generate TypeSchema from a single FHIR schema
70
- */
71
- export declare function generateTypeSchemaFromSchema(fhirSchema: FHIRSchema, packageInfo?: PackageInfo, options?: TypeschemaGeneratorOptions): Promise<TypeSchema[]>;
@@ -5,10 +5,10 @@
5
5
  * Provides high-level API for converting FHIR Structure Definitions to TypeSchema format.
6
6
  */
7
7
  import { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
8
- import { translate, } from "@atomic-ehr/fhirschema";
8
+ import * as fhirschema from "@atomic-ehr/fhirschema";
9
9
  import { createLogger } from "../utils/codegen-logger.js";
10
10
  import { TypeSchemaCache } from "./cache.js";
11
- import { transformFHIRSchema, transformFHIRSchemas, } from "./core/transformer.js";
11
+ import { transformFHIRSchema } from "./core/transformer.js";
12
12
  import { transformValueSet } from "./value-set/processor.js";
13
13
  /**
14
14
  * TypeSchema Generator class
@@ -19,16 +19,11 @@ import { transformValueSet } from "./value-set/processor.js";
19
19
  export class TypeSchemaGenerator {
20
20
  manager;
21
21
  options;
22
- cache = null;
23
22
  cacheConfig;
23
+ cache;
24
24
  logger;
25
25
  constructor(options = {}, cacheConfig) {
26
- this.options = {
27
- resourceTypes: [],
28
- maxDepth: 10,
29
- verbose: false,
30
- ...options,
31
- };
26
+ this.options = { verbose: false, ...options };
32
27
  this.manager = CanonicalManager({ packages: [], workingDir: "tmp/fhir" });
33
28
  this.cacheConfig = cacheConfig;
34
29
  this.logger =
@@ -38,28 +33,13 @@ export class TypeSchemaGenerator {
38
33
  prefix: "TypeSchema",
39
34
  });
40
35
  }
41
- /**
42
- * Initialize the cache if configured
43
- */
44
36
  async initializeCache() {
45
37
  if (this.cacheConfig && !this.cache) {
46
38
  this.cache = new TypeSchemaCache(this.cacheConfig);
47
39
  await this.cache.initialize();
48
40
  }
49
41
  }
50
- /**
51
- * Generate TypeSchema from a FHIR package name
52
- */
53
- async generateFromPackage(packageName, packageVersion) {
54
- await this.initializeCache();
55
- const forceRegenerate = this.cacheConfig?.forceRegenerate ?? false;
56
- if (this.cache && !forceRegenerate) {
57
- const cachedSchemas = this.cache.getByPackage(packageName);
58
- if (cachedSchemas.length > 0) {
59
- this.logger.info(`Using cached TypeSchemas for package: ${packageName} (${cachedSchemas.length} schemas)`);
60
- return cachedSchemas;
61
- }
62
- }
42
+ async fetchPackage(packageName, packageVersion) {
63
43
  this.logger.step(`Loading FHIR package: ${packageName}${packageVersion ? `@${packageVersion}` : ""}`);
64
44
  this.manager = CanonicalManager({
65
45
  packages: [`${packageName}${packageVersion ? `@${packageVersion}` : ""}`],
@@ -70,14 +50,18 @@ export class TypeSchemaGenerator {
70
50
  const structureDefinitions = allResources.filter((resource) => resource.resourceType === "StructureDefinition");
71
51
  const valueSets = allResources.filter((resource) => resource.resourceType === "ValueSet");
72
52
  this.logger.info(`Found ${structureDefinitions.length} StructureDefinitions and ${valueSets.length} ValueSets in package`);
53
+ return { structureDefinitions, valueSets };
54
+ }
55
+ generateFhirSchemas(structureDefinitions) {
73
56
  this.logger.progress(`Converting ${structureDefinitions.length} StructureDefinitions to FHIRSchemas`);
57
+ // TODO: do it on the TypeSchema
74
58
  const filteredStructureDefinitions = this.applyStructureDefinitionTreeshaking(structureDefinitions);
75
59
  const fhirSchemas = [];
76
60
  let convertedCount = 0;
77
61
  let failedCount = 0;
78
62
  for (const sd of filteredStructureDefinitions) {
79
63
  try {
80
- const fhirSchema = translate(sd);
64
+ const fhirSchema = fhirschema.translate(sd);
81
65
  fhirSchemas.push(fhirSchema);
82
66
  convertedCount++;
83
67
  this.logger.debug(`Converted StructureDefinition: ${sd.name || sd.id} (${sd.resourceType})`);
@@ -87,14 +71,13 @@ export class TypeSchemaGenerator {
87
71
  this.logger.warn(`Failed to convert StructureDefinition ${sd.name || sd.id}: ${error instanceof Error ? error.message : String(error)}`);
88
72
  }
89
73
  }
90
- this.logger.success(`Schema conversion completed: ${convertedCount}/${filteredStructureDefinitions.length} successful, ${failedCount} failed`);
74
+ this.logger.success(`FHIR Schema conversion completed: ${convertedCount}/${filteredStructureDefinitions.length} successful, ${failedCount} failed`);
75
+ return fhirSchemas;
76
+ }
77
+ async generateValueSetSchemas(valueSets, packageInfo) {
91
78
  if (valueSets.length > 0) {
92
79
  this.logger.debug(`${valueSets.length} ValueSets available for enum extraction`);
93
80
  }
94
- const packageInfo = {
95
- name: packageName,
96
- version: packageVersion || "latest",
97
- };
98
81
  // Process ValueSets separately to add to TypeSchema output
99
82
  const valueSetSchemas = [];
100
83
  if (valueSets.length > 0) {
@@ -117,114 +100,40 @@ export class TypeSchemaGenerator {
117
100
  }
118
101
  this.logger.success(`ValueSet conversion completed: ${valueSetConvertedCount}/${valueSets.length} successful, ${valueSetFailedCount} failed`);
119
102
  }
120
- const schemas = await this.generateFromSchemas(fhirSchemas, packageInfo);
121
- // Add the converted ValueSets to the final results
103
+ return valueSetSchemas;
104
+ }
105
+ async generateFromPackage(packageName, packageVersion) {
106
+ await this.initializeCache();
107
+ if (this.cache && !(this.cacheConfig?.forceRegenerate ?? false)) {
108
+ const cachedSchemas = this.cache.getByPackage(packageName);
109
+ if (cachedSchemas.length > 0) {
110
+ this.logger.info(`Using cached TypeSchemas for package: ${packageName} (${cachedSchemas.length} schemas)`);
111
+ return cachedSchemas;
112
+ }
113
+ }
114
+ const packageInfo = {
115
+ name: packageName,
116
+ version: packageVersion || "latest",
117
+ };
118
+ const { valueSets, structureDefinitions } = await this.fetchPackage(packageName, packageVersion);
119
+ const fhirSchemas = this.generateFhirSchemas(structureDefinitions);
120
+ const valueSetSchemas = await this.generateValueSetSchemas(valueSets, packageInfo);
121
+ const schemas = await this.generateFromSchemas(packageInfo, fhirSchemas);
122
122
  const allSchemas = [...schemas, ...valueSetSchemas];
123
- if (this.cache && allSchemas.length > 0) {
124
- this.logger.info(`Caching ${allSchemas.length} generated schemas for package: ${packageName}`);
123
+ if (this.cache) {
125
124
  for (const schema of allSchemas) {
126
125
  await this.cache.set(schema);
127
126
  }
128
- this.logger.success(`Cached ${allSchemas.length} TypeSchemas for package: ${packageName}`);
129
127
  }
130
128
  return allSchemas;
131
129
  }
132
- /**
133
- * Generate TypeSchema from individual FHIR schema
134
- */
135
- async generateFromSchema(fhirSchema, packageInfo) {
136
- this.logger.info("Transforming FHIR schema to TypeSchema");
137
- return transformFHIRSchema(fhirSchema, this.manager, packageInfo);
138
- }
139
- /**
140
- * Generate TypeSchema from multiple FHIR schemas with FHIR-specific enhancements
141
- */
142
- async generateFromSchemas(fhirSchemas, packageInfo) {
143
- this.logger.info(`Transforming ${fhirSchemas.length} FHIR schemas to TypeSchema`);
144
- const baseSchemas = await transformFHIRSchemas(fhirSchemas, this.manager, packageInfo);
145
- const results = [];
146
- const groupedSchemas = this.groupTypeSchemas(baseSchemas);
147
- results.push(...groupedSchemas.resources);
148
- results.push(...groupedSchemas.complexTypes);
149
- results.push(...groupedSchemas.primitives);
150
- if (groupedSchemas.profiles.length > 0) {
151
- this.logger.info(`Enhancing ${groupedSchemas.profiles.length} profiles`);
152
- const profileResults = await this.enhanceProfiles(groupedSchemas.profiles);
153
- results.push(...profileResults);
154
- }
155
- if (groupedSchemas.extensions.length > 0) {
156
- this.logger.info(`Enhancing ${groupedSchemas.extensions.length} extensions`);
157
- const extensionResults = await this.enhanceExtensions(groupedSchemas.extensions);
158
- results.push(...extensionResults);
159
- }
160
- if (groupedSchemas.valueSets.length > 0) {
161
- this.logger.info(`Enhancing ${groupedSchemas.valueSets.length} value sets`);
162
- const valueSetResults = await this.enhanceValueSets(groupedSchemas.valueSets);
163
- results.push(...valueSetResults);
164
- }
165
- if (groupedSchemas.codeSystems.length > 0) {
166
- this.logger.info(`Enhancing ${groupedSchemas.codeSystems.length} code systems`);
167
- const codeSystemResults = await this.enhanceCodeSystems(groupedSchemas.codeSystems);
168
- results.push(...codeSystemResults);
169
- }
170
- this.logger.success(`Generated ${results.length} enhanced FHIR type schemas: ${groupedSchemas.resources.length} resources, ${groupedSchemas.complexTypes.length} complex types, ${groupedSchemas.primitives.length} primitives`);
171
- return results;
172
- }
173
- groupTypeSchemas(schemas) {
174
- const groups = {
175
- resources: [],
176
- complexTypes: [],
177
- primitives: [],
178
- profiles: [],
179
- extensions: [],
180
- valueSets: [],
181
- codeSystems: [],
182
- };
183
- for (const schema of schemas) {
184
- switch (schema.identifier.kind) {
185
- case "resource":
186
- groups.resources.push(schema);
187
- break;
188
- case "complex-type":
189
- groups.complexTypes.push(schema);
190
- break;
191
- case "primitive-type":
192
- groups.primitives.push(schema);
193
- break;
194
- case "binding":
195
- if ("metadata" in schema && schema.metadata?.isExtension) {
196
- groups.extensions.push(schema);
197
- }
198
- else {
199
- groups.complexTypes.push(schema);
200
- }
201
- break;
202
- case "value-set":
203
- groups.valueSets.push(schema);
204
- break;
205
- default:
206
- if ("metadata" in schema && schema.metadata?.isCodeSystem) {
207
- groups.codeSystems.push(schema);
208
- }
209
- else {
210
- groups.complexTypes.push(schema);
211
- }
212
- break;
213
- }
130
+ async generateFromSchemas(packageInfo, fhirSchemas) {
131
+ this.logger.info(`Transforming ${fhirSchemas.length} FHIR schemas to Type Schema`);
132
+ const typeSchemas = [];
133
+ for (const fhirSchema of fhirSchemas) {
134
+ typeSchemas.push(...(await transformFHIRSchema(this.manager, fhirSchema, packageInfo)));
214
135
  }
215
- return groups;
216
- }
217
- async enhanceProfiles(schemas) {
218
- return schemas;
219
- }
220
- async enhanceExtensions(schemas) {
221
- return schemas;
222
- }
223
- async enhanceValueSets(schemas) {
224
- return schemas;
225
- }
226
- async enhanceCodeSystems(schemas) {
227
- return schemas;
136
+ return typeSchemas;
228
137
  }
229
138
  /**
230
139
  * Apply treeshaking to StructureDefinitions before FHIR schema transformation
@@ -354,24 +263,3 @@ export class TypeSchemaGenerator {
354
263
  return match ? (match[1] ?? null) : null;
355
264
  }
356
265
  }
357
- /**
358
- * Convenience function to generate TypeSchema from a package
359
- */
360
- export async function generateTypeSchemaFromPackage(packageName, options = {}) {
361
- const generator = new TypeSchemaGenerator(options);
362
- return await generator.generateFromPackage(packageName);
363
- }
364
- /**
365
- * Convenience function to generate TypeSchema from FHIR schemas
366
- */
367
- export async function generateTypeSchemaFromSchemas(fhirSchemas, packageInfo, options = {}) {
368
- const generator = new TypeSchemaGenerator(options);
369
- return await generator.generateFromSchemas(fhirSchemas, packageInfo);
370
- }
371
- /**
372
- * Convenience function to generate TypeSchema from a single FHIR schema
373
- */
374
- export async function generateTypeSchemaFromSchema(fhirSchema, packageInfo, options = {}) {
375
- const generator = new TypeSchemaGenerator(options);
376
- return await generator.generateFromSchema(fhirSchema, packageInfo);
377
- }
@@ -9,58 +9,8 @@
9
9
  * - Reading TypeSchema documents
10
10
  * - Validating TypeSchema documents
11
11
  */
12
- import type { TypeSchema } from "./type-schema.types.js";
13
- import type { TypeschemaParserOptions } from "./types.js";
14
- export { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
15
- export type { FHIRSchema, FHIRSchemaElement } from "@atomic-ehr/fhirschema";
16
- export { cacheSchema, clearGlobalCache, getCachedSchema, getGlobalCache, initializeGlobalCache, isCached, TypeSchemaCache, } from "./cache.js";
17
- export { buildEnum, collectBindingSchemas, extractValueSetConcepts, generateBindingSchema, } from "./core/binding.js";
18
- export { buildField, buildNestedField, getElementHierarchy, isExcluded, isNestedElement, isRequired, mergeElementHierarchy, } from "./core/field-builder.js";
19
- export { buildBindingIdentifier, buildNestedIdentifier, buildSchemaIdentifier, buildValueSetIdentifier, dropVersionFromUrl, } from "./core/identifier.js";
20
- export { buildNestedTypes, collectNestedElements, extractNestedDependencies, } from "./core/nested-types.js";
21
- export { transformFHIRSchema, transformFHIRSchemas, } from "./core/transformer.js";
22
- export { generateTypeSchemaFromPackage, generateTypeSchemaFromSchema, generateTypeSchemaFromSchemas, TypeSchemaGenerator, } from "./generator.js";
23
- export { parseTypeSchemaFromFile, parseTypeSchemaFromFiles, parseTypeSchemaFromString, TypeSchemaParser, } from "./parser.js";
12
+ export type { FHIRSchema } from "@atomic-ehr/fhirschema";
13
+ export { TypeSchemaCache } from "./cache.js";
14
+ export { TypeSchemaGenerator } from "./generator.js";
15
+ export { TypeSchemaParser } from "./parser.js";
24
16
  export * from "./type-schema.types.js";
25
- export type { PackageInfo, TypeschemaGeneratorOptions, TypeschemaParserOptions, } from "./types.js";
26
- export { isTypeSchemaBinding, isTypeSchemaForResourceComplexTypeLogical, isTypeSchemaValueSet, } from "./utils.js";
27
- export { transformValueSet } from "./value-set/processor.js";
28
- /**
29
- * TypeSchema Core API class
30
- *
31
- * Provides core TypeSchema functionality: convert, read, and validate.
32
- * Does NOT include target-specific generation (like TypeScript generation).
33
- * Use target generators in src/api/generators/ for output generation.
34
- */
35
- export declare class TypeSchemaAPI {
36
- private generator;
37
- private parser;
38
- private cache;
39
- constructor(options?: {
40
- generator?: any;
41
- parser?: TypeschemaParserOptions;
42
- validator?: {
43
- strict?: boolean;
44
- };
45
- });
46
- /**
47
- * Convert FHIR package to TypeSchema
48
- */
49
- generateFromPackage(packageName: string, packageVersion?: string): Promise<TypeSchema[]>;
50
- /**
51
- * Parse TypeSchema from files
52
- */
53
- parseFromFiles(inputFiles: string[]): Promise<TypeSchema[]>;
54
- }
55
- /**
56
- * Create a new TypeSchema API instance
57
- */
58
- export declare function createTypeSchemaAPI(options?: ConstructorParameters<typeof TypeSchemaAPI>[0]): TypeSchemaAPI;
59
- /**
60
- * Convenience function to convert FHIR package to TypeSchema
61
- */
62
- export declare function generateTypeSchemaFromPackageCore(packageName: string, packageVersion?: string): Promise<TypeSchema[]>;
63
- /**
64
- * Convenience function to parse TypeSchema from files
65
- */
66
- export declare function parseTypeSchemaFromFilesCore(inputFiles: string[]): Promise<TypeSchema[]>;
@@ -9,84 +9,7 @@
9
9
  * - Reading TypeSchema documents
10
10
  * - Validating TypeSchema documents
11
11
  */
12
- import { TypeSchemaCache } from "./cache.js";
13
- import { TypeSchemaGenerator } from "./generator.js";
14
- import { TypeSchemaParser } from "./parser.js";
15
- // Re-export core dependencies
16
- export { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
17
- // Export cache functionality
18
- export { cacheSchema, clearGlobalCache, getCachedSchema, getGlobalCache, initializeGlobalCache, isCached, TypeSchemaCache, } from "./cache.js";
19
- // Re-export utility functions for FHIR processing
20
- export { buildEnum, collectBindingSchemas, extractValueSetConcepts, generateBindingSchema, } from "./core/binding.js";
21
- export { buildField, buildNestedField, getElementHierarchy, isExcluded, isNestedElement, isRequired, mergeElementHierarchy, } from "./core/field-builder.js";
22
- export { buildBindingIdentifier, buildNestedIdentifier, buildSchemaIdentifier, buildValueSetIdentifier, dropVersionFromUrl, } from "./core/identifier.js";
23
- export { buildNestedTypes, collectNestedElements, extractNestedDependencies, } from "./core/nested-types.js";
24
- // Re-export FHIR transformation utilities
25
- export { transformFHIRSchema, transformFHIRSchemas, } from "./core/transformer.js";
26
- // Export generator functionality (FHIR -> TypeSchema)
27
- export { generateTypeSchemaFromPackage, generateTypeSchemaFromSchema, generateTypeSchemaFromSchemas, TypeSchemaGenerator, } from "./generator.js";
28
- // Export parser functionality (Read TypeSchema)
29
- export { parseTypeSchemaFromFile, parseTypeSchemaFromFiles, parseTypeSchemaFromString, TypeSchemaParser, } from "./parser.js";
30
- // Profile processing temporarily disabled (not in core TypeSchema spec)
31
- // export { transformProfile } from "./profile/processor";
32
- // Export new comprehensive types (preferred)
12
+ export { TypeSchemaCache } from "./cache.js";
13
+ export { TypeSchemaGenerator } from "./generator.js";
14
+ export { TypeSchemaParser } from "./parser.js";
33
15
  export * from "./type-schema.types.js";
34
- // Export typeschema-specific utils (renamed to avoid conflicts)
35
- export { isTypeSchemaBinding, isTypeSchemaForResourceComplexTypeLogical, isTypeSchemaValueSet, } from "./utils.js";
36
- // Export value set processing
37
- export { transformValueSet } from "./value-set/processor.js";
38
- /**
39
- * TypeSchema Core API class
40
- *
41
- * Provides core TypeSchema functionality: convert, read, and validate.
42
- * Does NOT include target-specific generation (like TypeScript generation).
43
- * Use target generators in src/api/generators/ for output generation.
44
- */
45
- export class TypeSchemaAPI {
46
- generator;
47
- parser;
48
- cache;
49
- constructor(options = {}) {
50
- this.generator = new TypeSchemaGenerator(options.generator);
51
- this.parser = new TypeSchemaParser(options.parser);
52
- this.cache = new TypeSchemaCache();
53
- }
54
- /**
55
- * Convert FHIR package to TypeSchema
56
- */
57
- async generateFromPackage(packageName, packageVersion) {
58
- const schemas = await this.generator.generateFromPackage(packageName, packageVersion);
59
- // Cache generated schemas
60
- this.cache.setMany(schemas);
61
- return schemas;
62
- }
63
- /**
64
- * Parse TypeSchema from files
65
- */
66
- async parseFromFiles(inputFiles) {
67
- const schemas = await this.parser.parseFromFiles(inputFiles);
68
- // Cache parsed schemas
69
- this.cache.setMany(schemas);
70
- return schemas;
71
- }
72
- }
73
- /**
74
- * Create a new TypeSchema API instance
75
- */
76
- export function createTypeSchemaAPI(options) {
77
- return new TypeSchemaAPI(options);
78
- }
79
- /**
80
- * Convenience function to convert FHIR package to TypeSchema
81
- */
82
- export async function generateTypeSchemaFromPackageCore(packageName, packageVersion) {
83
- const api = createTypeSchemaAPI();
84
- return await api.generateFromPackage(packageName, packageVersion);
85
- }
86
- /**
87
- * Convenience function to parse TypeSchema from files
88
- */
89
- export async function parseTypeSchemaFromFilesCore(inputFiles) {
90
- const api = createTypeSchemaAPI();
91
- return await api.parseFromFiles(inputFiles);
92
- }
@@ -480,9 +480,7 @@ export interface TypeSchemaForBinding {
480
480
  }
481
481
  export type TypeSchemaField = RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
482
482
  export interface TypeschemaGeneratorOptions {
483
- resourceTypes?: string[];
484
483
  verbose?: boolean;
485
- maxDepth?: number;
486
484
  logger?: import("../utils/codegen-logger").CodegenLogger;
487
485
  treeshake?: string[];
488
486
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomic-ehr/codegen",
3
- "version": "0.0.1-canary.20250831211734.bb1536b",
3
+ "version": "0.0.1-canary.20250924082247.588e04a",
4
4
  "description": "Code generation tools for FHIR resources and TypeSchema definitions",
5
5
  "keywords": [
6
6
  "fhir",
@@ -46,6 +46,7 @@
46
46
  "build": "rm -rf dist && bunx tsc --project tsconfig.build.json && bun build src/cli/index.ts --outfile dist/cli/atomic-codegen.js --target node --format esm --minify --external typescript && tail -n +2 dist/cli/atomic-codegen.js > dist/cli/temp.js && echo '#!/usr/bin/env node' > dist/cli/index.js && cat dist/cli/temp.js >> dist/cli/index.js && chmod +x dist/cli/index.js && rm dist/cli/atomic-codegen.js dist/cli/temp.js",
47
47
  "typecheck": "bunx tsc --noEmit",
48
48
  "lint": "biome check --write",
49
+ "format": "biome format --write",
49
50
  "quality": "bun run typecheck && bun run lint && bun run test:unit",
50
51
  "cli": "bun run src/cli/index.ts",
51
52
  "codegen": "bun run src/cli/index.ts",