@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.js CHANGED
@@ -73,15 +73,15 @@ function defaultCompareViewDependencies(prev, next) {
73
73
  * @param {Object} base Object to compare with
74
74
  * @return {Object} Return a new object who represent the diff
75
75
  */
76
- function difference(object, base) {
76
+ function difference(obj, baseObj) {
77
77
  function changes(object, base) {
78
78
  return transform__default.default(object, function (result, value, key) {
79
79
  if (!isEqual__default.default(value, base[key])) {
80
- result[key] = typeof value === 'object' && typeof base[key] === 'object' ? changes(value, base[key]) : value;
80
+ result[key] = (typeof value === 'object' && typeof base[key] === 'object') ? changes(value, base[key]) : value;
81
81
  }
82
82
  });
83
83
  }
84
- return changes(object, base);
84
+ return changes(obj, baseObj);
85
85
  }
86
86
 
87
87
  class Db {
@@ -413,14 +413,14 @@ function mergeEntityPatches(tables, patch) {
413
413
  const table = tables[key];
414
414
  const groupedEntities = groupBy__default.default(patch[key], (item) => table.getId(item));
415
415
  const tablePatch = map__default.default(groupedEntities, (entities) => {
416
- const result = merge__default.default({}, ...entities);
416
+ const tablePatchResult = merge__default.default({}, ...entities);
417
417
  if (process.env.NODE_ENV !== 'production') {
418
- const props = objectKeys(result).filter((prop) => Object.keys(countBy__default.default(entities.filter((entity) => entity[prop] !== undefined), (entity) => entity[prop])).length > 1);
418
+ const props = objectKeys(tablePatchResult).filter((prop) => Object.keys(countBy__default.default(entities.filter((entity) => entity[prop] !== undefined), (entity) => entity[prop])).length > 1);
419
419
  if (props.length) {
420
420
  console.warn('mergeEntityPatches: Different property values found for the same entity.\nProperty names:\n', props, '\nEntities:\n', ...entities);
421
421
  }
422
422
  }
423
- return result;
423
+ return tablePatchResult;
424
424
  });
425
425
  result[key] = tablePatch;
426
426
  });
@@ -463,7 +463,7 @@ function flattenResponse(response, tables) {
463
463
  const result = {};
464
464
  const tablesByTypeName = {};
465
465
  Object.values(tables).forEach((table) => (tablesByTypeName[table.schema.typeName] = table));
466
- objectKeys(tables).forEach((tableName) => tablesByTypeName);
466
+ objectKeys(tables).forEach(() => tablesByTypeName);
467
467
  objectKeys(tables).forEach((key) => (result[key] = []));
468
468
  flattenResponseHelper(result, response, tablesByTypeName);
469
469
  return result;
@@ -670,7 +670,7 @@ class TempIdMap {
670
670
  }
671
671
  entityPatch[fieldName] = clientId;
672
672
  });
673
- this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch, tableName) => {
673
+ this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch) => {
674
674
  let isUndefined = typeof fieldValue === 'undefined';
675
675
  if (fieldSchema.default != null && fieldValue == null) {
676
676
  fieldValue = fieldSchema.default;
@@ -697,7 +697,7 @@ class TempIdMap {
697
697
  }
698
698
  clientToServerPatch(patch) {
699
699
  patch = this.copyPatch(patch);
700
- this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch, tableName) => {
700
+ this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch) => {
701
701
  if (fieldValue != null) {
702
702
  const existingId = this.clientToServerIds.get(fieldValue);
703
703
  if (existingId) {
@@ -705,10 +705,10 @@ class TempIdMap {
705
705
  }
706
706
  }
707
707
  });
708
- this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema, fieldValue, entityPatch, tableName) => {
708
+ this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema, _, entityPatch) => {
709
709
  entityPatch[fieldName] = fieldSchema.toServer(entityPatch[fieldName]);
710
710
  });
711
- this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName, fieldSchema, fieldValue, entityPatch, tableName) => {
711
+ this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName, _, __, entityPatch) => {
712
712
  delete entityPatch[fieldName];
713
713
  });
714
714
  return patch;
@@ -1048,9 +1048,9 @@ class DbRef {
1048
1048
  subscribe(view, params, onUpdate) {
1049
1049
  const id = this.lastSubscriptionId++;
1050
1050
  const subscription = {
1051
- update: (params) => {
1052
- subscription.currentParams = params;
1053
- subscription.currentValue = this.db.runView(view, params);
1051
+ update: (subscriptionParams) => {
1052
+ subscription.currentParams = subscriptionParams;
1053
+ subscription.currentValue = this.db.runView(view, subscriptionParams);
1054
1054
  return subscription.currentValue;
1055
1055
  },
1056
1056
  currentParams: null,