@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.
@@ -8,7 +8,7 @@ async function main() {
8
8
 
9
9
  const placeRepo = new chevre.repository.Place(mongoose.connection);
10
10
 
11
- const event = await placeRepo.findScreeningRoomsByBranchCode({
11
+ const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
12
12
  branchCode: {
13
13
  $eq: '20'
14
14
  },
@@ -16,9 +16,10 @@ async function main() {
16
16
  id: {
17
17
  $eq: '5bfb841d5a78d7948369979a'
18
18
  }
19
- }
19
+ },
20
+ useScreeningRoomType: true
20
21
  });
21
- console.log('room found', event);
22
+ console.log('room found', screeningRoom);
22
23
 
23
24
  }
24
25
 
@@ -0,0 +1,54 @@
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
+ const memberId = 'xxx';
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
+
13
+ const memberRepo = new chevre.repository.Member(mongoose.connection);
14
+ const roleRepo = new chevre.repository.Role(mongoose.connection);
15
+
16
+ let now: Date;
17
+
18
+ // let now = new Date();
19
+ // const aggregateRoleNamesResult = await memberRepo.aggregateRoleNames({
20
+ // project: { id: { $eq: PROJECT_ID } },
21
+ // member: { id: { $eq: memberId } }
22
+ // });
23
+
24
+ // const aggregatePermissionsResult = await roleRepo.aggregatePermissions({
25
+ // roleName: {
26
+ // $in: aggregateRoleNamesResult.map((r) => r.roleName)
27
+ // }
28
+ // });
29
+ // console.log('time cost:', moment()
30
+ // .diff(now));
31
+
32
+ now = new Date();
33
+ const searchPermissionsResult = await chevre.service.iam.searchPermissions({
34
+ project: { id: PROJECT_ID },
35
+ member: { id: memberId }
36
+ })({
37
+ member: memberRepo,
38
+ role: roleRepo
39
+ });
40
+ console.log('time cost:', moment()
41
+ .diff(now));
42
+
43
+ console.log(searchPermissionsResult);
44
+ console.log(searchPermissionsResult.permissions.length);
45
+
46
+ // console.log(aggregateRoleNamesResult);
47
+ // console.log(aggregateRoleNamesResult.length);
48
+ // console.log(aggregatePermissionsResult);
49
+ // console.log(aggregatePermissionsResult.length);
50
+ }
51
+
52
+ main()
53
+ .then(console.log)
54
+ .catch(console.error);
@@ -24,7 +24,8 @@ async function main() {
24
24
 
25
25
  const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
26
26
  branchCode: { $eq: rooms[0].branchCode },
27
- containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } }
27
+ containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } },
28
+ useScreeningRoomType: true
28
29
  });
29
30
  console.log('screeningRoom found', screeningRoom);
30
31
  }
@@ -30,7 +30,7 @@ async function main() {
30
30
  doc.toObject();
31
31
 
32
32
  console.log('syncing...', project.id, typeOf, id, name.ja, i);
33
- // await placeRepo.syncScreeningRooms({ id });
33
+ await placeRepo.syncScreeningRooms({ id });
34
34
  console.log('synced.', project.id, typeOf, id, name.ja, i);
35
35
  });
36
36
 
@@ -9,6 +9,20 @@ export declare class MongoRepository {
9
9
  static CREATE_MONGO_CONDITIONS(params: factory.iam.ISearchConditions): any[];
10
10
  count(params: factory.iam.ISearchConditions): Promise<number>;
11
11
  search(params: factory.iam.ISearchConditions): Promise<factory.iam.IMember[]>;
12
+ aggregateRoleNames(params: {
13
+ project: {
14
+ id: {
15
+ $eq: string;
16
+ };
17
+ };
18
+ member: {
19
+ id: {
20
+ $eq: string;
21
+ };
22
+ };
23
+ }): Promise<{
24
+ roleName: string;
25
+ }[]>;
12
26
  findById(params: {
13
27
  id: string;
14
28
  }): Promise<factory.iam.IMember>;
@@ -132,6 +132,33 @@ class MongoRepository {
132
132
  .then((docs) => docs.map((doc) => doc.toObject()));
133
133
  });
134
134
  }
135
+ aggregateRoleNames(params) {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ const matchStages = [
138
+ { $match: { 'project.id': { $eq: params.project.id.$eq } } },
139
+ { $match: { 'member.id': { $eq: params.member.id.$eq } } }
140
+ ];
141
+ const aggregate = this.memberModel.aggregate([
142
+ // ...(typeof params.sort?.productID === 'number')
143
+ // ? [{ $sort: { productID: params.sort.productID } }]
144
+ // : [],
145
+ ...matchStages,
146
+ {
147
+ $unwind: {
148
+ path: '$member.hasRole'
149
+ }
150
+ },
151
+ {
152
+ $project: {
153
+ _id: 0,
154
+ roleName: '$member.hasRole.roleName'
155
+ }
156
+ }
157
+ ]);
158
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
159
+ .exec();
160
+ });
161
+ }
135
162
  findById(params) {
136
163
  return __awaiter(this, void 0, void 0, function* () {
137
164
  const doc = yield this.memberModel.findOne({
@@ -50,7 +50,7 @@ export declare class MongoRepository {
50
50
  deleteMovieTheaterById(params: {
51
51
  id: string;
52
52
  }): Promise<void>;
53
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>): Promise<{
53
+ createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>, useScreeningRoomType?: boolean): Promise<{
54
54
  /**
55
55
  * 施設ID
56
56
  */
@@ -61,7 +61,7 @@ export declare class MongoRepository {
61
61
  containedInPlace: {
62
62
  branchCode: string;
63
63
  };
64
- }, $unset: any): Promise<{
64
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
65
65
  /**
66
66
  * 施設ID
67
67
  */
@@ -82,7 +82,7 @@ export declare class MongoRepository {
82
82
  */
83
83
  branchCode: string;
84
84
  };
85
- }): Promise<{
85
+ }, useScreeningRoomType?: boolean): Promise<{
86
86
  /**
87
87
  * 施設ID
88
88
  */
@@ -100,7 +100,7 @@ export declare class MongoRepository {
100
100
  id: string;
101
101
  };
102
102
  }): Promise<void>;
103
- createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace): Promise<{
103
+ createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace, useScreeningRoomType?: boolean): Promise<{
104
104
  /**
105
105
  * 施設ID
106
106
  */
@@ -114,7 +114,7 @@ export declare class MongoRepository {
114
114
  branchCode: string;
115
115
  };
116
116
  };
117
- }, $unset: any): Promise<{
117
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
118
118
  /**
119
119
  * 施設ID
120
120
  */
@@ -125,7 +125,7 @@ export declare class MongoRepository {
125
125
  $projection?: {
126
126
  [key: string]: number;
127
127
  };
128
- }, useScreeningRoomType?: boolean): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
128
+ }, useScreeningRoomType: boolean): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
129
129
  deleteScreeningRoomSection(screeningRoomSection: {
130
130
  project: {
131
131
  id: string;
@@ -146,14 +146,14 @@ export declare class MongoRepository {
146
146
  branchCode: string;
147
147
  };
148
148
  };
149
- }): Promise<{
149
+ }, useScreeningRoomType?: boolean): Promise<{
150
150
  /**
151
151
  * 施設ID
152
152
  */
153
153
  id: string;
154
154
  typeOf: factory.placeType.MovieTheater;
155
155
  }>;
156
- searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions, useScreeningRoomType?: boolean): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
156
+ searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions, useScreeningRoomType: boolean): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
157
157
  findScreeningRoomsByBranchCode(params: {
158
158
  branchCode: {
159
159
  $eq: string;
@@ -163,8 +163,9 @@ export declare class MongoRepository {
163
163
  $eq: string;
164
164
  };
165
165
  };
166
+ useScreeningRoomType: boolean;
166
167
  }): Promise<IScreeningRoomFoundByBranchCode>;
167
- createSeat(seat: factory.place.seat.IPlace): Promise<{
168
+ createSeat(seat: factory.place.seat.IPlace, useScreeningRoomType?: boolean): Promise<{
168
169
  /**
169
170
  * 施設ID
170
171
  */
@@ -181,14 +182,14 @@ export declare class MongoRepository {
181
182
  };
182
183
  };
183
184
  };
184
- }, $unset: any): Promise<{
185
+ }, $unset: any, useScreeningRoomType?: boolean): Promise<{
185
186
  /**
186
187
  * 施設ID
187
188
  */
188
189
  id: string;
189
190
  typeOf: factory.placeType.MovieTheater;
190
191
  }>;
191
- searchSeats(params: factory.place.seat.ISearchConditions, useScreeningRoomType?: boolean): Promise<factory.place.seat.IPlace[]>;
192
+ searchSeats(params: factory.place.seat.ISearchConditions, useScreeningRoomType: boolean): Promise<factory.place.seat.IPlace[]>;
192
193
  deleteSeat(seat: {
193
194
  project: {
194
195
  id: string;
@@ -215,7 +216,7 @@ export declare class MongoRepository {
215
216
  };
216
217
  };
217
218
  };
218
- }): Promise<{
219
+ }, useScreeningRoomType?: boolean): Promise<{
219
220
  /**
220
221
  * 施設ID
221
222
  */