@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
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StockHolderRepository = void 0;
13
+ const createDebug = require("debug");
14
+ const moment = require("moment");
15
+ const factory = require("../factory");
16
+ const settings_1 = require("../settings");
17
+ const debug = createDebug('chevre-domain:repo');
18
+ /**
19
+ * イベントストックホルダーリポジトリ
20
+ */
21
+ class StockHolderRepository {
22
+ constructor(redisClient) {
23
+ this.redisClient = redisClient;
24
+ }
25
+ // public static GET_KEY(params: {
26
+ // eventId: string;
27
+ // startDate: Date;
28
+ // }) {
29
+ // return StockHolderRepository.createKey(params);
30
+ // }
31
+ static offer2field(params) {
32
+ var _a, _b;
33
+ // 予約IDをfieldにする場合
34
+ const serviceOutputId = (_b = (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id;
35
+ if (typeof serviceOutputId === 'string') {
36
+ return serviceOutputId;
37
+ }
38
+ return `${params.seatSection}:${params.seatNumber}`;
39
+ }
40
+ static createKey(params) {
41
+ if (!(params.startDate instanceof Date)) {
42
+ throw new factory.errors.Argument('startDate', 'must be Date');
43
+ }
44
+ const useNewKey = moment(params.startDate)
45
+ .isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
46
+ if (useNewKey) {
47
+ return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
48
+ }
49
+ else {
50
+ return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
51
+ }
52
+ }
53
+ /**
54
+ * 座席をロックする(maxキャパシティチェック有)
55
+ */
56
+ lockIfNotLimitExceeded(lockKey, maximum) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
59
+ yield this.redisClient.watch(key);
60
+ const hashCount = yield this.redisClient.hLen(key);
61
+ // Process result
62
+ // Heavy and time consuming operation here
63
+ debug('checking hash count...hashCount:', hashCount);
64
+ if (hashCount + lockKey.offers.length > maximum) {
65
+ throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
66
+ }
67
+ yield this.lock(lockKey);
68
+ });
69
+ }
70
+ /**
71
+ * 座席をロックする
72
+ */
73
+ lock(lockKey) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ if (!(lockKey.expires instanceof Date)) {
76
+ throw new factory.errors.Argument('expires', 'must be Date');
77
+ }
78
+ const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
79
+ yield this.checkIfConflicted({ key, eventId: lockKey.eventId });
80
+ const value = lockKey.holder;
81
+ const multi = this.redisClient.multi();
82
+ const fields = lockKey.offers.map((offer) => StockHolderRepository.offer2field(offer));
83
+ fields.forEach((field) => {
84
+ multi.hSetNX(key, field, value);
85
+ });
86
+ const results = yield multi.expireAt(key, moment(lockKey.expires)
87
+ .unix())
88
+ .exec();
89
+ const lockedFields = [];
90
+ if (Array.isArray(results)) {
91
+ results.slice(0, fields.length)
92
+ .forEach((r, index) => {
93
+ if (r === 1 || r === true) {
94
+ lockedFields.push(fields[index]);
95
+ }
96
+ });
97
+ }
98
+ const lockedAll = lockedFields.length === fields.length;
99
+ debug('lockedAll?', lockedAll);
100
+ // expireAtReplyの検証も追加する(2023-04-19~)
101
+ const expiredAll = results.slice(fields.length)
102
+ .every((r) => (r === 1 || r === true));
103
+ debug('expiredAll?', expiredAll);
104
+ if (!lockedAll || !expiredAll) {
105
+ if (lockedFields.length > 0) {
106
+ // 全て仮押さえできなければ仮押さえできたものは解除
107
+ yield this.redisClient.multi()
108
+ .hDel(key, lockedFields)
109
+ .exec();
110
+ }
111
+ if (!lockedAll) {
112
+ throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
113
+ }
114
+ else {
115
+ throw new factory.errors.ServiceUnavailable('timeout cannot be set unexpectedly');
116
+ }
117
+ }
118
+ });
119
+ }
120
+ /**
121
+ * 座席ロックを解除する
122
+ */
123
+ unlock(params) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
126
+ yield this.checkIfConflicted({ key, eventId: params.eventId });
127
+ const field = StockHolderRepository.offer2field(params.offer);
128
+ yield this.redisClient.multi()
129
+ .hDel(key, field)
130
+ .exec();
131
+ });
132
+ }
133
+ /**
134
+ * 空席でない座席を検索する
135
+ */
136
+ findUnavailableOffersByEventId(params) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
139
+ const reply = yield this.redisClient.hGetAll(key);
140
+ let offers = [];
141
+ if (reply !== null) {
142
+ offers = Object.keys(reply)
143
+ .map((field) => {
144
+ const seatSection = field.split(':')[0];
145
+ const seatNumber = field.split(':')[1];
146
+ return { seatSection, seatNumber };
147
+ });
148
+ }
149
+ return offers;
150
+ });
151
+ }
152
+ /**
153
+ * 空席でない座席をカウントする
154
+ */
155
+ countUnavailableOffers(params) {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ const key = StockHolderRepository.createKey({ eventId: params.event.id, startDate: params.event.startDate });
158
+ const reply = yield this.redisClient.hLen(key);
159
+ let fieldCount = 0;
160
+ if (typeof reply === 'number') {
161
+ fieldCount = Number(reply);
162
+ }
163
+ return fieldCount;
164
+ });
165
+ }
166
+ /**
167
+ * 保持者を取得する
168
+ */
169
+ getHolder(params) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
172
+ const field = StockHolderRepository.offer2field(params.offer);
173
+ return this.redisClient.hGet(key, field);
174
+ });
175
+ }
176
+ /**
177
+ * 在庫状況を検索する
178
+ * offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
179
+ */
180
+ // public async searchAvailability(params: {
181
+ // eventId: string;
182
+ // startDate: Date;
183
+ // offers: IOffer[];
184
+ // }): Promise<{
185
+ // seatSection: string;
186
+ // seatNumber: string;
187
+ // availability: factory.itemAvailability;
188
+ // }[]> {
189
+ // const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
190
+ // const fields = params.offers.map((o) => {
191
+ // return RedisRepository.offer2field(o);
192
+ // });
193
+ // // Array reply: list of values associated with the given fields, in the same order as they are requested.
194
+ // const result = await this.redisClient.hmGet(key, fields);
195
+ // if (!Array.isArray(result)) {
196
+ // throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
197
+ // }
198
+ // return params.offers.map((o, index) => {
199
+ // const value4offer = result[index];
200
+ // return {
201
+ // ...o,
202
+ // availability: (typeof value4offer === 'string')
203
+ // ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
204
+ // : factory.itemAvailability.InStock
205
+ // };
206
+ // });
207
+ // }
208
+ searchHolders(params) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
211
+ const fields = params.offers.map((o) => {
212
+ return StockHolderRepository.offer2field(o);
213
+ });
214
+ // Array reply: list of values associated with the given fields, in the same order as they are requested.
215
+ const result = yield this.redisClient.hmGet(key, fields);
216
+ if (!Array.isArray(result)) {
217
+ throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
218
+ }
219
+ // そのまま返却(2023-04-17~)
220
+ return result;
221
+ });
222
+ }
223
+ // public async migrateKey(params: {
224
+ // key: string;
225
+ // eventId: string;
226
+ // }): Promise<void> {
227
+ // // 旧キーと新キーの両方存在検証(念のため)
228
+ // const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
229
+ // const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
230
+ // if (params.key !== oldKey) {
231
+ // // newの場合oldが存在するはずがない
232
+ // const existingOldKeyCount = await this.redisClient.exists(oldKey);
233
+ // debug('existingOldKeyCount:', existingOldKeyCount);
234
+ // if (existingOldKeyCount > 0) {
235
+ // await this.redisClient.del(oldKey);
236
+ // }
237
+ // }
238
+ // if (params.key !== newKey) {
239
+ // // oldの場合newが存在するはずがない
240
+ // const existingNewKeyCount = await this.redisClient.exists(newKey);
241
+ // debug('existingNewKeyCount:', existingNewKeyCount);
242
+ // if (existingNewKeyCount > 0) {
243
+ // await this.redisClient.del(newKey);
244
+ // }
245
+ // }
246
+ // }
247
+ checkIfConflicted(params) {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ // 旧キーと新キーの両方存在検証(念のため)
250
+ const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
251
+ const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
252
+ if (params.key !== oldKey) {
253
+ // newの場合oldが存在するはずがない
254
+ const existingOldKeyCount = yield this.redisClient.exists(oldKey);
255
+ debug('existingOldKeyCount:', existingOldKeyCount);
256
+ if (existingOldKeyCount > 0) {
257
+ throw new factory.errors.ServiceUnavailable('stockHolder keys conflicted');
258
+ }
259
+ }
260
+ if (params.key !== newKey) {
261
+ // oldの場合newが存在するはずがない
262
+ const existingNewKeyCount = yield this.redisClient.exists(newKey);
263
+ debug('existingNewKeyCount:', existingNewKeyCount);
264
+ if (existingNewKeyCount > 0) {
265
+ throw new factory.errors.ServiceUnavailable('stockHolder keys conflicted');
266
+ }
267
+ }
268
+ });
269
+ }
270
+ }
271
+ StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
272
+ StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
273
+ exports.StockHolderRepository = StockHolderRepository;
@@ -17,6 +17,9 @@ interface IStatus {
17
17
  export interface IAggregateTask {
18
18
  statuses: IStatus[];
19
19
  }
20
+ interface IOptionOnCreate {
21
+ emitImmediately: boolean;
22
+ }
20
23
  /**
21
24
  * タスクリポジトリ
22
25
  */
@@ -24,13 +27,43 @@ export declare class MongoRepository {
24
27
  readonly taskModel: typeof Model;
25
28
  constructor(connection: Connection);
26
29
  static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
27
- saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<{
30
+ saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options: IOptionOnCreate): Promise<{
28
31
  id: string;
29
32
  }[]>;
30
- createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>): Promise<void>;
33
+ createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
34
+ executeById(params: {
35
+ id: string;
36
+ executor: {
37
+ name: string;
38
+ };
39
+ }): Promise<factory.task.ITask<factory.taskName> | null>;
31
40
  executeOneByName<T extends factory.taskName>(params: {
32
41
  name: T;
42
+ executor: {
43
+ name: string;
44
+ };
33
45
  }): Promise<factory.task.ITask<T> | null>;
46
+ /**
47
+ * 一定期間遅延したタスクを実行する
48
+ */
49
+ executeTasks(params: {
50
+ now: Date;
51
+ /**
52
+ * 指定期間遅延しているタスクを実行する
53
+ */
54
+ delayInSeconds: number;
55
+ limit: number;
56
+ name: {
57
+ /**
58
+ * 指定タスクのみ実行する
59
+ */
60
+ $in?: factory.taskName[];
61
+ /**
62
+ * 指定タスク以外のみ実行する
63
+ */
64
+ $nin?: factory.taskName[];
65
+ };
66
+ }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
34
67
  retry(params: {
35
68
  intervalInMinutes: number;
36
69
  }): Promise<void>;
@@ -60,7 +93,17 @@ export declare class MongoRepository {
60
93
  }): Promise<void>;
61
94
  deleteByName(params: {
62
95
  name: factory.taskName;
96
+ status?: {
97
+ $eq?: factory.taskStatus;
98
+ };
99
+ runsAt?: {
100
+ $gte: Date;
101
+ $lte: Date;
102
+ };
63
103
  }): Promise<import("mongodb").DeleteResult>;
104
+ countDelayedTasks(params: {
105
+ delayInSeconds: number;
106
+ }): Promise<number>;
64
107
  aggregateTask(params: {
65
108
  project?: {
66
109
  id?: {
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
16
15
  const task_1 = require("./mongoose/schemas/task");
16
+ const task_2 = require("../eventEmitter/task");
17
17
  /**
18
18
  * タスク実行時のソート条件
19
19
  */
@@ -27,9 +27,6 @@ const sortOrder4executionOfTasks = {
27
27
  class MongoRepository {
28
28
  constructor(connection) {
29
29
  this.taskModel = connection.model(task_1.modelName, task_1.schema);
30
- if (connection.get('autoIndex') === true) {
31
- this.taskModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
32
- }
33
30
  }
34
31
  // tslint:disable-next-line:max-func-body-length
35
32
  static CREATE_MONGO_CONDITIONS(params) {
@@ -153,27 +150,43 @@ class MongoRepository {
153
150
  }
154
151
  return andConditions;
155
152
  }
156
- saveMany(taskAttributes) {
153
+ saveMany(taskAttributes, options) {
157
154
  return __awaiter(this, void 0, void 0, function* () {
155
+ const emitImmediately = (options === null || options === void 0 ? void 0 : options.emitImmediately) === true;
158
156
  if (taskAttributes.length > 0) {
159
157
  const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
160
158
  if (result.insertedCount !== taskAttributes.length) {
161
159
  throw new factory.errors.ServiceUnavailable('all tasks not saved');
162
160
  }
163
- // return result.ops;
164
- return Object.values(result.insertedIds)
161
+ const savedTasks = Object.values(result.insertedIds)
165
162
  .map((objectId) => {
166
163
  return { id: objectId.toHexString() };
167
164
  });
165
+ if (emitImmediately) {
166
+ savedTasks.forEach((savedTask) => {
167
+ task_2.taskEventEmitter.emitTaskStatusChanged({
168
+ id: savedTask.id,
169
+ status: factory.taskStatus.Ready
170
+ });
171
+ });
172
+ // taskAttributes.forEach((savedTask) => {
173
+ // taskEventEmitter.emitTaskStatusChanged({
174
+ // name: savedTask.name,
175
+ // status: factory.taskStatus.Ready
176
+ // });
177
+ // });
178
+ }
179
+ // return result.ops;
180
+ return savedTasks;
168
181
  }
169
182
  else {
170
183
  return [];
171
184
  }
172
185
  });
173
186
  }
174
- createInformTaskIfNotExist(params) {
187
+ createInformTaskIfNotExist(params, options) {
175
188
  return __awaiter(this, void 0, void 0, function* () {
176
- yield this.taskModel.findOneAndUpdate({
189
+ const createdTask = yield this.taskModel.findOneAndUpdate({
177
190
  'project.id': { $eq: params.project.id },
178
191
  name: params.name,
179
192
  'data.object.id': {
@@ -181,7 +194,38 @@ class MongoRepository {
181
194
  $eq: String(params.data.object.id)
182
195
  }
183
196
  }, { $setOnInsert: params }, { new: true, upsert: true })
197
+ .select({ _id: 1 })
184
198
  .exec();
199
+ if (options.emitImmediately) {
200
+ task_2.taskEventEmitter.emitTaskStatusChanged({
201
+ id: createdTask.id,
202
+ name: params.name,
203
+ status: factory.taskStatus.Ready
204
+ });
205
+ }
206
+ });
207
+ }
208
+ executeById(params) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const doc = yield this.taskModel.findOneAndUpdate({
211
+ status: factory.taskStatus.Ready,
212
+ runsAt: { $lt: new Date() },
213
+ _id: { $eq: params.id }
214
+ }, {
215
+ status: factory.taskStatus.Running,
216
+ lastTriedAt: new Date(),
217
+ $inc: {
218
+ remainingNumberOfTries: -1,
219
+ numberOfTried: 1 // トライ回数増やす
220
+ },
221
+ executor: params.executor
222
+ }, { new: true })
223
+ .exec();
224
+ if (doc === null) {
225
+ // tslint:disable-next-line:no-null-keyword
226
+ return null;
227
+ }
228
+ return doc.toObject();
185
229
  });
186
230
  }
187
231
  executeOneByName(params) {
@@ -196,7 +240,8 @@ class MongoRepository {
196
240
  $inc: {
197
241
  remainingNumberOfTries: -1,
198
242
  numberOfTried: 1 // トライ回数増やす
199
- }
243
+ },
244
+ executor: params.executor
200
245
  }, { new: true })
201
246
  .sort(sortOrder4executionOfTasks)
202
247
  .exec();
@@ -207,6 +252,35 @@ class MongoRepository {
207
252
  return doc.toObject();
208
253
  });
209
254
  }
255
+ /**
256
+ * 一定期間遅延したタスクを実行する
257
+ */
258
+ executeTasks(params) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ const runsAtLt = moment(params.now)
261
+ .add(-params.delayInSeconds, 'seconds')
262
+ .toDate();
263
+ const delayedTasks = yield this.taskModel.find(Object.assign(Object.assign({ status: { $eq: factory.taskStatus.Ready }, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$in)) ? { name: { $in: params.name.$in } } : undefined), (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
264
+ .select({
265
+ _id: 1,
266
+ name: 1,
267
+ status: 1
268
+ })
269
+ .limit(params.limit)
270
+ .setOptions({ maxTimeMS: 10000 })
271
+ .exec();
272
+ if (delayedTasks.length > 0) {
273
+ delayedTasks.forEach((delayedTask) => {
274
+ task_2.taskEventEmitter.emitTaskStatusChanged({
275
+ id: delayedTask.id,
276
+ name: delayedTask.name,
277
+ status: delayedTask.status
278
+ });
279
+ });
280
+ }
281
+ return delayedTasks;
282
+ });
283
+ }
210
284
  retry(params) {
211
285
  return __awaiter(this, void 0, void 0, function* () {
212
286
  const lastTriedAtShoudBeLessThan = moment()
@@ -337,9 +411,24 @@ class MongoRepository {
337
411
  });
338
412
  }
339
413
  deleteByName(params) {
414
+ var _a, _b;
340
415
  return __awaiter(this, void 0, void 0, function* () {
341
- return this.taskModel.deleteMany({
342
- name: { $eq: params.name }
416
+ return this.taskModel.deleteMany(Object.assign(Object.assign({ name: { $eq: params.name } }, (typeof ((_a = params.status) === null || _a === void 0 ? void 0 : _a.$eq) === 'string') ? { status: { $eq: params.status.$eq } } : undefined), (((_b = params.runsAt) === null || _b === void 0 ? void 0 : _b.$gte) instanceof Date)
417
+ ? {
418
+ runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
419
+ }
420
+ : undefined))
421
+ .exec();
422
+ });
423
+ }
424
+ countDelayedTasks(params) {
425
+ return __awaiter(this, void 0, void 0, function* () {
426
+ const runsAtLt = moment()
427
+ .add(-params.delayInSeconds, 'seconds')
428
+ .toDate();
429
+ return this.taskModel.count({
430
+ status: factory.taskStatus.Ready,
431
+ runsAt: { $lt: runsAtLt }
343
432
  })
344
433
  .exec();
345
434
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MongoRepository = void 0;
4
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
5
4
  const telemetry_1 = require("./mongoose/schemas/telemetry");
6
5
  /**
7
6
  * 測定リポジトリ
@@ -9,9 +8,6 @@ const telemetry_1 = require("./mongoose/schemas/telemetry");
9
8
  class MongoRepository {
10
9
  constructor(connection) {
11
10
  this.telemetryModel = connection.model(telemetry_1.modelName, telemetry_1.schema);
12
- if (connection.get('autoIndex') === true) {
13
- this.telemetryModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
14
- }
15
11
  }
16
12
  }
17
13
  exports.MongoRepository = MongoRepository;
@@ -40,6 +40,8 @@ export declare class MongoRepository {
40
40
  findById<T extends factory.transactionType>(params: {
41
41
  typeOf: T;
42
42
  id: string;
43
+ inclusion?: string[];
44
+ exclusion?: string[];
43
45
  }): Promise<factory.transaction.ITransaction<T>>;
44
46
  /**
45
47
  * 進行中の取引を取得する
@@ -111,7 +113,13 @@ export declare class MongoRepository {
111
113
  $in: T[];
112
114
  };
113
115
  status: factory.transactionStatusType;
114
- }): Promise<factory.transaction.ITransaction<T> | null>;
116
+ id?: string;
117
+ tasksExportAction: {
118
+ agent: {
119
+ name: string;
120
+ };
121
+ };
122
+ }): Promise<Pick<factory.transaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
115
123
  /**
116
124
  * タスクエクスポートリトライ
117
125
  * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
@@ -119,6 +127,16 @@ export declare class MongoRepository {
119
127
  reexportTasks(params: {
120
128
  intervalInMinutes: number;
121
129
  }): Promise<void>;
130
+ /**
131
+ * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
132
+ */
133
+ exportTasks(params: {
134
+ now: Date;
135
+ delayInSeconds: number;
136
+ status: {
137
+ $in: factory.transactionStatusType[];
138
+ };
139
+ }): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
122
140
  /**
123
141
  * set task status exported by transaction id
124
142
  * IDでタスクをエクスポート済に変更する
@@ -130,7 +148,9 @@ export declare class MongoRepository {
130
148
  * 取引を期限切れにする
131
149
  */
132
150
  makeExpired(params: {
133
- expires: Date;
151
+ expires: {
152
+ $lt: Date;
153
+ };
134
154
  }): Promise<void>;
135
155
  /**
136
156
  * 取引を中止する
@@ -150,7 +170,7 @@ export declare class MongoRepository {
150
170
  /**
151
171
  * 特定の取引を更新する(汎用)
152
172
  */
153
- findByIdAndUpdate(params: {
173
+ findByIdAndUpdateInProgress(params: {
154
174
  id: string;
155
175
  update: {
156
176
  $set?: any;