remult 0.26.23 → 0.27.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/filter/filter-interfaces.js +1 -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 +15 -7
- package/esm/src/remult3/RepositoryImplementation.js +165 -125
- package/esm/src/remult3/entity.js +1 -1
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/remult3.js +15 -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.d.ts +1 -1
- 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 +2 -2
- package/remult-knex/index.js +7 -5
- package/remult-mongo.d.ts +1 -1
- package/remult-next.d.ts +5 -6
- 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.d.ts +1 -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.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 +21 -21
- package/server/remult-api-server.js +54 -48
- package/src/CompoundIdField.d.ts +2 -2
- 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 +4 -4
- 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 +4 -4
- package/src/data-api.js +4 -4
- package/src/data-interfaces.d.ts +1 -1
- 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.d.ts +1 -1
- package/src/data-providers/sql-database.js +11 -11
- package/src/data-providers/web-sql-data-provider.d.ts +2 -2
- package/src/entity.d.ts +1 -1
- 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 +2 -1
- package/src/filter/filter-interfaces.js +10 -7
- 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 +17 -17
- package/src/remult3/Fields.js +22 -13
- package/src/remult3/RepositoryImplementation.d.ts +51 -46
- package/src/remult3/RepositoryImplementation.js +421 -368
- 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 +4 -4
- package/src/remult3/classDescribers.js +3 -4
- package/src/remult3/columnInfo.d.ts +1 -1
- 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 +3 -3
- package/src/remult3/relationInfoMember.js +4 -5
- package/src/remult3/remult3.d.ts +23 -20
- package/src/remult3/remult3.js +15 -0
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/remult3/repository-internals.js +2 -2
- package/src/server-action.d.ts +2 -2
- 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:
|
|
@@ -1898,26 +1925,28 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1898
1925
|
}());
|
|
1899
1926
|
var rowHelperImplementation = /** @class */ (function (_super) {
|
|
1900
1927
|
tslib_1.__extends(rowHelperImplementation, _super);
|
|
1901
|
-
function rowHelperImplementation(info, instance,
|
|
1928
|
+
function rowHelperImplementation(info, instance, repo, edp, remult, _isNew) {
|
|
1902
1929
|
var e_30, _a;
|
|
1903
1930
|
var _this = _super.call(this, info.fieldsMetadata, instance, remult, _isNew) || this;
|
|
1904
1931
|
_this.info = info;
|
|
1905
|
-
_this.
|
|
1932
|
+
_this.repo = repo;
|
|
1906
1933
|
_this.edp = edp;
|
|
1907
1934
|
_this._isNew = _isNew;
|
|
1908
1935
|
_this._wasDeleted = false;
|
|
1909
1936
|
_this._saving = false;
|
|
1937
|
+
_this.repository = repo;
|
|
1910
1938
|
_this.metadata = info;
|
|
1911
1939
|
if (_isNew) {
|
|
1912
1940
|
try {
|
|
1913
1941
|
for (var _b = tslib_1.__values(info.fieldsMetadata), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1914
1942
|
var col = _c.value;
|
|
1915
|
-
|
|
1943
|
+
var colKey = col.key;
|
|
1944
|
+
if (col.options.defaultValue && instance[colKey] === undefined) {
|
|
1916
1945
|
if (typeof col.options.defaultValue === 'function') {
|
|
1917
|
-
instance[
|
|
1946
|
+
instance[colKey] = col.options.defaultValue(instance);
|
|
1918
1947
|
}
|
|
1919
|
-
else if (!instance[
|
|
1920
|
-
instance[
|
|
1948
|
+
else if (!instance[colKey])
|
|
1949
|
+
instance[colKey] = col.options.defaultValue;
|
|
1921
1950
|
}
|
|
1922
1951
|
}
|
|
1923
1952
|
}
|
|
@@ -1929,19 +1958,19 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1929
1958
|
finally { if (e_30) throw e_30.error; }
|
|
1930
1959
|
}
|
|
1931
1960
|
}
|
|
1932
|
-
if (_this.info.
|
|
1933
|
-
_this.info.
|
|
1961
|
+
if (_this.info.entityInfo.entityRefInit)
|
|
1962
|
+
_this.info.entityInfo.entityRefInit(_this, instance);
|
|
1934
1963
|
if (context_js_1.Remult.entityRefInit)
|
|
1935
1964
|
context_js_1.Remult.entityRefInit(_this, instance);
|
|
1936
1965
|
return _this;
|
|
1937
1966
|
}
|
|
1938
1967
|
rowHelperImplementation.prototype.clone = function () {
|
|
1939
1968
|
var data = this.toApiJson(true, true);
|
|
1940
|
-
return this.
|
|
1969
|
+
return this.repo.fromJson(data, this.isNew());
|
|
1941
1970
|
};
|
|
1942
1971
|
Object.defineProperty(rowHelperImplementation.prototype, "relations", {
|
|
1943
1972
|
get: function () {
|
|
1944
|
-
return this.
|
|
1973
|
+
return this.repo.relations(this.instance);
|
|
1945
1974
|
},
|
|
1946
1975
|
enumerable: false,
|
|
1947
1976
|
configurable: true
|
|
@@ -2009,7 +2038,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2009
2038
|
switch (_a.label) {
|
|
2010
2039
|
case 0:
|
|
2011
2040
|
if (newData.length === 0)
|
|
2012
|
-
throw this.
|
|
2041
|
+
throw this.repo._notFoundError(this.id);
|
|
2013
2042
|
return [4 /*yield*/, this.loadDataFrom(newData[0])];
|
|
2014
2043
|
case 1:
|
|
2015
2044
|
_a.sent();
|
|
@@ -2032,7 +2061,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2032
2061
|
if (!this._columns) {
|
|
2033
2062
|
var _items_1 = [];
|
|
2034
2063
|
var r_1 = (_a = {
|
|
2064
|
+
//@ts-ignore
|
|
2035
2065
|
find: function (c) {
|
|
2066
|
+
//@ts-ignore
|
|
2036
2067
|
return r_1[typeof c === 'string' ? c : c.key];
|
|
2037
2068
|
}
|
|
2038
2069
|
},
|
|
@@ -2042,7 +2073,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2042
2073
|
try {
|
|
2043
2074
|
for (var _c = tslib_1.__values(this.info.fieldsMetadata), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2044
2075
|
var c = _d.value;
|
|
2045
|
-
_items_1.push(
|
|
2076
|
+
_items_1.push(
|
|
2077
|
+
//@ts-ignore
|
|
2078
|
+
(r_1[c.key] = new FieldRefImplementation(c.options, c, this.instance, this, this)));
|
|
2046
2079
|
}
|
|
2047
2080
|
}
|
|
2048
2081
|
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
@@ -2060,14 +2093,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2060
2093
|
configurable: true
|
|
2061
2094
|
});
|
|
2062
2095
|
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2063
|
-
var _a;
|
|
2064
2096
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2065
|
-
var doNotSave_1, e,
|
|
2066
|
-
var e_32,
|
|
2067
|
-
|
|
2068
|
-
|
|
2097
|
+
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;
|
|
2098
|
+
var e_32, _l, e_34, _m, _o, _p, e_33, _q;
|
|
2099
|
+
var _r, _s;
|
|
2100
|
+
return tslib_1.__generator(this, function (_t) {
|
|
2101
|
+
switch (_t.label) {
|
|
2069
2102
|
case 0:
|
|
2070
|
-
|
|
2103
|
+
_t.trys.push([0, , 41, 42]);
|
|
2071
2104
|
if (this._saving)
|
|
2072
2105
|
throw new Error('cannot save while entity is already saving');
|
|
2073
2106
|
this._saving = true;
|
|
@@ -2080,36 +2113,36 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2080
2113
|
return [4 /*yield*/, this.__validateEntity()];
|
|
2081
2114
|
case 1:
|
|
2082
2115
|
// no need
|
|
2083
|
-
|
|
2084
|
-
|
|
2116
|
+
_t.sent();
|
|
2117
|
+
_t.label = 2;
|
|
2085
2118
|
case 2:
|
|
2086
2119
|
doNotSave_1 = false;
|
|
2087
2120
|
e = this.buildLifeCycleEvent(function () { return (doNotSave_1 = true); });
|
|
2088
|
-
if (!!this.
|
|
2089
|
-
|
|
2121
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 12];
|
|
2122
|
+
_t.label = 3;
|
|
2090
2123
|
case 3:
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2124
|
+
_t.trys.push([3, 8, 9, 10]);
|
|
2125
|
+
_a = tslib_1.__values(this.fields), _b = _a.next();
|
|
2126
|
+
_t.label = 4;
|
|
2094
2127
|
case 4:
|
|
2095
|
-
if (!!
|
|
2096
|
-
col =
|
|
2128
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
2129
|
+
col = _b.value;
|
|
2097
2130
|
if (!col.metadata.options.saving) return [3 /*break*/, 6];
|
|
2098
2131
|
return [4 /*yield*/, col.metadata.options.saving(this.instance, col, e)];
|
|
2099
2132
|
case 5:
|
|
2100
|
-
|
|
2101
|
-
|
|
2133
|
+
_t.sent();
|
|
2134
|
+
_t.label = 6;
|
|
2102
2135
|
case 6:
|
|
2103
|
-
|
|
2136
|
+
_b = _a.next();
|
|
2104
2137
|
return [3 /*break*/, 4];
|
|
2105
2138
|
case 7: return [3 /*break*/, 10];
|
|
2106
2139
|
case 8:
|
|
2107
|
-
e_32_1 =
|
|
2140
|
+
e_32_1 = _t.sent();
|
|
2108
2141
|
e_32 = { error: e_32_1 };
|
|
2109
2142
|
return [3 /*break*/, 10];
|
|
2110
2143
|
case 9:
|
|
2111
2144
|
try {
|
|
2112
|
-
if (
|
|
2145
|
+
if (_b && !_b.done && (_l = _a.return)) _l.call(_a);
|
|
2113
2146
|
}
|
|
2114
2147
|
finally { if (e_32) throw e_32.error; }
|
|
2115
2148
|
return [7 /*endfinally*/];
|
|
@@ -2117,15 +2150,15 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2117
2150
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 12];
|
|
2118
2151
|
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, e)];
|
|
2119
2152
|
case 11:
|
|
2120
|
-
|
|
2121
|
-
|
|
2153
|
+
_t.sent();
|
|
2154
|
+
_t.label = 12;
|
|
2122
2155
|
case 12:
|
|
2123
2156
|
this.__assertValidity();
|
|
2124
2157
|
d = this.copyDataToObject(this.isNew());
|
|
2125
2158
|
ignoreKeys = [];
|
|
2126
2159
|
try {
|
|
2127
|
-
for (
|
|
2128
|
-
field =
|
|
2160
|
+
for (_c = tslib_1.__values(this.metadata.fields), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2161
|
+
field = _d.value;
|
|
2129
2162
|
if (field.dbReadOnly ||
|
|
2130
2163
|
(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !==
|
|
2131
2164
|
undefined &&
|
|
@@ -2140,30 +2173,30 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2140
2173
|
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
2141
2174
|
finally {
|
|
2142
2175
|
try {
|
|
2143
|
-
if (
|
|
2176
|
+
if (_d && !_d.done && (_m = _c.return)) _m.call(_c);
|
|
2144
2177
|
}
|
|
2145
2178
|
finally { if (e_34) throw e_34.error; }
|
|
2146
2179
|
}
|
|
2147
2180
|
updatedRow = void 0;
|
|
2148
2181
|
isNew = this.isNew();
|
|
2149
|
-
|
|
2182
|
+
_t.label = 13;
|
|
2150
2183
|
case 13:
|
|
2151
|
-
|
|
2152
|
-
(
|
|
2184
|
+
_t.trys.push([13, 38, , 40]);
|
|
2185
|
+
(_r = this._subscribers) === null || _r === void 0 ? void 0 : _r.reportChanged();
|
|
2153
2186
|
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2154
2187
|
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
2155
|
-
|
|
2156
|
-
|
|
2188
|
+
_f = (_e = this.edp).find;
|
|
2189
|
+
_o = {};
|
|
2157
2190
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2158
|
-
case 14: return [4 /*yield*/,
|
|
2159
|
-
|
|
2191
|
+
case 14: return [4 /*yield*/, _f.apply(_e, [(_o.where = _t.sent(),
|
|
2192
|
+
_o)])];
|
|
2160
2193
|
case 15:
|
|
2161
|
-
updatedRow = (updatedRow =
|
|
2194
|
+
updatedRow = (updatedRow = _t.sent())[0];
|
|
2162
2195
|
return [3 /*break*/, 18];
|
|
2163
2196
|
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2164
2197
|
case 17:
|
|
2165
|
-
updatedRow =
|
|
2166
|
-
|
|
2198
|
+
updatedRow = _t.sent();
|
|
2199
|
+
_t.label = 18;
|
|
2167
2200
|
case 18: return [3 /*break*/, 24];
|
|
2168
2201
|
case 19:
|
|
2169
2202
|
changesOnly = {};
|
|
@@ -2181,71 +2214,69 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2181
2214
|
if (!wasChanged)
|
|
2182
2215
|
return [2 /*return*/, this.instance];
|
|
2183
2216
|
if (!doNotSave_1) return [3 /*break*/, 22];
|
|
2184
|
-
|
|
2185
|
-
|
|
2217
|
+
_h = (_g = this.edp).find;
|
|
2218
|
+
_p = {};
|
|
2186
2219
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2187
|
-
case 20: return [4 /*yield*/,
|
|
2220
|
+
case 20: return [4 /*yield*/, _h.apply(_g, [(_p.where = _t.sent(), _p)])];
|
|
2188
2221
|
case 21:
|
|
2189
|
-
updatedRow = (
|
|
2222
|
+
updatedRow = (_t.sent())[0];
|
|
2190
2223
|
return [3 /*break*/, 24];
|
|
2191
2224
|
case 22: return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2192
2225
|
case 23:
|
|
2193
|
-
updatedRow =
|
|
2194
|
-
|
|
2226
|
+
updatedRow = _t.sent();
|
|
2227
|
+
_t.label = 24;
|
|
2195
2228
|
case 24:
|
|
2196
2229
|
if (!updatedRow) return [3 /*break*/, 26];
|
|
2197
2230
|
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2198
2231
|
case 25:
|
|
2199
|
-
|
|
2200
|
-
|
|
2232
|
+
_t.sent();
|
|
2233
|
+
_t.label = 26;
|
|
2201
2234
|
case 26:
|
|
2202
2235
|
e.id = this.getId();
|
|
2203
|
-
if (!!this.
|
|
2236
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 36];
|
|
2204
2237
|
if (!this.info.entityInfo.saved) return [3 /*break*/, 28];
|
|
2205
2238
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2206
2239
|
case 27:
|
|
2207
|
-
|
|
2208
|
-
|
|
2240
|
+
_t.sent();
|
|
2241
|
+
_t.label = 28;
|
|
2209
2242
|
case 28:
|
|
2210
|
-
if (!this.
|
|
2211
|
-
|
|
2243
|
+
if (!this.repo.listeners) return [3 /*break*/, 36];
|
|
2244
|
+
_t.label = 29;
|
|
2212
2245
|
case 29:
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2246
|
+
_t.trys.push([29, 34, 35, 36]);
|
|
2247
|
+
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2248
|
+
_t.label = 30;
|
|
2216
2249
|
case 30:
|
|
2217
|
-
if (!!
|
|
2218
|
-
listener =
|
|
2219
|
-
return [4 /*yield*/, listener.saved(this.instance, isNew)];
|
|
2250
|
+
if (!!_k.done) return [3 /*break*/, 33];
|
|
2251
|
+
listener = _k.value;
|
|
2252
|
+
return [4 /*yield*/, ((_s = listener.saved) === null || _s === void 0 ? void 0 : _s.call(listener, this.instance, isNew))];
|
|
2220
2253
|
case 31:
|
|
2221
|
-
|
|
2222
|
-
|
|
2254
|
+
_t.sent();
|
|
2255
|
+
_t.label = 32;
|
|
2223
2256
|
case 32:
|
|
2224
|
-
|
|
2257
|
+
_k = _j.next();
|
|
2225
2258
|
return [3 /*break*/, 30];
|
|
2226
2259
|
case 33: return [3 /*break*/, 36];
|
|
2227
2260
|
case 34:
|
|
2228
|
-
e_33_1 =
|
|
2261
|
+
e_33_1 = _t.sent();
|
|
2229
2262
|
e_33 = { error: e_33_1 };
|
|
2230
2263
|
return [3 /*break*/, 36];
|
|
2231
2264
|
case 35:
|
|
2232
2265
|
try {
|
|
2233
|
-
if (
|
|
2266
|
+
if (_k && !_k.done && (_q = _j.return)) _q.call(_j);
|
|
2234
2267
|
}
|
|
2235
2268
|
finally { if (e_33) throw e_33.error; }
|
|
2236
2269
|
return [7 /*endfinally*/];
|
|
2237
|
-
case 36: return [4 /*yield*/, this.
|
|
2270
|
+
case 36: return [4 /*yield*/, this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }])];
|
|
2238
2271
|
case 37:
|
|
2239
|
-
|
|
2272
|
+
_t.sent();
|
|
2240
2273
|
this.saveOriginalData();
|
|
2241
2274
|
this._isNew = false;
|
|
2242
2275
|
return [2 /*return*/, this.instance];
|
|
2243
2276
|
case 38:
|
|
2244
|
-
err_1 =
|
|
2277
|
+
err_1 = _t.sent();
|
|
2245
2278
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2246
|
-
case 39:
|
|
2247
|
-
_s.sent();
|
|
2248
|
-
return [3 /*break*/, 40];
|
|
2279
|
+
case 39: throw _t.sent();
|
|
2249
2280
|
case 40: return [3 /*break*/, 42];
|
|
2250
2281
|
case 41:
|
|
2251
2282
|
this.isLoading = false;
|
|
@@ -2314,17 +2345,17 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2314
2345
|
fields: self.fields,
|
|
2315
2346
|
id: self.getId(),
|
|
2316
2347
|
originalId: self.getOriginalId(),
|
|
2317
|
-
metadata: self.
|
|
2318
|
-
repository: self.
|
|
2348
|
+
metadata: self.repo.metadata,
|
|
2349
|
+
repository: self.repo,
|
|
2319
2350
|
preventDefault: function () { return preventDefault(); },
|
|
2320
|
-
relations: self.
|
|
2351
|
+
relations: self.repo.relations(self.instance),
|
|
2321
2352
|
};
|
|
2322
2353
|
};
|
|
2323
2354
|
rowHelperImplementation.prototype.getIdFilter = function () {
|
|
2324
2355
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2325
2356
|
return tslib_1.__generator(this, function (_a) {
|
|
2326
2357
|
switch (_a.label) {
|
|
2327
|
-
case 0: return [4 /*yield*/, this.
|
|
2358
|
+
case 0: return [4 /*yield*/, this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id))];
|
|
2328
2359
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2329
2360
|
}
|
|
2330
2361
|
});
|
|
@@ -2334,55 +2365,56 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2334
2365
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2335
2366
|
var doDelete, e, _a, _b, listener, e_36_1, err_2;
|
|
2336
2367
|
var e_36, _c;
|
|
2337
|
-
|
|
2338
|
-
|
|
2368
|
+
var _d;
|
|
2369
|
+
return tslib_1.__generator(this, function (_e) {
|
|
2370
|
+
switch (_e.label) {
|
|
2339
2371
|
case 0:
|
|
2340
2372
|
this.__clearErrorsAndReportChanged();
|
|
2341
2373
|
doDelete = true;
|
|
2342
2374
|
e = this.buildLifeCycleEvent(function () { return (doDelete = false); });
|
|
2343
|
-
if (!!this.
|
|
2375
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 2];
|
|
2344
2376
|
if (!this.info.entityInfo.deleting) return [3 /*break*/, 2];
|
|
2345
2377
|
return [4 /*yield*/, this.info.entityInfo.deleting(this.instance, e)];
|
|
2346
2378
|
case 1:
|
|
2347
|
-
|
|
2348
|
-
|
|
2379
|
+
_e.sent();
|
|
2380
|
+
_e.label = 2;
|
|
2349
2381
|
case 2:
|
|
2350
2382
|
this.__assertValidity();
|
|
2351
|
-
|
|
2383
|
+
_e.label = 3;
|
|
2352
2384
|
case 3:
|
|
2353
|
-
|
|
2385
|
+
_e.trys.push([3, 17, , 19]);
|
|
2354
2386
|
if (!doDelete) return [3 /*break*/, 5];
|
|
2355
2387
|
return [4 /*yield*/, this.edp.delete(this.id)];
|
|
2356
2388
|
case 4:
|
|
2357
|
-
|
|
2358
|
-
|
|
2389
|
+
_e.sent();
|
|
2390
|
+
_e.label = 5;
|
|
2359
2391
|
case 5:
|
|
2360
|
-
if (!!this.
|
|
2392
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 7];
|
|
2361
2393
|
if (!this.info.entityInfo.deleted) return [3 /*break*/, 7];
|
|
2362
2394
|
return [4 /*yield*/, this.info.entityInfo.deleted(this.instance, e)];
|
|
2363
2395
|
case 6:
|
|
2364
|
-
|
|
2365
|
-
|
|
2396
|
+
_e.sent();
|
|
2397
|
+
_e.label = 7;
|
|
2366
2398
|
case 7:
|
|
2367
|
-
if (!this.
|
|
2368
|
-
|
|
2399
|
+
if (!this.repo.listeners) return [3 /*break*/, 15];
|
|
2400
|
+
_e.label = 8;
|
|
2369
2401
|
case 8:
|
|
2370
|
-
|
|
2371
|
-
_a = tslib_1.__values(this.
|
|
2372
|
-
|
|
2402
|
+
_e.trys.push([8, 13, 14, 15]);
|
|
2403
|
+
_a = tslib_1.__values(this.repo.listeners), _b = _a.next();
|
|
2404
|
+
_e.label = 9;
|
|
2373
2405
|
case 9:
|
|
2374
2406
|
if (!!_b.done) return [3 /*break*/, 12];
|
|
2375
2407
|
listener = _b.value;
|
|
2376
|
-
return [4 /*yield*/, listener.deleted(this.instance)];
|
|
2408
|
+
return [4 /*yield*/, ((_d = listener.deleted) === null || _d === void 0 ? void 0 : _d.call(listener, this.instance))];
|
|
2377
2409
|
case 10:
|
|
2378
|
-
|
|
2379
|
-
|
|
2410
|
+
_e.sent();
|
|
2411
|
+
_e.label = 11;
|
|
2380
2412
|
case 11:
|
|
2381
2413
|
_b = _a.next();
|
|
2382
2414
|
return [3 /*break*/, 9];
|
|
2383
2415
|
case 12: return [3 /*break*/, 15];
|
|
2384
2416
|
case 13:
|
|
2385
|
-
e_36_1 =
|
|
2417
|
+
e_36_1 = _e.sent();
|
|
2386
2418
|
e_36 = { error: e_36_1 };
|
|
2387
2419
|
return [3 /*break*/, 15];
|
|
2388
2420
|
case 14:
|
|
@@ -2391,17 +2423,15 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2391
2423
|
}
|
|
2392
2424
|
finally { if (e_36) throw e_36.error; }
|
|
2393
2425
|
return [7 /*endfinally*/];
|
|
2394
|
-
case 15: return [4 /*yield*/, this.
|
|
2426
|
+
case 15: return [4 /*yield*/, this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }])];
|
|
2395
2427
|
case 16:
|
|
2396
|
-
|
|
2428
|
+
_e.sent();
|
|
2397
2429
|
this._wasDeleted = true;
|
|
2398
2430
|
return [3 /*break*/, 19];
|
|
2399
2431
|
case 17:
|
|
2400
|
-
err_2 =
|
|
2432
|
+
err_2 = _e.sent();
|
|
2401
2433
|
return [4 /*yield*/, this.catchSaveErrors(err_2)];
|
|
2402
|
-
case 18:
|
|
2403
|
-
_d.sent();
|
|
2404
|
-
return [3 /*break*/, 19];
|
|
2434
|
+
case 18: throw _e.sent();
|
|
2405
2435
|
case 19: return [2 /*return*/];
|
|
2406
2436
|
}
|
|
2407
2437
|
});
|
|
@@ -2488,7 +2518,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2488
2518
|
_d = col.key;
|
|
2489
2519
|
return [4 /*yield*/, col.options.serverExpression(this.instance)];
|
|
2490
2520
|
case 3:
|
|
2491
|
-
_c[_d] =
|
|
2521
|
+
_c[_d] =
|
|
2522
|
+
(_f.sent());
|
|
2492
2523
|
_f.label = 4;
|
|
2493
2524
|
case 4:
|
|
2494
2525
|
_b = _a.next();
|
|
@@ -2540,12 +2571,13 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2540
2571
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2541
2572
|
var _a, _b, c, col, e_40_1, e, _c, _d, listener, e_41_1;
|
|
2542
2573
|
var e_40, _e, e_41, _f;
|
|
2543
|
-
|
|
2544
|
-
|
|
2574
|
+
var _g;
|
|
2575
|
+
return tslib_1.__generator(this, function (_h) {
|
|
2576
|
+
switch (_h.label) {
|
|
2545
2577
|
case 0:
|
|
2546
|
-
|
|
2578
|
+
_h.trys.push([0, 5, 6, 7]);
|
|
2547
2579
|
_a = tslib_1.__values(this.fieldsMetadata), _b = _a.next();
|
|
2548
|
-
|
|
2580
|
+
_h.label = 1;
|
|
2549
2581
|
case 1:
|
|
2550
2582
|
if (!!_b.done) return [3 /*break*/, 4];
|
|
2551
2583
|
c = _b.value;
|
|
@@ -2553,14 +2585,14 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2553
2585
|
col = new FieldRefImplementation(c.options, c, this.instance, this, this);
|
|
2554
2586
|
return [4 /*yield*/, col.__performValidation()];
|
|
2555
2587
|
case 2:
|
|
2556
|
-
|
|
2557
|
-
|
|
2588
|
+
_h.sent();
|
|
2589
|
+
_h.label = 3;
|
|
2558
2590
|
case 3:
|
|
2559
2591
|
_b = _a.next();
|
|
2560
2592
|
return [3 /*break*/, 1];
|
|
2561
2593
|
case 4: return [3 /*break*/, 7];
|
|
2562
2594
|
case 5:
|
|
2563
|
-
e_40_1 =
|
|
2595
|
+
e_40_1 = _h.sent();
|
|
2564
2596
|
e_40 = { error: e_40_1 };
|
|
2565
2597
|
return [3 /*break*/, 7];
|
|
2566
2598
|
case 6:
|
|
@@ -2574,28 +2606,28 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2574
2606
|
e = this.buildLifeCycleEvent(function () { });
|
|
2575
2607
|
return [4 /*yield*/, this.info.entityInfo.validation(this.instance, e)];
|
|
2576
2608
|
case 8:
|
|
2577
|
-
|
|
2578
|
-
|
|
2609
|
+
_h.sent();
|
|
2610
|
+
_h.label = 9;
|
|
2579
2611
|
case 9:
|
|
2580
|
-
if (!this.
|
|
2581
|
-
|
|
2612
|
+
if (!this.repo.listeners) return [3 /*break*/, 17];
|
|
2613
|
+
_h.label = 10;
|
|
2582
2614
|
case 10:
|
|
2583
|
-
|
|
2584
|
-
_c = tslib_1.__values(this.
|
|
2585
|
-
|
|
2615
|
+
_h.trys.push([10, 15, 16, 17]);
|
|
2616
|
+
_c = tslib_1.__values(this.repo.listeners), _d = _c.next();
|
|
2617
|
+
_h.label = 11;
|
|
2586
2618
|
case 11:
|
|
2587
2619
|
if (!!_d.done) return [3 /*break*/, 14];
|
|
2588
2620
|
listener = _d.value;
|
|
2589
|
-
return [4 /*yield*/, listener.validating(this.instance)];
|
|
2621
|
+
return [4 /*yield*/, ((_g = listener.validating) === null || _g === void 0 ? void 0 : _g.call(listener, this.instance))];
|
|
2590
2622
|
case 12:
|
|
2591
|
-
|
|
2592
|
-
|
|
2623
|
+
_h.sent();
|
|
2624
|
+
_h.label = 13;
|
|
2593
2625
|
case 13:
|
|
2594
2626
|
_d = _c.next();
|
|
2595
2627
|
return [3 /*break*/, 11];
|
|
2596
2628
|
case 14: return [3 /*break*/, 17];
|
|
2597
2629
|
case 15:
|
|
2598
|
-
e_41_1 =
|
|
2630
|
+
e_41_1 = _h.sent();
|
|
2599
2631
|
e_41 = { error: e_41_1 };
|
|
2600
2632
|
return [3 /*break*/, 17];
|
|
2601
2633
|
case 16:
|
|
@@ -2619,10 +2651,11 @@ function prepareColumnInfo(r, remult) {
|
|
|
2619
2651
|
function getFields(container, remult) {
|
|
2620
2652
|
return getControllerRef(container, remult).fields;
|
|
2621
2653
|
}
|
|
2622
|
-
exports.getFields = getFields;
|
|
2623
2654
|
function getControllerRef(container, remultArg) {
|
|
2624
2655
|
var remultVar = remultArg || remult_proxy_js_1.remult;
|
|
2656
|
+
//@ts-ignore
|
|
2625
2657
|
var result = container[controllerColumns];
|
|
2658
|
+
//@ts-ignore
|
|
2626
2659
|
if (!result)
|
|
2627
2660
|
result = container[getEntityRef_js_1.entityMember];
|
|
2628
2661
|
if (!result) {
|
|
@@ -2637,11 +2670,14 @@ function getControllerRef(container, remultArg) {
|
|
|
2637
2670
|
}
|
|
2638
2671
|
base = Object.getPrototypeOf(base);
|
|
2639
2672
|
}
|
|
2640
|
-
|
|
2673
|
+
//@ts-ignore
|
|
2674
|
+
container[controllerColumns] = result = new controllerRefImpl(prepareColumnInfo(columnSettings_1, remultVar).map(function (x) {
|
|
2675
|
+
return new columnDefsImpl(x, undefined, //TODO - not sure
|
|
2676
|
+
remultVar);
|
|
2677
|
+
}), container, remultVar);
|
|
2641
2678
|
}
|
|
2642
2679
|
return result;
|
|
2643
2680
|
}
|
|
2644
|
-
exports.getControllerRef = getControllerRef;
|
|
2645
2681
|
var controllerRefImpl = /** @class */ (function (_super) {
|
|
2646
2682
|
tslib_1.__extends(controllerRefImpl, _super);
|
|
2647
2683
|
function controllerRefImpl(columnsInfo, instance, remult) {
|
|
@@ -2720,7 +2756,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2720
2756
|
this.helper = helper;
|
|
2721
2757
|
this.rowBase = rowBase;
|
|
2722
2758
|
this.target = this.settings.target;
|
|
2723
|
-
this.entityRef = this.helper;
|
|
2759
|
+
this.entityRef = this.helper; //todo - I'm not sure this is correct in the case of ControllerInstance
|
|
2724
2760
|
}
|
|
2725
2761
|
FieldRefImplementation.prototype.subscribe = function (listener) {
|
|
2726
2762
|
if (!this._subscribers) {
|
|
@@ -2741,6 +2777,21 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2741
2777
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
2742
2778
|
return this.rawOriginalValue() === null;
|
|
2743
2779
|
};
|
|
2780
|
+
Object.defineProperty(FieldRefImplementation.prototype, "key", {
|
|
2781
|
+
get: function () {
|
|
2782
|
+
return this.metadata.key;
|
|
2783
|
+
},
|
|
2784
|
+
enumerable: false,
|
|
2785
|
+
configurable: true
|
|
2786
|
+
});
|
|
2787
|
+
Object.defineProperty(FieldRefImplementation.prototype, "repo", {
|
|
2788
|
+
get: function () {
|
|
2789
|
+
var _a;
|
|
2790
|
+
return (_a = this.helper) === null || _a === void 0 ? void 0 : _a.repository;
|
|
2791
|
+
},
|
|
2792
|
+
enumerable: false,
|
|
2793
|
+
configurable: true
|
|
2794
|
+
});
|
|
2744
2795
|
FieldRefImplementation.prototype.load = function () {
|
|
2745
2796
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2746
2797
|
var lu, rel, _a, _b, val;
|
|
@@ -2749,21 +2800,20 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2749
2800
|
case 0:
|
|
2750
2801
|
lu = this.rowBase.lookups.get(this.metadata.key);
|
|
2751
2802
|
rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(this.metadata);
|
|
2752
|
-
if (!rel) return [3 /*break*/, 5];
|
|
2803
|
+
if (!(rel && this.helper)) return [3 /*break*/, 5];
|
|
2753
2804
|
if (!(rel.type === 'toMany')) return [3 /*break*/, 2];
|
|
2754
2805
|
_a = this.container;
|
|
2755
2806
|
_b = this.metadata.key;
|
|
2756
|
-
return [4 /*yield*/, this.
|
|
2757
|
-
.relations(this.container)[this.metadata.key].find()];
|
|
2807
|
+
return [4 /*yield*/, this.repo.relations(this.container)[this.key].find()];
|
|
2758
2808
|
case 1: return [2 /*return*/, (_a[_b] = _c.sent())];
|
|
2759
|
-
case 2: return [4 /*yield*/, this.
|
|
2809
|
+
case 2: return [4 /*yield*/, this.repo
|
|
2760
2810
|
.relations(this.container)[this.metadata.key].findOne()];
|
|
2761
2811
|
case 3:
|
|
2762
2812
|
val = _c.sent();
|
|
2763
2813
|
if (val)
|
|
2764
2814
|
this.container[this.metadata.key] = val;
|
|
2765
2815
|
else
|
|
2766
|
-
return [2 /*return*/, null];
|
|
2816
|
+
return [2 /*return*/, null]; //TODO: check if this (!) is correct
|
|
2767
2817
|
_c.label = 4;
|
|
2768
2818
|
case 4: return [3 /*break*/, 9];
|
|
2769
2819
|
case 5:
|
|
@@ -2884,15 +2934,15 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2884
2934
|
return (JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key])) != JSON.stringify(this.metadata.valueConverter.toJson(val)));
|
|
2885
2935
|
};
|
|
2886
2936
|
FieldRefImplementation.prototype.__performValidation = function () {
|
|
2887
|
-
var _a;
|
|
2888
2937
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2889
|
-
var processValidation, self_1, event_1,
|
|
2890
|
-
var e_44,
|
|
2938
|
+
var processValidation, self_1, event_1, _a, _b, v, _c, e_44_1, _d, error_1;
|
|
2939
|
+
var e_44, _e;
|
|
2891
2940
|
var _this = this;
|
|
2892
|
-
|
|
2893
|
-
|
|
2941
|
+
var _f, _g;
|
|
2942
|
+
return tslib_1.__generator(this, function (_h) {
|
|
2943
|
+
switch (_h.label) {
|
|
2894
2944
|
case 0:
|
|
2895
|
-
|
|
2945
|
+
_h.trys.push([0, 12, , 13]);
|
|
2896
2946
|
processValidation = function (result) {
|
|
2897
2947
|
if (result !== true && result !== undefined && !_this.error) {
|
|
2898
2948
|
if (typeof result === 'string' && result.length > 0)
|
|
@@ -2911,7 +2961,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2911
2961
|
set error(value) {
|
|
2912
2962
|
self_1.error = value;
|
|
2913
2963
|
},
|
|
2914
|
-
isNew: (
|
|
2964
|
+
isNew: (_g = (_f = this.entityRef) === null || _f === void 0 ? void 0 : _f.isNew()) !== null && _g !== void 0 ? _g : false,
|
|
2915
2965
|
load: function () { return self_1.load(); },
|
|
2916
2966
|
metadata: self_1.metadata,
|
|
2917
2967
|
originalValue: self_1.originalValue,
|
|
@@ -2922,48 +2972,48 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2922
2972
|
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); },
|
|
2923
2973
|
};
|
|
2924
2974
|
if (!Array.isArray(this.settings.validate)) return [3 /*break*/, 9];
|
|
2925
|
-
|
|
2975
|
+
_h.label = 1;
|
|
2926
2976
|
case 1:
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2977
|
+
_h.trys.push([1, 6, 7, 8]);
|
|
2978
|
+
_a = tslib_1.__values(this.settings.validate), _b = _a.next();
|
|
2979
|
+
_h.label = 2;
|
|
2930
2980
|
case 2:
|
|
2931
|
-
if (!!
|
|
2932
|
-
v =
|
|
2933
|
-
|
|
2981
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
2982
|
+
v = _b.value;
|
|
2983
|
+
_c = processValidation;
|
|
2934
2984
|
return [4 /*yield*/, v(this.container, event_1)];
|
|
2935
2985
|
case 3:
|
|
2936
|
-
|
|
2937
|
-
|
|
2986
|
+
_c.apply(void 0, [_h.sent()]);
|
|
2987
|
+
_h.label = 4;
|
|
2938
2988
|
case 4:
|
|
2939
|
-
|
|
2989
|
+
_b = _a.next();
|
|
2940
2990
|
return [3 /*break*/, 2];
|
|
2941
2991
|
case 5: return [3 /*break*/, 8];
|
|
2942
2992
|
case 6:
|
|
2943
|
-
e_44_1 =
|
|
2993
|
+
e_44_1 = _h.sent();
|
|
2944
2994
|
e_44 = { error: e_44_1 };
|
|
2945
2995
|
return [3 /*break*/, 8];
|
|
2946
2996
|
case 7:
|
|
2947
2997
|
try {
|
|
2948
|
-
if (
|
|
2998
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
2949
2999
|
}
|
|
2950
3000
|
finally { if (e_44) throw e_44.error; }
|
|
2951
3001
|
return [7 /*endfinally*/];
|
|
2952
3002
|
case 8: return [3 /*break*/, 11];
|
|
2953
3003
|
case 9:
|
|
2954
3004
|
if (!(typeof this.settings.validate === 'function')) return [3 /*break*/, 11];
|
|
2955
|
-
|
|
3005
|
+
_d = processValidation;
|
|
2956
3006
|
return [4 /*yield*/, this.settings.validate(this.container, event_1)];
|
|
2957
3007
|
case 10:
|
|
2958
|
-
|
|
2959
|
-
|
|
3008
|
+
_d.apply(void 0, [_h.sent()]);
|
|
3009
|
+
_h.label = 11;
|
|
2960
3010
|
case 11: return [3 /*break*/, 13];
|
|
2961
3011
|
case 12:
|
|
2962
|
-
error_1 =
|
|
3012
|
+
error_1 = _h.sent();
|
|
2963
3013
|
if (typeof error_1 === 'string')
|
|
2964
3014
|
this.error = error_1;
|
|
2965
3015
|
else
|
|
2966
|
-
this.error = error_1.message;
|
|
3016
|
+
this.error = error_1 === null || error_1 === void 0 ? void 0 : error_1.message;
|
|
2967
3017
|
return [3 /*break*/, 13];
|
|
2968
3018
|
case 13: return [2 /*return*/];
|
|
2969
3019
|
}
|
|
@@ -2991,30 +3041,32 @@ var tempCaptionTransformer = {
|
|
|
2991
3041
|
exports.CaptionTransformer = remult_static_js_1.remultStatic.captionTransformer ||
|
|
2992
3042
|
(remult_static_js_1.remultStatic.captionTransformer = tempCaptionTransformer);
|
|
2993
3043
|
function buildCaption(caption, key, remult, metaData) {
|
|
2994
|
-
var result;
|
|
3044
|
+
var result = undefined;
|
|
2995
3045
|
if (typeof caption === 'function') {
|
|
2996
3046
|
if (remult)
|
|
2997
3047
|
result = caption(remult);
|
|
2998
3048
|
}
|
|
2999
3049
|
else if (caption)
|
|
3000
3050
|
result = caption;
|
|
3001
|
-
result = exports.CaptionTransformer.transformCaption(remult, key, result, metaData);
|
|
3051
|
+
result = exports.CaptionTransformer.transformCaption(remult, key, result !== null && result !== void 0 ? result : '', metaData);
|
|
3002
3052
|
if (result)
|
|
3003
3053
|
return result;
|
|
3004
3054
|
if (key)
|
|
3005
3055
|
return (0, column_js_1.makeTitle)(key);
|
|
3006
3056
|
return '';
|
|
3007
3057
|
}
|
|
3008
|
-
exports.buildCaption = buildCaption;
|
|
3009
3058
|
var columnDefsImpl = /** @class */ (function () {
|
|
3010
3059
|
function columnDefsImpl(settings, entityDefs, remult) {
|
|
3011
3060
|
var _this = this;
|
|
3061
|
+
var _a;
|
|
3012
3062
|
this.settings = settings;
|
|
3013
3063
|
this.entityDefs = entityDefs;
|
|
3014
3064
|
this.remult = remult;
|
|
3065
|
+
this.readonly = false;
|
|
3066
|
+
this.isServerExpression = false;
|
|
3015
3067
|
this.options = this.settings;
|
|
3016
3068
|
this.target = this.settings.target;
|
|
3017
|
-
this.valueConverter = new Proxy(this.settings.valueConverter, {
|
|
3069
|
+
this.valueConverter = new Proxy((_a = this.settings.valueConverter) !== null && _a !== void 0 ? _a : {}, {
|
|
3018
3070
|
get: function (target, prop) {
|
|
3019
3071
|
var result = target[prop];
|
|
3020
3072
|
if (typeof result === 'function') {
|
|
@@ -3086,7 +3138,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
3086
3138
|
};
|
|
3087
3139
|
Object.defineProperty(columnDefsImpl.prototype, "dbReadOnly", {
|
|
3088
3140
|
get: function () {
|
|
3089
|
-
return this.settings.dbReadOnly;
|
|
3141
|
+
return Boolean(this.settings.dbReadOnly);
|
|
3090
3142
|
},
|
|
3091
3143
|
enumerable: false,
|
|
3092
3144
|
configurable: true
|
|
@@ -3122,12 +3174,17 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3122
3174
|
: [this.field];
|
|
3123
3175
|
},
|
|
3124
3176
|
createIdInFilter: function (items) {
|
|
3177
|
+
var _a;
|
|
3125
3178
|
if (items.length > 0)
|
|
3126
3179
|
return {
|
|
3127
3180
|
$or: items.map(function (x) {
|
|
3128
3181
|
return _this.idMetadata.getIdFilter((0, getEntityRef_js_1.getEntityRef)(x).getId());
|
|
3129
3182
|
}),
|
|
3130
3183
|
};
|
|
3184
|
+
else
|
|
3185
|
+
return _a = {},
|
|
3186
|
+
_a[_this.fields.toArray()[0].key] = [],
|
|
3187
|
+
_a;
|
|
3131
3188
|
},
|
|
3132
3189
|
isIdField: function (col) {
|
|
3133
3190
|
return col.key == _this.idMetadata.field.key;
|
|
@@ -3166,11 +3223,11 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3166
3223
|
else
|
|
3167
3224
|
crud = this.options.allowApiCrud;
|
|
3168
3225
|
if (this.options.allowApiDelete === undefined)
|
|
3169
|
-
this.
|
|
3226
|
+
this.entityInfo.allowApiDelete = crud;
|
|
3170
3227
|
if (this.options.allowApiInsert === undefined)
|
|
3171
|
-
this.
|
|
3228
|
+
this.entityInfo.allowApiInsert = crud;
|
|
3172
3229
|
if (this.options.allowApiUpdate === undefined)
|
|
3173
|
-
this.
|
|
3230
|
+
this.entityInfo.allowApiUpdate = crud;
|
|
3174
3231
|
if (this.options.allowApiRead === undefined)
|
|
3175
3232
|
this.options.allowApiRead = this.options.allowApiCrud;
|
|
3176
3233
|
}
|
|
@@ -3218,8 +3275,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3218
3275
|
this.idMetadata.field = r_2;
|
|
3219
3276
|
}
|
|
3220
3277
|
if (!this.idMetadata.field) {
|
|
3221
|
-
|
|
3222
|
-
|
|
3278
|
+
var idField = this.fields['id'];
|
|
3279
|
+
if (idField)
|
|
3280
|
+
this.idMetadata.field = idField;
|
|
3223
3281
|
else
|
|
3224
3282
|
this.idMetadata.field = tslib_1.__spreadArray([], tslib_1.__read(this.fields), false)[0];
|
|
3225
3283
|
}
|
|
@@ -3279,12 +3337,10 @@ function FieldType() {
|
|
|
3279
3337
|
return target;
|
|
3280
3338
|
};
|
|
3281
3339
|
}
|
|
3282
|
-
exports.FieldType = FieldType;
|
|
3283
3340
|
function isAutoIncrement(f) {
|
|
3284
3341
|
var _a, _b;
|
|
3285
3342
|
return ((_b = (_a = f.options) === null || _a === void 0 ? void 0 : _a.valueConverter) === null || _b === void 0 ? void 0 : _b.fieldTypeInDb) === 'autoincrement';
|
|
3286
3343
|
}
|
|
3287
|
-
exports.isAutoIncrement = isAutoIncrement;
|
|
3288
3344
|
function ValueListFieldType() {
|
|
3289
3345
|
var options = [];
|
|
3290
3346
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -3302,10 +3358,9 @@ function ValueListFieldType() {
|
|
|
3302
3358
|
}
|
|
3303
3359
|
return validators_js_1.Validators.in(values)(entity, ref);
|
|
3304
3360
|
};
|
|
3305
|
-
}], tslib_1.__read(options), false))(type
|
|
3361
|
+
}], tslib_1.__read(options), false))(type);
|
|
3306
3362
|
};
|
|
3307
3363
|
}
|
|
3308
|
-
exports.ValueListFieldType = ValueListFieldType;
|
|
3309
3364
|
var ValueListInfo = /** @class */ (function () {
|
|
3310
3365
|
function ValueListInfo(valueListType) {
|
|
3311
3366
|
var e_46, _a, _b;
|
|
@@ -3415,12 +3470,11 @@ function getValueList(type) {
|
|
|
3415
3470
|
if (options)
|
|
3416
3471
|
return ValueListInfo.get(type).getValues();
|
|
3417
3472
|
}
|
|
3418
|
-
var optionalValues = meta === null || meta === void 0 ? void 0 : meta.options[exports.fieldOptionalValuesFunctionKey];
|
|
3473
|
+
var optionalValues = (meta === null || meta === void 0 ? void 0 : meta.options)[exports.fieldOptionalValuesFunctionKey];
|
|
3419
3474
|
if (optionalValues)
|
|
3420
3475
|
return optionalValues();
|
|
3421
3476
|
return undefined;
|
|
3422
3477
|
}
|
|
3423
|
-
exports.getValueList = getValueList;
|
|
3424
3478
|
exports.storableMember = Symbol.for('storableMember');
|
|
3425
3479
|
exports.fieldOptionalValuesFunctionKey = Symbol.for('fieldOptionalValues');
|
|
3426
3480
|
function buildOptions(options, remult) {
|
|
@@ -3449,7 +3503,6 @@ function buildOptions(options, remult) {
|
|
|
3449
3503
|
}
|
|
3450
3504
|
return r;
|
|
3451
3505
|
}
|
|
3452
|
-
exports.buildOptions = buildOptions;
|
|
3453
3506
|
function decorateColumnSettings(settings, remult) {
|
|
3454
3507
|
if (settings.valueType) {
|
|
3455
3508
|
var settingsOnTypeLevel = settings.valueType[exports.storableMember];
|
|
@@ -3538,23 +3591,22 @@ function decorateColumnSettings(settings, remult) {
|
|
|
3538
3591
|
if (!settings.valueConverter.fromJson) {
|
|
3539
3592
|
settings.valueConverter.fromJson = function (x) { return x; };
|
|
3540
3593
|
}
|
|
3594
|
+
var fromJson = settings.valueConverter.fromJson;
|
|
3595
|
+
var toJson = settings.valueConverter.toJson;
|
|
3541
3596
|
if (!settings.valueConverter.toDb) {
|
|
3542
|
-
settings.valueConverter.toDb = function (x) { return
|
|
3597
|
+
settings.valueConverter.toDb = function (x) { return toJson(x); };
|
|
3543
3598
|
}
|
|
3544
3599
|
if (!settings.valueConverter.fromDb) {
|
|
3545
|
-
settings.valueConverter.fromDb = function (x) { return
|
|
3600
|
+
settings.valueConverter.fromDb = function (x) { return fromJson(x); };
|
|
3546
3601
|
}
|
|
3547
3602
|
if (!settings.valueConverter.toInput) {
|
|
3548
|
-
settings.valueConverter.toInput = function (x) { return
|
|
3603
|
+
settings.valueConverter.toInput = function (x) { return toJson(x); };
|
|
3549
3604
|
}
|
|
3550
3605
|
if (!settings.valueConverter.fromInput) {
|
|
3551
|
-
settings.valueConverter.fromInput = function (x) {
|
|
3552
|
-
return settings.valueConverter.fromJson(x);
|
|
3553
|
-
};
|
|
3606
|
+
settings.valueConverter.fromInput = function (x) { return fromJson(x); };
|
|
3554
3607
|
}
|
|
3555
3608
|
return settings;
|
|
3556
3609
|
}
|
|
3557
|
-
exports.decorateColumnSettings = decorateColumnSettings;
|
|
3558
3610
|
var EntityBase = /** @class */ (function () {
|
|
3559
3611
|
function EntityBase() {
|
|
3560
3612
|
}
|
|
@@ -3627,7 +3679,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3627
3679
|
QueryResultImpl.prototype.getPage = function (page) {
|
|
3628
3680
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3629
3681
|
return tslib_1.__generator(this, function (_a) {
|
|
3630
|
-
if (page < 1)
|
|
3682
|
+
if ((page !== null && page !== void 0 ? page : 0) < 1)
|
|
3631
3683
|
page = 1;
|
|
3632
3684
|
return [2 /*return*/, this.repo.find({
|
|
3633
3685
|
where: this.options.where,
|
|
@@ -3658,9 +3710,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3658
3710
|
});
|
|
3659
3711
|
};
|
|
3660
3712
|
QueryResultImpl.prototype.forEach = function (what) {
|
|
3661
|
-
var _a, e_49, _b, _c;
|
|
3662
3713
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3663
|
-
var i,
|
|
3714
|
+
var i, _a, _b, _c, x, e_49_1;
|
|
3715
|
+
var _d, e_49, _e, _f;
|
|
3664
3716
|
return tslib_1.__generator(this, function (_g) {
|
|
3665
3717
|
switch (_g.label) {
|
|
3666
3718
|
case 0:
|
|
@@ -3668,21 +3720,21 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3668
3720
|
_g.label = 1;
|
|
3669
3721
|
case 1:
|
|
3670
3722
|
_g.trys.push([1, 7, 8, 13]);
|
|
3671
|
-
|
|
3723
|
+
_a = true, _b = tslib_1.__asyncValues(this);
|
|
3672
3724
|
_g.label = 2;
|
|
3673
|
-
case 2: return [4 /*yield*/,
|
|
3725
|
+
case 2: return [4 /*yield*/, _b.next()];
|
|
3674
3726
|
case 3:
|
|
3675
|
-
if (!(
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
x =
|
|
3727
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 6];
|
|
3728
|
+
_f = _c.value;
|
|
3729
|
+
_a = false;
|
|
3730
|
+
x = _f;
|
|
3679
3731
|
return [4 /*yield*/, what(x)];
|
|
3680
3732
|
case 4:
|
|
3681
3733
|
_g.sent();
|
|
3682
3734
|
i++;
|
|
3683
3735
|
_g.label = 5;
|
|
3684
3736
|
case 5:
|
|
3685
|
-
|
|
3737
|
+
_a = true;
|
|
3686
3738
|
return [3 /*break*/, 2];
|
|
3687
3739
|
case 6: return [3 /*break*/, 13];
|
|
3688
3740
|
case 7:
|
|
@@ -3691,8 +3743,8 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3691
3743
|
return [3 /*break*/, 13];
|
|
3692
3744
|
case 8:
|
|
3693
3745
|
_g.trys.push([8, , 11, 12]);
|
|
3694
|
-
if (!(!
|
|
3695
|
-
return [4 /*yield*/,
|
|
3746
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 10];
|
|
3747
|
+
return [4 /*yield*/, _e.call(_b)];
|
|
3696
3748
|
case 9:
|
|
3697
3749
|
_g.sent();
|
|
3698
3750
|
_g.label = 10;
|
|
@@ -3725,7 +3777,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3725
3777
|
})];
|
|
3726
3778
|
case 1:
|
|
3727
3779
|
items = _a.sent();
|
|
3728
|
-
nextPage =
|
|
3780
|
+
nextPage = function () {
|
|
3781
|
+
throw new Error('no more pages');
|
|
3782
|
+
};
|
|
3729
3783
|
hasNextPage = items.length == this.options.pageSize;
|
|
3730
3784
|
if (!hasNextPage) return [3 /*break*/, 3];
|
|
3731
3785
|
return [4 /*yield*/, this.repo._createAfterFilter(this.options.orderBy, items[items.length - 1])];
|
|
@@ -3756,16 +3810,17 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3756
3810
|
var j = 0;
|
|
3757
3811
|
itStrategy = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
3758
3812
|
var _a, _b, _c, prev;
|
|
3759
|
-
|
|
3760
|
-
|
|
3813
|
+
var _d;
|
|
3814
|
+
return tslib_1.__generator(this, function (_e) {
|
|
3815
|
+
switch (_e.label) {
|
|
3761
3816
|
case 0:
|
|
3762
3817
|
if (!this.options.progress) return [3 /*break*/, 2];
|
|
3763
3818
|
_b = (_a = this.options.progress).progress;
|
|
3764
3819
|
_c = j++;
|
|
3765
3820
|
return [4 /*yield*/, this.count()];
|
|
3766
3821
|
case 1:
|
|
3767
|
-
_b.apply(_a, [_c / (
|
|
3768
|
-
|
|
3822
|
+
_b.apply(_a, [_c / (_e.sent())]);
|
|
3823
|
+
_e.label = 2;
|
|
3769
3824
|
case 2:
|
|
3770
3825
|
if (!(currentPage === undefined || itemIndex == currentPage.items.length)) return [3 /*break*/, 7];
|
|
3771
3826
|
if (currentPage && !currentPage.hasNextPage)
|
|
@@ -3774,29 +3829,29 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3774
3829
|
if (!currentPage) return [3 /*break*/, 4];
|
|
3775
3830
|
return [4 /*yield*/, currentPage.nextPage()];
|
|
3776
3831
|
case 3:
|
|
3777
|
-
currentPage =
|
|
3832
|
+
currentPage = _e.sent();
|
|
3778
3833
|
return [3 /*break*/, 6];
|
|
3779
3834
|
case 4: return [4 /*yield*/, this.paginator()];
|
|
3780
3835
|
case 5:
|
|
3781
|
-
currentPage =
|
|
3782
|
-
|
|
3836
|
+
currentPage = _e.sent();
|
|
3837
|
+
_e.label = 6;
|
|
3783
3838
|
case 6:
|
|
3784
3839
|
itemIndex = 0;
|
|
3785
3840
|
if (currentPage.items.length == 0) {
|
|
3786
3841
|
return [2 /*return*/, { value: undefined, done: true }];
|
|
3787
3842
|
}
|
|
3788
3843
|
else {
|
|
3789
|
-
if ((prev === null || prev === void 0 ? void 0 : prev.items.length) > 0) {
|
|
3844
|
+
if ((_d = prev === null || prev === void 0 ? void 0 : prev.items.length) !== null && _d !== void 0 ? _d : 0 > 0) {
|
|
3790
3845
|
if (this.repo.getEntityRef(prev.items[0]).getId() ==
|
|
3791
3846
|
this.repo.getEntityRef(currentPage.items[0]).getId())
|
|
3792
3847
|
throw new Error('pagination failure, returned same first row');
|
|
3793
3848
|
}
|
|
3794
3849
|
}
|
|
3795
|
-
|
|
3850
|
+
_e.label = 7;
|
|
3796
3851
|
case 7:
|
|
3797
3852
|
if (itemIndex < currentPage.items.length)
|
|
3798
3853
|
return [2 /*return*/, { value: currentPage.items[itemIndex++], done: false }];
|
|
3799
|
-
return [2 /*return
|
|
3854
|
+
return [2 /*return*/, { done: true, value: undefined }];
|
|
3800
3855
|
}
|
|
3801
3856
|
});
|
|
3802
3857
|
}); };
|
|
@@ -3858,7 +3913,6 @@ function getEntityMetadata(entity) {
|
|
|
3858
3913
|
}
|
|
3859
3914
|
return entity;
|
|
3860
3915
|
}
|
|
3861
|
-
exports.getEntityMetadata = getEntityMetadata;
|
|
3862
3916
|
function getRepository(entity) {
|
|
3863
3917
|
var settings = (0, getEntityRef_js_1.getEntitySettings)(entity, false);
|
|
3864
3918
|
if (settings) {
|
|
@@ -3866,7 +3920,6 @@ function getRepository(entity) {
|
|
|
3866
3920
|
}
|
|
3867
3921
|
return entity;
|
|
3868
3922
|
}
|
|
3869
|
-
exports.getRepository = getRepository;
|
|
3870
3923
|
function promiseAll(array, mapToPromise) {
|
|
3871
3924
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3872
3925
|
var result, index, element, _a, _b;
|