proto.io 0.0.141 → 0.0.142

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.mjs CHANGED
@@ -692,7 +692,7 @@ const validateShapedObject = (schema, dataType) => {
692
692
  }
693
693
  }
694
694
  };
695
- const validateSchemaPermission = (schema) => {
695
+ const validateSchemaName = (schema) => {
696
696
  if (!_.isNil(schema['_Schema']) || !_.isNil(schema['_Config']))
697
697
  throw Error('Reserved name of class');
698
698
  for (const [, _schema] of _.toPairs(schema)) {
@@ -700,15 +700,6 @@ const validateSchemaPermission = (schema) => {
700
700
  if (_.includes(TObject.defaultKeys, key))
701
701
  throw Error(`Reserved field name: ${key}`);
702
702
  }
703
- const fields = _.keys(_schema.fields);
704
- for (const key of _.keys(_schema.fieldLevelPermissions)) {
705
- if (!fields.includes(key))
706
- throw Error(`Invalid field permission: ${key}`);
707
- }
708
- for (const key of _schema.secureFields ?? []) {
709
- if (!fields.includes(key))
710
- throw Error(`Invalid field permission: ${key}`);
711
- }
712
703
  }
713
704
  };
714
705
  const validateSchema = (schema) => {
@@ -730,6 +721,15 @@ const validateSchema = (schema) => {
730
721
  throw Error(`Invalid target: ${key}`);
731
722
  validateForeignField(schema, key, dataType);
732
723
  }
724
+ const fields = _.keys(_schema.fields);
725
+ for (const key of _.keys(_schema.fieldLevelPermissions)) {
726
+ if (!fields.includes(key))
727
+ throw Error(`Invalid field permission: ${key}`);
728
+ }
729
+ for (const key of _schema.secureFields ?? []) {
730
+ if (!fields.includes(key))
731
+ throw Error(`Invalid field permission: ${key}`);
732
+ }
733
733
  }
734
734
  }
735
735
  };
@@ -762,7 +762,7 @@ class ProtoInternal {
762
762
  functions = {};
763
763
  triggers = {};
764
764
  constructor(options) {
765
- validateSchemaPermission(options.schema);
765
+ validateSchemaName(options.schema);
766
766
  const schema = mergeSchema(defaultSchema, options.fileStorage.schema, options.schema);
767
767
  validateSchema(schema);
768
768
  this.options = {