@nimbleflux/fluxbase-sdk-react 2026.3.6 → 2026.3.7-rc.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/.nvmrc +1 -1
- package/package.json +10 -10
- package/src/index.ts +15 -0
- package/src/use-admin-auth.ts +1 -1
- package/src/use-admin-hooks.ts +122 -113
- package/src/use-auth-config.ts +1 -1
- package/src/use-auth.ts +1 -1
- package/src/use-captcha.ts +2 -2
- package/src/use-client-keys.ts +66 -51
- package/src/use-graphql.ts +14 -9
- package/src/use-query.ts +73 -62
- package/src/use-realtime.ts +6 -2
- package/src/use-saml.ts +1 -1
- package/src/use-storage.ts +4 -2
- package/src/use-table-export.ts +178 -139
- package/src/use-tenant.ts +311 -0
- package/src/use-users.ts +56 -55
- package/tsconfig.json +1 -0
- package/tsup.config.ts +1 -1
package/src/use-table-export.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* React hooks for exporting database tables to knowledge bases and managing sync configurations.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useState, useEffect, useCallback } from
|
|
8
|
-
import { useFluxbaseClient } from
|
|
7
|
+
import { useState, useEffect, useCallback } from "react";
|
|
8
|
+
import { useFluxbaseClient } from "./context";
|
|
9
9
|
import type {
|
|
10
10
|
ExportTableOptions,
|
|
11
11
|
ExportTableResult,
|
|
@@ -13,23 +13,23 @@ import type {
|
|
|
13
13
|
TableExportSyncConfig,
|
|
14
14
|
CreateTableExportSyncConfig,
|
|
15
15
|
UpdateTableExportSyncConfig,
|
|
16
|
-
} from
|
|
16
|
+
} from "@nimbleflux/fluxbase-sdk";
|
|
17
17
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
// useTableDetails Hook
|
|
20
20
|
// ============================================================================
|
|
21
21
|
|
|
22
22
|
export interface UseTableDetailsOptions {
|
|
23
|
-
schema?: string
|
|
24
|
-
table?: string
|
|
25
|
-
autoFetch?: boolean
|
|
23
|
+
schema?: string;
|
|
24
|
+
table?: string;
|
|
25
|
+
autoFetch?: boolean;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface UseTableDetailsReturn {
|
|
29
|
-
data: TableDetails | null
|
|
30
|
-
isLoading: boolean
|
|
31
|
-
error: Error | null
|
|
32
|
-
refetch: () => Promise<void
|
|
29
|
+
data: TableDetails | null;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
error: Error | null;
|
|
32
|
+
refetch: () => Promise<void>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -56,44 +56,46 @@ export interface UseTableDetailsReturn {
|
|
|
56
56
|
* }
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
export function useTableDetails(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
export function useTableDetails(
|
|
60
|
+
options: UseTableDetailsOptions,
|
|
61
|
+
): UseTableDetailsReturn {
|
|
62
|
+
const { schema, table, autoFetch = true } = options;
|
|
63
|
+
const client = useFluxbaseClient();
|
|
62
64
|
|
|
63
|
-
const [data, setData] = useState<TableDetails | null>(null)
|
|
64
|
-
const [isLoading, setIsLoading] = useState(autoFetch && !!schema && !!table)
|
|
65
|
-
const [error, setError] = useState<Error | null>(null)
|
|
65
|
+
const [data, setData] = useState<TableDetails | null>(null);
|
|
66
|
+
const [isLoading, setIsLoading] = useState(autoFetch && !!schema && !!table);
|
|
67
|
+
const [error, setError] = useState<Error | null>(null);
|
|
66
68
|
|
|
67
69
|
const fetchData = useCallback(async () => {
|
|
68
|
-
if (!schema || !table) return
|
|
70
|
+
if (!schema || !table) return;
|
|
69
71
|
|
|
70
72
|
try {
|
|
71
|
-
setIsLoading(true)
|
|
72
|
-
setError(null)
|
|
73
|
-
const result = await client.admin.ai.getTableDetails(schema, table)
|
|
73
|
+
setIsLoading(true);
|
|
74
|
+
setError(null);
|
|
75
|
+
const result = await client.admin.ai.getTableDetails(schema, table);
|
|
74
76
|
if (result.error) {
|
|
75
|
-
throw result.error
|
|
77
|
+
throw result.error;
|
|
76
78
|
}
|
|
77
|
-
setData(result.data)
|
|
79
|
+
setData(result.data);
|
|
78
80
|
} catch (err) {
|
|
79
|
-
setError(err as Error)
|
|
81
|
+
setError(err as Error);
|
|
80
82
|
} finally {
|
|
81
|
-
setIsLoading(false)
|
|
83
|
+
setIsLoading(false);
|
|
82
84
|
}
|
|
83
|
-
}, [client, schema, table])
|
|
85
|
+
}, [client, schema, table]);
|
|
84
86
|
|
|
85
87
|
useEffect(() => {
|
|
86
88
|
if (autoFetch && schema && table) {
|
|
87
|
-
fetchData()
|
|
89
|
+
fetchData();
|
|
88
90
|
}
|
|
89
|
-
}, [autoFetch, fetchData, schema, table])
|
|
91
|
+
}, [autoFetch, fetchData, schema, table]);
|
|
90
92
|
|
|
91
93
|
return {
|
|
92
94
|
data,
|
|
93
95
|
isLoading,
|
|
94
96
|
error,
|
|
95
97
|
refetch: fetchData,
|
|
96
|
-
}
|
|
98
|
+
};
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
// ============================================================================
|
|
@@ -101,10 +103,12 @@ export function useTableDetails(options: UseTableDetailsOptions): UseTableDetail
|
|
|
101
103
|
// ============================================================================
|
|
102
104
|
|
|
103
105
|
export interface UseExportTableReturn {
|
|
104
|
-
exportTable: (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
exportTable: (
|
|
107
|
+
options: ExportTableOptions,
|
|
108
|
+
) => Promise<ExportTableResult | null>;
|
|
109
|
+
isLoading: boolean;
|
|
110
|
+
error: Error | null;
|
|
111
|
+
reset: () => void;
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
/**
|
|
@@ -136,42 +140,45 @@ export interface UseExportTableReturn {
|
|
|
136
140
|
* ```
|
|
137
141
|
*/
|
|
138
142
|
export function useExportTable(knowledgeBaseId: string): UseExportTableReturn {
|
|
139
|
-
const client = useFluxbaseClient()
|
|
143
|
+
const client = useFluxbaseClient();
|
|
140
144
|
|
|
141
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
142
|
-
const [error, setError] = useState<Error | null>(null)
|
|
145
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
146
|
+
const [error, setError] = useState<Error | null>(null);
|
|
143
147
|
|
|
144
148
|
const exportTable = useCallback(
|
|
145
149
|
async (options: ExportTableOptions): Promise<ExportTableResult | null> => {
|
|
146
150
|
try {
|
|
147
|
-
setIsLoading(true)
|
|
148
|
-
setError(null)
|
|
149
|
-
const result = await client.admin.ai.exportTable(
|
|
151
|
+
setIsLoading(true);
|
|
152
|
+
setError(null);
|
|
153
|
+
const result = await client.admin.ai.exportTable(
|
|
154
|
+
knowledgeBaseId,
|
|
155
|
+
options,
|
|
156
|
+
);
|
|
150
157
|
if (result.error) {
|
|
151
|
-
throw result.error
|
|
158
|
+
throw result.error;
|
|
152
159
|
}
|
|
153
|
-
return result.data
|
|
160
|
+
return result.data;
|
|
154
161
|
} catch (err) {
|
|
155
|
-
setError(err as Error)
|
|
156
|
-
return null
|
|
162
|
+
setError(err as Error);
|
|
163
|
+
return null;
|
|
157
164
|
} finally {
|
|
158
|
-
setIsLoading(false)
|
|
165
|
+
setIsLoading(false);
|
|
159
166
|
}
|
|
160
167
|
},
|
|
161
168
|
[client, knowledgeBaseId],
|
|
162
|
-
)
|
|
169
|
+
);
|
|
163
170
|
|
|
164
171
|
const reset = useCallback(() => {
|
|
165
|
-
setError(null)
|
|
166
|
-
setIsLoading(false)
|
|
167
|
-
}, [])
|
|
172
|
+
setError(null);
|
|
173
|
+
setIsLoading(false);
|
|
174
|
+
}, []);
|
|
168
175
|
|
|
169
176
|
return {
|
|
170
177
|
exportTable,
|
|
171
178
|
isLoading,
|
|
172
179
|
error,
|
|
173
180
|
reset,
|
|
174
|
-
}
|
|
181
|
+
};
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
// ============================================================================
|
|
@@ -179,14 +186,14 @@ export function useExportTable(knowledgeBaseId: string): UseExportTableReturn {
|
|
|
179
186
|
// ============================================================================
|
|
180
187
|
|
|
181
188
|
export interface UseTableExportSyncsOptions {
|
|
182
|
-
autoFetch?: boolean
|
|
189
|
+
autoFetch?: boolean;
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
export interface UseTableExportSyncsReturn {
|
|
186
|
-
configs: TableExportSyncConfig[]
|
|
187
|
-
isLoading: boolean
|
|
188
|
-
error: Error | null
|
|
189
|
-
refetch: () => Promise<void
|
|
193
|
+
configs: TableExportSyncConfig[];
|
|
194
|
+
isLoading: boolean;
|
|
195
|
+
error: Error | null;
|
|
196
|
+
refetch: () => Promise<void>;
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
/**
|
|
@@ -215,41 +222,42 @@ export function useTableExportSyncs(
|
|
|
215
222
|
knowledgeBaseId: string,
|
|
216
223
|
options: UseTableExportSyncsOptions = {},
|
|
217
224
|
): UseTableExportSyncsReturn {
|
|
218
|
-
const { autoFetch = true } = options
|
|
219
|
-
const client = useFluxbaseClient()
|
|
225
|
+
const { autoFetch = true } = options;
|
|
226
|
+
const client = useFluxbaseClient();
|
|
220
227
|
|
|
221
|
-
const [configs, setConfigs] = useState<TableExportSyncConfig[]>([])
|
|
222
|
-
const [isLoading, setIsLoading] = useState(autoFetch)
|
|
223
|
-
const [error, setError] = useState<Error | null>(null)
|
|
228
|
+
const [configs, setConfigs] = useState<TableExportSyncConfig[]>([]);
|
|
229
|
+
const [isLoading, setIsLoading] = useState(autoFetch);
|
|
230
|
+
const [error, setError] = useState<Error | null>(null);
|
|
224
231
|
|
|
225
232
|
const fetchData = useCallback(async () => {
|
|
226
233
|
try {
|
|
227
|
-
setIsLoading(true)
|
|
228
|
-
setError(null)
|
|
229
|
-
const result =
|
|
234
|
+
setIsLoading(true);
|
|
235
|
+
setError(null);
|
|
236
|
+
const result =
|
|
237
|
+
await client.admin.ai.listTableExportSyncs(knowledgeBaseId);
|
|
230
238
|
if (result.error) {
|
|
231
|
-
throw result.error
|
|
239
|
+
throw result.error;
|
|
232
240
|
}
|
|
233
|
-
setConfigs(result.data || [])
|
|
241
|
+
setConfigs(result.data || []);
|
|
234
242
|
} catch (err) {
|
|
235
|
-
setError(err as Error)
|
|
243
|
+
setError(err as Error);
|
|
236
244
|
} finally {
|
|
237
|
-
setIsLoading(false)
|
|
245
|
+
setIsLoading(false);
|
|
238
246
|
}
|
|
239
|
-
}, [client, knowledgeBaseId])
|
|
247
|
+
}, [client, knowledgeBaseId]);
|
|
240
248
|
|
|
241
249
|
useEffect(() => {
|
|
242
250
|
if (autoFetch) {
|
|
243
|
-
fetchData()
|
|
251
|
+
fetchData();
|
|
244
252
|
}
|
|
245
|
-
}, [autoFetch, fetchData])
|
|
253
|
+
}, [autoFetch, fetchData]);
|
|
246
254
|
|
|
247
255
|
return {
|
|
248
256
|
configs,
|
|
249
257
|
isLoading,
|
|
250
258
|
error,
|
|
251
259
|
refetch: fetchData,
|
|
252
|
-
}
|
|
260
|
+
};
|
|
253
261
|
}
|
|
254
262
|
|
|
255
263
|
// ============================================================================
|
|
@@ -257,9 +265,11 @@ export function useTableExportSyncs(
|
|
|
257
265
|
// ============================================================================
|
|
258
266
|
|
|
259
267
|
export interface UseCreateTableExportSyncReturn {
|
|
260
|
-
createSync: (
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
createSync: (
|
|
269
|
+
config: CreateTableExportSyncConfig,
|
|
270
|
+
) => Promise<TableExportSyncConfig | null>;
|
|
271
|
+
isLoading: boolean;
|
|
272
|
+
error: Error | null;
|
|
263
273
|
}
|
|
264
274
|
|
|
265
275
|
/**
|
|
@@ -289,37 +299,44 @@ export interface UseCreateTableExportSyncReturn {
|
|
|
289
299
|
* }
|
|
290
300
|
* ```
|
|
291
301
|
*/
|
|
292
|
-
export function useCreateTableExportSync(
|
|
293
|
-
|
|
302
|
+
export function useCreateTableExportSync(
|
|
303
|
+
knowledgeBaseId: string,
|
|
304
|
+
): UseCreateTableExportSyncReturn {
|
|
305
|
+
const client = useFluxbaseClient();
|
|
294
306
|
|
|
295
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
296
|
-
const [error, setError] = useState<Error | null>(null)
|
|
307
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
308
|
+
const [error, setError] = useState<Error | null>(null);
|
|
297
309
|
|
|
298
310
|
const createSync = useCallback(
|
|
299
|
-
async (
|
|
311
|
+
async (
|
|
312
|
+
config: CreateTableExportSyncConfig,
|
|
313
|
+
): Promise<TableExportSyncConfig | null> => {
|
|
300
314
|
try {
|
|
301
|
-
setIsLoading(true)
|
|
302
|
-
setError(null)
|
|
303
|
-
const result = await client.admin.ai.createTableExportSync(
|
|
315
|
+
setIsLoading(true);
|
|
316
|
+
setError(null);
|
|
317
|
+
const result = await client.admin.ai.createTableExportSync(
|
|
318
|
+
knowledgeBaseId,
|
|
319
|
+
config,
|
|
320
|
+
);
|
|
304
321
|
if (result.error) {
|
|
305
|
-
throw result.error
|
|
322
|
+
throw result.error;
|
|
306
323
|
}
|
|
307
|
-
return result.data
|
|
324
|
+
return result.data;
|
|
308
325
|
} catch (err) {
|
|
309
|
-
setError(err as Error)
|
|
310
|
-
return null
|
|
326
|
+
setError(err as Error);
|
|
327
|
+
return null;
|
|
311
328
|
} finally {
|
|
312
|
-
setIsLoading(false)
|
|
329
|
+
setIsLoading(false);
|
|
313
330
|
}
|
|
314
331
|
},
|
|
315
332
|
[client, knowledgeBaseId],
|
|
316
|
-
)
|
|
333
|
+
);
|
|
317
334
|
|
|
318
335
|
return {
|
|
319
336
|
createSync,
|
|
320
337
|
isLoading,
|
|
321
338
|
error,
|
|
322
|
-
}
|
|
339
|
+
};
|
|
323
340
|
}
|
|
324
341
|
|
|
325
342
|
// ============================================================================
|
|
@@ -327,45 +344,57 @@ export function useCreateTableExportSync(knowledgeBaseId: string): UseCreateTabl
|
|
|
327
344
|
// ============================================================================
|
|
328
345
|
|
|
329
346
|
export interface UseUpdateTableExportSyncReturn {
|
|
330
|
-
updateSync: (
|
|
331
|
-
|
|
332
|
-
|
|
347
|
+
updateSync: (
|
|
348
|
+
syncId: string,
|
|
349
|
+
updates: UpdateTableExportSyncConfig,
|
|
350
|
+
) => Promise<TableExportSyncConfig | null>;
|
|
351
|
+
isLoading: boolean;
|
|
352
|
+
error: Error | null;
|
|
333
353
|
}
|
|
334
354
|
|
|
335
355
|
/**
|
|
336
356
|
* Hook for updating a table export sync configuration
|
|
337
357
|
*/
|
|
338
|
-
export function useUpdateTableExportSync(
|
|
339
|
-
|
|
358
|
+
export function useUpdateTableExportSync(
|
|
359
|
+
knowledgeBaseId: string,
|
|
360
|
+
): UseUpdateTableExportSyncReturn {
|
|
361
|
+
const client = useFluxbaseClient();
|
|
340
362
|
|
|
341
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
342
|
-
const [error, setError] = useState<Error | null>(null)
|
|
363
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
364
|
+
const [error, setError] = useState<Error | null>(null);
|
|
343
365
|
|
|
344
366
|
const updateSync = useCallback(
|
|
345
|
-
async (
|
|
367
|
+
async (
|
|
368
|
+
syncId: string,
|
|
369
|
+
updates: UpdateTableExportSyncConfig,
|
|
370
|
+
): Promise<TableExportSyncConfig | null> => {
|
|
346
371
|
try {
|
|
347
|
-
setIsLoading(true)
|
|
348
|
-
setError(null)
|
|
349
|
-
const result = await client.admin.ai.updateTableExportSync(
|
|
372
|
+
setIsLoading(true);
|
|
373
|
+
setError(null);
|
|
374
|
+
const result = await client.admin.ai.updateTableExportSync(
|
|
375
|
+
knowledgeBaseId,
|
|
376
|
+
syncId,
|
|
377
|
+
updates,
|
|
378
|
+
);
|
|
350
379
|
if (result.error) {
|
|
351
|
-
throw result.error
|
|
380
|
+
throw result.error;
|
|
352
381
|
}
|
|
353
|
-
return result.data
|
|
382
|
+
return result.data;
|
|
354
383
|
} catch (err) {
|
|
355
|
-
setError(err as Error)
|
|
356
|
-
return null
|
|
384
|
+
setError(err as Error);
|
|
385
|
+
return null;
|
|
357
386
|
} finally {
|
|
358
|
-
setIsLoading(false)
|
|
387
|
+
setIsLoading(false);
|
|
359
388
|
}
|
|
360
389
|
},
|
|
361
390
|
[client, knowledgeBaseId],
|
|
362
|
-
)
|
|
391
|
+
);
|
|
363
392
|
|
|
364
393
|
return {
|
|
365
394
|
updateSync,
|
|
366
395
|
isLoading,
|
|
367
396
|
error,
|
|
368
|
-
}
|
|
397
|
+
};
|
|
369
398
|
}
|
|
370
399
|
|
|
371
400
|
// ============================================================================
|
|
@@ -373,45 +402,50 @@ export function useUpdateTableExportSync(knowledgeBaseId: string): UseUpdateTabl
|
|
|
373
402
|
// ============================================================================
|
|
374
403
|
|
|
375
404
|
export interface UseDeleteTableExportSyncReturn {
|
|
376
|
-
deleteSync: (syncId: string) => Promise<boolean
|
|
377
|
-
isLoading: boolean
|
|
378
|
-
error: Error | null
|
|
405
|
+
deleteSync: (syncId: string) => Promise<boolean>;
|
|
406
|
+
isLoading: boolean;
|
|
407
|
+
error: Error | null;
|
|
379
408
|
}
|
|
380
409
|
|
|
381
410
|
/**
|
|
382
411
|
* Hook for deleting a table export sync configuration
|
|
383
412
|
*/
|
|
384
|
-
export function useDeleteTableExportSync(
|
|
385
|
-
|
|
413
|
+
export function useDeleteTableExportSync(
|
|
414
|
+
knowledgeBaseId: string,
|
|
415
|
+
): UseDeleteTableExportSyncReturn {
|
|
416
|
+
const client = useFluxbaseClient();
|
|
386
417
|
|
|
387
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
388
|
-
const [error, setError] = useState<Error | null>(null)
|
|
418
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
419
|
+
const [error, setError] = useState<Error | null>(null);
|
|
389
420
|
|
|
390
421
|
const deleteSync = useCallback(
|
|
391
422
|
async (syncId: string): Promise<boolean> => {
|
|
392
423
|
try {
|
|
393
|
-
setIsLoading(true)
|
|
394
|
-
setError(null)
|
|
395
|
-
const result = await client.admin.ai.deleteTableExportSync(
|
|
424
|
+
setIsLoading(true);
|
|
425
|
+
setError(null);
|
|
426
|
+
const result = await client.admin.ai.deleteTableExportSync(
|
|
427
|
+
knowledgeBaseId,
|
|
428
|
+
syncId,
|
|
429
|
+
);
|
|
396
430
|
if (result.error) {
|
|
397
|
-
throw result.error
|
|
431
|
+
throw result.error;
|
|
398
432
|
}
|
|
399
|
-
return true
|
|
433
|
+
return true;
|
|
400
434
|
} catch (err) {
|
|
401
|
-
setError(err as Error)
|
|
402
|
-
return false
|
|
435
|
+
setError(err as Error);
|
|
436
|
+
return false;
|
|
403
437
|
} finally {
|
|
404
|
-
setIsLoading(false)
|
|
438
|
+
setIsLoading(false);
|
|
405
439
|
}
|
|
406
440
|
},
|
|
407
441
|
[client, knowledgeBaseId],
|
|
408
|
-
)
|
|
442
|
+
);
|
|
409
443
|
|
|
410
444
|
return {
|
|
411
445
|
deleteSync,
|
|
412
446
|
isLoading,
|
|
413
447
|
error,
|
|
414
|
-
}
|
|
448
|
+
};
|
|
415
449
|
}
|
|
416
450
|
|
|
417
451
|
// ============================================================================
|
|
@@ -419,9 +453,9 @@ export function useDeleteTableExportSync(knowledgeBaseId: string): UseDeleteTabl
|
|
|
419
453
|
// ============================================================================
|
|
420
454
|
|
|
421
455
|
export interface UseTriggerTableExportSyncReturn {
|
|
422
|
-
triggerSync: (syncId: string) => Promise<ExportTableResult | null
|
|
423
|
-
isLoading: boolean
|
|
424
|
-
error: Error | null
|
|
456
|
+
triggerSync: (syncId: string) => Promise<ExportTableResult | null>;
|
|
457
|
+
isLoading: boolean;
|
|
458
|
+
error: Error | null;
|
|
425
459
|
}
|
|
426
460
|
|
|
427
461
|
/**
|
|
@@ -447,35 +481,40 @@ export interface UseTriggerTableExportSyncReturn {
|
|
|
447
481
|
* }
|
|
448
482
|
* ```
|
|
449
483
|
*/
|
|
450
|
-
export function useTriggerTableExportSync(
|
|
451
|
-
|
|
484
|
+
export function useTriggerTableExportSync(
|
|
485
|
+
knowledgeBaseId: string,
|
|
486
|
+
): UseTriggerTableExportSyncReturn {
|
|
487
|
+
const client = useFluxbaseClient();
|
|
452
488
|
|
|
453
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
454
|
-
const [error, setError] = useState<Error | null>(null)
|
|
489
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
490
|
+
const [error, setError] = useState<Error | null>(null);
|
|
455
491
|
|
|
456
492
|
const triggerSync = useCallback(
|
|
457
493
|
async (syncId: string): Promise<ExportTableResult | null> => {
|
|
458
494
|
try {
|
|
459
|
-
setIsLoading(true)
|
|
460
|
-
setError(null)
|
|
461
|
-
const result = await client.admin.ai.triggerTableExportSync(
|
|
495
|
+
setIsLoading(true);
|
|
496
|
+
setError(null);
|
|
497
|
+
const result = await client.admin.ai.triggerTableExportSync(
|
|
498
|
+
knowledgeBaseId,
|
|
499
|
+
syncId,
|
|
500
|
+
);
|
|
462
501
|
if (result.error) {
|
|
463
|
-
throw result.error
|
|
502
|
+
throw result.error;
|
|
464
503
|
}
|
|
465
|
-
return result.data
|
|
504
|
+
return result.data;
|
|
466
505
|
} catch (err) {
|
|
467
|
-
setError(err as Error)
|
|
468
|
-
return null
|
|
506
|
+
setError(err as Error);
|
|
507
|
+
return null;
|
|
469
508
|
} finally {
|
|
470
|
-
setIsLoading(false)
|
|
509
|
+
setIsLoading(false);
|
|
471
510
|
}
|
|
472
511
|
},
|
|
473
512
|
[client, knowledgeBaseId],
|
|
474
|
-
)
|
|
513
|
+
);
|
|
475
514
|
|
|
476
515
|
return {
|
|
477
516
|
triggerSync,
|
|
478
517
|
isLoading,
|
|
479
518
|
error,
|
|
480
|
-
}
|
|
519
|
+
};
|
|
481
520
|
}
|