@chevre/domain 22.5.0-alpha.8 → 22.5.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.
Files changed (160) hide show
  1. package/example/src/chevre/activateOptionalAggregationSettings.ts +19 -0
  2. package/example/src/chevre/aggregateAllEvents2.ts +7 -5
  3. package/example/src/chevre/aggregateEventPublicFields.ts +47 -0
  4. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +32 -0
  5. package/example/src/chevre/findReservationByCode.ts +11 -10
  6. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +101 -0
  7. package/example/src/chevre/migrateProjectMakesOfferAvailableAt.ts +85 -0
  8. package/example/src/chevre/person/cleanUpCognitoUsers.ts +90 -0
  9. package/example/src/chevre/searchCategoryCodesByAggregate.ts +1 -2
  10. package/example/src/chevre/searchOfferCatalogItems.ts +3 -2
  11. package/example/src/chevre/searchProjects.ts +2 -4
  12. package/example/src/chevre/searchSellersByAggregate.ts +4 -6
  13. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -19
  14. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +25 -14
  15. package/example/src/chevre/upsertProductsByProductId.ts +1 -1
  16. package/example/src/createMongooseConnection.ts +26 -0
  17. package/lib/chevre/repo/action.d.ts +41 -41
  18. package/lib/chevre/repo/action.js +5 -39
  19. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  20. package/lib/chevre/repo/categoryCode.d.ts +4 -8
  21. package/lib/chevre/repo/categoryCode.js +8 -36
  22. package/lib/chevre/repo/creativeWork.js +1 -20
  23. package/lib/chevre/repo/customer.d.ts +1 -1
  24. package/lib/chevre/repo/customer.js +4 -4
  25. package/lib/chevre/repo/event.d.ts +21 -12
  26. package/lib/chevre/repo/event.js +135 -37
  27. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +54 -0
  28. package/lib/chevre/repo/eventSellerMakesOffer.js +73 -0
  29. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -3
  30. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +0 -3
  31. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +0 -3
  32. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +0 -3
  33. package/lib/chevre/repo/mongoose/schemas/customer.js +0 -3
  34. package/lib/chevre/repo/mongoose/schemas/event.js +9 -54
  35. package/lib/chevre/repo/mongoose/schemas/member.js +0 -3
  36. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -3
  37. package/lib/chevre/repo/mongoose/schemas/paymentService.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +0 -3
  39. package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -3
  40. package/lib/chevre/repo/mongoose/schemas/project.js +0 -3
  41. package/lib/chevre/repo/mongoose/schemas/reservation.js +0 -3
  42. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -3
  43. package/lib/chevre/repo/mongoose/schemas/trip.js +0 -3
  44. package/lib/chevre/repo/paymentService.d.ts +1 -1
  45. package/lib/chevre/repo/paymentService.js +0 -19
  46. package/lib/chevre/repo/place/movieTheater.js +1 -25
  47. package/lib/chevre/repo/product.js +1 -6
  48. package/lib/chevre/repo/project.d.ts +8 -2
  49. package/lib/chevre/repo/project.js +25 -26
  50. package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
  51. package/lib/chevre/repo/projectMakesOffer.js +5 -2
  52. package/lib/chevre/repo/role.js +0 -7
  53. package/lib/chevre/repo/seller.d.ts +18 -16
  54. package/lib/chevre/repo/seller.js +13 -31
  55. package/lib/chevre/repo/task.d.ts +12 -12
  56. package/lib/chevre/repo/transaction.d.ts +1 -1
  57. package/lib/chevre/repository.d.ts +5 -0
  58. package/lib/chevre/repository.js +15 -2
  59. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +4 -18
  60. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  61. package/lib/chevre/service/aggregation/project.js +1 -2
  62. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -4
  63. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  64. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -1
  65. package/lib/chevre/service/assetTransaction/reserve/start.js +11 -38
  66. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +4 -1
  67. package/lib/chevre/service/event.js +2 -2
  68. package/lib/chevre/service/moneyTransfer.js +1 -2
  69. package/lib/chevre/service/notification.d.ts +2 -4
  70. package/lib/chevre/service/notification.js +30 -9
  71. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -1
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -1
  74. package/lib/chevre/service/offer/event/authorize.js +2 -2
  75. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -85
  77. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +21 -257
  78. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
  79. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
  80. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +48 -0
  81. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +109 -0
  82. package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +38 -0
  83. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +95 -0
  84. package/lib/chevre/service/offer/event/searchOffersByIds.js +26 -20
  85. package/lib/chevre/service/offer/event.d.ts +4 -1
  86. package/lib/chevre/service/offer/event.js +6 -3
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  88. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +1 -1
  89. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +4 -4
  90. package/lib/chevre/service/offer/onEventChanged.d.ts +1 -13
  91. package/lib/chevre/service/offer/onEventChanged.js +64 -71
  92. package/lib/chevre/service/offer.d.ts +6 -0
  93. package/lib/chevre/service/offer.js +12 -15
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +7 -8
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  97. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +7 -8
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +8 -11
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +7 -8
  101. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +1 -4
  102. package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -7
  103. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  104. package/lib/chevre/service/order/placeOrder.js +1 -1
  105. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  106. package/lib/chevre/service/payment/any.js +1 -1
  107. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  108. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +0 -3
  109. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  110. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  111. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  112. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +50 -57
  113. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  114. package/lib/chevre/service/payment/paymentCard.js +0 -5
  115. package/lib/chevre/service/payment.d.ts +1 -1
  116. package/lib/chevre/service/report/telemetry.js +1 -1
  117. package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
  118. package/lib/chevre/service/reserve/cancelReservation.js +14 -6
  119. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  120. package/lib/chevre/service/reserve/factory.d.ts +2 -61
  121. package/lib/chevre/service/reserve/factory.js +0 -11
  122. package/lib/chevre/service/reserve/findByCode.js +0 -1
  123. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +19 -0
  124. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +64 -0
  125. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -4
  126. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +37 -61
  127. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +22 -76
  128. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +26 -28
  129. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +0 -3
  130. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +17 -50
  131. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +18 -0
  132. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +66 -0
  133. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  134. package/lib/chevre/service/reserve/useReservation.js +4 -4
  135. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
  136. package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
  137. package/lib/chevre/service/task/aggregateScreeningEvent.js +4 -2
  138. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +1 -1
  139. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +1 -5
  140. package/lib/chevre/service/task/deletePerson.d.ts +6 -0
  141. package/lib/chevre/service/task/deletePerson.js +420 -0
  142. package/lib/chevre/service/task/handleNotification.d.ts +3 -0
  143. package/lib/chevre/service/task/handleNotification.js +26 -0
  144. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  145. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  146. package/lib/chevre/service/task/triggerWebhook.js +2 -2
  147. package/lib/chevre/service/task.d.ts +3 -0
  148. package/lib/chevre/service/task.js +2 -0
  149. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  150. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +1 -3
  151. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
  152. package/lib/chevre/service/transaction/returnOrder/preStart.js +4 -3
  153. package/lib/chevre/settings/aggregation.d.ts +23 -0
  154. package/lib/chevre/settings/aggregation.js +17 -0
  155. package/lib/chevre/settings.d.ts +52 -38
  156. package/lib/chevre/settings.js +12 -13
  157. package/package.json +5 -7
  158. package/example/src/chevre/migratePayTransactionRecipes.ts +0 -252
  159. package/example/src/chevre/migrateProductHasOfferCatalog.ts +0 -80
  160. package/example/src/chevre/migrateProjectMakesOffer.ts +0 -78
@@ -26,37 +26,14 @@ const EventFactory = require("../factory/event");
26
26
  const event_1 = require("./mongoose/schemas/event");
27
27
  const errorHandler_1 = require("../errorHandler");
28
28
  const settings_1 = require("../settings");
29
- // export const keyOfMinimizedScreeningEvent: IKeyOfProjection<factory.eventType.ScreeningEvent>[] = [
30
- // 'project', 'organizer', '_id', 'typeOf',
31
- // // 'additionalProperty', // discontinue(2024-07-20~)
32
- // 'name',
33
- // 'doorTime', 'endDate', 'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'coaInfo', 'identifier'
34
- // ];
35
- // export const keyOfMinimizedEvent: IKeyOfProjection<factory.eventType.Event>[] = [
36
- // 'project', 'organizer', '_id', 'typeOf',
37
- // // 'additionalProperty', // discontinue(2024-07-20~)
38
- // 'name',
39
- // 'doorTime', 'endDate', 'eventStatus', 'location', 'startDate', 'offers', 'identifier'
40
- // ];
41
- // const PROJECTION_MINIMIZED_EVENT: {
42
- // [key in (IKeyOfProjection<factory.eventType.ScreeningEvent> | IKeyOfProjection<factory.eventType.Event>)]?: 1
43
- // } = {
44
- // project: 1,
45
- // organizer: 1,
46
- // _id: 1,
47
- // typeOf: 1,
48
- // // additionalProperty: 1, // discontinue(2024-07-20~)
49
- // name: 1,
50
- // doorTime: 1,
51
- // endDate: 1,
52
- // eventStatus: 1,
53
- // location: 1,
54
- // startDate: 1,
55
- // superEvent: 1,
56
- // offers: 1,
57
- // coaInfo: 1,
58
- // identifier: 1
59
- // };
29
+ const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
30
+ 'additionalProperty', 'aggregateReservation', 'attendeeCount', 'checkInCount', 'coaInfo',
31
+ // 'description',
32
+ 'doorTime', 'endDate', 'eventStatus', 'identifier', 'location',
33
+ 'maximumAttendeeCapacity', 'name',
34
+ // 'offers',
35
+ 'organizer', 'project', 'remainingAttendeeCapacity', 'startDate', 'superEvent', 'typeOf'
36
+ ];
60
37
  /**
61
38
  * イベントリポジトリ
62
39
  */
@@ -410,8 +387,10 @@ class EventRepo {
410
387
  * 施設コンテンツとルームは1つに限定
411
388
  * 存在すれば、特定の属性のみ更新する
412
389
  */
390
+ // tslint:disable-next-line:max-func-body-length
413
391
  upsertManyByAdditionalProperty(params) {
414
392
  return __awaiter(this, void 0, void 0, function* () {
393
+ const { updateOffersSeller } = params.options;
415
394
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
416
395
  const bulkWriteOps = [];
417
396
  const additionalProperties = [];
@@ -429,7 +408,7 @@ class EventRepo {
429
408
  additionalProperties.push({ name: additionalPropertyFilter.name, value: additionalPropertyValue });
430
409
  const { coaInfo, // ←適用しない
431
410
  maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
432
- eventStatus, superEvent } = creatingEventParams, setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
411
+ eventStatus, superEvent, offers } = creatingEventParams, setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent", "offers"]);
433
412
  if (superEvent.id !== eventSeries.id) {
434
413
  throw new factory.errors.Argument('superEvent.id', 'superEvent.id not matched');
435
414
  }
@@ -447,17 +426,23 @@ class EventRepo {
447
426
  },
448
427
  'superEvent.id': { $exists: true, $eq: superEvent.id } // add superEvent.id(2024-09-15~)
449
428
  };
450
- const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() });
429
+ let setOnInsert;
430
+ if (updateOffersSeller) {
431
+ setOnInsert = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, setOnInsertFields), { 'offers.typeOf': offers.typeOf, 'offers.eligibleQuantity': offers.eligibleQuantity, 'offers.itemOffered': offers.itemOffered }), (offers.offeredThrough !== undefined) ? { 'offers.offeredThrough': offers.offeredThrough } : undefined), (offers.unacceptedPaymentMethod !== undefined)
432
+ ? { 'offers.unacceptedPaymentMethod': offers.unacceptedPaymentMethod }
433
+ : undefined), { _id: uniqid() });
434
+ }
435
+ else {
436
+ setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { offers, _id: uniqid() });
437
+ }
451
438
  bulkWriteOps.push({
452
439
  updateOne: {
453
440
  filter,
454
441
  update: {
455
442
  $setOnInsert: setOnInsert,
456
443
  // 変更可能な属性のみ上書き
457
- $set: {
458
- eventStatus,
459
- superEvent // add superEvent(2024-09-15~)
460
- }
444
+ $set: Object.assign({ eventStatus,
445
+ superEvent }, (updateOffersSeller) ? { 'offers.seller': offers.seller } : undefined)
461
446
  },
462
447
  upsert: true
463
448
  }
@@ -681,6 +666,119 @@ class EventRepo {
681
666
  .exec();
682
667
  });
683
668
  }
669
+ /**
670
+ * apiで公開属性を検索する(2024-10-13~)
671
+ */
672
+ aggregatePublicFields(params, inclusion, options) {
673
+ var _a, _b;
674
+ return __awaiter(this, void 0, void 0, function* () {
675
+ const { includeOffers, includeSellerMakesOffer, sellerMakesOfferAvailableAtIn } = options;
676
+ const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
677
+ let projection;
678
+ let positiveProjectionFields;
679
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
680
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PUBLIC_PROJECT_FIELDS.includes(key));
681
+ projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
682
+ if (includeOffers) {
683
+ projection = Object.assign(Object.assign(Object.assign({}, projection), { 'offers.typeOf': 1,
684
+ // 'offers.availabilityEnds': 1,
685
+ // 'offers.availabilityStarts': 1,
686
+ 'offers.eligibleQuantity': 1, 'offers.itemOffered': 1, 'offers.offeredThrough': 1,
687
+ // 'offers.validFrom': 1,
688
+ // 'offers.validThrough': 1,
689
+ 'offers.unacceptedPaymentMethod': 1, 'offers.seller.typeOf': 1, 'offers.seller.id': 1, 'offers.seller.name': 1 }), (includeSellerMakesOffer)
690
+ ? Object.assign({}, (Array.isArray(sellerMakesOfferAvailableAtIn))
691
+ ? {
692
+ 'offers.seller.makesOffer': {
693
+ $filter: {
694
+ input: '$offers.seller.makesOffer',
695
+ as: 'sellerMakesOffer',
696
+ cond: { $in: ['$$sellerMakesOffer.availableAtOrFrom.id', sellerMakesOfferAvailableAtIn] }
697
+ }
698
+ }
699
+ }
700
+ : { 'offers.seller.makesOffer': 1 }) : undefined);
701
+ }
702
+ }
703
+ else {
704
+ // discontinue(2024-07-24~)
705
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
706
+ }
707
+ const aggregate = this.eventModel.aggregate([
708
+ { $match: { $and: conditions } },
709
+ ...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined)
710
+ ? [{ $sort: { startDate: params.sort.startDate } }]
711
+ : [],
712
+ { $project: projection }
713
+ ]);
714
+ if (typeof params.limit === 'number' && params.limit > 0) {
715
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
716
+ aggregate.limit(params.limit * page)
717
+ .skip(params.limit * (page - 1));
718
+ }
719
+ // tslint:disable-next-line:no-single-line-block-comment
720
+ /* istanbul ignore else */
721
+ if (((_b = params.sort) === null || _b === void 0 ? void 0 : _b.startDate) !== undefined) {
722
+ aggregate.sort({ startDate: params.sort.startDate });
723
+ }
724
+ return aggregate
725
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
726
+ .exec();
727
+ });
728
+ }
729
+ // public async aggregateFields<T extends AvailableEventType>(
730
+ // params: ISearchConditions<T>,
731
+ // inclusion: IKeyOfProjection<T>[],
732
+ // makesOffer?: { $filter: { availableAtOrFrom: { id: { $in: string[] } } } }
733
+ // ): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]> {
734
+ // const conditions = EventRepo.CREATE_MONGO_CONDITIONS<T>(params);
735
+ // const makesOfferAvailableAtOrFromIdIn = makesOffer?.$filter.availableAtOrFrom.id.$in;
736
+ // let projection: ProjectionType<factory.event.IEvent<T>> = {};
737
+ // const positiveProjectionFields: IKeyOfProjection<T>[] = (Array.isArray(inclusion))
738
+ // ? inclusion.filter((key) => key !== 'id' && key !== '_id')
739
+ // : [];
740
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
741
+ // projection = {
742
+ // _id: 0,
743
+ // id: { $toString: '$_id' },
744
+ // ...(Array.isArray(makesOfferAvailableAtOrFromIdIn))
745
+ // ? {
746
+ // offerByClient: {
747
+ // $filter: {
748
+ // input: '$offers.seller.makesOffer',
749
+ // as: 'item',
750
+ // // cond: { $in: [makesOfferAvailableAtOrFromIdIn, '$$item.availableAtOrFrom.id'] }
751
+ // // cond: { $eq: [$arrayElemAt: [ "'$$item.availableAtOrFrom.$.id'", 0 ], ] }
752
+ // cond: { $in: ['$$item.availableAtOrFrom', makesOfferAvailableAtOrFromIdIn.map((id) => ([{ id }]))] }
753
+ // }
754
+ // }
755
+ // }
756
+ // : undefined,
757
+ // ...Object.fromEntries<1>(positiveProjectionFields.map((key) => ([key, 1])))
758
+ // };
759
+ // } else {
760
+ // // discontinue(2024-07-24~)
761
+ // throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
762
+ // }
763
+ // const aggregate = this.eventModel.aggregate<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>>([
764
+ // { $match: { $and: conditions } },
765
+ // // { $sort: { _id: factory.sortType.Ascending } },
766
+ // { $project: projection }
767
+ // ]);
768
+ // if (typeof params.limit === 'number' && params.limit > 0) {
769
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
770
+ // aggregate.limit(params.limit * page)
771
+ // .skip(params.limit * (page - 1));
772
+ // }
773
+ // // tslint:disable-next-line:no-single-line-block-comment
774
+ // /* istanbul ignore else */
775
+ // if (params.sort?.startDate !== undefined) {
776
+ // aggregate.sort({ startDate: params.sort.startDate });
777
+ // }
778
+ // return aggregate
779
+ // .option({ maxTimeMS: MONGO_MAX_TIME_MS })
780
+ // .exec();
781
+ // }
684
782
  /**
685
783
  * IDのみで検索する
686
784
  * projectionなし
@@ -0,0 +1,54 @@
1
+ import type { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ type IAggregateMakesOfferResult = Pick<factory.event.screeningEvent.ISellerMakesOffer, 'availabilityEnds' | 'availabilityStarts' | 'validFrom' | 'validThrough'> & {
4
+ itemOffered: {
5
+ serviceOutput: {
6
+ reservationFor: {
7
+ /**
8
+ * イベントID
9
+ */
10
+ id: string;
11
+ };
12
+ };
13
+ };
14
+ };
15
+ /**
16
+ * イベントの販売者makesOfferリポジトリ
17
+ */
18
+ export declare class EventSellerMakesOfferRepo {
19
+ private readonly eventModel;
20
+ constructor(connection: Connection);
21
+ /**
22
+ * 指定クライアントのオファーを集計する(2024-10-09~)
23
+ */
24
+ aggregateMakesOffer(conditions: {
25
+ limit?: number;
26
+ page?: number;
27
+ project: {
28
+ id: {
29
+ $eq: string;
30
+ };
31
+ };
32
+ /**
33
+ * アプリケーション(指定必須)
34
+ */
35
+ availableAtOrFrom: {
36
+ id: {
37
+ $eq: string;
38
+ };
39
+ };
40
+ itemOffered: {
41
+ serviceOutput: {
42
+ reservationFor: {
43
+ /**
44
+ * イベントID
45
+ */
46
+ id: {
47
+ $in?: string[];
48
+ };
49
+ };
50
+ };
51
+ };
52
+ }): Promise<IAggregateMakesOfferResult[]>;
53
+ }
54
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EventSellerMakesOfferRepo = void 0;
13
+ const factory = require("../factory");
14
+ const settings_1 = require("../settings");
15
+ const event_1 = require("./mongoose/schemas/event");
16
+ /**
17
+ * イベントの販売者makesOfferリポジトリ
18
+ */
19
+ class EventSellerMakesOfferRepo {
20
+ constructor(connection) {
21
+ this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
22
+ }
23
+ /**
24
+ * 指定クライアントのオファーを集計する(2024-10-09~)
25
+ */
26
+ aggregateMakesOffer(conditions) {
27
+ var _a;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const { availableAtOrFrom } = conditions;
30
+ if (typeof ((_a = availableAtOrFrom === null || availableAtOrFrom === void 0 ? void 0 : availableAtOrFrom.id) === null || _a === void 0 ? void 0 : _a.$eq) !== 'string' || availableAtOrFrom.id.$eq === '') {
31
+ throw new factory.errors.ArgumentNull('availableAtOrFrom.id.$eq');
32
+ }
33
+ const matchStages = [
34
+ { $match: { 'project.id': { $eq: conditions.project.id.$eq } } },
35
+ { $match: { 'offers.seller.makesOffer.availableAtOrFrom.id': { $exists: true, $eq: availableAtOrFrom.id.$eq } } }
36
+ ];
37
+ const reservationForIdIn = conditions.itemOffered.serviceOutput.reservationFor.id.$in;
38
+ if (Array.isArray(reservationForIdIn)) {
39
+ matchStages.push({ $match: { _id: { $in: reservationForIdIn } } });
40
+ }
41
+ const aggregate = this.eventModel.aggregate([
42
+ { $unwind: '$offers.seller.makesOffer' },
43
+ ...matchStages,
44
+ { $sort: { _id: factory.sortType.Ascending } },
45
+ {
46
+ $project: {
47
+ _id: 0,
48
+ availabilityEnds: '$offers.seller.makesOffer.availabilityEnds',
49
+ availabilityStarts: '$offers.seller.makesOffer.availabilityStarts',
50
+ validFrom: '$offers.seller.makesOffer.validFrom',
51
+ validThrough: '$offers.seller.makesOffer.validThrough',
52
+ itemOffered: {
53
+ serviceOutput: {
54
+ reservationFor: {
55
+ id: { $toString: '$_id' }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ]);
62
+ if (typeof conditions.limit === 'number' && conditions.limit > 0) {
63
+ const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
64
+ aggregate.limit(conditions.limit * page)
65
+ .skip(conditions.limit * (page - 1));
66
+ }
67
+ return aggregate
68
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
69
+ .exec();
70
+ });
71
+ }
72
+ }
73
+ exports.EventSellerMakesOfferRepo = EventSellerMakesOfferRepo;
@@ -12,9 +12,6 @@ const schemaDefinition = {
12
12
  reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
13
  aggregateEntranceGate: mongoose_1.SchemaTypes.Mixed,
14
14
  aggregateOffer: mongoose_1.SchemaTypes.Mixed
15
- // createdAt: SchemaTypes.Mixed,
16
- // updatedAt: SchemaTypes.Mixed,
17
- // __v: SchemaTypes.Mixed
18
15
  };
19
16
  const schemaOptions = {
20
17
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -7,9 +7,6 @@ const settings_1 = require("../../../settings");
7
7
  const modelName = 'AssetTransaction';
8
8
  exports.modelName = modelName;
9
9
  const schemaDefinition = {
10
- // __v: SchemaTypes.Mixed,
11
- // createdAt: SchemaTypes.Mixed,
12
- // updatedAt: SchemaTypes.Mixed,
13
10
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
14
11
  status: { type: String, required: true },
15
12
  typeOf: { type: String, required: true },
@@ -22,9 +22,6 @@ const schemaDefinition = {
22
22
  inCodeSet: mongoose_1.SchemaTypes.Mixed,
23
23
  name: mongoose_1.SchemaTypes.Mixed,
24
24
  paymentMethod: mongoose_1.SchemaTypes.Mixed
25
- // createdAt: SchemaTypes.Mixed,
26
- // updatedAt: SchemaTypes.Mixed,
27
- // __v: SchemaTypes.Mixed
28
25
  };
29
26
  const schemaOptions = {
30
27
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -28,9 +28,6 @@ const schemaDefinition = {
28
28
  contentRating: String,
29
29
  offers: mongoose_1.SchemaTypes.Mixed,
30
30
  additionalProperty: mongoose_1.SchemaTypes.Mixed
31
- // createdAt: SchemaTypes.Mixed,
32
- // updatedAt: SchemaTypes.Mixed,
33
- // __v: SchemaTypes.Mixed
34
31
  };
35
32
  const schemaOptions = {
36
33
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -19,9 +19,6 @@ const schemaDefinition = {
19
19
  },
20
20
  url: String,
21
21
  telephone: String
22
- // createdAt: SchemaTypes.Mixed,
23
- // updatedAt: SchemaTypes.Mixed,
24
- // __v: SchemaTypes.Mixed
25
22
  };
26
23
  const schemaOptions = {
27
24
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -165,60 +165,6 @@ const indexes = [
165
165
  { endDate: 1, startDate: 1 },
166
166
  { name: 'searchByEndDate' }
167
167
  ],
168
- [
169
- { 'hasOfferCatalog.id': 1, startDate: 1 },
170
- {
171
- name: 'searchByHasOfferCatalog',
172
- partialFilterExpression: {
173
- 'hasOfferCatalog.id': { $exists: true }
174
- }
175
- }
176
- ],
177
- [
178
- { 'offers.availabilityEnds': 1, startDate: 1 },
179
- {
180
- name: 'searchByOffersAvailabilityEnds-v2',
181
- partialFilterExpression: {
182
- 'offers.availabilityEnds': { $exists: true }
183
- }
184
- }
185
- ],
186
- [
187
- { 'offers.availabilityStarts': 1, startDate: 1 },
188
- {
189
- name: 'searchByOffersAvailabilityStarts-v2',
190
- partialFilterExpression: {
191
- 'offers.availabilityStarts': { $exists: true }
192
- }
193
- }
194
- ],
195
- [
196
- { 'offers.validThrough': 1, startDate: 1 },
197
- {
198
- name: 'searchByOffersValidThrough-v2',
199
- partialFilterExpression: {
200
- 'offers.validThrough': { $exists: true }
201
- }
202
- }
203
- ],
204
- [
205
- { 'offers.validFrom': 1, startDate: 1 },
206
- {
207
- name: 'searchByOffersValidFrom-v2',
208
- partialFilterExpression: {
209
- 'offers.validFrom': { $exists: true }
210
- }
211
- }
212
- ],
213
- [
214
- { 'offers.id': 1, startDate: 1 },
215
- {
216
- name: 'searchByOffersId-v2',
217
- partialFilterExpression: {
218
- 'offers.id': { $exists: true }
219
- }
220
- }
221
- ],
222
168
  [
223
169
  {
224
170
  'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': 1,
@@ -264,6 +210,15 @@ const indexes = [
264
210
  }
265
211
  }
266
212
  ],
213
+ [
214
+ { 'offers.seller.makesOffer.availableAtOrFrom.id': 1, startDate: 1 },
215
+ {
216
+ name: 'sellerMakesOfferAvailableAtOrFromId',
217
+ partialFilterExpression: {
218
+ 'offers.seller.makesOffer.availableAtOrFrom.id': { $exists: true }
219
+ }
220
+ }
221
+ ],
267
222
  [
268
223
  { 'name.ja': 1, startDate: 1 },
269
224
  {
@@ -19,9 +19,6 @@ const schemaDefinition = {
19
19
  type: mongoose_1.SchemaTypes.Mixed,
20
20
  required: true
21
21
  }
22
- // __v: SchemaTypes.Mixed,
23
- // createdAt: SchemaTypes.Mixed,
24
- // updatedAt: SchemaTypes.Mixed
25
22
  };
26
23
  const schemaOptions = {
27
24
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -22,9 +22,6 @@ const schemaDefinition = {
22
22
  ownedFrom: Date,
23
23
  ownedThrough: Date,
24
24
  typeOfGood: mongoose_1.SchemaTypes.Mixed
25
- // __v: SchemaTypes.Mixed,
26
- // createdAt: SchemaTypes.Mixed,
27
- // updatedAt: SchemaTypes.Mixed
28
25
  };
29
26
  const schemaOptions = {
30
27
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -17,9 +17,6 @@ const schemaDefinition = {
17
17
  provider: [mongoose_1.SchemaTypes.Mixed],
18
18
  serviceOutput: mongoose_1.SchemaTypes.Mixed,
19
19
  serviceType: mongoose_1.SchemaTypes.Mixed
20
- // __v: SchemaTypes.Mixed,
21
- // createdAt: SchemaTypes.Mixed,
22
- // updatedAt: SchemaTypes.Mixed
23
20
  };
24
21
  const schemaOptions = {
25
22
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -20,9 +20,6 @@ const schemaDefinition = {
20
20
  appliesToCategoryCode: mongoose_1.SchemaTypes.Mixed,
21
21
  appliesToMovieTicket: mongoose_1.SchemaTypes.Mixed,
22
22
  appliesToVideoFormat: String
23
- // createdAt: SchemaTypes.Mixed,
24
- // updatedAt: SchemaTypes.Mixed,
25
- // __v: SchemaTypes.Mixed
26
23
  };
27
24
  const schemaOptions = {
28
25
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -12,9 +12,6 @@ const schemaDefinition = {
12
12
  category: mongoose_1.SchemaTypes.Mixed,
13
13
  name: mongoose_1.SchemaTypes.Mixed,
14
14
  offers: mongoose_1.SchemaTypes.Mixed
15
- // createdAt: SchemaTypes.Mixed,
16
- // updatedAt: SchemaTypes.Mixed,
17
- // __v: SchemaTypes.Mixed
18
15
  };
19
16
  const schemaOptions = {
20
17
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -20,9 +20,6 @@ const schemaDefinition = {
20
20
  type: String,
21
21
  required: true
22
22
  }
23
- // createdAt: SchemaTypes.Mixed,
24
- // updatedAt: SchemaTypes.Mixed,
25
- // __v: SchemaTypes.Mixed
26
23
  };
27
24
  const schemaOptions = {
28
25
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -50,9 +50,6 @@ const schemaDefinition = {
50
50
  attended: { type: Boolean, default: false },
51
51
  additionalProperty: mongoose_1.SchemaTypes.Mixed,
52
52
  issuedThrough: mongoose_1.SchemaTypes.Mixed
53
- // createdAt: SchemaTypes.Mixed,
54
- // updatedAt: SchemaTypes.Mixed,
55
- // __v: SchemaTypes.Mixed
56
53
  };
57
54
  const schemaOptions = {
58
55
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -22,9 +22,6 @@ const schemaDefinition = {
22
22
  },
23
23
  url: String,
24
24
  telephone: String
25
- // createdAt: SchemaTypes.Mixed,
26
- // updatedAt: SchemaTypes.Mixed,
27
- // __v: SchemaTypes.Mixed
28
25
  };
29
26
  const schemaOptions = {
30
27
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -12,9 +12,6 @@ const schemaDefinition = {
12
12
  type: String,
13
13
  required: true
14
14
  }
15
- // createdAt: SchemaTypes.Mixed,
16
- // updatedAt: SchemaTypes.Mixed,
17
- // __v: SchemaTypes.Mixed
18
15
  };
19
16
  const schemaOptions = {
20
17
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -76,7 +76,7 @@ export declare class PaymentServiceRepo {
76
76
  };
77
77
  typeOf: factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
78
78
  id: string;
79
- }): Promise<factory.product.IAvailableChannel>;
79
+ }): Promise<factory.service.paymentService.IAvailableChannel>;
80
80
  unsetUnnecessaryFields(params: {
81
81
  filter: any;
82
82
  $unset: any;
@@ -240,25 +240,6 @@ class PaymentServiceRepo {
240
240
  }
241
241
  }
242
242
  const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
243
- // let projection: { [key: string]: number } = {};
244
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
245
- // inclusion.forEach((field) => {
246
- // projection[field] = 1;
247
- // });
248
- // } else {
249
- // projection = {
250
- // __v: 0,
251
- // createdAt: 0,
252
- // updatedAt: 0,
253
- // offers: 0,
254
- // provider: 0 // paymentServiceProviderRepoへの完全移行につき除外(2023-12-20~)
255
- // };
256
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
257
- // exclusion.forEach((field) => {
258
- // projection[field] = 0;
259
- // });
260
- // }
261
- // }
262
243
  const query = this.paymentServiceModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
263
244
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
264
245
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
@@ -173,34 +173,10 @@ class MovieTheaterRepo {
173
173
  * 施設検索
174
174
  * redefine(2024-09-18~)
175
175
  */
176
- projectFields(params, inclusion
177
- // exclusion: IKeyOfProjection[]
178
- ) {
176
+ projectFields(params, inclusion) {
179
177
  var _a;
180
178
  return __awaiter(this, void 0, void 0, function* () {
181
179
  const conditions = MovieTheaterRepo.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
182
- // let projection: { [key: string]: number } = {};
183
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
184
- // inclusion.forEach((field) => {
185
- // if (String(field) !== 'containsPlace' && String(field) !== 'hasPOS') { // 除外(2023-10-26~)
186
- // projection[field] = 1;
187
- // }
188
- // });
189
- // } else {
190
- // projection = {
191
- // __v: 0,
192
- // createdAt: 0,
193
- // updatedAt: 0,
194
- // // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
195
- // containsPlace: 0,
196
- // hasPOS: 0 // 除外(2023-10-26~)
197
- // };
198
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
199
- // exclusion.forEach((field) => {
200
- // projection[field] = 0;
201
- // });
202
- // }
203
- // }
204
180
  let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
205
181
  if (Array.isArray(inclusion) && inclusion.length > 0) {
206
182
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));