@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
@@ -1,3 +1,4 @@
1
+ import type { BulkWriteResult } from 'mongodb';
1
2
  import type { Connection, FilterQuery } from 'mongoose';
2
3
  import * as factory from '../../factory';
3
4
  import { IDocType } from '../mongoose/schemas/civicStructure';
@@ -5,7 +6,23 @@ export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.I
5
6
  export type IMovieTheaterIncludingScreeningRooms = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf'> & {
6
7
  containsPlace: factory.place.screeningRoom.IPlace[];
7
8
  };
8
- type IKeyOfProjection = keyof factory.place.movieTheater.IPlace;
9
+ type IKeyOfProjection = keyof factory.place.movieTheater.IPlace | 'offers.typeOf' | 'offers.eligibleQuantity' | 'offers.availabilityStartsGraceTime' | 'offers.availabilityEndsGraceTime';
10
+ type IMovieTheaterPublicAttributes = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'id' | 'kanaName' | 'name' | 'parentOrganization' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
11
+ offers?: Pick<factory.place.movieTheater.IOffer, 'availabilityEndsGraceTime' | 'availabilityStartsGraceTime'>;
12
+ };
13
+ type IUpsertingMovieTheater = Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'kanaName' | 'name' | 'offers' | 'telephone' | 'url'> & {
14
+ hasEntranceGate?: never;
15
+ hasPOS?: never;
16
+ };
17
+ interface IUpsertOptions {
18
+ project: {
19
+ id: string;
20
+ };
21
+ /**
22
+ * 施設の所属販売者ID
23
+ */
24
+ sellerId: string;
25
+ }
9
26
  /**
10
27
  * 施設リポジトリ
11
28
  */
@@ -16,15 +33,35 @@ export declare class MovieTheaterRepo {
16
33
  /**
17
34
  * 施設を保管する
18
35
  */
19
- saveMovieTheater(params: factory.place.movieTheater.IPlace): Promise<{
36
+ saveMovieTheater(params: Pick<factory.place.movieTheater.IPlace, 'additionalProperty' | 'branchCode' | 'hasEntranceGate' | 'id' | 'kanaName' | 'name' | 'offers' | 'parentOrganization' | 'project' | 'typeOf' | 'url'> & {
37
+ hasEntranceGate?: never;
38
+ }): Promise<{
20
39
  id: string;
21
40
  }>;
22
41
  saveMovieTheaterByBranchCode4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
42
+ /**
43
+ * コードをキーにして冪等作成
44
+ * 2026-01-13~
45
+ */
46
+ upsertMovieTheatersByBranchCode(params: {
47
+ $set: IUpsertingMovieTheater;
48
+ $unset?: {
49
+ [key in keyof IUpsertingMovieTheater]?: 1;
50
+ };
51
+ }[], options: IUpsertOptions): Promise<{
52
+ bulkWriteResult?: BulkWriteResult;
53
+ /**
54
+ * 追加あるいは編集された施設
55
+ */
56
+ modifiedMovieTheaters: {
57
+ id: string;
58
+ }[];
59
+ }>;
23
60
  /**
24
61
  * 施設のpublic属性検索
25
62
  * 2024-09-18~
26
63
  */
27
- projectPublicFields(params: factory.place.movieTheater.ISearchConditions): Promise<Omit<factory.place.movieTheater.IPlace, 'screenCount'>[]>;
64
+ projectPublicFields(params: factory.place.movieTheater.ISearchConditions): Promise<IMovieTheaterPublicAttributes[]>;
28
65
  /**
29
66
  * 施設検索
30
67
  * redefine(2024-09-18~)
@@ -26,7 +26,11 @@ const settings_1 = require("../../settings");
26
26
  const civicStructure_1 = require("../mongoose/schemas/civicStructure");
27
27
  const AVAILABLE_PROJECT_FIELDS = [
28
28
  'additionalProperty', 'branchCode', 'hasEntranceGate', 'kanaName', 'name',
29
- 'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url'
29
+ 'offers', 'parentOrganization', 'project', 'telephone', 'typeOf', 'url',
30
+ 'offers.typeOf',
31
+ 'offers.eligibleQuantity',
32
+ 'offers.availabilityStartsGraceTime',
33
+ 'offers.availabilityEndsGraceTime'
30
34
  ];
31
35
  /**
32
36
  * 施設リポジトリ
@@ -37,7 +41,7 @@ class MovieTheaterRepo {
37
41
  }
38
42
  // tslint:disable-next-line:max-func-body-length
39
43
  static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
41
45
  const andConditions = [{ typeOf: { $eq: factory.placeType.MovieTheater } }];
42
46
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
43
47
  if (typeof projectIdEq === 'string') {
@@ -71,11 +75,15 @@ class MovieTheaterRepo {
71
75
  ]
72
76
  });
73
77
  }
74
- const parentOrganizationIdEq = (_h = (_g = params.parentOrganization) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
78
+ const sellerIdEq = (_h = (_g = params.seller) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
79
+ if (typeof sellerIdEq === 'string') {
80
+ andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: sellerIdEq } });
81
+ }
82
+ const parentOrganizationIdEq = (_k = (_j = params.parentOrganization) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$eq;
75
83
  if (typeof parentOrganizationIdEq === 'string') {
76
84
  andConditions.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
77
85
  }
78
- const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
86
+ const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
79
87
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
80
88
  andConditions.push({
81
89
  additionalProperty: {
@@ -94,13 +102,15 @@ class MovieTheaterRepo {
94
102
  let savedId;
95
103
  let doc;
96
104
  if (params.id === '') {
97
- const { id } = params, creatingParams = __rest(params, ["id"]); // omit id(2024-09-12~)
105
+ const { id, hasEntranceGate } = params, // 入場ゲートを保管しない(2026-01-11~)
106
+ creatingParams = __rest(params, ["id", "hasEntranceGate"]); // omit id(2024-09-12~)
98
107
  doc = yield this.civicStructureModel.create(creatingParams);
99
108
  savedId = doc.id;
100
109
  }
101
110
  else {
102
111
  // 上書き禁止属性を除外(2022-08-24~)
103
- const { id, branchCode, project, typeOf } = params, updateFields = __rest(params, ["id", "branchCode", "project", "typeOf"]);
112
+ const { id, branchCode, project, typeOf, hasEntranceGate } = params, // 入場ゲートを保管しない(2026-01-11~)
113
+ updateFields = __rest(params, ["id", "branchCode", "project", "typeOf", "hasEntranceGate"]);
104
114
  doc = yield this.civicStructureModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true, projection: { _id: 1 } })
105
115
  .exec();
106
116
  savedId = params.id;
@@ -128,6 +138,67 @@ class MovieTheaterRepo {
128
138
  }
129
139
  });
130
140
  }
141
+ /**
142
+ * コードをキーにして冪等作成
143
+ * 2026-01-13~
144
+ */
145
+ upsertMovieTheatersByBranchCode(params, options) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const { project, sellerId } = options;
148
+ const bulkWriteOps = [];
149
+ const queryFilters = [];
150
+ if (Array.isArray(params)) {
151
+ params.forEach(({ $set, $unset }) => {
152
+ const { branchCode, hasEntranceGate, hasPOS } = $set, // 入場ゲート,POSを決して編集しないように
153
+ setFields = __rest($set, ["branchCode", "hasEntranceGate", "hasPOS"]);
154
+ if (typeof branchCode !== 'string' || branchCode === '') {
155
+ throw new factory.errors.ArgumentNull('branchCode');
156
+ }
157
+ // リソースのユニークネスを保証するfilter
158
+ const filter = {
159
+ typeOf: { $eq: factory.placeType.MovieTheater },
160
+ 'project.id': { $eq: project.id },
161
+ branchCode: { $eq: branchCode },
162
+ // プロジェクトとコードでユニークな仕様だが、販売者も指定する -> 異なる販売者でコードが重複すればDuplicateErrorとなる
163
+ 'parentOrganization.id': { $exists: true, $eq: sellerId }
164
+ };
165
+ const initialMovieTheater = {
166
+ typeOf: factory.placeType.MovieTheater,
167
+ project: { id: project.id, typeOf: factory.organizationType.Project },
168
+ branchCode,
169
+ parentOrganization: { id: sellerId, typeOf: factory.organizationType.Corporation }
170
+ };
171
+ const setOnInsert = initialMovieTheater;
172
+ const update = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
173
+ const updateOne = {
174
+ filter,
175
+ update,
176
+ upsert: true
177
+ };
178
+ bulkWriteOps.push({ updateOne });
179
+ queryFilters.push({
180
+ typeOf: { $eq: factory.placeType.MovieTheater },
181
+ 'project.id': { $eq: project.id },
182
+ branchCode: { $eq: branchCode },
183
+ // プロジェクトとコードでユニークな仕様だが、販売者も指定する -> 異なる販売者でコードが重複すればDuplicateErrorとなる
184
+ 'parentOrganization.id': { $exists: true, $eq: sellerId }
185
+ });
186
+ });
187
+ }
188
+ if (bulkWriteOps.length > 0) {
189
+ const bulkWriteResult = yield this.civicStructureModel.bulkWrite(bulkWriteOps, { ordered: false });
190
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
191
+ const modifiedMovieTheaters = yield this.civicStructureModel.find({ $or: queryFilters }, {
192
+ _id: 0,
193
+ id: { $toString: '$_id' }
194
+ })
195
+ .lean()
196
+ .exec();
197
+ return { bulkWriteResult, modifiedMovieTheaters };
198
+ }
199
+ return { modifiedMovieTheaters: [] };
200
+ });
201
+ }
131
202
  /**
132
203
  * 施設のpublic属性検索
133
204
  * 2024-09-18~
@@ -1,6 +1,28 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery, PipelineStage } from 'mongoose';
2
3
  import * as factory from '../../factory';
4
+ import { IDocType } from '../mongoose/schemas/place';
3
5
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
6
+ type IMatchStage = PipelineStage.Match;
7
+ type IUpsertingRoom = Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>;
8
+ interface IUpdateOptions {
9
+ project: {
10
+ id: string;
11
+ };
12
+ parentOrganization?: {
13
+ id?: string;
14
+ };
15
+ movieTheaterCode: string;
16
+ }
17
+ interface IUpsertOptions {
18
+ project: {
19
+ id: string;
20
+ };
21
+ parentOrganization?: {
22
+ id?: string;
23
+ };
24
+ movieTheaterId: string;
25
+ }
4
26
  /**
5
27
  * ルーム編集時レスポンス
6
28
  */
@@ -23,47 +45,34 @@ export declare class ScreeningRoomRepo {
23
45
  private readonly civicStructureModel;
24
46
  private readonly placeModel;
25
47
  constructor(connection: Connection);
48
+ static CREATE_ROOM_MONGO_CONDITIONS(searchConditions: Omit<factory.place.screeningRoom.ISearchConditions, '$projection' | 'limit' | 'page'>): IMatchStage[];
26
49
  saveScreeningRooms4coa(params: IMovieTheaterIncludingScreeningRooms): Promise<void>;
27
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
28
- containedInPlace: {
29
- branchCode: string;
30
- };
31
- parentOrganization?: {
32
- id?: string;
33
- };
34
- }): Promise<IUpdateScreeningRoomResult>;
35
- updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
36
- containedInPlace: {
37
- branchCode: string;
38
- };
39
- parentOrganization?: {
40
- id?: string;
41
- };
42
- }, $unset: any): Promise<IUpdateScreeningRoomResult>;
50
+ createRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
51
+ updateRoomByBranchCode(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed'>, $unset: any, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
43
52
  updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
44
53
  project: {
45
54
  id: string;
46
55
  };
47
56
  containedInPlace: Pick<factory.place.screeningRoom.IContainedInPlace, 'id' | 'name'>;
48
57
  }): Promise<void>;
49
- deleteScreeningRoom(screeningRoom: {
50
- project: {
51
- id: string;
52
- };
53
- parentOrganization?: {
54
- id?: string;
55
- };
58
+ /**
59
+ * コードをキーにして冪等作成
60
+ * 2026-01-12~
61
+ */
62
+ upsertRoomsByBranchCode(params: {
63
+ $set: IUpsertingRoom;
64
+ $unset?: {
65
+ [key in keyof IUpsertingRoom]?: 1;
66
+ };
67
+ }[], options: IUpsertOptions): Promise<{
68
+ bulkWriteResult?: BulkWriteResult;
69
+ }>;
70
+ deleteRoomByBranchCode(screeningRoom: {
56
71
  /**
57
72
  * ルームコード
58
73
  */
59
74
  branchCode: string;
60
- containedInPlace: {
61
- /**
62
- * 施設コード
63
- */
64
- branchCode: string;
65
- };
66
- }): Promise<IUpdateScreeningRoomResult>;
75
+ }, options: IUpdateOptions): Promise<IUpdateScreeningRoomResult>;
67
76
  deleteScreeningRoomsByMovieTheaterId(params: {
68
77
  project: {
69
78
  id: string;
@@ -76,6 +85,7 @@ export declare class ScreeningRoomRepo {
76
85
  };
77
86
  }): Promise<import("mongodb").DeleteResult>;
78
87
  searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
88
+ findRooms(params: Omit<factory.place.screeningRoom.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed' | 'maximumAttendeeCapacity'>[]>;
79
89
  /**
80
90
  * セクションと座席も含めたひとつのルームを取得する
81
91
  */
@@ -114,5 +124,24 @@ export declare class ScreeningRoomRepo {
114
124
  id: string;
115
125
  };
116
126
  }): Promise<void>;
127
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/screeningRoom").IPlace, "containsPlace"> & {
128
+ description?: any;
129
+ openingHoursSpecification?: any;
130
+ smokingAllowed?: boolean;
131
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
132
+ containsPlace?: factory.place.seat.IPlace[];
133
+ })[];
134
+ } & {
135
+ _id: import("mongoose").Types.ObjectId;
136
+ }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, IDocType> & Omit<import("@chevre/factory/lib/place/screeningRoom").IPlace, "containsPlace"> & {
137
+ description?: any;
138
+ openingHoursSpecification?: any;
139
+ smokingAllowed?: boolean;
140
+ containsPlace: (Pick<import("@chevre/factory/lib/place/screeningRoomSection").IPlace, "name" | "typeOf" | "additionalProperty" | "branchCode"> & {
141
+ containsPlace?: factory.place.seat.IPlace[];
142
+ })[];
143
+ } & {
144
+ _id: import("mongoose").Types.ObjectId;
145
+ }>>;
117
146
  }
118
147
  export {};