@fluxbase/sdk-react 0.1.0-rc.1 → 2026.1.1-rc.10
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-ADMIN.md +8 -8
- package/README.md +27 -14
- package/dist/index.d.mts +713 -83
- package/dist/index.d.ts +713 -83
- package/dist/index.js +574 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +561 -172
- package/dist/index.mjs.map +1 -1
- package/examples/AdminDashboard.tsx +3 -3
- package/examples/README.md +1 -1
- package/package.json +3 -3
- package/src/index.ts +60 -18
- package/src/use-admin-auth.ts +62 -51
- package/src/use-auth-config.ts +101 -0
- package/src/use-auth.ts +66 -49
- package/src/use-captcha.ts +250 -0
- package/src/{use-api-keys.ts → use-client-keys.ts} +43 -32
- package/src/use-graphql.ts +392 -0
- package/src/use-realtime.ts +58 -44
- package/src/use-saml.ts +221 -0
- package/src/use-storage.ts +325 -82
- package/src/use-users.ts +11 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/typedoc.json +2 -4
- package/CHANGELOG.md +0 -67
- package/src/use-rpc.ts +0 -109
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as _fluxbase_sdk from '@fluxbase/sdk';
|
|
4
|
-
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, QueryBuilder, RealtimeCallback,
|
|
5
|
-
export { APIKey, AdminUser, AppSettings, AuthSession, EnrichedUser, FluxbaseClient, PostgrestResponse, RealtimeChangePayload, SignInCredentials, SignUpCredentials, StorageObject, SystemSetting, User, Webhook } from '@fluxbase/sdk';
|
|
4
|
+
import { FluxbaseClient, User, AuthSession, SignInCredentials, SignUpCredentials, CaptchaConfig, CaptchaProvider, AuthConfig, SAMLProvider, SAMLLoginOptions, GraphQLRequestOptions, GraphQLError, GraphQLResponse, QueryBuilder, RealtimeCallback, RealtimePostgresChangesPayload, ListOptions, UploadOptions, UploadProgress, TransformOptions, SignedUrlOptions, AdminAuthResponse, ListUsersOptions, EnrichedUser, ClientKey, CreateClientKeyRequest, Webhook, CreateWebhookRequest, UpdateWebhookRequest, AppSettings, UpdateAppSettingsRequest, SystemSetting, UpdateSystemSettingRequest } 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
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
-
import { UseQueryOptions
|
|
7
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
8
8
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
9
9
|
|
|
10
10
|
interface FluxbaseProviderProps {
|
|
@@ -31,11 +31,11 @@ declare function useSession(): _tanstack_react_query.UseQueryResult<AuthSession
|
|
|
31
31
|
/**
|
|
32
32
|
* Hook for signing in
|
|
33
33
|
*/
|
|
34
|
-
declare function useSignIn(): _tanstack_react_query.UseMutationResult<
|
|
34
|
+
declare function useSignIn(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseResponse<_fluxbase_sdk.AuthResponseData | _fluxbase_sdk.SignInWith2FAResponse>, Error, SignInCredentials, unknown>;
|
|
35
35
|
/**
|
|
36
36
|
* Hook for signing up
|
|
37
37
|
*/
|
|
38
|
-
declare function useSignUp(): _tanstack_react_query.UseMutationResult<
|
|
38
|
+
declare function useSignUp(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseAuthResponse, Error, SignUpCredentials, unknown>;
|
|
39
39
|
/**
|
|
40
40
|
* Hook for signing out
|
|
41
41
|
*/
|
|
@@ -43,7 +43,7 @@ declare function useSignOut(): _tanstack_react_query.UseMutationResult<void, Err
|
|
|
43
43
|
/**
|
|
44
44
|
* Hook for updating the current user
|
|
45
45
|
*/
|
|
46
|
-
declare function useUpdateUser(): _tanstack_react_query.UseMutationResult<
|
|
46
|
+
declare function useUpdateUser(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.UserResponse, Error, Partial<Pick<User, "email" | "metadata">>, unknown>;
|
|
47
47
|
/**
|
|
48
48
|
* Combined auth hook with all auth state and methods
|
|
49
49
|
*/
|
|
@@ -52,16 +52,578 @@ declare function useAuth(): {
|
|
|
52
52
|
session: AuthSession | null | undefined;
|
|
53
53
|
isLoading: boolean;
|
|
54
54
|
isAuthenticated: boolean;
|
|
55
|
-
signIn: _tanstack_react_query.UseMutateAsyncFunction<
|
|
56
|
-
signUp: _tanstack_react_query.UseMutateAsyncFunction<
|
|
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
57
|
signOut: _tanstack_react_query.UseMutateAsyncFunction<void, Error, void, unknown>;
|
|
58
|
-
updateUser: _tanstack_react_query.UseMutateAsyncFunction<
|
|
58
|
+
updateUser: _tanstack_react_query.UseMutateAsyncFunction<_fluxbase_sdk.UserResponse, Error, Partial<Pick<User, "email" | "metadata">>, unknown>;
|
|
59
59
|
isSigningIn: boolean;
|
|
60
60
|
isSigningUp: boolean;
|
|
61
61
|
isSigningOut: boolean;
|
|
62
62
|
isUpdating: boolean;
|
|
63
63
|
};
|
|
64
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
|
+
|
|
65
627
|
interface UseFluxbaseQueryOptions<T> extends Omit<UseQueryOptions<T[], Error>, 'queryKey' | 'queryFn'> {
|
|
66
628
|
/**
|
|
67
629
|
* Custom query key. If not provided, will use table name and filters.
|
|
@@ -108,7 +670,7 @@ interface UseRealtimeOptions {
|
|
|
108
670
|
/**
|
|
109
671
|
* Event type to listen for ('INSERT', 'UPDATE', 'DELETE', or '*' for all)
|
|
110
672
|
*/
|
|
111
|
-
event?:
|
|
673
|
+
event?: "INSERT" | "UPDATE" | "DELETE" | "*";
|
|
112
674
|
/**
|
|
113
675
|
* Callback function when an event is received
|
|
114
676
|
*/
|
|
@@ -140,40 +702,93 @@ declare function useRealtime(options: UseRealtimeOptions): {
|
|
|
140
702
|
* @param table - Table name (with optional schema, e.g., 'public.products')
|
|
141
703
|
* @param options - Subscription options
|
|
142
704
|
*/
|
|
143
|
-
declare function useTableSubscription(table: string, options?: Omit<UseRealtimeOptions,
|
|
705
|
+
declare function useTableSubscription(table: string, options?: Omit<UseRealtimeOptions, "channel">): {
|
|
144
706
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
145
707
|
};
|
|
146
708
|
/**
|
|
147
709
|
* Hook to subscribe to INSERT events on a table
|
|
148
710
|
*/
|
|
149
|
-
declare function useTableInserts(table: string, callback: (payload:
|
|
711
|
+
declare function useTableInserts(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
150
712
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
151
713
|
};
|
|
152
714
|
/**
|
|
153
715
|
* Hook to subscribe to UPDATE events on a table
|
|
154
716
|
*/
|
|
155
|
-
declare function useTableUpdates(table: string, callback: (payload:
|
|
717
|
+
declare function useTableUpdates(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
156
718
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
157
719
|
};
|
|
158
720
|
/**
|
|
159
721
|
* Hook to subscribe to DELETE events on a table
|
|
160
722
|
*/
|
|
161
|
-
declare function useTableDeletes(table: string, callback: (payload:
|
|
723
|
+
declare function useTableDeletes(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
162
724
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
163
725
|
};
|
|
164
726
|
|
|
165
727
|
/**
|
|
166
728
|
* Hook to list files in a bucket
|
|
167
729
|
*/
|
|
168
|
-
declare function useStorageList(bucket: string, options?: ListOptions & Omit<UseQueryOptions<any[], Error>,
|
|
730
|
+
declare function useStorageList(bucket: string, options?: ListOptions & Omit<UseQueryOptions<any[], Error>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<any[], Error>;
|
|
169
731
|
/**
|
|
170
732
|
* Hook to upload a file to a bucket
|
|
733
|
+
*
|
|
734
|
+
* Note: You can track upload progress by passing an `onUploadProgress` callback in the options:
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```tsx
|
|
738
|
+
* const upload = useStorageUpload('avatars')
|
|
739
|
+
*
|
|
740
|
+
* upload.mutate({
|
|
741
|
+
* path: 'user.jpg',
|
|
742
|
+
* file: file,
|
|
743
|
+
* options: {
|
|
744
|
+
* onUploadProgress: (progress) => {
|
|
745
|
+
* console.log(`${progress.percentage}% uploaded`)
|
|
746
|
+
* }
|
|
747
|
+
* }
|
|
748
|
+
* })
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* For automatic progress state management, use `useStorageUploadWithProgress` instead.
|
|
171
752
|
*/
|
|
172
|
-
declare function useStorageUpload(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
753
|
+
declare function useStorageUpload(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
754
|
+
id: string;
|
|
755
|
+
path: string;
|
|
756
|
+
fullPath: string;
|
|
757
|
+
} | null, Error, {
|
|
173
758
|
path: string;
|
|
174
759
|
file: File | Blob | ArrayBuffer;
|
|
175
760
|
options?: UploadOptions;
|
|
176
761
|
}, unknown>;
|
|
762
|
+
/**
|
|
763
|
+
* Hook to upload a file to a bucket with built-in progress tracking
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* ```tsx
|
|
767
|
+
* const { upload, progress, reset } = useStorageUploadWithProgress('avatars')
|
|
768
|
+
*
|
|
769
|
+
* // Upload with automatic progress tracking
|
|
770
|
+
* upload.mutate({
|
|
771
|
+
* path: 'user.jpg',
|
|
772
|
+
* file: file
|
|
773
|
+
* })
|
|
774
|
+
*
|
|
775
|
+
* // Display progress
|
|
776
|
+
* console.log(progress) // { loaded: 1024, total: 2048, percentage: 50 }
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
779
|
+
declare function useStorageUploadWithProgress(bucket: string): {
|
|
780
|
+
upload: _tanstack_react_query.UseMutationResult<{
|
|
781
|
+
id: string;
|
|
782
|
+
path: string;
|
|
783
|
+
fullPath: string;
|
|
784
|
+
} | null, Error, {
|
|
785
|
+
path: string;
|
|
786
|
+
file: File | Blob | ArrayBuffer;
|
|
787
|
+
options?: Omit<UploadOptions, "onUploadProgress">;
|
|
788
|
+
}, unknown>;
|
|
789
|
+
progress: UploadProgress | null;
|
|
790
|
+
reset: () => void;
|
|
791
|
+
};
|
|
177
792
|
/**
|
|
178
793
|
* Hook to download a file from a bucket
|
|
179
794
|
*/
|
|
@@ -186,21 +801,78 @@ declare function useStorageDelete(bucket: string): _tanstack_react_query.UseMuta
|
|
|
186
801
|
* Hook to get a public URL for a file
|
|
187
802
|
*/
|
|
188
803
|
declare function useStoragePublicUrl(bucket: string, path: string | null): string | null;
|
|
804
|
+
/**
|
|
805
|
+
* Hook to get a public URL for an image with transformations applied
|
|
806
|
+
*
|
|
807
|
+
* Only works for image files (JPEG, PNG, WebP, GIF, AVIF, etc.)
|
|
808
|
+
*
|
|
809
|
+
* @param bucket - The storage bucket name
|
|
810
|
+
* @param path - The file path (or null to disable)
|
|
811
|
+
* @param transform - Transformation options (width, height, format, quality, fit)
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```tsx
|
|
815
|
+
* function ImageThumbnail({ path }: { path: string }) {
|
|
816
|
+
* const url = useStorageTransformUrl('images', path, {
|
|
817
|
+
* width: 300,
|
|
818
|
+
* height: 200,
|
|
819
|
+
* format: 'webp',
|
|
820
|
+
* quality: 85,
|
|
821
|
+
* fit: 'cover'
|
|
822
|
+
* });
|
|
823
|
+
*
|
|
824
|
+
* return <img src={url || ''} alt="Thumbnail" />;
|
|
825
|
+
* }
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
828
|
+
declare function useStorageTransformUrl(bucket: string, path: string | null, transform: TransformOptions): string | null;
|
|
189
829
|
/**
|
|
190
830
|
* Hook to create a signed URL
|
|
831
|
+
*
|
|
832
|
+
* @deprecated Use useStorageSignedUrlWithOptions for more control including transforms
|
|
191
833
|
*/
|
|
192
834
|
declare function useStorageSignedUrl(bucket: string, path: string | null, expiresIn?: number): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
835
|
+
/**
|
|
836
|
+
* Hook to create a signed URL with full options including image transformations
|
|
837
|
+
*
|
|
838
|
+
* @param bucket - The storage bucket name
|
|
839
|
+
* @param path - The file path (or null to disable)
|
|
840
|
+
* @param options - Signed URL options including expiration and transforms
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```tsx
|
|
844
|
+
* function SecureThumbnail({ path }: { path: string }) {
|
|
845
|
+
* const { data: url } = useStorageSignedUrlWithOptions('images', path, {
|
|
846
|
+
* expiresIn: 3600,
|
|
847
|
+
* transform: {
|
|
848
|
+
* width: 400,
|
|
849
|
+
* height: 300,
|
|
850
|
+
* format: 'webp',
|
|
851
|
+
* quality: 85,
|
|
852
|
+
* fit: 'cover'
|
|
853
|
+
* }
|
|
854
|
+
* });
|
|
855
|
+
*
|
|
856
|
+
* return <img src={url || ''} alt="Secure Thumbnail" />;
|
|
857
|
+
* }
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
declare function useStorageSignedUrlWithOptions(bucket: string, path: string | null, options?: SignedUrlOptions): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
193
861
|
/**
|
|
194
862
|
* Hook to move a file
|
|
195
863
|
*/
|
|
196
|
-
declare function useStorageMove(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
864
|
+
declare function useStorageMove(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
865
|
+
message: string;
|
|
866
|
+
} | null, Error, {
|
|
197
867
|
fromPath: string;
|
|
198
868
|
toPath: string;
|
|
199
869
|
}, unknown>;
|
|
200
870
|
/**
|
|
201
871
|
* Hook to copy a file
|
|
202
872
|
*/
|
|
203
|
-
declare function useStorageCopy(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
873
|
+
declare function useStorageCopy(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
874
|
+
path: string;
|
|
875
|
+
} | null, Error, {
|
|
204
876
|
fromPath: string;
|
|
205
877
|
toPath: string;
|
|
206
878
|
}, unknown>;
|
|
@@ -220,52 +892,6 @@ declare function useCreateBucket(): _tanstack_react_query.UseMutationResult<void
|
|
|
220
892
|
*/
|
|
221
893
|
declare function useDeleteBucket(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
222
894
|
|
|
223
|
-
/**
|
|
224
|
-
* Hook to call a PostgreSQL function and cache the result
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```tsx
|
|
228
|
-
* const { data, isLoading, error } = useRPC(
|
|
229
|
-
* 'calculate_total',
|
|
230
|
-
* { order_id: 123 },
|
|
231
|
-
* { enabled: !!orderId }
|
|
232
|
-
* )
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare function useRPC<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(functionName: string, params?: TParams, options?: Omit<UseQueryOptions<TData, Error>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<_tanstack_query_core.NoInfer<TData>, Error>;
|
|
236
|
-
/**
|
|
237
|
-
* Hook to create a mutation for calling PostgreSQL functions
|
|
238
|
-
* Useful for functions that modify data
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* ```tsx
|
|
242
|
-
* const createOrder = useRPCMutation('create_order')
|
|
243
|
-
*
|
|
244
|
-
* const handleSubmit = async () => {
|
|
245
|
-
* await createOrder.mutateAsync({
|
|
246
|
-
* user_id: 123,
|
|
247
|
-
* items: [{ product_id: 1, quantity: 2 }]
|
|
248
|
-
* })
|
|
249
|
-
* }
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
declare function useRPCMutation<TData = unknown, TParams extends Record<string, unknown> = Record<string, unknown>>(functionName: string, options?: Omit<UseMutationOptions<TData, Error, TParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<TData, Error, TParams, unknown>;
|
|
253
|
-
/**
|
|
254
|
-
* Hook to call multiple RPC functions in parallel
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```tsx
|
|
258
|
-
* const { data, isLoading } = useRPCBatch([
|
|
259
|
-
* { name: 'get_user_stats', params: { user_id: 123 } },
|
|
260
|
-
* { name: 'get_recent_orders', params: { limit: 10 } },
|
|
261
|
-
* ])
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
declare function useRPCBatch<TData = unknown>(calls: Array<{
|
|
265
|
-
name: string;
|
|
266
|
-
params?: Record<string, unknown>;
|
|
267
|
-
}>, options?: Omit<UseQueryOptions<TData[], Error, TData[], readonly unknown[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<TData[], Error>;
|
|
268
|
-
|
|
269
895
|
/**
|
|
270
896
|
* Simplified admin user type returned by authentication
|
|
271
897
|
*/
|
|
@@ -419,18 +1045,18 @@ interface UseUsersReturn {
|
|
|
419
1045
|
*/
|
|
420
1046
|
declare function useUsers(options?: UseUsersOptions): UseUsersReturn;
|
|
421
1047
|
|
|
422
|
-
interface
|
|
1048
|
+
interface UseClientKeysOptions {
|
|
423
1049
|
/**
|
|
424
|
-
* Whether to automatically fetch
|
|
1050
|
+
* Whether to automatically fetch client keys on mount
|
|
425
1051
|
* @default true
|
|
426
1052
|
*/
|
|
427
1053
|
autoFetch?: boolean;
|
|
428
1054
|
}
|
|
429
|
-
interface
|
|
1055
|
+
interface UseClientKeysReturn {
|
|
430
1056
|
/**
|
|
431
|
-
* Array of
|
|
1057
|
+
* Array of client keys
|
|
432
1058
|
*/
|
|
433
|
-
keys:
|
|
1059
|
+
keys: ClientKey[];
|
|
434
1060
|
/**
|
|
435
1061
|
* Whether keys are being fetched
|
|
436
1062
|
*/
|
|
@@ -440,46 +1066,46 @@ interface UseAPIKeysReturn {
|
|
|
440
1066
|
*/
|
|
441
1067
|
error: Error | null;
|
|
442
1068
|
/**
|
|
443
|
-
* Refetch
|
|
1069
|
+
* Refetch client keys
|
|
444
1070
|
*/
|
|
445
1071
|
refetch: () => Promise<void>;
|
|
446
1072
|
/**
|
|
447
|
-
* Create a new
|
|
1073
|
+
* Create a new client key
|
|
448
1074
|
*/
|
|
449
|
-
createKey: (request:
|
|
1075
|
+
createKey: (request: CreateClientKeyRequest) => Promise<{
|
|
450
1076
|
key: string;
|
|
451
|
-
keyData:
|
|
1077
|
+
keyData: ClientKey;
|
|
452
1078
|
}>;
|
|
453
1079
|
/**
|
|
454
|
-
* Update
|
|
1080
|
+
* Update a client key
|
|
455
1081
|
*/
|
|
456
1082
|
updateKey: (keyId: string, update: {
|
|
457
1083
|
name?: string;
|
|
458
1084
|
description?: string;
|
|
459
1085
|
}) => Promise<void>;
|
|
460
1086
|
/**
|
|
461
|
-
* Revoke
|
|
1087
|
+
* Revoke a client key
|
|
462
1088
|
*/
|
|
463
1089
|
revokeKey: (keyId: string) => Promise<void>;
|
|
464
1090
|
/**
|
|
465
|
-
* Delete
|
|
1091
|
+
* Delete a client key
|
|
466
1092
|
*/
|
|
467
1093
|
deleteKey: (keyId: string) => Promise<void>;
|
|
468
1094
|
}
|
|
469
1095
|
/**
|
|
470
|
-
* Hook for managing
|
|
1096
|
+
* Hook for managing client keys
|
|
471
1097
|
*
|
|
472
|
-
* Provides
|
|
1098
|
+
* Provides client key list and management functions.
|
|
473
1099
|
*
|
|
474
1100
|
* @example
|
|
475
1101
|
* ```tsx
|
|
476
|
-
* function
|
|
477
|
-
* const { keys, isLoading, createKey, revokeKey } =
|
|
1102
|
+
* function ClientKeyManager() {
|
|
1103
|
+
* const { keys, isLoading, createKey, revokeKey } = useClientKeys()
|
|
478
1104
|
*
|
|
479
1105
|
* const handleCreate = async () => {
|
|
480
1106
|
* const { key, keyData } = await createKey({
|
|
481
1107
|
* name: 'Backend Service',
|
|
482
|
-
* description: '
|
|
1108
|
+
* description: 'Client key for backend',
|
|
483
1109
|
* expires_at: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString()
|
|
484
1110
|
* })
|
|
485
1111
|
* alert(`Key created: ${key}`)
|
|
@@ -499,7 +1125,11 @@ interface UseAPIKeysReturn {
|
|
|
499
1125
|
* }
|
|
500
1126
|
* ```
|
|
501
1127
|
*/
|
|
502
|
-
declare function
|
|
1128
|
+
declare function useClientKeys(options?: UseClientKeysOptions): UseClientKeysReturn;
|
|
1129
|
+
/**
|
|
1130
|
+
* @deprecated Use useClientKeys instead
|
|
1131
|
+
*/
|
|
1132
|
+
declare const useAPIKeys: typeof useClientKeys;
|
|
503
1133
|
|
|
504
1134
|
/**
|
|
505
1135
|
* Admin Settings and Management Hooks
|
|
@@ -603,4 +1233,4 @@ interface UseWebhooksReturn {
|
|
|
603
1233
|
*/
|
|
604
1234
|
declare function useWebhooks(options?: UseWebhooksOptions): UseWebhooksReturn;
|
|
605
1235
|
|
|
606
|
-
export { FluxbaseProvider, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useCreateBucket, useDelete, useDeleteBucket, useFluxbaseClient, useFluxbaseQuery,
|
|
1236
|
+
export { type CaptchaState, FluxbaseProvider, type UseGraphQLMutationOptions, type UseGraphQLQueryOptions, isCaptchaRequiredForEndpoint, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useAuthConfig, useCaptcha, useCaptchaConfig, useClientKeys, useCreateBucket, useDelete, useDeleteBucket, 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, useTableInserts, useTableSubscription, useTableUpdates, useUpdate, useUpdateUser, useUpsert, useUser, useUsers, useWebhooks };
|