@chevre/domain 23.2.0-alpha.16 → 23.2.0-alpha.18

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.
Files changed (28) hide show
  1. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  2. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +1 -1
  3. package/example/src/chevre/place/{findEntranceGates.ts → findRooms.ts} +4 -7
  4. package/example/src/chevre/place/findSections.ts +28 -0
  5. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +1 -0
  6. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +1 -0
  7. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +33 -0
  8. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +33 -0
  9. package/lib/chevre/repo/aggregateOrder.js +0 -93
  10. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  11. package/lib/chevre/repo/aggregateReservation.js +0 -2
  12. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  13. package/lib/chevre/repo/place/screeningRoom.d.ts +4 -1
  14. package/lib/chevre/repo/place/screeningRoom.js +146 -115
  15. package/lib/chevre/repo/place/section.d.ts +8 -1
  16. package/lib/chevre/repo/place/section.js +132 -95
  17. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  18. package/lib/chevre/service/event/processUpdateMovieTheater.js +1 -1
  19. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  20. package/lib/chevre/service/event/saveScreeningEvents.js +1 -1
  21. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  22. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +2 -2
  23. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  24. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  25. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  26. package/package.json +2 -2
  27. package/lib/chevre/service/eventOld.d.ts +0 -60
  28. package/lib/chevre/service/eventOld.js +0 -864
@@ -67,7 +67,7 @@ async function main() {
67
67
  }
68
68
  console.log('movieTheater:', movieTheater);
69
69
 
70
- const screeningRooms = await roomRepo.searchScreeningRooms({
70
+ const screeningRooms = await roomRepo.findRooms({
71
71
  project: { id: { $eq: project.id } },
72
72
  containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
73
73
  branchCode: { $eq: roomCode }
@@ -13,7 +13,7 @@ async function main() {
13
13
  const cursor = eventSeriesRepo.getCursor(
14
14
  {
15
15
  // _id: { $eq: 'al9s38bj6' },
16
- 'project.id': { $ne: 'sskts-development' }
16
+ 'project.id': { $nin: ['sskts-development', 'sskts-test', 'sskts-production'] }
17
17
  },
18
18
  {
19
19
  // _id: 1,
@@ -8,18 +8,15 @@ const project = { id: String(process.env.PROJECT_ID) };
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
10
 
11
- const entranceGateRepo = await chevre.repository.place.EntranceGate.createInstance(
12
- mongoose.connection,
13
- { id: '5bfb841d5a78d7948369979a' }
14
- );
11
+ const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
15
12
 
16
- const entranceGates = await entranceGateRepo.findEntranceGates({
13
+ const rooms = await roomRepo.findRooms({
17
14
  limit: 20,
18
15
  page: 1,
19
16
  project: { id: { $eq: project.id } }
20
17
  });
21
- console.log(entranceGates);
22
- console.log(entranceGates.length);
18
+ console.log(rooms);
19
+ console.log(rooms.length);
23
20
  }
24
21
 
25
22
  main()
@@ -0,0 +1,28 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
12
+
13
+ const sections = await sectionRepo.findSections({
14
+ limit: 10,
15
+ page: 1,
16
+ project: { id: { $eq: project.id } },
17
+ containedInPlace: {
18
+ branchCode: { $eq: '10' },
19
+ containedInPlace: { id: { $eq: '5bfb841d5a78d7948369979a' } }
20
+ }
21
+ });
22
+ console.log(sections);
23
+ console.log(sections.length);
24
+ }
25
+
26
+ main()
27
+ .then(console.log)
28
+ .catch(console.error);
@@ -15,6 +15,7 @@ async function main() {
15
15
  chevre.factory.role.organizationRole.RoleName.TicketClerk
16
16
  ];
17
17
  const permissions = [
18
+ 'admin.sellers.entranceGates.read',
18
19
  'admin.sellers.movieTheaters.read'
19
20
  ];
20
21
  for (const roleName of roleNames) {
@@ -15,6 +15,7 @@ async function main() {
15
15
  // chevre.factory.role.organizationRole.RoleName.TicketClerk
16
16
  ];
17
17
  const permissions = [
18
+ 'admin.sellers.entranceGates.*',
18
19
  'admin.sellers.movieTheaters.*'
19
20
  ];
20
21
  for (const roleName of roleNames) {
@@ -0,0 +1,33 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ // chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
+ // chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ // chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
15
+ chevre.factory.role.organizationRole.RoleName.TicketClerk
16
+ ];
17
+ const permissions = [
18
+ 'admin.sellers.rooms.read'
19
+ ];
20
+ for (const roleName of roleNames) {
21
+ for (const permission of permissions) {
22
+ const result = await roleRepo.addPermissionIfNotExists({
23
+ roleName: { $eq: roleName },
24
+ permission
25
+ });
26
+ console.log('permission added.', result, roleName);
27
+ }
28
+ }
29
+ }
30
+
31
+ main()
32
+ .then()
33
+ .catch(console.error);
@@ -0,0 +1,33 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
+ chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
16
+ ];
17
+ const permissions = [
18
+ 'admin.sellers.rooms.*'
19
+ ];
20
+ for (const roleName of roleNames) {
21
+ for (const permission of permissions) {
22
+ const result = await roleRepo.addPermissionIfNotExists({
23
+ roleName: { $eq: roleName },
24
+ permission
25
+ });
26
+ console.log('permission added.', result, roleName);
27
+ }
28
+ }
29
+ }
30
+
31
+ main()
32
+ .then()
33
+ .catch(console.error);
@@ -20,99 +20,6 @@ class AggregateOrderRepo {
20
20
  constructor(connection) {
21
21
  this.aggregateOrderModel = connection.model(aggregateOrder_1.modelName, (0, aggregateOrder_1.createSchema)());
22
22
  }
23
- // public static CREATE_MONGO_CONDITIONS(
24
- // conditions: ISearchConditions
25
- // ): IMatchStage[] {
26
- // const matchStages: IMatchStage[] = [];
27
- // const projectIdEq = conditions.project?.id?.$eq;
28
- // if (typeof projectIdEq === 'string') {
29
- // matchStages.push({
30
- // $match: { 'project.id': { $eq: projectIdEq } }
31
- // });
32
- // }
33
- // const typeOfEq = conditions.reservationFor?.typeOf;
34
- // if (typeof typeOfEq === 'string') {
35
- // matchStages.push({
36
- // $match: { 'reservationFor.typeOf': { $eq: typeOfEq } }
37
- // });
38
- // }
39
- // const idEq = conditions.reservationFor?.id?.$eq;
40
- // if (typeof idEq === 'string') {
41
- // matchStages.push({
42
- // $match: { 'reservationFor.id': { $eq: idEq } }
43
- // });
44
- // }
45
- // const idIn = conditions.reservationFor?.id?.$in;
46
- // if (Array.isArray(idIn)) {
47
- // matchStages.push({
48
- // $match: { 'reservationFor.id': { $in: idIn } }
49
- // });
50
- // }
51
- // const reservationForStartDateGte = conditions.reservationFor?.startFrom;
52
- // if (reservationForStartDateGte instanceof Date) {
53
- // matchStages.push({
54
- // $match: { 'reservationFor.startDate': { $gte: reservationForStartDateGte } }
55
- // });
56
- // }
57
- // const reservationForStartDateLte = conditions.reservationFor?.startThrough;
58
- // if (reservationForStartDateLte instanceof Date) {
59
- // matchStages.push({
60
- // $match: { 'reservationFor.startDate': { $lte: reservationForStartDateLte } }
61
- // });
62
- // }
63
- // return matchStages;
64
- // }
65
- // /**
66
- // * 予約集計を検索する
67
- // */
68
- // public async searchWithReservationForId(
69
- // params: ISearchConditions,
70
- // inclusion: ('aggregateOffer')[]
71
- // ): Promise<ISearchWithReservationForIdResult[]> {
72
- // const matchStages = AggregateReservationRepo.CREATE_MONGO_CONDITIONS(params);
73
- // let projectStage: { [field in IKeyOfProjection]?: AnyExpression } = {
74
- // _id: 0,
75
- // id: '$reservationFor.id'
76
- // };
77
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
78
- // inclusion.forEach((field) => {
79
- // projectStage[field] = { $ifNull: [`$${field}`, '$false'] };
80
- // // projectStage[field] = 1;
81
- // });
82
- // } else {
83
- // projectStage = {
84
- // _id: 0,
85
- // id: '$reservationFor.id',
86
- // // aggregateEntranceGate: 1, // discontinue(2024-12-23~)
87
- // aggregateOffer: 1
88
- // };
89
- // }
90
- // const sortByStartDate = params.sort?.['reservationFor.startDate'];
91
- // const aggregate = this.aggregateReservationModel.aggregate<ISearchWithReservationForIdResult>([
92
- // ...matchStages,
93
- // ...(typeof sortByStartDate === 'number')
94
- // ? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
95
- // : [],
96
- // // 現時点でreservationFor.idへのunique indexがないので、重複ドキュメント対応として、$group
97
- // {
98
- // $group: {
99
- // _id: '$reservationFor.id',
100
- // reservationFor: { $first: '$reservationFor' },
101
- // aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
102
- // aggregateOffer: { $first: '$aggregateOffer' }
103
- // }
104
- // },
105
- // { $project: projectStage }
106
- // ]);
107
- // if (typeof params.limit === 'number' && params.limit > 0) {
108
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
109
- // aggregate.limit(params.limit * page)
110
- // .skip(params.limit * (page - 1));
111
- // }
112
- // return aggregate
113
- // .option({ maxTimeMS: MONGO_MAX_TIME_MS })
114
- // .exec();
115
- // }
116
23
  save(filter, update) {
117
24
  return __awaiter(this, void 0, void 0, function* () {
118
25
  const { $set } = update;
@@ -5,7 +5,6 @@ type IMatchStage = PipelineStage.Match;
5
5
  export interface IUpdateAggregateReservationParams {
6
6
  $set: {
7
7
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
8
- aggregateEntranceGate?: factory.event.screeningEvent.IAggregateEntranceGate;
9
8
  };
10
9
  }
11
10
  type ISearchWithReservationForIdResult = Pick<IAggregateReservation, 'aggregateOffer'> & {
@@ -82,7 +82,6 @@ class AggregateReservationRepo {
82
82
  projectStage = {
83
83
  _id: 0,
84
84
  id: '$reservationFor.id',
85
- // aggregateEntranceGate: 1, // discontinue(2024-12-23~)
86
85
  aggregateOffer: 1
87
86
  };
88
87
  }
@@ -97,7 +96,6 @@ class AggregateReservationRepo {
97
96
  $group: {
98
97
  _id: '$reservationFor.id',
99
98
  reservationFor: { $first: '$reservationFor' },
100
- aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
101
99
  aggregateOffer: { $first: '$aggregateOffer' }
102
100
  }
103
101
  },
@@ -11,7 +11,6 @@ const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
12
  typeOf: { type: String, required: true },
13
13
  reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
14
- // aggregateEntranceGate: SchemaTypes.Mixed, // discontinue(2024-12-23~)
15
14
  aggregateOffer: mongoose_1.SchemaTypes.Mixed
16
15
  };
17
16
  const schemaOptions = {
@@ -1,6 +1,7 @@
1
- import type { Connection, FilterQuery } from 'mongoose';
1
+ import type { Connection, FilterQuery, PipelineStage } from 'mongoose';
2
2
  import * as factory from '../../factory';
3
3
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
4
+ type IMatchStage = PipelineStage.Match;
4
5
  interface IUpdateOptions {
5
6
  project: {
6
7
  id: string;
@@ -32,6 +33,7 @@ export declare class ScreeningRoomRepo {
32
33
  private readonly civicStructureModel;
33
34
  private readonly placeModel;
34
35
  constructor(connection: Connection);
36
+ static CREATE_ROOM_MONGO_CONDITIONS(searchConditions: Omit<factory.place.screeningRoom.ISearchConditions, '$projection' | 'limit' | 'page'>): IMatchStage[];
35
37
  saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
36
38
  createRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
37
39
  updateRoomByBranchCode(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, $unset: any, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
@@ -59,6 +61,7 @@ export declare class ScreeningRoomRepo {
59
61
  };
60
62
  }): Promise<import("mongodb").DeleteResult>;
61
63
  searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
64
+ findRooms(params: Omit<factory.place.screeningRoom.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed' | 'maximumAttendeeCapacity'>[]>;
62
65
  /**
63
66
  * セクションと座席も含めたひとつのルームを取得する
64
67
  */
@@ -33,6 +33,120 @@ class ScreeningRoomRepo {
33
33
  this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
34
34
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
35
35
  }
36
+ // tslint:disable-next-line:max-func-body-length
37
+ static CREATE_ROOM_MONGO_CONDITIONS(searchConditions) {
38
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
39
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
40
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
41
+ if (typeof projectIdEq === 'string') {
42
+ matchStages.push({
43
+ $match: { 'project.id': { $eq: projectIdEq } }
44
+ });
45
+ }
46
+ const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
47
+ if (typeof parentOrganizationIdEq === 'string') {
48
+ matchStages.push({
49
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
50
+ });
51
+ }
52
+ // 施設ID
53
+ const containedInPlaceIdEq = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
54
+ if (typeof containedInPlaceIdEq === 'string') {
55
+ matchStages.push({
56
+ $match: {
57
+ 'containedInPlace.id': {
58
+ $exists: true,
59
+ $eq: containedInPlaceIdEq
60
+ }
61
+ }
62
+ });
63
+ }
64
+ if (searchConditions.containedInPlace !== undefined) {
65
+ // 施設コード
66
+ if (searchConditions.containedInPlace.branchCode !== undefined) {
67
+ if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
68
+ matchStages.push({
69
+ $match: {
70
+ 'containedInPlace.branchCode': {
71
+ $exists: true,
72
+ $eq: searchConditions.containedInPlace.branchCode.$eq
73
+ }
74
+ }
75
+ });
76
+ }
77
+ }
78
+ }
79
+ const branchCodeEq = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
80
+ if (typeof branchCodeEq === 'string') {
81
+ matchStages.push({
82
+ $match: {
83
+ branchCode: { $eq: branchCodeEq }
84
+ }
85
+ });
86
+ }
87
+ const branchCodeIn = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
88
+ if (Array.isArray(branchCodeIn)) {
89
+ matchStages.push({
90
+ $match: {
91
+ branchCode: { $in: branchCodeIn }
92
+ }
93
+ });
94
+ }
95
+ const branchCodeRegex = (_j = searchConditions.branchCode) === null || _j === void 0 ? void 0 : _j.$regex;
96
+ if (typeof branchCodeRegex === 'string') {
97
+ matchStages.push({
98
+ $match: {
99
+ branchCode: {
100
+ $regex: new RegExp(branchCodeRegex)
101
+ }
102
+ }
103
+ });
104
+ }
105
+ const nameCodeRegex = (_k = searchConditions.name) === null || _k === void 0 ? void 0 : _k.$regex;
106
+ if (typeof nameCodeRegex === 'string') {
107
+ matchStages.push({
108
+ $match: {
109
+ $or: [
110
+ {
111
+ 'name.ja': {
112
+ $exists: true,
113
+ $regex: new RegExp(nameCodeRegex)
114
+ }
115
+ },
116
+ {
117
+ 'name.en': {
118
+ $exists: true,
119
+ $regex: new RegExp(nameCodeRegex)
120
+ }
121
+ }
122
+ ]
123
+ }
124
+ });
125
+ }
126
+ const openSeatingAllowed = searchConditions.openSeatingAllowed;
127
+ if (typeof openSeatingAllowed === 'boolean') {
128
+ matchStages.push({
129
+ $match: {
130
+ openSeatingAllowed: {
131
+ $exists: true,
132
+ $eq: openSeatingAllowed
133
+ }
134
+ }
135
+ });
136
+ }
137
+ const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
138
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
139
+ matchStages.push({
140
+ $match: {
141
+ additionalProperty: {
142
+ $exists: true,
143
+ $elemMatch: additionalPropertyElemMatch
144
+ }
145
+ }
146
+ });
147
+ }
148
+ return matchStages;
149
+ }
36
150
  saveScreeningRooms4coa(params) {
37
151
  return __awaiter(this, void 0, void 0, function* () {
38
152
  const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
@@ -189,130 +303,19 @@ class ScreeningRoomRepo {
189
303
  .exec();
190
304
  });
191
305
  }
192
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
193
306
  searchScreeningRooms(searchConditions) {
194
307
  return __awaiter(this, void 0, void 0, function* () {
195
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
196
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
197
- const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
198
- if (typeof projectIdEq === 'string') {
199
- matchStages.push({
200
- $match: { 'project.id': { $eq: projectIdEq } }
201
- });
202
- }
203
- const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
204
- if (typeof parentOrganizationIdEq === 'string') {
205
- matchStages.push({
206
- $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
207
- });
208
- }
209
- // 施設ID
210
- const containedInPlaceIdEq = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
211
- if (typeof containedInPlaceIdEq === 'string') {
212
- matchStages.push({
213
- $match: {
214
- 'containedInPlace.id': {
215
- $exists: true,
216
- $eq: containedInPlaceIdEq
217
- }
218
- }
219
- });
220
- }
221
- if (searchConditions.containedInPlace !== undefined) {
222
- // 施設コード
223
- if (searchConditions.containedInPlace.branchCode !== undefined) {
224
- if (typeof searchConditions.containedInPlace.branchCode.$eq === 'string') {
225
- matchStages.push({
226
- $match: {
227
- 'containedInPlace.branchCode': {
228
- $exists: true,
229
- $eq: searchConditions.containedInPlace.branchCode.$eq
230
- }
231
- }
232
- });
233
- }
234
- }
235
- }
236
- const branchCodeEq = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
237
- if (typeof branchCodeEq === 'string') {
238
- matchStages.push({
239
- $match: {
240
- branchCode: { $eq: branchCodeEq }
241
- }
242
- });
243
- }
244
- const branchCodeIn = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
245
- if (Array.isArray(branchCodeIn)) {
246
- matchStages.push({
247
- $match: {
248
- branchCode: { $in: branchCodeIn }
249
- }
250
- });
251
- }
252
- const branchCodeRegex = (_j = searchConditions.branchCode) === null || _j === void 0 ? void 0 : _j.$regex;
253
- if (typeof branchCodeRegex === 'string') {
254
- matchStages.push({
255
- $match: {
256
- branchCode: {
257
- $regex: new RegExp(branchCodeRegex)
258
- }
259
- }
260
- });
261
- }
262
- const nameCodeRegex = (_k = searchConditions.name) === null || _k === void 0 ? void 0 : _k.$regex;
263
- if (typeof nameCodeRegex === 'string') {
264
- matchStages.push({
265
- $match: {
266
- $or: [
267
- {
268
- 'name.ja': {
269
- $exists: true,
270
- $regex: new RegExp(nameCodeRegex)
271
- }
272
- },
273
- {
274
- 'name.en': {
275
- $exists: true,
276
- $regex: new RegExp(nameCodeRegex)
277
- }
278
- }
279
- ]
280
- }
281
- });
282
- }
283
- const openSeatingAllowed = searchConditions.openSeatingAllowed;
284
- if (typeof openSeatingAllowed === 'boolean') {
285
- matchStages.push({
286
- $match: {
287
- openSeatingAllowed: {
288
- $exists: true,
289
- $eq: openSeatingAllowed
290
- }
291
- }
292
- });
293
- }
294
- const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
295
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
296
- matchStages.push({
297
- $match: {
298
- additionalProperty: {
299
- $exists: true,
300
- $elemMatch: additionalPropertyElemMatch
301
- }
302
- }
303
- });
304
- }
308
+ var _a, _b;
305
309
  const aggregate = this.placeModel.aggregate([
306
310
  { $sort: { branchCode: factory.sortType.Ascending } },
307
- // { $unwind: '$containsPlace' },
308
- ...matchStages,
311
+ ...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(searchConditions),
309
312
  {
310
313
  $project: Object.assign(Object.assign({ _id: 0, typeOf: '$typeOf', branchCode: '$branchCode', name: '$name', address: '$address', containedInPlace: {
311
314
  id: '$containedInPlace.id',
312
315
  typeOf: '$containedInPlace.typeOf',
313
316
  branchCode: '$containedInPlace.branchCode',
314
317
  name: '$containedInPlace.name'
315
- }, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.sectionCount) === 1)
318
+ }, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_a = searchConditions.$projection) === null || _a === void 0 ? void 0 : _a.sectionCount) === 1)
316
319
  ? {
317
320
  sectionCount: {
318
321
  $cond: {
@@ -322,7 +325,7 @@ class ScreeningRoomRepo {
322
325
  }
323
326
  }
324
327
  }
325
- : undefined), (((_o = searchConditions.$projection) === null || _o === void 0 ? void 0 : _o.seatCount) === 1)
328
+ : undefined), (((_b = searchConditions.$projection) === null || _b === void 0 ? void 0 : _b.seatCount) === 1)
326
329
  ? {
327
330
  seatCount: {
328
331
  $sum: {
@@ -354,6 +357,34 @@ class ScreeningRoomRepo {
354
357
  .exec();
355
358
  });
356
359
  }
360
+ findRooms(params) {
361
+ return __awaiter(this, void 0, void 0, function* () {
362
+ const aggregate = this.placeModel.aggregate([
363
+ ...ScreeningRoomRepo.CREATE_ROOM_MONGO_CONDITIONS(params),
364
+ {
365
+ $project: {
366
+ _id: 0,
367
+ branchCode: '$branchCode',
368
+ name: '$name',
369
+ address: '$address',
370
+ openSeatingAllowed: '$openSeatingAllowed',
371
+ additionalProperty: '$additionalProperty',
372
+ maximumAttendeeCapacity: '$maximumAttendeeCapacity'
373
+ }
374
+ },
375
+ { $sort: { branchCode: factory.sortType.Ascending } }
376
+ ]);
377
+ const { limit, page } = params;
378
+ if (typeof limit === 'number' && limit > 0) {
379
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
380
+ aggregate.skip(limit * (pageMustBePositive - 1))
381
+ .limit(limit);
382
+ }
383
+ return aggregate
384
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
385
+ .exec();
386
+ });
387
+ }
357
388
  /**
358
389
  * セクションと座席も含めたひとつのルームを取得する
359
390
  */
@@ -1,7 +1,8 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { Connection, PipelineStage } from 'mongoose';
2
2
  import * as factory from '../../factory';
3
3
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
4
4
  type ICreatingSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
5
+ type IMatchStage = PipelineStage.Match;
5
6
  interface IUpdateOptions {
6
7
  project: {
7
8
  id: string;
@@ -31,6 +32,7 @@ export declare class SectionRepo {
31
32
  private readonly civicStructureModel;
32
33
  private readonly placeModel;
33
34
  constructor(connection: Connection);
35
+ static CREATE_SECTION_MONGO_CONDITIONS(searchConditions: Omit<factory.place.screeningRoomSection.ISearchConditions, '$projection' | 'limit' | 'page'>): IMatchStage[];
34
36
  createSection(screeningRoomSection: ICreatingSection, options: IUpdateOptions): Promise<IUpdateSectionResult>;
35
37
  /**
36
38
  * セクションの名称と追加特性を編集する
@@ -53,6 +55,11 @@ export declare class SectionRepo {
53
55
  };
54
56
  };
55
57
  }): Promise<IUpdateSectionResult>;
58
+ /**
59
+ * 最小限のprojectionでセクション検索を再定義
60
+ * 2026-01-08~
61
+ */
62
+ findSections(params: Omit<factory.place.screeningRoomSection.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
56
63
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
57
64
  /**
58
65
  * ルーム指定のセクション検索として再定義(2025-12-07~)