@nimbleflux/fluxbase-sdk-react 2026.3.7-rc.2 → 2026.3.7-rc.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbleflux/fluxbase-sdk-react",
3
- "version": "2026.3.7-rc.2",
3
+ "version": "2026.3.7-rc.3",
4
4
  "description": "React hooks for Fluxbase SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "peerDependencies": {
42
- "@nimbleflux/fluxbase-sdk": "^2026.3.7-rc.2",
42
+ "@nimbleflux/fluxbase-sdk": "^2026.3.7-rc.3",
43
43
  "@tanstack/react-query": "^5.96.2",
44
44
  "react": "^18.0.0 || ^19.0.0"
45
45
  },
package/src/index.test.ts CHANGED
@@ -191,14 +191,6 @@ describe('Module Exports', () => {
191
191
  expect(exports.useStorageSignedUrlWithOptions).toBeDefined();
192
192
  });
193
193
 
194
- it('should export useStorageMove', () => {
195
- expect(exports.useStorageMove).toBeDefined();
196
- });
197
-
198
- it('should export useStorageCopy', () => {
199
- expect(exports.useStorageCopy).toBeDefined();
200
- });
201
-
202
194
  it('should export useStorageBuckets', () => {
203
195
  expect(exports.useStorageBuckets).toBeDefined();
204
196
  });
package/src/index.ts CHANGED
@@ -103,8 +103,6 @@ export {
103
103
  useStorageTransformUrl,
104
104
  useStorageSignedUrl,
105
105
  useStorageSignedUrlWithOptions,
106
- useStorageMove,
107
- useStorageCopy,
108
106
  useStorageBuckets,
109
107
  useCreateBucket,
110
108
  useDeleteBucket,
@@ -133,21 +131,8 @@ export {
133
131
  // Table export hooks
134
132
  export {
135
133
  useTableDetails,
136
- useExportTable,
137
- useTableExportSyncs,
138
- useCreateTableExportSync,
139
- useUpdateTableExportSync,
140
- useDeleteTableExportSync,
141
- useTriggerTableExportSync,
142
134
  type UseTableDetailsOptions,
143
135
  type UseTableDetailsReturn,
144
- type UseExportTableReturn,
145
- type UseTableExportSyncsOptions,
146
- type UseTableExportSyncsReturn,
147
- type UseCreateTableExportSyncReturn,
148
- type UseUpdateTableExportSyncReturn,
149
- type UseDeleteTableExportSyncReturn,
150
- type UseTriggerTableExportSyncReturn,
151
136
  } from "./use-table-export";
152
137
 
153
138
  // Re-export types from SDK
@@ -14,8 +14,6 @@ import {
14
14
  useStorageTransformUrl,
15
15
  useStorageSignedUrl,
16
16
  useStorageSignedUrlWithOptions,
17
- useStorageMove,
18
- useStorageCopy,
19
17
  useStorageBuckets,
20
18
  useCreateBucket,
21
19
  useDeleteBucket,
@@ -431,56 +429,6 @@ describe('useStorageSignedUrlWithOptions', () => {
431
429
  });
432
430
  });
433
431
 
434
- describe('useStorageMove', () => {
435
- it('should move file and invalidate queries', async () => {
436
- const moveMock = vi.fn().mockResolvedValue({ data: { path: 'new.txt' }, error: null });
437
- const fromMock = vi.fn().mockReturnValue({ move: moveMock });
438
-
439
- const client = createMockClient({
440
- storage: { from: fromMock },
441
- } as any);
442
-
443
- const queryClient = createTestQueryClient();
444
- const invalidateSpy = vi.spyOn(queryClient, 'invalidateQueries');
445
-
446
- const { result } = renderHook(() => useStorageMove('bucket'), {
447
- wrapper: createWrapper(client, queryClient),
448
- });
449
-
450
- await act(async () => {
451
- await result.current.mutateAsync({ fromPath: 'old.txt', toPath: 'new.txt' });
452
- });
453
-
454
- expect(moveMock).toHaveBeenCalledWith('old.txt', 'new.txt');
455
- expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ['fluxbase', 'storage', 'bucket', 'list'] });
456
- });
457
- });
458
-
459
- describe('useStorageCopy', () => {
460
- it('should copy file and invalidate queries', async () => {
461
- const copyMock = vi.fn().mockResolvedValue({ data: { path: 'copy.txt' }, error: null });
462
- const fromMock = vi.fn().mockReturnValue({ copy: copyMock });
463
-
464
- const client = createMockClient({
465
- storage: { from: fromMock },
466
- } as any);
467
-
468
- const queryClient = createTestQueryClient();
469
- const invalidateSpy = vi.spyOn(queryClient, 'invalidateQueries');
470
-
471
- const { result } = renderHook(() => useStorageCopy('bucket'), {
472
- wrapper: createWrapper(client, queryClient),
473
- });
474
-
475
- await act(async () => {
476
- await result.current.mutateAsync({ fromPath: 'source.txt', toPath: 'copy.txt' });
477
- });
478
-
479
- expect(copyMock).toHaveBeenCalledWith('source.txt', 'copy.txt');
480
- expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ['fluxbase', 'storage', 'bucket', 'list'] });
481
- });
482
- });
483
-
484
432
  describe('useStorageBuckets', () => {
485
433
  it('should list buckets', async () => {
486
434
  const mockBuckets = [{ name: 'bucket1' }, { name: 'bucket2' }];
@@ -387,62 +387,6 @@ export function useStorageSignedUrlWithOptions(
387
387
  });
388
388
  }
389
389
 
390
- /**
391
- * Hook to move a file
392
- */
393
- export function useStorageMove(bucket: string) {
394
- const client = useFluxbaseClient();
395
- const queryClient = useQueryClient();
396
-
397
- return useMutation({
398
- mutationFn: async (params: { fromPath: string; toPath: string }) => {
399
- const { fromPath, toPath } = params;
400
- const { data, error } = await client.storage
401
- .from(bucket)
402
- .move(fromPath, toPath);
403
-
404
- if (error) {
405
- throw error;
406
- }
407
-
408
- return data;
409
- },
410
- onSuccess: () => {
411
- queryClient.invalidateQueries({
412
- queryKey: ["fluxbase", "storage", bucket, "list"],
413
- });
414
- },
415
- });
416
- }
417
-
418
- /**
419
- * Hook to copy a file
420
- */
421
- export function useStorageCopy(bucket: string) {
422
- const client = useFluxbaseClient();
423
- const queryClient = useQueryClient();
424
-
425
- return useMutation({
426
- mutationFn: async (params: { fromPath: string; toPath: string }) => {
427
- const { fromPath, toPath } = params;
428
- const { data, error } = await client.storage
429
- .from(bucket)
430
- .copy(fromPath, toPath);
431
-
432
- if (error) {
433
- throw error;
434
- }
435
-
436
- return data;
437
- },
438
- onSuccess: () => {
439
- queryClient.invalidateQueries({
440
- queryKey: ["fluxbase", "storage", bucket, "list"],
441
- });
442
- },
443
- });
444
- }
445
-
446
390
  /**
447
391
  * Hook to manage buckets
448
392
  */
@@ -1,19 +1,12 @@
1
1
  /**
2
2
  * Table Export Hooks
3
3
  *
4
- * React hooks for exporting database tables to knowledge bases and managing sync configurations.
4
+ * React hooks for exporting database tables to knowledge bases.
5
5
  */
6
6
 
7
7
  import { useState, useEffect, useCallback } from "react";
8
8
  import { useFluxbaseClient } from "./context";
9
- import type {
10
- ExportTableOptions,
11
- ExportTableResult,
12
- TableDetails,
13
- TableExportSyncConfig,
14
- CreateTableExportSyncConfig,
15
- UpdateTableExportSyncConfig,
16
- } from "@nimbleflux/fluxbase-sdk";
9
+ import type { TableDetails } from "@nimbleflux/fluxbase-sdk";
17
10
 
18
11
  // ============================================================================
19
12
  // useTableDetails Hook
@@ -97,424 +90,3 @@ export function useTableDetails(
97
90
  refetch: fetchData,
98
91
  };
99
92
  }
100
-
101
- // ============================================================================
102
- // useExportTable Hook
103
- // ============================================================================
104
-
105
- export interface UseExportTableReturn {
106
- exportTable: (
107
- options: ExportTableOptions,
108
- ) => Promise<ExportTableResult | null>;
109
- isLoading: boolean;
110
- error: Error | null;
111
- reset: () => void;
112
- }
113
-
114
- /**
115
- * Hook for exporting a table to a knowledge base
116
- *
117
- * @example
118
- * ```tsx
119
- * function ExportTableButton({ kbId, schema, table }: Props) {
120
- * const { exportTable, isLoading, error } = useExportTable(kbId)
121
- *
122
- * const handleExport = async () => {
123
- * const result = await exportTable({
124
- * schema,
125
- * table,
126
- * columns: ['id', 'name', 'email'],
127
- * include_foreign_keys: true,
128
- * })
129
- * if (result) {
130
- * console.log('Exported document:', result.document_id)
131
- * }
132
- * }
133
- *
134
- * return (
135
- * <button onClick={handleExport} disabled={isLoading}>
136
- * {isLoading ? 'Exporting...' : 'Export Table'}
137
- * </button>
138
- * )
139
- * }
140
- * ```
141
- */
142
- export function useExportTable(knowledgeBaseId: string): UseExportTableReturn {
143
- const client = useFluxbaseClient();
144
-
145
- const [isLoading, setIsLoading] = useState(false);
146
- const [error, setError] = useState<Error | null>(null);
147
-
148
- const exportTable = useCallback(
149
- async (options: ExportTableOptions): Promise<ExportTableResult | null> => {
150
- try {
151
- setIsLoading(true);
152
- setError(null);
153
- const result = await client.admin.ai.exportTable(
154
- knowledgeBaseId,
155
- options,
156
- );
157
- if (result.error) {
158
- throw result.error;
159
- }
160
- return result.data;
161
- } catch (err) {
162
- setError(err as Error);
163
- return null;
164
- } finally {
165
- setIsLoading(false);
166
- }
167
- },
168
- [client, knowledgeBaseId],
169
- );
170
-
171
- const reset = useCallback(() => {
172
- setError(null);
173
- setIsLoading(false);
174
- }, []);
175
-
176
- return {
177
- exportTable,
178
- isLoading,
179
- error,
180
- reset,
181
- };
182
- }
183
-
184
- // ============================================================================
185
- // useTableExportSyncs Hook
186
- // ============================================================================
187
-
188
- export interface UseTableExportSyncsOptions {
189
- autoFetch?: boolean;
190
- }
191
-
192
- export interface UseTableExportSyncsReturn {
193
- configs: TableExportSyncConfig[];
194
- isLoading: boolean;
195
- error: Error | null;
196
- refetch: () => Promise<void>;
197
- }
198
-
199
- /**
200
- * Hook for listing table export sync configurations
201
- *
202
- * @example
203
- * ```tsx
204
- * function SyncConfigsList({ kbId }: { kbId: string }) {
205
- * const { configs, isLoading, error } = useTableExportSyncs(kbId)
206
- *
207
- * if (isLoading) return <div>Loading...</div>
208
- *
209
- * return (
210
- * <ul>
211
- * {configs.map(config => (
212
- * <li key={config.id}>
213
- * {config.schema_name}.{config.table_name} ({config.sync_mode})
214
- * </li>
215
- * ))}
216
- * </ul>
217
- * )
218
- * }
219
- * ```
220
- */
221
- export function useTableExportSyncs(
222
- knowledgeBaseId: string,
223
- options: UseTableExportSyncsOptions = {},
224
- ): UseTableExportSyncsReturn {
225
- const { autoFetch = true } = options;
226
- const client = useFluxbaseClient();
227
-
228
- const [configs, setConfigs] = useState<TableExportSyncConfig[]>([]);
229
- const [isLoading, setIsLoading] = useState(autoFetch);
230
- const [error, setError] = useState<Error | null>(null);
231
-
232
- const fetchData = useCallback(async () => {
233
- try {
234
- setIsLoading(true);
235
- setError(null);
236
- const result =
237
- await client.admin.ai.listTableExportSyncs(knowledgeBaseId);
238
- if (result.error) {
239
- throw result.error;
240
- }
241
- setConfigs(result.data || []);
242
- } catch (err) {
243
- setError(err as Error);
244
- } finally {
245
- setIsLoading(false);
246
- }
247
- }, [client, knowledgeBaseId]);
248
-
249
- useEffect(() => {
250
- if (autoFetch) {
251
- fetchData();
252
- }
253
- }, [autoFetch, fetchData]);
254
-
255
- return {
256
- configs,
257
- isLoading,
258
- error,
259
- refetch: fetchData,
260
- };
261
- }
262
-
263
- // ============================================================================
264
- // useCreateTableExportSync Hook
265
- // ============================================================================
266
-
267
- export interface UseCreateTableExportSyncReturn {
268
- createSync: (
269
- config: CreateTableExportSyncConfig,
270
- ) => Promise<TableExportSyncConfig | null>;
271
- isLoading: boolean;
272
- error: Error | null;
273
- }
274
-
275
- /**
276
- * Hook for creating a table export sync configuration
277
- *
278
- * @example
279
- * ```tsx
280
- * function CreateSyncForm({ kbId }: { kbId: string }) {
281
- * const { createSync, isLoading, error } = useCreateTableExportSync(kbId)
282
- *
283
- * const handleSubmit = async (e: React.FormEvent) => {
284
- * e.preventDefault()
285
- * const config = await createSync({
286
- * schema_name: 'public',
287
- * table_name: 'users',
288
- * columns: ['id', 'name', 'email'],
289
- * sync_mode: 'automatic',
290
- * sync_on_insert: true,
291
- * sync_on_update: true,
292
- * })
293
- * if (config) {
294
- * console.log('Created sync config:', config.id)
295
- * }
296
- * }
297
- *
298
- * return <form onSubmit={handleSubmit}>...</form>
299
- * }
300
- * ```
301
- */
302
- export function useCreateTableExportSync(
303
- knowledgeBaseId: string,
304
- ): UseCreateTableExportSyncReturn {
305
- const client = useFluxbaseClient();
306
-
307
- const [isLoading, setIsLoading] = useState(false);
308
- const [error, setError] = useState<Error | null>(null);
309
-
310
- const createSync = useCallback(
311
- async (
312
- config: CreateTableExportSyncConfig,
313
- ): Promise<TableExportSyncConfig | null> => {
314
- try {
315
- setIsLoading(true);
316
- setError(null);
317
- const result = await client.admin.ai.createTableExportSync(
318
- knowledgeBaseId,
319
- config,
320
- );
321
- if (result.error) {
322
- throw result.error;
323
- }
324
- return result.data;
325
- } catch (err) {
326
- setError(err as Error);
327
- return null;
328
- } finally {
329
- setIsLoading(false);
330
- }
331
- },
332
- [client, knowledgeBaseId],
333
- );
334
-
335
- return {
336
- createSync,
337
- isLoading,
338
- error,
339
- };
340
- }
341
-
342
- // ============================================================================
343
- // useUpdateTableExportSync Hook
344
- // ============================================================================
345
-
346
- export interface UseUpdateTableExportSyncReturn {
347
- updateSync: (
348
- syncId: string,
349
- updates: UpdateTableExportSyncConfig,
350
- ) => Promise<TableExportSyncConfig | null>;
351
- isLoading: boolean;
352
- error: Error | null;
353
- }
354
-
355
- /**
356
- * Hook for updating a table export sync configuration
357
- */
358
- export function useUpdateTableExportSync(
359
- knowledgeBaseId: string,
360
- ): UseUpdateTableExportSyncReturn {
361
- const client = useFluxbaseClient();
362
-
363
- const [isLoading, setIsLoading] = useState(false);
364
- const [error, setError] = useState<Error | null>(null);
365
-
366
- const updateSync = useCallback(
367
- async (
368
- syncId: string,
369
- updates: UpdateTableExportSyncConfig,
370
- ): Promise<TableExportSyncConfig | null> => {
371
- try {
372
- setIsLoading(true);
373
- setError(null);
374
- const result = await client.admin.ai.updateTableExportSync(
375
- knowledgeBaseId,
376
- syncId,
377
- updates,
378
- );
379
- if (result.error) {
380
- throw result.error;
381
- }
382
- return result.data;
383
- } catch (err) {
384
- setError(err as Error);
385
- return null;
386
- } finally {
387
- setIsLoading(false);
388
- }
389
- },
390
- [client, knowledgeBaseId],
391
- );
392
-
393
- return {
394
- updateSync,
395
- isLoading,
396
- error,
397
- };
398
- }
399
-
400
- // ============================================================================
401
- // useDeleteTableExportSync Hook
402
- // ============================================================================
403
-
404
- export interface UseDeleteTableExportSyncReturn {
405
- deleteSync: (syncId: string) => Promise<boolean>;
406
- isLoading: boolean;
407
- error: Error | null;
408
- }
409
-
410
- /**
411
- * Hook for deleting a table export sync configuration
412
- */
413
- export function useDeleteTableExportSync(
414
- knowledgeBaseId: string,
415
- ): UseDeleteTableExportSyncReturn {
416
- const client = useFluxbaseClient();
417
-
418
- const [isLoading, setIsLoading] = useState(false);
419
- const [error, setError] = useState<Error | null>(null);
420
-
421
- const deleteSync = useCallback(
422
- async (syncId: string): Promise<boolean> => {
423
- try {
424
- setIsLoading(true);
425
- setError(null);
426
- const result = await client.admin.ai.deleteTableExportSync(
427
- knowledgeBaseId,
428
- syncId,
429
- );
430
- if (result.error) {
431
- throw result.error;
432
- }
433
- return true;
434
- } catch (err) {
435
- setError(err as Error);
436
- return false;
437
- } finally {
438
- setIsLoading(false);
439
- }
440
- },
441
- [client, knowledgeBaseId],
442
- );
443
-
444
- return {
445
- deleteSync,
446
- isLoading,
447
- error,
448
- };
449
- }
450
-
451
- // ============================================================================
452
- // useTriggerTableExportSync Hook
453
- // ============================================================================
454
-
455
- export interface UseTriggerTableExportSyncReturn {
456
- triggerSync: (syncId: string) => Promise<ExportTableResult | null>;
457
- isLoading: boolean;
458
- error: Error | null;
459
- }
460
-
461
- /**
462
- * Hook for manually triggering a table export sync
463
- *
464
- * @example
465
- * ```tsx
466
- * function TriggerSyncButton({ kbId, syncId }: Props) {
467
- * const { triggerSync, isLoading, error } = useTriggerTableExportSync(kbId)
468
- *
469
- * const handleTrigger = async () => {
470
- * const result = await triggerSync(syncId)
471
- * if (result) {
472
- * console.log('Sync completed:', result.document_id)
473
- * }
474
- * }
475
- *
476
- * return (
477
- * <button onClick={handleTrigger} disabled={isLoading}>
478
- * {isLoading ? 'Syncing...' : 'Sync Now'}
479
- * </button>
480
- * )
481
- * }
482
- * ```
483
- */
484
- export function useTriggerTableExportSync(
485
- knowledgeBaseId: string,
486
- ): UseTriggerTableExportSyncReturn {
487
- const client = useFluxbaseClient();
488
-
489
- const [isLoading, setIsLoading] = useState(false);
490
- const [error, setError] = useState<Error | null>(null);
491
-
492
- const triggerSync = useCallback(
493
- async (syncId: string): Promise<ExportTableResult | null> => {
494
- try {
495
- setIsLoading(true);
496
- setError(null);
497
- const result = await client.admin.ai.triggerTableExportSync(
498
- knowledgeBaseId,
499
- syncId,
500
- );
501
- if (result.error) {
502
- throw result.error;
503
- }
504
- return result.data;
505
- } catch (err) {
506
- setError(err as Error);
507
- return null;
508
- } finally {
509
- setIsLoading(false);
510
- }
511
- },
512
- [client, knowledgeBaseId],
513
- );
514
-
515
- return {
516
- triggerSync,
517
- isLoading,
518
- error,
519
- };
520
- }