Skip to content

Commit aed3bba

Browse files
committed
fix: styles
1 parent c862f5c commit aed3bba

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

src/tools/atlas/createDBUser.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,28 @@ export class CreateDBUserTool extends AtlasToolBase {
1111
projectId: z.string().describe("Atlas project ID"),
1212
username: z.string().describe("Username for the new user"),
1313
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(),
2027
};
2128

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> {
2336
await this.ensureAuthenticated();
2437

2538
const input = {
@@ -32,18 +45,18 @@ export class CreateDBUserTool extends AtlasToolBase {
3245
username,
3346
password,
3447
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,
3954
} as CloudDatabaseUser;
40-
55+
4156
await this.apiClient!.createDatabaseUser(projectId, input);
4257

4358
return {
44-
content: [
45-
{ type: "text", text: `User "${username}" created sucessfully.` },
46-
],
59+
content: [{ type: "text", text: `User "${username}" created sucessfully.` }],
4760
};
4861
}
4962
}
@@ -52,12 +65,14 @@ function formatRoles(roles?: DatabaseUserRole[]) {
5265
if (!roles?.length) {
5366
return "N/A";
5467
}
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(", ");
5671
}
5772

5873
function formatScopes(scopes?: UserScope[]) {
5974
if (!scopes?.length) {
6075
return "All";
6176
}
62-
return scopes.map(scope => `${scope.type}:${scope.name}`).join(", ");
77+
return scopes.map((scope) => `${scope.type}:${scope.name}`).join(", ");
6378
}

src/tools/atlas/listDBUsers.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ export class ListDBUsersTool extends AtlasToolBase {
2020
throw new Error("No database users found.");
2121
}
2222

23-
const output = `Username | Roles | Scopes
23+
const output =
24+
`Username | Roles | Scopes
2425
----------------|----------------|----------------
25-
` + data.results
26-
.map((user) => {
27-
return `${user.username} | ${formatRoles(user.roles) } | ${formatScopes(user.scopes)}`;
28-
})
29-
.join("\n");
26+
` +
27+
data.results
28+
.map((user) => {
29+
return `${user.username} | ${formatRoles(user.roles)} | ${formatScopes(user.scopes)}`;
30+
})
31+
.join("\n");
3032
return {
31-
content: [
32-
{ type: "text", text: output },
33-
],
33+
content: [{ type: "text", text: output }],
3434
};
3535
}
3636
}
@@ -39,12 +39,17 @@ function formatRoles(roles?: DatabaseUserRole[]) {
3939
if (!roles?.length) {
4040
return "N/A";
4141
}
42-
return roles.map(role => `${role.roleName}${role.databaseName ? `@${role.databaseName}${role.collectionName ? `:${role.collectionName}` : ""}` : ""}`).join(", ");
42+
return roles
43+
.map(
44+
(role) =>
45+
`${role.roleName}${role.databaseName ? `@${role.databaseName}${role.collectionName ? `:${role.collectionName}` : ""}` : ""}`
46+
)
47+
.join(", ");
4348
}
4449

4550
function formatScopes(scopes?: UserScope[]) {
4651
if (!scopes?.length) {
4752
return "All";
4853
}
49-
return scopes.map(scope => `${scope.type}:${scope.name}`).join(", ");
54+
return scopes.map((scope) => `${scope.type}:${scope.name}`).join(", ");
5055
}

0 commit comments

Comments
 (0)