@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.
- package/example/src/chevre/searchOfferCatalogItemAvailability.ts +38 -0
- package/example/src/chevre/searchOfferCatalogItems.ts +41 -26
- package/example/src/chevre/searchOffers.ts +16 -4
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +45 -45
- package/lib/chevre/repo/offer.d.ts +16 -0
- package/lib/chevre/repo/offer.js +83 -44
- package/lib/chevre/repo/offerCatalog.d.ts +11 -0
- package/lib/chevre/repo/offerCatalog.js +28 -0
- package/lib/chevre/repo/offerCatalogItem.d.ts +6 -1
- package/lib/chevre/repo/offerCatalogItem.js +43 -23
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +51 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -1
- package/lib/chevre/service/offer/event.d.ts +2 -2
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +3 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +156 -118
- package/package.json +1 -1
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -39,7 +39,7 @@ class MongoRepository {
|
|
|
39
39
|
}
|
|
40
40
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
41
41
|
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
|
|
42
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40
|
|
42
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40;
|
|
43
43
|
const matchStages = [];
|
|
44
44
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
45
45
|
if (typeof projectIdEq === 'string') {
|
|
@@ -51,34 +51,38 @@ class MongoRepository {
|
|
|
51
51
|
if (Array.isArray(parentOfferIdIn)) {
|
|
52
52
|
matchStages.push({ $match: { _id: { $in: parentOfferIdIn } } });
|
|
53
53
|
}
|
|
54
|
+
// aggregateOffer.includedInDataCatalogで検索する(2023-09-21~)
|
|
54
55
|
const includedInDataCatalogIdIn = (_f = (_e = params.includedInDataCatalog) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
56
|
+
// if (Array.isArray(includedInDataCatalogIdIn)) {
|
|
57
|
+
// matchStages.push({ $match: { 'offers.includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
|
|
58
|
+
// }
|
|
55
59
|
if (Array.isArray(includedInDataCatalogIdIn)) {
|
|
56
|
-
matchStages.push({ $match: { '
|
|
57
|
-
}
|
|
58
|
-
const includedInOfferCatalogItemIncludedInDataCatalogIdIn =
|
|
59
|
-
if (Array.isArray(includedInOfferCatalogItemIncludedInDataCatalogIdIn)) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
const idEq = (
|
|
60
|
+
matchStages.push({ $match: { 'includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
|
|
61
|
+
}
|
|
62
|
+
// const includedInOfferCatalogItemIncludedInDataCatalogIdIn = params.includedInOfferCatalogItem?.includedInDataCatalog?.id?.$in;
|
|
63
|
+
// if (Array.isArray(includedInOfferCatalogItemIncludedInDataCatalogIdIn)) {
|
|
64
|
+
// matchStages.push({
|
|
65
|
+
// $match: {
|
|
66
|
+
// 'offers.includedInOfferCatalogItem.includedInDataCatalog.id': {
|
|
67
|
+
// $exists: true,
|
|
68
|
+
// $in: includedInOfferCatalogItemIncludedInDataCatalogIdIn
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
// });
|
|
72
|
+
// }
|
|
73
|
+
const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
70
74
|
if (typeof idEq === 'string') {
|
|
71
75
|
matchStages.push({
|
|
72
76
|
$match: { 'offers.id': { $eq: idEq } }
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
|
-
const idIn = (
|
|
79
|
+
const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
|
|
76
80
|
if (Array.isArray(idIn)) {
|
|
77
81
|
matchStages.push({
|
|
78
82
|
$match: { 'offers.id': { $in: idIn } }
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
|
-
const identifierEq = (
|
|
85
|
+
const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
82
86
|
if (typeof identifierEq === 'string') {
|
|
83
87
|
matchStages.push({
|
|
84
88
|
$match: {
|
|
@@ -86,7 +90,7 @@ class MongoRepository {
|
|
|
86
90
|
}
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
|
-
const identifierIn = (
|
|
93
|
+
const identifierIn = (_k = params.identifier) === null || _k === void 0 ? void 0 : _k.$in;
|
|
90
94
|
if (Array.isArray(identifierIn)) {
|
|
91
95
|
matchStages.push({
|
|
92
96
|
$match: {
|
|
@@ -94,7 +98,7 @@ class MongoRepository {
|
|
|
94
98
|
}
|
|
95
99
|
});
|
|
96
100
|
}
|
|
97
|
-
const identifierRegex = (
|
|
101
|
+
const identifierRegex = (_l = params.identifier) === null || _l === void 0 ? void 0 : _l.$regex;
|
|
98
102
|
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
99
103
|
matchStages.push({
|
|
100
104
|
$match: {
|
|
@@ -102,7 +106,7 @@ class MongoRepository {
|
|
|
102
106
|
}
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
|
-
const nameRegex = (
|
|
109
|
+
const nameRegex = (_m = params.name) === null || _m === void 0 ? void 0 : _m.$regex;
|
|
106
110
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
107
111
|
const nameRegexExp = new RegExp(nameRegex);
|
|
108
112
|
matchStages.push({
|
|
@@ -116,7 +120,7 @@ class MongoRepository {
|
|
|
116
120
|
}
|
|
117
121
|
});
|
|
118
122
|
}
|
|
119
|
-
const itemOfferedTypeOfEq = (
|
|
123
|
+
const itemOfferedTypeOfEq = (_p = (_o = params.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
120
124
|
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
121
125
|
matchStages.push({
|
|
122
126
|
$match: {
|
|
@@ -124,7 +128,7 @@ class MongoRepository {
|
|
|
124
128
|
}
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
|
-
const categoryCodeValueIn = (
|
|
131
|
+
const categoryCodeValueIn = (_r = (_q = params.category) === null || _q === void 0 ? void 0 : _q.codeValue) === null || _r === void 0 ? void 0 : _r.$in;
|
|
128
132
|
if (Array.isArray(categoryCodeValueIn)) {
|
|
129
133
|
matchStages.push({
|
|
130
134
|
$match: {
|
|
@@ -132,7 +136,7 @@ class MongoRepository {
|
|
|
132
136
|
}
|
|
133
137
|
});
|
|
134
138
|
}
|
|
135
|
-
const eligibleMembershipTypeCodeValueEq = (
|
|
139
|
+
const eligibleMembershipTypeCodeValueEq = (_t = (_s = params.eligibleMembershipType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
136
140
|
if (typeof eligibleMembershipTypeCodeValueEq === 'string') {
|
|
137
141
|
matchStages.push({
|
|
138
142
|
$match: {
|
|
@@ -143,7 +147,7 @@ class MongoRepository {
|
|
|
143
147
|
}
|
|
144
148
|
});
|
|
145
149
|
}
|
|
146
|
-
const eligibleMonetaryAmountCurrencyEq = (
|
|
150
|
+
const eligibleMonetaryAmountCurrencyEq = (_v = (_u = params.eligibleMonetaryAmount) === null || _u === void 0 ? void 0 : _u.currency) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
147
151
|
if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
|
|
148
152
|
matchStages.push({
|
|
149
153
|
$match: {
|
|
@@ -154,7 +158,7 @@ class MongoRepository {
|
|
|
154
158
|
}
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
|
-
const eligibleSeatingTypeCodeValueEq = (
|
|
161
|
+
const eligibleSeatingTypeCodeValueEq = (_x = (_w = params.eligibleSeatingType) === null || _w === void 0 ? void 0 : _w.codeValue) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
158
162
|
if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
|
|
159
163
|
matchStages.push({
|
|
160
164
|
$match: {
|
|
@@ -165,7 +169,7 @@ class MongoRepository {
|
|
|
165
169
|
}
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
|
-
const appliesToMovieTicketServiceTypeExist = (
|
|
172
|
+
const appliesToMovieTicketServiceTypeExist = (_0 = (_z = (_y = params.priceSpecification) === null || _y === void 0 ? void 0 : _y.appliesToMovieTicket) === null || _z === void 0 ? void 0 : _z.serviceType) === null || _0 === void 0 ? void 0 : _0.$exists;
|
|
169
173
|
if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
|
|
170
174
|
matchStages.push({
|
|
171
175
|
$match: {
|
|
@@ -175,7 +179,7 @@ class MongoRepository {
|
|
|
175
179
|
}
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
|
-
const appliesToMovieTicketServiceTypeEq = (
|
|
182
|
+
const appliesToMovieTicketServiceTypeEq = (_3 = (_2 = (_1 = params.priceSpecification) === null || _1 === void 0 ? void 0 : _1.appliesToMovieTicket) === null || _2 === void 0 ? void 0 : _2.serviceType) === null || _3 === void 0 ? void 0 : _3.$eq;
|
|
179
183
|
if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
|
|
180
184
|
matchStages.push({
|
|
181
185
|
$match: {
|
|
@@ -186,7 +190,7 @@ class MongoRepository {
|
|
|
186
190
|
}
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
|
-
const appliesToMovieTicketServiceOutputTypeOfEq = (
|
|
193
|
+
const appliesToMovieTicketServiceOutputTypeOfEq = (_7 = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.typeOf) === null || _7 === void 0 ? void 0 : _7.$eq;
|
|
190
194
|
if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
|
|
191
195
|
matchStages.push({
|
|
192
196
|
$match: {
|
|
@@ -197,7 +201,7 @@ class MongoRepository {
|
|
|
197
201
|
}
|
|
198
202
|
});
|
|
199
203
|
}
|
|
200
|
-
const appliesToMovieTicketServiceOutputTypeOfNin = (
|
|
204
|
+
const appliesToMovieTicketServiceOutputTypeOfNin = (_11 = (_10 = (_9 = (_8 = params.priceSpecification) === null || _8 === void 0 ? void 0 : _8.appliesToMovieTicket) === null || _9 === void 0 ? void 0 : _9.serviceOutput) === null || _10 === void 0 ? void 0 : _10.typeOf) === null || _11 === void 0 ? void 0 : _11.$nin;
|
|
201
205
|
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
|
|
202
206
|
matchStages.push({
|
|
203
207
|
$match: {
|
|
@@ -208,7 +212,7 @@ class MongoRepository {
|
|
|
208
212
|
});
|
|
209
213
|
}
|
|
210
214
|
if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
|
|
211
|
-
const priceSpecificationPriceGte = (
|
|
215
|
+
const priceSpecificationPriceGte = (_12 = params.priceSpecification.price) === null || _12 === void 0 ? void 0 : _12.$gte;
|
|
212
216
|
if (typeof priceSpecificationPriceGte === 'number') {
|
|
213
217
|
matchStages.push({
|
|
214
218
|
$match: {
|
|
@@ -219,7 +223,7 @@ class MongoRepository {
|
|
|
219
223
|
}
|
|
220
224
|
});
|
|
221
225
|
}
|
|
222
|
-
const priceSpecificationPriceLte = (
|
|
226
|
+
const priceSpecificationPriceLte = (_13 = params.priceSpecification.price) === null || _13 === void 0 ? void 0 : _13.$lte;
|
|
223
227
|
if (typeof priceSpecificationPriceLte === 'number') {
|
|
224
228
|
matchStages.push({
|
|
225
229
|
$match: {
|
|
@@ -230,7 +234,7 @@ class MongoRepository {
|
|
|
230
234
|
}
|
|
231
235
|
});
|
|
232
236
|
}
|
|
233
|
-
const accountsReceivableGte = (
|
|
237
|
+
const accountsReceivableGte = (_15 = (_14 = params.priceSpecification.accounting) === null || _14 === void 0 ? void 0 : _14.accountsReceivable) === null || _15 === void 0 ? void 0 : _15.$gte;
|
|
234
238
|
if (typeof accountsReceivableGte === 'number') {
|
|
235
239
|
matchStages.push({
|
|
236
240
|
$match: {
|
|
@@ -241,7 +245,7 @@ class MongoRepository {
|
|
|
241
245
|
}
|
|
242
246
|
});
|
|
243
247
|
}
|
|
244
|
-
const accountsReceivableLte = (
|
|
248
|
+
const accountsReceivableLte = (_17 = (_16 = params.priceSpecification.accounting) === null || _16 === void 0 ? void 0 : _16.accountsReceivable) === null || _17 === void 0 ? void 0 : _17.$lte;
|
|
245
249
|
if (typeof accountsReceivableLte === 'number') {
|
|
246
250
|
matchStages.push({
|
|
247
251
|
$match: {
|
|
@@ -252,7 +256,7 @@ class MongoRepository {
|
|
|
252
256
|
}
|
|
253
257
|
});
|
|
254
258
|
}
|
|
255
|
-
const accountingCodeValueEq = (
|
|
259
|
+
const accountingCodeValueEq = (_20 = (_19 = (_18 = params.priceSpecification.accounting) === null || _18 === void 0 ? void 0 : _18.operatingRevenue) === null || _19 === void 0 ? void 0 : _19.codeValue) === null || _20 === void 0 ? void 0 : _20.$eq;
|
|
256
260
|
if (typeof accountingCodeValueEq === 'string') {
|
|
257
261
|
matchStages.push({
|
|
258
262
|
$match: {
|
|
@@ -263,7 +267,7 @@ class MongoRepository {
|
|
|
263
267
|
}
|
|
264
268
|
});
|
|
265
269
|
}
|
|
266
|
-
const accountingCodeValueIn = (
|
|
270
|
+
const accountingCodeValueIn = (_23 = (_22 = (_21 = params.priceSpecification.accounting) === null || _21 === void 0 ? void 0 : _21.operatingRevenue) === null || _22 === void 0 ? void 0 : _22.codeValue) === null || _23 === void 0 ? void 0 : _23.$in;
|
|
267
271
|
if (Array.isArray(accountingCodeValueIn)) {
|
|
268
272
|
matchStages.push({
|
|
269
273
|
$match: {
|
|
@@ -274,7 +278,7 @@ class MongoRepository {
|
|
|
274
278
|
}
|
|
275
279
|
});
|
|
276
280
|
}
|
|
277
|
-
const referenceQuantityValueEq = (
|
|
281
|
+
const referenceQuantityValueEq = (_25 = (_24 = params.priceSpecification.referenceQuantity) === null || _24 === void 0 ? void 0 : _24.value) === null || _25 === void 0 ? void 0 : _25.$eq;
|
|
278
282
|
if (typeof referenceQuantityValueEq === 'number') {
|
|
279
283
|
matchStages.push({
|
|
280
284
|
$match: {
|
|
@@ -286,7 +290,7 @@ class MongoRepository {
|
|
|
286
290
|
});
|
|
287
291
|
}
|
|
288
292
|
}
|
|
289
|
-
const availabilityEq = (
|
|
293
|
+
const availabilityEq = (_26 = params.availability) === null || _26 === void 0 ? void 0 : _26.$eq;
|
|
290
294
|
if (typeof availabilityEq === 'string') {
|
|
291
295
|
matchStages.push({
|
|
292
296
|
$match: {
|
|
@@ -294,7 +298,7 @@ class MongoRepository {
|
|
|
294
298
|
}
|
|
295
299
|
});
|
|
296
300
|
}
|
|
297
|
-
const availableAtOrFromIdEq = (
|
|
301
|
+
const availableAtOrFromIdEq = (_28 = (_27 = params.availableAtOrFrom) === null || _27 === void 0 ? void 0 : _27.id) === null || _28 === void 0 ? void 0 : _28.$eq;
|
|
298
302
|
if (typeof availableAtOrFromIdEq === 'string') {
|
|
299
303
|
matchStages.push({
|
|
300
304
|
$match: {
|
|
@@ -305,7 +309,7 @@ class MongoRepository {
|
|
|
305
309
|
}
|
|
306
310
|
});
|
|
307
311
|
}
|
|
308
|
-
const availableAtOrFromIdIn = (
|
|
312
|
+
const availableAtOrFromIdIn = (_30 = (_29 = params.availableAtOrFrom) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$in;
|
|
309
313
|
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
310
314
|
matchStages.push({
|
|
311
315
|
$match: {
|
|
@@ -316,7 +320,7 @@ class MongoRepository {
|
|
|
316
320
|
}
|
|
317
321
|
});
|
|
318
322
|
}
|
|
319
|
-
const addOnItemOfferedIdEq = (
|
|
323
|
+
const addOnItemOfferedIdEq = (_33 = (_32 = (_31 = params.addOn) === null || _31 === void 0 ? void 0 : _31.itemOffered) === null || _32 === void 0 ? void 0 : _32.id) === null || _33 === void 0 ? void 0 : _33.$eq;
|
|
320
324
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
321
325
|
matchStages.push({
|
|
322
326
|
$match: {
|
|
@@ -324,7 +328,7 @@ class MongoRepository {
|
|
|
324
328
|
}
|
|
325
329
|
});
|
|
326
330
|
}
|
|
327
|
-
const addOnItemOfferedIdIn = (
|
|
331
|
+
const addOnItemOfferedIdIn = (_36 = (_35 = (_34 = params.addOn) === null || _34 === void 0 ? void 0 : _34.itemOffered) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
|
|
328
332
|
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
329
333
|
matchStages.push({
|
|
330
334
|
$match: {
|
|
@@ -332,7 +336,7 @@ class MongoRepository {
|
|
|
332
336
|
}
|
|
333
337
|
});
|
|
334
338
|
}
|
|
335
|
-
const hasMerchantReturnPolicyIdEq = (
|
|
339
|
+
const hasMerchantReturnPolicyIdEq = (_38 = (_37 = params.hasMerchantReturnPolicy) === null || _37 === void 0 ? void 0 : _37.id) === null || _38 === void 0 ? void 0 : _38.$eq;
|
|
336
340
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
337
341
|
matchStages.push({
|
|
338
342
|
$match: {
|
|
@@ -343,7 +347,7 @@ class MongoRepository {
|
|
|
343
347
|
}
|
|
344
348
|
});
|
|
345
349
|
}
|
|
346
|
-
const additionalPropertyAll = (
|
|
350
|
+
const additionalPropertyAll = (_39 = params.additionalProperty) === null || _39 === void 0 ? void 0 : _39.$all;
|
|
347
351
|
if (Array.isArray(additionalPropertyAll)) {
|
|
348
352
|
matchStages.push({
|
|
349
353
|
$match: {
|
|
@@ -354,7 +358,7 @@ class MongoRepository {
|
|
|
354
358
|
}
|
|
355
359
|
});
|
|
356
360
|
}
|
|
357
|
-
const additionalPropertyElemMatch = (
|
|
361
|
+
const additionalPropertyElemMatch = (_40 = params.additionalProperty) === null || _40 === void 0 ? void 0 : _40.$elemMatch;
|
|
358
362
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
359
363
|
matchStages.push({
|
|
360
364
|
$match: {
|
|
@@ -600,6 +604,41 @@ class MongoRepository {
|
|
|
600
604
|
return aggregate.exec();
|
|
601
605
|
});
|
|
602
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* クライアントの利用可能カタログを検索する
|
|
609
|
+
*/
|
|
610
|
+
searchAvailableCatalogs(params) {
|
|
611
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
612
|
+
const aggregate = this.aggregateOfferModel.aggregate([
|
|
613
|
+
{ $unwind: { path: '$offers' } },
|
|
614
|
+
// { $unwind: { path: '$offers.includedInDataCatalog' } },
|
|
615
|
+
{ $unwind: { path: '$includedInDataCatalog' } },
|
|
616
|
+
{
|
|
617
|
+
$match: {
|
|
618
|
+
'project.id': { $eq: params.project.id },
|
|
619
|
+
// 'offers.includedInDataCatalog.id': { $exists: true, $in: params.includedInDataCatalog.id },
|
|
620
|
+
'includedInDataCatalog.id': { $exists: true, $in: params.includedInDataCatalog.id },
|
|
621
|
+
'offers.availableAtOrFrom.id': { $exists: true, $eq: params.availableAtOrFrom.id }
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
$group: {
|
|
626
|
+
// _id: '$offers.includedInDataCatalog.id',
|
|
627
|
+
// includedInDataCatalog: { $first: '$offers.includedInDataCatalog' }
|
|
628
|
+
_id: '$includedInDataCatalog.id'
|
|
629
|
+
// includedInDataCatalog: { $first: '$includedInDataCatalog' }
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
$project: {
|
|
634
|
+
_id: 0,
|
|
635
|
+
id: '$_id'
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
]);
|
|
639
|
+
return aggregate.exec();
|
|
640
|
+
});
|
|
641
|
+
}
|
|
603
642
|
// public async findAggregateOfferById(params: {
|
|
604
643
|
// project: { id: string };
|
|
605
644
|
// id: string;
|
|
@@ -94,6 +94,17 @@ export declare class MongoRepository {
|
|
|
94
94
|
findFirstItemListElementById(params: {
|
|
95
95
|
id: string;
|
|
96
96
|
}): Promise<factory.offerCatalog.IItemListElement>;
|
|
97
|
+
/**
|
|
98
|
+
* カタログのitemListElementをpaging有で検索する
|
|
99
|
+
*/
|
|
100
|
+
searchItemListElementById(params: {
|
|
101
|
+
id: string;
|
|
102
|
+
limit: number;
|
|
103
|
+
page: number;
|
|
104
|
+
}): Promise<{
|
|
105
|
+
id: string;
|
|
106
|
+
elementIndex: number;
|
|
107
|
+
}[]>;
|
|
97
108
|
deleteById(params: {
|
|
98
109
|
id: string;
|
|
99
110
|
}): Promise<void>;
|
|
@@ -319,6 +319,34 @@ class MongoRepository {
|
|
|
319
319
|
return firstElement;
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* カタログのitemListElementをpaging有で検索する
|
|
324
|
+
*/
|
|
325
|
+
searchItemListElementById(params) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
328
|
+
const matchStages = [{ $match: { _id: { $eq: params.id } } }];
|
|
329
|
+
return this.offerCatalogModel.aggregate([
|
|
330
|
+
{
|
|
331
|
+
$unwind: {
|
|
332
|
+
path: '$itemListElement',
|
|
333
|
+
includeArrayIndex: 'elementIndex'
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
...matchStages,
|
|
337
|
+
{
|
|
338
|
+
$project: {
|
|
339
|
+
_id: 0,
|
|
340
|
+
id: '$itemListElement.id',
|
|
341
|
+
elementIndex: '$elementIndex'
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
])
|
|
345
|
+
.limit(params.limit * page)
|
|
346
|
+
.skip(params.limit * (page - 1))
|
|
347
|
+
.exec();
|
|
348
|
+
});
|
|
349
|
+
}
|
|
322
350
|
deleteById(params) {
|
|
323
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
324
352
|
yield this.offerCatalogModel.findOneAndRemove({
|
|
@@ -4,6 +4,10 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
4
4
|
numberOfItems?: number;
|
|
5
5
|
itemListElementTypeOf: factory.offerType.Offer;
|
|
6
6
|
};
|
|
7
|
+
type KeyOfOfferCatalogItem = keyof factory.offerCatalog.IOfferCatalog;
|
|
8
|
+
type IProjection = {
|
|
9
|
+
[key in KeyOfOfferCatalogItem]?: 0 | 1;
|
|
10
|
+
};
|
|
7
11
|
/**
|
|
8
12
|
* オファーカタログアイテムリポジトリ
|
|
9
13
|
*/
|
|
@@ -20,7 +24,7 @@ export declare class MongoRepository {
|
|
|
20
24
|
dateSynced: Date;
|
|
21
25
|
}): Promise<void>;
|
|
22
26
|
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
23
|
-
search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
|
|
27
|
+
search(params: factory.offerCatalog.ISearchConditions, projection: IProjection): Promise<IAggregatedOfferCatalog[]>;
|
|
24
28
|
findItemListElementById(params: {
|
|
25
29
|
id: string;
|
|
26
30
|
project: {
|
|
@@ -45,3 +49,4 @@ export declare class MongoRepository {
|
|
|
45
49
|
};
|
|
46
50
|
}): Promise<import("mongodb").UpdateResult | undefined>;
|
|
47
51
|
}
|
|
52
|
+
export {};
|
|
@@ -146,38 +146,58 @@ class MongoRepository {
|
|
|
146
146
|
return (result.length > 0) ? result[0].numItems : 0;
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
search(params) {
|
|
149
|
+
search(params, projection) {
|
|
150
150
|
var _a;
|
|
151
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
152
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
153
153
|
const matchStages = conditions.map((condition) => {
|
|
154
154
|
return { $match: condition };
|
|
155
155
|
});
|
|
156
|
+
let projectStage = {
|
|
157
|
+
_id: 0,
|
|
158
|
+
name: '$name',
|
|
159
|
+
description: '$description',
|
|
160
|
+
project: '$project',
|
|
161
|
+
typeOf: '$typeOf',
|
|
162
|
+
id: { $toString: '$_id' },
|
|
163
|
+
identifier: '$identifier',
|
|
164
|
+
itemOffered: '$itemOffered',
|
|
165
|
+
additionalProperty: '$additionalProperty',
|
|
166
|
+
relatedOffer: '$relatedOffer',
|
|
167
|
+
numberOfItems: {
|
|
168
|
+
$cond: {
|
|
169
|
+
if: { $isArray: '$itemListElement' },
|
|
170
|
+
then: { $size: '$itemListElement' },
|
|
171
|
+
else: 0
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
itemListElementTypeOf: { $first: '$itemListElement.typeOf' }
|
|
175
|
+
};
|
|
176
|
+
const positiveProjectionFields = Object.keys(projection)
|
|
177
|
+
.filter((key) => projection[key] !== 0 && key !== 'id');
|
|
178
|
+
const negativeProjectionFields = Object.keys(projection)
|
|
179
|
+
.filter((key) => projection[key] === 0);
|
|
180
|
+
if (positiveProjectionFields.length > 0) {
|
|
181
|
+
projectStage = {
|
|
182
|
+
_id: 0,
|
|
183
|
+
id: { $toString: '$_id' }
|
|
184
|
+
};
|
|
185
|
+
positiveProjectionFields.forEach((field) => {
|
|
186
|
+
projectStage[field] = `$${field}`;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
else if (negativeProjectionFields.length > 0) {
|
|
190
|
+
negativeProjectionFields.forEach((field) => {
|
|
191
|
+
if (typeof projectStage[field] === 'string') {
|
|
192
|
+
// tslint:disable-next-line:no-dynamic-delete
|
|
193
|
+
delete projectStage[field];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
156
197
|
const aggregate = this.offerCatalogItemModel.aggregate([
|
|
157
198
|
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
|
|
158
199
|
...matchStages,
|
|
159
|
-
{
|
|
160
|
-
$project: {
|
|
161
|
-
_id: 0,
|
|
162
|
-
name: '$name',
|
|
163
|
-
description: '$description',
|
|
164
|
-
project: '$project',
|
|
165
|
-
typeOf: '$typeOf',
|
|
166
|
-
id: { $toString: '$_id' },
|
|
167
|
-
identifier: '$identifier',
|
|
168
|
-
itemOffered: '$itemOffered',
|
|
169
|
-
additionalProperty: '$additionalProperty',
|
|
170
|
-
relatedOffer: '$relatedOffer',
|
|
171
|
-
numberOfItems: {
|
|
172
|
-
$cond: {
|
|
173
|
-
if: { $isArray: '$itemListElement' },
|
|
174
|
-
then: { $size: '$itemListElement' },
|
|
175
|
-
else: 0
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
itemListElementTypeOf: { $first: '$itemListElement.typeOf' }
|
|
179
|
-
}
|
|
180
|
-
}
|
|
200
|
+
{ $project: projectStage }
|
|
181
201
|
]);
|
|
182
202
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
183
203
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
2
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
3
3
|
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
4
|
+
import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
4
5
|
import { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
5
6
|
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
6
7
|
import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
@@ -77,4 +78,53 @@ declare function searchOfferAppliesToMovieTicket(params: {
|
|
|
77
78
|
offerCatalog: OfferCatalogRepo;
|
|
78
79
|
product: ProductRepo;
|
|
79
80
|
}) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
|
|
80
|
-
|
|
81
|
+
type ISearchOfferCatalogItemResult = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'additionalProperty' | 'relatedOffer'> & {
|
|
82
|
+
elementIndex: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* サブカタログ検索
|
|
86
|
+
*/
|
|
87
|
+
declare function searchOfferCatalogItems(params: {
|
|
88
|
+
event: {
|
|
89
|
+
/**
|
|
90
|
+
* イベントID
|
|
91
|
+
*/
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
limit: number;
|
|
95
|
+
page: number;
|
|
96
|
+
}): (repos: {
|
|
97
|
+
event: EventRepo;
|
|
98
|
+
offerCatalog: OfferCatalogRepo;
|
|
99
|
+
offerCatalogItem: OfferCatalogItemRepo;
|
|
100
|
+
product: ProductRepo;
|
|
101
|
+
}) => Promise<ISearchOfferCatalogItemResult[]>;
|
|
102
|
+
interface ISearchOfferCatalogItemAvailabilityResult {
|
|
103
|
+
id: string;
|
|
104
|
+
isAvailable: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* サブカタログ利用可能性検索
|
|
108
|
+
*/
|
|
109
|
+
declare function searchOfferCatalogItemAvailability(params: {
|
|
110
|
+
event: {
|
|
111
|
+
/**
|
|
112
|
+
* イベントID
|
|
113
|
+
*/
|
|
114
|
+
id: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* どのアプリケーションに対して
|
|
118
|
+
*/
|
|
119
|
+
availableAtOrFrom: {
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
limit: number;
|
|
123
|
+
page: number;
|
|
124
|
+
}): (repos: {
|
|
125
|
+
event: EventRepo;
|
|
126
|
+
offer: OfferRepo;
|
|
127
|
+
offerCatalog: OfferCatalogRepo;
|
|
128
|
+
product: ProductRepo;
|
|
129
|
+
}) => Promise<ISearchOfferCatalogItemAvailabilityResult[]>;
|
|
130
|
+
export { searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItems, searchOfferCatalogItemAvailability };
|