@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
package/lib/chevre/repo/task.js
CHANGED
|
@@ -1,45 +1,10 @@
|
|
|
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.TaskRepo = void 0;
|
|
7
|
-
const moment_1 = __importDefault(require("moment"));
|
|
8
4
|
const errorHandler_1 = require("../errorHandler");
|
|
9
5
|
const task_1 = require("../eventEmitter/task");
|
|
10
6
|
const factory_1 = require("../factory");
|
|
11
|
-
const settings_1 = require("../settings");
|
|
12
7
|
const task_2 = require("./mongoose/schemas/task");
|
|
13
|
-
const executableTaskProjection = {
|
|
14
|
-
_id: 0,
|
|
15
|
-
id: { $toString: '$_id' },
|
|
16
|
-
// 必要最低限にprojection(2024-04-23~)
|
|
17
|
-
data: 1,
|
|
18
|
-
name: 1,
|
|
19
|
-
status: 1,
|
|
20
|
-
numberOfTried: 1,
|
|
21
|
-
project: 1,
|
|
22
|
-
remainingNumberOfTries: 1,
|
|
23
|
-
runsAt: 1,
|
|
24
|
-
expires: 1
|
|
25
|
-
};
|
|
26
|
-
const AVAILABLE_PROJECT_FIELDS = [
|
|
27
|
-
'alternateName',
|
|
28
|
-
'identifier',
|
|
29
|
-
'description',
|
|
30
|
-
'project',
|
|
31
|
-
'name',
|
|
32
|
-
'status',
|
|
33
|
-
'runsAt',
|
|
34
|
-
'remainingNumberOfTries',
|
|
35
|
-
'lastTriedAt',
|
|
36
|
-
'numberOfTried',
|
|
37
|
-
'executionResults',
|
|
38
|
-
'executor',
|
|
39
|
-
'data',
|
|
40
|
-
'dateAborted',
|
|
41
|
-
'expires'
|
|
42
|
-
];
|
|
43
8
|
/**
|
|
44
9
|
* タスクリポジトリ
|
|
45
10
|
*/
|
|
@@ -50,7 +15,6 @@ class TaskRepo {
|
|
|
50
15
|
}
|
|
51
16
|
async saveMany(taskAttributes) {
|
|
52
17
|
const emitImmediately = true; // always true(2026-07-30~)
|
|
53
|
-
// const emitImmediately = options?.emitImmediately === true;
|
|
54
18
|
if (taskAttributes.length > 0) {
|
|
55
19
|
const creatingTasks = taskAttributes.map(({ identifier, ...creatingTask }) => creatingTask); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
56
20
|
const result = await this.taskModel.insertMany(creatingTasks, { ordered: false, rawResult: true });
|
|
@@ -68,14 +32,7 @@ class TaskRepo {
|
|
|
68
32
|
status: factory_1.factory.taskStatus.Ready
|
|
69
33
|
});
|
|
70
34
|
});
|
|
71
|
-
// taskAttributes.forEach((savedTask) => {
|
|
72
|
-
// taskEventEmitter.emitTaskStatusChanged({
|
|
73
|
-
// name: savedTask.name,
|
|
74
|
-
// status: factory.taskStatus.Ready
|
|
75
|
-
// });
|
|
76
|
-
// });
|
|
77
35
|
}
|
|
78
|
-
// return result.ops;
|
|
79
36
|
return savedTasks;
|
|
80
37
|
}
|
|
81
38
|
else {
|
|
@@ -104,6 +61,19 @@ class TaskRepo {
|
|
|
104
61
|
const { id, status } = doc;
|
|
105
62
|
return { id, status };
|
|
106
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* イベント予約集計タスクの冗長な作成を避けるためのメソッド
|
|
66
|
+
*/
|
|
67
|
+
async findReadyAggregateEventTask(params) {
|
|
68
|
+
return this.taskModel.findOne({
|
|
69
|
+
'project.id': { $eq: params.project.id },
|
|
70
|
+
name: { $eq: factory_1.factory.taskName.AggregateScreeningEvent },
|
|
71
|
+
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
72
|
+
'data.id': { $exists: true, $eq: params.reservationFor.id }
|
|
73
|
+
}, { _id: 1 })
|
|
74
|
+
.lean()
|
|
75
|
+
.exec();
|
|
76
|
+
}
|
|
107
77
|
/**
|
|
108
78
|
* タスク識別子から冪等作成する
|
|
109
79
|
* reimplement createIfNotExistByIdentifier(2025-03-28~)
|
|
@@ -114,12 +84,6 @@ class TaskRepo {
|
|
|
114
84
|
if (typeof params.identifier !== 'string' || params.identifier.length === 0) {
|
|
115
85
|
throw new factory_1.factory.errors.ArgumentNull('identifier');
|
|
116
86
|
}
|
|
117
|
-
if (typeof params.alternateName !== 'string' || params.alternateName.length === 0) {
|
|
118
|
-
throw new factory_1.factory.errors.ArgumentNull('alternateName');
|
|
119
|
-
}
|
|
120
|
-
if (params.identifier !== params.alternateName) {
|
|
121
|
-
throw new factory_1.factory.errors.Argument('identifier,alternateName not matched');
|
|
122
|
-
}
|
|
123
87
|
let createdTask;
|
|
124
88
|
const filterQuery = {
|
|
125
89
|
'project.id': { $eq: params.project.id },
|
|
@@ -165,311 +129,6 @@ class TaskRepo {
|
|
|
165
129
|
throw new factory_1.factory.errors.Internal(`falied in creating a task unexpectedly. ${params.identifier}`);
|
|
166
130
|
}
|
|
167
131
|
}
|
|
168
|
-
// /**
|
|
169
|
-
// * 取引削除タスク冪等作成
|
|
170
|
-
// */
|
|
171
|
-
// public async createDeleteTransactionTaskIfNotExist(
|
|
172
|
-
// // resolve uniqueness of identifier(2025-03-27~)
|
|
173
|
-
// params: Pick<
|
|
174
|
-
// factory.task.IAttributes<factory.taskName.DeleteTransaction>,
|
|
175
|
-
// 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status'
|
|
176
|
-
// >,
|
|
177
|
-
// options: IOptionOnCreate
|
|
178
|
-
// ): Promise<void> {
|
|
179
|
-
// if (params.data.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
|
|
180
|
-
// throw new factory.errors.NotImplemented(`only ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
|
|
181
|
-
// }
|
|
182
|
-
// const createdTask = await this.taskModel.findOneAndUpdate(
|
|
183
|
-
// {
|
|
184
|
-
// 'project.id': { $eq: params.project.id },
|
|
185
|
-
// name: { $eq: params.name },
|
|
186
|
-
// 'data.object.id': { $exists: true, $eq: params.data.object.id }
|
|
187
|
-
// },
|
|
188
|
-
// { $setOnInsert: params },
|
|
189
|
-
// { new: true, upsert: true }
|
|
190
|
-
// )
|
|
191
|
-
// .select({ _id: 1 })
|
|
192
|
-
// .exec();
|
|
193
|
-
// if (options.emitImmediately) {
|
|
194
|
-
// taskEventEmitter.emitTaskStatusChanged({
|
|
195
|
-
// id: createdTask.id,
|
|
196
|
-
// name: params.name,
|
|
197
|
-
// status: factory.taskStatus.Ready
|
|
198
|
-
// });
|
|
199
|
-
// }
|
|
200
|
-
// }
|
|
201
|
-
async createOnAssetTransactionStatusChangedTaskIfNotExist(params) {
|
|
202
|
-
const emitImmediately = true; // always true(2026-07-30~)
|
|
203
|
-
const createdTask = await this.taskModel.findOneAndUpdate({
|
|
204
|
-
'project.id': { $eq: params.project.id },
|
|
205
|
-
name: { $eq: params.name },
|
|
206
|
-
'data.object.transactionNumber': {
|
|
207
|
-
$exists: true,
|
|
208
|
-
$eq: String(params.data.object.transactionNumber)
|
|
209
|
-
},
|
|
210
|
-
'data.purpose.orderNumber': {
|
|
211
|
-
$exists: true,
|
|
212
|
-
$eq: String(params.data.purpose.orderNumber)
|
|
213
|
-
}
|
|
214
|
-
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
215
|
-
.select({ _id: 1 })
|
|
216
|
-
.exec();
|
|
217
|
-
if (emitImmediately) {
|
|
218
|
-
task_1.taskEventEmitter.emitTaskStatusChanged({
|
|
219
|
-
id: createdTask.id,
|
|
220
|
-
name: params.name,
|
|
221
|
-
status: factory_1.factory.taskStatus.Ready
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Ready -> remainingNumberOfTriesが1減る
|
|
227
|
-
* Running -> findOneするだけ
|
|
228
|
-
*/
|
|
229
|
-
async executeOneById(params) {
|
|
230
|
-
const now = new Date();
|
|
231
|
-
let doc;
|
|
232
|
-
if (params.status === factory_1.factory.taskStatus.Running) {
|
|
233
|
-
doc = await this.taskModel.findOne({
|
|
234
|
-
_id: { $eq: params.id },
|
|
235
|
-
status: { $eq: params.status },
|
|
236
|
-
runsAt: { $lt: now },
|
|
237
|
-
...(params.expires instanceof Date) ? { expires: { $gt: now } } : undefined
|
|
238
|
-
}, executableTaskProjection)
|
|
239
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
240
|
-
.lean()
|
|
241
|
-
.exec();
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
doc = await this.taskModel.findOneAndUpdate({
|
|
245
|
-
_id: { $eq: params.id },
|
|
246
|
-
status: { $eq: params.status },
|
|
247
|
-
runsAt: { $lt: now },
|
|
248
|
-
...(params.expires instanceof Date) ? { expires: { $gt: now } } : undefined
|
|
249
|
-
}, {
|
|
250
|
-
$set: {
|
|
251
|
-
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
252
|
-
lastTriedAt: now,
|
|
253
|
-
executor: params.executor
|
|
254
|
-
},
|
|
255
|
-
$inc: {
|
|
256
|
-
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
257
|
-
numberOfTried: 1 // トライ回数増やす
|
|
258
|
-
}
|
|
259
|
-
}, { new: true, projection: executableTaskProjection })
|
|
260
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
261
|
-
.lean() // lean(2024-09-26~)
|
|
262
|
-
.exec();
|
|
263
|
-
}
|
|
264
|
-
if (doc === null) {
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
return doc;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Readyのタスクをname指定でひとつRunningに変更する
|
|
271
|
-
*/
|
|
272
|
-
async executeOneIfExists(params) {
|
|
273
|
-
if (!(params.runsAt.$lt instanceof Date)) {
|
|
274
|
-
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
275
|
-
}
|
|
276
|
-
const nameEq = params.name?.$eq;
|
|
277
|
-
// const nameNin = params.name?.$nin;
|
|
278
|
-
const doc = await this.taskModel.findOneAndUpdate({
|
|
279
|
-
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
280
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
281
|
-
...(typeof nameEq === 'string')
|
|
282
|
-
? {
|
|
283
|
-
name: {
|
|
284
|
-
...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined
|
|
285
|
-
// ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
: undefined
|
|
289
|
-
}, {
|
|
290
|
-
$set: {
|
|
291
|
-
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
292
|
-
lastTriedAt: new Date(),
|
|
293
|
-
executor: params.executor
|
|
294
|
-
},
|
|
295
|
-
$inc: {
|
|
296
|
-
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
297
|
-
numberOfTried: 1 // トライ回数増やす
|
|
298
|
-
}
|
|
299
|
-
}, {
|
|
300
|
-
new: true,
|
|
301
|
-
projection: executableTaskProjection,
|
|
302
|
-
...(typeof params.sort.numberOfTried === 'number' || typeof params.sort.runsAt === 'number')
|
|
303
|
-
? { sort: params.sort }
|
|
304
|
-
: undefined
|
|
305
|
-
})
|
|
306
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
307
|
-
.lean() // lean(2024-09-26~)
|
|
308
|
-
.exec();
|
|
309
|
-
if (doc === null) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
return doc;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* add(2025-03-16~)
|
|
316
|
-
*/
|
|
317
|
-
async countPotentiallyRunning(params) {
|
|
318
|
-
const { runsAt, limit, name } = params;
|
|
319
|
-
const nameEq = name?.$eq;
|
|
320
|
-
// const nameNin = name?.$nin;
|
|
321
|
-
const nameIn = name?.$in;
|
|
322
|
-
if (!(runsAt.$lt instanceof Date)) {
|
|
323
|
-
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
324
|
-
}
|
|
325
|
-
const query = this.taskModel.countDocuments({
|
|
326
|
-
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
327
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
328
|
-
...(typeof nameEq === 'string' || Array.isArray(nameIn))
|
|
329
|
-
? {
|
|
330
|
-
name: {
|
|
331
|
-
...(typeof nameEq === 'string') ? { $eq: nameEq } : undefined,
|
|
332
|
-
// ...(Array.isArray(nameNin)) ? { $nin: nameNin } : undefined,
|
|
333
|
-
...(Array.isArray(nameIn)) ? { $in: nameIn } : undefined
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
: undefined
|
|
337
|
-
});
|
|
338
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
339
|
-
query.limit(limit);
|
|
340
|
-
}
|
|
341
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
342
|
-
.exec();
|
|
343
|
-
return { count };
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* 実行日時を一定期間過ぎたReadyタスクについて、Runningスタータスに変更した上で、Runningイベントを発生させる
|
|
347
|
-
*/
|
|
348
|
-
async emitRunningIfExists(params) {
|
|
349
|
-
if (!(params.runsAt.$lt instanceof Date)) {
|
|
350
|
-
throw new factory_1.factory.errors.Argument('runsAt.$lt', 'must be Date');
|
|
351
|
-
}
|
|
352
|
-
const projection = {
|
|
353
|
-
_id: 0,
|
|
354
|
-
id: { $toString: '$_id' },
|
|
355
|
-
name: 1
|
|
356
|
-
};
|
|
357
|
-
const nameEq = params.name?.$eq;
|
|
358
|
-
// const nameNin = params.name?.$nin;
|
|
359
|
-
// const nameIn = params.name?.$in;
|
|
360
|
-
const { nameFilterBeforeRunsAt } = params;
|
|
361
|
-
const filter = {
|
|
362
|
-
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
363
|
-
...(nameFilterBeforeRunsAt) ? { name: params.name } : undefined,
|
|
364
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
365
|
-
...(!nameFilterBeforeRunsAt) ? { name: params.name } : undefined
|
|
366
|
-
};
|
|
367
|
-
const doc = await this.taskModel.findOneAndUpdate(filter, {
|
|
368
|
-
$set: {
|
|
369
|
-
status: factory_1.factory.taskStatus.Running, // 実行中に変更
|
|
370
|
-
lastTriedAt: new Date(),
|
|
371
|
-
executor: params.executor
|
|
372
|
-
},
|
|
373
|
-
$inc: {
|
|
374
|
-
remainingNumberOfTries: -1, // 残りトライ可能回数減らす
|
|
375
|
-
numberOfTried: 1 // トライ回数増やす
|
|
376
|
-
}
|
|
377
|
-
}, {
|
|
378
|
-
new: true,
|
|
379
|
-
projection,
|
|
380
|
-
...(typeof params.sort.numberOfTried === 'number' || typeof params.sort.runsAt === 'number')
|
|
381
|
-
? { sort: params.sort }
|
|
382
|
-
: undefined
|
|
383
|
-
})
|
|
384
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
385
|
-
.lean()
|
|
386
|
-
.exec();
|
|
387
|
-
if (doc === null) {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
let changedTask;
|
|
391
|
-
if (typeof nameEq === 'string') {
|
|
392
|
-
changedTask = {
|
|
393
|
-
id: doc.id,
|
|
394
|
-
status: factory_1.factory.taskStatus.Running,
|
|
395
|
-
name: nameEq
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
changedTask = {
|
|
400
|
-
id: doc.id,
|
|
401
|
-
status: factory_1.factory.taskStatus.Running
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask);
|
|
405
|
-
return doc;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Runningのまま一定期間超過し、かつ、remainingNumberOfTries>0のタスクをReadyに変更する
|
|
409
|
-
*/
|
|
410
|
-
async retryTasks(params) {
|
|
411
|
-
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
412
|
-
.add(-params.intervalInMinutes, 'minutes')
|
|
413
|
-
.toDate();
|
|
414
|
-
// const remainingNumberOfTriesGte = params.remainingNumberOfTries.$gte;
|
|
415
|
-
// const remainingNumberOfTriesLte = params.remainingNumberOfTries.$lte;
|
|
416
|
-
return this.taskModel.updateMany(
|
|
417
|
-
// name: 'retry'のindexと連動しているので、条件の順序などには注意すること
|
|
418
|
-
// @see schemas/task
|
|
419
|
-
{
|
|
420
|
-
status: { $eq: factory_1.factory.taskStatus.Running },
|
|
421
|
-
lastTriedAt: {
|
|
422
|
-
$type: 'date',
|
|
423
|
-
$lt: lastTriedAtShoudBeLessThan
|
|
424
|
-
},
|
|
425
|
-
remainingNumberOfTries: { $gte: 1 },
|
|
426
|
-
// ...(typeof remainingNumberOfTriesGte === 'number')
|
|
427
|
-
// ? { remainingNumberOfTries: { $gte: remainingNumberOfTriesGte } }
|
|
428
|
-
// : undefined,
|
|
429
|
-
// ...(typeof remainingNumberOfTriesLte === 'number')
|
|
430
|
-
// ? { remainingNumberOfTries: { $lte: remainingNumberOfTriesLte } }
|
|
431
|
-
// : undefined,
|
|
432
|
-
// ...(Array.isArray(params.name.$in)) ? { name: { $in: params.name.$in } } : undefined
|
|
433
|
-
}, {
|
|
434
|
-
$set: {
|
|
435
|
-
status: factory_1.factory.taskStatus.Ready // 実行前に変更
|
|
436
|
-
}
|
|
437
|
-
})
|
|
438
|
-
.exec();
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* $lte:0をReadyにする(特定のタスクを除いて) -> Readyにすれば自動的にAbortedになる
|
|
442
|
-
*/
|
|
443
|
-
async retryAbortingTasksByName(params) {
|
|
444
|
-
const lastTriedAtShoudBeLessThan = (0, moment_1.default)()
|
|
445
|
-
.add(-params.intervalInMinutes, 'minutes')
|
|
446
|
-
.toDate();
|
|
447
|
-
// const remainingNumberOfTriesGte = params.remainingNumberOfTries.$gte;
|
|
448
|
-
// const remainingNumberOfTriesLte = params.remainingNumberOfTries.$lte;
|
|
449
|
-
return this.taskModel.updateMany(
|
|
450
|
-
// name: 'retry'のindexと連動しているので、条件の順序などには注意すること
|
|
451
|
-
// @see schemas/task
|
|
452
|
-
{
|
|
453
|
-
status: { $eq: factory_1.factory.taskStatus.Running },
|
|
454
|
-
lastTriedAt: {
|
|
455
|
-
$type: 'date',
|
|
456
|
-
$lt: lastTriedAtShoudBeLessThan
|
|
457
|
-
},
|
|
458
|
-
remainingNumberOfTries: { $lte: 0 },
|
|
459
|
-
// ...(typeof remainingNumberOfTriesGte === 'number')
|
|
460
|
-
// ? { remainingNumberOfTries: { $gte: remainingNumberOfTriesGte } }
|
|
461
|
-
// : undefined,
|
|
462
|
-
// ...(typeof remainingNumberOfTriesLte === 'number')
|
|
463
|
-
// ? { remainingNumberOfTries: { $lte: remainingNumberOfTriesLte } }
|
|
464
|
-
// : undefined,
|
|
465
|
-
...(Array.isArray(params.name.$in)) ? { name: { $in: params.name.$in } } : undefined
|
|
466
|
-
}, {
|
|
467
|
-
$set: {
|
|
468
|
-
status: factory_1.factory.taskStatus.Ready // 実行前に変更
|
|
469
|
-
}
|
|
470
|
-
})
|
|
471
|
-
.exec();
|
|
472
|
-
}
|
|
473
132
|
/**
|
|
474
133
|
* 実行中止済タスクを強制的にリトライ
|
|
475
134
|
* 中止済タスクでなければ何もしない
|
|
@@ -488,97 +147,5 @@ class TaskRepo {
|
|
|
488
147
|
})
|
|
489
148
|
.exec();
|
|
490
149
|
}
|
|
491
|
-
/**
|
|
492
|
-
* タスクIDから実行結果とステータスを保管する
|
|
493
|
-
* Abortedの場合、dateAbortedもセットする
|
|
494
|
-
*/
|
|
495
|
-
async setExecutionResultAndStatus(params, update,
|
|
496
|
-
// support customr function(2025-05-25~)
|
|
497
|
-
next) {
|
|
498
|
-
const { id, remainingNumberOfTries, name } = params;
|
|
499
|
-
const { status, executionResult } = update;
|
|
500
|
-
await this.taskModel.updateOne({ _id: { $eq: id } }, {
|
|
501
|
-
$set: {
|
|
502
|
-
status,
|
|
503
|
-
...(status === factory_1.factory.taskStatus.Aborted) ? { dateAborted: executionResult.endDate } : undefined // 2025-08-04~
|
|
504
|
-
},
|
|
505
|
-
$push: { executionResults: executionResult }
|
|
506
|
-
})
|
|
507
|
-
.exec();
|
|
508
|
-
// emit event(2025-05-26~)
|
|
509
|
-
if (typeof next === 'function') {
|
|
510
|
-
const changedTask = { id, name, status, remainingNumberOfTries, executionResult };
|
|
511
|
-
task_1.taskEventEmitter.emitTaskStatusChanged(changedTask, next);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* タスクの状態を参照する
|
|
516
|
-
* 非同期アクション移行が完了したら廃止する(2026-07-29~)
|
|
517
|
-
*/
|
|
518
|
-
async findTaskById(params, inclusion) {
|
|
519
|
-
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
520
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
521
|
-
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
// no op
|
|
525
|
-
}
|
|
526
|
-
const projection = {
|
|
527
|
-
_id: 0,
|
|
528
|
-
id: { $toString: '$_id' },
|
|
529
|
-
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
530
|
-
};
|
|
531
|
-
const query = this.taskModel.findOne({
|
|
532
|
-
_id: { $eq: params.id.$eq },
|
|
533
|
-
'project.id': { $eq: params.project.id.$eq },
|
|
534
|
-
name: { $eq: params.name }
|
|
535
|
-
}, projection);
|
|
536
|
-
const doc = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
537
|
-
.lean()
|
|
538
|
-
.exec();
|
|
539
|
-
if (doc === null) {
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
return doc;
|
|
543
|
-
}
|
|
544
|
-
async deleteByProject(params) {
|
|
545
|
-
await this.taskModel.deleteMany({
|
|
546
|
-
'project.id': { $eq: params.project.id }
|
|
547
|
-
})
|
|
548
|
-
.exec();
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* 不要なタスクを削除する
|
|
552
|
-
*/
|
|
553
|
-
async deleteRunsAtPassedCertainPeriod(params) {
|
|
554
|
-
return this.taskModel.deleteMany({
|
|
555
|
-
runsAt: { $lt: params.runsAt.$lt },
|
|
556
|
-
status: {
|
|
557
|
-
$in: [
|
|
558
|
-
factory_1.factory.taskStatus.Aborted,
|
|
559
|
-
factory_1.factory.taskStatus.Executed,
|
|
560
|
-
factory_1.factory.taskStatus.Expired
|
|
561
|
-
]
|
|
562
|
-
}
|
|
563
|
-
})
|
|
564
|
-
.exec();
|
|
565
|
-
}
|
|
566
|
-
async countDelayedTasks(params) {
|
|
567
|
-
const { limit } = params;
|
|
568
|
-
const runsAtLt = (0, moment_1.default)()
|
|
569
|
-
.add(-params.delayInSeconds, 'seconds')
|
|
570
|
-
.toDate();
|
|
571
|
-
const query = this.taskModel.countDocuments({
|
|
572
|
-
status: { $eq: factory_1.factory.taskStatus.Ready },
|
|
573
|
-
runsAt: { $lt: runsAtLt },
|
|
574
|
-
...(Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined
|
|
575
|
-
});
|
|
576
|
-
if (typeof limit === 'number' && limit >= 0) {
|
|
577
|
-
query.limit(limit);
|
|
578
|
-
}
|
|
579
|
-
const count = await query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
580
|
-
.exec();
|
|
581
|
-
return { count };
|
|
582
|
-
}
|
|
583
150
|
}
|
|
584
151
|
exports.TaskRepo = TaskRepo;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Connection, UpdateWriteOpResult } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
/**
|
|
4
|
+
* 遅延タスクリポジトリ
|
|
5
|
+
*/
|
|
6
|
+
export declare class TaskDelayedRepo {
|
|
7
|
+
private readonly taskModel;
|
|
8
|
+
constructor(connection: Connection);
|
|
9
|
+
/**
|
|
10
|
+
* 潜在的に実行されるべきタスクをカウントする
|
|
11
|
+
* add(2025-03-16~)
|
|
12
|
+
*/
|
|
13
|
+
countPotentiallyRunning(params: {
|
|
14
|
+
name?: {
|
|
15
|
+
$eq?: factory.taskName;
|
|
16
|
+
$in?: factory.taskName[];
|
|
17
|
+
};
|
|
18
|
+
runsAt: {
|
|
19
|
+
$lt: Date;
|
|
20
|
+
};
|
|
21
|
+
limit: number;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
count: number;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更する
|
|
27
|
+
*/
|
|
28
|
+
private runDelayedTask;
|
|
29
|
+
/**
|
|
30
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
31
|
+
*/
|
|
32
|
+
runDelayedTaskIfExistsByName(params: {
|
|
33
|
+
/**
|
|
34
|
+
* 必ずタスク名指定で実行する
|
|
35
|
+
*/
|
|
36
|
+
name: {
|
|
37
|
+
$eq: factory.taskName;
|
|
38
|
+
$in?: never;
|
|
39
|
+
} | {
|
|
40
|
+
$eq?: never;
|
|
41
|
+
$in: factory.taskName[];
|
|
42
|
+
};
|
|
43
|
+
runsAt: {
|
|
44
|
+
$lt: Date;
|
|
45
|
+
};
|
|
46
|
+
executor: {
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
}): Promise<Pick<factory.task.ITask<factory.taskName>, 'id' | 'name'> | null>;
|
|
50
|
+
/**
|
|
51
|
+
* 実行日時を一定期間過ぎたReadyタスクについて、Runningステータスに変更した上で、Runningイベントを発生させる
|
|
52
|
+
* 2026-08-06~
|
|
53
|
+
*/
|
|
54
|
+
runDelayedTaskIfExists(params: {
|
|
55
|
+
runsAt: {
|
|
56
|
+
$lt: Date;
|
|
57
|
+
};
|
|
58
|
+
executor: {
|
|
59
|
+
name: string;
|
|
60
|
+
};
|
|
61
|
+
}): Promise<Pick<factory.task.ITask<factory.taskName>, 'id' | 'name'> | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Runningのまま一定期間超過し、かつ、remainingNumberOfTries>0のタスクをReadyに変更する
|
|
64
|
+
*/
|
|
65
|
+
retryTasks(params: {
|
|
66
|
+
intervalInMinutes: number;
|
|
67
|
+
}): Promise<UpdateWriteOpResult>;
|
|
68
|
+
/**
|
|
69
|
+
* $lte:0をReadyにする -> Readyにすれば自動的にAbortedになる
|
|
70
|
+
*/
|
|
71
|
+
retryAbortingTasks(params: {
|
|
72
|
+
intervalInMinutes: number;
|
|
73
|
+
}): Promise<UpdateWriteOpResult>;
|
|
74
|
+
}
|