@chevre/domain 21.2.0-alpha.1 → 21.2.0-alpha.100

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 (306) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
  3. package/example/src/chevre/countDelayedTasks.ts +17 -0
  4. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  5. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  6. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  7. package/example/src/chevre/deleteTasksByName.ts +10 -2
  8. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  9. package/example/src/chevre/lockStockHolder.ts +48 -0
  10. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  11. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  12. package/example/src/chevre/processPay.ts +5 -1
  13. package/example/src/chevre/processReserve.ts +6 -3
  14. package/example/src/chevre/saveTasks.ts +13 -10
  15. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  16. package/example/src/chevre/searchActions.ts +33 -0
  17. package/example/src/chevre/searchEventSeats.ts +42 -0
  18. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
  19. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  20. package/example/src/chevre/task/executeTasks.ts +26 -0
  21. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  22. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  23. package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
  24. package/example/src/chevre/transaction/startExportTasks.ts +20 -0
  25. package/example/src/chevre/updateTransaction.ts +1 -1
  26. package/example/src/playOnMoment.ts +24 -0
  27. package/lib/chevre/credentials.d.ts +1 -0
  28. package/lib/chevre/credentials.js +2 -1
  29. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  30. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  31. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  32. package/lib/chevre/eventEmitter/task.js +25 -0
  33. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  34. package/lib/chevre/eventEmitter/transaction.js +25 -0
  35. package/lib/chevre/eventEmitter.d.ts +4 -0
  36. package/lib/chevre/eventEmitter.js +9 -0
  37. package/lib/chevre/index.d.ts +3 -2
  38. package/lib/chevre/index.js +5 -3
  39. package/lib/chevre/repo/account.js +0 -4
  40. package/lib/chevre/repo/accountTitle.js +0 -4
  41. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  42. package/lib/chevre/repo/accountTransaction.js +1 -58
  43. package/lib/chevre/repo/accountingReport.js +0 -4
  44. package/lib/chevre/repo/action.d.ts +29 -1
  45. package/lib/chevre/repo/action.js +98 -59
  46. package/lib/chevre/repo/additionalProperty.js +0 -4
  47. package/lib/chevre/repo/aggregation.js +0 -4
  48. package/lib/chevre/repo/assetTransaction.d.ts +25 -9
  49. package/lib/chevre/repo/assetTransaction.js +261 -89
  50. package/lib/chevre/repo/categoryCode.js +0 -4
  51. package/lib/chevre/repo/code.js +0 -4
  52. package/lib/chevre/repo/comment.d.ts +4 -1
  53. package/lib/chevre/repo/comment.js +20 -9
  54. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  55. package/lib/chevre/repo/confirmationNumber.js +3 -15
  56. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  57. package/lib/chevre/repo/creativeWork.js +0 -4
  58. package/lib/chevre/repo/customer.js +0 -4
  59. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  60. package/lib/chevre/repo/emailMessage.js +0 -4
  61. package/lib/chevre/repo/event.d.ts +5 -1
  62. package/lib/chevre/repo/event.js +0 -4
  63. package/lib/chevre/repo/member.js +0 -4
  64. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  65. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  66. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  67. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  68. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  69. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  70. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  71. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  72. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  73. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  74. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  75. package/lib/chevre/repo/mongoose/schemas/action.js +20 -1
  76. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  77. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  78. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  79. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  80. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  81. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +33 -19
  82. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  83. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  84. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  85. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  86. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  87. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  88. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  89. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  90. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  91. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  92. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  93. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  94. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  95. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  96. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  97. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  98. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  99. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  100. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  101. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  102. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  103. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  104. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  105. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  106. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  107. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  108. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  109. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  110. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  111. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  112. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  113. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  114. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  115. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  116. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  117. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  118. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +64 -5
  119. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  120. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  121. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  122. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  123. package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
  124. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  125. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  126. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  127. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  128. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  129. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  130. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  131. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  132. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  133. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  134. package/lib/chevre/repo/offer.js +0 -5
  135. package/lib/chevre/repo/offerCatalog.js +0 -4
  136. package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
  137. package/lib/chevre/repo/offerItemCondition.js +120 -0
  138. package/lib/chevre/repo/order.d.ts +55 -3
  139. package/lib/chevre/repo/order.js +56 -9
  140. package/lib/chevre/repo/orderNumber.d.ts +0 -1
  141. package/lib/chevre/repo/orderNumber.js +2 -12
  142. package/lib/chevre/repo/ownershipInfo.js +0 -4
  143. package/lib/chevre/repo/permit.js +0 -4
  144. package/lib/chevre/repo/place.d.ts +5 -1
  145. package/lib/chevre/repo/place.js +1 -10
  146. package/lib/chevre/repo/priceSpecification.js +0 -4
  147. package/lib/chevre/repo/product.js +0 -4
  148. package/lib/chevre/repo/project.js +0 -4
  149. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
  150. package/lib/chevre/repo/rateLimit/offer.js +14 -14
  151. package/lib/chevre/repo/reservation.d.ts +12 -4
  152. package/lib/chevre/repo/reservation.js +16 -48
  153. package/lib/chevre/repo/role.js +0 -4
  154. package/lib/chevre/repo/seller.js +19 -23
  155. package/lib/chevre/repo/serviceOutput.js +0 -4
  156. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
  157. package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
  158. package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -8
  159. package/lib/chevre/repo/stockHolder.js +273 -0
  160. package/lib/chevre/repo/task.d.ts +45 -2
  161. package/lib/chevre/repo/task.js +101 -12
  162. package/lib/chevre/repo/telemetry.js +0 -4
  163. package/lib/chevre/repo/transaction.d.ts +23 -3
  164. package/lib/chevre/repo/transaction.js +174 -58
  165. package/lib/chevre/repo/transactionNumber.d.ts +2 -1
  166. package/lib/chevre/repo/transactionNumber.js +14 -15
  167. package/lib/chevre/repo/trip.js +0 -4
  168. package/lib/chevre/repository.d.ts +8 -7
  169. package/lib/chevre/repository.js +12 -11
  170. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  171. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
  172. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  173. package/lib/chevre/service/aggregation/system.js +101 -89
  174. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
  175. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
  176. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  177. package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
  178. package/lib/chevre/service/assetTransaction/pay.js +18 -32
  179. package/lib/chevre/service/assetTransaction/refund.js +1 -23
  180. package/lib/chevre/service/assetTransaction/registerService.js +1 -25
  181. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
  182. package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
  183. package/lib/chevre/service/assetTransaction/reserve.d.ts +14 -5
  184. package/lib/chevre/service/assetTransaction/reserve.js +156 -74
  185. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  186. package/lib/chevre/service/assetTransaction.js +9 -5
  187. package/lib/chevre/service/event.js +3 -1
  188. package/lib/chevre/service/notification/factory.js +2 -2
  189. package/lib/chevre/service/notification.d.ts +3 -1
  190. package/lib/chevre/service/notification.js +41 -7
  191. package/lib/chevre/service/offer/event/authorize.d.ts +5 -2
  192. package/lib/chevre/service/offer/event/authorize.js +8 -2
  193. package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
  194. package/lib/chevre/service/offer/event/factory.d.ts +3 -0
  195. package/lib/chevre/service/offer/event/factory.js +16 -5
  196. package/lib/chevre/service/offer/event/voidTransaction.d.ts +4 -2
  197. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  198. package/lib/chevre/service/offer.d.ts +13 -26
  199. package/lib/chevre/service/offer.js +22 -117
  200. package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
  201. package/lib/chevre/service/order/deleteOrder.js +8 -8
  202. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
  203. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
  204. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
  205. package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
  206. package/lib/chevre/service/order/onOrderUpdated.js +22 -0
  207. package/lib/chevre/service/order/placeOrder.d.ts +1 -0
  208. package/lib/chevre/service/order/placeOrder.js +41 -24
  209. package/lib/chevre/service/order/returnOrder.d.ts +1 -0
  210. package/lib/chevre/service/order/returnOrder.js +7 -12
  211. package/lib/chevre/service/order/sendOrder.d.ts +1 -0
  212. package/lib/chevre/service/order/sendOrder.js +7 -10
  213. package/lib/chevre/service/order.d.ts +2 -1
  214. package/lib/chevre/service/order.js +3 -1
  215. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  216. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  217. package/lib/chevre/service/payment/any.d.ts +9 -5
  218. package/lib/chevre/service/payment/any.js +80 -18
  219. package/lib/chevre/service/payment/creditCard.d.ts +1 -1
  220. package/lib/chevre/service/payment/creditCard.js +21 -15
  221. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +7 -6
  222. package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
  223. package/lib/chevre/service/payment/movieTicket/validation.js +54 -31
  224. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  225. package/lib/chevre/service/payment/movieTicket.js +5 -4
  226. package/lib/chevre/service/product.js +1 -5
  227. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  228. package/lib/chevre/service/report/telemetry.js +21 -24
  229. package/lib/chevre/service/reserve/cancelReservation.d.ts +8 -6
  230. package/lib/chevre/service/reserve/cancelReservation.js +153 -145
  231. package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
  232. package/lib/chevre/service/reserve/checkInReservation.js +77 -3
  233. package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
  234. package/lib/chevre/service/reserve/confirmReservation.js +125 -58
  235. package/lib/chevre/service/reserve/factory.d.ts +1 -1
  236. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
  237. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
  238. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  239. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  240. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  241. package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
  242. package/lib/chevre/service/reserve/useReservation.js +61 -71
  243. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
  244. package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
  245. package/lib/chevre/service/reserve.d.ts +3 -2
  246. package/lib/chevre/service/reserve.js +4 -2
  247. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
  248. package/lib/chevre/service/task/cancelPendingReservation.js +8 -4
  249. package/lib/chevre/service/task/cancelReservation.js +3 -3
  250. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  251. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  252. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  253. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
  254. package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
  255. package/lib/chevre/service/task/placeOrder.js +1 -1
  256. package/lib/chevre/service/task/reserve.js +10 -7
  257. package/lib/chevre/service/task/returnOrder.js +1 -1
  258. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  259. package/lib/chevre/service/task/sendOrder.js +1 -1
  260. package/lib/chevre/service/task/useReservation.d.ts +7 -0
  261. package/lib/chevre/service/task/useReservation.js +36 -0
  262. package/lib/chevre/service/task/voidReserveTransaction.js +6 -4
  263. package/lib/chevre/service/task.d.ts +9 -0
  264. package/lib/chevre/service/task.js +43 -4
  265. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  266. package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
  267. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  268. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  269. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  270. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  271. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  272. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -2
  273. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  274. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  275. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  276. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  277. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  278. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  279. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  280. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  281. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  282. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  283. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  284. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  285. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  286. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  287. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  288. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  289. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
  290. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  291. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  292. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
  293. package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
  294. package/lib/chevre/service/transaction/returnOrder.js +225 -35
  295. package/lib/chevre/service/transaction.d.ts +8 -13
  296. package/lib/chevre/service/transaction.js +12 -145
  297. package/lib/chevre/settings.d.ts +4 -1
  298. package/lib/chevre/settings.js +16 -6
  299. package/package.json +5 -5
  300. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  301. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  302. package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -181
  303. package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
  304. package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
  305. package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
  306. package/lib/chevre/service/task/deleteOrder.js +0 -35
@@ -2,7 +2,6 @@ import * as factory from '../../factory';
2
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
3
3
  import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
4
4
  import { IMinimizedIndividualEvent, MongoRepository as EventRepo } from '../../repo/event';
5
- import { RedisRepository as ScreeningEventAvailabilityRepo } from '../../repo/itemAvailability/screeningEvent';
6
5
  import { MongoRepository as OfferRepo } from '../../repo/offer';
7
6
  import { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
8
7
  import { MongoRepository as OrderRepo } from '../../repo/order';
@@ -12,9 +11,10 @@ import { MongoRepository as ProductRepo } from '../../repo/product';
12
11
  import { MongoRepository as ProjectRepo } from '../../repo/project';
13
12
  import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
14
13
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
14
+ import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
15
15
  import { MongoRepository as TaskRepo } from '../../repo/task';
16
16
  export interface IStartOperationRepos {
17
- eventAvailability: ScreeningEventAvailabilityRepo;
17
+ stockHolder: StockHolderRepo;
18
18
  event: EventRepo;
19
19
  offer: OfferRepo;
20
20
  offerCatalog: OfferCatalogRepo;
@@ -29,7 +29,7 @@ export interface IStartOperationRepos {
29
29
  }
30
30
  export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
31
31
  export interface IAddReservationsOperationRepos {
32
- eventAvailability: ScreeningEventAvailabilityRepo;
32
+ stockHolder: StockHolderRepo;
33
33
  event: EventRepo;
34
34
  offer: OfferRepo;
35
35
  offerCatalog: OfferCatalogRepo;
@@ -44,7 +44,7 @@ export interface IAddReservationsOperationRepos {
44
44
  export type IAddReservationsOperation<T> = (repos: IAddReservationsOperationRepos) => Promise<T>;
45
45
  export type ICancelOperation<T> = (repos: {
46
46
  action: ActionRepo;
47
- eventAvailability: ScreeningEventAvailabilityRepo;
47
+ stockHolder: StockHolderRepo;
48
48
  offerRateLimit: OfferRateLimitRepo;
49
49
  reservation: ReservationRepo;
50
50
  task: TaskRepo;
@@ -62,6 +62,7 @@ interface IConfirmRepo {
62
62
  task: TaskRepo;
63
63
  }
64
64
  export type IConfirmOperation<T> = (repos: IConfirmRepo) => Promise<T>;
65
+ type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
65
66
  type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
66
67
  /**
67
68
  * 承認アクションを介した場合に検索済のイベント
@@ -94,7 +95,15 @@ type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail &
94
95
  /**
95
96
  * 取引開始
96
97
  */
97
- export declare function start(params: IStartParams): IStartOperation<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
98
+ export declare function start(params: IStartParams & {
99
+ disablePendingReservations: boolean;
100
+ useHoldStockByTransactionNumber: boolean;
101
+ stockHoldUntilDaysAfterEventEnd: number;
102
+ }): IStartOperation<{
103
+ transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
104
+ objectSubReservations: IObjectSubReservation[];
105
+ issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
106
+ }>;
98
107
  /**
99
108
  * 取引確定
100
109
  */
@@ -27,7 +27,7 @@ const validateStartRequest_1 = require("./reserve/validateStartRequest");
27
27
  */
28
28
  function start(params) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
- var _a, _b, _c, _d, _e;
30
+ var _a, _b, _c, _d;
31
31
  const now = new Date();
32
32
  // 自動発行廃止(2022-05-17~)
33
33
  const reservationNumber = params.transactionNumber;
@@ -35,7 +35,8 @@ function start(params) {
35
35
  throw new factory.errors.ArgumentNull('transactionNumber');
36
36
  }
37
37
  // eventをfix
38
- if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
38
+ const reservationForId = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id;
39
+ if (typeof reservationForId !== 'string' || reservationForId.length === 0) {
39
40
  throw new factory.errors.ArgumentNull('object.reservationFor.id');
40
41
  }
41
42
  let event;
@@ -43,7 +44,7 @@ function start(params) {
43
44
  event = params.preSearchedEvent;
44
45
  }
45
46
  else {
46
- event = yield repos.event.findMinimizedIndividualEventById({ id: params.object.reservationFor.id });
47
+ event = yield repos.event.findMinimizedIndividualEventById({ id: reservationForId });
47
48
  }
48
49
  // validationを承認アクション開始前から移行(2023-01-27~)
49
50
  (0, validateStartRequest_1.validateStartRequest)({
@@ -63,19 +64,24 @@ function start(params) {
63
64
  catch (error) {
64
65
  throw error;
65
66
  }
66
- // 指定があれば予約追加
67
- if (typeof ((_d = params.object.reservationFor) === null || _d === void 0 ? void 0 : _d.id) === 'string') {
68
- transaction = yield addReservations({
69
- id: transaction.id,
70
- object: params.object,
71
- event,
72
- preSearchedTicketOffers: params.preSearchedTicketOffers,
73
- preSearchedUnitPriceOffers: params.preSearchedUnitPriceOffers,
74
- availableAtOrFrom: { id: (_e = params.availableAtOrFrom) === null || _e === void 0 ? void 0 : _e.id },
75
- validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
76
- })(repos);
77
- }
78
- return transaction;
67
+ let objectSubReservations = [];
68
+ const addReservationsResult = yield addReservations({
69
+ id: transaction.id,
70
+ object: params.object,
71
+ event,
72
+ preSearchedTicketOffers: params.preSearchedTicketOffers,
73
+ preSearchedUnitPriceOffers: params.preSearchedUnitPriceOffers,
74
+ availableAtOrFrom: { id: (_d = params.availableAtOrFrom) === null || _d === void 0 ? void 0 : _d.id },
75
+ validateAppliesToMovieTicket: params.validateAppliesToMovieTicket,
76
+ stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
77
+ })(repos);
78
+ transaction = addReservationsResult.transaction;
79
+ objectSubReservations = addReservationsResult.objectSubReservations;
80
+ return {
81
+ transaction,
82
+ objectSubReservations,
83
+ issuedThrough: addReservationsResult.issuedThrough
84
+ };
79
85
  });
80
86
  }
81
87
  exports.start = start;
@@ -119,7 +125,7 @@ function addReservations(params) {
119
125
  ticketOffers = searchEventTicketOffersResult.ticketOffers;
120
126
  availableOffers = searchEventTicketOffersResult.unitPriceOffers;
121
127
  }
122
- const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event: { id: event.id } })(repos);
128
+ const availableSeatOffers = yield searchAvailableSeatOffers({ acceptedOffers, event })(repos);
123
129
  // 仮予約作成
124
130
  const { acceptedOffers4transactionObject, objectSubReservations } = yield createAcceptedOffers4transactionObject({
125
131
  acceptedOffers,
@@ -132,6 +138,21 @@ function addReservations(params) {
132
138
  })(repos);
133
139
  // 予約イベント最適化
134
140
  const reservationFor = (0, factory_1.createReservationFor)(event);
141
+ const { issuedThrough } = (0, factory_1.createIssuedThrough)({ reservationFor: event });
142
+ // const minimizedObjectSubReservations: factory.assetTransaction.reserve.IMinimizedObjectSubReservation[] =
143
+ // objectSubReservations.map((r) => {
144
+ // return {
145
+ // id: r.id,
146
+ // typeOf: r.typeOf,
147
+ // reservedTicket: {
148
+ // ticketType: r.reservedTicket.ticketType,
149
+ // ...(typeof r.reservedTicket.ticketedSeat?.typeOf === 'string')
150
+ // ? { ticketedSeat: r.reservedTicket.ticketedSeat }
151
+ // : undefined
152
+ // },
153
+ // ...(Array.isArray(r.subReservation)) ? { subReservation: r.subReservation } : undefined
154
+ // };
155
+ // });
135
156
  // 取引に予約追加
136
157
  let lockedOfferRateLimitKeys = [];
137
158
  try {
@@ -140,12 +161,13 @@ function addReservations(params) {
140
161
  typeOf: factory.assetTransactionType.Reserve,
141
162
  id: transaction.id,
142
163
  object: {
143
- project: transaction.project,
144
164
  acceptedOffer: acceptedOffers4transactionObject,
165
+ // issuedThroughを追加(2023-06-05~)
166
+ issuedThrough,
145
167
  reservationFor,
146
168
  // subReservationにreservationForを保管しない(2021-10-19~)
147
- subReservation: objectSubReservations,
148
- typeOf: factory.reservationType.ReservationPackage
169
+ subReservation: objectSubReservations
170
+ // subReservation: minimizedObjectSubReservations
149
171
  }
150
172
  });
151
173
  }
@@ -162,23 +184,96 @@ function addReservations(params) {
162
184
  yield processLockSeats({
163
185
  event: event,
164
186
  reservations: objectSubReservations,
165
- transaction: transaction
187
+ transaction: {
188
+ id: transaction.id,
189
+ transactionNumber: transaction.transactionNumber,
190
+ object: { useHoldStockByTransactionNumber: transaction.object.useHoldStockByTransactionNumber === true }
191
+ },
192
+ stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
166
193
  })(repos);
167
- // 予約作成(insertManyで実装)
168
- yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
169
- // 予約作成後処理
194
+ if (transaction.object.disablePendingReservations !== true) {
195
+ // 予約作成(insertManyで実装)
196
+ yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
197
+ }
198
+ // ストックホルダー処理(stockHolderで残席数を集計しているので必要)
170
199
  yield onReservationsCreated({ event })(repos);
171
- return transaction;
200
+ return { transaction, objectSubReservations, issuedThrough };
201
+ });
202
+ }
203
+ /**
204
+ * イベントに対する座席オファーを座席コードとセクションコード指定で検索する
205
+ */
206
+ function searchEventSeatOffers(params) {
207
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
208
+ var _a, _b, _c, _d, _e, _f;
209
+ let offers = [];
210
+ // 座席指定利用可能かどうか
211
+ const eventOffers = params.event.offers;
212
+ const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
213
+ if (reservedSeatsAvailable) {
214
+ // 座席タイプ価格仕様を検索
215
+ const priceSpecs = yield repos.priceSpecification.search({
216
+ project: { id: { $eq: params.event.project.id } },
217
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
218
+ appliesToCategoryCode: {
219
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
220
+ }
221
+ });
222
+ const roomBranchCode = String((_d = (_c = eventOffers.itemOffered) === null || _c === void 0 ? void 0 : _c.availableChannel) === null || _d === void 0 ? void 0 : _d.serviceLocation.branchCode);
223
+ const movieTheaterBranchCode = String((_f = (_e = eventOffers.itemOffered) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.serviceLocation.containedInPlace.branchCode);
224
+ const seats = yield repos.place.searchSeats({
225
+ project: { id: { $eq: params.event.project.id } },
226
+ branchCode: { $in: params.branchCode.$in },
227
+ containedInPlace: {
228
+ branchCode: {
229
+ $in: params.containedInPlace.branchCode.$in
230
+ },
231
+ containedInPlace: {
232
+ branchCode: { $eq: roomBranchCode },
233
+ containedInPlace: {
234
+ branchCode: { $eq: movieTheaterBranchCode }
235
+ }
236
+ }
237
+ },
238
+ $projection: params.$projection
239
+ });
240
+ if (seats.length > 0) {
241
+ const availabilities = yield repos.stockHolder.searchHolders({
242
+ eventId: params.event.id,
243
+ startDate: moment(params.event.startDate)
244
+ .toDate(),
245
+ offers: seats.map((s) => {
246
+ var _a;
247
+ return {
248
+ seatNumber: s.branchCode,
249
+ seatSection: (_a = s.containedInPlace) === null || _a === void 0 ? void 0 : _a.branchCode
250
+ };
251
+ })
252
+ });
253
+ offers = seats.map((seat, index) => {
254
+ return OfferService.addOffers2Seat({
255
+ seat,
256
+ // unavailableOffers: [],
257
+ // availability: availabilities[index].availability,
258
+ availability: (typeof availabilities[index] === 'string')
259
+ ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
260
+ : factory.itemAvailability.InStock,
261
+ priceSpecs
262
+ });
263
+ });
264
+ }
265
+ }
266
+ return offers;
172
267
  });
173
268
  }
174
269
  function searchAvailableSeatOffers(params) {
175
270
  return (repos) => __awaiter(this, void 0, void 0, function* () {
176
271
  // 座席オファー検索(必要な分だけ)
177
272
  const { acceptedSeatNumbers, acceptedSeatSections } = getAcceptedSeatNumbersAndSeatSections({ acceptedOffers: params.acceptedOffers });
178
- return OfferService.searchEventSeatOffers({
273
+ return searchEventSeatOffers({
179
274
  branchCode: { $in: acceptedSeatNumbers },
180
275
  containedInPlace: { branchCode: { $in: acceptedSeatSections } },
181
- event: { id: params.event.id },
276
+ event: params.event,
182
277
  // 試しに冗長な情報を非取得にしてみる
183
278
  $projection: {
184
279
  'containedInPlace.containedInPlace': 0
@@ -319,7 +414,7 @@ function createReservations4transactionObject(params) {
319
414
  id: reservationId,
320
415
  reserveDate: params.now,
321
416
  agent: params.transaction.agent,
322
- broker: params.transaction.object.broker,
417
+ // broker: params.transaction.object.broker,
323
418
  reservationNumber: reservationNumber,
324
419
  reservationFor: params.event,
325
420
  reservedTicket: reservedTicket,
@@ -530,7 +625,7 @@ function processLockOfferRateLimit(params) {
530
625
  */
531
626
  function processLockSeats(params) {
532
627
  return (repos) => __awaiter(this, void 0, void 0, function* () {
533
- var _a;
628
+ var _a, _b;
534
629
  const offers = [];
535
630
  params.reservations.forEach((r) => {
536
631
  var _a, _b;
@@ -570,12 +665,18 @@ function processLockSeats(params) {
570
665
  }
571
666
  });
572
667
  const expires = moment(params.event.endDate)
573
- .add(1, 'month')
668
+ // 設定化(2023-06-05~)
669
+ // .add(1, 'month')
670
+ .add(params.stockHoldUntilDaysAfterEventEnd, 'days')
574
671
  .toDate();
575
- const holder = params.transaction.id;
576
- const maximumAttendeeCapacity4event = (_a = params.event.location) === null || _a === void 0 ? void 0 : _a.maximumAttendeeCapacity;
672
+ // holder:取引番号に対応(2023-06-05~)
673
+ let holder = params.transaction.id;
674
+ if (((_a = params.transaction.object) === null || _a === void 0 ? void 0 : _a.useHoldStockByTransactionNumber) === true) {
675
+ holder = params.transaction.transactionNumber;
676
+ }
677
+ const maximumAttendeeCapacity4event = (_b = params.event.location) === null || _b === void 0 ? void 0 : _b.maximumAttendeeCapacity;
577
678
  if (typeof maximumAttendeeCapacity4event === 'number') {
578
- yield repos.eventAvailability.lockIfNotLimitExceeded({
679
+ yield repos.stockHolder.lockIfNotLimitExceeded({
579
680
  eventId: params.event.id,
580
681
  startDate: moment(params.event.startDate)
581
682
  .toDate(),
@@ -585,7 +686,7 @@ function processLockSeats(params) {
585
686
  }, maximumAttendeeCapacity4event);
586
687
  }
587
688
  else {
588
- yield repos.eventAvailability.lock({
689
+ yield repos.stockHolder.lock({
589
690
  eventId: params.event.id,
590
691
  startDate: moment(params.event.startDate)
591
692
  .toDate(),
@@ -632,20 +733,22 @@ function confirm(params) {
632
733
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
633
734
  }
634
735
  const order = yield fixOrderAsPurpose(params, transaction)(repos);
635
- const potentialActions = (0, factory_1.createPotentialActions)(Object.assign(Object.assign({}, params), { transaction: transaction, order }));
736
+ const { potentialActions, underName } = (0, factory_1.createPotentialActions)(Object.assign(Object.assign({}, params), { transaction,
737
+ order }));
636
738
  // 取引確定
637
739
  const result = {};
638
- yield repos.assetTransaction.confirm({
639
- typeOf: factory.assetTransactionType.Reserve,
640
- id: transaction.id,
641
- result: result,
642
- potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
740
+ yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Reserve, id: transaction.id, result: result, potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
643
741
  ? { reserve: [] }
644
- : potentialActions
645
- });
742
+ : potentialActions }, (typeof (underName === null || underName === void 0 ? void 0 : underName.typeOf) === 'string')
743
+ ? { object: { underName } }
744
+ : undefined));
646
745
  if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
647
746
  // sync対応(2023-01-13~)
648
- yield (0, confirmReservation_1.confirmReservation)(potentialActions.reserve)(repos);
747
+ yield (0, confirmReservation_1.confirmReservation)({
748
+ actionAttributesList: potentialActions.reserve,
749
+ useOnReservationConfirmed: true,
750
+ byTask: true
751
+ })(repos);
649
752
  }
650
753
  });
651
754
  }
@@ -666,7 +769,7 @@ function fixOrderAsPurpose(params, transaction) {
666
769
  project: { id: { $eq: transaction.project.id } },
667
770
  confirmationNumbers: [payPurposeConfirmationNumber],
668
771
  orderNumbers: [payPurposeOrderNumber]
669
- });
772
+ }, { customer: 1, orderNumber: 1, typeOf: 1 });
670
773
  order = orders.shift();
671
774
  if (order === undefined) {
672
775
  throw new factory.errors.NotFound('Order as purpose');
@@ -688,8 +791,8 @@ function cancel(params) {
688
791
  });
689
792
  // 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
690
793
  // 同期的にもcancelPendingReservationを実行しておく
691
- const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
692
- if (cancelActionAttributes.length > 0) {
794
+ const cancelActionAttributes = (0, factory_1.createCancelPendingReservationAction)({ transaction });
795
+ if (cancelActionAttributes !== undefined) {
693
796
  yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
694
797
  }
695
798
  });
@@ -707,27 +810,6 @@ function exportTasksById(params) {
707
810
  });
708
811
  const potentialActions = transaction.potentialActions;
709
812
  const taskAttributes = [];
710
- // 資産取引削除タスクを作成
711
- const deleteTransactionTask = {
712
- project: transaction.project,
713
- name: factory.taskName.DeleteAssetTransaction,
714
- status: factory.taskStatus.Ready,
715
- runsAt: moment(transaction.endDate)
716
- .add(settings_1.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS, 'days')
717
- .toDate(),
718
- remainingNumberOfTries: 3,
719
- numberOfTried: 0,
720
- executionResults: [],
721
- data: {
722
- object: {
723
- project: transaction.project,
724
- id: transaction.id,
725
- transactionNumber: transaction.transactionNumber,
726
- typeOf: transaction.typeOf
727
- }
728
- }
729
- };
730
- taskAttributes.push(deleteTransactionTask);
731
813
  switch (transaction.status) {
732
814
  case factory.transactionStatusType.Confirmed:
733
815
  // tslint:disable-next-line:no-single-line-block-comment
@@ -755,8 +837,8 @@ function exportTasksById(params) {
755
837
  case factory.transactionStatusType.Canceled:
756
838
  // sync対応(2023-01-13~)
757
839
  if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
758
- const cancelActionAttributes4canceled = (0, factory_1.createPendingReservationAction)({ transaction });
759
- if (cancelActionAttributes4canceled.length > 0) {
840
+ const cancelActionAttributes4canceled = (0, factory_1.createCancelPendingReservationAction)({ transaction });
841
+ if (cancelActionAttributes4canceled !== undefined) {
760
842
  const cancelPendingReservationTask = {
761
843
  project: transaction.project,
762
844
  name: factory.taskName.CancelPendingReservation,
@@ -766,7 +848,7 @@ function exportTasksById(params) {
766
848
  numberOfTried: 0,
767
849
  executionResults: [],
768
850
  data: {
769
- actionAttributes: cancelActionAttributes4canceled
851
+ actionAttributes: [cancelActionAttributes4canceled]
770
852
  }
771
853
  };
772
854
  taskAttributes.push(cancelPendingReservationTask);
@@ -774,8 +856,8 @@ function exportTasksById(params) {
774
856
  }
775
857
  break;
776
858
  case factory.transactionStatusType.Expired:
777
- const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
778
- if (cancelActionAttributes.length > 0) {
859
+ const cancelActionAttributes = (0, factory_1.createCancelPendingReservationAction)({ transaction });
860
+ if (cancelActionAttributes !== undefined) {
779
861
  const cancelPendingReservationTask = {
780
862
  project: transaction.project,
781
863
  name: factory.taskName.CancelPendingReservation,
@@ -785,7 +867,7 @@ function exportTasksById(params) {
785
867
  numberOfTried: 0,
786
868
  executionResults: [],
787
869
  data: {
788
- actionAttributes: cancelActionAttributes
870
+ actionAttributes: [cancelActionAttributes]
789
871
  }
790
872
  };
791
873
  taskAttributes.push(cancelPendingReservationTask);
@@ -794,7 +876,7 @@ function exportTasksById(params) {
794
876
  default:
795
877
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
796
878
  }
797
- return repos.task.saveMany(taskAttributes);
879
+ return repos.task.saveMany(taskAttributes, { emitImmediately: true });
798
880
  });
799
881
  }
800
882
  exports.exportTasksById = exportTasksById;
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import * as factory from '../factory';
5
5
  import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
6
- import { MongoRepository as ProjectRepo } from '../repo/project';
7
6
  import { MongoRepository as TaskRepo } from '../repo/task';
8
7
  import * as CancelReservationTransactionService from './assetTransaction/cancelReservation';
9
8
  import * as MoneyTransferTransactionService from './assetTransaction/moneyTransfer';
@@ -29,8 +28,13 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
29
28
  typeOf?: {
30
29
  $in: T[];
31
30
  };
31
+ id?: string;
32
+ tasksExportAction?: {
33
+ agent: {
34
+ name: string;
35
+ };
36
+ };
32
37
  }): (repos: {
33
- project: ProjectRepo;
34
38
  task: TaskRepo;
35
39
  assetTransaction: AssetTransactionRepo;
36
40
  }) => Promise<{
@@ -20,6 +20,7 @@ const PayTransactionService = require("./assetTransaction/pay");
20
20
  const RefundTransactionService = require("./assetTransaction/refund");
21
21
  const RegisterServiceTransactionService = require("./assetTransaction/registerService");
22
22
  const ReserveTransactionService = require("./assetTransaction/reserve");
23
+ const settings_1 = require("../settings");
23
24
  exports.cancelReservation = CancelReservationTransactionService;
24
25
  exports.moneyTransfer = MoneyTransferTransactionService;
25
26
  exports.pay = PayTransactionService;
@@ -31,11 +32,14 @@ exports.reserve = ReserveTransactionService;
31
32
  */
32
33
  function exportTasks(params) {
33
34
  return (repos) => __awaiter(this, void 0, void 0, function* () {
34
- const transaction = yield repos.assetTransaction.startExportTasks({
35
- // project: params.project,
36
- typeOf: params.typeOf,
37
- status: params.status
38
- });
35
+ var _a;
36
+ const transaction = yield repos.assetTransaction.startExportTasks(Object.assign({ typeOf: params.typeOf, status: params.status, tasksExportAction: {
37
+ agent: {
38
+ name: (typeof ((_a = params.tasksExportAction) === null || _a === void 0 ? void 0 : _a.agent.name) === 'string')
39
+ ? params.tasksExportAction.agent.name
40
+ : settings_1.DEFAULT_TASKS_EXPORT_AGENT_NAME
41
+ }
42
+ } }, (typeof params.id === 'string') ? { id: params.id } : undefined));
39
43
  if (transaction === null) {
40
44
  return;
41
45
  }
@@ -127,7 +127,7 @@ function importFromCOA(params) {
127
127
  })(repos);
128
128
  savedScreeningEventSeriesCount = savedEventsCount;
129
129
  try {
130
- // イベントごとに永続化トライ
130
+ // イベント永続化
131
131
  const screeningEvents = yield saveScreeningEvents({
132
132
  locationBranchCode: params.locationBranchCode,
133
133
  movieTheater: movieTheater,
@@ -154,6 +154,8 @@ function importFromCOA(params) {
154
154
  // "message": "ESOCKETTIMEDOUT",
155
155
  if (error.name === 'COAServiceError') {
156
156
  if (error.message === 'ESOCKETTIMEDOUT') {
157
+ // tslint:disable-next-line:no-console
158
+ console.error('saveScreeningEvents throwed an error', error.name, error.message);
157
159
  throwsError = false;
158
160
  }
159
161
  }
@@ -12,7 +12,7 @@ function task2lineNotify(params) {
12
12
  const lastExecutionResult = (task.executionResults.length > 0) ? task.executionResults.slice(-1)[0] : undefined;
13
13
  let lastError = lastExecutionResult === null || lastExecutionResult === void 0 ? void 0 : lastExecutionResult.error;
14
14
  if (typeof lastError === 'string') {
15
- lastError = { message: lastError };
15
+ lastError = { message: lastError, name: 'Error' };
16
16
  }
17
17
  const lastMessage = `${String(lastError === null || lastError === void 0 ? void 0 : lastError.name)} ${String(lastError === null || lastError === void 0 ? void 0 : lastError.message)}`;
18
18
  const content = `project:${(_a = task.project) === null || _a === void 0 ? void 0 : _a.id}
@@ -38,7 +38,7 @@ function tasks2lineNotify(params) {
38
38
  const lastExecutionResult = (task.executionResults.length > 0) ? task.executionResults.slice(-1)[0] : undefined;
39
39
  let lastError = lastExecutionResult === null || lastExecutionResult === void 0 ? void 0 : lastExecutionResult.error;
40
40
  if (typeof lastError === 'string') {
41
- lastError = { message: lastError };
41
+ lastError = { message: lastError, name: 'Error' };
42
42
  }
43
43
  const lastMessage = `${String(lastError === null || lastError === void 0 ? void 0 : lastError.name)} ${String(lastError === null || lastError === void 0 ? void 0 : lastError.message)}`;
44
44
  return `project:${(_a = task.project) === null || _a === void 0 ? void 0 : _a.id}
@@ -1,7 +1,9 @@
1
1
  import * as factory from '../factory';
2
2
  import { MongoRepository as ActionRepo } from '../repo/action';
3
3
  import { MongoRepository as ProjectRepo } from '../repo/project';
4
- export type Operation<T> = () => Promise<T>;
4
+ export type Operation<T> = (repos: {
5
+ accessToken: string;
6
+ }) => Promise<T>;
5
7
  /**
6
8
  * Eメールメッセージを送信する
7
9
  * https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
@@ -111,15 +111,11 @@ exports.sendEmailMessage = sendEmailMessage;
111
111
  * https://notify-bot.line.me/doc/ja/
112
112
  */
113
113
  function report2developers(subject, content, imageThumbnail, imageFullsize) {
114
- return () => __awaiter(this, void 0, void 0, function* () {
114
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
115
115
  const LINE_NOTIFY_URL = credentials_1.credentials.lineNotify.url;
116
- const LINE_NOTIFY_ACCESS_TOKEN = credentials_1.credentials.lineNotify.accessToken;
117
116
  if (LINE_NOTIFY_URL === undefined) {
118
117
  throw new Error('Environment variable LINE_NOTIFY_URL not set');
119
118
  }
120
- if (LINE_NOTIFY_ACCESS_TOKEN === undefined) {
121
- throw new Error('Environment variable LINE_NOTIFY_ACCESS_TOKEN not set');
122
- }
123
119
  const message = `--------
124
120
  ${subject}
125
121
  --------
@@ -130,7 +126,7 @@ ${content}`;
130
126
  var _a;
131
127
  request.post({
132
128
  url: LINE_NOTIFY_URL,
133
- auth: { bearer: LINE_NOTIFY_ACCESS_TOKEN },
129
+ auth: { bearer: repos.accessToken },
134
130
  form: formData,
135
131
  json: true,
136
132
  timeout: (_a = settings_1.settings.webhook) === null || _a === void 0 ? void 0 : _a.timeout
@@ -154,6 +150,45 @@ ${content}`;
154
150
  exports.report2developers = report2developers;
155
151
  const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
156
152
  function triggerWebhook(params) {
153
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
154
+ // retryableにする(2023-05-12~)
155
+ let retry = true;
156
+ let numberOfTry = 0;
157
+ while (numberOfTry >= 0) {
158
+ try {
159
+ numberOfTry += 1;
160
+ if (numberOfTry > settings_1.TRIGGER_WEBHOOK_MAX_RETRY_COUNT) {
161
+ retry = false;
162
+ }
163
+ // retryInterval
164
+ if (numberOfTry > 1) {
165
+ yield sleep(settings_1.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS * (numberOfTry - 1));
166
+ }
167
+ yield processInformAction(params)(repos);
168
+ break;
169
+ }
170
+ catch (error) {
171
+ if (retry) {
172
+ continue;
173
+ }
174
+ else {
175
+ throw error;
176
+ }
177
+ }
178
+ }
179
+ });
180
+ }
181
+ exports.triggerWebhook = triggerWebhook;
182
+ function sleep(waitTime) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ return new Promise((resolve) => {
185
+ setTimeout(() => {
186
+ resolve();
187
+ }, waitTime);
188
+ });
189
+ });
190
+ }
191
+ function processInformAction(params) {
157
192
  return (repos) => __awaiter(this, void 0, void 0, function* () {
158
193
  var _a, _b;
159
194
  // アクション開始
@@ -219,4 +254,3 @@ function triggerWebhook(params) {
219
254
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
220
255
  });
221
256
  }
222
- exports.triggerWebhook = triggerWebhook;