diff --git a/configs/webpack-config-compass/package.json b/configs/webpack-config-compass/package.json index 886ef3370a6..aacb5ff3670 100644 --- a/configs/webpack-config-compass/package.json +++ b/configs/webpack-config-compass/package.json @@ -36,11 +36,12 @@ "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", "postcompile": "gen-esm-wrapper . ./dist/.esm-wrapper.mjs", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "reformat": "npm run eslint . -- --fix && npm run prettier -- --write ." }, diff --git a/packages/compass-app-registry/package.json b/packages/compass-app-registry/package.json index 480da273fd1..6d75857f0f7 100644 --- a/packages/compass-app-registry/package.json +++ b/packages/compass-app-registry/package.json @@ -36,11 +36,12 @@ "bootstrap": "npm run compile", "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "compass-scripts check-peer-deps && depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "test": "mocha", "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", diff --git a/packages/compass-connections-navigation/package.json b/packages/compass-connections-navigation/package.json index 22e225c96a5..3a63d095cac 100644 --- a/packages/compass-connections-navigation/package.json +++ b/packages/compass-connections-navigation/package.json @@ -36,11 +36,12 @@ "bootstrap": "npm run compile", "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "compass-scripts check-peer-deps && depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "test": "mocha", "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", diff --git a/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx b/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx index 4a53f839043..71b99e5de88 100644 --- a/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx +++ b/packages/compass-connections-navigation/src/connections-navigation-tree.spec.tsx @@ -286,7 +286,7 @@ describe('ConnectionsNavigationTree', function () { { ...connections[0], csfleMode: 'enabled', - }, + } as Connection, connections[1], connections[2], ]; @@ -312,7 +312,7 @@ describe('ConnectionsNavigationTree', function () { { ...connections[0], csfleMode: 'disabled', - }, + } as Connection, connections[1], connections[2], ]; @@ -326,7 +326,7 @@ describe('ConnectionsNavigationTree', function () { { ...connections[0], csfleMode: 'unavailable', - }, + } as Connection, connections[1], connections[2], ]; diff --git a/packages/compass-connections-navigation/src/virtual-list/virtual-list.spec.tsx b/packages/compass-connections-navigation/src/virtual-list/virtual-list.spec.tsx index 3258b469cf8..601850acbd5 100644 --- a/packages/compass-connections-navigation/src/virtual-list/virtual-list.spec.tsx +++ b/packages/compass-connections-navigation/src/virtual-list/virtual-list.spec.tsx @@ -98,7 +98,8 @@ function NavigationTree({ onDefaultAction={() => {}} onItemExpand={onExpandedChange} onItemAction={() => {}} - getItemActions={() => []} + getItemActions={() => ({ actions: [] })} + getContextMenuGroups={() => []} width={100} renderItem={({ item }) => item.name} __TEST_OVER_SCAN_COUNT={Infinity} diff --git a/packages/compass-data-modeling/src/components/drawer/relationships-section.tsx b/packages/compass-data-modeling/src/components/drawer/relationships-section.tsx index 43fd6cbdb3d..aadea753aab 100644 --- a/packages/compass-data-modeling/src/components/drawer/relationships-section.tsx +++ b/packages/compass-data-modeling/src/components/drawer/relationships-section.tsx @@ -15,6 +15,9 @@ import { getDefaultRelationshipName } from '../../utils'; const titleBtnStyles = css({ marginLeft: 'auto', maxHeight: 20, // To match accordion line height + overflow: 'hidden', + textOverflow: 'ellipsis', + whiteSpace: 'nowrap', }); const emptyRelationshipMessageStyles = css({ diff --git a/packages/compass-logging/package.json b/packages/compass-logging/package.json index 816986a9431..20103ef5a1e 100644 --- a/packages/compass-logging/package.json +++ b/packages/compass-logging/package.json @@ -38,11 +38,12 @@ "bootstrap": "npm run compile", "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "compass-scripts check-peer-deps && depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "test": "mocha", "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", diff --git a/packages/databases-collections-list/package.json b/packages/databases-collections-list/package.json index 27fef282db6..52436d199c8 100644 --- a/packages/databases-collections-list/package.json +++ b/packages/databases-collections-list/package.json @@ -35,11 +35,12 @@ "bootstrap": "npm run compile", "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "compass-scripts check-peer-deps && depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "test": "mocha", "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", diff --git a/packages/databases-collections-list/src/index.spec.tsx b/packages/databases-collections-list/src/index.spec.tsx index b807482f2e3..ec17953b424 100644 --- a/packages/databases-collections-list/src/index.spec.tsx +++ b/packages/databases-collections-list/src/index.spec.tsx @@ -13,10 +13,11 @@ import { PreferencesProvider, } from 'compass-preferences-model/provider'; import { createSandboxFromDefaultPreferences } from 'compass-preferences-model'; +import type { CollectionProps } from 'mongodb-collection-model'; import type { DatabaseProps } from 'mongodb-database-model'; -function createDatabase(name) { - const db: Partial = { +function createDatabase(name: string): DatabaseProps { + const db: DatabaseProps = { _id: name, name: name, status: 'ready' as const, @@ -34,6 +35,7 @@ function createDatabase(name) { data_size: 1000, index_count: 25, index_size: 100, + calculated_storage_size: undefined, }; if (db.storage_size !== undefined && db.free_storage_size !== undefined) { @@ -43,7 +45,10 @@ function createDatabase(name) { return db; } -function createCollection(name, props: any = {}) { +function createCollection( + name: string, + props: Partial = {} +): CollectionProps { const col = { _id: name, name: name, @@ -79,6 +84,7 @@ function createCollection(name, props: any = {}) { free_storage_size: 1000, index_count: 15, index_size: 16, + calculated_storage_size: undefined, ...props, }; @@ -89,21 +95,24 @@ function createCollection(name, props: any = {}) { return col; } -function createTimeSeries(name, props: any = {}) { +function createTimeSeries( + name: string, + props: Partial = {} +): CollectionProps { return { ...createCollection(name, props), type: 'timeseries' as const, }; } -const dbs = [ +const dbs: DatabaseProps[] = [ createDatabase('foo'), createDatabase('bar'), createDatabase('buz'), createDatabase('bat'), ]; -const colls = [ +const colls: CollectionProps[] = [ createCollection('foo.foo', { storage_size: 1000, free_storage_size: 1000 }), // 1000 createCollection('bar.bar', { storage_size: 2000, free_storage_size: 500 }), // 1500 createCollection('buz.buz', { storage_size: 3000, free_storage_size: 2000 }), // 1000 @@ -120,10 +129,16 @@ describe('databases and collections list', function () { afterEach(cleanup); - const renderDatabasesList = (props) => { + const renderDatabasesList = ( + props: Partial> + ) => { render( - + {}} + {...props} + > ); }; @@ -200,10 +215,17 @@ describe('databases and collections list', function () { afterEach(cleanup); - const renderCollectionsList = (props) => { + const renderCollectionsList = ( + props: Partial> + ) => { render( - + {}} + namespace="db" + collections={[]} + {...props} + > ); }; diff --git a/packages/explain-plan-helper/package.json b/packages/explain-plan-helper/package.json index 57512ef602a..340e0f928e6 100644 --- a/packages/explain-plan-helper/package.json +++ b/packages/explain-plan-helper/package.json @@ -36,11 +36,12 @@ "bootstrap": "npm run compile", "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", + "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint-compass", "prettier": "prettier-compass", "lint": "npm run eslint . && npm run prettier -- --check .", "depcheck": "compass-scripts check-peer-deps && depcheck", - "check": "npm run lint && npm run depcheck", + "check": "npm run typecheck && npm run lint && npm run depcheck", "check-ci": "npm run check", "test": "mocha", "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", diff --git a/packages/explain-plan-helper/src/index.spec.ts b/packages/explain-plan-helper/src/index.spec.ts index 8924fbc4cea..8072b151b61 100644 --- a/packages/explain-plan-helper/src/index.spec.ts +++ b/packages/explain-plan-helper/src/index.spec.ts @@ -227,13 +227,13 @@ describe('explain-plan-plan', function () { it('should find a stage by name from the root stage', function () { const ixscan = plan.findStageByName('IXSCAN'); - expect(ixscan.indexName).to.equal('age_1'); + expect(ixscan?.indexName).to.equal('age_1'); }); it('should iterate over shards in a sharded explain plan', async function () { plan = await loadExplainFixture('sharded_geo_query_3.2.json'); const ixscan = plan.findStageByName('IXSCAN'); - expect(ixscan.indexName).to.equal('last_login_-1'); + expect(ixscan?.indexName).to.equal('last_login_-1'); }); it('should return all matching stages with findAllStagesByName', async function () { @@ -244,21 +244,21 @@ describe('explain-plan-plan', function () { it('should find a stage by name from a provided stage', function () { const fetch = plan.findStageByName('FETCH'); - expect(fetch.stage).to.equal('FETCH'); - const ixscan = plan.findStageByName('IXSCAN', fetch); - expect(ixscan.indexName).to.equal('age_1'); + expect(fetch?.stage).to.equal('FETCH'); + const ixscan = plan.findStageByName('IXSCAN', fetch!); + expect(ixscan?.indexName).to.equal('age_1'); }); it('should find a stage if it is the provided root stage', function () { const fetch = plan.findStageByName('FETCH'); - expect(fetch.stage).to.equal('FETCH'); - const fetch2 = plan.findStageByName('FETCH', fetch); + expect(fetch?.stage).to.equal('FETCH'); + const fetch2 = plan.findStageByName('FETCH', fetch!); expect(fetch).to.equal(fetch2); }); it('should iterate over stages', function () { - const it = plan._getStageIterator(); - expect(it.next().value).to.equal(plan.executionStats.executionStages); + const it = plan._getStageIterator()[Symbol.iterator](); + expect(it.next().value).to.equal(plan.executionStats?.executionStages); expect(it.next().value.stage).to.equal('IXSCAN'); expect(it.next().done).to.equal(true); }); @@ -354,7 +354,7 @@ describe('explain-plan-plan', function () { it('should have usedIndexes in executionStats object', function () { const expectedIndexes = [{ fields: {}, index: '_id_', shard: null }]; - expect(plan.executionStats.stageIndexes).to.deep.equal( + expect(plan.executionStats?.stageIndexes).to.deep.equal( expectedIndexes ); expect(plan.usedIndexes).to.deep.equal(expectedIndexes); @@ -367,7 +367,7 @@ describe('explain-plan-plan', function () { }); it('should sum estimate time correctly', function () { - expect(plan.executionStats.executionTimeMillis).to.equal(21317); + expect(plan.executionStats?.executionTimeMillis).to.equal(21317); }); }); }); @@ -417,17 +417,18 @@ describe('explain-plan-plan', function () { }); it('should have a SINGLE_SHARD stage', function () { const stage = plan.findStageByName('SINGLE_SHARD'); - expect(stage.shards).to.have.lengthOf(1); + expect(stage?.shards).to.have.lengthOf(1); }); it('should have correct execution metrics', function () { - expect(plan.executionStats.nReturned).to.equal(422); // nReturned is from the last stage - expect(plan.executionStats.executionTimeMillis).to.equal(12); - expect(plan.executionStats.totalKeysExamined).to.equal(719); - expect(plan.executionStats.totalDocsExamined).to.equal(490); + expect(plan.executionStats?.nReturned).to.equal(422); // nReturned is from the last stage + expect(plan.executionStats?.executionTimeMillis).to.equal(12); + expect(plan.executionStats?.totalKeysExamined).to.equal(719); + expect(plan.executionStats?.totalDocsExamined).to.equal(490); }); it('should find a stage if it is the provided root stage', function () { const stage1 = plan.findStageByName('SINGLE_SHARD'); - const stage2 = plan.findStageByName('SINGLE_SHARD', stage1); + expect(stage1).to.not.be.null; + const stage2 = plan.findStageByName('SINGLE_SHARD', stage1!); expect(stage1).to.equal(stage2); }); }); @@ -468,17 +469,18 @@ describe('explain-plan-plan', function () { }); it('should have a SINGLE_SHARD stage', function () { const stage = plan.findStageByName('SINGLE_SHARD'); - expect(stage.shards).to.have.lengthOf(1); + expect(stage?.shards).to.have.lengthOf(1); }); it('should have correct execution metrics', function () { - expect(plan.executionStats.nReturned).to.equal(20); - expect(plan.executionStats.executionTimeMillis).to.equal(0); - expect(plan.executionStats.totalKeysExamined).to.equal(0); - expect(plan.executionStats.totalDocsExamined).to.equal(581); + expect(plan.executionStats?.nReturned).to.equal(20); + expect(plan.executionStats?.executionTimeMillis).to.equal(0); + expect(plan.executionStats?.totalKeysExamined).to.equal(0); + expect(plan.executionStats?.totalDocsExamined).to.equal(581); }); it('should find a stage if it is the provided root stage', function () { const stage1 = plan.findStageByName('SINGLE_SHARD'); - const stage2 = plan.findStageByName('SINGLE_SHARD', stage1); + expect(stage1).to.not.be.null; + const stage2 = plan.findStageByName('SINGLE_SHARD', stage1!); expect(stage1).to.equal(stage2); }); }); @@ -530,18 +532,19 @@ describe('explain-plan-plan', function () { }); it('should have a SHARD_MERGE stage', function () { const stage = plan.findStageByName('SHARD_MERGE'); - expect(stage.shards).to.have.lengthOf(2); + expect(stage?.shards).to.have.lengthOf(2); }); it('should have correct execution metrics', function () { - expect(plan.executionStats.nReturned).to.equal(485); // sum of nReturned from the last stage of each shard + expect(plan.executionStats?.nReturned).to.equal(485); // sum of nReturned from the last stage of each shard // executionTimeMillis from each stage (except $cursor) + executionTimeMillis of $cursor stage for each shard - expect(plan.executionStats.executionTimeMillis).to.equal(28); - expect(plan.executionStats.totalKeysExamined).to.equal(719); - expect(plan.executionStats.totalDocsExamined).to.equal(490); + expect(plan.executionStats?.executionTimeMillis).to.equal(28); + expect(plan.executionStats?.totalKeysExamined).to.equal(719); + expect(plan.executionStats?.totalDocsExamined).to.equal(490); }); it('should find a stage if it is the provided root stage', function () { - const stage1 = plan.findStageByName('SINGLE_SHARD'); - const stage2 = plan.findStageByName('SINGLE_SHARD', stage1); + const stage1 = plan.findStageByName('SHARD_MERGE'); + expect(stage1).to.not.be.null; + const stage2 = plan.findStageByName('SHARD_MERGE', stage1!); expect(stage1).to.equal(stage2); }); }); @@ -576,17 +579,18 @@ describe('explain-plan-plan', function () { }); it('should have a SHARD_MERGE stage', function () { const stage = plan.findStageByName('SHARD_MERGE'); - expect(stage.shards).to.have.lengthOf(2); + expect(stage?.shards).to.have.lengthOf(2); }); it('should have correct execution metrics', function () { - expect(plan.executionStats.nReturned).to.equal(1); - expect(plan.executionStats.executionTimeMillis).to.equal(50); - expect(plan.executionStats.totalKeysExamined).to.equal(0); - expect(plan.executionStats.totalDocsExamined).to.equal(5555); + expect(plan.executionStats?.nReturned).to.equal(1); + expect(plan.executionStats?.executionTimeMillis).to.equal(50); + expect(plan.executionStats?.totalKeysExamined).to.equal(0); + expect(plan.executionStats?.totalDocsExamined).to.equal(5555); }); it('should find a stage if it is the provided root stage', function () { const stage1 = plan.findStageByName('SHARD_MERGE'); - const stage2 = plan.findStageByName('SHARD_MERGE', stage1); + expect(stage1).to.not.be.null; + const stage2 = plan.findStageByName('SHARD_MERGE', stage1!); expect(stage1).to.equal(stage2); }); }); @@ -599,7 +603,7 @@ describe('explain-plan-plan', function () { }); it('should have usedIndexes in executionStats object', function () { - expect(plan.executionStats.stageIndexes).to.deep.equal([ + expect(plan.executionStats?.stageIndexes).to.deep.equal([ { fields: {}, index: '_id_', shard: 'shard2' }, ]); });