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);
@@ -38,6 +38,15 @@ describe("Transwarp driver installation", () => {
});
});
describe("NebulaGraph driver installation", () => {
it("routes the v3 profile and legacy connections to the same Agent package", () => {
for (const profile of [undefined, "nebula", "nebula-v3"]) {
expect(agentDriverInstallKey("nebula", profile)).toBe("nebula");
expect(showAgentDriverInstallHint("nebula", [{ db_type: "nebula", installed: true }], profile)).toBe(false);
}
});
});
describe("shouldApplyDriverStoreFocus", () => {
it("applies when the driver first appears after a list load", () => {
expect(shouldApplyDriverStoreFocus(null, "driver:mysql", false)).toBe(true);
@@ -125,6 +125,7 @@ describe("AGENT_DRIVER_CATEGORY_MAP integrity", () => {
"mongodb",
// graph_ai
"neo4j",
"nebula",
// timeseries
"influxdb",
"iotdb",
@@ -1,5 +1,6 @@
import type { DatabaseType } from "@/types/database";
import { supportsDriverManagement } from "@/lib/database/databaseCapabilities";
import { databaseManifestEntry } from "@/lib/database/databaseDriverManifest";
export interface AgentDriverInstallState {
db_type: string;
@@ -38,6 +39,10 @@ export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverPr
if (dbType === "oracle") return "oracle";
if (dbType === "h2") return "h2";
if (dbType === "transwarp") return "transwarp";
if (dbType === "nebula") {
const entry = databaseManifestEntry(dbType);
return entry?.driverProfiles?.find((profile) => profile.profile === driverProfile)?.agentKey ?? entry?.agentKey;
}
if (dbType === "mongodb") return "mongodb";
if (dbType === "dameng") return "dameng";
if (dbType === "gbase") return driverProfile === "gbase8s" ? "gbase8s" : "gbase8a";
@@ -40,6 +40,7 @@ const DRIVER_STARTUP_FLOOR_TYPES = new Set<DatabaseType>([
"db2",
"informix",
"neo4j",
"nebula",
"cassandra",
"bigquery",
"spanner",
@@ -212,6 +212,9 @@ export function connectionUrlPlaceholder(dbType: DatabaseType, driverProfile?: s
case "mongodb":
return "mongodb://user:password@host:port/database";
case "nebula":
return "nebula://root:password@graphd:9669/space";
case "dynamodb":
return "https://dynamodb.us-east-1.amazonaws.com";
@@ -54,6 +54,7 @@ const SCHEME_PROFILES: Record<string, ConnectionProfile> = {
"mongodb+srv": { type: "mongodb", profile: "mongodb", label: "MongoDB", defaultPort: 27017 },
dynamodb: { type: "dynamodb", profile: "dynamodb", label: "Amazon DynamoDB", defaultPort: 443 },
clickhouse: { type: "clickhouse", profile: "clickhouse", label: "ClickHouse", defaultPort: 8123 },
nebula: { type: "nebula", profile: "nebula", label: "NebulaGraph", defaultPort: 9669 },
sqlserver: { type: "sqlserver", profile: "sqlserver", label: "SQL Server", defaultPort: 1433 },
mssql: { type: "sqlserver", profile: "sqlserver", label: "SQL Server", defaultPort: 1433 },
oracle: { type: "oracle", profile: "oracle", label: "Oracle", defaultPort: 1521 },
@@ -46,6 +46,7 @@ export const AGENT_DRIVER_CATEGORY_MAP: Readonly<Record<string, DriverCategoryKe
ignite3: "analytics",
mongodb: "document",
neo4j: "graph_ai",
nebula: "graph_ai",
"oceanbase-oracle": "domestic",
oracle: "sql",
oscar: "domestic",
@@ -12,6 +12,7 @@ describe("supportsDataDictionary", () => {
it("is hidden for engines that cannot list table metadata", () => {
expect(supportsDataDictionary("redis")).toBe(false);
expect(supportsDataDictionary("nebula")).toBe(false);
expect(supportsDataDictionary("plugin")).toBe(false);
});
});
@@ -147,7 +147,7 @@ export function supportsQueryExecution(dbType?: DatabaseType): boolean {
* that hierarchy, so they must not be offered by sidebar "Add to AI" actions.
*/
export function supportsAiAssistantContext(dbType?: DatabaseType): boolean {
return supportsQueryExecution(dbType) && !usesConnectionOnlyQueryTarget(dbType);
return supportsQueryExecution(dbType) && !usesConnectionOnlyQueryTarget(dbType) && dbType !== "nebula";
}
export function supportsConnectionScopedQueryExecution(dbType?: DatabaseType): boolean {
@@ -182,7 +182,7 @@ export function supportsSqlFileExecution(dbType?: DatabaseType): boolean {
return supportsDatabaseFeature(dbType, "sqlFileExecution");
}
const NON_SQL_IN_LIST_PASTE_TYPES = new Set<DatabaseType>(["neo4j"]);
const NON_SQL_IN_LIST_PASTE_TYPES = new Set<DatabaseType>(["neo4j", "nebula"]);
export function supportsSqlInListPaste(dbType?: DatabaseType): boolean {
if (!dbType) return true;
@@ -200,7 +200,7 @@ export function supportsSchemaDiagram(dbType?: DatabaseType): boolean {
/** Relational engines that can list tables and columns. Independent of diagram support. */
export function supportsDataDictionary(dbType?: DatabaseType): boolean {
return supportsDatabaseFeature(dbType, "metadataBrowse");
return dbType !== "nebula" && supportsDatabaseFeature(dbType, "metadataBrowse");
}
export function supportsDatabaseSearch(dbType?: DatabaseType): boolean {
@@ -256,7 +256,19 @@ export function supportsObjectBrowserTreeNode(dbType: DatabaseType | undefined,
export function supportsTableTruncate(dbType?: DatabaseType): boolean {
return (
!!dbType && dbType !== "impala" && dbType !== "sqlite" && dbType !== "rqlite" && dbType !== "turso" && dbType !== "cloudflare-d1" && dbType !== "duckdb" && dbType !== "influxdb" && dbType !== "influxdb3" && dbType !== "victoriametrics" && dbType !== "manticoresearch" && dbType !== "salesforce"
!!dbType &&
dbType !== "impala" &&
dbType !== "sqlite" &&
dbType !== "rqlite" &&
dbType !== "turso" &&
dbType !== "cloudflare-d1" &&
dbType !== "duckdb" &&
dbType !== "influxdb" &&
dbType !== "influxdb3" &&
dbType !== "victoriametrics" &&
dbType !== "manticoresearch" &&
dbType !== "salesforce" &&
dbType !== "nebula"
);
}
@@ -77,6 +77,7 @@ export const DATABASE_NAMESPACE_CREATION_MATRIX = {
db2: { database: "schema" },
informix: { connection: "database" },
neo4j: { deferred: "database creation depends on edition/admin privileges" },
nebula: { deferred: "space creation requires partition, replica and VID type options" },
cassandra: { deferred: "keyspace creation requires replication options" },
bigquery: { deferred: "dataset creation needs project/location options" },
spanner: { deferred: "database creation requires the Cloud Spanner Admin API" },
@@ -97,6 +97,7 @@ const DATABASE_TYPE_OBJECTS = new Map<DatabaseType, SidebarObjectKind[]>([
["tdengine", TABLE_VIEW_OBJECTS],
["iotdb", TABLE_VIEW_OBJECTS],
["neo4j", TABLE_VIEW_OBJECTS],
["nebula", TABLE_VIEW_OBJECTS],
// others
["influxdb", ["TABLE"]],
["influxdb3", ["TABLE"]],
@@ -78,6 +78,7 @@ export const DATABASE_PROPERTY_EDITING_MATRIX = {
db2: { deferred: "schema properties need product-specific handling" },
informix: { deferred: "schema properties need product-specific handling" },
neo4j: { deferred: "database properties depend on edition/admin privileges" },
nebula: { deferred: "space properties require NebulaGraph-specific administration" },
cassandra: { deferred: "keyspace properties require replication option handling" },
bigquery: { deferred: "dataset properties need project/location-specific handling" },
spanner: { deferred: "database/schema properties are Cloud Spanner Admin API operations" },
+1 -1
View File
@@ -98,7 +98,7 @@ export interface ResolveNewQueryInitialSqlInput extends ResolveNewQueryTableInpu
// Database types whose "table" view does not use standard SQL `SELECT * FROM <table>`
// (e.g. Neo4j uses Cypher). The new-query prefill is skipped for these.
const NEW_QUERY_PREFILL_DISABLED_TYPES: ReadonlySet<DatabaseType | undefined> = new Set<DatabaseType | undefined>(["neo4j"]);
const NEW_QUERY_PREFILL_DISABLED_TYPES: ReadonlySet<DatabaseType | undefined> = new Set<DatabaseType | undefined>(["neo4j", "nebula"]);
export function isNewQueryPrefillSupported(databaseType: DatabaseType | undefined): boolean {
return !NEW_QUERY_PREFILL_DISABLED_TYPES.has(databaseType);
+1 -1
View File
@@ -378,7 +378,7 @@ function findSqlParameterOccurrences(sql: string, options?: SqlParameterOptions)
const occurrences: ParameterOccurrence[] = [];
const databaseType = options?.databaseType;
const nativeSqlServerParameters = collectNativeSqlServerParameters(sql, databaseType);
const supportsNamedParameters = databaseType !== "saphana" && databaseType !== "neo4j";
const supportsNamedParameters = databaseType !== "saphana" && databaseType !== "neo4j" && databaseType !== "nebula";
const enabledSyntaxes = options?.enabledSyntaxes ? new Set(options.enabledSyntaxes) : null;
const isSyntaxEnabled = (syntax: SqlParameterSyntax) => !enabledSyntaxes || enabledSyntaxes.has(syntax);
const complexTypeFieldSeparators = supportsNamedParameters && isSyntaxEnabled("named") ? collectComplexTypeFieldSeparators(sql, databaseType) : new Set<number>();
@@ -27,7 +27,7 @@ export function elasticsearchRestRequestRanges(sql: string, databaseType?: Datab
return requests.length > 0 && requests.every((request) => ELASTICSEARCH_REST_REQUEST.test(request.sql)) ? requests : [];
}
const NON_SQL_EXECUTION_TARGET_TYPES: ReadonlySet<DatabaseType> = new Set(["mongodb", "elasticsearch", "easysearch", "meilisearch", "solr", "qdrant", "milvus", "weaviate", "chromadb", "etcd", "zookeeper", "consul", "mq", "neo4j", "victoriametrics", "salesforce"]);
const NON_SQL_EXECUTION_TARGET_TYPES: ReadonlySet<DatabaseType> = new Set(["mongodb", "elasticsearch", "easysearch", "meilisearch", "solr", "qdrant", "milvus", "weaviate", "chromadb", "etcd", "zookeeper", "consul", "mq", "neo4j", "nebula", "victoriametrics", "salesforce"]);
export function supportsExecutionTargetPicker(databaseType?: DatabaseType): boolean {
return !!databaseType && (databaseType === "redis" || isHttpJsonRestDatabaseType(databaseType) || !NON_SQL_EXECUTION_TARGET_TYPES.has(databaseType));
@@ -72,7 +72,7 @@ export function resolveSqlVariableSyntaxToggles(overrides: SqlVariableSyntaxOver
const partial = dbType ? overrides?.[dbType] : undefined;
return {
positional: partial?.positional ?? true,
named: dbType === "neo4j" ? false : (partial?.named ?? true),
named: dbType === "neo4j" || dbType === "nebula" ? false : (partial?.named ?? true),
shell: partial?.shell ?? true,
mybatis: partial?.mybatis ?? true,
sqlserver: partial?.sqlserver ?? true,
+3 -1
View File
@@ -447,9 +447,11 @@ export function normalizeWhereInput(whereInput?: string): string {
* * Salesforce: SOQL has no `SELECT *`. With no known fields the backend builder
* falls back to the `FIELDS(ALL)` selector, which the org only accepts with
* `LIMIT 200` or less — awaiting the describe keeps every page size working.
* * NebulaGraph: without tag/edge properties, the grid can only show a single
* vertex/edge value instead of separate property columns.
*/
export function requiresEagerTableMetadataForDataOpen(databaseType: DatabaseType | undefined): boolean {
return databaseType === "mysql" || databaseType === "postgres" || databaseType === "salesforce";
return databaseType === "mysql" || databaseType === "postgres" || databaseType === "salesforce" || databaseType === "nebula";
}
export async function buildTableSelectSql(options: BuildTableSelectSqlOptions): Promise<string> {