@@ -11,15 +11,28 @@ export class CreateDBUserTool extends AtlasToolBase {
11
11
projectId : z . string ( ) . describe ( "Atlas project ID" ) ,
12
12
username : z . string ( ) . describe ( "Username for the new user" ) ,
13
13
password : z . string ( ) . describe ( "Password for the new user" ) ,
14
- roles : z . array ( z . object ( {
15
- roleName : z . string ( ) . describe ( "Role name" ) ,
16
- databaseName : z . string ( ) . describe ( "Database name" ) . default ( "admin" ) ,
17
- collectionName : z . string ( ) . describe ( "Collection name" ) . optional ( ) ,
18
- } ) ) . describe ( "Roles for the new user" ) ,
19
- clusters : z . array ( z . string ( ) ) . describe ( "Clusters to assign the user to, leave empty for access to all clusters" ) . optional ( ) ,
14
+ roles : z
15
+ . array (
16
+ z . object ( {
17
+ roleName : z . string ( ) . describe ( "Role name" ) ,
18
+ databaseName : z . string ( ) . describe ( "Database name" ) . default ( "admin" ) ,
19
+ collectionName : z . string ( ) . describe ( "Collection name" ) . optional ( ) ,
20
+ } )
21
+ )
22
+ . describe ( "Roles for the new user" ) ,
23
+ clusters : z
24
+ . array ( z . string ( ) )
25
+ . describe ( "Clusters to assign the user to, leave empty for access to all clusters" )
26
+ . optional ( ) ,
20
27
} ;
21
28
22
- protected async execute ( { projectId, username, password, roles, clusters } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
29
+ protected async execute ( {
30
+ projectId,
31
+ username,
32
+ password,
33
+ roles,
34
+ clusters,
35
+ } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
23
36
await this . ensureAuthenticated ( ) ;
24
37
25
38
const input = {
@@ -32,18 +45,18 @@ export class CreateDBUserTool extends AtlasToolBase {
32
45
username,
33
46
password,
34
47
roles : roles as unknown as DatabaseUserRole [ ] ,
35
- scopes : clusters ?. length ? clusters . map ( cluster => ( {
36
- type : "CLUSTER" ,
37
- name : cluster ,
38
- } ) ) : undefined ,
48
+ scopes : clusters ?. length
49
+ ? clusters . map ( ( cluster ) => ( {
50
+ type : "CLUSTER" ,
51
+ name : cluster ,
52
+ } ) )
53
+ : undefined ,
39
54
} as CloudDatabaseUser ;
40
-
55
+
41
56
await this . apiClient ! . createDatabaseUser ( projectId , input ) ;
42
57
43
58
return {
44
- content : [
45
- { type : "text" , text : `User "${ username } " created sucessfully.` } ,
46
- ] ,
59
+ content : [ { type : "text" , text : `User "${ username } " created sucessfully.` } ] ,
47
60
} ;
48
61
}
49
62
}
@@ -52,12 +65,14 @@ function formatRoles(roles?: DatabaseUserRole[]) {
52
65
if ( ! roles ?. length ) {
53
66
return "N/A" ;
54
67
}
55
- return roles . map ( role => `${ role . roleName } @${ role . databaseName } ${ role . collectionName ? `:${ role . collectionName } ` : "" } ` ) . join ( ", " ) ;
68
+ return roles
69
+ . map ( ( role ) => `${ role . roleName } @${ role . databaseName } ${ role . collectionName ? `:${ role . collectionName } ` : "" } ` )
70
+ . join ( ", " ) ;
56
71
}
57
72
58
73
function formatScopes ( scopes ?: UserScope [ ] ) {
59
74
if ( ! scopes ?. length ) {
60
75
return "All" ;
61
76
}
62
- return scopes . map ( scope => `${ scope . type } :${ scope . name } ` ) . join ( ", " ) ;
77
+ return scopes . map ( ( scope ) => `${ scope . type } :${ scope . name } ` ) . join ( ", " ) ;
63
78
}
0 commit comments