@chevre/domain 21.2.0-alpha.6 → 21.2.0-alpha.8

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 (40) hide show
  1. package/example/src/chevre/countDelayedTasks.ts +17 -0
  2. package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
  3. package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
  4. package/lib/chevre/repo/account.js +0 -4
  5. package/lib/chevre/repo/accountTitle.js +0 -4
  6. package/lib/chevre/repo/accountTransaction.js +0 -4
  7. package/lib/chevre/repo/accountingReport.js +0 -4
  8. package/lib/chevre/repo/action.js +0 -4
  9. package/lib/chevre/repo/additionalProperty.js +0 -4
  10. package/lib/chevre/repo/aggregation.js +0 -4
  11. package/lib/chevre/repo/assetTransaction.js +0 -4
  12. package/lib/chevre/repo/categoryCode.js +0 -4
  13. package/lib/chevre/repo/code.js +0 -4
  14. package/lib/chevre/repo/comment.js +0 -4
  15. package/lib/chevre/repo/creativeWork.js +0 -4
  16. package/lib/chevre/repo/customer.js +0 -4
  17. package/lib/chevre/repo/emailMessage.js +0 -4
  18. package/lib/chevre/repo/event.js +0 -4
  19. package/lib/chevre/repo/member.js +0 -4
  20. package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
  21. package/lib/chevre/repo/offer.js +0 -5
  22. package/lib/chevre/repo/offerCatalog.js +0 -4
  23. package/lib/chevre/repo/order.js +0 -4
  24. package/lib/chevre/repo/ownershipInfo.js +0 -4
  25. package/lib/chevre/repo/permit.js +0 -4
  26. package/lib/chevre/repo/place.js +0 -4
  27. package/lib/chevre/repo/priceSpecification.js +0 -4
  28. package/lib/chevre/repo/product.js +0 -4
  29. package/lib/chevre/repo/project.js +0 -4
  30. package/lib/chevre/repo/reservation.js +0 -4
  31. package/lib/chevre/repo/role.js +0 -4
  32. package/lib/chevre/repo/seller.js +0 -4
  33. package/lib/chevre/repo/serviceOutput.js +0 -4
  34. package/lib/chevre/repo/stockHolder.js +30 -0
  35. package/lib/chevre/repo/task.d.ts +3 -0
  36. package/lib/chevre/repo/task.js +12 -4
  37. package/lib/chevre/repo/telemetry.js +0 -4
  38. package/lib/chevre/repo/transaction.js +0 -4
  39. package/lib/chevre/repo/trip.js +0 -4
  40. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ export async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+
9
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
10
+
11
+ const count = await taskRepo.countDelayedTasks({ delayInSeconds: 60 });
12
+ console.log('count:', count);
13
+ }
14
+
15
+ main()
16
+ .then()
17
+ .catch(console.error);
@@ -0,0 +1,36 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ export async function main() {
11
+ const now = new Date();
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
+
14
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
15
+
16
+ const transactions = await transactionRepo.search<chevre.factory.transactionType.MoneyTransfer>(
17
+ {
18
+ project: { id: { $eq: project.id } },
19
+ typeOf: chevre.factory.transactionType.MoneyTransfer,
20
+ statuses: [chevre.factory.transactionStatusType.Confirmed],
21
+ startFrom: moment(now)
22
+ .add(-1, 'year')
23
+ .toDate(),
24
+ startThrough: now,
25
+ inclusion: ['_id', 'startDate', 'typeOf', 'object'],
26
+ exclusion: []
27
+ }
28
+ );
29
+ const count = transactions.filter((t) => t.object.description === '受け取り')
30
+ .length;
31
+ console.log('transactions found', count);
32
+ }
33
+
34
+ main()
35
+ .then()
36
+ .catch(console.error);
@@ -0,0 +1,89 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+ import * as redis from 'redis';
5
+
6
+ import { chevre } from '../../../lib/index';
7
+
8
+ // const project = { id: String(process.env.PROJECT_ID) };
9
+
10
+ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
11
+
12
+ async function main() {
13
+ const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
14
+ socket: {
15
+ host: process.env.REDIS_HOST,
16
+ port: Number(process.env.REDIS_PORT)
17
+ },
18
+ password: process.env.REDIS_KEY
19
+ });
20
+ await client.connect();
21
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
22
+
23
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
24
+ const stockHolderRepo = new chevre.repository.StockHolder(client);
25
+
26
+ const cursor = eventRepo.getCursor(
27
+ {
28
+ // 'project.id': { $eq: project.id },
29
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID },
30
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
31
+ startDate: {
32
+ $gte: moment('2023-04-23T15:00:00Z')
33
+ .toDate()
34
+ }
35
+ // _id: { $eq: 'al6aff83w' }
36
+ },
37
+ {
38
+ // _id: 1,
39
+ }
40
+ );
41
+ console.log('events found');
42
+
43
+ let i = 0;
44
+ let updateCount = 0;
45
+ await cursor.eachAsync(async (doc) => {
46
+ i += 1;
47
+ const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
48
+
49
+ const oldKey = chevre.repository.StockHolder.GET_KEY({
50
+ eventId: event.id,
51
+ startDate: new Date()
52
+ });
53
+ const newKey = chevre.repository.StockHolder.GET_KEY({
54
+ eventId: event.id,
55
+ startDate: moment(event.startDate)
56
+ .toDate()
57
+ });
58
+
59
+ let conflicted = false;
60
+ try {
61
+ await stockHolderRepo.checkIfConflicted({
62
+ key: newKey,
63
+ eventId: event.id
64
+ });
65
+ } catch (error) {
66
+ conflicted = true;
67
+ }
68
+
69
+ if (conflicted) {
70
+ updateCount += 1;
71
+ await stockHolderRepo.migrateKey({
72
+ key: newKey,
73
+ eventId: event.id
74
+ });
75
+ console.log(
76
+ 'updated...', event.project.id, event.id, event.startDate, i);
77
+ } else {
78
+ console.log(
79
+ 'already exist...', event.project.id, event.id, event.startDate, i);
80
+ }
81
+ });
82
+
83
+ console.log(i, 'events checked');
84
+ console.log(updateCount, 'events updated');
85
+ }
86
+
87
+ main()
88
+ .then()
89
+ .catch(console.error);
@@ -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 account_1 = require("./mongoose/schemas/account");
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.accountModel = connection.model(account_1.modelName, account_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.accountModel.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 = void 0;
13
13
  const factory = require("../factory");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const accountTitle_1 = require("./mongoose/schemas/accountTitle");
16
15
  /**
17
16
  * 科目リポジトリ
@@ -19,9 +18,6 @@ const accountTitle_1 = require("./mongoose/schemas/accountTitle");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.accountTitleModel = connection.model(accountTitle_1.modelName, accountTitle_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.accountTitleModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  deleteByProject(params) {
27
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -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 moment = require("moment");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const accountTransaction_1 = require("./mongoose/schemas/accountTransaction");
16
15
  const factory = require("../factory");
17
16
  /**
@@ -20,9 +19,6 @@ const factory = require("../factory");
20
19
  class MongoRepository {
21
20
  constructor(connection) {
22
21
  this.transactionModel = connection.model(accountTransaction_1.modelName, accountTransaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
22
  }
27
23
  static CREATE_MONGO_CONDITIONS(params) {
28
24
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
@@ -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 accountingReport_1 = require("./mongoose/schemas/accountingReport");
15
14
  const errorHandler_1 = require("../errorHandler");
16
15
  /**
@@ -19,9 +18,6 @@ const errorHandler_1 = require("../errorHandler");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.accountingReportModel = connection.model(accountingReport_1.modelName, accountingReport_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.accountingReportModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  /**
27
23
  * なければ作成する
@@ -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 action_1 = require("./mongoose/schemas/action");
16
15
  /**
17
16
  * アクションリポジトリ
@@ -19,9 +18,6 @@ const action_1 = require("./mongoose/schemas/action");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.actionModel = connection.model(action_1.modelName, action_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.actionModel.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) {
@@ -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 additionalProperty_1 = require("./mongoose/schemas/additionalProperty");
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.additionalPropertyModel = connection.model(additionalProperty_1.modelName, additionalProperty_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.additionalPropertyModel.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 = exports.AggregationType = void 0;
24
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
25
24
  const aggregation_1 = require("./mongoose/schemas/aggregation");
26
25
  var AggregationType;
27
26
  (function (AggregationType) {
@@ -43,9 +42,6 @@ var AggregationType;
43
42
  class MongoRepository {
44
43
  constructor(connection) {
45
44
  this.aggregationModel = connection.model(aggregation_1.modelName, aggregation_1.schema);
46
- if (connection.get('autoIndex') === true) {
47
- this.aggregationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
48
- }
49
45
  }
50
46
  saveAggregation(params) {
51
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -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 moment = require("moment");
14
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
15
14
  const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
16
15
  const factory = require("../factory");
17
16
  /**
@@ -20,9 +19,6 @@ const factory = require("../factory");
20
19
  class MongoRepository {
21
20
  constructor(connection) {
22
21
  this.transactionModel = connection.model(assetTransaction_1.modelName, assetTransaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
22
  }
27
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
28
24
  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 categoryCode_1 = require("./mongoose/schemas/categoryCode");
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.categoryCodeModel = connection.model(categoryCode_1.modelName, categoryCode_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.categoryCodeModel.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) {
@@ -13,7 +13,6 @@ exports.MongoRepository = exports.modelName = void 0;
13
13
  const moment = require("moment");
14
14
  const uuid = require("uuid");
15
15
  const factory = require("../factory");
16
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
17
16
  const authorization_1 = require("./mongoose/schemas/authorization");
18
17
  Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return authorization_1.modelName; } });
19
18
  /**
@@ -22,9 +21,6 @@ Object.defineProperty(exports, "modelName", { enumerable: true, get: function ()
22
21
  class MongoRepository {
23
22
  constructor(connection) {
24
23
  this.authorizationModel = connection.model(authorization_1.modelName, authorization_1.schema);
25
- if (connection.get('autoIndex') === true) {
26
- this.authorizationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
27
- }
28
24
  }
29
25
  // tslint:disable-next-line:max-func-body-length
30
26
  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 comments_1 = require("./mongoose/schemas/comments");
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.commentModel = connection.model(comments_1.modelName, comments_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.commentModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
24
- }
25
21
  }
26
22
  static CREATE_MONGO_CONDITIONS(params) {
27
23
  var _a, _b, _c, _d, _e, _f;
@@ -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 creativeWork_1 = require("./mongoose/schemas/creativeWork");
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.creativeWorkModel = connection.model(creativeWork_1.modelName, creativeWork_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.creativeWorkModel.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) {
@@ -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 customer_1 = require("./mongoose/schemas/customer");
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.customerModel = connection.model(customer_1.modelName, customer_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.customerModel.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) {
@@ -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 emailMessages_1 = require("./mongoose/schemas/emailMessages");
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.emailMessageModel = connection.model(emailMessages_1.modelName, emailMessages_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.emailMessageModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
35
- }
36
32
  }
37
33
  static CREATE_MONGO_CONDITIONS(params) {
38
34
  var _a, _b, _c, _d, _e;
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = exports.PROJECTION_MINIMIZED_EVENT = void 0;
24
24
  const uniqid = require("uniqid");
25
25
  const factory = require("../factory");
26
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
27
26
  const event_1 = require("./mongoose/schemas/event");
28
27
  const errorHandler_1 = require("../errorHandler");
29
28
  exports.PROJECTION_MINIMIZED_EVENT = {
@@ -48,9 +47,6 @@ exports.PROJECTION_MINIMIZED_EVENT = {
48
47
  class MongoRepository {
49
48
  constructor(connection) {
50
49
  this.eventModel = connection.model(event_1.modelName, event_1.schema);
51
- if (connection.get('autoIndex') === true) {
52
- this.eventModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
53
- }
54
50
  }
55
51
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
56
52
  static CREATE_MONGO_CONDITIONS(conditions) {
@@ -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 member_1 = require("./mongoose/schemas/member");
16
15
  /**
17
16
  * IAMメンバーリポジトリ
@@ -19,9 +18,6 @@ const member_1 = require("./mongoose/schemas/member");
19
18
  class MongoRepository {
20
19
  constructor(connection) {
21
20
  this.memberModel = connection.model(member_1.modelName, member_1.schema);
22
- if (connection.get('autoIndex') === true) {
23
- this.memberModel.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) {
@@ -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 merchantReturnPolicy_1 = require("./mongoose/schemas/merchantReturnPolicy");
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.merchantReturnPolicyModel = connection.model(merchantReturnPolicy_1.modelName, merchantReturnPolicy_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.merchantReturnPolicyModel.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) {
@@ -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 offer_1 = require("./mongoose/schemas/offer");
28
27
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
29
28
  /**
@@ -33,10 +32,6 @@ class MongoRepository {
33
32
  constructor(connection) {
34
33
  this.offerModel = connection.model(offer_1.modelName, offer_1.schema);
35
34
  this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
36
- if (connection.get('autoIndex') === true) {
37
- this.offerModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
38
- this.offerCatalogModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
39
- }
40
35
  }
41
36
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
42
37
  static CREATE_OFFER_MONGO_CONDITIONS(params) {
@@ -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) {
@@ -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;
@@ -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) {
@@ -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検索条件
@@ -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) {
@@ -22,6 +22,12 @@ class StockHolderRepository {
22
22
  constructor(redisClient) {
23
23
  this.redisClient = redisClient;
24
24
  }
25
+ // public static GET_KEY(params: {
26
+ // eventId: string;
27
+ // startDate: Date;
28
+ // }) {
29
+ // return StockHolderRepository.createKey(params);
30
+ // }
25
31
  static offer2field(params) {
26
32
  var _a, _b;
27
33
  // 予約IDをfieldにする場合
@@ -214,6 +220,30 @@ class StockHolderRepository {
214
220
  return result;
215
221
  });
216
222
  }
223
+ // public async migrateKey(params: {
224
+ // key: string;
225
+ // eventId: string;
226
+ // }): Promise<void> {
227
+ // // 旧キーと新キーの両方存在検証(念のため)
228
+ // const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
229
+ // const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
230
+ // if (params.key !== oldKey) {
231
+ // // newの場合oldが存在するはずがない
232
+ // const existingOldKeyCount = await this.redisClient.exists(oldKey);
233
+ // debug('existingOldKeyCount:', existingOldKeyCount);
234
+ // if (existingOldKeyCount > 0) {
235
+ // await this.redisClient.del(oldKey);
236
+ // }
237
+ // }
238
+ // if (params.key !== newKey) {
239
+ // // oldの場合newが存在するはずがない
240
+ // const existingNewKeyCount = await this.redisClient.exists(newKey);
241
+ // debug('existingNewKeyCount:', existingNewKeyCount);
242
+ // if (existingNewKeyCount > 0) {
243
+ // await this.redisClient.del(newKey);
244
+ // }
245
+ // }
246
+ // }
217
247
  checkIfConflicted(params) {
218
248
  return __awaiter(this, void 0, void 0, function* () {
219
249
  // 旧キーと新キーの両方存在検証(念のため)
@@ -61,6 +61,9 @@ export declare class MongoRepository {
61
61
  deleteByName(params: {
62
62
  name: factory.taskName;
63
63
  }): Promise<import("mongodb").DeleteResult>;
64
+ countDelayedTasks(params: {
65
+ delayInSeconds: number;
66
+ }): Promise<number>;
64
67
  aggregateTask(params: {
65
68
  project?: {
66
69
  id?: {
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
16
15
  const task_1 = require("./mongoose/schemas/task");
17
16
  /**
18
17
  * タスク実行時のソート条件
@@ -27,9 +26,6 @@ const sortOrder4executionOfTasks = {
27
26
  class MongoRepository {
28
27
  constructor(connection) {
29
28
  this.taskModel = connection.model(task_1.modelName, task_1.schema);
30
- if (connection.get('autoIndex') === true) {
31
- this.taskModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
32
- }
33
29
  }
34
30
  // tslint:disable-next-line:max-func-body-length
35
31
  static CREATE_MONGO_CONDITIONS(params) {
@@ -344,6 +340,18 @@ class MongoRepository {
344
340
  .exec();
345
341
  });
346
342
  }
343
+ countDelayedTasks(params) {
344
+ return __awaiter(this, void 0, void 0, function* () {
345
+ const runsAtLt = moment()
346
+ .add(-params.delayInSeconds, 'seconds')
347
+ .toDate();
348
+ return this.taskModel.count({
349
+ status: factory.taskStatus.Ready,
350
+ runsAt: { $lt: runsAtLt }
351
+ })
352
+ .exec();
353
+ });
354
+ }
347
355
  aggregateTask(params) {
348
356
  return __awaiter(this, void 0, void 0, function* () {
349
357
  const statuses = yield Promise.all([
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MongoRepository = void 0;
4
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
5
4
  const telemetry_1 = require("./mongoose/schemas/telemetry");
6
5
  /**
7
6
  * 測定リポジトリ
@@ -9,9 +8,6 @@ const telemetry_1 = require("./mongoose/schemas/telemetry");
9
8
  class MongoRepository {
10
9
  constructor(connection) {
11
10
  this.telemetryModel = connection.model(telemetry_1.modelName, telemetry_1.schema);
12
- if (connection.get('autoIndex') === true) {
13
- this.telemetryModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
14
- }
15
11
  }
16
12
  }
17
13
  exports.MongoRepository = MongoRepository;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
- const onIndexCreated_1 = require("./mongoose/onIndexCreated");
16
15
  const transaction_1 = require("./mongoose/schemas/transaction");
17
16
  /**
18
17
  * 取引リポジトリ
@@ -20,9 +19,6 @@ const transaction_1 = require("./mongoose/schemas/transaction");
20
19
  class MongoRepository {
21
20
  constructor(connection) {
22
21
  this.transactionModel = connection.model(transaction_1.modelName, transaction_1.schema);
23
- if (connection.get('autoIndex') === true) {
24
- this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
25
- }
26
22
  }
27
23
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
28
24
  static CREATE_MONGO_CONDITIONS(params) {
@@ -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 trip_1 = require("./mongoose/schemas/trip");
27
26
  /**
28
27
  * トリップリポジトリ
@@ -30,9 +29,6 @@ const trip_1 = require("./mongoose/schemas/trip");
30
29
  class MongoRepository {
31
30
  constructor(connection) {
32
31
  this.tripModel = connection.model(trip_1.modelName, trip_1.schema);
33
- if (connection.get('autoIndex') === true) {
34
- this.tripModel.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(conditions) {
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.2.0-alpha.6"
120
+ "version": "21.2.0-alpha.8"
121
121
  }