@atomic-ehr/codegen 0.0.2-canary.20251117083918.dd4cd72 → 0.0.2-canary.20251117091307.8f59d1c
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 +12 -12
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5816,7 +5816,8 @@ var TypeScript = class extends Writer {
|
|
|
5816
5816
|
identifier: schema.identifier,
|
|
5817
5817
|
tsPackageName: tsModuleName(schema.identifier),
|
|
5818
5818
|
resourceName: tsResourceName(schema.identifier),
|
|
5819
|
-
nestedTypes: isResourceTypeSchema(schema) && schema.nested ? schema.nested.map((n) => tsResourceName(n.identifier)) : []
|
|
5819
|
+
nestedTypes: isResourceTypeSchema(schema) && schema.nested ? schema.nested.map((n) => tsResourceName(n.identifier)) : [],
|
|
5820
|
+
helpers: isResourceTypeSchema(schema) ? [`is${tsResourceName(schema.identifier)}`] : []
|
|
5820
5821
|
}
|
|
5821
5822
|
]).sort((a, b) => a.resourceName.localeCompare(b.resourceName));
|
|
5822
5823
|
exports = Array.from(new Map(exports.map((exp) => [exp.resourceName.toLowerCase(), exp])).values()).sort(
|
|
@@ -5825,7 +5826,7 @@ var TypeScript = class extends Writer {
|
|
|
5825
5826
|
for (const exp of exports) {
|
|
5826
5827
|
this.debugComment(exp.identifier);
|
|
5827
5828
|
this.lineSM(
|
|
5828
|
-
`export type { ${[exp.resourceName, ...exp.nestedTypes].join(", ")} } from "./${exp.tsPackageName}"`
|
|
5829
|
+
`export type { ${[exp.resourceName, ...exp.nestedTypes, ...exp.helpers].join(", ")} } from "./${exp.tsPackageName}"`
|
|
5829
5830
|
);
|
|
5830
5831
|
}
|
|
5831
5832
|
});
|
|
@@ -5935,6 +5936,13 @@ var TypeScript = class extends Writer {
|
|
|
5935
5936
|
}
|
|
5936
5937
|
});
|
|
5937
5938
|
}
|
|
5939
|
+
generateResourceTypePredicate(schema) {
|
|
5940
|
+
if (!isResourceTypeSchema(schema)) return;
|
|
5941
|
+
const name = tsResourceName(schema.identifier);
|
|
5942
|
+
this.curlyBlock(["export", "const", `is${name}`, "=", `(resource: any): resource is ${name}`, "=>"], () => {
|
|
5943
|
+
this.lineSM(`return resource && resource.resourceType === "${schema.identifier.name}"`);
|
|
5944
|
+
});
|
|
5945
|
+
}
|
|
5938
5946
|
generateNestedTypes(tsIndex, schema) {
|
|
5939
5947
|
if (schema.nested) {
|
|
5940
5948
|
for (const subtype of schema.nested) {
|
|
@@ -6102,6 +6110,7 @@ var TypeScript = class extends Writer {
|
|
|
6102
6110
|
this.generateNestedTypes(tsIndex, schema);
|
|
6103
6111
|
this.comment("CanonicalURL:", schema.identifier.url);
|
|
6104
6112
|
this.generateType(tsIndex, schema);
|
|
6113
|
+
this.generateResourceTypePredicate(schema);
|
|
6105
6114
|
} else if (isProfileTypeSchema(schema)) {
|
|
6106
6115
|
const flatProfile = tsIndex.flatProfile(schema);
|
|
6107
6116
|
this.generateDependenciesImports(flatProfile);
|