remult 0.9.6 → 0.9.10
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/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +1 -1
- package/postgres/postgres-data-provider.js +22 -10
- package/postgres/postgres-data-provider.js.map +1 -1
- package/remult-knex/index.d.ts +42 -0
- package/remult-knex/index.js +768 -0
- package/remult-knex/index.js.map +1 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +4 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +123 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.js.map +1 -0
- package/src/backend-tests/my-test.backend-spec.d.ts +1 -0
- package/src/backend-tests/my-test.backend-spec.js +24 -0
- package/src/backend-tests/my-test.backend-spec.js.map +1 -0
- package/src/context.d.ts +7 -2
- package/src/context.js +19 -5
- package/src/context.js.map +1 -1
- package/src/data-providers/array-entity-data-provider.js +1 -1
- package/src/data-providers/array-entity-data-provider.js.map +1 -1
- package/src/data-providers/sql-database.js +1 -2
- package/src/data-providers/sql-database.js.map +1 -1
- package/src/entity.d.ts +2 -1
- package/src/remult3/RepositoryImplementation.d.ts +14 -2
- package/src/remult3/RepositoryImplementation.js +373 -125
- package/src/remult3/RepositoryImplementation.js.map +1 -1
- package/src/remult3/remult3.d.ts +6 -1
- package/src/shared-tests/db-tests-setup.d.ts +23 -0
- package/src/shared-tests/db-tests-setup.js +171 -0
- package/src/shared-tests/db-tests-setup.js.map +1 -0
- package/src/shared-tests/db-tests.db-tests.d.ts +5 -0
- package/src/shared-tests/db-tests.db-tests.js +1228 -0
- package/src/shared-tests/db-tests.db-tests.js.map +1 -0
- package/src/shared-tests/deleteAll.d.ts +2 -0
- package/src/shared-tests/deleteAll.js +22 -0
- package/src/shared-tests/deleteAll.js.map +1 -0
- package/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/src/shared-tests/entityWithValidations.js +95 -0
- package/src/shared-tests/entityWithValidations.js.map +1 -0
- package/src/shared-tests/index.d.ts +4 -0
- package/src/shared-tests/index.js +7 -0
- package/src/shared-tests/index.js.map +1 -0
- package/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/src/shared-tests/test-custom-id-column.spec.js +88 -0
- package/src/shared-tests/test-custom-id-column.spec.js.map +1 -0
- package/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/src/shared-tests/test-special-value.spec.js +129 -0
- package/src/shared-tests/test-special-value.spec.js.map +1 -0
- package/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/src/shared-tests/test-update-with-null.spec.js +52 -0
- package/src/shared-tests/test-update-with-null.spec.js.map +1 -0
- package/src/tests/Done.d.ts +5 -0
- package/src/tests/Done.js +18 -0
- package/src/tests/Done.js.map +1 -0
- package/src/tests/TestDataApiResponse.d.ts +10 -0
- package/src/tests/TestDataApiResponse.js +30 -0
- package/src/tests/TestDataApiResponse.js.map +1 -0
- package/src/tests/c.d.ts +8 -0
- package/src/tests/c.js +29 -0
- package/src/tests/c.js.map +1 -0
- package/src/tests/createData.d.ts +7 -0
- package/src/tests/createData.js +51 -0
- package/src/tests/createData.js.map +1 -0
- package/src/tests/d.d.ts +7 -0
- package/src/tests/d.js +44 -0
- package/src/tests/d.js.map +1 -0
- package/src/tests/dWithPrefilter.d.ts +7 -0
- package/src/tests/dWithPrefilter.js +46 -0
- package/src/tests/dWithPrefilter.js.map +1 -0
- package/src/tests/entityForCustomFilter.d.ts +16 -0
- package/src/tests/entityForCustomFilter.js +67 -0
- package/src/tests/entityForCustomFilter.js.map +1 -0
- package/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/src/tests/entityWithValidationsOnColumn.js +30 -0
- package/src/tests/entityWithValidationsOnColumn.js.map +1 -0
- package/src/tests/h.d.ts +6 -0
- package/src/tests/h.js +43 -0
- package/src/tests/h.js.map +1 -0
- package/src/tests/tasks.d.ts +6 -0
- package/src/tests/tasks.js +31 -0
- package/src/tests/tasks.js.map +1 -0
|
@@ -94,6 +94,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
94
94
|
configurable: true
|
|
95
95
|
});
|
|
96
96
|
RepositoryImplementation.prototype.getCachedById = function (id) {
|
|
97
|
+
id = id + '';
|
|
97
98
|
this.getCachedByIdAsync(id);
|
|
98
99
|
var r = this.idCache.get(id);
|
|
99
100
|
if (r instanceof Promise)
|
|
@@ -107,6 +108,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
107
108
|
return tslib_1.__generator(this, function (_a) {
|
|
108
109
|
switch (_a.label) {
|
|
109
110
|
case 0:
|
|
111
|
+
id = id + '';
|
|
110
112
|
r = this.idCache.get(id);
|
|
111
113
|
if (!(r instanceof Promise)) return [3 /*break*/, 2];
|
|
112
114
|
return [4 /*yield*/, r];
|
|
@@ -134,7 +136,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
134
136
|
};
|
|
135
137
|
RepositoryImplementation.prototype.addToCache = function (item) {
|
|
136
138
|
if (item)
|
|
137
|
-
this.idCache.set(this.getEntityRef(item).getId(), item);
|
|
139
|
+
this.idCache.set(this.getEntityRef(item).getId() + '', item);
|
|
138
140
|
};
|
|
139
141
|
Object.defineProperty(RepositoryImplementation.prototype, "metadata", {
|
|
140
142
|
get: function () { return this._info; },
|
|
@@ -221,10 +223,11 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
221
223
|
};
|
|
222
224
|
RepositoryImplementation.prototype.find = function (options) {
|
|
223
225
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var opt, _a, rawRows, loadFields, result;
|
|
226
|
+
var opt, _a, rawRows, loadFields, _b, _c, col, ei, load, repo, toLoad, rawRows_1, rawRows_1_1, r, val, rows, rows_1, rows_1_1, r, e_4_1, result;
|
|
227
|
+
var e_4, _d, e_5, _e, _f, e_6, _g;
|
|
225
228
|
var _this = this;
|
|
226
|
-
return tslib_1.__generator(this, function (
|
|
227
|
-
switch (
|
|
229
|
+
return tslib_1.__generator(this, function (_h) {
|
|
230
|
+
switch (_h.label) {
|
|
228
231
|
case 0:
|
|
229
232
|
opt = {};
|
|
230
233
|
if (!options)
|
|
@@ -236,24 +239,88 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
236
239
|
_a = opt;
|
|
237
240
|
return [4 /*yield*/, this.translateWhereToFilter(options.where)];
|
|
238
241
|
case 1:
|
|
239
|
-
_a.where =
|
|
242
|
+
_a.where = _h.sent();
|
|
240
243
|
opt.orderBy = sort_1.Sort.translateOrderByToSort(this.metadata, options.orderBy);
|
|
241
244
|
opt.limit = options.limit;
|
|
242
245
|
opt.page = options.page;
|
|
243
246
|
return [4 /*yield*/, this.edp.find(opt)];
|
|
244
247
|
case 2:
|
|
245
|
-
rawRows =
|
|
248
|
+
rawRows = _h.sent();
|
|
246
249
|
loadFields = undefined;
|
|
247
250
|
if (options.load)
|
|
248
251
|
loadFields = options.load(this.metadata.fields);
|
|
249
|
-
|
|
250
|
-
switch (_a.label) {
|
|
251
|
-
case 0: return [4 /*yield*/, this.mapRawDataToResult(r, loadFields)];
|
|
252
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
253
|
-
}
|
|
254
|
-
}); }); }))];
|
|
252
|
+
_h.label = 3;
|
|
255
253
|
case 3:
|
|
256
|
-
|
|
254
|
+
_h.trys.push([3, 8, 9, 10]);
|
|
255
|
+
_b = tslib_1.__values(this.metadata.fields), _c = _b.next();
|
|
256
|
+
_h.label = 4;
|
|
257
|
+
case 4:
|
|
258
|
+
if (!!_c.done) return [3 /*break*/, 7];
|
|
259
|
+
col = _c.value;
|
|
260
|
+
ei = getEntitySettings(col.valueType, false);
|
|
261
|
+
if (!ei) return [3 /*break*/, 6];
|
|
262
|
+
load = !col.options.lazy;
|
|
263
|
+
if (loadFields !== undefined)
|
|
264
|
+
load = loadFields.includes(col);
|
|
265
|
+
if (!load) return [3 /*break*/, 6];
|
|
266
|
+
repo = this.remult.repo(col.valueType);
|
|
267
|
+
toLoad = [];
|
|
268
|
+
try {
|
|
269
|
+
for (rawRows_1 = (e_5 = void 0, tslib_1.__values(rawRows)), rawRows_1_1 = rawRows_1.next(); !rawRows_1_1.done; rawRows_1_1 = rawRows_1.next()) {
|
|
270
|
+
r = rawRows_1_1.value;
|
|
271
|
+
val = r[col.key];
|
|
272
|
+
if (val !== undefined && val !== null && !toLoad.includes(val) && !repo.idCache.has(val)) {
|
|
273
|
+
toLoad.push(val);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
278
|
+
finally {
|
|
279
|
+
try {
|
|
280
|
+
if (rawRows_1_1 && !rawRows_1_1.done && (_e = rawRows_1.return)) _e.call(rawRows_1);
|
|
281
|
+
}
|
|
282
|
+
finally { if (e_5) throw e_5.error; }
|
|
283
|
+
}
|
|
284
|
+
if (!(toLoad.length > 0)) return [3 /*break*/, 6];
|
|
285
|
+
return [4 /*yield*/, repo.find({ where: (_f = repo.metadata.idMetadata).getIdFilter.apply(_f, tslib_1.__spread(toLoad)) })];
|
|
286
|
+
case 5:
|
|
287
|
+
rows = _h.sent();
|
|
288
|
+
try {
|
|
289
|
+
for (rows_1 = (e_6 = void 0, tslib_1.__values(rows)), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
|
|
290
|
+
r = rows_1_1.value;
|
|
291
|
+
repo.addToCache(r);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
295
|
+
finally {
|
|
296
|
+
try {
|
|
297
|
+
if (rows_1_1 && !rows_1_1.done && (_g = rows_1.return)) _g.call(rows_1);
|
|
298
|
+
}
|
|
299
|
+
finally { if (e_6) throw e_6.error; }
|
|
300
|
+
}
|
|
301
|
+
_h.label = 6;
|
|
302
|
+
case 6:
|
|
303
|
+
_c = _b.next();
|
|
304
|
+
return [3 /*break*/, 4];
|
|
305
|
+
case 7: return [3 /*break*/, 10];
|
|
306
|
+
case 8:
|
|
307
|
+
e_4_1 = _h.sent();
|
|
308
|
+
e_4 = { error: e_4_1 };
|
|
309
|
+
return [3 /*break*/, 10];
|
|
310
|
+
case 9:
|
|
311
|
+
try {
|
|
312
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
313
|
+
}
|
|
314
|
+
finally { if (e_4) throw e_4.error; }
|
|
315
|
+
return [7 /*endfinally*/];
|
|
316
|
+
case 10: return [4 /*yield*/, Promise.all(rawRows.map(function (r) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
317
|
+
switch (_a.label) {
|
|
318
|
+
case 0: return [4 /*yield*/, this.mapRawDataToResult(r, loadFields)];
|
|
319
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
320
|
+
}
|
|
321
|
+
}); }); }))];
|
|
322
|
+
case 11:
|
|
323
|
+
result = _h.sent();
|
|
257
324
|
return [2 /*return*/, result];
|
|
258
325
|
}
|
|
259
326
|
});
|
|
@@ -379,7 +446,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
379
446
|
RepositoryImplementation.prototype.fromJson = function (json, newRow) {
|
|
380
447
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
381
448
|
var obj, _a, _b, col, r, helper;
|
|
382
|
-
var
|
|
449
|
+
var e_7, _c;
|
|
383
450
|
return tslib_1.__generator(this, function (_d) {
|
|
384
451
|
switch (_d.label) {
|
|
385
452
|
case 0:
|
|
@@ -392,12 +459,12 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
392
459
|
}
|
|
393
460
|
}
|
|
394
461
|
}
|
|
395
|
-
catch (
|
|
462
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
396
463
|
finally {
|
|
397
464
|
try {
|
|
398
465
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
399
466
|
}
|
|
400
|
-
finally { if (
|
|
467
|
+
finally { if (e_7) throw e_7.error; }
|
|
401
468
|
}
|
|
402
469
|
if (!newRow) return [3 /*break*/, 2];
|
|
403
470
|
r = this.create();
|
|
@@ -497,28 +564,62 @@ function createOldEntity(entity, remult) {
|
|
|
497
564
|
var r = exports.columnsOfType.get(entity);
|
|
498
565
|
if (!r)
|
|
499
566
|
exports.columnsOfType.set(entity, r = []);
|
|
500
|
-
var info = getEntitySettings(entity);
|
|
567
|
+
var info = getEntitySettings(entity)(remult);
|
|
501
568
|
var key = getEntityKey(entity);
|
|
502
569
|
var base = Object.getPrototypeOf(entity);
|
|
503
|
-
|
|
570
|
+
var _loop_1 = function () {
|
|
571
|
+
var e_8, _a;
|
|
504
572
|
var baseCols = exports.columnsOfType.get(base);
|
|
505
573
|
if (baseCols) {
|
|
506
574
|
r.unshift.apply(r, tslib_1.__spread(baseCols.filter(function (x) { return !r.find(function (y) { return y.key == x.key; }); })));
|
|
507
575
|
}
|
|
576
|
+
var baseSettingsFactory = getEntitySettings(base, false);
|
|
577
|
+
if (baseSettingsFactory) {
|
|
578
|
+
var baseSettings_1 = baseSettingsFactory(remult);
|
|
579
|
+
info = tslib_1.__assign(tslib_1.__assign({}, baseSettings_1), info);
|
|
580
|
+
var functions = ["saving", "saved", "deleting", "deleted", "validation"];
|
|
581
|
+
var _loop_2 = function (key_1) {
|
|
582
|
+
if (baseSettings_1[key_1]) {
|
|
583
|
+
var x_1 = info[key_1];
|
|
584
|
+
info[key_1] = function (a, b) {
|
|
585
|
+
x_1(a, b);
|
|
586
|
+
baseSettings_1[key_1](a, b);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
try {
|
|
591
|
+
for (var _b = (e_8 = void 0, tslib_1.__values(functions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
592
|
+
var key_1 = _c.value;
|
|
593
|
+
_loop_2(key_1);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
597
|
+
finally {
|
|
598
|
+
try {
|
|
599
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
600
|
+
}
|
|
601
|
+
finally { if (e_8) throw e_8.error; }
|
|
602
|
+
}
|
|
603
|
+
}
|
|
508
604
|
base = Object.getPrototypeOf(base);
|
|
605
|
+
};
|
|
606
|
+
while (base != null) {
|
|
607
|
+
_loop_1();
|
|
509
608
|
}
|
|
510
|
-
return new EntityFullInfo(prepareColumnInfo(r, remult), info
|
|
609
|
+
return new EntityFullInfo(prepareColumnInfo(r, remult), info, remult, entity, key);
|
|
511
610
|
}
|
|
512
611
|
exports.createOldEntity = createOldEntity;
|
|
513
612
|
var rowHelperBase = /** @class */ (function () {
|
|
514
613
|
function rowHelperBase(columnsInfo, instance, remult) {
|
|
515
|
-
var
|
|
614
|
+
var e_9, _a;
|
|
615
|
+
var _this = this;
|
|
516
616
|
this.columnsInfo = columnsInfo;
|
|
517
617
|
this.instance = instance;
|
|
518
618
|
this.remult = remult;
|
|
619
|
+
this._isLoading = false;
|
|
519
620
|
this.lookups = new Map();
|
|
520
621
|
this.originalValues = {};
|
|
521
|
-
var
|
|
622
|
+
var _loop_3 = function (col) {
|
|
522
623
|
var ei = getEntitySettings(col.valueType, false);
|
|
523
624
|
if (ei && remult) {
|
|
524
625
|
var lookup_1 = new column_1.LookupColumn(remult.repo(col.valueType), undefined);
|
|
@@ -526,31 +627,117 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
526
627
|
var val = instance[col.key];
|
|
527
628
|
Object.defineProperty(instance, col.key, {
|
|
528
629
|
get: function () {
|
|
630
|
+
_this._reportObserved();
|
|
529
631
|
return lookup_1.item;
|
|
530
632
|
},
|
|
531
633
|
set: function (val) {
|
|
532
|
-
|
|
634
|
+
lookup_1.set(val);
|
|
635
|
+
_this._reportChanged();
|
|
533
636
|
},
|
|
534
637
|
enumerable: true
|
|
535
638
|
});
|
|
536
639
|
instance[col.key] = val;
|
|
537
640
|
}
|
|
641
|
+
else {
|
|
642
|
+
}
|
|
538
643
|
};
|
|
539
644
|
var this_1 = this;
|
|
540
645
|
try {
|
|
541
646
|
for (var columnsInfo_1 = tslib_1.__values(columnsInfo), columnsInfo_1_1 = columnsInfo_1.next(); !columnsInfo_1_1.done; columnsInfo_1_1 = columnsInfo_1.next()) {
|
|
542
647
|
var col = columnsInfo_1_1.value;
|
|
543
|
-
|
|
648
|
+
_loop_3(col);
|
|
544
649
|
}
|
|
545
650
|
}
|
|
546
|
-
catch (
|
|
651
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
547
652
|
finally {
|
|
548
653
|
try {
|
|
549
654
|
if (columnsInfo_1_1 && !columnsInfo_1_1.done && (_a = columnsInfo_1.return)) _a.call(columnsInfo_1);
|
|
550
655
|
}
|
|
551
|
-
finally { if (
|
|
656
|
+
finally { if (e_9) throw e_9.error; }
|
|
552
657
|
}
|
|
553
658
|
}
|
|
659
|
+
Object.defineProperty(rowHelperBase.prototype, "error", {
|
|
660
|
+
get: function () {
|
|
661
|
+
this._reportObserved();
|
|
662
|
+
return this._error;
|
|
663
|
+
},
|
|
664
|
+
set: function (val) {
|
|
665
|
+
this._error = val;
|
|
666
|
+
this._reportChanged();
|
|
667
|
+
},
|
|
668
|
+
enumerable: false,
|
|
669
|
+
configurable: true
|
|
670
|
+
});
|
|
671
|
+
rowHelperBase.prototype._reportChanged = function () {
|
|
672
|
+
if (this._subscribers)
|
|
673
|
+
this._subscribers.forEach(function (x) { return x.reportChanged(); });
|
|
674
|
+
};
|
|
675
|
+
rowHelperBase.prototype._reportObserved = function () {
|
|
676
|
+
if (this._subscribers)
|
|
677
|
+
this._subscribers.forEach(function (x) { return x.reportObserved(); });
|
|
678
|
+
};
|
|
679
|
+
rowHelperBase.prototype.subscribe = function (listener) {
|
|
680
|
+
var e_10, _a;
|
|
681
|
+
var _this = this;
|
|
682
|
+
var list;
|
|
683
|
+
if (typeof listener === "function")
|
|
684
|
+
list = {
|
|
685
|
+
reportChanged: function () { return listener(); },
|
|
686
|
+
reportObserved: function () { }
|
|
687
|
+
};
|
|
688
|
+
else
|
|
689
|
+
list = listener;
|
|
690
|
+
if (!this._subscribers) {
|
|
691
|
+
this._subscribers = [];
|
|
692
|
+
var _loop_4 = function (col) {
|
|
693
|
+
var ei = getEntitySettings(col.valueType, false);
|
|
694
|
+
if (ei && this_2.remult) {
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
var val_1 = this_2.instance[col.key];
|
|
698
|
+
Object.defineProperty(this_2.instance, col.key, {
|
|
699
|
+
get: function () {
|
|
700
|
+
_this._reportObserved();
|
|
701
|
+
return val_1;
|
|
702
|
+
},
|
|
703
|
+
set: function (value) {
|
|
704
|
+
val_1 = value;
|
|
705
|
+
_this._reportChanged();
|
|
706
|
+
},
|
|
707
|
+
enumerable: true
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
var this_2 = this;
|
|
712
|
+
try {
|
|
713
|
+
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
714
|
+
var col = _c.value;
|
|
715
|
+
_loop_4(col);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
719
|
+
finally {
|
|
720
|
+
try {
|
|
721
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
722
|
+
}
|
|
723
|
+
finally { if (e_10) throw e_10.error; }
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
this._subscribers.push(list);
|
|
727
|
+
return function () { return _this._subscribers = _this._subscribers.filter(function (x) { return x != listener; }); };
|
|
728
|
+
};
|
|
729
|
+
Object.defineProperty(rowHelperBase.prototype, "isLoading", {
|
|
730
|
+
get: function () {
|
|
731
|
+
this._reportObserved();
|
|
732
|
+
return this._isLoading;
|
|
733
|
+
},
|
|
734
|
+
set: function (val) {
|
|
735
|
+
this._isLoading = val;
|
|
736
|
+
this._reportChanged();
|
|
737
|
+
},
|
|
738
|
+
enumerable: false,
|
|
739
|
+
configurable: true
|
|
740
|
+
});
|
|
554
741
|
rowHelperBase.prototype.waitLoad = function () {
|
|
555
742
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
556
743
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -564,7 +751,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
564
751
|
});
|
|
565
752
|
};
|
|
566
753
|
rowHelperBase.prototype.__assertValidity = function () {
|
|
567
|
-
var
|
|
754
|
+
var e_11, _a;
|
|
568
755
|
if (!this.hasErrors()) {
|
|
569
756
|
var error = {
|
|
570
757
|
modelState: Object.assign({}, this.errors),
|
|
@@ -581,12 +768,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
581
768
|
}
|
|
582
769
|
}
|
|
583
770
|
}
|
|
584
|
-
catch (
|
|
771
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
585
772
|
finally {
|
|
586
773
|
try {
|
|
587
774
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
588
775
|
}
|
|
589
|
-
finally { if (
|
|
776
|
+
finally { if (e_11) throw e_11.error; }
|
|
590
777
|
}
|
|
591
778
|
}
|
|
592
779
|
throw error;
|
|
@@ -618,12 +805,14 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
618
805
|
rowHelperBase.prototype.__clearErrors = function () {
|
|
619
806
|
this.errors = undefined;
|
|
620
807
|
this.error = undefined;
|
|
808
|
+
this._reportChanged();
|
|
621
809
|
};
|
|
622
810
|
rowHelperBase.prototype.hasErrors = function () {
|
|
811
|
+
this._reportObserved();
|
|
623
812
|
return !!!this.error && this.errors == undefined;
|
|
624
813
|
};
|
|
625
814
|
rowHelperBase.prototype.copyDataToObject = function () {
|
|
626
|
-
var
|
|
815
|
+
var e_12, _a;
|
|
627
816
|
var d = {};
|
|
628
817
|
try {
|
|
629
818
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -642,12 +831,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
642
831
|
d[col.key] = val;
|
|
643
832
|
}
|
|
644
833
|
}
|
|
645
|
-
catch (
|
|
834
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
646
835
|
finally {
|
|
647
836
|
try {
|
|
648
837
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
649
838
|
}
|
|
650
|
-
finally { if (
|
|
839
|
+
finally { if (e_12) throw e_12.error; }
|
|
651
840
|
}
|
|
652
841
|
return d;
|
|
653
842
|
};
|
|
@@ -693,7 +882,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
693
882
|
});
|
|
694
883
|
};
|
|
695
884
|
rowHelperBase.prototype.toApiJson = function () {
|
|
696
|
-
var
|
|
885
|
+
var e_13, _a;
|
|
697
886
|
var result = {};
|
|
698
887
|
try {
|
|
699
888
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -718,19 +907,19 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
718
907
|
}
|
|
719
908
|
}
|
|
720
909
|
}
|
|
721
|
-
catch (
|
|
910
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
722
911
|
finally {
|
|
723
912
|
try {
|
|
724
913
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
725
914
|
}
|
|
726
|
-
finally { if (
|
|
915
|
+
finally { if (e_13) throw e_13.error; }
|
|
727
916
|
}
|
|
728
917
|
return result;
|
|
729
918
|
};
|
|
730
919
|
rowHelperBase.prototype._updateEntityBasedOnApi = function (body) {
|
|
731
920
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
732
921
|
var keys, _a, _b, col, lu;
|
|
733
|
-
var
|
|
922
|
+
var e_14, _c;
|
|
734
923
|
return tslib_1.__generator(this, function (_d) {
|
|
735
924
|
switch (_d.label) {
|
|
736
925
|
case 0:
|
|
@@ -750,12 +939,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
750
939
|
}
|
|
751
940
|
}
|
|
752
941
|
}
|
|
753
|
-
catch (
|
|
942
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
754
943
|
finally {
|
|
755
944
|
try {
|
|
756
945
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
757
946
|
}
|
|
758
|
-
finally { if (
|
|
947
|
+
finally { if (e_14) throw e_14.error; }
|
|
759
948
|
}
|
|
760
949
|
return [4 /*yield*/, Promise.all(tslib_1.__spread(this.fields).map(function (x) { return x.load(); }))];
|
|
761
950
|
case 1:
|
|
@@ -770,7 +959,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
770
959
|
var rowHelperImplementation = /** @class */ (function (_super) {
|
|
771
960
|
tslib_1.__extends(rowHelperImplementation, _super);
|
|
772
961
|
function rowHelperImplementation(info, instance, repository, edp, remult, _isNew) {
|
|
773
|
-
var
|
|
962
|
+
var e_15, _a;
|
|
774
963
|
var _this = _super.call(this, info.columnsInfo, instance, remult) || this;
|
|
775
964
|
_this.info = info;
|
|
776
965
|
_this.repository = repository;
|
|
@@ -791,14 +980,18 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
791
980
|
}
|
|
792
981
|
}
|
|
793
982
|
}
|
|
794
|
-
catch (
|
|
983
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
795
984
|
finally {
|
|
796
985
|
try {
|
|
797
986
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
798
987
|
}
|
|
799
|
-
finally { if (
|
|
988
|
+
finally { if (e_15) throw e_15.error; }
|
|
800
989
|
}
|
|
801
990
|
}
|
|
991
|
+
if (_this.info.options.entityRefInit)
|
|
992
|
+
_this.info.options.entityRefInit(_this, instance);
|
|
993
|
+
if (context_1.Remult.entityRefInit)
|
|
994
|
+
context_1.Remult.entityRefInit(_this, instance);
|
|
802
995
|
return _this;
|
|
803
996
|
}
|
|
804
997
|
Object.defineProperty(rowHelperImplementation.prototype, "apiUpdateAllowed", {
|
|
@@ -823,11 +1016,13 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
823
1016
|
return this.instance[this.info.idMetadata.field.key];
|
|
824
1017
|
};
|
|
825
1018
|
rowHelperImplementation.prototype.wasDeleted = function () {
|
|
1019
|
+
this._reportObserved();
|
|
826
1020
|
return this._wasDeleted;
|
|
827
1021
|
};
|
|
828
1022
|
rowHelperImplementation.prototype.undoChanges = function () {
|
|
829
1023
|
this.loadDataFrom(this.originalValues);
|
|
830
1024
|
this.__clearErrors();
|
|
1025
|
+
this._reportChanged();
|
|
831
1026
|
};
|
|
832
1027
|
rowHelperImplementation.prototype.reload = function () {
|
|
833
1028
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -847,6 +1042,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
847
1042
|
}); })];
|
|
848
1043
|
case 1:
|
|
849
1044
|
_a.sent();
|
|
1045
|
+
this._reportChanged();
|
|
850
1046
|
return [2 /*return*/, this.instance];
|
|
851
1047
|
}
|
|
852
1048
|
});
|
|
@@ -854,7 +1050,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
854
1050
|
};
|
|
855
1051
|
Object.defineProperty(rowHelperImplementation.prototype, "fields", {
|
|
856
1052
|
get: function () {
|
|
857
|
-
var _a,
|
|
1053
|
+
var _a, e_16, _b;
|
|
858
1054
|
if (!this._columns) {
|
|
859
1055
|
var _items_1 = [];
|
|
860
1056
|
var r_1 = (_a = {
|
|
@@ -868,12 +1064,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
868
1064
|
_items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
|
|
869
1065
|
}
|
|
870
1066
|
}
|
|
871
|
-
catch (
|
|
1067
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
872
1068
|
finally {
|
|
873
1069
|
try {
|
|
874
1070
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
875
1071
|
}
|
|
876
|
-
finally { if (
|
|
1072
|
+
finally { if (e_16) throw e_16.error; }
|
|
877
1073
|
}
|
|
878
1074
|
this._columns = r_1;
|
|
879
1075
|
}
|
|
@@ -884,30 +1080,55 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
884
1080
|
});
|
|
885
1081
|
rowHelperImplementation.prototype.save = function () {
|
|
886
1082
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
887
|
-
var
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1083
|
+
var doNotSave_1, d, ignoreKeys, _a, _b, field, f, updatedRow, changesOnly, wasChanged, key, element, err_1;
|
|
1084
|
+
var e_17, _c;
|
|
1085
|
+
return tslib_1.__generator(this, function (_d) {
|
|
1086
|
+
switch (_d.label) {
|
|
1087
|
+
case 0:
|
|
1088
|
+
_d.trys.push([0, , 17, 18]);
|
|
1089
|
+
this.isLoading = true;
|
|
1090
|
+
return [4 /*yield*/, this.__validateEntity()];
|
|
891
1091
|
case 1:
|
|
892
|
-
|
|
893
|
-
|
|
1092
|
+
_d.sent();
|
|
1093
|
+
doNotSave_1 = false;
|
|
894
1094
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 3];
|
|
895
|
-
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return
|
|
1095
|
+
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
|
|
896
1096
|
case 2:
|
|
897
|
-
|
|
898
|
-
|
|
1097
|
+
_d.sent();
|
|
1098
|
+
_d.label = 3;
|
|
899
1099
|
case 3:
|
|
900
1100
|
this.__assertValidity();
|
|
901
1101
|
d = this.copyDataToObject();
|
|
1102
|
+
ignoreKeys = [];
|
|
1103
|
+
try {
|
|
1104
|
+
for (_a = tslib_1.__values(this.metadata.fields), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1105
|
+
field = _b.value;
|
|
1106
|
+
if (field.dbReadOnly || field == this.metadata.idMetadata.field && this.metadata.options.dbAutoIncrementId) {
|
|
1107
|
+
d[field.key] = undefined;
|
|
1108
|
+
ignoreKeys.push(field.key);
|
|
1109
|
+
f = this.fields.find(field);
|
|
1110
|
+
f.value = f.originalValue;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1115
|
+
finally {
|
|
1116
|
+
try {
|
|
1117
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1118
|
+
}
|
|
1119
|
+
finally { if (e_17) throw e_17.error; }
|
|
1120
|
+
}
|
|
902
1121
|
if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
|
|
903
1122
|
d.id = undefined;
|
|
904
|
-
|
|
1123
|
+
updatedRow = void 0;
|
|
1124
|
+
_d.label = 4;
|
|
905
1125
|
case 4:
|
|
906
|
-
|
|
1126
|
+
_d.trys.push([4, 14, , 16]);
|
|
1127
|
+
this._reportChanged();
|
|
907
1128
|
if (!this.isNew()) return [3 /*break*/, 6];
|
|
908
1129
|
return [4 /*yield*/, this.edp.insert(d)];
|
|
909
1130
|
case 5:
|
|
910
|
-
updatedRow =
|
|
1131
|
+
updatedRow = _d.sent();
|
|
911
1132
|
return [3 /*break*/, 10];
|
|
912
1133
|
case 6:
|
|
913
1134
|
changesOnly = {};
|
|
@@ -915,7 +1136,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
915
1136
|
for (key in d) {
|
|
916
1137
|
if (Object.prototype.hasOwnProperty.call(d, key)) {
|
|
917
1138
|
element = d[key];
|
|
918
|
-
if (element !== this.originalValues[key]) {
|
|
1139
|
+
if (element !== this.originalValues[key] && !ignoreKeys.includes(key)) {
|
|
919
1140
|
changesOnly[key] = element;
|
|
920
1141
|
wasChanged = true;
|
|
921
1142
|
}
|
|
@@ -923,34 +1144,39 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
923
1144
|
}
|
|
924
1145
|
if (!wasChanged)
|
|
925
1146
|
return [2 /*return*/, this.instance];
|
|
926
|
-
if (!
|
|
1147
|
+
if (!doNotSave_1) return [3 /*break*/, 8];
|
|
927
1148
|
return [4 /*yield*/, this.edp.find({ where: this.getIdFilter() })];
|
|
928
1149
|
case 7:
|
|
929
|
-
updatedRow = (
|
|
1150
|
+
updatedRow = (_d.sent())[0];
|
|
930
1151
|
return [3 /*break*/, 10];
|
|
931
1152
|
case 8: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
932
1153
|
case 9:
|
|
933
|
-
updatedRow =
|
|
934
|
-
|
|
1154
|
+
updatedRow = _d.sent();
|
|
1155
|
+
_d.label = 10;
|
|
935
1156
|
case 10: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
936
1157
|
case 11:
|
|
937
|
-
|
|
1158
|
+
_d.sent();
|
|
938
1159
|
if (!this.info.entityInfo.saved) return [3 /*break*/, 13];
|
|
939
1160
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance)];
|
|
940
1161
|
case 12:
|
|
941
|
-
|
|
942
|
-
|
|
1162
|
+
_d.sent();
|
|
1163
|
+
_d.label = 13;
|
|
943
1164
|
case 13:
|
|
944
1165
|
this.saveOriginalData();
|
|
945
1166
|
this._isNew = false;
|
|
946
1167
|
return [2 /*return*/, this.instance];
|
|
947
1168
|
case 14:
|
|
948
|
-
err_1 =
|
|
1169
|
+
err_1 = _d.sent();
|
|
949
1170
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
950
1171
|
case 15:
|
|
951
|
-
|
|
1172
|
+
_d.sent();
|
|
952
1173
|
return [3 /*break*/, 16];
|
|
953
|
-
case 16: return [
|
|
1174
|
+
case 16: return [3 /*break*/, 18];
|
|
1175
|
+
case 17:
|
|
1176
|
+
this.isLoading = false;
|
|
1177
|
+
this._reportChanged();
|
|
1178
|
+
return [7 /*endfinally*/];
|
|
1179
|
+
case 18: return [2 /*return*/];
|
|
954
1180
|
}
|
|
955
1181
|
});
|
|
956
1182
|
});
|
|
@@ -960,8 +1186,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
960
1186
|
};
|
|
961
1187
|
rowHelperImplementation.prototype.delete = function () {
|
|
962
1188
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
963
|
-
var _a, _b, listener,
|
|
964
|
-
var
|
|
1189
|
+
var _a, _b, listener, e_18_1, err_2;
|
|
1190
|
+
var e_18, _c;
|
|
965
1191
|
return tslib_1.__generator(this, function (_d) {
|
|
966
1192
|
switch (_d.label) {
|
|
967
1193
|
case 0:
|
|
@@ -1003,14 +1229,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1003
1229
|
return [3 /*break*/, 8];
|
|
1004
1230
|
case 11: return [3 /*break*/, 14];
|
|
1005
1231
|
case 12:
|
|
1006
|
-
|
|
1007
|
-
|
|
1232
|
+
e_18_1 = _d.sent();
|
|
1233
|
+
e_18 = { error: e_18_1 };
|
|
1008
1234
|
return [3 /*break*/, 14];
|
|
1009
1235
|
case 13:
|
|
1010
1236
|
try {
|
|
1011
1237
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1012
1238
|
}
|
|
1013
|
-
finally { if (
|
|
1239
|
+
finally { if (e_18) throw e_18.error; }
|
|
1014
1240
|
return [7 /*endfinally*/];
|
|
1015
1241
|
case 14:
|
|
1016
1242
|
this._wasDeleted = true;
|
|
@@ -1028,8 +1254,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1028
1254
|
};
|
|
1029
1255
|
rowHelperImplementation.prototype.loadDataFrom = function (data, loadItems) {
|
|
1030
1256
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1031
|
-
var _a, _b, col, lu,
|
|
1032
|
-
var
|
|
1257
|
+
var _a, _b, col, lu, e_19_1;
|
|
1258
|
+
var e_19, _c;
|
|
1033
1259
|
return tslib_1.__generator(this, function (_d) {
|
|
1034
1260
|
switch (_d.label) {
|
|
1035
1261
|
case 0:
|
|
@@ -1064,14 +1290,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1064
1290
|
return [3 /*break*/, 1];
|
|
1065
1291
|
case 9: return [3 /*break*/, 12];
|
|
1066
1292
|
case 10:
|
|
1067
|
-
|
|
1068
|
-
|
|
1293
|
+
e_19_1 = _d.sent();
|
|
1294
|
+
e_19 = { error: e_19_1 };
|
|
1069
1295
|
return [3 /*break*/, 12];
|
|
1070
1296
|
case 11:
|
|
1071
1297
|
try {
|
|
1072
1298
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1073
1299
|
}
|
|
1074
|
-
finally { if (
|
|
1300
|
+
finally { if (e_19) throw e_19.error; }
|
|
1075
1301
|
return [7 /*endfinally*/];
|
|
1076
1302
|
case 12: return [4 /*yield*/, this.calcServerExpression()];
|
|
1077
1303
|
case 13:
|
|
@@ -1091,8 +1317,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1091
1317
|
};
|
|
1092
1318
|
rowHelperImplementation.prototype.calcServerExpression = function () {
|
|
1093
1319
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1094
|
-
var _a, _b, col, _c, _d,
|
|
1095
|
-
var
|
|
1320
|
+
var _a, _b, col, _c, _d, e_20_1;
|
|
1321
|
+
var e_20, _e;
|
|
1096
1322
|
return tslib_1.__generator(this, function (_f) {
|
|
1097
1323
|
switch (_f.label) {
|
|
1098
1324
|
case 0:
|
|
@@ -1117,14 +1343,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1117
1343
|
return [3 /*break*/, 2];
|
|
1118
1344
|
case 5: return [3 /*break*/, 8];
|
|
1119
1345
|
case 6:
|
|
1120
|
-
|
|
1121
|
-
|
|
1346
|
+
e_20_1 = _f.sent();
|
|
1347
|
+
e_20 = { error: e_20_1 };
|
|
1122
1348
|
return [3 /*break*/, 8];
|
|
1123
1349
|
case 7:
|
|
1124
1350
|
try {
|
|
1125
1351
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1126
1352
|
}
|
|
1127
|
-
finally { if (
|
|
1353
|
+
finally { if (e_20) throw e_20.error; }
|
|
1128
1354
|
return [7 /*endfinally*/];
|
|
1129
1355
|
case 8: return [2 /*return*/];
|
|
1130
1356
|
}
|
|
@@ -1132,10 +1358,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1132
1358
|
});
|
|
1133
1359
|
};
|
|
1134
1360
|
rowHelperImplementation.prototype.isNew = function () {
|
|
1361
|
+
this._reportObserved();
|
|
1135
1362
|
return this._isNew;
|
|
1136
1363
|
};
|
|
1137
1364
|
rowHelperImplementation.prototype.wasChanged = function () {
|
|
1138
|
-
var
|
|
1365
|
+
var e_21, _a;
|
|
1366
|
+
this._reportObserved();
|
|
1139
1367
|
try {
|
|
1140
1368
|
for (var _b = tslib_1.__values(this.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1141
1369
|
var col = _c.value;
|
|
@@ -1143,19 +1371,19 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1143
1371
|
return true;
|
|
1144
1372
|
}
|
|
1145
1373
|
}
|
|
1146
|
-
catch (
|
|
1374
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
1147
1375
|
finally {
|
|
1148
1376
|
try {
|
|
1149
1377
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1150
1378
|
}
|
|
1151
|
-
finally { if (
|
|
1379
|
+
finally { if (e_21) throw e_21.error; }
|
|
1152
1380
|
}
|
|
1153
1381
|
return false;
|
|
1154
1382
|
};
|
|
1155
1383
|
rowHelperImplementation.prototype.__performColumnAndEntityValidations = function () {
|
|
1156
1384
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1157
|
-
var _a, _b, c, col,
|
|
1158
|
-
var
|
|
1385
|
+
var _a, _b, c, col, e_22_1, _c, _d, listener, e_23_1;
|
|
1386
|
+
var e_22, _e, e_23, _f;
|
|
1159
1387
|
return tslib_1.__generator(this, function (_g) {
|
|
1160
1388
|
switch (_g.label) {
|
|
1161
1389
|
case 0:
|
|
@@ -1176,14 +1404,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1176
1404
|
return [3 /*break*/, 1];
|
|
1177
1405
|
case 4: return [3 /*break*/, 7];
|
|
1178
1406
|
case 5:
|
|
1179
|
-
|
|
1180
|
-
|
|
1407
|
+
e_22_1 = _g.sent();
|
|
1408
|
+
e_22 = { error: e_22_1 };
|
|
1181
1409
|
return [3 /*break*/, 7];
|
|
1182
1410
|
case 6:
|
|
1183
1411
|
try {
|
|
1184
1412
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1185
1413
|
}
|
|
1186
|
-
finally { if (
|
|
1414
|
+
finally { if (e_22) throw e_22.error; }
|
|
1187
1415
|
return [7 /*endfinally*/];
|
|
1188
1416
|
case 7:
|
|
1189
1417
|
if (!this.info.entityInfo.validation) return [3 /*break*/, 9];
|
|
@@ -1210,14 +1438,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1210
1438
|
return [3 /*break*/, 11];
|
|
1211
1439
|
case 14: return [3 /*break*/, 17];
|
|
1212
1440
|
case 15:
|
|
1213
|
-
|
|
1214
|
-
|
|
1441
|
+
e_23_1 = _g.sent();
|
|
1442
|
+
e_23 = { error: e_23_1 };
|
|
1215
1443
|
return [3 /*break*/, 17];
|
|
1216
1444
|
case 16:
|
|
1217
1445
|
try {
|
|
1218
1446
|
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
1219
1447
|
}
|
|
1220
|
-
finally { if (
|
|
1448
|
+
finally { if (e_23) throw e_23.error; }
|
|
1221
1449
|
return [7 /*endfinally*/];
|
|
1222
1450
|
case 17: return [2 /*return*/];
|
|
1223
1451
|
}
|
|
@@ -1259,7 +1487,7 @@ exports.getControllerRef = getControllerRef;
|
|
|
1259
1487
|
var controllerRefImpl = /** @class */ (function (_super) {
|
|
1260
1488
|
tslib_1.__extends(controllerRefImpl, _super);
|
|
1261
1489
|
function controllerRefImpl(columnsInfo, instance, remult) {
|
|
1262
|
-
var _a,
|
|
1490
|
+
var _a, e_24, _b;
|
|
1263
1491
|
var _this = _super.call(this, columnsInfo, instance, remult) || this;
|
|
1264
1492
|
var _items = [];
|
|
1265
1493
|
var r = (_a = {
|
|
@@ -1273,20 +1501,20 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1273
1501
|
_items.push(r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this));
|
|
1274
1502
|
}
|
|
1275
1503
|
}
|
|
1276
|
-
catch (
|
|
1504
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
1277
1505
|
finally {
|
|
1278
1506
|
try {
|
|
1279
1507
|
if (columnsInfo_2_1 && !columnsInfo_2_1.done && (_b = columnsInfo_2.return)) _b.call(columnsInfo_2);
|
|
1280
1508
|
}
|
|
1281
|
-
finally { if (
|
|
1509
|
+
finally { if (e_24) throw e_24.error; }
|
|
1282
1510
|
}
|
|
1283
1511
|
_this.fields = r;
|
|
1284
1512
|
return _this;
|
|
1285
1513
|
}
|
|
1286
1514
|
controllerRefImpl.prototype.__performColumnAndEntityValidations = function () {
|
|
1287
1515
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1288
|
-
var _a, _b, col,
|
|
1289
|
-
var
|
|
1516
|
+
var _a, _b, col, e_25_1;
|
|
1517
|
+
var e_25, _c;
|
|
1290
1518
|
return tslib_1.__generator(this, function (_d) {
|
|
1291
1519
|
switch (_d.label) {
|
|
1292
1520
|
case 0:
|
|
@@ -1306,14 +1534,14 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1306
1534
|
return [3 /*break*/, 1];
|
|
1307
1535
|
case 4: return [3 /*break*/, 7];
|
|
1308
1536
|
case 5:
|
|
1309
|
-
|
|
1310
|
-
|
|
1537
|
+
e_25_1 = _d.sent();
|
|
1538
|
+
e_25 = { error: e_25_1 };
|
|
1311
1539
|
return [3 /*break*/, 7];
|
|
1312
1540
|
case 6:
|
|
1313
1541
|
try {
|
|
1314
1542
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1315
1543
|
}
|
|
1316
|
-
finally { if (
|
|
1544
|
+
finally { if (e_25) throw e_25.error; }
|
|
1317
1545
|
return [7 /*endfinally*/];
|
|
1318
1546
|
case 7: return [2 /*return*/];
|
|
1319
1547
|
}
|
|
@@ -1334,6 +1562,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1334
1562
|
this.entityRef = this.helper;
|
|
1335
1563
|
}
|
|
1336
1564
|
FieldRefImplementation.prototype.valueIsNull = function () {
|
|
1565
|
+
this.rowBase._reportObserved();
|
|
1337
1566
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1338
1567
|
if (lu) {
|
|
1339
1568
|
return lu.id === undefined || lu.id === null;
|
|
@@ -1341,6 +1570,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1341
1570
|
return this.value === null;
|
|
1342
1571
|
};
|
|
1343
1572
|
FieldRefImplementation.prototype.originalValueIsNull = function () {
|
|
1573
|
+
this.rowBase._reportObserved();
|
|
1344
1574
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1345
1575
|
return this.rawOriginalValue() === null;
|
|
1346
1576
|
};
|
|
@@ -1366,6 +1596,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1366
1596
|
};
|
|
1367
1597
|
Object.defineProperty(FieldRefImplementation.prototype, "error", {
|
|
1368
1598
|
get: function () {
|
|
1599
|
+
this.rowBase._reportObserved();
|
|
1369
1600
|
if (!this.rowBase.errors)
|
|
1370
1601
|
return undefined;
|
|
1371
1602
|
return this.rowBase.errors[this.metadata.key];
|
|
@@ -1374,12 +1605,14 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1374
1605
|
if (!this.rowBase.errors)
|
|
1375
1606
|
this.rowBase.errors = {};
|
|
1376
1607
|
this.rowBase.errors[this.metadata.key] = error;
|
|
1608
|
+
this.rowBase._reportChanged();
|
|
1377
1609
|
},
|
|
1378
1610
|
enumerable: false,
|
|
1379
1611
|
configurable: true
|
|
1380
1612
|
});
|
|
1381
1613
|
Object.defineProperty(FieldRefImplementation.prototype, "displayValue", {
|
|
1382
1614
|
get: function () {
|
|
1615
|
+
this.rowBase._reportObserved();
|
|
1383
1616
|
if (this.value != undefined) {
|
|
1384
1617
|
if (this.settings.displayValue)
|
|
1385
1618
|
return this.settings.displayValue(this.container, this.value);
|
|
@@ -1404,6 +1637,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1404
1637
|
;
|
|
1405
1638
|
Object.defineProperty(FieldRefImplementation.prototype, "originalValue", {
|
|
1406
1639
|
get: function () {
|
|
1640
|
+
this.rowBase._reportObserved();
|
|
1407
1641
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1408
1642
|
if (lu)
|
|
1409
1643
|
return lu.get(this.rawOriginalValue());
|
|
@@ -1418,6 +1652,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1418
1652
|
};
|
|
1419
1653
|
Object.defineProperty(FieldRefImplementation.prototype, "inputValue", {
|
|
1420
1654
|
get: function () {
|
|
1655
|
+
this.rowBase._reportObserved();
|
|
1421
1656
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1422
1657
|
if (lu)
|
|
1423
1658
|
return lu.id != undefined ? lu.id.toString() : null;
|
|
@@ -1436,6 +1671,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1436
1671
|
});
|
|
1437
1672
|
;
|
|
1438
1673
|
FieldRefImplementation.prototype.valueChanged = function () {
|
|
1674
|
+
this.rowBase._reportObserved();
|
|
1439
1675
|
var val = this.value;
|
|
1440
1676
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1441
1677
|
if (lu) {
|
|
@@ -1445,8 +1681,8 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1445
1681
|
};
|
|
1446
1682
|
FieldRefImplementation.prototype.__performValidation = function () {
|
|
1447
1683
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1448
|
-
var x, _a, _b, v,
|
|
1449
|
-
var
|
|
1684
|
+
var x, _a, _b, v, e_26_1;
|
|
1685
|
+
var e_26, _c;
|
|
1450
1686
|
return tslib_1.__generator(this, function (_d) {
|
|
1451
1687
|
switch (_d.label) {
|
|
1452
1688
|
case 0:
|
|
@@ -1469,14 +1705,14 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1469
1705
|
return [3 /*break*/, 2];
|
|
1470
1706
|
case 5: return [3 /*break*/, 8];
|
|
1471
1707
|
case 6:
|
|
1472
|
-
|
|
1473
|
-
|
|
1708
|
+
e_26_1 = _d.sent();
|
|
1709
|
+
e_26 = { error: e_26_1 };
|
|
1474
1710
|
return [3 /*break*/, 8];
|
|
1475
1711
|
case 7:
|
|
1476
1712
|
try {
|
|
1477
1713
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1478
1714
|
}
|
|
1479
|
-
finally { if (
|
|
1715
|
+
finally { if (e_26) throw e_26.error; }
|
|
1480
1716
|
return [7 /*endfinally*/];
|
|
1481
1717
|
case 8: return [3 /*break*/, 11];
|
|
1482
1718
|
case 9:
|
|
@@ -1603,7 +1839,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
1603
1839
|
exports.columnDefsImpl = columnDefsImpl;
|
|
1604
1840
|
var EntityFullInfo = /** @class */ (function () {
|
|
1605
1841
|
function EntityFullInfo(columnsInfo, entityInfo, remult, entityType, key) {
|
|
1606
|
-
var _a,
|
|
1842
|
+
var _a, e_27, _b;
|
|
1607
1843
|
var _this = this;
|
|
1608
1844
|
this.columnsInfo = columnsInfo;
|
|
1609
1845
|
this.entityInfo = entityInfo;
|
|
@@ -1622,14 +1858,26 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
1622
1858
|
isIdField: function (col) {
|
|
1623
1859
|
return col.key == _this.idMetadata.field.key;
|
|
1624
1860
|
},
|
|
1625
|
-
getIdFilter: function (
|
|
1626
|
-
var _a;
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1861
|
+
getIdFilter: function () {
|
|
1862
|
+
var _a, _b;
|
|
1863
|
+
var ids = [];
|
|
1864
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1865
|
+
ids[_i] = arguments[_i];
|
|
1866
|
+
}
|
|
1867
|
+
if (_this.idMetadata.field instanceof column_1.CompoundIdField) {
|
|
1868
|
+
var field_1 = _this.idMetadata.field;
|
|
1869
|
+
return {
|
|
1870
|
+
$or: ids.map(function (x) { return field_1.isEqualTo(x); })
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
if (ids.length == 1)
|
|
1630
1874
|
return _a = {},
|
|
1631
|
-
_a[_this.idMetadata.field.key] =
|
|
1875
|
+
_a[_this.idMetadata.field.key] = ids[0],
|
|
1632
1876
|
_a;
|
|
1877
|
+
else
|
|
1878
|
+
return _b = {},
|
|
1879
|
+
_b[_this.idMetadata.field.key] = ids,
|
|
1880
|
+
_b;
|
|
1633
1881
|
}
|
|
1634
1882
|
};
|
|
1635
1883
|
if (this.options.allowApiCrud !== undefined) {
|
|
@@ -1660,12 +1908,12 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
1660
1908
|
_items.push(r[x.key] = new columnDefsImpl(x, this, remult));
|
|
1661
1909
|
}
|
|
1662
1910
|
}
|
|
1663
|
-
catch (
|
|
1911
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
1664
1912
|
finally {
|
|
1665
1913
|
try {
|
|
1666
1914
|
if (columnsInfo_3_1 && !columnsInfo_3_1.done && (_b = columnsInfo_3.return)) _b.call(columnsInfo_3);
|
|
1667
1915
|
}
|
|
1668
|
-
finally { if (
|
|
1916
|
+
finally { if (e_27) throw e_27.error; }
|
|
1669
1917
|
}
|
|
1670
1918
|
this.fields = r;
|
|
1671
1919
|
this.dbAutoIncrementId = entityInfo.dbAutoIncrementId;
|
|
@@ -1832,7 +2080,7 @@ function Field() {
|
|
|
1832
2080
|
exports.Field = Field;
|
|
1833
2081
|
var storableMember = Symbol("storableMember");
|
|
1834
2082
|
function buildOptions(options, remult) {
|
|
1835
|
-
var
|
|
2083
|
+
var e_28, _a;
|
|
1836
2084
|
var r = {};
|
|
1837
2085
|
try {
|
|
1838
2086
|
for (var options_1 = tslib_1.__values(options), options_1_1 = options_1.next(); !options_1_1.done; options_1_1 = options_1.next()) {
|
|
@@ -1845,12 +2093,12 @@ function buildOptions(options, remult) {
|
|
|
1845
2093
|
}
|
|
1846
2094
|
}
|
|
1847
2095
|
}
|
|
1848
|
-
catch (
|
|
2096
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1849
2097
|
finally {
|
|
1850
2098
|
try {
|
|
1851
2099
|
if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
|
|
1852
2100
|
}
|
|
1853
|
-
finally { if (
|
|
2101
|
+
finally { if (e_28) throw e_28.error; }
|
|
1854
2102
|
}
|
|
1855
2103
|
return r;
|
|
1856
2104
|
}
|
|
@@ -1933,7 +2181,7 @@ function Entity(key) {
|
|
|
1933
2181
|
}
|
|
1934
2182
|
}
|
|
1935
2183
|
var factory = function (remult) {
|
|
1936
|
-
var
|
|
2184
|
+
var e_29, _a;
|
|
1937
2185
|
var r = {};
|
|
1938
2186
|
try {
|
|
1939
2187
|
for (var options_2 = tslib_1.__values(options), options_2_1 = options_2.next(); !options_2_1.done; options_2_1 = options_2.next()) {
|
|
@@ -1946,12 +2194,12 @@ function Entity(key) {
|
|
|
1946
2194
|
}
|
|
1947
2195
|
}
|
|
1948
2196
|
}
|
|
1949
|
-
catch (
|
|
2197
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
1950
2198
|
finally {
|
|
1951
2199
|
try {
|
|
1952
2200
|
if (options_2_1 && !options_2_1.done && (_a = options_2.return)) _a.call(options_2);
|
|
1953
2201
|
}
|
|
1954
|
-
finally { if (
|
|
2202
|
+
finally { if (e_29) throw e_29.error; }
|
|
1955
2203
|
}
|
|
1956
2204
|
var base = Object.getPrototypeOf(target);
|
|
1957
2205
|
if (base) {
|
|
@@ -2040,9 +2288,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2040
2288
|
});
|
|
2041
2289
|
};
|
|
2042
2290
|
QueryResultImpl.prototype.forEach = function (what) {
|
|
2043
|
-
var
|
|
2291
|
+
var e_30, _a;
|
|
2044
2292
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2045
|
-
var i, _b, _c, x,
|
|
2293
|
+
var i, _b, _c, x, e_30_1;
|
|
2046
2294
|
return tslib_1.__generator(this, function (_d) {
|
|
2047
2295
|
switch (_d.label) {
|
|
2048
2296
|
case 0:
|
|
@@ -2064,8 +2312,8 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2064
2312
|
case 5: return [3 /*break*/, 2];
|
|
2065
2313
|
case 6: return [3 /*break*/, 13];
|
|
2066
2314
|
case 7:
|
|
2067
|
-
|
|
2068
|
-
|
|
2315
|
+
e_30_1 = _d.sent();
|
|
2316
|
+
e_30 = { error: e_30_1 };
|
|
2069
2317
|
return [3 /*break*/, 13];
|
|
2070
2318
|
case 8:
|
|
2071
2319
|
_d.trys.push([8, , 11, 12]);
|
|
@@ -2076,7 +2324,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2076
2324
|
_d.label = 10;
|
|
2077
2325
|
case 10: return [3 /*break*/, 12];
|
|
2078
2326
|
case 11:
|
|
2079
|
-
if (
|
|
2327
|
+
if (e_30) throw e_30.error;
|
|
2080
2328
|
return [7 /*endfinally*/];
|
|
2081
2329
|
case 12: return [7 /*endfinally*/];
|
|
2082
2330
|
case 13: return [2 /*return*/, i];
|