@etsoo/appscript 1.5.91 → 1.5.93

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.
@@ -101,7 +101,7 @@ test("Tests for getRoleLabel", () => {
101
101
  test("Tests for getRoles", () => {
102
102
  const roles = app.getRoles(UserRole.User | UserRole.Manager | UserRole.Admin);
103
103
  expect(roles.length).toBe(3);
104
- expect(roles.map((r) => r.id)).toEqual([8, 128, 8192]);
104
+ expect(roles.map((r) => r.id)).toEqual([16, 128, 8192]);
105
105
  });
106
106
 
107
107
  test("Tests for getStatusList", () => {
@@ -559,7 +559,13 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
559
559
  */
560
560
  hashHex(message: string, passphrase?: string): string;
561
561
  /**
562
- * Check use has the specific role permission or not
562
+ * Check user has the minimum role permission or not
563
+ * @param role Minumum role
564
+ * @returns Result
565
+ */
566
+ hasMinPermission(role: UserRole): boolean;
567
+ /**
568
+ * Check user has the specific role permission or not
563
569
  * @param roles Roles to check
564
570
  * @returns Result
565
571
  */
@@ -575,10 +581,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
575
581
  */
576
582
  isFinanceUser(): boolean;
577
583
  /**
578
- * Is HR user
584
+ * Is Manager user
579
585
  * @returns Result
580
586
  */
581
- isHRUser(): boolean;
587
+ isManagerUser(): boolean;
582
588
  /**
583
589
  * Navigate to Url or delta
584
590
  * @param url Url or delta
@@ -1325,7 +1325,18 @@ class CoreApp {
1325
1325
  return HmacSHA512(message, passphrase).toString(enc.Hex);
1326
1326
  }
1327
1327
  /**
1328
- * Check use has the specific role permission or not
1328
+ * Check user has the minimum role permission or not
1329
+ * @param role Minumum role
1330
+ * @returns Result
1331
+ */
1332
+ hasMinPermission(role) {
1333
+ const userRole = this.userData?.role;
1334
+ if (userRole == null)
1335
+ return false;
1336
+ return userRole >= role;
1337
+ }
1338
+ /**
1339
+ * Check user has the specific role permission or not
1329
1340
  * @param roles Roles to check
1330
1341
  * @returns Result
1331
1342
  */
@@ -1346,7 +1357,7 @@ class CoreApp {
1346
1357
  * @returns Result
1347
1358
  */
1348
1359
  isAdminUser() {
1349
- return this.hasPermission([UserRole_1.UserRole.Admin, UserRole_1.UserRole.Founder]);
1360
+ return this.hasMinPermission(UserRole_1.UserRole.Admin);
1350
1361
  }
1351
1362
  /**
1352
1363
  * Is Finance user
@@ -1356,11 +1367,11 @@ class CoreApp {
1356
1367
  return this.hasPermission(UserRole_1.UserRole.Finance) || this.isAdminUser();
1357
1368
  }
1358
1369
  /**
1359
- * Is HR user
1370
+ * Is Manager user
1360
1371
  * @returns Result
1361
1372
  */
1362
- isHRUser() {
1363
- return this.hasPermission(UserRole_1.UserRole.HRManager) || this.isAdminUser();
1373
+ isManagerUser() {
1374
+ return this.hasMinPermission(UserRole_1.UserRole.Manager);
1364
1375
  }
1365
1376
  /**
1366
1377
  * Navigate to Url or delta
@@ -505,7 +505,13 @@ export interface IApp {
505
505
  */
506
506
  hashHex(message: string, passphrase?: string): string;
507
507
  /**
508
- * Check use has the specific role permission or not
508
+ * Check user has the minimum role permission or not
509
+ * @param role Minumum role
510
+ * @returns Result
511
+ */
512
+ hasMinPermission(role: UserRole): boolean;
513
+ /**
514
+ * Check user has the specific role permission or not
509
515
  * @param roles Roles to check
510
516
  * @returns Result
511
517
  */
@@ -528,10 +534,10 @@ export interface IApp {
528
534
  */
529
535
  isFinanceUser(): boolean;
530
536
  /**
531
- * Is HR user
537
+ * Is Manager user
532
538
  * @returns Result
533
539
  */
534
- isHRUser(): boolean;
540
+ isManagerUser(): boolean;
535
541
  /**
536
542
  * Is valid password, override to implement custom check
537
543
  * @param password Input password
@@ -5,38 +5,67 @@
5
5
  export declare enum UserRole {
6
6
  /**
7
7
  * Guest
8
+ * 访客
8
9
  */
9
10
  Guest = 1,
10
11
  /**
11
12
  * Outsourcing
13
+ * 外包
12
14
  */
13
15
  Outsourcing = 2,
14
16
  /**
15
17
  * Operator
18
+ * 操作员
16
19
  */
17
20
  Operator = 4,
21
+ /**
22
+ * Partner
23
+ * 渠道合作伙伴
24
+ */
25
+ Partner = 8,
18
26
  /**
19
27
  * User
28
+ * 用户
29
+ */
30
+ User = 16,
31
+ /**
32
+ * Team leader
33
+ * 团队负责人
20
34
  */
21
- User = 8,
35
+ Leader = 64,
22
36
  /**
23
37
  * Manager
38
+ * 经理
24
39
  */
25
40
  Manager = 128,
26
41
  /**
27
42
  * Finance
43
+ * 财务
28
44
  */
29
45
  Finance = 256,
30
46
  /**
31
- * HR Manager
47
+ * Executives
48
+ * 高管
49
+ */
50
+ Executive = 512,
51
+ /**
52
+ * Shareholder
53
+ * 股东
54
+ */
55
+ Shareholder = 1024,
56
+ /**
57
+ * API
58
+ * 接口
32
59
  */
33
- HRManager = 512,
60
+ API = 4096,
34
61
  /**
35
62
  * Administrator
63
+ * 管理员
36
64
  */
37
65
  Admin = 8192,
38
66
  /**
39
67
  * Founder, takes all ownership
68
+ * 创始人,所有权限
40
69
  */
41
70
  Founder = 16384
42
71
  }
@@ -9,38 +9,67 @@ var UserRole;
9
9
  (function (UserRole) {
10
10
  /**
11
11
  * Guest
12
+ * 访客
12
13
  */
13
14
  UserRole[UserRole["Guest"] = 1] = "Guest";
14
15
  /**
15
16
  * Outsourcing
17
+ * 外包
16
18
  */
17
19
  UserRole[UserRole["Outsourcing"] = 2] = "Outsourcing";
18
20
  /**
19
21
  * Operator
22
+ * 操作员
20
23
  */
21
24
  UserRole[UserRole["Operator"] = 4] = "Operator";
25
+ /**
26
+ * Partner
27
+ * 渠道合作伙伴
28
+ */
29
+ UserRole[UserRole["Partner"] = 8] = "Partner";
22
30
  /**
23
31
  * User
32
+ * 用户
33
+ */
34
+ UserRole[UserRole["User"] = 16] = "User";
35
+ /**
36
+ * Team leader
37
+ * 团队负责人
24
38
  */
25
- UserRole[UserRole["User"] = 8] = "User";
39
+ UserRole[UserRole["Leader"] = 64] = "Leader";
26
40
  /**
27
41
  * Manager
42
+ * 经理
28
43
  */
29
44
  UserRole[UserRole["Manager"] = 128] = "Manager";
30
45
  /**
31
46
  * Finance
47
+ * 财务
32
48
  */
33
49
  UserRole[UserRole["Finance"] = 256] = "Finance";
34
50
  /**
35
- * HR Manager
51
+ * Executives
52
+ * 高管
53
+ */
54
+ UserRole[UserRole["Executive"] = 512] = "Executive";
55
+ /**
56
+ * Shareholder
57
+ * 股东
58
+ */
59
+ UserRole[UserRole["Shareholder"] = 1024] = "Shareholder";
60
+ /**
61
+ * API
62
+ * 接口
36
63
  */
37
- UserRole[UserRole["HRManager"] = 512] = "HRManager";
64
+ UserRole[UserRole["API"] = 4096] = "API";
38
65
  /**
39
66
  * Administrator
67
+ * 管理员
40
68
  */
41
69
  UserRole[UserRole["Admin"] = 8192] = "Admin";
42
70
  /**
43
71
  * Founder, takes all ownership
72
+ * 创始人,所有权限
44
73
  */
45
74
  UserRole[UserRole["Founder"] = 16384] = "Founder";
46
75
  })(UserRole || (exports.UserRole = UserRole = {}));
@@ -559,7 +559,13 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
559
559
  */
560
560
  hashHex(message: string, passphrase?: string): string;
561
561
  /**
562
- * Check use has the specific role permission or not
562
+ * Check user has the minimum role permission or not
563
+ * @param role Minumum role
564
+ * @returns Result
565
+ */
566
+ hasMinPermission(role: UserRole): boolean;
567
+ /**
568
+ * Check user has the specific role permission or not
563
569
  * @param roles Roles to check
564
570
  * @returns Result
565
571
  */
@@ -575,10 +581,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
575
581
  */
576
582
  isFinanceUser(): boolean;
577
583
  /**
578
- * Is HR user
584
+ * Is Manager user
579
585
  * @returns Result
580
586
  */
581
- isHRUser(): boolean;
587
+ isManagerUser(): boolean;
582
588
  /**
583
589
  * Navigate to Url or delta
584
590
  * @param url Url or delta
@@ -1322,7 +1322,18 @@ export class CoreApp {
1322
1322
  return HmacSHA512(message, passphrase).toString(enc.Hex);
1323
1323
  }
1324
1324
  /**
1325
- * Check use has the specific role permission or not
1325
+ * Check user has the minimum role permission or not
1326
+ * @param role Minumum role
1327
+ * @returns Result
1328
+ */
1329
+ hasMinPermission(role) {
1330
+ const userRole = this.userData?.role;
1331
+ if (userRole == null)
1332
+ return false;
1333
+ return userRole >= role;
1334
+ }
1335
+ /**
1336
+ * Check user has the specific role permission or not
1326
1337
  * @param roles Roles to check
1327
1338
  * @returns Result
1328
1339
  */
@@ -1343,7 +1354,7 @@ export class CoreApp {
1343
1354
  * @returns Result
1344
1355
  */
1345
1356
  isAdminUser() {
1346
- return this.hasPermission([UserRole.Admin, UserRole.Founder]);
1357
+ return this.hasMinPermission(UserRole.Admin);
1347
1358
  }
1348
1359
  /**
1349
1360
  * Is Finance user
@@ -1353,11 +1364,11 @@ export class CoreApp {
1353
1364
  return this.hasPermission(UserRole.Finance) || this.isAdminUser();
1354
1365
  }
1355
1366
  /**
1356
- * Is HR user
1367
+ * Is Manager user
1357
1368
  * @returns Result
1358
1369
  */
1359
- isHRUser() {
1360
- return this.hasPermission(UserRole.HRManager) || this.isAdminUser();
1370
+ isManagerUser() {
1371
+ return this.hasMinPermission(UserRole.Manager);
1361
1372
  }
1362
1373
  /**
1363
1374
  * Navigate to Url or delta
@@ -505,7 +505,13 @@ export interface IApp {
505
505
  */
506
506
  hashHex(message: string, passphrase?: string): string;
507
507
  /**
508
- * Check use has the specific role permission or not
508
+ * Check user has the minimum role permission or not
509
+ * @param role Minumum role
510
+ * @returns Result
511
+ */
512
+ hasMinPermission(role: UserRole): boolean;
513
+ /**
514
+ * Check user has the specific role permission or not
509
515
  * @param roles Roles to check
510
516
  * @returns Result
511
517
  */
@@ -528,10 +534,10 @@ export interface IApp {
528
534
  */
529
535
  isFinanceUser(): boolean;
530
536
  /**
531
- * Is HR user
537
+ * Is Manager user
532
538
  * @returns Result
533
539
  */
534
- isHRUser(): boolean;
540
+ isManagerUser(): boolean;
535
541
  /**
536
542
  * Is valid password, override to implement custom check
537
543
  * @param password Input password
@@ -5,38 +5,67 @@
5
5
  export declare enum UserRole {
6
6
  /**
7
7
  * Guest
8
+ * 访客
8
9
  */
9
10
  Guest = 1,
10
11
  /**
11
12
  * Outsourcing
13
+ * 外包
12
14
  */
13
15
  Outsourcing = 2,
14
16
  /**
15
17
  * Operator
18
+ * 操作员
16
19
  */
17
20
  Operator = 4,
21
+ /**
22
+ * Partner
23
+ * 渠道合作伙伴
24
+ */
25
+ Partner = 8,
18
26
  /**
19
27
  * User
28
+ * 用户
29
+ */
30
+ User = 16,
31
+ /**
32
+ * Team leader
33
+ * 团队负责人
20
34
  */
21
- User = 8,
35
+ Leader = 64,
22
36
  /**
23
37
  * Manager
38
+ * 经理
24
39
  */
25
40
  Manager = 128,
26
41
  /**
27
42
  * Finance
43
+ * 财务
28
44
  */
29
45
  Finance = 256,
30
46
  /**
31
- * HR Manager
47
+ * Executives
48
+ * 高管
49
+ */
50
+ Executive = 512,
51
+ /**
52
+ * Shareholder
53
+ * 股东
54
+ */
55
+ Shareholder = 1024,
56
+ /**
57
+ * API
58
+ * 接口
32
59
  */
33
- HRManager = 512,
60
+ API = 4096,
34
61
  /**
35
62
  * Administrator
63
+ * 管理员
36
64
  */
37
65
  Admin = 8192,
38
66
  /**
39
67
  * Founder, takes all ownership
68
+ * 创始人,所有权限
40
69
  */
41
70
  Founder = 16384
42
71
  }
@@ -6,38 +6,67 @@ export var UserRole;
6
6
  (function (UserRole) {
7
7
  /**
8
8
  * Guest
9
+ * 访客
9
10
  */
10
11
  UserRole[UserRole["Guest"] = 1] = "Guest";
11
12
  /**
12
13
  * Outsourcing
14
+ * 外包
13
15
  */
14
16
  UserRole[UserRole["Outsourcing"] = 2] = "Outsourcing";
15
17
  /**
16
18
  * Operator
19
+ * 操作员
17
20
  */
18
21
  UserRole[UserRole["Operator"] = 4] = "Operator";
22
+ /**
23
+ * Partner
24
+ * 渠道合作伙伴
25
+ */
26
+ UserRole[UserRole["Partner"] = 8] = "Partner";
19
27
  /**
20
28
  * User
29
+ * 用户
30
+ */
31
+ UserRole[UserRole["User"] = 16] = "User";
32
+ /**
33
+ * Team leader
34
+ * 团队负责人
21
35
  */
22
- UserRole[UserRole["User"] = 8] = "User";
36
+ UserRole[UserRole["Leader"] = 64] = "Leader";
23
37
  /**
24
38
  * Manager
39
+ * 经理
25
40
  */
26
41
  UserRole[UserRole["Manager"] = 128] = "Manager";
27
42
  /**
28
43
  * Finance
44
+ * 财务
29
45
  */
30
46
  UserRole[UserRole["Finance"] = 256] = "Finance";
31
47
  /**
32
- * HR Manager
48
+ * Executives
49
+ * 高管
50
+ */
51
+ UserRole[UserRole["Executive"] = 512] = "Executive";
52
+ /**
53
+ * Shareholder
54
+ * 股东
55
+ */
56
+ UserRole[UserRole["Shareholder"] = 1024] = "Shareholder";
57
+ /**
58
+ * API
59
+ * 接口
33
60
  */
34
- UserRole[UserRole["HRManager"] = 512] = "HRManager";
61
+ UserRole[UserRole["API"] = 4096] = "API";
35
62
  /**
36
63
  * Administrator
64
+ * 管理员
37
65
  */
38
66
  UserRole[UserRole["Admin"] = 8192] = "Admin";
39
67
  /**
40
68
  * Founder, takes all ownership
69
+ * 创始人,所有权限
41
70
  */
42
71
  UserRole[UserRole["Founder"] = 16384] = "Founder";
43
72
  })(UserRole || (UserRole = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.91",
3
+ "version": "1.5.93",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "homepage": "https://github.com/ETSOO/AppScript#readme",
37
37
  "dependencies": {
38
- "@etsoo/notificationbase": "^1.1.56",
39
- "@etsoo/restclient": "^1.1.19",
40
- "@etsoo/shared": "^1.2.58",
38
+ "@etsoo/notificationbase": "^1.1.57",
39
+ "@etsoo/restclient": "^1.1.21",
40
+ "@etsoo/shared": "^1.2.59",
41
41
  "crypto-js": "^4.2.0"
42
42
  },
43
43
  "devDependencies": {
@@ -50,6 +50,6 @@
50
50
  "@vitejs/plugin-react": "^4.3.4",
51
51
  "jsdom": "^26.0.0",
52
52
  "typescript": "^5.7.3",
53
- "vitest": "^3.0.2"
53
+ "vitest": "^3.0.3"
54
54
  }
55
55
  }
@@ -1828,7 +1828,18 @@ export abstract class CoreApp<
1828
1828
  }
1829
1829
 
1830
1830
  /**
1831
- * Check use has the specific role permission or not
1831
+ * Check user has the minimum role permission or not
1832
+ * @param role Minumum role
1833
+ * @returns Result
1834
+ */
1835
+ hasMinPermission(role: UserRole) {
1836
+ const userRole = this.userData?.role;
1837
+ if (userRole == null) return false;
1838
+ return userRole >= role;
1839
+ }
1840
+
1841
+ /**
1842
+ * Check user has the specific role permission or not
1832
1843
  * @param roles Roles to check
1833
1844
  * @returns Result
1834
1845
  */
@@ -1851,7 +1862,7 @@ export abstract class CoreApp<
1851
1862
  * @returns Result
1852
1863
  */
1853
1864
  isAdminUser() {
1854
- return this.hasPermission([UserRole.Admin, UserRole.Founder]);
1865
+ return this.hasMinPermission(UserRole.Admin);
1855
1866
  }
1856
1867
 
1857
1868
  /**
@@ -1863,11 +1874,11 @@ export abstract class CoreApp<
1863
1874
  }
1864
1875
 
1865
1876
  /**
1866
- * Is HR user
1877
+ * Is Manager user
1867
1878
  * @returns Result
1868
1879
  */
1869
- isHRUser() {
1870
- return this.hasPermission(UserRole.HRManager) || this.isAdminUser();
1880
+ isManagerUser() {
1881
+ return this.hasMinPermission(UserRole.Manager);
1871
1882
  }
1872
1883
 
1873
1884
  /**
package/src/app/IApp.ts CHANGED
@@ -668,7 +668,14 @@ export interface IApp {
668
668
  hashHex(message: string, passphrase?: string): string;
669
669
 
670
670
  /**
671
- * Check use has the specific role permission or not
671
+ * Check user has the minimum role permission or not
672
+ * @param role Minumum role
673
+ * @returns Result
674
+ */
675
+ hasMinPermission(role: UserRole): boolean;
676
+
677
+ /**
678
+ * Check user has the specific role permission or not
672
679
  * @param roles Roles to check
673
680
  * @returns Result
674
681
  */
@@ -698,10 +705,10 @@ export interface IApp {
698
705
  isFinanceUser(): boolean;
699
706
 
700
707
  /**
701
- * Is HR user
708
+ * Is Manager user
702
709
  * @returns Result
703
710
  */
704
- isHRUser(): boolean;
711
+ isManagerUser(): boolean;
705
712
 
706
713
  /**
707
714
  * Is valid password, override to implement custom check
@@ -5,46 +5,79 @@
5
5
  export enum UserRole {
6
6
  /**
7
7
  * Guest
8
+ * 访客
8
9
  */
9
10
  Guest = 1,
10
11
 
11
12
  /**
12
13
  * Outsourcing
14
+ * 外包
13
15
  */
14
16
  Outsourcing = 2,
15
17
 
16
18
  /**
17
19
  * Operator
20
+ * 操作员
18
21
  */
19
22
  Operator = 4,
20
23
 
24
+ /**
25
+ * Partner
26
+ * 渠道合作伙伴
27
+ */
28
+ Partner = 8,
29
+
21
30
  /**
22
31
  * User
32
+ * 用户
33
+ */
34
+ User = 16,
35
+
36
+ /**
37
+ * Team leader
38
+ * 团队负责人
23
39
  */
24
- User = 8,
40
+ Leader = 64,
25
41
 
26
42
  /**
27
43
  * Manager
44
+ * 经理
28
45
  */
29
46
  Manager = 128,
30
47
 
31
48
  /**
32
49
  * Finance
50
+ * 财务
33
51
  */
34
52
  Finance = 256,
35
53
 
36
54
  /**
37
- * HR Manager
55
+ * Executives
56
+ * 高管
57
+ */
58
+ Executive = 512,
59
+
60
+ /**
61
+ * Shareholder
62
+ * 股东
63
+ */
64
+ Shareholder = 1024,
65
+
66
+ /**
67
+ * API
68
+ * 接口
38
69
  */
39
- HRManager = 512,
70
+ API = 4096,
40
71
 
41
72
  /**
42
73
  * Administrator
74
+ * 管理员
43
75
  */
44
76
  Admin = 8192,
45
77
 
46
78
  /**
47
79
  * Founder, takes all ownership
80
+ * 创始人,所有权限
48
81
  */
49
82
  Founder = 16384
50
83
  }