@atomic-ehr/codegen 0.0.2-canary.20251117083918.dd4cd72 → 0.0.2-canary.20251117091028.dc2c6a5

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
@@ -5935,6 +5935,13 @@ var TypeScript = class extends Writer {
5935
5935
  }
5936
5936
  });
5937
5937
  }
5938
+ generateResourceTypePredicate(schema) {
5939
+ if (!isResourceTypeSchema(schema)) return;
5940
+ const name = tsResourceName(schema.identifier);
5941
+ this.curlyBlock(["export", "const", `is${name}`, "=", `(resource: any): resource is ${name}`, "=>"], () => {
5942
+ this.lineSM(`return resource && resource.resourceType === "${schema.identifier.name}"`);
5943
+ });
5944
+ }
5938
5945
  generateNestedTypes(tsIndex, schema) {
5939
5946
  if (schema.nested) {
5940
5947
  for (const subtype of schema.nested) {
@@ -6102,6 +6109,7 @@ var TypeScript = class extends Writer {
6102
6109
  this.generateNestedTypes(tsIndex, schema);
6103
6110
  this.comment("CanonicalURL:", schema.identifier.url);
6104
6111
  this.generateType(tsIndex, schema);
6112
+ this.generateResourceTypePredicate(schema);
6105
6113
  } else if (isProfileTypeSchema(schema)) {
6106
6114
  const flatProfile = tsIndex.flatProfile(schema);
6107
6115
  this.generateDependenciesImports(flatProfile);