@chevre/domain 24.1.0-alpha.12 → 24.1.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.
@@ -36,7 +36,6 @@ export declare class AcceptedOfferRepo {
36
36
  searchAcceptedOffersByOrderNumber(filter: {
37
37
  limit?: number;
38
38
  page?: number;
39
- $slice?: [number, number];
40
39
  orderNumber: {
41
40
  $eq: string;
42
41
  };
@@ -53,9 +52,6 @@ export declare class AcceptedOfferRepo {
53
52
  id?: {
54
53
  $eq?: string;
55
54
  };
56
- typeOf?: {
57
- $in?: factory.order.IItemOffered['typeOf'][];
58
- };
59
55
  reservationFor?: {
60
56
  id?: {
61
57
  $in?: string[];
@@ -53,14 +53,14 @@ class AcceptedOfferRepo {
53
53
  }
54
54
  async aggreateOwnershipInfosByOrder(filter) {
55
55
  const aggregate = this.orderModel.aggregate([
56
+ { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
57
+ { $match: { typeOf: { $eq: factory_1.factory.order.OrderType.Order } } },
56
58
  {
57
59
  $unwind: {
58
60
  path: '$acceptedOffers',
59
61
  includeArrayIndex: 'acceptedOfferIndex'
60
62
  }
61
63
  },
62
- { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
63
- { $match: { typeOf: { $eq: factory_1.factory.order.OrderType.Order } } },
64
64
  {
65
65
  $project: {
66
66
  _id: 0,
@@ -82,21 +82,32 @@ class AcceptedOfferRepo {
82
82
  * 注文オファーを展開して検索する
83
83
  */
84
84
  async searchAcceptedOffersByOrderNumber(filter, inclusion) {
85
- const matchStages = [
85
+ /**
86
+ * unwind前に1ドキュメントを特定するためのstage
87
+ */
88
+ const matchStagesOneDocument = [
86
89
  { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } },
87
90
  { $match: { 'project.id': { $eq: filter.project.id.$eq } } },
88
91
  { $match: { typeOf: { $eq: factory_1.factory.order.OrderType.Order } } }
89
92
  ];
93
+ /**
94
+ * unwind後にオファー内容で絞るstage
95
+ */
96
+ const matchStages = [
97
+ // { $match: { orderNumber: { $eq: filter.orderNumber.$eq } } }, // matchStagesOneDocumentへ移行(2026-05-12~)
98
+ // { $match: { 'project.id': { $eq: filter.project.id.$eq } } }, // matchStagesOneDocumentへ移行(2026-05-12~)
99
+ // { $match: { typeOf: { $eq: factory.order.OrderType.Order } } } // matchStagesOneDocumentへ移行(2026-05-12~)
100
+ ];
90
101
  const itemOfferedIdEq = filter.acceptedOffers?.itemOffered?.id?.$eq;
91
102
  if (typeof itemOfferedIdEq === 'string') {
92
103
  matchStages.push({ $match: { 'acceptedOffers.itemOffered.id': { $exists: true, $eq: itemOfferedIdEq } } });
93
104
  }
94
- const itemOfferedTypeOfIn = filter.acceptedOffers?.itemOffered?.typeOf?.$in;
95
- if (Array.isArray(itemOfferedTypeOfIn)) {
96
- matchStages.push({
97
- $match: { 'acceptedOffers.itemOffered.typeOf': { $exists: true, $in: itemOfferedTypeOfIn } }
98
- });
99
- }
105
+ // const itemOfferedTypeOfIn = filter.acceptedOffers?.itemOffered?.typeOf?.$in;
106
+ // if (Array.isArray(itemOfferedTypeOfIn)) {
107
+ // matchStages.push({
108
+ // $match: { 'acceptedOffers.itemOffered.typeOf': { $exists: true, $in: itemOfferedTypeOfIn } }
109
+ // });
110
+ // }
100
111
  const resevationForIdIn = filter.acceptedOffers?.itemOffered?.reservationFor?.id?.$in;
101
112
  if (Array.isArray(resevationForIdIn)) {
102
113
  matchStages.push({
@@ -114,9 +125,7 @@ class AcceptedOfferRepo {
114
125
  });
115
126
  }
116
127
  const aggregate = this.orderModel.aggregate([
117
- // if (typeof params.sort?.orderDate === 'number') {
118
- // aggregate.sort({ orderDate: params.sort.orderDate });
119
- // }
128
+ ...matchStagesOneDocument,
120
129
  {
121
130
  $unwind: {
122
131
  path: '$acceptedOffers'
@@ -148,8 +157,11 @@ class AcceptedOfferRepo {
148
157
  }
149
158
  if (typeof filter.limit === 'number' && filter.limit > 0) {
150
159
  const page = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
151
- aggregate.limit(filter.limit * page)
152
- .skip(filter.limit * (page - 1));
160
+ // support skip -> limit(2026-05-12~)
161
+ // aggregate.limit(filter.limit * page)
162
+ // .skip(filter.limit * (page - 1));
163
+ aggregate.skip(filter.limit * (page - 1))
164
+ .limit(filter.limit);
153
165
  }
154
166
  return aggregate
155
167
  .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
@@ -1,6 +1,7 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import { factory } from '../../factory';
3
3
  type ISubReservationAsFindResult = Pick<factory.reservation.eventReservation.IReservation, 'underName' | 'id'> & {
4
+ numSeats?: number;
4
5
  price?: factory.reservation.eventReservation.IPrice;
5
6
  reservedTicket?: Pick<factory.reservation.eventReservation.IReservedTicket, 'ticketType'>;
6
7
  reservationFor?: factory.assetTransaction.reserve.IReservationFor;
@@ -91,6 +91,7 @@ class ReserveTransactionRepo {
91
91
  $project: {
92
92
  _id: 0,
93
93
  id: '$object.subReservation.id',
94
+ numSeats: '$object.subReservation.numSeats',
94
95
  price: '$object.subReservation.price',
95
96
  underName: '$object.underName',
96
97
  reservationFor: '$object.reservationFor',
@@ -25,7 +25,6 @@ const schemaDefinition = {
25
25
  bookingTime: Date,
26
26
  broker: mongoose_1.SchemaTypes.Mixed,
27
27
  modifiedTime: Date,
28
- numSeats: Number,
29
28
  previousReservationStatus: String,
30
29
  programMembershipUsed: mongoose_1.SchemaTypes.Mixed,
31
30
  reservationFor: mongoose_1.SchemaTypes.Mixed,
@@ -43,7 +42,9 @@ const schemaDefinition = {
43
42
  checkedIn: { type: Boolean, default: false },
44
43
  attended: { type: Boolean, default: false },
45
44
  additionalProperty: mongoose_1.SchemaTypes.Mixed,
45
+ // 以下廃止予定
46
46
  // bookingAgent: SchemaTypes.Mixed,
47
+ numSeats: Number,
47
48
  price: mongoose_1.SchemaTypes.Mixed,
48
49
  priceCurrency: String,
49
50
  issuedThrough: mongoose_1.SchemaTypes.Mixed
@@ -20,7 +20,7 @@ export type ICreatingReservation = Omit<factory.reservation.eventReservation.IRe
20
20
  /**
21
21
  * 廃止予定の予約属性
22
22
  */
23
- export type IDeprecatedField = 'price' | 'underName' | 'priceCurrency' | 'issuedThrough';
23
+ export type IDeprecatedField = 'price' | 'underName' | 'priceCurrency' | 'issuedThrough' | 'numSeats';
24
24
  export type IKeyOfProjection = Exclude<keyof factory.reservation.eventReservation.IReservation, IDeprecatedField> | 'reservedTicket.dateUsed' | 'reservationFor.id' | 'reservationFor.typeOf';
25
25
  export type IAttendedReservation = Pick<factory.reservation.eventReservation.IReservation, 'id' | 'typeOf' | 'project' | 'modifiedTime'> & {
26
26
  reservationFor: Pick<factory.reservation.eventReservation.IReservationForMinimized, 'id' | 'typeOf'>;
@@ -43,6 +43,10 @@ export type IReservationAsFindResult = Omit<factory.reservation.eventReservation
43
43
  * discontinue(2026-05-10~)
44
44
  */
45
45
  issuedThrough?: never;
46
+ /**
47
+ * discontinue(2026-05-11~)
48
+ */
49
+ numSeats?: never;
46
50
  };
47
51
  /**
48
52
  * 予約リポジトリ
@@ -115,6 +115,7 @@ class ReservationRepo {
115
115
  if (Array.isArray(params.subReservation)) {
116
116
  params.subReservation.forEach((subReservation) => {
117
117
  const { price: _discontinuePrice, reservedTicket, priceCurrency: _discontinuePriceCurrency, // discontinue priceCurrency
118
+ numSeats: _numSeats, // discontinue(2026-05-11~)
118
119
  ...subReservationWithoutPrice } = subReservation;
119
120
  const { ticketType: _ticketType, ...reservedTicketWithoutTicketType } = reservedTicket;
120
121
  // discontinue ticketType(2026-05-09~)
@@ -328,27 +328,17 @@ function createReservation(params) {
328
328
  const price4reservation = (0, price_1.createPrice)(params);
329
329
  if (params.reservationFor.typeOf === factory_1.factory.eventType.ScreeningEvent) {
330
330
  return {
331
- // project: params.project, // 廃止(2024-04-08~)
332
331
  typeOf: factory_1.factory.reservationType.EventReservation,
333
332
  id: params.id,
334
333
  // reservationPackage保管に移行(2023-06-06~)
335
334
  // issuedThrough,
336
335
  additionalProperty: params.additionalProperty,
337
- // bookingTime: params.reserveDate, // 廃止(2024-04-08~)
338
- // modifiedTime: params.reserveDate, // 廃止(2024-04-08~)
339
336
  numSeats: 1,
340
337
  price: price4reservation,
341
338
  priceCurrency: factory_1.factory.priceCurrency.JPY,
342
- // reservationNumber: params.reservationNumber, // 廃止(2024-04-08~)
343
339
  // statusは不要なので削除(2023-07-19~)
344
340
  // reservationStatus: factory.reservationStatusType.ReservationPending,
345
341
  reservedTicket: params.reservedTicket,
346
- // underName: { // 廃止(2024-04-08~)
347
- // typeOf: params.agent.typeOf,
348
- // name: params.agent.name
349
- // },
350
- // checkedIn: false, // 廃止(2024-04-08~)
351
- // attended: false, // 廃止(2024-04-08~)
352
342
  ...(typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined,
353
343
  ...(Array.isArray(params.subReservation))
354
344
  ? {
@@ -362,8 +352,6 @@ function createReservation(params) {
362
352
  })
363
353
  }
364
354
  : undefined,
365
- // reservationPackage保管に移行(2023-06-06~)
366
- // ...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined,
367
355
  ...(typeof params.programMembershipUsed?.identifier === 'string')
368
356
  ? { programMembershipUsed: params.programMembershipUsed }
369
357
  : undefined
@@ -94,7 +94,7 @@ function deleteReservationsByOrder(order) {
94
94
  orderNumber: { $eq: order.orderNumber },
95
95
  project: { id: { $eq: order.project.id } },
96
96
  acceptedOffers: {
97
- itemOffered: { typeOf: { $in: [factory_2.factory.reservationType.EventReservation] } }
97
+ // itemOffered: { typeOf: { $in: [factory.reservationType.EventReservation] } }
98
98
  }
99
99
  });
100
100
  const reservationIds = acceptedOffers.map((o) => String(o.itemOffered.id));
@@ -5,13 +5,14 @@ import type { IDeprecatedField, IKeyOfProjection, ReservationRepo } from '../../
5
5
  * 予約検索レスポンスとしての予約
6
6
  * 予約ドキュメントに予約取引の情報を補完する
7
7
  */
8
- type IReservationAsFindResult = Omit<factory.reservation.eventReservation.IReservation, 'price' | 'priceCurrency' | 'underName' | 'reservedTicket' | 'reservationFor' | 'issuedThrough'> & {
8
+ type IReservationAsFindResult = Omit<factory.reservation.eventReservation.IReservation, 'price' | 'priceCurrency' | 'underName' | 'reservedTicket' | 'reservationFor' | 'issuedThrough' | 'numSeats'> & {
9
9
  price?: factory.reservation.eventReservation.IPrice;
10
10
  priceCurrency?: factory.priceCurrency.JPY;
11
11
  underName?: factory.assetTransaction.reserve.IUnderName;
12
12
  reservedTicket?: factory.assetTransaction.reserve.IObjectSubReservation['reservedTicket'];
13
13
  reservationFor?: factory.assetTransaction.reserve.IReservationFor;
14
14
  issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
15
+ numSeats?: number;
15
16
  };
16
17
  /**
17
18
  * 予約を検索する
@@ -25,6 +25,7 @@ function findReservations(params, options) {
25
25
  const requireReservedTicket = Object.keys(inclusion).includes('reservedTicket');
26
26
  const requireReservationFor = Object.keys(inclusion).includes('reservationFor');
27
27
  const requireIssuedThrough = Object.keys(inclusion).includes('issuedThrough');
28
+ const requireNumSeats = Object.keys(inclusion).includes('numSeats');
28
29
  const reservationIds = rawReservations.map(({ id }) => id);
29
30
  const subReservations = await repos.assetTransaction.reserve.findSubReservationsById({
30
31
  ids: reservationIds
@@ -38,6 +39,7 @@ function findReservations(params, options) {
38
39
  const ticketTypeByTransaction = subReservationByTransaction?.reservedTicket?.ticketType;
39
40
  const reservationForByTransaction = subReservationByTransaction?.reservationFor;
40
41
  const issuedThroughByTransaction = subReservationByTransaction?.issuedThrough;
42
+ const numSeatsByTransaction = subReservationByTransaction?.numSeats;
41
43
  // 予約ドキュメントを最適化し始めたため、もう等しくない(2026-04-06~)
42
44
  // // 予約取引から参照した属性と全く等しいはず
43
45
  // if (requirePrice) {
@@ -53,7 +55,7 @@ function findReservations(params, options) {
53
55
  // console.error('reservationForMatched: false!!!', reservation.id);
54
56
  // }
55
57
  // }
56
- const { reservationFor: _reservationFor, issuedThrough: _issuedThrough, priceCurrency: _priceCurrency, reservedTicket, ...rawReservation4result } = reservation;
58
+ const { reservationFor: _reservationFor, issuedThrough: _issuedThrough, priceCurrency: _priceCurrency, numSeats: _numSeats, reservedTicket, ...rawReservation4result } = reservation;
57
59
  return {
58
60
  ...rawReservation4result, // 予約ドキュメントはそのまま返す
59
61
  ...(requirePrice && priceByTransaction !== undefined) ? { price: priceByTransaction } : undefined, // priceがあれば上書き
@@ -73,6 +75,9 @@ function findReservations(params, options) {
73
75
  ...(requireIssuedThrough && issuedThroughByTransaction !== undefined)
74
76
  ? { issuedThrough: issuedThroughByTransaction }
75
77
  : undefined, // issuedThroughがあれば上書き(2026-05-09~)
78
+ ...(requireNumSeats && numSeatsByTransaction !== undefined)
79
+ ? { numSeats: numSeatsByTransaction }
80
+ : undefined, // issuedThroughがあれば上書き(2026-05-09~)
76
81
  };
77
82
  });
78
83
  }
@@ -98,22 +98,14 @@ function onReservationConfirmed(confirmedReservations, reserveAction) {
98
98
  }
99
99
  }
100
100
  const subReservations4inform = confirmedReservations.map((r) => {
101
- const { additionalProperty, additionalTicketText,
102
- // attended, checkedIn,
103
- id, modifiedTime,
104
- // numSeats,
105
- price, programMembershipUsed, reservedTicket, subReservation, typeOf } = r;
101
+ const { additionalProperty, additionalTicketText, id, modifiedTime, price, programMembershipUsed, reservedTicket, subReservation, typeOf } = r;
106
102
  return {
107
- // bookingTime, // discontinue(2024-10-27~)
108
103
  id,
109
104
  typeOf,
110
105
  reservedTicket,
111
106
  ...(Array.isArray(additionalProperty)) ? { additionalProperty } : undefined,
112
107
  ...(typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined,
113
- // ...(typeof attended === 'boolean') ? { attended } : undefined, // discontinue(2024-10-27~)
114
- // ...(typeof checkedIn === 'boolean') ? { checkedIn } : undefined, // discontinue(2024-10-27~)
115
108
  ...(modifiedTime instanceof Date) ? { modifiedTime } : undefined,
116
- // ...(typeof numSeats === 'number') ? { numSeats } : undefined, // discontinue(2024-10-27~)
117
109
  ...(price !== undefined) ? { price } : undefined,
118
110
  ...(programMembershipUsed !== undefined) ? { programMembershipUsed } : undefined,
119
111
  ...(Array.isArray(subReservation)) ? { subReservation } : undefined
@@ -11,14 +11,18 @@ function searchByOrder(params) {
11
11
  page: params.page,
12
12
  project: { id: { $eq: params.project.id } },
13
13
  orderNumber: { $eq: params.orderNumber },
14
- acceptedOffers: { itemOffered: { typeOf: { $in: [reservationType] } } }
14
+ acceptedOffers: {
15
+ itemOffered: {
16
+ // typeOf: { $in: [reservationType] }
17
+ }
18
+ }
15
19
  }, ['itemOffered']);
16
20
  const reservationIds = acceptedOffers.map((offer) => {
17
21
  if (offer.itemOffered.typeOf === reservationType) {
18
22
  return offer.itemOffered.id;
19
23
  }
20
24
  else {
21
- // 検索条件にreservationTypeを含めているので、ありえないケース
25
+ // EventReservationしか存在しないので、ありえないケース
22
26
  throw new factory_1.factory.errors.Internal(`unexpected itemOffered.typeOf ${offer.itemOffered.typeOf}`);
23
27
  }
24
28
  });
@@ -71,7 +71,7 @@ function fixOrderAsPurpose(params, transaction) {
71
71
  project: { id: { $eq: transaction.project.id } },
72
72
  acceptedOffers: {
73
73
  itemOffered: {
74
- typeOf: { $in: [factory_1.factory.reservationType.EventReservation] },
74
+ // typeOf: { $in: [factory.reservationType.EventReservation] }, // EventReservationしか存在しないので不要(2026-05-12~)
75
75
  // movieTicketsに結合されたイベントID,座席コードで絞る
76
76
  reservationFor: { id: { $in: [reservationForId] } },
77
77
  reservedTicket: { ticketedSeat: { seatNumber: { $in: seatNumbers } } }
package/package.json CHANGED
@@ -11,7 +11,7 @@
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.1.0-alpha.6",
14
+ "@chevre/factory": "8.1.0-alpha.7",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -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.1.0-alpha.12"
94
+ "version": "24.1.0-alpha.14"
95
95
  }