feat(agents): add versioned offline driver packages
This commit is contained in:
1 parent
8d68a527a0
commit
79cd12d13a
29 files changed
+1372
-162
No files matched your search
@@ -109,7 +109,8 @@ export const getAgentJavaRuntimeConfig = forward("getAgentJavaRuntimeConfig");
|
||||
export const setAgentJavaRuntimeConfig = forward("setAgentJavaRuntimeConfig");
|
||||
export const invalidateAgentRegistryCache = forward("invalidateAgentRegistryCache");
|
||||
export const importAgentsFromZip = forward("importAgentsFromZip");
|
||||
export const importAgentJar = forward("importAgentJar");
|
||||
export const importAgentDriver = forward("importAgentDriver");
|
||||
export const importAgentJar = importAgentDriver;
|
||||
export async function reinstallJre(jreKey?: string) {
|
||||
const backend = await getBackend();
|
||||
return backend.reinstallJre(jreKey, useSettingsStore().editorSettings.updateDownloadSource);
|
||||
|
||||
@@ -457,23 +457,25 @@ export async function importAgentsFromZip(fileOrPath: string | File): Promise<nu
|
||||
return result.count;
|
||||
}
|
||||
|
||||
export async function importAgentJar(dbType: string, pathOrFile: string | File): Promise<void> {
|
||||
export async function importAgentDriver(dbType: string, pathOrFile: string | File): Promise<void> {
|
||||
let blob: Blob;
|
||||
let fileName: string;
|
||||
if (pathOrFile instanceof File) {
|
||||
blob = pathOrFile;
|
||||
fileName = pathOrFile.name;
|
||||
} else {
|
||||
fileName = pathOrFile.split("/").pop() || "driver.jar";
|
||||
fileName = pathOrFile.split("/").pop() || "agent";
|
||||
blob = await (await fetch(pathOrFile)).blob();
|
||||
}
|
||||
const formData = new FormData();
|
||||
formData.append("dbType", dbType);
|
||||
formData.append("file", blob, fileName);
|
||||
const uploadRes = await fetch(apiUrl("/api/agents/import-jar"), { method: "POST", body: formData });
|
||||
const uploadRes = await fetch(apiUrl("/api/agents/import-driver"), { method: "POST", body: formData });
|
||||
if (!uploadRes.ok) throw new Error(await uploadRes.text());
|
||||
}
|
||||
|
||||
export const importAgentJar = importAgentDriver;
|
||||
|
||||
export async function reinstallJre(jreKey?: string, _source?: UpdateDownloadSource): Promise<void> {
|
||||
await post("/api/agents/reinstall-jre", { jreKey });
|
||||
}
|
||||
|
||||
@@ -1341,13 +1341,15 @@ export async function importAgentsFromZip(path: string | File): Promise<number>
|
||||
return invoke("import_agents_from_zip", { path });
|
||||
}
|
||||
|
||||
export async function importAgentJar(dbType: string, path: string | File): Promise<void> {
|
||||
export async function importAgentDriver(dbType: string, path: string | File): Promise<void> {
|
||||
if (typeof path !== "string") {
|
||||
throw new Error("Desktop driver JAR import requires a local file path");
|
||||
throw new Error("Desktop driver import requires a local file path");
|
||||
}
|
||||
return invoke("import_agent_jar_cmd", { dbType, path });
|
||||
return invoke("import_agent_driver_cmd", { dbType, path });
|
||||
}
|
||||
|
||||
export const importAgentJar = importAgentDriver;
|
||||
|
||||
export async function reinstallJre(jreKey?: string, source?: UpdateDownloadSource): Promise<void> {
|
||||
return invoke("reinstall_jre", { jreKey, source });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isOfflineDriverPackage, webDriverImportAccept } from "./driverImportSelection";
|
||||
|
||||
describe("driver import selection", () => {
|
||||
it("recognizes ZIP paths and uploaded files case-insensitively", () => {
|
||||
expect(isOfflineDriverPackage("C:\\Downloads\\dbx-agent-h2-0.2.5.ZIP")).toBe(true);
|
||||
expect(isOfflineDriverPackage({ name: "dbx-agent-kingbase-0.1.34-macos-aarch64.zip" })).toBe(true);
|
||||
expect(isOfflineDriverPackage({ name: "dbx-agent-h2-0.2.5.jar" })).toBe(false);
|
||||
});
|
||||
|
||||
it("allows ZIP alongside the platform raw artifact", () => {
|
||||
expect(webDriverImportAccept(true, false)).toBe(".zip,.jar");
|
||||
expect(webDriverImportAccept(false, true)).toBe(".zip,.exe");
|
||||
expect(webDriverImportAccept(false, false)).toBe("");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
export type DriverImportSelection = string | { name: string };
|
||||
|
||||
export function isOfflineDriverPackage(selection: DriverImportSelection): boolean {
|
||||
const name = typeof selection === "string" ? selection : selection.name;
|
||||
return name.toLowerCase().endsWith(".zip");
|
||||
}
|
||||
|
||||
export function webDriverImportAccept(requiresJavaRuntime: boolean, isWindows: boolean): string {
|
||||
if (requiresJavaRuntime) return ".zip,.jar";
|
||||
return isWindows ? ".zip,.exe" : "";
|
||||
}
|
||||
Reference in new issue
Block a user