@chevre/domain 21.2.0-alpha.10 → 21.2.0-alpha.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) 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/processPay.ts +5 -1
  7. package/example/src/chevre/processReserve.ts +4 -1
  8. package/example/src/chevre/saveTasks.ts +13 -10
  9. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  10. package/example/src/chevre/searchActions.ts +33 -0
  11. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
  12. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  13. package/example/src/chevre/task/executeTasks.ts +26 -0
  14. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  15. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  16. package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
  17. package/example/src/chevre/transaction/startExportTasks.ts +20 -0
  18. package/example/src/chevre/updateTransaction.ts +1 -1
  19. package/example/src/playOnMoment.ts +24 -0
  20. package/lib/chevre/credentials.d.ts +1 -0
  21. package/lib/chevre/credentials.js +2 -1
  22. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  23. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  24. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  25. package/lib/chevre/eventEmitter/task.js +25 -0
  26. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  27. package/lib/chevre/eventEmitter/transaction.js +25 -0
  28. package/lib/chevre/eventEmitter.d.ts +4 -0
  29. package/lib/chevre/eventEmitter.js +9 -0
  30. package/lib/chevre/index.d.ts +3 -2
  31. package/lib/chevre/index.js +5 -3
  32. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  33. package/lib/chevre/repo/accountTransaction.js +1 -54
  34. package/lib/chevre/repo/action.d.ts +29 -1
  35. package/lib/chevre/repo/action.js +98 -55
  36. package/lib/chevre/repo/assetTransaction.d.ts +25 -9
  37. package/lib/chevre/repo/assetTransaction.js +256 -85
  38. package/lib/chevre/repo/comment.d.ts +4 -1
  39. package/lib/chevre/repo/comment.js +20 -5
  40. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  41. package/lib/chevre/repo/confirmationNumber.js +3 -15
  42. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  43. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  44. package/lib/chevre/repo/event.d.ts +5 -1
  45. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  46. package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
  47. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
  48. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
  49. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
  51. package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
  52. package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
  53. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
  54. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
  55. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
  56. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
  57. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
  58. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  59. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
  60. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
  61. package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
  62. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
  63. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
  64. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
  65. package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
  66. package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
  67. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
  68. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
  69. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
  70. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  71. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  72. package/lib/chevre/repo/mongoose/schemas/order.d.ts +51 -3
  73. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  74. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
  75. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
  76. package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
  77. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
  78. package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
  79. package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
  80. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
  81. package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
  82. package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
  83. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
  84. package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
  85. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
  86. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
  87. package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
  88. package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
  89. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
  90. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
  91. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
  92. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
  93. package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
  94. package/lib/chevre/repo/offerItemCondition.js +120 -0
  95. package/lib/chevre/repo/order.d.ts +55 -3
  96. package/lib/chevre/repo/order.js +56 -5
  97. package/lib/chevre/repo/reservation.d.ts +12 -4
  98. package/lib/chevre/repo/reservation.js +16 -44
  99. package/lib/chevre/repo/seller.js +19 -19
  100. package/lib/chevre/repo/task.d.ts +42 -2
  101. package/lib/chevre/repo/task.js +90 -9
  102. package/lib/chevre/repo/transaction.d.ts +23 -3
  103. package/lib/chevre/repo/transaction.js +174 -54
  104. package/lib/chevre/repository.d.ts +5 -2
  105. package/lib/chevre/repository.js +8 -4
  106. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  107. package/lib/chevre/service/aggregation/system.js +101 -89
  108. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
  109. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
  110. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  111. package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
  112. package/lib/chevre/service/assetTransaction/pay.js +18 -32
  113. package/lib/chevre/service/assetTransaction/refund.js +1 -23
  114. package/lib/chevre/service/assetTransaction/registerService.js +1 -25
  115. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
  116. package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
  117. package/lib/chevre/service/assetTransaction/reserve.d.ts +10 -1
  118. package/lib/chevre/service/assetTransaction/reserve.js +85 -69
  119. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  120. package/lib/chevre/service/assetTransaction.js +9 -5
  121. package/lib/chevre/service/event.js +3 -1
  122. package/lib/chevre/service/notification/factory.js +2 -2
  123. package/lib/chevre/service/notification.d.ts +3 -1
  124. package/lib/chevre/service/notification.js +41 -7
  125. package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
  126. package/lib/chevre/service/offer/event/authorize.js +8 -2
  127. package/lib/chevre/service/offer/event/factory.d.ts +3 -0
  128. package/lib/chevre/service/offer/event/factory.js +16 -5
  129. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  130. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  131. package/lib/chevre/service/offer.js +1 -1
  132. package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
  133. package/lib/chevre/service/order/deleteOrder.js +8 -8
  134. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
  135. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
  136. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
  137. package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
  138. package/lib/chevre/service/order/onOrderUpdated.js +22 -0
  139. package/lib/chevre/service/order/placeOrder.d.ts +1 -0
  140. package/lib/chevre/service/order/placeOrder.js +41 -24
  141. package/lib/chevre/service/order/returnOrder.d.ts +1 -0
  142. package/lib/chevre/service/order/returnOrder.js +7 -12
  143. package/lib/chevre/service/order/sendOrder.d.ts +1 -0
  144. package/lib/chevre/service/order/sendOrder.js +7 -10
  145. package/lib/chevre/service/order.d.ts +2 -1
  146. package/lib/chevre/service/order.js +3 -1
  147. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  148. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  149. package/lib/chevre/service/payment/any.d.ts +9 -5
  150. package/lib/chevre/service/payment/any.js +80 -18
  151. package/lib/chevre/service/payment/creditCard.d.ts +1 -1
  152. package/lib/chevre/service/payment/creditCard.js +21 -15
  153. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +7 -6
  154. package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
  155. package/lib/chevre/service/payment/movieTicket/validation.js +54 -31
  156. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  157. package/lib/chevre/service/payment/movieTicket.js +5 -4
  158. package/lib/chevre/service/product.js +1 -5
  159. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  160. package/lib/chevre/service/report/telemetry.js +21 -24
  161. package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
  162. package/lib/chevre/service/reserve/cancelReservation.js +147 -139
  163. package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
  164. package/lib/chevre/service/reserve/checkInReservation.js +77 -3
  165. package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
  166. package/lib/chevre/service/reserve/confirmReservation.js +125 -58
  167. package/lib/chevre/service/reserve/factory.d.ts +1 -1
  168. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
  169. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
  170. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  171. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  172. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  173. package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
  174. package/lib/chevre/service/reserve/useReservation.js +61 -71
  175. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
  176. package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
  177. package/lib/chevre/service/reserve.d.ts +3 -2
  178. package/lib/chevre/service/reserve.js +4 -2
  179. package/lib/chevre/service/task/cancelPendingReservation.js +5 -1
  180. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  181. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  182. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  183. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
  184. package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
  185. package/lib/chevre/service/task/placeOrder.js +1 -1
  186. package/lib/chevre/service/task/reserve.js +10 -7
  187. package/lib/chevre/service/task/returnOrder.js +1 -1
  188. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  189. package/lib/chevre/service/task/sendOrder.js +1 -1
  190. package/lib/chevre/service/task/useReservation.d.ts +7 -0
  191. package/lib/chevre/service/task/useReservation.js +36 -0
  192. package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
  193. package/lib/chevre/service/task.d.ts +9 -0
  194. package/lib/chevre/service/task.js +43 -4
  195. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  196. package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
  197. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  198. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  199. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  200. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  201. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  202. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -2
  203. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  204. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  205. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  206. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  207. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  208. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  209. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  210. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  211. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  212. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  213. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  214. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  215. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  216. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  217. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  218. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  219. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
  220. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  221. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  222. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
  223. package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
  224. package/lib/chevre/service/transaction/returnOrder.js +225 -35
  225. package/lib/chevre/service/transaction.d.ts +8 -13
  226. package/lib/chevre/service/transaction.js +12 -145
  227. package/lib/chevre/settings.d.ts +4 -1
  228. package/lib/chevre/settings.js +15 -5
  229. package/package.json +5 -5
  230. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  231. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  232. package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
  233. package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
  234. package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
  235. 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, _17, _18, _19, _20, _21;
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,27 @@ 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
+ }
249
+ const objectSubReservationSeatNumberEq = (_13 = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.reservations) === null || _10 === void 0 ? void 0 : _10.reservedTicket) === null || _11 === void 0 ? void 0 : _11.ticketedSeat) === null || _12 === void 0 ? void 0 : _12.seatNumber) === null || _13 === void 0 ? void 0 : _13.$eq;
250
+ if (typeof objectSubReservationSeatNumberEq === 'string') {
251
+ andConditions.push({
252
+ 'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
253
+ $exists: true,
254
+ $eq: objectSubReservationSeatNumberEq
255
+ }
256
+ });
257
+ }
220
258
  break;
221
259
  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;
260
+ const objectItemOfferedServiceOutputIdentifierEq = (_17 = (_16 = (_15 = (_14 = params.object) === null || _14 === void 0 ? void 0 : _14.itemOffered) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.identifier) === null || _17 === void 0 ? void 0 : _17.$eq;
223
261
  if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
224
262
  andConditions.push({
225
263
  'object.itemOffered.serviceOutput.identifier': {
@@ -228,7 +266,7 @@ class MongoRepository {
228
266
  }
229
267
  });
230
268
  }
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;
269
+ const objectItemOfferedServiceOutputIdentifierIn = (_21 = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
232
270
  if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
233
271
  andConditions.push({
234
272
  'object.itemOffered.serviceOutput.identifier': {
@@ -247,7 +285,9 @@ class MongoRepository {
247
285
  */
248
286
  start(params) {
249
287
  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 }))
288
+ return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
289
+ actionStatus: factory.actionStatusType.PotentialActionStatus
290
+ }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
251
291
  .then((doc) => doc.toObject());
252
292
  });
253
293
  }
@@ -277,26 +317,24 @@ class MongoRepository {
277
317
  return doc.toObject();
278
318
  });
279
319
  }
280
- /**
281
- * 取引を確定する
282
- */
283
320
  addReservations(params) {
321
+ var _a;
284
322
  return __awaiter(this, void 0, void 0, function* () {
285
323
  const doc = yield this.transactionModel.findOneAndUpdate({
286
- _id: params.id,
287
- typeOf: params.typeOf,
288
- status: factory.transactionStatusType.InProgress
289
- }, {
290
- 'object.acceptedOffer': params.object.acceptedOffer,
324
+ _id: { $eq: params.id },
325
+ typeOf: { $eq: params.typeOf },
326
+ status: { $eq: factory.transactionStatusType.InProgress }
327
+ }, Object.assign({ 'object.acceptedOffer': params.object.acceptedOffer,
291
328
  // 念のため残す(2021/10/14)が、そのうち削除
292
329
  // 冗長なので削除(2021/10/19~)
293
330
  // 'object.event': params.object.reservationFor,
294
- 'object.reservationFor': params.object.reservationFor,
331
+ 'object.reservationFor': params.object.reservationFor,
295
332
  // 念のため残す(2021/10/14)が、そのうち削除
296
333
  // 冗長なので削除(2021/10/19~)
297
334
  // 'object.reservations': params.object.subReservation,
298
- 'object.subReservation': params.object.subReservation
299
- }, { new: true })
335
+ 'object.subReservation': params.object.subReservation }, (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
336
+ ? { 'object.issuedThrough': params.object.issuedThrough }
337
+ : undefined), { new: true })
300
338
  .exec();
301
339
  if (doc === null) {
302
340
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -308,36 +346,40 @@ class MongoRepository {
308
346
  * 取引を確定する
309
347
  */
310
348
  confirm(params) {
349
+ var _a, _b;
311
350
  return __awaiter(this, void 0, void 0, function* () {
312
351
  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 })
352
+ _id: { $eq: params.id },
353
+ typeOf: { $eq: params.typeOf },
354
+ status: { $eq: factory.transactionStatusType.InProgress }
355
+ }, 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')
356
+ ? { 'object.underName': params.object.underName }
357
+ : undefined), {
358
+ new: true,
359
+ projection: { _id: 1 }
360
+ })
322
361
  .exec();
323
362
  // NotFoundであれば取引状態確認
324
363
  if (doc === null) {
325
364
  const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
326
365
  if (transaction.status === factory.transactionStatusType.Confirmed) {
327
- // すでに確定済の場合
328
- return transaction;
366
+ // すでに確定済の場合スルー
329
367
  }
330
368
  else if (transaction.status === factory.transactionStatusType.Expired) {
331
- throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
369
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
332
370
  }
333
371
  else if (transaction.status === factory.transactionStatusType.Canceled) {
334
- throw new factory.errors.Argument('Transaction id', 'Transaction already canceled');
372
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
335
373
  }
336
374
  else {
337
375
  throw new factory.errors.NotFound(this.transactionModel.modelName);
338
376
  }
339
377
  }
340
- return doc.toObject();
378
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
379
+ id: params.id,
380
+ typeOf: params.typeOf,
381
+ status: factory.transactionStatusType.Confirmed
382
+ });
341
383
  });
342
384
  }
343
385
  /**
@@ -345,23 +387,42 @@ class MongoRepository {
345
387
  */
346
388
  startAndConfirm(params) {
347
389
  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 }))
390
+ const startDate = new Date();
391
+ const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
392
+ actionStatus: factory.actionStatusType.PotentialActionStatus
393
+ }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
349
394
  .then((doc) => doc.toObject());
395
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
396
+ id: params.id,
397
+ typeOf: params.typeOf,
398
+ status: factory.transactionStatusType.Confirmed
399
+ });
400
+ return confirmedTransaction;
350
401
  });
351
402
  }
352
403
  /**
353
404
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
354
405
  */
355
406
  startExportTasks(params) {
356
- var _a, _b, _c;
407
+ var _a, _b;
357
408
  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 })
409
+ switch (params.status) {
410
+ case factory.transactionStatusType.InProgress:
411
+ throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
412
+ default:
413
+ // no op
414
+ }
415
+ const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
416
+ 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), {
417
+ 'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
418
+ 'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
419
+ 'tasksExportAction.startDate': new Date(),
420
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
421
+ }, { new: true })
422
+ .select({
423
+ _id: 1,
424
+ typeOf: 1
425
+ })
365
426
  .exec()
366
427
  // tslint:disable-next-line:no-null-keyword
367
428
  .then((doc) => (doc === null) ? null : doc.toObject());
@@ -374,17 +435,74 @@ class MongoRepository {
374
435
  */
375
436
  reexportTasks(params) {
376
437
  return __awaiter(this, void 0, void 0, function* () {
377
- yield this.transactionModel.updateMany({
378
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
438
+ const reexportingTransactions = yield this.transactionModel.find({
439
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
379
440
  updatedAt: {
380
441
  $lt: moment()
381
442
  .add(-params.intervalInMinutes, 'minutes')
382
443
  .toDate()
383
444
  }
384
- }, {
385
- tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
386
445
  })
446
+ .select({
447
+ _id: 1,
448
+ typeOf: 1,
449
+ status: 1
450
+ })
451
+ .setOptions({ maxTimeMS: 10000 })
387
452
  .exec();
453
+ if (reexportingTransactions.length > 0) {
454
+ for (const reexportingTransaction of reexportingTransactions) {
455
+ yield this.transactionModel.updateOne({
456
+ _id: { $eq: reexportingTransaction.id },
457
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
458
+ }, {
459
+ tasksExportAction: {
460
+ actionStatus: factory.actionStatusType.PotentialActionStatus
461
+ },
462
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
463
+ })
464
+ .exec();
465
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
466
+ id: reexportingTransaction.id,
467
+ typeOf: reexportingTransaction.typeOf,
468
+ status: reexportingTransaction.status
469
+ });
470
+ }
471
+ }
472
+ });
473
+ }
474
+ /**
475
+ * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
476
+ */
477
+ exportTasks(params) {
478
+ return __awaiter(this, void 0, void 0, function* () {
479
+ const delayedTransactions = yield this.transactionModel.find({
480
+ status: { $in: params.status.$in },
481
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
482
+ endDate: {
483
+ $exists: true,
484
+ $lt: moment(params.now)
485
+ .add(-params.delayInSeconds, 'seconds')
486
+ .toDate()
487
+ }
488
+ })
489
+ .select({
490
+ _id: 1,
491
+ typeOf: 1,
492
+ status: 1
493
+ })
494
+ .setOptions({ maxTimeMS: 10000 })
495
+ .exec();
496
+ if (delayedTransactions.length > 0) {
497
+ delayedTransactions.forEach((delayedTransaction) => {
498
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
499
+ id: delayedTransaction.id,
500
+ typeOf: delayedTransaction.typeOf,
501
+ status: delayedTransaction.status
502
+ });
503
+ });
504
+ }
505
+ return delayedTransactions;
388
506
  });
389
507
  }
390
508
  /**
@@ -393,10 +511,15 @@ class MongoRepository {
393
511
  */
394
512
  setTasksExportedById(params) {
395
513
  return __awaiter(this, void 0, void 0, function* () {
396
- yield this.transactionModel.findByIdAndUpdate(params.id, {
514
+ const endDate = new Date();
515
+ yield this.transactionModel.updateOne({
516
+ _id: { $eq: params.id },
517
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
518
+ }, {
397
519
  tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
398
- tasksExportedAt: moment()
399
- .toDate()
520
+ tasksExportedAt: endDate,
521
+ 'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
522
+ 'tasksExportAction.endDate': endDate
400
523
  })
401
524
  .exec();
402
525
  });
@@ -406,15 +529,36 @@ class MongoRepository {
406
529
  */
407
530
  makeExpired(params) {
408
531
  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()
532
+ // IDをemitしたいのでまずリスト検索(2023-04-27~)
533
+ const expiringTransactions = yield this.transactionModel.find({
534
+ status: { $eq: factory.transactionStatusType.InProgress },
535
+ expires: { $lt: params.expires.$lt }
416
536
  })
537
+ .select({
538
+ _id: 1,
539
+ typeOf: 1
540
+ })
541
+ .setOptions({ maxTimeMS: 10000 })
417
542
  .exec();
543
+ if (expiringTransactions.length > 0) {
544
+ // ステータスと期限を見て更新
545
+ yield this.transactionModel.updateMany({
546
+ _id: { $in: expiringTransactions.map((t) => t.id) },
547
+ status: { $eq: factory.transactionStatusType.InProgress },
548
+ expires: { $lt: params.expires.$lt }
549
+ }, {
550
+ status: factory.transactionStatusType.Expired,
551
+ endDate: new Date()
552
+ })
553
+ .exec();
554
+ expiringTransactions.forEach((expiringTransaction) => {
555
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
556
+ id: expiringTransaction.id,
557
+ typeOf: expiringTransaction.typeOf,
558
+ status: factory.transactionStatusType.Expired
559
+ });
560
+ });
561
+ }
418
562
  });
419
563
  }
420
564
  /**
@@ -422,19 +566,18 @@ class MongoRepository {
422
566
  */
423
567
  cancel(params) {
424
568
  return __awaiter(this, void 0, void 0, function* () {
425
- const endDate = moment()
426
- .toDate();
569
+ const endDate = new Date();
427
570
  // 進行中ステータスの取引を中止する
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')
571
+ 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
572
  ? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
430
- : undefined), { status: factory.transactionStatusType.InProgress }), {
573
+ : undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
431
574
  status: factory.transactionStatusType.Canceled,
432
575
  endDate: endDate
433
576
  }, { new: true })
434
577
  .exec();
578
+ let transaction;
435
579
  // NotFoundであれば取引状態確認
436
580
  if (doc === null) {
437
- let transaction;
438
581
  if (typeof params.id === 'string') {
439
582
  transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
440
583
  }
@@ -448,20 +591,27 @@ class MongoRepository {
448
591
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
449
592
  }
450
593
  if (transaction.status === factory.transactionStatusType.Canceled) {
451
- // すでに中止済の場合
452
- return transaction;
594
+ // すでに中止済の場合スルー
453
595
  }
454
596
  else if (transaction.status === factory.transactionStatusType.Expired) {
455
- throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
597
+ throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
456
598
  }
457
599
  else if (transaction.status === factory.transactionStatusType.Confirmed) {
458
- throw new factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
600
+ throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
459
601
  }
460
602
  else {
461
603
  throw new factory.errors.NotFound(this.transactionModel.modelName);
462
604
  }
463
605
  }
464
- return doc.toObject();
606
+ else {
607
+ transaction = doc.toObject();
608
+ }
609
+ assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
610
+ id: transaction.id,
611
+ typeOf: params.typeOf,
612
+ status: factory.transactionStatusType.Canceled
613
+ });
614
+ return transaction;
465
615
  });
466
616
  }
467
617
  count(params) {
@@ -475,12 +625,30 @@ class MongoRepository {
475
625
  /**
476
626
  * 取引を検索する
477
627
  */
478
- search(params, projection) {
628
+ search(params, inclusion, exclusion) {
479
629
  var _a;
480
630
  return __awaiter(this, void 0, void 0, function* () {
481
631
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
632
+ let projection = {};
633
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
634
+ inclusion.forEach((field) => {
635
+ projection[field] = 1;
636
+ });
637
+ }
638
+ else {
639
+ projection = {
640
+ __v: 0,
641
+ createdAt: 0,
642
+ updatedAt: 0
643
+ };
644
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
645
+ exclusion.forEach((field) => {
646
+ projection[field] = 0;
647
+ });
648
+ }
649
+ }
482
650
  const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
483
- .select(Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
651
+ .select(projection);
484
652
  if (typeof params.limit === 'number' && params.limit > 0) {
485
653
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
486
654
  query.limit(params.limit)
@@ -523,9 +691,12 @@ class MongoRepository {
523
691
  /**
524
692
  * 特定の取引を更新する(汎用)
525
693
  */
526
- findByIdAndUpdate(params) {
694
+ findByIdAndUpdateInProgress(params) {
527
695
  return __awaiter(this, void 0, void 0, function* () {
528
- return this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, { new: true })
696
+ return this.transactionModel.findOneAndUpdate({
697
+ _id: { $eq: params.id },
698
+ status: { $eq: factory.transactionStatusType.InProgress }
699
+ }, params.update, { new: true })
529
700
  .exec()
530
701
  .then((doc) => {
531
702
  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>;