@epam/uui-db 5.1.0 → 5.1.2-alpha.0
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 +21 -16
- package/index.esm.js.map +1 -1
- package/index.js +21 -16
- 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 +90 -1429
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(
|
|
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(
|
|
84
|
+
return changes(obj, baseObj);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
class Db {
|
|
@@ -166,7 +166,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
166
166
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
167
167
|
PERFORMANCE OF THIS SOFTWARE.
|
|
168
168
|
***************************************************************************** */
|
|
169
|
-
/* global Reflect, Promise */
|
|
169
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
function __rest(s, e) {
|
|
@@ -189,7 +189,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
189
189
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
190
190
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
191
191
|
});
|
|
192
|
-
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
195
|
+
var e = new Error(message);
|
|
196
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
197
|
+
};
|
|
193
198
|
|
|
194
199
|
class DbTable {
|
|
195
200
|
constructor(schema, state, q) {
|
|
@@ -408,14 +413,14 @@ function mergeEntityPatches(tables, patch) {
|
|
|
408
413
|
const table = tables[key];
|
|
409
414
|
const groupedEntities = groupBy__default.default(patch[key], (item) => table.getId(item));
|
|
410
415
|
const tablePatch = map__default.default(groupedEntities, (entities) => {
|
|
411
|
-
const
|
|
416
|
+
const tablePatchResult = merge__default.default({}, ...entities);
|
|
412
417
|
if (process.env.NODE_ENV !== 'production') {
|
|
413
|
-
const props = objectKeys(
|
|
418
|
+
const props = objectKeys(tablePatchResult).filter((prop) => Object.keys(countBy__default.default(entities.filter((entity) => entity[prop] !== undefined), (entity) => entity[prop])).length > 1);
|
|
414
419
|
if (props.length) {
|
|
415
420
|
console.warn('mergeEntityPatches: Different property values found for the same entity.\nProperty names:\n', props, '\nEntities:\n', ...entities);
|
|
416
421
|
}
|
|
417
422
|
}
|
|
418
|
-
return
|
|
423
|
+
return tablePatchResult;
|
|
419
424
|
});
|
|
420
425
|
result[key] = tablePatch;
|
|
421
426
|
});
|
|
@@ -458,7 +463,7 @@ function flattenResponse(response, tables) {
|
|
|
458
463
|
const result = {};
|
|
459
464
|
const tablesByTypeName = {};
|
|
460
465
|
Object.values(tables).forEach((table) => (tablesByTypeName[table.schema.typeName] = table));
|
|
461
|
-
objectKeys(tables).forEach((
|
|
466
|
+
objectKeys(tables).forEach(() => tablesByTypeName);
|
|
462
467
|
objectKeys(tables).forEach((key) => (result[key] = []));
|
|
463
468
|
flattenResponseHelper(result, response, tablesByTypeName);
|
|
464
469
|
return result;
|
|
@@ -665,7 +670,7 @@ class TempIdMap {
|
|
|
665
670
|
}
|
|
666
671
|
entityPatch[fieldName] = clientId;
|
|
667
672
|
});
|
|
668
|
-
this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch
|
|
673
|
+
this.mapFields(patch, (f) => !!(f.fk || f.default != null || f.toClient), (fieldName, fieldSchema, fieldValue, entityPatch) => {
|
|
669
674
|
let isUndefined = typeof fieldValue === 'undefined';
|
|
670
675
|
if (fieldSchema.default != null && fieldValue == null) {
|
|
671
676
|
fieldValue = fieldSchema.default;
|
|
@@ -692,7 +697,7 @@ class TempIdMap {
|
|
|
692
697
|
}
|
|
693
698
|
clientToServerPatch(patch) {
|
|
694
699
|
patch = this.copyPatch(patch);
|
|
695
|
-
this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch
|
|
700
|
+
this.mapFields(patch, (f) => f.isGenerated || !!f.fk, (fieldName, fieldSchema, fieldValue, entityPatch) => {
|
|
696
701
|
if (fieldValue != null) {
|
|
697
702
|
const existingId = this.clientToServerIds.get(fieldValue);
|
|
698
703
|
if (existingId) {
|
|
@@ -700,10 +705,10 @@ class TempIdMap {
|
|
|
700
705
|
}
|
|
701
706
|
}
|
|
702
707
|
});
|
|
703
|
-
this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema,
|
|
708
|
+
this.mapFields(patch, (f) => !(f.isClientOnly || f.isReadOnly) && !!f.toServer, (fieldName, fieldSchema, _, entityPatch) => {
|
|
704
709
|
entityPatch[fieldName] = fieldSchema.toServer(entityPatch[fieldName]);
|
|
705
710
|
});
|
|
706
|
-
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName,
|
|
711
|
+
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName, _, __, entityPatch) => {
|
|
707
712
|
delete entityPatch[fieldName];
|
|
708
713
|
});
|
|
709
714
|
return patch;
|
|
@@ -1043,9 +1048,9 @@ class DbRef {
|
|
|
1043
1048
|
subscribe(view, params, onUpdate) {
|
|
1044
1049
|
const id = this.lastSubscriptionId++;
|
|
1045
1050
|
const subscription = {
|
|
1046
|
-
update: (
|
|
1047
|
-
subscription.currentParams =
|
|
1048
|
-
subscription.currentValue = this.db.runView(view,
|
|
1051
|
+
update: (subscriptionParams) => {
|
|
1052
|
+
subscription.currentParams = subscriptionParams;
|
|
1053
|
+
subscription.currentValue = this.db.runView(view, subscriptionParams);
|
|
1049
1054
|
return subscription.currentValue;
|
|
1050
1055
|
},
|
|
1051
1056
|
currentParams: null,
|