@chevre/domain 23.1.0-alpha.9 → 23.1.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/{eventOffer/adminEventOffers.ts → acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts} +12 -11
- package/example/src/chevre/actions/checkAcceptPayActions.ts +60 -0
- package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +67 -0
- package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
- package/example/src/chevre/importEventsFromCOA.ts +5 -5
- package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +46 -0
- package/example/src/chevre/place/checkSectionCount.ts +27 -0
- package/example/src/chevre/place/findSectionsByRoom.ts +50 -0
- package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
- package/example/src/chevre/reIndex.ts +0 -1
- package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
- package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
- package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
- package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
- package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
- package/lib/chevre/repo/authorization.d.ts +3 -2
- package/lib/chevre/repo/authorization.js +13 -5
- package/lib/chevre/repo/event.d.ts +1 -35
- package/lib/chevre/repo/event.js +2 -102
- package/lib/chevre/repo/eventOffer.js +3 -3
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +97 -0
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +9 -0
- package/lib/chevre/repo/note.js +4 -2
- package/lib/chevre/repo/pendingReservation.js +28 -71
- package/lib/chevre/repo/place/seat.d.ts +24 -0
- package/lib/chevre/repo/place/seat.js +103 -21
- package/lib/chevre/repo/place/section.d.ts +20 -0
- package/lib/chevre/repo/place/section.js +47 -0
- package/lib/chevre/repo/ticket.d.ts +7 -1
- package/lib/chevre/repo/ticket.js +14 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +94 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
- package/lib/chevre/service/assetTransaction/pay.js +6 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +1 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +7 -7
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +6 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +7 -51
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +6 -8
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +29 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +9 -9
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -1
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
- package/lib/chevre/service/offer/event.d.ts +2 -1
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/offer.d.ts +31 -1
- package/lib/chevre/service/offer.js +104 -34
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
- package/lib/chevre/service/payment/any/factory.d.ts +20 -3
- package/lib/chevre/service/payment/any/factory.js +26 -6
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +8 -22
- package/lib/chevre/service/payment/any.d.ts +5 -1
- package/lib/chevre/service/payment/any.js +22 -13
- package/lib/chevre/service/payment/factory.js +0 -5
- package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
- package/package.json +3 -3
- package/example/src/chevre/checkReplaceActions.ts +0 -65
- package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +0 -7
|
@@ -10,6 +10,7 @@ import type { ActionRepo } from '../../repo/action';
|
|
|
10
10
|
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
11
11
|
import type { CredentialsRepo } from '../../repo/credentials';
|
|
12
12
|
import type { EventRepo } from '../../repo/event';
|
|
13
|
+
import type { EventSeriesRepo } from '../../repo/eventSeries';
|
|
13
14
|
import type { OrderRepo } from '../../repo/order';
|
|
14
15
|
import type { PaymentServiceRepo } from '../../repo/paymentService';
|
|
15
16
|
import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
@@ -24,6 +25,7 @@ export interface IStartOperationRepos {
|
|
|
24
25
|
action: ActionRepo;
|
|
25
26
|
credentials: CredentialsRepo;
|
|
26
27
|
event: EventRepo;
|
|
28
|
+
eventSeries: EventSeriesRepo;
|
|
27
29
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
28
30
|
paymentService: PaymentServiceRepo;
|
|
29
31
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -61,6 +63,8 @@ export type ICheckOperation<T> = (repos: {
|
|
|
61
63
|
}, settings: Settings) => Promise<T>;
|
|
62
64
|
export type IPublishPaymentUrlOperation<T> = (repos: {
|
|
63
65
|
action: ActionRepo;
|
|
66
|
+
event: EventRepo;
|
|
67
|
+
eventSeries: EventSeriesRepo;
|
|
64
68
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
65
69
|
paymentService: PaymentServiceRepo;
|
|
66
70
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -78,6 +82,7 @@ export declare function publishPaymentUrl(params: Pick<factory.assetTransaction.
|
|
|
78
82
|
* add identifier for an unique index(2025-02-25~)
|
|
79
83
|
*/
|
|
80
84
|
identifier?: string;
|
|
85
|
+
instrument: factory.action.accept.pay.IInstrument[];
|
|
81
86
|
}, options: {
|
|
82
87
|
purposeAsTransaction: {
|
|
83
88
|
id: string;
|
|
@@ -104,7 +109,7 @@ export import IPaymentAgencyTransaction = CreditCardPayment.IPaymentAgencyTransa
|
|
|
104
109
|
* 取引開始
|
|
105
110
|
*/
|
|
106
111
|
export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail & {
|
|
107
|
-
instrument: factory.action.trade.pay.
|
|
112
|
+
instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
|
|
108
113
|
}, options: {
|
|
109
114
|
pendingPaymentAgencyTransaction?: CreditCardPayment.IPaymentAgencyTransaction;
|
|
110
115
|
/**
|
|
@@ -24,6 +24,7 @@ const PaymentCardPayment = require("../payment/paymentCard");
|
|
|
24
24
|
const fixInformAction_1 = require("./fixInformAction");
|
|
25
25
|
const validation_1 = require("./pay/account/validation");
|
|
26
26
|
const factory_1 = require("./pay/factory");
|
|
27
|
+
const validateAcceptedPaymentMethodIfNeeded_1 = require("./pay/validateAcceptedPaymentMethodIfNeeded");
|
|
27
28
|
function publishPaymentUrlResult2recipe(params) {
|
|
28
29
|
const { project, result } = params;
|
|
29
30
|
return {
|
|
@@ -76,6 +77,8 @@ function publishPaymentUrl(params, options) {
|
|
|
76
77
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
77
78
|
}
|
|
78
79
|
yield validateSeller(params)(repos);
|
|
80
|
+
// リソースの対応決済方法検証(2025-12-02~)
|
|
81
|
+
yield (0, validateAcceptedPaymentMethodIfNeeded_1.validateAcceptedPaymentMethodIfNeeded)(params)(repos);
|
|
79
82
|
// 決済サービス確認
|
|
80
83
|
const paymentServiceId = getPaymentServiceId(params);
|
|
81
84
|
// 決済受入アクション生成(2024-03-28~)
|
|
@@ -84,7 +87,7 @@ function publishPaymentUrl(params, options) {
|
|
|
84
87
|
object: params.object,
|
|
85
88
|
transactionNumber,
|
|
86
89
|
typeOf: params.typeOf
|
|
87
|
-
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id } }, (typeof taskId === 'string')
|
|
90
|
+
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id }, instrument: (Array.isArray(params.instrument)) ? params.instrument : [] }, (typeof taskId === 'string')
|
|
88
91
|
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-22~)
|
|
89
92
|
: undefined), (typeof ((_d = params.location) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
|
|
90
93
|
? { location: params.location }
|
|
@@ -186,6 +189,8 @@ function start(params, options) {
|
|
|
186
189
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
187
190
|
}
|
|
188
191
|
yield validateSeller(params)(repos);
|
|
192
|
+
// リソースの対応決済方法検証(2025-12-02~)
|
|
193
|
+
yield (0, validateAcceptedPaymentMethodIfNeeded_1.validateAcceptedPaymentMethodIfNeeded)(params)(repos);
|
|
189
194
|
// 決済サービス確認
|
|
190
195
|
const paymentServiceType = (_b = params.object) === null || _b === void 0 ? void 0 : _b.typeOf;
|
|
191
196
|
const paymentService = yield fixPaymentService(params)(repos);
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts
CHANGED
|
@@ -14,10 +14,9 @@ declare function fixExtendedEventOffer(params: {
|
|
|
14
14
|
*/
|
|
15
15
|
id: string;
|
|
16
16
|
};
|
|
17
|
-
object: factory.assetTransaction.reserve.IObjectWithoutDetail;
|
|
18
17
|
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
19
18
|
}): (repos: {
|
|
20
19
|
eventOffer: EventOfferRepo;
|
|
21
20
|
member: MemberRepo;
|
|
22
|
-
}) => Promise<Pick<factory.eventOffer.IEventOffer, "identifier" | "itemOffered" | "typeOf" | "offeredBy" | "validFrom" | "validThrough">>;
|
|
21
|
+
}) => Promise<Pick<factory.eventOffer.IEventOffer, "identifier" | "itemOffered" | "typeOf" | "offeredBy" | "validFrom" | "validThrough" | "id">>;
|
|
23
22
|
export { fixExtendedEventOffer };
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js
CHANGED
|
@@ -21,9 +21,9 @@ function fixExtendedEventOffer(params) {
|
|
|
21
21
|
const { event, availableAt } = params;
|
|
22
22
|
const acceptedDate = moment(params.now);
|
|
23
23
|
// リクエストによるオファーコード指定が必須
|
|
24
|
-
const
|
|
25
|
-
if (typeof
|
|
26
|
-
throw new factory.errors.ArgumentNull('
|
|
24
|
+
const eventOfferIdMustBe = (_a = params.acceptedEventOffer) === null || _a === void 0 ? void 0 : _a.id;
|
|
25
|
+
if (typeof eventOfferIdMustBe !== 'string' || eventOfferIdMustBe === '') {
|
|
26
|
+
throw new factory.errors.ArgumentNull('ticket as instrument');
|
|
27
27
|
}
|
|
28
28
|
// アプリケーションIDからアプリケーションコードを参照
|
|
29
29
|
const existingCustomerMember = (yield repos.member.searchCustomerMembers({
|
|
@@ -37,8 +37,7 @@ function fixExtendedEventOffer(params) {
|
|
|
37
37
|
if (existingCustomerMember === undefined) {
|
|
38
38
|
throw new factory.errors.NotFound(`Member: ${availableAt.id}`);
|
|
39
39
|
}
|
|
40
|
-
//
|
|
41
|
-
console.log('existingCustomerMember found:', JSON.stringify(existingCustomerMember));
|
|
40
|
+
// console.log('existingCustomerMember found:', JSON.stringify(existingCustomerMember));
|
|
42
41
|
const applicationIdentifier = existingCustomerMember.member.identifier;
|
|
43
42
|
if (typeof applicationIdentifier !== 'string') {
|
|
44
43
|
throw new factory.errors.NotFound(`member.identifier of ${availableAt.id}`);
|
|
@@ -51,11 +50,12 @@ function fixExtendedEventOffer(params) {
|
|
|
51
50
|
validFrom: { $lte: acceptedDate.toDate() },
|
|
52
51
|
validThrough: { $gte: acceptedDate.toDate() },
|
|
53
52
|
itemOffered: { id: { $eq: event.id } }, // 対象イベント
|
|
54
|
-
|
|
53
|
+
id: { $eq: eventOfferIdMustBe }, // オファーID
|
|
54
|
+
// identifier: { $eq: eventOfferIdentifierMustBe }, // オファーコード
|
|
55
55
|
availableAtOrFrom: { identifier: { $eq: applicationIdentifier } } // アプリケーションコード
|
|
56
56
|
}, ['identifier', 'itemOffered', 'offeredBy', 'typeOf', 'validFrom', 'validThrough'])).shift();
|
|
57
57
|
if (existingEventOffer === undefined) {
|
|
58
|
-
throw new factory.errors.NotFound(`eventOffer: ${
|
|
58
|
+
throw new factory.errors.NotFound(`valid eventOffer: ${eventOfferIdMustBe}`);
|
|
59
59
|
}
|
|
60
60
|
return existingEventOffer;
|
|
61
61
|
});
|
|
@@ -7,9 +7,13 @@ import type { IssuerRepo } from '../../../../repo/issuer';
|
|
|
7
7
|
declare function validateIssuedOfferIfExists(params: {
|
|
8
8
|
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project' | 'identifier'>;
|
|
9
9
|
now: Date;
|
|
10
|
-
|
|
11
|
-
eventOffer: Pick<factory.eventOffer.IEventOffer, 'identifier' | 'itemOffered' | 'offeredBy' | 'validFrom' | 'validThrough'>;
|
|
10
|
+
eventOffer: Pick<factory.eventOffer.IEventOffer, 'identifier' | 'itemOffered' | 'offeredBy' | 'validFrom' | 'validThrough' | 'id'>;
|
|
12
11
|
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
12
|
+
/**
|
|
13
|
+
* オファー承認時の予約数
|
|
14
|
+
* 0であれば特に何も検証されない
|
|
15
|
+
*/
|
|
16
|
+
numAcceptedOffers: number;
|
|
13
17
|
}): (repos: {
|
|
14
18
|
issuer: IssuerRepo;
|
|
15
19
|
}) => Promise<void>;
|
|
@@ -37,10 +37,10 @@ function verifyOfferToken(params) {
|
|
|
37
37
|
catch (error) {
|
|
38
38
|
// JWTエラーをハンドリング
|
|
39
39
|
if (error instanceof jwt.TokenExpiredError) {
|
|
40
|
-
throw new factory.errors.Argument('
|
|
40
|
+
throw new factory.errors.Argument('ticketedOffer.token', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
41
41
|
}
|
|
42
42
|
else if (error instanceof jwt.JsonWebTokenError) {
|
|
43
|
-
throw new factory.errors.Argument('
|
|
43
|
+
throw new factory.errors.Argument('ticketedOffer.token', `invalid token. [${error.message}]`);
|
|
44
44
|
}
|
|
45
45
|
throw error;
|
|
46
46
|
}
|
|
@@ -51,30 +51,30 @@ const OFFER_TOKEN_DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';
|
|
|
51
51
|
function validateOfferToken(params) {
|
|
52
52
|
return () => __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
var _a, _b;
|
|
54
|
-
const { event, acceptedDate, verifiedOffer, eventOffer } = params;
|
|
55
|
-
//
|
|
56
|
-
const
|
|
57
|
-
if (typeof
|
|
58
|
-
throw new factory.errors.Argument('
|
|
54
|
+
const { event, acceptedDate, verifiedOffer, eventOffer, numAcceptedOffers } = params;
|
|
55
|
+
// イベントID一致検証
|
|
56
|
+
const itemOfferedId = (_a = verifiedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.id;
|
|
57
|
+
if (typeof itemOfferedId !== 'string' || itemOfferedId === '') {
|
|
58
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'itemOffered.id must be string');
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
if (typeof
|
|
62
|
-
throw new factory.errors.NotFound('
|
|
60
|
+
const itemOfferedIdMustBe = event.id;
|
|
61
|
+
if (typeof itemOfferedIdMustBe !== 'string') {
|
|
62
|
+
throw new factory.errors.NotFound('event.id', 'the event must have an ID');
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
65
|
-
throw new factory.errors.Argument('
|
|
64
|
+
if (itemOfferedId !== itemOfferedIdMustBe) {
|
|
65
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'itemOffered.id not matched');
|
|
66
66
|
}
|
|
67
|
-
//
|
|
67
|
+
// オファーコード一致検証
|
|
68
68
|
const applicationOfferIdentifier = verifiedOffer.identifier;
|
|
69
69
|
if (typeof applicationOfferIdentifier !== 'string' || applicationOfferIdentifier === '') {
|
|
70
|
-
throw new factory.errors.Argument('
|
|
70
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'identifier must be string');
|
|
71
71
|
}
|
|
72
72
|
const applicationOfferIdentifierMustBe = eventOffer.identifier;
|
|
73
73
|
if (typeof applicationOfferIdentifierMustBe !== 'string') {
|
|
74
74
|
throw new factory.errors.NotFound('makesOffer.identifier');
|
|
75
75
|
}
|
|
76
76
|
if (applicationOfferIdentifier !== applicationOfferIdentifierMustBe) {
|
|
77
|
-
throw new factory.errors.Argument('
|
|
77
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'identifier not matched');
|
|
78
78
|
}
|
|
79
79
|
// 有効期間検証
|
|
80
80
|
let validThroughMoment;
|
|
@@ -82,26 +82,26 @@ function validateOfferToken(params) {
|
|
|
82
82
|
validThroughMoment = moment(verifiedOffer.validThrough, OFFER_TOKEN_DATE_FORMAT, true);
|
|
83
83
|
validFromMoment = moment(verifiedOffer.validFrom, OFFER_TOKEN_DATE_FORMAT, true);
|
|
84
84
|
if (!validThroughMoment.isValid()) {
|
|
85
|
-
throw new factory.errors.Argument('
|
|
85
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'invalid validThrough');
|
|
86
86
|
}
|
|
87
87
|
if (!validFromMoment.isValid()) {
|
|
88
|
-
throw new factory.errors.Argument('
|
|
88
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'invalid validFrom');
|
|
89
89
|
}
|
|
90
90
|
if (acceptedDate.isBefore(validFromMoment)) {
|
|
91
|
-
throw new factory.errors.Argument('
|
|
91
|
+
throw new factory.errors.Argument('ticketedOffer.token', `the offer id valid from ${validFromMoment}`);
|
|
92
92
|
}
|
|
93
93
|
if (acceptedDate.isAfter(validThroughMoment)) {
|
|
94
|
-
throw new factory.errors.Argument('
|
|
94
|
+
throw new factory.errors.Argument('ticketedOffer.token', `the offer id valid through ${validThroughMoment}`);
|
|
95
95
|
}
|
|
96
96
|
// maxValueを検証
|
|
97
|
-
const maxValue = (
|
|
97
|
+
const maxValue = (_b = verifiedOffer === null || verifiedOffer === void 0 ? void 0 : verifiedOffer.eligibleQuantity) === null || _b === void 0 ? void 0 : _b.maxValue;
|
|
98
98
|
if (typeof maxValue !== 'number') {
|
|
99
|
-
throw new factory.errors.Argument('
|
|
99
|
+
throw new factory.errors.Argument('ticketedOffer.token', 'eligibleQuantity.maxValue must be number');
|
|
100
100
|
}
|
|
101
101
|
if (maxValue > NUM_ACCEPTED_OFFERS_MAX_VALUE) {
|
|
102
|
-
throw new factory.errors.Argument('
|
|
102
|
+
throw new factory.errors.Argument('ticketedOffer.token', `eligibleQuantity.maxValue must be <= ${NUM_ACCEPTED_OFFERS_MAX_VALUE}`);
|
|
103
103
|
}
|
|
104
|
-
const numAcceptedOffers =
|
|
104
|
+
// const numAcceptedOffers = params.object.acceptedOffer?.length;
|
|
105
105
|
if (typeof numAcceptedOffers === 'number' && numAcceptedOffers > 0) {
|
|
106
106
|
if (numAcceptedOffers > maxValue) {
|
|
107
107
|
throw new factory.errors.Argument('reservationFor.id', `Maximum number of offers exceeded`);
|
|
@@ -115,15 +115,15 @@ function validateOfferToken(params) {
|
|
|
115
115
|
function validateIssuedOfferIfExists(params) {
|
|
116
116
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
var _a, _b, _c;
|
|
118
|
-
const { event, eventOffer } = params;
|
|
118
|
+
const { event, eventOffer, numAcceptedOffers } = params;
|
|
119
119
|
const acceptedDate = moment(params.now);
|
|
120
120
|
const offerTokenIssuer = (_a = eventOffer.offeredBy) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
121
121
|
const offerTokenRequired = typeof offerTokenIssuer === 'string';
|
|
122
122
|
if (offerTokenRequired) {
|
|
123
|
-
const
|
|
123
|
+
const offerIdMustBe = (_b = params.acceptedEventOffer) === null || _b === void 0 ? void 0 : _b.id;
|
|
124
124
|
const offerToken = (_c = params.acceptedEventOffer) === null || _c === void 0 ? void 0 : _c.token;
|
|
125
|
-
if (typeof
|
|
126
|
-
throw new factory.errors.
|
|
125
|
+
if (typeof offerIdMustBe !== 'string' || offerIdMustBe === '') {
|
|
126
|
+
throw new factory.errors.NotFound('ticketedOffer.id');
|
|
127
127
|
}
|
|
128
128
|
if (typeof offerToken !== 'string' || offerToken === '') {
|
|
129
129
|
throw new factory.errors.ArgumentNull('object.reservationFor.offers.token');
|
|
@@ -131,8 +131,8 @@ function validateIssuedOfferIfExists(params) {
|
|
|
131
131
|
if (typeof eventOffer.identifier !== 'string' || eventOffer.identifier === '') {
|
|
132
132
|
throw new factory.errors.NotFound('eventOffer.identifier');
|
|
133
133
|
}
|
|
134
|
-
//
|
|
135
|
-
if (eventOffer.
|
|
134
|
+
// イベントオファーID一致検証
|
|
135
|
+
if (eventOffer.id !== offerIdMustBe) {
|
|
136
136
|
throw new factory.errors.Argument('object.reservationFor.offers.identifier', 'eventOffer.identifier not matched');
|
|
137
137
|
}
|
|
138
138
|
const issuer = yield repos.issuer.findByIdentifier({
|
|
@@ -152,7 +152,7 @@ function validateIssuedOfferIfExists(params) {
|
|
|
152
152
|
acceptedDate,
|
|
153
153
|
verifiedOffer,
|
|
154
154
|
eventOffer,
|
|
155
|
-
|
|
155
|
+
numAcceptedOffers
|
|
156
156
|
})();
|
|
157
157
|
}
|
|
158
158
|
});
|
|
@@ -6,7 +6,6 @@ import type { ProductOfferRepo } from '../../../../repo/productOffer';
|
|
|
6
6
|
declare function validateMemberTierIfExists(params: {
|
|
7
7
|
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project'>;
|
|
8
8
|
now: Date;
|
|
9
|
-
object: factory.assetTransaction.reserve.IObjectWithoutDetail;
|
|
10
9
|
makesOfferOnApplication: factory.event.screeningEvent.ISellerMakesOffer;
|
|
11
10
|
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
12
11
|
}): (repos: {
|
|
@@ -20,13 +20,13 @@ function validateMemberTier(params) {
|
|
|
20
20
|
const tierIdentifier = (_b = (_a = verifiedValidForMemberTier.member) === null || _a === void 0 ? void 0 : _a.memberOf) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
21
21
|
const memberProgramIdentifier = (_e = (_d = (_c = verifiedValidForMemberTier.member) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.isTierOf) === null || _e === void 0 ? void 0 : _e.identifier;
|
|
22
22
|
if (typeof tierIdentifier !== 'string') {
|
|
23
|
-
throw new factory.errors.Argument('
|
|
23
|
+
throw new factory.errors.Argument('ticketedOffer.validForMemberTier', 'tier identifier must be string');
|
|
24
24
|
}
|
|
25
25
|
if (typeof memberProgramIdentifier !== 'string') {
|
|
26
|
-
throw new factory.errors.Argument('
|
|
26
|
+
throw new factory.errors.Argument('ticketedOffer.validForMemberTier', 'member program must be string');
|
|
27
27
|
}
|
|
28
28
|
if (memberProgramIdentifier !== memberProgramIdentifierMustBe) {
|
|
29
|
-
throw new factory.errors.Argument('
|
|
29
|
+
throw new factory.errors.Argument('ticketedOffer.validForMemberTier', 'member program not matched');
|
|
30
30
|
}
|
|
31
31
|
const sellerId = event.offers.seller.id;
|
|
32
32
|
if (typeof sellerId !== 'string' || sellerId === '') {
|
|
@@ -47,22 +47,6 @@ function validateMemberTier(params) {
|
|
|
47
47
|
if (productOfferForMemberTier === undefined) {
|
|
48
48
|
throw new factory.errors.NotFound(factory.offerType.Offer, 'valid product offers for member tier not found');
|
|
49
49
|
}
|
|
50
|
-
// let validThroughMoment: moment.Moment;
|
|
51
|
-
// let validFromMoment: moment.Moment;
|
|
52
|
-
// validThroughMoment = moment(productOfferForMemberTier.validThrough, ROLE_DATE_FORMAT, true);
|
|
53
|
-
// validFromMoment = moment(productOfferForMemberTier.validFrom, ROLE_DATE_FORMAT, true);
|
|
54
|
-
// if (acceptedDate.isBefore(validFromMoment)) {
|
|
55
|
-
// throw new factory.errors.Argument(
|
|
56
|
-
// 'reservationFor.offers.validForMemberTier',
|
|
57
|
-
// `the offer id valid from ${validFromMoment}`
|
|
58
|
-
// );
|
|
59
|
-
// }
|
|
60
|
-
// if (acceptedDate.isAfter(validThroughMoment)) {
|
|
61
|
-
// throw new factory.errors.Argument(
|
|
62
|
-
// 'reservationFor.offers.validForMemberTier',
|
|
63
|
-
// `the offer id valid through ${validThroughMoment}`
|
|
64
|
-
// );
|
|
65
|
-
// }
|
|
66
50
|
});
|
|
67
51
|
}
|
|
68
52
|
function verifyMemberTierToken(params) {
|
|
@@ -88,10 +72,10 @@ function verifyMemberTierToken(params) {
|
|
|
88
72
|
catch (error) {
|
|
89
73
|
// JWTエラーをハンドリング
|
|
90
74
|
if (error instanceof jwt.TokenExpiredError) {
|
|
91
|
-
throw new factory.errors.Argument('
|
|
75
|
+
throw new factory.errors.Argument('ticketedOffer.validForMemberTier', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
92
76
|
}
|
|
93
77
|
else if (error instanceof jwt.JsonWebTokenError) {
|
|
94
|
-
throw new factory.errors.Argument('
|
|
78
|
+
throw new factory.errors.Argument('ticketedOffer.validForMemberTier', `invalid token. [${error.message}]`);
|
|
95
79
|
}
|
|
96
80
|
throw error;
|
|
97
81
|
}
|
|
@@ -114,11 +98,11 @@ function validateMemberTierIfExists(params) {
|
|
|
114
98
|
const memberProgramIdentifierMustBe = (_c = tokenizedMemberProgramTier === null || tokenizedMemberProgramTier === void 0 ? void 0 : tokenizedMemberProgramTier.isTierOf) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
115
99
|
// ティアトークンが必須
|
|
116
100
|
if (typeof validForMemberTierToken !== 'string' || validForMemberTierToken === '') {
|
|
117
|
-
throw new factory.errors.ArgumentNull('
|
|
101
|
+
throw new factory.errors.ArgumentNull('ticketedOffer.validForMemberTier.token');
|
|
118
102
|
}
|
|
119
103
|
// メンバープログラムコード指定が必須
|
|
120
104
|
if (typeof memberProgramIdentifierMustBe !== 'string' || memberProgramIdentifierMustBe === '') {
|
|
121
|
-
throw new factory.errors.ArgumentNull('
|
|
105
|
+
throw new factory.errors.ArgumentNull('ticketedOffer.validForMemberTier.isTierOf.identifier');
|
|
122
106
|
}
|
|
123
107
|
// 有効メンバープログラムティアが存在する場合、オファーコレクションコードが必須
|
|
124
108
|
const aggregateOfferIdentifier = eventOffers.identifier;
|
|
@@ -152,33 +136,5 @@ function validateMemberTierIfExists(params) {
|
|
|
152
136
|
memberProgramIdentifierMustBe, aggregateOfferIdentifier
|
|
153
137
|
})(repos);
|
|
154
138
|
}
|
|
155
|
-
// tslint:disable-next-line:no-suspicious-comment
|
|
156
|
-
// TODO オファートークン検証(2025-10-21~)
|
|
157
|
-
// const offerTokenIssuer = makesOfferOnApplication.issuedBy?.identifier;
|
|
158
|
-
// const offerTokenRequired = typeof offerTokenIssuer === 'string';
|
|
159
|
-
// if (offerTokenRequired) {
|
|
160
|
-
// const offerToken = params.object.reservationFor?.offers?.token;
|
|
161
|
-
// if (typeof offerToken !== 'string' || offerToken === '') {
|
|
162
|
-
// throw new factory.errors.ArgumentNull('object.reservationFor.offers.token');
|
|
163
|
-
// }
|
|
164
|
-
// const issuer = await repos.issuer.findByIdentifier({
|
|
165
|
-
// project: { id: params.event.project.id },
|
|
166
|
-
// identifier: offerTokenIssuer
|
|
167
|
-
// });
|
|
168
|
-
// if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
169
|
-
// throw new factory.errors.NotFound('issuer.tokenSecret');
|
|
170
|
-
// }
|
|
171
|
-
// const verifiedOffer = await verifyOfferToken({
|
|
172
|
-
// secret: issuer.tokenSecret,
|
|
173
|
-
// issuer: issuer.url,
|
|
174
|
-
// token: offerToken
|
|
175
|
-
// });
|
|
176
|
-
// await validateOfferToken({
|
|
177
|
-
// acceptedDate,
|
|
178
|
-
// verifiedOffer,
|
|
179
|
-
// makesOfferOnApplication,
|
|
180
|
-
// object: params.object
|
|
181
|
-
// })();
|
|
182
|
-
// }
|
|
183
139
|
});
|
|
184
140
|
}
|
|
@@ -25,7 +25,7 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
25
25
|
if (typeof placeOrderIdByInstrument !== 'string' || placeOrderIdByInstrument === '') {
|
|
26
26
|
throw new factory.errors.NotFound('instrument as placeOrder');
|
|
27
27
|
}
|
|
28
|
-
const ticket = (yield repos.ticket.
|
|
28
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
29
29
|
limit: 1,
|
|
30
30
|
page: 1,
|
|
31
31
|
project: { id: { $eq: event.project.id } },
|
|
@@ -46,13 +46,11 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
46
46
|
throw new factory.errors.Argument('ticketToken', 'audience not matched with placeOrder');
|
|
47
47
|
}
|
|
48
48
|
if (authorizedObject.typeOf === factory.offerType.Offer) {
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// }
|
|
55
|
-
// }
|
|
49
|
+
// イベントIDを検証
|
|
50
|
+
const eventIdMustBe = authorizedObject.itemOffered.serviceOutput.reservationFor.id;
|
|
51
|
+
if (eventIdMustBe !== event.id) {
|
|
52
|
+
throw new factory.errors.Argument('ticketToken', 'event.id not matched');
|
|
53
|
+
}
|
|
56
54
|
acceptedEventOffer = authorizedObject;
|
|
57
55
|
}
|
|
58
56
|
else {
|
|
@@ -32,4 +32,32 @@ declare function validateStartRequest(params: {
|
|
|
32
32
|
productOffer: ProductOfferRepo;
|
|
33
33
|
ticket: TicketRepo;
|
|
34
34
|
}) => Promise<void>;
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* アプリケーションに対して有効なイベントオファーが存在するかどうかを検証する
|
|
37
|
+
*/
|
|
38
|
+
declare function validEventOfferByApplicationExists(params: {
|
|
39
|
+
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project' | 'identifier'>;
|
|
40
|
+
now: Date;
|
|
41
|
+
availableAt: {
|
|
42
|
+
/**
|
|
43
|
+
* 販売アプリケーションID
|
|
44
|
+
*/
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* オファー承認時のticketTokenから生成されたイベントオファー
|
|
49
|
+
*/
|
|
50
|
+
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
51
|
+
/**
|
|
52
|
+
* オファー承認時の予約数
|
|
53
|
+
* 0であれば特に何も検証されない
|
|
54
|
+
*/
|
|
55
|
+
numAcceptedOffers: number;
|
|
56
|
+
}): (repos: {
|
|
57
|
+
eventOffer: EventOfferRepo;
|
|
58
|
+
issuer: IssuerRepo;
|
|
59
|
+
member: MemberRepo;
|
|
60
|
+
memberProgram: MemberProgramRepo;
|
|
61
|
+
productOffer: ProductOfferRepo;
|
|
62
|
+
}) => Promise<void>;
|
|
63
|
+
export { validateStartRequest, validEventOfferByApplicationExists };
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.validateStartRequest = validateStartRequest;
|
|
13
|
+
exports.validEventOfferByApplicationExists = validEventOfferByApplicationExists;
|
|
13
14
|
const moment = require("moment");
|
|
14
15
|
const factory = require("../../../factory");
|
|
15
16
|
const fixExtendedEventOffer_1 = require("./validateStartRequest/fixExtendedEventOffer");
|
|
@@ -33,12 +34,12 @@ function validateStartRequest(params) {
|
|
|
33
34
|
object: params.object,
|
|
34
35
|
instrument: params.instrument
|
|
35
36
|
})(repos);
|
|
36
|
-
yield
|
|
37
|
+
yield validEventOfferByApplicationExists({
|
|
37
38
|
event,
|
|
38
39
|
now,
|
|
39
40
|
availableAt: { id: params.store.id },
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
acceptedEventOffer,
|
|
42
|
+
numAcceptedOffers: (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer.length : 0
|
|
42
43
|
})(repos);
|
|
43
44
|
}
|
|
44
45
|
if (params.validateEvent === true) {
|
|
@@ -47,11 +48,11 @@ function validateStartRequest(params) {
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
|
-
*
|
|
51
|
+
* アプリケーションに対して有効なイベントオファーが存在するかどうかを検証する
|
|
51
52
|
*/
|
|
52
|
-
function
|
|
53
|
+
function validEventOfferByApplicationExists(params) {
|
|
53
54
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const { event, availableAt, acceptedEventOffer } = params;
|
|
55
|
+
const { event, availableAt, acceptedEventOffer, numAcceptedOffers } = params;
|
|
55
56
|
const acceptedDate = moment(params.now);
|
|
56
57
|
const eventOffers = event.offers;
|
|
57
58
|
// アプリケーションごとの設定を参照する(2022-11-19~)
|
|
@@ -85,9 +86,9 @@ function validateApplicationOffer(params) {
|
|
|
85
86
|
yield (0, validateIssuedOfferIfExists_1.validateIssuedOfferIfExists)({
|
|
86
87
|
event,
|
|
87
88
|
now: params.now,
|
|
88
|
-
object: params.object,
|
|
89
89
|
eventOffer: existingEventOffer,
|
|
90
|
-
acceptedEventOffer
|
|
90
|
+
acceptedEventOffer,
|
|
91
|
+
numAcceptedOffers
|
|
91
92
|
})(repos);
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
@@ -96,7 +97,6 @@ function validateApplicationOffer(params) {
|
|
|
96
97
|
yield (0, validateMemberTierIfExists_1.validateMemberTierIfExists)({
|
|
97
98
|
event,
|
|
98
99
|
now: params.now,
|
|
99
|
-
object: params.object,
|
|
100
100
|
makesOfferOnApplication,
|
|
101
101
|
acceptedEventOffer
|
|
102
102
|
})(repos);
|
|
@@ -27,7 +27,7 @@ function requestedProgramMembershipUsed2permit(params) {
|
|
|
27
27
|
else if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) === 'Ticket') {
|
|
28
28
|
const { ticketToken } = programMembershipUsed;
|
|
29
29
|
if (typeof ticketToken === 'string') {
|
|
30
|
-
const ticket = (yield repos.ticket.
|
|
30
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
31
31
|
limit: 1,
|
|
32
32
|
page: 1,
|
|
33
33
|
project: { id: { $eq: params.project.id } },
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import type { ActionRepo } from '../../../repo/action';
|
|
3
|
+
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
4
|
+
import type { EventRepo } from '../../../repo/event';
|
|
5
|
+
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
6
|
+
import type { IssuerRepo } from '../../../repo/issuer';
|
|
7
|
+
import type { MemberRepo } from '../../../repo/member';
|
|
8
|
+
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
9
|
+
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
10
|
+
import type { TicketRepo } from '../../../repo/ticket';
|
|
11
|
+
import type { TransactionRepo } from '../../../repo/transaction';
|
|
12
|
+
declare function issueEventOfferTicket(params: {
|
|
13
|
+
now: Date;
|
|
14
|
+
audience: Pick<factory.action.authorize.offer.eventService.IPurpose, 'id'>;
|
|
15
|
+
/**
|
|
16
|
+
* イベントID
|
|
17
|
+
*/
|
|
18
|
+
eventId: string;
|
|
19
|
+
/**
|
|
20
|
+
* 拡張イベントオファーID
|
|
21
|
+
*/
|
|
22
|
+
eventOfferId?: string;
|
|
23
|
+
ticketedOffer?: Pick<factory.authorization.IOfferAsObject, 'token' | 'validForMemberTier'>;
|
|
24
|
+
author: Pick<factory.authorization.IAuthor, 'id' | 'typeOf'>;
|
|
25
|
+
project: {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
instrument: {
|
|
29
|
+
/**
|
|
30
|
+
* アプリケーションID
|
|
31
|
+
*/
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
}): (repos: {
|
|
35
|
+
action: ActionRepo;
|
|
36
|
+
authorization: AuthorizationRepo;
|
|
37
|
+
event: EventRepo;
|
|
38
|
+
eventOffer: EventOfferRepo;
|
|
39
|
+
issuer: IssuerRepo;
|
|
40
|
+
member: MemberRepo;
|
|
41
|
+
memberProgram: MemberProgramRepo;
|
|
42
|
+
productOffer: ProductOfferRepo;
|
|
43
|
+
ticket: TicketRepo;
|
|
44
|
+
transaction: TransactionRepo;
|
|
45
|
+
}) => Promise<{
|
|
46
|
+
ticketToken: string;
|
|
47
|
+
}>;
|
|
48
|
+
export { issueEventOfferTicket };
|