@chevre/domain 22.8.0-alpha.20 → 22.8.0-alpha.22
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.
|
@@ -47,7 +47,7 @@ class SellerRepo {
|
|
|
47
47
|
}
|
|
48
48
|
// tslint:disable-next-line:max-func-body-length
|
|
49
49
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
50
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
51
51
|
const andConditions = [];
|
|
52
52
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
53
53
|
if (typeof projectIdEq === 'string') {
|
|
@@ -140,13 +140,23 @@ class SellerRepo {
|
|
|
140
140
|
'paymentAccepted.paymentMethodType': { $exists: true, $eq: paymentAcceptedEq }
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
const
|
|
143
|
+
const hasMerchantReturnPolicyIdentifierEq = (_r = (_q = params.hasMerchantReturnPolicy) === null || _q === void 0 ? void 0 : _q.identifier) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
144
|
+
if (typeof hasMerchantReturnPolicyIdentifierEq === 'string') {
|
|
145
|
+
andConditions.push({
|
|
146
|
+
'hasMerchantReturnPolicy.identifier': { $exists: true, $eq: hasMerchantReturnPolicyIdentifierEq }
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
150
|
+
// 互換性維持として TODO discontinue
|
|
151
|
+
const hasMerchantReturnApplicablePaymentMethodEq = (_t = (_s = params.hasMerchantReturnPolicy) === null || _s === void 0 ? void 0 : _s.applicablePaymentMethod) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
144
152
|
if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
|
|
145
153
|
andConditions.push({
|
|
146
154
|
'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
|
-
|
|
157
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
158
|
+
// 互換性維持として TODO discontinue
|
|
159
|
+
const hasMerchantReturnPolicyItemConditionIdEq = (_w = (_v = (_u = params.hasMerchantReturnPolicy) === null || _u === void 0 ? void 0 : _u.itemCondition) === null || _v === void 0 ? void 0 : _v.id) === null || _w === void 0 ? void 0 : _w.$eq;
|
|
150
160
|
if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
151
161
|
andConditions.push({
|
|
152
162
|
'hasMerchantReturnPolicy.itemCondition.id': {
|
|
@@ -33,7 +33,7 @@ class SellerReturnPolicyRepo {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
35
|
static CREATE_FILTER_QUERY(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
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') {
|
|
@@ -72,6 +72,14 @@ class SellerReturnPolicyRepo {
|
|
|
72
72
|
if (typeof restockingFeeValueEq === 'number') {
|
|
73
73
|
andConditions.push({ 'restockingFee.value': { $eq: restockingFeeValueEq } });
|
|
74
74
|
}
|
|
75
|
+
const applicablePaymentMethodEq = (_l = params.applicablePaymentMethod) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
76
|
+
if (typeof applicablePaymentMethodEq === 'string') {
|
|
77
|
+
andConditions.push({ applicablePaymentMethod: { $exists: true, $eq: applicablePaymentMethodEq } });
|
|
78
|
+
}
|
|
79
|
+
const itemConditionIdEq = (_o = (_m = params.itemCondition) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
80
|
+
if (typeof itemConditionIdEq === 'string') {
|
|
81
|
+
andConditions.push({ 'itemCondition.id': { $exists: true, $eq: itemConditionIdEq } });
|
|
82
|
+
}
|
|
75
83
|
return andConditions;
|
|
76
84
|
}
|
|
77
85
|
save(params) {
|
|
@@ -16,6 +16,11 @@ const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
|
16
16
|
const factory = require("../../factory");
|
|
17
17
|
// import { Settings } from '../../settings';
|
|
18
18
|
const debug = createDebug('chevre-domain:service:order');
|
|
19
|
+
function createReturnPolicy(params) {
|
|
20
|
+
const { identifier, returnFees, restockingFee, typeOf } = params.returnOrderTransaction.object.returnPolicy;
|
|
21
|
+
return Object.assign(Object.assign({ returnFees,
|
|
22
|
+
typeOf }, (typeof identifier === 'string') ? { identifier } : undefined), (typeof (restockingFee === null || restockingFee === void 0 ? void 0 : restockingFee.value) === 'number') ? { restockingFee } : undefined);
|
|
23
|
+
}
|
|
19
24
|
function returnOrder(params) {
|
|
20
25
|
// tslint:disable-next-line:max-func-body-length
|
|
21
26
|
return (repos
|
|
@@ -54,7 +59,7 @@ function returnOrder(params) {
|
|
|
54
59
|
typeOf: factory.transactionType.ReturnOrder,
|
|
55
60
|
statuses: [factory.transactionStatusType.Confirmed],
|
|
56
61
|
object: { order: { orderNumbers: [orderNumber] } },
|
|
57
|
-
inclusion: ['typeOf', 'potentialActions']
|
|
62
|
+
inclusion: ['typeOf', 'potentialActions', 'object']
|
|
58
63
|
});
|
|
59
64
|
const returnOrderTransaction = returnOrderTransactions.shift();
|
|
60
65
|
if (returnOrderTransaction === undefined) {
|
|
@@ -62,23 +67,22 @@ function returnOrder(params) {
|
|
|
62
67
|
}
|
|
63
68
|
const simpleOrder = {
|
|
64
69
|
typeOf: order.typeOf,
|
|
65
|
-
// seller: {
|
|
66
|
-
// id: order.seller.id,
|
|
67
|
-
// typeOf: order.seller.typeOf,
|
|
68
|
-
// name: order.seller.name
|
|
69
|
-
// }, // 廃止(2024-03-06~)
|
|
70
|
-
// customer: createMaskedCustomer(order, { noProfile: true }), // 廃止(2024-03-06~)
|
|
71
70
|
orderNumber: order.orderNumber,
|
|
72
|
-
// price: order.price,
|
|
73
|
-
// priceCurrency: order.priceCurrency,
|
|
74
71
|
orderDate: order.orderDate,
|
|
75
72
|
dateReturned
|
|
76
73
|
};
|
|
74
|
+
const recipient = {
|
|
75
|
+
id: order.seller.id,
|
|
76
|
+
name: order.seller.name,
|
|
77
|
+
typeOf: order.seller.typeOf
|
|
78
|
+
};
|
|
79
|
+
const returnPolicyAsInstrument = createReturnPolicy({ returnOrderTransaction });
|
|
77
80
|
const returnOrderActionAttributes = {
|
|
78
81
|
agent: returner,
|
|
82
|
+
instrument: [returnPolicyAsInstrument], // add returnPolicy(2025-01-21~)
|
|
79
83
|
object: simpleOrder,
|
|
80
84
|
project: order.project,
|
|
81
|
-
recipient
|
|
85
|
+
recipient,
|
|
82
86
|
typeOf: factory.actionType.ReturnAction
|
|
83
87
|
};
|
|
84
88
|
let returnedOwnershipInfos = [];
|
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.15",
|
|
15
|
+
"@cinerino/sdk": "10.20.0-alpha.10",
|
|
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.22"
|
|
116
116
|
}
|
|
@@ -1,110 +0,0 @@
|
|
|
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
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
15
|
-
const projectMakesOfferRepo = await chevre.repository.ProjectMakesOffer.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = memberRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
// 'project.id': { $eq: project.id },
|
|
20
|
-
// 'member.id': { $eq: 'xxx' },
|
|
21
|
-
'member.typeOf': { $eq: chevre.factory.creativeWorkType.WebApplication },
|
|
22
|
-
'member.member': { $exists: true }
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
// paymentMethods: 1,
|
|
26
|
-
// project: 1,
|
|
27
|
-
// orderDate: 1
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
console.log('docs found');
|
|
31
|
-
|
|
32
|
-
let updated: number = 0;
|
|
33
|
-
let i = 0;
|
|
34
|
-
await cursor.eachAsync(async (doc) => {
|
|
35
|
-
i += 1;
|
|
36
|
-
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
37
|
-
const makesOffer = (await projectMakesOfferRepo.search({
|
|
38
|
-
limit: 1,
|
|
39
|
-
page: 1,
|
|
40
|
-
offeredBy: { id: { $eq: iamMember.project.id } },
|
|
41
|
-
availableAtOrFrom: { id: { $eq: iamMember.member.id } }
|
|
42
|
-
})).shift();
|
|
43
|
-
if (makesOffer === undefined) {
|
|
44
|
-
throw new Error('iamMember not found');
|
|
45
|
-
}
|
|
46
|
-
// tslint:disable-next-line:no-null-keyword
|
|
47
|
-
// console.dir(makesOffer, { depth: null });
|
|
48
|
-
|
|
49
|
-
const issuerExpected = (<any>iamMember.member).member?.at(0)?.memberOf?.issuer;
|
|
50
|
-
const secretExpected = (<any>iamMember.member).member?.at(0)?.memberOf?.secret;
|
|
51
|
-
if (typeof issuerExpected !== 'string' || typeof secretExpected !== 'string') {
|
|
52
|
-
throw new Error('issuerExpected,secretExpected must be string');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log(
|
|
56
|
-
'checking...',
|
|
57
|
-
iamMember.member.id,
|
|
58
|
-
iamMember.member.typeOf,
|
|
59
|
-
iamMember.project.id,
|
|
60
|
-
issuerExpected,
|
|
61
|
-
secretExpected,
|
|
62
|
-
i
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const migrated = typeof makesOffer.validForMemberTier?.secret === 'string'
|
|
66
|
-
&& makesOffer.validForMemberTier?.isTierOf.hostingOrganization.identifier === issuerExpected
|
|
67
|
-
&& makesOffer.validForMemberTier?.secret === secretExpected;
|
|
68
|
-
if (migrated) {
|
|
69
|
-
console.log(
|
|
70
|
-
'migrated',
|
|
71
|
-
iamMember.member.id,
|
|
72
|
-
iamMember.member.typeOf,
|
|
73
|
-
iamMember.project.id,
|
|
74
|
-
issuerExpected,
|
|
75
|
-
secretExpected,
|
|
76
|
-
i
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
await projectMakesOfferRepo.updateOne({
|
|
80
|
-
availableAtOrFrom: {
|
|
81
|
-
id: makesOffer.availableAtOrFrom.id
|
|
82
|
-
},
|
|
83
|
-
offeredBy: {
|
|
84
|
-
id: iamMember.project.id
|
|
85
|
-
},
|
|
86
|
-
validForMemberTier: {
|
|
87
|
-
isTierOf: { hostingOrganization: { identifier: issuerExpected } },
|
|
88
|
-
secret: secretExpected
|
|
89
|
-
},
|
|
90
|
-
...(Array.isArray(makesOffer.eligibleCustomerType)) ? { eligibleCustomerType: makesOffer.eligibleCustomerType } : undefined
|
|
91
|
-
});
|
|
92
|
-
updated += 1;
|
|
93
|
-
console.log(
|
|
94
|
-
'updated',
|
|
95
|
-
iamMember.member.id,
|
|
96
|
-
iamMember.member.typeOf,
|
|
97
|
-
iamMember.project.id,
|
|
98
|
-
issuerExpected,
|
|
99
|
-
secretExpected,
|
|
100
|
-
i
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
console.log(i, 'docs checked');
|
|
105
|
-
console.log('updated:', updated);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
main()
|
|
109
|
-
.then()
|
|
110
|
-
.catch(console.error);
|