Add MVP operational readiness checks
This commit is contained in:
82
lib/operational-readiness.ts
Normal file
82
lib/operational-readiness.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
export type IntegrationReadinessStatus = "configured" | "missing";
|
||||
|
||||
export type IntegrationReadinessDefinition = {
|
||||
id:
|
||||
| "google"
|
||||
| "pagespeed"
|
||||
| "openrouter"
|
||||
| "playwright"
|
||||
| "smtp"
|
||||
| "convex_jobs"
|
||||
| "rybbit";
|
||||
label: string;
|
||||
requiredEnv: string[];
|
||||
errorSurface: string;
|
||||
};
|
||||
|
||||
export type IntegrationReadinessRow = IntegrationReadinessDefinition & {
|
||||
status: IntegrationReadinessStatus;
|
||||
missingEnv: string[];
|
||||
};
|
||||
|
||||
export const integrationReadinessDefinitions: IntegrationReadinessDefinition[] = [
|
||||
{
|
||||
id: "google",
|
||||
label: "Google",
|
||||
requiredEnv: ["GOOGLE_GEOCODING_API_KEY", "GOOGLE_PLACES_API_KEY"],
|
||||
errorSurface: "Run-Events der Lead-Recherche zeigen Google-Fehler.",
|
||||
},
|
||||
{
|
||||
id: "pagespeed",
|
||||
label: "PageSpeed",
|
||||
requiredEnv: ["PAGESPEED_API_KEY", "PAGESPEED_TIMEOUT_MS"],
|
||||
errorSurface: "PageSpeed-Run-Events und Audit-Quellen zeigen Fehlerdetails.",
|
||||
},
|
||||
{
|
||||
id: "openrouter",
|
||||
label: "OpenRouter",
|
||||
requiredEnv: ["OPENROUTER_API_KEY"],
|
||||
errorSurface: "Audit-Generierungsruns zeigen Modell- und Guard-Fehler.",
|
||||
},
|
||||
{
|
||||
id: "playwright",
|
||||
label: "Playwright",
|
||||
requiredEnv: ["TASK8_BROWSER_ASSET_URL"],
|
||||
errorSurface: "Website-Enrichment-Runs zeigen Browser- und Crawl-Fehler.",
|
||||
},
|
||||
{
|
||||
id: "smtp",
|
||||
label: "SMTP",
|
||||
requiredEnv: ["SMTP_HOST", "SMTP_USER", "SMTP_PASSWORD", "SMTP_FROM"],
|
||||
errorSurface: "Outreach-Sendeversuche zeigen SMTP-Fehler ohne Credentials.",
|
||||
},
|
||||
{
|
||||
id: "convex_jobs",
|
||||
label: "Convex Jobs",
|
||||
requiredEnv: ["NEXT_PUBLIC_CONVEX_URL", "CONVEX_DEPLOYMENT"],
|
||||
errorSurface: "Kampagnen-Run-Logs und Lifecycle-Runs zeigen Job-Status.",
|
||||
},
|
||||
{
|
||||
id: "rybbit",
|
||||
label: "Rybbit",
|
||||
requiredEnv: ["RYBBIT_API_URL", "RYBBIT_API_KEY", "NEXT_PUBLIC_RYBBIT_SITE_ID"],
|
||||
errorSurface: "Analytics zeigt API-Fehler als nicht blockierende Meldung.",
|
||||
},
|
||||
];
|
||||
|
||||
export function getIntegrationReadiness(
|
||||
env: Record<string, string | undefined>,
|
||||
): IntegrationReadinessRow[] {
|
||||
return integrationReadinessDefinitions.map((definition) => {
|
||||
const missingEnv = definition.requiredEnv.filter((key) => {
|
||||
const value = env[key];
|
||||
return !value || value.trim().length === 0;
|
||||
});
|
||||
|
||||
return {
|
||||
...definition,
|
||||
missingEnv,
|
||||
status: missingEnv.length === 0 ? "configured" : "missing",
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user