remult 0.26.21 → 0.26.23-next.0
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/SseSubscriptionServer.d.ts +3 -4
- package/assign.js +1 -2
- package/esm/graphql.js +1 -1
- package/esm/remult-hono.js +3 -1
- package/esm/remult-knex/index.js +3 -1
- package/esm/remult-sqlite3.js +4 -1
- package/esm/remult-sveltekit.js +1 -0
- package/esm/server/index.js +3 -2
- package/esm/server/initAsyncHooks.js +3 -3
- package/esm/server/remult-admin.js +1 -4
- package/esm/server/remult-api-server.js +47 -48
- package/esm/src/CompoundIdField.js +9 -9
- package/esm/src/data-api.js +1 -1
- package/esm/src/data-providers/json-entity-opfs-storage.js +9 -5
- package/esm/src/data-providers/sql-database.js +9 -9
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +3 -1
- package/esm/src/live-query/LiveQueryClient.js +0 -1
- package/esm/src/remult-proxy.js +1 -3
- package/esm/src/remult-static.js +1 -0
- package/esm/src/remult3/Fields.js +4 -3
- package/esm/src/remult3/RepositoryImplementation.js +143 -104
- package/esm/src/remult3/entity.js +1 -1
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/remult3.js +9 -0
- package/esm/src/server-action.js +16 -12
- package/esm/src/sort.js +0 -2
- package/esm/src/validators.js +3 -3
- package/esm/src/valueConverters.js +2 -2
- package/graphql.js +3 -4
- package/index.js +2 -2
- package/live-query/data-provider-live-query-storage.js +6 -6
- package/migrations/compare-migration-snapshots.js +48 -49
- package/migrations/generate-migrations.js +1 -2
- package/migrations/migrate.js +2 -3
- package/migrations/migration-types.d.ts +1 -1
- package/migrations/migration-types.js +4 -4
- package/migrations/update-migrations-ts-file.js +1 -2
- package/myLog.js +1 -2
- package/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +2 -2
- package/postgres/postgres-data-provider.js +5 -5
- package/postgres/schema-builder.js +3 -3
- package/remult-express.js +4 -3
- package/remult-fastify.js +4 -3
- package/remult-fresh.js +1 -2
- package/remult-hapi.js +4 -3
- package/remult-hono.js +6 -3
- package/remult-knex/index.d.ts +1 -1
- package/remult-knex/index.js +7 -5
- package/remult-mongo.d.ts +1 -1
- package/remult-next.d.ts +4 -5
- package/remult-next.js +11 -6
- package/remult-nuxt.js +1 -2
- package/remult-solid-start.js +1 -2
- package/remult-sqlite3.js +4 -1
- package/remult-sveltekit.js +33 -35
- package/server/JsonEntityFileStorage.d.ts +1 -1
- package/server/get-remult-admin-html.js +1 -2
- package/server/index.d.ts +1 -1
- package/server/index.js +4 -3
- package/server/initAsyncHooks.d.ts +10 -10
- package/server/initAsyncHooks.js +5 -2
- package/server/initDataProvider.js +1 -2
- package/server/initDataProviderOrJson.js +1 -2
- package/server/remult-admin.js +3 -7
- package/server/remult-api-server.d.ts +22 -22
- package/server/remult-api-server.js +54 -48
- package/src/CompoundIdField.d.ts +1 -1
- package/src/CompoundIdField.js +9 -0
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +8 -8
- package/src/column-interfaces.d.ts +8 -8
- package/src/column-interfaces.js +1 -2
- package/src/column.d.ts +4 -4
- package/src/column.js +2 -2
- package/src/context.d.ts +4 -4
- package/src/context.js +5 -5
- package/src/data-api.d.ts +2 -2
- package/src/data-api.js +4 -4
- package/src/data-interfaces.js +1 -2
- package/src/data-providers/json-entity-opfs-storage.js +30 -16
- package/src/data-providers/rest-data-provider.d.ts +3 -3
- package/src/data-providers/rest-data-provider.js +4 -4
- package/src/data-providers/sql-database.js +11 -11
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.js +21 -19
- package/src/filter/filter-interfaces.d.ts +1 -1
- package/src/filter/filter-interfaces.js +10 -6
- package/src/isOfType.js +2 -3
- package/src/live-query/SubscriptionServer.js +95 -97
- package/src/remult-proxy.js +1 -3
- package/src/remult-static.d.ts +2 -2
- package/src/remult-static.js +7 -4
- package/src/remult3/Fields.d.ts +2 -2
- package/src/remult3/Fields.js +11 -9
- package/src/remult3/RepositoryImplementation.d.ts +41 -39
- package/src/remult3/RepositoryImplementation.js +416 -365
- package/src/remult3/__updateEntityBasedOnWhere.js +1 -2
- package/src/remult3/addValidator.d.ts +1 -1
- package/src/remult3/addValidator.js +1 -2
- package/src/remult3/classDescribers.d.ts +3 -3
- package/src/remult3/classDescribers.js +3 -4
- package/src/remult3/entity.js +2 -4
- package/src/remult3/getEntityRef.js +4 -4
- package/src/remult3/relation-loader.d.ts +1 -1
- package/src/remult3/relationInfoMember.d.ts +2 -2
- package/src/remult3/relationInfoMember.js +4 -5
- package/src/remult3/remult3.d.ts +13 -10
- package/src/remult3/remult3.js +9 -0
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/remult3/repository-internals.js +2 -2
- package/src/server-action.d.ts +1 -1
- package/src/server-action.js +65 -58
- package/src/sort.d.ts +1 -1
- package/src/sort.js +0 -2
- package/src/sql-command.d.ts +1 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +13 -11
- package/src/valueConverters.js +3 -2
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ControllerBase = exports.EntityBase = exports.fieldOptionalValuesFunctionKey = exports.storableMember = exports.ValueListInfo = exports.columnDefsImpl = exports.CaptionTransformer = exports.FieldRefImplementation = exports.controllerRefImpl = exports.rowHelperImplementation = exports.RepositoryImplementation = void 0;
|
|
4
|
+
exports.createOldEntity = createOldEntity;
|
|
5
|
+
exports.getFields = getFields;
|
|
6
|
+
exports.getControllerRef = getControllerRef;
|
|
7
|
+
exports.buildCaption = buildCaption;
|
|
8
|
+
exports.FieldType = FieldType;
|
|
9
|
+
exports.isAutoIncrement = isAutoIncrement;
|
|
10
|
+
exports.ValueListFieldType = ValueListFieldType;
|
|
11
|
+
exports.getValueList = getValueList;
|
|
12
|
+
exports.buildOptions = buildOptions;
|
|
13
|
+
exports.decorateColumnSettings = decorateColumnSettings;
|
|
14
|
+
exports.getEntityMetadata = getEntityMetadata;
|
|
15
|
+
exports.getRepository = getRepository;
|
|
4
16
|
var tslib_1 = require("tslib");
|
|
5
17
|
var column_js_1 = require("../column.js");
|
|
6
18
|
var CompoundIdField_js_1 = require("../CompoundIdField.js");
|
|
@@ -439,52 +451,52 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
439
451
|
});
|
|
440
452
|
};
|
|
441
453
|
RepositoryImplementation.prototype.updateMany = function (_a) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
var
|
|
446
|
-
return tslib_1.__generator(this, function (
|
|
447
|
-
switch (
|
|
454
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
455
|
+
var _c, _d, updated, _e, _f, _g, item, e_7_1;
|
|
456
|
+
var _h, e_7, _j, _k;
|
|
457
|
+
var where = _b.where, set = _b.set;
|
|
458
|
+
return tslib_1.__generator(this, function (_l) {
|
|
459
|
+
switch (_l.label) {
|
|
448
460
|
case 0:
|
|
449
461
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'updateMany');
|
|
450
462
|
if (!this._dataProvider.isProxy) return [3 /*break*/, 2];
|
|
451
|
-
|
|
463
|
+
_d = (_c = this._edp).updateMany;
|
|
452
464
|
return [4 /*yield*/, this._translateWhereToFilter(where)];
|
|
453
|
-
case 1: return [2 /*return*/,
|
|
465
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_l.sent(), set])];
|
|
454
466
|
case 2:
|
|
455
467
|
updated = 0;
|
|
456
|
-
|
|
468
|
+
_l.label = 3;
|
|
457
469
|
case 3:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
case 4: return [4 /*yield*/,
|
|
470
|
+
_l.trys.push([3, 9, 10, 15]);
|
|
471
|
+
_e = true, _f = tslib_1.__asyncValues(this.query({ where: where }));
|
|
472
|
+
_l.label = 4;
|
|
473
|
+
case 4: return [4 /*yield*/, _f.next()];
|
|
462
474
|
case 5:
|
|
463
|
-
if (!(
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
item =
|
|
475
|
+
if (!(_g = _l.sent(), _h = _g.done, !_h)) return [3 /*break*/, 8];
|
|
476
|
+
_k = _g.value;
|
|
477
|
+
_e = false;
|
|
478
|
+
item = _k;
|
|
467
479
|
(0, assign_js_1.assign)(item, set);
|
|
468
480
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).save()];
|
|
469
481
|
case 6:
|
|
470
|
-
|
|
482
|
+
_l.sent();
|
|
471
483
|
updated++;
|
|
472
|
-
|
|
484
|
+
_l.label = 7;
|
|
473
485
|
case 7:
|
|
474
|
-
|
|
486
|
+
_e = true;
|
|
475
487
|
return [3 /*break*/, 4];
|
|
476
488
|
case 8: return [3 /*break*/, 15];
|
|
477
489
|
case 9:
|
|
478
|
-
e_7_1 =
|
|
490
|
+
e_7_1 = _l.sent();
|
|
479
491
|
e_7 = { error: e_7_1 };
|
|
480
492
|
return [3 /*break*/, 15];
|
|
481
493
|
case 10:
|
|
482
|
-
|
|
483
|
-
if (!(!
|
|
484
|
-
return [4 /*yield*/,
|
|
494
|
+
_l.trys.push([10, , 13, 14]);
|
|
495
|
+
if (!(!_e && !_h && (_j = _f.return))) return [3 /*break*/, 12];
|
|
496
|
+
return [4 /*yield*/, _j.call(_f)];
|
|
485
497
|
case 11:
|
|
486
|
-
|
|
487
|
-
|
|
498
|
+
_l.sent();
|
|
499
|
+
_l.label = 12;
|
|
488
500
|
case 12: return [3 /*break*/, 14];
|
|
489
501
|
case 13:
|
|
490
502
|
if (e_7) throw e_7.error;
|
|
@@ -554,7 +566,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
554
566
|
try {
|
|
555
567
|
for (var _b = tslib_1.__values(this._fieldsOf(entity)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
556
568
|
var field = _c.value;
|
|
557
|
-
|
|
569
|
+
var key = field.key;
|
|
570
|
+
instance[key] = entity[key];
|
|
558
571
|
}
|
|
559
572
|
}
|
|
560
573
|
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
@@ -625,14 +638,15 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
625
638
|
}
|
|
626
639
|
(_a = listener.error) !== null && _a !== void 0 ? _a : (listener.error = function () { });
|
|
627
640
|
(_b = listener.complete) !== null && _b !== void 0 ? _b : (listener.complete = function () { });
|
|
628
|
-
return _this._remult.liveQuerySubscriber.subscribe(
|
|
641
|
+
return _this._remult.liveQuerySubscriber.subscribe(//TODO - figure out why the type was required
|
|
642
|
+
_this, options, listener);
|
|
629
643
|
},
|
|
630
644
|
};
|
|
631
645
|
};
|
|
632
|
-
RepositoryImplementation.prototype._rawFind = function (
|
|
633
|
-
|
|
634
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
646
|
+
RepositoryImplementation.prototype._rawFind = function (options_1) {
|
|
647
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (options, skipOrderByAndLimit, loader) {
|
|
635
648
|
var opt, rawRows, result;
|
|
649
|
+
if (skipOrderByAndLimit === void 0) { skipOrderByAndLimit = false; }
|
|
636
650
|
return tslib_1.__generator(this, function (_a) {
|
|
637
651
|
switch (_a.label) {
|
|
638
652
|
case 0:
|
|
@@ -660,10 +674,10 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
660
674
|
});
|
|
661
675
|
});
|
|
662
676
|
};
|
|
663
|
-
RepositoryImplementation.prototype.find = function (
|
|
664
|
-
|
|
665
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
677
|
+
RepositoryImplementation.prototype.find = function (options_1) {
|
|
678
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (options, skipOrderByAndLimit) {
|
|
666
679
|
var loader, result;
|
|
680
|
+
if (skipOrderByAndLimit === void 0) { skipOrderByAndLimit = false; }
|
|
667
681
|
return tslib_1.__generator(this, function (_a) {
|
|
668
682
|
switch (_a.label) {
|
|
669
683
|
case 0:
|
|
@@ -742,7 +756,6 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
742
756
|
});
|
|
743
757
|
};
|
|
744
758
|
RepositoryImplementation.prototype._loadManyToOneForManyRows = function (rawRows, loadOptions, loader) {
|
|
745
|
-
var _a;
|
|
746
759
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
747
760
|
function loadManyToOne(repo, toLoad) {
|
|
748
761
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -771,9 +784,10 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
771
784
|
});
|
|
772
785
|
});
|
|
773
786
|
}
|
|
774
|
-
var loadFields,
|
|
775
|
-
var e_10,
|
|
787
|
+
var loadFields, _a, _b, col, ei, isRelation, load, repo, toLoad, rawRows_1, rawRows_1_1, r, val, e_10_1, result, _loop_1, this_1, _c, _d, col;
|
|
788
|
+
var e_10, _e, e_11, _f, e_12, _g;
|
|
776
789
|
var _this = this;
|
|
790
|
+
var _h;
|
|
777
791
|
return tslib_1.__generator(this, function (_j) {
|
|
778
792
|
switch (_j.label) {
|
|
779
793
|
case 0:
|
|
@@ -783,11 +797,11 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
783
797
|
_j.label = 1;
|
|
784
798
|
case 1:
|
|
785
799
|
_j.trys.push([1, 6, 7, 8]);
|
|
786
|
-
|
|
800
|
+
_a = tslib_1.__values(this.metadata.fields), _b = _a.next();
|
|
787
801
|
_j.label = 2;
|
|
788
802
|
case 2:
|
|
789
|
-
if (!!
|
|
790
|
-
col =
|
|
803
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
804
|
+
col = _b.value;
|
|
791
805
|
ei = (0, getEntityRef_js_1.getEntitySettings)(col.valueType, false);
|
|
792
806
|
if (!ei) return [3 /*break*/, 4];
|
|
793
807
|
isRelation = (0, relationInfoMember_js_1.getRelationFieldInfo)(col);
|
|
@@ -813,7 +827,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
813
827
|
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
814
828
|
finally {
|
|
815
829
|
try {
|
|
816
|
-
if (rawRows_1_1 && !rawRows_1_1.done && (
|
|
830
|
+
if (rawRows_1_1 && !rawRows_1_1.done && (_f = rawRows_1.return)) _f.call(rawRows_1);
|
|
817
831
|
}
|
|
818
832
|
finally { if (e_11) throw e_11.error; }
|
|
819
833
|
}
|
|
@@ -823,7 +837,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
823
837
|
_j.sent();
|
|
824
838
|
_j.label = 4;
|
|
825
839
|
case 4:
|
|
826
|
-
|
|
840
|
+
_b = _a.next();
|
|
827
841
|
return [3 /*break*/, 2];
|
|
828
842
|
case 5: return [3 /*break*/, 8];
|
|
829
843
|
case 6:
|
|
@@ -832,7 +846,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
832
846
|
return [3 /*break*/, 8];
|
|
833
847
|
case 7:
|
|
834
848
|
try {
|
|
835
|
-
if (
|
|
849
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
836
850
|
}
|
|
837
851
|
finally { if (e_10) throw e_10.error; }
|
|
838
852
|
return [7 /*endfinally*/];
|
|
@@ -849,15 +863,17 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
849
863
|
var rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(col);
|
|
850
864
|
var incl = col.options
|
|
851
865
|
.defaultIncluded;
|
|
852
|
-
|
|
853
|
-
|
|
866
|
+
var include = (_h = loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.include) === null || _h === void 0 ? void 0 : _h[col.key];
|
|
867
|
+
if (include !== undefined) {
|
|
868
|
+
incl = include;
|
|
854
869
|
}
|
|
855
870
|
if (rel && incl) {
|
|
856
871
|
var otherRepo = rel.toRepo;
|
|
857
872
|
var _loop_2 = function (row) {
|
|
858
873
|
var _l = this_1._findOptionsBasedOnRelation(rel, col, incl, row, otherRepo), findOptions = _l.findOptions, returnNull = _l.returnNull;
|
|
874
|
+
var colKey = col.key;
|
|
859
875
|
if (returnNull)
|
|
860
|
-
row[
|
|
876
|
+
row[colKey] = null;
|
|
861
877
|
else {
|
|
862
878
|
var entityType = rel.toEntity;
|
|
863
879
|
var toRepo_1 = otherRepo;
|
|
@@ -870,7 +886,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
870
886
|
.then(function (result) {
|
|
871
887
|
if (result.length == 0 && rel.type == 'toOne')
|
|
872
888
|
return;
|
|
873
|
-
row[
|
|
889
|
+
row[colKey] =
|
|
874
890
|
rel.type !== 'toMany'
|
|
875
891
|
? result.length == 0
|
|
876
892
|
? null
|
|
@@ -896,15 +912,15 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
896
912
|
};
|
|
897
913
|
this_1 = this;
|
|
898
914
|
try {
|
|
899
|
-
for (
|
|
900
|
-
col =
|
|
915
|
+
for (_c = tslib_1.__values(this.metadata.fields), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
916
|
+
col = _d.value;
|
|
901
917
|
_loop_1(col);
|
|
902
918
|
}
|
|
903
919
|
}
|
|
904
920
|
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
905
921
|
finally {
|
|
906
922
|
try {
|
|
907
|
-
if (
|
|
923
|
+
if (_d && !_d.done && (_g = _c.return)) _g.call(_c);
|
|
908
924
|
}
|
|
909
925
|
finally { if (e_12) throw e_12.error; }
|
|
910
926
|
}
|
|
@@ -1004,8 +1020,6 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1004
1020
|
return tslib_1.__generator(this, function (_a) {
|
|
1005
1021
|
switch (_a.label) {
|
|
1006
1022
|
case 0:
|
|
1007
|
-
if (!r)
|
|
1008
|
-
return [2 /*return*/, undefined];
|
|
1009
1023
|
x = new this._entity(this._remult);
|
|
1010
1024
|
helper = new rowHelperImplementation(this._info, x, this, this._edp, this._remult, false);
|
|
1011
1025
|
Object.defineProperty(x, getEntityRef_js_1.entityMember, {
|
|
@@ -1042,17 +1056,18 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1042
1056
|
try {
|
|
1043
1057
|
for (var _b = tslib_1.__values(this._fieldsOf(json)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1044
1058
|
var col = _c.value;
|
|
1059
|
+
var colKey = col.key;
|
|
1045
1060
|
var ei = (0, getEntityRef_js_1.getEntitySettings)(col.valueType, false);
|
|
1046
1061
|
if (ei) {
|
|
1047
1062
|
var val = json[col.key];
|
|
1048
1063
|
if (typeof val === 'string' || typeof val === 'number')
|
|
1049
|
-
result[
|
|
1064
|
+
result[colKey] = val;
|
|
1050
1065
|
else
|
|
1051
|
-
result[
|
|
1066
|
+
result[colKey] = this._remult.repo(col.valueType).fromJson(val);
|
|
1052
1067
|
}
|
|
1053
1068
|
else {
|
|
1054
|
-
if (json[
|
|
1055
|
-
result[
|
|
1069
|
+
if (json[colKey] !== undefined) {
|
|
1070
|
+
result[colKey] = col.valueConverter.fromJson(json[col.key]);
|
|
1056
1071
|
}
|
|
1057
1072
|
}
|
|
1058
1073
|
}
|
|
@@ -1092,51 +1107,51 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1092
1107
|
});
|
|
1093
1108
|
};
|
|
1094
1109
|
RepositoryImplementation.prototype.deleteMany = function (_a) {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
var
|
|
1099
|
-
return tslib_1.__generator(this, function (
|
|
1100
|
-
switch (
|
|
1110
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
1111
|
+
var _c, _d, deleted, _e, _f, _g, item, e_18_1;
|
|
1112
|
+
var _h, e_18, _j, _k;
|
|
1113
|
+
var where = _b.where;
|
|
1114
|
+
return tslib_1.__generator(this, function (_l) {
|
|
1115
|
+
switch (_l.label) {
|
|
1101
1116
|
case 0:
|
|
1102
1117
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'deleteMany');
|
|
1103
1118
|
if (!this._dataProvider.isProxy) return [3 /*break*/, 2];
|
|
1104
|
-
|
|
1119
|
+
_d = (_c = this._edp).deleteMany;
|
|
1105
1120
|
return [4 /*yield*/, this._translateWhereToFilter(where)];
|
|
1106
|
-
case 1: return [2 /*return*/,
|
|
1121
|
+
case 1: return [2 /*return*/, _d.apply(_c, [_l.sent()])];
|
|
1107
1122
|
case 2:
|
|
1108
1123
|
deleted = 0;
|
|
1109
|
-
|
|
1124
|
+
_l.label = 3;
|
|
1110
1125
|
case 3:
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
case 4: return [4 /*yield*/,
|
|
1126
|
+
_l.trys.push([3, 9, 10, 15]);
|
|
1127
|
+
_e = true, _f = tslib_1.__asyncValues(this.query({ where: where }));
|
|
1128
|
+
_l.label = 4;
|
|
1129
|
+
case 4: return [4 /*yield*/, _f.next()];
|
|
1115
1130
|
case 5:
|
|
1116
|
-
if (!(
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
item =
|
|
1131
|
+
if (!(_g = _l.sent(), _h = _g.done, !_h)) return [3 /*break*/, 8];
|
|
1132
|
+
_k = _g.value;
|
|
1133
|
+
_e = false;
|
|
1134
|
+
item = _k;
|
|
1120
1135
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).delete()];
|
|
1121
1136
|
case 6:
|
|
1122
|
-
|
|
1137
|
+
_l.sent();
|
|
1123
1138
|
deleted++;
|
|
1124
|
-
|
|
1139
|
+
_l.label = 7;
|
|
1125
1140
|
case 7:
|
|
1126
|
-
|
|
1141
|
+
_e = true;
|
|
1127
1142
|
return [3 /*break*/, 4];
|
|
1128
1143
|
case 8: return [3 /*break*/, 15];
|
|
1129
1144
|
case 9:
|
|
1130
|
-
e_18_1 =
|
|
1145
|
+
e_18_1 = _l.sent();
|
|
1131
1146
|
e_18 = { error: e_18_1 };
|
|
1132
1147
|
return [3 /*break*/, 15];
|
|
1133
1148
|
case 10:
|
|
1134
|
-
|
|
1135
|
-
if (!(!
|
|
1136
|
-
return [4 /*yield*/,
|
|
1149
|
+
_l.trys.push([10, , 13, 14]);
|
|
1150
|
+
if (!(!_e && !_h && (_j = _f.return))) return [3 /*break*/, 12];
|
|
1151
|
+
return [4 /*yield*/, _j.call(_f)];
|
|
1137
1152
|
case 11:
|
|
1138
|
-
|
|
1139
|
-
|
|
1153
|
+
_l.sent();
|
|
1154
|
+
_l.label = 12;
|
|
1140
1155
|
case 12: return [3 /*break*/, 14];
|
|
1141
1156
|
case 13:
|
|
1142
1157
|
if (e_18) throw e_18.error;
|
|
@@ -1147,14 +1162,13 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1147
1162
|
});
|
|
1148
1163
|
});
|
|
1149
1164
|
};
|
|
1150
|
-
RepositoryImplementation.prototype.findOne = function (
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
var r, cacheInfo, f, key;
|
|
1165
|
+
RepositoryImplementation.prototype.findOne = function (pOptions_1) {
|
|
1166
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (pOptions, skipOrderByAndLimit) {
|
|
1167
|
+
var r, cacheInfo, options, f, key;
|
|
1154
1168
|
var _this = this;
|
|
1169
|
+
if (skipOrderByAndLimit === void 0) { skipOrderByAndLimit = false; }
|
|
1155
1170
|
return tslib_1.__generator(this, function (_a) {
|
|
1156
|
-
|
|
1157
|
-
options = {};
|
|
1171
|
+
options = pOptions !== null && pOptions !== void 0 ? pOptions : {};
|
|
1158
1172
|
if (options.useCache) {
|
|
1159
1173
|
f = (0, rest_data_provider_js_1.findOptionsToJson)(options, this.metadata);
|
|
1160
1174
|
key = JSON.stringify(f);
|
|
@@ -1166,7 +1180,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1166
1180
|
this._cache.delete(key);
|
|
1167
1181
|
}
|
|
1168
1182
|
else
|
|
1169
|
-
return [2 /*return*/,
|
|
1183
|
+
return [2 /*return*/, cacheInfo.promise];
|
|
1170
1184
|
}
|
|
1171
1185
|
else {
|
|
1172
1186
|
cacheInfo = {
|
|
@@ -1205,10 +1219,10 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1205
1219
|
});
|
|
1206
1220
|
});
|
|
1207
1221
|
};
|
|
1208
|
-
RepositoryImplementation.prototype.findFirst = function (
|
|
1209
|
-
|
|
1210
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1222
|
+
RepositoryImplementation.prototype.findFirst = function (where_1, options_1) {
|
|
1223
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (where, options, skipOrderByAndLimit) {
|
|
1211
1224
|
var w;
|
|
1225
|
+
if (skipOrderByAndLimit === void 0) { skipOrderByAndLimit = false; }
|
|
1212
1226
|
return tslib_1.__generator(this, function (_a) {
|
|
1213
1227
|
if (!options)
|
|
1214
1228
|
options = {};
|
|
@@ -1238,7 +1252,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1238
1252
|
try {
|
|
1239
1253
|
for (var _c = tslib_1.__values(this._fieldsOf(item)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1240
1254
|
var field = _d.value;
|
|
1241
|
-
|
|
1255
|
+
var key = field.key;
|
|
1256
|
+
r[key] = item[key];
|
|
1242
1257
|
}
|
|
1243
1258
|
}
|
|
1244
1259
|
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
@@ -1304,52 +1319,51 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1304
1319
|
};
|
|
1305
1320
|
RepositoryImplementation.prototype.findId = function (id, options) {
|
|
1306
1321
|
if (id === null || id === undefined)
|
|
1307
|
-
return null;
|
|
1322
|
+
return Promise.resolve(null);
|
|
1308
1323
|
if (typeof id !== 'string' && typeof id !== 'number')
|
|
1309
1324
|
throw new Error('id can be either number or string, but got: ' + typeof id);
|
|
1310
1325
|
return this.findFirst({}, tslib_1.__assign(tslib_1.__assign({}, options), { where: this.metadata.idMetadata.getIdFilter(id) }), true);
|
|
1311
1326
|
};
|
|
1312
1327
|
RepositoryImplementation.prototype._translateWhereToFilter = function (where) {
|
|
1313
|
-
var _a, _b;
|
|
1314
1328
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1315
|
-
var z, z,
|
|
1316
|
-
var
|
|
1329
|
+
var safeWhere, z, z, _a, r;
|
|
1330
|
+
var _b;
|
|
1317
1331
|
var _this = this;
|
|
1332
|
+
var _c, _d;
|
|
1318
1333
|
return tslib_1.__generator(this, function (_e) {
|
|
1319
1334
|
switch (_e.label) {
|
|
1320
1335
|
case 0:
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
$and: [z, (_b = this._defaultFindOptions) === null || _b === void 0 ? void 0 : _b.where],
|
|
1336
|
+
safeWhere = where !== null && where !== void 0 ? where : {};
|
|
1337
|
+
if ((_c = this._defaultFindOptions) === null || _c === void 0 ? void 0 : _c.where) {
|
|
1338
|
+
z = safeWhere;
|
|
1339
|
+
safeWhere = {
|
|
1340
|
+
$and: [z, (_d = this._defaultFindOptions) === null || _d === void 0 ? void 0 : _d.where],
|
|
1327
1341
|
};
|
|
1328
1342
|
}
|
|
1329
1343
|
if (!!this._dataProvider.isProxy) return [3 /*break*/, 4];
|
|
1330
1344
|
if (!this.metadata.options.backendPreprocessFilter) return [3 /*break*/, 2];
|
|
1331
|
-
return [4 /*yield*/, this.metadata.options.backendPreprocessFilter(
|
|
1345
|
+
return [4 /*yield*/, this.metadata.options.backendPreprocessFilter(safeWhere, {
|
|
1332
1346
|
metadata: this.metadata,
|
|
1333
1347
|
getFilterPreciseValues: function (filter) {
|
|
1334
|
-
return filter_interfaces_js_1.Filter.getPreciseValues(_this.metadata, filter ||
|
|
1348
|
+
return filter_interfaces_js_1.Filter.getPreciseValues(_this.metadata, filter || safeWhere);
|
|
1335
1349
|
},
|
|
1336
1350
|
})];
|
|
1337
1351
|
case 1:
|
|
1338
|
-
|
|
1352
|
+
safeWhere = _e.sent();
|
|
1339
1353
|
_e.label = 2;
|
|
1340
1354
|
case 2:
|
|
1341
1355
|
if (!this.metadata.options.backendPrefilter) return [3 /*break*/, 4];
|
|
1342
|
-
z =
|
|
1343
|
-
|
|
1344
|
-
|
|
1356
|
+
z = safeWhere;
|
|
1357
|
+
_b = {};
|
|
1358
|
+
_a = [z];
|
|
1345
1359
|
return [4 /*yield*/, filter_interfaces_js_1.Filter.resolve(this.metadata.options.backendPrefilter)];
|
|
1346
1360
|
case 3:
|
|
1347
|
-
|
|
1361
|
+
safeWhere = (_b.$and = _a.concat([
|
|
1348
1362
|
_e.sent()
|
|
1349
1363
|
]),
|
|
1350
|
-
|
|
1364
|
+
_b);
|
|
1351
1365
|
_e.label = 4;
|
|
1352
|
-
case 4: return [4 /*yield*/, filter_interfaces_js_1.Filter.fromEntityFilter(this.metadata,
|
|
1366
|
+
case 4: return [4 /*yield*/, filter_interfaces_js_1.Filter.fromEntityFilter(this.metadata, safeWhere)];
|
|
1353
1367
|
case 5:
|
|
1354
1368
|
r = _e.sent();
|
|
1355
1369
|
if (!(r && !this._dataProvider.isProxy)) return [3 /*break*/, 7];
|
|
@@ -1393,14 +1407,22 @@ function createOldEntity(entity, remult) {
|
|
|
1393
1407
|
var _loop_4 = function (key_1) {
|
|
1394
1408
|
if (baseSettings_1[key_1] && baseSettings_1[key_1] !== info[key_1]) {
|
|
1395
1409
|
var x_1 = info[key_1];
|
|
1410
|
+
//@ts-ignore
|
|
1396
1411
|
info[key_1] = function (a, b) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1397
1412
|
return tslib_1.__generator(this, function (_a) {
|
|
1398
1413
|
switch (_a.label) {
|
|
1399
|
-
case 0:
|
|
1414
|
+
case 0:
|
|
1415
|
+
//@ts-ignore
|
|
1416
|
+
return [4 /*yield*/, x_1(a, b)
|
|
1417
|
+
//@ts-ignore
|
|
1418
|
+
];
|
|
1400
1419
|
case 1:
|
|
1420
|
+
//@ts-ignore
|
|
1401
1421
|
_a.sent();
|
|
1422
|
+
//@ts-ignore
|
|
1402
1423
|
return [4 /*yield*/, baseSettings_1[key_1](a, b)];
|
|
1403
1424
|
case 2:
|
|
1425
|
+
//@ts-ignore
|
|
1404
1426
|
_a.sent();
|
|
1405
1427
|
return [2 /*return*/];
|
|
1406
1428
|
}
|
|
@@ -1409,15 +1431,15 @@ function createOldEntity(entity, remult) {
|
|
|
1409
1431
|
}
|
|
1410
1432
|
};
|
|
1411
1433
|
try {
|
|
1412
|
-
for (var
|
|
1413
|
-
var key_1 =
|
|
1434
|
+
for (var functions_1 = (e_22 = void 0, tslib_1.__values(functions)), functions_1_1 = functions_1.next(); !functions_1_1.done; functions_1_1 = functions_1.next()) {
|
|
1435
|
+
var key_1 = functions_1_1.value;
|
|
1414
1436
|
_loop_4(key_1);
|
|
1415
1437
|
}
|
|
1416
1438
|
}
|
|
1417
1439
|
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
1418
1440
|
finally {
|
|
1419
1441
|
try {
|
|
1420
|
-
if (
|
|
1442
|
+
if (functions_1_1 && !functions_1_1.done && (_a = functions_1.return)) _a.call(functions_1);
|
|
1421
1443
|
}
|
|
1422
1444
|
finally { if (e_22) throw e_22.error; }
|
|
1423
1445
|
}
|
|
@@ -1429,12 +1451,10 @@ function createOldEntity(entity, remult) {
|
|
|
1429
1451
|
}
|
|
1430
1452
|
return new EntityFullInfo(prepareColumnInfo(r, remult), info, remult, entity, key);
|
|
1431
1453
|
}
|
|
1432
|
-
exports.createOldEntity = createOldEntity;
|
|
1433
1454
|
var rowHelperBase = /** @class */ (function () {
|
|
1434
1455
|
function rowHelperBase(fieldsMetadata, instance, remult, isNewRow) {
|
|
1435
1456
|
var e_23, _a;
|
|
1436
1457
|
var _this = this;
|
|
1437
|
-
var _b;
|
|
1438
1458
|
this.fieldsMetadata = fieldsMetadata;
|
|
1439
1459
|
this.instance = instance;
|
|
1440
1460
|
this.remult = remult;
|
|
@@ -1485,37 +1505,41 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1485
1505
|
});
|
|
1486
1506
|
lookup_1.set(val);
|
|
1487
1507
|
}
|
|
1488
|
-
else
|
|
1489
|
-
var
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1508
|
+
else {
|
|
1509
|
+
var rel_1 = (0, relationInfoMember_js_1.getRelationFieldInfo)(col);
|
|
1510
|
+
if ((rel_1 === null || rel_1 === void 0 ? void 0 : rel_1.type) === 'toOne') {
|
|
1511
|
+
var hasVal = instance.hasOwnProperty(col.key);
|
|
1512
|
+
var val_1 = instance[col.key];
|
|
1513
|
+
if (isNewRow && !val_1)
|
|
1514
|
+
hasVal = false;
|
|
1515
|
+
Object.defineProperty(instance, col.key, {
|
|
1516
|
+
get: function () {
|
|
1517
|
+
return val_1;
|
|
1518
|
+
},
|
|
1519
|
+
set: function (newVal) {
|
|
1520
|
+
val_1 = newVal;
|
|
1521
|
+
if (newVal === undefined)
|
|
1522
|
+
return;
|
|
1523
|
+
var op = col.options;
|
|
1524
|
+
if (op.field) {
|
|
1525
|
+
_this.instance[op.field] =
|
|
1526
|
+
rel_1.toRepo.metadata.idMetadata.getId(newVal);
|
|
1527
|
+
}
|
|
1528
|
+
if (op.fields) {
|
|
1529
|
+
for (var key in op.fields) {
|
|
1530
|
+
if (Object.prototype.hasOwnProperty.call(op.fields, key)) {
|
|
1531
|
+
var element = op.fields[key];
|
|
1532
|
+
_this.instance[element] =
|
|
1533
|
+
newVal == null ? null : newVal[key];
|
|
1534
|
+
}
|
|
1511
1535
|
}
|
|
1512
1536
|
}
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1537
|
+
},
|
|
1538
|
+
enumerable: true,
|
|
1539
|
+
});
|
|
1540
|
+
if (hasVal)
|
|
1541
|
+
instance[col.key] = val_1;
|
|
1542
|
+
}
|
|
1519
1543
|
}
|
|
1520
1544
|
};
|
|
1521
1545
|
var this_2 = this;
|
|
@@ -1553,9 +1577,9 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1553
1577
|
};
|
|
1554
1578
|
rowHelperBase.prototype.initSubscribers = function () {
|
|
1555
1579
|
var e_24, _a;
|
|
1556
|
-
var _this = this;
|
|
1557
1580
|
if (!this._subscribers) {
|
|
1558
1581
|
this._subscribers = new SubscribableImp();
|
|
1582
|
+
var safeSubscribers_1 = this._subscribers;
|
|
1559
1583
|
var _loop_6 = function (col) {
|
|
1560
1584
|
var ei = (0, getEntityRef_js_1.getEntitySettings)(col.valueType, false);
|
|
1561
1585
|
var refImpl = this_3.fields.find(col.key);
|
|
@@ -1566,13 +1590,13 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1566
1590
|
var val_2 = this_3.instance[col.key];
|
|
1567
1591
|
Object.defineProperty(this_3.instance, col.key, {
|
|
1568
1592
|
get: function () {
|
|
1569
|
-
|
|
1593
|
+
safeSubscribers_1.reportObserved();
|
|
1570
1594
|
refImpl._subscribers.reportObserved();
|
|
1571
1595
|
return val_2;
|
|
1572
1596
|
},
|
|
1573
1597
|
set: function (value) {
|
|
1574
1598
|
val_2 = value;
|
|
1575
|
-
|
|
1599
|
+
safeSubscribers_1.reportChanged();
|
|
1576
1600
|
refImpl._subscribers.reportChanged();
|
|
1577
1601
|
},
|
|
1578
1602
|
enumerable: true,
|
|
@@ -1627,17 +1651,20 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1627
1651
|
};
|
|
1628
1652
|
rowHelperBase.prototype.buildErrorInfoObject = function () {
|
|
1629
1653
|
var e_25, _a;
|
|
1654
|
+
var _b;
|
|
1630
1655
|
var error = {
|
|
1631
1656
|
modelState: Object.assign({}, this.errors),
|
|
1632
1657
|
message: this.error,
|
|
1633
1658
|
};
|
|
1634
1659
|
if (!error.message) {
|
|
1635
1660
|
try {
|
|
1636
|
-
for (var
|
|
1637
|
-
var col =
|
|
1638
|
-
if (this.errors[col.key]) {
|
|
1661
|
+
for (var _c = tslib_1.__values(this.fieldsMetadata), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1662
|
+
var col = _d.value;
|
|
1663
|
+
if ((_b = this.errors) === null || _b === void 0 ? void 0 : _b[col.key]) {
|
|
1639
1664
|
error.message =
|
|
1640
|
-
this.fields[col.key].metadata.caption +
|
|
1665
|
+
this.fields[col.key].metadata.caption +
|
|
1666
|
+
': ' +
|
|
1667
|
+
this.errors[col.key];
|
|
1641
1668
|
this.error = error.message;
|
|
1642
1669
|
break;
|
|
1643
1670
|
}
|
|
@@ -1646,7 +1673,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1646
1673
|
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
1647
1674
|
finally {
|
|
1648
1675
|
try {
|
|
1649
|
-
if (
|
|
1676
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1650
1677
|
}
|
|
1651
1678
|
finally { if (e_25) throw e_25.error; }
|
|
1652
1679
|
}
|
|
@@ -1853,11 +1880,11 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1853
1880
|
}
|
|
1854
1881
|
return result;
|
|
1855
1882
|
};
|
|
1856
|
-
rowHelperBase.prototype._updateEntityBasedOnApi = function (
|
|
1857
|
-
|
|
1858
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1883
|
+
rowHelperBase.prototype._updateEntityBasedOnApi = function (body_1) {
|
|
1884
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (body, ignoreApiAllowed) {
|
|
1859
1885
|
var keys, _a, _b, col, lu;
|
|
1860
1886
|
var e_29, _c;
|
|
1887
|
+
if (ignoreApiAllowed === void 0) { ignoreApiAllowed = false; }
|
|
1861
1888
|
return tslib_1.__generator(this, function (_d) {
|
|
1862
1889
|
switch (_d.label) {
|
|
1863
1890
|
case 0:
|
|
@@ -1912,12 +1939,13 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1912
1939
|
try {
|
|
1913
1940
|
for (var _b = tslib_1.__values(info.fieldsMetadata), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1914
1941
|
var col = _c.value;
|
|
1915
|
-
|
|
1942
|
+
var colKey = col.key;
|
|
1943
|
+
if (col.options.defaultValue && instance[colKey] === undefined) {
|
|
1916
1944
|
if (typeof col.options.defaultValue === 'function') {
|
|
1917
|
-
instance[
|
|
1945
|
+
instance[colKey] = col.options.defaultValue(instance);
|
|
1918
1946
|
}
|
|
1919
|
-
else if (!instance[
|
|
1920
|
-
instance[
|
|
1947
|
+
else if (!instance[colKey])
|
|
1948
|
+
instance[colKey] = col.options.defaultValue;
|
|
1921
1949
|
}
|
|
1922
1950
|
}
|
|
1923
1951
|
}
|
|
@@ -2032,7 +2060,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2032
2060
|
if (!this._columns) {
|
|
2033
2061
|
var _items_1 = [];
|
|
2034
2062
|
var r_1 = (_a = {
|
|
2063
|
+
//@ts-ignore
|
|
2035
2064
|
find: function (c) {
|
|
2065
|
+
//@ts-ignore
|
|
2036
2066
|
return r_1[typeof c === 'string' ? c : c.key];
|
|
2037
2067
|
}
|
|
2038
2068
|
},
|
|
@@ -2042,7 +2072,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2042
2072
|
try {
|
|
2043
2073
|
for (var _c = tslib_1.__values(this.info.fieldsMetadata), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2044
2074
|
var c = _d.value;
|
|
2045
|
-
_items_1.push(
|
|
2075
|
+
_items_1.push(
|
|
2076
|
+
//@ts-ignore
|
|
2077
|
+
(r_1[c.key] = new FieldRefImplementation(c.options, c, this.instance, this, this)));
|
|
2046
2078
|
}
|
|
2047
2079
|
}
|
|
2048
2080
|
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
@@ -2060,14 +2092,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2060
2092
|
configurable: true
|
|
2061
2093
|
});
|
|
2062
2094
|
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2063
|
-
var _a;
|
|
2064
2095
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2065
|
-
var doNotSave_1, e,
|
|
2066
|
-
var e_32,
|
|
2067
|
-
|
|
2068
|
-
|
|
2096
|
+
var doNotSave_1, e, _a, _b, col, e_32_1, d, ignoreKeys, _c, _d, field, f, updatedRow, isNew, _e, _f, changesOnly, wasChanged, key, element, _g, _h, _j, _k, listener, e_33_1, err_1;
|
|
2097
|
+
var e_32, _l, e_34, _m, _o, _p, e_33, _q;
|
|
2098
|
+
var _r, _s;
|
|
2099
|
+
return tslib_1.__generator(this, function (_t) {
|
|
2100
|
+
switch (_t.label) {
|
|
2069
2101
|
case 0:
|
|
2070
|
-
|
|
2102
|
+
_t.trys.push([0, , 41, 42]);
|
|
2071
2103
|
if (this._saving)
|
|
2072
2104
|
throw new Error('cannot save while entity is already saving');
|
|
2073
2105
|
this._saving = true;
|
|
@@ -2080,36 +2112,36 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2080
2112
|
return [4 /*yield*/, this.__validateEntity()];
|
|
2081
2113
|
case 1:
|
|
2082
2114
|
// no need
|
|
2083
|
-
|
|
2084
|
-
|
|
2115
|
+
_t.sent();
|
|
2116
|
+
_t.label = 2;
|
|
2085
2117
|
case 2:
|
|
2086
2118
|
doNotSave_1 = false;
|
|
2087
2119
|
e = this.buildLifeCycleEvent(function () { return (doNotSave_1 = true); });
|
|
2088
2120
|
if (!!this.repository._dataProvider.isProxy) return [3 /*break*/, 12];
|
|
2089
|
-
|
|
2121
|
+
_t.label = 3;
|
|
2090
2122
|
case 3:
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2123
|
+
_t.trys.push([3, 8, 9, 10]);
|
|
2124
|
+
_a = tslib_1.__values(this.fields), _b = _a.next();
|
|
2125
|
+
_t.label = 4;
|
|
2094
2126
|
case 4:
|
|
2095
|
-
if (!!
|
|
2096
|
-
col =
|
|
2127
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
2128
|
+
col = _b.value;
|
|
2097
2129
|
if (!col.metadata.options.saving) return [3 /*break*/, 6];
|
|
2098
2130
|
return [4 /*yield*/, col.metadata.options.saving(this.instance, col, e)];
|
|
2099
2131
|
case 5:
|
|
2100
|
-
|
|
2101
|
-
|
|
2132
|
+
_t.sent();
|
|
2133
|
+
_t.label = 6;
|
|
2102
2134
|
case 6:
|
|
2103
|
-
|
|
2135
|
+
_b = _a.next();
|
|
2104
2136
|
return [3 /*break*/, 4];
|
|
2105
2137
|
case 7: return [3 /*break*/, 10];
|
|
2106
2138
|
case 8:
|
|
2107
|
-
e_32_1 =
|
|
2139
|
+
e_32_1 = _t.sent();
|
|
2108
2140
|
e_32 = { error: e_32_1 };
|
|
2109
2141
|
return [3 /*break*/, 10];
|
|
2110
2142
|
case 9:
|
|
2111
2143
|
try {
|
|
2112
|
-
if (
|
|
2144
|
+
if (_b && !_b.done && (_l = _a.return)) _l.call(_a);
|
|
2113
2145
|
}
|
|
2114
2146
|
finally { if (e_32) throw e_32.error; }
|
|
2115
2147
|
return [7 /*endfinally*/];
|
|
@@ -2117,15 +2149,15 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2117
2149
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 12];
|
|
2118
2150
|
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, e)];
|
|
2119
2151
|
case 11:
|
|
2120
|
-
|
|
2121
|
-
|
|
2152
|
+
_t.sent();
|
|
2153
|
+
_t.label = 12;
|
|
2122
2154
|
case 12:
|
|
2123
2155
|
this.__assertValidity();
|
|
2124
2156
|
d = this.copyDataToObject(this.isNew());
|
|
2125
2157
|
ignoreKeys = [];
|
|
2126
2158
|
try {
|
|
2127
|
-
for (
|
|
2128
|
-
field =
|
|
2159
|
+
for (_c = tslib_1.__values(this.metadata.fields), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2160
|
+
field = _d.value;
|
|
2129
2161
|
if (field.dbReadOnly ||
|
|
2130
2162
|
(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !==
|
|
2131
2163
|
undefined &&
|
|
@@ -2140,22 +2172,32 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2140
2172
|
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
2141
2173
|
finally {
|
|
2142
2174
|
try {
|
|
2143
|
-
if (
|
|
2175
|
+
if (_d && !_d.done && (_m = _c.return)) _m.call(_c);
|
|
2144
2176
|
}
|
|
2145
2177
|
finally { if (e_34) throw e_34.error; }
|
|
2146
2178
|
}
|
|
2147
2179
|
updatedRow = void 0;
|
|
2148
2180
|
isNew = this.isNew();
|
|
2149
|
-
|
|
2181
|
+
_t.label = 13;
|
|
2150
2182
|
case 13:
|
|
2151
|
-
|
|
2152
|
-
(
|
|
2153
|
-
if (!this.isNew()) return [3 /*break*/,
|
|
2154
|
-
return [
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
return [
|
|
2183
|
+
_t.trys.push([13, 38, , 40]);
|
|
2184
|
+
(_r = this._subscribers) === null || _r === void 0 ? void 0 : _r.reportChanged();
|
|
2185
|
+
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2186
|
+
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
2187
|
+
_f = (_e = this.edp).find;
|
|
2188
|
+
_o = {};
|
|
2189
|
+
return [4 /*yield*/, this.getIdFilter()];
|
|
2190
|
+
case 14: return [4 /*yield*/, _f.apply(_e, [(_o.where = _t.sent(),
|
|
2191
|
+
_o)])];
|
|
2158
2192
|
case 15:
|
|
2193
|
+
updatedRow = (updatedRow = _t.sent())[0];
|
|
2194
|
+
return [3 /*break*/, 18];
|
|
2195
|
+
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2196
|
+
case 17:
|
|
2197
|
+
updatedRow = _t.sent();
|
|
2198
|
+
_t.label = 18;
|
|
2199
|
+
case 18: return [3 /*break*/, 24];
|
|
2200
|
+
case 19:
|
|
2159
2201
|
changesOnly = {};
|
|
2160
2202
|
wasChanged = false;
|
|
2161
2203
|
for (key in d) {
|
|
@@ -2170,75 +2212,77 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2170
2212
|
}
|
|
2171
2213
|
if (!wasChanged)
|
|
2172
2214
|
return [2 /*return*/, this.instance];
|
|
2173
|
-
if (!doNotSave_1) return [3 /*break*/,
|
|
2174
|
-
|
|
2175
|
-
|
|
2215
|
+
if (!doNotSave_1) return [3 /*break*/, 22];
|
|
2216
|
+
_h = (_g = this.edp).find;
|
|
2217
|
+
_p = {};
|
|
2176
2218
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2177
|
-
case
|
|
2178
|
-
case 17:
|
|
2179
|
-
updatedRow = (_p.sent())[0];
|
|
2180
|
-
return [3 /*break*/, 20];
|
|
2181
|
-
case 18: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2182
|
-
case 19:
|
|
2183
|
-
updatedRow = _p.sent();
|
|
2184
|
-
_p.label = 20;
|
|
2185
|
-
case 20: return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2219
|
+
case 20: return [4 /*yield*/, _h.apply(_g, [(_p.where = _t.sent(), _p)])];
|
|
2186
2220
|
case 21:
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
if (!this.info.entityInfo.saved) return [3 /*break*/, 23];
|
|
2191
|
-
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2192
|
-
case 22:
|
|
2193
|
-
_p.sent();
|
|
2194
|
-
_p.label = 23;
|
|
2221
|
+
updatedRow = (_t.sent())[0];
|
|
2222
|
+
return [3 /*break*/, 24];
|
|
2223
|
+
case 22: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2195
2224
|
case 23:
|
|
2196
|
-
|
|
2197
|
-
|
|
2225
|
+
updatedRow = _t.sent();
|
|
2226
|
+
_t.label = 24;
|
|
2198
2227
|
case 24:
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
_p.label = 25;
|
|
2228
|
+
if (!updatedRow) return [3 /*break*/, 26];
|
|
2229
|
+
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2202
2230
|
case 25:
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
return [4 /*yield*/, listener.saved(this.instance, isNew)];
|
|
2231
|
+
_t.sent();
|
|
2232
|
+
_t.label = 26;
|
|
2206
2233
|
case 26:
|
|
2207
|
-
|
|
2208
|
-
|
|
2234
|
+
e.id = this.getId();
|
|
2235
|
+
if (!!this.repository._dataProvider.isProxy) return [3 /*break*/, 36];
|
|
2236
|
+
if (!this.info.entityInfo.saved) return [3 /*break*/, 28];
|
|
2237
|
+
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2209
2238
|
case 27:
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
case 28:
|
|
2239
|
+
_t.sent();
|
|
2240
|
+
_t.label = 28;
|
|
2241
|
+
case 28:
|
|
2242
|
+
if (!this.repository.listeners) return [3 /*break*/, 36];
|
|
2243
|
+
_t.label = 29;
|
|
2213
2244
|
case 29:
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2245
|
+
_t.trys.push([29, 34, 35, 36]);
|
|
2246
|
+
_j = tslib_1.__values(this.repository.listeners), _k = _j.next();
|
|
2247
|
+
_t.label = 30;
|
|
2217
2248
|
case 30:
|
|
2249
|
+
if (!!_k.done) return [3 /*break*/, 33];
|
|
2250
|
+
listener = _k.value;
|
|
2251
|
+
return [4 /*yield*/, ((_s = listener.saved) === null || _s === void 0 ? void 0 : _s.call(listener, this.instance, isNew))];
|
|
2252
|
+
case 31:
|
|
2253
|
+
_t.sent();
|
|
2254
|
+
_t.label = 32;
|
|
2255
|
+
case 32:
|
|
2256
|
+
_k = _j.next();
|
|
2257
|
+
return [3 /*break*/, 30];
|
|
2258
|
+
case 33: return [3 /*break*/, 36];
|
|
2259
|
+
case 34:
|
|
2260
|
+
e_33_1 = _t.sent();
|
|
2261
|
+
e_33 = { error: e_33_1 };
|
|
2262
|
+
return [3 /*break*/, 36];
|
|
2263
|
+
case 35:
|
|
2218
2264
|
try {
|
|
2219
|
-
if (
|
|
2265
|
+
if (_k && !_k.done && (_q = _j.return)) _q.call(_j);
|
|
2220
2266
|
}
|
|
2221
2267
|
finally { if (e_33) throw e_33.error; }
|
|
2222
2268
|
return [7 /*endfinally*/];
|
|
2223
|
-
case
|
|
2224
|
-
case
|
|
2225
|
-
|
|
2269
|
+
case 36: return [4 /*yield*/, this.repository._remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }])];
|
|
2270
|
+
case 37:
|
|
2271
|
+
_t.sent();
|
|
2226
2272
|
this.saveOriginalData();
|
|
2227
2273
|
this._isNew = false;
|
|
2228
2274
|
return [2 /*return*/, this.instance];
|
|
2229
|
-
case
|
|
2230
|
-
err_1 =
|
|
2275
|
+
case 38:
|
|
2276
|
+
err_1 = _t.sent();
|
|
2231
2277
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2232
|
-
case
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
case 35: return [3 /*break*/, 37];
|
|
2236
|
-
case 36:
|
|
2278
|
+
case 39: throw _t.sent();
|
|
2279
|
+
case 40: return [3 /*break*/, 42];
|
|
2280
|
+
case 41:
|
|
2237
2281
|
this.isLoading = false;
|
|
2238
2282
|
this._reportChangedToEntityAndFields();
|
|
2239
2283
|
this._saving = false;
|
|
2240
2284
|
return [7 /*endfinally*/];
|
|
2241
|
-
case
|
|
2285
|
+
case 42: return [2 /*return*/];
|
|
2242
2286
|
}
|
|
2243
2287
|
});
|
|
2244
2288
|
});
|
|
@@ -2320,8 +2364,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2320
2364
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2321
2365
|
var doDelete, e, _a, _b, listener, e_36_1, err_2;
|
|
2322
2366
|
var e_36, _c;
|
|
2323
|
-
|
|
2324
|
-
|
|
2367
|
+
var _d;
|
|
2368
|
+
return tslib_1.__generator(this, function (_e) {
|
|
2369
|
+
switch (_e.label) {
|
|
2325
2370
|
case 0:
|
|
2326
2371
|
this.__clearErrorsAndReportChanged();
|
|
2327
2372
|
doDelete = true;
|
|
@@ -2330,45 +2375,45 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2330
2375
|
if (!this.info.entityInfo.deleting) return [3 /*break*/, 2];
|
|
2331
2376
|
return [4 /*yield*/, this.info.entityInfo.deleting(this.instance, e)];
|
|
2332
2377
|
case 1:
|
|
2333
|
-
|
|
2334
|
-
|
|
2378
|
+
_e.sent();
|
|
2379
|
+
_e.label = 2;
|
|
2335
2380
|
case 2:
|
|
2336
2381
|
this.__assertValidity();
|
|
2337
|
-
|
|
2382
|
+
_e.label = 3;
|
|
2338
2383
|
case 3:
|
|
2339
|
-
|
|
2384
|
+
_e.trys.push([3, 17, , 19]);
|
|
2340
2385
|
if (!doDelete) return [3 /*break*/, 5];
|
|
2341
2386
|
return [4 /*yield*/, this.edp.delete(this.id)];
|
|
2342
2387
|
case 4:
|
|
2343
|
-
|
|
2344
|
-
|
|
2388
|
+
_e.sent();
|
|
2389
|
+
_e.label = 5;
|
|
2345
2390
|
case 5:
|
|
2346
2391
|
if (!!this.repository._dataProvider.isProxy) return [3 /*break*/, 7];
|
|
2347
2392
|
if (!this.info.entityInfo.deleted) return [3 /*break*/, 7];
|
|
2348
2393
|
return [4 /*yield*/, this.info.entityInfo.deleted(this.instance, e)];
|
|
2349
2394
|
case 6:
|
|
2350
|
-
|
|
2351
|
-
|
|
2395
|
+
_e.sent();
|
|
2396
|
+
_e.label = 7;
|
|
2352
2397
|
case 7:
|
|
2353
2398
|
if (!this.repository.listeners) return [3 /*break*/, 15];
|
|
2354
|
-
|
|
2399
|
+
_e.label = 8;
|
|
2355
2400
|
case 8:
|
|
2356
|
-
|
|
2357
|
-
_a = tslib_1.__values(this.repository.listeners
|
|
2358
|
-
|
|
2401
|
+
_e.trys.push([8, 13, 14, 15]);
|
|
2402
|
+
_a = tslib_1.__values(this.repository.listeners), _b = _a.next();
|
|
2403
|
+
_e.label = 9;
|
|
2359
2404
|
case 9:
|
|
2360
2405
|
if (!!_b.done) return [3 /*break*/, 12];
|
|
2361
2406
|
listener = _b.value;
|
|
2362
|
-
return [4 /*yield*/, listener.deleted(this.instance)];
|
|
2407
|
+
return [4 /*yield*/, ((_d = listener.deleted) === null || _d === void 0 ? void 0 : _d.call(listener, this.instance))];
|
|
2363
2408
|
case 10:
|
|
2364
|
-
|
|
2365
|
-
|
|
2409
|
+
_e.sent();
|
|
2410
|
+
_e.label = 11;
|
|
2366
2411
|
case 11:
|
|
2367
2412
|
_b = _a.next();
|
|
2368
2413
|
return [3 /*break*/, 9];
|
|
2369
2414
|
case 12: return [3 /*break*/, 15];
|
|
2370
2415
|
case 13:
|
|
2371
|
-
e_36_1 =
|
|
2416
|
+
e_36_1 = _e.sent();
|
|
2372
2417
|
e_36 = { error: e_36_1 };
|
|
2373
2418
|
return [3 /*break*/, 15];
|
|
2374
2419
|
case 14:
|
|
@@ -2379,15 +2424,13 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2379
2424
|
return [7 /*endfinally*/];
|
|
2380
2425
|
case 15: return [4 /*yield*/, this.repository._remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }])];
|
|
2381
2426
|
case 16:
|
|
2382
|
-
|
|
2427
|
+
_e.sent();
|
|
2383
2428
|
this._wasDeleted = true;
|
|
2384
2429
|
return [3 /*break*/, 19];
|
|
2385
2430
|
case 17:
|
|
2386
|
-
err_2 =
|
|
2431
|
+
err_2 = _e.sent();
|
|
2387
2432
|
return [4 /*yield*/, this.catchSaveErrors(err_2)];
|
|
2388
|
-
case 18:
|
|
2389
|
-
_d.sent();
|
|
2390
|
-
return [3 /*break*/, 19];
|
|
2433
|
+
case 18: throw _e.sent();
|
|
2391
2434
|
case 19: return [2 /*return*/];
|
|
2392
2435
|
}
|
|
2393
2436
|
});
|
|
@@ -2474,7 +2517,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2474
2517
|
_d = col.key;
|
|
2475
2518
|
return [4 /*yield*/, col.options.serverExpression(this.instance)];
|
|
2476
2519
|
case 3:
|
|
2477
|
-
_c[_d] =
|
|
2520
|
+
_c[_d] =
|
|
2521
|
+
_f.sent();
|
|
2478
2522
|
_f.label = 4;
|
|
2479
2523
|
case 4:
|
|
2480
2524
|
_b = _a.next();
|
|
@@ -2526,12 +2570,13 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2526
2570
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2527
2571
|
var _a, _b, c, col, e_40_1, e, _c, _d, listener, e_41_1;
|
|
2528
2572
|
var e_40, _e, e_41, _f;
|
|
2529
|
-
|
|
2530
|
-
|
|
2573
|
+
var _g;
|
|
2574
|
+
return tslib_1.__generator(this, function (_h) {
|
|
2575
|
+
switch (_h.label) {
|
|
2531
2576
|
case 0:
|
|
2532
|
-
|
|
2577
|
+
_h.trys.push([0, 5, 6, 7]);
|
|
2533
2578
|
_a = tslib_1.__values(this.fieldsMetadata), _b = _a.next();
|
|
2534
|
-
|
|
2579
|
+
_h.label = 1;
|
|
2535
2580
|
case 1:
|
|
2536
2581
|
if (!!_b.done) return [3 /*break*/, 4];
|
|
2537
2582
|
c = _b.value;
|
|
@@ -2539,14 +2584,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2539
2584
|
col = new FieldRefImplementation(c.options, c, this.instance, this, this);
|
|
2540
2585
|
return [4 /*yield*/, col.__performValidation()];
|
|
2541
2586
|
case 2:
|
|
2542
|
-
|
|
2543
|
-
|
|
2587
|
+
_h.sent();
|
|
2588
|
+
_h.label = 3;
|
|
2544
2589
|
case 3:
|
|
2545
2590
|
_b = _a.next();
|
|
2546
2591
|
return [3 /*break*/, 1];
|
|
2547
2592
|
case 4: return [3 /*break*/, 7];
|
|
2548
2593
|
case 5:
|
|
2549
|
-
e_40_1 =
|
|
2594
|
+
e_40_1 = _h.sent();
|
|
2550
2595
|
e_40 = { error: e_40_1 };
|
|
2551
2596
|
return [3 /*break*/, 7];
|
|
2552
2597
|
case 6:
|
|
@@ -2560,28 +2605,28 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2560
2605
|
e = this.buildLifeCycleEvent(function () { });
|
|
2561
2606
|
return [4 /*yield*/, this.info.entityInfo.validation(this.instance, e)];
|
|
2562
2607
|
case 8:
|
|
2563
|
-
|
|
2564
|
-
|
|
2608
|
+
_h.sent();
|
|
2609
|
+
_h.label = 9;
|
|
2565
2610
|
case 9:
|
|
2566
2611
|
if (!this.repository.listeners) return [3 /*break*/, 17];
|
|
2567
|
-
|
|
2612
|
+
_h.label = 10;
|
|
2568
2613
|
case 10:
|
|
2569
|
-
|
|
2570
|
-
_c = tslib_1.__values(this.repository.listeners
|
|
2571
|
-
|
|
2614
|
+
_h.trys.push([10, 15, 16, 17]);
|
|
2615
|
+
_c = tslib_1.__values(this.repository.listeners), _d = _c.next();
|
|
2616
|
+
_h.label = 11;
|
|
2572
2617
|
case 11:
|
|
2573
2618
|
if (!!_d.done) return [3 /*break*/, 14];
|
|
2574
2619
|
listener = _d.value;
|
|
2575
|
-
return [4 /*yield*/, listener.validating(this.instance)];
|
|
2620
|
+
return [4 /*yield*/, ((_g = listener.validating) === null || _g === void 0 ? void 0 : _g.call(listener, this.instance))];
|
|
2576
2621
|
case 12:
|
|
2577
|
-
|
|
2578
|
-
|
|
2622
|
+
_h.sent();
|
|
2623
|
+
_h.label = 13;
|
|
2579
2624
|
case 13:
|
|
2580
2625
|
_d = _c.next();
|
|
2581
2626
|
return [3 /*break*/, 11];
|
|
2582
2627
|
case 14: return [3 /*break*/, 17];
|
|
2583
2628
|
case 15:
|
|
2584
|
-
e_41_1 =
|
|
2629
|
+
e_41_1 = _h.sent();
|
|
2585
2630
|
e_41 = { error: e_41_1 };
|
|
2586
2631
|
return [3 /*break*/, 17];
|
|
2587
2632
|
case 16:
|
|
@@ -2605,10 +2650,11 @@ function prepareColumnInfo(r, remult) {
|
|
|
2605
2650
|
function getFields(container, remult) {
|
|
2606
2651
|
return getControllerRef(container, remult).fields;
|
|
2607
2652
|
}
|
|
2608
|
-
exports.getFields = getFields;
|
|
2609
2653
|
function getControllerRef(container, remultArg) {
|
|
2610
2654
|
var remultVar = remultArg || remult_proxy_js_1.remult;
|
|
2655
|
+
//@ts-ignore
|
|
2611
2656
|
var result = container[controllerColumns];
|
|
2657
|
+
//@ts-ignore
|
|
2612
2658
|
if (!result)
|
|
2613
2659
|
result = container[getEntityRef_js_1.entityMember];
|
|
2614
2660
|
if (!result) {
|
|
@@ -2623,11 +2669,14 @@ function getControllerRef(container, remultArg) {
|
|
|
2623
2669
|
}
|
|
2624
2670
|
base = Object.getPrototypeOf(base);
|
|
2625
2671
|
}
|
|
2626
|
-
|
|
2672
|
+
//@ts-ignore
|
|
2673
|
+
container[controllerColumns] = result = new controllerRefImpl(prepareColumnInfo(columnSettings_1, remultVar).map(function (x) {
|
|
2674
|
+
return new columnDefsImpl(x, undefined, //TODO - not sure
|
|
2675
|
+
remultVar);
|
|
2676
|
+
}), container, remultVar);
|
|
2627
2677
|
}
|
|
2628
2678
|
return result;
|
|
2629
2679
|
}
|
|
2630
|
-
exports.getControllerRef = getControllerRef;
|
|
2631
2680
|
var controllerRefImpl = /** @class */ (function (_super) {
|
|
2632
2681
|
tslib_1.__extends(controllerRefImpl, _super);
|
|
2633
2682
|
function controllerRefImpl(columnsInfo, instance, remult) {
|
|
@@ -2706,7 +2755,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2706
2755
|
this.helper = helper;
|
|
2707
2756
|
this.rowBase = rowBase;
|
|
2708
2757
|
this.target = this.settings.target;
|
|
2709
|
-
this.entityRef = this.helper;
|
|
2758
|
+
this.entityRef = this.helper; //todo - I'm not sure this is correct in the case of ControllerInstance
|
|
2710
2759
|
}
|
|
2711
2760
|
FieldRefImplementation.prototype.subscribe = function (listener) {
|
|
2712
2761
|
if (!this._subscribers) {
|
|
@@ -2735,12 +2784,11 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2735
2784
|
case 0:
|
|
2736
2785
|
lu = this.rowBase.lookups.get(this.metadata.key);
|
|
2737
2786
|
rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(this.metadata);
|
|
2738
|
-
if (!rel) return [3 /*break*/, 5];
|
|
2787
|
+
if (!(rel && this.helper)) return [3 /*break*/, 5];
|
|
2739
2788
|
if (!(rel.type === 'toMany')) return [3 /*break*/, 2];
|
|
2740
2789
|
_a = this.container;
|
|
2741
2790
|
_b = this.metadata.key;
|
|
2742
|
-
return [4 /*yield*/, this.helper.repository
|
|
2743
|
-
.relations(this.container)[this.metadata.key].find()];
|
|
2791
|
+
return [4 /*yield*/, this.helper.repository.relations(this.container)[this.metadata.key].find()];
|
|
2744
2792
|
case 1: return [2 /*return*/, (_a[_b] = _c.sent())];
|
|
2745
2793
|
case 2: return [4 /*yield*/, this.helper.repository
|
|
2746
2794
|
.relations(this.container)[this.metadata.key].findOne()];
|
|
@@ -2749,7 +2797,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2749
2797
|
if (val)
|
|
2750
2798
|
this.container[this.metadata.key] = val;
|
|
2751
2799
|
else
|
|
2752
|
-
return [2 /*return*/, null];
|
|
2800
|
+
return [2 /*return*/, null]; //TODO: check if this (!) is correct
|
|
2753
2801
|
_c.label = 4;
|
|
2754
2802
|
case 4: return [3 /*break*/, 9];
|
|
2755
2803
|
case 5:
|
|
@@ -2870,15 +2918,15 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2870
2918
|
return (JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key])) != JSON.stringify(this.metadata.valueConverter.toJson(val)));
|
|
2871
2919
|
};
|
|
2872
2920
|
FieldRefImplementation.prototype.__performValidation = function () {
|
|
2873
|
-
var _a;
|
|
2874
2921
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2875
|
-
var processValidation, self_1, event_1,
|
|
2876
|
-
var e_44,
|
|
2922
|
+
var processValidation, self_1, event_1, _a, _b, v, _c, e_44_1, _d, error_1;
|
|
2923
|
+
var e_44, _e;
|
|
2877
2924
|
var _this = this;
|
|
2878
|
-
|
|
2879
|
-
|
|
2925
|
+
var _f, _g;
|
|
2926
|
+
return tslib_1.__generator(this, function (_h) {
|
|
2927
|
+
switch (_h.label) {
|
|
2880
2928
|
case 0:
|
|
2881
|
-
|
|
2929
|
+
_h.trys.push([0, 12, , 13]);
|
|
2882
2930
|
processValidation = function (result) {
|
|
2883
2931
|
if (result !== true && result !== undefined && !_this.error) {
|
|
2884
2932
|
if (typeof result === 'string' && result.length > 0)
|
|
@@ -2897,7 +2945,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2897
2945
|
set error(value) {
|
|
2898
2946
|
self_1.error = value;
|
|
2899
2947
|
},
|
|
2900
|
-
isNew: (
|
|
2948
|
+
isNew: (_g = (_f = this.entityRef) === null || _f === void 0 ? void 0 : _f.isNew()) !== null && _g !== void 0 ? _g : false,
|
|
2901
2949
|
load: function () { return self_1.load(); },
|
|
2902
2950
|
metadata: self_1.metadata,
|
|
2903
2951
|
originalValue: self_1.originalValue,
|
|
@@ -2908,48 +2956,48 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2908
2956
|
isBackend: function () { var _a, _b, _c; return !((_c = (_b = (_a = self_1.rowBase) === null || _a === void 0 ? void 0 : _a.remult) === null || _b === void 0 ? void 0 : _b.dataProvider) === null || _c === void 0 ? void 0 : _c.isProxy); },
|
|
2909
2957
|
};
|
|
2910
2958
|
if (!Array.isArray(this.settings.validate)) return [3 /*break*/, 9];
|
|
2911
|
-
|
|
2959
|
+
_h.label = 1;
|
|
2912
2960
|
case 1:
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2961
|
+
_h.trys.push([1, 6, 7, 8]);
|
|
2962
|
+
_a = tslib_1.__values(this.settings.validate), _b = _a.next();
|
|
2963
|
+
_h.label = 2;
|
|
2916
2964
|
case 2:
|
|
2917
|
-
if (!!
|
|
2918
|
-
v =
|
|
2919
|
-
|
|
2965
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
2966
|
+
v = _b.value;
|
|
2967
|
+
_c = processValidation;
|
|
2920
2968
|
return [4 /*yield*/, v(this.container, event_1)];
|
|
2921
2969
|
case 3:
|
|
2922
|
-
|
|
2923
|
-
|
|
2970
|
+
_c.apply(void 0, [_h.sent()]);
|
|
2971
|
+
_h.label = 4;
|
|
2924
2972
|
case 4:
|
|
2925
|
-
|
|
2973
|
+
_b = _a.next();
|
|
2926
2974
|
return [3 /*break*/, 2];
|
|
2927
2975
|
case 5: return [3 /*break*/, 8];
|
|
2928
2976
|
case 6:
|
|
2929
|
-
e_44_1 =
|
|
2977
|
+
e_44_1 = _h.sent();
|
|
2930
2978
|
e_44 = { error: e_44_1 };
|
|
2931
2979
|
return [3 /*break*/, 8];
|
|
2932
2980
|
case 7:
|
|
2933
2981
|
try {
|
|
2934
|
-
if (
|
|
2982
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
2935
2983
|
}
|
|
2936
2984
|
finally { if (e_44) throw e_44.error; }
|
|
2937
2985
|
return [7 /*endfinally*/];
|
|
2938
2986
|
case 8: return [3 /*break*/, 11];
|
|
2939
2987
|
case 9:
|
|
2940
2988
|
if (!(typeof this.settings.validate === 'function')) return [3 /*break*/, 11];
|
|
2941
|
-
|
|
2989
|
+
_d = processValidation;
|
|
2942
2990
|
return [4 /*yield*/, this.settings.validate(this.container, event_1)];
|
|
2943
2991
|
case 10:
|
|
2944
|
-
|
|
2945
|
-
|
|
2992
|
+
_d.apply(void 0, [_h.sent()]);
|
|
2993
|
+
_h.label = 11;
|
|
2946
2994
|
case 11: return [3 /*break*/, 13];
|
|
2947
2995
|
case 12:
|
|
2948
|
-
error_1 =
|
|
2996
|
+
error_1 = _h.sent();
|
|
2949
2997
|
if (typeof error_1 === 'string')
|
|
2950
2998
|
this.error = error_1;
|
|
2951
2999
|
else
|
|
2952
|
-
this.error = error_1.message;
|
|
3000
|
+
this.error = error_1 === null || error_1 === void 0 ? void 0 : error_1.message;
|
|
2953
3001
|
return [3 /*break*/, 13];
|
|
2954
3002
|
case 13: return [2 /*return*/];
|
|
2955
3003
|
}
|
|
@@ -2977,30 +3025,32 @@ var tempCaptionTransformer = {
|
|
|
2977
3025
|
exports.CaptionTransformer = remult_static_js_1.remultStatic.captionTransformer ||
|
|
2978
3026
|
(remult_static_js_1.remultStatic.captionTransformer = tempCaptionTransformer);
|
|
2979
3027
|
function buildCaption(caption, key, remult, metaData) {
|
|
2980
|
-
var result;
|
|
3028
|
+
var result = undefined;
|
|
2981
3029
|
if (typeof caption === 'function') {
|
|
2982
3030
|
if (remult)
|
|
2983
3031
|
result = caption(remult);
|
|
2984
3032
|
}
|
|
2985
3033
|
else if (caption)
|
|
2986
3034
|
result = caption;
|
|
2987
|
-
result = exports.CaptionTransformer.transformCaption(remult, key, result, metaData);
|
|
3035
|
+
result = exports.CaptionTransformer.transformCaption(remult, key, result !== null && result !== void 0 ? result : '', metaData);
|
|
2988
3036
|
if (result)
|
|
2989
3037
|
return result;
|
|
2990
3038
|
if (key)
|
|
2991
3039
|
return (0, column_js_1.makeTitle)(key);
|
|
2992
3040
|
return '';
|
|
2993
3041
|
}
|
|
2994
|
-
exports.buildCaption = buildCaption;
|
|
2995
3042
|
var columnDefsImpl = /** @class */ (function () {
|
|
2996
3043
|
function columnDefsImpl(settings, entityDefs, remult) {
|
|
2997
3044
|
var _this = this;
|
|
3045
|
+
var _a;
|
|
2998
3046
|
this.settings = settings;
|
|
2999
3047
|
this.entityDefs = entityDefs;
|
|
3000
3048
|
this.remult = remult;
|
|
3049
|
+
this.readonly = false;
|
|
3050
|
+
this.isServerExpression = false;
|
|
3001
3051
|
this.options = this.settings;
|
|
3002
3052
|
this.target = this.settings.target;
|
|
3003
|
-
this.valueConverter = new Proxy(this.settings.valueConverter, {
|
|
3053
|
+
this.valueConverter = new Proxy((_a = this.settings.valueConverter) !== null && _a !== void 0 ? _a : {}, {
|
|
3004
3054
|
get: function (target, prop) {
|
|
3005
3055
|
var result = target[prop];
|
|
3006
3056
|
if (typeof result === 'function') {
|
|
@@ -3072,7 +3122,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
3072
3122
|
};
|
|
3073
3123
|
Object.defineProperty(columnDefsImpl.prototype, "dbReadOnly", {
|
|
3074
3124
|
get: function () {
|
|
3075
|
-
return this.settings.dbReadOnly;
|
|
3125
|
+
return Boolean(this.settings.dbReadOnly);
|
|
3076
3126
|
},
|
|
3077
3127
|
enumerable: false,
|
|
3078
3128
|
configurable: true
|
|
@@ -3108,12 +3158,17 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3108
3158
|
: [this.field];
|
|
3109
3159
|
},
|
|
3110
3160
|
createIdInFilter: function (items) {
|
|
3161
|
+
var _a;
|
|
3111
3162
|
if (items.length > 0)
|
|
3112
3163
|
return {
|
|
3113
3164
|
$or: items.map(function (x) {
|
|
3114
3165
|
return _this.idMetadata.getIdFilter((0, getEntityRef_js_1.getEntityRef)(x).getId());
|
|
3115
3166
|
}),
|
|
3116
3167
|
};
|
|
3168
|
+
else
|
|
3169
|
+
return _a = {},
|
|
3170
|
+
_a[_this.fields.toArray()[0].key] = [],
|
|
3171
|
+
_a;
|
|
3117
3172
|
},
|
|
3118
3173
|
isIdField: function (col) {
|
|
3119
3174
|
return col.key == _this.idMetadata.field.key;
|
|
@@ -3204,8 +3259,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3204
3259
|
this.idMetadata.field = r_2;
|
|
3205
3260
|
}
|
|
3206
3261
|
if (!this.idMetadata.field) {
|
|
3207
|
-
|
|
3208
|
-
|
|
3262
|
+
var idField = this.fields['id'];
|
|
3263
|
+
if (idField)
|
|
3264
|
+
this.idMetadata.field = idField;
|
|
3209
3265
|
else
|
|
3210
3266
|
this.idMetadata.field = tslib_1.__spreadArray([], tslib_1.__read(this.fields), false)[0];
|
|
3211
3267
|
}
|
|
@@ -3256,7 +3312,7 @@ function FieldType() {
|
|
|
3256
3312
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3257
3313
|
options[_i] = arguments[_i];
|
|
3258
3314
|
}
|
|
3259
|
-
return function (target
|
|
3315
|
+
return function (target) {
|
|
3260
3316
|
if (!options) {
|
|
3261
3317
|
options = [];
|
|
3262
3318
|
}
|
|
@@ -3265,18 +3321,16 @@ function FieldType() {
|
|
|
3265
3321
|
return target;
|
|
3266
3322
|
};
|
|
3267
3323
|
}
|
|
3268
|
-
exports.FieldType = FieldType;
|
|
3269
3324
|
function isAutoIncrement(f) {
|
|
3270
3325
|
var _a, _b;
|
|
3271
3326
|
return ((_b = (_a = f.options) === null || _a === void 0 ? void 0 : _a.valueConverter) === null || _b === void 0 ? void 0 : _b.fieldTypeInDb) === 'autoincrement';
|
|
3272
3327
|
}
|
|
3273
|
-
exports.isAutoIncrement = isAutoIncrement;
|
|
3274
3328
|
function ValueListFieldType() {
|
|
3275
3329
|
var options = [];
|
|
3276
3330
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3277
3331
|
options[_i] = arguments[_i];
|
|
3278
3332
|
}
|
|
3279
|
-
return function (type
|
|
3333
|
+
return function (type) {
|
|
3280
3334
|
FieldType.apply(void 0, tslib_1.__spreadArray([function (o) {
|
|
3281
3335
|
;
|
|
3282
3336
|
(o.valueConverter = ValueListInfo.get(type)),
|
|
@@ -3288,10 +3342,9 @@ function ValueListFieldType() {
|
|
|
3288
3342
|
}
|
|
3289
3343
|
return validators_js_1.Validators.in(values)(entity, ref);
|
|
3290
3344
|
};
|
|
3291
|
-
}], tslib_1.__read(options), false))(type
|
|
3345
|
+
}], tslib_1.__read(options), false))(type);
|
|
3292
3346
|
};
|
|
3293
3347
|
}
|
|
3294
|
-
exports.ValueListFieldType = ValueListFieldType;
|
|
3295
3348
|
var ValueListInfo = /** @class */ (function () {
|
|
3296
3349
|
function ValueListInfo(valueListType) {
|
|
3297
3350
|
var e_46, _a, _b;
|
|
@@ -3401,12 +3454,11 @@ function getValueList(type) {
|
|
|
3401
3454
|
if (options)
|
|
3402
3455
|
return ValueListInfo.get(type).getValues();
|
|
3403
3456
|
}
|
|
3404
|
-
var optionalValues = meta === null || meta === void 0 ? void 0 : meta.options[exports.fieldOptionalValuesFunctionKey];
|
|
3457
|
+
var optionalValues = (meta === null || meta === void 0 ? void 0 : meta.options)[exports.fieldOptionalValuesFunctionKey];
|
|
3405
3458
|
if (optionalValues)
|
|
3406
3459
|
return optionalValues();
|
|
3407
3460
|
return undefined;
|
|
3408
3461
|
}
|
|
3409
|
-
exports.getValueList = getValueList;
|
|
3410
3462
|
exports.storableMember = Symbol.for('storableMember');
|
|
3411
3463
|
exports.fieldOptionalValuesFunctionKey = Symbol.for('fieldOptionalValues');
|
|
3412
3464
|
function buildOptions(options, remult) {
|
|
@@ -3435,7 +3487,6 @@ function buildOptions(options, remult) {
|
|
|
3435
3487
|
}
|
|
3436
3488
|
return r;
|
|
3437
3489
|
}
|
|
3438
|
-
exports.buildOptions = buildOptions;
|
|
3439
3490
|
function decorateColumnSettings(settings, remult) {
|
|
3440
3491
|
if (settings.valueType) {
|
|
3441
3492
|
var settingsOnTypeLevel = settings.valueType[exports.storableMember];
|
|
@@ -3524,23 +3575,22 @@ function decorateColumnSettings(settings, remult) {
|
|
|
3524
3575
|
if (!settings.valueConverter.fromJson) {
|
|
3525
3576
|
settings.valueConverter.fromJson = function (x) { return x; };
|
|
3526
3577
|
}
|
|
3578
|
+
var fromJson = settings.valueConverter.fromJson;
|
|
3579
|
+
var toJson = settings.valueConverter.toJson;
|
|
3527
3580
|
if (!settings.valueConverter.toDb) {
|
|
3528
|
-
settings.valueConverter.toDb = function (x) { return
|
|
3581
|
+
settings.valueConverter.toDb = function (x) { return toJson(x); };
|
|
3529
3582
|
}
|
|
3530
3583
|
if (!settings.valueConverter.fromDb) {
|
|
3531
|
-
settings.valueConverter.fromDb = function (x) { return
|
|
3584
|
+
settings.valueConverter.fromDb = function (x) { return fromJson(x); };
|
|
3532
3585
|
}
|
|
3533
3586
|
if (!settings.valueConverter.toInput) {
|
|
3534
|
-
settings.valueConverter.toInput = function (x) { return
|
|
3587
|
+
settings.valueConverter.toInput = function (x) { return toJson(x); };
|
|
3535
3588
|
}
|
|
3536
3589
|
if (!settings.valueConverter.fromInput) {
|
|
3537
|
-
settings.valueConverter.fromInput = function (x) {
|
|
3538
|
-
return settings.valueConverter.fromJson(x);
|
|
3539
|
-
};
|
|
3590
|
+
settings.valueConverter.fromInput = function (x) { return fromJson(x); };
|
|
3540
3591
|
}
|
|
3541
3592
|
return settings;
|
|
3542
3593
|
}
|
|
3543
|
-
exports.decorateColumnSettings = decorateColumnSettings;
|
|
3544
3594
|
var EntityBase = /** @class */ (function () {
|
|
3545
3595
|
function EntityBase() {
|
|
3546
3596
|
}
|
|
@@ -3613,7 +3663,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3613
3663
|
QueryResultImpl.prototype.getPage = function (page) {
|
|
3614
3664
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3615
3665
|
return tslib_1.__generator(this, function (_a) {
|
|
3616
|
-
if (page < 1)
|
|
3666
|
+
if ((page !== null && page !== void 0 ? page : 0) < 1)
|
|
3617
3667
|
page = 1;
|
|
3618
3668
|
return [2 /*return*/, this.repo.find({
|
|
3619
3669
|
where: this.options.where,
|
|
@@ -3644,9 +3694,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3644
3694
|
});
|
|
3645
3695
|
};
|
|
3646
3696
|
QueryResultImpl.prototype.forEach = function (what) {
|
|
3647
|
-
var _a, e_49, _b, _c;
|
|
3648
3697
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3649
|
-
var i,
|
|
3698
|
+
var i, _a, _b, _c, x, e_49_1;
|
|
3699
|
+
var _d, e_49, _e, _f;
|
|
3650
3700
|
return tslib_1.__generator(this, function (_g) {
|
|
3651
3701
|
switch (_g.label) {
|
|
3652
3702
|
case 0:
|
|
@@ -3654,21 +3704,21 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3654
3704
|
_g.label = 1;
|
|
3655
3705
|
case 1:
|
|
3656
3706
|
_g.trys.push([1, 7, 8, 13]);
|
|
3657
|
-
|
|
3707
|
+
_a = true, _b = tslib_1.__asyncValues(this);
|
|
3658
3708
|
_g.label = 2;
|
|
3659
|
-
case 2: return [4 /*yield*/,
|
|
3709
|
+
case 2: return [4 /*yield*/, _b.next()];
|
|
3660
3710
|
case 3:
|
|
3661
|
-
if (!(
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
x =
|
|
3711
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 6];
|
|
3712
|
+
_f = _c.value;
|
|
3713
|
+
_a = false;
|
|
3714
|
+
x = _f;
|
|
3665
3715
|
return [4 /*yield*/, what(x)];
|
|
3666
3716
|
case 4:
|
|
3667
3717
|
_g.sent();
|
|
3668
3718
|
i++;
|
|
3669
3719
|
_g.label = 5;
|
|
3670
3720
|
case 5:
|
|
3671
|
-
|
|
3721
|
+
_a = true;
|
|
3672
3722
|
return [3 /*break*/, 2];
|
|
3673
3723
|
case 6: return [3 /*break*/, 13];
|
|
3674
3724
|
case 7:
|
|
@@ -3677,8 +3727,8 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3677
3727
|
return [3 /*break*/, 13];
|
|
3678
3728
|
case 8:
|
|
3679
3729
|
_g.trys.push([8, , 11, 12]);
|
|
3680
|
-
if (!(!
|
|
3681
|
-
return [4 /*yield*/,
|
|
3730
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 10];
|
|
3731
|
+
return [4 /*yield*/, _e.call(_b)];
|
|
3682
3732
|
case 9:
|
|
3683
3733
|
_g.sent();
|
|
3684
3734
|
_g.label = 10;
|
|
@@ -3711,7 +3761,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3711
3761
|
})];
|
|
3712
3762
|
case 1:
|
|
3713
3763
|
items = _a.sent();
|
|
3714
|
-
nextPage =
|
|
3764
|
+
nextPage = function () {
|
|
3765
|
+
throw new Error('no more pages');
|
|
3766
|
+
};
|
|
3715
3767
|
hasNextPage = items.length == this.options.pageSize;
|
|
3716
3768
|
if (!hasNextPage) return [3 /*break*/, 3];
|
|
3717
3769
|
return [4 /*yield*/, this.repo._createAfterFilter(this.options.orderBy, items[items.length - 1])];
|
|
@@ -3742,16 +3794,17 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3742
3794
|
var j = 0;
|
|
3743
3795
|
itStrategy = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
3744
3796
|
var _a, _b, _c, prev;
|
|
3745
|
-
|
|
3746
|
-
|
|
3797
|
+
var _d;
|
|
3798
|
+
return tslib_1.__generator(this, function (_e) {
|
|
3799
|
+
switch (_e.label) {
|
|
3747
3800
|
case 0:
|
|
3748
3801
|
if (!this.options.progress) return [3 /*break*/, 2];
|
|
3749
3802
|
_b = (_a = this.options.progress).progress;
|
|
3750
3803
|
_c = j++;
|
|
3751
3804
|
return [4 /*yield*/, this.count()];
|
|
3752
3805
|
case 1:
|
|
3753
|
-
_b.apply(_a, [_c / (
|
|
3754
|
-
|
|
3806
|
+
_b.apply(_a, [_c / (_e.sent())]);
|
|
3807
|
+
_e.label = 2;
|
|
3755
3808
|
case 2:
|
|
3756
3809
|
if (!(currentPage === undefined || itemIndex == currentPage.items.length)) return [3 /*break*/, 7];
|
|
3757
3810
|
if (currentPage && !currentPage.hasNextPage)
|
|
@@ -3760,29 +3813,29 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3760
3813
|
if (!currentPage) return [3 /*break*/, 4];
|
|
3761
3814
|
return [4 /*yield*/, currentPage.nextPage()];
|
|
3762
3815
|
case 3:
|
|
3763
|
-
currentPage =
|
|
3816
|
+
currentPage = _e.sent();
|
|
3764
3817
|
return [3 /*break*/, 6];
|
|
3765
3818
|
case 4: return [4 /*yield*/, this.paginator()];
|
|
3766
3819
|
case 5:
|
|
3767
|
-
currentPage =
|
|
3768
|
-
|
|
3820
|
+
currentPage = _e.sent();
|
|
3821
|
+
_e.label = 6;
|
|
3769
3822
|
case 6:
|
|
3770
3823
|
itemIndex = 0;
|
|
3771
3824
|
if (currentPage.items.length == 0) {
|
|
3772
3825
|
return [2 /*return*/, { value: undefined, done: true }];
|
|
3773
3826
|
}
|
|
3774
3827
|
else {
|
|
3775
|
-
if ((prev === null || prev === void 0 ? void 0 : prev.items.length) > 0) {
|
|
3828
|
+
if ((_d = prev === null || prev === void 0 ? void 0 : prev.items.length) !== null && _d !== void 0 ? _d : 0 > 0) {
|
|
3776
3829
|
if (this.repo.getEntityRef(prev.items[0]).getId() ==
|
|
3777
3830
|
this.repo.getEntityRef(currentPage.items[0]).getId())
|
|
3778
3831
|
throw new Error('pagination failure, returned same first row');
|
|
3779
3832
|
}
|
|
3780
3833
|
}
|
|
3781
|
-
|
|
3834
|
+
_e.label = 7;
|
|
3782
3835
|
case 7:
|
|
3783
3836
|
if (itemIndex < currentPage.items.length)
|
|
3784
3837
|
return [2 /*return*/, { value: currentPage.items[itemIndex++], done: false }];
|
|
3785
|
-
return [2 /*return
|
|
3838
|
+
return [2 /*return*/, { done: true, value: undefined }];
|
|
3786
3839
|
}
|
|
3787
3840
|
});
|
|
3788
3841
|
}); };
|
|
@@ -3844,7 +3897,6 @@ function getEntityMetadata(entity) {
|
|
|
3844
3897
|
}
|
|
3845
3898
|
return entity;
|
|
3846
3899
|
}
|
|
3847
|
-
exports.getEntityMetadata = getEntityMetadata;
|
|
3848
3900
|
function getRepository(entity) {
|
|
3849
3901
|
var settings = (0, getEntityRef_js_1.getEntitySettings)(entity, false);
|
|
3850
3902
|
if (settings) {
|
|
@@ -3852,7 +3904,6 @@ function getRepository(entity) {
|
|
|
3852
3904
|
}
|
|
3853
3905
|
return entity;
|
|
3854
3906
|
}
|
|
3855
|
-
exports.getRepository = getRepository;
|
|
3856
3907
|
function promiseAll(array, mapToPromise) {
|
|
3857
3908
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3858
3909
|
var result, index, element, _a, _b;
|