61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import type { IntegrationStatus } from "@/types/appops";
|
|
|
|
export type IntegrationFlowState = "healthy" | "warning" | "critical" | "stopped" | "loading" | "unknown";
|
|
|
|
export interface IntegrationRuntimeStates {
|
|
mcp: IntegrationFlowState;
|
|
rag: IntegrationFlowState;
|
|
n8n: IntegrationFlowState;
|
|
executionBoundary: IntegrationFlowState;
|
|
}
|
|
|
|
export const getIntegrationRuntimeStates = (
|
|
status: IntegrationStatus | undefined,
|
|
loading: boolean,
|
|
unavailable: boolean,
|
|
): IntegrationRuntimeStates => {
|
|
if (unavailable) {
|
|
return { mcp: "unknown", rag: "unknown", n8n: "unknown", executionBoundary: "unknown" };
|
|
}
|
|
if (loading || !status) {
|
|
return { mcp: "loading", rag: "loading", n8n: "loading", executionBoundary: "loading" };
|
|
}
|
|
|
|
const mcp: IntegrationFlowState = !status.mcp.enabled
|
|
? "stopped"
|
|
: status.mcp.authenticated && status.mcp.state === "listening"
|
|
? "healthy"
|
|
: "warning";
|
|
|
|
const rag: IntegrationFlowState = status.rag.secretsIndexed
|
|
? "critical"
|
|
: status.rag.status === "ready" && status.rag.secretScanStatus?.startsWith("passed")
|
|
? "healthy"
|
|
: "warning";
|
|
|
|
const n8n: IntegrationFlowState = status.n8n.canExecute
|
|
? "critical"
|
|
: !status.n8n.enabled
|
|
? "stopped"
|
|
: status.n8n.authenticated && status.n8n.state === "reachable"
|
|
? "healthy"
|
|
: "warning";
|
|
|
|
const executionBoundary: IntegrationFlowState = status.n8n.canExecute === true
|
|
? "critical"
|
|
: status.n8n.canExecute === false
|
|
? "healthy"
|
|
: "unknown";
|
|
|
|
return { mcp, rag, n8n, executionBoundary };
|
|
};
|
|
|
|
export const integrationFlowStateLabel: Record<IntegrationFlowState, string> = {
|
|
healthy: "geverifieerd",
|
|
warning: "aandacht",
|
|
critical: "kritiek",
|
|
stopped: "uitgeschakeld",
|
|
loading: "controleren",
|
|
unknown: "onbekend",
|
|
};
|