@chevre/domain 20.2.0-alpha.8 → 20.2.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/example/src/chevre/aggregateEventReservation.ts +37 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
- package/example/src/chevre/attendIfNotAttended.ts +22 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
- package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
- package/example/src/chevre/migrateProjectSubscription.ts +51 -0
- package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
- package/example/src/chevre/processReserve.ts +2 -0
- package/example/src/chevre/searchEventIds.ts +24 -0
- package/example/src/chevre/searchEventTicketOffers.ts +5 -4
- package/example/src/chevre/searchEvents.ts +20 -41
- package/example/src/chevre/searchOffersByCatalog.ts +27 -0
- package/example/src/chevre/updateTransaction.ts +38 -0
- package/lib/chevre/factory/event.d.ts +2 -0
- package/lib/chevre/factory/event.js +2 -0
- package/lib/chevre/repo/action.d.ts +77 -1
- package/lib/chevre/repo/action.js +249 -6
- package/lib/chevre/repo/aggregation.d.ts +38 -0
- package/lib/chevre/repo/aggregation.js +68 -0
- package/lib/chevre/repo/assetTransaction.d.ts +32 -0
- package/lib/chevre/repo/assetTransaction.js +148 -0
- package/lib/chevre/repo/code.d.ts +13 -16
- package/lib/chevre/repo/code.js +33 -19
- package/lib/chevre/repo/creativeWork.js +13 -12
- package/lib/chevre/repo/event.d.ts +64 -17
- package/lib/chevre/repo/event.js +456 -156
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/event.js +4 -3
- package/lib/chevre/repo/mongoose/model/offer.js +2 -1
- package/lib/chevre/repo/mongoose/model/project.js +7 -1
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/offer.d.ts +10 -0
- package/lib/chevre/repo/offer.js +47 -16
- package/lib/chevre/repo/order.d.ts +6 -0
- package/lib/chevre/repo/order.js +53 -7
- package/lib/chevre/repo/place.d.ts +26 -1
- package/lib/chevre/repo/place.js +216 -12
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/project.d.ts +7 -1
- package/lib/chevre/repo/project.js +15 -6
- package/lib/chevre/repo/reservation.d.ts +7 -8
- package/lib/chevre/repo/reservation.js +181 -76
- package/lib/chevre/repo/task.d.ts +31 -4
- package/lib/chevre/repo/task.js +146 -33
- package/lib/chevre/repo/transaction.d.ts +57 -5
- package/lib/chevre/repo/transaction.js +228 -34
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -68
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
- package/lib/chevre/service/aggregation/system.d.ts +100 -0
- package/lib/chevre/service/aggregation/system.js +409 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
- package/lib/chevre/service/assetTransaction/pay.js +65 -32
- package/lib/chevre/service/assetTransaction/registerService.js +4 -1
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
- package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
- package/lib/chevre/service/assetTransaction/reserve.js +120 -94
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +2 -3
- package/lib/chevre/service/delivery/factory.d.ts +1 -1
- package/lib/chevre/service/delivery/product/factory.js +9 -3
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +35 -14
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
- package/lib/chevre/service/offer/event/authorize.js +33 -87
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.d.ts +3 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
- package/lib/chevre/service/offer/factory.js +10 -3
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
- package/lib/chevre/service/offer/product.d.ts +1 -0
- package/lib/chevre/service/offer/product.js +7 -2
- package/lib/chevre/service/offer.d.ts +13 -2
- package/lib/chevre/service/offer.js +68 -46
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/order/returnOrder.js +6 -4
- package/lib/chevre/service/order/sendOrder.js +4 -2
- package/lib/chevre/service/payment/any.d.ts +9 -0
- package/lib/chevre/service/payment/any.js +16 -1
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +8 -2
- package/lib/chevre/service/product.js +5 -3
- package/lib/chevre/service/report/telemetry.js +1 -1
- package/lib/chevre/service/reserve/checkInReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +7 -10
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
- package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
- package/lib/chevre/service/reserve/useReservation.js +58 -32
- package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
- package/lib/chevre/service/task/returnPayTransaction.js +10 -4
- package/lib/chevre/service/task.js +6 -9
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
- package/lib/chevre/service/transaction/placeOrder.js +5 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
- package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
- package/lib/chevre/service/transaction/returnOrder.js +8 -6
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +20 -12
- package/package.json +3 -3
- package/CHANGELOG.md +0 -2030
- package/example/.gitignore +0 -1
- package/example/src/chevre/.gitignore +0 -1
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
|
@@ -536,5 +536,153 @@ class MongoRepository {
|
|
|
536
536
|
.exec();
|
|
537
537
|
});
|
|
538
538
|
}
|
|
539
|
+
aggregateAssetTransaction(params) {
|
|
540
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
541
|
+
const statuses = yield Promise.all([
|
|
542
|
+
factory.transactionStatusType.Confirmed,
|
|
543
|
+
factory.transactionStatusType.Canceled,
|
|
544
|
+
factory.transactionStatusType.Expired
|
|
545
|
+
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
546
|
+
var _a, _b;
|
|
547
|
+
const matchConditions = Object.assign({ startDate: {
|
|
548
|
+
$gte: params.startFrom,
|
|
549
|
+
$lte: params.startThrough
|
|
550
|
+
}, typeOf: { $eq: params.typeOf }, status: { $eq: transactionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
551
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
552
|
+
: undefined);
|
|
553
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
554
|
+
})));
|
|
555
|
+
return { statuses };
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
// tslint:disable-next-line:max-func-body-length
|
|
559
|
+
agggregateByStatus(params) {
|
|
560
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
+
const matchConditions = params.matchConditions;
|
|
562
|
+
const transactionStatus = params.status;
|
|
563
|
+
const aggregations = yield this.transactionModel.aggregate([
|
|
564
|
+
{
|
|
565
|
+
$match: matchConditions
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
$project: {
|
|
569
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
570
|
+
graceTime: {
|
|
571
|
+
$cond: {
|
|
572
|
+
if: { $eq: ['$typeOf', factory.assetTransactionType.Reserve] },
|
|
573
|
+
then: { $subtract: ['$object.reservationFor.startDate', '$startDate'] },
|
|
574
|
+
else: 0
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
status: '$status',
|
|
578
|
+
startDate: '$startDate',
|
|
579
|
+
endDate: '$endDate',
|
|
580
|
+
typeOf: '$typeOf',
|
|
581
|
+
reservationCount: {
|
|
582
|
+
$cond: {
|
|
583
|
+
if: { $isArray: '$object.subReservation' },
|
|
584
|
+
then: { $size: '$object.subReservation' },
|
|
585
|
+
else: 0
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
$group: {
|
|
592
|
+
_id: '$typeOf',
|
|
593
|
+
transactionCount: { $sum: 1 },
|
|
594
|
+
maxDuration: { $max: '$duration' },
|
|
595
|
+
minDuration: { $min: '$duration' },
|
|
596
|
+
avgDuration: { $avg: '$duration' },
|
|
597
|
+
reservationCount: { $sum: '$reservationCount' },
|
|
598
|
+
maxGraceTime: { $max: '$graceTime' },
|
|
599
|
+
minGraceTime: { $min: '$graceTime' },
|
|
600
|
+
avgGraceTime: { $avg: '$graceTime' }
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
$project: {
|
|
605
|
+
_id: 0,
|
|
606
|
+
transactionCount: '$transactionCount',
|
|
607
|
+
avgDuration: '$avgDuration',
|
|
608
|
+
maxDuration: '$maxDuration',
|
|
609
|
+
minDuration: '$minDuration',
|
|
610
|
+
reservationCount: '$reservationCount',
|
|
611
|
+
avgGraceTime: '$avgGraceTime',
|
|
612
|
+
maxGraceTime: '$maxGraceTime',
|
|
613
|
+
minGraceTime: '$minGraceTime'
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
])
|
|
617
|
+
.exec();
|
|
618
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
619
|
+
const percents = [50, 95, 99];
|
|
620
|
+
if (aggregations.length === 0) {
|
|
621
|
+
return {
|
|
622
|
+
status: transactionStatus,
|
|
623
|
+
aggregation: {
|
|
624
|
+
transactionCount: 0,
|
|
625
|
+
avgDuration: 0,
|
|
626
|
+
maxDuration: 0,
|
|
627
|
+
minDuration: 0,
|
|
628
|
+
percentilesDuration: percents.map((percent) => {
|
|
629
|
+
return {
|
|
630
|
+
name: String(percent),
|
|
631
|
+
value: 0
|
|
632
|
+
};
|
|
633
|
+
}),
|
|
634
|
+
reservationCount: 0,
|
|
635
|
+
avgGraceTime: 0,
|
|
636
|
+
maxGraceTime: 0,
|
|
637
|
+
minGraceTime: 0
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
642
|
+
return {
|
|
643
|
+
percentile,
|
|
644
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
645
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
646
|
+
};
|
|
647
|
+
});
|
|
648
|
+
const aggregations2 = yield this.transactionModel.aggregate([
|
|
649
|
+
{
|
|
650
|
+
$match: matchConditions
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
$project: {
|
|
654
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
655
|
+
status: '$status',
|
|
656
|
+
startDate: '$startDate',
|
|
657
|
+
endDate: '$endDate',
|
|
658
|
+
typeOf: '$typeOf'
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
{ $sort: { duration: 1 } },
|
|
662
|
+
{
|
|
663
|
+
$group: {
|
|
664
|
+
_id: '$typeOf',
|
|
665
|
+
durations: { $push: '$duration' }
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
$project: {
|
|
670
|
+
_id: 0,
|
|
671
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
672
|
+
return {
|
|
673
|
+
name: String(rank.percentile),
|
|
674
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
675
|
+
};
|
|
676
|
+
})
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
])
|
|
680
|
+
.exec();
|
|
681
|
+
return {
|
|
682
|
+
status: transactionStatus,
|
|
683
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
}
|
|
539
687
|
}
|
|
540
688
|
exports.MongoRepository = MongoRepository;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { modelName } from './mongoose/model/authorization';
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type IObject = factory.authorization.IObject;
|
|
5
5
|
export declare type ICode = string;
|
|
6
6
|
export { modelName };
|
|
7
7
|
/**
|
|
@@ -19,7 +19,7 @@ export declare class MongoRepository {
|
|
|
19
19
|
id: string;
|
|
20
20
|
typeOf: factory.organizationType.Project;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
object: IObject;
|
|
23
23
|
validFrom: Date;
|
|
24
24
|
expiresInSeconds: number;
|
|
25
25
|
}[]): Promise<factory.authorization.IAuthorization[]>;
|
|
@@ -32,22 +32,9 @@ export declare class MongoRepository {
|
|
|
32
32
|
typeOf: factory.organizationType.Project;
|
|
33
33
|
};
|
|
34
34
|
code: ICode;
|
|
35
|
-
}): Promise<
|
|
35
|
+
}): Promise<IObject>;
|
|
36
36
|
count(params: factory.authorization.ISearchConditions): Promise<number>;
|
|
37
37
|
search(params: factory.authorization.ISearchConditions): Promise<factory.authorization.IAuthorization[]>;
|
|
38
|
-
/**
|
|
39
|
-
* コードを保管する
|
|
40
|
-
*/
|
|
41
|
-
save(params: {
|
|
42
|
-
project: {
|
|
43
|
-
id: string;
|
|
44
|
-
typeOf: factory.organizationType.Project;
|
|
45
|
-
};
|
|
46
|
-
code: ICode;
|
|
47
|
-
data: IData;
|
|
48
|
-
validFrom: Date;
|
|
49
|
-
expiresInSeconds: number;
|
|
50
|
-
}[]): Promise<factory.authorization.IAuthorization[]>;
|
|
51
38
|
deleteByCode(params: {
|
|
52
39
|
code: string;
|
|
53
40
|
}): Promise<{
|
|
@@ -55,4 +42,14 @@ export declare class MongoRepository {
|
|
|
55
42
|
ok?: number;
|
|
56
43
|
deletedCount?: number;
|
|
57
44
|
} | null>;
|
|
45
|
+
/**
|
|
46
|
+
* 有効期限を一定期間過ぎた承認を削除する
|
|
47
|
+
*/
|
|
48
|
+
deleteValidUntilPassedCertainPeriod(params: {
|
|
49
|
+
$lt: Date;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* コードを保管する
|
|
53
|
+
*/
|
|
54
|
+
private save;
|
|
58
55
|
}
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -134,7 +134,7 @@ class MongoRepository {
|
|
|
134
134
|
return {
|
|
135
135
|
project: p.project,
|
|
136
136
|
code: code,
|
|
137
|
-
|
|
137
|
+
object: p.object,
|
|
138
138
|
validFrom: p.validFrom,
|
|
139
139
|
expiresInSeconds: p.expiresInSeconds
|
|
140
140
|
};
|
|
@@ -204,6 +204,37 @@ class MongoRepository {
|
|
|
204
204
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
+
deleteByCode(params) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
return this.authorizationModel.deleteOne({
|
|
210
|
+
code: { $exists: true, $eq: params.code }
|
|
211
|
+
})
|
|
212
|
+
.exec()
|
|
213
|
+
.then((result) => {
|
|
214
|
+
return {
|
|
215
|
+
n: result === null || result === void 0 ? void 0 : result.n,
|
|
216
|
+
// opTime: result.opTime,
|
|
217
|
+
ok: result === null || result === void 0 ? void 0 : result.ok,
|
|
218
|
+
// operationTime,
|
|
219
|
+
deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 有効期限を一定期間過ぎた承認を削除する
|
|
226
|
+
*/
|
|
227
|
+
deleteValidUntilPassedCertainPeriod(params) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
yield this.authorizationModel.deleteMany({
|
|
230
|
+
validUntil: {
|
|
231
|
+
$exists: true,
|
|
232
|
+
$lt: params.$lt
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
.exec();
|
|
236
|
+
});
|
|
237
|
+
}
|
|
207
238
|
/**
|
|
208
239
|
* コードを保管する
|
|
209
240
|
*/
|
|
@@ -218,7 +249,7 @@ class MongoRepository {
|
|
|
218
249
|
project: p.project,
|
|
219
250
|
typeOf: 'Authorization',
|
|
220
251
|
code: p.code,
|
|
221
|
-
object: p.
|
|
252
|
+
object: p.object,
|
|
222
253
|
validFrom: p.validFrom,
|
|
223
254
|
validUntil: validUntil
|
|
224
255
|
};
|
|
@@ -234,22 +265,5 @@ class MongoRepository {
|
|
|
234
265
|
}
|
|
235
266
|
});
|
|
236
267
|
}
|
|
237
|
-
deleteByCode(params) {
|
|
238
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
return this.authorizationModel.deleteOne({
|
|
240
|
-
code: { $exists: true, $eq: params.code }
|
|
241
|
-
})
|
|
242
|
-
.exec()
|
|
243
|
-
.then((result) => {
|
|
244
|
-
return {
|
|
245
|
-
n: result === null || result === void 0 ? void 0 : result.n,
|
|
246
|
-
// opTime: result.opTime,
|
|
247
|
-
ok: result === null || result === void 0 ? void 0 : result.ok,
|
|
248
|
-
// operationTime,
|
|
249
|
-
deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
|
|
250
|
-
};
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
268
|
}
|
|
255
269
|
exports.MongoRepository = MongoRepository;
|
|
@@ -33,7 +33,7 @@ class MongoRepository {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
37
37
|
// MongoDB検索条件
|
|
38
38
|
const andConditions = [
|
|
39
39
|
{
|
|
@@ -69,20 +69,21 @@ class MongoRepository {
|
|
|
69
69
|
if (typeof params.identifier === 'string') {
|
|
70
70
|
if (params.identifier.length > 0) {
|
|
71
71
|
andConditions.push({
|
|
72
|
-
identifier: {
|
|
73
|
-
$exists: true,
|
|
74
|
-
$regex: new RegExp(params.identifier)
|
|
75
|
-
}
|
|
72
|
+
identifier: { $regex: new RegExp(params.identifier) }
|
|
76
73
|
});
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
|
-
else
|
|
80
|
-
|
|
76
|
+
else {
|
|
77
|
+
const identifierEq = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
78
|
+
if (typeof identifierEq === 'string') {
|
|
81
79
|
andConditions.push({
|
|
82
|
-
identifier: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
identifier: { $eq: identifierEq }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const identifierIn = (_g = params.identifier) === null || _g === void 0 ? void 0 : _g.$in;
|
|
84
|
+
if (Array.isArray(identifierIn)) {
|
|
85
|
+
andConditions.push({
|
|
86
|
+
identifier: { $in: identifierIn }
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -155,7 +156,7 @@ class MongoRepository {
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
|
-
const additionalPropertyElemMatch = (
|
|
159
|
+
const additionalPropertyElemMatch = (_h = params.additionalProperty) === null || _h === void 0 ? void 0 : _h.$elemMatch;
|
|
159
160
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
160
161
|
andConditions.push({
|
|
161
162
|
additionalProperty: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { BulkWriteOpResultObject } from 'mongodb';
|
|
1
2
|
import { Connection } from 'mongoose';
|
|
2
3
|
import * as factory from '../factory';
|
|
4
|
+
import * as EventFactory from '../factory/event';
|
|
3
5
|
export interface IAttributes4patchUpdate<T extends factory.eventType> {
|
|
4
6
|
typeOf: T;
|
|
5
7
|
eventStatus?: factory.eventStatusType;
|
|
@@ -30,6 +32,32 @@ export interface IUpdateAggregateUseActionsParams {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
export declare type ISearchConditions<T extends factory.eventType> = factory.event.ISearchConditions<T>;
|
|
35
|
+
interface IAggregationByStatus {
|
|
36
|
+
eventCount: number;
|
|
37
|
+
reservationCount: number;
|
|
38
|
+
avgOfferCount: number;
|
|
39
|
+
maximumAttendeeCapacity: number;
|
|
40
|
+
remainingAttendeeCapacity: number;
|
|
41
|
+
avgRemainingCapacityRate: number;
|
|
42
|
+
maxRemainingCapacityRate: number;
|
|
43
|
+
minRemainingCapacityRate: number;
|
|
44
|
+
percentilesRemainingCapacityRate: {
|
|
45
|
+
name: string;
|
|
46
|
+
value: number;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
interface IStatus {
|
|
50
|
+
status: factory.eventStatusType;
|
|
51
|
+
aggregation: IAggregationByStatus;
|
|
52
|
+
}
|
|
53
|
+
export interface IAggregateEvent {
|
|
54
|
+
statuses: IStatus[];
|
|
55
|
+
}
|
|
56
|
+
interface IProjection {
|
|
57
|
+
[key: string]: number;
|
|
58
|
+
}
|
|
59
|
+
export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
|
|
60
|
+
export declare const PROJECTION_MINIMIZED_EVENT: IProjection;
|
|
33
61
|
/**
|
|
34
62
|
* イベントリポジトリ
|
|
35
63
|
*/
|
|
@@ -40,7 +68,19 @@ export declare class MongoRepository {
|
|
|
40
68
|
/**
|
|
41
69
|
* 複数イベントを作成する
|
|
42
70
|
*/
|
|
43
|
-
createMany<T extends factory.eventType>(params:
|
|
71
|
+
createMany<T extends factory.eventType>(params: {
|
|
72
|
+
attributes: factory.event.IAttributes<T>[];
|
|
73
|
+
expectsNoContent: boolean;
|
|
74
|
+
}): Promise<factory.event.IEvent<T>[] | void>;
|
|
75
|
+
/**
|
|
76
|
+
* 特定の追加特性をキーにして、なければ作成する(複数対応)
|
|
77
|
+
*/
|
|
78
|
+
createManyIfNotExist<T extends factory.eventType>(params: {
|
|
79
|
+
attributes: factory.event.IAttributes<T>;
|
|
80
|
+
filter: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
}[]): Promise<BulkWriteOpResultObject | void>;
|
|
44
84
|
/**
|
|
45
85
|
* イベント部分更新
|
|
46
86
|
*/
|
|
@@ -54,36 +94,31 @@ export declare class MongoRepository {
|
|
|
54
94
|
save<T extends factory.eventType>(params: {
|
|
55
95
|
id?: string;
|
|
56
96
|
attributes: factory.event.IAttributes<T>;
|
|
57
|
-
$unset?:
|
|
58
|
-
[key: string]: number;
|
|
59
|
-
};
|
|
97
|
+
$unset?: IProjection;
|
|
60
98
|
upsert?: boolean;
|
|
61
99
|
}): Promise<factory.event.IEvent<T>>;
|
|
62
100
|
saveMany<T extends factory.eventType>(params: {
|
|
63
|
-
id
|
|
101
|
+
id: string;
|
|
64
102
|
attributes: factory.event.IAttributes<T>;
|
|
65
|
-
$unset?:
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
upsert?: boolean;
|
|
103
|
+
$unset?: IProjection;
|
|
104
|
+
upsert: boolean;
|
|
69
105
|
}[]): Promise<void>;
|
|
70
106
|
save4ttts(params: {
|
|
71
107
|
oldEventId: string;
|
|
72
108
|
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
73
|
-
useOldEventId: boolean;
|
|
74
109
|
}): Promise<factory.event.IEvent<factory.eventType.ScreeningEvent>>;
|
|
75
110
|
count<T extends factory.eventType>(params: ISearchConditions<T>): Promise<number>;
|
|
76
111
|
/**
|
|
77
112
|
* イベントを検索する
|
|
78
113
|
*/
|
|
79
|
-
search<T extends factory.eventType>(params: ISearchConditions<T>, projection?:
|
|
80
|
-
|
|
81
|
-
}): Promise<factory.event.IEvent<T>[]>;
|
|
114
|
+
search<T extends factory.eventType>(params: ISearchConditions<T>, projection?: IProjection): Promise<factory.event.IEvent<T>[]>;
|
|
115
|
+
searchIds<T extends factory.eventType>(params: ISearchConditions<T>): Promise<string[]>;
|
|
82
116
|
findById<T extends factory.eventType>(params: {
|
|
83
117
|
id: string;
|
|
84
|
-
}, projection?:
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
}, projection?: IProjection): Promise<factory.event.IEvent<T>>;
|
|
119
|
+
findMinimizedIndividualEventById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
|
|
120
|
+
id: string;
|
|
121
|
+
}): Promise<IMinimizedIndividualEvent<T>>;
|
|
87
122
|
/**
|
|
88
123
|
* イベントをキャンセルする
|
|
89
124
|
*/
|
|
@@ -104,9 +139,21 @@ export declare class MongoRepository {
|
|
|
104
139
|
updateAggregationById<T extends factory.eventType>(params: {
|
|
105
140
|
id: string;
|
|
106
141
|
}, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
|
|
107
|
-
bulkWrite(bulkWriteOps: any[]): Promise<
|
|
142
|
+
bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
|
|
108
143
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
109
144
|
deleteUnnecessaryProjectAttributesById(params: {
|
|
110
145
|
id: string;
|
|
111
146
|
}): Promise<void>;
|
|
147
|
+
aggregateEvent(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.eventType;
|
|
156
|
+
}): Promise<IAggregateEvent>;
|
|
157
|
+
private agggregateByStatus;
|
|
112
158
|
}
|
|
159
|
+
export {};
|