@fluxbase/sdk-react 0.0.1-rc.26 → 0.0.1-rc.27

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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/context.tsx","../src/use-auth.ts","../src/use-query.ts","../src/use-realtime.ts","../src/use-storage.ts","../src/use-rpc.ts","../src/use-admin-auth.ts","../src/use-users.ts","../src/use-api-keys.ts","../src/use-admin-hooks.ts"],"sourcesContent":["/**\n * Fluxbase React Hooks\n *\n * @example\n * ```tsx\n * import { createClient } from '@fluxbase/sdk'\n * import { FluxbaseProvider, useAuth, useTable } from '@fluxbase/sdk-react'\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'\n *\n * const client = createClient({ url: 'http://localhost:8080' })\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return (\n * <QueryClientProvider client={queryClient}>\n * <FluxbaseProvider client={client}>\n * <MyComponent />\n * </FluxbaseProvider>\n * </QueryClientProvider>\n * )\n * }\n *\n * function MyComponent() {\n * const { user, signIn, signOut } = useAuth()\n * const { data: products } = useTable('products', (q) => q.select('*').eq('active', true))\n *\n * return <div>...</div>\n * }\n * ```\n */\n\n// Context and provider\nexport { FluxbaseProvider, useFluxbaseClient } from './context'\n\n// Auth hooks\nexport {\n useAuth,\n useUser,\n useSession,\n useSignIn,\n useSignUp,\n useSignOut,\n useUpdateUser,\n} from './use-auth'\n\n// Database query hooks\nexport {\n useFluxbaseQuery,\n useTable,\n useInsert,\n useUpdate,\n useUpsert,\n useDelete,\n} from './use-query'\n\n// Realtime hooks\nexport {\n useRealtime,\n useTableSubscription,\n useTableInserts,\n useTableUpdates,\n useTableDeletes,\n} from './use-realtime'\n\n// Storage hooks\nexport {\n useStorageList,\n useStorageUpload,\n useStorageDownload,\n useStorageDelete,\n useStoragePublicUrl,\n useStorageSignedUrl,\n useStorageMove,\n useStorageCopy,\n useStorageBuckets,\n useCreateBucket,\n useDeleteBucket,\n} from './use-storage'\n\n// RPC hooks\nexport {\n useRPC,\n useRPCMutation,\n useRPCBatch,\n} from './use-rpc'\n\n// Admin hooks\nexport { useAdminAuth } from './use-admin-auth'\nexport { useUsers } from './use-users'\nexport { useAPIKeys } from './use-api-keys'\nexport {\n useWebhooks,\n useAppSettings,\n useSystemSettings,\n} from './use-admin-hooks'\n\n// Re-export types from SDK\nexport type {\n FluxbaseClient,\n AuthSession,\n User,\n SignInCredentials,\n SignUpCredentials,\n PostgrestResponse,\n RealtimeChangePayload,\n StorageObject,\n AdminUser,\n EnrichedUser,\n APIKey,\n Webhook,\n AppSettings,\n SystemSetting,\n} from '@fluxbase/sdk'\n","/**\n * React context for Fluxbase client\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport type { FluxbaseClient } from '@fluxbase/sdk'\n\nconst FluxbaseContext = createContext<FluxbaseClient | null>(null)\n\nexport interface FluxbaseProviderProps {\n client: FluxbaseClient\n children: ReactNode\n}\n\n/**\n * Provider component to make Fluxbase client available throughout the app\n */\nexport function FluxbaseProvider({ client, children }: FluxbaseProviderProps) {\n return <FluxbaseContext.Provider value={client}>{children}</FluxbaseContext.Provider>\n}\n\n/**\n * Hook to access the Fluxbase client from context\n */\nexport function useFluxbaseClient(): FluxbaseClient {\n const client = useContext(FluxbaseContext)\n\n if (!client) {\n throw new Error('useFluxbaseClient must be used within a FluxbaseProvider')\n }\n\n return client\n}\n","/**\n * Authentication hooks for Fluxbase SDK\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { SignInCredentials, SignUpCredentials, User, AuthSession } from '@fluxbase/sdk'\n\n/**\n * Hook to get the current user\n */\nexport function useUser() {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['fluxbase', 'auth', 'user'],\n queryFn: async () => {\n const session = client.auth.getSession()\n if (!session) {\n return null\n }\n\n try {\n return await client.auth.getCurrentUser()\n } catch {\n return null\n }\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n })\n}\n\n/**\n * Hook to get the current session\n */\nexport function useSession() {\n const client = useFluxbaseClient()\n\n return useQuery<AuthSession | null>({\n queryKey: ['fluxbase', 'auth', 'session'],\n queryFn: () => client.auth.getSession(),\n staleTime: 1000 * 60 * 5, // 5 minutes\n })\n}\n\n/**\n * Hook for signing in\n */\nexport function useSignIn() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (credentials: SignInCredentials) => {\n return await client.auth.signIn(credentials)\n },\n onSuccess: (session) => {\n queryClient.setQueryData(['fluxbase', 'auth', 'session'], session)\n // Only set user if this is a complete auth session (not 2FA required)\n if ('user' in session) {\n queryClient.setQueryData(['fluxbase', 'auth', 'user'], session.user)\n }\n },\n })\n}\n\n/**\n * Hook for signing up\n */\nexport function useSignUp() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (credentials: SignUpCredentials) => {\n return await client.auth.signUp(credentials)\n },\n onSuccess: (response) => {\n if (response.data) {\n queryClient.setQueryData(['fluxbase', 'auth', 'session'], response.data.session)\n queryClient.setQueryData(['fluxbase', 'auth', 'user'], response.data.user)\n }\n },\n })\n}\n\n/**\n * Hook for signing out\n */\nexport function useSignOut() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async () => {\n await client.auth.signOut()\n },\n onSuccess: () => {\n queryClient.setQueryData(['fluxbase', 'auth', 'session'], null)\n queryClient.setQueryData(['fluxbase', 'auth', 'user'], null)\n queryClient.invalidateQueries({ queryKey: ['fluxbase'] })\n },\n })\n}\n\n/**\n * Hook for updating the current user\n */\nexport function useUpdateUser() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (data: Partial<Pick<User, 'email' | 'metadata'>>) => {\n return await client.auth.updateUser(data)\n },\n onSuccess: (user) => {\n queryClient.setQueryData(['fluxbase', 'auth', 'user'], user)\n },\n })\n}\n\n/**\n * Combined auth hook with all auth state and methods\n */\nexport function useAuth() {\n const { data: user, isLoading: isLoadingUser } = useUser()\n const { data: session, isLoading: isLoadingSession } = useSession()\n const signIn = useSignIn()\n const signUp = useSignUp()\n const signOut = useSignOut()\n const updateUser = useUpdateUser()\n\n return {\n user,\n session,\n isLoading: isLoadingUser || isLoadingSession,\n isAuthenticated: !!session,\n signIn: signIn.mutateAsync,\n signUp: signUp.mutateAsync,\n signOut: signOut.mutateAsync,\n updateUser: updateUser.mutateAsync,\n isSigningIn: signIn.isPending,\n isSigningUp: signUp.isPending,\n isSigningOut: signOut.isPending,\n isUpdating: updateUser.isPending,\n }\n}\n","/**\n * Database query hooks for Fluxbase SDK\n */\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { QueryBuilder } from '@fluxbase/sdk'\n\nexport interface UseFluxbaseQueryOptions<T> extends Omit<UseQueryOptions<T[], Error>, 'queryKey' | 'queryFn'> {\n /**\n * Custom query key. If not provided, will use table name and filters.\n */\n queryKey?: unknown[]\n}\n\n/**\n * Hook to execute a database query\n * @param buildQuery - Function that builds and returns the query\n * @param options - React Query options\n */\nexport function useFluxbaseQuery<T = any>(\n buildQuery: (client: ReturnType<typeof useFluxbaseClient>) => QueryBuilder<T>,\n options?: UseFluxbaseQueryOptions<T>\n) {\n const client = useFluxbaseClient()\n\n // Build a stable query key\n const queryKey = options?.queryKey || ['fluxbase', 'query', buildQuery.toString()]\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n const query = buildQuery(client)\n const { data, error } = await query.execute()\n\n if (error) {\n throw error\n }\n\n return (Array.isArray(data) ? data : data ? [data] : []) as T[]\n },\n ...options,\n })\n}\n\n/**\n * Hook for table queries with a simpler API\n * @param table - Table name\n * @param buildQuery - Function to build the query\n */\nexport function useTable<T = any>(\n table: string,\n buildQuery?: (query: QueryBuilder<T>) => QueryBuilder<T>,\n options?: UseFluxbaseQueryOptions<T>\n) {\n const client = useFluxbaseClient()\n\n return useFluxbaseQuery(\n (client) => {\n const query = client.from<T>(table)\n return buildQuery ? buildQuery(query) : query\n },\n {\n ...options,\n queryKey: options?.queryKey || ['fluxbase', 'table', table, buildQuery?.toString()],\n }\n )\n}\n\n/**\n * Hook to insert data into a table\n */\nexport function useInsert<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (data: Partial<T> | Partial<T>[]) => {\n const query = client.from<T>(table)\n const { data: result, error } = await query.insert(data as Partial<T>)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n // Invalidate all queries for this table\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to update data in a table\n */\nexport function useUpdate<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (params: { data: Partial<T>; buildQuery: (query: QueryBuilder<T>) => QueryBuilder<T> }) => {\n const query = client.from<T>(table)\n const builtQuery = params.buildQuery(query)\n const { data: result, error } = await builtQuery.update(params.data)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to upsert data into a table\n */\nexport function useUpsert<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (data: Partial<T> | Partial<T>[]) => {\n const query = client.from<T>(table)\n const { data: result, error } = await query.upsert(data as Partial<T>)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to delete data from a table\n */\nexport function useDelete<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (buildQuery: (query: QueryBuilder<T>) => QueryBuilder<T>) => {\n const query = client.from<T>(table)\n const builtQuery = buildQuery(query)\n const { error } = await builtQuery.delete()\n\n if (error) {\n throw error\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n","/**\n * Realtime subscription hooks for Fluxbase SDK\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useFluxbaseClient } from \"./context\";\nimport type {\n RealtimeCallback,\n RealtimePostgresChangesPayload,\n} from \"@fluxbase/sdk\";\n\nexport interface UseRealtimeOptions {\n /**\n * The channel name (e.g., 'table:public.products')\n */\n channel: string;\n\n /**\n * Event type to listen for ('INSERT', 'UPDATE', 'DELETE', or '*' for all)\n */\n event?: \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"*\";\n\n /**\n * Callback function when an event is received\n */\n callback?: RealtimeCallback;\n\n /**\n * Whether to automatically invalidate queries for the table\n * Default: true\n */\n autoInvalidate?: boolean;\n\n /**\n * Custom query key to invalidate (if autoInvalidate is true)\n * Default: ['fluxbase', 'table', tableName]\n */\n invalidateKey?: unknown[];\n\n /**\n * Whether the subscription is enabled\n * Default: true\n */\n enabled?: boolean;\n}\n\n/**\n * Hook to subscribe to realtime changes for a channel\n */\nexport function useRealtime(options: UseRealtimeOptions) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n const channelRef = useRef<ReturnType<typeof client.realtime.channel> | null>(\n null,\n );\n\n const {\n channel: channelName,\n event = \"*\",\n callback,\n autoInvalidate = true,\n invalidateKey,\n enabled = true,\n } = options;\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n // Create channel and subscribe\n const channel = client.realtime.channel(channelName);\n channelRef.current = channel;\n\n const handleChange = (payload: RealtimePostgresChangesPayload) => {\n // Call user callback\n if (callback) {\n callback(payload);\n }\n\n // Auto-invalidate queries if enabled\n if (autoInvalidate) {\n // Extract table name from channel (e.g., 'table:public.products' -> 'public.products')\n const tableName = channelName.replace(/^table:/, \"\");\n\n const key = invalidateKey || [\"fluxbase\", \"table\", tableName];\n queryClient.invalidateQueries({ queryKey: key });\n }\n };\n\n channel.on(event, handleChange).subscribe();\n\n return () => {\n channel.unsubscribe();\n channelRef.current = null;\n };\n }, [\n client,\n channelName,\n event,\n callback,\n autoInvalidate,\n invalidateKey,\n queryClient,\n enabled,\n ]);\n\n return {\n channel: channelRef.current,\n };\n}\n\n/**\n * Hook to subscribe to a table's changes\n * @param table - Table name (with optional schema, e.g., 'public.products')\n * @param options - Subscription options\n */\nexport function useTableSubscription(\n table: string,\n options?: Omit<UseRealtimeOptions, \"channel\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n });\n}\n\n/**\n * Hook to subscribe to INSERT events on a table\n */\nexport function useTableInserts(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"INSERT\",\n callback,\n });\n}\n\n/**\n * Hook to subscribe to UPDATE events on a table\n */\nexport function useTableUpdates(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"UPDATE\",\n callback,\n });\n}\n\n/**\n * Hook to subscribe to DELETE events on a table\n */\nexport function useTableDeletes(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"DELETE\",\n callback,\n });\n}\n","/**\n * Storage hooks for Fluxbase SDK\n */\n\nimport { useMutation, useQuery, useQueryClient, type UseQueryOptions } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { ListOptions, UploadOptions } from '@fluxbase/sdk'\n\n/**\n * Hook to list files in a bucket\n */\nexport function useStorageList(\n bucket: string,\n options?: ListOptions & Omit<UseQueryOptions<any[], Error>, 'queryKey' | 'queryFn'>\n) {\n const client = useFluxbaseClient()\n const { prefix, limit, offset, ...queryOptions } = options || {}\n\n return useQuery({\n queryKey: ['fluxbase', 'storage', bucket, 'list', { prefix, limit, offset }],\n queryFn: async () => {\n const { data, error } = await client.storage.from(bucket).list({ prefix, limit, offset })\n\n if (error) {\n throw error\n }\n\n return data || []\n },\n ...queryOptions,\n })\n}\n\n/**\n * Hook to upload a file to a bucket\n */\nexport function useStorageUpload(bucket: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (params: {\n path: string\n file: File | Blob | ArrayBuffer\n options?: UploadOptions\n }) => {\n const { path, file, options } = params\n const { data, error } = await client.storage.from(bucket).upload(path, file, options)\n\n if (error) {\n throw error\n }\n\n return data\n },\n onSuccess: () => {\n // Invalidate list queries for this bucket\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', bucket, 'list'] })\n },\n })\n}\n\n/**\n * Hook to download a file from a bucket\n */\nexport function useStorageDownload(bucket: string, path: string | null, enabled = true) {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['fluxbase', 'storage', bucket, 'download', path],\n queryFn: async () => {\n if (!path) {\n return null\n }\n\n const { data, error } = await client.storage.from(bucket).download(path)\n\n if (error) {\n throw error\n }\n\n return data\n },\n enabled: enabled && !!path,\n })\n}\n\n/**\n * Hook to delete files from a bucket\n */\nexport function useStorageDelete(bucket: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (paths: string[]) => {\n const { error } = await client.storage.from(bucket).remove(paths)\n\n if (error) {\n throw error\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', bucket, 'list'] })\n },\n })\n}\n\n/**\n * Hook to get a public URL for a file\n */\nexport function useStoragePublicUrl(bucket: string, path: string | null) {\n const client = useFluxbaseClient()\n\n if (!path) {\n return null\n }\n\n const { data } = client.storage.from(bucket).getPublicUrl(path)\n return data.publicUrl\n}\n\n/**\n * Hook to create a signed URL\n */\nexport function useStorageSignedUrl(bucket: string, path: string | null, expiresIn?: number) {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['fluxbase', 'storage', bucket, 'signed-url', path, expiresIn],\n queryFn: async () => {\n if (!path) {\n return null\n }\n\n const { data, error } = await client.storage.from(bucket).createSignedUrl(path, { expiresIn })\n\n if (error) {\n throw error\n }\n\n return data?.signedUrl || null\n },\n enabled: !!path,\n staleTime: expiresIn ? expiresIn * 1000 - 60000 : 1000 * 60 * 50, // Refresh 1 minute before expiry\n })\n}\n\n/**\n * Hook to move a file\n */\nexport function useStorageMove(bucket: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (params: { fromPath: string; toPath: string }) => {\n const { fromPath, toPath } = params\n const { data, error } = await client.storage.from(bucket).move(fromPath, toPath)\n\n if (error) {\n throw error\n }\n\n return data\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', bucket, 'list'] })\n },\n })\n}\n\n/**\n * Hook to copy a file\n */\nexport function useStorageCopy(bucket: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (params: { fromPath: string; toPath: string }) => {\n const { fromPath, toPath } = params\n const { data, error } = await client.storage.from(bucket).copy(fromPath, toPath)\n\n if (error) {\n throw error\n }\n\n return data\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', bucket, 'list'] })\n },\n })\n}\n\n/**\n * Hook to manage buckets\n */\nexport function useStorageBuckets() {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['fluxbase', 'storage', 'buckets'],\n queryFn: async () => {\n const { data, error } = await client.storage.listBuckets()\n\n if (error) {\n throw error\n }\n\n return data || []\n },\n })\n}\n\n/**\n * Hook to create a bucket\n */\nexport function useCreateBucket() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (bucketName: string) => {\n const { error } = await client.storage.createBucket(bucketName)\n\n if (error) {\n throw error\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', 'buckets'] })\n },\n })\n}\n\n/**\n * Hook to delete a bucket\n */\nexport function useDeleteBucket() {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (bucketName: string) => {\n const { error } = await client.storage.deleteBucket(bucketName)\n\n if (error) {\n throw error\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'storage', 'buckets'] })\n },\n })\n}\n","/**\n * React hooks for RPC (Remote Procedure Calls)\n * Call PostgreSQL functions with React Query integration\n */\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions, type UseMutationOptions } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { PostgrestResponse } from '@fluxbase/sdk'\n\n/**\n * Hook to call a PostgreSQL function and cache the result\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useRPC(\n * 'calculate_total',\n * { order_id: 123 },\n * { enabled: !!orderId }\n * )\n * ```\n */\nexport function useRPC<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(\n functionName: string,\n params?: TParams,\n options?: Omit<UseQueryOptions<TData, Error>, 'queryKey' | 'queryFn'>\n) {\n const client = useFluxbaseClient()\n\n return useQuery<TData, Error>({\n queryKey: ['rpc', functionName, params],\n queryFn: async () => {\n const { data, error } = await client.rpc<TData>(functionName, params)\n if (error) {\n throw new Error(error.message)\n }\n return data as TData\n },\n ...options,\n })\n}\n\n/**\n * Hook to create a mutation for calling PostgreSQL functions\n * Useful for functions that modify data\n *\n * @example\n * ```tsx\n * const createOrder = useRPCMutation('create_order')\n *\n * const handleSubmit = async () => {\n * await createOrder.mutateAsync({\n * user_id: 123,\n * items: [{ product_id: 1, quantity: 2 }]\n * })\n * }\n * ```\n */\nexport function useRPCMutation<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(\n functionName: string,\n options?: Omit<UseMutationOptions<TData, Error, TParams>, 'mutationFn'>\n) {\n const client = useFluxbaseClient()\n\n return useMutation<TData, Error, TParams>({\n mutationFn: async (params: TParams) => {\n const { data, error } = await client.rpc<TData>(functionName, params)\n if (error) {\n throw new Error(error.message)\n }\n return data as TData\n },\n ...options,\n })\n}\n\n/**\n * Hook to call multiple RPC functions in parallel\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useRPCBatch([\n * { name: 'get_user_stats', params: { user_id: 123 } },\n * { name: 'get_recent_orders', params: { limit: 10 } },\n * ])\n * ```\n */\nexport function useRPCBatch<TData = unknown>(\n calls: Array<{ name: string; params?: Record<string, unknown> }>,\n options?: Omit<UseQueryOptions<TData[], Error, TData[], readonly unknown[]>, 'queryKey' | 'queryFn'>\n) {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['rpc-batch', calls] as const,\n queryFn: async () => {\n const results = await Promise.all(\n calls.map(async ({ name, params }) => {\n const { data, error } = await client.rpc<TData>(name, params)\n if (error) {\n throw new Error(`${name}: ${error.message}`)\n }\n return data\n })\n )\n return results as TData[]\n },\n ...options,\n })\n}\n","import { useState, useEffect, useCallback } from \"react\";\nimport { useFluxbaseClient } from \"./context\";\nimport type { AdminAuthResponse, DataResponse } from \"@fluxbase/sdk\";\n\n/**\n * Simplified admin user type returned by authentication\n */\nexport interface AdminUser {\n id: string;\n email: string;\n role: string;\n}\n\nexport interface UseAdminAuthOptions {\n /**\n * Automatically check authentication status on mount\n * @default true\n */\n autoCheck?: boolean;\n}\n\nexport interface UseAdminAuthReturn {\n /**\n * Current admin user if authenticated\n */\n user: AdminUser | null;\n\n /**\n * Whether the admin is authenticated\n */\n isAuthenticated: boolean;\n\n /**\n * Whether the authentication check is in progress\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during authentication\n */\n error: Error | null;\n\n /**\n * Login as admin\n */\n login: (email: string, password: string) => Promise<AdminAuthResponse>;\n\n /**\n * Logout admin\n */\n logout: () => Promise<void>;\n\n /**\n * Refresh admin user info\n */\n refresh: () => Promise<void>;\n}\n\n/**\n * Hook for admin authentication\n *\n * Manages admin login state, authentication checks, and user info.\n *\n * @example\n * ```tsx\n * function AdminLogin() {\n * const { user, isAuthenticated, isLoading, login, logout } = useAdminAuth()\n *\n * const handleLogin = async (e: React.FormEvent) => {\n * e.preventDefault()\n * await login(email, password)\n * }\n *\n * if (isLoading) return <div>Loading...</div>\n * if (isAuthenticated) return <div>Welcome {user?.email}</div>\n *\n * return <form onSubmit={handleLogin}>...</form>\n * }\n * ```\n */\nexport function useAdminAuth(\n options: UseAdminAuthOptions = {},\n): UseAdminAuthReturn {\n const { autoCheck = true } = options;\n const client = useFluxbaseClient();\n\n const [user, setUser] = useState<AdminUser | null>(null);\n const [isLoading, setIsLoading] = useState(autoCheck);\n const [error, setError] = useState<Error | null>(null);\n\n /**\n * Check current authentication status\n */\n const checkAuth = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const { data, error: apiError } = await client.admin.me();\n if (apiError) {\n throw apiError;\n }\n setUser(data!.user);\n } catch (err) {\n setUser(null);\n setError(err as Error);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Login as admin\n */\n const login = useCallback(\n async (email: string, password: string): Promise<AdminAuthResponse> => {\n try {\n setIsLoading(true);\n setError(null);\n const { data, error: apiError } = await client.admin.login({\n email,\n password,\n });\n if (apiError) {\n throw apiError;\n }\n setUser(data!.user);\n return data!;\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setIsLoading(false);\n }\n },\n [client],\n );\n\n /**\n * Logout admin\n */\n const logout = useCallback(async (): Promise<void> => {\n try {\n setIsLoading(true);\n setError(null);\n // Clear user state\n setUser(null);\n // Note: Add logout endpoint call here when available\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n /**\n * Refresh admin user info\n */\n const refresh = useCallback(async (): Promise<void> => {\n await checkAuth();\n }, [checkAuth]);\n\n // Auto-check authentication on mount\n useEffect(() => {\n if (autoCheck) {\n checkAuth();\n }\n }, [autoCheck, checkAuth]);\n\n return {\n user,\n isAuthenticated: user !== null,\n isLoading,\n error,\n login,\n logout,\n refresh,\n };\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type { EnrichedUser, ListUsersOptions } from '@fluxbase/sdk'\n\nexport interface UseUsersOptions extends ListUsersOptions {\n /**\n * Whether to automatically fetch users on mount\n * @default true\n */\n autoFetch?: boolean\n\n /**\n * Refetch interval in milliseconds (0 to disable)\n * @default 0\n */\n refetchInterval?: number\n}\n\nexport interface UseUsersReturn {\n /**\n * Array of users\n */\n users: EnrichedUser[]\n\n /**\n * Total number of users (for pagination)\n */\n total: number\n\n /**\n * Whether users are being fetched\n */\n isLoading: boolean\n\n /**\n * Any error that occurred\n */\n error: Error | null\n\n /**\n * Refetch users\n */\n refetch: () => Promise<void>\n\n /**\n * Invite a new user\n */\n inviteUser: (email: string, role: 'user' | 'admin') => Promise<void>\n\n /**\n * Update user role\n */\n updateUserRole: (userId: string, role: 'user' | 'admin') => Promise<void>\n\n /**\n * Delete a user\n */\n deleteUser: (userId: string) => Promise<void>\n\n /**\n * Reset user password\n */\n resetPassword: (userId: string) => Promise<{ message: string }>\n}\n\n/**\n * Hook for managing users\n *\n * Provides user list with pagination, search, and management functions.\n *\n * @example\n * ```tsx\n * function UserList() {\n * const { users, total, isLoading, refetch, inviteUser, deleteUser } = useUsers({\n * limit: 20,\n * search: searchTerm\n * })\n *\n * return (\n * <div>\n * {isLoading ? <Spinner /> : (\n * <ul>\n * {users.map(user => (\n * <li key={user.id}>\n * {user.email} - {user.role}\n * <button onClick={() => deleteUser(user.id)}>Delete</button>\n * </li>\n * ))}\n * </ul>\n * )}\n * </div>\n * )\n * }\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n const { autoFetch = true, refetchInterval = 0, ...listOptions } = options\n const client = useFluxbaseClient()\n\n const [users, setUsers] = useState<EnrichedUser[]>([])\n const [total, setTotal] = useState(0)\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n /**\n * Fetch users from API\n */\n const fetchUsers = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const { data, error: apiError } = await client.admin.listUsers(listOptions)\n if (apiError) {\n throw apiError\n }\n setUsers(data!.users)\n setTotal(data!.total)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client, JSON.stringify(listOptions)])\n\n /**\n * Invite a new user\n */\n const inviteUser = useCallback(\n async (email: string, role: 'user' | 'admin'): Promise<void> => {\n await client.admin.inviteUser({ email, role })\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Update user role\n */\n const updateUserRole = useCallback(\n async (userId: string, role: 'user' | 'admin'): Promise<void> => {\n await client.admin.updateUserRole(userId, role)\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Delete a user\n */\n const deleteUser = useCallback(\n async (userId: string): Promise<void> => {\n await client.admin.deleteUser(userId)\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Reset user password\n */\n const resetPassword = useCallback(\n async (userId: string): Promise<{ message: string }> => {\n const { data, error } = await client.admin.resetUserPassword(userId)\n if (error) {\n throw error\n }\n return data!\n },\n [client]\n )\n\n // Auto-fetch on mount\n useEffect(() => {\n if (autoFetch) {\n fetchUsers()\n }\n }, [autoFetch, fetchUsers])\n\n // Set up refetch interval\n useEffect(() => {\n if (refetchInterval > 0) {\n const interval = setInterval(fetchUsers, refetchInterval)\n return () => clearInterval(interval)\n }\n }, [refetchInterval, fetchUsers])\n\n return {\n users,\n total,\n isLoading,\n error,\n refetch: fetchUsers,\n inviteUser,\n updateUserRole,\n deleteUser,\n resetPassword\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type { APIKey, CreateAPIKeyRequest } from '@fluxbase/sdk'\n\nexport interface UseAPIKeysOptions {\n /**\n * Whether to automatically fetch API keys on mount\n * @default true\n */\n autoFetch?: boolean\n}\n\nexport interface UseAPIKeysReturn {\n /**\n * Array of API keys\n */\n keys: APIKey[]\n\n /**\n * Whether keys are being fetched\n */\n isLoading: boolean\n\n /**\n * Any error that occurred\n */\n error: Error | null\n\n /**\n * Refetch API keys\n */\n refetch: () => Promise<void>\n\n /**\n * Create a new API key\n */\n createKey: (request: CreateAPIKeyRequest) => Promise<{ key: string; keyData: APIKey }>\n\n /**\n * Update an API key\n */\n updateKey: (keyId: string, update: { name?: string; description?: string }) => Promise<void>\n\n /**\n * Revoke an API key\n */\n revokeKey: (keyId: string) => Promise<void>\n\n /**\n * Delete an API key\n */\n deleteKey: (keyId: string) => Promise<void>\n}\n\n/**\n * Hook for managing API keys\n *\n * Provides API key list and management functions.\n *\n * @example\n * ```tsx\n * function APIKeyManager() {\n * const { keys, isLoading, createKey, revokeKey } = useAPIKeys()\n *\n * const handleCreate = async () => {\n * const { key, keyData } = await createKey({\n * name: 'Backend Service',\n * description: 'API key for backend',\n * expires_at: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString()\n * })\n * alert(`Key created: ${key}`)\n * }\n *\n * return (\n * <div>\n * <button onClick={handleCreate}>Create Key</button>\n * {keys.map(k => (\n * <div key={k.id}>\n * {k.name}\n * <button onClick={() => revokeKey(k.id)}>Revoke</button>\n * </div>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useAPIKeys(options: UseAPIKeysOptions = {}): UseAPIKeysReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [keys, setKeys] = useState<APIKey[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n /**\n * Fetch API keys from API\n */\n const fetchKeys = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.management.apiKeys.list()\n setKeys(response.api_keys)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n /**\n * Create a new API key\n */\n const createKey = useCallback(\n async (request: CreateAPIKeyRequest): Promise<{ key: string; keyData: APIKey }> => {\n const response = await client.admin.management.apiKeys.create(request)\n await fetchKeys() // Refresh list\n return { key: response.key, keyData: response.api_key }\n },\n [client, fetchKeys]\n )\n\n /**\n * Update an API key\n */\n const updateKey = useCallback(\n async (keyId: string, update: { name?: string; description?: string }): Promise<void> => {\n await client.admin.management.apiKeys.update(keyId, update)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n /**\n * Revoke an API key\n */\n const revokeKey = useCallback(\n async (keyId: string): Promise<void> => {\n await client.admin.management.apiKeys.revoke(keyId)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n /**\n * Delete an API key\n */\n const deleteKey = useCallback(\n async (keyId: string): Promise<void> => {\n await client.admin.management.apiKeys.delete(keyId)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n // Auto-fetch on mount\n useEffect(() => {\n if (autoFetch) {\n fetchKeys()\n }\n }, [autoFetch, fetchKeys])\n\n return {\n keys,\n isLoading,\n error,\n refetch: fetchKeys,\n createKey,\n updateKey,\n revokeKey,\n deleteKey\n }\n}\n","/**\n * Admin Settings and Management Hooks\n *\n * Hooks for managing application settings, system settings, and webhooks.\n */\n\nimport { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type {\n AppSettings,\n UpdateAppSettingsRequest,\n SystemSetting,\n UpdateSystemSettingRequest,\n Webhook,\n CreateWebhookRequest,\n UpdateWebhookRequest\n} from '@fluxbase/sdk'\n\n// ============================================================================\n// useAppSettings Hook\n// ============================================================================\n\nexport interface UseAppSettingsOptions {\n autoFetch?: boolean\n}\n\nexport interface UseAppSettingsReturn {\n settings: AppSettings | null\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n updateSettings: (update: UpdateAppSettingsRequest) => Promise<void>\n}\n\n/**\n * Hook for managing application settings\n *\n * @example\n * ```tsx\n * function SettingsPanel() {\n * const { settings, isLoading, updateSettings } = useAppSettings({ autoFetch: true })\n *\n * const handleToggleFeature = async (feature: string, enabled: boolean) => {\n * await updateSettings({\n * features: { ...settings?.features, [feature]: enabled }\n * })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useAppSettings(options: UseAppSettingsOptions = {}): UseAppSettingsReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [settings, setSettings] = useState<AppSettings | null>(null)\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchSettings = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const appSettings = await client.admin.settings.app.get()\n setSettings(appSettings)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const updateSettings = useCallback(\n async (update: UpdateAppSettingsRequest): Promise<void> => {\n await client.admin.settings.app.update(update)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchSettings()\n }\n }, [autoFetch, fetchSettings])\n\n return {\n settings,\n isLoading,\n error,\n refetch: fetchSettings,\n updateSettings\n }\n}\n\n// ============================================================================\n// useSystemSettings Hook\n// ============================================================================\n\nexport interface UseSystemSettingsOptions {\n autoFetch?: boolean\n}\n\nexport interface UseSystemSettingsReturn {\n settings: SystemSetting[]\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n getSetting: (key: string) => SystemSetting | undefined\n updateSetting: (key: string, update: UpdateSystemSettingRequest) => Promise<void>\n deleteSetting: (key: string) => Promise<void>\n}\n\n/**\n * Hook for managing system settings (key-value storage)\n *\n * @example\n * ```tsx\n * function SystemSettings() {\n * const { settings, isLoading, updateSetting } = useSystemSettings({ autoFetch: true })\n *\n * const handleUpdateSetting = async (key: string, value: any) => {\n * await updateSetting(key, { value })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useSystemSettings(options: UseSystemSettingsOptions = {}): UseSystemSettingsReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [settings, setSettings] = useState<SystemSetting[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchSettings = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.settings.system.list()\n setSettings(response.settings)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const getSetting = useCallback(\n (key: string): SystemSetting | undefined => {\n return settings.find((s) => s.key === key)\n },\n [settings]\n )\n\n const updateSetting = useCallback(\n async (key: string, update: UpdateSystemSettingRequest): Promise<void> => {\n await client.admin.settings.system.update(key, update)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n const deleteSetting = useCallback(\n async (key: string): Promise<void> => {\n await client.admin.settings.system.delete(key)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchSettings()\n }\n }, [autoFetch, fetchSettings])\n\n return {\n settings,\n isLoading,\n error,\n refetch: fetchSettings,\n getSetting,\n updateSetting,\n deleteSetting\n }\n}\n\n// ============================================================================\n// useWebhooks Hook\n// ============================================================================\n\nexport interface UseWebhooksOptions {\n autoFetch?: boolean\n refetchInterval?: number\n}\n\nexport interface UseWebhooksReturn {\n webhooks: Webhook[]\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n createWebhook: (webhook: CreateWebhookRequest) => Promise<Webhook>\n updateWebhook: (id: string, update: UpdateWebhookRequest) => Promise<Webhook>\n deleteWebhook: (id: string) => Promise<void>\n testWebhook: (id: string) => Promise<void>\n}\n\n/**\n * Hook for managing webhooks\n *\n * @example\n * ```tsx\n * function WebhooksManager() {\n * const { webhooks, isLoading, createWebhook, deleteWebhook } = useWebhooks({\n * autoFetch: true\n * })\n *\n * const handleCreate = async () => {\n * await createWebhook({\n * url: 'https://example.com/webhook',\n * events: ['user.created', 'user.updated'],\n * enabled: true\n * })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useWebhooks(options: UseWebhooksOptions = {}): UseWebhooksReturn {\n const { autoFetch = true, refetchInterval = 0 } = options\n const client = useFluxbaseClient()\n\n const [webhooks, setWebhooks] = useState<Webhook[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchWebhooks = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.management.webhooks.list()\n setWebhooks(response.webhooks)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const createWebhook = useCallback(\n async (webhook: CreateWebhookRequest): Promise<Webhook> => {\n const created = await client.admin.management.webhooks.create(webhook)\n await fetchWebhooks()\n return created\n },\n [client, fetchWebhooks]\n )\n\n const updateWebhook = useCallback(\n async (id: string, update: UpdateWebhookRequest): Promise<Webhook> => {\n const updated = await client.admin.management.webhooks.update(id, update)\n await fetchWebhooks()\n return updated\n },\n [client, fetchWebhooks]\n )\n\n const deleteWebhook = useCallback(\n async (id: string): Promise<void> => {\n await client.admin.management.webhooks.delete(id)\n await fetchWebhooks()\n },\n [client, fetchWebhooks]\n )\n\n const testWebhook = useCallback(\n async (id: string): Promise<void> => {\n await client.admin.management.webhooks.test(id)\n },\n [client]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchWebhooks()\n }\n\n if (refetchInterval > 0) {\n const interval = setInterval(fetchWebhooks, refetchInterval)\n return () => clearInterval(interval)\n }\n }, [autoFetch, refetchInterval, fetchWebhooks])\n\n return {\n webhooks,\n isLoading,\n error,\n refetch: fetchWebhooks,\n createWebhook,\n updateWebhook,\n deleteWebhook,\n testWebhook\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;A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;AACpB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,aAAa;AAAA,EACxB;AAEA,QAAM,oBAAgB;AAAA,IACpB,OAAO,OAA8B;AACnC,YAAM,OAAO,MAAM,WAAW,SAAS,OAAO,EAAE;AAChD,YAAM,cAAc;AAAA,IACtB;AAAA,IACA,CAAC,QAAQ,aAAa;AAAA,EACxB;AAEA,QAAM,kBAAc;AAAA,IAClB,OAAO,OAA8B;AACnC,YAAM,OAAO,MAAM,WAAW,SAAS,KAAK,EAAE;AAAA,IAChD;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,+BAAU,MAAM;AACd,QAAI,WAAW;AACb,oBAAc;AAAA,IAChB;AAEA,QAAI,kBAAkB,GAAG;AACvB,YAAM,WAAW,YAAY,eAAe,eAAe;AAC3D,aAAO,MAAM,cAAc,QAAQ;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,WAAW,iBAAiB,aAAa,CAAC;AAE9C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_react_query","client","import_react","import_react_query","import_react_query","import_react_query","import_react","import_react","error","import_react","import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/context.tsx","../src/use-auth.ts","../src/use-query.ts","../src/use-realtime.ts","../src/use-storage.ts","../src/use-rpc.ts","../src/use-admin-auth.ts","../src/use-users.ts","../src/use-api-keys.ts","../src/use-admin-hooks.ts"],"sourcesContent":["/**\n * Fluxbase React Hooks\n *\n * @example\n * ```tsx\n * import { createClient } from '@fluxbase/sdk'\n * import { FluxbaseProvider, useAuth, useTable } from '@fluxbase/sdk-react'\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'\n *\n * const client = createClient({ url: 'http://localhost:8080' })\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return (\n * <QueryClientProvider client={queryClient}>\n * <FluxbaseProvider client={client}>\n * <MyComponent />\n * </FluxbaseProvider>\n * </QueryClientProvider>\n * )\n * }\n *\n * function MyComponent() {\n * const { user, signIn, signOut } = useAuth()\n * const { data: products } = useTable('products', (q) => q.select('*').eq('active', true))\n *\n * return <div>...</div>\n * }\n * ```\n */\n\n// Context and provider\nexport { FluxbaseProvider, useFluxbaseClient } from './context'\n\n// Auth hooks\nexport {\n useAuth,\n useUser,\n useSession,\n useSignIn,\n useSignUp,\n useSignOut,\n useUpdateUser,\n} from './use-auth'\n\n// Database query hooks\nexport {\n useFluxbaseQuery,\n useTable,\n useInsert,\n useUpdate,\n useUpsert,\n useDelete,\n} from './use-query'\n\n// Realtime hooks\nexport {\n useRealtime,\n useTableSubscription,\n useTableInserts,\n useTableUpdates,\n useTableDeletes,\n} from './use-realtime'\n\n// Storage hooks\nexport {\n useStorageList,\n useStorageUpload,\n useStorageDownload,\n useStorageDelete,\n useStoragePublicUrl,\n useStorageSignedUrl,\n useStorageMove,\n useStorageCopy,\n useStorageBuckets,\n useCreateBucket,\n useDeleteBucket,\n} from './use-storage'\n\n// RPC hooks\nexport {\n useRPC,\n useRPCMutation,\n useRPCBatch,\n} from './use-rpc'\n\n// Admin hooks\nexport { useAdminAuth } from './use-admin-auth'\nexport { useUsers } from './use-users'\nexport { useAPIKeys } from './use-api-keys'\nexport {\n useWebhooks,\n useAppSettings,\n useSystemSettings,\n} from './use-admin-hooks'\n\n// Re-export types from SDK\nexport type {\n FluxbaseClient,\n AuthSession,\n User,\n SignInCredentials,\n SignUpCredentials,\n PostgrestResponse,\n RealtimeChangePayload,\n StorageObject,\n AdminUser,\n EnrichedUser,\n APIKey,\n Webhook,\n AppSettings,\n SystemSetting,\n} from '@fluxbase/sdk'\n","/**\n * React context for Fluxbase client\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\nimport type { FluxbaseClient } from '@fluxbase/sdk'\n\nconst FluxbaseContext = createContext<FluxbaseClient | null>(null)\n\nexport interface FluxbaseProviderProps {\n client: FluxbaseClient\n children: ReactNode\n}\n\n/**\n * Provider component to make Fluxbase client available throughout the app\n */\nexport function FluxbaseProvider({ client, children }: FluxbaseProviderProps) {\n return <FluxbaseContext.Provider value={client}>{children}</FluxbaseContext.Provider>\n}\n\n/**\n * Hook to access the Fluxbase client from context\n */\nexport function useFluxbaseClient(): FluxbaseClient {\n const client = useContext(FluxbaseContext)\n\n if (!client) {\n throw new Error('useFluxbaseClient must be used within a FluxbaseProvider')\n }\n\n return client\n}\n","/**\n * Authentication hooks for Fluxbase SDK\n */\n\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { useFluxbaseClient } from \"./context\";\nimport type {\n SignInCredentials,\n SignUpCredentials,\n User,\n AuthSession,\n} from \"@fluxbase/sdk\";\n\n/**\n * Hook to get the current user\n */\nexport function useUser() {\n const client = useFluxbaseClient();\n\n return useQuery({\n queryKey: [\"fluxbase\", \"auth\", \"user\"],\n queryFn: async () => {\n const { data } = await client.auth.getSession();\n if (!data?.session) {\n return null;\n }\n\n try {\n const result = await client.auth.getCurrentUser();\n return result.data?.user ?? null;\n } catch {\n return null;\n }\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n });\n}\n\n/**\n * Hook to get the current session\n */\nexport function useSession() {\n const client = useFluxbaseClient();\n\n return useQuery<AuthSession | null>({\n queryKey: [\"fluxbase\", \"auth\", \"session\"],\n queryFn: async () => {\n const { data } = await client.auth.getSession();\n return data?.session ?? null;\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n });\n}\n\n/**\n * Hook for signing in\n */\nexport function useSignIn() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (credentials: SignInCredentials) => {\n return await client.auth.signIn(credentials);\n },\n onSuccess: (session) => {\n queryClient.setQueryData([\"fluxbase\", \"auth\", \"session\"], session);\n // Only set user if this is a complete auth session (not 2FA required)\n if (\"user\" in session) {\n queryClient.setQueryData([\"fluxbase\", \"auth\", \"user\"], session.user);\n }\n },\n });\n}\n\n/**\n * Hook for signing up\n */\nexport function useSignUp() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (credentials: SignUpCredentials) => {\n return await client.auth.signUp(credentials);\n },\n onSuccess: (response) => {\n if (response.data) {\n queryClient.setQueryData(\n [\"fluxbase\", \"auth\", \"session\"],\n response.data.session,\n );\n queryClient.setQueryData(\n [\"fluxbase\", \"auth\", \"user\"],\n response.data.user,\n );\n }\n },\n });\n}\n\n/**\n * Hook for signing out\n */\nexport function useSignOut() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async () => {\n await client.auth.signOut();\n },\n onSuccess: () => {\n queryClient.setQueryData([\"fluxbase\", \"auth\", \"session\"], null);\n queryClient.setQueryData([\"fluxbase\", \"auth\", \"user\"], null);\n queryClient.invalidateQueries({ queryKey: [\"fluxbase\"] });\n },\n });\n}\n\n/**\n * Hook for updating the current user\n */\nexport function useUpdateUser() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (data: Partial<Pick<User, \"email\" | \"metadata\">>) => {\n return await client.auth.updateUser(data);\n },\n onSuccess: (user) => {\n queryClient.setQueryData([\"fluxbase\", \"auth\", \"user\"], user);\n },\n });\n}\n\n/**\n * Combined auth hook with all auth state and methods\n */\nexport function useAuth() {\n const { data: user, isLoading: isLoadingUser } = useUser();\n const { data: session, isLoading: isLoadingSession } = useSession();\n const signIn = useSignIn();\n const signUp = useSignUp();\n const signOut = useSignOut();\n const updateUser = useUpdateUser();\n\n return {\n user,\n session,\n isLoading: isLoadingUser || isLoadingSession,\n isAuthenticated: !!session,\n signIn: signIn.mutateAsync,\n signUp: signUp.mutateAsync,\n signOut: signOut.mutateAsync,\n updateUser: updateUser.mutateAsync,\n isSigningIn: signIn.isPending,\n isSigningUp: signUp.isPending,\n isSigningOut: signOut.isPending,\n isUpdating: updateUser.isPending,\n };\n}\n","/**\n * Database query hooks for Fluxbase SDK\n */\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { QueryBuilder } from '@fluxbase/sdk'\n\nexport interface UseFluxbaseQueryOptions<T> extends Omit<UseQueryOptions<T[], Error>, 'queryKey' | 'queryFn'> {\n /**\n * Custom query key. If not provided, will use table name and filters.\n */\n queryKey?: unknown[]\n}\n\n/**\n * Hook to execute a database query\n * @param buildQuery - Function that builds and returns the query\n * @param options - React Query options\n */\nexport function useFluxbaseQuery<T = any>(\n buildQuery: (client: ReturnType<typeof useFluxbaseClient>) => QueryBuilder<T>,\n options?: UseFluxbaseQueryOptions<T>\n) {\n const client = useFluxbaseClient()\n\n // Build a stable query key\n const queryKey = options?.queryKey || ['fluxbase', 'query', buildQuery.toString()]\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n const query = buildQuery(client)\n const { data, error } = await query.execute()\n\n if (error) {\n throw error\n }\n\n return (Array.isArray(data) ? data : data ? [data] : []) as T[]\n },\n ...options,\n })\n}\n\n/**\n * Hook for table queries with a simpler API\n * @param table - Table name\n * @param buildQuery - Function to build the query\n */\nexport function useTable<T = any>(\n table: string,\n buildQuery?: (query: QueryBuilder<T>) => QueryBuilder<T>,\n options?: UseFluxbaseQueryOptions<T>\n) {\n const client = useFluxbaseClient()\n\n return useFluxbaseQuery(\n (client) => {\n const query = client.from<T>(table)\n return buildQuery ? buildQuery(query) : query\n },\n {\n ...options,\n queryKey: options?.queryKey || ['fluxbase', 'table', table, buildQuery?.toString()],\n }\n )\n}\n\n/**\n * Hook to insert data into a table\n */\nexport function useInsert<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (data: Partial<T> | Partial<T>[]) => {\n const query = client.from<T>(table)\n const { data: result, error } = await query.insert(data as Partial<T>)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n // Invalidate all queries for this table\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to update data in a table\n */\nexport function useUpdate<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (params: { data: Partial<T>; buildQuery: (query: QueryBuilder<T>) => QueryBuilder<T> }) => {\n const query = client.from<T>(table)\n const builtQuery = params.buildQuery(query)\n const { data: result, error } = await builtQuery.update(params.data)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to upsert data into a table\n */\nexport function useUpsert<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (data: Partial<T> | Partial<T>[]) => {\n const query = client.from<T>(table)\n const { data: result, error } = await query.upsert(data as Partial<T>)\n\n if (error) {\n throw error\n }\n\n return result\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n\n/**\n * Hook to delete data from a table\n */\nexport function useDelete<T = any>(table: string) {\n const client = useFluxbaseClient()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: async (buildQuery: (query: QueryBuilder<T>) => QueryBuilder<T>) => {\n const query = client.from<T>(table)\n const builtQuery = buildQuery(query)\n const { error } = await builtQuery.delete()\n\n if (error) {\n throw error\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['fluxbase', 'table', table] })\n },\n })\n}\n","/**\n * Realtime subscription hooks for Fluxbase SDK\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useFluxbaseClient } from \"./context\";\nimport type {\n RealtimeCallback,\n RealtimePostgresChangesPayload,\n} from \"@fluxbase/sdk\";\n\nexport interface UseRealtimeOptions {\n /**\n * The channel name (e.g., 'table:public.products')\n */\n channel: string;\n\n /**\n * Event type to listen for ('INSERT', 'UPDATE', 'DELETE', or '*' for all)\n */\n event?: \"INSERT\" | \"UPDATE\" | \"DELETE\" | \"*\";\n\n /**\n * Callback function when an event is received\n */\n callback?: RealtimeCallback;\n\n /**\n * Whether to automatically invalidate queries for the table\n * Default: true\n */\n autoInvalidate?: boolean;\n\n /**\n * Custom query key to invalidate (if autoInvalidate is true)\n * Default: ['fluxbase', 'table', tableName]\n */\n invalidateKey?: unknown[];\n\n /**\n * Whether the subscription is enabled\n * Default: true\n */\n enabled?: boolean;\n}\n\n/**\n * Hook to subscribe to realtime changes for a channel\n */\nexport function useRealtime(options: UseRealtimeOptions) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n const channelRef = useRef<ReturnType<typeof client.realtime.channel> | null>(\n null,\n );\n\n const {\n channel: channelName,\n event = \"*\",\n callback,\n autoInvalidate = true,\n invalidateKey,\n enabled = true,\n } = options;\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n // Create channel and subscribe\n const channel = client.realtime.channel(channelName);\n channelRef.current = channel;\n\n const handleChange = (payload: RealtimePostgresChangesPayload) => {\n // Call user callback\n if (callback) {\n callback(payload);\n }\n\n // Auto-invalidate queries if enabled\n if (autoInvalidate) {\n // Extract table name from channel (e.g., 'table:public.products' -> 'public.products')\n const tableName = channelName.replace(/^table:/, \"\");\n\n const key = invalidateKey || [\"fluxbase\", \"table\", tableName];\n queryClient.invalidateQueries({ queryKey: key });\n }\n };\n\n channel.on(event, handleChange).subscribe();\n\n return () => {\n channel.unsubscribe();\n channelRef.current = null;\n };\n }, [\n client,\n channelName,\n event,\n callback,\n autoInvalidate,\n invalidateKey,\n queryClient,\n enabled,\n ]);\n\n return {\n channel: channelRef.current,\n };\n}\n\n/**\n * Hook to subscribe to a table's changes\n * @param table - Table name (with optional schema, e.g., 'public.products')\n * @param options - Subscription options\n */\nexport function useTableSubscription(\n table: string,\n options?: Omit<UseRealtimeOptions, \"channel\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n });\n}\n\n/**\n * Hook to subscribe to INSERT events on a table\n */\nexport function useTableInserts(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"INSERT\",\n callback,\n });\n}\n\n/**\n * Hook to subscribe to UPDATE events on a table\n */\nexport function useTableUpdates(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"UPDATE\",\n callback,\n });\n}\n\n/**\n * Hook to subscribe to DELETE events on a table\n */\nexport function useTableDeletes(\n table: string,\n callback: (payload: RealtimePostgresChangesPayload) => void,\n options?: Omit<UseRealtimeOptions, \"channel\" | \"event\" | \"callback\">,\n) {\n return useRealtime({\n ...options,\n channel: `table:${table}`,\n event: \"DELETE\",\n callback,\n });\n}\n","/**\n * Storage hooks for Fluxbase SDK\n */\n\nimport { useState } from \"react\";\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseQueryOptions,\n} from \"@tanstack/react-query\";\nimport { useFluxbaseClient } from \"./context\";\nimport type { ListOptions, UploadOptions, UploadProgress } from \"@fluxbase/sdk\";\n\n/**\n * Hook to list files in a bucket\n */\nexport function useStorageList(\n bucket: string,\n options?: ListOptions &\n Omit<UseQueryOptions<any[], Error>, \"queryKey\" | \"queryFn\">,\n) {\n const client = useFluxbaseClient();\n const { prefix, limit, offset, ...queryOptions } = options || {};\n\n return useQuery({\n queryKey: [\n \"fluxbase\",\n \"storage\",\n bucket,\n \"list\",\n { prefix, limit, offset },\n ],\n queryFn: async () => {\n const { data, error } = await client.storage\n .from(bucket)\n .list({ prefix, limit, offset });\n\n if (error) {\n throw error;\n }\n\n return data || [];\n },\n ...queryOptions,\n });\n}\n\n/**\n * Hook to upload a file to a bucket\n *\n * Note: You can track upload progress by passing an `onUploadProgress` callback in the options:\n *\n * @example\n * ```tsx\n * const upload = useStorageUpload('avatars')\n *\n * upload.mutate({\n * path: 'user.jpg',\n * file: file,\n * options: {\n * onUploadProgress: (progress) => {\n * console.log(`${progress.percentage}% uploaded`)\n * }\n * }\n * })\n * ```\n *\n * For automatic progress state management, use `useStorageUploadWithProgress` instead.\n */\nexport function useStorageUpload(bucket: string) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (params: {\n path: string;\n file: File | Blob | ArrayBuffer;\n options?: UploadOptions;\n }) => {\n const { path, file, options } = params;\n const { data, error } = await client.storage\n .from(bucket)\n .upload(path, file, options);\n\n if (error) {\n throw error;\n }\n\n return data;\n },\n onSuccess: () => {\n // Invalidate list queries for this bucket\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"list\"],\n });\n },\n });\n}\n\n/**\n * Hook to upload a file to a bucket with built-in progress tracking\n *\n * @example\n * ```tsx\n * const { upload, progress, reset } = useStorageUploadWithProgress('avatars')\n *\n * // Upload with automatic progress tracking\n * upload.mutate({\n * path: 'user.jpg',\n * file: file\n * })\n *\n * // Display progress\n * console.log(progress) // { loaded: 1024, total: 2048, percentage: 50 }\n * ```\n */\nexport function useStorageUploadWithProgress(bucket: string) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n const [progress, setProgress] = useState<UploadProgress | null>(null);\n\n const mutation = useMutation({\n mutationFn: async (params: {\n path: string;\n file: File | Blob | ArrayBuffer;\n options?: Omit<UploadOptions, \"onUploadProgress\">;\n }) => {\n const { path, file, options } = params;\n\n // Reset progress at the start of upload\n setProgress({ loaded: 0, total: 0, percentage: 0 });\n\n const { data, error } = await client.storage\n .from(bucket)\n .upload(path, file, {\n ...options,\n onUploadProgress: (p) => {\n setProgress(p);\n },\n });\n\n if (error) {\n throw error;\n }\n\n return data;\n },\n onSuccess: () => {\n // Invalidate list queries for this bucket\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"list\"],\n });\n },\n onError: () => {\n // Reset progress on error\n setProgress(null);\n },\n });\n\n return {\n upload: mutation,\n progress,\n reset: () => setProgress(null),\n };\n}\n\n/**\n * Hook to download a file from a bucket\n */\nexport function useStorageDownload(\n bucket: string,\n path: string | null,\n enabled = true,\n) {\n const client = useFluxbaseClient();\n\n return useQuery({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"download\", path],\n queryFn: async () => {\n if (!path) {\n return null;\n }\n\n const { data, error } = await client.storage.from(bucket).download(path);\n\n if (error) {\n throw error;\n }\n\n return data;\n },\n enabled: enabled && !!path,\n });\n}\n\n/**\n * Hook to delete files from a bucket\n */\nexport function useStorageDelete(bucket: string) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (paths: string[]) => {\n const { error } = await client.storage.from(bucket).remove(paths);\n\n if (error) {\n throw error;\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"list\"],\n });\n },\n });\n}\n\n/**\n * Hook to get a public URL for a file\n */\nexport function useStoragePublicUrl(bucket: string, path: string | null) {\n const client = useFluxbaseClient();\n\n if (!path) {\n return null;\n }\n\n const { data } = client.storage.from(bucket).getPublicUrl(path);\n return data.publicUrl;\n}\n\n/**\n * Hook to create a signed URL\n */\nexport function useStorageSignedUrl(\n bucket: string,\n path: string | null,\n expiresIn?: number,\n) {\n const client = useFluxbaseClient();\n\n return useQuery({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"signed-url\", path, expiresIn],\n queryFn: async () => {\n if (!path) {\n return null;\n }\n\n const { data, error } = await client.storage\n .from(bucket)\n .createSignedUrl(path, { expiresIn });\n\n if (error) {\n throw error;\n }\n\n return data?.signedUrl || null;\n },\n enabled: !!path,\n staleTime: expiresIn ? expiresIn * 1000 - 60000 : 1000 * 60 * 50, // Refresh 1 minute before expiry\n });\n}\n\n/**\n * Hook to move a file\n */\nexport function useStorageMove(bucket: string) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (params: { fromPath: string; toPath: string }) => {\n const { fromPath, toPath } = params;\n const { data, error } = await client.storage\n .from(bucket)\n .move(fromPath, toPath);\n\n if (error) {\n throw error;\n }\n\n return data;\n },\n onSuccess: () => {\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"list\"],\n });\n },\n });\n}\n\n/**\n * Hook to copy a file\n */\nexport function useStorageCopy(bucket: string) {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (params: { fromPath: string; toPath: string }) => {\n const { fromPath, toPath } = params;\n const { data, error } = await client.storage\n .from(bucket)\n .copy(fromPath, toPath);\n\n if (error) {\n throw error;\n }\n\n return data;\n },\n onSuccess: () => {\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", bucket, \"list\"],\n });\n },\n });\n}\n\n/**\n * Hook to manage buckets\n */\nexport function useStorageBuckets() {\n const client = useFluxbaseClient();\n\n return useQuery({\n queryKey: [\"fluxbase\", \"storage\", \"buckets\"],\n queryFn: async () => {\n const { data, error } = await client.storage.listBuckets();\n\n if (error) {\n throw error;\n }\n\n return data || [];\n },\n });\n}\n\n/**\n * Hook to create a bucket\n */\nexport function useCreateBucket() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (bucketName: string) => {\n const { error } = await client.storage.createBucket(bucketName);\n\n if (error) {\n throw error;\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", \"buckets\"],\n });\n },\n });\n}\n\n/**\n * Hook to delete a bucket\n */\nexport function useDeleteBucket() {\n const client = useFluxbaseClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (bucketName: string) => {\n const { error } = await client.storage.deleteBucket(bucketName);\n\n if (error) {\n throw error;\n }\n },\n onSuccess: () => {\n queryClient.invalidateQueries({\n queryKey: [\"fluxbase\", \"storage\", \"buckets\"],\n });\n },\n });\n}\n","/**\n * React hooks for RPC (Remote Procedure Calls)\n * Call PostgreSQL functions with React Query integration\n */\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions, type UseMutationOptions } from '@tanstack/react-query'\nimport { useFluxbaseClient } from './context'\nimport type { PostgrestResponse } from '@fluxbase/sdk'\n\n/**\n * Hook to call a PostgreSQL function and cache the result\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useRPC(\n * 'calculate_total',\n * { order_id: 123 },\n * { enabled: !!orderId }\n * )\n * ```\n */\nexport function useRPC<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(\n functionName: string,\n params?: TParams,\n options?: Omit<UseQueryOptions<TData, Error>, 'queryKey' | 'queryFn'>\n) {\n const client = useFluxbaseClient()\n\n return useQuery<TData, Error>({\n queryKey: ['rpc', functionName, params],\n queryFn: async () => {\n const { data, error } = await client.rpc<TData>(functionName, params)\n if (error) {\n throw new Error(error.message)\n }\n return data as TData\n },\n ...options,\n })\n}\n\n/**\n * Hook to create a mutation for calling PostgreSQL functions\n * Useful for functions that modify data\n *\n * @example\n * ```tsx\n * const createOrder = useRPCMutation('create_order')\n *\n * const handleSubmit = async () => {\n * await createOrder.mutateAsync({\n * user_id: 123,\n * items: [{ product_id: 1, quantity: 2 }]\n * })\n * }\n * ```\n */\nexport function useRPCMutation<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(\n functionName: string,\n options?: Omit<UseMutationOptions<TData, Error, TParams>, 'mutationFn'>\n) {\n const client = useFluxbaseClient()\n\n return useMutation<TData, Error, TParams>({\n mutationFn: async (params: TParams) => {\n const { data, error } = await client.rpc<TData>(functionName, params)\n if (error) {\n throw new Error(error.message)\n }\n return data as TData\n },\n ...options,\n })\n}\n\n/**\n * Hook to call multiple RPC functions in parallel\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useRPCBatch([\n * { name: 'get_user_stats', params: { user_id: 123 } },\n * { name: 'get_recent_orders', params: { limit: 10 } },\n * ])\n * ```\n */\nexport function useRPCBatch<TData = unknown>(\n calls: Array<{ name: string; params?: Record<string, unknown> }>,\n options?: Omit<UseQueryOptions<TData[], Error, TData[], readonly unknown[]>, 'queryKey' | 'queryFn'>\n) {\n const client = useFluxbaseClient()\n\n return useQuery({\n queryKey: ['rpc-batch', calls] as const,\n queryFn: async () => {\n const results = await Promise.all(\n calls.map(async ({ name, params }) => {\n const { data, error } = await client.rpc<TData>(name, params)\n if (error) {\n throw new Error(`${name}: ${error.message}`)\n }\n return data\n })\n )\n return results as TData[]\n },\n ...options,\n })\n}\n","import { useState, useEffect, useCallback } from \"react\";\nimport { useFluxbaseClient } from \"./context\";\nimport type { AdminAuthResponse, DataResponse } from \"@fluxbase/sdk\";\n\n/**\n * Simplified admin user type returned by authentication\n */\nexport interface AdminUser {\n id: string;\n email: string;\n role: string;\n}\n\nexport interface UseAdminAuthOptions {\n /**\n * Automatically check authentication status on mount\n * @default true\n */\n autoCheck?: boolean;\n}\n\nexport interface UseAdminAuthReturn {\n /**\n * Current admin user if authenticated\n */\n user: AdminUser | null;\n\n /**\n * Whether the admin is authenticated\n */\n isAuthenticated: boolean;\n\n /**\n * Whether the authentication check is in progress\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during authentication\n */\n error: Error | null;\n\n /**\n * Login as admin\n */\n login: (email: string, password: string) => Promise<AdminAuthResponse>;\n\n /**\n * Logout admin\n */\n logout: () => Promise<void>;\n\n /**\n * Refresh admin user info\n */\n refresh: () => Promise<void>;\n}\n\n/**\n * Hook for admin authentication\n *\n * Manages admin login state, authentication checks, and user info.\n *\n * @example\n * ```tsx\n * function AdminLogin() {\n * const { user, isAuthenticated, isLoading, login, logout } = useAdminAuth()\n *\n * const handleLogin = async (e: React.FormEvent) => {\n * e.preventDefault()\n * await login(email, password)\n * }\n *\n * if (isLoading) return <div>Loading...</div>\n * if (isAuthenticated) return <div>Welcome {user?.email}</div>\n *\n * return <form onSubmit={handleLogin}>...</form>\n * }\n * ```\n */\nexport function useAdminAuth(\n options: UseAdminAuthOptions = {},\n): UseAdminAuthReturn {\n const { autoCheck = true } = options;\n const client = useFluxbaseClient();\n\n const [user, setUser] = useState<AdminUser | null>(null);\n const [isLoading, setIsLoading] = useState(autoCheck);\n const [error, setError] = useState<Error | null>(null);\n\n /**\n * Check current authentication status\n */\n const checkAuth = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const { data, error: apiError } = await client.admin.me();\n if (apiError) {\n throw apiError;\n }\n setUser(data!.user);\n } catch (err) {\n setUser(null);\n setError(err as Error);\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n /**\n * Login as admin\n */\n const login = useCallback(\n async (email: string, password: string): Promise<AdminAuthResponse> => {\n try {\n setIsLoading(true);\n setError(null);\n const { data, error: apiError } = await client.admin.login({\n email,\n password,\n });\n if (apiError) {\n throw apiError;\n }\n setUser(data!.user);\n return data!;\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setIsLoading(false);\n }\n },\n [client],\n );\n\n /**\n * Logout admin\n */\n const logout = useCallback(async (): Promise<void> => {\n try {\n setIsLoading(true);\n setError(null);\n // Clear user state\n setUser(null);\n // Note: Add logout endpoint call here when available\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setIsLoading(false);\n }\n }, []);\n\n /**\n * Refresh admin user info\n */\n const refresh = useCallback(async (): Promise<void> => {\n await checkAuth();\n }, [checkAuth]);\n\n // Auto-check authentication on mount\n useEffect(() => {\n if (autoCheck) {\n checkAuth();\n }\n }, [autoCheck, checkAuth]);\n\n return {\n user,\n isAuthenticated: user !== null,\n isLoading,\n error,\n login,\n logout,\n refresh,\n };\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type { EnrichedUser, ListUsersOptions } from '@fluxbase/sdk'\n\nexport interface UseUsersOptions extends ListUsersOptions {\n /**\n * Whether to automatically fetch users on mount\n * @default true\n */\n autoFetch?: boolean\n\n /**\n * Refetch interval in milliseconds (0 to disable)\n * @default 0\n */\n refetchInterval?: number\n}\n\nexport interface UseUsersReturn {\n /**\n * Array of users\n */\n users: EnrichedUser[]\n\n /**\n * Total number of users (for pagination)\n */\n total: number\n\n /**\n * Whether users are being fetched\n */\n isLoading: boolean\n\n /**\n * Any error that occurred\n */\n error: Error | null\n\n /**\n * Refetch users\n */\n refetch: () => Promise<void>\n\n /**\n * Invite a new user\n */\n inviteUser: (email: string, role: 'user' | 'admin') => Promise<void>\n\n /**\n * Update user role\n */\n updateUserRole: (userId: string, role: 'user' | 'admin') => Promise<void>\n\n /**\n * Delete a user\n */\n deleteUser: (userId: string) => Promise<void>\n\n /**\n * Reset user password\n */\n resetPassword: (userId: string) => Promise<{ message: string }>\n}\n\n/**\n * Hook for managing users\n *\n * Provides user list with pagination, search, and management functions.\n *\n * @example\n * ```tsx\n * function UserList() {\n * const { users, total, isLoading, refetch, inviteUser, deleteUser } = useUsers({\n * limit: 20,\n * search: searchTerm\n * })\n *\n * return (\n * <div>\n * {isLoading ? <Spinner /> : (\n * <ul>\n * {users.map(user => (\n * <li key={user.id}>\n * {user.email} - {user.role}\n * <button onClick={() => deleteUser(user.id)}>Delete</button>\n * </li>\n * ))}\n * </ul>\n * )}\n * </div>\n * )\n * }\n * ```\n */\nexport function useUsers(options: UseUsersOptions = {}): UseUsersReturn {\n const { autoFetch = true, refetchInterval = 0, ...listOptions } = options\n const client = useFluxbaseClient()\n\n const [users, setUsers] = useState<EnrichedUser[]>([])\n const [total, setTotal] = useState(0)\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n /**\n * Fetch users from API\n */\n const fetchUsers = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const { data, error: apiError } = await client.admin.listUsers(listOptions)\n if (apiError) {\n throw apiError\n }\n setUsers(data!.users)\n setTotal(data!.total)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client, JSON.stringify(listOptions)])\n\n /**\n * Invite a new user\n */\n const inviteUser = useCallback(\n async (email: string, role: 'user' | 'admin'): Promise<void> => {\n await client.admin.inviteUser({ email, role })\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Update user role\n */\n const updateUserRole = useCallback(\n async (userId: string, role: 'user' | 'admin'): Promise<void> => {\n await client.admin.updateUserRole(userId, role)\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Delete a user\n */\n const deleteUser = useCallback(\n async (userId: string): Promise<void> => {\n await client.admin.deleteUser(userId)\n await fetchUsers() // Refresh list\n },\n [client, fetchUsers]\n )\n\n /**\n * Reset user password\n */\n const resetPassword = useCallback(\n async (userId: string): Promise<{ message: string }> => {\n const { data, error } = await client.admin.resetUserPassword(userId)\n if (error) {\n throw error\n }\n return data!\n },\n [client]\n )\n\n // Auto-fetch on mount\n useEffect(() => {\n if (autoFetch) {\n fetchUsers()\n }\n }, [autoFetch, fetchUsers])\n\n // Set up refetch interval\n useEffect(() => {\n if (refetchInterval > 0) {\n const interval = setInterval(fetchUsers, refetchInterval)\n return () => clearInterval(interval)\n }\n }, [refetchInterval, fetchUsers])\n\n return {\n users,\n total,\n isLoading,\n error,\n refetch: fetchUsers,\n inviteUser,\n updateUserRole,\n deleteUser,\n resetPassword\n }\n}\n","import { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type { APIKey, CreateAPIKeyRequest } from '@fluxbase/sdk'\n\nexport interface UseAPIKeysOptions {\n /**\n * Whether to automatically fetch API keys on mount\n * @default true\n */\n autoFetch?: boolean\n}\n\nexport interface UseAPIKeysReturn {\n /**\n * Array of API keys\n */\n keys: APIKey[]\n\n /**\n * Whether keys are being fetched\n */\n isLoading: boolean\n\n /**\n * Any error that occurred\n */\n error: Error | null\n\n /**\n * Refetch API keys\n */\n refetch: () => Promise<void>\n\n /**\n * Create a new API key\n */\n createKey: (request: CreateAPIKeyRequest) => Promise<{ key: string; keyData: APIKey }>\n\n /**\n * Update an API key\n */\n updateKey: (keyId: string, update: { name?: string; description?: string }) => Promise<void>\n\n /**\n * Revoke an API key\n */\n revokeKey: (keyId: string) => Promise<void>\n\n /**\n * Delete an API key\n */\n deleteKey: (keyId: string) => Promise<void>\n}\n\n/**\n * Hook for managing API keys\n *\n * Provides API key list and management functions.\n *\n * @example\n * ```tsx\n * function APIKeyManager() {\n * const { keys, isLoading, createKey, revokeKey } = useAPIKeys()\n *\n * const handleCreate = async () => {\n * const { key, keyData } = await createKey({\n * name: 'Backend Service',\n * description: 'API key for backend',\n * expires_at: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString()\n * })\n * alert(`Key created: ${key}`)\n * }\n *\n * return (\n * <div>\n * <button onClick={handleCreate}>Create Key</button>\n * {keys.map(k => (\n * <div key={k.id}>\n * {k.name}\n * <button onClick={() => revokeKey(k.id)}>Revoke</button>\n * </div>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useAPIKeys(options: UseAPIKeysOptions = {}): UseAPIKeysReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [keys, setKeys] = useState<APIKey[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n /**\n * Fetch API keys from API\n */\n const fetchKeys = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.management.apiKeys.list()\n setKeys(response.api_keys)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n /**\n * Create a new API key\n */\n const createKey = useCallback(\n async (request: CreateAPIKeyRequest): Promise<{ key: string; keyData: APIKey }> => {\n const response = await client.admin.management.apiKeys.create(request)\n await fetchKeys() // Refresh list\n return { key: response.key, keyData: response.api_key }\n },\n [client, fetchKeys]\n )\n\n /**\n * Update an API key\n */\n const updateKey = useCallback(\n async (keyId: string, update: { name?: string; description?: string }): Promise<void> => {\n await client.admin.management.apiKeys.update(keyId, update)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n /**\n * Revoke an API key\n */\n const revokeKey = useCallback(\n async (keyId: string): Promise<void> => {\n await client.admin.management.apiKeys.revoke(keyId)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n /**\n * Delete an API key\n */\n const deleteKey = useCallback(\n async (keyId: string): Promise<void> => {\n await client.admin.management.apiKeys.delete(keyId)\n await fetchKeys() // Refresh list\n },\n [client, fetchKeys]\n )\n\n // Auto-fetch on mount\n useEffect(() => {\n if (autoFetch) {\n fetchKeys()\n }\n }, [autoFetch, fetchKeys])\n\n return {\n keys,\n isLoading,\n error,\n refetch: fetchKeys,\n createKey,\n updateKey,\n revokeKey,\n deleteKey\n }\n}\n","/**\n * Admin Settings and Management Hooks\n *\n * Hooks for managing application settings, system settings, and webhooks.\n */\n\nimport { useState, useEffect, useCallback } from 'react'\nimport { useFluxbaseClient } from './context'\nimport type {\n AppSettings,\n UpdateAppSettingsRequest,\n SystemSetting,\n UpdateSystemSettingRequest,\n Webhook,\n CreateWebhookRequest,\n UpdateWebhookRequest\n} from '@fluxbase/sdk'\n\n// ============================================================================\n// useAppSettings Hook\n// ============================================================================\n\nexport interface UseAppSettingsOptions {\n autoFetch?: boolean\n}\n\nexport interface UseAppSettingsReturn {\n settings: AppSettings | null\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n updateSettings: (update: UpdateAppSettingsRequest) => Promise<void>\n}\n\n/**\n * Hook for managing application settings\n *\n * @example\n * ```tsx\n * function SettingsPanel() {\n * const { settings, isLoading, updateSettings } = useAppSettings({ autoFetch: true })\n *\n * const handleToggleFeature = async (feature: string, enabled: boolean) => {\n * await updateSettings({\n * features: { ...settings?.features, [feature]: enabled }\n * })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useAppSettings(options: UseAppSettingsOptions = {}): UseAppSettingsReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [settings, setSettings] = useState<AppSettings | null>(null)\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchSettings = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const appSettings = await client.admin.settings.app.get()\n setSettings(appSettings)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const updateSettings = useCallback(\n async (update: UpdateAppSettingsRequest): Promise<void> => {\n await client.admin.settings.app.update(update)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchSettings()\n }\n }, [autoFetch, fetchSettings])\n\n return {\n settings,\n isLoading,\n error,\n refetch: fetchSettings,\n updateSettings\n }\n}\n\n// ============================================================================\n// useSystemSettings Hook\n// ============================================================================\n\nexport interface UseSystemSettingsOptions {\n autoFetch?: boolean\n}\n\nexport interface UseSystemSettingsReturn {\n settings: SystemSetting[]\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n getSetting: (key: string) => SystemSetting | undefined\n updateSetting: (key: string, update: UpdateSystemSettingRequest) => Promise<void>\n deleteSetting: (key: string) => Promise<void>\n}\n\n/**\n * Hook for managing system settings (key-value storage)\n *\n * @example\n * ```tsx\n * function SystemSettings() {\n * const { settings, isLoading, updateSetting } = useSystemSettings({ autoFetch: true })\n *\n * const handleUpdateSetting = async (key: string, value: any) => {\n * await updateSetting(key, { value })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useSystemSettings(options: UseSystemSettingsOptions = {}): UseSystemSettingsReturn {\n const { autoFetch = true } = options\n const client = useFluxbaseClient()\n\n const [settings, setSettings] = useState<SystemSetting[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchSettings = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.settings.system.list()\n setSettings(response.settings)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const getSetting = useCallback(\n (key: string): SystemSetting | undefined => {\n return settings.find((s) => s.key === key)\n },\n [settings]\n )\n\n const updateSetting = useCallback(\n async (key: string, update: UpdateSystemSettingRequest): Promise<void> => {\n await client.admin.settings.system.update(key, update)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n const deleteSetting = useCallback(\n async (key: string): Promise<void> => {\n await client.admin.settings.system.delete(key)\n await fetchSettings()\n },\n [client, fetchSettings]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchSettings()\n }\n }, [autoFetch, fetchSettings])\n\n return {\n settings,\n isLoading,\n error,\n refetch: fetchSettings,\n getSetting,\n updateSetting,\n deleteSetting\n }\n}\n\n// ============================================================================\n// useWebhooks Hook\n// ============================================================================\n\nexport interface UseWebhooksOptions {\n autoFetch?: boolean\n refetchInterval?: number\n}\n\nexport interface UseWebhooksReturn {\n webhooks: Webhook[]\n isLoading: boolean\n error: Error | null\n refetch: () => Promise<void>\n createWebhook: (webhook: CreateWebhookRequest) => Promise<Webhook>\n updateWebhook: (id: string, update: UpdateWebhookRequest) => Promise<Webhook>\n deleteWebhook: (id: string) => Promise<void>\n testWebhook: (id: string) => Promise<void>\n}\n\n/**\n * Hook for managing webhooks\n *\n * @example\n * ```tsx\n * function WebhooksManager() {\n * const { webhooks, isLoading, createWebhook, deleteWebhook } = useWebhooks({\n * autoFetch: true\n * })\n *\n * const handleCreate = async () => {\n * await createWebhook({\n * url: 'https://example.com/webhook',\n * events: ['user.created', 'user.updated'],\n * enabled: true\n * })\n * }\n *\n * return <div>...</div>\n * }\n * ```\n */\nexport function useWebhooks(options: UseWebhooksOptions = {}): UseWebhooksReturn {\n const { autoFetch = true, refetchInterval = 0 } = options\n const client = useFluxbaseClient()\n\n const [webhooks, setWebhooks] = useState<Webhook[]>([])\n const [isLoading, setIsLoading] = useState(autoFetch)\n const [error, setError] = useState<Error | null>(null)\n\n const fetchWebhooks = useCallback(async () => {\n try {\n setIsLoading(true)\n setError(null)\n const response = await client.admin.management.webhooks.list()\n setWebhooks(response.webhooks)\n } catch (err) {\n setError(err as Error)\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n const createWebhook = useCallback(\n async (webhook: CreateWebhookRequest): Promise<Webhook> => {\n const created = await client.admin.management.webhooks.create(webhook)\n await fetchWebhooks()\n return created\n },\n [client, fetchWebhooks]\n )\n\n const updateWebhook = useCallback(\n async (id: string, update: UpdateWebhookRequest): Promise<Webhook> => {\n const updated = await client.admin.management.webhooks.update(id, update)\n await fetchWebhooks()\n return updated\n },\n [client, fetchWebhooks]\n )\n\n const deleteWebhook = useCallback(\n async (id: string): Promise<void> => {\n await client.admin.management.webhooks.delete(id)\n await fetchWebhooks()\n },\n [client, fetchWebhooks]\n )\n\n const testWebhook = useCallback(\n async (id: string): Promise<void> => {\n await client.admin.management.webhooks.test(id)\n },\n [client]\n )\n\n useEffect(() => {\n if (autoFetch) {\n fetchWebhooks()\n }\n\n if (refetchInterval > 0) {\n const interval = setInterval(fetchWebhooks, refetchInterval)\n return () => clearInterval(interval)\n }\n }, [autoFetch, refetchInterval, fetchWebhooks])\n\n return {\n webhooks,\n isLoading,\n error,\n refetch: fetchWebhooks,\n createWebhook,\n updateWebhook,\n deleteWebhook,\n testWebhook\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,mBAA0D;AAcjD;AAXT,IAAM,sBAAkB,4BAAqC,IAAI;AAU1D,SAAS,iBAAiB,EAAE,QAAQ,SAAS,GAA0B;AAC5E,SAAO,4CAAC,gBAAgB,UAAhB,EAAyB,OAAO,QAAS,UAAS;AAC5D;AAKO,SA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ACtB;AAAA,IACA,CAAC,QAAQ,aAAa;AAAA,EACxB;AAEA,QAAM,kBAAc;AAAA,IAClB,OAAO,OAA8B;AACnC,YAAM,OAAO,MAAM,WAAW,SAAS,KAAK,EAAE;AAAA,IAChD;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,+BAAU,MAAM;AACd,QAAI,WAAW;AACb,oBAAc;AAAA,IAChB;AAEA,QAAI,kBAAkB,GAAG;AACvB,YAAM,WAAW,YAAY,eAAe,eAAe;AAC3D,aAAO,MAAM,cAAc,QAAQ;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,WAAW,iBAAiB,aAAa,CAAC;AAE9C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["import_react_query","client","import_react","import_react_query","import_react","import_react_query","import_react_query","import_react","import_react","error","import_react","import_react"]}
package/dist/index.mjs CHANGED
@@ -20,12 +20,13 @@ function useUser() {
20
20
  return useQuery({
21
21
  queryKey: ["fluxbase", "auth", "user"],
22
22
  queryFn: async () => {
23
- const session = client.auth.getSession();
24
- if (!session) {
23
+ const { data } = await client.auth.getSession();
24
+ if (!data?.session) {
25
25
  return null;
26
26
  }
27
27
  try {
28
- return await client.auth.getCurrentUser();
28
+ const result = await client.auth.getCurrentUser();
29
+ return result.data?.user ?? null;
29
30
  } catch {
30
31
  return null;
31
32
  }
@@ -38,7 +39,10 @@ function useSession() {
38
39
  const client = useFluxbaseClient();
39
40
  return useQuery({
40
41
  queryKey: ["fluxbase", "auth", "session"],
41
- queryFn: () => client.auth.getSession(),
42
+ queryFn: async () => {
43
+ const { data } = await client.auth.getSession();
44
+ return data?.session ?? null;
45
+ },
42
46
  staleTime: 1e3 * 60 * 5
43
47
  // 5 minutes
44
48
  });
@@ -67,8 +71,14 @@ function useSignUp() {
67
71
  },
68
72
  onSuccess: (response) => {
69
73
  if (response.data) {
70
- queryClient.setQueryData(["fluxbase", "auth", "session"], response.data.session);
71
- queryClient.setQueryData(["fluxbase", "auth", "user"], response.data.user);
74
+ queryClient.setQueryData(
75
+ ["fluxbase", "auth", "session"],
76
+ response.data.session
77
+ );
78
+ queryClient.setQueryData(
79
+ ["fluxbase", "auth", "user"],
80
+ response.data.user
81
+ );
72
82
  }
73
83
  }
74
84
  });
@@ -307,12 +317,23 @@ function useTableDeletes(table, callback, options) {
307
317
  }
308
318
 
309
319
  // src/use-storage.ts
310
- import { useMutation as useMutation3, useQuery as useQuery3, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
320
+ import { useState } from "react";
321
+ import {
322
+ useMutation as useMutation3,
323
+ useQuery as useQuery3,
324
+ useQueryClient as useQueryClient4
325
+ } from "@tanstack/react-query";
311
326
  function useStorageList(bucket, options) {
312
327
  const client = useFluxbaseClient();
313
328
  const { prefix, limit, offset, ...queryOptions } = options || {};
314
329
  return useQuery3({
315
- queryKey: ["fluxbase", "storage", bucket, "list", { prefix, limit, offset }],
330
+ queryKey: [
331
+ "fluxbase",
332
+ "storage",
333
+ bucket,
334
+ "list",
335
+ { prefix, limit, offset }
336
+ ],
316
337
  queryFn: async () => {
317
338
  const { data, error } = await client.storage.from(bucket).list({ prefix, limit, offset });
318
339
  if (error) {
@@ -336,7 +357,9 @@ function useStorageUpload(bucket) {
336
357
  return data;
337
358
  },
338
359
  onSuccess: () => {
339
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
360
+ queryClient.invalidateQueries({
361
+ queryKey: ["fluxbase", "storage", bucket, "list"]
362
+ });
340
363
  }
341
364
  });
342
365
  }
@@ -368,7 +391,9 @@ function useStorageDelete(bucket) {
368
391
  }
369
392
  },
370
393
  onSuccess: () => {
371
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
394
+ queryClient.invalidateQueries({
395
+ queryKey: ["fluxbase", "storage", bucket, "list"]
396
+ });
372
397
  }
373
398
  });
374
399
  }
@@ -412,7 +437,9 @@ function useStorageMove(bucket) {
412
437
  return data;
413
438
  },
414
439
  onSuccess: () => {
415
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
440
+ queryClient.invalidateQueries({
441
+ queryKey: ["fluxbase", "storage", bucket, "list"]
442
+ });
416
443
  }
417
444
  });
418
445
  }
@@ -429,7 +456,9 @@ function useStorageCopy(bucket) {
429
456
  return data;
430
457
  },
431
458
  onSuccess: () => {
432
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
459
+ queryClient.invalidateQueries({
460
+ queryKey: ["fluxbase", "storage", bucket, "list"]
461
+ });
433
462
  }
434
463
  });
435
464
  }
@@ -457,7 +486,9 @@ function useCreateBucket() {
457
486
  }
458
487
  },
459
488
  onSuccess: () => {
460
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", "buckets"] });
489
+ queryClient.invalidateQueries({
490
+ queryKey: ["fluxbase", "storage", "buckets"]
491
+ });
461
492
  }
462
493
  });
463
494
  }
@@ -472,7 +503,9 @@ function useDeleteBucket() {
472
503
  }
473
504
  },
474
505
  onSuccess: () => {
475
- queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", "buckets"] });
506
+ queryClient.invalidateQueries({
507
+ queryKey: ["fluxbase", "storage", "buckets"]
508
+ });
476
509
  }
477
510
  });
478
511
  }
@@ -527,13 +560,13 @@ function useRPCBatch(calls, options) {
527
560
  }
528
561
 
529
562
  // src/use-admin-auth.ts
530
- import { useState, useEffect as useEffect2, useCallback } from "react";
563
+ import { useState as useState2, useEffect as useEffect2, useCallback } from "react";
531
564
  function useAdminAuth(options = {}) {
532
565
  const { autoCheck = true } = options;
533
566
  const client = useFluxbaseClient();
534
- const [user, setUser] = useState(null);
535
- const [isLoading, setIsLoading] = useState(autoCheck);
536
- const [error, setError] = useState(null);
567
+ const [user, setUser] = useState2(null);
568
+ const [isLoading, setIsLoading] = useState2(autoCheck);
569
+ const [error, setError] = useState2(null);
537
570
  const checkAuth = useCallback(async () => {
538
571
  try {
539
572
  setIsLoading(true);
@@ -605,14 +638,14 @@ function useAdminAuth(options = {}) {
605
638
  }
606
639
 
607
640
  // src/use-users.ts
608
- import { useState as useState2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
641
+ import { useState as useState3, useEffect as useEffect3, useCallback as useCallback2 } from "react";
609
642
  function useUsers(options = {}) {
610
643
  const { autoFetch = true, refetchInterval = 0, ...listOptions } = options;
611
644
  const client = useFluxbaseClient();
612
- const [users, setUsers] = useState2([]);
613
- const [total, setTotal] = useState2(0);
614
- const [isLoading, setIsLoading] = useState2(autoFetch);
615
- const [error, setError] = useState2(null);
645
+ const [users, setUsers] = useState3([]);
646
+ const [total, setTotal] = useState3(0);
647
+ const [isLoading, setIsLoading] = useState3(autoFetch);
648
+ const [error, setError] = useState3(null);
616
649
  const fetchUsers = useCallback2(async () => {
617
650
  try {
618
651
  setIsLoading(true);
@@ -685,13 +718,13 @@ function useUsers(options = {}) {
685
718
  }
686
719
 
687
720
  // src/use-api-keys.ts
688
- import { useState as useState3, useEffect as useEffect4, useCallback as useCallback3 } from "react";
721
+ import { useState as useState4, useEffect as useEffect4, useCallback as useCallback3 } from "react";
689
722
  function useAPIKeys(options = {}) {
690
723
  const { autoFetch = true } = options;
691
724
  const client = useFluxbaseClient();
692
- const [keys, setKeys] = useState3([]);
693
- const [isLoading, setIsLoading] = useState3(autoFetch);
694
- const [error, setError] = useState3(null);
725
+ const [keys, setKeys] = useState4([]);
726
+ const [isLoading, setIsLoading] = useState4(autoFetch);
727
+ const [error, setError] = useState4(null);
695
728
  const fetchKeys = useCallback3(async () => {
696
729
  try {
697
730
  setIsLoading(true);
@@ -751,13 +784,13 @@ function useAPIKeys(options = {}) {
751
784
  }
752
785
 
753
786
  // src/use-admin-hooks.ts
754
- import { useState as useState4, useEffect as useEffect5, useCallback as useCallback4 } from "react";
787
+ import { useState as useState5, useEffect as useEffect5, useCallback as useCallback4 } from "react";
755
788
  function useAppSettings(options = {}) {
756
789
  const { autoFetch = true } = options;
757
790
  const client = useFluxbaseClient();
758
- const [settings, setSettings] = useState4(null);
759
- const [isLoading, setIsLoading] = useState4(autoFetch);
760
- const [error, setError] = useState4(null);
791
+ const [settings, setSettings] = useState5(null);
792
+ const [isLoading, setIsLoading] = useState5(autoFetch);
793
+ const [error, setError] = useState5(null);
761
794
  const fetchSettings = useCallback4(async () => {
762
795
  try {
763
796
  setIsLoading(true);
@@ -793,9 +826,9 @@ function useAppSettings(options = {}) {
793
826
  function useSystemSettings(options = {}) {
794
827
  const { autoFetch = true } = options;
795
828
  const client = useFluxbaseClient();
796
- const [settings, setSettings] = useState4([]);
797
- const [isLoading, setIsLoading] = useState4(autoFetch);
798
- const [error, setError] = useState4(null);
829
+ const [settings, setSettings] = useState5([]);
830
+ const [isLoading, setIsLoading] = useState5(autoFetch);
831
+ const [error, setError] = useState5(null);
799
832
  const fetchSettings = useCallback4(async () => {
800
833
  try {
801
834
  setIsLoading(true);
@@ -846,9 +879,9 @@ function useSystemSettings(options = {}) {
846
879
  function useWebhooks(options = {}) {
847
880
  const { autoFetch = true, refetchInterval = 0 } = options;
848
881
  const client = useFluxbaseClient();
849
- const [webhooks, setWebhooks] = useState4([]);
850
- const [isLoading, setIsLoading] = useState4(autoFetch);
851
- const [error, setError] = useState4(null);
882
+ const [webhooks, setWebhooks] = useState5([]);
883
+ const [isLoading, setIsLoading] = useState5(autoFetch);
884
+ const [error, setError] = useState5(null);
852
885
  const fetchWebhooks = useCallback4(async () => {
853
886
  try {
854
887
  setIsLoading(true);