@chevre/domain 21.23.0-alpha.2 → 21.24.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/findReservationByCode.ts +19 -2
- package/example/src/chevre/migrateProjectMakesOffer.ts +13 -9
- package/lib/chevre/repo/code.d.ts +2 -5
- package/lib/chevre/repo/code.js +17 -44
- package/lib/chevre/repo/mongoose/schemas/authorization.js +9 -8
- package/lib/chevre/service/code.js +10 -13
- package/lib/chevre/service/reserve/findByCode.js +24 -30
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -4
- package/lib/chevre/service/reserve/useReservation.js +17 -16
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +12 -1
- package/lib/chevre/service/reserve/verifyToken4reservation.js +24 -6
- package/lib/chevre/service/reserve.d.ts +1 -2
- package/lib/chevre/service/reserve.js +2 -3
- package/lib/chevre/service/task/onAuthorizationCreated.js +2 -2
- package/lib/chevre/service/task/useReservation.js +2 -4
- package/package.json +2 -2
|
@@ -9,17 +9,34 @@ mongoose.Model.on('index', (...args) => {
|
|
|
9
9
|
console.error('******** index event emitted. ********\n', args);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
const CODE = '068cb0ba-8529-4a2b-8cf5-890d5af9c536';
|
|
13
|
+
const RESERVATION_ID = '589701779538948-0';
|
|
14
|
+
|
|
12
15
|
async function main() {
|
|
13
16
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
17
|
|
|
15
18
|
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
16
19
|
const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
|
|
20
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
17
21
|
const reservationRepo = await chevre.repository.Reservation.createInstance(mongoose.connection);
|
|
18
22
|
|
|
23
|
+
await (await chevre.service.reserve.createService()).verifyToken4reservation({
|
|
24
|
+
project: { id: project.id },
|
|
25
|
+
agent: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
26
|
+
reservationId: RESERVATION_ID,
|
|
27
|
+
ticket: {
|
|
28
|
+
ticketToken: CODE
|
|
29
|
+
}
|
|
30
|
+
})({
|
|
31
|
+
authorization: authorizationRepo,
|
|
32
|
+
order: orderRepo
|
|
33
|
+
});
|
|
34
|
+
console.log('verified.');
|
|
35
|
+
|
|
19
36
|
const result = await (await chevre.service.reserve.createService()).findByCode({
|
|
20
37
|
project: { id: project.id },
|
|
21
|
-
code:
|
|
22
|
-
id:
|
|
38
|
+
code: CODE,
|
|
39
|
+
id: RESERVATION_ID
|
|
23
40
|
})({
|
|
24
41
|
acceptedOffer: acceptedOfferRepo,
|
|
25
42
|
authorization: authorizationRepo,
|
|
@@ -8,8 +8,8 @@ enum ROLE_NAME {
|
|
|
8
8
|
Customer = 'customer',
|
|
9
9
|
POS = 'pos'
|
|
10
10
|
}
|
|
11
|
-
const CLIENT_ID = '
|
|
12
|
-
const CUSTOMER_TYPE = '
|
|
11
|
+
const CLIENT_ID = '5an0cmki8v29vdmk627kdo1r0p';
|
|
12
|
+
const CUSTOMER_TYPE = 'Enduser';
|
|
13
13
|
|
|
14
14
|
// tslint:disable-next-line:max-func-body-length
|
|
15
15
|
async function main() {
|
|
@@ -51,13 +51,17 @@ async function main() {
|
|
|
51
51
|
console.log(
|
|
52
52
|
'updating project...',
|
|
53
53
|
iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.name, i);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
try {
|
|
55
|
+
await makesOfferRepo.updateOne({
|
|
56
|
+
availableAtOrFrom: { id: iamMember.member.id },
|
|
57
|
+
eligibleCustomerType: [{
|
|
58
|
+
codeValue: CUSTOMER_TYPE
|
|
59
|
+
}],
|
|
60
|
+
offeredBy: { id: iamMember.project.id }
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
}
|
|
61
65
|
updateCount += 1;
|
|
62
66
|
console.log(
|
|
63
67
|
'updated.',
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
import { modelName } from './mongoose/schemas/authorization';
|
|
4
3
|
export type IObject = factory.authorization.IObject;
|
|
5
4
|
export type ICode = string;
|
|
6
|
-
export { modelName };
|
|
7
5
|
/**
|
|
8
6
|
* 承認コードリポジトリ
|
|
9
7
|
*/
|
|
@@ -24,12 +22,11 @@ export declare class MongoRepository {
|
|
|
24
22
|
expiresInSeconds: number;
|
|
25
23
|
}[]): Promise<factory.authorization.IAuthorization[]>;
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* コードで承認対象を検索する
|
|
28
26
|
*/
|
|
29
|
-
|
|
27
|
+
findValidObjectByCode(params: {
|
|
30
28
|
project: {
|
|
31
29
|
id: string;
|
|
32
|
-
typeOf: factory.organizationType.Project;
|
|
33
30
|
};
|
|
34
31
|
code: ICode;
|
|
35
32
|
}): Promise<IObject>;
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MongoRepository =
|
|
12
|
+
exports.MongoRepository = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const uuid = require("uuid");
|
|
15
15
|
const factory = require("../factory");
|
|
16
16
|
const authorization_1 = require("./mongoose/schemas/authorization");
|
|
17
|
-
Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return authorization_1.modelName; } });
|
|
18
17
|
const settings_1 = require("../settings");
|
|
19
18
|
/**
|
|
20
19
|
* 承認コードリポジトリ
|
|
@@ -55,20 +54,14 @@ class MongoRepository {
|
|
|
55
54
|
/* istanbul ignore else */
|
|
56
55
|
if (Array.isArray(object.ids)) {
|
|
57
56
|
andConditions.push({
|
|
58
|
-
'object.id': {
|
|
59
|
-
$exists: true,
|
|
60
|
-
$in: object.ids
|
|
61
|
-
}
|
|
57
|
+
'object.id': { $exists: true, $in: object.ids }
|
|
62
58
|
});
|
|
63
59
|
}
|
|
64
60
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
65
61
|
/* istanbul ignore else */
|
|
66
62
|
if (Array.isArray(object.typeOfs)) {
|
|
67
63
|
andConditions.push({
|
|
68
|
-
'object.typeOf': {
|
|
69
|
-
$exists: true,
|
|
70
|
-
$in: object.typeOfs
|
|
71
|
-
}
|
|
64
|
+
'object.typeOf': { $exists: true, $in: object.typeOfs }
|
|
72
65
|
});
|
|
73
66
|
}
|
|
74
67
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -78,20 +71,14 @@ class MongoRepository {
|
|
|
78
71
|
/* istanbul ignore else */
|
|
79
72
|
if (Array.isArray(object.typeOfGood.ids)) {
|
|
80
73
|
andConditions.push({
|
|
81
|
-
'object.typeOfGood.id': {
|
|
82
|
-
$exists: true,
|
|
83
|
-
$in: object.typeOfGood.ids
|
|
84
|
-
}
|
|
74
|
+
'object.typeOfGood.id': { $exists: true, $in: object.typeOfGood.ids }
|
|
85
75
|
});
|
|
86
76
|
}
|
|
87
77
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
88
78
|
/* istanbul ignore else */
|
|
89
79
|
if (Array.isArray(object.typeOfGood.typeOfs)) {
|
|
90
80
|
andConditions.push({
|
|
91
|
-
'object.typeOfGood.typeOf': {
|
|
92
|
-
$exists: true,
|
|
93
|
-
$in: object.typeOfGood.typeOfs
|
|
94
|
-
}
|
|
81
|
+
'object.typeOfGood.typeOf': { $exists: true, $in: object.typeOfGood.typeOfs }
|
|
95
82
|
});
|
|
96
83
|
}
|
|
97
84
|
}
|
|
@@ -102,7 +89,7 @@ class MongoRepository {
|
|
|
102
89
|
// });
|
|
103
90
|
// }
|
|
104
91
|
if (params.validFrom instanceof Date) {
|
|
105
|
-
andConditions.push({ validUntil: { $
|
|
92
|
+
andConditions.push({ validUntil: { $gte: params.validFrom } });
|
|
106
93
|
}
|
|
107
94
|
if (params.validThrough instanceof Date) {
|
|
108
95
|
andConditions.push({ validFrom: { $lte: params.validThrough } });
|
|
@@ -114,37 +101,30 @@ class MongoRepository {
|
|
|
114
101
|
*/
|
|
115
102
|
publish(params) {
|
|
116
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
const saveParams = params.map((
|
|
104
|
+
const saveParams = params.map(({ project, object, validFrom, expiresInSeconds }) => {
|
|
118
105
|
const code = uuid.v4();
|
|
119
|
-
return {
|
|
120
|
-
project: p.project,
|
|
121
|
-
code: code,
|
|
122
|
-
object: p.object,
|
|
123
|
-
validFrom: p.validFrom,
|
|
124
|
-
expiresInSeconds: p.expiresInSeconds
|
|
125
|
-
};
|
|
106
|
+
return { project, code, object, validFrom, expiresInSeconds };
|
|
126
107
|
});
|
|
127
108
|
return this.save(saveParams);
|
|
128
109
|
});
|
|
129
110
|
}
|
|
130
111
|
/**
|
|
131
|
-
*
|
|
112
|
+
* コードで承認対象を検索する
|
|
132
113
|
*/
|
|
133
|
-
|
|
114
|
+
findValidObjectByCode(params) {
|
|
134
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
116
|
const now = new Date();
|
|
136
117
|
const doc = yield this.authorizationModel.findOne({
|
|
137
118
|
'project.id': { $eq: params.project.id },
|
|
138
119
|
code: { $eq: String(params.code) },
|
|
139
120
|
validFrom: { $lte: now },
|
|
140
|
-
validUntil: { $
|
|
141
|
-
})
|
|
121
|
+
validUntil: { $gte: now }
|
|
122
|
+
}, { object: 1 })
|
|
142
123
|
.exec();
|
|
143
124
|
if (doc === null) {
|
|
144
125
|
throw new factory.errors.NotFound(this.authorizationModel.modelName);
|
|
145
126
|
}
|
|
146
|
-
|
|
147
|
-
return authorization.object;
|
|
127
|
+
return doc.object;
|
|
148
128
|
});
|
|
149
129
|
}
|
|
150
130
|
count(params) {
|
|
@@ -199,18 +179,11 @@ class MongoRepository {
|
|
|
199
179
|
save(params) {
|
|
200
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
181
|
if (params.length > 0) {
|
|
202
|
-
const docs = params.map((
|
|
203
|
-
const validUntil = moment(
|
|
204
|
-
.add(
|
|
182
|
+
const docs = params.map(({ project, code, object, validFrom, expiresInSeconds }) => {
|
|
183
|
+
const validUntil = moment(validFrom)
|
|
184
|
+
.add(expiresInSeconds, 'seconds')
|
|
205
185
|
.toDate();
|
|
206
|
-
return {
|
|
207
|
-
project: p.project,
|
|
208
|
-
typeOf: 'Authorization',
|
|
209
|
-
code: p.code,
|
|
210
|
-
object: p.object,
|
|
211
|
-
validFrom: p.validFrom,
|
|
212
|
-
validUntil: validUntil
|
|
213
|
-
};
|
|
186
|
+
return { project, typeOf: 'Authorization', code, object, validFrom, validUntil };
|
|
214
187
|
});
|
|
215
188
|
const result = yield this.authorizationModel.insertMany(docs, { ordered: false, rawResult: true });
|
|
216
189
|
if (result.insertedCount !== docs.length) {
|
|
@@ -7,7 +7,10 @@ const settings_1 = require("../../../settings");
|
|
|
7
7
|
const modelName = 'Authorization';
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
|
-
project:
|
|
10
|
+
project: {
|
|
11
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
11
14
|
typeOf: {
|
|
12
15
|
type: String,
|
|
13
16
|
required: true
|
|
@@ -21,7 +24,10 @@ const schemaDefinition = {
|
|
|
21
24
|
type: Date,
|
|
22
25
|
required: true
|
|
23
26
|
},
|
|
24
|
-
validUntil:
|
|
27
|
+
validUntil: {
|
|
28
|
+
type: Date,
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
25
31
|
};
|
|
26
32
|
const schemaOptions = {
|
|
27
33
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -84,12 +90,7 @@ const indexes = [
|
|
|
84
90
|
],
|
|
85
91
|
[
|
|
86
92
|
{ validUntil: 1, validFrom: 1 },
|
|
87
|
-
{
|
|
88
|
-
name: 'searchByValidUntil',
|
|
89
|
-
partialFilterExpression: {
|
|
90
|
-
validUntil: { $exists: true }
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
+
{ name: 'searchByValidUntil-v2' }
|
|
93
94
|
],
|
|
94
95
|
[
|
|
95
96
|
{ 'object.typeOf': 1, validFrom: 1 },
|
|
@@ -21,22 +21,19 @@ const credentials_1 = require("../credentials");
|
|
|
21
21
|
*/
|
|
22
22
|
function getToken(params) {
|
|
23
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
validFrom: now,
|
|
30
|
-
validThrough: now
|
|
31
|
-
});
|
|
32
|
-
const authorization = authorizations.shift();
|
|
33
|
-
if (authorization === undefined) {
|
|
34
|
-
throw new factory.errors.NotFound('Authorization');
|
|
24
|
+
if (typeof params.project.id !== 'string' || params.project.id.length === 0) {
|
|
25
|
+
throw new factory.errors.ArgumentNull('project.id');
|
|
26
|
+
}
|
|
27
|
+
if (typeof params.code !== 'string' || params.code.length === 0) {
|
|
28
|
+
throw new factory.errors.ArgumentNull('code');
|
|
35
29
|
}
|
|
36
|
-
const
|
|
30
|
+
const authorizationObject = yield repos.authorization.findValidObjectByCode({
|
|
31
|
+
project: { id: params.project.id },
|
|
32
|
+
code: params.code
|
|
33
|
+
});
|
|
37
34
|
return new Promise((resolve, reject) => {
|
|
38
35
|
// 所有権を暗号化する
|
|
39
|
-
jwt.sign(
|
|
36
|
+
jwt.sign(authorizationObject, credentials_1.credentials.jwt.secret,
|
|
40
37
|
// params.secret,
|
|
41
38
|
{
|
|
42
39
|
issuer: credentials_1.credentials.jwt.issuer,
|
|
@@ -20,41 +20,35 @@ function findByCode(params) {
|
|
|
20
20
|
if (typeof params.code !== 'string' || params.code.length === 0) {
|
|
21
21
|
throw new factory.errors.ArgumentNull('code');
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
code: { $eq: params.code },
|
|
28
|
-
validFrom: now,
|
|
29
|
-
validThrough: now
|
|
30
|
-
})).shift();
|
|
31
|
-
if (authorization === undefined) {
|
|
32
|
-
throw new factory.errors.NotFound('Authorization');
|
|
33
|
-
}
|
|
23
|
+
const authorizationObject = yield repos.authorization.findValidObjectByCode({
|
|
24
|
+
project: { id: params.project.id },
|
|
25
|
+
code: params.code
|
|
26
|
+
});
|
|
34
27
|
let reservationIdInOrder;
|
|
35
28
|
let reservationTypeInOrder;
|
|
36
29
|
let offeredThroughIdentifier = factory.service.webAPI.Identifier.Chevre;
|
|
37
|
-
|
|
38
|
-
switch (data.typeOf) {
|
|
30
|
+
switch (authorizationObject.typeOf) {
|
|
39
31
|
case factory.order.OrderType.Order:
|
|
40
|
-
const { orderNumber } =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
const { orderNumber } = authorizationObject;
|
|
33
|
+
if (typeof orderNumber === 'string' && orderNumber.length > 0) {
|
|
34
|
+
const acceptedOffer = (yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
35
|
+
limit: 1,
|
|
36
|
+
page: 1,
|
|
37
|
+
project: { id: { $eq: params.project.id } },
|
|
38
|
+
orderNumber: { $eq: String(orderNumber) },
|
|
39
|
+
acceptedOffers: { itemOffered: { id: { $eq: String(params.id) } } }
|
|
40
|
+
}, ['itemOffered', 'offeredThrough'])).shift();
|
|
41
|
+
const itemOfferedTypeOf = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.typeOf;
|
|
42
|
+
if (itemOfferedTypeOf === factory.reservationType.BusReservation
|
|
43
|
+
|| itemOfferedTypeOf === factory.reservationType.EventReservation) {
|
|
44
|
+
reservationIdInOrder = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.itemOffered.id;
|
|
45
|
+
reservationTypeInOrder = itemOfferedTypeOf;
|
|
46
|
+
offeredThroughIdentifier = (_a = acceptedOffer === null || acceptedOffer === void 0 ? void 0 : acceptedOffer.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
47
|
+
}
|
|
54
48
|
}
|
|
55
49
|
break;
|
|
56
50
|
default:
|
|
57
|
-
throw new factory.errors.NotImplemented(`authorization object typeOf: ${
|
|
51
|
+
throw new factory.errors.NotImplemented(`authorization object typeOf: ${authorizationObject.typeOf} not implemented`);
|
|
58
52
|
}
|
|
59
53
|
let reservation;
|
|
60
54
|
if (typeof reservationIdInOrder === 'string' && typeof reservationTypeInOrder === 'string') {
|
|
@@ -74,8 +68,8 @@ function findByCode(params) {
|
|
|
74
68
|
id, additionalTicketText, reservationStatus,
|
|
75
69
|
reservedTicket: {
|
|
76
70
|
ticketType: {
|
|
77
|
-
identifier: reservedTicket
|
|
78
|
-
name: { ja: (_b = reservedTicket
|
|
71
|
+
identifier: reservedTicket.ticketType.identifier,
|
|
72
|
+
name: { ja: (_b = reservedTicket.ticketType.name) === null || _b === void 0 ? void 0 : _b.ja }
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
75
|
};
|
|
@@ -18,13 +18,10 @@ export declare function useReservation(params: {
|
|
|
18
18
|
*/
|
|
19
19
|
id: string;
|
|
20
20
|
};
|
|
21
|
-
instrument?:
|
|
22
|
-
token?: string;
|
|
23
|
-
};
|
|
21
|
+
instrument?: Pick<factory.action.consume.use.reservation.IInstrument, 'ticketToken' | 'token'>;
|
|
24
22
|
location?: {
|
|
25
23
|
identifier?: string;
|
|
26
24
|
};
|
|
27
|
-
verifyToken: boolean;
|
|
28
25
|
}): (repos: {
|
|
29
26
|
action: ActionRepo;
|
|
30
27
|
assetTransaction: AssetTransactionRepo;
|
|
@@ -14,7 +14,6 @@ const createDebug = require("debug");
|
|
|
14
14
|
const factory = require("../../factory");
|
|
15
15
|
const confirmReservation_1 = require("./confirmReservation");
|
|
16
16
|
const onReservationUsed_1 = require("./potentialActions/onReservationUsed");
|
|
17
|
-
const verifyToken4reservation_1 = require("./verifyToken4reservation");
|
|
18
17
|
const debug = createDebug('chevre-domain:service:reserve:useReservation');
|
|
19
18
|
/**
|
|
20
19
|
* 予約使用
|
|
@@ -22,21 +21,23 @@ const debug = createDebug('chevre-domain:service:reserve:useReservation');
|
|
|
22
21
|
// tslint:disable-next-line:max-func-body-length
|
|
23
22
|
function useReservation(params) {
|
|
24
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c;
|
|
26
25
|
const now = new Date();
|
|
27
26
|
const reservationId = params.object.id;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
27
|
+
const ticketToken = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.ticketToken;
|
|
28
|
+
const token = (_b = params === null || params === void 0 ? void 0 : params.instrument) === null || _b === void 0 ? void 0 : _b.token;
|
|
29
|
+
// タスク作成前に検証済なので検証不要
|
|
30
|
+
// if (params.verifyToken === true) {
|
|
31
|
+
// // instrument?.tokenを検証
|
|
32
|
+
// if (typeof token === 'string') {
|
|
33
|
+
// await verifyToken4reservation({
|
|
34
|
+
// project: { id: params.project.id },
|
|
35
|
+
// agent: params.agent,
|
|
36
|
+
// reservationId,
|
|
37
|
+
// token
|
|
38
|
+
// })({ order: repos.order });
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
40
41
|
// confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
|
|
41
42
|
yield reserveIfNotYet({ object: params.object })(repos);
|
|
42
43
|
// 予約検索
|
|
@@ -54,10 +55,10 @@ function useReservation(params) {
|
|
|
54
55
|
reservedTicket: reservation.reservedTicket,
|
|
55
56
|
typeOf: reservation.typeOf
|
|
56
57
|
};
|
|
57
|
-
const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }),
|
|
58
|
+
const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign(Object.assign({}, (typeof token === 'string') ? { token } : undefined), (typeof ticketToken === 'string') ? { ticketToken } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }),
|
|
58
59
|
// object最適化(2023-01-30~)
|
|
59
60
|
// どの予約を
|
|
60
|
-
object: [reservationAsObject] }, (typeof ((
|
|
61
|
+
object: [reservationAsObject] }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.identifier) === 'string')
|
|
61
62
|
? {
|
|
62
63
|
location: {
|
|
63
64
|
typeOf: factory.placeType.Place,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
+
import type { MongoRepository as AuthorizationRepo } from '../../repo/code';
|
|
2
3
|
import type { MongoRepository as OrderRepo } from '../../repo/order';
|
|
3
4
|
/**
|
|
4
5
|
* 予約使用のためのチケットトークンを検証する
|
|
@@ -12,7 +13,17 @@ export declare function verifyToken4reservation(params: {
|
|
|
12
13
|
};
|
|
13
14
|
agent: factory.action.check.token.IAgent;
|
|
14
15
|
reservationId: string;
|
|
15
|
-
|
|
16
|
+
ticket: {
|
|
17
|
+
/**
|
|
18
|
+
* JWT
|
|
19
|
+
*/
|
|
20
|
+
token?: string;
|
|
21
|
+
/**
|
|
22
|
+
* 承認コード
|
|
23
|
+
*/
|
|
24
|
+
ticketToken?: string;
|
|
25
|
+
};
|
|
16
26
|
}): (repos: {
|
|
27
|
+
authorization: AuthorizationRepo;
|
|
17
28
|
order: OrderRepo;
|
|
18
29
|
}) => Promise<void>;
|
|
@@ -17,17 +17,35 @@ const code_1 = require("../code");
|
|
|
17
17
|
*/
|
|
18
18
|
function verifyToken4reservation(params) {
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
// JWTと承認コードの両方に対応する(2024-02-28~)
|
|
21
|
+
const { token, ticketToken } = params.ticket;
|
|
22
|
+
let payload;
|
|
23
|
+
if (typeof token === 'string' && token.length > 0) {
|
|
24
|
+
payload = yield (0, code_1.verifyToken)({
|
|
25
|
+
project: params.project,
|
|
26
|
+
agent: params.agent,
|
|
27
|
+
token
|
|
28
|
+
})({});
|
|
29
|
+
}
|
|
30
|
+
else if (typeof ticketToken === 'string' && ticketToken.length > 0) {
|
|
31
|
+
payload = yield repos.authorization.findValidObjectByCode({
|
|
32
|
+
project: { id: params.project.id },
|
|
33
|
+
code: ticketToken
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new factory.errors.ArgumentNull('ticket.token or ticket.ticketToken');
|
|
38
|
+
}
|
|
25
39
|
switch (payload.typeOf) {
|
|
26
40
|
case factory.order.OrderType.Order:
|
|
41
|
+
const { orderNumber } = payload;
|
|
42
|
+
if (typeof orderNumber !== 'string' || orderNumber.length === 0) {
|
|
43
|
+
throw new factory.errors.NotFound('payload.orderNumber');
|
|
44
|
+
}
|
|
27
45
|
// reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
|
|
28
46
|
const order = yield repos.order.findByOrderNumberAndReservationId({
|
|
29
47
|
project: { id: params.project.id },
|
|
30
|
-
orderNumber
|
|
48
|
+
orderNumber,
|
|
31
49
|
reservationId: params.reservationId,
|
|
32
50
|
seller: params.seller
|
|
33
51
|
});
|
|
@@ -7,6 +7,5 @@ import { checkInReservation } from './reserve/checkInReservation';
|
|
|
7
7
|
import { confirmReservation } from './reserve/confirmReservation';
|
|
8
8
|
import { findByCode } from './reserve/findByCode';
|
|
9
9
|
import { searchByOrder } from './reserve/searchByOrder';
|
|
10
|
-
import { useReservation } from './reserve/useReservation';
|
|
11
10
|
import { verifyToken4reservation } from './reserve/verifyToken4reservation';
|
|
12
|
-
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInReservation, confirmReservation, findByCode, searchByOrder,
|
|
11
|
+
export { maskUnderName, cancelPendingReservation, cancelReservation, checkInReservation, confirmReservation, findByCode, searchByOrder, verifyToken4reservation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyToken4reservation = exports.
|
|
3
|
+
exports.verifyToken4reservation = exports.searchByOrder = exports.findByCode = exports.confirmReservation = exports.checkInReservation = exports.cancelReservation = exports.cancelPendingReservation = exports.maskUnderName = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 予約サービス
|
|
6
6
|
*/
|
|
@@ -17,7 +17,6 @@ const findByCode_1 = require("./reserve/findByCode");
|
|
|
17
17
|
Object.defineProperty(exports, "findByCode", { enumerable: true, get: function () { return findByCode_1.findByCode; } });
|
|
18
18
|
const searchByOrder_1 = require("./reserve/searchByOrder");
|
|
19
19
|
Object.defineProperty(exports, "searchByOrder", { enumerable: true, get: function () { return searchByOrder_1.searchByOrder; } });
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "useReservation", { enumerable: true, get: function () { return useReservation_1.useReservation; } });
|
|
20
|
+
// import { useReservation } from './reserve/useReservation';
|
|
22
21
|
const verifyToken4reservation_1 = require("./reserve/verifyToken4reservation");
|
|
23
22
|
Object.defineProperty(exports, "verifyToken4reservation", { enumerable: true, get: function () { return verifyToken4reservation_1.verifyToken4reservation; } });
|
|
@@ -49,9 +49,9 @@ function onAuthorizationCreated(params) {
|
|
|
49
49
|
let reservationNumbers = [];
|
|
50
50
|
// 発券対象イベントID
|
|
51
51
|
let reservationForIds = [];
|
|
52
|
-
const authorizationObject = yield repos.code.
|
|
52
|
+
const authorizationObject = yield repos.code.findValidObjectByCode({
|
|
53
53
|
code: params.code,
|
|
54
|
-
project: { id: params.project.id
|
|
54
|
+
project: { id: params.project.id }
|
|
55
55
|
});
|
|
56
56
|
switch (authorizationObject.typeOf) {
|
|
57
57
|
case factory.order.OrderType.Order:
|
|
@@ -15,16 +15,14 @@ const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
|
15
15
|
const order_1 = require("../../repo/order");
|
|
16
16
|
const reservation_1 = require("../../repo/reservation");
|
|
17
17
|
const task_1 = require("../../repo/task");
|
|
18
|
-
const
|
|
18
|
+
const useReservation_1 = require("../reserve/useReservation");
|
|
19
19
|
/**
|
|
20
20
|
* タスク実行関数
|
|
21
21
|
*/
|
|
22
22
|
function call(data) {
|
|
23
23
|
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
var _a, _b;
|
|
25
|
-
yield (0,
|
|
26
|
-
// タスク作成前に検証済なので検証不要
|
|
27
|
-
verifyToken: false }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
|
|
25
|
+
yield (0, useReservation_1.useReservation)(Object.assign(Object.assign({ project: data.project, agent: data.agent, object: data.object }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
|
|
28
26
|
action: new action_1.MongoRepository(settings.connection),
|
|
29
27
|
assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
|
|
30
28
|
order: new order_1.MongoRepository(settings.connection),
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
13
|
+
"@chevre/factory": "4.358.0",
|
|
14
14
|
"@cinerino/sdk": "5.12.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.3.0-alpha.5",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0-alpha.4",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.
|
|
113
|
+
"version": "21.24.0"
|
|
114
114
|
}
|