From e9a41275bc47e037234b8567c5f28245a6513427 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 10 Apr 2025 12:17:56 +0100 Subject: [PATCH 1/4] chore: refactor package.json import --- src/common/atlas/auth.ts | 4 ++-- src/config.ts | 9 +-------- src/tools/mongodb/connect.ts | 2 +- src/types/mongodb-redact.d.ts | 5 +++++ tsconfig.json | 13 +++++++++---- 5 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/types/mongodb-redact.d.ts diff --git a/src/common/atlas/auth.ts b/src/common/atlas/auth.ts index baeaf1ef6..316180006 100644 --- a/src/common/atlas/auth.ts +++ b/src/common/atlas/auth.ts @@ -1,5 +1,5 @@ -import { ApiClient } from "./apiClient"; -import { State } from "../../state"; +import { ApiClient } from "./apiClient.js"; +import { State } from "../../state.js"; export async function ensureAuthenticated(state: State, apiClient: ApiClient): Promise { if (!(await isAuthenticated(state, apiClient))) { diff --git a/src/config.ts b/src/config.ts index 5972fadf5..e9be53f58 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,13 +1,6 @@ import path from "path"; -import fs from "fs"; -import { fileURLToPath } from "url"; import os from "os"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -const packageMetadata = fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"); -const packageJson = JSON.parse(packageMetadata); +import packageJson from "../package.json" with { type: "json" }; export const config = { atlasApiVersion: `2025-03-12`, diff --git a/src/tools/mongodb/connect.ts b/src/tools/mongodb/connect.ts index 65e6b5c1b..763584543 100644 --- a/src/tools/mongodb/connect.ts +++ b/src/tools/mongodb/connect.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { NodeDriverServiceProvider } from "@mongosh/service-provider-node-driver"; import { DbOperationType, MongoDBToolBase } from "./mongodbTool.js"; -import { ToolArgs } from "../tool"; +import { ToolArgs } from "../tool.js"; import { ErrorCodes, MongoDBError } from "../../errors.js"; export class ConnectTool extends MongoDBToolBase { diff --git a/src/types/mongodb-redact.d.ts b/src/types/mongodb-redact.d.ts new file mode 100644 index 000000000..5e3b36154 --- /dev/null +++ b/src/types/mongodb-redact.d.ts @@ -0,0 +1,5 @@ + +declare module 'mongodb-redact' { + function redact(message: T): T; + export default redact; +} diff --git a/tsconfig.json b/tsconfig.json index d52200780..d5e2ca089 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,20 @@ { "compilerOptions": { "target": "es2020", - "module": "esnext", - "moduleResolution": "node", + "module": "nodenext", + "moduleResolution": "nodenext", "rootDir": "./src", "outDir": "./dist", "strict": true, "esModuleInterop": true, "types": ["node"], "sourceMap": true, - "skipLibCheck": true + "skipLibCheck": true, + "resolveJsonModule": true, + "typeRoots": [ + "./node_modules/@types", + "./src/types" + ], }, - "include": ["src/**/*.ts"] + "include": ["src/**/*.ts", "package.json"], } From b22652560b1ce3708dd8ae90c4dc1ee80442c1ce Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 10 Apr 2025 12:20:06 +0100 Subject: [PATCH 2/4] fix: tsconfig --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index d5e2ca089..1f56fc863 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,5 @@ "./src/types" ], }, - "include": ["src/**/*.ts", "package.json"], + "include": ["src/**/*.ts"], } From 7a68e657167939b2ed0b8664422a81875db53c02 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 10 Apr 2025 12:24:13 +0100 Subject: [PATCH 3/4] fix: styles --- src/types/mongodb-redact.d.ts | 3 +-- tsconfig.json | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/types/mongodb-redact.d.ts b/src/types/mongodb-redact.d.ts index 5e3b36154..df8801439 100644 --- a/src/types/mongodb-redact.d.ts +++ b/src/types/mongodb-redact.d.ts @@ -1,5 +1,4 @@ - -declare module 'mongodb-redact' { +declare module "mongodb-redact" { function redact(message: T): T; export default redact; } diff --git a/tsconfig.json b/tsconfig.json index 1f56fc863..9ad6d16b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,10 +11,7 @@ "sourceMap": true, "skipLibCheck": true, "resolveJsonModule": true, - "typeRoots": [ - "./node_modules/@types", - "./src/types" - ], + "typeRoots": ["./node_modules/@types", "./src/types"] }, - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts"] } From b3e37e740712a62275f7f700f436aecd4ca6b934 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 10 Apr 2025 12:38:19 +0100 Subject: [PATCH 4/4] fix: address comments --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 9ad6d16b3..a195f8592 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "sourceMap": true, "skipLibCheck": true, "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, "typeRoots": ["./node_modules/@types", "./src/types"] }, "include": ["src/**/*.ts"]