remult 3.3.0-next.1 → 3.3.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/esm/graphql.js +1 -1
- package/esm/remult-knex/index.js +8 -2
- 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 +28 -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/remult-proxy.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.js +41 -17
- 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 +16 -8
- 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 +48 -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/remult-proxy.js +4 -4
- package/src/remult3/RepositoryImplementation.d.ts +8 -7
- package/src/remult3/RepositoryImplementation.js +225 -169
- package/src/remult3/remult3.d.ts +10 -7
- 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,92 @@ 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
|
-
case 3:
|
|
659
|
-
_l.trys.push([3, 9, 10, 15]);
|
|
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
|
+
_m.label = 5;
|
|
663
680
|
case 5:
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
681
|
+
_m.trys.push([5, 11, 12, 17]);
|
|
682
|
+
_f = true, _g = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
683
|
+
_m.label = 6;
|
|
684
|
+
case 6: return [4 /*yield*/, _g.next()];
|
|
685
|
+
case 7:
|
|
686
|
+
if (!(_h = _m.sent(), _j = _h.done, !_j)) return [3 /*break*/, 10];
|
|
687
|
+
_l = _h.value;
|
|
688
|
+
_f = false;
|
|
689
|
+
item = _l;
|
|
668
690
|
(0, assign_js_1.assign)(item, set);
|
|
669
691
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).save()];
|
|
670
|
-
case
|
|
671
|
-
|
|
692
|
+
case 8:
|
|
693
|
+
_m.sent();
|
|
672
694
|
updated++;
|
|
673
|
-
|
|
674
|
-
case 7:
|
|
675
|
-
_e = true;
|
|
676
|
-
return [3 /*break*/, 4];
|
|
677
|
-
case 8: return [3 /*break*/, 15];
|
|
695
|
+
_m.label = 9;
|
|
678
696
|
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)];
|
|
697
|
+
_f = true;
|
|
698
|
+
return [3 /*break*/, 6];
|
|
699
|
+
case 10: return [3 /*break*/, 17];
|
|
686
700
|
case 11:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
701
|
+
e_10_1 = _m.sent();
|
|
702
|
+
e_10 = { error: e_10_1 };
|
|
703
|
+
return [3 /*break*/, 17];
|
|
704
|
+
case 12:
|
|
705
|
+
_m.trys.push([12, , 15, 16]);
|
|
706
|
+
if (!(!_f && !_j && (_k = _g.return))) return [3 /*break*/, 14];
|
|
707
|
+
return [4 /*yield*/, _k.call(_g)];
|
|
690
708
|
case 13:
|
|
709
|
+
_m.sent();
|
|
710
|
+
_m.label = 14;
|
|
711
|
+
case 14: return [3 /*break*/, 16];
|
|
712
|
+
case 15:
|
|
691
713
|
if (e_10) throw e_10.error;
|
|
692
714
|
return [7 /*endfinally*/];
|
|
693
|
-
case
|
|
694
|
-
case
|
|
715
|
+
case 16: return [7 /*endfinally*/];
|
|
716
|
+
case 17: return [2 /*return*/, updated];
|
|
695
717
|
}
|
|
696
718
|
});
|
|
697
719
|
});
|
|
698
720
|
};
|
|
699
|
-
RepositoryImplementation.prototype.update = function (id, entity) {
|
|
721
|
+
RepositoryImplementation.prototype.update = function (id, entity, options) {
|
|
700
722
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
723
|
+
function returnResult(result) {
|
|
724
|
+
if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
|
|
725
|
+
return undefined;
|
|
726
|
+
return result;
|
|
727
|
+
}
|
|
728
|
+
var ref_1, _a, ref_2, _b, ref, _c, r, key, f, _d;
|
|
729
|
+
return tslib_1.__generator(this, function (_e) {
|
|
730
|
+
switch (_e.label) {
|
|
704
731
|
case 0:
|
|
705
732
|
ref_1 = (0, getEntityRef_js_1.getEntityRef)(entity, false);
|
|
706
733
|
if (!ref_1) return [3 /*break*/, 2];
|
|
707
|
-
|
|
708
|
-
|
|
734
|
+
_a = returnResult;
|
|
735
|
+
return [4 /*yield*/, ref_1.save(options)];
|
|
736
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [(_e.sent())])];
|
|
709
737
|
case 2:
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
738
|
+
ref_2 = (0, getEntityRef_js_1.getEntityRef)(id, false);
|
|
739
|
+
if (!ref_2) return [3 /*break*/, 4];
|
|
740
|
+
(0, assign_js_1.assign)(id, entity);
|
|
741
|
+
_b = returnResult;
|
|
742
|
+
return [4 /*yield*/, ref_2.save(options)];
|
|
743
|
+
case 3: return [2 /*return*/, _b.apply(void 0, [_e.sent()])];
|
|
744
|
+
case 4:
|
|
717
745
|
this.__cleanupPartialObject(entity);
|
|
718
746
|
if (typeof id === 'object') {
|
|
719
747
|
ref = this._getRefForExistingRow(id, this.metadata.idMetadata.getId(id));
|
|
@@ -721,12 +749,13 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
721
749
|
}
|
|
722
750
|
else
|
|
723
751
|
ref = this._getRefForExistingRow(entity, id);
|
|
724
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
case
|
|
728
|
-
case
|
|
729
|
-
|
|
752
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 6];
|
|
753
|
+
_c = returnResult;
|
|
754
|
+
return [4 /*yield*/, ref.save(options, Object.keys(entity))];
|
|
755
|
+
case 5: return [2 /*return*/, _c.apply(void 0, [_e.sent()])];
|
|
756
|
+
case 6: return [4 /*yield*/, ref.reload()];
|
|
757
|
+
case 7:
|
|
758
|
+
r = _e.sent();
|
|
730
759
|
if (!r)
|
|
731
760
|
throw this._notFoundError(ref.id);
|
|
732
761
|
for (key in entity) {
|
|
@@ -740,10 +769,11 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
740
769
|
}
|
|
741
770
|
}
|
|
742
771
|
return [4 /*yield*/, this._fixTypes(r)];
|
|
743
|
-
case
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
772
|
+
case 8:
|
|
773
|
+
_e.sent();
|
|
774
|
+
_d = returnResult;
|
|
775
|
+
return [4 /*yield*/, ref.save(options)];
|
|
776
|
+
case 9: return [2 /*return*/, _d.apply(void 0, [_e.sent()])];
|
|
747
777
|
}
|
|
748
778
|
});
|
|
749
779
|
});
|
|
@@ -1419,56 +1449,62 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1419
1449
|
};
|
|
1420
1450
|
RepositoryImplementation.prototype.deleteMany = function (_a) {
|
|
1421
1451
|
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
1422
|
-
var _c, _d,
|
|
1423
|
-
var
|
|
1452
|
+
var _c, _d, _e, deleted, _f, _g, _h, item, e_22_1;
|
|
1453
|
+
var _j, e_22, _k, _l;
|
|
1424
1454
|
var where = _b.where;
|
|
1425
|
-
return tslib_1.__generator(this, function (
|
|
1426
|
-
switch (
|
|
1455
|
+
return tslib_1.__generator(this, function (_m) {
|
|
1456
|
+
switch (_m.label) {
|
|
1427
1457
|
case 0:
|
|
1428
1458
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'deleteMany');
|
|
1429
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
1459
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 4];
|
|
1430
1460
|
_d = (_c = this._edp).deleteMany;
|
|
1431
|
-
return [
|
|
1432
|
-
|
|
1461
|
+
if (!(where === 'all')) return [3 /*break*/, 1];
|
|
1462
|
+
_e = 'all';
|
|
1463
|
+
return [3 /*break*/, 3];
|
|
1464
|
+
case 1: return [4 /*yield*/, this._translateWhereToFilter(where)];
|
|
1433
1465
|
case 2:
|
|
1466
|
+
_e = _m.sent();
|
|
1467
|
+
_m.label = 3;
|
|
1468
|
+
case 3: return [2 /*return*/, _d.apply(_c, [_e])];
|
|
1469
|
+
case 4:
|
|
1434
1470
|
deleted = 0;
|
|
1435
|
-
|
|
1436
|
-
case 3:
|
|
1437
|
-
_l.trys.push([3, 9, 10, 15]);
|
|
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()];
|
|
1471
|
+
_m.label = 5;
|
|
1441
1472
|
case 5:
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1473
|
+
_m.trys.push([5, 11, 12, 17]);
|
|
1474
|
+
_f = true, _g = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
1475
|
+
_m.label = 6;
|
|
1476
|
+
case 6: return [4 /*yield*/, _g.next()];
|
|
1477
|
+
case 7:
|
|
1478
|
+
if (!(_h = _m.sent(), _j = _h.done, !_j)) return [3 /*break*/, 10];
|
|
1479
|
+
_l = _h.value;
|
|
1480
|
+
_f = false;
|
|
1481
|
+
item = _l;
|
|
1446
1482
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).delete()];
|
|
1447
|
-
case
|
|
1448
|
-
|
|
1483
|
+
case 8:
|
|
1484
|
+
_m.sent();
|
|
1449
1485
|
deleted++;
|
|
1450
|
-
|
|
1451
|
-
case 7:
|
|
1452
|
-
_e = true;
|
|
1453
|
-
return [3 /*break*/, 4];
|
|
1454
|
-
case 8: return [3 /*break*/, 15];
|
|
1486
|
+
_m.label = 9;
|
|
1455
1487
|
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)];
|
|
1488
|
+
_f = true;
|
|
1489
|
+
return [3 /*break*/, 6];
|
|
1490
|
+
case 10: return [3 /*break*/, 17];
|
|
1463
1491
|
case 11:
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1492
|
+
e_22_1 = _m.sent();
|
|
1493
|
+
e_22 = { error: e_22_1 };
|
|
1494
|
+
return [3 /*break*/, 17];
|
|
1495
|
+
case 12:
|
|
1496
|
+
_m.trys.push([12, , 15, 16]);
|
|
1497
|
+
if (!(!_f && !_j && (_k = _g.return))) return [3 /*break*/, 14];
|
|
1498
|
+
return [4 /*yield*/, _k.call(_g)];
|
|
1467
1499
|
case 13:
|
|
1500
|
+
_m.sent();
|
|
1501
|
+
_m.label = 14;
|
|
1502
|
+
case 14: return [3 /*break*/, 16];
|
|
1503
|
+
case 15:
|
|
1468
1504
|
if (e_22) throw e_22.error;
|
|
1469
1505
|
return [7 /*endfinally*/];
|
|
1470
|
-
case
|
|
1471
|
-
case
|
|
1506
|
+
case 16: return [7 /*endfinally*/];
|
|
1507
|
+
case 17: return [2 /*return*/, deleted];
|
|
1472
1508
|
}
|
|
1473
1509
|
});
|
|
1474
1510
|
});
|
|
@@ -2275,6 +2311,24 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2275
2311
|
context_js_1.Remult.entityRefInit(_this, instance);
|
|
2276
2312
|
return _this;
|
|
2277
2313
|
}
|
|
2314
|
+
rowHelperImplementation.prototype._updateResultsFromServerAction = function (rowInfo) {
|
|
2315
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2316
|
+
return tslib_1.__generator(this, function (_a) {
|
|
2317
|
+
switch (_a.label) {
|
|
2318
|
+
case 0: return [4 /*yield*/, this._updateEntityBasedOnApi(rowInfo.data, true)];
|
|
2319
|
+
case 1:
|
|
2320
|
+
_a.sent();
|
|
2321
|
+
if (this._isNew != rowInfo.isNewRow) {
|
|
2322
|
+
this._isNew = rowInfo.isNewRow;
|
|
2323
|
+
this.originalId = rowInfo.id;
|
|
2324
|
+
}
|
|
2325
|
+
if (!rowInfo.wasChanged)
|
|
2326
|
+
this.originalValues = this.copyDataToObject();
|
|
2327
|
+
return [2 /*return*/];
|
|
2328
|
+
}
|
|
2329
|
+
});
|
|
2330
|
+
});
|
|
2331
|
+
};
|
|
2278
2332
|
rowHelperImplementation.prototype.clone = function () {
|
|
2279
2333
|
var data = this.toApiJson(true, true);
|
|
2280
2334
|
return this.repo.fromJson(data, this.isNew());
|
|
@@ -2403,7 +2457,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2403
2457
|
enumerable: false,
|
|
2404
2458
|
configurable: true
|
|
2405
2459
|
});
|
|
2406
|
-
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2460
|
+
rowHelperImplementation.prototype.save = function (options, onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2407
2461
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2408
2462
|
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
2463
|
var e_36, _l, e_38, _m, _o, _p, e_37, _q;
|
|
@@ -2411,7 +2465,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2411
2465
|
return tslib_1.__generator(this, function (_t) {
|
|
2412
2466
|
switch (_t.label) {
|
|
2413
2467
|
case 0:
|
|
2414
|
-
_t.trys.push([0, ,
|
|
2468
|
+
_t.trys.push([0, , 41, 42]);
|
|
2415
2469
|
if (this._saving)
|
|
2416
2470
|
throw new Error('cannot save while entity is already saving');
|
|
2417
2471
|
this._saving = true;
|
|
@@ -2492,10 +2546,10 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2492
2546
|
isNew = this.isNew();
|
|
2493
2547
|
_t.label = 13;
|
|
2494
2548
|
case 13:
|
|
2495
|
-
_t.trys.push([13,
|
|
2549
|
+
_t.trys.push([13, 38, , 40]);
|
|
2496
2550
|
(_r = this._subscribers) === null || _r === void 0 ? void 0 : _r.reportChanged();
|
|
2497
2551
|
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2498
|
-
if (!doNotSave_1) return [3 /*break*/, 16];
|
|
2552
|
+
if (!(doNotSave_1 && (options === null || options === void 0 ? void 0 : options.select) !== 'none')) return [3 /*break*/, 16];
|
|
2499
2553
|
_f = (_e = this.edp).find;
|
|
2500
2554
|
_o = {};
|
|
2501
2555
|
return [4 /*yield*/, this.getIdFilter()];
|
|
@@ -2504,11 +2558,11 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2504
2558
|
case 15:
|
|
2505
2559
|
updatedRow = (updatedRow = _t.sent())[0];
|
|
2506
2560
|
return [3 /*break*/, 18];
|
|
2507
|
-
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2561
|
+
case 16: return [4 /*yield*/, this.edp.insert(d, options)];
|
|
2508
2562
|
case 17:
|
|
2509
2563
|
updatedRow = _t.sent();
|
|
2510
2564
|
_t.label = 18;
|
|
2511
|
-
case 18: return [3 /*break*/,
|
|
2565
|
+
case 18: return [3 /*break*/, 25];
|
|
2512
2566
|
case 19:
|
|
2513
2567
|
changesOnly = {};
|
|
2514
2568
|
wasChanged = false;
|
|
@@ -2525,79 +2579,81 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2525
2579
|
}
|
|
2526
2580
|
if (!wasChanged)
|
|
2527
2581
|
return [2 /*return*/, this.instance];
|
|
2528
|
-
if (!doNotSave_1) return [3 /*break*/,
|
|
2582
|
+
if (!doNotSave_1) return [3 /*break*/, 23];
|
|
2583
|
+
if (!((options === null || options === void 0 ? void 0 : options.select) !== 'none')) return [3 /*break*/, 22];
|
|
2529
2584
|
_h = (_g = this.edp).find;
|
|
2530
2585
|
_p = {};
|
|
2531
2586
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2532
2587
|
case 20: return [4 /*yield*/, _h.apply(_g, [(_p.where = _t.sent(), _p)])];
|
|
2533
2588
|
case 21:
|
|
2534
2589
|
updatedRow = (_t.sent())[0];
|
|
2535
|
-
|
|
2536
|
-
case 22:
|
|
2590
|
+
_t.label = 22;
|
|
2591
|
+
case 22: return [3 /*break*/, 25];
|
|
2592
|
+
case 23:
|
|
2537
2593
|
if (this.id === undefined)
|
|
2538
2594
|
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;
|
|
2595
|
+
return [4 /*yield*/, this.edp.update(this.id, changesOnly, options)];
|
|
2543
2596
|
case 24:
|
|
2544
|
-
|
|
2545
|
-
|
|
2597
|
+
updatedRow = _t.sent();
|
|
2598
|
+
_t.label = 25;
|
|
2546
2599
|
case 25:
|
|
2547
|
-
|
|
2548
|
-
|
|
2600
|
+
if (!updatedRow) return [3 /*break*/, 27];
|
|
2601
|
+
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2549
2602
|
case 26:
|
|
2603
|
+
_t.sent();
|
|
2604
|
+
_t.label = 27;
|
|
2605
|
+
case 27:
|
|
2550
2606
|
e.id = this.getId();
|
|
2551
|
-
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/,
|
|
2552
|
-
if (!this.info.entityInfo.saved) return [3 /*break*/,
|
|
2607
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 37];
|
|
2608
|
+
if (!this.info.entityInfo.saved) return [3 /*break*/, 29];
|
|
2553
2609
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2554
|
-
case 27:
|
|
2555
|
-
_t.sent();
|
|
2556
|
-
_t.label = 28;
|
|
2557
2610
|
case 28:
|
|
2558
|
-
|
|
2611
|
+
_t.sent();
|
|
2559
2612
|
_t.label = 29;
|
|
2560
2613
|
case 29:
|
|
2561
|
-
|
|
2562
|
-
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2614
|
+
if (!this.repo.listeners) return [3 /*break*/, 37];
|
|
2563
2615
|
_t.label = 30;
|
|
2564
2616
|
case 30:
|
|
2565
|
-
|
|
2617
|
+
_t.trys.push([30, 35, 36, 37]);
|
|
2618
|
+
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2619
|
+
_t.label = 31;
|
|
2620
|
+
case 31:
|
|
2621
|
+
if (!!_k.done) return [3 /*break*/, 34];
|
|
2566
2622
|
listener = _k.value;
|
|
2567
2623
|
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
2624
|
case 32:
|
|
2625
|
+
_t.sent();
|
|
2626
|
+
_t.label = 33;
|
|
2627
|
+
case 33:
|
|
2572
2628
|
_k = _j.next();
|
|
2573
|
-
return [3 /*break*/,
|
|
2574
|
-
case
|
|
2575
|
-
case
|
|
2629
|
+
return [3 /*break*/, 31];
|
|
2630
|
+
case 34: return [3 /*break*/, 37];
|
|
2631
|
+
case 35:
|
|
2576
2632
|
e_37_1 = _t.sent();
|
|
2577
2633
|
e_37 = { error: e_37_1 };
|
|
2578
|
-
return [3 /*break*/,
|
|
2579
|
-
case
|
|
2634
|
+
return [3 /*break*/, 37];
|
|
2635
|
+
case 36:
|
|
2580
2636
|
try {
|
|
2581
2637
|
if (_k && !_k.done && (_q = _j.return)) _q.call(_j);
|
|
2582
2638
|
}
|
|
2583
2639
|
finally { if (e_37) throw e_37.error; }
|
|
2584
2640
|
return [7 /*endfinally*/];
|
|
2585
|
-
case
|
|
2641
|
+
case 37:
|
|
2586
2642
|
this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
|
|
2587
2643
|
this.saveOriginalData();
|
|
2588
2644
|
this._isNew = false;
|
|
2589
2645
|
return [2 /*return*/, this.instance];
|
|
2590
|
-
case
|
|
2646
|
+
case 38:
|
|
2591
2647
|
err_1 = _t.sent();
|
|
2592
2648
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2593
|
-
case
|
|
2594
|
-
case
|
|
2595
|
-
case
|
|
2649
|
+
case 39: throw _t.sent();
|
|
2650
|
+
case 40: return [3 /*break*/, 42];
|
|
2651
|
+
case 41:
|
|
2596
2652
|
this.isLoading = false;
|
|
2597
2653
|
this._reportChangedToEntityAndFields();
|
|
2598
2654
|
this._saving = false;
|
|
2599
2655
|
return [7 /*endfinally*/];
|
|
2600
|
-
case
|
|
2656
|
+
case 42: return [2 /*return*/];
|
|
2601
2657
|
}
|
|
2602
2658
|
});
|
|
2603
2659
|
});
|