remult 0.9.7 → 0.9.8
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.js +6 -3
- 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 +5 -1
- 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/remult3/RepositoryImplementation.d.ts +8 -2
- package/src/remult3/RepositoryImplementation.js +326 -125
- package/src/remult3/RepositoryImplementation.js.map +1 -1
- package/src/remult3/remult3.d.ts +3 -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);
|
|
@@ -529,28 +630,85 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
529
630
|
return lookup_1.item;
|
|
530
631
|
},
|
|
531
632
|
set: function (val) {
|
|
532
|
-
|
|
633
|
+
lookup_1.set(val);
|
|
634
|
+
_this._fire();
|
|
533
635
|
},
|
|
534
636
|
enumerable: true
|
|
535
637
|
});
|
|
536
638
|
instance[col.key] = val;
|
|
537
639
|
}
|
|
640
|
+
else {
|
|
641
|
+
}
|
|
538
642
|
};
|
|
539
643
|
var this_1 = this;
|
|
540
644
|
try {
|
|
541
645
|
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
646
|
var col = columnsInfo_1_1.value;
|
|
543
|
-
|
|
647
|
+
_loop_3(col);
|
|
544
648
|
}
|
|
545
649
|
}
|
|
546
|
-
catch (
|
|
650
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
547
651
|
finally {
|
|
548
652
|
try {
|
|
549
653
|
if (columnsInfo_1_1 && !columnsInfo_1_1.done && (_a = columnsInfo_1.return)) _a.call(columnsInfo_1);
|
|
550
654
|
}
|
|
551
|
-
finally { if (
|
|
655
|
+
finally { if (e_9) throw e_9.error; }
|
|
552
656
|
}
|
|
553
657
|
}
|
|
658
|
+
Object.defineProperty(rowHelperBase.prototype, "error", {
|
|
659
|
+
get: function () { return this._error; },
|
|
660
|
+
set: function (val) {
|
|
661
|
+
this._error = val;
|
|
662
|
+
this._fire();
|
|
663
|
+
},
|
|
664
|
+
enumerable: false,
|
|
665
|
+
configurable: true
|
|
666
|
+
});
|
|
667
|
+
rowHelperBase.prototype._fire = function () {
|
|
668
|
+
if (this._subscribers)
|
|
669
|
+
this._subscribers.forEach(function (x) { return x(); });
|
|
670
|
+
};
|
|
671
|
+
rowHelperBase.prototype.subscribe = function (listener) {
|
|
672
|
+
var e_10, _a;
|
|
673
|
+
var _this = this;
|
|
674
|
+
if (!this._subscribers) {
|
|
675
|
+
this._subscribers = [];
|
|
676
|
+
var _loop_4 = function (col) {
|
|
677
|
+
var ei = getEntitySettings(col.valueType, false);
|
|
678
|
+
if (ei && this_2.remult) {
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
var val_1 = this_2.instance[col.key];
|
|
682
|
+
Object.defineProperty(this_2.instance, col.key, {
|
|
683
|
+
get: function () {
|
|
684
|
+
return val_1;
|
|
685
|
+
},
|
|
686
|
+
set: function (value) {
|
|
687
|
+
val_1 = value;
|
|
688
|
+
_this._fire();
|
|
689
|
+
},
|
|
690
|
+
enumerable: true
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
var this_2 = this;
|
|
695
|
+
try {
|
|
696
|
+
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
697
|
+
var col = _c.value;
|
|
698
|
+
_loop_4(col);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
702
|
+
finally {
|
|
703
|
+
try {
|
|
704
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
705
|
+
}
|
|
706
|
+
finally { if (e_10) throw e_10.error; }
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
this._subscribers.push(listener);
|
|
710
|
+
return function () { return _this._subscribers = _this._subscribers.filter(function (x) { return x != listener; }); };
|
|
711
|
+
};
|
|
554
712
|
rowHelperBase.prototype.waitLoad = function () {
|
|
555
713
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
556
714
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -564,7 +722,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
564
722
|
});
|
|
565
723
|
};
|
|
566
724
|
rowHelperBase.prototype.__assertValidity = function () {
|
|
567
|
-
var
|
|
725
|
+
var e_11, _a;
|
|
568
726
|
if (!this.hasErrors()) {
|
|
569
727
|
var error = {
|
|
570
728
|
modelState: Object.assign({}, this.errors),
|
|
@@ -581,12 +739,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
581
739
|
}
|
|
582
740
|
}
|
|
583
741
|
}
|
|
584
|
-
catch (
|
|
742
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
585
743
|
finally {
|
|
586
744
|
try {
|
|
587
745
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
588
746
|
}
|
|
589
|
-
finally { if (
|
|
747
|
+
finally { if (e_11) throw e_11.error; }
|
|
590
748
|
}
|
|
591
749
|
}
|
|
592
750
|
throw error;
|
|
@@ -623,7 +781,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
623
781
|
return !!!this.error && this.errors == undefined;
|
|
624
782
|
};
|
|
625
783
|
rowHelperBase.prototype.copyDataToObject = function () {
|
|
626
|
-
var
|
|
784
|
+
var e_12, _a;
|
|
627
785
|
var d = {};
|
|
628
786
|
try {
|
|
629
787
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -642,12 +800,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
642
800
|
d[col.key] = val;
|
|
643
801
|
}
|
|
644
802
|
}
|
|
645
|
-
catch (
|
|
803
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
646
804
|
finally {
|
|
647
805
|
try {
|
|
648
806
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
649
807
|
}
|
|
650
|
-
finally { if (
|
|
808
|
+
finally { if (e_12) throw e_12.error; }
|
|
651
809
|
}
|
|
652
810
|
return d;
|
|
653
811
|
};
|
|
@@ -693,7 +851,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
693
851
|
});
|
|
694
852
|
};
|
|
695
853
|
rowHelperBase.prototype.toApiJson = function () {
|
|
696
|
-
var
|
|
854
|
+
var e_13, _a;
|
|
697
855
|
var result = {};
|
|
698
856
|
try {
|
|
699
857
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -718,19 +876,19 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
718
876
|
}
|
|
719
877
|
}
|
|
720
878
|
}
|
|
721
|
-
catch (
|
|
879
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
722
880
|
finally {
|
|
723
881
|
try {
|
|
724
882
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
725
883
|
}
|
|
726
|
-
finally { if (
|
|
884
|
+
finally { if (e_13) throw e_13.error; }
|
|
727
885
|
}
|
|
728
886
|
return result;
|
|
729
887
|
};
|
|
730
888
|
rowHelperBase.prototype._updateEntityBasedOnApi = function (body) {
|
|
731
889
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
732
890
|
var keys, _a, _b, col, lu;
|
|
733
|
-
var
|
|
891
|
+
var e_14, _c;
|
|
734
892
|
return tslib_1.__generator(this, function (_d) {
|
|
735
893
|
switch (_d.label) {
|
|
736
894
|
case 0:
|
|
@@ -750,12 +908,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
750
908
|
}
|
|
751
909
|
}
|
|
752
910
|
}
|
|
753
|
-
catch (
|
|
911
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
754
912
|
finally {
|
|
755
913
|
try {
|
|
756
914
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
757
915
|
}
|
|
758
|
-
finally { if (
|
|
916
|
+
finally { if (e_14) throw e_14.error; }
|
|
759
917
|
}
|
|
760
918
|
return [4 /*yield*/, Promise.all(tslib_1.__spread(this.fields).map(function (x) { return x.load(); }))];
|
|
761
919
|
case 1:
|
|
@@ -770,7 +928,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
770
928
|
var rowHelperImplementation = /** @class */ (function (_super) {
|
|
771
929
|
tslib_1.__extends(rowHelperImplementation, _super);
|
|
772
930
|
function rowHelperImplementation(info, instance, repository, edp, remult, _isNew) {
|
|
773
|
-
var
|
|
931
|
+
var e_15, _a;
|
|
774
932
|
var _this = _super.call(this, info.columnsInfo, instance, remult) || this;
|
|
775
933
|
_this.info = info;
|
|
776
934
|
_this.repository = repository;
|
|
@@ -791,12 +949,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
791
949
|
}
|
|
792
950
|
}
|
|
793
951
|
}
|
|
794
|
-
catch (
|
|
952
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
795
953
|
finally {
|
|
796
954
|
try {
|
|
797
955
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
798
956
|
}
|
|
799
|
-
finally { if (
|
|
957
|
+
finally { if (e_15) throw e_15.error; }
|
|
800
958
|
}
|
|
801
959
|
}
|
|
802
960
|
return _this;
|
|
@@ -854,7 +1012,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
854
1012
|
};
|
|
855
1013
|
Object.defineProperty(rowHelperImplementation.prototype, "fields", {
|
|
856
1014
|
get: function () {
|
|
857
|
-
var _a,
|
|
1015
|
+
var _a, e_16, _b;
|
|
858
1016
|
if (!this._columns) {
|
|
859
1017
|
var _items_1 = [];
|
|
860
1018
|
var r_1 = (_a = {
|
|
@@ -868,12 +1026,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
868
1026
|
_items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
|
|
869
1027
|
}
|
|
870
1028
|
}
|
|
871
|
-
catch (
|
|
1029
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
872
1030
|
finally {
|
|
873
1031
|
try {
|
|
874
1032
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
875
1033
|
}
|
|
876
|
-
finally { if (
|
|
1034
|
+
finally { if (e_16) throw e_16.error; }
|
|
877
1035
|
}
|
|
878
1036
|
this._columns = r_1;
|
|
879
1037
|
}
|
|
@@ -884,30 +1042,55 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
884
1042
|
});
|
|
885
1043
|
rowHelperImplementation.prototype.save = function () {
|
|
886
1044
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
887
|
-
var
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1045
|
+
var doNotSave_1, d, ignoreKeys, _a, _b, field, f, updatedRow, changesOnly, wasChanged, key, element, err_1;
|
|
1046
|
+
var e_17, _c;
|
|
1047
|
+
return tslib_1.__generator(this, function (_d) {
|
|
1048
|
+
switch (_d.label) {
|
|
1049
|
+
case 0:
|
|
1050
|
+
_d.trys.push([0, , 17, 18]);
|
|
1051
|
+
this.isLoading = true;
|
|
1052
|
+
return [4 /*yield*/, this.__validateEntity()];
|
|
891
1053
|
case 1:
|
|
892
|
-
|
|
893
|
-
|
|
1054
|
+
_d.sent();
|
|
1055
|
+
doNotSave_1 = false;
|
|
894
1056
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 3];
|
|
895
|
-
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return
|
|
1057
|
+
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
|
|
896
1058
|
case 2:
|
|
897
|
-
|
|
898
|
-
|
|
1059
|
+
_d.sent();
|
|
1060
|
+
_d.label = 3;
|
|
899
1061
|
case 3:
|
|
900
1062
|
this.__assertValidity();
|
|
901
1063
|
d = this.copyDataToObject();
|
|
1064
|
+
ignoreKeys = [];
|
|
1065
|
+
try {
|
|
1066
|
+
for (_a = tslib_1.__values(this.metadata.fields), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1067
|
+
field = _b.value;
|
|
1068
|
+
if (field.dbReadOnly || field == this.metadata.idMetadata.field && this.metadata.options.dbAutoIncrementId) {
|
|
1069
|
+
d[field.key] = undefined;
|
|
1070
|
+
ignoreKeys.push(field.key);
|
|
1071
|
+
f = this.fields.find(field);
|
|
1072
|
+
f.value = f.originalValue;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1077
|
+
finally {
|
|
1078
|
+
try {
|
|
1079
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1080
|
+
}
|
|
1081
|
+
finally { if (e_17) throw e_17.error; }
|
|
1082
|
+
}
|
|
902
1083
|
if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
|
|
903
1084
|
d.id = undefined;
|
|
904
|
-
|
|
1085
|
+
updatedRow = void 0;
|
|
1086
|
+
_d.label = 4;
|
|
905
1087
|
case 4:
|
|
906
|
-
|
|
1088
|
+
_d.trys.push([4, 14, , 16]);
|
|
1089
|
+
this._fire();
|
|
907
1090
|
if (!this.isNew()) return [3 /*break*/, 6];
|
|
908
1091
|
return [4 /*yield*/, this.edp.insert(d)];
|
|
909
1092
|
case 5:
|
|
910
|
-
updatedRow =
|
|
1093
|
+
updatedRow = _d.sent();
|
|
911
1094
|
return [3 /*break*/, 10];
|
|
912
1095
|
case 6:
|
|
913
1096
|
changesOnly = {};
|
|
@@ -915,7 +1098,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
915
1098
|
for (key in d) {
|
|
916
1099
|
if (Object.prototype.hasOwnProperty.call(d, key)) {
|
|
917
1100
|
element = d[key];
|
|
918
|
-
if (element !== this.originalValues[key]) {
|
|
1101
|
+
if (element !== this.originalValues[key] && !ignoreKeys.includes(key)) {
|
|
919
1102
|
changesOnly[key] = element;
|
|
920
1103
|
wasChanged = true;
|
|
921
1104
|
}
|
|
@@ -923,34 +1106,39 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
923
1106
|
}
|
|
924
1107
|
if (!wasChanged)
|
|
925
1108
|
return [2 /*return*/, this.instance];
|
|
926
|
-
if (!
|
|
1109
|
+
if (!doNotSave_1) return [3 /*break*/, 8];
|
|
927
1110
|
return [4 /*yield*/, this.edp.find({ where: this.getIdFilter() })];
|
|
928
1111
|
case 7:
|
|
929
|
-
updatedRow = (
|
|
1112
|
+
updatedRow = (_d.sent())[0];
|
|
930
1113
|
return [3 /*break*/, 10];
|
|
931
1114
|
case 8: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
932
1115
|
case 9:
|
|
933
|
-
updatedRow =
|
|
934
|
-
|
|
1116
|
+
updatedRow = _d.sent();
|
|
1117
|
+
_d.label = 10;
|
|
935
1118
|
case 10: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
936
1119
|
case 11:
|
|
937
|
-
|
|
1120
|
+
_d.sent();
|
|
938
1121
|
if (!this.info.entityInfo.saved) return [3 /*break*/, 13];
|
|
939
1122
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance)];
|
|
940
1123
|
case 12:
|
|
941
|
-
|
|
942
|
-
|
|
1124
|
+
_d.sent();
|
|
1125
|
+
_d.label = 13;
|
|
943
1126
|
case 13:
|
|
944
1127
|
this.saveOriginalData();
|
|
945
1128
|
this._isNew = false;
|
|
946
1129
|
return [2 /*return*/, this.instance];
|
|
947
1130
|
case 14:
|
|
948
|
-
err_1 =
|
|
1131
|
+
err_1 = _d.sent();
|
|
949
1132
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
950
1133
|
case 15:
|
|
951
|
-
|
|
1134
|
+
_d.sent();
|
|
952
1135
|
return [3 /*break*/, 16];
|
|
953
|
-
case 16: return [
|
|
1136
|
+
case 16: return [3 /*break*/, 18];
|
|
1137
|
+
case 17:
|
|
1138
|
+
this.isLoading = false;
|
|
1139
|
+
this._fire();
|
|
1140
|
+
return [7 /*endfinally*/];
|
|
1141
|
+
case 18: return [2 /*return*/];
|
|
954
1142
|
}
|
|
955
1143
|
});
|
|
956
1144
|
});
|
|
@@ -960,8 +1148,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
960
1148
|
};
|
|
961
1149
|
rowHelperImplementation.prototype.delete = function () {
|
|
962
1150
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
963
|
-
var _a, _b, listener,
|
|
964
|
-
var
|
|
1151
|
+
var _a, _b, listener, e_18_1, err_2;
|
|
1152
|
+
var e_18, _c;
|
|
965
1153
|
return tslib_1.__generator(this, function (_d) {
|
|
966
1154
|
switch (_d.label) {
|
|
967
1155
|
case 0:
|
|
@@ -1003,14 +1191,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1003
1191
|
return [3 /*break*/, 8];
|
|
1004
1192
|
case 11: return [3 /*break*/, 14];
|
|
1005
1193
|
case 12:
|
|
1006
|
-
|
|
1007
|
-
|
|
1194
|
+
e_18_1 = _d.sent();
|
|
1195
|
+
e_18 = { error: e_18_1 };
|
|
1008
1196
|
return [3 /*break*/, 14];
|
|
1009
1197
|
case 13:
|
|
1010
1198
|
try {
|
|
1011
1199
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1012
1200
|
}
|
|
1013
|
-
finally { if (
|
|
1201
|
+
finally { if (e_18) throw e_18.error; }
|
|
1014
1202
|
return [7 /*endfinally*/];
|
|
1015
1203
|
case 14:
|
|
1016
1204
|
this._wasDeleted = true;
|
|
@@ -1028,8 +1216,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1028
1216
|
};
|
|
1029
1217
|
rowHelperImplementation.prototype.loadDataFrom = function (data, loadItems) {
|
|
1030
1218
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1031
|
-
var _a, _b, col, lu,
|
|
1032
|
-
var
|
|
1219
|
+
var _a, _b, col, lu, e_19_1;
|
|
1220
|
+
var e_19, _c;
|
|
1033
1221
|
return tslib_1.__generator(this, function (_d) {
|
|
1034
1222
|
switch (_d.label) {
|
|
1035
1223
|
case 0:
|
|
@@ -1064,14 +1252,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1064
1252
|
return [3 /*break*/, 1];
|
|
1065
1253
|
case 9: return [3 /*break*/, 12];
|
|
1066
1254
|
case 10:
|
|
1067
|
-
|
|
1068
|
-
|
|
1255
|
+
e_19_1 = _d.sent();
|
|
1256
|
+
e_19 = { error: e_19_1 };
|
|
1069
1257
|
return [3 /*break*/, 12];
|
|
1070
1258
|
case 11:
|
|
1071
1259
|
try {
|
|
1072
1260
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1073
1261
|
}
|
|
1074
|
-
finally { if (
|
|
1262
|
+
finally { if (e_19) throw e_19.error; }
|
|
1075
1263
|
return [7 /*endfinally*/];
|
|
1076
1264
|
case 12: return [4 /*yield*/, this.calcServerExpression()];
|
|
1077
1265
|
case 13:
|
|
@@ -1091,8 +1279,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1091
1279
|
};
|
|
1092
1280
|
rowHelperImplementation.prototype.calcServerExpression = function () {
|
|
1093
1281
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1094
|
-
var _a, _b, col, _c, _d,
|
|
1095
|
-
var
|
|
1282
|
+
var _a, _b, col, _c, _d, e_20_1;
|
|
1283
|
+
var e_20, _e;
|
|
1096
1284
|
return tslib_1.__generator(this, function (_f) {
|
|
1097
1285
|
switch (_f.label) {
|
|
1098
1286
|
case 0:
|
|
@@ -1117,14 +1305,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1117
1305
|
return [3 /*break*/, 2];
|
|
1118
1306
|
case 5: return [3 /*break*/, 8];
|
|
1119
1307
|
case 6:
|
|
1120
|
-
|
|
1121
|
-
|
|
1308
|
+
e_20_1 = _f.sent();
|
|
1309
|
+
e_20 = { error: e_20_1 };
|
|
1122
1310
|
return [3 /*break*/, 8];
|
|
1123
1311
|
case 7:
|
|
1124
1312
|
try {
|
|
1125
1313
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1126
1314
|
}
|
|
1127
|
-
finally { if (
|
|
1315
|
+
finally { if (e_20) throw e_20.error; }
|
|
1128
1316
|
return [7 /*endfinally*/];
|
|
1129
1317
|
case 8: return [2 /*return*/];
|
|
1130
1318
|
}
|
|
@@ -1135,7 +1323,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1135
1323
|
return this._isNew;
|
|
1136
1324
|
};
|
|
1137
1325
|
rowHelperImplementation.prototype.wasChanged = function () {
|
|
1138
|
-
var
|
|
1326
|
+
var e_21, _a;
|
|
1139
1327
|
try {
|
|
1140
1328
|
for (var _b = tslib_1.__values(this.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1141
1329
|
var col = _c.value;
|
|
@@ -1143,19 +1331,19 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1143
1331
|
return true;
|
|
1144
1332
|
}
|
|
1145
1333
|
}
|
|
1146
|
-
catch (
|
|
1334
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
1147
1335
|
finally {
|
|
1148
1336
|
try {
|
|
1149
1337
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1150
1338
|
}
|
|
1151
|
-
finally { if (
|
|
1339
|
+
finally { if (e_21) throw e_21.error; }
|
|
1152
1340
|
}
|
|
1153
1341
|
return false;
|
|
1154
1342
|
};
|
|
1155
1343
|
rowHelperImplementation.prototype.__performColumnAndEntityValidations = function () {
|
|
1156
1344
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1157
|
-
var _a, _b, c, col,
|
|
1158
|
-
var
|
|
1345
|
+
var _a, _b, c, col, e_22_1, _c, _d, listener, e_23_1;
|
|
1346
|
+
var e_22, _e, e_23, _f;
|
|
1159
1347
|
return tslib_1.__generator(this, function (_g) {
|
|
1160
1348
|
switch (_g.label) {
|
|
1161
1349
|
case 0:
|
|
@@ -1176,14 +1364,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1176
1364
|
return [3 /*break*/, 1];
|
|
1177
1365
|
case 4: return [3 /*break*/, 7];
|
|
1178
1366
|
case 5:
|
|
1179
|
-
|
|
1180
|
-
|
|
1367
|
+
e_22_1 = _g.sent();
|
|
1368
|
+
e_22 = { error: e_22_1 };
|
|
1181
1369
|
return [3 /*break*/, 7];
|
|
1182
1370
|
case 6:
|
|
1183
1371
|
try {
|
|
1184
1372
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
1185
1373
|
}
|
|
1186
|
-
finally { if (
|
|
1374
|
+
finally { if (e_22) throw e_22.error; }
|
|
1187
1375
|
return [7 /*endfinally*/];
|
|
1188
1376
|
case 7:
|
|
1189
1377
|
if (!this.info.entityInfo.validation) return [3 /*break*/, 9];
|
|
@@ -1210,14 +1398,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1210
1398
|
return [3 /*break*/, 11];
|
|
1211
1399
|
case 14: return [3 /*break*/, 17];
|
|
1212
1400
|
case 15:
|
|
1213
|
-
|
|
1214
|
-
|
|
1401
|
+
e_23_1 = _g.sent();
|
|
1402
|
+
e_23 = { error: e_23_1 };
|
|
1215
1403
|
return [3 /*break*/, 17];
|
|
1216
1404
|
case 16:
|
|
1217
1405
|
try {
|
|
1218
1406
|
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
1219
1407
|
}
|
|
1220
|
-
finally { if (
|
|
1408
|
+
finally { if (e_23) throw e_23.error; }
|
|
1221
1409
|
return [7 /*endfinally*/];
|
|
1222
1410
|
case 17: return [2 /*return*/];
|
|
1223
1411
|
}
|
|
@@ -1259,7 +1447,7 @@ exports.getControllerRef = getControllerRef;
|
|
|
1259
1447
|
var controllerRefImpl = /** @class */ (function (_super) {
|
|
1260
1448
|
tslib_1.__extends(controllerRefImpl, _super);
|
|
1261
1449
|
function controllerRefImpl(columnsInfo, instance, remult) {
|
|
1262
|
-
var _a,
|
|
1450
|
+
var _a, e_24, _b;
|
|
1263
1451
|
var _this = _super.call(this, columnsInfo, instance, remult) || this;
|
|
1264
1452
|
var _items = [];
|
|
1265
1453
|
var r = (_a = {
|
|
@@ -1273,20 +1461,20 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1273
1461
|
_items.push(r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this));
|
|
1274
1462
|
}
|
|
1275
1463
|
}
|
|
1276
|
-
catch (
|
|
1464
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
1277
1465
|
finally {
|
|
1278
1466
|
try {
|
|
1279
1467
|
if (columnsInfo_2_1 && !columnsInfo_2_1.done && (_b = columnsInfo_2.return)) _b.call(columnsInfo_2);
|
|
1280
1468
|
}
|
|
1281
|
-
finally { if (
|
|
1469
|
+
finally { if (e_24) throw e_24.error; }
|
|
1282
1470
|
}
|
|
1283
1471
|
_this.fields = r;
|
|
1284
1472
|
return _this;
|
|
1285
1473
|
}
|
|
1286
1474
|
controllerRefImpl.prototype.__performColumnAndEntityValidations = function () {
|
|
1287
1475
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1288
|
-
var _a, _b, col,
|
|
1289
|
-
var
|
|
1476
|
+
var _a, _b, col, e_25_1;
|
|
1477
|
+
var e_25, _c;
|
|
1290
1478
|
return tslib_1.__generator(this, function (_d) {
|
|
1291
1479
|
switch (_d.label) {
|
|
1292
1480
|
case 0:
|
|
@@ -1306,14 +1494,14 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1306
1494
|
return [3 /*break*/, 1];
|
|
1307
1495
|
case 4: return [3 /*break*/, 7];
|
|
1308
1496
|
case 5:
|
|
1309
|
-
|
|
1310
|
-
|
|
1497
|
+
e_25_1 = _d.sent();
|
|
1498
|
+
e_25 = { error: e_25_1 };
|
|
1311
1499
|
return [3 /*break*/, 7];
|
|
1312
1500
|
case 6:
|
|
1313
1501
|
try {
|
|
1314
1502
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1315
1503
|
}
|
|
1316
|
-
finally { if (
|
|
1504
|
+
finally { if (e_25) throw e_25.error; }
|
|
1317
1505
|
return [7 /*endfinally*/];
|
|
1318
1506
|
case 7: return [2 /*return*/];
|
|
1319
1507
|
}
|
|
@@ -1374,6 +1562,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1374
1562
|
if (!this.rowBase.errors)
|
|
1375
1563
|
this.rowBase.errors = {};
|
|
1376
1564
|
this.rowBase.errors[this.metadata.key] = error;
|
|
1565
|
+
this.rowBase._fire();
|
|
1377
1566
|
},
|
|
1378
1567
|
enumerable: false,
|
|
1379
1568
|
configurable: true
|
|
@@ -1445,8 +1634,8 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1445
1634
|
};
|
|
1446
1635
|
FieldRefImplementation.prototype.__performValidation = function () {
|
|
1447
1636
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1448
|
-
var x, _a, _b, v,
|
|
1449
|
-
var
|
|
1637
|
+
var x, _a, _b, v, e_26_1;
|
|
1638
|
+
var e_26, _c;
|
|
1450
1639
|
return tslib_1.__generator(this, function (_d) {
|
|
1451
1640
|
switch (_d.label) {
|
|
1452
1641
|
case 0:
|
|
@@ -1469,14 +1658,14 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1469
1658
|
return [3 /*break*/, 2];
|
|
1470
1659
|
case 5: return [3 /*break*/, 8];
|
|
1471
1660
|
case 6:
|
|
1472
|
-
|
|
1473
|
-
|
|
1661
|
+
e_26_1 = _d.sent();
|
|
1662
|
+
e_26 = { error: e_26_1 };
|
|
1474
1663
|
return [3 /*break*/, 8];
|
|
1475
1664
|
case 7:
|
|
1476
1665
|
try {
|
|
1477
1666
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1478
1667
|
}
|
|
1479
|
-
finally { if (
|
|
1668
|
+
finally { if (e_26) throw e_26.error; }
|
|
1480
1669
|
return [7 /*endfinally*/];
|
|
1481
1670
|
case 8: return [3 /*break*/, 11];
|
|
1482
1671
|
case 9:
|
|
@@ -1603,7 +1792,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
1603
1792
|
exports.columnDefsImpl = columnDefsImpl;
|
|
1604
1793
|
var EntityFullInfo = /** @class */ (function () {
|
|
1605
1794
|
function EntityFullInfo(columnsInfo, entityInfo, remult, entityType, key) {
|
|
1606
|
-
var _a,
|
|
1795
|
+
var _a, e_27, _b;
|
|
1607
1796
|
var _this = this;
|
|
1608
1797
|
this.columnsInfo = columnsInfo;
|
|
1609
1798
|
this.entityInfo = entityInfo;
|
|
@@ -1622,14 +1811,26 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
1622
1811
|
isIdField: function (col) {
|
|
1623
1812
|
return col.key == _this.idMetadata.field.key;
|
|
1624
1813
|
},
|
|
1625
|
-
getIdFilter: function (
|
|
1626
|
-
var _a;
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1814
|
+
getIdFilter: function () {
|
|
1815
|
+
var _a, _b;
|
|
1816
|
+
var ids = [];
|
|
1817
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1818
|
+
ids[_i] = arguments[_i];
|
|
1819
|
+
}
|
|
1820
|
+
if (_this.idMetadata.field instanceof column_1.CompoundIdField) {
|
|
1821
|
+
var field_1 = _this.idMetadata.field;
|
|
1822
|
+
return {
|
|
1823
|
+
$or: ids.map(function (x) { return field_1.isEqualTo(x); })
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
if (ids.length == 1)
|
|
1630
1827
|
return _a = {},
|
|
1631
|
-
_a[_this.idMetadata.field.key] =
|
|
1828
|
+
_a[_this.idMetadata.field.key] = ids[0],
|
|
1632
1829
|
_a;
|
|
1830
|
+
else
|
|
1831
|
+
return _b = {},
|
|
1832
|
+
_b[_this.idMetadata.field.key] = ids,
|
|
1833
|
+
_b;
|
|
1633
1834
|
}
|
|
1634
1835
|
};
|
|
1635
1836
|
if (this.options.allowApiCrud !== undefined) {
|
|
@@ -1660,12 +1861,12 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
1660
1861
|
_items.push(r[x.key] = new columnDefsImpl(x, this, remult));
|
|
1661
1862
|
}
|
|
1662
1863
|
}
|
|
1663
|
-
catch (
|
|
1864
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
1664
1865
|
finally {
|
|
1665
1866
|
try {
|
|
1666
1867
|
if (columnsInfo_3_1 && !columnsInfo_3_1.done && (_b = columnsInfo_3.return)) _b.call(columnsInfo_3);
|
|
1667
1868
|
}
|
|
1668
|
-
finally { if (
|
|
1869
|
+
finally { if (e_27) throw e_27.error; }
|
|
1669
1870
|
}
|
|
1670
1871
|
this.fields = r;
|
|
1671
1872
|
this.dbAutoIncrementId = entityInfo.dbAutoIncrementId;
|
|
@@ -1832,7 +2033,7 @@ function Field() {
|
|
|
1832
2033
|
exports.Field = Field;
|
|
1833
2034
|
var storableMember = Symbol("storableMember");
|
|
1834
2035
|
function buildOptions(options, remult) {
|
|
1835
|
-
var
|
|
2036
|
+
var e_28, _a;
|
|
1836
2037
|
var r = {};
|
|
1837
2038
|
try {
|
|
1838
2039
|
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 +2046,12 @@ function buildOptions(options, remult) {
|
|
|
1845
2046
|
}
|
|
1846
2047
|
}
|
|
1847
2048
|
}
|
|
1848
|
-
catch (
|
|
2049
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1849
2050
|
finally {
|
|
1850
2051
|
try {
|
|
1851
2052
|
if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
|
|
1852
2053
|
}
|
|
1853
|
-
finally { if (
|
|
2054
|
+
finally { if (e_28) throw e_28.error; }
|
|
1854
2055
|
}
|
|
1855
2056
|
return r;
|
|
1856
2057
|
}
|
|
@@ -1933,7 +2134,7 @@ function Entity(key) {
|
|
|
1933
2134
|
}
|
|
1934
2135
|
}
|
|
1935
2136
|
var factory = function (remult) {
|
|
1936
|
-
var
|
|
2137
|
+
var e_29, _a;
|
|
1937
2138
|
var r = {};
|
|
1938
2139
|
try {
|
|
1939
2140
|
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 +2147,12 @@ function Entity(key) {
|
|
|
1946
2147
|
}
|
|
1947
2148
|
}
|
|
1948
2149
|
}
|
|
1949
|
-
catch (
|
|
2150
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
1950
2151
|
finally {
|
|
1951
2152
|
try {
|
|
1952
2153
|
if (options_2_1 && !options_2_1.done && (_a = options_2.return)) _a.call(options_2);
|
|
1953
2154
|
}
|
|
1954
|
-
finally { if (
|
|
2155
|
+
finally { if (e_29) throw e_29.error; }
|
|
1955
2156
|
}
|
|
1956
2157
|
var base = Object.getPrototypeOf(target);
|
|
1957
2158
|
if (base) {
|
|
@@ -2040,9 +2241,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2040
2241
|
});
|
|
2041
2242
|
};
|
|
2042
2243
|
QueryResultImpl.prototype.forEach = function (what) {
|
|
2043
|
-
var
|
|
2244
|
+
var e_30, _a;
|
|
2044
2245
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2045
|
-
var i, _b, _c, x,
|
|
2246
|
+
var i, _b, _c, x, e_30_1;
|
|
2046
2247
|
return tslib_1.__generator(this, function (_d) {
|
|
2047
2248
|
switch (_d.label) {
|
|
2048
2249
|
case 0:
|
|
@@ -2064,8 +2265,8 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2064
2265
|
case 5: return [3 /*break*/, 2];
|
|
2065
2266
|
case 6: return [3 /*break*/, 13];
|
|
2066
2267
|
case 7:
|
|
2067
|
-
|
|
2068
|
-
|
|
2268
|
+
e_30_1 = _d.sent();
|
|
2269
|
+
e_30 = { error: e_30_1 };
|
|
2069
2270
|
return [3 /*break*/, 13];
|
|
2070
2271
|
case 8:
|
|
2071
2272
|
_d.trys.push([8, , 11, 12]);
|
|
@@ -2076,7 +2277,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
2076
2277
|
_d.label = 10;
|
|
2077
2278
|
case 10: return [3 /*break*/, 12];
|
|
2078
2279
|
case 11:
|
|
2079
|
-
if (
|
|
2280
|
+
if (e_30) throw e_30.error;
|
|
2080
2281
|
return [7 /*endfinally*/];
|
|
2081
2282
|
case 12: return [7 /*endfinally*/];
|
|
2082
2283
|
case 13: return [2 /*return*/, i];
|