fix(ui): update severity trends endpoint and reorganize types (#9460)

This commit is contained in:
Alan Buscaglia
2025-12-04 14:35:21 +01:00
committed by GitHub
parent eb247360c3
commit 379c1dc7dd
34 changed files with 42 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
import { AttackSurfaceOverview, AttackSurfaceOverviewResponse } from "../types";
import { AttackSurfaceOverview, AttackSurfaceOverviewResponse } from "./types";
const ATTACK_SURFACE_IDS = {
INTERNET_EXPOSED: "internet-exposed",

View File

@@ -3,7 +3,7 @@
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { AttackSurfaceOverviewResponse } from "../types";
import { AttackSurfaceOverviewResponse } from "./types";
export const getAttackSurfaceOverview = async ({
filters = {},

View File

@@ -1,2 +1,3 @@
export * from "./attack-surface";
export * from "./attack-surface.adapter";
export * from "./types";

View File

@@ -1,7 +1,9 @@
// Attack Surface Overview Types
// Corresponds to the /overviews/attack-surfaces endpoint
import { OverviewResponseMeta } from "./common";
interface OverviewResponseMeta {
version: string;
}
export interface AttackSurfaceOverviewAttributes {
total_findings: number;

View File

@@ -0,0 +1 @@
export * from "./attack-surface.types";

View File

@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { FindingsSeverityOverviewResponse } from "../types";
import { FindingsSeverityOverviewResponse } from "./types";
export const getFindingsByStatus = async ({
page = 1,

View File

@@ -1 +1,2 @@
export * from "./findings";
export * from "./types";

View File

@@ -1,7 +1,9 @@
// Findings Severity Overview Types
// Corresponds to the /overviews/findings_severity endpoint
import { OverviewResponseMeta } from "./common";
interface OverviewResponseMeta {
version: string;
}
export interface FindingsSeverityAttributes {
critical: number;

View File

@@ -0,0 +1 @@
export * from "./findings.types";

View File

@@ -6,4 +6,3 @@ export * from "./regions";
export * from "./services";
export * from "./severity-trends";
export * from "./threat-score";
export * from "./types";

View File

@@ -1,2 +1,3 @@
export * from "./providers";
export * from "./sankey.adapter";
export * from "./types";

View File

@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { ProvidersOverviewResponse } from "../types";
import { ProvidersOverviewResponse } from "./types";
export const getProvidersOverview = async ({
page = 1,

View File

@@ -0,0 +1 @@
export * from "./providers.types";

View File

@@ -1,7 +1,9 @@
// Providers Overview Types
// Corresponds to the /overviews/providers endpoint
import { OverviewResponseMeta } from "./common";
interface OverviewResponseMeta {
version: string;
}
export interface ProviderOverviewFindings {
pass: number;

View File

@@ -1,2 +1,3 @@
export * from "./regions";
export * from "./threat-map.adapter";
export * from "./types";

View File

@@ -3,7 +3,7 @@
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { RegionsOverviewResponse } from "../types";
import { RegionsOverviewResponse } from "./types";
export const getRegionsOverview = async ({
filters = {},

View File

@@ -1,6 +1,6 @@
import { getProviderDisplayName } from "@/types/providers";
import { RegionsOverviewResponse } from "../types";
import { RegionsOverviewResponse } from "./types";
export interface ThreatMapLocation {
id: string;

View File

@@ -0,0 +1 @@
export * from "./regions.types";

View File

@@ -1,7 +1,9 @@
// Regions Overview Types
// Corresponds to the /overviews/regions endpoint
import { OverviewResponseMeta } from "./common";
interface OverviewResponseMeta {
version: string;
}
export interface RegionOverviewAttributes {
provider_type: string;

View File

@@ -1 +1,2 @@
export * from "./services";
export * from "./types";

View File

@@ -3,7 +3,7 @@
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { ServicesOverviewResponse } from "../types";
import { ServicesOverviewResponse } from "./types";
export const getServicesOverview = async ({
filters = {},

View File

@@ -0,0 +1 @@
export * from "./services.types";

View File

@@ -1,7 +1,9 @@
// Services Overview Types
// Corresponds to the /overviews/services endpoint
import { OverviewResponseMeta } from "./common";
interface OverviewResponseMeta {
version: string;
}
export interface ServiceOverviewAttributes {
total: number;

View File

@@ -1,2 +1,3 @@
export * from "./severity-trends";
export * from "./severity-trends.adapter";
export * from "./types";

View File

@@ -3,7 +3,7 @@ import { LineDataPoint } from "@/components/graphs/types";
import {
AdaptedSeverityTrendsResponse,
FindingsSeverityOverTimeResponse,
} from "../types";
} from "./types";
export type { AdaptedSeverityTrendsResponse, FindingsSeverityOverTimeResponse };
@@ -11,7 +11,7 @@ export type { AdaptedSeverityTrendsResponse, FindingsSeverityOverTimeResponse };
* Adapts the API findings severity over time response to the format expected by LineChart.
* Transforms API response with nested attributes into flat LineDataPoint objects.
*
* @param response - The raw API response from /overviews/findings_severity_over_time
* @param response - The raw API response from /overviews/findings_severity/timeseries
* @returns Adapted response with LineDataPoint array ready for the chart
*/
export function adaptSeverityTrendsResponse(

View File

@@ -3,11 +3,11 @@
import { apiBaseUrl, getAuthHeaders } from "@/lib";
import { handleApiResponse } from "@/lib/server-actions-helper";
import { adaptSeverityTrendsResponse } from "./severity-trends.adapter";
import {
AdaptedSeverityTrendsResponse,
FindingsSeverityOverTimeResponse,
} from "../types";
import { adaptSeverityTrendsResponse } from "./severity-trends.adapter";
} from "./types";
const TIME_RANGE_VALUES = {
FIVE_DAYS: "5D",
@@ -35,7 +35,7 @@ const getFindingsSeverityTrends = async ({
} = {}): Promise<SeverityTrendsResult> => {
const headers = await getAuthHeaders({ contentType: false });
const url = new URL(`${apiBaseUrl}/overviews/findings_severity_over_time`);
const url = new URL(`${apiBaseUrl}/overviews/findings_severity/timeseries`);
Object.entries(filters).forEach(([key, value]) => {
if (value !== undefined) {

View File

@@ -0,0 +1 @@
export * from "./severity-trends.types";

View File

@@ -1 +1,2 @@
export * from "./threat-score";
export * from "./types";

View File

@@ -0,0 +1 @@
export * from "./threat-score.types";

View File

@@ -1,5 +0,0 @@
// Common types shared across overview endpoints
export interface OverviewResponseMeta {
version: string;
}

View File

@@ -1,8 +0,0 @@
export * from "./attack-surface";
export * from "./common";
export * from "./findings-severity";
export * from "./providers";
export * from "./regions";
export * from "./services";
export * from "./severity-trends";
export * from "./threat-score";

View File

@@ -5,7 +5,7 @@ import { MessageCircleWarning, ThumbsUp } from "lucide-react";
import type {
CriticalRequirement,
SectionScores,
} from "@/actions/overview/types";
} from "@/actions/overview/threat-score";
import { RadialChart } from "@/components/graphs/radial-chart";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/shadcn";