@chevre/domain 25.2.0-alpha.8 → 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/actionProcess.js +57 -57
- 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/action.js +57 -57
- 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 +13 -37
- package/lib/chevre/service/payment/any/factory.d.ts +7 -7
- package/lib/chevre/service/payment/any/factory.js +19 -22
- 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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AnyKeys, Connection, FilterQuery, ProjectionType } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
import { IDocType } from './mongoose/schemas/task';
|
|
4
|
+
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | 'expires';
|
|
5
|
+
/**
|
|
6
|
+
* タスク管理リポジトリ
|
|
7
|
+
*/
|
|
8
|
+
export declare class AdminTaskRepo {
|
|
9
|
+
private readonly taskModel;
|
|
10
|
+
constructor(connection: Connection);
|
|
11
|
+
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask>[];
|
|
12
|
+
countTasks(params: factory.task.ISearchConditions): Promise<{
|
|
13
|
+
count: number;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* 検索する
|
|
17
|
+
*/
|
|
18
|
+
findTasks(params: factory.task.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.task.ITask<factory.taskName>[]>;
|
|
19
|
+
getCursor(conditions: FilterQuery<factory.task.ITask<factory.taskName>>, projection: ProjectionType<factory.task.ITask<factory.taskName>>): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask, "id"> & {
|
|
20
|
+
expires?: Date;
|
|
21
|
+
} & {
|
|
22
|
+
_id: import("mongoose").Types.ObjectId;
|
|
23
|
+
} & {
|
|
24
|
+
__v: number;
|
|
25
|
+
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask, "id"> & {
|
|
26
|
+
expires?: Date;
|
|
27
|
+
} & {
|
|
28
|
+
_id: import("mongoose").Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}) | null>;
|
|
32
|
+
unsetUnnecessaryFields(params: {
|
|
33
|
+
filter: FilterQuery<factory.task.ITask<factory.taskName>>;
|
|
34
|
+
$unset: AnyKeys<factory.task.ITask<factory.taskName>>;
|
|
35
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminTaskRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
const task_1 = require("./mongoose/schemas/task");
|
|
7
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
8
|
+
'alternateName',
|
|
9
|
+
'identifier',
|
|
10
|
+
'description',
|
|
11
|
+
'project',
|
|
12
|
+
'name',
|
|
13
|
+
'status',
|
|
14
|
+
'runsAt',
|
|
15
|
+
'remainingNumberOfTries',
|
|
16
|
+
'lastTriedAt',
|
|
17
|
+
'numberOfTried',
|
|
18
|
+
'executionResults',
|
|
19
|
+
'executor',
|
|
20
|
+
'data',
|
|
21
|
+
'dateAborted',
|
|
22
|
+
'expires'
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* タスク管理リポジトリ
|
|
26
|
+
*/
|
|
27
|
+
class AdminTaskRepo {
|
|
28
|
+
taskModel;
|
|
29
|
+
constructor(connection) {
|
|
30
|
+
this.taskModel = connection.model(task_1.modelName, (0, task_1.createSchema)());
|
|
31
|
+
}
|
|
32
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
33
|
+
const andConditions = [];
|
|
34
|
+
const idEq = params.id?.$eq;
|
|
35
|
+
if (typeof idEq === 'string') {
|
|
36
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
37
|
+
}
|
|
38
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
if (typeof params.name === 'string') {
|
|
43
|
+
andConditions.push({ name: { $eq: params.name } });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const nameIn = params.name?.$in;
|
|
47
|
+
if (Array.isArray(nameIn)) {
|
|
48
|
+
andConditions.push({ name: { $in: nameIn } });
|
|
49
|
+
}
|
|
50
|
+
const nameNin = params.name?.$nin;
|
|
51
|
+
if (Array.isArray(nameNin)) {
|
|
52
|
+
andConditions.push({ name: { $nin: nameNin } });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const statusEq = params.status?.$eq;
|
|
56
|
+
if (typeof statusEq === 'string') {
|
|
57
|
+
andConditions.push({ status: { $eq: statusEq } });
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(params.statuses)) {
|
|
60
|
+
andConditions.push({ status: { $in: params.statuses } });
|
|
61
|
+
}
|
|
62
|
+
if (params.runsFrom instanceof Date) {
|
|
63
|
+
andConditions.push({ runsAt: { $gte: params.runsFrom } });
|
|
64
|
+
}
|
|
65
|
+
if (params.runsThrough instanceof Date) {
|
|
66
|
+
andConditions.push({ runsAt: { $lte: params.runsThrough } });
|
|
67
|
+
}
|
|
68
|
+
if (params.lastTriedFrom instanceof Date) {
|
|
69
|
+
andConditions.push({ lastTriedAt: { $type: 'date', $gte: params.lastTriedFrom } });
|
|
70
|
+
}
|
|
71
|
+
if (params.lastTriedThrough instanceof Date) {
|
|
72
|
+
andConditions.push({ lastTriedAt: { $type: 'date', $lte: params.lastTriedThrough } });
|
|
73
|
+
}
|
|
74
|
+
const dateAbortedGte = params.dateAborted?.$gte;
|
|
75
|
+
if (dateAbortedGte instanceof Date) {
|
|
76
|
+
andConditions.push({ dateAborted: { $type: 'date', $gte: dateAbortedGte } });
|
|
77
|
+
}
|
|
78
|
+
const dateAbortedLte = params.dateAborted?.$lte;
|
|
79
|
+
if (dateAbortedLte instanceof Date) {
|
|
80
|
+
andConditions.push({ dateAborted: { $type: 'date', $lte: dateAbortedLte } });
|
|
81
|
+
}
|
|
82
|
+
const objectIdEq = params.data?.object?.id?.$eq;
|
|
83
|
+
if (typeof objectIdEq === 'string') {
|
|
84
|
+
andConditions.push({ 'data.object.id': { $exists: true, $eq: objectIdEq } });
|
|
85
|
+
}
|
|
86
|
+
const objectOrderNumberEq = params.data?.object?.orderNumber?.$eq;
|
|
87
|
+
if (typeof objectOrderNumberEq === 'string') {
|
|
88
|
+
andConditions.push({ 'data.object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
|
|
89
|
+
}
|
|
90
|
+
const objectTransactionNumberEq = params.data?.object?.transactionNumber?.$eq;
|
|
91
|
+
if (typeof objectTransactionNumberEq === 'string') {
|
|
92
|
+
andConditions.push({ 'data.object.transactionNumber': { $exists: true, $eq: objectTransactionNumberEq } });
|
|
93
|
+
}
|
|
94
|
+
const objectPurposeIdEq = params.data?.purpose?.id?.$eq;
|
|
95
|
+
if (typeof objectPurposeIdEq === 'string') {
|
|
96
|
+
andConditions.push({ 'data.purpose.id': { $exists: true, $eq: objectPurposeIdEq } });
|
|
97
|
+
}
|
|
98
|
+
const objectPurposeOrderNumberEq = params.data?.purpose?.orderNumber?.$eq;
|
|
99
|
+
if (typeof objectPurposeOrderNumberEq === 'string') {
|
|
100
|
+
andConditions.push({ 'data.purpose.orderNumber': { $exists: true, $eq: objectPurposeOrderNumberEq } });
|
|
101
|
+
}
|
|
102
|
+
const alternateNameRegex = params.alternateName?.$regex;
|
|
103
|
+
if (typeof alternateNameRegex === 'string' && alternateNameRegex.length > 0) {
|
|
104
|
+
andConditions.push({ alternateName: { $exists: true, $regex: new RegExp(alternateNameRegex) } });
|
|
105
|
+
}
|
|
106
|
+
const identifierRegex = params.identifier?.$regex;
|
|
107
|
+
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
108
|
+
andConditions.push({ identifier: { $exists: true, $regex: new RegExp(identifierRegex) } });
|
|
109
|
+
}
|
|
110
|
+
return andConditions;
|
|
111
|
+
}
|
|
112
|
+
async countTasks(params) {
|
|
113
|
+
const { limit } = params;
|
|
114
|
+
const conditions = AdminTaskRepo.CREATE_MONGO_CONDITIONS(params);
|
|
115
|
+
const query = this.taskModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
116
|
+
if (typeof limit === 'number' && limit >= 0) {
|
|
117
|
+
query.limit(limit);
|
|
118
|
+
}
|
|
119
|
+
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
120
|
+
.exec();
|
|
121
|
+
return { count };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 検索する
|
|
125
|
+
*/
|
|
126
|
+
async findTasks(params, inclusion) {
|
|
127
|
+
const conditions = AdminTaskRepo.CREATE_MONGO_CONDITIONS(params);
|
|
128
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
129
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
130
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// no op
|
|
134
|
+
}
|
|
135
|
+
const projection = {
|
|
136
|
+
_id: 0,
|
|
137
|
+
id: { $toString: '$_id' },
|
|
138
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
139
|
+
};
|
|
140
|
+
const query = this.taskModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
141
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
142
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
143
|
+
query.limit(params.limit)
|
|
144
|
+
.skip(params.limit * (page - 1));
|
|
145
|
+
}
|
|
146
|
+
if (params.sort?.runsAt !== undefined) {
|
|
147
|
+
query.sort({ runsAt: params.sort.runsAt });
|
|
148
|
+
}
|
|
149
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
150
|
+
.lean() // lean(2024-09-26~)
|
|
151
|
+
.exec();
|
|
152
|
+
}
|
|
153
|
+
getCursor(conditions, projection) {
|
|
154
|
+
return this.taskModel.find(conditions, projection)
|
|
155
|
+
.sort({ runsAt: factory_1.factory.sortType.Ascending })
|
|
156
|
+
.cursor();
|
|
157
|
+
}
|
|
158
|
+
async unsetUnnecessaryFields(params) {
|
|
159
|
+
return this.taskModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
160
|
+
.exec();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.AdminTaskRepo = AdminTaskRepo;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AnyExpression, Connection, Document, FilterQuery, PipelineStage } from 'mongoose';
|
|
1
|
+
import { AnyExpression, Connection, Document, FilterQuery, PipelineStage, mongo } from 'mongoose';
|
|
3
2
|
import { factory } from '../factory';
|
|
4
3
|
import { IDocType as IAggregateOfferDocType } from './mongoose/schemas/aggregateOffer';
|
|
5
4
|
type IMatchStage = PipelineStage.Match;
|
|
@@ -13,7 +12,7 @@ export declare class AggregateOfferRepo {
|
|
|
13
12
|
constructor(connection: Connection);
|
|
14
13
|
static CREATE_MATCH_STAGE(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): IMatchStage[];
|
|
15
14
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): Record<string, AnyExpression>;
|
|
16
|
-
|
|
15
|
+
findAggregateOffers(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<Pick<factory.aggregateOffer.IAggregateOffer, 'id' | 'offers' | 'typeOf'>[]>;
|
|
17
16
|
pushIncludedInDataCatalog(params: {
|
|
18
17
|
project: {
|
|
19
18
|
id: string;
|
|
@@ -80,7 +79,7 @@ export declare class AggregateOfferRepo {
|
|
|
80
79
|
*/
|
|
81
80
|
productType: factory.product.ProductType;
|
|
82
81
|
}): Promise<{
|
|
83
|
-
bulkWriteResult?: BulkWriteResult;
|
|
82
|
+
bulkWriteResult?: mongo.BulkWriteResult;
|
|
84
83
|
modifiedOffers?: {
|
|
85
84
|
id: string;
|
|
86
85
|
}[];
|
|
@@ -110,15 +109,5 @@ export declare class AggregateOfferRepo {
|
|
|
110
109
|
};
|
|
111
110
|
};
|
|
112
111
|
}): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
113
|
-
countIncludedInDataCatalog(params: {
|
|
114
|
-
id: {
|
|
115
|
-
$eq: string;
|
|
116
|
-
};
|
|
117
|
-
}): Promise<{
|
|
118
|
-
includedInDataCatalogCount: number;
|
|
119
|
-
}[]>;
|
|
120
|
-
maxIncludedInDataCatalogCount(): Promise<{
|
|
121
|
-
includedInDataCatalogCount: number;
|
|
122
|
-
}[]>;
|
|
123
112
|
}
|
|
124
113
|
export {};
|
|
@@ -374,11 +374,11 @@ class AggregateOfferRepo {
|
|
|
374
374
|
_id: 0,
|
|
375
375
|
id: '$_id',
|
|
376
376
|
typeOf: '$typeOf',
|
|
377
|
-
project: '$project',
|
|
378
377
|
offers: [{ $first: '$offers' }],
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
378
|
+
// project: '$project', // discontinue(2026-07-24~)
|
|
379
|
+
// highPrice: { $max: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
|
|
380
|
+
// lowPrice: { $min: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
|
|
381
|
+
// offerCount: { $size: '$offers' } // offers.length:1に限定につき廃止(2026-07-24~)
|
|
382
382
|
};
|
|
383
383
|
const positiveProjectionFields = Object.keys(params)
|
|
384
384
|
.filter((key) => params[key] !== 0);
|
|
@@ -389,11 +389,10 @@ class AggregateOfferRepo {
|
|
|
389
389
|
_id: 0,
|
|
390
390
|
id: '$_id',
|
|
391
391
|
typeOf: '$typeOf',
|
|
392
|
-
project: '$project',
|
|
393
|
-
//
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
offerCount: { $size: '$offers' }
|
|
392
|
+
// project: '$project', // discontinue(2026-07-24~)
|
|
393
|
+
// highPrice: { $max: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
|
|
394
|
+
// lowPrice: { $min: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
|
|
395
|
+
// offerCount: { $size: '$offers' } // offers.length:1に限定につき廃止(2026-07-24~)
|
|
397
396
|
};
|
|
398
397
|
const offersProjection = {};
|
|
399
398
|
positiveProjectionFields.forEach((field) => {
|
|
@@ -410,7 +409,7 @@ class AggregateOfferRepo {
|
|
|
410
409
|
}
|
|
411
410
|
return projectStage;
|
|
412
411
|
}
|
|
413
|
-
async
|
|
412
|
+
async findAggregateOffers(params, projection) {
|
|
414
413
|
const matchStages = AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
415
414
|
const projectStage = AggregateOfferRepo.CREATE_AGGREGATE_OFFERS_PROJECTION({ ...projection });
|
|
416
415
|
const sortByPrice = params.sort?.['priceSpecification.price'];
|
|
@@ -436,8 +435,11 @@ class AggregateOfferRepo {
|
|
|
436
435
|
/* istanbul ignore else */
|
|
437
436
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
438
437
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
// support skip -> limit(2026-07-24~)
|
|
439
|
+
// aggregate.limit(params.limit * page)
|
|
440
|
+
// .skip(params.limit * (page - 1));
|
|
441
|
+
aggregate.skip(params.limit * (page - 1))
|
|
442
|
+
.limit(params.limit);
|
|
441
443
|
}
|
|
442
444
|
return aggregate.exec();
|
|
443
445
|
}
|
|
@@ -499,25 +501,6 @@ class AggregateOfferRepo {
|
|
|
499
501
|
}, { projection: { _id: 1 } })
|
|
500
502
|
.exec();
|
|
501
503
|
}
|
|
502
|
-
// 単価オファー最適化作業における一時的な処理
|
|
503
|
-
// public async optimizeOffers() {
|
|
504
|
-
// return this.aggregateOfferModel.updateMany(
|
|
505
|
-
// {
|
|
506
|
-
// $or: [
|
|
507
|
-
// { 'offers.id': { $exists: true } },
|
|
508
|
-
// { 'offers.project': { $exists: true } }
|
|
509
|
-
// ]
|
|
510
|
-
// },
|
|
511
|
-
// {
|
|
512
|
-
// $set: {},
|
|
513
|
-
// $unset: {
|
|
514
|
-
// 'offers.0.id': 1,
|
|
515
|
-
// 'offers.0.project': 1
|
|
516
|
-
// }
|
|
517
|
-
// }
|
|
518
|
-
// )
|
|
519
|
-
// .exec();
|
|
520
|
-
// }
|
|
521
504
|
getCursor(conditions, projection) {
|
|
522
505
|
return this.aggregateOfferModel.find(conditions, projection)
|
|
523
506
|
.sort({ 'offers.identifier': factory_1.factory.sortType.Ascending })
|
|
@@ -530,15 +513,12 @@ class AggregateOfferRepo {
|
|
|
530
513
|
async save(params) {
|
|
531
514
|
let doc;
|
|
532
515
|
let aggregateOfferId;
|
|
533
|
-
// const { $unset, ...paramsWithoutUnset } = params;
|
|
534
516
|
const { ...paramsWithoutUnset } = params;
|
|
535
|
-
// let savedUnitPriceOffer: factory.unitPriceOffer.IUnitPriceOffer;
|
|
536
517
|
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
537
518
|
const { default: uniqid } = await import('uniqid');
|
|
538
519
|
const newId = uniqid();
|
|
539
520
|
aggregateOfferId = newId;
|
|
540
521
|
// サブオファー最適化(2023-12-22~)
|
|
541
|
-
// savedUnitPriceOffer = { ...paramsWithoutUnset, id };
|
|
542
522
|
const { id, project, ...savedUnitPriceOffer } = paramsWithoutUnset; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
543
523
|
const aggregateOffer = {
|
|
544
524
|
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
@@ -552,18 +532,7 @@ class AggregateOfferRepo {
|
|
|
552
532
|
}
|
|
553
533
|
else {
|
|
554
534
|
aggregateOfferId = params.id;
|
|
555
|
-
|
|
556
|
-
// await this.search(
|
|
557
|
-
// {
|
|
558
|
-
// limit: 1,
|
|
559
|
-
// page: 1,
|
|
560
|
-
// project: { id: { $eq: params.project.id } },
|
|
561
|
-
// id: { $eq: params.id }
|
|
562
|
-
// },
|
|
563
|
-
// { identifier: 1, project: 1, typeOf: 1 }
|
|
564
|
-
// );
|
|
565
|
-
// const originalUnitPriceOffer = unitPriceOffers.shift();
|
|
566
|
-
const aggregateOffers = await this.search({
|
|
535
|
+
const aggregateOffers = await this.findAggregateOffers({
|
|
567
536
|
limit: 1,
|
|
568
537
|
page: 1,
|
|
569
538
|
project: { id: { $eq: params.project.id } },
|
|
@@ -579,26 +548,17 @@ class AggregateOfferRepo {
|
|
|
579
548
|
// サブオファー最適化(2023-12-22~)
|
|
580
549
|
const subOffer = {
|
|
581
550
|
...updateFields,
|
|
582
|
-
// id: originalUnitPriceOffer.id,
|
|
583
551
|
identifier: originalUnitPriceOffer.identifier,
|
|
584
|
-
// project: originalUnitPriceOffer.project,
|
|
585
552
|
typeOf: originalUnitPriceOffer.typeOf
|
|
586
553
|
};
|
|
587
|
-
doc = await this.aggregateOfferModel.findOneAndUpdate(
|
|
588
|
-
// { 'offers.id': params.id },
|
|
589
|
-
{ _id: params.id }, // _idに変更(2023-12-22~)
|
|
554
|
+
doc = await this.aggregateOfferModel.findOneAndUpdate({ _id: params.id }, // _idに変更(2023-12-22~)
|
|
590
555
|
{
|
|
591
556
|
$set: {
|
|
592
|
-
// 'offers.$[offer]': savedUnitPriceOffer
|
|
593
557
|
'offers.0': subOffer // _idに変更(2023-12-22~)
|
|
594
558
|
}
|
|
595
559
|
}, {
|
|
596
560
|
upsert: false,
|
|
597
561
|
new: true
|
|
598
|
-
// _idに変更(2023-12-22~)
|
|
599
|
-
// arrayFilters: [
|
|
600
|
-
// { 'offer.id': { $eq: params.id } }
|
|
601
|
-
// ]
|
|
602
562
|
})
|
|
603
563
|
.exec();
|
|
604
564
|
}
|
|
@@ -676,7 +636,6 @@ class AggregateOfferRepo {
|
|
|
676
636
|
async saveManyByIdentifier4sskts(params) {
|
|
677
637
|
const { default: uniqid } = await import('uniqid');
|
|
678
638
|
const insertBulkWriteOps = [];
|
|
679
|
-
// const updateBulkWriteOps: AnyBulkWriteOperation[] = [];
|
|
680
639
|
if (Array.isArray(params)) {
|
|
681
640
|
params.forEach((p) => {
|
|
682
641
|
const newOfferId = uniqid();
|
|
@@ -710,7 +669,6 @@ class AggregateOfferRepo {
|
|
|
710
669
|
}
|
|
711
670
|
if (insertBulkWriteOps.length > 0) {
|
|
712
671
|
await this.aggregateOfferModel.bulkWrite(insertBulkWriteOps, { ordered: false });
|
|
713
|
-
// await this.aggregateOfferModel.bulkWrite(updateBulkWriteOps, { ordered: false });
|
|
714
672
|
}
|
|
715
673
|
}
|
|
716
674
|
/**
|
|
@@ -724,13 +682,6 @@ class AggregateOfferRepo {
|
|
|
724
682
|
'project.id': { $eq: params.project.id },
|
|
725
683
|
'offers.addOn.itemOffered.id': { $exists: true, $in: params.addOn.itemOffered.id.$in }
|
|
726
684
|
};
|
|
727
|
-
// const updatingOffers = <Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id' | 'identifier'>[]>await this.search(
|
|
728
|
-
// {
|
|
729
|
-
// project: { id: { $eq: params.project.id } },
|
|
730
|
-
// addOn: { itemOffered: { id: { $in: params.addOn.itemOffered.id.$in } } }
|
|
731
|
-
// },
|
|
732
|
-
// { identifier: 1 }
|
|
733
|
-
// );
|
|
734
685
|
return this.aggregateOfferModel.updateMany(conditions, {
|
|
735
686
|
$pull: {
|
|
736
687
|
'offers.$[offer].addOn': {
|
|
@@ -743,66 +694,6 @@ class AggregateOfferRepo {
|
|
|
743
694
|
]
|
|
744
695
|
})
|
|
745
696
|
.exec();
|
|
746
|
-
// if (updatingOffers.length > 0) {
|
|
747
|
-
// // no op
|
|
748
|
-
// }
|
|
749
|
-
// return result;
|
|
750
|
-
}
|
|
751
|
-
async countIncludedInDataCatalog(params) {
|
|
752
|
-
const aggregate = this.aggregateOfferModel.aggregate([
|
|
753
|
-
{
|
|
754
|
-
$match: {
|
|
755
|
-
_id: { $eq: params.id.$eq }
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
$project: {
|
|
760
|
-
_id: 0,
|
|
761
|
-
includedInDataCatalogCount: {
|
|
762
|
-
$cond: {
|
|
763
|
-
if: { $isArray: '$includedInDataCatalog' },
|
|
764
|
-
then: { $size: '$includedInDataCatalog' },
|
|
765
|
-
else: 0
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
]);
|
|
771
|
-
return aggregate.exec();
|
|
772
|
-
}
|
|
773
|
-
async maxIncludedInDataCatalogCount() {
|
|
774
|
-
const aggregate = this.aggregateOfferModel.aggregate([
|
|
775
|
-
// {
|
|
776
|
-
// $match: {
|
|
777
|
-
// _id: { $eq: params.id.$eq }
|
|
778
|
-
// }
|
|
779
|
-
// },
|
|
780
|
-
{
|
|
781
|
-
$project: {
|
|
782
|
-
_id: 0,
|
|
783
|
-
includedInDataCatalogCount: {
|
|
784
|
-
$cond: {
|
|
785
|
-
if: { $isArray: '$includedInDataCatalog' },
|
|
786
|
-
then: { $size: '$includedInDataCatalog' },
|
|
787
|
-
else: 0
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
},
|
|
792
|
-
{
|
|
793
|
-
$group: {
|
|
794
|
-
_id: null,
|
|
795
|
-
maxCount: { $max: '$includedInDataCatalogCount' }
|
|
796
|
-
}
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
$project: {
|
|
800
|
-
_id: 0,
|
|
801
|
-
maxCount: '$maxCount'
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
]);
|
|
805
|
-
return aggregate.exec();
|
|
806
697
|
}
|
|
807
698
|
}
|
|
808
699
|
exports.AggregateOfferRepo = AggregateOfferRepo;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
interface IAggregationByStatus {
|
|
4
|
+
taskCount: number;
|
|
5
|
+
avgLatency: number;
|
|
6
|
+
maxLatency: number;
|
|
7
|
+
minLatency: number;
|
|
8
|
+
percentilesLatency: {
|
|
9
|
+
name: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
interface IStatus {
|
|
14
|
+
status: factory.taskStatus;
|
|
15
|
+
aggregation: IAggregationByStatus;
|
|
16
|
+
}
|
|
17
|
+
interface IAggregateTask {
|
|
18
|
+
statuses: IStatus[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* タスク集計リポジトリ
|
|
22
|
+
*/
|
|
23
|
+
export declare class AggregateTaskRepo {
|
|
24
|
+
private readonly taskModel;
|
|
25
|
+
constructor(connection: Connection);
|
|
26
|
+
aggregateTask(params: {
|
|
27
|
+
project?: {
|
|
28
|
+
id?: {
|
|
29
|
+
$ne?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
runsFrom: Date;
|
|
33
|
+
runsThrough: Date;
|
|
34
|
+
}): Promise<IAggregateTask>;
|
|
35
|
+
private agggregateByStatus;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AggregateTaskRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const task_1 = require("./mongoose/schemas/task");
|
|
6
|
+
/**
|
|
7
|
+
* タスク集計リポジトリ
|
|
8
|
+
*/
|
|
9
|
+
class AggregateTaskRepo {
|
|
10
|
+
taskModel;
|
|
11
|
+
constructor(connection) {
|
|
12
|
+
this.taskModel = connection.model(task_1.modelName, (0, task_1.createSchema)());
|
|
13
|
+
}
|
|
14
|
+
async aggregateTask(params) {
|
|
15
|
+
const statuses = await Promise.all([
|
|
16
|
+
factory_1.factory.taskStatus.Executed,
|
|
17
|
+
factory_1.factory.taskStatus.Aborted
|
|
18
|
+
].map(async (taskStatus) => {
|
|
19
|
+
const matchConditions = {
|
|
20
|
+
runsAt: {
|
|
21
|
+
$gte: params.runsFrom,
|
|
22
|
+
$lte: params.runsThrough
|
|
23
|
+
},
|
|
24
|
+
status: { $eq: taskStatus },
|
|
25
|
+
...(typeof params.project?.id?.$ne === 'string')
|
|
26
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
27
|
+
: undefined
|
|
28
|
+
};
|
|
29
|
+
return this.agggregateByStatus({ matchConditions, status: taskStatus });
|
|
30
|
+
}));
|
|
31
|
+
return { statuses };
|
|
32
|
+
}
|
|
33
|
+
async agggregateByStatus(params) {
|
|
34
|
+
const matchConditions = params.matchConditions;
|
|
35
|
+
const taskStatus = params.status;
|
|
36
|
+
const aggregate1 = this.taskModel.aggregate([
|
|
37
|
+
{
|
|
38
|
+
$match: matchConditions
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
$project: {
|
|
42
|
+
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
43
|
+
status: '$status',
|
|
44
|
+
runsAt: '$runsAt',
|
|
45
|
+
lastTriedAt: '$lastTriedAt'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
$group: {
|
|
50
|
+
_id: '$status',
|
|
51
|
+
taskCount: { $sum: 1 },
|
|
52
|
+
maxLatency: { $max: '$latency' },
|
|
53
|
+
minLatency: { $min: '$latency' },
|
|
54
|
+
avgLatency: { $avg: '$latency' }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
$project: {
|
|
59
|
+
_id: 0,
|
|
60
|
+
taskCount: '$taskCount',
|
|
61
|
+
avgLatency: '$avgLatency',
|
|
62
|
+
maxLatency: '$maxLatency',
|
|
63
|
+
minLatency: '$minLatency'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]);
|
|
67
|
+
// const explainResult = await aggregate1.explain();
|
|
68
|
+
// console.dir(explainResult, { depth: null });
|
|
69
|
+
// return;
|
|
70
|
+
const aggregations = await aggregate1.exec();
|
|
71
|
+
const percents = [50, 95, 99];
|
|
72
|
+
if (aggregations.length === 0) {
|
|
73
|
+
return {
|
|
74
|
+
status: taskStatus,
|
|
75
|
+
aggregation: {
|
|
76
|
+
taskCount: 0,
|
|
77
|
+
avgLatency: 0,
|
|
78
|
+
maxLatency: 0,
|
|
79
|
+
minLatency: 0,
|
|
80
|
+
percentilesLatency: percents.map((percent) => {
|
|
81
|
+
return {
|
|
82
|
+
name: String(percent),
|
|
83
|
+
value: 0
|
|
84
|
+
};
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
90
|
+
return {
|
|
91
|
+
percentile,
|
|
92
|
+
rank: Math.floor(aggregations[0].taskCount * percentile / 100)
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
const aggregate2 = this.taskModel.aggregate([
|
|
96
|
+
{
|
|
97
|
+
$match: matchConditions
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
$project: {
|
|
101
|
+
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
102
|
+
status: '$status',
|
|
103
|
+
runsAt: '$runsAt',
|
|
104
|
+
lastTriedAt: '$lastTriedAt'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{ $sort: { latency: 1 } },
|
|
108
|
+
{
|
|
109
|
+
$group: {
|
|
110
|
+
_id: '$status',
|
|
111
|
+
latencies: { $push: '$latency' }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
$project: {
|
|
116
|
+
_id: 0,
|
|
117
|
+
percentilesLatency: ranks4percentile.map((rank) => {
|
|
118
|
+
return {
|
|
119
|
+
name: String(rank.percentile),
|
|
120
|
+
value: { $arrayElemAt: ['$latencies', rank.rank] }
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
const aggregations2 = await aggregate2.exec();
|
|
127
|
+
return {
|
|
128
|
+
status: taskStatus,
|
|
129
|
+
aggregation: {
|
|
130
|
+
...aggregations[0],
|
|
131
|
+
...aggregations2[0]
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.AggregateTaskRepo = AggregateTaskRepo;
|