Skip to content

Commit d25d64a

Browse files
committed
replaced any : types everywhere
1 parent febd03a commit d25d64a

4 files changed

Lines changed: 128 additions & 16 deletions

File tree

backend/src/controllers/setup.controller.ts

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,62 @@ import { Request, Response } from 'express';
22
import app from '../index.js';
33
import StatusService from '../services/status.service.js';
44
import logger from '../services/logger.js';
5+
import { Endpoints } from '@octokit/types';
6+
7+
// Type definitions for the diagnostic response
8+
interface OctokitTestResult {
9+
success: boolean;
10+
appName?: string;
11+
appOwner?: string;
12+
permissions?: Record<string, string | undefined>;
13+
error?: string;
14+
}
15+
16+
interface InstallationDiagnostic {
17+
index: number;
18+
installationId: number;
19+
accountLogin: string;
20+
accountId: string | number;
21+
accountType: string;
22+
accountAvatarUrl: string;
23+
appId: number;
24+
appSlug: string;
25+
targetType: string;
26+
permissions: Record<string, string | undefined>;
27+
events: string[];
28+
createdAt: string;
29+
updatedAt: string;
30+
suspendedAt: string | null;
31+
suspendedBy: { login: string; id: number } | null;
32+
hasOctokit: boolean;
33+
octokitTest: OctokitTestResult | null;
34+
isValid: boolean;
35+
validationErrors: string[];
36+
}
37+
38+
interface AppInfo {
39+
name: string;
40+
description: string;
41+
owner: string;
42+
htmlUrl: string;
43+
permissions: Record<string, string | undefined>;
44+
events: string[];
45+
}
46+
47+
interface DiagnosticsResponse {
48+
timestamp: string;
49+
appConnected: boolean;
50+
totalInstallations: number;
51+
installations: InstallationDiagnostic[];
52+
errors: string[];
53+
appInfo: AppInfo | null;
54+
summary: {
55+
validInstallations: number;
56+
invalidInstallations: number;
57+
organizationNames: string[];
58+
accountTypes: Record<string, number>;
59+
};
60+
}
561

662
class SetupController {
763
async registrationComplete(req: Request, res: Response) {
@@ -114,18 +170,18 @@ class SetupController {
114170

115171
async validateInstallations(req: Request, res: Response) {
116172
try {
117-
const diagnostics = {
173+
const diagnostics: DiagnosticsResponse = {
118174
timestamp: new Date().toISOString(),
119175
appConnected: !!app.github.app,
120176
totalInstallations: app.github.installations.length,
121-
installations: [] as any[],
122-
errors: [] as string[],
123-
appInfo: null as any,
177+
installations: [],
178+
errors: [],
179+
appInfo: null,
124180
summary: {
125181
validInstallations: 0,
126182
invalidInstallations: 0,
127-
organizationNames: [] as string[],
128-
accountTypes: {} as Record<string, number>
183+
organizationNames: [],
184+
accountTypes: {}
129185
}
130186
};
131187

@@ -139,7 +195,7 @@ class SetupController {
139195
for (let i = 0; i < app.github.installations.length; i++) {
140196
const { installation, octokit } = app.github.installations[i];
141197

142-
const installationDiag = {
198+
const installationDiag: InstallationDiagnostic = {
143199
index: i,
144200
installationId: installation.id,
145201
accountLogin: installation.account?.login || 'MISSING',
@@ -149,16 +205,16 @@ class SetupController {
149205
appId: installation.app_id,
150206
appSlug: installation.app_slug,
151207
targetType: installation.target_type,
152-
permissions: installation.permissions,
153-
events: installation.events,
208+
permissions: installation.permissions || {},
209+
events: installation.events || [],
154210
createdAt: installation.created_at,
155211
updatedAt: installation.updated_at,
156212
suspendedAt: installation.suspended_at,
157213
suspendedBy: installation.suspended_by,
158214
hasOctokit: !!octokit,
159-
octokitTest: null as any,
215+
octokitTest: null,
160216
isValid: true,
161-
validationErrors: [] as string[]
217+
validationErrors: []
162218
};
163219

164220
// Validate required fields
@@ -185,7 +241,7 @@ class SetupController {
185241
installationDiag.octokitTest = {
186242
success: true,
187243
appName: authTest.data?.name || 'Unknown',
188-
appOwner: (authTest.data?.owner as any)?.login || 'Unknown',
244+
appOwner: (authTest.data?.owner && 'login' in authTest.data.owner) ? authTest.data.owner.login : 'Unknown',
189245
permissions: authTest.data?.permissions || {}
190246
};
191247
} catch (error) {
@@ -224,7 +280,7 @@ class SetupController {
224280
diagnostics.appInfo = {
225281
name: appInfo.data?.name || 'Unknown',
226282
description: appInfo.data?.description || 'No description',
227-
owner: (appInfo.data?.owner as any)?.login || 'Unknown',
283+
owner: (appInfo.data?.owner && 'login' in appInfo.data.owner) ? appInfo.data.owner.login : 'Unknown',
228284
htmlUrl: appInfo.data?.html_url || 'Unknown',
229285
permissions: appInfo.data?.permissions || {},
230286
events: appInfo.data?.events || []

frontend/src/app/main/diagnostics/main-diagnostics.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
1010
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
1111
import { MatToolbarModule } from '@angular/material/toolbar';
1212
import { SetupService } from '../../services/api/setup.service';
13+
import { DiagnosticsResponse } from '../../types/diagnostics.types';
1314

1415
@Component({
1516
selector: 'app-main-diagnostics',
@@ -192,7 +193,7 @@ import { SetupService } from '../../services/api/setup.service';
192193
})
193194
export class MainDiagnosticsComponent {
194195
isLoading = false;
195-
lastResult: any = null;
196+
lastResult: DiagnosticsResponse | null = null;
196197

197198
constructor(
198199
private setupService: SetupService,
@@ -460,7 +461,7 @@ export class MainDiagnosticsComponent {
460461
export class InstallationDiagnosticsDialogComponent {
461462
constructor(
462463
public dialogRef: MatDialogRef<InstallationDiagnosticsDialogComponent>,
463-
@Inject(MAT_DIALOG_DATA) public data: any
464+
@Inject(MAT_DIALOG_DATA) public data: DiagnosticsResponse
464465
) {}
465466

466467
getSuccessRate(): number {

frontend/src/app/services/api/setup.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
33
import { serverUrl } from '../server.service';
44
import { Endpoints } from '@octokit/types';
55
import { BehaviorSubject } from 'rxjs';
6+
import { DiagnosticsResponse } from '../../types/diagnostics.types';
67

78
export interface InstallationStatus {
89
installation?: Endpoints["GET /app/installations"]["response"]["data"][number],
@@ -61,7 +62,7 @@ export class SetupService {
6162
}
6263

6364
validateInstallations() {
64-
return this.http.get<any>(`${this.apiUrl}/validate-installations`);
65+
return this.http.get<DiagnosticsResponse>(`${this.apiUrl}/validate-installations`);
6566
}
6667

6768
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Type definitions for the diagnostic response from backend
2+
export interface OctokitTestResult {
3+
success: boolean;
4+
appName?: string;
5+
appOwner?: string;
6+
permissions?: Record<string, string | undefined>;
7+
error?: string;
8+
}
9+
10+
export interface InstallationDiagnostic {
11+
index: number;
12+
installationId: number;
13+
accountLogin: string;
14+
accountId: string | number;
15+
accountType: string;
16+
accountAvatarUrl: string;
17+
appId: number;
18+
appSlug: string;
19+
targetType: string;
20+
permissions: Record<string, string | undefined>;
21+
events: string[];
22+
createdAt: string;
23+
updatedAt: string;
24+
suspendedAt: string | null;
25+
suspendedBy: { login: string; id: number } | null;
26+
hasOctokit: boolean;
27+
octokitTest: OctokitTestResult | null;
28+
isValid: boolean;
29+
validationErrors: string[];
30+
}
31+
32+
export interface AppInfo {
33+
name: string;
34+
description: string;
35+
owner: string;
36+
htmlUrl: string;
37+
permissions: Record<string, string | undefined>;
38+
events: string[];
39+
}
40+
41+
export interface DiagnosticsResponse {
42+
timestamp: string;
43+
appConnected: boolean;
44+
totalInstallations: number;
45+
installations: InstallationDiagnostic[];
46+
errors: string[];
47+
appInfo: AppInfo | null;
48+
summary: {
49+
validInstallations: number;
50+
invalidInstallations: number;
51+
organizationNames: string[];
52+
accountTypes: Record<string, number>;
53+
};
54+
}

0 commit comments

Comments
 (0)