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 +2 -4
- package/dist/index.js +16 -17
- package/dist/utils.js +20 -18
- package/dist/utils.server.js +1 -1
- package/package.json +1 -1
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
|
|
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
|
|
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 (
|
|
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
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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 (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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";
|
package/dist/utils.server.js
CHANGED
|
@@ -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
|
|
220
|
+
return originalValue == comparedAtValue;
|
|
221
221
|
}
|
|
222
222
|
};
|
|
223
223
|
/**
|