@chevre/domain 22.11.0-alpha.3 → 22.11.0-alpha.5

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 (30) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
  2. package/example/src/chevre/roles/addAdminInventoryManagerRole.ts +50 -0
  3. package/lib/chevre/repo/confirmationNumber.d.ts +0 -11
  4. package/lib/chevre/repo/confirmationNumber.js +15 -54
  5. package/lib/chevre/repo/orderNumber.d.ts +0 -11
  6. package/lib/chevre/repo/orderNumber.js +13 -51
  7. package/lib/chevre/repo/role.d.ts +3 -0
  8. package/lib/chevre/repo/role.js +19 -0
  9. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -4
  10. package/lib/chevre/repo/serviceOutputIdentifier.js +13 -38
  11. package/lib/chevre/repo/transactionNumber.d.ts +0 -11
  12. package/lib/chevre/repo/transactionNumber.js +13 -51
  13. package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
  14. package/lib/chevre/repo/transactionNumberCounter.js +34 -29
  15. package/lib/chevre/service/task/acceptCOAOffer.js +2 -2
  16. package/lib/chevre/service/task/authorizePayment.js +3 -3
  17. package/lib/chevre/service/task/givePointAward.js +1 -1
  18. package/lib/chevre/service/task/moneyTransfer.js +1 -1
  19. package/lib/chevre/service/task/publishPaymentUrl.js +2 -2
  20. package/lib/chevre/service/task/refund.js +1 -1
  21. package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
  22. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  23. package/lib/chevre/service/task/returnPointAward.js +1 -1
  24. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  25. package/package.json +3 -3
  26. package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
  27. package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
  28. package/example/src/chevre/transactionNumber/setUseMongo4confirmationNumberFrom.ts +0 -45
  29. package/example/src/chevre/transactionNumber/setUseMongo4orderNumberFrom.ts +0 -41
  30. package/example/src/chevre/transactionNumber/setUseMongo4transactionNumberFrom.ts +0 -41
@@ -19,7 +19,6 @@ async function main() {
19
19
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
20
 
21
21
  const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
22
- redisClient,
23
22
  connection: mongoose.connection
24
23
  });
25
24
  const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
@@ -0,0 +1,50 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ chevre.factory.role.organizationRole.RoleName.AdminInventoryManager
13
+ ];
14
+ const permissions = [
15
+ 'iam.members.me.read',
16
+ 'admin.creativeWorks.*',
17
+ 'admin.sellers.eventSeries.*',
18
+ 'admin.sellers.read'
19
+ ];
20
+ for (const roleName of roleNames) {
21
+ const existingRoles = await roleRepo.projectFields(
22
+ {
23
+ roleName: { $eq: roleName }
24
+ },
25
+ ['roleName']
26
+ );
27
+ if (existingRoles.length === 0) {
28
+ const createResult = await roleRepo.create({
29
+ roleName: roleName,
30
+ member: { typeOf: chevre.factory.creativeWorkType.SoftwareApplication },
31
+ memberOf: { typeOf: chevre.factory.organizationType.Project },
32
+ permissions: []
33
+ });
34
+ console.log('role created.', createResult);
35
+ }
36
+ for (const permission of permissions) {
37
+ const result = await roleRepo.addPermissionIfNotExists({
38
+ roleName: { $eq: roleName },
39
+ permission
40
+ });
41
+ console.log('permission added.', result, roleName);
42
+ }
43
+ }
44
+ }
45
+
46
+ main()
47
+ .then(() => {
48
+ console.log('success!');
49
+ })
50
+ .catch(console.error);
@@ -1,14 +1,10 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
- import { ISetting } from './mongoose/schemas/setting';
4
2
  /**
5
3
  * 確認番号リポジトリ
6
4
  */
7
5
  export declare class ConfirmationNumberRepo {
8
- private readonly settingModel;
9
6
  private readonly counterRepo;
10
7
  constructor(params: {
11
- redisClient: RedisClientType;
12
8
  connection: Connection;
13
9
  });
14
10
  private static alignDigits;
@@ -20,11 +16,4 @@ export declare class ConfirmationNumberRepo {
20
16
  publish(params: {
21
17
  orderDate: Date;
22
18
  }): Promise<string>;
23
- /**
24
- * DB移行時のみに使用目的の設定更新
25
- */
26
- setUseMongo4confirmationNumberFrom(params: {
27
- useMongo4confirmationNumberFrom: Date;
28
- }): Promise<Pick<ISetting, "useMongo4confirmationNumberFrom"> | null>;
29
- private useMongoBySettings;
30
19
  }
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ConfirmationNumberRepo = void 0;
13
13
  const cdigit = require("cdigit");
14
14
  const moment = require("moment-timezone");
15
+ // import { RedisClientType } from 'redis';
15
16
  // tslint:disable-next-line:no-require-imports no-var-requires
16
17
  const fpe = require('node-fpe');
17
- const setting_1 = require("./mongoose/schemas/setting");
18
+ // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
18
19
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
19
20
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
20
21
  const CONFIRMATION_NUMBER_MIN_LENGH = 4;
@@ -24,8 +25,8 @@ const TIMEZONE = 'Asia/Tokyo';
24
25
  */
25
26
  class ConfirmationNumberRepo {
26
27
  constructor(params) {
27
- const { connection } = params;
28
- this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
28
+ // const { connection } = params;
29
+ // this.settingModel = connection.model(settingModelName, createSettingSchema());
29
30
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
30
31
  }
31
32
  static alignDigits(params) {
@@ -72,59 +73,19 @@ class ConfirmationNumberRepo {
72
73
  const dataFeedIdentifier = ConfirmationNumberRepo.createDataFeedIdentifier({ orderDate: params.orderDate });
73
74
  let incrReply;
74
75
  // support publishByMongo(2025-05-23~)
75
- const useMongoBySettings = yield this.useMongoBySettings(params);
76
- if (useMongoBySettings) {
77
- // データ保管期間はとりあえず2 months
78
- dataFeedExpires = moment(params.orderDate)
79
- // tslint:disable-next-line:no-magic-numbers
80
- .add(2, 'months')
81
- .toDate();
82
- incrReply = yield this.counterRepo.incrementByMongo({
83
- identifier: dataFeedIdentifier,
84
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
85
- expires: dataFeedExpires
86
- });
87
- }
88
- else {
89
- // データ保管期間はとりあえず一か月
90
- dataFeedExpires = moment(params.orderDate)
91
- .add(1, 'month')
92
- .toDate();
93
- incrReply = yield this.counterRepo.incrementByRedis({
94
- identifier: dataFeedIdentifier,
95
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
96
- expires: dataFeedExpires
97
- });
98
- }
76
+ // const useMongoBySettings = await this.useMongoBySettings(params);
77
+ // データ保管期間はとりあえず2 months
78
+ dataFeedExpires = moment(params.orderDate)
79
+ // tslint:disable-next-line:no-magic-numbers
80
+ .add(2, 'months')
81
+ .toDate();
82
+ incrReply = yield this.counterRepo.incrementByMongo({
83
+ identifier: dataFeedIdentifier,
84
+ includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
85
+ expires: dataFeedExpires
86
+ });
99
87
  return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
100
88
  });
101
89
  }
102
- /**
103
- * DB移行時のみに使用目的の設定更新
104
- */
105
- setUseMongo4confirmationNumberFrom(params) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const { useMongo4confirmationNumberFrom } = params;
108
- return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
109
- $set: { useMongo4confirmationNumberFrom }
110
- }, { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } })
111
- .lean()
112
- .exec();
113
- });
114
- }
115
- useMongoBySettings(params) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
118
- _id: 0,
119
- useMongo4confirmationNumberFrom: 1
120
- })
121
- .lean()
122
- .exec();
123
- const useMongo4confirmationNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4confirmationNumberFrom;
124
- return useMongo4confirmationNumberFrom instanceof Date
125
- && moment(params.orderDate)
126
- .isSameOrAfter(moment(useMongo4confirmationNumberFrom));
127
- });
128
- }
129
90
  }
130
91
  exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
@@ -1,14 +1,10 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
- import { ISetting } from './mongoose/schemas/setting';
4
2
  /**
5
3
  * 注文番号リポジトリ
6
4
  */
7
5
  export declare class OrderNumberRepo {
8
- private readonly settingModel;
9
6
  private readonly counterRepo;
10
7
  constructor(params: {
11
- redisClient: RedisClientType;
12
8
  connection: Connection;
13
9
  });
14
10
  /**
@@ -23,11 +19,4 @@ export declare class OrderNumberRepo {
23
19
  */
24
20
  orderDate: Date;
25
21
  }): Promise<string>;
26
- /**
27
- * DB移行時のみに使用目的の設定更新
28
- */
29
- setUseMongo4orderNumberFrom(params: {
30
- useMongo4orderNumberFrom: Date;
31
- }): Promise<Pick<ISetting, "useMongo4orderNumberFrom"> | null>;
32
- private useMongoBySettings;
33
22
  }
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.OrderNumberRepo = void 0;
13
13
  const cdigit = require("cdigit");
14
14
  const moment = require("moment-timezone");
15
+ // import { RedisClientType } from 'redis';
15
16
  // tslint:disable-next-line:no-require-imports no-var-requires
16
17
  const fpe = require('node-fpe');
17
- const setting_1 = require("./mongoose/schemas/setting");
18
+ // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
18
19
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
19
20
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
20
21
  const ORDER_NUMBER_SEPARATOR = '-';
@@ -23,8 +24,8 @@ const ORDER_NUMBER_SEPARATOR = '-';
23
24
  */
24
25
  class OrderNumberRepo {
25
26
  constructor(params) {
26
- const { connection } = params;
27
- this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
27
+ // const { connection } = params;
28
+ // this.settingModel = connection.model(settingModelName, createSettingSchema());
28
29
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
29
30
  }
30
31
  // private static createKey(params: {
@@ -52,27 +53,15 @@ class OrderNumberRepo {
52
53
  let dataFeedExpires;
53
54
  const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
54
55
  let incrReply;
55
- const useMongoBySettings = yield this.useMongoBySettings(params);
56
- if (useMongoBySettings) {
57
- dataFeedExpires = moment(params.orderDate)
58
- .add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
59
- .toDate();
60
- incrReply = yield this.counterRepo.incrementByMongo({
61
- identifier: dataFeedIdentifier,
62
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
63
- expires: dataFeedExpires
64
- });
65
- }
66
- else {
67
- dataFeedExpires = moment(params.orderDate)
68
- .add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
69
- .toDate();
70
- incrReply = yield this.counterRepo.incrementByRedis({
71
- identifier: dataFeedIdentifier,
72
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
73
- expires: dataFeedExpires
74
- });
75
- }
56
+ // const useMongoBySettings = await this.useMongoBySettings(params);
57
+ dataFeedExpires = moment(params.orderDate)
58
+ .add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
59
+ .toDate();
60
+ incrReply = yield this.counterRepo.incrementByMongo({
61
+ identifier: dataFeedIdentifier,
62
+ includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
63
+ expires: dataFeedExpires
64
+ });
76
65
  let orderNumber = `${timestamp}${incrReply}`;
77
66
  // checkdigit
78
67
  const cd = cdigit.luhn.compute(orderNumber);
@@ -90,32 +79,5 @@ class OrderNumberRepo {
90
79
  return orderNumber;
91
80
  });
92
81
  }
93
- /**
94
- * DB移行時のみに使用目的の設定更新
95
- */
96
- setUseMongo4orderNumberFrom(params) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const { useMongo4orderNumberFrom } = params;
99
- return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
100
- $set: { useMongo4orderNumberFrom }
101
- }, { projection: { _id: 0, useMongo4orderNumberFrom: 1 } })
102
- .lean()
103
- .exec();
104
- });
105
- }
106
- useMongoBySettings(params) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
109
- _id: 0,
110
- useMongo4orderNumberFrom: 1
111
- })
112
- .lean()
113
- .exec();
114
- const useMongo4orderNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4orderNumberFrom;
115
- return useMongo4orderNumberFrom instanceof Date
116
- && moment(params.orderDate)
117
- .isSameOrAfter(moment(useMongo4orderNumberFrom));
118
- });
119
- }
120
82
  }
121
83
  exports.OrderNumberRepo = OrderNumberRepo;
@@ -29,5 +29,8 @@ export declare class RoleRepo {
29
29
  addMember(params: Pick<IRole, 'member' | 'memberOf' | 'roleName'>): Promise<(import("mongoose").FlattenMaps<IDocType> & {
30
30
  _id: import("mongoose").Types.ObjectId;
31
31
  }) | null>;
32
+ create(params: Pick<IRole, 'member' | 'memberOf' | 'permissions' | 'roleName'>): Promise<{
33
+ id: string;
34
+ }>;
32
35
  }
33
36
  export {};
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RoleRepo = void 0;
13
+ const factory = require("../factory");
13
14
  const settings_1 = require("../settings");
14
15
  const role_1 = require("./mongoose/schemas/role");
15
16
  const AVAILABLE_PROJECT_FIELDS = [
@@ -148,5 +149,23 @@ class RoleRepo {
148
149
  .exec();
149
150
  });
150
151
  }
152
+ create(params) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ var _a, _b;
155
+ let savedId;
156
+ const { member, memberOf, permissions, roleName } = params;
157
+ const creatingRole = {
158
+ member, memberOf, permissions, roleName,
159
+ typeOf: factory.role.RoleType.OrganizationRole
160
+ };
161
+ const result = yield this.roleModel.insertMany(creatingRole, { rawResult: true });
162
+ const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
163
+ if (typeof insertedId !== 'string') {
164
+ throw new factory.errors.Internal(`role not saved unexpectedly. result:${JSON.stringify(result)}`);
165
+ }
166
+ savedId = insertedId;
167
+ return { id: savedId };
168
+ });
169
+ }
151
170
  }
152
171
  exports.RoleRepo = RoleRepo;
@@ -1,13 +1,10 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
2
  /**
4
3
  * サービスアウトプット識別子リポジトリ
5
4
  */
6
5
  export declare class ServiceOutputIdentifierRepo {
7
- private readonly settingModel;
8
6
  private readonly counterRepo;
9
7
  constructor(params: {
10
- redisClient: RedisClientType;
11
8
  connection: Connection;
12
9
  });
13
10
  /**
@@ -16,5 +13,4 @@ export declare class ServiceOutputIdentifierRepo {
16
13
  publishByTimestamp(params: {
17
14
  startDate: Date;
18
15
  }): Promise<string>;
19
- private useMongoBySettings;
20
16
  }
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ServiceOutputIdentifierRepo = void 0;
13
13
  const cdigit = require("cdigit");
14
14
  const moment = require("moment-timezone");
15
+ // import { RedisClientType } from 'redis';
15
16
  // tslint:disable-next-line:no-require-imports no-var-requires
16
17
  const fpe = require('node-fpe');
17
- const setting_1 = require("./mongoose/schemas/setting");
18
+ // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
18
19
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
19
20
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
20
21
  /**
@@ -22,8 +23,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
22
23
  */
23
24
  class ServiceOutputIdentifierRepo {
24
25
  constructor(params) {
25
- const { connection } = params;
26
- this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
26
+ // const { connection } = params;
27
+ // this.settingModel = connection.model(settingModelName, createSettingSchema());
27
28
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
28
29
  }
29
30
  // private static createKey(params: {
@@ -47,27 +48,15 @@ class ServiceOutputIdentifierRepo {
47
48
  let dataFeedExpires;
48
49
  const dataFeedIdentifier = timestamp;
49
50
  let incrReply;
50
- const useMongoBySettings = yield this.useMongoBySettings(params);
51
- if (useMongoBySettings) {
52
- dataFeedExpires = moment(params.startDate)
53
- .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
54
- .toDate();
55
- incrReply = yield this.counterRepo.incrementByMongo({
56
- identifier: dataFeedIdentifier,
57
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.serviceOutputIdentifier },
58
- expires: dataFeedExpires
59
- });
60
- }
61
- else {
62
- dataFeedExpires = moment(params.startDate)
63
- .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
64
- .toDate();
65
- incrReply = yield this.counterRepo.incrementByRedis({
66
- identifier: dataFeedIdentifier,
67
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.serviceOutputIdentifier },
68
- expires: dataFeedExpires
69
- });
70
- }
51
+ // const useMongoBySettings = await this.useMongoBySettings(params);
52
+ dataFeedExpires = moment(params.startDate)
53
+ .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
54
+ .toDate();
55
+ incrReply = yield this.counterRepo.incrementByMongo({
56
+ identifier: dataFeedIdentifier,
57
+ includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.serviceOutputIdentifier },
58
+ expires: dataFeedExpires
59
+ });
71
60
  let identifier = `${timestamp}${incrReply}`;
72
61
  // checkdigit
73
62
  const cd = cdigit.luhn.compute(identifier);
@@ -77,19 +66,5 @@ class ServiceOutputIdentifierRepo {
77
66
  return identifier;
78
67
  });
79
68
  }
80
- useMongoBySettings(params) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
83
- _id: 0,
84
- useMongo4transactionNumberFrom: 1
85
- })
86
- .lean()
87
- .exec();
88
- const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
89
- return useMongo4transactionNumberFrom instanceof Date
90
- && moment(params.startDate)
91
- .isSameOrAfter(moment(useMongo4transactionNumberFrom));
92
- });
93
- }
94
69
  }
95
70
  exports.ServiceOutputIdentifierRepo = ServiceOutputIdentifierRepo;
@@ -1,6 +1,4 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
- import { ISetting } from './mongoose/schemas/setting';
4
2
  interface IPublishResult {
5
3
  transactionNumber: string;
6
4
  }
@@ -8,10 +6,8 @@ interface IPublishResult {
8
6
  * 取引番号リポジトリ
9
7
  */
10
8
  export declare class TransactionNumberRepo {
11
- private readonly settingModel;
12
9
  private readonly counterRepo;
13
10
  constructor(params: {
14
- redisClient: RedisClientType;
15
11
  connection: Connection;
16
12
  });
17
13
  /**
@@ -20,12 +16,5 @@ export declare class TransactionNumberRepo {
20
16
  publishByTimestamp(params: {
21
17
  startDate: Date;
22
18
  }): Promise<IPublishResult>;
23
- /**
24
- * DB移行時のみに使用目的の設定更新
25
- */
26
- setUseMongo4transactionNumberFrom(params: {
27
- useMongo4transactionNumberFrom: Date;
28
- }): Promise<Pick<ISetting, "useMongo4transactionNumberFrom"> | null>;
29
- private useMongoBySettings;
30
19
  }
31
20
  export {};
@@ -12,9 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TransactionNumberRepo = void 0;
13
13
  const cdigit = require("cdigit");
14
14
  const moment = require("moment-timezone");
15
+ // import { RedisClientType } from 'redis';
15
16
  // tslint:disable-next-line:no-require-imports no-var-requires
16
17
  const fpe = require('node-fpe');
17
- const setting_1 = require("./mongoose/schemas/setting");
18
+ // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
18
19
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
19
20
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
20
21
  /**
@@ -22,8 +23,8 @@ const transactionNumberCounter_1 = require("./transactionNumberCounter");
22
23
  */
23
24
  class TransactionNumberRepo {
24
25
  constructor(params) {
25
- const { connection } = params;
26
- this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
26
+ // const { connection } = params;
27
+ // this.settingModel = connection.model(settingModelName, createSettingSchema());
27
28
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
28
29
  }
29
30
  // private static createKey(params: {
@@ -47,27 +48,15 @@ class TransactionNumberRepo {
47
48
  let dataFeedExpires;
48
49
  const dataFeedIdentifier = timestamp;
49
50
  let incrReply;
50
- const useMongoBySettings = yield this.useMongoBySettings(params);
51
- if (useMongoBySettings) {
52
- dataFeedExpires = moment(params.startDate)
53
- .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
54
- .toDate();
55
- incrReply = yield this.counterRepo.incrementByMongo({
56
- identifier: dataFeedIdentifier,
57
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.transactionNumber },
58
- expires: dataFeedExpires
59
- });
60
- }
61
- else {
62
- dataFeedExpires = moment(params.startDate)
63
- .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
64
- .toDate();
65
- incrReply = yield this.counterRepo.incrementByRedis({
66
- identifier: dataFeedIdentifier,
67
- includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.transactionNumber },
68
- expires: dataFeedExpires
69
- });
70
- }
51
+ // const useMongoBySettings = await this.useMongoBySettings(params);
52
+ dataFeedExpires = moment(params.startDate)
53
+ .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
54
+ .toDate();
55
+ incrReply = yield this.counterRepo.incrementByMongo({
56
+ identifier: dataFeedIdentifier,
57
+ includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.transactionNumber },
58
+ expires: dataFeedExpires
59
+ });
71
60
  let transactionNumber = `${timestamp}${incrReply}`;
72
61
  // checkdigit
73
62
  const cd = cdigit.luhn.compute(transactionNumber);
@@ -77,32 +66,5 @@ class TransactionNumberRepo {
77
66
  return { transactionNumber };
78
67
  });
79
68
  }
80
- /**
81
- * DB移行時のみに使用目的の設定更新
82
- */
83
- setUseMongo4transactionNumberFrom(params) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const { useMongo4transactionNumberFrom } = params;
86
- return this.settingModel.findOneAndUpdate({ 'project.id': { $eq: '*' } }, {
87
- $set: { useMongo4transactionNumberFrom }
88
- }, { projection: { _id: 0, useMongo4transactionNumberFrom: 1 } })
89
- .lean()
90
- .exec();
91
- });
92
- }
93
- useMongoBySettings(params) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const setting = yield this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
96
- _id: 0,
97
- useMongo4transactionNumberFrom: 1
98
- })
99
- .lean()
100
- .exec();
101
- const useMongo4transactionNumberFrom = setting === null || setting === void 0 ? void 0 : setting.useMongo4transactionNumberFrom;
102
- return useMongo4transactionNumberFrom instanceof Date
103
- && moment(params.startDate)
104
- .isSameOrAfter(moment(useMongo4transactionNumberFrom));
105
- });
106
- }
107
69
  }
108
70
  exports.TransactionNumberRepo = TransactionNumberRepo;
@@ -1,23 +1,13 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
2
  import { DataCatalogIdentifier } from './mongoose/schemas/transactionNumber';
4
3
  /**
5
4
  * 取引番号カウンターリポジトリ
6
5
  */
7
6
  export declare class TransactionNumberCounterRepo {
8
- private readonly redisClient;
9
7
  private readonly transactionNumberModel;
10
8
  constructor(params: {
11
- redisClient: RedisClientType;
12
9
  connection: Connection;
13
10
  });
14
- incrementByRedis(params: {
15
- identifier: string;
16
- includedInDataCatalog: {
17
- identifier: DataCatalogIdentifier;
18
- };
19
- expires: Date;
20
- }): Promise<number>;
21
11
  incrementByMongo(params: {
22
12
  identifier: string;
23
13
  includedInDataCatalog: {
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TransactionNumberCounterRepo = void 0;
13
+ // import { RedisClientType } from 'redis';
13
14
  const errorHandler_1 = require("../errorHandler");
14
15
  const factory = require("../factory");
15
16
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
@@ -19,37 +20,41 @@ const MAX_RETRY_INCREMENT = 1;
19
20
  */
20
21
  class TransactionNumberCounterRepo {
21
22
  constructor(params) {
22
- const { redisClient, connection } = params;
23
- this.redisClient = redisClient;
23
+ const { connection } = params;
24
+ // this.redisClient = redisClient;
24
25
  this.transactionNumberModel = connection.model(transactionNumber_1.modelName, (0, transactionNumber_1.createSchema)());
25
26
  }
26
- incrementByRedis(params) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- // const now = moment();
29
- const { expires } = params;
30
- const key = `${params.includedInDataCatalog.identifier}:${params.identifier}`;
31
- // const TTL = moment(expires)
32
- // .diff(now, 'seconds');
33
- const [incrReply, expireAtReply] = yield this.redisClient.multi()
34
- .incr(key)
35
- // .expire(key, TTL)
36
- .expireAt(key, expires)
37
- .exec();
38
- // tslint:disable-next-line:no-single-line-block-comment
39
- /* istanbul ignore else: please write tests */
40
- if (typeof incrReply !== 'number') {
41
- // 基本的にありえないフロー
42
- throw new factory.errors.Internal('transaction number not incremented unexpectedly');
43
- }
44
- // expireAtReplyの検証も追加する(2023-04-19~)
45
- const expiredSet = expireAtReply === 1 || expireAtReply === true;
46
- if (!expiredSet) {
47
- // 基本的にありえないフロー
48
- throw new factory.errors.Internal('transaction number expiration not set unexpectedly');
49
- }
50
- return incrReply;
51
- });
52
- }
27
+ // public async incrementByRedis(params: {
28
+ // identifier: string;
29
+ // includedInDataCatalog: {
30
+ // identifier: DataCatalogIdentifier;
31
+ // };
32
+ // expires: Date;
33
+ // }): Promise<number> {
34
+ // // const now = moment();
35
+ // const { expires } = params;
36
+ // const key = `${params.includedInDataCatalog.identifier}:${params.identifier}`;
37
+ // // const TTL = moment(expires)
38
+ // // .diff(now, 'seconds');
39
+ // const [incrReply, expireAtReply] = await this.redisClient.multi()
40
+ // .incr(key)
41
+ // // .expire(key, TTL)
42
+ // .expireAt(key, expires)
43
+ // .exec();
44
+ // // tslint:disable-next-line:no-single-line-block-comment
45
+ // /* istanbul ignore else: please write tests */
46
+ // if (typeof incrReply !== 'number') {
47
+ // // 基本的にありえないフロー
48
+ // throw new factory.errors.Internal('transaction number not incremented unexpectedly');
49
+ // }
50
+ // // expireAtReplyの検証も追加する(2023-04-19~)
51
+ // const expiredSet = expireAtReply === 1 || <any>expireAtReply === true;
52
+ // if (!expiredSet) {
53
+ // // 基本的にありえないフロー
54
+ // throw new factory.errors.Internal('transaction number expiration not set unexpectedly');
55
+ // }
56
+ // return incrReply;
57
+ // }
53
58
  incrementByMongo(params) {
54
59
  return __awaiter(this, void 0, void 0, function* () {
55
60
  var _a;
@@ -86,7 +86,7 @@ function call(params) {
86
86
  })({
87
87
  action: actionRepo,
88
88
  event: new event_1.EventRepo(connection),
89
- orderNumber: new orderNumber_1.OrderNumberRepo({ redisClient, connection }),
89
+ orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
90
90
  project: new project_1.ProjectRepo(connection),
91
91
  transaction: new transaction_1.TransactionRepo(connection),
92
92
  reserveService,
@@ -104,7 +104,7 @@ function call(params) {
104
104
  })({
105
105
  action: actionRepo,
106
106
  event: new event_1.EventRepo(connection),
107
- orderNumber: new orderNumber_1.OrderNumberRepo({ redisClient, connection }),
107
+ orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
108
108
  project: new project_1.ProjectRepo(connection),
109
109
  transaction: new transaction_1.TransactionRepo(connection),
110
110
  reserveService,
@@ -57,13 +57,13 @@ function call(params) {
57
57
  action: actionRepo,
58
58
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
59
59
  authorization: new authorization_1.AuthorizationRepo(connection),
60
- confirmationNumber: new confirmationNumber_1.ConfirmationNumberRepo({ redisClient, connection }),
60
+ confirmationNumber: new confirmationNumber_1.ConfirmationNumberRepo({ connection }),
61
61
  credentials: new credentials_1.CredentialsRepo(redisClient, {
62
62
  scope: `${factory.service.paymentService.PaymentServiceType.MovieTicket}:${paymentServiceId}`,
63
63
  expireInSeconds: (useCredentialsRepo) ? credentialsExpireInSeconds : 0
64
64
  }),
65
65
  event: new event_1.EventRepo(connection),
66
- orderNumber: new orderNumber_1.OrderNumberRepo({ redisClient, connection }),
66
+ orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
67
67
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
68
68
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
69
69
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
@@ -73,7 +73,7 @@ function call(params) {
73
73
  task: new task_1.TaskRepo(connection),
74
74
  ticket: new ticket_1.TicketRepo(connection),
75
75
  transaction: new transaction_1.TransactionRepo(connection),
76
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
76
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
77
77
  // transactionProcess: transactionProcessRepo
78
78
  }, settings);
79
79
  }
@@ -29,7 +29,7 @@ function call(data) {
29
29
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
30
30
  const productRepo = new product_1.ProductRepo(connection);
31
31
  const projectRepo = new project_1.ProjectRepo(connection);
32
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
32
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
33
33
  yield DeliveryService.givePointAward(data)({
34
34
  action: actionRepo,
35
35
  assetTransaction: assetTransactionRepo,
@@ -25,7 +25,7 @@ function call(data) {
25
25
  }
26
26
  const actionRepo = new action_1.ActionRepo(connection);
27
27
  const productRepo = new product_1.ProductRepo(connection);
28
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
28
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
29
29
  yield MoneyTransferService.moneyTransfer(data)({
30
30
  action: actionRepo,
31
31
  product: productRepo,
@@ -43,14 +43,14 @@ function call(params) {
43
43
  action: actionRepo,
44
44
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
45
45
  authorization: new authorization_1.AuthorizationRepo(connection),
46
- orderNumber: new orderNumber_1.OrderNumberRepo({ redisClient, connection }),
46
+ orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
47
47
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
48
48
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
49
49
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
50
50
  project: new project_1.ProjectRepo(connection),
51
51
  ticket: new ticket_1.TicketRepo(connection),
52
52
  transaction: new transaction_1.TransactionRepo(connection),
53
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
53
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
54
54
  }, settings);
55
55
  }
56
56
  catch (error) {
@@ -58,7 +58,7 @@ function call(params) {
58
58
  project: new project_1.ProjectRepo(connection),
59
59
  task: new task_1.TaskRepo(connection),
60
60
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
61
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
61
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
62
62
  }, settings);
63
63
  });
64
64
  }
@@ -29,7 +29,7 @@ function call(data) {
29
29
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
30
30
  const productRepo = new product_1.ProductRepo(connection);
31
31
  const projectRepo = new project_1.ProjectRepo(connection);
32
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
32
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
33
33
  yield (0, returnMoneyTransfer_1.returnMoneyTransfer)(data)({
34
34
  action: actionRepo,
35
35
  assetTransaction: assetTransactionRepo,
@@ -39,7 +39,7 @@ function call(params) {
39
39
  product: new product_1.ProductRepo(connection),
40
40
  task: new task_1.TaskRepo(connection),
41
41
  transaction: new transaction_1.TransactionRepo(connection),
42
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection })
42
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
43
43
  });
44
44
  });
45
45
  }
@@ -29,7 +29,7 @@ function call(data) {
29
29
  const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
30
30
  const productRepo = new product_1.ProductRepo(connection);
31
31
  const projectRepo = new project_1.ProjectRepo(connection);
32
- const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ redisClient, connection });
32
+ const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
33
33
  yield DeliveryService.returnPointAward(data)({
34
34
  action: actionRepo,
35
35
  assetTransaction: assetTransactionRepo,
@@ -55,7 +55,7 @@ function call(params) {
55
55
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
56
56
  project: new project_1.ProjectRepo(connection),
57
57
  reservation: new reservation_1.ReservationRepo(connection),
58
- transactionNumber: new transactionNumber_1.TransactionNumberRepo({ redisClient, connection }),
58
+ transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection }),
59
59
  reserveService
60
60
  });
61
61
  });
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.395.0-alpha.2",
15
- "@cinerino/sdk": "11.0.0-alpha.3",
14
+ "@chevre/factory": "4.395.0-alpha.3",
15
+ "@cinerino/sdk": "11.0.0-alpha.4",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/client": "8.1.4",
@@ -113,5 +113,5 @@
113
113
  "postversion": "git push origin --tags",
114
114
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
115
115
  },
116
- "version": "22.11.0-alpha.3"
116
+ "version": "22.11.0-alpha.5"
117
117
  }
@@ -1,37 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
- import * as redis from 'redis';
4
- import { chevre } from '../../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
9
- socket: {
10
- port: Number(<string>process.env.REDIS_PORT),
11
- host: <string>process.env.REDIS_HOST
12
- },
13
- password: <string>process.env.REDIS_KEY,
14
- name: 'checkRedisKeyCount'
15
- })
16
- .on('error', (err) => {
17
- // eslint-disable-next-line no-console
18
- console.error('createDefaultRedisClient: client onError:', err);
19
- // reject(err);
20
- });
21
- redisClient.connect();
22
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
23
-
24
- async function main() {
25
- const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
26
- redisClient,
27
- connection: mongoose.connection
28
- });
29
- const result = await confirmationNumberRepo.publish({ orderDate: new Date() });
30
- console.log(result);
31
- }
32
-
33
- main()
34
- .then(() => {
35
- console.log('success!');
36
- })
37
- .catch(console.error);
@@ -1,40 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
- import * as redis from 'redis';
4
- import { chevre } from '../../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
9
- socket: {
10
- port: Number(<string>process.env.REDIS_PORT),
11
- host: <string>process.env.REDIS_HOST
12
- },
13
- password: <string>process.env.REDIS_KEY,
14
- name: 'checkRedisKeyCount'
15
- })
16
- .on('error', (err) => {
17
- // eslint-disable-next-line no-console
18
- console.error('createDefaultRedisClient: client onError:', err);
19
- // reject(err);
20
- });
21
- redisClient.connect();
22
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
23
-
24
- async function main() {
25
- const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
26
- redisClient,
27
- connection: mongoose.connection
28
- });
29
- const result = await orderNumberRepo.publishByTimestamp({
30
- project: { alternateName: 'CIN' },
31
- orderDate: new Date()
32
- });
33
- console.log(result);
34
- }
35
-
36
- main()
37
- .then(() => {
38
- console.log('success!');
39
- })
40
- .catch(console.error);
@@ -1,45 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
10
- socket: {
11
- port: Number(<string>process.env.REDIS_PORT),
12
- host: <string>process.env.REDIS_HOST
13
- },
14
- password: <string>process.env.REDIS_KEY,
15
- name: 'checkRedisKeyCount'
16
- })
17
- .on('error', (err) => {
18
- // eslint-disable-next-line no-console
19
- console.error('createDefaultRedisClient: client onError:', err);
20
- // reject(err);
21
- });
22
- redisClient.connect();
23
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
24
-
25
- async function main() {
26
- const confirmationNumberRepo = await chevre.repository.ConfirmationNumber.createInstance({
27
- redisClient,
28
- connection: mongoose.connection
29
- });
30
- const result = await confirmationNumberRepo.setUseMongo4confirmationNumberFrom({
31
- // useMongo4confirmationNumberFrom: moment('2025-05-22T23:50:00Z')
32
- // .toDate(),
33
- // useMongo4confirmationNumberFrom: moment('2025-05-25T15:00:00Z')
34
- // .toDate()
35
- useMongo4confirmationNumberFrom: moment('2025-05-31T15:00:00Z')
36
- .toDate()
37
- });
38
- console.log(result);
39
- }
40
-
41
- main()
42
- .then(() => {
43
- console.log('success!');
44
- })
45
- .catch(console.error);
@@ -1,41 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
10
- socket: {
11
- port: Number(<string>process.env.REDIS_PORT),
12
- host: <string>process.env.REDIS_HOST
13
- },
14
- password: <string>process.env.REDIS_KEY,
15
- name: 'checkRedisKeyCount'
16
- })
17
- .on('error', (err) => {
18
- // eslint-disable-next-line no-console
19
- console.error('createDefaultRedisClient: client onError:', err);
20
- // reject(err);
21
- });
22
- redisClient.connect();
23
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
24
-
25
- async function main() {
26
- const orderNumberRepo = await chevre.repository.OrderNumber.createInstance({
27
- redisClient,
28
- connection: mongoose.connection
29
- });
30
- const result = await orderNumberRepo.setUseMongo4orderNumberFrom({
31
- useMongo4orderNumberFrom: moment('2025-06-03T05:00:00Z')
32
- .toDate()
33
- });
34
- console.log(result);
35
- }
36
-
37
- main()
38
- .then(() => {
39
- console.log('success!');
40
- })
41
- .catch(console.error);
@@ -1,41 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
10
- socket: {
11
- port: Number(<string>process.env.REDIS_PORT),
12
- host: <string>process.env.REDIS_HOST
13
- },
14
- password: <string>process.env.REDIS_KEY,
15
- name: 'checkRedisKeyCount'
16
- })
17
- .on('error', (err) => {
18
- // eslint-disable-next-line no-console
19
- console.error('createDefaultRedisClient: client onError:', err);
20
- // reject(err);
21
- });
22
- redisClient.connect();
23
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
24
-
25
- async function main() {
26
- const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance({
27
- redisClient,
28
- connection: mongoose.connection
29
- });
30
- const result = await transactionNumberRepo.setUseMongo4transactionNumberFrom({
31
- useMongo4transactionNumberFrom: moment('2025-06-05T22:45:00Z')
32
- .toDate()
33
- });
34
- console.log(result);
35
- }
36
-
37
- main()
38
- .then(() => {
39
- console.log('success!');
40
- })
41
- .catch(console.error);