graphmind-sdk 0.6.2
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/dist/src/client.d.ts +90 -0
- package/dist/src/client.js +148 -0
- package/dist/src/http-client.d.ts +25 -0
- package/dist/src/http-client.js +101 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +2 -0
- package/dist/src/types.d.ts +127 -0
- package/dist/src/types.js +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { QueryResult, ServerStatus, ClientOptions, GraphSchema, SampleRequest, SampleResult, CsvImportResult, JsonImportResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Client for the Graphmind Graph Database.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const client = new GraphmindClient({ url: "http://localhost:8080" });
|
|
8
|
+
*
|
|
9
|
+
* // Create data
|
|
10
|
+
* await client.query('CREATE (n:Person {name: "Alice"})');
|
|
11
|
+
*
|
|
12
|
+
* // Query data
|
|
13
|
+
* const result = await client.queryReadonly("MATCH (n:Person) RETURN n.name");
|
|
14
|
+
* console.log(result.records);
|
|
15
|
+
*
|
|
16
|
+
* // Schema introspection
|
|
17
|
+
* const schema = await client.schema();
|
|
18
|
+
* console.log(schema.node_types);
|
|
19
|
+
*
|
|
20
|
+
* // EXPLAIN / PROFILE
|
|
21
|
+
* const plan = await client.explain("MATCH (n:Person) RETURN n");
|
|
22
|
+
* const profile = await client.profile("MATCH (n:Person) RETURN n");
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class GraphmindClient {
|
|
26
|
+
private http;
|
|
27
|
+
private defaultGraph;
|
|
28
|
+
constructor(options?: ClientOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Connect to a Graphmind server via HTTP.
|
|
31
|
+
* Factory method for a more readable API.
|
|
32
|
+
*/
|
|
33
|
+
static connectHttp(url?: string): GraphmindClient;
|
|
34
|
+
/** Execute a read-write Cypher query */
|
|
35
|
+
query(cypher: string, graph?: string): Promise<QueryResult>;
|
|
36
|
+
/** Execute a read-only Cypher query */
|
|
37
|
+
queryReadonly(cypher: string, graph?: string): Promise<QueryResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Return the EXPLAIN plan for a Cypher query without executing it.
|
|
40
|
+
* Returns the plan as text rows in the QueryResult records.
|
|
41
|
+
*/
|
|
42
|
+
explain(cypher: string, graph?: string): Promise<QueryResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Execute a Cypher query with PROFILE instrumentation.
|
|
45
|
+
* Returns plan text with actual row counts and timing per operator.
|
|
46
|
+
*/
|
|
47
|
+
profile(cypher: string, graph?: string): Promise<QueryResult>;
|
|
48
|
+
/** Delete a graph (executes MATCH (n) DELETE n) */
|
|
49
|
+
deleteGraph(graph?: string): Promise<void>;
|
|
50
|
+
/** List graphs (fetches graph name from server status) */
|
|
51
|
+
listGraphs(): Promise<string[]>;
|
|
52
|
+
/** Get server status */
|
|
53
|
+
status(): Promise<ServerStatus>;
|
|
54
|
+
/** Get graph schema (node types, edge types, indexes, constraints, statistics) */
|
|
55
|
+
schema(): Promise<GraphSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Sample a subgraph for visualization.
|
|
58
|
+
* Returns a proportionally sampled set of nodes and edges.
|
|
59
|
+
* @param options - max_nodes (default 200), labels filter, graph/tenant name
|
|
60
|
+
*/
|
|
61
|
+
sample(options?: SampleRequest): Promise<SampleResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Import nodes from CSV content.
|
|
64
|
+
* @param csvContent - Raw CSV string (first row = headers)
|
|
65
|
+
* @param label - Node label to assign
|
|
66
|
+
* @param options - Optional: idColumn, delimiter
|
|
67
|
+
*/
|
|
68
|
+
importCsv(csvContent: string, label: string, options?: {
|
|
69
|
+
idColumn?: string;
|
|
70
|
+
delimiter?: string;
|
|
71
|
+
}): Promise<CsvImportResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Import nodes from JSON objects.
|
|
74
|
+
* @param label - Node label to assign
|
|
75
|
+
* @param nodes - Array of objects, each becoming a node
|
|
76
|
+
*/
|
|
77
|
+
importJson(label: string, nodes: Record<string, unknown>[]): Promise<JsonImportResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Execute a multi-statement Cypher script.
|
|
80
|
+
* Each semicolon-separated statement is executed in order.
|
|
81
|
+
*/
|
|
82
|
+
executeScript(script: string, graph?: string): Promise<QueryResult[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Translate a natural-language question into Cypher and execute it.
|
|
85
|
+
* Requires the server to have NLQ enabled.
|
|
86
|
+
*/
|
|
87
|
+
nlq(question: string, graph?: string): Promise<QueryResult>;
|
|
88
|
+
/** Ping the server */
|
|
89
|
+
ping(): Promise<string>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { HttpTransport } from "./http-client.js";
|
|
2
|
+
const DEFAULT_URL = "http://localhost:8080";
|
|
3
|
+
/**
|
|
4
|
+
* Client for the Graphmind Graph Database.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const client = new GraphmindClient({ url: "http://localhost:8080" });
|
|
9
|
+
*
|
|
10
|
+
* // Create data
|
|
11
|
+
* await client.query('CREATE (n:Person {name: "Alice"})');
|
|
12
|
+
*
|
|
13
|
+
* // Query data
|
|
14
|
+
* const result = await client.queryReadonly("MATCH (n:Person) RETURN n.name");
|
|
15
|
+
* console.log(result.records);
|
|
16
|
+
*
|
|
17
|
+
* // Schema introspection
|
|
18
|
+
* const schema = await client.schema();
|
|
19
|
+
* console.log(schema.node_types);
|
|
20
|
+
*
|
|
21
|
+
* // EXPLAIN / PROFILE
|
|
22
|
+
* const plan = await client.explain("MATCH (n:Person) RETURN n");
|
|
23
|
+
* const profile = await client.profile("MATCH (n:Person) RETURN n");
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class GraphmindClient {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
const url = options?.url ?? DEFAULT_URL;
|
|
29
|
+
this.defaultGraph = options?.graph ?? "default";
|
|
30
|
+
const headers = {};
|
|
31
|
+
if (options?.token) {
|
|
32
|
+
headers["Authorization"] = `Bearer ${options.token}`;
|
|
33
|
+
}
|
|
34
|
+
this.http = new HttpTransport(url, headers);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Connect to a Graphmind server via HTTP.
|
|
38
|
+
* Factory method for a more readable API.
|
|
39
|
+
*/
|
|
40
|
+
static connectHttp(url = DEFAULT_URL) {
|
|
41
|
+
return new GraphmindClient({ url });
|
|
42
|
+
}
|
|
43
|
+
/** Execute a read-write Cypher query */
|
|
44
|
+
async query(cypher, graph = "default") {
|
|
45
|
+
return this.http.query(cypher, graph);
|
|
46
|
+
}
|
|
47
|
+
/** Execute a read-only Cypher query */
|
|
48
|
+
async queryReadonly(cypher, graph = "default") {
|
|
49
|
+
return this.http.query(cypher, graph);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Return the EXPLAIN plan for a Cypher query without executing it.
|
|
53
|
+
* Returns the plan as text rows in the QueryResult records.
|
|
54
|
+
*/
|
|
55
|
+
async explain(cypher, graph = "default") {
|
|
56
|
+
const prefixed = cypher.trimStart().toUpperCase().startsWith("EXPLAIN")
|
|
57
|
+
? cypher
|
|
58
|
+
: `EXPLAIN ${cypher}`;
|
|
59
|
+
return this.http.query(prefixed, graph);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a Cypher query with PROFILE instrumentation.
|
|
63
|
+
* Returns plan text with actual row counts and timing per operator.
|
|
64
|
+
*/
|
|
65
|
+
async profile(cypher, graph = "default") {
|
|
66
|
+
const prefixed = cypher.trimStart().toUpperCase().startsWith("PROFILE")
|
|
67
|
+
? cypher
|
|
68
|
+
: `PROFILE ${cypher}`;
|
|
69
|
+
return this.http.query(prefixed, graph);
|
|
70
|
+
}
|
|
71
|
+
/** Delete a graph (executes MATCH (n) DELETE n) */
|
|
72
|
+
async deleteGraph(graph = "default") {
|
|
73
|
+
await this.http.query("MATCH (n) DELETE n", graph);
|
|
74
|
+
}
|
|
75
|
+
/** List graphs (fetches graph name from server status) */
|
|
76
|
+
async listGraphs() {
|
|
77
|
+
const s = await this.http.status();
|
|
78
|
+
// OSS mode returns a single graph; use the status graph field if present
|
|
79
|
+
const graph = s.graph ?? "default";
|
|
80
|
+
return [graph];
|
|
81
|
+
}
|
|
82
|
+
/** Get server status */
|
|
83
|
+
async status() {
|
|
84
|
+
return this.http.status();
|
|
85
|
+
}
|
|
86
|
+
/** Get graph schema (node types, edge types, indexes, constraints, statistics) */
|
|
87
|
+
async schema() {
|
|
88
|
+
return this.http.schema();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sample a subgraph for visualization.
|
|
92
|
+
* Returns a proportionally sampled set of nodes and edges.
|
|
93
|
+
* @param options - max_nodes (default 200), labels filter, graph/tenant name
|
|
94
|
+
*/
|
|
95
|
+
async sample(options = {}) {
|
|
96
|
+
return this.http.post("/api/sample", options);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Import nodes from CSV content.
|
|
100
|
+
* @param csvContent - Raw CSV string (first row = headers)
|
|
101
|
+
* @param label - Node label to assign
|
|
102
|
+
* @param options - Optional: idColumn, delimiter
|
|
103
|
+
*/
|
|
104
|
+
async importCsv(csvContent, label, options) {
|
|
105
|
+
return this.http.importCsv(csvContent, label, options);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Import nodes from JSON objects.
|
|
109
|
+
* @param label - Node label to assign
|
|
110
|
+
* @param nodes - Array of objects, each becoming a node
|
|
111
|
+
*/
|
|
112
|
+
async importJson(label, nodes) {
|
|
113
|
+
return this.http.importJson(label, nodes);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Execute a multi-statement Cypher script.
|
|
117
|
+
* Each semicolon-separated statement is executed in order.
|
|
118
|
+
*/
|
|
119
|
+
async executeScript(script, graph = this.defaultGraph) {
|
|
120
|
+
const statements = script
|
|
121
|
+
.split(";")
|
|
122
|
+
.map((s) => s.trim())
|
|
123
|
+
.filter((s) => s.length > 0);
|
|
124
|
+
const results = [];
|
|
125
|
+
for (const stmt of statements) {
|
|
126
|
+
results.push(await this.query(stmt, graph));
|
|
127
|
+
}
|
|
128
|
+
return results;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Translate a natural-language question into Cypher and execute it.
|
|
132
|
+
* Requires the server to have NLQ enabled.
|
|
133
|
+
*/
|
|
134
|
+
async nlq(question, graph = this.defaultGraph) {
|
|
135
|
+
return this.http.post("/api/nlq", {
|
|
136
|
+
query: question,
|
|
137
|
+
graph,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** Ping the server */
|
|
141
|
+
async ping() {
|
|
142
|
+
const s = await this.status();
|
|
143
|
+
if (s.status === "healthy") {
|
|
144
|
+
return "PONG";
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`Server unhealthy: ${s.status}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { QueryResult, ServerStatus, GraphSchema, CsvImportResult, JsonImportResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP transport for the Graphmind SDK.
|
|
4
|
+
* Uses the native `fetch` API (works in Node.js 18+ and browsers).
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpTransport {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private extraHeaders;
|
|
9
|
+
constructor(baseUrl: string, extraHeaders?: Record<string, string>);
|
|
10
|
+
/** Execute a Cypher query via POST /api/query */
|
|
11
|
+
query(cypher: string, graph?: string): Promise<QueryResult>;
|
|
12
|
+
/** Get server status via GET /api/status */
|
|
13
|
+
status(): Promise<ServerStatus>;
|
|
14
|
+
/** Get graph schema via GET /api/schema */
|
|
15
|
+
schema(): Promise<GraphSchema>;
|
|
16
|
+
/** Generic POST request returning typed JSON response */
|
|
17
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
18
|
+
/** Import nodes from CSV via POST /api/import/csv (multipart) */
|
|
19
|
+
importCsv(csvContent: string, label: string, options?: {
|
|
20
|
+
idColumn?: string;
|
|
21
|
+
delimiter?: string;
|
|
22
|
+
}): Promise<CsvImportResult>;
|
|
23
|
+
/** Import nodes from JSON via POST /api/import/json */
|
|
24
|
+
importJson(label: string, nodes: Record<string, unknown>[]): Promise<JsonImportResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport for the Graphmind SDK.
|
|
3
|
+
* Uses the native `fetch` API (works in Node.js 18+ and browsers).
|
|
4
|
+
*/
|
|
5
|
+
export class HttpTransport {
|
|
6
|
+
constructor(baseUrl, extraHeaders = {}) {
|
|
7
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
8
|
+
this.extraHeaders = extraHeaders;
|
|
9
|
+
}
|
|
10
|
+
/** Execute a Cypher query via POST /api/query */
|
|
11
|
+
async query(cypher, graph = "default") {
|
|
12
|
+
const response = await fetch(`${this.baseUrl}/api/query`, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: { "Content-Type": "application/json", ...this.extraHeaders },
|
|
15
|
+
body: JSON.stringify({ query: cypher, graph }),
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
const body = (await response.json().catch(() => ({
|
|
19
|
+
error: `HTTP ${response.status}`,
|
|
20
|
+
})));
|
|
21
|
+
throw new Error(body.error || `HTTP ${response.status}`);
|
|
22
|
+
}
|
|
23
|
+
return (await response.json());
|
|
24
|
+
}
|
|
25
|
+
/** Get server status via GET /api/status */
|
|
26
|
+
async status() {
|
|
27
|
+
const response = await fetch(`${this.baseUrl}/api/status`, {
|
|
28
|
+
headers: this.extraHeaders,
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`Status endpoint returned ${response.status}`);
|
|
32
|
+
}
|
|
33
|
+
return (await response.json());
|
|
34
|
+
}
|
|
35
|
+
/** Get graph schema via GET /api/schema */
|
|
36
|
+
async schema() {
|
|
37
|
+
const response = await fetch(`${this.baseUrl}/api/schema`, {
|
|
38
|
+
headers: this.extraHeaders,
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const body = (await response.json().catch(() => ({
|
|
42
|
+
error: `HTTP ${response.status}`,
|
|
43
|
+
})));
|
|
44
|
+
throw new Error(body.error || `HTTP ${response.status}`);
|
|
45
|
+
}
|
|
46
|
+
return (await response.json());
|
|
47
|
+
}
|
|
48
|
+
/** Generic POST request returning typed JSON response */
|
|
49
|
+
async post(path, body) {
|
|
50
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: { "Content-Type": "application/json", ...this.extraHeaders },
|
|
53
|
+
body: JSON.stringify(body),
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
const err = (await response.json().catch(() => ({
|
|
57
|
+
error: `HTTP ${response.status}`,
|
|
58
|
+
})));
|
|
59
|
+
throw new Error(err.error || `HTTP ${response.status}`);
|
|
60
|
+
}
|
|
61
|
+
return (await response.json());
|
|
62
|
+
}
|
|
63
|
+
/** Import nodes from CSV via POST /api/import/csv (multipart) */
|
|
64
|
+
async importCsv(csvContent, label, options) {
|
|
65
|
+
const formData = new FormData();
|
|
66
|
+
const blob = new Blob([csvContent], { type: "text/csv" });
|
|
67
|
+
formData.append("file", blob, "import.csv");
|
|
68
|
+
formData.append("label", label);
|
|
69
|
+
if (options?.idColumn)
|
|
70
|
+
formData.append("id_column", options.idColumn);
|
|
71
|
+
if (options?.delimiter)
|
|
72
|
+
formData.append("delimiter", options.delimiter);
|
|
73
|
+
const response = await fetch(`${this.baseUrl}/api/import/csv`, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: this.extraHeaders,
|
|
76
|
+
body: formData,
|
|
77
|
+
});
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const body = (await response.json().catch(() => ({
|
|
80
|
+
error: `HTTP ${response.status}`,
|
|
81
|
+
})));
|
|
82
|
+
throw new Error(body.error || `HTTP ${response.status}`);
|
|
83
|
+
}
|
|
84
|
+
return (await response.json());
|
|
85
|
+
}
|
|
86
|
+
/** Import nodes from JSON via POST /api/import/json */
|
|
87
|
+
async importJson(label, nodes) {
|
|
88
|
+
const response = await fetch(`${this.baseUrl}/api/import/json`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: { "Content-Type": "application/json", ...this.extraHeaders },
|
|
91
|
+
body: JSON.stringify({ label, nodes }),
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
const body = (await response.json().catch(() => ({
|
|
95
|
+
error: `HTTP ${response.status}`,
|
|
96
|
+
})));
|
|
97
|
+
throw new Error(body.error || `HTTP ${response.status}`);
|
|
98
|
+
}
|
|
99
|
+
return (await response.json());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { GraphmindClient } from "./client.js";
|
|
2
|
+
export { HttpTransport } from "./http-client.js";
|
|
3
|
+
export type { SdkNode, SdkEdge, QueryResult, ServerStatus, ErrorResponse, ClientOptions, GraphSchema, NodeType, EdgeType, IndexInfo, ConstraintInfo, CsvImportResult, JsonImportResult, } from "./types.js";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** A graph node returned from a query */
|
|
2
|
+
export interface SdkNode {
|
|
3
|
+
id: string;
|
|
4
|
+
labels: string[];
|
|
5
|
+
properties: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
/** A graph edge returned from a query */
|
|
8
|
+
export interface SdkEdge {
|
|
9
|
+
id: string;
|
|
10
|
+
source: string;
|
|
11
|
+
target: string;
|
|
12
|
+
type: string;
|
|
13
|
+
properties: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/** Result of executing a Cypher query */
|
|
16
|
+
export interface QueryResult {
|
|
17
|
+
nodes: SdkNode[];
|
|
18
|
+
edges: SdkEdge[];
|
|
19
|
+
columns: string[];
|
|
20
|
+
records: unknown[][];
|
|
21
|
+
}
|
|
22
|
+
/** Server status information */
|
|
23
|
+
export interface ServerStatus {
|
|
24
|
+
status: string;
|
|
25
|
+
version: string;
|
|
26
|
+
storage: {
|
|
27
|
+
nodes: number;
|
|
28
|
+
edges: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Error response from the server */
|
|
32
|
+
export interface ErrorResponse {
|
|
33
|
+
error: string;
|
|
34
|
+
}
|
|
35
|
+
/** Node type descriptor from schema introspection */
|
|
36
|
+
export interface NodeType {
|
|
37
|
+
label: string;
|
|
38
|
+
count: number;
|
|
39
|
+
properties: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
/** Edge type descriptor from schema introspection */
|
|
42
|
+
export interface EdgeType {
|
|
43
|
+
type: string;
|
|
44
|
+
count: number;
|
|
45
|
+
source_labels: string[];
|
|
46
|
+
target_labels: string[];
|
|
47
|
+
properties: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
/** Index descriptor from schema introspection */
|
|
50
|
+
export interface IndexInfo {
|
|
51
|
+
label: string;
|
|
52
|
+
property: string;
|
|
53
|
+
type: string;
|
|
54
|
+
}
|
|
55
|
+
/** Constraint descriptor from schema introspection */
|
|
56
|
+
export interface ConstraintInfo {
|
|
57
|
+
label: string;
|
|
58
|
+
property: string;
|
|
59
|
+
type: string;
|
|
60
|
+
}
|
|
61
|
+
/** Graph schema returned by GET /api/schema */
|
|
62
|
+
export interface GraphSchema {
|
|
63
|
+
node_types: NodeType[];
|
|
64
|
+
edge_types: EdgeType[];
|
|
65
|
+
indexes: IndexInfo[];
|
|
66
|
+
constraints: ConstraintInfo[];
|
|
67
|
+
statistics: {
|
|
68
|
+
total_nodes: number;
|
|
69
|
+
total_edges: number;
|
|
70
|
+
avg_out_degree: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Request for subgraph sampling (POST /api/sample) */
|
|
74
|
+
export interface SampleRequest {
|
|
75
|
+
/** Maximum nodes to return (default: 200, max: 1000) */
|
|
76
|
+
max_nodes?: number;
|
|
77
|
+
/** Only include these node labels (empty = all) */
|
|
78
|
+
labels?: string[];
|
|
79
|
+
/** Tenant/graph name */
|
|
80
|
+
graph?: string;
|
|
81
|
+
}
|
|
82
|
+
/** A sampled node for visualization */
|
|
83
|
+
export interface SampleNode {
|
|
84
|
+
id: number;
|
|
85
|
+
label: string;
|
|
86
|
+
name: string;
|
|
87
|
+
properties: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
/** A sampled edge for visualization */
|
|
90
|
+
export interface SampleEdge {
|
|
91
|
+
id: number;
|
|
92
|
+
source: number;
|
|
93
|
+
target: number;
|
|
94
|
+
type: string;
|
|
95
|
+
properties: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
/** Result of subgraph sampling */
|
|
98
|
+
export interface SampleResult {
|
|
99
|
+
nodes: SampleNode[];
|
|
100
|
+
edges: SampleEdge[];
|
|
101
|
+
total_nodes: number;
|
|
102
|
+
total_edges: number;
|
|
103
|
+
sampled_nodes: number;
|
|
104
|
+
sampled_edges: number;
|
|
105
|
+
}
|
|
106
|
+
/** Result of CSV import */
|
|
107
|
+
export interface CsvImportResult {
|
|
108
|
+
status: string;
|
|
109
|
+
nodes_created: number;
|
|
110
|
+
label: string;
|
|
111
|
+
columns: string[];
|
|
112
|
+
}
|
|
113
|
+
/** Result of JSON import */
|
|
114
|
+
export interface JsonImportResult {
|
|
115
|
+
status: string;
|
|
116
|
+
nodes_created: number;
|
|
117
|
+
label: string;
|
|
118
|
+
}
|
|
119
|
+
/** Options for creating a client */
|
|
120
|
+
export interface ClientOptions {
|
|
121
|
+
/** Base URL for HTTP transport (default: http://localhost:8080) */
|
|
122
|
+
url?: string;
|
|
123
|
+
/** Default graph/tenant name (default: "default") */
|
|
124
|
+
graph?: string;
|
|
125
|
+
/** Bearer token for authentication */
|
|
126
|
+
token?: string;
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "graphmind-sdk",
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "TypeScript SDK for the Graphmind Graph Database",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"module": "dist/src/index.js",
|
|
8
|
+
"types": "dist/src/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/src/**/*.js",
|
|
11
|
+
"dist/src/**/*.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"test": "node --test dist/tests/*.test.js",
|
|
16
|
+
"check": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"graph",
|
|
21
|
+
"database",
|
|
22
|
+
"cypher",
|
|
23
|
+
"graphmind"
|
|
24
|
+
],
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/fab679/graphmind"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^25.3.0",
|
|
32
|
+
"typescript": "^5.3"
|
|
33
|
+
}
|
|
34
|
+
}
|