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.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -695,7 +695,7 @@ const validateShapedObject = (schema, dataType) => {
|
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
};
|
|
698
|
-
const
|
|
698
|
+
const validateSchemaName = (schema) => {
|
|
699
699
|
if (!_.isNil(schema['_Schema']) || !_.isNil(schema['_Config']))
|
|
700
700
|
throw Error('Reserved name of class');
|
|
701
701
|
for (const [, _schema] of _.toPairs(schema)) {
|
|
@@ -703,15 +703,6 @@ const validateSchemaPermission = (schema) => {
|
|
|
703
703
|
if (_.includes(index$1.TObject.defaultKeys, key))
|
|
704
704
|
throw Error(`Reserved field name: ${key}`);
|
|
705
705
|
}
|
|
706
|
-
const fields = _.keys(_schema.fields);
|
|
707
|
-
for (const key of _.keys(_schema.fieldLevelPermissions)) {
|
|
708
|
-
if (!fields.includes(key))
|
|
709
|
-
throw Error(`Invalid field permission: ${key}`);
|
|
710
|
-
}
|
|
711
|
-
for (const key of _schema.secureFields ?? []) {
|
|
712
|
-
if (!fields.includes(key))
|
|
713
|
-
throw Error(`Invalid field permission: ${key}`);
|
|
714
|
-
}
|
|
715
706
|
}
|
|
716
707
|
};
|
|
717
708
|
const validateSchema = (schema) => {
|
|
@@ -733,6 +724,15 @@ const validateSchema = (schema) => {
|
|
|
733
724
|
throw Error(`Invalid target: ${key}`);
|
|
734
725
|
validateForeignField(schema, key, dataType);
|
|
735
726
|
}
|
|
727
|
+
const fields = _.keys(_schema.fields);
|
|
728
|
+
for (const key of _.keys(_schema.fieldLevelPermissions)) {
|
|
729
|
+
if (!fields.includes(key))
|
|
730
|
+
throw Error(`Invalid field permission: ${key}`);
|
|
731
|
+
}
|
|
732
|
+
for (const key of _schema.secureFields ?? []) {
|
|
733
|
+
if (!fields.includes(key))
|
|
734
|
+
throw Error(`Invalid field permission: ${key}`);
|
|
735
|
+
}
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
};
|
|
@@ -765,7 +765,7 @@ class ProtoInternal {
|
|
|
765
765
|
functions = {};
|
|
766
766
|
triggers = {};
|
|
767
767
|
constructor(options) {
|
|
768
|
-
|
|
768
|
+
validateSchemaName(options.schema);
|
|
769
769
|
const schema = mergeSchema(defaultSchema, options.fileStorage.schema, options.schema);
|
|
770
770
|
validateSchema(schema);
|
|
771
771
|
this.options = {
|