@chevre/domain 22.2.0-alpha.1 → 22.2.0-alpha.2
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/assetTransaction/reserve/start/createSubReservations.js +15 -12
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +4 -1
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +45 -27
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -3
- package/lib/chevre/service/transaction/moneyTransfer.js +5 -1
- package/package.json +2 -2
|
@@ -273,7 +273,7 @@ function validateAdvanceBookingRequirement(params) {
|
|
|
273
273
|
function validateProgramMembershipUsed(params) {
|
|
274
274
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
275
275
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
276
|
-
var _a, _b, _c, _d, _e;
|
|
276
|
+
var _a, _b, _c, _d, _e, _f;
|
|
277
277
|
const now = new Date();
|
|
278
278
|
let programMembershipUsed;
|
|
279
279
|
const requestedProgramMembershipUsed = (_b = (_a = params.acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed;
|
|
@@ -284,15 +284,15 @@ function validateProgramMembershipUsed(params) {
|
|
|
284
284
|
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'must be permit');
|
|
285
285
|
}
|
|
286
286
|
const programMembershipUsedIdentifier = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.identifier;
|
|
287
|
-
const
|
|
288
|
-
const issuedThroughTypeOf = (_d = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _d === void 0 ? void 0 : _d.typeOf;
|
|
287
|
+
const issuedThroughTypeOf = (_c = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _c === void 0 ? void 0 : _c.typeOf;
|
|
289
288
|
if (typeof programMembershipUsedIdentifier === 'string') {
|
|
290
|
-
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
291
|
-
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
292
|
-
}
|
|
293
289
|
let permitIssuedThrough;
|
|
294
290
|
// まずメンバーシップを検索して、存在しなければCreditCardを検索(どちらが発行元サービスか不明なので)
|
|
295
291
|
if (issuedThroughTypeOf === factory.product.ProductType.MembershipService) {
|
|
292
|
+
const issuedThroughId = (_d = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _d === void 0 ? void 0 : _d.id;
|
|
293
|
+
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
294
|
+
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
295
|
+
}
|
|
296
296
|
permitIssuedThrough = (yield repos.product.searchProducts({
|
|
297
297
|
limit: 1,
|
|
298
298
|
page: 1,
|
|
@@ -304,6 +304,10 @@ function validateProgramMembershipUsed(params) {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
else if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
307
|
+
const issuedThroughId = (_e = requestedProgramMembershipUsed === null || requestedProgramMembershipUsed === void 0 ? void 0 : requestedProgramMembershipUsed.issuedThrough) === null || _e === void 0 ? void 0 : _e.id;
|
|
308
|
+
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
309
|
+
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
310
|
+
}
|
|
307
311
|
permitIssuedThrough = (yield repos.paymentService.searchPaymentServices({
|
|
308
312
|
limit: 1,
|
|
309
313
|
page: 1,
|
|
@@ -316,13 +320,13 @@ function validateProgramMembershipUsed(params) {
|
|
|
316
320
|
}
|
|
317
321
|
else if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
318
322
|
// プロダクトは存在しないので特に検証なし
|
|
323
|
+
permitIssuedThrough = {
|
|
324
|
+
typeOf: factory.service.paymentService.PaymentServiceType.FaceToFace
|
|
325
|
+
};
|
|
319
326
|
}
|
|
320
327
|
else {
|
|
321
328
|
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
322
329
|
}
|
|
323
|
-
if (typeof (permitIssuedThrough === null || permitIssuedThrough === void 0 ? void 0 : permitIssuedThrough.typeOf) !== 'string') {
|
|
324
|
-
throw new factory.errors.NotFound(`Permit issuer service [${issuedThroughId}]`);
|
|
325
|
-
}
|
|
326
330
|
switch (permitIssuedThrough.typeOf) {
|
|
327
331
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
328
332
|
// 問答無用に受け入れる
|
|
@@ -330,7 +334,6 @@ function validateProgramMembershipUsed(params) {
|
|
|
330
334
|
typeOf: factory.permit.PermitType.Permit,
|
|
331
335
|
identifier: programMembershipUsedIdentifier,
|
|
332
336
|
issuedThrough: {
|
|
333
|
-
id: '',
|
|
334
337
|
typeOf: permitIssuedThrough.typeOf
|
|
335
338
|
}
|
|
336
339
|
};
|
|
@@ -362,7 +365,7 @@ function validateProgramMembershipUsed(params) {
|
|
|
362
365
|
break;
|
|
363
366
|
case factory.product.ProductType.MembershipService:
|
|
364
367
|
// requestedProgramMembershipUsedの発行サービスIDから外部連携設定を取得する
|
|
365
|
-
const permitService = yield createPermitService({ issuedThrough: { id:
|
|
368
|
+
const permitService = yield createPermitService({ issuedThrough: { id: permitIssuedThrough.id } })(repos);
|
|
366
369
|
// メンバーシップの存在確認
|
|
367
370
|
const serviceOutput = yield permitService.findByIdentifier({
|
|
368
371
|
project: { id: params.project.id },
|
|
@@ -380,7 +383,7 @@ function validateProgramMembershipUsed(params) {
|
|
|
380
383
|
.isBefore(moment(now))) {
|
|
381
384
|
throw new factory.errors.Argument('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed', 'unavailable programMembership');
|
|
382
385
|
}
|
|
383
|
-
if (((
|
|
386
|
+
if (((_f = permitIssuedThrough.serviceType) === null || _f === void 0 ? void 0 : _f.typeOf) === 'CategoryCode') {
|
|
384
387
|
programMembershipUsed = {
|
|
385
388
|
typeOf: serviceOutput.typeOf,
|
|
386
389
|
identifier: programMembershipUsedIdentifier,
|
|
@@ -12,6 +12,9 @@ declare function requestedProgramMembershipUsed2permit(params: {
|
|
|
12
12
|
id: string;
|
|
13
13
|
};
|
|
14
14
|
programMembershipUsed?: factory.assetTransaction.reserve.IAcceptedProgramMembershipUsed;
|
|
15
|
+
placeOrder: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
15
18
|
}): (repos: {
|
|
16
19
|
action: ActionRepo;
|
|
17
20
|
authorization: AuthorizationRepo;
|
|
@@ -19,5 +22,5 @@ declare function requestedProgramMembershipUsed2permit(params: {
|
|
|
19
22
|
ticket: TicketRepo;
|
|
20
23
|
}, credentials: {
|
|
21
24
|
jwt: JWTCredentials;
|
|
22
|
-
}) => Promise<factory.assetTransaction.reserve.
|
|
25
|
+
}) => Promise<factory.assetTransaction.reserve.IPermitIssuedThroughFaceToFace | factory.assetTransaction.reserve.IPermitIssuedThroughMembershipService | undefined>;
|
|
23
26
|
export { requestedProgramMembershipUsed2permit };
|
|
@@ -15,12 +15,13 @@ const CodeService = require("../../../../code");
|
|
|
15
15
|
/**
|
|
16
16
|
* チケット化された適用メンバーシップをPermitに変換する
|
|
17
17
|
*/
|
|
18
|
-
// tslint:disable-next-line:max-func-body-length
|
|
19
18
|
function requestedProgramMembershipUsed2permit(params) {
|
|
19
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
20
20
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a, _b;
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
22
|
let programMembershipUsedAsPermit;
|
|
23
|
-
const { programMembershipUsed } = params;
|
|
23
|
+
const { programMembershipUsed, placeOrder } = params;
|
|
24
|
+
const now = new Date();
|
|
24
25
|
// トークン化されたメンバーシップがリクエストされた場合、実メンバーシップ情報へ変換する
|
|
25
26
|
if (typeof programMembershipUsed === 'string') {
|
|
26
27
|
const { authorizedObject } = yield CodeService.verifyToken({
|
|
@@ -35,24 +36,27 @@ function requestedProgramMembershipUsed2permit(params) {
|
|
|
35
36
|
if (permitOwnershipInfo.typeOf !== 'OwnershipInfo') {
|
|
36
37
|
throw new factory.errors.Argument('programMembershipUsed', 'must be OwnershipInfo');
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
const typeOfGood = permitOwnershipInfo.typeOfGood;
|
|
40
|
+
if (typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
39
41
|
throw new factory.errors.Argument('programMembershipUsed', 'must be Permit');
|
|
40
42
|
}
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
+
const issuedThroughTypeOf = (_a = typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
44
|
+
if (issuedThroughTypeOf !== factory.product.ProductType.MembershipService) {
|
|
45
|
+
throw new factory.errors.Argument('programMembershipUsed', 'must be issued through MembershipService');
|
|
46
|
+
}
|
|
47
|
+
if (typeof ((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) !== 'string') {
|
|
43
48
|
throw new factory.errors.NotFound('itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
if (issuedThroughTypeOf === factory.product.ProductType.MembershipService) {
|
|
51
|
+
programMembershipUsedAsPermit = {
|
|
52
|
+
identifier: typeOfGood.identifier,
|
|
53
|
+
issuedThrough: { id: typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
54
|
+
typeOf: factory.permit.PermitType.Permit
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
49
58
|
throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
50
59
|
}
|
|
51
|
-
programMembershipUsedAsPermit = {
|
|
52
|
-
identifier: String(typeOfGood.identifier),
|
|
53
|
-
issuedThrough: { id: typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
54
|
-
typeOf: factory.permit.PermitType.Permit
|
|
55
|
-
};
|
|
56
60
|
}
|
|
57
61
|
else if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) === 'Ticket') {
|
|
58
62
|
const { ticketToken } = programMembershipUsed;
|
|
@@ -79,28 +83,42 @@ function requestedProgramMembershipUsed2permit(params) {
|
|
|
79
83
|
limit: 1,
|
|
80
84
|
page: 1,
|
|
81
85
|
project: { id: { $eq: params.project.id } },
|
|
82
|
-
ids: [ownershipInfoId]
|
|
86
|
+
ids: [ownershipInfoId],
|
|
87
|
+
ownedFrom: now,
|
|
88
|
+
ownedThrough: now
|
|
83
89
|
})).shift();
|
|
84
90
|
if (permitOwnershipInfo === undefined) {
|
|
85
91
|
throw new factory.errors.NotFound('OwnershipInfo');
|
|
86
92
|
}
|
|
93
|
+
// ownedBy検証
|
|
94
|
+
if (!Array.isArray(permitOwnershipInfo.ownedBy) || ((_c = permitOwnershipInfo.ownedBy[0]) === null || _c === void 0 ? void 0 : _c.id) !== placeOrder.id) {
|
|
95
|
+
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo not matched with placeOrder');
|
|
96
|
+
}
|
|
87
97
|
if (permitOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
88
98
|
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.typeOf must be Permit');
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
const issuedThroughTypeOf = (_d = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _d === void 0 ? void 0 : _d.typeOf;
|
|
101
|
+
if (issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
102
|
+
programMembershipUsedAsPermit = {
|
|
103
|
+
identifier: permitOwnershipInfo.typeOfGood.identifier,
|
|
104
|
+
issuedThrough: { typeOf: issuedThroughTypeOf },
|
|
105
|
+
typeOf: factory.permit.PermitType.Permit
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else if (issuedThroughTypeOf === factory.product.ProductType.MembershipService
|
|
109
|
+
|| issuedThroughTypeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
110
|
+
if (typeof ((_e = permitOwnershipInfo.typeOfGood.issuedThrough) === null || _e === void 0 ? void 0 : _e.id) !== 'string') {
|
|
111
|
+
throw new factory.errors.Argument('programMembershipUsed', 'ownershipInfo.typeOfGood.issuedThrough.id undefined');
|
|
112
|
+
}
|
|
113
|
+
programMembershipUsedAsPermit = {
|
|
114
|
+
identifier: permitOwnershipInfo.typeOfGood.identifier,
|
|
115
|
+
issuedThrough: { id: permitOwnershipInfo.typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
116
|
+
typeOf: factory.permit.PermitType.Permit
|
|
117
|
+
};
|
|
92
118
|
}
|
|
93
|
-
|
|
94
|
-
if (issuedThroughTypeOf !== factory.product.ProductType.MembershipService
|
|
95
|
-
&& issuedThroughTypeOf !== factory.service.paymentService.PaymentServiceType.CreditCard
|
|
96
|
-
&& issuedThroughTypeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
119
|
+
else {
|
|
97
120
|
throw new factory.errors.Argument('programMembershipUsed', `invalid issuedThrough.typeOf: ${issuedThroughTypeOf}`);
|
|
98
121
|
}
|
|
99
|
-
programMembershipUsedAsPermit = {
|
|
100
|
-
identifier: permitOwnershipInfo.typeOfGood.identifier,
|
|
101
|
-
issuedThrough: { id: permitOwnershipInfo.typeOfGood.issuedThrough.id, typeOf: issuedThroughTypeOf },
|
|
102
|
-
typeOf: factory.permit.PermitType.Permit
|
|
103
|
-
};
|
|
104
122
|
}
|
|
105
123
|
}
|
|
106
124
|
return programMembershipUsedAsPermit;
|
|
@@ -23,7 +23,7 @@ function processStartReserve4chevre(params, options) {
|
|
|
23
23
|
// object: <IObjectWithDetail>action.object,
|
|
24
24
|
acceptedOffers: params.acceptedOffers, event: { id: event.id }, transaction,
|
|
25
25
|
transactionNumber }, (params.broker !== undefined) ? { broker: params.broker } : undefined));
|
|
26
|
-
const startParamObject = yield validateObjectWithoutDetail(startParams)(repos, credentials);
|
|
26
|
+
const startParamObject = yield validateObjectWithoutDetail(startParams, { id: params.transaction.id })(repos, credentials);
|
|
27
27
|
const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject,
|
|
28
28
|
// discontinue preSearchedEvent(2024-07-17~)
|
|
29
29
|
// preSearchedEvent: event,
|
|
@@ -44,7 +44,7 @@ function processStartReserve4chevre(params, options) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
exports.processStartReserve4chevre = processStartReserve4chevre;
|
|
47
|
-
function validateObjectWithoutDetail(params) {
|
|
47
|
+
function validateObjectWithoutDetail(params, placeOrder) {
|
|
48
48
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
var _a, _b, _c;
|
|
50
50
|
const objectWithoutDetail = params.object;
|
|
@@ -53,7 +53,8 @@ function validateObjectWithoutDetail(params) {
|
|
|
53
53
|
for (let acceptedOffer of objectWithoutDetail.acceptedOffer) {
|
|
54
54
|
const programMembershipUsedAsPermit = yield (0, requestedProgramMembershipUsed2permit_1.requestedProgramMembershipUsed2permit)({
|
|
55
55
|
project: { id: params.project.id },
|
|
56
|
-
programMembershipUsed: (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed
|
|
56
|
+
programMembershipUsed: (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed,
|
|
57
|
+
placeOrder: { id: placeOrder.id }
|
|
57
58
|
})(repos, credentials);
|
|
58
59
|
// 適用メンバーシップがあればacceptedOfferを強制的に上書き
|
|
59
60
|
if (programMembershipUsedAsPermit !== undefined) {
|
|
@@ -368,6 +368,7 @@ function processMoneyTransferTransaction(params) {
|
|
|
368
368
|
return pendingTransaction;
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
+
// tslint:disable-next-line:max-func-body-length
|
|
371
372
|
function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
372
373
|
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
373
374
|
var _a, _b, _c;
|
|
@@ -389,10 +390,13 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
|
|
|
389
390
|
if (paymentCardOwnershipInfo.typeOfGood.typeOf !== factory.permit.PermitType.Permit) {
|
|
390
391
|
throw new factory.errors.Argument('fromLocation', 'must be Permit');
|
|
391
392
|
}
|
|
393
|
+
if (((_a = paymentCardOwnershipInfo.typeOfGood.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) !== factory.product.ProductType.PaymentCard) {
|
|
394
|
+
throw new factory.errors.Argument('fromLocation', 'must be issued through PaymentCard');
|
|
395
|
+
}
|
|
392
396
|
fromLocation = {
|
|
393
397
|
typeOf: paymentCardOwnershipInfo.typeOfGood.typeOf,
|
|
394
398
|
identifier: paymentCardOwnershipInfo.typeOfGood.identifier,
|
|
395
|
-
issuedThrough: { id:
|
|
399
|
+
issuedThrough: { id: paymentCardOwnershipInfo.typeOfGood.issuedThrough.id }
|
|
396
400
|
};
|
|
397
401
|
}
|
|
398
402
|
else {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.381.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.381.0-alpha.3",
|
|
13
13
|
"@cinerino/sdk": "10.5.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.4.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.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.2.0-alpha.
|
|
113
|
+
"version": "22.2.0-alpha.2"
|
|
114
114
|
}
|