@chevre/domain 21.2.0-alpha.1 → 21.2.0-alpha.11

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.
Files changed (143) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/countDelayedTasks.ts +17 -0
  3. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  4. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  5. package/example/src/chevre/lockStockHolder.ts +48 -0
  6. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  7. package/example/src/chevre/processReserve.ts +2 -2
  8. package/example/src/chevre/searchEventSeats.ts +42 -0
  9. package/lib/chevre/repo/account.js +0 -4
  10. package/lib/chevre/repo/accountTitle.js +0 -4
  11. package/lib/chevre/repo/accountTransaction.js +0 -4
  12. package/lib/chevre/repo/accountingReport.js +0 -4
  13. package/lib/chevre/repo/action.js +0 -4
  14. package/lib/chevre/repo/additionalProperty.js +0 -4
  15. package/lib/chevre/repo/aggregation.js +0 -4
  16. package/lib/chevre/repo/assetTransaction.js +5 -4
  17. package/lib/chevre/repo/categoryCode.js +0 -4
  18. package/lib/chevre/repo/code.js +0 -4
  19. package/lib/chevre/repo/comment.js +0 -4
  20. package/lib/chevre/repo/confirmationNumber.js +1 -1
  21. package/lib/chevre/repo/creativeWork.js +0 -4
  22. package/lib/chevre/repo/customer.js +0 -4
  23. package/lib/chevre/repo/emailMessage.js +0 -4
  24. package/lib/chevre/repo/event.js +0 -4
  25. package/lib/chevre/repo/member.js +0 -4
  26. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  27. package/lib/chevre/repo/mongoose/schemas/account.d.ts +1 -0
  28. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  29. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +1 -0
  30. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  31. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +1 -0
  32. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +1 -0
  33. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +1 -0
  34. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  35. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -0
  36. package/lib/chevre/repo/mongoose/schemas/action.js +1 -0
  37. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +1 -0
  38. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  39. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +1 -0
  40. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  41. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -0
  42. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +1 -0
  43. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +1 -0
  44. package/lib/chevre/repo/mongoose/schemas/authorization.js +1 -0
  45. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +1 -0
  46. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  47. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +1 -0
  48. package/lib/chevre/repo/mongoose/schemas/comments.js +1 -0
  49. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +1 -0
  50. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  51. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +1 -0
  52. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  53. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +1 -0
  54. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  55. package/lib/chevre/repo/mongoose/schemas/event.d.ts +1 -0
  56. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  57. package/lib/chevre/repo/mongoose/schemas/member.d.ts +1 -0
  58. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  59. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +1 -0
  60. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  61. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +1 -0
  62. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  63. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -0
  64. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  65. package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -0
  66. package/lib/chevre/repo/mongoose/schemas/order.js +1 -0
  67. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +1 -0
  68. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +1 -0
  69. package/lib/chevre/repo/mongoose/schemas/place.d.ts +1 -0
  70. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  71. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +1 -0
  72. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  73. package/lib/chevre/repo/mongoose/schemas/product.d.ts +1 -0
  74. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  75. package/lib/chevre/repo/mongoose/schemas/project.d.ts +1 -0
  76. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  77. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +1 -0
  78. package/lib/chevre/repo/mongoose/schemas/reservation.js +1 -0
  79. package/lib/chevre/repo/mongoose/schemas/role.d.ts +1 -0
  80. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  81. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +1 -0
  82. package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
  83. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +1 -0
  84. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +1 -0
  85. package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -0
  86. package/lib/chevre/repo/mongoose/schemas/task.js +1 -0
  87. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +1 -0
  88. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  89. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +1 -0
  90. package/lib/chevre/repo/mongoose/schemas/transaction.js +1 -0
  91. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +1 -0
  92. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  93. package/lib/chevre/repo/offer.js +0 -5
  94. package/lib/chevre/repo/offerCatalog.js +0 -4
  95. package/lib/chevre/repo/order.js +0 -4
  96. package/lib/chevre/repo/orderNumber.d.ts +0 -1
  97. package/lib/chevre/repo/orderNumber.js +2 -12
  98. package/lib/chevre/repo/ownershipInfo.js +0 -4
  99. package/lib/chevre/repo/permit.js +0 -4
  100. package/lib/chevre/repo/place.d.ts +5 -1
  101. package/lib/chevre/repo/place.js +1 -10
  102. package/lib/chevre/repo/priceSpecification.js +0 -4
  103. package/lib/chevre/repo/product.js +0 -4
  104. package/lib/chevre/repo/project.js +0 -4
  105. package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
  106. package/lib/chevre/repo/rateLimit/offer.js +14 -14
  107. package/lib/chevre/repo/reservation.js +0 -4
  108. package/lib/chevre/repo/role.js +0 -4
  109. package/lib/chevre/repo/seller.js +0 -4
  110. package/lib/chevre/repo/serviceOutput.js +0 -4
  111. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
  112. package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
  113. package/lib/chevre/repo/{itemAvailability/screeningEvent.d.ts → stockHolder.d.ts} +5 -8
  114. package/lib/chevre/repo/stockHolder.js +273 -0
  115. package/lib/chevre/repo/task.d.ts +3 -0
  116. package/lib/chevre/repo/task.js +12 -4
  117. package/lib/chevre/repo/telemetry.js +0 -4
  118. package/lib/chevre/repo/transaction.d.ts +1 -0
  119. package/lib/chevre/repo/transaction.js +4 -6
  120. package/lib/chevre/repo/transactionNumber.d.ts +2 -1
  121. package/lib/chevre/repo/transactionNumber.js +14 -15
  122. package/lib/chevre/repo/trip.js +0 -4
  123. package/lib/chevre/repository.d.ts +3 -5
  124. package/lib/chevre/repository.js +5 -8
  125. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  126. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -3
  127. package/lib/chevre/service/assetTransaction/reserve.d.ts +4 -4
  128. package/lib/chevre/service/assetTransaction/reserve.js +71 -5
  129. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  130. package/lib/chevre/service/offer/event/cancel.d.ts +2 -2
  131. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  132. package/lib/chevre/service/offer.d.ts +13 -26
  133. package/lib/chevre/service/offer.js +21 -116
  134. package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
  135. package/lib/chevre/service/reserve/cancelReservation.js +6 -6
  136. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -2
  137. package/lib/chevre/service/task/cancelPendingReservation.js +3 -3
  138. package/lib/chevre/service/task/cancelReservation.js +3 -3
  139. package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
  140. package/lib/chevre/settings.d.ts +1 -1
  141. package/lib/chevre/settings.js +4 -4
  142. package/package.json +2 -2
  143. package/lib/chevre/repo/itemAvailability/screeningEvent.js +0 -181
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
24
  const uniqid = require("uniqid");
25
25
  const factory = require("../factory");
26
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
27
26
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
28
27
  /**
29
28
  * オファーカタログリポジトリ
@@ -31,9 +30,6 @@ const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
31
30
  class MongoRepository {
32
31
  constructor(connection) {
33
32
  this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
34
- if (connection.get('autoIndex') === true) {
35
- this.offerCatalogModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
36
- }
37
33
  }
38
34
  // tslint:disable-next-line:max-func-body-length
39
35
  static CREATE_MONGO_CONDITIONS(params) {
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const factory = require("../factory");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const order_1 = require("./mongoose/schemas/order");
16
15
  const errorHandler_1 = require("../errorHandler");
17
16
  const order_2 = require("../factory/order");
@@ -21,9 +20,6 @@ const order_2 = require("../factory/order");
21
20
  class MongoRepository {
22
21
  constructor(connection) {
23
22
  this.orderModel = connection.model(order_1.modelName, order_1.schema);
24
- if (connection.get('autoIndex') === true) {
25
- this.orderModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
26
- }
27
23
  }
28
24
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
29
25
  static CREATE_MONGO_CONDITIONS(params) {
@@ -3,7 +3,6 @@ import { RedisClientType } from 'redis';
3
3
  * 注文番号リポジトリ
4
4
  */
5
5
  export declare class RedisRepository {
6
- private static readonly REDIS_KEY_PREFIX_NEW;
7
6
  private static readonly REDIS_KEY_PREFIX;
8
7
  private readonly redisClient;
9
8
  constructor(redisClient: RedisClientType);
@@ -16,7 +16,6 @@ const util = require("util");
16
16
  // tslint:disable-next-line:no-require-imports no-var-requires
17
17
  const fpe = require('node-fpe');
18
18
  const factory = require("../factory");
19
- const settings_1 = require("../settings");
20
19
  const ORDER_NUMBER_SEPARATOR = '-';
21
20
  /**
22
21
  * 注文番号リポジトリ
@@ -26,15 +25,7 @@ class RedisRepository {
26
25
  this.redisClient = redisClient;
27
26
  }
28
27
  static createKey(params) {
29
- const useNewKey = params.orderDate instanceof Date
30
- && moment(params.orderDate)
31
- .isSameOrAfter(settings_1.USE_NEW_ORDER_NUMBER_KEY_FROM);
32
- if (useNewKey) {
33
- return util.format('%s:%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, params.projectPrefix, params.timestamp);
34
- }
35
- else {
36
- return util.format('%s:%s:%s', RedisRepository.REDIS_KEY_PREFIX, params.projectPrefix, params.timestamp);
37
- }
28
+ return util.format('%s:%s:%s', RedisRepository.REDIS_KEY_PREFIX, params.projectPrefix, params.timestamp);
38
29
  }
39
30
  /**
40
31
  * タイムスタンプから発行する
@@ -79,6 +70,5 @@ class RedisRepository {
79
70
  });
80
71
  }
81
72
  }
82
- RedisRepository.REDIS_KEY_PREFIX_NEW = 'orderNumber';
83
- RedisRepository.REDIS_KEY_PREFIX = 'cinerino:orderNumber';
73
+ RedisRepository.REDIS_KEY_PREFIX = 'orderNumber';
84
74
  exports.RedisRepository = RedisRepository;
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const uuid = require("uuid");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const ownershipInfo_1 = require("./mongoose/schemas/ownershipInfo");
16
15
  const errorHandler_1 = require("../errorHandler");
17
16
  const factory = require("../factory");
@@ -21,9 +20,6 @@ const factory = require("../factory");
21
20
  class MongoRepository {
22
21
  constructor(connection) {
23
22
  this.ownershipInfoModel = connection.model(ownershipInfo_1.modelName, ownershipInfo_1.schema);
24
- if (connection.get('autoIndex') === true) {
25
- this.ownershipInfoModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
26
- }
27
23
  }
28
24
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
29
25
  static CREATE_MONGO_CONDITIONS(params) {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const serviceOutput_1 = require("./mongoose/schemas/serviceOutput");
15
14
  const factory = require("../factory");
16
15
  /**
@@ -19,9 +18,6 @@ const factory = require("../factory");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.serviceOutputModel = connection.model(serviceOutput_1.modelName, serviceOutput_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.serviceOutputModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  findByIdentifier(params, projection) {
27
23
  var _a, _b;
@@ -48,7 +48,11 @@ export declare class MongoRepository {
48
48
  /**
49
49
  * 施設検索
50
50
  */
51
- searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
51
+ searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions & {
52
+ $projection?: {
53
+ [key: string]: 0;
54
+ };
55
+ }): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
52
56
  /**
53
57
  * 施設取得
54
58
  */
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
24
  const mongoose_1 = require("mongoose");
25
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
26
25
  const place_1 = require("./mongoose/schemas/place");
27
26
  const factory = require("../factory");
28
27
  /**
@@ -31,9 +30,6 @@ const factory = require("../factory");
31
30
  class MongoRepository {
32
31
  constructor(connection) {
33
32
  this.placeModel = connection.model(place_1.modelName, place_1.schema);
34
- if (connection.get('autoIndex') === true) {
35
- this.placeModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
36
- }
37
33
  }
38
34
  // tslint:disable-next-line:max-func-body-length
39
35
  static CREATE_BUS_STOP_MONGO_CONDITIONS(params) {
@@ -276,12 +272,7 @@ class MongoRepository {
276
272
  return __awaiter(this, void 0, void 0, function* () {
277
273
  const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
278
274
  // containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
279
- const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
280
- __v: 0,
281
- createdAt: 0,
282
- updatedAt: 0,
283
- containsPlace: 0
284
- });
275
+ const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0, containsPlace: 0 }, params.$projection));
285
276
  if (typeof params.limit === 'number' && params.limit > 0) {
286
277
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
287
278
  query.limit(params.limit)
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
24
  const factory = require("../factory");
25
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
26
25
  const priceSpecification_1 = require("./mongoose/schemas/priceSpecification");
27
26
  /**
28
27
  * 価格仕様リポジトリ
@@ -30,9 +29,6 @@ const priceSpecification_1 = require("./mongoose/schemas/priceSpecification");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.priceSpecificationModel = connection.model(priceSpecification_1.modelName, priceSpecification_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.priceSpecificationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const product_1 = require("./mongoose/schemas/product");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.productModel = connection.model(product_1.modelName, product_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.productModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const project_1 = require("./mongoose/schemas/project");
15
14
  const factory = require("../factory");
16
15
  /**
@@ -19,9 +18,6 @@ const factory = require("../factory");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.projectModel = connection.model(project_1.modelName, project_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.projectModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  static CREATE_MONGO_CONDITIONS(params) {
27
23
  // MongoDB検索条件
@@ -18,10 +18,11 @@ export interface IRateLimitKey {
18
18
  * オファーレート制限リポジトリ
19
19
  */
20
20
  export declare class RedisRepository {
21
- static KEY_PREFIX: string;
21
+ private static readonly KEY_PREFIX_NEW;
22
+ private static readonly KEY_PREFIX;
22
23
  private readonly redisClient;
23
24
  constructor(redisClient: RedisClientType);
24
- static CREATE_REDIS_KEY(ratelimitKey: IRateLimitKey): string;
25
+ private static createKey;
25
26
  /**
26
27
  * ロックする
27
28
  */
@@ -10,10 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RedisRepository = void 0;
13
- const createDebug = require("debug");
14
13
  const moment = require("moment");
15
14
  const factory = require("../../factory");
16
- const debug = createDebug('chevre-domain:repo');
15
+ const settings_1 = require("../../settings");
17
16
  /**
18
17
  * オファーレート制限リポジトリ
19
18
  */
@@ -21,11 +20,17 @@ class RedisRepository {
21
20
  constructor(redisClient) {
22
21
  this.redisClient = redisClient;
23
22
  }
24
- static CREATE_REDIS_KEY(ratelimitKey) {
23
+ static createKey(ratelimitKey) {
25
24
  const dateNow = moment(ratelimitKey.reservationFor.startDate);
26
25
  const unitInSeconds = Number(ratelimitKey.reservedTicket.ticketType.validRateLimit.unitInSeconds.toString());
27
- const validFrom = dateNow.unix() - dateNow.unix() % unitInSeconds;
28
- return `${RedisRepository.KEY_PREFIX}:${ratelimitKey.reservedTicket.ticketType.validRateLimit.scope}:${validFrom.toString()}`;
26
+ const validFrom = dateNow.unix() - (dateNow.unix() % unitInSeconds);
27
+ const useNewKey = dateNow.isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
28
+ if (useNewKey) {
29
+ return `${RedisRepository.KEY_PREFIX_NEW}:${ratelimitKey.reservedTicket.ticketType.validRateLimit.scope}:${validFrom.toString()}`;
30
+ }
31
+ else {
32
+ return `${RedisRepository.KEY_PREFIX}:${ratelimitKey.reservedTicket.ticketType.validRateLimit.scope}:${validFrom.toString()}`;
33
+ }
29
34
  }
30
35
  /**
31
36
  * ロックする
@@ -34,7 +39,7 @@ class RedisRepository {
34
39
  return __awaiter(this, void 0, void 0, function* () {
35
40
  const datasets = ratelimitKeys.map((ratelimitKey) => {
36
41
  return {
37
- key: RedisRepository.CREATE_REDIS_KEY(ratelimitKey),
42
+ key: RedisRepository.createKey(ratelimitKey),
38
43
  value: ratelimitKey.reservationNumber,
39
44
  ttl: moment(ratelimitKey.reservationFor.startDate)
40
45
  .add(ratelimitKey.reservedTicket.ticketType.validRateLimit.unitInSeconds, 'seconds')
@@ -43,29 +48,24 @@ class RedisRepository {
43
48
  });
44
49
  let multi = this.redisClient.multi();
45
50
  datasets.forEach((dataset) => {
46
- debug('setting if not exist...', dataset.key);
47
51
  multi.setNX(dataset.key, dataset.value)
48
52
  .expire(dataset.key, dataset.ttl);
49
53
  });
50
54
  const results = yield multi.exec();
51
55
  const lockedFields = [];
52
56
  results.forEach((r, index) => {
53
- debug('r, index:', r, index);
54
57
  // tslint:disable-next-line:no-magic-numbers
55
58
  if (index % 2 === 0 && (r === 1 || r === true)) {
56
59
  // tslint:disable-next-line:no-magic-numbers
57
60
  lockedFields.push(datasets[index / 2].key);
58
61
  }
59
62
  });
60
- debug('locked fields:', lockedFields);
61
63
  const lockedAll = lockedFields.length === ratelimitKeys.length;
62
- debug('lockedAll?', lockedAll);
63
64
  if (!lockedAll) {
64
65
  if (lockedFields.length > 0) {
65
66
  // 全てロックできなければロックできたものは解除
66
67
  multi = this.redisClient.multi();
67
68
  lockedFields.forEach((key) => {
68
- debug('deleting...', key);
69
69
  multi.del(key);
70
70
  });
71
71
  yield multi.exec();
@@ -78,8 +78,7 @@ class RedisRepository {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
79
  const multi = this.redisClient.multi();
80
80
  ratelimitKeys.forEach((ratelimitKey) => {
81
- const key = RedisRepository.CREATE_REDIS_KEY(ratelimitKey);
82
- debug('deleting...', key);
81
+ const key = RedisRepository.createKey(ratelimitKey);
83
82
  multi.del(key);
84
83
  });
85
84
  yield multi.exec();
@@ -87,10 +86,11 @@ class RedisRepository {
87
86
  }
88
87
  getHolder(ratelimitKey) {
89
88
  return __awaiter(this, void 0, void 0, function* () {
90
- const key = RedisRepository.CREATE_REDIS_KEY(ratelimitKey);
89
+ const key = RedisRepository.createKey(ratelimitKey);
91
90
  return this.redisClient.get(key);
92
91
  });
93
92
  }
94
93
  }
94
+ RedisRepository.KEY_PREFIX_NEW = 'rateLimit:offer';
95
95
  RedisRepository.KEY_PREFIX = 'chevre:rateLimit:offer';
96
96
  exports.RedisRepository = RedisRepository;
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const reservation_1 = require("./mongoose/schemas/reservation");
15
14
  const factory = require("../factory");
16
15
  /**
@@ -19,9 +18,6 @@ const factory = require("../factory");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.reservationModel = connection.model(reservation_1.modelName, reservation_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.reservationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
27
23
  static CREATE_MONGO_CONDITIONS(params) {
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = exports.RoleType = void 0;
13
13
  const factory = require("../factory");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const role_1 = require("./mongoose/schemas/role");
16
15
  var RoleType;
17
16
  (function (RoleType) {
@@ -23,9 +22,6 @@ var RoleType;
23
22
  class MongoRepository {
24
23
  constructor(connection) {
25
24
  this.roleModel = connection.model(role_1.modelName, role_1.schema);
26
- if (connection.get('autoIndex') === true) {
27
- this.roleModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
28
- }
29
25
  }
30
26
  static CREATE_MONGO_CONDITIONS(params) {
31
27
  var _a, _b, _c;
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const seller_1 = require("./mongoose/schemas/seller");
26
25
  const factory = require("../factory");
27
26
  /**
@@ -30,9 +29,6 @@ const factory = require("../factory");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.organizationModel = connection.model(seller_1.modelName, seller_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.organizationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  // tslint:disable-next-line:max-func-body-length
38
34
  static CREATE_MONGO_CONDITIONS(params) {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
14
13
  const serviceOutput_1 = require("./mongoose/schemas/serviceOutput");
15
14
  const factory = require("../factory");
16
15
  /**
@@ -19,9 +18,6 @@ const factory = require("../factory");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.serviceOutputModel = connection.model(serviceOutput_1.modelName, serviceOutput_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.serviceOutputModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  // tslint:disable-next-line:max-func-body-length
27
23
  static CREATE_MONGO_CONDITIONS(params) {
@@ -3,9 +3,10 @@ import { RedisClientType } from 'redis';
3
3
  * サービスアウトプット識別子リポジトリ
4
4
  */
5
5
  export declare class RedisRepository {
6
- static REDIS_KEY_PREFIX: string;
6
+ private static readonly REDIS_KEY_PREFIX;
7
7
  private readonly redisClient;
8
8
  constructor(redisClient: RedisClientType);
9
+ private static createKey;
9
10
  /**
10
11
  * タイムスタンプから発行する
11
12
  */
@@ -23,6 +23,9 @@ class RedisRepository {
23
23
  constructor(redisClient) {
24
24
  this.redisClient = redisClient;
25
25
  }
26
+ static createKey(params) {
27
+ return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, params.timestamp);
28
+ }
26
29
  /**
27
30
  * タイムスタンプから発行する
28
31
  */
@@ -35,30 +38,26 @@ class RedisRepository {
35
38
  const TTL = moment(params.startDate)
36
39
  .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
37
40
  .diff(now, 'seconds');
38
- const key = util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, timestamp);
41
+ const key = RedisRepository.createKey({ startDate: params.startDate, timestamp });
39
42
  const [incrReply] = yield this.redisClient.multi()
40
43
  .incr(key)
41
44
  .expire(key, TTL)
42
45
  .exec();
43
46
  // tslint:disable-next-line:no-single-line-block-comment
44
47
  /* istanbul ignore else: please write tests */
45
- if (typeof incrReply === 'number') {
46
- let identifier = timestamp;
47
- const no = incrReply;
48
- identifier = `${identifier}${no}`;
49
- // checkdigit
50
- const cd = cdigit.luhn.compute(identifier);
51
- const cipher = fpe({ password: cd });
52
- identifier = cipher.encrypt(identifier);
53
- identifier = `${cd}${identifier}`;
54
- return identifier;
55
- }
56
- else {
48
+ if (typeof incrReply !== 'number') {
57
49
  // 基本的にありえないフロー
58
- throw new factory.errors.ServiceUnavailable('ServiceOutput identifier not published');
50
+ throw new factory.errors.ServiceUnavailable('serviceOutput identifier not incremented unexpectedly');
59
51
  }
52
+ let identifier = `${timestamp}${incrReply}`;
53
+ // checkdigit
54
+ const cd = cdigit.luhn.compute(identifier);
55
+ identifier = fpe({ password: cd })
56
+ .encrypt(identifier);
57
+ identifier = `${cd}${identifier}`;
58
+ return identifier;
60
59
  });
61
60
  }
62
61
  }
63
- RedisRepository.REDIS_KEY_PREFIX = 'chevre:serviceOutputIdentifier';
62
+ RedisRepository.REDIS_KEY_PREFIX = 'serviceOutputIdentifier';
64
63
  exports.RedisRepository = RedisRepository;
@@ -1,5 +1,4 @@
1
1
  import { RedisClientType } from 'redis';
2
- import * as factory from '../../factory';
3
2
  export interface IOffer {
4
3
  itemOffered?: {
5
4
  serviceOutput?: {
@@ -24,10 +23,11 @@ export interface IUnlockKey {
24
23
  startDate: Date;
25
24
  offer: IOffer;
26
25
  }
26
+ export type IGetHolderResult = string | null;
27
27
  /**
28
28
  * イベントストックホルダーリポジトリ
29
29
  */
30
- export declare class RedisRepository {
30
+ export declare class StockHolderRepository {
31
31
  static KEY_PREFIX_NEW: string;
32
32
  static KEY_PREFIX: string;
33
33
  private readonly redisClient;
@@ -70,13 +70,10 @@ export declare class RedisRepository {
70
70
  * 在庫状況を検索する
71
71
  * offers.lengthが0だと"ERR wrong number of arguments for 'hmget' command"となるので注意
72
72
  */
73
- searchAvailability(params: {
73
+ searchHolders(params: {
74
74
  eventId: string;
75
75
  startDate: Date;
76
76
  offers: IOffer[];
77
- }): Promise<{
78
- seatSection: string;
79
- seatNumber: string;
80
- availability: factory.itemAvailability;
81
- }[]>;
77
+ }): Promise<IGetHolderResult[]>;
78
+ private checkIfConflicted;
82
79
  }