@chevre/domain 22.11.0-alpha.4 → 22.11.0-alpha.6

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 (34) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
  2. package/example/src/chevre/roles/addAdminInventoryManagerRole.ts +50 -0
  3. package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +129 -0
  4. package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
  5. package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +17 -21
  6. package/example/src/chevre/unsetUnnecessaryFields.ts +6 -5
  7. package/lib/chevre/repo/confirmationNumber.d.ts +0 -3
  8. package/lib/chevre/repo/confirmationNumber.js +12 -47
  9. package/lib/chevre/repo/orderNumber.d.ts +0 -3
  10. package/lib/chevre/repo/orderNumber.js +10 -44
  11. package/lib/chevre/repo/role.d.ts +3 -0
  12. package/lib/chevre/repo/role.js +19 -0
  13. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -3
  14. package/lib/chevre/repo/serviceOutputIdentifier.js +10 -27
  15. package/lib/chevre/repo/setting.d.ts +5 -1
  16. package/lib/chevre/repo/setting.js +6 -0
  17. package/lib/chevre/repo/transactionNumber.d.ts +0 -3
  18. package/lib/chevre/repo/transactionNumber.js +10 -44
  19. package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
  20. package/lib/chevre/repo/transactionNumberCounter.js +34 -29
  21. package/lib/chevre/service/task/acceptCOAOffer.js +2 -2
  22. package/lib/chevre/service/task/authorizePayment.js +3 -3
  23. package/lib/chevre/service/task/givePointAward.js +1 -1
  24. package/lib/chevre/service/task/moneyTransfer.js +1 -1
  25. package/lib/chevre/service/task/publishPaymentUrl.js +2 -2
  26. package/lib/chevre/service/task/refund.js +1 -1
  27. package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
  28. package/lib/chevre/service/task/returnPayTransaction.js +1 -1
  29. package/lib/chevre/service/task/returnPointAward.js +1 -1
  30. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  31. package/lib/chevre/service/validation/validateOrder.js +55 -37
  32. package/package.json +3 -3
  33. package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
  34. package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
@@ -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);
@@ -0,0 +1,129 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
11
+
12
+ let roleNames = [
13
+ chevre.factory.role.organizationRole.RoleName.InventoryManager
14
+ ];
15
+ let permissions = [
16
+ 'admin.creativeWorks.*',
17
+ 'admin.sellers.eventSeries.*',
18
+ 'admin.customers.read',
19
+ 'admin.offers.read',
20
+ 'admin.offers.create',
21
+ 'admin.offerCatalogs.create',
22
+ 'admin.offerCatalogItems.read',
23
+ 'admin.offerCatalogItems.create',
24
+ 'admin.products.create',
25
+ 'admin.sellers.events.create',
26
+ 'admin.sellers.events.update'
27
+ ];
28
+ for (const roleName of roleNames) {
29
+ for (const permission of permissions) {
30
+ const result = await roleRepo.addPermissionIfNotExists({
31
+ roleName: { $eq: roleName },
32
+ permission
33
+ });
34
+ console.log('permission added.', result, roleName);
35
+ }
36
+ }
37
+
38
+ roleNames = [
39
+ chevre.factory.role.organizationRole.RoleName.SellersOwner
40
+ ];
41
+ permissions = [
42
+ 'admin.sellers.eventSeries.*',
43
+ 'admin.customers.read',
44
+ 'admin.offers.read',
45
+ 'admin.offerCatalogItems.read',
46
+ 'admin.sellers.events.create',
47
+ 'admin.sellers.events.update',
48
+ 'admin.sellers.orders.read',
49
+ 'admin.sellers.reservations.read',
50
+ 'admin.sellers.assetTransactions.cancelReservation.write'
51
+ ];
52
+ for (const roleName of roleNames) {
53
+ for (const permission of permissions) {
54
+ const result = await roleRepo.addPermissionIfNotExists({
55
+ roleName: { $eq: roleName },
56
+ permission
57
+ });
58
+ console.log('permission added.', result, roleName);
59
+ }
60
+ }
61
+
62
+ roleNames = [
63
+ chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
64
+ ];
65
+ permissions = [
66
+ 'admin.sellers.eventSeries.*',
67
+ 'admin.customers.read',
68
+ 'admin.offers.read',
69
+ 'admin.offerCatalogItems.read',
70
+ 'admin.sellers.events.create',
71
+ 'admin.sellers.events.update'
72
+ ];
73
+ for (const roleName of roleNames) {
74
+ for (const permission of permissions) {
75
+ const result = await roleRepo.addPermissionIfNotExists({
76
+ roleName: { $eq: roleName },
77
+ permission
78
+ });
79
+ console.log('permission added.', result, roleName);
80
+ }
81
+ }
82
+
83
+ roleNames = [
84
+ chevre.factory.role.organizationRole.RoleName.TicketClerk
85
+ ];
86
+ permissions = [
87
+ 'admin.customers.read',
88
+ 'admin.offers.read',
89
+ 'admin.sellers.notes.create',
90
+ 'admin.sellers.notes.read',
91
+ 'admin.sellers.notes.update',
92
+ 'admin.sellers.orders.read',
93
+ 'admin.sellers.orders.update',
94
+ 'admin.sellers.reservations.read',
95
+ 'admin.sellers.reservations.attended',
96
+ 'admin.sellers.assetTransactions.cancelReservation.write'
97
+ ];
98
+ for (const roleName of roleNames) {
99
+ for (const permission of permissions) {
100
+ const result = await roleRepo.addPermissionIfNotExists({
101
+ roleName: { $eq: roleName },
102
+ permission
103
+ });
104
+ console.log('permission added.', result, roleName);
105
+ }
106
+ }
107
+
108
+ roleNames = [
109
+ chevre.factory.role.organizationRole.RoleName.TicketCollector
110
+ ];
111
+ permissions = [
112
+ 'admin.sellers.reservations.read',
113
+ 'admin.sellers.reservations.attended'
114
+ ];
115
+ for (const roleName of roleNames) {
116
+ for (const permission of permissions) {
117
+ const result = await roleRepo.addPermissionIfNotExists({
118
+ roleName: { $eq: roleName },
119
+ permission
120
+ });
121
+ console.log('permission added.', result, roleName);
122
+ }
123
+ }
124
+
125
+ }
126
+
127
+ main()
128
+ .then()
129
+ .catch(console.error);
@@ -8,17 +8,50 @@ async function main() {
8
8
 
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
- const roleNames = [
11
+ // const roleNames = [
12
+ // chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
+ // chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ // chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
+ // ];
16
+ // for (const roleName of roleNames) {
17
+ // const result = await roleRepo.addPermissionIfNotExists({
18
+ // roleName: { $eq: roleName },
19
+ // permission: 'eventOffers.*'
20
+ // });
21
+ // console.log(result, roleName);
22
+ // }
23
+ let roleNames = [
24
+ chevre.factory.role.organizationRole.RoleName.InventoryManager
25
+ ];
26
+ let permissions = [
27
+ 'admin.creativeWorks.*'
28
+ ];
29
+ for (const roleName of roleNames) {
30
+ for (const permission of permissions) {
31
+ const result = await roleRepo.addPermissionIfNotExists({
32
+ roleName: { $eq: roleName },
33
+ permission
34
+ });
35
+ console.log('permission added.', result, roleName);
36
+ }
37
+ }
38
+
39
+ roleNames = [
12
40
  chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
41
  chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
42
  chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
43
  ];
44
+ permissions = [
45
+ 'admin.sellers.eventSeries.*'
46
+ ];
16
47
  for (const roleName of roleNames) {
17
- const result = await roleRepo.addPermissionIfNotExists({
18
- roleName: { $eq: roleName },
19
- permission: 'eventOffers.*'
20
- });
21
- console.log(result, roleName);
48
+ for (const permission of permissions) {
49
+ const result = await roleRepo.addPermissionIfNotExists({
50
+ roleName: { $eq: roleName },
51
+ permission
52
+ });
53
+ console.log('permission added.', result, roleName);
54
+ }
22
55
  }
23
56
  }
24
57
 
@@ -38,7 +38,6 @@ function countRedisKeyByProject(params: {
38
38
  {
39
39
  'project.id': {
40
40
  $eq: params.project.id
41
- // $in: useMongoAsStockHolderProjects
42
41
  },
43
42
  // startDate: {
44
43
  // $gte: params.now
@@ -93,30 +92,27 @@ function countRedisKeyByProject(params: {
93
92
  async function main() {
94
93
  const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
95
94
  const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
96
- const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
95
+ // const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
97
96
  const stockHolderRepo = await chevre.repository.StockHolder.createInstance(
98
97
  client,
99
98
  mongoose.connection
100
99
  );
101
100
 
102
- const setting = await settingRepo.findOne(
103
- { project: { id: { $eq: '*' } } },
104
- ['useMongoAsStockHolderProjects', 'useMongoAsStockHolder']
105
- );
106
- const useMongoAsStockHolder = setting?.useMongoAsStockHolder === true;
107
- let useMongoAsStockHolderProjects =
108
- (Array.isArray(setting?.useMongoAsStockHolderProjects)) ? setting?.useMongoAsStockHolderProjects : [];
109
- if (useMongoAsStockHolder) {
110
- // 全プロジェクト
111
- useMongoAsStockHolderProjects = (await projectRepo.projectFields(
112
- {
113
- // id: { $eq: 'xxx' }
114
- },
115
- ['id']
116
- )).map(({ id }) => id);
117
- }
118
-
119
- useMongoAsStockHolderProjects = useMongoAsStockHolderProjects.filter((id) => id.slice(0, 6) !== 'sskts-');
101
+ // const setting = await settingRepo.findOne(
102
+ // { project: { id: { $eq: '*' } } },
103
+ // ['useMongoAsStockHolder']
104
+ // );
105
+ // const useMongoAsStockHolder = setting?.useMongoAsStockHolder === true;
106
+ let checkingProjects: string[] = [];
107
+ // 全プロジェクト
108
+ checkingProjects = (await projectRepo.projectFields(
109
+ {
110
+ // id: { $eq: 'xxx' }
111
+ },
112
+ ['id']
113
+ )).map(({ id }) => id);
114
+
115
+ checkingProjects = checkingProjects.filter((id) => id.slice(0, 6) !== 'sskts-');
120
116
 
121
117
  const results: {
122
118
  project: { id: string };
@@ -127,7 +123,7 @@ async function main() {
127
123
  const now = moment()
128
124
  .add(0, 'days')
129
125
  .toDate();
130
- for (const projectId of useMongoAsStockHolderProjects) {
126
+ for (const projectId of checkingProjects) {
131
127
  const { checkedCount, redisKeyCount } = await countRedisKeyByProject({
132
128
  project: { id: projectId },
133
129
  now
@@ -9,17 +9,18 @@ import { chevre } from '../../../lib/index';
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
12
+ const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
13
13
 
14
14
  let updateResult: any;
15
15
 
16
- updateResult = await aggregateOfferRepo.unsetUnnecessaryFields({
16
+ updateResult = await settingRepo.unsetUnnecessaryFields({
17
17
  filter: {
18
- 'offers.includedInDataCatalog.id': { $exists: true }
19
- // _id: { $eq: 'blj55y1mo' }
18
+ 'project.id': { $eq: '*' }
20
19
  },
21
20
  $unset: {
22
- 'offers.0.includedInDataCatalog': 1
21
+ useMongo4confirmationNumberFrom: 1,
22
+ useMongo4orderNumberFrom: 1,
23
+ useMongo4transactionNumberFrom: 1
23
24
  }
24
25
  });
25
26
  console.log(updateResult);
@@ -1,12 +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 ConfirmationNumberRepo {
7
6
  private readonly counterRepo;
8
7
  constructor(params: {
9
- redisClient: RedisClientType;
10
8
  connection: Connection;
11
9
  });
12
10
  private static alignDigits;
@@ -18,5 +16,4 @@ export declare class ConfirmationNumberRepo {
18
16
  publish(params: {
19
17
  orderDate: Date;
20
18
  }): Promise<string>;
21
- private useMongoBySettings;
22
19
  }
@@ -12,6 +12,7 @@ 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
18
  // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
@@ -72,55 +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
- // public async setUseMongo4confirmationNumberFrom(params: {
106
- // useMongo4confirmationNumberFrom: Date;
107
- // }) {
108
- // const { useMongo4confirmationNumberFrom } = params;
109
- // return this.settingModel.findOneAndUpdate(
110
- // { 'project.id': { $eq: '*' } },
111
- // {
112
- // $set: { useMongo4confirmationNumberFrom }
113
- // },
114
- // { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } }
115
- // )
116
- // .lean<Pick<ISetting, 'useMongo4confirmationNumberFrom'> | null>()
117
- // .exec();
118
- // }
119
- // tslint:disable-next-line:prefer-function-over-method
120
- useMongoBySettings(__) {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- return true;
123
- });
124
- }
125
90
  }
126
91
  exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
@@ -1,12 +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 OrderNumberRepo {
7
6
  private readonly counterRepo;
8
7
  constructor(params: {
9
- redisClient: RedisClientType;
10
8
  connection: Connection;
11
9
  });
12
10
  /**
@@ -21,5 +19,4 @@ export declare class OrderNumberRepo {
21
19
  */
22
20
  orderDate: Date;
23
21
  }): Promise<string>;
24
- private useMongoBySettings;
25
22
  }
@@ -12,6 +12,7 @@ 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
18
  // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
@@ -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,28 +79,5 @@ class OrderNumberRepo {
90
79
  return orderNumber;
91
80
  });
92
81
  }
93
- // /**
94
- // * DB移行時のみに使用目的の設定更新
95
- // */
96
- // public async setUseMongo4orderNumberFrom(params: {
97
- // useMongo4orderNumberFrom: Date;
98
- // }) {
99
- // const { useMongo4orderNumberFrom } = params;
100
- // return this.settingModel.findOneAndUpdate(
101
- // { 'project.id': { $eq: '*' } },
102
- // {
103
- // $set: { useMongo4orderNumberFrom }
104
- // },
105
- // { projection: { _id: 0, useMongo4orderNumberFrom: 1 } }
106
- // )
107
- // .lean<Pick<ISetting, 'useMongo4orderNumberFrom'> | null>()
108
- // .exec();
109
- // }
110
- // tslint:disable-next-line:prefer-function-over-method
111
- useMongoBySettings(__) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- return true;
114
- });
115
- }
116
82
  }
117
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,12 +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
6
  private readonly counterRepo;
8
7
  constructor(params: {
9
- redisClient: RedisClientType;
10
8
  connection: Connection;
11
9
  });
12
10
  /**
@@ -15,5 +13,4 @@ export declare class ServiceOutputIdentifierRepo {
15
13
  publishByTimestamp(params: {
16
14
  startDate: Date;
17
15
  }): Promise<string>;
18
- private useMongoBySettings;
19
16
  }
@@ -12,6 +12,7 @@ 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
18
  // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
@@ -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,11 +66,5 @@ class ServiceOutputIdentifierRepo {
77
66
  return identifier;
78
67
  });
79
68
  }
80
- // tslint:disable-next-line:prefer-function-over-method
81
- useMongoBySettings(__) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- return true;
84
- });
85
- }
86
69
  }
87
70
  exports.ServiceOutputIdentifierRepo = ServiceOutputIdentifierRepo;
@@ -1,4 +1,4 @@
1
- import type { Connection } from 'mongoose';
1
+ import type { Connection, FilterQuery } from 'mongoose';
2
2
  import { ISetting } from './mongoose/schemas/setting';
3
3
  type IKeyOfProjection = keyof ISetting;
4
4
  export { ISetting };
@@ -32,4 +32,8 @@ export declare class SettingRepo {
32
32
  }, update: {
33
33
  $set: any;
34
34
  }): Promise<import("mongoose").UpdateWriteOpResult>;
35
+ unsetUnnecessaryFields(params: {
36
+ filter: FilterQuery<ISetting>;
37
+ $unset: any;
38
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
35
39
  }
@@ -65,5 +65,11 @@ class SettingRepo {
65
65
  .exec();
66
66
  });
67
67
  }
68
+ unsetUnnecessaryFields(params) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ return this.settingModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
71
+ .exec();
72
+ });
73
+ }
68
74
  }
69
75
  exports.SettingRepo = SettingRepo;
@@ -1,5 +1,4 @@
1
1
  import type { Connection } from 'mongoose';
2
- import { RedisClientType } from 'redis';
3
2
  interface IPublishResult {
4
3
  transactionNumber: string;
5
4
  }
@@ -9,7 +8,6 @@ interface IPublishResult {
9
8
  export declare class TransactionNumberRepo {
10
9
  private readonly counterRepo;
11
10
  constructor(params: {
12
- redisClient: RedisClientType;
13
11
  connection: Connection;
14
12
  });
15
13
  /**
@@ -18,6 +16,5 @@ export declare class TransactionNumberRepo {
18
16
  publishByTimestamp(params: {
19
17
  startDate: Date;
20
18
  }): Promise<IPublishResult>;
21
- private useMongoBySettings;
22
19
  }
23
20
  export {};
@@ -12,6 +12,7 @@ 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
18
  // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
@@ -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,28 +66,5 @@ class TransactionNumberRepo {
77
66
  return { transactionNumber };
78
67
  });
79
68
  }
80
- // /**
81
- // * DB移行時のみに使用目的の設定更新
82
- // */
83
- // public async setUseMongo4transactionNumberFrom(params: {
84
- // useMongo4transactionNumberFrom: Date;
85
- // }) {
86
- // const { useMongo4transactionNumberFrom } = params;
87
- // return this.settingModel.findOneAndUpdate(
88
- // { 'project.id': { $eq: '*' } },
89
- // {
90
- // $set: { useMongo4transactionNumberFrom }
91
- // },
92
- // { projection: { _id: 0, useMongo4transactionNumberFrom: 1 } }
93
- // )
94
- // .lean<Pick<ISetting, 'useMongo4transactionNumberFrom'> | null>()
95
- // .exec();
96
- // }
97
- // tslint:disable-next-line:prefer-function-over-method
98
- useMongoBySettings(__) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- return true;
101
- });
102
- }
103
69
  }
104
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
  });
@@ -12,35 +12,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.validateOrder = validateOrder;
13
13
  // import * as createDebug from 'debug';
14
14
  const moment = require("moment");
15
- const util = require("util");
16
15
  const factory = require("../../factory");
17
16
  const factory_1 = require("../offer/event/authorize/factory");
18
17
  const factory_2 = require("../offer/product/factory");
19
18
  const validateMovieTicket_1 = require("../transaction/placeOrder/confirm/validation/validateMovieTicket");
20
- function createCheckEventTasks(params) {
21
- const { order, project, reservationForIds } = params;
22
- const runsAt = new Date();
23
- return reservationForIds.map((reservationForId) => {
24
- const object = { id: reservationForId, typeOf: factory.eventType.ScreeningEvent };
25
- const data = {
26
- object,
27
- project: { id: project.id, typeOf: factory.organizationType.Project },
28
- typeOf: factory.actionType.CheckAction
29
- };
30
- const description = util.format('%s:%s:%s:%s', order.typeOf, order.orderNumber, factory.eventType.ScreeningEvent, reservationForId);
31
- return {
32
- description,
33
- project: { id: project.id, typeOf: factory.organizationType.Project },
34
- name: factory.taskName.CheckResource,
35
- status: factory.taskStatus.Ready,
36
- runsAt,
37
- remainingNumberOfTries: 3,
38
- numberOfTried: 0,
39
- executionResults: [],
40
- data
41
- };
42
- });
43
- }
19
+ // const debug = createDebug('chevre-domain:service:validation');
20
+ // type ICreatingCheckEventTask = Pick<
21
+ // factory.task.checkResource.IAttributes,
22
+ // 'data' | 'executionResults' | 'name' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'status' | 'description'
23
+ // > & {
24
+ // description: string;
25
+ // };
26
+ // function createCheckEventTasks(params: {
27
+ // order: Pick<factory.order.IOrder, 'orderNumber' | 'typeOf'>;
28
+ // project: { id: string };
29
+ // reservationForIds: string[];
30
+ // }): ICreatingCheckEventTask[] {
31
+ // const { order, project, reservationForIds } = params;
32
+ // const runsAt = new Date();
33
+ // return reservationForIds.map((reservationForId) => {
34
+ // const object: factory.task.checkResource.IResourceAsEvent = { id: reservationForId, typeOf: factory.eventType.ScreeningEvent };
35
+ // const data: factory.task.checkResource.IData = {
36
+ // object,
37
+ // project: { id: project.id, typeOf: factory.organizationType.Project },
38
+ // typeOf: factory.actionType.CheckAction
39
+ // };
40
+ // const description: string = util.format(
41
+ // '%s:%s:%s:%s',
42
+ // order.typeOf,
43
+ // order.orderNumber,
44
+ // factory.eventType.ScreeningEvent,
45
+ // reservationForId
46
+ // );
47
+ // return {
48
+ // description,
49
+ // project: { id: project.id, typeOf: factory.organizationType.Project },
50
+ // name: factory.taskName.CheckResource,
51
+ // status: factory.taskStatus.Ready,
52
+ // runsAt,
53
+ // remainingNumberOfTries: 3,
54
+ // numberOfTried: 0,
55
+ // executionResults: [],
56
+ // data
57
+ // };
58
+ // });
59
+ // }
44
60
  function validateOrder(params) {
45
61
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
46
62
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -216,18 +232,20 @@ function validateOrder(params) {
216
232
  throw new Error(`invalid ticketIdentifiers.length:${reservationReservedTicketIdentifiers.length} [expected:${acceptedOffers.length}]`);
217
233
  }
218
234
  }
235
+ // useMongoAsStockHolderProjectsの場合のイベント検証タスク作成を廃止(もう十分検証したので)(2025-07-11~)
219
236
  // add check event task(2025-05-01~)
220
- const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['useMongoAsStockHolderProjects']);
221
- const useMongoAsStockHolderProjects = setting === null || setting === void 0 ? void 0 : setting.useMongoAsStockHolderProjects;
222
- if (Array.isArray(useMongoAsStockHolderProjects) && useMongoAsStockHolderProjects.includes(params.project.id)) {
223
- const creatingCheckResourceTask = createCheckEventTasks({
224
- order: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
225
- project: { id: params.project.id },
226
- reservationForIds
227
- });
228
- if (creatingCheckResourceTask.length > 0) {
229
- yield repos.task.saveMany(creatingCheckResourceTask, { emitImmediately: true });
230
- }
231
- }
237
+ // const setting = <Pick<ISetting, 'useMongoAsStockHolderProjects'> | null>
238
+ // await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['useMongoAsStockHolderProjects']);
239
+ // const useMongoAsStockHolderProjects = setting?.useMongoAsStockHolderProjects;
240
+ // if (Array.isArray(useMongoAsStockHolderProjects) && useMongoAsStockHolderProjects.includes(params.project.id)) {
241
+ // const creatingCheckResourceTask = createCheckEventTasks({
242
+ // order: { orderNumber: order.orderNumber, typeOf: factory.order.OrderType.Order },
243
+ // project: { id: params.project.id },
244
+ // reservationForIds
245
+ // });
246
+ // if (creatingCheckResourceTask.length > 0) {
247
+ // await repos.task.saveMany(creatingCheckResourceTask, { emitImmediately: true });
248
+ // }
249
+ // }
232
250
  });
233
251
  }
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.4"
116
+ "version": "22.11.0-alpha.6"
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);