@chevre/domain 21.2.0-alpha.8 → 21.2.0-alpha.81
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/aggregation/aggregateSystem.ts +58 -31
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/processReserve.ts +2 -1
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchSellers.ts +32 -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 +20 -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/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +1 -54
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +32 -25
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +237 -80
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -5
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +27 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- 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 +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -4
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +120 -0
- package/lib/chevre/repo/order.d.ts +52 -2
- package/lib/chevre/repo/order.js +52 -4
- package/lib/chevre/repo/reservation.d.ts +8 -4
- package/lib/chevre/repo/reservation.js +8 -42
- package/lib/chevre/repo/seller.js +19 -19
- package/lib/chevre/repo/task.d.ts +42 -2
- package/lib/chevre/repo/task.js +90 -9
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +174 -54
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.js +10 -25
- package/lib/chevre/service/assetTransaction/refund.js +1 -23
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -22
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -1
- package/lib/chevre/service/assetTransaction/reserve.js +35 -40
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- 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 +1 -0
- package/lib/chevre/service/offer/event/authorize.js +5 -2
- package/lib/chevre/service/offer/event/factory.d.ts +2 -0
- package/lib/chevre/service/offer/event/factory.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.js +1 -1
- 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 +0 -1
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +1 -48
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/placeOrder.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +1 -5
- package/lib/chevre/service/order/sendOrder.js +1 -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.js +60 -10
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.js +4 -3
- 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 +4 -2
- package/lib/chevre/service/reserve/cancelReservation.js +2 -4
- package/lib/chevre/service/reserve/checkInReservation.d.ts +0 -3
- package/lib/chevre/service/reserve/checkInReservation.js +24 -0
- package/lib/chevre/service/reserve/confirmReservation.d.ts +2 -0
- package/lib/chevre/service/reserve/confirmReservation.js +45 -9
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
- 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 +4 -3
- package/lib/chevre/service/reserve/useReservation.js +14 -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 +2 -1
- package/lib/chevre/service/reserve.js +3 -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 +101 -0
- package/lib/chevre/service/task/reserve.js +5 -6
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/{deleteOrder.js → useReservation.js} +11 -12
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- 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.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 +9 -12
- 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 +22 -11
- 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 +225 -35
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +15 -5
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- 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
|
@@ -10,58 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useReservation = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* 予約サービス
|
|
15
|
-
*/
|
|
16
13
|
const factory = require("../../factory");
|
|
17
|
-
const code_1 = require("../code");
|
|
18
|
-
// import { maskUnderName } from './factory';
|
|
19
14
|
const onReservationUsed_1 = require("./potentialActions/onReservationUsed");
|
|
20
|
-
|
|
21
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const payload = yield (0, code_1.verifyToken)({
|
|
23
|
-
project: params.project,
|
|
24
|
-
agent: params.agent,
|
|
25
|
-
token: params.token
|
|
26
|
-
})({});
|
|
27
|
-
switch (payload.typeOf) {
|
|
28
|
-
case factory.order.OrderType.Order:
|
|
29
|
-
// reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
|
|
30
|
-
const order = yield repos.order.findByOrderNumberAndReservationId({
|
|
31
|
-
orderNumber: payload.orderNumber,
|
|
32
|
-
reservationId: params.reservationId
|
|
33
|
-
});
|
|
34
|
-
// 注文検索
|
|
35
|
-
// const order: Pick<factory.order.IOrder, 'orderStatus' | 'acceptedOffers'> =
|
|
36
|
-
// await repos.order.findByOrderNumber({
|
|
37
|
-
// orderNumber: payload.orderNumber,
|
|
38
|
-
// inclusion: ['orderStatus', 'acceptedOffers'],
|
|
39
|
-
// exclusion: []
|
|
40
|
-
// });
|
|
41
|
-
// ステータス検証
|
|
42
|
-
switch (order.orderStatus) {
|
|
43
|
-
case factory.orderStatus.OrderDelivered:
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
throw new factory.errors.Argument('token', `invalid orderStatus '${order.orderStatus}'`);
|
|
47
|
-
}
|
|
48
|
-
// const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
49
|
-
// const reservationExistsInOrder = acceptedOffers.some((offer) => {
|
|
50
|
-
// return (
|
|
51
|
-
// offer.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
52
|
-
// || offer.itemOffered.typeOf === factory.reservationType.BusReservation
|
|
53
|
-
// )
|
|
54
|
-
// && offer.itemOffered.id === params.reservationId;
|
|
55
|
-
// });
|
|
56
|
-
// if (!reservationExistsInOrder) {
|
|
57
|
-
// throw new factory.errors.NotFound('AcceptedOffer');
|
|
58
|
-
// }
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
throw new factory.errors.NotImplemented(`Payload type ${payload.typeOf} not implemented`);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
15
|
+
const verifyToken4reservation_1 = require("./verifyToken4reservation");
|
|
65
16
|
/**
|
|
66
17
|
* 予約使用
|
|
67
18
|
*/
|
|
@@ -71,22 +22,24 @@ function useReservation(params) {
|
|
|
71
22
|
var _a, _b;
|
|
72
23
|
const now = new Date();
|
|
73
24
|
const reservationId = params.object.id;
|
|
25
|
+
const token = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.token;
|
|
26
|
+
if (params.verifyToken === true) {
|
|
27
|
+
// instrument?.tokenを検証
|
|
28
|
+
if (typeof token === 'string') {
|
|
29
|
+
yield (0, verifyToken4reservation_1.verifyToken4reservation)({
|
|
30
|
+
project: { id: params.project.id },
|
|
31
|
+
agent: params.agent,
|
|
32
|
+
reservationId,
|
|
33
|
+
token
|
|
34
|
+
})({ order: repos.order });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
74
37
|
// 予約検索
|
|
75
38
|
// 取得属性最適化(2023-01-30~)
|
|
76
39
|
const reservation = yield repos.reservation.findById({
|
|
77
40
|
id: reservationId,
|
|
78
|
-
inclusion: ['
|
|
41
|
+
inclusion: ['_id', 'issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
|
|
79
42
|
});
|
|
80
|
-
// instrument?.tokenを検証
|
|
81
|
-
const token = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.token;
|
|
82
|
-
if (typeof token === 'string') {
|
|
83
|
-
yield verifyToken4reservation({
|
|
84
|
-
project: { id: reservation.project.id },
|
|
85
|
-
agent: params.agent,
|
|
86
|
-
reservationId,
|
|
87
|
-
token
|
|
88
|
-
})({ order: repos.order });
|
|
89
|
-
}
|
|
90
43
|
// UseActionを作成する
|
|
91
44
|
const reservationAsObject = {
|
|
92
45
|
id: reservation.id,
|
|
@@ -99,8 +52,6 @@ function useReservation(params) {
|
|
|
99
52
|
const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }),
|
|
100
53
|
// object最適化(2023-01-30~)
|
|
101
54
|
// どの予約を
|
|
102
|
-
// mask
|
|
103
|
-
// object: [maskUnderName(reservation)],
|
|
104
55
|
object: [reservationAsObject] }, (typeof ((_b = params.location) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
105
56
|
? {
|
|
106
57
|
location: {
|
|
@@ -118,14 +69,6 @@ function useReservation(params) {
|
|
|
118
69
|
try {
|
|
119
70
|
// 使用日時と同時更新(2023-01-30~)
|
|
120
71
|
attendedReservation = (yield repos.reservation.attendIfNotAttended({ id: reservationId, now }));
|
|
121
|
-
// attendedReservation = <IEventReservation>await repos.reservation.attend({ id: reservationId, now });
|
|
122
|
-
// // 使用日時がなければ追加
|
|
123
|
-
// if (attendedReservation.reservedTicket?.dateUsed === undefined) {
|
|
124
|
-
// attendedReservation = await repos.reservation.updatePartiallyById({
|
|
125
|
-
// id: attendedReservation.id,
|
|
126
|
-
// update: { 'reservedTicket.dateUsed': now }
|
|
127
|
-
// });
|
|
128
|
-
// }
|
|
129
72
|
}
|
|
130
73
|
catch (error) {
|
|
131
74
|
// actionにエラー結果を追加
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
|
+
/**
|
|
4
|
+
* 予約使用のためのチケットトークンを検証する
|
|
5
|
+
*/
|
|
6
|
+
export declare function verifyToken4reservation(params: {
|
|
7
|
+
project: {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
10
|
+
agent: factory.action.check.token.IAgent;
|
|
11
|
+
reservationId: string;
|
|
12
|
+
token: string;
|
|
13
|
+
}): (repos: {
|
|
14
|
+
order: OrderRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.verifyToken4reservation = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const code_1 = require("../code");
|
|
15
|
+
/**
|
|
16
|
+
* 予約使用のためのチケットトークンを検証する
|
|
17
|
+
*/
|
|
18
|
+
function verifyToken4reservation(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const payload = yield (0, code_1.verifyToken)({
|
|
21
|
+
project: params.project,
|
|
22
|
+
agent: params.agent,
|
|
23
|
+
token: params.token
|
|
24
|
+
})({});
|
|
25
|
+
switch (payload.typeOf) {
|
|
26
|
+
case factory.order.OrderType.Order:
|
|
27
|
+
// reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
|
|
28
|
+
const order = yield repos.order.findByOrderNumberAndReservationId({
|
|
29
|
+
orderNumber: payload.orderNumber,
|
|
30
|
+
reservationId: params.reservationId
|
|
31
|
+
});
|
|
32
|
+
// ステータス検証
|
|
33
|
+
switch (order.orderStatus) {
|
|
34
|
+
case factory.orderStatus.OrderDelivered:
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
throw new factory.errors.Argument('token', `invalid orderStatus '${order.orderStatus}'`);
|
|
38
|
+
}
|
|
39
|
+
// const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
40
|
+
// const reservationExistsInOrder = acceptedOffers.some((offer) => {
|
|
41
|
+
// return (
|
|
42
|
+
// offer.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
43
|
+
// || offer.itemOffered.typeOf === factory.reservationType.BusReservation
|
|
44
|
+
// )
|
|
45
|
+
// && offer.itemOffered.id === params.reservationId;
|
|
46
|
+
// });
|
|
47
|
+
// if (!reservationExistsInOrder) {
|
|
48
|
+
// throw new factory.errors.NotFound('AcceptedOffer');
|
|
49
|
+
// }
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
throw new factory.errors.NotImplemented(`Payload type ${payload.typeOf} not implemented`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.verifyToken4reservation = verifyToken4reservation;
|
|
@@ -6,4 +6,5 @@ import { cancelPendingReservation, cancelReservation } from './reserve/cancelRes
|
|
|
6
6
|
import { checkInRerservation } from './reserve/checkInReservation';
|
|
7
7
|
import { confirmReservation } from './reserve/confirmReservation';
|
|
8
8
|
import { useReservation } from './reserve/useReservation';
|
|
9
|
-
|
|
9
|
+
import { verifyToken4reservation } from './reserve/verifyToken4reservation';
|
|
10
|
+
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInRerservation, confirmReservation, useReservation, verifyToken4reservation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useReservation = exports.confirmReservation = exports.checkInRerservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
3
|
+
exports.verifyToken4reservation = exports.useReservation = exports.confirmReservation = exports.checkInRerservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約サービス
|
|
6
6
|
*/
|
|
@@ -15,3 +15,5 @@ const confirmReservation_1 = require("./reserve/confirmReservation");
|
|
|
15
15
|
Object.defineProperty(exports, "confirmReservation", { enumerable: true, get: function () { return confirmReservation_1.confirmReservation; } });
|
|
16
16
|
const useReservation_1 = require("./reserve/useReservation");
|
|
17
17
|
Object.defineProperty(exports, "useReservation", { enumerable: true, get: function () { return useReservation_1.useReservation; } });
|
|
18
|
+
const verifyToken4reservation_1 = require("./reserve/verifyToken4reservation");
|
|
19
|
+
Object.defineProperty(exports, "verifyToken4reservation", { enumerable: true, get: function () { return verifyToken4reservation_1.verifyToken4reservation; } });
|
|
@@ -95,7 +95,7 @@ function onRegistered(actionAttributes) {
|
|
|
95
95
|
taskAttributes.push(...orderProgramMembershipTasks);
|
|
96
96
|
}
|
|
97
97
|
// タスク保管
|
|
98
|
-
yield repos.task.saveMany(taskAttributes);
|
|
98
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
exports.onRegistered = onRegistered;
|
|
@@ -10,8 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
+
const accountingReport_1 = require("../../repo/accountingReport");
|
|
13
14
|
const action_1 = require("../../repo/action");
|
|
14
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const order_1 = require("../../repo/order");
|
|
17
|
+
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
15
18
|
const reservation_1 = require("../../repo/reservation");
|
|
16
19
|
const transaction_1 = require("../../repo/transaction");
|
|
17
20
|
const TransactionService = require("../transaction");
|
|
@@ -20,15 +23,14 @@ const TransactionService = require("../transaction");
|
|
|
20
23
|
*/
|
|
21
24
|
function call(data) {
|
|
22
25
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
24
|
-
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
25
|
-
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
26
|
-
const transactionRepo = new transaction_1.MongoRepository(settings.connection);
|
|
27
26
|
yield TransactionService.deleteTransaction(data)({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
28
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
29
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
30
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
31
|
+
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
32
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
33
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
36
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.onAuthorizationCreated.IData): IOperation<void>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const code_1 = require("../../repo/code");
|
|
15
|
+
const order_1 = require("../../repo/order");
|
|
16
|
+
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
17
|
+
const reservation_1 = require("../../repo/reservation");
|
|
18
|
+
const task_1 = require("../../repo/task");
|
|
19
|
+
const reserve_1 = require("../reserve");
|
|
20
|
+
/**
|
|
21
|
+
* タスク実行関数
|
|
22
|
+
*/
|
|
23
|
+
function call(data) {
|
|
24
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
yield onAuthorizationCreated(data)({
|
|
26
|
+
code: new code_1.MongoRepository(settings.connection),
|
|
27
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
28
|
+
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
29
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
30
|
+
task: new task_1.MongoRepository(settings.connection)
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.call = call;
|
|
35
|
+
function onAuthorizationCreated(params) {
|
|
36
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
// 発券対象予約ID
|
|
38
|
+
let reservationIds = [];
|
|
39
|
+
// 発券対象予約番号
|
|
40
|
+
let reservationNumbers = [];
|
|
41
|
+
// 発券対象イベントID
|
|
42
|
+
let reservationForIds = [];
|
|
43
|
+
const authorizationObject = yield repos.code.findOne({
|
|
44
|
+
code: params.code,
|
|
45
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project }
|
|
46
|
+
});
|
|
47
|
+
switch (authorizationObject.typeOf) {
|
|
48
|
+
case factory.order.OrderType.Order:
|
|
49
|
+
// 注文検索
|
|
50
|
+
const orderNumber = authorizationObject.orderNumber;
|
|
51
|
+
if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
52
|
+
// 最適化(2023-01-28~)
|
|
53
|
+
const order = yield repos.order.findByOrderNumber({
|
|
54
|
+
orderNumber,
|
|
55
|
+
inclusion: ['acceptedOffers'],
|
|
56
|
+
exclusion: []
|
|
57
|
+
});
|
|
58
|
+
const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
59
|
+
reservationNumbers = acceptedOffers
|
|
60
|
+
.filter((o) => o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
61
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
62
|
+
.map((o) => o.itemOffered.reservationNumber);
|
|
63
|
+
reservationNumbers = [...new Set(reservationNumbers)];
|
|
64
|
+
reservationForIds = acceptedOffers
|
|
65
|
+
.filter((o) => o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
66
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
67
|
+
.map((o) => String(o.itemOffered.reservationFor.id));
|
|
68
|
+
reservationForIds = [...new Set(reservationForIds)];
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case 'OwnershipInfo':
|
|
72
|
+
// 所有権検索
|
|
73
|
+
const ownershipInfoId = authorizationObject.id;
|
|
74
|
+
if (typeof ownershipInfoId === 'string' && ownershipInfoId.length > 0) {
|
|
75
|
+
const ownershipInfo = yield repos.ownershipInfo.findById({ id: ownershipInfoId });
|
|
76
|
+
// 座席予約に対する所有権であれば発券
|
|
77
|
+
if (ownershipInfo.typeOfGood.typeOf === factory.reservationType.EventReservation
|
|
78
|
+
|| ownershipInfo.typeOfGood.typeOf === factory.reservationType.BusReservation) {
|
|
79
|
+
const reservationId = String(ownershipInfo.typeOfGood.id);
|
|
80
|
+
reservationIds = [reservationId];
|
|
81
|
+
const reservation = yield repos.reservation.findById({ id: reservationId });
|
|
82
|
+
reservationForIds = [String(reservation.reservationFor.id)];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
// no op
|
|
88
|
+
}
|
|
89
|
+
yield (0, reserve_1.checkInRerservation)({
|
|
90
|
+
project: { id: params.project.id },
|
|
91
|
+
object: {
|
|
92
|
+
ids: reservationIds,
|
|
93
|
+
reservationNumbers: reservationNumbers,
|
|
94
|
+
reservationFor: { ids: reservationForIds }
|
|
95
|
+
}
|
|
96
|
+
})({
|
|
97
|
+
reservation: repos.reservation,
|
|
98
|
+
task: repos.task
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const action_1 = require("../../repo/action");
|
|
14
|
+
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
14
15
|
const reservation_1 = require("../../repo/reservation");
|
|
15
16
|
const task_1 = require("../../repo/task");
|
|
16
17
|
const ReserveService = require("../reserve");
|
|
@@ -19,13 +20,11 @@ const ReserveService = require("../reserve");
|
|
|
19
20
|
*/
|
|
20
21
|
function call(data) {
|
|
21
22
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
23
|
-
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
24
|
-
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
25
23
|
yield ReserveService.confirmReservation(data.actionAttributes)({
|
|
26
|
-
action:
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
25
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
26
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
27
|
+
task: new task_1.MongoRepository(settings.connection)
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
}
|
|
@@ -134,13 +134,7 @@ function refundTransactionAlreadyExists(params) {
|
|
|
134
134
|
typeOf: factory.assetTransactionType.Refund,
|
|
135
135
|
statuses: [factory.transactionStatusType.Confirmed],
|
|
136
136
|
object: { paymentMethodId: { $eq: params.object.paymentMethodId } }
|
|
137
|
-
},
|
|
138
|
-
agent: 0,
|
|
139
|
-
object: 0,
|
|
140
|
-
potentialActions: 0,
|
|
141
|
-
recipient: 0,
|
|
142
|
-
result: 0
|
|
143
|
-
});
|
|
137
|
+
}, ['_id'], []);
|
|
144
138
|
return refundTransactions.length > 0;
|
|
145
139
|
});
|
|
146
140
|
}
|
|
@@ -219,10 +213,6 @@ function onRefund(refundActionAttributes) {
|
|
|
219
213
|
});
|
|
220
214
|
}
|
|
221
215
|
// タスク保管
|
|
222
|
-
|
|
223
|
-
yield repos.task.saveMany(taskAttributes);
|
|
224
|
-
// await Promise.all(taskAttributes.map(async (taskAttribute) => {
|
|
225
|
-
// return repos.task.save(taskAttribute);
|
|
226
|
-
// }));
|
|
216
|
+
yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
227
217
|
});
|
|
228
218
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.useReservation.IData): IOperation<void>;
|
|
@@ -10,25 +10,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
|
-
const
|
|
13
|
+
const action_1 = require("../../repo/action");
|
|
14
14
|
const order_1 = require("../../repo/order");
|
|
15
|
-
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
16
15
|
const reservation_1 = require("../../repo/reservation");
|
|
17
|
-
const
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
17
|
+
const reserve_1 = require("../reserve");
|
|
18
18
|
/**
|
|
19
19
|
* タスク実行関数
|
|
20
20
|
*/
|
|
21
21
|
function call(data) {
|
|
22
22
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
reservation: reservationRepo
|
|
23
|
+
var _a, _b;
|
|
24
|
+
yield (0, reserve_1.useReservation)(Object.assign(Object.assign({ project: data.project, agent: data.agent, object: data.object,
|
|
25
|
+
// タスク作成前に検証済なので検証不要
|
|
26
|
+
verifyToken: false }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
|
|
27
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
28
|
+
order: new order_1.MongoRepository(settings.connection),
|
|
29
|
+
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
30
|
+
task: new task_1.MongoRepository(settings.connection)
|
|
32
31
|
});
|
|
33
32
|
});
|
|
34
33
|
}
|
|
@@ -17,6 +17,7 @@ const offer_1 = require("../../repo/rateLimit/offer");
|
|
|
17
17
|
const reservation_1 = require("../../repo/reservation");
|
|
18
18
|
const stockHolder_1 = require("../../repo/stockHolder");
|
|
19
19
|
const task_1 = require("../../repo/task");
|
|
20
|
+
const transaction_1 = require("../../repo/transaction");
|
|
20
21
|
const EventOfferService = require("../offer/event");
|
|
21
22
|
/**
|
|
22
23
|
* タスク実行関数
|
|
@@ -38,7 +39,8 @@ function call(data) {
|
|
|
38
39
|
stockHolder: stockHolderRepo,
|
|
39
40
|
offerRateLimit: offerRateLimitRepo,
|
|
40
41
|
reservation: reservationRepo,
|
|
41
|
-
task: taskRepo
|
|
42
|
+
task: taskRepo,
|
|
43
|
+
transaction: new transaction_1.MongoRepository(settings.connection)
|
|
42
44
|
});
|
|
43
45
|
});
|
|
44
46
|
}
|
|
@@ -16,11 +16,20 @@ export type TaskOperation<T> = (repos: {
|
|
|
16
16
|
task: TaskRepo;
|
|
17
17
|
}) => Promise<T>;
|
|
18
18
|
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
19
|
+
export declare function executeById(params: {
|
|
20
|
+
id: string;
|
|
21
|
+
executor?: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
}): IOperation<void>;
|
|
19
25
|
/**
|
|
20
26
|
* タスク名でタスクをひとつ実行する
|
|
21
27
|
*/
|
|
22
28
|
export declare function executeByName<T extends factory.taskName>(params: {
|
|
23
29
|
name: T;
|
|
30
|
+
executor?: {
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
24
33
|
}): IOperation<void>;
|
|
25
34
|
/**
|
|
26
35
|
* タスクを実行する
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.notifyAbortedTasks = exports.abort = exports.retry = exports.execute = exports.executeByName = void 0;
|
|
12
|
+
exports.notifyAbortedTasks = exports.abort = exports.retry = exports.execute = exports.executeByName = exports.executeById = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* タスクサービス
|
|
15
15
|
*/
|
|
@@ -18,19 +18,54 @@ const factory = require("../factory");
|
|
|
18
18
|
const task_1 = require("../repo/task");
|
|
19
19
|
const NotificationService = require("./notification");
|
|
20
20
|
const factory_1 = require("./notification/factory");
|
|
21
|
+
const credentials_1 = require("../credentials");
|
|
21
22
|
const settings_1 = require("../settings");
|
|
22
23
|
const debug = createDebug('chevre-domain:service:task');
|
|
24
|
+
const DEFAULT_EXECUTOR_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
|
|
25
|
+
function executeById(params) {
|
|
26
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
28
|
+
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
29
|
+
// 未実行のタスクを取得
|
|
30
|
+
// tslint:disable-next-line:no-null-keyword
|
|
31
|
+
let task = null;
|
|
32
|
+
try {
|
|
33
|
+
task = yield taskRepo.executeById({
|
|
34
|
+
id: params.id,
|
|
35
|
+
executor: {
|
|
36
|
+
name: (typeof ((_a = params.executor) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? params.executor.name : DEFAULT_EXECUTOR_NAME
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
42
|
+
/* istanbul ignore next */
|
|
43
|
+
debug('service.task.executeById error:', error);
|
|
44
|
+
}
|
|
45
|
+
// タスクがなければ終了
|
|
46
|
+
if (task !== null) {
|
|
47
|
+
yield execute(task)(settings);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.executeById = executeById;
|
|
23
52
|
/**
|
|
24
53
|
* タスク名でタスクをひとつ実行する
|
|
25
54
|
*/
|
|
26
55
|
function executeByName(params) {
|
|
27
56
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
28
58
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
29
59
|
// 未実行のタスクを取得
|
|
30
60
|
// tslint:disable-next-line:no-null-keyword
|
|
31
61
|
let task = null;
|
|
32
62
|
try {
|
|
33
|
-
task = yield taskRepo.executeOneByName(
|
|
63
|
+
task = yield taskRepo.executeOneByName({
|
|
64
|
+
name: params.name,
|
|
65
|
+
executor: {
|
|
66
|
+
name: (typeof ((_a = params.executor) === null || _a === void 0 ? void 0 : _a.name) === 'string') ? params.executor.name : DEFAULT_EXECUTOR_NAME
|
|
67
|
+
}
|
|
68
|
+
});
|
|
34
69
|
}
|
|
35
70
|
catch (error) {
|
|
36
71
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -106,7 +141,9 @@ function abort(params) {
|
|
|
106
141
|
}
|
|
107
142
|
// 開発者へ報告
|
|
108
143
|
const message = (0, factory_1.task2lineNotify)({ task: abortedTask });
|
|
109
|
-
yield NotificationService.report2developers(message.subject, message.content)(
|
|
144
|
+
yield NotificationService.report2developers(message.subject, message.content)({
|
|
145
|
+
accessToken: credentials_1.credentials.lineNotify.accessTokenAlert
|
|
146
|
+
});
|
|
110
147
|
}
|
|
111
148
|
});
|
|
112
149
|
}
|
|
@@ -123,7 +160,9 @@ function notifyAbortedTasks(params) {
|
|
|
123
160
|
if (abortedTasks.length > 0) {
|
|
124
161
|
// 開発者へ報告
|
|
125
162
|
const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
|
|
126
|
-
yield NotificationService.report2developers(message.subject, message.content)(
|
|
163
|
+
yield NotificationService.report2developers(message.subject, message.content)({
|
|
164
|
+
accessToken: credentials_1.credentials.lineNotify.accessTokenAlert
|
|
165
|
+
});
|
|
127
166
|
}
|
|
128
167
|
});
|
|
129
168
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
|
+
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
|
+
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
6
|
+
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
|
+
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
8
|
+
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
9
|
+
/**
|
|
10
|
+
* 取引に関わるリソースを削除する
|
|
11
|
+
* 冪等性を確保すること
|
|
12
|
+
*/
|
|
13
|
+
export declare function deleteTransaction(params: factory.task.IData<factory.taskName.DeleteTransaction>): (repos: {
|
|
14
|
+
accountingReport: AccountingReportRepo;
|
|
15
|
+
action: ActionRepo;
|
|
16
|
+
assetTransaction: AssetTransactionRepo;
|
|
17
|
+
order: OrderRepo;
|
|
18
|
+
ownershipInfo: OwnershipInfoRepo;
|
|
19
|
+
reservation: ReservationRepo;
|
|
20
|
+
transaction: TransactionRepo;
|
|
21
|
+
}) => Promise<void>;
|