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

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 (173) 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/testRandomness.ts +54 -0
  12. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  13. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  14. package/example/src/chevre/place/findRooms.ts +24 -0
  15. package/example/src/chevre/place/findSections.ts +28 -0
  16. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  17. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  18. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  19. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  20. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  21. package/example/src/chevre/reIndex.ts +1 -1
  22. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
  23. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
  24. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  25. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  26. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
  28. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  29. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  30. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  31. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  32. package/lib/chevre/emailMessageBuilder.js +1 -0
  33. package/lib/chevre/factory/event.d.ts +1 -1
  34. package/lib/chevre/factory/event.js +11 -5
  35. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  36. package/lib/chevre/factory/transactionNumber.js +54 -0
  37. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
  38. package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
  39. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  40. package/lib/chevre/repo/aggregateOffer.js +11 -3
  41. package/lib/chevre/repo/aggregateOrder.js +0 -93
  42. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  43. package/lib/chevre/repo/aggregateReservation.js +0 -2
  44. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  45. package/lib/chevre/repo/confirmationNumber.js +32 -25
  46. package/lib/chevre/repo/event.d.ts +3 -18
  47. package/lib/chevre/repo/event.js +94 -83
  48. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  49. package/lib/chevre/repo/eventOffer.js +11 -0
  50. package/lib/chevre/repo/eventSeries.d.ts +17 -30
  51. package/lib/chevre/repo/eventSeries.js +204 -146
  52. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  53. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +20 -5
  54. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
  55. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
  56. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  57. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
  58. package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
  59. package/lib/chevre/repo/offerCatalog.d.ts +14 -1
  60. package/lib/chevre/repo/offerCatalog.js +41 -19
  61. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  62. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  63. package/lib/chevre/repo/orderNumber.d.ts +6 -0
  64. package/lib/chevre/repo/orderNumber.js +110 -35
  65. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  66. package/lib/chevre/repo/place/entranceGate.js +172 -0
  67. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  68. package/lib/chevre/repo/place/movieTheater.js +77 -6
  69. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  70. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  71. package/lib/chevre/repo/place/seat.d.ts +47 -45
  72. package/lib/chevre/repo/place/seat.js +175 -45
  73. package/lib/chevre/repo/place/section.d.ts +60 -30
  74. package/lib/chevre/repo/place/section.js +337 -127
  75. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
  76. package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
  77. package/lib/chevre/repo/setting.d.ts +1 -1
  78. package/lib/chevre/repo/setting.js +2 -2
  79. package/lib/chevre/repo/task.d.ts +1 -1
  80. package/lib/chevre/repo/transactionNumber.d.ts +5 -0
  81. package/lib/chevre/repo/transactionNumber.js +63 -27
  82. package/lib/chevre/repository.d.ts +8 -0
  83. package/lib/chevre/repository.js +16 -0
  84. package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +3 -0
  85. package/lib/chevre/service/assetTransaction/fixInformAction.js +3 -0
  86. package/lib/chevre/service/assetTransaction/pay/cancel.d.ts +12 -0
  87. package/lib/chevre/service/assetTransaction/pay/cancel.js +25 -0
  88. package/lib/chevre/service/assetTransaction/pay/check.d.ts +23 -0
  89. package/lib/chevre/service/assetTransaction/pay/check.js +37 -0
  90. package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +24 -0
  91. package/lib/chevre/service/assetTransaction/pay/confirm.js +72 -0
  92. package/lib/chevre/service/assetTransaction/pay/exportTasksById.d.ts +18 -0
  93. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +111 -0
  94. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +48 -0
  95. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +164 -0
  96. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +20 -0
  97. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +59 -0
  98. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.d.ts +2 -2
  99. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.js +1 -1
  100. package/lib/chevre/service/assetTransaction/pay/{factory.d.ts → start/factory.d.ts} +1 -1
  101. package/lib/chevre/service/assetTransaction/pay/{factory.js → start/factory.js} +1 -1
  102. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.d.ts → start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts} +4 -4
  103. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.js → start/preStart/validateAcceptedPaymentMethodIfNeeded.js} +1 -4
  104. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +8 -0
  105. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +54 -0
  106. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +13 -0
  107. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +49 -0
  108. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +29 -0
  109. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +37 -0
  110. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +42 -0
  111. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +31 -0
  112. package/lib/chevre/service/assetTransaction/pay/start.d.ts +60 -0
  113. package/lib/chevre/service/assetTransaction/pay/start.js +145 -0
  114. package/lib/chevre/service/assetTransaction/pay.d.ts +8 -170
  115. package/lib/chevre/service/assetTransaction/pay.js +16 -623
  116. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
  117. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  118. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  119. package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
  120. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
  121. package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
  122. package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
  123. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  124. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  125. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  126. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
  127. package/lib/chevre/service/offer/onEventChanged.js +10 -6
  128. package/lib/chevre/service/offer/product.js +1 -1
  129. package/lib/chevre/service/offer.d.ts +5 -0
  130. package/lib/chevre/service/offer.js +34 -9
  131. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  132. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  133. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  134. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
  135. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
  136. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
  137. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
  138. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
  139. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
  140. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
  141. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
  142. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
  143. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
  144. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
  145. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
  146. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
  148. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  149. package/lib/chevre/service/task/onResourceDeleted.js +168 -0
  150. package/lib/chevre/service/task/onResourceUpdated.js +205 -42
  151. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  152. package/lib/chevre/service/taskHandler.js +1 -0
  153. package/package.json +9 -9
  154. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  155. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
  156. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  157. package/example/src/chevre/settings/addSettings.ts +0 -46
  158. package/lib/chevre/service/eventOld.d.ts +0 -60
  159. package/lib/chevre/service/eventOld.js +0 -864
  160. package/lib/chevre/service/task/createEvent/createEvent.d.ts +0 -25
  161. package/lib/chevre/service/task/createEvent/createEvent.js +0 -45
  162. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +0 -22
  163. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +0 -188
  164. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +0 -15
  165. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +0 -116
  166. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +0 -25
  167. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +0 -107
  168. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +0 -13
  169. package/lib/chevre/service/task/createEvent/createEventSeries.js +0 -118
  170. package/lib/chevre/service/task/createEvent.d.ts +0 -6
  171. package/lib/chevre/service/task/createEvent.js +0 -46
  172. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
  173. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.SectionRepo = void 0;
13
24
  const factory = require("../../factory");
@@ -23,20 +34,112 @@ class SectionRepo {
23
34
  this.placeModel = connection.model(place_1.modelName, (0, place_1.createSchema)());
24
35
  }
25
36
  // tslint:disable-next-line:max-func-body-length
26
- createScreeningRoomSection(screeningRoomSection) {
37
+ static CREATE_SECTION_MONGO_CONDITIONS(searchConditions) {
38
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
39
+ const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
40
+ const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
41
+ if (typeof projectIdEq === 'string') {
42
+ matchStages.push({
43
+ $match: { 'project.id': { $eq: projectIdEq } }
44
+ });
45
+ }
46
+ const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
47
+ if (typeof parentOrganizationIdEq === 'string') {
48
+ matchStages.push({
49
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
50
+ });
51
+ }
52
+ // 施設ID
53
+ const movieTheaterIdEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
54
+ if (typeof movieTheaterIdEq === 'string') {
55
+ matchStages.push({
56
+ $match: {
57
+ 'containedInPlace.id': { $exists: true, $eq: movieTheaterIdEq }
58
+ }
59
+ });
60
+ }
61
+ // 施設コード
62
+ const movieTheaterBranchCodeEq = (_k = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.containedInPlace) === null || _j === void 0 ? void 0 : _j.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
63
+ if (typeof movieTheaterBranchCodeEq === 'string') {
64
+ matchStages.push({
65
+ $match: {
66
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterBranchCodeEq }
67
+ }
68
+ });
69
+ }
70
+ // ルームコード
71
+ const containedInPlaceBranchCodeEq = (_m = (_l = searchConditions.containedInPlace) === null || _l === void 0 ? void 0 : _l.branchCode) === null || _m === void 0 ? void 0 : _m.$eq;
72
+ if (typeof containedInPlaceBranchCodeEq === 'string') {
73
+ matchStages.push({
74
+ $match: {
75
+ branchCode: { $eq: containedInPlaceBranchCodeEq }
76
+ }
77
+ });
78
+ }
79
+ // セクションコード
80
+ const sectionBranchCodeEq = (_o = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _o === void 0 ? void 0 : _o.$eq;
81
+ if (typeof sectionBranchCodeEq === 'string') {
82
+ matchStages.push({
83
+ $match: {
84
+ 'containsPlace.branchCode': {
85
+ $exists: true,
86
+ $eq: sectionBranchCodeEq
87
+ }
88
+ }
89
+ });
90
+ }
91
+ const nameCodeRegex = (_p = searchConditions.name) === null || _p === void 0 ? void 0 : _p.$regex;
92
+ if (typeof nameCodeRegex === 'string') {
93
+ matchStages.push({
94
+ $match: {
95
+ $or: [
96
+ {
97
+ 'containsPlace.name.ja': {
98
+ $exists: true,
99
+ $regex: new RegExp(nameCodeRegex)
100
+ }
101
+ },
102
+ {
103
+ 'containsPlace.name.en': {
104
+ $exists: true,
105
+ $regex: new RegExp(nameCodeRegex)
106
+ }
107
+ }
108
+ ]
109
+ }
110
+ });
111
+ }
112
+ const branchCodeRegex = (_q = searchConditions.branchCode) === null || _q === void 0 ? void 0 : _q.$regex;
113
+ if (typeof branchCodeRegex === 'string') {
114
+ matchStages.push({
115
+ $match: {
116
+ 'containsPlace.branchCode': {
117
+ $exists: true,
118
+ $regex: new RegExp(branchCodeRegex)
119
+ }
120
+ }
121
+ });
122
+ }
123
+ const additionalPropertyElemMatch = (_r = searchConditions.additionalProperty) === null || _r === void 0 ? void 0 : _r.$elemMatch;
124
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
125
+ matchStages.push({
126
+ $match: {
127
+ 'containsPlace.additionalProperty': {
128
+ $exists: true,
129
+ $elemMatch: additionalPropertyElemMatch
130
+ }
131
+ }
132
+ });
133
+ }
134
+ return matchStages;
135
+ }
136
+ // tslint:disable-next-line:max-func-body-length
137
+ createSection(screeningRoomSection, options) {
27
138
  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
- }
139
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
37
140
  // 施設存在確認
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 } }
141
+ 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')
142
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
40
143
  : undefined), { _id: 1 })
41
144
  .lean()
42
145
  .exec();
@@ -46,13 +149,13 @@ class SectionRepo {
46
149
  // セクションコードが存在しなければ追加する
47
150
  const doc = yield this.placeModel.findOneAndUpdate({
48
151
  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 },
152
+ 'project.id': { $eq: project.id },
153
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
154
+ branchCode: { $eq: roomCode },
52
155
  'containsPlace.branchCode': { $ne: screeningRoomSection.branchCode }
53
156
  }, {
54
157
  $push: {
55
- containsPlace: Object.assign({ typeOf: screeningRoomSection.typeOf, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
158
+ containsPlace: Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, branchCode: screeningRoomSection.branchCode, name: screeningRoomSection.name }, (Array.isArray(screeningRoomSection.additionalProperty))
56
159
  ? { additionalProperty: screeningRoomSection.additionalProperty }
57
160
  : undefined)
58
161
  }
@@ -68,21 +171,16 @@ class SectionRepo {
68
171
  return doc.toObject();
69
172
  });
70
173
  }
174
+ /**
175
+ * セクションの名称と追加特性を編集する
176
+ */
71
177
  // tslint:disable-next-line:max-func-body-length
72
- updateScreeningRoomSection(screeningRoomSection, $unset) {
178
+ updateSectionByBranchCode(screeningRoomSection, $unset, options) {
73
179
  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)
180
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
181
+ 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')
182
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
183
+ : undefined), Object.assign(Object.assign(Object.assign({ 'containsPlace.$[screeningRoomSection].branchCode': screeningRoomSection.branchCode }, (screeningRoomSection.name !== undefined && screeningRoomSection !== null)
86
184
  ? {
87
185
  'containsPlace.$[screeningRoomSection].name': screeningRoomSection.name
88
186
  }
@@ -90,12 +188,6 @@ class SectionRepo {
90
188
  ? {
91
189
  'containsPlace.$[screeningRoomSection].additionalProperty': screeningRoomSection.additionalProperty
92
190
  }
93
- : undefined), (Array.isArray(screeningRoomSection.containsPlace) && screeningRoomSection.containsPlace.length > 0)
94
- ? {
95
- 'containsPlace.$[screeningRoomSection].containsPlace': screeningRoomSection.containsPlace.map((p) => {
96
- 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
- })
98
- }
99
191
  : undefined), ($unset !== undefined && $unset !== null) ? { $unset } : undefined), {
100
192
  new: true,
101
193
  arrayFilters: [
@@ -110,106 +202,224 @@ class SectionRepo {
110
202
  return doc.toObject();
111
203
  });
112
204
  }
113
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
114
- searchScreeningRoomSections(searchConditions) {
205
+ /**
206
+ * コードをキーにして冪等追加
207
+ */
208
+ addSeatSectionsByBranchCodeIfNotExist(params, options) {
115
209
  return __awaiter(this, void 0, void 0, function* () {
116
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
117
- const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
118
- const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
119
- if (typeof projectIdEq === 'string') {
120
- matchStages.push({
121
- $match: { 'project.id': { $eq: projectIdEq } }
122
- });
210
+ const { project, parentOrganization, movieTheaterId, roomCode } = options;
211
+ // ルーム存在確認
212
+ const roomDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.id': { $eq: movieTheaterId }, branchCode: { $eq: roomCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
213
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
214
+ : undefined), { _id: 1 })
215
+ .lean()
216
+ .exec();
217
+ if (roomDoc === null) {
218
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
123
219
  }
124
- const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
125
- if (typeof parentOrganizationIdEq === 'string') {
126
- matchStages.push({
127
- $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
220
+ // console.log('roomDoc:', roomDoc);
221
+ const bulkWriteOps = [];
222
+ if (Array.isArray(params)) {
223
+ params.forEach(({ $set }) => {
224
+ var _a, _b;
225
+ const { branchCode } = $set, setFields = __rest($set, ["branchCode"]);
226
+ const filter = {
227
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
228
+ 'project.id': { $eq: project.id },
229
+ _id: { $eq: roomDoc._id },
230
+ 'containsPlace.branchCode': { $ne: branchCode } // セクションコードが存在しなければ追加する
231
+ };
232
+ const pushingSeatSection = Object.assign(Object.assign({ typeOf: factory.placeType.ScreeningRoomSection, 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')
233
+ ? { name: setFields.name }
234
+ : undefined), (Array.isArray(setFields.additionalProperty)) ? { additionalProperty: setFields.additionalProperty } : undefined);
235
+ const update = {
236
+ $push: { containsPlace: pushingSeatSection }
237
+ };
238
+ const updateOne = { filter, update };
239
+ bulkWriteOps.push({ updateOne });
128
240
  });
129
241
  }
130
- // 施設コード
131
- const movieTheaterBranchCodeEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
132
- if (typeof movieTheaterBranchCodeEq === 'string') {
133
- matchStages.push({
134
- $match: {
135
- 'containedInPlace.branchCode': {
136
- $exists: true,
137
- $eq: movieTheaterBranchCodeEq
138
- }
139
- }
140
- });
242
+ if (bulkWriteOps.length > 0) {
243
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
244
+ return { bulkWriteResult };
141
245
  }
142
- // ルームコード
143
- const containedInPlaceBranchCodeEq = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$eq;
144
- if (typeof containedInPlaceBranchCodeEq === 'string') {
145
- matchStages.push({
146
- $match: {
147
- branchCode: {
148
- $eq: containedInPlaceBranchCodeEq
149
- }
150
- }
151
- });
246
+ return {};
247
+ });
248
+ }
249
+ /**
250
+ * コードをキーにして冪等編集
251
+ */
252
+ updateSeatSectionsByBranchCode(params, options) {
253
+ return __awaiter(this, void 0, void 0, function* () {
254
+ const { project, parentOrganization, movieTheaterId, roomCode } = options;
255
+ // ルーム存在確認
256
+ const roomDoc = yield this.placeModel.findOne(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.id': { $eq: movieTheaterId }, branchCode: { $eq: roomCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
257
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
258
+ : undefined), { _id: 1 })
259
+ .lean()
260
+ .exec();
261
+ if (roomDoc === null) {
262
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
152
263
  }
153
- // セクションコード
154
- const sectionBranchCodeEq = (_k = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
155
- if (typeof sectionBranchCodeEq === 'string') {
156
- matchStages.push({
157
- $match: {
158
- 'containsPlace.branchCode': {
159
- $exists: true,
160
- $eq: sectionBranchCodeEq
161
- }
162
- }
264
+ const bulkWriteOps = [];
265
+ if (Array.isArray(params)) {
266
+ params.forEach(({ $set }) => {
267
+ const { branchCode } = $set, setFields = __rest($set, ["branchCode"]);
268
+ // セクションの存在するドキュメントでフィルター
269
+ const filter = {
270
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
271
+ 'project.id': { $eq: project.id },
272
+ _id: { $eq: roomDoc._id },
273
+ 'containsPlace.branchCode': { $eq: branchCode }
274
+ };
275
+ const update = {
276
+ // 限られた属性のみ更新する
277
+ $set: Object.assign(Object.assign({}, (setFields.name !== undefined && setFields.name !== null)
278
+ ? { 'containsPlace.$[seatSection].name': setFields.name }
279
+ : undefined), (Array.isArray(setFields.additionalProperty))
280
+ ? { 'containsPlace.$[seatSection].additionalProperty': setFields.additionalProperty }
281
+ : undefined)
282
+ // $unset: {}
283
+ };
284
+ const arrayFilters = [
285
+ { 'seatSection.branchCode': branchCode }
286
+ ];
287
+ const updateOne = { filter, update, arrayFilters };
288
+ bulkWriteOps.push({ updateOne });
163
289
  });
164
290
  }
165
- const nameCodeRegex = (_l = searchConditions.name) === null || _l === void 0 ? void 0 : _l.$regex;
166
- if (typeof nameCodeRegex === 'string') {
167
- matchStages.push({
168
- $match: {
169
- $or: [
170
- {
171
- 'containsPlace.name.ja': {
172
- $exists: true,
173
- $regex: new RegExp(nameCodeRegex)
174
- }
175
- },
176
- {
177
- 'containsPlace.name.en': {
178
- $exists: true,
179
- $regex: new RegExp(nameCodeRegex)
180
- }
181
- }
182
- ]
183
- }
184
- });
291
+ if (bulkWriteOps.length > 0) {
292
+ const bulkWriteResult = yield this.placeModel.bulkWrite(bulkWriteOps, { ordered: false });
293
+ return { bulkWriteResult };
185
294
  }
186
- const branchCodeRegex = (_m = searchConditions.branchCode) === null || _m === void 0 ? void 0 : _m.$regex;
187
- if (typeof branchCodeRegex === 'string') {
188
- matchStages.push({
189
- $match: {
190
- 'containsPlace.branchCode': {
191
- $exists: true,
192
- $regex: new RegExp(branchCodeRegex)
193
- }
194
- }
195
- });
295
+ return {};
296
+ });
297
+ }
298
+ // /**
299
+ // * セクションの座席を上書きする
300
+ // */
301
+ // // tslint:disable-next-line:max-func-body-length
302
+ // public async overwriteSeats(
303
+ // screeningRoomSection: Pick<factory.place.screeningRoomSection.IPlace, 'branchCode' | 'containsPlace'>,
304
+ // options: IUpdateOptions
305
+ // ): Promise<IUpdateSectionResult> {
306
+ // const { project, parentOrganization, movieTheaterCode, roomCode } = options;
307
+ // const { containsPlace } = screeningRoomSection;
308
+ // if (!Array.isArray(containsPlace)) {
309
+ // throw new factory.errors.ArgumentNull('containsPlace');
310
+ // }
311
+ // const doc = await this.placeModel.findOneAndUpdate<HydratedDocument<IUpdateSectionResult>>(
312
+ // {
313
+ // typeOf: { $eq: factory.placeType.ScreeningRoom },
314
+ // 'project.id': { $eq: project.id },
315
+ // 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode },
316
+ // branchCode: { $eq: roomCode },
317
+ // 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode },
318
+ // ...(typeof parentOrganization?.id === 'string')
319
+ // ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
320
+ // : undefined
321
+ // },
322
+ // {
323
+ // // 座席リストが1つ以上指定された場合のみ、上書きする
324
+ // ...(containsPlace.length > 0)
325
+ // ? {
326
+ // 'containsPlace.$[screeningRoomSection].containsPlace':
327
+ // containsPlace.map((p) => {
328
+ // return {
329
+ // typeOf: p.typeOf,
330
+ // branchCode: p.branchCode,
331
+ // ...(p.name !== undefined && p.name !== null) ? { name: p.name } : undefined,
332
+ // ...(Array.isArray(p.seatingType)) ? { seatingType: p.seatingType } : undefined,
333
+ // ...(Array.isArray(p.additionalProperty)) ? { additionalProperty: p.additionalProperty } : undefined
334
+ // };
335
+ // })
336
+ // }
337
+ // : undefined
338
+ // },
339
+ // {
340
+ // new: true,
341
+ // arrayFilters: [
342
+ // { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
343
+ // ],
344
+ // projection: { 'containedInPlace.id': 1, typeOf: 1 }
345
+ // }
346
+ // )
347
+ // .exec();
348
+ // if (doc === null) {
349
+ // throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
350
+ // }
351
+ // return doc.toObject();
352
+ // }
353
+ // tslint:disable-next-line:max-func-body-length
354
+ migrateSectionIdentifier(screeningRoomSection) {
355
+ return __awaiter(this, void 0, void 0, function* () {
356
+ const screeningRoom = screeningRoomSection.containedInPlace;
357
+ if (typeof (screeningRoom === null || screeningRoom === void 0 ? void 0 : screeningRoom.branchCode) !== 'string') {
358
+ throw new factory.errors.ArgumentNull('containedInPlace.branchCode');
196
359
  }
197
- const additionalPropertyElemMatch = (_o = searchConditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
198
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
199
- matchStages.push({
200
- $match: {
201
- 'containsPlace.additionalProperty': {
202
- $exists: true,
203
- $elemMatch: additionalPropertyElemMatch
204
- }
360
+ const movieTheater = screeningRoom.containedInPlace;
361
+ if (typeof (movieTheater === null || movieTheater === void 0 ? void 0 : movieTheater.branchCode) !== 'string') {
362
+ throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
363
+ }
364
+ const doc = yield this.placeModel.findOneAndUpdate({
365
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
366
+ 'project.id': { $eq: screeningRoomSection.project.id },
367
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheater.branchCode },
368
+ branchCode: { $eq: screeningRoom.branchCode },
369
+ 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode }
370
+ }, {
371
+ 'containsPlace.$[screeningRoomSection].identifier': screeningRoomSection.identifier
372
+ }, {
373
+ new: true,
374
+ arrayFilters: [
375
+ { 'screeningRoomSection.branchCode': screeningRoomSection.branchCode }
376
+ ],
377
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
378
+ })
379
+ .exec();
380
+ if (doc === null) {
381
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoomSection);
382
+ }
383
+ return doc.toObject();
384
+ });
385
+ }
386
+ /**
387
+ * 最小限のprojectionでセクション検索を再定義
388
+ * 2026-01-08~
389
+ */
390
+ findSections(params) {
391
+ return __awaiter(this, void 0, void 0, function* () {
392
+ const aggregate = this.placeModel.aggregate([
393
+ { $unwind: '$containsPlace' },
394
+ ...SectionRepo.CREATE_SECTION_MONGO_CONDITIONS(params),
395
+ {
396
+ $project: {
397
+ _id: 0,
398
+ branchCode: '$containsPlace.branchCode',
399
+ name: '$containsPlace.name',
400
+ additionalProperty: '$containsPlace.additionalProperty'
205
401
  }
206
- });
402
+ }
403
+ ]);
404
+ const { limit, page } = params;
405
+ if (typeof limit === 'number' && limit > 0) {
406
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
407
+ aggregate.skip(limit * (pageMustBePositive - 1))
408
+ .limit(limit);
207
409
  }
410
+ return aggregate
411
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
412
+ .exec();
413
+ });
414
+ }
415
+ searchScreeningRoomSections(searchConditions) {
416
+ return __awaiter(this, void 0, void 0, function* () {
417
+ var _a, _b;
208
418
  const aggregate = this.placeModel.aggregate([
209
419
  { $unwind: '$containsPlace' },
210
- ...matchStages,
420
+ ...SectionRepo.CREATE_SECTION_MONGO_CONDITIONS(searchConditions),
211
421
  {
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)
422
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', identifier: '$containsPlace.identifier', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_a = searchConditions.$projection) === null || _a === void 0 ? void 0 : _a.containedInPlace) === 1)
213
423
  ? {
214
424
  containedInPlace: {
215
425
  typeOf: '$typeOf',
@@ -223,7 +433,7 @@ class SectionRepo {
223
433
  }
224
434
  }
225
435
  }
226
- : undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
436
+ : undefined), (((_b = searchConditions.$projection) === null || _b === void 0 ? void 0 : _b.seatCount) === 1)
227
437
  ? {
228
438
  seatCount: {
229
439
  $cond: {
@@ -295,14 +505,14 @@ class SectionRepo {
295
505
  .exec();
296
506
  });
297
507
  }
298
- deleteScreeningRoomSection(screeningRoomSection) {
508
+ deleteSectionByBranchCode(screeningRoomSection, options) {
299
509
  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': {
510
+ const { project, parentOrganization, movieTheaterCode, roomCode } = options;
511
+ const doc = yield this.placeModel.findOneAndUpdate(Object.assign({ typeOf: { $eq: factory.placeType.ScreeningRoom }, 'project.id': { $eq: project.id }, 'containedInPlace.branchCode': {
302
512
  $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 } }
513
+ $eq: movieTheaterCode
514
+ }, branchCode: { $eq: roomCode }, 'containsPlace.branchCode': { $eq: screeningRoomSection.branchCode } }, (typeof (parentOrganization === null || parentOrganization === void 0 ? void 0 : parentOrganization.id) === 'string')
515
+ ? { 'parentOrganization.id': { $exists: true, $eq: parentOrganization.id } }
306
516
  : undefined), {
307
517
  $pull: {
308
518
  containsPlace: {
@@ -4,13 +4,15 @@ import type { Connection } from 'mongoose';
4
4
  */
5
5
  export declare class ServiceOutputIdentifierRepo {
6
6
  private readonly counterRepo;
7
+ private readonly settingModel;
7
8
  constructor(params: {
8
9
  connection: Connection;
9
10
  });
10
11
  /**
11
12
  * タイムスタンプから発行する
12
13
  */
13
- publishByTimestamp(params: {
14
+ issueServiceOutputIdentifier(params: {
14
15
  startDate: Date;
15
16
  }): Promise<string>;
17
+ private findSetting;
16
18
  }