remult 0.9.4 → 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.
Files changed (83) hide show
  1. package/package.json +1 -1
  2. package/postgres/postgres-data-provider.d.ts +1 -1
  3. package/postgres/postgres-data-provider.js +22 -10
  4. package/postgres/postgres-data-provider.js.map +1 -1
  5. package/remult-knex/index.d.ts +42 -0
  6. package/remult-knex/index.js +768 -0
  7. package/remult-knex/index.js.map +1 -0
  8. package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +4 -0
  9. package/src/backend-tests/backend-database-test-setup.backend-spec.js +123 -0
  10. package/src/backend-tests/backend-database-test-setup.backend-spec.js.map +1 -0
  11. package/src/backend-tests/my-test.backend-spec.d.ts +1 -0
  12. package/src/backend-tests/my-test.backend-spec.js +24 -0
  13. package/src/backend-tests/my-test.backend-spec.js.map +1 -0
  14. package/src/context.d.ts +5 -1
  15. package/src/context.js +19 -4
  16. package/src/context.js.map +1 -1
  17. package/src/data-api.d.ts +1 -11
  18. package/src/data-api.js +19 -41
  19. package/src/data-api.js.map +1 -1
  20. package/src/data-providers/array-entity-data-provider.js +1 -1
  21. package/src/data-providers/array-entity-data-provider.js.map +1 -1
  22. package/src/data-providers/json-data-provider.d.ts +1 -1
  23. package/src/data-providers/json-data-provider.js.map +1 -1
  24. package/src/data-providers/sql-database.js +1 -2
  25. package/src/data-providers/sql-database.js.map +1 -1
  26. package/src/remult3/RepositoryImplementation.d.ts +16 -2
  27. package/src/remult3/RepositoryImplementation.js +374 -125
  28. package/src/remult3/RepositoryImplementation.js.map +1 -1
  29. package/src/remult3/remult3.d.ts +10 -1
  30. package/src/shared-tests/db-tests-setup.d.ts +23 -0
  31. package/src/shared-tests/db-tests-setup.js +171 -0
  32. package/src/shared-tests/db-tests-setup.js.map +1 -0
  33. package/src/shared-tests/db-tests.db-tests.d.ts +5 -0
  34. package/src/shared-tests/db-tests.db-tests.js +1228 -0
  35. package/src/shared-tests/db-tests.db-tests.js.map +1 -0
  36. package/src/shared-tests/deleteAll.d.ts +2 -0
  37. package/src/shared-tests/deleteAll.js +22 -0
  38. package/src/shared-tests/deleteAll.js.map +1 -0
  39. package/src/shared-tests/entityWithValidations.d.ts +14 -0
  40. package/src/shared-tests/entityWithValidations.js +95 -0
  41. package/src/shared-tests/entityWithValidations.js.map +1 -0
  42. package/src/shared-tests/index.d.ts +4 -0
  43. package/src/shared-tests/index.js +7 -0
  44. package/src/shared-tests/index.js.map +1 -0
  45. package/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
  46. package/src/shared-tests/test-custom-id-column.spec.js +88 -0
  47. package/src/shared-tests/test-custom-id-column.spec.js.map +1 -0
  48. package/src/shared-tests/test-special-value.spec.d.ts +10 -0
  49. package/src/shared-tests/test-special-value.spec.js +129 -0
  50. package/src/shared-tests/test-special-value.spec.js.map +1 -0
  51. package/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
  52. package/src/shared-tests/test-update-with-null.spec.js +52 -0
  53. package/src/shared-tests/test-update-with-null.spec.js.map +1 -0
  54. package/src/tests/Done.d.ts +5 -0
  55. package/src/tests/Done.js +18 -0
  56. package/src/tests/Done.js.map +1 -0
  57. package/src/tests/TestDataApiResponse.d.ts +10 -0
  58. package/src/tests/TestDataApiResponse.js +30 -0
  59. package/src/tests/TestDataApiResponse.js.map +1 -0
  60. package/src/tests/c.d.ts +8 -0
  61. package/src/tests/c.js +29 -0
  62. package/src/tests/c.js.map +1 -0
  63. package/src/tests/createData.d.ts +7 -0
  64. package/src/tests/createData.js +51 -0
  65. package/src/tests/createData.js.map +1 -0
  66. package/src/tests/d.d.ts +7 -0
  67. package/src/tests/d.js +44 -0
  68. package/src/tests/d.js.map +1 -0
  69. package/src/tests/dWithPrefilter.d.ts +7 -0
  70. package/src/tests/dWithPrefilter.js +46 -0
  71. package/src/tests/dWithPrefilter.js.map +1 -0
  72. package/src/tests/entityForCustomFilter.d.ts +16 -0
  73. package/src/tests/entityForCustomFilter.js +67 -0
  74. package/src/tests/entityForCustomFilter.js.map +1 -0
  75. package/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
  76. package/src/tests/entityWithValidationsOnColumn.js +30 -0
  77. package/src/tests/entityWithValidationsOnColumn.js.map +1 -0
  78. package/src/tests/h.d.ts +6 -0
  79. package/src/tests/h.js +43 -0
  80. package/src/tests/h.js.map +1 -0
  81. package/src/tests/tasks.d.ts +6 -0
  82. package/src/tests/tasks.js +31 -0
  83. 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 (_b) {
227
- switch (_b.label) {
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 = _b.sent();
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 = _b.sent();
248
+ rawRows = _h.sent();
246
249
  loadFields = undefined;
247
250
  if (options.load)
248
251
  loadFields = options.load(this.metadata.fields);
249
- 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) {
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
- result = _b.sent();
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 e_4, _c;
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 (e_4_1) { e_4 = { error: e_4_1 }; }
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 (e_4) throw e_4.error; }
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
- while (base != null) {
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(remult), remult, entity, key);
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 e_5, _a;
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 _loop_1 = function (col) {
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
- return lookup_1.set(val);
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
- _loop_1(col);
647
+ _loop_3(col);
544
648
  }
545
649
  }
546
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
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 (e_5) throw e_5.error; }
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 e_6, _a;
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 (e_6_1) { e_6 = { error: e_6_1 }; }
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 (e_6) throw e_6.error; }
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 e_7, _a;
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 (e_7_1) { e_7 = { error: e_7_1 }; }
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 (e_7) throw e_7.error; }
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 e_8, _a;
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 (e_8_1) { e_8 = { error: e_8_1 }; }
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 (e_8) throw e_8.error; }
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 e_9, _c;
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 (e_9_1) { e_9 = { error: e_9_1 }; }
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 (e_9) throw e_9.error; }
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 e_10, _a;
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,16 +949,31 @@ var rowHelperImplementation = /** @class */ (function (_super) {
791
949
  }
792
950
  }
793
951
  }
794
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
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 (e_10) throw e_10.error; }
957
+ finally { if (e_15) throw e_15.error; }
800
958
  }
801
959
  }
802
960
  return _this;
803
961
  }
962
+ Object.defineProperty(rowHelperImplementation.prototype, "apiUpdateAllowed", {
963
+ get: function () { return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiUpdate); },
964
+ enumerable: false,
965
+ configurable: true
966
+ });
967
+ Object.defineProperty(rowHelperImplementation.prototype, "apiDeleteAllowed", {
968
+ get: function () { return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiDelete); },
969
+ enumerable: false,
970
+ configurable: true
971
+ });
972
+ Object.defineProperty(rowHelperImplementation.prototype, "apiInsertAllowed", {
973
+ get: function () { return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiInsert); },
974
+ enumerable: false,
975
+ configurable: true
976
+ });
804
977
  rowHelperImplementation.prototype.getId = function () {
805
978
  if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
806
979
  return this.info.idMetadata.field.getId(this.instance);
@@ -839,7 +1012,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
839
1012
  };
840
1013
  Object.defineProperty(rowHelperImplementation.prototype, "fields", {
841
1014
  get: function () {
842
- var _a, e_11, _b;
1015
+ var _a, e_16, _b;
843
1016
  if (!this._columns) {
844
1017
  var _items_1 = [];
845
1018
  var r_1 = (_a = {
@@ -853,12 +1026,12 @@ var rowHelperImplementation = /** @class */ (function (_super) {
853
1026
  _items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
854
1027
  }
855
1028
  }
856
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1029
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
857
1030
  finally {
858
1031
  try {
859
1032
  if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
860
1033
  }
861
- finally { if (e_11) throw e_11.error; }
1034
+ finally { if (e_16) throw e_16.error; }
862
1035
  }
863
1036
  this._columns = r_1;
864
1037
  }
@@ -869,30 +1042,55 @@ var rowHelperImplementation = /** @class */ (function (_super) {
869
1042
  });
870
1043
  rowHelperImplementation.prototype.save = function () {
871
1044
  return tslib_1.__awaiter(this, void 0, void 0, function () {
872
- var doNotSave, d, updatedRow, changesOnly, wasChanged, key, element, err_1;
873
- return tslib_1.__generator(this, function (_a) {
874
- switch (_a.label) {
875
- case 0: return [4 /*yield*/, this.__validateEntity()];
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()];
876
1053
  case 1:
877
- _a.sent();
878
- doNotSave = false;
1054
+ _d.sent();
1055
+ doNotSave_1 = false;
879
1056
  if (!this.info.entityInfo.saving) return [3 /*break*/, 3];
880
- return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave = true; })];
1057
+ return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
881
1058
  case 2:
882
- _a.sent();
883
- _a.label = 3;
1059
+ _d.sent();
1060
+ _d.label = 3;
884
1061
  case 3:
885
1062
  this.__assertValidity();
886
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
+ }
887
1083
  if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
888
1084
  d.id = undefined;
889
- _a.label = 4;
1085
+ updatedRow = void 0;
1086
+ _d.label = 4;
890
1087
  case 4:
891
- _a.trys.push([4, 14, , 16]);
1088
+ _d.trys.push([4, 14, , 16]);
1089
+ this._fire();
892
1090
  if (!this.isNew()) return [3 /*break*/, 6];
893
1091
  return [4 /*yield*/, this.edp.insert(d)];
894
1092
  case 5:
895
- updatedRow = _a.sent();
1093
+ updatedRow = _d.sent();
896
1094
  return [3 /*break*/, 10];
897
1095
  case 6:
898
1096
  changesOnly = {};
@@ -900,7 +1098,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
900
1098
  for (key in d) {
901
1099
  if (Object.prototype.hasOwnProperty.call(d, key)) {
902
1100
  element = d[key];
903
- if (element !== this.originalValues[key]) {
1101
+ if (element !== this.originalValues[key] && !ignoreKeys.includes(key)) {
904
1102
  changesOnly[key] = element;
905
1103
  wasChanged = true;
906
1104
  }
@@ -908,34 +1106,39 @@ var rowHelperImplementation = /** @class */ (function (_super) {
908
1106
  }
909
1107
  if (!wasChanged)
910
1108
  return [2 /*return*/, this.instance];
911
- if (!doNotSave) return [3 /*break*/, 8];
1109
+ if (!doNotSave_1) return [3 /*break*/, 8];
912
1110
  return [4 /*yield*/, this.edp.find({ where: this.getIdFilter() })];
913
1111
  case 7:
914
- updatedRow = (_a.sent())[0];
1112
+ updatedRow = (_d.sent())[0];
915
1113
  return [3 /*break*/, 10];
916
1114
  case 8: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
917
1115
  case 9:
918
- updatedRow = _a.sent();
919
- _a.label = 10;
1116
+ updatedRow = _d.sent();
1117
+ _d.label = 10;
920
1118
  case 10: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
921
1119
  case 11:
922
- _a.sent();
1120
+ _d.sent();
923
1121
  if (!this.info.entityInfo.saved) return [3 /*break*/, 13];
924
1122
  return [4 /*yield*/, this.info.entityInfo.saved(this.instance)];
925
1123
  case 12:
926
- _a.sent();
927
- _a.label = 13;
1124
+ _d.sent();
1125
+ _d.label = 13;
928
1126
  case 13:
929
1127
  this.saveOriginalData();
930
1128
  this._isNew = false;
931
1129
  return [2 /*return*/, this.instance];
932
1130
  case 14:
933
- err_1 = _a.sent();
1131
+ err_1 = _d.sent();
934
1132
  return [4 /*yield*/, this.catchSaveErrors(err_1)];
935
1133
  case 15:
936
- _a.sent();
1134
+ _d.sent();
937
1135
  return [3 /*break*/, 16];
938
- case 16: return [2 /*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*/];
939
1142
  }
940
1143
  });
941
1144
  });
@@ -945,8 +1148,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
945
1148
  };
946
1149
  rowHelperImplementation.prototype.delete = function () {
947
1150
  return tslib_1.__awaiter(this, void 0, void 0, function () {
948
- var _a, _b, listener, e_12_1, err_2;
949
- var e_12, _c;
1151
+ var _a, _b, listener, e_18_1, err_2;
1152
+ var e_18, _c;
950
1153
  return tslib_1.__generator(this, function (_d) {
951
1154
  switch (_d.label) {
952
1155
  case 0:
@@ -988,14 +1191,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
988
1191
  return [3 /*break*/, 8];
989
1192
  case 11: return [3 /*break*/, 14];
990
1193
  case 12:
991
- e_12_1 = _d.sent();
992
- e_12 = { error: e_12_1 };
1194
+ e_18_1 = _d.sent();
1195
+ e_18 = { error: e_18_1 };
993
1196
  return [3 /*break*/, 14];
994
1197
  case 13:
995
1198
  try {
996
1199
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
997
1200
  }
998
- finally { if (e_12) throw e_12.error; }
1201
+ finally { if (e_18) throw e_18.error; }
999
1202
  return [7 /*endfinally*/];
1000
1203
  case 14:
1001
1204
  this._wasDeleted = true;
@@ -1013,8 +1216,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1013
1216
  };
1014
1217
  rowHelperImplementation.prototype.loadDataFrom = function (data, loadItems) {
1015
1218
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1016
- var _a, _b, col, lu, e_13_1;
1017
- var e_13, _c;
1219
+ var _a, _b, col, lu, e_19_1;
1220
+ var e_19, _c;
1018
1221
  return tslib_1.__generator(this, function (_d) {
1019
1222
  switch (_d.label) {
1020
1223
  case 0:
@@ -1049,14 +1252,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1049
1252
  return [3 /*break*/, 1];
1050
1253
  case 9: return [3 /*break*/, 12];
1051
1254
  case 10:
1052
- e_13_1 = _d.sent();
1053
- e_13 = { error: e_13_1 };
1255
+ e_19_1 = _d.sent();
1256
+ e_19 = { error: e_19_1 };
1054
1257
  return [3 /*break*/, 12];
1055
1258
  case 11:
1056
1259
  try {
1057
1260
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1058
1261
  }
1059
- finally { if (e_13) throw e_13.error; }
1262
+ finally { if (e_19) throw e_19.error; }
1060
1263
  return [7 /*endfinally*/];
1061
1264
  case 12: return [4 /*yield*/, this.calcServerExpression()];
1062
1265
  case 13:
@@ -1076,8 +1279,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1076
1279
  };
1077
1280
  rowHelperImplementation.prototype.calcServerExpression = function () {
1078
1281
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1079
- var _a, _b, col, _c, _d, e_14_1;
1080
- var e_14, _e;
1282
+ var _a, _b, col, _c, _d, e_20_1;
1283
+ var e_20, _e;
1081
1284
  return tslib_1.__generator(this, function (_f) {
1082
1285
  switch (_f.label) {
1083
1286
  case 0:
@@ -1102,14 +1305,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1102
1305
  return [3 /*break*/, 2];
1103
1306
  case 5: return [3 /*break*/, 8];
1104
1307
  case 6:
1105
- e_14_1 = _f.sent();
1106
- e_14 = { error: e_14_1 };
1308
+ e_20_1 = _f.sent();
1309
+ e_20 = { error: e_20_1 };
1107
1310
  return [3 /*break*/, 8];
1108
1311
  case 7:
1109
1312
  try {
1110
1313
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
1111
1314
  }
1112
- finally { if (e_14) throw e_14.error; }
1315
+ finally { if (e_20) throw e_20.error; }
1113
1316
  return [7 /*endfinally*/];
1114
1317
  case 8: return [2 /*return*/];
1115
1318
  }
@@ -1120,7 +1323,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1120
1323
  return this._isNew;
1121
1324
  };
1122
1325
  rowHelperImplementation.prototype.wasChanged = function () {
1123
- var e_15, _a;
1326
+ var e_21, _a;
1124
1327
  try {
1125
1328
  for (var _b = tslib_1.__values(this.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
1126
1329
  var col = _c.value;
@@ -1128,19 +1331,19 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1128
1331
  return true;
1129
1332
  }
1130
1333
  }
1131
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
1334
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
1132
1335
  finally {
1133
1336
  try {
1134
1337
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1135
1338
  }
1136
- finally { if (e_15) throw e_15.error; }
1339
+ finally { if (e_21) throw e_21.error; }
1137
1340
  }
1138
1341
  return false;
1139
1342
  };
1140
1343
  rowHelperImplementation.prototype.__performColumnAndEntityValidations = function () {
1141
1344
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1142
- var _a, _b, c, col, e_16_1, _c, _d, listener, e_17_1;
1143
- var e_16, _e, e_17, _f;
1345
+ var _a, _b, c, col, e_22_1, _c, _d, listener, e_23_1;
1346
+ var e_22, _e, e_23, _f;
1144
1347
  return tslib_1.__generator(this, function (_g) {
1145
1348
  switch (_g.label) {
1146
1349
  case 0:
@@ -1161,14 +1364,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1161
1364
  return [3 /*break*/, 1];
1162
1365
  case 4: return [3 /*break*/, 7];
1163
1366
  case 5:
1164
- e_16_1 = _g.sent();
1165
- e_16 = { error: e_16_1 };
1367
+ e_22_1 = _g.sent();
1368
+ e_22 = { error: e_22_1 };
1166
1369
  return [3 /*break*/, 7];
1167
1370
  case 6:
1168
1371
  try {
1169
1372
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
1170
1373
  }
1171
- finally { if (e_16) throw e_16.error; }
1374
+ finally { if (e_22) throw e_22.error; }
1172
1375
  return [7 /*endfinally*/];
1173
1376
  case 7:
1174
1377
  if (!this.info.entityInfo.validation) return [3 /*break*/, 9];
@@ -1195,14 +1398,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1195
1398
  return [3 /*break*/, 11];
1196
1399
  case 14: return [3 /*break*/, 17];
1197
1400
  case 15:
1198
- e_17_1 = _g.sent();
1199
- e_17 = { error: e_17_1 };
1401
+ e_23_1 = _g.sent();
1402
+ e_23 = { error: e_23_1 };
1200
1403
  return [3 /*break*/, 17];
1201
1404
  case 16:
1202
1405
  try {
1203
1406
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
1204
1407
  }
1205
- finally { if (e_17) throw e_17.error; }
1408
+ finally { if (e_23) throw e_23.error; }
1206
1409
  return [7 /*endfinally*/];
1207
1410
  case 17: return [2 /*return*/];
1208
1411
  }
@@ -1244,7 +1447,7 @@ exports.getControllerRef = getControllerRef;
1244
1447
  var controllerRefImpl = /** @class */ (function (_super) {
1245
1448
  tslib_1.__extends(controllerRefImpl, _super);
1246
1449
  function controllerRefImpl(columnsInfo, instance, remult) {
1247
- var _a, e_18, _b;
1450
+ var _a, e_24, _b;
1248
1451
  var _this = _super.call(this, columnsInfo, instance, remult) || this;
1249
1452
  var _items = [];
1250
1453
  var r = (_a = {
@@ -1258,20 +1461,20 @@ var controllerRefImpl = /** @class */ (function (_super) {
1258
1461
  _items.push(r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this));
1259
1462
  }
1260
1463
  }
1261
- catch (e_18_1) { e_18 = { error: e_18_1 }; }
1464
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
1262
1465
  finally {
1263
1466
  try {
1264
1467
  if (columnsInfo_2_1 && !columnsInfo_2_1.done && (_b = columnsInfo_2.return)) _b.call(columnsInfo_2);
1265
1468
  }
1266
- finally { if (e_18) throw e_18.error; }
1469
+ finally { if (e_24) throw e_24.error; }
1267
1470
  }
1268
1471
  _this.fields = r;
1269
1472
  return _this;
1270
1473
  }
1271
1474
  controllerRefImpl.prototype.__performColumnAndEntityValidations = function () {
1272
1475
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1273
- var _a, _b, col, e_19_1;
1274
- var e_19, _c;
1476
+ var _a, _b, col, e_25_1;
1477
+ var e_25, _c;
1275
1478
  return tslib_1.__generator(this, function (_d) {
1276
1479
  switch (_d.label) {
1277
1480
  case 0:
@@ -1291,14 +1494,14 @@ var controllerRefImpl = /** @class */ (function (_super) {
1291
1494
  return [3 /*break*/, 1];
1292
1495
  case 4: return [3 /*break*/, 7];
1293
1496
  case 5:
1294
- e_19_1 = _d.sent();
1295
- e_19 = { error: e_19_1 };
1497
+ e_25_1 = _d.sent();
1498
+ e_25 = { error: e_25_1 };
1296
1499
  return [3 /*break*/, 7];
1297
1500
  case 6:
1298
1501
  try {
1299
1502
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1300
1503
  }
1301
- finally { if (e_19) throw e_19.error; }
1504
+ finally { if (e_25) throw e_25.error; }
1302
1505
  return [7 /*endfinally*/];
1303
1506
  case 7: return [2 /*return*/];
1304
1507
  }
@@ -1359,6 +1562,7 @@ var FieldRefImplementation = /** @class */ (function () {
1359
1562
  if (!this.rowBase.errors)
1360
1563
  this.rowBase.errors = {};
1361
1564
  this.rowBase.errors[this.metadata.key] = error;
1565
+ this.rowBase._fire();
1362
1566
  },
1363
1567
  enumerable: false,
1364
1568
  configurable: true
@@ -1430,8 +1634,8 @@ var FieldRefImplementation = /** @class */ (function () {
1430
1634
  };
1431
1635
  FieldRefImplementation.prototype.__performValidation = function () {
1432
1636
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1433
- var x, _a, _b, v, e_20_1;
1434
- var e_20, _c;
1637
+ var x, _a, _b, v, e_26_1;
1638
+ var e_26, _c;
1435
1639
  return tslib_1.__generator(this, function (_d) {
1436
1640
  switch (_d.label) {
1437
1641
  case 0:
@@ -1454,14 +1658,14 @@ var FieldRefImplementation = /** @class */ (function () {
1454
1658
  return [3 /*break*/, 2];
1455
1659
  case 5: return [3 /*break*/, 8];
1456
1660
  case 6:
1457
- e_20_1 = _d.sent();
1458
- e_20 = { error: e_20_1 };
1661
+ e_26_1 = _d.sent();
1662
+ e_26 = { error: e_26_1 };
1459
1663
  return [3 /*break*/, 8];
1460
1664
  case 7:
1461
1665
  try {
1462
1666
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1463
1667
  }
1464
- finally { if (e_20) throw e_20.error; }
1668
+ finally { if (e_26) throw e_26.error; }
1465
1669
  return [7 /*endfinally*/];
1466
1670
  case 8: return [3 /*break*/, 11];
1467
1671
  case 9:
@@ -1588,10 +1792,11 @@ var columnDefsImpl = /** @class */ (function () {
1588
1792
  exports.columnDefsImpl = columnDefsImpl;
1589
1793
  var EntityFullInfo = /** @class */ (function () {
1590
1794
  function EntityFullInfo(columnsInfo, entityInfo, remult, entityType, key) {
1591
- var _a, e_21, _b;
1795
+ var _a, e_27, _b;
1592
1796
  var _this = this;
1593
1797
  this.columnsInfo = columnsInfo;
1594
1798
  this.entityInfo = entityInfo;
1799
+ this.remult = remult;
1595
1800
  this.entityType = entityType;
1596
1801
  this.key = key;
1597
1802
  this.options = this.entityInfo;
@@ -1606,16 +1811,40 @@ var EntityFullInfo = /** @class */ (function () {
1606
1811
  isIdField: function (col) {
1607
1812
  return col.key == _this.idMetadata.field.key;
1608
1813
  },
1609
- getIdFilter: function (id) {
1610
- var _a;
1611
- if (_this.idMetadata.field instanceof column_1.CompoundIdField)
1612
- return _this.idMetadata.field.isEqualTo(id);
1613
- else
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)
1614
1827
  return _a = {},
1615
- _a[_this.idMetadata.field.key] = id,
1828
+ _a[_this.idMetadata.field.key] = ids[0],
1616
1829
  _a;
1830
+ else
1831
+ return _b = {},
1832
+ _b[_this.idMetadata.field.key] = ids,
1833
+ _b;
1617
1834
  }
1618
1835
  };
1836
+ if (this.options.allowApiCrud !== undefined) {
1837
+ if (this.options.allowApiDelete === undefined)
1838
+ this.options.allowApiDelete = this.options.allowApiCrud;
1839
+ if (this.options.allowApiInsert === undefined)
1840
+ this.options.allowApiInsert = this.options.allowApiCrud;
1841
+ if (this.options.allowApiUpdate === undefined)
1842
+ this.options.allowApiUpdate = this.options.allowApiCrud;
1843
+ if (this.options.allowApiRead === undefined)
1844
+ this.options.allowApiRead = this.options.allowApiCrud;
1845
+ }
1846
+ if (this.options.allowApiRead === undefined)
1847
+ this.options.allowApiRead = true;
1619
1848
  if (!this.key)
1620
1849
  this.key = entityType.name;
1621
1850
  if (!entityInfo.dbName)
@@ -1632,12 +1861,12 @@ var EntityFullInfo = /** @class */ (function () {
1632
1861
  _items.push(r[x.key] = new columnDefsImpl(x, this, remult));
1633
1862
  }
1634
1863
  }
1635
- catch (e_21_1) { e_21 = { error: e_21_1 }; }
1864
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
1636
1865
  finally {
1637
1866
  try {
1638
1867
  if (columnsInfo_3_1 && !columnsInfo_3_1.done && (_b = columnsInfo_3.return)) _b.call(columnsInfo_3);
1639
1868
  }
1640
- finally { if (e_21) throw e_21.error; }
1869
+ finally { if (e_27) throw e_27.error; }
1641
1870
  }
1642
1871
  this.fields = r;
1643
1872
  this.dbAutoIncrementId = entityInfo.dbAutoIncrementId;
@@ -1652,6 +1881,26 @@ var EntityFullInfo = /** @class */ (function () {
1652
1881
  this.idMetadata.field = tslib_1.__spread(this.fields)[0];
1653
1882
  }
1654
1883
  }
1884
+ Object.defineProperty(EntityFullInfo.prototype, "apiUpdateAllowed", {
1885
+ get: function () { return this.remult.isAllowedForInstance(undefined, this.options.allowApiUpdate); },
1886
+ enumerable: false,
1887
+ configurable: true
1888
+ });
1889
+ Object.defineProperty(EntityFullInfo.prototype, "apiReadAllowed", {
1890
+ get: function () { return this.remult.isAllowed(this.options.allowApiRead); },
1891
+ enumerable: false,
1892
+ configurable: true
1893
+ });
1894
+ Object.defineProperty(EntityFullInfo.prototype, "apiDeleteAllowed", {
1895
+ get: function () { return this.remult.isAllowedForInstance(undefined, this.options.allowApiDelete); },
1896
+ enumerable: false,
1897
+ configurable: true
1898
+ });
1899
+ Object.defineProperty(EntityFullInfo.prototype, "apiInsertAllowed", {
1900
+ get: function () { return this.remult.isAllowedForInstance(undefined, this.options.allowApiInsert); },
1901
+ enumerable: false,
1902
+ configurable: true
1903
+ });
1655
1904
  EntityFullInfo.prototype.getDbName = function () {
1656
1905
  var _this = this;
1657
1906
  if (this.dbNamePromise)
@@ -1784,7 +2033,7 @@ function Field() {
1784
2033
  exports.Field = Field;
1785
2034
  var storableMember = Symbol("storableMember");
1786
2035
  function buildOptions(options, remult) {
1787
- var e_22, _a;
2036
+ var e_28, _a;
1788
2037
  var r = {};
1789
2038
  try {
1790
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()) {
@@ -1797,12 +2046,12 @@ function buildOptions(options, remult) {
1797
2046
  }
1798
2047
  }
1799
2048
  }
1800
- catch (e_22_1) { e_22 = { error: e_22_1 }; }
2049
+ catch (e_28_1) { e_28 = { error: e_28_1 }; }
1801
2050
  finally {
1802
2051
  try {
1803
2052
  if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
1804
2053
  }
1805
- finally { if (e_22) throw e_22.error; }
2054
+ finally { if (e_28) throw e_28.error; }
1806
2055
  }
1807
2056
  return r;
1808
2057
  }
@@ -1885,7 +2134,7 @@ function Entity(key) {
1885
2134
  }
1886
2135
  }
1887
2136
  var factory = function (remult) {
1888
- var e_23, _a;
2137
+ var e_29, _a;
1889
2138
  var r = {};
1890
2139
  try {
1891
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()) {
@@ -1898,12 +2147,12 @@ function Entity(key) {
1898
2147
  }
1899
2148
  }
1900
2149
  }
1901
- catch (e_23_1) { e_23 = { error: e_23_1 }; }
2150
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
1902
2151
  finally {
1903
2152
  try {
1904
2153
  if (options_2_1 && !options_2_1.done && (_a = options_2.return)) _a.call(options_2);
1905
2154
  }
1906
- finally { if (e_23) throw e_23.error; }
2155
+ finally { if (e_29) throw e_29.error; }
1907
2156
  }
1908
2157
  var base = Object.getPrototypeOf(target);
1909
2158
  if (base) {
@@ -1992,9 +2241,9 @@ var QueryResultImpl = /** @class */ (function () {
1992
2241
  });
1993
2242
  };
1994
2243
  QueryResultImpl.prototype.forEach = function (what) {
1995
- var e_24, _a;
2244
+ var e_30, _a;
1996
2245
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1997
- var i, _b, _c, x, e_24_1;
2246
+ var i, _b, _c, x, e_30_1;
1998
2247
  return tslib_1.__generator(this, function (_d) {
1999
2248
  switch (_d.label) {
2000
2249
  case 0:
@@ -2016,8 +2265,8 @@ var QueryResultImpl = /** @class */ (function () {
2016
2265
  case 5: return [3 /*break*/, 2];
2017
2266
  case 6: return [3 /*break*/, 13];
2018
2267
  case 7:
2019
- e_24_1 = _d.sent();
2020
- e_24 = { error: e_24_1 };
2268
+ e_30_1 = _d.sent();
2269
+ e_30 = { error: e_30_1 };
2021
2270
  return [3 /*break*/, 13];
2022
2271
  case 8:
2023
2272
  _d.trys.push([8, , 11, 12]);
@@ -2028,7 +2277,7 @@ var QueryResultImpl = /** @class */ (function () {
2028
2277
  _d.label = 10;
2029
2278
  case 10: return [3 /*break*/, 12];
2030
2279
  case 11:
2031
- if (e_24) throw e_24.error;
2280
+ if (e_30) throw e_30.error;
2032
2281
  return [7 /*endfinally*/];
2033
2282
  case 12: return [7 /*endfinally*/];
2034
2283
  case 13: return [2 /*return*/, i];