inibase 1.0.0-rc.117 → 1.0.0-rc.119
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 -0
- package/dist/index.js +19 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -61,7 +61,13 @@ export default class Inibase {
|
|
|
61
61
|
: errorMessage.replaceAll("{variable}", `'${variable.toString()}'`)
|
|
62
62
|
: errorMessage.replaceAll("{variable}", ""));
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
clear() {
|
|
65
|
+
this.tables = {};
|
|
66
|
+
this.totalItems = {};
|
|
67
|
+
this.pageInfo = {};
|
|
68
|
+
this.checkIFunique = {};
|
|
69
|
+
}
|
|
70
|
+
getFileExtension(tableName) {
|
|
65
71
|
let mainExtension = this.fileExtension;
|
|
66
72
|
// TODO: ADD ENCRYPTION
|
|
67
73
|
// if(this.tables[tableName].config.encryption)
|
|
@@ -69,19 +75,20 @@ export default class Inibase {
|
|
|
69
75
|
if (this.tables[tableName].config.compression)
|
|
70
76
|
mainExtension += ".gz";
|
|
71
77
|
return mainExtension;
|
|
72
|
-
}
|
|
73
|
-
_schemaToIdsPath
|
|
78
|
+
}
|
|
79
|
+
_schemaToIdsPath(tableName, schema, prefix = "") {
|
|
74
80
|
const RETURN = {};
|
|
75
81
|
for (const field of schema)
|
|
76
82
|
if ((field.type === "array" || field.type === "object") &&
|
|
77
83
|
field.children &&
|
|
78
|
-
Utils.isArrayOfObjects(field.children))
|
|
84
|
+
Utils.isArrayOfObjects(field.children))
|
|
79
85
|
Utils.deepMerge(RETURN, this._schemaToIdsPath(tableName, field.children, `${(prefix ?? "") + field.key}.`));
|
|
80
|
-
}
|
|
81
86
|
else if (field.id)
|
|
82
|
-
RETURN[
|
|
87
|
+
RETURN[Utils.isValidID(field.id)
|
|
88
|
+
? UtilsServer.decodeID(field.id, this.salt)
|
|
89
|
+
: field.id] = `${(prefix ?? "") + field.key}${this.getFileExtension(tableName)}`;
|
|
83
90
|
return RETURN;
|
|
84
|
-
}
|
|
91
|
+
}
|
|
85
92
|
/**
|
|
86
93
|
* Create a new table inside database, with predefined schema and config
|
|
87
94
|
*
|
|
@@ -594,18 +601,16 @@ export default class Inibase {
|
|
|
594
601
|
}
|
|
595
602
|
else {
|
|
596
603
|
// Handling array of objects and filtering nested arrays
|
|
597
|
-
const nestedArrayFields = field.children.filter((
|
|
598
|
-
Utils.isArrayOfObjects(
|
|
604
|
+
const nestedArrayFields = field.children.filter((children) => children.type === "array" &&
|
|
605
|
+
Utils.isArrayOfObjects(children.children));
|
|
599
606
|
if (nestedArrayFields.length > 0) {
|
|
600
607
|
// one of children has array field type and has children array of object = Schema
|
|
601
|
-
const childItems = await this.processSchemaData(tableName,
|
|
602
|
-
Utils.isArrayOfObjects(children.children)), linesNumber, options, `${(prefix ?? "") + field.key}.`);
|
|
608
|
+
const childItems = await this.processSchemaData(tableName, nestedArrayFields, linesNumber, options, `${(prefix ?? "") + field.key}.`);
|
|
603
609
|
if (childItems)
|
|
604
610
|
for (const [index, item] of Object.entries(childItems))
|
|
605
611
|
this._processSchemaDataHelper(RETURN, item, index, field);
|
|
606
612
|
// Remove nested arrays after processing
|
|
607
|
-
field.children = field.children.filter((
|
|
608
|
-
Utils.isArrayOfObjects(child.children));
|
|
613
|
+
field.children = field.children.filter((children) => !nestedArrayFields.map(({ key }) => key).includes(children.key));
|
|
609
614
|
}
|
|
610
615
|
// Process remaining items for the field's children
|
|
611
616
|
const items = await this.processSchemaData(tableName, field.children, linesNumber, options, `${(prefix ?? "") + field.key}.`);
|
|
@@ -630,7 +635,7 @@ export default class Inibase {
|
|
|
630
635
|
[key]: value[_index],
|
|
631
636
|
};
|
|
632
637
|
});
|
|
633
|
-
else if (Object.values(item).every((_i) => Utils.isArrayOfArrays(_i)
|
|
638
|
+
else if (Object.values(item).every((_i) => Utils.isArrayOfArrays(_i)) &&
|
|
634
639
|
prefix)
|
|
635
640
|
RETURN[index][field.key] = item;
|
|
636
641
|
else {
|