@chevre/domain 26.0.0-alpha.9 → 26.1.0-alpha.0

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 (328) hide show
  1. package/lib/chevre/eventEmitter/task.d.ts +8 -23
  2. package/lib/chevre/eventEmitter/task.js +2 -2
  3. package/lib/chevre/repo/acceptedOffer.d.ts +0 -7
  4. package/lib/chevre/repo/acceptedOffer.js +27 -27
  5. package/lib/chevre/repo/action/acceptCOAOffer.d.ts +11 -1
  6. package/lib/chevre/repo/action/acceptCOAOffer.js +25 -2
  7. package/lib/chevre/repo/action/acceptPay.d.ts +11 -1
  8. package/lib/chevre/repo/action/acceptPay.js +27 -6
  9. package/lib/chevre/repo/action/anyAction/actionProcess.d.ts +111 -0
  10. package/lib/chevre/repo/action/anyAction/actionProcess.js +290 -0
  11. package/lib/chevre/repo/action/anyAction/actionRecipe.d.ts +37 -0
  12. package/lib/chevre/repo/action/anyAction/actionRecipe.js +53 -0
  13. package/lib/chevre/repo/action/authorizeInvoice.d.ts +5 -8
  14. package/lib/chevre/repo/action/authorizeInvoice.js +8 -5
  15. package/lib/chevre/repo/action/authorizeOffer.d.ts +3 -1
  16. package/lib/chevre/repo/action/authorizeOffer.js +8 -7
  17. package/lib/chevre/repo/action/authorizePaymentMethod.d.ts +11 -1
  18. package/lib/chevre/repo/action/authorizePaymentMethod.js +25 -5
  19. package/lib/chevre/repo/action/authorizeTicketedObject.d.ts +3 -1
  20. package/lib/chevre/repo/action/authorizeTicketedObject.js +7 -2
  21. package/lib/chevre/repo/action/cancel.d.ts +25 -0
  22. package/lib/chevre/repo/action/cancel.js +47 -0
  23. package/lib/chevre/repo/action/checkMovieTicket.d.ts +11 -1
  24. package/lib/chevre/repo/action/checkMovieTicket.js +25 -1
  25. package/lib/chevre/repo/action/confirm.d.ts +11 -0
  26. package/lib/chevre/repo/action/confirm.js +16 -0
  27. package/lib/chevre/repo/action/create.d.ts +10 -0
  28. package/lib/chevre/repo/action/create.js +17 -0
  29. package/lib/chevre/repo/action/dedicatedAction/dedicatedActionProcess.d.ts +46 -0
  30. package/lib/chevre/repo/action/dedicatedAction/dedicatedActionProcess.js +92 -0
  31. package/lib/chevre/repo/action/inform.d.ts +39 -0
  32. package/lib/chevre/repo/action/inform.js +115 -0
  33. package/lib/chevre/repo/action/order.d.ts +21 -0
  34. package/lib/chevre/repo/action/order.js +35 -0
  35. package/lib/chevre/repo/action/pay.d.ts +3 -1
  36. package/lib/chevre/repo/action/pay.js +8 -5
  37. package/lib/chevre/repo/action/refund.d.ts +3 -1
  38. package/lib/chevre/repo/action/refund.js +7 -4
  39. package/lib/chevre/repo/action/reserve.d.ts +21 -0
  40. package/lib/chevre/repo/action/reserve.js +37 -0
  41. package/lib/chevre/repo/action/returnAction.d.ts +11 -0
  42. package/lib/chevre/repo/action/returnAction.js +16 -0
  43. package/lib/chevre/repo/action/sendEmailMessage.d.ts +10 -0
  44. package/lib/chevre/repo/action/sendEmailMessage.js +17 -0
  45. package/lib/chevre/repo/action/sendOrder.d.ts +10 -0
  46. package/lib/chevre/repo/action/sendOrder.js +16 -0
  47. package/lib/chevre/repo/action/unknown2actionError.d.ts +6 -0
  48. package/lib/chevre/repo/action/unknown2actionError.js +15 -0
  49. package/lib/chevre/repo/action/update.d.ts +50 -0
  50. package/lib/chevre/repo/action/update.js +129 -0
  51. package/lib/chevre/repo/action/use.d.ts +40 -0
  52. package/lib/chevre/repo/action/use.js +122 -0
  53. package/lib/chevre/repo/{action.d.ts → adminAction.d.ts} +11 -37
  54. package/lib/chevre/repo/adminAction.js +202 -0
  55. package/lib/chevre/repo/adminAssetTransaction.d.ts +126 -0
  56. package/lib/chevre/repo/adminAssetTransaction.js +491 -0
  57. package/lib/chevre/repo/adminScheduledTask.d.ts +1 -1
  58. package/lib/chevre/repo/adminTask.d.ts +25 -8
  59. package/lib/chevre/repo/adminTask.js +31 -32
  60. package/lib/chevre/repo/adminTransaction.d.ts +131 -0
  61. package/lib/chevre/repo/adminTransaction.js +237 -0
  62. package/lib/chevre/repo/aggregateAction.d.ts +8 -11
  63. package/lib/chevre/repo/aggregateAction.js +0 -61
  64. package/lib/chevre/repo/aggregateAssetTransaction.d.ts +43 -0
  65. package/lib/chevre/repo/aggregateAssetTransaction.js +166 -0
  66. package/lib/chevre/repo/aggregateTransaction.d.ts +39 -0
  67. package/lib/chevre/repo/aggregateTransaction.js +166 -0
  68. package/lib/chevre/repo/aggregateUseAction.d.ts +35 -0
  69. package/lib/chevre/repo/aggregateUseAction.js +164 -0
  70. package/lib/chevre/repo/aggregation.d.ts +0 -8
  71. package/lib/chevre/repo/aggregation.js +0 -10
  72. package/lib/chevre/repo/assetTransaction.d.ts +10 -235
  73. package/lib/chevre/repo/assetTransaction.js +48 -636
  74. package/lib/chevre/repo/authorization.d.ts +0 -6
  75. package/lib/chevre/repo/authorization.js +15 -27
  76. package/lib/chevre/repo/factory/action/createMongoConditions.d.ts +4 -0
  77. package/lib/chevre/repo/factory/action/createMongoConditions.js +335 -0
  78. package/lib/chevre/repo/message.d.ts +0 -7
  79. package/lib/chevre/repo/message.js +0 -38
  80. package/lib/chevre/repo/migrateAction.d.ts +48 -0
  81. package/lib/chevre/repo/migrateAction.js +32 -0
  82. package/lib/chevre/repo/mongoose/schemas/action/abstractAction.d.ts +5 -0
  83. package/lib/chevre/repo/mongoose/schemas/action/abstractAction.js +2 -0
  84. package/lib/chevre/repo/mongoose/schemas/action/inform.d.ts +11 -0
  85. package/lib/chevre/repo/mongoose/schemas/action/inform.js +82 -0
  86. package/lib/chevre/repo/mongoose/schemas/action/update.d.ts +12 -0
  87. package/lib/chevre/repo/mongoose/schemas/action/update.js +112 -0
  88. package/lib/chevre/repo/mongoose/schemas/{ownershipInfo.d.ts → action/use.d.ts} +4 -6
  89. package/lib/chevre/repo/mongoose/schemas/action/use.js +92 -0
  90. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -3
  91. package/lib/chevre/repo/mongoose/schemas/action.js +22 -7
  92. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +1 -0
  93. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +19 -1
  94. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +8 -9
  95. package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
  96. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +95 -76
  97. package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
  98. package/lib/chevre/repo/mongoose/schemas/event.js +7 -0
  99. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +7 -0
  100. package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
  101. package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +11 -4
  102. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +5 -16
  103. package/lib/chevre/repo/mongoose/schemas/task.d.ts +2 -5
  104. package/lib/chevre/repo/mongoose/schemas/task.js +134 -118
  105. package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
  106. package/lib/chevre/repo/orderInTransaction.d.ts +0 -3
  107. package/lib/chevre/repo/orderInTransaction.js +30 -22
  108. package/lib/chevre/repo/scheduledTask.d.ts +4 -1
  109. package/lib/chevre/repo/scheduledTask.js +3 -25
  110. package/lib/chevre/repo/task.d.ts +44 -155
  111. package/lib/chevre/repo/task.js +13 -555
  112. package/lib/chevre/repo/taskDelayed.d.ts +74 -0
  113. package/lib/chevre/repo/taskDelayed.js +195 -0
  114. package/lib/chevre/repo/taskRunning.d.ts +35 -0
  115. package/lib/chevre/repo/taskRunning.js +89 -0
  116. package/lib/chevre/repo/ticket.d.ts +0 -6
  117. package/lib/chevre/repo/ticket.js +0 -11
  118. package/lib/chevre/repo/transaction.d.ts +1 -187
  119. package/lib/chevre/repo/transaction.js +2 -383
  120. package/lib/chevre/repository.d.ts +65 -25
  121. package/lib/chevre/repository.js +144 -56
  122. package/lib/chevre/service/aggregation/system.d.ts +9 -8
  123. package/lib/chevre/service/aggregation/system.js +5 -5
  124. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +10 -17
  125. package/lib/chevre/service/assetTransaction/pay/check.d.ts +3 -1
  126. package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +0 -10
  127. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +1 -2
  128. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -2
  129. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -2
  130. package/lib/chevre/service/assetTransaction/refund.d.ts +0 -1
  131. package/lib/chevre/service/assetTransaction/refund.js +2 -2
  132. package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +4 -2
  133. package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +4 -2
  134. package/lib/chevre/service/assetTransaction/reserveCOA/cancel.d.ts +8 -4
  135. package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -1
  136. package/lib/chevre/service/asyncAction.d.ts +2 -2
  137. package/lib/chevre/service/asyncAction.js +1 -4
  138. package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +2 -2
  139. package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +0 -2
  140. package/lib/chevre/service/asyncActionHandler.d.ts +4 -4
  141. package/lib/chevre/service/asyncActionHandler.js +11 -13
  142. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +4 -2
  143. package/lib/chevre/service/event/processUpdateMovieTheater.js +3 -3
  144. package/lib/chevre/service/event.d.ts +4 -2
  145. package/lib/chevre/service/event.js +3 -3
  146. package/lib/chevre/service/notification/sendEmailMessage.d.ts +4 -2
  147. package/lib/chevre/service/notification/sendEmailMessage.js +3 -3
  148. package/lib/chevre/service/notification/triggerWebhook.d.ts +4 -2
  149. package/lib/chevre/service/notification/triggerWebhook.js +5 -16
  150. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  151. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +0 -1
  152. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +4 -2
  153. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -3
  154. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +9 -5
  155. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +1 -1
  156. package/lib/chevre/service/offer/event/voidTransaction.d.ts +6 -4
  157. package/lib/chevre/service/offer/event/voidTransaction.js +7 -9
  158. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +6 -4
  159. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +3 -15
  160. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
  161. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  162. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +0 -4
  163. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +23 -24
  164. package/lib/chevre/service/offer/onEventChanged.js +0 -2
  165. package/lib/chevre/service/order/confirmPayTransaction.d.ts +4 -10
  166. package/lib/chevre/service/order/confirmPayTransaction.js +7 -11
  167. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -1
  168. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +2 -56
  169. package/lib/chevre/service/order/deleteOrder.d.ts +2 -2
  170. package/lib/chevre/service/order/deleteOrder.js +1 -2
  171. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +1 -49
  172. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +2 -2
  173. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +2 -4
  174. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +2 -4
  175. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +2 -2
  176. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
  177. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +1 -9
  178. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
  179. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +4 -8
  180. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
  181. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +5 -11
  182. package/lib/chevre/service/order/onOrderUpdated/factory.js +0 -3
  183. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +4 -2
  184. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  185. package/lib/chevre/service/order/placeOrder.d.ts +6 -4
  186. package/lib/chevre/service/order/placeOrder.js +9 -17
  187. package/lib/chevre/service/order/returnOrder.d.ts +4 -4
  188. package/lib/chevre/service/order/returnOrder.js +11 -43
  189. package/lib/chevre/service/order/sendOrder.d.ts +4 -6
  190. package/lib/chevre/service/order/sendOrder.js +30 -72
  191. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +0 -1
  192. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +0 -1
  193. package/lib/chevre/service/payment/any/authorize.d.ts +1 -2
  194. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +0 -4
  195. package/lib/chevre/service/payment/any/findAcceptAction.js +23 -24
  196. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +0 -4
  197. package/lib/chevre/service/payment/any/findAuthorizeAction.js +23 -24
  198. package/lib/chevre/service/payment/any/findCheckAction.d.ts +3 -5
  199. package/lib/chevre/service/payment/any/findCheckAction.js +24 -25
  200. package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +0 -1
  201. package/lib/chevre/service/payment/any/onPayActionCompleted.d.ts +0 -1
  202. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
  203. package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.d.ts +0 -1
  204. package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +0 -1
  205. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +2 -2
  206. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -2
  207. package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -2
  208. package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +0 -1
  209. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +0 -1
  210. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +0 -1
  211. package/lib/chevre/service/payment/creditCard/authorize.d.ts +0 -1
  212. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +0 -1
  213. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +0 -1
  214. package/lib/chevre/service/payment/faceToFace.d.ts +0 -2
  215. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -2
  216. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -1
  217. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
  218. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +0 -1
  219. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +0 -1
  220. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -1
  221. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  222. package/lib/chevre/service/project.d.ts +0 -6
  223. package/lib/chevre/service/project.js +0 -2
  224. package/lib/chevre/service/reserve/cancelReservation.d.ts +7 -3
  225. package/lib/chevre/service/reserve/cancelReservation.js +15 -25
  226. package/lib/chevre/service/reserve/checkInReservation.d.ts +4 -2
  227. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  228. package/lib/chevre/service/reserve/confirmReservation.d.ts +4 -2
  229. package/lib/chevre/service/reserve/confirmReservation.js +10 -36
  230. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -1
  231. package/lib/chevre/service/reserve/useReservation.d.ts +6 -2
  232. package/lib/chevre/service/reserve/useReservation.js +6 -24
  233. package/lib/chevre/service/reserveCOA/cancelReservation.d.ts +4 -2
  234. package/lib/chevre/service/reserveCOA/cancelReservation.js +3 -3
  235. package/lib/chevre/service/scheduledTask.d.ts +1 -4
  236. package/lib/chevre/service/scheduledTask.js +3 -10
  237. package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +1 -2
  238. package/lib/chevre/service/scheduledTaskHandler.js +0 -13
  239. package/lib/chevre/service/task/acceptCOAOffer.js +5 -19
  240. package/lib/chevre/service/task/authorizePayment.js +6 -13
  241. package/lib/chevre/service/task/cancelPendingReservation.js +3 -4
  242. package/lib/chevre/service/task/cancelReservation.js +3 -5
  243. package/lib/chevre/service/task/checkMovieTicket.js +8 -13
  244. package/lib/chevre/service/task/checkResource.js +14 -57
  245. package/lib/chevre/service/task/confirmPayTransaction.js +11 -12
  246. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -2
  247. package/lib/chevre/service/task/confirmReserveTransaction.js +12 -7
  248. package/lib/chevre/service/task/createAccountingReport.js +8 -15
  249. package/lib/chevre/service/task/deleteTransaction.js +10 -41
  250. package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
  251. package/lib/chevre/service/task/invalidatePaymentUrl.js +0 -1
  252. package/lib/chevre/service/task/onAuthorizationCreated.js +4 -13
  253. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +4 -2
  254. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +4 -4
  255. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +4 -2
  256. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +4 -4
  257. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +4 -2
  258. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +4 -4
  259. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +4 -2
  260. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +4 -4
  261. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +4 -2
  262. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +4 -4
  263. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +4 -2
  264. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +4 -4
  265. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +4 -2
  266. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +4 -4
  267. package/lib/chevre/service/task/onResourceDeleted.js +4 -3
  268. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +0 -1
  269. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
  270. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +0 -1
  271. package/lib/chevre/service/task/onResourceUpdated.js +0 -10
  272. package/lib/chevre/service/task/pay.js +3 -3
  273. package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +0 -1
  274. package/lib/chevre/service/task/payment/payByTask.d.ts +3 -2
  275. package/lib/chevre/service/task/payment/payByTask.js +1 -1
  276. package/lib/chevre/service/task/payment/refundByTask.d.ts +0 -1
  277. package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +0 -2
  278. package/lib/chevre/service/task/placeOrder.js +8 -6
  279. package/lib/chevre/service/task/publishPaymentUrl.js +6 -18
  280. package/lib/chevre/service/task/refund.js +0 -1
  281. package/lib/chevre/service/task/reserve.js +3 -6
  282. package/lib/chevre/service/task/returnOrder.js +3 -7
  283. package/lib/chevre/service/task/returnPayTransaction.js +9 -19
  284. package/lib/chevre/service/task/returnReserveTransaction.js +5 -6
  285. package/lib/chevre/service/task/sendEmailMessage.js +2 -2
  286. package/lib/chevre/service/task/sendOrder.js +4 -8
  287. package/lib/chevre/service/task/syncResourcesFromCOA.js +31 -23
  288. package/lib/chevre/service/task/triggerWebhook.js +4 -2
  289. package/lib/chevre/service/task/useReservation.js +6 -2
  290. package/lib/chevre/service/task/voidPayment.js +0 -2
  291. package/lib/chevre/service/task/voidReserveTransaction.js +11 -13
  292. package/lib/chevre/service/task.d.ts +4 -4
  293. package/lib/chevre/service/task.js +8 -12
  294. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +0 -1
  295. package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +3 -2
  296. package/lib/chevre/service/taskHandler/onOperationFailed.js +5 -16
  297. package/lib/chevre/service/taskHandler.d.ts +1 -2
  298. package/lib/chevre/service/taskHandler.js +7 -19
  299. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +2 -2
  300. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +2 -2
  301. package/lib/chevre/service/transaction/deleteTransaction.d.ts +8 -4
  302. package/lib/chevre/service/transaction/deleteTransaction.js +7 -7
  303. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  304. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
  305. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +11 -17
  306. package/lib/chevre/service/transaction/returnOrder.js +11 -17
  307. package/lib/chevre/service/validation/validateOrder.d.ts +0 -4
  308. package/lib/chevre/service/validation/validateOrder.js +3 -3
  309. package/lib/chevre/taskSettings.d.ts +4 -4
  310. package/package.json +2 -2
  311. package/lib/chevre/repo/action/actionProcess.d.ts +0 -147
  312. package/lib/chevre/repo/action/actionProcess.js +0 -775
  313. package/lib/chevre/repo/action/checkThing.d.ts +0 -8
  314. package/lib/chevre/repo/action/checkThing.js +0 -13
  315. package/lib/chevre/repo/action.js +0 -468
  316. package/lib/chevre/repo/asyncActionLegacy.d.ts +0 -23
  317. package/lib/chevre/repo/asyncActionLegacy.js +0 -59
  318. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -227
  319. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.d.ts +0 -25
  320. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +0 -100
  321. package/lib/chevre/repo/ownershipInfo.d.ts +0 -122
  322. package/lib/chevre/repo/ownershipInfo.js +0 -466
  323. package/lib/chevre/repo/scheduledTaskLegacy.d.ts +0 -39
  324. package/lib/chevre/repo/scheduledTaskLegacy.js +0 -96
  325. package/lib/chevre/repo/scheduledTaskMigration.d.ts +0 -21
  326. package/lib/chevre/repo/scheduledTaskMigration.js +0 -70
  327. package/lib/chevre/service/validation/validateEvent.d.ts +0 -11
  328. package/lib/chevre/service/validation/validateEvent.js +0 -21
@@ -1,775 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActionProcessRepo = exports.AVAILABLE_PROJECT_FIELDS = void 0;
4
- const factory_1 = require("../../factory");
5
- const settings_1 = require("../../settings");
6
- const action_1 = require("../mongoose/schemas/action");
7
- const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
8
- exports.AVAILABLE_PROJECT_FIELDS = [
9
- 'project',
10
- 'actionStatus',
11
- 'typeOf',
12
- 'description',
13
- 'agent',
14
- 'recipient',
15
- 'result',
16
- 'error',
17
- 'object',
18
- 'startDate',
19
- 'endDate',
20
- 'purpose',
21
- 'potentialActions',
22
- // 'amount', // discontinue(2026-07-08~)
23
- // 'fromLocation', // discontinue(2026-07-08~)
24
- // 'toLocation', // discontinue(2026-07-08~)
25
- 'instrument',
26
- 'location',
27
- 'replacer',
28
- 'targetCollection',
29
- 'sameAs',
30
- 'cancelAction',
31
- 'about',
32
- 'target',
33
- 'identifier'
34
- ];
35
- // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
36
- function unknown2actionError(e) {
37
- if (e instanceof Error) {
38
- // Errorオブジェクトの場合は、既存のロジック通り展開
39
- return { ...e, name: e.name, message: e.message };
40
- }
41
- else {
42
- // Error以外(文字列など)が投げられた場合のハンドリング
43
- return { name: 'UnknownError', message: String(e) };
44
- }
45
- }
46
- ;
47
- /**
48
- * アクション状態管理リポジトリ
49
- */
50
- class ActionProcessRepo {
51
- actionModel;
52
- actionRecipeModel;
53
- constructor(connection) {
54
- this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
55
- this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
56
- }
57
- static CREATE_MONGO_CONDITIONS(params) {
58
- const andConditions = []; // eslint-disable-line @typescript-eslint/no-explicit-any
59
- const idIn = params.id?.$in;
60
- if (Array.isArray(idIn)) {
61
- andConditions.push({ _id: { $in: idIn } });
62
- }
63
- const idNin = params.id?.$nin;
64
- if (Array.isArray(idNin)) {
65
- andConditions.push({ _id: { $nin: idNin } });
66
- }
67
- const projectIdEq = params.project?.id?.$eq;
68
- if (typeof projectIdEq === 'string') {
69
- andConditions.push({
70
- 'project.id': {
71
- $eq: projectIdEq
72
- }
73
- });
74
- }
75
- const agentTypeOfIn = params.agent?.typeOf?.$in;
76
- if (Array.isArray(agentTypeOfIn)) {
77
- andConditions.push({
78
- 'agent.typeOf': {
79
- $exists: true,
80
- $in: agentTypeOfIn
81
- }
82
- });
83
- }
84
- const agentIdIn = params.agent?.id?.$in;
85
- if (Array.isArray(agentIdIn)) {
86
- andConditions.push({
87
- 'agent.id': {
88
- $exists: true,
89
- $in: agentIdIn
90
- }
91
- });
92
- }
93
- const instrumentTransactionNumberEq = params.instrument?.transactionNumber?.$eq;
94
- if (typeof instrumentTransactionNumberEq === 'string') {
95
- andConditions.push({ 'instrument.transactionNumber': { $exists: true, $eq: instrumentTransactionNumberEq } });
96
- }
97
- const instrumentTypeOfEq = params.instrument?.typeOf?.$eq;
98
- if (typeof instrumentTypeOfEq === 'string') {
99
- andConditions.push({ 'instrument.typeOf': { $exists: true, $eq: instrumentTypeOfEq } });
100
- }
101
- const instrumentIdentifierEq = params.instrument?.identifier?.$eq;
102
- if (typeof instrumentIdentifierEq === 'string') {
103
- andConditions.push({ 'instrument.identifier': { $exists: true, $eq: instrumentIdentifierEq } });
104
- }
105
- const instrumentIdEq = params.instrument?.id?.$eq;
106
- if (typeof instrumentIdEq === 'string') {
107
- andConditions.push({ 'instrument.id': { $exists: true, $eq: instrumentIdEq } });
108
- }
109
- const instrumentOrderNumberEq = params.instrument?.orderNumber?.$eq;
110
- if (typeof instrumentOrderNumberEq === 'string') {
111
- andConditions.push({ 'instrument.orderNumber': { $exists: true, $eq: instrumentOrderNumberEq } });
112
- }
113
- const locationIdEq = params.location?.id?.$eq;
114
- if (typeof locationIdEq === 'string') {
115
- andConditions.push({
116
- 'location.id': {
117
- $exists: true,
118
- $eq: locationIdEq
119
- }
120
- });
121
- }
122
- const locationIdentifierEq = params.location?.identifier?.$eq;
123
- if (typeof locationIdentifierEq === 'string') {
124
- andConditions.push({
125
- 'location.identifier': {
126
- $exists: true,
127
- $eq: locationIdentifierEq
128
- }
129
- });
130
- }
131
- const objectMovieTicketsIdentifierEq = params.object?.movieTickets?.identifier?.$eq;
132
- if (typeof objectMovieTicketsIdentifierEq === 'string') {
133
- andConditions.push({
134
- 'object.movieTickets.identifier': {
135
- $exists: true,
136
- $eq: objectMovieTicketsIdentifierEq
137
- }
138
- });
139
- }
140
- const objectMovieTicketsServiceOutputReservationForIdEq = params.object?.movieTickets?.serviceOutput?.reservationFor?.id?.$eq;
141
- if (typeof objectMovieTicketsServiceOutputReservationForIdEq === 'string') {
142
- andConditions.push({
143
- 'object.movieTickets.serviceOutput.reservationFor.id': {
144
- $exists: true,
145
- $eq: objectMovieTicketsServiceOutputReservationForIdEq
146
- }
147
- });
148
- }
149
- const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
150
- if (typeof objectPaymentMethodIdEq === 'string') {
151
- andConditions.push({
152
- 'object.paymentMethodId': {
153
- $exists: true,
154
- $eq: objectPaymentMethodIdEq
155
- }
156
- });
157
- }
158
- const objectObjectPaymentMethodIdEq = params.object?.object?.paymentMethodId?.$eq;
159
- if (typeof objectObjectPaymentMethodIdEq === 'string') {
160
- andConditions.push({
161
- 'object.object.paymentMethodId': {
162
- $exists: true,
163
- $eq: objectObjectPaymentMethodIdEq
164
- }
165
- });
166
- }
167
- const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
168
- if (typeof objectReservationForIdEq === 'string') {
169
- andConditions.push({
170
- 'object.reservationFor.id': {
171
- $exists: true,
172
- $eq: objectReservationForIdEq
173
- }
174
- });
175
- }
176
- const objectReservationNumberEq = params.object?.reservationNumber?.$eq;
177
- if (typeof objectReservationNumberEq === 'string') {
178
- andConditions.push({
179
- 'object.reservationNumber': {
180
- $exists: true,
181
- $eq: objectReservationNumberEq
182
- }
183
- });
184
- }
185
- const objectReservationNumberIn = params.object?.reservationNumber?.$in;
186
- if (Array.isArray(objectReservationNumberIn)) {
187
- andConditions.push({
188
- 'object.reservationNumber': {
189
- $exists: true,
190
- $in: objectReservationNumberIn
191
- }
192
- });
193
- }
194
- const objectPaymentMethodAccountIdEq = params.object?.paymentMethod?.accountId?.$eq;
195
- if (typeof objectPaymentMethodAccountIdEq === 'string') {
196
- andConditions.push({
197
- 'object.paymentMethod.accountId': {
198
- $exists: true,
199
- $eq: objectPaymentMethodAccountIdEq
200
- }
201
- });
202
- }
203
- const objectPaymentMethodPaymentMethodIdEq = params.object?.paymentMethod?.paymentMethodId?.$eq;
204
- if (typeof objectPaymentMethodPaymentMethodIdEq === 'string') {
205
- andConditions.push({
206
- 'object.paymentMethod.paymentMethodId': {
207
- $exists: true,
208
- $eq: objectPaymentMethodPaymentMethodIdEq
209
- }
210
- });
211
- }
212
- const objectPaymentMethodPaymentMethodIdIn = params.object?.paymentMethod?.paymentMethodId?.$in;
213
- if (Array.isArray(objectPaymentMethodPaymentMethodIdIn)) {
214
- andConditions.push({
215
- 'object.paymentMethod.paymentMethodId': {
216
- $exists: true,
217
- $in: objectPaymentMethodPaymentMethodIdIn
218
- }
219
- });
220
- }
221
- const objectPaymentMethodTypeOfEq = params.object?.paymentMethod?.typeOf?.$eq;
222
- if (typeof objectPaymentMethodTypeOfEq === 'string') {
223
- andConditions.push({
224
- 'object.paymentMethod.typeOf': {
225
- $exists: true,
226
- $eq: objectPaymentMethodTypeOfEq
227
- }
228
- });
229
- }
230
- const objectTypeOfEq = params.object?.typeOf?.$eq;
231
- if (typeof objectTypeOfEq === 'string') {
232
- andConditions.push({
233
- 'object.typeOf': {
234
- $exists: true,
235
- $eq: objectTypeOfEq
236
- }
237
- });
238
- }
239
- const objectTypeOfIn = params.object?.typeOf?.$in;
240
- if (Array.isArray(objectTypeOfIn)) {
241
- andConditions.push({
242
- 'object.typeOf': {
243
- $exists: true,
244
- $in: objectTypeOfIn
245
- }
246
- });
247
- }
248
- const objectIdEq = params.object?.id?.$eq;
249
- if (typeof objectIdEq === 'string') {
250
- andConditions.push({
251
- 'object.id': {
252
- $exists: true,
253
- $eq: objectIdEq
254
- }
255
- });
256
- }
257
- const objectIdIn = params.object?.id?.$in;
258
- if (Array.isArray(objectIdIn)) {
259
- andConditions.push({
260
- 'object.id': {
261
- $exists: true,
262
- $in: objectIdIn
263
- }
264
- });
265
- }
266
- const objectOrderNumberIn = params.object?.orderNumber?.$in;
267
- if (Array.isArray(objectOrderNumberIn)) {
268
- andConditions.push({
269
- 'object.orderNumber': {
270
- $exists: true,
271
- $in: objectOrderNumberIn
272
- }
273
- });
274
- }
275
- // 承認アクションのobject.event廃止につき検索条件も廃止(2026-07-04~)
276
- // const objectEventIdIn = params.object?.event?.id?.$in;
277
- // if (Array.isArray(objectEventIdIn)) {
278
- // andConditions.push({
279
- // 'object.event.id': {
280
- // $exists: true,
281
- // $in: objectEventIdIn
282
- // }
283
- // });
284
- // }
285
- const objectTransactionNumberEq = params.object?.transactionNumber?.$eq;
286
- if (typeof objectTransactionNumberEq === 'string') {
287
- andConditions.push({ 'object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
288
- }
289
- if (typeof params.typeOf === 'string') {
290
- andConditions.push({
291
- typeOf: params.typeOf
292
- });
293
- }
294
- else {
295
- const typeOfEq = params.typeOf?.$eq;
296
- if (typeof typeOfEq === 'string') {
297
- andConditions.push({
298
- typeOf: { $eq: typeOfEq }
299
- });
300
- }
301
- }
302
- const actionStatusIn = params.actionStatus?.$in;
303
- if (Array.isArray(actionStatusIn)) {
304
- andConditions.push({
305
- actionStatus: { $in: actionStatusIn }
306
- });
307
- }
308
- if (Array.isArray(params.actionStatusTypes)) {
309
- andConditions.push({
310
- actionStatus: { $in: params.actionStatusTypes }
311
- });
312
- }
313
- const startDateGte = params.startFrom;
314
- if (startDateGte instanceof Date) {
315
- andConditions.push({
316
- startDate: { $gte: startDateGte }
317
- });
318
- }
319
- const startDateLte = params.startThrough;
320
- if (startDateLte instanceof Date) {
321
- andConditions.push({
322
- startDate: { $lte: startDateLte }
323
- });
324
- }
325
- // const fromLocationTypeOfIn = params.fromLocation?.typeOf?.$in;
326
- // if (Array.isArray(fromLocationTypeOfIn)) {
327
- // andConditions.push({
328
- // 'fromLocation.typeOf': {
329
- // $exists: true,
330
- // $in: fromLocationTypeOfIn
331
- // }
332
- // });
333
- // }
334
- // const fromLocationAccountNumberIn = params.fromLocation?.accountNumber?.$in;
335
- // if (Array.isArray(fromLocationAccountNumberIn)) {
336
- // andConditions.push({
337
- // 'fromLocation.accountNumber': {
338
- // $exists: true,
339
- // $in: fromLocationAccountNumberIn
340
- // }
341
- // });
342
- // }
343
- // const fromLocationAccountTypeIn = params.fromLocation?.accountType?.$in;
344
- // if (Array.isArray(fromLocationAccountTypeIn)) {
345
- // andConditions.push({
346
- // 'fromLocation.accountType': {
347
- // $exists: true,
348
- // $in: fromLocationAccountTypeIn
349
- // }
350
- // });
351
- // }
352
- // const toLocationTypeOfIn = params.toLocation?.typeOf?.$in;
353
- // if (Array.isArray(toLocationTypeOfIn)) {
354
- // andConditions.push({
355
- // 'toLocation.typeOf': {
356
- // $exists: true,
357
- // $in: toLocationTypeOfIn
358
- // }
359
- // });
360
- // }
361
- // const toLocationAccountNumberIn = params.toLocation?.accountNumber?.$in;
362
- // if (Array.isArray(toLocationAccountNumberIn)) {
363
- // andConditions.push({
364
- // 'toLocation.accountNumber': {
365
- // $exists: true,
366
- // $in: toLocationAccountNumberIn
367
- // }
368
- // });
369
- // }
370
- // const toLocationAccountTypeIn = params.toLocation?.accountType?.$in;
371
- // if (Array.isArray(toLocationAccountTypeIn)) {
372
- // andConditions.push({
373
- // 'toLocation.accountType': {
374
- // $exists: true,
375
- // $in: toLocationAccountTypeIn
376
- // }
377
- // });
378
- // }
379
- const purposeTypeOfIn = params.purpose?.typeOf?.$in;
380
- if (Array.isArray(purposeTypeOfIn)) {
381
- andConditions.push({
382
- 'purpose.typeOf': {
383
- $exists: true,
384
- $in: purposeTypeOfIn
385
- }
386
- });
387
- }
388
- const purposeIdIn = params.purpose?.id?.$in;
389
- if (Array.isArray(purposeIdIn)) {
390
- andConditions.push({
391
- 'purpose.id': {
392
- $exists: true,
393
- $in: purposeIdIn
394
- }
395
- });
396
- }
397
- const purposeOrderNumberIn = params.purpose?.orderNumber?.$in;
398
- if (Array.isArray(purposeOrderNumberIn)) {
399
- andConditions.push({
400
- 'purpose.orderNumber': {
401
- $exists: true,
402
- $in: purposeOrderNumberIn
403
- }
404
- });
405
- }
406
- const resultTypeOfIn = params.result?.typeOf?.$in;
407
- if (Array.isArray(resultTypeOfIn)) {
408
- andConditions.push({
409
- 'result.typeOf': {
410
- $exists: true,
411
- $in: resultTypeOfIn
412
- }
413
- });
414
- }
415
- const resultIdIn = params.result?.id?.$in;
416
- if (Array.isArray(resultIdIn)) {
417
- andConditions.push({
418
- 'result.id': {
419
- $exists: true,
420
- $in: resultIdIn
421
- }
422
- });
423
- }
424
- const resultOrderNumberIn = params.result?.orderNumber?.$in;
425
- if (Array.isArray(resultOrderNumberIn)) {
426
- andConditions.push({
427
- 'result.orderNumber': {
428
- $exists: true,
429
- $in: resultOrderNumberIn
430
- }
431
- });
432
- }
433
- const resultCodeIn = params.result?.code?.$in;
434
- if (Array.isArray(resultCodeIn)) {
435
- andConditions.push({
436
- 'result.code': {
437
- $exists: true,
438
- $in: resultCodeIn
439
- }
440
- });
441
- }
442
- // sameAs(2024-04-23~)
443
- const sameAsIdEq = params.sameAs?.id?.$eq;
444
- if (typeof sameAsIdEq === 'string') {
445
- andConditions.push({ 'sameAs.id': { $exists: true, $eq: sameAsIdEq } });
446
- }
447
- const aboutOrderNumberEq = params.about?.orderNumber?.$eq;
448
- if (typeof aboutOrderNumberEq === 'string') {
449
- andConditions.push({ 'about.orderNumber': { $exists: true, $eq: aboutOrderNumberEq } });
450
- }
451
- return andConditions;
452
- }
453
- /**
454
- * アクション開始
455
- */
456
- async start(
457
- // public async start<T extends Exclude<TAction['typeOf'], factory.actionType.AcceptAction>>(
458
- attributes, // eslint-disable-line @typescript-eslint/no-explicit-any
459
- options) {
460
- const startDate = new Date();
461
- const creatingAction = {
462
- ...attributes,
463
- actionStatus: factory_1.factory.actionStatusType.ActiveActionStatus,
464
- startDate
465
- };
466
- // reimplemnt with insertMany(2024-08-29~)
467
- const result = await this.actionModel.insertMany(creatingAction, { rawResult: true });
468
- const id = result.insertedIds?.[0]?.toHexString();
469
- if (typeof id !== 'string') {
470
- throw new factory_1.factory.errors.Internal('action not saved');
471
- }
472
- // add recipe(2024-06-09~)
473
- const savingRecipe = options?.recipe;
474
- if (savingRecipe?.typeOf === 'Recipe') {
475
- await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf } });
476
- }
477
- return { id, startDate, typeOf: creatingAction.typeOf };
478
- }
479
- async completeWithVoid(params) {
480
- if (params.recipe?.typeOf === 'Recipe') {
481
- await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
482
- }
483
- const doc = await this.actionModel.findOneAndUpdate({
484
- _id: { $eq: params.id },
485
- typeOf: { $eq: params.typeOf }
486
- }, {
487
- $set: {
488
- actionStatus: factory_1.factory.actionStatusType.CompletedActionStatus,
489
- result: params.result,
490
- endDate: new Date()
491
- }
492
- }, { new: false, projection: { _id: 1 } })
493
- .lean()
494
- .exec();
495
- if (doc === null) {
496
- throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
497
- }
498
- }
499
- /**
500
- * アクション取消
501
- */
502
- async cancelWithVoid(params) {
503
- const cancelDate = new Date();
504
- const cancelAction = (params.cancelAction !== undefined)
505
- ? {
506
- ...params.cancelAction,
507
- endTime: cancelDate,
508
- typeOf: factory_1.factory.actionType.CancelAction
509
- }
510
- : undefined;
511
- const doc = await this.actionModel.findOneAndUpdate({
512
- _id: { $eq: params.id },
513
- typeOf: { $eq: params.typeOf },
514
- actionStatus: { $ne: factory_1.factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
515
- }, {
516
- $set: {
517
- actionStatus: factory_1.factory.actionStatusType.CanceledActionStatus,
518
- ...(cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
519
- }
520
- }, { new: false, projection: { _id: 1 } })
521
- .lean()
522
- .exec();
523
- if (doc === null) {
524
- // 既にCanceledActionStatusであればok
525
- const existingAction = await this.findActionStatusById({ id: params.id, typeOf: params.typeOf });
526
- if (existingAction.actionStatus !== factory_1.factory.actionStatusType.CanceledActionStatus) {
527
- throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
528
- }
529
- }
530
- // endDateが存在しなければセット(2024-04-22~)
531
- await this.actionModel.updateOne({
532
- _id: { $eq: params.id },
533
- endDate: { $exists: false }
534
- }, { $set: { endDate: cancelDate } })
535
- .exec();
536
- }
537
- /**
538
- * アクション失敗
539
- */
540
- async giveUp(params) {
541
- // const actionError: IActionError | IActionError[] = (Array.isArray(params.error))
542
- // ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
543
- // : { ...params.error, message: params.error.message, name: params.error.name };
544
- const actionError = Array.isArray(params.error)
545
- ? params.error.map(unknown2actionError)
546
- : unknown2actionError(params.error);
547
- if (params.recipe?.typeOf === 'Recipe') {
548
- await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
549
- }
550
- const doc = await this.actionModel.findOneAndUpdate({
551
- typeOf: { $eq: params.typeOf },
552
- _id: { $eq: params.id }
553
- }, {
554
- $set: {
555
- actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
556
- error: actionError,
557
- endDate: new Date()
558
- }
559
- }, { new: true, projection: { _id: 1 } })
560
- .lean()
561
- .exec();
562
- if (doc === null) {
563
- throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
564
- }
565
- }
566
- /**
567
- * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
568
- */
569
- async giveUpStartDatePassedCertainPeriod(params) {
570
- return this.actionModel.updateMany({
571
- actionStatus: { $eq: factory_1.factory.actionStatusType.ActiveActionStatus },
572
- // 一定期間過ぎたもの
573
- startDate: { $lt: params.startDate.$lt },
574
- ...(typeof params.id?.$eq === 'string') ? { _id: { $eq: params.id.$eq } } : undefined
575
- }, {
576
- actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
577
- error: params.error,
578
- endDate: new Date()
579
- })
580
- .exec();
581
- }
582
- async findRecipeByAction(params) {
583
- return this.actionRecipeModel.findOne({
584
- 'project.id': { $eq: params.project.id },
585
- 'recipeFor.id': { $eq: params.recipeFor.id }
586
- }, { step: 1, recipeCategory: 1 }
587
- // { lean: true }
588
- )
589
- .lean()
590
- .exec();
591
- // if (result === null) {
592
- // throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
593
- // }
594
- // return result;
595
- }
596
- async findById(params, inclusion, exclusion) {
597
- let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
598
- if (Array.isArray(inclusion) && inclusion.length > 0) {
599
- positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
600
- }
601
- else {
602
- if (Array.isArray(exclusion) && exclusion.length > 0) {
603
- positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
604
- }
605
- }
606
- const projection = {
607
- _id: 0,
608
- id: { $toString: '$_id' },
609
- ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
610
- };
611
- const doc = await this.actionModel.findOne({
612
- typeOf: { $eq: params.typeOf },
613
- _id: { $eq: params.id }
614
- }, projection)
615
- .lean() // 2024-08-26~
616
- .exec();
617
- if (doc === null) {
618
- throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
619
- }
620
- return doc;
621
- }
622
- async searchBySameAs(params) {
623
- const projection = {
624
- _id: 0,
625
- id: { $toString: '$_id' },
626
- actionStatus: 1,
627
- error: 1,
628
- purpose: 1
629
- };
630
- const query = this.actionModel.find({
631
- typeOf: { $eq: params.typeOf.$eq },
632
- 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq },
633
- ...(typeof params.purpose?.id.$eq === 'string')
634
- ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
635
- : undefined
636
- }, projection)
637
- // .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
638
- .limit(1);
639
- return query
640
- .lean() // 2024-08-26~
641
- .exec();
642
- }
643
- async findActionStatusById(params) {
644
- const projection = {
645
- _id: 0,
646
- id: { $toString: '$_id' },
647
- actionStatus: 1
648
- };
649
- const doc = await this.actionModel.findOne({
650
- typeOf: { $eq: params.typeOf },
651
- _id: { $eq: params.id }
652
- }, projection)
653
- .lean() // 2024-08-26~
654
- .exec();
655
- if (doc === null) {
656
- throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
657
- }
658
- return doc;
659
- }
660
- /**
661
- * 汎用アクション検索
662
- * 継承クラスから呼ぶ想定
663
- */
664
- async findAnyActions(params, inclusion) {
665
- const conditions = ActionProcessRepo.CREATE_MONGO_CONDITIONS(params);
666
- let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
667
- if (Array.isArray(inclusion) && inclusion.length > 0) {
668
- positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
669
- }
670
- const projection = {
671
- _id: 0,
672
- id: { $toString: '$_id' },
673
- ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
674
- };
675
- const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
676
- if (typeof params.limit === 'number' && params.limit > 0) {
677
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
678
- query.limit(params.limit)
679
- .skip(params.limit * (page - 1));
680
- }
681
- /* istanbul ignore else */
682
- if (params.sort?.startDate !== undefined) {
683
- query.sort({ startDate: params.sort.startDate });
684
- }
685
- // const explainResult = await (<any>query).explain();
686
- // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
687
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
688
- .lean() // 2024-08-26~
689
- .exec();
690
- }
691
- /**
692
- * 取引に対する汎用アクション検索
693
- * 継承クラスから呼ぶ想定
694
- * 件数はlimitされない
695
- */
696
- async findAnyActionsByPurpose(params) {
697
- const andConditions = [
698
- { 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
699
- { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
700
- ];
701
- const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
702
- if (typeof objectPaymentMethodIdEq === 'string') {
703
- andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
704
- }
705
- const objectTypeOfEq = params.object?.typeOf?.$eq;
706
- if (typeof objectTypeOfEq === 'string') {
707
- andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
708
- }
709
- const objectTypeOfIn = params.object?.typeOf?.$in;
710
- if (Array.isArray(objectTypeOfIn)) {
711
- andConditions.push({ 'object.typeOf': { $exists: true, $in: objectTypeOfIn } });
712
- }
713
- if (typeof params.typeOf === 'string') {
714
- andConditions.push({ typeOf: { $eq: params.typeOf } });
715
- }
716
- const actionStatusEq = params.actionStatus?.$eq;
717
- if (typeof actionStatusEq === 'string') {
718
- andConditions.push({ actionStatus: { $eq: actionStatusEq } });
719
- }
720
- const positiveProjectionFields = [
721
- 'project',
722
- 'actionStatus',
723
- 'typeOf',
724
- 'description',
725
- 'agent',
726
- 'recipient',
727
- 'result',
728
- 'error',
729
- 'object',
730
- 'startDate',
731
- 'endDate',
732
- 'purpose',
733
- 'potentialActions',
734
- 'instrument',
735
- 'location',
736
- 'sameAs',
737
- 'cancelAction',
738
- 'identifier'
739
- ];
740
- const projection = {
741
- _id: 0,
742
- id: { $toString: '$_id' },
743
- ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
744
- };
745
- const query = this.actionModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
746
- if (typeof params.sort?.startDate === 'number') {
747
- query.sort({ startDate: params.sort.startDate });
748
- }
749
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
750
- .lean()
751
- .exec();
752
- }
753
- async upsertRecipe(savingRecipe) {
754
- const dateModified = new Date();
755
- const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
756
- const filter = {
757
- 'recipeFor.id': { $eq: recipeFor.id }
758
- };
759
- const setOnInsert = {
760
- project, typeOf, recipeCategory, recipeFor,
761
- dateCreated: dateModified
762
- };
763
- const setKeys = { step, dateModified };
764
- const update = {
765
- $setOnInsert: setOnInsert,
766
- $set: setKeys
767
- };
768
- await this.actionRecipeModel.updateOne(filter, update, {
769
- upsert: true
770
- // includeResultMetadata: true
771
- })
772
- .exec();
773
- }
774
- }
775
- exports.ActionProcessRepo = ActionProcessRepo;