@atomic-ehr/codegen 0.0.1-canary.20250924120719.44f2f7c → 0.0.1-canary.20250925150012.6169b6d
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 +5 -5
- package/dist/api/builder.js +6 -6
- package/dist/api/generators/base/BaseGenerator.d.ts +5 -5
- package/dist/api/generators/base/BaseGenerator.js +4 -4
- package/dist/api/generators/base/FileManager.d.ts +2 -2
- package/dist/api/generators/base/FileManager.js +1 -1
- package/dist/api/generators/base/PythonTypeMapper.d.ts +3 -3
- package/dist/api/generators/base/PythonTypeMapper.js +1 -1
- package/dist/api/generators/base/TemplateEngine.d.ts +1 -1
- package/dist/api/generators/base/TemplateEngine.js +1 -1
- package/dist/api/generators/base/TypeMapper.d.ts +2 -2
- package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +3 -3
- package/dist/api/generators/base/TypeScriptTypeMapper.js +1 -1
- package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +4 -4
- package/dist/api/generators/base/builders/FileBuilder.d.ts +2 -2
- package/dist/api/generators/base/builders/IndexBuilder.d.ts +2 -2
- package/dist/api/generators/base/enhanced-errors.d.ts +2 -2
- package/dist/api/generators/base/enhanced-errors.js +1 -1
- package/dist/api/generators/base/error-handler.d.ts +2 -2
- package/dist/api/generators/base/error-handler.js +1 -1
- package/dist/api/generators/base/errors.d.ts +2 -2
- package/dist/api/generators/base/index.d.ts +22 -22
- package/dist/api/generators/base/index.js +11 -11
- package/dist/api/generators/base/types.d.ts +4 -4
- package/dist/api/generators/typescript.d.ts +6 -6
- package/dist/api/generators/typescript.js +54 -46
- package/dist/api/index.d.ts +8 -8
- package/dist/api/index.js +3 -3
- package/dist/cli/commands/generate/typescript.d.ts +1 -1
- package/dist/cli/commands/generate/typescript.js +2 -2
- package/dist/cli/commands/generate.d.ts +1 -1
- package/dist/cli/commands/generate.js +4 -4
- package/dist/cli/commands/index.js +3 -3
- package/dist/cli/commands/typeschema/generate.js +3 -3
- package/dist/cli/commands/typeschema.js +2 -2
- package/dist/cli/index.js +51 -51
- package/dist/cli/utils/log.d.ts +2 -2
- package/dist/cli/utils/log.js +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/typeschema/cache.d.ts +7 -7
- package/dist/typeschema/core/binding.d.ts +1 -1
- package/dist/typeschema/core/binding.js +6 -4
- package/dist/typeschema/core/field-builder.d.ts +3 -3
- package/dist/typeschema/core/field-builder.js +3 -3
- package/dist/typeschema/core/identifier.d.ts +5 -17
- package/dist/typeschema/core/identifier.js +15 -47
- package/dist/typeschema/core/nested-types.d.ts +2 -2
- package/dist/typeschema/core/nested-types.js +2 -2
- package/dist/typeschema/core/transformer.d.ts +3 -3
- package/dist/typeschema/core/transformer.js +20 -28
- package/dist/typeschema/generator.d.ts +3 -4
- package/dist/typeschema/generator.js +9 -8
- package/dist/typeschema/index.d.ts +4 -5
- package/dist/typeschema/index.js +4 -4
- package/dist/typeschema/parser.d.ts +5 -5
- package/dist/typeschema/profile/processor.d.ts +2 -3
- package/dist/typeschema/profile/processor.js +12 -10
- package/dist/typeschema/types.d.ts +64 -375
- package/dist/typeschema/types.js +14 -2
- package/dist/typeschema/value-set/processor.d.ts +1 -1
- package/dist/typeschema/value-set/processor.js +1 -1
- package/package.json +1 -1
- package/dist/typeschema/schema.d.ts +0 -485
- package/dist/typeschema/schema.js +0 -456
- package/dist/typeschema/type-schema.types.d.ts +0 -186
- package/dist/typeschema/type-schema.types.js +0 -39
- package/dist/typeschema/utils.d.ts +0 -6
- package/dist/typeschema/utils.js +0 -13
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* This is the new, clean implementation that replaces the monolithic typescript.ts generator.
|
|
5
5
|
* Built using the BaseGenerator architecture with TypeMapper, TemplateEngine, and FileManager.
|
|
6
6
|
*/
|
|
7
|
-
import { isBindingSchema } from "
|
|
8
|
-
import { BaseGenerator } from "./base/BaseGenerator
|
|
9
|
-
import { TypeScriptTypeMapper, } from "./base/TypeScriptTypeMapper
|
|
7
|
+
import { isBindingSchema } from "@typeschema/types";
|
|
8
|
+
import { BaseGenerator } from "./base/BaseGenerator";
|
|
9
|
+
import { TypeScriptTypeMapper, } from "./base/TypeScriptTypeMapper";
|
|
10
10
|
/**
|
|
11
11
|
* Modern TypeScript Generator
|
|
12
12
|
*
|
|
@@ -146,21 +146,26 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
146
146
|
* Check if a binding schema should generate a value set file
|
|
147
147
|
*/
|
|
148
148
|
shouldGenerateValueSet(schema) {
|
|
149
|
-
if (!isBindingSchema(schema) ||
|
|
149
|
+
if (!isBindingSchema(schema) ||
|
|
150
|
+
!schema.enum ||
|
|
151
|
+
!Array.isArray(schema.enum) ||
|
|
152
|
+
schema.enum.length === 0) {
|
|
150
153
|
return false;
|
|
151
154
|
}
|
|
152
155
|
// Handle different value set modes
|
|
153
|
-
const mode = this.options.valueSetMode ||
|
|
156
|
+
const mode = this.options.valueSetMode || "required-only";
|
|
154
157
|
switch (mode) {
|
|
155
|
-
case
|
|
158
|
+
case "all":
|
|
156
159
|
return true; // Generate for all binding strengths
|
|
157
|
-
case
|
|
158
|
-
return schema.strength ===
|
|
159
|
-
case
|
|
160
|
-
const strengths = this.options.valueSetStrengths || [
|
|
160
|
+
case "required-only":
|
|
161
|
+
return schema.strength === "required";
|
|
162
|
+
case "custom":
|
|
163
|
+
const strengths = this.options.valueSetStrengths || [
|
|
164
|
+
"required",
|
|
165
|
+
];
|
|
161
166
|
return strengths.includes(schema.strength);
|
|
162
167
|
default:
|
|
163
|
-
return schema.strength ===
|
|
168
|
+
return schema.strength === "required";
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
/**
|
|
@@ -218,7 +223,9 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
218
223
|
return "string"; // fallback
|
|
219
224
|
}
|
|
220
225
|
// Create union type from enum values
|
|
221
|
-
const enumValues = field.enum
|
|
226
|
+
const enumValues = field.enum
|
|
227
|
+
.map((value) => `'${value}'`)
|
|
228
|
+
.join(" | ");
|
|
222
229
|
return enumValues;
|
|
223
230
|
}
|
|
224
231
|
shouldSkipSchema(schema) {
|
|
@@ -393,7 +400,7 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
393
400
|
// Generate value set imports
|
|
394
401
|
if (valueSetImports.size > 0) {
|
|
395
402
|
const sortedValueSetImports = Array.from(valueSetImports).sort();
|
|
396
|
-
const importList = sortedValueSetImports.join(
|
|
403
|
+
const importList = sortedValueSetImports.join(", ");
|
|
397
404
|
lines.push(`import type { ${importList} } from './valuesets/index.js';`);
|
|
398
405
|
}
|
|
399
406
|
if (imports.size > 0 || valueSetImports.size > 0) {
|
|
@@ -723,11 +730,11 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
723
730
|
*/
|
|
724
731
|
generateValueSetFile(binding) {
|
|
725
732
|
const name = this.typeMapper.formatTypeName(binding.identifier.name);
|
|
726
|
-
const values = binding.enum?.map((v) => ` '${v}'`).join(
|
|
733
|
+
const values = binding.enum?.map((v) => ` '${v}'`).join(",\n") || "";
|
|
727
734
|
const lines = [];
|
|
728
735
|
// Add file header comment
|
|
729
736
|
if (this.options.includeDocuments) {
|
|
730
|
-
lines.push(
|
|
737
|
+
lines.push("/**");
|
|
731
738
|
lines.push(` * ${binding.identifier.name} value set`);
|
|
732
739
|
if (binding.description) {
|
|
733
740
|
lines.push(` * ${binding.description}`);
|
|
@@ -738,32 +745,33 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
738
745
|
if (binding.identifier.package) {
|
|
739
746
|
lines.push(` * @package ${binding.identifier.package}`);
|
|
740
747
|
}
|
|
741
|
-
lines.push(
|
|
742
|
-
lines.push(
|
|
743
|
-
lines.push(
|
|
748
|
+
lines.push(" * @generated This file is auto-generated. Do not edit manually.");
|
|
749
|
+
lines.push(" */");
|
|
750
|
+
lines.push("");
|
|
744
751
|
}
|
|
745
752
|
// Add values array
|
|
746
753
|
lines.push(`export const ${name}Values = [`);
|
|
747
754
|
if (values) {
|
|
748
755
|
lines.push(values);
|
|
749
756
|
}
|
|
750
|
-
lines.push(
|
|
751
|
-
lines.push(
|
|
757
|
+
lines.push("] as const;");
|
|
758
|
+
lines.push("");
|
|
752
759
|
// Add union type
|
|
753
760
|
lines.push(`export type ${name} = typeof ${name}Values[number];`);
|
|
754
761
|
// Add helper function if enabled
|
|
755
762
|
if (this.tsOptions.includeValueSetHelpers) {
|
|
756
|
-
lines.push(
|
|
763
|
+
lines.push("");
|
|
757
764
|
lines.push(`export const isValid${name} = (value: string): value is ${name} =>`);
|
|
758
765
|
lines.push(` ${name}Values.includes(value as ${name});`);
|
|
759
766
|
}
|
|
760
|
-
return lines.join(
|
|
767
|
+
return lines.join("\n");
|
|
761
768
|
}
|
|
762
769
|
/**
|
|
763
770
|
* Create valuesets directory and generate all value set files
|
|
764
771
|
*/
|
|
765
772
|
async generateValueSetFiles() {
|
|
766
|
-
if (!this.tsOptions.generateValueSets ||
|
|
773
|
+
if (!this.tsOptions.generateValueSets ||
|
|
774
|
+
this.collectedValueSets.size === 0) {
|
|
767
775
|
return;
|
|
768
776
|
}
|
|
769
777
|
// Generate individual value set files in valuesets/
|
|
@@ -782,21 +790,21 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
782
790
|
async generateValueSetIndexFile() {
|
|
783
791
|
const lines = [];
|
|
784
792
|
if (this.tsOptions.includeDocuments) {
|
|
785
|
-
lines.push(
|
|
786
|
-
lines.push(
|
|
787
|
-
lines.push(
|
|
788
|
-
lines.push(
|
|
789
|
-
lines.push(
|
|
790
|
-
lines.push(
|
|
791
|
-
lines.push(
|
|
793
|
+
lines.push("/**");
|
|
794
|
+
lines.push(" * FHIR Value Sets");
|
|
795
|
+
lines.push(" * This file re-exports all generated value sets.");
|
|
796
|
+
lines.push(" * ");
|
|
797
|
+
lines.push(" * @generated This file is auto-generated. Do not edit manually.");
|
|
798
|
+
lines.push(" */");
|
|
799
|
+
lines.push("");
|
|
792
800
|
}
|
|
793
801
|
// Sort value sets for consistent output
|
|
794
802
|
const sortedValueSets = Array.from(this.collectedValueSets.keys()).sort();
|
|
795
803
|
for (const name of sortedValueSets) {
|
|
796
804
|
lines.push(`export * from './${name}.js';`);
|
|
797
805
|
}
|
|
798
|
-
const content = lines.join(
|
|
799
|
-
await this.fileManager.writeFile(
|
|
806
|
+
const content = lines.join("\n");
|
|
807
|
+
await this.fileManager.writeFile("valuesets/index.ts", content);
|
|
800
808
|
this.logger.info(`Generated valuesets/index.ts with ${this.collectedValueSets.size} value sets`);
|
|
801
809
|
}
|
|
802
810
|
/**
|
|
@@ -808,13 +816,13 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
808
816
|
}
|
|
809
817
|
const lines = [];
|
|
810
818
|
if (this.tsOptions.includeDocuments) {
|
|
811
|
-
lines.push(
|
|
812
|
-
lines.push(
|
|
813
|
-
lines.push(
|
|
814
|
-
lines.push(
|
|
815
|
-
lines.push(
|
|
816
|
-
lines.push(
|
|
817
|
-
lines.push(
|
|
819
|
+
lines.push("/**");
|
|
820
|
+
lines.push(" * FHIR R4 TypeScript Types");
|
|
821
|
+
lines.push(" * Generated from FHIR StructureDefinitions");
|
|
822
|
+
lines.push(" * ");
|
|
823
|
+
lines.push(" * @generated This file is auto-generated. Do not edit manually.");
|
|
824
|
+
lines.push(" */");
|
|
825
|
+
lines.push("");
|
|
818
826
|
}
|
|
819
827
|
// Generate exports for all generated files - we'll keep this simple
|
|
820
828
|
// and avoid accessing private fields for now. The key functionality
|
|
@@ -822,15 +830,15 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
822
830
|
// For now, we'll skip the individual file exports since they're complex
|
|
823
831
|
// and the main functionality is already working. This can be improved later.
|
|
824
832
|
// Export utilities
|
|
825
|
-
lines.push('export * from "./utilities
|
|
833
|
+
lines.push('export * from "./utilities";');
|
|
826
834
|
// Export value sets if any were generated
|
|
827
835
|
if (this.tsOptions.generateValueSets && this.collectedValueSets.size > 0) {
|
|
828
|
-
lines.push(
|
|
829
|
-
lines.push(
|
|
830
|
-
lines.push('export * from "./valuesets/index
|
|
836
|
+
lines.push("");
|
|
837
|
+
lines.push("// Value Sets");
|
|
838
|
+
lines.push('export * from "./valuesets/index";');
|
|
831
839
|
}
|
|
832
|
-
const content = lines.join(
|
|
833
|
-
await this.fileManager.writeFile(
|
|
834
|
-
this.logger.info(`Generated index.ts with type exports${this.tsOptions.generateValueSets && this.collectedValueSets.size > 0 ?
|
|
840
|
+
const content = lines.join("\n");
|
|
841
|
+
await this.fileManager.writeFile("index.ts", content);
|
|
842
|
+
this.logger.info(`Generated index.ts with type exports${this.tsOptions.generateValueSets && this.collectedValueSets.size > 0 ? " and value sets" : ""}`);
|
|
835
843
|
}
|
|
836
844
|
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export { TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, } from "
|
|
10
|
-
export type { TypeSchema, TypeSchemaField, TypeSchemaIdentifier, } from "
|
|
11
|
-
export type { PackageInfo } from "
|
|
12
|
-
export type { APIBuilderOptions, GenerationResult, ProgressCallback, } from "./builder
|
|
13
|
-
export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder
|
|
14
|
-
export type { GeneratedFile } from "./generators/base/index
|
|
15
|
-
export type { TypeScriptGeneratorOptions } from "./generators/typescript
|
|
16
|
-
export { TypeScriptGenerator } from "./generators/typescript
|
|
9
|
+
export { TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, } from "@typeschema/index";
|
|
10
|
+
export type { TypeSchema, TypeSchemaField, Identifier as TypeSchemaIdentifier, } from "@typeschema/types";
|
|
11
|
+
export type { PackageInfo } from "@typeschema/types";
|
|
12
|
+
export type { APIBuilderOptions, GenerationResult, ProgressCallback, } from "./builder";
|
|
13
|
+
export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder";
|
|
14
|
+
export type { GeneratedFile } from "./generators/base/index";
|
|
15
|
+
export type { TypeScriptGeneratorOptions } from "./generators/typescript";
|
|
16
|
+
export { TypeScriptGenerator } from "./generators/typescript";
|
|
17
17
|
/**
|
|
18
18
|
* Quick start examples:
|
|
19
19
|
*
|
package/dist/api/index.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
// Re-export core utilities
|
|
10
|
-
export { TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, } from "
|
|
10
|
+
export { TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, } from "@typeschema/index";
|
|
11
11
|
// Export main API builder and utilities
|
|
12
|
-
export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder
|
|
12
|
+
export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder";
|
|
13
13
|
// Export generator classes for advanced usage
|
|
14
|
-
export { TypeScriptGenerator } from "./generators/typescript
|
|
14
|
+
export { TypeScriptGenerator } from "./generators/typescript";
|
|
15
15
|
/**
|
|
16
16
|
* Quick start examples:
|
|
17
17
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generate TypeScript types from TypeSchema files using the new high-level API
|
|
5
5
|
*/
|
|
6
|
-
import type { Config } from "../../../config
|
|
6
|
+
import type { Config } from "../../../config";
|
|
7
7
|
/**
|
|
8
8
|
* Generate TypeScript types from TypeSchema using the high-level API
|
|
9
9
|
*/
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generate TypeScript types from TypeSchema files using the new high-level API
|
|
5
5
|
*/
|
|
6
|
-
import { APIBuilder } from "../../../api/index
|
|
7
|
-
import { createLogger } from "../../utils/log
|
|
6
|
+
import { APIBuilder } from "../../../api/index";
|
|
7
|
+
import { createLogger } from "../../utils/log";
|
|
8
8
|
/**
|
|
9
9
|
* Generate TypeScript types from TypeSchema using the high-level API
|
|
10
10
|
*/
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { resolve } from "node:path";
|
|
9
|
-
import { APIBuilder } from "../../api/index
|
|
10
|
-
import { CONFIG_FILE_NAMES, loadConfig } from "../../config
|
|
11
|
-
import { createLogger, error, step, success, warn } from "../utils/log
|
|
9
|
+
import { APIBuilder } from "../../api/index";
|
|
10
|
+
import { CONFIG_FILE_NAMES, loadConfig } from "../../config";
|
|
11
|
+
import { createLogger, error, step, success, warn } from "../utils/log";
|
|
12
12
|
/**
|
|
13
13
|
* Main generate command - fully config-driven
|
|
14
14
|
*/
|
|
@@ -27,7 +27,7 @@ export const generateCommand = {
|
|
|
27
27
|
handler: async (argv) => {
|
|
28
28
|
// Check for old command syntax and provide helpful error
|
|
29
29
|
if (argv._.length > 1) {
|
|
30
|
-
const extraArgs = argv._.slice(1).join(
|
|
30
|
+
const extraArgs = argv._.slice(1).join(" ");
|
|
31
31
|
error(`Invalid syntax: 'atomic-codegen generate ${extraArgs}'\n\n` +
|
|
32
32
|
`The CLI has been simplified and no longer uses subcommands.\n\n` +
|
|
33
33
|
`✅ Use: atomic-codegen generate\n` +
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import yargs from "yargs";
|
|
8
8
|
import { hideBin } from "yargs/helpers";
|
|
9
|
-
import { configure, error, header } from "../utils/log
|
|
10
|
-
import { generateCommand } from "./generate
|
|
11
|
-
import { typeschemaCommand } from "./typeschema
|
|
9
|
+
import { configure, error, header } from "../utils/log";
|
|
10
|
+
import { generateCommand } from "./generate";
|
|
11
|
+
import { typeschemaCommand } from "./typeschema";
|
|
12
12
|
/**
|
|
13
13
|
* Middleware to setup logging
|
|
14
14
|
*/
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
7
7
|
import { dirname } from "node:path";
|
|
8
|
-
import { loadConfig } from "../../../config
|
|
9
|
-
import { TypeSchemaGenerator } from "
|
|
10
|
-
import { complete, createLogger, list } from "../../utils/log
|
|
8
|
+
import { loadConfig } from "../../../config";
|
|
9
|
+
import { TypeSchemaGenerator } from "@typeschema/generator";
|
|
10
|
+
import { complete, createLogger, list } from "../../utils/log";
|
|
11
11
|
/**
|
|
12
12
|
* Generate TypeSchema from FHIR packages
|
|
13
13
|
*/
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Commands for validating and managing TypeSchema files
|
|
5
5
|
*/
|
|
6
|
-
import { error, info, list } from "../utils/log
|
|
7
|
-
import { generateTypeschemaCommand } from "./typeschema/generate
|
|
6
|
+
import { error, info, list } from "../utils/log";
|
|
7
|
+
import { generateTypeschemaCommand } from "./typeschema/generate";
|
|
8
8
|
/**
|
|
9
9
|
* TypeSchema command group
|
|
10
10
|
*/
|