@chevre/domain 21.2.0-alpha.150 → 21.2.0-alpha.151

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.
@@ -10,27 +10,28 @@ async function main() {
10
10
 
11
11
  const productRepo = new chevre.repository.Product(mongoose.connection);
12
12
 
13
- const providers = await productRepo.searchProviders({
13
+ const paymentServices = await productRepo.aggregateProvider({
14
14
  project: { id: { $eq: PROJECT_ID } },
15
- id: 'xxx'
15
+ provider: { id: { $eq: 'xxx' } }
16
+ // id: { $eq: 'xxx' }
16
17
  });
17
- console.log(providers);
18
- console.log(providers[0]?.credentials);
19
- console.log(providers.length);
20
-
21
- const paymentServices = await productRepo.searchPaymentServicesByProvider(
22
- {
23
- limit: 10,
24
- page: 1,
25
- sort: { productID: chevre.factory.sortType.Descending },
26
- project: { id: { $eq: PROJECT_ID } },
27
- typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard },
28
- provider: { id: { $eq: 'xxx' } }
29
- }
30
- );
31
18
  console.log(paymentServices);
32
- console.log(paymentServices[0]?.provider?.credentials);
19
+ console.log(paymentServices[0]?.provider.credentials);
33
20
  console.log(paymentServices.length);
21
+
22
+ // const paymentServices = await productRepo.searchPaymentServicesByProvider(
23
+ // {
24
+ // limit: 10,
25
+ // page: 1,
26
+ // sort: { productID: chevre.factory.sortType.Descending },
27
+ // project: { id: { $eq: PROJECT_ID } },
28
+ // typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard },
29
+ // provider: { id: { $eq: 'xxx' } }
30
+ // }
31
+ // );
32
+ // console.log(paymentServices);
33
+ // console.log(paymentServices[0]?.provider?.credentials);
34
+ // console.log(paymentServices.length);
34
35
  }
35
36
 
36
37
  main()
@@ -11,7 +11,8 @@ async function main() {
11
11
  const placeRepo = new chevre.repository.Place(mongoose.connection);
12
12
 
13
13
  await placeRepo.syncScreeningRooms({
14
- id: '60409176f60a46000a7a3787'
14
+ id: '60409176f60a46000a7a3787',
15
+ useScreeningRoomType: true
15
16
  });
16
17
  console.log('synced');
17
18
  }
@@ -30,7 +30,10 @@ async function main() {
30
30
  doc.toObject();
31
31
 
32
32
  console.log('syncing...', project.id, typeOf, id, name.ja, i);
33
- await placeRepo.syncScreeningRooms({ id });
33
+ await placeRepo.syncScreeningRooms({
34
+ id,
35
+ useScreeningRoomType: true
36
+ });
34
37
  console.log('synced.', project.id, typeOf, id, name.ja, i);
35
38
  });
36
39
 
@@ -58,7 +58,7 @@ export declare class MongoRepository {
58
58
  /**
59
59
  * 決済サービスのプロバイダー検索
60
60
  */
61
- searchProviders(params: {
61
+ aggregateProvider(params: {
62
62
  limit?: number;
63
63
  page?: number;
64
64
  project?: {
@@ -66,8 +66,17 @@ export declare class MongoRepository {
66
66
  $eq?: string;
67
67
  };
68
68
  };
69
- id: string;
70
- }): Promise<factory.service.paymentService.IProvider[]>;
69
+ id?: {
70
+ $eq?: string;
71
+ };
72
+ provider?: {
73
+ id?: {
74
+ $eq?: string;
75
+ };
76
+ };
77
+ }): Promise<(Pick<factory.service.paymentService.IService, 'id' | 'name'> & {
78
+ provider: Pick<factory.service.paymentService.IProvider, 'id' | 'name' | 'credentials'>;
79
+ })[]>;
71
80
  /**
72
81
  * プロダクトを保管する
73
82
  * 作成 or 更新
@@ -295,16 +295,24 @@ class MongoRepository {
295
295
  /**
296
296
  * 決済サービスのプロバイダー検索
297
297
  */
298
- searchProviders(params) {
299
- var _a, _b;
298
+ aggregateProvider(params) {
299
+ var _a, _b, _c, _d, _e;
300
300
  return __awaiter(this, void 0, void 0, function* () {
301
301
  const matchStages = [];
302
302
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
303
303
  if (typeof projectIdEq === 'string') {
304
304
  matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
305
305
  }
306
- matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id) } } });
306
+ const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
307
+ if (typeof idEq === 'string') {
308
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } } });
309
+ }
310
+ const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
311
+ if (typeof providerIdEq === 'string') {
312
+ matchStages.push({ $match: { 'provider.id': { $exists: true, $eq: providerIdEq } } });
313
+ }
307
314
  const aggregate = this.productModel.aggregate([
315
+ { $sort: { productID: factory.sortType.Ascending } },
308
316
  {
309
317
  $unwind: {
310
318
  path: '$provider'
@@ -314,18 +322,13 @@ class MongoRepository {
314
322
  {
315
323
  $project: {
316
324
  _id: 0,
317
- // ↓セキュアな情報を隠蔽するように
318
- credentials: {
319
- shopId: '$provider.credentials.shopId',
320
- tokenizationCode: '$provider.credentials.tokenizationCode',
321
- paymentUrl: {
322
- expiresInSeconds: '$provider.credentials.paymentUrl.expiresInSeconds',
323
- useCallback: '$provider.credentials.paymentUrl.useCallback',
324
- useWebhook: '$provider.credentials.paymentUrl.useWebhook'
325
- }
325
+ provider: {
326
+ id: '$provider.id',
327
+ name: '$provider.name',
328
+ credentials: '$provider.credentials'
326
329
  },
327
- id: '$provider.id',
328
- name: '$provider.name'
330
+ id: { $toString: '$_id' },
331
+ name: '$name'
329
332
  }
330
333
  }
331
334
  ]);
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.150"
120
+ "version": "21.2.0-alpha.151"
121
121
  }