@chevre/domain 21.2.0-alpha.13 → 21.2.0-alpha.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/aggregation/aggregateSystem.ts +85 -27
- package/example/src/chevre/countDelayedTasks.ts +7 -2
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/findMovieTheaterById.ts +40 -0
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/lockStockHolder.ts +5 -2
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- package/example/src/chevre/processReserve.ts +5 -2
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +34 -0
- package/example/src/chevre/searchActions.ts +33 -0
- package/example/src/chevre/searchEventSeats.ts +5 -2
- package/example/src/chevre/searchHoldReservations.ts +38 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchScreeningRooms.ts +23 -0
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/chevre/transaction/startExportTasks.ts +2 -1
- package/example/src/chevre/updateScreeningRoom.ts +41 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/example/src/playOnMoment.ts +24 -0
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +3 -2
- package/lib/chevre/repo/accountTransaction.d.ts +3 -1
- package/lib/chevre/repo/accountTransaction.js +3 -2
- package/lib/chevre/repo/action.d.ts +42 -2
- package/lib/chevre/repo/action.js +130 -57
- package/lib/chevre/repo/additionalProperty.js +2 -1
- package/lib/chevre/repo/aggregation.d.ts +3 -0
- package/lib/chevre/repo/aggregation.js +3 -0
- package/lib/chevre/repo/assetTransaction.d.ts +23 -8
- package/lib/chevre/repo/assetTransaction.js +253 -80
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +37 -25
- package/lib/chevre/repo/code.js +3 -2
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +22 -6
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +2 -4
- package/lib/chevre/repo/creativeWork.js +35 -12
- package/lib/chevre/repo/customer.js +2 -1
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +2 -1
- package/lib/chevre/repo/event.d.ts +27 -1
- package/lib/chevre/repo/event.js +67 -33
- package/lib/chevre/repo/member.js +4 -3
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
- package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +75 -0
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +51 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
- package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
- package/lib/chevre/repo/offer.js +3 -2
- package/lib/chevre/repo/offerCatalog.js +0 -27
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +121 -0
- package/lib/chevre/repo/order.d.ts +55 -3
- package/lib/chevre/repo/order.js +62 -10
- package/lib/chevre/repo/ownershipInfo.js +2 -7
- package/lib/chevre/repo/place.d.ts +20 -5
- package/lib/chevre/repo/place.js +63 -23
- package/lib/chevre/repo/priceSpecification.js +3 -2
- package/lib/chevre/repo/product.d.ts +1 -3
- package/lib/chevre/repo/product.js +25 -4
- package/lib/chevre/repo/project.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +20 -4
- package/lib/chevre/repo/reservation.js +40 -59
- package/lib/chevre/repo/role.js +3 -2
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +44 -23
- package/lib/chevre/repo/serviceOutput.js +2 -1
- package/lib/chevre/repo/stockHolder.d.ts +139 -7
- package/lib/chevre/repo/stockHolder.js +569 -102
- package/lib/chevre/repo/task.d.ts +45 -2
- package/lib/chevre/repo/task.js +94 -15
- package/lib/chevre/repo/transaction.d.ts +21 -2
- package/lib/chevre/repo/transaction.js +171 -50
- package/lib/chevre/repo/trip.js +2 -1
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +6 -2
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +8 -6
- package/lib/chevre/service/aggregation/system.d.ts +110 -23
- package/lib/chevre/service/aggregation/system.js +213 -91
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -24
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
- package/lib/chevre/service/assetTransaction/pay.js +20 -34
- package/lib/chevre/service/assetTransaction/refund.js +2 -24
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
- package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
- package/lib/chevre/service/assetTransaction/reserve.d.ts +10 -1
- package/lib/chevre/service/assetTransaction/reserve.js +92 -69
- package/lib/chevre/service/assetTransaction.d.ts +6 -0
- package/lib/chevre/service/assetTransaction.js +9 -4
- package/lib/chevre/service/event.js +25 -6
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize.js +8 -2
- package/lib/chevre/service/offer/event/factory.d.ts +3 -0
- package/lib/chevre/service/offer/event/factory.js +16 -5
- package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/offer.d.ts +16 -8
- package/lib/chevre/service/offer.js +71 -8
- package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -0
- package/lib/chevre/service/order/placeOrder.js +41 -24
- package/lib/chevre/service/order/returnOrder.d.ts +1 -0
- package/lib/chevre/service/order/returnOrder.js +7 -12
- package/lib/chevre/service/order/sendOrder.d.ts +1 -0
- package/lib/chevre/service/order/sendOrder.js +7 -10
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +9 -5
- package/lib/chevre/service/payment/any.js +80 -18
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +23 -17
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +8 -7
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +55 -32
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +7 -6
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
- package/lib/chevre/service/reserve/cancelReservation.js +162 -142
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
- package/lib/chevre/service/reserve/checkInReservation.js +77 -3
- package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
- package/lib/chevre/service/reserve/confirmReservation.js +133 -58
- package/lib/chevre/service/reserve/factory.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/useReservation.js +61 -71
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
- package/lib/chevre/service/reserve.d.ts +3 -2
- package/lib/chevre/service/reserve.js +4 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +6 -2
- package/lib/chevre/service/task/cancelReservation.js +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
- package/lib/chevre/service/task/onEventChanged.d.ts +7 -0
- package/lib/chevre/service/task/{deleteOrder.js → onEventChanged.js} +8 -14
- package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
- package/lib/chevre/service/task/onResourceUpdated.js +352 -0
- package/lib/chevre/service/task/placeOrder.js +1 -1
- package/lib/chevre/service/task/reserve.js +10 -7
- package/lib/chevre/service/task/returnOrder.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/sendOrder.js +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/useReservation.js +36 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +4 -2
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +10 -13
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +7 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +28 -15
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
- package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder.js +228 -36
- package/lib/chevre/service/transaction.d.ts +7 -13
- package/lib/chevre/service/transaction.js +12 -139
- package/lib/chevre/settings.d.ts +13 -1
- package/lib/chevre/settings.js +56 -6
- package/package.json +5 -5
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -205
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/example/src/chevre/migrateStockHolderKeys.ts +0 -89
- package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
- package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
- package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
|
@@ -64,13 +64,10 @@ export declare class MongoRepository {
|
|
|
64
64
|
typeOf: T;
|
|
65
65
|
transactionNumber: string;
|
|
66
66
|
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
67
|
-
/**
|
|
68
|
-
* 取引を確定する
|
|
69
|
-
*/
|
|
70
67
|
addReservations(params: {
|
|
71
68
|
typeOf: factory.assetTransactionType.Reserve;
|
|
72
69
|
id: string;
|
|
73
|
-
object: factory.assetTransaction.reserve.IObject
|
|
70
|
+
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'issuedThrough' | 'reservationFor' | 'subReservation'>;
|
|
74
71
|
}): Promise<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
|
|
75
72
|
/**
|
|
76
73
|
* 取引を確定する
|
|
@@ -78,9 +75,10 @@ export declare class MongoRepository {
|
|
|
78
75
|
confirm<T extends factory.assetTransactionType>(params: {
|
|
79
76
|
typeOf: T;
|
|
80
77
|
id: string;
|
|
78
|
+
object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'>;
|
|
81
79
|
result: factory.assetTransaction.IResult<T>;
|
|
82
80
|
potentialActions: factory.assetTransaction.IPotentialActions<T>;
|
|
83
|
-
}): Promise<
|
|
81
|
+
}): Promise<void>;
|
|
84
82
|
/**
|
|
85
83
|
* 取引を開始&確定
|
|
86
84
|
*/
|
|
@@ -101,6 +99,11 @@ export declare class MongoRepository {
|
|
|
101
99
|
};
|
|
102
100
|
status: factory.transactionStatusType;
|
|
103
101
|
id?: string;
|
|
102
|
+
tasksExportAction: {
|
|
103
|
+
agent: {
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
104
107
|
}): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
|
|
105
108
|
/**
|
|
106
109
|
* タスクエクスポートリトライ
|
|
@@ -109,6 +112,16 @@ export declare class MongoRepository {
|
|
|
109
112
|
reexportTasks(params: {
|
|
110
113
|
intervalInMinutes: number;
|
|
111
114
|
}): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
117
|
+
*/
|
|
118
|
+
exportTasks(params: {
|
|
119
|
+
now: Date;
|
|
120
|
+
delayInSeconds: number;
|
|
121
|
+
status: {
|
|
122
|
+
$in: factory.transactionStatusType[];
|
|
123
|
+
};
|
|
124
|
+
}): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction, "id" | "typeOf" | "status">[]>;
|
|
112
125
|
/**
|
|
113
126
|
* set task status exported by transaction id
|
|
114
127
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -120,7 +133,9 @@ export declare class MongoRepository {
|
|
|
120
133
|
* 取引を期限切れにする
|
|
121
134
|
*/
|
|
122
135
|
makeExpired(params: {
|
|
123
|
-
expires:
|
|
136
|
+
expires: {
|
|
137
|
+
$lt: Date;
|
|
138
|
+
};
|
|
124
139
|
}): Promise<void>;
|
|
125
140
|
/**
|
|
126
141
|
* 取引を中止する
|
|
@@ -134,7 +149,7 @@ export declare class MongoRepository {
|
|
|
134
149
|
/**
|
|
135
150
|
* 取引を検索する
|
|
136
151
|
*/
|
|
137
|
-
search<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>,
|
|
152
|
+
search<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>, inclusion?: string[], exclusion?: string[]): Promise<factory.assetTransaction.ITransaction<T>[]>;
|
|
138
153
|
/**
|
|
139
154
|
* 取引番号指定で削除する
|
|
140
155
|
*/
|
|
@@ -160,7 +175,7 @@ export declare class MongoRepository {
|
|
|
160
175
|
/**
|
|
161
176
|
* 特定の取引を更新する(汎用)
|
|
162
177
|
*/
|
|
163
|
-
|
|
178
|
+
findByIdAndUpdateInProgress<T extends factory.assetTransactionType>(params: {
|
|
164
179
|
id: string;
|
|
165
180
|
update: any;
|
|
166
181
|
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
@@ -13,6 +13,8 @@ exports.MongoRepository = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
|
|
15
15
|
const factory = require("../factory");
|
|
16
|
+
const assetTransaction_2 = require("../eventEmitter/assetTransaction");
|
|
17
|
+
const settings_1 = require("../settings");
|
|
16
18
|
/**
|
|
17
19
|
* 資産取引リポジトリ
|
|
18
20
|
*/
|
|
@@ -22,7 +24,7 @@ class MongoRepository {
|
|
|
22
24
|
}
|
|
23
25
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
26
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
26
28
|
const andConditions = [
|
|
27
29
|
{
|
|
28
30
|
typeOf: params.typeOf
|
|
@@ -132,15 +134,18 @@ class MongoRepository {
|
|
|
132
134
|
const objectPaymentMethodIdEq4refund = (_j = (_h = params.object) === null || _h === void 0 ? void 0 : _h.paymentMethodId) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
133
135
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
134
136
|
andConditions.push({
|
|
135
|
-
'object.paymentMethodId': {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const objectPaymentMethodIdIn4refund = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$in;
|
|
141
|
+
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
142
|
+
andConditions.push({
|
|
143
|
+
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
139
144
|
});
|
|
140
145
|
}
|
|
141
146
|
break;
|
|
142
147
|
case factory.assetTransactionType.MoneyTransfer:
|
|
143
|
-
const fromLocationIdentifierEq = (
|
|
148
|
+
const fromLocationIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.fromLocation) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
144
149
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
145
150
|
andConditions.push({
|
|
146
151
|
'object.fromLocation.identifier': {
|
|
@@ -149,7 +154,7 @@ class MongoRepository {
|
|
|
149
154
|
}
|
|
150
155
|
});
|
|
151
156
|
}
|
|
152
|
-
const toLocationIdentifierEq = (
|
|
157
|
+
const toLocationIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.toLocation) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
153
158
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
154
159
|
andConditions.push({
|
|
155
160
|
'object.toLocation.identifier': {
|
|
@@ -158,7 +163,7 @@ class MongoRepository {
|
|
|
158
163
|
}
|
|
159
164
|
});
|
|
160
165
|
}
|
|
161
|
-
const pendingTransactionIdentifierEq = (
|
|
166
|
+
const pendingTransactionIdentifierEq = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.pendingTransaction) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
162
167
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
163
168
|
andConditions.push({
|
|
164
169
|
'object.pendingTransaction.identifier': {
|
|
@@ -171,7 +176,25 @@ class MongoRepository {
|
|
|
171
176
|
case factory.assetTransactionType.CancelReservation:
|
|
172
177
|
break;
|
|
173
178
|
case factory.assetTransactionType.Reserve:
|
|
174
|
-
const
|
|
179
|
+
const objectReservationForIdEq = (_y = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationFor) === null || _x === void 0 ? void 0 : _x.id) === null || _y === void 0 ? void 0 : _y.$eq;
|
|
180
|
+
if (typeof objectReservationForIdEq === 'string') {
|
|
181
|
+
andConditions.push({
|
|
182
|
+
'object.reservationFor.id': {
|
|
183
|
+
$exists: true,
|
|
184
|
+
$eq: objectReservationForIdEq
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const objectReservationNumberIn = (_0 = (_z = params.object) === null || _z === void 0 ? void 0 : _z.reservationNumber) === null || _0 === void 0 ? void 0 : _0.$in;
|
|
189
|
+
if (Array.isArray(objectReservationNumberIn)) {
|
|
190
|
+
andConditions.push({
|
|
191
|
+
'object.reservationNumber': {
|
|
192
|
+
$exists: true,
|
|
193
|
+
$in: objectReservationNumberIn
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const objectReservationNumberEq = (_2 = (_1 = params.object) === null || _1 === void 0 ? void 0 : _1.reservationNumber) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
175
198
|
if (typeof objectReservationNumberEq === 'string') {
|
|
176
199
|
andConditions.push({
|
|
177
200
|
'object.reservationNumber': {
|
|
@@ -180,19 +203,17 @@ class MongoRepository {
|
|
|
180
203
|
}
|
|
181
204
|
});
|
|
182
205
|
}
|
|
206
|
+
const objectSubReservationIdIn = (_5 = (_4 = (_3 = params.object) === null || _3 === void 0 ? void 0 : _3.reservations) === null || _4 === void 0 ? void 0 : _4.id) === null || _5 === void 0 ? void 0 : _5.$in;
|
|
207
|
+
if (Array.isArray(objectSubReservationIdIn)) {
|
|
208
|
+
andConditions.push({
|
|
209
|
+
'object.subReservation.id': {
|
|
210
|
+
$exists: true,
|
|
211
|
+
$in: objectSubReservationIdIn
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
183
215
|
if (params.object !== undefined) {
|
|
184
216
|
if (params.object.reservations !== undefined) {
|
|
185
|
-
if (params.object.reservations.id !== undefined) {
|
|
186
|
-
if (Array.isArray(params.object.reservations.id.$in)) {
|
|
187
|
-
andConditions.push({
|
|
188
|
-
// 'object.reservations.id': {
|
|
189
|
-
'object.subReservation.id': {
|
|
190
|
-
$exists: true,
|
|
191
|
-
$in: params.object.reservations.id.$in
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
217
|
if (params.object.reservations.reservationNumber !== undefined) {
|
|
197
218
|
if (Array.isArray(params.object.reservations.reservationNumber.$in)) {
|
|
198
219
|
andConditions.push({
|
|
@@ -217,9 +238,27 @@ class MongoRepository {
|
|
|
217
238
|
}
|
|
218
239
|
}
|
|
219
240
|
}
|
|
241
|
+
const objectUnderNameIdEq = (_8 = (_7 = (_6 = params.object) === null || _6 === void 0 ? void 0 : _6.underName) === null || _7 === void 0 ? void 0 : _7.id) === null || _8 === void 0 ? void 0 : _8.$eq;
|
|
242
|
+
if (typeof objectUnderNameIdEq === 'string') {
|
|
243
|
+
andConditions.push({
|
|
244
|
+
'object.underName.id': {
|
|
245
|
+
$exists: true,
|
|
246
|
+
$eq: objectUnderNameIdEq
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const objectSubReservationSeatNumberEq = (_13 = (_12 = (_11 = (_10 = (_9 = params.object) === null || _9 === void 0 ? void 0 : _9.reservations) === null || _10 === void 0 ? void 0 : _10.reservedTicket) === null || _11 === void 0 ? void 0 : _11.ticketedSeat) === null || _12 === void 0 ? void 0 : _12.seatNumber) === null || _13 === void 0 ? void 0 : _13.$eq;
|
|
251
|
+
if (typeof objectSubReservationSeatNumberEq === 'string') {
|
|
252
|
+
andConditions.push({
|
|
253
|
+
'object.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
254
|
+
$exists: true,
|
|
255
|
+
$eq: objectSubReservationSeatNumberEq
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
220
259
|
break;
|
|
221
260
|
case factory.assetTransactionType.RegisterService:
|
|
222
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
261
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_17 = (_16 = (_15 = (_14 = params.object) === null || _14 === void 0 ? void 0 : _14.itemOffered) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.identifier) === null || _17 === void 0 ? void 0 : _17.$eq;
|
|
223
262
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
224
263
|
andConditions.push({
|
|
225
264
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -228,7 +267,7 @@ class MongoRepository {
|
|
|
228
267
|
}
|
|
229
268
|
});
|
|
230
269
|
}
|
|
231
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
270
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_21 = (_20 = (_19 = (_18 = params.object) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.identifier) === null || _21 === void 0 ? void 0 : _21.$in;
|
|
232
271
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
233
272
|
andConditions.push({
|
|
234
273
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -247,7 +286,9 @@ class MongoRepository {
|
|
|
247
286
|
*/
|
|
248
287
|
start(params) {
|
|
249
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined,
|
|
289
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
290
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
291
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
251
292
|
.then((doc) => doc.toObject());
|
|
252
293
|
});
|
|
253
294
|
}
|
|
@@ -277,26 +318,24 @@ class MongoRepository {
|
|
|
277
318
|
return doc.toObject();
|
|
278
319
|
});
|
|
279
320
|
}
|
|
280
|
-
/**
|
|
281
|
-
* 取引を確定する
|
|
282
|
-
*/
|
|
283
321
|
addReservations(params) {
|
|
322
|
+
var _a;
|
|
284
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
285
324
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
286
|
-
_id: params.id,
|
|
287
|
-
typeOf: params.typeOf,
|
|
288
|
-
status: factory.transactionStatusType.InProgress
|
|
289
|
-
}, {
|
|
290
|
-
'object.acceptedOffer': params.object.acceptedOffer,
|
|
325
|
+
_id: { $eq: params.id },
|
|
326
|
+
typeOf: { $eq: params.typeOf },
|
|
327
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
328
|
+
}, Object.assign({ 'object.acceptedOffer': params.object.acceptedOffer,
|
|
291
329
|
// 念のため残す(2021/10/14)が、そのうち削除
|
|
292
330
|
// 冗長なので削除(2021/10/19~)
|
|
293
331
|
// 'object.event': params.object.reservationFor,
|
|
294
|
-
'object.reservationFor': params.object.reservationFor,
|
|
332
|
+
'object.reservationFor': params.object.reservationFor,
|
|
295
333
|
// 念のため残す(2021/10/14)が、そのうち削除
|
|
296
334
|
// 冗長なので削除(2021/10/19~)
|
|
297
335
|
// 'object.reservations': params.object.subReservation,
|
|
298
|
-
'object.subReservation': params.object.subReservation
|
|
299
|
-
|
|
336
|
+
'object.subReservation': params.object.subReservation }, (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
337
|
+
? { 'object.issuedThrough': params.object.issuedThrough }
|
|
338
|
+
: undefined), { new: true })
|
|
300
339
|
.exec();
|
|
301
340
|
if (doc === null) {
|
|
302
341
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -308,36 +347,40 @@ class MongoRepository {
|
|
|
308
347
|
* 取引を確定する
|
|
309
348
|
*/
|
|
310
349
|
confirm(params) {
|
|
350
|
+
var _a, _b;
|
|
311
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
312
352
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
313
|
-
_id: params.id,
|
|
314
|
-
typeOf: params.typeOf,
|
|
315
|
-
status: factory.transactionStatusType.InProgress
|
|
316
|
-
}, {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
353
|
+
_id: { $eq: params.id },
|
|
354
|
+
typeOf: { $eq: params.typeOf },
|
|
355
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
356
|
+
}, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
357
|
+
? { 'object.underName': params.object.underName }
|
|
358
|
+
: undefined), {
|
|
359
|
+
new: true,
|
|
360
|
+
projection: { _id: 1 }
|
|
361
|
+
})
|
|
322
362
|
.exec();
|
|
323
363
|
// NotFoundであれば取引状態確認
|
|
324
364
|
if (doc === null) {
|
|
325
365
|
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
326
366
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
327
|
-
//
|
|
328
|
-
return transaction;
|
|
367
|
+
// すでに確定済の場合スルー
|
|
329
368
|
}
|
|
330
369
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
331
|
-
throw new factory.errors.Argument('Transaction id',
|
|
370
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
332
371
|
}
|
|
333
372
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
334
|
-
throw new factory.errors.Argument('Transaction id',
|
|
373
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
|
|
335
374
|
}
|
|
336
375
|
else {
|
|
337
376
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
338
377
|
}
|
|
339
378
|
}
|
|
340
|
-
|
|
379
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
380
|
+
id: params.id,
|
|
381
|
+
typeOf: params.typeOf,
|
|
382
|
+
status: factory.transactionStatusType.Confirmed
|
|
383
|
+
});
|
|
341
384
|
});
|
|
342
385
|
}
|
|
343
386
|
/**
|
|
@@ -345,8 +388,17 @@ class MongoRepository {
|
|
|
345
388
|
*/
|
|
346
389
|
startAndConfirm(params) {
|
|
347
390
|
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
-
|
|
391
|
+
const startDate = new Date();
|
|
392
|
+
const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
|
|
393
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
394
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
|
|
349
395
|
.then((doc) => doc.toObject());
|
|
396
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
397
|
+
id: params.id,
|
|
398
|
+
typeOf: params.typeOf,
|
|
399
|
+
status: factory.transactionStatusType.Confirmed
|
|
400
|
+
});
|
|
401
|
+
return confirmedTransaction;
|
|
350
402
|
});
|
|
351
403
|
}
|
|
352
404
|
/**
|
|
@@ -355,8 +407,19 @@ class MongoRepository {
|
|
|
355
407
|
startExportTasks(params) {
|
|
356
408
|
var _a, _b;
|
|
357
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
+
switch (params.status) {
|
|
411
|
+
case factory.transactionStatusType.InProgress:
|
|
412
|
+
throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
|
|
413
|
+
default:
|
|
414
|
+
// no op
|
|
415
|
+
}
|
|
358
416
|
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
359
|
-
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: params.status, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
417
|
+
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
418
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
419
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
420
|
+
'tasksExportAction.startDate': new Date(),
|
|
421
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
422
|
+
}, { new: true })
|
|
360
423
|
.select({
|
|
361
424
|
_id: 1,
|
|
362
425
|
typeOf: 1
|
|
@@ -373,17 +436,74 @@ class MongoRepository {
|
|
|
373
436
|
*/
|
|
374
437
|
reexportTasks(params) {
|
|
375
438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
376
|
-
yield this.transactionModel.
|
|
377
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
439
|
+
const reexportingTransactions = yield this.transactionModel.find({
|
|
440
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
378
441
|
updatedAt: {
|
|
379
442
|
$lt: moment()
|
|
380
443
|
.add(-params.intervalInMinutes, 'minutes')
|
|
381
444
|
.toDate()
|
|
382
445
|
}
|
|
383
|
-
}, {
|
|
384
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
385
446
|
})
|
|
447
|
+
.select({
|
|
448
|
+
_id: 1,
|
|
449
|
+
typeOf: 1,
|
|
450
|
+
status: 1
|
|
451
|
+
})
|
|
452
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
386
453
|
.exec();
|
|
454
|
+
if (reexportingTransactions.length > 0) {
|
|
455
|
+
for (const reexportingTransaction of reexportingTransactions) {
|
|
456
|
+
yield this.transactionModel.updateOne({
|
|
457
|
+
_id: { $eq: reexportingTransaction.id },
|
|
458
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
459
|
+
}, {
|
|
460
|
+
tasksExportAction: {
|
|
461
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
462
|
+
},
|
|
463
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
464
|
+
})
|
|
465
|
+
.exec();
|
|
466
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
467
|
+
id: reexportingTransaction.id,
|
|
468
|
+
typeOf: reexportingTransaction.typeOf,
|
|
469
|
+
status: reexportingTransaction.status
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
477
|
+
*/
|
|
478
|
+
exportTasks(params) {
|
|
479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
481
|
+
status: { $in: params.status.$in },
|
|
482
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
483
|
+
endDate: {
|
|
484
|
+
$exists: true,
|
|
485
|
+
$lt: moment(params.now)
|
|
486
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
487
|
+
.toDate()
|
|
488
|
+
}
|
|
489
|
+
})
|
|
490
|
+
.select({
|
|
491
|
+
_id: 1,
|
|
492
|
+
typeOf: 1,
|
|
493
|
+
status: 1
|
|
494
|
+
})
|
|
495
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
496
|
+
.exec();
|
|
497
|
+
if (delayedTransactions.length > 0) {
|
|
498
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
499
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
500
|
+
id: delayedTransaction.id,
|
|
501
|
+
typeOf: delayedTransaction.typeOf,
|
|
502
|
+
status: delayedTransaction.status
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return delayedTransactions;
|
|
387
507
|
});
|
|
388
508
|
}
|
|
389
509
|
/**
|
|
@@ -392,10 +512,15 @@ class MongoRepository {
|
|
|
392
512
|
*/
|
|
393
513
|
setTasksExportedById(params) {
|
|
394
514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
|
|
515
|
+
const endDate = new Date();
|
|
516
|
+
yield this.transactionModel.updateOne({
|
|
517
|
+
_id: { $eq: params.id },
|
|
518
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
519
|
+
}, {
|
|
396
520
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
397
|
-
tasksExportedAt:
|
|
398
|
-
|
|
521
|
+
tasksExportedAt: endDate,
|
|
522
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
523
|
+
'tasksExportAction.endDate': endDate
|
|
399
524
|
})
|
|
400
525
|
.exec();
|
|
401
526
|
});
|
|
@@ -405,15 +530,36 @@ class MongoRepository {
|
|
|
405
530
|
*/
|
|
406
531
|
makeExpired(params) {
|
|
407
532
|
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
-
//
|
|
409
|
-
yield this.transactionModel.
|
|
410
|
-
status: factory.transactionStatusType.InProgress,
|
|
411
|
-
expires: { $lt: params.expires }
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
533
|
+
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
534
|
+
const expiringTransactions = yield this.transactionModel.find({
|
|
535
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
536
|
+
expires: { $lt: params.expires.$lt }
|
|
537
|
+
})
|
|
538
|
+
.select({
|
|
539
|
+
_id: 1,
|
|
540
|
+
typeOf: 1
|
|
415
541
|
})
|
|
542
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
416
543
|
.exec();
|
|
544
|
+
if (expiringTransactions.length > 0) {
|
|
545
|
+
// ステータスと期限を見て更新
|
|
546
|
+
yield this.transactionModel.updateMany({
|
|
547
|
+
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
548
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
549
|
+
expires: { $lt: params.expires.$lt }
|
|
550
|
+
}, {
|
|
551
|
+
status: factory.transactionStatusType.Expired,
|
|
552
|
+
endDate: new Date()
|
|
553
|
+
})
|
|
554
|
+
.exec();
|
|
555
|
+
expiringTransactions.forEach((expiringTransaction) => {
|
|
556
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
557
|
+
id: expiringTransaction.id,
|
|
558
|
+
typeOf: expiringTransaction.typeOf,
|
|
559
|
+
status: factory.transactionStatusType.Expired
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
}
|
|
417
563
|
});
|
|
418
564
|
}
|
|
419
565
|
/**
|
|
@@ -421,19 +567,18 @@ class MongoRepository {
|
|
|
421
567
|
*/
|
|
422
568
|
cancel(params) {
|
|
423
569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
-
const endDate =
|
|
425
|
-
.toDate();
|
|
570
|
+
const endDate = new Date();
|
|
426
571
|
// 進行中ステータスの取引を中止する
|
|
427
|
-
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: params.typeOf }, (typeof params.id === 'string') ? { _id: params.id } : undefined), (typeof params.transactionNumber === 'string')
|
|
572
|
+
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
|
|
428
573
|
? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
|
|
429
|
-
: undefined), { status: factory.transactionStatusType.InProgress }), {
|
|
574
|
+
: undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
|
|
430
575
|
status: factory.transactionStatusType.Canceled,
|
|
431
576
|
endDate: endDate
|
|
432
577
|
}, { new: true })
|
|
433
578
|
.exec();
|
|
579
|
+
let transaction;
|
|
434
580
|
// NotFoundであれば取引状態確認
|
|
435
581
|
if (doc === null) {
|
|
436
|
-
let transaction;
|
|
437
582
|
if (typeof params.id === 'string') {
|
|
438
583
|
transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
439
584
|
}
|
|
@@ -447,39 +592,64 @@ class MongoRepository {
|
|
|
447
592
|
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
448
593
|
}
|
|
449
594
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
450
|
-
//
|
|
451
|
-
return transaction;
|
|
595
|
+
// すでに中止済の場合スルー
|
|
452
596
|
}
|
|
453
597
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
454
|
-
throw new factory.errors.Argument('Transaction id',
|
|
598
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
455
599
|
}
|
|
456
600
|
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
457
|
-
throw new factory.errors.Argument('Transaction id',
|
|
601
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
|
|
458
602
|
}
|
|
459
603
|
else {
|
|
460
604
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
461
605
|
}
|
|
462
606
|
}
|
|
463
|
-
|
|
607
|
+
else {
|
|
608
|
+
transaction = doc.toObject();
|
|
609
|
+
}
|
|
610
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
611
|
+
id: transaction.id,
|
|
612
|
+
typeOf: params.typeOf,
|
|
613
|
+
status: factory.transactionStatusType.Canceled
|
|
614
|
+
});
|
|
615
|
+
return transaction;
|
|
464
616
|
});
|
|
465
617
|
}
|
|
466
618
|
count(params) {
|
|
467
619
|
return __awaiter(this, void 0, void 0, function* () {
|
|
468
620
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
469
621
|
return this.transactionModel.countDocuments({ $and: conditions })
|
|
470
|
-
.setOptions({ maxTimeMS:
|
|
622
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
471
623
|
.exec();
|
|
472
624
|
});
|
|
473
625
|
}
|
|
474
626
|
/**
|
|
475
627
|
* 取引を検索する
|
|
476
628
|
*/
|
|
477
|
-
search(params,
|
|
629
|
+
search(params, inclusion, exclusion) {
|
|
478
630
|
var _a;
|
|
479
631
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
632
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
633
|
+
let projection = {};
|
|
634
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
635
|
+
inclusion.forEach((field) => {
|
|
636
|
+
projection[field] = 1;
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
projection = {
|
|
641
|
+
__v: 0,
|
|
642
|
+
createdAt: 0,
|
|
643
|
+
updatedAt: 0
|
|
644
|
+
};
|
|
645
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
646
|
+
exclusion.forEach((field) => {
|
|
647
|
+
projection[field] = 0;
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
481
651
|
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
482
|
-
.select(
|
|
652
|
+
.select(projection);
|
|
483
653
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
484
654
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
485
655
|
query.limit(params.limit)
|
|
@@ -490,7 +660,7 @@ class MongoRepository {
|
|
|
490
660
|
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.startDate) !== undefined) {
|
|
491
661
|
query.sort({ startDate: params.sort.startDate });
|
|
492
662
|
}
|
|
493
|
-
return query.setOptions({ maxTimeMS:
|
|
663
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
494
664
|
.exec()
|
|
495
665
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
496
666
|
});
|
|
@@ -522,9 +692,12 @@ class MongoRepository {
|
|
|
522
692
|
/**
|
|
523
693
|
* 特定の取引を更新する(汎用)
|
|
524
694
|
*/
|
|
525
|
-
|
|
695
|
+
findByIdAndUpdateInProgress(params) {
|
|
526
696
|
return __awaiter(this, void 0, void 0, function* () {
|
|
527
|
-
return this.transactionModel.findOneAndUpdate({
|
|
697
|
+
return this.transactionModel.findOneAndUpdate({
|
|
698
|
+
_id: { $eq: params.id },
|
|
699
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
700
|
+
}, params.update, { new: true })
|
|
528
701
|
.exec()
|
|
529
702
|
.then((doc) => {
|
|
530
703
|
if (doc === null) {
|
|
@@ -35,7 +35,7 @@ export declare class MongoRepository {
|
|
|
35
35
|
/**
|
|
36
36
|
* 検索
|
|
37
37
|
*/
|
|
38
|
-
search(params: factory.categoryCode.ISearchConditions): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
38
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
39
39
|
findById(params: {
|
|
40
40
|
id: string;
|
|
41
41
|
}): Promise<factory.categoryCode.ICategoryCode>;
|