@elqnt/kg 2.1.1 → 3.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/README.md +357 -39
- package/dist/api/index.d.mts +250 -3
- package/dist/api/index.d.ts +250 -3
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/server.d.mts +219 -0
- package/dist/api/server.d.ts +219 -0
- package/dist/api/server.js +442 -0
- package/dist/api/server.js.map +1 -0
- package/dist/api/server.mjs +442 -0
- package/dist/api/server.mjs.map +1 -0
- package/dist/{chunk-4XIW5GLO.js → chunk-2TJCYLTP.js} +63 -68
- package/dist/chunk-2TJCYLTP.js.map +1 -0
- package/dist/chunk-67SUELDR.js.map +1 -1
- package/dist/chunk-7RW5MHP5.js +497 -0
- package/dist/chunk-7RW5MHP5.js.map +1 -0
- package/dist/chunk-ADIKUMMI.js +238 -0
- package/dist/chunk-ADIKUMMI.js.map +1 -0
- package/dist/chunk-CAXPQTKI.mjs +238 -0
- package/dist/chunk-CAXPQTKI.mjs.map +1 -0
- package/dist/{chunk-3AS6C7FW.mjs → chunk-HCDFJCQL.mjs} +62 -67
- package/dist/chunk-HCDFJCQL.mjs.map +1 -0
- package/dist/chunk-JZ7UXVRW.mjs +497 -0
- package/dist/chunk-JZ7UXVRW.mjs.map +1 -0
- package/dist/chunk-UCKE66GB.js.map +1 -1
- package/dist/chunk-W4XVBGE7.js.map +1 -1
- package/dist/hooks/index.d.mts +109 -4
- package/dist/hooks/index.d.ts +109 -4
- package/dist/hooks/index.js +9 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +10 -4
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -4
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/kg-designer.js.map +1 -1
- package/dist/models/kg.js.map +1 -1
- package/dist/utils/index.d.mts +277 -0
- package/dist/utils/index.d.ts +277 -0
- package/dist/utils/index.js +44 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +44 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +24 -16
- package/dist/chunk-3AS6C7FW.mjs.map +0 -1
- package/dist/chunk-4XIW5GLO.js.map +0 -1
- package/dist/chunk-7HNJUCVW.js +0 -577
- package/dist/chunk-7HNJUCVW.js.map +0 -1
- package/dist/chunk-EW3NQGUZ.mjs +0 -577
- package/dist/chunk-EW3NQGUZ.mjs.map +0 -1
package/dist/api/index.d.mts
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
2
|
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ListGraphsResult, GetGraphResult, CreateGraphRequest, CreateGraphResult, Graph, UpdateGraphResult, DeleteGraphResult, KGQuery, KGQueryResult, KGLabelInfo, KGNode, KGNodeIngestRequest, KGSyncIngestResponse, DeleteDocumentResponse } from '../models/kg.mjs';
|
|
4
|
+
import { GraphNodeResponse, GraphNodeDefinition, GraphEdgeResponse, GraphEdgeDefinition } from '../models/kg-designer.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Knowledge Graph API
|
|
7
|
+
* Knowledge Graph Browser API
|
|
8
8
|
*
|
|
9
9
|
* Browser-side API client for KG operations.
|
|
10
10
|
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { listGraphsApi, queryGraphApi } from "@elqnt/kg/api";
|
|
15
|
+
*
|
|
16
|
+
* const graphs = await listGraphsApi({ baseUrl, orgId });
|
|
17
|
+
* const result = await queryGraphApi(query, { baseUrl, orgId, graphId });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
11
21
|
*/
|
|
12
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Options for KG API calls that may include a graph ID
|
|
25
|
+
*/
|
|
13
26
|
interface KGApiOptions extends ApiClientOptions {
|
|
27
|
+
/** Optional graph ID for graph-scoped operations */
|
|
14
28
|
graphId?: string;
|
|
15
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Crawl job information
|
|
32
|
+
*/
|
|
16
33
|
interface CrawlJob {
|
|
17
34
|
id: string;
|
|
18
35
|
baseUrl: string;
|
|
@@ -23,18 +40,30 @@ interface CrawlJob {
|
|
|
23
40
|
createdAt: string;
|
|
24
41
|
updatedAt: string;
|
|
25
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Response for listing crawl jobs
|
|
45
|
+
*/
|
|
26
46
|
interface CrawlJobsListResponse {
|
|
27
47
|
jobs: CrawlJob[];
|
|
28
48
|
total: number;
|
|
29
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Response for crawl job status
|
|
52
|
+
*/
|
|
30
53
|
interface CrawlJobStatusResponse {
|
|
31
54
|
job: CrawlJob;
|
|
32
55
|
success: boolean;
|
|
33
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Response for starting a crawl job
|
|
59
|
+
*/
|
|
34
60
|
interface CrawlJobStartResponse {
|
|
35
61
|
jobId: string;
|
|
36
62
|
success: boolean;
|
|
37
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Response for listing crawled pages
|
|
66
|
+
*/
|
|
38
67
|
interface CrawledPagesResponse {
|
|
39
68
|
pages: Array<{
|
|
40
69
|
url: string;
|
|
@@ -44,24 +73,125 @@ interface CrawledPagesResponse {
|
|
|
44
73
|
}>;
|
|
45
74
|
total: number;
|
|
46
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* List all knowledge graphs for the organization
|
|
78
|
+
*
|
|
79
|
+
* @param options - API client options (baseUrl, orgId)
|
|
80
|
+
* @returns List of graphs
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const response = await listGraphsApi({ baseUrl: "http://api-gateway:80", orgId: "org-123" });
|
|
85
|
+
* if (response.data?.graphs) {
|
|
86
|
+
* console.log("Graphs:", response.data.graphs);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
47
90
|
declare function listGraphsApi(options: ApiClientOptions): Promise<ApiResponse<ListGraphsResult>>;
|
|
91
|
+
/**
|
|
92
|
+
* Get a specific knowledge graph by ID
|
|
93
|
+
*
|
|
94
|
+
* @param graphId - The graph ID
|
|
95
|
+
* @param options - API client options
|
|
96
|
+
* @returns The graph details
|
|
97
|
+
*/
|
|
48
98
|
declare function getGraphApi(graphId: string, options: ApiClientOptions): Promise<ApiResponse<GetGraphResult>>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a new knowledge graph
|
|
101
|
+
*
|
|
102
|
+
* @param graph - Graph creation request
|
|
103
|
+
* @param options - API client options
|
|
104
|
+
* @returns The created graph
|
|
105
|
+
*/
|
|
49
106
|
declare function createGraphApi(graph: CreateGraphRequest, options: ApiClientOptions): Promise<ApiResponse<CreateGraphResult>>;
|
|
107
|
+
/**
|
|
108
|
+
* Update an existing knowledge graph
|
|
109
|
+
*
|
|
110
|
+
* @param graphId - The graph ID to update
|
|
111
|
+
* @param updates - Partial graph updates
|
|
112
|
+
* @param options - API client options
|
|
113
|
+
* @returns The updated graph
|
|
114
|
+
*/
|
|
50
115
|
declare function updateGraphApi(graphId: string, updates: Partial<Graph>, options: ApiClientOptions): Promise<ApiResponse<UpdateGraphResult>>;
|
|
116
|
+
/**
|
|
117
|
+
* Delete a knowledge graph
|
|
118
|
+
*
|
|
119
|
+
* @param graphId - The graph ID to delete
|
|
120
|
+
* @param options - API client options
|
|
121
|
+
* @returns Success/failure result
|
|
122
|
+
*/
|
|
51
123
|
declare function deleteGraphApi(graphId: string, options: ApiClientOptions): Promise<ApiResponse<DeleteGraphResult>>;
|
|
124
|
+
/**
|
|
125
|
+
* Query knowledge graph nodes
|
|
126
|
+
*
|
|
127
|
+
* @param query - The KG query parameters
|
|
128
|
+
* @param options - API options including optional graphId
|
|
129
|
+
* @returns Query results with matching nodes and edges
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const result = await queryGraphApi(
|
|
134
|
+
* { label: "Person", fields: [], limit: 10, depth: 1, sortBy: "", sortOrder: "" },
|
|
135
|
+
* { baseUrl, orgId, graphId }
|
|
136
|
+
* );
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
52
139
|
declare function queryGraphApi(query: KGQuery, options: KGApiOptions): Promise<ApiResponse<KGQueryResult>>;
|
|
140
|
+
/**
|
|
141
|
+
* Get all node labels in the knowledge graph
|
|
142
|
+
*
|
|
143
|
+
* @param options - API options including optional graphId
|
|
144
|
+
* @returns List of labels with counts
|
|
145
|
+
*/
|
|
53
146
|
declare function getGraphLabelsApi(options: KGApiOptions): Promise<ApiResponse<{
|
|
54
147
|
labels: KGLabelInfo[];
|
|
55
148
|
}>>;
|
|
149
|
+
/**
|
|
150
|
+
* Get a specific KG node by ID
|
|
151
|
+
*
|
|
152
|
+
* @param nodeId - The node ID
|
|
153
|
+
* @param options - API options including optional graphId
|
|
154
|
+
* @returns The node details
|
|
155
|
+
*/
|
|
56
156
|
declare function getKGNodeApi(nodeId: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
57
157
|
node: KGNode;
|
|
58
158
|
}>>;
|
|
159
|
+
/**
|
|
160
|
+
* Ingest a new node into the knowledge graph
|
|
161
|
+
*
|
|
162
|
+
* @param node - Node ingest request
|
|
163
|
+
* @param options - API options including optional graphId
|
|
164
|
+
* @returns The created node ID
|
|
165
|
+
*/
|
|
59
166
|
declare function ingestKGNodeApi(node: KGNodeIngestRequest, options: KGApiOptions): Promise<ApiResponse<KGSyncIngestResponse>>;
|
|
167
|
+
/**
|
|
168
|
+
* Update an existing KG node
|
|
169
|
+
*
|
|
170
|
+
* @param nodeId - The node ID to update
|
|
171
|
+
* @param updates - Partial node updates
|
|
172
|
+
* @param options - API options including optional graphId
|
|
173
|
+
* @returns Success/failure result
|
|
174
|
+
*/
|
|
60
175
|
declare function updateKGNodeApi(nodeId: string, updates: Partial<KGNode>, options: KGApiOptions): Promise<ApiResponse<{
|
|
61
176
|
success: boolean;
|
|
62
177
|
metadata: ResponseMetadata;
|
|
63
178
|
}>>;
|
|
179
|
+
/**
|
|
180
|
+
* Get connection statistics for a node
|
|
181
|
+
*
|
|
182
|
+
* @param nodeId - The node ID
|
|
183
|
+
* @param edgeLabel - The edge label to filter by
|
|
184
|
+
* @param options - API options including optional graphId
|
|
185
|
+
* @returns Connection counts by label
|
|
186
|
+
*/
|
|
64
187
|
declare function getNodeConnectionStatsApi(nodeId: string, edgeLabel: string, options: KGApiOptions): Promise<ApiResponse<Record<string, number>>>;
|
|
188
|
+
/**
|
|
189
|
+
* Ingest a document into the knowledge graph
|
|
190
|
+
*
|
|
191
|
+
* @param document - Document to ingest
|
|
192
|
+
* @param options - API options including optional graphId
|
|
193
|
+
* @returns Success/failure result
|
|
194
|
+
*/
|
|
65
195
|
declare function ingestDocumentApi(document: {
|
|
66
196
|
id: string;
|
|
67
197
|
title: string;
|
|
@@ -72,39 +202,156 @@ declare function ingestDocumentApi(document: {
|
|
|
72
202
|
success: boolean;
|
|
73
203
|
metadata: ResponseMetadata;
|
|
74
204
|
}>>;
|
|
205
|
+
/**
|
|
206
|
+
* Delete a document from the knowledge graph
|
|
207
|
+
*
|
|
208
|
+
* @param documentId - The document ID to delete
|
|
209
|
+
* @param options - API options including optional graphId
|
|
210
|
+
* @returns Deletion result with counts
|
|
211
|
+
*/
|
|
75
212
|
declare function deleteKGDocumentApi(documentId: string, options: KGApiOptions): Promise<ApiResponse<DeleteDocumentResponse>>;
|
|
213
|
+
/**
|
|
214
|
+
* Optimize the knowledge graph
|
|
215
|
+
*
|
|
216
|
+
* @param options - API options including optional graphId
|
|
217
|
+
* @returns Success/failure result
|
|
218
|
+
*/
|
|
76
219
|
declare function optimizeGraphApi(options: KGApiOptions): Promise<ApiResponse<{
|
|
77
220
|
success: boolean;
|
|
78
221
|
metadata: ResponseMetadata;
|
|
79
222
|
}>>;
|
|
223
|
+
/**
|
|
224
|
+
* List all node definitions in the graph designer
|
|
225
|
+
*
|
|
226
|
+
* @param options - API options including optional graphId
|
|
227
|
+
* @returns List of node definitions
|
|
228
|
+
*/
|
|
80
229
|
declare function listDesignerNodesApi(options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
230
|
+
/**
|
|
231
|
+
* Get a specific node definition by label
|
|
232
|
+
*
|
|
233
|
+
* @param label - The node label
|
|
234
|
+
* @param options - API options including optional graphId
|
|
235
|
+
* @returns The node definition
|
|
236
|
+
*/
|
|
81
237
|
declare function getDesignerNodeApi(label: string, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
238
|
+
/**
|
|
239
|
+
* Create a new node definition
|
|
240
|
+
*
|
|
241
|
+
* @param node - Node definition to create
|
|
242
|
+
* @param options - API options including optional graphId
|
|
243
|
+
* @returns The created node definition
|
|
244
|
+
*/
|
|
82
245
|
declare function createDesignerNodeApi(node: Omit<GraphNodeDefinition, "createdAt" | "updatedAt">, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
246
|
+
/**
|
|
247
|
+
* Update an existing node definition
|
|
248
|
+
*
|
|
249
|
+
* @param label - The node label to update
|
|
250
|
+
* @param node - Partial node definition updates
|
|
251
|
+
* @param options - API options including optional graphId
|
|
252
|
+
* @returns The updated node definition
|
|
253
|
+
*/
|
|
83
254
|
declare function updateDesignerNodeApi(label: string, node: Partial<GraphNodeDefinition>, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
255
|
+
/**
|
|
256
|
+
* Delete a node definition
|
|
257
|
+
*
|
|
258
|
+
* @param label - The node label to delete
|
|
259
|
+
* @param options - API options including optional graphId
|
|
260
|
+
* @returns Success/failure result
|
|
261
|
+
*/
|
|
84
262
|
declare function deleteDesignerNodeApi(label: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
85
263
|
success: boolean;
|
|
86
264
|
metadata: ResponseMetadata;
|
|
87
265
|
}>>;
|
|
266
|
+
/**
|
|
267
|
+
* List all edge definitions in the graph designer
|
|
268
|
+
*
|
|
269
|
+
* @param options - API options including optional graphId
|
|
270
|
+
* @returns List of edge definitions
|
|
271
|
+
*/
|
|
88
272
|
declare function listDesignerEdgesApi(options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
273
|
+
/**
|
|
274
|
+
* Get a specific edge definition by label
|
|
275
|
+
*
|
|
276
|
+
* @param label - The edge label
|
|
277
|
+
* @param options - API options including optional graphId
|
|
278
|
+
* @returns The edge definition
|
|
279
|
+
*/
|
|
89
280
|
declare function getDesignerEdgeApi(label: string, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
281
|
+
/**
|
|
282
|
+
* Create a new edge definition
|
|
283
|
+
*
|
|
284
|
+
* @param edge - Edge definition to create
|
|
285
|
+
* @param options - API options including optional graphId
|
|
286
|
+
* @returns The created edge definition
|
|
287
|
+
*/
|
|
90
288
|
declare function createDesignerEdgeApi(edge: Omit<GraphEdgeDefinition, "createdAt" | "updatedAt">, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
289
|
+
/**
|
|
290
|
+
* Update an existing edge definition
|
|
291
|
+
*
|
|
292
|
+
* @param label - The edge label to update
|
|
293
|
+
* @param edge - Partial edge definition updates
|
|
294
|
+
* @param options - API options including optional graphId
|
|
295
|
+
* @returns The updated edge definition
|
|
296
|
+
*/
|
|
91
297
|
declare function updateDesignerEdgeApi(label: string, edge: Partial<GraphEdgeDefinition>, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
298
|
+
/**
|
|
299
|
+
* Delete an edge definition
|
|
300
|
+
*
|
|
301
|
+
* @param label - The edge label to delete
|
|
302
|
+
* @param options - API options including optional graphId
|
|
303
|
+
* @returns Success/failure result
|
|
304
|
+
*/
|
|
92
305
|
declare function deleteDesignerEdgeApi(label: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
93
306
|
success: boolean;
|
|
94
307
|
metadata: ResponseMetadata;
|
|
95
308
|
}>>;
|
|
309
|
+
/**
|
|
310
|
+
* List crawl jobs
|
|
311
|
+
*
|
|
312
|
+
* @param options - API options including optional graphId, limit, offset, status
|
|
313
|
+
* @returns List of crawl jobs with total count
|
|
314
|
+
*/
|
|
96
315
|
declare function listCrawlJobsApi(options: KGApiOptions & {
|
|
97
316
|
limit?: number;
|
|
98
317
|
offset?: number;
|
|
99
318
|
status?: string;
|
|
100
319
|
}): Promise<ApiResponse<CrawlJobsListResponse>>;
|
|
320
|
+
/**
|
|
321
|
+
* Start a new crawl job
|
|
322
|
+
*
|
|
323
|
+
* @param params - Crawl job parameters
|
|
324
|
+
* @param options - API options including optional graphId
|
|
325
|
+
* @returns The created job ID
|
|
326
|
+
*/
|
|
101
327
|
declare function startCrawlJobApi(params: {
|
|
102
328
|
baseUrl: string;
|
|
103
329
|
depth: number;
|
|
104
330
|
maxPages: number;
|
|
105
331
|
}, options: KGApiOptions): Promise<ApiResponse<CrawlJobStartResponse>>;
|
|
332
|
+
/**
|
|
333
|
+
* Get crawl job status
|
|
334
|
+
*
|
|
335
|
+
* @param jobId - The job ID
|
|
336
|
+
* @param options - API options including optional graphId
|
|
337
|
+
* @returns The job status
|
|
338
|
+
*/
|
|
106
339
|
declare function getCrawlJobStatusApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawlJobStatusResponse>>;
|
|
340
|
+
/**
|
|
341
|
+
* Cancel a crawl job
|
|
342
|
+
*
|
|
343
|
+
* @param jobId - The job ID to cancel
|
|
344
|
+
* @param options - API options including optional graphId
|
|
345
|
+
* @returns The updated job status
|
|
346
|
+
*/
|
|
107
347
|
declare function cancelCrawlJobApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawlJobStatusResponse>>;
|
|
348
|
+
/**
|
|
349
|
+
* Get pages crawled by a job
|
|
350
|
+
*
|
|
351
|
+
* @param jobId - The job ID
|
|
352
|
+
* @param options - API options including optional graphId
|
|
353
|
+
* @returns List of crawled pages
|
|
354
|
+
*/
|
|
108
355
|
declare function getCrawledPagesApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawledPagesResponse>>;
|
|
109
356
|
|
|
110
357
|
export { type CrawlJob, type CrawlJobStartResponse, type CrawlJobStatusResponse, type CrawlJobsListResponse, type CrawledPagesResponse, type KGApiOptions, cancelCrawlJobApi, createDesignerEdgeApi, createDesignerNodeApi, createGraphApi, deleteDesignerEdgeApi, deleteDesignerNodeApi, deleteGraphApi, deleteKGDocumentApi, getCrawlJobStatusApi, getCrawledPagesApi, getDesignerEdgeApi, getDesignerNodeApi, getGraphApi, getGraphLabelsApi, getKGNodeApi, getNodeConnectionStatsApi, ingestDocumentApi, ingestKGNodeApi, listCrawlJobsApi, listDesignerEdgesApi, listDesignerNodesApi, listGraphsApi, optimizeGraphApi, queryGraphApi, startCrawlJobApi, updateDesignerEdgeApi, updateDesignerNodeApi, updateGraphApi, updateKGNodeApi };
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
|
|
2
2
|
import { ResponseMetadata } from '@elqnt/types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ListGraphsResult, GetGraphResult, CreateGraphRequest, CreateGraphResult, Graph, UpdateGraphResult, DeleteGraphResult, KGQuery, KGQueryResult, KGLabelInfo, KGNode, KGNodeIngestRequest, KGSyncIngestResponse, DeleteDocumentResponse } from '../models/kg.js';
|
|
4
|
+
import { GraphNodeResponse, GraphNodeDefinition, GraphEdgeResponse, GraphEdgeDefinition } from '../models/kg-designer.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Knowledge Graph API
|
|
7
|
+
* Knowledge Graph Browser API
|
|
8
8
|
*
|
|
9
9
|
* Browser-side API client for KG operations.
|
|
10
10
|
* Uses @elqnt/api-client for HTTP requests with automatic token management.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { listGraphsApi, queryGraphApi } from "@elqnt/kg/api";
|
|
15
|
+
*
|
|
16
|
+
* const graphs = await listGraphsApi({ baseUrl, orgId });
|
|
17
|
+
* const result = await queryGraphApi(query, { baseUrl, orgId, graphId });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
11
21
|
*/
|
|
12
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Options for KG API calls that may include a graph ID
|
|
25
|
+
*/
|
|
13
26
|
interface KGApiOptions extends ApiClientOptions {
|
|
27
|
+
/** Optional graph ID for graph-scoped operations */
|
|
14
28
|
graphId?: string;
|
|
15
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Crawl job information
|
|
32
|
+
*/
|
|
16
33
|
interface CrawlJob {
|
|
17
34
|
id: string;
|
|
18
35
|
baseUrl: string;
|
|
@@ -23,18 +40,30 @@ interface CrawlJob {
|
|
|
23
40
|
createdAt: string;
|
|
24
41
|
updatedAt: string;
|
|
25
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Response for listing crawl jobs
|
|
45
|
+
*/
|
|
26
46
|
interface CrawlJobsListResponse {
|
|
27
47
|
jobs: CrawlJob[];
|
|
28
48
|
total: number;
|
|
29
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Response for crawl job status
|
|
52
|
+
*/
|
|
30
53
|
interface CrawlJobStatusResponse {
|
|
31
54
|
job: CrawlJob;
|
|
32
55
|
success: boolean;
|
|
33
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Response for starting a crawl job
|
|
59
|
+
*/
|
|
34
60
|
interface CrawlJobStartResponse {
|
|
35
61
|
jobId: string;
|
|
36
62
|
success: boolean;
|
|
37
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Response for listing crawled pages
|
|
66
|
+
*/
|
|
38
67
|
interface CrawledPagesResponse {
|
|
39
68
|
pages: Array<{
|
|
40
69
|
url: string;
|
|
@@ -44,24 +73,125 @@ interface CrawledPagesResponse {
|
|
|
44
73
|
}>;
|
|
45
74
|
total: number;
|
|
46
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* List all knowledge graphs for the organization
|
|
78
|
+
*
|
|
79
|
+
* @param options - API client options (baseUrl, orgId)
|
|
80
|
+
* @returns List of graphs
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const response = await listGraphsApi({ baseUrl: "http://api-gateway:80", orgId: "org-123" });
|
|
85
|
+
* if (response.data?.graphs) {
|
|
86
|
+
* console.log("Graphs:", response.data.graphs);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
47
90
|
declare function listGraphsApi(options: ApiClientOptions): Promise<ApiResponse<ListGraphsResult>>;
|
|
91
|
+
/**
|
|
92
|
+
* Get a specific knowledge graph by ID
|
|
93
|
+
*
|
|
94
|
+
* @param graphId - The graph ID
|
|
95
|
+
* @param options - API client options
|
|
96
|
+
* @returns The graph details
|
|
97
|
+
*/
|
|
48
98
|
declare function getGraphApi(graphId: string, options: ApiClientOptions): Promise<ApiResponse<GetGraphResult>>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a new knowledge graph
|
|
101
|
+
*
|
|
102
|
+
* @param graph - Graph creation request
|
|
103
|
+
* @param options - API client options
|
|
104
|
+
* @returns The created graph
|
|
105
|
+
*/
|
|
49
106
|
declare function createGraphApi(graph: CreateGraphRequest, options: ApiClientOptions): Promise<ApiResponse<CreateGraphResult>>;
|
|
107
|
+
/**
|
|
108
|
+
* Update an existing knowledge graph
|
|
109
|
+
*
|
|
110
|
+
* @param graphId - The graph ID to update
|
|
111
|
+
* @param updates - Partial graph updates
|
|
112
|
+
* @param options - API client options
|
|
113
|
+
* @returns The updated graph
|
|
114
|
+
*/
|
|
50
115
|
declare function updateGraphApi(graphId: string, updates: Partial<Graph>, options: ApiClientOptions): Promise<ApiResponse<UpdateGraphResult>>;
|
|
116
|
+
/**
|
|
117
|
+
* Delete a knowledge graph
|
|
118
|
+
*
|
|
119
|
+
* @param graphId - The graph ID to delete
|
|
120
|
+
* @param options - API client options
|
|
121
|
+
* @returns Success/failure result
|
|
122
|
+
*/
|
|
51
123
|
declare function deleteGraphApi(graphId: string, options: ApiClientOptions): Promise<ApiResponse<DeleteGraphResult>>;
|
|
124
|
+
/**
|
|
125
|
+
* Query knowledge graph nodes
|
|
126
|
+
*
|
|
127
|
+
* @param query - The KG query parameters
|
|
128
|
+
* @param options - API options including optional graphId
|
|
129
|
+
* @returns Query results with matching nodes and edges
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const result = await queryGraphApi(
|
|
134
|
+
* { label: "Person", fields: [], limit: 10, depth: 1, sortBy: "", sortOrder: "" },
|
|
135
|
+
* { baseUrl, orgId, graphId }
|
|
136
|
+
* );
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
52
139
|
declare function queryGraphApi(query: KGQuery, options: KGApiOptions): Promise<ApiResponse<KGQueryResult>>;
|
|
140
|
+
/**
|
|
141
|
+
* Get all node labels in the knowledge graph
|
|
142
|
+
*
|
|
143
|
+
* @param options - API options including optional graphId
|
|
144
|
+
* @returns List of labels with counts
|
|
145
|
+
*/
|
|
53
146
|
declare function getGraphLabelsApi(options: KGApiOptions): Promise<ApiResponse<{
|
|
54
147
|
labels: KGLabelInfo[];
|
|
55
148
|
}>>;
|
|
149
|
+
/**
|
|
150
|
+
* Get a specific KG node by ID
|
|
151
|
+
*
|
|
152
|
+
* @param nodeId - The node ID
|
|
153
|
+
* @param options - API options including optional graphId
|
|
154
|
+
* @returns The node details
|
|
155
|
+
*/
|
|
56
156
|
declare function getKGNodeApi(nodeId: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
57
157
|
node: KGNode;
|
|
58
158
|
}>>;
|
|
159
|
+
/**
|
|
160
|
+
* Ingest a new node into the knowledge graph
|
|
161
|
+
*
|
|
162
|
+
* @param node - Node ingest request
|
|
163
|
+
* @param options - API options including optional graphId
|
|
164
|
+
* @returns The created node ID
|
|
165
|
+
*/
|
|
59
166
|
declare function ingestKGNodeApi(node: KGNodeIngestRequest, options: KGApiOptions): Promise<ApiResponse<KGSyncIngestResponse>>;
|
|
167
|
+
/**
|
|
168
|
+
* Update an existing KG node
|
|
169
|
+
*
|
|
170
|
+
* @param nodeId - The node ID to update
|
|
171
|
+
* @param updates - Partial node updates
|
|
172
|
+
* @param options - API options including optional graphId
|
|
173
|
+
* @returns Success/failure result
|
|
174
|
+
*/
|
|
60
175
|
declare function updateKGNodeApi(nodeId: string, updates: Partial<KGNode>, options: KGApiOptions): Promise<ApiResponse<{
|
|
61
176
|
success: boolean;
|
|
62
177
|
metadata: ResponseMetadata;
|
|
63
178
|
}>>;
|
|
179
|
+
/**
|
|
180
|
+
* Get connection statistics for a node
|
|
181
|
+
*
|
|
182
|
+
* @param nodeId - The node ID
|
|
183
|
+
* @param edgeLabel - The edge label to filter by
|
|
184
|
+
* @param options - API options including optional graphId
|
|
185
|
+
* @returns Connection counts by label
|
|
186
|
+
*/
|
|
64
187
|
declare function getNodeConnectionStatsApi(nodeId: string, edgeLabel: string, options: KGApiOptions): Promise<ApiResponse<Record<string, number>>>;
|
|
188
|
+
/**
|
|
189
|
+
* Ingest a document into the knowledge graph
|
|
190
|
+
*
|
|
191
|
+
* @param document - Document to ingest
|
|
192
|
+
* @param options - API options including optional graphId
|
|
193
|
+
* @returns Success/failure result
|
|
194
|
+
*/
|
|
65
195
|
declare function ingestDocumentApi(document: {
|
|
66
196
|
id: string;
|
|
67
197
|
title: string;
|
|
@@ -72,39 +202,156 @@ declare function ingestDocumentApi(document: {
|
|
|
72
202
|
success: boolean;
|
|
73
203
|
metadata: ResponseMetadata;
|
|
74
204
|
}>>;
|
|
205
|
+
/**
|
|
206
|
+
* Delete a document from the knowledge graph
|
|
207
|
+
*
|
|
208
|
+
* @param documentId - The document ID to delete
|
|
209
|
+
* @param options - API options including optional graphId
|
|
210
|
+
* @returns Deletion result with counts
|
|
211
|
+
*/
|
|
75
212
|
declare function deleteKGDocumentApi(documentId: string, options: KGApiOptions): Promise<ApiResponse<DeleteDocumentResponse>>;
|
|
213
|
+
/**
|
|
214
|
+
* Optimize the knowledge graph
|
|
215
|
+
*
|
|
216
|
+
* @param options - API options including optional graphId
|
|
217
|
+
* @returns Success/failure result
|
|
218
|
+
*/
|
|
76
219
|
declare function optimizeGraphApi(options: KGApiOptions): Promise<ApiResponse<{
|
|
77
220
|
success: boolean;
|
|
78
221
|
metadata: ResponseMetadata;
|
|
79
222
|
}>>;
|
|
223
|
+
/**
|
|
224
|
+
* List all node definitions in the graph designer
|
|
225
|
+
*
|
|
226
|
+
* @param options - API options including optional graphId
|
|
227
|
+
* @returns List of node definitions
|
|
228
|
+
*/
|
|
80
229
|
declare function listDesignerNodesApi(options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
230
|
+
/**
|
|
231
|
+
* Get a specific node definition by label
|
|
232
|
+
*
|
|
233
|
+
* @param label - The node label
|
|
234
|
+
* @param options - API options including optional graphId
|
|
235
|
+
* @returns The node definition
|
|
236
|
+
*/
|
|
81
237
|
declare function getDesignerNodeApi(label: string, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
238
|
+
/**
|
|
239
|
+
* Create a new node definition
|
|
240
|
+
*
|
|
241
|
+
* @param node - Node definition to create
|
|
242
|
+
* @param options - API options including optional graphId
|
|
243
|
+
* @returns The created node definition
|
|
244
|
+
*/
|
|
82
245
|
declare function createDesignerNodeApi(node: Omit<GraphNodeDefinition, "createdAt" | "updatedAt">, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
246
|
+
/**
|
|
247
|
+
* Update an existing node definition
|
|
248
|
+
*
|
|
249
|
+
* @param label - The node label to update
|
|
250
|
+
* @param node - Partial node definition updates
|
|
251
|
+
* @param options - API options including optional graphId
|
|
252
|
+
* @returns The updated node definition
|
|
253
|
+
*/
|
|
83
254
|
declare function updateDesignerNodeApi(label: string, node: Partial<GraphNodeDefinition>, options: KGApiOptions): Promise<ApiResponse<GraphNodeResponse>>;
|
|
255
|
+
/**
|
|
256
|
+
* Delete a node definition
|
|
257
|
+
*
|
|
258
|
+
* @param label - The node label to delete
|
|
259
|
+
* @param options - API options including optional graphId
|
|
260
|
+
* @returns Success/failure result
|
|
261
|
+
*/
|
|
84
262
|
declare function deleteDesignerNodeApi(label: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
85
263
|
success: boolean;
|
|
86
264
|
metadata: ResponseMetadata;
|
|
87
265
|
}>>;
|
|
266
|
+
/**
|
|
267
|
+
* List all edge definitions in the graph designer
|
|
268
|
+
*
|
|
269
|
+
* @param options - API options including optional graphId
|
|
270
|
+
* @returns List of edge definitions
|
|
271
|
+
*/
|
|
88
272
|
declare function listDesignerEdgesApi(options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
273
|
+
/**
|
|
274
|
+
* Get a specific edge definition by label
|
|
275
|
+
*
|
|
276
|
+
* @param label - The edge label
|
|
277
|
+
* @param options - API options including optional graphId
|
|
278
|
+
* @returns The edge definition
|
|
279
|
+
*/
|
|
89
280
|
declare function getDesignerEdgeApi(label: string, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
281
|
+
/**
|
|
282
|
+
* Create a new edge definition
|
|
283
|
+
*
|
|
284
|
+
* @param edge - Edge definition to create
|
|
285
|
+
* @param options - API options including optional graphId
|
|
286
|
+
* @returns The created edge definition
|
|
287
|
+
*/
|
|
90
288
|
declare function createDesignerEdgeApi(edge: Omit<GraphEdgeDefinition, "createdAt" | "updatedAt">, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
289
|
+
/**
|
|
290
|
+
* Update an existing edge definition
|
|
291
|
+
*
|
|
292
|
+
* @param label - The edge label to update
|
|
293
|
+
* @param edge - Partial edge definition updates
|
|
294
|
+
* @param options - API options including optional graphId
|
|
295
|
+
* @returns The updated edge definition
|
|
296
|
+
*/
|
|
91
297
|
declare function updateDesignerEdgeApi(label: string, edge: Partial<GraphEdgeDefinition>, options: KGApiOptions): Promise<ApiResponse<GraphEdgeResponse>>;
|
|
298
|
+
/**
|
|
299
|
+
* Delete an edge definition
|
|
300
|
+
*
|
|
301
|
+
* @param label - The edge label to delete
|
|
302
|
+
* @param options - API options including optional graphId
|
|
303
|
+
* @returns Success/failure result
|
|
304
|
+
*/
|
|
92
305
|
declare function deleteDesignerEdgeApi(label: string, options: KGApiOptions): Promise<ApiResponse<{
|
|
93
306
|
success: boolean;
|
|
94
307
|
metadata: ResponseMetadata;
|
|
95
308
|
}>>;
|
|
309
|
+
/**
|
|
310
|
+
* List crawl jobs
|
|
311
|
+
*
|
|
312
|
+
* @param options - API options including optional graphId, limit, offset, status
|
|
313
|
+
* @returns List of crawl jobs with total count
|
|
314
|
+
*/
|
|
96
315
|
declare function listCrawlJobsApi(options: KGApiOptions & {
|
|
97
316
|
limit?: number;
|
|
98
317
|
offset?: number;
|
|
99
318
|
status?: string;
|
|
100
319
|
}): Promise<ApiResponse<CrawlJobsListResponse>>;
|
|
320
|
+
/**
|
|
321
|
+
* Start a new crawl job
|
|
322
|
+
*
|
|
323
|
+
* @param params - Crawl job parameters
|
|
324
|
+
* @param options - API options including optional graphId
|
|
325
|
+
* @returns The created job ID
|
|
326
|
+
*/
|
|
101
327
|
declare function startCrawlJobApi(params: {
|
|
102
328
|
baseUrl: string;
|
|
103
329
|
depth: number;
|
|
104
330
|
maxPages: number;
|
|
105
331
|
}, options: KGApiOptions): Promise<ApiResponse<CrawlJobStartResponse>>;
|
|
332
|
+
/**
|
|
333
|
+
* Get crawl job status
|
|
334
|
+
*
|
|
335
|
+
* @param jobId - The job ID
|
|
336
|
+
* @param options - API options including optional graphId
|
|
337
|
+
* @returns The job status
|
|
338
|
+
*/
|
|
106
339
|
declare function getCrawlJobStatusApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawlJobStatusResponse>>;
|
|
340
|
+
/**
|
|
341
|
+
* Cancel a crawl job
|
|
342
|
+
*
|
|
343
|
+
* @param jobId - The job ID to cancel
|
|
344
|
+
* @param options - API options including optional graphId
|
|
345
|
+
* @returns The updated job status
|
|
346
|
+
*/
|
|
107
347
|
declare function cancelCrawlJobApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawlJobStatusResponse>>;
|
|
348
|
+
/**
|
|
349
|
+
* Get pages crawled by a job
|
|
350
|
+
*
|
|
351
|
+
* @param jobId - The job ID
|
|
352
|
+
* @param options - API options including optional graphId
|
|
353
|
+
* @returns List of crawled pages
|
|
354
|
+
*/
|
|
108
355
|
declare function getCrawledPagesApi(jobId: string, options: KGApiOptions): Promise<ApiResponse<CrawledPagesResponse>>;
|
|
109
356
|
|
|
110
357
|
export { type CrawlJob, type CrawlJobStartResponse, type CrawlJobStatusResponse, type CrawlJobsListResponse, type CrawledPagesResponse, type KGApiOptions, cancelCrawlJobApi, createDesignerEdgeApi, createDesignerNodeApi, createGraphApi, deleteDesignerEdgeApi, deleteDesignerNodeApi, deleteGraphApi, deleteKGDocumentApi, getCrawlJobStatusApi, getCrawledPagesApi, getDesignerEdgeApi, getDesignerNodeApi, getGraphApi, getGraphLabelsApi, getKGNodeApi, getNodeConnectionStatsApi, ingestDocumentApi, ingestKGNodeApi, listCrawlJobsApi, listDesignerEdgesApi, listDesignerNodesApi, listGraphsApi, optimizeGraphApi, queryGraphApi, startCrawlJobApi, updateDesignerEdgeApi, updateDesignerNodeApi, updateGraphApi, updateKGNodeApi };
|