@chevre/domain 21.27.0 → 21.28.0-alpha.1

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 (31) hide show
  1. package/example/src/chevre/importEventsFromCOA.ts +2 -0
  2. package/lib/chevre/repo/place/busStop.d.ts +27 -0
  3. package/lib/chevre/repo/place/busStop.js +199 -0
  4. package/lib/chevre/repo/place/movieTheater.d.ts +31 -0
  5. package/lib/chevre/repo/place/movieTheater.js +281 -0
  6. package/lib/chevre/repo/place/seat.d.ts +75 -0
  7. package/lib/chevre/repo/place/seat.js +361 -0
  8. package/lib/chevre/repo/place.d.ts +1 -120
  9. package/lib/chevre/repo/place.js +8 -801
  10. package/lib/chevre/repository.d.ts +27 -0
  11. package/lib/chevre/repository.js +51 -0
  12. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -2
  13. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  14. package/lib/chevre/service/assetTransaction/reserve.d.ts +3 -3
  15. package/lib/chevre/service/assetTransaction/reserve.js +1 -1
  16. package/lib/chevre/service/event/createEvent.d.ts +2 -2
  17. package/lib/chevre/service/event/createEvent.js +1 -1
  18. package/lib/chevre/service/event.d.ts +2 -0
  19. package/lib/chevre/service/event.js +2 -2
  20. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  21. package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +2 -2
  22. package/lib/chevre/service/offer.d.ts +2 -2
  23. package/lib/chevre/service/offer.js +1 -1
  24. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -2
  25. package/lib/chevre/service/task/createEvent.js +2 -2
  26. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  27. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
  28. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +1 -1
  29. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  30. package/lib/chevre/service/task/onResourceUpdated.js +4 -2
  31. package/package.json +1 -1
@@ -8,22 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.MongoRepository = void 0;
24
- const place_1 = require("./mongoose/schemas/place");
25
13
  const factory = require("../factory");
26
14
  const settings_1 = require("../settings");
15
+ const place_1 = require("./mongoose/schemas/place");
27
16
  /**
28
17
  * 施設リポジトリ
29
18
  */
@@ -31,365 +20,6 @@ class MongoRepository {
31
20
  constructor(connection) {
32
21
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
33
22
  }
34
- // tslint:disable-next-line:max-func-body-length
35
- static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h;
37
- const andConditions = [{ typeOf: { $eq: factory.placeType.BusStop } }];
38
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
39
- if (typeof projectIdEq === 'string') {
40
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
41
- }
42
- const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
43
- if (typeof branchCodeEq === 'string') {
44
- andConditions.push({
45
- branchCode: {
46
- $exists: true,
47
- $eq: branchCodeEq
48
- }
49
- });
50
- }
51
- const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
52
- if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
53
- andConditions.push({
54
- branchCode: {
55
- $exists: true,
56
- $regex: new RegExp(branchCodeRegex)
57
- }
58
- });
59
- }
60
- const branchCodeIn = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$in;
61
- if (Array.isArray(branchCodeIn)) {
62
- andConditions.push({
63
- branchCode: {
64
- $exists: true,
65
- $in: branchCodeIn
66
- }
67
- });
68
- }
69
- // tslint:disable-next-line:no-single-line-block-comment
70
- /* istanbul ignore else */
71
- const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
72
- if (typeof idEq === 'string') {
73
- andConditions.push({
74
- _id: {
75
- $eq: idEq
76
- }
77
- });
78
- }
79
- const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
80
- if (Array.isArray(idIn)) {
81
- andConditions.push({
82
- _id: {
83
- $in: idIn
84
- }
85
- });
86
- }
87
- const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
88
- // tslint:disable-next-line:no-single-line-block-comment
89
- /* istanbul ignore else */
90
- if (typeof nameRegex === 'string' && nameRegex.length > 0) {
91
- andConditions.push({
92
- $or: [
93
- {
94
- 'name.ja': {
95
- $exists: true,
96
- $regex: new RegExp(nameRegex)
97
- }
98
- },
99
- {
100
- 'name.en': {
101
- $exists: true,
102
- $regex: new RegExp(nameRegex)
103
- }
104
- }
105
- ]
106
- });
107
- }
108
- return andConditions;
109
- }
110
- // tslint:disable-next-line:max-func-body-length
111
- static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
112
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
113
- // MongoDB検索条件
114
- const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
115
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
116
- if (typeof projectIdEq === 'string') {
117
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
118
- }
119
- const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
120
- if (typeof branchCodeEq === 'string') {
121
- andConditions.push({
122
- branchCode: {
123
- $exists: true,
124
- $eq: branchCodeEq
125
- }
126
- });
127
- }
128
- const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
129
- if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
130
- andConditions.push({
131
- branchCode: {
132
- $exists: true,
133
- $regex: new RegExp(branchCodeRegex)
134
- }
135
- });
136
- }
137
- // tslint:disable-next-line:no-single-line-block-comment
138
- /* istanbul ignore else */
139
- if (Array.isArray(params.branchCodes)) {
140
- andConditions.push({
141
- branchCode: {
142
- $exists: true,
143
- $in: params.branchCodes
144
- }
145
- });
146
- }
147
- // tslint:disable-next-line:no-single-line-block-comment
148
- /* istanbul ignore else */
149
- const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
150
- if (typeof idEq === 'string') {
151
- andConditions.push({
152
- _id: {
153
- $eq: idEq
154
- }
155
- });
156
- }
157
- const idIn = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$in;
158
- if (Array.isArray(idIn)) {
159
- andConditions.push({
160
- _id: {
161
- $in: idIn
162
- }
163
- });
164
- }
165
- // tslint:disable-next-line:no-single-line-block-comment
166
- /* istanbul ignore else */
167
- if (typeof params.name === 'string' && params.name.length > 0) {
168
- andConditions.push({
169
- $or: [
170
- {
171
- 'name.ja': {
172
- $exists: true,
173
- $regex: new RegExp(params.name)
174
- }
175
- },
176
- {
177
- 'name.en': {
178
- $exists: true,
179
- $regex: new RegExp(params.name)
180
- }
181
- },
182
- {
183
- kanaName: {
184
- $exists: true,
185
- $regex: new RegExp(params.name)
186
- }
187
- }
188
- ]
189
- });
190
- }
191
- const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
192
- if (typeof parentOrganizationIdEq === 'string') {
193
- andConditions.push({
194
- 'parentOrganization.id': {
195
- $exists: true,
196
- $eq: parentOrganizationIdEq
197
- }
198
- });
199
- }
200
- const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
201
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
202
- andConditions.push({
203
- additionalProperty: {
204
- $exists: true,
205
- $elemMatch: additionalPropertyElemMatch
206
- }
207
- });
208
- }
209
- return andConditions;
210
- }
211
- static CREATE_SEARCH_SEATS_PROJECTION(params) {
212
- const includeSectionBranchCode = params['containedInPlace.branchCode'] !== 0;
213
- const includeSectionName = params['containedInPlace.name'] !== 0;
214
- const includeSectionTypeOf = params['containedInPlace.typeOf'] !== 0;
215
- const includeScreeningRooms = params['containedInPlace.containedInPlace'] !== 0;
216
- const projectStage = {
217
- _id: 0,
218
- typeOf: '$containsPlace.containsPlace.typeOf',
219
- branchCode: '$containsPlace.containsPlace.branchCode',
220
- name: '$containsPlace.containsPlace.name',
221
- seatingType: '$containsPlace.containsPlace.seatingType',
222
- containedInPlace: Object.assign(Object.assign(Object.assign(Object.assign({}, (includeSectionBranchCode) ? { branchCode: '$containsPlace.branchCode' } : undefined), (includeSectionName) ? { name: '$containsPlace.name' } : undefined), (includeSectionTypeOf) ? { typeOf: '$containsPlace.typeOf' } : undefined), (includeScreeningRooms)
223
- ? {
224
- containedInPlace: {
225
- typeOf: '$typeOf',
226
- branchCode: '$branchCode',
227
- name: '$name',
228
- containedInPlace: {
229
- id: '$containedInPlace.id',
230
- typeOf: '$containedInPlace.typeOf',
231
- branchCode: '$containedInPlace.branchCode',
232
- name: '$containedInPlace.name'
233
- }
234
- }
235
- }
236
- : undefined),
237
- additionalProperty: '$containsPlace.containsPlace.additionalProperty'
238
- };
239
- Object.keys(params)
240
- .forEach((field) => {
241
- if (typeof projectStage[field] === 'string') {
242
- // tslint:disable-next-line:no-dynamic-delete
243
- delete projectStage[field];
244
- }
245
- });
246
- return projectStage;
247
- }
248
- /**
249
- * 施設を保管する
250
- */
251
- saveMovieTheater(params) {
252
- return __awaiter(this, void 0, void 0, function* () {
253
- let doc;
254
- if (params.id === '') {
255
- doc = yield this.placeModel.create(params);
256
- }
257
- else {
258
- // 上書き禁止属性を除外(2022-08-24~)
259
- const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
260
- doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, {
261
- upsert: false,
262
- new: true,
263
- projection: {
264
- __v: 0,
265
- createdAt: 0,
266
- updatedAt: 0,
267
- containsPlace: 0
268
- }
269
- })
270
- .exec();
271
- }
272
- if (doc === null) {
273
- throw new factory.errors.NotFound(this.placeModel.modelName);
274
- }
275
- return doc.toObject();
276
- });
277
- }
278
- // void化(2023-06-23~)
279
- saveMovieTheaterByBranchCode4coa(params) {
280
- return __awaiter(this, void 0, void 0, function* () {
281
- const { containsPlace } = params, movieTheater4update = __rest(params, ["containsPlace"]);
282
- const movieTheaterDoc = yield this.placeModel.findOneAndUpdate({
283
- typeOf: { $eq: factory.placeType.MovieTheater },
284
- 'project.id': { $eq: params.project.id },
285
- branchCode: { $eq: params.branchCode }
286
- },
287
- // containsPlaceの保管を廃止(2023-07-04~)
288
- // params,
289
- movieTheater4update, {
290
- new: true,
291
- projection: { _id: 1 }
292
- })
293
- .exec();
294
- if (movieTheaterDoc === null) {
295
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
296
- }
297
- const movieTheater = movieTheaterDoc.toObject();
298
- // ScreeningRoomも保管する(2023-06-24~)
299
- const creatingScreeningRooms = params.containsPlace.map((place) => {
300
- return Object.assign(Object.assign({}, place), { containedInPlace: {
301
- id: movieTheater.id,
302
- typeOf: params.typeOf,
303
- branchCode: params.branchCode,
304
- name: params.name
305
- }, containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [], project: params.project });
306
- });
307
- yield Promise.all(creatingScreeningRooms.map((createScreeningRoom) => __awaiter(this, void 0, void 0, function* () {
308
- const { typeOf, project, branchCode } = createScreeningRoom, setFields = __rest(createScreeningRoom, ["typeOf", "project", "branchCode"]);
309
- if (typeof branchCode === 'string' && branchCode.length > 0) {
310
- yield this.placeModel.findOneAndUpdate({
311
- typeOf: { $eq: factory.placeType.ScreeningRoom },
312
- 'project.id': { $eq: createScreeningRoom.project.id },
313
- 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
314
- branchCode: { $eq: createScreeningRoom.branchCode }
315
- }, {
316
- $setOnInsert: {
317
- typeOf: createScreeningRoom.typeOf,
318
- project: createScreeningRoom.project,
319
- branchCode: createScreeningRoom.branchCode
320
- },
321
- $set: setFields
322
- }, {
323
- upsert: true,
324
- new: true,
325
- projection: { _id: 1 }
326
- })
327
- .exec();
328
- }
329
- })));
330
- });
331
- }
332
- /**
333
- * 施設検索
334
- */
335
- searchMovieTheaters(params, inclusion, exclusion) {
336
- var _a;
337
- return __awaiter(this, void 0, void 0, function* () {
338
- const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
339
- let projection = {};
340
- if (Array.isArray(inclusion) && inclusion.length > 0) {
341
- inclusion.forEach((field) => {
342
- if (String(field) !== 'containsPlace' && String(field) !== 'hasPOS') { // 除外(2023-10-26~)
343
- projection[field] = 1;
344
- }
345
- });
346
- }
347
- else {
348
- projection = {
349
- __v: 0,
350
- createdAt: 0,
351
- updatedAt: 0,
352
- // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
353
- containsPlace: 0,
354
- hasPOS: 0 // 除外(2023-10-26~)
355
- };
356
- if (Array.isArray(exclusion) && exclusion.length > 0) {
357
- exclusion.forEach((field) => {
358
- projection[field] = 0;
359
- });
360
- }
361
- }
362
- const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
363
- if (typeof params.limit === 'number' && params.limit > 0) {
364
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
365
- query.limit(params.limit)
366
- .skip(params.limit * (page - 1));
367
- }
368
- // tslint:disable-next-line:no-single-line-block-comment
369
- /* istanbul ignore else */
370
- if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
371
- query.sort({ branchCode: params.sort.branchCode });
372
- }
373
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
374
- .exec()
375
- .then((docs) => docs.map((doc) => doc.toObject()));
376
- });
377
- }
378
- deleteMovieTheaterById(params) {
379
- return __awaiter(this, void 0, void 0, function* () {
380
- yield this.placeModel.findOneAndDelete({
381
- typeOf: { $eq: factory.placeType.MovieTheater },
382
- _id: { $eq: params.id },
383
- 'project.id': { $eq: params.project.id }
384
- }, { projection: { _id: 1 } })
385
- .exec()
386
- .then((doc) => {
387
- if (doc === null) {
388
- throw new factory.errors.NotFound(this.placeModel.modelName);
389
- }
390
- });
391
- });
392
- }
393
23
  createScreeningRoom(screeningRoom) {
394
24
  var _a;
395
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -460,42 +90,6 @@ class MongoRepository {
460
90
  return doc.toObject();
461
91
  });
462
92
  }
463
- // public async addParentOrganization2ScreeningRoom(
464
- // screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'parentOrganization' | 'project'> & {
465
- // containedInPlace: {
466
- // branchCode: string;
467
- // };
468
- // }
469
- // ): Promise<{
470
- // containedInPlace: {
471
- // /**
472
- // * 施設ID
473
- // */
474
- // id: string;
475
- // };
476
- // typeOf: factory.placeType.ScreeningRoom;
477
- // }> {
478
- // const doc = await this.placeModel.findOneAndUpdate(
479
- // {
480
- // typeOf: { $eq: factory.placeType.ScreeningRoom },
481
- // 'project.id': { $eq: screeningRoom.project.id },
482
- // 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
483
- // branchCode: screeningRoom.branchCode
484
- // },
485
- // {
486
- // parentOrganization: screeningRoom.parentOrganization
487
- // },
488
- // {
489
- // new: true,
490
- // projection: { 'containedInPlace.id': 1, typeOf: 1 }
491
- // }
492
- // )
493
- // .exec();
494
- // if (doc === null) {
495
- // throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
496
- // }
497
- // return doc.toObject();
498
- // }
499
93
  updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
500
94
  var _a;
501
95
  return __awaiter(this, void 0, void 0, function* () {
@@ -756,7 +350,9 @@ class MongoRepository {
756
350
  aggregate.limit(searchConditions.limit * page)
757
351
  .skip(searchConditions.limit * (page - 1));
758
352
  }
759
- return aggregate.exec();
353
+ return aggregate
354
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
355
+ .exec();
760
356
  });
761
357
  }
762
358
  deleteScreeningRoomSection(screeningRoomSection) {
@@ -944,7 +540,9 @@ class MongoRepository {
944
540
  aggregate.limit(searchConditions.limit * page)
945
541
  .skip(searchConditions.limit * (page - 1));
946
542
  }
947
- return aggregate.exec();
543
+ return aggregate
544
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
545
+ .exec();
948
546
  });
949
547
  }
950
548
  findScreeningRoomsByBranchCode(params) {
@@ -983,6 +581,7 @@ class MongoRepository {
983
581
  }
984
582
  ]);
985
583
  const docs = yield aggregate.limit(1)
584
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
986
585
  .exec();
987
586
  if (docs.length < 1) {
988
587
  throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
@@ -990,310 +589,6 @@ class MongoRepository {
990
589
  return docs[0];
991
590
  });
992
591
  }
993
- // tslint:disable-next-line:max-func-body-length
994
- createSeat(seat) {
995
- var _a, _b, _c;
996
- return __awaiter(this, void 0, void 0, function* () {
997
- const screeningRoomSection = seat.containedInPlace;
998
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
999
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1000
- }
1001
- const screeningRoom = screeningRoomSection.containedInPlace;
1002
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1003
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1004
- }
1005
- const movieTheater = screeningRoom.containedInPlace;
1006
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1007
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1008
- }
1009
- // 施設存在確認
1010
- let doc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: seat.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
1011
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
1012
- : undefined), { _id: 1 })
1013
- .exec();
1014
- if (doc === null) {
1015
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
1016
- }
1017
- doc = yield this.placeModel.findOneAndUpdate({
1018
- typeOf: { $eq: factory.placeType.ScreeningRoom },
1019
- 'project.id': { $eq: seat.project.id },
1020
- 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
1021
- branchCode: { $eq: screeningRoom.branchCode },
1022
- 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
1023
- }, {
1024
- $push: {
1025
- 'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign({ typeOf: seat.typeOf, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.ja) === 'string' || typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined)
1026
- }
1027
- }, {
1028
- new: true,
1029
- arrayFilters: [
1030
- {
1031
- 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode },
1032
- 'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
1033
- }
1034
- ],
1035
- projection: { 'containedInPlace.id': 1, typeOf: 1 }
1036
- })
1037
- .exec();
1038
- // 存在しなければコード重複
1039
- if (doc === null) {
1040
- throw new factory.errors.AlreadyInUse(factory.placeType.Seat, ['branchCode']);
1041
- }
1042
- return doc.toObject();
1043
- });
1044
- }
1045
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
1046
- updateSeat(seat, $unset) {
1047
- var _a, _b, _c;
1048
- return __awaiter(this, void 0, void 0, function* () {
1049
- const screeningRoomSection = seat.containedInPlace;
1050
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
1051
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
1052
- }
1053
- const screeningRoom = screeningRoomSection.containedInPlace;
1054
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
1055
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
1056
- }
1057
- const movieTheater = screeningRoom.containedInPlace;
1058
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
1059
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
1060
- }
1061
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: seat.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
1062
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
1063
- : undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.ja) === 'string' || typeof ((_c = seat.name) === null || _c === void 0 ? void 0 : _c.en) === 'string')
1064
- ? {
1065
- 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
1066
- }
1067
- : undefined), (Array.isArray(seat.seatingType))
1068
- ? {
1069
- 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': seat.seatingType
1070
- }
1071
- : undefined), (Array.isArray(seat.additionalProperty))
1072
- ? {
1073
- 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': seat.additionalProperty
1074
- }
1075
- : undefined), { $unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].name'])
1076
- === 1
1077
- || ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].name']) === 1)
1078
- ? {
1079
- 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': 1
1080
- }
1081
- : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoom].containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType'])
1082
- === 1
1083
- || ($unset === null || $unset === void 0 ? void 0 : $unset['containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType']) === 1)
1084
- ? {
1085
- 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': 1
1086
- }
1087
- : undefined) }), {
1088
- new: true,
1089
- arrayFilters: [
1090
- { 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
1091
- { 'seat.branchCode': { $eq: seat.branchCode } }
1092
- ],
1093
- projection: { 'containedInPlace.id': 1, typeOf: 1 }
1094
- })
1095
- .exec();
1096
- if (doc === null) {
1097
- throw new factory.errors.NotFound(factory.placeType.Seat);
1098
- }
1099
- return doc.toObject();
1100
- });
1101
- }
1102
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
1103
- searchSeats(params) {
1104
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1105
- return __awaiter(this, void 0, void 0, function* () {
1106
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
1107
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
1108
- if (typeof projectIdEq === 'string') {
1109
- matchStages.push({
1110
- $match: { 'project.id': { $eq: projectIdEq } }
1111
- });
1112
- }
1113
- const parentOrganizationIdEq = (_d = (_c = params.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
1114
- if (typeof parentOrganizationIdEq === 'string') {
1115
- matchStages.push({
1116
- $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
1117
- });
1118
- }
1119
- const containedInPlaceBranchCodeEq = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$eq;
1120
- if (typeof containedInPlaceBranchCodeEq === 'string') {
1121
- matchStages.push({
1122
- $match: {
1123
- 'containsPlace.branchCode': {
1124
- $exists: true,
1125
- $eq: containedInPlaceBranchCodeEq
1126
- }
1127
- }
1128
- });
1129
- }
1130
- const containedInPlaceBranchCodeIn = (_h = (_g = params.containedInPlace) === null || _g === void 0 ? void 0 : _g.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
1131
- if (Array.isArray(containedInPlaceBranchCodeIn)) {
1132
- matchStages.push({
1133
- $match: {
1134
- 'containsPlace.branchCode': {
1135
- $exists: true,
1136
- $in: containedInPlaceBranchCodeIn
1137
- }
1138
- }
1139
- });
1140
- }
1141
- if (params.containedInPlace !== undefined) {
1142
- if (params.containedInPlace.containedInPlace !== undefined) {
1143
- if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
1144
- if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1145
- matchStages.push({
1146
- $match: {
1147
- branchCode: {
1148
- $eq: params.containedInPlace.containedInPlace.branchCode.$eq
1149
- }
1150
- }
1151
- });
1152
- }
1153
- }
1154
- if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
1155
- if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
1156
- if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
1157
- matchStages.push({
1158
- $match: {
1159
- 'containedInPlace.branchCode': {
1160
- $exists: true,
1161
- $eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
1162
- }
1163
- }
1164
- });
1165
- }
1166
- }
1167
- }
1168
- }
1169
- }
1170
- // 座席コード
1171
- if (params.branchCode !== undefined) {
1172
- if (typeof params.branchCode.$eq === 'string') {
1173
- matchStages.push({
1174
- $match: {
1175
- 'containsPlace.containsPlace.branchCode': {
1176
- $exists: true,
1177
- $eq: params.branchCode.$eq
1178
- }
1179
- }
1180
- });
1181
- }
1182
- }
1183
- const branchCodeIn = (_j = params.branchCode) === null || _j === void 0 ? void 0 : _j.$in;
1184
- if (Array.isArray(branchCodeIn)) {
1185
- matchStages.push({
1186
- $match: {
1187
- 'containsPlace.containsPlace.branchCode': {
1188
- $exists: true,
1189
- $in: branchCodeIn
1190
- }
1191
- }
1192
- });
1193
- }
1194
- const branchCodeRegex = (_k = params.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
1195
- if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
1196
- matchStages.push({
1197
- $match: {
1198
- 'containsPlace.containsPlace.branchCode': {
1199
- $exists: true,
1200
- $regex: new RegExp(branchCodeRegex)
1201
- }
1202
- }
1203
- });
1204
- }
1205
- const nameRegex = (_l = params.name) === null || _l === void 0 ? void 0 : _l.$regex;
1206
- if (typeof nameRegex === 'string' && nameRegex.length > 0) {
1207
- matchStages.push({
1208
- $match: {
1209
- $or: [
1210
- {
1211
- 'containsPlace.containsPlace.name.ja': {
1212
- $exists: true,
1213
- $regex: new RegExp(nameRegex)
1214
- }
1215
- },
1216
- {
1217
- 'containsPlace.containsPlace.name.en': {
1218
- $exists: true,
1219
- $regex: new RegExp(nameRegex)
1220
- }
1221
- }
1222
- ]
1223
- }
1224
- });
1225
- }
1226
- const seatingTypeEq = (_m = params.seatingType) === null || _m === void 0 ? void 0 : _m.$eq;
1227
- if (typeof seatingTypeEq === 'string') {
1228
- matchStages.push({
1229
- $match: {
1230
- 'containsPlace.containsPlace.seatingType': {
1231
- $exists: true,
1232
- $eq: seatingTypeEq
1233
- }
1234
- }
1235
- });
1236
- }
1237
- const additionalPropertyElemMatch = (_o = params.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
1238
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1239
- matchStages.push({
1240
- $match: {
1241
- 'containsPlace.containsPlace.additionalProperty': {
1242
- $exists: true,
1243
- $elemMatch: additionalPropertyElemMatch
1244
- }
1245
- }
1246
- });
1247
- }
1248
- const projectStage = MongoRepository.CREATE_SEARCH_SEATS_PROJECTION(Object.assign({}, params.$projection));
1249
- const aggregate = this.placeModel.aggregate([
1250
- { $unwind: '$containsPlace' },
1251
- { $unwind: '$containsPlace.containsPlace' },
1252
- ...matchStages,
1253
- { $project: projectStage }
1254
- ]);
1255
- if (typeof params.limit === 'number' && params.limit > 0) {
1256
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1257
- aggregate.limit(params.limit * page)
1258
- .skip(params.limit * (page - 1));
1259
- }
1260
- return aggregate.exec();
1261
- });
1262
- }
1263
- deleteSeat(seat) {
1264
- var _a;
1265
- return __awaiter(this, void 0, void 0, function* () {
1266
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: seat.project.id }, 'containedInPlace.branchCode': {
1267
- $exists: true,
1268
- $eq: seat.containedInPlace.containedInPlace.containedInPlace.branchCode
1269
- }, branchCode: { $eq: seat.containedInPlace.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: seat.containedInPlace.branchCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof ((_a = seat.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
1270
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
1271
- : undefined), {
1272
- $pull: {
1273
- 'containsPlace.$[screeningRoomSection].containsPlace': {
1274
- branchCode: seat.branchCode
1275
- }
1276
- }
1277
- }, {
1278
- new: true,
1279
- arrayFilters: [
1280
- { 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
1281
- ],
1282
- projection: { 'containedInPlace.id': 1, typeOf: 1 }
1283
- })
1284
- .exec();
1285
- if (doc === null) {
1286
- throw new factory.errors.NotFound(factory.placeType.Seat);
1287
- }
1288
- return doc.toObject();
1289
- });
1290
- }
1291
- unsetUnnecessaryFieldsFromMovieTheater(params) {
1292
- return __awaiter(this, void 0, void 0, function* () {
1293
- return this.placeModel.updateMany(params.filter, { $unset: params.$unset })
1294
- .exec();
1295
- });
1296
- }
1297
592
  deleteManyByParentOrganizationId(params) {
1298
593
  return __awaiter(this, void 0, void 0, function* () {
1299
594
  return this.placeModel.deleteMany({
@@ -1311,94 +606,6 @@ class MongoRepository {
1311
606
  .exec();
1312
607
  });
1313
608
  }
1314
- saveBusStop(params) {
1315
- return __awaiter(this, void 0, void 0, function* () {
1316
- let doc;
1317
- if (typeof params.id !== 'string' || params.id.length === 0) {
1318
- doc = yield this.placeModel.create(params);
1319
- }
1320
- else {
1321
- // 上書き禁止属性を除外(2022-08-24~)
1322
- const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
1323
- doc = yield this.placeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
1324
- .exec();
1325
- }
1326
- if (doc === null) {
1327
- throw new factory.errors.NotFound(this.placeModel.modelName);
1328
- }
1329
- return doc.toObject();
1330
- });
1331
- }
1332
- findBusStopByBranchCode(params) {
1333
- return __awaiter(this, void 0, void 0, function* () {
1334
- return this.placeModel.findOne({
1335
- typeOf: { $eq: factory.placeType.BusStop },
1336
- 'project.id': { $eq: params.project.id },
1337
- branchCode: { $eq: params.branchCode }
1338
- })
1339
- .exec()
1340
- .then((doc) => {
1341
- if (doc === null) {
1342
- throw new factory.errors.NotFound(`${factory.placeType.BusStop} ${params.branchCode}`);
1343
- }
1344
- return doc.toObject();
1345
- });
1346
- });
1347
- }
1348
- searchBusStops(params) {
1349
- var _a;
1350
- return __awaiter(this, void 0, void 0, function* () {
1351
- const conditions = MongoRepository.CREATE_BUS_STOP_MONGO_CONDITIONS(params);
1352
- // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
1353
- const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
1354
- __v: 0,
1355
- createdAt: 0,
1356
- updatedAt: 0,
1357
- containsPlace: 0
1358
- });
1359
- if (typeof params.limit === 'number' && params.limit > 0) {
1360
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1361
- query.limit(params.limit)
1362
- .skip(params.limit * (page - 1));
1363
- }
1364
- // tslint:disable-next-line:no-single-line-block-comment
1365
- /* istanbul ignore else */
1366
- if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
1367
- query.sort({ branchCode: params.sort.branchCode });
1368
- }
1369
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1370
- .exec()
1371
- .then((docs) => docs.map((doc) => doc.toObject()));
1372
- });
1373
- }
1374
- findBusStopById(params, projection) {
1375
- return __awaiter(this, void 0, void 0, function* () {
1376
- const doc = yield this.placeModel.findOne({
1377
- typeOf: { $eq: factory.placeType.BusStop },
1378
- _id: { $eq: params.id }
1379
- }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
1380
- .exec();
1381
- if (doc === null) {
1382
- throw new factory.errors.NotFound(this.placeModel.modelName);
1383
- }
1384
- return doc.toObject();
1385
- });
1386
- }
1387
- deleteBusStopById(params) {
1388
- return __awaiter(this, void 0, void 0, function* () {
1389
- yield this.placeModel.findOneAndDelete({
1390
- typeOf: { $eq: factory.placeType.BusStop },
1391
- _id: { $eq: params.id },
1392
- 'project.id': { $eq: params.project.id }
1393
- })
1394
- .exec()
1395
- .then((doc) => {
1396
- if (doc === null) {
1397
- throw new factory.errors.NotFound(this.placeModel.modelName);
1398
- }
1399
- });
1400
- });
1401
- }
1402
609
  getCursor(conditions, projection) {
1403
610
  return this.placeModel.find(conditions, projection)
1404
611
  .sort({ branchCode: factory.sortType.Ascending })