@chevre/domain 22.8.0-alpha.9 → 22.8.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.
- package/example/src/chevre/adminSellerReturnPolicy.ts +102 -0
- package/example/src/chevre/{searchActions.ts → searchActionsByOrderNumber.ts} +3 -5
- package/example/src/chevre/searchSellersByAggregate.ts +7 -20
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
- package/lib/chevre/repo/action.d.ts +5 -1
- package/lib/chevre/repo/action.js +51 -45
- package/lib/chevre/repo/issuer.d.ts +32 -0
- package/lib/chevre/repo/issuer.js +150 -0
- package/lib/chevre/repo/member.d.ts +4 -5
- package/lib/chevre/repo/member.js +19 -9
- package/lib/chevre/repo/memberProgram.d.ts +59 -0
- package/lib/chevre/repo/memberProgram.js +140 -0
- package/lib/chevre/repo/mongoose/schemas/action.js +20 -10
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +40 -0
- package/lib/chevre/repo/mongoose/schemas/issuer.js +56 -0
- package/lib/chevre/repo/mongoose/schemas/seller.js +3 -12
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/sellerReturnPolicy.js +92 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +0 -66
- package/lib/chevre/repo/projectMakesOffer.d.ts +2 -1
- package/lib/chevre/repo/projectMakesOffer.js +4 -5
- package/lib/chevre/repo/seller.d.ts +1 -1
- package/lib/chevre/repo/seller.js +25 -21
- package/lib/chevre/repo/sellerReturnPolicy.d.ts +36 -0
- package/lib/chevre/repo/sellerReturnPolicy.js +164 -0
- package/lib/chevre/repository.d.ts +15 -0
- package/lib/chevre/repository.js +41 -2
- package/lib/chevre/service/notification.js +3 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +5 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +5 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +20 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
- package/lib/chevre/service/order/onOrderUpdated/factory.js +1 -0
- package/lib/chevre/service/order/returnOrder.js +16 -11
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +34 -7
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +4 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +19 -7
- package/lib/chevre/service/transaction/returnOrder.d.ts +2 -0
- package/package.json +3 -3
- package/example/src/chevre/adminSellerPaymentAccepted.ts +0 -60
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -129
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = void 0;
|
|
4
|
+
exports.createSchema = createSchema;
|
|
5
|
+
const mongoose_1 = require("mongoose");
|
|
6
|
+
const writeConcern_1 = require("../writeConcern");
|
|
7
|
+
const settings_1 = require("../../../settings");
|
|
8
|
+
const modelName = 'SellerReturnPolicy';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: {
|
|
12
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
typeOf: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
identifier: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
merchantReturnDays: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
restockingFee: {
|
|
28
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
+
itemCondition: mongoose_1.SchemaTypes.Mixed,
|
|
33
|
+
applicablePaymentMethod: mongoose_1.SchemaTypes.Mixed
|
|
34
|
+
// url: SchemaTypes.Mixed,
|
|
35
|
+
};
|
|
36
|
+
const schemaOptions = {
|
|
37
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
38
|
+
autoCreate: false,
|
|
39
|
+
collection: 'sellerReturnPolicies',
|
|
40
|
+
id: true,
|
|
41
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
42
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
43
|
+
strict: true,
|
|
44
|
+
strictQuery: false,
|
|
45
|
+
timestamps: false,
|
|
46
|
+
versionKey: false,
|
|
47
|
+
toJSON: {
|
|
48
|
+
getters: false,
|
|
49
|
+
virtuals: false,
|
|
50
|
+
minimize: false,
|
|
51
|
+
versionKey: false
|
|
52
|
+
},
|
|
53
|
+
toObject: {
|
|
54
|
+
getters: false,
|
|
55
|
+
virtuals: true,
|
|
56
|
+
minimize: false,
|
|
57
|
+
versionKey: false
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const indexes = [
|
|
61
|
+
[
|
|
62
|
+
{ identifier: 1 },
|
|
63
|
+
{ name: 'identifier' }
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
{ 'project.id': 1, identifier: 1 },
|
|
67
|
+
{
|
|
68
|
+
unique: true,
|
|
69
|
+
name: 'uniqueIdentifier'
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
{ 'restockingFee.value': 1, identifier: 1 },
|
|
74
|
+
{ name: 'restockingFeeValue' }
|
|
75
|
+
]
|
|
76
|
+
];
|
|
77
|
+
exports.indexes = indexes;
|
|
78
|
+
/**
|
|
79
|
+
* 販売者返品ポリシースキーマ
|
|
80
|
+
*/
|
|
81
|
+
let schema;
|
|
82
|
+
function createSchema() {
|
|
83
|
+
if (schema === undefined) {
|
|
84
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
85
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
86
|
+
indexes.forEach((indexParams) => {
|
|
87
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return schema;
|
|
92
|
+
}
|
|
@@ -107,26 +107,6 @@ const indexes = [
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
],
|
|
110
|
-
// 廃止(2024-04-23~)
|
|
111
|
-
// [
|
|
112
|
-
// { 'data.object.itemOffered.id': 1, runsAt: -1 },
|
|
113
|
-
// {
|
|
114
|
-
// name: 'searchByDataObjectItemOfferedId',
|
|
115
|
-
// partialFilterExpression: {
|
|
116
|
-
// 'data.object.itemOffered.id': { $exists: true }
|
|
117
|
-
// }
|
|
118
|
-
// }
|
|
119
|
-
// ],
|
|
120
|
-
// 廃止(2024-04-23~)
|
|
121
|
-
// [
|
|
122
|
-
// { 'data.object.itemOffered.membershipFor.id': 1, runsAt: -1 },
|
|
123
|
-
// {
|
|
124
|
-
// name: 'searchByDataObjectItemOfferedMembershipForId',
|
|
125
|
-
// partialFilterExpression: {
|
|
126
|
-
// 'data.object.itemOffered.membershipFor.id': { $exists: true }
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
// ],
|
|
130
110
|
[
|
|
131
111
|
{ 'data.object.orderNumber': 1, runsAt: -1 },
|
|
132
112
|
{
|
|
@@ -185,22 +165,6 @@ const indexes = [
|
|
|
185
165
|
{ status: 1, name: 1, numberOfTried: 1, runsAt: 1 },
|
|
186
166
|
{ name: 'executeOneByName' }
|
|
187
167
|
],
|
|
188
|
-
// 廃止(2024-04-23~)
|
|
189
|
-
// [
|
|
190
|
-
// {
|
|
191
|
-
// 'project.id': 1,
|
|
192
|
-
// status: 1,
|
|
193
|
-
// name: 1,
|
|
194
|
-
// numberOfTried: 1,
|
|
195
|
-
// runsAt: 1
|
|
196
|
-
// },
|
|
197
|
-
// {
|
|
198
|
-
// name: 'executeOneByName-v2',
|
|
199
|
-
// partialFilterExpression: {
|
|
200
|
-
// 'project.id': { $exists: true }
|
|
201
|
-
// }
|
|
202
|
-
// }
|
|
203
|
-
// ],
|
|
204
168
|
[
|
|
205
169
|
{ status: 1, remainingNumberOfTries: 1, lastTriedAt: 1 },
|
|
206
170
|
{
|
|
@@ -210,36 +174,6 @@ const indexes = [
|
|
|
210
174
|
}
|
|
211
175
|
}
|
|
212
176
|
]
|
|
213
|
-
// 廃止(2024-04-23~)
|
|
214
|
-
// [
|
|
215
|
-
// { 'data.transactionId': 1 },
|
|
216
|
-
// {
|
|
217
|
-
// partialFilterExpression: {
|
|
218
|
-
// 'data.transactionId': { $exists: true }
|
|
219
|
-
// }
|
|
220
|
-
// }
|
|
221
|
-
// ],
|
|
222
|
-
// 廃止(2024-04-23~)
|
|
223
|
-
// [
|
|
224
|
-
// // メール送信タスク存在確認に使用
|
|
225
|
-
// { 'data.actionAttributes.object.identifier': 1, runsAt: -1 },
|
|
226
|
-
// {
|
|
227
|
-
// name: 'searchByDataActionAttributesObjectIdentifier',
|
|
228
|
-
// partialFilterExpression: {
|
|
229
|
-
// 'data.actionAttributes.object.identifier': { $exists: true }
|
|
230
|
-
// }
|
|
231
|
-
// }
|
|
232
|
-
// ]
|
|
233
|
-
// 廃止(2024-04-23~)
|
|
234
|
-
// [
|
|
235
|
-
// { 'data.transactionId': 1, runsAt: -1 },
|
|
236
|
-
// {
|
|
237
|
-
// name: 'searchByDataTransactionId',
|
|
238
|
-
// partialFilterExpression: {
|
|
239
|
-
// 'data.transactionId': { $exists: true }
|
|
240
|
-
// }
|
|
241
|
-
// }
|
|
242
|
-
// ]
|
|
243
177
|
];
|
|
244
178
|
exports.indexes = indexes;
|
|
245
179
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
type IMakesOffer = Pick<factory.project.IMakesOffer, 'eligibleCustomerType' | 'typeOf'> & {
|
|
3
|
+
type IMakesOffer = Pick<factory.project.IMakesOffer, 'eligibleCustomerType' | 'typeOf' | 'validForMemberTier'> & {
|
|
4
4
|
availableAtOrFrom: Pick<factory.offer.IAvailableAtOrFrom, 'id'>;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -41,6 +41,7 @@ export declare class ProjectMakesOfferRepo {
|
|
|
41
41
|
offeredBy: {
|
|
42
42
|
id: string;
|
|
43
43
|
};
|
|
44
|
+
validForMemberTier?: factory.project.IMemberProgramTier;
|
|
44
45
|
}): Promise<void>;
|
|
45
46
|
deleteOne(params: {
|
|
46
47
|
availableAtOrFrom: {
|
|
@@ -45,7 +45,8 @@ class ProjectMakesOfferRepo {
|
|
|
45
45
|
_id: 0,
|
|
46
46
|
typeOf: '$makesOffer.typeOf',
|
|
47
47
|
availableAtOrFrom: '$makesOffer.availableAtOrFrom',
|
|
48
|
-
eligibleCustomerType: '$makesOffer.eligibleCustomerType'
|
|
48
|
+
eligibleCustomerType: '$makesOffer.eligibleCustomerType',
|
|
49
|
+
validForMemberTier: '$makesOffer.validForMemberTier'
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
]);
|
|
@@ -88,16 +89,14 @@ class ProjectMakesOfferRepo {
|
|
|
88
89
|
}
|
|
89
90
|
updateOne(params) {
|
|
90
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
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))
|
|
92
|
+
const updatingMakesOffer = Object.assign(Object.assign({ typeOf: factory.offerType.Offer, availableAtOrFrom: { id: params.availableAtOrFrom.id } }, (Array.isArray(params.eligibleCustomerType))
|
|
94
93
|
? {
|
|
95
94
|
eligibleCustomerType: params.eligibleCustomerType.map(({ codeValue }) => ({
|
|
96
95
|
codeValue,
|
|
97
96
|
typeOf: 'CategoryCode'
|
|
98
97
|
}))
|
|
99
98
|
}
|
|
100
|
-
: undefined);
|
|
99
|
+
: undefined), (params.validForMemberTier !== undefined) ? { validForMemberTier: params.validForMemberTier } : undefined);
|
|
101
100
|
const doc = yield this.projectModel.findOneAndUpdate({
|
|
102
101
|
_id: { $eq: params.offeredBy.id },
|
|
103
102
|
'makesOffer.availableAtOrFrom.id': { $exists: true, $eq: params.availableAtOrFrom.id }
|
|
@@ -10,7 +10,7 @@ interface IUnset {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
type ISellerByAggregate = Pick<ISellerWithId, 'additionalProperty' | 'branchCode' | 'id' | 'name' | 'project' | 'telephone' | 'typeOf' | 'url'> & {
|
|
13
|
-
hasMerchantReturnPolicy?: Pick<factory.seller.
|
|
13
|
+
hasMerchantReturnPolicy?: Pick<factory.seller.IEachReturnPolicy, 'url'>[];
|
|
14
14
|
};
|
|
15
15
|
interface IMemberSearchConditions {
|
|
16
16
|
/**
|
|
@@ -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
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
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,26 +140,32 @@ class SellerRepo {
|
|
|
140
140
|
'paymentAccepted.paymentMethodType': { $exists: true, $eq: paymentAcceptedEq }
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
const
|
|
144
|
-
if (typeof
|
|
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
145
|
andConditions.push({
|
|
146
|
-
'hasMerchantReturnPolicy.
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
const hasMerchantReturnPolicyItemConditionIdEq = (_u = (_t = (_s = params.hasMerchantReturnPolicy) === null || _s === void 0 ? void 0 : _s.itemCondition) === null || _t === void 0 ? void 0 : _t.id) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
150
|
-
if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
151
|
-
andConditions.push({
|
|
152
|
-
'hasMerchantReturnPolicy.itemCondition.id': {
|
|
153
|
-
$exists: true,
|
|
154
|
-
$eq: hasMerchantReturnPolicyItemConditionIdEq
|
|
155
|
-
}
|
|
146
|
+
'hasMerchantReturnPolicy.identifier': { $exists: true, $eq: hasMerchantReturnPolicyIdentifierEq }
|
|
156
147
|
});
|
|
157
148
|
}
|
|
149
|
+
// discontinue(2025-01-22~)
|
|
150
|
+
// const hasMerchantReturnApplicablePaymentMethodEq = params.hasMerchantReturnPolicy?.applicablePaymentMethod?.$eq;
|
|
151
|
+
// if (typeof hasMerchantReturnApplicablePaymentMethodEq === 'string') {
|
|
152
|
+
// andConditions.push({
|
|
153
|
+
// 'hasMerchantReturnPolicy.applicablePaymentMethod': { $exists: true, $eq: hasMerchantReturnApplicablePaymentMethodEq }
|
|
154
|
+
// });
|
|
155
|
+
// }
|
|
156
|
+
// discontinue(2025-01-22~)
|
|
157
|
+
// const hasMerchantReturnPolicyItemConditionIdEq = params.hasMerchantReturnPolicy?.itemCondition?.id?.$eq;
|
|
158
|
+
// if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
|
|
159
|
+
// andConditions.push({
|
|
160
|
+
// 'hasMerchantReturnPolicy.itemCondition.id': {
|
|
161
|
+
// $exists: true,
|
|
162
|
+
// $eq: hasMerchantReturnPolicyItemConditionIdEq
|
|
163
|
+
// }
|
|
164
|
+
// });
|
|
165
|
+
// }
|
|
158
166
|
return andConditions;
|
|
159
167
|
}
|
|
160
|
-
static CREATE_AGGREGATE_SELLERS_PROJECTION(
|
|
161
|
-
// inclusion: string[], // discontinue(2024-10-20~)
|
|
162
|
-
exclusion) {
|
|
168
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(exclusion) {
|
|
163
169
|
const projectStage = {
|
|
164
170
|
_id: 0,
|
|
165
171
|
id: { $toString: '$_id' },
|
|
@@ -173,8 +179,8 @@ class SellerRepo {
|
|
|
173
179
|
if: { $eq: [{ $size: '$hasMerchantReturnPolicy' }, 0] },
|
|
174
180
|
then: [],
|
|
175
181
|
else: [{
|
|
176
|
-
url: { $first: '$hasMerchantReturnPolicy.url' }
|
|
177
|
-
typeOf: { $first: '$hasMerchantReturnPolicy.typeOf' }
|
|
182
|
+
url: { $first: '$hasMerchantReturnPolicy.url' }
|
|
183
|
+
// typeOf: { $first: '$hasMerchantReturnPolicy.typeOf' }
|
|
178
184
|
}]
|
|
179
185
|
}
|
|
180
186
|
},
|
|
@@ -249,9 +255,7 @@ class SellerRepo {
|
|
|
249
255
|
/**
|
|
250
256
|
* 集計検索(publicな属性検索が目的)
|
|
251
257
|
*/
|
|
252
|
-
searchByAggregate(conditions,
|
|
253
|
-
// inclusion: (keyof ISellerByAggregate)[], // discontinue(2024-10-20~)
|
|
254
|
-
exclusion) {
|
|
258
|
+
searchByAggregate(conditions, exclusion) {
|
|
255
259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
260
|
var _a;
|
|
257
261
|
const matchStages = SellerRepo.CREATE_MONGO_CONDITIONS(conditions)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
export type ISavingReturnPolicy = Pick<factory.sellerReturnPolicy.ISellerReturnPolicy, 'applicablePaymentMethod' | 'identifier' | 'itemCondition' | 'merchantReturnDays' | 'name' | 'project' | 'restockingFee' | 'typeOf'> & {
|
|
4
|
+
id?: never;
|
|
5
|
+
};
|
|
6
|
+
interface IUnset {
|
|
7
|
+
$unset?: {
|
|
8
|
+
[key: string]: 1;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
type ISellerReturnPolicyWithId = factory.sellerReturnPolicy.ISellerReturnPolicy & {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
type IKeyOfProjection = keyof ISellerReturnPolicyWithId;
|
|
15
|
+
/**
|
|
16
|
+
* 販売者返品ポリシーリポジトリ
|
|
17
|
+
*/
|
|
18
|
+
export declare class SellerReturnPolicyRepo {
|
|
19
|
+
private readonly sellerReturnPolicyModel;
|
|
20
|
+
constructor(connection: Connection);
|
|
21
|
+
static CREATE_FILTER_QUERY(params: factory.sellerReturnPolicy.ISearchConditions): FilterQuery<factory.sellerReturnPolicy.ISellerReturnPolicy>[];
|
|
22
|
+
save(params: {
|
|
23
|
+
id?: string;
|
|
24
|
+
attributes: ISavingReturnPolicy & IUnset;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
projectFields(conditions: factory.sellerReturnPolicy.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<ISellerReturnPolicyWithId[]>;
|
|
29
|
+
deleteById(params: {
|
|
30
|
+
id: string;
|
|
31
|
+
project: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.SellerReturnPolicyRepo = void 0;
|
|
24
|
+
const sellerReturnPolicy_1 = require("./mongoose/schemas/sellerReturnPolicy");
|
|
25
|
+
const factory = require("../factory");
|
|
26
|
+
const settings_1 = require("../settings");
|
|
27
|
+
/**
|
|
28
|
+
* 販売者返品ポリシーリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class SellerReturnPolicyRepo {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.sellerReturnPolicyModel = connection.model(sellerReturnPolicy_1.modelName, (0, sellerReturnPolicy_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_FILTER_QUERY(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
37
|
+
const andConditions = [];
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
+
if (typeof idEq === 'string') {
|
|
44
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
45
|
+
}
|
|
46
|
+
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
47
|
+
if (Array.isArray(idIn)) {
|
|
48
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
49
|
+
}
|
|
50
|
+
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
51
|
+
if (typeof identifierEq === 'string') {
|
|
52
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
53
|
+
}
|
|
54
|
+
const identifierIn = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$in;
|
|
55
|
+
if (Array.isArray(identifierIn)) {
|
|
56
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
57
|
+
}
|
|
58
|
+
const identifierRegex = (_g = params.identifier) === null || _g === void 0 ? void 0 : _g.$regex;
|
|
59
|
+
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
60
|
+
andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
|
|
61
|
+
}
|
|
62
|
+
const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
63
|
+
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
64
|
+
andConditions.push({
|
|
65
|
+
$or: [
|
|
66
|
+
{ 'name.ja': { $exists: true, $regex: new RegExp(nameRegex) } },
|
|
67
|
+
{ 'name.en': { $exists: true, $regex: new RegExp(nameRegex) } }
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const restockingFeeValueEq = (_k = (_j = params.restockingFee) === null || _j === void 0 ? void 0 : _j.value) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
72
|
+
if (typeof restockingFeeValueEq === 'number') {
|
|
73
|
+
andConditions.push({ 'restockingFee.value': { $eq: restockingFeeValueEq } });
|
|
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
|
+
}
|
|
83
|
+
return andConditions;
|
|
84
|
+
}
|
|
85
|
+
save(params) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
let doc;
|
|
89
|
+
let savedId;
|
|
90
|
+
const savingId = params.id;
|
|
91
|
+
if (typeof savingId === 'string') {
|
|
92
|
+
if (savingId === '') {
|
|
93
|
+
throw new factory.errors.ArgumentNull('id');
|
|
94
|
+
}
|
|
95
|
+
const _c = params.attributes, { id, identifier, project, typeOf, $unset } = _c, updateFields = __rest(_c, ["id", "identifier", "project", "typeOf", "$unset"]);
|
|
96
|
+
const filter = {
|
|
97
|
+
_id: { $eq: savingId },
|
|
98
|
+
'project.id': { $eq: project.id }
|
|
99
|
+
};
|
|
100
|
+
const update = Object.assign({ $set: updateFields }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
101
|
+
const options = {
|
|
102
|
+
upsert: false,
|
|
103
|
+
new: true,
|
|
104
|
+
projection: { _id: 1, id: { $toString: '$_id' } }
|
|
105
|
+
};
|
|
106
|
+
doc = yield this.sellerReturnPolicyModel.findOneAndUpdate(filter, update, options)
|
|
107
|
+
.lean()
|
|
108
|
+
.exec();
|
|
109
|
+
if (doc === null) {
|
|
110
|
+
throw new factory.errors.NotFound(this.sellerReturnPolicyModel.modelName);
|
|
111
|
+
}
|
|
112
|
+
savedId = savingId;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const _d = params.attributes, { $unset, id } = _d, createParams = __rest(_d, ["$unset", "id"]);
|
|
116
|
+
const result = yield this.sellerReturnPolicyModel.insertMany(createParams, { rawResult: true });
|
|
117
|
+
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
118
|
+
if (typeof insertedId !== 'string') {
|
|
119
|
+
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
120
|
+
}
|
|
121
|
+
savedId = insertedId;
|
|
122
|
+
}
|
|
123
|
+
return { id: savedId };
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
projectFields(conditions, inclusion) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
var _a;
|
|
129
|
+
const andConditions = SellerReturnPolicyRepo.CREATE_FILTER_QUERY(conditions);
|
|
130
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(inclusion.map((key) => ([key, 1])))
|
|
131
|
+
// applicablePaymentMethod: 1,
|
|
132
|
+
// identifier: 1,
|
|
133
|
+
// itemCondition: 1,
|
|
134
|
+
// merchantReturnDays: 1,
|
|
135
|
+
// name: 1,
|
|
136
|
+
// project: 1,
|
|
137
|
+
// restockingFee: 1,
|
|
138
|
+
// typeOf: 1
|
|
139
|
+
);
|
|
140
|
+
const query = this.sellerReturnPolicyModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
141
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
142
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
143
|
+
query.limit(conditions.limit)
|
|
144
|
+
.skip(conditions.limit * (page - 1));
|
|
145
|
+
}
|
|
146
|
+
if (typeof ((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.identifier) === 'number') {
|
|
147
|
+
query.sort({ identifier: conditions.sort.identifier });
|
|
148
|
+
}
|
|
149
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
150
|
+
.lean()
|
|
151
|
+
.exec();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
deleteById(params) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
yield this.sellerReturnPolicyModel.findOneAndDelete({
|
|
157
|
+
_id: { $eq: params.id },
|
|
158
|
+
'project.id': { $eq: params.project.id }
|
|
159
|
+
}, { projection: { _id: 1 } })
|
|
160
|
+
.exec();
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.SellerReturnPolicyRepo = SellerReturnPolicyRepo;
|
|
@@ -24,7 +24,9 @@ import type { EventRepo } from './repo/event';
|
|
|
24
24
|
import type { EventSellerMakesOfferRepo } from './repo/eventSellerMakesOffer';
|
|
25
25
|
import type { EventSeriesRepo } from './repo/eventSeries';
|
|
26
26
|
import type { InterfaceRepo } from './repo/interface';
|
|
27
|
+
import type { IssuerRepo } from './repo/issuer';
|
|
27
28
|
import type { MemberRepo } from './repo/member';
|
|
29
|
+
import type { MemberProgramRepo } from './repo/memberProgram';
|
|
28
30
|
import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
|
|
29
31
|
import type { MessageRepo } from './repo/message';
|
|
30
32
|
import type { NoteRepo } from './repo/note';
|
|
@@ -57,6 +59,7 @@ import type { RoleRepo } from './repo/role';
|
|
|
57
59
|
import type { ScheduleRepo } from './repo/schedule';
|
|
58
60
|
import type { SellerRepo } from './repo/seller';
|
|
59
61
|
import type { SellerPaymentAcceptedRepo } from './repo/sellerPaymentAccepted';
|
|
62
|
+
import type { SellerReturnPolicyRepo } from './repo/sellerReturnPolicy';
|
|
60
63
|
import type { ServiceOutputRepo } from './repo/serviceOutput';
|
|
61
64
|
import type { ServiceOutputIdentifierRepo } from './repo/serviceOutputIdentifier';
|
|
62
65
|
import type { SettingRepo } from './repo/setting';
|
|
@@ -169,10 +172,18 @@ export type Interface = InterfaceRepo;
|
|
|
169
172
|
export declare namespace Interface {
|
|
170
173
|
function createInstance(...params: ConstructorParameters<typeof InterfaceRepo>): Promise<InterfaceRepo>;
|
|
171
174
|
}
|
|
175
|
+
export type Issuer = IssuerRepo;
|
|
176
|
+
export declare namespace Issuer {
|
|
177
|
+
function createInstance(...params: ConstructorParameters<typeof IssuerRepo>): Promise<IssuerRepo>;
|
|
178
|
+
}
|
|
172
179
|
export type Member = MemberRepo;
|
|
173
180
|
export declare namespace Member {
|
|
174
181
|
function createInstance(...params: ConstructorParameters<typeof MemberRepo>): Promise<MemberRepo>;
|
|
175
182
|
}
|
|
183
|
+
export type MemberProgram = MemberProgramRepo;
|
|
184
|
+
export declare namespace MemberProgram {
|
|
185
|
+
function createInstance(...params: ConstructorParameters<typeof MemberProgramRepo>): Promise<MemberProgramRepo>;
|
|
186
|
+
}
|
|
176
187
|
export type MerchantReturnPolicy = MerchantReturnPolicyRepo;
|
|
177
188
|
export declare namespace MerchantReturnPolicy {
|
|
178
189
|
function createInstance(...params: ConstructorParameters<typeof MerchantReturnPolicyRepo>): Promise<MerchantReturnPolicyRepo>;
|
|
@@ -334,6 +345,10 @@ export type SellerPaymentAccepted = SellerPaymentAcceptedRepo;
|
|
|
334
345
|
export declare namespace SellerPaymentAccepted {
|
|
335
346
|
function createInstance(...params: ConstructorParameters<typeof SellerPaymentAcceptedRepo>): Promise<SellerPaymentAcceptedRepo>;
|
|
336
347
|
}
|
|
348
|
+
export type SellerReturnPolicy = SellerReturnPolicyRepo;
|
|
349
|
+
export declare namespace SellerReturnPolicy {
|
|
350
|
+
function createInstance(...params: ConstructorParameters<typeof SellerReturnPolicyRepo>): Promise<SellerReturnPolicyRepo>;
|
|
351
|
+
}
|
|
337
352
|
export type ServiceOutput = ServiceOutputRepo;
|
|
338
353
|
export declare namespace ServiceOutput {
|
|
339
354
|
function createInstance(...params: ConstructorParameters<typeof ServiceOutputRepo>): Promise<ServiceOutputRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = void 0;
|
|
12
|
+
exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.Interface = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.Reservation = exports.ProjectMakesOffer = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -323,6 +323,19 @@ var Interface;
|
|
|
323
323
|
}
|
|
324
324
|
Interface.createInstance = createInstance;
|
|
325
325
|
})(Interface || (exports.Interface = Interface = {}));
|
|
326
|
+
var Issuer;
|
|
327
|
+
(function (Issuer) {
|
|
328
|
+
let repo;
|
|
329
|
+
function createInstance(...params) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
if (repo === undefined) {
|
|
332
|
+
repo = (yield Promise.resolve().then(() => require('./repo/issuer'))).IssuerRepo;
|
|
333
|
+
}
|
|
334
|
+
return new repo(...params);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
Issuer.createInstance = createInstance;
|
|
338
|
+
})(Issuer || (exports.Issuer = Issuer = {}));
|
|
326
339
|
var Member;
|
|
327
340
|
(function (Member) {
|
|
328
341
|
let repo;
|
|
@@ -336,6 +349,19 @@ var Member;
|
|
|
336
349
|
}
|
|
337
350
|
Member.createInstance = createInstance;
|
|
338
351
|
})(Member || (exports.Member = Member = {}));
|
|
352
|
+
var MemberProgram;
|
|
353
|
+
(function (MemberProgram) {
|
|
354
|
+
let repo;
|
|
355
|
+
function createInstance(...params) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
if (repo === undefined) {
|
|
358
|
+
repo = (yield Promise.resolve().then(() => require('./repo/memberProgram'))).MemberProgramRepo;
|
|
359
|
+
}
|
|
360
|
+
return new repo(...params);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
MemberProgram.createInstance = createInstance;
|
|
364
|
+
})(MemberProgram || (exports.MemberProgram = MemberProgram = {}));
|
|
339
365
|
var MerchantReturnPolicy;
|
|
340
366
|
(function (MerchantReturnPolicy) {
|
|
341
367
|
let repo;
|
|
@@ -802,6 +828,19 @@ var SellerPaymentAccepted;
|
|
|
802
828
|
}
|
|
803
829
|
SellerPaymentAccepted.createInstance = createInstance;
|
|
804
830
|
})(SellerPaymentAccepted || (exports.SellerPaymentAccepted = SellerPaymentAccepted = {}));
|
|
831
|
+
var SellerReturnPolicy;
|
|
832
|
+
(function (SellerReturnPolicy) {
|
|
833
|
+
let repo;
|
|
834
|
+
function createInstance(...params) {
|
|
835
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
836
|
+
if (repo === undefined) {
|
|
837
|
+
repo = (yield Promise.resolve().then(() => require('./repo/sellerReturnPolicy'))).SellerReturnPolicyRepo;
|
|
838
|
+
}
|
|
839
|
+
return new repo(...params);
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
SellerReturnPolicy.createInstance = createInstance;
|
|
843
|
+
})(SellerReturnPolicy || (exports.SellerReturnPolicy = SellerReturnPolicy = {}));
|
|
805
844
|
var ServiceOutput;
|
|
806
845
|
(function (ServiceOutput) {
|
|
807
846
|
let repo;
|
|
@@ -242,8 +242,9 @@ function sleep(waitTime) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
function createInformActionAttributes(params) {
|
|
245
|
-
const { object, purpose, recipient, project } = params;
|
|
246
|
-
return Object.assign({ agent: { id: project.id, typeOf: factory.organizationType.Project }, object, project: { id: project.id, typeOf: factory.organizationType.Project }, recipient, typeOf: factory.actionType.InformAction }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined)
|
|
245
|
+
const { about, object, purpose, recipient, project } = params;
|
|
246
|
+
return Object.assign(Object.assign({ agent: { id: project.id, typeOf: factory.organizationType.Project }, object, project: { id: project.id, typeOf: factory.organizationType.Project }, recipient, typeOf: factory.actionType.InformAction }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined), (typeof (about === null || about === void 0 ? void 0 : about.typeOf) === 'string') ? { about } : undefined // add(2025-01-23~)
|
|
247
|
+
);
|
|
247
248
|
}
|
|
248
249
|
function signRequest(params) {
|
|
249
250
|
const { requestBody, timestamp, secretKey } = params;
|
|
@@ -18,6 +18,7 @@ setting) {
|
|
|
18
18
|
informTasks.push(...informOrder.map((informOrderParams) => {
|
|
19
19
|
var _a, _b;
|
|
20
20
|
const informActionAttributes = {
|
|
21
|
+
about: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
|
|
21
22
|
object: order4inform,
|
|
22
23
|
recipient: {
|
|
23
24
|
url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
|