@@ -14,15 +14,72 @@ import {
14
14
import { Map } from './util.js' ;
15
15
16
16
export interface Roles {
17
+ /**
18
+ * Retrieve all the roles in the system.
19
+ *
20
+ * @returns {Promise<Record<string, Role>> } A map of role names to their respective roles.
21
+ */
17
22
listAll : ( ) => Promise < Record < string , Role > > ;
23
+ /**
24
+ * Retrieve a role by its name.
25
+ *
26
+ * @param {string } roleName The name of the role to retrieve.
27
+ * @returns {Promise<Role | null> } The role if it exists, or null if it does not.
28
+ */
18
29
byName : ( roleName : string ) => Promise < Role | null > ;
30
+ /**
31
+ * Retrieve the user IDs assigned to a role.
32
+ *
33
+ * @param {string } roleName The name of the role to retrieve the assigned user IDs for.
34
+ * @returns {Promise<string[]> } The user IDs assigned to the role.
35
+ */
19
36
assignedUserIds : ( roleName : string ) => Promise < string [ ] > ;
37
+ /**
38
+ * Delete a role by its name.
39
+ *
40
+ * @param {string } roleName The name of the role to delete.
41
+ * @returns {Promise<void> } A promise that resolves when the role is deleted.
42
+ */
20
43
delete : ( roleName : string ) => Promise < void > ;
44
+ /**
45
+ * Create a new role.
46
+ *
47
+ * @param {string } roleName The name of the new role.
48
+ * @param {PermissionsInput } permissions The permissions to assign to the new role.
49
+ * @returns {Promise<Role> } The newly created role.
50
+ */
21
51
create : ( roleName : string , permissions : PermissionsInput ) => Promise < Role > ;
52
+ /**
53
+ * Check if a role exists.
54
+ *
55
+ * @param {string } roleName The name of the role to check for.
56
+ * @returns {Promise<boolean> } A promise that resolves to true if the role exists, or false if it does not.
57
+ */
22
58
exists : ( roleName : string ) => Promise < boolean > ;
59
+ /**
60
+ * Add permissions to a role.
61
+ *
62
+ * @param {string } roleName The name of the role to add permissions to.
63
+ * @param {PermissionsInput } permissions The permissions to add.
64
+ * @returns {Promise<void> } A promise that resolves when the permissions are added.
65
+ */
23
66
addPermissions : ( roleName : string , permissions : PermissionsInput ) => Promise < void > ;
67
+ /**
68
+ * Remove permissions from a role.
69
+ *
70
+ * @param {string } roleName The name of the role to remove permissions from.
71
+ * @param {PermissionsInput } permissions The permissions to remove.
72
+ * @returns {Promise<void> } A promise that resolves when the permissions are removed.
73
+ */
24
74
removePermissions : ( roleName : string , permissions : PermissionsInput ) => Promise < void > ;
25
- hasPermissions : ( roleName : string , permission : Permission ) => Promise < boolean > ;
75
+ /**
76
+ * Check if a role has the specified permissions.
77
+ *
78
+ * @param {string } roleName The name of the role to check.
79
+ * @param {Permission | Permission[] } permission The permission or permissions to check for.
80
+ * @returns {Promise<boolean> } A promise that resolves to true if the role has the permissions, or false if it does not.
81
+ */
82
+ hasPermissions : ( roleName : string , permission : Permission | Permission [ ] ) => Promise < boolean > ;
26
83
}
27
84
28
85
const roles = ( connection : ConnectionREST ) : Roles => {
0 commit comments