@chevre/domain 21.17.0-alpha.2 → 21.17.0-alpha.3
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/lib/chevre/service/transaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +5 -8
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +10 -0
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -3
- package/lib/chevre/service/transaction/validation.d.ts +4 -1
- package/lib/chevre/service/transaction/validation.js +7 -1
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ const CodeService = require("../code");
|
|
|
28
28
|
*/
|
|
29
29
|
function start(params) {
|
|
30
30
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const { passport } = yield (0, validation_1.validateWaiterPassport)(params);
|
|
31
32
|
const sellers = yield repos.seller.search({
|
|
32
33
|
limit: 1,
|
|
33
34
|
page: 1,
|
|
@@ -37,7 +38,6 @@ function start(params) {
|
|
|
37
38
|
if (seller === undefined) {
|
|
38
39
|
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
39
40
|
}
|
|
40
|
-
const passport = yield (0, validation_1.validateWaiterPassport)(params);
|
|
41
41
|
// 金額をfix
|
|
42
42
|
const amount = params.object.amount;
|
|
43
43
|
if (typeof amount.value !== 'number') {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
-
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail
|
|
2
|
+
export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, expiresInSeconds: number, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, broker?: factory.order.IBroker, customerType?: string): factory.transaction.placeOrder.IStartParams;
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createStartParams = void 0;
|
|
4
4
|
const factory = require("../../../factory");
|
|
5
|
-
function createStartParams(params, expiresInSeconds, passport, seller, broker) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
|
-
const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
8
|
-
? { clientUser: params.object.clientUser }
|
|
9
|
-
: undefined), (typeof ((_b = params.object) === null || _b === void 0 ? void 0 : _b.name) === 'string') ? { name: (_c = params.object) === null || _c === void 0 ? void 0 : _c.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_d = params.object.customer) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string') ? { customer: params.object.customer } : undefined);
|
|
5
|
+
function createStartParams(params, expiresInSeconds, passport, seller, broker, customerType) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
|
+
const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? { passportToken: params.object.passport.token } : undefined), (typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { passport } : undefined), (typeof ((_b = params.object.clientUser) === null || _b === void 0 ? void 0 : _b.client_id) === 'string') ? { clientUser: params.object.clientUser } : undefined), (typeof ((_c = params.object) === null || _c === void 0 ? void 0 : _c.name) === 'string') ? { name: (_d = params.object) === null || _d === void 0 ? void 0 : _d.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_e = params.object.customer) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string') ? { customer: params.object.customer } : undefined), (typeof customerType === 'string') ? { customerType } : undefined);
|
|
10
8
|
if (typeof seller.id !== 'string') {
|
|
11
9
|
throw new factory.errors.NotFound('seller.id');
|
|
12
10
|
}
|
|
@@ -21,11 +19,10 @@ function createStartParams(params, expiresInSeconds, passport, seller, broker) {
|
|
|
21
19
|
id: seller.id,
|
|
22
20
|
name: seller.name,
|
|
23
21
|
typeOf: seller.typeOf,
|
|
24
|
-
// 追加特性を追加(2023-08-08~)
|
|
25
|
-
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : []
|
|
22
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
|
|
26
23
|
},
|
|
27
24
|
object: transactionObject,
|
|
28
|
-
expiresInSeconds
|
|
25
|
+
expiresInSeconds
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
28
|
exports.createStartParams = createStartParams;
|
|
@@ -2,6 +2,10 @@ import * as factory from '../../../../factory';
|
|
|
2
2
|
export declare function validateSeller(params: {
|
|
3
3
|
seller: Pick<factory.seller.ISeller, 'makesOffer'>;
|
|
4
4
|
clientUser?: factory.clientUser.IClientUser;
|
|
5
|
+
/**
|
|
6
|
+
* passportによって決定するカスタマータイプ
|
|
7
|
+
*/
|
|
8
|
+
customerType?: string;
|
|
5
9
|
}): {
|
|
6
10
|
makesOfferFromClient: factory.seller.IMakesOffer;
|
|
7
11
|
};
|
|
@@ -5,6 +5,8 @@ const factory = require("../../../../factory");
|
|
|
5
5
|
function validateSeller(params) {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
const clientId = (_a = params.clientUser) === null || _a === void 0 ? void 0 : _a.client_id;
|
|
8
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
9
|
+
/* istanbul ignore if */
|
|
8
10
|
if (typeof clientId !== 'string' || clientId.length === 0) {
|
|
9
11
|
throw new factory.errors.ArgumentNull('client_id');
|
|
10
12
|
}
|
|
@@ -15,6 +17,14 @@ function validateSeller(params) {
|
|
|
15
17
|
if (makesOfferFromClient === undefined) {
|
|
16
18
|
throw new factory.errors.Argument('seller', 'makes no offers');
|
|
17
19
|
}
|
|
20
|
+
// eligibleCustomerType検証(2023-11-20~)
|
|
21
|
+
if (typeof params.customerType === 'string') {
|
|
22
|
+
const isCustomerTypeEligible = Array.isArray(makesOfferFromClient.eligibleCustomerType)
|
|
23
|
+
&& makesOfferFromClient.eligibleCustomerType.some((categoryCode) => categoryCode.codeValue === params.customerType);
|
|
24
|
+
if (!isCustomerTypeEligible) {
|
|
25
|
+
throw new factory.errors.Argument('seller', 'cutomer type ineligible');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
18
28
|
return { makesOfferFromClient };
|
|
19
29
|
}
|
|
20
30
|
exports.validateSeller = validateSeller;
|
|
@@ -23,7 +23,9 @@ export interface IConfirmOperationRepos {
|
|
|
23
23
|
}
|
|
24
24
|
export type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
|
|
25
25
|
export type IPassportValidator = IWaiterPassportValidator;
|
|
26
|
-
export type IStartParams = PlaceOrderFactory.IStartParams
|
|
26
|
+
export type IStartParams = PlaceOrderFactory.IStartParams & {
|
|
27
|
+
validateEligibleCustomerType: boolean;
|
|
28
|
+
};
|
|
27
29
|
/**
|
|
28
30
|
* 取引開始
|
|
29
31
|
*/
|
|
@@ -30,6 +30,7 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
|
30
30
|
function start(params) {
|
|
31
31
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
var _a;
|
|
33
|
+
const { passport, customerType } = yield (0, validation_2.validateWaiterPassport)(params);
|
|
33
34
|
const sellers = yield repos.seller.search({
|
|
34
35
|
limit: 1,
|
|
35
36
|
page: 1,
|
|
@@ -40,15 +41,15 @@ function start(params) {
|
|
|
40
41
|
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
41
42
|
}
|
|
42
43
|
let makesOfferFromClient;
|
|
43
|
-
const validateSellerResult = (0, validateSeller_1.validateSeller)({ seller, clientUser: params.object.clientUser }
|
|
44
|
+
const validateSellerResult = (0, validateSeller_1.validateSeller)(Object.assign({ seller, clientUser: params.object.clientUser }, (params.validateEligibleCustomerType === true
|
|
45
|
+
&& typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { customerType } : undefined));
|
|
44
46
|
makesOfferFromClient = validateSellerResult.makesOfferFromClient;
|
|
45
|
-
const passport = yield (0, validation_2.validateWaiterPassport)(params);
|
|
46
47
|
const expiresInSeconds = (_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue;
|
|
47
48
|
if (typeof expiresInSeconds !== 'number') {
|
|
48
49
|
throw new factory.errors.NotFound('eligibleTransactionDuration.maxValue');
|
|
49
50
|
}
|
|
50
51
|
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
51
|
-
const startParams = (0, factory_1.createStartParams)(params, expiresInSeconds, passport, seller, params.broker);
|
|
52
|
+
const startParams = (0, factory_1.createStartParams)(params, expiresInSeconds, passport, seller, params.broker, customerType);
|
|
52
53
|
let transaction;
|
|
53
54
|
try {
|
|
54
55
|
transaction = yield repos.transaction.start(startParams);
|
|
@@ -3,4 +3,7 @@ import { IPassportValidator } from '../../factory/transaction';
|
|
|
3
3
|
export type IStartParams = (factory.transaction.placeOrder.IStartParamsWithoutDetail | factory.transaction.moneyTransfer.IStartParamsWithoutDetail) & {
|
|
4
4
|
passportValidator?: IPassportValidator;
|
|
5
5
|
};
|
|
6
|
-
export declare function validateWaiterPassport(params: IStartParams): Promise<
|
|
6
|
+
export declare function validateWaiterPassport(params: IStartParams): Promise<{
|
|
7
|
+
passport: factory.waiter.passport.IPassport | undefined;
|
|
8
|
+
customerType?: string;
|
|
9
|
+
}>;
|
|
@@ -19,6 +19,7 @@ function validateWaiterPassport(params) {
|
|
|
19
19
|
var _a, _b;
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
let passport;
|
|
22
|
+
let customerType;
|
|
22
23
|
// WAITER許可証トークンがあれば検証する
|
|
23
24
|
if (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.passport) === null || _b === void 0 ? void 0 : _b.token) === 'string') {
|
|
24
25
|
try {
|
|
@@ -36,8 +37,13 @@ function validateWaiterPassport(params) {
|
|
|
36
37
|
throw new factory.errors.Argument('Passport Token', 'Invalid passport');
|
|
37
38
|
}
|
|
38
39
|
}
|
|
40
|
+
// カスタマータイプ決定(2023-11-20~)
|
|
41
|
+
// スコープのフォーマットは、Transaction:${TransactionType}:${sellerId}:${customerType}
|
|
42
|
+
const splittedScope = passport.scope.split(':');
|
|
43
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
+
customerType = splittedScope[3];
|
|
39
45
|
}
|
|
40
|
-
return passport;
|
|
46
|
+
return { customerType, passport };
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
exports.validateWaiterPassport = validateWaiterPassport;
|
package/package.json
CHANGED