graphmind-sdk 0.6.4 → 0.7.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/README.md +7 -0
- package/dist/src/client.d.ts +4 -2
- package/dist/src/client.js +10 -5
- package/dist/src/http-client.d.ts +2 -2
- package/dist/src/http-client.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,13 @@ await client.query(`
|
|
|
23
23
|
CREATE (a)-[:KNOWS]->(b)
|
|
24
24
|
`);
|
|
25
25
|
|
|
26
|
+
// Or use shared variables (no semicolons needed)
|
|
27
|
+
await client.query(`
|
|
28
|
+
CREATE (a:Person {name: "Charlie", age: 35})
|
|
29
|
+
CREATE (b:Person {name: "Diana", age: 28})
|
|
30
|
+
CREATE (a)-[:KNOWS {since: 2023}]->(b)
|
|
31
|
+
`);
|
|
32
|
+
|
|
26
33
|
// Query
|
|
27
34
|
const result = await client.query('MATCH (n:Person) RETURN n.name, n.age');
|
|
28
35
|
console.log(result);
|
package/dist/src/client.d.ts
CHANGED
|
@@ -50,9 +50,11 @@ export declare class GraphmindClient {
|
|
|
50
50
|
/** List graphs (fetches graph name from server status) */
|
|
51
51
|
listGraphs(): Promise<string[]>;
|
|
52
52
|
/** Get server status */
|
|
53
|
-
status(): Promise<ServerStatus>;
|
|
53
|
+
status(graph?: string): Promise<ServerStatus>;
|
|
54
|
+
/** Get the database server version */
|
|
55
|
+
version(): Promise<string>;
|
|
54
56
|
/** Get graph schema (node types, edge types, indexes, constraints, statistics) */
|
|
55
|
-
schema(): Promise<GraphSchema>;
|
|
57
|
+
schema(graph?: string): Promise<GraphSchema>;
|
|
56
58
|
/**
|
|
57
59
|
* Sample a subgraph for visualization.
|
|
58
60
|
* Returns a proportionally sampled set of nodes and edges.
|
package/dist/src/client.js
CHANGED
|
@@ -74,18 +74,23 @@ export class GraphmindClient {
|
|
|
74
74
|
}
|
|
75
75
|
/** List graphs (fetches graph name from server status) */
|
|
76
76
|
async listGraphs() {
|
|
77
|
-
const s = await this.http.status();
|
|
77
|
+
const s = await this.http.status(this.defaultGraph);
|
|
78
78
|
// OSS mode returns a single graph; use the status graph field if present
|
|
79
79
|
const graph = s.graph ?? "default";
|
|
80
80
|
return [graph];
|
|
81
81
|
}
|
|
82
82
|
/** Get server status */
|
|
83
|
-
async status() {
|
|
84
|
-
return this.http.status();
|
|
83
|
+
async status(graph) {
|
|
84
|
+
return this.http.status(graph || this.defaultGraph);
|
|
85
|
+
}
|
|
86
|
+
/** Get the database server version */
|
|
87
|
+
async version() {
|
|
88
|
+
const s = await this.status();
|
|
89
|
+
return s.version;
|
|
85
90
|
}
|
|
86
91
|
/** Get graph schema (node types, edge types, indexes, constraints, statistics) */
|
|
87
|
-
async schema() {
|
|
88
|
-
return this.http.schema();
|
|
92
|
+
async schema(graph) {
|
|
93
|
+
return this.http.schema(graph || this.defaultGraph);
|
|
89
94
|
}
|
|
90
95
|
/**
|
|
91
96
|
* Sample a subgraph for visualization.
|
|
@@ -10,9 +10,9 @@ export declare class HttpTransport {
|
|
|
10
10
|
/** Execute a Cypher query via POST /api/query */
|
|
11
11
|
query(cypher: string, graph?: string): Promise<QueryResult>;
|
|
12
12
|
/** Get server status via GET /api/status */
|
|
13
|
-
status(): Promise<ServerStatus>;
|
|
13
|
+
status(graph?: string): Promise<ServerStatus>;
|
|
14
14
|
/** Get graph schema via GET /api/schema */
|
|
15
|
-
schema(): Promise<GraphSchema>;
|
|
15
|
+
schema(graph?: string): Promise<GraphSchema>;
|
|
16
16
|
/** Generic POST request returning typed JSON response */
|
|
17
17
|
post<T>(path: string, body: unknown): Promise<T>;
|
|
18
18
|
/** Import nodes from CSV via POST /api/import/csv (multipart) */
|
package/dist/src/http-client.js
CHANGED
|
@@ -23,8 +23,9 @@ export class HttpTransport {
|
|
|
23
23
|
return (await response.json());
|
|
24
24
|
}
|
|
25
25
|
/** Get server status via GET /api/status */
|
|
26
|
-
async status() {
|
|
27
|
-
const
|
|
26
|
+
async status(graph) {
|
|
27
|
+
const q = graph ? `?graph=${encodeURIComponent(graph)}` : "";
|
|
28
|
+
const response = await fetch(`${this.baseUrl}/api/status${q}`, {
|
|
28
29
|
headers: this.extraHeaders,
|
|
29
30
|
});
|
|
30
31
|
if (!response.ok) {
|
|
@@ -33,8 +34,9 @@ export class HttpTransport {
|
|
|
33
34
|
return (await response.json());
|
|
34
35
|
}
|
|
35
36
|
/** Get graph schema via GET /api/schema */
|
|
36
|
-
async schema() {
|
|
37
|
-
const
|
|
37
|
+
async schema(graph) {
|
|
38
|
+
const q = graph ? `?graph=${encodeURIComponent(graph)}` : "";
|
|
39
|
+
const response = await fetch(`${this.baseUrl}/api/schema${q}`, {
|
|
38
40
|
headers: this.extraHeaders,
|
|
39
41
|
});
|
|
40
42
|
if (!response.ok) {
|