Skip to content

feat: bypass pulling the schema field from C['schema'] MONGOSH-2170 #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
508 changes: 109 additions & 399 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions packages/mongodb-ts-autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,25 @@
},
"dependencies": {
"@mongodb-js/ts-autocomplete": "^0.3.3",
"@mongosh/shell-api": "^3.16.2",
"mongodb-schema": "^12.6.2",
"node-cache": "^5.1.2",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"debug": "^4.4.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"@mongodb-js/eslint-config-devtools": "0.9.11",
"@mongodb-js/mocha-config-devtools": "^1.0.5",
"@mongodb-js/prettier-config-devtools": "^1.0.2",
"@mongodb-js/tsconfig-devtools": "^1.0.3",
"@mongosh/shell-api": "^3.13.0",
"@mongodb-js/mql-typescript": "^0.2.3",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.1.1",
"@types/node": "^22.15.30",
"@types/sinon-chai": "^3.2.5",
"bson": "^6.10.3",
"mongodb": "^6.9.0",
"chai": "^4.5.0",
"depcheck": "^1.4.7",
"eslint": "^7.25.0",
Expand Down
23 changes: 22 additions & 1 deletion packages/mongodb-ts-autocomplete/scripts/extract-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,28 @@ async function loadSources(sources: Record<string, string>) {

async function run() {
const input: Record<string, string> = {
// mql imports bson but right now so does shell-api. We could bake the types
// those use into the files we generate using api-extractor, but maybe
// including it just once is not so bad.
'/bson.ts': path.join(require.resolve('bson'), '..', '..', 'bson.d.ts'),
'/mql.ts': path.join(__dirname, '..', 'src', 'fixtures', 'mql.ts'),
// mql imports the mongodb driver. We could also use api-extractor there to
// bake the few mongodb types we use into the schema.
'/mongodb.ts': path.join(
require.resolve('mongodb'),
'..',
'..',
'mongodb.d.ts',
),
// We wouldn't have to include mql if we used it straight from shell-api,
// but since we're using it straight here for now to bypass the complicated
// generics on the shell-api side it is included here for now.
'/mql.ts': path.join(
require.resolve('@mongodb-js/mql-typescript'),
'..',
'..',
'out',
'schema.d.ts',
),
};
const files = await loadSources(input);
const code = `
Expand All @@ -32,6 +52,7 @@ export default files;
'autocomplete-types.ts',
);
console.log(filepath);
await fs.mkdir(path.dirname(filepath), { recursive: true });
await fs.writeFile(filepath, code, 'utf-8');
}

Expand Down
Loading