leangraph 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +456 -0
- package/dist/auth.d.ts +66 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +148 -0
- package/dist/auth.js.map +1 -0
- package/dist/backup.d.ts +51 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +201 -0
- package/dist/backup.js.map +1 -0
- package/dist/cli-helpers.d.ts +17 -0
- package/dist/cli-helpers.d.ts.map +1 -0
- package/dist/cli-helpers.js +121 -0
- package/dist/cli-helpers.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +660 -0
- package/dist/cli.js.map +1 -0
- package/dist/db.d.ts +118 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +720 -0
- package/dist/db.js.map +1 -0
- package/dist/executor.d.ts +663 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +8578 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/local.d.ts +7 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +119 -0
- package/dist/local.js.map +1 -0
- package/dist/parser.d.ts +365 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +2711 -0
- package/dist/parser.js.map +1 -0
- package/dist/property-value.d.ts +3 -0
- package/dist/property-value.d.ts.map +1 -0
- package/dist/property-value.js +30 -0
- package/dist/property-value.js.map +1 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +93 -0
- package/dist/remote.js.map +1 -0
- package/dist/routes.d.ts +31 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +202 -0
- package/dist/routes.js.map +1 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +25 -0
- package/dist/server.js.map +1 -0
- package/dist/translator.d.ts +330 -0
- package/dist/translator.d.ts.map +1 -0
- package/dist/translator.js +13712 -0
- package/dist/translator.js.map +1 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +77 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a GraphDB client.
|
|
3
|
+
* All options support environment variable defaults.
|
|
4
|
+
*/
|
|
5
|
+
export interface GraphDBOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Base URL of the GraphDB server.
|
|
8
|
+
* Used in production mode. Ignored in development mode.
|
|
9
|
+
* @default GRAPHDB_URL env var or 'https://leangraph.io'
|
|
10
|
+
* @example 'https://my-graphdb.example.com'
|
|
11
|
+
*/
|
|
12
|
+
url?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Project name.
|
|
15
|
+
* In production: used as part of the API endpoint path.
|
|
16
|
+
* In development: used as the database filename.
|
|
17
|
+
* @default GRAPHDB_PROJECT env var (required)
|
|
18
|
+
*/
|
|
19
|
+
project?: string;
|
|
20
|
+
/**
|
|
21
|
+
* API key for authentication.
|
|
22
|
+
* Used in production mode. Ignored in development mode.
|
|
23
|
+
* @default GRAPHDB_API_KEY env var
|
|
24
|
+
*/
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Environment name for data isolation.
|
|
28
|
+
* @default NODE_ENV or 'production'
|
|
29
|
+
*/
|
|
30
|
+
env?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Path for local data storage.
|
|
33
|
+
* Only used in development mode (when NODE_ENV=development).
|
|
34
|
+
* - Use ':memory:' for an in-memory database (resets on restart)
|
|
35
|
+
* @default GRAPHDB_DATA_PATH env var or './data'
|
|
36
|
+
*/
|
|
37
|
+
dataPath?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Full response from a query, including metadata.
|
|
41
|
+
*/
|
|
42
|
+
export interface QueryResponse<T = Record<string, unknown>> {
|
|
43
|
+
success: boolean;
|
|
44
|
+
data: T[];
|
|
45
|
+
meta: {
|
|
46
|
+
count: number;
|
|
47
|
+
time_ms: number;
|
|
48
|
+
};
|
|
49
|
+
error?: {
|
|
50
|
+
message: string;
|
|
51
|
+
position?: number;
|
|
52
|
+
line?: number;
|
|
53
|
+
column?: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Health check response.
|
|
58
|
+
*/
|
|
59
|
+
export interface HealthResponse {
|
|
60
|
+
status: string;
|
|
61
|
+
timestamp: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Result type for node queries.
|
|
65
|
+
* In Neo4j 3.5 format, nodes return their properties directly.
|
|
66
|
+
*/
|
|
67
|
+
export type NodeResult = Record<string, unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* GraphDB client interface.
|
|
70
|
+
* Both local and remote clients implement this interface.
|
|
71
|
+
*/
|
|
72
|
+
export interface GraphDBClient {
|
|
73
|
+
/**
|
|
74
|
+
* Execute a Cypher query and return the data array.
|
|
75
|
+
* @throws GraphDBError if the query fails
|
|
76
|
+
*/
|
|
77
|
+
query<T = Record<string, unknown>>(cypher: string, params?: Record<string, unknown>): Promise<T[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Execute a Cypher query and return the full response including metadata.
|
|
80
|
+
* @throws GraphDBError if the query fails
|
|
81
|
+
*/
|
|
82
|
+
queryRaw<T = Record<string, unknown>>(cypher: string, params?: Record<string, unknown>): Promise<QueryResponse<T>>;
|
|
83
|
+
/**
|
|
84
|
+
* Execute a mutating query (CREATE, SET, DELETE, MERGE) without expecting return data.
|
|
85
|
+
* @throws GraphDBError if the query fails
|
|
86
|
+
*/
|
|
87
|
+
execute(cypher: string, params?: Record<string, unknown>): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Create a node with the given label and properties.
|
|
90
|
+
* @returns The generated node ID
|
|
91
|
+
*/
|
|
92
|
+
createNode(label: string, properties?: Record<string, unknown>): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Create an edge between two nodes.
|
|
95
|
+
*/
|
|
96
|
+
createEdge(sourceId: string, type: string, targetId: string, properties?: Record<string, unknown>): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Get a node by label and property filter.
|
|
99
|
+
* @returns The node's properties, or null if not found
|
|
100
|
+
*/
|
|
101
|
+
getNode(label: string, filter: Record<string, unknown>): Promise<NodeResult | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Delete a node by ID (with DETACH to remove connected edges).
|
|
104
|
+
*/
|
|
105
|
+
deleteNode(id: string): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Update properties on a node.
|
|
108
|
+
*/
|
|
109
|
+
updateNode(id: string, properties: Record<string, unknown>): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Check health.
|
|
112
|
+
* Local: always returns ok.
|
|
113
|
+
* Remote: calls the server health endpoint.
|
|
114
|
+
*/
|
|
115
|
+
health(): Promise<HealthResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Close the client and release resources.
|
|
118
|
+
* Important: Always call this when done to prevent resource leaks.
|
|
119
|
+
*/
|
|
120
|
+
close(): void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Error thrown by GraphDB operations.
|
|
124
|
+
* Contains optional position information for Cypher parse errors.
|
|
125
|
+
*/
|
|
126
|
+
export declare class GraphDBError extends Error {
|
|
127
|
+
readonly position?: number;
|
|
128
|
+
readonly line?: number;
|
|
129
|
+
readonly column?: number;
|
|
130
|
+
constructor(message: string, options?: {
|
|
131
|
+
position?: number;
|
|
132
|
+
line?: number;
|
|
133
|
+
column?: number;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 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,SAAQ,KAAK;IACrC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAG9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAQJ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// LeanGraph - Shared Types
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Error Class
|
|
4
|
+
// ============================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown by GraphDB operations.
|
|
7
|
+
* Contains optional position information for Cypher parse errors.
|
|
8
|
+
*/
|
|
9
|
+
export class GraphDBError extends Error {
|
|
10
|
+
position;
|
|
11
|
+
line;
|
|
12
|
+
column;
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "GraphDBError";
|
|
16
|
+
this.position = options?.position;
|
|
17
|
+
this.line = options?.line;
|
|
18
|
+
this.column = options?.column;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AA0K3B,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrB,QAAQ,CAAU;IAClB,IAAI,CAAU;IACd,MAAM,CAAU;IAEhC,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAChC,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "leangraph",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SQLite-based graph database with Cypher query support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"leangraph": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepare": "[ -d .git ] && cp hooks/pre-commit .git/hooks/ && chmod +x .git/hooks/pre-commit || true",
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"test:coverage": "vitest run --coverage",
|
|
29
|
+
"dev": "tsx watch src/server.ts",
|
|
30
|
+
"tck": "node --import tsx test/tck/run-test.ts",
|
|
31
|
+
"tck:failing": "node --import tsx test/tck/list-failing-tests.ts",
|
|
32
|
+
"tck:check-fixed": "TCK_TEST_ALL=1 npm test 2>&1 | grep -A 50 'from FAILING_TESTS that now PASS'",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@hono/node-server": "^1.13.0",
|
|
37
|
+
"better-sqlite3": "^11.0.0",
|
|
38
|
+
"commander": "^12.0.0",
|
|
39
|
+
"hono": "^4.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
43
|
+
"@types/node": "^22.0.0",
|
|
44
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
45
|
+
"tsx": "^4.0.0",
|
|
46
|
+
"typescript": "^5.3.0",
|
|
47
|
+
"vitest": "^4.0.16"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"leangraph",
|
|
51
|
+
"graph",
|
|
52
|
+
"database",
|
|
53
|
+
"graphdb",
|
|
54
|
+
"cypher",
|
|
55
|
+
"opencypher",
|
|
56
|
+
"sqlite",
|
|
57
|
+
"typescript",
|
|
58
|
+
"neo4j",
|
|
59
|
+
"query"
|
|
60
|
+
],
|
|
61
|
+
"author": "Conrad Lelubre",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git+https://github.com/co-l/leangraph.git"
|
|
66
|
+
},
|
|
67
|
+
"homepage": "https://leangraph.io",
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/co-l/leangraph/issues"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=18.0.0"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
}
|
|
77
|
+
}
|