@atomic-ehr/codegen 0.0.1-canary.20250924120719.44f2f7c → 0.0.1-canary.20250927094522.7f26cfe

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.
Files changed (71) hide show
  1. package/dist/api/builder.d.ts +7 -5
  2. package/dist/api/builder.js +8 -6
  3. package/dist/api/generators/base/BaseGenerator.d.ts +5 -5
  4. package/dist/api/generators/base/BaseGenerator.js +4 -4
  5. package/dist/api/generators/base/FileManager.d.ts +2 -2
  6. package/dist/api/generators/base/FileManager.js +1 -1
  7. package/dist/api/generators/base/PythonTypeMapper.d.ts +3 -3
  8. package/dist/api/generators/base/PythonTypeMapper.js +1 -1
  9. package/dist/api/generators/base/TemplateEngine.d.ts +1 -1
  10. package/dist/api/generators/base/TemplateEngine.js +1 -1
  11. package/dist/api/generators/base/TypeMapper.d.ts +2 -2
  12. package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +3 -3
  13. package/dist/api/generators/base/TypeScriptTypeMapper.js +1 -1
  14. package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +4 -4
  15. package/dist/api/generators/base/builders/FileBuilder.d.ts +2 -2
  16. package/dist/api/generators/base/builders/IndexBuilder.d.ts +2 -2
  17. package/dist/api/generators/base/enhanced-errors.d.ts +2 -2
  18. package/dist/api/generators/base/enhanced-errors.js +1 -1
  19. package/dist/api/generators/base/error-handler.d.ts +2 -2
  20. package/dist/api/generators/base/error-handler.js +1 -1
  21. package/dist/api/generators/base/errors.d.ts +2 -2
  22. package/dist/api/generators/base/index.d.ts +22 -22
  23. package/dist/api/generators/base/index.js +11 -11
  24. package/dist/api/generators/base/types.d.ts +4 -4
  25. package/dist/api/generators/typescript.d.ts +6 -6
  26. package/dist/api/generators/typescript.js +54 -46
  27. package/dist/api/index.d.ts +8 -8
  28. package/dist/api/index.js +3 -3
  29. package/dist/cli/commands/generate/typescript.d.ts +1 -1
  30. package/dist/cli/commands/generate/typescript.js +2 -2
  31. package/dist/cli/commands/generate.d.ts +1 -1
  32. package/dist/cli/commands/generate.js +4 -4
  33. package/dist/cli/commands/index.js +3 -3
  34. package/dist/cli/commands/typeschema/generate.js +3 -3
  35. package/dist/cli/commands/typeschema.js +2 -2
  36. package/dist/cli/index.js +55 -55
  37. package/dist/cli/utils/log.d.ts +2 -2
  38. package/dist/cli/utils/log.js +2 -2
  39. package/dist/config.d.ts +2 -2
  40. package/dist/config.js +5 -5
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +2 -2
  43. package/dist/typeschema/cache.d.ts +7 -7
  44. package/dist/typeschema/core/binding.d.ts +1 -1
  45. package/dist/typeschema/core/binding.js +6 -4
  46. package/dist/typeschema/core/field-builder.d.ts +3 -3
  47. package/dist/typeschema/core/field-builder.js +3 -3
  48. package/dist/typeschema/core/identifier.d.ts +5 -17
  49. package/dist/typeschema/core/identifier.js +15 -47
  50. package/dist/typeschema/core/nested-types.d.ts +2 -2
  51. package/dist/typeschema/core/nested-types.js +2 -2
  52. package/dist/typeschema/core/transformer.d.ts +3 -3
  53. package/dist/typeschema/core/transformer.js +20 -28
  54. package/dist/typeschema/generator.d.ts +3 -4
  55. package/dist/typeschema/generator.js +12 -14
  56. package/dist/typeschema/index.d.ts +4 -5
  57. package/dist/typeschema/index.js +4 -4
  58. package/dist/typeschema/parser.d.ts +5 -5
  59. package/dist/typeschema/profile/processor.d.ts +2 -3
  60. package/dist/typeschema/profile/processor.js +12 -10
  61. package/dist/typeschema/types.d.ts +66 -375
  62. package/dist/typeschema/types.js +14 -2
  63. package/dist/typeschema/value-set/processor.d.ts +1 -1
  64. package/dist/typeschema/value-set/processor.js +1 -1
  65. package/package.json +2 -2
  66. package/dist/typeschema/schema.d.ts +0 -485
  67. package/dist/typeschema/schema.js +0 -456
  68. package/dist/typeschema/type-schema.types.d.ts +0 -186
  69. package/dist/typeschema/type-schema.types.js +0 -39
  70. package/dist/typeschema/utils.d.ts +0 -6
  71. package/dist/typeschema/utils.js +0 -13
@@ -1,5 +1,5 @@
1
- import type { TypeSchema, TypeSchemaIdentifier } from "./type-schema.types.js";
2
- import type { TypeschemaParserOptions } from "./types.js";
1
+ import type { TypeSchema, Identifier } from "@typeschema/types";
2
+ import type { TypeschemaParserOptions } from "./types";
3
3
  /**
4
4
  * TypeSchema Parser class
5
5
  *
@@ -28,7 +28,7 @@ export declare class TypeSchemaParser {
28
28
  /**
29
29
  * Find schemas by identifier
30
30
  */
31
- findByIdentifier(schemas: TypeSchema[], identifier: Partial<TypeSchemaIdentifier>): TypeSchema[];
31
+ findByIdentifier(schemas: TypeSchema[], identifier: Partial<Identifier>): TypeSchema[];
32
32
  /**
33
33
  * Find schema by URL
34
34
  */
@@ -36,7 +36,7 @@ export declare class TypeSchemaParser {
36
36
  /**
37
37
  * Find schemas by kind
38
38
  */
39
- findByKind(schemas: TypeSchema[], kind: TypeSchemaIdentifier["kind"]): TypeSchema[];
39
+ findByKind(schemas: TypeSchema[], kind: Identifier["kind"]): TypeSchema[];
40
40
  /**
41
41
  * Find schemas by package
42
42
  */
@@ -44,7 +44,7 @@ export declare class TypeSchemaParser {
44
44
  /**
45
45
  * Get all dependencies from a schema
46
46
  */
47
- getDependencies(schema: TypeSchema): TypeSchemaIdentifier[];
47
+ getDependencies(schema: TypeSchema): Identifier[];
48
48
  /**
49
49
  * Resolve schema dependencies
50
50
  */
@@ -5,10 +5,9 @@
5
5
  * This file is deprecated as profiles are not part of the core TypeSchema specification
6
6
  */
7
7
  import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
8
- import type { FHIRSchema } from "@atomic-ehr/fhirschema";
9
- import type { PackageInfo, TypeSchemaForProfile } from "../types.js";
8
+ import type { TypeSchemaForProfile } from "../types";
10
9
  /**
11
10
  * Transform a FHIR profile to TypeSchema format
12
11
  * Profiles are treated as specialized resources that extend base resources
13
12
  */
14
- export declare function transformProfile(fhirSchema: FHIRSchema, manager: ReturnType<typeof CanonicalManager>, packageInfo?: PackageInfo): Promise<TypeSchemaForProfile>;
13
+ export declare function transformProfile(fhirSchema: RichFHIRSchema, manager: ReturnType<typeof CanonicalManager>): Promise<TypeSchemaForProfile>;
@@ -5,15 +5,16 @@
5
5
  * Handles transformation of FHIR profiles to TypeSchema format
6
6
  * This file is deprecated as profiles are not part of the core TypeSchema specification
7
7
  */
8
- import { buildSchemaIdentifier } from "../core/identifier.js";
9
- import { transformElements } from "../core/transformer.js";
8
+ import { buildSchemaIdentifier } from "../core/identifier";
9
+ import { transformElements } from "../core/transformer";
10
10
  /**
11
11
  * Transform a FHIR profile to TypeSchema format
12
12
  * Profiles are treated as specialized resources that extend base resources
13
13
  */
14
- export async function transformProfile(fhirSchema, manager, packageInfo) {
14
+ export async function transformProfile(fhirSchema, manager) {
15
15
  // Build profile identifier
16
- const identifier = buildSchemaIdentifier(fhirSchema, packageInfo);
16
+ const identifier = buildSchemaIdentifier(fhirSchema);
17
+ const packageInfo = fhirSchema.package_meta;
17
18
  // Ensure this is recognized as a profile
18
19
  if (identifier.kind !== "profile") {
19
20
  throw new Error(`Expected profile, got ${identifier.kind} for ${fhirSchema.name}`);
@@ -33,10 +34,10 @@ export async function transformProfile(fhirSchema, manager, packageInfo) {
33
34
  kind: baseKind,
34
35
  package: isStandardFhir
35
36
  ? "hl7.fhir.r4.core"
36
- : packageInfo?.name || fhirSchema.package_name || "undefined",
37
+ : fhirSchema.package_meta.name || "undefined",
37
38
  version: isStandardFhir
38
39
  ? "4.0.1"
39
- : packageInfo?.version || fhirSchema.package_version || "undefined",
40
+ : fhirSchema.package_meta.version || "undefined",
40
41
  name: baseName,
41
42
  url: baseUrl,
42
43
  };
@@ -52,7 +53,7 @@ export async function transformProfile(fhirSchema, manager, packageInfo) {
52
53
  profileSchema.description = fhirSchema.description;
53
54
  }
54
55
  // Add profile-specific metadata
55
- const metadata = extractProfileMetadata(fhirSchema, packageInfo);
56
+ const metadata = extractProfileMetadata(fhirSchema);
56
57
  if (Object.keys(metadata).length > 0) {
57
58
  profileSchema.metadata = metadata;
58
59
  }
@@ -117,8 +118,9 @@ async function determineBaseKind(baseUrl, manager) {
117
118
  /**
118
119
  * Extract profile metadata from FHIR schema
119
120
  */
120
- function extractProfileMetadata(fhirSchema, packageInfo) {
121
+ function extractProfileMetadata(fhirSchema) {
121
122
  const metadata = {};
123
+ const packageInfo = fhirSchema.package_meta;
122
124
  // Add profile-specific metadata
123
125
  // @ts-ignore
124
126
  if (fhirSchema.publisher)
@@ -149,9 +151,9 @@ function extractProfileMetadata(fhirSchema, packageInfo) {
149
151
  metadata.package = packageInfo.name;
150
152
  // @ts-ignore
151
153
  }
152
- else if (fhirSchema.package_name) {
154
+ else if (fhirSchema.package_meta.name) {
153
155
  // @ts-ignore
154
- metadata.package = fhirSchema.package_name;
156
+ metadata.package = fhirSchema.package_meta.name;
155
157
  }
156
158
  return metadata;
157
159
  }
@@ -1,495 +1,186 @@
1
1
  /**
2
- * A code generation friendly representation of FHIR StructureDefinition and FHIR Schema designed to simplify SDK resource classes/types generation.
2
+ * A code generation friendly representation of FHIR StructureDefinition and
3
+ * FHIR Schema designed to simplify SDK resource classes/types generation.
3
4
  */
4
- export type TypeSchemaIdentifierBase = {
5
+ import type * as FS from "@atomic-ehr/fhirschema";
6
+ import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
7
+ export interface PackageInfo {
8
+ name: string;
9
+ version: string;
10
+ }
11
+ export type RichFHIRSchema = Omit<FS.FHIRSchema, "package_meta"> & {
12
+ package_meta: PackageInfo;
13
+ };
14
+ export declare const enrichFHIRSchema: (schema: FS.FHIRSchema) => RichFHIRSchema;
15
+ type IdentifierBase = {
5
16
  name: string;
6
17
  package: string;
7
18
  version: string;
8
19
  url: string;
9
20
  };
10
- export type TypeSchema = TypeSchemaForPrimitiveType | TypeSchemaForResourceComplexTypeLogical | TypeSchemaForValueSet | TypeSchemaForBinding | TypeSchemaForProfile;
11
- export type TypeSchemaIdentifier = TypeSchemaIdentifierBase & (WithProfileKind | WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
12
- /**
13
- * Schema for basic FHIR data types like string, boolean, decimal
14
- */
15
- export interface TypeSchemaForPrimitiveType {
16
- /**
17
- * The unique identifier for this primitive type
18
- */
19
- identifier: TypeSchemaIdentifier & WithPrimitiveTypeKind;
20
- /**
21
- * Human-readable description of the primitive type
22
- */
23
- description?: string;
24
- /**
25
- * The base type this primitive type extends (typically Element)
26
- */
27
- base: WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind;
28
- /**
29
- * Other types that this primitive type depends on
30
- */
31
- dependencies?: TypeSchemaIdentifier[];
32
- }
33
- /**
34
- * Constraint helper to ensure the kind profile
35
- */
36
- export interface WithProfileKind {
37
- kind: "profile";
38
- [k: string]: unknown;
39
- }
40
- /**
41
- * Constraint helper to ensure the kind is primitive-type
42
- */
43
- export interface WithPrimitiveTypeKind {
21
+ type PrimitiveIdentifier = {
44
22
  kind: "primitive-type";
45
- [k: string]: unknown;
46
- }
47
- /**
48
- * Constraint helper to ensure the kind is value-set
49
- */
50
- export interface WithValuesetKind {
51
- kind: "value-set";
52
- [k: string]: unknown;
53
- }
54
- /**
55
- * Constraint helper to ensure the kind is complex-type
56
- */
57
- export interface WithComplexTypeKind {
23
+ } & IdentifierBase;
24
+ type ComplexTypeIdentifier = {
58
25
  kind: "complex-type";
59
- [k: string]: unknown;
60
- }
61
- /**
62
- * Constraint helper to ensure the kind is resource
63
- */
64
- export interface WithResourceKind {
26
+ } & IdentifierBase;
27
+ type ResourceIdentifier = {
65
28
  kind: "resource";
66
- [k: string]: unknown;
67
- }
68
- /**
69
- * Constraint helper to ensure the kind is nested
70
- */
71
- export interface WithNestedKind {
29
+ } & IdentifierBase;
30
+ type ValueSetIdentifier = {
31
+ kind: "value-set";
32
+ } & IdentifierBase;
33
+ type NestedIdentifier = {
72
34
  kind: "nested";
73
- [k: string]: unknown;
74
- }
75
- /**
76
- * Constraint helper to ensure the kind is logical
77
- */
78
- export interface WithLogicalKind {
79
- kind: "logical";
80
- [k: string]: unknown;
81
- }
82
- /**
83
- * Constraint helper to ensure the kind is value-set
84
- */
85
- export interface WithBindingKind {
35
+ } & IdentifierBase;
36
+ type BindingIdentifier = {
86
37
  kind: "binding";
87
- [k: string]: unknown;
38
+ } & IdentifierBase;
39
+ type ProfileIdentifier = {
40
+ kind: "profile";
41
+ } & IdentifierBase;
42
+ type LogicalIdentifier = {
43
+ kind: "logical";
44
+ } & IdentifierBase;
45
+ export type Identifier = PrimitiveIdentifier | ComplexTypeIdentifier | ResourceIdentifier | NestedIdentifier | BindingIdentifier | ValueSetIdentifier | ProfileIdentifier | LogicalIdentifier;
46
+ export type TypeSchema = TypeSchemaForPrimitiveType | TypeSchemaForResourceComplexTypeLogical | TypeSchemaForValueSet | TypeSchemaForBinding | TypeSchemaForProfile;
47
+ interface TypeSchemaForPrimitiveType {
48
+ identifier: PrimitiveIdentifier;
49
+ description?: string;
50
+ base: Identifier;
51
+ dependencies?: Identifier[];
88
52
  }
89
- export interface TypeSchemaForProfile {
90
- identifier: TypeSchemaIdentifier & WithProfileKind;
91
- /**
92
- * The base resource or type this profile constrains
93
- */
94
- base: TypeSchemaIdentifier;
95
- /**
96
- * Human-readable description of the profile
97
- */
53
+ interface TypeSchemaForProfile {
54
+ identifier: ProfileIdentifier;
55
+ base: Identifier;
98
56
  description?: string;
99
- /**
100
- * Fields defined or constrained by this profile
101
- */
102
57
  fields?: Record<string, TypeSchemaField>;
103
- /**
104
- * Profile-specific constraints on elements
105
- */
106
58
  constraints?: Record<string, ProfileConstraint>;
107
- /**
108
- * Extensions used by this profile
109
- */
110
59
  extensions?: ProfileExtension[];
111
- /**
112
- * Validation rules specific to this profile
113
- */
114
60
  validation?: ValidationRule[];
115
- /**
116
- * Other types that this profile depends on
117
- */
118
- dependencies?: TypeSchemaIdentifier[];
119
- /**
120
- * Additional profile metadata
121
- */
61
+ dependencies?: Identifier[];
122
62
  metadata?: ProfileMetadata;
123
- /**
124
- * Nested types if any
125
- */
126
63
  nested?: any[];
127
64
  }
128
- /**
129
- * Profile constraint on a field
130
- */
131
- export interface ProfileConstraint {
132
- /**
133
- * Minimum cardinality
134
- */
65
+ interface ProfileConstraint {
135
66
  min?: number;
136
- /**
137
- * Maximum cardinality
138
- */
139
67
  max?: string;
140
- /**
141
- * Must Support flag
142
- */
143
68
  mustSupport?: boolean;
144
- /**
145
- * Fixed value constraint
146
- */
147
69
  fixedValue?: any;
148
- /**
149
- * Pattern value constraint
150
- */
151
70
  patternValue?: any;
152
- /**
153
- * Value set binding constraint
154
- */
155
71
  binding?: {
156
72
  strength: "required" | "extensible" | "preferred" | "example";
157
73
  valueSet: string;
158
74
  };
159
- /**
160
- * Type constraints
161
- */
162
75
  types?: Array<{
163
76
  code: string;
164
77
  profile?: string[];
165
78
  targetProfile?: string[];
166
79
  }>;
167
- /**
168
- * Slicing information
169
- */
170
80
  slicing?: {
171
81
  discriminator: any[];
172
82
  rules: string;
173
83
  ordered?: boolean;
174
84
  };
175
85
  }
176
- /**
177
- * Profile extension information
178
- */
179
- export interface ProfileExtension {
180
- /**
181
- * Element path where extension applies
182
- */
86
+ interface ProfileExtension {
183
87
  path: string;
184
- /**
185
- * Extension profile URL
186
- */
187
88
  profile: string | string[];
188
- /**
189
- * Minimum cardinality
190
- */
191
89
  min?: number;
192
- /**
193
- * Maximum cardinality
194
- */
195
90
  max?: string;
196
- /**
197
- * Must Support flag
198
- */
199
91
  mustSupport?: boolean;
200
92
  }
201
- /**
202
- * Profile validation rule
203
- */
204
- export interface ValidationRule {
205
- /**
206
- * Element path this rule applies to
207
- */
93
+ interface ValidationRule {
208
94
  path: string;
209
- /**
210
- * Rule key/identifier
211
- */
212
95
  key: string;
213
- /**
214
- * Severity level
215
- */
216
96
  severity: "error" | "warning" | "information";
217
- /**
218
- * Human readable description
219
- */
220
97
  human: string;
221
- /**
222
- * FHIRPath expression
223
- */
224
98
  expression?: string;
225
99
  }
226
- /**
227
- * Profile metadata
228
- */
229
- export interface ProfileMetadata {
230
- /**
231
- * Publisher information
232
- */
100
+ interface ProfileMetadata {
233
101
  publisher?: string;
234
- /**
235
- * Contact information
236
- */
237
102
  contact?: any[];
238
- /**
239
- * Copyright notice
240
- */
241
103
  copyright?: string;
242
- /**
243
- * Purpose statement
244
- */
245
104
  purpose?: string;
246
- /**
247
- * Experimental flag
248
- */
249
105
  experimental?: boolean;
250
- /**
251
- * Publication date
252
- */
253
106
  date?: string;
254
- /**
255
- * Jurisdiction
256
- */
257
107
  jurisdiction?: any[];
258
- /**
259
- * Package information
260
- */
261
108
  package?: string;
262
109
  }
263
- /**
264
- * Schema for FHIR resources, complex types, and logical types
265
- */
266
110
  export interface TypeSchemaForResourceComplexTypeLogical {
267
- /**
268
- * The unique identifier for this resource or type
269
- */
270
- identifier: TypeSchemaIdentifier & (WithResourceKind | WithComplexTypeKind | WithLogicalKind);
271
- /**
272
- * The base type this resource or type extends
273
- */
274
- base?: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
275
- /**
276
- * Human-readable description of the resource or type
277
- */
111
+ identifier: ResourceIdentifier | ComplexTypeIdentifier | LogicalIdentifier;
112
+ base?: Identifier;
278
113
  description?: string;
279
- /**
280
- * The fields contained in this resource or type
281
- */
282
114
  fields?: {
283
115
  [k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
284
116
  };
285
- /**
286
- * BackboneElement types nested within this resource or type
287
- */
288
117
  nested?: {
289
- /**
290
- * The unique identifier for this nested type
291
- */
292
- identifier: TypeSchemaIdentifier & WithNestedKind;
293
- /**
294
- * The base type this nested type extends (typically BackboneElement)
295
- */
296
- base: WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind;
297
- /**
298
- * The fields contained in this nested type
299
- */
118
+ identifier: NestedIdentifier;
119
+ base: Identifier;
300
120
  fields?: {
301
121
  [k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
302
122
  };
303
123
  }[];
304
- /**
305
- * Other types that this resource or type depends on
306
- */
307
- dependencies?: TypeSchemaIdentifier[];
124
+ dependencies?: Identifier[];
308
125
  }
309
- /**
310
- * A standard field with a single type
311
- */
312
126
  export interface RegularField {
313
- /**
314
- * The data type of this field
315
- */
316
- type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
317
- /**
318
- * Reference to other types that this field can point to
319
- */
320
- reference?: TypeSchemaIdentifier[];
321
- /**
322
- * Whether this field must be provided in valid instances
323
- */
127
+ type: Identifier;
128
+ reference?: Identifier[];
324
129
  required?: boolean;
325
- /**
326
- * Whether this field is prohibited in valid instances
327
- */
328
130
  excluded?: boolean;
329
- /**
330
- * Whether this field can contain multiple values (cardinality > 1)
331
- */
332
131
  array?: boolean;
333
- binding?: TypeSchemaIdentifier & WithBindingKind;
334
- /**
335
- * For code fields, the set of valid values when bound to a required value set
336
- */
132
+ binding?: BindingIdentifier;
337
133
  enum?: string[];
338
- /**
339
- * Minimum limit of items for an array
340
- */
341
134
  min?: number;
342
- /**
343
- * Maximum limit of items for an array
344
- */
345
135
  max?: number;
346
136
  }
347
- /**
348
- * The base declaration for a FHIR choice type (e.g., value[x])
349
- */
350
137
  export interface PolymorphicValueXFieldDeclaration {
351
- /**
352
- * The names of all concrete type options for this choice field
353
- */
354
138
  choices: string[];
355
- /**
356
- * Whether at least one choice must be provided
357
- */
358
139
  required?: boolean;
359
- /**
360
- * Whether all choices are prohibited
361
- */
362
140
  excluded?: boolean;
363
- /**
364
- * Whether the selected choice can contain multiple values
365
- */
366
141
  array?: boolean;
367
- /**
368
- * Minimum limit of items for an array
369
- */
370
142
  min?: number;
371
- /**
372
- * Maximum limit of items for an array
373
- */
374
143
  max?: number;
375
144
  }
376
- /**
377
- * A specific type option for a FHIR choice type (e.g., valueString, valueInteger)
378
- */
379
145
  export interface PolymorphicValueXFieldInstance {
380
- /**
381
- * The name of the choice field this instance belongs to (e.g., 'value' for valueString)
382
- */
383
146
  choiceOf: string;
384
- /**
385
- * The data type of this choice option
386
- */
387
- type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
388
- /**
389
- * Whether this specific choice must be provided
390
- */
147
+ type: Identifier;
391
148
  required?: boolean;
392
- /**
393
- * Whether this specific choice is prohibited
394
- */
395
149
  excluded?: boolean;
396
- /**
397
- * Whether this choice can contain multiple values
398
- */
399
150
  array?: boolean;
400
- /**
401
- * Reference to other types that this field can point to
402
- */
403
- reference?: TypeSchemaIdentifier[];
404
- /**
405
- * For coded choices, information about the value set binding
406
- */
407
- binding?: TypeSchemaIdentifier & WithBindingKind;
408
- /**
409
- * For code fields, the set of valid values when bound to a required value set
410
- */
151
+ reference?: Identifier[];
152
+ binding?: BindingIdentifier;
411
153
  enum?: string[];
412
- /**
413
- * Minimum limit of items for an array
414
- */
415
154
  min?: number;
416
- /**
417
- * Maximum limit of items for an array
418
- */
419
155
  max?: number;
420
156
  }
421
- /**
422
- * Schema for FHIR value sets that define terminology bindings
423
- */
424
157
  export interface TypeSchemaForValueSet {
425
- /**
426
- * The unique identifier for this value set
427
- */
428
- identifier: TypeSchemaIdentifier & WithValuesetKind;
429
- /**
430
- * Human-readable description of the value set
431
- */
158
+ identifier: ValueSetIdentifier;
432
159
  description?: string;
433
- /**
434
- * The list of coded concepts contained in this value set
435
- */
436
160
  concept?: {
437
- /**
438
- * The code value
439
- */
440
161
  code: string;
441
- /**
442
- * The human-readable display text for this code
443
- */
444
162
  display?: string;
445
- /**
446
- * The code system URL that defines this code
447
- */
448
163
  system?: string;
449
164
  }[];
450
- /**
451
- * Complex value set composition rules when the value set is defined as a composition of other value sets
452
- */
453
165
  compose?: {
454
166
  [k: string]: unknown;
455
167
  };
456
168
  }
457
169
  export interface TypeSchemaForBinding {
458
- /**
459
- * The unique identifier for this value set
460
- */
461
- identifier: TypeSchemaIdentifier & WithBindingKind;
462
- /**
463
- * Human-readable description of the value set
464
- */
170
+ identifier: BindingIdentifier;
465
171
  description?: string;
466
- type?: TypeSchemaIdentifier;
467
- /**
468
- * The strength of the binding
469
- */
172
+ type?: Identifier;
470
173
  strength?: string;
471
- /**
472
- * The enumeration of values for the binding
473
- */
474
174
  enum?: string[];
475
- valueset?: TypeSchemaIdentifier & WithValuesetKind;
476
- /**
477
- * Other types that this resource or type depends on
478
- */
479
- dependencies?: TypeSchemaIdentifier[];
175
+ valueset?: ValueSetIdentifier;
176
+ dependencies?: Identifier[];
480
177
  }
481
178
  export type TypeSchemaField = RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
482
179
  export interface TypeschemaGeneratorOptions {
483
180
  verbose?: boolean;
484
181
  logger?: import("../utils/codegen-logger").CodegenLogger;
485
182
  treeshake?: string[];
183
+ manager?: ReturnType<typeof CanonicalManager> | null;
486
184
  }
487
- export interface PackageInfo {
488
- name: string;
489
- version: string;
490
- }
491
- export type TypeschemaParserOptions = {
492
- format?: "auto" | "ndjson" | "json";
493
- validate?: boolean;
494
- strict?: boolean;
495
- };
185
+ export declare function isBindingSchema(schema: TypeSchema): schema is TypeSchemaForBinding;
186
+ export {};
@@ -1,4 +1,16 @@
1
1
  /**
2
- * A code generation friendly representation of FHIR StructureDefinition and FHIR Schema designed to simplify SDK resource classes/types generation.
2
+ * A code generation friendly representation of FHIR StructureDefinition and
3
+ * FHIR Schema designed to simplify SDK resource classes/types generation.
3
4
  */
4
- export {};
5
+ export const enrichFHIRSchema = (schema) => {
6
+ return {
7
+ ...schema,
8
+ package_meta: {
9
+ name: schema.package_name || schema.package_meta?.name || "undefined",
10
+ version: schema.package_version || schema.package_meta?.version || "undefined",
11
+ },
12
+ };
13
+ };
14
+ export function isBindingSchema(schema) {
15
+ return schema.identifier.kind === "binding";
16
+ }