remult 0.13.10 → 0.13.13

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ControllerBase = exports.EntityBase = exports.Entity = exports.BuildEntity = exports.decorateColumnSettings = exports.storableMember = exports.Field = exports.getValueList = exports.ValueListInfo = exports.ValueListFieldType = exports.isAutoIncrement = exports.Fields = exports.Fields1 = exports.FieldType = exports.columnDefsImpl = exports.buildCaption = exports.CaptionTransformer = exports.getEntityRef = exports.FieldRefImplementation = exports.controllerRefImpl = exports.getControllerRef = exports.getFields = exports.rowHelperImplementation = exports.createOldEntity = exports.columnsOfType = exports.getEntityKey = exports.getEntitySettings = exports.entityInfo_key = exports.entityInfo = exports.__updateEntityBasedOnWhere = exports.RepositoryImplementation = void 0;
3
+ exports.ControllerBase = exports.EntityBase = exports.Entity = exports.BuildEntity = exports.decorateColumnSettings = exports.storableMember = exports.Field = exports.getValueList = exports.ValueListInfo = exports.ValueListFieldType = exports.isAutoIncrement = exports.Fields = exports.FieldType = exports.columnDefsImpl = exports.buildCaption = exports.CaptionTransformer = exports.getEntityRef = exports.FieldRefImplementation = exports.controllerRefImpl = exports.getControllerRef = exports.getFields = exports.rowHelperImplementation = exports.createOldEntity = exports.columnsOfType = exports.getEntityKey = exports.getEntitySettings = exports.entityInfo_key = exports.entityInfo = exports.__updateEntityBasedOnWhere = exports.RepositoryImplementation = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var column_1 = require("../column");
6
6
  var context_1 = require("../context");
@@ -189,16 +189,12 @@ var RepositoryImplementation = /** @class */ (function () {
189
189
  RepositoryImplementation.prototype.delete = function (item) {
190
190
  return tslib_1.__awaiter(this, void 0, void 0, function () {
191
191
  return tslib_1.__generator(this, function (_a) {
192
- switch (_a.label) {
193
- case 0:
194
- if (!(typeof item === "string" || typeof item === "number")) return [3 /*break*/, 1];
195
- return [2 /*return*/, this.edp.delete(item)];
196
- case 1: return [4 /*yield*/, this.getEntityRef(item).delete()];
197
- case 2:
198
- _a.sent();
199
- _a.label = 3;
200
- case 3: return [2 /*return*/];
192
+ if (typeof item === "string" || typeof item === "number")
193
+ return [2 /*return*/, this.edp.delete(item)];
194
+ else {
195
+ return [2 /*return*/, this.getRefForExistingRow(item, undefined).delete()];
201
196
  }
197
+ return [2 /*return*/];
202
198
  });
203
199
  });
204
200
  };
@@ -226,25 +222,47 @@ var RepositoryImplementation = /** @class */ (function () {
226
222
  };
227
223
  RepositoryImplementation.prototype.update = function (id, entity) {
228
224
  return tslib_1.__awaiter(this, void 0, void 0, function () {
229
- var row, obj, key, updatedRow;
225
+ var ref;
230
226
  return tslib_1.__generator(this, function (_a) {
231
227
  switch (_a.label) {
232
228
  case 0:
233
- row = new rowHelperImplementation(this._info, Object.assign({}, entity), this, this.edp, this.remult, false);
234
- obj = row.copyDataToObject();
235
- for (key in entity) {
236
- if (Object.prototype.hasOwnProperty.call(entity, key)) {
237
- entity[key] = obj[key];
238
- }
239
- }
240
- return [4 /*yield*/, this.edp.update(id, entity)];
241
- case 1:
242
- updatedRow = _a.sent();
243
- return [2 /*return*/, this.mapRawDataToResult(updatedRow, undefined)];
229
+ ref = this.getRefForExistingRow(entity, id);
230
+ return [4 /*yield*/, ref.save()];
231
+ case 1: return [2 /*return*/, (_a.sent())];
244
232
  }
245
233
  });
246
234
  });
247
235
  };
236
+ RepositoryImplementation.prototype.getRefForExistingRow = function (entity, id) {
237
+ var e_4, _a;
238
+ var ref = getEntityRef(entity, false);
239
+ if (!ref) {
240
+ var instance = new this.entity(this.remult);
241
+ try {
242
+ for (var _b = tslib_1.__values(this.metadata.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
243
+ var field = _c.value;
244
+ instance[field.key] = entity[field.key];
245
+ }
246
+ }
247
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
248
+ finally {
249
+ try {
250
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
251
+ }
252
+ finally { if (e_4) throw e_4.error; }
253
+ }
254
+ var row_1 = new rowHelperImplementation(this._info, instance, this, this.edp, this.remult, false);
255
+ if (id)
256
+ row_1.id = id;
257
+ else
258
+ row_1.id = row_1.getId();
259
+ ref = row_1;
260
+ Object.defineProperty(instance, entityMember, {
261
+ get: function () { return row_1; }
262
+ });
263
+ }
264
+ return ref;
265
+ };
248
266
  RepositoryImplementation.prototype.save = function (entity) {
249
267
  return tslib_1.__awaiter(this, void 0, void 0, function () {
250
268
  var ref, id;
@@ -277,7 +295,7 @@ var RepositoryImplementation = /** @class */ (function () {
277
295
  function loadManyToOne(repo, toLoad) {
278
296
  return tslib_1.__awaiter(this, void 0, void 0, function () {
279
297
  var rows, rows_1, rows_1_1, r;
280
- var _a, e_6, _b;
298
+ var _a, e_7, _b;
281
299
  return tslib_1.__generator(this, function (_c) {
282
300
  switch (_c.label) {
283
301
  case 0: return [4 /*yield*/, repo.find({ where: (_a = repo.metadata.idMetadata).getIdFilter.apply(_a, tslib_1.__spread(toLoad)) })];
@@ -289,20 +307,20 @@ var RepositoryImplementation = /** @class */ (function () {
289
307
  repo.addToCache(r);
290
308
  }
291
309
  }
292
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
310
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
293
311
  finally {
294
312
  try {
295
313
  if (rows_1_1 && !rows_1_1.done && (_b = rows_1.return)) _b.call(rows_1);
296
314
  }
297
- finally { if (e_6) throw e_6.error; }
315
+ finally { if (e_7) throw e_7.error; }
298
316
  }
299
317
  return [2 /*return*/];
300
318
  }
301
319
  });
302
320
  });
303
321
  }
304
- var opt, _a, rawRows, loadFields, _b, _c, col, ei, load, repo, toLoad, rawRows_1, rawRows_1_1, r, val, e_4_1, result;
305
- var e_4, _d, e_5, _e;
322
+ var opt, _a, rawRows, loadFields, _b, _c, col, ei, load, repo, toLoad, rawRows_1, rawRows_1_1, r, val, e_5_1, result;
323
+ var e_5, _d, e_6, _e;
306
324
  var _this = this;
307
325
  return tslib_1.__generator(this, function (_f) {
308
326
  switch (_f.label) {
@@ -346,7 +364,7 @@ var RepositoryImplementation = /** @class */ (function () {
346
364
  repo = this.remult.repo(col.valueType);
347
365
  toLoad = [];
348
366
  try {
349
- 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()) {
367
+ for (rawRows_1 = (e_6 = void 0, tslib_1.__values(rawRows)), rawRows_1_1 = rawRows_1.next(); !rawRows_1_1.done; rawRows_1_1 = rawRows_1.next()) {
350
368
  r = rawRows_1_1.value;
351
369
  val = r[col.key];
352
370
  if (val !== undefined && val !== null && !toLoad.includes(val) && !repo.idCache.has(val)) {
@@ -354,12 +372,12 @@ var RepositoryImplementation = /** @class */ (function () {
354
372
  }
355
373
  }
356
374
  }
357
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
375
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
358
376
  finally {
359
377
  try {
360
378
  if (rawRows_1_1 && !rawRows_1_1.done && (_e = rawRows_1.return)) _e.call(rawRows_1);
361
379
  }
362
- finally { if (e_5) throw e_5.error; }
380
+ finally { if (e_6) throw e_6.error; }
363
381
  }
364
382
  if (!(toLoad.length > 0)) return [3 /*break*/, 6];
365
383
  return [4 /*yield*/, loadManyToOne(repo, toLoad)];
@@ -371,14 +389,14 @@ var RepositoryImplementation = /** @class */ (function () {
371
389
  return [3 /*break*/, 4];
372
390
  case 7: return [3 /*break*/, 10];
373
391
  case 8:
374
- e_4_1 = _f.sent();
375
- e_4 = { error: e_4_1 };
392
+ e_5_1 = _f.sent();
393
+ e_5 = { error: e_5_1 };
376
394
  return [3 /*break*/, 10];
377
395
  case 9:
378
396
  try {
379
397
  if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
380
398
  }
381
- finally { if (e_4) throw e_4.error; }
399
+ finally { if (e_5) throw e_5.error; }
382
400
  return [7 /*endfinally*/];
383
401
  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) {
384
402
  switch (_a.label) {
@@ -473,7 +491,7 @@ var RepositoryImplementation = /** @class */ (function () {
473
491
  }
474
492
  _a.label = 2;
475
493
  case 2:
476
- r = this.find(options).then(function (items) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
494
+ r = this.find(tslib_1.__assign(tslib_1.__assign({}, options), { limit: 1 })).then(function (items) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
477
495
  var r;
478
496
  return tslib_1.__generator(this, function (_a) {
479
497
  switch (_a.label) {
@@ -513,7 +531,7 @@ var RepositoryImplementation = /** @class */ (function () {
513
531
  RepositoryImplementation.prototype.fromJson = function (json, newRow) {
514
532
  return tslib_1.__awaiter(this, void 0, void 0, function () {
515
533
  var obj, _a, _b, col, r, helper;
516
- var e_7, _c;
534
+ var e_8, _c;
517
535
  return tslib_1.__generator(this, function (_d) {
518
536
  switch (_d.label) {
519
537
  case 0:
@@ -526,12 +544,12 @@ var RepositoryImplementation = /** @class */ (function () {
526
544
  }
527
545
  }
528
546
  }
529
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
547
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
530
548
  finally {
531
549
  try {
532
550
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
533
551
  }
534
- finally { if (e_7) throw e_7.error; }
552
+ finally { if (e_8) throw e_8.error; }
535
553
  }
536
554
  if (!newRow) return [3 /*break*/, 2];
537
555
  r = this.create();
@@ -640,7 +658,7 @@ function createOldEntity(entity, remult) {
640
658
  var key = getEntityKey(entity);
641
659
  var base = Object.getPrototypeOf(entity);
642
660
  var _loop_1 = function () {
643
- var e_8, _a;
661
+ var e_9, _a;
644
662
  var baseCols = exports.columnsOfType.get(base);
645
663
  if (baseCols) {
646
664
  r.unshift.apply(r, tslib_1.__spread(baseCols.filter(function (x) { return !r.find(function (y) { return y.key == x.key; }); })));
@@ -669,17 +687,17 @@ function createOldEntity(entity, remult) {
669
687
  }
670
688
  };
671
689
  try {
672
- for (var _b = (e_8 = void 0, tslib_1.__values(functions)), _c = _b.next(); !_c.done; _c = _b.next()) {
690
+ for (var _b = (e_9 = void 0, tslib_1.__values(functions)), _c = _b.next(); !_c.done; _c = _b.next()) {
673
691
  var key_1 = _c.value;
674
692
  _loop_2(key_1);
675
693
  }
676
694
  }
677
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
695
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
678
696
  finally {
679
697
  try {
680
698
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
681
699
  }
682
- finally { if (e_8) throw e_8.error; }
700
+ finally { if (e_9) throw e_9.error; }
683
701
  }
684
702
  }
685
703
  base = Object.getPrototypeOf(base);
@@ -692,7 +710,7 @@ function createOldEntity(entity, remult) {
692
710
  exports.createOldEntity = createOldEntity;
693
711
  var rowHelperBase = /** @class */ (function () {
694
712
  function rowHelperBase(columnsInfo, instance, remult) {
695
- var e_9, _a;
713
+ var e_10, _a;
696
714
  var _this = this;
697
715
  this.columnsInfo = columnsInfo;
698
716
  this.instance = instance;
@@ -747,12 +765,12 @@ var rowHelperBase = /** @class */ (function () {
747
765
  _loop_3(col);
748
766
  }
749
767
  }
750
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
768
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
751
769
  finally {
752
770
  try {
753
771
  if (columnsInfo_1_1 && !columnsInfo_1_1.done && (_a = columnsInfo_1.return)) _a.call(columnsInfo_1);
754
772
  }
755
- finally { if (e_9) throw e_9.error; }
773
+ finally { if (e_10) throw e_10.error; }
756
774
  }
757
775
  }
758
776
  Object.defineProperty(rowHelperBase.prototype, "error", {
@@ -774,7 +792,7 @@ var rowHelperBase = /** @class */ (function () {
774
792
  return this._subscribers.subscribe(listener);
775
793
  };
776
794
  rowHelperBase.prototype.initSubscribers = function () {
777
- var e_10, _a;
795
+ var e_11, _a;
778
796
  var _this = this;
779
797
  if (!this._subscribers) {
780
798
  this._subscribers = new SubscribableImp();
@@ -809,12 +827,12 @@ var rowHelperBase = /** @class */ (function () {
809
827
  _loop_4(col);
810
828
  }
811
829
  }
812
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
830
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
813
831
  finally {
814
832
  try {
815
833
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
816
834
  }
817
- finally { if (e_10) throw e_10.error; }
835
+ finally { if (e_11) throw e_11.error; }
818
836
  }
819
837
  }
820
838
  };
@@ -845,7 +863,7 @@ var rowHelperBase = /** @class */ (function () {
845
863
  });
846
864
  };
847
865
  rowHelperBase.prototype.__assertValidity = function () {
848
- var e_11, _a;
866
+ var e_12, _a;
849
867
  if (!this.hasErrors()) {
850
868
  var error = {
851
869
  modelState: Object.assign({}, this.errors),
@@ -862,12 +880,12 @@ var rowHelperBase = /** @class */ (function () {
862
880
  }
863
881
  }
864
882
  }
865
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
883
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
866
884
  finally {
867
885
  try {
868
886
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
869
887
  }
870
- finally { if (e_11) throw e_11.error; }
888
+ finally { if (e_12) throw e_12.error; }
871
889
  }
872
890
  }
873
891
  throw error;
@@ -902,7 +920,7 @@ var rowHelperBase = /** @class */ (function () {
902
920
  this._reportChangedToEntityAndFields();
903
921
  };
904
922
  rowHelperBase.prototype._reportChangedToEntityAndFields = function () {
905
- var e_12, _a;
923
+ var e_13, _a;
906
924
  if (this._subscribers) {
907
925
  this._subscribers.reportChanged();
908
926
  try {
@@ -912,12 +930,12 @@ var rowHelperBase = /** @class */ (function () {
912
930
  ref._subscribers.reportChanged();
913
931
  }
914
932
  }
915
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
933
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
916
934
  finally {
917
935
  try {
918
936
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
919
937
  }
920
- finally { if (e_12) throw e_12.error; }
938
+ finally { if (e_13) throw e_13.error; }
921
939
  }
922
940
  }
923
941
  };
@@ -927,7 +945,7 @@ var rowHelperBase = /** @class */ (function () {
927
945
  return !!!this.error && this.errors == undefined;
928
946
  };
929
947
  rowHelperBase.prototype.copyDataToObject = function () {
930
- var e_13, _a;
948
+ var e_14, _a;
931
949
  var d = {};
932
950
  try {
933
951
  for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -946,12 +964,12 @@ var rowHelperBase = /** @class */ (function () {
946
964
  d[col.key] = val;
947
965
  }
948
966
  }
949
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
967
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
950
968
  finally {
951
969
  try {
952
970
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
953
971
  }
954
- finally { if (e_13) throw e_13.error; }
972
+ finally { if (e_14) throw e_14.error; }
955
973
  }
956
974
  return d;
957
975
  };
@@ -1007,7 +1025,7 @@ var rowHelperBase = /** @class */ (function () {
1007
1025
  });
1008
1026
  };
1009
1027
  rowHelperBase.prototype.toApiJson = function () {
1010
- var e_14, _a;
1028
+ var e_15, _a;
1011
1029
  var result = {};
1012
1030
  try {
1013
1031
  for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1032,19 +1050,19 @@ var rowHelperBase = /** @class */ (function () {
1032
1050
  }
1033
1051
  }
1034
1052
  }
1035
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
1053
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1036
1054
  finally {
1037
1055
  try {
1038
1056
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1039
1057
  }
1040
- finally { if (e_14) throw e_14.error; }
1058
+ finally { if (e_15) throw e_15.error; }
1041
1059
  }
1042
1060
  return result;
1043
1061
  };
1044
1062
  rowHelperBase.prototype._updateEntityBasedOnApi = function (body) {
1045
1063
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1046
1064
  var keys, _a, _b, col, lu;
1047
- var e_15, _c;
1065
+ var e_16, _c;
1048
1066
  return tslib_1.__generator(this, function (_d) {
1049
1067
  switch (_d.label) {
1050
1068
  case 0:
@@ -1064,12 +1082,12 @@ var rowHelperBase = /** @class */ (function () {
1064
1082
  }
1065
1083
  }
1066
1084
  }
1067
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
1085
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
1068
1086
  finally {
1069
1087
  try {
1070
1088
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1071
1089
  }
1072
- finally { if (e_15) throw e_15.error; }
1090
+ finally { if (e_16) throw e_16.error; }
1073
1091
  }
1074
1092
  return [4 /*yield*/, Promise.all(tslib_1.__spread(this.fields).map(function (x) { return x.load(); }))];
1075
1093
  case 1:
@@ -1084,7 +1102,7 @@ var rowHelperBase = /** @class */ (function () {
1084
1102
  var rowHelperImplementation = /** @class */ (function (_super) {
1085
1103
  tslib_1.__extends(rowHelperImplementation, _super);
1086
1104
  function rowHelperImplementation(info, instance, repository, edp, remult, _isNew) {
1087
- var e_16, _a;
1105
+ var e_17, _a;
1088
1106
  var _this = _super.call(this, info.columnsInfo, instance, remult) || this;
1089
1107
  _this.info = info;
1090
1108
  _this.repository = repository;
@@ -1106,12 +1124,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1106
1124
  }
1107
1125
  }
1108
1126
  }
1109
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
1127
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
1110
1128
  finally {
1111
1129
  try {
1112
1130
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1113
1131
  }
1114
- finally { if (e_16) throw e_16.error; }
1132
+ finally { if (e_17) throw e_17.error; }
1115
1133
  }
1116
1134
  }
1117
1135
  if (_this.info.options.entityRefInit)
@@ -1176,7 +1194,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1176
1194
  };
1177
1195
  Object.defineProperty(rowHelperImplementation.prototype, "fields", {
1178
1196
  get: function () {
1179
- var _a, e_17, _b;
1197
+ var _a, e_18, _b;
1180
1198
  if (!this._columns) {
1181
1199
  var _items_1 = [];
1182
1200
  var r_1 = (_a = {
@@ -1191,12 +1209,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1191
1209
  _items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
1192
1210
  }
1193
1211
  }
1194
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
1212
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
1195
1213
  finally {
1196
1214
  try {
1197
1215
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1198
1216
  }
1199
- finally { if (e_17) throw e_17.error; }
1217
+ finally { if (e_18) throw e_18.error; }
1200
1218
  }
1201
1219
  this._columns = r_1;
1202
1220
  }
@@ -1208,8 +1226,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1208
1226
  rowHelperImplementation.prototype.save = function () {
1209
1227
  var _a;
1210
1228
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1211
- var doNotSave_1, _b, _c, col, e_18_1, d, ignoreKeys, _d, _e, field, f, updatedRow, changesOnly, wasChanged, key, element, err_1;
1212
- var e_18, _f, e_19, _g;
1229
+ var doNotSave_1, _b, _c, col, e_19_1, d, ignoreKeys, _d, _e, field, f, updatedRow, changesOnly, wasChanged, key, element, err_1;
1230
+ var e_19, _f, e_20, _g;
1213
1231
  return tslib_1.__generator(this, function (_h) {
1214
1232
  switch (_h.label) {
1215
1233
  case 0:
@@ -1242,14 +1260,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1242
1260
  return [3 /*break*/, 3];
1243
1261
  case 6: return [3 /*break*/, 9];
1244
1262
  case 7:
1245
- e_18_1 = _h.sent();
1246
- e_18 = { error: e_18_1 };
1263
+ e_19_1 = _h.sent();
1264
+ e_19 = { error: e_19_1 };
1247
1265
  return [3 /*break*/, 9];
1248
1266
  case 8:
1249
1267
  try {
1250
1268
  if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
1251
1269
  }
1252
- finally { if (e_18) throw e_18.error; }
1270
+ finally { if (e_19) throw e_19.error; }
1253
1271
  return [7 /*endfinally*/];
1254
1272
  case 9:
1255
1273
  if (!this.info.entityInfo.saving) return [3 /*break*/, 11];
@@ -1272,12 +1290,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1272
1290
  }
1273
1291
  }
1274
1292
  }
1275
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
1293
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
1276
1294
  finally {
1277
1295
  try {
1278
1296
  if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
1279
1297
  }
1280
- finally { if (e_19) throw e_19.error; }
1298
+ finally { if (e_20) throw e_20.error; }
1281
1299
  }
1282
1300
  if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
1283
1301
  delete (d.id);
@@ -1348,8 +1366,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1348
1366
  };
1349
1367
  rowHelperImplementation.prototype.delete = function () {
1350
1368
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1351
- var _a, _b, listener, e_20_1, err_2;
1352
- var e_20, _c;
1369
+ var _a, _b, listener, e_21_1, err_2;
1370
+ var e_21, _c;
1353
1371
  return tslib_1.__generator(this, function (_d) {
1354
1372
  switch (_d.label) {
1355
1373
  case 0:
@@ -1391,14 +1409,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1391
1409
  return [3 /*break*/, 8];
1392
1410
  case 11: return [3 /*break*/, 14];
1393
1411
  case 12:
1394
- e_20_1 = _d.sent();
1395
- e_20 = { error: e_20_1 };
1412
+ e_21_1 = _d.sent();
1413
+ e_21 = { error: e_21_1 };
1396
1414
  return [3 /*break*/, 14];
1397
1415
  case 13:
1398
1416
  try {
1399
1417
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1400
1418
  }
1401
- finally { if (e_20) throw e_20.error; }
1419
+ finally { if (e_21) throw e_21.error; }
1402
1420
  return [7 /*endfinally*/];
1403
1421
  case 14:
1404
1422
  this._wasDeleted = true;
@@ -1416,8 +1434,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1416
1434
  };
1417
1435
  rowHelperImplementation.prototype.loadDataFrom = function (data, loadItems) {
1418
1436
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1419
- var _a, _b, col, lu, e_21_1;
1420
- var e_21, _c;
1437
+ var _a, _b, col, lu, e_22_1;
1438
+ var e_22, _c;
1421
1439
  return tslib_1.__generator(this, function (_d) {
1422
1440
  switch (_d.label) {
1423
1441
  case 0:
@@ -1452,14 +1470,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1452
1470
  return [3 /*break*/, 1];
1453
1471
  case 9: return [3 /*break*/, 12];
1454
1472
  case 10:
1455
- e_21_1 = _d.sent();
1456
- e_21 = { error: e_21_1 };
1473
+ e_22_1 = _d.sent();
1474
+ e_22 = { error: e_22_1 };
1457
1475
  return [3 /*break*/, 12];
1458
1476
  case 11:
1459
1477
  try {
1460
1478
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1461
1479
  }
1462
- finally { if (e_21) throw e_21.error; }
1480
+ finally { if (e_22) throw e_22.error; }
1463
1481
  return [7 /*endfinally*/];
1464
1482
  case 12: return [4 /*yield*/, this.calcServerExpression()];
1465
1483
  case 13:
@@ -1479,8 +1497,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1479
1497
  };
1480
1498
  rowHelperImplementation.prototype.calcServerExpression = function () {
1481
1499
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1482
- var _a, _b, col, _c, _d, e_22_1;
1483
- var e_22, _e;
1500
+ var _a, _b, col, _c, _d, e_23_1;
1501
+ var e_23, _e;
1484
1502
  return tslib_1.__generator(this, function (_f) {
1485
1503
  switch (_f.label) {
1486
1504
  case 0:
@@ -1505,14 +1523,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1505
1523
  return [3 /*break*/, 2];
1506
1524
  case 5: return [3 /*break*/, 8];
1507
1525
  case 6:
1508
- e_22_1 = _f.sent();
1509
- e_22 = { error: e_22_1 };
1526
+ e_23_1 = _f.sent();
1527
+ e_23 = { error: e_23_1 };
1510
1528
  return [3 /*break*/, 8];
1511
1529
  case 7:
1512
1530
  try {
1513
1531
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
1514
1532
  }
1515
- finally { if (e_22) throw e_22.error; }
1533
+ finally { if (e_23) throw e_23.error; }
1516
1534
  return [7 /*endfinally*/];
1517
1535
  case 8: return [2 /*return*/];
1518
1536
  }
@@ -1525,7 +1543,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1525
1543
  return this._isNew;
1526
1544
  };
1527
1545
  rowHelperImplementation.prototype.wasChanged = function () {
1528
- var e_23, _a;
1546
+ var e_24, _a;
1529
1547
  var _b;
1530
1548
  (_b = this._subscribers) === null || _b === void 0 ? void 0 : _b.reportObserved();
1531
1549
  try {
@@ -1535,19 +1553,19 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1535
1553
  return true;
1536
1554
  }
1537
1555
  }
1538
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
1556
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
1539
1557
  finally {
1540
1558
  try {
1541
1559
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1542
1560
  }
1543
- finally { if (e_23) throw e_23.error; }
1561
+ finally { if (e_24) throw e_24.error; }
1544
1562
  }
1545
1563
  return false;
1546
1564
  };
1547
1565
  rowHelperImplementation.prototype.__performColumnAndEntityValidations = function () {
1548
1566
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1549
- var _a, _b, c, col, e_24_1, _c, _d, listener, e_25_1;
1550
- var e_24, _e, e_25, _f;
1567
+ var _a, _b, c, col, e_25_1, _c, _d, listener, e_26_1;
1568
+ var e_25, _e, e_26, _f;
1551
1569
  return tslib_1.__generator(this, function (_g) {
1552
1570
  switch (_g.label) {
1553
1571
  case 0:
@@ -1568,14 +1586,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1568
1586
  return [3 /*break*/, 1];
1569
1587
  case 4: return [3 /*break*/, 7];
1570
1588
  case 5:
1571
- e_24_1 = _g.sent();
1572
- e_24 = { error: e_24_1 };
1589
+ e_25_1 = _g.sent();
1590
+ e_25 = { error: e_25_1 };
1573
1591
  return [3 /*break*/, 7];
1574
1592
  case 6:
1575
1593
  try {
1576
1594
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
1577
1595
  }
1578
- finally { if (e_24) throw e_24.error; }
1596
+ finally { if (e_25) throw e_25.error; }
1579
1597
  return [7 /*endfinally*/];
1580
1598
  case 7:
1581
1599
  if (!this.info.entityInfo.validation) return [3 /*break*/, 9];
@@ -1602,14 +1620,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1602
1620
  return [3 /*break*/, 11];
1603
1621
  case 14: return [3 /*break*/, 17];
1604
1622
  case 15:
1605
- e_25_1 = _g.sent();
1606
- e_25 = { error: e_25_1 };
1623
+ e_26_1 = _g.sent();
1624
+ e_26 = { error: e_26_1 };
1607
1625
  return [3 /*break*/, 17];
1608
1626
  case 16:
1609
1627
  try {
1610
1628
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
1611
1629
  }
1612
- finally { if (e_25) throw e_25.error; }
1630
+ finally { if (e_26) throw e_26.error; }
1613
1631
  return [7 /*endfinally*/];
1614
1632
  case 17: return [2 /*return*/];
1615
1633
  }
@@ -1651,7 +1669,7 @@ exports.getControllerRef = getControllerRef;
1651
1669
  var controllerRefImpl = /** @class */ (function (_super) {
1652
1670
  tslib_1.__extends(controllerRefImpl, _super);
1653
1671
  function controllerRefImpl(columnsInfo, instance, remult) {
1654
- var _a, e_26, _b;
1672
+ var _a, e_27, _b;
1655
1673
  var _this = _super.call(this, columnsInfo, instance, remult) || this;
1656
1674
  var _items = [];
1657
1675
  var r = (_a = {
@@ -1666,20 +1684,20 @@ var controllerRefImpl = /** @class */ (function (_super) {
1666
1684
  _items.push(r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this));
1667
1685
  }
1668
1686
  }
1669
- catch (e_26_1) { e_26 = { error: e_26_1 }; }
1687
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
1670
1688
  finally {
1671
1689
  try {
1672
1690
  if (columnsInfo_2_1 && !columnsInfo_2_1.done && (_b = columnsInfo_2.return)) _b.call(columnsInfo_2);
1673
1691
  }
1674
- finally { if (e_26) throw e_26.error; }
1692
+ finally { if (e_27) throw e_27.error; }
1675
1693
  }
1676
1694
  _this.fields = r;
1677
1695
  return _this;
1678
1696
  }
1679
1697
  controllerRefImpl.prototype.__performColumnAndEntityValidations = function () {
1680
1698
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1681
- var _a, _b, col, e_27_1;
1682
- var e_27, _c;
1699
+ var _a, _b, col, e_28_1;
1700
+ var e_28, _c;
1683
1701
  return tslib_1.__generator(this, function (_d) {
1684
1702
  switch (_d.label) {
1685
1703
  case 0:
@@ -1699,14 +1717,14 @@ var controllerRefImpl = /** @class */ (function (_super) {
1699
1717
  return [3 /*break*/, 1];
1700
1718
  case 4: return [3 /*break*/, 7];
1701
1719
  case 5:
1702
- e_27_1 = _d.sent();
1703
- e_27 = { error: e_27_1 };
1720
+ e_28_1 = _d.sent();
1721
+ e_28 = { error: e_28_1 };
1704
1722
  return [3 /*break*/, 7];
1705
1723
  case 6:
1706
1724
  try {
1707
1725
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1708
1726
  }
1709
- finally { if (e_27) throw e_27.error; }
1727
+ finally { if (e_28) throw e_28.error; }
1710
1728
  return [7 /*endfinally*/];
1711
1729
  case 7: return [2 /*return*/];
1712
1730
  }
@@ -1865,8 +1883,8 @@ var FieldRefImplementation = /** @class */ (function () {
1865
1883
  };
1866
1884
  FieldRefImplementation.prototype.__performValidation = function () {
1867
1885
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1868
- var x, _a, _b, v, e_28_1;
1869
- var e_28, _c;
1886
+ var x, _a, _b, v, e_29_1;
1887
+ var e_29, _c;
1870
1888
  return tslib_1.__generator(this, function (_d) {
1871
1889
  switch (_d.label) {
1872
1890
  case 0:
@@ -1889,14 +1907,14 @@ var FieldRefImplementation = /** @class */ (function () {
1889
1907
  return [3 /*break*/, 2];
1890
1908
  case 5: return [3 /*break*/, 8];
1891
1909
  case 6:
1892
- e_28_1 = _d.sent();
1893
- e_28 = { error: e_28_1 };
1910
+ e_29_1 = _d.sent();
1911
+ e_29 = { error: e_29_1 };
1894
1912
  return [3 /*break*/, 8];
1895
1913
  case 7:
1896
1914
  try {
1897
1915
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1898
1916
  }
1899
- finally { if (e_28) throw e_28.error; }
1917
+ finally { if (e_29) throw e_29.error; }
1900
1918
  return [7 /*endfinally*/];
1901
1919
  case 8: return [3 /*break*/, 11];
1902
1920
  case 9:
@@ -2023,7 +2041,7 @@ var columnDefsImpl = /** @class */ (function () {
2023
2041
  exports.columnDefsImpl = columnDefsImpl;
2024
2042
  var EntityFullInfo = /** @class */ (function () {
2025
2043
  function EntityFullInfo(columnsInfo, entityInfo, remult, entityType, key) {
2026
- var _a, e_29, _b;
2044
+ var _a, e_30, _b;
2027
2045
  var _this = this;
2028
2046
  this.columnsInfo = columnsInfo;
2029
2047
  this.entityInfo = entityInfo;
@@ -2093,12 +2111,12 @@ var EntityFullInfo = /** @class */ (function () {
2093
2111
  _items.push(r[x.key] = new columnDefsImpl(x, this, remult));
2094
2112
  }
2095
2113
  }
2096
- catch (e_29_1) { e_29 = { error: e_29_1 }; }
2114
+ catch (e_30_1) { e_30 = { error: e_30_1 }; }
2097
2115
  finally {
2098
2116
  try {
2099
2117
  if (columnsInfo_3_1 && !columnsInfo_3_1.done && (_b = columnsInfo_3.return)) _b.call(columnsInfo_3);
2100
2118
  }
2101
- finally { if (e_29) throw e_29.error; }
2119
+ finally { if (e_30) throw e_30.error; }
2102
2120
  }
2103
2121
  this.fields = r;
2104
2122
  this.caption = buildCaption(entityInfo.caption, this.key, remult);
@@ -2172,12 +2190,6 @@ function FieldType() {
2172
2190
  };
2173
2191
  }
2174
2192
  exports.FieldType = FieldType;
2175
- exports.Fields1 = {
2176
- String: function () {
2177
- return function (a) {
2178
- };
2179
- }
2180
- };
2181
2193
  var Fields = /** @class */ (function () {
2182
2194
  function Fields() {
2183
2195
  }
@@ -2278,7 +2290,7 @@ function ValueListFieldType() {
2278
2290
  exports.ValueListFieldType = ValueListFieldType;
2279
2291
  var ValueListInfo = /** @class */ (function () {
2280
2292
  function ValueListInfo(valueListType) {
2281
- var e_30, _a, _b;
2293
+ var e_31, _a, _b;
2282
2294
  var _this = this;
2283
2295
  this.valueListType = valueListType;
2284
2296
  this.byIdMap = new Map();
@@ -2316,12 +2328,12 @@ var ValueListInfo = /** @class */ (function () {
2316
2328
  }
2317
2329
  }
2318
2330
  }
2319
- catch (e_30_1) { e_30 = { error: e_30_1 }; }
2331
+ catch (e_31_1) { e_31 = { error: e_31_1 }; }
2320
2332
  finally {
2321
2333
  try {
2322
2334
  if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
2323
2335
  }
2324
- finally { if (e_30) throw e_30.error; }
2336
+ finally { if (e_31) throw e_31.error; }
2325
2337
  }
2326
2338
  if (this.values.find(function (s) { return s.id === undefined; }))
2327
2339
  throw new Error("ValueType " + this.valueListType + " has values without an id");
@@ -2375,6 +2387,17 @@ var ValueListInfo = /** @class */ (function () {
2375
2387
  exports.ValueListInfo = ValueListInfo;
2376
2388
  var typeCache = new Map();
2377
2389
  function getValueList(type) {
2390
+ var _a, _b, _c;
2391
+ {
2392
+ var fr = (_b = (_a = type) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.valueType;
2393
+ if (fr)
2394
+ return ValueListInfo.get(fr).getValues();
2395
+ }
2396
+ {
2397
+ var fr = (_c = type) === null || _c === void 0 ? void 0 : _c.valueType;
2398
+ if (fr)
2399
+ return ValueListInfo.get(fr).getValues();
2400
+ }
2378
2401
  return ValueListInfo.get(type).getValues();
2379
2402
  }
2380
2403
  exports.getValueList = getValueList;
@@ -2427,7 +2450,7 @@ function Field(valueType) {
2427
2450
  exports.Field = Field;
2428
2451
  exports.storableMember = Symbol("storableMember");
2429
2452
  function buildOptions(options, remult) {
2430
- var e_31, _a;
2453
+ var e_32, _a;
2431
2454
  var r = {};
2432
2455
  try {
2433
2456
  for (var options_2 = tslib_1.__values(options), options_2_1 = options_2.next(); !options_2_1.done; options_2_1 = options_2.next()) {
@@ -2440,12 +2463,12 @@ function buildOptions(options, remult) {
2440
2463
  }
2441
2464
  }
2442
2465
  }
2443
- catch (e_31_1) { e_31 = { error: e_31_1 }; }
2466
+ catch (e_32_1) { e_32 = { error: e_32_1 }; }
2444
2467
  finally {
2445
2468
  try {
2446
2469
  if (options_2_1 && !options_2_1.done && (_a = options_2.return)) _a.call(options_2);
2447
2470
  }
2448
- finally { if (e_31) throw e_31.error; }
2471
+ finally { if (e_32) throw e_32.error; }
2449
2472
  }
2450
2473
  return r;
2451
2474
  }
@@ -2543,7 +2566,7 @@ function Entity(key) {
2543
2566
  }
2544
2567
  }
2545
2568
  var factory = function (remult) {
2546
- var e_32, _a;
2569
+ var e_33, _a;
2547
2570
  var r = {};
2548
2571
  try {
2549
2572
  for (var options_3 = tslib_1.__values(options), options_3_1 = options_3.next(); !options_3_1.done; options_3_1 = options_3.next()) {
@@ -2556,12 +2579,12 @@ function Entity(key) {
2556
2579
  }
2557
2580
  }
2558
2581
  }
2559
- catch (e_32_1) { e_32 = { error: e_32_1 }; }
2582
+ catch (e_33_1) { e_33 = { error: e_33_1 }; }
2560
2583
  finally {
2561
2584
  try {
2562
2585
  if (options_3_1 && !options_3_1.done && (_a = options_3.return)) _a.call(options_3);
2563
2586
  }
2564
- finally { if (e_32) throw e_32.error; }
2587
+ finally { if (e_33) throw e_33.error; }
2565
2588
  }
2566
2589
  var base = Object.getPrototypeOf(target);
2567
2590
  if (base) {
@@ -2667,9 +2690,9 @@ var QueryResultImpl = /** @class */ (function () {
2667
2690
  });
2668
2691
  };
2669
2692
  QueryResultImpl.prototype.forEach = function (what) {
2670
- var e_33, _a;
2693
+ var e_34, _a;
2671
2694
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2672
- var i, _b, _c, x, e_33_1;
2695
+ var i, _b, _c, x, e_34_1;
2673
2696
  return tslib_1.__generator(this, function (_d) {
2674
2697
  switch (_d.label) {
2675
2698
  case 0:
@@ -2691,8 +2714,8 @@ var QueryResultImpl = /** @class */ (function () {
2691
2714
  case 5: return [3 /*break*/, 2];
2692
2715
  case 6: return [3 /*break*/, 13];
2693
2716
  case 7:
2694
- e_33_1 = _d.sent();
2695
- e_33 = { error: e_33_1 };
2717
+ e_34_1 = _d.sent();
2718
+ e_34 = { error: e_34_1 };
2696
2719
  return [3 /*break*/, 13];
2697
2720
  case 8:
2698
2721
  _d.trys.push([8, , 11, 12]);
@@ -2703,7 +2726,7 @@ var QueryResultImpl = /** @class */ (function () {
2703
2726
  _d.label = 10;
2704
2727
  case 10: return [3 /*break*/, 12];
2705
2728
  case 11:
2706
- if (e_33) throw e_33.error;
2729
+ if (e_34) throw e_34.error;
2707
2730
  return [7 /*endfinally*/];
2708
2731
  case 12: return [7 /*endfinally*/];
2709
2732
  case 13: return [2 /*return*/, i];