@fluxbase/sdk-react 2026.2.8 → 2026.3.2-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +2 -2
- package/src/test-utils.tsx +2 -2
- package/dist/index.d.mts +0 -1457
- package/dist/index.d.ts +0 -1457
- package/dist/index.js +0 -1637
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1554
- package/dist/index.mjs.map +0 -1
package/dist/index.d.mts
DELETED
|
@@ -1,1457 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import * as _fluxbase_sdk from '@fluxbase/sdk';
|
|
4
|
-
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLLoginOptions, SAMLProvider, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, SignedUrlOptions, TransformOptions, UploadOptions, UploadProgress, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest, CreateTableExportSyncConfig, TableExportSyncConfig, ExportTableOptions, ExportTableResult, TableDetails, UpdateTableExportSyncConfig } from '@fluxbase/sdk';
|
|
5
|
-
export { APIKey, AdminUser, AppSettings, AuthSession, CaptchaConfig, CaptchaProvider, ClientKey, EnrichedUser, FluxbaseClient, GraphQLError, GraphQLErrorLocation, GraphQLRequestOptions, GraphQLResponse, ImageFitMode, ImageFormat, PostgrestResponse, RealtimeChangePayload, SAMLLoginOptions, SAMLLoginResponse, SAMLProvider, SAMLProvidersResponse, SAMLSession, SignInCredentials, SignUpCredentials, SignedUrlOptions, StorageObject, SystemSetting, TransformOptions, User, Webhook } from '@fluxbase/sdk';
|
|
6
|
-
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
-
import { UseQueryOptions } from '@tanstack/react-query';
|
|
8
|
-
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
9
|
-
|
|
10
|
-
interface FluxbaseProviderProps {
|
|
11
|
-
client: FluxbaseClient;
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Provider component to make Fluxbase client available throughout the app
|
|
16
|
-
*/
|
|
17
|
-
declare function FluxbaseProvider({ client, children }: FluxbaseProviderProps): react_jsx_runtime.JSX.Element;
|
|
18
|
-
/**
|
|
19
|
-
* Hook to access the Fluxbase client from context
|
|
20
|
-
*/
|
|
21
|
-
declare function useFluxbaseClient(): FluxbaseClient;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Hook to get the current user
|
|
25
|
-
*/
|
|
26
|
-
declare function useUser(): _tanstack_react_query.UseQueryResult<User | null, Error>;
|
|
27
|
-
/**
|
|
28
|
-
* Hook to get the current session
|
|
29
|
-
*/
|
|
30
|
-
declare function useSession(): _tanstack_react_query.UseQueryResult<AuthSession | null, Error>;
|
|
31
|
-
/**
|
|
32
|
-
* Hook for signing in
|
|
33
|
-
*/
|
|
34
|
-
declare function useSignIn(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseResponse<_fluxbase_sdk.AuthResponseData | _fluxbase_sdk.SignInWith2FAResponse>, Error, SignInCredentials, unknown>;
|
|
35
|
-
/**
|
|
36
|
-
* Hook for signing up
|
|
37
|
-
*/
|
|
38
|
-
declare function useSignUp(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseAuthResponse, Error, SignUpCredentials, unknown>;
|
|
39
|
-
/**
|
|
40
|
-
* Hook for signing out
|
|
41
|
-
*/
|
|
42
|
-
declare function useSignOut(): _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
|
|
43
|
-
/**
|
|
44
|
-
* Hook for updating the current user
|
|
45
|
-
*/
|
|
46
|
-
declare function useUpdateUser(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.UserResponse, Error, Partial<Pick<User, "email" | "metadata">>, unknown>;
|
|
47
|
-
/**
|
|
48
|
-
* Combined auth hook with all auth state and methods
|
|
49
|
-
*/
|
|
50
|
-
declare function useAuth(): {
|
|
51
|
-
user: User | null | undefined;
|
|
52
|
-
session: AuthSession | null | undefined;
|
|
53
|
-
isLoading: boolean;
|
|
54
|
-
isAuthenticated: boolean;
|
|
55
|
-
signIn: _tanstack_react_query.UseMutateAsyncFunction<_fluxbase_sdk.FluxbaseResponse<_fluxbase_sdk.AuthResponseData | _fluxbase_sdk.SignInWith2FAResponse>, Error, SignInCredentials, unknown>;
|
|
56
|
-
signUp: _tanstack_react_query.UseMutateAsyncFunction<_fluxbase_sdk.FluxbaseAuthResponse, Error, SignUpCredentials, unknown>;
|
|
57
|
-
signOut: _tanstack_react_query.UseMutateAsyncFunction<void, Error, void, unknown>;
|
|
58
|
-
updateUser: _tanstack_react_query.UseMutateAsyncFunction<_fluxbase_sdk.UserResponse, Error, Partial<Pick<User, "email" | "metadata">>, unknown>;
|
|
59
|
-
isSigningIn: boolean;
|
|
60
|
-
isSigningUp: boolean;
|
|
61
|
-
isSigningOut: boolean;
|
|
62
|
-
isUpdating: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Hook to get the CAPTCHA configuration from the server
|
|
67
|
-
* Use this to determine which CAPTCHA provider to load
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```tsx
|
|
71
|
-
* function AuthPage() {
|
|
72
|
-
* const { data: captchaConfig, isLoading } = useCaptchaConfig();
|
|
73
|
-
*
|
|
74
|
-
* if (isLoading) return <Loading />;
|
|
75
|
-
*
|
|
76
|
-
* return captchaConfig?.enabled ? (
|
|
77
|
-
* <CaptchaWidget provider={captchaConfig.provider} siteKey={captchaConfig.site_key} />
|
|
78
|
-
* ) : null;
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
declare function useCaptchaConfig(): _tanstack_react_query.UseQueryResult<CaptchaConfig, Error>;
|
|
83
|
-
/**
|
|
84
|
-
* CAPTCHA widget state for managing token generation
|
|
85
|
-
*/
|
|
86
|
-
interface CaptchaState {
|
|
87
|
-
/** Current CAPTCHA token (null until solved) */
|
|
88
|
-
token: string | null;
|
|
89
|
-
/** Whether the CAPTCHA widget is ready */
|
|
90
|
-
isReady: boolean;
|
|
91
|
-
/** Whether a token is being generated */
|
|
92
|
-
isLoading: boolean;
|
|
93
|
-
/** Any error that occurred */
|
|
94
|
-
error: Error | null;
|
|
95
|
-
/** Reset the CAPTCHA widget */
|
|
96
|
-
reset: () => void;
|
|
97
|
-
/** Execute/trigger the CAPTCHA (for invisible CAPTCHA like reCAPTCHA v3) */
|
|
98
|
-
execute: () => Promise<string>;
|
|
99
|
-
/** Callback to be called when CAPTCHA is verified */
|
|
100
|
-
onVerify: (token: string) => void;
|
|
101
|
-
/** Callback to be called when CAPTCHA expires */
|
|
102
|
-
onExpire: () => void;
|
|
103
|
-
/** Callback to be called when CAPTCHA errors */
|
|
104
|
-
onError: (error: Error) => void;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Hook to manage CAPTCHA widget state
|
|
108
|
-
*
|
|
109
|
-
* This hook provides a standardized interface for managing CAPTCHA tokens
|
|
110
|
-
* across different providers (hCaptcha, reCAPTCHA v3, Turnstile, Cap).
|
|
111
|
-
*
|
|
112
|
-
* Supported providers:
|
|
113
|
-
* - hcaptcha: Privacy-focused visual challenge
|
|
114
|
-
* - recaptcha_v3: Google's invisible risk-based CAPTCHA
|
|
115
|
-
* - turnstile: Cloudflare's invisible CAPTCHA
|
|
116
|
-
* - cap: Self-hosted proof-of-work CAPTCHA (https://capjs.js.org/)
|
|
117
|
-
*
|
|
118
|
-
* @param provider - The CAPTCHA provider type
|
|
119
|
-
* @returns CAPTCHA state and callbacks
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```tsx
|
|
123
|
-
* function LoginForm() {
|
|
124
|
-
* const captcha = useCaptcha('hcaptcha');
|
|
125
|
-
*
|
|
126
|
-
* const handleSubmit = async (e: FormEvent) => {
|
|
127
|
-
* e.preventDefault();
|
|
128
|
-
*
|
|
129
|
-
* // Get CAPTCHA token
|
|
130
|
-
* const captchaToken = captcha.token || await captcha.execute();
|
|
131
|
-
*
|
|
132
|
-
* // Sign in with CAPTCHA token
|
|
133
|
-
* await signIn({
|
|
134
|
-
* email,
|
|
135
|
-
* password,
|
|
136
|
-
* captchaToken
|
|
137
|
-
* });
|
|
138
|
-
* };
|
|
139
|
-
*
|
|
140
|
-
* return (
|
|
141
|
-
* <form onSubmit={handleSubmit}>
|
|
142
|
-
* <input name="email" />
|
|
143
|
-
* <input name="password" type="password" />
|
|
144
|
-
*
|
|
145
|
-
* <HCaptcha
|
|
146
|
-
* sitekey={siteKey}
|
|
147
|
-
* onVerify={captcha.onVerify}
|
|
148
|
-
* onExpire={captcha.onExpire}
|
|
149
|
-
* onError={captcha.onError}
|
|
150
|
-
* />
|
|
151
|
-
*
|
|
152
|
-
* <button type="submit" disabled={!captcha.isReady}>
|
|
153
|
-
* Sign In
|
|
154
|
-
* </button>
|
|
155
|
-
* </form>
|
|
156
|
-
* );
|
|
157
|
-
* }
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @example Cap provider
|
|
161
|
-
* ```tsx
|
|
162
|
-
* function LoginForm() {
|
|
163
|
-
* const { data: config } = useCaptchaConfig();
|
|
164
|
-
* const captcha = useCaptcha(config?.provider);
|
|
165
|
-
*
|
|
166
|
-
* // For Cap, load the widget from cap_server_url
|
|
167
|
-
* // <script src={`${config.cap_server_url}/widget.js`} />
|
|
168
|
-
* // <cap-widget data-cap-url={config.cap_server_url} />
|
|
169
|
-
* }
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
declare function useCaptcha(provider?: CaptchaProvider): CaptchaState;
|
|
173
|
-
/**
|
|
174
|
-
* Check if CAPTCHA is required for a specific endpoint
|
|
175
|
-
*
|
|
176
|
-
* @param config - CAPTCHA configuration from useCaptchaConfig
|
|
177
|
-
* @param endpoint - The endpoint to check (e.g., 'signup', 'login', 'password_reset')
|
|
178
|
-
* @returns Whether CAPTCHA is required for this endpoint
|
|
179
|
-
*/
|
|
180
|
-
declare function isCaptchaRequiredForEndpoint(config: CaptchaConfig | undefined, endpoint: string): boolean;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Hook to get the complete authentication configuration from the server
|
|
184
|
-
*
|
|
185
|
-
* Returns all public auth settings in a single request including:
|
|
186
|
-
* - Signup enabled status
|
|
187
|
-
* - Email verification requirements
|
|
188
|
-
* - Magic link availability
|
|
189
|
-
* - MFA availability
|
|
190
|
-
* - Password requirements (length, complexity)
|
|
191
|
-
* - Available OAuth providers (Google, GitHub, etc.)
|
|
192
|
-
* - Available SAML providers (enterprise SSO)
|
|
193
|
-
* - CAPTCHA configuration
|
|
194
|
-
*
|
|
195
|
-
* Use this to conditionally render UI elements based on server configuration,
|
|
196
|
-
* such as hiding signup forms when signup is disabled or displaying available
|
|
197
|
-
* OAuth provider buttons.
|
|
198
|
-
*
|
|
199
|
-
* @returns Query result with authentication configuration
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```tsx
|
|
203
|
-
* function AuthPage() {
|
|
204
|
-
* const { data: config, isLoading } = useAuthConfig();
|
|
205
|
-
*
|
|
206
|
-
* if (isLoading) return <Loading />;
|
|
207
|
-
*
|
|
208
|
-
* return (
|
|
209
|
-
* <div>
|
|
210
|
-
* {config?.signup_enabled && (
|
|
211
|
-
* <SignupForm passwordMinLength={config.password_min_length} />
|
|
212
|
-
* )}
|
|
213
|
-
*
|
|
214
|
-
* {config?.oauth_providers.map(provider => (
|
|
215
|
-
* <OAuthButton
|
|
216
|
-
* key={provider.provider}
|
|
217
|
-
* provider={provider.provider}
|
|
218
|
-
* displayName={provider.display_name}
|
|
219
|
-
* authorizeUrl={provider.authorize_url}
|
|
220
|
-
* />
|
|
221
|
-
* ))}
|
|
222
|
-
*
|
|
223
|
-
* {config?.saml_providers.map(provider => (
|
|
224
|
-
* <SAMLButton
|
|
225
|
-
* key={provider.provider}
|
|
226
|
-
* provider={provider.provider}
|
|
227
|
-
* displayName={provider.display_name}
|
|
228
|
-
* />
|
|
229
|
-
* ))}
|
|
230
|
-
* </div>
|
|
231
|
-
* );
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* @example Showing password requirements
|
|
236
|
-
* ```tsx
|
|
237
|
-
* function PasswordInput() {
|
|
238
|
-
* const { data: config } = useAuthConfig();
|
|
239
|
-
*
|
|
240
|
-
* return (
|
|
241
|
-
* <div>
|
|
242
|
-
* <input type="password" minLength={config?.password_min_length} />
|
|
243
|
-
* <ul>
|
|
244
|
-
* <li>Minimum {config?.password_min_length || 8} characters</li>
|
|
245
|
-
* {config?.password_require_uppercase && <li>One uppercase letter</li>}
|
|
246
|
-
* {config?.password_require_lowercase && <li>One lowercase letter</li>}
|
|
247
|
-
* {config?.password_require_number && <li>One number</li>}
|
|
248
|
-
* {config?.password_require_special && <li>One special character</li>}
|
|
249
|
-
* </ul>
|
|
250
|
-
* </div>
|
|
251
|
-
* );
|
|
252
|
-
* }
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
|
-
declare function useAuthConfig(): _tanstack_react_query.UseQueryResult<AuthConfig, Error>;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Hook to get available SAML SSO providers
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```tsx
|
|
262
|
-
* function SAMLProviderList() {
|
|
263
|
-
* const { data: providers, isLoading } = useSAMLProviders()
|
|
264
|
-
*
|
|
265
|
-
* if (isLoading) return <div>Loading...</div>
|
|
266
|
-
*
|
|
267
|
-
* return (
|
|
268
|
-
* <div>
|
|
269
|
-
* {providers?.map(provider => (
|
|
270
|
-
* <button key={provider.id} onClick={() => signInWithSAML(provider.name)}>
|
|
271
|
-
* Sign in with {provider.name}
|
|
272
|
-
* </button>
|
|
273
|
-
* ))}
|
|
274
|
-
* </div>
|
|
275
|
-
* )
|
|
276
|
-
* }
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
declare function useSAMLProviders(): _tanstack_react_query.UseQueryResult<SAMLProvider[], Error>;
|
|
280
|
-
/**
|
|
281
|
-
* Hook to get SAML login URL for a provider
|
|
282
|
-
*
|
|
283
|
-
* This hook returns a function to get the login URL for a specific provider.
|
|
284
|
-
* Use this when you need more control over the redirect behavior.
|
|
285
|
-
*
|
|
286
|
-
* @example
|
|
287
|
-
* ```tsx
|
|
288
|
-
* function SAMLLoginButton({ provider }: { provider: string }) {
|
|
289
|
-
* const getSAMLLoginUrl = useGetSAMLLoginUrl()
|
|
290
|
-
*
|
|
291
|
-
* const handleClick = async () => {
|
|
292
|
-
* const { data, error } = await getSAMLLoginUrl.mutateAsync({
|
|
293
|
-
* provider,
|
|
294
|
-
* options: { redirectUrl: window.location.href }
|
|
295
|
-
* })
|
|
296
|
-
* if (!error) {
|
|
297
|
-
* window.location.href = data.url
|
|
298
|
-
* }
|
|
299
|
-
* }
|
|
300
|
-
*
|
|
301
|
-
* return <button onClick={handleClick}>Login with {provider}</button>
|
|
302
|
-
* }
|
|
303
|
-
* ```
|
|
304
|
-
*/
|
|
305
|
-
declare function useGetSAMLLoginUrl(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.DataResponse<_fluxbase_sdk.SAMLLoginResponse>, Error, {
|
|
306
|
-
provider: string;
|
|
307
|
-
options?: SAMLLoginOptions;
|
|
308
|
-
}, unknown>;
|
|
309
|
-
/**
|
|
310
|
-
* Hook to initiate SAML login (redirects to IdP)
|
|
311
|
-
*
|
|
312
|
-
* This hook returns a mutation that when called, redirects the user to the
|
|
313
|
-
* SAML Identity Provider for authentication.
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```tsx
|
|
317
|
-
* function SAMLLoginButton() {
|
|
318
|
-
* const signInWithSAML = useSignInWithSAML()
|
|
319
|
-
*
|
|
320
|
-
* return (
|
|
321
|
-
* <button
|
|
322
|
-
* onClick={() => signInWithSAML.mutate({ provider: 'okta' })}
|
|
323
|
-
* disabled={signInWithSAML.isPending}
|
|
324
|
-
* >
|
|
325
|
-
* {signInWithSAML.isPending ? 'Redirecting...' : 'Sign in with Okta'}
|
|
326
|
-
* </button>
|
|
327
|
-
* )
|
|
328
|
-
* }
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
declare function useSignInWithSAML(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.DataResponse<{
|
|
332
|
-
provider: string;
|
|
333
|
-
url: string;
|
|
334
|
-
}>, Error, {
|
|
335
|
-
provider: string;
|
|
336
|
-
options?: SAMLLoginOptions;
|
|
337
|
-
}, unknown>;
|
|
338
|
-
/**
|
|
339
|
-
* Hook to handle SAML callback after IdP authentication
|
|
340
|
-
*
|
|
341
|
-
* Use this in your SAML callback page to complete the authentication flow.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
* ```tsx
|
|
345
|
-
* function SAMLCallbackPage() {
|
|
346
|
-
* const handleCallback = useHandleSAMLCallback()
|
|
347
|
-
* const navigate = useNavigate()
|
|
348
|
-
*
|
|
349
|
-
* useEffect(() => {
|
|
350
|
-
* const params = new URLSearchParams(window.location.search)
|
|
351
|
-
* const samlResponse = params.get('SAMLResponse')
|
|
352
|
-
*
|
|
353
|
-
* if (samlResponse) {
|
|
354
|
-
* handleCallback.mutate(
|
|
355
|
-
* { samlResponse },
|
|
356
|
-
* {
|
|
357
|
-
* onSuccess: () => navigate('/dashboard'),
|
|
358
|
-
* onError: (error) => console.error('SAML login failed:', error)
|
|
359
|
-
* }
|
|
360
|
-
* )
|
|
361
|
-
* }
|
|
362
|
-
* }, [])
|
|
363
|
-
*
|
|
364
|
-
* if (handleCallback.isPending) {
|
|
365
|
-
* return <div>Completing sign in...</div>
|
|
366
|
-
* }
|
|
367
|
-
*
|
|
368
|
-
* if (handleCallback.isError) {
|
|
369
|
-
* return <div>Authentication failed: {handleCallback.error.message}</div>
|
|
370
|
-
* }
|
|
371
|
-
*
|
|
372
|
-
* return null
|
|
373
|
-
* }
|
|
374
|
-
* ```
|
|
375
|
-
*/
|
|
376
|
-
declare function useHandleSAMLCallback(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseAuthResponse, Error, {
|
|
377
|
-
samlResponse: string;
|
|
378
|
-
provider?: string;
|
|
379
|
-
}, unknown>;
|
|
380
|
-
/**
|
|
381
|
-
* Hook to get SAML Service Provider metadata URL
|
|
382
|
-
*
|
|
383
|
-
* Returns a function that generates the SP metadata URL for a given provider.
|
|
384
|
-
* Use this URL when configuring your SAML IdP.
|
|
385
|
-
*
|
|
386
|
-
* @example
|
|
387
|
-
* ```tsx
|
|
388
|
-
* function SAMLSetupInfo({ provider }: { provider: string }) {
|
|
389
|
-
* const getSAMLMetadataUrl = useSAMLMetadataUrl()
|
|
390
|
-
* const metadataUrl = getSAMLMetadataUrl(provider)
|
|
391
|
-
*
|
|
392
|
-
* return (
|
|
393
|
-
* <div>
|
|
394
|
-
* <p>SP Metadata URL:</p>
|
|
395
|
-
* <code>{metadataUrl}</code>
|
|
396
|
-
* </div>
|
|
397
|
-
* )
|
|
398
|
-
* }
|
|
399
|
-
* ```
|
|
400
|
-
*/
|
|
401
|
-
declare function useSAMLMetadataUrl(): (provider: string) => string;
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Options for useGraphQLQuery hook
|
|
405
|
-
*/
|
|
406
|
-
interface UseGraphQLQueryOptions<T> {
|
|
407
|
-
/**
|
|
408
|
-
* Variables to pass to the GraphQL query
|
|
409
|
-
*/
|
|
410
|
-
variables?: Record<string, unknown>;
|
|
411
|
-
/**
|
|
412
|
-
* Operation name when the document contains multiple operations
|
|
413
|
-
*/
|
|
414
|
-
operationName?: string;
|
|
415
|
-
/**
|
|
416
|
-
* Additional request options
|
|
417
|
-
*/
|
|
418
|
-
requestOptions?: GraphQLRequestOptions;
|
|
419
|
-
/**
|
|
420
|
-
* Whether the query is enabled
|
|
421
|
-
* @default true
|
|
422
|
-
*/
|
|
423
|
-
enabled?: boolean;
|
|
424
|
-
/**
|
|
425
|
-
* Time in milliseconds after which the query is considered stale
|
|
426
|
-
* @default 0 (considered stale immediately)
|
|
427
|
-
*/
|
|
428
|
-
staleTime?: number;
|
|
429
|
-
/**
|
|
430
|
-
* Time in milliseconds after which inactive query data is garbage collected
|
|
431
|
-
* @default 5 minutes
|
|
432
|
-
*/
|
|
433
|
-
gcTime?: number;
|
|
434
|
-
/**
|
|
435
|
-
* Whether to refetch on window focus
|
|
436
|
-
* @default true
|
|
437
|
-
*/
|
|
438
|
-
refetchOnWindowFocus?: boolean;
|
|
439
|
-
/**
|
|
440
|
-
* Transform function to process the response data
|
|
441
|
-
*/
|
|
442
|
-
select?: (data: T | undefined) => T | undefined;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Options for useGraphQLMutation hook
|
|
446
|
-
*/
|
|
447
|
-
interface UseGraphQLMutationOptions<T, V> {
|
|
448
|
-
/**
|
|
449
|
-
* Operation name when the document contains multiple operations
|
|
450
|
-
*/
|
|
451
|
-
operationName?: string;
|
|
452
|
-
/**
|
|
453
|
-
* Additional request options
|
|
454
|
-
*/
|
|
455
|
-
requestOptions?: GraphQLRequestOptions;
|
|
456
|
-
/**
|
|
457
|
-
* Callback when mutation succeeds
|
|
458
|
-
*/
|
|
459
|
-
onSuccess?: (data: T, variables: V) => void;
|
|
460
|
-
/**
|
|
461
|
-
* Callback when mutation fails
|
|
462
|
-
*/
|
|
463
|
-
onError?: (error: GraphQLError, variables: V) => void;
|
|
464
|
-
/**
|
|
465
|
-
* Query keys to invalidate on success
|
|
466
|
-
*/
|
|
467
|
-
invalidateQueries?: string[];
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Hook to execute GraphQL queries with React Query caching
|
|
471
|
-
*
|
|
472
|
-
* @typeParam T - The expected response data type
|
|
473
|
-
* @param queryKey - Unique key for caching (string or array)
|
|
474
|
-
* @param query - The GraphQL query string
|
|
475
|
-
* @param options - Query options including variables
|
|
476
|
-
* @returns React Query result object
|
|
477
|
-
*
|
|
478
|
-
* @example
|
|
479
|
-
* ```tsx
|
|
480
|
-
* interface UsersQuery {
|
|
481
|
-
* users: Array<{ id: string; email: string }>
|
|
482
|
-
* }
|
|
483
|
-
*
|
|
484
|
-
* function UsersList() {
|
|
485
|
-
* const { data, isLoading } = useGraphQLQuery<UsersQuery>(
|
|
486
|
-
* 'users',
|
|
487
|
-
* `query { users { id email } }`
|
|
488
|
-
* )
|
|
489
|
-
*
|
|
490
|
-
* return <div>{data?.users.length} users</div>
|
|
491
|
-
* }
|
|
492
|
-
* ```
|
|
493
|
-
*
|
|
494
|
-
* @example
|
|
495
|
-
* ```tsx
|
|
496
|
-
* // With variables
|
|
497
|
-
* const { data } = useGraphQLQuery<UserQuery>(
|
|
498
|
-
* ['user', userId],
|
|
499
|
-
* `query GetUser($id: ID!) { user(id: $id) { id email } }`,
|
|
500
|
-
* { variables: { id: userId } }
|
|
501
|
-
* )
|
|
502
|
-
* ```
|
|
503
|
-
*/
|
|
504
|
-
declare function useGraphQLQuery<T = unknown>(queryKey: string | readonly unknown[], query: string, options?: UseGraphQLQueryOptions<T>): _tanstack_react_query.UseQueryResult<_tanstack_query_core.NoInfer<T | undefined>, GraphQLError>;
|
|
505
|
-
/**
|
|
506
|
-
* Hook to execute GraphQL mutations
|
|
507
|
-
*
|
|
508
|
-
* @typeParam T - The expected response data type
|
|
509
|
-
* @typeParam V - The variables type
|
|
510
|
-
* @param mutation - The GraphQL mutation string
|
|
511
|
-
* @param options - Mutation options
|
|
512
|
-
* @returns React Query mutation result object
|
|
513
|
-
*
|
|
514
|
-
* @example
|
|
515
|
-
* ```tsx
|
|
516
|
-
* interface CreateUserMutation {
|
|
517
|
-
* insertUser: { id: string; email: string }
|
|
518
|
-
* }
|
|
519
|
-
*
|
|
520
|
-
* interface CreateUserVariables {
|
|
521
|
-
* data: { email: string }
|
|
522
|
-
* }
|
|
523
|
-
*
|
|
524
|
-
* function CreateUserForm() {
|
|
525
|
-
* const mutation = useGraphQLMutation<CreateUserMutation, CreateUserVariables>(
|
|
526
|
-
* `mutation CreateUser($data: UserInput!) {
|
|
527
|
-
* insertUser(data: $data) { id email }
|
|
528
|
-
* }`,
|
|
529
|
-
* {
|
|
530
|
-
* onSuccess: (data) => console.log('Created:', data.insertUser),
|
|
531
|
-
* invalidateQueries: ['users']
|
|
532
|
-
* }
|
|
533
|
-
* )
|
|
534
|
-
*
|
|
535
|
-
* const handleSubmit = (email: string) => {
|
|
536
|
-
* mutation.mutate({ data: { email } })
|
|
537
|
-
* }
|
|
538
|
-
*
|
|
539
|
-
* return (
|
|
540
|
-
* <button
|
|
541
|
-
* onClick={() => handleSubmit('new@example.com')}
|
|
542
|
-
* disabled={mutation.isPending}
|
|
543
|
-
* >
|
|
544
|
-
* Create User
|
|
545
|
-
* </button>
|
|
546
|
-
* )
|
|
547
|
-
* }
|
|
548
|
-
* ```
|
|
549
|
-
*/
|
|
550
|
-
declare function useGraphQLMutation<T = unknown, V extends Record<string, unknown> = Record<string, unknown>>(mutation: string, options?: UseGraphQLMutationOptions<T, V>): _tanstack_react_query.UseMutationResult<T | undefined, GraphQLError, V, unknown>;
|
|
551
|
-
/**
|
|
552
|
-
* Hook to fetch the GraphQL schema via introspection
|
|
553
|
-
*
|
|
554
|
-
* @param options - Query options
|
|
555
|
-
* @returns React Query result with schema introspection data
|
|
556
|
-
*
|
|
557
|
-
* @example
|
|
558
|
-
* ```tsx
|
|
559
|
-
* function SchemaExplorer() {
|
|
560
|
-
* const { data, isLoading } = useGraphQLIntrospection()
|
|
561
|
-
*
|
|
562
|
-
* if (isLoading) return <div>Loading schema...</div>
|
|
563
|
-
*
|
|
564
|
-
* return (
|
|
565
|
-
* <div>
|
|
566
|
-
* <p>Query type: {data?.__schema.queryType.name}</p>
|
|
567
|
-
* <p>Types: {data?.__schema.types.length}</p>
|
|
568
|
-
* </div>
|
|
569
|
-
* )
|
|
570
|
-
* }
|
|
571
|
-
* ```
|
|
572
|
-
*/
|
|
573
|
-
declare function useGraphQLIntrospection(options?: {
|
|
574
|
-
enabled?: boolean;
|
|
575
|
-
staleTime?: number;
|
|
576
|
-
requestOptions?: GraphQLRequestOptions;
|
|
577
|
-
}): _tanstack_react_query.UseQueryResult<{
|
|
578
|
-
__schema: _fluxbase_sdk.IntrospectionSchema;
|
|
579
|
-
} | undefined, Error>;
|
|
580
|
-
/**
|
|
581
|
-
* Hook to execute raw GraphQL operations (query or mutation)
|
|
582
|
-
*
|
|
583
|
-
* This is a lower-level hook that doesn't use React Query caching.
|
|
584
|
-
* Useful for one-off operations or when you need full control.
|
|
585
|
-
*
|
|
586
|
-
* @returns Functions to execute queries and mutations
|
|
587
|
-
*
|
|
588
|
-
* @example
|
|
589
|
-
* ```tsx
|
|
590
|
-
* function AdminPanel() {
|
|
591
|
-
* const { executeQuery, executeMutation } = useGraphQL()
|
|
592
|
-
*
|
|
593
|
-
* const handleExport = async () => {
|
|
594
|
-
* const result = await executeQuery<ExportData>(
|
|
595
|
-
* `query { exportAllData { url } }`
|
|
596
|
-
* )
|
|
597
|
-
* if (result.data) {
|
|
598
|
-
* window.open(result.data.exportAllData.url)
|
|
599
|
-
* }
|
|
600
|
-
* }
|
|
601
|
-
*
|
|
602
|
-
* return <button onClick={handleExport}>Export Data</button>
|
|
603
|
-
* }
|
|
604
|
-
* ```
|
|
605
|
-
*/
|
|
606
|
-
declare function useGraphQL(): {
|
|
607
|
-
/**
|
|
608
|
-
* Execute a GraphQL query
|
|
609
|
-
*/
|
|
610
|
-
executeQuery: <T = unknown>(query: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
611
|
-
/**
|
|
612
|
-
* Execute a GraphQL mutation
|
|
613
|
-
*/
|
|
614
|
-
executeMutation: <T = unknown>(mutation: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
615
|
-
/**
|
|
616
|
-
* Execute a GraphQL operation with an explicit operation name
|
|
617
|
-
*/
|
|
618
|
-
execute: <T = unknown>(document: string, variables?: Record<string, unknown>, operationName?: string, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
619
|
-
/**
|
|
620
|
-
* Fetch the GraphQL schema via introspection
|
|
621
|
-
*/
|
|
622
|
-
introspect: (options?: GraphQLRequestOptions) => Promise<GraphQLResponse<{
|
|
623
|
-
__schema: _fluxbase_sdk.IntrospectionSchema;
|
|
624
|
-
}>>;
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
interface UseFluxbaseQueryOptions<T> extends Omit<UseQueryOptions<T[], Error>, 'queryKey' | 'queryFn'> {
|
|
628
|
-
/**
|
|
629
|
-
* Custom query key. If not provided, will use table name and filters.
|
|
630
|
-
*/
|
|
631
|
-
queryKey?: unknown[];
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Hook to execute a database query
|
|
635
|
-
* @param buildQuery - Function that builds and returns the query
|
|
636
|
-
* @param options - React Query options
|
|
637
|
-
*
|
|
638
|
-
* IMPORTANT: You must provide a stable `queryKey` in options for proper caching.
|
|
639
|
-
* Without a custom queryKey, each render may create a new cache entry.
|
|
640
|
-
*
|
|
641
|
-
* @example
|
|
642
|
-
* ```tsx
|
|
643
|
-
* // Always provide a queryKey for stable caching
|
|
644
|
-
* useFluxbaseQuery(
|
|
645
|
-
* (client) => client.from('users').select('*'),
|
|
646
|
-
* { queryKey: ['users', 'all'] }
|
|
647
|
-
* )
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
declare function useFluxbaseQuery<T = any>(buildQuery: (client: ReturnType<typeof useFluxbaseClient>) => QueryBuilder<T>, options?: UseFluxbaseQueryOptions<T>): _tanstack_react_query.UseQueryResult<T[], Error>;
|
|
651
|
-
/**
|
|
652
|
-
* Hook for table queries with a simpler API
|
|
653
|
-
* @param table - Table name
|
|
654
|
-
* @param buildQuery - Optional function to build the query (e.g., add filters)
|
|
655
|
-
* @param options - Query options including a stable queryKey
|
|
656
|
-
*
|
|
657
|
-
* NOTE: When using buildQuery with filters, provide a custom queryKey that includes
|
|
658
|
-
* the filter values to ensure proper caching.
|
|
659
|
-
*
|
|
660
|
-
* @example
|
|
661
|
-
* ```tsx
|
|
662
|
-
* // Simple query - queryKey is auto-generated from table name
|
|
663
|
-
* useTable('users')
|
|
664
|
-
*
|
|
665
|
-
* // With filters - provide queryKey including filter values
|
|
666
|
-
* useTable('users',
|
|
667
|
-
* (q) => q.eq('status', 'active'),
|
|
668
|
-
* { queryKey: ['users', 'active'] }
|
|
669
|
-
* )
|
|
670
|
-
* ```
|
|
671
|
-
*/
|
|
672
|
-
declare function useTable<T = any>(table: string, buildQuery?: (query: QueryBuilder<T>) => QueryBuilder<T>, options?: UseFluxbaseQueryOptions<T>): _tanstack_react_query.UseQueryResult<T[], Error>;
|
|
673
|
-
/**
|
|
674
|
-
* Hook to insert data into a table
|
|
675
|
-
*/
|
|
676
|
-
declare function useInsert<T = any>(table: string): _tanstack_react_query.UseMutationResult<T | null, Error, Partial<T> | Partial<T>[], unknown>;
|
|
677
|
-
/**
|
|
678
|
-
* Hook to update data in a table
|
|
679
|
-
*/
|
|
680
|
-
declare function useUpdate<T = any>(table: string): _tanstack_react_query.UseMutationResult<T | null, Error, {
|
|
681
|
-
data: Partial<T>;
|
|
682
|
-
buildQuery: (query: QueryBuilder<T>) => QueryBuilder<T>;
|
|
683
|
-
}, unknown>;
|
|
684
|
-
/**
|
|
685
|
-
* Hook to upsert data into a table
|
|
686
|
-
*/
|
|
687
|
-
declare function useUpsert<T = any>(table: string): _tanstack_react_query.UseMutationResult<T | null, Error, Partial<T> | Partial<T>[], unknown>;
|
|
688
|
-
/**
|
|
689
|
-
* Hook to delete data from a table
|
|
690
|
-
*/
|
|
691
|
-
declare function useDelete<T = any>(table: string): _tanstack_react_query.UseMutationResult<void, Error, (query: QueryBuilder<T>) => QueryBuilder<T>, unknown>;
|
|
692
|
-
|
|
693
|
-
interface UseRealtimeOptions {
|
|
694
|
-
/**
|
|
695
|
-
* The channel name (e.g., 'table:public.products')
|
|
696
|
-
*/
|
|
697
|
-
channel: string;
|
|
698
|
-
/**
|
|
699
|
-
* Event type to listen for ('INSERT', 'UPDATE', 'DELETE', or '*' for all)
|
|
700
|
-
*/
|
|
701
|
-
event?: "INSERT" | "UPDATE" | "DELETE" | "*";
|
|
702
|
-
/**
|
|
703
|
-
* Callback function when an event is received
|
|
704
|
-
*/
|
|
705
|
-
callback?: RealtimeCallback;
|
|
706
|
-
/**
|
|
707
|
-
* Whether to automatically invalidate queries for the table
|
|
708
|
-
* Default: true
|
|
709
|
-
*/
|
|
710
|
-
autoInvalidate?: boolean;
|
|
711
|
-
/**
|
|
712
|
-
* Custom query key to invalidate (if autoInvalidate is true)
|
|
713
|
-
* Default: ['fluxbase', 'table', tableName]
|
|
714
|
-
*/
|
|
715
|
-
invalidateKey?: unknown[];
|
|
716
|
-
/**
|
|
717
|
-
* Whether the subscription is enabled
|
|
718
|
-
* Default: true
|
|
719
|
-
*/
|
|
720
|
-
enabled?: boolean;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Hook to subscribe to realtime changes for a channel
|
|
724
|
-
*
|
|
725
|
-
* NOTE: The callback and invalidateKey are stored in refs to prevent
|
|
726
|
-
* subscription recreation on every render when inline functions/arrays are used.
|
|
727
|
-
*/
|
|
728
|
-
declare function useRealtime(options: UseRealtimeOptions): {
|
|
729
|
-
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
730
|
-
};
|
|
731
|
-
/**
|
|
732
|
-
* Hook to subscribe to a table's changes
|
|
733
|
-
* @param table - Table name (with optional schema, e.g., 'public.products')
|
|
734
|
-
* @param options - Subscription options
|
|
735
|
-
*/
|
|
736
|
-
declare function useTableSubscription(table: string, options?: Omit<UseRealtimeOptions, "channel">): {
|
|
737
|
-
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
738
|
-
};
|
|
739
|
-
/**
|
|
740
|
-
* Hook to subscribe to INSERT events on a table
|
|
741
|
-
*/
|
|
742
|
-
declare function useTableInserts(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
743
|
-
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
744
|
-
};
|
|
745
|
-
/**
|
|
746
|
-
* Hook to subscribe to UPDATE events on a table
|
|
747
|
-
*/
|
|
748
|
-
declare function useTableUpdates(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
749
|
-
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
750
|
-
};
|
|
751
|
-
/**
|
|
752
|
-
* Hook to subscribe to DELETE events on a table
|
|
753
|
-
*/
|
|
754
|
-
declare function useTableDeletes(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
755
|
-
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* Hook to list files in a bucket
|
|
760
|
-
*/
|
|
761
|
-
declare function useStorageList(bucket: string, options?: ListOptions & Omit<UseQueryOptions<any[], Error>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<any[], Error>;
|
|
762
|
-
/**
|
|
763
|
-
* Hook to upload a file to a bucket
|
|
764
|
-
*
|
|
765
|
-
* Note: You can track upload progress by passing an `onUploadProgress` callback in the options:
|
|
766
|
-
*
|
|
767
|
-
* @example
|
|
768
|
-
* ```tsx
|
|
769
|
-
* const upload = useStorageUpload('avatars')
|
|
770
|
-
*
|
|
771
|
-
* upload.mutate({
|
|
772
|
-
* path: 'user.jpg',
|
|
773
|
-
* file: file,
|
|
774
|
-
* options: {
|
|
775
|
-
* onUploadProgress: (progress) => {
|
|
776
|
-
* console.log(`${progress.percentage}% uploaded`)
|
|
777
|
-
* }
|
|
778
|
-
* }
|
|
779
|
-
* })
|
|
780
|
-
* ```
|
|
781
|
-
*
|
|
782
|
-
* For automatic progress state management, use `useStorageUploadWithProgress` instead.
|
|
783
|
-
*/
|
|
784
|
-
declare function useStorageUpload(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
785
|
-
id: string;
|
|
786
|
-
path: string;
|
|
787
|
-
fullPath: string;
|
|
788
|
-
} | null, Error, {
|
|
789
|
-
path: string;
|
|
790
|
-
file: File | Blob | ArrayBuffer;
|
|
791
|
-
options?: UploadOptions;
|
|
792
|
-
}, unknown>;
|
|
793
|
-
/**
|
|
794
|
-
* Hook to upload a file to a bucket with built-in progress tracking
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* ```tsx
|
|
798
|
-
* const { upload, progress, reset } = useStorageUploadWithProgress('avatars')
|
|
799
|
-
*
|
|
800
|
-
* // Upload with automatic progress tracking
|
|
801
|
-
* upload.mutate({
|
|
802
|
-
* path: 'user.jpg',
|
|
803
|
-
* file: file
|
|
804
|
-
* })
|
|
805
|
-
*
|
|
806
|
-
* // Display progress
|
|
807
|
-
* console.log(progress) // { loaded: 1024, total: 2048, percentage: 50 }
|
|
808
|
-
* ```
|
|
809
|
-
*/
|
|
810
|
-
declare function useStorageUploadWithProgress(bucket: string): {
|
|
811
|
-
upload: _tanstack_react_query.UseMutationResult<{
|
|
812
|
-
id: string;
|
|
813
|
-
path: string;
|
|
814
|
-
fullPath: string;
|
|
815
|
-
} | null, Error, {
|
|
816
|
-
path: string;
|
|
817
|
-
file: File | Blob | ArrayBuffer;
|
|
818
|
-
options?: Omit<UploadOptions, "onUploadProgress">;
|
|
819
|
-
}, unknown>;
|
|
820
|
-
progress: UploadProgress | null;
|
|
821
|
-
reset: () => void;
|
|
822
|
-
};
|
|
823
|
-
/**
|
|
824
|
-
* Hook to download a file from a bucket
|
|
825
|
-
*/
|
|
826
|
-
declare function useStorageDownload(bucket: string, path: string | null, enabled?: boolean): _tanstack_react_query.UseQueryResult<Blob | null, Error>;
|
|
827
|
-
/**
|
|
828
|
-
* Hook to delete files from a bucket
|
|
829
|
-
*/
|
|
830
|
-
declare function useStorageDelete(bucket: string): _tanstack_react_query.UseMutationResult<void, Error, string[], unknown>;
|
|
831
|
-
/**
|
|
832
|
-
* Hook to get a public URL for a file
|
|
833
|
-
*/
|
|
834
|
-
declare function useStoragePublicUrl(bucket: string, path: string | null): string | null;
|
|
835
|
-
/**
|
|
836
|
-
* Hook to get a public URL for an image with transformations applied
|
|
837
|
-
*
|
|
838
|
-
* Only works for image files (JPEG, PNG, WebP, GIF, AVIF, etc.)
|
|
839
|
-
*
|
|
840
|
-
* @param bucket - The storage bucket name
|
|
841
|
-
* @param path - The file path (or null to disable)
|
|
842
|
-
* @param transform - Transformation options (width, height, format, quality, fit)
|
|
843
|
-
*
|
|
844
|
-
* @example
|
|
845
|
-
* ```tsx
|
|
846
|
-
* function ImageThumbnail({ path }: { path: string }) {
|
|
847
|
-
* const url = useStorageTransformUrl('images', path, {
|
|
848
|
-
* width: 300,
|
|
849
|
-
* height: 200,
|
|
850
|
-
* format: 'webp',
|
|
851
|
-
* quality: 85,
|
|
852
|
-
* fit: 'cover'
|
|
853
|
-
* });
|
|
854
|
-
*
|
|
855
|
-
* return <img src={url || ''} alt="Thumbnail" />;
|
|
856
|
-
* }
|
|
857
|
-
* ```
|
|
858
|
-
*/
|
|
859
|
-
declare function useStorageTransformUrl(bucket: string, path: string | null, transform: TransformOptions): string | null;
|
|
860
|
-
/**
|
|
861
|
-
* Hook to create a signed URL
|
|
862
|
-
*
|
|
863
|
-
* @deprecated Use useStorageSignedUrlWithOptions for more control including transforms
|
|
864
|
-
*/
|
|
865
|
-
declare function useStorageSignedUrl(bucket: string, path: string | null, expiresIn?: number): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
866
|
-
/**
|
|
867
|
-
* Hook to create a signed URL with full options including image transformations
|
|
868
|
-
*
|
|
869
|
-
* @param bucket - The storage bucket name
|
|
870
|
-
* @param path - The file path (or null to disable)
|
|
871
|
-
* @param options - Signed URL options including expiration and transforms
|
|
872
|
-
*
|
|
873
|
-
* @example
|
|
874
|
-
* ```tsx
|
|
875
|
-
* function SecureThumbnail({ path }: { path: string }) {
|
|
876
|
-
* const { data: url } = useStorageSignedUrlWithOptions('images', path, {
|
|
877
|
-
* expiresIn: 3600,
|
|
878
|
-
* transform: {
|
|
879
|
-
* width: 400,
|
|
880
|
-
* height: 300,
|
|
881
|
-
* format: 'webp',
|
|
882
|
-
* quality: 85,
|
|
883
|
-
* fit: 'cover'
|
|
884
|
-
* }
|
|
885
|
-
* });
|
|
886
|
-
*
|
|
887
|
-
* return <img src={url || ''} alt="Secure Thumbnail" />;
|
|
888
|
-
* }
|
|
889
|
-
* ```
|
|
890
|
-
*/
|
|
891
|
-
declare function useStorageSignedUrlWithOptions(bucket: string, path: string | null, options?: SignedUrlOptions): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
892
|
-
/**
|
|
893
|
-
* Hook to move a file
|
|
894
|
-
*/
|
|
895
|
-
declare function useStorageMove(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
896
|
-
message: string;
|
|
897
|
-
} | null, Error, {
|
|
898
|
-
fromPath: string;
|
|
899
|
-
toPath: string;
|
|
900
|
-
}, unknown>;
|
|
901
|
-
/**
|
|
902
|
-
* Hook to copy a file
|
|
903
|
-
*/
|
|
904
|
-
declare function useStorageCopy(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
905
|
-
path: string;
|
|
906
|
-
} | null, Error, {
|
|
907
|
-
fromPath: string;
|
|
908
|
-
toPath: string;
|
|
909
|
-
}, unknown>;
|
|
910
|
-
/**
|
|
911
|
-
* Hook to manage buckets
|
|
912
|
-
*/
|
|
913
|
-
declare function useStorageBuckets(): _tanstack_react_query.UseQueryResult<{
|
|
914
|
-
name: string;
|
|
915
|
-
created_at: string;
|
|
916
|
-
}[], Error>;
|
|
917
|
-
/**
|
|
918
|
-
* Hook to create a bucket
|
|
919
|
-
*/
|
|
920
|
-
declare function useCreateBucket(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
921
|
-
/**
|
|
922
|
-
* Hook to delete a bucket
|
|
923
|
-
*/
|
|
924
|
-
declare function useDeleteBucket(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* Simplified admin user type returned by authentication
|
|
928
|
-
*/
|
|
929
|
-
interface AdminUser {
|
|
930
|
-
id: string;
|
|
931
|
-
email: string;
|
|
932
|
-
role: string;
|
|
933
|
-
}
|
|
934
|
-
interface UseAdminAuthOptions {
|
|
935
|
-
/**
|
|
936
|
-
* Automatically check authentication status on mount
|
|
937
|
-
* @default true
|
|
938
|
-
*/
|
|
939
|
-
autoCheck?: boolean;
|
|
940
|
-
}
|
|
941
|
-
interface UseAdminAuthReturn {
|
|
942
|
-
/**
|
|
943
|
-
* Current admin user if authenticated
|
|
944
|
-
*/
|
|
945
|
-
user: AdminUser | null;
|
|
946
|
-
/**
|
|
947
|
-
* Whether the admin is authenticated
|
|
948
|
-
*/
|
|
949
|
-
isAuthenticated: boolean;
|
|
950
|
-
/**
|
|
951
|
-
* Whether the authentication check is in progress
|
|
952
|
-
*/
|
|
953
|
-
isLoading: boolean;
|
|
954
|
-
/**
|
|
955
|
-
* Any error that occurred during authentication
|
|
956
|
-
*/
|
|
957
|
-
error: Error | null;
|
|
958
|
-
/**
|
|
959
|
-
* Login as admin
|
|
960
|
-
*/
|
|
961
|
-
login: (email: string, password: string) => Promise<AdminAuthResponse>;
|
|
962
|
-
/**
|
|
963
|
-
* Logout admin
|
|
964
|
-
*/
|
|
965
|
-
logout: () => Promise<void>;
|
|
966
|
-
/**
|
|
967
|
-
* Refresh admin user info
|
|
968
|
-
*/
|
|
969
|
-
refresh: () => Promise<void>;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Hook for admin authentication
|
|
973
|
-
*
|
|
974
|
-
* Manages admin login state, authentication checks, and user info.
|
|
975
|
-
*
|
|
976
|
-
* @example
|
|
977
|
-
* ```tsx
|
|
978
|
-
* function AdminLogin() {
|
|
979
|
-
* const { user, isAuthenticated, isLoading, login, logout } = useAdminAuth()
|
|
980
|
-
*
|
|
981
|
-
* const handleLogin = async (e: React.FormEvent) => {
|
|
982
|
-
* e.preventDefault()
|
|
983
|
-
* await login(email, password)
|
|
984
|
-
* }
|
|
985
|
-
*
|
|
986
|
-
* if (isLoading) return <div>Loading...</div>
|
|
987
|
-
* if (isAuthenticated) return <div>Welcome {user?.email}</div>
|
|
988
|
-
*
|
|
989
|
-
* return <form onSubmit={handleLogin}>...</form>
|
|
990
|
-
* }
|
|
991
|
-
* ```
|
|
992
|
-
*/
|
|
993
|
-
declare function useAdminAuth(options?: UseAdminAuthOptions): UseAdminAuthReturn;
|
|
994
|
-
|
|
995
|
-
interface UseUsersOptions extends ListUsersOptions {
|
|
996
|
-
/**
|
|
997
|
-
* Whether to automatically fetch users on mount
|
|
998
|
-
* @default true
|
|
999
|
-
*/
|
|
1000
|
-
autoFetch?: boolean;
|
|
1001
|
-
/**
|
|
1002
|
-
* Refetch interval in milliseconds (0 to disable)
|
|
1003
|
-
* @default 0
|
|
1004
|
-
*/
|
|
1005
|
-
refetchInterval?: number;
|
|
1006
|
-
}
|
|
1007
|
-
interface UseUsersReturn {
|
|
1008
|
-
/**
|
|
1009
|
-
* Array of users
|
|
1010
|
-
*/
|
|
1011
|
-
users: EnrichedUser[];
|
|
1012
|
-
/**
|
|
1013
|
-
* Total number of users (for pagination)
|
|
1014
|
-
*/
|
|
1015
|
-
total: number;
|
|
1016
|
-
/**
|
|
1017
|
-
* Whether users are being fetched
|
|
1018
|
-
*/
|
|
1019
|
-
isLoading: boolean;
|
|
1020
|
-
/**
|
|
1021
|
-
* Any error that occurred
|
|
1022
|
-
*/
|
|
1023
|
-
error: Error | null;
|
|
1024
|
-
/**
|
|
1025
|
-
* Refetch users
|
|
1026
|
-
*/
|
|
1027
|
-
refetch: () => Promise<void>;
|
|
1028
|
-
/**
|
|
1029
|
-
* Invite a new user
|
|
1030
|
-
*/
|
|
1031
|
-
inviteUser: (email: string, role: 'user' | 'admin') => Promise<void>;
|
|
1032
|
-
/**
|
|
1033
|
-
* Update user role
|
|
1034
|
-
*/
|
|
1035
|
-
updateUserRole: (userId: string, role: 'user' | 'admin') => Promise<void>;
|
|
1036
|
-
/**
|
|
1037
|
-
* Delete a user
|
|
1038
|
-
*/
|
|
1039
|
-
deleteUser: (userId: string) => Promise<void>;
|
|
1040
|
-
/**
|
|
1041
|
-
* Reset user password
|
|
1042
|
-
*/
|
|
1043
|
-
resetPassword: (userId: string) => Promise<{
|
|
1044
|
-
message: string;
|
|
1045
|
-
}>;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Hook for managing users
|
|
1049
|
-
*
|
|
1050
|
-
* Provides user list with pagination, search, and management functions.
|
|
1051
|
-
*
|
|
1052
|
-
* @example
|
|
1053
|
-
* ```tsx
|
|
1054
|
-
* function UserList() {
|
|
1055
|
-
* const { users, total, isLoading, refetch, inviteUser, deleteUser } = useUsers({
|
|
1056
|
-
* limit: 20,
|
|
1057
|
-
* search: searchTerm
|
|
1058
|
-
* })
|
|
1059
|
-
*
|
|
1060
|
-
* return (
|
|
1061
|
-
* <div>
|
|
1062
|
-
* {isLoading ? <Spinner /> : (
|
|
1063
|
-
* <ul>
|
|
1064
|
-
* {users.map(user => (
|
|
1065
|
-
* <li key={user.id}>
|
|
1066
|
-
* {user.email} - {user.role}
|
|
1067
|
-
* <button onClick={() => deleteUser(user.id)}>Delete</button>
|
|
1068
|
-
* </li>
|
|
1069
|
-
* ))}
|
|
1070
|
-
* </ul>
|
|
1071
|
-
* )}
|
|
1072
|
-
* </div>
|
|
1073
|
-
* )
|
|
1074
|
-
* }
|
|
1075
|
-
* ```
|
|
1076
|
-
*/
|
|
1077
|
-
declare function useUsers(options?: UseUsersOptions): UseUsersReturn;
|
|
1078
|
-
|
|
1079
|
-
interface UseClientKeysOptions {
|
|
1080
|
-
/**
|
|
1081
|
-
* Whether to automatically fetch client keys on mount
|
|
1082
|
-
* @default true
|
|
1083
|
-
*/
|
|
1084
|
-
autoFetch?: boolean;
|
|
1085
|
-
}
|
|
1086
|
-
interface UseClientKeysReturn {
|
|
1087
|
-
/**
|
|
1088
|
-
* Array of client keys
|
|
1089
|
-
*/
|
|
1090
|
-
keys: ClientKey[];
|
|
1091
|
-
/**
|
|
1092
|
-
* Whether keys are being fetched
|
|
1093
|
-
*/
|
|
1094
|
-
isLoading: boolean;
|
|
1095
|
-
/**
|
|
1096
|
-
* Any error that occurred
|
|
1097
|
-
*/
|
|
1098
|
-
error: Error | null;
|
|
1099
|
-
/**
|
|
1100
|
-
* Refetch client keys
|
|
1101
|
-
*/
|
|
1102
|
-
refetch: () => Promise<void>;
|
|
1103
|
-
/**
|
|
1104
|
-
* Create a new client key
|
|
1105
|
-
*/
|
|
1106
|
-
createKey: (request: CreateClientKeyRequest) => Promise<{
|
|
1107
|
-
key: string;
|
|
1108
|
-
keyData: ClientKey;
|
|
1109
|
-
}>;
|
|
1110
|
-
/**
|
|
1111
|
-
* Update a client key
|
|
1112
|
-
*/
|
|
1113
|
-
updateKey: (keyId: string, update: {
|
|
1114
|
-
name?: string;
|
|
1115
|
-
description?: string;
|
|
1116
|
-
}) => Promise<void>;
|
|
1117
|
-
/**
|
|
1118
|
-
* Revoke a client key
|
|
1119
|
-
*/
|
|
1120
|
-
revokeKey: (keyId: string) => Promise<void>;
|
|
1121
|
-
/**
|
|
1122
|
-
* Delete a client key
|
|
1123
|
-
*/
|
|
1124
|
-
deleteKey: (keyId: string) => Promise<void>;
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
|
-
* Hook for managing client keys
|
|
1128
|
-
*
|
|
1129
|
-
* Provides client key list and management functions.
|
|
1130
|
-
*
|
|
1131
|
-
* @example
|
|
1132
|
-
* ```tsx
|
|
1133
|
-
* function ClientKeyManager() {
|
|
1134
|
-
* const { keys, isLoading, createKey, revokeKey } = useClientKeys()
|
|
1135
|
-
*
|
|
1136
|
-
* const handleCreate = async () => {
|
|
1137
|
-
* const { key, keyData } = await createKey({
|
|
1138
|
-
* name: 'Backend Service',
|
|
1139
|
-
* description: 'Client key for backend',
|
|
1140
|
-
* expires_at: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString()
|
|
1141
|
-
* })
|
|
1142
|
-
* alert(`Key created: ${key}`)
|
|
1143
|
-
* }
|
|
1144
|
-
*
|
|
1145
|
-
* return (
|
|
1146
|
-
* <div>
|
|
1147
|
-
* <button onClick={handleCreate}>Create Key</button>
|
|
1148
|
-
* {keys.map(k => (
|
|
1149
|
-
* <div key={k.id}>
|
|
1150
|
-
* {k.name}
|
|
1151
|
-
* <button onClick={() => revokeKey(k.id)}>Revoke</button>
|
|
1152
|
-
* </div>
|
|
1153
|
-
* ))}
|
|
1154
|
-
* </div>
|
|
1155
|
-
* )
|
|
1156
|
-
* }
|
|
1157
|
-
* ```
|
|
1158
|
-
*/
|
|
1159
|
-
declare function useClientKeys(options?: UseClientKeysOptions): UseClientKeysReturn;
|
|
1160
|
-
/**
|
|
1161
|
-
* @deprecated Use useClientKeys instead
|
|
1162
|
-
*/
|
|
1163
|
-
declare const useAPIKeys: typeof useClientKeys;
|
|
1164
|
-
|
|
1165
|
-
/**
|
|
1166
|
-
* Admin Settings and Management Hooks
|
|
1167
|
-
*
|
|
1168
|
-
* Hooks for managing application settings, system settings, and webhooks.
|
|
1169
|
-
*/
|
|
1170
|
-
|
|
1171
|
-
interface UseAppSettingsOptions {
|
|
1172
|
-
autoFetch?: boolean;
|
|
1173
|
-
}
|
|
1174
|
-
interface UseAppSettingsReturn {
|
|
1175
|
-
settings: AppSettings | null;
|
|
1176
|
-
isLoading: boolean;
|
|
1177
|
-
error: Error | null;
|
|
1178
|
-
refetch: () => Promise<void>;
|
|
1179
|
-
updateSettings: (update: UpdateAppSettingsRequest) => Promise<void>;
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* Hook for managing application settings
|
|
1183
|
-
*
|
|
1184
|
-
* @example
|
|
1185
|
-
* ```tsx
|
|
1186
|
-
* function SettingsPanel() {
|
|
1187
|
-
* const { settings, isLoading, updateSettings } = useAppSettings({ autoFetch: true })
|
|
1188
|
-
*
|
|
1189
|
-
* const handleToggleFeature = async (feature: string, enabled: boolean) => {
|
|
1190
|
-
* await updateSettings({
|
|
1191
|
-
* features: { ...settings?.features, [feature]: enabled }
|
|
1192
|
-
* })
|
|
1193
|
-
* }
|
|
1194
|
-
*
|
|
1195
|
-
* return <div>...</div>
|
|
1196
|
-
* }
|
|
1197
|
-
* ```
|
|
1198
|
-
*/
|
|
1199
|
-
declare function useAppSettings(options?: UseAppSettingsOptions): UseAppSettingsReturn;
|
|
1200
|
-
interface UseSystemSettingsOptions {
|
|
1201
|
-
autoFetch?: boolean;
|
|
1202
|
-
}
|
|
1203
|
-
interface UseSystemSettingsReturn {
|
|
1204
|
-
settings: SystemSetting[];
|
|
1205
|
-
isLoading: boolean;
|
|
1206
|
-
error: Error | null;
|
|
1207
|
-
refetch: () => Promise<void>;
|
|
1208
|
-
getSetting: (key: string) => SystemSetting | undefined;
|
|
1209
|
-
updateSetting: (key: string, update: UpdateSystemSettingRequest) => Promise<void>;
|
|
1210
|
-
deleteSetting: (key: string) => Promise<void>;
|
|
1211
|
-
}
|
|
1212
|
-
/**
|
|
1213
|
-
* Hook for managing system settings (key-value storage)
|
|
1214
|
-
*
|
|
1215
|
-
* @example
|
|
1216
|
-
* ```tsx
|
|
1217
|
-
* function SystemSettings() {
|
|
1218
|
-
* const { settings, isLoading, updateSetting } = useSystemSettings({ autoFetch: true })
|
|
1219
|
-
*
|
|
1220
|
-
* const handleUpdateSetting = async (key: string, value: any) => {
|
|
1221
|
-
* await updateSetting(key, { value })
|
|
1222
|
-
* }
|
|
1223
|
-
*
|
|
1224
|
-
* return <div>...</div>
|
|
1225
|
-
* }
|
|
1226
|
-
* ```
|
|
1227
|
-
*/
|
|
1228
|
-
declare function useSystemSettings(options?: UseSystemSettingsOptions): UseSystemSettingsReturn;
|
|
1229
|
-
interface UseWebhooksOptions {
|
|
1230
|
-
autoFetch?: boolean;
|
|
1231
|
-
refetchInterval?: number;
|
|
1232
|
-
}
|
|
1233
|
-
interface UseWebhooksReturn {
|
|
1234
|
-
webhooks: Webhook[];
|
|
1235
|
-
isLoading: boolean;
|
|
1236
|
-
error: Error | null;
|
|
1237
|
-
refetch: () => Promise<void>;
|
|
1238
|
-
createWebhook: (webhook: CreateWebhookRequest) => Promise<Webhook>;
|
|
1239
|
-
updateWebhook: (id: string, update: UpdateWebhookRequest) => Promise<Webhook>;
|
|
1240
|
-
deleteWebhook: (id: string) => Promise<void>;
|
|
1241
|
-
testWebhook: (id: string) => Promise<void>;
|
|
1242
|
-
}
|
|
1243
|
-
/**
|
|
1244
|
-
* Hook for managing webhooks
|
|
1245
|
-
*
|
|
1246
|
-
* @example
|
|
1247
|
-
* ```tsx
|
|
1248
|
-
* function WebhooksManager() {
|
|
1249
|
-
* const { webhooks, isLoading, createWebhook, deleteWebhook } = useWebhooks({
|
|
1250
|
-
* autoFetch: true
|
|
1251
|
-
* })
|
|
1252
|
-
*
|
|
1253
|
-
* const handleCreate = async () => {
|
|
1254
|
-
* await createWebhook({
|
|
1255
|
-
* url: 'https://example.com/webhook',
|
|
1256
|
-
* events: ['user.created', 'user.updated'],
|
|
1257
|
-
* enabled: true
|
|
1258
|
-
* })
|
|
1259
|
-
* }
|
|
1260
|
-
*
|
|
1261
|
-
* return <div>...</div>
|
|
1262
|
-
* }
|
|
1263
|
-
* ```
|
|
1264
|
-
*/
|
|
1265
|
-
declare function useWebhooks(options?: UseWebhooksOptions): UseWebhooksReturn;
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* Table Export Hooks
|
|
1269
|
-
*
|
|
1270
|
-
* React hooks for exporting database tables to knowledge bases and managing sync configurations.
|
|
1271
|
-
*/
|
|
1272
|
-
|
|
1273
|
-
interface UseTableDetailsOptions {
|
|
1274
|
-
schema?: string;
|
|
1275
|
-
table?: string;
|
|
1276
|
-
autoFetch?: boolean;
|
|
1277
|
-
}
|
|
1278
|
-
interface UseTableDetailsReturn {
|
|
1279
|
-
data: TableDetails | null;
|
|
1280
|
-
isLoading: boolean;
|
|
1281
|
-
error: Error | null;
|
|
1282
|
-
refetch: () => Promise<void>;
|
|
1283
|
-
}
|
|
1284
|
-
/**
|
|
1285
|
-
* Hook for fetching detailed table information including columns
|
|
1286
|
-
*
|
|
1287
|
-
* @example
|
|
1288
|
-
* ```tsx
|
|
1289
|
-
* function TableColumnsList({ schema, table }: { schema: string; table: string }) {
|
|
1290
|
-
* const { data, isLoading, error } = useTableDetails({ schema, table })
|
|
1291
|
-
*
|
|
1292
|
-
* if (isLoading) return <div>Loading...</div>
|
|
1293
|
-
* if (error) return <div>Error: {error.message}</div>
|
|
1294
|
-
*
|
|
1295
|
-
* return (
|
|
1296
|
-
* <ul>
|
|
1297
|
-
* {data?.columns.map(col => (
|
|
1298
|
-
* <li key={col.name}>
|
|
1299
|
-
* {col.name} ({col.data_type})
|
|
1300
|
-
* {col.is_primary_key && ' 🔑'}
|
|
1301
|
-
* </li>
|
|
1302
|
-
* ))}
|
|
1303
|
-
* </ul>
|
|
1304
|
-
* )
|
|
1305
|
-
* }
|
|
1306
|
-
* ```
|
|
1307
|
-
*/
|
|
1308
|
-
declare function useTableDetails(options: UseTableDetailsOptions): UseTableDetailsReturn;
|
|
1309
|
-
interface UseExportTableReturn {
|
|
1310
|
-
exportTable: (options: ExportTableOptions) => Promise<ExportTableResult | null>;
|
|
1311
|
-
isLoading: boolean;
|
|
1312
|
-
error: Error | null;
|
|
1313
|
-
reset: () => void;
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* Hook for exporting a table to a knowledge base
|
|
1317
|
-
*
|
|
1318
|
-
* @example
|
|
1319
|
-
* ```tsx
|
|
1320
|
-
* function ExportTableButton({ kbId, schema, table }: Props) {
|
|
1321
|
-
* const { exportTable, isLoading, error } = useExportTable(kbId)
|
|
1322
|
-
*
|
|
1323
|
-
* const handleExport = async () => {
|
|
1324
|
-
* const result = await exportTable({
|
|
1325
|
-
* schema,
|
|
1326
|
-
* table,
|
|
1327
|
-
* columns: ['id', 'name', 'email'],
|
|
1328
|
-
* include_foreign_keys: true,
|
|
1329
|
-
* })
|
|
1330
|
-
* if (result) {
|
|
1331
|
-
* console.log('Exported document:', result.document_id)
|
|
1332
|
-
* }
|
|
1333
|
-
* }
|
|
1334
|
-
*
|
|
1335
|
-
* return (
|
|
1336
|
-
* <button onClick={handleExport} disabled={isLoading}>
|
|
1337
|
-
* {isLoading ? 'Exporting...' : 'Export Table'}
|
|
1338
|
-
* </button>
|
|
1339
|
-
* )
|
|
1340
|
-
* }
|
|
1341
|
-
* ```
|
|
1342
|
-
*/
|
|
1343
|
-
declare function useExportTable(knowledgeBaseId: string): UseExportTableReturn;
|
|
1344
|
-
interface UseTableExportSyncsOptions {
|
|
1345
|
-
autoFetch?: boolean;
|
|
1346
|
-
}
|
|
1347
|
-
interface UseTableExportSyncsReturn {
|
|
1348
|
-
configs: TableExportSyncConfig[];
|
|
1349
|
-
isLoading: boolean;
|
|
1350
|
-
error: Error | null;
|
|
1351
|
-
refetch: () => Promise<void>;
|
|
1352
|
-
}
|
|
1353
|
-
/**
|
|
1354
|
-
* Hook for listing table export sync configurations
|
|
1355
|
-
*
|
|
1356
|
-
* @example
|
|
1357
|
-
* ```tsx
|
|
1358
|
-
* function SyncConfigsList({ kbId }: { kbId: string }) {
|
|
1359
|
-
* const { configs, isLoading, error } = useTableExportSyncs(kbId)
|
|
1360
|
-
*
|
|
1361
|
-
* if (isLoading) return <div>Loading...</div>
|
|
1362
|
-
*
|
|
1363
|
-
* return (
|
|
1364
|
-
* <ul>
|
|
1365
|
-
* {configs.map(config => (
|
|
1366
|
-
* <li key={config.id}>
|
|
1367
|
-
* {config.schema_name}.{config.table_name} ({config.sync_mode})
|
|
1368
|
-
* </li>
|
|
1369
|
-
* ))}
|
|
1370
|
-
* </ul>
|
|
1371
|
-
* )
|
|
1372
|
-
* }
|
|
1373
|
-
* ```
|
|
1374
|
-
*/
|
|
1375
|
-
declare function useTableExportSyncs(knowledgeBaseId: string, options?: UseTableExportSyncsOptions): UseTableExportSyncsReturn;
|
|
1376
|
-
interface UseCreateTableExportSyncReturn {
|
|
1377
|
-
createSync: (config: CreateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1378
|
-
isLoading: boolean;
|
|
1379
|
-
error: Error | null;
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Hook for creating a table export sync configuration
|
|
1383
|
-
*
|
|
1384
|
-
* @example
|
|
1385
|
-
* ```tsx
|
|
1386
|
-
* function CreateSyncForm({ kbId }: { kbId: string }) {
|
|
1387
|
-
* const { createSync, isLoading, error } = useCreateTableExportSync(kbId)
|
|
1388
|
-
*
|
|
1389
|
-
* const handleSubmit = async (e: React.FormEvent) => {
|
|
1390
|
-
* e.preventDefault()
|
|
1391
|
-
* const config = await createSync({
|
|
1392
|
-
* schema_name: 'public',
|
|
1393
|
-
* table_name: 'users',
|
|
1394
|
-
* columns: ['id', 'name', 'email'],
|
|
1395
|
-
* sync_mode: 'automatic',
|
|
1396
|
-
* sync_on_insert: true,
|
|
1397
|
-
* sync_on_update: true,
|
|
1398
|
-
* })
|
|
1399
|
-
* if (config) {
|
|
1400
|
-
* console.log('Created sync config:', config.id)
|
|
1401
|
-
* }
|
|
1402
|
-
* }
|
|
1403
|
-
*
|
|
1404
|
-
* return <form onSubmit={handleSubmit}>...</form>
|
|
1405
|
-
* }
|
|
1406
|
-
* ```
|
|
1407
|
-
*/
|
|
1408
|
-
declare function useCreateTableExportSync(knowledgeBaseId: string): UseCreateTableExportSyncReturn;
|
|
1409
|
-
interface UseUpdateTableExportSyncReturn {
|
|
1410
|
-
updateSync: (syncId: string, updates: UpdateTableExportSyncConfig) => Promise<TableExportSyncConfig | null>;
|
|
1411
|
-
isLoading: boolean;
|
|
1412
|
-
error: Error | null;
|
|
1413
|
-
}
|
|
1414
|
-
/**
|
|
1415
|
-
* Hook for updating a table export sync configuration
|
|
1416
|
-
*/
|
|
1417
|
-
declare function useUpdateTableExportSync(knowledgeBaseId: string): UseUpdateTableExportSyncReturn;
|
|
1418
|
-
interface UseDeleteTableExportSyncReturn {
|
|
1419
|
-
deleteSync: (syncId: string) => Promise<boolean>;
|
|
1420
|
-
isLoading: boolean;
|
|
1421
|
-
error: Error | null;
|
|
1422
|
-
}
|
|
1423
|
-
/**
|
|
1424
|
-
* Hook for deleting a table export sync configuration
|
|
1425
|
-
*/
|
|
1426
|
-
declare function useDeleteTableExportSync(knowledgeBaseId: string): UseDeleteTableExportSyncReturn;
|
|
1427
|
-
interface UseTriggerTableExportSyncReturn {
|
|
1428
|
-
triggerSync: (syncId: string) => Promise<ExportTableResult | null>;
|
|
1429
|
-
isLoading: boolean;
|
|
1430
|
-
error: Error | null;
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* Hook for manually triggering a table export sync
|
|
1434
|
-
*
|
|
1435
|
-
* @example
|
|
1436
|
-
* ```tsx
|
|
1437
|
-
* function TriggerSyncButton({ kbId, syncId }: Props) {
|
|
1438
|
-
* const { triggerSync, isLoading, error } = useTriggerTableExportSync(kbId)
|
|
1439
|
-
*
|
|
1440
|
-
* const handleTrigger = async () => {
|
|
1441
|
-
* const result = await triggerSync(syncId)
|
|
1442
|
-
* if (result) {
|
|
1443
|
-
* console.log('Sync completed:', result.document_id)
|
|
1444
|
-
* }
|
|
1445
|
-
* }
|
|
1446
|
-
*
|
|
1447
|
-
* return (
|
|
1448
|
-
* <button onClick={handleTrigger} disabled={isLoading}>
|
|
1449
|
-
* {isLoading ? 'Syncing...' : 'Sync Now'}
|
|
1450
|
-
* </button>
|
|
1451
|
-
* )
|
|
1452
|
-
* }
|
|
1453
|
-
* ```
|
|
1454
|
-
*/
|
|
1455
|
-
declare function useTriggerTableExportSync(knowledgeBaseId: string): UseTriggerTableExportSyncReturn;
|
|
1456
|
-
|
|
1457
|
-
export { type CaptchaState, FluxbaseProvider, type UseCreateTableExportSyncReturn, type UseDeleteTableExportSyncReturn, type UseExportTableReturn, type UseGraphQLMutationOptions, type UseGraphQLQueryOptions, type UseTableDetailsOptions, type UseTableDetailsReturn, type UseTableExportSyncsOptions, type UseTableExportSyncsReturn, type UseTriggerTableExportSyncReturn, type UseUpdateTableExportSyncReturn, isCaptchaRequiredForEndpoint, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useAuthConfig, useCaptcha, useCaptchaConfig, useClientKeys, useCreateBucket, useCreateTableExportSync, useDelete, useDeleteBucket, useDeleteTableExportSync, useExportTable, useFluxbaseClient, useFluxbaseQuery, useGetSAMLLoginUrl, useGraphQL, useGraphQLIntrospection, useGraphQLMutation, useGraphQLQuery, useHandleSAMLCallback, useInsert, useRealtime, useSAMLMetadataUrl, useSAMLProviders, useSession, useSignIn, useSignInWithSAML, useSignOut, useSignUp, useStorageBuckets, useStorageCopy, useStorageDelete, useStorageDownload, useStorageList, useStorageMove, useStoragePublicUrl, useStorageSignedUrl, useStorageSignedUrlWithOptions, useStorageTransformUrl, useStorageUpload, useStorageUploadWithProgress, useSystemSettings, useTable, useTableDeletes, useTableDetails, useTableExportSyncs, useTableInserts, useTableSubscription, useTableUpdates, useTriggerTableExportSync, useUpdate, useUpdateTableExportSync, useUpdateUser, useUpsert, useUser, useUsers, useWebhooks };
|