@chevre/domain 21.2.0-alpha.13 → 21.2.0-alpha.130

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 (296) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +85 -27
  3. package/example/src/chevre/countDelayedTasks.ts +7 -2
  4. package/example/src/chevre/deleteTasksByName.ts +10 -2
  5. package/example/src/chevre/findMovieTheaterById.ts +40 -0
  6. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  7. package/example/src/chevre/lockStockHolder.ts +5 -2
  8. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  9. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
  10. package/example/src/chevre/processPay.ts +5 -1
  11. package/example/src/chevre/processRegisterMembership.ts +8 -4
  12. package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
  13. package/example/src/chevre/processReserve.ts +5 -2
  14. package/example/src/chevre/saveTasks.ts +13 -10
  15. package/example/src/chevre/searchAbortedTasks.ts +34 -0
  16. package/example/src/chevre/searchActions.ts +33 -0
  17. package/example/src/chevre/searchEventSeats.ts +5 -2
  18. package/example/src/chevre/searchHoldReservations.ts +38 -0
  19. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
  20. package/example/src/chevre/searchScreeningRooms.ts +23 -0
  21. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  22. package/example/src/chevre/task/executeTasks.ts +26 -0
  23. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  24. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  25. package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
  26. package/example/src/chevre/transaction/startExportTasks.ts +2 -1
  27. package/example/src/chevre/updateScreeningRoom.ts +41 -0
  28. package/example/src/chevre/updateTransaction.ts +1 -1
  29. package/example/src/playOnMoment.ts +24 -0
  30. package/lib/chevre/credentials.d.ts +1 -0
  31. package/lib/chevre/credentials.js +2 -1
  32. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  33. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  34. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  35. package/lib/chevre/eventEmitter/task.js +25 -0
  36. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  37. package/lib/chevre/eventEmitter/transaction.js +25 -0
  38. package/lib/chevre/eventEmitter.d.ts +4 -0
  39. package/lib/chevre/eventEmitter.js +9 -0
  40. package/lib/chevre/index.d.ts +3 -2
  41. package/lib/chevre/index.js +5 -3
  42. package/lib/chevre/repo/account.js +3 -2
  43. package/lib/chevre/repo/accountTransaction.d.ts +3 -1
  44. package/lib/chevre/repo/accountTransaction.js +3 -2
  45. package/lib/chevre/repo/action.d.ts +42 -2
  46. package/lib/chevre/repo/action.js +130 -57
  47. package/lib/chevre/repo/additionalProperty.js +2 -1
  48. package/lib/chevre/repo/aggregation.d.ts +3 -0
  49. package/lib/chevre/repo/aggregation.js +3 -0
  50. package/lib/chevre/repo/assetTransaction.d.ts +23 -8
  51. package/lib/chevre/repo/assetTransaction.js +253 -80
  52. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  53. package/lib/chevre/repo/categoryCode.js +37 -25
  54. package/lib/chevre/repo/code.js +3 -2
  55. package/lib/chevre/repo/comment.d.ts +4 -1
  56. package/lib/chevre/repo/comment.js +22 -6
  57. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  58. package/lib/chevre/repo/confirmationNumber.js +3 -15
  59. package/lib/chevre/repo/creativeWork.d.ts +2 -4
  60. package/lib/chevre/repo/creativeWork.js +35 -12
  61. package/lib/chevre/repo/customer.js +2 -1
  62. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  63. package/lib/chevre/repo/emailMessage.js +2 -1
  64. package/lib/chevre/repo/event.d.ts +27 -1
  65. package/lib/chevre/repo/event.js +67 -33
  66. package/lib/chevre/repo/member.js +4 -3
  67. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  68. package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
  69. package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
  70. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
  71. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
  72. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  73. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
  74. package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
  75. package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
  76. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
  77. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
  78. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
  79. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
  80. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
  81. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  82. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
  83. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
  84. package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
  85. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
  86. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
  87. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
  88. package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
  89. package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +75 -0
  90. package/lib/chevre/repo/mongoose/schemas/holdReservation.js +62 -0
  91. package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
  92. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
  93. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
  94. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
  95. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  96. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  97. package/lib/chevre/repo/mongoose/schemas/order.d.ts +51 -3
  98. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  99. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
  100. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
  101. package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
  102. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
  103. package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
  104. package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
  105. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
  106. package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
  107. package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
  108. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
  109. package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
  110. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
  111. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
  112. package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
  113. package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
  114. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
  115. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
  116. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
  117. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
  118. package/lib/chevre/repo/offer.js +3 -2
  119. package/lib/chevre/repo/offerCatalog.js +0 -27
  120. package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
  121. package/lib/chevre/repo/offerItemCondition.js +121 -0
  122. package/lib/chevre/repo/order.d.ts +55 -3
  123. package/lib/chevre/repo/order.js +62 -10
  124. package/lib/chevre/repo/ownershipInfo.js +2 -7
  125. package/lib/chevre/repo/place.d.ts +20 -5
  126. package/lib/chevre/repo/place.js +63 -23
  127. package/lib/chevre/repo/priceSpecification.js +3 -2
  128. package/lib/chevre/repo/product.d.ts +1 -3
  129. package/lib/chevre/repo/product.js +25 -4
  130. package/lib/chevre/repo/project.js +2 -1
  131. package/lib/chevre/repo/reservation.d.ts +20 -4
  132. package/lib/chevre/repo/reservation.js +40 -59
  133. package/lib/chevre/repo/role.js +3 -2
  134. package/lib/chevre/repo/seller.d.ts +1 -1
  135. package/lib/chevre/repo/seller.js +44 -23
  136. package/lib/chevre/repo/serviceOutput.js +2 -1
  137. package/lib/chevre/repo/stockHolder.d.ts +137 -7
  138. package/lib/chevre/repo/stockHolder.js +527 -102
  139. package/lib/chevre/repo/task.d.ts +45 -2
  140. package/lib/chevre/repo/task.js +94 -15
  141. package/lib/chevre/repo/transaction.d.ts +21 -2
  142. package/lib/chevre/repo/transaction.js +171 -50
  143. package/lib/chevre/repo/trip.js +2 -1
  144. package/lib/chevre/repository.d.ts +5 -2
  145. package/lib/chevre/repository.js +8 -4
  146. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +6 -2
  147. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +8 -6
  148. package/lib/chevre/service/aggregation/system.d.ts +110 -23
  149. package/lib/chevre/service/aggregation/system.js +213 -91
  150. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
  151. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -24
  152. package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
  153. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  154. package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
  155. package/lib/chevre/service/assetTransaction/pay.js +20 -34
  156. package/lib/chevre/service/assetTransaction/refund.js +2 -24
  157. package/lib/chevre/service/assetTransaction/registerService.js +1 -25
  158. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
  159. package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
  160. package/lib/chevre/service/assetTransaction/reserve.d.ts +10 -1
  161. package/lib/chevre/service/assetTransaction/reserve.js +92 -69
  162. package/lib/chevre/service/assetTransaction.d.ts +6 -0
  163. package/lib/chevre/service/assetTransaction.js +9 -4
  164. package/lib/chevre/service/event.js +25 -6
  165. package/lib/chevre/service/notification/factory.js +2 -2
  166. package/lib/chevre/service/notification.d.ts +3 -1
  167. package/lib/chevre/service/notification.js +41 -7
  168. package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
  169. package/lib/chevre/service/offer/event/authorize.js +8 -2
  170. package/lib/chevre/service/offer/event/factory.d.ts +3 -0
  171. package/lib/chevre/service/offer/event/factory.js +16 -5
  172. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  173. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  174. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  175. package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
  176. package/lib/chevre/service/offer/product.js +2 -2
  177. package/lib/chevre/service/offer.d.ts +16 -8
  178. package/lib/chevre/service/offer.js +71 -8
  179. package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
  180. package/lib/chevre/service/order/deleteOrder.js +8 -8
  181. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
  182. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
  183. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
  184. package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
  185. package/lib/chevre/service/order/onOrderUpdated.js +22 -0
  186. package/lib/chevre/service/order/placeOrder.d.ts +1 -0
  187. package/lib/chevre/service/order/placeOrder.js +41 -24
  188. package/lib/chevre/service/order/returnOrder.d.ts +1 -0
  189. package/lib/chevre/service/order/returnOrder.js +7 -12
  190. package/lib/chevre/service/order/sendOrder.d.ts +1 -0
  191. package/lib/chevre/service/order/sendOrder.js +7 -10
  192. package/lib/chevre/service/order.d.ts +2 -1
  193. package/lib/chevre/service/order.js +3 -1
  194. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  195. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  196. package/lib/chevre/service/payment/any.d.ts +9 -5
  197. package/lib/chevre/service/payment/any.js +80 -18
  198. package/lib/chevre/service/payment/creditCard.d.ts +1 -1
  199. package/lib/chevre/service/payment/creditCard.js +23 -17
  200. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +8 -7
  201. package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
  202. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
  203. package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
  204. package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
  205. package/lib/chevre/service/payment/movieTicket/validation.js +55 -32
  206. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  207. package/lib/chevre/service/payment/movieTicket.js +7 -6
  208. package/lib/chevre/service/product.js +1 -5
  209. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  210. package/lib/chevre/service/report/telemetry.js +21 -24
  211. package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
  212. package/lib/chevre/service/reserve/cancelReservation.js +162 -142
  213. package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
  214. package/lib/chevre/service/reserve/checkInReservation.js +77 -3
  215. package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
  216. package/lib/chevre/service/reserve/confirmReservation.js +133 -58
  217. package/lib/chevre/service/reserve/factory.d.ts +1 -1
  218. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
  219. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
  220. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  221. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  222. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  223. package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
  224. package/lib/chevre/service/reserve/useReservation.js +61 -71
  225. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
  226. package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
  227. package/lib/chevre/service/reserve.d.ts +3 -2
  228. package/lib/chevre/service/reserve.js +4 -2
  229. package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
  230. package/lib/chevre/service/task/cancelPendingReservation.js +6 -2
  231. package/lib/chevre/service/task/cancelReservation.js +1 -1
  232. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  233. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  234. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  235. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
  236. package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
  237. package/lib/chevre/service/task/onEventChanged.d.ts +7 -0
  238. package/lib/chevre/service/task/{deleteOrder.js → onEventChanged.js} +8 -14
  239. package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
  240. package/lib/chevre/service/task/onResourceUpdated.js +352 -0
  241. package/lib/chevre/service/task/placeOrder.js +1 -1
  242. package/lib/chevre/service/task/reserve.js +10 -7
  243. package/lib/chevre/service/task/returnOrder.js +1 -1
  244. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  245. package/lib/chevre/service/task/sendOrder.js +1 -1
  246. package/lib/chevre/service/task/useReservation.d.ts +7 -0
  247. package/lib/chevre/service/task/useReservation.js +36 -0
  248. package/lib/chevre/service/task/voidReserveTransaction.js +4 -2
  249. package/lib/chevre/service/task.d.ts +9 -0
  250. package/lib/chevre/service/task.js +43 -4
  251. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  252. package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
  253. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  254. package/lib/chevre/service/transaction/moneyTransfer/factory.d.ts +1 -1
  255. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  256. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  257. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  258. package/lib/chevre/service/transaction/moneyTransfer.js +10 -13
  259. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
  260. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
  261. package/lib/chevre/service/transaction/orderProgramMembership.js +7 -3
  262. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  263. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  264. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  265. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  266. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  267. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  268. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  269. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  270. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  271. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  272. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  273. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  274. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  275. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  276. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  277. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  278. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
  279. package/lib/chevre/service/transaction/placeOrderInProgress.js +28 -15
  280. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  281. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
  282. package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
  283. package/lib/chevre/service/transaction/returnOrder.js +228 -36
  284. package/lib/chevre/service/transaction.d.ts +7 -13
  285. package/lib/chevre/service/transaction.js +12 -139
  286. package/lib/chevre/settings.d.ts +13 -1
  287. package/lib/chevre/settings.js +56 -6
  288. package/package.json +5 -5
  289. package/example/src/chevre/createManyEventsIfNotExist.ts +0 -205
  290. package/example/src/chevre/eventCatalog2eventService.ts +0 -123
  291. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  292. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  293. package/example/src/chevre/migrateStockHolderKeys.ts +0 -89
  294. package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
  295. package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
  296. package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
@@ -10,78 +10,153 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.confirmReservation = void 0;
13
- /**
14
- * 予約サービス
15
- */
13
+ const createDebug = require("debug");
16
14
  const factory = require("../../factory");
17
15
  const onReservationConfirmed_1 = require("./potentialActions/onReservationConfirmed");
16
+ const debug = createDebug('chevre-domain:service:reserve:confirmReservation');
18
17
  /**
19
18
  * 予約を確定する
20
19
  */
21
- function confirmReservation(actionAttributesList) {
20
+ function confirmReservation(params) {
21
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
22
+ if (params.actionAttributesList.length > 0) {
23
+ yield Promise.all(params.actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
24
+ yield reserveIfNotYet(actionAttributes, { byTask: params.byTask })(repos);
25
+ if (params.useOnReservationConfirmed) {
26
+ yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
27
+ }
28
+ })));
29
+ if (params.useOnReservationConfirmed) {
30
+ let confirmedReservations = [];
31
+ // 確定予約通知タスクを予約番号単位で作成する(2022-12-21~)
32
+ const reservationNumber = params.actionAttributesList[0].object.reservationNumber;
33
+ if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
34
+ // 最新のconfirmedReservationsを検索
35
+ confirmedReservations = yield repos.reservation.search({
36
+ reservationNumber: { $eq: reservationNumber },
37
+ typeOf: factory.reservationType.EventReservation
38
+ });
39
+ confirmedReservations = confirmedReservations.map((r) => {
40
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
41
+ delete r._id;
42
+ return r;
43
+ });
44
+ }
45
+ yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
46
+ }
47
+ }
48
+ });
49
+ }
50
+ exports.confirmReservation = confirmReservation;
51
+ function reserveIfNotYet(params, options) {
22
52
  // tslint:disable-next-line:max-func-body-length
23
53
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
- let confirmedReservations = [];
25
- if (actionAttributesList.length > 0) {
26
- yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
27
- const reservation = actionAttributes.object;
28
- const action = yield repos.action.start(actionAttributes);
29
- try {
30
- // ReservationPackageに対応(2022-12-22~)
31
- if (reservation.typeOf === factory.reservationType.ReservationPackage) {
32
- // 予約を確定状態に変更する
33
- yield repos.reservation.confirmByReservationNumber({
34
- reservationNumber: reservation.reservationNumber,
35
- previousReservationStatus: reservation.reservationStatus,
36
- underName: reservation.underName
37
- });
54
+ var _a;
55
+ const reservationPackage = params.object;
56
+ // 冪等性を担保(2023-05-31~)
57
+ debug('searching completed reserveAction... byTask:', options === null || options === void 0 ? void 0 : options.byTask, 'reservationNumber:', reservationPackage.reservationNumber);
58
+ const completedActions = yield repos.action.search({
59
+ limit: 1,
60
+ page: 1,
61
+ actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
62
+ typeOf: { $eq: params.typeOf },
63
+ object: {
64
+ typeOf: { $eq: params.object.typeOf }
65
+ // reservationNumber: { $eq: params.object.reservationNumber }
66
+ },
67
+ purpose: {
68
+ id: { $in: [params.purpose.id] },
69
+ typeOf: { $in: [params.purpose.typeOf] }
70
+ }
71
+ }, ['_id'], []);
72
+ debug(completedActions.length, 'completed reserveAction found. byTask:', options === null || options === void 0 ? void 0 : options.byTask, 'reservationNumber:', reservationPackage.reservationNumber);
73
+ if (completedActions.length === 0) {
74
+ const action = yield repos.action.start(params);
75
+ try {
76
+ const reserveTransactions = yield repos.assetTransaction.search({
77
+ limit: 1,
78
+ page: 1,
79
+ typeOf: factory.assetTransactionType.Reserve,
80
+ transactionNumber: { $eq: reservationPackage.reservationNumber }
81
+ });
82
+ const reserveTransaction = reserveTransactions.shift();
83
+ if (reserveTransaction === undefined) {
84
+ throw new factory.errors.NotFound(factory.assetTransactionType.Reserve);
85
+ }
86
+ let underName;
87
+ // 予約取引に保管されたunderNameを使用する(2023-05-30~)
88
+ if (typeof ((_a = reserveTransaction.object.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
89
+ underName = reserveTransaction.object.underName;
90
+ // 廃止(2023-05-31~)→予約取引から取得に変更
91
+ // } else if (typeof reservationPackage.underName?.typeOf === 'string') {
92
+ // underName = reservationPackage.underName;
93
+ }
94
+ // ReservationPackageに対応(2022-12-22~)
95
+ if (reservationPackage.typeOf === factory.reservationType.ReservationPackage) {
96
+ // Pendingの予約が存在しないバージョンに対応する(2023-05-29~)
97
+ if (reserveTransaction.object.disablePendingReservations === true) {
98
+ const reservationFor = reserveTransaction.object.reservationFor;
99
+ const subReservations = reserveTransaction.object.subReservation;
100
+ if (Array.isArray(subReservations) && typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.typeOf) === 'string') {
101
+ // confirmManyに変更(2023-06-13~)
102
+ const confirmManyIfNotExistResult = yield repos.reservation.confirmManyIfNotExist({
103
+ subReservation: subReservations,
104
+ reservationFor,
105
+ underName,
106
+ broker: reserveTransaction.object.broker,
107
+ issuedThrough: reserveTransaction.object.issuedThrough
108
+ });
109
+ debug('confirmManyIfNotExistResult:', confirmManyIfNotExistResult, 'reservationNumber:', reservationPackage.reservationNumber);
110
+ // await Promise.all(subReservations.map(async (subReservation) => {
111
+ // await repos.reservation.confirmByIdIfNotExist({
112
+ // reservation: subReservation,
113
+ // reservationFor,
114
+ // underName,
115
+ // broker: reserveTransaction.object.broker,
116
+ // issuedThrough: reserveTransaction.object.issuedThrough
117
+ // });
118
+ // }));
119
+ }
38
120
  }
39
121
  else {
40
- // 廃止(2023-01-18)
41
- throw new factory.errors.Forbidden(`${reservation.typeOf} not acceptable`);
42
122
  // 予約を確定状態に変更する
43
- // await repos.reservation.confirm<factory.reservationType.EventReservation>({
44
- // id: reservation.id,
45
- // previousReservationStatus: reservation.reservationStatus,
46
- // underName: reservation.underName
47
- // });
48
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
49
- // delete (<any>reservation)._id;
50
- // confirmedReservations.push(reservation);
51
- }
52
- }
53
- catch (error) {
54
- // actionにエラー結果を追加
55
- try {
56
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
57
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
58
- }
59
- catch (__) {
60
- // 失敗したら仕方ない
123
+ yield repos.reservation.confirmByReservationNumber({
124
+ reservationNumber: reservationPackage.reservationNumber,
125
+ previousReservationStatus: reservationPackage.reservationStatus,
126
+ underName,
127
+ broker: reserveTransaction.object.broker,
128
+ issuedThrough: reserveTransaction.object.issuedThrough
129
+ });
61
130
  }
62
- throw error;
63
131
  }
64
- // アクション完了
65
- const actionResult = {};
66
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
67
- yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
68
- })));
69
- // 確定予約通知タスクを予約番号単位で作成する(2022-12-21~)
70
- const reservationNumber = actionAttributesList[0].object.reservationNumber;
71
- if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
72
- // 最新のconfirmedReservationsを検索
73
- confirmedReservations = yield repos.reservation.search({
74
- reservationNumber: { $eq: reservationNumber },
75
- typeOf: factory.reservationType.EventReservation
76
- });
77
- confirmedReservations = confirmedReservations.map((r) => {
132
+ else {
133
+ // 廃止(2023-01-18)
134
+ throw new factory.errors.Forbidden(`${reservationPackage.typeOf} not acceptable`);
135
+ // 予約を確定状態に変更する
136
+ // await repos.reservation.confirm<factory.reservationType.EventReservation>({
137
+ // id: reservation.id,
138
+ // previousReservationStatus: reservation.reservationStatus,
139
+ // underName: reservation.underName
140
+ // });
78
141
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
79
- delete r._id;
80
- return r;
81
- });
142
+ // delete (<any>reservation)._id;
143
+ // confirmedReservations.push(reservation);
144
+ }
145
+ }
146
+ catch (error) {
147
+ // actionにエラー結果を追加
148
+ try {
149
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
150
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
151
+ }
152
+ catch (__) {
153
+ // 失敗したら仕方ない
154
+ }
155
+ throw error;
82
156
  }
83
- yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
157
+ // アクション完了
158
+ const actionResult = {};
159
+ yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
84
160
  }
85
161
  });
86
162
  }
87
- exports.confirmReservation = confirmReservation;
@@ -25,7 +25,7 @@ export interface IReservationPackage4informConfirmed {
25
25
  * 予約取消通知
26
26
  */
27
27
  export interface IReservation4informCanceled {
28
- typeOf: factory.reservationType.EventReservation;
28
+ typeOf: factory.reservationType.BusReservation | factory.reservationType.EventReservation;
29
29
  project: IProject;
30
30
  id: string;
31
31
  reservationStatus: factory.reservationStatusType.ReservationCancelled;
@@ -1,13 +1,25 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { MongoRepository as TaskRepo } from '../../../repo/task';
3
3
  type IEventReservation = factory.reservation.IReservation<factory.reservationType.EventReservation>;
4
+ type IBusReservation = factory.reservation.IReservation<factory.reservationType.BusReservation>;
5
+ export declare function onReservationCanceled(
4
6
  /**
5
- * 予約取消後のアクション
7
+ * ステータス変更された予約リスト
6
8
  */
7
- export declare function onReservationCanceledByAction(actionAttributes: factory.action.cancel.reservation.IAttributes): (repos: {
8
- task: TaskRepo;
9
- }) => Promise<void>;
10
- export declare function onReservationCanceled(canceledReservations: IEventReservation[], useInformReservation: boolean): (repos: {
9
+ canceledReservations: IEventReservation[] | IBusReservation[],
10
+ /**
11
+ * 予約通知有無
12
+ */
13
+ useInformReservation: boolean,
14
+ /**
15
+ * 集計対象イベント
16
+ */
17
+ reservationFor: {
18
+ project: {
19
+ id: string;
20
+ };
21
+ id: string;
22
+ }): (repos: {
11
23
  task: TaskRepo;
12
24
  }) => Promise<void>;
13
25
  export {};
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.onReservationCanceled = exports.onReservationCanceledByAction = void 0;
12
+ exports.onReservationCanceled = void 0;
13
13
  /**
14
14
  * 予約取消時アクション
15
15
  */
@@ -19,27 +19,19 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
22
+ function onReservationCanceled(
23
23
  /**
24
- * 予約取消後のアクション
24
+ * ステータス変更された予約リスト
25
25
  */
26
- function onReservationCanceledByAction(actionAttributes) {
27
- return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- const potentialActions = actionAttributes.potentialActions;
29
- const taskAttributes = [];
30
- // tslint:disable-next-line:no-single-line-block-comment
31
- /* istanbul ignore else */
32
- if (potentialActions !== undefined) {
33
- // no op
34
- }
35
- // タスク保管
36
- if (taskAttributes.length > 0) {
37
- yield repos.task.saveMany(taskAttributes);
38
- }
39
- });
40
- }
41
- exports.onReservationCanceledByAction = onReservationCanceledByAction;
42
- function onReservationCanceled(canceledReservations, useInformReservation) {
26
+ canceledReservations,
27
+ /**
28
+ * 予約通知有無
29
+ */
30
+ useInformReservation,
31
+ /**
32
+ * 集計対象イベント
33
+ */
34
+ reservationFor) {
43
35
  return (repos) => __awaiter(this, void 0, void 0, function* () {
44
36
  if (Array.isArray(canceledReservations) && canceledReservations.length > 0) {
45
37
  const now = new Date();
@@ -50,7 +42,7 @@ function onReservationCanceled(canceledReservations, useInformReservation) {
50
42
  if (Array.isArray(informReservations)) {
51
43
  // やや遅延させる(確定通知が未達の可能性を考慮して)
52
44
  const informTaskRunsAt = moment(now)
53
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
45
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
54
46
  .toDate();
55
47
  const reservations4inform = canceledReservations.map((r) => {
56
48
  return {
@@ -91,12 +83,22 @@ function onReservationCanceled(canceledReservations, useInformReservation) {
91
83
  }
92
84
  // タスク保管
93
85
  if (taskAttributes.length > 0) {
94
- yield repos.task.saveMany(taskAttributes);
86
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
95
87
  }
88
+ // const reservationForId = canceledReservations[0].reservationFor.id;
89
+ // if (typeof reservationForId === 'string') {
90
+ // await createAggregateScreeningEventIfNotExist({
91
+ // project,
92
+ // reservationFor: [{ id: reservationForId }],
93
+ // force: false
94
+ // })({ task: repos.task });
95
+ // }
96
+ }
97
+ if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
96
98
  // 冗長な作成を避ける
97
99
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
98
- project,
99
- reservationFor: [{ id: canceledReservations[0].reservationFor.id }],
100
+ project: { id: reservationFor.project.id },
101
+ reservationFor: [{ id: reservationFor.id }],
100
102
  force: false
101
103
  })({ task: repos.task });
102
104
  }
@@ -19,7 +19,6 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
23
22
  // tslint:disable-next-line:max-func-body-length
24
23
  function onReservationCheckedIn(params) {
25
24
  // tslint:disable-next-line:max-func-body-length
@@ -31,7 +30,7 @@ function onReservationCheckedIn(params) {
31
30
  if (Array.isArray(informReservations)) {
32
31
  // やや遅延させる(確定通知が未達の可能性を考慮して)
33
32
  const informTaskRunsAt = moment(params.now)
34
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
33
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
35
34
  .toDate();
36
35
  informReservations.forEach((informReservation) => {
37
36
  var _a;
@@ -107,7 +106,7 @@ function onReservationCheckedIn(params) {
107
106
  });
108
107
  }
109
108
  if (tasks.length > 0) {
110
- yield repos.task.saveMany(tasks);
109
+ yield repos.task.saveMany(tasks, { emitImmediately: true });
111
110
  }
112
111
  // 冗長な作成を避ける
113
112
  const reservationForIds = (_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.ids;
@@ -57,38 +57,9 @@ function onReservationConfirmedByAction(actionAttributes
57
57
  }));
58
58
  }
59
59
  }
60
- // inform galobally
61
- // if (Array.isArray(informReservations)) {
62
- // const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
63
- // taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
64
- // const informUrl: string = String(informReservation.recipient?.url);
65
- // const informReservationAttributes: InformReservationActionattributes = {
66
- // agent: confirmedReservation.project,
67
- // object: [reservation4inform],
68
- // project: confirmedReservation.project,
69
- // recipient: {
70
- // id: '',
71
- // name: informUrl,
72
- // typeOf: factory.creativeWorkType.WebApplication,
73
- // url: informUrl
74
- // },
75
- // typeOf: factory.actionType.InformAction
76
- // };
77
- // return {
78
- // project: actionAttributes.project,
79
- // name: factory.taskName.TriggerWebhook,
80
- // status: factory.taskStatus.Ready,
81
- // runsAt: now,
82
- // remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
83
- // numberOfTried: 0,
84
- // executionResults: [],
85
- // data: informReservationAttributes
86
- // };
87
- // }));
88
- // }
89
60
  // タスク保管
90
61
  if (taskAttributes.length > 0) {
91
- yield repos.task.saveMany(taskAttributes);
62
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
92
63
  }
93
64
  });
94
65
  }
@@ -142,7 +113,7 @@ function onReservationConfirmed(confirmedReservations) {
142
113
  }
143
114
  // タスク保管
144
115
  if (taskAttributes.length > 0) {
145
- yield repos.task.saveMany(taskAttributes);
116
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
146
117
  }
147
118
  }
148
119
  });
@@ -19,7 +19,6 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
23
22
  /**
24
23
  * 予約使用
25
24
  */
@@ -32,7 +31,7 @@ function onReservationUsed(action, attendedReservation) {
32
31
  if (Array.isArray(informReservations)) {
33
32
  // やや遅延させる(確定通知が未達の可能性を考慮して)
34
33
  const informTaskRunsAt = moment(now)
35
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
34
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
36
35
  .toDate();
37
36
  const reservation4inform = {
38
37
  typeOf: attendedReservation.typeOf,
@@ -97,7 +96,7 @@ function onReservationUsed(action, attendedReservation) {
97
96
  }
98
97
  }
99
98
  if (tasks.length > 0) {
100
- yield repos.task.saveMany(tasks);
99
+ yield repos.task.saveMany(tasks, { emitImmediately: true });
101
100
  }
102
101
  // 冗長な作成を避ける
103
102
  yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
@@ -1,8 +1,6 @@
1
- /**
2
- * 予約サービス
3
- */
4
1
  import * as factory from '../../factory';
5
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
3
+ import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
6
4
  import { MongoRepository as OrderRepo } from '../../repo/order';
7
5
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
8
6
  import { MongoRepository as TaskRepo } from '../../repo/task';
@@ -11,6 +9,9 @@ import { IUseReservationAction } from './potentialActions/onReservationUsed';
11
9
  * 予約使用
12
10
  */
13
11
  export declare function useReservation(params: {
12
+ project: {
13
+ id: string;
14
+ };
14
15
  agent: factory.action.consume.use.reservation.IAgent;
15
16
  object: {
16
17
  /**
@@ -24,8 +25,11 @@ export declare function useReservation(params: {
24
25
  location?: {
25
26
  identifier?: string;
26
27
  };
28
+ verifyToken: boolean;
29
+ reserveIfNotYet: boolean;
27
30
  }): (repos: {
28
31
  action: ActionRepo;
32
+ assetTransaction: AssetTransactionRepo;
29
33
  order: OrderRepo;
30
34
  reservation: ReservationRepo;
31
35
  task: TaskRepo;
@@ -10,58 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useReservation = void 0;
13
- /**
14
- * 予約サービス
15
- */
13
+ const createDebug = require("debug");
16
14
  const factory = require("../../factory");
17
- const code_1 = require("../code");
18
- // import { maskUnderName } from './factory';
15
+ const confirmReservation_1 = require("./confirmReservation");
19
16
  const onReservationUsed_1 = require("./potentialActions/onReservationUsed");
20
- function verifyToken4reservation(params) {
21
- return (repos) => __awaiter(this, void 0, void 0, function* () {
22
- const payload = yield (0, code_1.verifyToken)({
23
- project: params.project,
24
- agent: params.agent,
25
- token: params.token
26
- })({});
27
- switch (payload.typeOf) {
28
- case factory.order.OrderType.Order:
29
- // reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
30
- const order = yield repos.order.findByOrderNumberAndReservationId({
31
- orderNumber: payload.orderNumber,
32
- reservationId: params.reservationId
33
- });
34
- // 注文検索
35
- // const order: Pick<factory.order.IOrder, 'orderStatus' | 'acceptedOffers'> =
36
- // await repos.order.findByOrderNumber({
37
- // orderNumber: payload.orderNumber,
38
- // inclusion: ['orderStatus', 'acceptedOffers'],
39
- // exclusion: []
40
- // });
41
- // ステータス検証
42
- switch (order.orderStatus) {
43
- case factory.orderStatus.OrderDelivered:
44
- break;
45
- default:
46
- throw new factory.errors.Argument('token', `invalid orderStatus '${order.orderStatus}'`);
47
- }
48
- // const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
49
- // const reservationExistsInOrder = acceptedOffers.some((offer) => {
50
- // return (
51
- // offer.itemOffered.typeOf === factory.reservationType.EventReservation
52
- // || offer.itemOffered.typeOf === factory.reservationType.BusReservation
53
- // )
54
- // && offer.itemOffered.id === params.reservationId;
55
- // });
56
- // if (!reservationExistsInOrder) {
57
- // throw new factory.errors.NotFound('AcceptedOffer');
58
- // }
59
- break;
60
- default:
61
- throw new factory.errors.NotImplemented(`Payload type ${payload.typeOf} not implemented`);
62
- }
63
- });
64
- }
17
+ const verifyToken4reservation_1 = require("./verifyToken4reservation");
18
+ const debug = createDebug('chevre-domain:service:reserve:useReservation');
65
19
  /**
66
20
  * 予約使用
67
21
  */
@@ -71,22 +25,29 @@ function useReservation(params) {
71
25
  var _a, _b;
72
26
  const now = new Date();
73
27
  const reservationId = params.object.id;
28
+ const token = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.token;
29
+ if (params.verifyToken === true) {
30
+ // instrument?.tokenを検証
31
+ if (typeof token === 'string') {
32
+ yield (0, verifyToken4reservation_1.verifyToken4reservation)({
33
+ project: { id: params.project.id },
34
+ agent: params.agent,
35
+ reservationId,
36
+ token
37
+ })({ order: repos.order });
38
+ }
39
+ }
40
+ // confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
41
+ debug('reserveIfNotYet?', params.reserveIfNotYet, 'id:', params.object.id);
42
+ if (params.reserveIfNotYet === true) {
43
+ yield reserveIfNotYet({ object: params.object })(repos);
44
+ }
74
45
  // 予約検索
75
46
  // 取得属性最適化(2023-01-30~)
76
47
  const reservation = yield repos.reservation.findById({
77
48
  id: reservationId,
78
- inclusion: ['id', 'issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
49
+ inclusion: ['_id', 'issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
79
50
  });
80
- // instrument?.tokenを検証
81
- const token = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.token;
82
- if (typeof token === 'string') {
83
- yield verifyToken4reservation({
84
- project: { id: reservation.project.id },
85
- agent: params.agent,
86
- reservationId,
87
- token
88
- })({ order: repos.order });
89
- }
90
51
  // UseActionを作成する
91
52
  const reservationAsObject = {
92
53
  id: reservation.id,
@@ -99,8 +60,6 @@ function useReservation(params) {
99
60
  const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }),
100
61
  // object最適化(2023-01-30~)
101
62
  // どの予約を
102
- // mask
103
- // object: [maskUnderName(reservation)],
104
63
  object: [reservationAsObject] }, (typeof ((_b = params.location) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
105
64
  ? {
106
65
  location: {
@@ -118,14 +77,6 @@ function useReservation(params) {
118
77
  try {
119
78
  // 使用日時と同時更新(2023-01-30~)
120
79
  attendedReservation = (yield repos.reservation.attendIfNotAttended({ id: reservationId, now }));
121
- // attendedReservation = <IEventReservation>await repos.reservation.attend({ id: reservationId, now });
122
- // // 使用日時がなければ追加
123
- // if (attendedReservation.reservedTicket?.dateUsed === undefined) {
124
- // attendedReservation = await repos.reservation.updatePartiallyById({
125
- // id: attendedReservation.id,
126
- // update: { 'reservedTicket.dateUsed': now }
127
- // });
128
- // }
129
80
  }
130
81
  catch (error) {
131
82
  // actionにエラー結果を追加
@@ -145,3 +96,42 @@ function useReservation(params) {
145
96
  });
146
97
  }
147
98
  exports.useReservation = useReservation;
99
+ function reserveIfNotYet(params) {
100
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
101
+ let reserveTransactions = [];
102
+ if (typeof params.object.id === 'string' && params.object.id.length > 0) {
103
+ reserveTransactions = yield repos.assetTransaction.search({
104
+ typeOf: factory.assetTransactionType.Reserve,
105
+ object: {
106
+ reservations: { id: { $in: [params.object.id] } }
107
+ },
108
+ statuses: [factory.transactionStatusType.Confirmed]
109
+ }, ['_id', 'transactionNumber', 'object', 'project', 'typeOf']);
110
+ debug(reserveTransactions.length, 'reserveTransactions found in reserveIfNotYet. id:', params.object.id);
111
+ }
112
+ yield Promise.all(reserveTransactions.map((reserveTransaction) => __awaiter(this, void 0, void 0, function* () {
113
+ var _a;
114
+ if (typeof ((_a = reserveTransaction.object.reservationFor) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
115
+ yield (0, confirmReservation_1.confirmReservation)({
116
+ actionAttributesList: [{
117
+ project: reserveTransaction.project,
118
+ typeOf: factory.actionType.ReserveAction,
119
+ object: {
120
+ typeOf: reserveTransaction.object.typeOf,
121
+ reservationNumber: reserveTransaction.object.reservationNumber,
122
+ reservationStatus: (typeof reserveTransaction.object.reservationStatus === 'string')
123
+ ? reserveTransaction.object.reservationStatus
124
+ : factory.reservationStatusType.ReservationPending,
125
+ reservationFor: reserveTransaction.object.reservationFor
126
+ },
127
+ agent: reserveTransaction.project,
128
+ purpose: { typeOf: reserveTransaction.typeOf, id: reserveTransaction.id }
129
+ }],
130
+ useOnReservationConfirmed: false,
131
+ byTask: false
132
+ })(repos);
133
+ debug('confirmReservation processed in reserveIfNotYet. reservationNumber:', reserveTransaction.object.reservationNumber);
134
+ }
135
+ })));
136
+ });
137
+ }