@chevre/domain 22.5.0-alpha.8 → 22.5.0

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 (160) hide show
  1. package/example/src/chevre/activateOptionalAggregationSettings.ts +19 -0
  2. package/example/src/chevre/aggregateAllEvents2.ts +7 -5
  3. package/example/src/chevre/aggregateEventPublicFields.ts +47 -0
  4. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +32 -0
  5. package/example/src/chevre/findReservationByCode.ts +11 -10
  6. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +101 -0
  7. package/example/src/chevre/migrateProjectMakesOfferAvailableAt.ts +85 -0
  8. package/example/src/chevre/person/cleanUpCognitoUsers.ts +90 -0
  9. package/example/src/chevre/searchCategoryCodesByAggregate.ts +1 -2
  10. package/example/src/chevre/searchOfferCatalogItems.ts +3 -2
  11. package/example/src/chevre/searchProjects.ts +2 -4
  12. package/example/src/chevre/searchSellersByAggregate.ts +4 -6
  13. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -19
  14. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +25 -14
  15. package/example/src/chevre/upsertProductsByProductId.ts +1 -1
  16. package/example/src/createMongooseConnection.ts +26 -0
  17. package/lib/chevre/repo/action.d.ts +41 -41
  18. package/lib/chevre/repo/action.js +5 -39
  19. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  20. package/lib/chevre/repo/categoryCode.d.ts +4 -8
  21. package/lib/chevre/repo/categoryCode.js +8 -36
  22. package/lib/chevre/repo/creativeWork.js +1 -20
  23. package/lib/chevre/repo/customer.d.ts +1 -1
  24. package/lib/chevre/repo/customer.js +4 -4
  25. package/lib/chevre/repo/event.d.ts +21 -12
  26. package/lib/chevre/repo/event.js +135 -37
  27. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +54 -0
  28. package/lib/chevre/repo/eventSellerMakesOffer.js +73 -0
  29. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -3
  30. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +0 -3
  31. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +0 -3
  32. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +0 -3
  33. package/lib/chevre/repo/mongoose/schemas/customer.js +0 -3
  34. package/lib/chevre/repo/mongoose/schemas/event.js +9 -54
  35. package/lib/chevre/repo/mongoose/schemas/member.js +0 -3
  36. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -3
  37. package/lib/chevre/repo/mongoose/schemas/paymentService.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +0 -3
  39. package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -3
  40. package/lib/chevre/repo/mongoose/schemas/project.js +0 -3
  41. package/lib/chevre/repo/mongoose/schemas/reservation.js +0 -3
  42. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -3
  43. package/lib/chevre/repo/mongoose/schemas/trip.js +0 -3
  44. package/lib/chevre/repo/paymentService.d.ts +1 -1
  45. package/lib/chevre/repo/paymentService.js +0 -19
  46. package/lib/chevre/repo/place/movieTheater.js +1 -25
  47. package/lib/chevre/repo/product.js +1 -6
  48. package/lib/chevre/repo/project.d.ts +8 -2
  49. package/lib/chevre/repo/project.js +25 -26
  50. package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
  51. package/lib/chevre/repo/projectMakesOffer.js +5 -2
  52. package/lib/chevre/repo/role.js +0 -7
  53. package/lib/chevre/repo/seller.d.ts +18 -16
  54. package/lib/chevre/repo/seller.js +13 -31
  55. package/lib/chevre/repo/task.d.ts +12 -12
  56. package/lib/chevre/repo/transaction.d.ts +1 -1
  57. package/lib/chevre/repository.d.ts +5 -0
  58. package/lib/chevre/repository.js +15 -2
  59. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +4 -18
  60. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  61. package/lib/chevre/service/aggregation/project.js +1 -2
  62. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -4
  63. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  64. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -1
  65. package/lib/chevre/service/assetTransaction/reserve/start.js +11 -38
  66. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +4 -1
  67. package/lib/chevre/service/event.js +2 -2
  68. package/lib/chevre/service/moneyTransfer.js +1 -2
  69. package/lib/chevre/service/notification.d.ts +2 -4
  70. package/lib/chevre/service/notification.js +30 -9
  71. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -1
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -1
  74. package/lib/chevre/service/offer/event/authorize.js +2 -2
  75. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -85
  77. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +21 -257
  78. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
  79. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
  80. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +48 -0
  81. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +109 -0
  82. package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +38 -0
  83. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +95 -0
  84. package/lib/chevre/service/offer/event/searchOffersByIds.js +26 -20
  85. package/lib/chevre/service/offer/event.d.ts +4 -1
  86. package/lib/chevre/service/offer/event.js +6 -3
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  88. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +1 -1
  89. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +4 -4
  90. package/lib/chevre/service/offer/onEventChanged.d.ts +1 -13
  91. package/lib/chevre/service/offer/onEventChanged.js +64 -71
  92. package/lib/chevre/service/offer.d.ts +6 -0
  93. package/lib/chevre/service/offer.js +12 -15
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +7 -8
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  97. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +7 -8
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +8 -11
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +7 -8
  101. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +1 -4
  102. package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -7
  103. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  104. package/lib/chevre/service/order/placeOrder.js +1 -1
  105. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  106. package/lib/chevre/service/payment/any.js +1 -1
  107. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  108. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +0 -3
  109. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  110. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  111. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  112. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +50 -57
  113. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  114. package/lib/chevre/service/payment/paymentCard.js +0 -5
  115. package/lib/chevre/service/payment.d.ts +1 -1
  116. package/lib/chevre/service/report/telemetry.js +1 -1
  117. package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
  118. package/lib/chevre/service/reserve/cancelReservation.js +14 -6
  119. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  120. package/lib/chevre/service/reserve/factory.d.ts +2 -61
  121. package/lib/chevre/service/reserve/factory.js +0 -11
  122. package/lib/chevre/service/reserve/findByCode.js +0 -1
  123. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +19 -0
  124. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +64 -0
  125. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -4
  126. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +37 -61
  127. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +22 -76
  128. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +26 -28
  129. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +0 -3
  130. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +17 -50
  131. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +18 -0
  132. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +66 -0
  133. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  134. package/lib/chevre/service/reserve/useReservation.js +4 -4
  135. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
  136. package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
  137. package/lib/chevre/service/task/aggregateScreeningEvent.js +4 -2
  138. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +1 -1
  139. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +1 -5
  140. package/lib/chevre/service/task/deletePerson.d.ts +6 -0
  141. package/lib/chevre/service/task/deletePerson.js +420 -0
  142. package/lib/chevre/service/task/handleNotification.d.ts +3 -0
  143. package/lib/chevre/service/task/handleNotification.js +26 -0
  144. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  145. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  146. package/lib/chevre/service/task/triggerWebhook.js +2 -2
  147. package/lib/chevre/service/task.d.ts +3 -0
  148. package/lib/chevre/service/task.js +2 -0
  149. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  150. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +1 -3
  151. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
  152. package/lib/chevre/service/transaction/returnOrder/preStart.js +4 -3
  153. package/lib/chevre/settings/aggregation.d.ts +23 -0
  154. package/lib/chevre/settings/aggregation.js +17 -0
  155. package/lib/chevre/settings.d.ts +52 -38
  156. package/lib/chevre/settings.js +12 -13
  157. package/package.json +5 -7
  158. package/example/src/chevre/migratePayTransactionRecipes.ts +0 -252
  159. package/example/src/chevre/migrateProductHasOfferCatalog.ts +0 -80
  160. package/example/src/chevre/migrateProjectMakesOffer.ts +0 -78
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.searchOfferCatalogItemAvailability = exports.searchOfferCatalogItems = exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = void 0;
12
+ exports.searchEventTicketOffers = void 0;
13
13
  const factory = require("../../../factory");
14
14
  const factory_1 = require("../factory");
15
15
  const checkAvailability_1 = require("./checkAvailability");
@@ -18,8 +18,7 @@ const searchPriceSpecs4event_1 = require("./searchPriceSpecs4event");
18
18
  function searchTicketOffersByItemOffered(params) {
19
19
  // tslint:disable-next-line:max-func-body-length
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
- var _a, _b, _c, _d, _e, _f, _g;
22
- let catalogId;
21
+ var _a, _b, _c, _d, _e, _f;
23
22
  const eventService = (yield repos.product.projectFields({
24
23
  limit: 1,
25
24
  page: 1,
@@ -30,35 +29,37 @@ function searchTicketOffersByItemOffered(params) {
30
29
  if (eventService === undefined) {
31
30
  throw new factory.errors.NotFound(factory.product.ProductType.EventService);
32
31
  }
33
- // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
34
- const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
35
- if (typeof firstCatalogIdOfProduct === 'string') {
36
- catalogId = firstCatalogIdOfProduct;
37
- }
38
- if (typeof catalogId !== 'string') {
32
+ const offerCatalogItemsOfProduct = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement;
33
+ /**
34
+ * プロダクトのカタログIDリスト
35
+ */
36
+ const catalogIdsOfProduct = (Array.isArray(offerCatalogItemsOfProduct)) ? offerCatalogItemsOfProduct.map(({ id }) => id) : [];
37
+ /**
38
+ * プロダクトのひとつめのカタログID
39
+ */
40
+ const firstCatalogIdOfProduct = catalogIdsOfProduct.at(0);
41
+ if (typeof firstCatalogIdOfProduct !== 'string') {
39
42
  throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
40
43
  }
41
- // サブカタログIDを決定
42
- let subOfferCatalogId = catalogId;
44
+ /**
45
+ * カタログID or サブカタログID
46
+ */
47
+ let subOfferCatalogId = firstCatalogIdOfProduct;
43
48
  let isOfferCatalogItem = false;
44
- const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
49
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: firstCatalogIdOfProduct });
45
50
  if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
46
51
  subOfferCatalogId = offerCatalogFirstElement.id;
47
52
  isOfferCatalogItem = true;
48
53
  }
49
54
  if (params.withSortIndex) {
50
- // addSortIndexの場合はid指定廃止(2023-09-13~)
51
- // if (Array.isArray(params.ids)) {
52
- // throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
53
- // }
54
55
  // 明示的にカタログ指定可能にする
55
- if (typeof ((_d = params.includedInDataCatalog) === null || _d === void 0 ? void 0 : _d.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
56
+ if (typeof ((_c = params.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
56
57
  if (isOfferCatalogItem) {
57
58
  // カタログに含まれるサブカタログか検証(2024-09-30~)
58
59
  const offerCatalogIncludingSpecifiedElement = yield repos.offerCatalog.projectFields({
59
60
  limit: 1,
60
61
  page: 1,
61
- id: { $in: [catalogId] },
62
+ id: { $in: catalogIdsOfProduct },
62
63
  itemListElement: { id: { $in: [params.includedInDataCatalog.id] } }
63
64
  }, ['id']);
64
65
  if (offerCatalogIncludingSpecifiedElement.length === 0) {
@@ -83,7 +84,7 @@ function searchTicketOffersByItemOffered(params) {
83
84
  throw new factory.errors.NotFound('OfferCatalogItem');
84
85
  }
85
86
  // 強制的にサブカタログの適用決済カード条件に変更
86
- const appliesToMovieTicketBySubCatalog = (_f = (_e = offerCatalogItem.relatedOffer) === null || _e === void 0 ? void 0 : _e.priceSpecification) === null || _f === void 0 ? void 0 : _f.appliesToMovieTicket;
87
+ const appliesToMovieTicketBySubCatalog = (_e = (_d = offerCatalogItem.relatedOffer) === null || _d === void 0 ? void 0 : _d.priceSpecification) === null || _e === void 0 ? void 0 : _e.appliesToMovieTicket;
87
88
  if (Array.isArray(appliesToMovieTicketBySubCatalog)) {
88
89
  priceSpecificationCondition = {
89
90
  appliesToMovieTicket: {
@@ -104,7 +105,7 @@ function searchTicketOffersByItemOffered(params) {
104
105
  }
105
106
  const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
106
107
  offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
107
- availableAtOrFrom: { id: (_g = params.store) === null || _g === void 0 ? void 0 : _g.id },
108
+ availableAtOrFrom: { id: (_f = params.store) === null || _f === void 0 ? void 0 : _f.id },
108
109
  unacceptedPaymentMethod: params.unacceptedPaymentMethod,
109
110
  excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
110
111
  priceSpecification: priceSpecificationCondition,
@@ -117,27 +118,6 @@ function searchTicketOffersByItemOffered(params) {
117
118
  }
118
119
  else {
119
120
  throw new factory.errors.NotImplemented('only withSortIndex: true implemented'); // ID指定での検索はモジュール分離(2024-09-30~)
120
- // if (!Array.isArray(params.ids)) {
121
- // throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
122
- // }
123
- // let includedInDataCatalogIds: string[] = [subOfferCatalogId];
124
- // if (isOfferCatalogItem) {
125
- // // 複数カタログ対応(2023-09-27~)
126
- // const offerCatalogItems = await repos.offerCatalog.findItemListElementById({
127
- // id: catalogId,
128
- // project: { id: eventService.project.id }
129
- // });
130
- // includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
131
- // }
132
- // const availableOffers = await repos.offer.searchAllByIdsAndOfferCatalogId({
133
- // ids: params.ids,
134
- // includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
135
- // availableAtOrFrom: { id: params.store?.id },
136
- // unacceptedPaymentMethod: params.unacceptedPaymentMethod,
137
- // excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
138
- // onlyValid: params.onlyValid === true
139
- // });
140
- // return { availableOffers };
141
121
  }
142
122
  });
143
123
  }
@@ -272,219 +252,3 @@ function searchEventTicketOffers(params) {
272
252
  });
273
253
  }
274
254
  exports.searchEventTicketOffers = searchEventTicketOffers;
275
- /**
276
- * オファーで利用可能な適用決済カード条件を検索する
277
- */
278
- function searchOfferAppliesToMovieTicket(params) {
279
- return (repos) => __awaiter(this, void 0, void 0, function* () {
280
- var _a, _b, _c, _d;
281
- // optimize(2024-07-18~)
282
- const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
283
- // let soundFormatTypes: string[] = [];
284
- let videoFormatTypes = [];
285
- if (event.typeOf === factory.eventType.ScreeningEvent) {
286
- const superEvents = yield repos.eventSeries.projectEventSeriesFields({
287
- limit: 1,
288
- page: 1,
289
- id: { $eq: event.superEvent.id }
290
- // typeOf: factory.eventType.ScreeningEventSeries
291
- }, ['soundFormat', 'videoFormat']);
292
- const superEvent = superEvents.shift();
293
- if (superEvent === undefined) {
294
- throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
295
- }
296
- // soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
297
- videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
298
- }
299
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
300
- // 上映方式がなければMovieTicket除外
301
- const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
302
- // 興行設定があれば興行のカタログを参照する
303
- const eventOffers = event.offers;
304
- let catalogId;
305
- if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
306
- const eventService = (yield repos.product.projectFields({
307
- limit: 1,
308
- page: 1,
309
- id: { $eq: eventOffers.itemOffered.id }
310
- }, ['hasOfferCatalog']
311
- // []
312
- )).shift();
313
- if (eventService === undefined) {
314
- throw new factory.errors.NotFound(factory.product.ProductType.EventService);
315
- }
316
- // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
317
- const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
318
- if (typeof firstCatalogIdOfProduct === 'string') {
319
- catalogId = firstCatalogIdOfProduct;
320
- }
321
- }
322
- if (typeof catalogId !== 'string') {
323
- throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
324
- }
325
- // サブカタログIDを決定
326
- let subOfferCatalogId = catalogId;
327
- // let isOfferCatalogItem: boolean = false;
328
- const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
329
- if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
330
- subOfferCatalogId = offerCatalogFirstElement.id;
331
- // isOfferCatalogItem = true;
332
- }
333
- return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
334
- // subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
335
- subOfferCatalog: { id: subOfferCatalogId },
336
- availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
337
- unacceptedPaymentMethod: unacceptedPaymentMethod,
338
- excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
339
- onlyValid: params.onlyValid === true,
340
- // useIncludeInDataCatalog: params.useIncludeInDataCatalog,
341
- limit: params.limit,
342
- page: params.page
343
- });
344
- });
345
- }
346
- exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
347
- /**
348
- * サブカタログ検索
349
- */
350
- function searchOfferCatalogItems(params) {
351
- return (repos) => __awaiter(this, void 0, void 0, function* () {
352
- var _a, _b, _c;
353
- if (typeof params.limit !== 'number') {
354
- throw new factory.errors.Argument('limit', 'must be number');
355
- }
356
- if (typeof params.page !== 'number') {
357
- throw new factory.errors.Argument('page', 'must be number');
358
- }
359
- let offerCatalogItems = [];
360
- // optimize(2024-07-18~)
361
- const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['offers.itemOffered.id']);
362
- // 興行設定があれば興行のカタログを参照する
363
- const eventOffers = event.offers;
364
- let catalogId;
365
- if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
366
- const eventService = (yield repos.product.projectFields({
367
- limit: 1,
368
- page: 1,
369
- id: { $eq: eventOffers.itemOffered.id }
370
- }, ['hasOfferCatalog']
371
- // []
372
- )).shift();
373
- if (eventService === undefined) {
374
- throw new factory.errors.NotFound(factory.product.ProductType.EventService);
375
- }
376
- // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
377
- const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
378
- if (typeof firstCatalogIdOfProduct === 'string') {
379
- catalogId = firstCatalogIdOfProduct;
380
- }
381
- }
382
- if (typeof catalogId !== 'string') {
383
- throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
384
- }
385
- const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
386
- if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
387
- const catalogItemListElements = yield repos.offerCatalog.searchItemListElementById({
388
- id: catalogId,
389
- limit: params.limit,
390
- page: params.page
391
- });
392
- if (catalogItemListElements.length > 0) {
393
- // サブカタログ検索
394
- const searchOfferCatalogItemsResult = yield repos.offerCatalogItem.projectFields({
395
- id: { $in: catalogItemListElements.map((element) => element.id) }
396
- }, ['description', 'name', 'additionalProperty', 'relatedOffer']
397
- // {
398
- // id: 1,
399
- // name: 1,
400
- // description: 1,
401
- // additionalProperty: 1,
402
- // relatedOffer: 1
403
- // }
404
- );
405
- offerCatalogItems = catalogItemListElements.map((element) => {
406
- const offerCatalogItem = searchOfferCatalogItemsResult.find((item) => item.id === element.id);
407
- if (offerCatalogItem === undefined) {
408
- throw new factory.errors.NotFound('OfferCatalog', `offerCatalogItem '${element.id}' not found`);
409
- }
410
- return Object.assign(Object.assign({}, element), offerCatalogItem);
411
- });
412
- }
413
- }
414
- else {
415
- // Offerによるカタログの場合はひとまずempty
416
- }
417
- return offerCatalogItems;
418
- });
419
- }
420
- exports.searchOfferCatalogItems = searchOfferCatalogItems;
421
- /**
422
- * サブカタログ利用可能性検索
423
- */
424
- function searchOfferCatalogItemAvailability(params) {
425
- return (repos) => __awaiter(this, void 0, void 0, function* () {
426
- var _a, _b, _c;
427
- const { considerUnacceptedPaymentMethod } = params.options;
428
- if (typeof params.limit !== 'number') {
429
- throw new factory.errors.Argument('limit', 'must be number');
430
- }
431
- if (typeof params.page !== 'number') {
432
- throw new factory.errors.Argument('page', 'must be number');
433
- }
434
- let availabilities = [];
435
- // optimize(2024-07-18~)
436
- const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
437
- // 興行設定があれば興行のカタログを参照する
438
- const eventOffers = event.offers;
439
- let catalogId;
440
- if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
441
- const eventService = (yield repos.product.projectFields({
442
- limit: 1,
443
- page: 1,
444
- id: { $eq: eventOffers.itemOffered.id }
445
- }, ['hasOfferCatalog']
446
- // []
447
- )).shift();
448
- if (eventService === undefined) {
449
- throw new factory.errors.NotFound(factory.product.ProductType.EventService);
450
- }
451
- // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
452
- const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
453
- if (typeof firstCatalogIdOfProduct === 'string') {
454
- catalogId = firstCatalogIdOfProduct;
455
- }
456
- }
457
- if (typeof catalogId !== 'string') {
458
- throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
459
- }
460
- const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
461
- if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
462
- const catalogItemListElements = yield repos.offerCatalog.searchItemListElementById({
463
- id: catalogId,
464
- limit: params.limit,
465
- page: params.page
466
- });
467
- const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
468
- if (catalogItemListElements.length > 0) {
469
- // 単価オファーから利用可能なサブカタログを検索
470
- const availableCatalogs = yield repos.offer.searchAvailableCatalogs({
471
- project: { id: event.project.id },
472
- includedInDataCatalog: { id: catalogItemListElements.map((element) => element.id) },
473
- availableAtOrFrom: { id: params.availableAtOrFrom.id },
474
- unacceptedPaymentMethod: (considerUnacceptedPaymentMethod) ? unacceptedPaymentMethod : []
475
- });
476
- availabilities = catalogItemListElements.map((element) => {
477
- return {
478
- id: element.id,
479
- isAvailable: availableCatalogs.some((item) => item.id === element.id)
480
- };
481
- });
482
- }
483
- }
484
- else {
485
- // Offerによるカタログの場合はひとまずempty
486
- }
487
- return availabilities;
488
- });
489
- }
490
- exports.searchOfferCatalogItemAvailability = searchOfferCatalogItemAvailability;
@@ -0,0 +1,38 @@
1
+ import type { EventRepo } from '../../../repo/event';
2
+ import type { EventSeriesRepo } from '../../../repo/eventSeries';
3
+ import type { OfferRepo } from '../../../repo/offer';
4
+ import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
5
+ import type { ProductRepo } from '../../../repo/product';
6
+ import * as factory from '../../../factory';
7
+ /**
8
+ * オファーで利用可能な適用決済カード条件を検索する
9
+ * プロダクトのひとつめのカタログのみ検索対象なので注意
10
+ * また、サブカタログによるカタログが設定されている場合、カタログのひとつめのサブカタログのみが検索対象
11
+ */
12
+ declare function searchOfferAppliesToMovieTicket(params: {
13
+ event: {
14
+ /**
15
+ * イベントID
16
+ */
17
+ id: string;
18
+ };
19
+ /**
20
+ * どのアプリケーションに対して
21
+ */
22
+ store?: {
23
+ id?: string;
24
+ };
25
+ limit?: number;
26
+ page?: number;
27
+ /**
28
+ * 有効なオファーのみ対象とするか
29
+ */
30
+ onlyValid?: boolean;
31
+ }): (repos: {
32
+ event: EventRepo;
33
+ eventSeries: EventSeriesRepo;
34
+ offer: OfferRepo;
35
+ offerCatalog: OfferCatalogRepo;
36
+ product: ProductRepo;
37
+ }) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
38
+ export { searchOfferAppliesToMovieTicket };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.searchOfferAppliesToMovieTicket = void 0;
13
+ const factory = require("../../../factory");
14
+ function getUnacceptedPaymentMethodByEvent(params) {
15
+ var _a;
16
+ let unacceptedPaymentMethod = [];
17
+ const unacceptedPaymentMethodByEvent = (_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.unacceptedPaymentMethod;
18
+ // 施設コンテンツを参照する必要はない(2022-10-31~)
19
+ if (Array.isArray(unacceptedPaymentMethodByEvent)) {
20
+ unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
21
+ }
22
+ return unacceptedPaymentMethod;
23
+ }
24
+ /**
25
+ * オファーで利用可能な適用決済カード条件を検索する
26
+ * プロダクトのひとつめのカタログのみ検索対象なので注意
27
+ * また、サブカタログによるカタログが設定されている場合、カタログのひとつめのサブカタログのみが検索対象
28
+ */
29
+ function searchOfferAppliesToMovieTicket(params) {
30
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
31
+ var _a, _b, _c, _d;
32
+ // optimize(2024-07-18~)
33
+ const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
34
+ // let soundFormatTypes: string[] = [];
35
+ let videoFormatTypes = [];
36
+ if (event.typeOf === factory.eventType.ScreeningEvent) {
37
+ const superEvents = yield repos.eventSeries.projectEventSeriesFields({
38
+ limit: 1,
39
+ page: 1,
40
+ id: { $eq: event.superEvent.id }
41
+ // typeOf: factory.eventType.ScreeningEventSeries
42
+ }, ['soundFormat', 'videoFormat']);
43
+ const superEvent = superEvents.shift();
44
+ if (superEvent === undefined) {
45
+ throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
46
+ }
47
+ // soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
48
+ videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
49
+ }
50
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
51
+ // 上映方式がなければMovieTicket除外
52
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
53
+ // 興行設定があれば興行のカタログを参照する
54
+ const eventOffers = event.offers;
55
+ let catalogId;
56
+ if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
57
+ const eventService = (yield repos.product.projectFields({
58
+ limit: 1,
59
+ page: 1,
60
+ id: { $eq: eventOffers.itemOffered.id }
61
+ }, ['hasOfferCatalog']
62
+ // []
63
+ )).shift();
64
+ if (eventService === undefined) {
65
+ throw new factory.errors.NotFound(factory.product.ProductType.EventService);
66
+ }
67
+ // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
68
+ const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
69
+ if (typeof firstCatalogIdOfProduct === 'string') {
70
+ catalogId = firstCatalogIdOfProduct;
71
+ }
72
+ }
73
+ if (typeof catalogId !== 'string') {
74
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
75
+ }
76
+ // サブカタログIDを決定
77
+ let subOfferCatalogId = catalogId;
78
+ // let isOfferCatalogItem: boolean = false;
79
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
80
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
81
+ subOfferCatalogId = offerCatalogFirstElement.id;
82
+ // isOfferCatalogItem = true;
83
+ }
84
+ return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
85
+ // subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
86
+ subOfferCatalog: { id: subOfferCatalogId },
87
+ availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
88
+ unacceptedPaymentMethod: unacceptedPaymentMethod,
89
+ excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
90
+ onlyValid: params.onlyValid === true,
91
+ // useIncludeInDataCatalog: params.useIncludeInDataCatalog,
92
+ limit: params.limit,
93
+ page: params.page
94
+ });
95
+ });
96
+ }
97
+ exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
@@ -0,0 +1,48 @@
1
+ import type { EventRepo } from '../../../repo/event';
2
+ import type { OfferRepo } from '../../../repo/offer';
3
+ import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
4
+ import type { ProductRepo } from '../../../repo/product';
5
+ interface ISearchOfferCatalogItemAvailabilityResult {
6
+ id: string;
7
+ isAvailable: boolean;
8
+ }
9
+ /**
10
+ * サブカタログ利用可能性検索
11
+ */
12
+ declare function searchOfferCatalogItemAvailability(params: {
13
+ event: {
14
+ /**
15
+ * イベントID
16
+ */
17
+ id: string;
18
+ };
19
+ /**
20
+ * どのアプリケーションに対して
21
+ */
22
+ availableAtOrFrom: {
23
+ id: string;
24
+ };
25
+ limit: number;
26
+ page: number;
27
+ options: {
28
+ /**
29
+ * イベントの利用不可決済方法区分を考慮するかどうか(2024-09-26~)
30
+ */
31
+ considerUnacceptedPaymentMethod: boolean;
32
+ /**
33
+ * 明示的なカタログID指定に対応(2024-10-01~)
34
+ */
35
+ includedInDataCatalog?: {
36
+ /**
37
+ * カタログID
38
+ */
39
+ id: string;
40
+ };
41
+ };
42
+ }): (repos: {
43
+ event: EventRepo;
44
+ offer: OfferRepo;
45
+ offerCatalog: OfferCatalogRepo;
46
+ product: ProductRepo;
47
+ }) => Promise<ISearchOfferCatalogItemAvailabilityResult[]>;
48
+ export { searchOfferCatalogItemAvailability };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.searchOfferCatalogItemAvailability = void 0;
13
+ const factory = require("../../../factory");
14
+ function getUnacceptedPaymentMethodByEvent(params) {
15
+ var _a;
16
+ let unacceptedPaymentMethod = [];
17
+ const unacceptedPaymentMethodByEvent = (_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.unacceptedPaymentMethod;
18
+ // 施設コンテンツを参照する必要はない(2022-10-31~)
19
+ if (Array.isArray(unacceptedPaymentMethodByEvent)) {
20
+ unacceptedPaymentMethod = unacceptedPaymentMethodByEvent;
21
+ }
22
+ return unacceptedPaymentMethod;
23
+ }
24
+ /**
25
+ * サブカタログ利用可能性検索
26
+ */
27
+ // tslint:disable-next-line:max-func-body-length
28
+ function searchOfferCatalogItemAvailability(params) {
29
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
30
+ var _a, _b, _c, _d;
31
+ const { considerUnacceptedPaymentMethod } = params.options;
32
+ if (typeof params.limit !== 'number') {
33
+ throw new factory.errors.Argument('limit', 'must be number');
34
+ }
35
+ if (typeof params.page !== 'number') {
36
+ throw new factory.errors.Argument('page', 'must be number');
37
+ }
38
+ let availabilities = [];
39
+ // optimize(2024-07-18~)
40
+ const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
41
+ // 興行設定があれば興行のカタログを参照する
42
+ const eventOffers = event.offers;
43
+ let catalogId;
44
+ if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
45
+ const eventService = (yield repos.product.projectFields({
46
+ limit: 1,
47
+ page: 1,
48
+ id: { $eq: eventOffers.itemOffered.id }
49
+ }, ['hasOfferCatalog']
50
+ // []
51
+ )).shift();
52
+ if (eventService === undefined) {
53
+ throw new factory.errors.NotFound(factory.product.ProductType.EventService);
54
+ }
55
+ const productCatalogs = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement;
56
+ /**
57
+ * 明示的なカタログID指定に対応(2024-10-01~)
58
+ */
59
+ const catalogIdSpecified = (_c = params.options.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id;
60
+ if (typeof catalogIdSpecified === 'string') {
61
+ const productHasSpecifiedCatalog = Array.isArray(productCatalogs) && productCatalogs.some(({ id }) => id === catalogIdSpecified);
62
+ if (!productHasSpecifiedCatalog) {
63
+ throw new factory.errors.Argument('includedInDataCatalog.id', 'specified catalog not found in product.hasOfferCatalog');
64
+ }
65
+ catalogId = catalogIdSpecified;
66
+ }
67
+ else {
68
+ // 指定のない場合、自動的にひとつめのカタログを選択
69
+ // const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
70
+ const firstCatalogIdOfProduct = (_d = productCatalogs === null || productCatalogs === void 0 ? void 0 : productCatalogs.at(0)) === null || _d === void 0 ? void 0 : _d.id;
71
+ if (typeof firstCatalogIdOfProduct === 'string') {
72
+ catalogId = firstCatalogIdOfProduct;
73
+ }
74
+ }
75
+ }
76
+ if (typeof catalogId !== 'string') {
77
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
78
+ }
79
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
80
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
81
+ const catalogItemListElements = yield repos.offerCatalog.searchItemListElementById({
82
+ id: catalogId,
83
+ limit: params.limit,
84
+ page: params.page
85
+ });
86
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
87
+ if (catalogItemListElements.length > 0) {
88
+ // 単価オファーから利用可能なサブカタログを検索
89
+ const availableCatalogs = yield repos.offer.searchAvailableCatalogs({
90
+ project: { id: event.project.id },
91
+ includedInDataCatalog: { id: catalogItemListElements.map((element) => element.id) },
92
+ availableAtOrFrom: { id: params.availableAtOrFrom.id },
93
+ unacceptedPaymentMethod: (considerUnacceptedPaymentMethod) ? unacceptedPaymentMethod : []
94
+ });
95
+ availabilities = catalogItemListElements.map((element) => {
96
+ return {
97
+ id: element.id,
98
+ isAvailable: availableCatalogs.some((item) => item.id === element.id)
99
+ };
100
+ });
101
+ }
102
+ }
103
+ else {
104
+ // Offerによるカタログの場合はひとまずempty
105
+ }
106
+ return availabilities;
107
+ });
108
+ }
109
+ exports.searchOfferCatalogItemAvailability = searchOfferCatalogItemAvailability;