@atomic-ehr/codegen 0.0.2-canary.20251121141554.c9f1e0b → 0.0.2-canary.20251121161730.cea2c3d

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/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import b from'picocolors';import wn from'yargs';import {hideBin}from'yargs/helpers';import*as x from'fs';import x__default,{existsSync}from'fs';import*as F from'path';import F__default,{dirname,resolve}from'path';import*as D from'fs/promises';import {mkdir,writeFile,readFile}from'fs/promises';import {CanonicalManager}from'@atomic-ehr/fhir-canonical-manager';import*as pt from'@atomic-ehr/fhirschema';import {isStructureDefinition}from'@atomic-ehr/fhirschema';import*as vt from'yaml';var B=class n{options;dryWarnSet=new Set;constructor(e={}){this.options={timestamp:false,verbose:false,...e};}static consoleLevelsMap={1:console.log,2:console.warn,3:console.error,0:console.log,4:()=>{}};formatMessage(e,t,r){let o=this.options.timestamp?`${b.gray(new Date().toLocaleTimeString())} `:"",i=this.options.prefix?`${b.cyan(`[${this.options.prefix}]`)} `:"";return `${o}${r(e)} ${i}${t}`}isSuppressed(e){return this.options.suppressLoggingLevel==="all"||this.options.suppressLoggingLevel?.includes(e)||false}tryWriteToConsole(e,t){if(this.isSuppressed(e))return;(n.consoleLevelsMap[e]||console.log)(t);}success(e){this.tryWriteToConsole(1,this.formatMessage("",e,b.green));}error(e,t){this.isSuppressed(3)||(console.error(this.formatMessage("X",e,b.red)),t&&this.options.verbose&&(console.error(b.red(` ${t.message}`)),t.stack&&console.error(b.gray(t.stack))));}warn(e){this.tryWriteToConsole(2,this.formatMessage("!",e,b.yellow));}dry_warn(e){this.dryWarnSet.has(e)||(this.warn(e),this.dryWarnSet.add(e));}info(e){this.tryWriteToConsole(1,this.formatMessage("i",e,b.blue));}debug(e){this.options.verbose&&this.tryWriteToConsole(0,this.formatMessage("\u{1F41B}",e,b.magenta));}step(e){this.tryWriteToConsole(1,this.formatMessage("\u{1F680}",e,b.cyan));}progress(e){this.tryWriteToConsole(1,this.formatMessage("\u23F3",e,b.blue));}plain(e,t=r=>r){let r=this.options.timestamp?`${b.gray(new Date().toLocaleTimeString())} `:"",o=this.options.prefix?`${b.cyan(`[${this.options.prefix}]`)} `:"";this.tryWriteToConsole(1,`${r}${o}${t(e)}`);}dim(e){this.plain(e,b.gray);}child(e){return new n({...this.options,prefix:this.options.prefix?`${this.options.prefix}:${e}`:e})}configure(e){this.options={...this.options,...e};}},M=new B;function ye(n){M.success(n);}function I(n,e){M.error(n,e);}function Ae(n){M.warn(n);}function Se(n){M.info(n);}function _e(n){M.step(n);}function Mt(n){M.dim(n);}function Ge(n){M.configure(n);}function E(n={}){return new B(n)}function ze(n){console.log(),console.log(b.cyan(b.bold(`\u2501\u2501\u2501 ${n} \u2501\u2501\u2501`)));}function We(n,e,t){let r=n;e&&(r+=` ${b.gray(`(${e}ms)`)}`),ye(r),t&&Object.entries(t).forEach(([o,i])=>{Mt(` ${o}: ${i}`);});}function U(n,e="\u2022"){n.forEach(t=>{console.log(b.gray(` ${e} ${t}`));});}var be=n=>n.split(/(?<=[a-z])(?=[A-Z])|[-_.\s]/).filter(Boolean),z=n=>be(n).map(e=>e.toLowerCase()).join("-"),qe=n=>{if(n.length===0)throw new Error("Empty string");return n[0]?.toUpperCase()+n.substring(1).toLowerCase()},Je=n=>{if(n.length===0)throw new Error("Empty string");let[e,...t]=be(n);return [e?.toLowerCase(),...t.map(qe)].join("")},L=n=>be(n).map(qe).join("");var w=n=>!n||n.length===0?n:n.charAt(0).toUpperCase()+n.slice(1),te=n=>n.map(e=>w(e));var Ke=n=>`<${n.identifier.url}> from ${n.identifier.package}#${n.identifier.version}`;var Te=class{opts;currentDir;currentFileDescriptor;writtenFilesSet=new Set;constructor(e){this.opts=e,this.currentDir=e.outputDir;}logger(){return this.opts.logger}cd(e,t){let r=this.currentDir;this.currentDir=e.startsWith("/")?F.join(this.opts.outputDir,e):F.join(this.currentDir,e),x.existsSync(this.currentDir)||x.mkdirSync(this.currentDir,{recursive:true}),this.logger()?.debug(`cd '${this.currentDir}'`),t(),this.currentDir=r;}cat(e,t){if(this.currentFileDescriptor)throw new Error("Can't open file in file");if(e.includes("/"))throw new Error(`Change file path separatly: ${e}`);let r=`${this.currentDir}/${e}`;try{this.currentFileDescriptor=x.openSync(r,"w"),this.writtenFilesSet.add(e),this.logger()?.debug(`cat > '${r}'`),t();}finally{this.currentFileDescriptor&&(x.fsyncSync(this.currentFileDescriptor),x.closeSync(this.currentFileDescriptor)),this.currentFileDescriptor=void 0;}}write(e){if(!this.currentFileDescriptor)throw new Error("No file opened");x.writeSync(this.currentFileDescriptor,e);}async generate(e){throw new Error("Not implemented")}writtenFiles(){return Array.from(this.writtenFilesSet)}},H=class extends Te{currentIndent=0;indent(){this.currentIndent+=this.opts.tabSize;}deindent(){this.currentIndent-=this.opts.tabSize;}writeIndent(){this.write(" ".repeat(this.currentIndent));}line(...e){e.length===0?this.write(`
2
+ import b from'picocolors';import wn from'yargs';import {hideBin}from'yargs/helpers';import*as x from'fs';import x__default,{existsSync}from'fs';import*as F from'path';import F__default,{dirname,resolve}from'path';import*as D from'fs/promises';import {mkdir,writeFile,readFile}from'fs/promises';import {CanonicalManager}from'@atomic-ehr/fhir-canonical-manager';import*as pt from'@atomic-ehr/fhirschema';import {isStructureDefinition}from'@atomic-ehr/fhirschema';import*as vt from'yaml';var B=class n{options;dryWarnSet=new Set;constructor(e={}){this.options={timestamp:false,verbose:false,...e};}static consoleLevelsMap={1:console.log,2:console.warn,3:console.error,0:console.log,4:()=>{}};formatMessage(e,t,r){let o=this.options.timestamp?`${b.gray(new Date().toLocaleTimeString())} `:"",i=this.options.prefix?`${b.cyan(`[${this.options.prefix}]`)} `:"";return `${o}${r(e)} ${i}${t}`}isSuppressed(e){return this.options.suppressLoggingLevel==="all"||this.options.suppressLoggingLevel?.includes(e)||false}tryWriteToConsole(e,t){if(this.isSuppressed(e))return;(n.consoleLevelsMap[e]||console.log)(t);}success(e){this.tryWriteToConsole(1,this.formatMessage("",e,b.green));}error(e,t){this.isSuppressed(3)||(console.error(this.formatMessage("X",e,b.red)),t&&this.options.verbose&&(console.error(b.red(` ${t.message}`)),t.stack&&console.error(b.gray(t.stack))));}warn(e){this.tryWriteToConsole(2,this.formatMessage("!",e,b.yellow));}dry_warn(e){this.dryWarnSet.has(e)||(this.warn(e),this.dryWarnSet.add(e));}info(e){this.tryWriteToConsole(1,this.formatMessage("i",e,b.blue));}debug(e){this.options.verbose&&this.tryWriteToConsole(0,this.formatMessage("\u{1F41B}",e,b.magenta));}step(e){this.tryWriteToConsole(1,this.formatMessage("\u{1F680}",e,b.cyan));}progress(e){this.tryWriteToConsole(1,this.formatMessage("\u23F3",e,b.blue));}plain(e,t=r=>r){let r=this.options.timestamp?`${b.gray(new Date().toLocaleTimeString())} `:"",o=this.options.prefix?`${b.cyan(`[${this.options.prefix}]`)} `:"";this.tryWriteToConsole(1,`${r}${o}${t(e)}`);}dim(e){this.plain(e,b.gray);}child(e){return new n({...this.options,prefix:this.options.prefix?`${this.options.prefix}:${e}`:e})}configure(e){this.options={...this.options,...e};}},M=new B;function ye(n){M.success(n);}function I(n,e){M.error(n,e);}function Ae(n){M.warn(n);}function Se(n){M.info(n);}function _e(n){M.step(n);}function Mt(n){M.dim(n);}function Ge(n){M.configure(n);}function E(n={}){return new B(n)}function ze(n){console.log(),console.log(b.cyan(b.bold(`\u2501\u2501\u2501 ${n} \u2501\u2501\u2501`)));}function We(n,e,t){let r=n;e&&(r+=` ${b.gray(`(${e}ms)`)}`),ye(r),t&&Object.entries(t).forEach(([o,i])=>{Mt(` ${o}: ${i}`);});}function U(n,e="\u2022"){n.forEach(t=>{console.log(b.gray(` ${e} ${t}`));});}var be=n=>n.split(/(?<=[a-z])(?=[A-Z])|[-_.\s]/).filter(Boolean),z=n=>be(n).map(e=>e.toLowerCase()).join("-"),qe=n=>{if(n.length===0)throw new Error("Empty string");return n[0]?.toUpperCase()+n.substring(1).toLowerCase()},Je=n=>{if(n.length===0)throw new Error("Empty string");let[e,...t]=be(n);return [e?.toLowerCase(),...t.map(qe)].join("")},L=n=>be(n).map(qe).join("");var w=n=>!n||n.length===0?n:n.charAt(0).toUpperCase()+n.slice(1),te=n=>n.map(e=>w(e));var Ke=n=>`<${n.identifier.url}> from ${n.identifier.package}#${n.identifier.version}`;var Te=class{opts;currentDir;currentFileDescriptor;writtenFilesSet=new Set;constructor(e){this.opts=e,this.currentDir=e.outputDir;}logger(){return this.opts.logger}cd(e,t){let r=this.currentDir;this.currentDir=e.startsWith("/")?F.join(this.opts.outputDir,e):F.join(this.currentDir,e),x.existsSync(this.currentDir)||x.mkdirSync(this.currentDir,{recursive:true}),this.logger()?.debug(`cd '${this.currentDir}'`),t(),this.currentDir=r;}cat(e,t){if(this.currentFileDescriptor)throw new Error("Can't open file in file");if(e.includes("/"))throw new Error(`Change file path separatly: ${e}`);let r=`${this.currentDir}/${e}`;try{this.currentFileDescriptor=x.openSync(r,"w"),this.writtenFilesSet.add(e),this.logger()?.debug(`cat > '${r}'`),t();}finally{this.currentFileDescriptor&&(x.fsyncSync(this.currentFileDescriptor),x.closeSync(this.currentFileDescriptor)),this.currentFileDescriptor=void 0;}}write(e){if(!this.currentFileDescriptor)throw new Error("No file opened");x.writeSync(this.currentFileDescriptor,e);}writtenFiles(){return Array.from(this.writtenFilesSet)}},H=class extends Te{currentIndent=0;indent(){this.currentIndent+=this.opts.tabSize;}deindent(){this.currentIndent-=this.opts.tabSize;}writeIndent(){this.write(" ".repeat(this.currentIndent));}line(...e){e.length===0?this.write(`
3
3
  `):(this.writeIndent(),this.write(`${e.join(" ")}
4
4
  `));}lineSM(...e){this.writeIndent(),this.write(`${e.join(" ")};
5
5
  `);}comment(...e){let t=e.join(" ").split(`
package/dist/index.js CHANGED
@@ -84,9 +84,6 @@ var FileSystemWriter = class {
84
84
  if (!this.currentFileDescriptor) throw new Error("No file opened");
85
85
  fs.writeSync(this.currentFileDescriptor, str);
86
86
  }
87
- async generate(_tsIndex) {
88
- throw new Error("Not implemented");
89
- }
90
87
  writtenFiles() {
91
88
  return Array.from(this.writtenFilesSet);
92
89
  }