@chevre/domain 23.2.0-alpha.4 → 23.2.0-alpha.41

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 (89) hide show
  1. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  2. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  3. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  4. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -42
  5. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
  6. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +7 -3
  7. package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
  8. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  9. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  10. package/example/src/chevre/place/findRooms.ts +24 -0
  11. package/example/src/chevre/place/findSections.ts +28 -0
  12. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  13. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  14. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  15. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  16. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  17. package/example/src/chevre/reIndex.ts +1 -1
  18. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  19. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  20. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  21. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  22. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  23. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  24. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  25. package/lib/chevre/factory/event.js +5 -5
  26. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  27. package/lib/chevre/repo/aggregateOffer.js +11 -3
  28. package/lib/chevre/repo/aggregateOrder.js +0 -93
  29. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  30. package/lib/chevre/repo/aggregateReservation.js +0 -2
  31. package/lib/chevre/repo/creativeWork.js +9 -5
  32. package/lib/chevre/repo/event.d.ts +2 -2
  33. package/lib/chevre/repo/event.js +20 -8
  34. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  35. package/lib/chevre/repo/eventOffer.js +11 -0
  36. package/lib/chevre/repo/eventSeries.d.ts +10 -4
  37. package/lib/chevre/repo/eventSeries.js +56 -28
  38. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  39. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  40. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  41. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  42. package/lib/chevre/repo/offerCatalog.d.ts +10 -1
  43. package/lib/chevre/repo/offerCatalog.js +34 -19
  44. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  45. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  46. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  47. package/lib/chevre/repo/place/entranceGate.js +172 -0
  48. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  49. package/lib/chevre/repo/place/movieTheater.js +77 -6
  50. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  51. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  52. package/lib/chevre/repo/place/seat.d.ts +47 -45
  53. package/lib/chevre/repo/place/seat.js +175 -45
  54. package/lib/chevre/repo/place/section.d.ts +60 -30
  55. package/lib/chevre/repo/place/section.js +337 -127
  56. package/lib/chevre/repo/task.d.ts +1 -1
  57. package/lib/chevre/repository.d.ts +8 -0
  58. package/lib/chevre/repository.js +16 -0
  59. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +6 -3
  60. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  61. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  62. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  63. package/lib/chevre/service/event/saveScreeningEvents.js +6 -5
  64. package/lib/chevre/service/offer/event/authorize/factory.js +4 -1
  65. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  66. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  67. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  68. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +4 -13
  69. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  70. package/lib/chevre/service/offer.d.ts +5 -0
  71. package/lib/chevre/service/offer.js +34 -9
  72. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  73. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  74. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  75. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  76. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  77. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  78. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  79. package/lib/chevre/service/task/onResourceDeleted.js +60 -0
  80. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
  81. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
  82. package/lib/chevre/service/task/onResourceUpdated.js +206 -42
  83. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  84. package/lib/chevre/service/taskHandler.js +1 -0
  85. package/package.json +4 -3
  86. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  87. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  88. package/lib/chevre/service/eventOld.d.ts +0 -60
  89. package/lib/chevre/service/eventOld.js +0 -864
@@ -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: {
@@ -34,7 +34,7 @@ type ICreatingTask = Pick<factory.task.IAttributes<factory.taskName>, 'data' | '
34
34
  export declare class TaskRepo {
35
35
  readonly taskModel: IModel;
36
36
  constructor(connection: Connection);
37
- static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createAccountingReport").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deletePerson").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask>[];
37
+ static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): FilterQuery<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createAccountingReport").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deletePerson").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceDeleted").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask>[];
38
38
  runImmediately(params: Pick<factory.task.IAttributes<factory.taskName>, 'data' | 'expires' | 'name' | 'project' | 'remainingNumberOfTries' | 'runsAt'> & {
39
39
  alternateName?: never;
40
40
  identifier?: never;
@@ -51,6 +51,7 @@ import type { PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
51
51
  import type { PendingReservationRepo } from './repo/pendingReservation';
52
52
  import type { PermitRepo } from './repo/permit';
53
53
  import type { BusStopRepo } from './repo/place/busStop';
54
+ import type { EntranceGateRepo } from './repo/place/entranceGate';
54
55
  import type { HasPOSRepo } from './repo/place/hasPOS';
55
56
  import type { MovieTheaterRepo } from './repo/place/movieTheater';
56
57
  import type { ScreeningRoomRepo } from './repo/place/screeningRoom';
@@ -316,6 +317,13 @@ export declare namespace place {
316
317
  namespace BusStop {
317
318
  function createInstance(...params: ConstructorParameters<typeof BusStopRepo>): Promise<BusStopRepo>;
318
319
  }
320
+ type EntranceGate = EntranceGateRepo;
321
+ /**
322
+ * 施設の入場ゲートリポジトリ
323
+ */
324
+ namespace EntranceGate {
325
+ function createInstance(...params: ConstructorParameters<typeof EntranceGateRepo>): Promise<EntranceGateRepo>;
326
+ }
319
327
  type HasPOS = HasPOSRepo;
320
328
  /**
321
329
  * 施設PointOfSalesリポジトリ
@@ -721,6 +721,22 @@ var place;
721
721
  }
722
722
  BusStop.createInstance = createInstance;
723
723
  })(BusStop = place.BusStop || (place.BusStop = {}));
724
+ /**
725
+ * 施設の入場ゲートリポジトリ
726
+ */
727
+ let EntranceGate;
728
+ (function (EntranceGate) {
729
+ let repo;
730
+ function createInstance(...params) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ if (repo === undefined) {
733
+ repo = (yield Promise.resolve().then(() => require('./repo/place/entranceGate'))).EntranceGateRepo;
734
+ }
735
+ return new repo(...params);
736
+ });
737
+ }
738
+ EntranceGate.createInstance = createInstance;
739
+ })(EntranceGate = place.EntranceGate || (place.EntranceGate = {}));
724
740
  /**
725
741
  * 施設PointOfSalesリポジトリ
726
742
  */
@@ -36,9 +36,9 @@ function createReservationFor(params, useOptimizeReservation) {
36
36
  }
37
37
  function optimizeReservationSuperEvent(params, useOptimizeReservation) {
38
38
  const superEvent = params.superEvent;
39
- return Object.assign(Object.assign({ id: superEvent.id,
39
+ return Object.assign(Object.assign(Object.assign({ id: superEvent.id,
40
40
  // kanaName: superEvent.kanaName, // 廃止(2024-01-26~)
41
- location: superEvent.location, name: superEvent.name, soundFormat: superEvent.soundFormat, typeOf: superEvent.typeOf, videoFormat: superEvent.videoFormat, workPerformed: superEvent.workPerformed }, (superEvent.headline !== undefined)
41
+ location: superEvent.location, name: superEvent.name, soundFormat: superEvent.soundFormat, typeOf: superEvent.typeOf, workPerformed: superEvent.workPerformed }, (superEvent.headline !== undefined)
42
42
  ? { headline: superEvent.headline }
43
43
  : undefined), (useOptimizeReservation)
44
44
  ? {}
@@ -46,7 +46,10 @@ function optimizeReservationSuperEvent(params, useOptimizeReservation) {
46
46
  additionalProperty: (Array.isArray(superEvent.additionalProperty))
47
47
  ? superEvent.additionalProperty
48
48
  : []
49
- });
49
+ }), {
50
+ // 現時点で型廃止済だがデータとしては互換性維持(2026-01-15~)
51
+ videoFormat: superEvent.videoFormat
52
+ });
50
53
  }
51
54
  function createIssuedThrough(params) {
52
55
  var _a;