inibase 1.0.0-rc.70 → 1.0.0-rc.72
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 +4 -4
- package/dist/utils.js +18 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -689,7 +689,7 @@ export default class Inibase {
|
|
|
689
689
|
if (searchResult) {
|
|
690
690
|
RETURN = Utils.deepMerge(RETURN, Object.fromEntries(Object.entries(searchResult).filter(([_k, v], _i) => Object.keys(v).length ===
|
|
691
691
|
Object.keys(criteria.and ?? {}).length)));
|
|
692
|
-
criteria.and
|
|
692
|
+
delete criteria.and;
|
|
693
693
|
RETURN_LineNumbers = lineNumbers;
|
|
694
694
|
}
|
|
695
695
|
else
|
|
@@ -697,7 +697,7 @@ export default class Inibase {
|
|
|
697
697
|
}
|
|
698
698
|
if (criteria.or && Utils.isObject(criteria.or)) {
|
|
699
699
|
const [searchResult, lineNumbers] = await this.applyCriteria(tableName, schema, options, criteria.or, false);
|
|
700
|
-
criteria.or
|
|
700
|
+
delete criteria.or;
|
|
701
701
|
if (searchResult) {
|
|
702
702
|
RETURN = Utils.deepMerge(RETURN, searchResult);
|
|
703
703
|
RETURN_LineNumbers = lineNumbers;
|
|
@@ -724,7 +724,7 @@ export default class Inibase {
|
|
|
724
724
|
searchComparedAtValue = searchCriteria.map((single_or) => single_or[1]);
|
|
725
725
|
searchLogicalOperator = "or";
|
|
726
726
|
}
|
|
727
|
-
value.or
|
|
727
|
+
delete value.or;
|
|
728
728
|
}
|
|
729
729
|
if (value?.and &&
|
|
730
730
|
Array.isArray(value?.and)) {
|
|
@@ -738,7 +738,7 @@ export default class Inibase {
|
|
|
738
738
|
searchComparedAtValue = searchCriteria.map((single_and) => single_and[1]);
|
|
739
739
|
searchLogicalOperator = "and";
|
|
740
740
|
}
|
|
741
|
-
value.and
|
|
741
|
+
delete value.and;
|
|
742
742
|
}
|
|
743
743
|
}
|
|
744
744
|
else if (Array.isArray(value)) {
|
package/dist/utils.js
CHANGED
|
@@ -243,17 +243,28 @@ export const detectFieldType = (input, availableTypes) => {
|
|
|
243
243
|
export const validateFieldType = (value, fieldType, fieldChildrenType) => {
|
|
244
244
|
if (value === null)
|
|
245
245
|
return true;
|
|
246
|
-
if (Array.isArray(fieldType))
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
if (Array.isArray(fieldType)) {
|
|
247
|
+
const detectedFieldType = detectFieldType(value, fieldType);
|
|
248
|
+
if (!detectedFieldType)
|
|
249
|
+
return false;
|
|
250
|
+
fieldType = detectedFieldType;
|
|
251
|
+
}
|
|
252
|
+
if (fieldType === "array" && fieldChildrenType)
|
|
253
|
+
return value.every((v) => {
|
|
254
|
+
let _fieldChildrenType = fieldChildrenType;
|
|
255
|
+
if (Array.isArray(_fieldChildrenType)) {
|
|
256
|
+
const detectedFieldType = detectFieldType(v, _fieldChildrenType);
|
|
257
|
+
if (!detectedFieldType)
|
|
258
|
+
return false;
|
|
259
|
+
_fieldChildrenType = detectedFieldType;
|
|
260
|
+
}
|
|
261
|
+
return validateFieldType(v, _fieldChildrenType);
|
|
262
|
+
});
|
|
252
263
|
switch (fieldType) {
|
|
253
264
|
case "string":
|
|
254
265
|
return isString(value);
|
|
255
266
|
case "password":
|
|
256
|
-
return
|
|
267
|
+
return !Array.isArray(value) && !isObject(value); // accept
|
|
257
268
|
case "number":
|
|
258
269
|
return isNumber(value);
|
|
259
270
|
case "html":
|