Skip to content

Commit 5aa2b03

Browse files
committed
Respond to review comments
1 parent 8151e1f commit 5aa2b03

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

src/roles/index.ts

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,72 @@ import {
1414
import { Map } from './util.js';
1515

1616
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+
*/
1722
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+
*/
1829
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+
*/
1936
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+
*/
2043
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+
*/
2151
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+
*/
2258
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+
*/
2366
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+
*/
2474
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>;
2683
}
2784

2885
const roles = (connection: ConnectionREST): Roles => {

src/users/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,34 @@ import { Map } from '../roles/util.js';
55
import { User } from './types.js';
66

77
export interface Users {
8+
/**
9+
* Retrieve the information relevant to the currently authenticated user.
10+
*
11+
* @returns {Promise<User>} The user information.
12+
*/
813
getMyUser: () => Promise<User>;
14+
/**
15+
* Retrieve the roles assigned to a user.
16+
*
17+
* @param {string} userId The ID of the user to retrieve the assigned roles for.
18+
* @returns {Promise<Record<string, Role>>} A map of role names to their respective roles.
19+
*/
920
getAssignedRoles: (userId: string) => Promise<Record<string, Role>>;
21+
/**
22+
* Assign roles to a user.
23+
*
24+
* @param {string | string[]} roleNames The name or names of the roles to assign.
25+
* @param {string} userId The ID of the user to assign the roles to.
26+
* @returns {Promise<void>} A promise that resolves when the roles are assigned.
27+
*/
1028
assignRoles: (roleNames: string | string[], userId: string) => Promise<void>;
29+
/**
30+
* Revoke roles from a user.
31+
*
32+
* @param {string | string[]} roleNames The name or names of the roles to revoke.
33+
* @param {string} userId The ID of the user to revoke the roles from.
34+
* @returns {Promise<void>} A promise that resolves when the roles are revoked.
35+
*/
1136
revokeRoles: (roleNames: string | string[], userId: string) => Promise<void>;
1237
}
1338

0 commit comments

Comments
 (0)