@chevre/domain 21.2.0-alpha.2 → 21.2.0-alpha.21

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 (187) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  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/lockStockHolder.ts +48 -0
  7. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  8. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  9. package/example/src/chevre/processReserve.ts +2 -2
  10. package/example/src/chevre/searchEventSeats.ts +42 -0
  11. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  12. package/example/src/chevre/transaction/makeExpired.ts +18 -0
  13. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  14. package/example/src/chevre/transaction/startExportTasks.ts +19 -0
  15. package/example/src/chevre/updateTransaction.ts +1 -1
  16. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  17. package/lib/chevre/eventEmitter/task.js +28 -0
  18. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  19. package/lib/chevre/eventEmitter/transaction.js +28 -0
  20. package/lib/chevre/eventEmitter.d.ts +3 -0
  21. package/lib/chevre/eventEmitter.js +7 -0
  22. package/lib/chevre/index.d.ts +3 -2
  23. package/lib/chevre/index.js +5 -3
  24. package/lib/chevre/repo/account.js +0 -4
  25. package/lib/chevre/repo/accountTitle.js +0 -4
  26. package/lib/chevre/repo/accountTransaction.d.ts +0 -10
  27. package/lib/chevre/repo/accountTransaction.js +0 -57
  28. package/lib/chevre/repo/accountingReport.js +0 -4
  29. package/lib/chevre/repo/action.js +0 -4
  30. package/lib/chevre/repo/additionalProperty.js +0 -4
  31. package/lib/chevre/repo/aggregation.js +0 -4
  32. package/lib/chevre/repo/assetTransaction.d.ts +4 -6
  33. package/lib/chevre/repo/assetTransaction.js +69 -45
  34. package/lib/chevre/repo/categoryCode.js +0 -4
  35. package/lib/chevre/repo/code.js +0 -4
  36. package/lib/chevre/repo/comment.js +0 -4
  37. package/lib/chevre/repo/confirmationNumber.js +1 -1
  38. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  39. package/lib/chevre/repo/creativeWork.js +0 -4
  40. package/lib/chevre/repo/customer.js +0 -4
  41. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  42. package/lib/chevre/repo/emailMessage.js +0 -4
  43. package/lib/chevre/repo/event.d.ts +5 -1
  44. package/lib/chevre/repo/event.js +0 -4
  45. package/lib/chevre/repo/member.js +0 -4
  46. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  47. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  48. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  49. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  50. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  51. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  52. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  53. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  54. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  55. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  56. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  57. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  58. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  59. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  60. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  61. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  62. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +42 -3
  63. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +2 -1
  64. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  65. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  66. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  67. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  68. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  69. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  70. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  71. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  72. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  73. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  74. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  75. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  76. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  77. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  78. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  79. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  80. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  81. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  82. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  83. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  84. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  85. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  86. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  87. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  88. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  89. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  90. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  91. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  92. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  93. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  94. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  95. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  96. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  97. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  98. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
  99. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  100. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  101. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  102. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  103. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  104. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  105. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  106. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  107. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  108. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  109. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  110. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +38 -3
  111. package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
  112. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  113. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  114. package/lib/chevre/repo/offer.js +0 -5
  115. package/lib/chevre/repo/offerCatalog.js +0 -4
  116. package/lib/chevre/repo/order.d.ts +25 -0
  117. package/lib/chevre/repo/order.js +5 -4
  118. package/lib/chevre/repo/orderNumber.d.ts +0 -1
  119. package/lib/chevre/repo/orderNumber.js +2 -12
  120. package/lib/chevre/repo/ownershipInfo.js +0 -4
  121. package/lib/chevre/repo/permit.js +0 -4
  122. package/lib/chevre/repo/place.d.ts +5 -1
  123. package/lib/chevre/repo/place.js +1 -10
  124. package/lib/chevre/repo/priceSpecification.js +0 -4
  125. package/lib/chevre/repo/product.js +0 -4
  126. package/lib/chevre/repo/project.js +0 -4
  127. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
  128. package/lib/chevre/repo/rateLimit/offer.js +14 -14
  129. package/lib/chevre/repo/reservation.js +0 -4
  130. package/lib/chevre/repo/role.js +0 -4
  131. package/lib/chevre/repo/seller.js +0 -4
  132. package/lib/chevre/repo/serviceOutput.js +0 -4
  133. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
  134. package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
  135. package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -6
  136. package/lib/chevre/repo/stockHolder.js +273 -0
  137. package/lib/chevre/repo/task.d.ts +17 -2
  138. package/lib/chevre/repo/task.js +61 -10
  139. package/lib/chevre/repo/telemetry.js +0 -4
  140. package/lib/chevre/repo/transaction.d.ts +3 -2
  141. package/lib/chevre/repo/transaction.js +116 -54
  142. package/lib/chevre/repo/transactionNumber.d.ts +2 -1
  143. package/lib/chevre/repo/transactionNumber.js +14 -15
  144. package/lib/chevre/repo/trip.js +0 -4
  145. package/lib/chevre/repository.d.ts +3 -5
  146. package/lib/chevre/repository.js +5 -8
  147. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  148. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
  149. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
  150. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  151. package/lib/chevre/service/assetTransaction/pay.js +2 -2
  152. package/lib/chevre/service/assetTransaction/refund.js +1 -1
  153. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  154. package/lib/chevre/service/assetTransaction/reserve.d.ts +4 -4
  155. package/lib/chevre/service/assetTransaction/reserve.js +8 -5
  156. package/lib/chevre/service/assetTransaction.d.ts +0 -2
  157. package/lib/chevre/service/assetTransaction.js +0 -1
  158. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  159. package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
  160. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  161. package/lib/chevre/service/offer.d.ts +2 -2
  162. package/lib/chevre/service/offer.js +5 -2
  163. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
  164. package/lib/chevre/service/order/placeOrder.js +1 -1
  165. package/lib/chevre/service/order/returnOrder.js +1 -5
  166. package/lib/chevre/service/order/sendOrder.js +1 -1
  167. package/lib/chevre/service/payment/any.js +1 -1
  168. package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
  169. package/lib/chevre/service/reserve/cancelReservation.js +6 -6
  170. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
  171. package/lib/chevre/service/task/cancelPendingReservation.js +3 -3
  172. package/lib/chevre/service/task/cancelReservation.js +3 -3
  173. package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
  174. package/lib/chevre/service/task.d.ts +9 -0
  175. package/lib/chevre/service/task.js +22 -1
  176. package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
  177. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  178. package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
  179. package/lib/chevre/service/transaction/returnOrder.js +1 -5
  180. package/lib/chevre/service/transaction.d.ts +1 -0
  181. package/lib/chevre/service/transaction.js +1 -7
  182. package/lib/chevre/settings.d.ts +2 -1
  183. package/lib/chevre/settings.js +5 -4
  184. package/package.json +4 -4
  185. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  186. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  187. package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -193
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const factory = require("../factory");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const accountTitle_1 = require("./mongoose/schemas/accountTitle");
16
15
  /**
17
16
  * 科目リポジトリ
@@ -19,9 +18,6 @@ const accountTitle_1 = require("./mongoose/schemas/accountTitle");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.accountTitleModel = connection.model(accountTitle_1.modelName, accountTitle_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.accountTitleModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  deleteByProject(params) {
27
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -42,16 +42,6 @@ export declare class MongoRepository {
42
42
  id?: string;
43
43
  transactionNumber?: string;
44
44
  }): Promise<factory.account.transaction.ITransaction<T>>;
45
- /**
46
- * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
47
- */
48
- /**
49
- * タスクエクスポートリトライ
50
- * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
51
- */
52
- /**
53
- * タスクをエクスポート済に変更する
54
- */
55
45
  /**
56
46
  * 取引を期限切れにする
57
47
  */
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const accountTransaction_1 = require("./mongoose/schemas/accountTransaction");
16
15
  const factory = require("../factory");
17
16
  /**
@@ -20,9 +19,6 @@ const factory = require("../factory");
20
19
  class MongoRepository {
21
20
  constructor(connection) {
22
21
  this.transactionModel = connection.model(accountTransaction_1.modelName, accountTransaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
22
  }
27
23
  static CREATE_MONGO_CONDITIONS(params) {
28
24
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
@@ -225,59 +221,6 @@ class MongoRepository {
225
221
  return doc.toObject();
226
222
  });
227
223
  }
228
- /**
229
- * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
230
- */
231
- // public async startExportTasks<T extends factory.account.transactionType>(
232
- // status: factory.transactionStatusType
233
- // ): Promise<factory.account.transaction.ITransaction<T> | null> {
234
- // return this.transactionModel.findOneAndUpdate(
235
- // {
236
- // status: status,
237
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
238
- // },
239
- // { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting },
240
- // { new: true }
241
- // )
242
- // .exec()
243
- // // tslint:disable-next-line:no-null-keyword
244
- // .then((doc) => (doc === null) ? null : doc.toObject());
245
- // }
246
- // tslint:disable-next-line:no-suspicious-comment
247
- /**
248
- * タスクエクスポートリトライ
249
- * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
250
- */
251
- // public async reexportTasks(params: { intervalInMinutes: number }): Promise<void> {
252
- // await this.transactionModel.updateMany(
253
- // {
254
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
255
- // updatedAt: {
256
- // $lt: moment()
257
- // .add(-params.intervalInMinutes, 'minutes')
258
- // .toDate()
259
- // }
260
- // },
261
- // {
262
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
263
- // }
264
- // )
265
- // .exec();
266
- // }
267
- /**
268
- * タスクをエクスポート済に変更する
269
- */
270
- // public async setTasksExportedById(transactionId: string): Promise<void> {
271
- // await this.transactionModel.findByIdAndUpdate(
272
- // transactionId,
273
- // {
274
- // tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
275
- // tasksExportedAt: moment()
276
- // .toDate()
277
- // }
278
- // )
279
- // .exec();
280
- // }
281
224
  /**
282
225
  * 取引を期限切れにする
283
226
  */
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const accountingReport_1 = require("./mongoose/schemas/accountingReport");
15
14
  const errorHandler_1 = require("../errorHandler");
16
15
  /**
@@ -19,9 +18,6 @@ const errorHandler_1 = require("../errorHandler");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.accountingReportModel = connection.model(accountingReport_1.modelName, accountingReport_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.accountingReportModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  /**
27
23
  * なければ作成する
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const factory = require("../factory");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const action_1 = require("./mongoose/schemas/action");
16
15
  /**
17
16
  * アクションリポジトリ
@@ -19,9 +18,6 @@ const action_1 = require("./mongoose/schemas/action");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.actionModel = connection.model(action_1.modelName, action_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.actionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
27
23
  static CREATE_MONGO_CONDITIONS(params) {
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const additionalProperty_1 = require("./mongoose/schemas/additionalProperty");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.additionalPropertyModel = connection.model(additionalProperty_1.modelName, additionalProperty_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.additionalPropertyModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = exports.AggregationType = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const aggregation_1 = require("./mongoose/schemas/aggregation");
26
25
  var AggregationType;
27
26
  (function (AggregationType) {
@@ -43,9 +42,6 @@ var AggregationType;
43
42
  class MongoRepository {
44
43
  constructor(connection) {
45
44
  this.aggregationModel = connection.model(aggregation_1.modelName, aggregation_1.schema);
46
- if (connection.get('autoIndex') === true) {
47
- this.aggregationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
48
- }
49
45
  }
50
46
  saveAggregation(params) {
51
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -64,9 +64,6 @@ export declare class MongoRepository {
64
64
  typeOf: T;
65
65
  transactionNumber: string;
66
66
  }): Promise<factory.assetTransaction.ITransaction<T>>;
67
- /**
68
- * 取引を確定する
69
- */
70
67
  addReservations(params: {
71
68
  typeOf: factory.assetTransactionType.Reserve;
72
69
  id: string;
@@ -80,7 +77,7 @@ export declare class MongoRepository {
80
77
  id: string;
81
78
  result: factory.assetTransaction.IResult<T>;
82
79
  potentialActions: factory.assetTransaction.IPotentialActions<T>;
83
- }): Promise<factory.assetTransaction.ITransaction<T>>;
80
+ }): Promise<void>;
84
81
  /**
85
82
  * 取引を開始&確定
86
83
  */
@@ -100,7 +97,8 @@ export declare class MongoRepository {
100
97
  $in: T[];
101
98
  };
102
99
  status: factory.transactionStatusType;
103
- }): Promise<factory.assetTransaction.ITransaction<T> | null>;
100
+ id?: string;
101
+ }): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
104
102
  /**
105
103
  * タスクエクスポートリトライ
106
104
  * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
@@ -159,7 +157,7 @@ export declare class MongoRepository {
159
157
  /**
160
158
  * 特定の取引を更新する(汎用)
161
159
  */
162
- findByIdAndUpdate<T extends factory.assetTransactionType>(params: {
160
+ findByIdAndUpdateInProgress<T extends factory.assetTransactionType>(params: {
163
161
  id: string;
164
162
  update: any;
165
163
  }): Promise<factory.assetTransaction.ITransaction<T>>;
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
16
15
  const factory = require("../factory");
17
16
  /**
@@ -20,9 +19,6 @@ const factory = require("../factory");
20
19
  class MongoRepository {
21
20
  constructor(connection) {
22
21
  this.transactionModel = connection.model(assetTransaction_1.modelName, assetTransaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
22
  }
27
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
28
24
  static CREATE_MONGO_CONDITIONS(params) {
@@ -106,6 +102,11 @@ class MongoRepository {
106
102
  }
107
103
  });
108
104
  }
105
+ if (Array.isArray(params.tasksExportationStatuses)) {
106
+ andConditions.push({
107
+ tasksExportationStatus: { $in: params.tasksExportationStatuses }
108
+ });
109
+ }
109
110
  switch (params.typeOf) {
110
111
  case factory.assetTransactionType.Pay:
111
112
  const objectAccountIdEq = (_e = (_d = params.object) === null || _d === void 0 ? void 0 : _d.accountId) === null || _e === void 0 ? void 0 : _e.$eq;
@@ -276,15 +277,12 @@ class MongoRepository {
276
277
  return doc.toObject();
277
278
  });
278
279
  }
279
- /**
280
- * 取引を確定する
281
- */
282
280
  addReservations(params) {
283
281
  return __awaiter(this, void 0, void 0, function* () {
284
282
  const doc = yield this.transactionModel.findOneAndUpdate({
285
- _id: params.id,
286
- typeOf: params.typeOf,
287
- status: factory.transactionStatusType.InProgress
283
+ _id: { $eq: params.id },
284
+ typeOf: { $eq: params.typeOf },
285
+ status: { $eq: factory.transactionStatusType.InProgress }
288
286
  }, {
289
287
  'object.acceptedOffer': params.object.acceptedOffer,
290
288
  // 念のため残す(2021/10/14)が、そのうち削除
@@ -309,22 +307,24 @@ class MongoRepository {
309
307
  confirm(params) {
310
308
  return __awaiter(this, void 0, void 0, function* () {
311
309
  const doc = yield this.transactionModel.findOneAndUpdate({
312
- _id: params.id,
313
- typeOf: params.typeOf,
314
- status: factory.transactionStatusType.InProgress
310
+ _id: { $eq: params.id },
311
+ typeOf: { $eq: params.typeOf },
312
+ status: { $eq: factory.transactionStatusType.InProgress }
315
313
  }, {
316
314
  status: factory.transactionStatusType.Confirmed,
317
315
  endDate: new Date(),
318
316
  result: params.result,
319
317
  potentialActions: params.potentialActions // resultを更新
320
- }, { new: true })
318
+ }, {
319
+ new: true,
320
+ projection: { _id: 1 }
321
+ })
321
322
  .exec();
322
323
  // NotFoundであれば取引状態確認
323
324
  if (doc === null) {
324
325
  const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
325
326
  if (transaction.status === factory.transactionStatusType.Confirmed) {
326
- // すでに確定済の場合
327
- return transaction;
327
+ // すでに確定済の場合スルー
328
328
  }
329
329
  else if (transaction.status === factory.transactionStatusType.Expired) {
330
330
  throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
@@ -336,7 +336,6 @@ class MongoRepository {
336
336
  throw new factory.errors.NotFound(this.transactionModel.modelName);
337
337
  }
338
338
  }
339
- return doc.toObject();
340
339
  });
341
340
  }
342
341
  /**
@@ -352,15 +351,20 @@ class MongoRepository {
352
351
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
353
352
  */
354
353
  startExportTasks(params) {
355
- var _a, _b, _c;
354
+ var _a, _b;
356
355
  return __awaiter(this, void 0, void 0, function* () {
357
- return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({}, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === 'string')
358
- ? {
359
- 'project.id': {
360
- $eq: params.project.id
361
- }
362
- } : undefined), (Array.isArray((_b = params.typeOf) === null || _b === void 0 ? void 0 : _b.$in))
363
- ? { typeOf: { $in: (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$in } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
356
+ switch (params.status) {
357
+ case factory.transactionStatusType.InProgress:
358
+ throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
359
+ default:
360
+ // no op
361
+ }
362
+ const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
363
+ return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
364
+ .select({
365
+ _id: 1,
366
+ typeOf: 1
367
+ })
364
368
  .exec()
365
369
  // tslint:disable-next-line:no-null-keyword
366
370
  .then((doc) => (doc === null) ? null : doc.toObject());
@@ -374,7 +378,7 @@ class MongoRepository {
374
378
  reexportTasks(params) {
375
379
  return __awaiter(this, void 0, void 0, function* () {
376
380
  yield this.transactionModel.updateMany({
377
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
381
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
378
382
  updatedAt: {
379
383
  $lt: moment()
380
384
  .add(-params.intervalInMinutes, 'minutes')
@@ -392,10 +396,12 @@ class MongoRepository {
392
396
  */
393
397
  setTasksExportedById(params) {
394
398
  return __awaiter(this, void 0, void 0, function* () {
395
- yield this.transactionModel.findByIdAndUpdate(params.id, {
399
+ yield this.transactionModel.updateOne({
400
+ _id: { $eq: params.id },
401
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
402
+ }, {
396
403
  tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
397
- tasksExportedAt: moment()
398
- .toDate()
404
+ tasksExportedAt: new Date()
399
405
  })
400
406
  .exec();
401
407
  });
@@ -405,15 +411,29 @@ class MongoRepository {
405
411
  */
406
412
  makeExpired(params) {
407
413
  return __awaiter(this, void 0, void 0, function* () {
408
- // ステータスと期限を見て更新
409
- yield this.transactionModel.updateMany({
410
- status: factory.transactionStatusType.InProgress,
414
+ // IDをemitしたいのでまずリスト検索(2023-04-27~)
415
+ const expiringTransactions = yield this.transactionModel.find({
416
+ status: { $eq: factory.transactionStatusType.InProgress },
411
417
  expires: { $lt: params.expires }
412
- }, {
413
- status: factory.transactionStatusType.Expired,
414
- endDate: new Date()
415
418
  })
419
+ .select({
420
+ _id: 1,
421
+ typeOf: 1
422
+ })
423
+ .setOptions({ maxTimeMS: 10000 })
416
424
  .exec();
425
+ if (expiringTransactions.length > 0) {
426
+ // ステータスと期限を見て更新
427
+ yield this.transactionModel.updateMany({
428
+ _id: { $in: expiringTransactions.map((t) => t.id) },
429
+ status: { $eq: factory.transactionStatusType.InProgress },
430
+ expires: { $lt: params.expires }
431
+ }, {
432
+ status: factory.transactionStatusType.Expired,
433
+ endDate: new Date()
434
+ })
435
+ .exec();
436
+ }
417
437
  });
418
438
  }
419
439
  /**
@@ -421,19 +441,18 @@ class MongoRepository {
421
441
  */
422
442
  cancel(params) {
423
443
  return __awaiter(this, void 0, void 0, function* () {
424
- const endDate = moment()
425
- .toDate();
444
+ const endDate = new Date();
426
445
  // 進行中ステータスの取引を中止する
427
- const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: params.typeOf }, (typeof params.id === 'string') ? { _id: params.id } : undefined), (typeof params.transactionNumber === 'string')
446
+ const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
428
447
  ? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
429
- : undefined), { status: factory.transactionStatusType.InProgress }), {
448
+ : undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
430
449
  status: factory.transactionStatusType.Canceled,
431
450
  endDate: endDate
432
451
  }, { new: true })
433
452
  .exec();
453
+ let transaction;
434
454
  // NotFoundであれば取引状態確認
435
455
  if (doc === null) {
436
- let transaction;
437
456
  if (typeof params.id === 'string') {
438
457
  transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
439
458
  }
@@ -447,8 +466,7 @@ class MongoRepository {
447
466
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
448
467
  }
449
468
  if (transaction.status === factory.transactionStatusType.Canceled) {
450
- // すでに中止済の場合
451
- return transaction;
469
+ // すでに中止済の場合スルー
452
470
  }
453
471
  else if (transaction.status === factory.transactionStatusType.Expired) {
454
472
  throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
@@ -460,7 +478,10 @@ class MongoRepository {
460
478
  throw new factory.errors.NotFound(this.transactionModel.modelName);
461
479
  }
462
480
  }
463
- return doc.toObject();
481
+ else {
482
+ transaction = doc.toObject();
483
+ }
484
+ return transaction;
464
485
  });
465
486
  }
466
487
  count(params) {
@@ -522,9 +543,12 @@ class MongoRepository {
522
543
  /**
523
544
  * 特定の取引を更新する(汎用)
524
545
  */
525
- findByIdAndUpdate(params) {
546
+ findByIdAndUpdateInProgress(params) {
526
547
  return __awaiter(this, void 0, void 0, function* () {
527
- return this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, { new: true })
548
+ return this.transactionModel.findOneAndUpdate({
549
+ _id: { $eq: params.id },
550
+ status: { $eq: factory.transactionStatusType.InProgress }
551
+ }, params.update, { new: true })
528
552
  .exec()
529
553
  .then((doc) => {
530
554
  if (doc === null) {
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const categoryCode_1 = require("./mongoose/schemas/categoryCode");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.categoryCodeModel = connection.model(categoryCode_1.modelName, categoryCode_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.categoryCodeModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -13,7 +13,6 @@ exports.MongoRepository = exports.modelName = void 0;
13
13
  const moment = require("moment");
14
14
  const uuid = require("uuid");
15
15
  const factory = require("../factory");
16
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
17
16
  const authorization_1 = require("./mongoose/schemas/authorization");
18
17
  Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return authorization_1.modelName; } });
19
18
  /**
@@ -22,9 +21,6 @@ Object.defineProperty(exports, "modelName", { enumerable: true, get: function ()
22
21
  class MongoRepository {
23
22
  constructor(connection) {
24
23
  this.authorizationModel = connection.model(authorization_1.modelName, authorization_1.schema);
25
- if (connection.get('autoIndex') === true) {
26
- this.authorizationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
27
- }
28
24
  }
29
25
  // tslint:disable-next-line:max-func-body-length
30
26
  static CREATE_MONGO_CONDITIONS(params) {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const comments_1 = require("./mongoose/schemas/comments");
15
14
  const factory = require("../factory");
16
15
  /**
@@ -19,9 +18,6 @@ const factory = require("../factory");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.commentModel = connection.model(comments_1.modelName, comments_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.commentModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  static CREATE_MONGO_CONDITIONS(params) {
27
23
  var _a, _b, _c, _d, _e, _f;
@@ -36,7 +36,7 @@ class RedisRepository {
36
36
  static createKey(params) {
37
37
  const useNewKey = params.orderDate instanceof Date
38
38
  && moment(params.orderDate)
39
- .isSameOrAfter(settings_1.USE_NEW_ORDER_NUMBER_KEY_FROM);
39
+ .isSameOrAfter(settings_1.USE_NEW_CONFIRMATION_NUMBER_KEY_FROM);
40
40
  if (useNewKey) {
41
41
  return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
42
42
  .tz('Asia/Tokyo')
@@ -34,9 +34,7 @@ export declare class MongoRepository {
34
34
  /**
35
35
  * コンテンツを保管する
36
36
  */
37
- saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<import("mongoose").LeanDocument<any> & Required<{
38
- _id: unknown;
39
- }>>;
37
+ saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<any>;
40
38
  findMovieById(params: {
41
39
  id: string;
42
40
  }): Promise<factory.creativeWork.movie.ICreativeWork>;
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const creativeWork_1 = require("./mongoose/schemas/creativeWork");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.creativeWorkModel = connection.model(creativeWork_1.modelName, creativeWork_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.creativeWorkModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const customer_1 = require("./mongoose/schemas/customer");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.customerModel = connection.model(customer_1.modelName, customer_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.customerModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -1,27 +1,3 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose/types/inferschematype" />
25
1
  import { Connection } from 'mongoose';
26
2
  import * as factory from '../factory';
27
3
  export type IEmailMessage = factory.creativeWork.message.email.ICreativeWork;
@@ -50,9 +26,7 @@ export declare class MongoRepository {
50
26
  private readonly emailMessageModel;
51
27
  constructor(connection: Connection);
52
28
  static CREATE_MONGO_CONDITIONS(params: ISearchConditions): any[];
53
- save(params: IEmailMessage): Promise<import("mongoose").LeanDocument<any> & Required<{
54
- _id: unknown;
55
- }>>;
29
+ save(params: IEmailMessage): Promise<any>;
56
30
  findById(params: {
57
31
  id: string;
58
32
  }): Promise<IEmailMessage>;
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const emailMessages_1 = require("./mongoose/schemas/emailMessages");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.emailMessageModel = connection.model(emailMessages_1.modelName, emailMessages_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.emailMessageModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  static CREATE_MONGO_CONDITIONS(params) {
38
34
  var _a, _b, _c, _d, _e;
@@ -169,7 +169,11 @@ export declare class MongoRepository {
169
169
  updateAggregationById<T extends factory.eventType>(params: {
170
170
  id: string;
171
171
  }, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
172
- bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
172
+ bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject & {
173
+ mongoose?: {
174
+ validationErrors: import("mongoose").Error[];
175
+ } | undefined;
176
+ }>;
173
177
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
174
178
  unsetUnnecessaryFields(params: {
175
179
  filter: any;