@chevre/domain 21.20.0-alpha.9 → 21.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/example/src/chevre/findTransactionById.ts +21 -0
  2. package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
  3. package/example/src/chevre/importOffersFromCOA.ts +2 -1
  4. package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
  5. package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
  6. package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
  7. package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
  8. package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
  9. package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
  10. package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
  11. package/example/src/chevre/retryTasks.ts +39 -0
  12. package/example/src/chevre/searchActions.ts +13 -7
  13. package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
  14. package/example/src/chevre/searchOrders.ts +13 -15
  15. package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
  16. package/example/src/chevre/sendOrder.ts +37 -0
  17. package/example/src/chevre/transaction/processPlaceOrder.ts +2 -1
  18. package/example/src/verifyToken.ts +44 -0
  19. package/lib/chevre/credentials.d.ts +2 -0
  20. package/lib/chevre/credentials.js +4 -2
  21. package/lib/chevre/errorHandler.js +3 -0
  22. package/lib/chevre/factory/order.d.ts +1 -0
  23. package/lib/chevre/factory/order.js +2 -1
  24. package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
  25. package/lib/chevre/factory/transaction.d.ts +10 -1
  26. package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
  27. package/lib/chevre/repo/acceptedOffer.js +100 -4
  28. package/lib/chevre/repo/accountingReport.d.ts +33 -7
  29. package/lib/chevre/repo/accountingReport.js +157 -5
  30. package/lib/chevre/repo/action.d.ts +32 -8
  31. package/lib/chevre/repo/action.js +114 -54
  32. package/lib/chevre/repo/event.d.ts +20 -0
  33. package/lib/chevre/repo/event.js +22 -0
  34. package/lib/chevre/repo/member.d.ts +8 -1
  35. package/lib/chevre/repo/member.js +7 -1
  36. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
  37. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
  39. package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
  40. package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
  41. package/lib/chevre/repo/offer.d.ts +42 -0
  42. package/lib/chevre/repo/offer.js +35 -0
  43. package/lib/chevre/repo/order.js +43 -20
  44. package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
  45. package/lib/chevre/repo/orderInTransaction.js +164 -0
  46. package/lib/chevre/repo/paymentServiceProvider.js +2 -1
  47. package/lib/chevre/repo/person.js +1 -4
  48. package/lib/chevre/repo/task.d.ts +26 -3
  49. package/lib/chevre/repo/task.js +61 -46
  50. package/lib/chevre/repo/transaction.d.ts +2 -2
  51. package/lib/chevre/repo/transaction.js +13 -36
  52. package/lib/chevre/repository.d.ts +5 -0
  53. package/lib/chevre/repository.js +15 -2
  54. package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
  55. package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
  57. package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
  58. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
  59. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
  60. package/lib/chevre/service/assetTransaction/pay.d.ts +21 -1
  61. package/lib/chevre/service/assetTransaction/pay.js +64 -23
  62. package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
  63. package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
  64. package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
  65. package/lib/chevre/service/code.js +1 -1
  66. package/lib/chevre/service/delivery.js +2 -2
  67. package/lib/chevre/service/event/createEvent.js +1 -1
  68. package/lib/chevre/service/event.js +16 -24
  69. package/lib/chevre/service/moneyTransfer.js +1 -1
  70. package/lib/chevre/service/notification.js +71 -66
  71. package/lib/chevre/service/offer/any.d.ts +35 -0
  72. package/lib/chevre/service/offer/any.js +67 -0
  73. package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
  74. package/lib/chevre/service/offer/event/authorize.js +27 -17
  75. package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
  76. package/lib/chevre/service/offer/event/cancel.js +13 -1
  77. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  78. package/lib/chevre/service/offer/event/factory.js +11 -22
  79. package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
  80. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  81. package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
  82. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
  83. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
  84. package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
  85. package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
  86. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
  87. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
  88. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
  89. package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
  90. package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
  91. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
  92. package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
  93. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
  94. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
  95. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
  96. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  97. package/lib/chevre/service/offer/product/factory.js +2 -5
  98. package/lib/chevre/service/offer/product.d.ts +2 -0
  99. package/lib/chevre/service/offer/product.js +11 -23
  100. package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
  101. package/lib/chevre/service/order/confirmPayTransaction.js +4 -4
  102. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
  103. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
  104. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
  109. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
  110. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
  111. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
  112. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
  113. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
  114. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
  115. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
  116. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
  117. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
  118. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
  119. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
  120. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
  121. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
  122. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
  123. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  124. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
  125. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
  126. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
  127. package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
  128. package/lib/chevre/service/order/placeOrder.d.ts +3 -1
  129. package/lib/chevre/service/order/placeOrder.js +157 -50
  130. package/lib/chevre/service/order/returnOrder.js +25 -16
  131. package/lib/chevre/service/order/sendOrder.d.ts +5 -0
  132. package/lib/chevre/service/order/sendOrder.js +67 -33
  133. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  134. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
  135. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
  136. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
  137. package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
  138. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
  139. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  140. package/lib/chevre/service/payment/any.d.ts +6 -2
  141. package/lib/chevre/service/payment/any.js +3 -2
  142. package/lib/chevre/service/payment/creditCard.d.ts +1 -1
  143. package/lib/chevre/service/payment/creditCard.js +62 -68
  144. package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
  145. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  146. package/lib/chevre/service/payment/movieTicket.js +1 -1
  147. package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
  148. package/lib/chevre/service/payment.d.ts +5 -0
  149. package/lib/chevre/service/payment.js +40 -5
  150. package/lib/chevre/service/product.js +1 -1
  151. package/lib/chevre/service/reserve/cancelReservation.js +2 -2
  152. package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
  153. package/lib/chevre/service/reserve/checkInReservation.js +6 -5
  154. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  155. package/lib/chevre/service/reserve/factory.js +0 -8
  156. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
  157. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
  158. package/lib/chevre/service/reserve/searchByOrder.js +2 -1
  159. package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
  160. package/lib/chevre/service/reserve/useReservation.js +10 -9
  161. package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
  162. package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
  163. package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
  164. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
  165. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
  166. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
  167. package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
  168. package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
  169. package/lib/chevre/service/task/createAccountingReport.js +80 -0
  170. package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
  171. package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
  172. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
  173. package/lib/chevre/service/task/pay.js +6 -0
  174. package/lib/chevre/service/task/placeOrder.js +9 -10
  175. package/lib/chevre/service/task/returnOrder.js +0 -3
  176. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  177. package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
  178. package/lib/chevre/service/task/sendOrder.js +8 -4
  179. package/lib/chevre/service/task/useReservation.js +1 -1
  180. package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
  181. package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
  182. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
  183. package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
  184. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
  185. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
  186. package/lib/chevre/service/transaction/placeOrder.js +2 -1
  187. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
  188. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
  189. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  190. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
  191. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  192. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
  193. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
  194. package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
  195. package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
  196. package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
  197. package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
  198. package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
  199. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
  200. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
  201. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
  202. package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
  203. package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
  204. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
  205. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
  206. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
  207. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
  208. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
  209. package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
  210. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
  211. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
  212. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
  213. package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
  214. package/lib/chevre/service/transaction/returnOrder.js +3 -10
  215. package/lib/chevre/service.js +0 -10
  216. package/lib/chevre/settings.d.ts +7 -3
  217. package/lib/chevre/settings.js +13 -4
  218. package/package.json +5 -9
  219. package/example/src/chevre/cleanAccountingReports.ts +0 -57
  220. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
  221. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
  222. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
  223. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
  224. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
  225. package/lib/chevre/service/util.d.ts +0 -19
  226. package/lib/chevre/service/util.js +0 -126
@@ -128,7 +128,7 @@ function deleteResourcesByScreeningEventSeries(params) {
128
128
  }
129
129
  throw error;
130
130
  }
131
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
131
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
132
132
  }
133
133
  });
134
134
  }
@@ -162,7 +162,7 @@ function deleteResourcesByScreeningRoom(params) {
162
162
  }
163
163
  throw error;
164
164
  }
165
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
165
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
166
166
  });
167
167
  }
168
168
  function deleteResourcesByMovieTheater(params) {
@@ -206,7 +206,7 @@ function deleteResourcesByMovieTheater(params) {
206
206
  }
207
207
  throw error;
208
208
  }
209
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
209
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
210
210
  }
211
211
  });
212
212
  }
@@ -269,7 +269,7 @@ function deleteResourcesBySeller(params) {
269
269
  }
270
270
  throw error;
271
271
  }
272
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
272
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
273
273
  }
274
274
  });
275
275
  }
@@ -309,7 +309,7 @@ function deleteResourcesByAggregateOffer(params) {
309
309
  }
310
310
  throw error;
311
311
  }
312
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
312
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
313
313
  }
314
314
  });
315
315
  }
@@ -369,7 +369,7 @@ function deleteResourcesByOfferCatalog(params) {
369
369
  }
370
370
  throw error;
371
371
  }
372
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
372
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
373
373
  }
374
374
  });
375
375
  }
@@ -411,7 +411,7 @@ function deleteResourcesByProduct(params) {
411
411
  }
412
412
  throw error;
413
413
  }
414
- yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
414
+ yield repos.action.completeWithVoid({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
415
415
  }
416
416
  });
417
417
  }
@@ -10,9 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
+ const acceptedOffer_1 = require("../../repo/acceptedOffer");
13
14
  const accountingReport_1 = require("../../repo/accountingReport");
14
15
  const action_1 = require("../../repo/action");
16
+ const assetTransaction_1 = require("../../repo/assetTransaction");
15
17
  const event_1 = require("../../repo/event");
18
+ const order_1 = require("../../repo/order");
16
19
  const paymentService_1 = require("../../repo/paymentService");
17
20
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
18
21
  const product_1 = require("../../repo/product");
@@ -26,9 +29,12 @@ const PaymentService = require("../payment");
26
29
  function call(data) {
27
30
  return (settings) => __awaiter(this, void 0, void 0, function* () {
28
31
  yield PaymentService.pay(data)({
32
+ acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
29
33
  accountingReport: new accountingReport_1.MongoRepository(settings.connection),
30
34
  action: new action_1.MongoRepository(settings.connection),
35
+ assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
31
36
  event: new event_1.MongoRepository(settings.connection),
37
+ order: new order_1.MongoRepository(settings.connection),
32
38
  paymentAccepted: new sellerPaymentAccepted_1.MongoRepository(settings.connection),
33
39
  paymentService: new paymentService_1.MongoRepository(settings.connection),
34
40
  paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(settings.connection),
@@ -14,6 +14,7 @@ const acceptedOffer_1 = require("../../repo/acceptedOffer");
14
14
  const accountingReport_1 = require("../../repo/accountingReport");
15
15
  const action_1 = require("../../repo/action");
16
16
  const order_1 = require("../../repo/order");
17
+ const orderInTransaction_1 = require("../../repo/orderInTransaction");
17
18
  const task_1 = require("../../repo/task");
18
19
  const transaction_1 = require("../../repo/transaction");
19
20
  const OrderService = require("../order");
@@ -21,17 +22,15 @@ const OrderService = require("../order");
21
22
  * タスク実行関数
22
23
  */
23
24
  function call(data) {
24
- return (settings) => __awaiter(this, void 0, void 0, function* () {
25
- // if (settings.redisClient === undefined) {
26
- // throw new factory.errors.Argument('settings', 'redisClient required');
27
- // }
25
+ return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
28
26
  yield OrderService.placeOrder(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
29
- acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
30
- accountingReport: new accountingReport_1.MongoRepository(settings.connection),
31
- action: new action_1.MongoRepository(settings.connection),
32
- order: new order_1.MongoRepository(settings.connection),
33
- task: new task_1.MongoRepository(settings.connection),
34
- transaction: new transaction_1.MongoRepository(settings.connection)
27
+ acceptedOffer: new acceptedOffer_1.MongoRepository(connection),
28
+ accountingReport: new accountingReport_1.MongoRepository(connection),
29
+ action: new action_1.MongoRepository(connection),
30
+ order: new order_1.MongoRepository(connection),
31
+ orderInTransaction: new orderInTransaction_1.MongoRepository(connection),
32
+ task: new task_1.MongoRepository(connection),
33
+ transaction: new transaction_1.MongoRepository(connection)
35
34
  });
36
35
  });
37
36
  }
@@ -22,9 +22,6 @@ const returnOrder_1 = require("../order/returnOrder");
22
22
  */
23
23
  function call(data) {
24
24
  return (settings) => __awaiter(this, void 0, void 0, function* () {
25
- // if (settings.redisClient === undefined) {
26
- // throw new factory.errors.Argument('settings', 'redisClient required');
27
- // }
28
25
  yield (0, returnOrder_1.returnOrder)(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
29
26
  acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
30
27
  action: new action_1.MongoRepository(settings.connection),
@@ -111,7 +111,7 @@ function returnPayTransaction(params) {
111
111
  throw error;
112
112
  }
113
113
  const result = { refundTransaction };
114
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
114
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
115
115
  // 潜在アクション
116
116
  yield onRefund(refundActionAttributes)({ task: repos.task });
117
117
  });
@@ -22,7 +22,8 @@ const CancelReservationTransactionService = require("../assetTransaction/cancelR
22
22
  const credentials_1 = require("../../credentials");
23
23
  const coaAuthClient = new COA.auth.RefreshToken({
24
24
  endpoint: credentials_1.credentials.coa.endpoint,
25
- refreshToken: credentials_1.credentials.coa.refreshToken
25
+ refreshToken: credentials_1.credentials.coa.refreshToken,
26
+ useFetch: credentials_1.credentials.coa.useFetch
26
27
  });
27
28
  /**
28
29
  * タスク実行関数
@@ -68,7 +69,7 @@ function cancelReservation(params) {
68
69
  }
69
70
  throw error;
70
71
  }
71
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: {} });
72
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: {} });
72
73
  });
73
74
  }
74
75
  function processCancelReservation4coa(params) {
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
+ const factory = require("../../factory");
13
14
  const acceptedOffer_1 = require("../../repo/acceptedOffer");
14
15
  const action_1 = require("../../repo/action");
15
16
  const order_1 = require("../../repo/order");
@@ -22,10 +23,13 @@ const OrderService = require("../order");
22
23
  */
23
24
  function call(data) {
24
25
  return (settings) => __awaiter(this, void 0, void 0, function* () {
25
- // if (settings.redisClient === undefined) {
26
- // throw new factory.errors.Argument('settings', 'redisClient required');
27
- // }
28
- yield OrderService.sendOrder(Object.assign(Object.assign({}, data), { useOnOrderStatusChanged: true }))({
26
+ var _a;
27
+ yield OrderService.sendOrder(Object.assign(Object.assign({}, data), { object: Object.assign(Object.assign({}, data.object), { previousOrderStatus: (typeof data.object.previousOrderStatus === 'string')
28
+ ? data.object.previousOrderStatus
29
+ : factory.orderStatus.OrderInTransit, acceptedOffers: (typeof ((_a = data.object.acceptedOffers) === null || _a === void 0 ? void 0 : _a.limit) === 'number')
30
+ ? data.object.acceptedOffers
31
+ : { limit: 50, page: 1 } // 互換性維持対応として指定がない場合に対応
32
+ }), useOnOrderStatusChanged: true }))({
29
33
  acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
30
34
  action: new action_1.MongoRepository(settings.connection),
31
35
  order: new order_1.MongoRepository(settings.connection),
@@ -24,7 +24,7 @@ function call(data) {
24
24
  var _a, _b;
25
25
  yield (0, reserve_1.useReservation)(Object.assign(Object.assign({ project: data.project, agent: data.agent, object: data.object,
26
26
  // タスク作成前に検証済なので検証不要
27
- verifyToken: false, reserveIfNotYet: data.reserveIfNotYet }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
27
+ verifyToken: false }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
28
28
  action: new action_1.MongoRepository(settings.connection),
29
29
  assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
30
30
  order: new order_1.MongoRepository(settings.connection),
@@ -13,6 +13,7 @@ exports.call = void 0;
13
13
  const factory = require("../../factory");
14
14
  const action_1 = require("../../repo/action");
15
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const orderInTransaction_1 = require("../../repo/orderInTransaction");
16
17
  const offer_1 = require("../../repo/rateLimit/offer");
17
18
  const reservation_1 = require("../../repo/reservation");
18
19
  const stockHolder_1 = require("../../repo/stockHolder");
@@ -27,19 +28,14 @@ function call(data) {
27
28
  if (settings.redisClient === undefined) {
28
29
  throw new factory.errors.Argument('settings', 'redisClient required');
29
30
  }
30
- const actionRepo = new action_1.MongoRepository(settings.connection);
31
- const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
32
- const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
33
- const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
34
- const reservationRepo = new reservation_1.MongoRepository(settings.connection);
35
- const taskRepo = new task_1.MongoRepository(settings.connection);
36
31
  yield EventOfferService.voidTransaction(data)({
37
- action: actionRepo,
38
- assetTransaction: assetTransactionRepo,
39
- stockHolder: stockHolderRepo,
40
- offerRateLimit: offerRateLimitRepo,
41
- reservation: reservationRepo,
42
- task: taskRepo,
32
+ action: new action_1.MongoRepository(settings.connection),
33
+ assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
34
+ stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
35
+ offerRateLimit: new offer_1.RedisRepository(settings.redisClient),
36
+ orderInTransaction: new orderInTransaction_1.MongoRepository(settings.connection),
37
+ reservation: new reservation_1.MongoRepository(settings.connection),
38
+ task: new task_1.MongoRepository(settings.connection),
43
39
  transaction: new transaction_1.MongoRepository(settings.connection)
44
40
  });
45
41
  });
@@ -261,7 +261,7 @@ function deleteTransactionById(params) {
261
261
  deletedReservationNumbers,
262
262
  deleteActionResult
263
263
  };
264
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
264
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
265
265
  });
266
266
  }
267
267
  function deleteReservationsByPlaceOrder(params) {
@@ -20,33 +20,17 @@ function createMoneyTransferActions(params) {
20
20
  var _a;
21
21
  const actionResult = a.result;
22
22
  const pendingTransaction = (_a = a.object.itemOffered.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction;
23
- // const fromLocation = params.transaction.object.fromLocation;
24
23
  if (actionResult !== undefined && pendingTransaction !== undefined) {
25
24
  moneyTransferActions.push({
26
25
  project: params.transaction.project,
27
26
  typeOf: factory.actionType.ConfirmAction,
28
27
  object: {
29
- pendingTransaction: { id: actionResult.responseBody.id },
28
+ // pendingTransaction: { id: actionResult.responseBody.id },
30
29
  transactionNumber: pendingTransaction.transactionNumber,
31
30
  typeOf: factory.assetTransactionType.MoneyTransfer
32
31
  },
33
- // agent: Projectに統一(2022-05-16~)
34
32
  agent: params.transaction.project,
35
- // agent: params.transaction.agent,
36
- // ↓recipient廃止(2022-05-16~)
37
- // recipient: a.recipient,
38
- // amount: {
39
- // typeOf: 'MonetaryAmount',
40
- // value: a.object.itemOffered.amount.value,
41
- // currency: a.object.itemOffered.amount.currency
42
- // },
43
- // fromLocation: fromLocation,
44
- // toLocation: params.transaction.object.toLocation,
45
- purpose: {
46
- typeOf: params.transaction.typeOf,
47
- id: params.transaction.id
48
- }
49
- // ...(typeof a.object.description === 'string') ? { description: a.object.description } : {}
33
+ purpose: { typeOf: params.transaction.typeOf, id: params.transaction.id }
50
34
  });
51
35
  }
52
36
  });
@@ -233,9 +233,10 @@ function processAuthorizePaymentCard(params) {
233
233
  price: 0,
234
234
  priceCurrency: factory.priceCurrency.JPY,
235
235
  // requestBody: requestBody,
236
- responseBody: responseBody
236
+ responseBody: responseBody,
237
+ acceptedOffers: [] // PlaceOrderではないのでacceptedOffersとしては空
237
238
  };
238
- return repos.action.complete({ typeOf: action.typeOf, id: action.id, result });
239
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
239
240
  });
240
241
  }
241
242
  function createAuthorizeMoneyTransferOfferActionAttributes(params) {
@@ -246,6 +247,10 @@ function createAuthorizeMoneyTransferOfferActionAttributes(params) {
246
247
  return {
247
248
  project: transaction.project,
248
249
  typeOf: factory.actionType.AuthorizeAction,
250
+ instrument: {
251
+ typeOf: factory.assetTransactionType.MoneyTransfer,
252
+ transactionNumber
253
+ },
249
254
  object: {
250
255
  project: { typeOf: transaction.project.typeOf, id: transaction.project.id },
251
256
  typeOf: factory.offerType.Offer,
@@ -472,10 +477,6 @@ function validateToLocation(project, toLocationBeforeStart, issuedThrough) {
472
477
  if (order === undefined) {
473
478
  throw new factory.errors.NotFound('Order');
474
479
  }
475
- // OrderDeliveredのみ許可
476
- // if (order.orderStatus !== chevre.factory.orderStatus.OrderDelivered) {
477
- // throw new chevre.factory.errors.Argument('fromLocation', `Invalid order status '${order.orderStatus}''`);
478
- // }
479
480
  let awardAccounts = [];
480
481
  const awardAccounsValue = (_b = (_a = order.identifier) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === order_1.AWARD_ACCOUNTS_IDENTIFIER_NAME)) === null || _b === void 0 ? void 0 : _b.value;
481
482
  if (typeof awardAccounsValue === 'string' && awardAccounsValue.length > 0) {
@@ -1,9 +1,9 @@
1
1
  import * as factory from '../../../../factory';
2
- export type IPlaceOrderTransactionAsInformObject = Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'id' | 'typeOf' | 'agent' | 'endDate' | 'expires' | 'project' | 'seller' | 'result' | 'startDate' | 'status'>;
2
+ export type IPlaceOrderTransactionAsInformObject = Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'id' | 'typeOf' | 'endDate' | 'project' | 'seller' | 'startDate' | 'status'>;
3
3
  /**
4
4
  * 取引のタスクを作成する
5
5
  */
6
6
  export declare function createTasks(params: {
7
- transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
7
+ transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'endDate' | 'id' | 'object' | 'project' | 'seller' | 'startDate' | 'status' | 'typeOf'>;
8
8
  runsAt: Date;
9
9
  }): factory.task.IAttributes<factory.taskName>[];
@@ -9,7 +9,6 @@ const settings_1 = require("../../../../settings");
9
9
  */
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  function createTasks(params) {
12
- var _a;
13
12
  const taskAttributes = [];
14
13
  const transaction = params.transaction;
15
14
  const taskRunsAt = params.runsAt;
@@ -18,12 +17,9 @@ function createTasks(params) {
18
17
  const informObject = {
19
18
  id: transaction.id,
20
19
  typeOf: transaction.typeOf,
21
- agent: transaction.agent,
22
20
  endDate: transaction.endDate,
23
- expires: transaction.expires,
24
21
  project: transaction.project,
25
22
  seller: transaction.seller,
26
- result: transaction.result,
27
23
  startDate: transaction.startDate,
28
24
  status: transaction.status
29
25
  };
@@ -121,25 +117,26 @@ function createTasks(params) {
121
117
  taskAttributes.push(...triggerWebhookTaskAttributes, deleteTransactionTask, voidPaymentTaskAttributes, voidReserveTaskAttributes);
122
118
  switch (transaction.status) {
123
119
  case factory.transactionStatusType.Confirmed:
124
- const potentialActions = transaction.potentialActions;
125
- if (potentialActions === undefined) {
126
- throw new factory.errors.NotFound('Transaction PotentialActions');
120
+ // const potentialActions = transaction.potentialActions;
121
+ // if (potentialActions === undefined) {
122
+ // throw new factory.errors.NotFound('Transaction PotentialActions');
123
+ // }
124
+ // const orderFromTransaction = transaction.result?.order;
125
+ // if (orderFromTransaction === undefined) {
126
+ // throw new factory.errors.NotFound('Transaction Result');
127
+ // }
128
+ const confirmationNumber = transaction.object.confirmationNumber;
129
+ if (typeof confirmationNumber !== 'string' || confirmationNumber.length === 0) {
130
+ throw new factory.errors.NotFound('transaction.object.confirmationNumber');
127
131
  }
128
- const orderFromTransaction = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
129
- if (orderFromTransaction === undefined) {
130
- throw new factory.errors.NotFound('Transaction Result');
132
+ const orderNumber = transaction.object.orderNumber;
133
+ if (typeof orderNumber !== 'string' || orderNumber.length === 0) {
134
+ throw new factory.errors.NotFound('transaction.object.orderNumber');
131
135
  }
132
- const orderActionAttributes = potentialActions.order;
136
+ // const orderActionAttributes = potentialActions.order;
133
137
  const placeOrderTaskData = {
134
- project: orderActionAttributes.project,
135
- object: {
136
- confirmationNumber: orderFromTransaction.confirmationNumber,
137
- orderNumber: orderActionAttributes.object.orderNumber
138
- }
139
- // 廃止(2023-08-21~)
140
- // ...(orderActionAttributes.potentialActions !== undefined)
141
- // ? { potentialActions: orderActionAttributes.potentialActions }
142
- // : undefined
138
+ project: transaction.project,
139
+ object: { confirmationNumber, orderNumber }
143
140
  };
144
141
  const placeOrderTaskAttributes = {
145
142
  project: transaction.project,
@@ -23,7 +23,8 @@ function exportTasksById(params) {
23
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
24
  const transaction = yield repos.transaction.findById({
25
25
  typeOf: factory.transactionType.PlaceOrder,
26
- id: params.id
26
+ id: params.id,
27
+ inclusion: ['endDate', 'id', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']
27
28
  });
28
29
  // タスク実行日時バッファの指定があれば調整
29
30
  let taskRunsAt = new Date();
@@ -0,0 +1,51 @@
1
+ import type { MongoRepository as ActionRepo } from '../../../repo/action';
2
+ import type { MongoRepository as CodeRepo } from '../../../repo/code';
3
+ import type { RedisRepository as ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
4
+ import type { MongoRepository as EmailMessageRepo } from '../../../repo/emailMessage';
5
+ import type { RedisRepository as OrderNumberRepo } from '../../../repo/orderNumber';
6
+ import type { MongoRepository as ProjectRepo } from '../../../repo/project';
7
+ import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
8
+ import * as factory from '../../../factory';
9
+ import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
10
+ interface IConfirmOperationRepos {
11
+ action: ActionRepo;
12
+ authorization: CodeRepo;
13
+ emailMessage?: EmailMessageRepo;
14
+ project: ProjectRepo;
15
+ transaction: TransactionRepo;
16
+ orderNumber: OrderNumberRepo;
17
+ confirmationNumber: ConfirmationNumberRepo;
18
+ }
19
+ type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
20
+ type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
21
+ options: {
22
+ /**
23
+ * 取引resultから注文オファーを作成するかどうか
24
+ */
25
+ ignoreAccpetedOffersFromResult: boolean;
26
+ /**
27
+ * 確定レスポンスに予約IDを含めるかどうか(ttts対応)
28
+ */
29
+ expectsReservationIds: boolean;
30
+ /**
31
+ * 同期的にに注文コードを発行する場合に指定
32
+ */
33
+ publishCodeExpiresInSeconds?: number;
34
+ };
35
+ };
36
+ /**
37
+ * 注文取引を確定する
38
+ */
39
+ declare function confirm(params: IConfirmParams): IConfirmOperation<{
40
+ order: factory.order.IOrder;
41
+ code?: string;
42
+ /**
43
+ * expectsReservationIdsの場合のみ
44
+ */
45
+ eventId?: string;
46
+ /**
47
+ * expectsReservationIdsの場合のみ
48
+ */
49
+ reservationIds?: string[];
50
+ }>;
51
+ export { confirm };