@epam/uui-db 4.5.2 → 4.5.3
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/bundle-stats.json +1 -1
- package/index.js +134 -112
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -91,7 +91,7 @@ module.exports =
|
|
|
91
91
|
/*!******************************************!*\
|
|
92
92
|
!*** ../node_modules/tslib/tslib.es6.js ***!
|
|
93
93
|
\******************************************/
|
|
94
|
-
/*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
|
|
94
|
+
/*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
|
|
95
95
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
96
96
|
|
|
97
97
|
"use strict";
|
|
@@ -110,6 +110,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
110
110
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
|
|
111
111
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
|
|
112
112
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
|
|
113
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArray", function() { return __spreadArray; });
|
|
113
114
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
|
|
114
115
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
|
|
115
116
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
|
|
@@ -138,11 +139,13 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
138
139
|
var extendStatics = function(d, b) {
|
|
139
140
|
extendStatics = Object.setPrototypeOf ||
|
|
140
141
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
141
|
-
function (d, b) { for (var p in b) if (
|
|
142
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
142
143
|
return extendStatics(d, b);
|
|
143
144
|
};
|
|
144
145
|
|
|
145
146
|
function __extends(d, b) {
|
|
147
|
+
if (typeof b !== "function" && b !== null)
|
|
148
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
146
149
|
extendStatics(d, b);
|
|
147
150
|
function __() { this.constructor = d; }
|
|
148
151
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -224,13 +227,16 @@ function __generator(thisArg, body) {
|
|
|
224
227
|
}
|
|
225
228
|
}
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
var __createBinding = Object.create ? (function(o, m, k, k2) {
|
|
231
|
+
if (k2 === undefined) k2 = k;
|
|
232
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
233
|
+
}) : (function(o, m, k, k2) {
|
|
228
234
|
if (k2 === undefined) k2 = k;
|
|
229
235
|
o[k2] = m[k];
|
|
230
|
-
}
|
|
236
|
+
});
|
|
231
237
|
|
|
232
|
-
function __exportStar(m,
|
|
233
|
-
for (var p in m) if (p !== "default" && !
|
|
238
|
+
function __exportStar(m, o) {
|
|
239
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
function __values(o) {
|
|
@@ -262,19 +268,31 @@ function __read(o, n) {
|
|
|
262
268
|
return ar;
|
|
263
269
|
}
|
|
264
270
|
|
|
271
|
+
/** @deprecated */
|
|
265
272
|
function __spread() {
|
|
266
273
|
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
267
274
|
ar = ar.concat(__read(arguments[i]));
|
|
268
275
|
return ar;
|
|
269
276
|
}
|
|
270
277
|
|
|
278
|
+
/** @deprecated */
|
|
271
279
|
function __spreadArrays() {
|
|
272
280
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
273
281
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
274
282
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
275
283
|
r[k] = a[j];
|
|
276
284
|
return r;
|
|
277
|
-
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function __spreadArray(to, from, pack) {
|
|
288
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
289
|
+
if (ar || !(i in from)) {
|
|
290
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
291
|
+
ar[i] = from[i];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
295
|
+
}
|
|
278
296
|
|
|
279
297
|
function __await(v) {
|
|
280
298
|
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
@@ -311,11 +329,17 @@ function __makeTemplateObject(cooked, raw) {
|
|
|
311
329
|
return cooked;
|
|
312
330
|
};
|
|
313
331
|
|
|
332
|
+
var __setModuleDefault = Object.create ? (function(o, v) {
|
|
333
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
334
|
+
}) : function(o, v) {
|
|
335
|
+
o["default"] = v;
|
|
336
|
+
};
|
|
337
|
+
|
|
314
338
|
function __importStar(mod) {
|
|
315
339
|
if (mod && mod.__esModule) return mod;
|
|
316
340
|
var result = {};
|
|
317
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result
|
|
318
|
-
result
|
|
341
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
342
|
+
__setModuleDefault(result, mod);
|
|
319
343
|
return result;
|
|
320
344
|
}
|
|
321
345
|
|
|
@@ -323,19 +347,17 @@ function __importDefault(mod) {
|
|
|
323
347
|
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
324
348
|
}
|
|
325
349
|
|
|
326
|
-
function __classPrivateFieldGet(receiver,
|
|
327
|
-
if (!
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return privateMap.get(receiver);
|
|
350
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
351
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
352
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
353
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
331
354
|
}
|
|
332
355
|
|
|
333
|
-
function __classPrivateFieldSet(receiver,
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return value;
|
|
356
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
357
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
358
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
359
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
360
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
339
361
|
}
|
|
340
362
|
|
|
341
363
|
|
|
@@ -352,7 +374,7 @@ function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
|
352
374
|
|
|
353
375
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
354
376
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
355
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./src */ "./src/index.ts"), exports);
|
|
377
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./src */ "./src/index.ts"), exports);
|
|
356
378
|
|
|
357
379
|
|
|
358
380
|
/***/ }),
|
|
@@ -370,7 +392,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
370
392
|
exports.Db = void 0;
|
|
371
393
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
372
394
|
var utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
|
|
373
|
-
var lodash_isequal_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.isequal */ "lodash.isequal"));
|
|
395
|
+
var lodash_isequal_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.isequal */ "lodash.isequal"));
|
|
374
396
|
var Db = /** @class */ (function () {
|
|
375
397
|
function Db(tables, reusedCache) {
|
|
376
398
|
this.tables = tables;
|
|
@@ -385,13 +407,13 @@ var Db = /** @class */ (function () {
|
|
|
385
407
|
}
|
|
386
408
|
}
|
|
387
409
|
Db.prototype.update = function (mutate) {
|
|
388
|
-
var clone = new this.constructor(tslib_1.__assign({}, this.tables), this.viewCache);
|
|
410
|
+
var clone = new this.constructor((0, tslib_1.__assign)({}, this.tables), this.viewCache);
|
|
389
411
|
mutate(clone);
|
|
390
412
|
return clone;
|
|
391
413
|
};
|
|
392
414
|
Db.prototype.with = function (patch) {
|
|
393
415
|
return this.update(function (db) {
|
|
394
|
-
utils_1.objectKeys(db.tables).forEach(function (entityName) {
|
|
416
|
+
(0, utils_1.objectKeys)(db.tables).forEach(function (entityName) {
|
|
395
417
|
if (patch[entityName]) {
|
|
396
418
|
db.tables[entityName] = db.tables[entityName].with(patch[entityName]);
|
|
397
419
|
}
|
|
@@ -429,7 +451,7 @@ var Db = /** @class */ (function () {
|
|
|
429
451
|
var compareResults = view.compareResults || lodash_isequal_1.default;
|
|
430
452
|
if (!compareResults(previousValue, newValue)) {
|
|
431
453
|
if (view.traceDiff) {
|
|
432
|
-
console.debug(utils_1.difference(previousValue, newValue));
|
|
454
|
+
console.debug((0, utils_1.difference)(previousValue, newValue));
|
|
433
455
|
}
|
|
434
456
|
cacheItem.currentValue = newValue;
|
|
435
457
|
}
|
|
@@ -458,7 +480,7 @@ var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.
|
|
|
458
480
|
var patchHelpers_1 = __webpack_require__(/*! ./patchHelpers */ "./src/patchHelpers.ts");
|
|
459
481
|
var tempIds_1 = __webpack_require__(/*! ./tempIds */ "./src/tempIds.tsx");
|
|
460
482
|
var utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
|
|
461
|
-
var lodash_isempty_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.isempty */ "lodash.isempty"));
|
|
483
|
+
var lodash_isempty_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.isempty */ "lodash.isempty"));
|
|
462
484
|
var Loader_1 = __webpack_require__(/*! ./Loader */ "./src/Loader.ts");
|
|
463
485
|
var SimpleLoadingTracker_1 = __webpack_require__(/*! ./SimpleLoadingTracker */ "./src/SimpleLoadingTracker.ts");
|
|
464
486
|
var ListLoadingTracker_1 = __webpack_require__(/*! ./ListLoadingTracker */ "./src/ListLoadingTracker.ts");
|
|
@@ -517,7 +539,7 @@ var DbRef = /** @class */ (function () {
|
|
|
517
539
|
try {
|
|
518
540
|
var dbBeforeUpdate = this.db.with(patch);
|
|
519
541
|
patch = this.beforeUpdate(patch, dbBeforeUpdate.tables, this.db.tables);
|
|
520
|
-
patch = patchHelpers_1.mergeEntityPatches(this.db.tables, patch);
|
|
542
|
+
patch = (0, patchHelpers_1.mergeEntityPatches)(this.db.tables, patch);
|
|
521
543
|
this.log.push({ patch: patch });
|
|
522
544
|
this.db = this.db.with(patch);
|
|
523
545
|
this.autoSave && this.enqueueSave();
|
|
@@ -530,10 +552,10 @@ var DbRef = /** @class */ (function () {
|
|
|
530
552
|
DbRef.prototype.beforeUpdate = function (patch, tables, prevTables) {
|
|
531
553
|
var _this = this;
|
|
532
554
|
var patchAndDependencies = {};
|
|
533
|
-
utils_1.objectKeys(tables).filter(function (entityName) { return patch[entityName] && !tables[entityName].schema.beforeUpdate; }).forEach(function (entityName) {
|
|
555
|
+
(0, utils_1.objectKeys)(tables).filter(function (entityName) { return patch[entityName] && !tables[entityName].schema.beforeUpdate; }).forEach(function (entityName) {
|
|
534
556
|
patchAndDependencies[entityName] = patch[entityName];
|
|
535
557
|
});
|
|
536
|
-
utils_1.objectKeys(tables).filter(function (entityName) { return patch[entityName] && tables[entityName].schema.beforeUpdate; }).forEach(function (entityName) {
|
|
558
|
+
(0, utils_1.objectKeys)(tables).filter(function (entityName) { return patch[entityName] && tables[entityName].schema.beforeUpdate; }).forEach(function (entityName) {
|
|
537
559
|
var _a;
|
|
538
560
|
var schema = tables[entityName].schema;
|
|
539
561
|
var beforeUpdate = schema.beforeUpdate;
|
|
@@ -545,9 +567,9 @@ var DbRef = /** @class */ (function () {
|
|
|
545
567
|
};
|
|
546
568
|
var results = patch[entityName].map(function (e) { return beforeUpdate(e, context); });
|
|
547
569
|
var updatedPatch = (_a = {}, _a[entityName] = results.map(function (result) { return result.entity; }), _a);
|
|
548
|
-
var dependentEntityPatchesForUpdate = patchHelpers_1.unionPatches(results.filter(function (result) { return result.dependentEntities; }).map(function (result) { return result.dependentEntities; }));
|
|
570
|
+
var dependentEntityPatchesForUpdate = (0, patchHelpers_1.unionPatches)(results.filter(function (result) { return result.dependentEntities; }).map(function (result) { return result.dependentEntities; }));
|
|
549
571
|
var dependentEntityPatches = _this.beforeUpdate(dependentEntityPatchesForUpdate, tables, prevTables);
|
|
550
|
-
patchAndDependencies = patchHelpers_1.mergeEntityPatches(tables, patchHelpers_1.unionPatches([patchAndDependencies, updatedPatch, dependentEntityPatches]));
|
|
572
|
+
patchAndDependencies = (0, patchHelpers_1.mergeEntityPatches)(tables, (0, patchHelpers_1.unionPatches)([patchAndDependencies, updatedPatch, dependentEntityPatches]));
|
|
551
573
|
});
|
|
552
574
|
return patchAndDependencies;
|
|
553
575
|
};
|
|
@@ -566,7 +588,7 @@ var DbRef = /** @class */ (function () {
|
|
|
566
588
|
DbRef.prototype.makeCumulativePatch = function () {
|
|
567
589
|
var lastLogEntry = this.log.length;
|
|
568
590
|
var logEntriesToSave = this.log.slice(this.savedPoint, lastLogEntry);
|
|
569
|
-
var cumulativePatch = patchHelpers_1.makeCumulativePatch(this.db, logEntriesToSave.map(function (t) { return t.patch; }), this.tempIdMap);
|
|
591
|
+
var cumulativePatch = (0, patchHelpers_1.makeCumulativePatch)(this.db, logEntriesToSave.map(function (t) { return t.patch; }), this.tempIdMap);
|
|
570
592
|
cumulativePatch = this.tempIdMap.clientToServerPatch(cumulativePatch);
|
|
571
593
|
return cumulativePatch;
|
|
572
594
|
};
|
|
@@ -574,8 +596,8 @@ var DbRef = /** @class */ (function () {
|
|
|
574
596
|
var _this = this;
|
|
575
597
|
if (this.errors.length == 0) {
|
|
576
598
|
this.tempIdMap.appendServerMapping(response);
|
|
577
|
-
var serverPatch = patchHelpers_1.flattenResponse(response.submit, this.db.tables);
|
|
578
|
-
serverPatch = patchHelpers_1.mergeEntityPatches(this.db.tables, serverPatch);
|
|
599
|
+
var serverPatch = (0, patchHelpers_1.flattenResponse)(response.submit, this.db.tables);
|
|
600
|
+
serverPatch = (0, patchHelpers_1.mergeEntityPatches)(this.db.tables, serverPatch);
|
|
579
601
|
this.savedPoint = newSavedPoint;
|
|
580
602
|
this.base = this.db;
|
|
581
603
|
this.commitFetch(serverPatch);
|
|
@@ -636,7 +658,7 @@ var DbRef = /** @class */ (function () {
|
|
|
636
658
|
this.isSaveInProgress = true;
|
|
637
659
|
var lastLogEntry_1 = this.log.length;
|
|
638
660
|
var cumulativePatch_1 = this.makeCumulativePatch();
|
|
639
|
-
if (lodash_isempty_1.default(cumulativePatch_1)) {
|
|
661
|
+
if ((0, lodash_isempty_1.default)(cumulativePatch_1)) {
|
|
640
662
|
this.isSaveInProgress = false;
|
|
641
663
|
return;
|
|
642
664
|
}
|
|
@@ -691,7 +713,7 @@ exports.DbRef = DbRef;
|
|
|
691
713
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
692
714
|
exports.DbTable = void 0;
|
|
693
715
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
694
|
-
var I = tslib_1.__importStar(__webpack_require__(/*! immutable */ "immutable"));
|
|
716
|
+
var I = (0, tslib_1.__importStar)(__webpack_require__(/*! immutable */ "immutable"));
|
|
695
717
|
var uui_1 = __webpack_require__(/*! @epam/uui */ "@epam/uui");
|
|
696
718
|
var immutable_1 = __webpack_require__(/*! immutable */ "immutable");
|
|
697
719
|
var DbTable = /** @class */ (function () {
|
|
@@ -743,7 +765,7 @@ var DbTable = /** @class */ (function () {
|
|
|
743
765
|
var existing = _this.state.pk.get(immId);
|
|
744
766
|
var updated = entityPatch;
|
|
745
767
|
if (existing) {
|
|
746
|
-
updated = tslib_1.__assign(tslib_1.__assign({}, existing), entityPatch);
|
|
768
|
+
updated = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, existing), entityPatch);
|
|
747
769
|
}
|
|
748
770
|
return { id: id, immId: immId, patch: entityPatch, existing: existing, updated: updated, updatedFieldsisNew: !existing };
|
|
749
771
|
});
|
|
@@ -765,7 +787,7 @@ var DbTable = /** @class */ (function () {
|
|
|
765
787
|
for (var n = 0; n < updates.length; n++) {
|
|
766
788
|
_loop_1(n);
|
|
767
789
|
}
|
|
768
|
-
return tslib_1.__assign(tslib_1.__assign({}, index), { map: newMap });
|
|
790
|
+
return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, index), { map: newMap });
|
|
769
791
|
});
|
|
770
792
|
var newState = { pk: newPk, indexes: newIndexes };
|
|
771
793
|
return this.update(function (t) { return t.state = newState; });
|
|
@@ -773,27 +795,27 @@ var DbTable = /** @class */ (function () {
|
|
|
773
795
|
/* Query */
|
|
774
796
|
DbTable.prototype.find = function (filter) {
|
|
775
797
|
var _this = this;
|
|
776
|
-
return this.update(function (t) { return t.q = tslib_1.__assign(tslib_1.__assign({}, t.q), { filter: tslib_1.__assign(tslib_1.__assign({}, _this.q.filter), filter) }); });
|
|
798
|
+
return this.update(function (t) { return t.q = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, t.q), { filter: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, _this.q.filter), filter) }); });
|
|
777
799
|
};
|
|
778
800
|
DbTable.prototype.order = function (order) {
|
|
779
|
-
return this.update(function (t) { return t.q = tslib_1.__assign(tslib_1.__assign({}, t.q), { sorting: order }); });
|
|
801
|
+
return this.update(function (t) { return t.q = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, t.q), { sorting: order }); });
|
|
780
802
|
};
|
|
781
803
|
DbTable.prototype.orderBy = function (field, direction) {
|
|
782
804
|
if (direction === void 0) { direction = 'asc'; }
|
|
783
|
-
return this.update(function (t) { return t.q = tslib_1.__assign(tslib_1.__assign({}, t.q), { sorting: [{ field: field, direction: direction }] }); });
|
|
805
|
+
return this.update(function (t) { return t.q = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, t.q), { sorting: [{ field: field, direction: direction }] }); });
|
|
784
806
|
};
|
|
785
807
|
DbTable.prototype.thenBy = function (field, direction) {
|
|
786
|
-
return this.update(function (t) { return t.q = tslib_1.__assign(tslib_1.__assign({}, t.q), { sorting: tslib_1.
|
|
808
|
+
return this.update(function (t) { return t.q = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, t.q), { sorting: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], t.q.sorting, true), [{ field: field, direction: direction }], false) }); });
|
|
787
809
|
};
|
|
788
810
|
DbTable.prototype.search = function (text) {
|
|
789
811
|
if (!this.schema.searchBy) {
|
|
790
|
-
throw new Error("Can't search in the "
|
|
812
|
+
throw new Error("Can't search in the ".concat(this.schema.typeName, " table - searchBy is not defined in the schema."));
|
|
791
813
|
}
|
|
792
|
-
return this.update(function (t) { return t.q = tslib_1.__assign(tslib_1.__assign({}, t.q), { search: text }); });
|
|
814
|
+
return this.update(function (t) { return t.q = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, t.q), { search: text }); });
|
|
793
815
|
};
|
|
794
816
|
/* Materializing */
|
|
795
817
|
DbTable.prototype.range = function (from, count) {
|
|
796
|
-
return this.runQuery(tslib_1.__assign(tslib_1.__assign({}, this.q), { range: { from: from, count: count } }));
|
|
818
|
+
return this.runQuery((0, tslib_1.__assign)((0, tslib_1.__assign)({}, this.q), { range: { from: from, count: count } }));
|
|
797
819
|
};
|
|
798
820
|
DbTable.prototype.count = function () {
|
|
799
821
|
return this.runQuery(this.q).length;
|
|
@@ -818,13 +840,13 @@ var DbTable = /** @class */ (function () {
|
|
|
818
840
|
for (var n = 0; n < indexes.length; n++) {
|
|
819
841
|
var index = indexes[n];
|
|
820
842
|
if (index.field in filter) {
|
|
821
|
-
var _a = filter, _b = index.field, condition = _a[_b], rest = tslib_1.__rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
843
|
+
var _a = filter, _b = index.field, condition = _a[_b], rest = (0, tslib_1.__rest)(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
822
844
|
var conditionValues = null;
|
|
823
845
|
if (condition != null && typeof condition === "object") {
|
|
824
846
|
// Attempt to use index for 'in' and 'isNull' criteria.
|
|
825
847
|
// We need to be very conservative here, indexed field should work the same way as getPatternPredicate. So
|
|
826
848
|
// - it's better to leave corner cases to getPatternPredicate
|
|
827
|
-
var _c = condition, inCriteria = _c.in, nullCriteria = _c.isNull, restCriteria = tslib_1.__rest(_c, ["in", "isNull"]);
|
|
849
|
+
var _c = condition, inCriteria = _c.in, nullCriteria = _c.isNull, restCriteria = (0, tslib_1.__rest)(_c, ["in", "isNull"]);
|
|
828
850
|
if (inCriteria && Array.isArray(inCriteria)) {
|
|
829
851
|
conditionValues = inCriteria;
|
|
830
852
|
}
|
|
@@ -871,15 +893,15 @@ var DbTable = /** @class */ (function () {
|
|
|
871
893
|
result = this.state.pk.toArray();
|
|
872
894
|
}
|
|
873
895
|
if (filter) {
|
|
874
|
-
var predicate = uui_1.getPatternPredicate(q.filter);
|
|
896
|
+
var predicate = (0, uui_1.getPatternPredicate)(q.filter);
|
|
875
897
|
result = result.filter(predicate);
|
|
876
898
|
}
|
|
877
899
|
if (q.search) {
|
|
878
|
-
var searchFilter_1 = uui_1.getSearchFilter(q.search);
|
|
900
|
+
var searchFilter_1 = (0, uui_1.getSearchFilter)(q.search);
|
|
879
901
|
result = result.filter(function (item) { return searchFilter_1(_this.schema.searchBy.map(function (field) { return item[field]; })); });
|
|
880
902
|
}
|
|
881
903
|
if (q.sorting) {
|
|
882
|
-
var comparer = uui_1.getOrderComparer(q.sorting);
|
|
904
|
+
var comparer = (0, uui_1.getOrderComparer)(q.sorting);
|
|
883
905
|
result = result.sort(comparer);
|
|
884
906
|
}
|
|
885
907
|
if (q.range) {
|
|
@@ -913,7 +935,7 @@ var ListLoadingTracker = /** @class */ (function () {
|
|
|
913
935
|
this.extractList = (options === null || options === void 0 ? void 0 : options.extractList) || (function (r) { return r; });
|
|
914
936
|
}
|
|
915
937
|
ListLoadingTracker.prototype.prepare = function (request) {
|
|
916
|
-
var filter = request.filter, sorting = request.sorting, search = request.search, range = request.range, unknownFields = tslib_1.__rest(request, ["filter", "sorting", "search", "range"]);
|
|
938
|
+
var filter = request.filter, sorting = request.sorting, search = request.search, range = request.range, unknownFields = (0, tslib_1.__rest)(request, ["filter", "sorting", "search", "range"]);
|
|
917
939
|
var options = {};
|
|
918
940
|
if (filter) {
|
|
919
941
|
options.filter = filter;
|
|
@@ -924,7 +946,7 @@ var ListLoadingTracker = /** @class */ (function () {
|
|
|
924
946
|
if (search) {
|
|
925
947
|
options.search = search;
|
|
926
948
|
}
|
|
927
|
-
var keyObject = tslib_1.__assign(tslib_1.__assign({}, options), unknownFields);
|
|
949
|
+
var keyObject = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), unknownFields);
|
|
928
950
|
var key = JSON.stringify(keyObject);
|
|
929
951
|
var entry = this.cache.get(key);
|
|
930
952
|
if (!entry) {
|
|
@@ -948,7 +970,7 @@ var ListLoadingTracker = /** @class */ (function () {
|
|
|
948
970
|
missingCount = Math.min(missingCount, entry.maxCount);
|
|
949
971
|
}
|
|
950
972
|
if (missingCount > 0) {
|
|
951
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, options), unknownFields), { range: { from: entry.count, count: requestedMax - entry.count } });
|
|
973
|
+
return (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), unknownFields), { range: { from: entry.count, count: requestedMax - entry.count } });
|
|
952
974
|
}
|
|
953
975
|
else {
|
|
954
976
|
return null;
|
|
@@ -1131,14 +1153,14 @@ exports.SimpleLoadingTracker = SimpleLoadingTracker;
|
|
|
1131
1153
|
|
|
1132
1154
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1133
1155
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
1134
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1135
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./Db */ "./src/Db.ts"), exports);
|
|
1136
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./DbTable */ "./src/DbTable.ts"), exports);
|
|
1137
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./DbRef */ "./src/DbRef.ts"), exports);
|
|
1138
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./tempIds */ "./src/tempIds.tsx"), exports);
|
|
1139
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./utils */ "./src/utils.ts"), exports);
|
|
1140
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./patchHelpers */ "./src/patchHelpers.ts"), exports);
|
|
1141
|
-
tslib_1.__exportStar(__webpack_require__(/*! ./reactHooks */ "./src/reactHooks.ts"), exports);
|
|
1156
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
|
|
1157
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./Db */ "./src/Db.ts"), exports);
|
|
1158
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./DbTable */ "./src/DbTable.ts"), exports);
|
|
1159
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./DbRef */ "./src/DbRef.ts"), exports);
|
|
1160
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./tempIds */ "./src/tempIds.tsx"), exports);
|
|
1161
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./utils */ "./src/utils.ts"), exports);
|
|
1162
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./patchHelpers */ "./src/patchHelpers.ts"), exports);
|
|
1163
|
+
(0, tslib_1.__exportStar)(__webpack_require__(/*! ./reactHooks */ "./src/reactHooks.ts"), exports);
|
|
1142
1164
|
|
|
1143
1165
|
|
|
1144
1166
|
/***/ }),
|
|
@@ -1156,20 +1178,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
1156
1178
|
exports.getEntityParentDependencies = exports.getParentEntities = exports.hasServerFields = exports.isNew = exports.getId = exports.isClientOnly = exports.makeCumulativePatch = exports.isPatchBlank = exports.flattenResponse = exports.mergeEntityPatches = exports.unionPatches = void 0;
|
|
1157
1179
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
1158
1180
|
var types_1 = __webpack_require__(/*! ./types */ "./src/types.ts");
|
|
1159
|
-
var I = tslib_1.__importStar(__webpack_require__(/*! immutable */ "immutable"));
|
|
1181
|
+
var I = (0, tslib_1.__importStar)(__webpack_require__(/*! immutable */ "immutable"));
|
|
1160
1182
|
var utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
|
|
1161
|
-
var lodash_groupby_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.groupby */ "lodash.groupby"));
|
|
1162
|
-
var lodash_map_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.map */ "lodash.map"));
|
|
1163
|
-
var lodash_merge_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.merge */ "lodash.merge"));
|
|
1164
|
-
var lodash_countby_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.countby */ "lodash.countby"));
|
|
1165
|
-
var lodash_filter_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.filter */ "lodash.filter"));
|
|
1166
|
-
var lodash_foreach_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.foreach */ "lodash.foreach"));
|
|
1167
|
-
var lodash_pick_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.pick */ "lodash.pick"));
|
|
1183
|
+
var lodash_groupby_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.groupby */ "lodash.groupby"));
|
|
1184
|
+
var lodash_map_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.map */ "lodash.map"));
|
|
1185
|
+
var lodash_merge_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.merge */ "lodash.merge"));
|
|
1186
|
+
var lodash_countby_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.countby */ "lodash.countby"));
|
|
1187
|
+
var lodash_filter_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.filter */ "lodash.filter"));
|
|
1188
|
+
var lodash_foreach_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.foreach */ "lodash.foreach"));
|
|
1189
|
+
var lodash_pick_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.pick */ "lodash.pick"));
|
|
1168
1190
|
function unionPatches(patches) {
|
|
1169
1191
|
var result = {};
|
|
1170
1192
|
patches.forEach(function (patch) {
|
|
1171
|
-
utils_1.objectKeys(patch).forEach(function (tableName) {
|
|
1172
|
-
result[tableName] = result[tableName] ? tslib_1.
|
|
1193
|
+
(0, utils_1.objectKeys)(patch).forEach(function (tableName) {
|
|
1194
|
+
result[tableName] = result[tableName] ? (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], result[tableName], true), patch[tableName], true) : patch[tableName];
|
|
1173
1195
|
});
|
|
1174
1196
|
});
|
|
1175
1197
|
return result;
|
|
@@ -1177,19 +1199,19 @@ function unionPatches(patches) {
|
|
|
1177
1199
|
exports.unionPatches = unionPatches;
|
|
1178
1200
|
function mergeEntityPatches(tables, patch) {
|
|
1179
1201
|
var result = {};
|
|
1180
|
-
utils_1.objectKeys(patch).forEach(function (key) {
|
|
1202
|
+
(0, utils_1.objectKeys)(patch).forEach(function (key) {
|
|
1181
1203
|
var table = tables[key];
|
|
1182
|
-
var groupedEntities = lodash_groupby_1.default(patch[key], function (item) { return table.getId(item); });
|
|
1183
|
-
var tablePatch = lodash_map_1.default(groupedEntities, function (entities) {
|
|
1184
|
-
var result = lodash_merge_1.default.apply(void 0, tslib_1.
|
|
1204
|
+
var groupedEntities = (0, lodash_groupby_1.default)(patch[key], function (item) { return table.getId(item); });
|
|
1205
|
+
var tablePatch = (0, lodash_map_1.default)(groupedEntities, function (entities) {
|
|
1206
|
+
var result = lodash_merge_1.default.apply(void 0, (0, tslib_1.__spreadArray)([{}], entities, false));
|
|
1185
1207
|
if (true) {
|
|
1186
|
-
var props = utils_1.objectKeys(result).filter(function (prop) {
|
|
1187
|
-
return Object.keys(lodash_countby_1.default(entities.filter(function (entity) {
|
|
1208
|
+
var props = (0, utils_1.objectKeys)(result).filter(function (prop) {
|
|
1209
|
+
return Object.keys((0, lodash_countby_1.default)(entities.filter(function (entity) {
|
|
1188
1210
|
return entity[prop] !== undefined;
|
|
1189
1211
|
}), function (entity) { return entity[prop]; })).length > 1;
|
|
1190
1212
|
});
|
|
1191
1213
|
if (props.length) {
|
|
1192
|
-
console.warn.apply(console, tslib_1.
|
|
1214
|
+
console.warn.apply(console, (0, tslib_1.__spreadArray)(['mergeEntityPatches: Different property values found for the same entity.\nProperty names:\n', props, '\nEntities:\n'], entities, false));
|
|
1193
1215
|
}
|
|
1194
1216
|
}
|
|
1195
1217
|
return result;
|
|
@@ -1236,14 +1258,14 @@ function flattenResponse(response, tables) {
|
|
|
1236
1258
|
var result = {};
|
|
1237
1259
|
var tablesByTypeName = {};
|
|
1238
1260
|
Object.values(tables).forEach(function (table) { return tablesByTypeName[table.schema.typeName] = table; });
|
|
1239
|
-
utils_1.objectKeys(tables).forEach(function (tableName) { return tablesByTypeName; });
|
|
1240
|
-
utils_1.objectKeys(tables).forEach(function (key) { return result[key] = []; });
|
|
1261
|
+
(0, utils_1.objectKeys)(tables).forEach(function (tableName) { return tablesByTypeName; });
|
|
1262
|
+
(0, utils_1.objectKeys)(tables).forEach(function (key) { return result[key] = []; });
|
|
1241
1263
|
flattenResponseHelper(result, response, tablesByTypeName);
|
|
1242
1264
|
return result;
|
|
1243
1265
|
}
|
|
1244
1266
|
exports.flattenResponse = flattenResponse;
|
|
1245
1267
|
function isPatchBlank(patch) {
|
|
1246
|
-
return !utils_1.objectKeys(patch).some(function (key) { return patch[key].length > 0; });
|
|
1268
|
+
return !(0, utils_1.objectKeys)(patch).some(function (key) { return patch[key].length > 0; });
|
|
1247
1269
|
}
|
|
1248
1270
|
exports.isPatchBlank = isPatchBlank;
|
|
1249
1271
|
/**
|
|
@@ -1251,7 +1273,7 @@ exports.isPatchBlank = isPatchBlank;
|
|
|
1251
1273
|
*/
|
|
1252
1274
|
function makeCumulativePatch(updatedDb, patches, clientIdsMap) {
|
|
1253
1275
|
var result = {};
|
|
1254
|
-
utils_1.objectKeys(updatedDb.tables).forEach(function (entityName) {
|
|
1276
|
+
(0, utils_1.objectKeys)(updatedDb.tables).forEach(function (entityName) {
|
|
1255
1277
|
var table = updatedDb.tables[entityName];
|
|
1256
1278
|
var schema = table.schema;
|
|
1257
1279
|
var ids = I.Set();
|
|
@@ -1282,7 +1304,7 @@ function getId(entity, schema) {
|
|
|
1282
1304
|
return entity[schema.primaryKey];
|
|
1283
1305
|
}
|
|
1284
1306
|
var result = [];
|
|
1285
|
-
lodash_foreach_1.default(lodash_pick_1.default(entity, schema.primaryKey), function (value) {
|
|
1307
|
+
(0, lodash_foreach_1.default)((0, lodash_pick_1.default)(entity, schema.primaryKey), function (value) {
|
|
1286
1308
|
result.push(value);
|
|
1287
1309
|
});
|
|
1288
1310
|
return result;
|
|
@@ -1294,11 +1316,11 @@ function isNew(entity, schema, clientIdsMap) {
|
|
|
1294
1316
|
}
|
|
1295
1317
|
exports.isNew = isNew;
|
|
1296
1318
|
function hasServerFields(entity, schema, clientIdsMap, tables) {
|
|
1297
|
-
var fullEntity = tslib_1.__assign(tslib_1.__assign({}, tables[schema.tableName].byId(entity.id) || {}), entity);
|
|
1319
|
+
var fullEntity = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, tables[schema.tableName].byId(entity.id) || {}), entity);
|
|
1298
1320
|
if (isClientOnly(fullEntity, schema)) {
|
|
1299
1321
|
return false;
|
|
1300
1322
|
}
|
|
1301
|
-
return utils_1.objectKeys(entity).some(function (fieldName) {
|
|
1323
|
+
return (0, utils_1.objectKeys)(entity).some(function (fieldName) {
|
|
1302
1324
|
var fieldSchema = schema.fields[fieldName];
|
|
1303
1325
|
return !fieldSchema || !(fieldSchema.isClientOnly || fieldSchema.isReadOnly || (fieldSchema.isGenerated && !isNew(entity, schema, clientIdsMap)));
|
|
1304
1326
|
});
|
|
@@ -1306,10 +1328,10 @@ function hasServerFields(entity, schema, clientIdsMap, tables) {
|
|
|
1306
1328
|
exports.hasServerFields = hasServerFields;
|
|
1307
1329
|
function getParentEntities(patch, tables) {
|
|
1308
1330
|
var dependenciesPatch = {};
|
|
1309
|
-
utils_1.objectKeys(patch).forEach(function (key) {
|
|
1331
|
+
(0, utils_1.objectKeys)(patch).forEach(function (key) {
|
|
1310
1332
|
var table = tables[key];
|
|
1311
1333
|
var tableSchema = table.schema;
|
|
1312
|
-
var fields = lodash_filter_1.default(lodash_map_1.default(tableSchema.fields, function (field, name) { return (tslib_1.__assign(tslib_1.__assign({}, field), { name: name })); }), function (field) { return field.fk && field.fk.relationType == types_1.DbRelationType.Aggregation; });
|
|
1334
|
+
var fields = (0, lodash_filter_1.default)((0, lodash_map_1.default)(tableSchema.fields, function (field, name) { return ((0, tslib_1.__assign)((0, tslib_1.__assign)({}, field), { name: name })); }), function (field) { return field.fk && field.fk.relationType == types_1.DbRelationType.Aggregation; });
|
|
1313
1335
|
var tablePatch = patch[key];
|
|
1314
1336
|
fields.forEach(function (field) {
|
|
1315
1337
|
var tableName = field.fk.tableName, name = field.name;
|
|
@@ -1317,7 +1339,7 @@ function getParentEntities(patch, tables) {
|
|
|
1317
1339
|
var actualTableName = (typeof tableName == 'function' ? tableName(entity) : tableName);
|
|
1318
1340
|
var dbEntity = table.byId(table.getId(entity));
|
|
1319
1341
|
var parentEntity = tables[actualTableName].byId(dbEntity[name]);
|
|
1320
|
-
var idFields = lodash_pick_1.default(parentEntity, tables[actualTableName].schema.primaryKey);
|
|
1342
|
+
var idFields = (0, lodash_pick_1.default)(parentEntity, tables[actualTableName].schema.primaryKey);
|
|
1321
1343
|
if (parentEntity) {
|
|
1322
1344
|
dependenciesPatch[actualTableName] = dependenciesPatch[actualTableName] || [];
|
|
1323
1345
|
dependenciesPatch[actualTableName].push(idFields);
|
|
@@ -1340,7 +1362,7 @@ function getEntityParentDependencies(entity, entityName, tables) {
|
|
|
1340
1362
|
resultPatches.push(parents);
|
|
1341
1363
|
patch = parents;
|
|
1342
1364
|
}
|
|
1343
|
-
var result = unionPatches(tslib_1.
|
|
1365
|
+
var result = unionPatches((0, tslib_1.__spreadArray)([patch], resultPatches, true));
|
|
1344
1366
|
result = mergeEntityPatches(tables, result);
|
|
1345
1367
|
return result;
|
|
1346
1368
|
}
|
|
@@ -1362,17 +1384,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
1362
1384
|
exports.useDbView = exports.useDbRef = exports.DbContext = void 0;
|
|
1363
1385
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
1364
1386
|
var react_1 = __webpack_require__(/*! react */ "react");
|
|
1365
|
-
exports.DbContext = react_1.createContext(null);
|
|
1387
|
+
exports.DbContext = (0, react_1.createContext)(null);
|
|
1366
1388
|
function useDbRef() {
|
|
1367
|
-
return react_1.useContext(exports.DbContext);
|
|
1389
|
+
return (0, react_1.useContext)(exports.DbContext);
|
|
1368
1390
|
}
|
|
1369
1391
|
exports.useDbRef = useDbRef;
|
|
1370
1392
|
function useDbView(fn, params, options) {
|
|
1371
1393
|
var dbRef = useDbRef();
|
|
1372
|
-
var _a = react_1.useState(), state = _a[0], setState = _a[1];
|
|
1373
|
-
var subscription = react_1.useMemo(function () { return dbRef.subscribe(tslib_1.__assign({ compute: fn }, options), params, setState); }, []);
|
|
1394
|
+
var _a = (0, react_1.useState)(), state = _a[0], setState = _a[1];
|
|
1395
|
+
var subscription = (0, react_1.useMemo)(function () { return dbRef.subscribe((0, tslib_1.__assign)({ compute: fn }, options), params, setState); }, []);
|
|
1374
1396
|
subscription.update(params);
|
|
1375
|
-
react_1.useEffect(function () {
|
|
1397
|
+
(0, react_1.useEffect)(function () {
|
|
1376
1398
|
return function () { return subscription.unsubscribe(); };
|
|
1377
1399
|
}, []);
|
|
1378
1400
|
return subscription.currentValue;
|
|
@@ -1413,14 +1435,14 @@ var TempIdMap = /** @class */ (function () {
|
|
|
1413
1435
|
this.clientToServer = function (id) { return _this.clientToServerIds.get(id); };
|
|
1414
1436
|
this.serverToClient = function (tableName, id) { return _this.getServerToClientMap(tableName).get(id); };
|
|
1415
1437
|
this.clientToServerRequest = function (request) {
|
|
1416
|
-
request = tslib_1.__assign({}, request);
|
|
1438
|
+
request = (0, tslib_1.__assign)({}, request);
|
|
1417
1439
|
if (request.filter) {
|
|
1418
1440
|
request.filter = _this.clientToServerDataFilter(request.filter);
|
|
1419
1441
|
}
|
|
1420
1442
|
return request;
|
|
1421
1443
|
};
|
|
1422
1444
|
this.clientToServerDataFilter = function (filter) {
|
|
1423
|
-
filter = tslib_1.__assign({}, filter);
|
|
1445
|
+
filter = (0, tslib_1.__assign)({}, filter);
|
|
1424
1446
|
var keys = Object.keys(filter);
|
|
1425
1447
|
// I hope that we can rely that there won't be any negative numbers, which are not IDs, in queries.
|
|
1426
1448
|
// We need to invent better heuristics or a schema otherwise.
|
|
@@ -1437,7 +1459,7 @@ var TempIdMap = /** @class */ (function () {
|
|
|
1437
1459
|
var key = keys[n];
|
|
1438
1460
|
var condition = filter[key];
|
|
1439
1461
|
if (condition != null && typeof condition === "object") {
|
|
1440
|
-
condition = tslib_1.__assign({}, condition);
|
|
1462
|
+
condition = (0, tslib_1.__assign)({}, condition);
|
|
1441
1463
|
if ('in' in condition && Array.isArray(condition.in) && condition.in.length) {
|
|
1442
1464
|
condition.in = condition.in.map(clientToServer);
|
|
1443
1465
|
}
|
|
@@ -1451,9 +1473,9 @@ var TempIdMap = /** @class */ (function () {
|
|
|
1451
1473
|
};
|
|
1452
1474
|
}
|
|
1453
1475
|
TempIdMap.prototype.copyPatch = function (patch) {
|
|
1454
|
-
var newPatch = tslib_1.__assign({}, patch);
|
|
1455
|
-
utils_1.objectKeys(patch).forEach(function (tableName) {
|
|
1456
|
-
var tablePatch = patch[tableName].map(function (entityPatch) { return (tslib_1.__assign({}, entityPatch)); });
|
|
1476
|
+
var newPatch = (0, tslib_1.__assign)({}, patch);
|
|
1477
|
+
(0, utils_1.objectKeys)(patch).forEach(function (tableName) {
|
|
1478
|
+
var tablePatch = patch[tableName].map(function (entityPatch) { return ((0, tslib_1.__assign)({}, entityPatch)); });
|
|
1457
1479
|
newPatch[tableName] = tablePatch;
|
|
1458
1480
|
});
|
|
1459
1481
|
return newPatch;
|
|
@@ -1461,9 +1483,9 @@ var TempIdMap = /** @class */ (function () {
|
|
|
1461
1483
|
// Iterate thru every field in every patch for every table, matching certain field criteria. The patch is mutated!
|
|
1462
1484
|
TempIdMap.prototype.mapFields = function (patch, filter, callback) {
|
|
1463
1485
|
var _this = this;
|
|
1464
|
-
utils_1.objectKeys(patch).forEach(function (tableName) {
|
|
1486
|
+
(0, utils_1.objectKeys)(patch).forEach(function (tableName) {
|
|
1465
1487
|
var schema = _this.db.tables[tableName].schema;
|
|
1466
|
-
var fields = utils_1.objectKeys(schema.fields || [])
|
|
1488
|
+
var fields = (0, utils_1.objectKeys)(schema.fields || [])
|
|
1467
1489
|
.map(function (fieldName) {
|
|
1468
1490
|
var fieldSchema = schema.fields[fieldName];
|
|
1469
1491
|
if (filter(fieldSchema, fieldName)) {
|
|
@@ -1553,7 +1575,7 @@ var TempIdMap = /** @class */ (function () {
|
|
|
1553
1575
|
};
|
|
1554
1576
|
TempIdMap.prototype.appendServerMapping = function (response) {
|
|
1555
1577
|
var _this = this;
|
|
1556
|
-
utils_1.objectKeys(response.submit).forEach(function (tableName) {
|
|
1578
|
+
(0, utils_1.objectKeys)(response.submit).forEach(function (tableName) {
|
|
1557
1579
|
if (_this.db.tables[tableName]) {
|
|
1558
1580
|
var tablePatch = response.submit[tableName];
|
|
1559
1581
|
if (tablePatch) {
|
|
@@ -1610,23 +1632,23 @@ var DbRelationType;
|
|
|
1610
1632
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1611
1633
|
exports.difference = exports.defaultCompareViewDependencies = exports.objectKeys = void 0;
|
|
1612
1634
|
var tslib_1 = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
|
|
1613
|
-
var shallowequal_1 = tslib_1.__importDefault(__webpack_require__(/*! shallowequal */ "shallowequal"));
|
|
1614
|
-
var lodash_zip_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.zip */ "lodash.zip"));
|
|
1615
|
-
var lodash_transform_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.transform */ "lodash.transform"));
|
|
1616
|
-
var lodash_isequal_1 = tslib_1.__importDefault(__webpack_require__(/*! lodash.isequal */ "lodash.isequal"));
|
|
1635
|
+
var shallowequal_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! shallowequal */ "shallowequal"));
|
|
1636
|
+
var lodash_zip_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.zip */ "lodash.zip"));
|
|
1637
|
+
var lodash_transform_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.transform */ "lodash.transform"));
|
|
1638
|
+
var lodash_isequal_1 = (0, tslib_1.__importDefault)(__webpack_require__(/*! lodash.isequal */ "lodash.isequal"));
|
|
1617
1639
|
// TBD: New typescript would contain better typing for this. Remove this hack after update.
|
|
1618
1640
|
exports.objectKeys = Object.keys;
|
|
1619
1641
|
function defaultCompareViewDependencies(prev, next) {
|
|
1620
1642
|
if (Array.isArray(prev) && Array.isArray(next)) {
|
|
1621
1643
|
if (prev.length === next.length) {
|
|
1622
|
-
return lodash_zip_1.default(prev, next).every(function (_a) {
|
|
1644
|
+
return (0, lodash_zip_1.default)(prev, next).every(function (_a) {
|
|
1623
1645
|
var p = _a[0], n = _a[1];
|
|
1624
|
-
return shallowequal_1.default(p, n);
|
|
1646
|
+
return (0, shallowequal_1.default)(p, n);
|
|
1625
1647
|
});
|
|
1626
1648
|
}
|
|
1627
1649
|
return false;
|
|
1628
1650
|
}
|
|
1629
|
-
return shallowequal_1.default(prev, next);
|
|
1651
|
+
return (0, shallowequal_1.default)(prev, next);
|
|
1630
1652
|
}
|
|
1631
1653
|
exports.defaultCompareViewDependencies = defaultCompareViewDependencies;
|
|
1632
1654
|
/**
|
|
@@ -1637,8 +1659,8 @@ exports.defaultCompareViewDependencies = defaultCompareViewDependencies;
|
|
|
1637
1659
|
*/
|
|
1638
1660
|
function difference(object, base) {
|
|
1639
1661
|
function changes(object, base) {
|
|
1640
|
-
return lodash_transform_1.default(object, function (result, value, key) {
|
|
1641
|
-
if (!lodash_isequal_1.default(value, base[key])) {
|
|
1662
|
+
return (0, lodash_transform_1.default)(object, function (result, value, key) {
|
|
1663
|
+
if (!(0, lodash_isequal_1.default)(value, base[key])) {
|
|
1642
1664
|
result[key] = (typeof value === "object" && typeof base[key] === "object") ? changes(value, base[key]) : value;
|
|
1643
1665
|
}
|
|
1644
1666
|
});
|