@chevre/domain 25.2.0-alpha.9 → 26.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/eventEmitter/task.d.ts +2 -1
- package/lib/chevre/factory/customerTelephone2COATelNum.d.ts +3 -0
- package/lib/chevre/factory/customerTelephone2COATelNum.js +22 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
- package/lib/chevre/repo/action/acceptPay.js +47 -19
- package/lib/chevre/repo/action.d.ts +16 -9
- package/lib/chevre/repo/action.js +99 -180
- package/lib/chevre/repo/adminTask.d.ts +37 -0
- package/lib/chevre/repo/adminTask.js +163 -0
- package/lib/chevre/repo/aggregateOffer.d.ts +3 -14
- package/lib/chevre/repo/aggregateOffer.js +16 -125
- package/lib/chevre/repo/aggregateTask.d.ts +37 -0
- package/lib/chevre/repo/aggregateTask.js +136 -0
- package/lib/chevre/repo/asyncAction.d.ts +69 -0
- package/lib/chevre/repo/asyncAction.js +237 -0
- package/lib/chevre/repo/concurrentLock.d.ts +3 -1
- package/lib/chevre/repo/creativeWork.d.ts +2 -3
- package/lib/chevre/repo/credentials.d.ts +2 -1
- package/lib/chevre/repo/customerType.d.ts +2 -3
- package/lib/chevre/repo/event.d.ts +10 -11
- package/lib/chevre/repo/eventOffer.d.ts +4 -5
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +2 -3
- package/lib/chevre/repo/eventSeries.d.ts +4 -5
- package/lib/chevre/repo/message.d.ts +1 -1
- package/lib/chevre/repo/message.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/asyncAction.d.ts +13 -0
- package/lib/chevre/repo/mongoose/schemas/asyncAction.js +89 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
- package/lib/chevre/repo/mongoose/schemas/scheduledTasks.d.ts +16 -0
- package/lib/chevre/repo/mongoose/schemas/scheduledTasks.js +103 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +6 -1
- package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
- package/lib/chevre/repo/note.d.ts +3 -4
- package/lib/chevre/repo/noteAboutOrder.d.ts +2 -3
- package/lib/chevre/repo/offer/offerInCatalogReadOnly.d.ts +2 -2
- package/lib/chevre/repo/offer/unitPriceInCatalog.d.ts +2 -2
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +59 -11
- package/lib/chevre/repo/offerCatalog.d.ts +2 -3
- package/lib/chevre/repo/offerCatalogItem.d.ts +2 -3
- package/lib/chevre/repo/order.d.ts +2 -0
- package/lib/chevre/repo/order.js +14 -14
- package/lib/chevre/repo/orderInTransaction.d.ts +68 -1
- package/lib/chevre/repo/orderInTransaction.js +181 -3
- package/lib/chevre/repo/passport.d.ts +2 -1
- package/lib/chevre/repo/person.d.ts +0 -15
- package/lib/chevre/repo/person.js +122 -108
- package/lib/chevre/repo/place/entranceGate.d.ts +4 -5
- package/lib/chevre/repo/place/movieTheater.d.ts +3 -4
- package/lib/chevre/repo/place/screeningRoom.d.ts +4 -5
- package/lib/chevre/repo/place/seat.d.ts +4 -5
- package/lib/chevre/repo/place/section.d.ts +3 -4
- package/lib/chevre/repo/priceSpecification.d.ts +4 -4
- package/lib/chevre/repo/product.d.ts +3 -4
- package/lib/chevre/repo/rateLimit/offer.d.ts +3 -1
- package/lib/chevre/repo/rateLimit/offer.js +0 -12
- package/lib/chevre/repo/reservation.d.ts +2 -3
- package/lib/chevre/repo/scheduledTask.d.ts +90 -0
- package/lib/chevre/repo/scheduledTask.js +223 -0
- package/lib/chevre/repo/sellerMakesOffer.d.ts +3 -4
- package/lib/chevre/repo/stockHolder.d.ts +1 -1
- package/lib/chevre/repo/stockHolder.js +0 -146
- package/lib/chevre/repo/task.d.ts +30 -71
- package/lib/chevre/repo/task.js +59 -345
- package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
- package/lib/chevre/repo/transaction/placeOrder.js +43 -83
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transactionNumberCounter.js +0 -34
- package/lib/chevre/repo/transactionProcess.d.ts +2 -1
- package/lib/chevre/repo/transactionProcess.js +0 -13
- package/lib/chevre/repository.d.ts +20 -0
- package/lib/chevre/repository.js +46 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/aggregation/system.d.ts +2 -2
- package/lib/chevre/service/aggregation/system.js +1 -1
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +1 -1
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -67
- package/lib/chevre/service/asyncAction.d.ts +16 -0
- package/lib/chevre/service/asyncAction.js +36 -0
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +15 -0
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +42 -0
- package/lib/chevre/service/asyncActionHandler.d.ts +13 -0
- package/lib/chevre/service/asyncActionHandler.js +89 -0
- package/lib/chevre/service/notification/factory.d.ts +2 -4
- package/lib/chevre/service/notification/factory.js +26 -24
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +12 -6
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +12 -4
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -5
- package/lib/chevre/service/offer/event/authorize/factory.js +93 -75
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -4
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/validateAcceptedOffers.js +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +15 -12
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +4 -0
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +20 -9
- package/lib/chevre/service/offer/onEventChanged.js +2 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +19 -11
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +1 -7
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +2 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +3 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +0 -3
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +73 -44
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +53 -33
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +6 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +3 -7
- package/lib/chevre/service/order/onOrderUpdated.js +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +2 -0
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -1
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +13 -58
- package/lib/chevre/service/order/placeOrder/factory.js +3 -21
- package/lib/chevre/service/order/placeOrder.d.ts +4 -5
- package/lib/chevre/service/order/placeOrder.js +20 -31
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
- package/lib/chevre/service/payment/any/authorize.js +7 -5
- package/lib/chevre/service/payment/any/factory.d.ts +7 -7
- package/lib/chevre/service/payment/any/factory.js +18 -21
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +7 -1
- package/lib/chevre/service/payment/any/findAcceptAction.js +34 -15
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +20 -9
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +4 -0
- package/lib/chevre/service/payment/any/findCheckAction.js +20 -9
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +5 -67
- package/lib/chevre/service/payment/any/onPayActionCompleted.js +1 -1
- package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.js +1 -1
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
- package/lib/chevre/service/reserve/adminFindReservations.d.ts +15 -0
- package/lib/chevre/service/reserve/adminFindReservations.js +35 -0
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +20 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +1 -1
- package/lib/chevre/service/reserve/searchByOrder.js +2 -6
- package/lib/chevre/service/reserve.d.ts +2 -2
- package/lib/chevre/service/reserve.js +3 -3
- package/lib/chevre/service/scheduledTask.d.ts +11 -0
- package/lib/chevre/service/scheduledTask.js +40 -0
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.d.ts +14 -0
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +56 -0
- package/lib/chevre/service/scheduledTaskHandler.d.ts +12 -0
- package/lib/chevre/service/scheduledTaskHandler.js +66 -0
- package/lib/chevre/service/task/aggregateOffers.d.ts +2 -2
- package/lib/chevre/service/task/aggregateOffers.js +2 -1
- package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/task/authorizePayment.js +3 -1
- package/lib/chevre/service/task/cancelReservation.d.ts +2 -2
- package/lib/chevre/service/task/cancelReservation.js +2 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +0 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +3 -8
- package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
- package/lib/chevre/service/task/deleteTransaction.js +2 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -3
- package/lib/chevre/service/task/onEventChanged.d.ts +2 -2
- package/lib/chevre/service/task/onEventChanged.js +2 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +4 -1
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated.js +10 -9
- package/lib/chevre/service/task/placeOrder.d.ts +2 -2
- package/lib/chevre/service/task/placeOrder.js +6 -3
- package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
- package/lib/chevre/service/task/refund.d.ts +2 -2
- package/lib/chevre/service/task/refund.js +4 -10
- package/lib/chevre/service/task/reserve.d.ts +2 -2
- package/lib/chevre/service/task/reserve.js +2 -1
- package/lib/chevre/service/task/returnOrder.d.ts +2 -2
- package/lib/chevre/service/task/returnOrder.js +2 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/sendOrder.d.ts +2 -2
- package/lib/chevre/service/task/sendOrder.js +2 -1
- package/lib/chevre/service/task/voidPayTransaction.js +3 -7
- package/lib/chevre/service/task/voidPayment.d.ts +2 -2
- package/lib/chevre/service/task/voidPayment.js +2 -1
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +1 -1
- package/lib/chevre/service/taskHandler/onOperationFailed.js +1 -1
- package/lib/chevre/service/taskHandler.d.ts +2 -2
- package/lib/chevre/service/taskHandler.js +36 -37
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +1 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +28 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +11 -12
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +4 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +6 -7
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +32 -4
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +10 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +6 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +23 -9
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +6 -5
- package/lib/chevre/service/transaction/placeOrder/confirm.js +30 -40
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.d.ts +20 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.js +63 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +17 -86
- package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +1 -1
- package/lib/chevre/service.d.ts +8 -0
- package/lib/chevre/service.js +23 -1
- package/lib/chevre/taskSettings.d.ts +3 -4
- package/package.json +8 -11
- package/lib/chevre/service/order/findConfirmedPlaceOrder.d.ts +0 -13
- package/lib/chevre/service/order/findConfirmedPlaceOrder.js +0 -32
- package/lib/chevre/service/reserve/findReservations.d.ts +0 -33
- package/lib/chevre/service/reserve/findReservations.js +0 -61
package/lib/chevre/repo/task.js
CHANGED
|
@@ -10,13 +10,6 @@ const task_1 = require("../eventEmitter/task");
|
|
|
10
10
|
const factory_1 = require("../factory");
|
|
11
11
|
const settings_1 = require("../settings");
|
|
12
12
|
const task_2 = require("./mongoose/schemas/task");
|
|
13
|
-
/**
|
|
14
|
-
* タスク実行時のソート条件
|
|
15
|
-
*/
|
|
16
|
-
// const sortOrder4executionOfTasks: { [key in keyof factory.task.IAttributes<factory.taskName>]?: factory.sortType } = {
|
|
17
|
-
// numberOfTried: factory.sortType.Ascending, // トライ回数の少なさ優先
|
|
18
|
-
// runsAt: factory.sortType.Ascending // 実行予定日時の早さ優先
|
|
19
|
-
// };
|
|
20
13
|
const executableTaskProjection = {
|
|
21
14
|
_id: 0,
|
|
22
15
|
id: { $toString: '$_id' },
|
|
@@ -30,7 +23,6 @@ const executableTaskProjection = {
|
|
|
30
23
|
runsAt: 1,
|
|
31
24
|
expires: 1
|
|
32
25
|
};
|
|
33
|
-
// type IProjection = { [key in IKeyOfProjection]?: 0 | 1; };
|
|
34
26
|
const AVAILABLE_PROJECT_FIELDS = [
|
|
35
27
|
'alternateName',
|
|
36
28
|
'identifier',
|
|
@@ -56,89 +48,7 @@ class TaskRepo {
|
|
|
56
48
|
constructor(connection) {
|
|
57
49
|
this.taskModel = connection.model(task_2.modelName, (0, task_2.createSchema)());
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
const andConditions = [];
|
|
61
|
-
const idEq = params.id?.$eq;
|
|
62
|
-
if (typeof idEq === 'string') {
|
|
63
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
64
|
-
}
|
|
65
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
66
|
-
if (typeof projectIdEq === 'string') {
|
|
67
|
-
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
68
|
-
}
|
|
69
|
-
if (typeof params.name === 'string') {
|
|
70
|
-
andConditions.push({ name: { $eq: params.name } });
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const nameIn = params.name?.$in;
|
|
74
|
-
if (Array.isArray(nameIn)) {
|
|
75
|
-
andConditions.push({ name: { $in: nameIn } });
|
|
76
|
-
}
|
|
77
|
-
const nameNin = params.name?.$nin;
|
|
78
|
-
if (Array.isArray(nameNin)) {
|
|
79
|
-
andConditions.push({ name: { $nin: nameNin } });
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const statusEq = params.status?.$eq;
|
|
83
|
-
if (typeof statusEq === 'string') {
|
|
84
|
-
andConditions.push({ status: { $eq: statusEq } });
|
|
85
|
-
}
|
|
86
|
-
if (Array.isArray(params.statuses)) {
|
|
87
|
-
andConditions.push({ status: { $in: params.statuses } });
|
|
88
|
-
}
|
|
89
|
-
if (params.runsFrom instanceof Date) {
|
|
90
|
-
andConditions.push({ runsAt: { $gte: params.runsFrom } });
|
|
91
|
-
}
|
|
92
|
-
if (params.runsThrough instanceof Date) {
|
|
93
|
-
andConditions.push({ runsAt: { $lte: params.runsThrough } });
|
|
94
|
-
}
|
|
95
|
-
if (params.lastTriedFrom instanceof Date) {
|
|
96
|
-
andConditions.push({ lastTriedAt: { $type: 'date', $gte: params.lastTriedFrom } });
|
|
97
|
-
}
|
|
98
|
-
if (params.lastTriedThrough instanceof Date) {
|
|
99
|
-
andConditions.push({ lastTriedAt: { $type: 'date', $lte: params.lastTriedThrough } });
|
|
100
|
-
}
|
|
101
|
-
const dateAbortedGte = params.dateAborted?.$gte;
|
|
102
|
-
if (dateAbortedGte instanceof Date) {
|
|
103
|
-
andConditions.push({ dateAborted: { $type: 'date', $gte: dateAbortedGte } });
|
|
104
|
-
}
|
|
105
|
-
const dateAbortedLte = params.dateAborted?.$lte;
|
|
106
|
-
if (dateAbortedLte instanceof Date) {
|
|
107
|
-
andConditions.push({ dateAborted: { $type: 'date', $lte: dateAbortedLte } });
|
|
108
|
-
}
|
|
109
|
-
const objectIdEq = params.data?.object?.id?.$eq;
|
|
110
|
-
if (typeof objectIdEq === 'string') {
|
|
111
|
-
andConditions.push({ 'data.object.id': { $exists: true, $eq: objectIdEq } });
|
|
112
|
-
}
|
|
113
|
-
const objectOrderNumberEq = params.data?.object?.orderNumber?.$eq;
|
|
114
|
-
if (typeof objectOrderNumberEq === 'string') {
|
|
115
|
-
andConditions.push({ 'data.object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
|
|
116
|
-
}
|
|
117
|
-
const objectTransactionNumberEq = params.data?.object?.transactionNumber?.$eq;
|
|
118
|
-
if (typeof objectTransactionNumberEq === 'string') {
|
|
119
|
-
andConditions.push({ 'data.object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
|
|
120
|
-
}
|
|
121
|
-
const objectPurposeIdEq = params.data?.purpose?.id?.$eq;
|
|
122
|
-
if (typeof objectPurposeIdEq === 'string') {
|
|
123
|
-
andConditions.push({ 'data.purpose.id': { $exists: true, $eq: objectPurposeIdEq } });
|
|
124
|
-
}
|
|
125
|
-
const objectPurposeOrderNumberEq = params.data?.purpose?.orderNumber?.$eq;
|
|
126
|
-
if (typeof objectPurposeOrderNumberEq === 'string') {
|
|
127
|
-
andConditions.push({ 'data.purpose.orderNumber': { $exists: true, $eq: objectPurposeOrderNumberEq } });
|
|
128
|
-
}
|
|
129
|
-
const alternateNameRegex = params.alternateName?.$regex;
|
|
130
|
-
if (typeof alternateNameRegex === 'string' && alternateNameRegex.length > 0) {
|
|
131
|
-
andConditions.push({ alternateName: { $exists: true, $regex: new RegExp(alternateNameRegex) } });
|
|
132
|
-
}
|
|
133
|
-
const identifierRegex = params.identifier?.$regex;
|
|
134
|
-
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
135
|
-
andConditions.push({ identifier: { $exists: true, $regex: new RegExp(identifierRegex) } });
|
|
136
|
-
}
|
|
137
|
-
return andConditions;
|
|
138
|
-
}
|
|
139
|
-
async runImmediately(
|
|
140
|
-
// resolve uniqueness of identifier(2025-03-27~)
|
|
141
|
-
params,
|
|
51
|
+
async runImmediately(params,
|
|
142
52
|
// support customr function(2025-05-25~)
|
|
143
53
|
next) {
|
|
144
54
|
const { expires } = params;
|
|
@@ -163,10 +73,10 @@ class TaskRepo {
|
|
|
163
73
|
}, next);
|
|
164
74
|
return { id };
|
|
165
75
|
}
|
|
166
|
-
async saveMany(taskAttributes
|
|
167
|
-
const emitImmediately =
|
|
76
|
+
async saveMany(taskAttributes) {
|
|
77
|
+
const emitImmediately = true; // always true(2026-07-30~)
|
|
78
|
+
// const emitImmediately = options?.emitImmediately === true;
|
|
168
79
|
if (taskAttributes.length > 0) {
|
|
169
|
-
// resolve uniqueness of identifier(2025-03-27~)
|
|
170
80
|
const creatingTasks = taskAttributes.map(({ identifier, ...creatingTask }) => creatingTask); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
171
81
|
const result = await this.taskModel.insertMany(creatingTasks, { ordered: false, rawResult: true });
|
|
172
82
|
if (result.insertedCount !== taskAttributes.length) {
|
|
@@ -223,7 +133,8 @@ class TaskRepo {
|
|
|
223
133
|
* タスク識別子から冪等作成する
|
|
224
134
|
* reimplement createIfNotExistByIdentifier(2025-03-28~)
|
|
225
135
|
*/
|
|
226
|
-
async createIfNotExistByAlternateName(params
|
|
136
|
+
async createIfNotExistByAlternateName(params) {
|
|
137
|
+
const emitImmediately = true; // always true(2026-07-30~)
|
|
227
138
|
if (typeof params.alternateName !== 'string' || params.alternateName.length === 0) {
|
|
228
139
|
throw new factory_1.factory.errors.ArgumentNull('alternateName');
|
|
229
140
|
}
|
|
@@ -260,7 +171,7 @@ class TaskRepo {
|
|
|
260
171
|
}
|
|
261
172
|
}
|
|
262
173
|
if (typeof createdTask?.id === 'string') {
|
|
263
|
-
if (
|
|
174
|
+
if (emitImmediately) {
|
|
264
175
|
task_1.taskEventEmitter.emitTaskStatusChanged({
|
|
265
176
|
id: createdTask.id,
|
|
266
177
|
name: params.name,
|
|
@@ -272,33 +183,41 @@ class TaskRepo {
|
|
|
272
183
|
throw new factory_1.factory.errors.Internal(`falied in creating a task unexpectedly. ${params.alternateName}`);
|
|
273
184
|
}
|
|
274
185
|
}
|
|
275
|
-
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
async createDeleteTransactionTaskIfNotExist(
|
|
279
|
-
// resolve uniqueness of identifier(2025-03-27~)
|
|
280
|
-
params
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
//
|
|
301
|
-
|
|
186
|
+
// /**
|
|
187
|
+
// * 取引削除タスク冪等作成
|
|
188
|
+
// */
|
|
189
|
+
// public async createDeleteTransactionTaskIfNotExist(
|
|
190
|
+
// // resolve uniqueness of identifier(2025-03-27~)
|
|
191
|
+
// params: Pick<
|
|
192
|
+
// factory.task.IAttributes<factory.taskName.DeleteTransaction>,
|
|
193
|
+
// 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status'
|
|
194
|
+
// >,
|
|
195
|
+
// options: IOptionOnCreate
|
|
196
|
+
// ): Promise<void> {
|
|
197
|
+
// if (params.data.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
198
|
+
// throw new factory.errors.NotImplemented(`only ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
|
|
199
|
+
// }
|
|
200
|
+
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
201
|
+
// {
|
|
202
|
+
// 'project.id': { $eq: params.project.id },
|
|
203
|
+
// name: { $eq: params.name },
|
|
204
|
+
// 'data.object.id': { $exists: true, $eq: params.data.object.id }
|
|
205
|
+
// },
|
|
206
|
+
// { $setOnInsert: params },
|
|
207
|
+
// { new: true, upsert: true }
|
|
208
|
+
// )
|
|
209
|
+
// .select({ _id: 1 })
|
|
210
|
+
// .exec();
|
|
211
|
+
// if (options.emitImmediately) {
|
|
212
|
+
// taskEventEmitter.emitTaskStatusChanged({
|
|
213
|
+
// id: createdTask.id,
|
|
214
|
+
// name: params.name,
|
|
215
|
+
// status: factory.taskStatus.Ready
|
|
216
|
+
// });
|
|
217
|
+
// }
|
|
218
|
+
// }
|
|
219
|
+
async createOnAssetTransactionStatusChangedTaskIfNotExist(params) {
|
|
220
|
+
const emitImmediately = true; // always true(2026-07-30~)
|
|
302
221
|
const createdTask = await this.taskModel.findOneAndUpdate({
|
|
303
222
|
'project.id': { $eq: params.project.id },
|
|
304
223
|
name: { $eq: params.name },
|
|
@@ -313,7 +232,7 @@ class TaskRepo {
|
|
|
313
232
|
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
314
233
|
.select({ _id: 1 })
|
|
315
234
|
.exec();
|
|
316
|
-
if (
|
|
235
|
+
if (emitImmediately) {
|
|
317
236
|
task_1.taskEventEmitter.emitTaskStatusChanged({
|
|
318
237
|
id: createdTask.id,
|
|
319
238
|
name: params.name,
|
|
@@ -444,8 +363,7 @@ class TaskRepo {
|
|
|
444
363
|
/**
|
|
445
364
|
* 実行日時を一定期間過ぎたReadyタスクについて、Runningスタータスに変更した上で、Runningイベントを発生させる
|
|
446
365
|
*/
|
|
447
|
-
async emitRunningIfExists(params
|
|
448
|
-
) {
|
|
366
|
+
async emitRunningIfExists(params) {
|
|
449
367
|
if (!(params.runsAt.$lt instanceof Date)) {
|
|
450
368
|
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
451
369
|
}
|
|
@@ -463,15 +381,6 @@ class TaskRepo {
|
|
|
463
381
|
...(nameFilterBeforeRunsAt) ? { name: params.name } : undefined,
|
|
464
382
|
runsAt: { $lt: params.runsAt.$lt },
|
|
465
383
|
...(!nameFilterBeforeRunsAt) ? { name: params.name } : undefined
|
|
466
|
-
// ...(typeof nameEq === 'string' || Array.isArray(nameIn))
|
|
467
|
-
// ? {
|
|
468
|
-
// name: {
|
|
469
|
-
// ...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
|
|
470
|
-
// // ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined
|
|
471
|
-
// ...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
|
|
472
|
-
// }
|
|
473
|
-
// }
|
|
474
|
-
// : undefined
|
|
475
384
|
};
|
|
476
385
|
const doc = await this.taskModel.findOneAndUpdate(filter, {
|
|
477
386
|
$set: {
|
|
@@ -510,7 +419,7 @@ class TaskRepo {
|
|
|
510
419
|
status: factory_1.factory.taskStatus.Running
|
|
511
420
|
};
|
|
512
421
|
}
|
|
513
|
-
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask
|
|
422
|
+
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
514
423
|
return doc;
|
|
515
424
|
}
|
|
516
425
|
/**
|
|
@@ -581,42 +490,6 @@ class TaskRepo {
|
|
|
581
490
|
})
|
|
582
491
|
.exec();
|
|
583
492
|
}
|
|
584
|
-
// public async abortOne(params: {
|
|
585
|
-
// intervalInMinutes: number;
|
|
586
|
-
// }): Promise<factory.task.ITask<factory.taskName> | null> {
|
|
587
|
-
// const lastTriedAtShoudBeLessThan = moment()
|
|
588
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
589
|
-
// .toDate();
|
|
590
|
-
// const projection: ProjectionType<factory.task.ITask<factory.taskName>> = {
|
|
591
|
-
// _id: 0,
|
|
592
|
-
// id: { $toString: '$_id' },
|
|
593
|
-
// ...Object.fromEntries<1>(AVAILABLE_PROJECT_FIELDS.map((key) => ([key, 1])))
|
|
594
|
-
// };
|
|
595
|
-
// const doc = await this.taskModel.findOneAndUpdate(
|
|
596
|
-
// {
|
|
597
|
-
// status: { $eq: factory.taskStatus.Running },
|
|
598
|
-
// lastTriedAt: {
|
|
599
|
-
// $type: 'date',
|
|
600
|
-
// $lt: lastTriedAtShoudBeLessThan
|
|
601
|
-
// },
|
|
602
|
-
// remainingNumberOfTries: { $eq: 0 }
|
|
603
|
-
// },
|
|
604
|
-
// {
|
|
605
|
-
// $set: {
|
|
606
|
-
// status: factory.taskStatus.Aborted,
|
|
607
|
-
// dateAborted: new Date()
|
|
608
|
-
// }
|
|
609
|
-
// },
|
|
610
|
-
// { new: true, projection }
|
|
611
|
-
// )
|
|
612
|
-
// .lean<factory.task.ITask<factory.taskName>>() // lean(2024-09-26~)
|
|
613
|
-
// .exec();
|
|
614
|
-
// if (doc === null) {
|
|
615
|
-
// // tslint:disable-next-line:no-null-keyword
|
|
616
|
-
// return null;
|
|
617
|
-
// }
|
|
618
|
-
// return doc;
|
|
619
|
-
// }
|
|
620
493
|
async abortMany(params) {
|
|
621
494
|
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
622
495
|
.add(-params.intervalInMinutes, 'minutes')
|
|
@@ -660,28 +533,11 @@ class TaskRepo {
|
|
|
660
533
|
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, next);
|
|
661
534
|
}
|
|
662
535
|
}
|
|
663
|
-
async count(params) {
|
|
664
|
-
const { limit } = params;
|
|
665
|
-
const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
|
|
666
|
-
const query = this.taskModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
667
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
668
|
-
query.limit(limit);
|
|
669
|
-
}
|
|
670
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
671
|
-
.exec();
|
|
672
|
-
return { count };
|
|
673
|
-
}
|
|
674
536
|
/**
|
|
675
|
-
*
|
|
537
|
+
* タスクの状態を参照する
|
|
538
|
+
* 非同期アクション移行が完了したら廃止する(2026-07-29~)
|
|
676
539
|
*/
|
|
677
|
-
async
|
|
678
|
-
// projection?: IProjection
|
|
679
|
-
inclusion) {
|
|
680
|
-
const conditions = TaskRepo.CREATE_MONGO_CONDITIONS(params);
|
|
681
|
-
// const positiveProjectionExists: boolean = (projection !== undefined && projection !== null)
|
|
682
|
-
// ? Object.values(projection)
|
|
683
|
-
// .some((value) => value !== 0)
|
|
684
|
-
// : false;
|
|
540
|
+
async findTaskById(params, inclusion) {
|
|
685
541
|
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
686
542
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
687
543
|
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
@@ -694,18 +550,18 @@ class TaskRepo {
|
|
|
694
550
|
id: { $toString: '$_id' },
|
|
695
551
|
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
696
552
|
};
|
|
697
|
-
const query = this.taskModel.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
query.sort({ runsAt: params.sort.runsAt });
|
|
705
|
-
}
|
|
706
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
707
|
-
.lean() // lean(2024-09-26~)
|
|
553
|
+
const query = this.taskModel.findOne({
|
|
554
|
+
_id: { $eq: params.id.$eq },
|
|
555
|
+
'project.id': { $eq: params.project.id.$eq },
|
|
556
|
+
name: { $eq: params.name }
|
|
557
|
+
}, projection);
|
|
558
|
+
const doc = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
559
|
+
.lean()
|
|
708
560
|
.exec();
|
|
561
|
+
if (doc === null) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
return doc;
|
|
709
565
|
}
|
|
710
566
|
async deleteByProject(params) {
|
|
711
567
|
await this.taskModel.deleteMany({
|
|
@@ -713,18 +569,6 @@ class TaskRepo {
|
|
|
713
569
|
})
|
|
714
570
|
.exec();
|
|
715
571
|
}
|
|
716
|
-
async deleteByName(params) {
|
|
717
|
-
return this.taskModel.deleteMany({
|
|
718
|
-
name: { $eq: params.name },
|
|
719
|
-
...(typeof params.status?.$eq === 'string') ? { status: { $eq: params.status.$eq } } : undefined,
|
|
720
|
-
...(params.runsAt?.$gte instanceof Date)
|
|
721
|
-
? {
|
|
722
|
-
runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
|
|
723
|
-
}
|
|
724
|
-
: undefined
|
|
725
|
-
})
|
|
726
|
-
.exec();
|
|
727
|
-
}
|
|
728
572
|
/**
|
|
729
573
|
* 不要なタスクを削除する
|
|
730
574
|
*/
|
|
@@ -758,135 +602,5 @@ class TaskRepo {
|
|
|
758
602
|
.exec();
|
|
759
603
|
return { count };
|
|
760
604
|
}
|
|
761
|
-
getCursor(conditions, projection) {
|
|
762
|
-
return this.taskModel.find(conditions, projection)
|
|
763
|
-
.sort({ runsAt: factory_1.factory.sortType.Ascending })
|
|
764
|
-
.cursor();
|
|
765
|
-
}
|
|
766
|
-
async unsetUnnecessaryFields(params) {
|
|
767
|
-
return this.taskModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
768
|
-
.exec();
|
|
769
|
-
}
|
|
770
|
-
async aggregateTask(params) {
|
|
771
|
-
const statuses = await Promise.all([
|
|
772
|
-
factory_1.factory.taskStatus.Executed,
|
|
773
|
-
factory_1.factory.taskStatus.Aborted
|
|
774
|
-
].map(async (taskStatus) => {
|
|
775
|
-
const matchConditions = {
|
|
776
|
-
runsAt: {
|
|
777
|
-
$gte: params.runsFrom,
|
|
778
|
-
$lte: params.runsThrough
|
|
779
|
-
},
|
|
780
|
-
status: { $eq: taskStatus },
|
|
781
|
-
...(typeof params.project?.id?.$ne === 'string')
|
|
782
|
-
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
783
|
-
: undefined
|
|
784
|
-
};
|
|
785
|
-
return this.agggregateByStatus({ matchConditions, status: taskStatus });
|
|
786
|
-
}));
|
|
787
|
-
return { statuses };
|
|
788
|
-
}
|
|
789
|
-
async agggregateByStatus(params) {
|
|
790
|
-
const matchConditions = params.matchConditions;
|
|
791
|
-
const taskStatus = params.status;
|
|
792
|
-
const aggregate1 = this.taskModel.aggregate([
|
|
793
|
-
{
|
|
794
|
-
$match: matchConditions
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
$project: {
|
|
798
|
-
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
799
|
-
status: '$status',
|
|
800
|
-
runsAt: '$runsAt',
|
|
801
|
-
lastTriedAt: '$lastTriedAt'
|
|
802
|
-
}
|
|
803
|
-
},
|
|
804
|
-
{
|
|
805
|
-
$group: {
|
|
806
|
-
_id: '$status',
|
|
807
|
-
taskCount: { $sum: 1 },
|
|
808
|
-
maxLatency: { $max: '$latency' },
|
|
809
|
-
minLatency: { $min: '$latency' },
|
|
810
|
-
avgLatency: { $avg: '$latency' }
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
$project: {
|
|
815
|
-
_id: 0,
|
|
816
|
-
taskCount: '$taskCount',
|
|
817
|
-
avgLatency: '$avgLatency',
|
|
818
|
-
maxLatency: '$maxLatency',
|
|
819
|
-
minLatency: '$minLatency'
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
]);
|
|
823
|
-
// const explainResult = await aggregate1.explain();
|
|
824
|
-
// console.dir(explainResult, { depth: null });
|
|
825
|
-
// return;
|
|
826
|
-
const aggregations = await aggregate1.exec();
|
|
827
|
-
const percents = [50, 95, 99];
|
|
828
|
-
if (aggregations.length === 0) {
|
|
829
|
-
return {
|
|
830
|
-
status: taskStatus,
|
|
831
|
-
aggregation: {
|
|
832
|
-
taskCount: 0,
|
|
833
|
-
avgLatency: 0,
|
|
834
|
-
maxLatency: 0,
|
|
835
|
-
minLatency: 0,
|
|
836
|
-
percentilesLatency: percents.map((percent) => {
|
|
837
|
-
return {
|
|
838
|
-
name: String(percent),
|
|
839
|
-
value: 0
|
|
840
|
-
};
|
|
841
|
-
})
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
const ranks4percentile = percents.map((percentile) => {
|
|
846
|
-
return {
|
|
847
|
-
percentile,
|
|
848
|
-
rank: Math.floor(aggregations[0].taskCount * percentile / 100)
|
|
849
|
-
};
|
|
850
|
-
});
|
|
851
|
-
const aggregate2 = this.taskModel.aggregate([
|
|
852
|
-
{
|
|
853
|
-
$match: matchConditions
|
|
854
|
-
},
|
|
855
|
-
{
|
|
856
|
-
$project: {
|
|
857
|
-
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
858
|
-
status: '$status',
|
|
859
|
-
runsAt: '$runsAt',
|
|
860
|
-
lastTriedAt: '$lastTriedAt'
|
|
861
|
-
}
|
|
862
|
-
},
|
|
863
|
-
{ $sort: { latency: 1 } },
|
|
864
|
-
{
|
|
865
|
-
$group: {
|
|
866
|
-
_id: '$status',
|
|
867
|
-
latencies: { $push: '$latency' }
|
|
868
|
-
}
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
$project: {
|
|
872
|
-
_id: 0,
|
|
873
|
-
percentilesLatency: ranks4percentile.map((rank) => {
|
|
874
|
-
return {
|
|
875
|
-
name: String(rank.percentile),
|
|
876
|
-
value: { $arrayElemAt: ['$latencies', rank.rank] }
|
|
877
|
-
};
|
|
878
|
-
})
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
]);
|
|
882
|
-
const aggregations2 = await aggregate2.exec();
|
|
883
|
-
return {
|
|
884
|
-
status: taskStatus,
|
|
885
|
-
aggregation: {
|
|
886
|
-
...aggregations[0],
|
|
887
|
-
...aggregations2[0]
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
605
|
}
|
|
892
606
|
exports.TaskRepo = TaskRepo;
|
|
@@ -37,21 +37,6 @@ export declare class PlaceOrderRepo {
|
|
|
37
37
|
}): Promise<(Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, IKeyOfProjection> & {
|
|
38
38
|
id: string;
|
|
39
39
|
})[]>;
|
|
40
|
-
/**
|
|
41
|
-
* 進行中取引に保管された採用済決済方法を検索する
|
|
42
|
-
*/
|
|
43
|
-
findInProgressPaymentMethodId(params: {
|
|
44
|
-
id: string;
|
|
45
|
-
}): Promise<factory.transaction.placeOrder.IPaymentMethodByPaymentUrl | undefined>;
|
|
46
|
-
/**
|
|
47
|
-
* 取引の確認番号を検索する
|
|
48
|
-
*/
|
|
49
|
-
findInProgressConfirmationNumberById(params: {
|
|
50
|
-
id: string;
|
|
51
|
-
status: {
|
|
52
|
-
$in: factory.transactionStatusType[];
|
|
53
|
-
};
|
|
54
|
-
}): Promise<string | undefined>;
|
|
55
40
|
/**
|
|
56
41
|
* 取引期限変更
|
|
57
42
|
*/
|
|
@@ -60,28 +45,6 @@ export declare class PlaceOrderRepo {
|
|
|
60
45
|
id: string;
|
|
61
46
|
expires: Date;
|
|
62
47
|
}): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* 取引オブジェクトを更新
|
|
65
|
-
* 注文名称など
|
|
66
|
-
*/
|
|
67
|
-
updateObject(params: {
|
|
68
|
-
typeOf: factory.transactionType.PlaceOrder;
|
|
69
|
-
id: string;
|
|
70
|
-
object?: {
|
|
71
|
-
name?: string;
|
|
72
|
-
};
|
|
73
|
-
}): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* 特定の進行中取引を更新する(汎用)
|
|
76
|
-
*/
|
|
77
|
-
findByIdAndUpdateInProgress(params: {
|
|
78
|
-
id: string;
|
|
79
|
-
update: {
|
|
80
|
-
$set?: {
|
|
81
|
-
'object.paymentMethods'?: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}): Promise<void>;
|
|
85
48
|
/**
|
|
86
49
|
* 進行中取引のobjectに注文番号を保管する
|
|
87
50
|
*/
|
|
@@ -91,13 +54,6 @@ export declare class PlaceOrderRepo {
|
|
|
91
54
|
}): Promise<{
|
|
92
55
|
modifiedCount: number;
|
|
93
56
|
}>;
|
|
94
|
-
saveConfirmationNumberIfNotExist(params: {
|
|
95
|
-
id: string;
|
|
96
|
-
status: {
|
|
97
|
-
$in: factory.transactionStatusType[];
|
|
98
|
-
};
|
|
99
|
-
confirmationNumber: string;
|
|
100
|
-
}): Promise<void>;
|
|
101
57
|
/**
|
|
102
58
|
* 進行中の注文取引を取得する
|
|
103
59
|
*/
|
|
@@ -125,9 +81,10 @@ export declare class PlaceOrderRepo {
|
|
|
125
81
|
object: {
|
|
126
82
|
orderDate: Date;
|
|
127
83
|
orderNumber: string;
|
|
84
|
+
confirmationNumber: string;
|
|
128
85
|
};
|
|
129
86
|
result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
|
|
130
|
-
potentialActions
|
|
87
|
+
potentialActions?: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
|
|
131
88
|
}): Promise<void>;
|
|
132
89
|
/**
|
|
133
90
|
* 取引を中止する
|