inibase 1.1.6 → 1.1.8
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.d.ts +1 -1
- package/dist/index.js +11 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type pageInfo = {
|
|
|
40
40
|
export type Criteria = ({
|
|
41
41
|
[logic in "and" | "or"]?: Criteria | (string | number | boolean | null)[];
|
|
42
42
|
} & {
|
|
43
|
-
[key: string]: string | number | boolean | undefined | Criteria;
|
|
43
|
+
[key: string]: string | number | boolean | undefined | Criteria | (string | number | boolean)[];
|
|
44
44
|
}) | null;
|
|
45
45
|
type Entries<T> = {
|
|
46
46
|
[K in keyof T]: [K, T[K]];
|
package/dist/index.js
CHANGED
|
@@ -435,10 +435,10 @@ export default class Inibase {
|
|
|
435
435
|
return Object.keys(cleanedObject).length > 0 ? cleanedObject : null;
|
|
436
436
|
}
|
|
437
437
|
formatField(value, fieldType, fieldChildrenType, _formatOnlyAvailiableKeys) {
|
|
438
|
+
if (value === null || value === undefined)
|
|
439
|
+
return value;
|
|
438
440
|
if (Array.isArray(fieldType))
|
|
439
441
|
fieldType = Utils.detectFieldType(value, fieldType) ?? fieldType[0];
|
|
440
|
-
if (!value)
|
|
441
|
-
return null;
|
|
442
442
|
if (Array.isArray(value) && !["array", "json"].includes(fieldType))
|
|
443
443
|
value = value[0];
|
|
444
444
|
switch (fieldType) {
|
|
@@ -476,7 +476,7 @@ export default class Inibase {
|
|
|
476
476
|
? value
|
|
477
477
|
: UtilsServer.hashPassword(String(value));
|
|
478
478
|
case "number":
|
|
479
|
-
return Utils.isNumber(value) ? Number(value) :
|
|
479
|
+
return Utils.isNumber(value) ? Number(value) : 0;
|
|
480
480
|
case "id":
|
|
481
481
|
return Utils.isNumber(value)
|
|
482
482
|
? value
|
|
@@ -587,10 +587,12 @@ export default class Inibase {
|
|
|
587
587
|
RETURN[f.key] = this.getDefaultValue(f);
|
|
588
588
|
return RETURN;
|
|
589
589
|
}
|
|
590
|
+
case "number":
|
|
591
|
+
return 0;
|
|
590
592
|
case "boolean":
|
|
591
593
|
return false;
|
|
592
594
|
default:
|
|
593
|
-
return
|
|
595
|
+
return "";
|
|
594
596
|
}
|
|
595
597
|
}
|
|
596
598
|
_combineObjectsToArray(input) {
|
|
@@ -987,11 +989,14 @@ export default class Inibase {
|
|
|
987
989
|
}
|
|
988
990
|
const [searchResult, totalLines, linesNumbers] = await File.search(join(tablePath, `${key}${this.getFileExtension(tableName)}`), searchOperator ?? "=", searchComparedAtValue ?? null, searchLogicalOperator, allTrue ? searchIn : undefined, field?.type, field?.children, options.perPage, (options.page - 1) * options.perPage + 1, true, this.salt);
|
|
989
991
|
if (searchResult) {
|
|
990
|
-
|
|
992
|
+
const formatedSearchResult = Object.fromEntries(Object.entries(searchResult).map(([id, value]) => {
|
|
991
993
|
const nestedObj = {};
|
|
992
994
|
this._setNestedKey(nestedObj, key, value);
|
|
993
995
|
return [id, nestedObj];
|
|
994
|
-
}))
|
|
996
|
+
}));
|
|
997
|
+
RETURN = allTrue
|
|
998
|
+
? formatedSearchResult
|
|
999
|
+
: Utils.deepMerge(RETURN, formatedSearchResult);
|
|
995
1000
|
this.totalItems.set(`${tableName}-${key}`, totalLines);
|
|
996
1001
|
if (linesNumbers?.size) {
|
|
997
1002
|
if (searchIn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inibase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Karim Amahtil",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@biomejs/biome": "1.9.4",
|
|
72
|
-
"@evilmartians/lefthook": "^1.10.1",
|
|
73
72
|
"@types/bun": "^1.1.10",
|
|
74
73
|
"@types/node": "^22.7.4",
|
|
74
|
+
"lefthook": "^1.10.1",
|
|
75
75
|
"tinybench": "^3.0.7",
|
|
76
76
|
"typescript": "^5.7.2"
|
|
77
77
|
},
|