feat(nebula): add NebulaGraph 3.x browser support

This commit is contained in:
Hand Sonic authored and GitHub committed 2026-09-29 21:03:12 +08:00
1 parent e59a8c1bd4
commit ef05a6a19b
69 files changed
+1737 -41

No files matched your search

@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import { connectionUrlPlaceholder } from "@/lib/connection/connectionPresentation";
import { parseConnectionUrl } from "@/lib/connection/connectionUrl";
describe("NebulaGraph connection URLs", () => {
it("parses graphd connection details and an optional space", () => {
expect(parseConnectionUrl("nebula://root:secret@graphd.example.com:9669/demo")).toMatchObject({
dbType: "nebula",
driverProfile: "nebula",
host: "graphd.example.com",
port: 9669,
username: "root",
password: "secret",
database: "demo",
});
});
it("shows a NebulaGraph-specific placeholder", () => {
expect(connectionUrlPlaceholder("nebula")).toBe("nebula://root:password@graphd:9669/space");
});
});
@@ -37,6 +37,10 @@ describe("databaseDriverManifest", () => {
});
});
it("offers only the supported NebulaGraph 3.x profile", () => {
expect(databaseManifestEntry("nebula")?.driverProfiles).toEqual([{ profile: "nebula-v3", agentKey: "nebula", label: "NebulaGraph 3.x", storeVisible: false }]);
});
it("routes only specialized connection forms explicitly", () => {
expect(databaseConnectionFormKind("mysql")).toBe("standard");
expect(databaseConnectionFormKind("jdbc")).toBe("jdbc");
@@ -46,6 +46,15 @@ describe("extractSqlParameters", () => {
expect(extractSqlParameters("MATCH (p:Person {name:${name}}) RETURN p", options)).toEqual(["name"]);
});
it("keeps NebulaGraph tags and edge types intact in nGQL", () => {
const ngql = 'MATCH (p:Person)-[:WORK_IN]->(c:Company{name:"星云科技"}) RETURN p.Person.name LIMIT 10';
const options = { databaseType: "nebula" as const };
expect(extractSqlParameterDescriptors(ngql, options)).toEqual([]);
expect(substituteSqlParameters(ngql, {}, options)).toBe(ngql);
expect(extractSqlParameters("MATCH (p:Person {name:${name}}) RETURN p LIMIT 10", options)).toEqual(["name"]);
expect(extractSqlParameters("select :customer_id", { databaseType: "mysql" })).toEqual(["customer_id"]);
});
it("extracts unique template parameters in order", () => {
const sql = "select * from t where pt_dt between ${start_date} and ${end_date} or pt_dt = ${start_date}";
expect(extractSqlParameters(sql)).toEqual(["start_date", "end_date"]);
@@ -19,6 +19,13 @@ describe("resolveSqlVariableSyntaxToggles", () => {
expect(resolveSqlVariableSyntaxToggles({ neo4j: { shell: false } }, "neo4j")).toEqual({ ...toggles, shell: false });
});
it("disables SQL named placeholders for NebulaGraph", () => {
const toggles = resolveSqlVariableSyntaxToggles(undefined, "nebula");
expect(toggles).toEqual({ ...DEFAULT_SQL_VARIABLE_SYNTAX_TOGGLES, named: false });
expect(enabledSqlParameterSyntaxes(toggles)).not.toContain("named");
expect(resolveSqlVariableSyntaxToggles(undefined, "mysql").named).toBe(true);
});
it("enables every syntax when the database type is unknown", () => {
expect(resolveSqlVariableSyntaxToggles({ mysql: { shell: false } }, undefined)).toEqual(DEFAULT_SQL_VARIABLE_SYNTAX_TOGGLES);
});
@@ -322,6 +322,7 @@ describe("quoteTableIdentifier", () => {
expect(requiresEagerTableMetadataForDataOpen("salesforce")).toBe(true);
expect(requiresEagerTableMetadataForDataOpen("mysql")).toBe(true);
expect(requiresEagerTableMetadataForDataOpen("postgres")).toBe(true);
expect(requiresEagerTableMetadataForDataOpen("nebula")).toBe(true);
// Drivers whose preview works from `SELECT *` keep loading metadata lazily.
expect(requiresEagerTableMetadataForDataOpen("sqlite")).toBe(false);
expect(requiresEagerTableMetadataForDataOpen(undefined)).toBe(false);