@chevre/domain 21.2.0-alpha.9 → 21.2.0-alpha.90
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.
- package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/processReserve.ts +2 -1
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchSellers.ts +33 -0
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/example/src/playOnMoment.ts +24 -0
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +1 -54
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +32 -25
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +241 -80
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -5
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +27 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -4
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +120 -0
- package/lib/chevre/repo/order.d.ts +52 -2
- package/lib/chevre/repo/order.js +52 -4
- package/lib/chevre/repo/reservation.d.ts +8 -4
- package/lib/chevre/repo/reservation.js +12 -42
- package/lib/chevre/repo/seller.js +19 -19
- package/lib/chevre/repo/task.d.ts +42 -2
- package/lib/chevre/repo/task.js +90 -9
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +174 -54
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.js +10 -25
- package/lib/chevre/service/assetTransaction/refund.js +1 -23
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -22
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -1
- package/lib/chevre/service/assetTransaction/reserve.js +40 -41
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/authorize.d.ts +1 -0
- package/lib/chevre/service/offer/event/authorize.js +5 -2
- package/lib/chevre/service/offer/event/factory.d.ts +2 -0
- package/lib/chevre/service/offer/event/factory.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +4 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/onOrderUpdated.d.ts +15 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -0
- package/lib/chevre/service/order/placeOrder.js +41 -24
- package/lib/chevre/service/order/returnOrder.d.ts +1 -0
- package/lib/chevre/service/order/returnOrder.js +7 -12
- package/lib/chevre/service/order/sendOrder.d.ts +1 -0
- package/lib/chevre/service/order/sendOrder.js +7 -10
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.js +74 -16
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.js +4 -3
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.d.ts +4 -2
- package/lib/chevre/service/reserve/cancelReservation.js +2 -4
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
- package/lib/chevre/service/reserve/checkInReservation.js +77 -3
- package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
- package/lib/chevre/service/reserve/confirmReservation.js +121 -58
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/useReservation.js +61 -71
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
- package/lib/chevre/service/reserve.d.ts +3 -2
- package/lib/chevre/service/reserve.js +4 -2
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
- package/lib/chevre/service/task/placeOrder.js +1 -1
- package/lib/chevre/service/task/reserve.js +10 -7
- package/lib/chevre/service/task/returnOrder.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/sendOrder.js +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/useReservation.js +36 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
- package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder.js +225 -35
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +15 -5
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
- package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
- package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
- package/lib/chevre/service/task/deleteOrder.js +0 -35
package/lib/chevre/repo/task.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.MongoRepository = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const task_1 = require("./mongoose/schemas/task");
|
|
16
|
+
const task_2 = require("../eventEmitter/task");
|
|
16
17
|
/**
|
|
17
18
|
* タスク実行時のソート条件
|
|
18
19
|
*/
|
|
@@ -149,27 +150,43 @@ class MongoRepository {
|
|
|
149
150
|
}
|
|
150
151
|
return andConditions;
|
|
151
152
|
}
|
|
152
|
-
saveMany(taskAttributes) {
|
|
153
|
+
saveMany(taskAttributes, options) {
|
|
153
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const emitImmediately = (options === null || options === void 0 ? void 0 : options.emitImmediately) === true;
|
|
154
156
|
if (taskAttributes.length > 0) {
|
|
155
157
|
const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
|
|
156
158
|
if (result.insertedCount !== taskAttributes.length) {
|
|
157
159
|
throw new factory.errors.ServiceUnavailable('all tasks not saved');
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
return Object.values(result.insertedIds)
|
|
161
|
+
const savedTasks = Object.values(result.insertedIds)
|
|
161
162
|
.map((objectId) => {
|
|
162
163
|
return { id: objectId.toHexString() };
|
|
163
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;
|
|
164
181
|
}
|
|
165
182
|
else {
|
|
166
183
|
return [];
|
|
167
184
|
}
|
|
168
185
|
});
|
|
169
186
|
}
|
|
170
|
-
createInformTaskIfNotExist(params) {
|
|
187
|
+
createInformTaskIfNotExist(params, options) {
|
|
171
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
yield this.taskModel.findOneAndUpdate({
|
|
189
|
+
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
173
190
|
'project.id': { $eq: params.project.id },
|
|
174
191
|
name: params.name,
|
|
175
192
|
'data.object.id': {
|
|
@@ -177,7 +194,38 @@ class MongoRepository {
|
|
|
177
194
|
$eq: String(params.data.object.id)
|
|
178
195
|
}
|
|
179
196
|
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
197
|
+
.select({ _id: 1 })
|
|
180
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();
|
|
181
229
|
});
|
|
182
230
|
}
|
|
183
231
|
executeOneByName(params) {
|
|
@@ -192,7 +240,8 @@ class MongoRepository {
|
|
|
192
240
|
$inc: {
|
|
193
241
|
remainingNumberOfTries: -1,
|
|
194
242
|
numberOfTried: 1 // トライ回数増やす
|
|
195
|
-
}
|
|
243
|
+
},
|
|
244
|
+
executor: params.executor
|
|
196
245
|
}, { new: true })
|
|
197
246
|
.sort(sortOrder4executionOfTasks)
|
|
198
247
|
.exec();
|
|
@@ -203,6 +252,35 @@ class MongoRepository {
|
|
|
203
252
|
return doc.toObject();
|
|
204
253
|
});
|
|
205
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
|
+
}
|
|
206
284
|
retry(params) {
|
|
207
285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
286
|
const lastTriedAtShoudBeLessThan = moment()
|
|
@@ -333,10 +411,13 @@ class MongoRepository {
|
|
|
333
411
|
});
|
|
334
412
|
}
|
|
335
413
|
deleteByName(params) {
|
|
414
|
+
var _a, _b;
|
|
336
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
-
return this.taskModel.deleteMany({
|
|
338
|
-
|
|
339
|
-
|
|
416
|
+
return this.taskModel.deleteMany(Object.assign(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), (((_b = params.runsAt) === null || _b === void 0 ? void 0 : _b.$gte) instanceof Date)
|
|
417
|
+
? {
|
|
418
|
+
runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
|
|
419
|
+
}
|
|
420
|
+
: undefined))
|
|
340
421
|
.exec();
|
|
341
422
|
});
|
|
342
423
|
}
|
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
|
|
173
|
+
findByIdAndUpdateInProgress(params: {
|
|
154
174
|
id: string;
|
|
155
175
|
update: {
|
|
156
176
|
$set?: any;
|
|
@@ -13,6 +13,7 @@ exports.MongoRepository = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const transaction_1 = require("./mongoose/schemas/transaction");
|
|
16
|
+
const transaction_2 = require("../eventEmitter/transaction");
|
|
16
17
|
/**
|
|
17
18
|
* 取引リポジトリ
|
|
18
19
|
*/
|
|
@@ -263,7 +264,9 @@ class MongoRepository {
|
|
|
263
264
|
else {
|
|
264
265
|
expires = params.expires;
|
|
265
266
|
}
|
|
266
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires,
|
|
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 }))
|
|
267
270
|
.then((doc) => doc.toObject());
|
|
268
271
|
});
|
|
269
272
|
}
|
|
@@ -272,10 +275,29 @@ class MongoRepository {
|
|
|
272
275
|
*/
|
|
273
276
|
findById(params) {
|
|
274
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
|
+
}
|
|
275
296
|
const doc = yield this.transactionModel.findOne({
|
|
276
297
|
_id: { $eq: params.id },
|
|
277
298
|
typeOf: { $eq: params.typeOf }
|
|
278
299
|
})
|
|
300
|
+
.select(projection)
|
|
279
301
|
.exec();
|
|
280
302
|
if (doc === null) {
|
|
281
303
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -291,7 +313,9 @@ class MongoRepository {
|
|
|
291
313
|
const doc = yield this.transactionModel.findOne({
|
|
292
314
|
_id: { $eq: params.id },
|
|
293
315
|
typeOf: { $eq: params.typeOf },
|
|
294
|
-
status: { $eq: factory.transactionStatusType.InProgress }
|
|
316
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
317
|
+
// expiresを条件に追加(2023-05-12~),
|
|
318
|
+
expires: { $gt: new Date() }
|
|
295
319
|
})
|
|
296
320
|
.exec();
|
|
297
321
|
if (doc === null) {
|
|
@@ -343,9 +367,9 @@ class MongoRepository {
|
|
|
343
367
|
var _a, _b;
|
|
344
368
|
return __awaiter(this, void 0, void 0, function* () {
|
|
345
369
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
346
|
-
_id: params.id,
|
|
347
|
-
typeOf: params.typeOf,
|
|
348
|
-
status: factory.transactionStatusType.InProgress
|
|
370
|
+
_id: { $eq: params.id },
|
|
371
|
+
typeOf: { $eq: params.typeOf },
|
|
372
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
349
373
|
}, {
|
|
350
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)
|
|
351
375
|
}, {
|
|
@@ -363,9 +387,9 @@ class MongoRepository {
|
|
|
363
387
|
updateExpires(params) {
|
|
364
388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
389
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
366
|
-
_id: params.id,
|
|
367
|
-
typeOf: params.typeOf,
|
|
368
|
-
status: factory.transactionStatusType.InProgress
|
|
390
|
+
_id: { $eq: params.id },
|
|
391
|
+
typeOf: { $eq: params.typeOf },
|
|
392
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
369
393
|
}, {
|
|
370
394
|
$set: {
|
|
371
395
|
expires: params.expires
|
|
@@ -387,9 +411,9 @@ class MongoRepository {
|
|
|
387
411
|
var _a;
|
|
388
412
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
413
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
390
|
-
_id: params.id,
|
|
391
|
-
typeOf: params.typeOf,
|
|
392
|
-
status: factory.transactionStatusType.InProgress
|
|
414
|
+
_id: { $eq: params.id },
|
|
415
|
+
typeOf: { $eq: params.typeOf },
|
|
416
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
393
417
|
}, {
|
|
394
418
|
$set: Object.assign({}, (typeof ((_a = params.object) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? { 'object.name': params.object.name } : undefined)
|
|
395
419
|
}, {
|
|
@@ -407,9 +431,9 @@ class MongoRepository {
|
|
|
407
431
|
confirm(params) {
|
|
408
432
|
return __awaiter(this, void 0, void 0, function* () {
|
|
409
433
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
410
|
-
_id: params.id,
|
|
411
|
-
typeOf: params.typeOf,
|
|
412
|
-
status: factory.transactionStatusType.InProgress
|
|
434
|
+
_id: { $eq: params.id },
|
|
435
|
+
typeOf: { $eq: params.typeOf },
|
|
436
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
413
437
|
}, {
|
|
414
438
|
status: factory.transactionStatusType.Confirmed,
|
|
415
439
|
endDate: new Date(),
|
|
@@ -424,43 +448,49 @@ class MongoRepository {
|
|
|
424
448
|
// NotFoundであれば取引状態確認
|
|
425
449
|
if (doc === null) {
|
|
426
450
|
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
427
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
428
|
-
/* istanbul ignore next */
|
|
429
451
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
430
|
-
//
|
|
431
|
-
return;
|
|
432
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
433
|
-
/* istanbul ignore next */
|
|
452
|
+
// すでに確定済の場合スルー
|
|
434
453
|
}
|
|
435
454
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
436
455
|
throw new factory.errors.Argument('Transaction id', 'Already expired');
|
|
437
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
438
|
-
/* istanbul ignore next */
|
|
439
456
|
}
|
|
440
457
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
441
458
|
throw new factory.errors.Argument('Transaction id', 'Already canceled');
|
|
442
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
443
|
-
/* istanbul ignore next */
|
|
444
459
|
}
|
|
445
460
|
else {
|
|
446
461
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
447
462
|
}
|
|
448
463
|
}
|
|
449
|
-
|
|
464
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
465
|
+
id: params.id,
|
|
466
|
+
typeOf: params.typeOf,
|
|
467
|
+
status: factory.transactionStatusType.Confirmed
|
|
468
|
+
});
|
|
450
469
|
});
|
|
451
470
|
}
|
|
452
471
|
/**
|
|
453
472
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
454
473
|
*/
|
|
455
474
|
startExportTasks(params) {
|
|
475
|
+
var _a;
|
|
456
476
|
return __awaiter(this, void 0, void 0, function* () {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
+
})
|
|
464
494
|
.exec()
|
|
465
495
|
// tslint:disable-next-line:no-null-keyword
|
|
466
496
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -473,17 +503,74 @@ class MongoRepository {
|
|
|
473
503
|
*/
|
|
474
504
|
reexportTasks(params) {
|
|
475
505
|
return __awaiter(this, void 0, void 0, function* () {
|
|
476
|
-
yield this.transactionModel.
|
|
477
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
506
|
+
const reexportingTransactions = yield this.transactionModel.find({
|
|
507
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
478
508
|
updatedAt: {
|
|
479
509
|
$lt: moment()
|
|
480
510
|
.add(-params.intervalInMinutes, 'minutes')
|
|
481
511
|
.toDate()
|
|
482
512
|
}
|
|
483
|
-
}, {
|
|
484
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
485
513
|
})
|
|
514
|
+
.select({
|
|
515
|
+
_id: 1,
|
|
516
|
+
typeOf: 1,
|
|
517
|
+
status: 1
|
|
518
|
+
})
|
|
519
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
486
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 })
|
|
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;
|
|
487
574
|
});
|
|
488
575
|
}
|
|
489
576
|
/**
|
|
@@ -492,9 +579,15 @@ class MongoRepository {
|
|
|
492
579
|
*/
|
|
493
580
|
setTasksExportedById(params) {
|
|
494
581
|
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
-
|
|
582
|
+
const endDate = new Date();
|
|
583
|
+
yield this.transactionModel.updateOne({
|
|
584
|
+
_id: { $eq: params.id },
|
|
585
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
586
|
+
}, {
|
|
496
587
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
497
|
-
tasksExportedAt:
|
|
588
|
+
tasksExportedAt: endDate,
|
|
589
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
590
|
+
'tasksExportAction.endDate': endDate
|
|
498
591
|
})
|
|
499
592
|
.exec();
|
|
500
593
|
});
|
|
@@ -504,15 +597,36 @@ class MongoRepository {
|
|
|
504
597
|
*/
|
|
505
598
|
makeExpired(params) {
|
|
506
599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
507
|
-
//
|
|
508
|
-
yield this.transactionModel.
|
|
509
|
-
status: factory.transactionStatusType.InProgress,
|
|
510
|
-
expires: { $lt: params.expires }
|
|
511
|
-
}, {
|
|
512
|
-
status: factory.transactionStatusType.Expired,
|
|
513
|
-
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 }
|
|
514
604
|
})
|
|
605
|
+
.select({
|
|
606
|
+
_id: 1,
|
|
607
|
+
typeOf: 1
|
|
608
|
+
})
|
|
609
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
515
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
|
+
}
|
|
516
630
|
});
|
|
517
631
|
}
|
|
518
632
|
/**
|
|
@@ -537,11 +651,8 @@ class MongoRepository {
|
|
|
537
651
|
// NotFoundであれば取引状態確認
|
|
538
652
|
if (doc === null) {
|
|
539
653
|
const transaction = yield this.findById(params);
|
|
540
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
541
|
-
/* istanbul ignore next */
|
|
542
654
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
543
|
-
//
|
|
544
|
-
return;
|
|
655
|
+
// すでに中止済の場合スルー
|
|
545
656
|
}
|
|
546
657
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
547
658
|
throw new factory.errors.Argument('Transaction id', 'Transaction already expired');
|
|
@@ -553,7 +664,11 @@ class MongoRepository {
|
|
|
553
664
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
554
665
|
}
|
|
555
666
|
}
|
|
556
|
-
|
|
667
|
+
transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
|
|
668
|
+
id: params.id,
|
|
669
|
+
typeOf: params.typeOf,
|
|
670
|
+
status: factory.transactionStatusType.Canceled
|
|
671
|
+
});
|
|
557
672
|
});
|
|
558
673
|
}
|
|
559
674
|
count(params) {
|
|
@@ -611,9 +726,12 @@ class MongoRepository {
|
|
|
611
726
|
/**
|
|
612
727
|
* 特定の取引を更新する(汎用)
|
|
613
728
|
*/
|
|
614
|
-
|
|
729
|
+
findByIdAndUpdateInProgress(params) {
|
|
615
730
|
return __awaiter(this, void 0, void 0, function* () {
|
|
616
|
-
yield this.transactionModel.findOneAndUpdate({
|
|
731
|
+
yield this.transactionModel.findOneAndUpdate({
|
|
732
|
+
_id: { $eq: params.id },
|
|
733
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
734
|
+
}, params.update, {
|
|
617
735
|
// new: true,
|
|
618
736
|
projection: { _id: 1 }
|
|
619
737
|
})
|
|
@@ -628,7 +746,8 @@ class MongoRepository {
|
|
|
628
746
|
saveOrderNumberIfNotExist(params) {
|
|
629
747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
630
748
|
yield this.transactionModel.updateOne({
|
|
631
|
-
_id: params.id,
|
|
749
|
+
_id: { $eq: params.id },
|
|
750
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
632
751
|
'object.orderNumber': { $exists: false }
|
|
633
752
|
}, { 'object.orderNumber': params.orderNumber })
|
|
634
753
|
.exec();
|
|
@@ -637,7 +756,8 @@ class MongoRepository {
|
|
|
637
756
|
saveConfirmationNumberIfNotExist(params) {
|
|
638
757
|
return __awaiter(this, void 0, void 0, function* () {
|
|
639
758
|
yield this.transactionModel.updateOne({
|
|
640
|
-
_id: params.id,
|
|
759
|
+
_id: { $eq: params.id },
|
|
760
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
641
761
|
'object.confirmationNumber': { $exists: false }
|
|
642
762
|
}, { 'object.confirmationNumber': params.confirmationNumber })
|
|
643
763
|
.exec();
|
|
@@ -20,6 +20,7 @@ import { MongoRepository as MemberRepo } from './repo/member';
|
|
|
20
20
|
import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
21
21
|
import { MongoRepository as OfferRepo } from './repo/offer';
|
|
22
22
|
import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
|
|
23
|
+
import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
|
|
23
24
|
import { MongoRepository as OrderRepo } from './repo/order';
|
|
24
25
|
import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
|
|
25
26
|
import { MongoRepository as PermitRepo } from './repo/permit';
|
|
@@ -123,10 +124,12 @@ export declare class Member extends MemberRepo {
|
|
|
123
124
|
*/
|
|
124
125
|
export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
|
|
125
126
|
}
|
|
126
|
-
export declare class Offer extends OfferRepo {
|
|
127
|
-
}
|
|
128
127
|
export declare class OfferCatalog extends OfferCatalogRepo {
|
|
129
128
|
}
|
|
129
|
+
export declare class OfferItemCondition extends OfferItemConditionRepo {
|
|
130
|
+
}
|
|
131
|
+
export declare class Offer extends OfferRepo {
|
|
132
|
+
}
|
|
130
133
|
/**
|
|
131
134
|
* 注文リポジトリ
|
|
132
135
|
*/
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.
|
|
3
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -24,6 +24,7 @@ const member_1 = require("./repo/member");
|
|
|
24
24
|
const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
|
|
25
25
|
const offer_1 = require("./repo/offer");
|
|
26
26
|
const offerCatalog_1 = require("./repo/offerCatalog");
|
|
27
|
+
const offerItemCondition_1 = require("./repo/offerItemCondition");
|
|
27
28
|
const order_1 = require("./repo/order");
|
|
28
29
|
const ownershipInfo_1 = require("./repo/ownershipInfo");
|
|
29
30
|
const permit_1 = require("./repo/permit");
|
|
@@ -147,12 +148,15 @@ exports.Member = Member;
|
|
|
147
148
|
class MerchantReturnPolicy extends merchantReturnPolicy_1.MongoRepository {
|
|
148
149
|
}
|
|
149
150
|
exports.MerchantReturnPolicy = MerchantReturnPolicy;
|
|
150
|
-
class Offer extends offer_1.MongoRepository {
|
|
151
|
-
}
|
|
152
|
-
exports.Offer = Offer;
|
|
153
151
|
class OfferCatalog extends offerCatalog_1.MongoRepository {
|
|
154
152
|
}
|
|
155
153
|
exports.OfferCatalog = OfferCatalog;
|
|
154
|
+
class OfferItemCondition extends offerItemCondition_1.MongoRepository {
|
|
155
|
+
}
|
|
156
|
+
exports.OfferItemCondition = OfferItemCondition;
|
|
157
|
+
class Offer extends offer_1.MongoRepository {
|
|
158
|
+
}
|
|
159
|
+
exports.Offer = Offer;
|
|
156
160
|
/**
|
|
157
161
|
* 注文リポジトリ
|
|
158
162
|
*/
|