@chevre/domain 21.2.0-alpha.6 → 21.2.0-alpha.60

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 (232) hide show
  1. package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
  2. package/example/src/chevre/countDelayedTasks.ts +17 -0
  3. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  4. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  5. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  6. package/example/src/chevre/deleteTasksByName.ts +2 -1
  7. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  8. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  9. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  10. package/example/src/chevre/saveTasks.ts +13 -10
  11. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  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/startExportTasks.ts +20 -0
  17. package/example/src/chevre/updateTransaction.ts +1 -1
  18. package/lib/chevre/credentials.d.ts +1 -0
  19. package/lib/chevre/credentials.js +2 -1
  20. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  21. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  22. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  23. package/lib/chevre/eventEmitter/task.js +25 -0
  24. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  25. package/lib/chevre/eventEmitter/transaction.js +25 -0
  26. package/lib/chevre/eventEmitter.d.ts +4 -0
  27. package/lib/chevre/eventEmitter.js +9 -0
  28. package/lib/chevre/index.d.ts +3 -2
  29. package/lib/chevre/index.js +5 -3
  30. package/lib/chevre/repo/account.js +0 -4
  31. package/lib/chevre/repo/accountTitle.js +0 -4
  32. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  33. package/lib/chevre/repo/accountTransaction.js +1 -58
  34. package/lib/chevre/repo/accountingReport.js +0 -4
  35. package/lib/chevre/repo/action.d.ts +29 -1
  36. package/lib/chevre/repo/action.js +32 -29
  37. package/lib/chevre/repo/additionalProperty.js +0 -4
  38. package/lib/chevre/repo/aggregation.js +0 -4
  39. package/lib/chevre/repo/assetTransaction.d.ts +23 -8
  40. package/lib/chevre/repo/assetTransaction.js +207 -68
  41. package/lib/chevre/repo/categoryCode.js +0 -4
  42. package/lib/chevre/repo/code.js +0 -4
  43. package/lib/chevre/repo/comment.d.ts +4 -1
  44. package/lib/chevre/repo/comment.js +20 -9
  45. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  46. package/lib/chevre/repo/confirmationNumber.js +3 -15
  47. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  48. package/lib/chevre/repo/creativeWork.js +0 -4
  49. package/lib/chevre/repo/customer.js +0 -4
  50. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  51. package/lib/chevre/repo/emailMessage.js +0 -4
  52. package/lib/chevre/repo/event.d.ts +5 -1
  53. package/lib/chevre/repo/event.js +0 -4
  54. package/lib/chevre/repo/member.js +0 -4
  55. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  56. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  57. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  58. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  59. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  60. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  61. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  62. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  63. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  64. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  65. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  66. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  67. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  68. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  69. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  70. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  71. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  72. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -1
  73. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  74. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  75. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  76. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  77. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  78. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  79. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  80. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  82. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  83. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  84. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  85. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  86. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  87. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  88. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  89. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  90. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  91. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  92. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  93. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  94. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  95. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  96. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  97. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  98. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  99. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  100. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  101. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  102. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  103. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  104. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  105. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  106. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  107. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  108. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  109. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
  110. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  111. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  112. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  113. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  114. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  115. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  116. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  117. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  118. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  119. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  120. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  121. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  122. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  123. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  124. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  125. package/lib/chevre/repo/offer.js +0 -5
  126. package/lib/chevre/repo/offerCatalog.js +0 -4
  127. package/lib/chevre/repo/offerItemCondition.d.ts +39 -0
  128. package/lib/chevre/repo/offerItemCondition.js +112 -0
  129. package/lib/chevre/repo/order.d.ts +25 -0
  130. package/lib/chevre/repo/order.js +5 -4
  131. package/lib/chevre/repo/ownershipInfo.js +0 -4
  132. package/lib/chevre/repo/permit.js +0 -4
  133. package/lib/chevre/repo/place.js +0 -4
  134. package/lib/chevre/repo/priceSpecification.js +0 -4
  135. package/lib/chevre/repo/product.js +0 -4
  136. package/lib/chevre/repo/project.js +0 -4
  137. package/lib/chevre/repo/reservation.js +0 -4
  138. package/lib/chevre/repo/role.js +0 -4
  139. package/lib/chevre/repo/seller.js +0 -4
  140. package/lib/chevre/repo/serviceOutput.js +0 -4
  141. package/lib/chevre/repo/stockHolder.js +30 -0
  142. package/lib/chevre/repo/task.d.ts +41 -2
  143. package/lib/chevre/repo/task.js +97 -12
  144. package/lib/chevre/repo/telemetry.js +0 -4
  145. package/lib/chevre/repo/transaction.d.ts +23 -3
  146. package/lib/chevre/repo/transaction.js +174 -58
  147. package/lib/chevre/repo/trip.js +0 -4
  148. package/lib/chevre/repository.d.ts +5 -2
  149. package/lib/chevre/repository.js +8 -4
  150. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  151. package/lib/chevre/service/aggregation/system.js +101 -89
  152. package/lib/chevre/service/assetTransaction/cancelReservation.js +23 -25
  153. package/lib/chevre/service/assetTransaction/moneyTransfer.js +23 -21
  154. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  155. package/lib/chevre/service/assetTransaction/pay.js +32 -24
  156. package/lib/chevre/service/assetTransaction/refund.js +23 -21
  157. package/lib/chevre/service/assetTransaction/registerService.js +23 -22
  158. package/lib/chevre/service/assetTransaction/reserve.js +23 -21
  159. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  160. package/lib/chevre/service/assetTransaction.js +9 -5
  161. package/lib/chevre/service/event.js +3 -1
  162. package/lib/chevre/service/notification/factory.js +2 -2
  163. package/lib/chevre/service/notification.d.ts +3 -1
  164. package/lib/chevre/service/notification.js +41 -7
  165. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  166. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  167. package/lib/chevre/service/offer.js +1 -1
  168. package/lib/chevre/service/order/deleteOrder.js +8 -8
  169. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -36
  170. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
  171. package/lib/chevre/service/order/placeOrder.js +1 -1
  172. package/lib/chevre/service/order/returnOrder.js +1 -5
  173. package/lib/chevre/service/order/sendOrder.js +1 -1
  174. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  175. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  176. package/lib/chevre/service/payment/any.js +60 -10
  177. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
  178. package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
  179. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  180. package/lib/chevre/service/payment/movieTicket.js +4 -3
  181. package/lib/chevre/service/product.js +1 -5
  182. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  183. package/lib/chevre/service/report/telemetry.js +21 -24
  184. package/lib/chevre/service/reserve/cancelReservation.js +0 -2
  185. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
  186. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
  187. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  188. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  189. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  190. package/lib/chevre/service/reserve/useReservation.js +1 -8
  191. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  192. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  193. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  194. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  195. package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
  196. package/lib/chevre/service/task.d.ts +9 -0
  197. package/lib/chevre/service/task.js +43 -4
  198. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  199. package/lib/chevre/service/transaction/deleteTransaction.js +226 -0
  200. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  201. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  202. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  203. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  204. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  205. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  206. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  207. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  208. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  209. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  210. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  211. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  212. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  213. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  214. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  215. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  216. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  217. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  218. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  219. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  220. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  221. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  222. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +1 -3
  223. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  224. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  225. package/lib/chevre/service/transaction/returnOrder.js +1 -5
  226. package/lib/chevre/service/transaction.d.ts +8 -13
  227. package/lib/chevre/service/transaction.js +12 -145
  228. package/lib/chevre/settings.d.ts +6 -1
  229. package/lib/chevre/settings.js +17 -5
  230. package/package.json +5 -5
  231. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  232. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
@@ -384,11 +384,7 @@ function exportTasksById(params) {
384
384
  transaction,
385
385
  runsAt: taskRunsAt
386
386
  });
387
- // saveManyに変更(2023-02-01~)
388
- yield repos.task.saveMany(taskAttributes);
389
- // await Promise.all(taskAttributes.map(async (taskAttribute) => {
390
- // await repos.task.save(taskAttribute);
391
- // }));
387
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
392
388
  });
393
389
  }
394
390
  exports.exportTasksById = exportTasksById;
@@ -1,9 +1,7 @@
1
1
  import * as factory from '../factory';
2
- import { MongoRepository as ActionRepo } from '../repo/action';
3
- import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
4
- import { MongoRepository as ReservationRepo } from '../repo/reservation';
5
2
  import { MongoRepository as TaskRepo } from '../repo/task';
6
3
  import { MongoRepository as TransactionRepo } from '../repo/transaction';
4
+ import { deleteTransaction } from './transaction/deleteTransaction';
7
5
  import * as MoneyTransferTransactionService from './transaction/moneyTransfer';
8
6
  import * as PlaceOrderTransactionService from './transaction/placeOrder';
9
7
  import * as PlaceOrderInProgressTransactionService from './transaction/placeOrderInProgress';
@@ -15,6 +13,7 @@ export import moneyTransfer = MoneyTransferTransactionService;
15
13
  export import placeOrder = PlaceOrderTransactionService;
16
14
  export import placeOrderInProgress = PlaceOrderInProgressTransactionService;
17
15
  export import returnOrder = ReturnOrderTransactionService;
16
+ export { deleteTransaction };
18
17
  /**
19
18
  * 取引人プロフィール更新
20
19
  */
@@ -45,14 +44,10 @@ export declare function exportTasks<T extends factory.transactionType>(params: {
45
44
  typeOf?: {
46
45
  $in: T[];
47
46
  };
47
+ id?: string;
48
+ tasksExportAction?: {
49
+ agent: {
50
+ name: string;
51
+ };
52
+ };
48
53
  }): IExportTasksOperation<void>;
49
- /**
50
- * 取引に関わるリソースを削除する
51
- * 冪等性を確保すること
52
- */
53
- export declare function deleteTransaction(params: factory.task.IData<factory.taskName.DeleteTransaction>): (repos: {
54
- action: ActionRepo;
55
- assetTransaction: AssetTransactionRepo;
56
- reservation: ReservationRepo;
57
- transaction: TransactionRepo;
58
- }) => Promise<void>;
@@ -9,16 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.deleteTransaction = exports.exportTasks = exports.updateAgent = exports.returnOrder = exports.placeOrderInProgress = exports.placeOrder = exports.moneyTransfer = void 0;
12
+ exports.exportTasks = exports.updateAgent = exports.deleteTransaction = exports.returnOrder = exports.placeOrderInProgress = exports.placeOrder = exports.moneyTransfer = void 0;
13
13
  /**
14
14
  * 取引サービス
15
15
  */
16
16
  const google_libphonenumber_1 = require("google-libphonenumber");
17
17
  const factory = require("../factory");
18
+ const deleteTransaction_1 = require("./transaction/deleteTransaction");
19
+ Object.defineProperty(exports, "deleteTransaction", { enumerable: true, get: function () { return deleteTransaction_1.deleteTransaction; } });
18
20
  const MoneyTransferTransactionService = require("./transaction/moneyTransfer");
19
21
  const PlaceOrderTransactionService = require("./transaction/placeOrder");
20
22
  const PlaceOrderInProgressTransactionService = require("./transaction/placeOrderInProgress");
21
23
  const ReturnOrderTransactionService = require("./transaction/returnOrder");
24
+ const settings_1 = require("../settings");
22
25
  exports.moneyTransfer = MoneyTransferTransactionService;
23
26
  exports.placeOrder = PlaceOrderTransactionService;
24
27
  exports.placeOrderInProgress = PlaceOrderInProgressTransactionService;
@@ -77,15 +80,17 @@ exports.updateAgent = updateAgent;
77
80
  */
78
81
  function exportTasks(params) {
79
82
  return (repos) => __awaiter(this, void 0, void 0, function* () {
80
- const transaction = yield repos.transaction.startExportTasks({
81
- project: params.project,
82
- typeOf: params.typeOf,
83
- status: params.status
84
- });
83
+ var _a;
84
+ const transaction = yield repos.transaction.startExportTasks(Object.assign({ project: params.project, typeOf: params.typeOf, status: params.status, tasksExportAction: {
85
+ agent: {
86
+ name: (typeof ((_a = params.tasksExportAction) === null || _a === void 0 ? void 0 : _a.agent.name) === 'string')
87
+ ? params.tasksExportAction.agent.name
88
+ : settings_1.DEFAULT_TASKS_EXPORT_AGENT_NAME
89
+ }
90
+ } }, (typeof params.id === 'string') ? { id: params.id } : undefined));
85
91
  if (transaction === null) {
86
92
  return;
87
93
  }
88
- // let tasks: factory.task.ITask<factory.taskName>[] = [];
89
94
  // 失敗してもここでは戻さない(RUNNINGのまま待機)
90
95
  switch (transaction.typeOf) {
91
96
  case factory.transactionType.MoneyTransfer:
@@ -109,144 +114,6 @@ function exportTasks(params) {
109
114
  default:
110
115
  }
111
116
  yield repos.transaction.setTasksExportedById({ id: transaction.id });
112
- // return tasks;
113
117
  });
114
118
  }
115
119
  exports.exportTasks = exportTasks;
116
- /**
117
- * 取引に関わるリソースを削除する
118
- * 冪等性を確保すること
119
- */
120
- function deleteTransaction(params) {
121
- return (repos) => __awaiter(this, void 0, void 0, function* () {
122
- var _a;
123
- const transaction = params.object;
124
- // DeleteTransactionアクションを作成(logとしての意味合いも含めて)
125
- const actionAttributes = {
126
- typeOf: factory.actionType.DeleteAction,
127
- project: transaction.project,
128
- object: transaction,
129
- agent: {
130
- typeOf: transaction.seller.typeOf,
131
- id: transaction.seller.id,
132
- name: (typeof transaction.seller.name === 'string')
133
- ? transaction.seller.name
134
- : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
135
- }
136
- };
137
- let deleteReservationsResult;
138
- let deleteReserveTransactionResult;
139
- let deletedReservationNumbers = [];
140
- const action = yield repos.action.start(actionAttributes);
141
- try {
142
- const transactionTypeOf = transaction.typeOf;
143
- switch (transactionTypeOf) {
144
- case factory.transactionType.PlaceOrder:
145
- switch (transaction.status) {
146
- // 中止あるいは期限切れ取引の場合
147
- case factory.transactionStatusType.Canceled:
148
- case factory.transactionStatusType.Expired:
149
- // tslint:disable-next-line:no-suspicious-comment
150
- // TODO サービス登録取引を削除
151
- // tslint:disable-next-line:no-suspicious-comment
152
- // TODO 決済取引を削除
153
- // 取引上での予約を削除
154
- const deleteReservationsByTransactionResult = yield deleteReservationsByTransaction({ transaction })(repos);
155
- deleteReservationsResult = deleteReservationsByTransactionResult.deleteResult;
156
- deleteReserveTransactionResult = deleteReservationsByTransactionResult.deleteReserveTransactionResult;
157
- deletedReservationNumbers = deleteReservationsByTransactionResult.reserveTransactionNumbers;
158
- break;
159
- case factory.transactionStatusType.Confirmed:
160
- // no op
161
- break;
162
- default:
163
- }
164
- // 取引削除
165
- yield repos.transaction.findByIdAndDelete({ id: transaction.id });
166
- // await repos.transaction.transactionModel.findByIdAndDelete(transaction.id)
167
- // .exec();
168
- break;
169
- // implemented(2022-06-09~)
170
- case factory.transactionType.ReturnOrder:
171
- // 取引削除
172
- yield repos.transaction.findByIdAndDelete({ id: transaction.id });
173
- break;
174
- // implemented(2022-06-09~)
175
- case factory.transactionType.MoneyTransfer:
176
- // 取引削除
177
- yield repos.transaction.findByIdAndDelete({ id: transaction.id });
178
- break;
179
- default:
180
- throw new factory.errors.NotImplemented(`${transactionTypeOf} not implemented`);
181
- }
182
- }
183
- catch (error) {
184
- // actionにエラー結果を追加
185
- try {
186
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
187
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
188
- }
189
- catch (__) {
190
- // 失敗したら仕方ない
191
- }
192
- throw error;
193
- }
194
- // アクション完了
195
- const actionResult = {
196
- deleteReservationsResult,
197
- deleteReserveTransactionResult,
198
- deletedReservationNumbers
199
- };
200
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
201
- });
202
- }
203
- exports.deleteTransaction = deleteTransaction;
204
- function deleteReservationsByTransaction(params) {
205
- return (repos) => __awaiter(this, void 0, void 0, function* () {
206
- let deleteResult;
207
- let deleteReserveTransactionResult;
208
- // 取引に対する全ての承認アクションを検索
209
- const authorizeActions = yield repos.action.searchByPurpose({
210
- typeOf: factory.actionType.AuthorizeAction,
211
- purpose: {
212
- typeOf: factory.transactionType.PlaceOrder,
213
- id: params.transaction.id
214
- }
215
- });
216
- // 予約取引番号を抽出
217
- const authorizeReservationOfferActions = authorizeActions
218
- .filter((a) => {
219
- var _a, _b;
220
- const pendingTransactionNumber = (_b = (_a = a.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction) === null || _b === void 0 ? void 0 : _b.transactionNumber;
221
- return a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation
222
- && typeof pendingTransactionNumber === 'string'
223
- && pendingTransactionNumber.length > 0;
224
- });
225
- const reserveTransactionNumbers = authorizeReservationOfferActions
226
- .map((a) => { var _a; return String((_a = a.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber); });
227
- if (reserveTransactionNumbers.length > 0) {
228
- // 該当予約番号の予約を削除する(プロジェクトでも絞ること)
229
- const deleteReservationsResult = yield repos.reservation.deleteByReservationNumbers({
230
- project: { id: params.transaction.project.id },
231
- reservationNumbers: reserveTransactionNumbers
232
- });
233
- deleteResult = {
234
- n: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.n,
235
- ok: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.ok,
236
- deletedCount: deleteReservationsResult === null || deleteReservationsResult === void 0 ? void 0 : deleteReservationsResult.deletedCount
237
- };
238
- // 予約取引を削除(プロジェクトでも絞ること)(2022-06-07~)
239
- const deleteAssetTransactionsResult = yield repos.assetTransaction.deleteByTransactionNumber({
240
- project: { id: params.transaction.project.id },
241
- transactionNumbers: reserveTransactionNumbers,
242
- typeOf: factory.assetTransactionType.Reserve
243
- });
244
- deleteReserveTransactionResult = {
245
- n: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.n,
246
- ok: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.ok,
247
- deletedCount: deleteAssetTransactionsResult === null || deleteAssetTransactionsResult === void 0 ? void 0 : deleteAssetTransactionsResult.deletedCount
248
- };
249
- }
250
- return { deleteResult, deleteReserveTransactionResult, reserveTransactionNumbers };
251
- });
252
- }
@@ -1,5 +1,7 @@
1
1
  import * as moment from 'moment';
2
2
  import * as factory from './factory';
3
+ export declare const TRIGGER_WEBHOOK_MAX_RETRY_COUNT: number;
4
+ export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
3
5
  export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
4
6
  /**
5
7
  * 資産取引保管期間
@@ -27,10 +29,13 @@ export type ISettings = factory.project.ISettings & {
27
29
  useOfferRateLimitProjects: string[];
28
30
  };
29
31
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
32
+ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
30
33
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
31
34
  export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
32
35
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
33
- export declare const USE_NEW_CONFIRMATION_NUMBER_KEY_FROM: moment.Moment;
36
+ export declare const USE_DELETE_ASSET_TRANSACTION_TASK: boolean;
37
+ export declare const USE_DELETE_ORDER_TASK: boolean;
38
+ export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
34
39
  /**
35
40
  * グローバル設定
36
41
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
3
+ exports.settings = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_ORDER_TASK = exports.USE_DELETE_ASSET_TRANSACTION_TASK = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -14,6 +14,12 @@ const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'st
14
14
  : [];
15
15
  // tslint:disable-next-line:no-magic-numbers
16
16
  const triggerWebhookTimeout = (process.env.TRIGGER_WEBHOOK_TIMEOUT !== undefined) ? Number(process.env.TRIGGER_WEBHOOK_TIMEOUT) : 15000;
17
+ exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = (typeof process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT === 'string')
18
+ ? Number(process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT)
19
+ : 0;
20
+ exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = (typeof process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS === 'string')
21
+ ? Number(process.env.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS)
22
+ : 0;
17
23
  const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = (typeof process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS === 'string')
18
24
  ? Number(process.env.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS)
19
25
  // tslint:disable-next-line:no-magic-numbers
@@ -34,7 +40,10 @@ exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = (typeof process.env.ASSET_TRA
34
40
  /**
35
41
  * 取引保管期間(Confirmed)
36
42
  */
37
- exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = 365;
43
+ exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS === 'string')
44
+ ? Number(process.env.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS)
45
+ // tslint:disable-next-line:no-magic-numbers
46
+ : 365;
38
47
  /**
39
48
  * 取引保管期間(Canceled)
40
49
  */
@@ -44,14 +53,17 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSA
44
53
  : 7;
45
54
  exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
46
55
  exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
56
+ exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
47
57
  exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
48
58
  exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
49
59
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
50
60
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
51
61
  : moment('2023-08-31T15:00:00Z');
52
- exports.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM = (typeof process.env.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM === 'string')
53
- ? moment(process.env.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM)
54
- : moment('2023-04-30T15:00:00Z');
62
+ exports.USE_DELETE_ASSET_TRANSACTION_TASK = process.env.USE_DELETE_ASSET_TRANSACTION_TASK === '1';
63
+ exports.USE_DELETE_ORDER_TASK = process.env.USE_DELETE_ORDER_TASK === '1';
64
+ exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
65
+ ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
66
+ : 0;
55
67
  /**
56
68
  * グローバル設定
57
69
  */
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.310.0",
13
- "@cinerino/sdk": "3.154.0",
12
+ "@chevre/factory": "4.313.0-alpha.4",
13
+ "@cinerino/sdk": "3.156.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -58,7 +58,7 @@
58
58
  "googleapis": "^85.0.0",
59
59
  "json2csv": "4.5.4",
60
60
  "mocha": "^5.2.0",
61
- "mongoose": "6.10.4",
61
+ "mongoose": "7.0.5",
62
62
  "nock": "^9.6.1",
63
63
  "nyc": "^15.1.0",
64
64
  "power-assert": "^1.6.1",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "peerDependencies": {
76
76
  "aws-sdk": "^2.0.0",
77
- "mongoose": "^6.0.0",
77
+ "mongoose": "^7.0.5",
78
78
  "redis": "^4.6.5"
79
79
  },
80
80
  "engines": {
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.6"
120
+ "version": "21.2.0-alpha.60"
121
121
  }
@@ -1,96 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- // tslint:disable-next-line:max-func-body-length
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const accountTransactionRepo = new chevre.repository.AccountTransaction(mongoose.connection);
14
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
15
-
16
- const cursor = assetTransactionRepo.getCursor(
17
- {
18
- 'project.id': { $eq: project.id },
19
- typeOf: { $eq: chevre.factory.assetTransactionType.MoneyTransfer },
20
- startDate: {
21
- $gte: moment('2023-02-17T15:00:00Z')
22
- .toDate()
23
- }
24
- // _id: { $eq: 'al6aff83w' }
25
- },
26
- {
27
- // _id: 1,
28
- }
29
- );
30
- console.log('assetTransactions found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- // tslint:disable-next-line:max-func-body-length
35
- await cursor.eachAsync(async (doc) => {
36
- i += 1;
37
- const moneyTransferTransaction: chevre.factory.assetTransaction.moneyTransfer.ITransaction = doc.toObject();
38
-
39
- const description = moneyTransferTransaction.object.description;
40
- if (description !== '鑑賞' && description !== '受け取り') {
41
- console.log(
42
- 'no operation needed',
43
- description,
44
- moneyTransferTransaction.project.id,
45
- moneyTransferTransaction.transactionNumber,
46
- moneyTransferTransaction.startDate
47
- );
48
- } else {
49
- const pendingTransactionIdentifier = moneyTransferTransaction.object.pendingTransaction?.identifier;
50
- if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
51
- console.log(
52
- 'pendingTransactionIdentifier found',
53
- description,
54
- moneyTransferTransaction.project.id,
55
- moneyTransferTransaction.transactionNumber,
56
- moneyTransferTransaction.startDate
57
- );
58
- } else {
59
- // 口座取引からidentifierを取得
60
- const accountTransaction =
61
- await accountTransactionRepo.findByTransactionNumber({ transactionNumber: moneyTransferTransaction.transactionNumber });
62
- console.log(
63
- 'updating identifier...',
64
- accountTransaction.identifier,
65
- description,
66
- moneyTransferTransaction.project.id,
67
- moneyTransferTransaction.transactionNumber,
68
- moneyTransferTransaction.startDate
69
- );
70
- if (typeof accountTransaction.identifier === 'string') {
71
- await assetTransactionRepo.findByIdAndUpdate({
72
- id: moneyTransferTransaction.id,
73
- update: {
74
- 'object.pendingTransaction.identifier': accountTransaction.identifier
75
- }
76
- });
77
- }
78
- console.log(
79
- 'ientifier updated',
80
- accountTransaction.identifier,
81
- description,
82
- moneyTransferTransaction.project.id,
83
- moneyTransferTransaction.transactionNumber,
84
- moneyTransferTransaction.startDate
85
- );
86
- updateCount += 1;
87
- }
88
- }
89
- });
90
- console.log(i, 'assetTransactions checked');
91
- console.log(updateCount, 'assetTransactions updated');
92
- }
93
-
94
- main()
95
- .then()
96
- .catch(console.error);
@@ -1,98 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
- const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
15
- const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
16
-
17
- const cursor = creativeWorkRepo.getCursor(
18
- {
19
- // 'project.id': { $eq: project.id },
20
- 'project.id': { $ne: EXCLUDED_PROJECT_ID }
21
- },
22
- {
23
- // _id: 1,
24
- }
25
- );
26
- console.log('movies found');
27
-
28
- const additionalPropertyNames: string[] = [];
29
- const projectIds: string[] = [];
30
- const unexpextedprojectIds: string[] = [];
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
37
-
38
- const additionalPropertyNamesOnEvent = movie.additionalProperty?.map((p) => p.name);
39
- if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
40
- console.log(
41
- additionalPropertyNamesOnEvent.length,
42
- 'additionalPropertyNamesOnEvent found',
43
- movie.project.id,
44
- movie.id
45
- );
46
- additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
47
- projectIds.push(movie.project.id);
48
- additionalPropertyNamesOnEvent.forEach((name) => {
49
- if (!name.match(/^[a-zA-Z]*$/)) {
50
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
51
- unexpextedprojectIds.push(movie.project.id);
52
- }
53
- // tslint:disable-next-line:no-magic-numbers
54
- if (name.length < 5) {
55
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
56
- unexpextedprojectIds.push(movie.project.id);
57
- }
58
- });
59
-
60
- for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
61
- const existings = await additionalPropertyRepo.search({
62
- project: { id: { $eq: movie.project.id } },
63
- limit: 1,
64
- page: 1,
65
- name: { $regex: `^${additionalPropertyNameOnEvent}$` }
66
- });
67
- if (existings.length > 0) {
68
- console.log('already existed', additionalPropertyNameOnEvent, movie.id, movie.project.id);
69
- } else {
70
- updateCount += 1;
71
- const newAdditionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
72
- project: movie.project,
73
- typeOf: 'CategoryCode',
74
- codeValue: additionalPropertyNameOnEvent,
75
- inCodeSet: {
76
- typeOf: 'CategoryCodeSet',
77
- identifier: <chevre.factory.creativeWorkType.Movie>movie.typeOf
78
- },
79
- name: { ja: additionalPropertyNameOnEvent }
80
- };
81
- await additionalPropertyRepo.save({
82
- attributes: newAdditionalProperty
83
- });
84
- console.log('created', additionalPropertyNameOnEvent, movie.id, movie.project.id);
85
- }
86
- }
87
- }
88
- });
89
- console.log(i, 'events checked');
90
- console.log(updateCount, 'properties updated');
91
- console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
92
- console.log('projectIds:', [...new Set(projectIds)]);
93
- console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
94
- }
95
-
96
- main()
97
- .then()
98
- .catch(console.error);