@chevre/domain 22.5.0-alpha.26 → 22.5.0-alpha.27
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/{migrateSellerMakesOfferAvailableAt.ts → migrateProjectMakesOfferAvailableAt.ts} +16 -21
- package/lib/chevre/repo/project.d.ts +4 -0
- package/lib/chevre/repo/project.js +9 -1
- package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
- package/lib/chevre/repo/projectMakesOffer.js +5 -2
- package/package.json +3 -3
|
@@ -10,17 +10,15 @@ import { chevre } from '../../../lib/index';
|
|
|
10
10
|
async function main() {
|
|
11
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
14
14
|
|
|
15
|
-
const cursor =
|
|
15
|
+
const cursor = projectRepo.getCursor(
|
|
16
16
|
{
|
|
17
|
-
// _id: { $eq: '
|
|
17
|
+
// _id: { $eq: 'cinerino' }
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
_id: 1,
|
|
21
21
|
makesOffer: 1,
|
|
22
|
-
startDate: 1,
|
|
23
|
-
project: 1,
|
|
24
22
|
typeOf: 1
|
|
25
23
|
}
|
|
26
24
|
);
|
|
@@ -30,14 +28,14 @@ async function main() {
|
|
|
30
28
|
let updateCount = 0;
|
|
31
29
|
await cursor.eachAsync(async (doc) => {
|
|
32
30
|
i += 1;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf'
|
|
32
|
+
> & {
|
|
33
|
+
makesOffer: chevre.factory.project.IMakesOffer[];
|
|
34
|
+
} = doc.toObject();
|
|
37
35
|
|
|
38
36
|
console.log(
|
|
39
|
-
'alreadyMigrated?',
|
|
40
|
-
const originMakesOffer =
|
|
37
|
+
'alreadyMigrated?', project.id, i);
|
|
38
|
+
const originMakesOffer = project.makesOffer;
|
|
41
39
|
const alreadyMigrated = !Array.isArray(originMakesOffer)
|
|
42
40
|
|| (Array.isArray(originMakesOffer)
|
|
43
41
|
&& originMakesOffer.every(
|
|
@@ -46,10 +44,10 @@ async function main() {
|
|
|
46
44
|
|
|
47
45
|
if (alreadyMigrated) {
|
|
48
46
|
console.log(
|
|
49
|
-
'already migrated.',
|
|
47
|
+
'already migrated.', project.id, i);
|
|
50
48
|
} else {
|
|
51
49
|
if (Array.isArray(originMakesOffer)) {
|
|
52
|
-
const newMakesOffer: chevre.factory.
|
|
50
|
+
const newMakesOffer: chevre.factory.project.IMakesOffer[] = originMakesOffer.map((offer) => {
|
|
53
51
|
let newAvailableAtOrFrom: { id: string } | undefined;
|
|
54
52
|
if (Array.isArray(offer.availableAtOrFrom)) {
|
|
55
53
|
newAvailableAtOrFrom = offer.availableAtOrFrom.at(0);
|
|
@@ -65,18 +63,15 @@ async function main() {
|
|
|
65
63
|
});
|
|
66
64
|
console.log(
|
|
67
65
|
'updating project...',
|
|
68
|
-
|
|
69
|
-
await
|
|
70
|
-
id:
|
|
71
|
-
|
|
72
|
-
project: seller.project,
|
|
73
|
-
makesOffer: newMakesOffer
|
|
74
|
-
}
|
|
66
|
+
project.id, i, newMakesOffer);
|
|
67
|
+
await projectRepo.updateMakesOfferById({
|
|
68
|
+
id: project.id,
|
|
69
|
+
makesOffer: newMakesOffer
|
|
75
70
|
});
|
|
76
71
|
updateCount += 1;
|
|
77
72
|
console.log(
|
|
78
73
|
'updated.',
|
|
79
|
-
|
|
74
|
+
project.id, i);
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
});
|
|
@@ -60,6 +60,10 @@ export declare class ProjectRepo {
|
|
|
60
60
|
useEventServiceAsProduct?: boolean;
|
|
61
61
|
};
|
|
62
62
|
}): Promise<void>;
|
|
63
|
+
updateMakesOfferById(params: {
|
|
64
|
+
id: string;
|
|
65
|
+
makesOffer: factory.project.IMakesOffer[];
|
|
66
|
+
}): Promise<void>;
|
|
63
67
|
updateAggregateReservation(params: {
|
|
64
68
|
id: string;
|
|
65
69
|
aggregateReservation?: any;
|
|
@@ -140,7 +140,7 @@ class ProjectRepo {
|
|
|
140
140
|
hasMerchantReturnPolicy = Object.assign({ sameAs: params.hasMerchantReturnPolicy.sameAs, typeOf: 'MerchantReturnPolicy' }, (typeof params.hasMerchantReturnPolicy.identifier === 'string')
|
|
141
141
|
? { identifier: params.hasMerchantReturnPolicy.identifier } : undefined);
|
|
142
142
|
}
|
|
143
|
-
yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
143
|
+
yield this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
144
144
|
? { alternateName: params.alternateName }
|
|
145
145
|
: undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_d = (_c = (_b = params.settings) === null || _b === void 0 ? void 0 : _b.sendEmailMessage) === null || _c === void 0 ? void 0 : _c.sender) === null || _d === void 0 ? void 0 : _d.email) === 'string')
|
|
146
146
|
? {
|
|
@@ -160,6 +160,14 @@ class ProjectRepo {
|
|
|
160
160
|
.exec();
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
+
updateMakesOfferById(params) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
yield this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
166
|
+
$set: { makesOffer: params.makesOffer }
|
|
167
|
+
}, { projection: { _id: 1 } })
|
|
168
|
+
.exec();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
163
171
|
updateAggregateReservation(params) {
|
|
164
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
173
|
yield this.projectModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
type IMakesOffer = factory.project.IMakesOffer
|
|
3
|
+
type IMakesOffer = Pick<factory.project.IMakesOffer, 'eligibleCustomerType' | 'typeOf'> & {
|
|
4
|
+
availableAtOrFrom: Pick<factory.offer.IAvailableAtOrFrom, 'id'>;
|
|
5
|
+
};
|
|
4
6
|
/**
|
|
5
7
|
* プロジェクト提供オファーリポジトリ
|
|
6
8
|
*/
|
|
@@ -69,7 +69,8 @@ class ProjectMakesOfferRepo {
|
|
|
69
69
|
}
|
|
70
70
|
const creatingMakesOffer = {
|
|
71
71
|
typeOf: factory.offerType.Offer,
|
|
72
|
-
availableAtOrFrom: [{ id: params.availableAtOrFrom.id }]
|
|
72
|
+
// availableAtOrFrom: [{ id: params.availableAtOrFrom.id }]
|
|
73
|
+
availableAtOrFrom: { id: params.availableAtOrFrom.id } // support non-array(2024-10-22~)
|
|
73
74
|
};
|
|
74
75
|
doc = yield this.projectModel.findOneAndUpdate({
|
|
75
76
|
_id: { $eq: params.offeredBy.id },
|
|
@@ -87,7 +88,9 @@ class ProjectMakesOfferRepo {
|
|
|
87
88
|
}
|
|
88
89
|
updateOne(params) {
|
|
89
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const updatingMakesOffer = Object.assign({ typeOf: factory.offerType.Offer,
|
|
91
|
+
const updatingMakesOffer = Object.assign({ typeOf: factory.offerType.Offer,
|
|
92
|
+
// availableAtOrFrom: [{ id: params.availableAtOrFrom.id }],
|
|
93
|
+
availableAtOrFrom: { id: params.availableAtOrFrom.id } }, (Array.isArray(params.eligibleCustomerType))
|
|
91
94
|
? {
|
|
92
95
|
eligibleCustomerType: params.eligibleCustomerType.map(({ codeValue }) => ({
|
|
93
96
|
codeValue,
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.387.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.
|
|
14
|
+
"@chevre/factory": "4.387.0-alpha.1",
|
|
15
|
+
"@cinerino/sdk": "10.14.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.5.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"postversion": "git push origin --tags",
|
|
109
109
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
110
110
|
},
|
|
111
|
-
"version": "22.5.0-alpha.
|
|
111
|
+
"version": "22.5.0-alpha.27"
|
|
112
112
|
}
|