@chevre/domain 20.0.0-alpha.4 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
8
|
+
|
|
9
|
+
const client = redis.createClient({
|
|
10
|
+
host: process.env.REDIS_HOST,
|
|
11
|
+
port: Number(process.env.REDIS_PORT),
|
|
12
|
+
password: process.env.REDIS_KEY
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
17
|
+
|
|
18
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
19
|
+
const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
20
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
21
|
+
const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
|
|
22
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
23
|
+
|
|
24
|
+
const offers = await chevre.service.offer.event.searchEventTicketOffers({
|
|
25
|
+
event: { id: 'al9ew43f5' },
|
|
26
|
+
onlyValid: true
|
|
27
|
+
// ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
|
|
28
|
+
// ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
|
|
29
|
+
})({
|
|
30
|
+
event: eventRepo,
|
|
31
|
+
offer: offerRepo,
|
|
32
|
+
offerRateLimit: offerRateLimitRepo,
|
|
33
|
+
priceSpecification: priceSpecificationRepo,
|
|
34
|
+
product: productRepo
|
|
35
|
+
});
|
|
36
|
+
// console.log(offers);
|
|
37
|
+
console.log(offers.length);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
main()
|
|
41
|
+
.then(console.log)
|
|
42
|
+
.catch(console.error);
|
|
@@ -10,8 +10,12 @@ export declare class MongoRepository {
|
|
|
10
10
|
static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): any[];
|
|
11
11
|
findById(conditions: {
|
|
12
12
|
id: string;
|
|
13
|
-
}, projection?:
|
|
14
|
-
|
|
13
|
+
}, projection?: {
|
|
14
|
+
[key: string]: number;
|
|
15
|
+
}): Promise<IProduct>;
|
|
16
|
+
search(conditions: factory.product.ISearchConditions, projection?: {
|
|
17
|
+
[key: string]: number;
|
|
18
|
+
}): Promise<IProduct[]>;
|
|
15
19
|
deleteById(params: {
|
|
16
20
|
id: string;
|
|
17
21
|
}): Promise<void>;
|
|
@@ -32,31 +32,25 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
36
36
|
// MongoDB検索条件
|
|
37
37
|
const andConditions = [];
|
|
38
38
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
39
|
if (typeof projectIdEq === 'string') {
|
|
40
40
|
andConditions.push({
|
|
41
|
-
'project.id': {
|
|
42
|
-
$eq: projectIdEq
|
|
43
|
-
}
|
|
41
|
+
'project.id': { $eq: projectIdEq }
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
44
|
const typeOfEq = (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
47
45
|
if (typeof typeOfEq === 'string') {
|
|
48
46
|
andConditions.push({
|
|
49
|
-
typeOf: {
|
|
50
|
-
$eq: typeOfEq
|
|
51
|
-
}
|
|
47
|
+
typeOf: { $eq: typeOfEq }
|
|
52
48
|
});
|
|
53
49
|
}
|
|
54
50
|
const typeOfIn = (_d = params.typeOf) === null || _d === void 0 ? void 0 : _d.$in;
|
|
55
51
|
if (Array.isArray(typeOfIn)) {
|
|
56
52
|
andConditions.push({
|
|
57
|
-
typeOf: {
|
|
58
|
-
$in: typeOfIn
|
|
59
|
-
}
|
|
53
|
+
typeOf: { $in: typeOfIn }
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
56
|
const hasOfferCatalogIdEq = (_f = (_e = params.hasOfferCatalog) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
@@ -79,38 +73,22 @@ class MongoRepository {
|
|
|
79
73
|
const productIDEq = (_j = params.productID) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
80
74
|
if (typeof productIDEq === 'string') {
|
|
81
75
|
andConditions.push({
|
|
82
|
-
productID: {
|
|
83
|
-
$eq: productIDEq
|
|
84
|
-
}
|
|
76
|
+
productID: { $eq: productIDEq }
|
|
85
77
|
});
|
|
86
78
|
}
|
|
87
79
|
const productIDIn = (_k = params.productID) === null || _k === void 0 ? void 0 : _k.$in;
|
|
88
80
|
if (Array.isArray(productIDIn)) {
|
|
89
81
|
andConditions.push({
|
|
90
|
-
productID: {
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
productID: { $in: productIDIn }
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const productIDRegex = (_l = params.productID) === null || _l === void 0 ? void 0 : _l.$regex;
|
|
86
|
+
if (typeof productIDRegex === 'string' && productIDRegex.length > 0) {
|
|
87
|
+
andConditions.push({
|
|
88
|
+
productID: { $regex: new RegExp(productIDRegex) }
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
|
-
|
|
96
|
-
// if (offersValidFromGte instanceof Date) {
|
|
97
|
-
// andConditions.push({
|
|
98
|
-
// 'offers.validFrom': {
|
|
99
|
-
// $exists: true,
|
|
100
|
-
// $gte: offersValidFromGte
|
|
101
|
-
// }
|
|
102
|
-
// });
|
|
103
|
-
// }
|
|
104
|
-
// const offersSellerIdIn = params.offers?.seller?.id?.$in;
|
|
105
|
-
// if (Array.isArray(offersSellerIdIn)) {
|
|
106
|
-
// andConditions.push({
|
|
107
|
-
// 'offers.seller.id': {
|
|
108
|
-
// $exists: true,
|
|
109
|
-
// $in: offersSellerIdIn
|
|
110
|
-
// }
|
|
111
|
-
// });
|
|
112
|
-
// }
|
|
113
|
-
const offersElemMatch = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
91
|
+
const offersElemMatch = (_m = params.offers) === null || _m === void 0 ? void 0 : _m.$elemMatch;
|
|
114
92
|
if (offersElemMatch !== undefined && offersElemMatch !== null) {
|
|
115
93
|
andConditions.push({
|
|
116
94
|
offers: {
|
|
@@ -118,7 +96,7 @@ class MongoRepository {
|
|
|
118
96
|
}
|
|
119
97
|
});
|
|
120
98
|
}
|
|
121
|
-
const serviceOutputTypeOfEq = (
|
|
99
|
+
const serviceOutputTypeOfEq = (_p = (_o = params.serviceOutput) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
122
100
|
if (typeof serviceOutputTypeOfEq === 'string') {
|
|
123
101
|
andConditions.push({
|
|
124
102
|
'serviceOutput.typeOf': {
|
|
@@ -127,7 +105,7 @@ class MongoRepository {
|
|
|
127
105
|
}
|
|
128
106
|
});
|
|
129
107
|
}
|
|
130
|
-
const serviceOutputAmountCurrencyEq = (
|
|
108
|
+
const serviceOutputAmountCurrencyEq = (_s = (_r = (_q = params.serviceOutput) === null || _q === void 0 ? void 0 : _q.amount) === null || _r === void 0 ? void 0 : _r.currency) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
131
109
|
if (typeof serviceOutputAmountCurrencyEq === 'string') {
|
|
132
110
|
andConditions.push({
|
|
133
111
|
'serviceOutput.amount.currency': {
|
|
@@ -136,7 +114,7 @@ class MongoRepository {
|
|
|
136
114
|
}
|
|
137
115
|
});
|
|
138
116
|
}
|
|
139
|
-
const serviceTypeCodeValueEq = (
|
|
117
|
+
const serviceTypeCodeValueEq = (_u = (_t = params.serviceType) === null || _t === void 0 ? void 0 : _t.codeValue) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
140
118
|
if (typeof serviceTypeCodeValueEq === 'string') {
|
|
141
119
|
andConditions.push({
|
|
142
120
|
'serviceType.codeValue': {
|
|
@@ -145,7 +123,7 @@ class MongoRepository {
|
|
|
145
123
|
}
|
|
146
124
|
});
|
|
147
125
|
}
|
|
148
|
-
const nameRegex = (
|
|
126
|
+
const nameRegex = (_v = params.name) === null || _v === void 0 ? void 0 : _v.$regex;
|
|
149
127
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
150
128
|
const nameRegexExp = new RegExp(nameRegex);
|
|
151
129
|
andConditions.push({
|
|
@@ -30,7 +30,7 @@ function createCompoundPriceSpec4event(params) {
|
|
|
30
30
|
const unitPriceSpec = Object.assign(Object.assign({}, params.offer.priceSpecification), { name: params.offer.name });
|
|
31
31
|
const videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
|
|
32
32
|
const soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
|
|
33
|
-
|
|
33
|
+
const mvtkPriceComponents = [];
|
|
34
34
|
// 複数決済カード対応(2022-07-11~)
|
|
35
35
|
if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
|
|
36
36
|
unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
|
|
@@ -42,7 +42,7 @@ function createCompoundPriceSpec4event(params) {
|
|
|
42
42
|
&& s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
|
|
43
43
|
&& params.videoFormatTypes.includes(s.appliesToVideoFormat);
|
|
44
44
|
});
|
|
45
|
-
mvtkPriceComponents
|
|
45
|
+
mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
const mvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
|
|
@@ -51,7 +51,7 @@ function createCompoundPriceSpec4event(params) {
|
|
|
51
51
|
&& s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType;
|
|
52
52
|
});
|
|
53
53
|
if (mvtkSpec4appliesToMovieTicket !== undefined) {
|
|
54
|
-
mvtkPriceComponents
|
|
54
|
+
mvtkPriceComponents.push(mvtkChargePriceSpec2component(mvtkSpec4appliesToMovieTicket));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
});
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.130.0
|
|
12
|
+
"@chevre/factory": "4.275.0",
|
|
13
|
+
"@cinerino/sdk": "3.130.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.0.0
|
|
123
|
+
"version": "20.0.0"
|
|
124
124
|
}
|