Skip to content

Commit 376b555

Browse files
committed
fix: styles
1 parent 4efb5cf commit 376b555

File tree

7 files changed

+2484
-364
lines changed

7 files changed

+2484
-364
lines changed

scripts/filter.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
2323
"createProject",
2424
"listClusters",
2525
"createCluster",
26-
"listClustersForAllProjects"
26+
"listClustersForAllProjects",
2727
];
2828

2929
const filteredPaths = {};
@@ -40,7 +40,7 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
4040
}
4141
}
4242

43-
return {...openapi, paths: filteredPaths};
43+
return { ...openapi, paths: filteredPaths };
4444
}
4545

4646
async function main() {
@@ -50,8 +50,7 @@ async function main() {
5050
console.log(JSON.stringify(filteredOpenapi));
5151
}
5252

53-
main()
54-
.catch((error) => {
55-
console.error("Error:", error);
56-
process.exit(1);
57-
});
53+
main().catch((error) => {
54+
console.error("Error:", error);
55+
process.exit(1);
56+
});

src/common/atlas/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ export async function isAuthenticated(state: State, apiClient: ApiClient): Promi
2929
default:
3030
throw new Error("Unknown authentication status");
3131
}
32-
}
32+
}

src/common/atlas/client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { log } from "console";
21
import config from "../../config.js";
32

4-
import { Group, PaginatedOrgGroupView, PaginatedAtlasGroupView, ClusterDescription20240805, PaginatedClusterDescription20240805 } from "./openapi.js"
3+
import {
4+
Group,
5+
PaginatedOrgGroupView,
6+
PaginatedAtlasGroupView,
7+
ClusterDescription20240805,
8+
PaginatedClusterDescription20240805,
9+
} from "./openapi.js";
510

611
export interface OAuthToken {
712
access_token: string;

src/common/atlas/openapi.d.ts

Lines changed: 2440 additions & 317 deletions
Large diffs are not rendered by default.

src/tools/atlas/createFreeCluster.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ export class CreateFreeClusterTool extends AtlasToolBase {
88
protected name = "atlas-create-free-cluster";
99
protected description = "Create a free MongoDB Atlas cluster";
1010
protected argsShape = {
11-
projectId: z
12-
.string()
13-
.describe("Atlas project ID to create the cluster in"),
14-
name: z.string()
15-
.describe("Name of the cluster"),
16-
region: z.string()
17-
.describe("Region of the cluster").default("US_EAST_1"),
11+
projectId: z.string().describe("Atlas project ID to create the cluster in"),
12+
name: z.string().describe("Name of the cluster"),
13+
region: z.string().describe("Region of the cluster").default("US_EAST_1"),
1814
};
1915

2016
protected async execute({ projectId, name, region }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
@@ -39,15 +35,13 @@ export class CreateFreeClusterTool extends AtlasToolBase {
3935
],
4036
},
4137
],
42-
terminationProtectionEnabled: false
38+
terminationProtectionEnabled: false,
4339
} as unknown as ClusterDescription20240805;
4440

4541
await this.apiClient.createCluster(projectId, input);
4642

4743
return {
48-
content: [
49-
{ type: "text", text: `Cluster "${name}" has been created in region "${region}".` },
50-
],
51-
}
44+
content: [{ type: "text", text: `Cluster "${name}" has been created in region "${region}".` }],
45+
};
5246
}
5347
}

src/tools/atlas/inspectCluster.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@ export class InspectClusterTool extends AtlasToolBase {
88
protected name = "atlas-inspect-cluster";
99
protected description = "Inspect MongoDB Atlas cluster";
1010
protected argsShape = {
11-
projectId: z
12-
.string()
13-
.describe("Atlas project ID"),
14-
clusterName: z
15-
.string()
16-
.describe("Atlas cluster name"),
11+
projectId: z.string().describe("Atlas project ID"),
12+
clusterName: z.string().describe("Atlas cluster name"),
1713
};
1814

1915
protected async execute({ projectId, clusterName }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2016
await this.ensureAuthenticated();
2117

2218
const cluster = await this.apiClient.getCluster(projectId, clusterName);
23-
19+
2420
return this.formatOutput(cluster);
25-
2621
}
2722

2823
private formatOutput(cluster: ClusterDescription20240805): CallToolResult {
2924
return {
3025
content: [
3126
{
32-
type: "text", text: `Cluster Name | State | MongoDB Version | Connection String
27+
type: "text",
28+
text: `Cluster Name | State | MongoDB Version | Connection String
3329
----------------|----------------|----------------|----------------|----------------
34-
${ cluster.name } | ${ cluster.stateName } | ${ cluster.mongoDBVersion || "N/A" } | ${ cluster.connectionStrings?.standard || "N/A" }` },
30+
${cluster.name} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standard || "N/A"}`,
31+
},
3532
],
3633
};
3734
}

src/tools/atlas/listClusters.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ export class ListClustersTool extends AtlasToolBase {
99
protected name = "atlas-list-clusters";
1010
protected description = "List MongoDB Atlas clusters";
1111
protected argsShape = {
12-
projectId: z
13-
.string()
14-
.describe("Atlas project ID to filter clusters")
15-
.optional(),
12+
projectId: z.string().describe("Atlas project ID to filter clusters").optional(),
1613
};
1714

1815
protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
@@ -30,7 +27,7 @@ export class ListClustersTool extends AtlasToolBase {
3027
throw new Error(`Project with ID "${selectedProjectId}" not found.`);
3128
}
3229

33-
const data = await this.apiClient.listClusters(project.id || '');
30+
const data = await this.apiClient.listClusters(project.id || "");
3431

3532
return this.formatClustersTable(project, data);
3633
}
@@ -40,8 +37,8 @@ export class ListClustersTool extends AtlasToolBase {
4037
if (!clusters.results?.length) {
4138
throw new Error("No clusters found.");
4239
}
43-
const rows = clusters.results!
44-
.map((result) => {
40+
const rows = clusters
41+
.results!.map((result) => {
4542
return (result.clusters || []).map((cluster) => {
4643
return { ...result, ...cluster, clusters: undefined };
4744
});
@@ -55,33 +52,38 @@ export class ListClustersTool extends AtlasToolBase {
5552
content: [
5653
{ type: "text", text: `Here are your MongoDB Atlas clusters:` },
5754
{
58-
type: "text", text: `Project | Cluster Name
55+
type: "text",
56+
text: `Project | Cluster Name
5957
----------------|----------------
60-
${rows}`
58+
${rows}`,
6159
},
6260
],
6361
};
6462
}
6563

66-
6764
private formatClustersTable(project: Group, clusters: PaginatedClusterDescription20240805): CallToolResult {
6865
if (!clusters.results?.length) {
6966
throw new Error("No clusters found.");
7067
}
71-
const rows = clusters.results!
72-
.map((cluster) => {
68+
const rows = clusters
69+
.results!.map((cluster) => {
7370
const connectionString = cluster.connectionStrings?.standard || "N/A";
7471
const mongoDBVersion = cluster.mongoDBVersion || "N/A";
7572
return `${cluster.name} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
7673
})
7774
.join("\n");
7875
return {
7976
content: [
80-
{ type: "text", text: `Here are your MongoDB Atlas clusters in project "${project.name}" (${project.id}):` },
8177
{
82-
type: "text", text: `Cluster Name | State | MongoDB Version | Connection String
78+
type: "text",
79+
text: `Here are your MongoDB Atlas clusters in project "${project.name}" (${project.id}):`,
80+
},
81+
{
82+
type: "text",
83+
text: `Cluster Name | State | MongoDB Version | Connection String
8384
----------------|----------------|----------------|----------------|----------------
84-
${rows}` },
85+
${rows}`,
86+
},
8587
],
8688
};
8789
}

0 commit comments

Comments
 (0)