@chevre/domain 21.4.0-alpha.2 → 21.4.0-alpha.4
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/cleanActions.ts +23 -0
- package/example/src/chevre/searchProductOffers.ts +6 -0
- package/lib/chevre/repo/action.d.ts +6 -0
- package/lib/chevre/repo/action.js +13 -0
- package/lib/chevre/repo/productOffer.d.ts +19 -4
- package/lib/chevre/repo/productOffer.js +37 -14
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
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);
|
|
9
|
+
|
|
10
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const result = await actionRepo.deleteStartDatePassedCertainPeriod({
|
|
13
|
+
$lt: moment()
|
|
14
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
15
|
+
.add(-548, 'days')
|
|
16
|
+
.toDate()
|
|
17
|
+
});
|
|
18
|
+
console.log(result);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then()
|
|
23
|
+
.catch(console.error);
|
|
@@ -16,6 +16,12 @@ async function main() {
|
|
|
16
16
|
});
|
|
17
17
|
console.log(offers);
|
|
18
18
|
console.log(offers.length);
|
|
19
|
+
|
|
20
|
+
// await productOfferRepo.deleteOne({
|
|
21
|
+
// project: { id: PROJECT_ID },
|
|
22
|
+
// seller: { id: 'xxx' },
|
|
23
|
+
// itemOffered: { id: 'xxx' }
|
|
24
|
+
// });
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
main()
|
|
@@ -163,6 +163,12 @@ export declare class MongoRepository {
|
|
|
163
163
|
};
|
|
164
164
|
entranceGateIdentifier: string;
|
|
165
165
|
}): Promise<IUseActionCountByOffer[]>;
|
|
166
|
+
/**
|
|
167
|
+
* 開始日時を一定期間過ぎたアクションを削除する
|
|
168
|
+
*/
|
|
169
|
+
deleteStartDatePassedCertainPeriod(params: {
|
|
170
|
+
$lt: Date;
|
|
171
|
+
}): Promise<any>;
|
|
166
172
|
/**
|
|
167
173
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
168
174
|
*/
|
|
@@ -713,6 +713,19 @@ class MongoRepository {
|
|
|
713
713
|
.exec();
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* 開始日時を一定期間過ぎたアクションを削除する
|
|
718
|
+
*/
|
|
719
|
+
deleteStartDatePassedCertainPeriod(params) {
|
|
720
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
721
|
+
return this.actionModel.deleteMany({
|
|
722
|
+
startDate: {
|
|
723
|
+
$lt: params.$lt
|
|
724
|
+
}
|
|
725
|
+
})
|
|
726
|
+
.exec();
|
|
727
|
+
});
|
|
728
|
+
}
|
|
716
729
|
/**
|
|
717
730
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
718
731
|
*/
|
|
@@ -17,16 +17,18 @@ export declare class MongoRepository {
|
|
|
17
17
|
$eq?: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
itemOffered?: {
|
|
21
|
+
id?: {
|
|
22
|
+
$eq?: string;
|
|
23
|
+
};
|
|
22
24
|
};
|
|
23
25
|
seller?: {
|
|
24
26
|
id?: {
|
|
25
27
|
$eq?: string;
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
|
-
}): Promise<(Pick<factory.product.
|
|
29
|
-
|
|
30
|
+
}): Promise<(Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
|
|
31
|
+
itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
|
|
30
32
|
})[]>;
|
|
31
33
|
create(params: factory.product.IOffer & {
|
|
32
34
|
project: {
|
|
@@ -54,4 +56,17 @@ export declare class MongoRepository {
|
|
|
54
56
|
}): Promise<{
|
|
55
57
|
id: string;
|
|
56
58
|
}>;
|
|
59
|
+
deleteOne(params: Pick<factory.product.IOffer, 'seller'> & {
|
|
60
|
+
project: {
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
itemOffered: {
|
|
64
|
+
/**
|
|
65
|
+
* プロダクトID
|
|
66
|
+
*/
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
}): Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
}>;
|
|
57
72
|
}
|
|
@@ -25,7 +25,7 @@ class MongoRepository {
|
|
|
25
25
|
* プロダクトオファー検索
|
|
26
26
|
*/
|
|
27
27
|
search(params) {
|
|
28
|
-
var _a, _b, _c, _d, _e;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f;
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
const matchStages = [{
|
|
31
31
|
$match: {
|
|
@@ -41,11 +41,11 @@ class MongoRepository {
|
|
|
41
41
|
if (typeof projectIdEq === 'string') {
|
|
42
42
|
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
if (typeof
|
|
46
|
-
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(
|
|
44
|
+
const itemOfferedIdEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
45
|
+
if (typeof itemOfferedIdEq === 'string') {
|
|
46
|
+
matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(itemOfferedIdEq) } } });
|
|
47
47
|
}
|
|
48
|
-
const sellerIdEq = (
|
|
48
|
+
const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
49
49
|
if (typeof sellerIdEq === 'string') {
|
|
50
50
|
matchStages.push({ $match: { 'offers.seller.id': { $exists: true, $eq: sellerIdEq } } });
|
|
51
51
|
}
|
|
@@ -60,16 +60,16 @@ class MongoRepository {
|
|
|
60
60
|
{
|
|
61
61
|
$project: {
|
|
62
62
|
_id: 0,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
validThrough: '$offers.validThrough',
|
|
68
|
-
seller: '$offers.seller'
|
|
63
|
+
itemOffered: {
|
|
64
|
+
id: { $toString: '$_id' },
|
|
65
|
+
name: '$name',
|
|
66
|
+
typeOf: '$typeOf'
|
|
69
67
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
availabilityEnds: '$offers.availabilityEnds',
|
|
69
|
+
availabilityStarts: '$offers.availabilityStarts',
|
|
70
|
+
validFrom: '$offers.validFrom',
|
|
71
|
+
validThrough: '$offers.validThrough',
|
|
72
|
+
seller: '$offers.seller'
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
]);
|
|
@@ -158,5 +158,28 @@ class MongoRepository {
|
|
|
158
158
|
return doc.toObject();
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
deleteOne(params) {
|
|
162
|
+
var _a;
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
|
|
165
|
+
if (typeof sellerId !== 'string' || sellerId.length === 0) {
|
|
166
|
+
throw new factory.errors.ArgumentNull('seller.id');
|
|
167
|
+
}
|
|
168
|
+
const doc = yield this.productModel.findOneAndUpdate({
|
|
169
|
+
'project.id': { $eq: params.project.id },
|
|
170
|
+
_id: { $eq: params.itemOffered.id },
|
|
171
|
+
'offers.seller.id': { $exists: true, $eq: sellerId }
|
|
172
|
+
}, {
|
|
173
|
+
$pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
|
|
174
|
+
}, {
|
|
175
|
+
projection: { _id: 1 }
|
|
176
|
+
})
|
|
177
|
+
.exec();
|
|
178
|
+
if (doc === null) {
|
|
179
|
+
throw new factory.errors.NotFound('Product');
|
|
180
|
+
}
|
|
181
|
+
return doc.toObject();
|
|
182
|
+
});
|
|
183
|
+
}
|
|
161
184
|
}
|
|
162
185
|
exports.MongoRepository = MongoRepository;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@chevre/factory": "4.314.0",
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
13
|
+
"@cinerino/sdk": "3.160.0-alpha.2",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -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.4.0-alpha.
|
|
120
|
+
"version": "21.4.0-alpha.4"
|
|
121
121
|
}
|