feat: verificación post-importación con aviso detallado de fallas

This commit is contained in:
Nurfog committed 2026-09-10 12:17:37 -03:00
1 parent 33d2cc2bcb
commit 16940d5f99
3 files changed
+494 -27

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
// ============================================================
// Verificación post-importación: tipos compartidos cliente/servidor.
// El deployer expone GET /api/modules/:name/verify con este contrato;
// si el deployer es antiguo (sin endpoint), la ruta del portal
// /api/modules/[name]/verify reconstruye un resultado equivalente.
// ============================================================
export interface VerifyCheck {
id: string;
label: string;
ok: boolean;
detail: string;
}
export interface VerifyResult {
ok: boolean;
module: string;
container: string | null;
containerStatus: string | null;
httpStatus: number | null;
checks: VerifyCheck[];
logsTail: string;
time: string;
/** Origen del resultado: deployer directo o reconstruido por el portal. */
source?: "deployer" | "portal";
/** URL pública verificada por el portal (si aplica). */
publicUrl?: string | null;
publicStatus?: number | null;
}
export const VERIFY_STEP_META: { id: string; label: string; icon: string }[] = [
{ id: "register", label: "Registro y deploy", icon: "bx-rocket" },
{ id: "container", label: "Contenedor en ejecución", icon: "bx-cube" },
{ id: "logs", label: "Logs sin errores", icon: "bx-terminal" },
{ id: "http-root", label: "Aplicación responde", icon: "bx-globe" },
{ id: "http-extra", label: "Contenido válido", icon: "bx-check-shield" },
{ id: "caddy", label: "Ruta pública", icon: "bx-link" },
];
export function failedChecks(v: VerifyResult | null | undefined): VerifyCheck[] {
if (!v) return [];
return v.checks.filter((c) => !c.ok);
}
/** Resumen de una línea para el aviso a quien importa. */
export function verifySummary(v: VerifyResult): string {
if (v.ok) return `"${v.module}" verificado: contenedor ${v.containerStatus || "running"} + HTTP ${v.httpStatus}`;
const failed = failedChecks(v).map((c) => c.label).join(", ");
return `"${v.module}" FALLÓ verificación en: ${failed || "paso desconocido"}`;
}