@chevre/domain 21.2.0-alpha.4 → 21.2.0-alpha.41
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/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/lockStockHolder.ts +48 -0
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/makeExpired.ts +18 -0
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- 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 +0 -4
- package/lib/chevre/repo/accountTitle.js +0 -4
- package/lib/chevre/repo/accountTransaction.d.ts +0 -10
- package/lib/chevre/repo/accountTransaction.js +0 -57
- package/lib/chevre/repo/accountingReport.js +0 -4
- package/lib/chevre/repo/action.js +0 -4
- package/lib/chevre/repo/additionalProperty.js +0 -4
- package/lib/chevre/repo/aggregation.js +0 -4
- package/lib/chevre/repo/assetTransaction.d.ts +16 -6
- package/lib/chevre/repo/assetTransaction.js +174 -50
- package/lib/chevre/repo/categoryCode.js +0 -4
- package/lib/chevre/repo/code.js +0 -4
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -9
- 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/creativeWork.js +0 -4
- package/lib/chevre/repo/customer.js +0 -4
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +0 -4
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +0 -4
- package/lib/chevre/repo/member.js +0 -4
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
- 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 +3 -1
- 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/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 +62 -3
- 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 +1 -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/offer.js +0 -5
- package/lib/chevre/repo/offerCatalog.js +0 -4
- package/lib/chevre/repo/order.d.ts +25 -0
- package/lib/chevre/repo/order.js +5 -4
- package/lib/chevre/repo/orderNumber.d.ts +0 -1
- package/lib/chevre/repo/orderNumber.js +2 -12
- package/lib/chevre/repo/ownershipInfo.js +0 -4
- package/lib/chevre/repo/permit.js +0 -4
- package/lib/chevre/repo/place.d.ts +5 -1
- package/lib/chevre/repo/place.js +1 -10
- package/lib/chevre/repo/priceSpecification.js +0 -4
- package/lib/chevre/repo/product.js +0 -4
- package/lib/chevre/repo/project.js +0 -4
- package/lib/chevre/repo/reservation.js +0 -4
- package/lib/chevre/repo/role.js +0 -4
- package/lib/chevre/repo/seller.js +0 -4
- package/lib/chevre/repo/serviceOutput.js +0 -4
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +2 -12
- package/lib/chevre/repo/stockHolder.d.ts +1 -0
- package/lib/chevre/repo/stockHolder.js +74 -7
- package/lib/chevre/repo/task.d.ts +38 -2
- package/lib/chevre/repo/task.js +90 -10
- package/lib/chevre/repo/telemetry.js +0 -4
- package/lib/chevre/repo/transaction.d.ts +17 -2
- package/lib/chevre/repo/transaction.js +176 -56
- package/lib/chevre/repo/transactionNumber.d.ts +0 -1
- package/lib/chevre/repo/transactionNumber.js +2 -12
- package/lib/chevre/repo/trip.js +0 -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 -5
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +2 -2
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +1 -2
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +28 -7
- 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/onOrderStatusChanged.js +1 -1
- 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 +25 -10
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/reserve/cancelReservation.js +0 -2
- 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.js +1 -8
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -5
- 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/moneyTransfer.js +1 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +30 -29
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder.js +1 -5
- package/lib/chevre/service/transaction.d.ts +6 -0
- package/lib/chevre/service/transaction.js +9 -7
- package/lib/chevre/settings.d.ts +3 -2
- package/lib/chevre/settings.js +9 -8
- package/package.json +4 -4
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
|
@@ -19,22 +19,22 @@ function aggregateEvent(params) {
|
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a;
|
|
21
21
|
const aggregateDate = new Date();
|
|
22
|
-
const aggregateDuration = moment.duration(1,
|
|
22
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
23
23
|
.toISOString();
|
|
24
24
|
let i = -1;
|
|
25
|
-
while (i < params.
|
|
25
|
+
while (i < params.aggregationCount) {
|
|
26
26
|
i += 1;
|
|
27
|
-
const startFrom = moment()
|
|
27
|
+
const startFrom = moment(aggregateDate)
|
|
28
28
|
.utc()
|
|
29
29
|
// .tz('Asia/Tokyo')
|
|
30
|
-
.add(-i,
|
|
31
|
-
.startOf(
|
|
30
|
+
.add(-i, params.aggregateDurationUnit)
|
|
31
|
+
.startOf(params.aggregateDurationUnit)
|
|
32
32
|
.toDate();
|
|
33
|
-
const startThrough = moment()
|
|
33
|
+
const startThrough = moment(aggregateDate)
|
|
34
34
|
.utc()
|
|
35
35
|
// .tz('Asia/Tokyo')
|
|
36
|
-
.add(-i,
|
|
37
|
-
.endOf(
|
|
36
|
+
.add(-i, params.aggregateDurationUnit)
|
|
37
|
+
.endOf(params.aggregateDurationUnit)
|
|
38
38
|
.toDate();
|
|
39
39
|
const aggregateResult = yield repos.event.aggregateEvent({
|
|
40
40
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -45,6 +45,7 @@ function aggregateEvent(params) {
|
|
|
45
45
|
debug('aggregateEvent:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesRemainingCapacityRate, startFrom);
|
|
46
46
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateEvent, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
47
47
|
}
|
|
48
|
+
return { aggregationCount: i, aggregateDuration };
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
exports.aggregateEvent = aggregateEvent;
|
|
@@ -55,22 +56,22 @@ function aggregatePlaceOrder(params) {
|
|
|
55
56
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
56
57
|
var _a, _b;
|
|
57
58
|
const aggregateDate = new Date();
|
|
58
|
-
const aggregateDuration = moment.duration(1,
|
|
59
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
59
60
|
.toISOString();
|
|
60
61
|
let i = -1;
|
|
61
|
-
while (i < params.
|
|
62
|
+
while (i < params.aggregationCount) {
|
|
62
63
|
i += 1;
|
|
63
|
-
const startFrom = moment()
|
|
64
|
+
const startFrom = moment(aggregateDate)
|
|
64
65
|
.utc()
|
|
65
66
|
// .tz('Asia/Tokyo')
|
|
66
|
-
.add(-i,
|
|
67
|
-
.startOf(
|
|
67
|
+
.add(-i, params.aggregateDurationUnit)
|
|
68
|
+
.startOf(params.aggregateDurationUnit)
|
|
68
69
|
.toDate();
|
|
69
|
-
const startThrough = moment()
|
|
70
|
+
const startThrough = moment(aggregateDate)
|
|
70
71
|
.utc()
|
|
71
72
|
// .tz('Asia/Tokyo')
|
|
72
|
-
.add(-i,
|
|
73
|
-
.endOf(
|
|
73
|
+
.add(-i, params.aggregateDurationUnit)
|
|
74
|
+
.endOf(params.aggregateDurationUnit)
|
|
74
75
|
.toDate();
|
|
75
76
|
const aggregateResult = yield repos.transaction.aggregatePlaceOrder({
|
|
76
77
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -98,6 +99,7 @@ function aggregatePlaceOrder(params) {
|
|
|
98
99
|
}
|
|
99
100
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePlaceOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate, aggregationByClient: aggregateResultsByClientId }, aggregateResult));
|
|
100
101
|
}
|
|
102
|
+
return { aggregationCount: i, aggregateDuration };
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
exports.aggregatePlaceOrder = aggregatePlaceOrder;
|
|
@@ -108,22 +110,22 @@ function aggregateAuthorizeEventServiceOfferAction(params) {
|
|
|
108
110
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
109
111
|
var _a;
|
|
110
112
|
const aggregateDate = new Date();
|
|
111
|
-
const aggregateDuration = moment.duration(1,
|
|
113
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
112
114
|
.toISOString();
|
|
113
115
|
let i = -1;
|
|
114
|
-
while (i < params.
|
|
116
|
+
while (i < params.aggregationCount) {
|
|
115
117
|
i += 1;
|
|
116
|
-
const startFrom = moment()
|
|
118
|
+
const startFrom = moment(aggregateDate)
|
|
117
119
|
.utc()
|
|
118
120
|
// .tz('Asia/Tokyo')
|
|
119
|
-
.add(-i,
|
|
120
|
-
.startOf(
|
|
121
|
+
.add(-i, params.aggregateDurationUnit)
|
|
122
|
+
.startOf(params.aggregateDurationUnit)
|
|
121
123
|
.toDate();
|
|
122
|
-
const startThrough = moment()
|
|
124
|
+
const startThrough = moment(aggregateDate)
|
|
123
125
|
.utc()
|
|
124
126
|
// .tz('Asia/Tokyo')
|
|
125
|
-
.add(-i,
|
|
126
|
-
.endOf(
|
|
127
|
+
.add(-i, params.aggregateDurationUnit)
|
|
128
|
+
.endOf(params.aggregateDurationUnit)
|
|
127
129
|
.toDate();
|
|
128
130
|
const aggregateResult = yield repos.action.aggregateAuthorizeEventServiceOfferAction({
|
|
129
131
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -134,6 +136,7 @@ function aggregateAuthorizeEventServiceOfferAction(params) {
|
|
|
134
136
|
debug('aggregateAuthorizeEventServiceOfferAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
135
137
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeEventServiceOfferAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
136
138
|
}
|
|
139
|
+
return { aggregationCount: i, aggregateDuration };
|
|
137
140
|
});
|
|
138
141
|
}
|
|
139
142
|
exports.aggregateAuthorizeEventServiceOfferAction = aggregateAuthorizeEventServiceOfferAction;
|
|
@@ -144,22 +147,22 @@ function aggregateAuthorizePaymentAction(params) {
|
|
|
144
147
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
145
148
|
var _a;
|
|
146
149
|
const aggregateDate = new Date();
|
|
147
|
-
const aggregateDuration = moment.duration(1,
|
|
150
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
148
151
|
.toISOString();
|
|
149
152
|
let i = -1;
|
|
150
|
-
while (i < params.
|
|
153
|
+
while (i < params.aggregationCount) {
|
|
151
154
|
i += 1;
|
|
152
|
-
const startFrom = moment()
|
|
155
|
+
const startFrom = moment(aggregateDate)
|
|
153
156
|
.utc()
|
|
154
157
|
// .tz('Asia/Tokyo')
|
|
155
|
-
.add(-i,
|
|
156
|
-
.startOf(
|
|
158
|
+
.add(-i, params.aggregateDurationUnit)
|
|
159
|
+
.startOf(params.aggregateDurationUnit)
|
|
157
160
|
.toDate();
|
|
158
|
-
const startThrough = moment()
|
|
161
|
+
const startThrough = moment(aggregateDate)
|
|
159
162
|
.utc()
|
|
160
163
|
// .tz('Asia/Tokyo')
|
|
161
|
-
.add(-i,
|
|
162
|
-
.endOf(
|
|
164
|
+
.add(-i, params.aggregateDurationUnit)
|
|
165
|
+
.endOf(params.aggregateDurationUnit)
|
|
163
166
|
.toDate();
|
|
164
167
|
const aggregateResult = yield repos.action.aggregateAuthorizePaymentAction({
|
|
165
168
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -170,6 +173,7 @@ function aggregateAuthorizePaymentAction(params) {
|
|
|
170
173
|
debug('aggregateAuthorizePaymentAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
171
174
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizePaymentAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
172
175
|
}
|
|
176
|
+
return { aggregationCount: i, aggregateDuration };
|
|
173
177
|
});
|
|
174
178
|
}
|
|
175
179
|
exports.aggregateAuthorizePaymentAction = aggregateAuthorizePaymentAction;
|
|
@@ -177,22 +181,22 @@ function aggregateAuthorizeOrderAction(params) {
|
|
|
177
181
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
178
182
|
var _a;
|
|
179
183
|
const aggregateDate = new Date();
|
|
180
|
-
const aggregateDuration = moment.duration(1,
|
|
184
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
181
185
|
.toISOString();
|
|
182
186
|
let i = -1;
|
|
183
|
-
while (i < params.
|
|
187
|
+
while (i < params.aggregationCount) {
|
|
184
188
|
i += 1;
|
|
185
|
-
const startFrom = moment()
|
|
189
|
+
const startFrom = moment(aggregateDate)
|
|
186
190
|
.utc()
|
|
187
191
|
// .tz('Asia/Tokyo')
|
|
188
|
-
.add(-i,
|
|
189
|
-
.startOf(
|
|
192
|
+
.add(-i, params.aggregateDurationUnit)
|
|
193
|
+
.startOf(params.aggregateDurationUnit)
|
|
190
194
|
.toDate();
|
|
191
|
-
const startThrough = moment()
|
|
195
|
+
const startThrough = moment(aggregateDate)
|
|
192
196
|
.utc()
|
|
193
197
|
// .tz('Asia/Tokyo')
|
|
194
|
-
.add(-i,
|
|
195
|
-
.endOf(
|
|
198
|
+
.add(-i, params.aggregateDurationUnit)
|
|
199
|
+
.endOf(params.aggregateDurationUnit)
|
|
196
200
|
.toDate();
|
|
197
201
|
const aggregateResult = yield repos.action.aggregateAuthorizeOrderAction({
|
|
198
202
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -203,6 +207,7 @@ function aggregateAuthorizeOrderAction(params) {
|
|
|
203
207
|
debug('aggregateAuthorizeOrderAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
204
208
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeOrderAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
205
209
|
}
|
|
210
|
+
return { aggregationCount: i, aggregateDuration };
|
|
206
211
|
});
|
|
207
212
|
}
|
|
208
213
|
exports.aggregateAuthorizeOrderAction = aggregateAuthorizeOrderAction;
|
|
@@ -213,22 +218,22 @@ function aggregateUseAction(params) {
|
|
|
213
218
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
214
219
|
var _a;
|
|
215
220
|
const aggregateDate = new Date();
|
|
216
|
-
const aggregateDuration = moment.duration(1,
|
|
221
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
217
222
|
.toISOString();
|
|
218
223
|
let i = -1;
|
|
219
|
-
while (i < params.
|
|
224
|
+
while (i < params.aggregationCount) {
|
|
220
225
|
i += 1;
|
|
221
|
-
const startFrom = moment()
|
|
226
|
+
const startFrom = moment(aggregateDate)
|
|
222
227
|
.utc()
|
|
223
228
|
// .tz('Asia/Tokyo')
|
|
224
|
-
.add(-i,
|
|
225
|
-
.startOf(
|
|
229
|
+
.add(-i, params.aggregateDurationUnit)
|
|
230
|
+
.startOf(params.aggregateDurationUnit)
|
|
226
231
|
.toDate();
|
|
227
|
-
const startThrough = moment()
|
|
232
|
+
const startThrough = moment(aggregateDate)
|
|
228
233
|
.utc()
|
|
229
234
|
// .tz('Asia/Tokyo')
|
|
230
|
-
.add(-i,
|
|
231
|
-
.endOf(
|
|
235
|
+
.add(-i, params.aggregateDurationUnit)
|
|
236
|
+
.endOf(params.aggregateDurationUnit)
|
|
232
237
|
.toDate();
|
|
233
238
|
const aggregateResult = yield repos.action.aggregateUseAction({
|
|
234
239
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -239,6 +244,7 @@ function aggregateUseAction(params) {
|
|
|
239
244
|
debug('aggregateUseAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
240
245
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateUseAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
241
246
|
}
|
|
247
|
+
return { aggregationCount: i, aggregateDuration };
|
|
242
248
|
});
|
|
243
249
|
}
|
|
244
250
|
exports.aggregateUseAction = aggregateUseAction;
|
|
@@ -246,22 +252,22 @@ function aggregateCheckMovieTicketAction(params) {
|
|
|
246
252
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
247
253
|
var _a;
|
|
248
254
|
const aggregateDate = new Date();
|
|
249
|
-
const aggregateDuration = moment.duration(1,
|
|
255
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
250
256
|
.toISOString();
|
|
251
257
|
let i = -1;
|
|
252
|
-
while (i < params.
|
|
258
|
+
while (i < params.aggregationCount) {
|
|
253
259
|
i += 1;
|
|
254
|
-
const startFrom = moment()
|
|
260
|
+
const startFrom = moment(aggregateDate)
|
|
255
261
|
.utc()
|
|
256
262
|
// .tz('Asia/Tokyo')
|
|
257
|
-
.add(-i,
|
|
258
|
-
.startOf(
|
|
263
|
+
.add(-i, params.aggregateDurationUnit)
|
|
264
|
+
.startOf(params.aggregateDurationUnit)
|
|
259
265
|
.toDate();
|
|
260
|
-
const startThrough = moment()
|
|
266
|
+
const startThrough = moment(aggregateDate)
|
|
261
267
|
.utc()
|
|
262
268
|
// .tz('Asia/Tokyo')
|
|
263
|
-
.add(-i,
|
|
264
|
-
.endOf(
|
|
269
|
+
.add(-i, params.aggregateDurationUnit)
|
|
270
|
+
.endOf(params.aggregateDurationUnit)
|
|
265
271
|
.toDate();
|
|
266
272
|
const aggregateResult = yield repos.action.aggregateCheckMovieTicketAction({
|
|
267
273
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -271,6 +277,7 @@ function aggregateCheckMovieTicketAction(params) {
|
|
|
271
277
|
debug('aggregateCheckMovieTicketAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
272
278
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateCheckMovieTicketAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
273
279
|
}
|
|
280
|
+
return { aggregationCount: i, aggregateDuration };
|
|
274
281
|
});
|
|
275
282
|
}
|
|
276
283
|
exports.aggregateCheckMovieTicketAction = aggregateCheckMovieTicketAction;
|
|
@@ -278,22 +285,22 @@ function aggregatePayMovieTicketAction(params) {
|
|
|
278
285
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
279
286
|
var _a;
|
|
280
287
|
const aggregateDate = new Date();
|
|
281
|
-
const aggregateDuration = moment.duration(1,
|
|
288
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
282
289
|
.toISOString();
|
|
283
290
|
let i = -1;
|
|
284
|
-
while (i < params.
|
|
291
|
+
while (i < params.aggregationCount) {
|
|
285
292
|
i += 1;
|
|
286
|
-
const startFrom = moment()
|
|
293
|
+
const startFrom = moment(aggregateDate)
|
|
287
294
|
.utc()
|
|
288
295
|
// .tz('Asia/Tokyo')
|
|
289
|
-
.add(-i,
|
|
290
|
-
.startOf(
|
|
296
|
+
.add(-i, params.aggregateDurationUnit)
|
|
297
|
+
.startOf(params.aggregateDurationUnit)
|
|
291
298
|
.toDate();
|
|
292
|
-
const startThrough = moment()
|
|
299
|
+
const startThrough = moment(aggregateDate)
|
|
293
300
|
.utc()
|
|
294
301
|
// .tz('Asia/Tokyo')
|
|
295
|
-
.add(-i,
|
|
296
|
-
.endOf(
|
|
302
|
+
.add(-i, params.aggregateDurationUnit)
|
|
303
|
+
.endOf(params.aggregateDurationUnit)
|
|
297
304
|
.toDate();
|
|
298
305
|
const aggregateResult = yield repos.action.aggregatePayMovieTicketAction({
|
|
299
306
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -303,6 +310,7 @@ function aggregatePayMovieTicketAction(params) {
|
|
|
303
310
|
debug('aggregatePayMovieTicketAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
304
311
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePayMovieTicketAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
305
312
|
}
|
|
313
|
+
return { aggregationCount: i, aggregateDuration };
|
|
306
314
|
});
|
|
307
315
|
}
|
|
308
316
|
exports.aggregatePayMovieTicketAction = aggregatePayMovieTicketAction;
|
|
@@ -310,22 +318,22 @@ function aggregatePayTransaction(params) {
|
|
|
310
318
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
311
319
|
var _a;
|
|
312
320
|
const aggregateDate = new Date();
|
|
313
|
-
const aggregateDuration = moment.duration(1,
|
|
321
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
314
322
|
.toISOString();
|
|
315
323
|
let i = -1;
|
|
316
|
-
while (i < params.
|
|
324
|
+
while (i < params.aggregationCount) {
|
|
317
325
|
i += 1;
|
|
318
|
-
const startFrom = moment()
|
|
326
|
+
const startFrom = moment(aggregateDate)
|
|
319
327
|
.utc()
|
|
320
328
|
// .tz('Asia/Tokyo')
|
|
321
|
-
.add(-i,
|
|
322
|
-
.startOf(
|
|
329
|
+
.add(-i, params.aggregateDurationUnit)
|
|
330
|
+
.startOf(params.aggregateDurationUnit)
|
|
323
331
|
.toDate();
|
|
324
|
-
const startThrough = moment()
|
|
332
|
+
const startThrough = moment(aggregateDate)
|
|
325
333
|
.utc()
|
|
326
334
|
// .tz('Asia/Tokyo')
|
|
327
|
-
.add(-i,
|
|
328
|
-
.endOf(
|
|
335
|
+
.add(-i, params.aggregateDurationUnit)
|
|
336
|
+
.endOf(params.aggregateDurationUnit)
|
|
329
337
|
.toDate();
|
|
330
338
|
const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
|
|
331
339
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -336,6 +344,7 @@ function aggregatePayTransaction(params) {
|
|
|
336
344
|
debug('aggregatePayTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
|
|
337
345
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePay, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
338
346
|
}
|
|
347
|
+
return { aggregationCount: i, aggregateDuration };
|
|
339
348
|
});
|
|
340
349
|
}
|
|
341
350
|
exports.aggregatePayTransaction = aggregatePayTransaction;
|
|
@@ -346,22 +355,22 @@ function aggregateReserveTransaction(params) {
|
|
|
346
355
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
347
356
|
var _a;
|
|
348
357
|
const aggregateDate = new Date();
|
|
349
|
-
const aggregateDuration = moment.duration(1,
|
|
358
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
350
359
|
.toISOString();
|
|
351
360
|
let i = -1;
|
|
352
|
-
while (i < params.
|
|
361
|
+
while (i < params.aggregationCount) {
|
|
353
362
|
i += 1;
|
|
354
|
-
const startFrom = moment()
|
|
363
|
+
const startFrom = moment(aggregateDate)
|
|
355
364
|
.utc()
|
|
356
365
|
// .tz('Asia/Tokyo')
|
|
357
|
-
.add(-i,
|
|
358
|
-
.startOf(
|
|
366
|
+
.add(-i, params.aggregateDurationUnit)
|
|
367
|
+
.startOf(params.aggregateDurationUnit)
|
|
359
368
|
.toDate();
|
|
360
|
-
const startThrough = moment()
|
|
369
|
+
const startThrough = moment(aggregateDate)
|
|
361
370
|
.utc()
|
|
362
371
|
// .tz('Asia/Tokyo')
|
|
363
|
-
.add(-i,
|
|
364
|
-
.endOf(
|
|
372
|
+
.add(-i, params.aggregateDurationUnit)
|
|
373
|
+
.endOf(params.aggregateDurationUnit)
|
|
365
374
|
.toDate();
|
|
366
375
|
const aggregateResult = yield repos.assetTransaction.aggregateAssetTransaction({
|
|
367
376
|
project: { id: { $ne: params.excludedProjectId } },
|
|
@@ -372,6 +381,7 @@ function aggregateReserveTransaction(params) {
|
|
|
372
381
|
debug('aggregateReserveTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
|
|
373
382
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReserve, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
374
383
|
}
|
|
384
|
+
return { aggregationCount: i, aggregateDuration };
|
|
375
385
|
});
|
|
376
386
|
}
|
|
377
387
|
exports.aggregateReserveTransaction = aggregateReserveTransaction;
|
|
@@ -379,31 +389,33 @@ function aggregateTask(params) {
|
|
|
379
389
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
380
390
|
var _a;
|
|
381
391
|
const aggregateDate = new Date();
|
|
382
|
-
const aggregateDuration = moment.duration(1,
|
|
392
|
+
const aggregateDuration = moment.duration(1, params.aggregateDurationUnit)
|
|
383
393
|
.toISOString();
|
|
384
394
|
let i = -1;
|
|
385
|
-
while (i < params.
|
|
395
|
+
while (i < params.aggregationCount) {
|
|
386
396
|
i += 1;
|
|
387
|
-
const runsFrom = moment()
|
|
397
|
+
const runsFrom = moment(aggregateDate)
|
|
388
398
|
.utc()
|
|
389
399
|
// .tz('Asia/Tokyo')
|
|
390
|
-
.add(-i,
|
|
391
|
-
.startOf(
|
|
400
|
+
.add(-i, params.aggregateDurationUnit)
|
|
401
|
+
.startOf(params.aggregateDurationUnit)
|
|
392
402
|
.toDate();
|
|
393
|
-
const runsThrough = moment()
|
|
403
|
+
const runsThrough = moment(aggregateDate)
|
|
394
404
|
.utc()
|
|
395
405
|
// .tz('Asia/Tokyo')
|
|
396
|
-
.add(-i,
|
|
397
|
-
.endOf(
|
|
406
|
+
.add(-i, params.aggregateDurationUnit)
|
|
407
|
+
.endOf(params.aggregateDurationUnit)
|
|
398
408
|
.toDate();
|
|
399
409
|
const aggregateResult = yield repos.task.aggregateTask({
|
|
400
410
|
project: { id: { $ne: params.excludedProjectId } },
|
|
401
411
|
runsFrom,
|
|
402
412
|
runsThrough
|
|
403
413
|
});
|
|
404
|
-
debug('aggregateTask:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, runsFrom);
|
|
414
|
+
debug('aggregateTask:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, runsFrom, runsThrough);
|
|
405
415
|
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateTask, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: runsFrom, aggregateDate }, aggregateResult));
|
|
406
416
|
}
|
|
417
|
+
debug(i, 'aggregations saved');
|
|
418
|
+
return { aggregationCount: i, aggregateDuration };
|
|
407
419
|
});
|
|
408
420
|
}
|
|
409
421
|
exports.aggregateTask = aggregateTask;
|
|
@@ -13,13 +13,11 @@ exports.exportTasksById = exports.startAndConfirm = exports.confirm = exports.st
|
|
|
13
13
|
/**
|
|
14
14
|
* 予約取消取引サービス
|
|
15
15
|
*/
|
|
16
|
-
const createDebug = require("debug");
|
|
17
16
|
const moment = require("moment");
|
|
18
17
|
const mongoose = require("mongoose");
|
|
19
18
|
const factory = require("../../factory");
|
|
20
19
|
const settings_1 = require("../../settings");
|
|
21
20
|
const factory_1 = require("./cancelReservation/factory");
|
|
22
|
-
const debug = createDebug('chevre-domain:service');
|
|
23
21
|
function validateStartParams(params) {
|
|
24
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
23
|
var _a, _b;
|
|
@@ -235,9 +233,7 @@ function exportTasksById(params) {
|
|
|
235
233
|
default:
|
|
236
234
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
237
235
|
}
|
|
238
|
-
|
|
239
|
-
return repos.task.saveMany(taskAttributes);
|
|
240
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
236
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
241
237
|
});
|
|
242
238
|
}
|
|
243
239
|
exports.exportTasksById = exportTasksById;
|
|
@@ -430,7 +430,7 @@ function exportTasksById(params) {
|
|
|
430
430
|
default:
|
|
431
431
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
432
432
|
}
|
|
433
|
-
return repos.task.saveMany(taskAttributes);
|
|
433
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
exports.exportTasksById = exportTasksById;
|
|
@@ -281,7 +281,7 @@ function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useC
|
|
|
281
281
|
}
|
|
282
282
|
function saveAuthorizeResult(params) {
|
|
283
283
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
return repos.assetTransaction.
|
|
284
|
+
return repos.assetTransaction.findByIdAndUpdateInProgress(params);
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
@@ -470,7 +470,7 @@ function exportTasksById(params) {
|
|
|
470
470
|
default:
|
|
471
471
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
472
472
|
}
|
|
473
|
-
return repos.task.saveMany(taskAttributes);
|
|
473
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
exports.exportTasksById = exportTasksById;
|
|
@@ -218,7 +218,7 @@ function exportTasksById(params) {
|
|
|
218
218
|
default:
|
|
219
219
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
220
220
|
}
|
|
221
|
-
return repos.task.saveMany(taskAttributes);
|
|
221
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
exports.exportTasksById = exportTasksById;
|
|
@@ -301,8 +301,7 @@ function exportTasksById(params) {
|
|
|
301
301
|
default:
|
|
302
302
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
303
303
|
}
|
|
304
|
-
return repos.task.saveMany(taskAttributes);
|
|
305
|
-
// return Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
|
|
304
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
306
305
|
});
|
|
307
306
|
}
|
|
308
307
|
exports.exportTasksById = exportTasksById;
|
|
@@ -860,7 +860,7 @@ function exportTasksById(params) {
|
|
|
860
860
|
default:
|
|
861
861
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
862
862
|
}
|
|
863
|
-
return repos.task.saveMany(taskAttributes);
|
|
863
|
+
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
864
864
|
});
|
|
865
865
|
}
|
|
866
866
|
exports.exportTasksById = exportTasksById;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as factory from '../factory';
|
|
5
5
|
import { MongoRepository as AssetTransactionRepo } from '../repo/assetTransaction';
|
|
6
|
-
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
7
6
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
8
7
|
import * as CancelReservationTransactionService from './assetTransaction/cancelReservation';
|
|
9
8
|
import * as MoneyTransferTransactionService from './assetTransaction/moneyTransfer';
|
|
@@ -29,8 +28,13 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
|
|
|
29
28
|
typeOf?: {
|
|
30
29
|
$in: T[];
|
|
31
30
|
};
|
|
31
|
+
id?: string;
|
|
32
|
+
tasksExportAction?: {
|
|
33
|
+
agent: {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
32
37
|
}): (repos: {
|
|
33
|
-
project: ProjectRepo;
|
|
34
38
|
task: TaskRepo;
|
|
35
39
|
assetTransaction: AssetTransactionRepo;
|
|
36
40
|
}) => Promise<{
|
|
@@ -20,6 +20,7 @@ const PayTransactionService = require("./assetTransaction/pay");
|
|
|
20
20
|
const RefundTransactionService = require("./assetTransaction/refund");
|
|
21
21
|
const RegisterServiceTransactionService = require("./assetTransaction/registerService");
|
|
22
22
|
const ReserveTransactionService = require("./assetTransaction/reserve");
|
|
23
|
+
const settings_1 = require("../settings");
|
|
23
24
|
exports.cancelReservation = CancelReservationTransactionService;
|
|
24
25
|
exports.moneyTransfer = MoneyTransferTransactionService;
|
|
25
26
|
exports.pay = PayTransactionService;
|
|
@@ -31,11 +32,14 @@ exports.reserve = ReserveTransactionService;
|
|
|
31
32
|
*/
|
|
32
33
|
function exportTasks(params) {
|
|
33
34
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
const transaction = yield repos.assetTransaction.startExportTasks(Object.assign({ typeOf: params.typeOf, status: params.status, tasksExportAction: {
|
|
37
|
+
agent: {
|
|
38
|
+
name: (typeof ((_a = params.tasksExportAction) === null || _a === void 0 ? void 0 : _a.agent.name) === 'string')
|
|
39
|
+
? params.tasksExportAction.agent.name
|
|
40
|
+
: settings_1.DEFAULT_TASKS_EXPORT_AGENT_NAME
|
|
41
|
+
}
|
|
42
|
+
} }, (typeof params.id === 'string') ? { id: params.id } : undefined));
|
|
39
43
|
if (transaction === null) {
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
2
|
import { MongoRepository as ActionRepo } from '../repo/action';
|
|
3
3
|
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
4
|
-
export type Operation<T> = (
|
|
4
|
+
export type Operation<T> = (repos: {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
}) => Promise<T>;
|
|
5
7
|
/**
|
|
6
8
|
* Eメールメッセージを送信する
|
|
7
9
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
@@ -111,15 +111,11 @@ exports.sendEmailMessage = sendEmailMessage;
|
|
|
111
111
|
* https://notify-bot.line.me/doc/ja/
|
|
112
112
|
*/
|
|
113
113
|
function report2developers(subject, content, imageThumbnail, imageFullsize) {
|
|
114
|
-
return () => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
115
115
|
const LINE_NOTIFY_URL = credentials_1.credentials.lineNotify.url;
|
|
116
|
-
const LINE_NOTIFY_ACCESS_TOKEN = credentials_1.credentials.lineNotify.accessToken;
|
|
117
116
|
if (LINE_NOTIFY_URL === undefined) {
|
|
118
117
|
throw new Error('Environment variable LINE_NOTIFY_URL not set');
|
|
119
118
|
}
|
|
120
|
-
if (LINE_NOTIFY_ACCESS_TOKEN === undefined) {
|
|
121
|
-
throw new Error('Environment variable LINE_NOTIFY_ACCESS_TOKEN not set');
|
|
122
|
-
}
|
|
123
119
|
const message = `--------
|
|
124
120
|
${subject}
|
|
125
121
|
--------
|
|
@@ -130,7 +126,7 @@ ${content}`;
|
|
|
130
126
|
var _a;
|
|
131
127
|
request.post({
|
|
132
128
|
url: LINE_NOTIFY_URL,
|
|
133
|
-
auth: { bearer:
|
|
129
|
+
auth: { bearer: repos.accessToken },
|
|
134
130
|
form: formData,
|
|
135
131
|
json: true,
|
|
136
132
|
timeout: (_a = settings_1.settings.webhook) === null || _a === void 0 ? void 0 : _a.timeout
|
|
@@ -154,6 +150,32 @@ ${content}`;
|
|
|
154
150
|
exports.report2developers = report2developers;
|
|
155
151
|
const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
|
|
156
152
|
function triggerWebhook(params) {
|
|
153
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
// retryableにする(2023-05-12~)
|
|
155
|
+
let retry = true;
|
|
156
|
+
let numberOfTry = 0;
|
|
157
|
+
while (numberOfTry >= 0) {
|
|
158
|
+
try {
|
|
159
|
+
numberOfTry += 1;
|
|
160
|
+
if (numberOfTry > settings_1.MAX_RETRY_COUNT_TRIGGER_WEBHOOK) {
|
|
161
|
+
retry = false;
|
|
162
|
+
}
|
|
163
|
+
yield processInformAction(params)(repos);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (retry) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
exports.triggerWebhook = triggerWebhook;
|
|
178
|
+
function processInformAction(params) {
|
|
157
179
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
158
180
|
var _a, _b;
|
|
159
181
|
// アクション開始
|
|
@@ -219,4 +241,3 @@ function triggerWebhook(params) {
|
|
|
219
241
|
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
220
242
|
});
|
|
221
243
|
}
|
|
222
|
-
exports.triggerWebhook = triggerWebhook;
|