@chevre/domain 21.4.0-alpha.30 → 21.4.0-alpha.32

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.
@@ -7,7 +7,7 @@ import { chevre } from '../../../../lib/index';
7
7
  const memberId = String(process.env.MEMBER_ID);
8
8
 
9
9
  async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
11
11
 
12
12
  const memberRepo = new chevre.repository.Member(mongoose.connection);
13
13
 
@@ -8,7 +8,7 @@ import { chevre } from '../../../lib/index';
8
8
  const project = { id: String(process.env.PROJECT_ID) };
9
9
 
10
10
  async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
12
 
13
13
  const actionRepo = new chevre.repository.Action(mongoose.connection);
14
14
  const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
@@ -21,10 +21,11 @@ async function main() {
21
21
  id: project.id,
22
22
  typeOf: chevre.factory.organizationType.Project
23
23
  },
24
- locationBranchCode: '018',
25
- importFrom: moment('2023-05-17T02:45:00.214Z')
24
+ locationBranchCode: '022',
25
+ importFrom: moment()
26
26
  .toDate(),
27
- importThrough: moment('2023-05-20T02:45:00.214Z')
27
+ importThrough: moment()
28
+ .add(1, 'day')
28
29
  .toDate(),
29
30
  saveMovieTheater: false,
30
31
  saveScreeningEventSeries: false
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
9
9
 
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  const eventRepo = new chevre.repository.Event(mongoose.connection);
15
15
  const placeRepo = new chevre.repository.Place(mongoose.connection);
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
9
9
 
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  const memberRepo = new chevre.repository.Member(mongoose.connection);
15
15
 
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
9
9
 
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  const placeRepo = new chevre.repository.Place(mongoose.connection);
15
15
 
@@ -6,7 +6,7 @@ import * as mongoose from 'mongoose';
6
6
  // const project = { id: String(process.env.PROJECT_ID) };
7
7
 
8
8
  async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
10
 
11
11
  const actionRepo = new chevre.repository.Action(mongoose.connection);
12
12
  const actions = await actionRepo.search(
@@ -242,7 +242,8 @@ class MongoRepository {
242
242
  return __awaiter(this, void 0, void 0, function* () {
243
243
  const doc = yield this.memberModel.findOneAndUpdate({
244
244
  'project.id': { $eq: params.project.id },
245
- 'member.id': { $eq: params.member.id }
245
+ 'member.id': { $eq: params.member.id },
246
+ 'member.memberOf': { $exists: false }
246
247
  }, {
247
248
  'member.memberOf': params.member.memberOf
248
249
  })
@@ -50,8 +50,16 @@ exports.schema = schema;
50
50
  schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
51
51
  schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
52
52
  schema.index({ 'member.id': 1 }, { name: 'searchByMemberId' });
53
- schema.index({ 'project.id': 1, 'member.id': 1 }, {
54
- name: 'uniqueProjectMember',
53
+ // uniqueIndex再設定(2023-07-25~)
54
+ // schema.index(
55
+ // { 'project.id': 1, 'member.id': 1 },
56
+ // {
57
+ // name: 'uniqueProjectMember',
58
+ // unique: true
59
+ // }
60
+ // );
61
+ schema.index({ 'project.id': 1, 'member.id': 1, 'member.memberOf.id': 1 }, {
62
+ name: 'uniqueIAMMember',
55
63
  unique: true
56
64
  });
57
65
  schema.index({ 'member.typeOf': 1, 'member.id': 1 }, {
@@ -85,10 +85,8 @@ export declare class StockHolderRepository {
85
85
  static KEY_PREFIX_NEW: string;
86
86
  static KEY_PREFIX: string;
87
87
  private readonly redisClient;
88
- private readonly holdReservationModel;
89
- constructor(redisClient: RedisClientType, connection: Connection);
88
+ constructor(redisClient: RedisClientType, __: Connection);
90
89
  private static offer2field;
91
- private static offer2subReservation;
92
90
  private static createKey;
93
91
  /**
94
92
  * 新リポジトリを使用するかどうか
@@ -101,12 +99,7 @@ export declare class StockHolderRepository {
101
99
  /**
102
100
  * 座席をロックする
103
101
  */
104
- lock(lockKey: ILockKey & {
105
- /**
106
- * テスト目的の強制オプション
107
- */
108
- useMongooseForcibly?: boolean;
109
- }): Promise<void>;
102
+ lock(lockKey: ILockKey & {}): Promise<void>;
110
103
  /**
111
104
  * 座席ロックを解除する
112
105
  */
@@ -128,10 +121,6 @@ export declare class StockHolderRepository {
128
121
  * 保持者を取得する
129
122
  */
130
123
  getHolder(params: Omit<IUnlockKey, 'holder'>): Promise<string | null | undefined>;
131
- /**
132
- * 在庫状況を検索する
133
- * offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
134
- */
135
124
  searchHolders(params: {
136
125
  project: {
137
126
  id: string;
@@ -144,72 +133,8 @@ export declare class StockHolderRepository {
144
133
  /**
145
134
  * 汎用的な検索(mongooseのみ対応)
146
135
  */
147
- search(params: {
148
- limit?: number;
149
- page?: number;
150
- sort?: {
151
- 'reservationFor.startDate': factory.sortType;
152
- };
153
- project?: {
154
- id?: {
155
- $eq?: string;
156
- };
157
- };
158
- reservationFor?: {
159
- id?: {
160
- $eq?: string;
161
- };
162
- };
163
- reservationNumber?: {
164
- $eq?: string;
165
- };
166
- id?: {
167
- $eq?: string;
168
- };
169
- identifier?: {
170
- $eq?: string;
171
- };
172
- reservedTicket?: {
173
- ticketedSeat?: {
174
- seatNumber?: {
175
- $eq?: string;
176
- };
177
- seatSection?: {
178
- $eq?: string;
179
- };
180
- };
181
- };
182
- }): Promise<ISearchResult[]>;
183
136
  /**
184
137
  * 汎用的な集計(mongooseのみ対応)
185
138
  */
186
- aggregateByReservationFor(params: {
187
- limit?: number;
188
- page?: number;
189
- project?: {
190
- id?: {
191
- $eq?: string;
192
- };
193
- };
194
- reservationFor?: {
195
- id?: {
196
- $eq?: string;
197
- };
198
- };
199
- }): Promise<{
200
- typeOf: 'AggregateReservation';
201
- reservationCount: number;
202
- reservationFor: {
203
- id: string;
204
- startDate: Date;
205
- };
206
- reservationPackageCount: number;
207
- objectSize: number;
208
- }[]>;
209
139
  private checkIfConflicted;
210
- private initializeHoldReservation;
211
- /**
212
- * 仮で追加したholdReservationsが重複していないかどうか検証する
213
- */
214
- private checkIfAlreadyInUse;
215
140
  }
@@ -12,18 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.StockHolderRepository = void 0;
13
13
  const createDebug = require("debug");
14
14
  const moment = require("moment");
15
- const mongoose_1 = require("mongoose");
16
15
  const factory = require("../factory");
17
- const holdReservation_1 = require("./mongoose/schemas/holdReservation");
18
16
  const settings_1 = require("../settings");
19
17
  const debug = createDebug('chevre-domain:repo:stockHolder');
20
18
  /**
21
19
  * イベントストックホルダーリポジトリ
22
20
  */
23
21
  class StockHolderRepository {
24
- constructor(redisClient, connection) {
22
+ constructor(redisClient, __) {
25
23
  this.redisClient = redisClient;
26
- this.holdReservationModel = connection.model(holdReservation_1.modelName, holdReservation_1.schema);
27
24
  }
28
25
  static offer2field(params, hasTicketedSeat) {
29
26
  var _a, _b;
@@ -41,32 +38,29 @@ class StockHolderRepository {
41
38
  }
42
39
  }
43
40
  }
44
- static offer2subReservation(params, hasTicketedSeat) {
45
- var _a, _b;
46
- if (hasTicketedSeat) {
47
- return {
48
- identifier: `${params.seatSection}:${params.seatNumber}`,
49
- reservedTicket: {
50
- ticketedSeat: {
51
- seatSection: params.seatSection,
52
- seatNumber: params.seatNumber
53
- }
54
- }
55
- };
56
- }
57
- else {
58
- const serviceOutputId = (_b = (_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.id;
59
- if (typeof serviceOutputId === 'string') {
60
- return {
61
- id: serviceOutputId,
62
- identifier: serviceOutputId
63
- };
64
- }
65
- else {
66
- throw new factory.errors.ServiceUnavailable('offer2subReservation requires itemOffered.serviceOutput.id');
67
- }
68
- }
69
- }
41
+ // private static offer2subReservation(params: IOffer, hasTicketedSeat: boolean): ISubReservation {
42
+ // if (hasTicketedSeat) {
43
+ // return {
44
+ // identifier: `${params.seatSection}:${params.seatNumber}`,
45
+ // reservedTicket: {
46
+ // ticketedSeat: {
47
+ // seatSection: params.seatSection,
48
+ // seatNumber: params.seatNumber
49
+ // }
50
+ // }
51
+ // };
52
+ // } else {
53
+ // const serviceOutputId = params.itemOffered?.serviceOutput?.id;
54
+ // if (typeof serviceOutputId === 'string') {
55
+ // return {
56
+ // id: serviceOutputId,
57
+ // identifier: serviceOutputId
58
+ // };
59
+ // } else {
60
+ // throw new factory.errors.ServiceUnavailable('offer2subReservation requires itemOffered.serviceOutput.id');
61
+ // }
62
+ // }
63
+ // }
70
64
  static createKey(params) {
71
65
  if (!(params.startDate instanceof Date)) {
72
66
  throw new factory.errors.Argument('startDate', 'must be Date');
@@ -87,20 +81,6 @@ class StockHolderRepository {
87
81
  if (!(params.startDate instanceof Date)) {
88
82
  throw new factory.errors.Argument('startDate', 'must be Date');
89
83
  }
90
- if (params.useMongooseForcibly === true) {
91
- return true;
92
- }
93
- // USE_NEW_STOCK_HOLDER_REPO_IDSに含まれれば強制的に使用
94
- if (settings_1.USE_NEW_STOCK_HOLDER_REPO_IDS.includes(params.eventId)) {
95
- return true;
96
- }
97
- // 座席有の場合のみ、USE_NEW_STOCK_HOLDER_REPO_FROMを検証
98
- if (params.hasTicketedSeat) {
99
- if (moment(params.startDate)
100
- .isSameOrAfter(settings_1.USE_NEW_STOCK_HOLDER_REPO_FROM)) {
101
- return true;
102
- }
103
- }
104
84
  return false;
105
85
  }
106
86
  /**
@@ -114,41 +94,7 @@ class StockHolderRepository {
114
94
  hasTicketedSeat: lockKey.hasTicketedSeat
115
95
  });
116
96
  if (useMongoose) {
117
- if (!(lockKey.expires instanceof Date)) {
118
- throw new factory.errors.Argument('expires', 'must be Date');
119
- }
120
- yield this.checkIfConflicted({ key: '', eventId: lockKey.eventId, useMongoose });
121
- // reservationCount<=nであれば$push+$incする
122
- const { id } = yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
123
- const addedReservationCount = lockKey.offers.length;
124
- const reservationCountLte = maximum - addedReservationCount;
125
- const subReservations = lockKey.offers.map((offer) => StockHolderRepository.offer2subReservation(offer, lockKey.hasTicketedSeat));
126
- const reservationPackage = {
127
- // typeOf: factory.reservationType.ReservationPackage,
128
- reservationNumber: lockKey.holder,
129
- subReservation: subReservations
130
- };
131
- yield this.holdReservationModel.findOneAndUpdate({
132
- _id: { $eq: id },
133
- reservationCount: { $lte: reservationCountLte }
134
- // 'reservationFor.id': { $eq: lockKey.eventId },
135
- // 座席有無に関わらずsubReservation.identifierはuniqueであるはず
136
- // 'reservations.subReservation.identifier': {
137
- // $nin: subReservations.map((r) => r.identifier)
138
- // }
139
- }, {
140
- $inc: { reservationCount: addedReservationCount },
141
- $push: { reservations: reservationPackage }
142
- }, { new: true })
143
- .select({ _id: 1 })
144
- .exec()
145
- .then((doc) => {
146
- if (doc === null) {
147
- throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
148
- }
149
- });
150
- // 重複検証
151
- yield this.checkIfAlreadyInUse({ reservationPackage, id });
97
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
152
98
  }
153
99
  else {
154
100
  const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
@@ -176,34 +122,12 @@ class StockHolderRepository {
176
122
  const useMongoose = StockHolderRepository.useMongoose({
177
123
  eventId: lockKey.eventId,
178
124
  startDate: lockKey.startDate,
179
- useMongooseForcibly: lockKey.useMongooseForcibly,
180
125
  hasTicketedSeat: lockKey.hasTicketedSeat
181
126
  });
182
127
  const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
183
128
  yield this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
184
129
  if (useMongoose) {
185
- const { id } = yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
186
- const addedReservationCount = lockKey.offers.length;
187
- const subReservations = lockKey.offers.map((offer) => StockHolderRepository.offer2subReservation(offer, lockKey.hasTicketedSeat));
188
- const reservationPackage = {
189
- // typeOf: factory.reservationType.ReservationPackage,
190
- reservationNumber: lockKey.holder,
191
- subReservation: subReservations
192
- };
193
- yield this.holdReservationModel.updateOne({
194
- _id: { $eq: id }
195
- // 'reservationFor.id': { $eq: lockKey.eventId },
196
- // 座席有無に関わらずsubReservation.identifierはuniqueであるはず
197
- // 'reservations.subReservation.identifier': {
198
- // $nin: subReservations.map((r) => r.identifier)
199
- // }
200
- }, {
201
- $inc: { reservationCount: addedReservationCount },
202
- $push: { reservations: reservationPackage }
203
- })
204
- .exec();
205
- // 重複検証
206
- yield this.checkIfAlreadyInUse({ reservationPackage, id });
130
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
207
131
  }
208
132
  else {
209
133
  const value = lockKey.holder;
@@ -260,47 +184,7 @@ class StockHolderRepository {
260
184
  const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
261
185
  yield this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
262
186
  if (useMongoose) {
263
- // [id]あるいは[seatNumber+seatSection]でreservations.subReservationsから$pull+$incする
264
- const { id } = yield this.initializeHoldReservation({ project: params.project, eventId: params.eventId, startDate: params.startDate });
265
- const subReservation = StockHolderRepository.offer2subReservation(params.offer, params.hasTicketedSeat);
266
- const reservationNumber = params.holder;
267
- const updateResult = yield this.holdReservationModel.updateOne({
268
- _id: { $eq: id },
269
- // 'reservationFor.id': { $eq: params.eventId },
270
- 'reservations.reservationNumber': {
271
- $exists: true,
272
- $eq: reservationNumber
273
- },
274
- 'reservations.subReservation.identifier': {
275
- $exists: true,
276
- $eq: subReservation.identifier
277
- }
278
- }, {
279
- $inc: { reservationCount: -1 },
280
- $pull: { 'reservations.$[reservationPackage].subReservation': { identifier: { $eq: subReservation.identifier } } }
281
- }, {
282
- arrayFilters: [
283
- { 'reservationPackage.reservationNumber': reservationNumber }
284
- ]
285
- })
286
- .exec();
287
- // docが存在しなくてもよい
288
- debug('unlock processed. updateResult:', updateResult, 'reservationNumber:', reservationNumber, 'identifier:', subReservation.identifier);
289
- // subReservationがemptyのreservationsをpull
290
- const pullReservationPackageResult = yield this.holdReservationModel.updateOne({
291
- _id: { $eq: id },
292
- // 'reservationFor.id': { $eq: params.eventId },
293
- 'reservations.reservationNumber': { $exists: true, $eq: reservationNumber }
294
- }, {
295
- $pull: {
296
- reservations: {
297
- reservationNumber: { $eq: reservationNumber },
298
- subReservation: { $size: 0 }
299
- }
300
- }
301
- })
302
- .exec();
303
- debug('unlock processed. pullReservationPackageResult:', pullReservationPackageResult, 'reservationNumber:', reservationNumber, 'identifier:', subReservation.identifier);
187
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
304
188
  }
305
189
  else {
306
190
  const field = StockHolderRepository.offer2field(params.offer, params.hasTicketedSeat);
@@ -337,20 +221,7 @@ class StockHolderRepository {
337
221
  startDate: params.event.startDate,
338
222
  hasTicketedSeat: params.event.hasTicketedSeat
339
223
  })) {
340
- // reservationCountを返す
341
- return this.holdReservationModel.findOne({
342
- 'reservationFor.id': { $eq: params.event.id }
343
- })
344
- .select({ reservationCount: 1 })
345
- .exec()
346
- .then((doc) => {
347
- if (doc === null) {
348
- return 0;
349
- }
350
- else {
351
- return doc.reservationCount;
352
- }
353
- });
224
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
354
225
  }
355
226
  else {
356
227
  const key = StockHolderRepository.createKey({ eventId: params.event.id, startDate: params.event.startDate });
@@ -367,48 +238,13 @@ class StockHolderRepository {
367
238
  * 保持者を取得する
368
239
  */
369
240
  getHolder(params) {
370
- var _a;
371
241
  return __awaiter(this, void 0, void 0, function* () {
372
242
  if (StockHolderRepository.useMongoose({
373
243
  eventId: params.eventId,
374
244
  startDate: params.startDate,
375
245
  hasTicketedSeat: params.hasTicketedSeat
376
246
  })) {
377
- // [id]あるいは[seatNumber+seatSection]でreservationNumberを返す
378
- const subReservation = StockHolderRepository.offer2subReservation(params.offer, params.hasTicketedSeat);
379
- const matchStages = [
380
- {
381
- $match: { 'reservationFor.id': { $eq: params.eventId } }
382
- },
383
- {
384
- $match: {
385
- 'reservations.subReservation.identifier': {
386
- $exists: true,
387
- $eq: subReservation.identifier
388
- }
389
- }
390
- }
391
- ];
392
- const aggregate = this.holdReservationModel.aggregate([
393
- { $unwind: '$reservations' },
394
- { $unwind: '$reservations.subReservation' },
395
- ...matchStages,
396
- {
397
- $project: {
398
- _id: 0,
399
- reservationNumber: '$reservations.reservationNumber',
400
- identifier: '$reservations.subReservation.identifier'
401
- }
402
- }
403
- ]);
404
- const subReservations = yield aggregate.exec();
405
- debug('getHolder found subReservations.', subReservation.identifier, subReservations);
406
- if (subReservations.length > 0) {
407
- return String((_a = subReservations.shift()) === null || _a === void 0 ? void 0 : _a.reservationNumber);
408
- }
409
- else {
410
- return;
411
- }
247
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
412
248
  }
413
249
  else {
414
250
  const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
@@ -417,38 +253,6 @@ class StockHolderRepository {
417
253
  }
418
254
  });
419
255
  }
420
- /**
421
- * 在庫状況を検索する
422
- * offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
423
- */
424
- // public async searchAvailability(params: {
425
- // eventId: string;
426
- // startDate: Date;
427
- // offers: IOffer[];
428
- // }): Promise<{
429
- // seatSection: string;
430
- // seatNumber: string;
431
- // availability: factory.itemAvailability;
432
- // }[]> {
433
- // const key = RedisRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
434
- // const fields = params.offers.map((o) => {
435
- // return RedisRepository.offer2field(o);
436
- // });
437
- // // Array reply: list of values associated with the given fields, in the same order as they are requested.
438
- // const result = await this.redisClient.hmGet(key, fields);
439
- // if (!Array.isArray(result)) {
440
- // throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
441
- // }
442
- // return params.offers.map((o, index) => {
443
- // const value4offer = result[index];
444
- // return {
445
- // ...o,
446
- // availability: (typeof value4offer === 'string')
447
- // ? factory.itemAvailability.OutOfStock // ホルダーが存在すればOutOfStock
448
- // : factory.itemAvailability.InStock
449
- // };
450
- // });
451
- // }
452
256
  searchHolders(params) {
453
257
  return __awaiter(this, void 0, void 0, function* () {
454
258
  if (StockHolderRepository.useMongoose({
@@ -456,41 +260,7 @@ class StockHolderRepository {
456
260
  startDate: params.startDate,
457
261
  hasTicketedSeat: params.hasTicketedSeat
458
262
  })) {
459
- // [id]あるいは[seatNumber+seatSection]のリストでreservationNumberのリストを返す
460
- const subReservations = params.offers.map((offer) => StockHolderRepository.offer2subReservation(offer, params.hasTicketedSeat));
461
- const matchStages = [
462
- {
463
- $match: { 'reservationFor.id': { $eq: params.eventId } }
464
- },
465
- {
466
- $match: {
467
- 'reservations.subReservation.identifier': {
468
- $exists: true,
469
- $in: subReservations.map((r) => r.identifier)
470
- }
471
- }
472
- }
473
- ];
474
- const aggregate = this.holdReservationModel.aggregate([
475
- { $unwind: '$reservations' },
476
- { $unwind: '$reservations.subReservation' },
477
- ...matchStages,
478
- {
479
- $project: {
480
- _id: 0,
481
- reservationNumber: '$reservations.reservationNumber',
482
- identifier: '$reservations.subReservation.identifier'
483
- }
484
- }
485
- ]);
486
- const subReservationsByDoc = yield aggregate.exec();
487
- return subReservations.map((subReservation) => {
488
- const subReservationByDoc = subReservationsByDoc.find((r) => r.identifier === subReservation.identifier);
489
- return (subReservationByDoc !== undefined)
490
- ? String(subReservationByDoc.reservationNumber)
491
- // tslint:disable-next-line:no-null-keyword
492
- : null;
493
- });
263
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
494
264
  }
495
265
  else {
496
266
  const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
@@ -535,165 +305,191 @@ class StockHolderRepository {
535
305
  * 汎用的な検索(mongooseのみ対応)
536
306
  */
537
307
  // tslint:disable-next-line:max-func-body-length
538
- search(params) {
539
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
540
- return __awaiter(this, void 0, void 0, function* () {
541
- const matchStages = [];
542
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
543
- if (typeof projectIdEq === 'string') {
544
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
545
- }
546
- const reservationForIdEq = (_d = (_c = params.reservationFor) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
547
- if (typeof reservationForIdEq === 'string') {
548
- matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
549
- }
550
- const reservationNumberEq = (_e = params.reservationNumber) === null || _e === void 0 ? void 0 : _e.$eq;
551
- if (typeof reservationNumberEq === 'string') {
552
- matchStages.push({ $match: { 'reservations.reservationNumber': { $exists: true, $eq: reservationNumberEq } } });
553
- }
554
- const identifierEq = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$eq;
555
- if (typeof identifierEq === 'string') {
556
- matchStages.push({ $match: { 'reservations.subReservation.identifier': { $exists: true, $eq: identifierEq } } });
557
- }
558
- const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
559
- if (typeof idEq === 'string') {
560
- matchStages.push({
561
- $match: { 'reservations.subReservation.id': { $exists: true, $eq: idEq } }
562
- });
563
- }
564
- const seatNumberEq = (_k = (_j = (_h = params.reservedTicket) === null || _h === void 0 ? void 0 : _h.ticketedSeat) === null || _j === void 0 ? void 0 : _j.seatNumber) === null || _k === void 0 ? void 0 : _k.$eq;
565
- if (typeof seatNumberEq === 'string') {
566
- matchStages.push({
567
- $match: {
568
- 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': {
569
- $exists: true,
570
- $eq: seatNumberEq
571
- }
572
- }
573
- });
574
- }
575
- const seatSectionEq = (_o = (_m = (_l = params.reservedTicket) === null || _l === void 0 ? void 0 : _l.ticketedSeat) === null || _m === void 0 ? void 0 : _m.seatSection) === null || _o === void 0 ? void 0 : _o.$eq;
576
- if (typeof seatSectionEq === 'string') {
577
- matchStages.push({
578
- $match: {
579
- 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': {
580
- $exists: true,
581
- $eq: seatSectionEq
582
- }
583
- }
584
- });
585
- }
586
- const aggregate = this.holdReservationModel.aggregate([
587
- ...(typeof ((_p = params.sort) === null || _p === void 0 ? void 0 : _p['reservationFor.startDate']) === 'number')
588
- ? [{ $sort: { 'reservationFor.startDate': params.sort['reservationFor.startDate'] } }]
589
- : [],
590
- {
591
- $unwind: {
592
- path: '$reservations',
593
- includeArrayIndex: 'reservationPackageIndex'
594
- }
595
- },
596
- {
597
- $unwind: {
598
- path: '$reservations.subReservation',
599
- includeArrayIndex: 'subReservationIndex'
600
- }
601
- },
602
- ...matchStages,
603
- {
604
- $project: {
605
- _id: 0,
606
- id: '$reservations.subReservation.id',
607
- identifier: '$reservations.subReservation.identifier',
608
- reservationFor: {
609
- id: '$reservationFor.id',
610
- startDate: '$reservationFor.startDate',
611
- aggregateReservation: {
612
- reservationCount: '$reservationCount'
613
- }
614
- },
615
- reservationNumber: '$reservations.reservationNumber',
616
- reservedTicket: '$reservations.subReservation.reservedTicket',
617
- objectSize: { $bsonSize: '$$ROOT' },
618
- reservationPackageIndex: '$reservationPackageIndex',
619
- subReservationIndex: '$subReservationIndex'
620
- }
621
- }
622
- ]);
623
- if (typeof params.limit === 'number' && params.limit > 0) {
624
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
625
- aggregate.limit(params.limit * page)
626
- .skip(params.limit * (page - 1));
627
- }
628
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
629
- .exec();
630
- });
631
- }
308
+ // public async search(params: {
309
+ // limit?: number;
310
+ // page?: number;
311
+ // sort?: { 'reservationFor.startDate': factory.sortType };
312
+ // project?: { id?: { $eq?: string } };
313
+ // reservationFor?: { id?: { $eq?: string } };
314
+ // reservationNumber?: { $eq?: string };
315
+ // id?: { $eq?: string };
316
+ // identifier?: { $eq?: string };
317
+ // reservedTicket?: {
318
+ // ticketedSeat?: {
319
+ // seatNumber?: { $eq?: string };
320
+ // seatSection?: { $eq?: string };
321
+ // };
322
+ // };
323
+ // }): Promise<ISearchResult[]> {
324
+ // const matchStages: IMatchStage[] = [];
325
+ // const projectIdEq = params.project?.id?.$eq;
326
+ // if (typeof projectIdEq === 'string') {
327
+ // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
328
+ // }
329
+ // const reservationForIdEq = params.reservationFor?.id?.$eq;
330
+ // if (typeof reservationForIdEq === 'string') {
331
+ // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
332
+ // }
333
+ // const reservationNumberEq = params.reservationNumber?.$eq;
334
+ // if (typeof reservationNumberEq === 'string') {
335
+ // matchStages.push({ $match: { 'reservations.reservationNumber': { $exists: true, $eq: reservationNumberEq } } });
336
+ // }
337
+ // const identifierEq = params.identifier?.$eq;
338
+ // if (typeof identifierEq === 'string') {
339
+ // matchStages.push({ $match: { 'reservations.subReservation.identifier': { $exists: true, $eq: identifierEq } } });
340
+ // }
341
+ // const idEq = params.id?.$eq;
342
+ // if (typeof idEq === 'string') {
343
+ // matchStages.push({
344
+ // $match: { 'reservations.subReservation.id': { $exists: true, $eq: idEq } }
345
+ // });
346
+ // }
347
+ // const seatNumberEq = params.reservedTicket?.ticketedSeat?.seatNumber?.$eq;
348
+ // if (typeof seatNumberEq === 'string') {
349
+ // matchStages.push({
350
+ // $match: {
351
+ // 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': {
352
+ // $exists: true,
353
+ // $eq: seatNumberEq
354
+ // }
355
+ // }
356
+ // });
357
+ // }
358
+ // const seatSectionEq = params.reservedTicket?.ticketedSeat?.seatSection?.$eq;
359
+ // if (typeof seatSectionEq === 'string') {
360
+ // matchStages.push({
361
+ // $match: {
362
+ // 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': {
363
+ // $exists: true,
364
+ // $eq: seatSectionEq
365
+ // }
366
+ // }
367
+ // });
368
+ // }
369
+ // const aggregate = this.holdReservationModel.aggregate([
370
+ // ...(typeof params.sort?.['reservationFor.startDate'] === 'number')
371
+ // ? [{ $sort: { 'reservationFor.startDate': params.sort['reservationFor.startDate'] } }]
372
+ // : [],
373
+ // {
374
+ // $unwind: {
375
+ // path: '$reservations',
376
+ // includeArrayIndex: 'reservationPackageIndex'
377
+ // }
378
+ // },
379
+ // {
380
+ // $unwind: {
381
+ // path: '$reservations.subReservation',
382
+ // includeArrayIndex: 'subReservationIndex'
383
+ // }
384
+ // },
385
+ // ...matchStages,
386
+ // {
387
+ // $project: {
388
+ // _id: 0,
389
+ // id: '$reservations.subReservation.id',
390
+ // identifier: '$reservations.subReservation.identifier',
391
+ // reservationFor: {
392
+ // id: '$reservationFor.id',
393
+ // startDate: '$reservationFor.startDate',
394
+ // aggregateReservation: {
395
+ // reservationCount: '$reservationCount'
396
+ // }
397
+ // },
398
+ // reservationNumber: '$reservations.reservationNumber',
399
+ // reservedTicket: '$reservations.subReservation.reservedTicket',
400
+ // objectSize: { $bsonSize: '$$ROOT' },
401
+ // reservationPackageIndex: '$reservationPackageIndex',
402
+ // subReservationIndex: '$subReservationIndex'
403
+ // }
404
+ // }
405
+ // ]);
406
+ // if (typeof params.limit === 'number' && params.limit > 0) {
407
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
408
+ // aggregate.limit(params.limit * page)
409
+ // .skip(params.limit * (page - 1));
410
+ // }
411
+ // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
412
+ // .exec();
413
+ // }
632
414
  /**
633
415
  * 汎用的な集計(mongooseのみ対応)
634
416
  */
635
- aggregateByReservationFor(params) {
636
- var _a, _b, _c, _d;
637
- return __awaiter(this, void 0, void 0, function* () {
638
- const matchStages = [];
639
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
640
- if (typeof projectIdEq === 'string') {
641
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
642
- }
643
- const reservationForIdEq = (_d = (_c = params.reservationFor) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
644
- if (typeof reservationForIdEq === 'string') {
645
- matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
646
- }
647
- const aggregate = this.holdReservationModel.aggregate([
648
- ...matchStages,
649
- {
650
- $project: {
651
- _id: 0,
652
- typeOf: '$typeOf',
653
- reservationCount: '$reservationCount',
654
- reservationFor: '$reservationFor',
655
- reservationPackageCount: { $size: '$reservations' },
656
- objectSize: { $bsonSize: '$$ROOT' }
657
- }
658
- }
659
- ]);
660
- if (typeof params.limit === 'number' && params.limit > 0) {
661
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
662
- aggregate.limit(params.limit * page)
663
- .skip(params.limit * (page - 1));
664
- }
665
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
666
- .exec();
667
- });
668
- }
417
+ // public async aggregateByReservationFor(params: {
418
+ // limit?: number;
419
+ // page?: number;
420
+ // project?: { id?: { $eq?: string } };
421
+ // reservationFor?: { id?: { $eq?: string } };
422
+ // }): Promise<{
423
+ // typeOf: 'AggregateReservation';
424
+ // reservationCount: number;
425
+ // reservationFor: {
426
+ // id: string;
427
+ // startDate: Date;
428
+ // };
429
+ // reservationPackageCount: number;
430
+ // objectSize: number;
431
+ // }[]> {
432
+ // const matchStages: IMatchStage[] = [];
433
+ // const projectIdEq = params.project?.id?.$eq;
434
+ // if (typeof projectIdEq === 'string') {
435
+ // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
436
+ // }
437
+ // const reservationForIdEq = params.reservationFor?.id?.$eq;
438
+ // if (typeof reservationForIdEq === 'string') {
439
+ // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
440
+ // }
441
+ // const aggregate = this.holdReservationModel.aggregate([
442
+ // ...matchStages,
443
+ // {
444
+ // $project: {
445
+ // _id: 0,
446
+ // typeOf: '$typeOf',
447
+ // reservationCount: '$reservationCount',
448
+ // reservationFor: '$reservationFor',
449
+ // reservationPackageCount: { $size: '$reservations' },
450
+ // objectSize: { $bsonSize: '$$ROOT' }
451
+ // }
452
+ // }
453
+ // ]);
454
+ // if (typeof params.limit === 'number' && params.limit > 0) {
455
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
456
+ // aggregate.limit(params.limit * page)
457
+ // .skip(params.limit * (page - 1));
458
+ // }
459
+ // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
460
+ // .exec();
461
+ // }
669
462
  checkIfConflicted(params) {
670
463
  return __awaiter(this, void 0, void 0, function* () {
671
464
  // 旧キーと新キーの両方存在検証(念のため)
672
465
  const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
673
466
  const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
674
467
  if (params.useMongoose) {
468
+ throw new factory.errors.NotImplemented('new stock holder repository not implemented');
675
469
  // newもoldも存在するはずがない
676
470
  // newの場合oldが存在するはずがない
677
- const existingOldKeyCount = yield this.redisClient.exists(oldKey);
678
- debug('existingOldKeyCount:', existingOldKeyCount);
679
- if (existingOldKeyCount > 0) {
680
- throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
681
- }
471
+ // const existingOldKeyCount = await this.redisClient.exists(oldKey);
472
+ // debug('existingOldKeyCount:', existingOldKeyCount);
473
+ // if (existingOldKeyCount > 0) {
474
+ // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
475
+ // }
682
476
  // oldの場合newが存在するはずがない
683
- const existingNewKeyCount = yield this.redisClient.exists(newKey);
684
- debug('existingNewKeyCount:', existingNewKeyCount);
685
- if (existingNewKeyCount > 0) {
686
- throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
687
- }
477
+ // const existingNewKeyCount = await this.redisClient.exists(newKey);
478
+ // debug('existingNewKeyCount:', existingNewKeyCount);
479
+ // if (existingNewKeyCount > 0) {
480
+ // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
481
+ // }
688
482
  }
689
483
  else {
690
484
  // collectionにdocumentが存在するはずがない
691
- const existingHoldReservationCount = yield this.holdReservationModel.count({ 'reservationFor.id': { $eq: params.eventId } })
692
- .exec();
693
- debug('existingHoldReservationCount:', existingHoldReservationCount);
694
- if (existingHoldReservationCount > 0) {
695
- throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
696
- }
485
+ // const existingHoldReservationCount = await this.holdReservationModel.count(
486
+ // { 'reservationFor.id': { $eq: params.eventId } }
487
+ // )
488
+ // .exec();
489
+ // debug('existingHoldReservationCount:', existingHoldReservationCount);
490
+ // if (existingHoldReservationCount > 0) {
491
+ // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
492
+ // }
697
493
  if (params.key !== oldKey) {
698
494
  // newの場合oldが存在するはずがない
699
495
  const existingOldKeyCount = yield this.redisClient.exists(oldKey);
@@ -713,78 +509,6 @@ class StockHolderRepository {
713
509
  }
714
510
  });
715
511
  }
716
- initializeHoldReservation(params) {
717
- return __awaiter(this, void 0, void 0, function* () {
718
- if (!(params.startDate instanceof Date)) {
719
- throw new factory.errors.Argument('startDate', 'must be Date');
720
- }
721
- const aggregateReservation = {
722
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
723
- typeOf: 'AggregateReservation',
724
- reservationCount: 0,
725
- reservationFor: {
726
- id: params.eventId,
727
- startDate: params.startDate
728
- },
729
- reservations: []
730
- };
731
- const initializedResult = yield this.holdReservationModel.findOneAndUpdate({ 'reservationFor.id': { $eq: params.eventId } }, {
732
- $setOnInsert: aggregateReservation
733
- }, { new: true, upsert: true })
734
- .select({ _id: 1 })
735
- .exec();
736
- debug('holdReservation initialized', initializedResult, params.eventId);
737
- return { id: initializedResult.id };
738
- });
739
- }
740
- /**
741
- * 仮で追加したholdReservationsが重複していないかどうか検証する
742
- */
743
- checkIfAlreadyInUse(params) {
744
- return __awaiter(this, void 0, void 0, function* () {
745
- const objectId = new mongoose_1.Types.ObjectId(params.id);
746
- const matchStages = [
747
- { $match: { _id: { $eq: objectId } } },
748
- {
749
- $match: {
750
- 'reservations.subReservation.identifier': {
751
- $exists: true,
752
- $in: params.reservationPackage.subReservation.map((r) => r.identifier)
753
- }
754
- }
755
- }
756
- ];
757
- const aggregate = this.holdReservationModel.aggregate([
758
- { $unwind: '$reservations' },
759
- { $unwind: '$reservations.subReservation' },
760
- ...matchStages,
761
- {
762
- $project: {
763
- _id: 0,
764
- reservationNumber: '$reservations.reservationNumber'
765
- }
766
- },
767
- {
768
- $group: {
769
- _id: '$reservationNumber'
770
- }
771
- }
772
- ]);
773
- const subReservationsByDoc = yield aggregate.exec();
774
- debug('checkIfAlreadyInUse:subReservationsByDoc:', subReservationsByDoc);
775
- if (subReservationsByDoc.length > 1) {
776
- // 仮追加したsubReservationsを削除
777
- debug('canceling hold reservationPackage...reservationNumber:', params.reservationPackage.reservationNumber);
778
- const updateOneResult = yield this.holdReservationModel.updateOne({ _id: { $eq: objectId } }, {
779
- $inc: { reservationCount: -params.reservationPackage.subReservation.length },
780
- $pull: { reservations: { reservationNumber: { $eq: params.reservationPackage.reservationNumber } } }
781
- })
782
- .exec();
783
- debug('hold reservationPackage canceled. reservationNumber:', params.reservationPackage.reservationNumber, updateOneResult);
784
- throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
785
- }
786
- });
787
- }
788
512
  }
789
513
  StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
790
514
  StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
@@ -39,8 +39,6 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
39
39
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
40
40
  export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
41
41
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
42
- export declare const USE_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment;
43
- export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
44
42
  export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
45
43
  export declare const MONGO_MAX_TIME_MS: number;
46
44
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -65,12 +65,12 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
65
65
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
66
66
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
67
67
  : moment('2023-08-31T15:00:00Z');
68
- exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
69
- ? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
70
- : moment('2024-11-30T15:00:00Z');
71
- exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
72
- ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
73
- : [];
68
+ // export const USE_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
69
+ // ? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
70
+ // : moment('2024-11-30T15:00:00Z');
71
+ // export const USE_NEW_STOCK_HOLDER_REPO_IDS: string[] = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
72
+ // ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
73
+ // : [];
74
74
  exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
75
75
  ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
76
76
  : 0;
package/package.json CHANGED
@@ -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.4.0-alpha.30"
120
+ "version": "21.4.0-alpha.32"
121
121
  }
@@ -1,38 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as redis from 'redis';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
10
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
11
- socket: {
12
- host: process.env.REDIS_HOST,
13
- port: Number(process.env.REDIS_PORT)
14
- },
15
- password: process.env.REDIS_KEY
16
- });
17
- await client.connect();
18
-
19
- const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
20
-
21
- const holdReservations = await stockHolderRepo.search({
22
- limit: 2,
23
- page: 2,
24
- sort: { 'reservationFor.startDate': chevre.factory.sortType.Ascending }
25
- });
26
- console.log(holdReservations);
27
- console.log(holdReservations.length);
28
-
29
- // const aggregations = await stockHolderRepo.aggregateByReservationFor({
30
- // limit: 100,
31
- // page: 1
32
- // });
33
- // console.log(aggregations);
34
- }
35
-
36
- main()
37
- .then(console.log)
38
- .catch(console.error);
@@ -1,75 +0,0 @@
1
- /// <reference types="mongoose/types/aggregate" />
2
- /// <reference types="mongoose/types/callback" />
3
- /// <reference types="mongoose/types/collection" />
4
- /// <reference types="mongoose/types/connection" />
5
- /// <reference types="mongoose/types/cursor" />
6
- /// <reference types="mongoose/types/document" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/expressions" />
9
- /// <reference types="mongoose/types/helpers" />
10
- /// <reference types="mongoose/types/middlewares" />
11
- /// <reference types="mongoose/types/indexes" />
12
- /// <reference types="mongoose/types/models" />
13
- /// <reference types="mongoose/types/mongooseoptions" />
14
- /// <reference types="mongoose/types/pipelinestage" />
15
- /// <reference types="mongoose/types/populate" />
16
- /// <reference types="mongoose/types/query" />
17
- /// <reference types="mongoose/types/schemaoptions" />
18
- /// <reference types="mongoose/types/schematypes" />
19
- /// <reference types="mongoose/types/session" />
20
- /// <reference types="mongoose/types/types" />
21
- /// <reference types="mongoose/types/utility" />
22
- /// <reference types="mongoose/types/validation" />
23
- /// <reference types="mongoose/types/virtuals" />
24
- /// <reference types="mongoose/types/inferschematype" />
25
- import { Schema } from 'mongoose';
26
- declare const modelName = "HoldReservation";
27
- /**
28
- * 保留予約スキーマ
29
- */
30
- declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
31
- collection: string;
32
- id: true;
33
- read: string;
34
- writeConcern: import("mongodb").WriteConcern;
35
- strict: true;
36
- strictQuery: false;
37
- useNestedStrict: boolean;
38
- timestamps: {
39
- createdAt: string;
40
- updatedAt: string;
41
- };
42
- toJSON: {
43
- getters: false;
44
- virtuals: false;
45
- minimize: false;
46
- versionKey: false;
47
- };
48
- toObject: {
49
- getters: false;
50
- virtuals: true;
51
- minimize: false;
52
- versionKey: false;
53
- };
54
- }, {
55
- typeOf: string;
56
- project: any;
57
- reservationFor: any;
58
- reservations: any[];
59
- reservationCount: number;
60
- }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
61
- typeOf: string;
62
- project: any;
63
- reservationFor: any;
64
- reservations: any[];
65
- reservationCount: number;
66
- }>> & Omit<import("mongoose").FlatRecord<{
67
- typeOf: string;
68
- project: any;
69
- reservationFor: any;
70
- reservations: any[];
71
- reservationCount: number;
72
- }> & {
73
- _id: import("mongoose").Types.ObjectId;
74
- }, never>>;
75
- export { modelName, schema };
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schema = exports.modelName = void 0;
4
- const mongoose_1 = require("mongoose");
5
- const writeConcern_1 = require("../writeConcern");
6
- const modelName = 'HoldReservation';
7
- exports.modelName = modelName;
8
- /**
9
- * 保留予約スキーマ
10
- */
11
- const schema = new mongoose_1.Schema({
12
- project: {
13
- type: mongoose_1.SchemaTypes.Mixed,
14
- required: true
15
- },
16
- typeOf: {
17
- type: String,
18
- required: true
19
- },
20
- reservationFor: {
21
- type: mongoose_1.SchemaTypes.Mixed,
22
- required: true
23
- },
24
- reservationCount: {
25
- type: Number,
26
- default: 0,
27
- required: true
28
- },
29
- reservations: [mongoose_1.SchemaTypes.Mixed]
30
- }, {
31
- collection: 'holdReservations',
32
- id: true,
33
- read: 'primary',
34
- writeConcern: writeConcern_1.writeConcern,
35
- strict: true,
36
- strictQuery: false,
37
- useNestedStrict: true,
38
- timestamps: {
39
- createdAt: 'createdAt',
40
- updatedAt: 'updatedAt'
41
- },
42
- toJSON: {
43
- getters: false,
44
- virtuals: false,
45
- minimize: false,
46
- versionKey: false
47
- },
48
- toObject: {
49
- getters: false,
50
- virtuals: true,
51
- minimize: false,
52
- versionKey: false
53
- }
54
- });
55
- exports.schema = schema;
56
- schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
57
- schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
58
- schema.index({ 'reservationFor.startDate': -1 }, { name: 'searchByReservationForStartDate' });
59
- // イベントIDでunique
60
- schema.index({ 'reservationFor.id': 1 }, { name: 'uniqueReservationForId', unique: true });
61
- schema.index({ 'reservationFor.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByReservationForId' });
62
- schema.index({ 'project.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByProjectId' });
63
- schema.index({ reservationCount: 1, 'reservationFor.startDate': -1 }, { name: 'searchByReservationCount' });
64
- schema.index({ 'reservations.reservationNumber': 1, 'reservationFor.startDate': -1 }, {
65
- name: 'searchByReservationNumber',
66
- partialFilterExpression: {
67
- 'reservations.reservationNumber': { $exists: true }
68
- }
69
- });
70
- schema.index({ 'reservations.subReservation.id': 1, 'reservationFor.startDate': -1 }, {
71
- name: 'searchBySubReservationId',
72
- partialFilterExpression: {
73
- 'reservations.subReservation.id': { $exists: true }
74
- }
75
- });
76
- schema.index({ 'reservations.subReservation.identifier': 1, 'reservationFor.startDate': -1 }, {
77
- name: 'searchBySubReservationIdentifier',
78
- partialFilterExpression: {
79
- 'reservations.subReservation.identifier': { $exists: true }
80
- }
81
- });
82
- schema.index({ 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': 1, 'reservationFor.startDate': -1 }, {
83
- name: 'searchBySubReservationSeatNumber',
84
- partialFilterExpression: {
85
- 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': { $exists: true }
86
- }
87
- });
88
- schema.index({ 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': 1, 'reservationFor.startDate': -1 }, {
89
- name: 'searchBySubReservationSeatSection',
90
- partialFilterExpression: {
91
- 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': { $exists: true }
92
- }
93
- });