feat(zookeeper): add agent client browsing and node management
This commit is contained in:
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 15 KiB |
@@ -1036,6 +1036,8 @@ async function handleQuickOpenSelect(item: any) {
|
||||
await connectionStore.loadRedisDatabases(item.connectionId);
|
||||
} else if (config?.db_type === "etcd") {
|
||||
await connectionStore.loadEtcdRoot(item.connectionId);
|
||||
} else if (config?.db_type === "zookeeper") {
|
||||
await connectionStore.loadZooKeeperRoot(item.connectionId);
|
||||
} else if (config?.db_type === "mongodb") {
|
||||
await connectionStore.loadMongoDatabases(item.connectionId);
|
||||
} else if (config?.db_type === "elasticsearch") {
|
||||
@@ -1059,6 +1061,8 @@ async function handleQuickOpenSelect(item: any) {
|
||||
await connectionStore.loadRedisDatabases(item.connectionId);
|
||||
} else if (config?.db_type === "etcd") {
|
||||
await connectionStore.loadEtcdRoot(item.connectionId);
|
||||
} else if (config?.db_type === "zookeeper") {
|
||||
await connectionStore.loadZooKeeperRoot(item.connectionId);
|
||||
} else if (config?.db_type === "mongodb") {
|
||||
await connectionStore.loadMongoDatabases(item.connectionId);
|
||||
} else if (config?.db_type === "elasticsearch") {
|
||||
|
||||
@@ -26,6 +26,7 @@ import { applyParsedConnectionUrl, normalizeMongoConnectionString, parseConnecti
|
||||
import type { ConnectionDeepLinkDraft } from "@/lib/connectionDeepLink";
|
||||
import { connectionUrlPlaceholder as getUrlPlaceholder } from "@/lib/connectionPresentation";
|
||||
import { h2ConnectionModeForConfig, h2FileJdbcUrl, h2FilePathFromJdbcUrl, type H2ConnectionMode } from "@/lib/h2Connection";
|
||||
import { firstZooKeeperEndpoint, normalizeZooKeeperConnectString } from "@/lib/zookeeperConnection";
|
||||
import { isLocalFileTypeDb } from "@/lib/connectionFile";
|
||||
import { MQ_PINNED_VERSION_OPTIONS, pinnedVersionToSelection, selectionToPinnedVersion } from "@/lib/mqPinnedVersionOptions";
|
||||
import { mongodbAuthFailureHint, mongoUrlParam, setMongoUrlParam } from "@/lib/mongoConnectionOptions";
|
||||
@@ -523,6 +524,7 @@ const driverProfiles: Record<
|
||||
xugu: { type: "xugu", port: 5138, user: "", label: "虚谷 XuguDB", icon: "xugu" },
|
||||
iotdb: { type: "iotdb", port: 6667, user: "root", label: "Apache IoTDB", icon: "iotdb" },
|
||||
etcd: { type: "etcd", port: 2379, user: "", label: "etcd", icon: "etcd" },
|
||||
zookeeper: { type: "zookeeper", port: 2181, user: "", label: "Apache ZooKeeper", icon: "zookeeper" },
|
||||
mq: { type: "mq", port: 8080, user: "", label: "Apache Pulsar", icon: "pulsar", host: "127.0.0.1" },
|
||||
nacos: { type: "nacos", port: 8848, user: "nacos", label: "Nacos", icon: "nacos", host: "127.0.0.1" },
|
||||
iris: { type: "iris", port: 1972, user: "_SYSTEM", label: "IRIS", icon: "iris" },
|
||||
@@ -799,6 +801,14 @@ function applyProfile(val: string, preserveConnectionFields = false) {
|
||||
form.value.database = undefined;
|
||||
form.value.connection_string = undefined;
|
||||
}
|
||||
if (profile.type === "zookeeper") {
|
||||
form.value.database = undefined;
|
||||
form.value.connection_string = "";
|
||||
form.value.ssl = false;
|
||||
form.value.ca_cert_path = "";
|
||||
form.value.client_cert_path = "";
|
||||
form.value.client_key_path = "";
|
||||
}
|
||||
if (profile.type === "nacos") {
|
||||
resetNacosFields();
|
||||
form.value.database = undefined;
|
||||
@@ -1042,6 +1052,7 @@ const iconTypeMap: Record<string, string> = {
|
||||
xugu: "xugu",
|
||||
iotdb: "iotdb",
|
||||
etcd: "etcd",
|
||||
zookeeper: "zookeeper",
|
||||
mq: "mq",
|
||||
nacos: "nacos",
|
||||
dm: "dm",
|
||||
@@ -1126,6 +1137,7 @@ const dbOptions: DbOption[] = [
|
||||
{ value: "xugu", label: "虚谷 XuguDB" },
|
||||
{ value: "iotdb", label: "Apache IoTDB" },
|
||||
{ value: "etcd", label: "etcd" },
|
||||
{ value: "zookeeper", label: "Apache ZooKeeper" },
|
||||
{ value: "mq", label: "Apache Pulsar" },
|
||||
{ value: "nacos", label: "Nacos" },
|
||||
{ value: "influxdb", label: "InfluxDB" },
|
||||
@@ -1251,6 +1263,12 @@ const etcdEndpointsLines = computed({
|
||||
form.value.etcd_endpoints = normalizeEndpointLines(value);
|
||||
},
|
||||
});
|
||||
const zookeeperConnectString = computed({
|
||||
get: () => form.value.connection_string || "",
|
||||
set: (value: string) => {
|
||||
form.value.connection_string = normalizeZooKeeperConnectString(value);
|
||||
},
|
||||
});
|
||||
const canUseTransportLayers = computed(() => form.value.db_type !== "sqlite" && form.value.db_type !== "access" && !isH2FileMode.value);
|
||||
const shouldShowAgentDriverInstallHint = computed(() => showAgentDriverInstallHint(form.value.db_type, agentDrivers.value, form.value.driver_profile));
|
||||
const h2DriverMissing = computed(() => form.value.db_type === "h2" && isH2FileMode.value && agentDrivers.value.find((d) => d.db_type === "h2")?.installed !== true);
|
||||
@@ -1284,6 +1302,7 @@ const testResultMessage = computed(() => {
|
||||
});
|
||||
const hasRequiredConnectionTarget = computed(() => {
|
||||
if (form.value.db_type === "mq") return !!mqAdminUrl.value.trim();
|
||||
if (form.value.db_type === "zookeeper") return !!(form.value.host || form.value.connection_string || connectionUrlInput.value.trim());
|
||||
if (form.value.db_type === "nacos") return !!nacosServerAddr.value.trim();
|
||||
if (isH2FileMode.value) return !!(form.value.host.trim() || h2FilePathFromJdbcUrl(form.value.connection_string));
|
||||
return !!(form.value.host || (mongoUseUrl.value && form.value.connection_string) || (form.value.db_type === "jdbc" && form.value.connection_string) || connectionUrlInput.value.trim());
|
||||
@@ -1500,6 +1519,17 @@ function connectionConfigForSubmit(id: string): ConnectionConfig {
|
||||
if (config.db_type === "redis") {
|
||||
config.redis_key_separator = config.redis_key_separator?.trim() ?? ":";
|
||||
}
|
||||
if (config.db_type === "zookeeper") {
|
||||
const normalizedConnectString = normalizeZooKeeperConnectString(config.connection_string || "");
|
||||
config.connection_string = normalizedConnectString || undefined;
|
||||
const firstEndpoint = firstZooKeeperEndpoint(normalizedConnectString || (config.host ? `${config.host}:${config.port || 2181}` : ""));
|
||||
if (firstEndpoint) {
|
||||
config.host = firstEndpoint.host;
|
||||
config.port = firstEndpoint.port;
|
||||
}
|
||||
config.database = undefined;
|
||||
config.ssl = false;
|
||||
}
|
||||
if (config.db_type === "etcd") {
|
||||
config.etcd_endpoints = normalizeEndpointLines(config.etcd_endpoints || "");
|
||||
const firstEndpoint = firstEtcdEndpoint(config.etcd_endpoints);
|
||||
@@ -3083,6 +3113,37 @@ function openExternalUrl(url: string) {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- ZooKeeper: host, connect string, user, password -->
|
||||
<template v-else-if="form.db_type === 'zookeeper'">
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label class="text-right">{{ t("connection.host") }}</Label>
|
||||
<Input v-model="form.host" class="col-span-2" placeholder="127.0.0.1" />
|
||||
<Input v-model.number="form.port" type="number" class="col-span-1" />
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-start gap-4">
|
||||
<Label class="text-right mt-2">{{ t("connection.zookeeperConnectString") }}</Label>
|
||||
<div class="col-span-3 space-y-1">
|
||||
<textarea
|
||||
v-model="zookeeperConnectString"
|
||||
class="flex min-h-[76px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
||||
placeholder="127.0.0.1:2181 zk-2:2181"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t("connection.zookeeperConnectStringHint") }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label class="text-right">{{ t("connection.user") }}</Label>
|
||||
<Input v-model="form.username" class="col-span-3" />
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label class="text-right">{{ t("connection.password") }}</Label>
|
||||
<PasswordInput v-model="form.password" class="col-span-3" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- MongoDB: URL or form -->
|
||||
<template v-else-if="form.db_type === 'mongodb'">
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
|
||||
@@ -114,7 +114,11 @@ const showModified = ref(true);
|
||||
|
||||
let syncPlanRequestId = 0;
|
||||
|
||||
<<<<<<< HEAD
|
||||
const sqlConnections = computed(() => store.connections.filter((connection) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "etcd", "zookeeper", "mq", "nacos"].includes(connection.db_type)));
|
||||
=======
|
||||
const sqlConnections = computed(() => store.connections.filter((connection) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "mq", "nacos"].includes(connection.db_type)));
|
||||
>>>>>>> origin/main
|
||||
const selectedSourceTableNames = computed(() => sourceTables.value.filter((table) => selectedSourceTables.value.has(table)));
|
||||
const isBatchCompare = computed(() => selectedSourceTableNames.value.length > 1);
|
||||
const filteredSourceTables = computed(() => {
|
||||
|
||||
@@ -1,297 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ChevronDown, ChevronRight, FolderClosed, FolderOpen, KeyRound, Loader2, Plus, RefreshCw, Search, Trash2 } from "@lucide/vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";
|
||||
import KvKeyBrowser from "@/components/kv/KvKeyBrowser.vue";
|
||||
import * as api from "@/lib/api";
|
||||
import type { KvGetResponse, KvKeySummary, KvValue } from "@/lib/api";
|
||||
import { buildEtcdKeyTree, collectEtcdGroupIds, flattenVisibleEtcdKeyTree, type EtcdKeyTreeNode } from "@/lib/etcdKeyTree";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
|
||||
const props = defineProps<{ connectionId: string }>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const searchInputRef = ref<HTMLInputElement>();
|
||||
const prefix = ref("");
|
||||
const keys = ref<KvKeySummary[]>([]);
|
||||
const continuation = ref<string | null>(null);
|
||||
const loading = ref(false);
|
||||
const loadingMore = ref(false);
|
||||
const expandedGroupIds = ref<Set<string>>(new Set());
|
||||
const selectedKey = ref<string | null>(null);
|
||||
const selectedValue = ref<KvGetResponse | null>(null);
|
||||
const detailLoading = ref(false);
|
||||
const detailError = ref("");
|
||||
const showEditDialog = ref(false);
|
||||
const editKey = ref("");
|
||||
const editValue = ref("");
|
||||
const editError = ref("");
|
||||
const saving = ref(false);
|
||||
const showDeleteConfirm = ref(false);
|
||||
const deleting = ref(false);
|
||||
const pageSize = 200;
|
||||
const browserRef = ref<InstanceType<typeof KvKeyBrowser> | null>(null);
|
||||
|
||||
const tree = computed(() => buildEtcdKeyTree(keys.value));
|
||||
const visibleRows = computed(() => flattenVisibleEtcdKeyTree(tree.value, expandedGroupIds.value));
|
||||
const selectedMetadata = computed(() => selectedValue.value?.metadata ?? keys.value.find((key) => key.key === selectedKey.value));
|
||||
const selectedTextValue = computed(() => {
|
||||
const value = selectedValue.value?.value;
|
||||
if (!value) return "";
|
||||
return value.encoding === "utf8" ? value.data : value.data;
|
||||
});
|
||||
const selectedValueIsBase64 = computed(() => selectedValue.value?.value?.encoding === "base64");
|
||||
const etcdApi = {
|
||||
listPrefix: api.etcdListPrefix,
|
||||
get: api.etcdGet,
|
||||
put: (connectionId: string, key: string, value: api.KvValue) => api.etcdPut(connectionId, key, value),
|
||||
deleteKey: api.etcdDelete,
|
||||
};
|
||||
|
||||
function preserveExpandedGroups(expandAll = false) {
|
||||
const available = collectEtcdGroupIds(tree.value);
|
||||
const next = new Set<string>();
|
||||
for (const id of expandAll ? available : expandedGroupIds.value) {
|
||||
if (available.has(id)) next.add(id);
|
||||
}
|
||||
expandedGroupIds.value = next;
|
||||
}
|
||||
|
||||
async function loadKeys(reset = true) {
|
||||
if (reset) {
|
||||
loading.value = true;
|
||||
continuation.value = null;
|
||||
keys.value = [];
|
||||
selectedKey.value = null;
|
||||
selectedValue.value = null;
|
||||
} else {
|
||||
loadingMore.value = true;
|
||||
}
|
||||
try {
|
||||
const result = await api.etcdListPrefix(props.connectionId, prefix.value.trim(), pageSize, reset ? null : continuation.value);
|
||||
const existing = new Set(keys.value.map((key) => key.key));
|
||||
const merged = reset ? result.keys : [...keys.value, ...result.keys.filter((key) => !existing.has(key.key))];
|
||||
keys.value = merged;
|
||||
continuation.value = result.continuation || null;
|
||||
preserveExpandedGroups(!!prefix.value.trim());
|
||||
} finally {
|
||||
loading.value = false;
|
||||
loadingMore.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSelectedKey(key: string) {
|
||||
selectedKey.value = key;
|
||||
detailLoading.value = true;
|
||||
detailError.value = "";
|
||||
try {
|
||||
selectedValue.value = await api.etcdGet(props.connectionId, key);
|
||||
} catch (error) {
|
||||
detailError.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleGroup(node: EtcdKeyTreeNode) {
|
||||
if (node.kind !== "group") return;
|
||||
const next = new Set(expandedGroupIds.value);
|
||||
if (next.has(node.id)) next.delete(node.id);
|
||||
else next.add(node.id);
|
||||
expandedGroupIds.value = next;
|
||||
}
|
||||
|
||||
function onRowClick(node: EtcdKeyTreeNode) {
|
||||
if (node.kind === "group") {
|
||||
toggleGroup(node);
|
||||
} else {
|
||||
void loadSelectedKey(node.key);
|
||||
}
|
||||
}
|
||||
|
||||
function openCreateDialog() {
|
||||
editKey.value = prefix.value.trim();
|
||||
editValue.value = "";
|
||||
editError.value = "";
|
||||
showEditDialog.value = true;
|
||||
}
|
||||
|
||||
function openEditDialog() {
|
||||
if (!selectedKey.value) return;
|
||||
editKey.value = selectedKey.value;
|
||||
editValue.value = selectedTextValue.value;
|
||||
editError.value = selectedValueIsBase64.value ? t("etcd.base64Readonly") : "";
|
||||
showEditDialog.value = true;
|
||||
}
|
||||
|
||||
async function saveKey() {
|
||||
const key = editKey.value.trim();
|
||||
if (!key) {
|
||||
editError.value = t("etcd.keyRequired");
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
editError.value = "";
|
||||
try {
|
||||
const value: KvValue = { encoding: "utf8", data: editValue.value };
|
||||
await api.etcdPut(props.connectionId, key, value);
|
||||
showEditDialog.value = false;
|
||||
await loadKeys(true);
|
||||
await loadSelectedKey(key);
|
||||
toast(t("etcd.saved"), 2500);
|
||||
} catch (error) {
|
||||
editError.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSelectedKey() {
|
||||
if (!selectedKey.value) return;
|
||||
deleting.value = true;
|
||||
try {
|
||||
await api.etcdDelete(props.connectionId, selectedKey.value);
|
||||
showDeleteConfirm.value = false;
|
||||
selectedKey.value = null;
|
||||
selectedValue.value = null;
|
||||
await loadKeys(true);
|
||||
toast(t("etcd.deleted"), 2500);
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function metadataLabel(value: number | null | undefined): string {
|
||||
return value == null ? "-" : String(value);
|
||||
}
|
||||
const labels = computed(() => ({
|
||||
prefixPlaceholder: t("etcd.prefixPlaceholder"),
|
||||
newKey: t("etcd.newKey"),
|
||||
loadingKeys: t("etcd.loadingKeys"),
|
||||
empty: t("etcd.empty"),
|
||||
loadMore: t("etcd.loadMore"),
|
||||
selectKey: t("etcd.selectKey"),
|
||||
loadingValue: t("etcd.loadingValue"),
|
||||
notFound: t("etcd.notFound"),
|
||||
edit: t("etcd.edit"),
|
||||
editKey: t("etcd.editKey"),
|
||||
delete: t("etcd.delete"),
|
||||
deleteTitle: t("etcd.deleteTitle"),
|
||||
keyPlaceholder: t("etcd.keyPlaceholder"),
|
||||
keyRequired: t("etcd.keyRequired"),
|
||||
saved: t("etcd.saved"),
|
||||
deleted: t("etcd.deleted"),
|
||||
base64Readonly: t("etcd.base64Readonly"),
|
||||
}));
|
||||
|
||||
function focusSearch(): boolean {
|
||||
searchInputRef.value?.focus();
|
||||
return true;
|
||||
return browserRef.value?.focusSearch() ?? false;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.connectionId,
|
||||
() => void loadKeys(true),
|
||||
);
|
||||
onMounted(() => void loadKeys(true));
|
||||
defineExpose({ focusSearch });
|
||||
function refresh(): boolean {
|
||||
return browserRef.value?.refresh() ?? false;
|
||||
}
|
||||
|
||||
defineExpose({ focusSearch, refresh });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col bg-background">
|
||||
<div class="flex shrink-0 items-center gap-2 border-b px-3 py-2">
|
||||
<div class="relative min-w-0 flex-1">
|
||||
<Search class="pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input ref="searchInputRef" v-model="prefix" class="h-8 pl-8" :placeholder="t('etcd.prefixPlaceholder')" @keyup.enter="loadKeys(true)" />
|
||||
</div>
|
||||
<Button size="sm" variant="outline" class="h-8 gap-1.5" :disabled="loading" @click="loadKeys(true)">
|
||||
<Loader2 v-if="loading" class="h-3.5 w-3.5 animate-spin" />
|
||||
<RefreshCw v-else class="h-3.5 w-3.5" />
|
||||
{{ t("grid.refresh") }}
|
||||
</Button>
|
||||
<Button size="sm" class="h-8 gap-1.5" @click="openCreateDialog">
|
||||
<Plus class="h-3.5 w-3.5" />
|
||||
{{ t("etcd.newKey") }}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="grid min-h-0 flex-1 grid-cols-[minmax(260px,38%)_1fr]">
|
||||
<div class="min-h-0 border-r">
|
||||
<div v-if="loading" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ t("etcd.loadingKeys") }}
|
||||
</div>
|
||||
<div v-else-if="visibleRows.length === 0" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
{{ t("etcd.empty") }}
|
||||
</div>
|
||||
<div v-else class="h-full overflow-auto py-1 text-sm">
|
||||
<button
|
||||
v-for="row in visibleRows"
|
||||
:key="row.node.id"
|
||||
type="button"
|
||||
class="flex h-8 w-full items-center gap-1.5 px-2 text-left hover:bg-accent"
|
||||
:class="{ 'bg-accent/70': row.node.kind === 'leaf' && row.node.key === selectedKey }"
|
||||
:style="{ paddingLeft: `${8 + row.depth * 18}px` }"
|
||||
@click="onRowClick(row.node)"
|
||||
>
|
||||
<template v-if="row.node.kind === 'group'">
|
||||
<ChevronDown v-if="expandedGroupIds.has(row.node.id)" class="h-3.5 w-3.5 shrink-0" />
|
||||
<ChevronRight v-else class="h-3.5 w-3.5 shrink-0" />
|
||||
<FolderOpen v-if="expandedGroupIds.has(row.node.id)" class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
<FolderClosed v-else class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="w-3.5 shrink-0" />
|
||||
<KeyRound class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
</template>
|
||||
<span class="truncate">{{ row.node.label }}</span>
|
||||
</button>
|
||||
<div v-if="continuation" class="border-t p-2">
|
||||
<Button size="sm" variant="outline" class="h-8 w-full gap-1.5" :disabled="loadingMore" @click="loadKeys(false)">
|
||||
<Loader2 v-if="loadingMore" class="h-3.5 w-3.5 animate-spin" />
|
||||
{{ t("etcd.loadMore") }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 overflow-auto">
|
||||
<div v-if="!selectedKey" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
{{ t("etcd.selectKey") }}
|
||||
</div>
|
||||
<div v-else class="flex min-h-full flex-col">
|
||||
<div class="flex shrink-0 items-start justify-between gap-3 border-b px-4 py-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-medium">{{ selectedKey }}</div>
|
||||
<div class="mt-1 flex flex-wrap gap-1.5 text-xs text-muted-foreground">
|
||||
<Badge variant="secondary">rev {{ metadataLabel(selectedMetadata?.modRevision) }}</Badge>
|
||||
<Badge variant="outline">ver {{ metadataLabel(selectedMetadata?.version) }}</Badge>
|
||||
<Badge variant="outline">lease {{ metadataLabel(selectedMetadata?.lease) }}</Badge>
|
||||
<Badge variant="outline">{{ metadataLabel(selectedMetadata?.valueSize) }} B</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 gap-2">
|
||||
<Button size="sm" variant="outline" class="h-8" :disabled="selectedValueIsBase64" @click="openEditDialog">
|
||||
{{ t("etcd.edit") }}
|
||||
</Button>
|
||||
<Button size="sm" variant="destructive" class="h-8 gap-1.5" @click="showDeleteConfirm = true">
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ t("etcd.delete") }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="detailLoading" class="flex flex-1 items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ t("etcd.loadingValue") }}
|
||||
</div>
|
||||
<div v-else-if="detailError" class="p-4 text-sm text-destructive">{{ detailError }}</div>
|
||||
<div v-else-if="selectedValue && !selectedValue.found" class="p-4 text-sm text-muted-foreground">
|
||||
{{ t("etcd.notFound") }}
|
||||
</div>
|
||||
<pre v-else class="dbx-editor-font-family m-0 flex-1 overflow-auto whitespace-pre-wrap break-words p-4 text-sm">{{ selectedTextValue }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog v-model:open="showEditDialog">
|
||||
<DialogContent class="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ editKey ? t("etcd.editKey") : t("etcd.newKey") }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div class="grid gap-3 py-2">
|
||||
<Input v-model="editKey" :placeholder="t('etcd.keyPlaceholder')" />
|
||||
<textarea v-model="editValue" class="min-h-52 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" spellcheck="false" />
|
||||
<div v-if="editError" class="text-sm text-destructive">{{ editError }}</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="showEditDialog = false">{{ t("common.cancel") }}</Button>
|
||||
<Button :disabled="saving || (!!editError && selectedValueIsBase64)" @click="saveKey">
|
||||
<Loader2 v-if="saving" class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ t("common.save") }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<DangerConfirmDialog v-model:open="showDeleteConfirm" :title="t('etcd.deleteTitle')" :details="selectedKey || ''" :confirm-label="t('etcd.delete')" @confirm="deleteSelectedKey" />
|
||||
</div>
|
||||
<KvKeyBrowser ref="browserRef" :connection-id="props.connectionId" :api="etcdApi" :labels="labels" />
|
||||
</template>
|
||||
|
||||
@@ -65,7 +65,11 @@ const exportCancelled = ref(false);
|
||||
const pendingPrefillTable = ref("");
|
||||
const pendingPrefillTables = ref<string[]>([]);
|
||||
|
||||
<<<<<<< HEAD
|
||||
const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "etcd", "zookeeper", "mq", "nacos"].includes(c.db_type)));
|
||||
=======
|
||||
const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "mq", "nacos"].includes(c.db_type)));
|
||||
>>>>>>> origin/main
|
||||
|
||||
const canExport = computed(() => connectionId.value && database.value && schema.value && !loadingTables.value && !tableError.value && (tables.value.length === 0 || selectedTables.value.length > 0) && (includeStructure.value || includeData.value || includeObjects.value) && !isExporting.value);
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ const assetIcons: Record<string, string> = {
|
||||
nacos: "nacos.png",
|
||||
iris: "iris.png",
|
||||
influxdb: "influxdb",
|
||||
zookeeper: "zookeeper",
|
||||
};
|
||||
|
||||
const letterIcons: Record<string, { letter: string; color: string }> = {};
|
||||
|
||||
@@ -0,0 +1,536 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ChevronDown, ChevronRight, FolderClosed, FolderOpen, KeyRound, Loader2, Plus, RefreshCw, Search, Trash2 } from "@lucide/vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";
|
||||
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
|
||||
import type { KvCreateMode, KvGetResponse, KvKeySummary, KvPutOptions, KvPutResponse, KvValue } from "@/lib/api";
|
||||
import { buildKvKeyTree, flattenVisibleKvKeyTree, preserveKvExpandedGroupIds, type KvKeyTreeNode } from "@/lib/kvKeyTree";
|
||||
import { refreshedKvSelectionKey } from "@/lib/kvRefreshSelection";
|
||||
import { formatZooKeeperMetadataRows, formatZooKeeperSummaryBadges, prettyPrintJsonText } from "@/lib/kvValueDisplay";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
|
||||
interface KvKeyBrowserLabels {
|
||||
prefixPlaceholder: string;
|
||||
newKey: string;
|
||||
loadingKeys: string;
|
||||
empty: string;
|
||||
loadMore: string;
|
||||
selectKey: string;
|
||||
loadingValue: string;
|
||||
notFound: string;
|
||||
edit: string;
|
||||
editKey: string;
|
||||
delete: string;
|
||||
deleteTitle: string;
|
||||
keyPlaceholder: string;
|
||||
keyRequired: string;
|
||||
saved: string;
|
||||
deleted: string;
|
||||
base64Readonly: string;
|
||||
createMode?: string;
|
||||
add?: string;
|
||||
value?: string;
|
||||
metadata?: string;
|
||||
prettyJson?: string;
|
||||
invalidJson?: string;
|
||||
summaryRevision?: string;
|
||||
summaryVersion?: string;
|
||||
summaryLease?: string;
|
||||
summarySize?: string;
|
||||
}
|
||||
|
||||
interface KvCreateModeOption {
|
||||
value: KvCreateMode;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface KvKeyBrowserApi {
|
||||
listPrefix: (connectionId: string, prefix: string, limit: number, continuation?: string | null) => Promise<{ keys: KvKeySummary[]; continuation?: string | null }>;
|
||||
get: (connectionId: string, key: string) => Promise<KvGetResponse>;
|
||||
put: (connectionId: string, key: string, value: KvValue, options?: KvPutOptions | null) => Promise<KvPutResponse>;
|
||||
deleteKey: (connectionId: string, key: string) => Promise<{ deleted: number }>;
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
connectionId: string;
|
||||
labels: KvKeyBrowserLabels;
|
||||
api: KvKeyBrowserApi;
|
||||
supportsCreateModes?: boolean;
|
||||
createModeOptions?: KvCreateModeOption[];
|
||||
enableNodeActions?: boolean;
|
||||
metadataStyle?: "default" | "zookeeper";
|
||||
}>(),
|
||||
{
|
||||
supportsCreateModes: false,
|
||||
createModeOptions: () => [],
|
||||
enableNodeActions: false,
|
||||
metadataStyle: "default",
|
||||
},
|
||||
);
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const searchInputRef = ref<HTMLInputElement>();
|
||||
const prefix = ref("");
|
||||
const keys = ref<KvKeySummary[]>([]);
|
||||
const continuation = ref<string | null>(null);
|
||||
const loading = ref(false);
|
||||
const loadingMore = ref(false);
|
||||
const expandedGroupIds = ref<Set<string>>(new Set());
|
||||
const selectedKey = ref<string | null>(null);
|
||||
const selectedValue = ref<KvGetResponse | null>(null);
|
||||
const detailLoading = ref(false);
|
||||
const detailError = ref("");
|
||||
const showEditDialog = ref(false);
|
||||
const isCreating = ref(false);
|
||||
const editKey = ref("");
|
||||
const editValue = ref("");
|
||||
const editError = ref("");
|
||||
const saving = ref(false);
|
||||
const showDeleteConfirm = ref(false);
|
||||
const deleting = ref(false);
|
||||
const selectedCreateMode = ref<KvCreateMode>("persistent");
|
||||
const selectedPrettyValue = ref<string | null>(null);
|
||||
const pageSize = 200;
|
||||
type LoadKeysOptions = {
|
||||
preserveSelection?: boolean;
|
||||
};
|
||||
|
||||
const tree = computed(() => buildKvKeyTree(keys.value));
|
||||
const visibleRows = computed(() => flattenVisibleKvKeyTree(tree.value, expandedGroupIds.value));
|
||||
const selectedMetadata = computed(() => selectedValue.value?.metadata ?? keys.value.find((key) => key.key === selectedKey.value));
|
||||
const selectedTextValue = computed(() => {
|
||||
const value = selectedValue.value?.value;
|
||||
if (!value) return "";
|
||||
return value.encoding === "utf8" ? value.data : value.data;
|
||||
});
|
||||
const displayedSelectedTextValue = computed(() => selectedPrettyValue.value ?? selectedTextValue.value);
|
||||
const selectedValueIsBase64 = computed(() => selectedValue.value?.value?.encoding === "base64");
|
||||
const showCreateModeSelect = computed(() => props.supportsCreateModes && isCreating.value && props.createModeOptions.length > 0);
|
||||
const zookeeperSummaryBadges = computed(() =>
|
||||
formatZooKeeperSummaryBadges(selectedMetadata.value, {
|
||||
revision: props.labels.summaryRevision,
|
||||
version: props.labels.summaryVersion,
|
||||
lease: props.labels.summaryLease,
|
||||
size: props.labels.summarySize,
|
||||
}),
|
||||
);
|
||||
const zookeeperMetadataRows = computed(() => formatZooKeeperMetadataRows(selectedMetadata.value));
|
||||
const selectedValueCanPrettyJson = computed(() => selectedValue.value?.value?.encoding === "utf8" && prettyPrintJsonText(selectedTextValue.value).ok);
|
||||
const editValueCanPrettyJson = computed(() => prettyPrintJsonText(editValue.value).ok);
|
||||
|
||||
function preserveExpandedGroups(expandAll = false) {
|
||||
expandedGroupIds.value = preserveKvExpandedGroupIds(tree.value, expandedGroupIds.value, expandAll);
|
||||
}
|
||||
|
||||
async function loadKeys(reset = true, options: LoadKeysOptions = {}) {
|
||||
const keyToRestore = options.preserveSelection ? selectedKey.value : null;
|
||||
if (reset) {
|
||||
loading.value = true;
|
||||
continuation.value = null;
|
||||
keys.value = [];
|
||||
if (!options.preserveSelection) {
|
||||
selectedKey.value = null;
|
||||
selectedValue.value = null;
|
||||
}
|
||||
} else {
|
||||
loadingMore.value = true;
|
||||
}
|
||||
try {
|
||||
const result = await props.api.listPrefix(props.connectionId, prefix.value.trim(), pageSize, reset ? null : continuation.value);
|
||||
const existing = new Set(keys.value.map((key) => key.key));
|
||||
const merged = reset ? result.keys : [...keys.value, ...result.keys.filter((key) => !existing.has(key.key))];
|
||||
keys.value = merged;
|
||||
continuation.value = result.continuation || null;
|
||||
preserveExpandedGroups(!!prefix.value.trim());
|
||||
if (reset && options.preserveSelection) {
|
||||
const restoredKey = refreshedKvSelectionKey(keyToRestore, merged);
|
||||
if (restoredKey) {
|
||||
await loadSelectedKey(restoredKey);
|
||||
} else {
|
||||
selectedKey.value = null;
|
||||
selectedValue.value = null;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
loadingMore.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSelectedKey(key: string) {
|
||||
selectedKey.value = key;
|
||||
selectedPrettyValue.value = null;
|
||||
detailLoading.value = true;
|
||||
detailError.value = "";
|
||||
try {
|
||||
selectedValue.value = await props.api.get(props.connectionId, key);
|
||||
} catch (error) {
|
||||
detailError.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleGroup(node: KvKeyTreeNode) {
|
||||
if (node.kind !== "group") return;
|
||||
const next = new Set(expandedGroupIds.value);
|
||||
if (next.has(node.id)) next.delete(node.id);
|
||||
else next.add(node.id);
|
||||
expandedGroupIds.value = next;
|
||||
}
|
||||
|
||||
function nodePath(node: KvKeyTreeNode): string {
|
||||
if (node.kind === "leaf") return node.key;
|
||||
return `/${node.pathSegments.join("/")}`;
|
||||
}
|
||||
|
||||
function onRowClick(node: KvKeyTreeNode) {
|
||||
if (node.kind === "group") {
|
||||
toggleGroup(node);
|
||||
if (props.enableNodeActions) void loadSelectedKey(nodePath(node));
|
||||
} else {
|
||||
void loadSelectedKey(node.key);
|
||||
}
|
||||
}
|
||||
|
||||
function onRowDoubleClick(node: KvKeyTreeNode) {
|
||||
if (node.kind === "leaf") {
|
||||
void loadSelectedKey(node.key).then(() => openEditDialog());
|
||||
}
|
||||
}
|
||||
|
||||
function createKeyPrefix(parentPath?: string): string {
|
||||
const path = parentPath ?? prefix.value.trim();
|
||||
if (!path) return "";
|
||||
if (path === "/") return "/";
|
||||
return path.endsWith("/") ? path : `${path}/`;
|
||||
}
|
||||
|
||||
function openCreateDialog(parentPath?: string) {
|
||||
isCreating.value = true;
|
||||
editKey.value = createKeyPrefix(parentPath);
|
||||
editValue.value = "";
|
||||
editError.value = "";
|
||||
selectedCreateMode.value = props.createModeOptions[0]?.value || "persistent";
|
||||
showEditDialog.value = true;
|
||||
}
|
||||
|
||||
function openEditDialog() {
|
||||
if (!selectedKey.value) return;
|
||||
isCreating.value = false;
|
||||
editKey.value = selectedKey.value;
|
||||
editValue.value = selectedTextValue.value;
|
||||
editError.value = selectedValueIsBase64.value ? props.labels.base64Readonly : "";
|
||||
showEditDialog.value = true;
|
||||
}
|
||||
|
||||
function putOptions(): KvPutOptions | undefined {
|
||||
if (!props.supportsCreateModes) return undefined;
|
||||
if (isCreating.value) {
|
||||
return { writeMode: "create", createMode: selectedCreateMode.value };
|
||||
}
|
||||
return { writeMode: "update" };
|
||||
}
|
||||
|
||||
async function saveKey() {
|
||||
const key = editKey.value.trim();
|
||||
if (!key) {
|
||||
editError.value = props.labels.keyRequired;
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
editError.value = "";
|
||||
try {
|
||||
const value: KvValue = { encoding: "utf8", data: editValue.value };
|
||||
const response = await props.api.put(props.connectionId, key, value, putOptions());
|
||||
const keyToSelect = response.createdKey || response.key || key;
|
||||
showEditDialog.value = false;
|
||||
await loadKeys(true);
|
||||
await loadSelectedKey(keyToSelect);
|
||||
toast(props.labels.saved, 2500);
|
||||
} catch (error) {
|
||||
editError.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSelectedKey() {
|
||||
if (!selectedKey.value) return;
|
||||
deleting.value = true;
|
||||
try {
|
||||
await props.api.deleteKey(props.connectionId, selectedKey.value);
|
||||
showDeleteConfirm.value = false;
|
||||
selectedKey.value = null;
|
||||
selectedValue.value = null;
|
||||
await loadKeys(true);
|
||||
toast(props.labels.deleted, 2500);
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectNodeForAction(node: KvKeyTreeNode) {
|
||||
const key = nodePath(node);
|
||||
if (selectedKey.value !== key) void loadSelectedKey(key);
|
||||
else selectedKey.value = key;
|
||||
}
|
||||
|
||||
function openDeleteForNode(node: KvKeyTreeNode) {
|
||||
selectNodeForAction(node);
|
||||
showDeleteConfirm.value = true;
|
||||
}
|
||||
|
||||
function nodeContextMenuItems(node: KvKeyTreeNode): ContextMenuItem[] {
|
||||
if (!props.enableNodeActions) return [];
|
||||
return [
|
||||
{
|
||||
label: props.labels.add || props.labels.newKey,
|
||||
icon: Plus,
|
||||
action: () => openCreateDialog(nodePath(node)),
|
||||
},
|
||||
{
|
||||
label: props.labels.delete,
|
||||
icon: Trash2,
|
||||
variant: "destructive",
|
||||
action: () => openDeleteForNode(node),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function onRowContextMenu(event: MouseEvent, node: KvKeyTreeNode, openContextMenu: (event: MouseEvent) => void) {
|
||||
if (!props.enableNodeActions) return;
|
||||
selectNodeForAction(node);
|
||||
openContextMenu(event);
|
||||
}
|
||||
|
||||
function rowIsSelected(node: KvKeyTreeNode): boolean {
|
||||
return nodePath(node) === selectedKey.value;
|
||||
}
|
||||
|
||||
function prettifySelectedJson() {
|
||||
const result = prettyPrintJsonText(selectedTextValue.value);
|
||||
if (result.ok && result.value != null) {
|
||||
selectedPrettyValue.value = result.value;
|
||||
} else {
|
||||
toast(props.labels.invalidJson || "Invalid JSON", 2500);
|
||||
}
|
||||
}
|
||||
|
||||
function prettifyEditJson() {
|
||||
const result = prettyPrintJsonText(editValue.value);
|
||||
if (result.ok && result.value != null) {
|
||||
editValue.value = result.value;
|
||||
editError.value = "";
|
||||
} else {
|
||||
editError.value = props.labels.invalidJson || "Invalid JSON";
|
||||
}
|
||||
}
|
||||
|
||||
function metadataLabel(value: number | null | undefined): string {
|
||||
return value == null ? "-" : String(value);
|
||||
}
|
||||
|
||||
function focusSearch(): boolean {
|
||||
searchInputRef.value?.focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
function refresh(): boolean {
|
||||
void loadKeys(true, { preserveSelection: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.connectionId,
|
||||
() => void loadKeys(true),
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.createModeOptions,
|
||||
(options) => {
|
||||
if (!options.some((option) => option.value === selectedCreateMode.value)) {
|
||||
selectedCreateMode.value = options[0]?.value || "persistent";
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onMounted(() => void loadKeys(true));
|
||||
defineExpose({ focusSearch, refresh });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col bg-background">
|
||||
<div class="flex shrink-0 items-center gap-2 border-b px-3 py-2">
|
||||
<div class="relative min-w-0 flex-1">
|
||||
<Search class="pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input ref="searchInputRef" v-model="prefix" class="h-8 pl-8" :placeholder="labels.prefixPlaceholder" @keyup.enter="loadKeys(true)" />
|
||||
</div>
|
||||
<Button size="sm" variant="outline" class="h-8 gap-1.5" :disabled="loading" @click="loadKeys(true, { preserveSelection: true })">
|
||||
<Loader2 v-if="loading" class="h-3.5 w-3.5 animate-spin" />
|
||||
<RefreshCw v-else class="h-3.5 w-3.5" />
|
||||
{{ t("grid.refresh") }}
|
||||
</Button>
|
||||
<Button size="sm" class="h-8 gap-1.5" @click="openCreateDialog()">
|
||||
<Plus class="h-3.5 w-3.5" />
|
||||
{{ labels.newKey }}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="grid min-h-0 flex-1 grid-cols-[minmax(260px,38%)_1fr]">
|
||||
<div class="min-h-0 border-r">
|
||||
<div v-if="loading" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ labels.loadingKeys }}
|
||||
</div>
|
||||
<div v-else-if="visibleRows.length === 0" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
{{ labels.empty }}
|
||||
</div>
|
||||
<div v-else class="h-full overflow-auto py-1 text-sm">
|
||||
<CustomContextMenu v-for="row in visibleRows" :key="row.node.id" :items="nodeContextMenuItems(row.node)" v-slot="{ onContextMenu }">
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-8 w-full items-center gap-1.5 px-2 text-left hover:bg-accent"
|
||||
:class="{ 'bg-accent/70': rowIsSelected(row.node) }"
|
||||
:style="{ paddingLeft: `${8 + row.depth * 18}px` }"
|
||||
@click="onRowClick(row.node)"
|
||||
@dblclick.stop.prevent="onRowDoubleClick(row.node)"
|
||||
@contextmenu="(event) => onRowContextMenu(event, row.node, onContextMenu)"
|
||||
>
|
||||
<template v-if="row.node.kind === 'group'">
|
||||
<ChevronDown v-if="expandedGroupIds.has(row.node.id)" class="h-3.5 w-3.5 shrink-0" />
|
||||
<ChevronRight v-else class="h-3.5 w-3.5 shrink-0" />
|
||||
<FolderOpen v-if="expandedGroupIds.has(row.node.id)" class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
<FolderClosed v-else class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="w-3.5 shrink-0" />
|
||||
<KeyRound class="h-4 w-4 shrink-0 text-sky-500" />
|
||||
</template>
|
||||
<span class="truncate">{{ row.node.label }}</span>
|
||||
</button>
|
||||
</CustomContextMenu>
|
||||
<div v-if="continuation" class="border-t p-2">
|
||||
<Button size="sm" variant="outline" class="h-8 w-full gap-1.5" :disabled="loadingMore" @click="loadKeys(false)">
|
||||
<Loader2 v-if="loadingMore" class="h-3.5 w-3.5 animate-spin" />
|
||||
{{ labels.loadMore }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 overflow-auto">
|
||||
<div v-if="!selectedKey" class="flex h-full items-center justify-center text-sm text-muted-foreground">
|
||||
{{ labels.selectKey }}
|
||||
</div>
|
||||
<div v-else class="flex min-h-full flex-col">
|
||||
<div class="flex shrink-0 items-start justify-between gap-3 border-b px-4 py-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-medium" :class="{ 'text-blue-600 dark:text-blue-400': metadataStyle === 'zookeeper' }">{{ selectedKey }}</div>
|
||||
<div class="mt-1 flex flex-wrap gap-1.5 text-xs text-muted-foreground">
|
||||
<template v-if="metadataStyle === 'zookeeper'">
|
||||
<Badge v-for="badge in zookeeperSummaryBadges" :key="badge.label" variant="outline" class="rounded-full">
|
||||
{{ `${badge.label} ${badge.value}` }}
|
||||
</Badge>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Badge variant="secondary">rev {{ metadataLabel(selectedMetadata?.modRevision) }}</Badge>
|
||||
<Badge variant="outline">ver {{ metadataLabel(selectedMetadata?.version) }}</Badge>
|
||||
<Badge variant="outline">lease {{ metadataLabel(selectedMetadata?.lease) }}</Badge>
|
||||
<Badge variant="outline">{{ metadataLabel(selectedMetadata?.valueSize) }} B</Badge>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 gap-2">
|
||||
<Button size="sm" variant="outline" class="h-8" :disabled="selectedValueIsBase64" @click="openEditDialog">
|
||||
{{ labels.edit }}
|
||||
</Button>
|
||||
<Button size="sm" variant="destructive" class="h-8 gap-1.5" @click="showDeleteConfirm = true">
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ labels.delete }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="detailLoading" class="flex flex-1 items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ labels.loadingValue }}
|
||||
</div>
|
||||
<div v-else-if="detailError" class="p-4 text-sm text-destructive">{{ detailError }}</div>
|
||||
<div v-else-if="selectedValue && !selectedValue.found" class="p-4 text-sm text-muted-foreground">
|
||||
{{ labels.notFound }}
|
||||
</div>
|
||||
<div v-else class="flex min-h-0 flex-1 flex-col gap-4 p-4">
|
||||
<div class="min-h-0">
|
||||
<div v-if="metadataStyle === 'zookeeper'" class="mb-2 text-xs font-medium text-muted-foreground">{{ labels.value || "Value" }}</div>
|
||||
<pre class="dbx-editor-font-family m-0 max-h-[40vh] min-h-32 overflow-auto rounded-md border bg-muted/20 whitespace-pre-wrap break-words p-3 text-sm">{{ displayedSelectedTextValue }}</pre>
|
||||
<div v-if="selectedValueCanPrettyJson" class="mt-2 flex justify-end">
|
||||
<Button size="sm" variant="outline" class="h-8" @click="prettifySelectedJson">
|
||||
{{ labels.prettyJson || "Pretty" }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="metadataStyle === 'zookeeper'" class="grid gap-3 border-t pt-4">
|
||||
<div class="text-xs font-medium text-muted-foreground">{{ labels.metadata || "Metadata" }}</div>
|
||||
<div class="grid gap-x-10 gap-y-4 sm:grid-cols-2">
|
||||
<div v-for="row in zookeeperMetadataRows" :key="row.label" class="grid grid-cols-[minmax(96px,auto)_1fr] items-baseline gap-5 text-sm">
|
||||
<div class="text-foreground">{{ row.label }}</div>
|
||||
<div class="dbx-editor-font-family min-w-0 break-all text-blue-600 dark:text-blue-400">{{ row.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog v-model:open="showEditDialog">
|
||||
<DialogContent class="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ isCreating ? labels.newKey : labels.editKey }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div class="grid gap-3 py-2">
|
||||
<Input v-model="editKey" :placeholder="labels.keyPlaceholder" />
|
||||
<div v-if="showCreateModeSelect" class="grid grid-cols-4 items-center gap-3">
|
||||
<Label class="text-right text-xs">{{ labels.createMode || "Create Mode" }}</Label>
|
||||
<Select v-model="selectedCreateMode">
|
||||
<SelectTrigger class="col-span-3 h-9">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="option in createModeOptions" :key="option.value" :value="option.value">
|
||||
{{ option.label }}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<textarea v-model="editValue" class="min-h-52 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" spellcheck="false" />
|
||||
<div v-if="editValueCanPrettyJson" class="flex justify-end">
|
||||
<Button size="sm" variant="outline" class="h-8" @click="prettifyEditJson">
|
||||
{{ labels.prettyJson || "Pretty" }}
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="editError" class="text-sm text-destructive">{{ editError }}</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="showEditDialog = false">{{ t("common.cancel") }}</Button>
|
||||
<Button :disabled="saving || (!!editError && selectedValueIsBase64)" @click="saveKey">
|
||||
<Loader2 v-if="saving" class="mr-2 h-4 w-4 animate-spin" />
|
||||
{{ t("common.save") }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<DangerConfirmDialog v-model:open="showDeleteConfirm" :title="labels.deleteTitle" :details="selectedKey || ''" :confirm-label="labels.delete" @confirm="deleteSelectedKey" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -235,7 +235,7 @@ const openTabMenuItems = computed(() =>
|
||||
function tabMenuIcon(tab: QueryTab) {
|
||||
if (tab.mode === "data" || tab.mode === "mongo" || tab.mode === "redis") return Table2;
|
||||
if (tab.mode === "vector") return TableProperties;
|
||||
if (tab.mode === "etcd") return KeyRound;
|
||||
if (tab.mode === "etcd" || tab.mode === "zookeeper") return KeyRound;
|
||||
if (tab.mode === "nacos") return Network;
|
||||
if (tab.mode === "objects") return TableProperties;
|
||||
if (tab.mode === "structure") return PencilRuler;
|
||||
@@ -329,7 +329,7 @@ function activateTab(tabId: string) {
|
||||
<span class="shrink-0" :class="tabIconClass(tab)">
|
||||
<Table2 v-if="tab.mode === 'data' || tab.mode === 'mongo' || tab.mode === 'redis'" class="h-3.5 w-3.5" />
|
||||
<TableProperties v-else-if="tab.mode === 'vector'" class="h-3.5 w-3.5" />
|
||||
<KeyRound v-else-if="tab.mode === 'etcd'" class="h-3.5 w-3.5" />
|
||||
<KeyRound v-else-if="tab.mode === 'etcd' || tab.mode === 'zookeeper'" class="h-3.5 w-3.5" />
|
||||
<Network v-else-if="tab.mode === 'nacos'" class="h-3.5 w-3.5" />
|
||||
<TableProperties v-else-if="tab.mode === 'objects'" class="h-3.5 w-3.5" />
|
||||
<PencilRuler v-else-if="tab.mode === 'structure'" class="h-3.5 w-3.5" />
|
||||
|
||||
@@ -37,6 +37,7 @@ const DataGrid = defineAsyncComponent(loadDataGridComponent);
|
||||
const RedisKeyBrowser = defineAsyncComponent(() => import("@/components/redis/RedisKeyBrowser.vue"));
|
||||
const RedisDashboard = defineAsyncComponent(() => import("@/components/redis/RedisDashboard.vue"));
|
||||
const EtcdKeyBrowser = defineAsyncComponent(() => import("@/components/etcd/EtcdKeyBrowser.vue"));
|
||||
const ZooKeeperKeyBrowser = defineAsyncComponent(() => import("@/components/zookeeper/ZooKeeperKeyBrowser.vue"));
|
||||
const DocumentBrowser = defineAsyncComponent(() => import("@/components/document/DocumentBrowser.vue"));
|
||||
const VectorBrowser = defineAsyncComponent(() => import("@/components/vector/VectorBrowser.vue"));
|
||||
const MqAdminConsole = defineAsyncComponent(() => import("@/components/mq/MqAdminConsole.vue"));
|
||||
@@ -94,6 +95,7 @@ type DataGridHandle = {
|
||||
|
||||
type SearchableBrowserHandle = {
|
||||
focusSearch: () => boolean;
|
||||
refresh?: () => boolean;
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -145,6 +147,7 @@ onMounted(() => {
|
||||
} else {
|
||||
setTimeout(preload, 300);
|
||||
}
|
||||
window.addEventListener("dbx-refresh-active-kv-browser", onRefreshActiveKvBrowser);
|
||||
});
|
||||
|
||||
watch(
|
||||
@@ -167,6 +170,7 @@ const columnVisibilitySearch = ref("");
|
||||
const columnVisibilityOptions = computed(() => dataGridRef.value?.filteredColumnVisibilityOptions(columnVisibilitySearch.value) ?? []);
|
||||
const redisKeyBrowserRef = ref<SearchableBrowserHandle>();
|
||||
const etcdKeyBrowserRef = ref<SearchableBrowserHandle>();
|
||||
const zookeeperKeyBrowserRef = ref<SearchableBrowserHandle>();
|
||||
const objectBrowserRef = ref<SearchableBrowserHandle>();
|
||||
const activeTableMeta = computed(() => props.activeTab.tableMeta);
|
||||
const activeDataTabTableMeta = computed(() => tableMetaForDataTab(props.activeTab));
|
||||
@@ -298,7 +302,10 @@ const queryRunningElapsedSeconds = computed(() => (queryRunningElapsed.value / 1
|
||||
|
||||
watch(() => [props.activeTab.id, props.activeTab.isExecuting, props.activeTab.queryExecutionStartedAt] as const, startQueryRunningElapsedTimer, { immediate: true });
|
||||
|
||||
onUnmounted(stopQueryRunningElapsedTimer);
|
||||
onUnmounted(() => {
|
||||
stopQueryRunningElapsedTimer();
|
||||
window.removeEventListener("dbx-refresh-active-kv-browser", onRefreshActiveKvBrowser);
|
||||
});
|
||||
|
||||
watch(
|
||||
hasQueryOutput,
|
||||
@@ -474,17 +481,26 @@ function onHandleCloseColumnPanel() {
|
||||
function focusSearch(): boolean {
|
||||
if (props.activeTab.mode === "redis") return redisKeyBrowserRef.value?.focusSearch() ?? false;
|
||||
if (props.activeTab.mode === "etcd") return etcdKeyBrowserRef.value?.focusSearch() ?? false;
|
||||
if (props.activeTab.mode === "zookeeper") return zookeeperKeyBrowserRef.value?.focusSearch() ?? false;
|
||||
if (props.activeTab.mode === "objects") return objectBrowserRef.value?.focusSearch() ?? false;
|
||||
if (props.activeTab.mode === "query") return queryEditorRef.value?.openSearch() ?? false;
|
||||
return dataGridRef.value?.focusSearch() ?? false;
|
||||
}
|
||||
|
||||
function refreshData(): boolean {
|
||||
if (props.activeTab.mode === "etcd") return etcdKeyBrowserRef.value?.refresh?.() ?? false;
|
||||
if (props.activeTab.mode === "zookeeper") return zookeeperKeyBrowserRef.value?.refresh?.() ?? false;
|
||||
if (!dataGridRef.value) return false;
|
||||
void dataGridRef.value.onToolbarRefresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
function onRefreshActiveKvBrowser(event: Event) {
|
||||
const detail = (event as CustomEvent<{ mode?: string; connectionId?: string }>).detail;
|
||||
if (!detail || props.activeTab.mode !== detail.mode || props.activeTab.connectionId !== detail.connectionId) return;
|
||||
void nextTick(() => refreshData());
|
||||
}
|
||||
|
||||
async function exportResultArchive() {
|
||||
if (resultArchiveExporting.value) return;
|
||||
resultArchiveExporting.value = true;
|
||||
@@ -1034,6 +1050,13 @@ defineExpose({ focusSearch, refreshData, handleModRTarget, requestQueryEditorExe
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- ZooKeeper mode: znode browser -->
|
||||
<template v-else-if="activeTab.mode === 'zookeeper'">
|
||||
<div class="flex-1 min-h-0">
|
||||
<ZooKeeperKeyBrowser ref="zookeeperKeyBrowserRef" :key="activeTab.id" :connection-id="activeTab.connectionId" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Document mode: MongoDB collections and Elasticsearch indices -->
|
||||
<template v-else-if="activeTab.mode === 'mongo'">
|
||||
<div class="flex-1 min-h-0">
|
||||
|
||||
@@ -61,7 +61,11 @@ const activeConnectionValue = computed(() => props.activeConnection?.id || "");
|
||||
const activeSchemaValue = computed(() => props.activeTab.schema || "");
|
||||
const supportsExplain = computed(() => {
|
||||
const dbType = props.activeConnection?.db_type;
|
||||
<<<<<<< HEAD
|
||||
return dbType !== "redis" && dbType !== "mongodb" && dbType !== "elasticsearch" && dbType !== "qdrant" && dbType !== "milvus" && dbType !== "etcd" && dbType !== "zookeeper" && dbType !== "mq" && dbType !== "nacos";
|
||||
=======
|
||||
return dbType !== "redis" && dbType !== "mongodb" && dbType !== "elasticsearch" && dbType !== "qdrant" && dbType !== "milvus" && dbType !== "weaviate" && dbType !== "etcd" && dbType !== "mq" && dbType !== "nacos";
|
||||
>>>>>>> origin/main
|
||||
});
|
||||
const isSingleDb = computed(() => isSingleDatabase(props.activeConnection?.db_type));
|
||||
const hasDefaultDatabaseOption = computed(() => activeDatabaseOptions.value.includes(""));
|
||||
@@ -251,7 +255,11 @@ function connectionById(connectionId: string): ConnectionConfig | undefined {
|
||||
</template>
|
||||
</SearchableSelect>
|
||||
</div>
|
||||
<<<<<<< HEAD
|
||||
<div v-if="activeConnection?.db_type !== 'elasticsearch' && activeConnection?.db_type !== 'qdrant' && activeConnection?.db_type !== 'milvus' && activeConnection?.db_type !== 'zookeeper' && !isSingleDb" class="flex items-center gap-1">
|
||||
=======
|
||||
<div v-if="activeConnection?.db_type !== 'elasticsearch' && activeConnection?.db_type !== 'qdrant' && activeConnection?.db_type !== 'milvus' && activeConnection?.db_type !== 'weaviate' && !isSingleDb" class="flex items-center gap-1">
|
||||
>>>>>>> origin/main
|
||||
<Database class="h-3.5 w-3.5 shrink-0" />
|
||||
<SearchableSelect
|
||||
:model-value="activeDatabaseValue"
|
||||
|
||||
@@ -378,7 +378,7 @@ function resolveLoadedLocateTarget(target: ActiveTabSidebarTarget, candidate: Qu
|
||||
}
|
||||
|
||||
async function ensureTreeLoadedForTarget(target: ActiveTabSidebarTarget, opts?: { force?: boolean }) {
|
||||
if (target.type === "saved-sql-file" || target.type === "etcd-root") return;
|
||||
if (target.type === "saved-sql-file" || target.type === "etcd-root" || target.type === "zookeeper-root") return;
|
||||
const connId = target.connectionId;
|
||||
if (!connId) return;
|
||||
|
||||
|
||||
@@ -254,6 +254,8 @@ function getIconInfo(node: TreeNode): { icon: any; colorClass: string } | null {
|
||||
return { icon: FolderOpen, colorClass: "text-sky-500" };
|
||||
case "etcd-root":
|
||||
return { icon: Database, colorClass: "text-sky-500" };
|
||||
case "zookeeper-root":
|
||||
return { icon: Database, colorClass: "text-blue-500" };
|
||||
case "mongo-db":
|
||||
return { icon: Database, colorClass: "text-yellow-500" };
|
||||
case "mongo-collection":
|
||||
@@ -471,6 +473,8 @@ async function toggle() {
|
||||
await connectionStore.loadRedisDatabases(node.connectionId);
|
||||
} else if (config?.db_type === "etcd") {
|
||||
await connectionStore.loadEtcdRoot(node.connectionId);
|
||||
} else if (config?.db_type === "zookeeper") {
|
||||
await connectionStore.loadZooKeeperRoot(node.connectionId);
|
||||
} else if (config?.db_type === "mongodb") {
|
||||
await connectionStore.loadMongoDatabases(node.connectionId);
|
||||
} else if (config?.db_type === "elasticsearch") {
|
||||
@@ -494,6 +498,11 @@ async function toggle() {
|
||||
} else if (node.type === "etcd-root" && node.connectionId) {
|
||||
const tabTitle = `${connectionStore.getConfig(node.connectionId)?.name || "etcd"}:keys`;
|
||||
queryStore.createTab(node.connectionId, "", tabTitle, "etcd");
|
||||
refreshActiveKvBrowserAfterOpen("etcd", node.connectionId);
|
||||
} else if (node.type === "zookeeper-root" && node.connectionId) {
|
||||
const tabTitle = `${connectionStore.getConfig(node.connectionId)?.name || "ZooKeeper"}:keys`;
|
||||
queryStore.createTab(node.connectionId, "", tabTitle, "zookeeper");
|
||||
refreshActiveKvBrowserAfterOpen("zookeeper", node.connectionId);
|
||||
} else if (node.type === "user-admin" && node.connectionId) {
|
||||
queryStore.openUserAdmin(node.connectionId);
|
||||
} else if (node.type === "mongo-db" && node.connectionId && node.database) {
|
||||
@@ -572,6 +581,12 @@ function runRowClickAction() {
|
||||
}
|
||||
}
|
||||
|
||||
function refreshActiveKvBrowserAfterOpen(mode: "etcd" | "zookeeper", connectionId: string) {
|
||||
void nextTick(() => {
|
||||
window.dispatchEvent(new CustomEvent("dbx-refresh-active-kv-browser", { detail: { mode, connectionId } }));
|
||||
});
|
||||
}
|
||||
|
||||
async function loadMoreObjectGroupChildren() {
|
||||
try {
|
||||
await connectionStore.loadMoreObjectGroupChildren(props.node);
|
||||
@@ -3632,7 +3647,7 @@ function treeItemMenuItems(): ContextMenuItem[] {
|
||||
}
|
||||
|
||||
// 5. Redis DB / Mongo DB
|
||||
if (node.type === "etcd-root") {
|
||||
if (node.type === "etcd-root" || node.type === "zookeeper-root") {
|
||||
items.push({ label: t("contextMenu.openConnection"), action: toggle, icon: Database });
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,11 @@ const terminalStatus = ref<SqlFileStatus | "idle">("idle");
|
||||
const terminalError = ref("");
|
||||
const refreshedTarget = ref(false);
|
||||
|
||||
<<<<<<< HEAD
|
||||
const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "etcd", "zookeeper", "mq", "nacos"].includes(c.db_type)));
|
||||
=======
|
||||
const sqlConnections = computed(() => store.connections.filter((c) => !["redis", "mongodb", "elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "mq", "nacos"].includes(c.db_type)));
|
||||
>>>>>>> origin/main
|
||||
|
||||
const selectedConnection = computed(() => sqlConnections.value.find((c) => c.id === connectionId.value));
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import KvKeyBrowser from "@/components/kv/KvKeyBrowser.vue";
|
||||
import * as api from "@/lib/api";
|
||||
import type { KvCreateMode } from "@/lib/api";
|
||||
|
||||
const props = defineProps<{ connectionId: string }>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const browserRef = ref<InstanceType<typeof KvKeyBrowser> | null>(null);
|
||||
|
||||
const zookeeperApi = {
|
||||
listPrefix: api.zookeeperListPrefix,
|
||||
get: api.zookeeperGet,
|
||||
put: api.zookeeperPut,
|
||||
deleteKey: api.zookeeperDelete,
|
||||
};
|
||||
|
||||
const createModeOptions = computed<{ value: KvCreateMode; label: string }[]>(() => [
|
||||
{ value: "persistent", label: t("zookeeper.createModePersistent") },
|
||||
{ value: "ephemeral", label: t("zookeeper.createModeEphemeral") },
|
||||
{ value: "persistent_sequential", label: t("zookeeper.createModePersistentSequential") },
|
||||
{ value: "ephemeral_sequential", label: t("zookeeper.createModeEphemeralSequential") },
|
||||
]);
|
||||
|
||||
const labels = computed(() => ({
|
||||
prefixPlaceholder: t("zookeeper.prefixPlaceholder"),
|
||||
newKey: t("zookeeper.newKey"),
|
||||
loadingKeys: t("zookeeper.loadingKeys"),
|
||||
empty: t("zookeeper.empty"),
|
||||
loadMore: t("zookeeper.loadMore"),
|
||||
selectKey: t("zookeeper.selectKey"),
|
||||
loadingValue: t("zookeeper.loadingValue"),
|
||||
notFound: t("zookeeper.notFound"),
|
||||
edit: t("zookeeper.edit"),
|
||||
editKey: t("zookeeper.editKey"),
|
||||
delete: t("zookeeper.delete"),
|
||||
deleteTitle: t("zookeeper.deleteTitle"),
|
||||
keyPlaceholder: t("zookeeper.keyPlaceholder"),
|
||||
keyRequired: t("zookeeper.keyRequired"),
|
||||
saved: t("zookeeper.saved"),
|
||||
deleted: t("zookeeper.deleted"),
|
||||
base64Readonly: t("zookeeper.base64Readonly"),
|
||||
createMode: t("zookeeper.createMode"),
|
||||
add: t("zookeeper.add"),
|
||||
value: t("zookeeper.value"),
|
||||
metadata: t("zookeeper.metadata"),
|
||||
prettyJson: t("zookeeper.prettyJson"),
|
||||
invalidJson: t("zookeeper.invalidJson"),
|
||||
summaryRevision: t("zookeeper.summaryRevision"),
|
||||
summaryVersion: t("zookeeper.summaryVersion"),
|
||||
summaryLease: t("zookeeper.summaryLease"),
|
||||
summarySize: t("zookeeper.summarySize"),
|
||||
}));
|
||||
|
||||
function focusSearch(): boolean {
|
||||
return browserRef.value?.focusSearch() ?? false;
|
||||
}
|
||||
|
||||
function refresh(): boolean {
|
||||
return browserRef.value?.refresh() ?? false;
|
||||
}
|
||||
|
||||
defineExpose({ focusSearch, refresh });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<KvKeyBrowser ref="browserRef" :connection-id="props.connectionId" :api="zookeeperApi" :labels="labels" supports-create-modes enable-node-actions metadata-style="zookeeper" :create-mode-options="createModeOptions" />
|
||||
</template>
|
||||
@@ -251,6 +251,12 @@ export default {
|
||||
etcdClientCertBrowse: "Choose client certificate",
|
||||
etcdClientKeyBrowse: "Choose client private key",
|
||||
etcdClientCertPairRequired: "Client certificate and private key must be provided together.",
|
||||
zookeeperConnectString: "Connect String",
|
||||
zookeeperConnectStringHint: "Comma or line separated host:port entries. Leave blank to use the host and port above.",
|
||||
zookeeperCreateModePersistent: "Persistent",
|
||||
zookeeperCreateModeEphemeral: "Ephemeral",
|
||||
zookeeperCreateModePersistentSequential: "Persistent Sequential",
|
||||
zookeeperCreateModeEphemeralSequential: "Ephemeral Sequential",
|
||||
nacosConsoleUrl: "Console URL",
|
||||
nacosConsoleUrlHint: "Use the Nacos console/admin API address. Nacos 3 Docker usually exposes the console on 8085; older deployments may share 8848 with the service port.",
|
||||
nacosConsoleUrlRequired: "Nacos Console URL is required",
|
||||
@@ -470,6 +476,7 @@ export default {
|
||||
tableData: "Table Data",
|
||||
redis: "Redis",
|
||||
etcd: "etcd",
|
||||
zookeeper: "ZooKeeper",
|
||||
mongo: "Mongo",
|
||||
vector: "Vector",
|
||||
objects: "Objects",
|
||||
@@ -1556,6 +1563,39 @@ export default {
|
||||
deleted: "Key deleted",
|
||||
base64Readonly: "Base64 values are read-only in this version.",
|
||||
},
|
||||
zookeeper: {
|
||||
prefixPlaceholder: "Path prefix, e.g. /app/",
|
||||
newKey: "New Znode",
|
||||
loadingKeys: "Loading znodes...",
|
||||
empty: "No znodes found",
|
||||
loadMore: "Load more",
|
||||
selectKey: "Select a znode to view its value",
|
||||
loadingValue: "Loading value...",
|
||||
notFound: "Znode not found",
|
||||
edit: "Edit",
|
||||
editKey: "Edit Znode",
|
||||
delete: "Delete",
|
||||
deleteTitle: "Delete ZooKeeper znode",
|
||||
keyPlaceholder: "/path/to/znode",
|
||||
keyRequired: "Znode path is required",
|
||||
saved: "Znode saved",
|
||||
deleted: "Znode deleted",
|
||||
base64Readonly: "Base64 values are read-only in this version.",
|
||||
createMode: "Create Mode",
|
||||
createModePersistent: "Persistent",
|
||||
createModeEphemeral: "Ephemeral",
|
||||
createModePersistentSequential: "Persistent Sequential",
|
||||
createModeEphemeralSequential: "Ephemeral Sequential",
|
||||
add: "Add",
|
||||
value: "Value",
|
||||
metadata: "Node Info",
|
||||
prettyJson: "Pretty",
|
||||
invalidJson: "Invalid JSON",
|
||||
summaryRevision: "rev",
|
||||
summaryVersion: "ver",
|
||||
summaryLease: "lease",
|
||||
summarySize: "size",
|
||||
},
|
||||
redis: {
|
||||
selectKey: "Select a key to view its value",
|
||||
noKeys: "No keys found",
|
||||
|
||||
@@ -252,6 +252,12 @@ export default {
|
||||
etcdClientCertBrowse: "选择客户端证书",
|
||||
etcdClientKeyBrowse: "选择客户端私钥",
|
||||
etcdClientCertPairRequired: "客户端证书和私钥必须一起填写。",
|
||||
zookeeperConnectString: "Connect String",
|
||||
zookeeperConnectStringHint: "可用逗号或换行分隔 host:port;留空时使用上面的 host 和端口。",
|
||||
zookeeperCreateModePersistent: "持久节点",
|
||||
zookeeperCreateModeEphemeral: "临时节点",
|
||||
zookeeperCreateModePersistentSequential: "持久顺序节点",
|
||||
zookeeperCreateModeEphemeralSequential: "临时顺序节点",
|
||||
nacosConsoleUrl: "控制台 URL",
|
||||
nacosConsoleUrlHint: "填写 Nacos 控制台/admin API 地址。Nacos 3 Docker 通常是 8085;如果旧版控制台和服务共用 8848,也可以填 8848。",
|
||||
nacosConsoleUrlRequired: "Nacos 控制台 URL 不能为空",
|
||||
@@ -471,6 +477,7 @@ export default {
|
||||
tableData: "数据表",
|
||||
redis: "Redis",
|
||||
etcd: "etcd",
|
||||
zookeeper: "ZooKeeper",
|
||||
mongo: "Mongo",
|
||||
vector: "向量",
|
||||
objects: "对象",
|
||||
@@ -1555,6 +1562,39 @@ export default {
|
||||
deleted: "Key 已删除",
|
||||
base64Readonly: "Base64 值当前版本只读。",
|
||||
},
|
||||
zookeeper: {
|
||||
prefixPlaceholder: "路径前缀,例如 /app/",
|
||||
newKey: "新建 Znode",
|
||||
loadingKeys: "正在加载 znode...",
|
||||
empty: "未找到 znode",
|
||||
loadMore: "加载更多",
|
||||
selectKey: "选择一个 znode 查看值",
|
||||
loadingValue: "正在加载值...",
|
||||
notFound: "未找到 znode",
|
||||
edit: "编辑",
|
||||
editKey: "编辑 Znode",
|
||||
delete: "删除",
|
||||
deleteTitle: "删除 ZooKeeper znode",
|
||||
keyPlaceholder: "/path/to/znode",
|
||||
keyRequired: "Znode 路径不能为空",
|
||||
saved: "Znode 已保存",
|
||||
deleted: "Znode 已删除",
|
||||
base64Readonly: "Base64 值当前版本只读。",
|
||||
createMode: "创建模式",
|
||||
createModePersistent: "持久节点",
|
||||
createModeEphemeral: "临时节点",
|
||||
createModePersistentSequential: "持久顺序节点",
|
||||
createModeEphemeralSequential: "临时顺序节点",
|
||||
add: "添加",
|
||||
value: "值",
|
||||
metadata: "节点信息",
|
||||
prettyJson: "美化",
|
||||
invalidJson: "不是合法的 JSON",
|
||||
summaryRevision: "修订",
|
||||
summaryVersion: "版本",
|
||||
summaryLease: "租约",
|
||||
summarySize: "大小",
|
||||
},
|
||||
redis: {
|
||||
selectKey: "选择一个 key 查看值",
|
||||
noKeys: "未找到 key",
|
||||
|
||||
@@ -18,6 +18,10 @@ describe("connectionAttemptTimeout", () => {
|
||||
expect(connectionAttemptTimeoutMs({ db_type: "prestosql", connect_timeout_secs: 5, transport_layers: [] })).toBe(AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS);
|
||||
});
|
||||
|
||||
it("uses the startup floor for ZooKeeper agent connections", () => {
|
||||
expect(connectionAttemptTimeoutMs({ db_type: "zookeeper", connect_timeout_secs: 5, transport_layers: [] })).toBe(AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS);
|
||||
});
|
||||
|
||||
it("uses a 30s Access agent startup floor", () => {
|
||||
expect(connectionAttemptTimeoutMs({ db_type: "access", connect_timeout_secs: 5, transport_layers: [] })).toBe(ACCESS_AGENT_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseConnectionUrl } from "../connectionUrl";
|
||||
|
||||
describe("ZooKeeper connection URLs", () => {
|
||||
it("preserves the host:port chroot path as a ZooKeeper connect string", () => {
|
||||
expect(parseConnectionUrl("zookeeper://zk-main:2181/app").connectionString).toBe("zk-main:2181/app");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildKvKeyTree, collectKvGroupIds, flattenVisibleKvKeyTree, preserveKvExpandedGroupIds } from "@/lib/kvKeyTree";
|
||||
|
||||
describe("kv key tree", () => {
|
||||
it("keeps root keys as leaf nodes", () => {
|
||||
const tree = buildKvKeyTree([{ key: "/plain", version: 2 }, { key: "/" }]);
|
||||
|
||||
expect(tree.map((node) => `${node.kind}:${node.label}`)).toEqual(["leaf:/", "leaf:plain"]);
|
||||
expect(tree[1]).toMatchObject({ kind: "leaf", key: "/plain", version: 2 });
|
||||
});
|
||||
|
||||
it("groups slash-delimited keys and sorts groups before leaves", () => {
|
||||
const tree = buildKvKeyTree([
|
||||
{ key: "/app/config/name", modRevision: 3 },
|
||||
{ key: "/plain", modRevision: 4 },
|
||||
{ key: "/app/config/env", modRevision: 5 },
|
||||
{ key: "/service/api", modRevision: 6 },
|
||||
]);
|
||||
|
||||
expect(tree.map((node) => node.label)).toEqual(["app", "service", "plain"]);
|
||||
const app = tree[0];
|
||||
expect(app.kind).toBe("group");
|
||||
if (app.kind === "group") {
|
||||
expect(app.children.map((node) => node.label)).toEqual(["config"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("collects stable group ids", () => {
|
||||
const tree = buildKvKeyTree([{ key: "/app/config/name" }, { key: "/service/api" }]);
|
||||
|
||||
expect([...collectKvGroupIds(tree)].sort()).toEqual(["group:app", "group:app\u0000config", "group:service"]);
|
||||
});
|
||||
|
||||
it("flattens only expanded groups", () => {
|
||||
const tree = buildKvKeyTree([{ key: "/app/config/name" }, { key: "/plain" }]);
|
||||
const rows = flattenVisibleKvKeyTree(tree, new Set(["group:app"]));
|
||||
|
||||
expect(rows.map((row) => `${row.depth}:${row.node.label}`)).toEqual(["0:app", "1:config", "0:plain"]);
|
||||
});
|
||||
|
||||
it("preserves only expanded groups still present after reload", () => {
|
||||
const tree = buildKvKeyTree([{ key: "/app/config/name" }, { key: "/service/api" }]);
|
||||
const next = preserveKvExpandedGroupIds(tree, new Set(["group:app", "group:missing"]));
|
||||
|
||||
expect([...next]).toEqual(["group:app"]);
|
||||
expect([...preserveKvExpandedGroupIds(tree, new Set(), true)].sort()).toEqual(["group:app", "group:app\u0000config", "group:service"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { refreshedKvSelectionKey } from "@/lib/kvRefreshSelection";
|
||||
import type { KvKeySummary } from "@/lib/api";
|
||||
|
||||
describe("kv refresh selection", () => {
|
||||
const keys: KvKeySummary[] = [{ key: "/app/config" }, { key: "/app/feature" }];
|
||||
|
||||
it("keeps the previously selected key when it still exists after refresh", () => {
|
||||
expect(refreshedKvSelectionKey("/app/config", keys)).toBe("/app/config");
|
||||
});
|
||||
|
||||
it("clears the selected key when it no longer exists after refresh", () => {
|
||||
expect(refreshedKvSelectionKey("/app/missing", keys)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { kvRootNodeLabel } from "@/lib/kvRootPresentation";
|
||||
|
||||
describe("kv root presentation", () => {
|
||||
it("keeps etcd under Keys but shows ZooKeeper as root path", () => {
|
||||
expect(kvRootNodeLabel("etcd")).toBe("Keys");
|
||||
expect(kvRootNodeLabel("zookeeper")).toBe("/");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatZooKeeperMetadataRows, formatZooKeeperSummaryBadges, prettyPrintJsonText } from "@/lib/kvValueDisplay";
|
||||
import type { KvKeyMetadata } from "@/lib/api";
|
||||
|
||||
describe("kv value display helpers", () => {
|
||||
it("pretty prints valid JSON text", () => {
|
||||
expect(prettyPrintJsonText('{"name":"张三","roles":["admin","reader"]}')).toEqual({
|
||||
ok: true,
|
||||
value: '{\n "name": "张三",\n "roles": [\n "admin",\n "reader"\n ]\n}',
|
||||
});
|
||||
});
|
||||
|
||||
it("does not treat plain text as JSON", () => {
|
||||
expect(prettyPrintJsonText("hello")).toEqual({
|
||||
ok: false,
|
||||
error: "invalid_json",
|
||||
});
|
||||
});
|
||||
|
||||
it("formats ZooKeeper summary badges with ZK fallbacks", () => {
|
||||
const metadata: KvKeyMetadata = {
|
||||
mzxid: 29,
|
||||
version: 0,
|
||||
lease: null,
|
||||
dataLength: 291,
|
||||
};
|
||||
|
||||
expect(formatZooKeeperSummaryBadges(metadata)).toEqual([
|
||||
{ label: "rev", value: "29" },
|
||||
{ label: "ver", value: "0" },
|
||||
{ label: "lease", value: "-" },
|
||||
{ label: "size", value: "291 B" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("formats ZooKeeper summary badges with localized labels", () => {
|
||||
const metadata: KvKeyMetadata = {
|
||||
mzxid: 373437,
|
||||
version: 0,
|
||||
lease: null,
|
||||
dataLength: 291,
|
||||
};
|
||||
|
||||
expect(
|
||||
formatZooKeeperSummaryBadges(metadata, {
|
||||
revision: "修订",
|
||||
version: "版本",
|
||||
lease: "租约",
|
||||
size: "大小",
|
||||
}),
|
||||
).toEqual([
|
||||
{ label: "修订", value: "373437" },
|
||||
{ label: "版本", value: "0" },
|
||||
{ label: "租约", value: "-" },
|
||||
{ label: "大小", value: "291 B" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("formats ZooKeeper stat rows using user-facing labels", () => {
|
||||
const metadata: KvKeyMetadata = {
|
||||
ephemeralOwner: 0,
|
||||
ctime: 1780674584000,
|
||||
mtime: 1780674585000,
|
||||
mzxid: 27,
|
||||
pzxid: 39825,
|
||||
czxid: 27,
|
||||
dataLength: 0,
|
||||
numChildren: 5,
|
||||
version: 0,
|
||||
aversion: 0,
|
||||
cversion: 5,
|
||||
};
|
||||
|
||||
expect(formatZooKeeperMetadataRows(metadata).map((row) => [row.label, row.value])).toEqual([
|
||||
["ephemeralOwner", "0x0"],
|
||||
["mtime", expect.stringMatching(/^2026-06-05 \d{2}:49:45$/)],
|
||||
["ctime", expect.stringMatching(/^2026-06-05 \d{2}:49:44$/)],
|
||||
["mZxid", "0x1b"],
|
||||
["pZxid", "0x9b91"],
|
||||
["cZxid", "0x1b"],
|
||||
["dataLength", "0"],
|
||||
["numChildren", "5"],
|
||||
["dataVersion", "0"],
|
||||
["aclVersion", "0"],
|
||||
["cVersion", "5"],
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -332,6 +332,7 @@ describe("supportsExecutionTargetPicker", () => {
|
||||
expect(supportsExecutionTargetPicker("milvus")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("weaviate")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("etcd")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("zookeeper")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("mq")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker("neo4j")).toBe(false);
|
||||
expect(supportsExecutionTargetPicker(undefined)).toBe(false);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { zookeeperDelete, zookeeperGet, zookeeperListPrefix, zookeeperPut, type KvPutOptions, type KvPutResponse } from "../api";
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
|
||||
describe("zookeeper frontend API contract", () => {
|
||||
it("exposes the zookeeper database type and KV put options", () => {
|
||||
const dbType: DatabaseType = "zookeeper";
|
||||
const options: KvPutOptions = {
|
||||
writeMode: "create",
|
||||
createMode: "ephemeral_sequential",
|
||||
};
|
||||
const response: KvPutResponse = {
|
||||
key: "/sessions/member-0000000001",
|
||||
createdKey: "/sessions/member-0000000001",
|
||||
};
|
||||
|
||||
expect(dbType).toBe("zookeeper");
|
||||
expect(options.createMode).toBe("ephemeral_sequential");
|
||||
expect(response.createdKey).toBe(response.key);
|
||||
expect(typeof zookeeperListPrefix).toBe("function");
|
||||
expect(typeof zookeeperGet).toBe("function");
|
||||
expect(typeof zookeeperPut).toBe("function");
|
||||
expect(typeof zookeeperDelete).toBe("function");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { firstZooKeeperEndpoint, normalizeZooKeeperConnectString } from "../zookeeperConnection";
|
||||
|
||||
describe("zookeeperConnection", () => {
|
||||
it("normalizes comma, semicolon, and newline separated connect strings", () => {
|
||||
expect(normalizeZooKeeperConnectString(" zk-1:2181, zk-2:2182\nzk-3 ; ")).toBe("zk-1:2181,zk-2:2182,zk-3");
|
||||
});
|
||||
|
||||
it("extracts the first host and port from a connect string", () => {
|
||||
expect(firstZooKeeperEndpoint("zk-1:2182,zk-2:2181")).toEqual({ host: "zk-1", port: 2182 });
|
||||
});
|
||||
|
||||
it("strips a zookeeper URL scheme when normalizing connect strings", () => {
|
||||
expect(normalizeZooKeeperConnectString("zookeeper://zk-main:2181")).toBe("zk-main:2181");
|
||||
});
|
||||
|
||||
it("uses the ZooKeeper default port when the first endpoint omits a port", () => {
|
||||
expect(firstZooKeeperEndpoint("zk-main")).toEqual({ host: "zk-main", port: 2181 });
|
||||
});
|
||||
|
||||
it("parses bracketed IPv6 endpoints", () => {
|
||||
expect(firstZooKeeperEndpoint("[::1]:2281,zk-2:2181")).toEqual({ host: "::1", port: 2281 });
|
||||
});
|
||||
});
|
||||
@@ -311,6 +311,12 @@ export const etcdGet = forward("etcdGet");
|
||||
export const etcdPut = forward("etcdPut");
|
||||
export const etcdDelete = forward("etcdDelete");
|
||||
|
||||
// ZooKeeper
|
||||
export const zookeeperListPrefix = forward("zookeeperListPrefix");
|
||||
export const zookeeperGet = forward("zookeeperGet");
|
||||
export const zookeeperPut = forward("zookeeperPut");
|
||||
export const zookeeperDelete = forward("zookeeperDelete");
|
||||
|
||||
// Message Queue
|
||||
export const mqTestConnection = forward("mqTestConnection");
|
||||
export const mqListTenants = forward("mqListTenants");
|
||||
@@ -435,6 +441,9 @@ export type {
|
||||
KvKeySummary,
|
||||
KvListPrefixResponse,
|
||||
KvGetResponse,
|
||||
KvWriteMode,
|
||||
KvCreateMode,
|
||||
KvPutOptions,
|
||||
KvPutResponse,
|
||||
KvDeleteResponse,
|
||||
MongoDocumentResult,
|
||||
|
||||
@@ -39,6 +39,7 @@ const DRIVER_STARTUP_FLOOR_TYPES = new Set<DatabaseType>([
|
||||
"xugu",
|
||||
"iotdb",
|
||||
"etcd",
|
||||
"zookeeper",
|
||||
"iris",
|
||||
]);
|
||||
|
||||
|
||||
@@ -99,6 +99,9 @@ export function connectionUrlPlaceholder(dbType: DatabaseType): string {
|
||||
case "etcd":
|
||||
return "etcd://host:2379";
|
||||
|
||||
case "zookeeper":
|
||||
return "zookeeper://host:2181";
|
||||
|
||||
case "sqlite":
|
||||
return "sqlite:///absolute/path/to/database.db";
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ const SCHEME_PROFILES: Record<string, ConnectionProfile> = {
|
||||
redis: { type: "redis", profile: "redis", label: "Redis", defaultPort: 6379 },
|
||||
rediss: { type: "redis", profile: "redis", label: "Redis", defaultPort: 6379 },
|
||||
etcd: { type: "etcd", profile: "etcd", label: "etcd", defaultPort: 2379 },
|
||||
zookeeper: { type: "zookeeper", profile: "zookeeper", label: "Apache ZooKeeper", defaultPort: 2181 },
|
||||
mongodb: { type: "mongodb", profile: "mongodb", label: "MongoDB", defaultPort: 27017 },
|
||||
"mongodb+srv": { type: "mongodb", profile: "mongodb", label: "MongoDB", defaultPort: 27017 },
|
||||
clickhouse: { type: "clickhouse", profile: "clickhouse", label: "ClickHouse", defaultPort: 8123 },
|
||||
@@ -447,6 +448,21 @@ export function parseConnectionUrl(value: string, preferredProfile?: string): Pa
|
||||
useMongoUrl: true,
|
||||
};
|
||||
}
|
||||
if (profile.type === "zookeeper") {
|
||||
return {
|
||||
dbType: profile.type,
|
||||
driverProfile: profile.profile,
|
||||
driverLabel: profile.label,
|
||||
host: parsed.hostname.replace(/^\[(.*)]$/, "$1"),
|
||||
port: parsed.port ? Number(parsed.port) : profile.defaultPort,
|
||||
username: decodeUrlPart(parsed.username),
|
||||
password: decodeUrlPart(parsed.password),
|
||||
database: undefined,
|
||||
urlParams,
|
||||
ssl: false,
|
||||
connectionString: zookeeperConnectStringFromUrl(parsed, profile.defaultPort),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
dbType: profile.type,
|
||||
@@ -462,6 +478,14 @@ export function parseConnectionUrl(value: string, preferredProfile?: string): Pa
|
||||
};
|
||||
}
|
||||
|
||||
function zookeeperConnectStringFromUrl(parsed: URL, defaultPort: number): string {
|
||||
const rawHost = parsed.hostname.replace(/^\[(.*)]$/, "$1");
|
||||
const host = rawHost.includes(":") ? `[${rawHost}]` : rawHost;
|
||||
const port = parsed.port ? Number(parsed.port) : defaultPort;
|
||||
const chroot = parsed.pathname && parsed.pathname !== "/" ? parsed.pathname : "";
|
||||
return `${host}:${port}${chroot}`;
|
||||
}
|
||||
|
||||
export function applyParsedConnectionUrl(config: Omit<ConnectionConfig, "id">, parsed: ParsedConnectionUrl): Omit<ConnectionConfig, "id"> {
|
||||
return {
|
||||
...config,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { filterDatabaseNamesForConnection, normalizeVisibleDatabaseSelection } f
|
||||
|
||||
const DRAFT_VISIBLE_DATABASES_PREFIX = "__visible_draft_";
|
||||
|
||||
const UNSUPPORTED_VISIBLE_DATABASE_TYPES = new Set<DatabaseType>(["elasticsearch", "qdrant", "milvus", "weaviate", "etcd"]);
|
||||
const UNSUPPORTED_VISIBLE_DATABASE_TYPES = new Set<DatabaseType>(["elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "zookeeper"]);
|
||||
|
||||
type VisibleDatabaseConnectionFields = Pick<
|
||||
ConnectionConfig,
|
||||
|
||||
@@ -1,127 +1,3 @@
|
||||
import type { KvKeySummary } from "./api";
|
||||
export { buildKvKeyTree as buildEtcdKeyTree, collectKvGroupIds as collectEtcdGroupIds, flattenVisibleKvKeyTree as flattenVisibleEtcdKeyTree, preserveKvExpandedGroupIds as preserveEtcdExpandedGroupIds } from "./kvKeyTree";
|
||||
|
||||
export interface EtcdKeyTreeLeafNode {
|
||||
kind: "leaf";
|
||||
id: string;
|
||||
label: string;
|
||||
key: string;
|
||||
pathSegments: string[];
|
||||
createRevision?: number | null;
|
||||
modRevision?: number | null;
|
||||
version?: number | null;
|
||||
lease?: number | null;
|
||||
valueSize?: number | null;
|
||||
}
|
||||
|
||||
export interface EtcdKeyTreeGroupNode {
|
||||
kind: "group";
|
||||
id: string;
|
||||
label: string;
|
||||
pathSegments: string[];
|
||||
children: EtcdKeyTreeNode[];
|
||||
}
|
||||
|
||||
export type EtcdKeyTreeNode = EtcdKeyTreeLeafNode | EtcdKeyTreeGroupNode;
|
||||
|
||||
export interface EtcdKeyTreeRow {
|
||||
node: EtcdKeyTreeNode;
|
||||
depth: number;
|
||||
}
|
||||
|
||||
function keySegments(key: string): string[] {
|
||||
return key.split("/").filter(Boolean);
|
||||
}
|
||||
|
||||
function groupId(pathSegments: string[]): string {
|
||||
return `group:${pathSegments.join("\u0000")}`;
|
||||
}
|
||||
|
||||
function leafId(key: string): string {
|
||||
return `leaf:${key}`;
|
||||
}
|
||||
|
||||
function sortNodes(nodes: EtcdKeyTreeNode[]): EtcdKeyTreeNode[] {
|
||||
return [...nodes]
|
||||
.sort((a, b) => {
|
||||
if (a.kind !== b.kind) return a.kind === "group" ? -1 : 1;
|
||||
return a.label.localeCompare(b.label);
|
||||
})
|
||||
.map((node) => (node.kind === "group" ? { ...node, children: sortNodes(node.children) } : node));
|
||||
}
|
||||
|
||||
export function buildEtcdKeyTree(keys: KvKeySummary[]): EtcdKeyTreeNode[] {
|
||||
const root: EtcdKeyTreeNode[] = [];
|
||||
const groups = new Map<string, EtcdKeyTreeGroupNode>();
|
||||
|
||||
for (const key of keys) {
|
||||
const segments = keySegments(key.key);
|
||||
if (segments.length <= 1) {
|
||||
root.push({
|
||||
kind: "leaf",
|
||||
id: leafId(key.key),
|
||||
label: segments[0] || key.key || "/",
|
||||
key: key.key,
|
||||
pathSegments: segments,
|
||||
createRevision: key.createRevision,
|
||||
modRevision: key.modRevision,
|
||||
version: key.version,
|
||||
lease: key.lease,
|
||||
valueSize: key.valueSize,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
let current = root;
|
||||
const groupSegments: string[] = [];
|
||||
for (const segment of segments.slice(0, -1)) {
|
||||
groupSegments.push(segment);
|
||||
const id = groupId(groupSegments);
|
||||
let group = groups.get(id);
|
||||
if (!group) {
|
||||
group = { kind: "group", id, label: segment, pathSegments: [...groupSegments], children: [] };
|
||||
groups.set(id, group);
|
||||
current.push(group);
|
||||
}
|
||||
current = group.children;
|
||||
}
|
||||
|
||||
current.push({
|
||||
kind: "leaf",
|
||||
id: leafId(key.key),
|
||||
label: segments[segments.length - 1],
|
||||
key: key.key,
|
||||
pathSegments: segments,
|
||||
createRevision: key.createRevision,
|
||||
modRevision: key.modRevision,
|
||||
version: key.version,
|
||||
lease: key.lease,
|
||||
valueSize: key.valueSize,
|
||||
});
|
||||
}
|
||||
|
||||
return sortNodes(root);
|
||||
}
|
||||
|
||||
export function collectEtcdGroupIds(nodes: EtcdKeyTreeNode[]): Set<string> {
|
||||
const ids = new Set<string>();
|
||||
const walk = (entries: EtcdKeyTreeNode[]) => {
|
||||
for (const node of entries) {
|
||||
if (node.kind !== "group") continue;
|
||||
ids.add(node.id);
|
||||
walk(node.children);
|
||||
}
|
||||
};
|
||||
walk(nodes);
|
||||
return ids;
|
||||
}
|
||||
|
||||
export function flattenVisibleEtcdKeyTree(nodes: EtcdKeyTreeNode[], expandedGroupIds: ReadonlySet<string>, depth = 0): EtcdKeyTreeRow[] {
|
||||
const rows: EtcdKeyTreeRow[] = [];
|
||||
for (const node of nodes) {
|
||||
rows.push({ node, depth });
|
||||
if (node.kind === "group" && expandedGroupIds.has(node.id)) {
|
||||
rows.push(...flattenVisibleEtcdKeyTree(node.children, expandedGroupIds, depth + 1));
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
export type { KvKeyTreeGroupNode as EtcdKeyTreeGroupNode, KvKeyTreeLeafNode as EtcdKeyTreeLeafNode, KvKeyTreeNode as EtcdKeyTreeNode, KvKeyTreeRow as EtcdKeyTreeRow } from "./kvKeyTree";
|
||||
|
||||
@@ -57,6 +57,7 @@ import type {
|
||||
KvValue,
|
||||
KvListPrefixResponse,
|
||||
KvGetResponse,
|
||||
KvPutOptions,
|
||||
KvPutResponse,
|
||||
KvDeleteResponse,
|
||||
MongoDocumentResult,
|
||||
@@ -1591,6 +1592,26 @@ export async function etcdDelete(connectionId: string, key: string): Promise<KvD
|
||||
return post("/api/etcd/delete", { connectionId, key });
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ZooKeeper
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function zookeeperListPrefix(connectionId: string, prefix: string, limit: number, continuation?: string | null): Promise<KvListPrefixResponse> {
|
||||
return post("/api/zookeeper/list-prefix", { connectionId, prefix, limit, continuation });
|
||||
}
|
||||
|
||||
export async function zookeeperGet(connectionId: string, key: string): Promise<KvGetResponse> {
|
||||
return post("/api/zookeeper/get", { connectionId, key });
|
||||
}
|
||||
|
||||
export async function zookeeperPut(connectionId: string, key: string, value: KvValue, options?: KvPutOptions | null): Promise<KvPutResponse> {
|
||||
return post("/api/zookeeper/put", { connectionId, key, value, options: options ?? null });
|
||||
}
|
||||
|
||||
export async function zookeeperDelete(connectionId: string, key: string): Promise<KvDeleteResponse> {
|
||||
return post("/api/zookeeper/delete", { connectionId, key });
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Nacos
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import type { KvKeySummary } from "./api";
|
||||
|
||||
export interface KvKeyTreeLeafNode {
|
||||
kind: "leaf";
|
||||
id: string;
|
||||
label: string;
|
||||
key: string;
|
||||
pathSegments: string[];
|
||||
createRevision?: number | null;
|
||||
modRevision?: number | null;
|
||||
version?: number | null;
|
||||
lease?: number | null;
|
||||
valueSize?: number | null;
|
||||
}
|
||||
|
||||
export interface KvKeyTreeGroupNode {
|
||||
kind: "group";
|
||||
id: string;
|
||||
label: string;
|
||||
pathSegments: string[];
|
||||
children: KvKeyTreeNode[];
|
||||
}
|
||||
|
||||
export type KvKeyTreeNode = KvKeyTreeLeafNode | KvKeyTreeGroupNode;
|
||||
|
||||
export interface KvKeyTreeRow {
|
||||
node: KvKeyTreeNode;
|
||||
depth: number;
|
||||
}
|
||||
|
||||
function keySegments(key: string): string[] {
|
||||
return key.split("/").filter(Boolean);
|
||||
}
|
||||
|
||||
function groupId(pathSegments: string[]): string {
|
||||
return `group:${pathSegments.join("\u0000")}`;
|
||||
}
|
||||
|
||||
function leafId(key: string): string {
|
||||
return `leaf:${key}`;
|
||||
}
|
||||
|
||||
function sortNodes(nodes: KvKeyTreeNode[]): KvKeyTreeNode[] {
|
||||
return [...nodes]
|
||||
.sort((a, b) => {
|
||||
if (a.kind !== b.kind) return a.kind === "group" ? -1 : 1;
|
||||
return a.label.localeCompare(b.label);
|
||||
})
|
||||
.map((node) => (node.kind === "group" ? { ...node, children: sortNodes(node.children) } : node));
|
||||
}
|
||||
|
||||
export function buildKvKeyTree(keys: KvKeySummary[]): KvKeyTreeNode[] {
|
||||
const root: KvKeyTreeNode[] = [];
|
||||
const groups = new Map<string, KvKeyTreeGroupNode>();
|
||||
|
||||
for (const key of keys) {
|
||||
const segments = keySegments(key.key);
|
||||
if (segments.length <= 1) {
|
||||
root.push({
|
||||
kind: "leaf",
|
||||
id: leafId(key.key),
|
||||
label: segments[0] || key.key || "/",
|
||||
key: key.key,
|
||||
pathSegments: segments,
|
||||
createRevision: key.createRevision,
|
||||
modRevision: key.modRevision,
|
||||
version: key.version,
|
||||
lease: key.lease,
|
||||
valueSize: key.valueSize,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
let current = root;
|
||||
const groupSegments: string[] = [];
|
||||
for (const segment of segments.slice(0, -1)) {
|
||||
groupSegments.push(segment);
|
||||
const id = groupId(groupSegments);
|
||||
let group = groups.get(id);
|
||||
if (!group) {
|
||||
group = { kind: "group", id, label: segment, pathSegments: [...groupSegments], children: [] };
|
||||
groups.set(id, group);
|
||||
current.push(group);
|
||||
}
|
||||
current = group.children;
|
||||
}
|
||||
|
||||
current.push({
|
||||
kind: "leaf",
|
||||
id: leafId(key.key),
|
||||
label: segments[segments.length - 1],
|
||||
key: key.key,
|
||||
pathSegments: segments,
|
||||
createRevision: key.createRevision,
|
||||
modRevision: key.modRevision,
|
||||
version: key.version,
|
||||
lease: key.lease,
|
||||
valueSize: key.valueSize,
|
||||
});
|
||||
}
|
||||
|
||||
return sortNodes(root);
|
||||
}
|
||||
|
||||
export function collectKvGroupIds(nodes: KvKeyTreeNode[]): Set<string> {
|
||||
const ids = new Set<string>();
|
||||
const walk = (entries: KvKeyTreeNode[]) => {
|
||||
for (const node of entries) {
|
||||
if (node.kind !== "group") continue;
|
||||
ids.add(node.id);
|
||||
walk(node.children);
|
||||
}
|
||||
};
|
||||
walk(nodes);
|
||||
return ids;
|
||||
}
|
||||
|
||||
export function preserveKvExpandedGroupIds(nodes: KvKeyTreeNode[], previous: ReadonlySet<string>, expandAll = false): Set<string> {
|
||||
const available = collectKvGroupIds(nodes);
|
||||
const next = new Set<string>();
|
||||
for (const id of expandAll ? available : previous) {
|
||||
if (available.has(id)) next.add(id);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export function flattenVisibleKvKeyTree(nodes: KvKeyTreeNode[], expandedGroupIds: ReadonlySet<string>, depth = 0): KvKeyTreeRow[] {
|
||||
const rows: KvKeyTreeRow[] = [];
|
||||
for (const node of nodes) {
|
||||
rows.push({ node, depth });
|
||||
if (node.kind === "group" && expandedGroupIds.has(node.id)) {
|
||||
rows.push(...flattenVisibleKvKeyTree(node.children, expandedGroupIds, depth + 1));
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { KvKeySummary } from "@/lib/api";
|
||||
|
||||
export function refreshedKvSelectionKey(previousKey: string | null | undefined, refreshedKeys: readonly KvKeySummary[]): string | null {
|
||||
if (!previousKey) return null;
|
||||
return refreshedKeys.some((item) => item.key === previousKey) ? previousKey : null;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export type KvRootKind = "etcd" | "zookeeper";
|
||||
|
||||
export function kvRootNodeLabel(kind: KvRootKind): string {
|
||||
return kind === "zookeeper" ? "/" : "Keys";
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import type { KvKeyMetadata } from "@/lib/api";
|
||||
|
||||
export interface PrettyPrintJsonResult {
|
||||
ok: boolean;
|
||||
value?: string;
|
||||
error?: "invalid_json";
|
||||
}
|
||||
|
||||
export interface DisplayItem {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface ZooKeeperSummaryLabels {
|
||||
revision?: string;
|
||||
version?: string;
|
||||
lease?: string;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
export function prettyPrintJsonText(text: string): PrettyPrintJsonResult {
|
||||
try {
|
||||
return { ok: true, value: JSON.stringify(JSON.parse(text), null, 2) };
|
||||
} catch {
|
||||
return { ok: false, error: "invalid_json" };
|
||||
}
|
||||
}
|
||||
|
||||
function valueLabel(value: number | null | undefined): string {
|
||||
return value == null ? "-" : String(value);
|
||||
}
|
||||
|
||||
function byteLabel(value: number | null | undefined): string {
|
||||
return value == null ? "- B" : `${value} B`;
|
||||
}
|
||||
|
||||
function hexLabel(value: number | null | undefined): string {
|
||||
if (value == null) return "-";
|
||||
return `0x${Math.trunc(value).toString(16)}`;
|
||||
}
|
||||
|
||||
function dateTimeLabel(value: number | null | undefined): string {
|
||||
if (value == null) return "-";
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "-";
|
||||
const pad = (part: number) => String(part).padStart(2, "0");
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
}
|
||||
|
||||
function metadataNumber(metadata: KvKeyMetadata | null | undefined, key: keyof KvKeyMetadata): number | null | undefined {
|
||||
return metadata?.[key] as number | null | undefined;
|
||||
}
|
||||
|
||||
export function formatZooKeeperSummaryBadges(metadata: KvKeyMetadata | null | undefined, labels: ZooKeeperSummaryLabels = {}): DisplayItem[] {
|
||||
return [
|
||||
{ label: labels.revision ?? "rev", value: valueLabel(metadata?.modRevision ?? metadata?.mzxid) },
|
||||
{ label: labels.version ?? "ver", value: valueLabel(metadata?.version) },
|
||||
{ label: labels.lease ?? "lease", value: valueLabel(metadata?.lease) },
|
||||
{ label: labels.size ?? "size", value: byteLabel(metadata?.valueSize ?? metadata?.dataLength) },
|
||||
];
|
||||
}
|
||||
|
||||
export function formatZooKeeperMetadataRows(metadata: KvKeyMetadata | null | undefined): DisplayItem[] {
|
||||
return [
|
||||
{ label: "ephemeralOwner", value: hexLabel(metadata?.ephemeralOwner) },
|
||||
{ label: "mtime", value: dateTimeLabel(metadata?.mtime) },
|
||||
{ label: "ctime", value: dateTimeLabel(metadata?.ctime) },
|
||||
{ label: "mZxid", value: hexLabel(metadata?.mzxid) },
|
||||
{ label: "pZxid", value: hexLabel(metadataNumber(metadata, "pzxid")) },
|
||||
{ label: "cZxid", value: hexLabel(metadata?.czxid) },
|
||||
{ label: "dataLength", value: valueLabel(metadata?.dataLength) },
|
||||
{ label: "numChildren", value: valueLabel(metadata?.numChildren) },
|
||||
{ label: "dataVersion", value: valueLabel(metadata?.version) },
|
||||
{ label: "aclVersion", value: valueLabel(metadata?.aversion) },
|
||||
{ label: "cVersion", value: valueLabel(metadata?.cversion) },
|
||||
];
|
||||
}
|
||||
@@ -24,6 +24,10 @@ export type ActiveTabSidebarTarget =
|
||||
type: "etcd-root";
|
||||
connectionId: string;
|
||||
}
|
||||
| {
|
||||
type: "zookeeper-root";
|
||||
connectionId: string;
|
||||
}
|
||||
| {
|
||||
type: "mq-tenant";
|
||||
connectionId: string;
|
||||
@@ -85,6 +89,10 @@ export function activeTabSidebarTarget(tab: QueryTab | undefined | null): Active
|
||||
return { type: "etcd-root", connectionId: tab.connectionId };
|
||||
}
|
||||
|
||||
if (tab.mode === "zookeeper") {
|
||||
return { type: "zookeeper-root", connectionId: tab.connectionId };
|
||||
}
|
||||
|
||||
if (tab.mode === "mq" && tab.mqTenant) {
|
||||
return { type: "mq-tenant", connectionId: tab.connectionId, tenant: tab.mqTenant };
|
||||
}
|
||||
@@ -138,6 +146,10 @@ export function matchesTarget(node: TreeNode, target: ActiveTabSidebarTarget): b
|
||||
return node.type === "etcd-root" && node.connectionId === target.connectionId;
|
||||
}
|
||||
|
||||
if (target.type === "zookeeper-root") {
|
||||
return node.type === "zookeeper-root" && node.connectionId === target.connectionId;
|
||||
}
|
||||
|
||||
if (target.type === "mq-tenant") {
|
||||
return node.type === "mq-tenant" && node.connectionId === target.connectionId && (node.mqTenant || node.label) === target.tenant;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { TreeNodeType } from "@/types/database";
|
||||
|
||||
const leafTypes: Set<TreeNodeType> = new Set(["column", "index", "fkey", "trigger", "procedure", "function", "package", "package-body", "object-browser", "redis-db", "mq-tenant", "vector-collection", "elasticsearch-index", "user-admin", "saved-sql-file", "load-more"]);
|
||||
const leafTypes: Set<TreeNodeType> = new Set(["column", "index", "fkey", "trigger", "procedure", "function", "package", "package-body", "object-browser", "redis-db", "mq-tenant", "zookeeper-root", "vector-collection", "elasticsearch-index", "user-admin", "saved-sql-file", "load-more"]);
|
||||
|
||||
const fullWidthLabelTypes: Set<TreeNodeType> = new Set(["table", "view", "materialized_view", "mongo-collection", "vector-collection", "elasticsearch-index"]);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface SqlTextRange {
|
||||
sql: string;
|
||||
}
|
||||
|
||||
const NON_SQL_EXECUTION_TARGET_TYPES: ReadonlySet<DatabaseType> = new Set(["mongodb", "elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "mq", "neo4j"]);
|
||||
const NON_SQL_EXECUTION_TARGET_TYPES: ReadonlySet<DatabaseType> = new Set(["mongodb", "elasticsearch", "qdrant", "milvus", "weaviate", "etcd", "zookeeper", "mq", "neo4j"]);
|
||||
|
||||
export function supportsExecutionTargetPicker(databaseType?: DatabaseType): boolean {
|
||||
return !!databaseType && (databaseType === "redis" || !NON_SQL_EXECUTION_TARGET_TYPES.has(databaseType));
|
||||
@@ -91,6 +91,7 @@ const DATABASE_SOFT_STATEMENT_KEYWORDS: Partial<Record<DatabaseType, readonly st
|
||||
weaviate: [],
|
||||
mq: [],
|
||||
etcd: [],
|
||||
zookeeper: [],
|
||||
};
|
||||
|
||||
const WITH_MAIN_STATEMENT_KEYWORDS = new Set(["SELECT", "INSERT", "UPDATE", "DELETE", "MERGE"]);
|
||||
|
||||
@@ -82,6 +82,10 @@ export function tabDisplayTitle(tab: QueryTab, t: Translate): string {
|
||||
if (compact) return connectionDisplayName(tab.connectionId);
|
||||
return `${connectionDisplayName(tab.connectionId)}@keys`;
|
||||
}
|
||||
if (tab.mode === "zookeeper") {
|
||||
if (compact) return connectionDisplayName(tab.connectionId);
|
||||
return `${connectionDisplayName(tab.connectionId)}@keys`;
|
||||
}
|
||||
if (tab.mode === "objects") {
|
||||
const schema = tab.objectBrowser?.schema;
|
||||
if (compact) return schema || tab.title;
|
||||
@@ -181,6 +185,7 @@ export function tabModeLabel(tab: QueryTab, t: Translate): string {
|
||||
if (tab.mode === "vector") return t("tabs.vector");
|
||||
if (tab.mode === "redis") return t("tabs.redis");
|
||||
if (tab.mode === "etcd") return t("tabs.etcd");
|
||||
if (tab.mode === "zookeeper") return t("tabs.zookeeper");
|
||||
if (tab.mode === "nacos") return "Nacos";
|
||||
if (tab.mode === "objects") return t("tabs.objects");
|
||||
if (tab.mode === "users") return t("tabs.users");
|
||||
|
||||
@@ -1301,6 +1301,16 @@ export interface KvKeyMetadata {
|
||||
version?: number | null;
|
||||
lease?: number | null;
|
||||
valueSize?: number | null;
|
||||
czxid?: number | null;
|
||||
mzxid?: number | null;
|
||||
pzxid?: number | null;
|
||||
ctime?: number | null;
|
||||
mtime?: number | null;
|
||||
cversion?: number | null;
|
||||
aversion?: number | null;
|
||||
ephemeralOwner?: number | null;
|
||||
dataLength?: number | null;
|
||||
numChildren?: number | null;
|
||||
}
|
||||
|
||||
export interface KvKeySummary extends KvKeyMetadata {
|
||||
@@ -1322,6 +1332,18 @@ export interface KvGetResponse {
|
||||
|
||||
export interface KvPutResponse {
|
||||
revision?: number | null;
|
||||
version?: number | null;
|
||||
mtime?: number | null;
|
||||
key?: string | null;
|
||||
createdKey?: string | null;
|
||||
}
|
||||
|
||||
export type KvWriteMode = "upsert" | "create" | "update";
|
||||
export type KvCreateMode = "persistent" | "ephemeral" | "persistent_sequential" | "ephemeral_sequential";
|
||||
|
||||
export interface KvPutOptions {
|
||||
writeMode?: KvWriteMode | null;
|
||||
createMode?: KvCreateMode | null;
|
||||
}
|
||||
|
||||
export interface KvDeleteResponse {
|
||||
@@ -1345,6 +1367,23 @@ export async function etcdDelete(connectionId: string, key: string): Promise<KvD
|
||||
return invoke("etcd_delete", { connectionId, key });
|
||||
}
|
||||
|
||||
// --- ZooKeeper ---
|
||||
export async function zookeeperListPrefix(connectionId: string, prefix: string, limit: number, continuation?: string | null): Promise<KvListPrefixResponse> {
|
||||
return invoke("zookeeper_list_prefix", { connectionId, prefix, limit, continuation });
|
||||
}
|
||||
|
||||
export async function zookeeperGet(connectionId: string, key: string): Promise<KvGetResponse> {
|
||||
return invoke("zookeeper_get", { connectionId, key });
|
||||
}
|
||||
|
||||
export async function zookeeperPut(connectionId: string, key: string, value: KvValue, options?: KvPutOptions | null): Promise<KvPutResponse> {
|
||||
return invoke("zookeeper_put", { connectionId, key, value, options: options ?? null });
|
||||
}
|
||||
|
||||
export async function zookeeperDelete(connectionId: string, key: string): Promise<KvDeleteResponse> {
|
||||
return invoke("zookeeper_delete", { connectionId, key });
|
||||
}
|
||||
|
||||
// --- MongoDB ---
|
||||
export interface MongoDocumentResult {
|
||||
documents: any[];
|
||||
|
||||
@@ -7,7 +7,7 @@ export type SidebarSelectionCopyAction = "copy-name" | "none";
|
||||
export type SidebarActivation = "single" | "double";
|
||||
|
||||
const dataNodeTypes = new Set<TreeNodeType>(["table", "view", "materialized_view"]);
|
||||
const toggleLeafNodeTypes = new Set<TreeNodeType>(["redis-db", "mq-tenant", "mongo-collection", "vector-collection", "elasticsearch-index", "user-admin"]);
|
||||
const toggleLeafNodeTypes = new Set<TreeNodeType>(["redis-db", "mq-tenant", "etcd-root", "zookeeper-root", "mongo-collection", "vector-collection", "elasticsearch-index", "user-admin"]);
|
||||
const objectBrowserNodeTypes = new Set<TreeNodeType>(["database", "schema", "object-browser"]);
|
||||
const sourceNodeTypes = new Set<TreeNodeType>(["materialized_view", "procedure", "function", "sequence", "package", "package-body"]);
|
||||
const savedSqlNodeTypes = new Set<TreeNodeType>(["saved-sql-file"]);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
export interface ZooKeeperEndpoint {
|
||||
host: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
const DEFAULT_ZOOKEEPER_PORT = 2181;
|
||||
|
||||
export function normalizeZooKeeperConnectString(value: string): string {
|
||||
return value
|
||||
.split(/[\n,;]+/)
|
||||
.map((endpoint) => endpoint.trim())
|
||||
.map((endpoint) => endpoint.replace(/^zookeeper:\/\//i, ""))
|
||||
.filter(Boolean)
|
||||
.join(",");
|
||||
}
|
||||
|
||||
export function firstZooKeeperEndpoint(value?: string): ZooKeeperEndpoint | null {
|
||||
const first = normalizeZooKeeperConnectString(value || "")
|
||||
.split(",")
|
||||
.find(Boolean);
|
||||
if (!first) return null;
|
||||
return parseZooKeeperEndpoint(first);
|
||||
}
|
||||
|
||||
function parseZooKeeperEndpoint(value: string): ZooKeeperEndpoint {
|
||||
const endpoint = value
|
||||
.trim()
|
||||
.replace(/^zookeeper:\/\//i, "")
|
||||
.replace(/^.*@/, "")
|
||||
.replace(/[/?#].*$/, "");
|
||||
|
||||
if (endpoint.startsWith("[")) {
|
||||
const end = endpoint.indexOf("]");
|
||||
if (end > 0) {
|
||||
const host = endpoint.slice(1, end);
|
||||
const portText = endpoint.slice(end + 1).replace(/^:/, "");
|
||||
const port = Number(portText);
|
||||
return { host, port: Number.isFinite(port) && port > 0 ? port : DEFAULT_ZOOKEEPER_PORT };
|
||||
}
|
||||
}
|
||||
|
||||
const parts = endpoint.split(":");
|
||||
if (parts.length === 2) {
|
||||
const port = Number(parts[1]);
|
||||
return { host: parts[0], port: Number.isFinite(port) && port > 0 ? port : DEFAULT_ZOOKEEPER_PORT };
|
||||
}
|
||||
return { host: endpoint, port: DEFAULT_ZOOKEEPER_PORT };
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { encodeSqlServerLinkedSchema, parseSqlServerLinkedSchema } from "@/lib/sqlServerLinkedServers";
|
||||
import { inferMongoCompletionFields, type MongoCompletionField } from "@/lib/mongoCompletion";
|
||||
import { completionSchemasFromTree, completionTablesFromTree } from "@/lib/completionTreeIndex";
|
||||
import { kvRootNodeLabel } from "@/lib/kvRootPresentation";
|
||||
|
||||
const PINNED_TREE_NODES_STORAGE_KEY = "dbx-pinned-tree-nodes";
|
||||
const ACTIVE_CONNECTION_STORAGE_KEY = "dbx-active-connection";
|
||||
@@ -398,6 +399,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
sqlite: "SQLite",
|
||||
redis: "Redis",
|
||||
etcd: "etcd",
|
||||
zookeeper: "Apache ZooKeeper",
|
||||
duckdb: "DuckDB",
|
||||
clickhouse: "ClickHouse",
|
||||
sqlserver: "SQL Server",
|
||||
@@ -947,6 +949,8 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
await loadRedisDatabases(connectionId);
|
||||
} else if (config.db_type === "etcd") {
|
||||
await loadEtcdRoot(connectionId);
|
||||
} else if (config.db_type === "zookeeper") {
|
||||
await loadZooKeeperRoot(connectionId);
|
||||
} else if (config.db_type === "mongodb") {
|
||||
await loadMongoDatabases(connectionId);
|
||||
} else if (config.db_type === "elasticsearch") {
|
||||
@@ -1257,7 +1261,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
[
|
||||
{
|
||||
id: `${connectionId}:etcd`,
|
||||
label: "Keys",
|
||||
label: kvRootNodeLabel("etcd"),
|
||||
type: "etcd-root" as const,
|
||||
connectionId,
|
||||
database: "",
|
||||
@@ -1277,6 +1281,40 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadZooKeeperRoot(connectionId: string) {
|
||||
const node = findNode(treeNodes.value, connectionId);
|
||||
if (!node) return;
|
||||
|
||||
node.isLoading = true;
|
||||
try {
|
||||
await ensureConnected(connectionId);
|
||||
setChildren(
|
||||
node,
|
||||
withSavedSqlRoot(
|
||||
connectionId,
|
||||
[
|
||||
{
|
||||
id: `${connectionId}:zookeeper`,
|
||||
label: kvRootNodeLabel("zookeeper"),
|
||||
type: "zookeeper-root" as const,
|
||||
connectionId,
|
||||
database: "",
|
||||
isExpanded: false,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
node,
|
||||
),
|
||||
);
|
||||
node.isExpanded = true;
|
||||
} catch (e) {
|
||||
recordMetadataLoadError(connectionId, e);
|
||||
throw e;
|
||||
} finally {
|
||||
node.isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMqTenants(connectionId: string, options?: LoadTreeOptions) {
|
||||
const node = findNode(treeNodes.value, connectionId);
|
||||
if (!node) return;
|
||||
@@ -2112,6 +2150,8 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
await loadRedisDatabases(node.connectionId);
|
||||
} else if (config?.db_type === "etcd") {
|
||||
await loadEtcdRoot(node.connectionId);
|
||||
} else if (config?.db_type === "zookeeper") {
|
||||
await loadZooKeeperRoot(node.connectionId);
|
||||
} else if (config?.db_type === "mongodb") {
|
||||
await loadMongoDatabases(node.connectionId);
|
||||
} else if (config?.db_type === "elasticsearch") {
|
||||
@@ -3391,6 +3431,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
loadRedisDatabases,
|
||||
refreshRedisDbKeyCounts,
|
||||
loadEtcdRoot,
|
||||
loadZooKeeperRoot,
|
||||
loadMqTenants,
|
||||
loadNacosNamespaces,
|
||||
updateRedisDbKeyStats,
|
||||
|
||||
@@ -54,6 +54,7 @@ export type DatabaseType =
|
||||
| "xugu"
|
||||
| "iotdb"
|
||||
| "etcd"
|
||||
| "zookeeper"
|
||||
| "iris"
|
||||
| "influxdb"
|
||||
| "jdbc"
|
||||
@@ -495,6 +496,7 @@ export type TreeNodeType =
|
||||
| "mq-tenant"
|
||||
| "nacos-namespace"
|
||||
| "etcd-root"
|
||||
| "zookeeper-root"
|
||||
| "mongo-db"
|
||||
| "mongo-collection"
|
||||
| "vector-collection"
|
||||
@@ -606,7 +608,7 @@ export interface QueryTab {
|
||||
executionId?: string;
|
||||
isExplaining?: boolean;
|
||||
explainExecutionId?: string;
|
||||
mode: "data" | "query" | "redis" | "redis-dashboard" | "mongo" | "vector" | "etcd" | "mq" | "nacos" | "objects" | "structure" | "users";
|
||||
mode: "data" | "query" | "redis" | "redis-dashboard" | "mongo" | "vector" | "etcd" | "zookeeper" | "mq" | "nacos" | "objects" | "structure" | "users";
|
||||
mqTenant?: string;
|
||||
nacosNamespace?: string;
|
||||
nacosNamespaceName?: string;
|
||||
|
||||
@@ -1578,6 +1578,36 @@
|
||||
"driverManagement": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"dbType": "zookeeper",
|
||||
"label": "Apache ZooKeeper",
|
||||
"runtimeMode": "agent",
|
||||
"mcpMode": "bridge",
|
||||
"agentKey": "zookeeper",
|
||||
"singleConnectionPool": false,
|
||||
"metadataConnectionScoped": false,
|
||||
"skipTcpProbe": true,
|
||||
"defaultPort": 2181,
|
||||
"supportLevel": "connect",
|
||||
"capabilities": {
|
||||
"queryExecution": true,
|
||||
"metadataBrowse": false,
|
||||
"objectBrowser": false,
|
||||
"objectSource": false,
|
||||
"schemaSearch": true,
|
||||
"diagram": false,
|
||||
"tableDataEdit": false,
|
||||
"tableStructureEdit": false,
|
||||
"tableImport": false,
|
||||
"dataTransfer": false,
|
||||
"sqlFileExecution": false,
|
||||
"databaseCreate": false,
|
||||
"fieldLineage": false,
|
||||
"sqlExplain": false,
|
||||
"userAdmin": false,
|
||||
"driverManagement": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"dbType": "mq",
|
||||
"label": "Message Queue",
|
||||
|
||||
@@ -248,6 +248,13 @@ const AGENT_CATALOG: &[AgentCatalogEntry] = &[
|
||||
profiles: &[],
|
||||
},
|
||||
AgentCatalogEntry { db_type: DatabaseType::Etcd, key: "etcd", label: "etcd", store_visible: true, profiles: &[] },
|
||||
AgentCatalogEntry {
|
||||
db_type: DatabaseType::ZooKeeper,
|
||||
key: "zookeeper",
|
||||
label: "Apache ZooKeeper",
|
||||
store_visible: true,
|
||||
profiles: &[],
|
||||
},
|
||||
AgentCatalogEntry {
|
||||
db_type: DatabaseType::MongoDb,
|
||||
key: "mongodb",
|
||||
|
||||
@@ -35,6 +35,11 @@ pub fn agent_connect_params(config: &ConnectionConfig, host: &str, port: u16, da
|
||||
};
|
||||
let etcd_endpoints =
|
||||
if config.db_type == DatabaseType::Etcd { normalize_etcd_endpoints(config, host, port) } else { String::new() };
|
||||
let zookeeper_connect_string = if config.db_type == DatabaseType::ZooKeeper {
|
||||
normalize_zookeeper_connect_string(config, host, port)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let (agent_host, agent_port) = if is_h2_file_connection(config) { ("", 0) } else { (host, port) };
|
||||
|
||||
serde_json::json!({
|
||||
@@ -51,6 +56,7 @@ pub fn agent_connect_params(config: &ConnectionConfig, host: &str, port: u16, da
|
||||
"client_cert_path": config.client_cert_path,
|
||||
"client_key_path": config.client_key_path,
|
||||
"etcd_endpoints": etcd_endpoints,
|
||||
"zookeeper_connect_string": zookeeper_connect_string,
|
||||
"gbase_server": config.gbase_server,
|
||||
"informix_server": config.informix_server,
|
||||
"jdbc_driver_class": config.jdbc_driver_class.as_deref().unwrap_or(""),
|
||||
@@ -511,6 +517,16 @@ fn normalize_etcd_endpoints(config: &ConnectionConfig, host: &str, port: u16) ->
|
||||
format!("{scheme}://{host}:{port}")
|
||||
}
|
||||
|
||||
fn normalize_zookeeper_connect_string(config: &ConnectionConfig, host: &str, port: u16) -> String {
|
||||
config
|
||||
.connection_string
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| format!("{host}:{port}"))
|
||||
}
|
||||
|
||||
fn normalize_agent_url_params(params: Option<&str>) -> &str {
|
||||
params.unwrap_or("").trim().trim_start_matches(['?', '&'])
|
||||
}
|
||||
@@ -659,6 +675,27 @@ mod tests {
|
||||
assert_eq!(params["connection_string"], "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zookeeper_agent_params_preserve_configured_connect_string() {
|
||||
let mut cfg = config(DatabaseType::ZooKeeper, None);
|
||||
cfg.connection_string = Some("zk-1:2181,zk-2:2181/app".to_string());
|
||||
|
||||
let params = agent_connect_params(&cfg, "127.0.0.1", 2181, "");
|
||||
|
||||
assert_eq!(params["connection_string"], "zk-1:2181,zk-2:2181/app");
|
||||
assert_eq!(params["zookeeper_connect_string"], "zk-1:2181,zk-2:2181/app");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zookeeper_agent_params_fall_back_to_host_port_connect_string() {
|
||||
let cfg = config(DatabaseType::ZooKeeper, None);
|
||||
|
||||
let params = agent_connect_params(&cfg, "zk.local", 2281, "");
|
||||
|
||||
assert_eq!(params["connection_string"], "");
|
||||
assert_eq!(params["zookeeper_connect_string"], "zk.local:2281");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mongo_auth_hint_preserves_original_error() {
|
||||
let err = "Agent RPC error: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='rwuser', source='admin'}";
|
||||
|
||||
@@ -25,6 +25,16 @@ pub struct KvKeyMetadata {
|
||||
pub version: Option<i64>,
|
||||
pub lease: Option<i64>,
|
||||
pub value_size: Option<u64>,
|
||||
pub czxid: Option<i64>,
|
||||
pub mzxid: Option<i64>,
|
||||
pub pzxid: Option<i64>,
|
||||
pub ctime: Option<i64>,
|
||||
pub mtime: Option<i64>,
|
||||
pub cversion: Option<i64>,
|
||||
pub aversion: Option<i64>,
|
||||
pub ephemeral_owner: Option<i64>,
|
||||
pub data_length: Option<u64>,
|
||||
pub num_children: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -74,12 +84,46 @@ pub struct KvPutRequest {
|
||||
pub value: KvValue,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub lease: Option<i64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub write_mode: Option<KvWriteMode>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub create_mode: Option<KvCreateMode>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KvPutOptions {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub lease: Option<i64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub write_mode: Option<KvWriteMode>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub create_mode: Option<KvCreateMode>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KvWriteMode {
|
||||
Upsert,
|
||||
Create,
|
||||
Update,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum KvCreateMode {
|
||||
Persistent,
|
||||
Ephemeral,
|
||||
PersistentSequential,
|
||||
EphemeralSequential,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KvPutResponse {
|
||||
pub revision: Option<i64>,
|
||||
pub key: Option<String>,
|
||||
pub created_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -109,7 +153,18 @@ pub fn kv_get_params(key: &str) -> serde_json::Value {
|
||||
}
|
||||
|
||||
pub fn kv_put_params(key: &str, value: KvValue, lease: Option<i64>) -> serde_json::Value {
|
||||
serde_json::to_value(KvPutRequest { key: key.to_string(), value, lease }).expect("KV put request should serialize")
|
||||
kv_put_params_with_options(key, value, KvPutOptions { lease, ..KvPutOptions::default() })
|
||||
}
|
||||
|
||||
pub fn kv_put_params_with_options(key: &str, value: KvValue, options: KvPutOptions) -> serde_json::Value {
|
||||
serde_json::to_value(KvPutRequest {
|
||||
key: key.to_string(),
|
||||
value,
|
||||
lease: options.lease,
|
||||
write_mode: options.write_mode,
|
||||
create_mode: options.create_mode,
|
||||
})
|
||||
.expect("KV put request should serialize")
|
||||
}
|
||||
|
||||
pub fn kv_delete_params(key: &str) -> serde_json::Value {
|
||||
@@ -138,7 +193,17 @@ pub async fn kv_put_core(
|
||||
value: KvValue,
|
||||
lease: Option<i64>,
|
||||
) -> Result<KvPutResponse, String> {
|
||||
call_agent_kv(state, connection_id, AgentKvMethod::Put, kv_put_params(key, value, lease)).await
|
||||
kv_put_core_with_options(state, connection_id, key, value, KvPutOptions { lease, ..KvPutOptions::default() }).await
|
||||
}
|
||||
|
||||
pub async fn kv_put_core_with_options(
|
||||
state: &AppState,
|
||||
connection_id: &str,
|
||||
key: &str,
|
||||
value: KvValue,
|
||||
options: KvPutOptions,
|
||||
) -> Result<KvPutResponse, String> {
|
||||
call_agent_kv(state, connection_id, AgentKvMethod::Put, kv_put_params_with_options(key, value, options)).await
|
||||
}
|
||||
|
||||
pub async fn kv_delete_core(state: &AppState, connection_id: &str, key: &str) -> Result<KvDeleteResponse, String> {
|
||||
@@ -211,6 +276,41 @@ mod tests {
|
||||
assert_eq!(kv_delete_params("/app/name"), serde_json::json!({ "key": "/app/name" }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serializes_kv_put_options_without_changing_default_shape() {
|
||||
let value = KvValue { encoding: KvValueEncoding::Utf8, data: "dbx".to_string() };
|
||||
assert_eq!(
|
||||
kv_put_params("/app/name", value.clone(), None),
|
||||
serde_json::json!({
|
||||
"key": "/app/name",
|
||||
"value": {
|
||||
"encoding": "utf8",
|
||||
"data": "dbx"
|
||||
}
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
kv_put_params_with_options(
|
||||
"/jobs/job-",
|
||||
value,
|
||||
KvPutOptions {
|
||||
write_mode: Some(KvWriteMode::Create),
|
||||
create_mode: Some(KvCreateMode::EphemeralSequential),
|
||||
..KvPutOptions::default()
|
||||
},
|
||||
),
|
||||
serde_json::json!({
|
||||
"key": "/jobs/job-",
|
||||
"value": {
|
||||
"encoding": "utf8",
|
||||
"data": "dbx"
|
||||
},
|
||||
"writeMode": "create",
|
||||
"createMode": "ephemeral_sequential"
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_kv_list_prefix_response() {
|
||||
let decoded: KvListPrefixResponse = serde_json::from_value(serde_json::json!({
|
||||
@@ -232,4 +332,49 @@ mod tests {
|
||||
assert_eq!(decoded.continuation.as_deref(), Some("next-token"));
|
||||
assert_eq!(decoded.revision, Some(9));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_kv_put_response_with_created_key() {
|
||||
let decoded: KvPutResponse = serde_json::from_value(serde_json::json!({
|
||||
"key": "/jobs/job-0000000001",
|
||||
"createdKey": "/jobs/job-0000000001"
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(decoded.revision, None);
|
||||
assert_eq!(decoded.key.as_deref(), Some("/jobs/job-0000000001"));
|
||||
assert_eq!(decoded.created_key.as_deref(), Some("/jobs/job-0000000001"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_zookeeper_metadata_fields() {
|
||||
let decoded: KvGetResponse = serde_json::from_value(serde_json::json!({
|
||||
"found": true,
|
||||
"key": "/admin",
|
||||
"value": {
|
||||
"encoding": "utf8",
|
||||
"data": ""
|
||||
},
|
||||
"metadata": {
|
||||
"czxid": 27,
|
||||
"mzxid": 27,
|
||||
"pzxid": 39825,
|
||||
"ctime": 1780674584000_i64,
|
||||
"mtime": 1780674585000_i64,
|
||||
"cversion": 5,
|
||||
"aversion": 0,
|
||||
"ephemeralOwner": 0,
|
||||
"dataLength": 0,
|
||||
"numChildren": 5
|
||||
}
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
let metadata = decoded.metadata.unwrap();
|
||||
assert_eq!(metadata.czxid, Some(27));
|
||||
assert_eq!(metadata.mzxid, Some(27));
|
||||
assert_eq!(metadata.pzxid, Some(39825));
|
||||
assert_eq!(metadata.ephemeral_owner, Some(0));
|
||||
assert_eq!(metadata.num_children, Some(5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ macro_rules! agent_connection_pool_database_type {
|
||||
| DatabaseType::Xugu
|
||||
| DatabaseType::Iotdb
|
||||
| DatabaseType::Etcd
|
||||
| DatabaseType::ZooKeeper
|
||||
| DatabaseType::Iris
|
||||
| DatabaseType::Access
|
||||
};
|
||||
@@ -1286,6 +1287,12 @@ impl AppState {
|
||||
let timeout = crate::db::connection_timeout();
|
||||
match agent.validate_connection(Some(timeout)).await {
|
||||
Ok(_) => false,
|
||||
Err(err) if is_agent_validate_connection_unsupported(&err) => {
|
||||
log::debug!(
|
||||
"Agent connection pool '{pool_key}' does not support validate_connection; keeping pool"
|
||||
);
|
||||
false
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("Agent connection pool '{pool_key}' is stale: {err}");
|
||||
true
|
||||
@@ -1876,6 +1883,7 @@ async fn ping_keepalive_target(target: &mut KeepaliveTarget, timeout: Duration)
|
||||
};
|
||||
match client.validate_connection(Some(timeout)).await {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) if is_agent_validate_connection_unsupported(&err) => Ok(()),
|
||||
Err(err) => {
|
||||
client.kill();
|
||||
Err(err)
|
||||
@@ -1885,6 +1893,11 @@ async fn ping_keepalive_target(target: &mut KeepaliveTarget, timeout: Duration)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_agent_validate_connection_unsupported(err: &str) -> bool {
|
||||
let lower = err.to_ascii_lowercase();
|
||||
lower.contains("validate_connection") && (lower.contains("unknown method") || lower.contains("method not found"))
|
||||
}
|
||||
|
||||
fn connection_remote_endpoint(config: &ConnectionConfig) -> (String, u16) {
|
||||
if config.db_type == DatabaseType::MongoDb {
|
||||
config
|
||||
@@ -2480,6 +2493,7 @@ mod tests {
|
||||
assert!(uses_bare_mysql_pool(&DatabaseType::ManticoreSearch));
|
||||
assert!(!uses_bare_mysql_pool(&DatabaseType::Databend));
|
||||
assert!(database_capabilities::is_agent_type(&DatabaseType::Databend));
|
||||
assert!(super::uses_agent_connection_pool(&DatabaseType::ZooKeeper));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3304,6 +3318,18 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agent_validate_connection_unknown_method_is_not_stale() {
|
||||
assert!(super::is_agent_validate_connection_unsupported(
|
||||
"Agent RPC error (-1): Unknown method: validate_connection"
|
||||
));
|
||||
assert!(super::is_agent_validate_connection_unsupported(
|
||||
"Agent RPC error (-32601): Method not found: validate_connection"
|
||||
));
|
||||
assert!(!super::is_agent_validate_connection_unsupported("Agent RPC error (-1): Connection timed out"));
|
||||
assert!(!super::is_agent_validate_connection_unsupported("Agent RPC error (-1): Unknown method: kv_put"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
#[tokio::test]
|
||||
async fn duckdb_client_session_reuses_base_pool_to_avoid_file_locks() {
|
||||
|
||||
@@ -309,6 +309,8 @@ pub enum DatabaseType {
|
||||
Xugu,
|
||||
Iotdb,
|
||||
Etcd,
|
||||
#[serde(rename = "zookeeper")]
|
||||
ZooKeeper,
|
||||
Nacos,
|
||||
#[serde(rename = "iris")]
|
||||
Iris,
|
||||
@@ -789,6 +791,9 @@ impl ConnectionConfig {
|
||||
DatabaseType::Etcd => {
|
||||
format!("etcd://{host}:{port}")
|
||||
}
|
||||
DatabaseType::ZooKeeper => {
|
||||
format!("zookeeper://{host}:{port}")
|
||||
}
|
||||
DatabaseType::Iris => format!("iris://{host}:{port}{db_part}"),
|
||||
DatabaseType::InfluxDb => {
|
||||
let scheme = if self.ssl { "https" } else { "http" };
|
||||
@@ -991,6 +996,13 @@ impl ConnectionConfig {
|
||||
format!("etcd://{}:{}@{host}:{port}", username, password)
|
||||
}
|
||||
}
|
||||
DatabaseType::ZooKeeper => {
|
||||
if self.username.is_empty() {
|
||||
format!("zookeeper://{host}:{port}")
|
||||
} else {
|
||||
format!("zookeeper://{}:{}@{host}:{port}", username, password)
|
||||
}
|
||||
}
|
||||
DatabaseType::Iris => {
|
||||
format!("iris://{}:{}@{host}:{port}{db_part}", username, password)
|
||||
}
|
||||
@@ -1571,6 +1583,27 @@ mod tests {
|
||||
config
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zookeeper_database_type_uses_stable_wire_name() {
|
||||
assert_eq!(serde_json::to_string(&DatabaseType::ZooKeeper).unwrap(), "\"zookeeper\"");
|
||||
assert_eq!(serde_json::from_str::<DatabaseType>("\"zookeeper\"").unwrap(), DatabaseType::ZooKeeper);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zookeeper_connection_url_uses_zookeeper_scheme() {
|
||||
let mut config = mysql_config("", "", None);
|
||||
config.db_type = DatabaseType::ZooKeeper;
|
||||
config.host = "zk.local".to_string();
|
||||
config.port = 2181;
|
||||
|
||||
assert_eq!(config.connection_url_with_host("zk.local", 2181), "zookeeper://zk.local:2181");
|
||||
|
||||
config.username = "digest".to_string();
|
||||
config.password = "secret".to_string();
|
||||
|
||||
assert_eq!(config.connection_url_with_host("zk.local", 2181), "zookeeper://digest:secret@zk.local:2181");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_single_ssh_config_migrates_to_transport_layer() {
|
||||
let config: ConnectionConfig = serde_json::from_value(serde_json::json!({
|
||||
|
||||
@@ -112,6 +112,7 @@ fn maps_agent_database_types_to_driver_keys() {
|
||||
assert_eq!(agent_key(&DatabaseType::Oracle, None), Some("oracle"));
|
||||
assert_eq!(agent_key(&DatabaseType::Databend, None), Some("databend"));
|
||||
assert_eq!(agent_key(&DatabaseType::InfluxDb, None), Some("influxdb"));
|
||||
assert_eq!(agent_key(&DatabaseType::ZooKeeper, None), Some("zookeeper"));
|
||||
assert_eq!(agent_key(&DatabaseType::Oracle, Some("oracle-legacy")), Some("oracle"));
|
||||
assert_eq!(agent_key(&DatabaseType::Oracle, Some("oracle-10g")), Some("oracle"));
|
||||
assert_eq!(agent_key(&DatabaseType::Postgres, None), None);
|
||||
@@ -136,6 +137,7 @@ fn classifies_agent_database_types() {
|
||||
assert!(is_agent_type(&DatabaseType::Access));
|
||||
assert!(is_agent_type(&DatabaseType::Databend));
|
||||
assert!(is_agent_type(&DatabaseType::InfluxDb));
|
||||
assert!(is_agent_type(&DatabaseType::ZooKeeper));
|
||||
assert!(!is_agent_type(&DatabaseType::Mysql));
|
||||
assert!(!is_agent_type(&DatabaseType::Jdbc));
|
||||
assert!(!is_agent_type(&DatabaseType::Gaussdb));
|
||||
@@ -189,6 +191,7 @@ fn skips_tcp_probe_for_local_file_plugin_and_agent_types() {
|
||||
assert!(skips_tcp_probe(&DatabaseType::Databend));
|
||||
assert!(skips_tcp_probe(&DatabaseType::InfluxDb));
|
||||
assert!(skips_tcp_probe(&DatabaseType::MessageQueue));
|
||||
assert!(skips_tcp_probe(&DatabaseType::ZooKeeper));
|
||||
assert!(!skips_tcp_probe(&DatabaseType::Postgres));
|
||||
assert!(!skips_tcp_probe(&DatabaseType::Mysql));
|
||||
assert!(!skips_tcp_probe(&DatabaseType::Gaussdb));
|
||||
@@ -298,4 +301,13 @@ fn driver_manifest_declares_expected_product_capabilities() {
|
||||
assert_eq!(redis.support_level, "connect");
|
||||
assert!(!redis.capabilities.object_browser);
|
||||
assert!(!redis.capabilities.sql_file_execution);
|
||||
|
||||
let zookeeper = find_driver(DatabaseType::ZooKeeper);
|
||||
assert_eq!(zookeeper.label, "Apache ZooKeeper");
|
||||
assert_eq!(zookeeper.runtime_mode, "agent");
|
||||
assert_eq!(zookeeper.agent_key.as_deref(), Some("zookeeper"));
|
||||
assert_eq!(zookeeper.support_level, "connect");
|
||||
assert!(zookeeper.capabilities.query_execution);
|
||||
assert!(zookeeper.capabilities.driver_management);
|
||||
assert!(!zookeeper.capabilities.metadata_browse);
|
||||
}
|
||||
|
||||
@@ -335,6 +335,11 @@ async fn main() {
|
||||
.route("/etcd/get", post(routes::etcd::get))
|
||||
.route("/etcd/put", post(routes::etcd::put))
|
||||
.route("/etcd/delete", post(routes::etcd::delete))
|
||||
// ZooKeeper
|
||||
.route("/zookeeper/list-prefix", post(routes::zookeeper::list_prefix))
|
||||
.route("/zookeeper/get", post(routes::zookeeper::get))
|
||||
.route("/zookeeper/put", post(routes::zookeeper::put))
|
||||
.route("/zookeeper/delete", post(routes::zookeeper::delete))
|
||||
// Nacos
|
||||
.route("/nacos/test-connection", post(routes::nacos::test_connection))
|
||||
.route("/nacos/namespaces/list", post(routes::nacos::list_namespaces))
|
||||
|
||||
@@ -29,3 +29,4 @@ pub mod table_import;
|
||||
pub mod text_export;
|
||||
pub mod transfer;
|
||||
pub mod update;
|
||||
pub mod zookeeper;
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::extract::State;
|
||||
use axum::Json;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::AppError;
|
||||
use crate::state::WebState;
|
||||
|
||||
async fn ensure_writable(
|
||||
app: &dbx_core::connection::AppState,
|
||||
connection_id: &str,
|
||||
action: &str,
|
||||
) -> Result<(), AppError> {
|
||||
if let Some(name) = dbx_core::query::connection_readonly_name(app, connection_id).await {
|
||||
return Err(AppError(format!(
|
||||
"Read-only mode: connection '{}' has read-only protection enabled. {} blocked.",
|
||||
name, action
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ZooKeeperListPrefixRequest {
|
||||
pub connection_id: String,
|
||||
pub prefix: String,
|
||||
pub limit: usize,
|
||||
pub continuation: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ZooKeeperKeyRequest {
|
||||
pub connection_id: String,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ZooKeeperPutRequest {
|
||||
pub connection_id: String,
|
||||
pub key: String,
|
||||
pub value: dbx_core::agent_kv::KvValue,
|
||||
pub options: Option<dbx_core::agent_kv::KvPutOptions>,
|
||||
}
|
||||
|
||||
pub async fn list_prefix(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<ZooKeeperListPrefixRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvListPrefixResponse>, AppError> {
|
||||
let result = dbx_core::agent_kv::kv_list_prefix_core(
|
||||
&state.app,
|
||||
&req.connection_id,
|
||||
&req.prefix,
|
||||
req.limit,
|
||||
req.continuation.as_deref(),
|
||||
)
|
||||
.await
|
||||
.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<ZooKeeperKeyRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvGetResponse>, AppError> {
|
||||
let result = dbx_core::agent_kv::kv_get_core(&state.app, &req.connection_id, &req.key).await.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn put(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<ZooKeeperPutRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvPutResponse>, AppError> {
|
||||
ensure_writable(&state.app, &req.connection_id, "Put").await?;
|
||||
let result = dbx_core::agent_kv::kv_put_core_with_options(
|
||||
&state.app,
|
||||
&req.connection_id,
|
||||
&req.key,
|
||||
req.value,
|
||||
req.options.unwrap_or_default(),
|
||||
)
|
||||
.await
|
||||
.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn delete(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<ZooKeeperKeyRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvDeleteResponse>, AppError> {
|
||||
ensure_writable(&state.app, &req.connection_id, "Delete").await?;
|
||||
let result =
|
||||
dbx_core::agent_kv::kv_delete_core(&state.app, &req.connection_id, &req.key).await.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "vitest";
|
||||
import { buildDraftVisibleDatabasesConnectionId, visibleDatabaseSelectionIsStale, initialVisibleDatabaseSelection } from "../../apps/desktop/src/lib/connectionVisibleDatabases.ts";
|
||||
import { buildDraftVisibleDatabasesConnectionId, connectionCanChooseVisibleDatabases, visibleDatabaseSelectionIsStale, initialVisibleDatabaseSelection } from "../../apps/desktop/src/lib/connectionVisibleDatabases.ts";
|
||||
import type { ConnectionConfig } from "../../apps/desktop/src/types/database.ts";
|
||||
|
||||
function config(overrides: Partial<ConnectionConfig> = {}): ConnectionConfig {
|
||||
@@ -48,6 +48,10 @@ test("initial selection uses default visible database names when no filter is co
|
||||
assert.deepEqual(initialVisibleDatabaseSelection(["app", "mysql", "sys"], undefined, config()), ["app"]);
|
||||
});
|
||||
|
||||
test("ZooKeeper connections do not offer visible database selection", () => {
|
||||
assert.equal(connectionCanChooseVisibleDatabases(config({ db_type: "zookeeper" })), false);
|
||||
});
|
||||
|
||||
test("visible database selection is stale when connection target changes", () => {
|
||||
const previous = config({ host: "db.internal", visible_databases: ["app"] });
|
||||
assert.equal(visibleDatabaseSelectionIsStale(previous, config({ host: "db.internal" })), false);
|
||||
|
||||
@@ -86,6 +86,30 @@ test("MQ tabs with a selected tenant target the matching tenant node", () => {
|
||||
assert.equal(findSidebarNodeForActiveTab(tab, [flat(tenant)])?.id, "tenant-node");
|
||||
});
|
||||
|
||||
test("ZooKeeper tabs target the matching visible zookeeper root node", () => {
|
||||
const tab: QueryTab = {
|
||||
id: "tab-1",
|
||||
title: "ZooKeeper Keys",
|
||||
connectionId: "conn-1",
|
||||
database: "",
|
||||
sql: "",
|
||||
isExecuting: false,
|
||||
mode: "zookeeper",
|
||||
};
|
||||
const root: TreeNode = {
|
||||
id: "zookeeper-root",
|
||||
label: "Keys",
|
||||
type: "zookeeper-root",
|
||||
connectionId: "conn-1",
|
||||
};
|
||||
|
||||
assert.deepEqual(activeTabSidebarTarget(tab), {
|
||||
type: "zookeeper-root",
|
||||
connectionId: "conn-1",
|
||||
});
|
||||
assert.equal(findSidebarNodeForActiveTab(tab, [flat(root)])?.id, "zookeeper-root");
|
||||
});
|
||||
|
||||
test("Nacos tabs target the matching namespace node", () => {
|
||||
const tab: QueryTab = {
|
||||
id: "tab-1",
|
||||
|
||||
@@ -5,3 +5,7 @@ import { canTreeNodeShowExpander } from "../../apps/desktop/src/lib/sidebarTreeI
|
||||
test("mongodb collection rows can show an expander for metadata groups", () => {
|
||||
assert.equal(canTreeNodeShowExpander({ type: "mongo-collection", childCount: 0 }), true);
|
||||
});
|
||||
|
||||
test("ZooKeeper root rows do not show an empty expander", () => {
|
||||
assert.equal(canTreeNodeShowExpander({ type: "zookeeper-root", childCount: 0 }), false);
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
resultGridCacheKey,
|
||||
resultRunItems,
|
||||
tabDisplayTitle,
|
||||
tabModeLabel,
|
||||
tabularResultItems,
|
||||
} from "../../apps/desktop/src/lib/tabPresentation.ts";
|
||||
import { useConnectionStore } from "../../apps/desktop/src/stores/connectionStore.ts";
|
||||
@@ -113,6 +114,26 @@ test("jdbc tabs use the connection target when database is empty", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("zookeeper tabs use key browser labels", () => {
|
||||
const restoreStorage = installMemoryStorage();
|
||||
setActivePinia(createPinia());
|
||||
useConnectionStore().addEphemeralConnection({
|
||||
...conn("conn-1"),
|
||||
name: "ZK Prod",
|
||||
db_type: "zookeeper",
|
||||
port: 2181,
|
||||
});
|
||||
const t = (key: string) => (key === "tabs.zookeeper" ? "ZooKeeper" : key);
|
||||
|
||||
try {
|
||||
const tab = queryTab({ mode: "zookeeper", database: "", title: "ZooKeeper Keys" });
|
||||
assert.equal(tabDisplayTitle(tab, t), "ZK Prod@keys");
|
||||
assert.equal(tabModeLabel(tab, t), "ZooKeeper");
|
||||
} finally {
|
||||
restoreStorage();
|
||||
}
|
||||
});
|
||||
|
||||
test("tabular result items hide statement results without returned columns", () => {
|
||||
const results = [result([]), result(["id"]), result([]), result(["name"])];
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ test("double click navigation mode toggles expandable rows on double click", ()
|
||||
assert.equal(treeNodeRowDoubleClickAction("connection", false, "double", true), "toggle");
|
||||
assert.equal(treeNodeRowDoubleClickAction("group-columns", false, "double", true), "toggle");
|
||||
assert.equal(treeNodeRowDoubleClickAction("redis-db", false, "double", false), "toggle");
|
||||
assert.equal(treeNodeRowDoubleClickAction("etcd-root", false, "double", false), "toggle");
|
||||
assert.equal(treeNodeRowDoubleClickAction("zookeeper-root", false, "double", false), "toggle");
|
||||
});
|
||||
|
||||
test("expandable non-table rows still toggle from row clicks", () => {
|
||||
@@ -36,6 +38,8 @@ test("expandable non-table rows still toggle from row clicks", () => {
|
||||
|
||||
test("leaf data browser nodes keep their open behavior through toggle handler", () => {
|
||||
assert.equal(treeNodeRowAction("redis-db", false), "toggle");
|
||||
assert.equal(treeNodeRowAction("etcd-root", false), "toggle");
|
||||
assert.equal(treeNodeRowAction("zookeeper-root", false), "toggle");
|
||||
assert.equal(treeNodeRowAction("mongo-collection", false), "toggle");
|
||||
});
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ export const BRIDGE_REQUIRED_TYPES = [
|
||||
"jdbc",
|
||||
"access",
|
||||
"influxdb",
|
||||
"zookeeper",
|
||||
] as const;
|
||||
|
||||
export interface DbxDiagnostics {
|
||||
|
||||
@@ -41,3 +41,4 @@ pub mod text_export;
|
||||
pub mod transfer;
|
||||
pub mod update;
|
||||
pub mod xlsx_export;
|
||||
pub mod zookeeper_cmd;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use crate::commands::connection::{ensure_connection_writable, AppState};
|
||||
use dbx_core::agent_kv::{KvDeleteResponse, KvGetResponse, KvListPrefixResponse, KvPutOptions, KvPutResponse, KvValue};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zookeeper_list_prefix(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
connection_id: String,
|
||||
prefix: String,
|
||||
limit: usize,
|
||||
continuation: Option<String>,
|
||||
) -> Result<KvListPrefixResponse, String> {
|
||||
dbx_core::agent_kv::kv_list_prefix_core(&state, &connection_id, &prefix, limit, continuation.as_deref()).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zookeeper_get(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
connection_id: String,
|
||||
key: String,
|
||||
) -> Result<KvGetResponse, String> {
|
||||
dbx_core::agent_kv::kv_get_core(&state, &connection_id, &key).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zookeeper_put(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
connection_id: String,
|
||||
key: String,
|
||||
value: KvValue,
|
||||
options: Option<KvPutOptions>,
|
||||
) -> Result<KvPutResponse, String> {
|
||||
ensure_connection_writable(&state, &connection_id, "Put").await?;
|
||||
dbx_core::agent_kv::kv_put_core_with_options(&state, &connection_id, &key, value, options.unwrap_or_default()).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zookeeper_delete(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
connection_id: String,
|
||||
key: String,
|
||||
) -> Result<KvDeleteResponse, String> {
|
||||
ensure_connection_writable(&state, &connection_id, "Delete").await?;
|
||||
dbx_core::agent_kv::kv_delete_core(&state, &connection_id, &key).await
|
||||
}
|
||||
@@ -574,6 +574,10 @@ pub fn run() {
|
||||
commands::etcd_cmd::etcd_get,
|
||||
commands::etcd_cmd::etcd_put,
|
||||
commands::etcd_cmd::etcd_delete,
|
||||
commands::zookeeper_cmd::zookeeper_list_prefix,
|
||||
commands::zookeeper_cmd::zookeeper_get,
|
||||
commands::zookeeper_cmd::zookeeper_put,
|
||||
commands::zookeeper_cmd::zookeeper_delete,
|
||||
commands::nacos_cmd::nacos_test_connection,
|
||||
commands::nacos_cmd::nacos_list_namespaces,
|
||||
commands::nacos_cmd::nacos_create_namespace,
|
||||
|
||||
Reference in New Issue
Block a user