@chevre/domain 25.2.0-alpha.9 → 26.0.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 (260) hide show
  1. package/lib/chevre/eventEmitter/task.d.ts +2 -1
  2. package/lib/chevre/factory/customerTelephone2COATelNum.d.ts +3 -0
  3. package/lib/chevre/factory/customerTelephone2COATelNum.js +22 -0
  4. package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
  5. package/lib/chevre/repo/action/acceptPay.js +47 -19
  6. package/lib/chevre/repo/action.d.ts +16 -9
  7. package/lib/chevre/repo/action.js +99 -180
  8. package/lib/chevre/repo/adminTask.d.ts +37 -0
  9. package/lib/chevre/repo/adminTask.js +163 -0
  10. package/lib/chevre/repo/aggregateOffer.d.ts +3 -14
  11. package/lib/chevre/repo/aggregateOffer.js +16 -125
  12. package/lib/chevre/repo/aggregateTask.d.ts +37 -0
  13. package/lib/chevre/repo/aggregateTask.js +136 -0
  14. package/lib/chevre/repo/asyncAction.d.ts +69 -0
  15. package/lib/chevre/repo/asyncAction.js +237 -0
  16. package/lib/chevre/repo/concurrentLock.d.ts +3 -1
  17. package/lib/chevre/repo/creativeWork.d.ts +2 -3
  18. package/lib/chevre/repo/credentials.d.ts +2 -1
  19. package/lib/chevre/repo/customerType.d.ts +2 -3
  20. package/lib/chevre/repo/event.d.ts +10 -11
  21. package/lib/chevre/repo/eventOffer.d.ts +4 -5
  22. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +2 -3
  23. package/lib/chevre/repo/eventSeries.d.ts +4 -5
  24. package/lib/chevre/repo/message.d.ts +1 -1
  25. package/lib/chevre/repo/message.js +1 -1
  26. package/lib/chevre/repo/mongoose/schemas/asyncAction.d.ts +13 -0
  27. package/lib/chevre/repo/mongoose/schemas/asyncAction.js +89 -0
  28. package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
  29. package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
  30. package/lib/chevre/repo/mongoose/schemas/scheduledTasks.d.ts +16 -0
  31. package/lib/chevre/repo/mongoose/schemas/scheduledTasks.js +103 -0
  32. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
  33. package/lib/chevre/repo/mongoose/schemas/task.d.ts +6 -1
  34. package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
  35. package/lib/chevre/repo/note.d.ts +3 -4
  36. package/lib/chevre/repo/noteAboutOrder.d.ts +2 -3
  37. package/lib/chevre/repo/offer/offerInCatalogReadOnly.d.ts +2 -2
  38. package/lib/chevre/repo/offer/unitPriceInCatalog.d.ts +2 -2
  39. package/lib/chevre/repo/offer/unitPriceInCatalog.js +59 -11
  40. package/lib/chevre/repo/offerCatalog.d.ts +2 -3
  41. package/lib/chevre/repo/offerCatalogItem.d.ts +2 -3
  42. package/lib/chevre/repo/order.d.ts +2 -0
  43. package/lib/chevre/repo/order.js +14 -14
  44. package/lib/chevre/repo/orderInTransaction.d.ts +68 -1
  45. package/lib/chevre/repo/orderInTransaction.js +181 -3
  46. package/lib/chevre/repo/passport.d.ts +2 -1
  47. package/lib/chevre/repo/person.d.ts +0 -15
  48. package/lib/chevre/repo/person.js +122 -108
  49. package/lib/chevre/repo/place/entranceGate.d.ts +4 -5
  50. package/lib/chevre/repo/place/movieTheater.d.ts +3 -4
  51. package/lib/chevre/repo/place/screeningRoom.d.ts +4 -5
  52. package/lib/chevre/repo/place/seat.d.ts +4 -5
  53. package/lib/chevre/repo/place/section.d.ts +3 -4
  54. package/lib/chevre/repo/priceSpecification.d.ts +4 -4
  55. package/lib/chevre/repo/product.d.ts +3 -4
  56. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -1
  57. package/lib/chevre/repo/rateLimit/offer.js +0 -12
  58. package/lib/chevre/repo/reservation.d.ts +2 -3
  59. package/lib/chevre/repo/scheduledTask.d.ts +90 -0
  60. package/lib/chevre/repo/scheduledTask.js +223 -0
  61. package/lib/chevre/repo/sellerMakesOffer.d.ts +3 -4
  62. package/lib/chevre/repo/stockHolder.d.ts +1 -1
  63. package/lib/chevre/repo/stockHolder.js +0 -146
  64. package/lib/chevre/repo/task.d.ts +30 -71
  65. package/lib/chevre/repo/task.js +59 -345
  66. package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
  67. package/lib/chevre/repo/transaction/placeOrder.js +43 -83
  68. package/lib/chevre/repo/transaction.d.ts +2 -2
  69. package/lib/chevre/repo/transactionNumberCounter.js +0 -34
  70. package/lib/chevre/repo/transactionProcess.d.ts +2 -1
  71. package/lib/chevre/repo/transactionProcess.js +0 -13
  72. package/lib/chevre/repository.d.ts +20 -0
  73. package/lib/chevre/repository.js +46 -2
  74. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
  75. package/lib/chevre/service/aggregation/system.d.ts +2 -2
  76. package/lib/chevre/service/aggregation/system.js +1 -1
  77. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -1
  78. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +1 -1
  79. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
  80. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +1 -1
  81. package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
  82. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
  83. package/lib/chevre/service/assetTransaction/refund.js +1 -1
  84. package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +1 -1
  85. package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -67
  86. package/lib/chevre/service/asyncAction.d.ts +16 -0
  87. package/lib/chevre/service/asyncAction.js +36 -0
  88. package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +15 -0
  89. package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +42 -0
  90. package/lib/chevre/service/asyncActionHandler.d.ts +13 -0
  91. package/lib/chevre/service/asyncActionHandler.js +89 -0
  92. package/lib/chevre/service/notification/factory.d.ts +2 -4
  93. package/lib/chevre/service/notification/factory.js +26 -24
  94. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +12 -6
  95. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +12 -4
  96. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -5
  97. package/lib/chevre/service/offer/event/authorize/factory.js +93 -75
  98. package/lib/chevre/service/offer/event/authorize.d.ts +0 -4
  99. package/lib/chevre/service/offer/event/authorize.js +2 -2
  100. package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
  101. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
  102. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
  103. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
  104. package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +2 -1
  105. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
  106. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +15 -12
  107. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
  108. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
  109. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +4 -0
  110. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +20 -9
  111. package/lib/chevre/service/offer/onEventChanged.js +2 -2
  112. package/lib/chevre/service/order/confirmPayTransaction.js +1 -1
  113. package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
  114. package/lib/chevre/service/order/deleteOrder.js +8 -1
  115. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +19 -11
  116. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
  117. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -2
  118. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +1 -7
  119. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
  120. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +2 -0
  121. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  122. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
  123. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
  124. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  125. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
  126. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +3 -3
  127. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +0 -3
  128. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +73 -44
  129. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
  130. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +53 -33
  131. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
  132. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -2
  133. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +6 -4
  134. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  135. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +3 -7
  136. package/lib/chevre/service/order/onOrderUpdated.js +1 -1
  137. package/lib/chevre/service/order/payOrder.d.ts +2 -0
  138. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -1
  139. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +13 -58
  140. package/lib/chevre/service/order/placeOrder/factory.js +3 -21
  141. package/lib/chevre/service/order/placeOrder.d.ts +4 -5
  142. package/lib/chevre/service/order/placeOrder.js +20 -31
  143. package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
  144. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
  145. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
  146. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
  147. package/lib/chevre/service/payment/any/authorize.js +7 -5
  148. package/lib/chevre/service/payment/any/factory.d.ts +7 -7
  149. package/lib/chevre/service/payment/any/factory.js +18 -21
  150. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +7 -1
  151. package/lib/chevre/service/payment/any/findAcceptAction.js +34 -15
  152. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +4 -0
  153. package/lib/chevre/service/payment/any/findAuthorizeAction.js +20 -9
  154. package/lib/chevre/service/payment/any/findCheckAction.d.ts +4 -0
  155. package/lib/chevre/service/payment/any/findCheckAction.js +20 -9
  156. package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
  157. package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +5 -67
  158. package/lib/chevre/service/payment/any/onPayActionCompleted.js +1 -1
  159. package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +1 -1
  160. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
  161. package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
  162. package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
  163. package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
  164. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  165. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
  166. package/lib/chevre/service/reserve/adminFindReservations.d.ts +15 -0
  167. package/lib/chevre/service/reserve/adminFindReservations.js +35 -0
  168. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +1 -1
  169. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -1
  170. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
  171. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +20 -11
  172. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -1
  173. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +1 -1
  174. package/lib/chevre/service/reserve/searchByOrder.js +2 -6
  175. package/lib/chevre/service/reserve.d.ts +2 -2
  176. package/lib/chevre/service/reserve.js +3 -3
  177. package/lib/chevre/service/scheduledTask.d.ts +11 -0
  178. package/lib/chevre/service/scheduledTask.js +40 -0
  179. package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.d.ts +14 -0
  180. package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +56 -0
  181. package/lib/chevre/service/scheduledTaskHandler.d.ts +12 -0
  182. package/lib/chevre/service/scheduledTaskHandler.js +66 -0
  183. package/lib/chevre/service/task/aggregateOffers.d.ts +2 -2
  184. package/lib/chevre/service/task/aggregateOffers.js +2 -1
  185. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -2
  186. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -1
  187. package/lib/chevre/service/task/authorizePayment.js +3 -1
  188. package/lib/chevre/service/task/cancelReservation.d.ts +2 -2
  189. package/lib/chevre/service/task/cancelReservation.js +2 -1
  190. package/lib/chevre/service/task/confirmPayTransaction.js +0 -1
  191. package/lib/chevre/service/task/confirmReserveTransaction.js +3 -8
  192. package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
  193. package/lib/chevre/service/task/deleteTransaction.js +2 -1
  194. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
  195. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -3
  196. package/lib/chevre/service/task/onEventChanged.d.ts +2 -2
  197. package/lib/chevre/service/task/onEventChanged.js +2 -1
  198. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
  199. package/lib/chevre/service/task/onOrderPaymentCompleted.js +4 -1
  200. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +2 -2
  201. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +1 -1
  202. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  203. package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -2
  204. package/lib/chevre/service/task/onResourceUpdated.js +10 -9
  205. package/lib/chevre/service/task/placeOrder.d.ts +2 -2
  206. package/lib/chevre/service/task/placeOrder.js +6 -3
  207. package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
  208. package/lib/chevre/service/task/refund.d.ts +2 -2
  209. package/lib/chevre/service/task/refund.js +4 -10
  210. package/lib/chevre/service/task/reserve.d.ts +2 -2
  211. package/lib/chevre/service/task/reserve.js +2 -1
  212. package/lib/chevre/service/task/returnOrder.d.ts +2 -2
  213. package/lib/chevre/service/task/returnOrder.js +2 -1
  214. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  215. package/lib/chevre/service/task/sendOrder.d.ts +2 -2
  216. package/lib/chevre/service/task/sendOrder.js +2 -1
  217. package/lib/chevre/service/task/voidPayTransaction.js +3 -7
  218. package/lib/chevre/service/task/voidPayment.d.ts +2 -2
  219. package/lib/chevre/service/task/voidPayment.js +2 -1
  220. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  221. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +1 -1
  222. package/lib/chevre/service/taskHandler/onOperationFailed.js +1 -1
  223. package/lib/chevre/service/taskHandler.d.ts +2 -2
  224. package/lib/chevre/service/taskHandler.js +36 -37
  225. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
  226. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
  227. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
  228. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
  229. package/lib/chevre/service/transaction/deleteTransaction.d.ts +1 -1
  230. package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
  231. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +28 -2
  232. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +11 -12
  233. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +4 -2
  234. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +6 -7
  235. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +32 -4
  236. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +10 -1
  237. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
  238. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +6 -2
  239. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +23 -9
  240. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +6 -5
  241. package/lib/chevre/service/transaction/placeOrder/confirm.js +30 -40
  242. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
  243. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  244. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
  245. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
  246. package/lib/chevre/service/transaction/placeOrder/start.d.ts +1 -1
  247. package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.d.ts +20 -0
  248. package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.js +63 -0
  249. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +0 -1
  250. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +17 -86
  251. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  252. package/lib/chevre/service/transaction/returnOrder.js +1 -1
  253. package/lib/chevre/service.d.ts +8 -0
  254. package/lib/chevre/service.js +23 -1
  255. package/lib/chevre/taskSettings.d.ts +3 -4
  256. package/package.json +8 -11
  257. package/lib/chevre/service/order/findConfirmedPlaceOrder.d.ts +0 -13
  258. package/lib/chevre/service/order/findConfirmedPlaceOrder.js +0 -32
  259. package/lib/chevre/service/reserve/findReservations.d.ts +0 -33
  260. package/lib/chevre/service/reserve/findReservations.js +0 -61
@@ -0,0 +1,69 @@
1
+ import type { Connection, FilterQuery } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ import { IModel, IDocType } from './mongoose/schemas/asyncAction';
4
+ import type { IExecutableTask } from '../taskSettings';
5
+ type ISavingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'executionResults' | 'name' | 'project' | 'runsAt' | 'status'> & {
6
+ expires: Date;
7
+ };
8
+ export type IExecutableAsyncAction = Pick<IExecutableTask<factory.taskName>, 'data' | 'expires' | 'id' | 'name' | 'project' | 'runsAt' | 'status'>;
9
+ type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | 'expires';
10
+ type IFindParams = Pick<factory.task.ISearchConditions, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status' | 'limit' | 'page' | 'sort'>;
11
+ /**
12
+ * 非同期アクションリポジトリ
13
+ */
14
+ export declare class AsyncActionRepo {
15
+ readonly asyncActionModel: IModel;
16
+ constructor(connection: Connection);
17
+ static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status'>): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask>[];
18
+ findAsyncActions(params: IFindParams, inclusion: IKeyOfProjection[]): Promise<(IDocType & {
19
+ id: string;
20
+ })[]>;
21
+ /**
22
+ * Readyタスクをひとつ追加する
23
+ */
24
+ addReadyAsyncAction(params: Pick<ISavingTask, 'data' | 'expires' | 'name' | 'project' | 'runsAt'> & {
25
+ alternateName?: never;
26
+ identifier?: never;
27
+ }): Promise<{
28
+ id: string;
29
+ }>;
30
+ /**
31
+ * Ready -> Running
32
+ */
33
+ executeAsyncActionById(params: {
34
+ id: string;
35
+ executor: {
36
+ name: string;
37
+ };
38
+ }): Promise<IExecutableAsyncAction | null>;
39
+ /**
40
+ * 非同期アクションの状態を参照する
41
+ */
42
+ findAsyncActionById(params: {
43
+ id: {
44
+ $eq: string;
45
+ };
46
+ project: {
47
+ id: {
48
+ $eq: string;
49
+ };
50
+ };
51
+ name: factory.taskName;
52
+ }, inclusion: IKeyOfProjection[]): Promise<(IDocType & {
53
+ id: string;
54
+ } | undefined)>;
55
+ /**
56
+ * タスクIDから実行結果とステータスを保管する
57
+ * Abortedの場合、dateAbortedもセットする
58
+ */
59
+ setExecutionResultAndStatus(params: {
60
+ /**
61
+ * タスクID
62
+ */
63
+ id: string;
64
+ }, update: {
65
+ status: factory.taskStatus.Executed | factory.taskStatus.Aborted;
66
+ executionResult: factory.task.IExecutionResult;
67
+ }): Promise<void>;
68
+ }
69
+ export {};
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncActionRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const settings_1 = require("../settings");
6
+ const asyncAction_1 = require("./mongoose/schemas/asyncAction");
7
+ const executableTaskProjection = {
8
+ _id: 0,
9
+ id: { $toString: '$_id' },
10
+ // 必要最低限にprojection(2024-04-23~)
11
+ data: 1,
12
+ name: 1,
13
+ status: 1,
14
+ project: 1,
15
+ runsAt: 1,
16
+ expires: 1
17
+ };
18
+ const AVAILABLE_PROJECT_FIELDS = [
19
+ 'project',
20
+ 'name',
21
+ 'status',
22
+ 'runsAt',
23
+ 'lastTriedAt',
24
+ 'executionResults',
25
+ 'executor',
26
+ 'data',
27
+ 'dateAborted',
28
+ 'expires'
29
+ ];
30
+ /**
31
+ * 非同期アクションリポジトリ
32
+ */
33
+ class AsyncActionRepo {
34
+ asyncActionModel;
35
+ constructor(connection) {
36
+ this.asyncActionModel = connection.model(asyncAction_1.modelName, (0, asyncAction_1.createSchema)());
37
+ }
38
+ static CREATE_MONGO_CONDITIONS(params) {
39
+ const andConditions = [];
40
+ const idEq = params.id?.$eq;
41
+ if (typeof idEq === 'string') {
42
+ andConditions.push({ _id: { $eq: idEq } });
43
+ }
44
+ const projectIdEq = params.project?.id?.$eq;
45
+ if (typeof projectIdEq === 'string') {
46
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
47
+ }
48
+ if (typeof params.name === 'string') {
49
+ andConditions.push({ name: { $eq: params.name } });
50
+ }
51
+ else {
52
+ const nameIn = params.name?.$in;
53
+ if (Array.isArray(nameIn)) {
54
+ andConditions.push({ name: { $in: nameIn } });
55
+ }
56
+ const nameNin = params.name?.$nin;
57
+ if (Array.isArray(nameNin)) {
58
+ andConditions.push({ name: { $nin: nameNin } });
59
+ }
60
+ }
61
+ const statusEq = params.status?.$eq;
62
+ if (typeof statusEq === 'string') {
63
+ andConditions.push({ status: { $eq: statusEq } });
64
+ }
65
+ if (params.runsFrom instanceof Date) {
66
+ andConditions.push({ runsAt: { $gte: params.runsFrom } });
67
+ }
68
+ if (params.runsThrough instanceof Date) {
69
+ andConditions.push({ runsAt: { $lte: params.runsThrough } });
70
+ }
71
+ return andConditions;
72
+ }
73
+ async findAsyncActions(params, inclusion) {
74
+ const conditions = AsyncActionRepo.CREATE_MONGO_CONDITIONS(params);
75
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
76
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
77
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
78
+ }
79
+ const projection = {
80
+ _id: 0,
81
+ id: { $toString: '$_id' },
82
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
83
+ };
84
+ const query = this.asyncActionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
85
+ if (typeof params.limit === 'number' && params.limit > 0) {
86
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
87
+ query.limit(params.limit)
88
+ .skip(params.limit * (page - 1));
89
+ }
90
+ if (params.sort?.runsAt !== undefined) {
91
+ query.sort({ runsAt: params.sort.runsAt });
92
+ }
93
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
94
+ .lean()
95
+ .exec();
96
+ }
97
+ /**
98
+ * Readyタスクをひとつ追加する
99
+ */
100
+ async addReadyAsyncAction(params) {
101
+ const { expires } = params;
102
+ if (!(expires instanceof Date)) {
103
+ throw new factory_1.factory.errors.Argument('expires', 'must be Date');
104
+ }
105
+ const savingTask = {
106
+ ...params,
107
+ status: factory_1.factory.taskStatus.Ready,
108
+ executionResults: []
109
+ };
110
+ const result = await this.asyncActionModel.insertMany(savingTask, { rawResult: true });
111
+ const id = result.insertedIds?.[0]?.toHexString();
112
+ if (typeof id !== 'string') {
113
+ throw new factory_1.factory.errors.Internal('task not saved');
114
+ }
115
+ return { id };
116
+ }
117
+ /**
118
+ * Ready -> Running
119
+ */
120
+ async executeAsyncActionById(params) {
121
+ const now = new Date();
122
+ const doc = await this.asyncActionModel.findOneAndUpdate({
123
+ _id: { $eq: params.id },
124
+ status: { $eq: factory_1.factory.taskStatus.Ready }, // Readyのものしか実行しない
125
+ runsAt: { $lt: now },
126
+ expires: { $gt: now }, // ワンタイムタスクなのでexpiresは必ず存在する
127
+ }, {
128
+ $set: {
129
+ status: factory_1.factory.taskStatus.Running, // 実行中に変更
130
+ lastTriedAt: now,
131
+ executor: params.executor
132
+ },
133
+ }, { new: true, projection: executableTaskProjection })
134
+ .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
135
+ .lean() // lean(2024-09-26~)
136
+ .exec();
137
+ if (doc === null) {
138
+ return null;
139
+ }
140
+ return doc;
141
+ }
142
+ /**
143
+ * 非同期アクションの状態を参照する
144
+ */
145
+ async findAsyncActionById(params, inclusion) {
146
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
147
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
148
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
149
+ }
150
+ else {
151
+ // no op
152
+ }
153
+ const projection = {
154
+ _id: 0,
155
+ id: { $toString: '$_id' },
156
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
157
+ };
158
+ const query = this.asyncActionModel.findOne({
159
+ _id: { $eq: params.id.$eq },
160
+ 'project.id': { $eq: params.project.id.$eq },
161
+ name: { $eq: params.name }
162
+ }, projection);
163
+ const doc = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
164
+ .lean()
165
+ .exec();
166
+ if (doc === null) {
167
+ return;
168
+ }
169
+ return doc;
170
+ }
171
+ // /**
172
+ // * Readyのままで期限切れのタスクをExpiredに変更する
173
+ // */
174
+ // public async makeExpiredMany(params: {
175
+ // expiresLt: Date;
176
+ // }): Promise<UpdateWriteOpResult> {
177
+ // const { expiresLt } = params;
178
+ // if (!(expiresLt instanceof Date)) {
179
+ // throw new factory.errors.Argument('expiresLt', 'must be Date');
180
+ // }
181
+ // return this.asyncActionModel.updateMany(
182
+ // {
183
+ // status: { $eq: factory.taskStatus.Ready },
184
+ // expires: { $lt: expiresLt }
185
+ // },
186
+ // {
187
+ // $set: {
188
+ // status: factory.taskStatus.Expired
189
+ // }
190
+ // }
191
+ // )
192
+ // .exec();
193
+ // }
194
+ // /**
195
+ // * taskNameに関わらず、Runningのまま放置された非同期アクションをAbortedに変更する
196
+ // */
197
+ // public async abortMany(params: {
198
+ // intervalInMinutes: number;
199
+ // }): Promise<UpdateWriteOpResult> {
200
+ // const lastTriedAtShoudBeLessThan = moment()
201
+ // .add(-params.intervalInMinutes, 'minutes')
202
+ // .toDate();
203
+ // return this.asyncActionModel.updateMany(
204
+ // {
205
+ // status: { $eq: factory.taskStatus.Running },
206
+ // lastTriedAt: {
207
+ // $exists: true,
208
+ // $lt: lastTriedAtShoudBeLessThan
209
+ // }
210
+ // },
211
+ // {
212
+ // $set: {
213
+ // status: factory.taskStatus.Aborted,
214
+ // dateAborted: new Date()
215
+ // }
216
+ // }
217
+ // )
218
+ // .exec();
219
+ // }
220
+ /**
221
+ * タスクIDから実行結果とステータスを保管する
222
+ * Abortedの場合、dateAbortedもセットする
223
+ */
224
+ async setExecutionResultAndStatus(params, update) {
225
+ const { id } = params;
226
+ const { status, executionResult } = update;
227
+ await this.asyncActionModel.updateOne({ _id: { $eq: id } }, {
228
+ $set: {
229
+ status,
230
+ ...(status === factory_1.factory.taskStatus.Aborted) ? { dateAborted: executionResult.endDate } : undefined // 2025-08-04~
231
+ },
232
+ $push: { executionResults: executionResult }
233
+ })
234
+ .exec();
235
+ }
236
+ }
237
+ exports.AsyncActionRepo = AsyncActionRepo;
@@ -1,5 +1,6 @@
1
- import type { RedisClientType } from 'redis';
1
+ import type { createClient } from 'redis';
2
2
  import { AbstractConcurrentLockRepo, ILockParams, IUnlockParams } from './concurrentLockAbstract';
3
+ type RedisClientType = ReturnType<typeof createClient>;
3
4
  /**
4
5
  * 同時実行ロックリポジトリ
5
6
  */
@@ -12,3 +13,4 @@ export declare class ConcurrentLockRepo implements AbstractConcurrentLockRepo {
12
13
  lock(params: ILockParams): Promise<void>;
13
14
  unlock(params: IUnlockParams): Promise<void>;
14
15
  }
16
+ export {};
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { Connection, FilterQuery, Types } from 'mongoose';
1
+ import { Connection, FilterQuery, Types, mongo } from 'mongoose';
3
2
  import { factory } from '../factory';
4
3
  import { IDocType } from './mongoose/schemas/creativeWork';
5
4
  type IKeyOfProjection = keyof factory.creativeWork.movie.ICreativeWork;
@@ -32,7 +31,7 @@ export declare class CreativeWorkRepo {
32
31
  [key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
33
32
  };
34
33
  }[]): Promise<{
35
- bulkWriteResult?: BulkWriteResult;
34
+ bulkWriteResult?: mongo.BulkWriteResult;
36
35
  }>;
37
36
  /**
38
37
  * コンテンツを検索する
@@ -1,9 +1,10 @@
1
1
  import type { COA } from '@motionpicture/coa-service';
2
- import type { RedisClientType } from 'redis';
2
+ import type { createClient } from 'redis';
3
3
  interface IOptions {
4
4
  scope: string;
5
5
  expireInSeconds: number;
6
6
  }
7
+ type RedisClientType = ReturnType<typeof createClient>;
7
8
  /**
8
9
  * 認証情報リポジトリ
9
10
  */
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { Connection, FilterQuery } from 'mongoose';
1
+ import type { Connection, FilterQuery, mongo } from 'mongoose';
3
2
  import { ICustomerType } from './mongoose/schemas/customerType';
4
3
  import { factory } from '../factory';
5
4
  type IKeyOfProjection = keyof ICustomerType;
@@ -17,6 +16,6 @@ export declare class CustomerTypeRepo {
17
16
  saveManyByCodeValue(params: {
18
17
  attributes: ICustomerType;
19
18
  upsert?: boolean;
20
- }[]): Promise<BulkWriteResult | undefined>;
19
+ }[]): Promise<mongo.BulkWriteResult | undefined>;
21
20
  }
22
21
  export {};
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { Connection, FilterQuery } from 'mongoose';
1
+ import { Connection, FilterQuery, mongo } from 'mongoose';
3
2
  import { factory } from '../factory';
4
3
  import * as EventFactory from '../factory/event';
5
4
  export interface IAttributes4patchUpdate {
@@ -83,7 +82,7 @@ export declare class EventRepo {
83
82
  */
84
83
  update: boolean;
85
84
  }): Promise<{
86
- bulkWriteResult?: BulkWriteResult;
85
+ bulkWriteResult?: mongo.BulkWriteResult;
87
86
  modifiedEvents: {
88
87
  id: string;
89
88
  }[];
@@ -202,7 +201,7 @@ export declare class EventRepo {
202
201
  organizer: {
203
202
  id: string;
204
203
  };
205
- }): Promise<import("mongodb").DeleteResult>;
204
+ }): Promise<mongo.DeleteResult>;
206
205
  deleteManyEventsByScreeningRoom(params: {
207
206
  project: {
208
207
  id: string;
@@ -219,7 +218,7 @@ export declare class EventRepo {
219
218
  id: string;
220
219
  };
221
220
  };
222
- }): Promise<import("mongodb").DeleteResult>;
221
+ }): Promise<mongo.DeleteResult>;
223
222
  deleteManyBySuperEventId(params: {
224
223
  project: {
225
224
  id: string;
@@ -227,7 +226,7 @@ export declare class EventRepo {
227
226
  superEvent: {
228
227
  id: string;
229
228
  };
230
- }): Promise<import("mongodb").DeleteResult>;
229
+ }): Promise<mongo.DeleteResult>;
231
230
  deleteManyBySuperEventLocationId(params: {
232
231
  project: {
233
232
  id: string;
@@ -237,7 +236,7 @@ export declare class EventRepo {
237
236
  id: string;
238
237
  };
239
238
  };
240
- }): Promise<import("mongodb").DeleteResult>;
239
+ }): Promise<mongo.DeleteResult>;
241
240
  /**
242
241
  * 興行(プロダクト)から削除する
243
242
  */
@@ -252,7 +251,7 @@ export declare class EventRepo {
252
251
  };
253
252
  };
254
253
  };
255
- }): Promise<import("mongodb").DeleteResult>;
254
+ }): Promise<mongo.DeleteResult>;
256
255
  deleteManyEventsEndedByProject(params: {
257
256
  typeOf: {
258
257
  $in: factory.eventType.ScreeningEvent[];
@@ -263,7 +262,7 @@ export declare class EventRepo {
263
262
  endDate: {
264
263
  $lte: Date;
265
264
  };
266
- }): Promise<import("mongodb").DeleteResult>;
265
+ }): Promise<mongo.DeleteResult>;
267
266
  deleteManyEventsEnded(params: {
268
267
  typeOf: {
269
268
  $eq: factory.eventType.ScreeningEvent;
@@ -271,7 +270,7 @@ export declare class EventRepo {
271
270
  endDate: {
272
271
  $lte: Date;
273
272
  };
274
- }): Promise<import("mongodb").DeleteResult>;
273
+ }): Promise<mongo.DeleteResult>;
275
274
  deleteByProject(params: {
276
275
  project: {
277
276
  id: string;
@@ -283,7 +282,7 @@ export declare class EventRepo {
283
282
  updateAggregationById(params: {
284
283
  id: string;
285
284
  }, update: IUpdateAggregateReservationParams): Promise<void>;
286
- bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteResult & {
285
+ bulkWrite(bulkWriteOps: any[]): Promise<mongo.BulkWriteResult & {
287
286
  mongoose?: {
288
287
  validationErrors: import("mongoose").Error[];
289
288
  } | undefined;
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult, DeleteResult } from 'mongodb';
2
- import { Connection, FilterQuery } from 'mongoose';
1
+ import type { Connection, FilterQuery, mongo } from 'mongoose';
3
2
  import { factory } from '../factory';
4
3
  import { IDocType } from './mongoose/schemas/eventOffer';
5
4
  type IUnset = {
@@ -32,7 +31,7 @@ export declare class EventOfferRepo {
32
31
  */
33
32
  update: boolean;
34
33
  }): Promise<{
35
- bulkWriteResult?: BulkWriteResult;
34
+ bulkWriteResult?: mongo.BulkWriteResult;
36
35
  modifiedProductOffers?: {
37
36
  id: string;
38
37
  }[];
@@ -47,7 +46,7 @@ export declare class EventOfferRepo {
47
46
  seller: {
48
47
  id: string;
49
48
  };
50
- }): Promise<DeleteResult>;
49
+ }): Promise<mongo.DeleteResult>;
51
50
  /**
52
51
  * 有効期間を過ぎたイベントオファーを削除する
53
52
  */
@@ -55,6 +54,6 @@ export declare class EventOfferRepo {
55
54
  validThrough: {
56
55
  $lte: Date;
57
56
  };
58
- }): Promise<DeleteResult>;
57
+ }): Promise<mongo.DeleteResult>;
59
58
  }
60
59
  export {};
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection } from 'mongoose';
1
+ import type { Connection, mongo } from 'mongoose';
3
2
  import { factory } from '../factory';
4
3
  /**
5
4
  * イベントのアプリケーションオファーリポジトリ
@@ -31,7 +30,7 @@ export declare class EventSellerMakesOfferRepo {
31
30
  };
32
31
  };
33
32
  }[]): Promise<{
34
- bulkWriteResult?: BulkWriteResult;
33
+ bulkWriteResult?: mongo.BulkWriteResult;
35
34
  modifiedEvents?: {
36
35
  id: string;
37
36
  }[];
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection, FilterQuery } from 'mongoose';
1
+ import type { Connection, FilterQuery, mongo } from 'mongoose';
3
2
  import { factory } from '../factory';
4
3
  type ISearchConditions = factory.eventSeries.ISearchConditions;
5
4
  type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id' | 'videoFormat'>;
@@ -26,7 +25,7 @@ export declare class EventSeriesRepo {
26
25
  */
27
26
  upsert: boolean;
28
27
  }): Promise<{
29
- bulkWriteResult?: BulkWriteResult;
28
+ bulkWriteResult?: mongo.BulkWriteResult;
30
29
  modifiedEvents: {
31
30
  id: string;
32
31
  }[];
@@ -55,7 +54,7 @@ export declare class EventSeriesRepo {
55
54
  organizer: {
56
55
  id: string;
57
56
  };
58
- }): Promise<import("mongodb").DeleteResult>;
57
+ }): Promise<mongo.DeleteResult>;
59
58
  deleteManyByLocationId(params: {
60
59
  project: {
61
60
  id: string;
@@ -63,7 +62,7 @@ export declare class EventSeriesRepo {
63
62
  location: {
64
63
  id: string;
65
64
  };
66
- }): Promise<import("mongodb").DeleteResult>;
65
+ }): Promise<mongo.DeleteResult>;
67
66
  /**
68
67
  * 既存施設コンテンツの最大バージョンを集計する
69
68
  */
@@ -43,7 +43,7 @@ export declare class MessageRepo {
43
43
  /**
44
44
  * 検索
45
45
  */
46
- projectFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(IEmailMessage & {
46
+ findMessages(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(IEmailMessage & {
47
47
  id: string;
48
48
  })[]>;
49
49
  /**
@@ -53,7 +53,7 @@ class MessageRepo {
53
53
  /**
54
54
  * 検索
55
55
  */
56
- async projectFields(params, inclusion) {
56
+ async findMessages(params, inclusion) {
57
57
  const conditions = MessageRepo.CREATE_MONGO_CONDITIONS(params);
58
58
  let positiveProjectionFields;
59
59
  if (Array.isArray(inclusion) && inclusion.length > 0) {
@@ -0,0 +1,13 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import { IVirtuals } from '../virtuals';
3
+ import { factory } from '../../../factory';
4
+ type IDocType = Pick<factory.task.ITask<factory.taskName>, 'data' | 'dateAborted' | 'executionResults' | 'executor' | 'lastTriedAt' | 'name' | 'project' | 'runsAt' | 'status'> & {
5
+ expires: Date;
6
+ };
7
+ type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
8
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
9
+ type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
10
+ declare const modelName = "AsyncAction";
11
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
12
+ declare function createSchema(): ISchema;
13
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../writeConcern");
7
+ const settings_1 = require("../../../settings");
8
+ const modelName = 'AsyncAction';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ name: { type: String, required: true },
13
+ status: { type: String, required: true },
14
+ runsAt: { type: Date, required: true },
15
+ expires: { type: Date, required: true },
16
+ lastTriedAt: Date,
17
+ executionResults: [mongoose_1.SchemaTypes.Mixed],
18
+ executor: mongoose_1.SchemaTypes.Mixed,
19
+ data: mongoose_1.SchemaTypes.Mixed,
20
+ dateAborted: Date,
21
+ // remainingNumberOfTries: { type: Number, required: true }, // ワンタイム前提につき不要
22
+ // numberOfTried: { type: Number, required: true }, // ワンタイム前提につき不要
23
+ };
24
+ const schemaOptions = {
25
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
26
+ autoCreate: false,
27
+ collection: 'asyncActions',
28
+ id: true,
29
+ read: 'primary',
30
+ writeConcern: writeConcern_1.writeConcern,
31
+ strict: true,
32
+ strictQuery: false,
33
+ timestamps: false,
34
+ versionKey: false,
35
+ toJSON: {
36
+ getters: false,
37
+ virtuals: false,
38
+ minimize: false,
39
+ versionKey: false
40
+ },
41
+ toObject: {
42
+ getters: false,
43
+ virtuals: true,
44
+ minimize: false,
45
+ versionKey: false
46
+ }
47
+ };
48
+ const EXPIRE_AFTER_SECONDS = 3600; // 1 hour
49
+ const indexes = [
50
+ [
51
+ { expires: 1 },
52
+ {
53
+ name: 'ttlByExpires',
54
+ expireAfterSeconds: EXPIRE_AFTER_SECONDS
55
+ }
56
+ ],
57
+ [
58
+ { runsAt: -1 },
59
+ { name: 'runsAt' }
60
+ ],
61
+ [
62
+ { 'project.id': 1, runsAt: -1 },
63
+ { name: 'projectId' }
64
+ ],
65
+ [
66
+ { name: 1, runsAt: -1 },
67
+ { name: 'asyncActionName' }
68
+ ],
69
+ [
70
+ { status: 1, runsAt: -1 },
71
+ { name: 'status' }
72
+ ],
73
+ ];
74
+ exports.indexes = indexes;
75
+ /**
76
+ * 非同期アクションスキーマ
77
+ */
78
+ let schema;
79
+ function createSchema() {
80
+ if (schema === undefined) {
81
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
82
+ if (settings_1.MONGO_AUTO_INDEX) {
83
+ indexes.forEach((indexParams) => {
84
+ schema?.index(...indexParams);
85
+ });
86
+ }
87
+ }
88
+ return schema;
89
+ }
@@ -7,6 +7,10 @@ type IDocType = Omit<factory.order.IOrder, 'id'> & {
7
7
  * 注文取引IDとして再定義(2026-06-22~)
8
8
  */
9
9
  identifier?: string;
10
+ /**
11
+ * 外部URL決済の場合に発行される決済方法IDとして定義(2026-07-12~)
12
+ */
13
+ paymentMethodId?: string;
10
14
  };
11
15
  type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
12
16
  type ISchemaDefinition = SchemaDefinition<IDocType>;