inibase 1.0.0-rc.123 → 1.0.0-rc.124

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 CHANGED
@@ -99,7 +99,6 @@ export default class Inibase {
99
99
  private cleanObject;
100
100
  private formatField;
101
101
  private checkUnique;
102
- private _formatData;
103
102
  private formatData;
104
103
  private getDefaultValue;
105
104
  private _combineObjectsToArray;
package/dist/index.js CHANGED
@@ -381,13 +381,13 @@ export default class Inibase {
381
381
  if (!Array.isArray(value))
382
382
  value = [value];
383
383
  if (Utils.isArrayOfObjects(fieldChildrenType))
384
- return this._formatData(value, fieldChildrenType);
384
+ return this.formatData(value, fieldChildrenType);
385
385
  if (!value.length)
386
386
  return null;
387
387
  return value.map((_value) => this.formatField(_value, fieldChildrenType));
388
388
  case "object":
389
389
  if (Utils.isArrayOfObjects(fieldChildrenType))
390
- return this._formatData(value, fieldChildrenType, _formatOnlyAvailiableKeys);
390
+ return this.formatData(value, fieldChildrenType, _formatOnlyAvailiableKeys);
391
391
  break;
392
392
  case "table":
393
393
  if (Utils.isObject(value)) {
@@ -452,10 +452,10 @@ export default class Inibase {
452
452
  }
453
453
  this.uniqueMap = new Map();
454
454
  }
455
- _formatData(data, schema, formatOnlyAvailiableKeys) {
455
+ formatData(data, schema, formatOnlyAvailiableKeys) {
456
456
  const clonedData = JSON.parse(JSON.stringify(data));
457
457
  if (Utils.isArrayOfObjects(clonedData))
458
- return clonedData.map((singleData) => this._formatData(singleData, schema, formatOnlyAvailiableKeys));
458
+ return clonedData.map((singleData) => this.formatData(singleData, schema, formatOnlyAvailiableKeys));
459
459
  if (Utils.isObject(clonedData)) {
460
460
  const RETURN = {};
461
461
  for (const field of schema) {
@@ -471,9 +471,6 @@ export default class Inibase {
471
471
  }
472
472
  return [];
473
473
  }
474
- formatData(tableName, data, formatOnlyAvailiableKeys) {
475
- data = this._formatData(data, this.tablesMap.get(tableName).schema, formatOnlyAvailiableKeys);
476
- }
477
474
  getDefaultValue(field) {
478
475
  if (Array.isArray(field.type))
479
476
  return this.getDefaultValue({
@@ -1192,7 +1189,7 @@ export default class Inibase {
1192
1189
  data.createdAt = Date.now();
1193
1190
  data.updatedAt = undefined;
1194
1191
  }
1195
- this.formatData(tableName, data);
1192
+ data = this.formatData(data, this.tablesMap.get(tableName).schema, true);
1196
1193
  const pathesContents = this.joinPathesContents(tableName, this.tablesMap.get(tableName).config.prepend
1197
1194
  ? Array.isArray(data)
1198
1195
  ? data.toReversed()
@@ -1245,7 +1242,7 @@ export default class Inibase {
1245
1242
  return this.put(tableName, data, data.id, options, returnUpdatedData || undefined);
1246
1243
  }
1247
1244
  await this.validateData(tableName, data, true);
1248
- this.formatData(tableName, data, true);
1245
+ data = this.formatData(data, this.tablesMap.get(tableName).schema, true);
1249
1246
  const pathesContents = this.joinPathesContents(tableName, {
1250
1247
  ...(({ id, ...restOfData }) => restOfData)(data),
1251
1248
  updatedAt: Date.now(),
@@ -1280,7 +1277,7 @@ export default class Inibase {
1280
1277
  Utils.isNumber(where)) {
1281
1278
  // "where" in this case, is the line(s) number(s) and not id(s)
1282
1279
  await this.validateData(tableName, data, true);
1283
- this.formatData(tableName, data, true);
1280
+ data = this.formatData(data, this.tablesMap.get(tableName).schema, true);
1284
1281
  const pathesContents = Object.fromEntries(Object.entries(this.joinPathesContents(tableName, Utils.isArrayOfObjects(data)
1285
1282
  ? data.map((item) => ({
1286
1283
  ...item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.0.0-rc.123",
3
+ "version": "1.0.0-rc.124",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Karim Amahtil",