remult 0.9.27 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/column-interfaces.d.ts +2 -1
- package/src/column-interfaces.js.map +1 -1
- package/src/data-api.d.ts +1 -1
- package/src/data-interfaces.d.ts +4 -2
- package/src/filter/filter-interfaces.js +2 -0
- package/src/filter/filter-interfaces.js.map +1 -1
- package/src/remult3/RepositoryImplementation.d.ts +3 -1
- package/src/remult3/RepositoryImplementation.js +168 -135
- package/src/remult3/RepositoryImplementation.js.map +1 -1
- package/src/remult3/remult3.d.ts +22 -2
- package/src/server-action.js +14 -4
- package/src/server-action.js.map +1 -1
- package/src/tests/testModel/models.js +1 -1
- package/src/tests/testModel/models.js.map +1 -1
- package/valueConverters.js +1 -1
- package/valueConverters.js.map +1 -1
|
@@ -11,33 +11,23 @@ var valueConverters_1 = require("../../valueConverters");
|
|
|
11
11
|
var filter_interfaces_2 = require("../filter/filter-interfaces");
|
|
12
12
|
var assign_1 = require("../../assign");
|
|
13
13
|
var classValidatorValidate = undefined;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
if (errors_1_1 && !errors_1_1.done && (_a = errors_1.return)) _a.call(errors_1);
|
|
33
|
-
}
|
|
34
|
-
finally { if (e_1) throw e_1.error; }
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
})
|
|
39
|
-
.catch(function () {
|
|
40
|
-
});
|
|
14
|
+
// import("class-validator".toString())
|
|
15
|
+
// .then((v) => {
|
|
16
|
+
// classValidatorValidate = (item, ref) => {
|
|
17
|
+
// return v.validate(item).then(errors => {
|
|
18
|
+
// for (const err of errors) {
|
|
19
|
+
// for (const key in err.constraints) {
|
|
20
|
+
// if (Object.prototype.hasOwnProperty.call(err.constraints, key)) {
|
|
21
|
+
// const element = err.constraints[key];
|
|
22
|
+
// ref.fields.find(err.property).error = element;
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// });
|
|
27
|
+
// }
|
|
28
|
+
// })
|
|
29
|
+
// .catch(() => {
|
|
30
|
+
// });
|
|
41
31
|
var RepositoryImplementation = /** @class */ (function () {
|
|
42
32
|
function RepositoryImplementation(entity, remult, dataProvider) {
|
|
43
33
|
this.entity = entity;
|
|
@@ -50,7 +40,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
50
40
|
RepositoryImplementation.prototype.createAfterFilter = function (orderBy, lastRow) {
|
|
51
41
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
52
42
|
var values, _a, _b, s, existingVal, r, equalToColumn, _c, _d, s, ff, f, equalToColumn_1, equalToColumn_1_1, c;
|
|
53
|
-
var
|
|
43
|
+
var e_1, _e, e_2, _f, e_3, _g;
|
|
54
44
|
return tslib_1.__generator(this, function (_h) {
|
|
55
45
|
values = new Map();
|
|
56
46
|
try {
|
|
@@ -68,12 +58,12 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
68
58
|
values.set(s.field.key, existingVal);
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
|
-
catch (
|
|
61
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
72
62
|
finally {
|
|
73
63
|
try {
|
|
74
64
|
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
75
65
|
}
|
|
76
|
-
finally { if (
|
|
66
|
+
finally { if (e_1) throw e_1.error; }
|
|
77
67
|
}
|
|
78
68
|
r = { $or: [] };
|
|
79
69
|
equalToColumn = [];
|
|
@@ -83,17 +73,17 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
83
73
|
ff = new filter_interfaces_2.filterHelper(s.field);
|
|
84
74
|
f = {};
|
|
85
75
|
try {
|
|
86
|
-
for (equalToColumn_1 = (
|
|
76
|
+
for (equalToColumn_1 = (e_3 = void 0, tslib_1.__values(equalToColumn)), equalToColumn_1_1 = equalToColumn_1.next(); !equalToColumn_1_1.done; equalToColumn_1_1 = equalToColumn_1.next()) {
|
|
87
77
|
c = equalToColumn_1_1.value;
|
|
88
78
|
f[c.key] = values.get(c.key);
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
|
-
catch (
|
|
81
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
92
82
|
finally {
|
|
93
83
|
try {
|
|
94
84
|
if (equalToColumn_1_1 && !equalToColumn_1_1.done && (_g = equalToColumn_1.return)) _g.call(equalToColumn_1);
|
|
95
85
|
}
|
|
96
|
-
finally { if (
|
|
86
|
+
finally { if (e_3) throw e_3.error; }
|
|
97
87
|
}
|
|
98
88
|
equalToColumn.push(s.field);
|
|
99
89
|
if (s.isDescending) {
|
|
@@ -104,12 +94,12 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
104
94
|
r.$or.push(f);
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
|
-
catch (
|
|
97
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
108
98
|
finally {
|
|
109
99
|
try {
|
|
110
100
|
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
111
101
|
}
|
|
112
|
-
finally { if (
|
|
102
|
+
finally { if (e_2) throw e_2.error; }
|
|
113
103
|
}
|
|
114
104
|
return [2 /*return*/, r];
|
|
115
105
|
});
|
|
@@ -252,8 +242,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
252
242
|
};
|
|
253
243
|
RepositoryImplementation.prototype.find = function (options) {
|
|
254
244
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
255
|
-
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,
|
|
256
|
-
var
|
|
245
|
+
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;
|
|
246
|
+
var e_4, _d, e_5, _e, _f, e_6, _g;
|
|
257
247
|
var _this = this;
|
|
258
248
|
return tslib_1.__generator(this, function (_h) {
|
|
259
249
|
switch (_h.label) {
|
|
@@ -295,7 +285,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
295
285
|
repo = this.remult.repo(col.valueType);
|
|
296
286
|
toLoad = [];
|
|
297
287
|
try {
|
|
298
|
-
for (rawRows_1 = (
|
|
288
|
+
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()) {
|
|
299
289
|
r = rawRows_1_1.value;
|
|
300
290
|
val = r[col.key];
|
|
301
291
|
if (val !== undefined && val !== null && !toLoad.includes(val) && !repo.idCache.has(val)) {
|
|
@@ -303,29 +293,29 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
303
293
|
}
|
|
304
294
|
}
|
|
305
295
|
}
|
|
306
|
-
catch (
|
|
296
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
307
297
|
finally {
|
|
308
298
|
try {
|
|
309
299
|
if (rawRows_1_1 && !rawRows_1_1.done && (_e = rawRows_1.return)) _e.call(rawRows_1);
|
|
310
300
|
}
|
|
311
|
-
finally { if (
|
|
301
|
+
finally { if (e_5) throw e_5.error; }
|
|
312
302
|
}
|
|
313
303
|
if (!(toLoad.length > 0)) return [3 /*break*/, 6];
|
|
314
304
|
return [4 /*yield*/, repo.find({ where: (_f = repo.metadata.idMetadata).getIdFilter.apply(_f, tslib_1.__spread(toLoad)) })];
|
|
315
305
|
case 5:
|
|
316
306
|
rows = _h.sent();
|
|
317
307
|
try {
|
|
318
|
-
for (rows_1 = (
|
|
308
|
+
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()) {
|
|
319
309
|
r = rows_1_1.value;
|
|
320
310
|
repo.addToCache(r);
|
|
321
311
|
}
|
|
322
312
|
}
|
|
323
|
-
catch (
|
|
313
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
324
314
|
finally {
|
|
325
315
|
try {
|
|
326
316
|
if (rows_1_1 && !rows_1_1.done && (_g = rows_1.return)) _g.call(rows_1);
|
|
327
317
|
}
|
|
328
|
-
finally { if (
|
|
318
|
+
finally { if (e_6) throw e_6.error; }
|
|
329
319
|
}
|
|
330
320
|
_h.label = 6;
|
|
331
321
|
case 6:
|
|
@@ -333,14 +323,14 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
333
323
|
return [3 /*break*/, 4];
|
|
334
324
|
case 7: return [3 /*break*/, 10];
|
|
335
325
|
case 8:
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
e_4_1 = _h.sent();
|
|
327
|
+
e_4 = { error: e_4_1 };
|
|
338
328
|
return [3 /*break*/, 10];
|
|
339
329
|
case 9:
|
|
340
330
|
try {
|
|
341
331
|
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
342
332
|
}
|
|
343
|
-
finally { if (
|
|
333
|
+
finally { if (e_4) throw e_4.error; }
|
|
344
334
|
return [7 /*endfinally*/];
|
|
345
335
|
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) {
|
|
346
336
|
switch (_a.label) {
|
|
@@ -475,7 +465,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
475
465
|
RepositoryImplementation.prototype.fromJson = function (json, newRow) {
|
|
476
466
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
477
467
|
var obj, _a, _b, col, r, helper;
|
|
478
|
-
var
|
|
468
|
+
var e_7, _c;
|
|
479
469
|
return tslib_1.__generator(this, function (_d) {
|
|
480
470
|
switch (_d.label) {
|
|
481
471
|
case 0:
|
|
@@ -488,12 +478,12 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
488
478
|
}
|
|
489
479
|
}
|
|
490
480
|
}
|
|
491
|
-
catch (
|
|
481
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
492
482
|
finally {
|
|
493
483
|
try {
|
|
494
484
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
495
485
|
}
|
|
496
|
-
finally { if (
|
|
486
|
+
finally { if (e_7) throw e_7.error; }
|
|
497
487
|
}
|
|
498
488
|
if (!newRow) return [3 /*break*/, 2];
|
|
499
489
|
r = this.create();
|
|
@@ -597,7 +587,7 @@ function createOldEntity(entity, remult) {
|
|
|
597
587
|
var key = getEntityKey(entity);
|
|
598
588
|
var base = Object.getPrototypeOf(entity);
|
|
599
589
|
var _loop_1 = function () {
|
|
600
|
-
var
|
|
590
|
+
var e_8, _a;
|
|
601
591
|
var baseCols = exports.columnsOfType.get(base);
|
|
602
592
|
if (baseCols) {
|
|
603
593
|
r.unshift.apply(r, tslib_1.__spread(baseCols.filter(function (x) { return !r.find(function (y) { return y.key == x.key; }); })));
|
|
@@ -617,17 +607,17 @@ function createOldEntity(entity, remult) {
|
|
|
617
607
|
}
|
|
618
608
|
};
|
|
619
609
|
try {
|
|
620
|
-
for (var _b = (
|
|
610
|
+
for (var _b = (e_8 = void 0, tslib_1.__values(functions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
621
611
|
var key_1 = _c.value;
|
|
622
612
|
_loop_2(key_1);
|
|
623
613
|
}
|
|
624
614
|
}
|
|
625
|
-
catch (
|
|
615
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
626
616
|
finally {
|
|
627
617
|
try {
|
|
628
618
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
629
619
|
}
|
|
630
|
-
finally { if (
|
|
620
|
+
finally { if (e_8) throw e_8.error; }
|
|
631
621
|
}
|
|
632
622
|
}
|
|
633
623
|
base = Object.getPrototypeOf(base);
|
|
@@ -640,7 +630,7 @@ function createOldEntity(entity, remult) {
|
|
|
640
630
|
exports.createOldEntity = createOldEntity;
|
|
641
631
|
var rowHelperBase = /** @class */ (function () {
|
|
642
632
|
function rowHelperBase(columnsInfo, instance, remult) {
|
|
643
|
-
var
|
|
633
|
+
var e_9, _a;
|
|
644
634
|
var _this = this;
|
|
645
635
|
this.columnsInfo = columnsInfo;
|
|
646
636
|
this.instance = instance;
|
|
@@ -695,12 +685,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
695
685
|
_loop_3(col);
|
|
696
686
|
}
|
|
697
687
|
}
|
|
698
|
-
catch (
|
|
688
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
699
689
|
finally {
|
|
700
690
|
try {
|
|
701
691
|
if (columnsInfo_1_1 && !columnsInfo_1_1.done && (_a = columnsInfo_1.return)) _a.call(columnsInfo_1);
|
|
702
692
|
}
|
|
703
|
-
finally { if (
|
|
693
|
+
finally { if (e_9) throw e_9.error; }
|
|
704
694
|
}
|
|
705
695
|
}
|
|
706
696
|
Object.defineProperty(rowHelperBase.prototype, "error", {
|
|
@@ -722,7 +712,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
722
712
|
return this._subscribers.subscribe(listener);
|
|
723
713
|
};
|
|
724
714
|
rowHelperBase.prototype.initSubscribers = function () {
|
|
725
|
-
var
|
|
715
|
+
var e_10, _a;
|
|
726
716
|
var _this = this;
|
|
727
717
|
if (!this._subscribers) {
|
|
728
718
|
this._subscribers = new SubscribableImp();
|
|
@@ -757,12 +747,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
757
747
|
_loop_4(col);
|
|
758
748
|
}
|
|
759
749
|
}
|
|
760
|
-
catch (
|
|
750
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
761
751
|
finally {
|
|
762
752
|
try {
|
|
763
753
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
764
754
|
}
|
|
765
|
-
finally { if (
|
|
755
|
+
finally { if (e_10) throw e_10.error; }
|
|
766
756
|
}
|
|
767
757
|
}
|
|
768
758
|
};
|
|
@@ -793,7 +783,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
793
783
|
});
|
|
794
784
|
};
|
|
795
785
|
rowHelperBase.prototype.__assertValidity = function () {
|
|
796
|
-
var
|
|
786
|
+
var e_11, _a;
|
|
797
787
|
if (!this.hasErrors()) {
|
|
798
788
|
var error = {
|
|
799
789
|
modelState: Object.assign({}, this.errors),
|
|
@@ -810,12 +800,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
810
800
|
}
|
|
811
801
|
}
|
|
812
802
|
}
|
|
813
|
-
catch (
|
|
803
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
814
804
|
finally {
|
|
815
805
|
try {
|
|
816
806
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
817
807
|
}
|
|
818
|
-
finally { if (
|
|
808
|
+
finally { if (e_11) throw e_11.error; }
|
|
819
809
|
}
|
|
820
810
|
}
|
|
821
811
|
throw error;
|
|
@@ -850,7 +840,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
850
840
|
this._reportChangedToEntityAndFields();
|
|
851
841
|
};
|
|
852
842
|
rowHelperBase.prototype._reportChangedToEntityAndFields = function () {
|
|
853
|
-
var
|
|
843
|
+
var e_12, _a;
|
|
854
844
|
if (this._subscribers) {
|
|
855
845
|
this._subscribers.reportChanged();
|
|
856
846
|
try {
|
|
@@ -860,12 +850,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
860
850
|
ref._subscribers.reportChanged();
|
|
861
851
|
}
|
|
862
852
|
}
|
|
863
|
-
catch (
|
|
853
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
864
854
|
finally {
|
|
865
855
|
try {
|
|
866
856
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
867
857
|
}
|
|
868
|
-
finally { if (
|
|
858
|
+
finally { if (e_12) throw e_12.error; }
|
|
869
859
|
}
|
|
870
860
|
}
|
|
871
861
|
};
|
|
@@ -875,7 +865,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
875
865
|
return !!!this.error && this.errors == undefined;
|
|
876
866
|
};
|
|
877
867
|
rowHelperBase.prototype.copyDataToObject = function () {
|
|
878
|
-
var
|
|
868
|
+
var e_13, _a;
|
|
879
869
|
var d = {};
|
|
880
870
|
try {
|
|
881
871
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -888,18 +878,18 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
888
878
|
val = this.instance[col.key];
|
|
889
879
|
if (val !== undefined) {
|
|
890
880
|
val = col.valueConverter.toJson(val);
|
|
891
|
-
if (val !== undefined)
|
|
881
|
+
if (val !== undefined && val !== null)
|
|
892
882
|
val = col.valueConverter.fromJson(JSON.parse(JSON.stringify(val)));
|
|
893
883
|
}
|
|
894
884
|
d[col.key] = val;
|
|
895
885
|
}
|
|
896
886
|
}
|
|
897
|
-
catch (
|
|
887
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
898
888
|
finally {
|
|
899
889
|
try {
|
|
900
890
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
901
891
|
}
|
|
902
|
-
finally { if (
|
|
892
|
+
finally { if (e_13) throw e_13.error; }
|
|
903
893
|
}
|
|
904
894
|
return d;
|
|
905
895
|
};
|
|
@@ -955,7 +945,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
955
945
|
});
|
|
956
946
|
};
|
|
957
947
|
rowHelperBase.prototype.toApiJson = function () {
|
|
958
|
-
var
|
|
948
|
+
var e_14, _a;
|
|
959
949
|
var result = {};
|
|
960
950
|
try {
|
|
961
951
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -980,19 +970,19 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
980
970
|
}
|
|
981
971
|
}
|
|
982
972
|
}
|
|
983
|
-
catch (
|
|
973
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
984
974
|
finally {
|
|
985
975
|
try {
|
|
986
976
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
987
977
|
}
|
|
988
|
-
finally { if (
|
|
978
|
+
finally { if (e_14) throw e_14.error; }
|
|
989
979
|
}
|
|
990
980
|
return result;
|
|
991
981
|
};
|
|
992
982
|
rowHelperBase.prototype._updateEntityBasedOnApi = function (body) {
|
|
993
983
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
994
984
|
var keys, _a, _b, col, lu;
|
|
995
|
-
var
|
|
985
|
+
var e_15, _c;
|
|
996
986
|
return tslib_1.__generator(this, function (_d) {
|
|
997
987
|
switch (_d.label) {
|
|
998
988
|
case 0:
|
|
@@ -1012,12 +1002,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1012
1002
|
}
|
|
1013
1003
|
}
|
|
1014
1004
|
}
|
|
1015
|
-
catch (
|
|
1005
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1016
1006
|
finally {
|
|
1017
1007
|
try {
|
|
1018
1008
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1019
1009
|
}
|
|
1020
|
-
finally { if (
|
|
1010
|
+
finally { if (e_15) throw e_15.error; }
|
|
1021
1011
|
}
|
|
1022
1012
|
return [4 /*yield*/, Promise.all(tslib_1.__spread(this.fields).map(function (x) { return x.load(); }))];
|
|
1023
1013
|
case 1:
|
|
@@ -1032,13 +1022,14 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1032
1022
|
var rowHelperImplementation = /** @class */ (function (_super) {
|
|
1033
1023
|
tslib_1.__extends(rowHelperImplementation, _super);
|
|
1034
1024
|
function rowHelperImplementation(info, instance, repository, edp, remult, _isNew) {
|
|
1035
|
-
var
|
|
1025
|
+
var e_16, _a;
|
|
1036
1026
|
var _this = _super.call(this, info.columnsInfo, instance, remult) || this;
|
|
1037
1027
|
_this.info = info;
|
|
1038
1028
|
_this.repository = repository;
|
|
1039
1029
|
_this.edp = edp;
|
|
1040
1030
|
_this._isNew = _isNew;
|
|
1041
1031
|
_this._wasDeleted = false;
|
|
1032
|
+
_this._saving = false;
|
|
1042
1033
|
_this.metadata = info;
|
|
1043
1034
|
if (_isNew) {
|
|
1044
1035
|
try {
|
|
@@ -1053,12 +1044,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1053
1044
|
}
|
|
1054
1045
|
}
|
|
1055
1046
|
}
|
|
1056
|
-
catch (
|
|
1047
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1057
1048
|
finally {
|
|
1058
1049
|
try {
|
|
1059
1050
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1060
1051
|
}
|
|
1061
|
-
finally { if (
|
|
1052
|
+
finally { if (e_16) throw e_16.error; }
|
|
1062
1053
|
}
|
|
1063
1054
|
}
|
|
1064
1055
|
if (_this.info.options.entityRefInit)
|
|
@@ -1123,13 +1114,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1123
1114
|
};
|
|
1124
1115
|
Object.defineProperty(rowHelperImplementation.prototype, "fields", {
|
|
1125
1116
|
get: function () {
|
|
1126
|
-
var _a,
|
|
1117
|
+
var _a, e_17, _b;
|
|
1127
1118
|
if (!this._columns) {
|
|
1128
1119
|
var _items_1 = [];
|
|
1129
1120
|
var r_1 = (_a = {
|
|
1130
1121
|
find: function (c) { return r_1[typeof c === "string" ? c : c.key]; }
|
|
1131
1122
|
},
|
|
1132
1123
|
_a[Symbol.iterator] = function () { return _items_1[Symbol.iterator](); },
|
|
1124
|
+
_a.toArray = function () { return _items_1; },
|
|
1133
1125
|
_a);
|
|
1134
1126
|
try {
|
|
1135
1127
|
for (var _c = tslib_1.__values(this.info.columnsInfo), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
@@ -1137,12 +1129,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1137
1129
|
_items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
|
|
1138
1130
|
}
|
|
1139
1131
|
}
|
|
1140
|
-
catch (
|
|
1132
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1141
1133
|
finally {
|
|
1142
1134
|
try {
|
|
1143
1135
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1144
1136
|
}
|
|
1145
|
-
finally { if (
|
|
1137
|
+
finally { if (e_17) throw e_17.error; }
|
|
1146
1138
|
}
|
|
1147
1139
|
this._columns = r_1;
|
|
1148
1140
|
}
|
|
@@ -1154,29 +1146,62 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1154
1146
|
rowHelperImplementation.prototype.save = function () {
|
|
1155
1147
|
var _a;
|
|
1156
1148
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1157
|
-
var doNotSave_1, d, ignoreKeys,
|
|
1158
|
-
var e_19,
|
|
1159
|
-
return tslib_1.__generator(this, function (
|
|
1160
|
-
switch (
|
|
1149
|
+
var doNotSave_1, _b, _c, col, e_18_1, d, ignoreKeys, _d, _e, field, f, updatedRow, changesOnly, wasChanged, key, element, err_1;
|
|
1150
|
+
var e_18, _f, e_19, _g;
|
|
1151
|
+
return tslib_1.__generator(this, function (_h) {
|
|
1152
|
+
switch (_h.label) {
|
|
1161
1153
|
case 0:
|
|
1162
|
-
|
|
1154
|
+
_h.trys.push([0, , 25, 26]);
|
|
1155
|
+
if (this._saving)
|
|
1156
|
+
throw new Error("cannot save while entity is already saving");
|
|
1157
|
+
this._saving = true;
|
|
1158
|
+
if (this.wasDeleted())
|
|
1159
|
+
throw new Error("cannot save a deleted row");
|
|
1163
1160
|
this.isLoading = true;
|
|
1164
1161
|
return [4 /*yield*/, this.__validateEntity()];
|
|
1165
1162
|
case 1:
|
|
1166
|
-
|
|
1163
|
+
_h.sent();
|
|
1167
1164
|
doNotSave_1 = false;
|
|
1168
|
-
|
|
1169
|
-
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
|
|
1165
|
+
_h.label = 2;
|
|
1170
1166
|
case 2:
|
|
1171
|
-
|
|
1172
|
-
|
|
1167
|
+
_h.trys.push([2, 7, 8, 9]);
|
|
1168
|
+
_b = tslib_1.__values(this.fields), _c = _b.next();
|
|
1169
|
+
_h.label = 3;
|
|
1173
1170
|
case 3:
|
|
1171
|
+
if (!!_c.done) return [3 /*break*/, 6];
|
|
1172
|
+
col = _c.value;
|
|
1173
|
+
if (!col.metadata.options.saving) return [3 /*break*/, 5];
|
|
1174
|
+
return [4 /*yield*/, col.metadata.options.saving(this.instance, col)];
|
|
1175
|
+
case 4:
|
|
1176
|
+
_h.sent();
|
|
1177
|
+
_h.label = 5;
|
|
1178
|
+
case 5:
|
|
1179
|
+
_c = _b.next();
|
|
1180
|
+
return [3 /*break*/, 3];
|
|
1181
|
+
case 6: return [3 /*break*/, 9];
|
|
1182
|
+
case 7:
|
|
1183
|
+
e_18_1 = _h.sent();
|
|
1184
|
+
e_18 = { error: e_18_1 };
|
|
1185
|
+
return [3 /*break*/, 9];
|
|
1186
|
+
case 8:
|
|
1187
|
+
try {
|
|
1188
|
+
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
1189
|
+
}
|
|
1190
|
+
finally { if (e_18) throw e_18.error; }
|
|
1191
|
+
return [7 /*endfinally*/];
|
|
1192
|
+
case 9:
|
|
1193
|
+
if (!this.info.entityInfo.saving) return [3 /*break*/, 11];
|
|
1194
|
+
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
|
|
1195
|
+
case 10:
|
|
1196
|
+
_h.sent();
|
|
1197
|
+
_h.label = 11;
|
|
1198
|
+
case 11:
|
|
1174
1199
|
this.__assertValidity();
|
|
1175
1200
|
d = this.copyDataToObject();
|
|
1176
1201
|
ignoreKeys = [];
|
|
1177
1202
|
try {
|
|
1178
|
-
for (
|
|
1179
|
-
field =
|
|
1203
|
+
for (_d = tslib_1.__values(this.metadata.fields), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1204
|
+
field = _e.value;
|
|
1180
1205
|
if (field.dbReadOnly || field == this.metadata.idMetadata.field && this.metadata.options.dbAutoIncrementId) {
|
|
1181
1206
|
d[field.key] = undefined;
|
|
1182
1207
|
ignoreKeys.push(field.key);
|
|
@@ -1188,29 +1213,29 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1188
1213
|
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
1189
1214
|
finally {
|
|
1190
1215
|
try {
|
|
1191
|
-
if (
|
|
1216
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
1192
1217
|
}
|
|
1193
1218
|
finally { if (e_19) throw e_19.error; }
|
|
1194
1219
|
}
|
|
1195
1220
|
if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
|
|
1196
|
-
d.id
|
|
1221
|
+
delete (d.id);
|
|
1197
1222
|
updatedRow = void 0;
|
|
1198
|
-
|
|
1199
|
-
case
|
|
1200
|
-
|
|
1223
|
+
_h.label = 12;
|
|
1224
|
+
case 12:
|
|
1225
|
+
_h.trys.push([12, 22, , 24]);
|
|
1201
1226
|
(_a = this._subscribers) === null || _a === void 0 ? void 0 : _a.reportChanged();
|
|
1202
|
-
if (!this.isNew()) return [3 /*break*/,
|
|
1227
|
+
if (!this.isNew()) return [3 /*break*/, 14];
|
|
1203
1228
|
return [4 /*yield*/, this.edp.insert(d)];
|
|
1204
|
-
case
|
|
1205
|
-
updatedRow =
|
|
1206
|
-
return [3 /*break*/,
|
|
1207
|
-
case
|
|
1229
|
+
case 13:
|
|
1230
|
+
updatedRow = _h.sent();
|
|
1231
|
+
return [3 /*break*/, 18];
|
|
1232
|
+
case 14:
|
|
1208
1233
|
changesOnly = {};
|
|
1209
1234
|
wasChanged = false;
|
|
1210
1235
|
for (key in d) {
|
|
1211
1236
|
if (Object.prototype.hasOwnProperty.call(d, key)) {
|
|
1212
1237
|
element = d[key];
|
|
1213
|
-
if (
|
|
1238
|
+
if (this.fields.find(key).valueChanged() && !ignoreKeys.includes(key)) {
|
|
1214
1239
|
changesOnly[key] = element;
|
|
1215
1240
|
wasChanged = true;
|
|
1216
1241
|
}
|
|
@@ -1218,39 +1243,40 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1218
1243
|
}
|
|
1219
1244
|
if (!wasChanged)
|
|
1220
1245
|
return [2 /*return*/, this.instance];
|
|
1221
|
-
if (!doNotSave_1) return [3 /*break*/,
|
|
1246
|
+
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
1222
1247
|
return [4 /*yield*/, this.edp.find({ where: this.getIdFilter() })];
|
|
1223
|
-
case
|
|
1224
|
-
updatedRow = (
|
|
1225
|
-
return [3 /*break*/,
|
|
1226
|
-
case
|
|
1227
|
-
case
|
|
1228
|
-
updatedRow =
|
|
1229
|
-
|
|
1230
|
-
case
|
|
1231
|
-
case
|
|
1232
|
-
|
|
1233
|
-
if (!this.info.entityInfo.saved) return [3 /*break*/,
|
|
1248
|
+
case 15:
|
|
1249
|
+
updatedRow = (_h.sent())[0];
|
|
1250
|
+
return [3 /*break*/, 18];
|
|
1251
|
+
case 16: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
1252
|
+
case 17:
|
|
1253
|
+
updatedRow = _h.sent();
|
|
1254
|
+
_h.label = 18;
|
|
1255
|
+
case 18: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
1256
|
+
case 19:
|
|
1257
|
+
_h.sent();
|
|
1258
|
+
if (!this.info.entityInfo.saved) return [3 /*break*/, 21];
|
|
1234
1259
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance)];
|
|
1235
|
-
case
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
case
|
|
1260
|
+
case 20:
|
|
1261
|
+
_h.sent();
|
|
1262
|
+
_h.label = 21;
|
|
1263
|
+
case 21:
|
|
1239
1264
|
this.saveOriginalData();
|
|
1240
1265
|
this._isNew = false;
|
|
1241
1266
|
return [2 /*return*/, this.instance];
|
|
1242
|
-
case
|
|
1243
|
-
err_1 =
|
|
1267
|
+
case 22:
|
|
1268
|
+
err_1 = _h.sent();
|
|
1244
1269
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
1245
|
-
case
|
|
1246
|
-
|
|
1247
|
-
return [3 /*break*/,
|
|
1248
|
-
case
|
|
1249
|
-
case
|
|
1270
|
+
case 23:
|
|
1271
|
+
_h.sent();
|
|
1272
|
+
return [3 /*break*/, 24];
|
|
1273
|
+
case 24: return [3 /*break*/, 26];
|
|
1274
|
+
case 25:
|
|
1250
1275
|
this.isLoading = false;
|
|
1251
1276
|
this._reportChangedToEntityAndFields();
|
|
1277
|
+
this._saving = false;
|
|
1252
1278
|
return [7 /*endfinally*/];
|
|
1253
|
-
case
|
|
1279
|
+
case 26: return [2 /*return*/];
|
|
1254
1280
|
}
|
|
1255
1281
|
});
|
|
1256
1282
|
});
|
|
@@ -1570,6 +1596,7 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1570
1596
|
find: function (c) { return r[typeof c === "string" ? c : c.key]; }
|
|
1571
1597
|
},
|
|
1572
1598
|
_a[Symbol.iterator] = function () { return _items[Symbol.iterator](); },
|
|
1599
|
+
_a.toArray = function () { return _items; },
|
|
1573
1600
|
_a);
|
|
1574
1601
|
try {
|
|
1575
1602
|
for (var columnsInfo_2 = tslib_1.__values(columnsInfo), columnsInfo_2_1 = columnsInfo_2.next(); !columnsInfo_2_1.done; columnsInfo_2_1 = columnsInfo_2.next()) {
|
|
@@ -1742,6 +1769,9 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
1742
1769
|
FieldRefImplementation.prototype.rawOriginalValue = function () {
|
|
1743
1770
|
return this.rowBase.originalValues[this.metadata.key];
|
|
1744
1771
|
};
|
|
1772
|
+
FieldRefImplementation.prototype.setId = function (id) {
|
|
1773
|
+
this.value = id;
|
|
1774
|
+
};
|
|
1745
1775
|
Object.defineProperty(FieldRefImplementation.prototype, "inputValue", {
|
|
1746
1776
|
get: function () {
|
|
1747
1777
|
this.reportObserved();
|
|
@@ -1993,6 +2023,7 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
1993
2023
|
find: function (c) { return r[typeof c === "string" ? c : c.key]; }
|
|
1994
2024
|
},
|
|
1995
2025
|
_a[Symbol.iterator] = function () { return _items[Symbol.iterator](); },
|
|
2026
|
+
_a.toArray = function () { return _items; },
|
|
1996
2027
|
_a);
|
|
1997
2028
|
try {
|
|
1998
2029
|
for (var columnsInfo_3 = tslib_1.__values(columnsInfo), columnsInfo_3_1 = columnsInfo_3.next(); !columnsInfo_3_1.done; columnsInfo_3_1 = columnsInfo_3.next()) {
|
|
@@ -2115,15 +2146,17 @@ function IntegerField() {
|
|
|
2115
2146
|
}], options));
|
|
2116
2147
|
}
|
|
2117
2148
|
exports.IntegerField = IntegerField;
|
|
2118
|
-
function ValueListFieldType(
|
|
2149
|
+
function ValueListFieldType() {
|
|
2119
2150
|
var options = [];
|
|
2120
|
-
for (var _i =
|
|
2121
|
-
options[_i
|
|
2151
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2152
|
+
options[_i] = arguments[_i];
|
|
2122
2153
|
}
|
|
2123
|
-
return
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2154
|
+
return function (type) {
|
|
2155
|
+
return FieldType.apply(void 0, tslib_1.__spread([{
|
|
2156
|
+
valueConverter: new valueConverters_1.ValueListValueConverter(type),
|
|
2157
|
+
displayValue: function (item, val) { return val.caption; }
|
|
2158
|
+
}], options))(type);
|
|
2159
|
+
};
|
|
2127
2160
|
}
|
|
2128
2161
|
exports.ValueListFieldType = ValueListFieldType;
|
|
2129
2162
|
function UuidField() {
|