@chevre/domain 22.9.0-alpha.110 → 22.9.0-alpha.111

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.
@@ -14,10 +14,13 @@ const today = moment()
14
14
  .format('YYYYMMDD');
15
15
  const project = { id: String(process.env.PROJECT_ID) };
16
16
  const eventId = `sampleEventId${today}:03`;
17
+ // const eventId = 'bma1pcxs0';
17
18
  const eventStartDate = new Date('2025-05-01T00:00:00Z');
18
- const seatSection = 'SampleSectionNameXXXXXXXXXXXXXXXXXXX';
19
+ // const seatSection = 'SampleSectionNameXXXXXXXXXXXXXXXXXXX';
20
+ const seatSection = 'Default';
19
21
  // tslint:disable-next-line:no-magic-numbers prefer-array-literal
20
22
  const allSeatNumbers = [...Array(10000)].map((__, seatKey) => `SampleSeatNumber-${seatKey}`);
23
+ // const allSeatNumbers = [...Array(10000)].map((__, seatKey) => `A-${seatKey}`);
21
24
 
22
25
  const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
23
26
  socket: {
@@ -8,6 +8,7 @@ const today = moment()
8
8
  .tz('Asia/Tokyo')
9
9
  .format('YYYYMMDD');
10
10
  const project = { id: String(process.env.PROJECT_ID) };
11
+ const providerId = 'sampleProviderId';
11
12
  const eventId = `sampleEventId${today}:03`;
12
13
  const eventStartDate = new Date('2025-05-01T00:00:00Z');
13
14
  const expires = moment(eventStartDate)
@@ -140,6 +141,7 @@ async function lockSeatsForcibly(params: {
140
141
  await stockHolderRepo.lockIfNotLimitExceeded(
141
142
  {
142
143
  project: { id: project.id },
144
+ provider: { id: providerId },
143
145
  eventId,
144
146
  startDate: eventStartDate,
145
147
  hasTicketedSeat: true,
@@ -160,6 +162,7 @@ async function lockSeatsForcibly(params: {
160
162
  } else {
161
163
  await stockHolderRepo.lock({
162
164
  project: { id: project.id },
165
+ provider: { id: providerId },
163
166
  eventId,
164
167
  startDate: eventStartDate,
165
168
  hasTicketedSeat: true,
@@ -19,8 +19,9 @@ async function main() {
19
19
  limit: 10,
20
20
  page: 1,
21
21
  project: { id: { $eq: project.id } },
22
- reservationFor: { id: { $eq: 'bma0cfbc6' } }
23
- // reservationNumber: { $eq: '3073981402299' }
22
+ reservationFor: { id: { $eq: 'bma31zpnv' } },
23
+ subReservation: { identifier: { $eq: 'Default:A-1' } },
24
+ reservationNumber: { $eq: '283714519921158' }
24
25
  });
25
26
  diff = process.hrtime(startTime);
26
27
  console.log('result:', result, result.length);
@@ -3,11 +3,19 @@ import * as factory from '../../../factory';
3
3
  interface ISubReservation {
4
4
  identifier: string;
5
5
  }
6
+ interface IProvider {
7
+ /**
8
+ * 販売者ID
9
+ */
10
+ id: string;
11
+ typeOf: factory.organizationType.Corporation;
12
+ }
6
13
  interface IReservationPackage {
7
14
  project: {
8
15
  id: string;
9
16
  typeOf: factory.organizationType.Project;
10
17
  };
18
+ provider: IProvider;
11
19
  typeOf: factory.reservationType.ReservationPackage;
12
20
  bookingTime: Date;
13
21
  dateCreated: Date;
@@ -9,6 +9,7 @@ const modelName = 'PendingReservation';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ provider: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
13
  typeOf: { type: String, required: true },
13
14
  numSeats: { type: Number, required: true },
14
15
  reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
@@ -60,6 +61,10 @@ const indexes = [
60
61
  { reservationNumber: 1, bookingTime: -1 },
61
62
  { name: 'reservationNumber' }
62
63
  ],
64
+ [
65
+ { 'subReservation.identifier': 1, bookingTime: -1 },
66
+ { name: 'subReservationIdentifier' }
67
+ ],
63
68
  [
64
69
  { reservationNumber: 1 },
65
70
  {
@@ -1,6 +1,33 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import { IReservationPackage } from './mongoose/schemas/pendingReservation';
3
3
  import { AbstractStockHolderRepo, IGetHolderResult, ILockKey, IOffer, IUnlockKey } from './stockHolderAbstract';
4
+ interface ISearchConditions {
5
+ limit?: number;
6
+ page?: number;
7
+ project?: {
8
+ id?: {
9
+ $eq?: string;
10
+ };
11
+ };
12
+ provider?: {
13
+ id?: {
14
+ $eq?: string;
15
+ };
16
+ };
17
+ reservationFor?: {
18
+ id?: {
19
+ $eq?: string;
20
+ };
21
+ };
22
+ reservationNumber?: {
23
+ $eq?: string;
24
+ };
25
+ subReservation?: {
26
+ identifier?: {
27
+ $eq?: string;
28
+ };
29
+ };
30
+ }
4
31
  type IProjectFieldResult = Pick<IReservationPackage, 'bookingTime' | 'numSeats' | 'dateCreated' | 'dateModified' | 'expires' | 'reservationFor' | 'reservationNumber' | 'typeOf'>;
5
32
  /**
6
33
  * 保留予約リポジトリ
@@ -44,23 +71,7 @@ export declare class PendingReservationRepo implements AbstractStockHolderRepo {
44
71
  $lte: Date;
45
72
  };
46
73
  }): Promise<import("mongodb").DeleteResult>;
47
- projectFields(params: {
48
- limit?: number;
49
- page?: number;
50
- project?: {
51
- id?: {
52
- $eq?: string;
53
- };
54
- };
55
- reservationFor?: {
56
- id?: {
57
- $eq?: string;
58
- };
59
- };
60
- reservationNumber?: {
61
- $eq?: string;
62
- };
63
- }): Promise<IProjectFieldResult[]>;
74
+ projectFields(params: ISearchConditions): Promise<IProjectFieldResult[]>;
64
75
  private aggregateNumSeats;
65
76
  private createReservationPackageIfPossible;
66
77
  private deleteReservationPackage;
@@ -78,6 +78,7 @@ class PendingReservationRepo {
78
78
  });
79
79
  return {
80
80
  project: { id: lockKey.project.id, typeOf: factory.organizationType.Project },
81
+ provider: { id: lockKey.provider.id, typeOf: factory.organizationType.Corporation },
81
82
  typeOf: factory.reservationType.ReservationPackage,
82
83
  bookingTime,
83
84
  expires,
@@ -232,7 +233,8 @@ class PendingReservationRepo {
232
233
  },
233
234
  {
234
235
  $match: {
235
- 'subReservation.identifier': { $exists: true, $in: reservationIdentifiers }
236
+ // 'subReservation.identifier': { $exists: true, $in: reservationIdentifiers }
237
+ 'subReservation.identifier': { $in: reservationIdentifiers } // $exists不要か?
236
238
  }
237
239
  }, // unwind後にもmatchがないと、reservationIdentifiers以外のsubReservationもprojectされる
238
240
  {
@@ -372,7 +374,7 @@ class PendingReservationRepo {
372
374
  }
373
375
  projectFields(params) {
374
376
  return __awaiter(this, void 0, void 0, function* () {
375
- var _a, _b, _c, _d, _e;
377
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
376
378
  const { limit, page } = params;
377
379
  const filterQueries = [
378
380
  // { numSeats: { $gte: 1 } }
@@ -381,14 +383,22 @@ class PendingReservationRepo {
381
383
  if (typeof projectIdEq === 'string') {
382
384
  filterQueries.push({ 'project.id': { $eq: projectIdEq } });
383
385
  }
384
- const reservationForIdEq = (_d = (_c = params.reservationFor) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
386
+ const providerIdEq = (_d = (_c = params.provider) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
387
+ if (typeof providerIdEq === 'string') {
388
+ filterQueries.push({ 'provider.id': { $eq: providerIdEq } });
389
+ }
390
+ const reservationForIdEq = (_f = (_e = params.reservationFor) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
385
391
  if (typeof reservationForIdEq === 'string') {
386
392
  filterQueries.push({ 'reservationFor.id': { $eq: reservationForIdEq } });
387
393
  }
388
- const reservationNumberEq = (_e = params.reservationNumber) === null || _e === void 0 ? void 0 : _e.$eq;
394
+ const reservationNumberEq = (_g = params.reservationNumber) === null || _g === void 0 ? void 0 : _g.$eq;
389
395
  if (typeof reservationNumberEq === 'string') {
390
396
  filterQueries.push({ reservationNumber: { $eq: reservationNumberEq } });
391
397
  }
398
+ const subReservationIdentifierEq = (_j = (_h = params.subReservation) === null || _h === void 0 ? void 0 : _h.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
399
+ if (typeof subReservationIdentifierEq === 'string') {
400
+ filterQueries.push({ 'subReservation.identifier': { $eq: subReservationIdentifierEq } });
401
+ }
392
402
  const matchStage = (filterQueries.length > 0) ? { $match: { $and: filterQueries } } : undefined;
393
403
  let limitStage;
394
404
  let skipStage;
@@ -14,6 +14,13 @@ export interface ILockKey {
14
14
  project: {
15
15
  id: string;
16
16
  };
17
+ /**
18
+ * required(2025-04-30~)
19
+ * = event.organizer.id
20
+ */
21
+ provider: {
22
+ id: string;
23
+ };
17
24
  eventId: string;
18
25
  startDate: Date;
19
26
  hasTicketedSeat: boolean;
@@ -551,6 +551,7 @@ function processLockSeats(params) {
551
551
  if (typeof maximumAttendeeCapacity4event === 'number') {
552
552
  yield repos.stockHolder.lockIfNotLimitExceeded({
553
553
  project: { id: params.event.project.id },
554
+ provider: { id: params.event.organizer.id },
554
555
  eventId: params.event.id,
555
556
  startDate: moment(params.event.startDate)
556
557
  .toDate(),
@@ -564,6 +565,7 @@ function processLockSeats(params) {
564
565
  else {
565
566
  yield repos.stockHolder.lock({
566
567
  project: { id: params.event.project.id },
568
+ provider: { id: params.event.organizer.id },
567
569
  eventId: params.event.id,
568
570
  startDate: moment(params.event.startDate)
569
571
  .toDate(),
package/package.json CHANGED
@@ -113,5 +113,5 @@
113
113
  "postversion": "git push origin --tags",
114
114
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
115
115
  },
116
- "version": "22.9.0-alpha.110"
116
+ "version": "22.9.0-alpha.111"
117
117
  }