remult 3.3.0-next.1 → 3.3.1
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/esm/graphql.js +1 -1
- package/esm/remult-knex/index.js +10 -3
- package/esm/remult-mongo.js +7 -3
- package/esm/server/get-remult-admin-html.js +125 -111
- package/esm/server/remult-admin.js +2 -0
- package/esm/server/remult-api-server.js +1 -1
- package/esm/src/data-api.js +30 -19
- package/esm/src/data-providers/rest-data-provider.js +48 -37
- package/esm/src/data-providers/sql-database.js +14 -3
- package/esm/src/live-query/SubscriptionChannel.js +52 -4
- package/esm/src/remult-proxy.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.js +53 -25
- package/esm/src/server-action.js +2 -2
- package/esm/src/valueConverters.js +9 -5
- package/graphql.js +1 -1
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/remult-knex/index.js +18 -9
- package/remult-mongo.js +6 -2
- package/server/get-remult-admin-html.js +1 -1
- package/server/remult-admin.d.ts +2 -0
- package/server/remult-admin.js +2 -1
- package/server/remult-api-server.js +1 -0
- package/src/data-api.d.ts +4 -4
- package/src/data-api.js +50 -30
- package/src/data-interfaces.d.ts +6 -6
- package/src/data-providers/rest-data-provider.d.ts +4 -4
- package/src/data-providers/rest-data-provider.js +48 -37
- package/src/data-providers/sql-database.js +14 -3
- package/src/live-query/SubscriptionChannel.d.ts +52 -4
- package/src/live-query/SubscriptionChannel.js +52 -4
- package/src/remult-proxy.js +4 -4
- package/src/remult3/RepositoryImplementation.d.ts +11 -10
- package/src/remult3/RepositoryImplementation.js +237 -177
- package/src/remult3/remult3.d.ts +25 -23
- package/src/server-action.js +2 -2
- package/src/valueConverters.d.ts +3 -1
- package/src/valueConverters.js +9 -6
|
@@ -453,22 +453,22 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
453
453
|
finally { if (e_5) throw e_5.error; }
|
|
454
454
|
}
|
|
455
455
|
};
|
|
456
|
-
RepositoryImplementation.prototype.insert = function (entity) {
|
|
456
|
+
RepositoryImplementation.prototype.insert = function (entity, options) {
|
|
457
457
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
458
|
-
var refs_1, raw, entity_1, entity_1_1, item, ref, _a, _b, e_6_1,
|
|
459
|
-
var e_6,
|
|
460
|
-
return tslib_1.__generator(this, function (
|
|
461
|
-
switch (
|
|
458
|
+
var refs_1, raw, entity_1, entity_1_1, item, ref, _a, _b, e_6_1, inserted, r, entity_2, entity_2_1, item, _c, _d, e_7_1, ref, result;
|
|
459
|
+
var e_6, _e, e_7, _f;
|
|
460
|
+
return tslib_1.__generator(this, function (_g) {
|
|
461
|
+
switch (_g.label) {
|
|
462
462
|
case 0:
|
|
463
463
|
if (!Array.isArray(entity)) return [3 /*break*/, 23];
|
|
464
464
|
if (!this._dataProvider.isProxy) return [3 /*break*/, 13];
|
|
465
465
|
refs_1 = [];
|
|
466
466
|
raw = [];
|
|
467
|
-
|
|
467
|
+
_g.label = 1;
|
|
468
468
|
case 1:
|
|
469
|
-
|
|
469
|
+
_g.trys.push([1, 9, 10, 11]);
|
|
470
470
|
entity_1 = tslib_1.__values(entity), entity_1_1 = entity_1.next();
|
|
471
|
-
|
|
471
|
+
_g.label = 2;
|
|
472
472
|
case 2:
|
|
473
473
|
if (!!entity_1_1.done) return [3 /*break*/, 8];
|
|
474
474
|
item = entity_1_1.value;
|
|
@@ -480,76 +480,92 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
480
480
|
return [3 /*break*/, 5];
|
|
481
481
|
case 3: return [4 /*yield*/, this.getEntityRef(this.create(item))];
|
|
482
482
|
case 4:
|
|
483
|
-
ref = (
|
|
484
|
-
|
|
483
|
+
ref = (_g.sent());
|
|
484
|
+
_g.label = 5;
|
|
485
485
|
case 5:
|
|
486
486
|
refs_1.push(ref);
|
|
487
487
|
_b = (_a = raw).push;
|
|
488
488
|
return [4 /*yield*/, ref.buildDtoForInsert()];
|
|
489
489
|
case 6:
|
|
490
|
-
_b.apply(_a, [
|
|
491
|
-
|
|
490
|
+
_b.apply(_a, [_g.sent()]);
|
|
491
|
+
_g.label = 7;
|
|
492
492
|
case 7:
|
|
493
493
|
entity_1_1 = entity_1.next();
|
|
494
494
|
return [3 /*break*/, 2];
|
|
495
495
|
case 8: return [3 /*break*/, 11];
|
|
496
496
|
case 9:
|
|
497
|
-
e_6_1 =
|
|
497
|
+
e_6_1 = _g.sent();
|
|
498
498
|
e_6 = { error: e_6_1 };
|
|
499
499
|
return [3 /*break*/, 11];
|
|
500
500
|
case 10:
|
|
501
501
|
try {
|
|
502
|
-
if (entity_1_1 && !entity_1_1.done && (
|
|
502
|
+
if (entity_1_1 && !entity_1_1.done && (_e = entity_1.return)) _e.call(entity_1);
|
|
503
503
|
}
|
|
504
504
|
finally { if (e_6) throw e_6.error; }
|
|
505
505
|
return [7 /*endfinally*/];
|
|
506
|
-
case 11:
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
506
|
+
case 11: return [4 /*yield*/, this._edp.insertMany(raw, options)];
|
|
507
|
+
case 12:
|
|
508
|
+
inserted = _g.sent();
|
|
509
|
+
if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
|
|
510
|
+
return [2 /*return*/, undefined];
|
|
511
|
+
return [2 /*return*/, promiseAll(inserted, function (item, i) {
|
|
512
|
+
return refs_1[i].processInsertResponseDto(item);
|
|
513
|
+
})];
|
|
510
514
|
case 13:
|
|
511
515
|
r = [];
|
|
512
|
-
|
|
516
|
+
_g.label = 14;
|
|
513
517
|
case 14:
|
|
514
|
-
|
|
518
|
+
_g.trys.push([14, 19, 20, 21]);
|
|
515
519
|
entity_2 = tslib_1.__values(entity), entity_2_1 = entity_2.next();
|
|
516
|
-
|
|
520
|
+
_g.label = 15;
|
|
517
521
|
case 15:
|
|
518
522
|
if (!!entity_2_1.done) return [3 /*break*/, 18];
|
|
519
523
|
item = entity_2_1.value;
|
|
520
|
-
|
|
521
|
-
return [4 /*yield*/, this.insert(item)];
|
|
524
|
+
_d = (_c = r).push;
|
|
525
|
+
return [4 /*yield*/, this.insert(item, options)];
|
|
522
526
|
case 16:
|
|
523
|
-
|
|
524
|
-
|
|
527
|
+
_d.apply(_c, [_g.sent()]);
|
|
528
|
+
_g.label = 17;
|
|
525
529
|
case 17:
|
|
526
530
|
entity_2_1 = entity_2.next();
|
|
527
531
|
return [3 /*break*/, 15];
|
|
528
532
|
case 18: return [3 /*break*/, 21];
|
|
529
533
|
case 19:
|
|
530
|
-
e_7_1 =
|
|
534
|
+
e_7_1 = _g.sent();
|
|
531
535
|
e_7 = { error: e_7_1 };
|
|
532
536
|
return [3 /*break*/, 21];
|
|
533
537
|
case 20:
|
|
534
538
|
try {
|
|
535
|
-
if (entity_2_1 && !entity_2_1.done && (
|
|
539
|
+
if (entity_2_1 && !entity_2_1.done && (_f = entity_2.return)) _f.call(entity_2);
|
|
536
540
|
}
|
|
537
541
|
finally { if (e_7) throw e_7.error; }
|
|
538
542
|
return [7 /*endfinally*/];
|
|
539
|
-
case 21:
|
|
540
|
-
|
|
543
|
+
case 21:
|
|
544
|
+
if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
|
|
545
|
+
return [2 /*return*/, undefined];
|
|
546
|
+
return [2 /*return*/, r];
|
|
547
|
+
case 22: return [3 /*break*/, 28];
|
|
541
548
|
case 23:
|
|
542
549
|
ref = (0, getEntityRef_js_1.getEntityRef)(entity, false);
|
|
550
|
+
result = undefined;
|
|
543
551
|
if (!ref) return [3 /*break*/, 25];
|
|
544
552
|
if (!ref.isNew())
|
|
545
553
|
throw 'Item is not new';
|
|
546
|
-
return [4 /*yield*/, ref.save()];
|
|
547
|
-
case 24:
|
|
554
|
+
return [4 /*yield*/, ref.save(options)];
|
|
555
|
+
case 24:
|
|
556
|
+
result = _g.sent();
|
|
557
|
+
return [3 /*break*/, 27];
|
|
548
558
|
case 25:
|
|
549
559
|
this.__cleanupPartialObject(entity);
|
|
550
|
-
return [4 /*yield*/, this.getEntityRef(this.create(entity)).save()];
|
|
551
|
-
case 26:
|
|
552
|
-
|
|
560
|
+
return [4 /*yield*/, this.getEntityRef(this.create(entity)).save(options)];
|
|
561
|
+
case 26:
|
|
562
|
+
result = _g.sent();
|
|
563
|
+
_g.label = 27;
|
|
564
|
+
case 27:
|
|
565
|
+
if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
|
|
566
|
+
return [2 /*return*/, undefined];
|
|
567
|
+
return [2 /*return*/, result];
|
|
568
|
+
case 28: return [2 /*return*/];
|
|
553
569
|
}
|
|
554
570
|
});
|
|
555
571
|
});
|
|
@@ -640,80 +656,94 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
640
656
|
};
|
|
641
657
|
RepositoryImplementation.prototype.updateMany = function (_a) {
|
|
642
658
|
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
643
|
-
var _c, _d,
|
|
644
|
-
var
|
|
659
|
+
var _c, _d, _e, updated, _f, _g, _h, item, e_10_1;
|
|
660
|
+
var _j, e_10, _k, _l;
|
|
645
661
|
var where = _b.where, set = _b.set;
|
|
646
|
-
return tslib_1.__generator(this, function (
|
|
647
|
-
switch (
|
|
662
|
+
return tslib_1.__generator(this, function (_m) {
|
|
663
|
+
switch (_m.label) {
|
|
648
664
|
case 0:
|
|
649
665
|
this.__cleanupPartialObject(set);
|
|
650
666
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'updateMany');
|
|
651
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
667
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 4];
|
|
652
668
|
_d = (_c = this._edp).updateMany;
|
|
653
|
-
return [
|
|
654
|
-
|
|
669
|
+
if (!(where === 'all')) return [3 /*break*/, 1];
|
|
670
|
+
_e = 'all';
|
|
671
|
+
return [3 /*break*/, 3];
|
|
672
|
+
case 1: return [4 /*yield*/, this._translateWhereToFilter(where)];
|
|
655
673
|
case 2:
|
|
674
|
+
_e = _m.sent();
|
|
675
|
+
_m.label = 3;
|
|
676
|
+
case 3: return [2 /*return*/, _d.apply(_c, [_e, this.__createDto(tslib_1.__assign({}, set))])];
|
|
677
|
+
case 4:
|
|
656
678
|
updated = 0;
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
_e = true, _f = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
661
|
-
_l.label = 4;
|
|
662
|
-
case 4: return [4 /*yield*/, _f.next()];
|
|
679
|
+
if (where === 'all')
|
|
680
|
+
where = undefined;
|
|
681
|
+
_m.label = 5;
|
|
663
682
|
case 5:
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
683
|
+
_m.trys.push([5, 11, 12, 17]);
|
|
684
|
+
_f = true, _g = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
685
|
+
_m.label = 6;
|
|
686
|
+
case 6: return [4 /*yield*/, _g.next()];
|
|
687
|
+
case 7:
|
|
688
|
+
if (!(_h = _m.sent(), _j = _h.done, !_j)) return [3 /*break*/, 10];
|
|
689
|
+
_l = _h.value;
|
|
690
|
+
_f = false;
|
|
691
|
+
item = _l;
|
|
668
692
|
(0, assign_js_1.assign)(item, set);
|
|
669
|
-
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).save()];
|
|
670
|
-
case
|
|
671
|
-
|
|
693
|
+
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).save({ select: 'none' })];
|
|
694
|
+
case 8:
|
|
695
|
+
_m.sent();
|
|
672
696
|
updated++;
|
|
673
|
-
|
|
674
|
-
case 7:
|
|
675
|
-
_e = true;
|
|
676
|
-
return [3 /*break*/, 4];
|
|
677
|
-
case 8: return [3 /*break*/, 15];
|
|
697
|
+
_m.label = 9;
|
|
678
698
|
case 9:
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
case 10:
|
|
683
|
-
_l.trys.push([10, , 13, 14]);
|
|
684
|
-
if (!(!_e && !_h && (_j = _f.return))) return [3 /*break*/, 12];
|
|
685
|
-
return [4 /*yield*/, _j.call(_f)];
|
|
699
|
+
_f = true;
|
|
700
|
+
return [3 /*break*/, 6];
|
|
701
|
+
case 10: return [3 /*break*/, 17];
|
|
686
702
|
case 11:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
703
|
+
e_10_1 = _m.sent();
|
|
704
|
+
e_10 = { error: e_10_1 };
|
|
705
|
+
return [3 /*break*/, 17];
|
|
706
|
+
case 12:
|
|
707
|
+
_m.trys.push([12, , 15, 16]);
|
|
708
|
+
if (!(!_f && !_j && (_k = _g.return))) return [3 /*break*/, 14];
|
|
709
|
+
return [4 /*yield*/, _k.call(_g)];
|
|
690
710
|
case 13:
|
|
711
|
+
_m.sent();
|
|
712
|
+
_m.label = 14;
|
|
713
|
+
case 14: return [3 /*break*/, 16];
|
|
714
|
+
case 15:
|
|
691
715
|
if (e_10) throw e_10.error;
|
|
692
716
|
return [7 /*endfinally*/];
|
|
693
|
-
case
|
|
694
|
-
case
|
|
717
|
+
case 16: return [7 /*endfinally*/];
|
|
718
|
+
case 17: return [2 /*return*/, updated];
|
|
695
719
|
}
|
|
696
720
|
});
|
|
697
721
|
});
|
|
698
722
|
};
|
|
699
|
-
RepositoryImplementation.prototype.update = function (id, entity) {
|
|
723
|
+
RepositoryImplementation.prototype.update = function (id, entity, options) {
|
|
700
724
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
725
|
+
function returnResult(result) {
|
|
726
|
+
if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
|
|
727
|
+
return undefined;
|
|
728
|
+
return result;
|
|
729
|
+
}
|
|
730
|
+
var ref_1, _a, ref_2, _b, ref, _c, r, key, f, _d;
|
|
731
|
+
return tslib_1.__generator(this, function (_e) {
|
|
732
|
+
switch (_e.label) {
|
|
704
733
|
case 0:
|
|
705
734
|
ref_1 = (0, getEntityRef_js_1.getEntityRef)(entity, false);
|
|
706
735
|
if (!ref_1) return [3 /*break*/, 2];
|
|
707
|
-
|
|
708
|
-
|
|
736
|
+
_a = returnResult;
|
|
737
|
+
return [4 /*yield*/, ref_1.save(options)];
|
|
738
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [(_e.sent())])];
|
|
709
739
|
case 2:
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
740
|
+
ref_2 = (0, getEntityRef_js_1.getEntityRef)(id, false);
|
|
741
|
+
if (!ref_2) return [3 /*break*/, 4];
|
|
742
|
+
(0, assign_js_1.assign)(id, entity);
|
|
743
|
+
_b = returnResult;
|
|
744
|
+
return [4 /*yield*/, ref_2.save(options)];
|
|
745
|
+
case 3: return [2 /*return*/, _b.apply(void 0, [_e.sent()])];
|
|
746
|
+
case 4:
|
|
717
747
|
this.__cleanupPartialObject(entity);
|
|
718
748
|
if (typeof id === 'object') {
|
|
719
749
|
ref = this._getRefForExistingRow(id, this.metadata.idMetadata.getId(id));
|
|
@@ -721,12 +751,13 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
721
751
|
}
|
|
722
752
|
else
|
|
723
753
|
ref = this._getRefForExistingRow(entity, id);
|
|
724
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
case
|
|
728
|
-
case
|
|
729
|
-
|
|
754
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 6];
|
|
755
|
+
_c = returnResult;
|
|
756
|
+
return [4 /*yield*/, ref.save(options, Object.keys(entity))];
|
|
757
|
+
case 5: return [2 /*return*/, _c.apply(void 0, [_e.sent()])];
|
|
758
|
+
case 6: return [4 /*yield*/, ref.reload()];
|
|
759
|
+
case 7:
|
|
760
|
+
r = _e.sent();
|
|
730
761
|
if (!r)
|
|
731
762
|
throw this._notFoundError(ref.id);
|
|
732
763
|
for (key in entity) {
|
|
@@ -740,10 +771,11 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
740
771
|
}
|
|
741
772
|
}
|
|
742
773
|
return [4 /*yield*/, this._fixTypes(r)];
|
|
743
|
-
case
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
774
|
+
case 8:
|
|
775
|
+
_e.sent();
|
|
776
|
+
_d = returnResult;
|
|
777
|
+
return [4 /*yield*/, ref.save(options)];
|
|
778
|
+
case 9: return [2 /*return*/, _d.apply(void 0, [_e.sent()])];
|
|
747
779
|
}
|
|
748
780
|
});
|
|
749
781
|
});
|
|
@@ -842,7 +874,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
842
874
|
}
|
|
843
875
|
return ref;
|
|
844
876
|
};
|
|
845
|
-
RepositoryImplementation.prototype.save = function (entity) {
|
|
877
|
+
RepositoryImplementation.prototype.save = function (entity, options) {
|
|
846
878
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
847
879
|
var ref, id;
|
|
848
880
|
var _this = this;
|
|
@@ -854,17 +886,17 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
854
886
|
case 1:
|
|
855
887
|
ref = (0, getEntityRef_js_1.getEntityRef)(entity, false);
|
|
856
888
|
if (!ref) return [3 /*break*/, 3];
|
|
857
|
-
return [4 /*yield*/, ref.save()];
|
|
889
|
+
return [4 /*yield*/, ref.save(options)];
|
|
858
890
|
case 2: return [2 /*return*/, _a.sent()];
|
|
859
891
|
case 3:
|
|
860
892
|
if (!(entity instanceof EntityBase)) return [3 /*break*/, 5];
|
|
861
|
-
return [4 /*yield*/, this.getEntityRef(entity).save()];
|
|
893
|
+
return [4 /*yield*/, this.getEntityRef(entity).save(options)];
|
|
862
894
|
case 4: return [2 /*return*/, _a.sent()];
|
|
863
895
|
case 5:
|
|
864
896
|
id = this.metadata.idMetadata.getId(entity);
|
|
865
897
|
if (id === undefined)
|
|
866
|
-
return [2 /*return*/, this.insert(entity)];
|
|
867
|
-
return [2 /*return*/, this.update(id, entity)];
|
|
898
|
+
return [2 /*return*/, this.insert(entity, options)];
|
|
899
|
+
return [2 /*return*/, this.update(id, entity, options)];
|
|
868
900
|
}
|
|
869
901
|
});
|
|
870
902
|
});
|
|
@@ -1419,56 +1451,64 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1419
1451
|
};
|
|
1420
1452
|
RepositoryImplementation.prototype.deleteMany = function (_a) {
|
|
1421
1453
|
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
1422
|
-
var _c, _d,
|
|
1423
|
-
var
|
|
1454
|
+
var _c, _d, _e, deleted, _f, _g, _h, item, e_22_1;
|
|
1455
|
+
var _j, e_22, _k, _l;
|
|
1424
1456
|
var where = _b.where;
|
|
1425
|
-
return tslib_1.__generator(this, function (
|
|
1426
|
-
switch (
|
|
1457
|
+
return tslib_1.__generator(this, function (_m) {
|
|
1458
|
+
switch (_m.label) {
|
|
1427
1459
|
case 0:
|
|
1428
1460
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'deleteMany');
|
|
1429
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
1461
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 4];
|
|
1430
1462
|
_d = (_c = this._edp).deleteMany;
|
|
1431
|
-
return [
|
|
1432
|
-
|
|
1463
|
+
if (!(where === 'all')) return [3 /*break*/, 1];
|
|
1464
|
+
_e = 'all';
|
|
1465
|
+
return [3 /*break*/, 3];
|
|
1466
|
+
case 1: return [4 /*yield*/, this._translateWhereToFilter(where)];
|
|
1433
1467
|
case 2:
|
|
1468
|
+
_e = _m.sent();
|
|
1469
|
+
_m.label = 3;
|
|
1470
|
+
case 3: return [2 /*return*/, _d.apply(_c, [_e])];
|
|
1471
|
+
case 4:
|
|
1434
1472
|
deleted = 0;
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
_e = true, _f = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
1439
|
-
_l.label = 4;
|
|
1440
|
-
case 4: return [4 /*yield*/, _f.next()];
|
|
1473
|
+
if (where === 'all')
|
|
1474
|
+
where = undefined;
|
|
1475
|
+
_m.label = 5;
|
|
1441
1476
|
case 5:
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1477
|
+
_m.trys.push([5, 11, 12, 17]);
|
|
1478
|
+
_f = true, _g = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
1479
|
+
_m.label = 6;
|
|
1480
|
+
case 6: return [4 /*yield*/, _g.next()];
|
|
1481
|
+
case 7:
|
|
1482
|
+
if (!(_h = _m.sent(), _j = _h.done, !_j)) return [3 /*break*/, 10];
|
|
1483
|
+
_l = _h.value;
|
|
1484
|
+
_f = false;
|
|
1485
|
+
item = _l;
|
|
1446
1486
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).delete()];
|
|
1447
|
-
case
|
|
1448
|
-
|
|
1487
|
+
case 8:
|
|
1488
|
+
_m.sent();
|
|
1449
1489
|
deleted++;
|
|
1450
|
-
|
|
1451
|
-
case 7:
|
|
1452
|
-
_e = true;
|
|
1453
|
-
return [3 /*break*/, 4];
|
|
1454
|
-
case 8: return [3 /*break*/, 15];
|
|
1490
|
+
_m.label = 9;
|
|
1455
1491
|
case 9:
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
case 10:
|
|
1460
|
-
_l.trys.push([10, , 13, 14]);
|
|
1461
|
-
if (!(!_e && !_h && (_j = _f.return))) return [3 /*break*/, 12];
|
|
1462
|
-
return [4 /*yield*/, _j.call(_f)];
|
|
1492
|
+
_f = true;
|
|
1493
|
+
return [3 /*break*/, 6];
|
|
1494
|
+
case 10: return [3 /*break*/, 17];
|
|
1463
1495
|
case 11:
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1496
|
+
e_22_1 = _m.sent();
|
|
1497
|
+
e_22 = { error: e_22_1 };
|
|
1498
|
+
return [3 /*break*/, 17];
|
|
1499
|
+
case 12:
|
|
1500
|
+
_m.trys.push([12, , 15, 16]);
|
|
1501
|
+
if (!(!_f && !_j && (_k = _g.return))) return [3 /*break*/, 14];
|
|
1502
|
+
return [4 /*yield*/, _k.call(_g)];
|
|
1467
1503
|
case 13:
|
|
1504
|
+
_m.sent();
|
|
1505
|
+
_m.label = 14;
|
|
1506
|
+
case 14: return [3 /*break*/, 16];
|
|
1507
|
+
case 15:
|
|
1468
1508
|
if (e_22) throw e_22.error;
|
|
1469
1509
|
return [7 /*endfinally*/];
|
|
1470
|
-
case
|
|
1471
|
-
case
|
|
1510
|
+
case 16: return [7 /*endfinally*/];
|
|
1511
|
+
case 17: return [2 /*return*/, deleted];
|
|
1472
1512
|
}
|
|
1473
1513
|
});
|
|
1474
1514
|
});
|
|
@@ -2275,6 +2315,24 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2275
2315
|
context_js_1.Remult.entityRefInit(_this, instance);
|
|
2276
2316
|
return _this;
|
|
2277
2317
|
}
|
|
2318
|
+
rowHelperImplementation.prototype._updateResultsFromServerAction = function (rowInfo) {
|
|
2319
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2320
|
+
return tslib_1.__generator(this, function (_a) {
|
|
2321
|
+
switch (_a.label) {
|
|
2322
|
+
case 0: return [4 /*yield*/, this._updateEntityBasedOnApi(rowInfo.data, true)];
|
|
2323
|
+
case 1:
|
|
2324
|
+
_a.sent();
|
|
2325
|
+
if (this._isNew != rowInfo.isNewRow) {
|
|
2326
|
+
this._isNew = rowInfo.isNewRow;
|
|
2327
|
+
this.originalId = rowInfo.id;
|
|
2328
|
+
}
|
|
2329
|
+
if (!rowInfo.wasChanged)
|
|
2330
|
+
this.originalValues = this.copyDataToObject();
|
|
2331
|
+
return [2 /*return*/];
|
|
2332
|
+
}
|
|
2333
|
+
});
|
|
2334
|
+
});
|
|
2335
|
+
};
|
|
2278
2336
|
rowHelperImplementation.prototype.clone = function () {
|
|
2279
2337
|
var data = this.toApiJson(true, true);
|
|
2280
2338
|
return this.repo.fromJson(data, this.isNew());
|
|
@@ -2403,7 +2461,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2403
2461
|
enumerable: false,
|
|
2404
2462
|
configurable: true
|
|
2405
2463
|
});
|
|
2406
|
-
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2464
|
+
rowHelperImplementation.prototype.save = function (options, onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2407
2465
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2408
2466
|
var doNotSave_1, e, _a, _b, col, e_36_1, d, ignoreKeys, _c, _d, field, f, updatedRow, isNew, _e, _f, changesOnly, wasChanged, key, element, _g, _h, _j, _k, listener, e_37_1, err_1;
|
|
2409
2467
|
var e_36, _l, e_38, _m, _o, _p, e_37, _q;
|
|
@@ -2411,7 +2469,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2411
2469
|
return tslib_1.__generator(this, function (_t) {
|
|
2412
2470
|
switch (_t.label) {
|
|
2413
2471
|
case 0:
|
|
2414
|
-
_t.trys.push([0, ,
|
|
2472
|
+
_t.trys.push([0, , 41, 42]);
|
|
2415
2473
|
if (this._saving)
|
|
2416
2474
|
throw new Error('cannot save while entity is already saving');
|
|
2417
2475
|
this._saving = true;
|
|
@@ -2492,10 +2550,10 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2492
2550
|
isNew = this.isNew();
|
|
2493
2551
|
_t.label = 13;
|
|
2494
2552
|
case 13:
|
|
2495
|
-
_t.trys.push([13,
|
|
2553
|
+
_t.trys.push([13, 38, , 40]);
|
|
2496
2554
|
(_r = this._subscribers) === null || _r === void 0 ? void 0 : _r.reportChanged();
|
|
2497
2555
|
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2498
|
-
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
2556
|
+
if (!(doNotSave_1 && (options === null || options === void 0 ? void 0 : options.select) !== 'none')) return [3 /*break*/, 16];
|
|
2499
2557
|
_f = (_e = this.edp).find;
|
|
2500
2558
|
_o = {};
|
|
2501
2559
|
return [4 /*yield*/, this.getIdFilter()];
|
|
@@ -2504,11 +2562,11 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2504
2562
|
case 15:
|
|
2505
2563
|
updatedRow = (updatedRow = _t.sent())[0];
|
|
2506
2564
|
return [3 /*break*/, 18];
|
|
2507
|
-
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2565
|
+
case 16: return [4 /*yield*/, this.edp.insert(d, options)];
|
|
2508
2566
|
case 17:
|
|
2509
2567
|
updatedRow = _t.sent();
|
|
2510
2568
|
_t.label = 18;
|
|
2511
|
-
case 18: return [3 /*break*/,
|
|
2569
|
+
case 18: return [3 /*break*/, 25];
|
|
2512
2570
|
case 19:
|
|
2513
2571
|
changesOnly = {};
|
|
2514
2572
|
wasChanged = false;
|
|
@@ -2525,79 +2583,81 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2525
2583
|
}
|
|
2526
2584
|
if (!wasChanged)
|
|
2527
2585
|
return [2 /*return*/, this.instance];
|
|
2528
|
-
if (!doNotSave_1) return [3 /*break*/,
|
|
2586
|
+
if (!doNotSave_1) return [3 /*break*/, 23];
|
|
2587
|
+
if (!((options === null || options === void 0 ? void 0 : options.select) !== 'none')) return [3 /*break*/, 22];
|
|
2529
2588
|
_h = (_g = this.edp).find;
|
|
2530
2589
|
_p = {};
|
|
2531
2590
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2532
2591
|
case 20: return [4 /*yield*/, _h.apply(_g, [(_p.where = _t.sent(), _p)])];
|
|
2533
2592
|
case 21:
|
|
2534
2593
|
updatedRow = (_t.sent())[0];
|
|
2535
|
-
|
|
2536
|
-
case 22:
|
|
2594
|
+
_t.label = 22;
|
|
2595
|
+
case 22: return [3 /*break*/, 25];
|
|
2596
|
+
case 23:
|
|
2537
2597
|
if (this.id === undefined)
|
|
2538
2598
|
throw new Error('Invalid operation, id is undefined');
|
|
2539
|
-
return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2540
|
-
case 23:
|
|
2541
|
-
updatedRow = _t.sent();
|
|
2542
|
-
_t.label = 24;
|
|
2599
|
+
return [4 /*yield*/, this.edp.update(this.id, changesOnly, options)];
|
|
2543
2600
|
case 24:
|
|
2544
|
-
|
|
2545
|
-
|
|
2601
|
+
updatedRow = _t.sent();
|
|
2602
|
+
_t.label = 25;
|
|
2546
2603
|
case 25:
|
|
2547
|
-
|
|
2548
|
-
|
|
2604
|
+
if (!updatedRow) return [3 /*break*/, 27];
|
|
2605
|
+
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2549
2606
|
case 26:
|
|
2607
|
+
_t.sent();
|
|
2608
|
+
_t.label = 27;
|
|
2609
|
+
case 27:
|
|
2550
2610
|
e.id = this.getId();
|
|
2551
|
-
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/,
|
|
2552
|
-
if (!this.info.entityInfo.saved) return [3 /*break*/,
|
|
2611
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 37];
|
|
2612
|
+
if (!this.info.entityInfo.saved) return [3 /*break*/, 29];
|
|
2553
2613
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2554
|
-
case 27:
|
|
2555
|
-
_t.sent();
|
|
2556
|
-
_t.label = 28;
|
|
2557
2614
|
case 28:
|
|
2558
|
-
|
|
2615
|
+
_t.sent();
|
|
2559
2616
|
_t.label = 29;
|
|
2560
2617
|
case 29:
|
|
2561
|
-
|
|
2562
|
-
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2618
|
+
if (!this.repo.listeners) return [3 /*break*/, 37];
|
|
2563
2619
|
_t.label = 30;
|
|
2564
2620
|
case 30:
|
|
2565
|
-
|
|
2621
|
+
_t.trys.push([30, 35, 36, 37]);
|
|
2622
|
+
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2623
|
+
_t.label = 31;
|
|
2624
|
+
case 31:
|
|
2625
|
+
if (!!_k.done) return [3 /*break*/, 34];
|
|
2566
2626
|
listener = _k.value;
|
|
2567
2627
|
return [4 /*yield*/, ((_s = listener.saved) === null || _s === void 0 ? void 0 : _s.call(listener, this.instance, isNew))];
|
|
2568
|
-
case 31:
|
|
2569
|
-
_t.sent();
|
|
2570
|
-
_t.label = 32;
|
|
2571
2628
|
case 32:
|
|
2629
|
+
_t.sent();
|
|
2630
|
+
_t.label = 33;
|
|
2631
|
+
case 33:
|
|
2572
2632
|
_k = _j.next();
|
|
2573
|
-
return [3 /*break*/,
|
|
2574
|
-
case
|
|
2575
|
-
case
|
|
2633
|
+
return [3 /*break*/, 31];
|
|
2634
|
+
case 34: return [3 /*break*/, 37];
|
|
2635
|
+
case 35:
|
|
2576
2636
|
e_37_1 = _t.sent();
|
|
2577
2637
|
e_37 = { error: e_37_1 };
|
|
2578
|
-
return [3 /*break*/,
|
|
2579
|
-
case
|
|
2638
|
+
return [3 /*break*/, 37];
|
|
2639
|
+
case 36:
|
|
2580
2640
|
try {
|
|
2581
2641
|
if (_k && !_k.done && (_q = _j.return)) _q.call(_j);
|
|
2582
2642
|
}
|
|
2583
2643
|
finally { if (e_37) throw e_37.error; }
|
|
2584
2644
|
return [7 /*endfinally*/];
|
|
2585
|
-
case
|
|
2645
|
+
case 37:
|
|
2586
2646
|
this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
|
|
2587
2647
|
this.saveOriginalData();
|
|
2588
2648
|
this._isNew = false;
|
|
2589
2649
|
return [2 /*return*/, this.instance];
|
|
2590
|
-
case
|
|
2650
|
+
case 38:
|
|
2591
2651
|
err_1 = _t.sent();
|
|
2592
2652
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2593
|
-
case
|
|
2594
|
-
case
|
|
2595
|
-
case
|
|
2653
|
+
case 39: throw _t.sent();
|
|
2654
|
+
case 40: return [3 /*break*/, 42];
|
|
2655
|
+
case 41:
|
|
2596
2656
|
this.isLoading = false;
|
|
2597
2657
|
this._reportChangedToEntityAndFields();
|
|
2598
2658
|
this._saving = false;
|
|
2599
2659
|
return [7 /*endfinally*/];
|
|
2600
|
-
case
|
|
2660
|
+
case 42: return [2 /*return*/];
|
|
2601
2661
|
}
|
|
2602
2662
|
});
|
|
2603
2663
|
});
|
|
@@ -3969,8 +4029,8 @@ var EntityBase = /** @class */ (function () {
|
|
|
3969
4029
|
enumerable: false,
|
|
3970
4030
|
configurable: true
|
|
3971
4031
|
});
|
|
3972
|
-
EntityBase.prototype.save = function () {
|
|
3973
|
-
return (0, getEntityRef_js_1.getEntityRef)(this).save();
|
|
4032
|
+
EntityBase.prototype.save = function (options) {
|
|
4033
|
+
return (0, getEntityRef_js_1.getEntityRef)(this).save(options);
|
|
3974
4034
|
};
|
|
3975
4035
|
EntityBase.prototype.assign = function (values) {
|
|
3976
4036
|
(0, assign_js_1.assign)(this, values);
|