@chevre/domain 22.0.0-alpha.13 → 22.0.0-alpha.14

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,37 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ const startTime = process.hrtime();
5
+ import { chevre } from '../../../lib/index';
6
+ const diff = process.hrtime(startTime);
7
+ console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
8
+
9
+ // const PROJECT_ID = process.env.PROJECT_ID;
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
15
+
16
+ const event = await eventRepo.findMinimizedIndividualEventById(
17
+ {
18
+ id: '120162210202407171202250'
19
+ // id: 'blxonxv1m'
20
+ },
21
+ [
22
+ 'project', 'typeOf', 'startDate',
23
+ // 'superEvent.id',
24
+ // 'offers.itemOffered',
25
+ 'offers.itemOffered.id',
26
+ 'offers.offeredThrough',
27
+ 'offers.eligibleQuantity',
28
+ 'offers.unacceptedPaymentMethod'
29
+ ]
30
+ );
31
+ // tslint:disable-next-line:no-null-keyword
32
+ console.dir(event, { depth: null });
33
+ }
34
+
35
+ main()
36
+ .then(console.log)
37
+ .catch(console.error);
@@ -69,6 +69,11 @@ interface IAggregateEvent {
69
69
  statuses: IStatus[];
70
70
  }
71
71
  type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.id' | 'offers.itemOffered.id' | 'offers.offeredThrough';
72
+ /**
73
+ * minimizedEvent検索時のprojection候補
74
+ * add(2024-07-18~)
75
+ */
76
+ type IKeyOfProjection4minimizedEvent = 'project' | 'typeOf' | 'startDate' | 'superEvent.id' | 'offers.itemOffered' | 'offers.itemOffered.id' | 'offers.offeredThrough' | 'offers.unacceptedPaymentMethod' | 'offers.eligibleQuantity';
72
77
  type IUnset<T extends factory.eventType> = {
73
78
  [key in keyof factory.event.IEvent<T>]?: 1;
74
79
  };
@@ -161,7 +166,7 @@ export declare class EventRepo {
161
166
  searchIds<T extends factory.eventType>(params: ISearchConditions<T>): Promise<string[]>;
162
167
  findMinimizedIndividualEventById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
163
168
  id: string;
164
- }): Promise<IMinimizedIndividualEvent<T>>;
169
+ }, inclusion: IKeyOfProjection4minimizedEvent[]): Promise<IMinimizedIndividualEvent<T>>;
165
170
  /**
166
171
  * イベントをキャンセルする
167
172
  */
@@ -906,9 +906,19 @@ class EventRepo {
906
906
  .exec();
907
907
  });
908
908
  }
909
- findMinimizedIndividualEventById(params) {
909
+ findMinimizedIndividualEventById(params, inclusion // add projection(2024-07-18~)
910
+ ) {
910
911
  return __awaiter(this, void 0, void 0, function* () {
911
- const doc = yield this.eventModel.findOne({ _id: params.id }, PROJECTION_MINIMIZED_EVENT)
912
+ let projection = {};
913
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
914
+ inclusion.forEach((field) => {
915
+ projection[field] = 1;
916
+ });
917
+ }
918
+ else {
919
+ projection = PROJECTION_MINIMIZED_EVENT;
920
+ }
921
+ const doc = yield this.eventModel.findOne({ _id: { $eq: params.id } }, projection)
912
922
  .exec();
913
923
  if (doc === null) {
914
924
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -21,7 +21,7 @@ const debug = createDebug('chevre-domain:service:aggregation');
21
21
  function aggregateOffers(params) {
22
22
  return (repos) => __awaiter(this, void 0, void 0, function* () {
23
23
  // 集計対象イベント検索
24
- const event = yield repos.event.findMinimizedIndividualEventById({ id: params.id });
24
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.id }, []);
25
25
  const eventCapacity = (yield repos.event.search({
26
26
  limit: 1,
27
27
  page: 1,
@@ -25,7 +25,7 @@ const debug = createDebug('chevre-domain:service:aggregation');
25
25
  function aggregateScreeningEvent(params) {
26
26
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
27
27
  // 集計対象イベント検索
28
- const event = yield repos.event.findMinimizedIndividualEventById(params);
28
+ const event = yield repos.event.findMinimizedIndividualEventById(params, []);
29
29
  let aggregatingEvents = [event];
30
30
  // プロジェクト限定(2023-02-22~)
31
31
  if (settings.useOfferRateLimitProjects.includes(event.project.id)) {
@@ -23,7 +23,7 @@ function aggregateUseActionsOnEvent(params) {
23
23
  const now = new Date();
24
24
  // 集計対象イベント検索
25
25
  // イベント取得属性最適化(2023-01-23~)
26
- const event = yield repos.event.findMinimizedIndividualEventById(params);
26
+ const event = yield repos.event.findMinimizedIndividualEventById(params, []);
27
27
  // 入場ゲート検索
28
28
  const entranceGates = yield findEntranceGates({ event })(repos);
29
29
  // 入場ゲートごとの集計
@@ -91,7 +91,7 @@ function fixEvent(params) {
91
91
  // } else {
92
92
  // event = await repos.event.findMinimizedIndividualEventById({ id: reservationForId });
93
93
  // }
94
- event = yield repos.event.findMinimizedIndividualEventById({ id: reservationForId });
94
+ event = yield repos.event.findMinimizedIndividualEventById({ id: reservationForId }, []);
95
95
  let offeredThrough = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
96
96
  if (offeredThrough === undefined) {
97
97
  offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
@@ -311,27 +311,13 @@ function checkAvailability(params) {
311
311
  */
312
312
  function searchEventTicketOffers(params) {
313
313
  return (repos) => __awaiter(this, void 0, void 0, function* () {
314
- // optimize projection(2024-07-17~)
315
- let event;
316
- // event = await repos.event.findMinimizedIndividualEventById({ id: params.event.id });
317
314
  const eventType = params.event.typeOf;
318
- if (eventType === factory.eventType.Event) {
319
- event = (yield repos.event.search({
320
- limit: 1, page: 1,
321
- id: { $eq: params.event.id },
322
- typeOf: eventType
323
- }, ['_id', 'project', 'typeOf', 'startDate', 'offers.itemOffered.id', 'offers.offeredThrough'], [])).shift();
324
- }
325
- else if (eventType === factory.eventType.ScreeningEvent) {
326
- event = (yield repos.event.search({
327
- limit: 1, page: 1,
328
- id: { $eq: params.event.id },
329
- typeOf: eventType
330
- }, ['_id', 'project', 'typeOf', 'startDate', 'superEvent.id', 'offers.itemOffered.id', 'offers.offeredThrough'], [])).shift();
331
- }
332
- if (event === undefined) {
333
- throw new factory.errors.NotFound(params.event.typeOf);
334
- }
315
+ // optimize projection(2024-07-17~)
316
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id }, [
317
+ 'project', 'typeOf', 'startDate',
318
+ 'superEvent.id',
319
+ 'offers.itemOffered.id', 'offers.offeredThrough', 'offers.unacceptedPaymentMethod', 'offers.eligibleQuantity'
320
+ ]);
335
321
  let offers;
336
322
  let unitPriceOffers;
337
323
  const eventOffers = event.offers;
@@ -371,7 +357,8 @@ exports.searchEventTicketOffers = searchEventTicketOffers;
371
357
  function searchOfferAppliesToMovieTicket(params) {
372
358
  return (repos) => __awaiter(this, void 0, void 0, function* () {
373
359
  var _a, _b, _c;
374
- const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
360
+ // optimize(2024-07-18~)
361
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
375
362
  // let soundFormatTypes: string[] = [];
376
363
  let videoFormatTypes = [];
377
364
  if (event.typeOf === factory.eventType.ScreeningEvent) {
@@ -449,7 +436,8 @@ function searchOfferCatalogItems(params) {
449
436
  throw new factory.errors.Argument('page', 'must be number');
450
437
  }
451
438
  let offerCatalogItems = [];
452
- const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
439
+ // optimize(2024-07-18~)
440
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id }, ['offers.itemOffered.id']);
453
441
  // 興行設定があれば興行のカタログを参照する
454
442
  const eventOffers = event.offers;
455
443
  let catalogId;
@@ -518,7 +506,8 @@ function searchOfferCatalogItemAvailability(params) {
518
506
  throw new factory.errors.Argument('page', 'must be number');
519
507
  }
520
508
  let availabilities = [];
521
- const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
509
+ // optimize(2024-07-18~)
510
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id }, ['project', 'offers.itemOffered.id']);
522
511
  // 興行設定があれば興行のカタログを参照する
523
512
  const eventOffers = event.offers;
524
513
  let catalogId;
@@ -50,7 +50,7 @@ function authorize(params) {
50
50
  try {
51
51
  // イベント取得属性最適化(2023-01-23~)
52
52
  screeningEvent =
53
- yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id });
53
+ yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id }, []);
54
54
  const availablePaymentMethodTypes = yield repos.categoryCode.search({
55
55
  project: { id: { $eq: transaction.project.id } },
56
56
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
@@ -72,9 +72,7 @@ function changeOffers(params) {
72
72
  return Object.assign(Object.assign({}, offer), { ticketInfo: Object.assign(Object.assign({}, offer.ticketInfo), { spseatAdd1: originalAcceptedOfferBySeatNumber.ticketInfo.spseatAdd1, spseatAdd2: originalAcceptedOfferBySeatNumber.ticketInfo.spseatAdd2, spseatKbn: originalAcceptedOfferBySeatNumber.ticketInfo.spseatKbn }) });
73
73
  });
74
74
  // イベント取得属性最適化(2023-01-23~)
75
- const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
76
- id: params.object.event.id
77
- });
75
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id }, []);
78
76
  const availablePaymentMethodTypes = yield repos.categoryCode.search({
79
77
  project: { id: { $eq: transaction.project.id } },
80
78
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
@@ -60,12 +60,13 @@ exports.addOffers2Seat = addOffers2Seat;
60
60
  /**
61
61
  * イベントに対する座席オファーを検索する
62
62
  */
63
+ // tslint:disable-next-line:max-func-body-length
63
64
  function searchEventSeatOffersWithPaging(params) {
64
65
  return (repos) => __awaiter(this, void 0, void 0, function* () {
65
66
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
66
67
  let offers = [];
67
- // イベント取得属性最適化(2023-01-23~)
68
- const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
68
+ // optimize(2024-07-18~)
69
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id }, ['project', 'startDate', 'offers.itemOffered']);
69
70
  // 座席指定利用可能かどうか
70
71
  const eventOffers = event.offers;
71
72
  const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
@@ -55,7 +55,7 @@ function checkMovieTicket(params) {
55
55
  }
56
56
  // イベント取得属性最適化(2023-01-23~)
57
57
  let screeningEvent;
58
- screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] });
58
+ screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] }, []);
59
59
  const sellerId = (_f = optimizedCheckObject[0]) === null || _f === void 0 ? void 0 : _f.seller.id;
60
60
  const paymentAccepted = yield repos.paymentAccepted.isAcceptedBySeller({
61
61
  seller: { id: sellerId },
@@ -112,7 +112,7 @@ function payActionParams2seatInfoSyncIn(params) {
112
112
  throw new factory.errors.Argument('movieTickets', 'Number of events must be 1');
113
113
  }
114
114
  // イベント取得属性最適化(2023-01-23~)
115
- const event = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] });
115
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] }, []);
116
116
  const sellerId = String((_d = params.recipient) === null || _d === void 0 ? void 0 : _d.id);
117
117
  // 全購入管理番号のMovieTicketをマージ
118
118
  const movieTickets = params.object.reduce((a, b) => [...a, ...(Array.isArray(b.movieTickets)) ? b.movieTickets : []], []);
@@ -45,9 +45,7 @@ function validateMovieTicket(params, paymentServiceId, useCheckByIdentifierIfNot
45
45
  throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
46
46
  }
47
47
  // イベント取得属性最適化(2023-01-23~)
48
- const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
49
- id: eventIds[0]
50
- });
48
+ const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] }, []);
51
49
  // 販売者からムビチケ決済情報取得
52
50
  const sellerId = (_c = params.recipient) === null || _c === void 0 ? void 0 : _c.id;
53
51
  if (typeof sellerId !== 'string') {
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.0.0-alpha.13"
113
+ "version": "22.0.0-alpha.14"
114
114
  }