@chevre/domain 22.8.0-alpha.19 → 22.8.0-alpha.20
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.
|
@@ -25,6 +25,7 @@ async function main() {
|
|
|
25
25
|
|
|
26
26
|
let i = 0;
|
|
27
27
|
let updateCount = 0;
|
|
28
|
+
// tslint:disable-next-line:max-func-body-length
|
|
28
29
|
await cursor.eachAsync(async (doc) => {
|
|
29
30
|
i += 1;
|
|
30
31
|
const seller: Pick<chevre.factory.seller.ISeller, 'id' | 'typeOf' | 'hasMerchantReturnPolicy' | 'project'> = doc.toObject();
|
|
@@ -38,18 +39,20 @@ async function main() {
|
|
|
38
39
|
} else {
|
|
39
40
|
for (const policy of hasMerchantReturnPolicy) {
|
|
40
41
|
if (policy.restockingFee !== undefined) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
alreadyMigrated = false;
|
|
43
|
+
|
|
44
|
+
// const existingPolicy = (await sellerReturnPolicyRepo.projectFields(
|
|
45
|
+
// {
|
|
46
|
+
// limit: 1,
|
|
47
|
+
// page: 1,
|
|
48
|
+
// project: { id: { $eq: seller.project.id } },
|
|
49
|
+
// restockingFee: { value: { $eq: policy.restockingFee.value } }
|
|
50
|
+
// },
|
|
51
|
+
// ['identifier']
|
|
52
|
+
// )).shift();
|
|
53
|
+
// if (existingPolicy === undefined) {
|
|
54
|
+
// alreadyMigrated = false;
|
|
55
|
+
// }
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -58,7 +61,9 @@ async function main() {
|
|
|
58
61
|
console.log(
|
|
59
62
|
'already migrated.', seller.id, seller.project.id, i);
|
|
60
63
|
} else {
|
|
61
|
-
if (Array.isArray(hasMerchantReturnPolicy)) {
|
|
64
|
+
if (Array.isArray(hasMerchantReturnPolicy) && hasMerchantReturnPolicy.length > 0) {
|
|
65
|
+
const policyUrl = hasMerchantReturnPolicy[0].url;
|
|
66
|
+
|
|
62
67
|
const newPolicies: ISavingReturnPolicy[] = [];
|
|
63
68
|
hasMerchantReturnPolicy.forEach((policy) => {
|
|
64
69
|
if (policy.restockingFee !== undefined) {
|
|
@@ -103,6 +108,24 @@ async function main() {
|
|
|
103
108
|
});
|
|
104
109
|
}
|
|
105
110
|
}
|
|
111
|
+
|
|
112
|
+
// update seller
|
|
113
|
+
const newReturnPolicy: chevre.factory.seller.IHasMerchantReturnPolicy = newPolicies.map((policy) => {
|
|
114
|
+
return {
|
|
115
|
+
identifier: policy.identifier,
|
|
116
|
+
...(typeof policyUrl === 'string') ? { url: policyUrl } : undefined
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
console.log('updating seller...', newReturnPolicy);
|
|
120
|
+
await sellerRepo.save({
|
|
121
|
+
id: seller.id,
|
|
122
|
+
attributes: <any>{
|
|
123
|
+
hasMerchantReturnPolicy: newReturnPolicy,
|
|
124
|
+
project: { id: seller.project.id }
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
console.log('seller updated.', seller.id, seller.project.id, i);
|
|
128
|
+
|
|
106
129
|
updateCount += 1;
|
|
107
130
|
console.log(
|
|
108
131
|
'created.',
|
|
@@ -41,7 +41,7 @@ export declare class ProjectMakesOfferRepo {
|
|
|
41
41
|
offeredBy: {
|
|
42
42
|
id: string;
|
|
43
43
|
};
|
|
44
|
-
validForMemberTier?: factory.project.IMemberProgramTier
|
|
44
|
+
validForMemberTier?: factory.project.IMemberProgramTier;
|
|
45
45
|
}): Promise<void>;
|
|
46
46
|
deleteOne(params: {
|
|
47
47
|
availableAtOrFrom: {
|
|
@@ -52,7 +52,7 @@ function verifyMembershipToken(params) {
|
|
|
52
52
|
function validateStartRequest(params) {
|
|
53
53
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
54
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a, _b, _c
|
|
55
|
+
var _a, _b, _c;
|
|
56
56
|
const clientId = (_a = params.clientUser) === null || _a === void 0 ? void 0 : _a.client_id;
|
|
57
57
|
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
58
58
|
throw new factory.errors.ArgumentNull('client_id');
|
|
@@ -121,33 +121,26 @@ function validateStartRequest(params) {
|
|
|
121
121
|
// メンバーシップトークン検証(2024-01-31~)
|
|
122
122
|
let memeberOfPayload;
|
|
123
123
|
// 適用メンバーシップについてはproject.makesOfferを参照(2025-01-13~)
|
|
124
|
-
const
|
|
125
|
-
if (typeof
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const issuer = yield repos.issuer.findByIdentifier({
|
|
143
|
-
project: { id: params.project.id },
|
|
144
|
-
identifier: memberProgram.hostingOrganization.identifier
|
|
145
|
-
});
|
|
146
|
-
if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
147
|
-
throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
148
|
-
}
|
|
149
|
-
memeberOfPayload = yield verifyMembershipToken(Object.assign({ secret: issuer.tokenSecret, issuer: issuer.identifier }, (typeof params.memberOfToken === 'string') ? { token: params.memberOfToken } : undefined));
|
|
124
|
+
const validMemberProgramIdentifier = (_c = projectMakesOffer.validForMemberTier) === null || _c === void 0 ? void 0 : _c.isTierOf.identifier;
|
|
125
|
+
if (typeof validMemberProgramIdentifier === 'string') {
|
|
126
|
+
// メンバープログラムと発行者を参照(2025-01-16~)
|
|
127
|
+
const memberProgram = (yield repos.memberProgram.search({
|
|
128
|
+
limit: 1,
|
|
129
|
+
page: 1,
|
|
130
|
+
project: { id: { $eq: params.project.id } },
|
|
131
|
+
identifier: { $eq: validMemberProgramIdentifier }
|
|
132
|
+
})).shift();
|
|
133
|
+
if (memberProgram === undefined) {
|
|
134
|
+
throw new factory.errors.NotFound('MemberProgram');
|
|
135
|
+
}
|
|
136
|
+
const issuer = yield repos.issuer.findByIdentifier({
|
|
137
|
+
project: { id: params.project.id },
|
|
138
|
+
identifier: memberProgram.hostingOrganization.identifier
|
|
139
|
+
});
|
|
140
|
+
if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
141
|
+
throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
150
142
|
}
|
|
143
|
+
memeberOfPayload = yield verifyMembershipToken(Object.assign({ secret: issuer.tokenSecret, issuer: issuer.identifier }, (typeof params.memberOfToken === 'string') ? { token: params.memberOfToken } : undefined));
|
|
151
144
|
}
|
|
152
145
|
// discontinue(2025-01-14~)
|
|
153
146
|
// if (Array.isArray(iamMember.member.member)) {
|
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.392.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.20.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.392.0-alpha.13",
|
|
15
|
+
"@cinerino/sdk": "10.20.0-alpha.9",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.8.0-alpha.
|
|
115
|
+
"version": "22.8.0-alpha.20"
|
|
116
116
|
}
|