@chevre/domain 21.9.0-alpha.13 → 21.9.0-alpha.14

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,38 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const PROJECT_ID = process.env.PROJECT_ID;
7
+ mongoose.Model.on('index', (...args) => {
8
+ console.error('******** index event emitted. ********\n', args);
9
+ });
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
15
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
16
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
17
+ const productRepo = new chevre.repository.Product(mongoose.connection);
18
+
19
+ const result = await chevre.service.offer.event.searchOfferCatalogItemAvailability({
20
+ event: {
21
+ id: 'cllkq475u'
22
+ },
23
+ limit: 10,
24
+ page: 1,
25
+ availableAtOrFrom: { id: '3eo6okferrsdpfd9j2ce1iv9k7' }
26
+ })({
27
+ event: eventRepo,
28
+ offer: offerRepo,
29
+ offerCatalog: offerCatalogRepo,
30
+ product: productRepo
31
+ });
32
+ console.log(result);
33
+ console.log(result.length);
34
+ }
35
+
36
+ main()
37
+ .then(console.log)
38
+ .catch(console.error);
@@ -3,7 +3,7 @@ import * as mongoose from 'mongoose';
3
3
 
4
4
  import { chevre } from '../../../lib/index';
5
5
 
6
- const PROJECT_ID = process.env.PROJECT_ID;
6
+ // const PROJECT_ID = process.env.PROJECT_ID;
7
7
  mongoose.Model.on('index', (...args) => {
8
8
  console.error('******** index event emitted. ********\n', args);
9
9
  });
@@ -11,31 +11,46 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const catalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
15
-
16
- console.log('searching...');
17
- const catalogs = await catalogItemRepo.search(
18
- {
19
- project: { id: { $eq: PROJECT_ID } },
20
- sort: { identifier: chevre.factory.sortType.Descending },
21
- limit: 2,
22
- page: 1,
23
- itemListElement: { typeOf: { $eq: 'Offer' } }
24
- // id: { $in: ['xxx'] }
25
- }
26
- );
27
- console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
28
- console.log('catalogs found', catalogs.map((catalog) => `${catalog.id} ${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
29
- console.log(catalogs.length);
30
-
31
- const numCatalogs = await catalogItemRepo.count(
32
- {
33
- project: { id: { $eq: PROJECT_ID } },
34
- itemListElement: { typeOf: { $eq: 'Offer' } }
35
- // id: { $in: ['xxx'] }
36
- }
37
- );
38
- console.log('numCatalogs:', numCatalogs);
14
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
15
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
16
+ const offerCatalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
17
+ const productRepo = new chevre.repository.Product(mongoose.connection);
18
+
19
+ const result = await chevre.service.offer.event.searchOfferCatalogItems({
20
+ event: {
21
+ id: 'cllkq475u'
22
+ },
23
+ limit: 10,
24
+ page: 1
25
+ })({
26
+ event: eventRepo,
27
+ offerCatalog: offerCatalogRepo,
28
+ offerCatalogItem: offerCatalogItemRepo,
29
+ product: productRepo
30
+ });
31
+ console.log(result);
32
+ console.log(result.length);
33
+
34
+ // console.log('searching...');
35
+ // const catalogs = await catalogItemRepo.search(
36
+ // {
37
+ // project: { id: { $eq: PROJECT_ID } },
38
+ // sort: { identifier: chevre.factory.sortType.Descending },
39
+ // limit: 2,
40
+ // page: 1,
41
+ // itemListElement: { typeOf: { $eq: 'Offer' } }
42
+ // }
43
+ // );
44
+ // console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
45
+ // console.log(catalogs.length);
46
+
47
+ // const numCatalogs = await catalogItemRepo.count(
48
+ // {
49
+ // project: { id: { $eq: PROJECT_ID } },
50
+ // itemListElement: { typeOf: { $eq: 'Offer' } }
51
+ // }
52
+ // );
53
+ // console.log('numCatalogs:', numCatalogs);
39
54
  }
40
55
 
41
56
  main()
@@ -3,8 +3,20 @@ import * as mongoose from 'mongoose';
3
3
 
4
4
  import { chevre } from '../../../lib/index';
5
5
 
6
+ mongoose.Model.on('index', (...args) => {
7
+ console.error('******** index event emitted. ********\n', args);
8
+ });
9
+
6
10
  async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
12
+
13
+ console.log(
14
+ await mongoose.connection.db.collection('aggregateOffers')
15
+ .indexes()
16
+ );
17
+ // await mongoose.connection.db.collection('aggregateOffers')
18
+ // .dropIndexes();
19
+ // console.log('indexes droped');
8
20
 
9
21
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
10
22
 
@@ -33,9 +45,9 @@ async function main() {
33
45
  // ]
34
46
  // }
35
47
  });
36
- console.log(offers.map((offer) => {
37
- return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
38
- }));
48
+ // console.log(offers.map((offer) => {
49
+ // return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
50
+ // }));
39
51
  console.log(offers.length);
40
52
  }
41
53
 
@@ -42,7 +42,6 @@ exports.schema = schema;
42
42
  schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
43
43
  schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
44
44
  schema.index({ 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersPriceSpecificationPrice' });
45
- schema.index({ 'project.id': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByProjectId' });
46
45
  // オファーIDはグローバルユニーク
47
46
  schema.index({ 'offers.id': 1 }, {
48
47
  name: 'uniqueOfferId',
@@ -59,130 +58,131 @@ schema.index({ 'includedInDataCatalog.id': 1 }, {
59
58
  'includedInDataCatalog.id': { $exists: true }
60
59
  }
61
60
  });
62
- schema.index({ 'offers.includedInDataCatalog.id': 1, 'offers.priceSpecification.price': 1 }, {
63
- name: 'searchByOffersIncludedInDataCatalogId',
61
+ schema.index({ 'offers.includedInDataCatalog.id': 1 }, {
62
+ name: 'searchByOffersIncludedInDataCatalogId-v2',
64
63
  partialFilterExpression: {
65
64
  'offers.includedInDataCatalog.id': { $exists: true }
66
65
  }
67
66
  });
68
- schema.index({ 'offers.availability': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersAvailability' });
69
- schema.index({ 'offers.itemOffered.typeOf': 1, 'offers.priceSpecification.price': 1 }, { name: 'searchByOffersItemOfferedTypeOf' });
70
- schema.index({ 'offers.identifier': 1, 'offers.priceSpecification.price': 1 }, {
71
- name: 'searchByOffersIdentifier',
67
+ schema.index({ 'project.id': 1 }, { name: 'searchByProjectId-v2' });
68
+ schema.index({ 'offers.availability': 1 }, { name: 'searchByOffersAvailability-v2' });
69
+ schema.index({ 'offers.itemOffered.typeOf': 1 }, { name: 'searchByOffersItemOfferedTypeOf-v2' });
70
+ schema.index({ 'offers.identifier': 1 }, {
71
+ name: 'searchByOffersIdentifier-v2',
72
72
  partialFilterExpression: {
73
73
  'offers.identifier': { $exists: true }
74
74
  }
75
75
  });
76
- schema.index({ 'offers.priceSpecification.referenceQuantity.value': 1, 'offers.priceSpecification.price': 1 }, {
77
- name: 'searchByOffersPriceSpecificationReferenceQuantityValue',
76
+ schema.index({ 'offers.priceSpecification.referenceQuantity.value': 1 }, {
77
+ name: 'searchByOffersPriceSpecificationReferenceQuantityValue-v2',
78
78
  partialFilterExpression: {
79
79
  'offers.priceSpecification.referenceQuantity.value': { $exists: true }
80
80
  }
81
81
  });
82
- schema.index({ 'offers.priceSpecification.accounting.accountsReceivable': 1, 'offers.priceSpecification.price': 1 }, {
83
- name: 'searchByOffersPriceSpecificationAccountingAccountsReceivable',
82
+ schema.index({ 'offers.priceSpecification.accounting.accountsReceivable': 1 }, {
83
+ name: 'searchByOffersPriceSpecificationAccountingAccountsReceivable-v2',
84
84
  partialFilterExpression: {
85
85
  'offers.priceSpecification.accounting.accountsReceivable': { $exists: true }
86
86
  }
87
87
  });
88
- schema.index({ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
89
- name: 'searchByOffersPriceSpecificationAccountingOperatingRevenueCodeValue',
88
+ schema.index({ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': 1 }, {
89
+ name: 'searchByOffersPriceSpecificationAccountingOperatingRevenueCodeValue-v2',
90
90
  partialFilterExpression: {
91
91
  'offers.priceSpecification.accounting.operatingRevenue.codeValue': { $exists: true }
92
92
  }
93
93
  });
94
- schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceType': 1, 'offers.priceSpecification.price': 1 }, {
95
- name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceType',
94
+ schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceType': 1 }, {
95
+ name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceType-v2',
96
96
  partialFilterExpression: {
97
97
  'offers.priceSpecification.appliesToMovieTicket.serviceType': { $exists: true }
98
98
  }
99
99
  });
100
- schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': 1, 'offers.priceSpecification.price': 1 }, {
101
- name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceOutputTypeOf',
100
+ schema.index({ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': 1 }, {
101
+ name: 'searchByOffersPriceSpecificationAppliesToMovieTicketServiceOutputTypeOf-v2',
102
102
  partialFilterExpression: {
103
103
  'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': { $exists: true }
104
104
  }
105
105
  });
106
- schema.index({ 'offers.name.ja': 1, 'offers.priceSpecification.price': 1 }, {
107
- name: 'searchByOffersNameJa',
106
+ schema.index({ 'offers.name.ja': 1 }, {
107
+ name: 'searchByOffersNameJa-v2',
108
108
  partialFilterExpression: {
109
109
  'offers.name.ja': { $exists: true }
110
110
  }
111
111
  });
112
- schema.index({ 'offers.name.en': 1, 'offers.priceSpecification.price': 1 }, {
113
- name: 'searchByOffersNameEn',
112
+ schema.index({ 'offers.name.en': 1 }, {
113
+ name: 'searchByOffersNameEn-v2',
114
114
  partialFilterExpression: {
115
115
  'offers.name.en': { $exists: true }
116
116
  }
117
117
  });
118
- schema.index({ 'offers.alternateName': 1, 'offers.priceSpecification.price': 1 }, {
119
- name: 'searchByOffersAlternateName',
118
+ schema.index({ 'offers.alternateName': 1 }, {
119
+ name: 'searchByOffersAlternateName-v2',
120
120
  partialFilterExpression: {
121
121
  'offers.alternateName': { $exists: true }
122
122
  }
123
123
  });
124
- schema.index({ 'offers.category.id': 1, 'offers.priceSpecification.price': 1 }, {
125
- name: 'searchOffersCategoryId',
124
+ schema.index({ 'offers.category.id': 1 }, {
125
+ name: 'searchOffersCategoryId-v2',
126
126
  partialFilterExpression: {
127
127
  'offers.category.id': { $exists: true }
128
128
  }
129
129
  });
130
- schema.index({ 'offers.category.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
131
- name: 'searchByOffersCategoryCodeValue',
130
+ schema.index({ 'offers.category.codeValue': 1 }, {
131
+ name: 'searchByOffersCategoryCodeValue-v2',
132
132
  partialFilterExpression: {
133
133
  'offers.category.codeValue': { $exists: true }
134
134
  }
135
135
  });
136
- schema.index({ 'offers.availableAtOrFrom.id': 1, 'offers.priceSpecification.price': 1 }, {
137
- name: 'searchByOffersAvailableAtOrFromId',
136
+ schema.index({ 'offers.availableAtOrFrom.id': 1 }, {
137
+ name: 'searchByOffersAvailableAtOrFromId-v2',
138
138
  partialFilterExpression: {
139
139
  'offers.availableAtOrFrom.id': { $exists: true }
140
140
  }
141
141
  });
142
- schema.index({ 'offers.eligibleMembershipType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
143
- name: 'searchByOffersEligibleMembershipTypeCodeValue',
142
+ schema.index({ 'offers.eligibleMembershipType.codeValue': 1 }, {
143
+ name: 'searchByOffersEligibleMembershipTypeCodeValue-v2',
144
144
  partialFilterExpression: {
145
145
  'offers.eligibleMembershipType.codeValue': { $exists: true }
146
146
  }
147
147
  });
148
- schema.index({ 'offers.eligibleMonetaryAmount.currency': 1, 'offers.priceSpecification.price': 1 }, {
149
- name: 'searchByOffersEligibleMonetaryAmountCurrency',
148
+ schema.index({ 'offers.eligibleMonetaryAmount.currency': 1 }, {
149
+ name: 'searchByOffersEligibleMonetaryAmountCurrency-v2',
150
150
  partialFilterExpression: {
151
151
  'offers.eligibleMonetaryAmount.currency': { $exists: true }
152
152
  }
153
153
  });
154
- schema.index({ 'offers.eligibleSeatingType.codeValue': 1, 'offers.priceSpecification.price': 1 }, {
155
- name: 'searchByOffersEligibleSeatingTypeCodeValue',
154
+ schema.index({ 'offers.eligibleSeatingType.codeValue': 1 }, {
155
+ name: 'searchByOffersEligibleSeatingTypeCodeValue-v2',
156
156
  partialFilterExpression: {
157
157
  'offers.eligibleSeatingType.codeValue': { $exists: true }
158
158
  }
159
159
  });
160
- schema.index({ 'offers.addOn.itemOffered.id': 1, 'offers.priceSpecification.price': 1 }, {
161
- name: 'searchByOffersAddOnItemOfferedId',
160
+ schema.index({ 'offers.addOn.itemOffered.id': 1 }, {
161
+ name: 'searchByOffersAddOnItemOfferedId-v2',
162
162
  partialFilterExpression: {
163
163
  'offers.addOn.itemOffered.id': { $exists: true }
164
164
  }
165
165
  });
166
- schema.index({ 'offers.hasMerchantReturnPolicy.id': 1, 'offers.priceSpecification.price': 1 }, {
167
- name: 'searchByOffersHasMerchantReturnPolicyId',
166
+ schema.index({ 'offers.hasMerchantReturnPolicy.id': 1 }, {
167
+ name: 'searchByOffersHasMerchantReturnPolicyId-v2',
168
168
  partialFilterExpression: {
169
169
  'offers.hasMerchantReturnPolicy.id': { $exists: true }
170
170
  }
171
171
  });
172
- schema.index({ 'offers.additionalProperty': 1, 'offers.priceSpecification.price': 1 }, {
173
- name: 'searchByOffersAdditionalProperty',
172
+ schema.index({ 'offers.additionalProperty': 1 }, {
173
+ name: 'searchByOffersAdditionalProperty-v2',
174
174
  partialFilterExpression: {
175
175
  'offers.additionalProperty': { $exists: true }
176
176
  }
177
177
  });
178
- schema.index({ 'offers.validFrom': 1, 'offers.priceSpecification.price': 1 }, {
179
- name: 'searchByOffersValidFrom',
178
+ schema.index({ 'offers.validFrom': 1 }, {
179
+ name: 'searchByOffersValidFrom-v2',
180
180
  partialFilterExpression: {
181
181
  'offers.validFrom': { $exists: true }
182
182
  }
183
183
  });
184
- schema.index({ 'offers.validThrough': 1, 'offers.priceSpecification.price': 1 }, {
185
- name: 'searchByOffersValidThrough',
184
+ schema.index({ 'offers.validThrough': 1 }, {
185
+ name: 'searchByOffersValidThrough-v2',
186
186
  partialFilterExpression: {
187
187
  'offers.validThrough': { $exists: true }
188
188
  }
@@ -119,6 +119,22 @@ export declare class MongoRepository {
119
119
  limit?: number;
120
120
  page?: number;
121
121
  }): Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
122
+ /**
123
+ * クライアントの利用可能カタログを検索する
124
+ */
125
+ searchAvailableCatalogs(params: {
126
+ project: {
127
+ id: string;
128
+ };
129
+ includedInDataCatalog: {
130
+ id: string[];
131
+ };
132
+ availableAtOrFrom: {
133
+ id: string;
134
+ };
135
+ }): Promise<{
136
+ id: string;
137
+ }[]>;
122
138
  count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
123
139
  search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<IUnitPriceOfferFromAggregateOffer[]>;
124
140
  save(params: factory.unitPriceOffer.IUnitPriceOffer & {