@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
package/README.md
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
# Atomic FHIR Codegen
|
|
2
|
+
|
|
3
|
+
A powerful, extensible code generation toolkit for FHIR (Fast Healthcare Interoperability Resources) that transforms FHIR specifications into strongly-typed code for multiple programming languages.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **High-Performance** - Built with Bun runtime for blazing-fast generation
|
|
8
|
+
- 🔧 **Extensible Architecture** - Three-stage pipeline (Parse → Transform → Generate)
|
|
9
|
+
- 📦 **Multi-Package Support** - Generate from FHIR R4 core packages (profiles in development)
|
|
10
|
+
- 🎯 **Type-Safe** - Generates fully typed interfaces with proper inheritance
|
|
11
|
+
- 🔄 **Intermediate Format** - TypeSchema format enables multi-language support
|
|
12
|
+
- 🛠️ **Developer Friendly** - Fluent API, CLI, and configuration file support
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Using npm
|
|
18
|
+
npm install @atomic-ehr/codegen
|
|
19
|
+
|
|
20
|
+
# Using bun
|
|
21
|
+
bun add @atomic-ehr/codegen
|
|
22
|
+
|
|
23
|
+
# Using yarn
|
|
24
|
+
yarn add @atomic-ehr/codegen
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### 1. Using the CLI
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Initialize configuration
|
|
33
|
+
bunx atomic-codegen config init
|
|
34
|
+
|
|
35
|
+
# Generate TypeScript types from FHIR R4
|
|
36
|
+
bunx atomic-codegen generate typescript
|
|
37
|
+
|
|
38
|
+
# Generate from specific package
|
|
39
|
+
bunx atomic-codegen typeschema generate --package hl7.fhir.r4.core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Using the Fluent API
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { APIBuilder } from '@atomic-ehr/codegen';
|
|
46
|
+
|
|
47
|
+
// Create builder instance
|
|
48
|
+
const builder = new APIBuilder();
|
|
49
|
+
|
|
50
|
+
// Generate FHIR R4 TypeScript types
|
|
51
|
+
await builder
|
|
52
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
53
|
+
.typescript({
|
|
54
|
+
outputDir: './generated/types',
|
|
55
|
+
generateIndex: true,
|
|
56
|
+
includeExtensions: false,
|
|
57
|
+
})
|
|
58
|
+
.generate();
|
|
59
|
+
|
|
60
|
+
// Generate with additional configuration
|
|
61
|
+
await builder
|
|
62
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
63
|
+
.typescript({
|
|
64
|
+
outputDir: './generated/fhir',
|
|
65
|
+
generateIndex: true,
|
|
66
|
+
includeDocuments: true,
|
|
67
|
+
namingConvention: 'PascalCase'
|
|
68
|
+
})
|
|
69
|
+
.generate();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Using Configuration File
|
|
73
|
+
|
|
74
|
+
Create `atomic-codegen.config.ts`:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { defineConfig } from '@atomic-ehr/codegen';
|
|
78
|
+
|
|
79
|
+
export default defineConfig({
|
|
80
|
+
packages: [
|
|
81
|
+
{
|
|
82
|
+
name: 'hl7.fhir.r4.core',
|
|
83
|
+
version: '4.0.1'
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
generators: {
|
|
87
|
+
typescript: {
|
|
88
|
+
outputDir: './src/types/fhir',
|
|
89
|
+
generateIndex: true,
|
|
90
|
+
namingConvention: 'PascalCase',
|
|
91
|
+
includeExtensions: false,
|
|
92
|
+
includeProfiles: true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then run:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
bunx atomic-codegen generate typescript
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Architecture
|
|
105
|
+
|
|
106
|
+
The toolkit uses a three-stage architecture:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
FHIR Package → TypeSchema Parser → TypeSchema Format → Code Generators → Output
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
1. **Input Layer** - Parses FHIR packages and profiles into TypeSchema format
|
|
113
|
+
2. **Intermediate Format** - TypeSchema provides a universal representation
|
|
114
|
+
3. **Output Generators** - Generate code for TypeScript, Python, and other languages
|
|
115
|
+
|
|
116
|
+
## Usage Examples
|
|
117
|
+
|
|
118
|
+
### Generate Types for a Custom Profile
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { APIBuilder } from '@atomic-ehr/codegen';
|
|
122
|
+
|
|
123
|
+
const builder = new APIBuilder();
|
|
124
|
+
|
|
125
|
+
// Load custom profile
|
|
126
|
+
await builder
|
|
127
|
+
.fromProfile('./profiles/my-patient-profile.json')
|
|
128
|
+
.withBaseProfile('http://hl7.org/fhir/StructureDefinition/Patient')
|
|
129
|
+
.typescript({
|
|
130
|
+
outputDir: './generated/profiles',
|
|
131
|
+
includeValidators: true,
|
|
132
|
+
})
|
|
133
|
+
.generate();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Generate with Custom Templates
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { APIBuilder } from '@atomic-ehr/codegen';
|
|
140
|
+
|
|
141
|
+
const builder = new APIBuilder();
|
|
142
|
+
|
|
143
|
+
await builder
|
|
144
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
145
|
+
.withTemplate('./templates/custom-interface.hbs')
|
|
146
|
+
.typescript({
|
|
147
|
+
outputDir: './generated',
|
|
148
|
+
customHelpers: {
|
|
149
|
+
upperCase: (str) => str.toUpperCase()
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
.generate();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Generate Multiple Output Formats
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { APIBuilder } from '@atomic-ehr/codegen';
|
|
159
|
+
|
|
160
|
+
const builder = new APIBuilder();
|
|
161
|
+
|
|
162
|
+
// Parse once, generate multiple formats
|
|
163
|
+
const schemas = await builder
|
|
164
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
165
|
+
.parse();
|
|
166
|
+
|
|
167
|
+
// Generate TypeScript
|
|
168
|
+
await builder
|
|
169
|
+
.fromSchemas(schemas)
|
|
170
|
+
.typescript({ outputDir: './ts-types' })
|
|
171
|
+
.generate();
|
|
172
|
+
|
|
173
|
+
// Generate Python (coming soon)
|
|
174
|
+
await builder
|
|
175
|
+
.fromSchemas(schemas)
|
|
176
|
+
.python({ outputDir: './py-types' })
|
|
177
|
+
.generate();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Working with Generated Types
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// Import generated types
|
|
184
|
+
import { Patient, Observation, Bundle } from './generated/types';
|
|
185
|
+
|
|
186
|
+
// Use with type safety
|
|
187
|
+
const patient: Patient = {
|
|
188
|
+
resourceType: 'Patient',
|
|
189
|
+
id: '123',
|
|
190
|
+
name: [{
|
|
191
|
+
given: ['John'],
|
|
192
|
+
family: 'Doe'
|
|
193
|
+
}],
|
|
194
|
+
birthDate: '1990-01-01'
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Type-safe resource references
|
|
198
|
+
const observation: Observation = {
|
|
199
|
+
resourceType: 'Observation',
|
|
200
|
+
status: 'final',
|
|
201
|
+
code: {
|
|
202
|
+
coding: [{
|
|
203
|
+
system: 'http://loinc.org',
|
|
204
|
+
code: '85354-9',
|
|
205
|
+
display: 'Blood pressure'
|
|
206
|
+
}]
|
|
207
|
+
},
|
|
208
|
+
subject: {
|
|
209
|
+
reference: 'Patient/123',
|
|
210
|
+
type: 'Patient' // Type-checked!
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// Work with bundles
|
|
215
|
+
const bundle: Bundle = {
|
|
216
|
+
resourceType: 'Bundle',
|
|
217
|
+
type: 'collection',
|
|
218
|
+
entry: [
|
|
219
|
+
{ resource: patient },
|
|
220
|
+
{ resource: observation }
|
|
221
|
+
]
|
|
222
|
+
};
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## CLI Commands
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Configuration
|
|
229
|
+
atomic-codegen config init # Initialize configuration
|
|
230
|
+
atomic-codegen config validate # Validate configuration
|
|
231
|
+
|
|
232
|
+
# Generation
|
|
233
|
+
atomic-codegen generate typescript # Generate TypeScript types
|
|
234
|
+
atomic-codegen generate python # Generate Python types (coming soon)
|
|
235
|
+
|
|
236
|
+
# TypeSchema operations
|
|
237
|
+
atomic-codegen typeschema generate # Generate TypeSchema from FHIR
|
|
238
|
+
atomic-codegen typeschema validate # Validate TypeSchema documents
|
|
239
|
+
|
|
240
|
+
# Development
|
|
241
|
+
atomic-codegen dev # Start development mode with watch
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Configuration Options
|
|
245
|
+
|
|
246
|
+
### TypeScript Generator Options
|
|
247
|
+
|
|
248
|
+
| Option | Type | Default | Description |
|
|
249
|
+
|--------|------|---------|-------------|
|
|
250
|
+
| `outputDir` | `string` | `./generated` | Output directory for generated files |
|
|
251
|
+
| `moduleFormat` | `'esm' \| 'cjs'` | `'esm'` | Module format |
|
|
252
|
+
| `generateIndex` | `boolean` | `true` | Generate index file with exports |
|
|
253
|
+
| `includeDocuments` | `boolean` | `true` | Include JSDoc documentation |
|
|
254
|
+
| `namingConvention` | `'PascalCase' \| 'camelCase'` | `'PascalCase'` | Type naming convention |
|
|
255
|
+
| `includeExtensions` | `boolean` | `false` | Include FHIR extensions |
|
|
256
|
+
| `includeProfiles` | `boolean` | `false` | Include FHIR profiles |
|
|
257
|
+
|
|
258
|
+
## Advanced Features
|
|
259
|
+
|
|
260
|
+
### Custom Type Mappings
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
const builder = new APIBuilder();
|
|
264
|
+
|
|
265
|
+
await builder
|
|
266
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
267
|
+
.withTypeMappings({
|
|
268
|
+
'date': 'Date', // Map FHIR date to JS Date
|
|
269
|
+
'instant': 'Date', // Map FHIR instant to JS Date
|
|
270
|
+
'decimal': 'BigNumber' // Use BigNumber for decimals
|
|
271
|
+
})
|
|
272
|
+
.typescript({ outputDir: './generated' })
|
|
273
|
+
.generate();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Selective Generation
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const builder = new APIBuilder();
|
|
280
|
+
|
|
281
|
+
// Generate only specific resources
|
|
282
|
+
await builder
|
|
283
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
284
|
+
.filter({
|
|
285
|
+
resources: ['Patient', 'Observation', 'Encounter'],
|
|
286
|
+
excludeExtensions: true,
|
|
287
|
+
excludeProfiles: true
|
|
288
|
+
})
|
|
289
|
+
.typescript({ outputDir: './generated' })
|
|
290
|
+
.generate();
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Plugin System
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
import { APIBuilder, Plugin } from '@atomic-ehr/codegen';
|
|
297
|
+
|
|
298
|
+
// Create custom plugin
|
|
299
|
+
const validatorPlugin: Plugin = {
|
|
300
|
+
name: 'validator-plugin',
|
|
301
|
+
transform: (schema) => {
|
|
302
|
+
// Add validation metadata
|
|
303
|
+
return {
|
|
304
|
+
...schema,
|
|
305
|
+
validation: generateValidationRules(schema)
|
|
306
|
+
};
|
|
307
|
+
},
|
|
308
|
+
generate: (schema, options) => {
|
|
309
|
+
// Generate validator functions
|
|
310
|
+
return generateValidators(schema, options);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Use plugin
|
|
315
|
+
const builder = new APIBuilder();
|
|
316
|
+
|
|
317
|
+
await builder
|
|
318
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
319
|
+
.use(validatorPlugin)
|
|
320
|
+
.typescript({ outputDir: './generated' })
|
|
321
|
+
.generate();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Development
|
|
325
|
+
|
|
326
|
+
### Prerequisites
|
|
327
|
+
|
|
328
|
+
- [Bun](https://bun.sh) runtime (v1.0+)
|
|
329
|
+
- Node.js 18+ (for compatibility)
|
|
330
|
+
|
|
331
|
+
### Setup
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# Clone repository
|
|
335
|
+
git clone https://github.com/your-org/atomic-codegen
|
|
336
|
+
cd atomic-codegen
|
|
337
|
+
|
|
338
|
+
# Install dependencies
|
|
339
|
+
bun install
|
|
340
|
+
|
|
341
|
+
# Run tests
|
|
342
|
+
bun test
|
|
343
|
+
|
|
344
|
+
# Build
|
|
345
|
+
bun run build
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Project Structure
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
atomic-codegen/
|
|
352
|
+
├── src/
|
|
353
|
+
│ ├── api/ # High-level API
|
|
354
|
+
│ ├── cli/ # CLI implementation
|
|
355
|
+
│ ├── typeschema/ # TypeSchema parser/transformer
|
|
356
|
+
│ ├── generators/ # Code generators
|
|
357
|
+
│ └── config.ts # Configuration system
|
|
358
|
+
├── test/ # Test suites
|
|
359
|
+
├── examples/ # Usage examples
|
|
360
|
+
└── docs/ # Documentation
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Contributing
|
|
364
|
+
|
|
365
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
366
|
+
|
|
367
|
+
## License
|
|
368
|
+
|
|
369
|
+
MIT © Atomic Healthcare
|
|
370
|
+
|
|
371
|
+
## Support
|
|
372
|
+
|
|
373
|
+
- 📖 [Documentation](https://docs.atomic-ehr.com/codegen)
|
|
374
|
+
- 🐛 [Issue Tracker](https://github.com/atomic-ehr/codegen/issues)
|
|
375
|
+
|
|
376
|
+
## Next Steps: REST Client & Advanced Features
|
|
377
|
+
|
|
378
|
+
We're expanding beyond type generation to create a complete FHIR development toolkit:
|
|
379
|
+
|
|
380
|
+
### 🔄 REST Client Generation (Q2 2024)
|
|
381
|
+
```typescript
|
|
382
|
+
// Generate type-safe FHIR clients
|
|
383
|
+
await builder
|
|
384
|
+
.fromPackage('hl7.fhir.r4.core', '4.0.1')
|
|
385
|
+
.restClient({
|
|
386
|
+
clientName: 'MyFHIRClient',
|
|
387
|
+
baseUrl: 'https://api.example.com/fhir',
|
|
388
|
+
authType: 'oauth2'
|
|
389
|
+
})
|
|
390
|
+
.generate();
|
|
391
|
+
|
|
392
|
+
// Use generated client
|
|
393
|
+
const client = new MyFHIRClient();
|
|
394
|
+
const patient = await client.Patient.read('123');
|
|
395
|
+
const bundle = await client.Patient.search({ name: 'Smith' });
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### 🔍 Smart Chained Search (Q3 2024)
|
|
399
|
+
```typescript
|
|
400
|
+
// Intelligent search builders
|
|
401
|
+
const results = await client.Patient
|
|
402
|
+
.search()
|
|
403
|
+
.name().contains('Smith')
|
|
404
|
+
.birthdate().greaterThan('2000-01-01')
|
|
405
|
+
.address().city().equals('Boston')
|
|
406
|
+
.include('Patient:organization')
|
|
407
|
+
.sort('birthdate', 'desc')
|
|
408
|
+
.execute();
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### ⚡ Operation Generation (Q4 2024)
|
|
412
|
+
```typescript
|
|
413
|
+
// Type-safe FHIR operations
|
|
414
|
+
const result = await client.Patient
|
|
415
|
+
.operation('$match')
|
|
416
|
+
.withParameters({
|
|
417
|
+
resource: patient,
|
|
418
|
+
onlyCertainMatches: true
|
|
419
|
+
})
|
|
420
|
+
.execute();
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
See our detailed [**ROADMAP.md**](ROADMAP.md) for the complete development plan.
|
|
424
|
+
|
|
425
|
+
## Current Roadmap
|
|
426
|
+
|
|
427
|
+
- [x] TypeScript generation
|
|
428
|
+
- [x] FHIR R4 core package support
|
|
429
|
+
- [x] Configuration file support
|
|
430
|
+
- [x] Comprehensive test suite (72+ tests)
|
|
431
|
+
- [~] **Profile & Extension Support** - Basic parsing (US Core in development)
|
|
432
|
+
- [ ] **Complete Multi-Package Support** - Custom packages and dependencies
|
|
433
|
+
- [ ] **REST Client Generation** - Fetch-based FHIR clients
|
|
434
|
+
- [ ] **Smart Chained Search** - Intelligent search builders
|
|
435
|
+
- [ ] **Operation Generation** - Type-safe FHIR operations
|
|
436
|
+
- [ ] **Python generation**
|
|
437
|
+
- [ ] **Rust generation**
|
|
438
|
+
- [ ] **GraphQL schema generation**
|
|
439
|
+
- [ ] **OpenAPI specification generation**
|
|
440
|
+
- [ ] **Validation functions**
|
|
441
|
+
- [ ] **Mock data generation**
|
|
442
|
+
- [ ] **FHIR R5 support**
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
Built with ❤️ by the Atomic Healthcare team
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-Level API Builder
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent, chainable API for common codegen use cases with pre-built generators.
|
|
5
|
+
* This builder pattern allows users to configure generation in a declarative way.
|
|
6
|
+
*/
|
|
7
|
+
import type { TypeSchemaConfig } from "../config";
|
|
8
|
+
import { type TypeSchema } from "../typeschema";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for the API builder
|
|
11
|
+
*/
|
|
12
|
+
export interface APIBuilderOptions {
|
|
13
|
+
outputDir?: string;
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
overwrite?: boolean;
|
|
16
|
+
validate?: boolean;
|
|
17
|
+
cache?: boolean;
|
|
18
|
+
typeSchemaConfig?: TypeSchemaConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Progress callback for long-running operations
|
|
22
|
+
*/
|
|
23
|
+
export type ProgressCallback = (phase: string, current: number, total: number, message?: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Generation result information
|
|
26
|
+
*/
|
|
27
|
+
export interface GenerationResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
outputDir: string;
|
|
30
|
+
filesGenerated: string[];
|
|
31
|
+
errors: string[];
|
|
32
|
+
warnings: string[];
|
|
33
|
+
duration: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* High-Level API Builder class
|
|
37
|
+
*
|
|
38
|
+
* Provides a fluent interface for configuring and executing code generation
|
|
39
|
+
* from FHIR packages or TypeSchema documents.
|
|
40
|
+
*/
|
|
41
|
+
export declare class APIBuilder {
|
|
42
|
+
private schemas;
|
|
43
|
+
private options;
|
|
44
|
+
private generators;
|
|
45
|
+
private progressCallback?;
|
|
46
|
+
private cache?;
|
|
47
|
+
private pendingOperations;
|
|
48
|
+
private typeSchemaGenerator?;
|
|
49
|
+
private logger;
|
|
50
|
+
private typeSchemaConfig?;
|
|
51
|
+
constructor(options?: APIBuilderOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Load TypeSchema from a FHIR package
|
|
54
|
+
*/
|
|
55
|
+
fromPackage(packageName: string, version?: string): APIBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* Load TypeSchema from files
|
|
58
|
+
*/
|
|
59
|
+
fromFiles(...filePaths: string[]): APIBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Load TypeSchema from TypeSchema objects
|
|
62
|
+
*/
|
|
63
|
+
fromSchemas(schemas: TypeSchema[]): APIBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Configure TypeScript generation with validation support
|
|
66
|
+
*/
|
|
67
|
+
typescript(options?: {
|
|
68
|
+
moduleFormat?: "esm" | "cjs";
|
|
69
|
+
generateIndex?: boolean;
|
|
70
|
+
includeDocuments?: boolean;
|
|
71
|
+
namingConvention?: "PascalCase" | "camelCase";
|
|
72
|
+
includeExtensions?: boolean;
|
|
73
|
+
includeProfiles?: boolean;
|
|
74
|
+
generateValidators?: boolean;
|
|
75
|
+
generateGuards?: boolean;
|
|
76
|
+
generateBuilders?: boolean;
|
|
77
|
+
strictValidation?: boolean;
|
|
78
|
+
includePerformanceMetrics?: boolean;
|
|
79
|
+
}): APIBuilder;
|
|
80
|
+
/**
|
|
81
|
+
* Set a progress callback for monitoring generation
|
|
82
|
+
*/
|
|
83
|
+
onProgress(callback: ProgressCallback): APIBuilder;
|
|
84
|
+
/**
|
|
85
|
+
* Set the output directory for all generators
|
|
86
|
+
*/
|
|
87
|
+
outputTo(directory: string): APIBuilder;
|
|
88
|
+
/**
|
|
89
|
+
* Enable/disable verbose logging
|
|
90
|
+
*/
|
|
91
|
+
verbose(enabled?: boolean): APIBuilder;
|
|
92
|
+
/**
|
|
93
|
+
* Enable/disable validation
|
|
94
|
+
*/
|
|
95
|
+
validate(enabled?: boolean): APIBuilder;
|
|
96
|
+
/**
|
|
97
|
+
* Execute the generation process
|
|
98
|
+
*/
|
|
99
|
+
generate(): Promise<GenerationResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Generate and return the results without writing to files
|
|
102
|
+
*/
|
|
103
|
+
build(): Promise<{
|
|
104
|
+
typescript?: {
|
|
105
|
+
content: string;
|
|
106
|
+
filename: string;
|
|
107
|
+
}[];
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Clear all configuration and start fresh
|
|
111
|
+
*/
|
|
112
|
+
reset(): APIBuilder;
|
|
113
|
+
/**
|
|
114
|
+
* Get loaded schemas (for inspection)
|
|
115
|
+
*/
|
|
116
|
+
getSchemas(): TypeSchema[];
|
|
117
|
+
/**
|
|
118
|
+
* Get configured generators (for inspection)
|
|
119
|
+
*/
|
|
120
|
+
getGenerators(): string[];
|
|
121
|
+
private loadFromPackage;
|
|
122
|
+
private loadFromFiles;
|
|
123
|
+
private resolveSchemas;
|
|
124
|
+
private validateSchemas;
|
|
125
|
+
private executeGenerators;
|
|
126
|
+
private reportProgress;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a new API builder instance
|
|
130
|
+
*/
|
|
131
|
+
export declare function createAPI(options?: APIBuilderOptions): APIBuilder;
|
|
132
|
+
/**
|
|
133
|
+
* Convenience function for quick TypeScript generation from a package
|
|
134
|
+
*/
|
|
135
|
+
export declare function generateTypesFromPackage(packageName: string, outputDir: string, options?: {
|
|
136
|
+
version?: string;
|
|
137
|
+
verbose?: boolean;
|
|
138
|
+
validate?: boolean;
|
|
139
|
+
}): Promise<GenerationResult>;
|
|
140
|
+
/**
|
|
141
|
+
* Convenience function for quick TypeScript generation from files
|
|
142
|
+
*/
|
|
143
|
+
export declare function generateTypesFromFiles(inputFiles: string[], outputDir: string, options?: {
|
|
144
|
+
verbose?: boolean;
|
|
145
|
+
validate?: boolean;
|
|
146
|
+
}): Promise<GenerationResult>;
|
|
147
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/api/builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EACN,KAAK,UAAU,EAIf,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAEb;IACF,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C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