@chevre/domain 21.7.0-alpha.8 → 21.7.0-alpha.9
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/migrateAuthorizePaymentActionResult.ts +3 -3
- package/example/src/chevre/unsetUnnecessaryFields.ts +17 -11
- package/lib/chevre/repo/event.d.ts +12 -0
- package/lib/chevre/repo/event.js +11 -0
- package/lib/chevre/repo/transaction.d.ts +4 -0
- package/lib/chevre/repo/transaction.js +6 -0
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +42 -0
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +1 -1
|
@@ -20,10 +20,10 @@ async function main() {
|
|
|
20
20
|
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
21
21
|
'result.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
22
22
|
startDate: {
|
|
23
|
-
$gte: moment('
|
|
24
|
-
.toDate(),
|
|
25
|
-
$lte: moment('2023-08-01T00:00:00Z')
|
|
23
|
+
$gte: moment('2022-08-16T00:00:00Z')
|
|
26
24
|
.toDate()
|
|
25
|
+
// $lte: moment('2023-08-01T00:00:00Z')
|
|
26
|
+
// .toDate()
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
2
3
|
import * as mongoose from 'mongoose';
|
|
3
4
|
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
5
6
|
|
|
7
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
+
|
|
6
9
|
async function main() {
|
|
7
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
11
|
|
|
9
|
-
const
|
|
12
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
13
|
|
|
11
14
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
13
|
-
filter: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
16
|
+
filter: {
|
|
17
|
+
'project.id': { $eq: PROJECT_ID },
|
|
18
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
19
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
20
|
+
startDate: {
|
|
21
|
+
$lte: moment('2023-08-16T07:26:00Z')
|
|
22
|
+
.toDate()
|
|
23
|
+
},
|
|
24
|
+
'object.authorizeActions': { $exists: true }
|
|
25
|
+
},
|
|
26
|
+
$unset: { 'object.authorizeActions': 1 }
|
|
21
27
|
});
|
|
22
|
-
console.log('unset processed.', updateResult);
|
|
28
|
+
console.log('unset processed.', updateResult, 'PROJECT_ID:', PROJECT_ID);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
main()
|
|
@@ -252,6 +252,18 @@ export declare class MongoRepository {
|
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
254
|
}): Promise<import("mongodb").DeleteResult>;
|
|
255
|
+
deleteManyEndedByIds(params: {
|
|
256
|
+
typeOf: {
|
|
257
|
+
$in: factory.eventType[];
|
|
258
|
+
};
|
|
259
|
+
project: {
|
|
260
|
+
id: string;
|
|
261
|
+
};
|
|
262
|
+
ids: string[];
|
|
263
|
+
endDate: {
|
|
264
|
+
$lte: Date;
|
|
265
|
+
};
|
|
266
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
255
267
|
deleteByProject(params: {
|
|
256
268
|
project: {
|
|
257
269
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -966,6 +966,17 @@ class MongoRepository {
|
|
|
966
966
|
.exec();
|
|
967
967
|
});
|
|
968
968
|
}
|
|
969
|
+
deleteManyEndedByIds(params) {
|
|
970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
971
|
+
return this.eventModel.deleteMany({
|
|
972
|
+
typeOf: { $in: params.typeOf.$in },
|
|
973
|
+
'project.id': { $eq: params.project.id },
|
|
974
|
+
_id: { $in: params.ids },
|
|
975
|
+
endDate: { $lte: params.endDate.$lte }
|
|
976
|
+
})
|
|
977
|
+
.exec();
|
|
978
|
+
});
|
|
979
|
+
}
|
|
969
980
|
deleteByProject(params) {
|
|
970
981
|
return __awaiter(this, void 0, void 0, function* () {
|
|
971
982
|
yield this.eventModel.deleteMany({
|
|
@@ -190,6 +190,10 @@ export declare class MongoRepository {
|
|
|
190
190
|
findByIdAndDelete(params: {
|
|
191
191
|
id: string;
|
|
192
192
|
}): Promise<void>;
|
|
193
|
+
unsetUnnecessaryFields(params: {
|
|
194
|
+
filter: any;
|
|
195
|
+
$unset: any;
|
|
196
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
193
197
|
aggregatePlaceOrder(params: {
|
|
194
198
|
project?: {
|
|
195
199
|
id?: {
|
|
@@ -770,6 +770,12 @@ class MongoRepository {
|
|
|
770
770
|
.exec();
|
|
771
771
|
});
|
|
772
772
|
}
|
|
773
|
+
unsetUnnecessaryFields(params) {
|
|
774
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
775
|
+
return this.transactionModel.updateMany(params.filter, { $unset: params.$unset })
|
|
776
|
+
.exec();
|
|
777
|
+
});
|
|
778
|
+
}
|
|
773
779
|
aggregatePlaceOrder(params) {
|
|
774
780
|
return __awaiter(this, void 0, void 0, function* () {
|
|
775
781
|
const statuses = yield Promise.all([
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
2
3
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
4
|
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
4
5
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
@@ -11,6 +12,7 @@ declare function deleteOrder(params: {
|
|
|
11
12
|
object: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'confirmationNumber' | 'orderDate' | 'orderNumber'>;
|
|
12
13
|
}): (repos: {
|
|
13
14
|
accountingReport: AccountingReportRepo;
|
|
15
|
+
event: EventRepo;
|
|
14
16
|
order: OrderRepo;
|
|
15
17
|
ownershipInfo: OwnershipInfoRepo;
|
|
16
18
|
reservation: ReservationRepo;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.deleteOrder = void 0;
|
|
13
13
|
const factory_1 = require("../delivery/factory");
|
|
14
14
|
const factory = require("../../factory");
|
|
15
|
+
const settings_1 = require("../../settings");
|
|
15
16
|
/**
|
|
16
17
|
* 注文に関わるリソースを削除する
|
|
17
18
|
* 冪等性を確保すること
|
|
@@ -38,6 +39,10 @@ function deleteOrder(params) {
|
|
|
38
39
|
}
|
|
39
40
|
// 経理レポート削除
|
|
40
41
|
yield repos.accountingReport.deleteByOrderNumber({ mainEntity: { orderNumber: order.orderNumber } });
|
|
42
|
+
// 終了済の関連イベントを削除(2023-08-16~)
|
|
43
|
+
if (settings_1.USE_DELETE_EVENT_BY_ORDER) {
|
|
44
|
+
yield deleteEventsByOrder(order)(repos);
|
|
45
|
+
}
|
|
41
46
|
// 注文削除
|
|
42
47
|
yield repos.order.deleteByOrderNumber({ orderNumber: order.orderNumber });
|
|
43
48
|
});
|
|
@@ -73,3 +78,40 @@ function deleteOwnershipInfosByOrder(order) {
|
|
|
73
78
|
}
|
|
74
79
|
});
|
|
75
80
|
}
|
|
81
|
+
function deleteEventsByOrder(order) {
|
|
82
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
|
|
85
|
+
const reservationForIds = acceptedOffers.filter((o) => {
|
|
86
|
+
return (o.itemOffered.typeOf === factory.reservationType.EventReservation
|
|
87
|
+
|| o.itemOffered.typeOf === factory.reservationType.BusReservation)
|
|
88
|
+
&& typeof o.itemOffered.reservationFor.id === 'string';
|
|
89
|
+
})
|
|
90
|
+
.map((o) => {
|
|
91
|
+
return String(o.itemOffered.reservationFor.id);
|
|
92
|
+
});
|
|
93
|
+
if (reservationForIds.length > 0) {
|
|
94
|
+
for (const reservationForId of reservationForIds) {
|
|
95
|
+
// 関連注文が存在しなければ削除
|
|
96
|
+
const relatedOrders = yield repos.order.search({
|
|
97
|
+
limit: 1,
|
|
98
|
+
page: 1,
|
|
99
|
+
project: { id: { $eq: order.project.id } },
|
|
100
|
+
acceptedOffers: {
|
|
101
|
+
itemOffered: {
|
|
102
|
+
reservationFor: { ids: [reservationForId] }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, { _id: 1 });
|
|
106
|
+
if (relatedOrders.length === 0) {
|
|
107
|
+
yield repos.event.deleteManyEndedByIds({
|
|
108
|
+
typeOf: { $in: [factory.eventType.Event, factory.eventType.ScreeningEvent] },
|
|
109
|
+
project: { id: order.project.id },
|
|
110
|
+
ids: [reservationForId],
|
|
111
|
+
endDate: { $lte: now }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -13,6 +13,7 @@ exports.call = void 0;
|
|
|
13
13
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
14
14
|
const action_1 = require("../../repo/action");
|
|
15
15
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
|
+
const event_1 = require("../../repo/event");
|
|
16
17
|
const order_1 = require("../../repo/order");
|
|
17
18
|
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
18
19
|
const reservation_1 = require("../../repo/reservation");
|
|
@@ -28,6 +29,7 @@ function call(data) {
|
|
|
28
29
|
accountingReport: new accountingReport_1.MongoRepository(settings.connection),
|
|
29
30
|
action: new action_1.MongoRepository(settings.connection),
|
|
30
31
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
32
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
31
33
|
order: new order_1.MongoRepository(settings.connection),
|
|
32
34
|
ownershipInfo: new ownershipInfo_1.MongoRepository(settings.connection),
|
|
33
35
|
reservation: new reservation_1.MongoRepository(settings.connection),
|
|
@@ -2,6 +2,7 @@ import * as factory from '../../factory';
|
|
|
2
2
|
import { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
|
|
3
3
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
4
4
|
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
5
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
5
6
|
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
6
7
|
import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
|
|
7
8
|
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
@@ -15,6 +16,7 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
|
|
|
15
16
|
accountingReport: AccountingReportRepo;
|
|
16
17
|
action: ActionRepo;
|
|
17
18
|
assetTransaction: AssetTransactionRepo;
|
|
19
|
+
event: EventRepo;
|
|
18
20
|
order: OrderRepo;
|
|
19
21
|
ownershipInfo: OwnershipInfoRepo;
|
|
20
22
|
reservation: ReservationRepo;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
|
41
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
42
42
|
export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
43
43
|
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
44
|
+
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
44
45
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
45
46
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
46
47
|
/**
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -73,6 +73,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
73
73
|
// : [];
|
|
74
74
|
exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
|
|
75
75
|
exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
|
|
76
|
+
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
76
77
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
77
78
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
78
79
|
: 0;
|
package/package.json
CHANGED