@chevre/domain 22.2.0-alpha.9 → 22.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/example/src/chevre/createProject.ts +19 -0
  2. package/example/src/chevre/findValidAuthorization.ts +1 -2
  3. package/example/src/chevre/migrateDeleteTransactionTasks.ts +1 -1
  4. package/example/src/chevre/{migrateMovieTheaterAdditionalProperties.ts → migrateRoomAdditionalProperties.ts} +17 -17
  5. package/example/src/chevre/migrateRoomSectionAdditionalProperties.ts +119 -0
  6. package/example/src/chevre/playAroundTicket.ts +3 -2
  7. package/example/src/chevre/processAction.ts +3 -1
  8. package/example/src/chevre/projectFields.ts +42 -0
  9. package/example/src/chevre/{projectEventFieldsById.ts → projectFieldsById.ts} +7 -12
  10. package/example/src/chevre/searchActionsByPurpose.ts +38 -0
  11. package/example/src/chevre/searchProjects.ts +9 -4
  12. package/example/src/chevre/searchSellersByAggregate.ts +3 -3
  13. package/example/src/chevre/searchTransactions.ts +1 -1
  14. package/example/src/chevre/unsetUnnecessaryFields.ts +2 -41
  15. package/lib/chevre/repo/accountTitle.d.ts +9 -3
  16. package/lib/chevre/repo/accountingReport.d.ts +2 -15
  17. package/lib/chevre/repo/action.d.ts +110 -47
  18. package/lib/chevre/repo/action.js +170 -133
  19. package/lib/chevre/repo/aggregateReservation.d.ts +1 -14
  20. package/lib/chevre/repo/assetTransaction.d.ts +134 -7
  21. package/lib/chevre/repo/assetTransaction.js +2 -2
  22. package/lib/chevre/repo/categoryCode.d.ts +14 -2
  23. package/lib/chevre/repo/categoryCode.js +47 -19
  24. package/lib/chevre/repo/comment.d.ts +5 -1
  25. package/lib/chevre/repo/creativeWork.d.ts +14 -2
  26. package/lib/chevre/repo/customer.d.ts +5 -1
  27. package/lib/chevre/repo/customerType.d.ts +1 -1
  28. package/lib/chevre/repo/event.d.ts +49 -2
  29. package/lib/chevre/repo/member.d.ts +5 -1
  30. package/lib/chevre/repo/merchantReturnPolicy.d.ts +22 -2
  31. package/lib/chevre/repo/message.d.ts +1 -15
  32. package/lib/chevre/repo/mongoose/schemas/account.d.ts +8 -3
  33. package/lib/chevre/repo/mongoose/schemas/account.js +1 -1
  34. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +8 -3
  35. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +2 -2
  36. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +8 -3
  37. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
  38. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +22 -3
  39. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -1
  40. package/lib/chevre/repo/mongoose/schemas/action.d.ts +8 -3
  41. package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
  42. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +14 -3
  43. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +2 -5
  44. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +8 -3
  45. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +12 -12
  46. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +11 -3
  47. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +1 -1
  48. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +22 -3
  49. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +1 -1
  50. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +7 -3
  51. package/lib/chevre/repo/mongoose/schemas/aggregation.js +2 -1
  52. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +10 -3
  53. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -1
  54. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +8 -3
  55. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
  56. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +8 -3
  57. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +22 -24
  58. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +8 -3
  59. package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
  60. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +10 -3
  61. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +2 -2
  62. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +8 -3
  63. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -1
  64. package/lib/chevre/repo/mongoose/schemas/customerType.d.ts +9 -3
  65. package/lib/chevre/repo/mongoose/schemas/customerType.js +1 -1
  66. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +8 -3
  67. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -1
  68. package/lib/chevre/repo/mongoose/schemas/event.d.ts +19 -3
  69. package/lib/chevre/repo/mongoose/schemas/event.js +1 -1
  70. package/lib/chevre/repo/mongoose/schemas/member.d.ts +8 -3
  71. package/lib/chevre/repo/mongoose/schemas/member.js +1 -1
  72. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +8 -3
  73. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -1
  74. package/lib/chevre/repo/mongoose/schemas/message.d.ts +23 -3
  75. package/lib/chevre/repo/mongoose/schemas/message.js +1 -1
  76. package/lib/chevre/repo/mongoose/schemas/note.d.ts +8 -3
  77. package/lib/chevre/repo/mongoose/schemas/note.js +1 -1
  78. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +12 -3
  79. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -1
  80. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +12 -3
  81. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
  82. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +8 -3
  83. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +1 -1
  84. package/lib/chevre/repo/mongoose/schemas/order.d.ts +10 -3
  85. package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
  86. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +10 -3
  87. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
  88. package/lib/chevre/repo/mongoose/schemas/paymentService.d.ts +10 -3
  89. package/lib/chevre/repo/mongoose/schemas/paymentService.js +13 -4
  90. package/lib/chevre/repo/mongoose/schemas/place.d.ts +16 -3
  91. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  92. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +11 -3
  93. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -1
  94. package/lib/chevre/repo/mongoose/schemas/product.d.ts +12 -3
  95. package/lib/chevre/repo/mongoose/schemas/product.js +6 -13
  96. package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +30 -3
  97. package/lib/chevre/repo/mongoose/schemas/productModel.js +1 -1
  98. package/lib/chevre/repo/mongoose/schemas/project.d.ts +12 -3
  99. package/lib/chevre/repo/mongoose/schemas/project.js +3 -3
  100. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +12 -3
  101. package/lib/chevre/repo/mongoose/schemas/reservation.js +5 -5
  102. package/lib/chevre/repo/mongoose/schemas/role.d.ts +9 -3
  103. package/lib/chevre/repo/mongoose/schemas/role.js +1 -1
  104. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +8 -3
  105. package/lib/chevre/repo/mongoose/schemas/seller.js +22 -24
  106. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +8 -3
  107. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
  108. package/lib/chevre/repo/mongoose/schemas/task.d.ts +8 -3
  109. package/lib/chevre/repo/mongoose/schemas/task.js +1 -1
  110. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +7 -3
  111. package/lib/chevre/repo/mongoose/schemas/telemetry.js +2 -1
  112. package/lib/chevre/repo/mongoose/schemas/ticket.d.ts +26 -3
  113. package/lib/chevre/repo/mongoose/schemas/ticket.js +1 -1
  114. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +8 -3
  115. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -2
  116. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +8 -3
  117. package/lib/chevre/repo/mongoose/schemas/trip.js +3 -3
  118. package/lib/chevre/repo/offer.d.ts +13 -4
  119. package/lib/chevre/repo/offerCatalog.d.ts +15 -2
  120. package/lib/chevre/repo/order.d.ts +13 -1
  121. package/lib/chevre/repo/ownershipInfo.d.ts +15 -3
  122. package/lib/chevre/repo/ownershipInfo.js +40 -11
  123. package/lib/chevre/repo/paymentService.d.ts +2 -2
  124. package/lib/chevre/repo/paymentService.js +108 -58
  125. package/lib/chevre/repo/paymentServiceProvider.d.ts +1 -10
  126. package/lib/chevre/repo/place/movieTheater.d.ts +54 -2
  127. package/lib/chevre/repo/priceSpecification.d.ts +42 -1
  128. package/lib/chevre/repo/product.d.ts +8 -3
  129. package/lib/chevre/repo/product.js +67 -33
  130. package/lib/chevre/repo/productModel.d.ts +1 -22
  131. package/lib/chevre/repo/project.d.ts +25 -5
  132. package/lib/chevre/repo/project.js +69 -28
  133. package/lib/chevre/repo/reservation.d.ts +35 -3
  134. package/lib/chevre/repo/reservation.js +1 -1
  135. package/lib/chevre/repo/role.d.ts +2 -9
  136. package/lib/chevre/repo/role.js +20 -10
  137. package/lib/chevre/repo/seller.d.ts +64 -14
  138. package/lib/chevre/repo/seller.js +61 -27
  139. package/lib/chevre/repo/task.d.ts +64 -3
  140. package/lib/chevre/repo/telemetry.d.ts +3 -2
  141. package/lib/chevre/repo/ticket.d.ts +4 -20
  142. package/lib/chevre/repo/ticket.js +23 -10
  143. package/lib/chevre/repo/transaction.d.ts +30 -14
  144. package/lib/chevre/repo/transaction.js +106 -77
  145. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
  146. package/lib/chevre/service/aggregation/event/findEventOffers.js +1 -1
  147. package/lib/chevre/service/aggregation/project.js +1 -1
  148. package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +1 -1
  149. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  150. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  151. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  152. package/lib/chevre/service/assetTransaction/pay.js +3 -3
  153. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  154. package/lib/chevre/service/assetTransaction/refund.js +3 -3
  155. package/lib/chevre/service/assetTransaction/registerService.js +4 -6
  156. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +9 -11
  157. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +1 -1
  158. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -3
  159. package/lib/chevre/service/code.d.ts +0 -4
  160. package/lib/chevre/service/code.js +22 -18
  161. package/lib/chevre/service/event.js +4 -4
  162. package/lib/chevre/service/moneyTransfer.js +3 -5
  163. package/lib/chevre/service/notification.js +2 -2
  164. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
  165. package/lib/chevre/service/offer/event/authorize/factory.js +16 -2
  166. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +2 -2
  167. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +3 -2
  168. package/lib/chevre/service/offer/event/authorize.d.ts +4 -2
  169. package/lib/chevre/service/offer/event/authorize.js +3 -2
  170. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  171. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -12
  172. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  173. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -1
  174. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.d.ts +2 -2
  175. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +45 -5
  176. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +3 -3
  177. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +3 -3
  178. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +7 -3
  179. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +10 -5
  180. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +3 -1
  181. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +3 -1
  182. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +14 -6
  183. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +8 -5
  184. package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
  185. package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.js +38 -17
  186. package/lib/chevre/service/offer/moneyTransfer/authorize.js +1 -1
  187. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
  188. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -3
  189. package/lib/chevre/service/offer/product.d.ts +4 -2
  190. package/lib/chevre/service/offer/product.js +12 -12
  191. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  192. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  193. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  194. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  195. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  196. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +3 -3
  197. package/lib/chevre/service/order/placeOrder.js +1 -1
  198. package/lib/chevre/service/order/returnOrder.js +1 -1
  199. package/lib/chevre/service/payment/any/factory.d.ts +1 -1
  200. package/lib/chevre/service/payment/any/onPaid.d.ts +1 -1
  201. package/lib/chevre/service/payment/any/onRefund.d.ts +1 -1
  202. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +1 -4
  203. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +21 -26
  204. package/lib/chevre/service/payment/any.d.ts +3 -1
  205. package/lib/chevre/service/payment/any.js +21 -13
  206. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -1
  207. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -1
  208. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +1 -2
  209. package/lib/chevre/service/payment/creditCard/payCreditCard.js +12 -5
  210. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +13 -3
  211. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  212. package/lib/chevre/service/payment/faceToFace.d.ts +2 -2
  213. package/lib/chevre/service/payment/faceToFace.js +28 -10
  214. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +0 -1
  215. package/lib/chevre/service/payment/movieTicket/authorize.js +8 -3
  216. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +1 -2
  217. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +12 -4
  218. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +15 -4
  219. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  220. package/lib/chevre/service/payment/paymentCard.d.ts +2 -2
  221. package/lib/chevre/service/payment/paymentCard.js +29 -16
  222. package/lib/chevre/service/payment.d.ts +1 -1
  223. package/lib/chevre/service/report/telemetry.js +2 -2
  224. package/lib/chevre/service/reserve/cancelReservation.js +1 -1
  225. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  226. package/lib/chevre/service/task/onAuthorizationCreated.js +20 -16
  227. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +2 -2
  228. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  229. package/lib/chevre/service/task/onResourceUpdated.js +16 -4
  230. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  231. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  232. package/lib/chevre/service/transaction/deleteTransaction.js +2 -2
  233. package/lib/chevre/service/transaction/moneyTransfer.js +4 -4
  234. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  235. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  236. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +2 -2
  237. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -1
  238. package/lib/chevre/service/transaction/placeOrder/start.js +1 -1
  239. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -2
  240. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  241. package/lib/chevre/service/transaction/returnOrder.js +2 -2
  242. package/lib/chevre/service/transaction.js +1 -1
  243. package/package.json +4 -4
  244. package/example/src/chevre/findTransactionById.ts +0 -23
  245. package/example/src/chevre/findTransactionInProgressById.ts +0 -23
  246. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +0 -154
  247. package/example/src/chevre/projectReservationFields.ts +0 -31
  248. package/example/src/chevre/searchActions.ts +0 -40
  249. package/example/src/chevre/searchProducts.ts +0 -28
@@ -25,6 +25,30 @@ const factory = require("../factory");
25
25
  const settings_1 = require("../settings");
26
26
  const action_1 = require("./mongoose/schemas/action");
27
27
  const actionRecipe_1 = require("./mongoose/schemas/actionRecipe");
28
+ const AVAILABLE_PROJECT_FIELDS = [
29
+ 'project',
30
+ 'actionStatus',
31
+ 'typeOf',
32
+ 'description',
33
+ 'agent',
34
+ 'recipient',
35
+ 'result',
36
+ 'error',
37
+ 'object',
38
+ 'startDate',
39
+ 'endDate',
40
+ 'purpose',
41
+ 'potentialActions',
42
+ 'amount',
43
+ 'fromLocation',
44
+ 'toLocation',
45
+ 'instrument',
46
+ 'location',
47
+ 'replacer',
48
+ 'targetCollection',
49
+ 'sameAs',
50
+ 'cancelAction'
51
+ ];
28
52
  /**
29
53
  * アクションリポジトリ
30
54
  */
@@ -432,24 +456,33 @@ class ActionRepo {
432
456
  var _a;
433
457
  return __awaiter(this, void 0, void 0, function* () {
434
458
  const conditions = ActionRepo.CREATE_MONGO_CONDITIONS(params);
435
- let projection = {};
459
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
436
460
  if (Array.isArray(inclusion) && inclusion.length > 0) {
437
- inclusion.forEach((field) => {
438
- projection[field] = 1;
439
- });
461
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
440
462
  }
441
463
  else {
442
- projection = {
443
- __v: 0,
444
- createdAt: 0,
445
- updatedAt: 0
446
- };
447
464
  if (Array.isArray(exclusion) && exclusion.length > 0) {
448
- exclusion.forEach((field) => {
449
- projection[field] = 0;
450
- });
465
+ positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
451
466
  }
452
467
  }
468
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
469
+ // let projection: { [key: string]: number } = {};
470
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
471
+ // inclusion.forEach((field) => {
472
+ // projection[field] = 1;
473
+ // });
474
+ // } else {
475
+ // projection = {
476
+ // __v: 0,
477
+ // createdAt: 0,
478
+ // updatedAt: 0
479
+ // };
480
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
481
+ // exclusion.forEach((field) => {
482
+ // projection[field] = 0;
483
+ // });
484
+ // }
485
+ // }
453
486
  const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
454
487
  if (typeof params.limit === 'number' && params.limit > 0) {
455
488
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
@@ -464,50 +497,36 @@ class ActionRepo {
464
497
  // const explainResult = await (<any>query).explain();
465
498
  // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
466
499
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
467
- .exec()
468
- .then((docs) => docs.map((doc) => doc.toObject()));
500
+ .lean() // 2024-08-26~
501
+ .exec();
469
502
  });
470
503
  }
471
504
  /**
472
505
  * アクション開始
473
506
  */
474
507
  start(attributes, options) {
508
+ var _a, _b;
475
509
  return __awaiter(this, void 0, void 0, function* () {
476
- const startedAction = yield this.actionModel.create(Object.assign(Object.assign({}, attributes), { actionStatus: factory.actionStatusType.ActiveActionStatus, startDate: new Date() }))
477
- .then((doc) => doc.toObject());
510
+ const startDate = new Date();
511
+ // const startedAction: IAction<T> = await this.actionModel.create<AnyKeys<IAction<T>>>({
512
+ // ...attributes,
513
+ // actionStatus: factory.actionStatusType.ActiveActionStatus,
514
+ // startDate
515
+ // })
516
+ // .then((doc) => doc.toObject());
517
+ const creatingAction = Object.assign(Object.assign({}, attributes), { actionStatus: factory.actionStatusType.ActiveActionStatus, startDate });
518
+ // reimplemnt with insertMany(2024-08-29~)
519
+ const result = yield this.actionModel.insertMany(creatingAction, { rawResult: true });
520
+ const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
521
+ if (typeof id !== 'string') {
522
+ throw new factory.errors.Internal('action not saved');
523
+ }
478
524
  // add recipe(2024-06-09~)
479
525
  const savingRecipe = options === null || options === void 0 ? void 0 : options.recipe;
480
526
  if ((savingRecipe === null || savingRecipe === void 0 ? void 0 : savingRecipe.typeOf) === 'Recipe') {
481
- yield this.upsertRecipe(Object.assign(Object.assign({}, savingRecipe), { recipeFor: { id: startedAction.id, typeOf: startedAction.typeOf } }));
482
- }
483
- return startedAction;
484
- });
485
- }
486
- /**
487
- * アクション完了
488
- */
489
- complete(params) {
490
- var _a;
491
- return __awaiter(this, void 0, void 0, function* () {
492
- if (((_a = params.recipe) === null || _a === void 0 ? void 0 : _a.typeOf) === 'Recipe') {
493
- yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
494
- }
495
- const doc = yield this.actionModel.findOneAndUpdate({
496
- typeOf: { $eq: params.typeOf },
497
- _id: { $eq: params.id }
498
- }, {
499
- $set: {
500
- actionStatus: factory.actionStatusType.CompletedActionStatus,
501
- result: params.result,
502
- endDate: new Date()
503
- }
504
- }, { new: true })
505
- .select({ __v: 0, createdAt: 0, updatedAt: 0 })
506
- .exec();
507
- if (doc === null) {
508
- throw new factory.errors.NotFound(this.actionModel.modelName);
527
+ yield this.upsertRecipe(Object.assign(Object.assign({}, savingRecipe), { recipeFor: { id, typeOf: creatingAction.typeOf } }));
509
528
  }
510
- return doc.toObject();
529
+ return { id, startDate, typeOf: creatingAction.typeOf };
511
530
  });
512
531
  }
513
532
  completeWithVoid(params) {
@@ -526,6 +545,7 @@ class ActionRepo {
526
545
  endDate: new Date()
527
546
  }
528
547
  }, { new: false, projection: { _id: 1 } })
548
+ .lean()
529
549
  .exec();
530
550
  if (doc === null) {
531
551
  throw new factory.errors.NotFound(this.actionModel.modelName);
@@ -548,6 +568,7 @@ class ActionRepo {
548
568
  $set: Object.assign({ actionStatus: factory.actionStatusType.CanceledActionStatus }, (cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
549
569
  )
550
570
  }, { new: false, projection: { _id: 1 } })
571
+ .lean()
551
572
  .exec();
552
573
  if (doc === null) {
553
574
  // 既にCanceledActionStatusであればok
@@ -564,32 +585,6 @@ class ActionRepo {
564
585
  .exec();
565
586
  });
566
587
  }
567
- /**
568
- * アクション失敗
569
- */
570
- giveUpWithObject(params) {
571
- return __awaiter(this, void 0, void 0, function* () {
572
- const actionError = (Array.isArray(params.error))
573
- ? params.error.map((e) => (Object.assign(Object.assign({}, e), { message: e.message, name: e.name })))
574
- : Object.assign(Object.assign({}, params.error), { message: params.error.message, name: params.error.name });
575
- const doc = yield this.actionModel.findOneAndUpdate({
576
- typeOf: { $eq: params.typeOf },
577
- _id: { $eq: params.id }
578
- }, {
579
- $set: {
580
- actionStatus: factory.actionStatusType.FailedActionStatus,
581
- error: actionError,
582
- endDate: new Date()
583
- }
584
- }, { new: true })
585
- .select({ __v: 0, createdAt: 0, updatedAt: 0 })
586
- .exec();
587
- if (doc === null) {
588
- throw new factory.errors.NotFound(this.actionModel.modelName);
589
- }
590
- return doc.toObject();
591
- });
592
- }
593
588
  /**
594
589
  * アクション失敗
595
590
  */
@@ -611,8 +606,8 @@ class ActionRepo {
611
606
  error: actionError,
612
607
  endDate: new Date()
613
608
  }
614
- }, { new: true })
615
- .select({ _id: 1 })
609
+ }, { new: true, projection: { _id: 1 } })
610
+ .lean()
616
611
  .exec();
617
612
  if (doc === null) {
618
613
  throw new factory.errors.NotFound(this.actionModel.modelName);
@@ -636,6 +631,7 @@ class ActionRepo {
636
631
  },
637
632
  $unset: { endDate: 1 }
638
633
  }, { new: false, projection: { _id: 1 } })
634
+ .lean()
639
635
  .exec();
640
636
  if (doc === null) {
641
637
  throw new factory.errors.NotFound(this.actionModel.modelName);
@@ -664,33 +660,43 @@ class ActionRepo {
664
660
  }
665
661
  findById(params, inclusion, exclusion) {
666
662
  return __awaiter(this, void 0, void 0, function* () {
667
- let projection = {};
663
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
668
664
  if (Array.isArray(inclusion) && inclusion.length > 0) {
669
- inclusion.forEach((field) => {
670
- projection[field] = 1;
671
- });
665
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
672
666
  }
673
667
  else {
674
- projection = {
675
- __v: 0,
676
- createdAt: 0,
677
- updatedAt: 0
678
- };
679
668
  if (Array.isArray(exclusion) && exclusion.length > 0) {
680
- exclusion.forEach((field) => {
681
- projection[field] = 0;
682
- });
669
+ positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
683
670
  }
684
671
  }
672
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
673
+ // let projection: { [key: string]: number } = {};
674
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
675
+ // inclusion.forEach((field) => {
676
+ // projection[field] = 1;
677
+ // });
678
+ // } else {
679
+ // projection = {
680
+ // __v: 0,
681
+ // createdAt: 0,
682
+ // updatedAt: 0
683
+ // };
684
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
685
+ // exclusion.forEach((field) => {
686
+ // projection[field] = 0;
687
+ // });
688
+ // }
689
+ // }
685
690
  const doc = yield this.actionModel.findOne({
686
691
  typeOf: { $eq: params.typeOf },
687
692
  _id: { $eq: params.id }
688
693
  }, projection)
694
+ .lean() // 2024-08-26~
689
695
  .exec();
690
696
  if (doc === null) {
691
697
  throw new factory.errors.NotFound(this.actionModel.modelName);
692
698
  }
693
- return doc.toObject();
699
+ return doc;
694
700
  });
695
701
  }
696
702
  findPayAction(params) {
@@ -712,17 +718,60 @@ class ActionRepo {
712
718
  /**
713
719
  * 取引に対するアクションを検索する
714
720
  */
721
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
715
722
  searchByPurpose(params) {
716
- var _a, _b, _c, _d, _e, _f, _g, _h;
723
+ var _a, _b, _c, _d, _e, _f;
717
724
  return __awaiter(this, void 0, void 0, function* () {
718
- return this.search(Object.assign(Object.assign(Object.assign(Object.assign({ purpose: {
719
- id: { $in: [params.purpose.id] },
720
- typeOf: { $in: [params.purpose.typeOf] }
721
- }, object: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf) === null || _b === void 0 ? void 0 : _b.$eq) === 'string')
722
- ? { typeOf: { $eq: params.object.typeOf.$eq } }
723
- : undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethodId) === null || _d === void 0 ? void 0 : _d.$eq) === 'string')
724
- ? { paymentMethodId: { $eq: params.object.paymentMethodId.$eq } }
725
- : undefined) }, (typeof ((_e = params.actionStatus) === null || _e === void 0 ? void 0 : _e.$eq) === 'string') ? { actionStatus: { $in: [params.actionStatus.$eq] } } : undefined), (typeof params.typeOf === 'string') ? { typeOf: { $eq: params.typeOf } } : undefined), (Array.isArray((_f = params.id) === null || _f === void 0 ? void 0 : _f.$nin)) ? { id: { $nin: (_g = params.id) === null || _g === void 0 ? void 0 : _g.$nin } } : undefined), (typeof ((_h = params.sort) === null || _h === void 0 ? void 0 : _h.startDate) === 'number') ? { sort: params.sort } : undefined), [], []);
725
+ const andConditions = [
726
+ { 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
727
+ { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
728
+ ];
729
+ // const idNin = params.id?.$nin;
730
+ // if (Array.isArray(idNin)) {
731
+ // andConditions.push({ _id: { $nin: idNin } });
732
+ // }
733
+ const objectPaymentMethodIdEq = (_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.paymentMethodId) === null || _b === void 0 ? void 0 : _b.$eq;
734
+ if (typeof objectPaymentMethodIdEq === 'string') {
735
+ andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
736
+ }
737
+ const objectTypeOfEq = (_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.typeOf) === null || _d === void 0 ? void 0 : _d.$eq;
738
+ if (typeof objectTypeOfEq === 'string') {
739
+ andConditions.push({ 'object.typeOf': { $exists: true, $eq: objectTypeOfEq } });
740
+ }
741
+ if (typeof params.typeOf === 'string') {
742
+ andConditions.push({ typeOf: { $eq: params.typeOf } });
743
+ }
744
+ const actionStatusEq = (_e = params.actionStatus) === null || _e === void 0 ? void 0 : _e.$eq;
745
+ if (typeof actionStatusEq === 'string') {
746
+ andConditions.push({ actionStatus: { $eq: actionStatusEq } });
747
+ }
748
+ const positiveProjectionFields = [
749
+ 'project',
750
+ 'actionStatus',
751
+ 'typeOf',
752
+ 'description',
753
+ 'agent',
754
+ 'recipient',
755
+ 'result',
756
+ 'error',
757
+ 'object',
758
+ 'startDate',
759
+ 'endDate',
760
+ 'purpose',
761
+ 'potentialActions',
762
+ 'instrument',
763
+ 'location',
764
+ 'sameAs',
765
+ 'cancelAction'
766
+ ];
767
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
768
+ const query = this.actionModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
769
+ if (typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.startDate) === 'number') {
770
+ query.sort({ startDate: params.sort.startDate });
771
+ }
772
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
773
+ .lean()
774
+ .exec();
726
775
  });
727
776
  }
728
777
  /**
@@ -731,33 +780,43 @@ class ActionRepo {
731
780
  searchByOrderNumber(params) {
732
781
  var _a;
733
782
  return __awaiter(this, void 0, void 0, function* () {
734
- const conditions = {
783
+ const filter = {
735
784
  $or: [
736
- { 'object.orderNumber': params.orderNumber },
737
- { 'purpose.orderNumber': params.orderNumber }
785
+ { 'object.orderNumber': { $eq: params.orderNumber } },
786
+ { 'purpose.orderNumber': { $eq: params.orderNumber } }
738
787
  ]
739
788
  };
740
- const query = this.actionModel.find(conditions)
741
- .select({ __v: 0, createdAt: 0, updatedAt: 0 });
789
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(AVAILABLE_PROJECT_FIELDS.map((key) => ([key, 1]))));
790
+ const query = this.actionModel.find(filter, projection);
791
+ // .select({ __v: 0, createdAt: 0, updatedAt: 0 });
742
792
  // tslint:disable-next-line:no-single-line-block-comment
743
793
  /* istanbul ignore else */
744
794
  if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
745
795
  query.sort({ startDate: params.sort.startDate });
746
796
  }
747
- return query.exec()
748
- .then((docs) => docs.map((doc) => doc.toObject()));
797
+ return query
798
+ .lean() // 2024-08-26~
799
+ .exec();
749
800
  });
750
801
  }
751
802
  searchBySameAs(params) {
752
803
  var _a;
753
804
  return __awaiter(this, void 0, void 0, function* () {
805
+ const projection = {
806
+ _id: 0,
807
+ id: { $toString: '$_id' },
808
+ actionStatus: 1,
809
+ error: 1,
810
+ purpose: 1
811
+ };
754
812
  const query = this.actionModel.find(Object.assign({ typeOf: { $eq: params.typeOf.$eq }, 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
755
813
  ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
756
- : undefined))
757
- .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
814
+ : undefined), projection)
815
+ // .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
758
816
  .limit(1);
759
- return query.exec()
760
- .then((docs) => docs.map((doc) => doc.toObject()));
817
+ return query
818
+ .lean() // 2024-08-26~
819
+ .exec();
761
820
  });
762
821
  }
763
822
  deleteByProject(params) {
@@ -768,7 +827,7 @@ class ActionRepo {
768
827
  .exec();
769
828
  });
770
829
  }
771
- updateAuthorizeEventOfferAction(params) {
830
+ reCompleteAuthorizeEventOfferAction(params) {
772
831
  return __awaiter(this, void 0, void 0, function* () {
773
832
  return this.actionModel.findOneAndUpdate({
774
833
  // typeOf: factory.actionType.AuthorizeAction,
@@ -783,13 +842,13 @@ class ActionRepo {
783
842
  result: params.result,
784
843
  endDate: new Date()
785
844
  }
786
- }, { new: true })
845
+ }, { new: true, projection: { _id: 1 } })
846
+ .lean()
787
847
  .exec()
788
848
  .then((doc) => {
789
849
  if (doc === null) {
790
850
  throw new factory.errors.NotFound(this.actionModel.modelName);
791
851
  }
792
- return doc.toObject();
793
852
  });
794
853
  });
795
854
  }
@@ -802,10 +861,11 @@ class ActionRepo {
802
861
  findByIdAndUpdate(params) {
803
862
  return __awaiter(this, void 0, void 0, function* () {
804
863
  yield this.actionModel.findOneAndUpdate({ _id: { $eq: params.id } }, params.update, { projection: { _id: 1 } })
864
+ .lean()
805
865
  .exec()
806
866
  .then((doc) => {
807
867
  if (doc === null) {
808
- throw new factory.errors.ArgumentNull(this.actionModel.modelName);
868
+ throw new factory.errors.NotFound(this.actionModel.modelName);
809
869
  }
810
870
  });
811
871
  });
@@ -1358,29 +1418,6 @@ class ActionRepo {
1358
1418
  .exec();
1359
1419
  });
1360
1420
  }
1361
- /**
1362
- * 互換性維持対応専用
1363
- */
1364
- fixInstrumentTransactionNumber(params) {
1365
- var _a, _b;
1366
- return __awaiter(this, void 0, void 0, function* () {
1367
- const pendingTransactionNumber = (_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction) === null || _b === void 0 ? void 0 : _b.transactionNumber;
1368
- const doc = yield this.actionModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
1369
- $set: Object.assign({ 'instrument.transactionNumber': params.instrument.transactionNumber }, (typeof pendingTransactionNumber === 'string')
1370
- ? { 'object.pendingTransaction.transactionNumber': pendingTransactionNumber }
1371
- : undefined)
1372
- }, {
1373
- new: true,
1374
- projection: {
1375
- _id: 1
1376
- }
1377
- })
1378
- .exec();
1379
- if (doc === null) {
1380
- throw new factory.errors.NotFound(this.actionModel.modelName);
1381
- }
1382
- });
1383
- }
1384
1421
  // tslint:disable-next-line:max-func-body-length
1385
1422
  agggregateByStatus(params) {
1386
1423
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,20 +1,7 @@
1
1
  import type { Connection, PipelineStage } from 'mongoose';
2
2
  import * as factory from '../factory';
3
+ import { IAggregateReservation } from './mongoose/schemas/aggregateReservation';
3
4
  type IMatchStage = PipelineStage.Match;
4
- export interface IAggregateReservation {
5
- project: {
6
- id: string;
7
- typeOf: factory.organizationType.Project;
8
- };
9
- typeOf: 'AggregateReservation';
10
- reservationFor: {
11
- id: string;
12
- typeOf: factory.eventType;
13
- startDate: Date;
14
- };
15
- aggregateEntranceGate?: factory.event.event.IAggregateEntranceGate;
16
- aggregateOffer?: factory.event.event.IAggregateOffer;
17
- }
18
5
  export interface IUpdateAggregateReservationParams {
19
6
  $set: {
20
7
  aggregateOffer?: factory.event.event.IAggregateOffer;