@chevre/domain 21.10.0 → 21.11.0-alpha.1

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.
@@ -0,0 +1,34 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../../lib/index';
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const offers = await offerRepo.searchAllByIdsAndOfferCatalogId({
13
+ ids: ['xx', 'xxx', '1001', '901'],
14
+ includedInDataCatalog: {
15
+ // id: ['0001'],
16
+ // isOfferCatalogItem: false
17
+ id: ['6509262f69b07dde13c708eb', '6509262f69b07dde13c708ex', '6508dd91584bb60769914d2b', '651360e04df434b49114e4bb'],
18
+ isOfferCatalogItem: true
19
+ },
20
+ excludeAppliesToMovieTicket: false
21
+ });
22
+ // console.log(offers);
23
+ console.log(offers.map((offer) => {
24
+ return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${offer.offerIndex}`;
25
+ }));
26
+ console.log(offers.length);
27
+ }
28
+
29
+ main()
30
+ .then(console.log)
31
+ .catch((error) => {
32
+ console.error(chevre.errorHandler.handleMongoError(error));
33
+ console.error(error.name, error.code, error.message);
34
+ });
@@ -2,7 +2,7 @@
2
2
  import * as mongoose from 'mongoose';
3
3
  import * as redis from 'redis';
4
4
 
5
- import { chevre } from '../../../lib/index';
5
+ import { chevre } from '../../../../lib/index';
6
6
 
7
7
  // const PROJECT_ID = process.env.PROJECT_ID;
8
8
 
@@ -28,6 +28,7 @@ async function main() {
28
28
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
29
29
  event: { id: 'ale6qiedq' },
30
30
  onlyValid: true,
31
+ includedInDataCatalog: { id: '' },
31
32
  priceSpecification: {},
32
33
  validateOfferRateLimit: true,
33
34
  addSortIndex: true,
@@ -2,7 +2,7 @@
2
2
  // import * as redis from 'redis';
3
3
  import * as mongoose from 'mongoose';
4
4
 
5
- import { chevre } from '../../../lib/index';
5
+ import { chevre } from '../../../../lib/index';
6
6
 
7
7
  async function main() {
8
8
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
@@ -13,7 +13,7 @@ async function main() {
13
13
  limit: 10,
14
14
  page: 1,
15
15
  // ids: ['xx', 'xxx', '1001', '901'],
16
- subOfferCatalog: {
16
+ offerCatalog: {
17
17
  id: '0001',
18
18
  isOfferCatalogItem: false
19
19
  },
@@ -33,7 +33,6 @@ async function main() {
33
33
  return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${offer.offerIndex} ${sortIndex}`;
34
34
  }));
35
35
  console.log(offers.length);
36
- console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
37
36
  }
38
37
 
39
38
  main()
@@ -33,6 +33,9 @@ function handleMongoError(error) {
33
33
  default:
34
34
  }
35
35
  }
36
+ if (mongoose_1.mongo.BSON.BSONError.isBSONError(handledError)) {
37
+ handledError = new factory_1.errors.Argument('', handledError.message);
38
+ }
36
39
  return handledError;
37
40
  }
38
41
  exports.handleMongoError = handleMongoError;
@@ -48,11 +48,11 @@ export declare class MongoRepository {
48
48
  * 指定したIDの単価オファーだけ取得
49
49
  */
50
50
  ids: string[];
51
- subOfferCatalog: {
51
+ includedInDataCatalog: {
52
52
  /**
53
- * サブカタログID
53
+ * オファー記載のカタログID(複数対応)
54
54
  */
55
- id: string;
55
+ id: string[];
56
56
  isOfferCatalogItem: boolean;
57
57
  };
58
58
  availableAtOrFrom?: {
@@ -62,15 +62,13 @@ export declare class MongoRepository {
62
62
  excludeAppliesToMovieTicket: boolean;
63
63
  onlyValid?: boolean;
64
64
  projection?: IProjection;
65
- }): Promise<{
66
- offers: IUnitPriceOfferFromAggregateOffer[];
67
- }>;
65
+ }): Promise<IUnitPriceOfferFromAggregateOffer[]>;
68
66
  /**
69
67
  * カタログに含まれるオファーを検索する(カタログ内ソートは保証しない)
70
68
  * カタログ内ソートインデックスはsortedOfferIdsで判断する
71
69
  */
72
70
  searchByOfferCatalogIdWithSortIndex(params: {
73
- subOfferCatalog: {
71
+ offerCatalog: {
74
72
  /**
75
73
  * サブカタログID
76
74
  */
@@ -166,5 +164,9 @@ export declare class MongoRepository {
166
164
  * サブカタログから集計オファーIDリストを検索する
167
165
  */
168
166
  private searchAggregateOfferIdsBySubOfferCatalog;
167
+ /**
168
+ * 複数サブカタログから集計オファーIDリストを検索する
169
+ */
170
+ private searchAggregateOfferIdsBySubOfferCatalogs;
169
171
  }
170
172
  export {};
@@ -492,17 +492,17 @@ class MongoRepository {
492
492
  if (aggregateOfferIds.length === 0) {
493
493
  throw new factory.errors.NotFound(factory.offerType.AggregateOffer);
494
494
  }
495
- const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
496
- id: params.subOfferCatalog.id,
497
- isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem,
495
+ const aggregateOfferIdsInDataCatalog = yield this.searchAggregateOfferIdsBySubOfferCatalogs({
496
+ id: params.includedInDataCatalog.id,
497
+ isOfferCatalogItem: params.includedInDataCatalog.isOfferCatalogItem,
498
498
  itemListElementIds: aggregateOfferIds
499
499
  });
500
500
  let offers = [];
501
- if (sortedOfferIds.length > 0) {
502
- debug('searchAllByIdsAndOfferCatalogId:searching offers...,sortedOfferIds:', sortedOfferIds, 'ids:', params.ids);
501
+ if (aggregateOfferIdsInDataCatalog.length > 0) {
502
+ debug('searchAllByIdsAndOfferCatalogId:searching offers...,aggregateOfferIdsInDataCatalog:', aggregateOfferIdsInDataCatalog, 'ids:', params.ids);
503
503
  const searchOffersConditions = Object.assign({
504
504
  // aggregateOffer.idで検索する(2023-09-09~)
505
- parentOffer: { id: { $in: sortedOfferIds } }, id: { $in: params.ids }, priceSpecification: {
505
+ parentOffer: { id: { $in: aggregateOfferIdsInDataCatalog } }, id: { $in: params.ids }, priceSpecification: {
506
506
  appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
507
507
  ? {
508
508
  serviceOutput: {
@@ -516,17 +516,10 @@ class MongoRepository {
516
516
  : undefined)
517
517
  }, onlyValid: params.onlyValid === true }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
518
518
  ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
519
- : undefined
520
- // ...(typeof params.limit === 'number' && typeof params.page === 'number')
521
- // // 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
522
- // ? { sort: { identifier: factory.sortType.Ascending } }
523
- // : undefined,
524
- // ...(typeof params.limit === 'number') ? { limit: params.limit } : undefined,
525
- // ...(typeof params.page === 'number') ? { page: params.page } : undefined
526
- );
519
+ : undefined);
527
520
  offers = yield this.search(searchOffersConditions, params.projection);
528
521
  }
529
- return { offers };
522
+ return offers;
530
523
  });
531
524
  }
532
525
  /**
@@ -537,8 +530,8 @@ class MongoRepository {
537
530
  var _a, _b, _c, _d, _e, _f, _g, _h;
538
531
  return __awaiter(this, void 0, void 0, function* () {
539
532
  const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
540
- id: params.subOfferCatalog.id,
541
- isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
533
+ id: params.offerCatalog.id,
534
+ isOfferCatalogItem: params.offerCatalog.isOfferCatalogItem
542
535
  });
543
536
  let offers = [];
544
537
  if (sortedOfferIds.length > 0) {
@@ -562,7 +555,7 @@ class MongoRepository {
562
555
  : undefined)
563
556
  };
564
557
  const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ priceSpecification: priceSpecificationConditions, onlyValid: params.onlyValid === true }, (params.useIncludeInDataCatalog)
565
- ? { includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }
558
+ ? { includedInDataCatalog: { id: { $in: [params.offerCatalog.id] } } }
566
559
  : { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_h = params.availableAtOrFrom) === null || _h === void 0 ? void 0 : _h.id) === 'string')
567
560
  ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
568
561
  : undefined), (typeof params.limit === 'number' && typeof params.page === 'number')
@@ -891,9 +884,6 @@ class MongoRepository {
891
884
  let itemListElements;
892
885
  if (params.isOfferCatalogItem) {
893
886
  const matchStages = [{ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id) } } }]; // ObjectIdなので注意
894
- if (Array.isArray(params.itemListElementIds)) {
895
- matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
896
- }
897
887
  itemListElements = yield this.offerCatalogItemModel.aggregate([
898
888
  { $unwind: '$itemListElement' },
899
889
  ...matchStages,
@@ -908,9 +898,6 @@ class MongoRepository {
908
898
  }
909
899
  else {
910
900
  const matchStages = [{ $match: { _id: { $eq: params.id } } }];
911
- if (Array.isArray(params.itemListElementIds)) {
912
- matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
913
- }
914
901
  itemListElements = yield this.offerCatalogModel.aggregate([
915
902
  { $unwind: '$itemListElement' },
916
903
  ...matchStages,
@@ -928,5 +915,53 @@ class MongoRepository {
928
915
  : [];
929
916
  });
930
917
  }
918
+ /**
919
+ * 複数サブカタログから集計オファーIDリストを検索する
920
+ */
921
+ searchAggregateOfferIdsBySubOfferCatalogs(params) {
922
+ return __awaiter(this, void 0, void 0, function* () {
923
+ if (!Array.isArray(params.itemListElementIds) || params.itemListElementIds.length === 0) {
924
+ throw new factory.errors.ArgumentNull('itemListElementIds');
925
+ }
926
+ let itemListElements;
927
+ if (params.isOfferCatalogItem) {
928
+ const matchStages = [
929
+ { $match: { _id: { $in: params.id.map((id) => new mongoose_1.Types.ObjectId(id)) } } },
930
+ { $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } }
931
+ ];
932
+ itemListElements = yield this.offerCatalogItemModel.aggregate([
933
+ { $unwind: '$itemListElement' },
934
+ ...matchStages,
935
+ {
936
+ $group: { _id: '$itemListElement.id' }
937
+ }
938
+ ])
939
+ .exec();
940
+ }
941
+ else {
942
+ // 1カタログしかありえないはず
943
+ if (params.id.length !== 1) {
944
+ throw new factory.errors.Argument('id', 'length must be 1');
945
+ }
946
+ const matchStages = [
947
+ { $match: { _id: { $in: params.id } } },
948
+ { $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } }
949
+ ];
950
+ itemListElements = yield this.offerCatalogModel.aggregate([
951
+ { $unwind: '$itemListElement' },
952
+ ...matchStages,
953
+ {
954
+ $project: {
955
+ _id: '$itemListElement.id'
956
+ }
957
+ }
958
+ ])
959
+ .exec();
960
+ }
961
+ return (Array.isArray(itemListElements))
962
+ ? itemListElements.map((element) => element._id)
963
+ : [];
964
+ });
965
+ }
931
966
  }
932
967
  exports.MongoRepository = MongoRepository;
@@ -94,6 +94,7 @@ function createTransactionObject(params) {
94
94
  ids: params.acceptedOffers.map((o) => o.id),
95
95
  itemOffered: { id: String(params.product.id) },
96
96
  onlyValid: true,
97
+ includedInDataCatalog: { id: '' },
97
98
  addSortIndex: false,
98
99
  useIncludeInDataCatalog: false
99
100
  })(repos);
@@ -119,6 +119,7 @@ function addReservations(params) {
119
119
  // 対応アプリケーション条件追加(2023-01-27~)
120
120
  store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
121
121
  priceSpecification: {},
122
+ includedInDataCatalog: { id: '' },
122
123
  onlyValid: true,
123
124
  addSortIndex: false,
124
125
  validateOfferRateLimit: true,
@@ -478,7 +479,7 @@ function searchAvailableAddOns(params) {
478
479
  if (Array.isArray(params.ticketOffer.addOn)) {
479
480
  const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
480
481
  for (const addOnProductId of addOnProductIds) {
481
- const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
482
+ const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, includedInDataCatalog: { id: '' }, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
482
483
  ? { availableAt: { id: params.availableAtOrFrom.id } }
483
484
  : undefined))(repos);
484
485
  availableAddOns.push(...offers.map((o) => {
@@ -238,6 +238,7 @@ function validateAcceptedOffers(params) {
238
238
  event: { id: params.event.id },
239
239
  store: params.store,
240
240
  priceSpecification: {},
241
+ includedInDataCatalog: { id: '' },
241
242
  onlyValid: true,
242
243
  addSortIndex: false,
243
244
  validateOfferRateLimit: true,
@@ -41,6 +41,9 @@ declare function searchEventTicketOffers(params: {
41
41
  */
42
42
  onlyValid: boolean;
43
43
  priceSpecification: Pick<factory.unitPriceOffer.IPriceSpecificationSearchConditions, 'appliesToMovieTicket'>;
44
+ includedInDataCatalog: {
45
+ id: string;
46
+ };
44
47
  limit?: number;
45
48
  page?: number;
46
49
  addSortIndex: boolean;
@@ -16,12 +16,11 @@ const factory_1 = require("../factory");
16
16
  function searchTicketOffersByItemOffered(params) {
17
17
  return (repos) => __awaiter(this, void 0, void 0, function* () {
18
18
  var _a, _b, _c, _d, _e;
19
+ let eventService;
19
20
  let catalogId;
20
- if (typeof ((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
21
- const eventService = yield repos.product.findById({ id: (_b = params.itemOffered) === null || _b === void 0 ? void 0 : _b.id }, ['hasOfferCatalog'], []);
22
- if (typeof ((_c = eventService.hasOfferCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
23
- catalogId = eventService.hasOfferCatalog.id;
24
- }
21
+ eventService = yield repos.product.findById({ id: (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id }, ['hasOfferCatalog', 'project'], []);
22
+ if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
23
+ catalogId = eventService.hasOfferCatalog.id;
25
24
  }
26
25
  if (typeof catalogId !== 'string') {
27
26
  throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
@@ -39,9 +38,20 @@ function searchTicketOffersByItemOffered(params) {
39
38
  if (Array.isArray(params.ids)) {
40
39
  throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
41
40
  }
41
+ // 明示的にカタログ指定可能にする
42
+ if (typeof ((_c = params.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
43
+ if (isOfferCatalogItem) {
44
+ // no op
45
+ }
46
+ else {
47
+ if (subOfferCatalogId !== params.includedInDataCatalog.id) {
48
+ throw new factory.errors.Argument('includedInDataCatalog.id', 'invalid offerCatalog');
49
+ }
50
+ }
51
+ subOfferCatalogId = params.includedInDataCatalog.id;
52
+ }
42
53
  const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
43
- // ids: params.ids,
44
- subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
54
+ offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
45
55
  availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
46
56
  unacceptedPaymentMethod: params.unacceptedPaymentMethod,
47
57
  excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
@@ -54,21 +64,28 @@ function searchTicketOffersByItemOffered(params) {
54
64
  return { availableOffers: offers, sortedOfferIds };
55
65
  }
56
66
  else {
57
- // addSortIndexの場合はid指定廃止(2023-09-13~)
67
+ // id指定必須(2023-09-13~)
58
68
  if (!Array.isArray(params.ids)) {
59
69
  throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
60
70
  }
61
- const { offers } = yield repos.offer.searchAllByIdsAndOfferCatalogId({
71
+ let includedInDataCatalogIds = [subOfferCatalogId];
72
+ if (isOfferCatalogItem) {
73
+ // 複数カタログ対応(2023-09-27~)
74
+ const offerCatalogItems = yield repos.offerCatalog.findItemListElementById({
75
+ id: catalogId,
76
+ project: { id: eventService.project.id }
77
+ });
78
+ includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
79
+ }
80
+ const availableOffers = yield repos.offer.searchAllByIdsAndOfferCatalogId({
62
81
  ids: params.ids,
63
- subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
82
+ includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
64
83
  availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
65
84
  unacceptedPaymentMethod: params.unacceptedPaymentMethod,
66
85
  excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
67
86
  onlyValid: params.onlyValid === true
68
- // limit: params.limit,
69
- // page: params.page
70
87
  });
71
- return { availableOffers: offers };
88
+ return { availableOffers };
72
89
  }
73
90
  });
74
91
  }
@@ -108,12 +125,13 @@ function searchEventTicketOffersByEvent(params) {
108
125
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
109
126
  const eventOffers = event.offers;
110
127
  const { availableOffers, sortedOfferIds } = yield searchTicketOffersByItemOffered({
111
- itemOffered: { id: (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id },
128
+ itemOffered: { id: String((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) },
112
129
  ids: params.ids,
113
130
  store: params.store,
114
131
  limit: params.limit,
115
132
  page: params.page,
116
133
  onlyValid: params.onlyValid,
134
+ includedInDataCatalog: params.includedInDataCatalog,
117
135
  unacceptedPaymentMethod,
118
136
  excludeAppliesToMovieTicket,
119
137
  priceSpecification: params.priceSpecification,
@@ -279,6 +297,7 @@ function searchEventTicketOffers(params) {
279
297
  event,
280
298
  store: params.store,
281
299
  priceSpecification: params.priceSpecification,
300
+ includedInDataCatalog: params.includedInDataCatalog,
282
301
  limit: params.limit,
283
302
  page: params.page,
284
303
  addSortIndex: params.addSortIndex,
@@ -24,6 +24,9 @@ export declare function searchProductOffers(params: {
24
24
  onlyValid: boolean;
25
25
  addSortIndex: boolean;
26
26
  useIncludeInDataCatalog: boolean;
27
+ includedInDataCatalog: {
28
+ id: string;
29
+ };
27
30
  limit?: number;
28
31
  page?: number;
29
32
  }): (repos: {
@@ -15,12 +15,12 @@ const settings_1 = require("../../../settings");
15
15
  /**
16
16
  * プロダクトオファーを検索する
17
17
  */
18
- // tslint:disable-next-line:max-func-body-length
19
18
  function searchProductOffers(params) {
19
+ // tslint:disable-next-line:max-func-body-length
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
- var _a;
21
+ var _a, _b;
22
22
  // プロダクト検索
23
- const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id }, ['hasOfferCatalog'], []);
23
+ const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id }, ['hasOfferCatalog', 'project'], []);
24
24
  const offerCatalogId = (_a = productWithOffers.hasOfferCatalog) === null || _a === void 0 ? void 0 : _a.id;
25
25
  if (typeof offerCatalogId !== 'string') {
26
26
  return [];
@@ -40,9 +40,20 @@ function searchProductOffers(params) {
40
40
  if (Array.isArray(params.ids)) {
41
41
  throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
42
42
  }
43
+ // 明示的にカタログ指定可能にする
44
+ if (typeof ((_b = params.includedInDataCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
45
+ if (isOfferCatalogItem) {
46
+ // no op
47
+ }
48
+ else {
49
+ if (subOfferCatalogId !== params.includedInDataCatalog.id) {
50
+ throw new factory.errors.Argument('includedInDataCatalog.id', 'invalid offerCatalog');
51
+ }
52
+ }
53
+ subOfferCatalogId = params.includedInDataCatalog.id;
54
+ }
43
55
  const searchByOfferCatalogIdResult = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
44
- // ids: params.ids,
45
- subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
56
+ offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
46
57
  excludeAppliesToMovieTicket: false,
47
58
  priceSpecification: {},
48
59
  limit: params.limit,
@@ -55,20 +66,27 @@ function searchProductOffers(params) {
55
66
  sortedOfferIds = searchByOfferCatalogIdResult.sortedOfferIds;
56
67
  }
57
68
  else {
58
- // addSortIndexの場合はid指定廃止(2023-09-13~)
69
+ // id指定必須(2023-09-13~)
59
70
  if (!Array.isArray(params.ids)) {
60
71
  throw new factory.errors.ArgumentNull('ids', 'ids must be specified');
61
72
  }
73
+ let includedInDataCatalogIds = [subOfferCatalogId];
74
+ if (isOfferCatalogItem) {
75
+ // 複数カタログ対応(2023-09-27~)
76
+ const offerCatalogItems = yield repos.offerCatalog.findItemListElementById({
77
+ id: offerCatalogId,
78
+ project: { id: productWithOffers.project.id }
79
+ });
80
+ includedInDataCatalogIds = offerCatalogItems.itemListElement.map((element) => element.id);
81
+ }
62
82
  const searchByOfferCatalogIdResult = yield repos.offer.searchAllByIdsAndOfferCatalogId({
63
83
  ids: params.ids,
64
- subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
84
+ includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
65
85
  excludeAppliesToMovieTicket: false,
66
- // limit: params.limit,
67
- // page: params.page,
68
86
  onlyValid: params.onlyValid === true,
69
87
  availableAtOrFrom: params.availableAt
70
88
  });
71
- offers = searchByOfferCatalogIdResult.offers;
89
+ offers = searchByOfferCatalogIdResult;
72
90
  }
73
91
  return offers.map((o) => {
74
92
  var _a;
@@ -52,6 +52,9 @@ export declare function search(params: {
52
52
  id: string;
53
53
  };
54
54
  onlyValid: boolean;
55
+ includedInDataCatalog: {
56
+ id: string;
57
+ };
55
58
  limit?: number;
56
59
  page?: number;
57
60
  addSortIndex: boolean;
@@ -64,6 +64,7 @@ function search(params) {
64
64
  itemOffered: { id: params.itemOffered.id },
65
65
  availableAt: params.availableAt,
66
66
  onlyValid: params.onlyValid,
67
+ includedInDataCatalog: params.includedInDataCatalog,
67
68
  addSortIndex: params.addSortIndex,
68
69
  useIncludeInDataCatalog: params.useIncludeInDataCatalog,
69
70
  limit: params.limit,
@@ -185,7 +186,7 @@ function fixProductAndOffers(params) {
185
186
  if (product === undefined) {
186
187
  throw new factory.errors.NotFound('Product');
187
188
  }
188
- const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
189
+ const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, includedInDataCatalog: { id: '' }, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
189
190
  return { product, availableOffers: offers };
190
191
  });
191
192
  }
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.10.0"
120
+ "version": "21.11.0-alpha.1"
121
121
  }