@fluxbase/sdk-react 0.0.7-rc.11 → 2026.1.1-rc.1
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 +638 -83
- package/dist/index.d.ts +638 -83
- package/dist/index.js +552 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +540 -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 +57 -18
- package/src/use-admin-auth.ts +62 -51
- 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, 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,503 @@ 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 available SAML SSO providers
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```tsx
|
|
187
|
+
* function SAMLProviderList() {
|
|
188
|
+
* const { data: providers, isLoading } = useSAMLProviders()
|
|
189
|
+
*
|
|
190
|
+
* if (isLoading) return <div>Loading...</div>
|
|
191
|
+
*
|
|
192
|
+
* return (
|
|
193
|
+
* <div>
|
|
194
|
+
* {providers?.map(provider => (
|
|
195
|
+
* <button key={provider.id} onClick={() => signInWithSAML(provider.name)}>
|
|
196
|
+
* Sign in with {provider.name}
|
|
197
|
+
* </button>
|
|
198
|
+
* ))}
|
|
199
|
+
* </div>
|
|
200
|
+
* )
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function useSAMLProviders(): _tanstack_react_query.UseQueryResult<SAMLProvider[], Error>;
|
|
205
|
+
/**
|
|
206
|
+
* Hook to get SAML login URL for a provider
|
|
207
|
+
*
|
|
208
|
+
* This hook returns a function to get the login URL for a specific provider.
|
|
209
|
+
* Use this when you need more control over the redirect behavior.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* function SAMLLoginButton({ provider }: { provider: string }) {
|
|
214
|
+
* const getSAMLLoginUrl = useGetSAMLLoginUrl()
|
|
215
|
+
*
|
|
216
|
+
* const handleClick = async () => {
|
|
217
|
+
* const { data, error } = await getSAMLLoginUrl.mutateAsync({
|
|
218
|
+
* provider,
|
|
219
|
+
* options: { redirectUrl: window.location.href }
|
|
220
|
+
* })
|
|
221
|
+
* if (!error) {
|
|
222
|
+
* window.location.href = data.url
|
|
223
|
+
* }
|
|
224
|
+
* }
|
|
225
|
+
*
|
|
226
|
+
* return <button onClick={handleClick}>Login with {provider}</button>
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare function useGetSAMLLoginUrl(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.DataResponse<_fluxbase_sdk.SAMLLoginResponse>, Error, {
|
|
231
|
+
provider: string;
|
|
232
|
+
options?: SAMLLoginOptions;
|
|
233
|
+
}, unknown>;
|
|
234
|
+
/**
|
|
235
|
+
* Hook to initiate SAML login (redirects to IdP)
|
|
236
|
+
*
|
|
237
|
+
* This hook returns a mutation that when called, redirects the user to the
|
|
238
|
+
* SAML Identity Provider for authentication.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```tsx
|
|
242
|
+
* function SAMLLoginButton() {
|
|
243
|
+
* const signInWithSAML = useSignInWithSAML()
|
|
244
|
+
*
|
|
245
|
+
* return (
|
|
246
|
+
* <button
|
|
247
|
+
* onClick={() => signInWithSAML.mutate({ provider: 'okta' })}
|
|
248
|
+
* disabled={signInWithSAML.isPending}
|
|
249
|
+
* >
|
|
250
|
+
* {signInWithSAML.isPending ? 'Redirecting...' : 'Sign in with Okta'}
|
|
251
|
+
* </button>
|
|
252
|
+
* )
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function useSignInWithSAML(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.DataResponse<{
|
|
257
|
+
provider: string;
|
|
258
|
+
url: string;
|
|
259
|
+
}>, Error, {
|
|
260
|
+
provider: string;
|
|
261
|
+
options?: SAMLLoginOptions;
|
|
262
|
+
}, unknown>;
|
|
263
|
+
/**
|
|
264
|
+
* Hook to handle SAML callback after IdP authentication
|
|
265
|
+
*
|
|
266
|
+
* Use this in your SAML callback page to complete the authentication flow.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```tsx
|
|
270
|
+
* function SAMLCallbackPage() {
|
|
271
|
+
* const handleCallback = useHandleSAMLCallback()
|
|
272
|
+
* const navigate = useNavigate()
|
|
273
|
+
*
|
|
274
|
+
* useEffect(() => {
|
|
275
|
+
* const params = new URLSearchParams(window.location.search)
|
|
276
|
+
* const samlResponse = params.get('SAMLResponse')
|
|
277
|
+
*
|
|
278
|
+
* if (samlResponse) {
|
|
279
|
+
* handleCallback.mutate(
|
|
280
|
+
* { samlResponse },
|
|
281
|
+
* {
|
|
282
|
+
* onSuccess: () => navigate('/dashboard'),
|
|
283
|
+
* onError: (error) => console.error('SAML login failed:', error)
|
|
284
|
+
* }
|
|
285
|
+
* )
|
|
286
|
+
* }
|
|
287
|
+
* }, [])
|
|
288
|
+
*
|
|
289
|
+
* if (handleCallback.isPending) {
|
|
290
|
+
* return <div>Completing sign in...</div>
|
|
291
|
+
* }
|
|
292
|
+
*
|
|
293
|
+
* if (handleCallback.isError) {
|
|
294
|
+
* return <div>Authentication failed: {handleCallback.error.message}</div>
|
|
295
|
+
* }
|
|
296
|
+
*
|
|
297
|
+
* return null
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
declare function useHandleSAMLCallback(): _tanstack_react_query.UseMutationResult<_fluxbase_sdk.FluxbaseAuthResponse, Error, {
|
|
302
|
+
samlResponse: string;
|
|
303
|
+
provider?: string;
|
|
304
|
+
}, unknown>;
|
|
305
|
+
/**
|
|
306
|
+
* Hook to get SAML Service Provider metadata URL
|
|
307
|
+
*
|
|
308
|
+
* Returns a function that generates the SP metadata URL for a given provider.
|
|
309
|
+
* Use this URL when configuring your SAML IdP.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```tsx
|
|
313
|
+
* function SAMLSetupInfo({ provider }: { provider: string }) {
|
|
314
|
+
* const getSAMLMetadataUrl = useSAMLMetadataUrl()
|
|
315
|
+
* const metadataUrl = getSAMLMetadataUrl(provider)
|
|
316
|
+
*
|
|
317
|
+
* return (
|
|
318
|
+
* <div>
|
|
319
|
+
* <p>SP Metadata URL:</p>
|
|
320
|
+
* <code>{metadataUrl}</code>
|
|
321
|
+
* </div>
|
|
322
|
+
* )
|
|
323
|
+
* }
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
declare function useSAMLMetadataUrl(): (provider: string) => string;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Options for useGraphQLQuery hook
|
|
330
|
+
*/
|
|
331
|
+
interface UseGraphQLQueryOptions<T> {
|
|
332
|
+
/**
|
|
333
|
+
* Variables to pass to the GraphQL query
|
|
334
|
+
*/
|
|
335
|
+
variables?: Record<string, unknown>;
|
|
336
|
+
/**
|
|
337
|
+
* Operation name when the document contains multiple operations
|
|
338
|
+
*/
|
|
339
|
+
operationName?: string;
|
|
340
|
+
/**
|
|
341
|
+
* Additional request options
|
|
342
|
+
*/
|
|
343
|
+
requestOptions?: GraphQLRequestOptions;
|
|
344
|
+
/**
|
|
345
|
+
* Whether the query is enabled
|
|
346
|
+
* @default true
|
|
347
|
+
*/
|
|
348
|
+
enabled?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Time in milliseconds after which the query is considered stale
|
|
351
|
+
* @default 0 (considered stale immediately)
|
|
352
|
+
*/
|
|
353
|
+
staleTime?: number;
|
|
354
|
+
/**
|
|
355
|
+
* Time in milliseconds after which inactive query data is garbage collected
|
|
356
|
+
* @default 5 minutes
|
|
357
|
+
*/
|
|
358
|
+
gcTime?: number;
|
|
359
|
+
/**
|
|
360
|
+
* Whether to refetch on window focus
|
|
361
|
+
* @default true
|
|
362
|
+
*/
|
|
363
|
+
refetchOnWindowFocus?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Transform function to process the response data
|
|
366
|
+
*/
|
|
367
|
+
select?: (data: T | undefined) => T | undefined;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Options for useGraphQLMutation hook
|
|
371
|
+
*/
|
|
372
|
+
interface UseGraphQLMutationOptions<T, V> {
|
|
373
|
+
/**
|
|
374
|
+
* Operation name when the document contains multiple operations
|
|
375
|
+
*/
|
|
376
|
+
operationName?: string;
|
|
377
|
+
/**
|
|
378
|
+
* Additional request options
|
|
379
|
+
*/
|
|
380
|
+
requestOptions?: GraphQLRequestOptions;
|
|
381
|
+
/**
|
|
382
|
+
* Callback when mutation succeeds
|
|
383
|
+
*/
|
|
384
|
+
onSuccess?: (data: T, variables: V) => void;
|
|
385
|
+
/**
|
|
386
|
+
* Callback when mutation fails
|
|
387
|
+
*/
|
|
388
|
+
onError?: (error: GraphQLError, variables: V) => void;
|
|
389
|
+
/**
|
|
390
|
+
* Query keys to invalidate on success
|
|
391
|
+
*/
|
|
392
|
+
invalidateQueries?: string[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Hook to execute GraphQL queries with React Query caching
|
|
396
|
+
*
|
|
397
|
+
* @typeParam T - The expected response data type
|
|
398
|
+
* @param queryKey - Unique key for caching (string or array)
|
|
399
|
+
* @param query - The GraphQL query string
|
|
400
|
+
* @param options - Query options including variables
|
|
401
|
+
* @returns React Query result object
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```tsx
|
|
405
|
+
* interface UsersQuery {
|
|
406
|
+
* users: Array<{ id: string; email: string }>
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* function UsersList() {
|
|
410
|
+
* const { data, isLoading } = useGraphQLQuery<UsersQuery>(
|
|
411
|
+
* 'users',
|
|
412
|
+
* `query { users { id email } }`
|
|
413
|
+
* )
|
|
414
|
+
*
|
|
415
|
+
* return <div>{data?.users.length} users</div>
|
|
416
|
+
* }
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```tsx
|
|
421
|
+
* // With variables
|
|
422
|
+
* const { data } = useGraphQLQuery<UserQuery>(
|
|
423
|
+
* ['user', userId],
|
|
424
|
+
* `query GetUser($id: ID!) { user(id: $id) { id email } }`,
|
|
425
|
+
* { variables: { id: userId } }
|
|
426
|
+
* )
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
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>;
|
|
430
|
+
/**
|
|
431
|
+
* Hook to execute GraphQL mutations
|
|
432
|
+
*
|
|
433
|
+
* @typeParam T - The expected response data type
|
|
434
|
+
* @typeParam V - The variables type
|
|
435
|
+
* @param mutation - The GraphQL mutation string
|
|
436
|
+
* @param options - Mutation options
|
|
437
|
+
* @returns React Query mutation result object
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```tsx
|
|
441
|
+
* interface CreateUserMutation {
|
|
442
|
+
* insertUser: { id: string; email: string }
|
|
443
|
+
* }
|
|
444
|
+
*
|
|
445
|
+
* interface CreateUserVariables {
|
|
446
|
+
* data: { email: string }
|
|
447
|
+
* }
|
|
448
|
+
*
|
|
449
|
+
* function CreateUserForm() {
|
|
450
|
+
* const mutation = useGraphQLMutation<CreateUserMutation, CreateUserVariables>(
|
|
451
|
+
* `mutation CreateUser($data: UserInput!) {
|
|
452
|
+
* insertUser(data: $data) { id email }
|
|
453
|
+
* }`,
|
|
454
|
+
* {
|
|
455
|
+
* onSuccess: (data) => console.log('Created:', data.insertUser),
|
|
456
|
+
* invalidateQueries: ['users']
|
|
457
|
+
* }
|
|
458
|
+
* )
|
|
459
|
+
*
|
|
460
|
+
* const handleSubmit = (email: string) => {
|
|
461
|
+
* mutation.mutate({ data: { email } })
|
|
462
|
+
* }
|
|
463
|
+
*
|
|
464
|
+
* return (
|
|
465
|
+
* <button
|
|
466
|
+
* onClick={() => handleSubmit('new@example.com')}
|
|
467
|
+
* disabled={mutation.isPending}
|
|
468
|
+
* >
|
|
469
|
+
* Create User
|
|
470
|
+
* </button>
|
|
471
|
+
* )
|
|
472
|
+
* }
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
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>;
|
|
476
|
+
/**
|
|
477
|
+
* Hook to fetch the GraphQL schema via introspection
|
|
478
|
+
*
|
|
479
|
+
* @param options - Query options
|
|
480
|
+
* @returns React Query result with schema introspection data
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* ```tsx
|
|
484
|
+
* function SchemaExplorer() {
|
|
485
|
+
* const { data, isLoading } = useGraphQLIntrospection()
|
|
486
|
+
*
|
|
487
|
+
* if (isLoading) return <div>Loading schema...</div>
|
|
488
|
+
*
|
|
489
|
+
* return (
|
|
490
|
+
* <div>
|
|
491
|
+
* <p>Query type: {data?.__schema.queryType.name}</p>
|
|
492
|
+
* <p>Types: {data?.__schema.types.length}</p>
|
|
493
|
+
* </div>
|
|
494
|
+
* )
|
|
495
|
+
* }
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
declare function useGraphQLIntrospection(options?: {
|
|
499
|
+
enabled?: boolean;
|
|
500
|
+
staleTime?: number;
|
|
501
|
+
requestOptions?: GraphQLRequestOptions;
|
|
502
|
+
}): _tanstack_react_query.UseQueryResult<{
|
|
503
|
+
__schema: _fluxbase_sdk.IntrospectionSchema;
|
|
504
|
+
} | undefined, Error>;
|
|
505
|
+
/**
|
|
506
|
+
* Hook to execute raw GraphQL operations (query or mutation)
|
|
507
|
+
*
|
|
508
|
+
* This is a lower-level hook that doesn't use React Query caching.
|
|
509
|
+
* Useful for one-off operations or when you need full control.
|
|
510
|
+
*
|
|
511
|
+
* @returns Functions to execute queries and mutations
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```tsx
|
|
515
|
+
* function AdminPanel() {
|
|
516
|
+
* const { executeQuery, executeMutation } = useGraphQL()
|
|
517
|
+
*
|
|
518
|
+
* const handleExport = async () => {
|
|
519
|
+
* const result = await executeQuery<ExportData>(
|
|
520
|
+
* `query { exportAllData { url } }`
|
|
521
|
+
* )
|
|
522
|
+
* if (result.data) {
|
|
523
|
+
* window.open(result.data.exportAllData.url)
|
|
524
|
+
* }
|
|
525
|
+
* }
|
|
526
|
+
*
|
|
527
|
+
* return <button onClick={handleExport}>Export Data</button>
|
|
528
|
+
* }
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
declare function useGraphQL(): {
|
|
532
|
+
/**
|
|
533
|
+
* Execute a GraphQL query
|
|
534
|
+
*/
|
|
535
|
+
executeQuery: <T = unknown>(query: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
536
|
+
/**
|
|
537
|
+
* Execute a GraphQL mutation
|
|
538
|
+
*/
|
|
539
|
+
executeMutation: <T = unknown>(mutation: string, variables?: Record<string, unknown>, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
540
|
+
/**
|
|
541
|
+
* Execute a GraphQL operation with an explicit operation name
|
|
542
|
+
*/
|
|
543
|
+
execute: <T = unknown>(document: string, variables?: Record<string, unknown>, operationName?: string, options?: GraphQLRequestOptions) => Promise<GraphQLResponse<T>>;
|
|
544
|
+
/**
|
|
545
|
+
* Fetch the GraphQL schema via introspection
|
|
546
|
+
*/
|
|
547
|
+
introspect: (options?: GraphQLRequestOptions) => Promise<GraphQLResponse<{
|
|
548
|
+
__schema: _fluxbase_sdk.IntrospectionSchema;
|
|
549
|
+
}>>;
|
|
550
|
+
};
|
|
551
|
+
|
|
65
552
|
interface UseFluxbaseQueryOptions<T> extends Omit<UseQueryOptions<T[], Error>, 'queryKey' | 'queryFn'> {
|
|
66
553
|
/**
|
|
67
554
|
* Custom query key. If not provided, will use table name and filters.
|
|
@@ -108,7 +595,7 @@ interface UseRealtimeOptions {
|
|
|
108
595
|
/**
|
|
109
596
|
* Event type to listen for ('INSERT', 'UPDATE', 'DELETE', or '*' for all)
|
|
110
597
|
*/
|
|
111
|
-
event?:
|
|
598
|
+
event?: "INSERT" | "UPDATE" | "DELETE" | "*";
|
|
112
599
|
/**
|
|
113
600
|
* Callback function when an event is received
|
|
114
601
|
*/
|
|
@@ -140,40 +627,93 @@ declare function useRealtime(options: UseRealtimeOptions): {
|
|
|
140
627
|
* @param table - Table name (with optional schema, e.g., 'public.products')
|
|
141
628
|
* @param options - Subscription options
|
|
142
629
|
*/
|
|
143
|
-
declare function useTableSubscription(table: string, options?: Omit<UseRealtimeOptions,
|
|
630
|
+
declare function useTableSubscription(table: string, options?: Omit<UseRealtimeOptions, "channel">): {
|
|
144
631
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
145
632
|
};
|
|
146
633
|
/**
|
|
147
634
|
* Hook to subscribe to INSERT events on a table
|
|
148
635
|
*/
|
|
149
|
-
declare function useTableInserts(table: string, callback: (payload:
|
|
636
|
+
declare function useTableInserts(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
150
637
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
151
638
|
};
|
|
152
639
|
/**
|
|
153
640
|
* Hook to subscribe to UPDATE events on a table
|
|
154
641
|
*/
|
|
155
|
-
declare function useTableUpdates(table: string, callback: (payload:
|
|
642
|
+
declare function useTableUpdates(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
156
643
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
157
644
|
};
|
|
158
645
|
/**
|
|
159
646
|
* Hook to subscribe to DELETE events on a table
|
|
160
647
|
*/
|
|
161
|
-
declare function useTableDeletes(table: string, callback: (payload:
|
|
648
|
+
declare function useTableDeletes(table: string, callback: (payload: RealtimePostgresChangesPayload) => void, options?: Omit<UseRealtimeOptions, "channel" | "event" | "callback">): {
|
|
162
649
|
channel: _fluxbase_sdk.RealtimeChannel | null;
|
|
163
650
|
};
|
|
164
651
|
|
|
165
652
|
/**
|
|
166
653
|
* Hook to list files in a bucket
|
|
167
654
|
*/
|
|
168
|
-
declare function useStorageList(bucket: string, options?: ListOptions & Omit<UseQueryOptions<any[], Error>,
|
|
655
|
+
declare function useStorageList(bucket: string, options?: ListOptions & Omit<UseQueryOptions<any[], Error>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<any[], Error>;
|
|
169
656
|
/**
|
|
170
657
|
* Hook to upload a file to a bucket
|
|
658
|
+
*
|
|
659
|
+
* Note: You can track upload progress by passing an `onUploadProgress` callback in the options:
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```tsx
|
|
663
|
+
* const upload = useStorageUpload('avatars')
|
|
664
|
+
*
|
|
665
|
+
* upload.mutate({
|
|
666
|
+
* path: 'user.jpg',
|
|
667
|
+
* file: file,
|
|
668
|
+
* options: {
|
|
669
|
+
* onUploadProgress: (progress) => {
|
|
670
|
+
* console.log(`${progress.percentage}% uploaded`)
|
|
671
|
+
* }
|
|
672
|
+
* }
|
|
673
|
+
* })
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* For automatic progress state management, use `useStorageUploadWithProgress` instead.
|
|
171
677
|
*/
|
|
172
|
-
declare function useStorageUpload(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
678
|
+
declare function useStorageUpload(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
679
|
+
id: string;
|
|
680
|
+
path: string;
|
|
681
|
+
fullPath: string;
|
|
682
|
+
} | null, Error, {
|
|
173
683
|
path: string;
|
|
174
684
|
file: File | Blob | ArrayBuffer;
|
|
175
685
|
options?: UploadOptions;
|
|
176
686
|
}, unknown>;
|
|
687
|
+
/**
|
|
688
|
+
* Hook to upload a file to a bucket with built-in progress tracking
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* ```tsx
|
|
692
|
+
* const { upload, progress, reset } = useStorageUploadWithProgress('avatars')
|
|
693
|
+
*
|
|
694
|
+
* // Upload with automatic progress tracking
|
|
695
|
+
* upload.mutate({
|
|
696
|
+
* path: 'user.jpg',
|
|
697
|
+
* file: file
|
|
698
|
+
* })
|
|
699
|
+
*
|
|
700
|
+
* // Display progress
|
|
701
|
+
* console.log(progress) // { loaded: 1024, total: 2048, percentage: 50 }
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
declare function useStorageUploadWithProgress(bucket: string): {
|
|
705
|
+
upload: _tanstack_react_query.UseMutationResult<{
|
|
706
|
+
id: string;
|
|
707
|
+
path: string;
|
|
708
|
+
fullPath: string;
|
|
709
|
+
} | null, Error, {
|
|
710
|
+
path: string;
|
|
711
|
+
file: File | Blob | ArrayBuffer;
|
|
712
|
+
options?: Omit<UploadOptions, "onUploadProgress">;
|
|
713
|
+
}, unknown>;
|
|
714
|
+
progress: UploadProgress | null;
|
|
715
|
+
reset: () => void;
|
|
716
|
+
};
|
|
177
717
|
/**
|
|
178
718
|
* Hook to download a file from a bucket
|
|
179
719
|
*/
|
|
@@ -186,21 +726,78 @@ declare function useStorageDelete(bucket: string): _tanstack_react_query.UseMuta
|
|
|
186
726
|
* Hook to get a public URL for a file
|
|
187
727
|
*/
|
|
188
728
|
declare function useStoragePublicUrl(bucket: string, path: string | null): string | null;
|
|
729
|
+
/**
|
|
730
|
+
* Hook to get a public URL for an image with transformations applied
|
|
731
|
+
*
|
|
732
|
+
* Only works for image files (JPEG, PNG, WebP, GIF, AVIF, etc.)
|
|
733
|
+
*
|
|
734
|
+
* @param bucket - The storage bucket name
|
|
735
|
+
* @param path - The file path (or null to disable)
|
|
736
|
+
* @param transform - Transformation options (width, height, format, quality, fit)
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```tsx
|
|
740
|
+
* function ImageThumbnail({ path }: { path: string }) {
|
|
741
|
+
* const url = useStorageTransformUrl('images', path, {
|
|
742
|
+
* width: 300,
|
|
743
|
+
* height: 200,
|
|
744
|
+
* format: 'webp',
|
|
745
|
+
* quality: 85,
|
|
746
|
+
* fit: 'cover'
|
|
747
|
+
* });
|
|
748
|
+
*
|
|
749
|
+
* return <img src={url || ''} alt="Thumbnail" />;
|
|
750
|
+
* }
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
753
|
+
declare function useStorageTransformUrl(bucket: string, path: string | null, transform: TransformOptions): string | null;
|
|
189
754
|
/**
|
|
190
755
|
* Hook to create a signed URL
|
|
756
|
+
*
|
|
757
|
+
* @deprecated Use useStorageSignedUrlWithOptions for more control including transforms
|
|
191
758
|
*/
|
|
192
759
|
declare function useStorageSignedUrl(bucket: string, path: string | null, expiresIn?: number): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
760
|
+
/**
|
|
761
|
+
* Hook to create a signed URL with full options including image transformations
|
|
762
|
+
*
|
|
763
|
+
* @param bucket - The storage bucket name
|
|
764
|
+
* @param path - The file path (or null to disable)
|
|
765
|
+
* @param options - Signed URL options including expiration and transforms
|
|
766
|
+
*
|
|
767
|
+
* @example
|
|
768
|
+
* ```tsx
|
|
769
|
+
* function SecureThumbnail({ path }: { path: string }) {
|
|
770
|
+
* const { data: url } = useStorageSignedUrlWithOptions('images', path, {
|
|
771
|
+
* expiresIn: 3600,
|
|
772
|
+
* transform: {
|
|
773
|
+
* width: 400,
|
|
774
|
+
* height: 300,
|
|
775
|
+
* format: 'webp',
|
|
776
|
+
* quality: 85,
|
|
777
|
+
* fit: 'cover'
|
|
778
|
+
* }
|
|
779
|
+
* });
|
|
780
|
+
*
|
|
781
|
+
* return <img src={url || ''} alt="Secure Thumbnail" />;
|
|
782
|
+
* }
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
785
|
+
declare function useStorageSignedUrlWithOptions(bucket: string, path: string | null, options?: SignedUrlOptions): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
193
786
|
/**
|
|
194
787
|
* Hook to move a file
|
|
195
788
|
*/
|
|
196
|
-
declare function useStorageMove(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
789
|
+
declare function useStorageMove(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
790
|
+
message: string;
|
|
791
|
+
} | null, Error, {
|
|
197
792
|
fromPath: string;
|
|
198
793
|
toPath: string;
|
|
199
794
|
}, unknown>;
|
|
200
795
|
/**
|
|
201
796
|
* Hook to copy a file
|
|
202
797
|
*/
|
|
203
|
-
declare function useStorageCopy(bucket: string): _tanstack_react_query.UseMutationResult<
|
|
798
|
+
declare function useStorageCopy(bucket: string): _tanstack_react_query.UseMutationResult<{
|
|
799
|
+
path: string;
|
|
800
|
+
} | null, Error, {
|
|
204
801
|
fromPath: string;
|
|
205
802
|
toPath: string;
|
|
206
803
|
}, unknown>;
|
|
@@ -220,52 +817,6 @@ declare function useCreateBucket(): _tanstack_react_query.UseMutationResult<void
|
|
|
220
817
|
*/
|
|
221
818
|
declare function useDeleteBucket(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
222
819
|
|
|
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
820
|
/**
|
|
270
821
|
* Simplified admin user type returned by authentication
|
|
271
822
|
*/
|
|
@@ -419,18 +970,18 @@ interface UseUsersReturn {
|
|
|
419
970
|
*/
|
|
420
971
|
declare function useUsers(options?: UseUsersOptions): UseUsersReturn;
|
|
421
972
|
|
|
422
|
-
interface
|
|
973
|
+
interface UseClientKeysOptions {
|
|
423
974
|
/**
|
|
424
|
-
* Whether to automatically fetch
|
|
975
|
+
* Whether to automatically fetch client keys on mount
|
|
425
976
|
* @default true
|
|
426
977
|
*/
|
|
427
978
|
autoFetch?: boolean;
|
|
428
979
|
}
|
|
429
|
-
interface
|
|
980
|
+
interface UseClientKeysReturn {
|
|
430
981
|
/**
|
|
431
|
-
* Array of
|
|
982
|
+
* Array of client keys
|
|
432
983
|
*/
|
|
433
|
-
keys:
|
|
984
|
+
keys: ClientKey[];
|
|
434
985
|
/**
|
|
435
986
|
* Whether keys are being fetched
|
|
436
987
|
*/
|
|
@@ -440,46 +991,46 @@ interface UseAPIKeysReturn {
|
|
|
440
991
|
*/
|
|
441
992
|
error: Error | null;
|
|
442
993
|
/**
|
|
443
|
-
* Refetch
|
|
994
|
+
* Refetch client keys
|
|
444
995
|
*/
|
|
445
996
|
refetch: () => Promise<void>;
|
|
446
997
|
/**
|
|
447
|
-
* Create a new
|
|
998
|
+
* Create a new client key
|
|
448
999
|
*/
|
|
449
|
-
createKey: (request:
|
|
1000
|
+
createKey: (request: CreateClientKeyRequest) => Promise<{
|
|
450
1001
|
key: string;
|
|
451
|
-
keyData:
|
|
1002
|
+
keyData: ClientKey;
|
|
452
1003
|
}>;
|
|
453
1004
|
/**
|
|
454
|
-
* Update
|
|
1005
|
+
* Update a client key
|
|
455
1006
|
*/
|
|
456
1007
|
updateKey: (keyId: string, update: {
|
|
457
1008
|
name?: string;
|
|
458
1009
|
description?: string;
|
|
459
1010
|
}) => Promise<void>;
|
|
460
1011
|
/**
|
|
461
|
-
* Revoke
|
|
1012
|
+
* Revoke a client key
|
|
462
1013
|
*/
|
|
463
1014
|
revokeKey: (keyId: string) => Promise<void>;
|
|
464
1015
|
/**
|
|
465
|
-
* Delete
|
|
1016
|
+
* Delete a client key
|
|
466
1017
|
*/
|
|
467
1018
|
deleteKey: (keyId: string) => Promise<void>;
|
|
468
1019
|
}
|
|
469
1020
|
/**
|
|
470
|
-
* Hook for managing
|
|
1021
|
+
* Hook for managing client keys
|
|
471
1022
|
*
|
|
472
|
-
* Provides
|
|
1023
|
+
* Provides client key list and management functions.
|
|
473
1024
|
*
|
|
474
1025
|
* @example
|
|
475
1026
|
* ```tsx
|
|
476
|
-
* function
|
|
477
|
-
* const { keys, isLoading, createKey, revokeKey } =
|
|
1027
|
+
* function ClientKeyManager() {
|
|
1028
|
+
* const { keys, isLoading, createKey, revokeKey } = useClientKeys()
|
|
478
1029
|
*
|
|
479
1030
|
* const handleCreate = async () => {
|
|
480
1031
|
* const { key, keyData } = await createKey({
|
|
481
1032
|
* name: 'Backend Service',
|
|
482
|
-
* description: '
|
|
1033
|
+
* description: 'Client key for backend',
|
|
483
1034
|
* expires_at: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString()
|
|
484
1035
|
* })
|
|
485
1036
|
* alert(`Key created: ${key}`)
|
|
@@ -499,7 +1050,11 @@ interface UseAPIKeysReturn {
|
|
|
499
1050
|
* }
|
|
500
1051
|
* ```
|
|
501
1052
|
*/
|
|
502
|
-
declare function
|
|
1053
|
+
declare function useClientKeys(options?: UseClientKeysOptions): UseClientKeysReturn;
|
|
1054
|
+
/**
|
|
1055
|
+
* @deprecated Use useClientKeys instead
|
|
1056
|
+
*/
|
|
1057
|
+
declare const useAPIKeys: typeof useClientKeys;
|
|
503
1058
|
|
|
504
1059
|
/**
|
|
505
1060
|
* Admin Settings and Management Hooks
|
|
@@ -603,4 +1158,4 @@ interface UseWebhooksReturn {
|
|
|
603
1158
|
*/
|
|
604
1159
|
declare function useWebhooks(options?: UseWebhooksOptions): UseWebhooksReturn;
|
|
605
1160
|
|
|
606
|
-
export { FluxbaseProvider, useAPIKeys, useAdminAuth, useAppSettings, useAuth, useCreateBucket, useDelete, useDeleteBucket, useFluxbaseClient, useFluxbaseQuery,
|
|
1161
|
+
export { type CaptchaState, FluxbaseProvider, type UseGraphQLMutationOptions, type UseGraphQLQueryOptions, isCaptchaRequiredForEndpoint, useAPIKeys, useAdminAuth, useAppSettings, useAuth, 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 };
|