@fluxbase/sdk 0.0.1-rc.24 → 0.0.1-rc.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +168 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -103
- package/dist/index.d.ts +144 -103
- package/dist/index.js +168 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -530,32 +530,6 @@ interface CustomSetting {
|
|
|
530
530
|
created_at: string;
|
|
531
531
|
updated_at: string;
|
|
532
532
|
}
|
|
533
|
-
/**
|
|
534
|
-
* Request to create a custom setting
|
|
535
|
-
*/
|
|
536
|
-
interface CreateCustomSettingRequest {
|
|
537
|
-
key: string;
|
|
538
|
-
value: Record<string, unknown>;
|
|
539
|
-
value_type?: 'string' | 'number' | 'boolean' | 'json';
|
|
540
|
-
description?: string;
|
|
541
|
-
editable_by?: string[];
|
|
542
|
-
metadata?: Record<string, unknown>;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Request to update a custom setting
|
|
546
|
-
*/
|
|
547
|
-
interface UpdateCustomSettingRequest {
|
|
548
|
-
value: Record<string, unknown>;
|
|
549
|
-
description?: string;
|
|
550
|
-
editable_by?: string[];
|
|
551
|
-
metadata?: Record<string, unknown>;
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Response containing all custom settings
|
|
555
|
-
*/
|
|
556
|
-
interface ListCustomSettingsResponse {
|
|
557
|
-
settings: CustomSetting[];
|
|
558
|
-
}
|
|
559
533
|
/**
|
|
560
534
|
* Authentication settings for the application
|
|
561
535
|
*/
|
|
@@ -2285,104 +2259,83 @@ declare class AppSettingsManager {
|
|
|
2285
2259
|
* ```
|
|
2286
2260
|
*/
|
|
2287
2261
|
setEmailVerificationRequired(required: boolean): Promise<AppSettings>;
|
|
2288
|
-
}
|
|
2289
|
-
/**
|
|
2290
|
-
* Custom Settings Manager
|
|
2291
|
-
*
|
|
2292
|
-
* Manages custom admin-created settings with flexible key-value storage.
|
|
2293
|
-
* Unlike system settings, custom settings allow admins to create arbitrary configuration entries
|
|
2294
|
-
* with role-based editing permissions.
|
|
2295
|
-
*
|
|
2296
|
-
* @example
|
|
2297
|
-
* ```typescript
|
|
2298
|
-
* const custom = client.admin.settings.custom
|
|
2299
|
-
*
|
|
2300
|
-
* // Create a custom setting
|
|
2301
|
-
* const setting = await custom.create({
|
|
2302
|
-
* key: 'feature.dark_mode',
|
|
2303
|
-
* value: { enabled: true, theme: 'dark' },
|
|
2304
|
-
* value_type: 'json',
|
|
2305
|
-
* description: 'Dark mode configuration',
|
|
2306
|
-
* editable_by: ['dashboard_admin', 'admin']
|
|
2307
|
-
* })
|
|
2308
|
-
*
|
|
2309
|
-
* // List all custom settings
|
|
2310
|
-
* const { settings } = await custom.list()
|
|
2311
|
-
*
|
|
2312
|
-
* // Get specific setting
|
|
2313
|
-
* const darkMode = await custom.get('feature.dark_mode')
|
|
2314
|
-
*
|
|
2315
|
-
* // Update setting
|
|
2316
|
-
* await custom.update('feature.dark_mode', {
|
|
2317
|
-
* value: { enabled: false, theme: 'light' }
|
|
2318
|
-
* })
|
|
2319
|
-
*
|
|
2320
|
-
* // Delete setting
|
|
2321
|
-
* await custom.delete('feature.dark_mode')
|
|
2322
|
-
* ```
|
|
2323
|
-
*/
|
|
2324
|
-
declare class CustomSettingsManager {
|
|
2325
|
-
private fetch;
|
|
2326
|
-
constructor(fetch: FluxbaseFetch);
|
|
2327
2262
|
/**
|
|
2328
|
-
*
|
|
2263
|
+
* Get a specific custom setting's value only (without metadata)
|
|
2329
2264
|
*
|
|
2330
|
-
*
|
|
2331
|
-
*
|
|
2265
|
+
* Convenience method that returns just the value field instead of the full CustomSetting object.
|
|
2266
|
+
*
|
|
2267
|
+
* @param key - Setting key (e.g., 'billing.tiers', 'features.beta_enabled')
|
|
2268
|
+
* @returns Promise resolving to the setting's value
|
|
2332
2269
|
*
|
|
2333
2270
|
* @example
|
|
2334
2271
|
* ```typescript
|
|
2335
|
-
* const
|
|
2336
|
-
*
|
|
2337
|
-
* value: { free: 1000, pro: 10000, enterprise: 100000 },
|
|
2338
|
-
* value_type: 'json',
|
|
2339
|
-
* description: 'API request quotas by tier',
|
|
2340
|
-
* metadata: { category: 'billing' }
|
|
2341
|
-
* })
|
|
2272
|
+
* const tiers = await client.admin.settings.app.getSetting('billing.tiers')
|
|
2273
|
+
* console.log(tiers) // { free: 1000, pro: 10000, enterprise: 100000 }
|
|
2342
2274
|
* ```
|
|
2343
2275
|
*/
|
|
2344
|
-
|
|
2276
|
+
getSetting(key: string): Promise<any>;
|
|
2345
2277
|
/**
|
|
2346
|
-
*
|
|
2278
|
+
* Get multiple custom settings' values by keys
|
|
2347
2279
|
*
|
|
2348
|
-
*
|
|
2280
|
+
* Fetches multiple settings in a single request and returns only their values.
|
|
2281
|
+
*
|
|
2282
|
+
* @param keys - Array of setting keys to fetch
|
|
2283
|
+
* @returns Promise resolving to object mapping keys to values
|
|
2349
2284
|
*
|
|
2350
2285
|
* @example
|
|
2351
2286
|
* ```typescript
|
|
2352
|
-
* const
|
|
2353
|
-
*
|
|
2287
|
+
* const values = await client.admin.settings.app.getSettings([
|
|
2288
|
+
* 'billing.tiers',
|
|
2289
|
+
* 'features.beta_enabled'
|
|
2290
|
+
* ])
|
|
2291
|
+
* console.log(values)
|
|
2292
|
+
* // {
|
|
2293
|
+
* // 'billing.tiers': { free: 1000, pro: 10000 },
|
|
2294
|
+
* // 'features.beta_enabled': { enabled: true }
|
|
2295
|
+
* // }
|
|
2354
2296
|
* ```
|
|
2355
2297
|
*/
|
|
2356
|
-
|
|
2298
|
+
getSettings(keys: string[]): Promise<Record<string, any>>;
|
|
2357
2299
|
/**
|
|
2358
|
-
*
|
|
2300
|
+
* Set or create a custom setting
|
|
2301
|
+
*
|
|
2302
|
+
* Creates a new custom setting or updates an existing one.
|
|
2359
2303
|
*
|
|
2360
|
-
* @param key - Setting key
|
|
2304
|
+
* @param key - Setting key
|
|
2305
|
+
* @param value - Setting value (any JSON-serializable value)
|
|
2306
|
+
* @param options - Optional configuration (description, is_public, is_secret, etc.)
|
|
2361
2307
|
* @returns Promise resolving to CustomSetting
|
|
2362
2308
|
*
|
|
2363
2309
|
* @example
|
|
2364
2310
|
* ```typescript
|
|
2365
|
-
*
|
|
2366
|
-
*
|
|
2311
|
+
* await client.admin.settings.app.setSetting('billing.tiers', {
|
|
2312
|
+
* free: 1000,
|
|
2313
|
+
* pro: 10000,
|
|
2314
|
+
* enterprise: 100000
|
|
2315
|
+
* }, {
|
|
2316
|
+
* description: 'API quotas per billing tier',
|
|
2317
|
+
* is_public: false
|
|
2318
|
+
* })
|
|
2367
2319
|
* ```
|
|
2368
2320
|
*/
|
|
2369
|
-
|
|
2321
|
+
setSetting(key: string, value: any, options?: {
|
|
2322
|
+
description?: string;
|
|
2323
|
+
is_public?: boolean;
|
|
2324
|
+
is_secret?: boolean;
|
|
2325
|
+
value_type?: string;
|
|
2326
|
+
}): Promise<CustomSetting>;
|
|
2370
2327
|
/**
|
|
2371
|
-
*
|
|
2328
|
+
* List all custom settings
|
|
2372
2329
|
*
|
|
2373
|
-
* @
|
|
2374
|
-
* @param request - Update request with new values
|
|
2375
|
-
* @returns Promise resolving to CustomSetting
|
|
2330
|
+
* @returns Promise resolving to array of CustomSetting objects
|
|
2376
2331
|
*
|
|
2377
2332
|
* @example
|
|
2378
2333
|
* ```typescript
|
|
2379
|
-
* const
|
|
2380
|
-
*
|
|
2381
|
-
* description: 'Updated description'
|
|
2382
|
-
* })
|
|
2334
|
+
* const settings = await client.admin.settings.app.listSettings()
|
|
2335
|
+
* settings.forEach(s => console.log(s.key, s.value))
|
|
2383
2336
|
* ```
|
|
2384
2337
|
*/
|
|
2385
|
-
|
|
2338
|
+
listSettings(): Promise<CustomSetting[]>;
|
|
2386
2339
|
/**
|
|
2387
2340
|
* Delete a custom setting
|
|
2388
2341
|
*
|
|
@@ -2391,10 +2344,10 @@ declare class CustomSettingsManager {
|
|
|
2391
2344
|
*
|
|
2392
2345
|
* @example
|
|
2393
2346
|
* ```typescript
|
|
2394
|
-
* await client.admin.settings.
|
|
2347
|
+
* await client.admin.settings.app.deleteSetting('billing.tiers')
|
|
2395
2348
|
* ```
|
|
2396
2349
|
*/
|
|
2397
|
-
|
|
2350
|
+
deleteSetting(key: string): Promise<void>;
|
|
2398
2351
|
}
|
|
2399
2352
|
/**
|
|
2400
2353
|
* Email Template Manager
|
|
@@ -2511,7 +2464,8 @@ declare class EmailTemplateManager {
|
|
|
2511
2464
|
/**
|
|
2512
2465
|
* Settings Manager
|
|
2513
2466
|
*
|
|
2514
|
-
* Provides access to system-level
|
|
2467
|
+
* Provides access to system-level and application-level settings.
|
|
2468
|
+
* AppSettingsManager now handles both structured framework settings and custom key-value settings.
|
|
2515
2469
|
*
|
|
2516
2470
|
* @example
|
|
2517
2471
|
* ```typescript
|
|
@@ -2520,19 +2474,104 @@ declare class EmailTemplateManager {
|
|
|
2520
2474
|
* // Access system settings
|
|
2521
2475
|
* const systemSettings = await settings.system.list()
|
|
2522
2476
|
*
|
|
2523
|
-
* // Access app settings
|
|
2477
|
+
* // Access app settings (structured)
|
|
2524
2478
|
* const appSettings = await settings.app.get()
|
|
2479
|
+
* await settings.app.enableSignup()
|
|
2525
2480
|
*
|
|
2526
|
-
* // Access custom settings
|
|
2527
|
-
*
|
|
2481
|
+
* // Access custom settings (key-value)
|
|
2482
|
+
* await settings.app.setSetting('billing.tiers', { free: 1000, pro: 10000 })
|
|
2483
|
+
* const tiers = await settings.app.getSetting('billing.tiers')
|
|
2528
2484
|
* ```
|
|
2529
2485
|
*/
|
|
2530
2486
|
declare class FluxbaseSettings {
|
|
2531
2487
|
system: SystemSettingsManager;
|
|
2532
2488
|
app: AppSettingsManager;
|
|
2533
|
-
custom: CustomSettingsManager;
|
|
2534
2489
|
constructor(fetch: FluxbaseFetch);
|
|
2535
2490
|
}
|
|
2491
|
+
/**
|
|
2492
|
+
* Public Settings Client
|
|
2493
|
+
*
|
|
2494
|
+
* Provides read-only access to public settings for non-admin users.
|
|
2495
|
+
* Access is controlled by RLS policies on the app.settings table.
|
|
2496
|
+
*
|
|
2497
|
+
* @example
|
|
2498
|
+
* ```typescript
|
|
2499
|
+
* const client = new FluxbaseClient(url, userToken)
|
|
2500
|
+
*
|
|
2501
|
+
* // Get single public setting
|
|
2502
|
+
* const betaEnabled = await client.settings.get('features.beta_enabled')
|
|
2503
|
+
* console.log(betaEnabled) // { enabled: true }
|
|
2504
|
+
*
|
|
2505
|
+
* // Get multiple public settings
|
|
2506
|
+
* const values = await client.settings.getMany([
|
|
2507
|
+
* 'features.beta_enabled',
|
|
2508
|
+
* 'features.dark_mode',
|
|
2509
|
+
* 'public.app_version'
|
|
2510
|
+
* ])
|
|
2511
|
+
* console.log(values)
|
|
2512
|
+
* // {
|
|
2513
|
+
* // 'features.beta_enabled': { enabled: true },
|
|
2514
|
+
* // 'features.dark_mode': { enabled: false },
|
|
2515
|
+
* // 'public.app_version': '1.0.0'
|
|
2516
|
+
* // }
|
|
2517
|
+
* ```
|
|
2518
|
+
*/
|
|
2519
|
+
declare class SettingsClient {
|
|
2520
|
+
private fetch;
|
|
2521
|
+
constructor(fetch: FluxbaseFetch);
|
|
2522
|
+
/**
|
|
2523
|
+
* Get a single setting's value
|
|
2524
|
+
*
|
|
2525
|
+
* Returns only the value field of the setting.
|
|
2526
|
+
* Access is controlled by RLS policies - will return 403 if the user
|
|
2527
|
+
* doesn't have permission to read the setting.
|
|
2528
|
+
*
|
|
2529
|
+
* @param key - Setting key (e.g., 'features.beta_enabled')
|
|
2530
|
+
* @returns Promise resolving to the setting's value
|
|
2531
|
+
* @throws Error if setting doesn't exist or user lacks permission
|
|
2532
|
+
*
|
|
2533
|
+
* @example
|
|
2534
|
+
* ```typescript
|
|
2535
|
+
* // Get public setting (any user)
|
|
2536
|
+
* const value = await client.settings.get('features.beta_enabled')
|
|
2537
|
+
* console.log(value) // { enabled: true }
|
|
2538
|
+
*
|
|
2539
|
+
* // Get restricted setting (requires permission)
|
|
2540
|
+
* try {
|
|
2541
|
+
* const secret = await client.settings.get('internal.api_key')
|
|
2542
|
+
* } catch (error) {
|
|
2543
|
+
* console.error('Access denied:', error)
|
|
2544
|
+
* }
|
|
2545
|
+
* ```
|
|
2546
|
+
*/
|
|
2547
|
+
get(key: string): Promise<any>;
|
|
2548
|
+
/**
|
|
2549
|
+
* Get multiple settings' values by keys
|
|
2550
|
+
*
|
|
2551
|
+
* Fetches multiple settings in a single request.
|
|
2552
|
+
* Only returns settings the user has permission to read based on RLS policies.
|
|
2553
|
+
* Settings the user can't access will be omitted from the result (no error thrown).
|
|
2554
|
+
*
|
|
2555
|
+
* @param keys - Array of setting keys to fetch
|
|
2556
|
+
* @returns Promise resolving to object mapping keys to values
|
|
2557
|
+
*
|
|
2558
|
+
* @example
|
|
2559
|
+
* ```typescript
|
|
2560
|
+
* const values = await client.settings.getMany([
|
|
2561
|
+
* 'features.beta_enabled', // public - will be returned
|
|
2562
|
+
* 'features.dark_mode', // public - will be returned
|
|
2563
|
+
* 'internal.api_key' // secret - will be omitted
|
|
2564
|
+
* ])
|
|
2565
|
+
* console.log(values)
|
|
2566
|
+
* // {
|
|
2567
|
+
* // 'features.beta_enabled': { enabled: true },
|
|
2568
|
+
* // 'features.dark_mode': { enabled: false }
|
|
2569
|
+
* // // 'internal.api_key' is omitted (no error)
|
|
2570
|
+
* // }
|
|
2571
|
+
* ```
|
|
2572
|
+
*/
|
|
2573
|
+
getMany(keys: string[]): Promise<Record<string, any>>;
|
|
2574
|
+
}
|
|
2536
2575
|
|
|
2537
2576
|
/**
|
|
2538
2577
|
* DDL (Data Definition Language) Manager
|
|
@@ -4251,6 +4290,8 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
4251
4290
|
admin: FluxbaseAdmin;
|
|
4252
4291
|
/** Management module for API keys, webhooks, and invitations */
|
|
4253
4292
|
management: FluxbaseManagement;
|
|
4293
|
+
/** Settings module for reading public application settings (respects RLS policies) */
|
|
4294
|
+
settings: SettingsClient;
|
|
4254
4295
|
/**
|
|
4255
4296
|
* Create a new Fluxbase client instance
|
|
4256
4297
|
*
|
|
@@ -4424,4 +4465,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
4424
4465
|
*/
|
|
4425
4466
|
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
4426
4467
|
|
|
4427
|
-
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
4468
|
+
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
package/dist/index.js
CHANGED
|
@@ -1942,87 +1942,128 @@ var AppSettingsManager = class {
|
|
|
1942
1942
|
authentication: { require_email_verification: required }
|
|
1943
1943
|
});
|
|
1944
1944
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
}
|
|
1945
|
+
// ===================================================================
|
|
1946
|
+
// CUSTOM SETTINGS METHODS
|
|
1947
|
+
// Flexible key-value storage for application-specific configuration
|
|
1948
|
+
// ===================================================================
|
|
1950
1949
|
/**
|
|
1951
|
-
*
|
|
1950
|
+
* Get a specific custom setting's value only (without metadata)
|
|
1952
1951
|
*
|
|
1953
|
-
*
|
|
1954
|
-
*
|
|
1952
|
+
* Convenience method that returns just the value field instead of the full CustomSetting object.
|
|
1953
|
+
*
|
|
1954
|
+
* @param key - Setting key (e.g., 'billing.tiers', 'features.beta_enabled')
|
|
1955
|
+
* @returns Promise resolving to the setting's value
|
|
1955
1956
|
*
|
|
1956
1957
|
* @example
|
|
1957
1958
|
* ```typescript
|
|
1958
|
-
* const
|
|
1959
|
-
*
|
|
1960
|
-
* value: { free: 1000, pro: 10000, enterprise: 100000 },
|
|
1961
|
-
* value_type: 'json',
|
|
1962
|
-
* description: 'API request quotas by tier',
|
|
1963
|
-
* metadata: { category: 'billing' }
|
|
1964
|
-
* })
|
|
1959
|
+
* const tiers = await client.admin.settings.app.getSetting('billing.tiers')
|
|
1960
|
+
* console.log(tiers) // { free: 1000, pro: 10000, enterprise: 100000 }
|
|
1965
1961
|
* ```
|
|
1966
1962
|
*/
|
|
1967
|
-
async
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
request
|
|
1963
|
+
async getSetting(key) {
|
|
1964
|
+
const setting = await this.fetch.get(
|
|
1965
|
+
`/api/v1/admin/settings/custom/${key}`
|
|
1971
1966
|
);
|
|
1967
|
+
return setting.value;
|
|
1972
1968
|
}
|
|
1973
1969
|
/**
|
|
1974
|
-
*
|
|
1970
|
+
* Get multiple custom settings' values by keys
|
|
1971
|
+
*
|
|
1972
|
+
* Fetches multiple settings in a single request and returns only their values.
|
|
1975
1973
|
*
|
|
1976
|
-
* @
|
|
1974
|
+
* @param keys - Array of setting keys to fetch
|
|
1975
|
+
* @returns Promise resolving to object mapping keys to values
|
|
1977
1976
|
*
|
|
1978
1977
|
* @example
|
|
1979
1978
|
* ```typescript
|
|
1980
|
-
* const
|
|
1981
|
-
*
|
|
1979
|
+
* const values = await client.admin.settings.app.getSettings([
|
|
1980
|
+
* 'billing.tiers',
|
|
1981
|
+
* 'features.beta_enabled'
|
|
1982
|
+
* ])
|
|
1983
|
+
* console.log(values)
|
|
1984
|
+
* // {
|
|
1985
|
+
* // 'billing.tiers': { free: 1000, pro: 10000 },
|
|
1986
|
+
* // 'features.beta_enabled': { enabled: true }
|
|
1987
|
+
* // }
|
|
1982
1988
|
* ```
|
|
1983
1989
|
*/
|
|
1984
|
-
async
|
|
1985
|
-
const
|
|
1986
|
-
"/api/v1/
|
|
1990
|
+
async getSettings(keys) {
|
|
1991
|
+
const response = await this.fetch.post(
|
|
1992
|
+
"/api/v1/settings/batch",
|
|
1993
|
+
{ keys }
|
|
1994
|
+
);
|
|
1995
|
+
return response.reduce(
|
|
1996
|
+
(acc, setting) => {
|
|
1997
|
+
acc[setting.key] = setting.value;
|
|
1998
|
+
return acc;
|
|
1999
|
+
},
|
|
2000
|
+
{}
|
|
1987
2001
|
);
|
|
1988
|
-
return { settings: Array.isArray(settings) ? settings : [] };
|
|
1989
2002
|
}
|
|
1990
2003
|
/**
|
|
1991
|
-
*
|
|
2004
|
+
* Set or create a custom setting
|
|
2005
|
+
*
|
|
2006
|
+
* Creates a new custom setting or updates an existing one.
|
|
1992
2007
|
*
|
|
1993
|
-
* @param key - Setting key
|
|
2008
|
+
* @param key - Setting key
|
|
2009
|
+
* @param value - Setting value (any JSON-serializable value)
|
|
2010
|
+
* @param options - Optional configuration (description, is_public, is_secret, etc.)
|
|
1994
2011
|
* @returns Promise resolving to CustomSetting
|
|
1995
2012
|
*
|
|
1996
2013
|
* @example
|
|
1997
2014
|
* ```typescript
|
|
1998
|
-
*
|
|
1999
|
-
*
|
|
2015
|
+
* await client.admin.settings.app.setSetting('billing.tiers', {
|
|
2016
|
+
* free: 1000,
|
|
2017
|
+
* pro: 10000,
|
|
2018
|
+
* enterprise: 100000
|
|
2019
|
+
* }, {
|
|
2020
|
+
* description: 'API quotas per billing tier',
|
|
2021
|
+
* is_public: false
|
|
2022
|
+
* })
|
|
2000
2023
|
* ```
|
|
2001
2024
|
*/
|
|
2002
|
-
async
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2025
|
+
async setSetting(key, value, options) {
|
|
2026
|
+
try {
|
|
2027
|
+
return await this.fetch.put(
|
|
2028
|
+
`/api/v1/admin/settings/custom/${key}`,
|
|
2029
|
+
{
|
|
2030
|
+
value,
|
|
2031
|
+
description: options?.description,
|
|
2032
|
+
is_public: options?.is_public,
|
|
2033
|
+
is_secret: options?.is_secret
|
|
2034
|
+
}
|
|
2035
|
+
);
|
|
2036
|
+
} catch (error) {
|
|
2037
|
+
if (error.status === 404 || error.message?.includes("not found")) {
|
|
2038
|
+
return await this.fetch.post(
|
|
2039
|
+
"/api/v1/admin/settings/custom",
|
|
2040
|
+
{
|
|
2041
|
+
key,
|
|
2042
|
+
value,
|
|
2043
|
+
value_type: options?.value_type || "json",
|
|
2044
|
+
description: options?.description,
|
|
2045
|
+
is_public: options?.is_public ?? false,
|
|
2046
|
+
is_secret: options?.is_secret ?? false
|
|
2047
|
+
}
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
throw error;
|
|
2051
|
+
}
|
|
2006
2052
|
}
|
|
2007
2053
|
/**
|
|
2008
|
-
*
|
|
2054
|
+
* List all custom settings
|
|
2009
2055
|
*
|
|
2010
|
-
* @
|
|
2011
|
-
* @param request - Update request with new values
|
|
2012
|
-
* @returns Promise resolving to CustomSetting
|
|
2056
|
+
* @returns Promise resolving to array of CustomSetting objects
|
|
2013
2057
|
*
|
|
2014
2058
|
* @example
|
|
2015
2059
|
* ```typescript
|
|
2016
|
-
* const
|
|
2017
|
-
*
|
|
2018
|
-
* description: 'Updated description'
|
|
2019
|
-
* })
|
|
2060
|
+
* const settings = await client.admin.settings.app.listSettings()
|
|
2061
|
+
* settings.forEach(s => console.log(s.key, s.value))
|
|
2020
2062
|
* ```
|
|
2021
2063
|
*/
|
|
2022
|
-
async
|
|
2023
|
-
return await this.fetch.
|
|
2024
|
-
|
|
2025
|
-
request
|
|
2064
|
+
async listSettings() {
|
|
2065
|
+
return await this.fetch.get(
|
|
2066
|
+
"/api/v1/admin/settings/custom"
|
|
2026
2067
|
);
|
|
2027
2068
|
}
|
|
2028
2069
|
/**
|
|
@@ -2033,10 +2074,10 @@ var CustomSettingsManager = class {
|
|
|
2033
2074
|
*
|
|
2034
2075
|
* @example
|
|
2035
2076
|
* ```typescript
|
|
2036
|
-
* await client.admin.settings.
|
|
2077
|
+
* await client.admin.settings.app.deleteSetting('billing.tiers')
|
|
2037
2078
|
* ```
|
|
2038
2079
|
*/
|
|
2039
|
-
async
|
|
2080
|
+
async deleteSetting(key) {
|
|
2040
2081
|
await this.fetch.delete(`/api/v1/admin/settings/custom/${key}`);
|
|
2041
2082
|
}
|
|
2042
2083
|
};
|
|
@@ -2150,7 +2191,80 @@ var FluxbaseSettings = class {
|
|
|
2150
2191
|
constructor(fetch2) {
|
|
2151
2192
|
this.system = new SystemSettingsManager(fetch2);
|
|
2152
2193
|
this.app = new AppSettingsManager(fetch2);
|
|
2153
|
-
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
var SettingsClient = class {
|
|
2197
|
+
constructor(fetch2) {
|
|
2198
|
+
this.fetch = fetch2;
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Get a single setting's value
|
|
2202
|
+
*
|
|
2203
|
+
* Returns only the value field of the setting.
|
|
2204
|
+
* Access is controlled by RLS policies - will return 403 if the user
|
|
2205
|
+
* doesn't have permission to read the setting.
|
|
2206
|
+
*
|
|
2207
|
+
* @param key - Setting key (e.g., 'features.beta_enabled')
|
|
2208
|
+
* @returns Promise resolving to the setting's value
|
|
2209
|
+
* @throws Error if setting doesn't exist or user lacks permission
|
|
2210
|
+
*
|
|
2211
|
+
* @example
|
|
2212
|
+
* ```typescript
|
|
2213
|
+
* // Get public setting (any user)
|
|
2214
|
+
* const value = await client.settings.get('features.beta_enabled')
|
|
2215
|
+
* console.log(value) // { enabled: true }
|
|
2216
|
+
*
|
|
2217
|
+
* // Get restricted setting (requires permission)
|
|
2218
|
+
* try {
|
|
2219
|
+
* const secret = await client.settings.get('internal.api_key')
|
|
2220
|
+
* } catch (error) {
|
|
2221
|
+
* console.error('Access denied:', error)
|
|
2222
|
+
* }
|
|
2223
|
+
* ```
|
|
2224
|
+
*/
|
|
2225
|
+
async get(key) {
|
|
2226
|
+
const response = await this.fetch.get(
|
|
2227
|
+
`/api/v1/settings/${encodeURIComponent(key)}`
|
|
2228
|
+
);
|
|
2229
|
+
return response.value;
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Get multiple settings' values by keys
|
|
2233
|
+
*
|
|
2234
|
+
* Fetches multiple settings in a single request.
|
|
2235
|
+
* Only returns settings the user has permission to read based on RLS policies.
|
|
2236
|
+
* Settings the user can't access will be omitted from the result (no error thrown).
|
|
2237
|
+
*
|
|
2238
|
+
* @param keys - Array of setting keys to fetch
|
|
2239
|
+
* @returns Promise resolving to object mapping keys to values
|
|
2240
|
+
*
|
|
2241
|
+
* @example
|
|
2242
|
+
* ```typescript
|
|
2243
|
+
* const values = await client.settings.getMany([
|
|
2244
|
+
* 'features.beta_enabled', // public - will be returned
|
|
2245
|
+
* 'features.dark_mode', // public - will be returned
|
|
2246
|
+
* 'internal.api_key' // secret - will be omitted
|
|
2247
|
+
* ])
|
|
2248
|
+
* console.log(values)
|
|
2249
|
+
* // {
|
|
2250
|
+
* // 'features.beta_enabled': { enabled: true },
|
|
2251
|
+
* // 'features.dark_mode': { enabled: false }
|
|
2252
|
+
* // // 'internal.api_key' is omitted (no error)
|
|
2253
|
+
* // }
|
|
2254
|
+
* ```
|
|
2255
|
+
*/
|
|
2256
|
+
async getMany(keys) {
|
|
2257
|
+
const response = await this.fetch.post(
|
|
2258
|
+
"/api/v1/settings/batch",
|
|
2259
|
+
{ keys }
|
|
2260
|
+
);
|
|
2261
|
+
return response.reduce(
|
|
2262
|
+
(acc, setting) => {
|
|
2263
|
+
acc[setting.key] = setting.value;
|
|
2264
|
+
return acc;
|
|
2265
|
+
},
|
|
2266
|
+
{}
|
|
2267
|
+
);
|
|
2154
2268
|
}
|
|
2155
2269
|
};
|
|
2156
2270
|
|
|
@@ -4075,8 +4189,8 @@ var FluxbaseClient = class {
|
|
|
4075
4189
|
this.fluxbaseUrl = fluxbaseUrl;
|
|
4076
4190
|
this.fluxbaseKey = fluxbaseKey;
|
|
4077
4191
|
const headers = {
|
|
4078
|
-
|
|
4079
|
-
|
|
4192
|
+
apikey: fluxbaseKey,
|
|
4193
|
+
Authorization: `Bearer ${fluxbaseKey}`,
|
|
4080
4194
|
...options?.headers
|
|
4081
4195
|
};
|
|
4082
4196
|
this.fetch = new FluxbaseFetch(fluxbaseUrl, {
|
|
@@ -4100,6 +4214,7 @@ var FluxbaseClient = class {
|
|
|
4100
4214
|
this.functions = new FluxbaseFunctions(this.fetch);
|
|
4101
4215
|
this.admin = new FluxbaseAdmin(this.fetch);
|
|
4102
4216
|
this.management = new FluxbaseManagement(this.fetch);
|
|
4217
|
+
this.settings = new SettingsClient(this.fetch);
|
|
4103
4218
|
this.setupAuthSync();
|
|
4104
4219
|
}
|
|
4105
4220
|
/**
|
|
@@ -4252,6 +4367,6 @@ function createClient(fluxbaseUrl, fluxbaseKey, options) {
|
|
|
4252
4367
|
);
|
|
4253
4368
|
}
|
|
4254
4369
|
|
|
4255
|
-
export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, EmailTemplateManager, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, StorageBucket, SystemSettingsManager, WebhooksManager, createClient };
|
|
4370
|
+
export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, EmailTemplateManager, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, SettingsClient, StorageBucket, SystemSettingsManager, WebhooksManager, createClient };
|
|
4256
4371
|
//# sourceMappingURL=index.js.map
|
|
4257
4372
|
//# sourceMappingURL=index.js.map
|