mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-02 02:34:42 +08:00
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import type { ConnectionConfig } from "@/types/database";
|
|
import { resolveDefaultDatabase } from "@/lib/database/defaultDatabase";
|
|
|
|
export type QuickConnectionOpenTarget = { kind: "mq-admin" } | { kind: "nacos-admin" } | { kind: "plugin-workbench" } | { kind: "etcd" } | { kind: "zookeeper" } | { kind: "consul" } | { kind: "query"; database: string };
|
|
|
|
export function quickConnectionOpenTarget(connection: Pick<ConnectionConfig, "db_type" | "database">, databaseOptions: string[] = []): QuickConnectionOpenTarget {
|
|
if (connection.db_type === "mq") {
|
|
return { kind: "mq-admin" };
|
|
}
|
|
if (connection.db_type === "nacos") {
|
|
return { kind: "nacos-admin" };
|
|
}
|
|
if (connection.db_type === "plugin") {
|
|
return { kind: "plugin-workbench" };
|
|
}
|
|
if (connection.db_type === "etcd") {
|
|
return { kind: "etcd" };
|
|
}
|
|
if (connection.db_type === "zookeeper") {
|
|
return { kind: "zookeeper" };
|
|
}
|
|
if (connection.db_type === "consul") {
|
|
return { kind: "consul" };
|
|
}
|
|
return { kind: "query", database: resolveDefaultDatabase(connection, databaseOptions) };
|
|
}
|