inibase 1.1.3 → 1.1.4
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/file.js +1 -0
- package/dist/index.js +14 -8
- package/package.json +1 -1
package/dist/file.js
CHANGED
|
@@ -108,6 +108,7 @@ const secureString = (input) => {
|
|
|
108
108
|
export const encode = (input) => Array.isArray(input)
|
|
109
109
|
? input.every((_input) => _input === null ||
|
|
110
110
|
_input === undefined ||
|
|
111
|
+
_input === "" ||
|
|
111
112
|
(typeof _input === "string" && isStringified(_input)))
|
|
112
113
|
? `[${input.join(",")}]`
|
|
113
114
|
: Inison.stringify(input)
|
package/dist/index.js
CHANGED
|
@@ -489,8 +489,9 @@ export default class Inibase {
|
|
|
489
489
|
for (const field of schema) {
|
|
490
490
|
if (!Object.hasOwn(clonedData, field.key)) {
|
|
491
491
|
if (formatOnlyAvailiableKeys)
|
|
492
|
-
|
|
493
|
-
|
|
492
|
+
RETURN[field.key] = "undefined";
|
|
493
|
+
else
|
|
494
|
+
RETURN[field.key] = this.getDefaultValue(field);
|
|
494
495
|
continue;
|
|
495
496
|
}
|
|
496
497
|
if (Array.isArray(clonedData[field.key]) &&
|
|
@@ -551,8 +552,12 @@ export default class Inibase {
|
|
|
551
552
|
else if (Utils.isArrayOfArrays(value) &&
|
|
552
553
|
value.every(Utils.isArrayOfObjects))
|
|
553
554
|
Object.assign(RETURN, this._CombineData(this._combineObjectsToArray(value.map(this._combineObjectsToArray)), `${(prefix ?? "") + key}.`));
|
|
554
|
-
else
|
|
555
|
-
RETURN[(prefix ?? "") + key] = File.encode(value)
|
|
555
|
+
else if (value !== "undefined")
|
|
556
|
+
RETURN[(prefix ?? "") + key] = File.encode(Array.isArray(value)
|
|
557
|
+
? value.map((_value) => typeof _value === "string" && _value === "undefined"
|
|
558
|
+
? ""
|
|
559
|
+
: _value)
|
|
560
|
+
: value);
|
|
556
561
|
}
|
|
557
562
|
return RETURN;
|
|
558
563
|
}
|
|
@@ -1331,16 +1336,17 @@ export default class Inibase {
|
|
|
1331
1336
|
// "where" in this case, is the line(s) number(s) and not id(s)
|
|
1332
1337
|
await this.validateData(tableName, clonedData, true);
|
|
1333
1338
|
clonedData = this.formatData(clonedData, this.tablesMap.get(tableName).schema, true);
|
|
1334
|
-
const pathesContents = Object.fromEntries(Object.entries(this.joinPathesContents(tableName,
|
|
1339
|
+
const pathesContents = Object.fromEntries(Object.entries(this.joinPathesContents(tableName, Array.isArray(clonedData)
|
|
1335
1340
|
? clonedData.map((item) => ({
|
|
1336
1341
|
...item,
|
|
1337
1342
|
updatedAt: Date.now(),
|
|
1338
1343
|
}))
|
|
1339
1344
|
: { ...clonedData, updatedAt: Date.now() })).map(([path, content]) => [
|
|
1340
1345
|
path,
|
|
1341
|
-
|
|
1342
|
-
[lineNum]
|
|
1343
|
-
|
|
1346
|
+
(Array.isArray(where) ? where : [where]).reduce((obj, lineNum, index) => {
|
|
1347
|
+
obj[lineNum] = Array.isArray(content) ? content[index] : content;
|
|
1348
|
+
return obj;
|
|
1349
|
+
}, {}),
|
|
1344
1350
|
]));
|
|
1345
1351
|
const keys = UtilsServer.hashString(Object.keys(pathesContents)
|
|
1346
1352
|
.map((path) => path.replaceAll(this.getFileExtension(tableName), ""))
|