@atomic-ehr/codegen 0.0.1-canary.20250830233015.ec9aae7 → 0.0.1-canary.20250923152114.2852906
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/builder.d.ts +1 -9
- package/dist/api/builder.js +1 -41
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +0 -1
- package/dist/cli/commands/generate.js +2 -12
- package/dist/cli/index.js +59 -1219
- package/dist/cli/utils/prompts.js +0 -22
- package/dist/config.d.ts +0 -39
- package/dist/config.js +0 -108
- package/dist/typeschema/generator.d.ts +2 -11
- package/dist/typeschema/generator.js +4 -18
- package/dist/typeschema/index.d.ts +4 -54
- package/dist/typeschema/index.js +3 -80
- package/dist/typeschema/types.d.ts +0 -2
- package/package.json +2 -1
- package/dist/api/generators/rest-client.d.ts +0 -117
- package/dist/api/generators/rest-client.js +0 -847
- package/dist/api/generators/search-parameter-enhancer.d.ts +0 -185
- package/dist/api/generators/search-parameter-enhancer.js +0 -801
- package/dist/api/generators/validation-generator.d.ts +0 -126
- package/dist/api/generators/validation-generator.js +0 -632
|
@@ -35,7 +35,6 @@ export async function promptInitConfig() {
|
|
|
35
35
|
choices: [
|
|
36
36
|
{ name: "TypeScript", value: "typescript", checked: true },
|
|
37
37
|
{ name: "Python", value: "python" },
|
|
38
|
-
{ name: "REST Client", value: "rest-client" },
|
|
39
38
|
],
|
|
40
39
|
});
|
|
41
40
|
const packageManager = (await select({
|
|
@@ -154,27 +153,6 @@ export async function promptGeneratorConfig(generatorId) {
|
|
|
154
153
|
default: true,
|
|
155
154
|
});
|
|
156
155
|
break;
|
|
157
|
-
case "rest-client":
|
|
158
|
-
config.httpClient = await select({
|
|
159
|
-
message: "HTTP client library:",
|
|
160
|
-
choices: [
|
|
161
|
-
{ name: "Fetch (native)", value: "fetch" },
|
|
162
|
-
{ name: "Axios", value: "axios" },
|
|
163
|
-
{ name: "Node fetch", value: "node-fetch" },
|
|
164
|
-
],
|
|
165
|
-
default: "fetch",
|
|
166
|
-
});
|
|
167
|
-
config.authentication = await select({
|
|
168
|
-
message: "Authentication type:",
|
|
169
|
-
choices: [
|
|
170
|
-
{ name: "None", value: "none" },
|
|
171
|
-
{ name: "Bearer token", value: "bearer" },
|
|
172
|
-
{ name: "Basic auth", value: "basic" },
|
|
173
|
-
{ name: "OAuth2", value: "oauth2" },
|
|
174
|
-
],
|
|
175
|
-
default: "none",
|
|
176
|
-
});
|
|
177
|
-
break;
|
|
178
156
|
}
|
|
179
157
|
return config;
|
|
180
158
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -4,43 +4,6 @@
|
|
|
4
4
|
* Simple configuration system compatible ONLY with the new high-level APIBuilder.
|
|
5
5
|
* All legacy config functionality has been removed.
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
* REST Client generator configuration options
|
|
9
|
-
*/
|
|
10
|
-
export interface RestClientConfig {
|
|
11
|
-
/** Name of the generated client class */
|
|
12
|
-
clientName?: string;
|
|
13
|
-
/** Include client-side resource validation */
|
|
14
|
-
includeValidation?: boolean;
|
|
15
|
-
/** Include enhanced error handling */
|
|
16
|
-
includeErrorHandling?: boolean;
|
|
17
|
-
/** Include request interceptors */
|
|
18
|
-
includeRequestInterceptors?: boolean;
|
|
19
|
-
/** Override base URL in client (for testing) */
|
|
20
|
-
baseUrlOverride?: string;
|
|
21
|
-
/** Generate enhanced search parameter types */
|
|
22
|
-
enhancedSearch?: boolean;
|
|
23
|
-
/** Enable chained search builder generation with fluent API */
|
|
24
|
-
chainedSearchBuilder?: boolean;
|
|
25
|
-
/** Enable IDE autocomplete for search params via string literal unions */
|
|
26
|
-
searchAutocomplete?: boolean;
|
|
27
|
-
/** Generate enums (string literal unions) from bound ValueSets when possible */
|
|
28
|
-
generateValueSetEnums?: boolean;
|
|
29
|
-
/** Generate utility methods */
|
|
30
|
-
includeUtilities?: boolean;
|
|
31
|
-
/** Generate resource validators */
|
|
32
|
-
generateValidators?: boolean;
|
|
33
|
-
/** Use FHIR canonical manager for search parameters */
|
|
34
|
-
useCanonicalManager?: boolean;
|
|
35
|
-
/** Timeout for HTTP requests */
|
|
36
|
-
defaultTimeout?: number;
|
|
37
|
-
/** Default retry count */
|
|
38
|
-
defaultRetries?: number;
|
|
39
|
-
/** Include documentation in generated client */
|
|
40
|
-
includeDocumentation?: boolean;
|
|
41
|
-
/** Generate examples and usage patterns */
|
|
42
|
-
generateExamples?: boolean;
|
|
43
|
-
}
|
|
44
7
|
/**
|
|
45
8
|
* TypeScript generator configuration options
|
|
46
9
|
*/
|
|
@@ -152,7 +115,6 @@ export interface Config {
|
|
|
152
115
|
validate?: boolean;
|
|
153
116
|
cache?: boolean;
|
|
154
117
|
typescript?: TypeScriptGeneratorConfig;
|
|
155
|
-
restClient?: RestClientConfig;
|
|
156
118
|
typeSchema?: TypeSchemaConfig;
|
|
157
119
|
packages?: string[];
|
|
158
120
|
files?: string[];
|
|
@@ -193,7 +155,6 @@ export declare class ConfigValidator {
|
|
|
193
155
|
validate(config: unknown): ConfigValidationResult;
|
|
194
156
|
private validateTypeScriptConfig;
|
|
195
157
|
private validateValidatorOptions;
|
|
196
|
-
private validateRestClientConfig;
|
|
197
158
|
private validateGuardOptions;
|
|
198
159
|
private validateProfileOptions;
|
|
199
160
|
private validateTypeSchemaConfig;
|
package/dist/config.js
CHANGED
|
@@ -16,24 +16,6 @@ export const DEFAULT_CONFIG = {
|
|
|
16
16
|
overwrite: true,
|
|
17
17
|
validate: true,
|
|
18
18
|
cache: true,
|
|
19
|
-
restClient: {
|
|
20
|
-
clientName: "FHIRClient",
|
|
21
|
-
includeValidation: false,
|
|
22
|
-
includeErrorHandling: true,
|
|
23
|
-
includeRequestInterceptors: false,
|
|
24
|
-
baseUrlOverride: "",
|
|
25
|
-
enhancedSearch: false,
|
|
26
|
-
chainedSearchBuilder: false,
|
|
27
|
-
searchAutocomplete: true,
|
|
28
|
-
generateValueSetEnums: true,
|
|
29
|
-
includeUtilities: true,
|
|
30
|
-
generateValidators: false,
|
|
31
|
-
useCanonicalManager: true,
|
|
32
|
-
defaultTimeout: 30000,
|
|
33
|
-
defaultRetries: 0,
|
|
34
|
-
includeDocumentation: true,
|
|
35
|
-
generateExamples: false,
|
|
36
|
-
},
|
|
37
19
|
typescript: {
|
|
38
20
|
moduleFormat: "esm",
|
|
39
21
|
generateIndex: true,
|
|
@@ -185,11 +167,6 @@ export class ConfigValidator {
|
|
|
185
167
|
const tsErrors = this.validateTypeSchemaConfig(cfg.typeSchema);
|
|
186
168
|
result.errors.push(...tsErrors);
|
|
187
169
|
}
|
|
188
|
-
// Validate restClient config
|
|
189
|
-
if (cfg.restClient !== undefined) {
|
|
190
|
-
const rcErrors = this.validateRestClientConfig(cfg.restClient);
|
|
191
|
-
result.errors.push(...rcErrors);
|
|
192
|
-
}
|
|
193
170
|
// Validate packages array
|
|
194
171
|
if (cfg.packages !== undefined) {
|
|
195
172
|
if (!Array.isArray(cfg.packages)) {
|
|
@@ -345,80 +322,6 @@ export class ConfigValidator {
|
|
|
345
322
|
}
|
|
346
323
|
return errors;
|
|
347
324
|
}
|
|
348
|
-
validateRestClientConfig(config) {
|
|
349
|
-
const errors = [];
|
|
350
|
-
if (typeof config !== "object" || config === null) {
|
|
351
|
-
errors.push({
|
|
352
|
-
path: "restClient",
|
|
353
|
-
message: "restClient config must be an object",
|
|
354
|
-
value: config,
|
|
355
|
-
});
|
|
356
|
-
return errors;
|
|
357
|
-
}
|
|
358
|
-
const cfg = config;
|
|
359
|
-
// Validate clientName
|
|
360
|
-
if (cfg.clientName !== undefined && typeof cfg.clientName !== "string") {
|
|
361
|
-
errors.push({
|
|
362
|
-
path: "restClient.clientName",
|
|
363
|
-
message: "clientName must be a string",
|
|
364
|
-
value: cfg.clientName,
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
// Validate baseUrlOverride
|
|
368
|
-
if (cfg.baseUrlOverride !== undefined &&
|
|
369
|
-
typeof cfg.baseUrlOverride !== "string") {
|
|
370
|
-
errors.push({
|
|
371
|
-
path: "restClient.baseUrlOverride",
|
|
372
|
-
message: "baseUrlOverride must be a string",
|
|
373
|
-
value: cfg.baseUrlOverride,
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
// Validate timeout
|
|
377
|
-
if (cfg.defaultTimeout !== undefined) {
|
|
378
|
-
if (typeof cfg.defaultTimeout !== "number" || cfg.defaultTimeout <= 0) {
|
|
379
|
-
errors.push({
|
|
380
|
-
path: "restClient.defaultTimeout",
|
|
381
|
-
message: "defaultTimeout must be a positive number",
|
|
382
|
-
value: cfg.defaultTimeout,
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
// Validate retries
|
|
387
|
-
if (cfg.defaultRetries !== undefined) {
|
|
388
|
-
if (typeof cfg.defaultRetries !== "number" || cfg.defaultRetries < 0) {
|
|
389
|
-
errors.push({
|
|
390
|
-
path: "restClient.defaultRetries",
|
|
391
|
-
message: "defaultRetries must be a non-negative number",
|
|
392
|
-
value: cfg.defaultRetries,
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
// Validate boolean fields
|
|
397
|
-
const booleanFields = [
|
|
398
|
-
"includeValidation",
|
|
399
|
-
"includeErrorHandling",
|
|
400
|
-
"includeRequestInterceptors",
|
|
401
|
-
"enhancedSearch",
|
|
402
|
-
"chainedSearchBuilder",
|
|
403
|
-
"searchAutocomplete",
|
|
404
|
-
"generateValueSetEnums",
|
|
405
|
-
"includeUtilities",
|
|
406
|
-
"generateValidators",
|
|
407
|
-
"useCanonicalManager",
|
|
408
|
-
"includeDocumentation",
|
|
409
|
-
"generateExamples",
|
|
410
|
-
];
|
|
411
|
-
for (const field of booleanFields) {
|
|
412
|
-
if (cfg[field] !== undefined && typeof cfg[field] !== "boolean") {
|
|
413
|
-
errors.push({
|
|
414
|
-
path: `restClient.${field}`,
|
|
415
|
-
message: `${field} must be a boolean`,
|
|
416
|
-
value: cfg[field],
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return errors;
|
|
421
|
-
}
|
|
422
325
|
validateGuardOptions(config) {
|
|
423
326
|
const errors = [];
|
|
424
327
|
if (typeof config !== "object" || config === null) {
|
|
@@ -653,17 +556,6 @@ export class ConfigLoader {
|
|
|
653
556
|
...userConfig.typescript,
|
|
654
557
|
},
|
|
655
558
|
};
|
|
656
|
-
// Only include restClient if it was explicitly defined in user config
|
|
657
|
-
if (userConfig.restClient !== undefined) {
|
|
658
|
-
merged.restClient = {
|
|
659
|
-
...DEFAULT_CONFIG.restClient,
|
|
660
|
-
...userConfig.restClient,
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
else {
|
|
664
|
-
// Remove restClient from merged config if not defined in user config
|
|
665
|
-
delete merged.restClient;
|
|
666
|
-
}
|
|
667
559
|
return merged;
|
|
668
560
|
}
|
|
669
561
|
}
|
|
@@ -17,22 +17,13 @@ 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
|
-
*/
|
|
31
25
|
generateFromPackage(packageName: string, packageVersion?: string): Promise<TypeSchema[]>;
|
|
32
|
-
|
|
33
|
-
* Generate TypeSchema from individual FHIR schema
|
|
34
|
-
*/
|
|
35
|
-
generateFromSchema(fhirSchema: FHIRSchema, packageInfo?: PackageInfo): Promise<TypeSchema[]>;
|
|
26
|
+
generateFromFhirSchema(fhirSchema: FHIRSchema, packageInfo?: PackageInfo): Promise<TypeSchema[]>;
|
|
36
27
|
/**
|
|
37
28
|
* Generate TypeSchema from multiple FHIR schemas with FHIR-specific enhancements
|
|
38
29
|
*/
|
|
@@ -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,18 +33,12 @@ 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
42
|
async generateFromPackage(packageName, packageVersion) {
|
|
54
43
|
await this.initializeCache();
|
|
55
44
|
const forceRegenerate = this.cacheConfig?.forceRegenerate ?? false;
|
|
@@ -129,10 +118,7 @@ export class TypeSchemaGenerator {
|
|
|
129
118
|
}
|
|
130
119
|
return allSchemas;
|
|
131
120
|
}
|
|
132
|
-
|
|
133
|
-
* Generate TypeSchema from individual FHIR schema
|
|
134
|
-
*/
|
|
135
|
-
async generateFromSchema(fhirSchema, packageInfo) {
|
|
121
|
+
async generateFromFhirSchema(fhirSchema, packageInfo) {
|
|
136
122
|
this.logger.info("Transforming FHIR schema to TypeSchema");
|
|
137
123
|
return transformFHIRSchema(fhirSchema, this.manager, packageInfo);
|
|
138
124
|
}
|
|
@@ -373,5 +359,5 @@ export async function generateTypeSchemaFromSchemas(fhirSchemas, packageInfo, op
|
|
|
373
359
|
*/
|
|
374
360
|
export async function generateTypeSchemaFromSchema(fhirSchema, packageInfo, options = {}) {
|
|
375
361
|
const generator = new TypeSchemaGenerator(options);
|
|
376
|
-
return await generator.
|
|
362
|
+
return await generator.generateFromFhirSchema(fhirSchema, packageInfo);
|
|
377
363
|
}
|
|
@@ -9,58 +9,8 @@
|
|
|
9
9
|
* - Reading TypeSchema documents
|
|
10
10
|
* - Validating TypeSchema documents
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
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[]>;
|
package/dist/typeschema/index.js
CHANGED
|
@@ -9,84 +9,7 @@
|
|
|
9
9
|
* - Reading TypeSchema documents
|
|
10
10
|
* - Validating TypeSchema documents
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
3
|
+
"version": "0.0.1-canary.20250923152114.2852906",
|
|
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",
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* REST Client Generator
|
|
3
|
-
*
|
|
4
|
-
* Generates a fetch-based FHIR REST client with TypeScript autocompletion
|
|
5
|
-
* and type safety for all FHIR resources.
|
|
6
|
-
*/
|
|
7
|
-
import type { RestClientConfig } from "../../config.js";
|
|
8
|
-
import type { TypeSchema } from "../../typeschema/type-schema.types";
|
|
9
|
-
import type { CodegenLogger } from "../../utils/codegen-logger.js";
|
|
10
|
-
/**
|
|
11
|
-
* Options for the REST Client generator
|
|
12
|
-
* Extends RestClientConfig with outputDir
|
|
13
|
-
*/
|
|
14
|
-
export interface RestClientOptions extends RestClientConfig {
|
|
15
|
-
outputDir: string;
|
|
16
|
-
logger?: CodegenLogger;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generated file result
|
|
20
|
-
*/
|
|
21
|
-
export interface GeneratedRestClient {
|
|
22
|
-
path: string;
|
|
23
|
-
filename: string;
|
|
24
|
-
content: string;
|
|
25
|
-
exports: string[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* REST Client Generator
|
|
29
|
-
*
|
|
30
|
-
* Generates a type-safe FHIR REST client with autocompletion for all
|
|
31
|
-
* available resource types.
|
|
32
|
-
*/
|
|
33
|
-
export declare class RestClientGenerator {
|
|
34
|
-
private options;
|
|
35
|
-
private resourceTypes;
|
|
36
|
-
private searchParameterEnhancer;
|
|
37
|
-
private validationGenerator;
|
|
38
|
-
private logger;
|
|
39
|
-
constructor(options: RestClientOptions);
|
|
40
|
-
/**
|
|
41
|
-
* Collect resource types from schemas
|
|
42
|
-
*/
|
|
43
|
-
private collectResourceTypes;
|
|
44
|
-
/**
|
|
45
|
-
* Generate the REST client from TypeSchema documents
|
|
46
|
-
*/
|
|
47
|
-
generate(schemas: TypeSchema[]): Promise<GeneratedRestClient[]>;
|
|
48
|
-
/**
|
|
49
|
-
* Generate the main client file
|
|
50
|
-
*/
|
|
51
|
-
private generateClientFile;
|
|
52
|
-
/**
|
|
53
|
-
* Generate the types file
|
|
54
|
-
*/
|
|
55
|
-
private generateTypesFile;
|
|
56
|
-
/**
|
|
57
|
-
* Generate error handling code
|
|
58
|
-
*/
|
|
59
|
-
private generateErrorHandling;
|
|
60
|
-
/**
|
|
61
|
-
* Generate error handling methods
|
|
62
|
-
*/
|
|
63
|
-
private generateErrorHandlingMethods;
|
|
64
|
-
/**
|
|
65
|
-
* Set output directory
|
|
66
|
-
*/
|
|
67
|
-
setOutputDir(directory: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Update generator options
|
|
70
|
-
*/
|
|
71
|
-
setOptions(options: Partial<RestClientOptions>): void;
|
|
72
|
-
/**
|
|
73
|
-
* Get current options
|
|
74
|
-
*/
|
|
75
|
-
getOptions(): RestClientOptions;
|
|
76
|
-
/**
|
|
77
|
-
* Generate enhanced search parameters file
|
|
78
|
-
*/
|
|
79
|
-
private generateEnhancedSearchParamsFile;
|
|
80
|
-
/**
|
|
81
|
-
* Generate validation configuration fields
|
|
82
|
-
*/
|
|
83
|
-
private generateValidationConfigFields;
|
|
84
|
-
/**
|
|
85
|
-
* Generate validation types file
|
|
86
|
-
*/
|
|
87
|
-
private generateValidationTypesFile;
|
|
88
|
-
/**
|
|
89
|
-
* Generate resource validators file
|
|
90
|
-
*/
|
|
91
|
-
private generateValidatorsFile;
|
|
92
|
-
/**
|
|
93
|
-
* Generate CRUD methods with conditional validation support
|
|
94
|
-
*/
|
|
95
|
-
private generateCRUDMethods;
|
|
96
|
-
/**
|
|
97
|
-
* Generate validation code for CRUD operations
|
|
98
|
-
*/
|
|
99
|
-
private generateValidationCode;
|
|
100
|
-
/**
|
|
101
|
-
* Generate the search method with conditional enhanced search support
|
|
102
|
-
*/
|
|
103
|
-
private generateSearchMethod;
|
|
104
|
-
/**
|
|
105
|
-
* Generate validation methods for the client
|
|
106
|
-
*/
|
|
107
|
-
private generateValidationMethods;
|
|
108
|
-
/**
|
|
109
|
-
* Generate search parameter handling code based on configuration
|
|
110
|
-
*/
|
|
111
|
-
private generateSearchParameterHandlingCode;
|
|
112
|
-
/**
|
|
113
|
-
* Generate utility file with ResourceTypeMap
|
|
114
|
-
*/
|
|
115
|
-
private generateUtilityFile;
|
|
116
|
-
private ensureDirectoryExists;
|
|
117
|
-
}
|