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

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/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/place/upsertSeatsByBranchCode.ts +72 -0
  5. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  6. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  7. package/example/src/chevre/roles/addAdminSeatReadPermissionIfNotExists.ts +33 -0
  8. package/example/src/chevre/roles/addAdminSeatWritePermissionIfNotExists.ts +33 -0
  9. package/lib/chevre/repo/acceptedPaymentMethod.js +14 -10
  10. package/lib/chevre/repo/creativeWork.js +9 -5
  11. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  12. package/lib/chevre/repo/place/screeningRoom.d.ts +35 -31
  13. package/lib/chevre/repo/place/screeningRoom.js +20 -20
  14. package/lib/chevre/repo/place/seat.d.ts +36 -45
  15. package/lib/chevre/repo/place/seat.js +140 -45
  16. package/lib/chevre/repo/place/section.d.ts +28 -29
  17. package/lib/chevre/repo/place/section.js +86 -39
  18. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +6 -1
  19. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +26 -4
  20. package/lib/chevre/service/assetTransaction/pay.d.ts +3 -0
  21. package/lib/chevre/service/payment/any/factory.d.ts +5 -0
  22. package/lib/chevre/service/payment/any/factory.js +11 -2
  23. package/lib/chevre/service/payment/any.d.ts +8 -0
  24. package/lib/chevre/service/payment/any.js +3 -2
  25. package/lib/chevre/service/task/authorizePayment.js +3 -1
  26. package/lib/chevre/service/task/publishPaymentUrl.js +3 -1
  27. package/lib/chevre/service/task/syncResourcesFromCOA.js +148 -15
  28. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +2 -2
  29. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +3 -1
  30. package/lib/chevre/service/transaction/placeOrder/confirm.js +3 -1
  31. package/package.json +2 -2
@@ -1,6 +1,15 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { Connection, FilterQuery } 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
+ interface IUpdateOptions {
5
+ project: {
6
+ id: string;
7
+ };
8
+ parentOrganization?: {
9
+ id?: string;
10
+ };
11
+ movieTheaterCode: string;
12
+ }
4
13
  /**
5
14
  * ルーム編集時レスポンス
6
15
  */
@@ -24,46 +33,20 @@ export declare class ScreeningRoomRepo {
24
33
  private readonly placeModel;
25
34
  constructor(connection: Connection);
26
35
  saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
27
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
28
- containedInPlace: {
29
- branchCode: string;
30
- };
31
- parentOrganization?: {
32
- id?: string;
33
- };
34
- }): Promise<IUpdateScreeningRoomResult>;
35
- updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
36
- containedInPlace: {
37
- branchCode: string;
38
- };
39
- parentOrganization?: {
40
- id?: string;
41
- };
42
- }, $unset: any): Promise<IUpdateScreeningRoomResult>;
36
+ createRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
37
+ updateRoomByBranchCode(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, $unset: any, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
43
38
  updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
44
39
  project: {
45
40
  id: string;
46
41
  };
47
42
  containedInPlace: Pick<factory.place.screeningRoom.IContainedInPlace, 'id' | 'name'>;
48
43
  }): Promise<void>;
49
- deleteScreeningRoom(screeningRoom: {
50
- project: {
51
- id: string;
52
- };
53
- parentOrganization?: {
54
- id?: string;
55
- };
44
+ deleteRoomByBranchCode(screeningRoom: {
56
45
  /**
57
46
  * ルームコード
58
47
  */
59
48
  branchCode: string;
60
- containedInPlace: {
61
- /**
62
- * 施設コード
63
- */
64
- branchCode: string;
65
- };
66
- }): Promise<IUpdateScreeningRoomResult>;
49
+ }, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
67
50
  deleteScreeningRoomsByMovieTheaterId(params: {
68
51
  project: {
69
52
  id: string;
@@ -114,5 +97,26 @@ export declare class ScreeningRoomRepo {
114
97
  id: string;
115
98
  };
116
99
  }): Promise<void>;
100
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/place/screeningRoom").IPlace & {
101
+ description?: any;
102
+ openingHoursSpecification?: any;
103
+ smokingAllowed?: boolean;
104
+ }> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
105
+ description?: any;
106
+ openingHoursSpecification?: any;
107
+ smokingAllowed?: boolean;
108
+ } & {
109
+ _id: import("mongoose").Types.ObjectId;
110
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/place/screeningRoom").IPlace & {
111
+ description?: any;
112
+ openingHoursSpecification?: any;
113
+ smokingAllowed?: boolean;
114
+ }> & import("@chevre/factory/lib/place/screeningRoom").IPlace & {
115
+ description?: any;
116
+ openingHoursSpecification?: any;
117
+ smokingAllowed?: boolean;
118
+ } & {
119
+ _id: import("mongoose").Types.ObjectId;
120
+ }>>;
117
121
  }
118
122
  export {};
@@ -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,19 @@
1
- import type { AnyExpression, Connection, PipelineStage } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { AnyExpression, Connection, PipelineStage } from 'mongoose';
2
3
  import * as factory from '../../factory';
3
4
  type IMatchStage = PipelineStage.Match;
5
+ type ICreatingSeat = Pick<factory.place.seat.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'maximumAttendeeCapacity' | 'seatingType'>;
6
+ interface IUpdateOptions {
7
+ project: {
8
+ id: string;
9
+ };
10
+ parentOrganization?: {
11
+ id?: string;
12
+ };
13
+ movieTheaterCode: string;
14
+ roomCode: string;
15
+ sectionCode: string;
16
+ }
4
17
  /**
5
18
  * 座席編集時レスポンス
6
19
  */
@@ -27,25 +40,27 @@ export declare class SeatRepo {
27
40
  static CREATE_MATCH_STAGES(params: factory.place.seat.ISearchConditions, options: {
28
41
  filterTypeOf: boolean;
29
42
  }): 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;
43
+ createSeat(seat: ICreatingSeat, options: IUpdateOptions): Promise<IUpdateSeatResult>;
44
+ /**
45
+ * コードをキーにして冪等追加
46
+ */
47
+ addSeatsByBranchCodeIfNotExist(params: {
48
+ $set: ICreatingSeat;
49
+ }[], options: IUpdateOptions): Promise<{
50
+ bulkWriteResult: BulkWriteResult;
51
+ } | void>;
52
+ /**
53
+ * コードをキーにして冪等編集
54
+ */
55
+ updateSeatsByBranchCode(params: {
56
+ $set: ICreatingSeat;
57
+ $unset?: {
58
+ [key in keyof ICreatingSeat]?: 1;
47
59
  };
48
- }, $unset: any): Promise<IUpdateSeatResult>;
60
+ }[], options: IUpdateOptions): Promise<{
61
+ bulkWriteResult: BulkWriteResult;
62
+ } | void>;
63
+ updateSeatByBranchCode(seat: ICreatingSeat, $unset: any, options: IUpdateOptions): Promise<IUpdateSeatResult>;
49
64
  searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
50
65
  projectSeatsByScreeningRoom(params: Pick<factory.place.seat.ISearchConditions, '$projection' | 'additionalProperty' | 'branchCode' | 'seatingType' | 'name' | 'limit' | 'page'> & {
51
66
  project: {
@@ -137,35 +152,11 @@ export declare class SeatRepo {
137
152
  };
138
153
  };
139
154
  }): Promise<string[]>;
140
- deleteSeat(seat: {
141
- project: {
142
- id: string;
143
- };
144
- parentOrganization?: {
145
- id?: string;
146
- };
155
+ deleteSeatByBranchCode(seat: {
147
156
  /**
148
157
  * 座席コード
149
158
  */
150
159
  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>;
160
+ }, options: IUpdateOptions): Promise<IUpdateSeatResult>;
170
161
  }
171
162
  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
  ],
@@ -278,25 +267,131 @@ class SeatRepo {
278
267
  return doc.toObject();
279
268
  });
280
269
  }
281
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
282
- updateSeat(seat, $unset) {
270
+ /**
271
+ * コードをキーにして冪等追加
272
+ */
273
+ addSeatsByBranchCodeIfNotExist(params, options) {
283
274
  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');
275
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
276
+ // 施設存在確認
277
+ 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')
278
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
279
+ : undefined), { _id: 1 })
280
+ .lean()
281
+ .exec();
282
+ if (movieTheaterDoc === null) {
283
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
284
+ }
285
+ const bulkWriteOps = [];
286
+ if (Array.isArray(params)) {
287
+ // セクションの存在するドキュメントでフィルター
288
+ const filter = {
289
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
290
+ 'project.id': { $eq: project.id },
291
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
292
+ branchCode: { $eq: roomCode },
293
+ 'containsPlace.branchCode': { $eq: sectionCode }
294
+ };
295
+ params.forEach(({ $set }) => {
296
+ var _a, _b;
297
+ const setFields = __rest($set, []);
298
+ const pushingSeat = Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.placeType.Seat, branchCode: setFields.branchCode }, (typeof ((_a = setFields.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = setFields.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
299
+ ? { name: setFields.name }
300
+ : undefined), (Array.isArray(setFields.seatingType)) ? { seatingType: setFields.seatingType } : undefined), (Array.isArray(setFields.additionalProperty)) ? { additionalProperty: setFields.additionalProperty } : undefined), (setFields.maximumAttendeeCapacity === 0)
301
+ ? { maximumAttendeeCapacity: setFields.maximumAttendeeCapacity }
302
+ : undefined);
303
+ const updateFilter = {
304
+ $push: { 'containsPlace.$[screeningRoomSection].containsPlace': pushingSeat }
305
+ };
306
+ const arrayFilters = [
307
+ {
308
+ 'screeningRoomSection.branchCode': { $eq: sectionCode }, // セクションに
309
+ 'screeningRoomSection.containsPlace.branchCode': { $ne: pushingSeat.branchCode } // 座席が存在しなければ
310
+ }
311
+ ];
312
+ const updateOne = {
313
+ filter,
314
+ update: updateFilter,
315
+ arrayFilters
316
+ };
317
+ bulkWriteOps.push({ updateOne });
318
+ });
319
+ }
320
+ if (bulkWriteOps.length > 0) {
321
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
322
+ return { bulkWriteResult };
288
323
  }
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');
324
+ });
325
+ }
326
+ /**
327
+ * コードをキーにして冪等編集
328
+ */
329
+ updateSeatsByBranchCode(params, options) {
330
+ return __awaiter(this, void 0, void 0, function* () {
331
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
332
+ const bulkWriteOps = [];
333
+ if (Array.isArray(params)) {
334
+ params.forEach(({ $set, $unset }) => {
335
+ var _a, _b;
336
+ // 座席の存在するドキュメントでフィルター
337
+ const filter = 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: $set.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
338
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
339
+ : undefined);
340
+ const setFields = __rest($set, []);
341
+ const updateFilter = {
342
+ $set: Object.assign(Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].branchCode': setFields.branchCode }, (typeof ((_a = setFields.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string' || typeof ((_b = setFields.name) === null || _b === void 0 ? void 0 : _b.en) === 'string')
343
+ ? {
344
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': setFields.name
345
+ }
346
+ : undefined), (Array.isArray(setFields.seatingType))
347
+ ? {
348
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': setFields.seatingType
349
+ }
350
+ : undefined), (Array.isArray(setFields.additionalProperty))
351
+ ? {
352
+ // tslint:disable-next-line:max-line-length
353
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].additionalProperty': setFields.additionalProperty
354
+ }
355
+ : undefined), (setFields.maximumAttendeeCapacity === 0)
356
+ ? {
357
+ // tslint:disable-next-line:max-line-length
358
+ 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].maximumAttendeeCapacity': setFields.maximumAttendeeCapacity
359
+ }
360
+ : undefined),
361
+ $unset: Object.assign(Object.assign(Object.assign({}, (($unset === null || $unset === void 0 ? void 0 : $unset.name) === 1)
362
+ ? { 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': 1 }
363
+ : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset.seatingType) === 1)
364
+ ? { 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].seatingType': 1 }
365
+ : undefined), (($unset === null || $unset === void 0 ? void 0 : $unset.maximumAttendeeCapacity) === 1)
366
+ ? { 'containsPlace.$[screeningRoomSection].containsPlace.$[seat].maximumAttendeeCapacity': 1 }
367
+ : undefined)
368
+ };
369
+ const arrayFilters = [
370
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } },
371
+ { 'seat.branchCode': { $eq: setFields.branchCode } }
372
+ ];
373
+ const updateOne = {
374
+ filter,
375
+ update: updateFilter,
376
+ arrayFilters
377
+ };
378
+ bulkWriteOps.push({ updateOne });
379
+ });
292
380
  }
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');
381
+ if (bulkWriteOps.length > 0) {
382
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
383
+ return { bulkWriteResult };
296
384
  }
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')
385
+ });
386
+ }
387
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
388
+ updateSeatByBranchCode(seat, $unset, options) {
389
+ return __awaiter(this, void 0, void 0, function* () {
390
+ var _a, _b;
391
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
392
+ 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')
393
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
394
+ : 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
395
  ? {
301
396
  'containsPlace.$[screeningRoomSection].containsPlace.$[seat].name': seat.name
302
397
  }
@@ -333,7 +428,7 @@ class SeatRepo {
333
428
  : undefined) }), {
334
429
  new: true,
335
430
  arrayFilters: [
336
- { 'screeningRoomSection.branchCode': { $eq: screeningRoomSection.branchCode } },
431
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } },
337
432
  { 'seat.branchCode': { $eq: seat.branchCode } }
338
433
  ],
339
434
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
@@ -585,14 +680,14 @@ class SeatRepo {
585
680
  return (result !== undefined) ? result.seatingTypes : [];
586
681
  });
587
682
  }
588
- deleteSeat(seat) {
683
+ deleteSeatByBranchCode(seat, options) {
589
684
  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': {
685
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
686
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
592
687
  $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 } }
688
+ $eq: movieTheaterCode
689
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: sectionCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
690
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
596
691
  : undefined), {
597
692
  $pull: {
598
693
  'containsPlace.$[screeningRoomSection].containsPlace': {
@@ -602,7 +697,7 @@ class SeatRepo {
602
697
  }, {
603
698
  new: true,
604
699
  arrayFilters: [
605
- { 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
700
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } }
606
701
  ],
607
702
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
608
703
  })
@@ -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 {};