@chevre/domain 21.2.0-alpha.10 → 21.2.0-alpha.100
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/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +10 -2
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/processPay.ts +5 -1
- package/example/src/chevre/processReserve.ts +4 -1
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchActions.ts +33 -0
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/example/src/playOnMoment.ts +24 -0
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +1 -54
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +98 -55
- package/lib/chevre/repo/assetTransaction.d.ts +25 -9
- package/lib/chevre/repo/assetTransaction.js +256 -85
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -5
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +19 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +17 -3
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +4 -2
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +32 -19
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +19 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +43 -3
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +71 -3
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +13 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +65 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +27 -3
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +51 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +25 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +49 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +29 -3
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +23 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -5
- package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +11 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +21 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +40 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +11 -3
- package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
- package/lib/chevre/repo/offerItemCondition.js +120 -0
- package/lib/chevre/repo/order.d.ts +55 -3
- package/lib/chevre/repo/order.js +56 -5
- package/lib/chevre/repo/reservation.d.ts +12 -4
- package/lib/chevre/repo/reservation.js +16 -44
- package/lib/chevre/repo/seller.js +19 -19
- package/lib/chevre/repo/task.d.ts +42 -2
- package/lib/chevre/repo/task.js +90 -9
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +174 -54
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +5 -1
- package/lib/chevre/service/assetTransaction/pay.js +18 -32
- package/lib/chevre/service/assetTransaction/refund.js +1 -23
- package/lib/chevre/service/assetTransaction/registerService.js +1 -25
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +15 -5
- package/lib/chevre/service/assetTransaction/reserve/factory.js +122 -58
- package/lib/chevre/service/assetTransaction/reserve.d.ts +10 -1
- package/lib/chevre/service/assetTransaction/reserve.js +85 -69
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize.js +8 -2
- package/lib/chevre/service/offer/event/factory.d.ts +3 -0
- package/lib/chevre/service/offer/event/factory.js +16 -5
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +41 -81
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
- package/lib/chevre/service/order/onOrderUpdated.d.ts +16 -0
- package/lib/chevre/service/order/onOrderUpdated.js +22 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -0
- package/lib/chevre/service/order/placeOrder.js +41 -24
- package/lib/chevre/service/order/returnOrder.d.ts +1 -0
- package/lib/chevre/service/order/returnOrder.js +7 -12
- package/lib/chevre/service/order/sendOrder.d.ts +1 -0
- package/lib/chevre/service/order/sendOrder.js +7 -10
- package/lib/chevre/service/order.d.ts +2 -1
- package/lib/chevre/service/order.js +3 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +9 -5
- package/lib/chevre/service/payment/any.js +80 -18
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +21 -15
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +7 -6
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/validation.js +54 -31
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +5 -4
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
- package/lib/chevre/service/reserve/cancelReservation.js +147 -139
- package/lib/chevre/service/reserve/checkInReservation.d.ts +9 -4
- package/lib/chevre/service/reserve/checkInReservation.js +77 -3
- package/lib/chevre/service/reserve/confirmReservation.d.ts +7 -4
- package/lib/chevre/service/reserve/confirmReservation.js +125 -58
- package/lib/chevre/service/reserve/factory.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +17 -5
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +26 -24
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.d.ts +7 -3
- package/lib/chevre/service/reserve/useReservation.js +61 -71
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
- package/lib/chevre/service/reserve.d.ts +3 -2
- package/lib/chevre/service/reserve.js +4 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +5 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +108 -0
- package/lib/chevre/service/task/placeOrder.js +1 -1
- package/lib/chevre/service/task/reserve.js +10 -7
- package/lib/chevre/service/task/returnOrder.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/sendOrder.js +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +7 -0
- package/lib/chevre/service/task/useReservation.js +36 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
- package/lib/chevre/service/transaction/orderProgramMembership.js +6 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
- package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder.js +225 -35
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +15 -5
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
- package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
- package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
- package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
- package/lib/chevre/service/task/deleteOrder.js +0 -35
|
@@ -32,21 +32,12 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
36
36
|
// MongoDB検索条件
|
|
37
37
|
const andConditions = [];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
42
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
43
|
-
andConditions.push({
|
|
44
|
-
'project.id': {
|
|
45
|
-
$eq: params.project.id.$eq
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
50
41
|
}
|
|
51
42
|
const nameRegex = params.name;
|
|
52
43
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
@@ -67,7 +58,7 @@ class MongoRepository {
|
|
|
67
58
|
]
|
|
68
59
|
});
|
|
69
60
|
}
|
|
70
|
-
const branchCodeEq = (
|
|
61
|
+
const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
71
62
|
if (typeof branchCodeEq === 'string') {
|
|
72
63
|
andConditions.push({
|
|
73
64
|
branchCode: {
|
|
@@ -75,7 +66,7 @@ class MongoRepository {
|
|
|
75
66
|
}
|
|
76
67
|
});
|
|
77
68
|
}
|
|
78
|
-
const branchCodeRegex = (
|
|
69
|
+
const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
|
|
79
70
|
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
80
71
|
andConditions.push({
|
|
81
72
|
branchCode: {
|
|
@@ -83,7 +74,7 @@ class MongoRepository {
|
|
|
83
74
|
}
|
|
84
75
|
});
|
|
85
76
|
}
|
|
86
|
-
const additionalPropertyAll = (
|
|
77
|
+
const additionalPropertyAll = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$all;
|
|
87
78
|
if (Array.isArray(additionalPropertyAll)) {
|
|
88
79
|
andConditions.push({
|
|
89
80
|
additionalProperty: {
|
|
@@ -92,7 +83,7 @@ class MongoRepository {
|
|
|
92
83
|
}
|
|
93
84
|
});
|
|
94
85
|
}
|
|
95
|
-
const additionalPropertyIn = (
|
|
86
|
+
const additionalPropertyIn = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$in;
|
|
96
87
|
if (Array.isArray(additionalPropertyIn)) {
|
|
97
88
|
andConditions.push({
|
|
98
89
|
additionalProperty: {
|
|
@@ -101,7 +92,7 @@ class MongoRepository {
|
|
|
101
92
|
}
|
|
102
93
|
});
|
|
103
94
|
}
|
|
104
|
-
const additionalPropertyNin = (
|
|
95
|
+
const additionalPropertyNin = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$nin;
|
|
105
96
|
if (Array.isArray(additionalPropertyNin)) {
|
|
106
97
|
andConditions.push({
|
|
107
98
|
additionalProperty: {
|
|
@@ -109,7 +100,7 @@ class MongoRepository {
|
|
|
109
100
|
}
|
|
110
101
|
});
|
|
111
102
|
}
|
|
112
|
-
const additionalPropertyElemMatch = (
|
|
103
|
+
const additionalPropertyElemMatch = (_h = params.additionalProperty) === null || _h === void 0 ? void 0 : _h.$elemMatch;
|
|
113
104
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
114
105
|
andConditions.push({
|
|
115
106
|
additionalProperty: {
|
|
@@ -118,6 +109,15 @@ class MongoRepository {
|
|
|
118
109
|
}
|
|
119
110
|
});
|
|
120
111
|
}
|
|
112
|
+
const hasMerchantReturnPolicyItemConditionIdEq = (_l = (_k = (_j = params.hasMerchantReturnPolicy) === null || _j === void 0 ? void 0 : _j.itemCondition) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
113
|
+
if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
114
|
+
andConditions.push({
|
|
115
|
+
'hasMerchantReturnPolicy.itemCondition.id': {
|
|
116
|
+
$exists: true,
|
|
117
|
+
$eq: hasMerchantReturnPolicyItemConditionIdEq
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
121
|
return andConditions;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
@@ -17,6 +17,9 @@ interface IStatus {
|
|
|
17
17
|
export interface IAggregateTask {
|
|
18
18
|
statuses: IStatus[];
|
|
19
19
|
}
|
|
20
|
+
interface IOptionOnCreate {
|
|
21
|
+
emitImmediately: boolean;
|
|
22
|
+
}
|
|
20
23
|
/**
|
|
21
24
|
* タスクリポジトリ
|
|
22
25
|
*/
|
|
@@ -24,13 +27,43 @@ export declare class MongoRepository {
|
|
|
24
27
|
readonly taskModel: typeof Model;
|
|
25
28
|
constructor(connection: Connection);
|
|
26
29
|
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
|
|
27
|
-
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<{
|
|
30
|
+
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[], options: IOptionOnCreate): Promise<{
|
|
28
31
|
id: string;
|
|
29
32
|
}[]>;
|
|
30
|
-
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook
|
|
33
|
+
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
|
|
34
|
+
executeById(params: {
|
|
35
|
+
id: string;
|
|
36
|
+
executor: {
|
|
37
|
+
name: string;
|
|
38
|
+
};
|
|
39
|
+
}): Promise<factory.task.ITask<factory.taskName> | null>;
|
|
31
40
|
executeOneByName<T extends factory.taskName>(params: {
|
|
32
41
|
name: T;
|
|
42
|
+
executor: {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
33
45
|
}): Promise<factory.task.ITask<T> | null>;
|
|
46
|
+
/**
|
|
47
|
+
* 一定期間遅延したタスクを実行する
|
|
48
|
+
*/
|
|
49
|
+
executeTasks(params: {
|
|
50
|
+
now: Date;
|
|
51
|
+
/**
|
|
52
|
+
* 指定期間遅延しているタスクを実行する
|
|
53
|
+
*/
|
|
54
|
+
delayInSeconds: number;
|
|
55
|
+
limit: number;
|
|
56
|
+
name: {
|
|
57
|
+
/**
|
|
58
|
+
* 指定タスクのみ実行する
|
|
59
|
+
*/
|
|
60
|
+
$in?: factory.taskName[];
|
|
61
|
+
/**
|
|
62
|
+
* 指定タスク以外のみ実行する
|
|
63
|
+
*/
|
|
64
|
+
$nin?: factory.taskName[];
|
|
65
|
+
};
|
|
66
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
34
67
|
retry(params: {
|
|
35
68
|
intervalInMinutes: number;
|
|
36
69
|
}): Promise<void>;
|
|
@@ -60,6 +93,13 @@ export declare class MongoRepository {
|
|
|
60
93
|
}): Promise<void>;
|
|
61
94
|
deleteByName(params: {
|
|
62
95
|
name: factory.taskName;
|
|
96
|
+
status?: {
|
|
97
|
+
$eq?: factory.taskStatus;
|
|
98
|
+
};
|
|
99
|
+
runsAt?: {
|
|
100
|
+
$gte: Date;
|
|
101
|
+
$lte: Date;
|
|
102
|
+
};
|
|
63
103
|
}): Promise<import("mongodb").DeleteResult>;
|
|
64
104
|
countDelayedTasks(params: {
|
|
65
105
|
delayInSeconds: number;
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.MongoRepository = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const task_1 = require("./mongoose/schemas/task");
|
|
16
|
+
const task_2 = require("../eventEmitter/task");
|
|
16
17
|
/**
|
|
17
18
|
* タスク実行時のソート条件
|
|
18
19
|
*/
|
|
@@ -149,27 +150,43 @@ class MongoRepository {
|
|
|
149
150
|
}
|
|
150
151
|
return andConditions;
|
|
151
152
|
}
|
|
152
|
-
saveMany(taskAttributes) {
|
|
153
|
+
saveMany(taskAttributes, options) {
|
|
153
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const emitImmediately = (options === null || options === void 0 ? void 0 : options.emitImmediately) === true;
|
|
154
156
|
if (taskAttributes.length > 0) {
|
|
155
157
|
const result = yield this.taskModel.insertMany(taskAttributes, { ordered: false, rawResult: true });
|
|
156
158
|
if (result.insertedCount !== taskAttributes.length) {
|
|
157
159
|
throw new factory.errors.ServiceUnavailable('all tasks not saved');
|
|
158
160
|
}
|
|
159
|
-
|
|
160
|
-
return Object.values(result.insertedIds)
|
|
161
|
+
const savedTasks = Object.values(result.insertedIds)
|
|
161
162
|
.map((objectId) => {
|
|
162
163
|
return { id: objectId.toHexString() };
|
|
163
164
|
});
|
|
165
|
+
if (emitImmediately) {
|
|
166
|
+
savedTasks.forEach((savedTask) => {
|
|
167
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
168
|
+
id: savedTask.id,
|
|
169
|
+
status: factory.taskStatus.Ready
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
// taskAttributes.forEach((savedTask) => {
|
|
173
|
+
// taskEventEmitter.emitTaskStatusChanged({
|
|
174
|
+
// name: savedTask.name,
|
|
175
|
+
// status: factory.taskStatus.Ready
|
|
176
|
+
// });
|
|
177
|
+
// });
|
|
178
|
+
}
|
|
179
|
+
// return result.ops;
|
|
180
|
+
return savedTasks;
|
|
164
181
|
}
|
|
165
182
|
else {
|
|
166
183
|
return [];
|
|
167
184
|
}
|
|
168
185
|
});
|
|
169
186
|
}
|
|
170
|
-
createInformTaskIfNotExist(params) {
|
|
187
|
+
createInformTaskIfNotExist(params, options) {
|
|
171
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
yield this.taskModel.findOneAndUpdate({
|
|
189
|
+
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
173
190
|
'project.id': { $eq: params.project.id },
|
|
174
191
|
name: params.name,
|
|
175
192
|
'data.object.id': {
|
|
@@ -177,7 +194,38 @@ class MongoRepository {
|
|
|
177
194
|
$eq: String(params.data.object.id)
|
|
178
195
|
}
|
|
179
196
|
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
197
|
+
.select({ _id: 1 })
|
|
180
198
|
.exec();
|
|
199
|
+
if (options.emitImmediately) {
|
|
200
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
201
|
+
id: createdTask.id,
|
|
202
|
+
name: params.name,
|
|
203
|
+
status: factory.taskStatus.Ready
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
executeById(params) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const doc = yield this.taskModel.findOneAndUpdate({
|
|
211
|
+
status: factory.taskStatus.Ready,
|
|
212
|
+
runsAt: { $lt: new Date() },
|
|
213
|
+
_id: { $eq: params.id }
|
|
214
|
+
}, {
|
|
215
|
+
status: factory.taskStatus.Running,
|
|
216
|
+
lastTriedAt: new Date(),
|
|
217
|
+
$inc: {
|
|
218
|
+
remainingNumberOfTries: -1,
|
|
219
|
+
numberOfTried: 1 // トライ回数増やす
|
|
220
|
+
},
|
|
221
|
+
executor: params.executor
|
|
222
|
+
}, { new: true })
|
|
223
|
+
.exec();
|
|
224
|
+
if (doc === null) {
|
|
225
|
+
// tslint:disable-next-line:no-null-keyword
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return doc.toObject();
|
|
181
229
|
});
|
|
182
230
|
}
|
|
183
231
|
executeOneByName(params) {
|
|
@@ -192,7 +240,8 @@ class MongoRepository {
|
|
|
192
240
|
$inc: {
|
|
193
241
|
remainingNumberOfTries: -1,
|
|
194
242
|
numberOfTried: 1 // トライ回数増やす
|
|
195
|
-
}
|
|
243
|
+
},
|
|
244
|
+
executor: params.executor
|
|
196
245
|
}, { new: true })
|
|
197
246
|
.sort(sortOrder4executionOfTasks)
|
|
198
247
|
.exec();
|
|
@@ -203,6 +252,35 @@ class MongoRepository {
|
|
|
203
252
|
return doc.toObject();
|
|
204
253
|
});
|
|
205
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* 一定期間遅延したタスクを実行する
|
|
257
|
+
*/
|
|
258
|
+
executeTasks(params) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
const runsAtLt = moment(params.now)
|
|
261
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
262
|
+
.toDate();
|
|
263
|
+
const delayedTasks = yield this.taskModel.find(Object.assign(Object.assign({ status: { $eq: factory.taskStatus.Ready }, runsAt: { $lt: runsAtLt } }, (Array.isArray(params.name.$in)) ? { name: { $in: params.name.$in } } : undefined), (Array.isArray(params.name.$nin)) ? { name: { $nin: params.name.$nin } } : undefined))
|
|
264
|
+
.select({
|
|
265
|
+
_id: 1,
|
|
266
|
+
name: 1,
|
|
267
|
+
status: 1
|
|
268
|
+
})
|
|
269
|
+
.limit(params.limit)
|
|
270
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
271
|
+
.exec();
|
|
272
|
+
if (delayedTasks.length > 0) {
|
|
273
|
+
delayedTasks.forEach((delayedTask) => {
|
|
274
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
275
|
+
id: delayedTask.id,
|
|
276
|
+
name: delayedTask.name,
|
|
277
|
+
status: delayedTask.status
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return delayedTasks;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
206
284
|
retry(params) {
|
|
207
285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
286
|
const lastTriedAtShoudBeLessThan = moment()
|
|
@@ -333,10 +411,13 @@ class MongoRepository {
|
|
|
333
411
|
});
|
|
334
412
|
}
|
|
335
413
|
deleteByName(params) {
|
|
414
|
+
var _a, _b;
|
|
336
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
-
return this.taskModel.deleteMany({
|
|
338
|
-
|
|
339
|
-
|
|
416
|
+
return this.taskModel.deleteMany(Object.assign(Object.assign({ name: { $eq: params.name } }, (typeof ((_a = params.status) === null || _a === void 0 ? void 0 : _a.$eq) === 'string') ? { status: { $eq: params.status.$eq } } : undefined), (((_b = params.runsAt) === null || _b === void 0 ? void 0 : _b.$gte) instanceof Date)
|
|
417
|
+
? {
|
|
418
|
+
runsAt: { $gte: params.runsAt.$gte, $lte: params.runsAt.$lte }
|
|
419
|
+
}
|
|
420
|
+
: undefined))
|
|
340
421
|
.exec();
|
|
341
422
|
});
|
|
342
423
|
}
|
|
@@ -40,6 +40,8 @@ export declare class MongoRepository {
|
|
|
40
40
|
findById<T extends factory.transactionType>(params: {
|
|
41
41
|
typeOf: T;
|
|
42
42
|
id: string;
|
|
43
|
+
inclusion?: string[];
|
|
44
|
+
exclusion?: string[];
|
|
43
45
|
}): Promise<factory.transaction.ITransaction<T>>;
|
|
44
46
|
/**
|
|
45
47
|
* 進行中の取引を取得する
|
|
@@ -111,7 +113,13 @@ export declare class MongoRepository {
|
|
|
111
113
|
$in: T[];
|
|
112
114
|
};
|
|
113
115
|
status: factory.transactionStatusType;
|
|
114
|
-
|
|
116
|
+
id?: string;
|
|
117
|
+
tasksExportAction: {
|
|
118
|
+
agent: {
|
|
119
|
+
name: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}): Promise<Pick<factory.transaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
|
|
115
123
|
/**
|
|
116
124
|
* タスクエクスポートリトライ
|
|
117
125
|
* TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
|
|
@@ -119,6 +127,16 @@ export declare class MongoRepository {
|
|
|
119
127
|
reexportTasks(params: {
|
|
120
128
|
intervalInMinutes: number;
|
|
121
129
|
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
132
|
+
*/
|
|
133
|
+
exportTasks(params: {
|
|
134
|
+
now: Date;
|
|
135
|
+
delayInSeconds: number;
|
|
136
|
+
status: {
|
|
137
|
+
$in: factory.transactionStatusType[];
|
|
138
|
+
};
|
|
139
|
+
}): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
|
|
122
140
|
/**
|
|
123
141
|
* set task status exported by transaction id
|
|
124
142
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -130,7 +148,9 @@ export declare class MongoRepository {
|
|
|
130
148
|
* 取引を期限切れにする
|
|
131
149
|
*/
|
|
132
150
|
makeExpired(params: {
|
|
133
|
-
expires:
|
|
151
|
+
expires: {
|
|
152
|
+
$lt: Date;
|
|
153
|
+
};
|
|
134
154
|
}): Promise<void>;
|
|
135
155
|
/**
|
|
136
156
|
* 取引を中止する
|
|
@@ -150,7 +170,7 @@ export declare class MongoRepository {
|
|
|
150
170
|
/**
|
|
151
171
|
* 特定の取引を更新する(汎用)
|
|
152
172
|
*/
|
|
153
|
-
|
|
173
|
+
findByIdAndUpdateInProgress(params: {
|
|
154
174
|
id: string;
|
|
155
175
|
update: {
|
|
156
176
|
$set?: any;
|