@zenstackhq/sdk 3.9.0 → 3.9.2

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.cjs CHANGED
@@ -742,7 +742,7 @@ var TsSchemaGenerator = class {
742
742
  }
743
743
  createDataModelObject(dm, lite) {
744
744
  const allFields = (0, _zenstackhq_language_utils.getAllFields)(dm);
745
- const allAttributes = lite ? [] : (0, _zenstackhq_language_utils.getAllAttributes)(dm).filter((attr) => {
745
+ const allAttributes = lite ? (0, _zenstackhq_language_utils.getAllAttributes)(dm).filter((attr) => (0, _zenstackhq_language_utils.isLiteAttribute)(attr.decl.ref)) : (0, _zenstackhq_language_utils.getAllAttributes)(dm).filter((attr) => {
746
746
  if (attr.decl.$refText === "@@delegate" && attr.$container !== dm) return false;
747
747
  return true;
748
748
  });
@@ -783,12 +783,13 @@ var TsSchemaGenerator = class {
783
783
  }
784
784
  createTypeDefObject(td, lite) {
785
785
  const allFields = (0, _zenstackhq_language_utils.getAllFields)(td);
786
- const allAttributes = (0, _zenstackhq_language_utils.getAllAttributes)(td);
786
+ const attributes = lite ? (0, _zenstackhq_language_utils.getAllAttributes)(td).filter((attr) => (0, _zenstackhq_language_utils.isLiteAttribute)(attr.decl.ref)) : (0, _zenstackhq_language_utils.getAllAttributes)(td);
787
787
  const fields = [
788
788
  typescript.factory.createPropertyAssignment("name", typescript.factory.createStringLiteral(td.name)),
789
789
  typescript.factory.createPropertyAssignment("fields", typescript.factory.createObjectLiteralExpression(allFields.map((field) => typescript.factory.createPropertyAssignment(field.name, this.createDataFieldObject(field, void 0, lite))), true)),
790
- ...allAttributes.length > 0 ? [typescript.factory.createPropertyAssignment("attributes", this.createAttributesTypeAssertion(typescript.factory.createArrayLiteralExpression(allAttributes.map((attr) => this.createAttributeObject(attr)), true)))] : []
790
+ ...attributes.length > 0 ? [typescript.factory.createPropertyAssignment("attributes", this.createAttributesTypeAssertion(typescript.factory.createArrayLiteralExpression(attributes.map((attr) => this.createAttributeObject(attr)), true)))] : []
791
791
  ];
792
+ if ((0, _zenstackhq_language_utils.getAllAttributes)(td).some((attr) => attr.decl.$refText === "@@strict")) fields.push(typescript.factory.createPropertyAssignment("strict", typescript.factory.createTrue()));
792
793
  return typescript.factory.createObjectLiteralExpression(fields, true);
793
794
  }
794
795
  createComputedFieldsObject(fields) {
@@ -839,7 +840,8 @@ var TsSchemaGenerator = class {
839
840
  if (delegateOrigin) objectFields.push(typescript.factory.createPropertyAssignment("originModel", typescript.factory.createStringLiteral(delegateOrigin)));
840
841
  }
841
842
  if (this.isDiscriminatorField(field)) objectFields.push(typescript.factory.createPropertyAssignment("isDiscriminator", typescript.factory.createTrue()));
842
- if (!lite && field.attributes.length > 0) objectFields.push(typescript.factory.createPropertyAssignment("attributes", this.createAttributesTypeAssertion(typescript.factory.createArrayLiteralExpression(field.attributes.map((attr) => this.createAttributeObject(attr))))));
843
+ const attributes = lite ? field.attributes.filter((attr) => (0, _zenstackhq_language_utils.isLiteAttribute)(attr.decl.ref)) : field.attributes;
844
+ if (attributes.length > 0) objectFields.push(typescript.factory.createPropertyAssignment("attributes", this.createAttributesTypeAssertion(typescript.factory.createArrayLiteralExpression(attributes.map((attr) => this.createAttributeObject(attr))))));
843
845
  const defaultValue = this.getFieldMappedDefault(field);
844
846
  if (defaultValue !== void 0) {
845
847
  let defaultExpr;