@chevre/domain 24.0.0-alpha.81 → 24.0.0-alpha.82
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/repo/mongoose/schemas/setting.d.ts +0 -1
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +1 -12
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +0 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +0 -3
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -11
- package/lib/chevre/service/notification/triggerWebhook.js +43 -48
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +1 -3
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +11 -13
- package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.js +2 -7
- package/lib/chevre/service/payment/creditCard/gmoError.d.ts +1 -31
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +2 -2
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +1 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +0 -2
- package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +0 -6
- package/lib/chevre/service/task/onResourceDeleted.js +0 -2
- package/lib/chevre/service/task/onResourceUpdated.js +0 -2
- package/package.json +3 -3
- package/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +0 -14
- package/lib/chevre/repo/mongoose/schemas/productOffer.js +0 -108
- package/lib/chevre/repo/productOffer.d.ts +0 -52
- package/lib/chevre/repo/productOffer.js +0 -209
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +0 -16
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +0 -129
|
@@ -72,7 +72,6 @@ import type { PriceSpecificationRepo } from './repo/priceSpecification';
|
|
|
72
72
|
import type { ProductRepo } from './repo/product';
|
|
73
73
|
import type { ProductHasOfferCatalogRepo } from './repo/productHasOfferCatalog';
|
|
74
74
|
import type { ProductModelRepo } from './repo/productModel';
|
|
75
|
-
import type { ProductOfferRepo } from './repo/productOffer';
|
|
76
75
|
import type { ProjectRepo } from './repo/project';
|
|
77
76
|
import type { ProjectMakesOfferRepo } from './repo/projectMakesOffer';
|
|
78
77
|
import type { OfferRateLimitRepo } from './repo/rateLimit/offer';
|
|
@@ -421,10 +420,6 @@ export type ProductModel = ProductModelRepo;
|
|
|
421
420
|
export declare namespace ProductModel {
|
|
422
421
|
function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
|
|
423
422
|
}
|
|
424
|
-
export type ProductOffer = ProductOfferRepo;
|
|
425
|
-
export declare namespace ProductOffer {
|
|
426
|
-
function createInstance(...params: ConstructorParameters<typeof ProductOfferRepo>): Promise<ProductOfferRepo>;
|
|
427
|
-
}
|
|
428
423
|
export type Project = ProjectRepo;
|
|
429
424
|
export declare namespace Project {
|
|
430
425
|
function createInstance(...params: ConstructorParameters<typeof ProjectRepo>): Promise<ProjectRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAction = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
4
|
-
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.
|
|
4
|
+
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = void 0;
|
|
5
5
|
var AcceptedOffer;
|
|
6
6
|
(function (AcceptedOffer) {
|
|
7
7
|
let repo;
|
|
@@ -843,17 +843,6 @@ var ProductModel;
|
|
|
843
843
|
}
|
|
844
844
|
ProductModel.createInstance = createInstance;
|
|
845
845
|
})(ProductModel || (exports.ProductModel = ProductModel = {}));
|
|
846
|
-
var ProductOffer;
|
|
847
|
-
(function (ProductOffer) {
|
|
848
|
-
let repo;
|
|
849
|
-
async function createInstance(...params) {
|
|
850
|
-
if (repo === undefined) {
|
|
851
|
-
repo = (await import('./repo/productOffer.js')).ProductOfferRepo;
|
|
852
|
-
}
|
|
853
|
-
return new repo(...params);
|
|
854
|
-
}
|
|
855
|
-
ProductOffer.createInstance = createInstance;
|
|
856
|
-
})(ProductOffer || (exports.ProductOffer = ProductOffer = {}));
|
|
857
846
|
var Project;
|
|
858
847
|
(function (Project) {
|
|
859
848
|
let repo;
|
|
@@ -16,7 +16,6 @@ import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
|
16
16
|
import { SeatRepo } from '../../../repo/place/seat';
|
|
17
17
|
import type { PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
18
18
|
import type { ProductRepo } from '../../../repo/product';
|
|
19
|
-
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
20
19
|
import type { ProjectRepo } from '../../../repo/project';
|
|
21
20
|
import type { OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
22
21
|
import type { SettingRepo } from '../../../repo/setting';
|
|
@@ -39,7 +38,6 @@ interface IStartOperationRepos {
|
|
|
39
38
|
offerRateLimit: OfferRateLimitRepo;
|
|
40
39
|
paymentService: PaymentServiceRepo;
|
|
41
40
|
product: ProductRepo;
|
|
42
|
-
productOffer: ProductOfferRepo;
|
|
43
41
|
priceSpecification: PriceSpecificationRepo;
|
|
44
42
|
project: ProjectRepo;
|
|
45
43
|
seat: SeatRepo;
|
|
@@ -5,7 +5,6 @@ import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
|
5
5
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
6
6
|
import type { MemberRepo } from '../../../repo/member';
|
|
7
7
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
8
|
-
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
9
8
|
import type { TicketRepo } from '../../../repo/ticket';
|
|
10
9
|
declare function validateStartRequest(params: {
|
|
11
10
|
object: factory.assetTransaction.reserve.IObjectWithoutDetail;
|
|
@@ -29,7 +28,6 @@ declare function validateStartRequest(params: {
|
|
|
29
28
|
issuer: IssuerRepo;
|
|
30
29
|
member: MemberRepo;
|
|
31
30
|
memberProgram: MemberProgramRepo;
|
|
32
|
-
productOffer: ProductOfferRepo;
|
|
33
31
|
ticket: TicketRepo;
|
|
34
32
|
}) => Promise<void>;
|
|
35
33
|
/**
|
|
@@ -58,6 +56,5 @@ declare function validEventOfferByApplicationExists(params: {
|
|
|
58
56
|
issuer: IssuerRepo;
|
|
59
57
|
member: MemberRepo;
|
|
60
58
|
memberProgram: MemberProgramRepo;
|
|
61
|
-
productOffer: ProductOfferRepo;
|
|
62
59
|
}) => Promise<void>;
|
|
63
60
|
export { validateStartRequest, validEventOfferByApplicationExists };
|
|
@@ -9,7 +9,6 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
9
9
|
const factory_1 = require("../../../factory");
|
|
10
10
|
const fixExtendedEventOffer_1 = require("./validateStartRequest/fixExtendedEventOffer");
|
|
11
11
|
const validateIssuedOfferIfExists_1 = require("./validateStartRequest/validateIssuedOfferIfExists");
|
|
12
|
-
const validateMemberTierIfExists_1 = require("./validateStartRequest/validateMemberTierIfExists");
|
|
13
12
|
const verifyTicketTokenAsNeeded_1 = require("./validateStartRequest/verifyTicketTokenAsNeeded");
|
|
14
13
|
function validateStartRequest(params) {
|
|
15
14
|
return async (repos) => {
|
|
@@ -59,8 +58,6 @@ function validEventOfferByApplicationExists(params) {
|
|
|
59
58
|
}
|
|
60
59
|
const validFrom = makesOfferOnApplication.validFrom;
|
|
61
60
|
const validThrough = makesOfferOnApplication.validThrough;
|
|
62
|
-
// const validFrom = eventOffers?.validFrom;
|
|
63
|
-
// const validThrough = eventOffers?.validThrough;
|
|
64
61
|
if (validFrom !== undefined && validFrom !== null) {
|
|
65
62
|
if (acceptedDate.isBefore((0, moment_1.default)(validFrom))) {
|
|
66
63
|
throw new factory_1.factory.errors.Argument('reservationFor.id', `Offer of ${params.event.id} is valid from ${validFrom}`);
|
|
@@ -84,14 +81,7 @@ function validEventOfferByApplicationExists(params) {
|
|
|
84
81
|
})(repos);
|
|
85
82
|
}
|
|
86
83
|
else {
|
|
87
|
-
//
|
|
88
|
-
// 有効メンバープログラムティアが存在する場合
|
|
89
|
-
await (0, validateMemberTierIfExists_1.validateMemberTierIfExists)({
|
|
90
|
-
event,
|
|
91
|
-
now: params.now,
|
|
92
|
-
makesOfferOnApplication,
|
|
93
|
-
acceptedEventOffer
|
|
94
|
-
})(repos);
|
|
84
|
+
// 拡張イベントオファーを利用しない場合は、これ以上検証なし
|
|
95
85
|
}
|
|
96
86
|
};
|
|
97
87
|
}
|
|
@@ -155,7 +155,6 @@ function signRequest(params) {
|
|
|
155
155
|
function processInformAction(params, options) {
|
|
156
156
|
return async (repos) => {
|
|
157
157
|
const timeout = options?.triggerWebhook?.timeout;
|
|
158
|
-
const useFetchAPI = options?.triggerWebhook?.useFetchAPI === true;
|
|
159
158
|
const secretKey = options?.triggerWebhook?.secretKey;
|
|
160
159
|
const headerIdentifier = options?.triggerWebhook?.headerIdentifier;
|
|
161
160
|
const { identifier } = params;
|
|
@@ -180,63 +179,59 @@ function processInformAction(params, options) {
|
|
|
180
179
|
&& typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
181
180
|
signature = signRequest({ requestBody, timestamp, secretKey });
|
|
182
181
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const res = await fetch(urlTemplate, {
|
|
192
|
-
method: 'POST',
|
|
193
|
-
headers,
|
|
194
|
-
body: requestBody, // body data type must match "Content-Type" header
|
|
195
|
-
...(typeof timeout === 'number')
|
|
196
|
-
? { signal: AbortSignal.timeout(timeout) }
|
|
197
|
-
: undefined
|
|
198
|
-
});
|
|
199
|
-
let body;
|
|
200
|
-
try {
|
|
201
|
-
body = await res.text();
|
|
182
|
+
const headers = new Headers({ 'Content-Type': 'application/json' });
|
|
183
|
+
if (typeof headerIdentifier === 'string' && headerIdentifier !== '') {
|
|
184
|
+
headers.append(`X-${headerIdentifier}-Webhook-Timestamp`, String(timestamp));
|
|
185
|
+
if (typeof signature === 'string') {
|
|
186
|
+
headers.append(`X-${headerIdentifier}-Webhook-Signature`, signature);
|
|
202
187
|
}
|
|
203
|
-
|
|
204
|
-
|
|
188
|
+
}
|
|
189
|
+
const res = await fetch(urlTemplate, {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
headers,
|
|
192
|
+
body: requestBody, // body data type must match "Content-Type" header
|
|
193
|
+
...(typeof timeout === 'number')
|
|
194
|
+
? { signal: AbortSignal.timeout(timeout) }
|
|
195
|
+
: undefined
|
|
196
|
+
});
|
|
197
|
+
let body;
|
|
198
|
+
try {
|
|
199
|
+
body = await res.text();
|
|
200
|
+
}
|
|
201
|
+
catch (_error) {
|
|
202
|
+
// no op
|
|
203
|
+
}
|
|
204
|
+
switch (res.status) {
|
|
205
|
+
case http_status_1.status.OK:
|
|
206
|
+
case http_status_1.status.CREATED:
|
|
207
|
+
case http_status_1.status.ACCEPTED:
|
|
208
|
+
case http_status_1.status.NO_CONTENT: {
|
|
209
|
+
result = {
|
|
210
|
+
statusCode: res.status,
|
|
211
|
+
useFetchAPI: true
|
|
212
|
+
};
|
|
213
|
+
break;
|
|
205
214
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
statusCode: res.status,
|
|
213
|
-
useFetchAPI
|
|
214
|
-
};
|
|
215
|
-
break;
|
|
216
|
-
default:
|
|
215
|
+
default: {
|
|
216
|
+
// プロジェクト固有の特別対応
|
|
217
|
+
const ignoreUnexpectedResponse = res.status === http_status_1.status.INTERNAL_SERVER_ERROR
|
|
218
|
+
&& typeof body === 'string'
|
|
219
|
+
&& body.includes(USERNAME_ARGUMENT_REQUIRED_MESSAGE);
|
|
220
|
+
if (!ignoreUnexpectedResponse) {
|
|
217
221
|
throw new factory_1.factory.errors.Internal(`statusCode: ${res.status} body: ${body}`);
|
|
222
|
+
}
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
|
-
else {
|
|
221
|
-
throw new factory_1.factory.errors.NotImplemented('only useFetchAPI implemented');
|
|
222
|
-
}
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
227
|
catch (error) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (error.statusCode === http_status_1.status.INTERNAL_SERVER_ERROR && error.body?.message === USERNAME_ARGUMENT_REQUIRED_MESSAGE) {
|
|
229
|
-
throwsError = false;
|
|
228
|
+
try {
|
|
229
|
+
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
234
|
-
}
|
|
235
|
-
catch (__) {
|
|
236
|
-
// 失敗したら仕方ない
|
|
237
|
-
}
|
|
238
|
-
throw error;
|
|
231
|
+
catch (__) {
|
|
232
|
+
// 失敗したら仕方ない
|
|
239
233
|
}
|
|
234
|
+
throw error;
|
|
240
235
|
}
|
|
241
236
|
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
242
237
|
};
|
|
@@ -16,7 +16,6 @@ import type { PaymentServiceRepo } from '../../../../repo/paymentService';
|
|
|
16
16
|
import type { SeatRepo } from '../../../../repo/place/seat';
|
|
17
17
|
import type { PriceSpecificationRepo } from '../../../../repo/priceSpecification';
|
|
18
18
|
import type { ProductRepo } from '../../../../repo/product';
|
|
19
|
-
import type { ProductOfferRepo } from '../../../../repo/productOffer';
|
|
20
19
|
import type { ProjectRepo } from '../../../../repo/project';
|
|
21
20
|
import type { OfferRateLimitRepo } from '../../../../repo/rateLimit/offer';
|
|
22
21
|
import type { SettingRepo } from '../../../../repo/setting';
|
|
@@ -65,7 +64,6 @@ declare function processStartReserve4chevre(params: {
|
|
|
65
64
|
offerRateLimit: OfferRateLimitRepo;
|
|
66
65
|
paymentService: PaymentServiceRepo;
|
|
67
66
|
product: ProductRepo;
|
|
68
|
-
productOffer: ProductOfferRepo;
|
|
69
67
|
priceSpecification: PriceSpecificationRepo;
|
|
70
68
|
project: ProjectRepo;
|
|
71
69
|
seat: SeatRepo;
|
|
@@ -19,7 +19,6 @@ import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
|
19
19
|
import type { SeatRepo } from '../../../repo/place/seat';
|
|
20
20
|
import type { PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
21
21
|
import type { ProductRepo } from '../../../repo/product';
|
|
22
|
-
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
23
22
|
import type { ProjectRepo } from '../../../repo/project';
|
|
24
23
|
import type { OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
|
|
25
24
|
import type { SettingRepo } from '../../../repo/setting';
|
|
@@ -50,7 +49,6 @@ interface IAuthorizeRepos {
|
|
|
50
49
|
paymentService: PaymentServiceRepo;
|
|
51
50
|
priceSpecification: PriceSpecificationRepo;
|
|
52
51
|
product: ProductRepo;
|
|
53
|
-
productOffer: ProductOfferRepo;
|
|
54
52
|
project: ProjectRepo;
|
|
55
53
|
seat: SeatRepo;
|
|
56
54
|
setting: SettingRepo;
|
|
@@ -6,7 +6,6 @@ import type { EventOfferRepo } from '../../../repo/eventOffer';
|
|
|
6
6
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
7
7
|
import type { MemberRepo } from '../../../repo/member';
|
|
8
8
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
9
|
-
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
10
9
|
import type { TicketRepo } from '../../../repo/ticket';
|
|
11
10
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
12
11
|
interface IIssueEventOfferTicketRepos {
|
|
@@ -18,7 +17,6 @@ interface IIssueEventOfferTicketRepos {
|
|
|
18
17
|
issuer: IssuerRepo;
|
|
19
18
|
member: MemberRepo;
|
|
20
19
|
memberProgram: MemberProgramRepo;
|
|
21
|
-
productOffer: ProductOfferRepo;
|
|
22
20
|
ticket: TicketRepo;
|
|
23
21
|
placeOrder: PlaceOrderRepo;
|
|
24
22
|
}
|
|
@@ -33,7 +31,7 @@ declare function issueEventOfferTicket(params: {
|
|
|
33
31
|
* 拡張イベントオファーID
|
|
34
32
|
*/
|
|
35
33
|
eventOfferId?: string;
|
|
36
|
-
ticketedOffer?: Pick<factory.authorization.IOfferAsObject, 'token'
|
|
34
|
+
ticketedOffer?: Pick<factory.authorization.IOfferAsObject, 'token'>;
|
|
37
35
|
author: Pick<factory.authorization.IAuthor, 'id' | 'typeOf'>;
|
|
38
36
|
project: {
|
|
39
37
|
id: string;
|
|
@@ -66,8 +66,6 @@ function issueEventOfferTicket(params) {
|
|
|
66
66
|
const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: audience.id }, ['expires', 'typeOf', 'seller']);
|
|
67
67
|
// イベントは存在するか
|
|
68
68
|
const event = await repos.event.projectEventFieldsById({ id: eventId }, ['project', 'offers', 'identifier']);
|
|
69
|
-
// 取引番号発行
|
|
70
|
-
// const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: now });
|
|
71
69
|
const { seller } = transaction;
|
|
72
70
|
// 承認作成
|
|
73
71
|
const issuedBy = {
|
|
@@ -75,8 +73,8 @@ function issueEventOfferTicket(params) {
|
|
|
75
73
|
typeOf: seller.typeOf,
|
|
76
74
|
...(typeof seller.name.ja === 'string') ? { name: seller.name.ja } : undefined
|
|
77
75
|
};
|
|
78
|
-
const validForMemberTierToken = ticketedOffer?.validForMemberTier?.token;
|
|
79
|
-
const validForMemberProgramIdentifier = ticketedOffer?.validForMemberTier?.isTierOf.identifier;
|
|
76
|
+
// const validForMemberTierToken = ticketedOffer?.validForMemberTier?.token;
|
|
77
|
+
// const validForMemberProgramIdentifier = ticketedOffer?.validForMemberTier?.isTierOf.identifier;
|
|
80
78
|
const authorizationObject = {
|
|
81
79
|
typeOf: factory_1.factory.offerType.Offer,
|
|
82
80
|
itemOffered: {
|
|
@@ -90,15 +88,15 @@ function issueEventOfferTicket(params) {
|
|
|
90
88
|
...(typeof ticketedOffer?.token === 'string' && ticketedOffer.token !== '')
|
|
91
89
|
? { token: ticketedOffer.token }
|
|
92
90
|
: undefined,
|
|
93
|
-
...(typeof validForMemberTierToken === 'string' && validForMemberTierToken !== ''
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
// ...(typeof validForMemberTierToken === 'string' && validForMemberTierToken !== ''
|
|
92
|
+
// && typeof validForMemberProgramIdentifier === 'string' && validForMemberProgramIdentifier !== '')
|
|
93
|
+
// ? {
|
|
94
|
+
// validForMemberTier: {
|
|
95
|
+
// token: validForMemberTierToken,
|
|
96
|
+
// isTierOf: { identifier: validForMemberProgramIdentifier }
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
// : undefined
|
|
102
100
|
};
|
|
103
101
|
// validations(eventId,eventOfferIdentifier,offerToken...)
|
|
104
102
|
await (0, validateStartRequest_1.validEventOfferByApplicationExists)({
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.handleAuthorizeError = handleAuthorizeError;
|
|
7
|
-
const
|
|
4
|
+
const gmo_service_1 = require("@motionpicture/gmo-service");
|
|
8
5
|
const http_status_1 = require("http-status");
|
|
9
6
|
const factory_1 = require("../../../../factory");
|
|
10
|
-
const debug = (0, debug_1.default)('chevre-domain:service:payment');
|
|
11
7
|
function handleAuthorizeError(error) {
|
|
12
|
-
debug('handling creditCard authorizeError:', error);
|
|
13
8
|
let handledError = error;
|
|
14
|
-
if (error
|
|
9
|
+
if (error instanceof gmo_service_1.GMO.error.badRequest.GMOBadRequestError) {
|
|
15
10
|
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
16
11
|
const gmoErrors = error.errors;
|
|
17
12
|
// 流量制限オーバーエラーの場合
|
|
@@ -8,34 +8,4 @@ declare enum GMOErrorInfo {
|
|
|
8
8
|
*/
|
|
9
9
|
JobCodeNotAcceptable = "E01050004"
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* エラー番号
|
|
14
|
-
*/
|
|
15
|
-
errorNumber: string;
|
|
16
|
-
/**
|
|
17
|
-
* コード
|
|
18
|
-
*/
|
|
19
|
-
code: string;
|
|
20
|
-
/**
|
|
21
|
-
* 詳細コード
|
|
22
|
-
*/
|
|
23
|
-
info: GMOErrorInfo | string;
|
|
24
|
-
/**
|
|
25
|
-
* 状態
|
|
26
|
-
*/
|
|
27
|
-
state: string;
|
|
28
|
-
/**
|
|
29
|
-
* 課金対象
|
|
30
|
-
*/
|
|
31
|
-
billing: string;
|
|
32
|
-
/**
|
|
33
|
-
* エラー内容と加盟店側の対処の方法
|
|
34
|
-
*/
|
|
35
|
-
content: string;
|
|
36
|
-
/**
|
|
37
|
-
* ユーザへ表示するメッセージ例
|
|
38
|
-
*/
|
|
39
|
-
userMessage: string;
|
|
40
|
-
}
|
|
41
|
-
export { GMOErrorInfo, IGMOError };
|
|
11
|
+
export { GMOErrorInfo };
|
|
@@ -133,7 +133,7 @@ function processAlterTran(params) {
|
|
|
133
133
|
let throwsError = true;
|
|
134
134
|
if (purpose.typeOf === factory_1.factory.transactionType.PlaceOrder) {
|
|
135
135
|
// handle notFoundError as searchTradeResult(2025-02-20~)
|
|
136
|
-
if (error
|
|
136
|
+
if (error instanceof gmo_service_1.GMO.error.badRequest.GMOBadRequestError) {
|
|
137
137
|
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
138
138
|
const gmoErrors = error.errors;
|
|
139
139
|
// 指定されたIDとパスワードの取引が存在しません。
|
|
@@ -201,7 +201,7 @@ function processAlterTran(params) {
|
|
|
201
201
|
catch (error) {
|
|
202
202
|
let throwsError = true;
|
|
203
203
|
// 未決済(3D 登録済)->取消をトライするとE01050004エラーとなるが、この場合何もする必要はない(2024-01-09~)
|
|
204
|
-
if (error
|
|
204
|
+
if (error instanceof gmo_service_1.GMO.error.badRequest.GMOBadRequestError) {
|
|
205
205
|
if (Array.isArray(error.errors) && error.errors.length === 1
|
|
206
206
|
&& error.errors[0].info === gmoError_1.GMOErrorInfo.JobCodeNotAcceptable) {
|
|
207
207
|
if (status === gmo_service_1.GMO.factory.util.Status.Authenticated
|
|
@@ -26,7 +26,7 @@ async function searchGMOTrade(params, settings) {
|
|
|
26
26
|
catch (error) {
|
|
27
27
|
// searchTradeでのエラーをハンドリング(2024-04-08~)
|
|
28
28
|
let throwsError = true;
|
|
29
|
-
if (error
|
|
29
|
+
if (error instanceof gmo_service_1.GMO.error.badRequest.GMOBadRequestError) {
|
|
30
30
|
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
31
31
|
const gmoErrors = error.errors;
|
|
32
32
|
// 指定されたIDとパスワードの取引が存在しません。
|
|
@@ -73,7 +73,7 @@ function voidTransaction(params) {
|
|
|
73
73
|
catch (error) {
|
|
74
74
|
// searchTradeでのエラーをハンドリング(2024-01-27~)
|
|
75
75
|
let throwsError = true;
|
|
76
|
-
if (error
|
|
76
|
+
if (error instanceof gmo_service_1.GMO.error.badRequest.GMOBadRequestError) {
|
|
77
77
|
if (Array.isArray(error.errors) && error.errors.length > 0) {
|
|
78
78
|
const gmoErrors = error.errors;
|
|
79
79
|
// 指定されたIDとパスワードの取引が存在しません。
|
|
@@ -6,7 +6,6 @@ import type { MemberRepo } from '../../../repo/member';
|
|
|
6
6
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
7
7
|
import type { MovieTheaterRepo } from '../../../repo/place/movieTheater';
|
|
8
8
|
import type { ScreeningRoomRepo } from '../../../repo/place/screeningRoom';
|
|
9
|
-
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
10
9
|
export declare function deleteResourcesBySeller(params: {
|
|
11
10
|
project: {
|
|
12
11
|
id: string;
|
|
@@ -21,5 +20,4 @@ export declare function deleteResourcesBySeller(params: {
|
|
|
21
20
|
movieTheater: MovieTheaterRepo;
|
|
22
21
|
screeningRoom: ScreeningRoomRepo;
|
|
23
22
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
24
|
-
productOffer: ProductOfferRepo;
|
|
25
23
|
}) => Promise<void>;
|
|
@@ -57,15 +57,9 @@ function deleteResourcesBySeller(params) {
|
|
|
57
57
|
project: { id: params.project.id },
|
|
58
58
|
parentOrganization: { id: sellerId }
|
|
59
59
|
});
|
|
60
|
-
// プロダクトオファー削除(2025-10-02~)
|
|
61
|
-
const deleteProductOfferResult = await repos.productOffer.deleteProductOffersBySeller({
|
|
62
|
-
project: { id: params.project.id },
|
|
63
|
-
offeredBy: { id: sellerId }
|
|
64
|
-
});
|
|
65
60
|
deleteResult = {
|
|
66
61
|
deleteMemberResult, deletePaymentServiceProviderResult,
|
|
67
62
|
deleteEventOfferResult,
|
|
68
|
-
deleteProductOfferResult,
|
|
69
63
|
deleteEventResult, deleteEventSeriesResult, deleteScreeningRoomResult, deleteMovieTheaterResult
|
|
70
64
|
};
|
|
71
65
|
}
|
|
@@ -18,7 +18,6 @@ const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
|
18
18
|
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
19
19
|
const product_1 = require("../../repo/product");
|
|
20
20
|
const productModel_1 = require("../../repo/productModel");
|
|
21
|
-
const productOffer_1 = require("../../repo/productOffer");
|
|
22
21
|
const setting_1 = require("../../repo/setting");
|
|
23
22
|
const task_1 = require("../../repo/task");
|
|
24
23
|
const deleteResourcesByAggregateOffer_1 = require("./onResourceDeleted/deleteResourcesByAggregateOffer");
|
|
@@ -53,7 +52,6 @@ function call(params) {
|
|
|
53
52
|
screeningRoom: new screeningRoom_1.ScreeningRoomRepo(connection),
|
|
54
53
|
product: new product_1.ProductRepo(connection),
|
|
55
54
|
productModel: new productModel_1.ProductModelRepo(connection),
|
|
56
|
-
productOffer: new productOffer_1.ProductOfferRepo(connection),
|
|
57
55
|
setting: new setting_1.SettingRepo(connection),
|
|
58
56
|
task: new task_1.TaskRepo(connection)
|
|
59
57
|
});
|
|
@@ -21,7 +21,6 @@ const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
|
21
21
|
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
22
22
|
const product_1 = require("../../repo/product");
|
|
23
23
|
const productModel_1 = require("../../repo/productModel");
|
|
24
|
-
const productOffer_1 = require("../../repo/productOffer");
|
|
25
24
|
const setting_1 = require("../../repo/setting");
|
|
26
25
|
const task_1 = require("../../repo/task");
|
|
27
26
|
const onAggregateOfferUpdated_1 = require("./onResourceUpdated/onAggregateOfferUpdated");
|
|
@@ -53,7 +52,6 @@ function call(data) {
|
|
|
53
52
|
screeningRoom: new screeningRoom_1.ScreeningRoomRepo(connection),
|
|
54
53
|
product: new product_1.ProductRepo(connection),
|
|
55
54
|
productModel: new productModel_1.ProductModelRepo(connection),
|
|
56
|
-
productOffer: new productOffer_1.ProductOfferRepo(connection),
|
|
57
55
|
setting: new setting_1.SettingRepo(connection),
|
|
58
56
|
task: new task_1.TaskRepo(connection)
|
|
59
57
|
});
|
package/package.json
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "8.0.0-alpha.
|
|
14
|
+
"@chevre/factory": "8.0.0-alpha.4",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
|
-
"@motionpicture/gmo-service": "6.0.0",
|
|
16
|
+
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
18
18
|
"@surfrock/sdk": "2.0.0",
|
|
19
19
|
"debug": "4.4.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "24.0.0-alpha.
|
|
94
|
+
"version": "24.0.0-alpha.82"
|
|
95
95
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
-
import { factory } from '../../../factory';
|
|
3
|
-
import { IVirtuals } from '../virtuals';
|
|
4
|
-
type IDocType = Omit<factory.productOffer.IProductOffer, 'acceptedPaymentMethod' | 'validForMemberTier'> & {
|
|
5
|
-
acceptedPaymentMethod?: factory.productOffer.IAcceptedPaymentMethod;
|
|
6
|
-
validForMemberTier?: factory.productOffer.IValidForMemberTier;
|
|
7
|
-
};
|
|
8
|
-
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
9
|
-
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
10
|
-
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|
|
11
|
-
declare const modelName = "ProductOffer";
|
|
12
|
-
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
13
|
-
declare function createSchema(): ISchema;
|
|
14
|
-
export { createSchema, IDocType, IModel, indexes, modelName };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.modelName = exports.indexes = void 0;
|
|
4
|
-
exports.createSchema = createSchema;
|
|
5
|
-
const mongoose_1 = require("mongoose");
|
|
6
|
-
const settings_1 = require("../../../settings");
|
|
7
|
-
const writeConcern_1 = require("../writeConcern");
|
|
8
|
-
const modelName = 'ProductOffer';
|
|
9
|
-
exports.modelName = modelName;
|
|
10
|
-
const schemaDefinition = {
|
|
11
|
-
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
12
|
-
typeOf: { type: String, required: true },
|
|
13
|
-
identifier: { type: String, required: true },
|
|
14
|
-
itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
15
|
-
offeredBy: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
16
|
-
availability: { type: String, required: true },
|
|
17
|
-
validFrom: { type: Date, required: true },
|
|
18
|
-
validThrough: { type: Date, required: true },
|
|
19
|
-
// availableAtOrFrom: { type: SchemaTypes.Mixed, required: false },
|
|
20
|
-
validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false },
|
|
21
|
-
acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: false }
|
|
22
|
-
};
|
|
23
|
-
const schemaOptions = {
|
|
24
|
-
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
25
|
-
autoCreate: false,
|
|
26
|
-
collection: 'productOffers',
|
|
27
|
-
id: true,
|
|
28
|
-
read: settings_1.MONGO_READ_PREFERENCE,
|
|
29
|
-
writeConcern: writeConcern_1.writeConcern,
|
|
30
|
-
strict: true,
|
|
31
|
-
strictQuery: false,
|
|
32
|
-
timestamps: false,
|
|
33
|
-
versionKey: false,
|
|
34
|
-
toJSON: {
|
|
35
|
-
getters: false,
|
|
36
|
-
virtuals: false,
|
|
37
|
-
minimize: false,
|
|
38
|
-
versionKey: false
|
|
39
|
-
},
|
|
40
|
-
toObject: {
|
|
41
|
-
getters: false,
|
|
42
|
-
virtuals: true,
|
|
43
|
-
minimize: false,
|
|
44
|
-
versionKey: false
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const indexes = [
|
|
48
|
-
[
|
|
49
|
-
{ validFrom: 1 },
|
|
50
|
-
{ name: 'validFrom' }
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
{
|
|
54
|
-
'project.id': 1,
|
|
55
|
-
'itemOffered.identifier': 1,
|
|
56
|
-
identifier: 1
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'uniqueByItemOfferedAndIdentifier',
|
|
60
|
-
unique: true
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
{ 'project.id': 1, validFrom: 1 },
|
|
65
|
-
{ name: 'projectId' }
|
|
66
|
-
],
|
|
67
|
-
[
|
|
68
|
-
{ identifier: 1, validFrom: 1 },
|
|
69
|
-
{ name: 'identifier' }
|
|
70
|
-
],
|
|
71
|
-
[
|
|
72
|
-
{ 'itemOffered.identifier': 1, validFrom: 1 },
|
|
73
|
-
{ name: 'itemOfferedIdentifier' }
|
|
74
|
-
],
|
|
75
|
-
[
|
|
76
|
-
{ 'offeredBy.id': 1, validFrom: 1 },
|
|
77
|
-
{ name: 'offeredById' }
|
|
78
|
-
],
|
|
79
|
-
[
|
|
80
|
-
{ validThrough: 1, validFrom: 1 },
|
|
81
|
-
{ name: 'validThrough' }
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
{ 'validForMemberTier.identifier': 1, validFrom: 1 },
|
|
85
|
-
{
|
|
86
|
-
name: 'validForMemberTierIdentifier',
|
|
87
|
-
partialFilterExpression: {
|
|
88
|
-
'validForMemberTier.identifier': { $exists: true }
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
];
|
|
93
|
-
exports.indexes = indexes;
|
|
94
|
-
/**
|
|
95
|
-
* プロダクトオファー(汎用的なオファー設定)スキーマ
|
|
96
|
-
*/
|
|
97
|
-
let schema;
|
|
98
|
-
function createSchema() {
|
|
99
|
-
if (schema === undefined) {
|
|
100
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
101
|
-
if (settings_1.MONGO_AUTO_INDEX) {
|
|
102
|
-
indexes.forEach((indexParams) => {
|
|
103
|
-
schema?.index(...indexParams);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return schema;
|
|
108
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { BulkWriteResult, DeleteResult } from 'mongodb';
|
|
2
|
-
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
-
import { factory } from '../factory';
|
|
4
|
-
import { IDocType } from './mongoose/schemas/productOffer';
|
|
5
|
-
type IUnset = {
|
|
6
|
-
[key in keyof IDocType]?: 1;
|
|
7
|
-
};
|
|
8
|
-
type IDocWithId = factory.productOffer.IProductOffer & {
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
type IKeyOfProjection = keyof IDocType;
|
|
12
|
-
/**
|
|
13
|
-
* プロダクトオファーリポジトリ
|
|
14
|
-
*/
|
|
15
|
-
export declare class ProductOfferRepo {
|
|
16
|
-
private readonly productOfferModel;
|
|
17
|
-
constructor(connection: Connection);
|
|
18
|
-
static CREATE_MONGO_CONDITIONS(params: factory.productOffer.ISearchConditions): FilterQuery<IDocType>[];
|
|
19
|
-
findProductOffers(params: factory.productOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
20
|
-
/**
|
|
21
|
-
* オファーコードとオファーコレクションコードをキーにして冪等置換
|
|
22
|
-
*/
|
|
23
|
-
upsertOffersByIdentifier(params: {
|
|
24
|
-
$set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'offeredBy' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
25
|
-
id?: never;
|
|
26
|
-
};
|
|
27
|
-
$unset: IUnset;
|
|
28
|
-
}[], options: {
|
|
29
|
-
/**
|
|
30
|
-
* falseの場合setOnInsertのみ
|
|
31
|
-
* trueの場合setのみ
|
|
32
|
-
*/
|
|
33
|
-
update: boolean;
|
|
34
|
-
}): Promise<{
|
|
35
|
-
bulkWriteResult?: BulkWriteResult;
|
|
36
|
-
modifiedProductOffers?: {
|
|
37
|
-
id: string;
|
|
38
|
-
}[];
|
|
39
|
-
}>;
|
|
40
|
-
/**
|
|
41
|
-
* 販売者の提供するプロダクトオファーを削除する
|
|
42
|
-
*/
|
|
43
|
-
deleteProductOffersBySeller(params: {
|
|
44
|
-
project: {
|
|
45
|
-
id: string;
|
|
46
|
-
};
|
|
47
|
-
offeredBy: {
|
|
48
|
-
id: string;
|
|
49
|
-
};
|
|
50
|
-
}): Promise<DeleteResult>;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductOfferRepo = void 0;
|
|
4
|
-
const factory_1 = require("../factory");
|
|
5
|
-
const settings_1 = require("../settings");
|
|
6
|
-
const productOffer_1 = require("./mongoose/schemas/productOffer");
|
|
7
|
-
const AVAILABLE_PROJECT_FIELDS = [
|
|
8
|
-
'identifier',
|
|
9
|
-
'project',
|
|
10
|
-
'itemOffered',
|
|
11
|
-
'offeredBy',
|
|
12
|
-
'typeOf',
|
|
13
|
-
'validFrom',
|
|
14
|
-
'validThrough',
|
|
15
|
-
'availability',
|
|
16
|
-
'acceptedPaymentMethod',
|
|
17
|
-
'validForMemberTier'
|
|
18
|
-
];
|
|
19
|
-
/**
|
|
20
|
-
* プロダクトオファーリポジトリ
|
|
21
|
-
*/
|
|
22
|
-
class ProductOfferRepo {
|
|
23
|
-
productOfferModel;
|
|
24
|
-
constructor(connection) {
|
|
25
|
-
this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
|
|
26
|
-
}
|
|
27
|
-
static CREATE_MONGO_CONDITIONS(params) {
|
|
28
|
-
const andConditions = [];
|
|
29
|
-
const idEq = params.id?.$eq;
|
|
30
|
-
if (typeof idEq === 'string') {
|
|
31
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
32
|
-
}
|
|
33
|
-
const projectIdEq = params.project?.id?.$eq;
|
|
34
|
-
if (typeof projectIdEq === 'string') {
|
|
35
|
-
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
36
|
-
}
|
|
37
|
-
const identifierEq = params.identifier?.$eq;
|
|
38
|
-
if (typeof identifierEq === 'string') {
|
|
39
|
-
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
40
|
-
}
|
|
41
|
-
const identifierIn = params.identifier?.$in;
|
|
42
|
-
if (Array.isArray(identifierIn)) {
|
|
43
|
-
andConditions.push({ identifier: { $in: identifierIn } });
|
|
44
|
-
}
|
|
45
|
-
const itemOfferedIdentifierEq = params.itemOffered?.identifier?.$eq;
|
|
46
|
-
if (typeof itemOfferedIdentifierEq === 'string') {
|
|
47
|
-
andConditions.push({ 'itemOffered.identifier': { $eq: itemOfferedIdentifierEq } });
|
|
48
|
-
}
|
|
49
|
-
const itemOfferedIdentifierIn = params.itemOffered?.identifier?.$in;
|
|
50
|
-
if (Array.isArray(itemOfferedIdentifierIn)) {
|
|
51
|
-
andConditions.push({ 'itemOffered.identifier': { $in: itemOfferedIdentifierIn } });
|
|
52
|
-
}
|
|
53
|
-
const offeredByIdEq = params.offeredBy?.id?.$eq;
|
|
54
|
-
if (typeof offeredByIdEq === 'string') {
|
|
55
|
-
andConditions.push({ 'offeredBy.id': { $eq: offeredByIdEq } });
|
|
56
|
-
}
|
|
57
|
-
const sellerByIdEq = params.seller?.id?.$eq;
|
|
58
|
-
if (typeof sellerByIdEq === 'string') {
|
|
59
|
-
andConditions.push({ 'offeredBy.id': { $eq: sellerByIdEq } });
|
|
60
|
-
}
|
|
61
|
-
const validForMemberTierIdentifierEq = params.validForMemberTier?.identifier?.$eq;
|
|
62
|
-
if (typeof validForMemberTierIdentifierEq === 'string') {
|
|
63
|
-
andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
|
|
64
|
-
}
|
|
65
|
-
const validFromLte = params.validFrom?.$lte;
|
|
66
|
-
if (validFromLte instanceof Date) {
|
|
67
|
-
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
68
|
-
}
|
|
69
|
-
const validThroughGte = params.validThrough?.$gte;
|
|
70
|
-
if (validThroughGte instanceof Date) {
|
|
71
|
-
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
72
|
-
}
|
|
73
|
-
return andConditions;
|
|
74
|
-
}
|
|
75
|
-
async findProductOffers(params, inclusion) {
|
|
76
|
-
const conditions = ProductOfferRepo.CREATE_MONGO_CONDITIONS(params);
|
|
77
|
-
let positiveProjectionFields;
|
|
78
|
-
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
79
|
-
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw new factory_1.factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
83
|
-
}
|
|
84
|
-
const projection = {
|
|
85
|
-
_id: 0,
|
|
86
|
-
id: { $toString: '$_id' },
|
|
87
|
-
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
88
|
-
};
|
|
89
|
-
const query = this.productOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
90
|
-
if (typeof params.sort?.validFrom === 'number') {
|
|
91
|
-
query.sort({ validFrom: params.sort.validFrom });
|
|
92
|
-
}
|
|
93
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
94
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
95
|
-
query.limit(params.limit)
|
|
96
|
-
.skip(params.limit * (page - 1));
|
|
97
|
-
}
|
|
98
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
99
|
-
.lean()
|
|
100
|
-
.exec();
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* オファーコードとオファーコレクションコードをキーにして冪等置換
|
|
104
|
-
*/
|
|
105
|
-
async upsertOffersByIdentifier(params, options) {
|
|
106
|
-
const { update } = options;
|
|
107
|
-
const bulkWriteOps = [];
|
|
108
|
-
const queryFilters = [];
|
|
109
|
-
if (Array.isArray(params)) {
|
|
110
|
-
params.forEach(({ $set, $unset }) => {
|
|
111
|
-
const { availability, identifier, itemOffered, offeredBy, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
|
|
112
|
-
if (typeof identifier !== 'string' || identifier === '') {
|
|
113
|
-
throw new factory_1.factory.errors.ArgumentNull('identifier');
|
|
114
|
-
}
|
|
115
|
-
if (typeof itemOffered.identifier !== 'string' || itemOffered.identifier === '') {
|
|
116
|
-
throw new factory_1.factory.errors.ArgumentNull('itemOffered.identifier');
|
|
117
|
-
}
|
|
118
|
-
// リソースのユニークネスを保証するfilter
|
|
119
|
-
const filter = {
|
|
120
|
-
'project.id': { $eq: project.id },
|
|
121
|
-
'itemOffered.identifier': { $eq: itemOffered.identifier },
|
|
122
|
-
identifier: { $eq: identifier }
|
|
123
|
-
};
|
|
124
|
-
queryFilters.push({
|
|
125
|
-
'project.id': { $eq: project.id },
|
|
126
|
-
'itemOffered.identifier': { $eq: itemOffered.identifier },
|
|
127
|
-
identifier: { $eq: identifier }
|
|
128
|
-
});
|
|
129
|
-
if (update === true) {
|
|
130
|
-
const setFields = {
|
|
131
|
-
availability,
|
|
132
|
-
validFrom,
|
|
133
|
-
validThrough,
|
|
134
|
-
...(typeof acceptedPaymentMethod?.typeOf === 'string') ? { acceptedPaymentMethod } : undefined,
|
|
135
|
-
...(typeof validForMemberTier?.typeOf === 'string') ? { validForMemberTier } : undefined
|
|
136
|
-
};
|
|
137
|
-
const updateFilter = {
|
|
138
|
-
$set: setFields,
|
|
139
|
-
...($unset !== undefined) ? { $unset } : undefined
|
|
140
|
-
};
|
|
141
|
-
const updateOne = {
|
|
142
|
-
filter,
|
|
143
|
-
update: updateFilter,
|
|
144
|
-
upsert: false
|
|
145
|
-
};
|
|
146
|
-
bulkWriteOps.push({ updateOne });
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const setOnInsert = {
|
|
150
|
-
itemOffered, offeredBy, identifier, project,
|
|
151
|
-
typeOf: factory_1.factory.offerType.Offer,
|
|
152
|
-
availability,
|
|
153
|
-
validFrom,
|
|
154
|
-
validThrough,
|
|
155
|
-
...(typeof acceptedPaymentMethod?.typeOf === 'string') ? { acceptedPaymentMethod } : undefined,
|
|
156
|
-
...(typeof validForMemberTier?.typeOf === 'string') ? { validForMemberTier } : undefined
|
|
157
|
-
};
|
|
158
|
-
const updateFilter = {
|
|
159
|
-
$setOnInsert: setOnInsert
|
|
160
|
-
};
|
|
161
|
-
const updateOne = {
|
|
162
|
-
filter,
|
|
163
|
-
update: updateFilter,
|
|
164
|
-
upsert: true
|
|
165
|
-
};
|
|
166
|
-
bulkWriteOps.push({ updateOne });
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (bulkWriteOps.length > 0) {
|
|
171
|
-
const bulkWriteResult = await this.productOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
172
|
-
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
173
|
-
const modifiedProductOffers = await this.productOfferModel.find({ $or: queryFilters }, {
|
|
174
|
-
_id: 0,
|
|
175
|
-
id: { $toString: '$_id' }
|
|
176
|
-
})
|
|
177
|
-
.lean()
|
|
178
|
-
.exec();
|
|
179
|
-
return { bulkWriteResult, modifiedProductOffers };
|
|
180
|
-
}
|
|
181
|
-
return {};
|
|
182
|
-
}
|
|
183
|
-
// public async deleteProductOffersByIds(params: {
|
|
184
|
-
// project: { id: string };
|
|
185
|
-
// ids: string[];
|
|
186
|
-
// }): Promise<DeleteResult | void> {
|
|
187
|
-
// const { project, ids } = params;
|
|
188
|
-
// if (Array.isArray(ids) && ids.length > 0) {
|
|
189
|
-
// return this.productOfferModel.deleteMany(
|
|
190
|
-
// {
|
|
191
|
-
// 'project.id': { $eq: project.id },
|
|
192
|
-
// _id: { $in: ids }
|
|
193
|
-
// }
|
|
194
|
-
// )
|
|
195
|
-
// .exec();
|
|
196
|
-
// }
|
|
197
|
-
// }
|
|
198
|
-
/**
|
|
199
|
-
* 販売者の提供するプロダクトオファーを削除する
|
|
200
|
-
*/
|
|
201
|
-
async deleteProductOffersBySeller(params) {
|
|
202
|
-
return this.productOfferModel.deleteMany({
|
|
203
|
-
'project.id': { $eq: params.project.id },
|
|
204
|
-
'offeredBy.id': { $eq: params.offeredBy.id }
|
|
205
|
-
})
|
|
206
|
-
.exec();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.ProductOfferRepo = ProductOfferRepo;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../../../factory';
|
|
2
|
-
import { IMinimizedIndividualEvent } from '../../../../factory/event';
|
|
3
|
-
import type { IssuerRepo } from '../../../../repo/issuer';
|
|
4
|
-
import type { MemberProgramRepo } from '../../../../repo/memberProgram';
|
|
5
|
-
import type { ProductOfferRepo } from '../../../../repo/productOffer';
|
|
6
|
-
declare function validateMemberTierIfExists(params: {
|
|
7
|
-
event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project'>;
|
|
8
|
-
now: Date;
|
|
9
|
-
makesOfferOnApplication: factory.event.screeningEvent.ISellerMakesOffer;
|
|
10
|
-
acceptedEventOffer?: factory.authorization.IOfferAsObject;
|
|
11
|
-
}): (repos: {
|
|
12
|
-
issuer: IssuerRepo;
|
|
13
|
-
memberProgram: MemberProgramRepo;
|
|
14
|
-
productOffer: ProductOfferRepo;
|
|
15
|
-
}) => Promise<void>;
|
|
16
|
-
export { validateMemberTierIfExists };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateMemberTierIfExists = validateMemberTierIfExists;
|
|
7
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
8
|
-
const moment_1 = __importDefault(require("moment"));
|
|
9
|
-
const factory_1 = require("../../../../factory");
|
|
10
|
-
function validateMemberTier(params) {
|
|
11
|
-
return async (repos) => {
|
|
12
|
-
const { acceptedDate, event, verifiedValidForMemberTier, memberProgramIdentifierMustBe, aggregateOfferIdentifier } = params;
|
|
13
|
-
const tierIdentifier = verifiedValidForMemberTier.member?.memberOf?.identifier;
|
|
14
|
-
const memberProgramIdentifier = verifiedValidForMemberTier.member?.memberOf?.isTierOf?.identifier;
|
|
15
|
-
if (typeof tierIdentifier !== 'string') {
|
|
16
|
-
throw new factory_1.factory.errors.Argument('ticketedOffer.validForMemberTier', 'tier identifier must be string');
|
|
17
|
-
}
|
|
18
|
-
if (typeof memberProgramIdentifier !== 'string') {
|
|
19
|
-
throw new factory_1.factory.errors.Argument('ticketedOffer.validForMemberTier', 'member program must be string');
|
|
20
|
-
}
|
|
21
|
-
if (memberProgramIdentifier !== memberProgramIdentifierMustBe) {
|
|
22
|
-
throw new factory_1.factory.errors.Argument('ticketedOffer.validForMemberTier', 'member program not matched');
|
|
23
|
-
}
|
|
24
|
-
const sellerId = event.offers.seller.id;
|
|
25
|
-
if (typeof sellerId !== 'string' || sellerId === '') {
|
|
26
|
-
throw new factory_1.factory.errors.NotFound('event.offers.seller.id');
|
|
27
|
-
}
|
|
28
|
-
// 有効なプロダクトオファーを検証
|
|
29
|
-
const productOfferForMemberTier = (await repos.productOffer.findProductOffers({
|
|
30
|
-
limit: 1,
|
|
31
|
-
page: 1,
|
|
32
|
-
project: { id: { $eq: event.project.id } },
|
|
33
|
-
// availableAtOrFrom: { id: { $eq: availableAt.id } },
|
|
34
|
-
itemOffered: { identifier: { $eq: aggregateOfferIdentifier } }, // オファーコレクションコード
|
|
35
|
-
validForMemberTier: { identifier: { $eq: tierIdentifier } },
|
|
36
|
-
validFrom: { $lte: acceptedDate.toDate() },
|
|
37
|
-
validThrough: { $gte: acceptedDate.toDate() },
|
|
38
|
-
offeredBy: { id: { $eq: sellerId } } // オファー提供者も検証する
|
|
39
|
-
}, ['identifier'])).shift();
|
|
40
|
-
if (productOfferForMemberTier === undefined) {
|
|
41
|
-
throw new factory_1.factory.errors.NotFound(factory_1.factory.offerType.Offer, 'valid product offers for member tier not found');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async function verifyMemberTierToken(params) {
|
|
46
|
-
let result;
|
|
47
|
-
const { issuer, secret, token } = params;
|
|
48
|
-
try {
|
|
49
|
-
result = await new Promise((resolve, reject) => {
|
|
50
|
-
(0, jsonwebtoken_1.verify)(token, secret, {
|
|
51
|
-
algorithms: ['HS256'],
|
|
52
|
-
issuer
|
|
53
|
-
// ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
|
|
54
|
-
}, (err, decoded) => {
|
|
55
|
-
if (err instanceof Error) {
|
|
56
|
-
reject(err);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
resolve(decoded);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
// JWTエラーをハンドリング
|
|
66
|
-
if (error instanceof jsonwebtoken_1.TokenExpiredError) {
|
|
67
|
-
throw new factory_1.factory.errors.Argument('ticketedOffer.validForMemberTier', `invalid token. [${error.message} expiredAt:${error.expiredAt}]`);
|
|
68
|
-
}
|
|
69
|
-
else if (error instanceof jsonwebtoken_1.JsonWebTokenError) {
|
|
70
|
-
throw new factory_1.factory.errors.Argument('ticketedOffer.validForMemberTier', `invalid token. [${error.message}]`);
|
|
71
|
-
}
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
function validateMemberTierIfExists(params) {
|
|
77
|
-
return async (repos) => {
|
|
78
|
-
const { event, makesOfferOnApplication } = params;
|
|
79
|
-
const acceptedDate = (0, moment_1.default)(params.now);
|
|
80
|
-
const eventOffers = event.offers;
|
|
81
|
-
// 有効メンバープログラムティアが存在する場合
|
|
82
|
-
// support validForMemberTier(2025-05-14~)
|
|
83
|
-
const validForMemberTierExists = makesOfferOnApplication.validForMemberTier?.typeOf === 'MemberProgramTier';
|
|
84
|
-
if (validForMemberTierExists) {
|
|
85
|
-
const tokenizedMemberProgramTier = params.acceptedEventOffer?.validForMemberTier;
|
|
86
|
-
const validForMemberTierToken = tokenizedMemberProgramTier?.token;
|
|
87
|
-
const memberProgramIdentifierMustBe = tokenizedMemberProgramTier?.isTierOf?.identifier;
|
|
88
|
-
// ティアトークンが必須
|
|
89
|
-
if (typeof validForMemberTierToken !== 'string' || validForMemberTierToken === '') {
|
|
90
|
-
throw new factory_1.factory.errors.ArgumentNull('ticketedOffer.validForMemberTier.token');
|
|
91
|
-
}
|
|
92
|
-
// メンバープログラムコード指定が必須
|
|
93
|
-
if (typeof memberProgramIdentifierMustBe !== 'string' || memberProgramIdentifierMustBe === '') {
|
|
94
|
-
throw new factory_1.factory.errors.ArgumentNull('ticketedOffer.validForMemberTier.isTierOf.identifier');
|
|
95
|
-
}
|
|
96
|
-
// 有効メンバープログラムティアが存在する場合、オファーコレクションコードが必須
|
|
97
|
-
const aggregateOfferIdentifier = eventOffers.identifier;
|
|
98
|
-
if (typeof aggregateOfferIdentifier !== 'string' || aggregateOfferIdentifier === '') {
|
|
99
|
-
throw new factory_1.factory.errors.NotFound('makesOfferOnApplication.identifier');
|
|
100
|
-
}
|
|
101
|
-
// トークン検証
|
|
102
|
-
const memberProgram = (await repos.memberProgram.projectMemberPrograms({
|
|
103
|
-
limit: 1,
|
|
104
|
-
page: 1,
|
|
105
|
-
project: { id: { $eq: params.event.project.id } },
|
|
106
|
-
identifier: { $eq: memberProgramIdentifierMustBe }
|
|
107
|
-
})).shift();
|
|
108
|
-
if (memberProgram === undefined) {
|
|
109
|
-
throw new factory_1.factory.errors.NotFound('MemberProgram', `MemberProgram '${memberProgramIdentifierMustBe}' not found`);
|
|
110
|
-
}
|
|
111
|
-
const issuer = await repos.issuer.findByIdentifier({
|
|
112
|
-
project: { id: params.event.project.id },
|
|
113
|
-
identifier: memberProgram.hostingOrganization.identifier
|
|
114
|
-
});
|
|
115
|
-
if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
|
|
116
|
-
throw new factory_1.factory.errors.NotFound('issuer.tokenSecret');
|
|
117
|
-
}
|
|
118
|
-
const verifiedValidForMemberTier = await verifyMemberTierToken({
|
|
119
|
-
secret: issuer.tokenSecret,
|
|
120
|
-
issuer: issuer.url,
|
|
121
|
-
token: validForMemberTierToken
|
|
122
|
-
});
|
|
123
|
-
await validateMemberTier({
|
|
124
|
-
event, acceptedDate, verifiedValidForMemberTier,
|
|
125
|
-
memberProgramIdentifierMustBe, aggregateOfferIdentifier
|
|
126
|
-
})(repos);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|