@chevre/domain 21.2.0-alpha.9 → 21.2.0-alpha.91

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 (247) hide show
  1. package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  3. package/example/src/chevre/deleteTasksByName.ts +10 -2
  4. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  5. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  6. package/example/src/chevre/processReserve.ts +2 -1
  7. package/example/src/chevre/saveTasks.ts +13 -10
  8. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  9. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
  10. package/example/src/chevre/searchSellers.ts +33 -0
  11. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  12. package/example/src/chevre/task/executeTasks.ts +26 -0
  13. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  14. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  15. package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
  16. package/example/src/chevre/transaction/startExportTasks.ts +20 -0
  17. package/example/src/chevre/updateTransaction.ts +1 -1
  18. package/example/src/playOnMoment.ts +24 -0
  19. package/lib/chevre/credentials.d.ts +1 -0
  20. package/lib/chevre/credentials.js +2 -1
  21. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  22. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  23. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  24. package/lib/chevre/eventEmitter/task.js +25 -0
  25. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  26. package/lib/chevre/eventEmitter/transaction.js +25 -0
  27. package/lib/chevre/eventEmitter.d.ts +4 -0
  28. package/lib/chevre/eventEmitter.js +9 -0
  29. package/lib/chevre/index.d.ts +3 -2
  30. package/lib/chevre/index.js +5 -3
  31. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  32. package/lib/chevre/repo/accountTransaction.js +1 -54
  33. package/lib/chevre/repo/action.d.ts +29 -1
  34. package/lib/chevre/repo/action.js +32 -25
  35. package/lib/chevre/repo/assetTransaction.d.ts +25 -9
  36. package/lib/chevre/repo/assetTransaction.js +241 -80
  37. package/lib/chevre/repo/comment.d.ts +4 -1
  38. package/lib/chevre/repo/comment.js +20 -5
  39. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  40. package/lib/chevre/repo/confirmationNumber.js +3 -15
  41. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  42. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  43. package/lib/chevre/repo/event.d.ts +5 -1
  44. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  45. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  46. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  47. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  48. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  49. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  50. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  51. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  52. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  53. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  54. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  55. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  56. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  57. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  58. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  59. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  60. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +27 -19
  61. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  62. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  63. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  64. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  65. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  66. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  67. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  68. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  69. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  70. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  71. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  72. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  73. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  74. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  75. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  76. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  77. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  78. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  79. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  80. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  82. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  83. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  84. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  85. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  86. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  87. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  88. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  89. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  90. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  91. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  92. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  93. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  94. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  95. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  96. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  97. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -4
  98. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  99. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  100. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  101. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  102. package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
  103. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  104. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  105. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  106. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  107. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  108. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  109. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  110. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  111. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  112. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  113. package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
  114. package/lib/chevre/repo/offerItemCondition.js +120 -0
  115. package/lib/chevre/repo/order.d.ts +55 -3
  116. package/lib/chevre/repo/order.js +56 -5
  117. package/lib/chevre/repo/reservation.d.ts +8 -4
  118. package/lib/chevre/repo/reservation.js +12 -42
  119. package/lib/chevre/repo/seller.js +19 -19
  120. package/lib/chevre/repo/task.d.ts +42 -2
  121. package/lib/chevre/repo/task.js +90 -9
  122. package/lib/chevre/repo/transaction.d.ts +23 -3
  123. package/lib/chevre/repo/transaction.js +174 -54
  124. package/lib/chevre/repository.d.ts +5 -2
  125. package/lib/chevre/repository.js +8 -4
  126. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  127. package/lib/chevre/service/aggregation/system.js +101 -89
  128. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
  129. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
  130. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  131. package/lib/chevre/service/assetTransaction/pay.js +10 -25
  132. package/lib/chevre/service/assetTransaction/refund.js +1 -23
  133. package/lib/chevre/service/assetTransaction/registerService.js +1 -25
  134. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +7 -2
  135. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -22
  136. package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -1
  137. package/lib/chevre/service/assetTransaction/reserve.js +40 -41
  138. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  139. package/lib/chevre/service/assetTransaction.js +9 -5
  140. package/lib/chevre/service/event.js +3 -1
  141. package/lib/chevre/service/notification/factory.js +2 -2
  142. package/lib/chevre/service/notification.d.ts +3 -1
  143. package/lib/chevre/service/notification.js +41 -7
  144. package/lib/chevre/service/offer/event/authorize.d.ts +1 -0
  145. package/lib/chevre/service/offer/event/authorize.js +5 -2
  146. package/lib/chevre/service/offer/event/factory.d.ts +2 -0
  147. package/lib/chevre/service/offer/event/factory.js +2 -2
  148. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  149. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  150. package/lib/chevre/service/offer.js +1 -1
  151. package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
  152. package/lib/chevre/service/order/deleteOrder.js +8 -8
  153. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +4 -2
  154. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
  155. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
  156. package/lib/chevre/service/order/onOrderUpdated.d.ts +15 -0
  157. package/lib/chevre/service/order/onOrderUpdated.js +22 -0
  158. package/lib/chevre/service/order/placeOrder.d.ts +1 -0
  159. package/lib/chevre/service/order/placeOrder.js +41 -24
  160. package/lib/chevre/service/order/returnOrder.d.ts +1 -0
  161. package/lib/chevre/service/order/returnOrder.js +7 -12
  162. package/lib/chevre/service/order/sendOrder.d.ts +1 -0
  163. package/lib/chevre/service/order/sendOrder.js +7 -10
  164. package/lib/chevre/service/order.d.ts +2 -1
  165. package/lib/chevre/service/order.js +3 -1
  166. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  167. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  168. package/lib/chevre/service/payment/any.js +74 -16
  169. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
  170. package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
  171. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  172. package/lib/chevre/service/payment/movieTicket.js +4 -3
  173. package/lib/chevre/service/product.js +1 -5
  174. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  175. package/lib/chevre/service/report/telemetry.js +21 -24
  176. package/lib/chevre/service/reserve/cancelReservation.d.ts +4 -2
  177. package/lib/chevre/service/reserve/cancelReservation.js +2 -4
  178. package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
  179. package/lib/chevre/service/reserve/checkInReservation.js +77 -3
  180. package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
  181. package/lib/chevre/service/reserve/confirmReservation.js +121 -58
  182. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
  183. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
  184. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  185. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  186. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  187. package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
  188. package/lib/chevre/service/reserve/useReservation.js +61 -71
  189. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
  190. package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
  191. package/lib/chevre/service/reserve.d.ts +3 -2
  192. package/lib/chevre/service/reserve.js +4 -2
  193. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  194. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  195. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  196. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
  197. package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
  198. package/lib/chevre/service/task/placeOrder.js +1 -1
  199. package/lib/chevre/service/task/reserve.js +10 -7
  200. package/lib/chevre/service/task/returnOrder.js +1 -1
  201. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  202. package/lib/chevre/service/task/sendOrder.js +1 -1
  203. package/lib/chevre/service/task/useReservation.d.ts +7 -0
  204. package/lib/chevre/service/task/useReservation.js +36 -0
  205. package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
  206. package/lib/chevre/service/task.d.ts +9 -0
  207. package/lib/chevre/service/task.js +43 -4
  208. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  209. package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
  210. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  211. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  212. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  213. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  214. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  215. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  216. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  217. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  218. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  219. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  220. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  221. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  222. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  223. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  224. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  225. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  226. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  227. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  228. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  229. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  230. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  231. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
  232. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  233. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  234. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
  235. package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
  236. package/lib/chevre/service/transaction/returnOrder.js +225 -35
  237. package/lib/chevre/service/transaction.d.ts +8 -13
  238. package/lib/chevre/service/transaction.js +12 -145
  239. package/lib/chevre/settings.d.ts +4 -1
  240. package/lib/chevre/settings.js +15 -5
  241. package/package.json +5 -5
  242. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  243. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  244. package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
  245. package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
  246. package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
  247. package/lib/chevre/service/task/deleteOrder.js +0 -35
@@ -13,6 +13,7 @@ exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
15
15
  const factory = require("../factory");
16
+ const assetTransaction_2 = require("../eventEmitter/assetTransaction");
16
17
  /**
17
18
  * 資産取引リポジトリ
18
19
  */
@@ -22,7 +23,7 @@ class MongoRepository {
22
23
  }
23
24
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
24
25
  static CREATE_MONGO_CONDITIONS(params) {
25
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
26
27
  const andConditions = [
27
28
  {
28
29
  typeOf: params.typeOf
@@ -132,15 +133,18 @@ class MongoRepository {
132
133
  const objectPaymentMethodIdEq4refund = (_j = (_h = params.object) === null || _h === void 0 ? void 0 : _h.paymentMethodId) === null || _j === void 0 ? void 0 : _j.$eq;
133
134
  if (typeof objectPaymentMethodIdEq4refund === 'string') {
134
135
  andConditions.push({
135
- 'object.paymentMethodId': {
136
- $exists: true,
137
- $eq: objectPaymentMethodIdEq4refund
138
- }
136
+ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
137
+ });
138
+ }
139
+ const objectPaymentMethodIdIn4refund = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$in;
140
+ if (Array.isArray(objectPaymentMethodIdIn4refund)) {
141
+ andConditions.push({
142
+ 'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
139
143
  });
140
144
  }
141
145
  break;
142
146
  case factory.assetTransactionType.MoneyTransfer:
143
- const fromLocationIdentifierEq = (_m = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.fromLocation) === null || _l === void 0 ? void 0 : _l.identifier) === null || _m === void 0 ? void 0 : _m.$eq;
147
+ const fromLocationIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.fromLocation) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
144
148
  if (typeof fromLocationIdentifierEq === 'string') {
145
149
  andConditions.push({
146
150
  'object.fromLocation.identifier': {
@@ -149,7 +153,7 @@ class MongoRepository {
149
153
  }
150
154
  });
151
155
  }
152
- const toLocationIdentifierEq = (_q = (_p = (_o = params.object) === null || _o === void 0 ? void 0 : _o.toLocation) === null || _p === void 0 ? void 0 : _p.identifier) === null || _q === void 0 ? void 0 : _q.$eq;
156
+ const toLocationIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.toLocation) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
153
157
  if (typeof toLocationIdentifierEq === 'string') {
154
158
  andConditions.push({
155
159
  'object.toLocation.identifier': {
@@ -158,7 +162,7 @@ class MongoRepository {
158
162
  }
159
163
  });
160
164
  }
161
- const pendingTransactionIdentifierEq = (_t = (_s = (_r = params.object) === null || _r === void 0 ? void 0 : _r.pendingTransaction) === null || _s === void 0 ? void 0 : _s.identifier) === null || _t === void 0 ? void 0 : _t.$eq;
165
+ const pendingTransactionIdentifierEq = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.pendingTransaction) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$eq;
162
166
  if (typeof pendingTransactionIdentifierEq === 'string') {
163
167
  andConditions.push({
164
168
  'object.pendingTransaction.identifier': {
@@ -171,7 +175,25 @@ class MongoRepository {
171
175
  case factory.assetTransactionType.CancelReservation:
172
176
  break;
173
177
  case factory.assetTransactionType.Reserve:
174
- const objectReservationNumberEq = (_v = (_u = params.object) === null || _u === void 0 ? void 0 : _u.reservationNumber) === null || _v === void 0 ? void 0 : _v.$eq;
178
+ const objectReservationForIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationFor) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
179
+ if (typeof objectReservationForIdEq === 'string') {
180
+ andConditions.push({
181
+ 'object.reservationFor.id': {
182
+ $exists: true,
183
+ $eq: objectReservationForIdEq
184
+ }
185
+ });
186
+ }
187
+ const objectReservationNumberIn = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationNumber) === null || _0 === void 0 ? void 0 : _0.$in;
188
+ if (Array.isArray(objectReservationNumberIn)) {
189
+ andConditions.push({
190
+ 'object.reservationNumber': {
191
+ $exists: true,
192
+ $in: objectReservationNumberIn
193
+ }
194
+ });
195
+ }
196
+ const objectReservationNumberEq = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.reservationNumber) === null || _2 === void 0 ? void 0 : _2.$eq;
175
197
  if (typeof objectReservationNumberEq === 'string') {
176
198
  andConditions.push({
177
199
  'object.reservationNumber': {
@@ -180,19 +202,17 @@ class MongoRepository {
180
202
  }
181
203
  });
182
204
  }
205
+ const objectSubReservationIdIn = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservations) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$in;
206
+ if (Array.isArray(objectSubReservationIdIn)) {
207
+ andConditions.push({
208
+ 'object.subReservation.id': {
209
+ $exists: true,
210
+ $in: objectSubReservationIdIn
211
+ }
212
+ });
213
+ }
183
214
  if (params.object !== undefined) {
184
215
  if (params.object.reservations !== undefined) {
185
- if (params.object.reservations.id !== undefined) {
186
- if (Array.isArray(params.object.reservations.id.$in)) {
187
- andConditions.push({
188
- // 'object.reservations.id': {
189
- 'object.subReservation.id': {
190
- $exists: true,
191
- $in: params.object.reservations.id.$in
192
- }
193
- });
194
- }
195
- }
196
216
  if (params.object.reservations.reservationNumber !== undefined) {
197
217
  if (Array.isArray(params.object.reservations.reservationNumber.$in)) {
198
218
  andConditions.push({
@@ -217,9 +237,18 @@ class MongoRepository {
217
237
  }
218
238
  }
219
239
  }
240
+ const objectUnderNameIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.underName) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$eq;
241
+ if (typeof objectUnderNameIdEq === 'string') {
242
+ andConditions.push({
243
+ 'object.underName.id': {
244
+ $exists: true,
245
+ $eq: objectUnderNameIdEq
246
+ }
247
+ });
248
+ }
220
249
  break;
221
250
  case factory.assetTransactionType.RegisterService:
222
- const objectItemOfferedServiceOutputIdentifierEq = (_z = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.itemOffered) === null || _x === void 0 ? void 0 : _x.serviceOutput) === null || _y === void 0 ? void 0 : _y.identifier) === null || _z === void 0 ? void 0 : _z.$eq;
251
+ const objectItemOfferedServiceOutputIdentifierEq = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.itemOffered) === null || _10 === void 0 ? void 0 : _10.serviceOutput) === null || _11 === void 0 ? void 0 : _11.identifier) === null || _12 === void 0 ? void 0 : _12.$eq;
223
252
  if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
224
253
  andConditions.push({
225
254
  'object.itemOffered.serviceOutput.identifier': {
@@ -228,7 +257,7 @@ class MongoRepository {
228
257
  }
229
258
  });
230
259
  }
231
- const objectItemOfferedServiceOutputIdentifierIn = (_3 = (_2 = (_1 = (_0 = params.object) === null || _0 === void 0 ? void 0 : _0.itemOffered) === null || _1 === void 0 ? void 0 : _1.serviceOutput) === null || _2 === void 0 ? void 0 : _2.identifier) === null || _3 === void 0 ? void 0 : _3.$in;
260
+ const objectItemOfferedServiceOutputIdentifierIn = (_16 = (_15 = (_14 = (_13 = params.object) === null || _13 === void 0 ? void 0 : _13.itemOffered) === null || _14 === void 0 ? void 0 : _14.serviceOutput) === null || _15 === void 0 ? void 0 : _15.identifier) === null || _16 === void 0 ? void 0 : _16.$in;
232
261
  if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
233
262
  andConditions.push({
234
263
  'object.itemOffered.serviceOutput.identifier': {
@@ -247,7 +276,9 @@ class MongoRepository {
247
276
  */
248
277
  start(params) {
249
278
  return __awaiter(this, void 0, void 0, function* () {
250
- return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
279
+ return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
280
+ actionStatus: factory.actionStatusType.PotentialActionStatus
281
+ }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
251
282
  .then((doc) => doc.toObject());
252
283
  });
253
284
  }
@@ -277,15 +308,12 @@ class MongoRepository {
277
308
  return doc.toObject();
278
309
  });
279
310
  }
280
- /**
281
- * 取引を確定する
282
- */
283
311
  addReservations(params) {
284
312
  return __awaiter(this, void 0, void 0, function* () {
285
313
  const doc = yield this.transactionModel.findOneAndUpdate({
286
- _id: params.id,
287
- typeOf: params.typeOf,
288
- status: factory.transactionStatusType.InProgress
314
+ _id: { $eq: params.id },
315
+ typeOf: { $eq: params.typeOf },
316
+ status: { $eq: factory.transactionStatusType.InProgress }
289
317
  }, {
290
318
  'object.acceptedOffer': params.object.acceptedOffer,
291
319
  // 念のため残す(2021/10/14)が、そのうち削除
@@ -308,36 +336,40 @@ class MongoRepository {
308
336
  * 取引を確定する
309
337
  */
310
338
  confirm(params) {
339
+ var _a, _b;
311
340
  return __awaiter(this, void 0, void 0, function* () {
312
341
  const doc = yield this.transactionModel.findOneAndUpdate({
313
- _id: params.id,
314
- typeOf: params.typeOf,
315
- status: factory.transactionStatusType.InProgress
316
- }, {
317
- status: factory.transactionStatusType.Confirmed,
318
- endDate: new Date(),
319
- result: params.result,
320
- potentialActions: params.potentialActions // resultを更新
321
- }, { new: true })
342
+ _id: { $eq: params.id },
343
+ typeOf: { $eq: params.typeOf },
344
+ status: { $eq: factory.transactionStatusType.InProgress }
345
+ }, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
346
+ ? { 'object.underName': params.object.underName }
347
+ : undefined), {
348
+ new: true,
349
+ projection: { _id: 1 }
350
+ })
322
351
  .exec();
323
352
  // NotFoundであれば取引状態確認
324
353
  if (doc === null) {
325
354
  const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
326
355
  if (transaction.status === factory.transactionStatusType.Confirmed) {
327
- // すでに確定済の場合
328
- return transaction;
356
+ // すでに確定済の場合スルー
329
357
  }
330
358
  else if (transaction.status === factory.transactionStatusType.Expired) {
331
- throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
359
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
332
360
  }
333
361
  else if (transaction.status === factory.transactionStatusType.Canceled) {
334
- throw new factory.errors.Argument('Transaction id', 'Transaction already canceled');
362
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
335
363
  }
336
364
  else {
337
365
  throw new factory.errors.NotFound(this.transactionModel.modelName);
338
366
  }
339
367
  }
340
- return doc.toObject();
368
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
369
+ id: params.id,
370
+ typeOf: params.typeOf,
371
+ status: factory.transactionStatusType.Confirmed
372
+ });
341
373
  });
342
374
  }
343
375
  /**
@@ -345,23 +377,42 @@ class MongoRepository {
345
377
  */
346
378
  startAndConfirm(params) {
347
379
  return __awaiter(this, void 0, void 0, function* () {
348
- return this.transactionModel.create(Object.assign(Object.assign({ _id: params.id, typeOf: params.typeOf }, params), { startDate: new Date(), status: factory.transactionStatusType.Confirmed, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }))
380
+ const startDate = new Date();
381
+ const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
382
+ actionStatus: factory.actionStatusType.PotentialActionStatus
383
+ }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
349
384
  .then((doc) => doc.toObject());
385
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
386
+ id: params.id,
387
+ typeOf: params.typeOf,
388
+ status: factory.transactionStatusType.Confirmed
389
+ });
390
+ return confirmedTransaction;
350
391
  });
351
392
  }
352
393
  /**
353
394
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
354
395
  */
355
396
  startExportTasks(params) {
356
- var _a, _b, _c;
397
+ var _a, _b;
357
398
  return __awaiter(this, void 0, void 0, function* () {
358
- return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({}, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === 'string')
359
- ? {
360
- 'project.id': {
361
- $eq: params.project.id
362
- }
363
- } : undefined), (Array.isArray((_b = params.typeOf) === null || _b === void 0 ? void 0 : _b.$in))
364
- ? { typeOf: { $in: (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$in } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
399
+ switch (params.status) {
400
+ case factory.transactionStatusType.InProgress:
401
+ throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
402
+ default:
403
+ // no op
404
+ }
405
+ const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
406
+ return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
407
+ 'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
408
+ 'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
409
+ 'tasksExportAction.startDate': new Date(),
410
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
411
+ }, { new: true })
412
+ .select({
413
+ _id: 1,
414
+ typeOf: 1
415
+ })
365
416
  .exec()
366
417
  // tslint:disable-next-line:no-null-keyword
367
418
  .then((doc) => (doc === null) ? null : doc.toObject());
@@ -374,17 +425,74 @@ class MongoRepository {
374
425
  */
375
426
  reexportTasks(params) {
376
427
  return __awaiter(this, void 0, void 0, function* () {
377
- yield this.transactionModel.updateMany({
378
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
428
+ const reexportingTransactions = yield this.transactionModel.find({
429
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
379
430
  updatedAt: {
380
431
  $lt: moment()
381
432
  .add(-params.intervalInMinutes, 'minutes')
382
433
  .toDate()
383
434
  }
384
- }, {
385
- tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
386
435
  })
436
+ .select({
437
+ _id: 1,
438
+ typeOf: 1,
439
+ status: 1
440
+ })
441
+ .setOptions({ maxTimeMS: 10000 })
387
442
  .exec();
443
+ if (reexportingTransactions.length > 0) {
444
+ for (const reexportingTransaction of reexportingTransactions) {
445
+ yield this.transactionModel.updateOne({
446
+ _id: { $eq: reexportingTransaction.id },
447
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
448
+ }, {
449
+ tasksExportAction: {
450
+ actionStatus: factory.actionStatusType.PotentialActionStatus
451
+ },
452
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
453
+ })
454
+ .exec();
455
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
456
+ id: reexportingTransaction.id,
457
+ typeOf: reexportingTransaction.typeOf,
458
+ status: reexportingTransaction.status
459
+ });
460
+ }
461
+ }
462
+ });
463
+ }
464
+ /**
465
+ * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
466
+ */
467
+ exportTasks(params) {
468
+ return __awaiter(this, void 0, void 0, function* () {
469
+ const delayedTransactions = yield this.transactionModel.find({
470
+ status: { $in: params.status.$in },
471
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
472
+ endDate: {
473
+ $exists: true,
474
+ $lt: moment(params.now)
475
+ .add(-params.delayInSeconds, 'seconds')
476
+ .toDate()
477
+ }
478
+ })
479
+ .select({
480
+ _id: 1,
481
+ typeOf: 1,
482
+ status: 1
483
+ })
484
+ .setOptions({ maxTimeMS: 10000 })
485
+ .exec();
486
+ if (delayedTransactions.length > 0) {
487
+ delayedTransactions.forEach((delayedTransaction) => {
488
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
489
+ id: delayedTransaction.id,
490
+ typeOf: delayedTransaction.typeOf,
491
+ status: delayedTransaction.status
492
+ });
493
+ });
494
+ }
495
+ return delayedTransactions;
388
496
  });
389
497
  }
390
498
  /**
@@ -393,10 +501,15 @@ class MongoRepository {
393
501
  */
394
502
  setTasksExportedById(params) {
395
503
  return __awaiter(this, void 0, void 0, function* () {
396
- yield this.transactionModel.findByIdAndUpdate(params.id, {
504
+ const endDate = new Date();
505
+ yield this.transactionModel.updateOne({
506
+ _id: { $eq: params.id },
507
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
508
+ }, {
397
509
  tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
398
- tasksExportedAt: moment()
399
- .toDate()
510
+ tasksExportedAt: endDate,
511
+ 'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
512
+ 'tasksExportAction.endDate': endDate
400
513
  })
401
514
  .exec();
402
515
  });
@@ -406,15 +519,36 @@ class MongoRepository {
406
519
  */
407
520
  makeExpired(params) {
408
521
  return __awaiter(this, void 0, void 0, function* () {
409
- // ステータスと期限を見て更新
410
- yield this.transactionModel.updateMany({
411
- status: factory.transactionStatusType.InProgress,
412
- expires: { $lt: params.expires }
413
- }, {
414
- status: factory.transactionStatusType.Expired,
415
- endDate: new Date()
522
+ // IDをemitしたいのでまずリスト検索(2023-04-27~)
523
+ const expiringTransactions = yield this.transactionModel.find({
524
+ status: { $eq: factory.transactionStatusType.InProgress },
525
+ expires: { $lt: params.expires.$lt }
526
+ })
527
+ .select({
528
+ _id: 1,
529
+ typeOf: 1
416
530
  })
531
+ .setOptions({ maxTimeMS: 10000 })
417
532
  .exec();
533
+ if (expiringTransactions.length > 0) {
534
+ // ステータスと期限を見て更新
535
+ yield this.transactionModel.updateMany({
536
+ _id: { $in: expiringTransactions.map((t) => t.id) },
537
+ status: { $eq: factory.transactionStatusType.InProgress },
538
+ expires: { $lt: params.expires.$lt }
539
+ }, {
540
+ status: factory.transactionStatusType.Expired,
541
+ endDate: new Date()
542
+ })
543
+ .exec();
544
+ expiringTransactions.forEach((expiringTransaction) => {
545
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
546
+ id: expiringTransaction.id,
547
+ typeOf: expiringTransaction.typeOf,
548
+ status: factory.transactionStatusType.Expired
549
+ });
550
+ });
551
+ }
418
552
  });
419
553
  }
420
554
  /**
@@ -422,19 +556,18 @@ class MongoRepository {
422
556
  */
423
557
  cancel(params) {
424
558
  return __awaiter(this, void 0, void 0, function* () {
425
- const endDate = moment()
426
- .toDate();
559
+ const endDate = new Date();
427
560
  // 進行中ステータスの取引を中止する
428
- const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: params.typeOf }, (typeof params.id === 'string') ? { _id: params.id } : undefined), (typeof params.transactionNumber === 'string')
561
+ const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
429
562
  ? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
430
- : undefined), { status: factory.transactionStatusType.InProgress }), {
563
+ : undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
431
564
  status: factory.transactionStatusType.Canceled,
432
565
  endDate: endDate
433
566
  }, { new: true })
434
567
  .exec();
568
+ let transaction;
435
569
  // NotFoundであれば取引状態確認
436
570
  if (doc === null) {
437
- let transaction;
438
571
  if (typeof params.id === 'string') {
439
572
  transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
440
573
  }
@@ -448,20 +581,27 @@ class MongoRepository {
448
581
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
449
582
  }
450
583
  if (transaction.status === factory.transactionStatusType.Canceled) {
451
- // すでに中止済の場合
452
- return transaction;
584
+ // すでに中止済の場合スルー
453
585
  }
454
586
  else if (transaction.status === factory.transactionStatusType.Expired) {
455
- throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
587
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
456
588
  }
457
589
  else if (transaction.status === factory.transactionStatusType.Confirmed) {
458
- throw new factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
590
+ throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
459
591
  }
460
592
  else {
461
593
  throw new factory.errors.NotFound(this.transactionModel.modelName);
462
594
  }
463
595
  }
464
- return doc.toObject();
596
+ else {
597
+ transaction = doc.toObject();
598
+ }
599
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
600
+ id: transaction.id,
601
+ typeOf: params.typeOf,
602
+ status: factory.transactionStatusType.Canceled
603
+ });
604
+ return transaction;
465
605
  });
466
606
  }
467
607
  count(params) {
@@ -475,12 +615,30 @@ class MongoRepository {
475
615
  /**
476
616
  * 取引を検索する
477
617
  */
478
- search(params, projection) {
618
+ search(params, inclusion, exclusion) {
479
619
  var _a;
480
620
  return __awaiter(this, void 0, void 0, function* () {
481
621
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
622
+ let projection = {};
623
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
624
+ inclusion.forEach((field) => {
625
+ projection[field] = 1;
626
+ });
627
+ }
628
+ else {
629
+ projection = {
630
+ __v: 0,
631
+ createdAt: 0,
632
+ updatedAt: 0
633
+ };
634
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
635
+ exclusion.forEach((field) => {
636
+ projection[field] = 0;
637
+ });
638
+ }
639
+ }
482
640
  const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
483
- .select(Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
641
+ .select(projection);
484
642
  if (typeof params.limit === 'number' && params.limit > 0) {
485
643
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
486
644
  query.limit(params.limit)
@@ -523,9 +681,12 @@ class MongoRepository {
523
681
  /**
524
682
  * 特定の取引を更新する(汎用)
525
683
  */
526
- findByIdAndUpdate(params) {
684
+ findByIdAndUpdateInProgress(params) {
527
685
  return __awaiter(this, void 0, void 0, function* () {
528
- return this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, { new: true })
686
+ return this.transactionModel.findOneAndUpdate({
687
+ _id: { $eq: params.id },
688
+ status: { $eq: factory.transactionStatusType.InProgress }
689
+ }, params.update, { new: true })
529
690
  .exec()
530
691
  .then((doc) => {
531
692
  if (doc === null) {
@@ -34,7 +34,10 @@ export declare class MongoRepository {
34
34
  /**
35
35
  * 検索
36
36
  */
37
- search(params: factory.creativeWork.comment.ISearchConditions): Promise<factory.creativeWork.comment.IComment[]>;
37
+ search(params: factory.creativeWork.comment.ISearchConditions & {
38
+ inclusion: string[];
39
+ exclusion: string[];
40
+ }): Promise<factory.creativeWork.comment.IComment[]>;
38
41
  findById(params: {
39
42
  id: string;
40
43
  }): Promise<factory.creativeWork.comment.IComment>;
@@ -42,12 +42,27 @@ class MongoRepository {
42
42
  search(params) {
43
43
  var _a;
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
+ let projection = {};
46
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
47
+ params.inclusion.forEach((field) => {
48
+ projection[field] = 1;
49
+ });
50
+ }
51
+ else {
52
+ projection = {
53
+ __v: 0,
54
+ createdAt: 0,
55
+ updatedAt: 0
56
+ };
57
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
58
+ params.exclusion.forEach((field) => {
59
+ projection[field] = 0;
60
+ });
61
+ }
62
+ }
45
63
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
46
- const query = this.commentModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
47
- __v: 0,
48
- createdAt: 0,
49
- updatedAt: 0
50
- });
64
+ const query = this.commentModel.find((conditions.length > 0) ? { $and: conditions } : {})
65
+ .select(projection);
51
66
  if (typeof params.limit === 'number' && params.limit > 0) {
52
67
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
53
68
  query.limit(params.limit)
@@ -4,7 +4,6 @@ import { RedisClientType } from 'redis';
4
4
  */
5
5
  export declare class RedisRepository {
6
6
  private static readonly REDIS_KEY_PREFIX_NEW;
7
- private static readonly REDIS_KEY_PREFIX;
8
7
  private readonly redisClient;
9
8
  constructor(redisClient: RedisClientType);
10
9
  private static alignDigits;
@@ -16,7 +16,6 @@ const util = require("util");
16
16
  // tslint:disable-next-line:no-require-imports no-var-requires
17
17
  const fpe = require('node-fpe');
18
18
  const factory = require("../factory");
19
- const settings_1 = require("../settings");
20
19
  const CONFIRMATION_NUMBER_MIN_LENGH = 4;
21
20
  /**
22
21
  * 確認番号リポジトリ
@@ -34,19 +33,9 @@ class RedisRepository {
34
33
  return aligndNumber;
35
34
  }
36
35
  static createKey(params) {
37
- const useNewKey = params.orderDate instanceof Date
38
- && moment(params.orderDate)
39
- .isSameOrAfter(settings_1.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM);
40
- if (useNewKey) {
41
- return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
42
- .tz('Asia/Tokyo')
43
- .format('YYMM'));
44
- }
45
- else {
46
- return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, moment(params.orderDate)
47
- .tz('Asia/Tokyo')
48
- .format('YYMM'));
49
- }
36
+ return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
37
+ .tz('Asia/Tokyo')
38
+ .format('YYMM'));
50
39
  }
51
40
  /**
52
41
  * 発行する
@@ -81,5 +70,4 @@ class RedisRepository {
81
70
  }
82
71
  }
83
72
  RedisRepository.REDIS_KEY_PREFIX_NEW = 'confirmationNumber';
84
- RedisRepository.REDIS_KEY_PREFIX = 'cinerino:confirmationNumber';
85
73
  exports.RedisRepository = RedisRepository;
@@ -34,9 +34,7 @@ export declare class MongoRepository {
34
34
  /**
35
35
  * コンテンツを保管する
36
36
  */
37
- saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<import("mongoose").LeanDocument<any> & Required<{
38
- _id: unknown;
39
- }>>;
37
+ saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<any>;
40
38
  findMovieById(params: {
41
39
  id: string;
42
40
  }): Promise<factory.creativeWork.movie.ICreativeWork>;