remult 3.2.3 → 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/remult-api-server.js +1 -1
- package/esm/src/data-api.js +30 -19
- package/esm/src/data-providers/rest-data-provider.js +50 -35
- package/esm/src/data-providers/sql-database.js +35 -13
- package/esm/src/filter/fieldDbName.js +4 -1
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +5 -2
- package/esm/src/remult-proxy.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.js +34 -17
- package/esm/src/remult3/remult3.js +8 -0
- package/esm/src/valueConverters.js +10 -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/remult-api-server.js +1 -0
- package/src/column-interfaces.d.ts +3 -1
- package/src/data-api.d.ts +4 -4
- package/src/data-api.js +50 -30
- package/src/data-interfaces.d.ts +7 -6
- package/src/data-providers/rest-data-provider.d.ts +4 -4
- package/src/data-providers/rest-data-provider.js +50 -35
- package/src/data-providers/sql-database.js +158 -90
- package/src/filter/fieldDbName.d.ts +2 -1
- package/src/filter/fieldDbName.js +5 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -0
- package/src/filter/filter-consumer-bridge-to-sql-request.js +7 -2
- package/src/remult-proxy.js +4 -4
- package/src/remult3/RepositoryImplementation.d.ts +6 -6
- package/src/remult3/RepositoryImplementation.js +209 -169
- package/src/remult3/remult3.d.ts +11 -7
- package/src/remult3/remult3.js +8 -0
- package/src/valueConverters.d.ts +3 -1
- package/src/valueConverters.js +10 -6
|
@@ -5,7 +5,7 @@ import { Remult } from '../context.js';
|
|
|
5
5
|
import type { EntityOptions } from '../entity.js';
|
|
6
6
|
import { Filter } from '../filter/filter-interfaces.js';
|
|
7
7
|
import { type GroupByOptions, type GroupByResult, type ControllerRef, type ControllerRefForControllerBase, type EntityFilter, type EntityMetadata, type EntityOrderBy, type EntityRef, type EntityRefForEntityBase, type FieldRef, type FieldsMetadata, type FieldsRef, type FieldsRefForEntityBase, type FindFirstOptions, type FindFirstOptionsBase, type FindOptions, type IdMetadata, type LiveQuery, type LoadOptions, type MembersOnly, type NumericKeys, type Repository, type RepositoryRelations, type idType } from './remult3.js';
|
|
8
|
-
import type { QueryOptions, RefSubscriber, UpsertOptions } from './remult3.js';
|
|
8
|
+
import type { InsertOrUpdateOptions, QueryOptions, RefSubscriber, UpsertOptions } from './remult3.js';
|
|
9
9
|
import type { entityEventListener, packedRowInfo } from '../__EntityValueProvider.js';
|
|
10
10
|
import { type DataProvider, type EntityDataProvider, type EntityDataProviderGroupByOptions, type EntityDataProviderFindOptions, type ErrorInfo, EntityError } from '../data-interfaces.js';
|
|
11
11
|
import type { Unsubscribe } from '../live-query/SubscriptionChannel.js';
|
|
@@ -50,8 +50,8 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
50
50
|
delete(id: idType<entityType>): Promise<void>;
|
|
51
51
|
delete(item: Partial<MembersOnly<entityType>>): Promise<void>;
|
|
52
52
|
__cleanupPartialObject(item: Partial<MembersOnly<entityType>>): void;
|
|
53
|
-
insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
|
|
54
|
-
insert(item: Partial<MembersOnly<entityType
|
|
53
|
+
insert(item: Partial<MembersOnly<entityType>>[], options?: InsertOrUpdateOptions): Promise<entityType[]>;
|
|
54
|
+
insert(item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
|
|
55
55
|
get fields(): FieldsMetadata<entityType>;
|
|
56
56
|
validate(entity: Partial<MembersOnly<entityType>>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
|
|
57
57
|
private __createDto;
|
|
@@ -59,8 +59,8 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
59
59
|
where: EntityFilter<entityType>;
|
|
60
60
|
set: Partial<MembersOnly<entityType>>;
|
|
61
61
|
}): Promise<number>;
|
|
62
|
-
update(id: idType<entityType>, item: Partial<MembersOnly<entityType
|
|
63
|
-
update(originalItem: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType
|
|
62
|
+
update(id: idType<entityType>, item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
|
|
63
|
+
update(originalItem: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
|
|
64
64
|
upsert(options: UpsertOptions<entityType>[]): Promise<entityType[]>;
|
|
65
65
|
upsert(options: UpsertOptions<entityType>): Promise<entityType>;
|
|
66
66
|
private _getRefForExistingRow;
|
|
@@ -154,7 +154,7 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
|
|
|
154
154
|
private _columns?;
|
|
155
155
|
get fields(): FieldsRef<T>;
|
|
156
156
|
private _saving;
|
|
157
|
-
save(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject?: string[]): Promise<T>;
|
|
157
|
+
save(options: InsertOrUpdateOptions | undefined, onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject?: string[]): Promise<T>;
|
|
158
158
|
processInsertResponseDto(updatedRow: any): Promise<T>;
|
|
159
159
|
buildDtoForInsert(): Promise<any>;
|
|
160
160
|
private buildLifeCycleEvent;
|
|
@@ -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
|
});
|
|
@@ -952,6 +982,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
952
982
|
options = tslib_1.__assign({}, options);
|
|
953
983
|
opt = {};
|
|
954
984
|
opt = {};
|
|
985
|
+
if (options.args)
|
|
986
|
+
opt.args = options.args;
|
|
955
987
|
if (options.select) {
|
|
956
988
|
opt.select = Object.keys(options.select)
|
|
957
989
|
.filter(function (x) { return options.select[x]; })
|
|
@@ -1417,56 +1449,62 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1417
1449
|
};
|
|
1418
1450
|
RepositoryImplementation.prototype.deleteMany = function (_a) {
|
|
1419
1451
|
return tslib_1.__awaiter(this, arguments, void 0, function (_b) {
|
|
1420
|
-
var _c, _d,
|
|
1421
|
-
var
|
|
1452
|
+
var _c, _d, _e, deleted, _f, _g, _h, item, e_22_1;
|
|
1453
|
+
var _j, e_22, _k, _l;
|
|
1422
1454
|
var where = _b.where;
|
|
1423
|
-
return tslib_1.__generator(this, function (
|
|
1424
|
-
switch (
|
|
1455
|
+
return tslib_1.__generator(this, function (_m) {
|
|
1456
|
+
switch (_m.label) {
|
|
1425
1457
|
case 0:
|
|
1426
1458
|
filter_interfaces_js_1.Filter.throwErrorIfFilterIsEmpty(where, 'deleteMany');
|
|
1427
|
-
if (!this._dataProvider.isProxy) return [3 /*break*/,
|
|
1459
|
+
if (!this._dataProvider.isProxy) return [3 /*break*/, 4];
|
|
1428
1460
|
_d = (_c = this._edp).deleteMany;
|
|
1429
|
-
return [
|
|
1430
|
-
|
|
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)];
|
|
1431
1465
|
case 2:
|
|
1466
|
+
_e = _m.sent();
|
|
1467
|
+
_m.label = 3;
|
|
1468
|
+
case 3: return [2 /*return*/, _d.apply(_c, [_e])];
|
|
1469
|
+
case 4:
|
|
1432
1470
|
deleted = 0;
|
|
1433
|
-
|
|
1434
|
-
case 3:
|
|
1435
|
-
_l.trys.push([3, 9, 10, 15]);
|
|
1436
|
-
_e = true, _f = tslib_1.__asyncValues(this.query({ where: where, aggregate: undefined }));
|
|
1437
|
-
_l.label = 4;
|
|
1438
|
-
case 4: return [4 /*yield*/, _f.next()];
|
|
1471
|
+
_m.label = 5;
|
|
1439
1472
|
case 5:
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
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;
|
|
1444
1482
|
return [4 /*yield*/, (0, getEntityRef_js_1.getEntityRef)(item).delete()];
|
|
1445
|
-
case
|
|
1446
|
-
|
|
1483
|
+
case 8:
|
|
1484
|
+
_m.sent();
|
|
1447
1485
|
deleted++;
|
|
1448
|
-
|
|
1449
|
-
case 7:
|
|
1450
|
-
_e = true;
|
|
1451
|
-
return [3 /*break*/, 4];
|
|
1452
|
-
case 8: return [3 /*break*/, 15];
|
|
1486
|
+
_m.label = 9;
|
|
1453
1487
|
case 9:
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
case 10:
|
|
1458
|
-
_l.trys.push([10, , 13, 14]);
|
|
1459
|
-
if (!(!_e && !_h && (_j = _f.return))) return [3 /*break*/, 12];
|
|
1460
|
-
return [4 /*yield*/, _j.call(_f)];
|
|
1488
|
+
_f = true;
|
|
1489
|
+
return [3 /*break*/, 6];
|
|
1490
|
+
case 10: return [3 /*break*/, 17];
|
|
1461
1491
|
case 11:
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
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)];
|
|
1465
1499
|
case 13:
|
|
1500
|
+
_m.sent();
|
|
1501
|
+
_m.label = 14;
|
|
1502
|
+
case 14: return [3 /*break*/, 16];
|
|
1503
|
+
case 15:
|
|
1466
1504
|
if (e_22) throw e_22.error;
|
|
1467
1505
|
return [7 /*endfinally*/];
|
|
1468
|
-
case
|
|
1469
|
-
case
|
|
1506
|
+
case 16: return [7 /*endfinally*/];
|
|
1507
|
+
case 17: return [2 /*return*/, deleted];
|
|
1470
1508
|
}
|
|
1471
1509
|
});
|
|
1472
1510
|
});
|
|
@@ -2419,7 +2457,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2419
2457
|
enumerable: false,
|
|
2420
2458
|
configurable: true
|
|
2421
2459
|
});
|
|
2422
|
-
rowHelperImplementation.prototype.save = function (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2460
|
+
rowHelperImplementation.prototype.save = function (options, onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject) {
|
|
2423
2461
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2424
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;
|
|
2425
2463
|
var e_36, _l, e_38, _m, _o, _p, e_37, _q;
|
|
@@ -2427,7 +2465,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2427
2465
|
return tslib_1.__generator(this, function (_t) {
|
|
2428
2466
|
switch (_t.label) {
|
|
2429
2467
|
case 0:
|
|
2430
|
-
_t.trys.push([0, ,
|
|
2468
|
+
_t.trys.push([0, , 41, 42]);
|
|
2431
2469
|
if (this._saving)
|
|
2432
2470
|
throw new Error('cannot save while entity is already saving');
|
|
2433
2471
|
this._saving = true;
|
|
@@ -2508,10 +2546,10 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2508
2546
|
isNew = this.isNew();
|
|
2509
2547
|
_t.label = 13;
|
|
2510
2548
|
case 13:
|
|
2511
|
-
_t.trys.push([13,
|
|
2549
|
+
_t.trys.push([13, 38, , 40]);
|
|
2512
2550
|
(_r = this._subscribers) === null || _r === void 0 ? void 0 : _r.reportChanged();
|
|
2513
2551
|
if (!this.isNew()) return [3 /*break*/, 19];
|
|
2514
|
-
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];
|
|
2515
2553
|
_f = (_e = this.edp).find;
|
|
2516
2554
|
_o = {};
|
|
2517
2555
|
return [4 /*yield*/, this.getIdFilter()];
|
|
@@ -2520,11 +2558,11 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2520
2558
|
case 15:
|
|
2521
2559
|
updatedRow = (updatedRow = _t.sent())[0];
|
|
2522
2560
|
return [3 /*break*/, 18];
|
|
2523
|
-
case 16: return [4 /*yield*/, this.edp.insert(d)];
|
|
2561
|
+
case 16: return [4 /*yield*/, this.edp.insert(d, options)];
|
|
2524
2562
|
case 17:
|
|
2525
2563
|
updatedRow = _t.sent();
|
|
2526
2564
|
_t.label = 18;
|
|
2527
|
-
case 18: return [3 /*break*/,
|
|
2565
|
+
case 18: return [3 /*break*/, 25];
|
|
2528
2566
|
case 19:
|
|
2529
2567
|
changesOnly = {};
|
|
2530
2568
|
wasChanged = false;
|
|
@@ -2541,79 +2579,81 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2541
2579
|
}
|
|
2542
2580
|
if (!wasChanged)
|
|
2543
2581
|
return [2 /*return*/, this.instance];
|
|
2544
|
-
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];
|
|
2545
2584
|
_h = (_g = this.edp).find;
|
|
2546
2585
|
_p = {};
|
|
2547
2586
|
return [4 /*yield*/, this.getIdFilter()];
|
|
2548
2587
|
case 20: return [4 /*yield*/, _h.apply(_g, [(_p.where = _t.sent(), _p)])];
|
|
2549
2588
|
case 21:
|
|
2550
2589
|
updatedRow = (_t.sent())[0];
|
|
2551
|
-
|
|
2552
|
-
case 22:
|
|
2590
|
+
_t.label = 22;
|
|
2591
|
+
case 22: return [3 /*break*/, 25];
|
|
2592
|
+
case 23:
|
|
2553
2593
|
if (this.id === undefined)
|
|
2554
2594
|
throw new Error('Invalid operation, id is undefined');
|
|
2555
|
-
return [4 /*yield*/, this.edp.update(this.id, changesOnly)];
|
|
2556
|
-
case 23:
|
|
2557
|
-
updatedRow = _t.sent();
|
|
2558
|
-
_t.label = 24;
|
|
2595
|
+
return [4 /*yield*/, this.edp.update(this.id, changesOnly, options)];
|
|
2559
2596
|
case 24:
|
|
2560
|
-
|
|
2561
|
-
|
|
2597
|
+
updatedRow = _t.sent();
|
|
2598
|
+
_t.label = 25;
|
|
2562
2599
|
case 25:
|
|
2563
|
-
|
|
2564
|
-
|
|
2600
|
+
if (!updatedRow) return [3 /*break*/, 27];
|
|
2601
|
+
return [4 /*yield*/, this.loadDataFrom(updatedRow)];
|
|
2565
2602
|
case 26:
|
|
2603
|
+
_t.sent();
|
|
2604
|
+
_t.label = 27;
|
|
2605
|
+
case 27:
|
|
2566
2606
|
e.id = this.getId();
|
|
2567
|
-
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/,
|
|
2568
|
-
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];
|
|
2569
2609
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2570
|
-
case 27:
|
|
2571
|
-
_t.sent();
|
|
2572
|
-
_t.label = 28;
|
|
2573
2610
|
case 28:
|
|
2574
|
-
|
|
2611
|
+
_t.sent();
|
|
2575
2612
|
_t.label = 29;
|
|
2576
2613
|
case 29:
|
|
2577
|
-
|
|
2578
|
-
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2614
|
+
if (!this.repo.listeners) return [3 /*break*/, 37];
|
|
2579
2615
|
_t.label = 30;
|
|
2580
2616
|
case 30:
|
|
2581
|
-
|
|
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];
|
|
2582
2622
|
listener = _k.value;
|
|
2583
2623
|
return [4 /*yield*/, ((_s = listener.saved) === null || _s === void 0 ? void 0 : _s.call(listener, this.instance, isNew))];
|
|
2584
|
-
case 31:
|
|
2585
|
-
_t.sent();
|
|
2586
|
-
_t.label = 32;
|
|
2587
2624
|
case 32:
|
|
2625
|
+
_t.sent();
|
|
2626
|
+
_t.label = 33;
|
|
2627
|
+
case 33:
|
|
2588
2628
|
_k = _j.next();
|
|
2589
|
-
return [3 /*break*/,
|
|
2590
|
-
case
|
|
2591
|
-
case
|
|
2629
|
+
return [3 /*break*/, 31];
|
|
2630
|
+
case 34: return [3 /*break*/, 37];
|
|
2631
|
+
case 35:
|
|
2592
2632
|
e_37_1 = _t.sent();
|
|
2593
2633
|
e_37 = { error: e_37_1 };
|
|
2594
|
-
return [3 /*break*/,
|
|
2595
|
-
case
|
|
2634
|
+
return [3 /*break*/, 37];
|
|
2635
|
+
case 36:
|
|
2596
2636
|
try {
|
|
2597
2637
|
if (_k && !_k.done && (_q = _j.return)) _q.call(_j);
|
|
2598
2638
|
}
|
|
2599
2639
|
finally { if (e_37) throw e_37.error; }
|
|
2600
2640
|
return [7 /*endfinally*/];
|
|
2601
|
-
case
|
|
2641
|
+
case 37:
|
|
2602
2642
|
this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
|
|
2603
2643
|
this.saveOriginalData();
|
|
2604
2644
|
this._isNew = false;
|
|
2605
2645
|
return [2 /*return*/, this.instance];
|
|
2606
|
-
case
|
|
2646
|
+
case 38:
|
|
2607
2647
|
err_1 = _t.sent();
|
|
2608
2648
|
return [4 /*yield*/, this.catchSaveErrors(err_1)];
|
|
2609
|
-
case
|
|
2610
|
-
case
|
|
2611
|
-
case
|
|
2649
|
+
case 39: throw _t.sent();
|
|
2650
|
+
case 40: return [3 /*break*/, 42];
|
|
2651
|
+
case 41:
|
|
2612
2652
|
this.isLoading = false;
|
|
2613
2653
|
this._reportChangedToEntityAndFields();
|
|
2614
2654
|
this._saving = false;
|
|
2615
2655
|
return [7 /*endfinally*/];
|
|
2616
|
-
case
|
|
2656
|
+
case 42: return [2 /*return*/];
|
|
2617
2657
|
}
|
|
2618
2658
|
});
|
|
2619
2659
|
});
|