Skip to content

Commit f0e9105

Browse files
SP-1173: trim the CuiService response types
CuiPdfCoverResponse is the only type consumed outside the module, so the three helper interfaces are inlined into it. Categories are counted, never read, so their element type carries no weight. Includes-AI-Code: true Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8720f01 commit f0e9105

1 file changed

Lines changed: 5 additions & 27 deletions

File tree

src/core/utils/cui-service.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,13 @@ import { HttpClient } from "../http/http-client";
22
import { FatalError, logger } from "./logger";
33
import { Context } from "../command/cli-context";
44

5-
export interface CuiCategory {
6-
code: string;
7-
name: string;
8-
}
9-
10-
export interface ResolvedCuiMarking {
11-
categories?: CuiCategory[];
12-
}
13-
14-
export interface CuiCoverPage {
15-
pdfContent: string;
16-
encoding: string;
17-
}
18-
195
export interface CuiPdfCoverResponse {
20-
resolvedCuiMarking?: ResolvedCuiMarking;
21-
coverPage?: CuiCoverPage;
6+
resolvedCuiMarking?: { categories?: unknown[] };
7+
coverPage?: { pdfContent: string; encoding: string };
228
}
239

2410
export class CuiService {
25-
private static readonly COVER_SHEET_URL = "/api/team/cui-settings/cui-pdf-cover";
11+
private static readonly CUI_PDF_COVER_SHEET_URL = "/api/team/cui-settings/cui-pdf-cover";
2612

2713
private static readonly STATUS_OK = 200;
2814
private static readonly STATUS_NO_CONTENT = 204;
@@ -35,7 +21,7 @@ export class CuiService {
3521
}
3622

3723
public async getCuiPdfCover(): Promise<CuiPdfCoverResponse | null> {
38-
const { status, data } = await this.httpClient().getStatusAndData(CuiService.COVER_SHEET_URL);
24+
const { status, data } = await this.httpClient().getStatusAndData(CuiService.CUI_PDF_COVER_SHEET_URL);
3925

4026
if (status === CuiService.STATUS_FORBIDDEN) {
4127
logger.debug("CUI marking does not apply, the feature flag is disabled");
@@ -48,17 +34,9 @@ export class CuiService {
4834
}
4935

5036
if (status !== CuiService.STATUS_OK) {
51-
const detail = this.describeBody(data) || `Backend responded with status code ${status}`;
52-
throw new FatalError(`Problem fetching cui: ${detail}`);
37+
throw new FatalError("Problem fetching cui pdf cover");
5338
}
5439

5540
return data ? (data as CuiPdfCoverResponse) : null;
5641
}
57-
58-
private describeBody(data: any): string {
59-
if (!data) {
60-
return "";
61-
}
62-
return `: ${typeof data === "string" ? data : JSON.stringify(data)}`;
63-
}
6442
}

0 commit comments

Comments
 (0)