Skip to content

Commit 491dbe8

Browse files
committed
chore: clean up script and public only defs
1 parent 3466db5 commit 491dbe8

File tree

8 files changed

+42
-129
lines changed

8 files changed

+42
-129
lines changed

packages/compass-web/api-extractor.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"mainEntryPointFilePath": "./dist/index.d.ts",
4+
"newlineKind": "lf",
45
"bundledPackages": [
56
"@mongodb-js/*",
67
"@mongodb-js/mdb-experiment-js",
@@ -25,7 +26,8 @@
2526
},
2627
"dtsRollup": {
2728
"enabled": true,
28-
"untrimmedFilePath": "./dist/index.untrimmed.d.ts"
29+
"untrimmedFilePath": "",
30+
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
2931
},
3032
"apiReport": {
3133
"enabled": false

packages/compass-web/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
".": "./src/index.tsx",
3434
"./package.json": "./package.json"
3535
},
36-
"types": "./dist/index.d.ts",
36+
"types": "./dist/compass-web.d.ts",
3737
"scripts": {
3838
"prepublishOnly": "npm run compile && compass-scripts check-exports-exist",
3939
"compile": "npm run webpack -- --mode production",
4040
"webpack": "webpack-compass",
41-
"postcompile": "npm run typescript && npm run api-extractor && npm run bundle-types",
41+
"postcompile": "npm run typescript",
4242
"typescript": "tsc -p tsconfig-build.json --emitDeclarationOnly",
43+
"posttypescript": "npm run api-extractor",
4344
"api-extractor": "api-extractor run --local",
44-
"bundle-types": "cp dist/index.bundled.d.ts dist/index.d.ts && rm -f dist/index.bundled.d.ts && node scripts/cleanup-bundled-types.js",
45-
"check-external-deps": "echo 'External dependencies that consumers will need:' && grep '^import.*from.*' dist/index.d.ts | grep -v '\\./\\|@mongodb-js\\|compass-preferences-model' | grep -v 'stream\\|events\\|https\\|http\\|tls\\|net\\|dns' | sort | uniq",
45+
"postapi-extractor": "node scripts/clean-dts.mjs",
4646
"test-types": "cd test/types && npm install && npm test",
4747
"prestart": "npm run compile -w @mongodb-js/webpack-config-compass",
4848
"start": "electron ./scripts/electron-proxy.js",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
//@ts-check
4+
5+
import fs from 'node:fs';
6+
import path from 'node:path';
7+
import process from 'node:process';
8+
9+
const distDir = path.join(process.cwd(), 'dist');
10+
const keepFiles = new Set(['compass-web.d.ts', 'compass-web.d.ts.map']);
11+
12+
for (const file of fs.readdirSync(distDir)) {
13+
if (
14+
(file.endsWith('.d.ts') || file.endsWith('.d.ts.map')) &&
15+
!keepFiles.has(file)
16+
) {
17+
fs.unlinkSync(path.join(distDir, file));
18+
console.log(`Deleted: ${file}`);
19+
}
20+
}

packages/compass-web/scripts/cleanup-bundled-types.js

Lines changed: 0 additions & 123 deletions
This file was deleted.

packages/compass-web/src/entrypoint.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
CompassAssistantProvider,
6868
} from '@mongodb-js/compass-assistant';
6969

70+
/** @public */
7071
export type TrackFunction = (
7172
event: string,
7273
properties: Record<string, any>
@@ -95,6 +96,7 @@ type CompassWorkspaceProps = Pick<
9596
'onOpenConnectViaModal'
9697
>;
9798

99+
/** @public */
98100
export type CompassWebProps = {
99101
/**
100102
* App name to be passed with the connection string when connection to a
@@ -264,6 +266,7 @@ const connectedContainerStyles = css({
264266
display: 'flex',
265267
});
266268

269+
/** @public */
267270
const CompassWeb = ({
268271
appName,
269272
orgId,

packages/compass-web/src/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
export { CompassWeb } from './entrypoint';
2-
export type { CompassWebProps } from './entrypoint';
2+
export type { CompassWebProps, TrackFunction } from './entrypoint';
33
export * from './url-builder';
44
export type {
55
OpenWorkspaceOptions,
66
WorkspaceTab,
77
} from '@mongodb-js/compass-workspaces';
88

99
export { CompassExperimentationProvider } from '@mongodb-js/compass-telemetry';
10+
11+
export type { CollectionTabInfo } from '@mongodb-js/compass-workspaces';
12+
export type { AllPreferences } from 'compass-preferences-model/provider';
13+
export type { AtlasClusterMetadata } from '@mongodb-js/connection-info';
14+
export type { LogFunction, LogMessage, DebugFunction } from './logger';

packages/compass-web/src/logger.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Writable } from 'stream';
44
import { mongoLogId } from '@mongodb-js/compass-logging/provider';
55
import { useRef } from 'react';
66

7+
/** @public */
78
export type LogMessage = {
89
id: number;
910
t: { $date: string };
@@ -13,8 +14,11 @@ export type LogMessage = {
1314
msg: string;
1415
attr?: any;
1516
};
17+
18+
/** @public */
1619
export type LogFunction = (message: LogMessage) => void;
1720

21+
/** @public */
1822
export type DebugFunction = (...args: any[]) => void;
1923

2024
type Debugger = Logger['debug'];

packages/compass-web/src/url-builder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function getRouteFromCollectionSubTab(subTab: CollectionSubtab): string {
4949
}
5050
}
5151

52+
/** @public */
5253
export function getWorkspaceTabFromRoute(
5354
route: string
5455
): OpenWorkspaceOptions | null {
@@ -85,6 +86,7 @@ function buildAbsoluteURL(...parts: string[]) {
8586
);
8687
}
8788

89+
/** @public */
8890
export function getRouteFromWorkspaceTab(tab: WorkspaceTab | null) {
8991
let route: string;
9092
switch (tab?.type) {

0 commit comments

Comments
 (0)