@chevre/domain 21.13.0-alpha.11 → 21.13.0-alpha.12

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.
@@ -22,10 +22,11 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import type { Connection } from 'mongoose';
25
+ import type { AnyExpression, Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
28
28
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
29
+ export type IKeyOfSearchSeatsProjection = 'typeOf' | 'branchCode' | 'name' | 'seatingType' | 'additionalProperty' | 'containedInPlace.containedInPlace';
29
30
  /**
30
31
  * 施設リポジトリ
31
32
  */
@@ -34,6 +35,11 @@ export declare class MongoRepository {
34
35
  constructor(connection: Connection);
35
36
  static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): any[];
36
37
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): any[];
38
+ static CREATE_SEARCH_SEATS_PROJECTION(params: {
39
+ [key in IKeyOfSearchSeatsProjection]?: 0;
40
+ }): {
41
+ [field: string]: AnyExpression;
42
+ };
37
43
  /**
38
44
  * 施設を保管する
39
45
  */
@@ -242,7 +248,11 @@ export declare class MongoRepository {
242
248
  };
243
249
  typeOf: factory.placeType.ScreeningRoom;
244
250
  }>;
245
- searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
251
+ searchSeats(params: Omit<factory.place.seat.ISearchConditions, '$projection'> & {
252
+ $projection: {
253
+ [key in IKeyOfSearchSeatsProjection]?: 0;
254
+ };
255
+ }): Promise<factory.place.seat.IPlace[]>;
246
256
  deleteSeat(seat: {
247
257
  project: {
248
258
  id: string;
@@ -209,6 +209,43 @@ class MongoRepository {
209
209
  }
210
210
  return andConditions;
211
211
  }
212
+ static CREATE_SEARCH_SEATS_PROJECTION(params) {
213
+ let includeScreeningRooms = true;
214
+ if (params['containedInPlace.containedInPlace'] === 0) {
215
+ includeScreeningRooms = false;
216
+ }
217
+ const projectStage = {
218
+ _id: 0,
219
+ typeOf: '$containsPlace.containsPlace.typeOf',
220
+ branchCode: '$containsPlace.containsPlace.branchCode',
221
+ name: '$containsPlace.containsPlace.name',
222
+ seatingType: '$containsPlace.containsPlace.seatingType',
223
+ containedInPlace: Object.assign({ typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name' }, (includeScreeningRooms)
224
+ ? {
225
+ containedInPlace: {
226
+ typeOf: '$typeOf',
227
+ branchCode: '$branchCode',
228
+ name: '$name',
229
+ containedInPlace: {
230
+ id: '$containedInPlace.id',
231
+ typeOf: '$containedInPlace.typeOf',
232
+ branchCode: '$containedInPlace.branchCode',
233
+ name: '$containedInPlace.name'
234
+ }
235
+ }
236
+ }
237
+ : undefined),
238
+ additionalProperty: '$containsPlace.containsPlace.additionalProperty'
239
+ };
240
+ Object.keys(params)
241
+ .forEach((field) => {
242
+ if (typeof projectStage[field] === 'string') {
243
+ // tslint:disable-next-line:no-dynamic-delete
244
+ delete projectStage[field];
245
+ }
246
+ });
247
+ return projectStage;
248
+ }
212
249
  /**
213
250
  * 施設を保管する
214
251
  */
@@ -1193,11 +1230,6 @@ class MongoRepository {
1193
1230
  }
1194
1231
  });
1195
1232
  }
1196
- let includeScreeningRooms = true;
1197
- if (params.$projection !== undefined && params.$projection !== null
1198
- && params.$projection['containedInPlace.containedInPlace'] === 0) {
1199
- includeScreeningRooms = false;
1200
- }
1201
1233
  const additionalPropertyElemMatch = (_o = params.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
1202
1234
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1203
1235
  matchStages.push({
@@ -1209,36 +1241,12 @@ class MongoRepository {
1209
1241
  }
1210
1242
  });
1211
1243
  }
1244
+ const projectStage = MongoRepository.CREATE_SEARCH_SEATS_PROJECTION(Object.assign({}, params.$projection));
1212
1245
  const aggregate = this.placeModel.aggregate([
1213
1246
  { $unwind: '$containsPlace' },
1214
1247
  { $unwind: '$containsPlace.containsPlace' },
1215
- // { $unwind: '$containsPlace.containsPlace.containsPlace' },
1216
1248
  ...matchStages,
1217
- {
1218
- $project: {
1219
- _id: 0,
1220
- typeOf: '$containsPlace.containsPlace.typeOf',
1221
- branchCode: '$containsPlace.containsPlace.branchCode',
1222
- name: '$containsPlace.containsPlace.name',
1223
- seatingType: '$containsPlace.containsPlace.seatingType',
1224
- containedInPlace: Object.assign({ typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name' }, (includeScreeningRooms)
1225
- ? {
1226
- containedInPlace: {
1227
- typeOf: '$typeOf',
1228
- branchCode: '$branchCode',
1229
- name: '$name',
1230
- containedInPlace: {
1231
- id: '$containedInPlace.id',
1232
- typeOf: '$containedInPlace.typeOf',
1233
- branchCode: '$containedInPlace.branchCode',
1234
- name: '$containedInPlace.name'
1235
- }
1236
- }
1237
- }
1238
- : undefined),
1239
- additionalProperty: '$containsPlace.containsPlace.additionalProperty'
1240
- }
1241
- }
1249
+ { $project: projectStage }
1242
1250
  ]);
1243
1251
  if (typeof params.limit === 'number' && params.limit > 0) {
1244
1252
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
@@ -223,7 +223,7 @@ function searchEventSeatOffers(params) {
223
223
  }
224
224
  }
225
225
  },
226
- $projection: params.$projection
226
+ $projection: Object.assign({}, params.$projection)
227
227
  });
228
228
  if (seats.length > 0) {
229
229
  const availabilities = yield repos.stockHolder.searchHolders({
@@ -1,5 +1,5 @@
1
1
  import type { MongoRepository as EventRepo } from '../repo/event';
2
- import type { MongoRepository as PlaceRepo } from '../repo/place';
2
+ import type { IKeyOfSearchSeatsProjection, MongoRepository as PlaceRepo } from '../repo/place';
3
3
  import type { MongoRepository as PriceSpecificationRepo } from '../repo/priceSpecification';
4
4
  import type { MongoRepository as ProjectRepo } from '../repo/project';
5
5
  import type { StockHolderRepository as StockHolderRepo } from '../repo/stockHolder';
@@ -39,14 +39,14 @@ export declare function searchEventSeatOffersWithPaging(params: {
39
39
  id: string;
40
40
  };
41
41
  $projection?: {
42
- [key: string]: number;
42
+ [key in IKeyOfSearchSeatsProjection]?: 0;
43
43
  };
44
44
  }): (repos: {
45
45
  event: EventRepo;
46
46
  priceSpecification: PriceSpecificationRepo;
47
47
  stockHolder: StockHolderRepo;
48
48
  place: PlaceRepo;
49
- }) => Promise<factory.place.seat.IPlaceWithOffer[]>;
49
+ }) => Promise<Pick<factory.place.seat.IPlaceWithOffer, 'branchCode' | 'containedInPlace' | 'offers' | 'seatingType' | 'typeOf'>[]>;
50
50
  /**
51
51
  * イベント変更時処理
52
52
  */
@@ -88,7 +88,7 @@ function searchEventSeatOffersWithPaging(params) {
88
88
  branchCode: { $eq: movieTheaterBranchCode }
89
89
  }
90
90
  }
91
- } }));
91
+ }, $projection: Object.assign({}, params.$projection) }));
92
92
  if (seats.length > 0) {
93
93
  const availabilities = yield repos.stockHolder.searchHolders({
94
94
  project: { id: event.project.id },
package/package.json CHANGED
@@ -116,5 +116,5 @@
116
116
  "postversion": "git push origin --tags",
117
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
118
118
  },
119
- "version": "21.13.0-alpha.11"
119
+ "version": "21.13.0-alpha.12"
120
120
  }