dbgate-tools 6.6.1 → 6.6.2

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.
@@ -6,6 +6,7 @@ interface CompiledPermissions {
6
6
  levels: CompiledPermissionLevel[];
7
7
  }
8
8
  export declare function compilePermissions(permissions: string[] | string): CompiledPermissions;
9
+ export declare function getPermissionsCacheKey(permissions: string[] | string): string;
9
10
  export declare function testPermission(tested: string, permissions: CompiledPermissions): boolean;
10
11
  export declare function testSubPermission(tested: string, permissions: string[], allowSamePermission?: boolean): true | false | null;
11
12
  export declare function getPredefinedPermissions(predefinedRoleName: string): string[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sortPermissionsFromTheSameLevel = exports.getPredefinedPermissions = exports.testSubPermission = exports.testPermission = exports.compilePermissions = void 0;
6
+ exports.sortPermissionsFromTheSameLevel = exports.getPredefinedPermissions = exports.testSubPermission = exports.testPermission = exports.getPermissionsCacheKey = exports.compilePermissions = void 0;
7
7
  const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
8
8
  const isString_1 = __importDefault(require("lodash/isString"));
9
9
  const compact_1 = __importDefault(require("lodash/compact"));
@@ -48,6 +48,14 @@ function compilePermissions(permissions) {
48
48
  return res;
49
49
  }
50
50
  exports.compilePermissions = compilePermissions;
51
+ function getPermissionsCacheKey(permissions) {
52
+ if (!permissions)
53
+ return null;
54
+ if ((0, isString_1.default)(permissions))
55
+ return permissions;
56
+ return permissions.join('|');
57
+ }
58
+ exports.getPermissionsCacheKey = getPermissionsCacheKey;
51
59
  function testPermission(tested, permissions) {
52
60
  let allow = true;
53
61
  if (!permissions) {
@@ -89,9 +97,9 @@ function getPredefinedPermissions(predefinedRoleName) {
89
97
  case 'superadmin':
90
98
  return ['*', '~widgets/*', 'widgets/admin', 'widgets/database', '~all-connections'];
91
99
  case 'logged-user':
92
- return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections'];
100
+ return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections', '~run-shell-script'];
93
101
  case 'anonymous-user':
94
- return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections'];
102
+ return ['*', '~widgets/admin', '~admin/*', '~internal-storage', '~all-connections', '~run-shell-script'];
95
103
  default:
96
104
  return null;
97
105
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.6.1",
2
+ "version": "6.6.2",
3
3
  "name": "dbgate-tools",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -26,14 +26,14 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@types/node": "^13.7.0",
29
- "dbgate-types": "^6.6.1",
29
+ "dbgate-types": "^6.6.2",
30
30
  "jest": "^28.1.3",
31
31
  "ts-jest": "^28.0.7",
32
32
  "typescript": "^4.4.3"
33
33
  },
34
34
  "dependencies": {
35
35
  "dbgate-query-splitter": "^4.11.5",
36
- "dbgate-sqltree": "^6.6.1",
36
+ "dbgate-sqltree": "^6.6.2",
37
37
  "debug": "^4.3.4",
38
38
  "json-stable-stringify": "^1.0.1",
39
39
  "lodash": "^4.17.21",