@chevre/domain 23.2.0-alpha.1 → 23.2.0-alpha.10

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 (30) hide show
  1. package/example/src/chevre/actions/checkAuthorizePaymentActions.ts +55 -0
  2. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  3. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  4. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  5. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  6. package/example/src/chevre/roles/addAdminSeatReadPermissionIfNotExists.ts +33 -0
  7. package/example/src/chevre/roles/addAdminSeatWritePermissionIfNotExists.ts +33 -0
  8. package/lib/chevre/repo/acceptedPaymentMethod.js +14 -10
  9. package/lib/chevre/repo/creativeWork.js +9 -5
  10. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  11. package/lib/chevre/repo/place/screeningRoom.d.ts +35 -31
  12. package/lib/chevre/repo/place/screeningRoom.js +20 -20
  13. package/lib/chevre/repo/place/seat.d.ts +16 -45
  14. package/lib/chevre/repo/place/seat.js +25 -47
  15. package/lib/chevre/repo/place/section.d.ts +28 -29
  16. package/lib/chevre/repo/place/section.js +86 -39
  17. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +6 -1
  18. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +26 -4
  19. package/lib/chevre/service/assetTransaction/pay.d.ts +3 -0
  20. package/lib/chevre/service/payment/any/factory.d.ts +5 -0
  21. package/lib/chevre/service/payment/any/factory.js +11 -2
  22. package/lib/chevre/service/payment/any.d.ts +8 -0
  23. package/lib/chevre/service/payment/any.js +3 -2
  24. package/lib/chevre/service/task/authorizePayment.js +3 -1
  25. package/lib/chevre/service/task/publishPaymentUrl.js +3 -1
  26. package/lib/chevre/service/task/syncResourcesFromCOA.js +148 -15
  27. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +2 -2
  28. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +3 -1
  29. package/lib/chevre/service/transaction/placeOrder/confirm.js +3 -1
  30. package/package.json +2 -2
@@ -79,29 +79,24 @@ class ScreeningRoomRepo {
79
79
  })));
80
80
  });
81
81
  }
82
- createScreeningRoom(screeningRoom) {
82
+ createRoom(screeningRoom, options) {
83
83
  return __awaiter(this, void 0, void 0, function* () {
84
- var _a;
84
+ const { project, parentOrganization, movieTheaterCode } = options;
85
85
  // 施設存在確認
86
- const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoom.project.id }, branchCode: { $eq: screeningRoom.containedInPlace.branchCode } }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
87
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
86
+ const movieTheater = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
87
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
88
88
  : undefined), { _id: 0, id: { $toString: '$_id' }, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
89
89
  .lean()
90
90
  .exec();
91
- if (movieTheaterDoc === null) {
91
+ if (movieTheater === null) {
92
92
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
93
93
  }
94
- // const movieTheater = <Pick<
95
- // factory.place.movieTheater.IPlace,
96
- // 'id' | 'typeOf' | 'branchCode' | 'name' | 'parentOrganization'
97
- // >>movieTheaterDoc.toObject();
98
- const movieTheater = movieTheaterDoc;
99
- const creatingScreeningRoom = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
94
+ const creatingScreeningRoom = Object.assign({ typeOf: factory.placeType.ScreeningRoom, branchCode: screeningRoom.branchCode, name: screeningRoom.name, address: screeningRoom.address, additionalProperty: (Array.isArray(screeningRoom.additionalProperty)) ? screeningRoom.additionalProperty : [], containedInPlace: {
100
95
  id: movieTheater.id,
101
96
  typeOf: movieTheater.typeOf,
102
97
  branchCode: movieTheater.branchCode,
103
98
  name: movieTheater.name
104
- }, containsPlace: [], project: screeningRoom.project,
99
+ }, containsPlace: [], project: { id: project.id, typeOf: factory.organizationType.Project },
105
100
  // 必須化(2023-07-14~)
106
101
  parentOrganization: movieTheater.parentOrganization }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
107
102
  ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
@@ -125,11 +120,11 @@ class ScreeningRoomRepo {
125
120
  };
126
121
  });
127
122
  }
128
- updateScreeningRoom(screeningRoom, $unset) {
123
+ updateRoomByBranchCode(screeningRoom, $unset, options) {
129
124
  return __awaiter(this, void 0, void 0, function* () {
130
- var _a;
131
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoom.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode }, branchCode: screeningRoom.branchCode }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
132
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
125
+ const { project, parentOrganization, movieTheaterCode } = options;
126
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: screeningRoom.branchCode }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
127
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
133
128
  : undefined), Object.assign(Object.assign(Object.assign(Object.assign({ name: screeningRoom.name }, (screeningRoom.address !== undefined && screeningRoom.address !== null)
134
129
  ? { address: screeningRoom.address }
135
130
  : undefined), (typeof screeningRoom.openSeatingAllowed === 'boolean')
@@ -169,11 +164,11 @@ class ScreeningRoomRepo {
169
164
  }
170
165
  });
171
166
  }
172
- deleteScreeningRoom(screeningRoom) {
167
+ deleteRoomByBranchCode(screeningRoom, options) {
173
168
  return __awaiter(this, void 0, void 0, function* () {
174
- var _a;
175
- const doc = yield this.placeModel.findOneAndDelete(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoom.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode }, branchCode: screeningRoom.branchCode }, (typeof ((_a = screeningRoom.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
176
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoom.parentOrganization.id } }
169
+ const { project, parentOrganization, movieTheaterCode } = options;
170
+ const doc = yield this.placeModel.findOneAndDelete(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: screeningRoom.branchCode }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
171
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
177
172
  : undefined), {
178
173
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
179
174
  })
@@ -430,5 +425,10 @@ class ScreeningRoomRepo {
430
425
  .exec();
431
426
  });
432
427
  }
428
+ getCursor(conditions, projection) {
429
+ return this.placeModel.find(conditions, projection)
430
+ .sort({ branchCode: factory.sortType.Ascending })
431
+ .cursor();
432
+ }
433
433
  }
434
434
  exports.ScreeningRoomRepo = ScreeningRoomRepo;
@@ -1,6 +1,18 @@
1
1
  import type { AnyExpression, Connection, PipelineStage } from 'mongoose';
2
2
  import * as factory from '../../factory';
3
3
  type IMatchStage = PipelineStage.Match;
4
+ type ICreatingSeat = Pick<factory.place.seat.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'maximumAttendeeCapacity' | 'seatingType'>;
5
+ interface IUpdateOptions {
6
+ project: {
7
+ id: string;
8
+ };
9
+ parentOrganization?: {
10
+ id?: string;
11
+ };
12
+ movieTheaterCode: string;
13
+ roomCode: string;
14
+ sectionCode: string;
15
+ }
4
16
  /**
5
17
  * 座席編集時レスポンス
6
18
  */
@@ -27,25 +39,8 @@ export declare class SeatRepo {
27
39
  static CREATE_MATCH_STAGES(params: factory.place.seat.ISearchConditions, options: {
28
40
  filterTypeOf: boolean;
29
41
  }): IMatchStage[];
30
- createSeat(seat: factory.place.seat.IPlace & {
31
- parentOrganization?: {
32
- id?: string;
33
- };
34
- }): Promise<IUpdateSeatResult>;
35
- updateSeat(seat: Omit<factory.place.seat.IPlace, 'containedInPlace'> & {
36
- containedInPlace: {
37
- branchCode: string;
38
- containedInPlace: {
39
- branchCode: string;
40
- containedInPlace: {
41
- branchCode: string;
42
- };
43
- };
44
- };
45
- parentOrganization?: {
46
- id?: string;
47
- };
48
- }, $unset: any): Promise<IUpdateSeatResult>;
42
+ createSeat(seat: ICreatingSeat, options: IUpdateOptions): Promise<IUpdateSeatResult>;
43
+ updateSeatByBranchCode(seat: ICreatingSeat, $unset: any, options: IUpdateOptions): Promise<IUpdateSeatResult>;
49
44
  searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
50
45
  projectSeatsByScreeningRoom(params: Pick<factory.place.seat.ISearchConditions, '$projection' | 'additionalProperty' | 'branchCode' | 'seatingType' | 'name' | 'limit' | 'page'> & {
51
46
  project: {
@@ -137,35 +132,11 @@ export declare class SeatRepo {
137
132
  };
138
133
  };
139
134
  }): Promise<string[]>;
140
- deleteSeat(seat: {
141
- project: {
142
- id: string;
143
- };
144
- parentOrganization?: {
145
- id?: string;
146
- };
135
+ deleteSeatByBranchCode(seat: {
147
136
  /**
148
137
  * 座席コード
149
138
  */
150
139
  branchCode: string;
151
- containedInPlace: {
152
- /**
153
- * セクションコード
154
- */
155
- branchCode: string;
156
- containedInPlace: {
157
- /**
158
- * ルームコード
159
- */
160
- branchCode: string;
161
- containedInPlace: {
162
- /**
163
- * 施設コード
164
- */
165
- branchCode: string;
166
- };
167
- };
168
- };
169
- }): Promise<IUpdateSeatResult>;
140
+ }, options: IUpdateOptions): Promise<IUpdateSeatResult>;
170
141
  }
171
142
  export {};
@@ -226,24 +226,13 @@ class SeatRepo {
226
226
  return matchStages;
227
227
  }
228
228
  // tslint:disable-next-line:max-func-body-length
229
- createSeat(seat) {
229
+ createSeat(seat, options) {
230
230
  return __awaiter(this, void 0, void 0, function* () {
231
- var _a, _b, _c;
232
- const screeningRoomSection = seat.containedInPlace;
233
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
234
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
235
- }
236
- const screeningRoom = screeningRoomSection.containedInPlace;
237
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
238
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
239
- }
240
- const movieTheater = screeningRoom.containedInPlace;
241
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
242
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
243
- }
231
+ var _a, _b;
232
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
244
233
  // 施設存在確認
245
- const movieTheaterDoc = yield this.civicStructureModel.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')
246
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
234
+ const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
235
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
247
236
  : undefined), { _id: 1 })
248
237
  .lean()
249
238
  .exec();
@@ -252,19 +241,19 @@ class SeatRepo {
252
241
  }
253
242
  const doc = yield this.placeModel.findOneAndUpdate({
254
243
  typeOf: { $eq: factory.placeType.ScreeningRoom },
255
- 'project.id': { $eq: seat.project.id },
256
- 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
257
- branchCode: { $eq: screeningRoom.branchCode },
258
- 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
244
+ 'project.id': { $eq: project.id },
245
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
246
+ branchCode: { $eq: roomCode },
247
+ 'containsPlace.branchCode': { $eq: sectionCode }
259
248
  }, {
260
249
  $push: {
261
- 'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(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), (seat.maximumAttendeeCapacity === 0) ? { maximumAttendeeCapacity: seat.maximumAttendeeCapacity } : undefined)
250
+ 'containsPlace.$[screeningRoomSection].containsPlace': Object.assign(Object.assign(Object.assign({ typeOf: factory.placeType.Seat, branchCode: seat.branchCode, additionalProperty: seat.additionalProperty }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string') ? { name: seat.name } : undefined), (Array.isArray(seat.seatingType)) ? { seatingType: seat.seatingType } : undefined), (seat.maximumAttendeeCapacity === 0) ? { maximumAttendeeCapacity: seat.maximumAttendeeCapacity } : undefined)
262
251
  }
263
252
  }, {
264
253
  new: true,
265
254
  arrayFilters: [
266
255
  {
267
- 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode },
256
+ 'screeningRoomSection.branchCode': { $eq: sectionCode },
268
257
  'screeningRoomSection.containsPlace.branchCode': { $ne: seat.branchCode }
269
258
  }
270
259
  ],
@@ -279,24 +268,13 @@ class SeatRepo {
279
268
  });
280
269
  }
281
270
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
282
- updateSeat(seat, $unset) {
271
+ updateSeatByBranchCode(seat, $unset, options) {
283
272
  return __awaiter(this, void 0, void 0, function* () {
284
- var _a, _b, _c;
285
- const screeningRoomSection = seat.containedInPlace;
286
- if (typeof (screeningRoomSection === null || screeningRoomSection === void 0 ? void 0 : screeningRoomSection.branchCode) !== 'string') {
287
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
288
- }
289
- const screeningRoom = screeningRoomSection.containedInPlace;
290
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
291
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
292
- }
293
- const movieTheater = screeningRoom.containedInPlace;
294
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
295
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
296
- }
297
- 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')
298
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
299
- : undefined), Object.assign(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')
273
+ var _a, _b;
274
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
275
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: sectionCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
276
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
277
+ : undefined), Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': seat.branchCode }, (typeof ((_a = seat.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = seat.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
300
278
  ? {
301
279
  'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
302
280
  }
@@ -333,7 +311,7 @@ class SeatRepo {
333
311
  : undefined) }), {
334
312
  new: true,
335
313
  arrayFilters: [
336
- { 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
314
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } },
337
315
  { 'seat.branchCode': { $eq: seat.branchCode } }
338
316
  ],
339
317
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
@@ -585,14 +563,14 @@ class SeatRepo {
585
563
  return (result !== undefined) ? result.seatingTypes : [];
586
564
  });
587
565
  }
588
- deleteSeat(seat) {
566
+ deleteSeatByBranchCode(seat, options) {
589
567
  return __awaiter(this, void 0, void 0, function* () {
590
- var _a;
591
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: seat.project.id }, 'containedInPlace.branchCode': {
568
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
569
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
592
570
  $exists: true,
593
- $eq: seat.containedInPlace.containedInPlace.containedInPlace.branchCode
594
- }, 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')
595
- ? { 'parentOrganization.id': { $exists: true, $eq: seat.parentOrganization.id } }
571
+ $eq: movieTheaterCode
572
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: sectionCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
573
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
596
574
  : undefined), {
597
575
  $pull: {
598
576
  'containsPlace.$[screeningRoomSection].containsPlace': {
@@ -602,7 +580,7 @@ class SeatRepo {
602
580
  }, {
603
581
  new: true,
604
582
  arrayFilters: [
605
- { 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
583
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } }
606
584
  ],
607
585
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
608
586
  })
@@ -1,6 +1,17 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import * as factory from '../../factory';
3
3
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
4
+ type ICreatingSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
5
+ interface IUpdateOptions {
6
+ project: {
7
+ id: string;
8
+ };
9
+ parentOrganization?: {
10
+ id?: string;
11
+ };
12
+ movieTheaterCode: string;
13
+ roomCode: string;
14
+ }
4
15
  /**
5
16
  * セクション編集時レスポンス
6
17
  */
@@ -20,22 +31,28 @@ export declare class SectionRepo {
20
31
  private readonly civicStructureModel;
21
32
  private readonly placeModel;
22
33
  constructor(connection: Connection);
23
- createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
24
- parentOrganization?: {
25
- id?: string;
34
+ createSection(screeningRoomSection: ICreatingSection, options: IUpdateOptions): Promise<IUpdateSectionResult>;
35
+ /**
36
+ * セクションの名称と追加特性を編集する
37
+ */
38
+ updateSectionByBranchCode(screeningRoomSection: ICreatingSection, $unset: any, options: IUpdateOptions): Promise<IUpdateSectionResult>;
39
+ /**
40
+ * セクションの座席を上書きする
41
+ */
42
+ overwriteSeats(screeningRoomSection: Pick<factory.place.screeningRoomSection.IPlace, 'branchCode' | 'containsPlace'>, options: IUpdateOptions): Promise<IUpdateSectionResult>;
43
+ migrateSectionIdentifier(screeningRoomSection: {
44
+ project: {
45
+ id: string;
26
46
  };
27
- }): Promise<IUpdateSectionResult>;
28
- updateScreeningRoomSection(screeningRoomSection: Omit<factory.place.screeningRoomSection.IPlace, 'containedInPlace'> & {
47
+ identifier: string;
48
+ branchCode: string;
29
49
  containedInPlace: {
30
50
  branchCode: string;
31
51
  containedInPlace: {
32
52
  branchCode: string;
33
53
  };
34
54
  };
35
- parentOrganization?: {
36
- id?: string;
37
- };
38
- }, $unset: any): Promise<IUpdateSectionResult>;
55
+ }): Promise<IUpdateSectionResult>;
39
56
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
40
57
  /**
41
58
  * ルーム指定のセクション検索として再定義(2025-12-07~)
@@ -57,29 +74,11 @@ export declare class SectionRepo {
57
74
  */
58
75
  roomCode: string;
59
76
  }): Promise<Pick<IScreeningRoomSectionWithoutContainsPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
60
- deleteScreeningRoomSection(screeningRoomSection: {
61
- project: {
62
- id: string;
63
- };
64
- parentOrganization?: {
65
- id?: string;
66
- };
77
+ deleteSectionByBranchCode(screeningRoomSection: {
67
78
  /**
68
79
  * セクションコード
69
80
  */
70
81
  branchCode: string;
71
- containedInPlace: {
72
- /**
73
- * ルームコード
74
- */
75
- branchCode: string;
76
- containedInPlace: {
77
- /**
78
- * 施設コード
79
- */
80
- branchCode: string;
81
- };
82
- };
83
- }): Promise<IUpdateSectionResult>;
82
+ }, options: IUpdateOptions): Promise<IUpdateSectionResult>;
84
83
  }
85
84
  export {};
@@ -23,20 +23,12 @@ class SectionRepo {
23
23
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
24
24
  }
25
25
  // tslint:disable-next-line:max-func-body-length
26
- createScreeningRoomSection(screeningRoomSection) {
26
+ createSection(screeningRoomSection, options) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- var _a;
29
- const screeningRoom = screeningRoomSection.containedInPlace;
30
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
31
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
32
- }
33
- const movieTheater = screeningRoom.containedInPlace;
34
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
35
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
36
- }
28
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
37
29
  // 施設存在確認
38
- const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: screeningRoomSection.project.id }, branchCode: { $eq: movieTheater.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
39
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
30
+ const movieTheaterDoc = yield this.civicStructureModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.MovieTheater }, 'project.id': { $eq: project.id }, branchCode: { $eq: movieTheaterCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
31
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
40
32
  : undefined), { _id: 1 })
41
33
  .lean()
42
34
  .exec();
@@ -46,13 +38,13 @@ class SectionRepo {
46
38
  // セクションコードが存在しなければ追加する
47
39
  const doc = yield this.placeModel.findOneAndUpdate({
48
40
  typeOf: { $eq: factory.placeType.ScreeningRoom },
49
- 'project.id': { $eq: screeningRoomSection.project.id },
50
- 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
51
- branchCode: { $eq: screeningRoom.branchCode },
41
+ 'project.id': { $eq: project.id },
42
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
43
+ branchCode: { $eq: roomCode },
52
44
  'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
53
45
  }, {
54
46
  $push: {
55
- containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
47
+ containsPlace: Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
56
48
  ? { additionalProperty: screeningRoomSection.additionalProperty }
57
49
  : undefined)
58
50
  }
@@ -68,21 +60,16 @@ class SectionRepo {
68
60
  return doc.toObject();
69
61
  });
70
62
  }
63
+ /**
64
+ * セクションの名称と追加特性を編集する
65
+ */
71
66
  // tslint:disable-next-line:max-func-body-length
72
- updateScreeningRoomSection(screeningRoomSection, $unset) {
67
+ updateSectionByBranchCode(screeningRoomSection, $unset, options) {
73
68
  return __awaiter(this, void 0, void 0, function* () {
74
- var _a;
75
- const screeningRoom = screeningRoomSection.containedInPlace;
76
- if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
77
- throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
78
- }
79
- const movieTheater = screeningRoom.containedInPlace;
80
- if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
81
- throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
82
- }
83
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode }, branchCode: { $eq: screeningRoom.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
84
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
85
- : undefined), Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
69
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
70
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
71
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
72
+ : undefined), Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
86
73
  ? {
87
74
  'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
88
75
  }
@@ -90,13 +77,73 @@ class SectionRepo {
90
77
  ? {
91
78
  'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
92
79
  }
93
- : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
80
+ : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
81
+ new: true,
82
+ arrayFilters: [
83
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
84
+ ],
85
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
86
+ })
87
+ .exec();
88
+ if (doc === null) {
89
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
90
+ }
91
+ return doc.toObject();
92
+ });
93
+ }
94
+ /**
95
+ * セクションの座席を上書きする
96
+ */
97
+ // tslint:disable-next-line:max-func-body-length
98
+ overwriteSeats(screeningRoomSection, options) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
101
+ const { containsPlace } = screeningRoomSection;
102
+ if (!Array.isArray(containsPlace)) {
103
+ throw new factory.errors.ArgumentNull('containsPlace');
104
+ }
105
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
106
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
107
+ : undefined), Object.assign({}, (containsPlace.length > 0)
94
108
  ? {
95
- 'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
109
+ 'containsPlace.$[screeningRoomSection].containsPlace': containsPlace.map((p) => {
96
110
  return Object.assign(Object.assign(Object.assign({ typeOf: p.typeOf, branchCode: p.branchCode }, (p.name !== undefined && p.name !== null) ? { name: p.name } : undefined), (Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined), (Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined);
97
111
  })
98
112
  }
99
- : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
113
+ : undefined), {
114
+ new: true,
115
+ arrayFilters: [
116
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
117
+ ],
118
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
119
+ })
120
+ .exec();
121
+ if (doc === null) {
122
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
123
+ }
124
+ return doc.toObject();
125
+ });
126
+ }
127
+ // tslint:disable-next-line:max-func-body-length
128
+ migrateSectionIdentifier(screeningRoomSection) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const screeningRoom = screeningRoomSection.containedInPlace;
131
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
132
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
133
+ }
134
+ const movieTheater = screeningRoom.containedInPlace;
135
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
136
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
137
+ }
138
+ const doc = yield this.placeModel.findOneAndUpdate({
139
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
140
+ 'project.id': { $eq: screeningRoomSection.project.id },
141
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
142
+ branchCode: { $eq: screeningRoom.branchCode },
143
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
144
+ }, {
145
+ 'containsPlace.$[screeningRoomSection].identifier': screeningRoomSection.identifier
146
+ }, {
100
147
  new: true,
101
148
  arrayFilters: [
102
149
  { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
@@ -209,7 +256,7 @@ class SectionRepo {
209
256
  { $unwind: '$containsPlace' },
210
257
  ...matchStages,
211
258
  {
212
- $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
259
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', identifier: '$containsPlace.identifier', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
213
260
  ? {
214
261
  containedInPlace: {
215
262
  typeOf: '$typeOf',
@@ -295,14 +342,14 @@ class SectionRepo {
295
342
  .exec();
296
343
  });
297
344
  }
298
- deleteScreeningRoomSection(screeningRoomSection) {
345
+ deleteSectionByBranchCode(screeningRoomSection, options) {
299
346
  return __awaiter(this, void 0, void 0, function* () {
300
- var _a;
301
- const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: screeningRoomSection.project.id }, 'containedInPlace.branchCode': {
347
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
348
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
302
349
  $exists: true,
303
- $eq: screeningRoomSection.containedInPlace.containedInPlace.branchCode
304
- }, branchCode: { $eq: screeningRoomSection.containedInPlace.branchCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof ((_a = screeningRoomSection.parentOrganization) === null || _a === void 0 ? void 0 : _a.id) === 'string')
305
- ? { 'parentOrganization.id': { $exists: true, $eq: screeningRoomSection.parentOrganization.id } }
350
+ $eq: movieTheaterCode
351
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
352
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
306
353
  : undefined), {
307
354
  $pull: {
308
355
  containsPlace: {
@@ -1,16 +1,21 @@
1
1
  import * as factory from '../../../factory';
2
+ import type { AcceptedPaymentMethodRepo } from '../../../repo/acceptedPaymentMethod';
2
3
  import type { EventRepo } from '../../../repo/event';
3
4
  import type { EventSeriesRepo } from '../../../repo/eventSeries';
4
5
  /**
5
6
  * 必要あらば関連リソースの対応決済方法を検証する
6
7
  */
7
- export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> | {
8
+ export declare function validateAcceptedPaymentMethodIfNeeded(params: Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object'> & {
9
+ instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
10
+ } | {
8
11
  object: factory.action.accept.pay.IPayObject & {
9
12
  paymentMethod: factory.action.accept.pay.IPaymentMethod & {
10
13
  movieTickets: never;
11
14
  };
12
15
  };
16
+ instrument: factory.action.accept.pay.IInstrument[];
13
17
  }): (repos: {
18
+ acceptedPaymentMethod: AcceptedPaymentMethodRepo;
14
19
  event: EventRepo;
15
20
  eventSeries: EventSeriesRepo;
16
21
  }) => Promise<void>;