@chevre/domain 26.0.0-alpha.4 → 26.0.0-alpha.41

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 (246) 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 +3 -1
  6. package/lib/chevre/repo/action/acceptCOAOffer.js +8 -2
  7. package/lib/chevre/repo/action/acceptPay.d.ts +3 -1
  8. package/lib/chevre/repo/action/acceptPay.js +8 -4
  9. package/lib/chevre/repo/action/{actionProcess.d.ts → anyAction/actionProcess.d.ts} +18 -45
  10. package/lib/chevre/repo/action/{actionProcess.js → anyAction/actionProcess.js} +26 -91
  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 +7 -4
  15. package/lib/chevre/repo/action/authorizeOffer.d.ts +3 -1
  16. package/lib/chevre/repo/action/authorizeOffer.js +7 -2
  17. package/lib/chevre/repo/action/authorizePaymentMethod.d.ts +3 -1
  18. package/lib/chevre/repo/action/authorizePaymentMethod.js +7 -4
  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/checkMovieTicket.d.ts +3 -1
  22. package/lib/chevre/repo/action/checkMovieTicket.js +8 -1
  23. package/lib/chevre/repo/action/create.d.ts +10 -0
  24. package/lib/chevre/repo/action/create.js +17 -0
  25. package/lib/chevre/repo/action/inform.d.ts +38 -0
  26. package/lib/chevre/repo/action/inform.js +146 -0
  27. package/lib/chevre/repo/action/pay.d.ts +3 -1
  28. package/lib/chevre/repo/action/pay.js +7 -4
  29. package/lib/chevre/repo/action/refund.d.ts +3 -1
  30. package/lib/chevre/repo/action/refund.js +7 -4
  31. package/lib/chevre/repo/action/sendEmailMessage.d.ts +10 -0
  32. package/lib/chevre/repo/action/sendEmailMessage.js +17 -0
  33. package/lib/chevre/repo/action/sendOrder.d.ts +10 -0
  34. package/lib/chevre/repo/action/sendOrder.js +16 -0
  35. package/lib/chevre/repo/action/unknown2actionError.d.ts +6 -0
  36. package/lib/chevre/repo/action/unknown2actionError.js +15 -0
  37. package/lib/chevre/repo/action/update.d.ts +48 -0
  38. package/lib/chevre/repo/action/update.js +166 -0
  39. package/lib/chevre/repo/action/use.d.ts +39 -0
  40. package/lib/chevre/repo/action/use.js +153 -0
  41. package/lib/chevre/repo/action.d.ts +5 -101
  42. package/lib/chevre/repo/action.js +7 -453
  43. package/lib/chevre/repo/adminAction.d.ts +87 -0
  44. package/lib/chevre/repo/adminAction.js +170 -0
  45. package/lib/chevre/repo/adminAssetTransaction.d.ts +126 -0
  46. package/lib/chevre/repo/adminAssetTransaction.js +491 -0
  47. package/lib/chevre/repo/adminAsyncAction.d.ts +2 -2
  48. package/lib/chevre/repo/adminScheduledTask.d.ts +1 -1
  49. package/lib/chevre/repo/adminTask.d.ts +25 -8
  50. package/lib/chevre/repo/adminTask.js +31 -32
  51. package/lib/chevre/repo/adminTransaction.d.ts +131 -0
  52. package/lib/chevre/repo/adminTransaction.js +237 -0
  53. package/lib/chevre/repo/aggregateAction.d.ts +8 -11
  54. package/lib/chevre/repo/aggregateAction.js +0 -61
  55. package/lib/chevre/repo/aggregateAssetTransaction.d.ts +43 -0
  56. package/lib/chevre/repo/aggregateAssetTransaction.js +166 -0
  57. package/lib/chevre/repo/aggregateTransaction.d.ts +39 -0
  58. package/lib/chevre/repo/aggregateTransaction.js +166 -0
  59. package/lib/chevre/repo/aggregateUseAction.d.ts +35 -0
  60. package/lib/chevre/repo/aggregateUseAction.js +164 -0
  61. package/lib/chevre/repo/aggregation.d.ts +0 -8
  62. package/lib/chevre/repo/aggregation.js +0 -10
  63. package/lib/chevre/repo/assetTransaction.d.ts +10 -235
  64. package/lib/chevre/repo/assetTransaction.js +48 -636
  65. package/lib/chevre/repo/asyncAction.d.ts +2 -2
  66. package/lib/chevre/repo/authorization.d.ts +0 -6
  67. package/lib/chevre/repo/authorization.js +15 -27
  68. package/lib/chevre/repo/message.d.ts +0 -7
  69. package/lib/chevre/repo/message.js +0 -38
  70. package/lib/chevre/repo/migrateAction.d.ts +48 -0
  71. package/lib/chevre/repo/migrateAction.js +32 -0
  72. package/lib/chevre/repo/mongoose/schemas/action/inform.d.ts +11 -0
  73. package/lib/chevre/repo/mongoose/schemas/action/inform.js +82 -0
  74. package/lib/chevre/repo/mongoose/schemas/action/update.d.ts +12 -0
  75. package/lib/chevre/repo/mongoose/schemas/action/update.js +112 -0
  76. package/lib/chevre/repo/mongoose/schemas/{ownershipInfo.d.ts → action/use.d.ts} +4 -6
  77. package/lib/chevre/repo/mongoose/schemas/action/use.js +92 -0
  78. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -3
  79. package/lib/chevre/repo/mongoose/schemas/action.js +22 -7
  80. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +19 -1
  82. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +8 -9
  83. package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
  84. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +95 -76
  85. package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
  86. package/lib/chevre/repo/mongoose/schemas/event.js +7 -0
  87. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +7 -0
  88. package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
  89. package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +11 -4
  90. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +1 -0
  91. package/lib/chevre/repo/mongoose/schemas/task.d.ts +2 -5
  92. package/lib/chevre/repo/mongoose/schemas/task.js +134 -118
  93. package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
  94. package/lib/chevre/repo/orderInTransaction.d.ts +0 -3
  95. package/lib/chevre/repo/orderInTransaction.js +30 -22
  96. package/lib/chevre/repo/scheduledTask.d.ts +5 -2
  97. package/lib/chevre/repo/scheduledTask.js +3 -25
  98. package/lib/chevre/repo/task.d.ts +45 -171
  99. package/lib/chevre/repo/task.js +20 -475
  100. package/lib/chevre/repo/taskDelayed.d.ts +74 -0
  101. package/lib/chevre/repo/taskDelayed.js +195 -0
  102. package/lib/chevre/repo/taskRunning.d.ts +35 -0
  103. package/lib/chevre/repo/taskRunning.js +89 -0
  104. package/lib/chevre/repo/ticket.d.ts +0 -6
  105. package/lib/chevre/repo/ticket.js +0 -11
  106. package/lib/chevre/repo/transaction.d.ts +1 -187
  107. package/lib/chevre/repo/transaction.js +2 -383
  108. package/lib/chevre/repository.d.ts +50 -10
  109. package/lib/chevre/repository.js +112 -24
  110. package/lib/chevre/service/aggregation/system.d.ts +9 -8
  111. package/lib/chevre/service/aggregation/system.js +5 -5
  112. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +10 -17
  113. package/lib/chevre/service/assetTransaction/refund.js +2 -2
  114. package/lib/chevre/service/asyncAction.d.ts +2 -2
  115. package/lib/chevre/service/asyncAction.js +1 -4
  116. package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +2 -2
  117. package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +0 -2
  118. package/lib/chevre/service/asyncActionHandler.d.ts +4 -4
  119. package/lib/chevre/service/asyncActionHandler.js +11 -13
  120. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +4 -2
  121. package/lib/chevre/service/event/processUpdateMovieTheater.js +3 -3
  122. package/lib/chevre/service/event.d.ts +4 -2
  123. package/lib/chevre/service/event.js +3 -3
  124. package/lib/chevre/service/notification/sendEmailMessage.d.ts +4 -2
  125. package/lib/chevre/service/notification/sendEmailMessage.js +3 -3
  126. package/lib/chevre/service/notification/triggerWebhook.d.ts +4 -2
  127. package/lib/chevre/service/notification/triggerWebhook.js +5 -16
  128. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -3
  129. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +0 -4
  130. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +19 -19
  131. package/lib/chevre/service/offer/onEventChanged.js +0 -2
  132. package/lib/chevre/service/order/confirmPayTransaction.js +4 -1
  133. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -1
  134. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +2 -56
  135. package/lib/chevre/service/order/deleteOrder.d.ts +2 -2
  136. package/lib/chevre/service/order/deleteOrder.js +1 -2
  137. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +1 -49
  138. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +2 -2
  139. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +2 -4
  140. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +2 -4
  141. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +4 -4
  142. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  143. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +2 -10
  144. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
  145. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +4 -8
  146. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -2
  147. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  148. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +5 -11
  149. package/lib/chevre/service/order/onOrderUpdated/factory.js +0 -3
  150. package/lib/chevre/service/order/returnOrder.d.ts +0 -2
  151. package/lib/chevre/service/order/returnOrder.js +8 -40
  152. package/lib/chevre/service/order/sendOrder.d.ts +4 -6
  153. package/lib/chevre/service/order/sendOrder.js +30 -72
  154. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +0 -4
  155. package/lib/chevre/service/payment/any/findAcceptAction.js +19 -19
  156. package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +0 -4
  157. package/lib/chevre/service/payment/any/findAuthorizeAction.js +19 -19
  158. package/lib/chevre/service/payment/any/findCheckAction.d.ts +0 -4
  159. package/lib/chevre/service/payment/any/findCheckAction.js +19 -19
  160. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +1 -1
  161. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -2
  162. package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -2
  163. package/lib/chevre/service/project.d.ts +0 -6
  164. package/lib/chevre/service/project.js +0 -2
  165. package/lib/chevre/service/reserve/cancelReservation.js +3 -3
  166. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  167. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  168. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -2
  169. package/lib/chevre/service/reserve/useReservation.d.ts +4 -0
  170. package/lib/chevre/service/reserve/useReservation.js +6 -24
  171. package/lib/chevre/service/scheduledTask.d.ts +1 -4
  172. package/lib/chevre/service/scheduledTask.js +3 -10
  173. package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +1 -2
  174. package/lib/chevre/service/scheduledTaskHandler.js +0 -13
  175. package/lib/chevre/service/task/acceptCOAOffer.js +1 -14
  176. package/lib/chevre/service/task/authorizePayment.js +1 -7
  177. package/lib/chevre/service/task/checkMovieTicket.js +1 -7
  178. package/lib/chevre/service/task/checkResource.js +14 -57
  179. package/lib/chevre/service/task/confirmReserveTransaction.js +3 -1
  180. package/lib/chevre/service/task/createAccountingReport.js +8 -15
  181. package/lib/chevre/service/task/deleteTransaction.js +10 -41
  182. package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
  183. package/lib/chevre/service/task/onAuthorizationCreated.js +2 -2
  184. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +4 -2
  185. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +4 -4
  186. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +4 -2
  187. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +4 -4
  188. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +4 -2
  189. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +4 -4
  190. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +4 -2
  191. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +4 -4
  192. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +4 -2
  193. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +4 -4
  194. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +4 -2
  195. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +4 -4
  196. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +4 -2
  197. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +4 -4
  198. package/lib/chevre/service/task/onResourceDeleted.js +4 -3
  199. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +0 -1
  200. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
  201. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +0 -1
  202. package/lib/chevre/service/task/onResourceUpdated.js +0 -8
  203. package/lib/chevre/service/task/publishPaymentUrl.js +2 -13
  204. package/lib/chevre/service/task/returnOrder.js +2 -5
  205. package/lib/chevre/service/task/returnPayTransaction.js +2 -5
  206. package/lib/chevre/service/task/sendEmailMessage.js +2 -2
  207. package/lib/chevre/service/task/sendOrder.js +4 -8
  208. package/lib/chevre/service/task/syncResourcesFromCOA.js +31 -23
  209. package/lib/chevre/service/task/triggerWebhook.js +4 -2
  210. package/lib/chevre/service/task/useReservation.js +4 -0
  211. package/lib/chevre/service/task/voidReserveTransaction.js +5 -8
  212. package/lib/chevre/service/task.d.ts +3 -22
  213. package/lib/chevre/service/task.js +8 -40
  214. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +0 -1
  215. package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +3 -2
  216. package/lib/chevre/service/taskHandler/onOperationFailed.js +5 -16
  217. package/lib/chevre/service/taskHandler.d.ts +1 -2
  218. package/lib/chevre/service/taskHandler.js +7 -19
  219. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +2 -2
  220. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +2 -2
  221. package/lib/chevre/service/transaction/deleteTransaction.d.ts +8 -4
  222. package/lib/chevre/service/transaction/deleteTransaction.js +7 -7
  223. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  224. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +8 -4
  225. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +55 -103
  226. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -0
  227. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +14 -10
  228. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +13 -3
  229. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +48 -51
  230. package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
  231. package/lib/chevre/service/transaction/returnOrder.js +15 -13
  232. package/lib/chevre/service/transaction.d.ts +2 -0
  233. package/lib/chevre/service/transaction.js +0 -2
  234. package/lib/chevre/service/validation/validateOrder.d.ts +0 -4
  235. package/lib/chevre/service/validation/validateOrder.js +3 -3
  236. package/lib/chevre/taskSettings.d.ts +4 -4
  237. package/package.json +2 -2
  238. package/lib/chevre/repo/action/checkThing.d.ts +0 -8
  239. package/lib/chevre/repo/action/checkThing.js +0 -13
  240. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -227
  241. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.d.ts +0 -25
  242. package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +0 -100
  243. package/lib/chevre/repo/ownershipInfo.d.ts +0 -122
  244. package/lib/chevre/repo/ownershipInfo.js +0 -466
  245. package/lib/chevre/service/validation/validateEvent.d.ts +0 -11
  246. package/lib/chevre/service/validation/validateEvent.js +0 -21
@@ -1,48 +1,16 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.TransactionRepo = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const transaction_1 = require("../eventEmitter/transaction");
9
4
  const factory_1 = require("../factory");
10
5
  const settings_1 = require("../settings");
11
- const transaction_2 = require("./mongoose/schemas/transaction");
6
+ const transaction_1 = require("./mongoose/schemas/transaction");
12
7
  /**
13
8
  * 取引リポジトリ
14
9
  */
15
10
  class TransactionRepo {
16
11
  transactionModel;
17
12
  constructor(connection) {
18
- this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
19
- }
20
- async countPotentiallyExportTasks(params) {
21
- const { endDate, limit } = params;
22
- const endDateLt = endDate?.$lt;
23
- if (!(endDateLt instanceof Date)) {
24
- throw new factory_1.factory.errors.Argument('endDate.$lt', 'must be Date');
25
- }
26
- const query = this.transactionModel.countDocuments({
27
- status: {
28
- $in: [
29
- factory_1.factory.transactionStatusType.Canceled,
30
- factory_1.factory.transactionStatusType.Confirmed,
31
- factory_1.factory.transactionStatusType.Expired
32
- ]
33
- },
34
- 'tasksExportAction.actionStatus': {
35
- $exists: true,
36
- $eq: factory_1.factory.actionStatusType.PotentialActionStatus
37
- },
38
- endDate: { $exists: true, $lt: endDateLt }
39
- });
40
- if (typeof limit === 'number' && limit >= 0) {
41
- query.limit(limit);
42
- }
43
- const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
44
- .exec();
45
- return { count };
13
+ this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
46
14
  }
47
15
  /**
48
16
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
@@ -101,72 +69,6 @@ class TransactionRepo {
101
69
  .exec()
102
70
  .then((doc) => (doc === null) ? null : doc);
103
71
  }
104
- /**
105
- * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
106
- * PotentialActionStatusに変更する
107
- * 2025-03-10~
108
- */
109
- async reExportAction(params) {
110
- const { startDate } = params;
111
- if (!(startDate.$lt instanceof Date)) {
112
- throw new factory_1.factory.errors.Argument('startDate.$lt', 'must be Date');
113
- }
114
- return this.transactionModel.updateMany({
115
- 'tasksExportAction.actionStatus': {
116
- $exists: true,
117
- $eq: factory_1.factory.actionStatusType.ActiveActionStatus
118
- },
119
- 'tasksExportAction.startDate': {
120
- $exists: true,
121
- $lt: startDate.$lt
122
- }
123
- }, {
124
- $set: {
125
- tasksExportAction: {
126
- actionStatus: factory_1.factory.actionStatusType.PotentialActionStatus
127
- }
128
- }
129
- })
130
- .exec();
131
- }
132
- /**
133
- * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
134
- */
135
- async exportTasksMany(params) {
136
- const delayedTransactions = await this.transactionModel.find({
137
- status: { $in: params.status.$in },
138
- 'tasksExportAction.actionStatus': {
139
- $exists: true,
140
- $eq: factory_1.factory.actionStatusType.PotentialActionStatus
141
- },
142
- endDate: {
143
- $exists: true,
144
- $lt: (0, moment_1.default)(params.now)
145
- .add(-params.delayInSeconds, 'seconds')
146
- .toDate()
147
- }
148
- })
149
- .select({
150
- _id: 0,
151
- id: { $toString: '$_id' },
152
- typeOf: 1,
153
- status: 1
154
- })
155
- .limit(params.limit)
156
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
157
- .lean()
158
- .exec();
159
- if (delayedTransactions.length > 0) {
160
- delayedTransactions.forEach((delayedTransaction) => {
161
- transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
162
- id: delayedTransaction.id,
163
- typeOf: delayedTransaction.typeOf,
164
- status: delayedTransaction.status
165
- });
166
- });
167
- }
168
- return delayedTransactions;
169
- }
170
72
  /**
171
73
  * set task status exported by transaction id
172
74
  * IDでタスクをエクスポート済に変更する
@@ -189,288 +91,5 @@ class TransactionRepo {
189
91
  })
190
92
  .exec();
191
93
  }
192
- /**
193
- * add(2025-03-13~)
194
- */
195
- async countPotentiallyExpired(params) {
196
- const { expires, limit } = params;
197
- const query = this.transactionModel.countDocuments({
198
- status: { $eq: factory_1.factory.transactionStatusType.InProgress },
199
- expires: { $lt: expires.$lt }
200
- });
201
- if (typeof limit === 'number' && limit >= 0) {
202
- query.limit(limit);
203
- }
204
- const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
205
- .exec();
206
- return { count };
207
- }
208
- /**
209
- * add(2025-03-03~)
210
- */
211
- async makeOneExpiredIfExists(params) {
212
- const endDate = new Date();
213
- const sort = {
214
- expires: factory_1.factory.sortType.Ascending
215
- };
216
- const doc = await this.transactionModel.findOneAndUpdate({
217
- status: { $eq: factory_1.factory.transactionStatusType.InProgress },
218
- expires: { $lt: params.expires.$lt }
219
- }, {
220
- status: factory_1.factory.transactionStatusType.Expired,
221
- endDate
222
- }, {
223
- new: true,
224
- projection: {
225
- _id: 0,
226
- id: { $toString: '$_id' },
227
- typeOf: 1
228
- }
229
- })
230
- .sort(sort)
231
- .lean()
232
- .exec();
233
- if (doc === null) {
234
- // no op
235
- return;
236
- }
237
- else {
238
- transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
239
- id: doc.id,
240
- typeOf: doc.typeOf,
241
- status: factory_1.factory.transactionStatusType.Expired
242
- });
243
- return doc;
244
- }
245
- }
246
- /**
247
- * 取引を期限切れにする
248
- */
249
- async makeExpired(params) {
250
- if (typeof params.limit !== 'number' || params.limit === 0) {
251
- throw new factory_1.factory.errors.ArgumentNull('limit');
252
- }
253
- const sort = {
254
- expires: factory_1.factory.sortType.Ascending
255
- };
256
- // IDをemitしたいのでまずリスト検索(2023-04-27~)
257
- const expiringTransactions = await this.transactionModel.find({
258
- status: { $eq: factory_1.factory.transactionStatusType.InProgress },
259
- expires: { $lt: params.expires.$lt }
260
- })
261
- .select({
262
- _id: 0,
263
- id: { $toString: '$_id' },
264
- typeOf: 1
265
- })
266
- .limit(params.limit)
267
- .sort(sort) // sort(2025-03-03~)
268
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
269
- .lean()
270
- .exec();
271
- if (expiringTransactions.length > 0) {
272
- // ステータスと期限を見て更新
273
- await this.transactionModel.updateMany({
274
- _id: { $in: expiringTransactions.map((t) => t.id) },
275
- status: { $eq: factory_1.factory.transactionStatusType.InProgress },
276
- expires: { $lt: params.expires.$lt }
277
- }, {
278
- status: factory_1.factory.transactionStatusType.Expired,
279
- endDate: new Date()
280
- })
281
- .exec();
282
- expiringTransactions.forEach((expiringTransaction) => {
283
- transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
284
- id: expiringTransaction.id,
285
- typeOf: expiringTransaction.typeOf,
286
- status: factory_1.factory.transactionStatusType.Expired
287
- });
288
- });
289
- }
290
- return expiringTransactions;
291
- }
292
- async findByIdAndDelete(params) {
293
- await this.transactionModel.findByIdAndDelete(params.id)
294
- .exec();
295
- }
296
- async unsetUnnecessaryFields(params) {
297
- return this.transactionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
298
- .exec();
299
- }
300
- async updateById4migration(params) {
301
- return this.transactionModel.updateOne({ _id: { $eq: params.id } }, params.update)
302
- .exec();
303
- }
304
- /**
305
- * 終了日時を一定期間過ぎたアクションを削除する
306
- */
307
- async deleteEndDatePassedCertainPeriod(params) {
308
- return this.transactionModel.deleteMany({
309
- typeOf: { $eq: params.typeOf },
310
- // 終了日時を一定期間過ぎたもの
311
- endDate: {
312
- $exists: true,
313
- $gte: params.endDate.$gte,
314
- $lt: params.endDate.$lt
315
- }
316
- })
317
- .exec();
318
- }
319
- getCursor(conditions, projection, sort) {
320
- return this.transactionModel.find(conditions, projection)
321
- .sort({ startDate: (sort === factory_1.factory.sortType.Ascending) ? sort : factory_1.factory.sortType.Descending })
322
- .cursor();
323
- }
324
- async aggregatePlaceOrder(params) {
325
- const statuses = await Promise.all([
326
- factory_1.factory.transactionStatusType.Confirmed,
327
- factory_1.factory.transactionStatusType.Canceled,
328
- factory_1.factory.transactionStatusType.Expired
329
- ].map(async (transactionStatus) => {
330
- const matchConditions = {
331
- startDate: {
332
- $gte: params.startFrom,
333
- $lte: params.startThrough
334
- },
335
- typeOf: { $eq: params.typeOf },
336
- status: { $eq: transactionStatus },
337
- ...(typeof params.project?.id?.$ne === 'string')
338
- ? { 'project.id': { $ne: params.project.id.$ne } }
339
- : undefined,
340
- ...(typeof params.clientId === 'string')
341
- // customerIdentifierAll.push();
342
- ? {
343
- 'agent.identifier': {
344
- $exists: true,
345
- $all: [{ name: 'clientId', value: params.clientId }]
346
- }
347
- }
348
- : undefined
349
- };
350
- return this.agggregateByStatus({ matchConditions, status: transactionStatus });
351
- }));
352
- return { statuses };
353
- }
354
- async agggregateByStatus(params) {
355
- const matchConditions = params.matchConditions;
356
- const transactionStatus = params.status;
357
- const aggregations = await this.transactionModel.aggregate([
358
- {
359
- $match: matchConditions
360
- },
361
- {
362
- $project: {
363
- duration: { $subtract: ['$endDate', '$startDate'] },
364
- status: '$status',
365
- startDate: '$startDate',
366
- endDate: '$endDate',
367
- typeOf: '$typeOf'
368
- }
369
- },
370
- {
371
- $group: {
372
- _id: '$typeOf',
373
- transactionCount: { $sum: 1 },
374
- maxDuration: { $max: '$duration' },
375
- minDuration: { $min: '$duration' },
376
- avgDuration: { $avg: '$duration' }
377
- }
378
- },
379
- {
380
- $project: {
381
- _id: 0,
382
- transactionCount: '$transactionCount',
383
- avgDuration: '$avgDuration',
384
- maxDuration: '$maxDuration',
385
- minDuration: '$minDuration'
386
- }
387
- }
388
- ])
389
- .exec();
390
- const percents = [50, 95, 99];
391
- if (aggregations.length === 0) {
392
- return {
393
- status: transactionStatus,
394
- aggregation: {
395
- transactionCount: 0,
396
- avgDuration: 0,
397
- maxDuration: 0,
398
- minDuration: 0,
399
- percentilesDuration: percents.map((percent) => {
400
- return {
401
- name: String(percent),
402
- value: 0
403
- };
404
- })
405
- // totalPrice: 0,
406
- // maxPrice: 0,
407
- // minPrice: 0,
408
- // avgPrice: 0
409
- }
410
- };
411
- }
412
- const ranks4percentile = percents.map((percentile) => {
413
- return {
414
- percentile,
415
- rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
416
- };
417
- });
418
- const aggregations2 = await this.transactionModel.aggregate([
419
- {
420
- $match: matchConditions
421
- },
422
- {
423
- $project: {
424
- duration: { $subtract: ['$endDate', '$startDate'] },
425
- status: '$status',
426
- startDate: '$startDate',
427
- endDate: '$endDate',
428
- typeOf: '$typeOf'
429
- // result: '$result',
430
- // price: {
431
- // $cond: {
432
- // if: { $isNumber: '$result.order.price' },
433
- // then: '$result.order.price',
434
- // else: 0
435
- // }
436
- // }
437
- }
438
- },
439
- { $sort: { duration: 1 } },
440
- {
441
- $group: {
442
- _id: '$typeOf',
443
- durations: { $push: '$duration' }
444
- // totalPrice: { $sum: '$price' },
445
- // maxPrice: { $max: '$price' },
446
- // minPrice: { $min: '$price' },
447
- // avgPrice: { $avg: '$price' }
448
- }
449
- },
450
- {
451
- $project: {
452
- _id: 0,
453
- percentilesDuration: ranks4percentile.map((rank) => {
454
- return {
455
- name: String(rank.percentile),
456
- value: { $arrayElemAt: ['$durations', rank.rank] }
457
- };
458
- })
459
- // totalPrice: '$totalPrice',
460
- // maxPrice: '$maxPrice',
461
- // minPrice: '$minPrice',
462
- // avgPrice: '$avgPrice'
463
- }
464
- }
465
- ])
466
- .exec();
467
- return {
468
- status: transactionStatus,
469
- aggregation: {
470
- ...aggregations[0],
471
- ...aggregations2[0]
472
- }
473
- };
474
- }
475
94
  }
476
95
  exports.TransactionRepo = TransactionRepo;
@@ -12,20 +12,28 @@ import type { AuthorizeOfferActionRepo } from './repo/action/authorizeOffer';
12
12
  import type { AuthorizePaymentMethodActionRepo } from './repo/action/authorizePaymentMethod';
13
13
  import type { AuthorizeTicketedObjectActionRepo } from './repo/action/authorizeTicketedObject';
14
14
  import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
15
- import type { CheckThingActionRepo } from './repo/action/checkThing';
15
+ import type { InformActionRepo } from './repo/action/inform';
16
16
  import type { PayActionRepo } from './repo/action/pay';
17
17
  import type { RefundActionRepo } from './repo/action/refund';
18
+ import type { UpdateActionRepo } from './repo/action/update';
19
+ import type { UseActionRepo } from './repo/action/use';
18
20
  import type { AsyncActionRepo } from './repo/asyncAction';
19
21
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
22
+ import type { AdminActionRepo } from './repo/adminAction';
23
+ import type { AdminAssetTransactionRepo } from './repo/adminAssetTransaction';
20
24
  import type { AdminAsyncActionRepo } from './repo/adminAsyncAction';
21
25
  import type { AdminScheduledTaskRepo } from './repo/adminScheduledTask';
22
26
  import type { AdminTaskRepo } from './repo/adminTask';
27
+ import type { AdminTransactionRepo } from './repo/adminTransaction';
23
28
  import type { AggregateActionRepo } from './repo/aggregateAction';
29
+ import type { AggregateUseActionRepo } from './repo/aggregateUseAction';
30
+ import type { AggregateAssetTransactionRepo } from './repo/aggregateAssetTransaction';
24
31
  import type { AggregateOfferRepo } from './repo/aggregateOffer';
25
32
  import type { AggregateOrderRepo } from './repo/aggregateOrder';
26
33
  import type { AggregateReservationRepo } from './repo/aggregateReservation';
27
34
  import type { AggregateScheduledTaskRepo } from './repo/aggregateScheduledTask';
28
35
  import type { AggregateTaskRepo } from './repo/aggregateTask';
36
+ import type { AggregateTransactionRepo } from './repo/aggregateTransaction';
29
37
  import type { AggregationRepo } from './repo/aggregation';
30
38
  import type { AssetTransactionRepo } from './repo/assetTransaction';
31
39
  import type { ReserveTransactionRepo } from './repo/assetTransaction/reserve';
@@ -56,7 +64,6 @@ import type { OfferCatalogItemRepo } from './repo/offerCatalogItem';
56
64
  import type { OfferItemConditionRepo } from './repo/offerItemCondition';
57
65
  import type { OrderRepo } from './repo/order';
58
66
  import type { OrderInTransactionRepo } from './repo/orderInTransaction';
59
- import type { OwnershipInfoRepo } from './repo/ownershipInfo';
60
67
  import type { PassportRepo } from './repo/passport';
61
68
  import type { PaymentServiceRepo } from './repo/paymentService';
62
69
  import type { PaymentServiceChannelRepo } from './repo/paymentServiceChannel';
@@ -93,6 +100,7 @@ import type { WaiterSettingRepo } from './repo/setting/waiter';
93
100
  import type { StockHolderRepo } from './repo/stockHolder';
94
101
  import type { ScheduledTaskRepo } from './repo/scheduledTask';
95
102
  import type { TaskRepo } from './repo/task';
103
+ import type { TaskDelayedRepo } from './repo/taskDelayed';
96
104
  import type { TicketRepo } from './repo/ticket';
97
105
  import type { TransactionRepo } from './repo/transaction';
98
106
  import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
@@ -148,10 +156,6 @@ export declare namespace action {
148
156
  namespace CheckMovieTicket {
149
157
  function createInstance(...params: ConstructorParameters<typeof CheckMovieTicketActionRepo>): Promise<CheckMovieTicketActionRepo>;
150
158
  }
151
- type CheckThing = CheckThingActionRepo;
152
- namespace CheckThing {
153
- function createInstance(...params: ConstructorParameters<typeof CheckThingActionRepo>): Promise<CheckThingActionRepo>;
154
- }
155
159
  type Pay = PayActionRepo;
156
160
  namespace Pay {
157
161
  function createInstance(...params: ConstructorParameters<typeof PayActionRepo>): Promise<PayActionRepo>;
@@ -160,11 +164,31 @@ export declare namespace action {
160
164
  namespace Refund {
161
165
  function createInstance(...params: ConstructorParameters<typeof RefundActionRepo>): Promise<RefundActionRepo>;
162
166
  }
167
+ type Update = UpdateActionRepo;
168
+ namespace Update {
169
+ function createInstance(...params: ConstructorParameters<typeof UpdateActionRepo>): Promise<UpdateActionRepo>;
170
+ }
171
+ type Inform = InformActionRepo;
172
+ namespace Inform {
173
+ function createInstance(...params: ConstructorParameters<typeof InformActionRepo>): Promise<InformActionRepo>;
174
+ }
175
+ type Use = UseActionRepo;
176
+ namespace Use {
177
+ function createInstance(...params: ConstructorParameters<typeof UseActionRepo>): Promise<UseActionRepo>;
178
+ }
163
179
  }
164
180
  export type AdditionalProperty = AdditionalPropertyRepo;
165
181
  export declare namespace AdditionalProperty {
166
182
  function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
167
183
  }
184
+ export type AdminAction = AdminActionRepo;
185
+ export declare namespace AdminAction {
186
+ function createInstance(...params: ConstructorParameters<typeof AdminActionRepo>): Promise<AdminActionRepo>;
187
+ }
188
+ export type AdminAssetTransaction = AdminAssetTransactionRepo;
189
+ export declare namespace AdminAssetTransaction {
190
+ function createInstance(...params: ConstructorParameters<typeof AdminAssetTransactionRepo>): Promise<AdminAssetTransactionRepo>;
191
+ }
168
192
  export type AdminAsyncAction = AdminAsyncActionRepo;
169
193
  export declare namespace AdminAsyncAction {
170
194
  function createInstance(...params: ConstructorParameters<typeof AdminAsyncActionRepo>): Promise<AdminAsyncActionRepo>;
@@ -177,10 +201,18 @@ export type AdminTask = AdminTaskRepo;
177
201
  export declare namespace AdminTask {
178
202
  function createInstance(...params: ConstructorParameters<typeof AdminTaskRepo>): Promise<AdminTaskRepo>;
179
203
  }
204
+ export type AdminTransaction = AdminTransactionRepo;
205
+ export declare namespace AdminTransaction {
206
+ function createInstance(...params: ConstructorParameters<typeof AdminTransactionRepo>): Promise<AdminTransactionRepo>;
207
+ }
180
208
  export type AggregateAction = AggregateActionRepo;
181
209
  export declare namespace AggregateAction {
182
210
  function createInstance(...params: ConstructorParameters<typeof AggregateActionRepo>): Promise<AggregateActionRepo>;
183
211
  }
212
+ export type AggregateUseAction = AggregateUseActionRepo;
213
+ export declare namespace AggregateUseAction {
214
+ function createInstance(...params: ConstructorParameters<typeof AggregateUseActionRepo>): Promise<AggregateUseActionRepo>;
215
+ }
184
216
  export type AggregateScheduledTask = AggregateScheduledTaskRepo;
185
217
  export declare namespace AggregateScheduledTask {
186
218
  function createInstance(...params: ConstructorParameters<typeof AggregateScheduledTaskRepo>): Promise<AggregateScheduledTaskRepo>;
@@ -189,6 +221,14 @@ export type AggregateTask = AggregateTaskRepo;
189
221
  export declare namespace AggregateTask {
190
222
  function createInstance(...params: ConstructorParameters<typeof AggregateTaskRepo>): Promise<AggregateTaskRepo>;
191
223
  }
224
+ export type AggregateTransaction = AggregateTransactionRepo;
225
+ export declare namespace AggregateTransaction {
226
+ function createInstance(...params: ConstructorParameters<typeof AggregateTransactionRepo>): Promise<AggregateTransactionRepo>;
227
+ }
228
+ export type AggregateAssetTransaction = AggregateAssetTransactionRepo;
229
+ export declare namespace AggregateAssetTransaction {
230
+ function createInstance(...params: ConstructorParameters<typeof AggregateAssetTransactionRepo>): Promise<AggregateAssetTransactionRepo>;
231
+ }
192
232
  export type AggregateOffer = AggregateOfferRepo;
193
233
  export declare namespace AggregateOffer {
194
234
  function createInstance(...params: ConstructorParameters<typeof AggregateOfferRepo>): Promise<AggregateOfferRepo>;
@@ -331,10 +371,6 @@ export type OrderNumber = OrderNumberRepo;
331
371
  export declare namespace OrderNumber {
332
372
  function createInstance(...params: ConstructorParameters<typeof OrderNumberRepo>): Promise<OrderNumberRepo>;
333
373
  }
334
- export type OwnershipInfo = OwnershipInfoRepo;
335
- export declare namespace OwnershipInfo {
336
- function createInstance(...params: ConstructorParameters<typeof OwnershipInfoRepo>): Promise<OwnershipInfoRepo>;
337
- }
338
374
  export type Passport = PassportRepo;
339
375
  export declare namespace Passport {
340
376
  function createInstance(...params: ConstructorParameters<typeof PassportRepo>): Promise<PassportRepo>;
@@ -501,6 +537,10 @@ export type Task = TaskRepo;
501
537
  export declare namespace Task {
502
538
  function createInstance(...params: ConstructorParameters<typeof TaskRepo>): Promise<TaskRepo>;
503
539
  }
540
+ export type TaskDelayed = TaskDelayedRepo;
541
+ export declare namespace TaskDelayed {
542
+ function createInstance(...params: ConstructorParameters<typeof TaskDelayedRepo>): Promise<TaskDelayedRepo>;
543
+ }
504
544
  export type AsyncAction = AsyncActionRepo;
505
545
  export declare namespace AsyncAction {
506
546
  function createInstance(...params: ConstructorParameters<typeof AsyncActionRepo>): Promise<AsyncActionRepo>;