@chevre/domain 21.21.0-alpha.9 → 21.21.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/migrateDeleteTransactionTasks.ts +2 -2
- package/example/src/chevre/playAroundProjectMakesOffer.ts +47 -0
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/orderInTransaction.d.ts +0 -2
- package/lib/chevre/repo/orderInTransaction.js +8 -9
- package/lib/chevre/repo/project.d.ts +1 -0
- package/lib/chevre/repo/project.js +13 -8
- package/lib/chevre/repo/projectMakesOffer.d.ts +52 -0
- package/lib/chevre/repo/projectMakesOffer.js +133 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/order/placeOrder.js +131 -105
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +0 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +7 -10
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +6 -5
- package/lib/chevre/service/transaction/validation.d.ts +5 -0
- package/lib/chevre/service/transaction/validation.js +55 -3
- package/lib/chevre/settings.d.ts +0 -2
- package/lib/chevre/settings.js +1 -3
- package/package.json +3 -4
|
@@ -20,11 +20,11 @@ async function main() {
|
|
|
20
20
|
runsAt: {
|
|
21
21
|
$gte: moment()
|
|
22
22
|
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
-
.add(
|
|
23
|
+
.add(175, 'days')
|
|
24
24
|
.toDate(),
|
|
25
25
|
$lte: moment()
|
|
26
26
|
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
-
.add(
|
|
27
|
+
.add(200, 'days')
|
|
28
28
|
.toDate()
|
|
29
29
|
}
|
|
30
30
|
// _id: { $eq: '64aba5f37b8b8ef9eca60be5' }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const CLIENT_ID = 'xxxx';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const projectMakesOfferRepo = await chevre.repository.ProjectMakesOffer.createInstance(mongoose.connection);
|
|
13
|
+
const result = await projectMakesOfferRepo.search({
|
|
14
|
+
limit: 100,
|
|
15
|
+
page: 1,
|
|
16
|
+
offeredBy: { id: { $eq: project.id } },
|
|
17
|
+
availableAtOrFrom: { id: { $eq: CLIENT_ID } }
|
|
18
|
+
});
|
|
19
|
+
console.log('result:', result);
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
await projectMakesOfferRepo.create({
|
|
23
|
+
availableAtOrFrom: { id: CLIENT_ID },
|
|
24
|
+
offeredBy: { id: project.id }
|
|
25
|
+
});
|
|
26
|
+
console.log('offer created');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await projectMakesOfferRepo.updateOne({
|
|
32
|
+
availableAtOrFrom: { id: CLIENT_ID },
|
|
33
|
+
eligibleCustomerType: [{ codeValue: 'Enduser' }],
|
|
34
|
+
offeredBy: { id: project.id }
|
|
35
|
+
});
|
|
36
|
+
console.log('offer updated');
|
|
37
|
+
|
|
38
|
+
await projectMakesOfferRepo.deleteOne({
|
|
39
|
+
availableAtOrFrom: { id: CLIENT_ID },
|
|
40
|
+
offeredBy: { id: project.id }
|
|
41
|
+
});
|
|
42
|
+
console.log('offer deleted');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main()
|
|
46
|
+
.then(console.log)
|
|
47
|
+
.catch(console.error);
|
|
@@ -12,6 +12,7 @@ const schemaDefinition = {
|
|
|
12
12
|
alternateName: String,
|
|
13
13
|
logo: String,
|
|
14
14
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
15
|
+
makesOffer: [mongoose_1.SchemaTypes.Mixed],
|
|
15
16
|
name: String,
|
|
16
17
|
settings: mongoose_1.SchemaTypes.Mixed,
|
|
17
18
|
subscription: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -20,8 +20,6 @@ export declare class MongoRepository {
|
|
|
20
20
|
*/
|
|
21
21
|
placeOrder(order: Omit<factory.order.IOrder, 'id'> & {
|
|
22
22
|
acceptedOffers?: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
23
|
-
}, options: {
|
|
24
|
-
ignoreAccpetedOffersFromResult: boolean;
|
|
25
23
|
}): Promise<void>;
|
|
26
24
|
acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongodb").UpdateResult | undefined>;
|
|
27
25
|
/**
|
|
@@ -46,17 +46,16 @@ class MongoRepository {
|
|
|
46
46
|
/**
|
|
47
47
|
* 注文を受注する
|
|
48
48
|
*/
|
|
49
|
-
placeOrder(order
|
|
49
|
+
placeOrder(order
|
|
50
|
+
// options: {
|
|
51
|
+
// ignoreAccpetedOffersFromResult: boolean;
|
|
52
|
+
// }
|
|
53
|
+
) {
|
|
50
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
55
|
let setFields;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setFields = orderWithoutAcceptedOffers;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
setFields = order;
|
|
59
|
-
}
|
|
56
|
+
// acceptedOffersを上書きしない
|
|
57
|
+
const { acceptedOffers } = order, orderWithoutAcceptedOffers = __rest(order, ["acceptedOffers"]);
|
|
58
|
+
setFields = orderWithoutAcceptedOffers;
|
|
60
59
|
debug('placing an order...', order.orderNumber, 'setFields:', setFields);
|
|
61
60
|
// typeOf:PlaceOrderのドキュメントが存在すれば、typeOf:Orderに変更する
|
|
62
61
|
yield this.orderModel.updateOne({
|
|
@@ -73,14 +73,17 @@ class MongoRepository {
|
|
|
73
73
|
let projection = {};
|
|
74
74
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
75
75
|
inclusion.forEach((field) => {
|
|
76
|
-
|
|
76
|
+
if (String(field) !== 'makesOffer') {
|
|
77
|
+
projection[field] = 1;
|
|
78
|
+
}
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
else {
|
|
80
82
|
projection = {
|
|
81
83
|
__v: 0,
|
|
82
84
|
createdAt: 0,
|
|
83
|
-
updatedAt: 0
|
|
85
|
+
updatedAt: 0,
|
|
86
|
+
makesOffer: 0
|
|
84
87
|
};
|
|
85
88
|
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
86
89
|
exclusion.forEach((field) => {
|
|
@@ -109,9 +112,9 @@ class MongoRepository {
|
|
|
109
112
|
});
|
|
110
113
|
}
|
|
111
114
|
findByIdAndIUpdate(params) {
|
|
112
|
-
var _a, _b, _c, _d, _e, _f;
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
113
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
117
|
+
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({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
115
118
|
? { alternateName: params.alternateName }
|
|
116
119
|
: 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 ((_c = (_b = (_a = params.settings) === null || _a === void 0 ? void 0 : _a.sendEmailMessage) === null || _b === void 0 ? void 0 : _b.sender) === null || _c === void 0 ? void 0 : _c.email) === 'string')
|
|
117
120
|
? {
|
|
@@ -121,9 +124,11 @@ class MongoRepository {
|
|
|
121
124
|
}
|
|
122
125
|
: undefined), (typeof ((_d = params.settings) === null || _d === void 0 ? void 0 : _d.sendgridApiKey) === 'string')
|
|
123
126
|
? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
|
|
124
|
-
: undefined), (
|
|
127
|
+
: undefined), (Array.isArray((_e = params.settings) === null || _e === void 0 ? void 0 : _e.tokenIssuers))
|
|
128
|
+
? { 'settings.tokenIssuers': (_f = params.settings) === null || _f === void 0 ? void 0 : _f.tokenIssuers }
|
|
129
|
+
: undefined), (typeof ((_g = params.subscription) === null || _g === void 0 ? void 0 : _g.useEventServiceAsProduct) === 'boolean')
|
|
125
130
|
? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
|
|
126
|
-
: undefined), (typeof ((
|
|
131
|
+
: undefined), (typeof ((_h = params.hasMerchantReturnPolicy) === null || _h === void 0 ? void 0 : _h.sameAs) === 'string')
|
|
127
132
|
? { 'hasMerchantReturnPolicy.sameAs': params.hasMerchantReturnPolicy.sameAs }
|
|
128
133
|
: undefined), { $unset: {
|
|
129
134
|
'settings.cognito': 1 // 廃止(2023-11-10~)
|
|
@@ -133,12 +138,12 @@ class MongoRepository {
|
|
|
133
138
|
}
|
|
134
139
|
updateAggregateReservation(params) {
|
|
135
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
|
|
141
|
+
yield this.projectModel.findOneAndUpdate({ _id: params.id }, {
|
|
137
142
|
$set: Object.assign({ updatedAt: new Date() }, (params.aggregateReservation !== undefined) ? { aggregateReservation: params.aggregateReservation } : undefined),
|
|
138
143
|
$unset: {
|
|
139
144
|
noExistingAttributeName: 1 // $unsetは空だとエラーになるので
|
|
140
145
|
}
|
|
141
|
-
}, { new: true })
|
|
146
|
+
}, { new: true, projection: { _id: 1 } })
|
|
142
147
|
.exec();
|
|
143
148
|
});
|
|
144
149
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
type IMakesOffer = factory.project.IMakesOffer;
|
|
4
|
+
/**
|
|
5
|
+
* プロジェクト提供オファーリポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class MongoRepository {
|
|
8
|
+
private readonly projectModel;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
search(params: {
|
|
11
|
+
limit?: number;
|
|
12
|
+
page?: number;
|
|
13
|
+
offeredBy?: {
|
|
14
|
+
id?: {
|
|
15
|
+
$eq?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
availableAtOrFrom?: {
|
|
19
|
+
id?: {
|
|
20
|
+
$eq?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}): Promise<IMakesOffer[]>;
|
|
24
|
+
create(params: {
|
|
25
|
+
availableAtOrFrom: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
offeredBy: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
updateOne(params: {
|
|
33
|
+
availableAtOrFrom: {
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
eligibleCustomerType?: {
|
|
37
|
+
codeValue: string;
|
|
38
|
+
}[];
|
|
39
|
+
offeredBy: {
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
deleteOne(params: {
|
|
44
|
+
availableAtOrFrom: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
offeredBy: {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MongoRepository = void 0;
|
|
13
|
+
const project_1 = require("./mongoose/schemas/project");
|
|
14
|
+
const factory = require("../factory");
|
|
15
|
+
const settings_1 = require("../settings");
|
|
16
|
+
/**
|
|
17
|
+
* プロジェクト提供オファーリポジトリ
|
|
18
|
+
*/
|
|
19
|
+
class MongoRepository {
|
|
20
|
+
constructor(connection) {
|
|
21
|
+
this.projectModel = connection.model(project_1.modelName, (0, project_1.createSchema)());
|
|
22
|
+
}
|
|
23
|
+
search(params) {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const matchStages = [];
|
|
27
|
+
const offeredByIdEq = (_b = (_a = params.offeredBy) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
28
|
+
if (typeof offeredByIdEq === 'string') {
|
|
29
|
+
matchStages.push({ $match: { _id: { $eq: offeredByIdEq } } });
|
|
30
|
+
}
|
|
31
|
+
const availableAtOrFromIdEq = (_d = (_c = params.availableAtOrFrom) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
32
|
+
if (typeof availableAtOrFromIdEq === 'string') {
|
|
33
|
+
matchStages.push({ $match: { 'makesOffer.availableAtOrFrom.id': { $exists: true, $eq: availableAtOrFromIdEq } } });
|
|
34
|
+
}
|
|
35
|
+
const aggregate = this.projectModel.aggregate([
|
|
36
|
+
{
|
|
37
|
+
$unwind: {
|
|
38
|
+
path: '$makesOffer'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
...matchStages,
|
|
42
|
+
// { $sort: { 'makesOffer.availableAtOrFrom.id': factory.sortType.Ascending } },
|
|
43
|
+
{
|
|
44
|
+
$project: {
|
|
45
|
+
_id: 0,
|
|
46
|
+
typeOf: '$makesOffer.typeOf',
|
|
47
|
+
availableAtOrFrom: '$makesOffer.availableAtOrFrom',
|
|
48
|
+
eligibleCustomerType: '$makesOffer.eligibleCustomerType'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
53
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
54
|
+
aggregate.limit(params.limit * page)
|
|
55
|
+
.skip(params.limit * (page - 1));
|
|
56
|
+
}
|
|
57
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
58
|
+
.exec();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
create(params) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
let doc = yield this.projectModel.findOne({
|
|
64
|
+
_id: { $eq: params.offeredBy.id }
|
|
65
|
+
}, { _id: 1 })
|
|
66
|
+
.exec();
|
|
67
|
+
if (doc === null) {
|
|
68
|
+
throw new factory.errors.NotFound(factory.organizationType.Project);
|
|
69
|
+
}
|
|
70
|
+
const creatingMakesOffer = {
|
|
71
|
+
typeOf: factory.offerType.Offer,
|
|
72
|
+
availableAtOrFrom: [{ id: params.availableAtOrFrom.id }]
|
|
73
|
+
};
|
|
74
|
+
doc = yield this.projectModel.findOneAndUpdate({
|
|
75
|
+
_id: { $eq: params.offeredBy.id },
|
|
76
|
+
'makesOffer.availableAtOrFrom.id': { $ne: params.availableAtOrFrom.id }
|
|
77
|
+
}, {
|
|
78
|
+
$push: { makesOffer: creatingMakesOffer }
|
|
79
|
+
}, {
|
|
80
|
+
projection: { _id: 1 }
|
|
81
|
+
})
|
|
82
|
+
.exec();
|
|
83
|
+
if (doc === null) {
|
|
84
|
+
throw new factory.errors.AlreadyInUse('makesOffer', ['availableAtOrFrom.id']);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
updateOne(params) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const updatingMakesOffer = Object.assign({ typeOf: factory.offerType.Offer, availableAtOrFrom: [{ id: params.availableAtOrFrom.id }] }, (Array.isArray(params.eligibleCustomerType))
|
|
91
|
+
? {
|
|
92
|
+
eligibleCustomerType: params.eligibleCustomerType.map(({ codeValue }) => ({
|
|
93
|
+
codeValue,
|
|
94
|
+
typeOf: 'CategoryCode'
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
: undefined);
|
|
98
|
+
const doc = yield this.projectModel.findOneAndUpdate({
|
|
99
|
+
_id: { $eq: params.offeredBy.id },
|
|
100
|
+
'makesOffer.availableAtOrFrom.id': { $exists: true, $eq: params.availableAtOrFrom.id }
|
|
101
|
+
}, {
|
|
102
|
+
$set: { 'makesOffer.$[makesOfferElement]': updatingMakesOffer }
|
|
103
|
+
}, {
|
|
104
|
+
new: true,
|
|
105
|
+
arrayFilters: [
|
|
106
|
+
{ 'makesOfferElement.availableAtOrFrom.id': { $eq: params.availableAtOrFrom.id } }
|
|
107
|
+
],
|
|
108
|
+
projection: { _id: 1 }
|
|
109
|
+
})
|
|
110
|
+
.exec();
|
|
111
|
+
if (doc === null) {
|
|
112
|
+
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
deleteOne(params) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const doc = yield this.projectModel.findOneAndUpdate({
|
|
119
|
+
_id: { $eq: params.offeredBy.id },
|
|
120
|
+
'makesOffer.availableAtOrFrom.id': { $exists: true, $eq: params.availableAtOrFrom.id }
|
|
121
|
+
}, {
|
|
122
|
+
$pull: { makesOffer: { 'availableAtOrFrom.id': params.availableAtOrFrom.id } }
|
|
123
|
+
}, {
|
|
124
|
+
projection: { _id: 1 }
|
|
125
|
+
})
|
|
126
|
+
.exec();
|
|
127
|
+
if (doc === null) {
|
|
128
|
+
throw new factory.errors.NotFound(factory.organizationType.Project);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -37,6 +37,7 @@ import type { MongoRepository as PriceSpecificationRepo } from './repo/priceSpec
|
|
|
37
37
|
import type { MongoRepository as ProductRepo } from './repo/product';
|
|
38
38
|
import type { MongoRepository as ProductOfferRepo } from './repo/productOffer';
|
|
39
39
|
import type { MongoRepository as ProjectRepo } from './repo/project';
|
|
40
|
+
import type { MongoRepository as ProjectMakesOfferRepo } from './repo/projectMakesOffer';
|
|
40
41
|
import type { RedisRepository as OfferRateLimitRepo } from './repo/rateLimit/offer';
|
|
41
42
|
import type { MongoRepository as ReservationRepo } from './repo/reservation';
|
|
42
43
|
import type { MongoRepository as RoleRepo } from './repo/role';
|
|
@@ -221,6 +222,10 @@ export type Project = ProjectRepo;
|
|
|
221
222
|
export declare namespace Project {
|
|
222
223
|
function createInstance(...params: ConstructorParameters<typeof ProjectRepo>): Promise<ProjectRepo>;
|
|
223
224
|
}
|
|
225
|
+
export type ProjectMakesOffer = ProjectMakesOfferRepo;
|
|
226
|
+
export declare namespace ProjectMakesOffer {
|
|
227
|
+
function createInstance(...params: ConstructorParameters<typeof ProjectMakesOfferRepo>): Promise<ProjectMakesOfferRepo>;
|
|
228
|
+
}
|
|
224
229
|
export type Reservation = ReservationRepo;
|
|
225
230
|
export declare namespace Reservation {
|
|
226
231
|
function createInstance(...params: ConstructorParameters<typeof ReservationRepo>): Promise<ReservationRepo>;
|
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.TransactionNumber = void 0;
|
|
12
|
+
exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -537,6 +537,19 @@ var Project;
|
|
|
537
537
|
}
|
|
538
538
|
Project.createInstance = createInstance;
|
|
539
539
|
})(Project = exports.Project || (exports.Project = {}));
|
|
540
|
+
var ProjectMakesOffer;
|
|
541
|
+
(function (ProjectMakesOffer) {
|
|
542
|
+
let repo;
|
|
543
|
+
function createInstance(...params) {
|
|
544
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
545
|
+
if (repo === undefined) {
|
|
546
|
+
repo = (yield Promise.resolve().then(() => require('./repo/projectMakesOffer'))).MongoRepository;
|
|
547
|
+
}
|
|
548
|
+
return new repo(...params);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
ProjectMakesOffer.createInstance = createInstance;
|
|
552
|
+
})(ProjectMakesOffer = exports.ProjectMakesOffer || (exports.ProjectMakesOffer = {}));
|
|
540
553
|
var Reservation;
|
|
541
554
|
(function (Reservation) {
|
|
542
555
|
let repo;
|
|
@@ -14,59 +14,79 @@ const createDebug = require("debug");
|
|
|
14
14
|
const moment = require("moment");
|
|
15
15
|
const factory = require("../../factory");
|
|
16
16
|
const order_1 = require("../../factory/order");
|
|
17
|
-
const settings_1 = require("../../settings");
|
|
18
17
|
const onAssetTransactionStatusChanged_1 = require("./onAssetTransactionStatusChanged");
|
|
19
18
|
const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
20
19
|
const debug = createDebug('chevre-domain:service:order');
|
|
21
20
|
function createOrder(params) {
|
|
22
21
|
// 必要な属性についてDate型に変換(でないと検索クエリを効率的に使えない)
|
|
23
|
-
const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
22
|
+
// const acceptedOffers = (Array.isArray(params.acceptedOffers))
|
|
23
|
+
// ? params.acceptedOffers.map((o) => {
|
|
24
|
+
// if (o.itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
25
|
+
// let itemOffered = o.itemOffered;
|
|
26
|
+
// const reservationFor = itemOffered.reservationFor;
|
|
27
|
+
// itemOffered = {
|
|
28
|
+
// ...itemOffered,
|
|
29
|
+
// reservationFor: {
|
|
30
|
+
// ...reservationFor,
|
|
31
|
+
// ...(reservationFor.doorTime !== undefined && reservationFor.doorTime !== null)
|
|
32
|
+
// ? {
|
|
33
|
+
// doorTime: moment(reservationFor.doorTime)
|
|
34
|
+
// .toDate()
|
|
35
|
+
// }
|
|
36
|
+
// : undefined,
|
|
37
|
+
// ...(reservationFor.endDate !== undefined)
|
|
38
|
+
// ? {
|
|
39
|
+
// endDate: moment(reservationFor.endDate)
|
|
40
|
+
// .toDate()
|
|
41
|
+
// }
|
|
42
|
+
// : undefined,
|
|
43
|
+
// ...(reservationFor.startDate !== undefined)
|
|
44
|
+
// ? {
|
|
45
|
+
// startDate: moment(reservationFor.startDate)
|
|
46
|
+
// .toDate()
|
|
47
|
+
// }
|
|
48
|
+
// : undefined
|
|
49
|
+
// }
|
|
50
|
+
// };
|
|
51
|
+
// return {
|
|
52
|
+
// ...o,
|
|
53
|
+
// itemOffered
|
|
54
|
+
// };
|
|
55
|
+
// } else if (o.itemOffered.typeOf === factory.reservationType.BusReservation) {
|
|
56
|
+
// let itemOffered = o.itemOffered;
|
|
57
|
+
// const reservationFor = itemOffered.reservationFor;
|
|
58
|
+
// itemOffered = {
|
|
59
|
+
// ...itemOffered,
|
|
60
|
+
// reservationFor: {
|
|
61
|
+
// ...reservationFor,
|
|
62
|
+
// ...(reservationFor.arrivalTime !== undefined)
|
|
63
|
+
// ? {
|
|
64
|
+
// arrivalTime: moment(reservationFor.arrivalTime)
|
|
65
|
+
// .toDate()
|
|
66
|
+
// }
|
|
67
|
+
// : undefined,
|
|
68
|
+
// ...(reservationFor.departureTime !== undefined)
|
|
69
|
+
// ? {
|
|
70
|
+
// departureTime: moment(reservationFor.departureTime)
|
|
71
|
+
// .toDate()
|
|
72
|
+
// }
|
|
73
|
+
// : undefined
|
|
74
|
+
// }
|
|
75
|
+
// };
|
|
76
|
+
// return {
|
|
77
|
+
// ...o,
|
|
78
|
+
// itemOffered
|
|
79
|
+
// };
|
|
80
|
+
// } else {
|
|
81
|
+
// return o;
|
|
82
|
+
// }
|
|
83
|
+
// })
|
|
84
|
+
// : [];
|
|
67
85
|
const orderedItems = (Array.isArray(params.orderedItem)) ? params.orderedItem : [];
|
|
68
86
|
return Object.assign(Object.assign(Object.assign({}, params), { orderDate: moment(params.orderDate)
|
|
69
|
-
.toDate(),
|
|
87
|
+
.toDate(),
|
|
88
|
+
// acceptedOffers,
|
|
89
|
+
orderedItem: orderedItems }), (params.dateReturned !== null && params.dateReturned !== undefined)
|
|
70
90
|
? {
|
|
71
91
|
dateReturned: moment(params.dateReturned)
|
|
72
92
|
.toDate()
|
|
@@ -210,61 +230,67 @@ function voidAcceptedOfferIfNecessary(params) {
|
|
|
210
230
|
}
|
|
211
231
|
});
|
|
212
232
|
}
|
|
213
|
-
function verifyAcceptedOffers(params
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
233
|
+
// function verifyAcceptedOffers(params: {
|
|
234
|
+
// order: factory.order.IOrder & {
|
|
235
|
+
// acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
236
|
+
// };
|
|
237
|
+
// }) {
|
|
238
|
+
// return async (repos: {
|
|
239
|
+
// orderInTransaction: OrderInTransactionRepo;
|
|
240
|
+
// }) => {
|
|
241
|
+
// const { order } = params;
|
|
242
|
+
// const orderInTransaction = (await repos.orderInTransaction.searchByOrderNumber({
|
|
243
|
+
// orderNumber: { $eq: order.orderNumber }
|
|
244
|
+
// })).shift();
|
|
245
|
+
// if (orderInTransaction !== undefined) {
|
|
246
|
+
// debug('verifying acceptedOffers...', order.orderNumber);
|
|
247
|
+
// const acceptedOffersLengthMatched = orderInTransaction.acceptedOffers.length === order.acceptedOffers.length;
|
|
248
|
+
// debug('acceptedOffers.length matched?', acceptedOffersLengthMatched);
|
|
249
|
+
// if (!acceptedOffersLengthMatched) {
|
|
250
|
+
// throw new factory.errors.ServiceUnavailable('acceptedOffers.length not matched');
|
|
251
|
+
// }
|
|
252
|
+
// const reservationIdsByOrderInTransation = orderInTransaction.acceptedOffers.map((offer) => {
|
|
253
|
+
// return (offer.itemOffered.typeOf === factory.reservationType.EventReservation)
|
|
254
|
+
// ? offer.itemOffered.id
|
|
255
|
+
// : '';
|
|
256
|
+
// });
|
|
257
|
+
// const reservationIdsByOrder = order.acceptedOffers.map((offer) => {
|
|
258
|
+
// return (offer.itemOffered.typeOf === factory.reservationType.EventReservation)
|
|
259
|
+
// ? offer.itemOffered.id
|
|
260
|
+
// : '';
|
|
261
|
+
// });
|
|
262
|
+
// debug('reservationIdsByOrderInTransation:', reservationIdsByOrderInTransation);
|
|
263
|
+
// debug('reservationIdsByOrder:', reservationIdsByOrder);
|
|
264
|
+
// const offerIdsByOrderInTransation = [...new Set(orderInTransaction.acceptedOffers.map((offer) => {
|
|
265
|
+
// return String(offer.id);
|
|
266
|
+
// }))];
|
|
267
|
+
// const offerIdsByOrder = [...new Set(order.acceptedOffers.map((offer) => {
|
|
268
|
+
// return String(offer.id);
|
|
269
|
+
// }))];
|
|
270
|
+
// debug('offerIdsByOrderInTransation:', offerIdsByOrderInTransation);
|
|
271
|
+
// debug('offerIdsByOrder:', offerIdsByOrder);
|
|
272
|
+
// const reservationIdsMatched = reservationIdsByOrderInTransation.length === reservationIdsByOrder.length
|
|
273
|
+
// && reservationIdsByOrderInTransation.every((reservationId) => reservationIdsByOrder.includes(reservationId));
|
|
274
|
+
// debug('reservationIds matched?', reservationIdsMatched);
|
|
275
|
+
// const offerIdsMatched = offerIdsByOrderInTransation.length === offerIdsByOrder.length
|
|
276
|
+
// && offerIdsByOrderInTransation.every((offerId) => offerIdsByOrder.includes(offerId));
|
|
277
|
+
// debug('offerIds matched?', offerIdsMatched);
|
|
278
|
+
// if (!reservationIdsMatched) {
|
|
279
|
+
// throw new factory.errors.ServiceUnavailable('reservationIds not matched');
|
|
280
|
+
// }
|
|
281
|
+
// if (!offerIdsMatched) {
|
|
282
|
+
// throw new factory.errors.ServiceUnavailable('offerIds not matched');
|
|
283
|
+
// }
|
|
284
|
+
// }
|
|
285
|
+
// };
|
|
286
|
+
// }
|
|
261
287
|
/**
|
|
262
288
|
* 注文を作成する
|
|
263
289
|
*/
|
|
264
290
|
function placeOrder(params) {
|
|
265
291
|
// tslint:disable-next-line:max-func-body-length
|
|
266
292
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
267
|
-
var _a
|
|
293
|
+
var _a;
|
|
268
294
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
269
295
|
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
270
296
|
}
|
|
@@ -326,17 +352,17 @@ function placeOrder(params) {
|
|
|
326
352
|
purpose: placeOrderTransaction
|
|
327
353
|
})(repos);
|
|
328
354
|
// acceptedOffersの内容検証(開発)
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
const ignoreAccpetedOffersFromResult =
|
|
355
|
+
// if (USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT) {
|
|
356
|
+
// if (USE_VERIFY_ACCEPTED_OFFERS) {
|
|
357
|
+
// await verifyAcceptedOffers({ order })(repos);
|
|
358
|
+
// }
|
|
359
|
+
// }
|
|
360
|
+
// const ignoreAccpetedOffersFromResult = placeOrderTransaction.result?.options?.ignoreAccpetedOffersFromResult === true;
|
|
335
361
|
// orderInTransactionを考慮(2024-01-14~)
|
|
336
|
-
yield repos.orderInTransaction.placeOrder(order
|
|
337
|
-
if (!ignoreAccpetedOffersFromResult) {
|
|
338
|
-
|
|
339
|
-
}
|
|
362
|
+
yield repos.orderInTransaction.placeOrder(order);
|
|
363
|
+
// if (!ignoreAccpetedOffersFromResult) {
|
|
364
|
+
// await repos.order.createIfNotExist(order);
|
|
365
|
+
// }
|
|
340
366
|
}
|
|
341
367
|
catch (error) {
|
|
342
368
|
try {
|
|
@@ -19,10 +19,6 @@ interface IConfirmOperationRepos {
|
|
|
19
19
|
type IConfirmOperation<T> = (repos: IConfirmOperationRepos) => Promise<T>;
|
|
20
20
|
type IConfirmParams = PlaceOrderFactory.IConfirmParams & {
|
|
21
21
|
options: {
|
|
22
|
-
/**
|
|
23
|
-
* 取引resultから注文オファーを作成するかどうか
|
|
24
|
-
*/
|
|
25
|
-
ignoreAccpetedOffersFromResult: boolean;
|
|
26
22
|
/**
|
|
27
23
|
* 確定レスポンスに予約IDを含めるかどうか(ttts対応)
|
|
28
24
|
*/
|
|
@@ -24,7 +24,6 @@ exports.confirm = void 0;
|
|
|
24
24
|
const moment = require("moment");
|
|
25
25
|
const errorHandler_1 = require("../../../errorHandler");
|
|
26
26
|
const factory = require("../../../factory");
|
|
27
|
-
const settings_1 = require("../../../settings");
|
|
28
27
|
const potentialActions_1 = require("./potentialActions");
|
|
29
28
|
const publishCode_1 = require("./publishCode");
|
|
30
29
|
const publishConfirmationNumberIfNotExist_1 = require("./publishConfirmationNumberIfNotExist");
|
|
@@ -151,7 +150,6 @@ function createReservationIdsResult(order) {
|
|
|
151
150
|
return { eventId, reservationIds };
|
|
152
151
|
}
|
|
153
152
|
function createResult(params) {
|
|
154
|
-
var _a;
|
|
155
153
|
const transaction = params.transaction;
|
|
156
154
|
// 取引の確定条件が全て整っているかどうか確認
|
|
157
155
|
(0, validation_1.validateTransaction)(transaction, params.authorizeActions);
|
|
@@ -194,13 +192,12 @@ function createResult(params) {
|
|
|
194
192
|
order.url = url;
|
|
195
193
|
const authorizeActions = params.authorizeActions.map(({ id }) => ({ id }));
|
|
196
194
|
let orderAsResult;
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
195
|
+
// if (USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT) {
|
|
196
|
+
// orderAsResult = order;
|
|
197
|
+
// } else {
|
|
198
|
+
// }
|
|
199
|
+
const { acceptedOffers } = order, orderWithoutAcceptedOffers = __rest(order, ["acceptedOffers"]);
|
|
200
|
+
orderAsResult = orderWithoutAcceptedOffers;
|
|
204
201
|
let eventId;
|
|
205
202
|
let reservationIds;
|
|
206
203
|
if (params.options.expectsReservationIds) {
|
|
@@ -212,7 +209,7 @@ function createResult(params) {
|
|
|
212
209
|
return {
|
|
213
210
|
orderWithAcceptedOffers: order,
|
|
214
211
|
result: Object.assign({ order: orderAsResult, authorizeActions, numAcceptedOffers: order.acceptedOffers.length, options: {
|
|
215
|
-
ignoreAccpetedOffersFromResult:
|
|
212
|
+
ignoreAccpetedOffersFromResult: true
|
|
216
213
|
} }, (typeof params.code === 'string') ? { code: params.code } : undefined),
|
|
217
214
|
eventId,
|
|
218
215
|
reservationIds
|
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js
CHANGED
|
@@ -15,13 +15,13 @@ const factory = require("../../../../factory");
|
|
|
15
15
|
function verifyMembershipToken(params) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
let result;
|
|
18
|
-
const { secret, token } = params;
|
|
18
|
+
const { issuer, secret, token } = params;
|
|
19
19
|
if (typeof token === 'string' && token.length > 0) {
|
|
20
20
|
try {
|
|
21
21
|
result = yield new Promise((resolve, reject) => {
|
|
22
22
|
jwt.verify(token, secret, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
issuer
|
|
24
|
+
// ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
25
25
|
}, (err, decoded) => {
|
|
26
26
|
if (err instanceof Error) {
|
|
27
27
|
reject(err);
|
|
@@ -51,7 +51,7 @@ function verifyMembershipToken(params) {
|
|
|
51
51
|
}
|
|
52
52
|
function validateStartRequest(params) {
|
|
53
53
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a, _b, _c, _d;
|
|
54
|
+
var _a, _b, _c, _d, _e, _f;
|
|
55
55
|
const sellers = yield repos.seller.search({
|
|
56
56
|
limit: 1,
|
|
57
57
|
page: 1,
|
|
@@ -103,8 +103,9 @@ function validateStartRequest(params) {
|
|
|
103
103
|
let memeberOfPayload;
|
|
104
104
|
if (Array.isArray(iamMember.member.member)) {
|
|
105
105
|
const verifySecret = (_d = (_c = iamMember.member.member[0]) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.secret; // ひとまず1種類のメンバーシップのみ対応
|
|
106
|
+
const verifyIssuer = (_f = (_e = iamMember.member.member[0]) === null || _e === void 0 ? void 0 : _e.memberOf) === null || _f === void 0 ? void 0 : _f.issuer; // ひとまず1種類のメンバーシップのみ対応
|
|
106
107
|
if (typeof verifySecret === 'string') {
|
|
107
|
-
memeberOfPayload = yield verifyMembershipToken({ token: params.memberOfToken, secret: verifySecret });
|
|
108
|
+
memeberOfPayload = yield verifyMembershipToken({ token: params.memberOfToken, secret: verifySecret, issuer: verifyIssuer });
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
return { makesOfferFromClient, memeberOfPayload, seller };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 取引バリデーション
|
|
3
|
+
*/
|
|
4
|
+
import * as jwt from 'jsonwebtoken';
|
|
1
5
|
import * as factory from '../../factory';
|
|
2
6
|
import { IPassportValidator } from '../../factory/transaction';
|
|
3
7
|
export type IStartParams = (factory.transaction.placeOrder.IStartParamsWithoutDetail | factory.transaction.moneyTransfer.IStartParamsWithoutDetail) & {
|
|
4
8
|
passportValidator?: IPassportValidator;
|
|
5
9
|
};
|
|
10
|
+
export declare function createPassport(params: string | jwt.JwtPayload | undefined): factory.waiter.passport.IPassport;
|
|
6
11
|
export declare function validateWaiterPassport(params: IStartParams): Promise<{
|
|
7
12
|
passport: factory.waiter.passport.IPassport | undefined;
|
|
8
13
|
customerType?: string;
|
|
@@ -9,12 +9,64 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validateWaiterPassport = void 0;
|
|
12
|
+
exports.validateWaiterPassport = exports.createPassport = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 取引バリデーション
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
16
|
+
const jwt = require("jsonwebtoken");
|
|
17
17
|
const factory = require("../../factory");
|
|
18
|
+
function createPassport(params) {
|
|
19
|
+
var _a;
|
|
20
|
+
if (typeof params === 'string' || params === undefined) {
|
|
21
|
+
throw new factory.errors.Argument('decoded must be an object');
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line no-magic-numbers
|
|
24
|
+
if (typeof params.scope !== 'string' || params.scope.length === 0) {
|
|
25
|
+
throw new factory.errors.ArgumentNull('scope');
|
|
26
|
+
}
|
|
27
|
+
if (typeof params.iat !== 'number') {
|
|
28
|
+
throw new factory.errors.Argument('iat', 'iat must be number');
|
|
29
|
+
}
|
|
30
|
+
if (typeof params.exp !== 'number') {
|
|
31
|
+
throw new factory.errors.Argument('exp', 'exp must be number');
|
|
32
|
+
}
|
|
33
|
+
// eslint-disable-next-line no-magic-numbers
|
|
34
|
+
if (typeof params.iss !== 'string' || params.iss.length === 0) {
|
|
35
|
+
throw new factory.errors.ArgumentNull('iss');
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-magic-numbers
|
|
38
|
+
if (typeof ((_a = params.issueUnit) === null || _a === void 0 ? void 0 : _a.identifier) !== 'string' || params.issueUnit.identifier.length === 0) {
|
|
39
|
+
throw new factory.errors.Argument('issueUnit.identifier', 'issueUnit.identifier must be string');
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
42
|
+
if (typeof params.issueUnit.numberOfRequests !== 'number') {
|
|
43
|
+
throw new factory.errors.Argument('issueUnit.numberOfRequests', 'issueUnit.numberOfRequests must be number');
|
|
44
|
+
}
|
|
45
|
+
return Object.assign({ scope: params.scope, iat: params.iat, exp: params.exp, iss: params.iss,
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
47
|
+
project: params.project,
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
49
|
+
issueUnit: params.issueUnit }, (Array.isArray(params.aud)) ? { aud: params.aud } : undefined);
|
|
50
|
+
}
|
|
51
|
+
exports.createPassport = createPassport;
|
|
52
|
+
/**
|
|
53
|
+
* 暗号化された許可証を検証する
|
|
54
|
+
*/
|
|
55
|
+
function verify(params) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
jwt.verify(params.token, params.secret, (err, decoded) => {
|
|
59
|
+
if (err instanceof Error) {
|
|
60
|
+
reject(err);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const passport = createPassport(decoded);
|
|
64
|
+
resolve(passport);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
18
70
|
function validateWaiterPassport(params) {
|
|
19
71
|
var _a, _b;
|
|
20
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -23,7 +75,7 @@ function validateWaiterPassport(params) {
|
|
|
23
75
|
// WAITER許可証トークンがあれば検証する
|
|
24
76
|
if (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.passport) === null || _b === void 0 ? void 0 : _b.token) === 'string') {
|
|
25
77
|
try {
|
|
26
|
-
passport = yield
|
|
78
|
+
passport = yield verify({
|
|
27
79
|
token: params.object.passport.token,
|
|
28
80
|
secret: params.object.passport.secret
|
|
29
81
|
});
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,8 +40,6 @@ export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
|
|
|
40
40
|
export declare const USE_FETCH_API: boolean;
|
|
41
41
|
export declare const USE_INFORM_ORDER_IN_TRANSIT: boolean;
|
|
42
42
|
export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
|
|
43
|
-
export declare const USE_VERIFY_ACCEPTED_OFFERS: boolean;
|
|
44
|
-
export declare const USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT: boolean;
|
|
45
43
|
export declare const USE_MINIMIZED_PAY_TASK: boolean;
|
|
46
44
|
export declare const USE_KANA_NAME_IN_ACCEPTED_OFFER: boolean;
|
|
47
45
|
export declare const MONGO_MAX_TIME_MS: number;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = exports.USE_MINIMIZED_PAY_TASK = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_INFORM_ORDER_IN_TRANSIT = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -64,8 +64,6 @@ exports.USE_OPTIMIZE_TICKET_OFFER = process.env.USE_OPTIMIZE_TICKET_OFFER === '1
|
|
|
64
64
|
exports.USE_FETCH_API = process.env.USE_FETCH_API === '1';
|
|
65
65
|
exports.USE_INFORM_ORDER_IN_TRANSIT = process.env.USE_INFORM_ORDER_IN_TRANSIT === '1';
|
|
66
66
|
exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = process.env.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING === '1';
|
|
67
|
-
exports.USE_VERIFY_ACCEPTED_OFFERS = process.env.USE_VERIFY_ACCEPTED_OFFERS === '1';
|
|
68
|
-
exports.USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT = process.env.USE_ACCEPTED_OFFERS_AS_TRANSACTION_RESULT === '1';
|
|
69
67
|
exports.USE_MINIMIZED_PAY_TASK = process.env.USE_MINIMIZED_PAY_TASK === '1';
|
|
70
68
|
exports.USE_KANA_NAME_IN_ACCEPTED_OFFER = process.env.USE_KANA_NAME_IN_ACCEPTED_OFFER === '1';
|
|
71
69
|
// export const USE_OPTIMIZED_CONFIRM_RESERVE_COA_TASK = process.env.USE_OPTIMIZED_CONFIRM_RESERVE_COA_TASK === '1';
|
package/package.json
CHANGED
|
@@ -10,13 +10,12 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
14
|
-
"@cinerino/sdk": "5.
|
|
13
|
+
"@chevre/factory": "4.355.0-alpha.1",
|
|
14
|
+
"@cinerino/sdk": "5.12.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.3.0-alpha.5",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.4",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
18
18
|
"@surfrock/sdk": "1.2.0",
|
|
19
|
-
"@waiter/domain": "6.4.0-alpha.4",
|
|
20
19
|
"cdigit": "2.6.7",
|
|
21
20
|
"debug": "^3.2.7",
|
|
22
21
|
"google-libphonenumber": "^3.2.18",
|
|
@@ -111,5 +110,5 @@
|
|
|
111
110
|
"postversion": "git push origin --tags",
|
|
112
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
113
112
|
},
|
|
114
|
-
"version": "21.21.0
|
|
113
|
+
"version": "21.21.0"
|
|
115
114
|
}
|