@fluxbase/sdk 0.0.1-rc.24 → 0.0.1-rc.25

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.d.cts 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
- * Create a new custom setting
2263
+ * Get a specific custom setting's value only (without metadata)
2329
2264
  *
2330
- * @param request - Custom setting creation request
2331
- * @returns Promise resolving to CustomSetting
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 setting = await client.admin.settings.custom.create({
2336
- * key: 'api.quotas',
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
- create(request: CreateCustomSettingRequest): Promise<CustomSetting>;
2276
+ getSetting(key: string): Promise<any>;
2345
2277
  /**
2346
- * List all custom settings
2278
+ * Get multiple custom settings' values by keys
2347
2279
  *
2348
- * @returns Promise resolving to ListCustomSettingsResponse
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 response = await client.admin.settings.custom.list()
2353
- * console.log(response.settings)
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
- list(): Promise<ListCustomSettingsResponse>;
2298
+ getSettings(keys: string[]): Promise<Record<string, any>>;
2357
2299
  /**
2358
- * Get a specific custom setting by key
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 (e.g., 'feature.dark_mode')
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
- * const setting = await client.admin.settings.custom.get('feature.dark_mode')
2366
- * console.log(setting.value)
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
- get(key: string): Promise<CustomSetting>;
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
- * Update an existing custom setting
2328
+ * List all custom settings
2372
2329
  *
2373
- * @param key - Setting key
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 updated = await client.admin.settings.custom.update('feature.dark_mode', {
2380
- * value: { enabled: false },
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
- update(key: string, request: UpdateCustomSettingRequest): Promise<CustomSetting>;
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.custom.delete('feature.dark_mode')
2347
+ * await client.admin.settings.app.deleteSetting('billing.tiers')
2395
2348
  * ```
2396
2349
  */
2397
- delete(key: string): Promise<void>;
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, application-level, and custom settings.
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
- * const customSettings = await settings.custom.list()
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 };