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

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 +4 -2
  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
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
16
15
  const task_1 = require("./mongoose/schemas/task");
16
+ const task_2 = require("../eventEmitter/task");
17
17
  /**
18
18
  * タスク実行時のソート条件
19
19
  */
@@ -27,9 +27,6 @@ const sortOrder4executionOfTasks = {
27
27
  class MongoRepository {
28
28
  constructor(connection) {
29
29
  this.taskModel = connection.model(task_1.modelName, task_1.schema);
30
- if (connection.get('autoIndex') === true) {
31
- this.taskModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
32
- }
33
30
  }
34
31
  // tslint:disable-next-line:max-func-body-length
35
32
  static CREATE_MONGO_CONDITIONS(params) {
@@ -153,27 +150,43 @@ class MongoRepository {
153
150
  }
154
151
  return andConditions;
155
152
  }
156
- saveMany(taskAttributes) {
153
+ saveMany(taskAttributes, options) {
157
154
  return __awaiter(this, void 0, void 0, function* () {
155
+ const emitImmediately = (options === null || options === void 0 ? void 0 : options.emitImmediately) === true;
158
156
  if (taskAttributes.length > 0) {
159
157
  const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
160
158
  if (result.insertedCount !== taskAttributes.length) {
161
159
  throw new factory.errors.ServiceUnavailable('all tasks not saved');
162
160
  }
163
- // return result.ops;
164
- return Object.values(result.insertedIds)
161
+ const savedTasks = Object.values(result.insertedIds)
165
162
  .map((objectId) => {
166
163
  return { id: objectId.toHexString() };
167
164
  });
165
+ if (emitImmediately) {
166
+ savedTasks.forEach((savedTask) => {
167
+ task_2.taskEventEmitter.emitTaskStatusChanged({
168
+ id: savedTask.id,
169
+ status: factory.taskStatus.Ready
170
+ });
171
+ });
172
+ // taskAttributes.forEach((savedTask) => {
173
+ // taskEventEmitter.emitTaskStatusChanged({
174
+ // name: savedTask.name,
175
+ // status: factory.taskStatus.Ready
176
+ // });
177
+ // });
178
+ }
179
+ // return result.ops;
180
+ return savedTasks;
168
181
  }
169
182
  else {
170
183
  return [];
171
184
  }
172
185
  });
173
186
  }
174
- createInformTaskIfNotExist(params) {
187
+ createInformTaskIfNotExist(params, options) {
175
188
  return __awaiter(this, void 0, void 0, function* () {
176
- yield this.taskModel.findOneAndUpdate({
189
+ const createdTask = yield this.taskModel.findOneAndUpdate({
177
190
  'project.id': { $eq: params.project.id },
178
191
  name: params.name,
179
192
  'data.object.id': {
@@ -181,7 +194,38 @@ class MongoRepository {
181
194
  $eq: String(params.data.object.id)
182
195
  }
183
196
  }, { $setOnInsert: params }, { new: true, upsert: true })
197
+ .select({ _id: 1 })
184
198
  .exec();
199
+ if (options.emitImmediately) {
200
+ task_2.taskEventEmitter.emitTaskStatusChanged({
201
+ id: createdTask.id,
202
+ name: params.name,
203
+ status: factory.taskStatus.Ready
204
+ });
205
+ }
206
+ });
207
+ }
208
+ executeById(params) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const doc = yield this.taskModel.findOneAndUpdate({
211
+ status: factory.taskStatus.Ready,
212
+ runsAt: { $lt: new Date() },
213
+ _id: { $eq: params.id }
214
+ }, {
215
+ status: factory.taskStatus.Running,
216
+ lastTriedAt: new Date(),
217
+ $inc: {
218
+ remainingNumberOfTries: -1,
219
+ numberOfTried: 1 // トライ回数増やす
220
+ },
221
+ executor: params.executor
222
+ }, { new: true })
223
+ .exec();
224
+ if (doc === null) {
225
+ // tslint:disable-next-line:no-null-keyword
226
+ return null;
227
+ }
228
+ return doc.toObject();
185
229
  });
186
230
  }
187
231
  executeOneByName(params) {
@@ -196,7 +240,8 @@ class MongoRepository {
196
240
  $inc: {
197
241
  remainingNumberOfTries: -1,
198
242
  numberOfTried: 1 // トライ回数増やす
199
- }
243
+ },
244
+ executor: params.executor
200
245
  }, { new: true })
201
246
  .sort(sortOrder4executionOfTasks)
202
247
  .exec();
@@ -207,6 +252,35 @@ class MongoRepository {
207
252
  return doc.toObject();
208
253
  });
209
254
  }
255
+ /**
256
+ * 一定期間遅延したタスクを実行する
257
+ */
258
+ executeTasks(params) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ const runsAtLt = moment(params.now)
261
+ .add(-params.delayInSeconds, 'seconds')
262
+ .toDate();
263
+ const delayedTasks = yield this.taskModel.find(Object.assign(Object.assign({ status: { $eq: factory.taskStatus.Ready }, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$in)) ? { name: { $in: params.name.$in } } : undefined), (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
264
+ .select({
265
+ _id: 1,
266
+ name: 1,
267
+ status: 1
268
+ })
269
+ .limit(params.limit)
270
+ .setOptions({ maxTimeMS: 10000 })
271
+ .exec();
272
+ if (delayedTasks.length > 0) {
273
+ delayedTasks.forEach((delayedTask) => {
274
+ task_2.taskEventEmitter.emitTaskStatusChanged({
275
+ id: delayedTask.id,
276
+ name: delayedTask.name,
277
+ status: delayedTask.status
278
+ });
279
+ });
280
+ }
281
+ return delayedTasks;
282
+ });
283
+ }
210
284
  retry(params) {
211
285
  return __awaiter(this, void 0, void 0, function* () {
212
286
  const lastTriedAtShoudBeLessThan = moment()
@@ -337,9 +411,20 @@ class MongoRepository {
337
411
  });
338
412
  }
339
413
  deleteByName(params) {
414
+ var _a;
340
415
  return __awaiter(this, void 0, void 0, function* () {
341
- return this.taskModel.deleteMany({
342
- name: { $eq: params.name }
416
+ return this.taskModel.deleteMany(Object.assign({ name: { $eq: params.name } }, (typeof ((_a = params.status) === null || _a === void 0 ? void 0 : _a.$eq) === 'string') ? { status: { $eq: params.status.$eq } } : undefined))
417
+ .exec();
418
+ });
419
+ }
420
+ countDelayedTasks(params) {
421
+ return __awaiter(this, void 0, void 0, function* () {
422
+ const runsAtLt = moment()
423
+ .add(-params.delayInSeconds, 'seconds')
424
+ .toDate();
425
+ return this.taskModel.count({
426
+ status: factory.taskStatus.Ready,
427
+ runsAt: { $lt: runsAtLt }
343
428
  })
344
429
  .exec();
345
430
  });
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MongoRepository = void 0;
4
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
5
4
  const telemetry_1 = require("./mongoose/schemas/telemetry");
6
5
  /**
7
6
  * 測定リポジトリ
@@ -9,9 +8,6 @@ const telemetry_1 = require("./mongoose/schemas/telemetry");
9
8
  class MongoRepository {
10
9
  constructor(connection) {
11
10
  this.telemetryModel = connection.model(telemetry_1.modelName, telemetry_1.schema);
12
- if (connection.get('autoIndex') === true) {
13
- this.telemetryModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
14
- }
15
11
  }
16
12
  }
17
13
  exports.MongoRepository = MongoRepository;
@@ -40,6 +40,8 @@ export declare class MongoRepository {
40
40
  findById<T extends factory.transactionType>(params: {
41
41
  typeOf: T;
42
42
  id: string;
43
+ inclusion?: string[];
44
+ exclusion?: string[];
43
45
  }): Promise<factory.transaction.ITransaction<T>>;
44
46
  /**
45
47
  * 進行中の取引を取得する
@@ -111,7 +113,13 @@ export declare class MongoRepository {
111
113
  $in: T[];
112
114
  };
113
115
  status: factory.transactionStatusType;
114
- }): Promise<factory.transaction.ITransaction<T> | null>;
116
+ id?: string;
117
+ tasksExportAction: {
118
+ agent: {
119
+ name: string;
120
+ };
121
+ };
122
+ }): Promise<Pick<factory.transaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
115
123
  /**
116
124
  * タスクエクスポートリトライ
117
125
  * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
@@ -119,6 +127,16 @@ export declare class MongoRepository {
119
127
  reexportTasks(params: {
120
128
  intervalInMinutes: number;
121
129
  }): Promise<void>;
130
+ /**
131
+ * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
132
+ */
133
+ exportTasks(params: {
134
+ now: Date;
135
+ delayInSeconds: number;
136
+ status: {
137
+ $in: factory.transactionStatusType[];
138
+ };
139
+ }): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
122
140
  /**
123
141
  * set task status exported by transaction id
124
142
  * IDでタスクをエクスポート済に変更する
@@ -130,7 +148,9 @@ export declare class MongoRepository {
130
148
  * 取引を期限切れにする
131
149
  */
132
150
  makeExpired(params: {
133
- expires: Date;
151
+ expires: {
152
+ $lt: Date;
153
+ };
134
154
  }): Promise<void>;
135
155
  /**
136
156
  * 取引を中止する
@@ -150,7 +170,7 @@ export declare class MongoRepository {
150
170
  /**
151
171
  * 特定の取引を更新する(汎用)
152
172
  */
153
- findByIdAndUpdate(params: {
173
+ findByIdAndUpdateInProgress(params: {
154
174
  id: string;
155
175
  update: {
156
176
  $set?: any;
@@ -12,17 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
16
15
  const transaction_1 = require("./mongoose/schemas/transaction");
16
+ const transaction_2 = require("../eventEmitter/transaction");
17
17
  /**
18
18
  * 取引リポジトリ
19
19
  */
20
20
  class MongoRepository {
21
21
  constructor(connection) {
22
22
  this.transactionModel = connection.model(transaction_1.modelName, transaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
23
  }
27
24
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
28
25
  static CREATE_MONGO_CONDITIONS(params) {
@@ -267,7 +264,9 @@ class MongoRepository {
267
264
  else {
268
265
  expires = params.expires;
269
266
  }
270
- return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
267
+ return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportAction: {
268
+ actionStatus: factory.actionStatusType.PotentialActionStatus
269
+ }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
271
270
  .then((doc) => doc.toObject());
272
271
  });
273
272
  }
@@ -276,10 +275,29 @@ class MongoRepository {
276
275
  */
277
276
  findById(params) {
278
277
  return __awaiter(this, void 0, void 0, function* () {
278
+ let projection = {};
279
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
280
+ params.inclusion.forEach((field) => {
281
+ projection[field] = 1;
282
+ });
283
+ }
284
+ else {
285
+ projection = {
286
+ __v: 0,
287
+ createdAt: 0,
288
+ updatedAt: 0
289
+ };
290
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
291
+ params.exclusion.forEach((field) => {
292
+ projection[field] = 0;
293
+ });
294
+ }
295
+ }
279
296
  const doc = yield this.transactionModel.findOne({
280
297
  _id: { $eq: params.id },
281
298
  typeOf: { $eq: params.typeOf }
282
299
  })
300
+ .select(projection)
283
301
  .exec();
284
302
  if (doc === null) {
285
303
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -295,7 +313,9 @@ class MongoRepository {
295
313
  const doc = yield this.transactionModel.findOne({
296
314
  _id: { $eq: params.id },
297
315
  typeOf: { $eq: params.typeOf },
298
- status: { $eq: factory.transactionStatusType.InProgress }
316
+ status: { $eq: factory.transactionStatusType.InProgress },
317
+ // expiresを条件に追加(2023-05-12~),
318
+ expires: { $gt: new Date() }
299
319
  })
300
320
  .exec();
301
321
  if (doc === null) {
@@ -347,9 +367,9 @@ class MongoRepository {
347
367
  var _a, _b;
348
368
  return __awaiter(this, void 0, void 0, function* () {
349
369
  const doc = yield this.transactionModel.findOneAndUpdate({
350
- _id: params.id,
351
- typeOf: params.typeOf,
352
- status: factory.transactionStatusType.InProgress
370
+ _id: { $eq: params.id },
371
+ typeOf: { $eq: params.typeOf },
372
+ status: { $eq: factory.transactionStatusType.InProgress }
353
373
  }, {
354
374
  $set: Object.assign(Object.assign({ 'agent.id': params.agent.id }, (typeof params.agent.name === 'string') ? { 'agent.name': params.agent.name } : undefined), (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.customer) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { 'object.customer': params.object.customer } : undefined)
355
375
  }, {
@@ -367,9 +387,9 @@ class MongoRepository {
367
387
  updateExpires(params) {
368
388
  return __awaiter(this, void 0, void 0, function* () {
369
389
  const doc = yield this.transactionModel.findOneAndUpdate({
370
- _id: params.id,
371
- typeOf: params.typeOf,
372
- status: factory.transactionStatusType.InProgress
390
+ _id: { $eq: params.id },
391
+ typeOf: { $eq: params.typeOf },
392
+ status: { $eq: factory.transactionStatusType.InProgress }
373
393
  }, {
374
394
  $set: {
375
395
  expires: params.expires
@@ -391,9 +411,9 @@ class MongoRepository {
391
411
  var _a;
392
412
  return __awaiter(this, void 0, void 0, function* () {
393
413
  const doc = yield this.transactionModel.findOneAndUpdate({
394
- _id: params.id,
395
- typeOf: params.typeOf,
396
- status: factory.transactionStatusType.InProgress
414
+ _id: { $eq: params.id },
415
+ typeOf: { $eq: params.typeOf },
416
+ status: { $eq: factory.transactionStatusType.InProgress }
397
417
  }, {
398
418
  $set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
399
419
  }, {
@@ -411,9 +431,9 @@ class MongoRepository {
411
431
  confirm(params) {
412
432
  return __awaiter(this, void 0, void 0, function* () {
413
433
  const doc = yield this.transactionModel.findOneAndUpdate({
414
- _id: params.id,
415
- typeOf: params.typeOf,
416
- status: factory.transactionStatusType.InProgress
434
+ _id: { $eq: params.id },
435
+ typeOf: { $eq: params.typeOf },
436
+ status: { $eq: factory.transactionStatusType.InProgress }
417
437
  }, {
418
438
  status: factory.transactionStatusType.Confirmed,
419
439
  endDate: new Date(),
@@ -428,43 +448,49 @@ class MongoRepository {
428
448
  // NotFoundであれば取引状態確認
429
449
  if (doc === null) {
430
450
  const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
431
- // tslint:disable-next-line:no-single-line-block-comment
432
- /* istanbul ignore next */
433
451
  if (transaction.status === factory.transactionStatusType.Confirmed) {
434
- // すでに確定済の場合
435
- return;
436
- // tslint:disable-next-line:no-single-line-block-comment
437
- /* istanbul ignore next */
452
+ // すでに確定済の場合スルー
438
453
  }
439
454
  else if (transaction.status === factory.transactionStatusType.Expired) {
440
455
  throw new factory.errors.Argument('Transaction id', 'Already expired');
441
- // tslint:disable-next-line:no-single-line-block-comment
442
- /* istanbul ignore next */
443
456
  }
444
457
  else if (transaction.status === factory.transactionStatusType.Canceled) {
445
458
  throw new factory.errors.Argument('Transaction id', 'Already canceled');
446
- // tslint:disable-next-line:no-single-line-block-comment
447
- /* istanbul ignore next */
448
459
  }
449
460
  else {
450
461
  throw new factory.errors.NotFound(this.transactionModel.modelName);
451
462
  }
452
463
  }
453
- // return doc.toObject();
464
+ transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
465
+ id: params.id,
466
+ typeOf: params.typeOf,
467
+ status: factory.transactionStatusType.Confirmed
468
+ });
454
469
  });
455
470
  }
456
471
  /**
457
472
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
458
473
  */
459
474
  startExportTasks(params) {
475
+ var _a;
460
476
  return __awaiter(this, void 0, void 0, function* () {
461
- return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({}, (params.project !== undefined)
462
- ? {
463
- 'project.id': {
464
- $eq: params.project.id
465
- }
466
- } : undefined), (params.typeOf !== undefined && params.typeOf !== null && Array.isArray(params.typeOf.$in))
467
- ? { typeOf: { $in: params.typeOf.$in } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
477
+ switch (params.status) {
478
+ case factory.transactionStatusType.InProgress:
479
+ throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
480
+ default:
481
+ // no op
482
+ }
483
+ const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
484
+ return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.project !== undefined) ? { '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), {
485
+ 'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
486
+ 'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
487
+ 'tasksExportAction.startDate': new Date(),
488
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
489
+ }, { new: true })
490
+ .select({
491
+ _id: 1,
492
+ typeOf: 1
493
+ })
468
494
  .exec()
469
495
  // tslint:disable-next-line:no-null-keyword
470
496
  .then((doc) => (doc === null) ? null : doc.toObject());
@@ -477,17 +503,74 @@ class MongoRepository {
477
503
  */
478
504
  reexportTasks(params) {
479
505
  return __awaiter(this, void 0, void 0, function* () {
480
- yield this.transactionModel.updateMany({
481
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
506
+ const reexportingTransactions = yield this.transactionModel.find({
507
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
482
508
  updatedAt: {
483
509
  $lt: moment()
484
510
  .add(-params.intervalInMinutes, 'minutes')
485
511
  .toDate()
486
512
  }
487
- }, {
488
- tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
489
513
  })
514
+ .select({
515
+ _id: 1,
516
+ typeOf: 1,
517
+ status: 1
518
+ })
519
+ .setOptions({ maxTimeMS: 10000 })
520
+ .exec();
521
+ if (reexportingTransactions.length > 0) {
522
+ for (const reexportingTransaction of reexportingTransactions) {
523
+ yield this.transactionModel.updateOne({
524
+ _id: { $eq: reexportingTransaction.id },
525
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
526
+ }, {
527
+ tasksExportAction: {
528
+ actionStatus: factory.actionStatusType.PotentialActionStatus
529
+ },
530
+ tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
531
+ })
532
+ .exec();
533
+ transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
534
+ id: reexportingTransaction.id,
535
+ typeOf: reexportingTransaction.typeOf,
536
+ status: reexportingTransaction.status
537
+ });
538
+ }
539
+ }
540
+ });
541
+ }
542
+ /**
543
+ * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
544
+ */
545
+ exportTasks(params) {
546
+ return __awaiter(this, void 0, void 0, function* () {
547
+ const delayedTransactions = yield this.transactionModel.find({
548
+ status: { $in: params.status.$in },
549
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
550
+ endDate: {
551
+ $exists: true,
552
+ $lt: moment(params.now)
553
+ .add(-params.delayInSeconds, 'seconds')
554
+ .toDate()
555
+ }
556
+ })
557
+ .select({
558
+ _id: 1,
559
+ typeOf: 1,
560
+ status: 1
561
+ })
562
+ .setOptions({ maxTimeMS: 10000 })
490
563
  .exec();
564
+ if (delayedTransactions.length > 0) {
565
+ delayedTransactions.forEach((delayedTransaction) => {
566
+ transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
567
+ id: delayedTransaction.id,
568
+ typeOf: delayedTransaction.typeOf,
569
+ status: delayedTransaction.status
570
+ });
571
+ });
572
+ }
573
+ return delayedTransactions;
491
574
  });
492
575
  }
493
576
  /**
@@ -496,9 +579,15 @@ class MongoRepository {
496
579
  */
497
580
  setTasksExportedById(params) {
498
581
  return __awaiter(this, void 0, void 0, function* () {
499
- yield this.transactionModel.findByIdAndUpdate(params.id, {
582
+ const endDate = new Date();
583
+ yield this.transactionModel.updateOne({
584
+ _id: { $eq: params.id },
585
+ tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
586
+ }, {
500
587
  tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
501
- tasksExportedAt: new Date()
588
+ tasksExportedAt: endDate,
589
+ 'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
590
+ 'tasksExportAction.endDate': endDate
502
591
  })
503
592
  .exec();
504
593
  });
@@ -508,15 +597,36 @@ class MongoRepository {
508
597
  */
509
598
  makeExpired(params) {
510
599
  return __awaiter(this, void 0, void 0, function* () {
511
- // ステータスと期限を見て更新
512
- yield this.transactionModel.updateMany({
513
- status: factory.transactionStatusType.InProgress,
514
- expires: { $lt: params.expires }
515
- }, {
516
- status: factory.transactionStatusType.Expired,
517
- endDate: new Date()
600
+ // IDをemitしたいのでまずリスト検索(2023-04-27~)
601
+ const expiringTransactions = yield this.transactionModel.find({
602
+ status: { $eq: factory.transactionStatusType.InProgress },
603
+ expires: { $lt: params.expires.$lt }
604
+ })
605
+ .select({
606
+ _id: 1,
607
+ typeOf: 1
518
608
  })
609
+ .setOptions({ maxTimeMS: 10000 })
519
610
  .exec();
611
+ if (expiringTransactions.length > 0) {
612
+ // ステータスと期限を見て更新
613
+ yield this.transactionModel.updateMany({
614
+ _id: { $in: expiringTransactions.map((t) => t.id) },
615
+ status: { $eq: factory.transactionStatusType.InProgress },
616
+ expires: { $lt: params.expires.$lt }
617
+ }, {
618
+ status: factory.transactionStatusType.Expired,
619
+ endDate: new Date()
620
+ })
621
+ .exec();
622
+ expiringTransactions.forEach((expiringTransaction) => {
623
+ transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
624
+ id: expiringTransaction.id,
625
+ typeOf: expiringTransaction.typeOf,
626
+ status: factory.transactionStatusType.Expired
627
+ });
628
+ });
629
+ }
520
630
  });
521
631
  }
522
632
  /**
@@ -541,11 +651,8 @@ class MongoRepository {
541
651
  // NotFoundであれば取引状態確認
542
652
  if (doc === null) {
543
653
  const transaction = yield this.findById(params);
544
- // tslint:disable-next-line:no-single-line-block-comment
545
- /* istanbul ignore next */
546
654
  if (transaction.status === factory.transactionStatusType.Canceled) {
547
- // すでに中止済の場合
548
- return;
655
+ // すでに中止済の場合スルー
549
656
  }
550
657
  else if (transaction.status === factory.transactionStatusType.Expired) {
551
658
  throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
@@ -557,7 +664,11 @@ class MongoRepository {
557
664
  throw new factory.errors.NotFound(this.transactionModel.modelName);
558
665
  }
559
666
  }
560
- // return doc.toObject();
667
+ transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
668
+ id: params.id,
669
+ typeOf: params.typeOf,
670
+ status: factory.transactionStatusType.Canceled
671
+ });
561
672
  });
562
673
  }
563
674
  count(params) {
@@ -615,9 +726,12 @@ class MongoRepository {
615
726
  /**
616
727
  * 特定の取引を更新する(汎用)
617
728
  */
618
- findByIdAndUpdate(params) {
729
+ findByIdAndUpdateInProgress(params) {
619
730
  return __awaiter(this, void 0, void 0, function* () {
620
- yield this.transactionModel.findOneAndUpdate({ _id: params.id }, params.update, {
731
+ yield this.transactionModel.findOneAndUpdate({
732
+ _id: { $eq: params.id },
733
+ status: { $eq: factory.transactionStatusType.InProgress }
734
+ }, params.update, {
621
735
  // new: true,
622
736
  projection: { _id: 1 }
623
737
  })
@@ -632,7 +746,8 @@ class MongoRepository {
632
746
  saveOrderNumberIfNotExist(params) {
633
747
  return __awaiter(this, void 0, void 0, function* () {
634
748
  yield this.transactionModel.updateOne({
635
- _id: params.id,
749
+ _id: { $eq: params.id },
750
+ status: { $eq: factory.transactionStatusType.InProgress },
636
751
  'object.orderNumber': { $exists: false }
637
752
  }, { 'object.orderNumber': params.orderNumber })
638
753
  .exec();
@@ -641,7 +756,8 @@ class MongoRepository {
641
756
  saveConfirmationNumberIfNotExist(params) {
642
757
  return __awaiter(this, void 0, void 0, function* () {
643
758
  yield this.transactionModel.updateOne({
644
- _id: params.id,
759
+ _id: { $eq: params.id },
760
+ status: { $eq: factory.transactionStatusType.InProgress },
645
761
  'object.confirmationNumber': { $exists: false }
646
762
  }, { 'object.confirmationNumber': params.confirmationNumber })
647
763
  .exec();
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
24
  const factory = require("../factory");
25
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
26
25
  const trip_1 = require("./mongoose/schemas/trip");
27
26
  /**
28
27
  * トリップリポジトリ
@@ -30,9 +29,6 @@ const trip_1 = require("./mongoose/schemas/trip");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.tripModel = connection.model(trip_1.modelName, trip_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.tripModel.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(conditions) {