@chevre/domain 22.5.0-alpha.10 → 22.5.0-alpha.11
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 +11 -10
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -20
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
- package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
- package/package.json +3 -3
|
@@ -32,17 +32,18 @@ async function main() {
|
|
|
32
32
|
authorization: authorizationRepo,
|
|
33
33
|
order: orderRepo,
|
|
34
34
|
ticket: ticketRepo
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
jwt: await chevre.credentials.JWT.createInstance({
|
|
38
|
-
secret: <string>process.env.TOKEN_SECRET,
|
|
39
|
-
issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
|
|
40
|
-
? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
|
|
41
|
-
: [],
|
|
42
|
-
version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
|
|
43
|
-
payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
|
|
44
|
-
})
|
|
45
35
|
}
|
|
36
|
+
// {
|
|
37
|
+
// jwt: await chevre.credentials.JWT.createInstance({
|
|
38
|
+
// secret: <string>process.env.TOKEN_SECRET,
|
|
39
|
+
// issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
|
|
40
|
+
// ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
|
|
41
|
+
// : [],
|
|
42
|
+
// version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
|
|
43
|
+
// payloadTypPrefix:
|
|
44
|
+
// (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
|
|
45
|
+
// })
|
|
46
|
+
// }
|
|
46
47
|
);
|
|
47
48
|
console.log('verified.');
|
|
48
49
|
|
|
@@ -6,30 +6,15 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const offerItemConditionRepo = await chevre.repository.OfferItemCondition.createInstance(mongoose.connection);
|
|
9
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
11
10
|
|
|
12
11
|
let updateResult: any;
|
|
13
|
-
updateResult = await
|
|
12
|
+
updateResult = await productRepo.unsetUnnecessaryFields({
|
|
14
13
|
filter: {
|
|
15
|
-
|
|
14
|
+
'hasOfferCatalog.id': { $exists: true }
|
|
16
15
|
},
|
|
17
|
-
$unset:
|
|
18
|
-
|
|
19
|
-
updatedAt: 1,
|
|
20
|
-
__v: 1
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
console.log(updateResult);
|
|
24
|
-
|
|
25
|
-
updateResult = await offerItemConditionRepo.unsetUnnecessaryFields({
|
|
26
|
-
filter: {
|
|
27
|
-
_id: { $exists: true }
|
|
28
|
-
},
|
|
29
|
-
$unset: <any>{
|
|
30
|
-
createdAt: 1,
|
|
31
|
-
updatedAt: 1,
|
|
32
|
-
__v: 1
|
|
16
|
+
$unset: {
|
|
17
|
+
'hasOfferCatalog.id': 1
|
|
33
18
|
}
|
|
34
19
|
});
|
|
35
20
|
console.log(updateResult);
|
|
@@ -19,7 +19,7 @@ export declare function useReservation(params: {
|
|
|
19
19
|
*/
|
|
20
20
|
id: string;
|
|
21
21
|
};
|
|
22
|
-
instrument?: Pick<factory.action.consume.use.reservation.IInstrument, 'ticketToken'
|
|
22
|
+
instrument?: Pick<factory.action.consume.use.reservation.IInstrument, 'ticketToken'>;
|
|
23
23
|
location?: {
|
|
24
24
|
identifier?: string;
|
|
25
25
|
};
|
|
@@ -21,11 +21,11 @@ const debug = createDebug('chevre-domain:service:reserve:useReservation');
|
|
|
21
21
|
// tslint:disable-next-line:max-func-body-length
|
|
22
22
|
function useReservation(params) {
|
|
23
23
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
var _a, _b, _c
|
|
24
|
+
var _a, _b, _c;
|
|
25
25
|
const now = new Date();
|
|
26
26
|
const reservationId = params.object.id;
|
|
27
27
|
const ticketToken = (_a = params === null || params === void 0 ? void 0 : params.instrument) === null || _a === void 0 ? void 0 : _a.ticketToken;
|
|
28
|
-
const token =
|
|
28
|
+
// const token = params?.instrument?.token;
|
|
29
29
|
// if (params.verifyToken === true) {} // タスク作成前に検証済なので検証不要
|
|
30
30
|
// confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
|
|
31
31
|
yield reserveIfNotYet({ object: params.object })(repos, settings);
|
|
@@ -47,9 +47,9 @@ function useReservation(params) {
|
|
|
47
47
|
typeOf: reservation.typeOf,
|
|
48
48
|
issuedThrough: { id: reservation.issuedThrough.id, typeOf: reservation.issuedThrough.typeOf },
|
|
49
49
|
reservationFor: { id: reservation.reservationFor.id, typeOf: reservation.reservationFor.typeOf },
|
|
50
|
-
reservedTicket: Object.assign(Object.assign({ typeOf: reservedTicket.typeOf, ticketType: Object.assign({ identifier: reservedTicket.ticketType.identifier, typeOf: reservedTicket.ticketType.typeOf }, (typeof reservedTicket.ticketType.id === 'string') ? { id: reservedTicket.ticketType.id } : undefined) }, (typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined), (typeof ((
|
|
50
|
+
reservedTicket: Object.assign(Object.assign({ typeOf: reservedTicket.typeOf, ticketType: Object.assign({ identifier: reservedTicket.ticketType.identifier, typeOf: reservedTicket.ticketType.typeOf }, (typeof reservedTicket.ticketType.id === 'string') ? { id: reservedTicket.ticketType.id } : undefined) }, (typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined), (typeof ((_b = reservedTicket.ticketedSeat) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { ticketedSeat: reservedTicket.ticketedSeat } : undefined)
|
|
51
51
|
};
|
|
52
|
-
const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign(
|
|
52
|
+
const actionAttributes = Object.assign({ project: reservation.project, typeOf: factory.actionType.UseAction, agent: params.agent, instrument: Object.assign(Object.assign({}, (typeof ticketToken === 'string') ? { ticketToken } : undefined), { typeOf: factory.action.check.token.ObjectType.Ticket }), object: [reservationAsObject] }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.identifier) === 'string')
|
|
53
53
|
? { location: { typeOf: factory.placeType.Place, identifier: params.location.identifier } }
|
|
54
54
|
: undefined);
|
|
55
55
|
const action = yield repos.action.start(actionAttributes);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { JWTCredentials } from '../../credentials/jwt';
|
|
2
1
|
import * as factory from '../../factory';
|
|
3
2
|
import type { AuthorizationRepo } from '../../repo/authorization';
|
|
4
3
|
import type { OrderRepo } from '../../repo/order';
|
|
@@ -16,10 +15,6 @@ export declare function verifyToken4reservation(params: {
|
|
|
16
15
|
agent: factory.action.check.token.IAgent;
|
|
17
16
|
reservationId: string;
|
|
18
17
|
ticket: {
|
|
19
|
-
/**
|
|
20
|
-
* JWT
|
|
21
|
-
*/
|
|
22
|
-
token?: string;
|
|
23
18
|
/**
|
|
24
19
|
* 承認コード
|
|
25
20
|
*/
|
|
@@ -29,6 +24,4 @@ export declare function verifyToken4reservation(params: {
|
|
|
29
24
|
authorization: AuthorizationRepo;
|
|
30
25
|
order: OrderRepo;
|
|
31
26
|
ticket: TicketRepo;
|
|
32
|
-
}, credentials: {
|
|
33
|
-
jwt: JWTCredentials;
|
|
34
27
|
}) => Promise<void>;
|
|
@@ -10,25 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.verifyToken4reservation = void 0;
|
|
13
|
+
// import type { JWTCredentials } from '../../credentials/jwt';
|
|
13
14
|
const factory = require("../../factory");
|
|
14
|
-
|
|
15
|
+
// import { verifyToken } from '../code';
|
|
15
16
|
/**
|
|
16
17
|
* 予約使用のためのチケットトークンを検証する
|
|
17
18
|
*/
|
|
18
19
|
function verifyToken4reservation(params) {
|
|
19
|
-
return (repos
|
|
20
|
+
return (repos
|
|
21
|
+
// credentials: {
|
|
22
|
+
// jwt: JWTCredentials;
|
|
23
|
+
// }
|
|
24
|
+
) => __awaiter(this, void 0, void 0, function* () {
|
|
20
25
|
// JWTと承認コードの両方に対応する(2024-02-28~)
|
|
21
|
-
const {
|
|
26
|
+
const { ticketToken } = params.ticket;
|
|
22
27
|
let payload;
|
|
23
|
-
if (typeof token === 'string' && token.length > 0) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
28
|
+
// if (typeof token === 'string' && token.length > 0) {
|
|
29
|
+
// const { authorizedObject } = await verifyToken({
|
|
30
|
+
// project: params.project,
|
|
31
|
+
// agent: params.agent,
|
|
32
|
+
// token
|
|
33
|
+
// })(repos, credentials);
|
|
34
|
+
// payload = authorizedObject;
|
|
35
|
+
// } else
|
|
36
|
+
if (typeof ticketToken === 'string' && ticketToken.length > 0) {
|
|
32
37
|
const findValidOneByCodeResult = yield repos.authorization.findValidOneByCode({
|
|
33
38
|
project: { id: params.project.id },
|
|
34
39
|
code: ticketToken
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.386.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "10.
|
|
12
|
+
"@chevre/factory": "4.386.0-alpha.4",
|
|
13
|
+
"@cinerino/sdk": "10.13.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.5.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -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": "22.5.0-alpha.
|
|
113
|
+
"version": "22.5.0-alpha.11"
|
|
114
114
|
}
|