@atomic-ehr/codegen 0.0.2-canary.20251114125643.cb2d5e2 → 0.0.2

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/index.js CHANGED
@@ -2,8 +2,8 @@ import * as fs from 'fs';
2
2
  import fs__default, { existsSync, mkdirSync } from 'fs';
3
3
  import * as afs2 from 'fs/promises';
4
4
  import { readdir, stat, unlink, readFile, writeFile, access, mkdir, rm } from 'fs/promises';
5
- import * as Path4 from 'path';
6
- import Path4__default, { join, resolve, dirname, relative } from 'path';
5
+ import * as Path3 from 'path';
6
+ import Path3__default, { join, resolve, dirname, relative } from 'path';
7
7
  import { CanonicalManager } from '@atomic-ehr/fhir-canonical-manager';
8
8
  import * as fhirschema from '@atomic-ehr/fhirschema';
9
9
  import { isStructureDefinition } from '@atomic-ehr/fhirschema';
@@ -3036,7 +3036,7 @@ var FileSystemWriter = class {
3036
3036
  }
3037
3037
  cd(path, gen) {
3038
3038
  const prev = this.currentDir;
3039
- this.currentDir = path.startsWith("/") ? Path4.join(this.opts.outputDir, path) : Path4.join(this.currentDir, path);
3039
+ this.currentDir = path.startsWith("/") ? Path3.join(this.opts.outputDir, path) : Path3.join(this.currentDir, path);
3040
3040
  if (!fs.existsSync(this.currentDir)) {
3041
3041
  fs.mkdirSync(this.currentDir, { recursive: true });
3042
3042
  }
@@ -3461,12 +3461,12 @@ var CSharp = class extends Writer {
3461
3461
  }
3462
3462
  copyStaticFiles() {
3463
3463
  if (!this.staticSourceDir) return;
3464
- const sourcePath = Path4__default.resolve(this.staticSourceDir);
3464
+ const sourcePath = Path3__default.resolve(this.staticSourceDir);
3465
3465
  fs__default.cpSync(sourcePath, this.opts.outputDir, { recursive: true });
3466
3466
  }
3467
3467
  generateHelperFile() {
3468
3468
  const sourceFile = "src/api/writer-generator/csharp/Helper.cs";
3469
- const destFile = Path4__default.join(this.opts.outputDir, "Helper.cs");
3469
+ const destFile = Path3__default.join(this.opts.outputDir, "Helper.cs");
3470
3470
  fs__default.copyFileSync(sourceFile, destFile);
3471
3471
  }
3472
3472
  };
@@ -3685,7 +3685,6 @@ var mkTypeSchemaIndex = (schemas, logger) => {
3685
3685
  }
3686
3686
  }
3687
3687
  const raw = filename.endsWith(".yaml") ? YAML.stringify(tree) : JSON.stringify(tree, void 0, 2);
3688
- await afs2.mkdir(Path4.dirname(filename), { recursive: true });
3689
3688
  await afs2.writeFile(filename, raw);
3690
3689
  };
3691
3690
  return {
@@ -5945,7 +5944,7 @@ var TypeScript = class extends Writer {
5945
5944
  const tsName2 = tsFieldName(fieldName);
5946
5945
  let tsType;
5947
5946
  if (field.enum) {
5948
- tsType = `(${field.enum.map((e) => `'${e}'`).join(" | ")})`;
5947
+ tsType = field.enum.map((e) => `'${e}'`).join(" | ");
5949
5948
  } else if (field.reference && field.reference.length > 0) {
5950
5949
  const specialization = tsIndex.findLastSpecialization(flatProfile);
5951
5950
  if (!isSpecializationTypeSchema(specialization))
@@ -6127,7 +6126,7 @@ var writerToGenerator = (writerGen) => {
6127
6126
  const getGeneratedFiles = () => {
6128
6127
  return writerGen.writtenFiles().map((fn) => {
6129
6128
  return {
6130
- path: Path4.normalize(Path4.join(writerGen.opts.outputDir, fn)),
6129
+ path: Path3.normalize(Path3.join(writerGen.opts.outputDir, fn)),
6131
6130
  filename: fn.replace(/^.*[\\/]/, ""),
6132
6131
  content: "",
6133
6132
  exports: [],
@@ -6185,7 +6184,7 @@ var writeTypeSchemasToSeparateFiles = async (typeSchemas, outputDir, logger) =>
6185
6184
  const pkgPath = normalizeFileName(packageMetaToFhir(pkg));
6186
6185
  const name = normalizeFileName(`${ts.identifier.name}(${extractNameFromCanonical(ts.identifier.url)})`);
6187
6186
  const json = JSON.stringify(ts, null, 2);
6188
- const baseName = Path4.join(outputDir, pkgPath, name);
6187
+ const baseName = Path3.join(outputDir, pkgPath, name);
6189
6188
  if (!files[baseName]) files[baseName] = [];
6190
6189
  if (!files[baseName]?.some((e) => e === json)) {
6191
6190
  files[baseName].push(json);
@@ -6200,7 +6199,7 @@ var writeTypeSchemasToSeparateFiles = async (typeSchemas, outputDir, logger) =>
6200
6199
  } else {
6201
6200
  fullName = `${baseName}-${index}.typeschema.json`;
6202
6201
  }
6203
- await afs2.mkdir(Path4.dirname(fullName), { recursive: true });
6202
+ await afs2.mkdir(Path3.dirname(fullName), { recursive: true });
6204
6203
  await afs2.writeFile(fullName, json);
6205
6204
  })
6206
6205
  );
@@ -6208,7 +6207,7 @@ var writeTypeSchemasToSeparateFiles = async (typeSchemas, outputDir, logger) =>
6208
6207
  };
6209
6208
  var writeTypeSchemasToSingleFile = async (typeSchemas, outputFile, logger) => {
6210
6209
  logger.info(`Writing TypeSchema files to: ${outputFile}`);
6211
- await afs2.mkdir(Path4.dirname(outputFile), { recursive: true });
6210
+ await afs2.mkdir(Path3.dirname(outputFile), { recursive: true });
6212
6211
  logger.info(`Writing TypeSchemas to one file ${outputFile}...`);
6213
6212
  for (const ts of typeSchemas) {
6214
6213
  const json = JSON.stringify(ts, null, 2);
@@ -6219,7 +6218,7 @@ var writeTypeSchemasToSingleFile = async (typeSchemas, outputFile, logger) => {
6219
6218
  var tryWriteTypeSchema = async (typeSchemas, opts, logger) => {
6220
6219
  if (!opts.typeSchemaOutputDir) return;
6221
6220
  try {
6222
- if (Path4.extname(opts.typeSchemaOutputDir) === ".ndjson") {
6221
+ if (Path3.extname(opts.typeSchemaOutputDir) === ".ndjson") {
6223
6222
  await writeTypeSchemasToSingleFile(typeSchemas, opts.typeSchemaOutputDir, logger);
6224
6223
  } else {
6225
6224
  await writeTypeSchemasToSeparateFiles(typeSchemas, opts.typeSchemaOutputDir, logger);
@@ -6311,7 +6310,7 @@ var APIBuilder = class {
6311
6310
  }
6312
6311
  typescript(opts) {
6313
6312
  const writerOpts = {
6314
- outputDir: Path4.join(this.options.outputDir, "/types"),
6313
+ outputDir: Path3.join(this.options.outputDir, "/types"),
6315
6314
  tabSize: 4,
6316
6315
  withDebugComment: false,
6317
6316
  commentLinePrefix: "//",
@@ -6327,7 +6326,7 @@ var APIBuilder = class {
6327
6326
  csharp(namespace, staticSourceDir) {
6328
6327
  const generator = writerToGenerator(
6329
6328
  new CSharp({
6330
- outputDir: Path4.join(this.options.outputDir, "/types"),
6329
+ outputDir: Path3.join(this.options.outputDir, "/types"),
6331
6330
  staticSourceDir: staticSourceDir ?? void 0,
6332
6331
  targetNamespace: namespace,
6333
6332
  logger: new CodegenLogger({