@chevre/domain 22.11.0-alpha.6 → 22.11.0-alpha.7
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.
- package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +5 -2
- package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +0 -5
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -3
- package/lib/chevre/repo/stockHolder.js +0 -11
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ async function main() {
|
|
|
47
47
|
'admin.sellers.events.update',
|
|
48
48
|
'admin.sellers.orders.read',
|
|
49
49
|
'admin.sellers.reservations.read',
|
|
50
|
+
'admin.sellers.reservations.useActions.read',
|
|
50
51
|
'admin.sellers.assetTransactions.cancelReservation.write'
|
|
51
52
|
];
|
|
52
53
|
for (const roleName of roleNames) {
|
|
@@ -92,7 +93,8 @@ async function main() {
|
|
|
92
93
|
'admin.sellers.orders.read',
|
|
93
94
|
'admin.sellers.orders.update',
|
|
94
95
|
'admin.sellers.reservations.read',
|
|
95
|
-
'admin.sellers.reservations.
|
|
96
|
+
'admin.sellers.reservations.useActions.read',
|
|
97
|
+
'admin.sellers.reservations.useActions.create',
|
|
96
98
|
'admin.sellers.assetTransactions.cancelReservation.write'
|
|
97
99
|
];
|
|
98
100
|
for (const roleName of roleNames) {
|
|
@@ -110,7 +112,8 @@ async function main() {
|
|
|
110
112
|
];
|
|
111
113
|
permissions = [
|
|
112
114
|
'admin.sellers.reservations.read',
|
|
113
|
-
'admin.sellers.reservations.
|
|
115
|
+
'admin.sellers.reservations.useActions.read',
|
|
116
|
+
'admin.sellers.reservations.useActions.create'
|
|
114
117
|
];
|
|
115
118
|
for (const roleName of roleNames) {
|
|
116
119
|
for (const permission of permissions) {
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
const roleNames = [
|
|
13
|
+
chevre.factory.role.organizationRole.RoleName.Customer,
|
|
14
|
+
chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
15
|
+
chevre.factory.role.organizationRole.RoleName.POS,
|
|
16
|
+
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
|
|
17
|
+
chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
18
|
+
chevre.factory.role.organizationRole.RoleName.TicketClerk,
|
|
19
|
+
chevre.factory.role.organizationRole.RoleName.User
|
|
20
|
+
];
|
|
21
|
+
const permissions = [
|
|
22
|
+
'db.primary.read'
|
|
23
|
+
];
|
|
24
|
+
for (const roleName of roleNames) {
|
|
25
|
+
for (const permission of permissions) {
|
|
26
|
+
const result = await roleRepo.addPermissionIfNotExists({
|
|
27
|
+
roleName: { $eq: roleName },
|
|
28
|
+
permission
|
|
29
|
+
});
|
|
30
|
+
console.log('permission added.', result, roleName);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then()
|
|
37
|
+
.catch(console.error);
|
|
@@ -98,11 +98,6 @@ async function main() {
|
|
|
98
98
|
mongoose.connection
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
// const setting = await settingRepo.findOne(
|
|
102
|
-
// { project: { id: { $eq: '*' } } },
|
|
103
|
-
// ['useMongoAsStockHolder']
|
|
104
|
-
// );
|
|
105
|
-
// const useMongoAsStockHolder = setting?.useMongoAsStockHolder === true;
|
|
106
101
|
let checkingProjects: string[] = [];
|
|
107
102
|
// 全プロジェクト
|
|
108
103
|
checkingProjects = (await projectRepo.projectFields(
|
|
@@ -18,9 +18,11 @@ async function main() {
|
|
|
18
18
|
'project.id': { $eq: '*' }
|
|
19
19
|
},
|
|
20
20
|
$unset: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
useMongoAsStockHolder: 1,
|
|
22
|
+
useMongoAsStockHolderProjects: 1
|
|
23
|
+
// useMongo4confirmationNumberFrom: 1,
|
|
24
|
+
// useMongo4orderNumberFrom: 1,
|
|
25
|
+
// useMongo4transactionNumberFrom: 1
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
console.log(updateResult);
|
|
@@ -287,17 +287,6 @@ class StockHolderRepo {
|
|
|
287
287
|
throw new factory.errors.Argument('startDate', 'must be Date');
|
|
288
288
|
}
|
|
289
289
|
let useMongoose = false;
|
|
290
|
-
// useMongoAsStockHolder設定有の場合のみmongo利用(2025-04-18~)
|
|
291
|
-
// const useMongoAsStockHolderBySettings = await this.useMongoAsStockHolderBySettings({ project: { id: params.project.id } });
|
|
292
|
-
// if (useMongoAsStockHolderBySettings) {
|
|
293
|
-
// const redisKeyExists = await this.redisKeyExists(params);
|
|
294
|
-
// if (redisKeyExists) {
|
|
295
|
-
// useMongoose = false;
|
|
296
|
-
// } else {
|
|
297
|
-
// // redis keyが存在しなければmongo利用
|
|
298
|
-
// useMongoose = true;
|
|
299
|
-
// }
|
|
300
|
-
// }
|
|
301
290
|
// always use mongo(2025-05-21~)
|
|
302
291
|
const redisKeyExists = yield this.redisKeyExists(params);
|
|
303
292
|
if (redisKeyExists) {
|
package/package.json
CHANGED