UNPKG

@copilotkit/shared

Version:

<div align="center"> <a href="https://copilotkit.ai" target="_blank"> <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo"> </a>

40 lines (36 loc) 1.27 kB
import chalk from "chalk"; export function flattenObject( obj: Record<string, any>, parentKey = "", res: Record<string, any> = {}, ): Record<string, any> { for (let key in obj) { const propName = parentKey ? `${parentKey}.${key}` : key; if (typeof obj[key] === "object" && obj[key] !== null) { flattenObject(obj[key], propName, res); } else { res[propName] = obj[key]; } } return res; } export function printSecurityNotice(advisory: { advisory: string | null; message: string; severity: "low" | "medium" | "high" | "none"; }) { const severityColor = { low: chalk.blue, medium: chalk.yellow, high: chalk.red, }[advisory.severity.toLowerCase()] || chalk.white; console.log(); console.log(`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`); console.log(); console.log(`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`); console.log(); console.log(`${chalk.bold(advisory.message)}`); console.log(); console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`); }