25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import type { DatabaseType, TreeNode } from "@/types/database";
import { xuguDependencyProvider } from "@/lib/database/xuguObjectDependencies";
import { oracleDependencyProvider, dmTriggerDependencyProvider } from "@/lib/database/oracleObjectDependencies";
import { supportsTypeObjectSource } from "@/lib/database/databaseObjectCapabilities";
/**
* The subset of a sidebar node needed by a database dependency provider.
* Keeping this contract small lets providers remain independent of Vue state
* and makes it possible to test them without constructing a full tree node.
*/
export type DependencyTreeNode = Pick<TreeNode, "type" | "schema" | "objectName" | "label" | "parentType" | "parentName" | "parentSchema" | "meta">;
/**
* Database-specific dependency inspection contract.
*
* Providers own catalog SQL and object-type mappings. The sidebar only asks
* whether a node is supported and executes the returned read-only query.
*/
export interface DatabaseDependencyProvider {
readonly databaseType: DatabaseType;
supports(node: DependencyTreeNode): boolean;
buildQuery(node: DependencyTreeNode): string | null;
targetLabel?(node: DependencyTreeNode): { name: string; packageScope?: boolean } | null;
}
const PROVIDERS: Partial<Record<DatabaseType, DatabaseDependencyProvider>> = {
xugu: xuguDependencyProvider,
oracle: oracleDependencyProvider,
"oceanbase-oracle": oracleDependencyProvider,
dameng: dmTriggerDependencyProvider,
};
export function databaseDependencyProviderFor(databaseType?: DatabaseType): DatabaseDependencyProvider | null {
return databaseType ? (PROVIDERS[databaseType] ?? null) : null;
}
export function canViewDatabaseObjectDependencies(databaseType: DatabaseType | undefined, node: DependencyTreeNode): boolean {
if (databaseType === "oracle" || databaseType === "oceanbase-oracle") {
if ((node.type === "type" || node.type === "type-body") && !supportsTypeObjectSource(databaseType)) return false;
if (node.type === "index" && (!node.parentName || !node.parentSchema)) return false;
}
return databaseDependencyProviderFor(databaseType)?.supports(node) ?? false;
}