@fluxbase/sdk-react 2026.2.3-rc.8 → 2026.2.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/dist/index.d.mts +192 -2
- package/dist/index.d.ts +192 -2
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +227 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +20 -0
- package/src/use-table-export.ts +481 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as _fluxbase_sdk from '@fluxbase/sdk';
|
|
4
|
-
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLLoginOptions, SAMLProvider, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, SignedUrlOptions, TransformOptions, UploadOptions, UploadProgress, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest } from '@fluxbase/sdk';
|
|
4
|
+
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLLoginOptions, SAMLProvider, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, SignedUrlOptions, TransformOptions, UploadOptions, UploadProgress, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest, CreateTableExportSyncConfig, TableExportSyncConfig, ExportTableOptions, ExportTableResult, TableDetails, UpdateTableExportSyncConfig } from '@fluxbase/sdk';
|
|
5
5
|
export { APIKey, AdminUser, AppSettings, AuthSession, CaptchaConfig, CaptchaProvider, ClientKey, EnrichedUser, FluxbaseClient, GraphQLError, GraphQLErrorLocation, GraphQLRequestOptions, GraphQLResponse, ImageFitMode, ImageFormat, PostgrestResponse, RealtimeChangePayload, SAMLLoginOptions, SAMLLoginResponse, SAMLProvider, SAMLProvidersResponse, SAMLSession, SignInCredentials, SignUpCredentials, SignedUrlOptions, StorageObject, SystemSetting, TransformOptions, User, Webhook } from '@fluxbase/sdk';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
@@ -1264,4 +1264,194 @@ interface UseWebhooksReturn {
|
|
|
1264
1264
|
*/
|
|
1265
1265
|
declare function useWebhooks(options?: UseWebhooksOptions): UseWebhooksReturn;
|
|
1266
1266
|
|
|
1267
|
-
|
|
1267
|
+
/**
|
|
1268
|
+
* Table Export Hooks
|
|
1269
|
+
*
|
|
1270
|
+
* React hooks for exporting database tables to knowledge bases and managing sync configurations.
|
|
1271
|
+
*/
|
|
1272
|
+
|
|
1273
|
+
interface UseTableDetailsOptions {
|
|
1274
|
+
schema?: string;
|
|
1275
|
+
table?: string;
|
|
1276
|
+
autoFetch?: boolean;
|
|
1277
|
+
}
|
|
1278
|
+
interface UseTableDetailsReturn {
|
|
1279
|
+
data: TableDetails | null;
|
|
1280
|
+
isLoading: boolean;
|
|
1281
|
+
error: Error | null;
|
|
1282
|
+
refetch: () => Promise<void>;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Hook for fetching detailed table information including columns
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* ```tsx
|
|
1289
|
+
* function TableColumnsList({ schema, table }: { schema: string; table: string }) {
|
|
1290
|
+
* const { data, isLoading, error } = useTableDetails({ schema, table })
|
|
1291
|
+
*
|
|
1292
|
+
* if (isLoading) return <div>Loading...</div>
|
|
1293
|
+
* if (error) return <div>Error: {error.message}</div>
|
|
1294
|
+
*
|
|
1295
|
+
* return (
|
|
1296
|
+
* <ul>
|
|
1297
|
+
* {data?.columns.map(col => (
|
|
1298
|
+
* <li key={col.name}>
|
|
1299
|
+
* {col.name} ({col.data_type})
|
|
1300
|
+
* {col.is_primary_key && ' 🔑'}
|
|
1301
|
+
* </li>
|
|
1302
|
+
* ))}
|
|
1303
|
+
* </ul>
|
|
1304
|
+
* )
|
|
1305
|
+
* }
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
declare function useTableDetails(options: UseTableDetailsOptions): UseTableDetailsReturn;
|
|
1309
|
+
interface UseExportTableReturn {
|
|
1310
|
+
exportTable: (options: ExportTableOptions) => Promise<ExportTableResult | null>;
|
|
1311
|
+
isLoading: boolean;
|
|
1312
|
+
error: Error | null;
|
|
1313
|
+
reset: () => void;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Hook for exporting a table to a knowledge base
|
|
1317
|
+
*
|
|
1318
|
+
* @example
|
|
1319
|
+
* ```tsx
|
|
1320
|
+
* function ExportTableButton({ kbId, schema, table }: Props) {
|
|
1321
|
+
* const { exportTable, isLoading, error } = useExportTable(kbId)
|
|
1322
|
+
*
|
|
1323
|
+
* const handleExport = async () => {
|
|
1324
|
+
* const result = await exportTable({
|
|
1325
|
+
* schema,
|
|
1326
|
+
* table,
|
|
1327
|
+
* columns: ['id', 'name', 'email'],
|
|
1328
|
+
* include_foreign_keys: true,
|
|
1329
|
+
* })
|
|
1330
|
+
* if (result) {
|
|
1331
|
+
* console.log('Exported document:', result.document_id)
|
|
1332
|
+
* }
|
|
1333
|
+
* }
|
|
1334
|
+
*
|
|
1335
|
+
* return (
|
|
1336
|
+
* <button onClick={handleExport} disabled={isLoading}>
|
|
1337
|
+
* {isLoading ? 'Exporting...' : 'Export Table'}
|
|
1338
|
+
* </button>
|
|
1339
|
+
* )
|
|
1340
|
+
* }
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
declare function useExportTable(knowledgeBaseId: string): UseExportTableReturn;
|
|
1344
|
+
interface UseTableExportSyncsOptions {
|
|
1345
|
+
autoFetch?: boolean;
|
|
1346
|
+
}
|
|
1347
|
+
interface UseTableExportSyncsReturn {
|
|
1348
|
+
configs: TableExportSyncConfig[];
|
|
1349
|
+
isLoading: boolean;
|
|
1350
|
+
error: Error | null;
|
|
1351
|
+
refetch: () => Promise<void>;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Hook for listing table export sync configurations
|
|
1355
|
+
*
|
|
1356
|
+
* @example
|
|
1357
|
+
* ```tsx
|
|
1358
|
+
* function SyncConfigsList({ kbId }: { kbId: string }) {
|
|
1359
|
+
* const { configs, isLoading, error } = useTableExportSyncs(kbId)
|
|
1360
|
+
*
|
|
1361
|
+
* if (isLoading) return <div>Loading...</div>
|
|
1362
|
+
*
|
|
1363
|
+
* return (
|
|
1364
|
+
* <ul>
|
|
1365
|
+
* {configs.map(config => (
|
|
1366
|
+
* <li key={config.id}>
|
|
1367
|
+
* {config.schema_name}.{config.table_name} ({config.sync_mode})
|
|
1368
|
+
* </li>
|
|
1369
|
+
* ))}
|
|
1370
|
+
* </ul>
|
|
1371
|
+
* )
|
|
1372
|
+
* }
|
|
1373
|
+
* ```
|
|
1374
|
+
*/
|
|
1375
|
+
declare function useTableExportSyncs(knowledgeBaseId: string, options?: UseTableExportSyncsOptions): UseTableExportSyncsReturn;
|
|
1376
|
+
interface UseCreateTableExportSyncReturn {
|
|
1377
|
+
createSync: (config: CreateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1378
|
+
isLoading: boolean;
|
|
1379
|
+
error: Error | null;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Hook for creating a table export sync configuration
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```tsx
|
|
1386
|
+
* function CreateSyncForm({ kbId }: { kbId: string }) {
|
|
1387
|
+
* const { createSync, isLoading, error } = useCreateTableExportSync(kbId)
|
|
1388
|
+
*
|
|
1389
|
+
* const handleSubmit = async (e: React.FormEvent) => {
|
|
1390
|
+
* e.preventDefault()
|
|
1391
|
+
* const config = await createSync({
|
|
1392
|
+
* schema_name: 'public',
|
|
1393
|
+
* table_name: 'users',
|
|
1394
|
+
* columns: ['id', 'name', 'email'],
|
|
1395
|
+
* sync_mode: 'automatic',
|
|
1396
|
+
* sync_on_insert: true,
|
|
1397
|
+
* sync_on_update: true,
|
|
1398
|
+
* })
|
|
1399
|
+
* if (config) {
|
|
1400
|
+
* console.log('Created sync config:', config.id)
|
|
1401
|
+
* }
|
|
1402
|
+
* }
|
|
1403
|
+
*
|
|
1404
|
+
* return <form onSubmit={handleSubmit}>...</form>
|
|
1405
|
+
* }
|
|
1406
|
+
* ```
|
|
1407
|
+
*/
|
|
1408
|
+
declare function useCreateTableExportSync(knowledgeBaseId: string): UseCreateTableExportSyncReturn;
|
|
1409
|
+
interface UseUpdateTableExportSyncReturn {
|
|
1410
|
+
updateSync: (syncId: string, updates: UpdateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1411
|
+
isLoading: boolean;
|
|
1412
|
+
error: Error | null;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Hook for updating a table export sync configuration
|
|
1416
|
+
*/
|
|
1417
|
+
declare function useUpdateTableExportSync(knowledgeBaseId: string): UseUpdateTableExportSyncReturn;
|
|
1418
|
+
interface UseDeleteTableExportSyncReturn {
|
|
1419
|
+
deleteSync: (syncId: string) => Promise<boolean>;
|
|
1420
|
+
isLoading: boolean;
|
|
1421
|
+
error: Error | null;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Hook for deleting a table export sync configuration
|
|
1425
|
+
*/
|
|
1426
|
+
declare function useDeleteTableExportSync(knowledgeBaseId: string): UseDeleteTableExportSyncReturn;
|
|
1427
|
+
interface UseTriggerTableExportSyncReturn {
|
|
1428
|
+
triggerSync: (syncId: string) => Promise<ExportTableResult | null>;
|
|
1429
|
+
isLoading: boolean;
|
|
1430
|
+
error: Error | null;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Hook for manually triggering a table export sync
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
* ```tsx
|
|
1437
|
+
* function TriggerSyncButton({ kbId, syncId }: Props) {
|
|
1438
|
+
* const { triggerSync, isLoading, error } = useTriggerTableExportSync(kbId)
|
|
1439
|
+
*
|
|
1440
|
+
* const handleTrigger = async () => {
|
|
1441
|
+
* const result = await triggerSync(syncId)
|
|
1442
|
+
* if (result) {
|
|
1443
|
+
* console.log('Sync completed:', result.document_id)
|
|
1444
|
+
* }
|
|
1445
|
+
* }
|
|
1446
|
+
*
|
|
1447
|
+
* return (
|
|
1448
|
+
* <button onClick={handleTrigger} disabled={isLoading}>
|
|
1449
|
+
* {isLoading ? 'Syncing...' : 'Sync Now'}
|
|
1450
|
+
* </button>
|
|
1451
|
+
* )
|
|
1452
|
+
* }
|
|
1453
|
+
* ```
|
|
1454
|
+
*/
|
|
1455
|
+
declare function useTriggerTableExportSync(knowledgeBaseId: string): UseTriggerTableExportSyncReturn;
|
|
1456
|
+
|
|
1457
|
+
export { type CaptchaState, FluxbaseProvider, type UseCreateTableExportSyncReturn, type UseDeleteTableExportSyncReturn, type UseExportTableReturn, type UseGraphQLMutationOptions, type UseGraphQLQueryOptions, type UseTableDetailsOptions, type UseTableDetailsReturn, type UseTableExportSyncsOptions, type UseTableExportSyncsReturn, type UseTriggerTableExportSyncReturn, type UseUpdateTableExportSyncReturn, isCaptchaRequiredForEndpoint, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useAuthConfig, useCaptcha, useCaptchaConfig, useClientKeys, useCreateBucket, useCreateTableExportSync, useDelete, useDeleteBucket, useDeleteTableExportSync, useExportTable, useFluxbaseClient, useFluxbaseQuery, useGetSAMLLoginUrl, useGraphQL, useGraphQLIntrospection, useGraphQLMutation, useGraphQLQuery, useHandleSAMLCallback, useInsert, useRealtime, useSAMLMetadataUrl, useSAMLProviders, useSession, useSignIn, useSignInWithSAML, useSignOut, useSignUp, useStorageBuckets, useStorageCopy, useStorageDelete, useStorageDownload, useStorageList, useStorageMove, useStoragePublicUrl, useStorageSignedUrl, useStorageSignedUrlWithOptions, useStorageTransformUrl, useStorageUpload, useStorageUploadWithProgress, useSystemSettings, useTable, useTableDeletes, useTableDetails, useTableExportSyncs, useTableInserts, useTableSubscription, useTableUpdates, useTriggerTableExportSync, useUpdate, useUpdateTableExportSync, useUpdateUser, useUpsert, useUser, useUsers, useWebhooks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as _fluxbase_sdk from '@fluxbase/sdk';
|
|
4
|
-
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLLoginOptions, SAMLProvider, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, SignedUrlOptions, TransformOptions, UploadOptions, UploadProgress, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest } from '@fluxbase/sdk';
|
|
4
|
+
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLLoginOptions, SAMLProvider, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, SignedUrlOptions, TransformOptions, UploadOptions, UploadProgress, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest, CreateTableExportSyncConfig, TableExportSyncConfig, ExportTableOptions, ExportTableResult, TableDetails, UpdateTableExportSyncConfig } from '@fluxbase/sdk';
|
|
5
5
|
export { APIKey, AdminUser, AppSettings, AuthSession, CaptchaConfig, CaptchaProvider, ClientKey, EnrichedUser, FluxbaseClient, GraphQLError, GraphQLErrorLocation, GraphQLRequestOptions, GraphQLResponse, ImageFitMode, ImageFormat, PostgrestResponse, RealtimeChangePayload, SAMLLoginOptions, SAMLLoginResponse, SAMLProvider, SAMLProvidersResponse, SAMLSession, SignInCredentials, SignUpCredentials, SignedUrlOptions, StorageObject, SystemSetting, TransformOptions, User, Webhook } from '@fluxbase/sdk';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
@@ -1264,4 +1264,194 @@ interface UseWebhooksReturn {
|
|
|
1264
1264
|
*/
|
|
1265
1265
|
declare function useWebhooks(options?: UseWebhooksOptions): UseWebhooksReturn;
|
|
1266
1266
|
|
|
1267
|
-
|
|
1267
|
+
/**
|
|
1268
|
+
* Table Export Hooks
|
|
1269
|
+
*
|
|
1270
|
+
* React hooks for exporting database tables to knowledge bases and managing sync configurations.
|
|
1271
|
+
*/
|
|
1272
|
+
|
|
1273
|
+
interface UseTableDetailsOptions {
|
|
1274
|
+
schema?: string;
|
|
1275
|
+
table?: string;
|
|
1276
|
+
autoFetch?: boolean;
|
|
1277
|
+
}
|
|
1278
|
+
interface UseTableDetailsReturn {
|
|
1279
|
+
data: TableDetails | null;
|
|
1280
|
+
isLoading: boolean;
|
|
1281
|
+
error: Error | null;
|
|
1282
|
+
refetch: () => Promise<void>;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Hook for fetching detailed table information including columns
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* ```tsx
|
|
1289
|
+
* function TableColumnsList({ schema, table }: { schema: string; table: string }) {
|
|
1290
|
+
* const { data, isLoading, error } = useTableDetails({ schema, table })
|
|
1291
|
+
*
|
|
1292
|
+
* if (isLoading) return <div>Loading...</div>
|
|
1293
|
+
* if (error) return <div>Error: {error.message}</div>
|
|
1294
|
+
*
|
|
1295
|
+
* return (
|
|
1296
|
+
* <ul>
|
|
1297
|
+
* {data?.columns.map(col => (
|
|
1298
|
+
* <li key={col.name}>
|
|
1299
|
+
* {col.name} ({col.data_type})
|
|
1300
|
+
* {col.is_primary_key && ' 🔑'}
|
|
1301
|
+
* </li>
|
|
1302
|
+
* ))}
|
|
1303
|
+
* </ul>
|
|
1304
|
+
* )
|
|
1305
|
+
* }
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
declare function useTableDetails(options: UseTableDetailsOptions): UseTableDetailsReturn;
|
|
1309
|
+
interface UseExportTableReturn {
|
|
1310
|
+
exportTable: (options: ExportTableOptions) => Promise<ExportTableResult | null>;
|
|
1311
|
+
isLoading: boolean;
|
|
1312
|
+
error: Error | null;
|
|
1313
|
+
reset: () => void;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Hook for exporting a table to a knowledge base
|
|
1317
|
+
*
|
|
1318
|
+
* @example
|
|
1319
|
+
* ```tsx
|
|
1320
|
+
* function ExportTableButton({ kbId, schema, table }: Props) {
|
|
1321
|
+
* const { exportTable, isLoading, error } = useExportTable(kbId)
|
|
1322
|
+
*
|
|
1323
|
+
* const handleExport = async () => {
|
|
1324
|
+
* const result = await exportTable({
|
|
1325
|
+
* schema,
|
|
1326
|
+
* table,
|
|
1327
|
+
* columns: ['id', 'name', 'email'],
|
|
1328
|
+
* include_foreign_keys: true,
|
|
1329
|
+
* })
|
|
1330
|
+
* if (result) {
|
|
1331
|
+
* console.log('Exported document:', result.document_id)
|
|
1332
|
+
* }
|
|
1333
|
+
* }
|
|
1334
|
+
*
|
|
1335
|
+
* return (
|
|
1336
|
+
* <button onClick={handleExport} disabled={isLoading}>
|
|
1337
|
+
* {isLoading ? 'Exporting...' : 'Export Table'}
|
|
1338
|
+
* </button>
|
|
1339
|
+
* )
|
|
1340
|
+
* }
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
declare function useExportTable(knowledgeBaseId: string): UseExportTableReturn;
|
|
1344
|
+
interface UseTableExportSyncsOptions {
|
|
1345
|
+
autoFetch?: boolean;
|
|
1346
|
+
}
|
|
1347
|
+
interface UseTableExportSyncsReturn {
|
|
1348
|
+
configs: TableExportSyncConfig[];
|
|
1349
|
+
isLoading: boolean;
|
|
1350
|
+
error: Error | null;
|
|
1351
|
+
refetch: () => Promise<void>;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Hook for listing table export sync configurations
|
|
1355
|
+
*
|
|
1356
|
+
* @example
|
|
1357
|
+
* ```tsx
|
|
1358
|
+
* function SyncConfigsList({ kbId }: { kbId: string }) {
|
|
1359
|
+
* const { configs, isLoading, error } = useTableExportSyncs(kbId)
|
|
1360
|
+
*
|
|
1361
|
+
* if (isLoading) return <div>Loading...</div>
|
|
1362
|
+
*
|
|
1363
|
+
* return (
|
|
1364
|
+
* <ul>
|
|
1365
|
+
* {configs.map(config => (
|
|
1366
|
+
* <li key={config.id}>
|
|
1367
|
+
* {config.schema_name}.{config.table_name} ({config.sync_mode})
|
|
1368
|
+
* </li>
|
|
1369
|
+
* ))}
|
|
1370
|
+
* </ul>
|
|
1371
|
+
* )
|
|
1372
|
+
* }
|
|
1373
|
+
* ```
|
|
1374
|
+
*/
|
|
1375
|
+
declare function useTableExportSyncs(knowledgeBaseId: string, options?: UseTableExportSyncsOptions): UseTableExportSyncsReturn;
|
|
1376
|
+
interface UseCreateTableExportSyncReturn {
|
|
1377
|
+
createSync: (config: CreateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1378
|
+
isLoading: boolean;
|
|
1379
|
+
error: Error | null;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Hook for creating a table export sync configuration
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```tsx
|
|
1386
|
+
* function CreateSyncForm({ kbId }: { kbId: string }) {
|
|
1387
|
+
* const { createSync, isLoading, error } = useCreateTableExportSync(kbId)
|
|
1388
|
+
*
|
|
1389
|
+
* const handleSubmit = async (e: React.FormEvent) => {
|
|
1390
|
+
* e.preventDefault()
|
|
1391
|
+
* const config = await createSync({
|
|
1392
|
+
* schema_name: 'public',
|
|
1393
|
+
* table_name: 'users',
|
|
1394
|
+
* columns: ['id', 'name', 'email'],
|
|
1395
|
+
* sync_mode: 'automatic',
|
|
1396
|
+
* sync_on_insert: true,
|
|
1397
|
+
* sync_on_update: true,
|
|
1398
|
+
* })
|
|
1399
|
+
* if (config) {
|
|
1400
|
+
* console.log('Created sync config:', config.id)
|
|
1401
|
+
* }
|
|
1402
|
+
* }
|
|
1403
|
+
*
|
|
1404
|
+
* return <form onSubmit={handleSubmit}>...</form>
|
|
1405
|
+
* }
|
|
1406
|
+
* ```
|
|
1407
|
+
*/
|
|
1408
|
+
declare function useCreateTableExportSync(knowledgeBaseId: string): UseCreateTableExportSyncReturn;
|
|
1409
|
+
interface UseUpdateTableExportSyncReturn {
|
|
1410
|
+
updateSync: (syncId: string, updates: UpdateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1411
|
+
isLoading: boolean;
|
|
1412
|
+
error: Error | null;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Hook for updating a table export sync configuration
|
|
1416
|
+
*/
|
|
1417
|
+
declare function useUpdateTableExportSync(knowledgeBaseId: string): UseUpdateTableExportSyncReturn;
|
|
1418
|
+
interface UseDeleteTableExportSyncReturn {
|
|
1419
|
+
deleteSync: (syncId: string) => Promise<boolean>;
|
|
1420
|
+
isLoading: boolean;
|
|
1421
|
+
error: Error | null;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Hook for deleting a table export sync configuration
|
|
1425
|
+
*/
|
|
1426
|
+
declare function useDeleteTableExportSync(knowledgeBaseId: string): UseDeleteTableExportSyncReturn;
|
|
1427
|
+
interface UseTriggerTableExportSyncReturn {
|
|
1428
|
+
triggerSync: (syncId: string) => Promise<ExportTableResult | null>;
|
|
1429
|
+
isLoading: boolean;
|
|
1430
|
+
error: Error | null;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Hook for manually triggering a table export sync
|
|
1434
|
+
*
|
|
1435
|
+
* @example
|
|
1436
|
+
* ```tsx
|
|
1437
|
+
* function TriggerSyncButton({ kbId, syncId }: Props) {
|
|
1438
|
+
* const { triggerSync, isLoading, error } = useTriggerTableExportSync(kbId)
|
|
1439
|
+
*
|
|
1440
|
+
* const handleTrigger = async () => {
|
|
1441
|
+
* const result = await triggerSync(syncId)
|
|
1442
|
+
* if (result) {
|
|
1443
|
+
* console.log('Sync completed:', result.document_id)
|
|
1444
|
+
* }
|
|
1445
|
+
* }
|
|
1446
|
+
*
|
|
1447
|
+
* return (
|
|
1448
|
+
* <button onClick={handleTrigger} disabled={isLoading}>
|
|
1449
|
+
* {isLoading ? 'Syncing...' : 'Sync Now'}
|
|
1450
|
+
* </button>
|
|
1451
|
+
* )
|
|
1452
|
+
* }
|
|
1453
|
+
* ```
|
|
1454
|
+
*/
|
|
1455
|
+
declare function useTriggerTableExportSync(knowledgeBaseId: string): UseTriggerTableExportSyncReturn;
|
|
1456
|
+
|
|
1457
|
+
export { type CaptchaState, FluxbaseProvider, type UseCreateTableExportSyncReturn, type UseDeleteTableExportSyncReturn, type UseExportTableReturn, type UseGraphQLMutationOptions, type UseGraphQLQueryOptions, type UseTableDetailsOptions, type UseTableDetailsReturn, type UseTableExportSyncsOptions, type UseTableExportSyncsReturn, type UseTriggerTableExportSyncReturn, type UseUpdateTableExportSyncReturn, isCaptchaRequiredForEndpoint, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useAuthConfig, useCaptcha, useCaptchaConfig, useClientKeys, useCreateBucket, useCreateTableExportSync, useDelete, useDeleteBucket, useDeleteTableExportSync, useExportTable, useFluxbaseClient, useFluxbaseQuery, useGetSAMLLoginUrl, useGraphQL, useGraphQLIntrospection, useGraphQLMutation, useGraphQLQuery, useHandleSAMLCallback, useInsert, useRealtime, useSAMLMetadataUrl, useSAMLProviders, useSession, useSignIn, useSignInWithSAML, useSignOut, useSignUp, useStorageBuckets, useStorageCopy, useStorageDelete, useStorageDownload, useStorageList, useStorageMove, useStoragePublicUrl, useStorageSignedUrl, useStorageSignedUrlWithOptions, useStorageTransformUrl, useStorageUpload, useStorageUploadWithProgress, useSystemSettings, useTable, useTableDeletes, useTableDetails, useTableExportSyncs, useTableInserts, useTableSubscription, useTableUpdates, useTriggerTableExportSync, useUpdate, useUpdateTableExportSync, useUpdateUser, useUpsert, useUser, useUsers, useWebhooks };
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,11 @@ __export(index_exports, {
|
|
|
31
31
|
useCaptchaConfig: () => useCaptchaConfig,
|
|
32
32
|
useClientKeys: () => useClientKeys,
|
|
33
33
|
useCreateBucket: () => useCreateBucket,
|
|
34
|
+
useCreateTableExportSync: () => useCreateTableExportSync,
|
|
34
35
|
useDelete: () => useDelete,
|
|
35
36
|
useDeleteBucket: () => useDeleteBucket,
|
|
37
|
+
useDeleteTableExportSync: () => useDeleteTableExportSync,
|
|
38
|
+
useExportTable: () => useExportTable,
|
|
36
39
|
useFluxbaseClient: () => useFluxbaseClient,
|
|
37
40
|
useFluxbaseQuery: () => useFluxbaseQuery,
|
|
38
41
|
useGetSAMLLoginUrl: () => useGetSAMLLoginUrl,
|
|
@@ -65,10 +68,14 @@ __export(index_exports, {
|
|
|
65
68
|
useSystemSettings: () => useSystemSettings,
|
|
66
69
|
useTable: () => useTable,
|
|
67
70
|
useTableDeletes: () => useTableDeletes,
|
|
71
|
+
useTableDetails: () => useTableDetails,
|
|
72
|
+
useTableExportSyncs: () => useTableExportSyncs,
|
|
68
73
|
useTableInserts: () => useTableInserts,
|
|
69
74
|
useTableSubscription: () => useTableSubscription,
|
|
70
75
|
useTableUpdates: () => useTableUpdates,
|
|
76
|
+
useTriggerTableExportSync: () => useTriggerTableExportSync,
|
|
71
77
|
useUpdate: () => useUpdate,
|
|
78
|
+
useUpdateTableExportSync: () => useUpdateTableExportSync,
|
|
72
79
|
useUpdateUser: () => useUpdateUser,
|
|
73
80
|
useUpsert: () => useUpsert,
|
|
74
81
|
useUser: () => useUser,
|
|
@@ -1343,6 +1350,226 @@ function useWebhooks(options = {}) {
|
|
|
1343
1350
|
testWebhook
|
|
1344
1351
|
};
|
|
1345
1352
|
}
|
|
1353
|
+
|
|
1354
|
+
// src/use-table-export.ts
|
|
1355
|
+
var import_react9 = require("react");
|
|
1356
|
+
function useTableDetails(options) {
|
|
1357
|
+
const { schema, table, autoFetch = true } = options;
|
|
1358
|
+
const client = useFluxbaseClient();
|
|
1359
|
+
const [data, setData] = (0, import_react9.useState)(null);
|
|
1360
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(autoFetch && !!schema && !!table);
|
|
1361
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1362
|
+
const fetchData = (0, import_react9.useCallback)(async () => {
|
|
1363
|
+
if (!schema || !table) return;
|
|
1364
|
+
try {
|
|
1365
|
+
setIsLoading(true);
|
|
1366
|
+
setError(null);
|
|
1367
|
+
const result = await client.admin.ai.getTableDetails(schema, table);
|
|
1368
|
+
if (result.error) {
|
|
1369
|
+
throw result.error;
|
|
1370
|
+
}
|
|
1371
|
+
setData(result.data);
|
|
1372
|
+
} catch (err) {
|
|
1373
|
+
setError(err);
|
|
1374
|
+
} finally {
|
|
1375
|
+
setIsLoading(false);
|
|
1376
|
+
}
|
|
1377
|
+
}, [client, schema, table]);
|
|
1378
|
+
(0, import_react9.useEffect)(() => {
|
|
1379
|
+
if (autoFetch && schema && table) {
|
|
1380
|
+
fetchData();
|
|
1381
|
+
}
|
|
1382
|
+
}, [autoFetch, fetchData, schema, table]);
|
|
1383
|
+
return {
|
|
1384
|
+
data,
|
|
1385
|
+
isLoading,
|
|
1386
|
+
error,
|
|
1387
|
+
refetch: fetchData
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function useExportTable(knowledgeBaseId) {
|
|
1391
|
+
const client = useFluxbaseClient();
|
|
1392
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1393
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1394
|
+
const exportTable = (0, import_react9.useCallback)(
|
|
1395
|
+
async (options) => {
|
|
1396
|
+
try {
|
|
1397
|
+
setIsLoading(true);
|
|
1398
|
+
setError(null);
|
|
1399
|
+
const result = await client.admin.ai.exportTable(knowledgeBaseId, options);
|
|
1400
|
+
if (result.error) {
|
|
1401
|
+
throw result.error;
|
|
1402
|
+
}
|
|
1403
|
+
return result.data;
|
|
1404
|
+
} catch (err) {
|
|
1405
|
+
setError(err);
|
|
1406
|
+
return null;
|
|
1407
|
+
} finally {
|
|
1408
|
+
setIsLoading(false);
|
|
1409
|
+
}
|
|
1410
|
+
},
|
|
1411
|
+
[client, knowledgeBaseId]
|
|
1412
|
+
);
|
|
1413
|
+
const reset = (0, import_react9.useCallback)(() => {
|
|
1414
|
+
setError(null);
|
|
1415
|
+
setIsLoading(false);
|
|
1416
|
+
}, []);
|
|
1417
|
+
return {
|
|
1418
|
+
exportTable,
|
|
1419
|
+
isLoading,
|
|
1420
|
+
error,
|
|
1421
|
+
reset
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
function useTableExportSyncs(knowledgeBaseId, options = {}) {
|
|
1425
|
+
const { autoFetch = true } = options;
|
|
1426
|
+
const client = useFluxbaseClient();
|
|
1427
|
+
const [configs, setConfigs] = (0, import_react9.useState)([]);
|
|
1428
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(autoFetch);
|
|
1429
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1430
|
+
const fetchData = (0, import_react9.useCallback)(async () => {
|
|
1431
|
+
try {
|
|
1432
|
+
setIsLoading(true);
|
|
1433
|
+
setError(null);
|
|
1434
|
+
const result = await client.admin.ai.listTableExportSyncs(knowledgeBaseId);
|
|
1435
|
+
if (result.error) {
|
|
1436
|
+
throw result.error;
|
|
1437
|
+
}
|
|
1438
|
+
setConfigs(result.data || []);
|
|
1439
|
+
} catch (err) {
|
|
1440
|
+
setError(err);
|
|
1441
|
+
} finally {
|
|
1442
|
+
setIsLoading(false);
|
|
1443
|
+
}
|
|
1444
|
+
}, [client, knowledgeBaseId]);
|
|
1445
|
+
(0, import_react9.useEffect)(() => {
|
|
1446
|
+
if (autoFetch) {
|
|
1447
|
+
fetchData();
|
|
1448
|
+
}
|
|
1449
|
+
}, [autoFetch, fetchData]);
|
|
1450
|
+
return {
|
|
1451
|
+
configs,
|
|
1452
|
+
isLoading,
|
|
1453
|
+
error,
|
|
1454
|
+
refetch: fetchData
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
function useCreateTableExportSync(knowledgeBaseId) {
|
|
1458
|
+
const client = useFluxbaseClient();
|
|
1459
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1460
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1461
|
+
const createSync = (0, import_react9.useCallback)(
|
|
1462
|
+
async (config) => {
|
|
1463
|
+
try {
|
|
1464
|
+
setIsLoading(true);
|
|
1465
|
+
setError(null);
|
|
1466
|
+
const result = await client.admin.ai.createTableExportSync(knowledgeBaseId, config);
|
|
1467
|
+
if (result.error) {
|
|
1468
|
+
throw result.error;
|
|
1469
|
+
}
|
|
1470
|
+
return result.data;
|
|
1471
|
+
} catch (err) {
|
|
1472
|
+
setError(err);
|
|
1473
|
+
return null;
|
|
1474
|
+
} finally {
|
|
1475
|
+
setIsLoading(false);
|
|
1476
|
+
}
|
|
1477
|
+
},
|
|
1478
|
+
[client, knowledgeBaseId]
|
|
1479
|
+
);
|
|
1480
|
+
return {
|
|
1481
|
+
createSync,
|
|
1482
|
+
isLoading,
|
|
1483
|
+
error
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function useUpdateTableExportSync(knowledgeBaseId) {
|
|
1487
|
+
const client = useFluxbaseClient();
|
|
1488
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1489
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1490
|
+
const updateSync = (0, import_react9.useCallback)(
|
|
1491
|
+
async (syncId, updates) => {
|
|
1492
|
+
try {
|
|
1493
|
+
setIsLoading(true);
|
|
1494
|
+
setError(null);
|
|
1495
|
+
const result = await client.admin.ai.updateTableExportSync(knowledgeBaseId, syncId, updates);
|
|
1496
|
+
if (result.error) {
|
|
1497
|
+
throw result.error;
|
|
1498
|
+
}
|
|
1499
|
+
return result.data;
|
|
1500
|
+
} catch (err) {
|
|
1501
|
+
setError(err);
|
|
1502
|
+
return null;
|
|
1503
|
+
} finally {
|
|
1504
|
+
setIsLoading(false);
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
[client, knowledgeBaseId]
|
|
1508
|
+
);
|
|
1509
|
+
return {
|
|
1510
|
+
updateSync,
|
|
1511
|
+
isLoading,
|
|
1512
|
+
error
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function useDeleteTableExportSync(knowledgeBaseId) {
|
|
1516
|
+
const client = useFluxbaseClient();
|
|
1517
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1518
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1519
|
+
const deleteSync = (0, import_react9.useCallback)(
|
|
1520
|
+
async (syncId) => {
|
|
1521
|
+
try {
|
|
1522
|
+
setIsLoading(true);
|
|
1523
|
+
setError(null);
|
|
1524
|
+
const result = await client.admin.ai.deleteTableExportSync(knowledgeBaseId, syncId);
|
|
1525
|
+
if (result.error) {
|
|
1526
|
+
throw result.error;
|
|
1527
|
+
}
|
|
1528
|
+
return true;
|
|
1529
|
+
} catch (err) {
|
|
1530
|
+
setError(err);
|
|
1531
|
+
return false;
|
|
1532
|
+
} finally {
|
|
1533
|
+
setIsLoading(false);
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1536
|
+
[client, knowledgeBaseId]
|
|
1537
|
+
);
|
|
1538
|
+
return {
|
|
1539
|
+
deleteSync,
|
|
1540
|
+
isLoading,
|
|
1541
|
+
error
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
function useTriggerTableExportSync(knowledgeBaseId) {
|
|
1545
|
+
const client = useFluxbaseClient();
|
|
1546
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1547
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1548
|
+
const triggerSync = (0, import_react9.useCallback)(
|
|
1549
|
+
async (syncId) => {
|
|
1550
|
+
try {
|
|
1551
|
+
setIsLoading(true);
|
|
1552
|
+
setError(null);
|
|
1553
|
+
const result = await client.admin.ai.triggerTableExportSync(knowledgeBaseId, syncId);
|
|
1554
|
+
if (result.error) {
|
|
1555
|
+
throw result.error;
|
|
1556
|
+
}
|
|
1557
|
+
return result.data;
|
|
1558
|
+
} catch (err) {
|
|
1559
|
+
setError(err);
|
|
1560
|
+
return null;
|
|
1561
|
+
} finally {
|
|
1562
|
+
setIsLoading(false);
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
[client, knowledgeBaseId]
|
|
1566
|
+
);
|
|
1567
|
+
return {
|
|
1568
|
+
triggerSync,
|
|
1569
|
+
isLoading,
|
|
1570
|
+
error
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1346
1573
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1347
1574
|
0 && (module.exports = {
|
|
1348
1575
|
FluxbaseProvider,
|
|
@@ -1356,8 +1583,11 @@ function useWebhooks(options = {}) {
|
|
|
1356
1583
|
useCaptchaConfig,
|
|
1357
1584
|
useClientKeys,
|
|
1358
1585
|
useCreateBucket,
|
|
1586
|
+
useCreateTableExportSync,
|
|
1359
1587
|
useDelete,
|
|
1360
1588
|
useDeleteBucket,
|
|
1589
|
+
useDeleteTableExportSync,
|
|
1590
|
+
useExportTable,
|
|
1361
1591
|
useFluxbaseClient,
|
|
1362
1592
|
useFluxbaseQuery,
|
|
1363
1593
|
useGetSAMLLoginUrl,
|
|
@@ -1390,10 +1620,14 @@ function useWebhooks(options = {}) {
|
|
|
1390
1620
|
useSystemSettings,
|
|
1391
1621
|
useTable,
|
|
1392
1622
|
useTableDeletes,
|
|
1623
|
+
useTableDetails,
|
|
1624
|
+
useTableExportSyncs,
|
|
1393
1625
|
useTableInserts,
|
|
1394
1626
|
useTableSubscription,
|
|
1395
1627
|
useTableUpdates,
|
|
1628
|
+
useTriggerTableExportSync,
|
|
1396
1629
|
useUpdate,
|
|
1630
|
+
useUpdateTableExportSync,
|
|
1397
1631
|
useUpdateUser,
|
|
1398
1632
|
useUpsert,
|
|
1399
1633
|
useUser,
|