@chevre/domain 20.2.0-alpha.2 → 20.2.0-alpha.21
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 +82 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +90 -0
- package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
- package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
- package/lib/chevre/repo/action.d.ts +58 -0
- package/lib/chevre/repo/action.js +187 -0
- package/lib/chevre/repo/aggregation.d.ts +34 -0
- package/lib/chevre/repo/aggregation.js +64 -0
- package/lib/chevre/repo/event.d.ts +0 -1
- package/lib/chevre/repo/event.js +124 -105
- 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 +2 -2
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/order.d.ts +9 -0
- package/lib/chevre/repo/order.js +49 -0
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +205 -52
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/reservation.d.ts +0 -6
- package/lib/chevre/repo/reservation.js +106 -66
- package/lib/chevre/repo/transaction.d.ts +29 -0
- package/lib/chevre/repo/transaction.js +133 -0
- 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.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
- package/lib/chevre/service/aggregation/system.d.ts +74 -0
- package/lib/chevre/service/aggregation/system.js +266 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -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/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +33 -51
- package/lib/chevre/service/delivery/factory.js +1 -0
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +21 -10
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.js +25 -5
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer.js +28 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/payment/any.d.ts +5 -0
- package/lib/chevre/service/reserve/confirmReservation.js +7 -10
- package/lib/chevre/service/reserve/useReservation.js +2 -1
- 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/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -21,7 +21,7 @@ class MongoRepository {
|
|
|
21
21
|
}
|
|
22
22
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
23
23
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
25
25
|
// MongoDB検索条件
|
|
26
26
|
const andConditions = [
|
|
27
27
|
{ typeOf: params.typeOf }
|
|
@@ -233,9 +233,54 @@ class MongoRepository {
|
|
|
233
233
|
}
|
|
234
234
|
switch (params.typeOf) {
|
|
235
235
|
case factory.reservationType.BusReservation:
|
|
236
|
-
|
|
236
|
+
const reservationForTypeOfEq = (_h = params.reservationFor) === null || _h === void 0 ? void 0 : _h.typeOf;
|
|
237
|
+
if (typeof reservationForTypeOfEq === 'string') {
|
|
238
|
+
andConditions.push({
|
|
239
|
+
'reservationFor.typeOf': {
|
|
240
|
+
$exists: true,
|
|
241
|
+
$eq: reservationForTypeOfEq
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const reservationForIdEq = (_k = (_j = params.reservationFor) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
246
|
+
if (typeof reservationForIdEq === 'string') {
|
|
247
|
+
andConditions.push({
|
|
248
|
+
'reservationFor.id': {
|
|
249
|
+
$exists: true,
|
|
250
|
+
$eq: reservationForIdEq
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const reservationForIdIn = (_m = (_l = params.reservationFor) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$in;
|
|
255
|
+
if (Array.isArray(reservationForIdIn)) {
|
|
256
|
+
andConditions.push({
|
|
257
|
+
'reservationFor.id': {
|
|
258
|
+
$exists: true,
|
|
259
|
+
$in: reservationForIdIn
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
237
263
|
break;
|
|
238
264
|
case factory.reservationType.EventReservation:
|
|
265
|
+
if (typeof ((_o = params.reservationFor) === null || _o === void 0 ? void 0 : _o.id) === 'string') {
|
|
266
|
+
andConditions.push({
|
|
267
|
+
'reservationFor.id': {
|
|
268
|
+
$exists: true,
|
|
269
|
+
$eq: params.reservationFor.id
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const reservationForIdEq4eventReservation = (_q = (_p = params.reservationFor) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
275
|
+
if (typeof reservationForIdEq4eventReservation === 'string') {
|
|
276
|
+
andConditions.push({
|
|
277
|
+
'reservationFor.id': {
|
|
278
|
+
$exists: true,
|
|
279
|
+
$eq: reservationForIdEq4eventReservation
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
239
284
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
240
285
|
/* istanbul ignore else */
|
|
241
286
|
if (params.reservationFor !== undefined) {
|
|
@@ -251,16 +296,6 @@ class MongoRepository {
|
|
|
251
296
|
}
|
|
252
297
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
253
298
|
/* istanbul ignore else */
|
|
254
|
-
if (params.reservationFor.id !== undefined) {
|
|
255
|
-
andConditions.push({
|
|
256
|
-
'reservationFor.id': {
|
|
257
|
-
$exists: true,
|
|
258
|
-
$eq: params.reservationFor.id
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
263
|
-
/* istanbul ignore else */
|
|
264
299
|
if (Array.isArray(params.reservationFor.ids)) {
|
|
265
300
|
andConditions.push({
|
|
266
301
|
'reservationFor.id': {
|
|
@@ -490,7 +525,7 @@ class MongoRepository {
|
|
|
490
525
|
}
|
|
491
526
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
492
527
|
/* istanbul ignore else */
|
|
493
|
-
const ticketedSeatSeatingTypeIn = (
|
|
528
|
+
const ticketedSeatSeatingTypeIn = (_s = (_r = params.reservedTicket.ticketedSeat) === null || _r === void 0 ? void 0 : _r.seatingType) === null || _s === void 0 ? void 0 : _s.$in;
|
|
494
529
|
if (Array.isArray(ticketedSeatSeatingTypeIn)) {
|
|
495
530
|
andConditions.push({
|
|
496
531
|
'reservedTicket.ticketedSeat.seatingType': {
|
|
@@ -501,7 +536,7 @@ class MongoRepository {
|
|
|
501
536
|
}
|
|
502
537
|
}
|
|
503
538
|
}
|
|
504
|
-
const brokerIdRegex = (
|
|
539
|
+
const brokerIdRegex = (_t = params.broker) === null || _t === void 0 ? void 0 : _t.id;
|
|
505
540
|
if (typeof brokerIdRegex === 'string' && brokerIdRegex.length > 0) {
|
|
506
541
|
andConditions.push({
|
|
507
542
|
'broker.id': {
|
|
@@ -510,7 +545,7 @@ class MongoRepository {
|
|
|
510
545
|
}
|
|
511
546
|
});
|
|
512
547
|
}
|
|
513
|
-
const brokerIdentifierAll = (
|
|
548
|
+
const brokerIdentifierAll = (_v = (_u = params.broker) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$all;
|
|
514
549
|
if (Array.isArray(brokerIdentifierAll)) {
|
|
515
550
|
andConditions.push({
|
|
516
551
|
'broker.identifier': {
|
|
@@ -519,7 +554,7 @@ class MongoRepository {
|
|
|
519
554
|
}
|
|
520
555
|
});
|
|
521
556
|
}
|
|
522
|
-
const brokerIdentifierIn = (
|
|
557
|
+
const brokerIdentifierIn = (_x = (_w = params.broker) === null || _w === void 0 ? void 0 : _w.identifier) === null || _x === void 0 ? void 0 : _x.$in;
|
|
523
558
|
if (Array.isArray(brokerIdentifierIn)) {
|
|
524
559
|
andConditions.push({
|
|
525
560
|
'broker.identifier': {
|
|
@@ -528,7 +563,7 @@ class MongoRepository {
|
|
|
528
563
|
}
|
|
529
564
|
});
|
|
530
565
|
}
|
|
531
|
-
const brokerIdentifierNin = (
|
|
566
|
+
const brokerIdentifierNin = (_z = (_y = params.broker) === null || _y === void 0 ? void 0 : _y.identifier) === null || _z === void 0 ? void 0 : _z.$nin;
|
|
532
567
|
if (Array.isArray(brokerIdentifierNin)) {
|
|
533
568
|
andConditions.push({
|
|
534
569
|
'broker.identifier': {
|
|
@@ -536,7 +571,7 @@ class MongoRepository {
|
|
|
536
571
|
}
|
|
537
572
|
});
|
|
538
573
|
}
|
|
539
|
-
const brokerIdentifierElemMatch = (
|
|
574
|
+
const brokerIdentifierElemMatch = (_1 = (_0 = params.broker) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$elemMatch;
|
|
540
575
|
if (brokerIdentifierElemMatch !== undefined && brokerIdentifierElemMatch !== null) {
|
|
541
576
|
andConditions.push({
|
|
542
577
|
'broker.identifier': {
|
|
@@ -571,9 +606,9 @@ class MongoRepository {
|
|
|
571
606
|
}
|
|
572
607
|
}
|
|
573
608
|
else {
|
|
574
|
-
const emailRegex = (
|
|
609
|
+
const emailRegex = (_2 = params.underName.email) === null || _2 === void 0 ? void 0 : _2.$regex;
|
|
575
610
|
if (typeof emailRegex === 'string' && emailRegex.length > 0) {
|
|
576
|
-
const emailOptions = (
|
|
611
|
+
const emailOptions = (_3 = params.underName.email) === null || _3 === void 0 ? void 0 : _3.$options;
|
|
577
612
|
andConditions.push({
|
|
578
613
|
'underName.email': Object.assign({ $exists: true, $regex: new RegExp(emailRegex) }, (typeof emailOptions === 'string') ? { $options: emailOptions } : undefined)
|
|
579
614
|
});
|
|
@@ -592,9 +627,9 @@ class MongoRepository {
|
|
|
592
627
|
}
|
|
593
628
|
}
|
|
594
629
|
else {
|
|
595
|
-
const underNameNameRegex = (
|
|
630
|
+
const underNameNameRegex = (_4 = params.underName.name) === null || _4 === void 0 ? void 0 : _4.$regex;
|
|
596
631
|
if (typeof underNameNameRegex === 'string' && underNameNameRegex.length > 0) {
|
|
597
|
-
const underNameNameOptions = (
|
|
632
|
+
const underNameNameOptions = (_5 = params.underName.name) === null || _5 === void 0 ? void 0 : _5.$options;
|
|
598
633
|
andConditions.push({
|
|
599
634
|
'underName.name': Object.assign({ $exists: true, $regex: new RegExp(underNameNameRegex) }, (typeof underNameNameOptions === 'string') ? { $options: underNameNameOptions } : undefined)
|
|
600
635
|
});
|
|
@@ -623,9 +658,9 @@ class MongoRepository {
|
|
|
623
658
|
}
|
|
624
659
|
}
|
|
625
660
|
else {
|
|
626
|
-
const givenNameRegex = (
|
|
661
|
+
const givenNameRegex = (_6 = params.underName.givenName) === null || _6 === void 0 ? void 0 : _6.$regex;
|
|
627
662
|
if (typeof givenNameRegex === 'string' && givenNameRegex.length > 0) {
|
|
628
|
-
const givenNameOptions = (
|
|
663
|
+
const givenNameOptions = (_7 = params.underName.givenName) === null || _7 === void 0 ? void 0 : _7.$options;
|
|
629
664
|
andConditions.push({
|
|
630
665
|
'underName.givenName': Object.assign({ $exists: true, $regex: new RegExp(givenNameRegex) }, (typeof givenNameOptions === 'string') ? { $options: givenNameOptions } : undefined)
|
|
631
666
|
});
|
|
@@ -644,9 +679,9 @@ class MongoRepository {
|
|
|
644
679
|
}
|
|
645
680
|
}
|
|
646
681
|
else {
|
|
647
|
-
const familyNameRegex = (
|
|
682
|
+
const familyNameRegex = (_8 = params.underName.familyName) === null || _8 === void 0 ? void 0 : _8.$regex;
|
|
648
683
|
if (typeof familyNameRegex === 'string' && familyNameRegex.length > 0) {
|
|
649
|
-
const familyNameOptions = (
|
|
684
|
+
const familyNameOptions = (_9 = params.underName.familyName) === null || _9 === void 0 ? void 0 : _9.$options;
|
|
650
685
|
andConditions.push({
|
|
651
686
|
'underName.familyName': Object.assign({ $exists: true, $regex: new RegExp(familyNameRegex) }, (typeof familyNameOptions === 'string') ? { $options: familyNameOptions } : undefined)
|
|
652
687
|
});
|
|
@@ -747,7 +782,7 @@ class MongoRepository {
|
|
|
747
782
|
});
|
|
748
783
|
}
|
|
749
784
|
}
|
|
750
|
-
const programMembershipUsedIdentifierEq = (
|
|
785
|
+
const programMembershipUsedIdentifierEq = (_11 = (_10 = params.programMembershipUsed) === null || _10 === void 0 ? void 0 : _10.identifier) === null || _11 === void 0 ? void 0 : _11.$eq;
|
|
751
786
|
if (typeof programMembershipUsedIdentifierEq === 'string') {
|
|
752
787
|
andConditions.push({
|
|
753
788
|
'programMembershipUsed.identifier': {
|
|
@@ -756,7 +791,7 @@ class MongoRepository {
|
|
|
756
791
|
}
|
|
757
792
|
});
|
|
758
793
|
}
|
|
759
|
-
const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (
|
|
794
|
+
const programMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_15 = (_14 = (_13 = (_12 = params.programMembershipUsed) === null || _12 === void 0 ? void 0 : _12.issuedThrough) === null || _13 === void 0 ? void 0 : _13.serviceType) === null || _14 === void 0 ? void 0 : _14.codeValue) === null || _15 === void 0 ? void 0 : _15.$eq;
|
|
760
795
|
if (typeof programMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
|
|
761
796
|
andConditions.push({
|
|
762
797
|
'programMembershipUsed.issuedThrough.serviceType.codeValue': {
|
|
@@ -765,7 +800,7 @@ class MongoRepository {
|
|
|
765
800
|
}
|
|
766
801
|
});
|
|
767
802
|
}
|
|
768
|
-
const appliesToMovieTicketIdentifierEq = (
|
|
803
|
+
const appliesToMovieTicketIdentifierEq = (_19 = (_18 = (_17 = (_16 = params.price) === null || _16 === void 0 ? void 0 : _16.priceComponent) === null || _17 === void 0 ? void 0 : _17.appliesToMovieTicket) === null || _18 === void 0 ? void 0 : _18.identifier) === null || _19 === void 0 ? void 0 : _19.$eq;
|
|
769
804
|
if (typeof appliesToMovieTicketIdentifierEq === 'string') {
|
|
770
805
|
andConditions.push({
|
|
771
806
|
'price.priceComponent.appliesToMovieTicket.identifier': {
|
|
@@ -880,49 +915,54 @@ class MongoRepository {
|
|
|
880
915
|
/**
|
|
881
916
|
* 予約確定
|
|
882
917
|
*/
|
|
883
|
-
confirm(params
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
}
|
|
918
|
+
// public async confirm<T extends factory.reservationType>(params: {
|
|
919
|
+
// id: string;
|
|
920
|
+
// previousReservationStatus: factory.reservationStatusType;
|
|
921
|
+
// underName?: factory.reservation.IUnderName<T>;
|
|
922
|
+
// }): Promise<factory.reservation.IReservation<T>> {
|
|
923
|
+
// const conditions = {
|
|
924
|
+
// _id: { $eq: String(params.id) },
|
|
925
|
+
// reservationStatus: { $eq: params.previousReservationStatus }
|
|
926
|
+
// };
|
|
927
|
+
// // 更新属性をwhitelist化(2022-06-13~)
|
|
928
|
+
// const update = {
|
|
929
|
+
// // previousReservationStatusを保管(2023-01-19~)
|
|
930
|
+
// previousReservationStatus: params.previousReservationStatus,
|
|
931
|
+
// reservationStatus: factory.reservationStatusType.ReservationConfirmed,
|
|
932
|
+
// modifiedTime: new Date(),
|
|
933
|
+
// ...(params.underName !== undefined) ? { underName: params.underName } : undefined
|
|
934
|
+
// };
|
|
935
|
+
// const doc = await this.reservationModel.findOneAndUpdate(
|
|
936
|
+
// conditions,
|
|
937
|
+
// update,
|
|
938
|
+
// { new: true }
|
|
939
|
+
// )
|
|
940
|
+
// .select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
941
|
+
// .exec();
|
|
942
|
+
// // NotFoundであれば状態確認
|
|
943
|
+
// if (doc === null) {
|
|
944
|
+
// const reservation = await this.findById<T>({ id: String(params.id) });
|
|
945
|
+
// if (reservation.reservationStatus === factory.reservationStatusType.ReservationConfirmed) {
|
|
946
|
+
// // すでに確定済の場合
|
|
947
|
+
// return reservation;
|
|
948
|
+
// } else {
|
|
949
|
+
// throw new factory.errors.Argument(
|
|
950
|
+
// 'id',
|
|
951
|
+
// `Reservation ${reservation.id} already changed -> ${reservation.reservationStatus}`
|
|
952
|
+
// );
|
|
953
|
+
// }
|
|
954
|
+
// }
|
|
955
|
+
// return doc.toObject();
|
|
956
|
+
// }
|
|
917
957
|
confirmByReservationNumber(params) {
|
|
918
958
|
return __awaiter(this, void 0, void 0, function* () {
|
|
919
959
|
const conditions = {
|
|
920
960
|
reservationNumber: { $eq: String(params.reservationNumber) },
|
|
921
961
|
reservationStatus: { $eq: params.previousReservationStatus }
|
|
922
962
|
};
|
|
923
|
-
const update = Object.assign({
|
|
924
|
-
|
|
925
|
-
|
|
963
|
+
const update = Object.assign({
|
|
964
|
+
// previousReservationStatusを保管(2023-01-19~)
|
|
965
|
+
previousReservationStatus: params.previousReservationStatus, reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime: new Date() }, (params.underName !== undefined) ? { underName: params.underName } : undefined);
|
|
926
966
|
yield this.reservationModel.updateMany(conditions, update)
|
|
927
967
|
.exec();
|
|
928
968
|
});
|
|
@@ -2,6 +2,23 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { modelName } from './mongoose/model/transaction';
|
|
4
4
|
export { modelName };
|
|
5
|
+
interface IAggregationByStatus {
|
|
6
|
+
transactionCount: number;
|
|
7
|
+
avgDuration: number;
|
|
8
|
+
maxDuration: number;
|
|
9
|
+
minDuration: number;
|
|
10
|
+
percentilesDuration: {
|
|
11
|
+
name: string;
|
|
12
|
+
value: number;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
interface IStatus {
|
|
16
|
+
status: factory.transactionStatusType;
|
|
17
|
+
aggregation: IAggregationByStatus;
|
|
18
|
+
}
|
|
19
|
+
export interface IAggregatePlaceOrder {
|
|
20
|
+
statuses: IStatus[];
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* 取引リポジトリ
|
|
7
24
|
*/
|
|
@@ -129,4 +146,16 @@ export declare class MongoRepository {
|
|
|
129
146
|
findByIdAndDelete(params: {
|
|
130
147
|
id: string;
|
|
131
148
|
}): Promise<void>;
|
|
149
|
+
aggregatePlaceOrder(params: {
|
|
150
|
+
project?: {
|
|
151
|
+
id?: {
|
|
152
|
+
$ne?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
startFrom: Date;
|
|
156
|
+
startThrough: Date;
|
|
157
|
+
typeOf: factory.transactionType;
|
|
158
|
+
clientId?: string;
|
|
159
|
+
}): Promise<IAggregatePlaceOrder>;
|
|
160
|
+
private agggregateByStatus;
|
|
132
161
|
}
|
|
@@ -600,5 +600,138 @@ class MongoRepository {
|
|
|
600
600
|
.exec();
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
|
+
aggregatePlaceOrder(params) {
|
|
604
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
const statuses = yield Promise.all([
|
|
606
|
+
factory.transactionStatusType.Canceled,
|
|
607
|
+
factory.transactionStatusType.Expired,
|
|
608
|
+
factory.transactionStatusType.Confirmed
|
|
609
|
+
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
610
|
+
var _a, _b;
|
|
611
|
+
const matchConditions = Object.assign(Object.assign({ startDate: {
|
|
612
|
+
$gte: params.startFrom,
|
|
613
|
+
$lte: params.startThrough
|
|
614
|
+
}, 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')
|
|
615
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
616
|
+
: undefined), (typeof params.clientId === 'string')
|
|
617
|
+
// customerIdentifierAll.push();
|
|
618
|
+
? {
|
|
619
|
+
'agent.identifier': {
|
|
620
|
+
$exists: true,
|
|
621
|
+
$all: [{ name: 'clientId', value: params.clientId }]
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
: undefined);
|
|
625
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
626
|
+
})));
|
|
627
|
+
return { statuses };
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
// tslint:disable-next-line:max-func-body-length
|
|
631
|
+
agggregateByStatus(params) {
|
|
632
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
633
|
+
const matchConditions = params.matchConditions;
|
|
634
|
+
const transactionStatus = params.status;
|
|
635
|
+
const aggregations = yield this.transactionModel.aggregate([
|
|
636
|
+
{
|
|
637
|
+
$match: matchConditions
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
$project: {
|
|
641
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
642
|
+
status: '$status',
|
|
643
|
+
startDate: '$startDate',
|
|
644
|
+
endDate: '$endDate',
|
|
645
|
+
typeOf: '$typeOf'
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
$group: {
|
|
650
|
+
_id: '$typeOf',
|
|
651
|
+
transactionCount: { $sum: 1 },
|
|
652
|
+
maxDuration: { $max: '$duration' },
|
|
653
|
+
minDuration: { $min: '$duration' },
|
|
654
|
+
avgDuration: { $avg: '$duration' }
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
$project: {
|
|
659
|
+
_id: 0,
|
|
660
|
+
transactionCount: '$transactionCount',
|
|
661
|
+
avgDuration: '$avgDuration',
|
|
662
|
+
maxDuration: '$maxDuration',
|
|
663
|
+
minDuration: '$minDuration'
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
])
|
|
667
|
+
.exec();
|
|
668
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
669
|
+
const percents = [50, 95, 99];
|
|
670
|
+
if (aggregations.length === 0) {
|
|
671
|
+
return {
|
|
672
|
+
status: transactionStatus,
|
|
673
|
+
aggregation: {
|
|
674
|
+
transactionCount: 0,
|
|
675
|
+
avgDuration: 0,
|
|
676
|
+
maxDuration: 0,
|
|
677
|
+
minDuration: 0,
|
|
678
|
+
percentilesDuration: percents.map((percent) => {
|
|
679
|
+
return {
|
|
680
|
+
name: String(percent),
|
|
681
|
+
value: 0
|
|
682
|
+
};
|
|
683
|
+
})
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
688
|
+
return {
|
|
689
|
+
percentile,
|
|
690
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
691
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
692
|
+
};
|
|
693
|
+
});
|
|
694
|
+
const aggregations2 = yield this.transactionModel.aggregate([
|
|
695
|
+
{
|
|
696
|
+
$match: matchConditions
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
$project: {
|
|
700
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
701
|
+
status: '$status',
|
|
702
|
+
startDate: '$startDate',
|
|
703
|
+
endDate: '$endDate',
|
|
704
|
+
typeOf: '$typeOf'
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
{ $sort: { duration: 1 } },
|
|
708
|
+
{
|
|
709
|
+
$group: {
|
|
710
|
+
_id: '$typeOf',
|
|
711
|
+
durations: { $push: '$duration' }
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
$project: {
|
|
716
|
+
_id: 0,
|
|
717
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
718
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
719
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
720
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
721
|
+
return {
|
|
722
|
+
name: String(rank.percentile),
|
|
723
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
724
|
+
};
|
|
725
|
+
})
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
])
|
|
729
|
+
.exec();
|
|
730
|
+
return {
|
|
731
|
+
status: transactionStatus,
|
|
732
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
733
|
+
};
|
|
734
|
+
});
|
|
735
|
+
}
|
|
603
736
|
}
|
|
604
737
|
exports.MongoRepository = MongoRepository;
|
package/lib/chevre/repo/trip.js
CHANGED
|
@@ -32,18 +32,46 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
35
|
-
var _a, _b, _c;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f;
|
|
36
36
|
const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
|
|
37
37
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
38
|
if (typeof projectIdEq === 'string') {
|
|
39
|
-
andConditions.push({
|
|
40
|
-
'project.id': { $eq: projectIdEq }
|
|
41
|
-
});
|
|
39
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
42
40
|
}
|
|
43
41
|
const idIn = (_c = conditions.id) === null || _c === void 0 ? void 0 : _c.$in;
|
|
44
42
|
if (Array.isArray(idIn)) {
|
|
43
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
44
|
+
}
|
|
45
|
+
const identifierEq = (_d = conditions.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
46
|
+
if (typeof identifierEq === 'string') {
|
|
47
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
48
|
+
}
|
|
49
|
+
const nameRegex = (_e = conditions.name) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
50
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
51
|
+
andConditions.push({
|
|
52
|
+
$or: [
|
|
53
|
+
{
|
|
54
|
+
'name.ja': {
|
|
55
|
+
$exists: true,
|
|
56
|
+
$regex: new RegExp(nameRegex)
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
'name.en': {
|
|
61
|
+
$exists: true,
|
|
62
|
+
$regex: new RegExp(nameRegex)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const additionalPropertyElemMatch = (_f = conditions.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
|
|
69
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
45
70
|
andConditions.push({
|
|
46
|
-
|
|
71
|
+
additionalProperty: {
|
|
72
|
+
$exists: true,
|
|
73
|
+
$elemMatch: additionalPropertyElemMatch
|
|
74
|
+
}
|
|
47
75
|
});
|
|
48
76
|
}
|
|
49
77
|
return andConditions;
|
|
@@ -119,28 +147,6 @@ class MongoRepository {
|
|
|
119
147
|
if (p.attributes.typeOf === factory.tripType.BusTrip) {
|
|
120
148
|
// 上書き禁止属性を除外
|
|
121
149
|
const _a = p.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
122
|
-
bulkWriteOps.push({
|
|
123
|
-
updateOne: {
|
|
124
|
-
filter: {
|
|
125
|
-
_id: p.id,
|
|
126
|
-
typeOf: p.attributes.typeOf
|
|
127
|
-
},
|
|
128
|
-
// upsertの場合、createがありうるので属性を除外しない
|
|
129
|
-
update: Object.assign({ $setOnInsert: {
|
|
130
|
-
typeOf: p.attributes.typeOf,
|
|
131
|
-
project: p.attributes.project,
|
|
132
|
-
identifier: p.attributes.identifier
|
|
133
|
-
// ...(typeof p.attributes.remainingAttendeeCapacity === 'number')
|
|
134
|
-
// ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
|
|
135
|
-
// : undefined
|
|
136
|
-
}, $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
|
|
137
|
-
upsert
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else if (p.attributes.typeOf === factory.tripType.BusTripSeries) {
|
|
142
|
-
// 上書き禁止属性を除外
|
|
143
|
-
const _b = p.attributes, { identifier, project, typeOf } = _b, updateFields = __rest(_b, ["identifier", "project", "typeOf"]);
|
|
144
150
|
bulkWriteOps.push({
|
|
145
151
|
updateOne: {
|
|
146
152
|
filter: {
|
|
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
|
7
7
|
import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
|
|
8
8
|
import { MongoRepository as ActionRepo } from './repo/action';
|
|
9
9
|
import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
10
|
+
import { MongoRepository as AggregationRepo } from './repo/aggregation';
|
|
10
11
|
import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
|
|
11
12
|
import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
|
|
12
13
|
import { MongoRepository as CodeRepo } from './repo/code';
|
|
@@ -69,6 +70,8 @@ export declare class Action extends ActionRepo {
|
|
|
69
70
|
*/
|
|
70
71
|
export declare class AdditionalProperty extends AdditionalPropertyRepo {
|
|
71
72
|
}
|
|
73
|
+
export declare class Aggregation extends AggregationRepo {
|
|
74
|
+
}
|
|
72
75
|
export declare namespace action {
|
|
73
76
|
class RegisterServiceInProgress extends RegisterServiceActionInProgress {
|
|
74
77
|
}
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
3
|
+
exports.rateLimit = exports.itemAvailability = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
|
|
|
11
11
|
const accountTransaction_1 = require("./repo/accountTransaction");
|
|
12
12
|
const action_1 = require("./repo/action");
|
|
13
13
|
const additionalProperty_1 = require("./repo/additionalProperty");
|
|
14
|
+
const aggregation_1 = require("./repo/aggregation");
|
|
14
15
|
const assetTransaction_1 = require("./repo/assetTransaction");
|
|
15
16
|
const categoryCode_1 = require("./repo/categoryCode");
|
|
16
17
|
const code_1 = require("./repo/code");
|
|
@@ -80,6 +81,9 @@ exports.Action = Action;
|
|
|
80
81
|
class AdditionalProperty extends additionalProperty_1.MongoRepository {
|
|
81
82
|
}
|
|
82
83
|
exports.AdditionalProperty = AdditionalProperty;
|
|
84
|
+
class Aggregation extends aggregation_1.MongoRepository {
|
|
85
|
+
}
|
|
86
|
+
exports.Aggregation = Aggregation;
|
|
83
87
|
var action;
|
|
84
88
|
(function (action) {
|
|
85
89
|
class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
|
|
@@ -26,5 +26,5 @@ export declare function aggregateScreeningEvent(params: {
|
|
|
26
26
|
id: string;
|
|
27
27
|
}): IAggregateScreeningEventOperation<void>;
|
|
28
28
|
export declare function aggregateByEvent(params: {
|
|
29
|
-
event: factory.event.screeningEvent.IEvent;
|
|
29
|
+
event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
|
|
30
30
|
}): IAggregateScreeningEventOperation<void>;
|