@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.60

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 (133) hide show
  1. package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +25 -17
  2. package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
  3. package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
  4. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +2 -2
  5. package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
  6. package/example/src/chevre/eventSeries/unsetVideoFormat.ts +31 -0
  7. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -43
  8. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
  9. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +8 -3
  10. package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
  11. package/example/src/chevre/orderNumber/decryptOrderNumber.ts +14 -0
  12. package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
  13. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  14. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  15. package/example/src/chevre/place/findRooms.ts +24 -0
  16. package/example/src/chevre/place/findSections.ts +28 -0
  17. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  18. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  19. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  20. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  21. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  22. package/example/src/chevre/reIndex.ts +1 -1
  23. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
  24. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
  25. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  26. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  28. package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
  29. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  30. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  31. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  32. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  33. package/lib/chevre/emailMessageBuilder.js +1 -0
  34. package/lib/chevre/factory/event.d.ts +1 -1
  35. package/lib/chevre/factory/event.js +11 -5
  36. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  37. package/lib/chevre/factory/transactionNumber.js +54 -0
  38. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
  39. package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
  40. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  41. package/lib/chevre/repo/aggregateOffer.js +11 -3
  42. package/lib/chevre/repo/aggregateOrder.js +0 -93
  43. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  44. package/lib/chevre/repo/aggregateReservation.js +0 -2
  45. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  46. package/lib/chevre/repo/confirmationNumber.js +32 -25
  47. package/lib/chevre/repo/event.d.ts +3 -3
  48. package/lib/chevre/repo/event.js +20 -8
  49. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  50. package/lib/chevre/repo/eventOffer.js +11 -0
  51. package/lib/chevre/repo/eventSeries.d.ts +18 -25
  52. package/lib/chevre/repo/eventSeries.js +155 -101
  53. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  54. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +13 -25
  55. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
  56. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
  57. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  58. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
  59. package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
  60. package/lib/chevre/repo/offerCatalog.d.ts +14 -1
  61. package/lib/chevre/repo/offerCatalog.js +41 -19
  62. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  63. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  64. package/lib/chevre/repo/orderNumber.d.ts +7 -0
  65. package/lib/chevre/repo/orderNumber.js +110 -34
  66. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  67. package/lib/chevre/repo/place/entranceGate.js +172 -0
  68. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  69. package/lib/chevre/repo/place/movieTheater.js +77 -6
  70. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  71. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  72. package/lib/chevre/repo/place/seat.d.ts +47 -45
  73. package/lib/chevre/repo/place/seat.js +175 -45
  74. package/lib/chevre/repo/place/section.d.ts +60 -30
  75. package/lib/chevre/repo/place/section.js +337 -127
  76. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
  77. package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
  78. package/lib/chevre/repo/setting.d.ts +1 -1
  79. package/lib/chevre/repo/setting.js +2 -2
  80. package/lib/chevre/repo/task.d.ts +1 -1
  81. package/lib/chevre/repo/transactionNumber.d.ts +5 -0
  82. package/lib/chevre/repo/transactionNumber.js +63 -27
  83. package/lib/chevre/repository.d.ts +8 -0
  84. package/lib/chevre/repository.js +16 -0
  85. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
  86. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  87. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  88. package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
  89. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
  90. package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
  91. package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
  92. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  93. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  94. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  95. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
  96. package/lib/chevre/service/offer/onEventChanged.js +10 -6
  97. package/lib/chevre/service/offer/product.js +1 -1
  98. package/lib/chevre/service/offer.d.ts +5 -0
  99. package/lib/chevre/service/offer.js +34 -9
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  103. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +2 -2
  104. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  105. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +4 -2
  106. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
  107. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
  108. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
  109. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
  110. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
  111. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
  112. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
  113. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
  114. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
  115. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
  116. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
  117. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
  118. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
  119. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
  120. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  121. package/lib/chevre/service/task/onResourceDeleted.js +168 -0
  122. package/lib/chevre/service/task/onResourceUpdated.js +205 -42
  123. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  124. package/lib/chevre/service/taskHandler.js +1 -0
  125. package/package.json +10 -8
  126. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  127. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
  128. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  129. package/example/src/chevre/settings/addSettings.ts +0 -46
  130. package/lib/chevre/service/eventOld.d.ts +0 -60
  131. package/lib/chevre/service/eventOld.js +0 -864
  132. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
  133. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
@@ -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);
288
284
  }
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');
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
+ });
292
319
  }
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');
320
+ if (bulkWriteOps.length > 0) {
321
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
322
+ return { bulkWriteResult };
296
323
  }
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')
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
+ });
380
+ }
381
+ if (bulkWriteOps.length > 0) {
382
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
383
+ return { bulkWriteResult };
384
+ }
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,49 @@ class SeatRepo {
585
680
  return (result !== undefined) ? result.seatingTypes : [];
586
681
  });
587
682
  }
588
- deleteSeat(seat) {
683
+ /**
684
+ * コードをキーにして冪等削除
685
+ */
686
+ deleteSeatsByBranchCode(params, options) {
687
+ return __awaiter(this, void 0, void 0, function* () {
688
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
689
+ const bulkWriteOps = [];
690
+ if (Array.isArray(params)) {
691
+ params.forEach(({ branchCode }) => {
692
+ // 座席の存在するドキュメントでフィルター
693
+ 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: branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
694
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
695
+ : undefined);
696
+ const updateFilter = {
697
+ $pull: {
698
+ 'containsPlace.$[screeningRoomSection].containsPlace': { branchCode }
699
+ }
700
+ };
701
+ const arrayFilters = [
702
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } }
703
+ ];
704
+ const updateOne = {
705
+ filter,
706
+ update: updateFilter,
707
+ arrayFilters
708
+ };
709
+ bulkWriteOps.push({ updateOne });
710
+ });
711
+ }
712
+ if (bulkWriteOps.length > 0) {
713
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
714
+ return { bulkWriteResult };
715
+ }
716
+ });
717
+ }
718
+ deleteSeatByBranchCode(seat, options) {
589
719
  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': {
720
+ const { project, parentOrganization, movieTheaterCode, roomCode, sectionCode } = options;
721
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
592
722
  $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 } }
723
+ $eq: movieTheaterCode
724
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: sectionCode }, 'containsPlace.containsPlace.branchCode': { $eq: seat.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
725
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
596
726
  : undefined), {
597
727
  $pull: {
598
728
  'containsPlace.$[screeningRoomSection].containsPlace': {
@@ -602,7 +732,7 @@ class SeatRepo {
602
732
  }, {
603
733
  new: true,
604
734
  arrayFilters: [
605
- { 'screeningRoomSection.branchCode': { $eq: seat.containedInPlace.branchCode } }
735
+ { 'screeningRoomSection.branchCode': { $eq: sectionCode } }
606
736
  ],
607
737
  projection: { 'containedInPlace.id': 1, typeOf: 1 }
608
738
  })
@@ -1,6 +1,19 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import type { Connection, PipelineStage } from 'mongoose';
2
3
  import * as factory from '../../factory';
3
4
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
5
+ type ICreatingSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
6
+ type IMatchStage = PipelineStage.Match;
7
+ interface IUpdateOptions {
8
+ project: {
9
+ id: string;
10
+ };
11
+ parentOrganization?: {
12
+ id?: string;
13
+ };
14
+ movieTheaterCode: string;
15
+ roomCode: string;
16
+ }
4
17
  /**
5
18
  * セクション編集時レスポンス
6
19
  */
@@ -13,6 +26,17 @@ interface IUpdateSectionResult {
13
26
  };
14
27
  typeOf: factory.placeType.ScreeningRoom;
15
28
  }
29
+ type IUpsertingSeatSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>;
30
+ interface IUpsertOptions {
31
+ project: {
32
+ id: string;
33
+ };
34
+ parentOrganization?: {
35
+ id?: string;
36
+ };
37
+ movieTheaterId: string;
38
+ roomCode: string;
39
+ }
16
40
  /**
17
41
  * セクションリポジトリ
18
42
  */
@@ -20,22 +44,46 @@ export declare class SectionRepo {
20
44
  private readonly civicStructureModel;
21
45
  private readonly placeModel;
22
46
  constructor(connection: Connection);
23
- createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
24
- parentOrganization?: {
25
- id?: string;
47
+ static CREATE_SECTION_MONGO_CONDITIONS(searchConditions: Omit<factory.place.screeningRoomSection.ISearchConditions, '$projection' | 'limit' | 'page'>): IMatchStage[];
48
+ createSection(screeningRoomSection: ICreatingSection, options: IUpdateOptions): Promise<IUpdateSectionResult>;
49
+ /**
50
+ * セクションの名称と追加特性を編集する
51
+ */
52
+ updateSectionByBranchCode(screeningRoomSection: ICreatingSection, $unset: any, options: IUpdateOptions): Promise<IUpdateSectionResult>;
53
+ /**
54
+ * コードをキーにして冪等追加
55
+ */
56
+ addSeatSectionsByBranchCodeIfNotExist(params: {
57
+ $set: IUpsertingSeatSection;
58
+ }[], options: IUpsertOptions): Promise<{
59
+ bulkWriteResult?: BulkWriteResult;
60
+ }>;
61
+ /**
62
+ * コードをキーにして冪等編集
63
+ */
64
+ updateSeatSectionsByBranchCode(params: {
65
+ $set: IUpsertingSeatSection;
66
+ }[], options: IUpsertOptions): Promise<{
67
+ bulkWriteResult?: BulkWriteResult;
68
+ }>;
69
+ migrateSectionIdentifier(screeningRoomSection: {
70
+ project: {
71
+ id: string;
26
72
  };
27
- }): Promise<IUpdateSectionResult>;
28
- updateScreeningRoomSection(screeningRoomSection: Omit<factory.place.screeningRoomSection.IPlace, 'containedInPlace'> & {
73
+ identifier: string;
74
+ branchCode: string;
29
75
  containedInPlace: {
30
76
  branchCode: string;
31
77
  containedInPlace: {
32
78
  branchCode: string;
33
79
  };
34
80
  };
35
- parentOrganization?: {
36
- id?: string;
37
- };
38
- }, $unset: any): Promise<IUpdateSectionResult>;
81
+ }): Promise<IUpdateSectionResult>;
82
+ /**
83
+ * 最小限のprojectionでセクション検索を再定義
84
+ * 2026-01-08~
85
+ */
86
+ findSections(params: Omit<factory.place.screeningRoomSection.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
39
87
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
40
88
  /**
41
89
  * ルーム指定のセクション検索として再定義(2025-12-07~)
@@ -57,29 +105,11 @@ export declare class SectionRepo {
57
105
  */
58
106
  roomCode: string;
59
107
  }): Promise<Pick<IScreeningRoomSectionWithoutContainsPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
60
- deleteScreeningRoomSection(screeningRoomSection: {
61
- project: {
62
- id: string;
63
- };
64
- parentOrganization?: {
65
- id?: string;
66
- };
108
+ deleteSectionByBranchCode(screeningRoomSection: {
67
109
  /**
68
110
  * セクションコード
69
111
  */
70
112
  branchCode: string;
71
- containedInPlace: {
72
- /**
73
- * ルームコード
74
- */
75
- branchCode: string;
76
- containedInPlace: {
77
- /**
78
- * 施設コード
79
- */
80
- branchCode: string;
81
- };
82
- };
83
- }): Promise<IUpdateSectionResult>;
113
+ }, options: IUpdateOptions): Promise<IUpdateSectionResult>;
84
114
  }
85
115
  export {};