Skip to content

Commit 67259e4

Browse files
committed
chore: add type check for CI
We have been running lint which did catch most TypeScript errors but there's more complex type issues which arise from the TypeScript compiler itself. This adds a type check step and fixes existing issues with it.
1 parent 3b9e002 commit 67259e4

19 files changed

+93
-76
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"name": "Launch Program",
1111
"skipFiles": ["<node_internals>/**"],
1212
"program": "${workspaceFolder}/dist/index.js",
13-
"preLaunchTask": "tsc: build - tsconfig.json",
13+
"preLaunchTask": "tsc: build - tsconfig.build.json",
1414
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
1515
}
1616
]

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default defineConfig([
2929
files,
3030
languageOptions: {
3131
parserOptions: {
32-
project: "./tsconfig.lint.json",
32+
project: "./tsconfig.json",
3333
tsconfigRootDir: import.meta.dirname,
3434
},
3535
},

package-lock.json

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
"scripts": {
1919
"prepare": "npm run build",
2020
"build:clean": "rm -rf dist",
21-
"build:compile": "tsc",
21+
"build:compile": "tsc --project tsconfig.build.json",
2222
"build:chmod": "chmod +x dist/index.js",
2323
"build": "npm run build:clean && npm run build:compile && npm run build:chmod",
2424
"inspect": "npm run build && mcp-inspector -- dist/index.js",
2525
"prettier": "prettier",
26-
"check": "npm run build && npm run check:lint && npm run check:format",
26+
"check": "npm run build && npm run check:types && npm run check:lint && npm run check:format",
2727
"check:lint": "eslint .",
2828
"check:format": "prettier -c .",
29+
"check:types": "tsc --noEmit --project tsconfig.json",
2930
"reformat": "prettier --write .",
3031
"generate": "./scripts/generate.sh",
3132
"test": "jest --coverage"

scripts/apply.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async function main() {
4444
const openapi = JSON.parse(specFile) as OpenAPIV3_1.Document;
4545
for (const path in openapi.paths) {
4646
for (const method in openapi.paths[path]) {
47+
// @ts-expect-error This is a workaround for the OpenAPI types
4748
const operation = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
4849

4950
if (!operation.operationId || !operation.tags?.length) {

scripts/filter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
4343
for (const path in openapi.paths) {
4444
const filteredMethods = {} as OpenAPIV3_1.PathItemObject;
4545
for (const method in openapi.paths[path]) {
46+
// @ts-expect-error This is a workaround for the OpenAPI types
4647
if (allowedOperations.includes((openapi.paths[path][method] as { operationId: string }).operationId)) {
48+
// @ts-expect-error This is a workaround for the OpenAPI types
4749
filteredMethods[method] = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
4850
}
4951
}
5052
if (Object.keys(filteredMethods).length > 0) {
53+
// @ts-expect-error This is a workaround for the OpenAPI types
5154
filteredPaths[path] = filteredMethods;
5255
}
5356
}

src/common/atlas/apiClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { FetchOptions } from "openapi-fetch";
33
import { AccessToken, ClientCredentials } from "simple-oauth2";
44
import { ApiClientError } from "./apiClientError.js";
55
import { paths, operations } from "./openapi.js";
6-
import { BaseEvent } from "../../telemetry/types.js";
6+
import { CommonProperties, TelemetryEvent } from "../../telemetry/types.js";
77
import { packageInfo } from "../../packageInfo.js";
88

99
const ATLAS_API_VERSION = "2025-03-12";
@@ -123,7 +123,7 @@ export class ApiClient {
123123
}>;
124124
}
125125

126-
async sendEvents(events: BaseEvent[]): Promise<void> {
126+
async sendEvents(events: TelemetryEvent<CommonProperties>[]): Promise<void> {
127127
let endpoint = "api/private/unauth/telemetry/events";
128128
const headers: Record<string, string> = {
129129
Accept: "application/json",

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class Server {
119119
if (command === "start") {
120120
event.properties.startup_time_ms = commandDuration;
121121
event.properties.read_only_mode = this.userConfig.readOnly || false;
122-
event.properties.disallowed_tools = this.userConfig.disabledTools || [];
122+
event.properties.disabled_tools = this.userConfig.disabledTools || [];
123123
}
124124
if (command === "stop") {
125125
event.properties.runtime_duration_ms = Date.now() - this.startTime;

src/telemetry/eventCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class EventCache {
1313
private cache: LRUCache<number, BaseEvent>;
1414
private nextId = 0;
1515

16-
private constructor() {
16+
constructor() {
1717
this.cache = new LRUCache({
1818
max: EventCache.MAX_EVENTS,
1919
// Using FIFO eviction strategy for events

src/telemetry/telemetry.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ export class Telemetry {
113113
*/
114114
private async sendEvents(client: ApiClient, events: BaseEvent[]): Promise<EventResult> {
115115
try {
116-
await client.sendEvents(events);
116+
await client.sendEvents(
117+
events.map((event) => ({
118+
...event,
119+
properties: { ...event.properties, ...this.getCommonProperties() },
120+
}))
121+
);
117122
return { success: true };
118123
} catch (error) {
119124
return {

0 commit comments

Comments
 (0)