@fluxbase/sdk 0.0.1-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4021 @@
1
+ /**
2
+ * Core types for the Fluxbase SDK
3
+ */
4
+ interface FluxbaseClientOptions {
5
+ /**
6
+ * Base URL of your Fluxbase instance
7
+ * @example 'https://api.myapp.com'
8
+ * @example 'http://localhost:8080'
9
+ */
10
+ url: string;
11
+ /**
12
+ * Authentication options
13
+ */
14
+ auth?: {
15
+ /**
16
+ * Access token for authentication
17
+ */
18
+ token?: string;
19
+ /**
20
+ * Auto-refresh token when it expires
21
+ * @default true
22
+ */
23
+ autoRefresh?: boolean;
24
+ /**
25
+ * Persist auth state in localStorage
26
+ * @default true
27
+ */
28
+ persist?: boolean;
29
+ };
30
+ /**
31
+ * Global headers to include in all requests
32
+ */
33
+ headers?: Record<string, string>;
34
+ /**
35
+ * Request timeout in milliseconds
36
+ * @default 30000
37
+ */
38
+ timeout?: number;
39
+ /**
40
+ * Enable debug logging
41
+ * @default false
42
+ */
43
+ debug?: boolean;
44
+ }
45
+ interface AuthSession {
46
+ user: User;
47
+ access_token: string;
48
+ refresh_token: string;
49
+ expires_in: number;
50
+ expires_at?: number;
51
+ }
52
+ interface User {
53
+ id: string;
54
+ email: string;
55
+ email_verified: boolean;
56
+ role: string;
57
+ metadata?: Record<string, unknown> | null;
58
+ created_at: string;
59
+ updated_at: string;
60
+ }
61
+ interface SignInCredentials {
62
+ email: string;
63
+ password: string;
64
+ }
65
+ interface SignUpCredentials {
66
+ email: string;
67
+ password: string;
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ interface AuthResponse {
71
+ user: User;
72
+ access_token: string;
73
+ refresh_token: string;
74
+ expires_in: number;
75
+ }
76
+ interface TwoFactorSetupResponse {
77
+ secret: string;
78
+ qr_code_url: string;
79
+ message: string;
80
+ }
81
+ interface TwoFactorEnableResponse {
82
+ success: boolean;
83
+ backup_codes: string[];
84
+ message: string;
85
+ }
86
+ interface TwoFactorStatusResponse {
87
+ totp_enabled: boolean;
88
+ }
89
+ interface TwoFactorVerifyRequest {
90
+ user_id: string;
91
+ code: string;
92
+ }
93
+ interface SignInWith2FAResponse {
94
+ requires_2fa: boolean;
95
+ user_id: string;
96
+ message: string;
97
+ }
98
+ interface FluxbaseError extends Error {
99
+ status?: number;
100
+ code?: string;
101
+ details?: unknown;
102
+ }
103
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD';
104
+ interface RequestOptions {
105
+ method: HttpMethod;
106
+ headers?: Record<string, string>;
107
+ body?: unknown;
108
+ timeout?: number;
109
+ }
110
+ interface PostgrestError {
111
+ message: string;
112
+ details?: string;
113
+ hint?: string;
114
+ code?: string;
115
+ }
116
+ interface PostgrestResponse<T> {
117
+ data: T | null;
118
+ error: PostgrestError | null;
119
+ count: number | null;
120
+ status: number;
121
+ statusText: string;
122
+ }
123
+ type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'fts' | 'plfts' | 'wfts';
124
+ interface QueryFilter {
125
+ column: string;
126
+ operator: FilterOperator;
127
+ value: unknown;
128
+ }
129
+ type OrderDirection = 'asc' | 'desc';
130
+ interface OrderBy {
131
+ column: string;
132
+ direction: OrderDirection;
133
+ nulls?: 'first' | 'last';
134
+ }
135
+ interface RealtimeMessage {
136
+ type: 'subscribe' | 'unsubscribe' | 'heartbeat' | 'broadcast' | 'ack' | 'error';
137
+ channel?: string;
138
+ event?: string;
139
+ schema?: string;
140
+ table?: string;
141
+ filter?: string;
142
+ payload?: unknown;
143
+ error?: string;
144
+ config?: PostgresChangesConfig;
145
+ }
146
+ interface PostgresChangesConfig {
147
+ event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
148
+ schema: string;
149
+ table: string;
150
+ filter?: string;
151
+ }
152
+ interface RealtimeChangePayload {
153
+ type: 'INSERT' | 'UPDATE' | 'DELETE';
154
+ schema: string;
155
+ table: string;
156
+ new_record?: Record<string, unknown>;
157
+ old_record?: Record<string, unknown>;
158
+ timestamp: string;
159
+ }
160
+ type RealtimeCallback = (payload: RealtimeChangePayload) => void;
161
+ interface StorageObject {
162
+ key: string;
163
+ bucket: string;
164
+ size: number;
165
+ content_type: string;
166
+ last_modified: string;
167
+ etag?: string;
168
+ metadata?: Record<string, string>;
169
+ }
170
+ interface UploadOptions {
171
+ contentType?: string;
172
+ metadata?: Record<string, string>;
173
+ cacheControl?: string;
174
+ upsert?: boolean;
175
+ }
176
+ interface ListOptions {
177
+ prefix?: string;
178
+ limit?: number;
179
+ offset?: number;
180
+ }
181
+ interface SignedUrlOptions {
182
+ expiresIn?: number;
183
+ }
184
+ interface ShareFileOptions {
185
+ userId: string;
186
+ permission: 'read' | 'write';
187
+ }
188
+ interface FileShare {
189
+ user_id: string;
190
+ permission: 'read' | 'write';
191
+ created_at: string;
192
+ }
193
+ interface BucketSettings {
194
+ public?: boolean;
195
+ allowed_mime_types?: string[];
196
+ max_file_size?: number;
197
+ }
198
+ interface Bucket {
199
+ id: string;
200
+ name: string;
201
+ public: boolean;
202
+ allowed_mime_types: string[];
203
+ max_file_size?: number;
204
+ created_at: string;
205
+ updated_at: string;
206
+ }
207
+ interface PasswordResetResponse {
208
+ message: string;
209
+ }
210
+ interface VerifyResetTokenResponse {
211
+ valid: boolean;
212
+ message: string;
213
+ }
214
+ interface ResetPasswordResponse {
215
+ message: string;
216
+ }
217
+ interface MagicLinkOptions {
218
+ redirect_to?: string;
219
+ }
220
+ interface MagicLinkResponse {
221
+ message: string;
222
+ }
223
+ interface OAuthProvidersResponse {
224
+ providers: OAuthProvider[];
225
+ }
226
+ interface OAuthOptions {
227
+ redirect_to?: string;
228
+ scopes?: string[];
229
+ }
230
+ interface OAuthUrlResponse {
231
+ url: string;
232
+ provider: string;
233
+ }
234
+ interface AdminSetupStatusResponse {
235
+ needs_setup: boolean;
236
+ has_admin: boolean;
237
+ }
238
+ interface AdminSetupRequest {
239
+ email: string;
240
+ password: string;
241
+ name: string;
242
+ }
243
+ interface AdminUser {
244
+ id: string;
245
+ email: string;
246
+ name: string;
247
+ role: string;
248
+ email_verified: boolean;
249
+ created_at: string;
250
+ updated_at: string;
251
+ last_login_at?: string;
252
+ }
253
+ interface AdminAuthResponse {
254
+ user: AdminUser;
255
+ access_token: string;
256
+ refresh_token: string;
257
+ expires_in: number;
258
+ }
259
+ interface AdminLoginRequest {
260
+ email: string;
261
+ password: string;
262
+ }
263
+ interface AdminRefreshRequest {
264
+ refresh_token: string;
265
+ }
266
+ interface AdminRefreshResponse {
267
+ access_token: string;
268
+ refresh_token: string;
269
+ expires_in: number;
270
+ user: AdminUser;
271
+ }
272
+ interface AdminMeResponse {
273
+ user: {
274
+ id: string;
275
+ email: string;
276
+ role: string;
277
+ };
278
+ }
279
+ interface EnrichedUser {
280
+ id: string;
281
+ email: string;
282
+ role?: string;
283
+ created_at: string;
284
+ updated_at?: string;
285
+ email_verified?: boolean;
286
+ last_login_at?: string;
287
+ session_count?: number;
288
+ is_anonymous?: boolean;
289
+ metadata?: Record<string, any>;
290
+ }
291
+ interface ListUsersResponse {
292
+ users: EnrichedUser[];
293
+ total: number;
294
+ }
295
+ interface ListUsersOptions {
296
+ exclude_admins?: boolean;
297
+ search?: string;
298
+ limit?: number;
299
+ type?: 'app' | 'dashboard';
300
+ }
301
+ interface InviteUserRequest {
302
+ email: string;
303
+ role?: string;
304
+ send_email?: boolean;
305
+ }
306
+ interface InviteUserResponse {
307
+ user: EnrichedUser;
308
+ invitation_link?: string;
309
+ message: string;
310
+ }
311
+ interface UpdateUserRoleRequest {
312
+ role: string;
313
+ }
314
+ interface ResetUserPasswordResponse {
315
+ message: string;
316
+ }
317
+ interface DeleteUserResponse {
318
+ message: string;
319
+ }
320
+ interface APIKey {
321
+ id: string;
322
+ name: string;
323
+ description?: string;
324
+ key_prefix: string;
325
+ scopes: string[];
326
+ rate_limit_per_minute: number;
327
+ created_at: string;
328
+ updated_at?: string;
329
+ expires_at?: string;
330
+ revoked_at?: string;
331
+ last_used_at?: string;
332
+ user_id: string;
333
+ }
334
+ interface CreateAPIKeyRequest {
335
+ name: string;
336
+ description?: string;
337
+ scopes: string[];
338
+ rate_limit_per_minute: number;
339
+ expires_at?: string;
340
+ }
341
+ interface CreateAPIKeyResponse {
342
+ api_key: APIKey;
343
+ key: string;
344
+ }
345
+ interface ListAPIKeysResponse {
346
+ api_keys: APIKey[];
347
+ total: number;
348
+ }
349
+ interface UpdateAPIKeyRequest {
350
+ name?: string;
351
+ description?: string;
352
+ scopes?: string[];
353
+ rate_limit_per_minute?: number;
354
+ }
355
+ interface RevokeAPIKeyResponse {
356
+ message: string;
357
+ }
358
+ interface DeleteAPIKeyResponse {
359
+ message: string;
360
+ }
361
+ interface Webhook {
362
+ id: string;
363
+ url: string;
364
+ events: string[];
365
+ secret?: string;
366
+ description?: string;
367
+ is_active: boolean;
368
+ created_at: string;
369
+ updated_at?: string;
370
+ user_id: string;
371
+ }
372
+ interface CreateWebhookRequest {
373
+ url: string;
374
+ events: string[];
375
+ description?: string;
376
+ secret?: string;
377
+ }
378
+ interface UpdateWebhookRequest {
379
+ url?: string;
380
+ events?: string[];
381
+ description?: string;
382
+ is_active?: boolean;
383
+ }
384
+ interface ListWebhooksResponse {
385
+ webhooks: Webhook[];
386
+ total: number;
387
+ }
388
+ interface TestWebhookResponse {
389
+ success: boolean;
390
+ status_code?: number;
391
+ response_body?: string;
392
+ error?: string;
393
+ }
394
+ interface WebhookDelivery {
395
+ id: string;
396
+ webhook_id: string;
397
+ event: string;
398
+ payload: Record<string, any>;
399
+ status_code?: number;
400
+ response_body?: string;
401
+ error?: string;
402
+ created_at: string;
403
+ delivered_at?: string;
404
+ }
405
+ interface ListWebhookDeliveriesResponse {
406
+ deliveries: WebhookDelivery[];
407
+ }
408
+ interface DeleteWebhookResponse {
409
+ message: string;
410
+ }
411
+ interface Invitation {
412
+ id: string;
413
+ email: string;
414
+ role: string;
415
+ token?: string;
416
+ invited_by: string;
417
+ accepted_at?: string;
418
+ expires_at: string;
419
+ created_at: string;
420
+ revoked_at?: string;
421
+ }
422
+ interface CreateInvitationRequest {
423
+ email: string;
424
+ role: 'dashboard_admin' | 'dashboard_user';
425
+ expiry_duration?: number;
426
+ }
427
+ interface CreateInvitationResponse {
428
+ invitation: Invitation;
429
+ invite_link: string;
430
+ email_sent: boolean;
431
+ email_status?: string;
432
+ }
433
+ interface ValidateInvitationResponse {
434
+ valid: boolean;
435
+ invitation?: Invitation;
436
+ error?: string;
437
+ }
438
+ interface AcceptInvitationRequest {
439
+ password: string;
440
+ name: string;
441
+ }
442
+ interface AcceptInvitationResponse {
443
+ user: AdminUser;
444
+ access_token: string;
445
+ refresh_token: string;
446
+ expires_in: number;
447
+ }
448
+ interface ListInvitationsOptions {
449
+ include_accepted?: boolean;
450
+ include_expired?: boolean;
451
+ }
452
+ interface ListInvitationsResponse {
453
+ invitations: Invitation[];
454
+ }
455
+ interface RevokeInvitationResponse {
456
+ message: string;
457
+ }
458
+ /**
459
+ * System setting with key-value storage
460
+ */
461
+ interface SystemSetting {
462
+ id: string;
463
+ key: string;
464
+ value: Record<string, unknown>;
465
+ description?: string;
466
+ created_at: string;
467
+ updated_at: string;
468
+ }
469
+ /**
470
+ * Request to update a system setting
471
+ */
472
+ interface UpdateSystemSettingRequest {
473
+ value: Record<string, unknown>;
474
+ description?: string;
475
+ }
476
+ /**
477
+ * Response containing all system settings
478
+ */
479
+ interface ListSystemSettingsResponse {
480
+ settings: SystemSetting[];
481
+ }
482
+ /**
483
+ * Custom setting with flexible key-value storage and role-based editing permissions
484
+ */
485
+ interface CustomSetting {
486
+ id: string;
487
+ key: string;
488
+ value: Record<string, unknown>;
489
+ value_type: 'string' | 'number' | 'boolean' | 'json';
490
+ description?: string;
491
+ editable_by: string[];
492
+ metadata?: Record<string, unknown>;
493
+ created_by?: string;
494
+ updated_by?: string;
495
+ created_at: string;
496
+ updated_at: string;
497
+ }
498
+ /**
499
+ * Request to create a custom setting
500
+ */
501
+ interface CreateCustomSettingRequest {
502
+ key: string;
503
+ value: Record<string, unknown>;
504
+ value_type?: 'string' | 'number' | 'boolean' | 'json';
505
+ description?: string;
506
+ editable_by?: string[];
507
+ metadata?: Record<string, unknown>;
508
+ }
509
+ /**
510
+ * Request to update a custom setting
511
+ */
512
+ interface UpdateCustomSettingRequest {
513
+ value: Record<string, unknown>;
514
+ description?: string;
515
+ editable_by?: string[];
516
+ metadata?: Record<string, unknown>;
517
+ }
518
+ /**
519
+ * Response containing all custom settings
520
+ */
521
+ interface ListCustomSettingsResponse {
522
+ settings: CustomSetting[];
523
+ }
524
+ /**
525
+ * Authentication settings for the application
526
+ */
527
+ interface AuthenticationSettings {
528
+ enable_signup: boolean;
529
+ enable_magic_link: boolean;
530
+ password_min_length: number;
531
+ require_email_verification: boolean;
532
+ password_require_uppercase: boolean;
533
+ password_require_lowercase: boolean;
534
+ password_require_number: boolean;
535
+ password_require_special: boolean;
536
+ session_timeout_minutes: number;
537
+ max_sessions_per_user: number;
538
+ }
539
+ /**
540
+ * Feature flags for the application
541
+ */
542
+ interface FeatureSettings {
543
+ enable_realtime: boolean;
544
+ enable_storage: boolean;
545
+ enable_functions: boolean;
546
+ }
547
+ /**
548
+ * SMTP email provider configuration
549
+ */
550
+ interface SMTPSettings {
551
+ host: string;
552
+ port: number;
553
+ username: string;
554
+ password: string;
555
+ use_tls: boolean;
556
+ }
557
+ /**
558
+ * SendGrid email provider configuration
559
+ */
560
+ interface SendGridSettings {
561
+ api_key: string;
562
+ }
563
+ /**
564
+ * Mailgun email provider configuration
565
+ */
566
+ interface MailgunSettings {
567
+ api_key: string;
568
+ domain: string;
569
+ eu_region: boolean;
570
+ }
571
+ /**
572
+ * AWS SES email provider configuration
573
+ */
574
+ interface SESSettings {
575
+ access_key_id: string;
576
+ secret_access_key: string;
577
+ region: string;
578
+ }
579
+ /**
580
+ * Email configuration settings
581
+ */
582
+ interface EmailSettings {
583
+ enabled: boolean;
584
+ provider: 'smtp' | 'sendgrid' | 'mailgun' | 'ses';
585
+ from_address?: string;
586
+ from_name?: string;
587
+ reply_to_address?: string;
588
+ smtp?: SMTPSettings;
589
+ sendgrid?: SendGridSettings;
590
+ mailgun?: MailgunSettings;
591
+ ses?: SESSettings;
592
+ }
593
+ /**
594
+ * Security settings for the application
595
+ */
596
+ interface SecuritySettings {
597
+ enable_global_rate_limit: boolean;
598
+ }
599
+ /**
600
+ * Complete application settings structure
601
+ */
602
+ interface AppSettings {
603
+ authentication: AuthenticationSettings;
604
+ features: FeatureSettings;
605
+ email: EmailSettings;
606
+ security: SecuritySettings;
607
+ }
608
+ /**
609
+ * Request to update application settings
610
+ * All fields are optional for partial updates
611
+ */
612
+ interface UpdateAppSettingsRequest {
613
+ authentication?: Partial<AuthenticationSettings>;
614
+ features?: Partial<FeatureSettings>;
615
+ email?: Partial<EmailSettings>;
616
+ security?: Partial<SecuritySettings>;
617
+ }
618
+ /**
619
+ * Email template type
620
+ */
621
+ type EmailTemplateType = 'magic_link' | 'verify_email' | 'reset_password' | 'invite_user';
622
+ /**
623
+ * Email template structure
624
+ */
625
+ interface EmailTemplate {
626
+ id: string;
627
+ template_type: EmailTemplateType;
628
+ subject: string;
629
+ html_body: string;
630
+ text_body?: string;
631
+ is_custom: boolean;
632
+ created_at: string;
633
+ updated_at: string;
634
+ }
635
+ /**
636
+ * Request to update an email template
637
+ */
638
+ interface UpdateEmailTemplateRequest {
639
+ subject: string;
640
+ html_body: string;
641
+ text_body?: string;
642
+ }
643
+ /**
644
+ * Request to test an email template
645
+ */
646
+ interface TestEmailTemplateRequest {
647
+ recipient_email: string;
648
+ }
649
+ /**
650
+ * Response when listing email templates
651
+ */
652
+ interface ListEmailTemplatesResponse {
653
+ templates: EmailTemplate[];
654
+ }
655
+ interface OAuthProvider {
656
+ id: string;
657
+ name: string;
658
+ enabled: boolean;
659
+ authorize_url?: string;
660
+ }
661
+ /**
662
+ * OAuth provider configuration
663
+ */
664
+ interface OAuthProvider {
665
+ id: string;
666
+ provider_name: string;
667
+ display_name: string;
668
+ enabled: boolean;
669
+ client_id: string;
670
+ client_secret?: string;
671
+ redirect_url: string;
672
+ scopes: string[];
673
+ is_custom: boolean;
674
+ authorization_url?: string;
675
+ token_url?: string;
676
+ user_info_url?: string;
677
+ created_at: string;
678
+ updated_at: string;
679
+ }
680
+ /**
681
+ * Request to create a new OAuth provider
682
+ */
683
+ interface CreateOAuthProviderRequest {
684
+ provider_name: string;
685
+ display_name: string;
686
+ enabled: boolean;
687
+ client_id: string;
688
+ client_secret: string;
689
+ redirect_url: string;
690
+ scopes: string[];
691
+ is_custom: boolean;
692
+ authorization_url?: string;
693
+ token_url?: string;
694
+ user_info_url?: string;
695
+ }
696
+ /**
697
+ * Response after creating an OAuth provider
698
+ */
699
+ interface CreateOAuthProviderResponse {
700
+ success: boolean;
701
+ id: string;
702
+ provider: string;
703
+ message: string;
704
+ created_at: string;
705
+ updated_at: string;
706
+ }
707
+ /**
708
+ * Request to update an OAuth provider
709
+ */
710
+ interface UpdateOAuthProviderRequest {
711
+ display_name?: string;
712
+ enabled?: boolean;
713
+ client_id?: string;
714
+ client_secret?: string;
715
+ redirect_url?: string;
716
+ scopes?: string[];
717
+ authorization_url?: string;
718
+ token_url?: string;
719
+ user_info_url?: string;
720
+ }
721
+ /**
722
+ * Response after updating an OAuth provider
723
+ */
724
+ interface UpdateOAuthProviderResponse {
725
+ success: boolean;
726
+ message: string;
727
+ }
728
+ /**
729
+ * Response after deleting an OAuth provider
730
+ */
731
+ interface DeleteOAuthProviderResponse {
732
+ success: boolean;
733
+ message: string;
734
+ }
735
+ /**
736
+ * Response for listing OAuth providers
737
+ */
738
+ interface ListOAuthProvidersResponse {
739
+ providers: OAuthProvider[];
740
+ }
741
+ /**
742
+ * Authentication settings configuration
743
+ */
744
+ interface AuthSettings {
745
+ enable_signup: boolean;
746
+ require_email_verification: boolean;
747
+ enable_magic_link: boolean;
748
+ password_min_length: number;
749
+ password_require_uppercase: boolean;
750
+ password_require_lowercase: boolean;
751
+ password_require_number: boolean;
752
+ password_require_special: boolean;
753
+ session_timeout_minutes: number;
754
+ max_sessions_per_user: number;
755
+ }
756
+ /**
757
+ * Request to update authentication settings
758
+ */
759
+ interface UpdateAuthSettingsRequest {
760
+ enable_signup?: boolean;
761
+ require_email_verification?: boolean;
762
+ enable_magic_link?: boolean;
763
+ password_min_length?: number;
764
+ password_require_uppercase?: boolean;
765
+ password_require_lowercase?: boolean;
766
+ password_require_number?: boolean;
767
+ password_require_special?: boolean;
768
+ session_timeout_minutes?: number;
769
+ max_sessions_per_user?: number;
770
+ }
771
+ /**
772
+ * Response after updating authentication settings
773
+ */
774
+ interface UpdateAuthSettingsResponse {
775
+ success: boolean;
776
+ message: string;
777
+ }
778
+ /**
779
+ * Column definition for creating a table
780
+ */
781
+ interface CreateColumnRequest {
782
+ name: string;
783
+ type: string;
784
+ nullable?: boolean;
785
+ primaryKey?: boolean;
786
+ defaultValue?: string;
787
+ }
788
+ /**
789
+ * Request to create a new database schema
790
+ */
791
+ interface CreateSchemaRequest {
792
+ name: string;
793
+ }
794
+ /**
795
+ * Response after creating a schema
796
+ */
797
+ interface CreateSchemaResponse {
798
+ message: string;
799
+ schema: string;
800
+ }
801
+ /**
802
+ * Request to create a new table
803
+ */
804
+ interface CreateTableRequest {
805
+ schema: string;
806
+ name: string;
807
+ columns: CreateColumnRequest[];
808
+ }
809
+ /**
810
+ * Response after creating a table
811
+ */
812
+ interface CreateTableResponse {
813
+ message: string;
814
+ schema: string;
815
+ table: string;
816
+ }
817
+ /**
818
+ * Response after deleting a table
819
+ */
820
+ interface DeleteTableResponse {
821
+ message: string;
822
+ }
823
+ /**
824
+ * Database schema information
825
+ */
826
+ interface Schema {
827
+ name: string;
828
+ owner?: string;
829
+ }
830
+ /**
831
+ * Response for listing schemas
832
+ */
833
+ interface ListSchemasResponse {
834
+ schemas: Schema[];
835
+ }
836
+ /**
837
+ * Table column information
838
+ */
839
+ interface Column {
840
+ name: string;
841
+ type: string;
842
+ nullable: boolean;
843
+ default_value?: string;
844
+ is_primary_key?: boolean;
845
+ }
846
+ /**
847
+ * Database table information
848
+ */
849
+ interface Table {
850
+ schema: string;
851
+ name: string;
852
+ columns?: Column[];
853
+ }
854
+ /**
855
+ * Response for listing tables
856
+ */
857
+ interface ListTablesResponse {
858
+ tables: Table[];
859
+ }
860
+ /**
861
+ * Impersonation type
862
+ */
863
+ type ImpersonationType = 'user' | 'anon' | 'service';
864
+ /**
865
+ * Target user information for impersonation
866
+ */
867
+ interface ImpersonationTargetUser {
868
+ id: string;
869
+ email: string;
870
+ role: string;
871
+ }
872
+ /**
873
+ * Impersonation session information
874
+ */
875
+ interface ImpersonationSession {
876
+ id: string;
877
+ admin_user_id: string;
878
+ target_user_id: string | null;
879
+ impersonation_type: ImpersonationType;
880
+ target_role: string;
881
+ reason: string;
882
+ started_at: string;
883
+ ended_at: string | null;
884
+ is_active: boolean;
885
+ ip_address: string | null;
886
+ user_agent: string | null;
887
+ }
888
+ /**
889
+ * Request to start impersonating a specific user
890
+ */
891
+ interface ImpersonateUserRequest {
892
+ target_user_id: string;
893
+ reason: string;
894
+ }
895
+ /**
896
+ * Request to start impersonating as anonymous user
897
+ */
898
+ interface ImpersonateAnonRequest {
899
+ reason: string;
900
+ }
901
+ /**
902
+ * Request to start impersonating with service role
903
+ */
904
+ interface ImpersonateServiceRequest {
905
+ reason: string;
906
+ }
907
+ /**
908
+ * Response after starting impersonation
909
+ */
910
+ interface StartImpersonationResponse {
911
+ session: ImpersonationSession;
912
+ target_user: ImpersonationTargetUser | null;
913
+ access_token: string;
914
+ refresh_token: string;
915
+ expires_in: number;
916
+ }
917
+ /**
918
+ * Response after stopping impersonation
919
+ */
920
+ interface StopImpersonationResponse {
921
+ success: boolean;
922
+ message: string;
923
+ }
924
+ /**
925
+ * Response for getting current impersonation session
926
+ */
927
+ interface GetImpersonationResponse {
928
+ session: ImpersonationSession | null;
929
+ target_user: ImpersonationTargetUser | null;
930
+ }
931
+ /**
932
+ * Options for listing impersonation sessions
933
+ */
934
+ interface ListImpersonationSessionsOptions {
935
+ limit?: number;
936
+ offset?: number;
937
+ admin_user_id?: string;
938
+ target_user_id?: string;
939
+ impersonation_type?: ImpersonationType;
940
+ is_active?: boolean;
941
+ }
942
+ /**
943
+ * Response for listing impersonation sessions
944
+ */
945
+ interface ListImpersonationSessionsResponse {
946
+ sessions: ImpersonationSession[];
947
+ total: number;
948
+ }
949
+ /**
950
+ * Auth state change events
951
+ */
952
+ type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'PASSWORD_RECOVERY' | 'MFA_CHALLENGE_VERIFIED';
953
+ /**
954
+ * Callback for auth state changes
955
+ */
956
+ type AuthStateChangeCallback = (event: AuthChangeEvent, session: AuthSession | null) => void;
957
+ /**
958
+ * Subscription object returned by onAuthStateChange
959
+ */
960
+ interface AuthSubscription {
961
+ /**
962
+ * Unsubscribe from auth state changes
963
+ */
964
+ unsubscribe: () => void;
965
+ }
966
+
967
+ /**
968
+ * HTTP client for making requests to the Fluxbase API
969
+ */
970
+
971
+ interface FetchOptions {
972
+ method: HttpMethod;
973
+ headers?: Record<string, string>;
974
+ body?: unknown;
975
+ timeout?: number;
976
+ }
977
+ declare class FluxbaseFetch {
978
+ private baseUrl;
979
+ private defaultHeaders;
980
+ private timeout;
981
+ private debug;
982
+ constructor(baseUrl: string, options?: {
983
+ headers?: Record<string, string>;
984
+ timeout?: number;
985
+ debug?: boolean;
986
+ });
987
+ /**
988
+ * Update the authorization header
989
+ */
990
+ setAuthToken(token: string | null): void;
991
+ /**
992
+ * Make an HTTP request
993
+ */
994
+ request<T = unknown>(path: string, options: FetchOptions): Promise<T>;
995
+ /**
996
+ * GET request
997
+ */
998
+ get<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
999
+ /**
1000
+ * POST request
1001
+ */
1002
+ post<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1003
+ /**
1004
+ * PUT request
1005
+ */
1006
+ put<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1007
+ /**
1008
+ * PATCH request
1009
+ */
1010
+ patch<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1011
+ /**
1012
+ * DELETE request
1013
+ */
1014
+ delete<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
1015
+ /**
1016
+ * HEAD request
1017
+ */
1018
+ head(path: string, options?: Omit<FetchOptions, 'method'>): Promise<Headers>;
1019
+ }
1020
+
1021
+ /**
1022
+ * Authentication module for Fluxbase SDK
1023
+ */
1024
+
1025
+ declare class FluxbaseAuth {
1026
+ private fetch;
1027
+ private session;
1028
+ private persist;
1029
+ private autoRefresh;
1030
+ private refreshTimer;
1031
+ private stateChangeListeners;
1032
+ constructor(fetch: FluxbaseFetch, autoRefresh?: boolean, persist?: boolean);
1033
+ /**
1034
+ * Get the current session
1035
+ */
1036
+ getSession(): AuthSession | null;
1037
+ /**
1038
+ * Get the current user
1039
+ */
1040
+ getUser(): User | null;
1041
+ /**
1042
+ * Get the current access token
1043
+ */
1044
+ getAccessToken(): string | null;
1045
+ /**
1046
+ * Listen to auth state changes
1047
+ * @param callback - Function called when auth state changes
1048
+ * @returns Subscription object with unsubscribe method
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * const { data: { subscription } } = client.auth.onAuthStateChange((event, session) => {
1053
+ * console.log('Auth event:', event, session)
1054
+ * })
1055
+ *
1056
+ * // Later, to unsubscribe:
1057
+ * subscription.unsubscribe()
1058
+ * ```
1059
+ */
1060
+ onAuthStateChange(callback: AuthStateChangeCallback): AuthSubscription;
1061
+ /**
1062
+ * Sign in with email and password
1063
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1064
+ */
1065
+ signIn(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1066
+ /**
1067
+ * Sign up with email and password
1068
+ */
1069
+ signUp(credentials: SignUpCredentials): Promise<AuthSession>;
1070
+ /**
1071
+ * Sign out the current user
1072
+ */
1073
+ signOut(): Promise<void>;
1074
+ /**
1075
+ * Refresh the access token
1076
+ */
1077
+ refreshToken(): Promise<AuthSession>;
1078
+ /**
1079
+ * Get the current user from the server
1080
+ */
1081
+ getCurrentUser(): Promise<User>;
1082
+ /**
1083
+ * Update the current user
1084
+ */
1085
+ updateUser(data: Partial<Pick<User, 'email' | 'metadata'>>): Promise<User>;
1086
+ /**
1087
+ * Set the auth token manually
1088
+ */
1089
+ setToken(token: string): void;
1090
+ /**
1091
+ * Setup 2FA for the current user
1092
+ * Returns TOTP secret and QR code URL
1093
+ */
1094
+ setup2FA(): Promise<TwoFactorSetupResponse>;
1095
+ /**
1096
+ * Enable 2FA after verifying the TOTP code
1097
+ * Returns backup codes that should be saved by the user
1098
+ */
1099
+ enable2FA(code: string): Promise<TwoFactorEnableResponse>;
1100
+ /**
1101
+ * Disable 2FA for the current user
1102
+ * Requires password confirmation
1103
+ */
1104
+ disable2FA(password: string): Promise<{
1105
+ success: boolean;
1106
+ message: string;
1107
+ }>;
1108
+ /**
1109
+ * Check 2FA status for the current user
1110
+ */
1111
+ get2FAStatus(): Promise<TwoFactorStatusResponse>;
1112
+ /**
1113
+ * Verify 2FA code during login
1114
+ * Call this after signIn returns requires_2fa: true
1115
+ */
1116
+ verify2FA(request: TwoFactorVerifyRequest): Promise<AuthSession>;
1117
+ /**
1118
+ * Send password reset email
1119
+ * Sends a password reset link to the provided email address
1120
+ * @param email - Email address to send reset link to
1121
+ */
1122
+ sendPasswordReset(email: string): Promise<PasswordResetResponse>;
1123
+ /**
1124
+ * Verify password reset token
1125
+ * Check if a password reset token is valid before allowing password reset
1126
+ * @param token - Password reset token to verify
1127
+ */
1128
+ verifyResetToken(token: string): Promise<VerifyResetTokenResponse>;
1129
+ /**
1130
+ * Reset password with token
1131
+ * Complete the password reset process with a valid token
1132
+ * @param token - Password reset token
1133
+ * @param newPassword - New password to set
1134
+ */
1135
+ resetPassword(token: string, newPassword: string): Promise<ResetPasswordResponse>;
1136
+ /**
1137
+ * Send magic link for passwordless authentication
1138
+ * @param email - Email address to send magic link to
1139
+ * @param options - Optional configuration for magic link
1140
+ */
1141
+ sendMagicLink(email: string, options?: MagicLinkOptions): Promise<MagicLinkResponse>;
1142
+ /**
1143
+ * Verify magic link token and sign in
1144
+ * @param token - Magic link token from email
1145
+ */
1146
+ verifyMagicLink(token: string): Promise<AuthSession>;
1147
+ /**
1148
+ * Sign in anonymously
1149
+ * Creates a temporary anonymous user session
1150
+ */
1151
+ signInAnonymously(): Promise<AuthSession>;
1152
+ /**
1153
+ * Get list of enabled OAuth providers
1154
+ */
1155
+ getOAuthProviders(): Promise<OAuthProvidersResponse>;
1156
+ /**
1157
+ * Get OAuth authorization URL for a provider
1158
+ * @param provider - OAuth provider name (e.g., 'google', 'github')
1159
+ * @param options - Optional OAuth configuration
1160
+ */
1161
+ getOAuthUrl(provider: string, options?: OAuthOptions): Promise<OAuthUrlResponse>;
1162
+ /**
1163
+ * Exchange OAuth authorization code for session
1164
+ * This is typically called in your OAuth callback handler
1165
+ * @param code - Authorization code from OAuth callback
1166
+ */
1167
+ exchangeCodeForSession(code: string): Promise<AuthSession>;
1168
+ /**
1169
+ * Convenience method to initiate OAuth sign-in
1170
+ * Redirects the user to the OAuth provider's authorization page
1171
+ * @param provider - OAuth provider name (e.g., 'google', 'github')
1172
+ * @param options - Optional OAuth configuration
1173
+ */
1174
+ signInWithOAuth(provider: string, options?: OAuthOptions): Promise<void>;
1175
+ /**
1176
+ * Internal: Set the session and persist it
1177
+ */
1178
+ private setSession;
1179
+ /**
1180
+ * Internal: Clear the session
1181
+ */
1182
+ private clearSession;
1183
+ /**
1184
+ * Internal: Save session to storage
1185
+ */
1186
+ private saveSession;
1187
+ /**
1188
+ * Internal: Schedule automatic token refresh
1189
+ */
1190
+ private scheduleTokenRefresh;
1191
+ /**
1192
+ * Internal: Emit auth state change event to all listeners
1193
+ */
1194
+ private emitAuthChange;
1195
+ }
1196
+
1197
+ /**
1198
+ * Realtime subscriptions using WebSockets
1199
+ */
1200
+
1201
+ declare class RealtimeChannel {
1202
+ private ws;
1203
+ private url;
1204
+ private token;
1205
+ private channelName;
1206
+ private callbacks;
1207
+ private subscriptionConfig;
1208
+ private reconnectAttempts;
1209
+ private maxReconnectAttempts;
1210
+ private reconnectDelay;
1211
+ private heartbeatInterval;
1212
+ constructor(url: string, channelName: string, token?: string | null);
1213
+ /**
1214
+ * Listen to postgres_changes with optional row-level filtering
1215
+ *
1216
+ * @param event - 'postgres_changes'
1217
+ * @param config - Configuration including optional filter
1218
+ * @param callback - Function to call when changes occur
1219
+ * @returns This channel for chaining
1220
+ *
1221
+ * @example
1222
+ * ```typescript
1223
+ * channel.on('postgres_changes', {
1224
+ * event: '*',
1225
+ * schema: 'public',
1226
+ * table: 'jobs',
1227
+ * filter: 'created_by=eq.user123'
1228
+ * }, (payload) => {
1229
+ * console.log('Job updated:', payload)
1230
+ * })
1231
+ * ```
1232
+ */
1233
+ on(event: 'postgres_changes', config: PostgresChangesConfig, callback: RealtimeCallback): this;
1234
+ /**
1235
+ * Listen to a specific event type (backwards compatibility)
1236
+ *
1237
+ * @param event - The event type (INSERT, UPDATE, DELETE, or '*' for all)
1238
+ * @param callback - The callback function
1239
+ * @returns This channel for chaining
1240
+ *
1241
+ * @example
1242
+ * ```typescript
1243
+ * channel.on('INSERT', (payload) => {
1244
+ * console.log('New record inserted:', payload.new_record)
1245
+ * })
1246
+ * ```
1247
+ */
1248
+ on(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
1249
+ /**
1250
+ * Remove a callback
1251
+ */
1252
+ off(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
1253
+ /**
1254
+ * Subscribe to the channel
1255
+ */
1256
+ subscribe(): this;
1257
+ /**
1258
+ * Unsubscribe from the channel
1259
+ */
1260
+ unsubscribe(): void;
1261
+ /**
1262
+ * Internal: Connect to WebSocket
1263
+ */
1264
+ private connect;
1265
+ /**
1266
+ * Internal: Disconnect WebSocket
1267
+ */
1268
+ private disconnect;
1269
+ /**
1270
+ * Internal: Send a message
1271
+ */
1272
+ private send;
1273
+ /**
1274
+ * Internal: Handle incoming message
1275
+ */
1276
+ private handleMessage;
1277
+ /**
1278
+ * Internal: Handle broadcast message
1279
+ */
1280
+ private handleBroadcast;
1281
+ /**
1282
+ * Internal: Start heartbeat interval
1283
+ */
1284
+ private startHeartbeat;
1285
+ /**
1286
+ * Internal: Stop heartbeat interval
1287
+ */
1288
+ private stopHeartbeat;
1289
+ /**
1290
+ * Internal: Attempt to reconnect
1291
+ */
1292
+ private attemptReconnect;
1293
+ }
1294
+ declare class FluxbaseRealtime {
1295
+ private url;
1296
+ private token;
1297
+ private channels;
1298
+ constructor(url: string, token?: string | null);
1299
+ /**
1300
+ * Create or get a channel
1301
+ * @param channelName - Channel name (e.g., 'table:public.products')
1302
+ */
1303
+ channel(channelName: string): RealtimeChannel;
1304
+ /**
1305
+ * Remove all channels
1306
+ */
1307
+ removeAllChannels(): void;
1308
+ /**
1309
+ * Update auth token for all channels
1310
+ */
1311
+ setToken(token: string | null): void;
1312
+ }
1313
+
1314
+ /**
1315
+ * Storage client for file operations
1316
+ */
1317
+
1318
+ declare class StorageBucket {
1319
+ private fetch;
1320
+ private bucketName;
1321
+ constructor(fetch: FluxbaseFetch, bucketName: string);
1322
+ /**
1323
+ * Upload a file to the bucket
1324
+ * @param path - The path/key for the file
1325
+ * @param file - The file to upload (File, Blob, or ArrayBuffer)
1326
+ * @param options - Upload options
1327
+ */
1328
+ upload(path: string, file: File | Blob | ArrayBuffer, options?: UploadOptions): Promise<{
1329
+ data: StorageObject | null;
1330
+ error: Error | null;
1331
+ }>;
1332
+ /**
1333
+ * Download a file from the bucket
1334
+ * @param path - The path/key of the file
1335
+ */
1336
+ download(path: string): Promise<{
1337
+ data: Blob | null;
1338
+ error: Error | null;
1339
+ }>;
1340
+ /**
1341
+ * List files in the bucket
1342
+ * @param options - List options (prefix, limit, offset)
1343
+ */
1344
+ list(options?: ListOptions): Promise<{
1345
+ data: StorageObject[] | null;
1346
+ error: Error | null;
1347
+ }>;
1348
+ /**
1349
+ * Remove files from the bucket
1350
+ * @param paths - Array of file paths to remove
1351
+ */
1352
+ remove(paths: string[]): Promise<{
1353
+ data: null;
1354
+ error: Error | null;
1355
+ }>;
1356
+ /**
1357
+ * Get a public URL for a file
1358
+ * @param path - The file path
1359
+ */
1360
+ getPublicUrl(path: string): {
1361
+ data: {
1362
+ publicUrl: string;
1363
+ };
1364
+ };
1365
+ /**
1366
+ * Create a signed URL for temporary access to a file
1367
+ * @param path - The file path
1368
+ * @param options - Signed URL options
1369
+ */
1370
+ createSignedUrl(path: string, options?: SignedUrlOptions): Promise<{
1371
+ data: {
1372
+ signedUrl: string;
1373
+ } | null;
1374
+ error: Error | null;
1375
+ }>;
1376
+ /**
1377
+ * Move a file to a new location
1378
+ * @param fromPath - Current file path
1379
+ * @param toPath - New file path
1380
+ */
1381
+ move(fromPath: string, toPath: string): Promise<{
1382
+ data: StorageObject | null;
1383
+ error: Error | null;
1384
+ }>;
1385
+ /**
1386
+ * Copy a file to a new location
1387
+ * @param fromPath - Source file path
1388
+ * @param toPath - Destination file path
1389
+ */
1390
+ copy(fromPath: string, toPath: string): Promise<{
1391
+ data: StorageObject | null;
1392
+ error: Error | null;
1393
+ }>;
1394
+ /**
1395
+ * Share a file with another user (RLS)
1396
+ * @param path - The file path
1397
+ * @param options - Share options (userId and permission)
1398
+ */
1399
+ share(path: string, options: ShareFileOptions): Promise<{
1400
+ data: null;
1401
+ error: Error | null;
1402
+ }>;
1403
+ /**
1404
+ * Revoke file access from a user (RLS)
1405
+ * @param path - The file path
1406
+ * @param userId - The user ID to revoke access from
1407
+ */
1408
+ revokeShare(path: string, userId: string): Promise<{
1409
+ data: null;
1410
+ error: Error | null;
1411
+ }>;
1412
+ /**
1413
+ * List users a file is shared with (RLS)
1414
+ * @param path - The file path
1415
+ */
1416
+ listShares(path: string): Promise<{
1417
+ data: FileShare[] | null;
1418
+ error: Error | null;
1419
+ }>;
1420
+ }
1421
+ declare class FluxbaseStorage {
1422
+ private fetch;
1423
+ constructor(fetch: FluxbaseFetch);
1424
+ /**
1425
+ * Get a reference to a storage bucket
1426
+ * @param bucketName - The name of the bucket
1427
+ */
1428
+ from(bucketName: string): StorageBucket;
1429
+ /**
1430
+ * List all buckets
1431
+ */
1432
+ listBuckets(): Promise<{
1433
+ data: Array<{
1434
+ name: string;
1435
+ created_at: string;
1436
+ }> | null;
1437
+ error: Error | null;
1438
+ }>;
1439
+ /**
1440
+ * Create a new bucket
1441
+ * @param bucketName - The name of the bucket to create
1442
+ */
1443
+ createBucket(bucketName: string): Promise<{
1444
+ data: null;
1445
+ error: Error | null;
1446
+ }>;
1447
+ /**
1448
+ * Delete a bucket
1449
+ * @param bucketName - The name of the bucket to delete
1450
+ */
1451
+ deleteBucket(bucketName: string): Promise<{
1452
+ data: null;
1453
+ error: Error | null;
1454
+ }>;
1455
+ /**
1456
+ * Empty a bucket (delete all files)
1457
+ * @param bucketName - The name of the bucket to empty
1458
+ */
1459
+ emptyBucket(bucketName: string): Promise<{
1460
+ data: null;
1461
+ error: Error | null;
1462
+ }>;
1463
+ /**
1464
+ * Update bucket settings (RLS - requires admin or service key)
1465
+ * @param bucketName - The name of the bucket
1466
+ * @param settings - Bucket settings to update
1467
+ */
1468
+ updateBucketSettings(bucketName: string, settings: BucketSettings): Promise<{
1469
+ data: null;
1470
+ error: Error | null;
1471
+ }>;
1472
+ /**
1473
+ * Get bucket details
1474
+ * @param bucketName - The name of the bucket
1475
+ */
1476
+ getBucket(bucketName: string): Promise<{
1477
+ data: Bucket | null;
1478
+ error: Error | null;
1479
+ }>;
1480
+ }
1481
+
1482
+ /**
1483
+ * System Settings Manager
1484
+ *
1485
+ * Manages low-level system settings with key-value storage.
1486
+ * For application-level settings, use AppSettingsManager instead.
1487
+ *
1488
+ * @example
1489
+ * ```typescript
1490
+ * const settings = client.admin.settings.system
1491
+ *
1492
+ * // List all system settings
1493
+ * const { settings } = await settings.list()
1494
+ *
1495
+ * // Get specific setting
1496
+ * const setting = await settings.get('app.auth.enable_signup')
1497
+ *
1498
+ * // Update setting
1499
+ * await settings.update('app.auth.enable_signup', {
1500
+ * value: { value: true },
1501
+ * description: 'Enable user signup'
1502
+ * })
1503
+ *
1504
+ * // Delete setting
1505
+ * await settings.delete('app.auth.enable_signup')
1506
+ * ```
1507
+ */
1508
+ declare class SystemSettingsManager {
1509
+ private fetch;
1510
+ constructor(fetch: FluxbaseFetch);
1511
+ /**
1512
+ * List all system settings
1513
+ *
1514
+ * @returns Promise resolving to ListSystemSettingsResponse
1515
+ *
1516
+ * @example
1517
+ * ```typescript
1518
+ * const response = await client.admin.settings.system.list()
1519
+ * console.log(response.settings)
1520
+ * ```
1521
+ */
1522
+ list(): Promise<ListSystemSettingsResponse>;
1523
+ /**
1524
+ * Get a specific system setting by key
1525
+ *
1526
+ * @param key - Setting key (e.g., 'app.auth.enable_signup')
1527
+ * @returns Promise resolving to SystemSetting
1528
+ *
1529
+ * @example
1530
+ * ```typescript
1531
+ * const setting = await client.admin.settings.system.get('app.auth.enable_signup')
1532
+ * console.log(setting.value)
1533
+ * ```
1534
+ */
1535
+ get(key: string): Promise<SystemSetting>;
1536
+ /**
1537
+ * Update or create a system setting
1538
+ *
1539
+ * @param key - Setting key
1540
+ * @param request - Update request with value and optional description
1541
+ * @returns Promise resolving to SystemSetting
1542
+ *
1543
+ * @example
1544
+ * ```typescript
1545
+ * const updated = await client.admin.settings.system.update('app.auth.enable_signup', {
1546
+ * value: { value: true },
1547
+ * description: 'Enable user signup'
1548
+ * })
1549
+ * ```
1550
+ */
1551
+ update(key: string, request: UpdateSystemSettingRequest): Promise<SystemSetting>;
1552
+ /**
1553
+ * Delete a system setting
1554
+ *
1555
+ * @param key - Setting key to delete
1556
+ * @returns Promise<void>
1557
+ *
1558
+ * @example
1559
+ * ```typescript
1560
+ * await client.admin.settings.system.delete('app.auth.enable_signup')
1561
+ * ```
1562
+ */
1563
+ delete(key: string): Promise<void>;
1564
+ }
1565
+ /**
1566
+ * Application Settings Manager
1567
+ *
1568
+ * Manages high-level application settings with a structured API.
1569
+ * Provides type-safe access to authentication, features, email, and security settings.
1570
+ *
1571
+ * @example
1572
+ * ```typescript
1573
+ * const settings = client.admin.settings.app
1574
+ *
1575
+ * // Get all app settings
1576
+ * const appSettings = await settings.get()
1577
+ * console.log(appSettings.authentication.enable_signup)
1578
+ *
1579
+ * // Update specific settings
1580
+ * const updated = await settings.update({
1581
+ * authentication: {
1582
+ * enable_signup: true,
1583
+ * password_min_length: 12
1584
+ * }
1585
+ * })
1586
+ *
1587
+ * // Reset to defaults
1588
+ * await settings.reset()
1589
+ * ```
1590
+ */
1591
+ declare class AppSettingsManager {
1592
+ private fetch;
1593
+ constructor(fetch: FluxbaseFetch);
1594
+ /**
1595
+ * Get all application settings
1596
+ *
1597
+ * Returns structured settings for authentication, features, email, and security.
1598
+ *
1599
+ * @returns Promise resolving to AppSettings
1600
+ *
1601
+ * @example
1602
+ * ```typescript
1603
+ * const settings = await client.admin.settings.app.get()
1604
+ *
1605
+ * console.log('Signup enabled:', settings.authentication.enable_signup)
1606
+ * console.log('Realtime enabled:', settings.features.enable_realtime)
1607
+ * console.log('Email provider:', settings.email.provider)
1608
+ * ```
1609
+ */
1610
+ get(): Promise<AppSettings>;
1611
+ /**
1612
+ * Update application settings
1613
+ *
1614
+ * Supports partial updates - only provide the fields you want to change.
1615
+ *
1616
+ * @param request - Settings to update (partial update supported)
1617
+ * @returns Promise resolving to AppSettings - Updated settings
1618
+ *
1619
+ * @example
1620
+ * ```typescript
1621
+ * // Update authentication settings
1622
+ * const updated = await client.admin.settings.app.update({
1623
+ * authentication: {
1624
+ * enable_signup: true,
1625
+ * password_min_length: 12
1626
+ * }
1627
+ * })
1628
+ *
1629
+ * // Update multiple categories
1630
+ * await client.admin.settings.app.update({
1631
+ * authentication: { enable_signup: false },
1632
+ * features: { enable_realtime: true },
1633
+ * security: { enable_global_rate_limit: true }
1634
+ * })
1635
+ * ```
1636
+ */
1637
+ update(request: UpdateAppSettingsRequest): Promise<AppSettings>;
1638
+ /**
1639
+ * Reset all application settings to defaults
1640
+ *
1641
+ * This will delete all custom settings and return to default values.
1642
+ *
1643
+ * @returns Promise resolving to AppSettings - Default settings
1644
+ *
1645
+ * @example
1646
+ * ```typescript
1647
+ * const defaults = await client.admin.settings.app.reset()
1648
+ * console.log('Settings reset to defaults:', defaults)
1649
+ * ```
1650
+ */
1651
+ reset(): Promise<AppSettings>;
1652
+ /**
1653
+ * Enable user signup
1654
+ *
1655
+ * Convenience method to enable user registration.
1656
+ *
1657
+ * @returns Promise resolving to AppSettings
1658
+ *
1659
+ * @example
1660
+ * ```typescript
1661
+ * await client.admin.settings.app.enableSignup()
1662
+ * ```
1663
+ */
1664
+ enableSignup(): Promise<AppSettings>;
1665
+ /**
1666
+ * Disable user signup
1667
+ *
1668
+ * Convenience method to disable user registration.
1669
+ *
1670
+ * @returns Promise resolving to AppSettings
1671
+ *
1672
+ * @example
1673
+ * ```typescript
1674
+ * await client.admin.settings.app.disableSignup()
1675
+ * ```
1676
+ */
1677
+ disableSignup(): Promise<AppSettings>;
1678
+ /**
1679
+ * Update password minimum length
1680
+ *
1681
+ * Convenience method to set password requirements.
1682
+ *
1683
+ * @param length - Minimum password length (8-128 characters)
1684
+ * @returns Promise resolving to AppSettings
1685
+ *
1686
+ * @example
1687
+ * ```typescript
1688
+ * await client.admin.settings.app.setPasswordMinLength(12)
1689
+ * ```
1690
+ */
1691
+ setPasswordMinLength(length: number): Promise<AppSettings>;
1692
+ /**
1693
+ * Enable or disable a feature
1694
+ *
1695
+ * Convenience method to toggle feature flags.
1696
+ *
1697
+ * @param feature - Feature name ('realtime' | 'storage' | 'functions')
1698
+ * @param enabled - Whether to enable or disable the feature
1699
+ * @returns Promise resolving to AppSettings
1700
+ *
1701
+ * @example
1702
+ * ```typescript
1703
+ * // Enable realtime
1704
+ * await client.admin.settings.app.setFeature('realtime', true)
1705
+ *
1706
+ * // Disable storage
1707
+ * await client.admin.settings.app.setFeature('storage', false)
1708
+ * ```
1709
+ */
1710
+ setFeature(feature: "realtime" | "storage" | "functions", enabled: boolean): Promise<AppSettings>;
1711
+ /**
1712
+ * Enable or disable global rate limiting
1713
+ *
1714
+ * Convenience method to toggle global rate limiting.
1715
+ *
1716
+ * @param enabled - Whether to enable rate limiting
1717
+ * @returns Promise resolving to AppSettings
1718
+ *
1719
+ * @example
1720
+ * ```typescript
1721
+ * await client.admin.settings.app.setRateLimiting(true)
1722
+ * ```
1723
+ */
1724
+ setRateLimiting(enabled: boolean): Promise<AppSettings>;
1725
+ /**
1726
+ * Configure SMTP email provider
1727
+ *
1728
+ * Convenience method to set up SMTP email delivery.
1729
+ *
1730
+ * @param config - SMTP configuration
1731
+ * @returns Promise resolving to AppSettings
1732
+ *
1733
+ * @example
1734
+ * ```typescript
1735
+ * await client.admin.settings.app.configureSMTP({
1736
+ * host: 'smtp.gmail.com',
1737
+ * port: 587,
1738
+ * username: 'your-email@gmail.com',
1739
+ * password: 'your-app-password',
1740
+ * use_tls: true,
1741
+ * from_address: 'noreply@yourapp.com',
1742
+ * from_name: 'Your App'
1743
+ * })
1744
+ * ```
1745
+ */
1746
+ configureSMTP(config: {
1747
+ host: string;
1748
+ port: number;
1749
+ username: string;
1750
+ password: string;
1751
+ use_tls: boolean;
1752
+ from_address?: string;
1753
+ from_name?: string;
1754
+ reply_to_address?: string;
1755
+ }): Promise<AppSettings>;
1756
+ /**
1757
+ * Configure SendGrid email provider
1758
+ *
1759
+ * Convenience method to set up SendGrid email delivery.
1760
+ *
1761
+ * @param apiKey - SendGrid API key
1762
+ * @param options - Optional from address, name, and reply-to
1763
+ * @returns Promise resolving to AppSettings
1764
+ *
1765
+ * @example
1766
+ * ```typescript
1767
+ * await client.admin.settings.app.configureSendGrid('SG.xxx', {
1768
+ * from_address: 'noreply@yourapp.com',
1769
+ * from_name: 'Your App'
1770
+ * })
1771
+ * ```
1772
+ */
1773
+ configureSendGrid(apiKey: string, options?: {
1774
+ from_address?: string;
1775
+ from_name?: string;
1776
+ reply_to_address?: string;
1777
+ }): Promise<AppSettings>;
1778
+ /**
1779
+ * Configure Mailgun email provider
1780
+ *
1781
+ * Convenience method to set up Mailgun email delivery.
1782
+ *
1783
+ * @param apiKey - Mailgun API key
1784
+ * @param domain - Mailgun domain
1785
+ * @param options - Optional EU region flag and email addresses
1786
+ * @returns Promise resolving to AppSettings
1787
+ *
1788
+ * @example
1789
+ * ```typescript
1790
+ * await client.admin.settings.app.configureMailgun('key-xxx', 'mg.yourapp.com', {
1791
+ * eu_region: false,
1792
+ * from_address: 'noreply@yourapp.com',
1793
+ * from_name: 'Your App'
1794
+ * })
1795
+ * ```
1796
+ */
1797
+ configureMailgun(apiKey: string, domain: string, options?: {
1798
+ eu_region?: boolean;
1799
+ from_address?: string;
1800
+ from_name?: string;
1801
+ reply_to_address?: string;
1802
+ }): Promise<AppSettings>;
1803
+ /**
1804
+ * Configure AWS SES email provider
1805
+ *
1806
+ * Convenience method to set up AWS SES email delivery.
1807
+ *
1808
+ * @param accessKeyId - AWS access key ID
1809
+ * @param secretAccessKey - AWS secret access key
1810
+ * @param region - AWS region (e.g., 'us-east-1')
1811
+ * @param options - Optional email addresses
1812
+ * @returns Promise resolving to AppSettings
1813
+ *
1814
+ * @example
1815
+ * ```typescript
1816
+ * await client.admin.settings.app.configureSES(
1817
+ * 'AKIAIOSFODNN7EXAMPLE',
1818
+ * 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
1819
+ * 'us-east-1',
1820
+ * {
1821
+ * from_address: 'noreply@yourapp.com',
1822
+ * from_name: 'Your App'
1823
+ * }
1824
+ * )
1825
+ * ```
1826
+ */
1827
+ configureSES(accessKeyId: string, secretAccessKey: string, region: string, options?: {
1828
+ from_address?: string;
1829
+ from_name?: string;
1830
+ reply_to_address?: string;
1831
+ }): Promise<AppSettings>;
1832
+ /**
1833
+ * Enable or disable email functionality
1834
+ *
1835
+ * Convenience method to toggle email system on/off.
1836
+ *
1837
+ * @param enabled - Whether to enable email
1838
+ * @returns Promise resolving to AppSettings
1839
+ *
1840
+ * @example
1841
+ * ```typescript
1842
+ * await client.admin.settings.app.setEmailEnabled(true)
1843
+ * ```
1844
+ */
1845
+ setEmailEnabled(enabled: boolean): Promise<AppSettings>;
1846
+ /**
1847
+ * Configure password complexity requirements
1848
+ *
1849
+ * Convenience method to set password validation rules.
1850
+ *
1851
+ * @param requirements - Password complexity requirements
1852
+ * @returns Promise resolving to AppSettings
1853
+ *
1854
+ * @example
1855
+ * ```typescript
1856
+ * await client.admin.settings.app.setPasswordComplexity({
1857
+ * min_length: 12,
1858
+ * require_uppercase: true,
1859
+ * require_lowercase: true,
1860
+ * require_number: true,
1861
+ * require_special: true
1862
+ * })
1863
+ * ```
1864
+ */
1865
+ setPasswordComplexity(requirements: {
1866
+ min_length?: number;
1867
+ require_uppercase?: boolean;
1868
+ require_lowercase?: boolean;
1869
+ require_number?: boolean;
1870
+ require_special?: boolean;
1871
+ }): Promise<AppSettings>;
1872
+ /**
1873
+ * Configure session settings
1874
+ *
1875
+ * Convenience method to set session timeout and limits.
1876
+ *
1877
+ * @param timeoutMinutes - Session timeout in minutes (0 for no timeout)
1878
+ * @param maxSessionsPerUser - Maximum concurrent sessions per user (0 for unlimited)
1879
+ * @returns Promise resolving to AppSettings
1880
+ *
1881
+ * @example
1882
+ * ```typescript
1883
+ * // 30 minute sessions, max 3 devices per user
1884
+ * await client.admin.settings.app.setSessionSettings(30, 3)
1885
+ * ```
1886
+ */
1887
+ setSessionSettings(timeoutMinutes: number, maxSessionsPerUser: number): Promise<AppSettings>;
1888
+ /**
1889
+ * Enable or disable email verification requirement
1890
+ *
1891
+ * Convenience method to require email verification for new signups.
1892
+ *
1893
+ * @param required - Whether to require email verification
1894
+ * @returns Promise resolving to AppSettings
1895
+ *
1896
+ * @example
1897
+ * ```typescript
1898
+ * await client.admin.settings.app.setEmailVerificationRequired(true)
1899
+ * ```
1900
+ */
1901
+ setEmailVerificationRequired(required: boolean): Promise<AppSettings>;
1902
+ }
1903
+ /**
1904
+ * Custom Settings Manager
1905
+ *
1906
+ * Manages custom admin-created settings with flexible key-value storage.
1907
+ * Unlike system settings, custom settings allow admins to create arbitrary configuration entries
1908
+ * with role-based editing permissions.
1909
+ *
1910
+ * @example
1911
+ * ```typescript
1912
+ * const custom = client.admin.settings.custom
1913
+ *
1914
+ * // Create a custom setting
1915
+ * const setting = await custom.create({
1916
+ * key: 'feature.dark_mode',
1917
+ * value: { enabled: true, theme: 'dark' },
1918
+ * value_type: 'json',
1919
+ * description: 'Dark mode configuration',
1920
+ * editable_by: ['dashboard_admin', 'admin']
1921
+ * })
1922
+ *
1923
+ * // List all custom settings
1924
+ * const { settings } = await custom.list()
1925
+ *
1926
+ * // Get specific setting
1927
+ * const darkMode = await custom.get('feature.dark_mode')
1928
+ *
1929
+ * // Update setting
1930
+ * await custom.update('feature.dark_mode', {
1931
+ * value: { enabled: false, theme: 'light' }
1932
+ * })
1933
+ *
1934
+ * // Delete setting
1935
+ * await custom.delete('feature.dark_mode')
1936
+ * ```
1937
+ */
1938
+ declare class CustomSettingsManager {
1939
+ private fetch;
1940
+ constructor(fetch: FluxbaseFetch);
1941
+ /**
1942
+ * Create a new custom setting
1943
+ *
1944
+ * @param request - Custom setting creation request
1945
+ * @returns Promise resolving to CustomSetting
1946
+ *
1947
+ * @example
1948
+ * ```typescript
1949
+ * const setting = await client.admin.settings.custom.create({
1950
+ * key: 'api.quotas',
1951
+ * value: { free: 1000, pro: 10000, enterprise: 100000 },
1952
+ * value_type: 'json',
1953
+ * description: 'API request quotas by tier',
1954
+ * metadata: { category: 'billing' }
1955
+ * })
1956
+ * ```
1957
+ */
1958
+ create(request: CreateCustomSettingRequest): Promise<CustomSetting>;
1959
+ /**
1960
+ * List all custom settings
1961
+ *
1962
+ * @returns Promise resolving to ListCustomSettingsResponse
1963
+ *
1964
+ * @example
1965
+ * ```typescript
1966
+ * const response = await client.admin.settings.custom.list()
1967
+ * console.log(response.settings)
1968
+ * ```
1969
+ */
1970
+ list(): Promise<ListCustomSettingsResponse>;
1971
+ /**
1972
+ * Get a specific custom setting by key
1973
+ *
1974
+ * @param key - Setting key (e.g., 'feature.dark_mode')
1975
+ * @returns Promise resolving to CustomSetting
1976
+ *
1977
+ * @example
1978
+ * ```typescript
1979
+ * const setting = await client.admin.settings.custom.get('feature.dark_mode')
1980
+ * console.log(setting.value)
1981
+ * ```
1982
+ */
1983
+ get(key: string): Promise<CustomSetting>;
1984
+ /**
1985
+ * Update an existing custom setting
1986
+ *
1987
+ * @param key - Setting key
1988
+ * @param request - Update request with new values
1989
+ * @returns Promise resolving to CustomSetting
1990
+ *
1991
+ * @example
1992
+ * ```typescript
1993
+ * const updated = await client.admin.settings.custom.update('feature.dark_mode', {
1994
+ * value: { enabled: false },
1995
+ * description: 'Updated description'
1996
+ * })
1997
+ * ```
1998
+ */
1999
+ update(key: string, request: UpdateCustomSettingRequest): Promise<CustomSetting>;
2000
+ /**
2001
+ * Delete a custom setting
2002
+ *
2003
+ * @param key - Setting key to delete
2004
+ * @returns Promise<void>
2005
+ *
2006
+ * @example
2007
+ * ```typescript
2008
+ * await client.admin.settings.custom.delete('feature.dark_mode')
2009
+ * ```
2010
+ */
2011
+ delete(key: string): Promise<void>;
2012
+ }
2013
+ /**
2014
+ * Email Template Manager
2015
+ *
2016
+ * Manages email templates for authentication and user communication.
2017
+ * Supports customizing templates for magic links, email verification, password resets, and user invitations.
2018
+ *
2019
+ * @example
2020
+ * ```typescript
2021
+ * const templates = client.admin.emailTemplates
2022
+ *
2023
+ * // List all templates
2024
+ * const { templates: allTemplates } = await templates.list()
2025
+ *
2026
+ * // Get specific template
2027
+ * const magicLink = await templates.get('magic_link')
2028
+ *
2029
+ * // Update template
2030
+ * await templates.update('magic_link', {
2031
+ * subject: 'Sign in to ' + '{{.AppName}}',
2032
+ * html_body: '<html>Custom template with ' + '{{.MagicLink}}' + '</html>',
2033
+ * text_body: 'Click here: ' + '{{.MagicLink}}'
2034
+ * })
2035
+ *
2036
+ * // Test template (sends to specified email)
2037
+ * await templates.test('magic_link', 'test@example.com')
2038
+ *
2039
+ * // Reset to default
2040
+ * await templates.reset('magic_link')
2041
+ * ```
2042
+ */
2043
+ declare class EmailTemplateManager {
2044
+ private fetch;
2045
+ constructor(fetch: FluxbaseFetch);
2046
+ /**
2047
+ * List all email templates
2048
+ *
2049
+ * @returns Promise resolving to ListEmailTemplatesResponse
2050
+ *
2051
+ * @example
2052
+ * ```typescript
2053
+ * const response = await client.admin.emailTemplates.list()
2054
+ * console.log(response.templates)
2055
+ * ```
2056
+ */
2057
+ list(): Promise<ListEmailTemplatesResponse>;
2058
+ /**
2059
+ * Get a specific email template by type
2060
+ *
2061
+ * @param type - Template type (magic_link | verify_email | reset_password | invite_user)
2062
+ * @returns Promise resolving to EmailTemplate
2063
+ *
2064
+ * @example
2065
+ * ```typescript
2066
+ * const template = await client.admin.emailTemplates.get('magic_link')
2067
+ * console.log(template.subject)
2068
+ * console.log(template.html_body)
2069
+ * ```
2070
+ */
2071
+ get(type: EmailTemplateType): Promise<EmailTemplate>;
2072
+ /**
2073
+ * Update an email template
2074
+ *
2075
+ * Available template variables:
2076
+ * - magic_link: `{{.MagicLink}}`, `{{.AppName}}`, `{{.ExpiryMinutes}}`
2077
+ * - verify_email: `{{.VerificationLink}}`, `{{.AppName}}`
2078
+ * - reset_password: `{{.ResetLink}}`, `{{.AppName}}`, `{{.ExpiryMinutes}}`
2079
+ * - invite_user: `{{.InviteLink}}`, `{{.AppName}}`, `{{.InviterName}}`
2080
+ *
2081
+ * @param type - Template type to update
2082
+ * @param request - Update request with subject, html_body, and optional text_body
2083
+ * @returns Promise resolving to EmailTemplate
2084
+ *
2085
+ * @example
2086
+ * ```typescript
2087
+ * const updated = await client.admin.emailTemplates.update('magic_link', {
2088
+ * subject: 'Your Magic Link - Sign in to ' + '{{.AppName}}',
2089
+ * html_body: '<html><body><h1>Welcome!</h1><a href="' + '{{.MagicLink}}' + '">Sign In</a></body></html>',
2090
+ * text_body: 'Click here to sign in: ' + '{{.MagicLink}}'
2091
+ * })
2092
+ * ```
2093
+ */
2094
+ update(type: EmailTemplateType, request: UpdateEmailTemplateRequest): Promise<EmailTemplate>;
2095
+ /**
2096
+ * Reset an email template to default
2097
+ *
2098
+ * Removes any customizations and restores the template to its original state.
2099
+ *
2100
+ * @param type - Template type to reset
2101
+ * @returns Promise resolving to EmailTemplate - The default template
2102
+ *
2103
+ * @example
2104
+ * ```typescript
2105
+ * const defaultTemplate = await client.admin.emailTemplates.reset('magic_link')
2106
+ * ```
2107
+ */
2108
+ reset(type: EmailTemplateType): Promise<EmailTemplate>;
2109
+ /**
2110
+ * Send a test email using the template
2111
+ *
2112
+ * Useful for previewing template changes before deploying to production.
2113
+ *
2114
+ * @param type - Template type to test
2115
+ * @param recipientEmail - Email address to send test to
2116
+ * @returns Promise<void>
2117
+ *
2118
+ * @example
2119
+ * ```typescript
2120
+ * await client.admin.emailTemplates.test('magic_link', 'test@example.com')
2121
+ * ```
2122
+ */
2123
+ test(type: EmailTemplateType, recipientEmail: string): Promise<void>;
2124
+ }
2125
+ /**
2126
+ * Settings Manager
2127
+ *
2128
+ * Provides access to system-level, application-level, and custom settings.
2129
+ *
2130
+ * @example
2131
+ * ```typescript
2132
+ * const settings = client.admin.settings
2133
+ *
2134
+ * // Access system settings
2135
+ * const systemSettings = await settings.system.list()
2136
+ *
2137
+ * // Access app settings
2138
+ * const appSettings = await settings.app.get()
2139
+ *
2140
+ * // Access custom settings
2141
+ * const customSettings = await settings.custom.list()
2142
+ * ```
2143
+ */
2144
+ declare class FluxbaseSettings {
2145
+ system: SystemSettingsManager;
2146
+ app: AppSettingsManager;
2147
+ custom: CustomSettingsManager;
2148
+ constructor(fetch: FluxbaseFetch);
2149
+ }
2150
+
2151
+ /**
2152
+ * DDL (Data Definition Language) Manager
2153
+ *
2154
+ * Provides methods for managing database schemas and tables programmatically.
2155
+ * This includes creating schemas, creating tables with custom columns, listing
2156
+ * schemas and tables, and deleting tables.
2157
+ *
2158
+ * @example
2159
+ * ```typescript
2160
+ * const ddl = client.admin.ddl
2161
+ *
2162
+ * // Create a new schema
2163
+ * await ddl.createSchema('analytics')
2164
+ *
2165
+ * // Create a table with columns
2166
+ * await ddl.createTable('analytics', 'events', [
2167
+ * { name: 'id', type: 'UUID', primaryKey: true, defaultValue: 'gen_random_uuid()' },
2168
+ * { name: 'user_id', type: 'UUID', nullable: false },
2169
+ * { name: 'event_name', type: 'TEXT', nullable: false },
2170
+ * { name: 'event_data', type: 'JSONB' },
2171
+ * { name: 'created_at', type: 'TIMESTAMPTZ', defaultValue: 'NOW()' }
2172
+ * ])
2173
+ *
2174
+ * // List all schemas
2175
+ * const { schemas } = await ddl.listSchemas()
2176
+ *
2177
+ * // List all tables in a schema
2178
+ * const { tables } = await ddl.listTables('analytics')
2179
+ *
2180
+ * // Delete a table
2181
+ * await ddl.deleteTable('analytics', 'events')
2182
+ * ```
2183
+ */
2184
+ declare class DDLManager {
2185
+ private fetch;
2186
+ constructor(fetch: FluxbaseFetch);
2187
+ /**
2188
+ * Create a new database schema
2189
+ *
2190
+ * Creates a new schema in the database. Schemas are used to organize tables
2191
+ * into logical groups and provide namespace isolation.
2192
+ *
2193
+ * @param name - Schema name (must be valid PostgreSQL identifier)
2194
+ * @returns Promise resolving to CreateSchemaResponse
2195
+ *
2196
+ * @example
2197
+ * ```typescript
2198
+ * // Create a schema for analytics data
2199
+ * const result = await client.admin.ddl.createSchema('analytics')
2200
+ * console.log(result.message) // "Schema created successfully"
2201
+ * console.log(result.schema) // "analytics"
2202
+ * ```
2203
+ */
2204
+ createSchema(name: string): Promise<CreateSchemaResponse>;
2205
+ /**
2206
+ * List all database schemas
2207
+ *
2208
+ * Retrieves a list of all schemas in the database. This includes both
2209
+ * system schemas (like 'public', 'pg_catalog') and user-created schemas.
2210
+ *
2211
+ * @returns Promise resolving to ListSchemasResponse
2212
+ *
2213
+ * @example
2214
+ * ```typescript
2215
+ * const { schemas } = await client.admin.ddl.listSchemas()
2216
+ *
2217
+ * schemas.forEach(schema => {
2218
+ * console.log(`Schema: ${schema.name}, Owner: ${schema.owner}`)
2219
+ * })
2220
+ * ```
2221
+ */
2222
+ listSchemas(): Promise<ListSchemasResponse>;
2223
+ /**
2224
+ * Create a new table in a schema
2225
+ *
2226
+ * Creates a new table with the specified columns. Supports various column
2227
+ * options including primary keys, nullability, data types, and default values.
2228
+ *
2229
+ * @param schema - Schema name where the table will be created
2230
+ * @param name - Table name (must be valid PostgreSQL identifier)
2231
+ * @param columns - Array of column definitions
2232
+ * @returns Promise resolving to CreateTableResponse
2233
+ *
2234
+ * @example
2235
+ * ```typescript
2236
+ * // Create a users table
2237
+ * await client.admin.ddl.createTable('public', 'users', [
2238
+ * {
2239
+ * name: 'id',
2240
+ * type: 'UUID',
2241
+ * primaryKey: true,
2242
+ * defaultValue: 'gen_random_uuid()'
2243
+ * },
2244
+ * {
2245
+ * name: 'email',
2246
+ * type: 'TEXT',
2247
+ * nullable: false
2248
+ * },
2249
+ * {
2250
+ * name: 'name',
2251
+ * type: 'TEXT'
2252
+ * },
2253
+ * {
2254
+ * name: 'created_at',
2255
+ * type: 'TIMESTAMPTZ',
2256
+ * nullable: false,
2257
+ * defaultValue: 'NOW()'
2258
+ * }
2259
+ * ])
2260
+ * ```
2261
+ *
2262
+ * @example
2263
+ * ```typescript
2264
+ * // Create a products table with JSONB metadata
2265
+ * await client.admin.ddl.createTable('public', 'products', [
2266
+ * { name: 'id', type: 'SERIAL', primaryKey: true },
2267
+ * { name: 'name', type: 'TEXT', nullable: false },
2268
+ * { name: 'price', type: 'DECIMAL(10,2)', nullable: false },
2269
+ * { name: 'metadata', type: 'JSONB' },
2270
+ * { name: 'in_stock', type: 'BOOLEAN', defaultValue: 'true' }
2271
+ * ])
2272
+ * ```
2273
+ */
2274
+ createTable(schema: string, name: string, columns: CreateColumnRequest[]): Promise<CreateTableResponse>;
2275
+ /**
2276
+ * List all tables in the database or a specific schema
2277
+ *
2278
+ * Retrieves a list of all tables. If a schema is specified, only tables
2279
+ * from that schema are returned. Otherwise, all tables from all schemas
2280
+ * are returned.
2281
+ *
2282
+ * @param schema - Optional schema name to filter tables
2283
+ * @returns Promise resolving to ListTablesResponse
2284
+ *
2285
+ * @example
2286
+ * ```typescript
2287
+ * // List all tables in the public schema
2288
+ * const { tables } = await client.admin.ddl.listTables('public')
2289
+ *
2290
+ * tables.forEach(table => {
2291
+ * console.log(`Table: ${table.schema}.${table.name}`)
2292
+ * table.columns?.forEach(col => {
2293
+ * console.log(` - ${col.name}: ${col.type}`)
2294
+ * })
2295
+ * })
2296
+ * ```
2297
+ *
2298
+ * @example
2299
+ * ```typescript
2300
+ * // List all tables across all schemas
2301
+ * const { tables } = await client.admin.ddl.listTables()
2302
+ *
2303
+ * const tablesBySchema = tables.reduce((acc, table) => {
2304
+ * if (!acc[table.schema]) acc[table.schema] = []
2305
+ * acc[table.schema].push(table.name)
2306
+ * return acc
2307
+ * }, {} as Record<string, string[]>)
2308
+ *
2309
+ * console.log(tablesBySchema)
2310
+ * ```
2311
+ */
2312
+ listTables(schema?: string): Promise<ListTablesResponse>;
2313
+ /**
2314
+ * Delete a table from a schema
2315
+ *
2316
+ * Permanently deletes a table and all its data. This operation cannot be undone.
2317
+ *
2318
+ * @param schema - Schema name containing the table
2319
+ * @param name - Table name to delete
2320
+ * @returns Promise resolving to DeleteTableResponse
2321
+ *
2322
+ * @example
2323
+ * ```typescript
2324
+ * // Delete a table
2325
+ * const result = await client.admin.ddl.deleteTable('public', 'old_data')
2326
+ * console.log(result.message) // "Table deleted successfully"
2327
+ * ```
2328
+ *
2329
+ * @example
2330
+ * ```typescript
2331
+ * // Safe deletion with confirmation
2332
+ * const confirm = await askUser('Are you sure you want to delete this table?')
2333
+ * if (confirm) {
2334
+ * await client.admin.ddl.deleteTable('analytics', 'events')
2335
+ * console.log('Table deleted')
2336
+ * }
2337
+ * ```
2338
+ */
2339
+ deleteTable(schema: string, name: string): Promise<DeleteTableResponse>;
2340
+ }
2341
+
2342
+ /**
2343
+ * OAuth Provider Manager
2344
+ *
2345
+ * Manages OAuth provider configurations for third-party authentication.
2346
+ * Supports both built-in providers (Google, GitHub, etc.) and custom OAuth2 providers.
2347
+ *
2348
+ * @example
2349
+ * ```typescript
2350
+ * const oauth = client.admin.oauth
2351
+ *
2352
+ * // List all OAuth providers
2353
+ * const { providers } = await oauth.listProviders()
2354
+ *
2355
+ * // Create a new provider
2356
+ * await oauth.createProvider({
2357
+ * provider_name: 'github',
2358
+ * display_name: 'GitHub',
2359
+ * enabled: true,
2360
+ * client_id: 'your-client-id',
2361
+ * client_secret: 'your-client-secret',
2362
+ * redirect_url: 'https://yourapp.com/auth/callback',
2363
+ * scopes: ['user:email', 'read:user'],
2364
+ * is_custom: false
2365
+ * })
2366
+ *
2367
+ * // Update a provider
2368
+ * await oauth.updateProvider('provider-id', {
2369
+ * enabled: false
2370
+ * })
2371
+ *
2372
+ * // Delete a provider
2373
+ * await oauth.deleteProvider('provider-id')
2374
+ * ```
2375
+ */
2376
+ declare class OAuthProviderManager {
2377
+ private fetch;
2378
+ constructor(fetch: FluxbaseFetch);
2379
+ /**
2380
+ * List all OAuth providers
2381
+ *
2382
+ * Retrieves all configured OAuth providers including both enabled and disabled providers.
2383
+ * Note: Client secrets are not included in the response for security reasons.
2384
+ *
2385
+ * @returns Promise resolving to ListOAuthProvidersResponse
2386
+ *
2387
+ * @example
2388
+ * ```typescript
2389
+ * const { providers } = await client.admin.oauth.listProviders()
2390
+ *
2391
+ * providers.forEach(provider => {
2392
+ * console.log(`${provider.display_name}: ${provider.enabled ? 'enabled' : 'disabled'}`)
2393
+ * })
2394
+ * ```
2395
+ */
2396
+ listProviders(): Promise<OAuthProvider[]>;
2397
+ /**
2398
+ * Get a specific OAuth provider by ID
2399
+ *
2400
+ * Retrieves detailed configuration for a single OAuth provider.
2401
+ * Note: Client secret is not included in the response.
2402
+ *
2403
+ * @param providerId - Provider ID (UUID)
2404
+ * @returns Promise resolving to OAuthProvider
2405
+ *
2406
+ * @example
2407
+ * ```typescript
2408
+ * const provider = await client.admin.oauth.getProvider('provider-uuid')
2409
+ *
2410
+ * console.log('Provider:', provider.display_name)
2411
+ * console.log('Scopes:', provider.scopes.join(', '))
2412
+ * console.log('Redirect URL:', provider.redirect_url)
2413
+ * ```
2414
+ */
2415
+ getProvider(providerId: string): Promise<OAuthProvider>;
2416
+ /**
2417
+ * Create a new OAuth provider
2418
+ *
2419
+ * Creates a new OAuth provider configuration. For built-in providers (Google, GitHub, etc.),
2420
+ * set `is_custom` to false. For custom OAuth2 providers, set `is_custom` to true and provide
2421
+ * the authorization, token, and user info URLs.
2422
+ *
2423
+ * @param request - OAuth provider configuration
2424
+ * @returns Promise resolving to CreateOAuthProviderResponse
2425
+ *
2426
+ * @example
2427
+ * ```typescript
2428
+ * // Create GitHub provider
2429
+ * const result = await client.admin.oauth.createProvider({
2430
+ * provider_name: 'github',
2431
+ * display_name: 'GitHub',
2432
+ * enabled: true,
2433
+ * client_id: process.env.GITHUB_CLIENT_ID,
2434
+ * client_secret: process.env.GITHUB_CLIENT_SECRET,
2435
+ * redirect_url: 'https://yourapp.com/auth/callback',
2436
+ * scopes: ['user:email', 'read:user'],
2437
+ * is_custom: false
2438
+ * })
2439
+ *
2440
+ * console.log('Provider created:', result.id)
2441
+ * ```
2442
+ *
2443
+ * @example
2444
+ * ```typescript
2445
+ * // Create custom OAuth2 provider
2446
+ * await client.admin.oauth.createProvider({
2447
+ * provider_name: 'custom_sso',
2448
+ * display_name: 'Custom SSO',
2449
+ * enabled: true,
2450
+ * client_id: 'client-id',
2451
+ * client_secret: 'client-secret',
2452
+ * redirect_url: 'https://yourapp.com/auth/callback',
2453
+ * scopes: ['openid', 'profile', 'email'],
2454
+ * is_custom: true,
2455
+ * authorization_url: 'https://sso.example.com/oauth/authorize',
2456
+ * token_url: 'https://sso.example.com/oauth/token',
2457
+ * user_info_url: 'https://sso.example.com/oauth/userinfo'
2458
+ * })
2459
+ * ```
2460
+ */
2461
+ createProvider(request: CreateOAuthProviderRequest): Promise<CreateOAuthProviderResponse>;
2462
+ /**
2463
+ * Update an existing OAuth provider
2464
+ *
2465
+ * Updates an OAuth provider configuration. All fields are optional - only provided fields
2466
+ * will be updated. To update the client secret, provide a non-empty value.
2467
+ *
2468
+ * @param providerId - Provider ID (UUID)
2469
+ * @param request - Fields to update
2470
+ * @returns Promise resolving to UpdateOAuthProviderResponse
2471
+ *
2472
+ * @example
2473
+ * ```typescript
2474
+ * // Disable a provider
2475
+ * await client.admin.oauth.updateProvider('provider-id', {
2476
+ * enabled: false
2477
+ * })
2478
+ * ```
2479
+ *
2480
+ * @example
2481
+ * ```typescript
2482
+ * // Update scopes and redirect URL
2483
+ * await client.admin.oauth.updateProvider('provider-id', {
2484
+ * scopes: ['user:email', 'read:user', 'read:org'],
2485
+ * redirect_url: 'https://newdomain.com/auth/callback'
2486
+ * })
2487
+ * ```
2488
+ *
2489
+ * @example
2490
+ * ```typescript
2491
+ * // Rotate client secret
2492
+ * await client.admin.oauth.updateProvider('provider-id', {
2493
+ * client_id: 'new-client-id',
2494
+ * client_secret: 'new-client-secret'
2495
+ * })
2496
+ * ```
2497
+ */
2498
+ updateProvider(providerId: string, request: UpdateOAuthProviderRequest): Promise<UpdateOAuthProviderResponse>;
2499
+ /**
2500
+ * Delete an OAuth provider
2501
+ *
2502
+ * Permanently deletes an OAuth provider configuration. This will prevent users from
2503
+ * authenticating with this provider.
2504
+ *
2505
+ * @param providerId - Provider ID (UUID) to delete
2506
+ * @returns Promise resolving to DeleteOAuthProviderResponse
2507
+ *
2508
+ * @example
2509
+ * ```typescript
2510
+ * await client.admin.oauth.deleteProvider('provider-id')
2511
+ * console.log('Provider deleted')
2512
+ * ```
2513
+ *
2514
+ * @example
2515
+ * ```typescript
2516
+ * // Safe deletion with confirmation
2517
+ * const provider = await client.admin.oauth.getProvider('provider-id')
2518
+ * const confirmed = await confirm(`Delete ${provider.display_name}?`)
2519
+ *
2520
+ * if (confirmed) {
2521
+ * await client.admin.oauth.deleteProvider('provider-id')
2522
+ * }
2523
+ * ```
2524
+ */
2525
+ deleteProvider(providerId: string): Promise<DeleteOAuthProviderResponse>;
2526
+ /**
2527
+ * Enable an OAuth provider
2528
+ *
2529
+ * Convenience method to enable a provider.
2530
+ *
2531
+ * @param providerId - Provider ID (UUID)
2532
+ * @returns Promise resolving to UpdateOAuthProviderResponse
2533
+ *
2534
+ * @example
2535
+ * ```typescript
2536
+ * await client.admin.oauth.enableProvider('provider-id')
2537
+ * ```
2538
+ */
2539
+ enableProvider(providerId: string): Promise<UpdateOAuthProviderResponse>;
2540
+ /**
2541
+ * Disable an OAuth provider
2542
+ *
2543
+ * Convenience method to disable a provider.
2544
+ *
2545
+ * @param providerId - Provider ID (UUID)
2546
+ * @returns Promise resolving to UpdateOAuthProviderResponse
2547
+ *
2548
+ * @example
2549
+ * ```typescript
2550
+ * await client.admin.oauth.disableProvider('provider-id')
2551
+ * ```
2552
+ */
2553
+ disableProvider(providerId: string): Promise<UpdateOAuthProviderResponse>;
2554
+ }
2555
+ /**
2556
+ * Authentication Settings Manager
2557
+ *
2558
+ * Manages global authentication settings including password requirements, session timeouts,
2559
+ * and signup configuration.
2560
+ *
2561
+ * @example
2562
+ * ```typescript
2563
+ * const authSettings = client.admin.authSettings
2564
+ *
2565
+ * // Get current settings
2566
+ * const settings = await authSettings.get()
2567
+ *
2568
+ * // Update settings
2569
+ * await authSettings.update({
2570
+ * password_min_length: 12,
2571
+ * password_require_uppercase: true,
2572
+ * session_timeout_minutes: 120
2573
+ * })
2574
+ * ```
2575
+ */
2576
+ declare class AuthSettingsManager {
2577
+ private fetch;
2578
+ constructor(fetch: FluxbaseFetch);
2579
+ /**
2580
+ * Get current authentication settings
2581
+ *
2582
+ * Retrieves all authentication configuration settings.
2583
+ *
2584
+ * @returns Promise resolving to AuthSettings
2585
+ *
2586
+ * @example
2587
+ * ```typescript
2588
+ * const settings = await client.admin.authSettings.get()
2589
+ *
2590
+ * console.log('Password min length:', settings.password_min_length)
2591
+ * console.log('Signup enabled:', settings.enable_signup)
2592
+ * console.log('Session timeout:', settings.session_timeout_minutes, 'minutes')
2593
+ * ```
2594
+ */
2595
+ get(): Promise<AuthSettings>;
2596
+ /**
2597
+ * Update authentication settings
2598
+ *
2599
+ * Updates one or more authentication settings. All fields are optional - only provided
2600
+ * fields will be updated.
2601
+ *
2602
+ * @param request - Settings to update
2603
+ * @returns Promise resolving to UpdateAuthSettingsResponse
2604
+ *
2605
+ * @example
2606
+ * ```typescript
2607
+ * // Strengthen password requirements
2608
+ * await client.admin.authSettings.update({
2609
+ * password_min_length: 16,
2610
+ * password_require_uppercase: true,
2611
+ * password_require_lowercase: true,
2612
+ * password_require_number: true,
2613
+ * password_require_special: true
2614
+ * })
2615
+ * ```
2616
+ *
2617
+ * @example
2618
+ * ```typescript
2619
+ * // Extend session timeout
2620
+ * await client.admin.authSettings.update({
2621
+ * session_timeout_minutes: 240,
2622
+ * max_sessions_per_user: 10
2623
+ * })
2624
+ * ```
2625
+ *
2626
+ * @example
2627
+ * ```typescript
2628
+ * // Disable email verification during development
2629
+ * await client.admin.authSettings.update({
2630
+ * require_email_verification: false
2631
+ * })
2632
+ * ```
2633
+ */
2634
+ update(request: UpdateAuthSettingsRequest): Promise<UpdateAuthSettingsResponse>;
2635
+ }
2636
+ /**
2637
+ * OAuth Configuration Manager
2638
+ *
2639
+ * Root manager providing access to OAuth provider and authentication settings management.
2640
+ *
2641
+ * @example
2642
+ * ```typescript
2643
+ * const oauth = client.admin.oauth
2644
+ *
2645
+ * // Manage OAuth providers
2646
+ * const providers = await oauth.providers.listProviders()
2647
+ *
2648
+ * // Manage auth settings
2649
+ * const settings = await oauth.authSettings.get()
2650
+ * ```
2651
+ */
2652
+ declare class FluxbaseOAuth {
2653
+ providers: OAuthProviderManager;
2654
+ authSettings: AuthSettingsManager;
2655
+ constructor(fetch: FluxbaseFetch);
2656
+ }
2657
+
2658
+ /**
2659
+ * Impersonation Manager
2660
+ *
2661
+ * Manages user impersonation for debugging, testing RLS policies, and customer support.
2662
+ * Allows admins to view data as different users, anonymous visitors, or with service role permissions.
2663
+ *
2664
+ * All impersonation sessions are logged in the audit trail for security and compliance.
2665
+ *
2666
+ * @example
2667
+ * ```typescript
2668
+ * const impersonation = client.admin.impersonation
2669
+ *
2670
+ * // Impersonate a specific user
2671
+ * const { session, access_token } = await impersonation.impersonateUser({
2672
+ * target_user_id: 'user-uuid',
2673
+ * reason: 'Support ticket #1234'
2674
+ * })
2675
+ *
2676
+ * // Impersonate anonymous user
2677
+ * await impersonation.impersonateAnon({
2678
+ * reason: 'Testing public data access'
2679
+ * })
2680
+ *
2681
+ * // Impersonate with service role
2682
+ * await impersonation.impersonateService({
2683
+ * reason: 'Administrative query'
2684
+ * })
2685
+ *
2686
+ * // Stop impersonation
2687
+ * await impersonation.stop()
2688
+ * ```
2689
+ */
2690
+ declare class ImpersonationManager {
2691
+ private fetch;
2692
+ constructor(fetch: FluxbaseFetch);
2693
+ /**
2694
+ * Impersonate a specific user
2695
+ *
2696
+ * Start an impersonation session as a specific user. This allows you to see data
2697
+ * exactly as that user would see it, respecting all RLS policies and permissions.
2698
+ *
2699
+ * @param request - Impersonation request with target user ID and reason
2700
+ * @returns Promise resolving to impersonation session with access token
2701
+ *
2702
+ * @example
2703
+ * ```typescript
2704
+ * const result = await client.admin.impersonation.impersonateUser({
2705
+ * target_user_id: 'user-123',
2706
+ * reason: 'Support ticket #5678 - user reports missing data'
2707
+ * })
2708
+ *
2709
+ * console.log('Impersonating:', result.target_user.email)
2710
+ * console.log('Session ID:', result.session.id)
2711
+ *
2712
+ * // Use the access token for subsequent requests
2713
+ * // (typically handled automatically by the SDK)
2714
+ * ```
2715
+ */
2716
+ impersonateUser(request: ImpersonateUserRequest): Promise<StartImpersonationResponse>;
2717
+ /**
2718
+ * Impersonate anonymous user
2719
+ *
2720
+ * Start an impersonation session as an unauthenticated user. This allows you to see
2721
+ * what data is publicly accessible and test RLS policies for anonymous access.
2722
+ *
2723
+ * @param request - Impersonation request with reason
2724
+ * @returns Promise resolving to impersonation session with access token
2725
+ *
2726
+ * @example
2727
+ * ```typescript
2728
+ * await client.admin.impersonation.impersonateAnon({
2729
+ * reason: 'Testing public data access for blog posts'
2730
+ * })
2731
+ *
2732
+ * // Now all queries will use anonymous permissions
2733
+ * const publicPosts = await client.from('posts').select('*')
2734
+ * console.log('Public posts:', publicPosts.length)
2735
+ * ```
2736
+ */
2737
+ impersonateAnon(request: ImpersonateAnonRequest): Promise<StartImpersonationResponse>;
2738
+ /**
2739
+ * Impersonate with service role
2740
+ *
2741
+ * Start an impersonation session with service-level permissions. This provides elevated
2742
+ * access that may bypass RLS policies, useful for administrative operations.
2743
+ *
2744
+ * @param request - Impersonation request with reason
2745
+ * @returns Promise resolving to impersonation session with access token
2746
+ *
2747
+ * @example
2748
+ * ```typescript
2749
+ * await client.admin.impersonation.impersonateService({
2750
+ * reason: 'Administrative data cleanup'
2751
+ * })
2752
+ *
2753
+ * // Now all queries will use service role permissions
2754
+ * const allRecords = await client.from('sensitive_data').select('*')
2755
+ * console.log('All records:', allRecords.length)
2756
+ * ```
2757
+ */
2758
+ impersonateService(request: ImpersonateServiceRequest): Promise<StartImpersonationResponse>;
2759
+ /**
2760
+ * Stop impersonation
2761
+ *
2762
+ * Ends the current impersonation session and returns to admin context.
2763
+ * The session is marked as ended in the audit trail.
2764
+ *
2765
+ * @returns Promise resolving to stop confirmation
2766
+ *
2767
+ * @example
2768
+ * ```typescript
2769
+ * await client.admin.impersonation.stop()
2770
+ * console.log('Impersonation ended')
2771
+ *
2772
+ * // Subsequent queries will use admin permissions
2773
+ * ```
2774
+ */
2775
+ stop(): Promise<StopImpersonationResponse>;
2776
+ /**
2777
+ * Get current impersonation session
2778
+ *
2779
+ * Retrieves information about the active impersonation session, if any.
2780
+ *
2781
+ * @returns Promise resolving to current impersonation session or null
2782
+ *
2783
+ * @example
2784
+ * ```typescript
2785
+ * const current = await client.admin.impersonation.getCurrent()
2786
+ *
2787
+ * if (current.session) {
2788
+ * console.log('Currently impersonating:', current.target_user?.email)
2789
+ * console.log('Reason:', current.session.reason)
2790
+ * console.log('Started:', current.session.started_at)
2791
+ * } else {
2792
+ * console.log('No active impersonation')
2793
+ * }
2794
+ * ```
2795
+ */
2796
+ getCurrent(): Promise<GetImpersonationResponse>;
2797
+ /**
2798
+ * List impersonation sessions (audit trail)
2799
+ *
2800
+ * Retrieves a list of impersonation sessions for audit and compliance purposes.
2801
+ * Can be filtered by admin user, target user, type, and active status.
2802
+ *
2803
+ * @param options - Filter and pagination options
2804
+ * @returns Promise resolving to list of impersonation sessions
2805
+ *
2806
+ * @example
2807
+ * ```typescript
2808
+ * // List all sessions
2809
+ * const { sessions, total } = await client.admin.impersonation.listSessions()
2810
+ * console.log(`Total sessions: ${total}`)
2811
+ *
2812
+ * // List active sessions only
2813
+ * const active = await client.admin.impersonation.listSessions({
2814
+ * is_active: true
2815
+ * })
2816
+ * console.log('Active sessions:', active.sessions.length)
2817
+ *
2818
+ * // List sessions for a specific admin
2819
+ * const adminSessions = await client.admin.impersonation.listSessions({
2820
+ * admin_user_id: 'admin-uuid',
2821
+ * limit: 50
2822
+ * })
2823
+ *
2824
+ * // List user impersonation sessions only
2825
+ * const userSessions = await client.admin.impersonation.listSessions({
2826
+ * impersonation_type: 'user',
2827
+ * offset: 0,
2828
+ * limit: 100
2829
+ * })
2830
+ * ```
2831
+ *
2832
+ * @example
2833
+ * ```typescript
2834
+ * // Audit trail: Find who impersonated a specific user
2835
+ * const userHistory = await client.admin.impersonation.listSessions({
2836
+ * target_user_id: 'user-uuid'
2837
+ * })
2838
+ *
2839
+ * userHistory.sessions.forEach(session => {
2840
+ * console.log(`Admin ${session.admin_user_id} impersonated user`)
2841
+ * console.log(`Reason: ${session.reason}`)
2842
+ * console.log(`Duration: ${session.started_at} - ${session.ended_at}`)
2843
+ * })
2844
+ * ```
2845
+ */
2846
+ listSessions(options?: ListImpersonationSessionsOptions): Promise<ListImpersonationSessionsResponse>;
2847
+ }
2848
+
2849
+ /**
2850
+ * API Keys management client
2851
+ *
2852
+ * Provides methods for managing API keys for service-to-service authentication.
2853
+ * API keys allow external services to authenticate without user credentials.
2854
+ *
2855
+ * @example
2856
+ * ```typescript
2857
+ * const client = createClient({ url: 'http://localhost:8080' })
2858
+ * await client.auth.login({ email: 'user@example.com', password: 'password' })
2859
+ *
2860
+ * // Create an API key
2861
+ * const { api_key, key } = await client.management.apiKeys.create({
2862
+ * name: 'Production Service',
2863
+ * scopes: ['read:users', 'write:users'],
2864
+ * rate_limit_per_minute: 100
2865
+ * })
2866
+ *
2867
+ * // List API keys
2868
+ * const { api_keys } = await client.management.apiKeys.list()
2869
+ * ```
2870
+ *
2871
+ * @category Management
2872
+ */
2873
+ declare class APIKeysManager {
2874
+ private fetch;
2875
+ constructor(fetch: FluxbaseFetch);
2876
+ /**
2877
+ * Create a new API key
2878
+ *
2879
+ * @param request - API key configuration
2880
+ * @returns Created API key with the full key value (only shown once)
2881
+ *
2882
+ * @example
2883
+ * ```typescript
2884
+ * const { api_key, key } = await client.management.apiKeys.create({
2885
+ * name: 'Production Service',
2886
+ * description: 'API key for production service',
2887
+ * scopes: ['read:users', 'write:users'],
2888
+ * rate_limit_per_minute: 100,
2889
+ * expires_at: '2025-12-31T23:59:59Z'
2890
+ * })
2891
+ *
2892
+ * // Store the key securely - it won't be shown again
2893
+ * console.log('API Key:', key)
2894
+ * ```
2895
+ */
2896
+ create(request: CreateAPIKeyRequest): Promise<CreateAPIKeyResponse>;
2897
+ /**
2898
+ * List all API keys for the authenticated user
2899
+ *
2900
+ * @returns List of API keys (without full key values)
2901
+ *
2902
+ * @example
2903
+ * ```typescript
2904
+ * const { api_keys, total } = await client.management.apiKeys.list()
2905
+ *
2906
+ * api_keys.forEach(key => {
2907
+ * console.log(`${key.name}: ${key.key_prefix}... (expires: ${key.expires_at})`)
2908
+ * })
2909
+ * ```
2910
+ */
2911
+ list(): Promise<ListAPIKeysResponse>;
2912
+ /**
2913
+ * Get a specific API key by ID
2914
+ *
2915
+ * @param keyId - API key ID
2916
+ * @returns API key details
2917
+ *
2918
+ * @example
2919
+ * ```typescript
2920
+ * const apiKey = await client.management.apiKeys.get('key-uuid')
2921
+ * console.log('Last used:', apiKey.last_used_at)
2922
+ * ```
2923
+ */
2924
+ get(keyId: string): Promise<APIKey>;
2925
+ /**
2926
+ * Update an API key
2927
+ *
2928
+ * @param keyId - API key ID
2929
+ * @param updates - Fields to update
2930
+ * @returns Updated API key
2931
+ *
2932
+ * @example
2933
+ * ```typescript
2934
+ * const updated = await client.management.apiKeys.update('key-uuid', {
2935
+ * name: 'Updated Name',
2936
+ * rate_limit_per_minute: 200
2937
+ * })
2938
+ * ```
2939
+ */
2940
+ update(keyId: string, updates: UpdateAPIKeyRequest): Promise<APIKey>;
2941
+ /**
2942
+ * Revoke an API key
2943
+ *
2944
+ * Revoked keys can no longer be used but remain in the system for audit purposes.
2945
+ *
2946
+ * @param keyId - API key ID
2947
+ * @returns Revocation confirmation
2948
+ *
2949
+ * @example
2950
+ * ```typescript
2951
+ * await client.management.apiKeys.revoke('key-uuid')
2952
+ * console.log('API key revoked')
2953
+ * ```
2954
+ */
2955
+ revoke(keyId: string): Promise<RevokeAPIKeyResponse>;
2956
+ /**
2957
+ * Delete an API key
2958
+ *
2959
+ * Permanently removes the API key from the system.
2960
+ *
2961
+ * @param keyId - API key ID
2962
+ * @returns Deletion confirmation
2963
+ *
2964
+ * @example
2965
+ * ```typescript
2966
+ * await client.management.apiKeys.delete('key-uuid')
2967
+ * console.log('API key deleted')
2968
+ * ```
2969
+ */
2970
+ delete(keyId: string): Promise<DeleteAPIKeyResponse>;
2971
+ }
2972
+ /**
2973
+ * Webhooks management client
2974
+ *
2975
+ * Provides methods for managing webhooks to receive real-time event notifications.
2976
+ * Webhooks allow your application to be notified when events occur in Fluxbase.
2977
+ *
2978
+ * @example
2979
+ * ```typescript
2980
+ * const client = createClient({ url: 'http://localhost:8080' })
2981
+ * await client.auth.login({ email: 'user@example.com', password: 'password' })
2982
+ *
2983
+ * // Create a webhook
2984
+ * const webhook = await client.management.webhooks.create({
2985
+ * url: 'https://myapp.com/webhook',
2986
+ * events: ['user.created', 'user.updated'],
2987
+ * secret: 'my-webhook-secret'
2988
+ * })
2989
+ *
2990
+ * // Test the webhook
2991
+ * const result = await client.management.webhooks.test(webhook.id)
2992
+ * ```
2993
+ *
2994
+ * @category Management
2995
+ */
2996
+ declare class WebhooksManager {
2997
+ private fetch;
2998
+ constructor(fetch: FluxbaseFetch);
2999
+ /**
3000
+ * Create a new webhook
3001
+ *
3002
+ * @param request - Webhook configuration
3003
+ * @returns Created webhook
3004
+ *
3005
+ * @example
3006
+ * ```typescript
3007
+ * const webhook = await client.management.webhooks.create({
3008
+ * url: 'https://myapp.com/webhook',
3009
+ * events: ['user.created', 'user.updated', 'user.deleted'],
3010
+ * description: 'User events webhook',
3011
+ * secret: 'my-webhook-secret'
3012
+ * })
3013
+ * ```
3014
+ */
3015
+ create(request: CreateWebhookRequest): Promise<Webhook>;
3016
+ /**
3017
+ * List all webhooks for the authenticated user
3018
+ *
3019
+ * @returns List of webhooks
3020
+ *
3021
+ * @example
3022
+ * ```typescript
3023
+ * const { webhooks, total } = await client.management.webhooks.list()
3024
+ *
3025
+ * webhooks.forEach(webhook => {
3026
+ * console.log(`${webhook.url}: ${webhook.is_active ? 'active' : 'inactive'}`)
3027
+ * })
3028
+ * ```
3029
+ */
3030
+ list(): Promise<ListWebhooksResponse>;
3031
+ /**
3032
+ * Get a specific webhook by ID
3033
+ *
3034
+ * @param webhookId - Webhook ID
3035
+ * @returns Webhook details
3036
+ *
3037
+ * @example
3038
+ * ```typescript
3039
+ * const webhook = await client.management.webhooks.get('webhook-uuid')
3040
+ * console.log('Events:', webhook.events)
3041
+ * ```
3042
+ */
3043
+ get(webhookId: string): Promise<Webhook>;
3044
+ /**
3045
+ * Update a webhook
3046
+ *
3047
+ * @param webhookId - Webhook ID
3048
+ * @param updates - Fields to update
3049
+ * @returns Updated webhook
3050
+ *
3051
+ * @example
3052
+ * ```typescript
3053
+ * const updated = await client.management.webhooks.update('webhook-uuid', {
3054
+ * events: ['user.created', 'user.deleted'],
3055
+ * is_active: false
3056
+ * })
3057
+ * ```
3058
+ */
3059
+ update(webhookId: string, updates: UpdateWebhookRequest): Promise<Webhook>;
3060
+ /**
3061
+ * Delete a webhook
3062
+ *
3063
+ * @param webhookId - Webhook ID
3064
+ * @returns Deletion confirmation
3065
+ *
3066
+ * @example
3067
+ * ```typescript
3068
+ * await client.management.webhooks.delete('webhook-uuid')
3069
+ * console.log('Webhook deleted')
3070
+ * ```
3071
+ */
3072
+ delete(webhookId: string): Promise<DeleteWebhookResponse>;
3073
+ /**
3074
+ * Test a webhook by sending a test payload
3075
+ *
3076
+ * @param webhookId - Webhook ID
3077
+ * @returns Test result with status and response
3078
+ *
3079
+ * @example
3080
+ * ```typescript
3081
+ * const result = await client.management.webhooks.test('webhook-uuid')
3082
+ *
3083
+ * if (result.success) {
3084
+ * console.log('Webhook test successful')
3085
+ * } else {
3086
+ * console.error('Webhook test failed:', result.error)
3087
+ * }
3088
+ * ```
3089
+ */
3090
+ test(webhookId: string): Promise<TestWebhookResponse>;
3091
+ /**
3092
+ * List webhook delivery history
3093
+ *
3094
+ * @param webhookId - Webhook ID
3095
+ * @param limit - Maximum number of deliveries to return (default: 50)
3096
+ * @returns List of webhook deliveries
3097
+ *
3098
+ * @example
3099
+ * ```typescript
3100
+ * const { deliveries } = await client.management.webhooks.listDeliveries('webhook-uuid', 100)
3101
+ *
3102
+ * deliveries.forEach(delivery => {
3103
+ * console.log(`Event: ${delivery.event}, Status: ${delivery.status_code}`)
3104
+ * })
3105
+ * ```
3106
+ */
3107
+ listDeliveries(webhookId: string, limit?: number): Promise<ListWebhookDeliveriesResponse>;
3108
+ }
3109
+ /**
3110
+ * Invitations management client
3111
+ *
3112
+ * Provides methods for creating and managing user invitations.
3113
+ * Invitations allow admins to invite new users to join the dashboard.
3114
+ *
3115
+ * @example
3116
+ * ```typescript
3117
+ * const client = createClient({ url: 'http://localhost:8080' })
3118
+ * await client.admin.login({ email: 'admin@example.com', password: 'password' })
3119
+ *
3120
+ * // Create an invitation
3121
+ * const invitation = await client.management.invitations.create({
3122
+ * email: 'newuser@example.com',
3123
+ * role: 'dashboard_user'
3124
+ * })
3125
+ *
3126
+ * console.log('Invite link:', invitation.invite_link)
3127
+ * ```
3128
+ *
3129
+ * @category Management
3130
+ */
3131
+ declare class InvitationsManager {
3132
+ private fetch;
3133
+ constructor(fetch: FluxbaseFetch);
3134
+ /**
3135
+ * Create a new invitation (admin only)
3136
+ *
3137
+ * @param request - Invitation details
3138
+ * @returns Created invitation with invite link
3139
+ *
3140
+ * @example
3141
+ * ```typescript
3142
+ * const invitation = await client.management.invitations.create({
3143
+ * email: 'newuser@example.com',
3144
+ * role: 'dashboard_user',
3145
+ * expiry_duration: 604800 // 7 days in seconds
3146
+ * })
3147
+ *
3148
+ * // Share the invite link
3149
+ * console.log('Send this link to the user:', invitation.invite_link)
3150
+ * ```
3151
+ */
3152
+ create(request: CreateInvitationRequest): Promise<CreateInvitationResponse>;
3153
+ /**
3154
+ * List all invitations (admin only)
3155
+ *
3156
+ * @param options - Filter options
3157
+ * @returns List of invitations
3158
+ *
3159
+ * @example
3160
+ * ```typescript
3161
+ * // List pending invitations only
3162
+ * const { invitations } = await client.management.invitations.list({
3163
+ * include_accepted: false,
3164
+ * include_expired: false
3165
+ * })
3166
+ *
3167
+ * // List all invitations including accepted and expired
3168
+ * const all = await client.management.invitations.list({
3169
+ * include_accepted: true,
3170
+ * include_expired: true
3171
+ * })
3172
+ * ```
3173
+ */
3174
+ list(options?: ListInvitationsOptions): Promise<ListInvitationsResponse>;
3175
+ /**
3176
+ * Validate an invitation token (public endpoint)
3177
+ *
3178
+ * @param token - Invitation token
3179
+ * @returns Validation result with invitation details
3180
+ *
3181
+ * @example
3182
+ * ```typescript
3183
+ * const result = await client.management.invitations.validate('invitation-token')
3184
+ *
3185
+ * if (result.valid) {
3186
+ * console.log('Valid invitation for:', result.invitation?.email)
3187
+ * } else {
3188
+ * console.error('Invalid:', result.error)
3189
+ * }
3190
+ * ```
3191
+ */
3192
+ validate(token: string): Promise<ValidateInvitationResponse>;
3193
+ /**
3194
+ * Accept an invitation and create a new user (public endpoint)
3195
+ *
3196
+ * @param token - Invitation token
3197
+ * @param request - User details (password and name)
3198
+ * @returns Created user with authentication tokens
3199
+ *
3200
+ * @example
3201
+ * ```typescript
3202
+ * const response = await client.management.invitations.accept('invitation-token', {
3203
+ * password: 'SecurePassword123!',
3204
+ * name: 'John Doe'
3205
+ * })
3206
+ *
3207
+ * // Store tokens
3208
+ * localStorage.setItem('access_token', response.access_token)
3209
+ * console.log('Welcome:', response.user.name)
3210
+ * ```
3211
+ */
3212
+ accept(token: string, request: AcceptInvitationRequest): Promise<AcceptInvitationResponse>;
3213
+ /**
3214
+ * Revoke an invitation (admin only)
3215
+ *
3216
+ * @param token - Invitation token
3217
+ * @returns Revocation confirmation
3218
+ *
3219
+ * @example
3220
+ * ```typescript
3221
+ * await client.management.invitations.revoke('invitation-token')
3222
+ * console.log('Invitation revoked')
3223
+ * ```
3224
+ */
3225
+ revoke(token: string): Promise<RevokeInvitationResponse>;
3226
+ }
3227
+ /**
3228
+ * Management client for API keys, webhooks, and invitations
3229
+ *
3230
+ * @category Management
3231
+ */
3232
+ declare class FluxbaseManagement {
3233
+ /** API Keys management */
3234
+ apiKeys: APIKeysManager;
3235
+ /** Webhooks management */
3236
+ webhooks: WebhooksManager;
3237
+ /** Invitations management */
3238
+ invitations: InvitationsManager;
3239
+ constructor(fetch: FluxbaseFetch);
3240
+ }
3241
+
3242
+ /**
3243
+ * Admin client for managing Fluxbase instance
3244
+ */
3245
+ declare class FluxbaseAdmin {
3246
+ private fetch;
3247
+ private adminToken;
3248
+ /**
3249
+ * Settings manager for system and application settings
3250
+ */
3251
+ settings: FluxbaseSettings;
3252
+ /**
3253
+ * DDL manager for database schema and table operations
3254
+ */
3255
+ ddl: DDLManager;
3256
+ /**
3257
+ * OAuth configuration manager for provider and auth settings
3258
+ */
3259
+ oauth: FluxbaseOAuth;
3260
+ /**
3261
+ * Impersonation manager for user impersonation and audit trail
3262
+ */
3263
+ impersonation: ImpersonationManager;
3264
+ /**
3265
+ * Management namespace for API keys, webhooks, and invitations
3266
+ */
3267
+ management: FluxbaseManagement;
3268
+ /**
3269
+ * Email template manager for customizing authentication and notification emails
3270
+ */
3271
+ emailTemplates: EmailTemplateManager;
3272
+ constructor(fetch: FluxbaseFetch);
3273
+ /**
3274
+ * Set admin authentication token
3275
+ */
3276
+ setToken(token: string): void;
3277
+ /**
3278
+ * Get current admin token
3279
+ */
3280
+ getToken(): string | null;
3281
+ /**
3282
+ * Clear admin token
3283
+ */
3284
+ clearToken(): void;
3285
+ /**
3286
+ * Check if initial admin setup is needed
3287
+ *
3288
+ * @returns Setup status indicating if initial setup is required
3289
+ *
3290
+ * @example
3291
+ * ```typescript
3292
+ * const status = await admin.getSetupStatus();
3293
+ * if (status.needs_setup) {
3294
+ * console.log('Initial setup required');
3295
+ * }
3296
+ * ```
3297
+ */
3298
+ getSetupStatus(): Promise<AdminSetupStatusResponse>;
3299
+ /**
3300
+ * Perform initial admin setup
3301
+ *
3302
+ * Creates the first admin user and completes initial setup.
3303
+ * This endpoint can only be called once.
3304
+ *
3305
+ * @param email - Admin email address
3306
+ * @param password - Admin password (minimum 12 characters)
3307
+ * @param name - Admin display name
3308
+ * @returns Authentication response with tokens
3309
+ *
3310
+ * @example
3311
+ * ```typescript
3312
+ * const response = await admin.setup({
3313
+ * email: 'admin@example.com',
3314
+ * password: 'SecurePassword123!',
3315
+ * name: 'Admin User'
3316
+ * });
3317
+ *
3318
+ * // Store tokens
3319
+ * localStorage.setItem('admin_token', response.access_token);
3320
+ * ```
3321
+ */
3322
+ setup(request: AdminSetupRequest): Promise<AdminAuthResponse>;
3323
+ /**
3324
+ * Admin login
3325
+ *
3326
+ * Authenticate as an admin user
3327
+ *
3328
+ * @param email - Admin email
3329
+ * @param password - Admin password
3330
+ * @returns Authentication response with tokens
3331
+ *
3332
+ * @example
3333
+ * ```typescript
3334
+ * const response = await admin.login({
3335
+ * email: 'admin@example.com',
3336
+ * password: 'password123'
3337
+ * });
3338
+ *
3339
+ * // Token is automatically set in the client
3340
+ * console.log('Logged in as:', response.user.email);
3341
+ * ```
3342
+ */
3343
+ login(request: AdminLoginRequest): Promise<AdminAuthResponse>;
3344
+ /**
3345
+ * Refresh admin access token
3346
+ *
3347
+ * @param refreshToken - Refresh token
3348
+ * @returns New access and refresh tokens
3349
+ *
3350
+ * @example
3351
+ * ```typescript
3352
+ * const refreshToken = localStorage.getItem('admin_refresh_token');
3353
+ * const response = await admin.refreshToken({ refresh_token: refreshToken });
3354
+ *
3355
+ * // Update stored tokens
3356
+ * localStorage.setItem('admin_token', response.access_token);
3357
+ * localStorage.setItem('admin_refresh_token', response.refresh_token);
3358
+ * ```
3359
+ */
3360
+ refreshToken(request: AdminRefreshRequest): Promise<AdminRefreshResponse>;
3361
+ /**
3362
+ * Admin logout
3363
+ *
3364
+ * Invalidates the current admin session
3365
+ *
3366
+ * @example
3367
+ * ```typescript
3368
+ * await admin.logout();
3369
+ * localStorage.removeItem('admin_token');
3370
+ * ```
3371
+ */
3372
+ logout(): Promise<void>;
3373
+ /**
3374
+ * Get current admin user information
3375
+ *
3376
+ * @returns Current admin user details
3377
+ *
3378
+ * @example
3379
+ * ```typescript
3380
+ * const { user } = await admin.me();
3381
+ * console.log('Logged in as:', user.email);
3382
+ * console.log('Role:', user.role);
3383
+ * ```
3384
+ */
3385
+ me(): Promise<AdminMeResponse>;
3386
+ /**
3387
+ * List all users
3388
+ *
3389
+ * @param options - Filter and pagination options
3390
+ * @returns List of users with metadata
3391
+ *
3392
+ * @example
3393
+ * ```typescript
3394
+ * // List all users
3395
+ * const { users, total } = await admin.listUsers();
3396
+ *
3397
+ * // List with filters
3398
+ * const result = await admin.listUsers({
3399
+ * exclude_admins: true,
3400
+ * search: 'john',
3401
+ * limit: 50,
3402
+ * type: 'app'
3403
+ * });
3404
+ * ```
3405
+ */
3406
+ listUsers(options?: ListUsersOptions): Promise<ListUsersResponse>;
3407
+ /**
3408
+ * Get a user by ID
3409
+ *
3410
+ * Fetch a single user's details by their user ID
3411
+ *
3412
+ * @param userId - User ID to fetch
3413
+ * @param type - User type ('app' or 'dashboard')
3414
+ * @returns User details with metadata
3415
+ *
3416
+ * @example
3417
+ * ```typescript
3418
+ * // Get an app user
3419
+ * const user = await admin.getUserById('user-123');
3420
+ *
3421
+ * // Get a dashboard user
3422
+ * const dashboardUser = await admin.getUserById('admin-456', 'dashboard');
3423
+ * console.log('User email:', dashboardUser.email);
3424
+ * console.log('Last login:', dashboardUser.last_login_at);
3425
+ * ```
3426
+ */
3427
+ getUserById(userId: string, type?: "app" | "dashboard"): Promise<EnrichedUser>;
3428
+ /**
3429
+ * Invite a new user
3430
+ *
3431
+ * Creates a new user and optionally sends an invitation email
3432
+ *
3433
+ * @param request - User invitation details
3434
+ * @param type - User type ('app' or 'dashboard')
3435
+ * @returns Created user and invitation details
3436
+ *
3437
+ * @example
3438
+ * ```typescript
3439
+ * const response = await admin.inviteUser({
3440
+ * email: 'newuser@example.com',
3441
+ * role: 'user',
3442
+ * send_email: true
3443
+ * });
3444
+ *
3445
+ * console.log('User invited:', response.user.email);
3446
+ * console.log('Invitation link:', response.invitation_link);
3447
+ * ```
3448
+ */
3449
+ inviteUser(request: InviteUserRequest, type?: "app" | "dashboard"): Promise<InviteUserResponse>;
3450
+ /**
3451
+ * Delete a user
3452
+ *
3453
+ * Permanently deletes a user and all associated data
3454
+ *
3455
+ * @param userId - User ID to delete
3456
+ * @param type - User type ('app' or 'dashboard')
3457
+ * @returns Deletion confirmation
3458
+ *
3459
+ * @example
3460
+ * ```typescript
3461
+ * await admin.deleteUser('user-uuid');
3462
+ * console.log('User deleted');
3463
+ * ```
3464
+ */
3465
+ deleteUser(userId: string, type?: "app" | "dashboard"): Promise<DeleteUserResponse>;
3466
+ /**
3467
+ * Update user role
3468
+ *
3469
+ * Changes a user's role
3470
+ *
3471
+ * @param userId - User ID
3472
+ * @param role - New role
3473
+ * @param type - User type ('app' or 'dashboard')
3474
+ * @returns Updated user
3475
+ *
3476
+ * @example
3477
+ * ```typescript
3478
+ * const user = await admin.updateUserRole('user-uuid', 'admin');
3479
+ * console.log('User role updated:', user.role);
3480
+ * ```
3481
+ */
3482
+ updateUserRole(userId: string, role: string, type?: "app" | "dashboard"): Promise<EnrichedUser>;
3483
+ /**
3484
+ * Reset user password
3485
+ *
3486
+ * Generates a new password for the user and optionally sends it via email
3487
+ *
3488
+ * @param userId - User ID
3489
+ * @param type - User type ('app' or 'dashboard')
3490
+ * @returns Reset confirmation message
3491
+ *
3492
+ * @example
3493
+ * ```typescript
3494
+ * const response = await admin.resetUserPassword('user-uuid');
3495
+ * console.log(response.message);
3496
+ * ```
3497
+ */
3498
+ resetUserPassword(userId: string, type?: "app" | "dashboard"): Promise<ResetUserPasswordResponse>;
3499
+ }
3500
+
3501
+ /**
3502
+ * PostgreSQL query builder for Fluxbase SDK
3503
+ * Inspired by Supabase's PostgREST client
3504
+ */
3505
+
3506
+ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse<T>> {
3507
+ private fetch;
3508
+ private table;
3509
+ private selectQuery;
3510
+ private filters;
3511
+ private orderBys;
3512
+ private limitValue?;
3513
+ private offsetValue?;
3514
+ private singleRow;
3515
+ private groupByColumns?;
3516
+ constructor(fetch: FluxbaseFetch, table: string);
3517
+ /**
3518
+ * Select columns to return
3519
+ * @example select('*')
3520
+ * @example select('id, name, email')
3521
+ * @example select('id, name, posts(title, content)')
3522
+ */
3523
+ select(columns?: string): this;
3524
+ /**
3525
+ * Insert a single row or multiple rows
3526
+ */
3527
+ insert(data: Partial<T> | Array<Partial<T>>): Promise<PostgrestResponse<T>>;
3528
+ /**
3529
+ * Upsert (insert or update) rows
3530
+ */
3531
+ upsert(data: Partial<T> | Array<Partial<T>>): Promise<PostgrestResponse<T>>;
3532
+ /**
3533
+ * Update rows matching the filters
3534
+ */
3535
+ update(data: Partial<T>): Promise<PostgrestResponse<T>>;
3536
+ /**
3537
+ * Delete rows matching the filters
3538
+ */
3539
+ delete(): Promise<PostgrestResponse<null>>;
3540
+ /**
3541
+ * Equal to
3542
+ */
3543
+ eq(column: string, value: unknown): this;
3544
+ /**
3545
+ * Not equal to
3546
+ */
3547
+ neq(column: string, value: unknown): this;
3548
+ /**
3549
+ * Greater than
3550
+ */
3551
+ gt(column: string, value: unknown): this;
3552
+ /**
3553
+ * Greater than or equal to
3554
+ */
3555
+ gte(column: string, value: unknown): this;
3556
+ /**
3557
+ * Less than
3558
+ */
3559
+ lt(column: string, value: unknown): this;
3560
+ /**
3561
+ * Less than or equal to
3562
+ */
3563
+ lte(column: string, value: unknown): this;
3564
+ /**
3565
+ * Pattern matching (case-sensitive)
3566
+ */
3567
+ like(column: string, pattern: string): this;
3568
+ /**
3569
+ * Pattern matching (case-insensitive)
3570
+ */
3571
+ ilike(column: string, pattern: string): this;
3572
+ /**
3573
+ * Check if value is null or not null
3574
+ */
3575
+ is(column: string, value: null | boolean): this;
3576
+ /**
3577
+ * Check if value is in array
3578
+ */
3579
+ in(column: string, values: unknown[]): this;
3580
+ /**
3581
+ * Contains (for arrays and JSONB)
3582
+ */
3583
+ contains(column: string, value: unknown): this;
3584
+ /**
3585
+ * Full-text search
3586
+ */
3587
+ textSearch(column: string, query: string): this;
3588
+ /**
3589
+ * Order results
3590
+ */
3591
+ order(column: string, options?: {
3592
+ ascending?: boolean;
3593
+ nullsFirst?: boolean;
3594
+ }): this;
3595
+ /**
3596
+ * Limit number of rows returned
3597
+ */
3598
+ limit(count: number): this;
3599
+ /**
3600
+ * Skip rows
3601
+ */
3602
+ offset(count: number): this;
3603
+ /**
3604
+ * Return a single row (adds limit(1))
3605
+ */
3606
+ single(): this;
3607
+ /**
3608
+ * Range selection (pagination)
3609
+ */
3610
+ range(from: number, to: number): this;
3611
+ /**
3612
+ * Group results by one or more columns (for use with aggregations)
3613
+ *
3614
+ * @param columns - Column name(s) to group by
3615
+ * @returns Query builder for chaining
3616
+ *
3617
+ * @example
3618
+ * ```typescript
3619
+ * // Group by single column
3620
+ * const { data } = await client.from('orders')
3621
+ * .count('*')
3622
+ * .groupBy('status')
3623
+ * .execute()
3624
+ *
3625
+ * // Group by multiple columns
3626
+ * const { data } = await client.from('sales')
3627
+ * .sum('amount')
3628
+ * .groupBy(['region', 'product_category'])
3629
+ * .execute()
3630
+ * ```
3631
+ *
3632
+ * @category Aggregation
3633
+ */
3634
+ groupBy(columns: string | string[]): this;
3635
+ /**
3636
+ * Count rows or a specific column
3637
+ *
3638
+ * @param column - Column to count (default: '*' for row count)
3639
+ * @returns Query builder for chaining
3640
+ *
3641
+ * @example
3642
+ * ```typescript
3643
+ * // Count all rows
3644
+ * const { data } = await client.from('users').count().execute()
3645
+ * // Returns: { count: 150 }
3646
+ *
3647
+ * // Count non-null values in a column
3648
+ * const { data } = await client.from('orders').count('completed_at').execute()
3649
+ *
3650
+ * // Count with grouping
3651
+ * const { data } = await client.from('products')
3652
+ * .count('*')
3653
+ * .groupBy('category')
3654
+ * .execute()
3655
+ * // Returns: [{ category: 'electronics', count: 45 }, { category: 'books', count: 23 }]
3656
+ * ```
3657
+ *
3658
+ * @category Aggregation
3659
+ */
3660
+ count(column?: string): this;
3661
+ /**
3662
+ * Calculate the sum of a numeric column
3663
+ *
3664
+ * @param column - Column to sum
3665
+ * @returns Query builder for chaining
3666
+ *
3667
+ * @example
3668
+ * ```typescript
3669
+ * // Sum all prices
3670
+ * const { data } = await client.from('products').sum('price').execute()
3671
+ * // Returns: { sum_price: 15420.50 }
3672
+ *
3673
+ * // Sum by category
3674
+ * const { data } = await client.from('orders')
3675
+ * .sum('total')
3676
+ * .groupBy('status')
3677
+ * .execute()
3678
+ * // Returns: [{ status: 'completed', sum_total: 12500 }, { status: 'pending', sum_total: 3200 }]
3679
+ * ```
3680
+ *
3681
+ * @category Aggregation
3682
+ */
3683
+ sum(column: string): this;
3684
+ /**
3685
+ * Calculate the average of a numeric column
3686
+ *
3687
+ * @param column - Column to average
3688
+ * @returns Query builder for chaining
3689
+ *
3690
+ * @example
3691
+ * ```typescript
3692
+ * // Average price
3693
+ * const { data } = await client.from('products').avg('price').execute()
3694
+ * // Returns: { avg_price: 129.99 }
3695
+ *
3696
+ * // Average by category
3697
+ * const { data } = await client.from('products')
3698
+ * .avg('price')
3699
+ * .groupBy('category')
3700
+ * .execute()
3701
+ * ```
3702
+ *
3703
+ * @category Aggregation
3704
+ */
3705
+ avg(column: string): this;
3706
+ /**
3707
+ * Find the minimum value in a column
3708
+ *
3709
+ * @param column - Column to find minimum value
3710
+ * @returns Query builder for chaining
3711
+ *
3712
+ * @example
3713
+ * ```typescript
3714
+ * // Find lowest price
3715
+ * const { data } = await client.from('products').min('price').execute()
3716
+ * // Returns: { min_price: 9.99 }
3717
+ *
3718
+ * // Find earliest date
3719
+ * const { data } = await client.from('orders').min('created_at').execute()
3720
+ * ```
3721
+ *
3722
+ * @category Aggregation
3723
+ */
3724
+ min(column: string): this;
3725
+ /**
3726
+ * Find the maximum value in a column
3727
+ *
3728
+ * @param column - Column to find maximum value
3729
+ * @returns Query builder for chaining
3730
+ *
3731
+ * @example
3732
+ * ```typescript
3733
+ * // Find highest price
3734
+ * const { data } = await client.from('products').max('price').execute()
3735
+ * // Returns: { max_price: 1999.99 }
3736
+ *
3737
+ * // Find most recent order
3738
+ * const { data } = await client.from('orders').max('created_at').execute()
3739
+ * ```
3740
+ *
3741
+ * @category Aggregation
3742
+ */
3743
+ max(column: string): this;
3744
+ /**
3745
+ * Insert multiple rows in a single request (batch insert)
3746
+ *
3747
+ * This is a convenience method that explicitly shows intent for batch operations.
3748
+ * Internally calls `insert()` with an array.
3749
+ *
3750
+ * @param rows - Array of row objects to insert
3751
+ * @returns Promise with the inserted rows
3752
+ *
3753
+ * @example
3754
+ * ```typescript
3755
+ * // Insert multiple users at once
3756
+ * const { data } = await client.from('users').insertMany([
3757
+ * { name: 'Alice', email: 'alice@example.com' },
3758
+ * { name: 'Bob', email: 'bob@example.com' },
3759
+ * { name: 'Charlie', email: 'charlie@example.com' }
3760
+ * ]).execute()
3761
+ * ```
3762
+ *
3763
+ * @category Batch Operations
3764
+ */
3765
+ insertMany(rows: Array<Partial<T>>): Promise<PostgrestResponse<T>>;
3766
+ /**
3767
+ * Update multiple rows matching the filters (batch update)
3768
+ *
3769
+ * Updates all rows that match the current query filters.
3770
+ * This is a convenience method that explicitly shows intent for batch operations.
3771
+ *
3772
+ * @param data - Data to update matching rows with
3773
+ * @returns Promise with the updated rows
3774
+ *
3775
+ * @example
3776
+ * ```typescript
3777
+ * // Apply discount to all electronics
3778
+ * const { data } = await client.from('products')
3779
+ * .eq('category', 'electronics')
3780
+ * .updateMany({ discount: 10, updated_at: new Date() })
3781
+ * .execute()
3782
+ *
3783
+ * // Mark all pending orders as processing
3784
+ * const { data } = await client.from('orders')
3785
+ * .eq('status', 'pending')
3786
+ * .updateMany({ status: 'processing' })
3787
+ * .execute()
3788
+ * ```
3789
+ *
3790
+ * @category Batch Operations
3791
+ */
3792
+ updateMany(data: Partial<T>): Promise<PostgrestResponse<T>>;
3793
+ /**
3794
+ * Delete multiple rows matching the filters (batch delete)
3795
+ *
3796
+ * Deletes all rows that match the current query filters.
3797
+ * This is a convenience method that explicitly shows intent for batch operations.
3798
+ *
3799
+ * @returns Promise confirming deletion
3800
+ *
3801
+ * @example
3802
+ * ```typescript
3803
+ * // Delete all inactive users
3804
+ * await client.from('users')
3805
+ * .eq('active', false)
3806
+ * .deleteMany()
3807
+ * .execute()
3808
+ *
3809
+ * // Delete old logs
3810
+ * await client.from('logs')
3811
+ * .lt('created_at', '2024-01-01')
3812
+ * .deleteMany()
3813
+ * .execute()
3814
+ * ```
3815
+ *
3816
+ * @category Batch Operations
3817
+ */
3818
+ deleteMany(): Promise<PostgrestResponse<null>>;
3819
+ /**
3820
+ * Execute the query and return results
3821
+ */
3822
+ execute(): Promise<PostgrestResponse<T>>;
3823
+ /**
3824
+ * Make QueryBuilder awaitable (implements PromiseLike)
3825
+ * This allows using `await client.from('table').select()` without calling `.execute()`
3826
+ *
3827
+ * @example
3828
+ * ```typescript
3829
+ * // Without .execute() (new way)
3830
+ * const { data } = await client.from('users').select('*')
3831
+ *
3832
+ * // With .execute() (old way, still supported)
3833
+ * const { data } = await client.from('users').select('*').execute()
3834
+ * ```
3835
+ */
3836
+ then<TResult1 = PostgrestResponse<T>, TResult2 = never>(onfulfilled?: ((value: PostgrestResponse<T>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
3837
+ /**
3838
+ * Build the query string from filters, ordering, etc.
3839
+ */
3840
+ private buildQueryString;
3841
+ /**
3842
+ * Format a value for the query string
3843
+ */
3844
+ private formatValue;
3845
+ }
3846
+
3847
+ /**
3848
+ * Main Fluxbase client for interacting with the Fluxbase backend.
3849
+ *
3850
+ * This client provides access to all Fluxbase features including:
3851
+ * - Database operations via PostgREST-compatible API
3852
+ * - Authentication and user management
3853
+ * - Real-time subscriptions via WebSockets
3854
+ * - File storage and management
3855
+ * - PostgreSQL function calls (RPC)
3856
+ *
3857
+ * @example
3858
+ * ```typescript
3859
+ * import { createClient } from '@fluxbase/sdk'
3860
+ *
3861
+ * const client = createClient({
3862
+ * url: 'http://localhost:8080',
3863
+ * auth: {
3864
+ * token: 'your-jwt-token',
3865
+ * autoRefresh: true
3866
+ * }
3867
+ * })
3868
+ *
3869
+ * // Query database
3870
+ * const { data } = await client.from('users').select('*').execute()
3871
+ *
3872
+ * // Subscribe to realtime changes
3873
+ * client.realtime.subscribe('users', (payload) => {
3874
+ * console.log('Change:', payload)
3875
+ * })
3876
+ * ```
3877
+ *
3878
+ * @category Client
3879
+ */
3880
+
3881
+ /**
3882
+ * Main Fluxbase client class
3883
+ * @category Client
3884
+ */
3885
+ declare class FluxbaseClient {
3886
+ /** Internal HTTP client for making requests */
3887
+ private fetch;
3888
+ /** Authentication module for user management */
3889
+ auth: FluxbaseAuth;
3890
+ /** Realtime module for WebSocket subscriptions */
3891
+ realtime: FluxbaseRealtime;
3892
+ /** Storage module for file operations */
3893
+ storage: FluxbaseStorage;
3894
+ /** Admin module for instance management (requires admin authentication) */
3895
+ admin: FluxbaseAdmin;
3896
+ /** Management module for API keys, webhooks, and invitations */
3897
+ management: FluxbaseManagement;
3898
+ /**
3899
+ * Create a new Fluxbase client instance
3900
+ * @param options - Client configuration options
3901
+ */
3902
+ constructor(options: FluxbaseClientOptions);
3903
+ /**
3904
+ * Create a query builder for a database table
3905
+ *
3906
+ * @param table - The table name (can include schema, e.g., 'public.users')
3907
+ * @returns A query builder instance for constructing and executing queries
3908
+ *
3909
+ * @example
3910
+ * ```typescript
3911
+ * // Simple select
3912
+ * const { data } = await client.from('users').select('*').execute()
3913
+ *
3914
+ * // With filters
3915
+ * const { data } = await client.from('products')
3916
+ * .select('id, name, price')
3917
+ * .gt('price', 100)
3918
+ * .eq('category', 'electronics')
3919
+ * .execute()
3920
+ *
3921
+ * // Insert
3922
+ * await client.from('users').insert({ name: 'John', email: 'john@example.com' }).execute()
3923
+ * ```
3924
+ *
3925
+ * @category Database
3926
+ */
3927
+ from<T = any>(table: string): QueryBuilder<T>;
3928
+ /**
3929
+ * Call a PostgreSQL function (Remote Procedure Call)
3930
+ *
3931
+ * @param functionName - The name of the PostgreSQL function to call
3932
+ * @param params - Optional parameters to pass to the function
3933
+ * @returns Promise containing the function result or error
3934
+ *
3935
+ * @example
3936
+ * ```typescript
3937
+ * // Call a function without parameters
3938
+ * const { data, error } = await client.rpc('get_total_users')
3939
+ *
3940
+ * // Call a function with parameters
3941
+ * const { data, error } = await client.rpc('calculate_discount', {
3942
+ * product_id: 123,
3943
+ * coupon_code: 'SAVE20'
3944
+ * })
3945
+ * ```
3946
+ *
3947
+ * @category Database
3948
+ */
3949
+ rpc<T = any>(functionName: string, params?: Record<string, unknown>): Promise<{
3950
+ data: T | null;
3951
+ error: Error | null;
3952
+ }>;
3953
+ /**
3954
+ * Sync auth state with realtime connections
3955
+ * @internal
3956
+ */
3957
+ private setupAuthSync;
3958
+ /**
3959
+ * Get the current authentication token
3960
+ *
3961
+ * @returns The current JWT access token, or null if not authenticated
3962
+ *
3963
+ * @category Authentication
3964
+ */
3965
+ getAuthToken(): string | null;
3966
+ /**
3967
+ * Set a new authentication token
3968
+ *
3969
+ * This updates both the HTTP client and realtime connection with the new token.
3970
+ *
3971
+ * @param token - The JWT access token to set, or null to clear authentication
3972
+ *
3973
+ * @category Authentication
3974
+ */
3975
+ setAuthToken(token: string | null): void;
3976
+ /**
3977
+ * Get the internal HTTP client
3978
+ *
3979
+ * Use this for advanced scenarios like making custom API calls or admin operations.
3980
+ *
3981
+ * @returns The internal FluxbaseFetch instance
3982
+ *
3983
+ * @example
3984
+ * ```typescript
3985
+ * // Make a custom API call
3986
+ * const data = await client.http.get('/api/custom-endpoint')
3987
+ * ```
3988
+ *
3989
+ * @category Advanced
3990
+ */
3991
+ get http(): FluxbaseFetch;
3992
+ }
3993
+ /**
3994
+ * Create a new Fluxbase client instance
3995
+ *
3996
+ * This is the recommended way to initialize the Fluxbase SDK.
3997
+ *
3998
+ * @param options - Client configuration options
3999
+ * @returns A configured Fluxbase client instance
4000
+ *
4001
+ * @example
4002
+ * ```typescript
4003
+ * import { createClient } from '@fluxbase/sdk'
4004
+ *
4005
+ * const client = createClient({
4006
+ * url: 'http://localhost:8080',
4007
+ * auth: {
4008
+ * token: 'your-jwt-token',
4009
+ * autoRefresh: true,
4010
+ * persist: true
4011
+ * },
4012
+ * timeout: 30000,
4013
+ * debug: false
4014
+ * })
4015
+ * ```
4016
+ *
4017
+ * @category Client
4018
+ */
4019
+ declare function createClient(options: FluxbaseClientOptions): FluxbaseClient;
4020
+
4021
+ 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 CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, 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 PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, 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 UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type ValidateInvitationResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };