51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
// ============================================================
|
|
// 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"}`;
|
|
}
|