@@ -55,26 +55,74 @@ export interface Users extends UsersBase {
5555/** Operations supported for namespaced 'db' users.*/
5656export interface DBUsers extends UsersBase {
5757 /**
58- * Retrieve the roles assigned to a user.
58+ * Retrieve the roles assigned to a 'db_user' user.
5959 *
6060 * @param {string } userId The ID of the user to retrieve the assigned roles for.
6161 * @returns {Promise<Record<string, Role>> } A map of role names to their respective roles.
6262 */
6363 getAssignedRoles : ( userId : string , opts ?: GetAssignedRolesOptions ) => Promise < Record < string , Role > > ;
6464
65+ /** Create a new 'db_user' user.
66+ *
67+ * @param {string } userId The ID of the user to create. Must consist of valid URL characters only.
68+ * @returns {Promise<string> } API key for the newly created user.
69+ */
6570 create : ( userId : string ) => Promise < string > ;
71+
72+ /**
73+ * Delete a 'db_user' user. It is not possible to delete 'db_env_user' users programmatically.
74+ *
75+ * @param {string } userId The ID of the user to delete.
76+ * @returns {Promise<boolean> } `true` if the user has been successfully deleted.
77+ */
6678 delete : ( userId : string ) => Promise < boolean > ;
79+
80+ /**
81+ * Rotate the API key of a 'db_user' user. The old API key becomes invalid.
82+ * API keys of 'db_env_user' users are defined in the server's environment
83+ * and cannot be modified programmatically.
84+ *
85+ * @param {string } userId The ID of the user to create a new API key for.
86+ * @returns {Promise<string> } New API key for the user.
87+ */
6788 rotateKey : ( userId : string ) => Promise < string > ;
89+
90+ /**
91+ * Activate 'db_user' user.
92+ *
93+ * @param {string } userId The ID of the user to activate.
94+ * @returns {Promise<boolean> } `true` if the user has been successfully activated.
95+ */
6896 activate : ( userId : string ) => Promise < boolean > ;
97+
98+ /**
99+ * Deactivate 'db_user' user.
100+ *
101+ * @param {string } userId The ID of the user to deactivate.
102+ * @returns {Promise<boolean> } `true` if the user has been successfully deactivated.
103+ */
69104 deactivate : ( userId : string ) => Promise < boolean > ;
105+
106+ /**
107+ * Retrieve information about the 'db_user' / 'db_env_user' user.
108+ *
109+ * @param {string } userId The ID of the user to get.
110+ * @returns {Promise<UserDB> } ID, status, and assigned roles of a 'db_*' user.
111+ */
70112 byName : ( userId : string ) => Promise < UserDB > ;
113+
114+ /**
115+ * List all 'db_user' / 'db_env_user' users.
116+ *
117+ * @returns {Promise<UserDB[]> } ID, status, and assigned roles for each 'db_*' user.
118+ */
71119 listAll : ( ) => Promise < UserDB [ ] > ;
72120}
73121
74122/** Operations supported for namespaced 'oidc' users.*/
75123export interface OIDCUsers extends UsersBase {
76124 /**
77- * Retrieve the roles assigned to a user.
125+ * Retrieve the roles assigned to an 'oidc' user.
78126 *
79127 * @param {string } userId The ID of the user to retrieve the assigned roles for.
80128 * @returns {Promise<Record<string, Role>> } A map of role names to their respective roles.
@@ -167,6 +215,7 @@ interface NamespacedUsers {
167215 revokeRoles : ( roleNames : string | string [ ] , userId : string , opts ?: AssignRevokeOptions ) => Promise < void > ;
168216}
169217
218+ /** Implementation of the operations common to 'db', 'oidc', and legacy users. */
170219const baseUsers = ( connection : ConnectionREST ) : UsersBase => {
171220 const ns = namespacedUsers ( connection ) ;
172221 return {
@@ -175,13 +224,13 @@ const baseUsers = (connection: ConnectionREST): UsersBase => {
175224 } ;
176225} ;
177226
227+ /** Implementation of the operations common to 'db' and 'oidc' users. */
178228const namespacedUsers = ( connection : ConnectionREST ) : NamespacedUsers => {
179229 return {
180230 getAssignedRoles : ( userType : UserTypeInternal , userId : string , opts ?: GetAssignedRolesOptions ) =>
181231 connection
182232 . get < WeaviateRole [ ] > (
183- `/authz/users/${ userId } /roles/${ userType } ${
184- opts ?. includePermissions ? '?&includeFullRoles=true' : ''
233+ `/authz/users/${ userId } /roles/${ userType } ${ opts ?. includePermissions ? '?&includeFullRoles=true' : ''
185234 } `
186235 )
187236 . then ( Map . roles ) ,
0 commit comments