Skip to content

Commit 4a9a09d

Browse files
authored
feat: bypass pulling the schema field from C['schema'] MONGOSH-2170 (#552)
1 parent f4399a6 commit 4a9a09d

File tree

8 files changed

+453
-584
lines changed

8 files changed

+453
-584
lines changed

package-lock.json

Lines changed: 109 additions & 399 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mongodb-ts-autocomplete/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,25 @@
5454
},
5555
"dependencies": {
5656
"@mongodb-js/ts-autocomplete": "^0.3.3",
57+
"@mongosh/shell-api": "^3.16.2",
5758
"mongodb-schema": "^12.6.2",
5859
"node-cache": "^5.1.2",
59-
"typescript": "^5.0.4"
60+
"typescript": "^5.0.4",
61+
"debug": "^4.4.0",
62+
"lodash": "^4.17.21"
6063
},
6164
"devDependencies": {
6265
"@mongodb-js/eslint-config-devtools": "0.9.11",
6366
"@mongodb-js/mocha-config-devtools": "^1.0.5",
6467
"@mongodb-js/prettier-config-devtools": "^1.0.2",
6568
"@mongodb-js/tsconfig-devtools": "^1.0.3",
66-
"@mongosh/shell-api": "^3.13.0",
69+
"@mongodb-js/mql-typescript": "^0.2.3",
6770
"@types/chai": "^4.2.21",
6871
"@types/mocha": "^9.1.1",
6972
"@types/node": "^22.15.30",
7073
"@types/sinon-chai": "^3.2.5",
7174
"bson": "^6.10.3",
75+
"mongodb": "^6.9.0",
7276
"chai": "^4.5.0",
7377
"depcheck": "^1.4.7",
7478
"eslint": "^7.25.0",

packages/mongodb-ts-autocomplete/scripts/extract-types.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,28 @@ async function loadSources(sources: Record<string, string>) {
1515

1616
async function run() {
1717
const input: Record<string, string> = {
18+
// mql imports bson but right now so does shell-api. We could bake the types
19+
// those use into the files we generate using api-extractor, but maybe
20+
// including it just once is not so bad.
1821
'/bson.ts': path.join(require.resolve('bson'), '..', '..', 'bson.d.ts'),
19-
'/mql.ts': path.join(__dirname, '..', 'src', 'fixtures', 'mql.ts'),
22+
// mql imports the mongodb driver. We could also use api-extractor there to
23+
// bake the few mongodb types we use into the schema.
24+
'/mongodb.ts': path.join(
25+
require.resolve('mongodb'),
26+
'..',
27+
'..',
28+
'mongodb.d.ts',
29+
),
30+
// We wouldn't have to include mql if we used it straight from shell-api,
31+
// but since we're using it straight here for now to bypass the complicated
32+
// generics on the shell-api side it is included here for now.
33+
'/mql.ts': path.join(
34+
require.resolve('@mongodb-js/mql-typescript'),
35+
'..',
36+
'..',
37+
'out',
38+
'schema.d.ts',
39+
),
2040
};
2141
const files = await loadSources(input);
2242
const code = `
@@ -32,6 +52,7 @@ export default files;
3252
'autocomplete-types.ts',
3353
);
3454
console.log(filepath);
55+
await fs.mkdir(path.dirname(filepath), { recursive: true });
3556
await fs.writeFile(filepath, code, 'utf-8');
3657
}
3758

0 commit comments

Comments
 (0)