@epam/uui-db 5.1.1 → 5.1.2
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/index.esm.js +14 -14
- package/index.esm.js.map +1 -1
- package/index.js +14 -14
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/DbTable.d.ts +4 -4
- package/src/DbTable.d.ts.map +1 -1
- package/src/tempIds.d.ts.map +1 -1
- package/src/utils.d.ts +1 -1
- package/src/utils.d.ts.map +1 -1
- package/stats.html +1 -1
package/index.esm.js
CHANGED
|
@@ -38,15 +38,15 @@ function defaultCompareViewDependencies(prev, next) {
|
|
|
38
38
|
* @param {Object} base Object to compare with
|
|
39
39
|
* @return {Object} Return a new object who represent the diff
|
|
40
40
|
*/
|
|
41
|
-
function difference(
|
|
41
|
+
function difference(obj, baseObj) {
|
|
42
42
|
function changes(object, base) {
|
|
43
43
|
return transform(object, function (result, value, key) {
|
|
44
44
|
if (!isEqual(value, base[key])) {
|
|
45
|
-
result[key] = typeof value === 'object' && typeof base[key] === 'object' ? changes(value, base[key]) : value;
|
|
45
|
+
result[key] = (typeof value === 'object' && typeof base[key] === 'object') ? changes(value, base[key]) : value;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
return changes(
|
|
49
|
+
return changes(obj, baseObj);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
class Db {
|
|
@@ -378,14 +378,14 @@ function mergeEntityPatches(tables, patch) {
|
|
|
378
378
|
const table = tables[key];
|
|
379
379
|
const groupedEntities = groupBy(patch[key], (item) => table.getId(item));
|
|
380
380
|
const tablePatch = map(groupedEntities, (entities) => {
|
|
381
|
-
const
|
|
381
|
+
const tablePatchResult = merge({}, ...entities);
|
|
382
382
|
if (process.env.NODE_ENV !== 'production') {
|
|
383
|
-
const props = objectKeys(
|
|
383
|
+
const props = objectKeys(tablePatchResult).filter((prop) => Object.keys(countBy(entities.filter((entity) => entity[prop] !== undefined), (entity) => entity[prop])).length > 1);
|
|
384
384
|
if (props.length) {
|
|
385
385
|
console.warn('mergeEntityPatches: Different property values found for the same entity.\nProperty names:\n', props, '\nEntities:\n', ...entities);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
return
|
|
388
|
+
return tablePatchResult;
|
|
389
389
|
});
|
|
390
390
|
result[key] = tablePatch;
|
|
391
391
|
});
|
|
@@ -428,7 +428,7 @@ function flattenResponse(response, tables) {
|
|
|
428
428
|
const result = {};
|
|
429
429
|
const tablesByTypeName = {};
|
|
430
430
|
Object.values(tables).forEach((table) => (tablesByTypeName[table.schema.typeName] = table));
|
|
431
|
-
objectKeys(tables).forEach((
|
|
431
|
+
objectKeys(tables).forEach(() => tablesByTypeName);
|
|
432
432
|
objectKeys(tables).forEach((key) => (result[key] = []));
|
|
433
433
|
flattenResponseHelper(result, response, tablesByTypeName);
|
|
434
434
|
return result;
|
|
@@ -635,7 +635,7 @@ class TempIdMap {
|
|
|
635
635
|
}
|
|
636
636
|
entityPatch[fieldName] = clientId;
|
|
637
637
|
});
|
|
638
|
-
this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch
|
|
638
|
+
this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch) => {
|
|
639
639
|
let isUndefined = typeof fieldValue === 'undefined';
|
|
640
640
|
if (fieldSchema.default != null && fieldValue == null) {
|
|
641
641
|
fieldValue = fieldSchema.default;
|
|
@@ -662,7 +662,7 @@ class TempIdMap {
|
|
|
662
662
|
}
|
|
663
663
|
clientToServerPatch(patch) {
|
|
664
664
|
patch = this.copyPatch(patch);
|
|
665
|
-
this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch
|
|
665
|
+
this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch) => {
|
|
666
666
|
if (fieldValue != null) {
|
|
667
667
|
const existingId = this.clientToServerIds.get(fieldValue);
|
|
668
668
|
if (existingId) {
|
|
@@ -670,10 +670,10 @@ class TempIdMap {
|
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
672
|
});
|
|
673
|
-
this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema,
|
|
673
|
+
this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema, _, entityPatch) => {
|
|
674
674
|
entityPatch[fieldName] = fieldSchema.toServer(entityPatch[fieldName]);
|
|
675
675
|
});
|
|
676
|
-
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName,
|
|
676
|
+
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName, _, __, entityPatch) => {
|
|
677
677
|
delete entityPatch[fieldName];
|
|
678
678
|
});
|
|
679
679
|
return patch;
|
|
@@ -1013,9 +1013,9 @@ class DbRef {
|
|
|
1013
1013
|
subscribe(view, params, onUpdate) {
|
|
1014
1014
|
const id = this.lastSubscriptionId++;
|
|
1015
1015
|
const subscription = {
|
|
1016
|
-
update: (
|
|
1017
|
-
subscription.currentParams =
|
|
1018
|
-
subscription.currentValue = this.db.runView(view,
|
|
1016
|
+
update: (subscriptionParams) => {
|
|
1017
|
+
subscription.currentParams = subscriptionParams;
|
|
1018
|
+
subscription.currentValue = this.db.runView(view, subscriptionParams);
|
|
1019
1019
|
return subscription.currentValue;
|
|
1020
1020
|
},
|
|
1021
1021
|
currentParams: null,
|