@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.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 {
|
|
@@ -131,7 +131,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
131
131
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
132
132
|
PERFORMANCE OF THIS SOFTWARE.
|
|
133
133
|
***************************************************************************** */
|
|
134
|
-
/* global Reflect, Promise */
|
|
134
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
function __rest(s, e) {
|
|
@@ -154,7 +154,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
154
154
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
155
155
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
156
156
|
});
|
|
157
|
-
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
160
|
+
var e = new Error(message);
|
|
161
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
162
|
+
};
|
|
158
163
|
|
|
159
164
|
class DbTable {
|
|
160
165
|
constructor(schema, state, q) {
|
|
@@ -373,14 +378,14 @@ function mergeEntityPatches(tables, patch) {
|
|
|
373
378
|
const table = tables[key];
|
|
374
379
|
const groupedEntities = groupBy(patch[key], (item) => table.getId(item));
|
|
375
380
|
const tablePatch = map(groupedEntities, (entities) => {
|
|
376
|
-
const
|
|
381
|
+
const tablePatchResult = merge({}, ...entities);
|
|
377
382
|
if (process.env.NODE_ENV !== 'production') {
|
|
378
|
-
const props = objectKeys(
|
|
383
|
+
const props = objectKeys(tablePatchResult).filter((prop) => Object.keys(countBy(entities.filter((entity) => entity[prop] !== undefined), (entity) => entity[prop])).length > 1);
|
|
379
384
|
if (props.length) {
|
|
380
385
|
console.warn('mergeEntityPatches: Different property values found for the same entity.\nProperty names:\n', props, '\nEntities:\n', ...entities);
|
|
381
386
|
}
|
|
382
387
|
}
|
|
383
|
-
return
|
|
388
|
+
return tablePatchResult;
|
|
384
389
|
});
|
|
385
390
|
result[key] = tablePatch;
|
|
386
391
|
});
|
|
@@ -423,7 +428,7 @@ function flattenResponse(response, tables) {
|
|
|
423
428
|
const result = {};
|
|
424
429
|
const tablesByTypeName = {};
|
|
425
430
|
Object.values(tables).forEach((table) => (tablesByTypeName[table.schema.typeName] = table));
|
|
426
|
-
objectKeys(tables).forEach((
|
|
431
|
+
objectKeys(tables).forEach(() => tablesByTypeName);
|
|
427
432
|
objectKeys(tables).forEach((key) => (result[key] = []));
|
|
428
433
|
flattenResponseHelper(result, response, tablesByTypeName);
|
|
429
434
|
return result;
|
|
@@ -630,7 +635,7 @@ class TempIdMap {
|
|
|
630
635
|
}
|
|
631
636
|
entityPatch[fieldName] = clientId;
|
|
632
637
|
});
|
|
633
|
-
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) => {
|
|
634
639
|
let isUndefined = typeof fieldValue === 'undefined';
|
|
635
640
|
if (fieldSchema.default != null && fieldValue == null) {
|
|
636
641
|
fieldValue = fieldSchema.default;
|
|
@@ -657,7 +662,7 @@ class TempIdMap {
|
|
|
657
662
|
}
|
|
658
663
|
clientToServerPatch(patch) {
|
|
659
664
|
patch = this.copyPatch(patch);
|
|
660
|
-
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) => {
|
|
661
666
|
if (fieldValue != null) {
|
|
662
667
|
const existingId = this.clientToServerIds.get(fieldValue);
|
|
663
668
|
if (existingId) {
|
|
@@ -665,10 +670,10 @@ class TempIdMap {
|
|
|
665
670
|
}
|
|
666
671
|
}
|
|
667
672
|
});
|
|
668
|
-
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) => {
|
|
669
674
|
entityPatch[fieldName] = fieldSchema.toServer(entityPatch[fieldName]);
|
|
670
675
|
});
|
|
671
|
-
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName,
|
|
676
|
+
this.mapFields(patch, (meta) => meta.isClientOnly || meta.isReadOnly, (fieldName, _, __, entityPatch) => {
|
|
672
677
|
delete entityPatch[fieldName];
|
|
673
678
|
});
|
|
674
679
|
return patch;
|
|
@@ -1008,9 +1013,9 @@ class DbRef {
|
|
|
1008
1013
|
subscribe(view, params, onUpdate) {
|
|
1009
1014
|
const id = this.lastSubscriptionId++;
|
|
1010
1015
|
const subscription = {
|
|
1011
|
-
update: (
|
|
1012
|
-
subscription.currentParams =
|
|
1013
|
-
subscription.currentValue = this.db.runView(view,
|
|
1016
|
+
update: (subscriptionParams) => {
|
|
1017
|
+
subscription.currentParams = subscriptionParams;
|
|
1018
|
+
subscription.currentValue = this.db.runView(view, subscriptionParams);
|
|
1014
1019
|
return subscription.currentValue;
|
|
1015
1020
|
},
|
|
1016
1021
|
currentParams: null,
|