@atomic-ehr/codegen 0.0.2-canary.20251114125643.cb2d5e2 → 0.0.2-canary.20251114134039.790395b
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 +18 -18
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5802,23 +5802,31 @@ var tsGet = (object, tsFieldName2) => {
|
|
|
5802
5802
|
if (tsFieldName2.startsWith('"')) return `${object}[${tsFieldName2}]`;
|
|
5803
5803
|
return `${object}.${tsFieldName2}`;
|
|
5804
5804
|
};
|
|
5805
|
+
var tsEnumType = (enumValues) => {
|
|
5806
|
+
return `(${enumValues.map((e) => `"${e}"`).join(" | ")})`;
|
|
5807
|
+
};
|
|
5805
5808
|
var TypeScript = class extends Writer {
|
|
5806
5809
|
tsImportType(tsPackageName, ...entities) {
|
|
5807
5810
|
this.lineSM(`import type { ${entities.join(", ")} } from "${tsPackageName}"`);
|
|
5808
5811
|
}
|
|
5809
5812
|
generateFhirPackageIndexFile(schemas) {
|
|
5810
5813
|
this.cat("index.ts", () => {
|
|
5811
|
-
let exports = schemas.
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5814
|
+
let exports = schemas.flatMap((schema) => [
|
|
5815
|
+
{
|
|
5816
|
+
identifier: schema.identifier,
|
|
5817
|
+
tsPackageName: tsModuleName(schema.identifier),
|
|
5818
|
+
resourceName: tsResourceName(schema.identifier),
|
|
5819
|
+
nestedTypes: isResourceTypeSchema(schema) && schema.nested ? schema.nested.map((n) => tsResourceName(n.identifier)) : []
|
|
5820
|
+
}
|
|
5821
|
+
]).sort((a, b) => a.resourceName.localeCompare(b.resourceName));
|
|
5816
5822
|
exports = Array.from(new Map(exports.map((exp) => [exp.resourceName.toLowerCase(), exp])).values()).sort(
|
|
5817
5823
|
(a, b) => a.resourceName.localeCompare(b.resourceName)
|
|
5818
5824
|
);
|
|
5819
5825
|
for (const exp of exports) {
|
|
5820
5826
|
this.debugComment(exp.identifier);
|
|
5821
|
-
this.lineSM(
|
|
5827
|
+
this.lineSM(
|
|
5828
|
+
`export type { ${[exp.resourceName, ...exp.nestedTypes].join(", ")} } from "./${exp.tsPackageName}"`
|
|
5829
|
+
);
|
|
5822
5830
|
}
|
|
5823
5831
|
});
|
|
5824
5832
|
}
|
|
@@ -5901,7 +5909,7 @@ var TypeScript = class extends Writer {
|
|
|
5901
5909
|
const tsName = tsFieldName(fieldName);
|
|
5902
5910
|
let tsType;
|
|
5903
5911
|
if (field.enum) {
|
|
5904
|
-
tsType = field.enum
|
|
5912
|
+
tsType = tsEnumType(field.enum);
|
|
5905
5913
|
} else if (schema.identifier.name === "Reference" && tsName === "reference") {
|
|
5906
5914
|
tsType = "`${T}/${string}`";
|
|
5907
5915
|
} else if (field.reference && field.reference.length > 0) {
|
|
@@ -5945,7 +5953,7 @@ var TypeScript = class extends Writer {
|
|
|
5945
5953
|
const tsName2 = tsFieldName(fieldName);
|
|
5946
5954
|
let tsType;
|
|
5947
5955
|
if (field.enum) {
|
|
5948
|
-
tsType =
|
|
5956
|
+
tsType = tsEnumType(field.enum);
|
|
5949
5957
|
} else if (field.reference && field.reference.length > 0) {
|
|
5950
5958
|
const specialization = tsIndex.findLastSpecialization(flatProfile);
|
|
5951
5959
|
if (!isSpecializationTypeSchema(specialization))
|