@chevre/domain 24.1.0-alpha.2 → 24.1.0-alpha.4

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.
@@ -54,5 +54,11 @@ export declare class AggregateReservationRepo {
54
54
  filter: any;
55
55
  $unset: any;
56
56
  }): Promise<import("mongoose").UpdateWriteOpResult>;
57
+ /**
58
+ * イベント開始日時が指定以前の集計を削除する
59
+ */
60
+ deleteManyByEventStartDate(params: {
61
+ reservationForStartDateLte: Date;
62
+ }): Promise<import("mongodb").DeleteResult>;
57
63
  }
58
64
  export {};
@@ -132,5 +132,14 @@ class AggregateReservationRepo {
132
132
  return this.aggregateReservationModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
133
133
  .exec();
134
134
  }
135
+ /**
136
+ * イベント開始日時が指定以前の集計を削除する
137
+ */
138
+ async deleteManyByEventStartDate(params) {
139
+ return this.aggregateReservationModel.deleteMany({
140
+ 'reservationFor.startDate': { $lte: params.reservationForStartDateLte }
141
+ })
142
+ .exec();
143
+ }
135
144
  }
136
145
  exports.AggregateReservationRepo = AggregateReservationRepo;
@@ -390,47 +390,21 @@ function CREATE_MONGO_CONDITIONS(params) {
390
390
  }
391
391
  /* istanbul ignore else */
392
392
  if (params.reservedTicket !== undefined) {
393
- /* istanbul ignore else */
394
- if (params.reservedTicket.ticketType !== undefined) {
395
- /* istanbul ignore else */
396
- if (Array.isArray(params.reservedTicket.ticketType.ids)) {
397
- andConditions.push({
398
- 'reservedTicket.ticketType.id': {
399
- $exists: true,
400
- $in: params.reservedTicket.ticketType.ids
401
- }
402
- });
403
- }
404
- // 単価オファーカテゴリーでの検索は廃止(2026-04-02~)
405
- // /* istanbul ignore else */
406
- // if (params.reservedTicket.ticketType.category !== undefined) {
407
- // /* istanbul ignore else */
408
- // if (Array.isArray(params.reservedTicket.ticketType.category.ids)) {
409
- // andConditions.push(
410
- // {
411
- // 'reservedTicket.ticketType.category.id': {
412
- // $exists: true,
413
- // $in: params.reservedTicket.ticketType.category.ids
414
- // }
415
- // }
416
- // );
417
- // }
418
- // /* istanbul ignore else */
419
- // if (params.reservedTicket.ticketType.category.codeValue !== undefined
420
- // && params.reservedTicket.ticketType.category !== null) {
421
- // if (Array.isArray(params.reservedTicket.ticketType.category.codeValue.$in)) {
422
- // andConditions.push(
423
- // {
424
- // 'reservedTicket.ticketType.category.codeValue': {
425
- // $exists: true,
426
- // $in: params.reservedTicket.ticketType.category.codeValue.$in
427
- // }
428
- // }
429
- // );
430
- // }
431
- // }
432
- // }
433
- }
393
+ // discontinue ticketType(2026-05-06~)
394
+ // /* istanbul ignore else */
395
+ // if (params.reservedTicket.ticketType !== undefined) {
396
+ // /* istanbul ignore else */
397
+ // if (Array.isArray(params.reservedTicket.ticketType.ids)) {
398
+ // andConditions.push(
399
+ // {
400
+ // 'reservedTicket.ticketType.id': {
401
+ // $exists: true,
402
+ // $in: params.reservedTicket.ticketType.ids
403
+ // }
404
+ // }
405
+ // );
406
+ // }
407
+ // }
434
408
  /* istanbul ignore else */
435
409
  if (params.reservedTicket.ticketedSeat !== undefined) {
436
410
  /* istanbul ignore else */
@@ -125,48 +125,39 @@ function aggregateOfferByEvent(params) {
125
125
  function aggregateReservationByOffer(params) {
126
126
  return async (repos) => {
127
127
  let reservationCount4offer;
128
- // let attendeeCount4offer: number | undefined;
129
- // let checkInCount4offer: number | undefined;
130
128
  const reservationType = factory_1.factory.reservationType.EventReservation;
131
129
  const offerIdsWithSameCategory = params.availableOffers.filter(({ category }) => {
132
130
  return typeof category?.codeValue === 'string' && category.codeValue === params.offer.category?.codeValue;
133
131
  })
134
132
  .map(({ id }) => id);
135
133
  if (offerIdsWithSameCategory.length > 0) {
136
- reservationCount4offer = await repos.reservation.count({
137
- typeOf: reservationType,
138
- reservationFor: { id: { $eq: params.event.id } },
139
- reservationStatuses: [factory_1.factory.reservationStatusType.ReservationConfirmed],
140
- // オファーカテゴリーごとに集計する(2024-11-10~)
141
- // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } }
142
- reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } }
143
- });
144
- // attendeeCount4offer = await repos.reservation.count({
134
+ // オファーIDによる集計を座席区分(オファーの適用座席区分を参照)による集計に変更(2026-05-05~)
135
+ // reservationCount4offer = await repos.reservation.count({
145
136
  // typeOf: reservationType,
146
137
  // reservationFor: { id: { $eq: params.event.id } },
147
138
  // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
148
- // // オファーカテゴリーごとに集計する(2024-11-10~)
149
- // // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
150
- // reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
151
- // attended: true
152
- // });
153
- // checkInCount4offer = await repos.reservation.count({
154
- // typeOf: reservationType,
155
- // reservationFor: { id: { $eq: params.event.id } },
156
- // reservationStatuses: [factory.reservationStatusType.ReservationConfirmed],
157
- // // オファーカテゴリーごとに集計する(2024-11-10~)
158
- // // reservedTicket: { ticketType: { ids: [<string>params.offer.id] } },
159
- // reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } },
160
- // checkedIn: true
139
+ // reservedTicket: { ticketType: { ids: offerIdsWithSameCategory } }
161
140
  // });
141
+ const aggregateSeatingType = params.offer.eligibleSeatingType?.at(0)?.codeValue;
142
+ if (typeof aggregateSeatingType === 'string') {
143
+ reservationCount4offer = await repos.reservation.count({
144
+ typeOf: reservationType,
145
+ reservationFor: { id: { $eq: params.event.id } },
146
+ reservationStatuses: [factory_1.factory.reservationStatusType.ReservationConfirmed],
147
+ reservedTicket: {
148
+ ticketedSeat: {
149
+ seatingType: { $in: [aggregateSeatingType] }
150
+ }
151
+ }
152
+ });
153
+ console.log('aggregateReservationByOffer: reservationCount4offer:', reservationCount4offer, 'aggregateSeatingType:', aggregateSeatingType, 'offer.id:', params.offer.id, 'offer.category:', params.offer.category?.codeValue);
154
+ }
162
155
  }
163
156
  const { maximumAttendeeCapacity, remainingAttendeeCapacity } = await calculateCapacityByOffer(params)(repos);
164
157
  return {
165
158
  aggregateReservation: {
166
159
  typeOf: 'AggregateReservation',
167
160
  reservationCount: reservationCount4offer
168
- // attendeeCount: attendeeCount4offer, // discontinue(2024-11-10~)
169
- // checkInCount: checkInCount4offer // discontinue(2024-11-10~)
170
161
  },
171
162
  ...(typeof maximumAttendeeCapacity === 'number') ? { maximumAttendeeCapacity } : undefined,
172
163
  ...(typeof remainingAttendeeCapacity === 'number') ? { remainingAttendeeCapacity } : undefined
@@ -20,7 +20,7 @@ export declare function useReservation(params: {
20
20
  */
21
21
  id: string;
22
22
  };
23
- instrument?: Pick<factory.action.consume.use.reservation.ITicketAsInstrument, 'ticketToken'> | factory.action.consume.use.reservation.IInstrument[];
23
+ instrument?: factory.action.consume.use.reservation.IInstrument[];
24
24
  location?: {
25
25
  identifier?: string;
26
26
  };
@@ -16,7 +16,6 @@ function useReservation(params) {
16
16
  return async (repos) => {
17
17
  const reservationId = params.object.id;
18
18
  let ticketToken;
19
- // const ticketToken = params?.instrument?.ticketToken;
20
19
  if (Array.isArray(params.instrument)) {
21
20
  for (const eachInstrument of params.instrument) {
22
21
  if (eachInstrument.typeOf === 'Ticket' && typeof eachInstrument.ticketToken === 'string') {
@@ -24,9 +23,8 @@ function useReservation(params) {
24
23
  break;
25
24
  }
26
25
  }
27
- }
28
- else {
29
- ticketToken = params?.instrument?.ticketToken;
26
+ // } else {
27
+ // ticketToken = params?.instrument?.ticketToken;
30
28
  }
31
29
  // if (params.verifyToken === true) {} // タスク作成前に検証済なので検証不要
32
30
  // confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
@@ -34,36 +32,34 @@ function useReservation(params) {
34
32
  // 予約検索
35
33
  const reservation = await repos.reservation.findReservationById({
36
34
  id: reservationId,
37
- inclusion: ['issuedThrough', 'project', 'reservationFor', 'reservationNumber', 'reservedTicket', 'typeOf']
35
+ inclusion: [
36
+ // 'issuedThrough',
37
+ // 'reservedTicket',
38
+ 'project', 'reservationFor', 'reservationNumber', 'typeOf'
39
+ ]
38
40
  });
39
- if (typeof reservation.issuedThrough.id !== 'string') {
40
- // COA予約では予約使用アクションを想定していないので、興行idは必ず存在するはず
41
- throw new factory_1.factory.errors.Internal('reservation.issuedThrough.id must be string');
42
- }
43
- const { reservedTicket } = reservation;
44
- // optimize(2024-05-07~)
41
+ // if (typeof reservation.issuedThrough.id !== 'string') {
42
+ // // COA予約では予約使用アクションを想定していないので、興行idは必ず存在するはず
43
+ // throw new factory.errors.Internal('reservation.issuedThrough.id must be string');
44
+ // }
45
+ // const { reservedTicket } = reservation;
46
+ // optimize(2026-05-06~)
45
47
  const reservationAsObject = {
46
48
  id: reservation.id,
47
49
  reservationNumber: reservation.reservationNumber,
48
50
  typeOf: reservation.typeOf,
49
- issuedThrough: { id: reservation.issuedThrough.id, typeOf: reservation.issuedThrough.typeOf },
50
51
  reservationFor: { id: reservation.reservationFor.id, typeOf: reservation.reservationFor.typeOf },
51
- reservedTicket: {
52
- typeOf: reservedTicket.typeOf,
53
- // discontinue ticketType(2026-03-25~)
54
- // ticketType: {
55
- // identifier: reservedTicket.ticketType.identifier,
56
- // typeOf: reservedTicket.ticketType.typeOf,
57
- // ...(typeof reservedTicket.ticketType.id === 'string') ? { id: reservedTicket.ticketType.id } : undefined
58
- // },
59
- ...(typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined,
60
- ...(typeof reservedTicket.ticketedSeat?.typeOf === 'string') ? { ticketedSeat: reservedTicket.ticketedSeat } : undefined
61
- }
52
+ // discontinue issuedThrough,reservedTicket(2026-05-06~)
53
+ // issuedThrough: { id: reservation.issuedThrough.id, typeOf: reservation.issuedThrough.typeOf },
54
+ // reservedTicket: {
55
+ // typeOf: reservedTicket.typeOf,
56
+ // ...(typeof reservedTicket.identifier === 'string') ? { identifier: reservedTicket.identifier } : undefined,
57
+ // ...(typeof reservedTicket.ticketedSeat?.typeOf === 'string') ? { ticketedSeat: reservedTicket.ticketedSeat } : undefined
58
+ // }
62
59
  };
63
60
  // extend instrument to array(2025-02-18~)
64
61
  const instrument = [
65
62
  {
66
- // ...(typeof token === 'string') ? { token } : undefined, // discontinue token(2024-10-03~)
67
63
  ...(typeof ticketToken === 'string') ? { ticketToken } : undefined,
68
64
  typeOf: 'Ticket'
69
65
  },
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
+ const factory_1 = require("../../factory");
4
5
  const action_1 = require("../../repo/action");
5
6
  const assetTransaction_1 = require("../../repo/assetTransaction");
6
7
  const authorization_1 = require("../../repo/authorization");
@@ -20,16 +21,16 @@ function call(data) {
20
21
  instrument = data.instrument;
21
22
  }
22
23
  else {
23
- if (data.instrument?.typeOf === 'Ticket') {
24
- instrument = [data.instrument];
25
- }
24
+ throw new factory_1.factory.errors.NotImplemented('instrument as object discontinued');
25
+ // if (data.instrument?.typeOf === 'Ticket') {
26
+ // instrument = [data.instrument];
27
+ // }
26
28
  }
27
29
  await (0, useReservation_1.useReservation)({
28
30
  project: data.project,
29
31
  agent: data.agent,
30
32
  object: data.object,
31
33
  instrument,
32
- // ...(typeof data.instrument?.typeOf === 'string') ? { instrument: data.instrument } : undefined,
33
34
  ...(typeof data.location?.typeOf === 'string') ? { location: data.location } : undefined
34
35
  })({
35
36
  action: new action_1.ActionRepo(connection),
@@ -39,8 +40,6 @@ function call(data) {
39
40
  reservation: new reservation_1.ReservationRepo(connection),
40
41
  setting: new setting_1.SettingRepo(connection),
41
42
  task: new task_1.TaskRepo(connection)
42
- }
43
- // settings
44
- );
43
+ });
45
44
  };
46
45
  }
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.0",
14
+ "@chevre/factory": "8.1.0-alpha.1",
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.2"
94
+ "version": "24.1.0-alpha.4"
95
95
  }