@chevre/domain 21.2.0-alpha.144 → 21.2.0-alpha.146
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/findScreeningRoomsByBranchCode.ts +4 -3
- package/example/src/chevre/searchPermissions.ts +54 -0
- package/example/src/chevre/searchScreeningRooms.ts +2 -1
- package/example/src/chevre/syncScreeningRoomsAll.ts +1 -1
- package/lib/chevre/repo/member.d.ts +14 -0
- package/lib/chevre/repo/member.js +27 -0
- package/lib/chevre/repo/place.d.ts +13 -12
- package/lib/chevre/repo/place.js +478 -367
- package/lib/chevre/repo/role.d.ts +7 -0
- package/lib/chevre/repo/role.js +36 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/event.js +2 -1
- package/lib/chevre/service/iam.d.ts +6 -2
- package/lib/chevre/service/iam.js +23 -9
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -6
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +3 -1
- package/package.json +1 -1
|
@@ -17,6 +17,13 @@ export declare class MongoRepository {
|
|
|
17
17
|
static CREATE_MONGO_CONDITIONS(params: factory.iam.IRoleSearchConditions): any[];
|
|
18
18
|
count(params: factory.iam.IRoleSearchConditions): Promise<number>;
|
|
19
19
|
search(params: factory.iam.IRoleSearchConditions): Promise<IRole[]>;
|
|
20
|
+
aggregatePermissions(params: {
|
|
21
|
+
roleName: {
|
|
22
|
+
$in: string[];
|
|
23
|
+
};
|
|
24
|
+
}): Promise<{
|
|
25
|
+
_id: string;
|
|
26
|
+
}[]>;
|
|
20
27
|
findById(params: {
|
|
21
28
|
id: string;
|
|
22
29
|
}): Promise<IRole>;
|
package/lib/chevre/repo/role.js
CHANGED
|
@@ -97,6 +97,42 @@ class MongoRepository {
|
|
|
97
97
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
+
aggregatePermissions(params) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const matchStages = [
|
|
103
|
+
{ $match: { roleName: { $in: params.roleName.$in } } }
|
|
104
|
+
];
|
|
105
|
+
const aggregate = this.roleModel.aggregate([
|
|
106
|
+
// ...(typeof params.sort?.productID === 'number')
|
|
107
|
+
// ? [{ $sort: { productID: params.sort.productID } }]
|
|
108
|
+
// : [],
|
|
109
|
+
...matchStages,
|
|
110
|
+
{
|
|
111
|
+
$unwind: {
|
|
112
|
+
path: '$permissions'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
$project: {
|
|
117
|
+
_id: 0,
|
|
118
|
+
permission: '$permissions'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
$group: {
|
|
123
|
+
_id: '$permission'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]);
|
|
127
|
+
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
128
|
+
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
129
|
+
// aggregate.limit(params.limit * page)
|
|
130
|
+
// .skip(params.limit * (page - 1));
|
|
131
|
+
// }
|
|
132
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
133
|
+
.exec();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
100
136
|
findById(params) {
|
|
101
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
138
|
const doc = yield this.roleModel.findOne({
|
|
@@ -81,7 +81,8 @@ function aggregateByEvent(params) {
|
|
|
81
81
|
}
|
|
82
82
|
const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
|
|
83
83
|
branchCode: { $eq: event.location.branchCode },
|
|
84
|
-
containedInPlace: { id: { $eq: movieTheaterId } }
|
|
84
|
+
containedInPlace: { id: { $eq: movieTheaterId } },
|
|
85
|
+
useScreeningRoomType: settings_1.USE_READ_SCREENING_ROOM_TYPE
|
|
85
86
|
});
|
|
86
87
|
// 予約集計
|
|
87
88
|
const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
|
|
@@ -236,7 +236,7 @@ function searchEventSeatOffers(params) {
|
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
$projection: params.$projection
|
|
239
|
-
});
|
|
239
|
+
}, settings_1.USE_READ_SCREENING_ROOM_TYPE);
|
|
240
240
|
if (seats.length > 0) {
|
|
241
241
|
const availabilities = yield repos.stockHolder.searchHolders({
|
|
242
242
|
project: { id: params.event.project.id },
|
|
@@ -21,6 +21,7 @@ const difference = require("lodash.difference");
|
|
|
21
21
|
const moment = require("moment-timezone");
|
|
22
22
|
const credentials_1 = require("../credentials");
|
|
23
23
|
const factory = require("../factory");
|
|
24
|
+
const settings_1 = require("../settings");
|
|
24
25
|
const offer_1 = require("./offer");
|
|
25
26
|
const debug = createDebug('chevre-domain:service:event');
|
|
26
27
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
@@ -120,7 +121,7 @@ function importFromCOA(params) {
|
|
|
120
121
|
}
|
|
121
122
|
const screeningRooms = yield repos.place.searchScreeningRooms({
|
|
122
123
|
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
|
|
123
|
-
});
|
|
124
|
+
}, settings_1.USE_READ_SCREENING_ROOM_TYPE);
|
|
124
125
|
const targetImportFrom = moment(`${moment(params.importFrom)
|
|
125
126
|
.tz('Asia/Tokyo')
|
|
126
127
|
.format('YYYY-MM-DD')}T00:00:00+09:00`);
|
|
@@ -18,6 +18,10 @@ export declare function searchPermissions(params: {
|
|
|
18
18
|
member: MemberRepo;
|
|
19
19
|
role: RoleRepo;
|
|
20
20
|
}) => Promise<{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
hasRole: {
|
|
22
|
+
roleName: string;
|
|
23
|
+
}[];
|
|
24
|
+
permissions: {
|
|
25
|
+
_id: string;
|
|
26
|
+
}[];
|
|
23
27
|
}>;
|
|
@@ -16,18 +16,32 @@ exports.searchPermissions = void 0;
|
|
|
16
16
|
function searchPermissions(params) {
|
|
17
17
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
let permissions = [];
|
|
19
|
-
|
|
20
|
-
const projectMembers = yield repos.member.search({
|
|
19
|
+
const hasRole = yield repos.member.aggregateRoleNames({
|
|
21
20
|
project: { id: { $eq: params.project.id } },
|
|
22
21
|
member: { id: { $eq: params.member.id } }
|
|
23
22
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
if (hasRole.length > 0) {
|
|
24
|
+
permissions = yield repos.role.aggregatePermissions({ roleName: { $in: hasRole.map((r) => r.roleName) } });
|
|
25
|
+
}
|
|
26
|
+
return { hasRole, permissions };
|
|
27
|
+
// let permissions: IPermission[] = [];
|
|
28
|
+
// const projectMembers = await repos.member.search({
|
|
29
|
+
// project: { id: { $eq: params.project.id } },
|
|
30
|
+
// member: { id: { $eq: params.member.id } }
|
|
31
|
+
// });
|
|
32
|
+
// // 持っているロールを検索
|
|
33
|
+
// const roleNames = projectMembers.reduce<string[]>(
|
|
34
|
+
// (a, b) => [...a, ...(Array.isArray(b.member.hasRole)) ? b.member.hasRole.map((r) => r.roleName) : []],
|
|
35
|
+
// []
|
|
36
|
+
// );
|
|
37
|
+
// const roles = await repos.role.search({ roleName: { $in: roleNames } });
|
|
38
|
+
// // 権限をまとめる
|
|
39
|
+
// permissions = roles.reduce<string[]>(
|
|
40
|
+
// (a, b) => [...a, ...b.permissions],
|
|
41
|
+
// []
|
|
42
|
+
// );
|
|
43
|
+
// permissions = [...new Set(permissions)];
|
|
44
|
+
// return { roleNames, permissions };
|
|
31
45
|
});
|
|
32
46
|
}
|
|
33
47
|
exports.searchPermissions = searchPermissions;
|
|
@@ -88,7 +88,7 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
88
88
|
branchCode: { $eq: movieTheaterBranchCode }
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
} }));
|
|
91
|
+
} }), settings_1.USE_READ_SCREENING_ROOM_TYPE);
|
|
92
92
|
if (seats.length > 0) {
|
|
93
93
|
const availabilities = yield repos.stockHolder.searchHolders({
|
|
94
94
|
project: { id: event.project.id },
|
|
@@ -252,11 +252,6 @@ function createInformMovieTheaterTasks(params) {
|
|
|
252
252
|
'telephone',
|
|
253
253
|
'url',
|
|
254
254
|
'typeOf'
|
|
255
|
-
// 'containsPlace.branchCode',
|
|
256
|
-
// 'containsPlace.name',
|
|
257
|
-
// 'containsPlace.typeOf',
|
|
258
|
-
// 'containsPlace.additionalProperty',
|
|
259
|
-
// 'containsPlace.address'
|
|
260
255
|
], []);
|
|
261
256
|
const movieTheater = movieTheaters.shift();
|
|
262
257
|
if (movieTheater === undefined) {
|
|
@@ -265,7 +260,7 @@ function createInformMovieTheaterTasks(params) {
|
|
|
265
260
|
// ルームを検索
|
|
266
261
|
const screeningRooms = yield repos.place.searchScreeningRooms({
|
|
267
262
|
containedInPlace: { id: { $eq: movieTheater.id } }
|
|
268
|
-
});
|
|
263
|
+
}, settings_1.USE_READ_SCREENING_ROOM_TYPE);
|
|
269
264
|
const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
|
|
270
265
|
return {
|
|
271
266
|
branchCode: room.branchCode,
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ 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_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment;
|
|
43
43
|
export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
|
|
44
|
+
export declare const USE_READ_SCREENING_ROOM_TYPE: boolean;
|
|
45
|
+
export declare const USE_WRITE_SCREENING_ROOM_TYPE: boolean;
|
|
44
46
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
45
47
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
46
48
|
/**
|
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_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = 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_WRITE_SCREENING_ROOM_TYPE = exports.USE_READ_SCREENING_ROOM_TYPE = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = 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')
|
|
@@ -71,6 +71,8 @@ exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDE
|
|
|
71
71
|
exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
|
|
72
72
|
? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
73
73
|
: [];
|
|
74
|
+
exports.USE_READ_SCREENING_ROOM_TYPE = process.env.USE_READ_SCREENING_ROOM_TYPE === '1';
|
|
75
|
+
exports.USE_WRITE_SCREENING_ROOM_TYPE = process.env.USE_WRITE_SCREENING_ROOM_TYPE === '1';
|
|
74
76
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
75
77
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
76
78
|
: 0;
|
package/package.json
CHANGED