@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,13 +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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.OrderRepo = void 0;
13
4
  const factory = require("../factory");
@@ -28,23 +19,20 @@ const AVAILABLE_PROJECT_FIELDS = [
28
19
  * 注文リポジトリ
29
20
  */
30
21
  class OrderRepo {
22
+ orderModel;
31
23
  constructor(connection) {
32
24
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
33
25
  }
34
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
35
26
  static CREATE_MONGO_CONDITIONS(params) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
37
27
  const andConditions = [
38
28
  { typeOf: { $eq: factory.order.OrderType.Order } }
39
29
  ];
40
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
30
+ const projectIdEq = params.project?.id?.$eq;
41
31
  if (typeof projectIdEq === 'string') {
42
32
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
43
33
  }
44
- // tslint:disable-next-line:no-single-line-block-comment
45
34
  /* istanbul ignore else */
46
35
  if (params.identifier !== undefined) {
47
- // tslint:disable-next-line:no-single-line-block-comment
48
36
  /* istanbul ignore else */
49
37
  if (Array.isArray(params.identifier.$all)) {
50
38
  andConditions.push({
@@ -54,7 +42,6 @@ class OrderRepo {
54
42
  }
55
43
  });
56
44
  }
57
- // tslint:disable-next-line:no-single-line-block-comment
58
45
  /* istanbul ignore else */
59
46
  if (Array.isArray(params.identifier.$in)) {
60
47
  andConditions.push({
@@ -65,15 +52,15 @@ class OrderRepo {
65
52
  });
66
53
  }
67
54
  }
68
- const providerIdEq = (_d = (_c = params.provider) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
55
+ const providerIdEq = params.provider?.id?.$eq;
69
56
  if (typeof providerIdEq === 'string') {
70
57
  andConditions.push({ 'seller.id': { $exists: true, $eq: providerIdEq } });
71
58
  }
72
- const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
59
+ const sellerIdEq = params.seller?.id?.$eq;
73
60
  if (typeof sellerIdEq === 'string') {
74
61
  andConditions.push({ 'seller.id': { $exists: true, $eq: sellerIdEq } });
75
62
  }
76
- const sellerIds = (_g = params.seller) === null || _g === void 0 ? void 0 : _g.ids;
63
+ const sellerIds = params.seller?.ids;
77
64
  if (Array.isArray(sellerIds)) {
78
65
  if (sellerIds.length === 1) {
79
66
  // use $eq(2025-04-01~)
@@ -83,7 +70,7 @@ class OrderRepo {
83
70
  andConditions.push({ 'seller.id': { $exists: true, $in: sellerIds } });
84
71
  }
85
72
  }
86
- const brokerIdEq = (_j = (_h = params.broker) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
73
+ const brokerIdEq = params.broker?.id?.$eq;
87
74
  if (typeof brokerIdEq === 'string') {
88
75
  andConditions.push({
89
76
  'broker.id': {
@@ -92,10 +79,8 @@ class OrderRepo {
92
79
  }
93
80
  });
94
81
  }
95
- // tslint:disable-next-line:no-single-line-block-comment
96
82
  /* istanbul ignore else */
97
83
  if (params.customer !== undefined) {
98
- // tslint:disable-next-line:no-single-line-block-comment
99
84
  /* istanbul ignore else */
100
85
  if (params.customer.typeOf !== undefined) {
101
86
  andConditions.push({
@@ -105,7 +90,6 @@ class OrderRepo {
105
90
  }
106
91
  });
107
92
  }
108
- // tslint:disable-next-line:no-single-line-block-comment
109
93
  /* istanbul ignore else */
110
94
  if (Array.isArray(params.customer.ids)) {
111
95
  andConditions.push({
@@ -115,7 +99,6 @@ class OrderRepo {
115
99
  }
116
100
  });
117
101
  }
118
- // tslint:disable-next-line:no-single-line-block-comment
119
102
  /* istanbul ignore else */
120
103
  if (Array.isArray(params.customer.identifiers)) {
121
104
  andConditions.push({
@@ -125,10 +108,8 @@ class OrderRepo {
125
108
  }
126
109
  });
127
110
  }
128
- // tslint:disable-next-line:no-single-line-block-comment
129
111
  /* istanbul ignore else */
130
112
  if (params.customer.identifier !== undefined) {
131
- // tslint:disable-next-line:no-single-line-block-comment
132
113
  /* istanbul ignore else */
133
114
  if (Array.isArray(params.customer.identifier.$all)) {
134
115
  andConditions.push({
@@ -138,7 +119,6 @@ class OrderRepo {
138
119
  }
139
120
  });
140
121
  }
141
- // tslint:disable-next-line:no-single-line-block-comment
142
122
  /* istanbul ignore else */
143
123
  if (Array.isArray(params.customer.identifier.$in)) {
144
124
  andConditions.push({
@@ -300,7 +280,7 @@ class OrderRepo {
300
280
  }
301
281
  }
302
282
  }
303
- const nameEq = (_k = params.name) === null || _k === void 0 ? void 0 : _k.$eq;
283
+ const nameEq = params.name?.$eq;
304
284
  if (typeof nameEq === 'string') {
305
285
  andConditions.push({
306
286
  name: {
@@ -309,7 +289,7 @@ class OrderRepo {
309
289
  }
310
290
  });
311
291
  }
312
- const nameRegex = (_l = params.name) === null || _l === void 0 ? void 0 : _l.$regex;
292
+ const nameRegex = params.name?.$regex;
313
293
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
314
294
  andConditions.push({
315
295
  name: {
@@ -345,19 +325,19 @@ class OrderRepo {
345
325
  andConditions.push({ confirmationNumber: { $exists: true, $in: params.confirmationNumbers } });
346
326
  }
347
327
  }
348
- const orderedItemSize = (_m = params.orderedItem) === null || _m === void 0 ? void 0 : _m.$size;
328
+ const orderedItemSize = params.orderedItem?.$size;
349
329
  if (typeof orderedItemSize === 'number') {
350
330
  andConditions.push({ orderedItem: { $size: orderedItemSize } });
351
331
  }
352
- const acceptedOffersSize = (_o = params.acceptedOffers) === null || _o === void 0 ? void 0 : _o.$size;
332
+ const acceptedOffersSize = params.acceptedOffers?.$size;
353
333
  if (typeof acceptedOffersSize === 'number') {
354
334
  andConditions.push({ acceptedOffers: { $size: acceptedOffersSize } });
355
335
  }
356
- const serialNumberEq = (_q = (_p = params.acceptedOffers) === null || _p === void 0 ? void 0 : _p.serialNumber) === null || _q === void 0 ? void 0 : _q.$eq;
336
+ const serialNumberEq = params.acceptedOffers?.serialNumber?.$eq;
357
337
  if (typeof serialNumberEq === 'string') {
358
338
  andConditions.push({ 'acceptedOffers.serialNumber': { $exists: true, $eq: serialNumberEq } });
359
339
  }
360
- const itemOfferedIdentifierIn = (_t = (_s = (_r = params.acceptedOffers) === null || _r === void 0 ? void 0 : _r.itemOffered) === null || _s === void 0 ? void 0 : _s.identifier) === null || _t === void 0 ? void 0 : _t.$in;
340
+ const itemOfferedIdentifierIn = params.acceptedOffers?.itemOffered?.identifier?.$in;
361
341
  if (Array.isArray(itemOfferedIdentifierIn)) {
362
342
  andConditions.push({
363
343
  'acceptedOffers.itemOffered.identifier': {
@@ -366,7 +346,7 @@ class OrderRepo {
366
346
  }
367
347
  });
368
348
  }
369
- const itemOfferedTypeOfIn = (_w = (_v = (_u = params.acceptedOffers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.typeOf) === null || _w === void 0 ? void 0 : _w.$in;
349
+ const itemOfferedTypeOfIn = params.acceptedOffers?.itemOffered?.typeOf?.$in;
370
350
  if (Array.isArray(itemOfferedTypeOfIn)) {
371
351
  andConditions.push({
372
352
  'acceptedOffers.itemOffered.typeOf': {
@@ -375,7 +355,7 @@ class OrderRepo {
375
355
  }
376
356
  });
377
357
  }
378
- const itemOfferedIssuedThroughTypeOfEq = (_0 = (_z = (_y = (_x = params.acceptedOffers) === null || _x === void 0 ? void 0 : _x.itemOffered) === null || _y === void 0 ? void 0 : _y.issuedThrough) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$eq;
358
+ const itemOfferedIssuedThroughTypeOfEq = params.acceptedOffers?.itemOffered?.issuedThrough?.typeOf?.$eq;
379
359
  if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
380
360
  andConditions.push({
381
361
  'acceptedOffers.itemOffered.issuedThrough.typeOf': {
@@ -384,7 +364,7 @@ class OrderRepo {
384
364
  }
385
365
  });
386
366
  }
387
- const itemOfferedIssuedThroughIdIn = (_4 = (_3 = (_2 = (_1 = params.acceptedOffers) === null || _1 === void 0 ? void 0 : _1.itemOffered) === null || _2 === void 0 ? void 0 : _2.issuedThrough) === null || _3 === void 0 ? void 0 : _3.id) === null || _4 === void 0 ? void 0 : _4.$in;
367
+ const itemOfferedIssuedThroughIdIn = params.acceptedOffers?.itemOffered?.issuedThrough?.id?.$in;
388
368
  if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
389
369
  andConditions.push({
390
370
  'acceptedOffers.itemOffered.issuedThrough.id': {
@@ -393,7 +373,7 @@ class OrderRepo {
393
373
  }
394
374
  });
395
375
  }
396
- const itemOfferedProgramMembershipUsedIdentifierEq = (_8 = (_7 = (_6 = (_5 = params.acceptedOffers) === null || _5 === void 0 ? void 0 : _5.itemOffered) === null || _6 === void 0 ? void 0 : _6.programMembershipUsed) === null || _7 === void 0 ? void 0 : _7.identifier) === null || _8 === void 0 ? void 0 : _8.$eq;
376
+ const itemOfferedProgramMembershipUsedIdentifierEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.identifier?.$eq;
397
377
  if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
398
378
  andConditions.push({
399
379
  'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
@@ -402,7 +382,7 @@ class OrderRepo {
402
382
  }
403
383
  });
404
384
  }
405
- const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_14 = (_13 = (_12 = (_11 = (_10 = (_9 = params.acceptedOffers) === null || _9 === void 0 ? void 0 : _9.itemOffered) === null || _10 === void 0 ? void 0 : _10.programMembershipUsed) === null || _11 === void 0 ? void 0 : _11.issuedThrough) === null || _12 === void 0 ? void 0 : _12.serviceType) === null || _13 === void 0 ? void 0 : _13.codeValue) === null || _14 === void 0 ? void 0 : _14.$eq;
385
+ const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
406
386
  if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
407
387
  andConditions.push({
408
388
  'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
@@ -411,7 +391,7 @@ class OrderRepo {
411
391
  }
412
392
  });
413
393
  }
414
- const itemOfferedReservedTicketIdentifierEq = (_18 = (_17 = (_16 = (_15 = params.acceptedOffers) === null || _15 === void 0 ? void 0 : _15.itemOffered) === null || _16 === void 0 ? void 0 : _16.reservedTicket) === null || _17 === void 0 ? void 0 : _17.identifier) === null || _18 === void 0 ? void 0 : _18.$eq;
394
+ const itemOfferedReservedTicketIdentifierEq = params.acceptedOffers?.itemOffered?.reservedTicket?.identifier?.$eq;
415
395
  if (typeof itemOfferedReservedTicketIdentifierEq === 'string') {
416
396
  andConditions.push({
417
397
  'acceptedOffers.itemOffered.reservedTicket.identifier': {
@@ -420,13 +400,10 @@ class OrderRepo {
420
400
  }
421
401
  });
422
402
  }
423
- // tslint:disable-next-line:no-single-line-block-comment
424
403
  /* istanbul ignore else */
425
404
  if (params.acceptedOffers !== undefined) {
426
- // tslint:disable-next-line:no-single-line-block-comment
427
405
  /* istanbul ignore else */
428
406
  if (params.acceptedOffers.itemOffered !== undefined) {
429
- // tslint:disable-next-line:no-single-line-block-comment
430
407
  /* istanbul ignore else */
431
408
  if (Array.isArray(params.acceptedOffers.itemOffered.ids)) {
432
409
  andConditions.push({
@@ -436,7 +413,6 @@ class OrderRepo {
436
413
  }
437
414
  });
438
415
  }
439
- // tslint:disable-next-line:no-single-line-block-comment
440
416
  /* istanbul ignore else */
441
417
  if (Array.isArray(params.acceptedOffers.itemOffered.reservationNumbers)) {
442
418
  andConditions.push({
@@ -447,10 +423,8 @@ class OrderRepo {
447
423
  });
448
424
  }
449
425
  const reservationForConditions = params.acceptedOffers.itemOffered.reservationFor;
450
- // tslint:disable-next-line:no-single-line-block-comment
451
426
  /* istanbul ignore else */
452
427
  if (reservationForConditions !== undefined) {
453
- // tslint:disable-next-line:no-single-line-block-comment
454
428
  /* istanbul ignore else */
455
429
  if (Array.isArray(reservationForConditions.ids)) {
456
430
  andConditions.push({
@@ -460,7 +434,6 @@ class OrderRepo {
460
434
  }
461
435
  });
462
436
  }
463
- // tslint:disable-next-line:no-single-line-block-comment
464
437
  /* istanbul ignore else */
465
438
  if (typeof reservationForConditions.name === 'string' && reservationForConditions.name.length > 0) {
466
439
  andConditions.push({
@@ -480,7 +453,6 @@ class OrderRepo {
480
453
  ]
481
454
  });
482
455
  }
483
- // tslint:disable-next-line:no-single-line-block-comment
484
456
  /* istanbul ignore else */
485
457
  if (reservationForConditions.location !== undefined) {
486
458
  if (Array.isArray(reservationForConditions.location.branchCodes)) {
@@ -503,10 +475,8 @@ class OrderRepo {
503
475
  }
504
476
  }
505
477
  }
506
- // tslint:disable-next-line:no-single-line-block-comment
507
478
  /* istanbul ignore else */
508
479
  if (reservationForConditions.superEvent !== undefined) {
509
- // tslint:disable-next-line:no-single-line-block-comment
510
480
  /* istanbul ignore else */
511
481
  if (Array.isArray(reservationForConditions.superEvent.ids)) {
512
482
  andConditions.push({
@@ -516,7 +486,6 @@ class OrderRepo {
516
486
  }
517
487
  });
518
488
  }
519
- // tslint:disable-next-line:no-single-line-block-comment
520
489
  /* istanbul ignore else */
521
490
  if (reservationForConditions.superEvent.location !== undefined) {
522
491
  if (Array.isArray(reservationForConditions.superEvent.location.branchCodes)) {
@@ -539,7 +508,6 @@ class OrderRepo {
539
508
  }
540
509
  }
541
510
  }
542
- // tslint:disable-next-line:no-single-line-block-comment
543
511
  /* istanbul ignore else */
544
512
  if (reservationForConditions.superEvent.workPerformed !== undefined) {
545
513
  if (Array.isArray(reservationForConditions.superEvent.workPerformed.identifiers)) {
@@ -552,7 +520,6 @@ class OrderRepo {
552
520
  }
553
521
  }
554
522
  }
555
- // tslint:disable-next-line:no-single-line-block-comment
556
523
  /* istanbul ignore else */
557
524
  if (reservationForConditions.inSessionFrom instanceof Date) {
558
525
  andConditions.push({
@@ -562,7 +529,6 @@ class OrderRepo {
562
529
  }
563
530
  });
564
531
  }
565
- // tslint:disable-next-line:no-single-line-block-comment
566
532
  /* istanbul ignore else */
567
533
  if (reservationForConditions.inSessionThrough instanceof Date) {
568
534
  andConditions.push({
@@ -572,7 +538,6 @@ class OrderRepo {
572
538
  }
573
539
  });
574
540
  }
575
- // tslint:disable-next-line:no-single-line-block-comment
576
541
  /* istanbul ignore else */
577
542
  if (reservationForConditions.startFrom instanceof Date) {
578
543
  andConditions.push({
@@ -582,7 +547,6 @@ class OrderRepo {
582
547
  }
583
548
  });
584
549
  }
585
- // tslint:disable-next-line:no-single-line-block-comment
586
550
  /* istanbul ignore else */
587
551
  if (reservationForConditions.startThrough instanceof Date) {
588
552
  andConditions.push({
@@ -595,20 +559,18 @@ class OrderRepo {
595
559
  }
596
560
  }
597
561
  }
598
- const paymentMethodIdentifierIn = (_21 = (_20 = (_19 = params.paymentMethods) === null || _19 === void 0 ? void 0 : _19.paymentMethod) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
562
+ const paymentMethodIdentifierIn = params.paymentMethods?.paymentMethod?.identifier?.$in;
599
563
  if (Array.isArray(paymentMethodIdentifierIn)) {
600
564
  andConditions.push({ 'paymentMethods.paymentMethod.identifier': { $exists: true, $in: paymentMethodIdentifierIn } });
601
565
  }
602
- const paymentMethodsTypeOfIn = (_22 = params.paymentMethods) === null || _22 === void 0 ? void 0 : _22.typeOfs;
566
+ const paymentMethodsTypeOfIn = params.paymentMethods?.typeOfs;
603
567
  if (Array.isArray(paymentMethodsTypeOfIn)) {
604
568
  // paymentMethod.identifierで検索(2023-11-15~)
605
569
  // andConditions.push({ 'paymentMethods.typeOf': { $exists: true, $in: paymentMethodsTypeOfIn } });
606
570
  andConditions.push({ 'paymentMethods.paymentMethod.identifier': { $exists: true, $in: paymentMethodsTypeOfIn } });
607
571
  }
608
- // tslint:disable-next-line:no-single-line-block-comment
609
572
  /* istanbul ignore else */
610
573
  if (params.paymentMethods !== undefined) {
611
- // tslint:disable-next-line:no-single-line-block-comment
612
574
  /* istanbul ignore else */
613
575
  if (Array.isArray(params.paymentMethods.accountIds)) {
614
576
  andConditions.push({
@@ -618,7 +580,6 @@ class OrderRepo {
618
580
  }
619
581
  });
620
582
  }
621
- // tslint:disable-next-line:no-single-line-block-comment
622
583
  /* istanbul ignore else */
623
584
  if (Array.isArray(params.paymentMethods.paymentMethodIds)) {
624
585
  andConditions.push({
@@ -629,7 +590,7 @@ class OrderRepo {
629
590
  });
630
591
  }
631
592
  }
632
- const paymentMethodAdditionalPropertyAll = (_24 = (_23 = params.paymentMethods) === null || _23 === void 0 ? void 0 : _23.additionalProperty) === null || _24 === void 0 ? void 0 : _24.$all;
593
+ const paymentMethodAdditionalPropertyAll = params.paymentMethods?.additionalProperty?.$all;
633
594
  if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
634
595
  andConditions.push({
635
596
  'paymentMethods.additionalProperty': {
@@ -638,7 +599,7 @@ class OrderRepo {
638
599
  }
639
600
  });
640
601
  }
641
- const paymentMethodAdditionalPropertyIn = (_26 = (_25 = params.paymentMethods) === null || _25 === void 0 ? void 0 : _25.additionalProperty) === null || _26 === void 0 ? void 0 : _26.$in;
602
+ const paymentMethodAdditionalPropertyIn = params.paymentMethods?.additionalProperty?.$in;
642
603
  if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
643
604
  andConditions.push({
644
605
  'paymentMethods.additionalProperty': {
@@ -647,14 +608,12 @@ class OrderRepo {
647
608
  }
648
609
  });
649
610
  }
650
- // tslint:disable-next-line:no-single-line-block-comment
651
611
  /* istanbul ignore else */
652
612
  if (params.orderDateFrom instanceof Date) {
653
613
  andConditions.push({
654
614
  orderDate: { $gte: params.orderDateFrom }
655
615
  });
656
616
  }
657
- // tslint:disable-next-line:no-single-line-block-comment
658
617
  /* istanbul ignore else */
659
618
  if (params.orderDateThrough instanceof Date) {
660
619
  andConditions.push({
@@ -696,622 +655,615 @@ class OrderRepo {
696
655
  /**
697
656
  * なければ作成する
698
657
  */
699
- createIfNotExist(order) {
700
- return __awaiter(this, void 0, void 0, function* () {
701
- try {
702
- // 存在しなければ上書き
703
- // updateOneに変更(2024-01-14~)
704
- // await this.orderModel.findOneAndUpdate(
705
- yield this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
706
- // new: true,
707
- upsert: true
708
- })
709
- .exec();
710
- }
711
- catch (error) {
712
- let throwsError = true;
713
- if (yield (0, errorHandler_1.isMongoError)(error)) {
714
- // すでにorderNumberが存在する場合ok
715
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
716
- throwsError = false;
717
- }
718
- }
719
- if (throwsError) {
720
- throw error;
658
+ async createIfNotExist(order) {
659
+ try {
660
+ // 存在しなければ上書き
661
+ // updateOneに変更(2024-01-14~)
662
+ // await this.orderModel.findOneAndUpdate(
663
+ await this.orderModel.updateOne({ orderNumber: order.orderNumber }, { $setOnInsert: order }, {
664
+ // new: true,
665
+ upsert: true
666
+ })
667
+ .exec();
668
+ }
669
+ catch (error) {
670
+ let throwsError = true;
671
+ if (await (0, errorHandler_1.isMongoError)(error)) {
672
+ // すでにorderNumberが存在する場合ok
673
+ if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
674
+ throwsError = false;
721
675
  }
722
676
  }
723
- });
677
+ if (throwsError) {
678
+ throw error;
679
+ }
680
+ }
724
681
  }
725
682
  /**
726
683
  * 注文ステータスを変更する
727
684
  */
728
- changeStatus(params) {
729
- return __awaiter(this, void 0, void 0, function* () {
730
- const { orderNumber, previousOrderStatus, orderStatus } = params;
731
- const doc = yield this.orderModel.findOneAndUpdate({
732
- orderNumber: { $eq: orderNumber },
733
- orderStatus: { $eq: previousOrderStatus },
734
- 'project.id': { $eq: params.project.id },
735
- typeOf: { $eq: factory.order.OrderType.Order }
736
- }, {
737
- $set: {
738
- previousOrderStatus, // 追加(2023-08-31~)
739
- orderStatus
740
- }
741
- }, {
742
- new: true,
743
- // inclusion projection(2024-07-25~)
744
- projection: {
745
- _id: 0, // hide _id(2024-07-25~)
746
- id: { $toString: '$_id' },
747
- orderNumber: 1, broker: 1, confirmationNumber: 1, customer: 1, dateReturned: 1,
748
- name: 1, orderDate: 1, orderStatus: 1, orderedItem: 1, paymentMethods: 1,
749
- previousOrderStatus: 1, price: 1, priceCurrency: 1, project: 1, returner: 1, seller: 1, typeOf: 1
750
- }
751
- // projection: {
752
- // __v: 0,
753
- // createdAt: 0,
754
- // updatedAt: 0,
755
- // acceptedOffers: 0 // 除外(2023-12-08~)
756
- // }
757
- })
758
- .lean() // lean(2024-07-25~)
759
- .exec();
760
- // NotFoundであれば状態確認
761
- if (doc === null) {
762
- const order = yield this.projectFieldsByOrderNumber({
763
- orderNumber: params.orderNumber,
764
- project: { id: params.project.id },
765
- inclusion: [
766
- 'orderNumber', 'broker', 'confirmationNumber', 'customer', 'dateReturned',
767
- 'name', 'orderDate', 'orderStatus', 'orderedItem', 'paymentMethods',
768
- 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf'
769
- ] // inclusion projection(2024-07-25~)
770
- });
771
- // tslint:disable-next-line:no-single-line-block-comment
685
+ async changeStatus(params) {
686
+ const { orderNumber, previousOrderStatus, orderStatus } = params;
687
+ const doc = await this.orderModel.findOneAndUpdate({
688
+ orderNumber: { $eq: orderNumber },
689
+ orderStatus: { $eq: previousOrderStatus },
690
+ 'project.id': { $eq: params.project.id },
691
+ typeOf: { $eq: factory.order.OrderType.Order }
692
+ }, {
693
+ $set: {
694
+ previousOrderStatus, // 追加(2023-08-31~)
695
+ orderStatus
696
+ }
697
+ }, {
698
+ new: true,
699
+ // inclusion projection(2024-07-25~)
700
+ projection: {
701
+ _id: 0, // hide _id(2024-07-25~)
702
+ id: { $toString: '$_id' },
703
+ orderNumber: 1, broker: 1, confirmationNumber: 1, customer: 1, dateReturned: 1,
704
+ name: 1, orderDate: 1, orderStatus: 1, orderedItem: 1, paymentMethods: 1,
705
+ previousOrderStatus: 1, price: 1, priceCurrency: 1, project: 1, returner: 1, seller: 1, typeOf: 1
706
+ }
707
+ // projection: {
708
+ // __v: 0,
709
+ // createdAt: 0,
710
+ // updatedAt: 0,
711
+ // acceptedOffers: 0 // 除外(2023-12-08~)
712
+ // }
713
+ })
714
+ .lean() // lean(2024-07-25~)
715
+ .exec();
716
+ // NotFoundであれば状態確認
717
+ if (doc === null) {
718
+ const order = await this.projectFieldsByOrderNumber({
719
+ orderNumber: params.orderNumber,
720
+ project: { id: params.project.id },
721
+ inclusion: [
722
+ 'orderNumber', 'broker', 'confirmationNumber', 'customer', 'dateReturned',
723
+ 'name', 'orderDate', 'orderStatus', 'orderedItem', 'paymentMethods',
724
+ 'previousOrderStatus', 'price', 'priceCurrency', 'project', 'returner', 'seller', 'typeOf'
725
+ ] // inclusion projection(2024-07-25~)
726
+ });
727
+ /* istanbul ignore next */
728
+ if (order.orderStatus === params.orderStatus) {
729
+ // すでに変更済の場合
730
+ return order;
772
731
  /* istanbul ignore next */
773
- if (order.orderStatus === params.orderStatus) {
774
- // すでに変更済の場合
775
- return order;
776
- // tslint:disable-next-line:no-single-line-block-comment
777
- /* istanbul ignore next */
778
- }
779
- else {
780
- throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
781
- }
782
732
  }
783
- return doc;
784
- });
733
+ else {
734
+ throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
735
+ }
736
+ }
737
+ return doc;
785
738
  }
786
739
  /**
787
740
  * 注文を返品する
788
741
  */
789
- returnOrder(params) {
790
- return __awaiter(this, void 0, void 0, function* () {
791
- const { dateReturned, returner, orderNumber, project } = params;
792
- const doc = yield this.orderModel.findOneAndUpdate({
793
- orderNumber: { $eq: orderNumber },
794
- orderStatus: { $eq: factory.orderStatus.OrderDelivered },
795
- 'project.id': { $eq: project.id },
796
- typeOf: { $eq: factory.order.OrderType.Order }
797
- }, {
798
- $set: {
799
- previousOrderStatus: factory.orderStatus.OrderDelivered,
800
- orderStatus: factory.orderStatus.OrderReturned,
801
- dateReturned,
802
- returner
803
- }
804
- }, {
805
- new: true,
806
- projection: {
807
- _id: 0, // hide _id(2024-07-30~)
808
- id: { $toString: '$_id' },
809
- // _id: 1,
810
- project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
811
- customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
812
- // __v: 0,
813
- // createdAt: 0,
814
- // updatedAt: 0
815
- }
816
- })
817
- .lean() // lean(2024-07-30~)
818
- .exec();
819
- // NotFoundであれば状態確認
820
- if (doc === null) {
821
- const order = yield this.projectFieldsByOrderNumber({
822
- orderNumber: params.orderNumber,
823
- project: { id: params.project.id },
824
- inclusion: [
825
- 'project', 'typeOf', 'orderNumber', 'dateReturned',
826
- 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
827
- ]
828
- });
829
- // tslint:disable-next-line:no-single-line-block-comment
742
+ async returnOrder(params) {
743
+ const { dateReturned, returner, orderNumber, project } = params;
744
+ const doc = await this.orderModel.findOneAndUpdate({
745
+ orderNumber: { $eq: orderNumber },
746
+ orderStatus: { $eq: factory.orderStatus.OrderDelivered },
747
+ 'project.id': { $eq: project.id },
748
+ typeOf: { $eq: factory.order.OrderType.Order }
749
+ }, {
750
+ $set: {
751
+ previousOrderStatus: factory.orderStatus.OrderDelivered,
752
+ orderStatus: factory.orderStatus.OrderReturned,
753
+ dateReturned,
754
+ returner
755
+ }
756
+ }, {
757
+ new: true,
758
+ projection: {
759
+ _id: 0, // hide _id(2024-07-30~)
760
+ id: { $toString: '$_id' },
761
+ // _id: 1,
762
+ project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
763
+ customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
764
+ // __v: 0,
765
+ // createdAt: 0,
766
+ // updatedAt: 0
767
+ }
768
+ })
769
+ .lean() // lean(2024-07-30~)
770
+ .exec();
771
+ // NotFoundであれば状態確認
772
+ if (doc === null) {
773
+ const order = await this.projectFieldsByOrderNumber({
774
+ orderNumber: params.orderNumber,
775
+ project: { id: params.project.id },
776
+ inclusion: [
777
+ 'project', 'typeOf', 'orderNumber', 'dateReturned',
778
+ 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
779
+ ]
780
+ });
781
+ /* istanbul ignore next */
782
+ if (order.orderStatus === factory.orderStatus.OrderReturned) {
783
+ // すでに変更済の場合
784
+ return order;
830
785
  /* istanbul ignore next */
831
- if (order.orderStatus === factory.orderStatus.OrderReturned) {
832
- // すでに変更済の場合
833
- return order;
834
- // tslint:disable-next-line:no-single-line-block-comment
835
- /* istanbul ignore next */
836
- }
837
- else {
838
- throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
839
- }
840
786
  }
841
- return doc;
842
- });
787
+ else {
788
+ throw new factory.errors.Argument('orderNumber', `Order ${order.orderNumber} already changed -> ${order.orderStatus}`);
789
+ }
790
+ }
791
+ return doc;
843
792
  }
844
793
  /**
845
794
  * 変更可能な属性を更新する
846
795
  */
847
- updateChangeableAttributes(params) {
848
- return __awaiter(this, void 0, void 0, function* () {
849
- const updatedAt = new Date();
850
- const { orderNumber, project, name } = params;
851
- const doc = yield this.orderModel.findOneAndUpdate({
852
- orderNumber: { $eq: orderNumber },
853
- 'project.id': { $eq: project.id },
854
- typeOf: { $eq: factory.order.OrderType.Order }
855
- }, {
856
- $set: Object.assign({}, (typeof name === 'string') ? { name } : undefined)
857
- }, {
858
- new: false,
859
- projection: {
860
- _id: 1
861
- // updatedAt: 1 // discontinue(2024-06-17~)
862
- }
863
- })
864
- .lean() // lean(2024-07-30~)
865
- .exec();
866
- if (doc === null) {
867
- throw new factory.errors.NotFound(this.orderModel.modelName);
796
+ async updateChangeableAttributes(params) {
797
+ const updatedAt = new Date();
798
+ const { orderNumber, project, name } = params;
799
+ const doc = await this.orderModel.findOneAndUpdate({
800
+ orderNumber: { $eq: orderNumber },
801
+ 'project.id': { $eq: project.id },
802
+ typeOf: { $eq: factory.order.OrderType.Order }
803
+ }, {
804
+ $set: {
805
+ ...(typeof name === 'string') ? { name } : undefined
806
+ }
807
+ }, {
808
+ new: false,
809
+ projection: {
810
+ _id: 1
811
+ // updatedAt: 1 // discontinue(2024-06-17~)
868
812
  }
869
- return { updatedAt };
870
- });
813
+ })
814
+ .lean() // lean(2024-07-30~)
815
+ .exec();
816
+ if (doc === null) {
817
+ throw new factory.errors.NotFound(this.orderModel.modelName);
818
+ }
819
+ return { updatedAt };
871
820
  }
872
821
  /**
873
822
  * 注文後に決済方法区分を確定する
874
823
  */
875
- fixPaymentMethodIdentifier(params) {
876
- return __awaiter(this, void 0, void 0, function* () {
877
- const doc = yield this.orderModel.findOneAndUpdate({
878
- orderNumber: { $eq: params.orderNumber },
879
- 'project.id': { $eq: params.project.id },
880
- typeOf: { $eq: factory.order.OrderType.Order },
881
- 'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
882
- }, {
883
- $set: {
884
- 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
885
- // tslint:disable-next-line:no-suspicious-comment
886
- // TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
887
- 'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
888
- }
889
- }, {
890
- arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
891
- new: true,
892
- projection: {
893
- _id: 1
894
- }
895
- })
896
- .lean() // lean(2024-07-30~)
897
- .exec();
898
- if (doc === null) {
899
- throw new factory.errors.NotFound(this.orderModel.modelName);
900
- }
901
- });
902
- }
903
- projectFieldsById(params) {
904
- return __awaiter(this, void 0, void 0, function* () {
905
- const projection = {
906
- // _id: 1
907
- _id: 0, // hide _id(2024-07-25~)
908
- id: { $toString: '$_id' }
909
- };
910
- if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
911
- params.inclusion.forEach((field) => {
912
- // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
913
- // projection[field] = 1;
914
- // }
915
- if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
916
- projection[field] = 1;
917
- }
918
- });
824
+ async fixPaymentMethodIdentifier(params) {
825
+ const doc = await this.orderModel.findOneAndUpdate({
826
+ orderNumber: { $eq: params.orderNumber },
827
+ 'project.id': { $eq: params.project.id },
828
+ typeOf: { $eq: factory.order.OrderType.Order },
829
+ 'paymentMethods.paymentMethodId': { $exists: true, $eq: params.invoice.paymentMethodId }
830
+ }, {
831
+ $set: {
832
+ 'paymentMethods.$[invoice].paymentMethod.identifier': params.invoice.paymentMethod.identifier,
833
+ // TODO 互換性維持対応としてtypeOfも変更しているが、そのうち廃止(2023-08-30)
834
+ 'paymentMethods.$[invoice].typeOf': params.invoice.paymentMethod.identifier
919
835
  }
920
- else {
921
- // discontinue(2024-07-25~)
922
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
836
+ }, {
837
+ arrayFilters: [{ 'invoice.paymentMethodId': { $eq: params.invoice.paymentMethodId } }],
838
+ new: true,
839
+ projection: {
840
+ _id: 1
923
841
  }
924
- const doc = yield this.orderModel.findOne({
925
- _id: { $eq: params.id },
926
- typeOf: { $eq: factory.order.OrderType.Order }
927
- }, projection)
928
- .lean() // lean(2024-07-25~)
929
- .exec();
930
- if (doc === null) {
931
- throw new factory.errors.NotFound(this.orderModel.modelName);
932
- }
933
- return doc;
934
- });
842
+ })
843
+ .lean() // lean(2024-07-30~)
844
+ .exec();
845
+ if (doc === null) {
846
+ throw new factory.errors.NotFound(this.orderModel.modelName);
847
+ }
848
+ }
849
+ async projectFieldsById(params) {
850
+ const projection = {
851
+ // _id: 1
852
+ _id: 0, // hide _id(2024-07-25~)
853
+ id: { $toString: '$_id' }
854
+ };
855
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
856
+ params.inclusion.forEach((field) => {
857
+ // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
858
+ // projection[field] = 1;
859
+ // }
860
+ if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
861
+ projection[field] = 1;
862
+ }
863
+ });
864
+ }
865
+ else {
866
+ // discontinue(2024-07-25~)
867
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
868
+ }
869
+ const doc = await this.orderModel.findOne({
870
+ _id: { $eq: params.id },
871
+ typeOf: { $eq: factory.order.OrderType.Order }
872
+ }, projection)
873
+ .lean() // lean(2024-07-25~)
874
+ .exec();
875
+ if (doc === null) {
876
+ throw new factory.errors.NotFound(this.orderModel.modelName);
877
+ }
878
+ return doc;
935
879
  }
936
880
  /**
937
881
  * 注文番号から注文を取得する
938
882
  */
939
- projectFieldsByOrderNumber(
883
+ async projectFieldsByOrderNumber(
940
884
  // public async findByOrderNumber(
941
885
  params) {
942
- return __awaiter(this, void 0, void 0, function* () {
943
- const projection = {
944
- _id: 0, // hide _id(2024-07-25~)
945
- id: { $toString: '$_id' }
946
- };
947
- if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
948
- params.inclusion.forEach((field) => {
949
- // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
950
- // projection[field] = 1;
951
- // }
952
- if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
953
- projection[field] = 1;
954
- }
955
- });
956
- }
957
- else {
958
- // discontinue(2024-07-25~)
959
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
960
- }
961
- const doc = yield this.orderModel.findOne({
962
- orderNumber: { $eq: params.orderNumber },
963
- 'project.id': { $eq: params.project.id },
964
- typeOf: { $eq: factory.order.OrderType.Order }
965
- }, projection)
966
- .lean() // lean(2024-07-25~)
967
- .exec();
968
- if (doc === null) {
969
- throw new factory.errors.NotFound(this.orderModel.modelName);
970
- }
971
- return doc;
972
- });
886
+ const projection = {
887
+ _id: 0, // hide _id(2024-07-25~)
888
+ id: { $toString: '$_id' }
889
+ };
890
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
891
+ params.inclusion.forEach((field) => {
892
+ // if (String(field) !== 'acceptedOffers' && field !== '_id' && field !== 'id') {
893
+ // projection[field] = 1;
894
+ // }
895
+ if (AVAILABLE_PROJECT_FIELDS.includes(field)) {
896
+ projection[field] = 1;
897
+ }
898
+ });
899
+ }
900
+ else {
901
+ // discontinue(2024-07-25~)
902
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
903
+ }
904
+ const doc = await this.orderModel.findOne({
905
+ orderNumber: { $eq: params.orderNumber },
906
+ 'project.id': { $eq: params.project.id },
907
+ typeOf: { $eq: factory.order.OrderType.Order }
908
+ }, projection)
909
+ .lean() // lean(2024-07-25~)
910
+ .exec();
911
+ if (doc === null) {
912
+ throw new factory.errors.NotFound(this.orderModel.modelName);
913
+ }
914
+ return doc;
973
915
  }
974
- findByOrderNumberAndReservationId(params) {
975
- return __awaiter(this, void 0, void 0, function* () {
976
- var _a;
977
- const projection = {
978
- orderStatus: 1,
979
- typeOf: 1,
980
- orderNumber: 1,
981
- _id: 0
982
- };
983
- const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, typeOf: { $eq: factory.order.OrderType.Order }, acceptedOffers: {
984
- $elemMatch: {
985
- 'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
986
- 'itemOffered.id': { $eq: params.reservationId }
987
- }
988
- } }, (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string')
916
+ async findByOrderNumberAndReservationId(params) {
917
+ const projection = {
918
+ orderStatus: 1,
919
+ typeOf: 1,
920
+ orderNumber: 1,
921
+ _id: 0
922
+ };
923
+ const doc = await this.orderModel.findOne({
924
+ orderNumber: { $eq: params.orderNumber },
925
+ 'project.id': { $eq: params.project.id },
926
+ typeOf: { $eq: factory.order.OrderType.Order },
927
+ acceptedOffers: {
928
+ $elemMatch: {
929
+ 'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
930
+ 'itemOffered.id': { $eq: params.reservationId }
931
+ }
932
+ },
933
+ ...(typeof params.seller?.id === 'string')
989
934
  ? { 'seller.id': { $exists: true, $eq: params.seller.id } }
990
- : undefined), projection)
991
- // projection的にleanで十分
992
- .lean()
993
- .exec();
994
- if (doc === null) {
995
- throw new factory.errors.NotFound(this.orderModel.modelName);
996
- }
997
- return doc;
998
- });
935
+ : undefined
936
+ }, projection)
937
+ // projection的にleanで十分
938
+ .lean()
939
+ .exec();
940
+ if (doc === null) {
941
+ throw new factory.errors.NotFound(this.orderModel.modelName);
942
+ }
943
+ return doc;
999
944
  }
1000
945
  /**
1001
946
  * 注文番号で削除する
1002
947
  */
1003
- deleteByOrderNumber(params) {
1004
- return __awaiter(this, void 0, void 0, function* () {
1005
- yield this.orderModel.deleteOne({
1006
- orderNumber: { $eq: params.orderNumber },
1007
- typeOf: { $eq: factory.order.OrderType.Order }
1008
- })
1009
- .exec();
1010
- });
948
+ async deleteByOrderNumber(params) {
949
+ await this.orderModel.deleteOne({
950
+ orderNumber: { $eq: params.orderNumber },
951
+ typeOf: { $eq: factory.order.OrderType.Order }
952
+ })
953
+ .exec();
1011
954
  }
1012
- count(params) {
1013
- return __awaiter(this, void 0, void 0, function* () {
1014
- const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1015
- return this.orderModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
1016
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1017
- .exec();
1018
- });
955
+ async count(params) {
956
+ const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
957
+ return this.orderModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
958
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
959
+ .exec();
1019
960
  }
1020
961
  /**
1021
962
  * 注文を検索する(inclusion projection)
1022
963
  * redefine from search(2024-07-31~)
1023
964
  */
1024
- projectFields(params, options) {
1025
- return __awaiter(this, void 0, void 0, function* () {
1026
- var _a;
1027
- const { inclusion } = options;
1028
- const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1029
- let projectStage = {};
1030
- const positiveProjectionFields = (Array.isArray(inclusion))
1031
- ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
1032
- : [];
1033
- if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
1034
- projectStage = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
1035
- }
1036
- else {
1037
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
1038
- }
1039
- const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
1040
- if (typeof params.limit === 'number' && params.limit > 0) {
1041
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1042
- query.limit(params.limit)
1043
- .skip(params.limit * (page - 1));
1044
- }
1045
- // tslint:disable-next-line:no-single-line-block-comment
1046
- /* istanbul ignore else */
1047
- if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) !== undefined) {
1048
- query.sort({ orderDate: params.sort.orderDate });
1049
- }
1050
- // const explainResult = await (<any>query).explain();
1051
- // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
1052
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1053
- .lean() // lean(2024-07-25~)
1054
- .exec();
1055
- });
965
+ async projectFields(params, options) {
966
+ const { inclusion } = options;
967
+ const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
968
+ let projectStage = {};
969
+ const positiveProjectionFields = (Array.isArray(inclusion))
970
+ ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
971
+ : [];
972
+ if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
973
+ projectStage = {
974
+ _id: 0, // hide _id(2024-07-25~)
975
+ id: { $toString: '$_id' },
976
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
977
+ };
978
+ }
979
+ else {
980
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
981
+ }
982
+ const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
983
+ if (typeof params.limit === 'number' && params.limit > 0) {
984
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
985
+ query.limit(params.limit)
986
+ .skip(params.limit * (page - 1));
987
+ }
988
+ /* istanbul ignore else */
989
+ if (params.sort?.orderDate !== undefined) {
990
+ query.sort({ orderDate: params.sort.orderDate });
991
+ }
992
+ // const explainResult = await (<any>query).explain();
993
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
994
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
995
+ .lean() // lean(2024-07-25~)
996
+ .exec();
1056
997
  }
1057
998
  getCursor(conditions, projection) {
1058
999
  return this.orderModel.find(conditions, projection)
1059
1000
  .sort({ orderDate: factory.sortType.Descending })
1060
1001
  .cursor();
1061
1002
  }
1062
- unsetUnnecessaryFields(params) {
1063
- return __awaiter(this, void 0, void 0, function* () {
1064
- return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1065
- .exec();
1066
- });
1003
+ async unsetUnnecessaryFields(params) {
1004
+ return this.orderModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
1005
+ .exec();
1067
1006
  }
1068
- // tslint:disable-next-line:max-func-body-length
1069
- aggregateOrder(params) {
1070
- return __awaiter(this, void 0, void 0, function* () {
1071
- var _a, _b;
1072
- const matchConditions = Object.assign({ orderDate: {
1073
- $gte: params.orderDate.$gte,
1074
- $lte: params.orderDate.$lte
1075
- }, typeOf: { $eq: factory.order.OrderType.Order } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
1007
+ async aggregateOrder(params) {
1008
+ const matchConditions = {
1009
+ orderDate: {
1010
+ $gte: params.orderDate.$gte,
1011
+ $lte: params.orderDate.$lte
1012
+ },
1013
+ typeOf: { $eq: factory.order.OrderType.Order },
1014
+ ...(typeof params.project?.id?.$ne === 'string')
1076
1015
  ? { 'project.id': { $ne: params.project.id.$ne } }
1077
- : undefined);
1078
- const aggregations = yield this.orderModel.aggregate([
1079
- { $match: matchConditions },
1080
- {
1081
- $project: {
1082
- typeOf: '$typeOf',
1083
- price: '$price',
1084
- numAcceptedOffers: { $size: '$acceptedOffers' }
1085
- }
1086
- },
1087
- {
1088
- $group: {
1089
- _id: '$typeOf',
1090
- orderCount: { $sum: 1 },
1091
- totalNumAcceptedOffer: { $sum: '$numAcceptedOffers' },
1092
- maxNumAcceptedOffer: { $max: '$numAcceptedOffers' },
1093
- minNumAcceptedOffer: { $min: '$numAcceptedOffers' },
1094
- avgNumAcceptedOffer: { $avg: '$numAcceptedOffers' },
1095
- totalPrice: { $sum: '$price' },
1096
- maxPrice: { $max: '$price' },
1097
- minPrice: { $min: '$price' },
1098
- avgPrice: { $avg: '$price' }
1099
- }
1100
- },
1101
- {
1102
- $project: {
1103
- _id: 0,
1104
- orderCount: '$orderCount',
1105
- totalNumAcceptedOffer: '$totalNumAcceptedOffer',
1106
- maxNumAcceptedOffer: '$maxNumAcceptedOffer',
1107
- minNumAcceptedOffer: '$minNumAcceptedOffer',
1108
- avgNumAcceptedOffer: '$avgNumAcceptedOffer',
1109
- totalPrice: '$totalPrice',
1110
- maxPrice: '$maxPrice',
1111
- minPrice: '$minPrice',
1112
- avgPrice: '$avgPrice'
1113
- }
1016
+ : undefined
1017
+ };
1018
+ const aggregations = await this.orderModel.aggregate([
1019
+ { $match: matchConditions },
1020
+ {
1021
+ $project: {
1022
+ typeOf: '$typeOf',
1023
+ price: '$price',
1024
+ numAcceptedOffers: { $size: '$acceptedOffers' }
1025
+ }
1026
+ },
1027
+ {
1028
+ $group: {
1029
+ _id: '$typeOf',
1030
+ orderCount: { $sum: 1 },
1031
+ totalNumAcceptedOffer: { $sum: '$numAcceptedOffers' },
1032
+ maxNumAcceptedOffer: { $max: '$numAcceptedOffers' },
1033
+ minNumAcceptedOffer: { $min: '$numAcceptedOffers' },
1034
+ avgNumAcceptedOffer: { $avg: '$numAcceptedOffers' },
1035
+ totalPrice: { $sum: '$price' },
1036
+ maxPrice: { $max: '$price' },
1037
+ minPrice: { $min: '$price' },
1038
+ avgPrice: { $avg: '$price' }
1039
+ }
1040
+ },
1041
+ {
1042
+ $project: {
1043
+ _id: 0,
1044
+ orderCount: '$orderCount',
1045
+ totalNumAcceptedOffer: '$totalNumAcceptedOffer',
1046
+ maxNumAcceptedOffer: '$maxNumAcceptedOffer',
1047
+ minNumAcceptedOffer: '$minNumAcceptedOffer',
1048
+ avgNumAcceptedOffer: '$avgNumAcceptedOffer',
1049
+ totalPrice: '$totalPrice',
1050
+ maxPrice: '$maxPrice',
1051
+ minPrice: '$minPrice',
1052
+ avgPrice: '$avgPrice'
1114
1053
  }
1115
- ])
1116
- .exec();
1117
- if (aggregations.length === 0) {
1118
- return {
1119
- aggregation: {
1120
- orderCount: 0,
1121
- totalNumAcceptedOffer: 0,
1122
- maxNumAcceptedOffer: 0,
1123
- minNumAcceptedOffer: 0,
1124
- avgNumAcceptedOffer: 0,
1125
- totalPrice: 0,
1126
- maxPrice: 0,
1127
- minPrice: 0,
1128
- avgPrice: 0
1129
- }
1130
- };
1131
1054
  }
1132
- return { aggregation: aggregations[0] };
1133
- });
1055
+ ])
1056
+ .exec();
1057
+ if (aggregations.length === 0) {
1058
+ return {
1059
+ aggregation: {
1060
+ orderCount: 0,
1061
+ totalNumAcceptedOffer: 0,
1062
+ maxNumAcceptedOffer: 0,
1063
+ minNumAcceptedOffer: 0,
1064
+ avgNumAcceptedOffer: 0,
1065
+ totalPrice: 0,
1066
+ maxPrice: 0,
1067
+ minPrice: 0,
1068
+ avgPrice: 0
1069
+ }
1070
+ };
1071
+ }
1072
+ return { aggregation: aggregations[0] };
1134
1073
  }
1135
- aggregateOrderOfSeat(params) {
1136
- return __awaiter(this, void 0, void 0, function* () {
1137
- var _a, _b;
1138
- const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
1139
- const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
1140
- const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
1141
- const customerEmailIn = (_b = (_a = params.customer) === null || _a === void 0 ? void 0 : _a.email) === null || _b === void 0 ? void 0 : _b.$in;
1142
- const matchConditions = Object.assign({ orderDate: {
1143
- $gte: params.orderDate.$gte,
1144
- $lte: params.orderDate.$lte
1145
- }, typeOf: { $eq: factory.order.OrderType.Order }, 'project.id': { $eq: params.project.id.$eq }, 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode }, 'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode }, 'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber } }, (Array.isArray(customerEmailIn))
1074
+ async aggregateOrderOfSeat(params) {
1075
+ const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
1076
+ const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
1077
+ const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
1078
+ const customerEmailIn = params.customer?.email?.$in;
1079
+ const matchConditions = {
1080
+ orderDate: {
1081
+ $gte: params.orderDate.$gte,
1082
+ $lte: params.orderDate.$lte
1083
+ },
1084
+ typeOf: { $eq: factory.order.OrderType.Order },
1085
+ 'project.id': { $eq: params.project.id.$eq },
1086
+ 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode },
1087
+ 'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode },
1088
+ 'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber },
1089
+ ...(Array.isArray(customerEmailIn))
1146
1090
  ? { 'customer.email': { $exists: true, $in: customerEmailIn } }
1147
- : undefined);
1148
- const aggregations4email = yield this.orderModel.aggregate([
1149
- { $match: matchConditions },
1150
- {
1151
- $group: {
1152
- _id: '$customer.email'
1153
- }
1154
- },
1155
- {
1156
- $count: 'emailCount'
1091
+ : undefined
1092
+ };
1093
+ const aggregations4email = await this.orderModel.aggregate([
1094
+ { $match: matchConditions },
1095
+ {
1096
+ $group: {
1097
+ _id: '$customer.email'
1157
1098
  }
1158
- ])
1159
- .exec();
1160
- const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
1161
- const aggregations = yield this.orderModel.aggregate([
1162
- { $match: matchConditions },
1163
- {
1164
- $project: {
1165
- typeOf: '$typeOf',
1166
- graceTime: {
1167
- $subtract: [
1168
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1169
- '$orderDate'
1170
- ]
1171
- }
1172
- }
1173
- },
1174
- {
1175
- $group: {
1176
- _id: '$typeOf',
1177
- orderCount: { $sum: 1 },
1178
- sumGraceTime: { $sum: '$graceTime' }
1179
- }
1180
- },
1181
- {
1182
- $project: {
1183
- _id: 0,
1184
- orderCount: '$orderCount',
1185
- sumGraceTime: '$sumGraceTime'
1099
+ },
1100
+ {
1101
+ $count: 'emailCount'
1102
+ }
1103
+ ])
1104
+ .exec();
1105
+ const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
1106
+ const aggregations = await this.orderModel.aggregate([
1107
+ { $match: matchConditions },
1108
+ {
1109
+ $project: {
1110
+ typeOf: '$typeOf',
1111
+ graceTime: {
1112
+ $subtract: [
1113
+ { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1114
+ '$orderDate'
1115
+ ]
1186
1116
  }
1187
1117
  }
1188
- ])
1189
- .exec();
1190
- if (aggregations.length === 0) {
1191
- return {
1192
- aggregation: {
1193
- orderCount: 0
1194
- }
1195
- };
1118
+ },
1119
+ {
1120
+ $group: {
1121
+ _id: '$typeOf',
1122
+ orderCount: { $sum: 1 },
1123
+ sumGraceTime: { $sum: '$graceTime' }
1124
+ }
1125
+ },
1126
+ {
1127
+ $project: {
1128
+ _id: 0,
1129
+ orderCount: '$orderCount',
1130
+ sumGraceTime: '$sumGraceTime'
1131
+ }
1196
1132
  }
1133
+ ])
1134
+ .exec();
1135
+ if (aggregations.length === 0) {
1197
1136
  return {
1198
- aggregation: Object.assign(Object.assign({}, aggregations[0]), { emailCount })
1137
+ aggregation: {
1138
+ orderCount: 0
1139
+ }
1199
1140
  };
1200
- });
1141
+ }
1142
+ return {
1143
+ aggregation: {
1144
+ ...aggregations[0],
1145
+ emailCount
1146
+ }
1147
+ };
1201
1148
  }
1202
- aggregateOrderOfCustomerByProject(params) {
1203
- return __awaiter(this, void 0, void 0, function* () {
1204
- var _a;
1205
- const matchConditions = Object.assign(Object.assign({ orderDate: {
1206
- $gte: params.orderDate.$gte,
1207
- $lte: params.orderDate.$lte
1208
- }, typeOf: { $eq: factory.order.OrderType.Order } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined), { 'customer.email': { $exists: true, $eq: params.customer.email.$eq } });
1209
- const aggregations = yield this.orderModel.aggregate([
1210
- { $match: matchConditions },
1211
- {
1212
- $project: {
1213
- typeOf: '$typeOf',
1214
- graceTime: {
1215
- $subtract: [
1216
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1217
- '$orderDate'
1218
- ]
1219
- }
1220
- }
1221
- },
1222
- {
1223
- $group: {
1224
- _id: '$typeOf',
1225
- orderCount: { $sum: 1 },
1226
- sumGraceTime: { $sum: '$graceTime' }
1227
- }
1228
- },
1229
- {
1230
- $project: {
1231
- _id: 0,
1232
- orderCount: '$orderCount',
1233
- sumGraceTime: '$sumGraceTime'
1149
+ async aggregateOrderOfCustomerByProject(params) {
1150
+ const matchConditions = {
1151
+ orderDate: {
1152
+ $gte: params.orderDate.$gte,
1153
+ $lte: params.orderDate.$lte
1154
+ },
1155
+ typeOf: { $eq: factory.order.OrderType.Order },
1156
+ ...(typeof params.project?.id.$eq === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined,
1157
+ 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1158
+ };
1159
+ const aggregations = await this.orderModel.aggregate([
1160
+ { $match: matchConditions },
1161
+ {
1162
+ $project: {
1163
+ typeOf: '$typeOf',
1164
+ graceTime: {
1165
+ $subtract: [
1166
+ { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1167
+ '$orderDate'
1168
+ ]
1234
1169
  }
1235
1170
  }
1236
- ])
1237
- .exec();
1238
- if (aggregations.length === 0) {
1239
- return {
1240
- aggregation: {
1241
- orderCount: 0
1242
- }
1243
- };
1171
+ },
1172
+ {
1173
+ $group: {
1174
+ _id: '$typeOf',
1175
+ orderCount: { $sum: 1 },
1176
+ sumGraceTime: { $sum: '$graceTime' }
1177
+ }
1178
+ },
1179
+ {
1180
+ $project: {
1181
+ _id: 0,
1182
+ orderCount: '$orderCount',
1183
+ sumGraceTime: '$sumGraceTime'
1184
+ }
1244
1185
  }
1186
+ ])
1187
+ .exec();
1188
+ if (aggregations.length === 0) {
1245
1189
  return {
1246
- aggregation: Object.assign({}, aggregations[0])
1190
+ aggregation: {
1191
+ orderCount: 0
1192
+ }
1247
1193
  };
1248
- });
1194
+ }
1195
+ return {
1196
+ aggregation: {
1197
+ ...aggregations[0]
1198
+ }
1199
+ };
1249
1200
  }
1250
- aggregateOrderOfCustomerGlobally(params) {
1251
- return __awaiter(this, void 0, void 0, function* () {
1252
- const matchConditions = {
1253
- orderDate: {
1254
- $gte: params.orderDate.$gte,
1255
- $lte: params.orderDate.$lte
1256
- },
1257
- typeOf: { $eq: factory.order.OrderType.Order },
1258
- 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1259
- };
1260
- const aggregations = yield this.orderModel.aggregate([
1261
- { $match: matchConditions },
1262
- {
1263
- $project: {
1264
- typeOf: '$typeOf'
1265
- }
1266
- },
1267
- {
1268
- $group: {
1269
- _id: '$typeOf',
1270
- orderCount: { $sum: 1 }
1271
- }
1272
- },
1273
- {
1274
- $project: {
1275
- _id: 0,
1276
- orderCount: '$orderCount'
1277
- }
1201
+ async aggregateOrderOfCustomerGlobally(params) {
1202
+ const matchConditions = {
1203
+ orderDate: {
1204
+ $gte: params.orderDate.$gte,
1205
+ $lte: params.orderDate.$lte
1206
+ },
1207
+ typeOf: { $eq: factory.order.OrderType.Order },
1208
+ 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1209
+ };
1210
+ const aggregations = await this.orderModel.aggregate([
1211
+ { $match: matchConditions },
1212
+ {
1213
+ $project: {
1214
+ typeOf: '$typeOf'
1278
1215
  }
1279
- ])
1280
- .exec();
1281
- if (aggregations.length === 0) {
1282
- return {
1283
- aggregation: {
1284
- orderCount: 0,
1285
- aggregateProject: { projectCount: 0 }
1286
- }
1287
- };
1288
- }
1289
- const aggregations2 = yield this.orderModel.aggregate([
1290
- { $match: matchConditions },
1291
- {
1292
- $project: {
1293
- project: '$project'
1294
- }
1295
- },
1296
- {
1297
- $group: {
1298
- _id: '$project.id'
1299
- }
1300
- },
1301
- {
1302
- $count: 'projectCount'
1303
- },
1304
- {
1305
- $project: {
1306
- aggregateProject: { projectCount: '$projectCount' }
1307
- }
1216
+ },
1217
+ {
1218
+ $group: {
1219
+ _id: '$typeOf',
1220
+ orderCount: { $sum: 1 }
1308
1221
  }
1309
- ])
1310
- .exec();
1222
+ },
1223
+ {
1224
+ $project: {
1225
+ _id: 0,
1226
+ orderCount: '$orderCount'
1227
+ }
1228
+ }
1229
+ ])
1230
+ .exec();
1231
+ if (aggregations.length === 0) {
1311
1232
  return {
1312
- aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
1233
+ aggregation: {
1234
+ orderCount: 0,
1235
+ aggregateProject: { projectCount: 0 }
1236
+ }
1313
1237
  };
1314
- });
1238
+ }
1239
+ const aggregations2 = await this.orderModel.aggregate([
1240
+ { $match: matchConditions },
1241
+ {
1242
+ $project: {
1243
+ project: '$project'
1244
+ }
1245
+ },
1246
+ {
1247
+ $group: {
1248
+ _id: '$project.id'
1249
+ }
1250
+ },
1251
+ {
1252
+ $count: 'projectCount'
1253
+ },
1254
+ {
1255
+ $project: {
1256
+ aggregateProject: { projectCount: '$projectCount' }
1257
+ }
1258
+ }
1259
+ ])
1260
+ .exec();
1261
+ return {
1262
+ aggregation: {
1263
+ ...aggregations[0],
1264
+ ...aggregations2[0]
1265
+ }
1266
+ };
1315
1267
  }
1316
1268
  }
1317
1269
  exports.OrderRepo = OrderRepo;