refactor web structure (re-org to utils)

This commit is contained in:
Oliver Kieselbach
2026-04-14 11:29:55 +02:00
parent a3e8e0449a
commit ebc588c460
19 changed files with 29 additions and 30 deletions
@@ -1,15 +1,12 @@
"use client";
import { useState, useMemo } from "react";
import { validateDiagnosticsPath } from "@/lib/guardValidation";
import { validateDiagnosticsPath } from "@/utils/guardValidation";
import { ValidationIndicator } from "@/components/ValidationIndicator";
import type { DiagnosticsLogPath } from "@/types/diagnostics";
export interface DiagnosticsLogPath {
path: string;
description: string;
isBuiltIn: boolean;
includeSubfolders?: boolean;
}
// Re-export so existing consumers importing from this component keep working
export type { DiagnosticsLogPath };
interface DiagnosticsLogPathsSectionProps {
globalDiagPaths: DiagnosticsLogPath[];
@@ -5,7 +5,7 @@ import { api } from "@/lib/api";
import { authenticatedFetch, TokenExpiredError } from "@/lib/authenticatedFetch";
import { TenantConfiguration } from "./TenantManagementSection";
import { TenantSearchSelect } from "./TenantSearchSelect";
import { SessionExportEvent, generateCsvExport, generateUiExport } from "@/lib/sessionExportUtils";
import { SessionExportEvent, generateCsvExport, generateUiExport } from "@/utils/sessionExportUtils";
import { trackEvent } from "@/lib/appInsights";
function downloadFile(content: string, filename: string, mimeType: string) {
@@ -3,7 +3,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { api } from "@/lib/api";
import { authenticatedFetch, TokenExpiredError } from "@/lib/authenticatedFetch";
import { asGuidOrUndefined } from "@/lib/inputValidation";
import { asGuidOrUndefined } from "@/utils/inputValidation";
import type { NotificationType } from "@/contexts/NotificationContext";
import type { Session } from "../types";
@@ -6,7 +6,7 @@ import {
COMMAND_CATEGORIES,
ALLOWED_FILE_PREFIXES,
ALLOWED_WMI_QUERY_PREFIXES,
} from "@/lib/guardrails.generated";
} from "@/utils/guardrails.generated";
function GuardToggle({ label, children }: { label: string; children: React.ReactNode }) {
const [open, setOpen] = useState(false);
@@ -4,7 +4,7 @@ import { useMemo, useState } from "react";
import { GatherRule, NewRuleForm, CATEGORY_COLORS, COLLECTOR_TYPE_LABELS, EMPTY_FORM, formatTrigger } from "../types";
import { GatherRuleFormFields } from "./GatherRuleFormFields";
import { FormJsonToggle, JsonModeToggleButtons, ReadOnlyJsonView } from "@/components/rules/FormJsonToggle";
import { validateGatherRuleTarget } from "@/lib/guardValidation";
import { validateGatherRuleTarget } from "@/utils/guardValidation";
import { ValidationIndicator } from "@/components/ValidationIndicator";
import { stripInternalFields } from "@/lib/rulePageHelpers";
@@ -13,7 +13,7 @@ import {
formatTrigger,
} from "../types";
import { KNOWN_EVENT_TYPES, findEventType } from "../eventTypes";
import { validateGatherRuleTarget } from "@/lib/guardValidation";
import { validateGatherRuleTarget } from "@/utils/guardValidation";
import { ValidationIndicator } from "@/components/ValidationIndicator";
interface GatherRuleFormFieldsProps {
@@ -1,4 +1,4 @@
import { validateBootstrapResponse } from "@/lib/bootstrapValidation";
import { validateBootstrapResponse } from "@/utils/bootstrapValidation";
export const runtime = "nodejs";
@@ -79,7 +79,7 @@ function errorScript(message: string): Response {
}
// SECURITY INVARIANT: All template parameters MUST come from
// validateBootstrapResponse() in @/lib/bootstrapValidation. The single-quoted
// validateBootstrapResponse() in @/utils/bootstrapValidation. The single-quoted
// PowerShell string literals below are the second line of defense against
// injection (single-quoted PS strings do NOT expand $(...), $var, or
// backticks). Do NOT change to double-quoted without re-reviewing the
@@ -3,7 +3,7 @@
import { useState, useMemo } from "react";
import { EnrollmentEvent } from "@/types";
import OobeConfigModal from "./OobeConfigModal";
import { compareVersions, stripGitHashSuffix } from "@/lib/bootstrapVersion";
import { compareVersions, stripGitHashSuffix } from "@/utils/bootstrapVersion";
export default function DeviceDetailsCard({ events, latestAgentVersion }: { events: EnrollmentEvent[]; latestAgentVersion?: string | null }) {
const [expanded, setExpanded] = useState(false);
@@ -3,7 +3,7 @@ import { useState, useCallback } from "react";
import { api } from "@/lib/api";
import { authenticatedFetch } from "@/lib/authenticatedFetch";
import { RuleResult } from "@/types";
import { isGuid } from "@/lib/inputValidation";
import { isGuid } from "@/utils/inputValidation";
export function useSessionAnalysis(
sessionId: string,
@@ -30,11 +30,11 @@ import { usePageSections } from "../../../hooks/usePageSections";
import { PageSectionItem } from "../../../contexts/SidebarContext";
import { InformationCircleIcon, ComputerDesktopIcon, PlayCircleIcon, SparklesIcon, ChartBarIcon, CodeBracketIcon, ArrowDownTrayIcon, ListBulletIcon, ClockIcon, ShieldCheckIcon } from "../../../lib/sidebarIcons";
import DeviceDetailsCard from "./components/DeviceDetailsCard";
import { generateUiExport, generateCsvExport, generateSessionCsvExport, generateRuleResultsCsvExport, SessionExportEvent } from "@/lib/sessionExportUtils";
import { generateUiExport, generateCsvExport, generateSessionCsvExport, generateRuleResultsCsvExport, SessionExportEvent } from "@/utils/sessionExportUtils";
import { Session, EnrollmentEvent, RuleResult } from "@/types";
import { trackEvent } from "@/lib/appInsights";
import { useAdminMode } from "@/hooks/useAdminMode";
import { isGuid } from "@/lib/inputValidation";
import { isGuid } from "@/utils/inputValidation";
export default function SessionDetailPage() {
const params = useParams();
@@ -2,7 +2,7 @@
import { useMemo, useState } from "react";
import { DiagnosticsLogPath } from "../types";
import { validateDiagnosticsPath } from "@/lib/guardValidation";
import { validateDiagnosticsPath } from "@/utils/guardValidation";
import { ValidationIndicator } from "@/components/ValidationIndicator";
import SaveResetBar from "./SaveResetBar";
@@ -1,9 +1,4 @@
export interface DiagnosticsLogPath {
path: string;
description: string;
isBuiltIn: boolean;
includeSubfolders?: boolean;
}
export type { DiagnosticsLogPath } from "@/types/diagnostics";
export interface TenantConfiguration {
tenantId: string;
+1 -1
View File
@@ -1,6 +1,6 @@
import type { MetadataRoute } from "next";
import { NAV_SECTIONS } from "./docs/docsNavSections";
import { PAGE_LASTMOD } from "../lib/page-lastmod.generated";
import { PAGE_LASTMOD } from "@/utils/page-lastmod.generated";
const BASE_URL = "https://www.autopilotmonitor.com";
@@ -1,7 +1,7 @@
"use client";
import { useMemo, useState } from "react";
import { compareVersions, extractBootstrapVersion } from "@/lib/bootstrapVersion";
import { compareVersions, extractBootstrapVersion } from "@/utils/bootstrapVersion";
interface ScriptEvent {
timestamp: string;
@@ -1,6 +1,6 @@
"use client";
import { ValidationResult } from "@/lib/guardValidation";
import { ValidationResult } from "@/utils/guardValidation";
interface ValidationIndicatorProps {
result: ValidationResult | null;
+1 -1
View File
@@ -2,7 +2,7 @@
* Typed API URL builder
* All backend endpoint URLs are defined here for type-safety and maintainability.
*/
import { API_BASE_URL } from "./config";
import { API_BASE_URL } from "@/utils/config";
function qs(params: Record<string, string | undefined>): string {
const p = new URLSearchParams();
@@ -11,7 +11,7 @@ const fs = require("fs");
const path = require("path");
const WEB_ROOT = path.resolve(__dirname, "..");
const OUTPUT_FILE = path.join(WEB_ROOT, "lib/page-lastmod.generated.ts");
const OUTPUT_FILE = path.join(WEB_ROOT, "utils/page-lastmod.generated.ts");
// URL path -> source file(s) relative to WEB_ROOT
// For docs sections, we check the section component file
@@ -0,0 +1,6 @@
export interface DiagnosticsLogPath {
path: string;
description: string;
isBuiltIn: boolean;
includeSubfolders?: boolean;
}
@@ -1,3 +1,4 @@
export type { Session } from "./session";
export type { EnrollmentEvent, RuleResult } from "./enrollment";
export type { AdminConfiguration, OpsAlertRule } from "./adminConfig";
export type { DiagnosticsLogPath } from "./diagnostics";