inibase 1.0.0-rc.52 → 1.0.0-rc.54

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
@@ -57,7 +57,7 @@ export default class Inibase {
57
57
  private _schemaToIdsPath;
58
58
  setTableSchema(tableName: string, schema: Schema): Promise<void>;
59
59
  getTableSchema(tableName: string, encodeIDs?: boolean): Promise<Schema | undefined>;
60
- getSchemaWhenTableNotEmpty(tableName: string, schema?: Schema): Promise<never | Schema>;
60
+ private getSchemaWhenTableNotEmpty;
61
61
  private validateData;
62
62
  private formatField;
63
63
  private checkUnique;
@@ -66,9 +66,7 @@ export default class Inibase {
66
66
  private _combineObjectsToArray;
67
67
  private _CombineData;
68
68
  private _addPathToKeys;
69
- joinPathesContents(mainPath: string, data: Data | Data[]): {
70
- [key: string]: string[];
71
- };
69
+ private joinPathesContents;
72
70
  private _getItemsFromSchemaHelper;
73
71
  private getItemsFromSchema;
74
72
  private applyCriteria;
package/dist/index.js CHANGED
@@ -343,29 +343,28 @@ export default class Inibase {
343
343
  }
344
344
  _combineObjectsToArray = (input) => input.reduce((result, current) => {
345
345
  for (const [key, value] of Object.entries(current))
346
- if (!result[key])
347
- result[key] = [value];
348
- else
346
+ if (Object.hasOwn(result, key) && Array.isArray(result[key]))
349
347
  result[key].push(value);
348
+ else
349
+ result[key] = [value];
350
350
  return result;
351
351
  }, {});
352
352
  _CombineData = (data, prefix) => {
353
- let RETURN = {};
354
353
  if (Utils.isArrayOfObjects(data))
355
- RETURN = this._combineObjectsToArray(data.map((single_data) => this._CombineData(single_data)));
356
- else
357
- for (const [key, value] of Object.entries(data)) {
358
- if (Utils.isObject(value))
359
- Object.assign(RETURN, this._CombineData(value, `${key}.`));
360
- else if (Utils.isArrayOfObjects(value)) {
361
- Object.assign(RETURN, this._CombineData(this._combineObjectsToArray(value), `${(prefix ?? "") + key}.`));
362
- }
363
- else if (Utils.isArrayOfArrays(value) &&
364
- value.every(Utils.isArrayOfObjects))
365
- Object.assign(RETURN, this._CombineData(this._combineObjectsToArray(value.map(this._combineObjectsToArray)), `${(prefix ?? "") + key}.`));
366
- else
367
- RETURN[(prefix ?? "") + key] = File.encode(value);
354
+ return this._combineObjectsToArray(data.map((single_data) => this._CombineData(single_data)));
355
+ const RETURN = {};
356
+ for (const [key, value] of Object.entries(data)) {
357
+ if (Utils.isObject(value))
358
+ Object.assign(RETURN, this._CombineData(value, `${key}.`));
359
+ else if (Utils.isArrayOfObjects(value)) {
360
+ Object.assign(RETURN, this._CombineData(this._combineObjectsToArray(value), `${(prefix ?? "") + key}.`));
368
361
  }
362
+ else if (Utils.isArrayOfArrays(value) &&
363
+ value.every(Utils.isArrayOfObjects))
364
+ Object.assign(RETURN, this._CombineData(this._combineObjectsToArray(value.map(this._combineObjectsToArray)), `${(prefix ?? "") + key}.`));
365
+ else
366
+ RETURN[(prefix ?? "") + key] = File.encode(value);
367
+ }
369
368
  return RETURN;
370
369
  };
371
370
  _addPathToKeys = (obj, path) => {
package/dist/utils.js CHANGED
@@ -253,24 +253,26 @@ export const detectFieldType = (input, availableTypes) => {
253
253
  if (availableTypes.includes("number"))
254
254
  return "number";
255
255
  }
256
- else if (availableTypes.includes("table") && isValidID(input))
257
- return "table";
258
- else if (input.startsWith("[") && availableTypes.includes("array"))
259
- return "array";
260
- else if (availableTypes.includes("email") && isEmail(input))
261
- return "email";
262
- else if (availableTypes.includes("url") && isURL(input))
263
- return "url";
264
- else if (availableTypes.includes("password") && isPassword(input))
265
- return "password";
266
- else if (availableTypes.includes("json") && isJSON(input))
267
- return "json";
268
- else if (availableTypes.includes("json") && isDate(input))
269
- return "json";
270
- else if (availableTypes.includes("string") && isString(input))
271
- return "string";
272
- else if (availableTypes.includes("ip") && isIP(input))
273
- return "ip";
256
+ else if (typeof input === "string") {
257
+ if (availableTypes.includes("table") && isValidID(input))
258
+ return "table";
259
+ if (input.startsWith("[") && availableTypes.includes("array"))
260
+ return "array";
261
+ if (availableTypes.includes("email") && isEmail(input))
262
+ return "email";
263
+ if (availableTypes.includes("url") && isURL(input))
264
+ return "url";
265
+ if (availableTypes.includes("password") && isPassword(input))
266
+ return "password";
267
+ if (availableTypes.includes("json") && isJSON(input))
268
+ return "json";
269
+ if (availableTypes.includes("json") && isDate(input))
270
+ return "json";
271
+ if (availableTypes.includes("string") && isString(input))
272
+ return "string";
273
+ if (availableTypes.includes("ip") && isIP(input))
274
+ return "ip";
275
+ }
274
276
  }
275
277
  else
276
278
  return "array";
@@ -217,7 +217,7 @@ export const isEqual = (originalValue, comparedAtValue, fieldType) => {
217
217
  return Number(originalValue) === Number(comparedAtValue);
218
218
  // Default comparison.
219
219
  default:
220
- return originalValue === comparedAtValue;
220
+ return originalValue == comparedAtValue;
221
221
  }
222
222
  };
223
223
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inibase",
3
- "version": "1.0.0-rc.52",
3
+ "version": "1.0.0-rc.54",
4
4
  "author": {
5
5
  "name": "Karim Amahtil",
6
6
  "email": "karim.amahtil@gmail.com"