@atomic-ehr/codegen 0.0.1-canary.20250808231821.ab61009
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/README.md +446 -0
- package/dist/api/builder.d.ts +147 -0
- package/dist/api/builder.d.ts.map +1 -0
- package/dist/api/generators/typescript.d.ts +129 -0
- package/dist/api/generators/typescript.d.ts.map +1 -0
- package/dist/api/index.d.ts +51 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/cli/commands/generate/typescript.d.ts +11 -0
- package/dist/cli/commands/generate/typescript.d.ts.map +1 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/index.d.ts +40 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/typeschema/generate.d.ts +18 -0
- package/dist/cli/commands/typeschema/generate.d.ts.map +1 -0
- package/dist/cli/commands/typeschema.d.ts +11 -0
- package/dist/cli/commands/typeschema.d.ts.map +1 -0
- package/dist/cli/index.d.ts +11 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/utils/prompts.d.ts +57 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/spinner.d.ts +111 -0
- package/dist/cli/utils/spinner.d.ts.map +1 -0
- package/dist/config.d.ts +171 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4008 -0
- package/dist/logger.d.ts +158 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/types/base.d.ts +66 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/typeschema/cache.d.ts +105 -0
- package/dist/typeschema/cache.d.ts.map +1 -0
- package/dist/typeschema/core/binding.d.ts +29 -0
- package/dist/typeschema/core/binding.d.ts.map +1 -0
- package/dist/typeschema/core/field-builder.d.ts +45 -0
- package/dist/typeschema/core/field-builder.d.ts.map +1 -0
- package/dist/typeschema/core/identifier.d.ts +28 -0
- package/dist/typeschema/core/identifier.d.ts.map +1 -0
- package/dist/typeschema/core/nested-types.d.ts +25 -0
- package/dist/typeschema/core/nested-types.d.ts.map +1 -0
- package/dist/typeschema/core/transformer.d.ts +18 -0
- package/dist/typeschema/core/transformer.d.ts.map +1 -0
- package/dist/typeschema/generator.d.ts +57 -0
- package/dist/typeschema/generator.d.ts.map +1 -0
- package/dist/typeschema/index.d.ts +66 -0
- package/dist/typeschema/index.d.ts.map +1 -0
- package/dist/typeschema/parser.d.ts +92 -0
- package/dist/typeschema/parser.d.ts.map +1 -0
- package/dist/typeschema/profile/processor.d.ts +14 -0
- package/dist/typeschema/profile/processor.d.ts.map +1 -0
- package/dist/typeschema/schema.d.ts +486 -0
- package/dist/typeschema/schema.d.ts.map +1 -0
- package/dist/typeschema/types.d.ts +326 -0
- package/dist/typeschema/types.d.ts.map +1 -0
- package/dist/typeschema/utils.d.ts +7 -0
- package/dist/typeschema/utils.d.ts.map +1 -0
- package/dist/typeschema/value-set/processor.d.ts +20 -0
- package/dist/typeschema/value-set/processor.d.ts.map +1 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +60 -0
- package/src/index.ts +86 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A code generation friendly representation of FHIR StructureDefinition and FHIR Schema designed to simplify SDK resource classes/types generation.
|
|
3
|
+
*/
|
|
4
|
+
export type TypeSchemaIdentifierBase = {
|
|
5
|
+
name: string;
|
|
6
|
+
package: string;
|
|
7
|
+
version: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
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 {
|
|
44
|
+
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 {
|
|
58
|
+
kind: "complex-type";
|
|
59
|
+
[k: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Constraint helper to ensure the kind is resource
|
|
63
|
+
*/
|
|
64
|
+
export interface WithResourceKind {
|
|
65
|
+
kind: "resource";
|
|
66
|
+
[k: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Constraint helper to ensure the kind is nested
|
|
70
|
+
*/
|
|
71
|
+
export interface WithNestedKind {
|
|
72
|
+
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 {
|
|
86
|
+
kind: "binding";
|
|
87
|
+
[k: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
export interface TypeSchemaForProfile {
|
|
90
|
+
identifier: TypeSchemaIdentifier & WithProfileKind;
|
|
91
|
+
[k: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Schema for FHIR resources, complex types, and logical types
|
|
95
|
+
*/
|
|
96
|
+
export interface TypeSchemaForResourceComplexTypeLogical {
|
|
97
|
+
/**
|
|
98
|
+
* The unique identifier for this resource or type
|
|
99
|
+
*/
|
|
100
|
+
identifier: TypeSchemaIdentifier & (WithResourceKind | WithComplexTypeKind | WithLogicalKind);
|
|
101
|
+
/**
|
|
102
|
+
* The base type this resource or type extends
|
|
103
|
+
*/
|
|
104
|
+
base?: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
105
|
+
/**
|
|
106
|
+
* Human-readable description of the resource or type
|
|
107
|
+
*/
|
|
108
|
+
description?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The fields contained in this resource or type
|
|
111
|
+
*/
|
|
112
|
+
fields?: {
|
|
113
|
+
[k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* BackboneElement types nested within this resource or type
|
|
117
|
+
*/
|
|
118
|
+
nested?: {
|
|
119
|
+
/**
|
|
120
|
+
* The unique identifier for this nested type
|
|
121
|
+
*/
|
|
122
|
+
identifier: TypeSchemaIdentifier & WithNestedKind;
|
|
123
|
+
/**
|
|
124
|
+
* The base type this nested type extends (typically BackboneElement)
|
|
125
|
+
*/
|
|
126
|
+
base: WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind;
|
|
127
|
+
/**
|
|
128
|
+
* The fields contained in this nested type
|
|
129
|
+
*/
|
|
130
|
+
fields?: {
|
|
131
|
+
[k: string]: RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
132
|
+
};
|
|
133
|
+
}[];
|
|
134
|
+
/**
|
|
135
|
+
* Other types that this resource or type depends on
|
|
136
|
+
*/
|
|
137
|
+
dependencies?: TypeSchemaIdentifier[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A standard field with a single type
|
|
141
|
+
*/
|
|
142
|
+
export interface RegularField {
|
|
143
|
+
/**
|
|
144
|
+
* The data type of this field
|
|
145
|
+
*/
|
|
146
|
+
type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
147
|
+
/**
|
|
148
|
+
* Reference to other types that this field can point to
|
|
149
|
+
*/
|
|
150
|
+
reference?: TypeSchemaIdentifier[];
|
|
151
|
+
/**
|
|
152
|
+
* Whether this field must be provided in valid instances
|
|
153
|
+
*/
|
|
154
|
+
required?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether this field is prohibited in valid instances
|
|
157
|
+
*/
|
|
158
|
+
excluded?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether this field can contain multiple values (cardinality > 1)
|
|
161
|
+
*/
|
|
162
|
+
array?: boolean;
|
|
163
|
+
binding?: TypeSchemaIdentifier & WithBindingKind;
|
|
164
|
+
/**
|
|
165
|
+
* For code fields, the set of valid values when bound to a required value set
|
|
166
|
+
*/
|
|
167
|
+
enum?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* Minimum limit of items for an array
|
|
170
|
+
*/
|
|
171
|
+
min?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Maximum limit of items for an array
|
|
174
|
+
*/
|
|
175
|
+
max?: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The base declaration for a FHIR choice type (e.g., value[x])
|
|
179
|
+
*/
|
|
180
|
+
export interface PolymorphicValueXFieldDeclaration {
|
|
181
|
+
/**
|
|
182
|
+
* The names of all concrete type options for this choice field
|
|
183
|
+
*/
|
|
184
|
+
choices: string[];
|
|
185
|
+
/**
|
|
186
|
+
* Whether at least one choice must be provided
|
|
187
|
+
*/
|
|
188
|
+
required?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Whether all choices are prohibited
|
|
191
|
+
*/
|
|
192
|
+
excluded?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Whether the selected choice can contain multiple values
|
|
195
|
+
*/
|
|
196
|
+
array?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Minimum limit of items for an array
|
|
199
|
+
*/
|
|
200
|
+
min?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Maximum limit of items for an array
|
|
203
|
+
*/
|
|
204
|
+
max?: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A specific type option for a FHIR choice type (e.g., valueString, valueInteger)
|
|
208
|
+
*/
|
|
209
|
+
export interface PolymorphicValueXFieldInstance {
|
|
210
|
+
/**
|
|
211
|
+
* The name of the choice field this instance belongs to (e.g., 'value' for valueString)
|
|
212
|
+
*/
|
|
213
|
+
choiceOf: string;
|
|
214
|
+
/**
|
|
215
|
+
* The data type of this choice option
|
|
216
|
+
*/
|
|
217
|
+
type: TypeSchemaIdentifierBase & (WithPrimitiveTypeKind | WithValuesetKind | WithComplexTypeKind | WithResourceKind | WithNestedKind | WithLogicalKind | WithBindingKind);
|
|
218
|
+
/**
|
|
219
|
+
* Whether this specific choice must be provided
|
|
220
|
+
*/
|
|
221
|
+
required?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Whether this specific choice is prohibited
|
|
224
|
+
*/
|
|
225
|
+
excluded?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether this choice can contain multiple values
|
|
228
|
+
*/
|
|
229
|
+
array?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Reference to other types that this field can point to
|
|
232
|
+
*/
|
|
233
|
+
reference?: TypeSchemaIdentifier[];
|
|
234
|
+
/**
|
|
235
|
+
* For coded choices, information about the value set binding
|
|
236
|
+
*/
|
|
237
|
+
binding?: TypeSchemaIdentifier & WithBindingKind;
|
|
238
|
+
/**
|
|
239
|
+
* For code fields, the set of valid values when bound to a required value set
|
|
240
|
+
*/
|
|
241
|
+
enum?: string[];
|
|
242
|
+
/**
|
|
243
|
+
* Minimum limit of items for an array
|
|
244
|
+
*/
|
|
245
|
+
min?: number;
|
|
246
|
+
/**
|
|
247
|
+
* Maximum limit of items for an array
|
|
248
|
+
*/
|
|
249
|
+
max?: number;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Schema for FHIR value sets that define terminology bindings
|
|
253
|
+
*/
|
|
254
|
+
export interface TypeSchemaForValueSet {
|
|
255
|
+
/**
|
|
256
|
+
* The unique identifier for this value set
|
|
257
|
+
*/
|
|
258
|
+
identifier: TypeSchemaIdentifier & WithValuesetKind;
|
|
259
|
+
/**
|
|
260
|
+
* Human-readable description of the value set
|
|
261
|
+
*/
|
|
262
|
+
description?: string;
|
|
263
|
+
/**
|
|
264
|
+
* The list of coded concepts contained in this value set
|
|
265
|
+
*/
|
|
266
|
+
concept?: {
|
|
267
|
+
/**
|
|
268
|
+
* The code value
|
|
269
|
+
*/
|
|
270
|
+
code: string;
|
|
271
|
+
/**
|
|
272
|
+
* The human-readable display text for this code
|
|
273
|
+
*/
|
|
274
|
+
display?: string;
|
|
275
|
+
/**
|
|
276
|
+
* The code system URL that defines this code
|
|
277
|
+
*/
|
|
278
|
+
system?: string;
|
|
279
|
+
}[];
|
|
280
|
+
/**
|
|
281
|
+
* Complex value set composition rules when the value set is defined as a composition of other value sets
|
|
282
|
+
*/
|
|
283
|
+
compose?: {
|
|
284
|
+
[k: string]: unknown;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
export interface TypeSchemaForBinding {
|
|
288
|
+
/**
|
|
289
|
+
* The unique identifier for this value set
|
|
290
|
+
*/
|
|
291
|
+
identifier: TypeSchemaIdentifier & WithBindingKind;
|
|
292
|
+
/**
|
|
293
|
+
* Human-readable description of the value set
|
|
294
|
+
*/
|
|
295
|
+
description?: string;
|
|
296
|
+
type?: TypeSchemaIdentifier;
|
|
297
|
+
/**
|
|
298
|
+
* The strength of the binding
|
|
299
|
+
*/
|
|
300
|
+
strength?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The enumeration of values for the binding
|
|
303
|
+
*/
|
|
304
|
+
enum?: string[];
|
|
305
|
+
valueset?: TypeSchemaIdentifier & WithValuesetKind;
|
|
306
|
+
/**
|
|
307
|
+
* Other types that this resource or type depends on
|
|
308
|
+
*/
|
|
309
|
+
dependencies?: TypeSchemaIdentifier[];
|
|
310
|
+
}
|
|
311
|
+
export type TypeSchemaField = RegularField | PolymorphicValueXFieldDeclaration | PolymorphicValueXFieldInstance;
|
|
312
|
+
export interface TypeschemaGeneratorOptions {
|
|
313
|
+
resourceTypes?: string[];
|
|
314
|
+
verbose?: boolean;
|
|
315
|
+
maxDepth?: number;
|
|
316
|
+
}
|
|
317
|
+
export interface PackageInfo {
|
|
318
|
+
name: string;
|
|
319
|
+
version: string;
|
|
320
|
+
}
|
|
321
|
+
export type TypeschemaParserOptions = {
|
|
322
|
+
format?: "auto" | "ndjson" | "json";
|
|
323
|
+
validate?: boolean;
|
|
324
|
+
strict?: boolean;
|
|
325
|
+
};
|
|
326
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/typeschema/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,UAAU,GACnB,0BAA0B,GAC1B,uCAAuC,GACvC,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,CAAC;AAExB,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GAC1D,CACG,eAAe,GACf,qBAAqB,GACrB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,CACjB,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,UAAU,EAAE,oBAAoB,GAAG,qBAAqB,CAAC;IACzD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,IAAI,EACD,qBAAqB,GACrB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAA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ACjB;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,EAAE,CAAC;IACJ;;OAEG;IACH,OAAO,CAAC,EAAE;QACT,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACrB,CAAC;CACF;AACD,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,UAAU,EAAE,oBAAoB,GAAG,eAAe,CAAC;IACnD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,CAAC;IACnD;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACtC;AAED,MAAM,MAAM,eAAe,GACxB,YAAY,GACZ,iCAAiC,GACjC,8BAA8B,CAAC;AAElC,MAAM,WAAW,0BAA0B;IAC1C,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PolymorphicValueXFieldInstance, RegularField, TypeSchema, TypeSchemaField, TypeSchemaForResourceComplexTypeLogical } from "./types";
|
|
2
|
+
export declare const isPolymorphicInstanceField: (field: TypeSchemaField) => field is PolymorphicValueXFieldInstance;
|
|
3
|
+
export declare const isTypeSchemaValueSet: () => void;
|
|
4
|
+
export declare const isRegularField: (field: TypeSchemaField) => field is RegularField;
|
|
5
|
+
export declare const isTypeSchemaBinding: () => void;
|
|
6
|
+
export declare const isTypeSchemaForResourceComplexTypeLogical: (schema: TypeSchema) => schema is TypeSchemaForResourceComplexTypeLogical;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/typeschema/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,8BAA8B,EAC9B,YAAY,EACZ,UAAU,EACV,eAAe,EACf,uCAAuC,EACvC,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,0BAA0B,GACtC,OAAO,eAAe,KACpB,KAAK,IAAI,8BAEX,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAW,CAAC;AAC7C,eAAO,MAAM,cAAc,GAC1B,OAAO,eAAe,KACpB,KAAK,IAAI,YAEX,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAAW,CAAC;AAE5C,eAAO,MAAM,yCAAyC,GACrD,QAAQ,UAAU,KAChB,MAAM,IAAI,uCAMZ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value Set Processing
|
|
3
|
+
*
|
|
4
|
+
* Functions for transforming FHIR ValueSets into TypeSchema format
|
|
5
|
+
*/
|
|
6
|
+
import type { CanonicalManager } from "@atomic-ehr/fhir-canonical-manager";
|
|
7
|
+
import type { PackageInfo, TypeSchemaForValueSet } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Extract all concepts from a ValueSet
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractValueSetConcepts(valueSet: any, manager: ReturnType<typeof CanonicalManager>): Promise<Array<{
|
|
12
|
+
system: string;
|
|
13
|
+
code: string;
|
|
14
|
+
display?: string;
|
|
15
|
+
}> | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Transform a FHIR ValueSet to TypeSchema format
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformValueSet(valueSet: any, manager: ReturnType<typeof CanonicalManager>, packageInfo?: PackageInfo): Promise<TypeSchemaForValueSet>;
|
|
20
|
+
//# sourceMappingURL=processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../../src/typeschema/value-set/processor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EACX,WAAW,EACX,qBAAqB,EAErB,MAAM,UAAU,CAAC;AAgGlB;;GAEG;AACH,wBAAsB,uBAAuB,CAC5C,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC1C,OAAO,CACT,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CACrE,CAqCA;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EAC5C,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,qBAAqB,CAAC,CA4DhC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string into PascalCase.
|
|
3
|
+
* Examples:
|
|
4
|
+
* - "patient-name" -> "PatientName"
|
|
5
|
+
* - "Patient name" -> "PatientName"
|
|
6
|
+
* - "patient_name" -> "PatientName"
|
|
7
|
+
* - "patientName" -> "PatientName"
|
|
8
|
+
*/
|
|
9
|
+
export declare function toPascalCase(input: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Split an array into chunks of a given size.
|
|
12
|
+
*
|
|
13
|
+
* Examples:
|
|
14
|
+
* - chunkArray([1,2,3,4,5], 2) -> [[1,2],[3,4],[5]]
|
|
15
|
+
* - chunkArray([], 3) -> []
|
|
16
|
+
*
|
|
17
|
+
* @param arr - The array to split.
|
|
18
|
+
* @param size - The maximum size of each chunk (must be >= 1).
|
|
19
|
+
* @returns An array of chunks (each chunk is an array of T).
|
|
20
|
+
* @throws RangeError if size is less than 1.
|
|
21
|
+
*/
|
|
22
|
+
export declare function chunkArray<T>(arr: T[], size: number): T[][];
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAa3D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atomic-ehr/codegen",
|
|
3
|
+
"version": "0.0.1-canary.20250808231821.ab61009",
|
|
4
|
+
"description": "Code generation tools for FHIR resources and TypeSchema definitions",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fhir",
|
|
7
|
+
"codegen",
|
|
8
|
+
"typescript",
|
|
9
|
+
"healthcare",
|
|
10
|
+
"ehr",
|
|
11
|
+
"typeschema"
|
|
12
|
+
],
|
|
13
|
+
"module": "src/index.ts",
|
|
14
|
+
"main": "src/index.ts",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"bin": {
|
|
17
|
+
"atomic-codegen": "./dist/cli/index.ts"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "bun test",
|
|
24
|
+
"test:watch": "bun test --watch",
|
|
25
|
+
"test:coverage": "bun test --coverage",
|
|
26
|
+
"test:ci": "bun test --coverage --bail",
|
|
27
|
+
"build": "rm -rf dist && bun build src/index.ts --outdir dist --target node --format esm --splitting --external typescript && bunx tsc --project tsconfig.build.json",
|
|
28
|
+
"typecheck": "bunx tsc --noEmit",
|
|
29
|
+
"cli": "bun run src/cli/index.ts",
|
|
30
|
+
"codegen": "bun run src/cli/index.ts",
|
|
31
|
+
"codegen:all": "bun run src/cli/index.ts generate typescript",
|
|
32
|
+
"lint": "biome check --write ./src"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/atomic-ehr/codegen.git"
|
|
37
|
+
},
|
|
38
|
+
"author": "Atomic EHR Team",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/atomic-ehr/codegen/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/atomic-ehr/codegen#readme",
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@biomejs/biome": "^2.1.3",
|
|
46
|
+
"@types/bun": "latest",
|
|
47
|
+
"@types/node": "22",
|
|
48
|
+
"@types/yargs": "^17.0.33",
|
|
49
|
+
"typescript": "^5.8.3"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@atomic-ehr/fhir-canonical-manager": "^0.0.10",
|
|
53
|
+
"@atomic-ehr/fhirschema": "^0.0.2",
|
|
54
|
+
"@inquirer/prompts": "^7.0.0",
|
|
55
|
+
"ajv": "^8.17.1",
|
|
56
|
+
"picocolors": "^1.0.0",
|
|
57
|
+
"ora": "^8.1.0",
|
|
58
|
+
"yargs": "^18.0.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main entry point for the @atomic-ehr/codegen library
|
|
3
|
+
*
|
|
4
|
+
* ## Overview
|
|
5
|
+
*
|
|
6
|
+
* atomic-codegen is a comprehensive code generation toolkit for FHIR healthcare standards,
|
|
7
|
+
* designed with TypeSchema as the intermediate format for maximum flexibility and type safety.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **π₯ FHIR R4/R5 Support**: Complete FHIR resource and profile generation
|
|
12
|
+
* - **πΊπΈ US Core Profiles**: Built-in support for US healthcare implementation guides
|
|
13
|
+
* - **π TypeSchema Integration**: Uses TypeSchema as universal intermediate format
|
|
14
|
+
* - **π― Type Safety**: Full TypeScript support with runtime validation
|
|
15
|
+
* - **β‘ Performance**: Built with Bun for maximum speed
|
|
16
|
+
* - **ποΈ Extensible**: Plugin architecture for custom generators
|
|
17
|
+
*
|
|
18
|
+
* ## Quick Start
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { APIBuilder } from '@atomic-ehr/codegen';
|
|
22
|
+
*
|
|
23
|
+
* // High-level API for common workflows
|
|
24
|
+
* const api = new APIBuilder();
|
|
25
|
+
*
|
|
26
|
+
* // Generate FHIR types from packages
|
|
27
|
+
* await api
|
|
28
|
+
* .fromFHIRPackages(['hl7.fhir.r4.core@4.0.1', 'hl7.fhir.us.core@6.1.0'])
|
|
29
|
+
* .typescript('./src/types/fhir')
|
|
30
|
+
* .withValidation()
|
|
31
|
+
* .generate();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## Architecture
|
|
35
|
+
*
|
|
36
|
+
* The library follows a three-stage architecture:
|
|
37
|
+
*
|
|
38
|
+
* 1. **Input**: FHIR packages, JSON Schema, or custom schemas
|
|
39
|
+
* 2. **TypeSchema**: Universal intermediate representation
|
|
40
|
+
* 3. **Output**: TypeScript, Python, Go, or custom target languages
|
|
41
|
+
*
|
|
42
|
+
* ## Examples
|
|
43
|
+
*
|
|
44
|
+
* ### FHIR Patient with US Core Extensions
|
|
45
|
+
*
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { USCorePatient, USCoreRaceExtension } from './types/fhir';
|
|
48
|
+
*
|
|
49
|
+
* const patient: USCorePatient = {
|
|
50
|
+
* resourceType: 'Patient',
|
|
51
|
+
* identifier: [{ value: 'MRN-123' }],
|
|
52
|
+
* name: [{ family: 'Johnson', given: ['Maria'] }],
|
|
53
|
+
* gender: 'female',
|
|
54
|
+
* extension: [{
|
|
55
|
+
* url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race',
|
|
56
|
+
* extension: [{ url: 'text', valueString: 'Hispanic or Latino' }]
|
|
57
|
+
* } as USCoreRaceExtension]
|
|
58
|
+
* };
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ### Runtime Validation
|
|
62
|
+
*
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { isUSCorePatient, validateFHIRResource } from './types/fhir/guards';
|
|
65
|
+
*
|
|
66
|
+
* if (isUSCorePatient(someData)) {
|
|
67
|
+
* // TypeScript knows this is a USCorePatient
|
|
68
|
+
* const validation = await validateFHIRResource(someData);
|
|
69
|
+
* if (validation.valid) {
|
|
70
|
+
* console.log('Valid US Core Patient!');
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @packageDocumentation
|
|
76
|
+
* @module @atomic-ehr/codegen
|
|
77
|
+
* @version 0.0.1
|
|
78
|
+
* @author Atomic EHR Team
|
|
79
|
+
* @since 0.0.1
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
// Export new high-level API (primary)
|
|
83
|
+
export * from "./api";
|
|
84
|
+
|
|
85
|
+
// Export new config system
|
|
86
|
+
export * from "./config";
|