Skip to content

Commit 22c3d0c

Browse files
gribnoysupnbbeeken
authored andcommitted
fix public interfaces in compass-web
1 parent c392ead commit 22c3d0c

File tree

4 files changed

+153
-186
lines changed

4 files changed

+153
-186
lines changed

packages/compass-connections/src/stores/store-context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function getConnectionsActions(dispatch: ConnectionsStore['dispatch']) {
117117
return dispatch(saveEditedConnectionInfo(connectionInfo));
118118
},
119119
cancelEditConnection: (connectionId: ConnectionId) => {
120-
return dispatch(cancelEditConnection(connectionId));
120+
dispatch(cancelEditConnection(connectionId));
121121
},
122122
toggleFavoritedConnectionStatus: (connectionId: ConnectionId) => {
123123
return dispatch(toggleConnectionFavoritedStatus(connectionId));

packages/compass-web/api-extractor.json

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,34 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"mainEntryPointFilePath": "./dist/index.d.ts",
44
"bundledPackages": [
5-
"@mongodb-js/compass-workspaces",
6-
"@mongodb-js/compass-telemetry",
7-
"@mongodb-js/compass-connections",
8-
"@mongodb-js/compass-app-registry",
9-
"@mongodb-js/connection-info",
10-
"@mongodb-js/connection-storage",
11-
"@mongodb-js/compass-logging",
12-
"@mongodb-js/compass-app-stores",
13-
"@mongodb-js/compass-user-data",
14-
"@mongodb-js/compass-utils",
15-
"@mongodb-js/devtools-connect",
16-
"@mongodb-js/devtools-proxy-support",
17-
"@mongodb-js/oidc-plugin",
18-
"@mongodb-js/mdb-experiment-js",
5+
"@mongodb-js/*",
6+
"bson-transpilers",
7+
"compass-e2e-tests",
198
"compass-preferences-model",
20-
"mongodb-data-service",
9+
"hadron-build",
10+
"hadron-document",
11+
"hadron-ipc",
12+
"hadron-type-checker",
2113
"mongodb-instance-model",
22-
"mongodb-log-writer",
23-
"mongodb-collection-model",
14+
"mongodb-explain-compat",
15+
"mongodb-query-util",
16+
"mongodb-data-service",
2417
"mongodb-database-model",
25-
"mongodb",
26-
"bson",
27-
"mongodb-connection-string-url",
28-
"zod"
18+
"mongodb-collection-model",
19+
"mongodb-compass"
2920
],
3021
"compiler": {
3122
"tsconfigFilePath": "./tsconfig-build.json"
3223
},
33-
"apiReport": {
34-
"enabled": false
35-
},
36-
"docModel": {
37-
"enabled": false
38-
},
3924
"dtsRollup": {
4025
"enabled": true,
41-
"untrimmedFilePath": "./dist/index.bundled.d.ts",
42-
"publicTrimmedFilePath": "./dist/index.bundled.d.ts",
43-
"omitTrimmingComments": true,
44-
"betaTrimmedFilePath": "./dist/index.bundled.d.ts"
26+
"untrimmedFilePath": "./dist/index.untrimmed.d.ts",
27+
"publicTrimmedFilePath": "./dist/index.public.d.ts"
4528
},
46-
"tsdocMetadata": {
29+
"apiReport": {
4730
"enabled": false
4831
},
49-
"messages": {
50-
"compilerMessageReporting": {
51-
"default": {
52-
"logLevel": "warning"
53-
}
54-
},
55-
"extractorMessageReporting": {
56-
"default": {
57-
"logLevel": "warning"
58-
},
59-
"ae-missing-release-tag": {
60-
"logLevel": "none"
61-
},
62-
"ae-unresolved-link": {
63-
"logLevel": "none"
64-
},
65-
"ae-forgotten-export": {
66-
"logLevel": "none"
67-
}
68-
},
69-
"tsdocMessageReporting": {
70-
"default": {
71-
"logLevel": "none"
72-
}
73-
}
32+
"docModel": {
33+
"enabled": false
7434
}
7535
}
Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,123 @@
1-
#!/usr/bin/env node
2-
3-
const fs = require('fs');
4-
const path = require('path');
5-
6-
const typesFile = path.join(__dirname, '../dist/index.d.ts');
7-
let content = fs.readFileSync(typesFile, 'utf8');
8-
9-
// eslint-disable-next-line no-console
10-
console.log('Starting comprehensive cleanup of bundled types...');
11-
12-
// Count initial problematic imports
13-
const initialWhatwgMatches = (content.match(/whatwg-url/g) || []).length;
14-
const initialEventEmitterMatches = (content.match(/eventemitter3/g) || [])
15-
.length;
16-
const initialRelativeMatches = (content.match(/^import.*from.*['"]\./gm) || [])
17-
.length;
18-
const initialMongoJsMatches = (content.match(/from\s+['"]@mongodb-js\//g) || [])
19-
.length;
20-
21-
// eslint-disable-next-line no-console
22-
console.log(
23-
`Initial counts - whatwg-url: ${initialWhatwgMatches}, eventemitter3: ${initialEventEmitterMatches}, relative imports: ${initialRelativeMatches}, @mongodb-js imports: ${initialMongoJsMatches}`
24-
);
25-
26-
// 1. Remove whatwg-url imports and replace references
27-
content = content.replace(
28-
/import\s*\{\s*URL\s*as\s*URL_2\s*\}\s*from\s*['"]whatwg-url['"];\s*\n?/g,
29-
''
30-
);
31-
content = content.replace(
32-
/import\s*\{\s*URL\s*\}\s*from\s*['"]whatwg-url['"];\s*\n?/g,
33-
''
34-
);
35-
content = content.replace(/\bURL_2\b/g, 'URL');
36-
37-
// 2. Remove eventemitter3 imports and replace with Node.js EventEmitter
38-
content = content.replace(
39-
/import\s*\{\s*default\s+as\s+EventEmitter_2\s*\}\s*from\s*['"]eventemitter3['"];\s*\n?/g,
40-
''
41-
);
42-
content = content.replace(
43-
/import\s*\{\s*EventEmitter\s*\}\s*from\s*['"]eventemitter3['"];\s*\n?/g,
44-
''
45-
);
46-
content = content.replace(
47-
/import\s*EventEmitter\s*from\s*['"]eventemitter3['"];\s*\n?/g,
48-
''
49-
);
50-
content = content.replace(/\bEventEmitter_2\b/g, 'NodeJS.EventEmitter');
51-
52-
// 3. Fix duplicate type references (remove _2, _3, etc. suffixes)
53-
content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_2\b/g, '$1');
54-
content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_3\b/g, '$1');
55-
content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_4\b/g, '$1');
56-
57-
// 4. Remove relative imports that API Extractor couldn't resolve
58-
content = content.replace(/^import.*from\s*['"][./].*['"];\s*\n?/gm, '');
59-
60-
// 5. Remove remaining @mongodb-js imports that weren't bundled (deep path imports)
61-
content = content.replace(
62-
/^import\s+\{[^}]+\}\s+from\s+['"]@mongodb-js\/[^'"]+['"];\s*\n?/gm,
63-
''
64-
);
65-
content = content.replace(
66-
/^import\s+[^{][^;]+from\s+['"]@mongodb-js\/[^'"]+['"];\s*\n?/gm,
67-
''
68-
);
69-
70-
// 6. Fix ambient context issues by removing statements in declare blocks
71-
content = content.replace(
72-
/declare\s+namespace\s+[^{]+\s*\{[^}]*\bexport\s*\{[^}]*\}\s*;?\s*([^}]*)\}/g,
73-
(match) => {
74-
// Remove export statements from within declare namespace blocks
75-
return match.replace(/export\s*\{[^}]*\}\s*;?\s*/g, '');
76-
}
77-
);
78-
79-
// 7. Fix event emitter method return types
80-
content = content.replace(
81-
/(\s+)(on|off|removeListener)\([^)]*\):\s*any;/g,
82-
'$1$2(...args: any[]): this;'
83-
);
84-
85-
// 8. Remove problematic type assertions and fix generic types
86-
content = content.replace(/: AppRegistry<[^>]*>/g, ': AppRegistry');
87-
88-
// 9. Fix module resolution issues for mongodb-log-writer
89-
content = content.replace(
90-
/from\s*['"]mongodb-log-writer\/mongo-log-writer['"]/g,
91-
"from 'mongodb-log-writer'"
92-
);
93-
94-
// 10. Remove or fix value/type confusion
95-
content = content.replace(
96-
/(\s+)([a-zA-Z_][a-zA-Z0-9_]*)\s+refers\s+to\s+a\s+value.*?Did you mean typeof.*?\n/g,
97-
''
98-
);
99-
100-
// 11. Add necessary imports at the top if we reference Node.js types
101-
if (
102-
content.includes('NodeJS.EventEmitter') &&
103-
!content.includes('/// <reference types="node" />')
104-
) {
105-
content = '/// <reference types="node" />\n' + content;
106-
}
107-
108-
// Count final problematic imports
109-
const finalWhatwgMatches = (content.match(/whatwg-url/g) || []).length;
110-
const finalEventEmitterMatches = (content.match(/eventemitter3/g) || []).length;
111-
const finalRelativeMatches = (content.match(/^import.*from.*['"]\./gm) || [])
112-
.length;
113-
const finalMongoJsMatches = (content.match(/from\s+['"]@mongodb-js\//g) || [])
114-
.length;
115-
116-
// eslint-disable-next-line no-console
117-
console.log(
118-
`Final counts - whatwg-url: ${finalWhatwgMatches}, eventemitter3: ${finalEventEmitterMatches}, relative imports: ${finalRelativeMatches}, @mongodb-js imports: ${finalMongoJsMatches}`
119-
);
120-
121-
fs.writeFileSync(typesFile, content);
122-
// eslint-disable-next-line no-console
123-
console.log('Successfully cleaned up bundled types file');
1+
// #!/usr/bin/env node
2+
3+
// const fs = require('fs');
4+
// const path = require('path');
5+
6+
// const typesFile = path.join(__dirname, '../dist/index.d.ts');
7+
// let content = fs.readFileSync(typesFile, 'utf8');
8+
9+
// // eslint-disable-next-line no-console
10+
// console.log('Starting comprehensive cleanup of bundled types...');
11+
12+
// // Count initial problematic imports
13+
// const initialWhatwgMatches = (content.match(/whatwg-url/g) || []).length;
14+
// const initialEventEmitterMatches = (content.match(/eventemitter3/g) || [])
15+
// .length;
16+
// const initialRelativeMatches = (content.match(/^import.*from.*['"]\./gm) || [])
17+
// .length;
18+
// const initialMongoJsMatches = (content.match(/from\s+['"]@mongodb-js\//g) || [])
19+
// .length;
20+
21+
// // eslint-disable-next-line no-console
22+
// console.log(
23+
// `Initial counts - whatwg-url: ${initialWhatwgMatches}, eventemitter3: ${initialEventEmitterMatches}, relative imports: ${initialRelativeMatches}, @mongodb-js imports: ${initialMongoJsMatches}`
24+
// );
25+
26+
// // 1. Remove whatwg-url imports and replace references
27+
// content = content.replace(
28+
// /import\s*\{\s*URL\s*as\s*URL_2\s*\}\s*from\s*['"]whatwg-url['"];\s*\n?/g,
29+
// ''
30+
// );
31+
// content = content.replace(
32+
// /import\s*\{\s*URL\s*\}\s*from\s*['"]whatwg-url['"];\s*\n?/g,
33+
// ''
34+
// );
35+
// content = content.replace(/\bURL_2\b/g, 'URL');
36+
37+
// // 2. Remove eventemitter3 imports and replace with Node.js EventEmitter
38+
// content = content.replace(
39+
// /import\s*\{\s*default\s+as\s+EventEmitter_2\s*\}\s*from\s*['"]eventemitter3['"];\s*\n?/g,
40+
// ''
41+
// );
42+
// content = content.replace(
43+
// /import\s*\{\s*EventEmitter\s*\}\s*from\s*['"]eventemitter3['"];\s*\n?/g,
44+
// ''
45+
// );
46+
// content = content.replace(
47+
// /import\s*EventEmitter\s*from\s*['"]eventemitter3['"];\s*\n?/g,
48+
// ''
49+
// );
50+
// content = content.replace(/\bEventEmitter_2\b/g, 'NodeJS.EventEmitter');
51+
52+
// // 3. Fix duplicate type references (remove _2, _3, etc. suffixes)
53+
// content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_2\b/g, '$1');
54+
// content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_3\b/g, '$1');
55+
// content = content.replace(/\b([A-Za-z_][A-Za-z0-9_]*?)_4\b/g, '$1');
56+
57+
// // 4. Remove relative imports that API Extractor couldn't resolve
58+
// content = content.replace(/^import.*from\s*['"][./].*['"];\s*\n?/gm, '');
59+
60+
// // 5. Remove remaining @mongodb-js imports that weren't bundled (deep path imports)
61+
// content = content.replace(
62+
// /^import\s+\{[^}]+\}\s+from\s+['"]@mongodb-js\/[^'"]+['"];\s*\n?/gm,
63+
// ''
64+
// );
65+
// content = content.replace(
66+
// /^import\s+[^{][^;]+from\s+['"]@mongodb-js\/[^'"]+['"];\s*\n?/gm,
67+
// ''
68+
// );
69+
70+
// // 6. Fix ambient context issues by removing statements in declare blocks
71+
// content = content.replace(
72+
// /declare\s+namespace\s+[^{]+\s*\{[^}]*\bexport\s*\{[^}]*\}\s*;?\s*([^}]*)\}/g,
73+
// (match) => {
74+
// // Remove export statements from within declare namespace blocks
75+
// return match.replace(/export\s*\{[^}]*\}\s*;?\s*/g, '');
76+
// }
77+
// );
78+
79+
// // 7. Fix event emitter method return types
80+
// content = content.replace(
81+
// /(\s+)(on|off|removeListener)\([^)]*\):\s*any;/g,
82+
// '$1$2(...args: any[]): this;'
83+
// );
84+
85+
// // 8. Remove problematic type assertions and fix generic types
86+
// content = content.replace(/: AppRegistry<[^>]*>/g, ': AppRegistry');
87+
88+
// // 9. Fix module resolution issues for mongodb-log-writer
89+
// content = content.replace(
90+
// /from\s*['"]mongodb-log-writer\/mongo-log-writer['"]/g,
91+
// "from 'mongodb-log-writer'"
92+
// );
93+
94+
// // 10. Remove or fix value/type confusion
95+
// content = content.replace(
96+
// /(\s+)([a-zA-Z_][a-zA-Z0-9_]*)\s+refers\s+to\s+a\s+value.*?Did you mean typeof.*?\n/g,
97+
// ''
98+
// );
99+
100+
// // 11. Add necessary imports at the top if we reference Node.js types
101+
// if (
102+
// content.includes('NodeJS.EventEmitter') &&
103+
// !content.includes('/// <reference types="node" />')
104+
// ) {
105+
// content = '/// <reference types="node" />\n' + content;
106+
// }
107+
108+
// // Count final problematic imports
109+
// const finalWhatwgMatches = (content.match(/whatwg-url/g) || []).length;
110+
// const finalEventEmitterMatches = (content.match(/eventemitter3/g) || []).length;
111+
// const finalRelativeMatches = (content.match(/^import.*from.*['"]\./gm) || [])
112+
// .length;
113+
// const finalMongoJsMatches = (content.match(/from\s+['"]@mongodb-js\//g) || [])
114+
// .length;
115+
116+
// // eslint-disable-next-line no-console
117+
// console.log(
118+
// `Final counts - whatwg-url: ${finalWhatwgMatches}, eventemitter3: ${finalEventEmitterMatches}, relative imports: ${finalRelativeMatches}, @mongodb-js imports: ${finalMongoJsMatches}`
119+
// );
120+
121+
// fs.writeFileSync(typesFile, content);
122+
// // eslint-disable-next-line no-console
123+
// console.log('Successfully cleaned up bundled types file');

packages/compass-web/src/entrypoint.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import AppRegistry, {
33
AppRegistryProvider,
44
GlobalAppRegistryProvider,
55
} from '@mongodb-js/compass-app-registry';
6-
import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider';
6+
import type { ConnectionInfo } from '@mongodb-js/connection-info';
77
import { useConnectionActions } from '@mongodb-js/compass-connections/provider';
88
import { CompassInstanceStorePlugin } from '@mongodb-js/compass-app-stores';
9-
import type { OpenWorkspaceOptions } from '@mongodb-js/compass-workspaces';
9+
import type {
10+
CollectionTabInfo,
11+
OpenWorkspaceOptions,
12+
WorkspaceTab,
13+
} from '@mongodb-js/compass-workspaces';
1014
import WorkspacesPlugin, {
1115
WorkspacesProvider,
1216
} from '@mongodb-js/compass-workspaces';
@@ -131,9 +135,12 @@ export type CompassWebProps = {
131135
* communicate current workspace back to the parent component for example to
132136
* sync router with the current active workspace
133137
*/
134-
onActiveWorkspaceTabChange: React.ComponentProps<
135-
typeof WorkspacesPlugin
136-
>['onActiveWorkspaceTabChange'];
138+
onActiveWorkspaceTabChange<WS extends WorkspaceTab>(
139+
ws: WS | null,
140+
collectionInfo: WS extends { type: 'Collection' }
141+
? CollectionTabInfo | null
142+
: never
143+
): void;
137144

138145
/**
139146
* Set of initial preferences to override default values

0 commit comments

Comments
 (0)