@chevre/domain 21.18.0-alpha.41 → 21.18.0-alpha.43

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.
@@ -0,0 +1,28 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
12
+ const products = await productRepo.searchProducts(
13
+ {
14
+ project: { id: { $eq: project.id } }
15
+ },
16
+ // ['_id', 'typeOf'],
17
+ [],
18
+ []
19
+ );
20
+ console.log('products:', products);
21
+ console.log(products.length, 'products found');
22
+ }
23
+
24
+ main()
25
+ .then(() => {
26
+ console.log('success!');
27
+ })
28
+ .catch(console.error);
@@ -15,7 +15,9 @@ export declare class MongoRepository {
15
15
  * idを指定すれば更新
16
16
  */
17
17
  id?: string;
18
- $set: factory.service.paymentService.IService;
18
+ $set: factory.service.paymentService.IService & {
19
+ provider?: never;
20
+ };
19
21
  $unset: {
20
22
  [key in IUnsetKey]?: 1;
21
23
  };
@@ -1,6 +1,20 @@
1
1
  import { Connection } from 'mongoose';
2
2
  import * as factory from '../factory';
3
- export type IAvailablePaymentServiceType = factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
3
+ type IAvailablePaymentServiceType = factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
4
+ /**
5
+ * 決済サービス検索条件
6
+ */
7
+ type ISearchConditions4paymentService = factory.product.ISearchConditions & {
8
+ typeOf?: {
9
+ $eq?: factory.service.paymentService.PaymentServiceType;
10
+ $in?: factory.service.paymentService.PaymentServiceType[];
11
+ };
12
+ };
13
+ export type IPublicPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'serviceOutput' | 'additionalProperty'> & {
14
+ provider?: {
15
+ credentials?: Pick<factory.service.paymentService.IProviderCredentials, 'shopId' | 'paymentUrl' | 'tokenizationCode'>;
16
+ };
17
+ };
4
18
  /**
5
19
  * 決済サービスプロバイダーリポジトリ
6
20
  */
@@ -29,6 +43,10 @@ export declare class MongoRepository {
29
43
  }): Promise<(Pick<factory.service.paymentService.IService, 'id' | 'name' | 'typeOf'> & {
30
44
  provider: Pick<factory.service.paymentService.IProvider, 'id' | 'name' | 'credentials'>;
31
45
  })[]>;
46
+ /**
47
+ * 販売者の提供決済サービス(公開情報のみ)検索
48
+ */
49
+ searchPublicPaymentServicesByProvider(params: Pick<ISearchConditions4paymentService, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPublicPaymentServiceByProvider[]>;
32
50
  create(params: factory.service.paymentService.IProvider & {
33
51
  project: {
34
52
  id: string;
@@ -68,3 +86,4 @@ export declare class MongoRepository {
68
86
  };
69
87
  }): Promise<import("mongodb").UpdateResult>;
70
88
  }
89
+ export {};
@@ -71,6 +71,70 @@ class MongoRepository {
71
71
  .exec();
72
72
  });
73
73
  }
74
+ /**
75
+ * 販売者の提供決済サービス(公開情報のみ)検索
76
+ */
77
+ searchPublicPaymentServicesByProvider(params) {
78
+ var _a, _b, _c, _d, _e, _f;
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const matchStages = [];
81
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
82
+ if (typeof projectIdEq === 'string') {
83
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
84
+ }
85
+ const typeOfEq = (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$eq;
86
+ if (typeof typeOfEq === 'string') {
87
+ matchStages.push({ $match: { typeOf: { $eq: typeOfEq } } });
88
+ }
89
+ const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
90
+ if (typeof providerIdEq === 'string') {
91
+ matchStages.push({ $match: { 'provider.id': { $exists: true, $eq: providerIdEq } } });
92
+ }
93
+ const aggregate = this.productModel.aggregate([
94
+ ...(typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.productID) === 'number')
95
+ ? [{ $sort: { productID: params.sort.productID } }]
96
+ : [],
97
+ {
98
+ $unwind: {
99
+ path: '$provider'
100
+ }
101
+ },
102
+ ...matchStages,
103
+ {
104
+ $project: {
105
+ _id: 0,
106
+ typeOf: '$typeOf',
107
+ productID: '$productID',
108
+ description: '$description',
109
+ name: '$name',
110
+ additionalProperty: '$additionalProperty',
111
+ serviceOutput: '$serviceOutput',
112
+ serviceType: '$serviceType',
113
+ id: { $toString: '$_id' },
114
+ // ↓セキュアな情報を隠蔽するように
115
+ provider: {
116
+ credentials: {
117
+ shopId: '$provider.credentials.shopId',
118
+ tokenizationCode: '$provider.credentials.tokenizationCode',
119
+ paymentUrl: {
120
+ expiresInSeconds: '$provider.credentials.paymentUrl.expiresInSeconds',
121
+ useCallback: '$provider.credentials.paymentUrl.useCallback',
122
+ useWebhook: '$provider.credentials.paymentUrl.useWebhook'
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ ]);
129
+ if (typeof params.limit === 'number' && params.limit > 0) {
130
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
131
+ aggregate.limit(params.limit * page)
132
+ .skip(params.limit * (page - 1));
133
+ }
134
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
135
+ .exec();
136
+ });
137
+ }
74
138
  create(params) {
75
139
  return __awaiter(this, void 0, void 0, function* () {
76
140
  // 決済サービス存在確認
@@ -25,6 +25,7 @@
25
25
  import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  type IKeyOfProjection4product = keyof factory.product.IProduct | '_id';
28
+ type IKeyOfProjection4paymentService = keyof factory.service.paymentService.IService | '_id';
28
29
  /**
29
30
  * プロダクト検索条件
30
31
  */
@@ -43,9 +44,6 @@ type ISearchConditions4paymentService = factory.product.ISearchConditions & {
43
44
  $in?: factory.service.paymentService.PaymentServiceType[];
44
45
  };
45
46
  };
46
- export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'serviceOutput' | 'additionalProperty'> & {
47
- provider?: Pick<factory.service.paymentService.IProvider, 'credentials'>;
48
- };
49
47
  type IUnsetKey = keyof Pick<factory.product.IProduct, 'additionalProperty' | 'availableChannel' | 'hasOfferCatalog' | 'serviceOutput' | 'serviceType'>;
50
48
  /**
51
49
  * プロダクトリポジトリ
@@ -54,9 +52,6 @@ export declare class MongoRepository {
54
52
  private readonly productModel;
55
53
  constructor(connection: Connection);
56
54
  static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): FilterQuery<factory.product.IProduct>[];
57
- findById(conditions: {
58
- id: string;
59
- }, inclusion: string[], exclusion: string[]): Promise<factory.product.IProduct | factory.service.paymentService.IService>;
60
55
  /**
61
56
  * プロダクトを検索する
62
57
  */
@@ -64,7 +59,7 @@ export declare class MongoRepository {
64
59
  /**
65
60
  * 決済サービスを検索する
66
61
  */
67
- searchPaymentServices(conditions: ISearchConditions4paymentService, inclusion: string[], exclusion: string[]): Promise<factory.service.paymentService.IService[]>;
62
+ searchPaymentServices(conditions: ISearchConditions4paymentService, inclusion: IKeyOfProjection4paymentService[], exclusion: IKeyOfProjection4paymentService[]): Promise<factory.service.paymentService.IService[]>;
68
63
  deleteById(params: {
69
64
  id: string;
70
65
  }): Promise<void>;
@@ -78,7 +73,6 @@ export declare class MongoRepository {
78
73
  typeOf: factory.service.paymentService.PaymentServiceType;
79
74
  id: string;
80
75
  }): Promise<factory.product.IAvailableChannel>;
81
- searchPaymentServicesByProvider(params: Pick<ISearchConditions4paymentService, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
82
76
  /**
83
77
  * プロダクトを保管する
84
78
  */
@@ -87,7 +81,9 @@ export declare class MongoRepository {
87
81
  * idを指定すれば更新
88
82
  */
89
83
  id?: string;
90
- $set: factory.product.IProduct;
84
+ $set: factory.product.IProduct & {
85
+ offers?: never;
86
+ };
91
87
  $unset: {
92
88
  [key in IUnsetKey]?: 1;
93
89
  };
@@ -151,34 +151,35 @@ class MongoRepository {
151
151
  }
152
152
  return andConditions;
153
153
  }
154
- findById(conditions, inclusion, exclusion) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- let projection = {};
157
- if (Array.isArray(inclusion) && inclusion.length > 0) {
158
- inclusion.forEach((field) => {
159
- projection[field] = 1;
160
- });
161
- }
162
- else {
163
- projection = {
164
- __v: 0,
165
- createdAt: 0,
166
- updatedAt: 0
167
- };
168
- if (Array.isArray(exclusion) && exclusion.length > 0) {
169
- exclusion.forEach((field) => {
170
- projection[field] = 0;
171
- });
172
- }
173
- }
174
- const doc = yield this.productModel.findOne({ _id: conditions.id }, projection)
175
- .exec();
176
- if (doc === null) {
177
- throw new factory.errors.NotFound(this.productModel.modelName);
178
- }
179
- return doc.toObject();
180
- });
181
- }
154
+ // public async findById(
155
+ // conditions: { id: string },
156
+ // inclusion: string[],
157
+ // exclusion: string[]
158
+ // ): Promise<factory.product.IProduct | factory.service.paymentService.IService> {
159
+ // let projection: { [key: string]: number } = {};
160
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
161
+ // inclusion.forEach((field) => {
162
+ // projection[field] = 1;
163
+ // });
164
+ // } else {
165
+ // projection = {
166
+ // __v: 0,
167
+ // createdAt: 0,
168
+ // updatedAt: 0
169
+ // };
170
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
171
+ // exclusion.forEach((field) => {
172
+ // projection[field] = 0;
173
+ // });
174
+ // }
175
+ // }
176
+ // const doc = await this.productModel.findOne({ _id: conditions.id }, projection)
177
+ // .exec();
178
+ // if (doc === null) {
179
+ // throw new factory.errors.NotFound(this.productModel.modelName);
180
+ // }
181
+ // return doc.toObject();
182
+ // }
182
183
  /**
183
184
  * プロダクトを検索する
184
185
  */
@@ -186,6 +187,20 @@ class MongoRepository {
186
187
  var _a;
187
188
  return __awaiter(this, void 0, void 0, function* () {
188
189
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
190
+ // 強制的にtypeOfを絞る(2023-12-19~)
191
+ if (settings_1.USE_SEARCH_ONLY_PRODUCTS_FORCIBLY) {
192
+ andConditions.push({
193
+ typeOf: {
194
+ $in: [
195
+ factory.product.ProductType.EventService,
196
+ factory.product.ProductType.MembershipService,
197
+ factory.product.ProductType.PaymentCard,
198
+ factory.product.ProductType.Product,
199
+ factory.product.ProductType.Transportation
200
+ ]
201
+ }
202
+ });
203
+ }
189
204
  let projection = {};
190
205
  if (Array.isArray(inclusion) && inclusion.length > 0) {
191
206
  inclusion.forEach((field) => {
@@ -246,7 +261,8 @@ class MongoRepository {
246
261
  projection = {
247
262
  __v: 0,
248
263
  createdAt: 0,
249
- updatedAt: 0
264
+ updatedAt: 0,
265
+ provider: 0 // paymentServiceProviderRepoへの完全移行につき除外(2023-12-20~)
250
266
  };
251
267
  if (Array.isArray(exclusion) && exclusion.length > 0) {
252
268
  exclusion.forEach((field) => {
@@ -310,68 +326,6 @@ class MongoRepository {
310
326
  return availableChannel;
311
327
  });
312
328
  }
313
- searchPaymentServicesByProvider(params) {
314
- var _a, _b, _c, _d, _e, _f;
315
- return __awaiter(this, void 0, void 0, function* () {
316
- const matchStages = [];
317
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
318
- if (typeof projectIdEq === 'string') {
319
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
320
- }
321
- const typeOfEq = (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$eq;
322
- if (typeof typeOfEq === 'string') {
323
- matchStages.push({ $match: { typeOf: { $eq: typeOfEq } } });
324
- }
325
- const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
326
- if (typeof providerIdEq === 'string') {
327
- matchStages.push({ $match: { 'provider.id': { $exists: true, $eq: providerIdEq } } });
328
- }
329
- const aggregate = this.productModel.aggregate([
330
- ...(typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.productID) === 'number')
331
- ? [{ $sort: { productID: params.sort.productID } }]
332
- : [],
333
- {
334
- $unwind: {
335
- path: '$provider'
336
- }
337
- },
338
- ...matchStages,
339
- {
340
- $project: {
341
- _id: 0,
342
- typeOf: '$typeOf',
343
- productID: '$productID',
344
- description: '$description',
345
- name: '$name',
346
- // provider: [ [Object] ],
347
- additionalProperty: '$additionalProperty',
348
- serviceOutput: '$serviceOutput',
349
- serviceType: '$serviceType',
350
- id: { $toString: '$_id' },
351
- // ↓セキュアな情報を隠蔽するように
352
- provider: {
353
- credentials: {
354
- shopId: '$provider.credentials.shopId',
355
- tokenizationCode: '$provider.credentials.tokenizationCode',
356
- paymentUrl: {
357
- expiresInSeconds: '$provider.credentials.paymentUrl.expiresInSeconds',
358
- useCallback: '$provider.credentials.paymentUrl.useCallback',
359
- useWebhook: '$provider.credentials.paymentUrl.useWebhook'
360
- }
361
- }
362
- }
363
- }
364
- }
365
- ]);
366
- if (typeof params.limit === 'number' && params.limit > 0) {
367
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
368
- aggregate.limit(params.limit * page)
369
- .skip(params.limit * (page - 1));
370
- }
371
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
372
- .exec();
373
- });
374
- }
375
329
  /**
376
330
  * プロダクトを保管する
377
331
  */
@@ -58,6 +58,7 @@ export type ICheckOperation<T> = (repos: {
58
58
  action: ActionRepo;
59
59
  event: EventRepo;
60
60
  paymentAccepted: PaymentAcceptedRepo;
61
+ paymentServiceProvider: PaymentServiceProviderRepo;
61
62
  product: ProductRepo;
62
63
  project: ProjectRepo;
63
64
  }) => Promise<T>;
@@ -78,9 +78,7 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
78
78
  /**
79
79
  * 決済方法認証
80
80
  */
81
- function check(params
82
- // ): ICheckOperation<factory.action.check.paymentMethod.movieTicket.IAction> {
83
- ) {
81
+ function check(params) {
84
82
  return (repos) => __awaiter(this, void 0, void 0, function* () {
85
83
  var _a;
86
84
  let action;
@@ -9,6 +9,7 @@ import type { MongoRepository as OrderRepo } from '../../repo/order';
9
9
  import type { MongoRepository as PlaceRepo } from '../../repo/place';
10
10
  import type { MongoRepository as PriceSpecificationRepo } from '../../repo/priceSpecification';
11
11
  import type { MongoRepository as ProductRepo } from '../../repo/product';
12
+ import type { MongoRepository as ProductOfferRepo } from '../../repo/productOffer';
12
13
  import type { MongoRepository as ProjectRepo } from '../../repo/project';
13
14
  import type { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offer';
14
15
  import type { MongoRepository as ReservationRepo } from '../../repo/reservation';
@@ -22,6 +23,7 @@ export interface IStartOperationRepos {
22
23
  offerCatalogItem: OfferCatalogItemRepo;
23
24
  offerRateLimit: OfferRateLimitRepo;
24
25
  product: ProductRepo;
26
+ productOffer: ProductOfferRepo;
25
27
  place: PlaceRepo;
26
28
  priceSpecification: PriceSpecificationRepo;
27
29
  project: ProjectRepo;
@@ -38,6 +40,7 @@ export interface IAddReservationsOperationRepos {
38
40
  offerCatalogItem: OfferCatalogItemRepo;
39
41
  offerRateLimit: OfferRateLimitRepo;
40
42
  product: ProductRepo;
43
+ productOffer: ProductOfferRepo;
41
44
  place: PlaceRepo;
42
45
  priceSpecification: PriceSpecificationRepo;
43
46
  reservation: ReservationRepo;
@@ -8,6 +8,7 @@ import type { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offe
8
8
  import type { MongoRepository as PlaceRepo } from '../../../repo/place';
9
9
  import type { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
10
10
  import type { MongoRepository as ProductRepo } from '../../../repo/product';
11
+ import type { MongoRepository as ProductOfferRepo } from '../../../repo/productOffer';
11
12
  import type { MongoRepository as ProjectRepo } from '../../../repo/project';
12
13
  import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
13
14
  import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
@@ -28,6 +29,7 @@ interface IAuthorizeRepos {
28
29
  place: PlaceRepo;
29
30
  priceSpecification: PriceSpecificationRepo;
30
31
  product: ProductRepo;
32
+ productOffer: ProductOfferRepo;
31
33
  project: ProjectRepo;
32
34
  reservation: ReservationRepo;
33
35
  task: TaskRepo;
@@ -8,6 +8,7 @@ import type { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offe
8
8
  import type { MongoRepository as PlaceRepo } from '../../../repo/place';
9
9
  import type { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
10
10
  import type { MongoRepository as ProductRepo } from '../../../repo/product';
11
+ import type { MongoRepository as ProductOfferRepo } from '../../../repo/productOffer';
11
12
  import type { MongoRepository as ProjectRepo } from '../../../repo/project';
12
13
  import type { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
13
14
  import type { MongoRepository as ReservationRepo } from '../../../repo/reservation';
@@ -37,6 +38,7 @@ declare function processStartReserve4chevre(params: {
37
38
  offerCatalogItem: OfferCatalogItemRepo;
38
39
  offerRateLimit: OfferRateLimitRepo;
39
40
  product: ProductRepo;
41
+ productOffer: ProductOfferRepo;
40
42
  place: PlaceRepo;
41
43
  priceSpecification: PriceSpecificationRepo;
42
44
  project: ProjectRepo;
@@ -7,6 +7,7 @@ import type { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalo
7
7
  import type { RedisRepository as OrderNumberRepo } from '../../repo/orderNumber';
8
8
  import type { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
9
9
  import type { MongoRepository as ProductRepo } from '../../repo/product';
10
+ import type { MongoRepository as ProductOfferRepo } from '../../repo/productOffer';
10
11
  import type { MongoRepository as ProjectRepo } from '../../repo/project';
11
12
  import type { MongoRepository as ServiceOutputRepo } from '../../repo/serviceOutput';
12
13
  import type { RedisRepository as ServiceOutputIdentifierRepo } from '../../repo/serviceOutputIdentifier';
@@ -21,6 +22,7 @@ export interface IAuthorizeOperationRepos {
21
22
  orderNumber: OrderNumberRepo;
22
23
  ownershipInfo: OwnershipInfoRepo;
23
24
  product: ProductRepo;
25
+ productOffer: ProductOfferRepo;
24
26
  project: ProjectRepo;
25
27
  serviceOutput: ServiceOutputRepo;
26
28
  serviceOutputIdentifier: ServiceOutputIdentifierRepo;
@@ -61,9 +63,10 @@ export declare function search(params: {
61
63
  offer: OfferRepo;
62
64
  offerCatalog: OfferCatalogRepo;
63
65
  product: ProductRepo;
66
+ productOffer: ProductOfferRepo;
64
67
  }) => Promise<{
65
68
  offers: factory.product.ITicketOffer[];
66
- product: factory.product.IProduct;
69
+ product: Omit<factory.product.IProduct, "offers">;
67
70
  }>;
68
71
  export type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
69
72
  /**
@@ -39,14 +39,20 @@ function search(params) {
39
39
  // 販売者指定の場合、検証
40
40
  if (product.typeOf === factory.product.ProductType.MembershipService
41
41
  || product.typeOf === factory.product.ProductType.PaymentCard) {
42
- if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
43
- const productOffers = product.offers;
44
- if (!Array.isArray(productOffers)) {
45
- return { offers: [], product };
46
- }
42
+ const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
43
+ if (typeof sellerId === 'string') {
44
+ // const productOffers = product.offers;
45
+ // if (!Array.isArray(productOffers)) {
46
+ // return { offers: [], product };
47
+ // }
48
+ const productOffers = yield repos.productOffer.search({
49
+ project: { id: { $eq: params.project.id } },
50
+ itemOffered: { id: { $eq: params.itemOffered.id } },
51
+ seller: { id: { $eq: sellerId } }
52
+ });
47
53
  const hasValidOffer = productOffers.some((o) => {
48
- var _a, _b;
49
- return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
54
+ var _a;
55
+ return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === sellerId
50
56
  && o.validFrom !== undefined
51
57
  && moment(o.validFrom)
52
58
  .isSameOrBefore(now)
@@ -111,7 +117,7 @@ function authorize(params) {
111
117
  availableOffers,
112
118
  seller: transaction.seller,
113
119
  orderNumber
114
- })();
120
+ })(repos);
115
121
  acceptedOffer = yield createServiceOutputIdentifier({ acceptedOffer, product })(repos);
116
122
  let requestBody;
117
123
  let responseBody;
@@ -278,7 +284,7 @@ function processVoidRegisterServiceTransaction(params) {
278
284
  * 受け入れらたオファーの内容を検証
279
285
  */
280
286
  function validateAcceptedOffers(params) {
281
- return () => __awaiter(this, void 0, void 0, function* () {
287
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
282
288
  let acceptedOfferWithoutDetail = params.object;
283
289
  if (!Array.isArray(acceptedOfferWithoutDetail)) {
284
290
  acceptedOfferWithoutDetail = [acceptedOfferWithoutDetail];
@@ -293,10 +299,15 @@ function validateAcceptedOffers(params) {
293
299
  typeOf: params.seller.typeOf
294
300
  };
295
301
  // 販売者を検証
296
- const productOffers = params.product.offers;
297
- if (!Array.isArray(productOffers)) {
298
- throw new factory.errors.Argument('Product', 'Product offers undefined');
299
- }
302
+ // const productOffers = params.product.offers;
303
+ // if (!Array.isArray(productOffers)) {
304
+ // throw new factory.errors.Argument('Product', 'Product offers undefined');
305
+ // }
306
+ const productOffers = yield repos.productOffer.search({
307
+ project: { id: { $eq: params.product.project.id } },
308
+ itemOffered: { id: { $eq: String(params.product.id) } },
309
+ seller: { id: { $eq: params.seller.id } }
310
+ });
300
311
  const hasValidOffer = productOffers.some((o) => {
301
312
  var _a;
302
313
  return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === params.seller.id;
@@ -1,4 +1,5 @@
1
- import { IMinimizedIndividualEvent } from '../../../repo/event';
1
+ import type { IMinimizedIndividualEvent } from '../../../repo/event';
2
+ import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
2
3
  import type { MongoRepository as ProductRepo } from '../../../repo/product';
3
4
  import type { MongoRepository as ProjectRepo } from '../../../repo/project';
4
5
  import * as factory from '../../../factory';
@@ -16,6 +17,7 @@ interface ICheckByIdentifierParams {
16
17
  * MovieTicket認証
17
18
  */
18
19
  declare function checkByIdentifier(params: ICheckByIdentifierParams): (repos: {
20
+ paymentServiceProvider: PaymentServiceProviderRepo;
19
21
  product: ProductRepo;
20
22
  project: ProjectRepo;
21
23
  }) => Promise<ICheckResult>;
@@ -61,8 +61,8 @@ function checkByIdentifier(params) {
61
61
  skhnCd = `${eventCOAInfo.titleCode}${`00${eventCOAInfo.titleBranchNum}`.slice(DIGITS)}`;
62
62
  }
63
63
  const sellerCredentials = yield (0, getCredentials_1.getCredentials)({
64
- paymentMethodType,
65
- seller: params.seller,
64
+ // paymentMethodType,
65
+ seller: { id: String(params.seller.id), project: { id: params.seller.project.id } },
66
66
  paymentServiceId: params.paymentServiceId
67
67
  })(repos);
68
68
  purchaseNumberAuthIn = {
@@ -1,11 +1,20 @@
1
- import type { MongoRepository as ProductRepo } from '../../../repo/product';
2
- import * as factory from '../../../factory';
1
+ import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
3
2
  declare function getCredentials(params: {
4
- paymentMethodType: string;
5
- seller: Pick<factory.seller.ISeller, 'id' | 'project'>;
3
+ seller: {
4
+ /**
5
+ * 販売者ID
6
+ */
7
+ id: string;
8
+ project: {
9
+ id: string;
10
+ };
11
+ };
12
+ /**
13
+ * 決済サービスID
14
+ */
6
15
  paymentServiceId: string;
7
16
  }): (repos: {
8
- product: ProductRepo;
17
+ paymentServiceProvider: PaymentServiceProviderRepo;
9
18
  }) => Promise<{
10
19
  kgygishCd: string;
11
20
  stCd: string;
@@ -13,25 +13,43 @@ exports.getCredentials = void 0;
13
13
  const factory = require("../../../factory");
14
14
  function getCredentials(params) {
15
15
  return (repos) => __awaiter(this, void 0, void 0, function* () {
16
- var _a, _b, _c;
16
+ var _a, _b;
17
17
  // 決済サービスからcredentialsを取得する
18
- const paymentServices = yield repos.product.searchPaymentServices({
18
+ // const paymentServices = await repos.product.searchPaymentServices(
19
+ // {
20
+ // limit: 1,
21
+ // page: 1,
22
+ // project: { id: { $eq: params.seller.project.id } },
23
+ // typeOf: { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket },
24
+ // id: { $eq: params.paymentServiceId }
25
+ // },
26
+ // [],
27
+ // []
28
+ // );
29
+ // const paymentService = paymentServices.shift();
30
+ // if (paymentService === undefined) {
31
+ // throw new factory.errors.NotFound('PaymentService');
32
+ // }
33
+ // const provider = paymentService.provider?.find((p) => p.id === params.seller.id);
34
+ // if (provider === undefined) {
35
+ // throw new factory.errors.NotFound('PaymentService provider');
36
+ // }
37
+ const paymentService = (yield repos.paymentServiceProvider.search({
19
38
  limit: 1,
20
39
  page: 1,
21
40
  project: { id: { $eq: params.seller.project.id } },
22
- typeOf: { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket },
41
+ provider: { id: { $eq: params.seller.id } },
23
42
  id: { $eq: params.paymentServiceId }
24
- }, [], []);
25
- const paymentService = paymentServices.shift();
43
+ })).shift();
26
44
  if (paymentService === undefined) {
27
45
  throw new factory.errors.NotFound('PaymentService');
28
46
  }
29
- const provider = (_a = paymentService.provider) === null || _a === void 0 ? void 0 : _a.find((p) => p.id === params.seller.id);
47
+ const provider = paymentService.provider;
30
48
  if (provider === undefined) {
31
49
  throw new factory.errors.NotFound('PaymentService provider');
32
50
  }
33
- const kgygishCd = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.kgygishCd;
34
- const stCd = (_c = provider.credentials) === null || _c === void 0 ? void 0 : _c.stCd;
51
+ const kgygishCd = (_a = provider.credentials) === null || _a === void 0 ? void 0 : _a.kgygishCd;
52
+ const stCd = (_b = provider.credentials) === null || _b === void 0 ? void 0 : _b.stCd;
35
53
  if (typeof kgygishCd !== 'string' || typeof stCd !== 'string') {
36
54
  throw new factory.errors.Argument('transaction', 'Provider credentials not enough');
37
55
  }
@@ -1,6 +1,7 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { MongoRepository as ActionRepo } from '../../../repo/action';
3
3
  import type { MongoRepository as EventRepo } from '../../../repo/event';
4
+ import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
4
5
  import type { MongoRepository as ProductRepo } from '../../../repo/product';
5
6
  import type { MongoRepository as ProjectRepo } from '../../../repo/project';
6
7
  import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
@@ -8,6 +9,7 @@ export declare function validateMovieTicket(params: factory.assetTransaction.pay
8
9
  action: ActionRepo;
9
10
  event: EventRepo;
10
11
  paymentAccepted: PaymentAcceptedRepo;
12
+ paymentServiceProvider: PaymentServiceProviderRepo;
11
13
  product: ProductRepo;
12
14
  project: ProjectRepo;
13
15
  }) => Promise<{
@@ -1,6 +1,7 @@
1
1
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
2
2
  import type { MongoRepository as ActionRepo } from '../../repo/action';
3
- import { MongoRepository as EventRepo } from '../../repo/event';
3
+ import type { MongoRepository as EventRepo } from '../../repo/event';
4
+ import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
4
5
  import type { MongoRepository as ProductRepo } from '../../repo/product';
5
6
  import type { MongoRepository as ProjectRepo } from '../../repo/project';
6
7
  import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
@@ -11,6 +12,7 @@ interface ICheckOperationRepos {
11
12
  action: ActionRepo;
12
13
  event: EventRepo;
13
14
  paymentAccepted: PaymentAcceptedRepo;
15
+ paymentServiceProvider: PaymentServiceProviderRepo;
14
16
  product: ProductRepo;
15
17
  project: ProjectRepo;
16
18
  }
@@ -20,6 +22,7 @@ interface IPayOperationRepos {
20
22
  accountingReport: AccountingReportRepo;
21
23
  event: EventRepo;
22
24
  paymentAccepted: PaymentAcceptedRepo;
25
+ paymentServiceProvider: PaymentServiceProviderRepo;
23
26
  product: ProductRepo;
24
27
  project: ProjectRepo;
25
28
  task: TaskRepo;
@@ -53,6 +56,7 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
53
56
  accountingReport: AccountingReportRepo;
54
57
  event: EventRepo;
55
58
  paymentAccepted: PaymentAcceptedRepo;
59
+ paymentServiceProvider: PaymentServiceProviderRepo;
56
60
  product: ProductRepo;
57
61
  project: ProjectRepo;
58
62
  task: TaskRepo;
@@ -23,7 +23,6 @@ const validation_1 = require("./movieTicket/validation");
23
23
  const errorHandler_1 = require("../../errorHandler");
24
24
  const onPaid_1 = require("./any/onPaid");
25
25
  const onRefund_1 = require("./any/onRefund");
26
- // type ICheckMovieTicketAction = factory.action.check.paymentMethod.movieTicket.IAction;
27
26
  /**
28
27
  * MovieTicket認証
29
28
  */
@@ -314,8 +313,8 @@ function payActionParams2seatInfoSyncIn(params) {
314
313
  // 全購入管理番号のMovieTicketをマージ
315
314
  const movieTickets = params.object.reduce((a, b) => [...a, ...(Array.isArray(b.movieTickets)) ? b.movieTickets : []], []);
316
315
  const sellerCredentials = yield (0, getCredentials_1.getCredentials)({
317
- paymentMethodType,
318
- seller: { id: sellerId, project: { id: event.project.id, typeOf: factory.organizationType.Project } },
316
+ // paymentMethodType,
317
+ seller: { id: sellerId, project: { id: event.project.id } },
319
318
  paymentServiceId
320
319
  })(repos);
321
320
  const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
@@ -41,6 +41,7 @@ export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
41
41
  export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
42
42
  export declare const USE_ORDER_PAYMENT_METHOD_TYPE_OF: boolean;
43
43
  export declare const USE_FETCH_API: boolean;
44
+ export declare const USE_SEARCH_ONLY_PRODUCTS_FORCIBLY: boolean;
44
45
  export declare const MONGO_MAX_TIME_MS: number;
45
46
  export declare const MONGO_READ_PREFERENCE: string;
46
47
  export declare const MONGO_AUTO_INDEX: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_FETCH_API = exports.USE_ORDER_PAYMENT_METHOD_TYPE_OF = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_SEARCH_ONLY_PRODUCTS_FORCIBLY = exports.USE_FETCH_API = exports.USE_ORDER_PAYMENT_METHOD_TYPE_OF = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const factory = require("./factory");
5
5
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
6
6
  ? process.env.INFORM_TRANSACTION_URL.split(' ')
@@ -65,6 +65,7 @@ exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_P
65
65
  exports.USE_OPTIMIZE_TICKET_OFFER = process.env.USE_OPTIMIZE_TICKET_OFFER === '1';
66
66
  exports.USE_ORDER_PAYMENT_METHOD_TYPE_OF = process.env.USE_ORDER_PAYMENT_METHOD_TYPE_OF === '1';
67
67
  exports.USE_FETCH_API = process.env.USE_FETCH_API === '1';
68
+ exports.USE_SEARCH_ONLY_PRODUCTS_FORCIBLY = process.env.USE_SEARCH_ONLY_PRODUCTS_FORCIBLY === '1';
68
69
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
69
70
  ? Number(process.env.MONGO_MAX_TIME_MS)
70
71
  // tslint:disable-next-line:no-magic-numbers
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.347.0-alpha.12",
14
- "@cinerino/sdk": "5.4.0-alpha.7",
13
+ "@chevre/factory": "4.347.0-alpha.13",
14
+ "@cinerino/sdk": "5.5.0-alpha.2",
15
15
  "@motionpicture/coa-service": "9.2.0",
16
16
  "@motionpicture/gmo-service": "5.2.0",
17
17
  "@sendgrid/mail": "6.4.0",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "21.18.0-alpha.41"
118
+ "version": "21.18.0-alpha.43"
119
119
  }