@chevre/domain 21.8.0-alpha.31 → 21.8.0-alpha.33

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.
@@ -5,144 +5,154 @@ import { chevre } from '../../../lib/index';
5
5
 
6
6
  // tslint:disable-next-line:max-func-body-length
7
7
  async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
9
9
 
10
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
11
 
12
- const offers = await offerRepo.searchFromAggregateOffer({
13
- limit: 5,
14
- page: 1,
15
- sort: { 'priceSpecification.price': 1 },
16
- project: { id: { $eq: String(process.env.PROJECT_ID) } },
17
- availability: { $eq: chevre.factory.itemAvailability.InStock },
18
- addOn: {
19
- itemOffered: {
12
+ const offers = await offerRepo.searchFromAggregateOffer(
13
+ {
14
+ limit: 5,
15
+ page: 1,
16
+ sort: { 'priceSpecification.price': 1 },
17
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
18
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
19
+ addOn: {
20
+ itemOffered: {
21
+ /**
22
+ * アドオンプロダクトID
23
+ */
24
+ id: {
25
+ // $eq: ''
26
+ }
27
+ }
28
+ },
29
+ availableAtOrFrom: {
30
+ id: {
31
+ // $eq: ''
32
+ // $in: string[]
33
+ }
34
+ },
35
+ eligibleMembershipType: {
20
36
  /**
21
- * アドオンプロダクトID
37
+ * 適用メンバーシップ区分
22
38
  */
39
+ codeValue: {
40
+ // $eq: 'Permit'
41
+ }
42
+ },
43
+ eligibleMonetaryAmount: {
44
+ /**
45
+ * 適用通貨区分
46
+ */
47
+ currency: {
48
+ // $eq: 'Point'
49
+ }
50
+ },
51
+ eligibleSeatingType: {
52
+ /**
53
+ * 適用座席区分
54
+ */
55
+ codeValue: {
56
+ // $eq: ''
57
+ }
58
+ },
59
+ hasMerchantReturnPolicy: {
23
60
  id: {
24
61
  // $eq: ''
25
62
  }
26
- }
27
- },
28
- availableAtOrFrom: {
29
- id: {
30
- // $eq: ''
31
- // $in: string[]
32
- }
33
- },
34
- eligibleMembershipType: {
35
- /**
36
- * 適用メンバーシップ区分
37
- */
38
- codeValue: {
39
- // $eq: 'Permit'
40
- }
41
- },
42
- eligibleMonetaryAmount: {
43
- /**
44
- * 適用通貨区分
45
- */
46
- currency: {
47
- // $eq: 'Point'
48
- }
49
- },
50
- eligibleSeatingType: {
51
- /**
52
- * 適用座席区分
53
- */
54
- codeValue: {
55
- // $eq: ''
56
- }
57
- },
58
- hasMerchantReturnPolicy: {
63
+ },
59
64
  id: {
60
- // $eq: ''
61
- }
62
- },
63
- id: {
64
- // $eq: '1001'
65
- // $in: string[];
66
- },
67
- identifier: {
68
- // $eq: '1001'
69
- // $in: string[];
70
- // $regex: '003'
71
- },
72
- name: {
73
- // $regex: ''
74
- },
75
- priceSpecification: {
76
- appliesToMovieTicket: {
77
- /**
78
- * 適用決済カード区分
79
- */
80
- serviceType: {
65
+ // $eq: '1001'
66
+ // $in: string[];
67
+ },
68
+ identifier: {
69
+ // $eq: '1001'
70
+ // $in: string[];
71
+ // $regex: '003'
72
+ },
73
+ name: {
74
+ // $regex: ''
75
+ },
76
+ priceSpecification: {
77
+ appliesToMovieTicket: {
81
78
  /**
82
- * 適用決済カード区分が存在するかどうか
79
+ * 適用決済カード区分
83
80
  */
84
- // $exists: boolean;
85
- // $eq: '01'
81
+ serviceType: {
82
+ /**
83
+ * 適用決済カード区分が存在するかどうか
84
+ */
85
+ // $exists: boolean;
86
+ // $eq: '01'
87
+ },
88
+ serviceOutput: {
89
+ /**
90
+ * 適用決済方法タイプ
91
+ */
92
+ typeOf: {
93
+ // $eq: ''
94
+ // $nin: string[];
95
+ }
96
+ }
86
97
  },
87
- serviceOutput: {
88
- /**
89
- * 適用決済方法タイプ
90
- */
91
- typeOf: {
92
- // $eq: ''
93
- // $nin: string[];
98
+ price: {
99
+ // $gte: 100,
100
+ // $lte: 500
101
+ },
102
+ referenceQuantity: {
103
+ value: {
104
+ // $eq: 2
105
+ }
106
+ },
107
+ accounting: {
108
+ accountsReceivable: {
109
+ // $gte: 1800,
110
+ // $lte: 100
111
+ },
112
+ operatingRevenue: {
113
+ codeValue: {
114
+ // $eq: ''
115
+ // $in: string[];
116
+ }
94
117
  }
95
118
  }
96
119
  },
97
- price: {
98
- // $gte: 100,
99
- // $lte: 500
120
+ category: {
121
+ codeValue: {
122
+ // $in: ['1']
123
+ }
100
124
  },
101
- referenceQuantity: {
102
- value: {
103
- // $eq: 2
125
+ itemOffered: {
126
+ typeOf: {
127
+ // $eq: chevre.factory.product.ProductType.Product
104
128
  }
105
129
  },
106
- accounting: {
107
- accountsReceivable: {
108
- // $gte: 1800,
109
- // $lte: 100
110
- },
111
- operatingRevenue: {
112
- codeValue: {
113
- // $eq: ''
114
- // $in: string[];
130
+ /**
131
+ * 有効期間設定がない、あるいは、有効期間内
132
+ */
133
+ // onlyValid: true
134
+ additionalProperty: {
135
+ $all: [
136
+ {
137
+ $elemMatch: {
138
+ // name: { $eq: 'nameForPrinting' },
139
+ // value: { $in: ['General'] }
140
+ }
115
141
  }
116
- }
117
- }
118
- },
119
- category: {
120
- codeValue: {
121
- // $in: ['1']
142
+ ]
122
143
  }
123
144
  },
124
- itemOffered: {
125
- typeOf: {
126
- // $eq: chevre.factory.product.ProductType.Product
127
- }
128
- },
129
- /**
130
- * 有効期間設定がない、あるいは、有効期間内
131
- */
132
- // onlyValid: true
133
- additionalProperty: {
134
- $all: [
135
- {
136
- $elemMatch: {
137
- // name: { $eq: 'nameForPrinting' },
138
- // value: { $in: ['General'] }
139
- }
140
- }
141
- ]
145
+ {
146
+ id: 1,
147
+ identifier: 1,
148
+ name: 1,
149
+ alternateName: 1,
150
+ priceSpecification: 1
142
151
  }
143
- });
152
+ );
153
+ console.log(offers);
144
154
  console.log(offers.map((offer) => {
145
- return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja} ${offer.priceSpecification.price}`;
155
+ return `${offer.project?.id} ${offer.id} ${offer.identifier} ${offer.name?.ja} ${offer.priceSpecification?.price}`;
146
156
  }));
147
157
  console.log(offers.length);
148
158
  }
@@ -52,3 +52,125 @@ schema.index({ 'offers.identifier': 1, 'project.id': 1 }, {
52
52
  name: 'uniqueOfferIdentifier',
53
53
  unique: true
54
54
  });
55
+ schema.index({ 'offers.availability': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersAvailability' });
56
+ schema.index({ 'offers.itemOffered.typeOf': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersItemOfferedTypeOf' });
57
+ schema.index({ 'offers.identifier': 1, 'offers.priceSpecification.price': 1 }, {
58
+ name: 'searchByOffersIdentifier',
59
+ partialFilterExpression: {
60
+ 'offers.identifier': { $exists: true }
61
+ }
62
+ });
63
+ schema.index({ 'offers.priceSpecification.referenceQuantity.value': 1, 'offers.priceSpecification.price': 1 }, {
64
+ name: 'searchByOffersPriceSpecificationReferenceQuantityValue',
65
+ partialFilterExpression: {
66
+ 'offers.priceSpecification.referenceQuantity.value': { $exists: true }
67
+ }
68
+ });
69
+ schema.index({ 'offers.priceSpecification.accounting.accountsReceivable': 1, 'offers.priceSpecification.price': 1 }, {
70
+ name: 'searchByOffersPriceSpecificationAccountingAccountsReceivable',
71
+ partialFilterExpression: {
72
+ 'offers.priceSpecification.accounting.accountsReceivable': { $exists: true }
73
+ }
74
+ });
75
+ schema.index({ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
76
+ name: 'searchByOffersPriceSpecificationAccountingOperatingRevenueCodeValue',
77
+ partialFilterExpression: {
78
+ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': { $exists: true }
79
+ }
80
+ });
81
+ schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceType': 1, 'offers.priceSpecification.price': 1 }, {
82
+ name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceType',
83
+ partialFilterExpression: {
84
+ 'offers.priceSpecification.appliesToMovieTicket.serviceType': { $exists: true }
85
+ }
86
+ });
87
+ schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': 1, 'offers.priceSpecification.price': 1 }, {
88
+ name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceOutputTypeOf',
89
+ partialFilterExpression: {
90
+ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': { $exists: true }
91
+ }
92
+ });
93
+ schema.index({ 'offers.name.ja': 1, 'offers.priceSpecification.price': 1 }, {
94
+ name: 'searchByOffersNameJa',
95
+ partialFilterExpression: {
96
+ 'offers.name.ja': { $exists: true }
97
+ }
98
+ });
99
+ schema.index({ 'offers.name.en': 1, 'offers.priceSpecification.price': 1 }, {
100
+ name: 'searchByOffersNameEn',
101
+ partialFilterExpression: {
102
+ 'offers.name.en': { $exists: true }
103
+ }
104
+ });
105
+ schema.index({ 'offers.alternateName': 1, 'offers.priceSpecification.price': 1 }, {
106
+ name: 'searchByOffersAlternateName',
107
+ partialFilterExpression: {
108
+ 'offers.alternateName': { $exists: true }
109
+ }
110
+ });
111
+ schema.index({ 'offers.category.id': 1, 'offers.priceSpecification.price': 1 }, {
112
+ name: 'searchOffersCategoryId',
113
+ partialFilterExpression: {
114
+ 'offers.category.id': { $exists: true }
115
+ }
116
+ });
117
+ schema.index({ 'offers.category.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
118
+ name: 'searchByOffersCategoryCodeValue',
119
+ partialFilterExpression: {
120
+ 'offers.category.codeValue': { $exists: true }
121
+ }
122
+ });
123
+ schema.index({ 'offers.availableAtOrFrom.id': 1, 'offers.priceSpecification.price': 1 }, {
124
+ name: 'searchByOffersAvailableAtOrFromId',
125
+ partialFilterExpression: {
126
+ 'offers.availableAtOrFrom.id': { $exists: true }
127
+ }
128
+ });
129
+ schema.index({ 'offers.eligibleMembershipType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
130
+ name: 'searchByOffersEligibleMembershipTypeCodeValue',
131
+ partialFilterExpression: {
132
+ 'offers.eligibleMembershipType.codeValue': { $exists: true }
133
+ }
134
+ });
135
+ schema.index({ 'offers.eligibleMonetaryAmount.currency': 1, 'offers.priceSpecification.price': 1 }, {
136
+ name: 'searchByOffersEligibleMonetaryAmountCurrency',
137
+ partialFilterExpression: {
138
+ 'offers.eligibleMonetaryAmount.currency': { $exists: true }
139
+ }
140
+ });
141
+ schema.index({ 'offers.eligibleSeatingType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
142
+ name: 'searchByOffersEligibleSeatingTypeCodeValue',
143
+ partialFilterExpression: {
144
+ 'offers.eligibleSeatingType.codeValue': { $exists: true }
145
+ }
146
+ });
147
+ schema.index({ 'offers.addOn.itemOffered.id': 1, 'offers.priceSpecification.price': 1 }, {
148
+ name: 'searchByOffersAddOnItemOfferedId',
149
+ partialFilterExpression: {
150
+ 'offers.addOn.itemOffered.id': { $exists: true }
151
+ }
152
+ });
153
+ schema.index({ 'offers.hasMerchantReturnPolicy.id': 1, 'offers.priceSpecification.price': 1 }, {
154
+ name: 'searchByOffersHasMerchantReturnPolicyId',
155
+ partialFilterExpression: {
156
+ 'offers.hasMerchantReturnPolicy.id': { $exists: true }
157
+ }
158
+ });
159
+ schema.index({ 'offers.additionalProperty': 1, 'offers.priceSpecification.price': 1 }, {
160
+ name: 'searchByOffersAdditionalProperty',
161
+ partialFilterExpression: {
162
+ 'offers.additionalProperty': { $exists: true }
163
+ }
164
+ });
165
+ schema.index({ 'offers.validFrom': 1, 'offers.priceSpecification.price': 1 }, {
166
+ name: 'searchByOffersValidFrom',
167
+ partialFilterExpression: {
168
+ 'offers.validFrom': { $exists: true }
169
+ }
170
+ });
171
+ schema.index({ 'offers.validThrough': 1, 'offers.priceSpecification.price': 1 }, {
172
+ name: 'searchByOffersValidThrough',
173
+ partialFilterExpression: {
174
+ 'offers.validThrough': { $exists: true }
175
+ }
176
+ });
@@ -23,8 +23,9 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
26
- import { Connection, PipelineStage } from 'mongoose';
26
+ import { AnyExpression, Connection, PipelineStage } from 'mongoose';
27
27
  import * as factory from '../factory';
28
+ type IMatchStage = PipelineStage.Match;
28
29
  interface IProjection {
29
30
  [key: string]: 0 | 1;
30
31
  }
@@ -38,7 +39,10 @@ export declare class MongoRepository {
38
39
  private readonly taskModel;
39
40
  constructor(connection: Connection);
40
41
  static CREATE_OFFER_MONGO_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): any[];
41
- static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): PipelineStage.Match[];
42
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
43
+ static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
44
+ [field: string]: AnyExpression;
45
+ };
42
46
  /**
43
47
  * カタログに含まれるオファーを検索する
44
48
  * カタログに登録されたオファーの順序は保証される
@@ -65,6 +69,9 @@ export declare class MongoRepository {
65
69
  sortedOfferIds: string[];
66
70
  }>;
67
71
  findById(params: {
72
+ project: {
73
+ id: string;
74
+ };
68
75
  id: string;
69
76
  }): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
70
77
  findAggregateOfferById(params: {
@@ -74,8 +81,12 @@ export declare class MongoRepository {
74
81
  id: string;
75
82
  }): Promise<factory.aggregateOffer.IAggregateOffer>;
76
83
  count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
77
- search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
78
- searchFromAggregateOffer(params: factory.unitPriceOffer.ISearchConditions, __?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
84
+ search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection,
85
+ /**
86
+ * 強制的にoffersコレクションを使用する
87
+ */
88
+ useOffersAsPrimary?: boolean): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
89
+ searchFromAggregateOffer(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
79
90
  save(params: factory.unitPriceOffer.IUnitPriceOffer): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
80
91
  /**
81
92
  * sskts専用オファー保管
@@ -29,6 +29,7 @@ const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
29
29
  const task_1 = require("./mongoose/schemas/task");
30
30
  const task_2 = require("../eventEmitter/task");
31
31
  const settings_1 = require("../settings");
32
+ const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
32
33
  /**
33
34
  * オファーリポジトリ
34
35
  */
@@ -712,6 +713,64 @@ class MongoRepository {
712
713
  }
713
714
  return matchStages;
714
715
  }
716
+ static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
717
+ let projectStage = {
718
+ _id: 0,
719
+ offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`,
720
+ typeOf: '$offers.typeOf',
721
+ project: '$project',
722
+ id: '$offers.id',
723
+ identifier: '$offers.identifier',
724
+ name: '$offers.name',
725
+ description: '$offers.description',
726
+ category: '$offers.category',
727
+ color: '$offers.color',
728
+ additionalProperty: '$offers.additionalProperty',
729
+ advanceBookingRequirement: '$offers.advanceBookingRequirement',
730
+ alternateName: '$offers.alternateName',
731
+ addOn: '$offers.addOn',
732
+ availability: '$offers.availability',
733
+ availableAtOrFrom: '$offers.availableAtOrFrom',
734
+ hasMerchantReturnPolicy: '$offers.hasMerchantReturnPolicy',
735
+ itemOffered: '$offers.itemOffered',
736
+ priceCurrency: '$offers.priceCurrency',
737
+ priceSpecification: '$offers.priceSpecification',
738
+ eligibleCustomerType: '$offers.eligibleCustomerType',
739
+ eligibleDuration: '$offers.eligibleDuration',
740
+ eligibleMembershipType: '$offers.eligibleMembershipType',
741
+ eligibleMonetaryAmount: '$offers.eligibleMonetaryAmount',
742
+ eligibleQuantity: '$offers.eligibleQuantity',
743
+ eligibleRegion: '$offers.eligibleRegion',
744
+ eligibleSeatingType: '$offers.eligibleSeatingType',
745
+ eligibleSubReservation: '$offers.eligibleSubReservation',
746
+ settings: '$offers.settings',
747
+ validFrom: '$offers.validFrom',
748
+ validThrough: '$offers.validThrough',
749
+ validRateLimit: '$offers.validRateLimit'
750
+ };
751
+ const positiveProjectionFields = Object.keys(params)
752
+ .filter((key) => params[key] !== 0);
753
+ const negativeProjectionFields = Object.keys(params)
754
+ .filter((key) => params[key] === 0);
755
+ if (positiveProjectionFields.length > 0) {
756
+ projectStage = {
757
+ _id: 0,
758
+ offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`
759
+ };
760
+ positiveProjectionFields.forEach((field) => {
761
+ projectStage[field] = `$offers.${field}`;
762
+ });
763
+ }
764
+ else if (negativeProjectionFields.length > 0) {
765
+ negativeProjectionFields.forEach((field) => {
766
+ if (typeof projectStage[field] === 'string') {
767
+ // tslint:disable-next-line:no-dynamic-delete
768
+ delete projectStage[field];
769
+ }
770
+ });
771
+ }
772
+ return projectStage;
773
+ }
715
774
  /**
716
775
  * カタログに含まれるオファーを検索する
717
776
  * カタログに登録されたオファーの順序は保証される
@@ -759,7 +818,7 @@ class MongoRepository {
759
818
  }, onlyValid: params.onlyValid === true }), (typeof params.limit === 'number' && typeof params.page === 'number')
760
819
  ? { sort: { _id: factory.sortType.Ascending } }
761
820
  : undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
762
- offers = yield this.search(searchOffersConditions, params.projection);
821
+ offers = yield this.search(searchOffersConditions, params.projection, true);
763
822
  // 完全廃止(基本的にsortedOfferIdsと合わせて利用する想定)(2023-09-04~)
764
823
  // if (params.sort) {
765
824
  // // sorting
@@ -771,17 +830,17 @@ class MongoRepository {
771
830
  }
772
831
  findById(params) {
773
832
  return __awaiter(this, void 0, void 0, function* () {
774
- const doc = yield this.offerModel.findOne({ _id: params.id }, {
775
- __v: 0,
776
- createdAt: 0,
777
- updatedAt: 0,
778
- availableAddOn: 0 // 廃止属性の残存が確認されたので(2023-09-04~)
779
- })
780
- .exec();
781
- if (doc === null) {
833
+ const offers = yield this.search({
834
+ limit: 1,
835
+ page: 1,
836
+ project: { id: { $eq: params.project.id } },
837
+ id: { $eq: params.id }
838
+ });
839
+ const unitPriceOffer = offers.shift();
840
+ if (unitPriceOffer === undefined) {
782
841
  throw new factory.errors.NotFound(this.offerModel.modelName);
783
842
  }
784
- return doc.toObject();
843
+ return unitPriceOffer;
785
844
  });
786
845
  }
787
846
  findAggregateOfferById(params) {
@@ -809,9 +868,18 @@ class MongoRepository {
809
868
  .exec();
810
869
  });
811
870
  }
812
- search(params, projection) {
871
+ search(params, projection,
872
+ /**
873
+ * 強制的にoffersコレクションを使用する
874
+ */
875
+ useOffersAsPrimary) {
813
876
  var _a;
814
877
  return __awaiter(this, void 0, void 0, function* () {
878
+ // primaryコレクションをコントロール(2023-09-05~)
879
+ const useAggregateOfferAsPrimary = settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY && (useOffersAsPrimary !== true);
880
+ if (useAggregateOfferAsPrimary) {
881
+ return this.searchFromAggregateOffer(params, projection);
882
+ }
815
883
  const conditions = MongoRepository.CREATE_OFFER_MONGO_CONDITIONS(params);
816
884
  const positiveProjectionExists = (projection !== undefined && projection !== null)
817
885
  ? Object.values(projection)
@@ -836,69 +904,23 @@ class MongoRepository {
836
904
  .then((docs) => docs.map((doc) => doc.toObject()));
837
905
  });
838
906
  }
839
- // tslint:disable-next-line:max-func-body-length
840
- searchFromAggregateOffer(params, __) {
907
+ searchFromAggregateOffer(params, projection) {
841
908
  var _a;
842
909
  return __awaiter(this, void 0, void 0, function* () {
843
910
  const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
844
- // tslint:disable-next-line:no-suspicious-comment
845
- // TODO implement projection
846
- // const positiveProjectionExists: boolean = (projection !== undefined && projection !== null)
847
- // ? Object.values(projection)
848
- // .some((value) => value !== 0)
849
- // : false;
911
+ const projectStage = MongoRepository.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
850
912
  const aggregate = this.aggregateOfferModel.aggregate([
851
- { $unwind: '$offers' },
913
+ {
914
+ $unwind: {
915
+ path: '$offers',
916
+ includeArrayIndex: OFFERS_ARRAY_INDEX_NAME
917
+ }
918
+ },
852
919
  ...matchStages,
853
- ...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) !== undefined)
920
+ ...(typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number')
854
921
  ? [{ $sort: { 'offers.priceSpecification.price': params.sort['priceSpecification.price'] } }]
855
922
  : [],
856
- {
857
- $project: {
858
- _id: 0,
859
- typeOf: '$offers.typeOf',
860
- project: '$project',
861
- id: '$offers.id',
862
- identifier: '$offers.identifier',
863
- name: '$offers.name',
864
- description: '$offers.description',
865
- category: '$offers.category',
866
- color: '$offers.color',
867
- additionalProperty: '$offers.additionalProperty',
868
- advanceBookingRequirement: '$offers.advanceBookingRequirement',
869
- alternateName: '$offers.alternateName',
870
- addOn: '$offers.addOn',
871
- availability: '$offers.availability',
872
- availableAtOrFrom: '$offers.availableAtOrFrom',
873
- hasMerchantReturnPolicy: '$offers.hasMerchantReturnPolicy',
874
- itemOffered: '$offers.itemOffered',
875
- priceCurrency: '$offers.priceCurrency',
876
- priceSpecification: '$offers.priceSpecification',
877
- eligibleCustomerType: '$offers.eligibleCustomerType',
878
- eligibleDuration: '$offers.eligibleDuration',
879
- eligibleMembershipType: '$offers.eligibleMembershipType',
880
- eligibleMonetaryAmount: '$offers.eligibleMonetaryAmount',
881
- eligibleQuantity: '$offers.eligibleQuantity',
882
- eligibleRegion: '$offers.eligibleRegion',
883
- eligibleSeatingType: '$offers.eligibleSeatingType',
884
- eligibleSubReservation: '$offers.eligibleSubReservation',
885
- settings: '$offers.settings',
886
- validFrom: '$offers.validFrom',
887
- validThrough: '$offers.validThrough',
888
- validRateLimit: '$offers.validRateLimit'
889
- // ...(searchConditions.$projection?.seatCount === 1)
890
- // ? {
891
- // seatCount: {
892
- // $cond: {
893
- // if: { $isArray: '$containsPlace.containsPlace' },
894
- // then: { $size: '$containsPlace.containsPlace' },
895
- // else: 0
896
- // }
897
- // }
898
- // }
899
- // : undefined
900
- }
901
- }
923
+ { $project: projectStage }
902
924
  ]);
903
925
  // tslint:disable-next-line:no-single-line-block-comment
904
926
  /* istanbul ignore else */
@@ -43,6 +43,7 @@ export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
43
43
  export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
44
44
  export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
45
45
  export declare const USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY: boolean;
46
+ export declare const USE_AGGREGATE_OFFERS_AS_PRIMARY: boolean;
46
47
  export declare const MONGO_MAX_TIME_MS: number;
47
48
  /**
48
49
  * グローバル設定
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -75,6 +75,7 @@ exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1
75
75
  exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
76
76
  exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
77
77
  exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = process.env.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY === '1';
78
+ exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY === '1';
78
79
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
79
80
  ? Number(process.env.MONGO_MAX_TIME_MS)
80
81
  // tslint:disable-next-line:no-magic-numbers
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.8.0-alpha.31"
120
+ "version": "21.8.0-alpha.33"
121
121
  }