@chevre/domain 21.1.0-alpha.2 → 21.1.0-alpha.3

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.
@@ -10,8 +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.RedisRepository = void 0;
13
- const createDebug = require("debug");
14
- const debug = createDebug('chevre:repository');
15
13
  /**
16
14
  * 進行中サービス登録アクションリポジトリ
17
15
  */
@@ -26,14 +24,13 @@ class RedisRepository {
26
24
  return __awaiter(this, void 0, void 0, function* () {
27
25
  const key = `${RedisRepository.KEY_PREFIX}:${progressKey.agent.id}:${progressKey.product.id}`;
28
26
  const ttl = 7200;
29
- debug('locking...', key, ttl);
30
27
  const results = yield this.redisClient.multi()
31
28
  .setNX(key, holder)
32
29
  .expire(key, ttl)
33
30
  .exec();
34
31
  // tslint:disable-next-line:no-single-line-block-comment
35
32
  /* istanbul ignore else: please write tests */
36
- if (results[0] === 1 || results[0] === true) {
33
+ if (Array.isArray(results) && (results[0] === 1 || results[0] === true)) {
37
34
  return true;
38
35
  }
39
36
  else {
@@ -83,7 +83,7 @@ class RedisRepository {
83
83
  .hDel(key, lockedFields)
84
84
  .exec();
85
85
  }
86
- throw new factory.errors.AlreadyInUse('', [], 'Seat number already hold');
86
+ throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
87
87
  }
88
88
  });
89
89
  }
@@ -51,7 +51,6 @@ class RedisRepository {
51
51
  if (typeof results[0] === 'number') {
52
52
  let orderNumber = timestamp;
53
53
  const no = results[0];
54
- // orderNumber = `${orderNumber}${(`${no}`).slice(-1)}`; // ミリ秒あたり10件以内の注文想定
55
54
  orderNumber = `${orderNumber}${no}`;
56
55
  // checkdigit
57
56
  const cd = cdigit.luhn.compute(orderNumber);
@@ -11,13 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RedisRepository = void 0;
13
13
  const cdigit = require("cdigit");
14
- const createDebug = require("debug");
15
14
  const moment = require("moment-timezone");
16
15
  const util = require("util");
17
16
  // tslint:disable-next-line:no-require-imports no-var-requires
18
17
  const fpe = require('node-fpe');
19
18
  const factory = require("../factory");
20
- const debug = createDebug('chevre-domain:repo');
21
19
  /**
22
20
  * サービスアウトプット識別子リポジトリ
23
21
  */
@@ -37,7 +35,6 @@ class RedisRepository {
37
35
  const TTL = moment(params.startDate)
38
36
  .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
39
37
  .diff(now, 'seconds');
40
- debug(`TTL:${TTL} seconds`);
41
38
  const key = util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, timestamp);
42
39
  const results = yield this.redisClient.multi()
43
40
  .incr(key)
@@ -48,13 +45,11 @@ class RedisRepository {
48
45
  if (Array.isArray(results) && typeof results[0] === 'number') {
49
46
  let identifier = timestamp;
50
47
  const no = results[0];
51
- debug('no incremented.', no);
52
48
  identifier = `${identifier}${no}`;
53
49
  // checkdigit
54
50
  const cd = cdigit.luhn.compute(identifier);
55
51
  const cipher = fpe({ password: cd });
56
52
  identifier = cipher.encrypt(identifier);
57
- debug('publishing serviceOutputIdentifier from', timestamp, no, cd);
58
53
  identifier = `${cd}${identifier}`;
59
54
  return identifier;
60
55
  }
@@ -11,13 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RedisRepository = void 0;
13
13
  const cdigit = require("cdigit");
14
- const createDebug = require("debug");
15
14
  const moment = require("moment-timezone");
16
15
  const util = require("util");
17
16
  // tslint:disable-next-line:no-require-imports no-var-requires
18
17
  const fpe = require('node-fpe');
19
18
  const factory = require("../factory");
20
- const debug = createDebug('chevre-domain:repo');
21
19
  /**
22
20
  * 取引番号リポジトリ
23
21
  */
@@ -30,9 +28,6 @@ class RedisRepository {
30
28
  */
31
29
  publishByTimestamp(params) {
32
30
  return __awaiter(this, void 0, void 0, function* () {
33
- // tslint:disable-next-line:no-magic-numbers
34
- // const projectPrefix = params.project.id.slice(0, 3)
35
- // .toUpperCase();
36
31
  const timestamp = moment(params.startDate)
37
32
  .valueOf()
38
33
  .toString();
@@ -40,12 +35,7 @@ class RedisRepository {
40
35
  const TTL = moment(params.startDate)
41
36
  .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
42
37
  .diff(now, 'seconds');
43
- debug(`TTL:${TTL} seconds`);
44
- const key = util.format(
45
- // '%s:%s:%s',
46
- '%s:%s', RedisRepository.REDIS_KEY_PREFIX,
47
- // projectPrefix,
48
- timestamp);
38
+ const key = util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, timestamp);
49
39
  const results = yield this.redisClient.multi()
50
40
  .incr(key)
51
41
  .expire(key, TTL)
@@ -55,15 +45,11 @@ class RedisRepository {
55
45
  if (Array.isArray(results) && typeof results[0] === 'number') {
56
46
  let transactionNumber = timestamp;
57
47
  const no = results[0];
58
- debug('no incremented.', no);
59
48
  transactionNumber = `${transactionNumber}${no}`;
60
49
  // checkdigit
61
50
  const cd = cdigit.luhn.compute(transactionNumber);
62
51
  const cipher = fpe({ password: cd });
63
52
  transactionNumber = cipher.encrypt(transactionNumber);
64
- // debug('publishing transactionNumber from', projectPrefix, timestamp, no, cd);
65
- // transactionNumber = `${projectPrefix}${cd}${transactionNumber}`;
66
- debug('publishing transactionNumber from', timestamp, no, cd);
67
53
  transactionNumber = `${cd}${transactionNumber}`;
68
54
  return { transactionNumber };
69
55
  }
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.1.0-alpha.2"
120
+ "version": "21.1.0-alpha.3"
121
121
  }