@atomic-ehr/codegen 0.0.2-canary.20251114134039.790395b → 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
@@ -5892,6 +5892,10 @@ var TypeScript = class extends Writer {
5892
5892
  let extendsClause;
5893
5893
  if (schema.base) extendsClause = `extends ${canonicalToName2(schema.base.url)}`;
5894
5894
  this.debugComment(schema.identifier);
5895
+ if (!schema.fields && !extendsClause && !isResourceTypeSchema(schema)) {
5896
+ this.lineSM(`export type ${name} = object`);
5897
+ return;
5898
+ }
5895
5899
  this.curlyBlock(["export", "interface", name, extendsClause], () => {
5896
5900
  if (isResourceTypeSchema(schema)) {
5897
5901
  const possibleResourceTypes = [schema.identifier];
@@ -5931,6 +5935,13 @@ var TypeScript = class extends Writer {
5931
5935
  }
5932
5936
  });
5933
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
+ }
5934
5945
  generateNestedTypes(tsIndex, schema) {
5935
5946
  if (schema.nested) {
5936
5947
  for (const subtype of schema.nested) {
@@ -6098,6 +6109,7 @@ var TypeScript = class extends Writer {
6098
6109
  this.generateNestedTypes(tsIndex, schema);
6099
6110
  this.comment("CanonicalURL:", schema.identifier.url);
6100
6111
  this.generateType(tsIndex, schema);
6112
+ this.generateResourceTypePredicate(schema);
6101
6113
  } else if (isProfileTypeSchema(schema)) {
6102
6114
  const flatProfile = tsIndex.flatProfile(schema);
6103
6115
  this.generateDependenciesImports(flatProfile);