@elqnt/kg 2.1.1 → 3.0.1
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 +248 -1
- package/dist/api/index.d.ts +248 -1
- package/dist/api/index.js +2 -2
- 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-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/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/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 +15 -5
- 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
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunk2TJCYLTPjs = require('./chunk-2TJCYLTP.js');
|
|
28
|
+
|
|
29
|
+
// hooks/index.ts
|
|
30
|
+
var _react = require('react');
|
|
31
|
+
|
|
32
|
+
// hooks/use-async.ts
|
|
33
|
+
|
|
34
|
+
function extractFromResponse(response, extractor, defaultValue) {
|
|
35
|
+
if (response.error) {
|
|
36
|
+
return [defaultValue, response.error];
|
|
37
|
+
}
|
|
38
|
+
if (!response.data) {
|
|
39
|
+
return [defaultValue, null];
|
|
40
|
+
}
|
|
41
|
+
return [extractor(response.data), null];
|
|
42
|
+
}
|
|
43
|
+
function useAsync(asyncFn, options) {
|
|
44
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
45
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
46
|
+
const requestCount = _react.useRef.call(void 0, 0);
|
|
47
|
+
const execute = _react.useCallback.call(void 0,
|
|
48
|
+
async (...args) => {
|
|
49
|
+
requestCount.current += 1;
|
|
50
|
+
setLoading(true);
|
|
51
|
+
setError(null);
|
|
52
|
+
try {
|
|
53
|
+
const result = await asyncFn(...args);
|
|
54
|
+
return result;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
const message = err instanceof Error ? err.message : "An error occurred";
|
|
57
|
+
setError(message);
|
|
58
|
+
_optionalChain([options, 'optionalAccess', _ => _.onError, 'optionalCall', _2 => _2(message)]);
|
|
59
|
+
throw err;
|
|
60
|
+
} finally {
|
|
61
|
+
requestCount.current -= 1;
|
|
62
|
+
if (requestCount.current === 0) {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[asyncFn, options]
|
|
68
|
+
);
|
|
69
|
+
const clearError = _react.useCallback.call(void 0, () => {
|
|
70
|
+
setError(null);
|
|
71
|
+
}, []);
|
|
72
|
+
return { execute, loading, error, clearError };
|
|
73
|
+
}
|
|
74
|
+
function useApiAsync(asyncFn, extractor, defaultValue, options) {
|
|
75
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
76
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
77
|
+
const requestCount = _react.useRef.call(void 0, 0);
|
|
78
|
+
const execute = _react.useCallback.call(void 0,
|
|
79
|
+
async (...args) => {
|
|
80
|
+
requestCount.current += 1;
|
|
81
|
+
setLoading(true);
|
|
82
|
+
setError(null);
|
|
83
|
+
try {
|
|
84
|
+
const response = await asyncFn(...args);
|
|
85
|
+
const [result, errorMessage] = extractFromResponse(response, extractor, defaultValue);
|
|
86
|
+
if (errorMessage) {
|
|
87
|
+
setError(errorMessage);
|
|
88
|
+
_optionalChain([options, 'optionalAccess', _3 => _3.onError, 'optionalCall', _4 => _4(errorMessage)]);
|
|
89
|
+
return defaultValue;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
const message = err instanceof Error ? err.message : "An error occurred";
|
|
94
|
+
setError(message);
|
|
95
|
+
_optionalChain([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(message)]);
|
|
96
|
+
return defaultValue;
|
|
97
|
+
} finally {
|
|
98
|
+
requestCount.current -= 1;
|
|
99
|
+
if (requestCount.current === 0) {
|
|
100
|
+
setLoading(false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
[asyncFn, extractor, defaultValue, options]
|
|
105
|
+
);
|
|
106
|
+
const clearError = _react.useCallback.call(void 0, () => {
|
|
107
|
+
setError(null);
|
|
108
|
+
}, []);
|
|
109
|
+
return { execute, loading, error, clearError };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// hooks/use-options-ref.ts
|
|
113
|
+
|
|
114
|
+
function useOptionsRef(options) {
|
|
115
|
+
const ref = _react.useRef.call(void 0, options);
|
|
116
|
+
_react.useEffect.call(void 0, () => {
|
|
117
|
+
ref.current = options;
|
|
118
|
+
}, [options]);
|
|
119
|
+
return ref;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// hooks/index.ts
|
|
123
|
+
function useGraphs(options) {
|
|
124
|
+
const optionsRef = useOptionsRef(options);
|
|
125
|
+
const {
|
|
126
|
+
execute: listGraphs,
|
|
127
|
+
loading: listLoading,
|
|
128
|
+
error: listError
|
|
129
|
+
} = useApiAsync(
|
|
130
|
+
() => _chunk2TJCYLTPjs.listGraphsApi.call(void 0, optionsRef.current),
|
|
131
|
+
(data) => data.graphs || [],
|
|
132
|
+
[]
|
|
133
|
+
);
|
|
134
|
+
const {
|
|
135
|
+
execute: getGraphInternal,
|
|
136
|
+
loading: getLoading,
|
|
137
|
+
error: getError
|
|
138
|
+
} = useApiAsync(
|
|
139
|
+
(graphId) => _chunk2TJCYLTPjs.getGraphApi.call(void 0, graphId, optionsRef.current),
|
|
140
|
+
(data) => data.graph || null,
|
|
141
|
+
null
|
|
142
|
+
);
|
|
143
|
+
const getGraph = _react.useCallback.call(void 0, (graphId) => getGraphInternal(graphId), [getGraphInternal]);
|
|
144
|
+
const {
|
|
145
|
+
execute: createGraphInternal,
|
|
146
|
+
loading: createLoading,
|
|
147
|
+
error: createError
|
|
148
|
+
} = useApiAsync(
|
|
149
|
+
(graph) => _chunk2TJCYLTPjs.createGraphApi.call(void 0, graph, optionsRef.current),
|
|
150
|
+
(data) => data.graph || null,
|
|
151
|
+
null
|
|
152
|
+
);
|
|
153
|
+
const createGraph = _react.useCallback.call(void 0,
|
|
154
|
+
(graph) => createGraphInternal(graph),
|
|
155
|
+
[createGraphInternal]
|
|
156
|
+
);
|
|
157
|
+
const {
|
|
158
|
+
execute: updateGraphInternal,
|
|
159
|
+
loading: updateLoading,
|
|
160
|
+
error: updateError
|
|
161
|
+
} = useApiAsync(
|
|
162
|
+
(graphId, updates) => _chunk2TJCYLTPjs.updateGraphApi.call(void 0, graphId, updates, optionsRef.current),
|
|
163
|
+
(data) => data.graph || null,
|
|
164
|
+
null
|
|
165
|
+
);
|
|
166
|
+
const updateGraph = _react.useCallback.call(void 0,
|
|
167
|
+
(graphId, updates) => updateGraphInternal(graphId, updates),
|
|
168
|
+
[updateGraphInternal]
|
|
169
|
+
);
|
|
170
|
+
const {
|
|
171
|
+
execute: deleteGraphInternal,
|
|
172
|
+
loading: deleteLoading,
|
|
173
|
+
error: deleteError
|
|
174
|
+
} = useApiAsync(
|
|
175
|
+
(graphId) => _chunk2TJCYLTPjs.deleteGraphApi.call(void 0, graphId, optionsRef.current),
|
|
176
|
+
(data) => _nullishCoalesce(data.success, () => ( true)),
|
|
177
|
+
false
|
|
178
|
+
);
|
|
179
|
+
const deleteGraph = _react.useCallback.call(void 0,
|
|
180
|
+
(graphId) => deleteGraphInternal(graphId),
|
|
181
|
+
[deleteGraphInternal]
|
|
182
|
+
);
|
|
183
|
+
const loading = listLoading || getLoading || createLoading || updateLoading || deleteLoading;
|
|
184
|
+
const error = listError || getError || createError || updateError || deleteError;
|
|
185
|
+
return _react.useMemo.call(void 0,
|
|
186
|
+
() => ({
|
|
187
|
+
loading,
|
|
188
|
+
error,
|
|
189
|
+
listGraphs,
|
|
190
|
+
getGraph,
|
|
191
|
+
createGraph,
|
|
192
|
+
updateGraph,
|
|
193
|
+
deleteGraph
|
|
194
|
+
}),
|
|
195
|
+
[loading, error, listGraphs, getGraph, createGraph, updateGraph, deleteGraph]
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
function useKGQuery(options) {
|
|
199
|
+
const optionsRef = useOptionsRef(options);
|
|
200
|
+
const {
|
|
201
|
+
execute: queryInternal,
|
|
202
|
+
loading: queryLoading,
|
|
203
|
+
error: queryError
|
|
204
|
+
} = useApiAsync(
|
|
205
|
+
(queryParams) => _chunk2TJCYLTPjs.queryGraphApi.call(void 0, queryParams, optionsRef.current),
|
|
206
|
+
(data) => data,
|
|
207
|
+
null
|
|
208
|
+
);
|
|
209
|
+
const query = _react.useCallback.call(void 0,
|
|
210
|
+
(queryParams) => queryInternal(queryParams),
|
|
211
|
+
[queryInternal]
|
|
212
|
+
);
|
|
213
|
+
const {
|
|
214
|
+
execute: getLabels,
|
|
215
|
+
loading: labelsLoading,
|
|
216
|
+
error: labelsError
|
|
217
|
+
} = useApiAsync(
|
|
218
|
+
() => _chunk2TJCYLTPjs.getGraphLabelsApi.call(void 0, optionsRef.current),
|
|
219
|
+
(data) => data.labels || [],
|
|
220
|
+
[]
|
|
221
|
+
);
|
|
222
|
+
const {
|
|
223
|
+
execute: getNodeInternal,
|
|
224
|
+
loading: nodeLoading,
|
|
225
|
+
error: nodeError
|
|
226
|
+
} = useApiAsync(
|
|
227
|
+
(nodeId) => _chunk2TJCYLTPjs.getKGNodeApi.call(void 0, nodeId, optionsRef.current),
|
|
228
|
+
(data) => data.node || null,
|
|
229
|
+
null
|
|
230
|
+
);
|
|
231
|
+
const getNode = _react.useCallback.call(void 0, (nodeId) => getNodeInternal(nodeId), [getNodeInternal]);
|
|
232
|
+
const {
|
|
233
|
+
execute: ingestNodeInternal,
|
|
234
|
+
loading: ingestLoading,
|
|
235
|
+
error: ingestError
|
|
236
|
+
} = useApiAsync(
|
|
237
|
+
(node) => _chunk2TJCYLTPjs.ingestKGNodeApi.call(void 0, node, optionsRef.current),
|
|
238
|
+
(data) => data.nodeId || null,
|
|
239
|
+
null
|
|
240
|
+
);
|
|
241
|
+
const ingestNode = _react.useCallback.call(void 0,
|
|
242
|
+
(node) => ingestNodeInternal(node),
|
|
243
|
+
[ingestNodeInternal]
|
|
244
|
+
);
|
|
245
|
+
const {
|
|
246
|
+
execute: updateNodeInternal,
|
|
247
|
+
loading: updateLoading,
|
|
248
|
+
error: updateError
|
|
249
|
+
} = useApiAsync(
|
|
250
|
+
(nodeId, updates) => _chunk2TJCYLTPjs.updateKGNodeApi.call(void 0, nodeId, updates, optionsRef.current),
|
|
251
|
+
(data) => _nullishCoalesce(data.success, () => ( true)),
|
|
252
|
+
false
|
|
253
|
+
);
|
|
254
|
+
const updateNode = _react.useCallback.call(void 0,
|
|
255
|
+
(nodeId, updates) => updateNodeInternal(nodeId, updates),
|
|
256
|
+
[updateNodeInternal]
|
|
257
|
+
);
|
|
258
|
+
const loading = queryLoading || labelsLoading || nodeLoading || ingestLoading || updateLoading;
|
|
259
|
+
const error = queryError || labelsError || nodeError || ingestError || updateError;
|
|
260
|
+
return _react.useMemo.call(void 0,
|
|
261
|
+
() => ({
|
|
262
|
+
loading,
|
|
263
|
+
error,
|
|
264
|
+
query,
|
|
265
|
+
getLabels,
|
|
266
|
+
getNode,
|
|
267
|
+
ingestNode,
|
|
268
|
+
updateNode
|
|
269
|
+
}),
|
|
270
|
+
[loading, error, query, getLabels, getNode, ingestNode, updateNode]
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function useKGDesigner(options) {
|
|
274
|
+
const optionsRef = useOptionsRef(options);
|
|
275
|
+
const {
|
|
276
|
+
execute: listNodes,
|
|
277
|
+
loading: listNodesLoading,
|
|
278
|
+
error: listNodesError
|
|
279
|
+
} = useApiAsync(
|
|
280
|
+
() => _chunk2TJCYLTPjs.listDesignerNodesApi.call(void 0, optionsRef.current),
|
|
281
|
+
(data) => data.nodes || [],
|
|
282
|
+
[]
|
|
283
|
+
);
|
|
284
|
+
const {
|
|
285
|
+
execute: getNodeInternal,
|
|
286
|
+
loading: getNodeLoading,
|
|
287
|
+
error: getNodeError
|
|
288
|
+
} = useApiAsync(
|
|
289
|
+
(label) => _chunk2TJCYLTPjs.getDesignerNodeApi.call(void 0, label, optionsRef.current),
|
|
290
|
+
(data) => data.node || null,
|
|
291
|
+
null
|
|
292
|
+
);
|
|
293
|
+
const getNode = _react.useCallback.call(void 0, (label) => getNodeInternal(label), [getNodeInternal]);
|
|
294
|
+
const {
|
|
295
|
+
execute: createNodeInternal,
|
|
296
|
+
loading: createNodeLoading,
|
|
297
|
+
error: createNodeError
|
|
298
|
+
} = useApiAsync(
|
|
299
|
+
(node) => _chunk2TJCYLTPjs.createDesignerNodeApi.call(void 0, node, optionsRef.current),
|
|
300
|
+
(data) => data.node || null,
|
|
301
|
+
null
|
|
302
|
+
);
|
|
303
|
+
const createNode = _react.useCallback.call(void 0,
|
|
304
|
+
(node) => createNodeInternal(node),
|
|
305
|
+
[createNodeInternal]
|
|
306
|
+
);
|
|
307
|
+
const {
|
|
308
|
+
execute: updateNodeInternal,
|
|
309
|
+
loading: updateNodeLoading,
|
|
310
|
+
error: updateNodeError
|
|
311
|
+
} = useApiAsync(
|
|
312
|
+
(label, updates) => _chunk2TJCYLTPjs.updateDesignerNodeApi.call(void 0, label, updates, optionsRef.current),
|
|
313
|
+
(data) => data.node || null,
|
|
314
|
+
null
|
|
315
|
+
);
|
|
316
|
+
const updateNode = _react.useCallback.call(void 0,
|
|
317
|
+
(label, updates) => updateNodeInternal(label, updates),
|
|
318
|
+
[updateNodeInternal]
|
|
319
|
+
);
|
|
320
|
+
const {
|
|
321
|
+
execute: deleteNodeInternal,
|
|
322
|
+
loading: deleteNodeLoading,
|
|
323
|
+
error: deleteNodeError
|
|
324
|
+
} = useApiAsync(
|
|
325
|
+
(label) => _chunk2TJCYLTPjs.deleteDesignerNodeApi.call(void 0, label, optionsRef.current),
|
|
326
|
+
(data) => _nullishCoalesce(data.success, () => ( true)),
|
|
327
|
+
false
|
|
328
|
+
);
|
|
329
|
+
const deleteNode = _react.useCallback.call(void 0, (label) => deleteNodeInternal(label), [deleteNodeInternal]);
|
|
330
|
+
const {
|
|
331
|
+
execute: listEdges,
|
|
332
|
+
loading: listEdgesLoading,
|
|
333
|
+
error: listEdgesError
|
|
334
|
+
} = useApiAsync(
|
|
335
|
+
() => _chunk2TJCYLTPjs.listDesignerEdgesApi.call(void 0, optionsRef.current),
|
|
336
|
+
(data) => data.edges || [],
|
|
337
|
+
[]
|
|
338
|
+
);
|
|
339
|
+
const {
|
|
340
|
+
execute: createEdgeInternal,
|
|
341
|
+
loading: createEdgeLoading,
|
|
342
|
+
error: createEdgeError
|
|
343
|
+
} = useApiAsync(
|
|
344
|
+
(edge) => _chunk2TJCYLTPjs.createDesignerEdgeApi.call(void 0, edge, optionsRef.current),
|
|
345
|
+
(data) => data.edge || null,
|
|
346
|
+
null
|
|
347
|
+
);
|
|
348
|
+
const createEdge = _react.useCallback.call(void 0,
|
|
349
|
+
(edge) => createEdgeInternal(edge),
|
|
350
|
+
[createEdgeInternal]
|
|
351
|
+
);
|
|
352
|
+
const {
|
|
353
|
+
execute: updateEdgeInternal,
|
|
354
|
+
loading: updateEdgeLoading,
|
|
355
|
+
error: updateEdgeError
|
|
356
|
+
} = useApiAsync(
|
|
357
|
+
(label, updates) => _chunk2TJCYLTPjs.updateDesignerEdgeApi.call(void 0, label, updates, optionsRef.current),
|
|
358
|
+
(data) => data.edge || null,
|
|
359
|
+
null
|
|
360
|
+
);
|
|
361
|
+
const updateEdge = _react.useCallback.call(void 0,
|
|
362
|
+
(label, updates) => updateEdgeInternal(label, updates),
|
|
363
|
+
[updateEdgeInternal]
|
|
364
|
+
);
|
|
365
|
+
const {
|
|
366
|
+
execute: deleteEdgeInternal,
|
|
367
|
+
loading: deleteEdgeLoading,
|
|
368
|
+
error: deleteEdgeError
|
|
369
|
+
} = useApiAsync(
|
|
370
|
+
(label) => _chunk2TJCYLTPjs.deleteDesignerEdgeApi.call(void 0, label, optionsRef.current),
|
|
371
|
+
(data) => _nullishCoalesce(data.success, () => ( true)),
|
|
372
|
+
false
|
|
373
|
+
);
|
|
374
|
+
const deleteEdge = _react.useCallback.call(void 0, (label) => deleteEdgeInternal(label), [deleteEdgeInternal]);
|
|
375
|
+
const loading = listNodesLoading || getNodeLoading || createNodeLoading || updateNodeLoading || deleteNodeLoading || listEdgesLoading || createEdgeLoading || updateEdgeLoading || deleteEdgeLoading;
|
|
376
|
+
const error = listNodesError || getNodeError || createNodeError || updateNodeError || deleteNodeError || listEdgesError || createEdgeError || updateEdgeError || deleteEdgeError;
|
|
377
|
+
return _react.useMemo.call(void 0,
|
|
378
|
+
() => ({
|
|
379
|
+
loading,
|
|
380
|
+
error,
|
|
381
|
+
// Nodes
|
|
382
|
+
listNodes,
|
|
383
|
+
getNode,
|
|
384
|
+
createNode,
|
|
385
|
+
updateNode,
|
|
386
|
+
deleteNode,
|
|
387
|
+
// Edges
|
|
388
|
+
listEdges,
|
|
389
|
+
createEdge,
|
|
390
|
+
updateEdge,
|
|
391
|
+
deleteEdge
|
|
392
|
+
}),
|
|
393
|
+
[
|
|
394
|
+
loading,
|
|
395
|
+
error,
|
|
396
|
+
listNodes,
|
|
397
|
+
getNode,
|
|
398
|
+
createNode,
|
|
399
|
+
updateNode,
|
|
400
|
+
deleteNode,
|
|
401
|
+
listEdges,
|
|
402
|
+
createEdge,
|
|
403
|
+
updateEdge,
|
|
404
|
+
deleteEdge
|
|
405
|
+
]
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
function useCrawlJobs(options) {
|
|
409
|
+
const optionsRef = useOptionsRef(options);
|
|
410
|
+
const {
|
|
411
|
+
execute: listJobsInternal,
|
|
412
|
+
loading: listLoading,
|
|
413
|
+
error: listError
|
|
414
|
+
} = useApiAsync(
|
|
415
|
+
(params) => _chunk2TJCYLTPjs.listCrawlJobsApi.call(void 0, { ...optionsRef.current, ...params }),
|
|
416
|
+
(data) => ({ jobs: data.jobs || [], total: data.total || 0 }),
|
|
417
|
+
{ jobs: [], total: 0 }
|
|
418
|
+
);
|
|
419
|
+
const listJobs = _react.useCallback.call(void 0,
|
|
420
|
+
(params) => listJobsInternal(params),
|
|
421
|
+
[listJobsInternal]
|
|
422
|
+
);
|
|
423
|
+
const {
|
|
424
|
+
execute: startJobInternal,
|
|
425
|
+
loading: startLoading,
|
|
426
|
+
error: startError
|
|
427
|
+
} = useApiAsync(
|
|
428
|
+
(params) => _chunk2TJCYLTPjs.startCrawlJobApi.call(void 0, params, optionsRef.current),
|
|
429
|
+
(data) => data.jobId || null,
|
|
430
|
+
null
|
|
431
|
+
);
|
|
432
|
+
const startJob = _react.useCallback.call(void 0,
|
|
433
|
+
(params) => startJobInternal(params),
|
|
434
|
+
[startJobInternal]
|
|
435
|
+
);
|
|
436
|
+
const {
|
|
437
|
+
execute: getJobStatusInternal,
|
|
438
|
+
loading: statusLoading,
|
|
439
|
+
error: statusError
|
|
440
|
+
} = useApiAsync(
|
|
441
|
+
(jobId) => _chunk2TJCYLTPjs.getCrawlJobStatusApi.call(void 0, jobId, optionsRef.current),
|
|
442
|
+
(data) => data.job || null,
|
|
443
|
+
null
|
|
444
|
+
);
|
|
445
|
+
const getJobStatus = _react.useCallback.call(void 0,
|
|
446
|
+
(jobId) => getJobStatusInternal(jobId),
|
|
447
|
+
[getJobStatusInternal]
|
|
448
|
+
);
|
|
449
|
+
const {
|
|
450
|
+
execute: cancelJobInternal,
|
|
451
|
+
loading: cancelLoading,
|
|
452
|
+
error: cancelError
|
|
453
|
+
} = useApiAsync(
|
|
454
|
+
(jobId) => _chunk2TJCYLTPjs.cancelCrawlJobApi.call(void 0, jobId, optionsRef.current),
|
|
455
|
+
(data) => _nullishCoalesce(data.success, () => ( true)),
|
|
456
|
+
false
|
|
457
|
+
);
|
|
458
|
+
const cancelJob = _react.useCallback.call(void 0, (jobId) => cancelJobInternal(jobId), [cancelJobInternal]);
|
|
459
|
+
const {
|
|
460
|
+
execute: getCrawledPagesInternal,
|
|
461
|
+
loading: pagesLoading,
|
|
462
|
+
error: pagesError
|
|
463
|
+
} = useApiAsync(
|
|
464
|
+
(jobId) => _chunk2TJCYLTPjs.getCrawledPagesApi.call(void 0, jobId, optionsRef.current),
|
|
465
|
+
(data) => data.pages || [],
|
|
466
|
+
[]
|
|
467
|
+
);
|
|
468
|
+
const getCrawledPages = _react.useCallback.call(void 0,
|
|
469
|
+
(jobId) => getCrawledPagesInternal(jobId),
|
|
470
|
+
[getCrawledPagesInternal]
|
|
471
|
+
);
|
|
472
|
+
const loading = listLoading || startLoading || statusLoading || cancelLoading || pagesLoading;
|
|
473
|
+
const error = listError || startError || statusError || cancelError || pagesError;
|
|
474
|
+
return _react.useMemo.call(void 0,
|
|
475
|
+
() => ({
|
|
476
|
+
loading,
|
|
477
|
+
error,
|
|
478
|
+
listJobs,
|
|
479
|
+
startJob,
|
|
480
|
+
getJobStatus,
|
|
481
|
+
cancelJob,
|
|
482
|
+
getCrawledPages
|
|
483
|
+
}),
|
|
484
|
+
[loading, error, listJobs, startJob, getJobStatus, cancelJob, getCrawledPages]
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
exports.useAsync = useAsync; exports.useApiAsync = useApiAsync; exports.useOptionsRef = useOptionsRef; exports.useGraphs = useGraphs; exports.useKGQuery = useKGQuery; exports.useKGDesigner = useKGDesigner; exports.useCrawlJobs = useCrawlJobs;
|
|
497
|
+
//# sourceMappingURL=chunk-7RW5MHP5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/eloquent/eloquent/packages/@elqnt/kg/dist/chunk-7RW5MHP5.js","../hooks/index.ts","../hooks/use-async.ts","../hooks/use-options-ref.ts"],"names":["useRef","useCallback"],"mappings":"AAAA,6rBAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;ACjBA,8BAAqC;ADmBrC;AACA;AEpBA;AAuBA,SAAS,mBAAA,CACP,QAAA,EACA,SAAA,EACA,YAAA,EAC0B;AAC1B,EAAA,GAAA,CAAI,QAAA,CAAS,KAAA,EAAO;AAClB,IAAA,OAAO,CAAC,YAAA,EAAc,QAAA,CAAS,KAAK,CAAA;AAAA,EACtC;AACA,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,EAAM;AAClB,IAAA,OAAO,CAAC,YAAA,EAAc,IAAI,CAAA;AAAA,EAC5B;AACA,EAAA,OAAO,CAAC,SAAA,CAAU,QAAA,CAAS,IAAI,CAAA,EAAG,IAAI,CAAA;AACxC;AAoBO,SAAS,QAAA,CACd,OAAA,EACA,OAAA,EACgC;AAChC,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAC5C,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,EAAA,EAAI,6BAAA,IAA4B,CAAA;AACtD,EAAA,MAAM,aAAA,EAAe,2BAAA,CAAQ,CAAA;AAE7B,EAAA,MAAM,QAAA,EAAU,gCAAA;AAAA,IACd,MAAA,CAAA,G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cesContent":[null,"\"use client\";\n\n/**\n * Knowledge Graph React Hooks\n *\n * Provides React hooks for KG operations with loading/error states.\n * All hooks use the useOptionsRef pattern to always access the latest options.\n *\n * @packageDocumentation\n */\n\nimport { useCallback, useMemo } from \"react\";\nimport type { ApiClientOptions } from \"@elqnt/api-client\";\nimport type {\n Graph,\n CreateGraphRequest,\n KGNode,\n KGQuery,\n KGQueryResult,\n KGLabelInfo,\n KGNodeIngestRequest,\n GraphNodeDefinition,\n GraphEdgeDefinition,\n} from \"../models\";\nimport {\n listGraphsApi,\n getGraphApi,\n createGraphApi,\n updateGraphApi,\n deleteGraphApi,\n queryGraphApi,\n getGraphLabelsApi,\n getKGNodeApi,\n ingestKGNodeApi,\n updateKGNodeApi,\n listDesignerNodesApi,\n getDesignerNodeApi,\n createDesignerNodeApi,\n updateDesignerNodeApi,\n deleteDesignerNodeApi,\n listDesignerEdgesApi,\n createDesignerEdgeApi,\n updateDesignerEdgeApi,\n deleteDesignerEdgeApi,\n listCrawlJobsApi,\n startCrawlJobApi,\n getCrawlJobStatusApi,\n cancelCrawlJobApi,\n getCrawledPagesApi,\n type KGApiOptions,\n type CrawlJob,\n} from \"../api\";\nimport { useApiAsync } from \"./use-async\";\nimport { useOptionsRef } from \"./use-options-ref\";\n\n// Re-export utilities for external use\nexport { useApiAsync, useAsync } from \"./use-async\";\nexport type { UseAsyncOptions, UseAsyncReturn } from \"./use-async\";\nexport { useOptionsRef } from \"./use-options-ref\";\n\n// =============================================================================\n// TYPES\n// =============================================================================\n\n/** Options for KG hooks that require a graph ID */\nexport type UseKGOptions = ApiClientOptions & { graphId?: string };\n\n// =============================================================================\n// USE GRAPHS HOOK\n// =============================================================================\n\n/**\n * Hook for knowledge graph CRUD operations\n *\n * @example\n * ```tsx\n * const { loading, error, listGraphs, createGraph } = useGraphs({\n * baseUrl: apiGatewayUrl,\n * orgId: selectedOrgId,\n * });\n *\n * const graphs = await listGraphs();\n * ```\n */\nexport function useGraphs(options: ApiClientOptions) {\n const optionsRef = useOptionsRef(options);\n\n const {\n execute: listGraphs,\n loading: listLoading,\n error: listError,\n } = useApiAsync(\n () => listGraphsApi(optionsRef.current),\n (data) => data.graphs || [],\n []\n );\n\n const {\n execute: getGraphInternal,\n loading: getLoading,\n error: getError,\n } = useApiAsync(\n (graphId: string) => getGraphApi(graphId, optionsRef.current),\n (data) => data.graph || null,\n null\n );\n const getGraph = useCallback((graphId: string) => getGraphInternal(graphId), [getGraphInternal]);\n\n const {\n execute: createGraphInternal,\n loading: createLoading,\n error: createError,\n } = useApiAsync(\n (graph: CreateGraphRequest) => createGraphApi(graph, optionsRef.current),\n (data) => data.graph || null,\n null\n );\n const createGraph = useCallback(\n (graph: CreateGraphRequest) => createGraphInternal(graph),\n [createGraphInternal]\n );\n\n const {\n execute: updateGraphInternal,\n loading: updateLoading,\n error: updateError,\n } = useApiAsync(\n (graphId: string, updates: Partial<Graph>) => updateGraphApi(graphId, updates, optionsRef.current),\n (data) => data.graph || null,\n null\n );\n const updateGraph = useCallback(\n (graphId: string, updates: Partial<Graph>) => updateGraphInternal(graphId, updates),\n [updateGraphInternal]\n );\n\n const {\n execute: deleteGraphInternal,\n loading: deleteLoading,\n error: deleteError,\n } = useApiAsync(\n (graphId: string) => deleteGraphApi(graphId, optionsRef.current),\n (data) => data.success ?? true,\n false\n );\n const deleteGraph = useCallback(\n (graphId: string) => deleteGraphInternal(graphId),\n [deleteGraphInternal]\n );\n\n // Combine loading and error states\n const loading = listLoading || getLoading || createLoading || updateLoading || deleteLoading;\n const error = listError || getError || createError || updateError || deleteError;\n\n return useMemo(\n () => ({\n loading,\n error,\n listGraphs,\n getGraph,\n createGraph,\n updateGraph,\n deleteGraph,\n }),\n [loading, error, listGraphs, getGraph, createGraph, updateGraph, deleteGraph]\n );\n}\n\n// =============================================================================\n// USE KG QUERY HOOK\n// =============================================================================\n\n/**\n * Hook for querying knowledge graph nodes\n *\n * @example\n * ```tsx\n * const { query, getLabels, loading, error } = useKGQuery({\n * baseUrl: apiGatewayUrl,\n * orgId: selectedOrgId,\n * graphId: selectedGraphId,\n * });\n *\n * const result = await query({ label: \"Person\", fields: [], limit: 10 });\n * ```\n */\nexport function useKGQuery(options: UseKGOptions) {\n const optionsRef = useOptionsRef(options);\n\n const {\n execute: queryInternal,\n loading: queryLoading,\n error: queryError,\n } = useApiAsync(\n (queryParams: KGQuery) => queryGraphApi(queryParams, optionsRef.current),\n (data) => data,\n null\n );\n const query = useCallback(\n (queryParams: KGQuery): Promise<KGQueryResult | null> => queryInternal(queryParams),\n [queryInternal]\n );\n\n const {\n execute: getLabels,\n loading: labelsLoading,\n error: labelsError,\n } = useApiAsync(\n () => getGraphLabelsApi(optionsRef.current),\n (data) => data.labels || [],\n []\n );\n\n const {\n execute: getNodeInternal,\n loading: nodeLoading,\n error: nodeError,\n } = useApiAsync(\n (nodeId: string) => getKGNodeApi(nodeId, optionsRef.current),\n (data) => data.node || null,\n null\n );\n const getNode = useCallback((nodeId: string) => getNodeInternal(nodeId), [getNodeInternal]);\n\n const {\n execute: ingestNodeInternal,\n loading: ingestLoading,\n error: ingestError,\n } = useApiAsync(\n (node: KGNodeIngestRequest) => ingestKGNodeApi(node, optionsRef.current),\n (data) => data.nodeId || null,\n null\n );\n const ingestNode = useCallback(\n (node: KGNodeIngestRequest) => ingestNodeInternal(node),\n [ingestNodeInternal]\n );\n\n const {\n execute: updateNodeInternal,\n loading: updateLoading,\n error: updateError,\n } = useApiAsync(\n (nodeId: string, updates: Partial<KGNode>) => updateKGNodeApi(nodeId, updates, optionsRef.current),\n (data) => data.success ?? true,\n false\n );\n const updateNode = useCallback(\n (nodeId: string, updates: Partial<KGNode>) => updateNodeInternal(nodeId, updates),\n [updateNodeInternal]\n );\n\n const loading = queryLoading || labelsLoading || nodeLoading || ingestLoading || updateLoading;\n const error = queryError || labelsError || nodeError || ingestError || updateError;\n\n return useMemo(\n () => ({\n loading,\n error,\n query,\n getLabels,\n getNode,\n ingestNode,\n updateNode,\n }),\n [loading, error, query, getLabels, getNode, ingestNode, updateNode]\n );\n}\n\n// =============================================================================\n// USE KG DESIGNER HOOK\n// =============================================================================\n\n/**\n * Hook for KG designer operations (node and edge definitions)\n *\n * @example\n * ```tsx\n * const { listNodes, createNode, listEdges, createEdge } = useKGDesigner({\n * baseUrl: apiGatewayUrl,\n * orgId: selectedOrgId,\n * graphId: selectedGraphId,\n * });\n *\n * const nodes = await listNodes();\n * ```\n */\nexport function useKGDesigner(options: UseKGOptions) {\n const optionsRef = useOptionsRef(options);\n\n // Node operations\n const {\n execute: listNodes,\n loading: listNodesLoading,\n error: listNodesError,\n } = useApiAsync(\n () => listDesignerNodesApi(optionsRef.current),\n (data) => data.nodes || [],\n []\n );\n\n const {\n execute: getNodeInternal,\n loading: getNodeLoading,\n error: getNodeError,\n } = useApiAsync(\n (label: string) => getDesignerNodeApi(label, optionsRef.current),\n (data) => data.node || null,\n null\n );\n const getNode = useCallback((label: string) => getNodeInternal(label), [getNodeInternal]);\n\n const {\n execute: createNodeInternal,\n loading: createNodeLoading,\n error: createNodeError,\n } = useApiAsync(\n (node: Omit<GraphNodeDefinition, \"createdAt\" | \"updatedAt\">) =>\n createDesignerNodeApi(node, optionsRef.current),\n (data) => data.node || null,\n null\n );\n const createNode = useCallback(\n (node: Omit<GraphNodeDefinition, \"createdAt\" | \"updatedAt\">) => createNodeInternal(node),\n [createNodeInternal]\n );\n\n const {\n execute: updateNodeInternal,\n loading: updateNodeLoading,\n error: updateNodeError,\n } = useApiAsync(\n (label: string, updates: Partial<GraphNodeDefinition>) =>\n updateDesignerNodeApi(label, updates, optionsRef.current),\n (data) => data.node || null,\n null\n );\n const updateNode = useCallback(\n (label: string, updates: Partial<GraphNodeDefinition>) => updateNodeInternal(label, updates),\n [updateNodeInternal]\n );\n\n const {\n execute: deleteNodeInternal,\n loading: deleteNodeLoading,\n error: deleteNodeError,\n } = useApiAsync(\n (label: string) => deleteDesignerNodeApi(label, optionsRef.current),\n (data) => data.success ?? true,\n false\n );\n const deleteNode = useCallback((label: string) => deleteNodeInternal(label), [deleteNodeInternal]);\n\n // Edge operations\n const {\n execute: listEdges,\n loading: listEdgesLoading,\n error: listEdgesError,\n } = useApiAsync(\n () => listDesignerEdgesApi(optionsRef.current),\n (data) => data.edges || [],\n []\n );\n\n const {\n execute: createEdgeInternal,\n loading: createEdgeLoading,\n error: createEdgeError,\n } = useApiAsync(\n (edge: Omit<GraphEdgeDefinition, \"createdAt\" | \"updatedAt\">) =>\n createDesignerEdgeApi(edge, optionsRef.current),\n (data) => data.edge || null,\n null\n );\n const createEdge = useCallback(\n (edge: Omit<GraphEdgeDefinition, \"createdAt\" | \"updatedAt\">) => createEdgeInternal(edge),\n [createEdgeInternal]\n );\n\n const {\n execute: updateEdgeInternal,\n loading: updateEdgeLoading,\n error: updateEdgeError,\n } = useApiAsync(\n (label: string, updates: Partial<GraphEdgeDefinition>) =>\n updateDesignerEdgeApi(label, updates, optionsRef.current),\n (data) => data.edge || null,\n null\n );\n const updateEdge = useCallback(\n (label: string, updates: Partial<GraphEdgeDefinition>) => updateEdgeInternal(label, updates),\n [updateEdgeInternal]\n );\n\n const {\n execute: deleteEdgeInternal,\n loading: deleteEdgeLoading,\n error: deleteEdgeError,\n } = useApiAsync(\n (label: string) => deleteDesignerEdgeApi(label, optionsRef.current),\n (data) => data.success ?? true,\n false\n );\n const deleteEdge = useCallback((label: string) => deleteEdgeInternal(label), [deleteEdgeInternal]);\n\n const loading =\n listNodesLoading ||\n getNodeLoading ||\n createNodeLoading ||\n updateNodeLoading ||\n deleteNodeLoading ||\n listEdgesLoading ||\n createEdgeLoading ||\n updateEdgeLoading ||\n deleteEdgeLoading;\n\n const error =\n listNodesError ||\n getNodeError ||\n createNodeError ||\n updateNodeError ||\n deleteNodeError ||\n listEdgesError ||\n createEdgeError ||\n updateEdgeError ||\n deleteEdgeError;\n\n return useMemo(\n () => ({\n loading,\n error,\n // Nodes\n listNodes,\n getNode,\n createNode,\n updateNode,\n deleteNode,\n // Edges\n listEdges,\n createEdge,\n updateEdge,\n deleteEdge,\n }),\n [\n loading,\n error,\n listNodes,\n getNode,\n createNode,\n updateNode,\n deleteNode,\n listEdges,\n createEdge,\n updateEdge,\n deleteEdge,\n ]\n );\n}\n\n// =============================================================================\n// USE CRAWL JOBS HOOK\n// =============================================================================\n\n/**\n * Hook for web crawl job operations\n *\n * @example\n * ```tsx\n * const { listJobs, startJob, getJobStatus } = useCrawlJobs({\n * baseUrl: apiGatewayUrl,\n * orgId: selectedOrgId,\n * graphId: selectedGraphId,\n * });\n *\n * const jobId = await startJob({ baseUrl: \"https://example.com\", depth: 2, maxPages: 100 });\n * ```\n */\nexport function useCrawlJobs(options: UseKGOptions) {\n const optionsRef = useOptionsRef(options);\n\n const {\n execute: listJobsInternal,\n loading: listLoading,\n error: listError,\n } = useApiAsync(\n (params?: { limit?: number; offset?: number; status?: string }) =>\n listCrawlJobsApi({ ...optionsRef.current, ...params }),\n (data) => ({ jobs: data.jobs || [], total: data.total || 0 }),\n { jobs: [], total: 0 }\n );\n const listJobs = useCallback(\n (params?: { limit?: number; offset?: number; status?: string }) => listJobsInternal(params),\n [listJobsInternal]\n );\n\n const {\n execute: startJobInternal,\n loading: startLoading,\n error: startError,\n } = useApiAsync(\n (params: { baseUrl: string; depth: number; maxPages: number }) =>\n startCrawlJobApi(params, optionsRef.current),\n (data) => data.jobId || null,\n null\n );\n const startJob = useCallback(\n (params: { baseUrl: string; depth: number; maxPages: number }) => startJobInternal(params),\n [startJobInternal]\n );\n\n const {\n execute: getJobStatusInternal,\n loading: statusLoading,\n error: statusError,\n } = useApiAsync(\n (jobId: string) => getCrawlJobStatusApi(jobId, optionsRef.current),\n (data) => data.job || null,\n null\n );\n const getJobStatus = useCallback(\n (jobId: string): Promise<CrawlJob | null> => getJobStatusInternal(jobId),\n [getJobStatusInternal]\n );\n\n const {\n execute: cancelJobInternal,\n loading: cancelLoading,\n error: cancelError,\n } = useApiAsync(\n (jobId: string) => cancelCrawlJobApi(jobId, optionsRef.current),\n (data) => data.success ?? true,\n false\n );\n const cancelJob = useCallback((jobId: string) => cancelJobInternal(jobId), [cancelJobInternal]);\n\n const {\n execute: getCrawledPagesInternal,\n loading: pagesLoading,\n error: pagesError,\n } = useApiAsync(\n (jobId: string) => getCrawledPagesApi(jobId, optionsRef.current),\n (data) => data.pages || [],\n []\n );\n const getCrawledPages = useCallback(\n (jobId: string) => getCrawledPagesInternal(jobId),\n [getCrawledPagesInternal]\n );\n\n const loading = listLoading || startLoading || statusLoading || cancelLoading || pagesLoading;\n const error = listError || startError || statusError || cancelError || pagesError;\n\n return useMemo(\n () => ({\n loading,\n error,\n listJobs,\n startJob,\n getJobStatus,\n cancelJob,\n getCrawledPages,\n }),\n [loading, error, listJobs, startJob, getJobStatus, cancelJob, getCrawledPages]\n );\n}\n","\"use client\";\n\n/**\n * Generic async operation hook with loading/error state management\n *\n * Reduces boilerplate for async operations by handling:\n * - Loading state with request counter (handles concurrent calls correctly)\n * - Error state management\n * - Automatic error extraction from ApiResponse or Error objects\n */\n\nimport { useState, useCallback, useRef } from \"react\";\nimport type { ApiResponse } from \"@elqnt/api-client\";\n\nexport interface UseAsyncOptions {\n /** Custom error handler - called in addition to setting error state */\n onError?: (error: string) => void;\n}\n\nexport interface UseAsyncReturn<TResult, TArgs extends unknown[]> {\n /** Execute the async function */\n execute: (...args: TArgs) => Promise<TResult>;\n /** Whether any request is currently in flight */\n loading: boolean;\n /** Last error message, or null if no error */\n error: string | null;\n /** Clear the current error */\n clearError: () => void;\n}\n\n/**\n * Extract data from an ApiResponse, handling errors\n * @returns [data, errorMessage]\n */\nfunction extractFromResponse<T, TResult>(\n response: ApiResponse<T>,\n extractor: (data: T) => TResult,\n defaultValue: TResult\n): [TResult, string | null] {\n if (response.error) {\n return [defaultValue, response.error];\n }\n if (!response.data) {\n return [defaultValue, null];\n }\n return [extractor(response.data), null];\n}\n\n/**\n * Create an async operation handler with loading and error states\n *\n * This hook wraps async functions to automatically manage:\n * - Loading state (using request counter for concurrent calls)\n * - Error state (extracted from ApiResponse or Error)\n *\n * @example\n * ```tsx\n * const { execute: fetchGraphs, loading, error } = useAsync(\n * async () => {\n * const response = await listGraphsApi(options);\n * if (response.error) throw new Error(response.error);\n * return response.data?.graphs || [];\n * }\n * );\n * ```\n */\nexport function useAsync<TResult, TArgs extends unknown[] = []>(\n asyncFn: (...args: TArgs) => Promise<TResult>,\n options?: UseAsyncOptions\n): UseAsyncReturn<TResult, TArgs> {\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const requestCount = useRef(0);\n\n const execute = useCallback(\n async (...args: TArgs): Promise<TResult> => {\n requestCount.current += 1;\n setLoading(true);\n setError(null);\n\n try {\n const result = await asyncFn(...args);\n return result;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"An error occurred\";\n setError(message);\n options?.onError?.(message);\n throw err;\n } finally {\n requestCount.current -= 1;\n if (requestCount.current === 0) {\n setLoading(false);\n }\n }\n },\n [asyncFn, options]\n );\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n return { execute, loading, error, clearError };\n}\n\n/**\n * Create an async operation handler specifically for ApiResponse-returning functions\n *\n * Unlike useAsync, this handles the ApiResponse unwrapping automatically:\n * - Extracts data using the provided extractor\n * - Sets error state from response.error\n * - Returns default value on error\n *\n * @example\n * ```tsx\n * const { execute: fetchGraphs, loading, error } = useApiAsync(\n * () => listGraphsApi(optionsRef.current),\n * (data) => data.graphs || [],\n * []\n * );\n * ```\n */\nexport function useApiAsync<TResponse, TResult, TArgs extends unknown[] = []>(\n asyncFn: (...args: TArgs) => Promise<ApiResponse<TResponse>>,\n extractor: (data: TResponse) => TResult,\n defaultValue: TResult,\n options?: UseAsyncOptions\n): UseAsyncReturn<TResult, TArgs> {\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const requestCount = useRef(0);\n\n const execute = useCallback(\n async (...args: TArgs): Promise<TResult> => {\n requestCount.current += 1;\n setLoading(true);\n setError(null);\n\n try {\n const response = await asyncFn(...args);\n const [result, errorMessage] = extractFromResponse(response, extractor, defaultValue);\n\n if (errorMessage) {\n setError(errorMessage);\n options?.onError?.(errorMessage);\n return defaultValue;\n }\n\n return result;\n } catch (err) {\n const message = err instanceof Error ? err.message : \"An error occurred\";\n setError(message);\n options?.onError?.(message);\n return defaultValue;\n } finally {\n requestCount.current -= 1;\n if (requestCount.current === 0) {\n setLoading(false);\n }\n }\n },\n [asyncFn, extractor, defaultValue, options]\n );\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n return { execute, loading, error, clearError };\n}\n","\"use client\";\n\n/**\n * Hook to keep a mutable ref of options in sync\n *\n * This pattern allows callbacks created with useCallback to always access\n * the latest options without needing to re-create the callback when options change.\n *\n * This is useful for API hooks where:\n * - Options (baseUrl, orgId, graphId) may change over time\n * - Callbacks are memoized and shouldn't be recreated on every options change\n * - The callback should always use the current options when called\n */\n\nimport { useRef, useEffect } from \"react\";\n\n/**\n * Keep a mutable ref synchronized with the latest value\n *\n * @example\n * ```tsx\n * function useGraphs(options: ApiClientOptions) {\n * const optionsRef = useOptionsRef(options);\n *\n * const listGraphs = useCallback(async () => {\n * // Always uses latest options\n * return listGraphsApi(optionsRef.current);\n * }, []); // No dependency on options - callback never changes\n *\n * return { listGraphs };\n * }\n * ```\n */\nexport function useOptionsRef<T>(options: T): React.MutableRefObject<T> {\n const ref = useRef(options);\n\n useEffect(() => {\n ref.current = options;\n }, [options]);\n\n return ref;\n}\n"]}
|