Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

4.2 KB
Raw Blame
import { commonGraphFunctions, functionDefinitions, graphListPredicates, graphReduce, temporalFunctions, type GraphQueryProfile } from "../graphQueryProfile";

// Neo4j 5 built-ins: https://neo4j.com/docs/cypher-manual/5/functions/
const reservedWords =
  "ALL ALTER AND AS ASC ASCENDING ASSERT BY CALL CASE COMMIT COMPOSITE CONSTRAINT CONSTRAINTS CONTAINS CREATE CSV CURRENT DATABASE DATABASES DELETE DESC DESCENDING DETACH DISTINCT DROP ELSE END ENDS EXCEPT EXECUTABLE EXISTS EXPLAIN FALSE FIELDTERMINATOR FOR FOREACH FROM FUNCTIONS HEADERS IF IN INDEX INDEXES IS JOIN LIMIT LOAD MATCH MERGE NODE NODETACH NOT NULL OF ON OPTIONAL OR ORDER PERIODIC PRIVILEGES PROCEDURE PROCEDURES PROFILE REMOVE RENAME REQUIRE RETURN ROLE ROLES SCAN SERVER SERVERS SET SETTINGS SHOW SKIP START STARTS THEN TO TRANSACTION TRANSACTIONS TRUE UNION UNIQUE UNWIND USE USER USERS USING WHEN WHERE WITH XOR YIELD".split(
    " ",
  );
// Cypher 5.19+ path selectors/restrictors (SHORTEST/WALK/TRAIL/ACYCLIC/SIMPLE) and index
// DDL words (LOOKUP/FULLTEXT) complete and highlight as keywords but stay out of
// reservedWords; POINT/RANGE/TEXT/GROUP are intentionally omitted because they are common
// variable/property names and keyword-ness breaks bound-variable resolution.
const keywords = [...new Set([...reservedWords, ..."ACYCLIC FULLTEXT LOOKUP SHORTEST SIMPLE TRAIL WALK".split(" ")])];

const profile: GraphQueryProfile = {
  databaseType: "neo4j",
  language: "Cypher",
  lineComment: "//",
  keywords,
  reservedWords,
  functions: [
    ...commonGraphFunctions,
    ...functionDefinitions({
      length: ["path"],
      timestamp: [],
      elementId: ["entity"],
      endNode: ["relationship"],
      startNode: ["relationship"],
      toLower: ["string"],
      toUpper: ["string"],
      lower: ["string"],
      upper: ["string"],
      exists: ["property"],
      isEmpty: ["value"],
      shortestPath: ["pattern"],
      allShortestPaths: ["pattern"],
      percentileCont: ["expression", "percentile"],
      percentileDisc: ["expression", "percentile"],
      stDev: ["expression"],
      stDevP: ["expression"],
      rand: [],
      randomUUID: [],
      e: [],
      pi: [],
      exp: ["number"],
      log: ["number"],
      log10: ["number"],
      isNaN: ["number"],
      acos: ["number"],
      asin: ["number"],
      atan: ["number"],
      atan2: ["y", "x"],
      cos: ["number"],
      cot: ["number"],
      degrees: ["radians"],
      haversin: ["number"],
      radians: ["degrees"],
      sin: ["number"],
      tan: ["number"],
      point: ["map"],
      "point.distance": ["from", "to"],
      "point.withinBBox": ["point", "lowerLeft", "upperRight"],
      "duration.between": ["from", "to"],
      "duration.inDays": ["from", "to"],
      "duration.inMonths": ["from", "to"],
      "duration.inSeconds": ["from", "to"],
      "datetime.fromEpoch": ["seconds", "nanoseconds"],
      "datetime.fromEpochMillis": ["milliseconds"],
      "db.nameFromElementId": ["elementId"],
      "graph.byElementId": ["elementId"],
      "graph.byName": ["name"],
      "graph.names": [],
      "graph.propertiesByName": ["name"],
      "vector.similarity.cosine": ["a", "b"],
      "vector.similarity.euclidean": ["a", "b"],
      nullIf: ["value1", "value2"],
      valueType: ["value"],
      char_length: ["string"],
      character_length: ["string"],
      btrim: ["string", "characters?"],
      ltrim: ["string", "characters?"],
      rtrim: ["string", "characters?"],
      normalize: ["string", "normalForm?"],
      toBooleanOrNull: ["value"],
      toFloatOrNull: ["value"],
      toIntegerOrNull: ["value"],
      toStringOrNull: ["value"],
      toBooleanList: ["list"],
      toFloatList: ["list"],
      toIntegerList: ["list"],
      toStringList: ["list"],
      file: [],
      linenumber: [],
    }),
    ...temporalFunctions(["date", "datetime", "localdatetime", "localtime", "time"]),
    ...["date", "datetime", "localdatetime", "localtime", "time"].flatMap((type) =>
      functionDefinitions({
        [`${type}.realtime`]: ["timezone?"],
        [`${type}.statement`]: ["timezone?"],
        [`${type}.transaction`]: ["timezone?"],
        [`${type}.truncate`]: ["unit", "input?", "fields?"],
      }),
    ),
    ...graphListPredicates,
    graphReduce,
  ],
};

export default profile;