@chevre/domain 23.2.0-alpha.61 → 23.2.0-alpha.63

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 (481) hide show
  1. package/lib/chevre/credentials/customSearch.js +2 -0
  2. package/lib/chevre/credentials/lineNotify.js +4 -0
  3. package/lib/chevre/credentials/sendGrid.js +2 -0
  4. package/lib/chevre/credentials.js +15 -30
  5. package/lib/chevre/emailMessageBuilder.js +225 -250
  6. package/lib/chevre/errorHandler.js +38 -59
  7. package/lib/chevre/eventEmitter/assetTransaction.js +0 -1
  8. package/lib/chevre/eventEmitter/task.js +0 -1
  9. package/lib/chevre/eventEmitter/transaction.js +0 -1
  10. package/lib/chevre/factory/event.js +69 -42
  11. package/lib/chevre/factory/transactionNumber.js +2 -2
  12. package/lib/chevre/index.js +15 -30
  13. package/lib/chevre/repo/acceptedOffer.js +177 -197
  14. package/lib/chevre/repo/acceptedPaymentMethod.js +131 -144
  15. package/lib/chevre/repo/account.js +194 -238
  16. package/lib/chevre/repo/accountTitle.js +9 -21
  17. package/lib/chevre/repo/accountTransaction.js +186 -193
  18. package/lib/chevre/repo/accountingReport.js +88 -107
  19. package/lib/chevre/repo/action.js +849 -883
  20. package/lib/chevre/repo/additionalProperty.js +64 -92
  21. package/lib/chevre/repo/advanceBookingRequirement.js +69 -91
  22. package/lib/chevre/repo/aggregateOffer.js +392 -430
  23. package/lib/chevre/repo/aggregateOrder.js +50 -62
  24. package/lib/chevre/repo/aggregateReservation.js +76 -89
  25. package/lib/chevre/repo/aggregation.js +42 -63
  26. package/lib/chevre/repo/assetTransaction.js +692 -729
  27. package/lib/chevre/repo/authorization.js +115 -134
  28. package/lib/chevre/repo/categoryCode.js +114 -147
  29. package/lib/chevre/repo/comment.js +73 -82
  30. package/lib/chevre/repo/concurrentLock.js +17 -29
  31. package/lib/chevre/repo/confirmationNumber.js +19 -35
  32. package/lib/chevre/repo/creativeWork.js +152 -180
  33. package/lib/chevre/repo/credentials.js +39 -51
  34. package/lib/chevre/repo/customer.js +64 -88
  35. package/lib/chevre/repo/customerType.js +52 -62
  36. package/lib/chevre/repo/emailMessage.js +51 -80
  37. package/lib/chevre/repo/event.js +640 -684
  38. package/lib/chevre/repo/eventOffer.js +122 -125
  39. package/lib/chevre/repo/eventSellerMakesOffer.js +64 -76
  40. package/lib/chevre/repo/eventSeries.js +207 -244
  41. package/lib/chevre/repo/identity.js +94 -107
  42. package/lib/chevre/repo/identityProvider.js +72 -96
  43. package/lib/chevre/repo/issuer.js +102 -135
  44. package/lib/chevre/repo/member.js +238 -259
  45. package/lib/chevre/repo/memberProgram.js +157 -177
  46. package/lib/chevre/repo/merchantReturnPolicy.js +61 -94
  47. package/lib/chevre/repo/message.js +122 -135
  48. package/lib/chevre/repo/mongoose/onIndexCreated.js +0 -1
  49. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/account.js +1 -1
  51. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -1
  52. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  53. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -1
  54. package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
  55. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +1 -1
  56. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -1
  57. package/lib/chevre/repo/mongoose/schemas/advanceBookingRequirement.js +1 -1
  58. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +1 -1
  59. package/lib/chevre/repo/mongoose/schemas/aggregateOrder.js +1 -1
  60. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
  61. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -1
  62. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -1
  63. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  64. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -1
  65. package/lib/chevre/repo/mongoose/schemas/civicStructure.js +1 -1
  66. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -1
  67. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -1
  68. package/lib/chevre/repo/mongoose/schemas/customerType.js +1 -1
  69. package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
  70. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +1 -1
  71. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +1 -1
  72. package/lib/chevre/repo/mongoose/schemas/identity.js +1 -1
  73. package/lib/chevre/repo/mongoose/schemas/identityProvider.js +1 -1
  74. package/lib/chevre/repo/mongoose/schemas/issuer.js +1 -1
  75. package/lib/chevre/repo/mongoose/schemas/member/global.js +1 -1
  76. package/lib/chevre/repo/mongoose/schemas/member.js +1 -1
  77. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -1
  78. package/lib/chevre/repo/mongoose/schemas/message.js +1 -1
  79. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +1 -1
  80. package/lib/chevre/repo/mongoose/schemas/note.js +1 -1
  81. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -1
  82. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
  83. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +1 -1
  84. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  85. package/lib/chevre/repo/mongoose/schemas/paymentService.js +1 -1
  86. package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.js +1 -1
  87. package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +1 -1
  88. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +1 -1
  89. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  90. package/lib/chevre/repo/mongoose/schemas/potentialAction.js +1 -1
  91. package/lib/chevre/repo/mongoose/schemas/product.js +1 -1
  92. package/lib/chevre/repo/mongoose/schemas/productModel.js +1 -1
  93. package/lib/chevre/repo/mongoose/schemas/productOffer.js +1 -1
  94. package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
  95. package/lib/chevre/repo/mongoose/schemas/reserveInterface.js +1 -1
  96. package/lib/chevre/repo/mongoose/schemas/role.js +1 -1
  97. package/lib/chevre/repo/mongoose/schemas/schedule.js +1 -1
  98. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -1
  99. package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +1 -1
  100. package/lib/chevre/repo/mongoose/schemas/service/availableHour.js +1 -1
  101. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -1
  102. package/lib/chevre/repo/mongoose/schemas/task.js +1 -2
  103. package/lib/chevre/repo/mongoose/schemas/ticket.js +1 -1
  104. package/lib/chevre/repo/mongoose/schemas/transaction.js +1 -1
  105. package/lib/chevre/repo/mongoose/schemas/transactionNumber.js +1 -1
  106. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -1
  107. package/lib/chevre/repo/mongoose/schemas/webSite.js +1 -1
  108. package/lib/chevre/repo/movieTicketType.js +67 -94
  109. package/lib/chevre/repo/note.js +143 -147
  110. package/lib/chevre/repo/noteAboutOrder.js +112 -113
  111. package/lib/chevre/repo/offer/unitPriceInCatalog.js +330 -314
  112. package/lib/chevre/repo/offerCatalog.js +302 -334
  113. package/lib/chevre/repo/offerCatalogItem.js +289 -317
  114. package/lib/chevre/repo/offerItemCondition.js +60 -85
  115. package/lib/chevre/repo/order.js +559 -607
  116. package/lib/chevre/repo/orderInTransaction.js +113 -136
  117. package/lib/chevre/repo/orderNumber.js +95 -112
  118. package/lib/chevre/repo/ownershipInfo.js +212 -240
  119. package/lib/chevre/repo/passport.js +93 -102
  120. package/lib/chevre/repo/paymentMethod/creditCard.js +151 -169
  121. package/lib/chevre/repo/paymentService.js +179 -200
  122. package/lib/chevre/repo/paymentServiceChannel.js +76 -100
  123. package/lib/chevre/repo/paymentServiceProvider.js +186 -201
  124. package/lib/chevre/repo/pendingReservation.js +272 -305
  125. package/lib/chevre/repo/permit.js +47 -42
  126. package/lib/chevre/repo/person.js +217 -256
  127. package/lib/chevre/repo/place/busStop.js +76 -106
  128. package/lib/chevre/repo/place/entranceGate.js +123 -128
  129. package/lib/chevre/repo/place/hasPOS.js +108 -120
  130. package/lib/chevre/repo/place/movieTheater.js +185 -220
  131. package/lib/chevre/repo/place/screeningRoom.js +339 -325
  132. package/lib/chevre/repo/place/seat.js +538 -481
  133. package/lib/chevre/repo/place/section.js +328 -296
  134. package/lib/chevre/repo/potentialAction.js +67 -87
  135. package/lib/chevre/repo/priceSpecification.js +102 -146
  136. package/lib/chevre/repo/product.js +203 -239
  137. package/lib/chevre/repo/productHasOfferCatalog.js +39 -50
  138. package/lib/chevre/repo/productModel.js +94 -127
  139. package/lib/chevre/repo/productOffer.js +119 -118
  140. package/lib/chevre/repo/project.js +123 -141
  141. package/lib/chevre/repo/projectMakesOffer.js +96 -108
  142. package/lib/chevre/repo/rateLimit/offer.js +43 -57
  143. package/lib/chevre/repo/reservation.js +369 -398
  144. package/lib/chevre/repo/reserveInterface.js +31 -42
  145. package/lib/chevre/repo/role.js +93 -112
  146. package/lib/chevre/repo/schedule.js +25 -36
  147. package/lib/chevre/repo/seller.js +114 -147
  148. package/lib/chevre/repo/sellerMakesOffer.js +95 -110
  149. package/lib/chevre/repo/sellerPaymentAccepted.js +92 -109
  150. package/lib/chevre/repo/sellerReturnPolicy.js +74 -97
  151. package/lib/chevre/repo/service/availableHour.js +27 -38
  152. package/lib/chevre/repo/serviceOutput.js +54 -67
  153. package/lib/chevre/repo/serviceOutputIdentifier.js +46 -58
  154. package/lib/chevre/repo/setting/jwt.js +40 -50
  155. package/lib/chevre/repo/setting.js +48 -48
  156. package/lib/chevre/repo/stockHolder.js +179 -199
  157. package/lib/chevre/repo/task.js +610 -619
  158. package/lib/chevre/repo/telemetry.js +1 -0
  159. package/lib/chevre/repo/ticket.js +52 -65
  160. package/lib/chevre/repo/transaction.js +754 -815
  161. package/lib/chevre/repo/transactionNumber.js +67 -80
  162. package/lib/chevre/repo/transactionNumberCounter.js +68 -79
  163. package/lib/chevre/repo/transactionProcess.js +36 -47
  164. package/lib/chevre/repo/trip.js +144 -164
  165. package/lib/chevre/repo/webSite.js +90 -106
  166. package/lib/chevre/repository.js +455 -647
  167. package/lib/chevre/service/account.js +9 -21
  168. package/lib/chevre/service/accountTransaction/deposit.js +16 -17
  169. package/lib/chevre/service/accountTransaction/transfer.js +18 -22
  170. package/lib/chevre/service/accountTransaction/withdraw.js +16 -17
  171. package/lib/chevre/service/accountTransaction.js +4 -16
  172. package/lib/chevre/service/aggregation/event/aggregateOffers.js +63 -60
  173. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +52 -55
  174. package/lib/chevre/service/aggregation/event/findEventOffers.js +7 -17
  175. package/lib/chevre/service/aggregation/event/importFromCOA.js +4 -14
  176. package/lib/chevre/service/aggregation/project.js +10 -19
  177. package/lib/chevre/service/aggregation/system.js +182 -99
  178. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +31 -17
  179. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +17 -24
  180. package/lib/chevre/service/assetTransaction/cancelReservation/startAndConfirm.js +17 -15
  181. package/lib/chevre/service/assetTransaction/cancelReservation.js +7 -18
  182. package/lib/chevre/service/assetTransaction/cancelReservationCOA/factory.js +11 -4
  183. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +4 -13
  184. package/lib/chevre/service/assetTransaction/fixInformAction.js +6 -16
  185. package/lib/chevre/service/assetTransaction/moneyTransfer/potentialActions.js +13 -25
  186. package/lib/chevre/service/assetTransaction/moneyTransfer.js +101 -90
  187. package/lib/chevre/service/assetTransaction/pay/cancel.js +3 -12
  188. package/lib/chevre/service/assetTransaction/pay/check.js +4 -14
  189. package/lib/chevre/service/assetTransaction/pay/confirm.js +18 -21
  190. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +4 -14
  191. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +33 -34
  192. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +7 -17
  193. package/lib/chevre/service/assetTransaction/pay/start/account/validation.js +6 -16
  194. package/lib/chevre/service/assetTransaction/pay/start/factory.js +64 -37
  195. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.js +7 -19
  196. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +6 -16
  197. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +7 -17
  198. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +9 -15
  199. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +3 -12
  200. package/lib/chevre/service/assetTransaction/pay/start.js +29 -35
  201. package/lib/chevre/service/assetTransaction/refund/factory.js +36 -16
  202. package/lib/chevre/service/assetTransaction/refund/potentialActions.js +12 -21
  203. package/lib/chevre/service/assetTransaction/refund.js +35 -41
  204. package/lib/chevre/service/assetTransaction/registerService/factory.js +65 -28
  205. package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +50 -43
  206. package/lib/chevre/service/assetTransaction/registerService.js +45 -56
  207. package/lib/chevre/service/assetTransaction/reserve/cancel.js +5 -14
  208. package/lib/chevre/service/assetTransaction/reserve/confirm/factory.js +15 -4
  209. package/lib/chevre/service/assetTransaction/reserve/confirm.js +21 -26
  210. package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +3 -13
  211. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +99 -83
  212. package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +17 -12
  213. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +108 -72
  214. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +69 -30
  215. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.js +29 -20
  216. package/lib/chevre/service/assetTransaction/reserve/start.js +91 -108
  217. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +5 -15
  218. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +41 -54
  219. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +42 -56
  220. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +7 -19
  221. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +15 -27
  222. package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +24 -24
  223. package/lib/chevre/service/assetTransaction/reserveCOA/factory.js +12 -4
  224. package/lib/chevre/service/assetTransaction/reserveCOA.js +4 -13
  225. package/lib/chevre/service/assetTransaction.js +17 -21
  226. package/lib/chevre/service/delivery/factory.js +3 -4
  227. package/lib/chevre/service/delivery/product/factory.js +16 -7
  228. package/lib/chevre/service/delivery/reservation/factory.js +14 -3
  229. package/lib/chevre/service/delivery.js +48 -52
  230. package/lib/chevre/service/event/processUpdateMovieTheater.js +21 -26
  231. package/lib/chevre/service/event/saveScreeningEventSeries.js +56 -41
  232. package/lib/chevre/service/event/saveScreeningEvents.js +14 -29
  233. package/lib/chevre/service/event.js +34 -30
  234. package/lib/chevre/service/iam.js +8 -17
  235. package/lib/chevre/service/moneyTransfer.js +128 -112
  236. package/lib/chevre/service/notification/factory.js +11 -10
  237. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +11 -15
  238. package/lib/chevre/service/notification/notifyByEmail.js +7 -19
  239. package/lib/chevre/service/notification/sendEmailMessage.js +23 -26
  240. package/lib/chevre/service/notification/triggerWebhook.js +58 -56
  241. package/lib/chevre/service/offer/any.js +6 -15
  242. package/lib/chevre/service/offer/event/authorize/factory.js +139 -63
  243. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +8 -19
  244. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +43 -27
  245. package/lib/chevre/service/offer/event/authorize.js +114 -71
  246. package/lib/chevre/service/offer/event/checkAvailability.js +5 -15
  247. package/lib/chevre/service/offer/event/importFromCOA/factory.js +9 -3
  248. package/lib/chevre/service/offer/event/importFromCOA.js +13 -19
  249. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +38 -39
  250. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +26 -41
  251. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +11 -22
  252. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +13 -26
  253. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +15 -23
  254. package/lib/chevre/service/offer/event/searchOffersByIds.js +24 -39
  255. package/lib/chevre/service/offer/event/searchPriceSpecs4event.js +5 -14
  256. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +4 -13
  257. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +6 -15
  258. package/lib/chevre/service/offer/event/voidTransaction.js +35 -41
  259. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +14 -20
  260. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +52 -42
  261. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +5 -1
  262. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +34 -37
  263. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +45 -26
  264. package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +67 -62
  265. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +16 -27
  266. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +8 -18
  267. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +42 -43
  268. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +22 -25
  269. package/lib/chevre/service/offer/factory.js +18 -8
  270. package/lib/chevre/service/offer/moneyTransfer/authorize.js +31 -36
  271. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +9 -18
  272. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +10 -19
  273. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +14 -24
  274. package/lib/chevre/service/offer/onEventChanged.js +69 -65
  275. package/lib/chevre/service/offer/product/factory.js +54 -32
  276. package/lib/chevre/service/offer/product/searchProductOffers.js +30 -24
  277. package/lib/chevre/service/offer/product.js +106 -82
  278. package/lib/chevre/service/offer.js +48 -45
  279. package/lib/chevre/service/order/confirmPayTransaction.js +28 -27
  280. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +54 -41
  281. package/lib/chevre/service/order/deleteOrder.js +28 -36
  282. package/lib/chevre/service/order/findPlaceOrderTransaction.js +3 -12
  283. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +64 -70
  284. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +1 -2
  285. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +3 -12
  286. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +11 -6
  287. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +5 -14
  288. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +22 -9
  289. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +5 -14
  290. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +23 -26
  291. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +13 -19
  292. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +5 -14
  293. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +24 -14
  294. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +23 -32
  295. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +8 -18
  296. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +10 -9
  297. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +23 -28
  298. package/lib/chevre/service/order/onOrderUpdated/factory.js +3 -5
  299. package/lib/chevre/service/order/onOrderUpdated.js +13 -15
  300. package/lib/chevre/service/order/payOrder.js +3 -12
  301. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +9 -20
  302. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +31 -15
  303. package/lib/chevre/service/order/placeOrder/factory.js +35 -22
  304. package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.js +3 -12
  305. package/lib/chevre/service/order/placeOrder.js +12 -23
  306. package/lib/chevre/service/order/placeOrderWithoutTransaction.js +10 -18
  307. package/lib/chevre/service/order/returnOrder.js +27 -30
  308. package/lib/chevre/service/order/sendOrder.js +37 -37
  309. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +19 -25
  310. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +24 -39
  311. package/lib/chevre/service/payment/any/factory.js +106 -50
  312. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -13
  313. package/lib/chevre/service/payment/any/onPayActionCompleted.js +13 -18
  314. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +34 -37
  315. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +18 -24
  316. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +16 -16
  317. package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +15 -21
  318. package/lib/chevre/service/payment/any/person2username.js +32 -45
  319. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +8 -18
  320. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +5 -17
  321. package/lib/chevre/service/payment/any.js +181 -142
  322. package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.js +2 -2
  323. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +44 -25
  324. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +6 -15
  325. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.js +5 -1
  326. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.js +10 -2
  327. package/lib/chevre/service/payment/creditCard/authorize.js +20 -22
  328. package/lib/chevre/service/payment/creditCard/factory.js +22 -4
  329. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +8 -18
  330. package/lib/chevre/service/payment/creditCard/payCreditCard.js +31 -36
  331. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +40 -51
  332. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +33 -45
  333. package/lib/chevre/service/payment/creditCard/voidTransaction.js +15 -26
  334. package/lib/chevre/service/payment/faceToFace.js +14 -23
  335. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +44 -25
  336. package/lib/chevre/service/payment/factory.js +50 -24
  337. package/lib/chevre/service/payment/movieTicket/authorize.js +35 -30
  338. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +22 -25
  339. package/lib/chevre/service/payment/movieTicket/factory.js +33 -10
  340. package/lib/chevre/service/payment/movieTicket/getCredentials.js +5 -15
  341. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +29 -40
  342. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +8 -18
  343. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +60 -60
  344. package/lib/chevre/service/payment/movieTicket/validation.js +41 -37
  345. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +8 -18
  346. package/lib/chevre/service/payment/paymentCard.js +87 -104
  347. package/lib/chevre/service/permit.js +36 -35
  348. package/lib/chevre/service/product.js +23 -28
  349. package/lib/chevre/service/project.js +22 -31
  350. package/lib/chevre/service/report/ownershipInfo.js +3 -4
  351. package/lib/chevre/service/report/telemetry.js +51 -70
  352. package/lib/chevre/service/reserve/cancelReservation.js +92 -93
  353. package/lib/chevre/service/reserve/checkInReservation.js +24 -29
  354. package/lib/chevre/service/reserve/confirmReservation.js +33 -39
  355. package/lib/chevre/service/reserve/factory.js +42 -20
  356. package/lib/chevre/service/reserve/findByCode.js +13 -18
  357. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +18 -24
  358. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +17 -25
  359. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +38 -30
  360. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +45 -37
  361. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +37 -33
  362. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +17 -23
  363. package/lib/chevre/service/reserve/searchByOrder.js +10 -20
  364. package/lib/chevre/service/reserve/useReservation.js +47 -34
  365. package/lib/chevre/service/reserve/verifyToken4reservation.js +7 -14
  366. package/lib/chevre/service/reserveCOA/cancelReservation.js +7 -17
  367. package/lib/chevre/service/reserveCOA/factory.js +5 -1
  368. package/lib/chevre/service/task/acceptCOAOffer.js +20 -25
  369. package/lib/chevre/service/task/aggregateOffers.js +3 -12
  370. package/lib/chevre/service/task/aggregateOnSystem.js +4 -14
  371. package/lib/chevre/service/task/aggregateScreeningEvent.js +3 -12
  372. package/lib/chevre/service/task/authorizePayment.js +9 -15
  373. package/lib/chevre/service/task/cancelMoneyTransfer.js +3 -12
  374. package/lib/chevre/service/task/cancelPendingReservation.js +10 -20
  375. package/lib/chevre/service/task/cancelReservation.js +3 -12
  376. package/lib/chevre/service/task/checkMovieTicket.js +16 -19
  377. package/lib/chevre/service/task/checkResource.js +7 -16
  378. package/lib/chevre/service/task/confirmMoneyTransfer.js +3 -12
  379. package/lib/chevre/service/task/confirmPayTransaction.js +6 -12
  380. package/lib/chevre/service/task/confirmRegisterService.js +3 -12
  381. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +24 -31
  382. package/lib/chevre/service/task/confirmReserveTransaction.js +48 -45
  383. package/lib/chevre/service/task/createAccountingReport.js +14 -20
  384. package/lib/chevre/service/task/deletePerson.js +48 -60
  385. package/lib/chevre/service/task/deleteTransaction.js +3 -12
  386. package/lib/chevre/service/task/givePointAward.js +3 -12
  387. package/lib/chevre/service/task/handleNotification.js +4 -14
  388. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +6 -16
  389. package/lib/chevre/service/task/importEventsFromCOA.js +6 -16
  390. package/lib/chevre/service/task/importOffersFromCOA.js +8 -18
  391. package/lib/chevre/service/task/invalidatePaymentUrl.js +6 -12
  392. package/lib/chevre/service/task/moneyTransfer.js +3 -12
  393. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +3 -12
  394. package/lib/chevre/service/task/onAuthorizationCreated.js +11 -19
  395. package/lib/chevre/service/task/onEventChanged.js +3 -12
  396. package/lib/chevre/service/task/onOrderPaymentCompleted.js +3 -12
  397. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +7 -16
  398. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +7 -16
  399. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +8 -17
  400. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +10 -19
  401. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +8 -17
  402. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +6 -15
  403. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +14 -24
  404. package/lib/chevre/service/task/onResourceDeleted.js +17 -27
  405. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +9 -21
  406. package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +3 -12
  407. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +11 -23
  408. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +13 -25
  409. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +9 -15
  410. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +21 -27
  411. package/lib/chevre/service/task/onResourceUpdated.js +113 -158
  412. package/lib/chevre/service/task/pay.js +8 -16
  413. package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.js +4 -14
  414. package/lib/chevre/service/task/payment/payByTask.js +49 -38
  415. package/lib/chevre/service/task/payment/refundByTask.js +7 -17
  416. package/lib/chevre/service/task/payment/voidPaymentByTask.js +6 -15
  417. package/lib/chevre/service/task/placeOrder.js +6 -12
  418. package/lib/chevre/service/task/publishPaymentUrl.js +9 -14
  419. package/lib/chevre/service/task/refund.js +8 -16
  420. package/lib/chevre/service/task/registerService.js +3 -12
  421. package/lib/chevre/service/task/reserve.js +3 -12
  422. package/lib/chevre/service/task/returnMoneyTransfer.js +3 -12
  423. package/lib/chevre/service/task/returnOrder.js +6 -12
  424. package/lib/chevre/service/task/returnPayTransaction.js +54 -49
  425. package/lib/chevre/service/task/returnPointAward.js +3 -12
  426. package/lib/chevre/service/task/returnReserveTransaction.js +29 -30
  427. package/lib/chevre/service/task/sendEmailMessage.js +6 -13
  428. package/lib/chevre/service/task/sendOrder.js +12 -15
  429. package/lib/chevre/service/task/syncResourcesFromCOA.js +39 -45
  430. package/lib/chevre/service/task/triggerWebhook.js +6 -12
  431. package/lib/chevre/service/task/useReservation.js +11 -14
  432. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +3 -12
  433. package/lib/chevre/service/task/voidPayTransaction.js +7 -12
  434. package/lib/chevre/service/task/voidPayment.js +3 -12
  435. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -12
  436. package/lib/chevre/service/task/voidReserveTransaction.js +10 -16
  437. package/lib/chevre/service/task.js +16 -26
  438. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +9 -20
  439. package/lib/chevre/service/taskHandler/onOperationFailed.js +20 -17
  440. package/lib/chevre/service/taskHandler.js +19 -22
  441. package/lib/chevre/service/transaction/deleteTransaction.js +104 -88
  442. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +15 -9
  443. package/lib/chevre/service/transaction/moneyTransfer/factory.js +13 -4
  444. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +12 -24
  445. package/lib/chevre/service/transaction/moneyTransfer.js +119 -98
  446. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +49 -51
  447. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +14 -25
  448. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +4 -14
  449. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +3 -4
  450. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.js +3 -6
  451. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -3
  452. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +30 -47
  453. package/lib/chevre/service/transaction/placeOrder/confirm.js +75 -59
  454. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +31 -15
  455. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +6 -15
  456. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +6 -15
  457. package/lib/chevre/service/transaction/placeOrder/publishOrderNumberIfNotExist.js +7 -16
  458. package/lib/chevre/service/transaction/placeOrder/start/factory.js +27 -7
  459. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +53 -60
  460. package/lib/chevre/service/transaction/placeOrder/start.js +14 -18
  461. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +13 -7
  462. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +176 -190
  463. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +75 -89
  464. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +40 -48
  465. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +52 -56
  466. package/lib/chevre/service/transaction/returnOrder/preStart/findApplicableReturnPolicy.js +100 -104
  467. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +60 -80
  468. package/lib/chevre/service/transaction/returnOrder/preStart.js +42 -47
  469. package/lib/chevre/service/transaction/returnOrder.js +32 -37
  470. package/lib/chevre/service/transaction.js +75 -46
  471. package/lib/chevre/service/validation/validateEvent.js +2 -11
  472. package/lib/chevre/service/validation/validateOrder.js +7 -18
  473. package/lib/chevre/service.js +85 -131
  474. package/lib/chevre/settings/aggregation.js +4 -0
  475. package/lib/chevre/settings.js +7 -1
  476. package/lib/index.js +0 -1
  477. package/package.json +6 -11
  478. package/example/src/chevre/addEventBySchedule.ts +0 -46
  479. package/example/src/idaas/auth0/adminApplications.ts +0 -183
  480. package/example/src/idaas/auth0/getToken.ts +0 -55
  481. package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +0 -84
@@ -1,24 +1,4 @@
1
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
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
2
  Object.defineProperty(exports, "__esModule", { value: true });
23
3
  exports.EventRepo = void 0;
24
4
  const mongoose_1 = require("mongoose");
@@ -39,6 +19,7 @@ const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
39
19
  * イベントリポジトリ
40
20
  */
41
21
  class EventRepo {
22
+ eventModel;
42
23
  constructor(connection) {
43
24
  this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
44
25
  }
@@ -50,9 +31,7 @@ class EventRepo {
50
31
  // return (USE_OBJECT_ID_AS_EVENT_ID) ? new Types.ObjectId().toHexString() : uniqid();
51
32
  return new mongoose_1.Types.ObjectId().toHexString(); // 設定を廃止(2025-11-20~)
52
33
  }
53
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
54
34
  static CREATE_MONGO_CONDITIONS(conditions) {
55
- 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;
56
35
  const andConditions = [];
57
36
  const typeOfEq = conditions.typeOf;
58
37
  if (typeof typeOfEq === 'string') {
@@ -66,19 +45,19 @@ class EventRepo {
66
45
  if (typeof typeOfEq !== 'string' && !Array.isArray(typeOfIn)) {
67
46
  throw new factory.errors.ArgumentNull('typeOf');
68
47
  }
69
- const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
48
+ const projectIdEq = conditions.project?.id?.$eq;
70
49
  if (typeof projectIdEq === 'string') {
71
50
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
72
51
  }
73
- const organizerIdEq = (_d = (_c = conditions.organizer) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
52
+ const organizerIdEq = conditions.organizer?.id?.$eq;
74
53
  if (typeof organizerIdEq === 'string') {
75
54
  andConditions.push({ 'organizer.id': { $exists: true, $eq: organizerIdEq } });
76
55
  }
77
- const idEq = (_e = conditions.id) === null || _e === void 0 ? void 0 : _e.$eq;
56
+ const idEq = conditions.id?.$eq;
78
57
  if (typeof idEq === 'string') {
79
58
  andConditions.push({ _id: { $eq: idEq } });
80
59
  }
81
- const idIn = (_f = conditions.id) === null || _f === void 0 ? void 0 : _f.$in;
60
+ const idIn = conditions.id?.$in;
82
61
  if (Array.isArray(idIn)) {
83
62
  andConditions.push({ _id: { $in: idIn } });
84
63
  }
@@ -86,64 +65,57 @@ class EventRepo {
86
65
  if (Array.isArray(identifierIn)) {
87
66
  andConditions.push({ identifier: { $exists: true, $in: identifierIn } });
88
67
  }
89
- // tslint:disable-next-line:no-single-line-block-comment
90
68
  /* istanbul ignore else */
91
69
  if (Array.isArray(conditions.eventStatuses)) {
92
70
  andConditions.push({
93
71
  eventStatus: { $in: conditions.eventStatuses }
94
72
  });
95
73
  }
96
- // tslint:disable-next-line:no-single-line-block-comment
97
74
  /* istanbul ignore else */
98
75
  if (conditions.inSessionFrom !== undefined) {
99
76
  andConditions.push({
100
77
  endDate: { $gte: conditions.inSessionFrom }
101
78
  });
102
79
  }
103
- // tslint:disable-next-line:no-single-line-block-comment
104
80
  /* istanbul ignore else */
105
81
  if (conditions.inSessionThrough !== undefined) {
106
82
  andConditions.push({
107
83
  startDate: { $lte: conditions.inSessionThrough }
108
84
  });
109
85
  }
110
- // tslint:disable-next-line:no-single-line-block-comment
111
86
  /* istanbul ignore else */
112
87
  if (conditions.startFrom !== undefined) {
113
88
  andConditions.push({
114
89
  startDate: { $gte: conditions.startFrom }
115
90
  });
116
91
  }
117
- // tslint:disable-next-line:no-single-line-block-comment
118
92
  /* istanbul ignore else */
119
93
  if (conditions.startThrough !== undefined) {
120
94
  andConditions.push({
121
95
  startDate: { $lte: conditions.startThrough }
122
96
  });
123
97
  }
124
- // tslint:disable-next-line:no-single-line-block-comment
125
98
  /* istanbul ignore else */
126
99
  if (conditions.endFrom !== undefined) {
127
100
  andConditions.push({
128
101
  endDate: { $gte: conditions.endFrom }
129
102
  });
130
103
  }
131
- // tslint:disable-next-line:no-single-line-block-comment
132
104
  /* istanbul ignore else */
133
105
  if (conditions.endThrough !== undefined) {
134
106
  andConditions.push({
135
107
  endDate: { $lte: conditions.endThrough }
136
108
  });
137
109
  }
138
- const locationBranchCodeEq = (_h = (_g = conditions.location) === null || _g === void 0 ? void 0 : _g.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
110
+ const locationBranchCodeEq = conditions.location?.branchCode?.$eq;
139
111
  if (typeof locationBranchCodeEq === 'string') {
140
112
  andConditions.push({ 'location.branchCode': { $exists: true, $eq: locationBranchCodeEq } });
141
113
  }
142
- const locationBranchCodeIn = (_k = (_j = conditions.location) === null || _j === void 0 ? void 0 : _j.branchCode) === null || _k === void 0 ? void 0 : _k.$in;
114
+ const locationBranchCodeIn = conditions.location?.branchCode?.$in;
143
115
  if (Array.isArray(locationBranchCodeIn)) {
144
116
  andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
145
117
  }
146
- const additionalPropertyElemMatch = (_l = conditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
118
+ const additionalPropertyElemMatch = conditions.additionalProperty?.$elemMatch;
147
119
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
148
120
  andConditions.push({
149
121
  additionalProperty: {
@@ -156,7 +128,6 @@ class EventRepo {
156
128
  switch (conditions.typeOf) {
157
129
  case factory.eventType.ScreeningEvent:
158
130
  params = conditions;
159
- // tslint:disable-next-line:no-single-line-block-comment
160
131
  /* istanbul ignore else */
161
132
  if (typeof params.name === 'string' && params.name.length > 0) {
162
133
  andConditions.push({
@@ -176,9 +147,8 @@ class EventRepo {
176
147
  ]
177
148
  });
178
149
  }
179
- // tslint:disable-next-line:no-single-line-block-comment
180
150
  /* istanbul ignore else */
181
- const superEventLocationIdEq = (_p = (_o = (_m = params.superEvent) === null || _m === void 0 ? void 0 : _m.location) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$eq;
151
+ const superEventLocationIdEq = params.superEvent?.location?.id?.$eq;
182
152
  if (typeof superEventLocationIdEq === 'string') {
183
153
  andConditions.push({
184
154
  'superEvent.location.id': {
@@ -187,10 +157,8 @@ class EventRepo {
187
157
  }
188
158
  });
189
159
  }
190
- // tslint:disable-next-line:no-single-line-block-comment
191
160
  /* istanbul ignore else */
192
161
  if (params.superEvent !== undefined) {
193
- // tslint:disable-next-line:no-single-line-block-comment
194
162
  /* istanbul ignore else */
195
163
  if (Array.isArray(params.superEvent.ids)) {
196
164
  andConditions.push({
@@ -200,7 +168,6 @@ class EventRepo {
200
168
  }
201
169
  });
202
170
  }
203
- // tslint:disable-next-line:no-single-line-block-comment
204
171
  /* istanbul ignore else */
205
172
  if (Array.isArray(params.superEvent.locationBranchCodes)) {
206
173
  andConditions.push({
@@ -210,7 +177,6 @@ class EventRepo {
210
177
  }
211
178
  });
212
179
  }
213
- // tslint:disable-next-line:no-single-line-block-comment
214
180
  /* istanbul ignore else */
215
181
  if (Array.isArray(params.superEvent.workPerformedIdentifiers)) {
216
182
  andConditions.push({
@@ -221,7 +187,7 @@ class EventRepo {
221
187
  });
222
188
  }
223
189
  }
224
- const itemOfferedIdIn = (_s = (_r = (_q = params.offers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.id) === null || _s === void 0 ? void 0 : _s.$in;
190
+ const itemOfferedIdIn = params.offers?.itemOffered?.id?.$in;
225
191
  if (Array.isArray(itemOfferedIdIn)) {
226
192
  andConditions.push({
227
193
  'offers.itemOffered.id': {
@@ -230,7 +196,7 @@ class EventRepo {
230
196
  }
231
197
  });
232
198
  }
233
- const itemOfferedTicketedSeatTypeOfIn = (_x = (_w = (_v = (_u = (_t = params.offers) === null || _t === void 0 ? void 0 : _t.itemOffered) === null || _u === void 0 ? void 0 : _u.serviceOutput) === null || _v === void 0 ? void 0 : _v.reservedTicket) === null || _w === void 0 ? void 0 : _w.ticketedSeat) === null || _x === void 0 ? void 0 : _x.typeOfs;
199
+ const itemOfferedTicketedSeatTypeOfIn = params.offers?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.typeOfs;
234
200
  if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
235
201
  andConditions.push({
236
202
  'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
@@ -239,7 +205,7 @@ class EventRepo {
239
205
  }
240
206
  });
241
207
  }
242
- const itemOfferedServiceTypeIdIn = (_0 = (_z = (_y = params.offers) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.serviceType) === null || _0 === void 0 ? void 0 : _0.ids;
208
+ const itemOfferedServiceTypeIdIn = params.offers?.itemOffered?.serviceType?.ids;
243
209
  if (Array.isArray(itemOfferedServiceTypeIdIn)) {
244
210
  andConditions.push({
245
211
  'offers.itemOffered.serviceType.id': {
@@ -248,8 +214,8 @@ class EventRepo {
248
214
  }
249
215
  });
250
216
  }
251
- const sellerMakesOfferElemMatch = (_3 = (_2 = (_1 = params.offers) === null || _1 === void 0 ? void 0 : _1.seller) === null || _2 === void 0 ? void 0 : _2.makesOffer) === null || _3 === void 0 ? void 0 : _3.$elemMatch;
252
- if (typeof ((_4 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _4 === void 0 ? void 0 : _4.$eq) === 'string') {
217
+ const sellerMakesOfferElemMatch = params.offers?.seller?.makesOffer?.$elemMatch;
218
+ if (typeof sellerMakesOfferElemMatch?.['availableAtOrFrom.id']?.$eq === 'string') {
253
219
  andConditions.push({
254
220
  'offers.seller.makesOffer': {
255
221
  $exists: true,
@@ -300,188 +266,199 @@ class EventRepo {
300
266
  /**
301
267
  * イベントコードをキーにして冪等置換
302
268
  */
303
- upsertManyScreeningEventByIdentifier(params, options) {
304
- return __awaiter(this, void 0, void 0, function* () {
305
- const { update } = options;
306
- const bulkWriteOps = [];
307
- const queryFilters = [];
308
- if (Array.isArray(params)) {
309
- params.forEach(({ $set, $unset }) => {
310
- const { project, identifier } = $set;
311
- if (typeof identifier !== 'string' || identifier.length === 0) {
312
- throw new factory.errors.ArgumentNull('identifier');
313
- }
314
- // リソースのユニークネスを保証するfilter
315
- const filter = {
316
- 'project.id': { $eq: project.id },
317
- identifier: { $exists: true, $eq: identifier }
318
- };
319
- queryFilters.push({
320
- 'project.id': { $eq: project.id },
321
- identifier: { $exists: true, $eq: identifier }
322
- });
323
- if (update === true) {
324
- const { maximumPhysicalAttendeeCapacity, additionalProperty, eventStatus, location, name, superEvent, offers, doorTime, endDate, startDate } = $set;
325
- const setFields = {
326
- maximumPhysicalAttendeeCapacity, additionalProperty,
327
- eventStatus, location, name, superEvent, offers,
328
- doorTime, endDate, startDate
329
- };
330
- const updateOne = {
331
- filter,
332
- update: Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
333
- upsert: false
334
- };
335
- bulkWriteOps.push({ updateOne });
336
- }
337
- else {
338
- const { id, coaInfo, description, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation } = $set, setOnInsertFields = __rest($set, ["id", "coaInfo", "description", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation"]);
339
- const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { identifier, _id: EventRepo.CREATE_ID() });
340
- const updateOne = {
341
- filter,
342
- update: {
343
- $setOnInsert: setOnInsert
344
- },
345
- upsert: true
346
- };
347
- bulkWriteOps.push({ updateOne });
348
- }
269
+ async upsertManyScreeningEventByIdentifier(params, options) {
270
+ const { update } = options;
271
+ const bulkWriteOps = [];
272
+ const queryFilters = [];
273
+ if (Array.isArray(params)) {
274
+ params.forEach(({ $set, $unset }) => {
275
+ const { project, identifier } = $set;
276
+ if (typeof identifier !== 'string' || identifier.length === 0) {
277
+ throw new factory.errors.ArgumentNull('identifier');
278
+ }
279
+ // リソースのユニークネスを保証するfilter
280
+ const filter = {
281
+ 'project.id': { $eq: project.id },
282
+ identifier: { $exists: true, $eq: identifier }
283
+ };
284
+ queryFilters.push({
285
+ 'project.id': { $eq: project.id },
286
+ identifier: { $exists: true, $eq: identifier }
349
287
  });
350
- }
351
- if (bulkWriteOps.length > 0) {
352
- const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
353
- // update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
354
- if (!update) {
355
- // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
356
- return {
357
- bulkWriteResult,
358
- modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
359
- .map((id) => ({ id: String(id) }))
288
+ if (update === true) {
289
+ const { maximumPhysicalAttendeeCapacity, additionalProperty, eventStatus, location, name, superEvent, offers, doorTime, endDate, startDate } = $set;
290
+ const setFields = {
291
+ maximumPhysicalAttendeeCapacity, additionalProperty,
292
+ eventStatus, location, name, superEvent, offers,
293
+ doorTime, endDate, startDate
294
+ };
295
+ const updateOne = {
296
+ filter,
297
+ update: {
298
+ $set: setFields,
299
+ ...($unset !== undefined) ? { $unset } : undefined
300
+ },
301
+ upsert: false
360
302
  };
303
+ bulkWriteOps.push({ updateOne });
361
304
  }
362
305
  else {
363
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
364
- const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
365
- _id: 0,
366
- id: { $toString: '$_id' }
367
- })
368
- .lean()
369
- .exec();
370
- return { bulkWriteResult, modifiedEvents };
306
+ const { id, coaInfo, description, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, ...setOnInsertFields } = $set;
307
+ const setOnInsert = {
308
+ ...setOnInsertFields,
309
+ identifier,
310
+ _id: EventRepo.CREATE_ID()
311
+ };
312
+ const updateOne = {
313
+ filter,
314
+ update: {
315
+ $setOnInsert: setOnInsert
316
+ },
317
+ upsert: true
318
+ };
319
+ bulkWriteOps.push({ updateOne });
371
320
  }
321
+ });
322
+ }
323
+ if (bulkWriteOps.length > 0) {
324
+ const bulkWriteResult = await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
325
+ // update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
326
+ if (!update) {
327
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
328
+ return {
329
+ bulkWriteResult,
330
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
331
+ .map((id) => ({ id: String(id) }))
332
+ };
372
333
  }
373
- return { modifiedEvents: [] };
374
- });
334
+ else {
335
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
336
+ const modifiedEvents = await this.eventModel.find({ $or: queryFilters }, {
337
+ _id: 0,
338
+ id: { $toString: '$_id' }
339
+ })
340
+ .lean()
341
+ .exec();
342
+ return { bulkWriteResult, modifiedEvents };
343
+ }
344
+ }
345
+ return { modifiedEvents: [] };
375
346
  }
376
347
  /**
377
348
  * イベント部分更新
378
349
  */
379
- updatePartiallyById(params) {
380
- return __awaiter(this, void 0, void 0, function* () {
381
- // let doc: Document | null;
382
- const _a = params.attributes, { typeOf } = _a, updateFields = __rest(_a, ["typeOf"]);
383
- if (typeof typeOf !== 'string' || typeOf.length === 0) {
384
- throw new factory.errors.ArgumentNull('attributes.typeOf');
385
- }
386
- const doc = yield this.eventModel.findOneAndUpdate({
350
+ async updatePartiallyById(params) {
351
+ // let doc: Document | null;
352
+ const { typeOf, ...updateFields } = params.attributes;
353
+ if (typeof typeOf !== 'string' || typeOf.length === 0) {
354
+ throw new factory.errors.ArgumentNull('attributes.typeOf');
355
+ }
356
+ const doc = await this.eventModel.findOneAndUpdate({
357
+ _id: { $eq: params.id },
358
+ 'project.id': { $eq: params.project.id },
359
+ typeOf: { $eq: typeOf }
360
+ }, {
361
+ $set: updateFields
362
+ }, { upsert: false, new: false, projection: { _id: 1 } })
363
+ .lean()
364
+ .exec();
365
+ if (doc === null) {
366
+ throw new factory.errors.NotFound(this.eventModel.modelName);
367
+ }
368
+ }
369
+ /**
370
+ * 単一イベント編集
371
+ */
372
+ async updateEventById(params) {
373
+ let doc;
374
+ const { identifier, project, typeOf, organizer, aggregateReservation, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, coaInfo, ...updateFields
375
+ // maximumPhysicalAttendeeCapacity, additionalProperty,
376
+ // eventStatus, location, name, superEvent, offers,
377
+ // doorTime, endDate, startDate
378
+ } = params.attributes;
379
+ if (typeof typeOf !== 'string' || typeOf.length === 0) {
380
+ throw new factory.errors.ArgumentNull('attributes.typeOf');
381
+ }
382
+ if (typeof params.id !== 'string' || params.id === '') {
383
+ throw new factory.errors.ArgumentNull('id');
384
+ }
385
+ try {
386
+ doc = await this.eventModel.findOneAndUpdate({
387
387
  _id: { $eq: params.id },
388
- 'project.id': { $eq: params.project.id },
389
388
  typeOf: { $eq: typeOf }
390
389
  }, {
391
- $set: updateFields
392
- }, { upsert: false, new: false, projection: { _id: 1 } })
390
+ // 編集のためのみのメソッドになったので、setOnInsertは廃止(2025-10-27~)
391
+ // 上書き禁止属性を除外(2022-08-24~)
392
+ // $setOnInsert: {
393
+ // typeOf,
394
+ // project,
395
+ // ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
396
+ // },
397
+ $set: updateFields,
398
+ ...(params.$unset !== undefined) ? { $unset: params.$unset } : undefined
399
+ }, {
400
+ upsert: false,
401
+ new: true,
402
+ projection: { _id: 1 }
403
+ })
393
404
  .lean()
394
405
  .exec();
395
- if (doc === null) {
396
- throw new factory.errors.NotFound(this.eventModel.modelName);
397
- }
398
- });
399
- }
400
- /**
401
- * 単一イベント編集
402
- */
403
- updateEventById(params) {
404
- return __awaiter(this, void 0, void 0, function* () {
405
- let doc;
406
- const _a = params.attributes, { identifier, project, typeOf, organizer, aggregateReservation, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, coaInfo } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf", "organizer", "aggregateReservation", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "coaInfo"])
407
- // maximumPhysicalAttendeeCapacity, additionalProperty,
408
- // eventStatus, location, name, superEvent, offers,
409
- // doorTime, endDate, startDate
410
- ;
411
- if (typeof typeOf !== 'string' || typeOf.length === 0) {
412
- throw new factory.errors.ArgumentNull('attributes.typeOf');
413
- }
414
- if (typeof params.id !== 'string' || params.id === '') {
415
- throw new factory.errors.ArgumentNull('id');
416
- }
417
- try {
418
- doc = yield this.eventModel.findOneAndUpdate({
419
- _id: { $eq: params.id },
420
- typeOf: { $eq: typeOf }
421
- }, Object.assign({
422
- // 編集のためのみのメソッドになったので、setOnInsertは廃止(2025-10-27~)
423
- // 上書き禁止属性を除外(2022-08-24~)
424
- // $setOnInsert: {
425
- // typeOf,
426
- // project,
427
- // ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
428
- // },
429
- $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), {
430
- upsert: false,
431
- new: true,
432
- projection: { _id: 1 }
433
- })
434
- .lean()
435
- .exec();
436
- }
437
- catch (error) {
438
- if (yield (0, errorHandler_1.isMongoError)(error)) {
439
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
440
- throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
441
- }
406
+ }
407
+ catch (error) {
408
+ if (await (0, errorHandler_1.isMongoError)(error)) {
409
+ if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
410
+ throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
442
411
  }
443
- throw error;
444
412
  }
445
- if (doc === null) {
446
- throw new factory.errors.NotFound(this.eventModel.modelName);
447
- }
448
- });
413
+ throw error;
414
+ }
415
+ if (doc === null) {
416
+ throw new factory.errors.NotFound(this.eventModel.modelName);
417
+ }
449
418
  }
450
419
  /**
451
420
  * sskts専用
452
421
  */
453
- saveManyEvents(params) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- const bulkWriteOps = [];
456
- if (Array.isArray(params)) {
457
- params.forEach((p) => {
458
- const upsert = p.upsert === true;
459
- if (p.attributes.typeOf === factory.eventType.ScreeningEvent) {
460
- // 上書き禁止属性を除外(2022-08-24~)
461
- const _a = p.attributes, { identifier, project, typeOf, remainingAttendeeCapacity } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf", "remainingAttendeeCapacity"]);
462
- bulkWriteOps.push({
463
- updateOne: {
464
- filter: {
465
- _id: p.id,
466
- typeOf: p.attributes.typeOf
467
- },
468
- update: Object.assign({ $setOnInsert: Object.assign(Object.assign({ typeOf: p.attributes.typeOf, project: p.attributes.project }, (typeof p.attributes.identifier === 'string')
469
- ? { identifier: p.attributes.identifier } : undefined), (typeof p.attributes.remainingAttendeeCapacity === 'number')
422
+ async saveManyEvents(params) {
423
+ const bulkWriteOps = [];
424
+ if (Array.isArray(params)) {
425
+ params.forEach((p) => {
426
+ const upsert = p.upsert === true;
427
+ if (p.attributes.typeOf === factory.eventType.ScreeningEvent) {
428
+ // 上書き禁止属性を除外(2022-08-24~)
429
+ const { identifier, project, typeOf, remainingAttendeeCapacity, ...updateFields } = p.attributes;
430
+ bulkWriteOps.push({
431
+ updateOne: {
432
+ filter: {
433
+ _id: p.id,
434
+ typeOf: p.attributes.typeOf
435
+ },
436
+ update: {
437
+ $setOnInsert: {
438
+ typeOf: p.attributes.typeOf,
439
+ project: p.attributes.project,
440
+ ...(typeof p.attributes.identifier === 'string')
441
+ ? { identifier: p.attributes.identifier } : undefined,
442
+ ...(typeof p.attributes.remainingAttendeeCapacity === 'number')
470
443
  ? { remainingAttendeeCapacity: p.attributes.remainingAttendeeCapacity }
471
- : undefined), $set: updateFields }, (p.$unset !== undefined) ? { $unset: p.$unset } : undefined),
472
- upsert
473
- }
474
- });
475
- }
476
- else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
477
- throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
478
- }
479
- });
480
- }
481
- if (bulkWriteOps.length > 0) {
482
- yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
483
- }
484
- });
444
+ : undefined
445
+ },
446
+ $set: updateFields,
447
+ // $unsetに対応(2022-08-31~)
448
+ ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
449
+ },
450
+ upsert
451
+ }
452
+ });
453
+ }
454
+ else if (p.attributes.typeOf === factory.eventType.ScreeningEventSeries) {
455
+ throw new factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
456
+ }
457
+ });
458
+ }
459
+ if (bulkWriteOps.length > 0) {
460
+ await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
461
+ }
485
462
  }
486
463
  // /**
487
464
  // * tttsイベントを識別子によって冪等作成する
@@ -527,546 +504,525 @@ class EventRepo {
527
504
  /**
528
505
  * イベントを検索する(inclusion projection)
529
506
  */
530
- projectEventFields(params, inclusion) {
531
- return __awaiter(this, void 0, void 0, function* () {
532
- var _a;
533
- const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
534
- let projection;
535
- const positiveProjectionFields = (Array.isArray(inclusion))
536
- ? inclusion.filter((key) => String(key) !== 'id' && String(key) !== '_id')
537
- : [];
538
- if (Array.isArray(inclusion) && inclusion.length > 0) {
539
- projection = Object.assign(Object.assign({}, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))), { _id: 0, id: { $toString: '$_id' } });
540
- }
541
- else {
542
- // discontinue(2024-07-24~)
543
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
544
- }
545
- const query = this.eventModel.find({ $and: conditions }, projection);
546
- if (typeof params.limit === 'number' && params.limit > 0) {
547
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
548
- query.limit(params.limit)
549
- .skip(params.limit * (page - 1));
550
- }
551
- // tslint:disable-next-line:no-single-line-block-comment
552
- /* istanbul ignore else */
553
- if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
554
- query.sort({ startDate: params.sort.startDate });
555
- }
556
- // const explainResult = await query.explain()
557
- // .exec();
558
- // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
559
- // console.log(explainResult[0].executionStats.allPlansExecution);
560
- // console.log(explainResult[0].queryPlanner?.winningPlan);
561
- // console.log(explainResult[0].queryPlanner?.winningPlan?.inputStage?.inputStage?.inputStage);
562
- // console.log(explainResult);
563
- // return [];
564
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
565
- .lean() // lean(2024-08-01~)
566
- .exec();
567
- });
507
+ async projectEventFields(params, inclusion) {
508
+ const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
509
+ let projection;
510
+ const positiveProjectionFields = (Array.isArray(inclusion))
511
+ ? inclusion.filter((key) => String(key) !== 'id' && String(key) !== '_id')
512
+ : [];
513
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
514
+ projection = {
515
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))),
516
+ _id: 0, // hide _id(2024-08-01~)
517
+ id: { $toString: '$_id' }
518
+ };
519
+ }
520
+ else {
521
+ // discontinue(2024-07-24~)
522
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
523
+ }
524
+ const query = this.eventModel.find({ $and: conditions }, projection);
525
+ if (typeof params.limit === 'number' && params.limit > 0) {
526
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
527
+ query.limit(params.limit)
528
+ .skip(params.limit * (page - 1));
529
+ }
530
+ /* istanbul ignore else */
531
+ if (params.sort?.startDate !== undefined) {
532
+ query.sort({ startDate: params.sort.startDate });
533
+ }
534
+ // const explainResult = await query.explain()
535
+ // .exec();
536
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
537
+ // console.log(explainResult[0].executionStats.allPlansExecution);
538
+ // console.log(explainResult[0].queryPlanner?.winningPlan);
539
+ // console.log(explainResult[0].queryPlanner?.winningPlan?.inputStage?.inputStage?.inputStage);
540
+ // console.log(explainResult);
541
+ // return [];
542
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
543
+ .lean() // lean(2024-08-01~)
544
+ .exec();
568
545
  }
569
- findByAdditionalProperty(params) {
570
- return __awaiter(this, void 0, void 0, function* () {
571
- const query = this.eventModel.find({
572
- 'project.id': { $eq: params.project.id },
573
- additionalProperty: { $eq: params.additionalProperty }
574
- }, { _id: 1 });
575
- // if (typeof params.limit === 'number' && params.limit > 0) {
576
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
577
- // query.limit(params.limit)
578
- // .skip(params.limit * (page - 1));
579
- // }
580
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
581
- .lean()
582
- .exec();
583
- });
546
+ async findByAdditionalProperty(params) {
547
+ const query = this.eventModel.find({
548
+ 'project.id': { $eq: params.project.id },
549
+ additionalProperty: { $eq: params.additionalProperty }
550
+ }, { _id: 1 });
551
+ // if (typeof params.limit === 'number' && params.limit > 0) {
552
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
553
+ // query.limit(params.limit)
554
+ // .skip(params.limit * (page - 1));
555
+ // }
556
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
557
+ .lean()
558
+ .exec();
584
559
  }
585
560
  /**
586
561
  * apiで公開属性を検索する(2024-10-13~)
587
562
  */
588
- aggregatePublicFields(params, inclusion, options) {
589
- return __awaiter(this, void 0, void 0, function* () {
590
- var _a, _b;
591
- const { includeOffers, includeSellerMakesOffer, sellerMakesOfferAvailableAtIn } = options;
592
- const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
593
- let projection;
594
- let positiveProjectionFields;
595
- if (Array.isArray(inclusion) && inclusion.length > 0) {
596
- positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PUBLIC_PROJECT_FIELDS.includes(key));
597
- projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
598
- if (includeOffers) {
599
- projection = Object.assign(Object.assign(Object.assign({}, projection), { 'offers.typeOf': 1, 'offers.eligibleQuantity': 1, 'offers.itemOffered': 1, 'offers.identifier': 1, 'offers.offeredThrough': 1, 'offers.unacceptedPaymentMethod': 1, 'offers.seller.typeOf': 1, 'offers.seller.id': 1, 'offers.seller.name': 1 }), (includeSellerMakesOffer)
600
- ? Object.assign({}, (Array.isArray(sellerMakesOfferAvailableAtIn))
601
- ? {
602
- 'offers.seller.makesOffer': {
603
- $filter: {
604
- input: '$offers.seller.makesOffer',
605
- as: 'sellerMakesOffer',
606
- cond: { $in: ['$$sellerMakesOffer.availableAtOrFrom.id', sellerMakesOfferAvailableAtIn] }
563
+ async aggregatePublicFields(params, inclusion, options) {
564
+ const { includeOffers, includeSellerMakesOffer, sellerMakesOfferAvailableAtIn } = options;
565
+ const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
566
+ let projection;
567
+ let positiveProjectionFields;
568
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
569
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PUBLIC_PROJECT_FIELDS.includes(key));
570
+ projection = {
571
+ _id: 0,
572
+ id: { $toString: '$_id' },
573
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
574
+ };
575
+ if (includeOffers) {
576
+ projection = {
577
+ ...projection,
578
+ 'offers.typeOf': 1,
579
+ 'offers.eligibleQuantity': 1,
580
+ 'offers.itemOffered': 1,
581
+ 'offers.identifier': 1, // support オファーコレクションコード(2025-09-29~)
582
+ 'offers.offeredThrough': 1,
583
+ 'offers.unacceptedPaymentMethod': 1,
584
+ 'offers.seller.typeOf': 1,
585
+ 'offers.seller.id': 1,
586
+ 'offers.seller.name': 1,
587
+ ...(includeSellerMakesOffer)
588
+ ? {
589
+ ...(Array.isArray(sellerMakesOfferAvailableAtIn))
590
+ ? {
591
+ 'offers.seller.makesOffer': {
592
+ $filter: {
593
+ input: '$offers.seller.makesOffer',
594
+ as: 'sellerMakesOffer',
595
+ cond: { $in: ['$$sellerMakesOffer.availableAtOrFrom.id', sellerMakesOfferAvailableAtIn] }
596
+ }
607
597
  }
608
598
  }
609
- }
610
- : { 'offers.seller.makesOffer': 1 }) : undefined);
611
- }
612
- }
613
- else {
614
- // discontinue(2024-07-24~)
615
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
616
- }
617
- const aggregate = this.eventModel.aggregate([
618
- { $match: { $and: conditions } },
619
- ...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined)
620
- ? [{ $sort: { startDate: params.sort.startDate } }]
621
- : [],
622
- { $project: projection }
623
- ]);
624
- if (typeof params.limit === 'number' && params.limit > 0) {
625
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
626
- aggregate.limit(params.limit * page)
627
- .skip(params.limit * (page - 1));
628
- }
629
- // tslint:disable-next-line:no-single-line-block-comment
630
- /* istanbul ignore else */
631
- if (((_b = params.sort) === null || _b === void 0 ? void 0 : _b.startDate) !== undefined) {
632
- aggregate.sort({ startDate: params.sort.startDate });
599
+ : { 'offers.seller.makesOffer': 1 }
600
+ }
601
+ : undefined
602
+ };
633
603
  }
634
- return aggregate
635
- .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
636
- .exec();
637
- });
604
+ }
605
+ else {
606
+ // discontinue(2024-07-24~)
607
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
608
+ }
609
+ const aggregate = this.eventModel.aggregate([
610
+ { $match: { $and: conditions } },
611
+ ...(params.sort?.startDate !== undefined)
612
+ ? [{ $sort: { startDate: params.sort.startDate } }]
613
+ : [],
614
+ { $project: projection }
615
+ ]);
616
+ if (typeof params.limit === 'number' && params.limit > 0) {
617
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
618
+ aggregate.limit(params.limit * page)
619
+ .skip(params.limit * (page - 1));
620
+ }
621
+ /* istanbul ignore else */
622
+ if (params.sort?.startDate !== undefined) {
623
+ aggregate.sort({ startDate: params.sort.startDate });
624
+ }
625
+ return aggregate
626
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
627
+ .exec();
638
628
  }
639
629
  /**
640
630
  * IDのみで検索する
641
631
  * projectionなし
642
632
  */
643
- findAnyEventById(params) {
644
- return __awaiter(this, void 0, void 0, function* () {
645
- var _a;
646
- const doc = yield this.eventModel.findOne(Object.assign({ _id: { $eq: params.id.$eq }, 'project.id': { $eq: params.project.id.$eq }, typeOf: { $in: [factory.eventType.ScreeningEvent] } }, (typeof ((_a = params.organizer) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
633
+ async findAnyEventById(params) {
634
+ const doc = await this.eventModel.findOne({
635
+ _id: { $eq: params.id.$eq },
636
+ 'project.id': { $eq: params.project.id.$eq },
637
+ typeOf: { $in: [factory.eventType.ScreeningEvent] },
638
+ ...(typeof params.organizer?.id.$eq === 'string')
647
639
  ? { 'organizer.id': { $exists: true, $eq: params.organizer.id.$eq } }
648
- : undefined), {
649
- __v: 0,
650
- createdAt: 0,
651
- updatedAt: 0,
652
- // DefaultでaggregateEntranceGateを取得しない(2023-01-25~)
653
- aggregateEntranceGate: 0,
654
- // DefaultでaggregateOfferを取得しない(2023-01-24~)
655
- aggregateOffer: 0
656
- })
657
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
658
- .exec();
659
- if (doc === null) {
660
- throw new factory.errors.NotFound('Event');
661
- }
662
- return doc.toObject();
663
- });
640
+ : undefined
641
+ }, {
642
+ __v: 0,
643
+ createdAt: 0,
644
+ updatedAt: 0,
645
+ // DefaultでaggregateEntranceGateを取得しない(2023-01-25~)
646
+ aggregateEntranceGate: 0,
647
+ // DefaultでaggregateOfferを取得しない(2023-01-24~)
648
+ aggregateOffer: 0
649
+ })
650
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
651
+ .exec();
652
+ if (doc === null) {
653
+ throw new factory.errors.NotFound('Event');
654
+ }
655
+ return doc.toObject();
664
656
  }
665
- searchEventIds(params) {
666
- return __awaiter(this, void 0, void 0, function* () {
667
- const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
668
- const query = this.eventModel.distinct('_id', { $and: conditions });
669
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
670
- .exec();
671
- });
657
+ async searchEventIds(params) {
658
+ const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
659
+ const query = this.eventModel.distinct('_id', { $and: conditions });
660
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
661
+ .exec();
672
662
  }
673
663
  /**
674
664
  * 特定イベントから指定フィールドのみ取得する
675
665
  * イベント IDは必ず返ります
676
666
  */
677
- projectEventFieldsById(params, inclusion // add projection(2024-07-18~)
667
+ async projectEventFieldsById(params, inclusion // add projection(2024-07-18~)
678
668
  ) {
679
- return __awaiter(this, void 0, void 0, function* () {
680
- const projection = {
681
- _id: 0,
682
- id: { $toString: '$_id' }
683
- };
684
- if (Array.isArray(inclusion) && inclusion.length > 0) {
685
- inclusion.forEach((field) => {
686
- if (String(field) !== '_id' && String(field) !== 'id') {
687
- projection[field] = 1;
688
- }
689
- });
690
- }
691
- else {
692
- // discontinue(2024-07-24~)
693
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
694
- // projection = PROJECTION_MINIMIZED_EVENT;
695
- }
696
- const doc = yield this.eventModel.findOne({ _id: { $eq: params.id } }, projection)
697
- .lean() // lean(2024-07-24~)
698
- .exec();
699
- if (doc === null) {
700
- throw new factory.errors.NotFound(this.eventModel.modelName);
701
- }
702
- return doc;
703
- });
669
+ const projection = {
670
+ _id: 0,
671
+ id: { $toString: '$_id' }
672
+ };
673
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
674
+ inclusion.forEach((field) => {
675
+ if (String(field) !== '_id' && String(field) !== 'id') {
676
+ projection[field] = 1;
677
+ }
678
+ });
679
+ }
680
+ else {
681
+ // discontinue(2024-07-24~)
682
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
683
+ // projection = PROJECTION_MINIMIZED_EVENT;
684
+ }
685
+ const doc = await this.eventModel.findOne({ _id: { $eq: params.id } }, projection)
686
+ .lean() // lean(2024-07-24~)
687
+ .exec();
688
+ if (doc === null) {
689
+ throw new factory.errors.NotFound(this.eventModel.modelName);
690
+ }
691
+ return doc;
704
692
  }
705
693
  /**
706
694
  * イベントをキャンセルする
707
695
  */
708
- cancelEvent(params) {
709
- return __awaiter(this, void 0, void 0, function* () {
710
- return this.eventModel.updateOne({
711
- _id: { $eq: params.id },
712
- 'project.id': { $eq: params.project.id }
713
- }, { $set: { eventStatus: factory.eventStatusType.EventCancelled } }, { includeResultMetadata: true })
714
- .exec();
715
- });
696
+ async cancelEvent(params) {
697
+ return this.eventModel.updateOne({
698
+ _id: { $eq: params.id },
699
+ 'project.id': { $eq: params.project.id }
700
+ }, { $set: { eventStatus: factory.eventStatusType.EventCancelled } }, { includeResultMetadata: true })
701
+ .exec();
716
702
  }
717
703
  /**
718
704
  * 興行イベントのsuperEventを最新の情報に同期する
719
705
  */
720
- syncScreeningEventSeries2screeningEvents(params) {
721
- return __awaiter(this, void 0, void 0, function* () {
722
- const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB: params.superEventFromDB });
723
- yield this.eventModel.updateMany({
724
- typeOf: { $eq: factory.eventType.ScreeningEvent },
725
- 'project.id': { $eq: params.project.id },
726
- 'superEvent.id': { $exists: true, $eq: params.superEventFromDB.id },
727
- startDate: { $gte: params.startDate.$gte }
728
- }, {
729
- $set: {
730
- superEvent
731
- }
732
- })
733
- .exec();
734
- });
706
+ async syncScreeningEventSeries2screeningEvents(params) {
707
+ const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB: params.superEventFromDB });
708
+ await this.eventModel.updateMany({
709
+ typeOf: { $eq: factory.eventType.ScreeningEvent },
710
+ 'project.id': { $eq: params.project.id },
711
+ 'superEvent.id': { $exists: true, $eq: params.superEventFromDB.id },
712
+ startDate: { $gte: params.startDate.$gte }
713
+ }, {
714
+ $set: {
715
+ superEvent
716
+ }
717
+ })
718
+ .exec();
735
719
  }
736
- deleteEventById(params) {
737
- return __awaiter(this, void 0, void 0, function* () {
738
- yield this.eventModel.findOneAndDelete({
739
- _id: params.id,
740
- 'project.id': { $eq: params.project.id }
741
- })
742
- .exec();
743
- });
720
+ async deleteEventById(params) {
721
+ await this.eventModel.findOneAndDelete({
722
+ _id: params.id,
723
+ 'project.id': { $eq: params.project.id }
724
+ })
725
+ .exec();
744
726
  }
745
- deleteManyEventByOrganizerId(params) {
746
- return __awaiter(this, void 0, void 0, function* () {
747
- return this.eventModel.deleteMany({
748
- 'project.id': { $eq: params.project.id },
749
- 'organizer.id': { $exists: true, $eq: params.organizer.id }
750
- })
751
- .exec();
752
- });
727
+ async deleteManyEventByOrganizerId(params) {
728
+ return this.eventModel.deleteMany({
729
+ 'project.id': { $eq: params.project.id },
730
+ 'organizer.id': { $exists: true, $eq: params.organizer.id }
731
+ })
732
+ .exec();
753
733
  }
754
- deleteManyEventsByScreeningRoom(params) {
755
- return __awaiter(this, void 0, void 0, function* () {
756
- return this.eventModel.deleteMany({
757
- 'project.id': { $eq: params.project.id },
758
- 'location.branchCode': { $exists: true, $eq: params.location.branchCode },
759
- 'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
760
- })
761
- .exec();
762
- });
734
+ async deleteManyEventsByScreeningRoom(params) {
735
+ return this.eventModel.deleteMany({
736
+ 'project.id': { $eq: params.project.id },
737
+ 'location.branchCode': { $exists: true, $eq: params.location.branchCode },
738
+ 'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
739
+ })
740
+ .exec();
763
741
  }
764
- deleteManyBySuperEventId(params) {
765
- return __awaiter(this, void 0, void 0, function* () {
766
- return this.eventModel.deleteMany({
767
- 'project.id': { $eq: params.project.id },
768
- 'superEvent.id': { $exists: true, $eq: params.superEvent.id }
769
- })
770
- .exec();
771
- });
742
+ async deleteManyBySuperEventId(params) {
743
+ return this.eventModel.deleteMany({
744
+ 'project.id': { $eq: params.project.id },
745
+ 'superEvent.id': { $exists: true, $eq: params.superEvent.id }
746
+ })
747
+ .exec();
772
748
  }
773
- deleteManyBySuperEventLocationId(params) {
774
- return __awaiter(this, void 0, void 0, function* () {
775
- return this.eventModel.deleteMany({
776
- 'project.id': { $eq: params.project.id },
777
- 'superEvent.location.id': { $exists: true, $eq: params.superEvent.location.id }
778
- })
779
- .exec();
780
- });
749
+ async deleteManyBySuperEventLocationId(params) {
750
+ return this.eventModel.deleteMany({
751
+ 'project.id': { $eq: params.project.id },
752
+ 'superEvent.location.id': { $exists: true, $eq: params.superEvent.location.id }
753
+ })
754
+ .exec();
781
755
  }
782
756
  /**
783
757
  * 興行(プロダクト)から削除する
784
758
  */
785
- deleteManyEventsByItemOfferedId(params) {
786
- return __awaiter(this, void 0, void 0, function* () {
787
- return this.eventModel.deleteMany({
788
- 'project.id': { $eq: params.project.id },
789
- 'offers.itemOffered.id': { $exists: true, $in: params.offers.itemOffered.id.$in }
790
- })
791
- .exec();
792
- });
759
+ async deleteManyEventsByItemOfferedId(params) {
760
+ return this.eventModel.deleteMany({
761
+ 'project.id': { $eq: params.project.id },
762
+ 'offers.itemOffered.id': { $exists: true, $in: params.offers.itemOffered.id.$in }
763
+ })
764
+ .exec();
793
765
  }
794
- deleteManyEventsEndedByProject(params) {
795
- return __awaiter(this, void 0, void 0, function* () {
796
- return this.eventModel.deleteMany({
797
- typeOf: { $in: params.typeOf.$in },
798
- 'project.id': { $eq: params.project.id },
799
- endDate: { $lte: params.endDate.$lte }
800
- })
801
- .exec();
802
- });
766
+ async deleteManyEventsEndedByProject(params) {
767
+ return this.eventModel.deleteMany({
768
+ typeOf: { $in: params.typeOf.$in },
769
+ 'project.id': { $eq: params.project.id },
770
+ endDate: { $lte: params.endDate.$lte }
771
+ })
772
+ .exec();
803
773
  }
804
- deleteManyEventsEnded(params) {
805
- return __awaiter(this, void 0, void 0, function* () {
806
- return this.eventModel.deleteMany({
807
- typeOf: { $eq: params.typeOf.$eq },
808
- endDate: { $lte: params.endDate.$lte }
809
- })
810
- .exec();
811
- });
774
+ async deleteManyEventsEnded(params) {
775
+ return this.eventModel.deleteMany({
776
+ typeOf: { $eq: params.typeOf.$eq },
777
+ endDate: { $lte: params.endDate.$lte }
778
+ })
779
+ .exec();
812
780
  }
813
- deleteByProject(params) {
814
- return __awaiter(this, void 0, void 0, function* () {
815
- yield this.eventModel.deleteMany({
816
- 'project.id': { $eq: params.project.id }
817
- })
818
- .exec();
819
- });
781
+ async deleteByProject(params) {
782
+ await this.eventModel.deleteMany({
783
+ 'project.id': { $eq: params.project.id }
784
+ })
785
+ .exec();
820
786
  }
821
787
  /**
822
788
  * 集計属性を更新する
823
789
  */
824
- updateAggregationById(params, update) {
825
- return __awaiter(this, void 0, void 0, function* () {
826
- const doc = yield this.eventModel.findOneAndUpdate({ _id: { $eq: params.id } }, update, {
827
- new: false,
828
- projection: { _id: 1 }
829
- })
830
- .lean()
831
- .exec();
832
- if (doc === null) {
833
- throw new factory.errors.NotFound(this.eventModel.modelName);
834
- }
835
- });
790
+ async updateAggregationById(params, update) {
791
+ const doc = await this.eventModel.findOneAndUpdate({ _id: { $eq: params.id } }, update, {
792
+ new: false,
793
+ projection: { _id: 1 }
794
+ })
795
+ .lean()
796
+ .exec();
797
+ if (doc === null) {
798
+ throw new factory.errors.NotFound(this.eventModel.modelName);
799
+ }
836
800
  }
837
- bulkWrite(bulkWriteOps) {
838
- return __awaiter(this, void 0, void 0, function* () {
839
- return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
840
- });
801
+ async bulkWrite(bulkWriteOps) {
802
+ return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
841
803
  }
842
804
  getCursor(conditions, projection) {
843
805
  return this.eventModel.find(conditions, projection)
844
806
  .sort({ startDate: factory.sortType.Descending })
845
807
  .cursor();
846
808
  }
847
- addAvailableAtOrFrom(params) {
848
- return __awaiter(this, void 0, void 0, function* () {
849
- yield this.eventModel.updateOne({ _id: { $eq: params.id } }, {
850
- $push: {
851
- 'offers.seller.makesOffer': params.offers.seller.makesOffer
852
- }
853
- }, { includeResultMetadata: true })
854
- .exec();
855
- });
809
+ async addAvailableAtOrFrom(params) {
810
+ await this.eventModel.updateOne({ _id: { $eq: params.id } }, {
811
+ $push: {
812
+ 'offers.seller.makesOffer': params.offers.seller.makesOffer
813
+ }
814
+ }, { includeResultMetadata: true })
815
+ .exec();
856
816
  }
857
- unsetUnnecessaryFields(params) {
858
- return __awaiter(this, void 0, void 0, function* () {
859
- return this.eventModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
860
- .exec();
861
- });
817
+ async unsetUnnecessaryFields(params) {
818
+ return this.eventModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
819
+ .exec();
862
820
  }
863
- aggregateEvent(params) {
864
- return __awaiter(this, void 0, void 0, function* () {
865
- const statuses = yield Promise.all([
866
- factory.eventStatusType.EventScheduled,
867
- factory.eventStatusType.EventCancelled,
868
- factory.eventStatusType.EventPostponed
869
- ].map((eventStatus) => __awaiter(this, void 0, void 0, function* () {
870
- var _a, _b;
871
- const matchConditions = Object.assign({ startDate: {
872
- $gte: params.startFrom,
873
- $lte: params.startThrough
874
- }, typeOf: { $eq: params.typeOf }, eventStatus: { $eq: eventStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
821
+ async aggregateEvent(params) {
822
+ const statuses = await Promise.all([
823
+ factory.eventStatusType.EventScheduled,
824
+ factory.eventStatusType.EventCancelled,
825
+ factory.eventStatusType.EventPostponed
826
+ ].map(async (eventStatus) => {
827
+ const matchConditions = {
828
+ startDate: {
829
+ $gte: params.startFrom,
830
+ $lte: params.startThrough
831
+ },
832
+ typeOf: { $eq: params.typeOf },
833
+ eventStatus: { $eq: eventStatus },
834
+ ...(typeof params.project?.id?.$ne === 'string')
875
835
  ? { 'project.id': { $ne: params.project.id.$ne } }
876
- : undefined);
877
- return this.agggregateByStatus({ matchConditions, status: eventStatus });
878
- })));
879
- return { statuses };
880
- });
836
+ : undefined
837
+ };
838
+ return this.agggregateByStatus({ matchConditions, status: eventStatus });
839
+ }));
840
+ return { statuses };
881
841
  }
882
- // tslint:disable-next-line:max-func-body-length
883
- agggregateByStatus(params) {
884
- return __awaiter(this, void 0, void 0, function* () {
885
- const matchConditions = params.matchConditions;
886
- const eventStatus = params.status;
887
- const aggregations = yield this.eventModel.aggregate([
888
- {
889
- $match: matchConditions
890
- },
891
- {
892
- $project: {
893
- remainingCapacityRate: {
894
- $cond: {
895
- if: {
896
- $and: [
897
- { $isNumber: '$maximumAttendeeCapacity' },
898
- { $isNumber: '$remainingAttendeeCapacity' }
899
- ]
900
- },
901
- then: {
902
- $cond: {
903
- if: { $gt: ['$maximumAttendeeCapacity', 0] },
904
- then: {
905
- $multiply: [
906
- { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
907
- // tslint:disable-next-line:no-magic-numbers
908
- 100
909
- ]
910
- },
911
- else: 0
912
- }
913
- },
914
- else: 0
915
- }
916
- },
917
- eventStatus: '$eventStatus',
918
- startDate: '$startDate',
919
- endDate: '$endDate',
920
- typeOf: '$typeOf',
921
- maximumAttendeeCapacity: {
922
- $cond: {
923
- if: { $isNumber: '$maximumAttendeeCapacity' },
924
- then: '$maximumAttendeeCapacity',
925
- else: 0
926
- }
927
- },
928
- remainingAttendeeCapacity: {
929
- $cond: {
930
- if: { $isNumber: '$remainingAttendeeCapacity' },
931
- then: '$remainingAttendeeCapacity',
932
- else: 0
933
- }
934
- },
935
- reservationCount: {
936
- $cond: {
937
- if: { $isNumber: '$aggregateReservation.reservationCount' },
938
- then: '$aggregateReservation.reservationCount',
939
- else: 0
940
- }
941
- },
942
- offerCount: {
943
- $cond: {
944
- if: { $isNumber: '$aggregateOffer.offerCount' },
945
- then: '$aggregateOffer.offerCount',
946
- else: 0
947
- }
842
+ async agggregateByStatus(params) {
843
+ const matchConditions = params.matchConditions;
844
+ const eventStatus = params.status;
845
+ const aggregations = await this.eventModel.aggregate([
846
+ {
847
+ $match: matchConditions
848
+ },
849
+ {
850
+ $project: {
851
+ remainingCapacityRate: {
852
+ $cond: {
853
+ if: {
854
+ $and: [
855
+ { $isNumber: '$maximumAttendeeCapacity' },
856
+ { $isNumber: '$remainingAttendeeCapacity' }
857
+ ]
858
+ },
859
+ then: {
860
+ $cond: {
861
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
862
+ then: {
863
+ $multiply: [
864
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
865
+ 100
866
+ ]
867
+ },
868
+ else: 0
869
+ }
870
+ },
871
+ else: 0
872
+ }
873
+ },
874
+ eventStatus: '$eventStatus',
875
+ startDate: '$startDate',
876
+ endDate: '$endDate',
877
+ typeOf: '$typeOf',
878
+ maximumAttendeeCapacity: {
879
+ $cond: {
880
+ if: { $isNumber: '$maximumAttendeeCapacity' },
881
+ then: '$maximumAttendeeCapacity',
882
+ else: 0
883
+ }
884
+ },
885
+ remainingAttendeeCapacity: {
886
+ $cond: {
887
+ if: { $isNumber: '$remainingAttendeeCapacity' },
888
+ then: '$remainingAttendeeCapacity',
889
+ else: 0
890
+ }
891
+ },
892
+ reservationCount: {
893
+ $cond: {
894
+ if: { $isNumber: '$aggregateReservation.reservationCount' },
895
+ then: '$aggregateReservation.reservationCount',
896
+ else: 0
897
+ }
898
+ },
899
+ offerCount: {
900
+ $cond: {
901
+ if: { $isNumber: '$aggregateOffer.offerCount' },
902
+ then: '$aggregateOffer.offerCount',
903
+ else: 0
948
904
  }
949
- }
950
- },
951
- {
952
- $group: {
953
- _id: '$typeOf',
954
- eventCount: { $sum: 1 },
955
- reservationCount: { $sum: '$reservationCount' },
956
- avgOfferCount: { $avg: '$offerCount' },
957
- maximumAttendeeCapacity: { $sum: '$maximumAttendeeCapacity' },
958
- remainingAttendeeCapacity: { $sum: '$remainingAttendeeCapacity' },
959
- avgRemainingCapacityRate: { $avg: '$remainingCapacityRate' },
960
- maxRemainingCapacityRate: { $max: '$remainingCapacityRate' },
961
- minRemainingCapacityRate: { $min: '$remainingCapacityRate' }
962
- }
963
- },
964
- {
965
- $project: {
966
- _id: 0,
967
- eventCount: '$eventCount',
968
- reservationCount: '$reservationCount',
969
- avgOfferCount: '$avgOfferCount',
970
- maximumAttendeeCapacity: '$maximumAttendeeCapacity',
971
- remainingAttendeeCapacity: '$remainingAttendeeCapacity',
972
- avgRemainingCapacityRate: '$avgRemainingCapacityRate',
973
- maxRemainingCapacityRate: '$maxRemainingCapacityRate',
974
- minRemainingCapacityRate: '$minRemainingCapacityRate'
975
905
  }
976
906
  }
977
- ])
978
- .exec();
979
- // tslint:disable-next-line:no-magic-numbers
980
- const percents = [50, 95, 99];
981
- if (aggregations.length === 0) {
982
- return {
983
- status: eventStatus,
984
- aggregation: {
985
- eventCount: 0,
986
- reservationCount: 0,
987
- avgOfferCount: 0,
988
- maximumAttendeeCapacity: 0,
989
- remainingAttendeeCapacity: 0,
990
- avgRemainingCapacityRate: 0,
991
- maxRemainingCapacityRate: 0,
992
- minRemainingCapacityRate: 0,
993
- percentilesRemainingCapacityRate: percents.map((percent) => {
994
- return {
995
- name: String(percent),
996
- value: 0
997
- };
998
- })
999
- }
1000
- };
1001
- }
1002
- const ranks4percentile = percents.map((percentile) => {
1003
- return {
1004
- percentile,
1005
- // tslint:disable-next-line:no-magic-numbers
1006
- rank: Math.floor(aggregations[0].eventCount * percentile / 100)
1007
- };
1008
- });
1009
- const aggregations2 = yield this.eventModel.aggregate([
1010
- {
1011
- $match: matchConditions
1012
- },
1013
- {
1014
- $project: {
1015
- remainingCapacityRate: {
1016
- $cond: {
1017
- if: {
1018
- $and: [
1019
- { $isNumber: '$maximumAttendeeCapacity' },
1020
- { $isNumber: '$remainingAttendeeCapacity' }
1021
- ]
1022
- },
1023
- then: {
1024
- $cond: {
1025
- if: { $gt: ['$maximumAttendeeCapacity', 0] },
1026
- then: {
1027
- $multiply: [
1028
- { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
1029
- // tslint:disable-next-line:no-magic-numbers
1030
- 100
1031
- ]
1032
- },
1033
- else: 0
1034
- }
1035
- },
1036
- else: 0
1037
- }
1038
- },
1039
- eventStatus: '$eventStatus',
1040
- startDate: '$startDate',
1041
- endDate: '$endDate',
1042
- typeOf: '$typeOf'
1043
- }
1044
- },
1045
- { $sort: { remainingCapacityRate: 1 } },
1046
- {
1047
- $group: {
1048
- _id: '$typeOf',
1049
- remainingCapacityRates: { $push: '$remainingCapacityRate' }
1050
- }
1051
- },
1052
- {
1053
- $project: {
1054
- _id: 0,
1055
- percentilesRemainingCapacityRate: ranks4percentile.map((rank) => {
1056
- return {
1057
- name: String(rank.percentile),
1058
- value: { $arrayElemAt: ['$remainingCapacityRates', rank.rank] }
1059
- };
1060
- })
1061
- }
907
+ },
908
+ {
909
+ $group: {
910
+ _id: '$typeOf',
911
+ eventCount: { $sum: 1 },
912
+ reservationCount: { $sum: '$reservationCount' },
913
+ avgOfferCount: { $avg: '$offerCount' },
914
+ maximumAttendeeCapacity: { $sum: '$maximumAttendeeCapacity' },
915
+ remainingAttendeeCapacity: { $sum: '$remainingAttendeeCapacity' },
916
+ avgRemainingCapacityRate: { $avg: '$remainingCapacityRate' },
917
+ maxRemainingCapacityRate: { $max: '$remainingCapacityRate' },
918
+ minRemainingCapacityRate: { $min: '$remainingCapacityRate' }
1062
919
  }
1063
- ])
1064
- .exec();
920
+ },
921
+ {
922
+ $project: {
923
+ _id: 0,
924
+ eventCount: '$eventCount',
925
+ reservationCount: '$reservationCount',
926
+ avgOfferCount: '$avgOfferCount',
927
+ maximumAttendeeCapacity: '$maximumAttendeeCapacity',
928
+ remainingAttendeeCapacity: '$remainingAttendeeCapacity',
929
+ avgRemainingCapacityRate: '$avgRemainingCapacityRate',
930
+ maxRemainingCapacityRate: '$maxRemainingCapacityRate',
931
+ minRemainingCapacityRate: '$minRemainingCapacityRate'
932
+ }
933
+ }
934
+ ])
935
+ .exec();
936
+ const percents = [50, 95, 99];
937
+ if (aggregations.length === 0) {
1065
938
  return {
1066
939
  status: eventStatus,
1067
- aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
940
+ aggregation: {
941
+ eventCount: 0,
942
+ reservationCount: 0,
943
+ avgOfferCount: 0,
944
+ maximumAttendeeCapacity: 0,
945
+ remainingAttendeeCapacity: 0,
946
+ avgRemainingCapacityRate: 0,
947
+ maxRemainingCapacityRate: 0,
948
+ minRemainingCapacityRate: 0,
949
+ percentilesRemainingCapacityRate: percents.map((percent) => {
950
+ return {
951
+ name: String(percent),
952
+ value: 0
953
+ };
954
+ })
955
+ }
956
+ };
957
+ }
958
+ const ranks4percentile = percents.map((percentile) => {
959
+ return {
960
+ percentile,
961
+ rank: Math.floor(aggregations[0].eventCount * percentile / 100)
1068
962
  };
1069
963
  });
964
+ const aggregations2 = await this.eventModel.aggregate([
965
+ {
966
+ $match: matchConditions
967
+ },
968
+ {
969
+ $project: {
970
+ remainingCapacityRate: {
971
+ $cond: {
972
+ if: {
973
+ $and: [
974
+ { $isNumber: '$maximumAttendeeCapacity' },
975
+ { $isNumber: '$remainingAttendeeCapacity' }
976
+ ]
977
+ },
978
+ then: {
979
+ $cond: {
980
+ if: { $gt: ['$maximumAttendeeCapacity', 0] },
981
+ then: {
982
+ $multiply: [
983
+ { $divide: ['$remainingAttendeeCapacity', '$maximumAttendeeCapacity'] },
984
+ 100
985
+ ]
986
+ },
987
+ else: 0
988
+ }
989
+ },
990
+ else: 0
991
+ }
992
+ },
993
+ eventStatus: '$eventStatus',
994
+ startDate: '$startDate',
995
+ endDate: '$endDate',
996
+ typeOf: '$typeOf'
997
+ }
998
+ },
999
+ { $sort: { remainingCapacityRate: 1 } },
1000
+ {
1001
+ $group: {
1002
+ _id: '$typeOf',
1003
+ remainingCapacityRates: { $push: '$remainingCapacityRate' }
1004
+ }
1005
+ },
1006
+ {
1007
+ $project: {
1008
+ _id: 0,
1009
+ percentilesRemainingCapacityRate: ranks4percentile.map((rank) => {
1010
+ return {
1011
+ name: String(rank.percentile),
1012
+ value: { $arrayElemAt: ['$remainingCapacityRates', rank.rank] }
1013
+ };
1014
+ })
1015
+ }
1016
+ }
1017
+ ])
1018
+ .exec();
1019
+ return {
1020
+ status: eventStatus,
1021
+ aggregation: {
1022
+ ...aggregations[0],
1023
+ ...aggregations2[0]
1024
+ }
1025
+ };
1070
1026
  }
1071
1027
  }
1072
1028
  exports.EventRepo = EventRepo;