fix(docs): update offline driver downloads
This commit is contained in:
@@ -3,15 +3,19 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { LandingNav } from "@/components/landing/LandingNav";
|
||||
import { buildDriverEntries, buildJreEntries, fetchAgentRegistry, formatSize, type AgentRegistry, type JreDisplayEntry } from "@/lib/agentRegistry";
|
||||
import { AlertTriangle, Cpu, Database, Download, Loader2, Search, X } from "lucide-react";
|
||||
import { fetchAgentDownloadCatalog, formatSize, type AgentDownloadCatalog, type JreDisplayEntry, type NativeAgentDisplayEntry, type OfflineBundleEntry } from "@/lib/agentRegistry";
|
||||
import { AlertTriangle, Archive, Cpu, Database, Download, Loader2, Search, Terminal, X } from "lucide-react";
|
||||
|
||||
const i18n = {
|
||||
en: {
|
||||
title: "Offline Driver Downloads",
|
||||
subtitle: "Download database drivers and JRE packages for offline use. Search for the exact resource your air-gapped environment needs.",
|
||||
bundles: "Offline Bundles",
|
||||
bundlesDesc: "Platform-specific ZIP packages that include the agent registry, database drivers, native agents, and the matching JRE.",
|
||||
drivers: "Database Drivers",
|
||||
driversDesc: "JDBC driver JAR files for each supported database type.",
|
||||
nativeAgents: "Native Agents",
|
||||
nativeAgentsDesc: "Go-based native agents for Oracle and XuguDB. Download the executable that matches the offline machine.",
|
||||
jre: "Java Runtime (JRE)",
|
||||
jreDesc: "JRE packages used by agent-based database drivers. Required for Oracle, SQL Server, and other agent-managed connections.",
|
||||
loading: "Loading driver catalog...",
|
||||
@@ -22,18 +26,23 @@ const i18n = {
|
||||
size: "Size",
|
||||
requiresJre: "Requires JRE",
|
||||
platform: "Platform",
|
||||
filename: "File",
|
||||
search: "Search drivers, platforms, versions...",
|
||||
noResults: "No matching downloads.",
|
||||
showing: "Showing",
|
||||
of: "of",
|
||||
clearSearch: "Clear search",
|
||||
downloadHint: "For air-gapped environments: download these files on an internet-connected machine, then transfer them to the offline machine and import them in DBX from Settings > Driver Manager.",
|
||||
downloadHint: "For air-gapped environments: download the bundle for your platform on an internet-connected machine, then transfer it to the offline machine and import it in DBX from Settings > Driver Manager. Use the driver and JRE tabs only when you need individual artifacts.",
|
||||
},
|
||||
cn: {
|
||||
title: "离线驱动下载",
|
||||
subtitle: "下载数据库驱动和 JRE 离线包。搜索内网环境需要的资源,在有网机器下载后传输。",
|
||||
bundles: "整包下载",
|
||||
bundlesDesc: "按平台提供的 ZIP 离线包,包含 Agent registry、数据库驱动、原生 Agent 和匹配的 JRE。",
|
||||
drivers: "数据库驱动",
|
||||
driversDesc: "每种支持的数据库类型对应的 JDBC 驱动 JAR 文件。",
|
||||
nativeAgents: "原生 Agent",
|
||||
nativeAgentsDesc: "Oracle 和虚谷使用 Go 原生 Agent,请下载与内网机器平台匹配的可执行文件。",
|
||||
jre: "Java 运行时 (JRE)",
|
||||
jreDesc: "Agent 驱动所需的 JRE 环境,Oracle、SQL Server 等数据库通过 Agent 连接时需要。",
|
||||
loading: "正在加载驱动列表...",
|
||||
@@ -44,21 +53,37 @@ const i18n = {
|
||||
size: "大小",
|
||||
requiresJre: "依赖 JRE",
|
||||
platform: "平台",
|
||||
filename: "文件",
|
||||
search: "搜索驱动、平台、版本...",
|
||||
noResults: "没有匹配的下载项。",
|
||||
showing: "显示",
|
||||
of: "/",
|
||||
clearSearch: "清空搜索",
|
||||
downloadHint: "内网环境使用说明:在有网的电脑上下载这些文件,然后传输到内网机器,在 DBX 的“设置 > 驱动管理”中导入。",
|
||||
downloadHint: "内网环境使用说明:在有网的电脑上下载对应平台的整包,然后传输到内网机器,在 DBX 的“设置 > 驱动管理”中导入。只有需要单个产物时再使用驱动和 JRE 标签页。",
|
||||
},
|
||||
};
|
||||
|
||||
type ActiveTab = "drivers" | "jre";
|
||||
type ActiveTab = "bundles" | "drivers" | "native" | "jre";
|
||||
|
||||
function platformKey(j: JreDisplayEntry): string {
|
||||
return `${j.jreKey}-${j.platformKey}`;
|
||||
}
|
||||
|
||||
function bundleKey(bundle: OfflineBundleEntry): string {
|
||||
return `${bundle.platformKey}-${bundle.filename}`;
|
||||
}
|
||||
|
||||
function nativeKey(agent: NativeAgentDisplayEntry): string {
|
||||
return `${agent.key}-${agent.platformKey}`;
|
||||
}
|
||||
|
||||
type NativeAgentGroup = {
|
||||
key: string;
|
||||
label: string;
|
||||
version: string;
|
||||
options: NativeAgentDisplayEntry[];
|
||||
};
|
||||
|
||||
function matchesSearch(values: Array<string | number | undefined>, query: string): boolean {
|
||||
if (!query) return true;
|
||||
return values.filter(Boolean).join(" ").toLowerCase().includes(query);
|
||||
@@ -70,19 +95,20 @@ export function DriversClient() {
|
||||
const lang: "en" | "cn" = rawLang === "cn" ? "cn" : "en";
|
||||
const t = i18n[lang];
|
||||
|
||||
const [registry, setRegistry] = useState<AgentRegistry | null>(null);
|
||||
const [catalog, setCatalog] = useState<AgentDownloadCatalog | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [activeTab, setActiveTab] = useState<ActiveTab>("drivers");
|
||||
const [activeTab, setActiveTab] = useState<ActiveTab>("bundles");
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [selectedNativePlatforms, setSelectedNativePlatforms] = useState<Record<string, string>>({});
|
||||
|
||||
const loadRegistry = useCallback(async () => {
|
||||
const loadCatalog = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const data = await fetchAgentRegistry();
|
||||
const data = await fetchAgentDownloadCatalog();
|
||||
if (data) {
|
||||
setRegistry(data);
|
||||
setCatalog(data);
|
||||
} else {
|
||||
setError("Unable to load driver catalog");
|
||||
}
|
||||
@@ -94,19 +120,68 @@ export function DriversClient() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadRegistry();
|
||||
}, [loadRegistry]);
|
||||
loadCatalog();
|
||||
}, [loadCatalog]);
|
||||
|
||||
const drivers = useMemo(() => (registry ? buildDriverEntries(registry) : []), [registry]);
|
||||
const jres = useMemo(() => (registry ? buildJreEntries(registry) : []), [registry]);
|
||||
const bundles = catalog?.bundles ?? [];
|
||||
const drivers = catalog?.drivers ?? [];
|
||||
const nativeAgents = catalog?.nativeAgents ?? [];
|
||||
const jres = catalog?.jres ?? [];
|
||||
const normalizedSearch = searchQuery.trim().toLowerCase();
|
||||
|
||||
const filteredBundles = useMemo(() => bundles.filter((bundle) => matchesSearch([bundle.platformLabel, bundle.platformKey, bundle.filename, formatSize(bundle.size)], normalizedSearch)), [bundles, normalizedSearch]);
|
||||
|
||||
const filteredDrivers = useMemo(() => drivers.filter((d) => matchesSearch([d.label, d.key, d.version, d.jre, formatSize(d.jar.size)], normalizedSearch)), [drivers, normalizedSearch]);
|
||||
|
||||
const nativeGroups = useMemo(() => {
|
||||
const groups = new Map<string, NativeAgentGroup>();
|
||||
for (const agent of nativeAgents) {
|
||||
const group = groups.get(agent.key);
|
||||
if (group) {
|
||||
group.options.push(agent);
|
||||
} else {
|
||||
groups.set(agent.key, { key: agent.key, label: agent.label, version: agent.version, options: [agent] });
|
||||
}
|
||||
}
|
||||
return Array.from(groups.values());
|
||||
}, [nativeAgents]);
|
||||
|
||||
useEffect(() => {
|
||||
if (nativeGroups.length === 0) return;
|
||||
setSelectedNativePlatforms((current) => {
|
||||
const next = { ...current };
|
||||
let changed = false;
|
||||
for (const group of nativeGroups) {
|
||||
if (group.options.length === 0) continue;
|
||||
if (!next[group.key] || !group.options.some((option) => option.platformKey === next[group.key])) {
|
||||
next[group.key] = group.options[0].platformKey;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed ? next : current;
|
||||
});
|
||||
}, [nativeGroups]);
|
||||
|
||||
const filteredNativeGroups = useMemo(
|
||||
() =>
|
||||
nativeGroups.filter((group) =>
|
||||
matchesSearch(
|
||||
[
|
||||
group.label,
|
||||
group.key,
|
||||
group.version,
|
||||
...group.options.flatMap((option) => [option.platformLabel, option.platformKey, option.filename, formatSize(option.info.size)]),
|
||||
],
|
||||
normalizedSearch,
|
||||
),
|
||||
),
|
||||
[nativeGroups, normalizedSearch],
|
||||
);
|
||||
|
||||
const filteredJres = useMemo(() => jres.filter((j) => matchesSearch([j.platformLabel, j.platformKey, j.jreVersion, j.jreKey, formatSize(j.info.size)], normalizedSearch)), [jres, normalizedSearch]);
|
||||
|
||||
const activeCount = activeTab === "drivers" ? filteredDrivers.length : filteredJres.length;
|
||||
const activeTotal = activeTab === "drivers" ? drivers.length : jres.length;
|
||||
const activeCount = activeTab === "bundles" ? filteredBundles.length : activeTab === "drivers" ? filteredDrivers.length : activeTab === "native" ? filteredNativeGroups.length : filteredJres.length;
|
||||
const activeTotal = activeTab === "bundles" ? bundles.length : activeTab === "drivers" ? drivers.length : activeTab === "native" ? nativeGroups.length : jres.length;
|
||||
|
||||
return (
|
||||
<main className="landing">
|
||||
@@ -132,26 +207,38 @@ export function DriversClient() {
|
||||
<div className="flex flex-col items-center gap-4 py-20">
|
||||
<AlertTriangle size={28} className="text-yellow-500" />
|
||||
<span className="text-landing-muted text-sm">{t.error}</span>
|
||||
<button type="button" onClick={loadRegistry} className="landing-nav-link rounded-[7px] px-4 py-2 text-sm font-medium border border-landing-line">
|
||||
<button type="button" onClick={loadCatalog} className="landing-nav-link rounded-[7px] px-4 py-2 text-sm font-medium border border-landing-line">
|
||||
{t.retry}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{registry && !loading && (
|
||||
{catalog && !loading && (
|
||||
<>
|
||||
<div className="landing-glass-card mb-12 overflow-hidden rounded-[10px]">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-landing-line bg-landing-panel/70 p-3">
|
||||
<div className="inline-flex shrink-0 rounded-[8px] border border-landing-line bg-black/10 p-1">
|
||||
<div className="inline-flex shrink-0 rounded-[8px] border border-landing-line bg-black/10 p-1 max-[760px]:grid max-[760px]:w-full max-[760px]:grid-cols-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab("bundles")}
|
||||
className={`inline-flex h-8 cursor-pointer items-center justify-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "bundles" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}
|
||||
>
|
||||
<Archive size={14} />
|
||||
{t.bundles}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab("drivers")}
|
||||
className={`inline-flex h-8 cursor-pointer items-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "drivers" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}
|
||||
className={`inline-flex h-8 cursor-pointer items-center justify-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "drivers" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}
|
||||
>
|
||||
<Database size={14} />
|
||||
{t.drivers}
|
||||
</button>
|
||||
<button type="button" onClick={() => setActiveTab("jre")} className={`inline-flex h-8 cursor-pointer items-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "jre" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}>
|
||||
<button type="button" onClick={() => setActiveTab("native")} className={`inline-flex h-8 cursor-pointer items-center justify-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "native" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}>
|
||||
<Terminal size={14} />
|
||||
{t.nativeAgents}
|
||||
</button>
|
||||
<button type="button" onClick={() => setActiveTab("jre")} className={`inline-flex h-8 cursor-pointer items-center justify-center gap-2 rounded-[6px] px-3 text-xs font-[650] transition-colors ${activeTab === "jre" ? "bg-landing-blue text-white" : "text-landing-muted hover:text-landing-ink"}`}>
|
||||
<Cpu size={14} />
|
||||
{t.jre}
|
||||
</button>
|
||||
@@ -178,6 +265,43 @@ export function DriversClient() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activeTab === "bundles" && (
|
||||
<>
|
||||
<p className="border-b border-landing-line px-5 py-3 text-sm text-landing-muted whitespace-nowrap max-[760px]:whitespace-normal max-[760px]:px-4">{t.bundlesDesc}</p>
|
||||
<table className="w-full table-auto border-collapse text-sm max-[760px]:block">
|
||||
<thead className="bg-landing-panel text-xs font-medium text-landing-muted max-[760px]:hidden">
|
||||
<tr className="border-b border-landing-line">
|
||||
<th className="px-5 py-2.5 text-left font-medium">{t.platform}</th>
|
||||
<th className="px-5 py-2.5 text-left font-medium">{t.filename}</th>
|
||||
<th className="px-5 py-2.5 text-right font-medium">{t.size}</th>
|
||||
<th className="w-24 px-5 py-2.5" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="max-[760px]:block">
|
||||
{filteredBundles.map((bundle) => (
|
||||
<tr key={bundleKey(bundle)} className="border-b border-landing-line transition-colors last:border-b-0 hover:bg-landing-panel max-[760px]:grid max-[760px]:grid-cols-[1fr_auto] max-[760px]:items-center max-[760px]:gap-3 max-[760px]:px-4">
|
||||
<td className="min-w-0 px-5 py-3 font-medium text-landing-ink max-[760px]:px-0">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="min-w-0 truncate">{bundle.platformLabel}</span>
|
||||
<span className="hidden shrink-0 rounded-[5px] border border-landing-blue/35 bg-landing-blue/10 px-1.5 py-0.5 font-mono text-[11px] text-landing-sky max-[760px]:inline">ZIP</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-5 py-3 font-mono text-[11px] text-landing-muted max-[760px]:hidden">{bundle.filename}</td>
|
||||
<td className="px-5 py-3 text-right text-xs text-landing-muted max-[760px]:hidden">{formatSize(bundle.size)}</td>
|
||||
<td className="px-5 py-3 text-right max-[760px]:px-0">
|
||||
<a href={bundle.url} download className="landing-nav-link inline-flex h-8 items-center gap-1 whitespace-nowrap rounded-[6px] border border-landing-line px-2.5 text-xs font-medium transition-colors hover:border-landing-blue">
|
||||
<Download size={13} />
|
||||
{t.download}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{filteredBundles.length === 0 && <div className="px-5 py-12 text-center text-sm text-landing-muted">{t.noResults}</div>}
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === "drivers" && (
|
||||
<>
|
||||
<p className="border-b border-landing-line px-5 py-3 text-sm text-landing-muted whitespace-nowrap max-[760px]:whitespace-normal max-[760px]:px-4">{t.driversDesc}</p>
|
||||
@@ -221,6 +345,62 @@ export function DriversClient() {
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === "native" && (
|
||||
<>
|
||||
<p className="border-b border-landing-line px-5 py-3 text-sm text-landing-muted whitespace-nowrap max-[760px]:whitespace-normal max-[760px]:px-4">{t.nativeAgentsDesc}</p>
|
||||
<table className="w-full table-auto border-collapse text-sm max-[760px]:block">
|
||||
<thead className="bg-landing-panel text-xs font-medium text-landing-muted max-[760px]:hidden">
|
||||
<tr className="border-b border-landing-line">
|
||||
<th className="px-5 py-2.5 text-left font-medium">Agent</th>
|
||||
<th className="px-5 py-2.5 text-left font-medium">{t.platform}</th>
|
||||
<th className="px-5 py-2.5 text-left font-medium">{t.version}</th>
|
||||
<th className="px-5 py-2.5 text-right font-medium">{t.size}</th>
|
||||
<th className="w-24 px-5 py-2.5" />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="max-[760px]:block">
|
||||
{filteredNativeGroups.map((group) => {
|
||||
const selectedPlatform = selectedNativePlatforms[group.key] ?? group.options[0]?.platformKey;
|
||||
const selectedAgent = group.options.find((option) => option.platformKey === selectedPlatform) ?? group.options[0];
|
||||
if (!selectedAgent) return null;
|
||||
return (
|
||||
<tr key={group.key} className="border-b border-landing-line transition-colors last:border-b-0 hover:bg-landing-panel max-[760px]:grid max-[760px]:grid-cols-[1fr_auto] max-[760px]:items-center max-[760px]:gap-3 max-[760px]:px-4">
|
||||
<td className="min-w-0 px-5 py-3 font-medium text-landing-ink max-[760px]:px-0">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="min-w-0 truncate">{group.label}</span>
|
||||
<span className="hidden shrink-0 rounded-[5px] border border-landing-blue/35 bg-landing-blue/10 px-1.5 py-0.5 font-mono text-[11px] text-landing-sky max-[760px]:inline">{selectedAgent.platformKey}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-5 py-3 max-[760px]:col-span-2 max-[760px]:px-0 max-[760px]:pt-0">
|
||||
<select
|
||||
value={selectedAgent.platformKey}
|
||||
onChange={(event) => setSelectedNativePlatforms((current) => ({ ...current, [group.key]: event.target.value }))}
|
||||
className="h-8 min-w-[190px] rounded-[6px] border border-landing-line bg-black/10 px-2.5 text-xs text-landing-ink outline-none transition-colors focus:border-landing-blue max-[760px]:w-full"
|
||||
>
|
||||
{group.options.map((option) => (
|
||||
<option key={nativeKey(option)} value={option.platformKey} className="bg-[#10151d] text-landing-ink">
|
||||
{option.platformLabel}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</td>
|
||||
<td className="px-5 py-3 text-xs text-landing-muted max-[760px]:hidden">{group.version}</td>
|
||||
<td className="px-5 py-3 text-right text-xs text-landing-muted max-[760px]:hidden">{formatSize(selectedAgent.info.size)}</td>
|
||||
<td className="px-5 py-3 text-right max-[760px]:px-0">
|
||||
<a href={selectedAgent.info.url} download className="landing-nav-link inline-flex h-8 items-center gap-1 whitespace-nowrap rounded-[6px] border border-landing-line px-2.5 text-xs font-medium transition-colors hover:border-landing-blue">
|
||||
<Download size={13} />
|
||||
{t.download}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
{filteredNativeGroups.length === 0 && <div className="px-5 py-12 text-center text-sm text-landing-muted">{t.noResults}</div>}
|
||||
</>
|
||||
)}
|
||||
|
||||
{activeTab === "jre" && (
|
||||
<>
|
||||
<p className="border-b border-landing-line px-5 py-3 text-sm text-landing-muted whitespace-nowrap max-[760px]:whitespace-normal max-[760px]:px-4">{t.jreDesc}</p>
|
||||
|
||||
@@ -5,11 +5,11 @@ import type { Metadata } from "next";
|
||||
const pageMeta = {
|
||||
en: {
|
||||
title: "Offline Driver Downloads",
|
||||
description: "Download all database drivers and JRE packages for offline use. Supports 30+ database types across macOS, Linux, and Windows.",
|
||||
description: "Download DBX offline driver bundles, database drivers, and JRE packages for air-gapped environments across macOS, Linux, and Windows.",
|
||||
},
|
||||
cn: {
|
||||
title: "离线驱动下载",
|
||||
description: "下载所有数据库驱动和 JRE 离线包,支持 30+ 种数据库类型,覆盖 macOS、Linux、Windows 平台。",
|
||||
description: "下载 DBX 离线驱动整包、数据库驱动和 JRE 离线包,覆盖 macOS、Linux、Windows 平台。",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -91,6 +91,12 @@ article {
|
||||
color: color-mix(in srgb, var(--color-fd-foreground) 92%, var(--color-fd-muted-foreground));
|
||||
}
|
||||
|
||||
article,
|
||||
article :where(h1, h2, h3, h4, h5, h6, p, li, blockquote, table, th, td, pre, code, span, strong, em) {
|
||||
-webkit-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
article h1 {
|
||||
letter-spacing: 0;
|
||||
line-height: 1.08;
|
||||
|
||||
+205
-94
@@ -1,57 +1,26 @@
|
||||
const R2_CDN_BASE = "https://dl.dbxio.com";
|
||||
|
||||
function filenameFromUrl(url: string): string {
|
||||
return url.split("/").pop() ?? url;
|
||||
}
|
||||
|
||||
function githubUrlToR2Url(url: string, category: "jre" | "driver"): string {
|
||||
const filename = filenameFromUrl(url);
|
||||
return `${R2_CDN_BASE}/agents/${category}/${filename}`;
|
||||
}
|
||||
import driverVersions from "../../agents/versions.json";
|
||||
|
||||
export interface ArtifactInfo {
|
||||
url: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface JreInfo {
|
||||
version: string;
|
||||
platforms: Record<string, ArtifactInfo>;
|
||||
export interface GitHubReleaseAsset {
|
||||
name: string;
|
||||
size: number;
|
||||
browser_download_url: string;
|
||||
}
|
||||
|
||||
export interface DriverInfo {
|
||||
version: string;
|
||||
label: string;
|
||||
min_app_version: string;
|
||||
jar: ArtifactInfo;
|
||||
jre: string;
|
||||
interface GitHubRelease {
|
||||
assets?: GitHubReleaseAsset[];
|
||||
}
|
||||
|
||||
export interface AgentRegistry {
|
||||
jre?: JreInfo;
|
||||
jres?: Record<string, JreInfo>;
|
||||
drivers: Record<string, DriverInfo>;
|
||||
}
|
||||
|
||||
const AGENT_REGISTRY_R2_URL = "https://dl.dbxio.com/agents/agent-registry.json";
|
||||
const AGENT_REGISTRY_GITHUB_URL = "https://github.com/t8y2/dbx/releases/download/agents-latest/agent-registry.json";
|
||||
|
||||
export async function fetchAgentRegistry(): Promise<AgentRegistry | null> {
|
||||
const urls = [AGENT_REGISTRY_R2_URL, AGENT_REGISTRY_GITHUB_URL];
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
cache: "no-store",
|
||||
headers: { Accept: "application/json" },
|
||||
});
|
||||
if (res.ok) {
|
||||
return (await res.json()) as AgentRegistry;
|
||||
}
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
export interface OfflineBundleEntry {
|
||||
platformKey: string;
|
||||
platformLabel: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface JreDisplayEntry {
|
||||
@@ -60,7 +29,6 @@ export interface JreDisplayEntry {
|
||||
info: ArtifactInfo;
|
||||
jreVersion: string;
|
||||
jreKey: string;
|
||||
r2Url: string;
|
||||
}
|
||||
|
||||
export interface DriverDisplayEntry {
|
||||
@@ -70,60 +38,203 @@ export interface DriverDisplayEntry {
|
||||
minAppVersion: string;
|
||||
jar: ArtifactInfo;
|
||||
jre: string;
|
||||
r2Url: string;
|
||||
}
|
||||
|
||||
export function buildJreEntries(registry: AgentRegistry): JreDisplayEntry[] {
|
||||
const entries: JreDisplayEntry[] = [];
|
||||
const platformLabels: Record<string, string> = {
|
||||
"macos-aarch64": "macOS (Apple Silicon)",
|
||||
"macos-x64": "macOS (Intel)",
|
||||
"linux-aarch64": "Linux (ARM64)",
|
||||
"linux-x64": "Linux (x64)",
|
||||
"windows-aarch64": "Windows (ARM64)",
|
||||
"windows-x64": "Windows (x64)",
|
||||
export interface NativeAgentDisplayEntry {
|
||||
key: string;
|
||||
label: string;
|
||||
version: string;
|
||||
platformKey: string;
|
||||
platformLabel: string;
|
||||
filename: string;
|
||||
info: ArtifactInfo;
|
||||
}
|
||||
|
||||
export interface AgentDownloadCatalog {
|
||||
bundles: OfflineBundleEntry[];
|
||||
drivers: DriverDisplayEntry[];
|
||||
jres: JreDisplayEntry[];
|
||||
nativeAgents: NativeAgentDisplayEntry[];
|
||||
}
|
||||
|
||||
const AGENTS_LATEST_RELEASE_API_URL = "https://api.github.com/repos/t8y2/dbx/releases/tags/agents-latest";
|
||||
const MIN_APP_VERSION = "0.6.0";
|
||||
const driverVersionMap = driverVersions as Record<string, string>;
|
||||
const nativeDriverKeys = new Set(["oracle", "xugu"]);
|
||||
|
||||
const platformLabels: Record<string, string> = {
|
||||
"macos-aarch64": "macOS (Apple Silicon)",
|
||||
"macos-x64": "macOS (Intel)",
|
||||
"linux-aarch64": "Linux (ARM64)",
|
||||
"linux-x64": "Linux (x64)",
|
||||
"windows-aarch64": "Windows (ARM64)",
|
||||
"windows-x64": "Windows (x64)",
|
||||
};
|
||||
|
||||
const driverLabels: Record<string, string> = {
|
||||
access: "Microsoft Access",
|
||||
bigquery: "BigQuery",
|
||||
cassandra: "Cassandra",
|
||||
dameng: "Dameng",
|
||||
databend: "Databend",
|
||||
databricks: "Databricks",
|
||||
db2: "DB2",
|
||||
etcd: "etcd",
|
||||
exasol: "Exasol",
|
||||
firebird: "Firebird",
|
||||
gbase8a: "GBase 8a",
|
||||
gbase8s: "GBase 8s",
|
||||
goldendb: "GoldenDB",
|
||||
h2: "H2",
|
||||
highgo: "HighGo",
|
||||
hive: "Hive",
|
||||
informix: "Informix",
|
||||
iotdb: "Apache IoTDB",
|
||||
iris: "InterSystems IRIS",
|
||||
kingbase: "KingBase",
|
||||
kylin: "Apache Kylin",
|
||||
mongodb: "MongoDB (Legacy)",
|
||||
neo4j: "Neo4j",
|
||||
"oceanbase-oracle": "OceanBase Oracle Mode",
|
||||
oracle: "Oracle",
|
||||
saphana: "SAP HANA",
|
||||
snowflake: "Snowflake",
|
||||
sundb: "SunDB",
|
||||
tdengine: "TDengine",
|
||||
teradata: "Teradata",
|
||||
trino: "Trino",
|
||||
vastbase: "Vastbase",
|
||||
vertica: "Vertica",
|
||||
xugu: "虚谷 XuguDB",
|
||||
yashandb: "YashanDB",
|
||||
zookeeper: "ZooKeeper",
|
||||
};
|
||||
|
||||
const currentDriverKeys = Object.keys(driverVersionMap).sort((a, b) => labelForDriver(a).localeCompare(labelForDriver(b)));
|
||||
const currentJavaDriverKeys = currentDriverKeys.filter((key) => !nativeDriverKeys.has(key));
|
||||
|
||||
const jreVersions: Record<string, string> = {
|
||||
"21": "21",
|
||||
};
|
||||
|
||||
function labelForDriver(key: string): string {
|
||||
return driverLabels[key] ?? key.replace(/-/g, " ");
|
||||
}
|
||||
|
||||
function assetInfo(asset: GitHubReleaseAsset): ArtifactInfo {
|
||||
return {
|
||||
url: asset.browser_download_url,
|
||||
size: asset.size,
|
||||
};
|
||||
|
||||
const jres = registry.jres ?? {};
|
||||
for (const [key, jreInfo] of Object.entries(jres)) {
|
||||
for (const [platformKey, artifact] of Object.entries(jreInfo.platforms)) {
|
||||
entries.push({
|
||||
platformKey,
|
||||
platformLabel: platformLabels[platformKey] ?? platformKey,
|
||||
info: artifact,
|
||||
jreVersion: jreInfo.version,
|
||||
jreKey: key,
|
||||
r2Url: githubUrlToR2Url(artifact.url, "jre"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (entries.length === 0 && registry.jre) {
|
||||
for (const [platformKey, artifact] of Object.entries(registry.jre.platforms)) {
|
||||
entries.push({
|
||||
platformKey,
|
||||
platformLabel: platformLabels[platformKey] ?? platformKey,
|
||||
info: artifact,
|
||||
jreVersion: registry.jre.version,
|
||||
jreKey: "21",
|
||||
r2Url: githubUrlToR2Url(artifact.url, "jre"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
export function buildDriverEntries(registry: AgentRegistry): DriverDisplayEntry[] {
|
||||
return Object.entries(registry.drivers).map(([key, info]) => ({
|
||||
key,
|
||||
label: info.label,
|
||||
version: info.version,
|
||||
minAppVersion: info.min_app_version,
|
||||
jar: info.jar,
|
||||
jre: info.jre,
|
||||
r2Url: githubUrlToR2Url(info.jar.url, "driver"),
|
||||
}));
|
||||
function assetMap(assets: GitHubReleaseAsset[]): Map<string, GitHubReleaseAsset> {
|
||||
return new Map(assets.map((asset) => [asset.name, asset]));
|
||||
}
|
||||
|
||||
export async function fetchAgentDownloadCatalog(): Promise<AgentDownloadCatalog | null> {
|
||||
try {
|
||||
const res = await fetch(AGENTS_LATEST_RELEASE_API_URL, {
|
||||
cache: "no-store",
|
||||
headers: { Accept: "application/vnd.github+json" },
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
|
||||
const release = (await res.json()) as GitHubRelease;
|
||||
return buildAgentDownloadCatalog(release.assets ?? []);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function buildAgentDownloadCatalog(assets: GitHubReleaseAsset[]): AgentDownloadCatalog {
|
||||
return {
|
||||
bundles: buildOfflineBundleEntries(assets),
|
||||
drivers: buildDriverEntries(assets),
|
||||
jres: buildJreEntries(assets),
|
||||
nativeAgents: buildNativeAgentEntries(assets),
|
||||
};
|
||||
}
|
||||
|
||||
export function buildJreEntries(assets: GitHubReleaseAsset[]): JreDisplayEntry[] {
|
||||
return assets
|
||||
.map((asset) => {
|
||||
const match = /^dbx-jre-(\d+)-(.+)\.tar\.gz$/.exec(asset.name);
|
||||
if (!match) return null;
|
||||
|
||||
const [, jreKey, platformKey] = match;
|
||||
if (!jreVersions[jreKey]) return null;
|
||||
|
||||
return {
|
||||
platformKey,
|
||||
platformLabel: platformLabels[platformKey] ?? platformKey,
|
||||
info: assetInfo(asset),
|
||||
jreVersion: jreVersions[jreKey],
|
||||
jreKey,
|
||||
};
|
||||
})
|
||||
.filter((entry): entry is JreDisplayEntry => entry !== null)
|
||||
.sort((a, b) => a.platformLabel.localeCompare(b.platformLabel));
|
||||
}
|
||||
|
||||
export function buildDriverEntries(assets: GitHubReleaseAsset[]): DriverDisplayEntry[] {
|
||||
const byName = assetMap(assets);
|
||||
|
||||
return currentJavaDriverKeys
|
||||
.map((key) => {
|
||||
const asset = byName.get(`dbx-agent-${key}.jar`);
|
||||
if (!asset) return null;
|
||||
|
||||
return {
|
||||
key,
|
||||
label: labelForDriver(key),
|
||||
version: driverVersionMap[key] ?? "",
|
||||
minAppVersion: MIN_APP_VERSION,
|
||||
jar: assetInfo(asset),
|
||||
jre: "21",
|
||||
};
|
||||
})
|
||||
.filter((entry): entry is DriverDisplayEntry => entry !== null);
|
||||
}
|
||||
|
||||
export function buildNativeAgentEntries(assets: GitHubReleaseAsset[]): NativeAgentDisplayEntry[] {
|
||||
const entries: NativeAgentDisplayEntry[] = [];
|
||||
|
||||
for (const asset of assets) {
|
||||
const match = /^dbx-agent-(oracle|xugu)-(.+?)(?:\.exe)?$/.exec(asset.name);
|
||||
if (!match) continue;
|
||||
|
||||
const [, key, platformKey] = match;
|
||||
entries.push({
|
||||
key,
|
||||
label: labelForDriver(key),
|
||||
version: driverVersionMap[key] ?? "",
|
||||
platformKey,
|
||||
platformLabel: platformLabels[platformKey] ?? platformKey,
|
||||
filename: asset.name,
|
||||
info: assetInfo(asset),
|
||||
});
|
||||
}
|
||||
|
||||
return entries.sort((a, b) => a.label.localeCompare(b.label) || a.platformLabel.localeCompare(b.platformLabel));
|
||||
}
|
||||
|
||||
export function buildOfflineBundleEntries(assets: GitHubReleaseAsset[]): OfflineBundleEntry[] {
|
||||
return assets
|
||||
.map((asset) => {
|
||||
const match = /^dbx-agents-offline-(.+)\.zip$/.exec(asset.name);
|
||||
if (!match) return null;
|
||||
const platformKey = match[1];
|
||||
return {
|
||||
platformKey,
|
||||
platformLabel: platformLabels[platformKey] ?? platformKey,
|
||||
filename: asset.name,
|
||||
size: asset.size,
|
||||
url: asset.browser_download_url,
|
||||
};
|
||||
})
|
||||
.filter((entry): entry is OfflineBundleEntry => entry !== null)
|
||||
.sort((a, b) => a.platformLabel.localeCompare(b.platformLabel));
|
||||
}
|
||||
|
||||
export function formatSize(bytes: number): string {
|
||||
|
||||
@@ -55,6 +55,10 @@ export function changelogUrl(lang: "en" | "cn") {
|
||||
}
|
||||
|
||||
export async function fetchChangelog(lang: "en" | "cn"): Promise<ChangelogData> {
|
||||
if (typeof window !== "undefined") {
|
||||
return fetchGitHubChangelog();
|
||||
}
|
||||
|
||||
const url = changelogUrl(lang);
|
||||
|
||||
try {
|
||||
|
||||
@@ -21,6 +21,10 @@ function normalizeVersion(version: string) {
|
||||
}
|
||||
|
||||
export async function fetchLatestReleaseInfo(): Promise<LatestReleaseInfo | null> {
|
||||
if (typeof window !== "undefined") {
|
||||
return fetchGitHubLatestReleaseInfo();
|
||||
}
|
||||
|
||||
try {
|
||||
const release = await requestJson<LatestReleaseInfo>(createUncachedUrl(LATEST_RELEASE_URL, browserCacheBuster()), releaseMetadataRequestInit());
|
||||
return release.version ? { ...release, version: normalizeVersion(release.version) } : null;
|
||||
|
||||
Reference in New Issue
Block a user