@chevre/domain 21.2.0-alpha.131 → 21.2.0-alpha.133

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,38 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const PROJECT_ID = process.env.PROJECT_ID;
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const productRepo = new chevre.repository.Product(mongoose.connection);
12
+
13
+ const providers = await productRepo.searchProviders({
14
+ project: { id: { $eq: PROJECT_ID } },
15
+ id: 'xxx'
16
+ });
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
+ console.log(paymentServices);
32
+ console.log(paymentServices[0]?.provider?.credentials);
33
+ console.log(paymentServices.length);
34
+ }
35
+
36
+ main()
37
+ .then(console.log)
38
+ .catch(console.error);
@@ -73,6 +73,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
73
73
  smokingAllowed?: boolean | undefined;
74
74
  sameAs?: string | undefined;
75
75
  parentOrganization?: any;
76
+ openSeatingAllowed?: any;
77
+ amenityFeature?: any;
76
78
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
77
79
  typeOf: string;
78
80
  additionalProperty: any[];
@@ -95,6 +97,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
95
97
  smokingAllowed?: boolean | undefined;
96
98
  sameAs?: string | undefined;
97
99
  parentOrganization?: any;
100
+ openSeatingAllowed?: any;
101
+ amenityFeature?: any;
98
102
  }>> & Omit<import("mongoose").FlatRecord<{
99
103
  typeOf: string;
100
104
  additionalProperty: any[];
@@ -117,6 +121,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
117
121
  smokingAllowed?: boolean | undefined;
118
122
  sameAs?: string | undefined;
119
123
  parentOrganization?: any;
124
+ openSeatingAllowed?: any;
125
+ amenityFeature?: any;
120
126
  }> & {
121
127
  _id: import("mongoose").Types.ObjectId;
122
128
  }, never>>;
@@ -32,7 +32,10 @@ const schema = new mongoose_1.Schema({
32
32
  kanaName: String,
33
33
  offers: mongoose_1.SchemaTypes.Mixed,
34
34
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
35
- parentOrganization: mongoose_1.SchemaTypes.Mixed
35
+ parentOrganization: mongoose_1.SchemaTypes.Mixed,
36
+ // ↓ルームの施設からの分離に伴い属性追加(2023-06-22~)
37
+ openSeatingAllowed: mongoose_1.SchemaTypes.Mixed,
38
+ amenityFeature: mongoose_1.SchemaTypes.Mixed
36
39
  }, {
37
40
  collection: 'places',
38
41
  id: true,
@@ -132,3 +135,15 @@ schema.index({ 'containsPlace.containsPlace.containsPlace.additionalProperty': 1
132
135
  'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
133
136
  }
134
137
  });
138
+ schema.index({ 'containedInPlace.id': 1, branchCode: 1 }, {
139
+ name: 'searchByContainedInPlaceId',
140
+ partialFilterExpression: {
141
+ 'containedInPlace.id': { $exists: true }
142
+ }
143
+ });
144
+ schema.index({ 'containedInPlace.branchCode': 1, branchCode: 1 }, {
145
+ name: 'searchByContainedInPlaceBranchCode',
146
+ partialFilterExpression: {
147
+ 'containedInPlace.branchCode': { $exists: true }
148
+ }
149
+ });
@@ -100,3 +100,9 @@ schema.index({ 'name.en': 1, productID: 1 }, {
100
100
  'name.en': { $exists: true }
101
101
  }
102
102
  });
103
+ schema.index({ 'provider.id': 1, productID: 1 }, {
104
+ name: 'searchByProviderId',
105
+ partialFilterExpression: {
106
+ 'provider.id': { $exists: true }
107
+ }
108
+ });
@@ -25,6 +25,9 @@
25
25
  import { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  export type IProduct = factory.product.IProduct | factory.service.paymentService.IService;
28
+ export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'additionalProperty'> & {
29
+ provider?: Pick<factory.service.paymentService.IProvider, 'credentials'>;
30
+ };
28
31
  /**
29
32
  * プロダクトリポジトリ
30
33
  */
@@ -51,6 +54,20 @@ export declare class MongoRepository {
51
54
  typeOf: factory.service.paymentService.PaymentServiceType;
52
55
  id: string;
53
56
  }): Promise<factory.product.IAvailableChannel>;
57
+ searchPaymentServicesByProvider(params: Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
58
+ /**
59
+ * 決済サービスのプロバイダー検索
60
+ */
61
+ searchProviders(params: {
62
+ limit?: number;
63
+ page?: number;
64
+ project?: {
65
+ id?: {
66
+ $eq?: string;
67
+ };
68
+ };
69
+ id: string;
70
+ }): Promise<factory.service.paymentService.IProvider[]>;
54
71
  /**
55
72
  * プロダクトを保管する
56
73
  * 作成 or 更新
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
+ const mongoose_1 = require("mongoose");
24
25
  const product_1 = require("./mongoose/schemas/product");
25
26
  const factory = require("../factory");
26
27
  const settings_1 = require("../settings");
@@ -33,7 +34,7 @@ class MongoRepository {
33
34
  }
34
35
  // tslint:disable-next-line:max-func-body-length
35
36
  static CREATE_MONGO_CONDITIONS(params) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
37
38
  // MongoDB検索条件
38
39
  const andConditions = [];
39
40
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -144,6 +145,11 @@ class MongoRepository {
144
145
  ]
145
146
  });
146
147
  }
148
+ // プロバイダー条件を追加(2023-06-21~)
149
+ const providerIdEq = (_x = (_w = params.provider) === null || _w === void 0 ? void 0 : _w.id) === null || _x === void 0 ? void 0 : _x.$eq;
150
+ if (typeof providerIdEq === 'string') {
151
+ andConditions.push({ 'provider.id': { $exists: true, $eq: providerIdEq } });
152
+ }
147
153
  return andConditions;
148
154
  }
149
155
  findById(conditions, projection) {
@@ -225,6 +231,113 @@ class MongoRepository {
225
231
  return availableChannel;
226
232
  });
227
233
  }
234
+ searchPaymentServicesByProvider(params) {
235
+ var _a, _b, _c, _d, _e, _f;
236
+ return __awaiter(this, void 0, void 0, function* () {
237
+ const matchStages = [];
238
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
239
+ if (typeof projectIdEq === 'string') {
240
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
241
+ }
242
+ const typeOfEq = (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$eq;
243
+ if (typeof typeOfEq === 'string') {
244
+ matchStages.push({ $match: { typeOf: { $eq: typeOfEq } } });
245
+ }
246
+ const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
247
+ if (typeof providerIdEq === 'string') {
248
+ matchStages.push({ $match: { 'provider.id': { $exists: true, $eq: providerIdEq } } });
249
+ }
250
+ const aggregate = this.productModel.aggregate([
251
+ ...(typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.productID) === 'number')
252
+ ? [{ $sort: { productID: params.sort.productID } }]
253
+ : [],
254
+ {
255
+ $unwind: {
256
+ path: '$provider'
257
+ }
258
+ },
259
+ ...matchStages,
260
+ {
261
+ $project: {
262
+ _id: 0,
263
+ typeOf: '$typeOf',
264
+ productID: '$productID',
265
+ description: '$description',
266
+ name: '$name',
267
+ // provider: [ [Object] ],
268
+ additionalProperty: '$additionalProperty',
269
+ serviceType: '$serviceType',
270
+ id: { $toString: '$_id' },
271
+ // ↓セキュアな情報を隠蔽するように
272
+ provider: {
273
+ credentials: {
274
+ shopId: '$provider.credentials.shopId',
275
+ tokenizationCode: '$provider.credentials.tokenizationCode',
276
+ paymentUrl: {
277
+ expiresInSeconds: '$provider.credentials.paymentUrl.expiresInSeconds',
278
+ useCallback: '$provider.credentials.paymentUrl.useCallback',
279
+ useWebhook: '$provider.credentials.paymentUrl.useWebhook'
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ ]);
286
+ if (typeof params.limit === 'number' && params.limit > 0) {
287
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
288
+ aggregate.limit(params.limit * page)
289
+ .skip(params.limit * (page - 1));
290
+ }
291
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
292
+ .exec();
293
+ });
294
+ }
295
+ /**
296
+ * 決済サービスのプロバイダー検索
297
+ */
298
+ searchProviders(params) {
299
+ var _a, _b;
300
+ return __awaiter(this, void 0, void 0, function* () {
301
+ const matchStages = [];
302
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
303
+ if (typeof projectIdEq === 'string') {
304
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
305
+ }
306
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id) } } });
307
+ const aggregate = this.productModel.aggregate([
308
+ {
309
+ $unwind: {
310
+ path: '$provider'
311
+ }
312
+ },
313
+ ...matchStages,
314
+ {
315
+ $project: {
316
+ _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
+ }
326
+ },
327
+ id: '$provider.id',
328
+ name: '$provider.name'
329
+ }
330
+ }
331
+ ]);
332
+ if (typeof params.limit === 'number' && params.limit > 0) {
333
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
334
+ aggregate.limit(params.limit * page)
335
+ .skip(params.limit * (page - 1));
336
+ }
337
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
338
+ .exec();
339
+ });
340
+ }
228
341
  /**
229
342
  * プロダクトを保管する
230
343
  * 作成 or 更新
@@ -56,16 +56,25 @@ function findEntranceGates(params) {
56
56
  return (repos) => __awaiter(this, void 0, void 0, function* () {
57
57
  let movieTheater;
58
58
  try {
59
- movieTheater = yield repos.place.findById({ id: params.event.superEvent.location.id },
60
- // 不要な属性を取得しない
61
- ['hasEntranceGate'], []
62
- // {
63
- // containsPlace: 0,
64
- // hasPOS: 0,
65
- // offers: 0,
66
- // parentOrganization: 0
67
- // }
68
- );
59
+ const searchMovieTheatersResult = yield repos.place.searchMovieTheaters({
60
+ limit: 1,
61
+ page: 1,
62
+ id: { $eq: params.event.superEvent.location.id },
63
+ $projection: {
64
+ containsPlace: 0,
65
+ hasPOS: 0,
66
+ offers: 0,
67
+ parentOrganization: 0,
68
+ name: 0
69
+ }
70
+ });
71
+ movieTheater = searchMovieTheatersResult.shift();
72
+ // movieTheater = await repos.place.findById(
73
+ // { id: params.event.superEvent.location.id },
74
+ // // 不要な属性を取得しない
75
+ // ['hasEntranceGate'],
76
+ // []
77
+ // );
69
78
  }
70
79
  catch (error) {
71
80
  let throwsError = true;
@@ -66,6 +66,13 @@ function onResourceUpdated(params) {
66
66
  ids: params.id,
67
67
  typeOf: params.typeOf
68
68
  })(repos);
69
+ // tslint:disable-next-line:no-suspicious-comment
70
+ // TODO ルーム同期タスクを作成
71
+ yield syncScreeningRooms({
72
+ project: { id: params.project.id },
73
+ ids: params.id,
74
+ typeOf: params.typeOf
75
+ })(repos);
69
76
  break;
70
77
  case 'AccountTitle':
71
78
  yield createInformAccountTitleTasks({
@@ -235,17 +242,29 @@ function createInformMovieTheaterTasks(params) {
235
242
  'project',
236
243
  'telephone',
237
244
  'url',
238
- 'typeOf',
239
- 'containsPlace.branchCode',
240
- 'containsPlace.name',
241
- 'containsPlace.typeOf',
242
- 'containsPlace.additionalProperty',
243
- 'containsPlace.address'
245
+ 'typeOf'
246
+ // 'containsPlace.branchCode',
247
+ // 'containsPlace.name',
248
+ // 'containsPlace.typeOf',
249
+ // 'containsPlace.additionalProperty',
250
+ // 'containsPlace.address'
244
251
  ], []);
245
252
  if (movieTheater.project.id !== params.project.id) {
246
253
  throw new factory.errors.Argument('project.id', 'project.id not matched');
247
254
  }
248
- const movieTheaters4inform = [movieTheater];
255
+ // ルームを検索
256
+ const screeningRooms = yield repos.place.searchScreeningRooms({
257
+ containedInPlace: { id: { $eq: movieTheater.id } }
258
+ });
259
+ const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
260
+ return {
261
+ branchCode: room.branchCode,
262
+ name: room.name,
263
+ typeOf: room.typeOf,
264
+ additionalProperty: room.additionalProperty,
265
+ address: room.address
266
+ };
267
+ }) })];
249
268
  if (movieTheaters4inform.length > 0) {
250
269
  const taskRunsAt = new Date();
251
270
  const informTasks = [];
@@ -350,3 +369,35 @@ function createInformAccountTitleTasks(params) {
350
369
  }
351
370
  });
352
371
  }
372
+ function syncScreeningRooms(__) {
373
+ return (__2) => __awaiter(this, void 0, void 0, function* () {
374
+ // if (params.ids.length !== 1) {
375
+ // throw new factory.errors.Argument('id', 'id.length must be 1');
376
+ // }
377
+ // const movieTheater = await repos.place.findById(
378
+ // { id: params.ids[0] },
379
+ // [
380
+ // 'additionalProperty',
381
+ // 'branchCode',
382
+ // 'hasEntranceGate',
383
+ // 'hasPOS',
384
+ // 'kanaName',
385
+ // 'name',
386
+ // 'parentOrganization',
387
+ // 'project',
388
+ // 'telephone',
389
+ // 'url',
390
+ // 'typeOf',
391
+ // 'containsPlace.branchCode',
392
+ // 'containsPlace.name',
393
+ // 'containsPlace.typeOf',
394
+ // 'containsPlace.additionalProperty',
395
+ // 'containsPlace.address'
396
+ // ],
397
+ // []
398
+ // );
399
+ // if (movieTheater.project.id !== params.project.id) {
400
+ // throw new factory.errors.Argument('project.id', 'project.id not matched');
401
+ // }
402
+ });
403
+ }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.39",
12
+ "@chevre/factory": "4.313.0-alpha.40",
13
13
  "@cinerino/sdk": "3.157.0-alpha.16",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -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.131"
120
+ "version": "21.2.0-alpha.133"
121
121
  }