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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/api/builder.d.ts +7 -5
  2. package/dist/api/builder.js +8 -6
  3. package/dist/api/generators/base/BaseGenerator.d.ts +5 -5
  4. package/dist/api/generators/base/BaseGenerator.js +4 -4
  5. package/dist/api/generators/base/FileManager.d.ts +2 -2
  6. package/dist/api/generators/base/FileManager.js +1 -1
  7. package/dist/api/generators/base/PythonTypeMapper.d.ts +3 -3
  8. package/dist/api/generators/base/PythonTypeMapper.js +1 -1
  9. package/dist/api/generators/base/TemplateEngine.d.ts +1 -1
  10. package/dist/api/generators/base/TemplateEngine.js +1 -1
  11. package/dist/api/generators/base/TypeMapper.d.ts +2 -2
  12. package/dist/api/generators/base/TypeScriptTypeMapper.d.ts +3 -3
  13. package/dist/api/generators/base/TypeScriptTypeMapper.js +1 -1
  14. package/dist/api/generators/base/builders/DirectoryBuilder.d.ts +4 -4
  15. package/dist/api/generators/base/builders/FileBuilder.d.ts +2 -2
  16. package/dist/api/generators/base/builders/IndexBuilder.d.ts +2 -2
  17. package/dist/api/generators/base/enhanced-errors.d.ts +2 -2
  18. package/dist/api/generators/base/enhanced-errors.js +1 -1
  19. package/dist/api/generators/base/error-handler.d.ts +2 -2
  20. package/dist/api/generators/base/error-handler.js +1 -1
  21. package/dist/api/generators/base/errors.d.ts +2 -2
  22. package/dist/api/generators/base/index.d.ts +22 -22
  23. package/dist/api/generators/base/index.js +11 -11
  24. package/dist/api/generators/base/types.d.ts +4 -4
  25. package/dist/api/generators/typescript.d.ts +6 -6
  26. package/dist/api/generators/typescript.js +54 -46
  27. package/dist/api/index.d.ts +8 -8
  28. package/dist/api/index.js +3 -3
  29. package/dist/cli/commands/generate/typescript.d.ts +1 -1
  30. package/dist/cli/commands/generate/typescript.js +2 -2
  31. package/dist/cli/commands/generate.d.ts +1 -1
  32. package/dist/cli/commands/generate.js +4 -4
  33. package/dist/cli/commands/index.js +3 -3
  34. package/dist/cli/commands/typeschema/generate.js +3 -3
  35. package/dist/cli/commands/typeschema.js +2 -2
  36. package/dist/cli/index.js +55 -55
  37. package/dist/cli/utils/log.d.ts +2 -2
  38. package/dist/cli/utils/log.js +2 -2
  39. package/dist/config.d.ts +2 -2
  40. package/dist/config.js +5 -5
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +2 -2
  43. package/dist/typeschema/cache.d.ts +7 -7
  44. package/dist/typeschema/core/binding.d.ts +1 -1
  45. package/dist/typeschema/core/binding.js +6 -4
  46. package/dist/typeschema/core/field-builder.d.ts +3 -3
  47. package/dist/typeschema/core/field-builder.js +3 -3
  48. package/dist/typeschema/core/identifier.d.ts +5 -17
  49. package/dist/typeschema/core/identifier.js +15 -47
  50. package/dist/typeschema/core/nested-types.d.ts +2 -2
  51. package/dist/typeschema/core/nested-types.js +2 -2
  52. package/dist/typeschema/core/transformer.d.ts +3 -3
  53. package/dist/typeschema/core/transformer.js +20 -28
  54. package/dist/typeschema/generator.d.ts +3 -4
  55. package/dist/typeschema/generator.js +12 -14
  56. package/dist/typeschema/index.d.ts +4 -5
  57. package/dist/typeschema/index.js +4 -4
  58. package/dist/typeschema/parser.d.ts +5 -5
  59. package/dist/typeschema/profile/processor.d.ts +2 -3
  60. package/dist/typeschema/profile/processor.js +12 -10
  61. package/dist/typeschema/types.d.ts +66 -375
  62. package/dist/typeschema/types.js +14 -2
  63. package/dist/typeschema/value-set/processor.d.ts +1 -1
  64. package/dist/typeschema/value-set/processor.js +1 -1
  65. package/package.json +2 -2
  66. package/dist/typeschema/schema.d.ts +0 -485
  67. package/dist/typeschema/schema.js +0 -456
  68. package/dist/typeschema/type-schema.types.d.ts +0 -186
  69. package/dist/typeschema/type-schema.types.js +0 -39
  70. package/dist/typeschema/utils.d.ts +0 -6
  71. package/dist/typeschema/utils.js +0 -13
@@ -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 "../../typeschema/type-schema.types.js";
8
- import { BaseGenerator } from "./base/BaseGenerator.js";
9
- import { TypeScriptTypeMapper, } from "./base/TypeScriptTypeMapper.js";
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) || !schema.enum || !Array.isArray(schema.enum) || schema.enum.length === 0) {
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 || 'required-only';
156
+ const mode = this.options.valueSetMode || "required-only";
154
157
  switch (mode) {
155
- case 'all':
158
+ case "all":
156
159
  return true; // Generate for all binding strengths
157
- case 'required-only':
158
- return schema.strength === 'required';
159
- case 'custom':
160
- const strengths = this.options.valueSetStrengths || ['required'];
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 === 'required';
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.map((value) => `'${value}'`).join(' | ');
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(',\n') || '';
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(' * @generated This file is auto-generated. Do not edit manually.');
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('] as const;');
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('\n');
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 || this.collectedValueSets.size === 0) {
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(' * FHIR Value Sets');
787
- lines.push(' * This file re-exports all generated value sets.');
788
- lines.push(' * ');
789
- lines.push(' * @generated This file is auto-generated. Do not edit manually.');
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('\n');
799
- await this.fileManager.writeFile('valuesets/index.ts', content);
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(' * FHIR R4 TypeScript Types');
813
- lines.push(' * Generated from FHIR StructureDefinitions');
814
- lines.push(' * ');
815
- lines.push(' * @generated This file is auto-generated. Do not edit manually.');
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.js";');
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('// Value Sets');
830
- lines.push('export * from "./valuesets/index.js";');
836
+ lines.push("");
837
+ lines.push("// Value Sets");
838
+ lines.push('export * from "./valuesets/index";');
831
839
  }
832
- const content = lines.join('\n');
833
- await this.fileManager.writeFile('index.ts', content);
834
- this.logger.info(`Generated index.ts with type exports${this.tsOptions.generateValueSets && this.collectedValueSets.size > 0 ? ' and value sets' : ''}`);
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
  }
@@ -6,14 +6,14 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- export { TypeSchemaCache, TypeSchemaGenerator, TypeSchemaParser, } from "../typeschema/index.js";
10
- export type { TypeSchema, TypeSchemaField, TypeSchemaIdentifier, } from "../typeschema/type-schema.types.js";
11
- export type { PackageInfo } from "../typeschema/types.js";
12
- export type { APIBuilderOptions, GenerationResult, ProgressCallback, } from "./builder.js";
13
- export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder.js";
14
- export type { GeneratedFile } from "./generators/base/index.js";
15
- export type { TypeScriptGeneratorOptions } from "./generators/typescript.js";
16
- export { TypeScriptGenerator } from "./generators/typescript.js";
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 "../typeschema/index.js";
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.js";
12
+ export { APIBuilder, createAPI, createAPIFromConfig, generateTypesFromFiles, generateTypesFromPackage, } from "./builder";
13
13
  // Export generator classes for advanced usage
14
- export { TypeScriptGenerator } from "./generators/typescript.js";
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.js";
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.js";
7
- import { createLogger } from "../../utils/log.js";
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
  */
@@ -5,7 +5,7 @@
5
5
  * and executes generation based purely on config settings.
6
6
  */
7
7
  import type { CommandModule } from "yargs";
8
- import type { CLIArgv } from "./index.js";
8
+ import type { CLIArgv } from "./index";
9
9
  interface GenerateArgs extends CLIArgv {
10
10
  }
11
11
  /**
@@ -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.js";
10
- import { CONFIG_FILE_NAMES, loadConfig } from "../../config.js";
11
- import { createLogger, error, step, success, warn } from "../utils/log.js";
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.js";
10
- import { generateCommand } from "./generate.js";
11
- import { typeschemaCommand } from "./typeschema.js";
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.js";
9
- import { TypeSchemaGenerator } from "../../../typeschema/generator.js";
10
- import { complete, createLogger, list } from "../../utils/log.js";
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.js";
7
- import { generateTypeschemaCommand } from "./typeschema/generate.js";
6
+ import { error, info, list } from "../utils/log";
7
+ import { generateTypeschemaCommand } from "./typeschema/generate";
8
8
  /**
9
9
  * TypeSchema command group
10
10
  */