@chevre/domain 21.30.0-alpha.2 → 21.30.0-alpha.3
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/cleanTransactions.ts +39 -0
- package/example/src/chevre/optimizeDeleteTransactionActions.ts +57 -0
- package/example/src/chevre/searchActionsBySameAs.ts +26 -0
- package/lib/chevre/repo/action.d.ts +12 -1
- package/lib/chevre/repo/action.js +15 -0
- package/lib/chevre/repo/mongoose/schemas/action.js +9 -0
- package/lib/chevre/repo/transaction.d.ts +10 -0
- package/lib/chevre/repo/transaction.js +17 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/event/authorize.js +2 -3
- package/lib/chevre/service/offer/event/factory.d.ts +0 -1
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -5
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +0 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +0 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -0
- package/lib/chevre/service/payment/any.js +9 -18
- package/lib/chevre/service/task/aggregateOffers.d.ts +2 -3
- package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -3
- package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +2 -3
- package/lib/chevre/service/task/authorizePayment.d.ts +2 -2
- package/lib/chevre/service/task/authorizePayment.js +41 -15
- package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +2 -3
- package/lib/chevre/service/task/cancelPendingReservation.d.ts +2 -3
- package/lib/chevre/service/task/cancelReservation.d.ts +2 -3
- package/lib/chevre/service/task/checkResource.d.ts +2 -3
- package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +2 -2
- package/lib/chevre/service/task/confirmPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/confirmRegisterService.d.ts +2 -2
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +2 -2
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
- package/lib/chevre/service/task/createEvent.d.ts +2 -3
- package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
- package/lib/chevre/service/task/givePointAward.d.ts +2 -2
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +2 -3
- package/lib/chevre/service/task/importEventsFromCOA.d.ts +2 -3
- package/lib/chevre/service/task/importOffersFromCOA.d.ts +2 -3
- package/lib/chevre/service/task/moneyTransfer.d.ts +2 -3
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +2 -3
- package/lib/chevre/service/task/onEventChanged.d.ts +2 -3
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -3
- package/lib/chevre/service/task/pay.d.ts +2 -2
- package/lib/chevre/service/task/placeOrder.d.ts +2 -2
- package/lib/chevre/service/task/refund.d.ts +2 -2
- package/lib/chevre/service/task/registerService.d.ts +2 -3
- package/lib/chevre/service/task/reserve.d.ts +2 -3
- package/lib/chevre/service/task/returnMoneyTransfer.d.ts +2 -2
- package/lib/chevre/service/task/returnOrder.d.ts +2 -2
- package/lib/chevre/service/task/returnPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/returnPointAward.d.ts +2 -2
- package/lib/chevre/service/task/returnReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task/sendEmailMessage.d.ts +2 -2
- package/lib/chevre/service/task/sendOrder.d.ts +2 -2
- package/lib/chevre/service/task/triggerWebhook.d.ts +2 -2
- package/lib/chevre/service/task/useReservation.d.ts +2 -3
- package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidPayment.d.ts +2 -2
- package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +2 -2
- package/lib/chevre/service/task.d.ts +15 -9
- package/lib/chevre/service/task.js +10 -4
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const STORAGE_PERIOD_IN_DAYS = 365;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
18
|
+
for (let index = 0; index < 1800; index++) {
|
|
19
|
+
const updateResult = await transactionRepo.deleteEndDatePassedCertainPeriod({
|
|
20
|
+
typeOf: chevre.factory.transactionType.MoneyTransfer,
|
|
21
|
+
endDate: {
|
|
22
|
+
$gte: moment()
|
|
23
|
+
.add(-(index + STORAGE_PERIOD_IN_DAYS + 1), 'days')
|
|
24
|
+
.toDate(),
|
|
25
|
+
$lt: moment()
|
|
26
|
+
.add(-(index + STORAGE_PERIOD_IN_DAYS), 'days')
|
|
27
|
+
.toDate()
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
console.log(
|
|
31
|
+
'unset processed.', updateResult, -(index + STORAGE_PERIOD_IN_DAYS), 'days',
|
|
32
|
+
moment.duration(index + STORAGE_PERIOD_IN_DAYS, 'days')
|
|
33
|
+
.humanize());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
main()
|
|
38
|
+
.then()
|
|
39
|
+
.catch(console.error);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
// tslint:disable-next-line:no-increment-decrement
|
|
16
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
17
|
+
for (let index = 0; index < 24 * 548; index++) {
|
|
18
|
+
const updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
19
|
+
filter: {
|
|
20
|
+
typeOf: { $eq: chevre.factory.actionType.DeleteAction },
|
|
21
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.transactionType.PlaceOrder },
|
|
22
|
+
startDate: {
|
|
23
|
+
$gte: moment()
|
|
24
|
+
.add(-(index + 1), 'hours')
|
|
25
|
+
.toDate(),
|
|
26
|
+
$lte: moment()
|
|
27
|
+
.add(-index, 'hours')
|
|
28
|
+
.toDate()
|
|
29
|
+
}
|
|
30
|
+
// _id: { $eq: '65fbb1746e12c17600902282' }
|
|
31
|
+
},
|
|
32
|
+
$unset: {
|
|
33
|
+
'object._id': 1,
|
|
34
|
+
'object.agent': 1,
|
|
35
|
+
'object.seller': 1,
|
|
36
|
+
'object.object.passportToken': 1,
|
|
37
|
+
'object.object.authorizeActions': 1,
|
|
38
|
+
'object.object.clientUser': 1,
|
|
39
|
+
'object.object.customer': 1,
|
|
40
|
+
'object.object.passport': 1,
|
|
41
|
+
'object.status': 1,
|
|
42
|
+
'object.expires': 1,
|
|
43
|
+
'object.tasksExportationStatus': 1,
|
|
44
|
+
'object.createdAt': 1,
|
|
45
|
+
'object.updatedAt': 1,
|
|
46
|
+
'object.potentialActions': 1,
|
|
47
|
+
'object.result': 1
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
console.log('unset processed.', updateResult, -index, 'hours', moment.duration(index, 'hours')
|
|
51
|
+
.asDays());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then()
|
|
57
|
+
.catch(console.error);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
16
|
+
const actions = await actionRepo.searchBySameAs({
|
|
17
|
+
sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } }
|
|
18
|
+
});
|
|
19
|
+
console.log('actions:', actions);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then(() => {
|
|
24
|
+
console.log('success!');
|
|
25
|
+
})
|
|
26
|
+
.catch(console.error);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import type { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
28
28
|
export type IPayAction = factory.action.trade.pay.IAction;
|
|
@@ -163,6 +163,13 @@ export declare class MongoRepository {
|
|
|
163
163
|
orderNumber: string;
|
|
164
164
|
sort?: factory.action.ISortOrder;
|
|
165
165
|
}): Promise<IAction<factory.actionType>[]>;
|
|
166
|
+
searchBySameAs(params: {
|
|
167
|
+
sameAs: {
|
|
168
|
+
id: {
|
|
169
|
+
$eq: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
}): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus'>[]>;
|
|
166
173
|
deleteByProject(params: {
|
|
167
174
|
project: {
|
|
168
175
|
id: string;
|
|
@@ -290,6 +297,10 @@ export declare class MongoRepository {
|
|
|
290
297
|
startThrough: Date;
|
|
291
298
|
}): Promise<IAggregateAction>;
|
|
292
299
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
300
|
+
unsetUnnecessaryFields(params: {
|
|
301
|
+
filter: FilterQuery<factory.action.IAction<factory.action.IAttributes<factory.actionType, any, any>>>;
|
|
302
|
+
$unset: any;
|
|
303
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
293
304
|
/**
|
|
294
305
|
* 互換性維持対応専用
|
|
295
306
|
*/
|
|
@@ -701,6 +701,15 @@ class MongoRepository {
|
|
|
701
701
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
702
702
|
});
|
|
703
703
|
}
|
|
704
|
+
searchBySameAs(params) {
|
|
705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
706
|
+
const query = this.actionModel.find({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } })
|
|
707
|
+
.select({ _id: 1, actionStatus: 1 })
|
|
708
|
+
.limit(1);
|
|
709
|
+
return query.exec()
|
|
710
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
711
|
+
});
|
|
712
|
+
}
|
|
704
713
|
deleteByProject(params) {
|
|
705
714
|
return __awaiter(this, void 0, void 0, function* () {
|
|
706
715
|
yield this.actionModel.deleteMany({
|
|
@@ -1024,6 +1033,12 @@ class MongoRepository {
|
|
|
1024
1033
|
.sort({ startDate: factory.sortType.Descending })
|
|
1025
1034
|
.cursor();
|
|
1026
1035
|
}
|
|
1036
|
+
unsetUnnecessaryFields(params) {
|
|
1037
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1038
|
+
return this.actionModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
1039
|
+
.exec();
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1027
1042
|
/**
|
|
1028
1043
|
* 互換性維持対応専用
|
|
1029
1044
|
*/
|
|
@@ -405,6 +405,15 @@ const indexes = [
|
|
|
405
405
|
'object.transactionNumber': { $exists: true }
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
+
],
|
|
409
|
+
[
|
|
410
|
+
{ 'sameAs.id': 1, startDate: -1 },
|
|
411
|
+
{
|
|
412
|
+
name: 'searchBySameAsId',
|
|
413
|
+
partialFilterExpression: {
|
|
414
|
+
'sameAs.id': { $exists: true }
|
|
415
|
+
}
|
|
416
|
+
}
|
|
408
417
|
]
|
|
409
418
|
];
|
|
410
419
|
exports.indexes = indexes;
|
|
@@ -224,6 +224,16 @@ export declare class MongoRepository {
|
|
|
224
224
|
filter: any;
|
|
225
225
|
$unset: any;
|
|
226
226
|
}): Promise<import("mongodb").UpdateResult>;
|
|
227
|
+
/**
|
|
228
|
+
* 終了日時を一定期間過ぎたアクションを削除する
|
|
229
|
+
*/
|
|
230
|
+
deleteEndDatePassedCertainPeriod(params: {
|
|
231
|
+
typeOf: factory.transactionType;
|
|
232
|
+
endDate: {
|
|
233
|
+
$gte: Date;
|
|
234
|
+
$lt: Date;
|
|
235
|
+
};
|
|
236
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
227
237
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
228
238
|
aggregatePlaceOrder(params: {
|
|
229
239
|
project?: {
|
|
@@ -759,6 +759,23 @@ class MongoRepository {
|
|
|
759
759
|
.exec();
|
|
760
760
|
});
|
|
761
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* 終了日時を一定期間過ぎたアクションを削除する
|
|
764
|
+
*/
|
|
765
|
+
deleteEndDatePassedCertainPeriod(params) {
|
|
766
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
767
|
+
return this.transactionModel.deleteMany({
|
|
768
|
+
typeOf: { $eq: params.typeOf },
|
|
769
|
+
// 終了日時を一定期間過ぎたもの
|
|
770
|
+
endDate: {
|
|
771
|
+
$exists: true,
|
|
772
|
+
$gte: params.endDate.$gte,
|
|
773
|
+
$lt: params.endDate.$lt
|
|
774
|
+
}
|
|
775
|
+
})
|
|
776
|
+
.exec();
|
|
777
|
+
});
|
|
778
|
+
}
|
|
762
779
|
getCursor(conditions, projection) {
|
|
763
780
|
return this.transactionModel.find(conditions, projection)
|
|
764
781
|
.sort({ startDate: factory.sortType.Descending })
|
|
@@ -53,8 +53,7 @@ function authorize(params) {
|
|
|
53
53
|
event: event,
|
|
54
54
|
transaction: transaction,
|
|
55
55
|
pendingTransaction: { typeOf: factory.assetTransactionType.Reserve, transactionNumber },
|
|
56
|
-
broker: params.object.broker
|
|
57
|
-
useResultAcceptedOffers: params.options.useResultAcceptedOffers
|
|
56
|
+
broker: params.object.broker
|
|
58
57
|
});
|
|
59
58
|
const action = yield repos.action.start(actionAttributes);
|
|
60
59
|
try {
|
|
@@ -106,7 +105,7 @@ function authorize(params) {
|
|
|
106
105
|
const result = Object.assign({ priceCurrency: acceptedOffers[0].priceCurrency, amount: [], requestBody: {}, responseBody: {} }, (!noOfferSpecified) // オファー指定の場合のみ金額計算(2023-11-27~)
|
|
107
106
|
? {
|
|
108
107
|
price: (0, factory_1.acceptedOffers2amount)({ acceptedOffers: acceptedOffers4result }),
|
|
109
|
-
acceptedOffers:
|
|
108
|
+
acceptedOffers: []
|
|
110
109
|
}
|
|
111
110
|
: undefined);
|
|
112
111
|
return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
@@ -19,7 +19,6 @@ export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
19
19
|
pendingTransaction: factory.action.authorize.offer.eventService.IChevrePendingTransaction;
|
|
20
20
|
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
21
21
|
broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
|
|
22
|
-
useResultAcceptedOffers: boolean;
|
|
23
22
|
}): factory.action.authorize.offer.eventService.IAttributes<factory.service.webAPI.Identifier.Chevre>;
|
|
24
23
|
export declare function acceptedOffers2amount(params: {
|
|
25
24
|
acceptedOffers: IResultAcceptedOffer[];
|
|
@@ -91,7 +91,7 @@ function createAuthorizeSeatReservationActionAttributes(params) {
|
|
|
91
91
|
return {
|
|
92
92
|
project: transaction.project,
|
|
93
93
|
typeOf: factory.actionType.AuthorizeAction,
|
|
94
|
-
object: Object.assign(Object.assign({ typeOf: factory.action.authorize.offer.eventService.ObjectType.SeatReservation, event: authorizeObjectEvent, acceptedOffer: acceptedOffers, pendingTransaction: params.pendingTransaction }, (params.broker !== undefined) ? { broker: params.broker } : undefined), { useResultAcceptedOffers:
|
|
94
|
+
object: Object.assign(Object.assign({ typeOf: factory.action.authorize.offer.eventService.ObjectType.SeatReservation, event: authorizeObjectEvent, acceptedOffer: acceptedOffers, pendingTransaction: params.pendingTransaction }, (params.broker !== undefined) ? { broker: params.broker } : undefined), { useResultAcceptedOffers: false }),
|
|
95
95
|
agent: {
|
|
96
96
|
id: transaction.seller.id,
|
|
97
97
|
typeOf: transaction.seller.typeOf,
|
|
@@ -79,8 +79,7 @@ function authorize(params) {
|
|
|
79
79
|
acceptedOffers: [],
|
|
80
80
|
event: { id: params.object.event.id, typeOf: factory.eventType.ScreeningEvent },
|
|
81
81
|
transaction,
|
|
82
|
-
pendingTransaction
|
|
83
|
-
useResultAcceptedOffers: params.options.useResultAcceptedOffers
|
|
82
|
+
pendingTransaction
|
|
84
83
|
});
|
|
85
84
|
const failedAction = yield repos.action.start(failedActionAttributes);
|
|
86
85
|
yield repos.action.giveUp({ typeOf: failedAction.typeOf, id: failedAction.id, error });
|
|
@@ -92,8 +91,7 @@ function authorize(params) {
|
|
|
92
91
|
acceptedOffers,
|
|
93
92
|
event: screeningEvent,
|
|
94
93
|
transaction,
|
|
95
|
-
pendingTransaction
|
|
96
|
-
useResultAcceptedOffers: params.options.useResultAcceptedOffers
|
|
94
|
+
pendingTransaction
|
|
97
95
|
});
|
|
98
96
|
const action = yield repos.action.start(actionAttributes);
|
|
99
97
|
try {
|
|
@@ -115,7 +113,7 @@ function authorize(params) {
|
|
|
115
113
|
amount: eligibleMonetaryAmount,
|
|
116
114
|
requestBody: params.result.requestBody,
|
|
117
115
|
responseBody: params.result.responseBody,
|
|
118
|
-
acceptedOffers:
|
|
116
|
+
acceptedOffers: []
|
|
119
117
|
};
|
|
120
118
|
// add orderInTransaction(2024-01-15~)
|
|
121
119
|
if (params.options.useCreateOrderOnOfferAccepted) {
|
|
@@ -92,7 +92,7 @@ function changeOffers(params) {
|
|
|
92
92
|
.toDate(),
|
|
93
93
|
totalPrice: price
|
|
94
94
|
});
|
|
95
|
-
const actionResult = Object.assign(Object.assign({}, authorizeAction.result), { price: price, amount: eligibleMonetaryAmount, acceptedOffers:
|
|
95
|
+
const actionResult = Object.assign(Object.assign({}, authorizeAction.result), { price: price, amount: eligibleMonetaryAmount, acceptedOffers: [] });
|
|
96
96
|
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
97
97
|
yield repos.action.reStart({ id: authorizeAction.id });
|
|
98
98
|
try {
|
|
@@ -7,7 +7,6 @@ export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
|
7
7
|
event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id' | 'typeOf'>;
|
|
8
8
|
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
9
9
|
pendingTransaction: factory.action.authorize.offer.eventService.ICOAPendingTransaction;
|
|
10
|
-
useResultAcceptedOffers: boolean;
|
|
11
10
|
}): factory.action.authorize.offer.eventService.IAttributes<WebAPIIdentifier.COA>;
|
|
12
11
|
/**
|
|
13
12
|
* 供給情報から承認アクションの価格を導き出す
|
|
@@ -25,7 +25,7 @@ function createAuthorizeSeatReservationActionAttributes(params) {
|
|
|
25
25
|
acceptedOffer: params.acceptedOffers,
|
|
26
26
|
event: authorizeObjectEvent,
|
|
27
27
|
pendingTransaction: params.pendingTransaction,
|
|
28
|
-
useResultAcceptedOffers:
|
|
28
|
+
useResultAcceptedOffers: false
|
|
29
29
|
};
|
|
30
30
|
return {
|
|
31
31
|
project: transaction.project,
|
|
@@ -116,6 +116,12 @@ declare function authorize(params: {
|
|
|
116
116
|
useCheckByIdentifierIfNotYet: boolean;
|
|
117
117
|
useUnlockTransactionProcess: boolean;
|
|
118
118
|
};
|
|
119
|
+
sameAs?: {
|
|
120
|
+
/**
|
|
121
|
+
* 実行元タスクID
|
|
122
|
+
*/
|
|
123
|
+
id: string;
|
|
124
|
+
};
|
|
119
125
|
}): IAuthorizeOperation<{
|
|
120
126
|
/**
|
|
121
127
|
* 承認アクションID
|
|
@@ -280,7 +280,7 @@ exports.publishPaymentUrl = publishPaymentUrl;
|
|
|
280
280
|
function authorize(params) {
|
|
281
281
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
282
282
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
var _a, _b;
|
|
283
|
+
var _a, _b, _c;
|
|
284
284
|
const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
|
|
285
285
|
const paymentServiceType = params.paymentServiceType;
|
|
286
286
|
// 取引番号生成
|
|
@@ -336,29 +336,24 @@ function authorize(params) {
|
|
|
336
336
|
})({ action: repos.action });
|
|
337
337
|
const authorizeObject = Object.assign(Object.assign(Object.assign(Object.assign({}, params.object), { accountId, paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined);
|
|
338
338
|
// 承認アクションを開始する
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
typeOf: factory.actionType.AuthorizeAction,
|
|
342
|
-
object: authorizeObject,
|
|
343
|
-
agent: {
|
|
339
|
+
const taskId = (_b = params.sameAs) === null || _b === void 0 ? void 0 : _b.id;
|
|
340
|
+
const actionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.AuthorizeAction, object: authorizeObject, agent: {
|
|
344
341
|
typeOf: transaction.agent.typeOf,
|
|
345
342
|
id: transaction.agent.id
|
|
346
|
-
},
|
|
347
|
-
instrument: {
|
|
343
|
+
}, instrument: {
|
|
348
344
|
// typeOf: 'WebAPI',
|
|
349
345
|
typeOf: factory.assetTransactionType.Pay,
|
|
350
346
|
identifier: factory.action.authorize.paymentMethod.any.ServiceIdentifier.Chevre,
|
|
351
347
|
transactionNumber
|
|
352
|
-
},
|
|
353
|
-
recipient: {
|
|
348
|
+
}, recipient: {
|
|
354
349
|
typeOf: transaction.seller.typeOf,
|
|
355
350
|
id: transaction.seller.id,
|
|
356
351
|
name: (typeof transaction.seller.name === 'string')
|
|
357
352
|
? transaction.seller.name
|
|
358
|
-
: String((
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
|
|
353
|
+
: String((_c = transaction.seller.name) === null || _c === void 0 ? void 0 : _c.ja)
|
|
354
|
+
}, purpose: { typeOf: transaction.typeOf, id: transaction.id } }, (typeof taskId === 'string')
|
|
355
|
+
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-04-22~)
|
|
356
|
+
: undefined);
|
|
362
357
|
const action = yield repos.action.start(actionAttributes);
|
|
363
358
|
let payTransaction;
|
|
364
359
|
try {
|
|
@@ -406,10 +401,6 @@ function authorize(params) {
|
|
|
406
401
|
}
|
|
407
402
|
const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
|
|
408
403
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
409
|
-
// 取引プロセスロック解除(2024-04-20~)
|
|
410
|
-
if (params.options.useUnlockTransactionProcess) {
|
|
411
|
-
yield repos.transactionProcess.unlock({ typeOf: transaction.typeOf, id: transaction.id });
|
|
412
|
-
}
|
|
413
404
|
return { id: action.id };
|
|
414
405
|
});
|
|
415
406
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.aggregateOffers.IData):
|
|
6
|
+
export declare function call(data: factory.task.aggregateOffers.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.aggregateScreeningEvent.IData):
|
|
6
|
+
export declare function call(data: factory.task.aggregateScreeningEvent.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.aggregateScreeningEvent.IData):
|
|
6
|
+
export declare function call(data: factory.task.aggregateScreeningEvent.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: factory.task.authorizePayment.ITask):
|
|
6
|
+
export declare function call(params: factory.task.authorizePayment.ITask): IOperationExecute<void>;
|
|
@@ -28,24 +28,50 @@ const any_1 = require("../payment/any");
|
|
|
28
28
|
* タスク実行関数
|
|
29
29
|
*/
|
|
30
30
|
function call(params) {
|
|
31
|
-
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return (settings, options) => __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
if (settings.redisClient === undefined) {
|
|
33
33
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
// 遅延実行(executeByName)には対応しない
|
|
36
|
+
if (!options.executeById) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
40
|
+
const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepository(settings.redisClient, { lockExpiresInSeconds: 120 });
|
|
41
|
+
try {
|
|
42
|
+
yield (0, any_1.authorize)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } // タスクIDを関連付け(2024-04-20~)
|
|
43
|
+
}))({
|
|
44
|
+
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
45
|
+
action: actionRepo,
|
|
46
|
+
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
47
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
48
|
+
paymentAccepted: new sellerPaymentAccepted_1.MongoRepository(settings.connection),
|
|
49
|
+
paymentService: new paymentService_1.MongoRepository(settings.connection),
|
|
50
|
+
paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(settings.connection),
|
|
51
|
+
product: new product_1.MongoRepository(settings.connection),
|
|
52
|
+
task: new task_1.MongoRepository(settings.connection),
|
|
53
|
+
transaction: new transaction_1.MongoRepository(settings.connection),
|
|
54
|
+
transactionNumber: new transactionNumber_1.RedisRepository(settings.redisClient),
|
|
55
|
+
transactionProcess: transactionProcessRepo
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
let throwsError = true;
|
|
60
|
+
// アクションが存在すればタスクを実行済扱いにする
|
|
61
|
+
const action = (yield actionRepo.searchBySameAs({ sameAs: { id: { $eq: params.id } } })).shift();
|
|
62
|
+
if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
|
|
63
|
+
throwsError = false;
|
|
64
|
+
}
|
|
65
|
+
if (throwsError) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
// 取引プロセスロック解除(2024-04-20~)
|
|
71
|
+
if (params.data.options.useUnlockTransactionProcess) {
|
|
72
|
+
yield transactionProcessRepo.unlock({ typeOf: params.data.purpose.typeOf, id: params.data.purpose.id });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
49
75
|
});
|
|
50
76
|
}
|
|
51
77
|
exports.call = call;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.cancelMoneyTransfer.IData):
|
|
6
|
+
export declare function call(data: factory.task.cancelMoneyTransfer.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.cancelPendingReservation.IData):
|
|
6
|
+
export declare function call(data: factory.task.cancelPendingReservation.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.cancelReservation.IData):
|
|
6
|
+
export declare function call(data: factory.task.cancelReservation.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.checkResource.IData):
|
|
6
|
+
export declare function call(data: factory.task.checkResource.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmMoneyTransfer>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ConfirmMoneyTransfer>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmPayTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ConfirmPayTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterService>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterService>): IOperationExecute<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
@@ -6,7 +6,7 @@ import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
|
6
6
|
/**
|
|
7
7
|
* タスク実行関数
|
|
8
8
|
*/
|
|
9
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterServiceTransaction>):
|
|
9
|
+
export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterServiceTransaction>): IOperationExecute<void>;
|
|
10
10
|
export declare function confirmRegisterServiceTransaction(params: factory.action.interact.confirm.registerService.IAttributes): (repos: {
|
|
11
11
|
action: ActionRepo;
|
|
12
12
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
import { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
|
|
4
4
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
@@ -9,7 +9,7 @@ import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
|
9
9
|
/**
|
|
10
10
|
* タスク実行関数
|
|
11
11
|
*/
|
|
12
|
-
export declare function call(data: factory.task.IData<factory.taskName.ConfirmReserveTransaction>):
|
|
12
|
+
export declare function call(data: factory.task.IData<factory.taskName.ConfirmReserveTransaction>): IOperationExecute<void>;
|
|
13
13
|
/**
|
|
14
14
|
* 予約を確定する
|
|
15
15
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.CreateAccountingReport>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.CreateAccountingReport>): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.createEvent.IData):
|
|
6
|
+
export declare function call(data: factory.task.createEvent.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.DeleteTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.DeleteTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.GivePointAward>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.GivePointAward>): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.importEventCapacitiesFromCOA.IData):
|
|
6
|
+
export declare function call(data: factory.task.importEventCapacitiesFromCOA.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.importEventsFromCOA.IData):
|
|
6
|
+
export declare function call(data: factory.task.importEventsFromCOA.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.importOffersFromCOA.IData):
|
|
6
|
+
export declare function call(data: factory.task.importOffersFromCOA.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.moneyTransfer.IData):
|
|
6
|
+
export declare function call(data: factory.task.moneyTransfer.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.OnAssetTransactionStatusChanged>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.OnAssetTransactionStatusChanged>): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.onAuthorizationCreated.IData):
|
|
6
|
+
export declare function call(data: factory.task.onAuthorizationCreated.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.onEventChanged.IData):
|
|
6
|
+
export declare function call(data: factory.task.onEventChanged.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.OnOrderPaymentCompleted>): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.onResourceUpdated.IData):
|
|
6
|
+
export declare function call(data: factory.task.onResourceUpdated.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.pay.IData):
|
|
6
|
+
export declare function call(data: factory.task.pay.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.PlaceOrder>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.PlaceOrder>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(params: factory.task.refund.IData | factory.task.refund.ITask):
|
|
6
|
+
export declare function call(params: factory.task.refund.IData | factory.task.refund.ITask): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.registerService.IData):
|
|
6
|
+
export declare function call(data: factory.task.registerService.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.reserve.IData):
|
|
6
|
+
export declare function call(data: factory.task.reserve.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ReturnMoneyTransfer>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ReturnMoneyTransfer>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ReturnOrder>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ReturnOrder>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ReturnPayTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ReturnPayTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ReturnPointAward>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ReturnPointAward>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.ReturnReserveTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.ReturnReserveTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.sendEmailMessage.IData):
|
|
6
|
+
export declare function call(data: factory.task.sendEmailMessage.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.SendOrder>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.SendOrder>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.triggerWebhook.IData):
|
|
6
|
+
export declare function call(data: factory.task.triggerWebhook.IData): IOperationExecute<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import {
|
|
3
|
-
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
2
|
+
import type { IOperationExecute } from '../task';
|
|
4
3
|
/**
|
|
5
4
|
* タスク実行関数
|
|
6
5
|
*/
|
|
7
|
-
export declare function call(data: factory.task.useReservation.IData):
|
|
6
|
+
export declare function call(data: factory.task.useReservation.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.VoidMoneyTransferTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.VoidMoneyTransferTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.VoidPayTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.VoidPayTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.voidPayment.IData):
|
|
6
|
+
export declare function call(data: factory.task.voidPayment.IData): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): IOperationExecute<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IOperationExecute } from '../task';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(data: factory.task.IData<factory.taskName.VoidReserveTransaction>):
|
|
6
|
+
export declare function call(data: factory.task.IData<factory.taskName.VoidReserveTransaction>): IOperationExecute<void>;
|
|
@@ -2,7 +2,7 @@ import type { Connection } from 'mongoose';
|
|
|
2
2
|
import type { RedisClientType } from 'redis';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
import type { MongoRepository as TaskRepo } from '../repo/task';
|
|
5
|
-
|
|
5
|
+
interface IConnectionSettings {
|
|
6
6
|
/**
|
|
7
7
|
* MongoDBコネクション
|
|
8
8
|
*/
|
|
@@ -12,11 +12,16 @@ export interface IConnectionSettings {
|
|
|
12
12
|
*/
|
|
13
13
|
redisClient?: RedisClientType;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface IExecuteOptions {
|
|
16
|
+
executeById: boolean;
|
|
17
|
+
executeByName: boolean;
|
|
18
|
+
}
|
|
19
|
+
type TaskOperation<T> = (repos: {
|
|
16
20
|
task: TaskRepo;
|
|
17
21
|
}) => Promise<T>;
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
23
|
+
type IOperationExecute<T> = (settings: IConnectionSettings, options: IExecuteOptions) => Promise<T>;
|
|
24
|
+
declare function executeById(params: {
|
|
20
25
|
id: string;
|
|
21
26
|
executor?: {
|
|
22
27
|
name: string;
|
|
@@ -25,7 +30,7 @@ export declare function executeById(params: {
|
|
|
25
30
|
/**
|
|
26
31
|
* タスク名でタスクをひとつ実行する
|
|
27
32
|
*/
|
|
28
|
-
|
|
33
|
+
declare function executeByName<T extends factory.taskName>(params: {
|
|
29
34
|
name: T;
|
|
30
35
|
executor?: {
|
|
31
36
|
name: string;
|
|
@@ -34,23 +39,24 @@ export declare function executeByName<T extends factory.taskName>(params: {
|
|
|
34
39
|
/**
|
|
35
40
|
* タスクを実行する
|
|
36
41
|
*/
|
|
37
|
-
|
|
42
|
+
declare function execute(task: factory.task.ITask<factory.taskName>): IOperationExecute<void>;
|
|
38
43
|
/**
|
|
39
44
|
* 実行中ステータスのままになっているタスクをリトライする
|
|
40
45
|
*/
|
|
41
|
-
|
|
46
|
+
declare function retry(params: {
|
|
42
47
|
intervalInMinutes: number;
|
|
43
48
|
}): TaskOperation<void>;
|
|
44
49
|
/**
|
|
45
50
|
* トライ可能回数が0に達したタスクを実行中止する
|
|
46
51
|
*/
|
|
47
|
-
|
|
52
|
+
declare function abort(params: {
|
|
48
53
|
/**
|
|
49
54
|
* 最終トライ日時から何分経過したタスクを中止するか
|
|
50
55
|
*/
|
|
51
56
|
intervalInMinutes: number;
|
|
52
57
|
notify: boolean;
|
|
53
58
|
}): TaskOperation<void>;
|
|
54
|
-
|
|
59
|
+
declare function notifyAbortedTasks(params: {
|
|
55
60
|
dateAbortedGte: Date;
|
|
56
61
|
}): TaskOperation<void>;
|
|
62
|
+
export { IOperationExecute, executeById, executeByName, execute, retry, abort, notifyAbortedTasks };
|
|
@@ -42,7 +42,10 @@ function executeById(params) {
|
|
|
42
42
|
}
|
|
43
43
|
// タスクがなければ終了
|
|
44
44
|
if (task !== null) {
|
|
45
|
-
yield execute(task)(settings
|
|
45
|
+
yield execute(task)(settings, {
|
|
46
|
+
executeById: true,
|
|
47
|
+
executeByName: false
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
});
|
|
48
51
|
}
|
|
@@ -72,7 +75,10 @@ function executeByName(params) {
|
|
|
72
75
|
}
|
|
73
76
|
// タスクがなければ終了
|
|
74
77
|
if (task !== null) {
|
|
75
|
-
yield execute(task)(settings
|
|
78
|
+
yield execute(task)(settings, {
|
|
79
|
+
executeById: false,
|
|
80
|
+
executeByName: true
|
|
81
|
+
});
|
|
76
82
|
}
|
|
77
83
|
});
|
|
78
84
|
}
|
|
@@ -82,7 +88,7 @@ exports.executeByName = executeByName;
|
|
|
82
88
|
*/
|
|
83
89
|
function execute(task) {
|
|
84
90
|
const now = new Date();
|
|
85
|
-
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return (settings, options) => __awaiter(this, void 0, void 0, function* () {
|
|
86
92
|
const taskRepo = new (yield Promise.resolve().then(() => require('../repo/task'))).MongoRepository(settings.connection);
|
|
87
93
|
try {
|
|
88
94
|
// タスク名の関数が定義されていなければ、TypeErrorとなる
|
|
@@ -90,7 +96,7 @@ function execute(task) {
|
|
|
90
96
|
switch (task.name) {
|
|
91
97
|
case factory.taskName.AuthorizePayment:
|
|
92
98
|
case factory.taskName.Refund:
|
|
93
|
-
yield call(task)(settings);
|
|
99
|
+
yield call(task)(settings, options);
|
|
94
100
|
break;
|
|
95
101
|
default:
|
|
96
102
|
yield call(task.data)(settings);
|
package/package.json
CHANGED