@chevre/domain 26.0.0-alpha.8 → 26.0.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 +8 -23
- package/lib/chevre/eventEmitter/task.js +2 -2
- package/lib/chevre/repo/acceptedOffer.d.ts +0 -7
- package/lib/chevre/repo/acceptedOffer.js +27 -27
- package/lib/chevre/repo/action/acceptCOAOffer.d.ts +3 -1
- package/lib/chevre/repo/action/acceptCOAOffer.js +8 -2
- package/lib/chevre/repo/action/acceptPay.d.ts +3 -1
- package/lib/chevre/repo/action/acceptPay.js +8 -4
- package/lib/chevre/repo/action/anyAction/actionProcess.d.ts +120 -0
- package/lib/chevre/repo/action/{actionProcess.js → anyAction/actionProcess.js} +28 -157
- package/lib/chevre/repo/action/anyAction/actionRecipe.d.ts +37 -0
- package/lib/chevre/repo/action/anyAction/actionRecipe.js +53 -0
- package/lib/chevre/repo/action/authorizeInvoice.d.ts +5 -8
- package/lib/chevre/repo/action/authorizeInvoice.js +7 -4
- package/lib/chevre/repo/action/authorizeOffer.d.ts +3 -1
- package/lib/chevre/repo/action/authorizeOffer.js +7 -2
- package/lib/chevre/repo/action/authorizePaymentMethod.d.ts +3 -1
- package/lib/chevre/repo/action/authorizePaymentMethod.js +7 -4
- package/lib/chevre/repo/action/authorizeTicketedObject.d.ts +3 -1
- package/lib/chevre/repo/action/authorizeTicketedObject.js +7 -2
- package/lib/chevre/repo/action/cancel.d.ts +25 -0
- package/lib/chevre/repo/action/cancel.js +47 -0
- package/lib/chevre/repo/action/checkMovieTicket.d.ts +3 -1
- package/lib/chevre/repo/action/checkMovieTicket.js +8 -1
- package/lib/chevre/repo/action/confirm.d.ts +11 -0
- package/lib/chevre/repo/action/confirm.js +16 -0
- package/lib/chevre/repo/action/create.d.ts +10 -0
- package/lib/chevre/repo/action/create.js +17 -0
- package/lib/chevre/repo/action/inform.d.ts +38 -0
- package/lib/chevre/repo/action/inform.js +146 -0
- package/lib/chevre/repo/action/order.d.ts +21 -0
- package/lib/chevre/repo/action/order.js +35 -0
- package/lib/chevre/repo/action/pay.d.ts +3 -1
- package/lib/chevre/repo/action/pay.js +7 -4
- package/lib/chevre/repo/action/refund.d.ts +3 -1
- package/lib/chevre/repo/action/refund.js +7 -4
- package/lib/chevre/repo/action/reserve.d.ts +21 -0
- package/lib/chevre/repo/action/reserve.js +37 -0
- package/lib/chevre/repo/action/returnAction.d.ts +11 -0
- package/lib/chevre/repo/action/returnAction.js +16 -0
- package/lib/chevre/repo/action/sendEmailMessage.d.ts +10 -0
- package/lib/chevre/repo/action/sendEmailMessage.js +17 -0
- package/lib/chevre/repo/action/sendOrder.d.ts +10 -0
- package/lib/chevre/repo/action/sendOrder.js +16 -0
- package/lib/chevre/repo/action/unknown2actionError.d.ts +6 -0
- package/lib/chevre/repo/action/unknown2actionError.js +15 -0
- package/lib/chevre/repo/action/update.d.ts +48 -0
- package/lib/chevre/repo/action/update.js +166 -0
- package/lib/chevre/repo/action/use.d.ts +39 -0
- package/lib/chevre/repo/action/use.js +153 -0
- package/lib/chevre/repo/{action.d.ts → adminAction.d.ts} +11 -37
- package/lib/chevre/repo/adminAction.js +176 -0
- package/lib/chevre/repo/adminAssetTransaction.d.ts +126 -0
- package/lib/chevre/repo/adminAssetTransaction.js +491 -0
- package/lib/chevre/repo/adminAsyncAction.d.ts +2 -2
- package/lib/chevre/repo/adminScheduledTask.d.ts +1 -1
- package/lib/chevre/repo/adminTask.d.ts +25 -8
- package/lib/chevre/repo/adminTask.js +31 -32
- package/lib/chevre/repo/adminTransaction.d.ts +131 -0
- package/lib/chevre/repo/adminTransaction.js +237 -0
- package/lib/chevre/repo/aggregateAction.d.ts +8 -11
- package/lib/chevre/repo/aggregateAction.js +0 -61
- package/lib/chevre/repo/aggregateAssetTransaction.d.ts +43 -0
- package/lib/chevre/repo/aggregateAssetTransaction.js +166 -0
- package/lib/chevre/repo/aggregateTransaction.d.ts +39 -0
- package/lib/chevre/repo/aggregateTransaction.js +166 -0
- package/lib/chevre/repo/aggregateUseAction.d.ts +35 -0
- package/lib/chevre/repo/aggregateUseAction.js +164 -0
- package/lib/chevre/repo/aggregation.d.ts +0 -8
- package/lib/chevre/repo/aggregation.js +0 -10
- package/lib/chevre/repo/assetTransaction.d.ts +10 -235
- package/lib/chevre/repo/assetTransaction.js +48 -636
- package/lib/chevre/repo/asyncAction.d.ts +2 -2
- package/lib/chevre/repo/authorization.d.ts +0 -6
- package/lib/chevre/repo/authorization.js +15 -27
- package/lib/chevre/repo/message.d.ts +0 -7
- package/lib/chevre/repo/message.js +0 -38
- package/lib/chevre/repo/migrateAction.d.ts +48 -0
- package/lib/chevre/repo/migrateAction.js +32 -0
- package/lib/chevre/repo/mongoose/schemas/action/inform.d.ts +11 -0
- package/lib/chevre/repo/mongoose/schemas/action/inform.js +82 -0
- package/lib/chevre/repo/mongoose/schemas/action/update.d.ts +12 -0
- package/lib/chevre/repo/mongoose/schemas/action/update.js +112 -0
- package/lib/chevre/repo/mongoose/schemas/{ownershipInfo.d.ts → action/use.d.ts} +4 -6
- package/lib/chevre/repo/mongoose/schemas/action/use.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +22 -7
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +1 -0
- package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +19 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +8 -9
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +95 -76
- package/lib/chevre/repo/mongoose/schemas/authorization.js +25 -18
- package/lib/chevre/repo/mongoose/schemas/event.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/message.js +8 -1
- package/lib/chevre/repo/mongoose/schemas/pendingReservation.js +11 -4
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +5 -16
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +2 -5
- package/lib/chevre/repo/mongoose/schemas/task.js +134 -118
- package/lib/chevre/repo/mongoose/schemas/ticket.js +8 -1
- package/lib/chevre/repo/orderInTransaction.d.ts +0 -3
- package/lib/chevre/repo/orderInTransaction.js +30 -22
- package/lib/chevre/repo/scheduledTask.d.ts +4 -1
- package/lib/chevre/repo/scheduledTask.js +3 -25
- package/lib/chevre/repo/task.d.ts +44 -150
- package/lib/chevre/repo/task.js +13 -446
- package/lib/chevre/repo/taskDelayed.d.ts +74 -0
- package/lib/chevre/repo/taskDelayed.js +195 -0
- package/lib/chevre/repo/taskRunning.d.ts +35 -0
- package/lib/chevre/repo/taskRunning.js +89 -0
- package/lib/chevre/repo/ticket.d.ts +0 -6
- package/lib/chevre/repo/ticket.js +0 -11
- package/lib/chevre/repo/transaction.d.ts +1 -187
- package/lib/chevre/repo/transaction.js +2 -383
- package/lib/chevre/repository.d.ts +65 -25
- package/lib/chevre/repository.js +144 -56
- package/lib/chevre/service/aggregation/system.d.ts +9 -8
- package/lib/chevre/service/aggregation/system.js +5 -5
- package/lib/chevre/service/assetTransaction/cancelReservation/start.js +10 -17
- package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/refund.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/refund.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +4 -2
- package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +4 -2
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.d.ts +8 -4
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +1 -1
- package/lib/chevre/service/asyncAction.d.ts +2 -2
- package/lib/chevre/service/asyncAction.js +1 -4
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.d.ts +2 -2
- package/lib/chevre/service/asyncActionHandler/onOperationFailed.js +0 -2
- package/lib/chevre/service/asyncActionHandler.d.ts +4 -4
- package/lib/chevre/service/asyncActionHandler.js +11 -13
- package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +4 -2
- package/lib/chevre/service/event/processUpdateMovieTheater.js +3 -3
- package/lib/chevre/service/event.d.ts +4 -2
- package/lib/chevre/service/event.js +3 -3
- package/lib/chevre/service/notification/sendEmailMessage.d.ts +4 -2
- package/lib/chevre/service/notification/sendEmailMessage.js +3 -3
- package/lib/chevre/service/notification/triggerWebhook.d.ts +4 -2
- package/lib/chevre/service/notification/triggerWebhook.js +5 -16
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +0 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +4 -2
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -3
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +9 -5
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +6 -4
- package/lib/chevre/service/offer/event/voidTransaction.js +7 -9
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +6 -4
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +3 -15
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +0 -4
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +19 -19
- package/lib/chevre/service/offer/onEventChanged.js +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +4 -10
- package/lib/chevre/service/order/confirmPayTransaction.js +7 -11
- package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -1
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +2 -56
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -2
- package/lib/chevre/service/order/deleteOrder.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +1 -49
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +2 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +2 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +1 -9
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +4 -8
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +5 -11
- package/lib/chevre/service/order/onOrderUpdated/factory.js +0 -3
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +4 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
- package/lib/chevre/service/order/placeOrder.d.ts +6 -4
- package/lib/chevre/service/order/placeOrder.js +9 -17
- package/lib/chevre/service/order/returnOrder.d.ts +4 -4
- package/lib/chevre/service/order/returnOrder.js +11 -43
- package/lib/chevre/service/order/sendOrder.d.ts +4 -6
- package/lib/chevre/service/order/sendOrder.js +30 -72
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +0 -1
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +0 -1
- package/lib/chevre/service/payment/any/authorize.d.ts +0 -1
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findAcceptAction.js +19 -19
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +19 -19
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +0 -4
- package/lib/chevre/service/payment/any/findCheckAction.js +19 -19
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +0 -1
- package/lib/chevre/service/payment/any/onPayActionCompleted.d.ts +0 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
- package/lib/chevre/service/payment/any/onRefundActionCompletedOrFailed.d.ts +0 -1
- package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +0 -1
- package/lib/chevre/service/payment/any/processVoidPayTransaction.js +2 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +2 -2
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +0 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +0 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +0 -1
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +0 -1
- package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +0 -1
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +0 -1
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +0 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +0 -1
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +0 -1
- package/lib/chevre/service/project.d.ts +0 -6
- package/lib/chevre/service/project.js +0 -2
- package/lib/chevre/service/reserve/cancelReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/cancelReservation.js +15 -25
- package/lib/chevre/service/reserve/checkInReservation.d.ts +4 -2
- package/lib/chevre/service/reserve/checkInReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.d.ts +4 -2
- package/lib/chevre/service/reserve/confirmReservation.js +10 -36
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +6 -2
- package/lib/chevre/service/reserve/useReservation.js +6 -24
- package/lib/chevre/service/reserveCOA/cancelReservation.d.ts +4 -2
- package/lib/chevre/service/reserveCOA/cancelReservation.js +3 -3
- package/lib/chevre/service/scheduledTask.d.ts +1 -4
- package/lib/chevre/service/scheduledTask.js +3 -10
- package/lib/chevre/service/scheduledTaskHandler/onOperationFailed.js +1 -2
- package/lib/chevre/service/scheduledTaskHandler.js +0 -13
- package/lib/chevre/service/task/acceptCOAOffer.js +1 -14
- package/lib/chevre/service/task/authorizePayment.js +1 -7
- package/lib/chevre/service/task/cancelPendingReservation.js +3 -4
- package/lib/chevre/service/task/cancelReservation.js +3 -5
- package/lib/chevre/service/task/checkMovieTicket.js +1 -7
- package/lib/chevre/service/task/checkResource.js +14 -57
- package/lib/chevre/service/task/confirmPayTransaction.js +11 -12
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -2
- package/lib/chevre/service/task/confirmReserveTransaction.js +12 -7
- package/lib/chevre/service/task/createAccountingReport.js +8 -15
- package/lib/chevre/service/task/deleteTransaction.js +10 -41
- package/lib/chevre/service/task/importEventsFromCOA.js +4 -2
- package/lib/chevre/service/task/invalidatePaymentUrl.js +0 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +4 -13
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +4 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +4 -4
- package/lib/chevre/service/task/onResourceDeleted.js +4 -3
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated.js +0 -10
- package/lib/chevre/service/task/pay.js +0 -1
- package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +0 -1
- package/lib/chevre/service/task/payment/payByTask.d.ts +0 -1
- package/lib/chevre/service/task/payment/refundByTask.d.ts +0 -1
- package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +0 -2
- package/lib/chevre/service/task/placeOrder.js +8 -6
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -13
- package/lib/chevre/service/task/refund.js +0 -1
- package/lib/chevre/service/task/reserve.js +3 -6
- package/lib/chevre/service/task/returnOrder.js +3 -7
- package/lib/chevre/service/task/returnPayTransaction.js +9 -19
- package/lib/chevre/service/task/returnReserveTransaction.js +5 -6
- package/lib/chevre/service/task/sendEmailMessage.js +2 -2
- package/lib/chevre/service/task/sendOrder.js +4 -8
- package/lib/chevre/service/task/syncResourcesFromCOA.js +31 -23
- package/lib/chevre/service/task/triggerWebhook.js +4 -2
- package/lib/chevre/service/task/useReservation.js +6 -2
- package/lib/chevre/service/task/voidPayment.js +0 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +11 -13
- package/lib/chevre/service/task.d.ts +3 -22
- package/lib/chevre/service/task.js +8 -40
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +0 -1
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +3 -2
- package/lib/chevre/service/taskHandler/onOperationFailed.js +5 -16
- package/lib/chevre/service/taskHandler.d.ts +1 -2
- package/lib/chevre/service/taskHandler.js +7 -19
- package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +2 -2
- package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +2 -2
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +8 -4
- package/lib/chevre/service/transaction/deleteTransaction.js +7 -7
- package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +11 -17
- package/lib/chevre/service/transaction/returnOrder.js +11 -17
- package/lib/chevre/service/validation/validateOrder.d.ts +0 -4
- package/lib/chevre/service/validation/validateOrder.js +3 -3
- package/lib/chevre/taskSettings.d.ts +4 -4
- package/package.json +2 -2
- package/lib/chevre/repo/action/actionProcess.d.ts +0 -147
- package/lib/chevre/repo/action/checkThing.d.ts +0 -8
- package/lib/chevre/repo/action/checkThing.js +0 -13
- package/lib/chevre/repo/action.js +0 -468
- package/lib/chevre/repo/asyncActionLegacy.d.ts +0 -23
- package/lib/chevre/repo/asyncActionLegacy.js +0 -59
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -227
- package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.d.ts +0 -25
- package/lib/chevre/repo/mongoose/schemas/pendingReservationAggregate.js +0 -100
- package/lib/chevre/repo/ownershipInfo.d.ts +0 -122
- package/lib/chevre/repo/ownershipInfo.js +0 -466
- package/lib/chevre/repo/scheduledTaskLegacy.d.ts +0 -19
- package/lib/chevre/repo/scheduledTaskLegacy.js +0 -42
- package/lib/chevre/repo/scheduledTaskMigration.d.ts +0 -21
- package/lib/chevre/repo/scheduledTaskMigration.js +0 -70
- package/lib/chevre/service/validation/validateEvent.d.ts +0 -11
- package/lib/chevre/service/validation/validateEvent.js +0 -21
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.AssetTransactionRepo = void 0;
|
|
7
|
-
const moment_1 = __importDefault(require("moment"));
|
|
8
4
|
const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
|
|
9
5
|
const factory_1 = require("../factory");
|
|
10
6
|
const assetTransaction_2 = require("../eventEmitter/assetTransaction");
|
|
@@ -13,7 +9,6 @@ const settings_1 = require("../settings");
|
|
|
13
9
|
* 資産取引リポジトリ
|
|
14
10
|
*/
|
|
15
11
|
class AssetTransactionRepo {
|
|
16
|
-
// private化(2022-06-08~)
|
|
17
12
|
transactionModel;
|
|
18
13
|
constructor(connection) {
|
|
19
14
|
this.transactionModel = connection.model(assetTransaction_1.modelName, (0, assetTransaction_1.createSchema)());
|
|
@@ -28,36 +23,6 @@ class AssetTransactionRepo {
|
|
|
28
23
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
29
24
|
}
|
|
30
25
|
/* istanbul ignore else */
|
|
31
|
-
if (params.startFrom !== undefined) {
|
|
32
|
-
andConditions.push({
|
|
33
|
-
startDate: { $gte: params.startFrom }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/* istanbul ignore else */
|
|
37
|
-
if (params.startThrough !== undefined) {
|
|
38
|
-
andConditions.push({
|
|
39
|
-
startDate: { $lte: params.startThrough }
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/* istanbul ignore else */
|
|
43
|
-
if (params.endFrom !== undefined) {
|
|
44
|
-
andConditions.push({
|
|
45
|
-
endDate: {
|
|
46
|
-
$exists: true,
|
|
47
|
-
$gte: params.endFrom
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/* istanbul ignore else */
|
|
52
|
-
if (params.endThrough !== undefined) {
|
|
53
|
-
andConditions.push({
|
|
54
|
-
endDate: {
|
|
55
|
-
$exists: true,
|
|
56
|
-
$lt: params.endThrough
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/* istanbul ignore else */
|
|
61
26
|
if (Array.isArray(params.ids)) {
|
|
62
27
|
andConditions.push({
|
|
63
28
|
_id: { $in: params.ids }
|
|
@@ -72,14 +37,6 @@ class AssetTransactionRepo {
|
|
|
72
37
|
if (Array.isArray(statusIn)) {
|
|
73
38
|
andConditions.push({ status: { $in: statusIn } });
|
|
74
39
|
}
|
|
75
|
-
/* istanbul ignore else */
|
|
76
|
-
if (params.agent !== undefined) {
|
|
77
|
-
if (Array.isArray(params.agent.ids)) {
|
|
78
|
-
andConditions.push({
|
|
79
|
-
'agent.id': { $in: params.agent.ids }
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
40
|
const transactionNumberEq = params.transactionNumber?.$eq;
|
|
84
41
|
if (typeof transactionNumberEq === 'string') {
|
|
85
42
|
andConditions.push({ transactionNumber: { $eq: transactionNumberEq } });
|
|
@@ -88,16 +45,6 @@ class AssetTransactionRepo {
|
|
|
88
45
|
if (Array.isArray(transactionNumberIn)) {
|
|
89
46
|
andConditions.push({ transactionNumber: { $in: transactionNumberIn } });
|
|
90
47
|
}
|
|
91
|
-
const tasksExportActionStatusIn = params.tasksExportAction?.actionStatus?.$in;
|
|
92
|
-
/* istanbul ignore else */
|
|
93
|
-
if (Array.isArray(tasksExportActionStatusIn)) {
|
|
94
|
-
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $in: tasksExportActionStatusIn } });
|
|
95
|
-
}
|
|
96
|
-
const tasksExportActionStatusEq = params.tasksExportAction?.actionStatus?.$eq;
|
|
97
|
-
/* istanbul ignore else */
|
|
98
|
-
if (typeof tasksExportActionStatusEq === 'string') {
|
|
99
|
-
andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
|
|
100
|
-
}
|
|
101
48
|
switch (params.typeOf) {
|
|
102
49
|
case factory_1.factory.assetTransactionType.Pay: {
|
|
103
50
|
const objectAccountIdEq = params.object?.accountId?.$eq;
|
|
@@ -134,36 +81,6 @@ class AssetTransactionRepo {
|
|
|
134
81
|
}
|
|
135
82
|
break;
|
|
136
83
|
}
|
|
137
|
-
// case factory.assetTransactionType.MoneyTransfer: {
|
|
138
|
-
// const fromLocationIdentifierEq = params.object?.fromLocation?.identifier?.$eq;
|
|
139
|
-
// if (typeof fromLocationIdentifierEq === 'string') {
|
|
140
|
-
// andConditions.push({
|
|
141
|
-
// 'object.fromLocation.identifier': {
|
|
142
|
-
// $exists: true,
|
|
143
|
-
// $eq: fromLocationIdentifierEq
|
|
144
|
-
// }
|
|
145
|
-
// });
|
|
146
|
-
// }
|
|
147
|
-
// const toLocationIdentifierEq = params.object?.toLocation?.identifier?.$eq;
|
|
148
|
-
// if (typeof toLocationIdentifierEq === 'string') {
|
|
149
|
-
// andConditions.push({
|
|
150
|
-
// 'object.toLocation.identifier': {
|
|
151
|
-
// $exists: true,
|
|
152
|
-
// $eq: toLocationIdentifierEq
|
|
153
|
-
// }
|
|
154
|
-
// });
|
|
155
|
-
// }
|
|
156
|
-
// const pendingTransactionIdentifierEq = params.object?.pendingTransaction?.identifier?.$eq;
|
|
157
|
-
// if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
158
|
-
// andConditions.push({
|
|
159
|
-
// 'object.pendingTransaction.identifier': {
|
|
160
|
-
// $exists: true,
|
|
161
|
-
// $eq: pendingTransactionIdentifierEq
|
|
162
|
-
// }
|
|
163
|
-
// });
|
|
164
|
-
// }
|
|
165
|
-
// break;
|
|
166
|
-
// }
|
|
167
84
|
case factory_1.factory.assetTransactionType.CancelReservation: {
|
|
168
85
|
const objectReservationNumberIn4cancelReservation = params.object?.reservationNumber?.$in;
|
|
169
86
|
if (Array.isArray(objectReservationNumberIn4cancelReservation)) {
|
|
@@ -180,10 +97,11 @@ class AssetTransactionRepo {
|
|
|
180
97
|
break;
|
|
181
98
|
}
|
|
182
99
|
case factory_1.factory.assetTransactionType.Reserve: {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
100
|
+
// discontinue(2026-08-10~)
|
|
101
|
+
// const objectProviderIdEq = params.object?.provider?.id?.$eq;
|
|
102
|
+
// if (typeof objectProviderIdEq === 'string') {
|
|
103
|
+
// andConditions.push({ 'object.provider.id': { $exists: true, $eq: objectProviderIdEq } });
|
|
104
|
+
// }
|
|
187
105
|
const objectReservationForIdEq = params.object?.reservationFor?.id?.$eq;
|
|
188
106
|
if (typeof objectReservationForIdEq === 'string') {
|
|
189
107
|
andConditions.push({
|
|
@@ -216,39 +134,42 @@ class AssetTransactionRepo {
|
|
|
216
134
|
}
|
|
217
135
|
if (params.object !== undefined) {
|
|
218
136
|
if (params.object.reservations !== undefined) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
137
|
+
// discontinue(2026-08-10~)
|
|
138
|
+
// if (params.object.reservations.reservationNumber !== undefined) {
|
|
139
|
+
// if (Array.isArray(params.object.reservations.reservationNumber.$in)) {
|
|
140
|
+
// andConditions.push({
|
|
141
|
+
// 'object.subReservation.reservationNumber': {
|
|
142
|
+
// $exists: true,
|
|
143
|
+
// $in: params.object.reservations.reservationNumber.$in
|
|
144
|
+
// }
|
|
145
|
+
// });
|
|
146
|
+
// }
|
|
147
|
+
// }
|
|
148
|
+
// discontinue(2026-08-10~)
|
|
149
|
+
// if (params.object.reservations.reservationFor !== undefined) {
|
|
150
|
+
// if (params.object.reservations.reservationFor.id !== undefined) {
|
|
151
|
+
// if (Array.isArray(params.object.reservations.reservationFor.id.$in)) {
|
|
152
|
+
// andConditions.push({
|
|
153
|
+
// 'object.subReservation.reservationFor.id': {
|
|
154
|
+
// $exists: true,
|
|
155
|
+
// $in: params.object.reservations.reservationFor.id.$in
|
|
156
|
+
// }
|
|
157
|
+
// });
|
|
158
|
+
// }
|
|
159
|
+
// }
|
|
160
|
+
// }
|
|
241
161
|
}
|
|
242
162
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
163
|
+
// discontinue(2026-08-10~)
|
|
164
|
+
// const objectUnderNameIdEq = params.object?.underName?.id?.$eq;
|
|
165
|
+
// if (typeof objectUnderNameIdEq === 'string') {
|
|
166
|
+
// andConditions.push({
|
|
167
|
+
// 'object.underName.id': {
|
|
168
|
+
// $exists: true,
|
|
169
|
+
// $eq: objectUnderNameIdEq
|
|
170
|
+
// }
|
|
171
|
+
// });
|
|
172
|
+
// }
|
|
252
173
|
const objectSubReservationSeatNumberEq = params.object?.reservations?.reservedTicket?.ticketedSeat?.seatNumber?.$eq;
|
|
253
174
|
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
254
175
|
andConditions.push({
|
|
@@ -260,27 +181,6 @@ class AssetTransactionRepo {
|
|
|
260
181
|
}
|
|
261
182
|
break;
|
|
262
183
|
}
|
|
263
|
-
// case factory.assetTransactionType.RegisterService: {
|
|
264
|
-
// const objectItemOfferedServiceOutputIdentifierEq = params.object?.itemOffered?.serviceOutput?.identifier?.$eq;
|
|
265
|
-
// if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
266
|
-
// andConditions.push({
|
|
267
|
-
// 'object.itemOffered.serviceOutput.identifier': {
|
|
268
|
-
// $exists: true,
|
|
269
|
-
// $eq: objectItemOfferedServiceOutputIdentifierEq
|
|
270
|
-
// }
|
|
271
|
-
// });
|
|
272
|
-
// }
|
|
273
|
-
// const objectItemOfferedServiceOutputIdentifierIn = params.object?.itemOffered?.serviceOutput?.identifier?.$in;
|
|
274
|
-
// if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
275
|
-
// andConditions.push({
|
|
276
|
-
// 'object.itemOffered.serviceOutput.identifier': {
|
|
277
|
-
// $exists: true,
|
|
278
|
-
// $in: objectItemOfferedServiceOutputIdentifierIn
|
|
279
|
-
// }
|
|
280
|
-
// });
|
|
281
|
-
// }
|
|
282
|
-
// break;
|
|
283
|
-
// }
|
|
284
184
|
default:
|
|
285
185
|
}
|
|
286
186
|
return andConditions;
|
|
@@ -456,33 +356,6 @@ class AssetTransactionRepo {
|
|
|
456
356
|
});
|
|
457
357
|
return { id: params.id };
|
|
458
358
|
}
|
|
459
|
-
async countPotentiallyExportTasks(params) {
|
|
460
|
-
const { endDate, limit } = params;
|
|
461
|
-
const endDateLt = endDate?.$lt;
|
|
462
|
-
if (!(endDateLt instanceof Date)) {
|
|
463
|
-
throw new factory_1.factory.errors.Argument('endDate.$lt', 'must be Date');
|
|
464
|
-
}
|
|
465
|
-
const query = this.transactionModel.countDocuments({
|
|
466
|
-
status: {
|
|
467
|
-
$in: [
|
|
468
|
-
factory_1.factory.transactionStatusType.Canceled,
|
|
469
|
-
factory_1.factory.transactionStatusType.Confirmed,
|
|
470
|
-
factory_1.factory.transactionStatusType.Expired
|
|
471
|
-
]
|
|
472
|
-
},
|
|
473
|
-
'tasksExportAction.actionStatus': {
|
|
474
|
-
$exists: true,
|
|
475
|
-
$eq: factory_1.factory.actionStatusType.PotentialActionStatus
|
|
476
|
-
},
|
|
477
|
-
endDate: { $exists: true, $lt: endDateLt }
|
|
478
|
-
});
|
|
479
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
480
|
-
query.limit(limit);
|
|
481
|
-
}
|
|
482
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
483
|
-
.exec();
|
|
484
|
-
return { count };
|
|
485
|
-
}
|
|
486
359
|
/**
|
|
487
360
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
488
361
|
*/
|
|
@@ -541,123 +414,6 @@ class AssetTransactionRepo {
|
|
|
541
414
|
.exec()
|
|
542
415
|
.then((doc) => (doc === null) ? null : doc);
|
|
543
416
|
}
|
|
544
|
-
// discontinue(2025-03-10~)
|
|
545
|
-
// public async reexportTasksByExportAction(params: {
|
|
546
|
-
// intervalInMinutes: number;
|
|
547
|
-
// limit: number;
|
|
548
|
-
// }): Promise<void> {
|
|
549
|
-
// const reexportingTransactions: Pick<
|
|
550
|
-
// factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'status' | 'typeOf'
|
|
551
|
-
// >[] = await this.transactionModel.find(
|
|
552
|
-
// {
|
|
553
|
-
// 'tasksExportAction.actionStatus': {
|
|
554
|
-
// $exists: true,
|
|
555
|
-
// $eq: factory.actionStatusType.ActiveActionStatus
|
|
556
|
-
// },
|
|
557
|
-
// 'tasksExportAction.startDate': {
|
|
558
|
-
// $exists: true,
|
|
559
|
-
// $lt: moment()
|
|
560
|
-
// .add(-params.intervalInMinutes, 'minutes')
|
|
561
|
-
// .toDate()
|
|
562
|
-
// }
|
|
563
|
-
// },
|
|
564
|
-
// { _id: 1, typeOf: 1, status: 1 }
|
|
565
|
-
// )
|
|
566
|
-
// .limit(params.limit)
|
|
567
|
-
// .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
568
|
-
// .exec();
|
|
569
|
-
// if (reexportingTransactions.length > 0) {
|
|
570
|
-
// for (const reexportingTransaction of reexportingTransactions) {
|
|
571
|
-
// await this.transactionModel.updateOne(
|
|
572
|
-
// {
|
|
573
|
-
// _id: { $eq: reexportingTransaction.id },
|
|
574
|
-
// 'tasksExportAction.actionStatus': {
|
|
575
|
-
// $exists: true,
|
|
576
|
-
// $eq: factory.actionStatusType.ActiveActionStatus
|
|
577
|
-
// }
|
|
578
|
-
// },
|
|
579
|
-
// {
|
|
580
|
-
// tasksExportAction: {
|
|
581
|
-
// actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
582
|
-
// }
|
|
583
|
-
// // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported // discontinue(2024-06-20~)
|
|
584
|
-
// }
|
|
585
|
-
// )
|
|
586
|
-
// .exec();
|
|
587
|
-
// assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
588
|
-
// id: reexportingTransaction.id,
|
|
589
|
-
// typeOf: reexportingTransaction.typeOf,
|
|
590
|
-
// status: reexportingTransaction.status
|
|
591
|
-
// });
|
|
592
|
-
// }
|
|
593
|
-
// }
|
|
594
|
-
// }
|
|
595
|
-
/**
|
|
596
|
-
* tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について
|
|
597
|
-
* PotentialActionStatusに変更する
|
|
598
|
-
* 2025-03-10~
|
|
599
|
-
*/
|
|
600
|
-
async reExportAction(params) {
|
|
601
|
-
const { startDate } = params;
|
|
602
|
-
if (!(startDate.$lt instanceof Date)) {
|
|
603
|
-
throw new factory_1.factory.errors.Argument('startDate.$lt', 'must be Date');
|
|
604
|
-
}
|
|
605
|
-
return this.transactionModel.updateMany({
|
|
606
|
-
'tasksExportAction.actionStatus': {
|
|
607
|
-
$exists: true,
|
|
608
|
-
$eq: factory_1.factory.actionStatusType.ActiveActionStatus
|
|
609
|
-
},
|
|
610
|
-
'tasksExportAction.startDate': {
|
|
611
|
-
$exists: true,
|
|
612
|
-
$lt: startDate.$lt
|
|
613
|
-
}
|
|
614
|
-
}, {
|
|
615
|
-
$set: {
|
|
616
|
-
tasksExportAction: {
|
|
617
|
-
actionStatus: factory_1.factory.actionStatusType.PotentialActionStatus
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
})
|
|
621
|
-
.exec();
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
625
|
-
*/
|
|
626
|
-
async exportTasksMany(params) {
|
|
627
|
-
const delayedTransactions = await this.transactionModel.find({
|
|
628
|
-
status: { $in: params.status.$in },
|
|
629
|
-
'tasksExportAction.actionStatus': {
|
|
630
|
-
$exists: true,
|
|
631
|
-
$eq: factory_1.factory.actionStatusType.PotentialActionStatus
|
|
632
|
-
},
|
|
633
|
-
endDate: {
|
|
634
|
-
$exists: true,
|
|
635
|
-
$lt: (0, moment_1.default)(params.now)
|
|
636
|
-
.add(-params.delayInSeconds, 'seconds')
|
|
637
|
-
.toDate()
|
|
638
|
-
}
|
|
639
|
-
})
|
|
640
|
-
.select({
|
|
641
|
-
_id: 0,
|
|
642
|
-
id: { $toString: '$_id' },
|
|
643
|
-
typeOf: 1,
|
|
644
|
-
status: 1
|
|
645
|
-
})
|
|
646
|
-
.limit(params.limit)
|
|
647
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
648
|
-
.lean()
|
|
649
|
-
.exec();
|
|
650
|
-
if (delayedTransactions.length > 0) {
|
|
651
|
-
delayedTransactions.forEach((delayedTransaction) => {
|
|
652
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
653
|
-
id: delayedTransaction.id,
|
|
654
|
-
typeOf: delayedTransaction.typeOf,
|
|
655
|
-
status: delayedTransaction.status
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
return delayedTransactions;
|
|
660
|
-
}
|
|
661
417
|
/**
|
|
662
418
|
* set task status exported by transaction id
|
|
663
419
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -680,95 +436,6 @@ class AssetTransactionRepo {
|
|
|
680
436
|
})
|
|
681
437
|
.exec();
|
|
682
438
|
}
|
|
683
|
-
/**
|
|
684
|
-
* add(2025-03-17~)
|
|
685
|
-
*/
|
|
686
|
-
async countPotentiallyExpired(params) {
|
|
687
|
-
const { expires, limit } = params;
|
|
688
|
-
const query = this.transactionModel.countDocuments({
|
|
689
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress },
|
|
690
|
-
expires: { $lt: expires.$lt }
|
|
691
|
-
});
|
|
692
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
693
|
-
query.limit(limit);
|
|
694
|
-
}
|
|
695
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
696
|
-
.exec();
|
|
697
|
-
return { count };
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* add(2025-03-12~)
|
|
701
|
-
*/
|
|
702
|
-
async makeOneExpiredIfExists(params) {
|
|
703
|
-
const endDate = new Date();
|
|
704
|
-
const sort = {
|
|
705
|
-
expires: factory_1.factory.sortType.Ascending
|
|
706
|
-
};
|
|
707
|
-
const doc = await this.transactionModel.findOneAndUpdate({
|
|
708
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress },
|
|
709
|
-
expires: { $lt: params.expires.$lt }
|
|
710
|
-
}, {
|
|
711
|
-
status: factory_1.factory.transactionStatusType.Expired,
|
|
712
|
-
endDate
|
|
713
|
-
}, {
|
|
714
|
-
new: true,
|
|
715
|
-
projection: {
|
|
716
|
-
_id: 0,
|
|
717
|
-
id: { $toString: '$_id' },
|
|
718
|
-
typeOf: 1
|
|
719
|
-
}
|
|
720
|
-
})
|
|
721
|
-
.sort(sort)
|
|
722
|
-
.lean()
|
|
723
|
-
.exec();
|
|
724
|
-
if (doc === null) {
|
|
725
|
-
// no op
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
else {
|
|
729
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
730
|
-
id: doc.id,
|
|
731
|
-
typeOf: doc.typeOf,
|
|
732
|
-
status: factory_1.factory.transactionStatusType.Expired
|
|
733
|
-
});
|
|
734
|
-
return doc;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* 取引を期限切れにする
|
|
739
|
-
*/
|
|
740
|
-
async makeExpired(params) {
|
|
741
|
-
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
742
|
-
const expiringTransactions = await this.transactionModel.find({
|
|
743
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress },
|
|
744
|
-
expires: { $lt: params.expires.$lt }
|
|
745
|
-
})
|
|
746
|
-
.select({
|
|
747
|
-
_id: 1,
|
|
748
|
-
typeOf: 1
|
|
749
|
-
})
|
|
750
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
751
|
-
.exec();
|
|
752
|
-
if (expiringTransactions.length > 0) {
|
|
753
|
-
// ステータスと期限を見て更新
|
|
754
|
-
await this.transactionModel.updateMany({
|
|
755
|
-
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
756
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress },
|
|
757
|
-
expires: { $lt: params.expires.$lt }
|
|
758
|
-
}, {
|
|
759
|
-
status: factory_1.factory.transactionStatusType.Expired,
|
|
760
|
-
endDate: new Date()
|
|
761
|
-
})
|
|
762
|
-
.exec();
|
|
763
|
-
expiringTransactions.forEach((expiringTransaction) => {
|
|
764
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
765
|
-
id: expiringTransaction.id,
|
|
766
|
-
typeOf: expiringTransaction.typeOf,
|
|
767
|
-
status: factory_1.factory.transactionStatusType.Expired
|
|
768
|
-
});
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
439
|
/**
|
|
773
440
|
* 取引を中止する
|
|
774
441
|
*/
|
|
@@ -831,21 +498,10 @@ class AssetTransactionRepo {
|
|
|
831
498
|
});
|
|
832
499
|
return result;
|
|
833
500
|
}
|
|
834
|
-
async count(params) {
|
|
835
|
-
const { limit } = params;
|
|
836
|
-
const conditions = AssetTransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
837
|
-
const query = this.transactionModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {});
|
|
838
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
839
|
-
query.limit(limit);
|
|
840
|
-
}
|
|
841
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
842
|
-
.exec();
|
|
843
|
-
return { count };
|
|
844
|
-
}
|
|
845
501
|
/**
|
|
846
502
|
* 取引を検索する
|
|
847
503
|
*/
|
|
848
|
-
async
|
|
504
|
+
async findAssetTransactionsByTypeOf(params, inclusion) {
|
|
849
505
|
const conditions = AssetTransactionRepo.CREATE_MONGO_CONDITIONS(params);
|
|
850
506
|
let projection = {};
|
|
851
507
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
@@ -859,11 +515,11 @@ class AssetTransactionRepo {
|
|
|
859
515
|
createdAt: 0,
|
|
860
516
|
updatedAt: 0
|
|
861
517
|
};
|
|
862
|
-
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
518
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
519
|
+
// exclusion.forEach((field) => {
|
|
520
|
+
// projection[field] = 0;
|
|
521
|
+
// });
|
|
522
|
+
// }
|
|
867
523
|
}
|
|
868
524
|
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
869
525
|
.select(projection);
|
|
@@ -872,10 +528,9 @@ class AssetTransactionRepo {
|
|
|
872
528
|
query.limit(params.limit)
|
|
873
529
|
.skip(params.limit * (page - 1));
|
|
874
530
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}
|
|
531
|
+
// if (params.sort?.startDate !== undefined) {
|
|
532
|
+
// query.sort({ startDate: params.sort.startDate });
|
|
533
|
+
// }
|
|
879
534
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
880
535
|
.exec()
|
|
881
536
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
@@ -900,248 +555,5 @@ class AssetTransactionRepo {
|
|
|
900
555
|
})
|
|
901
556
|
.exec();
|
|
902
557
|
}
|
|
903
|
-
/**
|
|
904
|
-
* 終了日時を一定期間過ぎたアクションを削除する
|
|
905
|
-
*/
|
|
906
|
-
async deleteEndDatePassedCertainPeriod(params) {
|
|
907
|
-
return this.transactionModel.deleteMany({
|
|
908
|
-
// 終了日時を一定期間過ぎたもの
|
|
909
|
-
endDate: {
|
|
910
|
-
$exists: true,
|
|
911
|
-
$lt: params.$lt
|
|
912
|
-
}
|
|
913
|
-
})
|
|
914
|
-
.exec();
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* 特定の取引を更新する(汎用)
|
|
918
|
-
*/
|
|
919
|
-
async findByIdAndUpdateInProgress(params) {
|
|
920
|
-
return this.transactionModel.findOneAndUpdate({
|
|
921
|
-
_id: { $eq: params.id },
|
|
922
|
-
status: { $eq: factory_1.factory.transactionStatusType.InProgress }
|
|
923
|
-
}, params.update, { new: true })
|
|
924
|
-
.exec()
|
|
925
|
-
.then((doc) => {
|
|
926
|
-
if (doc === null) {
|
|
927
|
-
throw new factory_1.factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
928
|
-
}
|
|
929
|
-
return doc.toObject();
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* 互換性維持対応
|
|
934
|
-
*/
|
|
935
|
-
async migrateObjectReservationNumber(params) {
|
|
936
|
-
return this.transactionModel.findOneAndUpdate({
|
|
937
|
-
typeOf: { $eq: factory_1.factory.assetTransactionType.CancelReservation },
|
|
938
|
-
_id: { $eq: params.id }
|
|
939
|
-
}, {
|
|
940
|
-
$set: {
|
|
941
|
-
'object.reservationNumber': params.object.reservationNumber,
|
|
942
|
-
'object.typeOf': factory_1.factory.reservationType.ReservationPackage
|
|
943
|
-
}
|
|
944
|
-
}, {
|
|
945
|
-
timestamps: false,
|
|
946
|
-
new: true,
|
|
947
|
-
projection: { _id: 1 }
|
|
948
|
-
})
|
|
949
|
-
.exec()
|
|
950
|
-
.then((doc) => {
|
|
951
|
-
if (doc === null) {
|
|
952
|
-
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName);
|
|
953
|
-
}
|
|
954
|
-
return doc.toObject();
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* 互換性維持対応専用
|
|
959
|
-
*/
|
|
960
|
-
async fixReservedTicketIdentifier(params) {
|
|
961
|
-
const doc = await this.transactionModel.findOneAndUpdate({
|
|
962
|
-
transactionNumber: { $eq: params.transactionNumber },
|
|
963
|
-
'project.id': { $eq: params.project.id },
|
|
964
|
-
typeOf: { $eq: factory_1.factory.assetTransactionType.Pay }
|
|
965
|
-
}, {
|
|
966
|
-
$set: {
|
|
967
|
-
'object.paymentMethod.movieTickets': params.object.paymentMethod.movieTickets
|
|
968
|
-
}
|
|
969
|
-
}, {
|
|
970
|
-
timestamps: false,
|
|
971
|
-
new: true,
|
|
972
|
-
projection: {
|
|
973
|
-
_id: 1
|
|
974
|
-
}
|
|
975
|
-
})
|
|
976
|
-
.exec();
|
|
977
|
-
if (doc === null) {
|
|
978
|
-
throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
async findByIdAndDelete(params) {
|
|
982
|
-
await this.transactionModel.findByIdAndDelete(params.id)
|
|
983
|
-
.exec();
|
|
984
|
-
}
|
|
985
|
-
getCursor(conditions, projection) {
|
|
986
|
-
return this.transactionModel.find(conditions, projection)
|
|
987
|
-
// .sort({ startDate: factory.sortType.Ascending })
|
|
988
|
-
.sort({ startDate: factory_1.factory.sortType.Descending })
|
|
989
|
-
.cursor();
|
|
990
|
-
}
|
|
991
|
-
async unsetUnnecessaryFields(params) {
|
|
992
|
-
return this.transactionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
993
|
-
.exec();
|
|
994
|
-
}
|
|
995
|
-
async aggregateAssetTransaction(params) {
|
|
996
|
-
const statuses = await Promise.all([
|
|
997
|
-
factory_1.factory.transactionStatusType.Confirmed,
|
|
998
|
-
factory_1.factory.transactionStatusType.Canceled,
|
|
999
|
-
factory_1.factory.transactionStatusType.Expired
|
|
1000
|
-
].map(async (transactionStatus) => {
|
|
1001
|
-
const matchConditions = {
|
|
1002
|
-
startDate: {
|
|
1003
|
-
$gte: params.startFrom,
|
|
1004
|
-
$lte: params.startThrough
|
|
1005
|
-
},
|
|
1006
|
-
typeOf: { $eq: params.typeOf },
|
|
1007
|
-
status: { $eq: transactionStatus },
|
|
1008
|
-
...(typeof params.project?.id?.$ne === 'string')
|
|
1009
|
-
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
1010
|
-
: undefined,
|
|
1011
|
-
...(typeof params.project?.id?.$eq === 'string')
|
|
1012
|
-
? { 'project.id': { $eq: params.project.id.$eq } }
|
|
1013
|
-
: undefined
|
|
1014
|
-
};
|
|
1015
|
-
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
1016
|
-
}));
|
|
1017
|
-
return { statuses };
|
|
1018
|
-
}
|
|
1019
|
-
async agggregateByStatus(params) {
|
|
1020
|
-
const matchConditions = params.matchConditions;
|
|
1021
|
-
const transactionStatus = params.status;
|
|
1022
|
-
const aggregations = await this.transactionModel.aggregate([
|
|
1023
|
-
{
|
|
1024
|
-
$match: matchConditions
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
$project: {
|
|
1028
|
-
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1029
|
-
graceTime: {
|
|
1030
|
-
$cond: {
|
|
1031
|
-
if: { $eq: ['$typeOf', factory_1.factory.assetTransactionType.Reserve] },
|
|
1032
|
-
then: { $subtract: ['$object.reservationFor.startDate', '$startDate'] },
|
|
1033
|
-
else: 0
|
|
1034
|
-
}
|
|
1035
|
-
},
|
|
1036
|
-
status: '$status',
|
|
1037
|
-
startDate: '$startDate',
|
|
1038
|
-
endDate: '$endDate',
|
|
1039
|
-
typeOf: '$typeOf',
|
|
1040
|
-
reservationCount: {
|
|
1041
|
-
$cond: {
|
|
1042
|
-
if: { $isArray: '$object.subReservation' },
|
|
1043
|
-
then: { $size: '$object.subReservation' },
|
|
1044
|
-
else: 0
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
{
|
|
1050
|
-
$group: {
|
|
1051
|
-
_id: '$typeOf',
|
|
1052
|
-
transactionCount: { $sum: 1 },
|
|
1053
|
-
maxDuration: { $max: '$duration' },
|
|
1054
|
-
minDuration: { $min: '$duration' },
|
|
1055
|
-
avgDuration: { $avg: '$duration' },
|
|
1056
|
-
reservationCount: { $sum: '$reservationCount' },
|
|
1057
|
-
maxGraceTime: { $max: '$graceTime' },
|
|
1058
|
-
minGraceTime: { $min: '$graceTime' },
|
|
1059
|
-
avgGraceTime: { $avg: '$graceTime' }
|
|
1060
|
-
}
|
|
1061
|
-
},
|
|
1062
|
-
{
|
|
1063
|
-
$project: {
|
|
1064
|
-
_id: 0,
|
|
1065
|
-
transactionCount: '$transactionCount',
|
|
1066
|
-
avgDuration: '$avgDuration',
|
|
1067
|
-
maxDuration: '$maxDuration',
|
|
1068
|
-
minDuration: '$minDuration',
|
|
1069
|
-
reservationCount: '$reservationCount',
|
|
1070
|
-
avgGraceTime: '$avgGraceTime',
|
|
1071
|
-
maxGraceTime: '$maxGraceTime',
|
|
1072
|
-
minGraceTime: '$minGraceTime'
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
])
|
|
1076
|
-
.exec();
|
|
1077
|
-
const percents = [50, 95, 99];
|
|
1078
|
-
if (aggregations.length === 0) {
|
|
1079
|
-
return {
|
|
1080
|
-
status: transactionStatus,
|
|
1081
|
-
aggregation: {
|
|
1082
|
-
transactionCount: 0,
|
|
1083
|
-
avgDuration: 0,
|
|
1084
|
-
maxDuration: 0,
|
|
1085
|
-
minDuration: 0,
|
|
1086
|
-
percentilesDuration: percents.map((percent) => {
|
|
1087
|
-
return {
|
|
1088
|
-
name: String(percent),
|
|
1089
|
-
value: 0
|
|
1090
|
-
};
|
|
1091
|
-
}),
|
|
1092
|
-
reservationCount: 0,
|
|
1093
|
-
avgGraceTime: 0,
|
|
1094
|
-
maxGraceTime: 0,
|
|
1095
|
-
minGraceTime: 0
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
const ranks4percentile = percents.map((percentile) => {
|
|
1100
|
-
return {
|
|
1101
|
-
percentile,
|
|
1102
|
-
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
1103
|
-
};
|
|
1104
|
-
});
|
|
1105
|
-
const aggregations2 = await this.transactionModel.aggregate([
|
|
1106
|
-
{
|
|
1107
|
-
$match: matchConditions
|
|
1108
|
-
},
|
|
1109
|
-
{
|
|
1110
|
-
$project: {
|
|
1111
|
-
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
1112
|
-
status: '$status',
|
|
1113
|
-
startDate: '$startDate',
|
|
1114
|
-
endDate: '$endDate',
|
|
1115
|
-
typeOf: '$typeOf'
|
|
1116
|
-
}
|
|
1117
|
-
},
|
|
1118
|
-
{ $sort: { duration: 1 } },
|
|
1119
|
-
{
|
|
1120
|
-
$group: {
|
|
1121
|
-
_id: '$typeOf',
|
|
1122
|
-
durations: { $push: '$duration' }
|
|
1123
|
-
}
|
|
1124
|
-
},
|
|
1125
|
-
{
|
|
1126
|
-
$project: {
|
|
1127
|
-
_id: 0,
|
|
1128
|
-
percentilesDuration: ranks4percentile.map((rank) => {
|
|
1129
|
-
return {
|
|
1130
|
-
name: String(rank.percentile),
|
|
1131
|
-
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
1132
|
-
};
|
|
1133
|
-
})
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
])
|
|
1137
|
-
.exec();
|
|
1138
|
-
return {
|
|
1139
|
-
status: transactionStatus,
|
|
1140
|
-
aggregation: {
|
|
1141
|
-
...aggregations[0],
|
|
1142
|
-
...aggregations2[0]
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
558
|
}
|
|
1147
559
|
exports.AssetTransactionRepo = AssetTransactionRepo;
|