mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2026-02-22 13:33:30 +01:00
MAESTRO: add analysis types
This commit is contained in:
79
frontend/src/types/analysis.test.ts
Normal file
79
frontend/src/types/analysis.test.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { describe, expectTypeOf, it } from "vitest";
|
||||
|
||||
import type {
|
||||
AnalysisConfig,
|
||||
AnalysisProgress,
|
||||
AnalysisReport,
|
||||
HeaderInput,
|
||||
TestResult,
|
||||
} from "./analysis";
|
||||
|
||||
describe("analysis types", () => {
|
||||
it("matches expected analysis config shape", () => {
|
||||
expectTypeOf<AnalysisConfig>().toEqualTypeOf<{
|
||||
testIds: number[];
|
||||
resolve: boolean;
|
||||
decodeAll: boolean;
|
||||
}>();
|
||||
});
|
||||
|
||||
it("matches expected header input shape", () => {
|
||||
expectTypeOf<HeaderInput>().toEqualTypeOf<{
|
||||
rawText: string;
|
||||
source: "paste" | "file";
|
||||
fileName?: string;
|
||||
}>();
|
||||
});
|
||||
|
||||
it("matches expected test result shape", () => {
|
||||
expectTypeOf<TestResult>().toEqualTypeOf<{
|
||||
testId: number;
|
||||
testName: string;
|
||||
headerName: string;
|
||||
headerValue: string;
|
||||
analysis: string;
|
||||
description: string;
|
||||
severity: "spam" | "suspicious" | "clean" | "info";
|
||||
status: "success" | "error" | "skipped";
|
||||
error?: string | null;
|
||||
}>();
|
||||
});
|
||||
|
||||
it("matches expected report shape", () => {
|
||||
expectTypeOf<AnalysisReport>().toEqualTypeOf<{
|
||||
results: TestResult[];
|
||||
hopChain: {
|
||||
index: number;
|
||||
hostname: string;
|
||||
ip?: string;
|
||||
timestamp?: string;
|
||||
serverInfo?: string;
|
||||
delay?: number | null;
|
||||
}[];
|
||||
securityAppliances: {
|
||||
name: string;
|
||||
vendor: string;
|
||||
headers: string[];
|
||||
}[];
|
||||
metadata: {
|
||||
totalTests: number;
|
||||
passedTests: number;
|
||||
failedTests: number;
|
||||
skippedTests: number;
|
||||
elapsedMs: number;
|
||||
timedOut: boolean;
|
||||
incompleteTests: string[];
|
||||
};
|
||||
}>();
|
||||
});
|
||||
|
||||
it("matches expected progress shape", () => {
|
||||
expectTypeOf<AnalysisProgress>().toEqualTypeOf<{
|
||||
currentIndex: number;
|
||||
totalTests: number;
|
||||
currentTest: string;
|
||||
elapsedMs: number;
|
||||
percentage: number;
|
||||
}>();
|
||||
});
|
||||
});
|
||||
69
frontend/src/types/analysis.ts
Normal file
69
frontend/src/types/analysis.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
export type HeaderInputSource = "paste" | "file";
|
||||
|
||||
export interface HeaderInput {
|
||||
rawText: string;
|
||||
source: HeaderInputSource;
|
||||
fileName?: string;
|
||||
}
|
||||
|
||||
export interface AnalysisConfig {
|
||||
testIds: number[];
|
||||
resolve: boolean;
|
||||
decodeAll: boolean;
|
||||
}
|
||||
|
||||
export type TestSeverity = "spam" | "suspicious" | "clean" | "info";
|
||||
|
||||
export type TestStatus = "success" | "error" | "skipped";
|
||||
|
||||
export interface TestResult {
|
||||
testId: number;
|
||||
testName: string;
|
||||
headerName: string;
|
||||
headerValue: string;
|
||||
analysis: string;
|
||||
description: string;
|
||||
severity: TestSeverity;
|
||||
status: TestStatus;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
export interface HopChainNode {
|
||||
index: number;
|
||||
hostname: string;
|
||||
ip?: string;
|
||||
timestamp?: string;
|
||||
serverInfo?: string;
|
||||
delay?: number | null;
|
||||
}
|
||||
|
||||
export interface SecurityAppliance {
|
||||
name: string;
|
||||
vendor: string;
|
||||
headers: string[];
|
||||
}
|
||||
|
||||
export interface ReportMetadata {
|
||||
totalTests: number;
|
||||
passedTests: number;
|
||||
failedTests: number;
|
||||
skippedTests: number;
|
||||
elapsedMs: number;
|
||||
timedOut: boolean;
|
||||
incompleteTests: string[];
|
||||
}
|
||||
|
||||
export interface AnalysisReport {
|
||||
results: TestResult[];
|
||||
hopChain: HopChainNode[];
|
||||
securityAppliances: SecurityAppliance[];
|
||||
metadata: ReportMetadata;
|
||||
}
|
||||
|
||||
export interface AnalysisProgress {
|
||||
currentIndex: number;
|
||||
totalTests: number;
|
||||
currentTest: string;
|
||||
elapsedMs: number;
|
||||
percentage: number;
|
||||
}
|
||||
Reference in New Issue
Block a user