@chevre/domain 23.1.0-alpha.2 → 23.1.0-alpha.21
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/assetTransaction/processReserve.ts +8 -3
- package/example/src/chevre/authorizeEventServiceOffer.ts +7 -5
- package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
- package/example/src/chevre/eventOffer/publishEventOfferToken.ts +98 -0
- package/example/src/chevre/member/migrateMemberIdentifier.ts +99 -0
- package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
- package/example/src/chevre/reIndex.ts +2 -2
- package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
- package/lib/chevre/repo/authorization.d.ts +3 -2
- package/lib/chevre/repo/authorization.js +13 -5
- package/lib/chevre/repo/event.d.ts +2 -1
- package/lib/chevre/repo/event.js +4 -4
- package/lib/chevre/repo/eventOffer.d.ts +1 -1
- package/lib/chevre/repo/eventOffer.js +14 -8
- package/lib/chevre/repo/member.d.ts +18 -1
- package/lib/chevre/repo/member.js +14 -8
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +39 -35
- package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
- 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.d.ts +2 -1
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +63 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +32 -32
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +10 -54
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.d.ts +23 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +62 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +36 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +23 -27
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -3
- package/lib/chevre/service/offer/event/authorize/factory.js +4 -3
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +42 -25
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -4
- package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize.js +10 -5
- 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/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 +19 -27
- package/lib/chevre/service/payment/any.d.ts +1 -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/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/upsertManyEventsByAdditionalProperty.ts +0 -193
|
@@ -30,7 +30,7 @@ class MemberRepo {
|
|
|
30
30
|
}
|
|
31
31
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
32
32
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
34
34
|
const andConditions = [];
|
|
35
35
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
36
36
|
if (typeof idEq === 'string') {
|
|
@@ -64,7 +64,11 @@ class MemberRepo {
|
|
|
64
64
|
if (Array.isArray(memberIdIn)) {
|
|
65
65
|
andConditions.push({ 'member.id': { $in: memberIdIn } });
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const memberIdentifierEq = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
|
|
68
|
+
if (typeof memberIdentifierEq === 'string') {
|
|
69
|
+
andConditions.push({ 'member.identifier': { $exists: true, $eq: memberIdentifierEq } });
|
|
70
|
+
}
|
|
71
|
+
const memberNameRegex = (_w = (_v = params.member) === null || _v === void 0 ? void 0 : _v.name) === null || _w === void 0 ? void 0 : _w.$regex;
|
|
68
72
|
if (typeof memberNameRegex === 'string' && memberNameRegex.length > 0) {
|
|
69
73
|
andConditions.push({
|
|
70
74
|
'member.name': {
|
|
@@ -73,7 +77,7 @@ class MemberRepo {
|
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
|
-
const memberHasRoleRoleNameEq = (
|
|
80
|
+
const memberHasRoleRoleNameEq = (_z = (_y = (_x = params.member) === null || _x === void 0 ? void 0 : _x.hasRole) === null || _y === void 0 ? void 0 : _y.roleName) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
77
81
|
if (typeof memberHasRoleRoleNameEq === 'string') {
|
|
78
82
|
andConditions.push({
|
|
79
83
|
'member.hasRole.roleName': {
|
|
@@ -82,7 +86,7 @@ class MemberRepo {
|
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
|
-
const memberHasRoleRoleNameIn = (
|
|
89
|
+
const memberHasRoleRoleNameIn = (_2 = (_1 = (_0 = params.member) === null || _0 === void 0 ? void 0 : _0.hasRole) === null || _1 === void 0 ? void 0 : _1.roleName) === null || _2 === void 0 ? void 0 : _2.$in;
|
|
86
90
|
if (Array.isArray(memberHasRoleRoleNameIn)) {
|
|
87
91
|
andConditions.push({
|
|
88
92
|
'member.hasRole.roleName': {
|
|
@@ -110,7 +114,7 @@ class MemberRepo {
|
|
|
110
114
|
*/
|
|
111
115
|
searchCustomerMembers(params) {
|
|
112
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
114
118
|
if (typeof params.project.id !== 'string' || params.project.id === '') {
|
|
115
119
|
throw new factory.errors.ArgumentNull('project.id');
|
|
116
120
|
}
|
|
@@ -128,7 +132,8 @@ class MemberRepo {
|
|
|
128
132
|
}
|
|
129
133
|
},
|
|
130
134
|
id: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.member) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') ? { $eq: params.member.id.$eq } : undefined), (Array.isArray((_d = (_c = params.member) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in)) ? { $in: params.member.id.$in } : undefined),
|
|
131
|
-
|
|
135
|
+
identifier: Object.assign({}, (typeof ((_f = (_e = params.member) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$eq) === 'string') ? { $eq: params.member.identifier.$eq } : undefined),
|
|
136
|
+
name: Object.assign({}, (typeof ((_h = (_g = params.member) === null || _g === void 0 ? void 0 : _g.name) === null || _h === void 0 ? void 0 : _h.$regex) === 'string') ? { $regex: params.member.name.$regex } : undefined)
|
|
132
137
|
}
|
|
133
138
|
});
|
|
134
139
|
const projection = {
|
|
@@ -138,6 +143,7 @@ class MemberRepo {
|
|
|
138
143
|
// typeOf: 'WebApplication',
|
|
139
144
|
hasRole: '$member.hasRole',
|
|
140
145
|
id: '$member.id',
|
|
146
|
+
identifier: '$member.identifier',
|
|
141
147
|
member: '$member.member',
|
|
142
148
|
memberOf: '$member.memberOf',
|
|
143
149
|
name: '$member.name'
|
|
@@ -154,7 +160,7 @@ class MemberRepo {
|
|
|
154
160
|
},
|
|
155
161
|
{ $project: projection }
|
|
156
162
|
]);
|
|
157
|
-
if (typeof ((
|
|
163
|
+
if (typeof ((_j = params.sort) === null || _j === void 0 ? void 0 : _j['member.id']) === 'number') {
|
|
158
164
|
aggregate.sort(params.sort);
|
|
159
165
|
}
|
|
160
166
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
@@ -259,7 +265,7 @@ class MemberRepo {
|
|
|
259
265
|
'member.memberOf.id': { $eq: params.member.memberOf.id },
|
|
260
266
|
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
261
267
|
}, {
|
|
262
|
-
$set: Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined
|
|
268
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined), (typeof params.member.identifier === 'string') ? { 'member.identifier': params.member.identifier } : undefined
|
|
263
269
|
// discontinue(2025-01-14~)
|
|
264
270
|
// ...(Array.isArray(params.member.member)) ? { 'member.member': params.member.member } : undefined
|
|
265
271
|
),
|
|
@@ -44,41 +44,45 @@ const schemaOptions = {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const indexes = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
47
|
+
[
|
|
48
|
+
{ validFrom: 1 },
|
|
49
|
+
{ name: 'validFrom' }
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
{ validThrough: 1, validFrom: 1 },
|
|
53
|
+
{ name: 'validThrough' }
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
'project.id': 1,
|
|
58
|
+
'itemOffered.id': 1,
|
|
59
|
+
identifier: 1
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'uniqueByItemOfferedAndIdentifier',
|
|
63
|
+
unique: true
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
{ 'project.id': 1, validFrom: 1 },
|
|
68
|
+
{ name: 'projectId' }
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
{ 'seller.id': 1, validFrom: 1 },
|
|
72
|
+
{ name: 'sellerId' }
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
{ identifier: 1, validFrom: 1 },
|
|
76
|
+
{ name: 'identifier' }
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
{ 'itemOffered.id': 1, validFrom: 1 },
|
|
80
|
+
{ name: 'itemOfferedId' }
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
{ 'availableAtOrFrom.identifier': 1, validFrom: 1 },
|
|
84
|
+
{ name: 'availableAtOrFrom' }
|
|
85
|
+
]
|
|
82
86
|
];
|
|
83
87
|
exports.indexes = indexes;
|
|
84
88
|
/**
|
|
@@ -61,6 +61,16 @@ const indexes = [
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
|
+
[
|
|
65
|
+
{ 'project.id': 1, 'member.identifier': 1 }, // アプリケーションコード追加(2025-11-17~)
|
|
66
|
+
{
|
|
67
|
+
name: 'uniqueByMemberIdentifier',
|
|
68
|
+
unique: true,
|
|
69
|
+
partialFilterExpression: {
|
|
70
|
+
'member.identifier': { $exists: true }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
],
|
|
64
74
|
[
|
|
65
75
|
{ 'project.id': 1, 'member.id': 1, 'member.memberOf.id': 1 },
|
|
66
76
|
{
|
|
@@ -14,7 +14,7 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
|
|
|
14
14
|
*/
|
|
15
15
|
id: string;
|
|
16
16
|
}[];
|
|
17
|
-
instrument: factory.action.trade.pay.
|
|
17
|
+
instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
|
|
18
18
|
}, options: {
|
|
19
19
|
checkedAction: {
|
|
20
20
|
id: string;
|
|
@@ -7,7 +7,7 @@ exports.createStartParams = createStartParams;
|
|
|
7
7
|
const factory = require("../../../factory");
|
|
8
8
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
9
9
|
function createStartParams(params, options) {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
11
11
|
const { instrument } = params;
|
|
12
12
|
const paymentServiceId = (params.paymentService !== undefined)
|
|
13
13
|
? String(params.paymentService.id)
|
|
@@ -109,7 +109,12 @@ function createStartParams(params, options) {
|
|
|
109
109
|
: undefined);
|
|
110
110
|
const object = Object.assign({ accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: params.transactionNumber, typeOf: params.paymentServiceType, id: paymentServiceId,
|
|
111
111
|
// onPaymentStatusChanged: { informPayment: params.informActions }, // discontinue(2025-02-09~)
|
|
112
|
-
paymentMethod
|
|
112
|
+
paymentMethod, serviceOutput: (((_0 = params.object.serviceOutput) === null || _0 === void 0 ? void 0 : _0.typeOf) === 'Invoice') // support serviceOutput(2025-11-24~)
|
|
113
|
+
? params.object.serviceOutput
|
|
114
|
+
: {
|
|
115
|
+
typeOf: 'Invoice',
|
|
116
|
+
referencesOrder: { typeOf: factory.order.OrderType.Order }
|
|
117
|
+
} }, (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket)
|
|
113
118
|
? { checkedAction: { id: options.checkedAction.id } } // add checkedAction(2024-12-13~)
|
|
114
119
|
: undefined);
|
|
115
120
|
const potentialAction = [];
|
|
@@ -118,7 +123,7 @@ function createStartParams(params, options) {
|
|
|
118
123
|
potentialAction.push({ id: informAction.id, typeOf: factory.actionType.InformAction });
|
|
119
124
|
}
|
|
120
125
|
});
|
|
121
|
-
return Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires, instrument: (Array.isArray(instrument)) ? instrument : [] }, (typeof ((
|
|
126
|
+
return Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires, instrument: (Array.isArray(instrument)) ? instrument : [] }, (typeof ((_1 = params.location) === null || _1 === void 0 ? void 0 : _1.typeOf) === 'string')
|
|
122
127
|
? { location: params.location }
|
|
123
128
|
: undefined), (potentialAction.length > 0) ? { potentialAction } : undefined // add potentialAction(2025-02-05~)
|
|
124
129
|
);
|
|
@@ -78,6 +78,7 @@ export declare function publishPaymentUrl(params: Pick<factory.assetTransaction.
|
|
|
78
78
|
* add identifier for an unique index(2025-02-25~)
|
|
79
79
|
*/
|
|
80
80
|
identifier?: string;
|
|
81
|
+
instrument: factory.action.accept.pay.IInstrument[];
|
|
81
82
|
}, options: {
|
|
82
83
|
purposeAsTransaction: {
|
|
83
84
|
id: string;
|
|
@@ -104,7 +105,7 @@ export import IPaymentAgencyTransaction = CreditCardPayment.IPaymentAgencyTransa
|
|
|
104
105
|
* 取引開始
|
|
105
106
|
*/
|
|
106
107
|
export declare function start(params: factory.assetTransaction.pay.IStartParamsWithoutDetail & {
|
|
107
|
-
instrument: factory.action.trade.pay.
|
|
108
|
+
instrument: factory.action.trade.pay.IPlaceOrderRelatedInstrument[];
|
|
108
109
|
}, options: {
|
|
109
110
|
pendingPaymentAgencyTransaction?: CreditCardPayment.IPaymentAgencyTransaction;
|
|
110
111
|
/**
|
|
@@ -84,7 +84,7 @@ function publishPaymentUrl(params, options) {
|
|
|
84
84
|
object: params.object,
|
|
85
85
|
transactionNumber,
|
|
86
86
|
typeOf: params.typeOf
|
|
87
|
-
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id } }, (typeof taskId === 'string')
|
|
87
|
+
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id }, instrument: (Array.isArray(params.instrument)) ? params.instrument : [] }, (typeof taskId === 'string')
|
|
88
88
|
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-22~)
|
|
89
89
|
: undefined), (typeof ((_d = params.location) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
|
|
90
90
|
? { location: params.location }
|
|
@@ -2,10 +2,12 @@ import * as factory from '../../../factory';
|
|
|
2
2
|
import { Settings } from '../../../settings';
|
|
3
3
|
import type { AdvanceBookingRequirementRepo } from '../../../repo/advanceBookingRequirement';
|
|
4
4
|
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
5
|
+
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
5
6
|
import type { EventRepo } from '../../../repo/event';
|
|
6
7
|
import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
7
8
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
8
9
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
10
|
+
import type { MemberRepo } from '../../../repo/member';
|
|
9
11
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
10
12
|
import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
|
|
11
13
|
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
@@ -20,13 +22,16 @@ import type { OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
|
20
22
|
import type { SettingRepo } from '../../../repo/setting';
|
|
21
23
|
import type { StockHolderRepo } from '../../../repo/stockHolder';
|
|
22
24
|
import type { TaskRepo } from '../../../repo/task';
|
|
25
|
+
import type { TicketRepo } from '../../../repo/ticket';
|
|
23
26
|
interface IStartOperationRepos {
|
|
24
27
|
advanceBookingRequirement: AdvanceBookingRequirementRepo;
|
|
28
|
+
authorization: AuthorizationRepo;
|
|
25
29
|
stockHolder: StockHolderRepo;
|
|
26
30
|
event: EventRepo;
|
|
27
31
|
eventOffer: EventOfferRepo;
|
|
28
32
|
eventSeries: EventSeriesRepo;
|
|
29
33
|
issuer: IssuerRepo;
|
|
34
|
+
member: MemberRepo;
|
|
30
35
|
memberProgram: MemberProgramRepo;
|
|
31
36
|
offer: OfferRepo;
|
|
32
37
|
offerCatalog: OfferCatalogRepo;
|
|
@@ -40,6 +45,7 @@ interface IStartOperationRepos {
|
|
|
40
45
|
seat: SeatRepo;
|
|
41
46
|
setting: SettingRepo;
|
|
42
47
|
task: TaskRepo;
|
|
48
|
+
ticket: TicketRepo;
|
|
43
49
|
assetTransaction: AssetTransactionRepo;
|
|
44
50
|
}
|
|
45
51
|
type IStartOperation<T> = (repos: IStartOperationRepos, settings: Settings) => Promise<T>;
|
|
@@ -41,16 +41,20 @@ function start(params, options) {
|
|
|
41
41
|
// validationを承認アクション開始前から移行(2023-01-27~)
|
|
42
42
|
yield (0, validateStartRequest_1.validateStartRequest)({
|
|
43
43
|
object: params.object,
|
|
44
|
+
instrument: params.instrument,
|
|
44
45
|
event,
|
|
45
46
|
validateEventOfferPeriod: params.validateEventOfferPeriod,
|
|
46
47
|
validateEvent: params.validateEvent,
|
|
47
48
|
now,
|
|
48
49
|
store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id }
|
|
49
50
|
})({
|
|
51
|
+
authorization: repos.authorization,
|
|
50
52
|
eventOffer: repos.eventOffer,
|
|
51
53
|
issuer: repos.issuer,
|
|
54
|
+
member: repos.member,
|
|
52
55
|
memberProgram: repos.memberProgram,
|
|
53
|
-
productOffer: repos.productOffer
|
|
56
|
+
productOffer: repos.productOffer,
|
|
57
|
+
ticket: repos.ticket
|
|
54
58
|
});
|
|
55
59
|
// objectに必要な情報をそろえる
|
|
56
60
|
const { acceptedOffers4transactionObject, objectSubReservations } = yield createObjectAttributes({
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as factory from '../../../../factory';
|
|
2
|
+
import { IMinimizedIndividualEvent } from '../../../../factory/event';
|
|
3
|
+
import type { EventOfferRepo } from '../../../../repo/eventOffer';
|
|
4
|
+
import type { MemberRepo } from '../../../../repo/member';
|
|
5
|
+
/**
|
|
6
|
+
* リクエストから拡張イベントオファーを決定する
|
|
7
|
+
*/
|
|
8
|
+
declare function fixExtendedEventOffer(params: {
|
|
9
|
+
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project' | 'identifier'>;
|
|
10
|
+
now: Date;
|
|
11
|
+
availableAt: {
|
|
12
|
+
/**
|
|
13
|
+
* 販売アプリケーションID
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
18
|
+
}): (repos: {
|
|
19
|
+
eventOffer: EventOfferRepo;
|
|
20
|
+
member: MemberRepo;
|
|
21
|
+
}) => Promise<Pick<factory.eventOffer.IEventOffer, "identifier" | "itemOffered" | "typeOf" | "offeredBy" | "validFrom" | "validThrough" | "id">>;
|
|
22
|
+
export { fixExtendedEventOffer };
|
package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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.fixExtendedEventOffer = fixExtendedEventOffer;
|
|
13
|
+
const moment = require("moment");
|
|
14
|
+
const factory = require("../../../../factory");
|
|
15
|
+
/**
|
|
16
|
+
* リクエストから拡張イベントオファーを決定する
|
|
17
|
+
*/
|
|
18
|
+
function fixExtendedEventOffer(params) {
|
|
19
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a;
|
|
21
|
+
const { event, availableAt } = params;
|
|
22
|
+
const acceptedDate = moment(params.now);
|
|
23
|
+
// リクエストによるオファーコード指定が必須
|
|
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
|
+
}
|
|
28
|
+
// アプリケーションIDからアプリケーションコードを参照
|
|
29
|
+
const existingCustomerMember = (yield repos.member.searchCustomerMembers({
|
|
30
|
+
project: { id: event.project.id },
|
|
31
|
+
limit: 1,
|
|
32
|
+
page: 1,
|
|
33
|
+
member: {
|
|
34
|
+
id: { $eq: availableAt.id }
|
|
35
|
+
}
|
|
36
|
+
})).shift();
|
|
37
|
+
if (existingCustomerMember === undefined) {
|
|
38
|
+
throw new factory.errors.NotFound(`Member: ${availableAt.id}`);
|
|
39
|
+
}
|
|
40
|
+
// tslint:disable-next-line:no-console
|
|
41
|
+
console.log('existingCustomerMember found:', JSON.stringify(existingCustomerMember));
|
|
42
|
+
const applicationIdentifier = existingCustomerMember.member.identifier;
|
|
43
|
+
if (typeof applicationIdentifier !== 'string') {
|
|
44
|
+
throw new factory.errors.NotFound(`member.identifier of ${availableAt.id}`);
|
|
45
|
+
}
|
|
46
|
+
// アプリケーションコードで利用可能な拡張オファーを検索
|
|
47
|
+
const existingEventOffer = (yield repos.eventOffer.findEventOffers({
|
|
48
|
+
limit: 1,
|
|
49
|
+
page: 1,
|
|
50
|
+
project: { id: { $eq: event.project.id } }, // プロジェクト
|
|
51
|
+
validFrom: { $lte: acceptedDate.toDate() },
|
|
52
|
+
validThrough: { $gte: acceptedDate.toDate() },
|
|
53
|
+
itemOffered: { id: { $eq: event.id } }, // 対象イベント
|
|
54
|
+
id: { $eq: eventOfferIdMustBe }, // オファーID
|
|
55
|
+
// identifier: { $eq: eventOfferIdentifierMustBe }, // オファーコード
|
|
56
|
+
availableAtOrFrom: { identifier: { $eq: applicationIdentifier } } // アプリケーションコード
|
|
57
|
+
}, ['identifier', 'itemOffered', 'offeredBy', 'typeOf', 'validFrom', 'validThrough'])).shift();
|
|
58
|
+
if (existingEventOffer === undefined) {
|
|
59
|
+
throw new factory.errors.NotFound(`valid eventOffer: ${eventOfferIdMustBe}`);
|
|
60
|
+
}
|
|
61
|
+
return existingEventOffer;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -7,8 +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
|
-
|
|
10
|
+
eventOffer: Pick<factory.eventOffer.IEventOffer, 'identifier' | 'itemOffered' | 'offeredBy' | 'validFrom' | 'validThrough' | 'id'>;
|
|
11
|
+
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
12
|
+
/**
|
|
13
|
+
* オファー承認時の予約数
|
|
14
|
+
* 0であれば特に何も検証されない
|
|
15
|
+
*/
|
|
16
|
+
numAcceptedOffers: number;
|
|
12
17
|
}): (repos: {
|
|
13
18
|
issuer: IssuerRepo;
|
|
14
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`);
|
|
@@ -114,16 +114,16 @@ function validateOfferToken(params) {
|
|
|
114
114
|
*/
|
|
115
115
|
function validateIssuedOfferIfExists(params) {
|
|
116
116
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
var _a, _b, _c
|
|
118
|
-
const { event, eventOffer } = params;
|
|
117
|
+
var _a, _b, _c;
|
|
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
|
|
124
|
-
const offerToken = (
|
|
125
|
-
if (typeof
|
|
126
|
-
throw new factory.errors.
|
|
123
|
+
const offerIdMustBe = (_b = params.acceptedEventOffer) === null || _b === void 0 ? void 0 : _b.id;
|
|
124
|
+
const offerToken = (_c = params.acceptedEventOffer) === null || _c === void 0 ? void 0 : _c.token;
|
|
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,8 +6,8 @@ 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;
|
|
10
|
+
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
11
11
|
}): (repos: {
|
|
12
12
|
issuer: IssuerRepo;
|
|
13
13
|
memberProgram: MemberProgramRepo;
|