@fluxbase/sdk 0.0.1-rc.2 → 0.0.1-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * Core types for the Fluxbase SDK
3
3
  */
4
+ /**
5
+ * Client configuration options (Supabase-compatible)
6
+ * These options are passed as the third parameter to createClient()
7
+ */
4
8
  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
9
  /**
12
10
  * Authentication options
13
11
  */
@@ -149,24 +147,60 @@ interface PostgresChangesConfig {
149
147
  table: string;
150
148
  filter?: string;
151
149
  }
150
+ /**
151
+ * Realtime postgres_changes payload structure
152
+ * Compatible with Supabase realtime payloads
153
+ */
154
+ interface RealtimePostgresChangesPayload<T = any> {
155
+ /** Event type (Supabase-compatible field name) */
156
+ eventType: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
157
+ /** Database schema */
158
+ schema: string;
159
+ /** Table name */
160
+ table: string;
161
+ /** Commit timestamp (Supabase-compatible field name) */
162
+ commit_timestamp: string;
163
+ /** New record data (Supabase-compatible field name) */
164
+ new: T;
165
+ /** Old record data (Supabase-compatible field name) */
166
+ old: T;
167
+ /** Error message if any */
168
+ errors: string | null;
169
+ }
170
+ /**
171
+ * @deprecated Use RealtimePostgresChangesPayload instead
172
+ */
152
173
  interface RealtimeChangePayload {
174
+ /** @deprecated Use eventType instead */
153
175
  type: 'INSERT' | 'UPDATE' | 'DELETE';
154
176
  schema: string;
155
177
  table: string;
178
+ /** @deprecated Use 'new' instead */
156
179
  new_record?: Record<string, unknown>;
180
+ /** @deprecated Use 'old' instead */
157
181
  old_record?: Record<string, unknown>;
182
+ /** @deprecated Use commit_timestamp instead */
158
183
  timestamp: string;
159
184
  }
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>;
185
+ type RealtimeCallback = (payload: RealtimePostgresChangesPayload) => void;
186
+ /**
187
+ * File object returned by storage operations
188
+ * Compatible with Supabase FileObject structure
189
+ */
190
+ interface FileObject {
191
+ name: string;
192
+ id?: string;
193
+ bucket_id?: string;
194
+ owner?: string;
195
+ created_at?: string;
196
+ updated_at?: string;
197
+ last_accessed_at?: string;
198
+ metadata?: Record<string, any>;
169
199
  }
200
+ /**
201
+ * @deprecated Use FileObject instead. This alias is provided for backwards compatibility.
202
+ */
203
+ type StorageObject = FileObject;
170
204
  interface UploadOptions {
171
205
  contentType?: string;
172
206
  metadata?: Record<string, string>;
@@ -181,6 +215,29 @@ interface ListOptions {
181
215
  interface SignedUrlOptions {
182
216
  expiresIn?: number;
183
217
  }
218
+ interface ShareFileOptions {
219
+ userId: string;
220
+ permission: 'read' | 'write';
221
+ }
222
+ interface FileShare {
223
+ user_id: string;
224
+ permission: 'read' | 'write';
225
+ created_at: string;
226
+ }
227
+ interface BucketSettings {
228
+ public?: boolean;
229
+ allowed_mime_types?: string[];
230
+ max_file_size?: number;
231
+ }
232
+ interface Bucket {
233
+ id: string;
234
+ name: string;
235
+ public: boolean;
236
+ allowed_mime_types: string[];
237
+ max_file_size?: number;
238
+ created_at: string;
239
+ updated_at: string;
240
+ }
184
241
  interface PasswordResetResponse {
185
242
  message: string;
186
243
  }
@@ -216,6 +273,7 @@ interface AdminSetupRequest {
216
273
  email: string;
217
274
  password: string;
218
275
  name: string;
276
+ setup_token: string;
219
277
  }
220
278
  interface AdminUser {
221
279
  id: string;
@@ -456,6 +514,48 @@ interface UpdateSystemSettingRequest {
456
514
  interface ListSystemSettingsResponse {
457
515
  settings: SystemSetting[];
458
516
  }
517
+ /**
518
+ * Custom setting with flexible key-value storage and role-based editing permissions
519
+ */
520
+ interface CustomSetting {
521
+ id: string;
522
+ key: string;
523
+ value: Record<string, unknown>;
524
+ value_type: 'string' | 'number' | 'boolean' | 'json';
525
+ description?: string;
526
+ editable_by: string[];
527
+ metadata?: Record<string, unknown>;
528
+ created_by?: string;
529
+ updated_by?: string;
530
+ created_at: string;
531
+ updated_at: string;
532
+ }
533
+ /**
534
+ * Request to create a custom setting
535
+ */
536
+ interface CreateCustomSettingRequest {
537
+ key: string;
538
+ value: Record<string, unknown>;
539
+ value_type?: 'string' | 'number' | 'boolean' | 'json';
540
+ description?: string;
541
+ editable_by?: string[];
542
+ metadata?: Record<string, unknown>;
543
+ }
544
+ /**
545
+ * Request to update a custom setting
546
+ */
547
+ interface UpdateCustomSettingRequest {
548
+ value: Record<string, unknown>;
549
+ description?: string;
550
+ editable_by?: string[];
551
+ metadata?: Record<string, unknown>;
552
+ }
553
+ /**
554
+ * Response containing all custom settings
555
+ */
556
+ interface ListCustomSettingsResponse {
557
+ settings: CustomSetting[];
558
+ }
459
559
  /**
460
560
  * Authentication settings for the application
461
561
  */
@@ -464,6 +564,12 @@ interface AuthenticationSettings {
464
564
  enable_magic_link: boolean;
465
565
  password_min_length: number;
466
566
  require_email_verification: boolean;
567
+ password_require_uppercase: boolean;
568
+ password_require_lowercase: boolean;
569
+ password_require_number: boolean;
570
+ password_require_special: boolean;
571
+ session_timeout_minutes: number;
572
+ max_sessions_per_user: number;
467
573
  }
468
574
  /**
469
575
  * Feature flags for the application
@@ -473,12 +579,51 @@ interface FeatureSettings {
473
579
  enable_storage: boolean;
474
580
  enable_functions: boolean;
475
581
  }
582
+ /**
583
+ * SMTP email provider configuration
584
+ */
585
+ interface SMTPSettings {
586
+ host: string;
587
+ port: number;
588
+ username: string;
589
+ password: string;
590
+ use_tls: boolean;
591
+ }
592
+ /**
593
+ * SendGrid email provider configuration
594
+ */
595
+ interface SendGridSettings {
596
+ api_key: string;
597
+ }
598
+ /**
599
+ * Mailgun email provider configuration
600
+ */
601
+ interface MailgunSettings {
602
+ api_key: string;
603
+ domain: string;
604
+ eu_region: boolean;
605
+ }
606
+ /**
607
+ * AWS SES email provider configuration
608
+ */
609
+ interface SESSettings {
610
+ access_key_id: string;
611
+ secret_access_key: string;
612
+ region: string;
613
+ }
476
614
  /**
477
615
  * Email configuration settings
478
616
  */
479
617
  interface EmailSettings {
480
618
  enabled: boolean;
481
- provider: string;
619
+ provider: 'smtp' | 'sendgrid' | 'mailgun' | 'ses';
620
+ from_address?: string;
621
+ from_name?: string;
622
+ reply_to_address?: string;
623
+ smtp?: SMTPSettings;
624
+ sendgrid?: SendGridSettings;
625
+ mailgun?: MailgunSettings;
626
+ ses?: SESSettings;
482
627
  }
483
628
  /**
484
629
  * Security settings for the application
@@ -505,6 +650,43 @@ interface UpdateAppSettingsRequest {
505
650
  email?: Partial<EmailSettings>;
506
651
  security?: Partial<SecuritySettings>;
507
652
  }
653
+ /**
654
+ * Email template type
655
+ */
656
+ type EmailTemplateType = 'magic_link' | 'verify_email' | 'reset_password' | 'invite_user';
657
+ /**
658
+ * Email template structure
659
+ */
660
+ interface EmailTemplate {
661
+ id: string;
662
+ template_type: EmailTemplateType;
663
+ subject: string;
664
+ html_body: string;
665
+ text_body?: string;
666
+ is_custom: boolean;
667
+ created_at: string;
668
+ updated_at: string;
669
+ }
670
+ /**
671
+ * Request to update an email template
672
+ */
673
+ interface UpdateEmailTemplateRequest {
674
+ subject: string;
675
+ html_body: string;
676
+ text_body?: string;
677
+ }
678
+ /**
679
+ * Request to test an email template
680
+ */
681
+ interface TestEmailTemplateRequest {
682
+ recipient_email: string;
683
+ }
684
+ /**
685
+ * Response when listing email templates
686
+ */
687
+ interface ListEmailTemplatesResponse {
688
+ templates: EmailTemplate[];
689
+ }
508
690
  interface OAuthProvider {
509
691
  id: string;
510
692
  name: string;
@@ -816,85 +998,347 @@ interface AuthSubscription {
816
998
  */
817
999
  unsubscribe: () => void;
818
1000
  }
819
-
820
1001
  /**
821
- * HTTP client for making requests to the Fluxbase API
1002
+ * Options for invoking an edge function
822
1003
  */
823
-
824
- interface FetchOptions {
825
- method: HttpMethod;
826
- headers?: Record<string, string>;
827
- body?: unknown;
828
- timeout?: number;
829
- }
830
- declare class FluxbaseFetch {
831
- private baseUrl;
832
- private defaultHeaders;
833
- private timeout;
834
- private debug;
835
- constructor(baseUrl: string, options?: {
836
- headers?: Record<string, string>;
837
- timeout?: number;
838
- debug?: boolean;
839
- });
1004
+ interface FunctionInvokeOptions {
840
1005
  /**
841
- * Update the authorization header
1006
+ * Request body to send to the function
842
1007
  */
843
- setAuthToken(token: string | null): void;
1008
+ body?: any;
844
1009
  /**
845
- * Make an HTTP request
1010
+ * Custom headers to include in the request
846
1011
  */
847
- request<T = unknown>(path: string, options: FetchOptions): Promise<T>;
1012
+ headers?: Record<string, string>;
848
1013
  /**
849
- * GET request
1014
+ * HTTP method to use
1015
+ * @default 'POST'
850
1016
  */
851
- get<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
1017
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
1018
+ }
1019
+ /**
1020
+ * Edge function metadata
1021
+ */
1022
+ interface EdgeFunction {
1023
+ id: string;
1024
+ name: string;
1025
+ description?: string;
1026
+ code: string;
1027
+ version: number;
1028
+ enabled: boolean;
1029
+ timeout_seconds: number;
1030
+ memory_limit_mb: number;
1031
+ allow_net: boolean;
1032
+ allow_env: boolean;
1033
+ allow_read: boolean;
1034
+ allow_write: boolean;
1035
+ allow_unauthenticated: boolean;
1036
+ cron_schedule?: string;
1037
+ created_at: string;
1038
+ updated_at: string;
1039
+ created_by?: string;
1040
+ }
1041
+ /**
1042
+ * Request to create a new edge function
1043
+ */
1044
+ interface CreateFunctionRequest {
1045
+ name: string;
1046
+ description?: string;
1047
+ code: string;
1048
+ enabled?: boolean;
1049
+ timeout_seconds?: number;
1050
+ memory_limit_mb?: number;
1051
+ allow_net?: boolean;
1052
+ allow_env?: boolean;
1053
+ allow_read?: boolean;
1054
+ allow_write?: boolean;
1055
+ allow_unauthenticated?: boolean;
1056
+ cron_schedule?: string;
1057
+ }
1058
+ /**
1059
+ * Request to update an existing edge function
1060
+ */
1061
+ interface UpdateFunctionRequest {
1062
+ description?: string;
1063
+ code?: string;
1064
+ enabled?: boolean;
1065
+ timeout_seconds?: number;
1066
+ memory_limit_mb?: number;
1067
+ allow_net?: boolean;
1068
+ allow_env?: boolean;
1069
+ allow_read?: boolean;
1070
+ allow_write?: boolean;
1071
+ allow_unauthenticated?: boolean;
1072
+ cron_schedule?: string;
1073
+ }
1074
+ /**
1075
+ * Edge function execution record
1076
+ */
1077
+ interface EdgeFunctionExecution {
1078
+ id: string;
1079
+ function_id: string;
1080
+ trigger_type: string;
1081
+ status: 'success' | 'error';
1082
+ status_code?: number;
1083
+ duration_ms?: number;
1084
+ result?: string;
1085
+ logs?: string;
1086
+ error_message?: string;
1087
+ executed_at: string;
1088
+ completed_at?: string;
1089
+ }
1090
+ /**
1091
+ * Base Fluxbase response type (Supabase-compatible)
1092
+ * Returns either `{ data, error: null }` on success or `{ data: null, error }` on failure
1093
+ */
1094
+ type FluxbaseResponse<T> = {
1095
+ data: T;
1096
+ error: null;
1097
+ } | {
1098
+ data: null;
1099
+ error: Error;
1100
+ };
1101
+ /**
1102
+ * Response type for operations that don't return data (void operations)
1103
+ */
1104
+ type VoidResponse = {
1105
+ error: Error | null;
1106
+ };
1107
+ /**
1108
+ * Auth response with user and session
1109
+ */
1110
+ type AuthResponseData = {
1111
+ user: User;
1112
+ session: AuthSession;
1113
+ };
1114
+ /**
1115
+ * Fluxbase auth response
1116
+ */
1117
+ type FluxbaseAuthResponse = FluxbaseResponse<AuthResponseData>;
1118
+ /**
1119
+ * User response
1120
+ */
1121
+ type UserResponse = FluxbaseResponse<{
1122
+ user: User;
1123
+ }>;
1124
+ /**
1125
+ * Session response
1126
+ */
1127
+ type SessionResponse = FluxbaseResponse<{
1128
+ session: AuthSession;
1129
+ }>;
1130
+ /**
1131
+ * Generic data response
1132
+ */
1133
+ type DataResponse<T> = FluxbaseResponse<T>;
1134
+ /**
1135
+ * @deprecated Use FluxbaseResponse instead
1136
+ */
1137
+ type SupabaseResponse<T> = FluxbaseResponse<T>;
1138
+ /**
1139
+ * @deprecated Use FluxbaseAuthResponse instead
1140
+ */
1141
+ type SupabaseAuthResponse = FluxbaseAuthResponse;
1142
+
1143
+ /**
1144
+ * Realtime subscriptions using WebSockets
1145
+ */
1146
+
1147
+ declare class RealtimeChannel {
1148
+ private ws;
1149
+ private url;
1150
+ private token;
1151
+ private channelName;
1152
+ private callbacks;
1153
+ private subscriptionConfig;
1154
+ private reconnectAttempts;
1155
+ private maxReconnectAttempts;
1156
+ private reconnectDelay;
1157
+ private heartbeatInterval;
1158
+ constructor(url: string, channelName: string, token?: string | null);
852
1159
  /**
853
- * POST request
1160
+ * Listen to postgres_changes with optional row-level filtering
1161
+ *
1162
+ * @param event - 'postgres_changes'
1163
+ * @param config - Configuration including optional filter
1164
+ * @param callback - Function to call when changes occur
1165
+ * @returns This channel for chaining
1166
+ *
1167
+ * @example
1168
+ * ```typescript
1169
+ * channel.on('postgres_changes', {
1170
+ * event: '*',
1171
+ * schema: 'public',
1172
+ * table: 'jobs',
1173
+ * filter: 'created_by=eq.user123'
1174
+ * }, (payload) => {
1175
+ * console.log('Job updated:', payload)
1176
+ * })
1177
+ * ```
854
1178
  */
855
- post<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1179
+ on(event: "postgres_changes", config: PostgresChangesConfig, callback: RealtimeCallback): this;
856
1180
  /**
857
- * PUT request
1181
+ * Listen to a specific event type (backwards compatibility)
1182
+ *
1183
+ * @param event - The event type (INSERT, UPDATE, DELETE, or '*' for all)
1184
+ * @param callback - The callback function
1185
+ * @returns This channel for chaining
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * channel.on('INSERT', (payload) => {
1190
+ * console.log('New record inserted:', payload.new_record)
1191
+ * })
1192
+ * ```
858
1193
  */
859
- put<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1194
+ on(event: "INSERT" | "UPDATE" | "DELETE" | "*", callback: RealtimeCallback): this;
860
1195
  /**
861
- * PATCH request
1196
+ * Remove a callback
862
1197
  */
863
- patch<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1198
+ off(event: "INSERT" | "UPDATE" | "DELETE" | "*", callback: RealtimeCallback): this;
864
1199
  /**
865
- * DELETE request
1200
+ * Subscribe to the channel
1201
+ * @param callback - Optional status callback (Supabase-compatible)
1202
+ * @param _timeout - Optional timeout in milliseconds (currently unused)
866
1203
  */
867
- delete<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
1204
+ subscribe(callback?: (status: "SUBSCRIBED" | "CHANNEL_ERROR" | "TIMED_OUT" | "CLOSED", err?: Error) => void, _timeout?: number): this;
868
1205
  /**
869
- * HEAD request
1206
+ * Unsubscribe from the channel
1207
+ * @param timeout - Optional timeout in milliseconds
1208
+ * @returns Promise resolving to status string (Supabase-compatible)
870
1209
  */
871
- head(path: string, options?: Omit<FetchOptions, 'method'>): Promise<Headers>;
872
- }
873
-
874
- /**
875
- * Authentication module for Fluxbase SDK
876
- */
877
-
878
- declare class FluxbaseAuth {
879
- private fetch;
880
- private session;
881
- private persist;
882
- private autoRefresh;
883
- private refreshTimer;
884
- private stateChangeListeners;
885
- constructor(fetch: FluxbaseFetch, autoRefresh?: boolean, persist?: boolean);
1210
+ unsubscribe(timeout?: number): Promise<"ok" | "timed out" | "error">;
886
1211
  /**
887
- * Get the current session
1212
+ * Internal: Connect to WebSocket
888
1213
  */
889
- getSession(): AuthSession | null;
1214
+ private connect;
890
1215
  /**
891
- * Get the current user
1216
+ * Internal: Disconnect WebSocket
892
1217
  */
893
- getUser(): User | null;
1218
+ private disconnect;
894
1219
  /**
895
- * Get the current access token
1220
+ * Internal: Send a message
896
1221
  */
897
- getAccessToken(): string | null;
1222
+ private send;
1223
+ /**
1224
+ * Internal: Handle incoming message
1225
+ */
1226
+ private handleMessage;
1227
+ /**
1228
+ * Internal: Handle broadcast message
1229
+ */
1230
+ private handleBroadcast;
1231
+ /**
1232
+ * Internal: Start heartbeat interval
1233
+ */
1234
+ private startHeartbeat;
1235
+ /**
1236
+ * Internal: Stop heartbeat interval
1237
+ */
1238
+ private stopHeartbeat;
1239
+ /**
1240
+ * Internal: Attempt to reconnect
1241
+ */
1242
+ private attemptReconnect;
1243
+ }
1244
+ declare class FluxbaseRealtime {
1245
+ private url;
1246
+ private token;
1247
+ private channels;
1248
+ constructor(url: string, token?: string | null);
1249
+ /**
1250
+ * Create or get a channel
1251
+ * @param channelName - Channel name (e.g., 'table:public.products')
1252
+ */
1253
+ channel(channelName: string): RealtimeChannel;
1254
+ /**
1255
+ * Remove all channels
1256
+ */
1257
+ removeAllChannels(): void;
1258
+ /**
1259
+ * Update auth token for all channels
1260
+ */
1261
+ setToken(token: string | null): void;
1262
+ }
1263
+
1264
+ /**
1265
+ * HTTP client for making requests to the Fluxbase API
1266
+ */
1267
+
1268
+ interface FetchOptions {
1269
+ method: HttpMethod;
1270
+ headers?: Record<string, string>;
1271
+ body?: unknown;
1272
+ timeout?: number;
1273
+ }
1274
+ declare class FluxbaseFetch {
1275
+ private baseUrl;
1276
+ private defaultHeaders;
1277
+ private timeout;
1278
+ private debug;
1279
+ constructor(baseUrl: string, options?: {
1280
+ headers?: Record<string, string>;
1281
+ timeout?: number;
1282
+ debug?: boolean;
1283
+ });
1284
+ /**
1285
+ * Update the authorization header
1286
+ */
1287
+ setAuthToken(token: string | null): void;
1288
+ /**
1289
+ * Make an HTTP request
1290
+ */
1291
+ request<T = unknown>(path: string, options: FetchOptions): Promise<T>;
1292
+ /**
1293
+ * GET request
1294
+ */
1295
+ get<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
1296
+ /**
1297
+ * POST request
1298
+ */
1299
+ post<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1300
+ /**
1301
+ * PUT request
1302
+ */
1303
+ put<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1304
+ /**
1305
+ * PATCH request
1306
+ */
1307
+ patch<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<T>;
1308
+ /**
1309
+ * DELETE request
1310
+ */
1311
+ delete<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
1312
+ /**
1313
+ * HEAD request
1314
+ */
1315
+ head(path: string, options?: Omit<FetchOptions, 'method'>): Promise<Headers>;
1316
+ }
1317
+
1318
+ /**
1319
+ * Authentication module for Fluxbase SDK
1320
+ */
1321
+
1322
+ declare class FluxbaseAuth {
1323
+ private fetch;
1324
+ private session;
1325
+ private persist;
1326
+ private autoRefresh;
1327
+ private refreshTimer;
1328
+ private stateChangeListeners;
1329
+ constructor(fetch: FluxbaseFetch, autoRefresh?: boolean, persist?: boolean);
1330
+ /**
1331
+ * Get the current session
1332
+ */
1333
+ getSession(): AuthSession | null;
1334
+ /**
1335
+ * Get the current user
1336
+ */
1337
+ getUser(): User | null;
1338
+ /**
1339
+ * Get the current access token
1340
+ */
1341
+ getAccessToken(): string | null;
898
1342
  /**
899
1343
  * Listen to auth state changes
900
1344
  * @param callback - Function called when auth state changes
@@ -915,27 +1359,33 @@ declare class FluxbaseAuth {
915
1359
  * Sign in with email and password
916
1360
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
917
1361
  */
918
- signIn(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1362
+ signIn(credentials: SignInCredentials): Promise<FluxbaseResponse<AuthSession | SignInWith2FAResponse>>;
1363
+ /**
1364
+ * Sign in with email and password
1365
+ * Alias for signIn() to maintain compatibility with common authentication patterns
1366
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1367
+ */
1368
+ signInWithPassword(credentials: SignInCredentials): Promise<FluxbaseResponse<AuthSession | SignInWith2FAResponse>>;
919
1369
  /**
920
1370
  * Sign up with email and password
921
1371
  */
922
- signUp(credentials: SignUpCredentials): Promise<AuthSession>;
1372
+ signUp(credentials: SignUpCredentials): Promise<FluxbaseAuthResponse>;
923
1373
  /**
924
1374
  * Sign out the current user
925
1375
  */
926
- signOut(): Promise<void>;
1376
+ signOut(): Promise<VoidResponse>;
927
1377
  /**
928
1378
  * Refresh the access token
929
1379
  */
930
- refreshToken(): Promise<AuthSession>;
1380
+ refreshToken(): Promise<SessionResponse>;
931
1381
  /**
932
1382
  * Get the current user from the server
933
1383
  */
934
- getCurrentUser(): Promise<User>;
1384
+ getCurrentUser(): Promise<UserResponse>;
935
1385
  /**
936
1386
  * Update the current user
937
1387
  */
938
- updateUser(data: Partial<Pick<User, 'email' | 'metadata'>>): Promise<User>;
1388
+ updateUser(data: Partial<Pick<User, "email" | "metadata">>): Promise<UserResponse>;
939
1389
  /**
940
1390
  * Set the auth token manually
941
1391
  */
@@ -944,87 +1394,98 @@ declare class FluxbaseAuth {
944
1394
  * Setup 2FA for the current user
945
1395
  * Returns TOTP secret and QR code URL
946
1396
  */
947
- setup2FA(): Promise<TwoFactorSetupResponse>;
1397
+ setup2FA(): Promise<DataResponse<TwoFactorSetupResponse>>;
948
1398
  /**
949
1399
  * Enable 2FA after verifying the TOTP code
950
1400
  * Returns backup codes that should be saved by the user
951
1401
  */
952
- enable2FA(code: string): Promise<TwoFactorEnableResponse>;
1402
+ enable2FA(code: string): Promise<DataResponse<TwoFactorEnableResponse>>;
953
1403
  /**
954
1404
  * Disable 2FA for the current user
955
1405
  * Requires password confirmation
956
1406
  */
957
- disable2FA(password: string): Promise<{
1407
+ disable2FA(password: string): Promise<DataResponse<{
958
1408
  success: boolean;
959
1409
  message: string;
960
- }>;
1410
+ }>>;
961
1411
  /**
962
1412
  * Check 2FA status for the current user
963
1413
  */
964
- get2FAStatus(): Promise<TwoFactorStatusResponse>;
1414
+ get2FAStatus(): Promise<DataResponse<TwoFactorStatusResponse>>;
965
1415
  /**
966
1416
  * Verify 2FA code during login
967
1417
  * Call this after signIn returns requires_2fa: true
968
1418
  */
969
- verify2FA(request: TwoFactorVerifyRequest): Promise<AuthSession>;
1419
+ verify2FA(request: TwoFactorVerifyRequest): Promise<FluxbaseAuthResponse>;
970
1420
  /**
971
1421
  * Send password reset email
972
1422
  * Sends a password reset link to the provided email address
973
1423
  * @param email - Email address to send reset link to
974
1424
  */
975
- sendPasswordReset(email: string): Promise<PasswordResetResponse>;
1425
+ sendPasswordReset(email: string): Promise<DataResponse<PasswordResetResponse>>;
1426
+ /**
1427
+ * Supabase-compatible alias for sendPasswordReset()
1428
+ * @param email - Email address to send reset link to
1429
+ * @param _options - Optional redirect configuration (currently not used)
1430
+ */
1431
+ resetPasswordForEmail(email: string, _options?: {
1432
+ redirectTo?: string;
1433
+ }): Promise<DataResponse<PasswordResetResponse>>;
976
1434
  /**
977
1435
  * Verify password reset token
978
1436
  * Check if a password reset token is valid before allowing password reset
979
1437
  * @param token - Password reset token to verify
980
1438
  */
981
- verifyResetToken(token: string): Promise<VerifyResetTokenResponse>;
1439
+ verifyResetToken(token: string): Promise<DataResponse<VerifyResetTokenResponse>>;
982
1440
  /**
983
1441
  * Reset password with token
984
1442
  * Complete the password reset process with a valid token
985
1443
  * @param token - Password reset token
986
1444
  * @param newPassword - New password to set
987
1445
  */
988
- resetPassword(token: string, newPassword: string): Promise<ResetPasswordResponse>;
1446
+ resetPassword(token: string, newPassword: string): Promise<DataResponse<ResetPasswordResponse>>;
989
1447
  /**
990
1448
  * Send magic link for passwordless authentication
991
1449
  * @param email - Email address to send magic link to
992
1450
  * @param options - Optional configuration for magic link
993
1451
  */
994
- sendMagicLink(email: string, options?: MagicLinkOptions): Promise<MagicLinkResponse>;
1452
+ sendMagicLink(email: string, options?: MagicLinkOptions): Promise<DataResponse<MagicLinkResponse>>;
995
1453
  /**
996
1454
  * Verify magic link token and sign in
997
1455
  * @param token - Magic link token from email
998
1456
  */
999
- verifyMagicLink(token: string): Promise<AuthSession>;
1457
+ verifyMagicLink(token: string): Promise<FluxbaseAuthResponse>;
1000
1458
  /**
1001
1459
  * Sign in anonymously
1002
1460
  * Creates a temporary anonymous user session
1003
1461
  */
1004
- signInAnonymously(): Promise<AuthSession>;
1462
+ signInAnonymously(): Promise<FluxbaseAuthResponse>;
1005
1463
  /**
1006
1464
  * Get list of enabled OAuth providers
1007
1465
  */
1008
- getOAuthProviders(): Promise<OAuthProvidersResponse>;
1466
+ getOAuthProviders(): Promise<DataResponse<OAuthProvidersResponse>>;
1009
1467
  /**
1010
1468
  * Get OAuth authorization URL for a provider
1011
1469
  * @param provider - OAuth provider name (e.g., 'google', 'github')
1012
1470
  * @param options - Optional OAuth configuration
1013
1471
  */
1014
- getOAuthUrl(provider: string, options?: OAuthOptions): Promise<OAuthUrlResponse>;
1472
+ getOAuthUrl(provider: string, options?: OAuthOptions): Promise<DataResponse<OAuthUrlResponse>>;
1015
1473
  /**
1016
1474
  * Exchange OAuth authorization code for session
1017
1475
  * This is typically called in your OAuth callback handler
1018
1476
  * @param code - Authorization code from OAuth callback
1019
1477
  */
1020
- exchangeCodeForSession(code: string): Promise<AuthSession>;
1478
+ exchangeCodeForSession(code: string): Promise<FluxbaseAuthResponse>;
1021
1479
  /**
1022
1480
  * Convenience method to initiate OAuth sign-in
1023
1481
  * Redirects the user to the OAuth provider's authorization page
1024
1482
  * @param provider - OAuth provider name (e.g., 'google', 'github')
1025
1483
  * @param options - Optional OAuth configuration
1026
1484
  */
1027
- signInWithOAuth(provider: string, options?: OAuthOptions): Promise<void>;
1485
+ signInWithOAuth(provider: string, options?: OAuthOptions): Promise<DataResponse<{
1486
+ provider: string;
1487
+ url: string;
1488
+ }>>;
1028
1489
  /**
1029
1490
  * Internal: Set the session and persist it
1030
1491
  */
@@ -1047,123 +1508,6 @@ declare class FluxbaseAuth {
1047
1508
  private emitAuthChange;
1048
1509
  }
1049
1510
 
1050
- /**
1051
- * Realtime subscriptions using WebSockets
1052
- */
1053
-
1054
- declare class RealtimeChannel {
1055
- private ws;
1056
- private url;
1057
- private token;
1058
- private channelName;
1059
- private callbacks;
1060
- private subscriptionConfig;
1061
- private reconnectAttempts;
1062
- private maxReconnectAttempts;
1063
- private reconnectDelay;
1064
- private heartbeatInterval;
1065
- constructor(url: string, channelName: string, token?: string | null);
1066
- /**
1067
- * Listen to postgres_changes with optional row-level filtering
1068
- *
1069
- * @param event - 'postgres_changes'
1070
- * @param config - Configuration including optional filter
1071
- * @param callback - Function to call when changes occur
1072
- * @returns This channel for chaining
1073
- *
1074
- * @example
1075
- * ```typescript
1076
- * channel.on('postgres_changes', {
1077
- * event: '*',
1078
- * schema: 'public',
1079
- * table: 'jobs',
1080
- * filter: 'created_by=eq.user123'
1081
- * }, (payload) => {
1082
- * console.log('Job updated:', payload)
1083
- * })
1084
- * ```
1085
- */
1086
- on(event: 'postgres_changes', config: PostgresChangesConfig, callback: RealtimeCallback): this;
1087
- /**
1088
- * Listen to a specific event type (backwards compatibility)
1089
- *
1090
- * @param event - The event type (INSERT, UPDATE, DELETE, or '*' for all)
1091
- * @param callback - The callback function
1092
- * @returns This channel for chaining
1093
- *
1094
- * @example
1095
- * ```typescript
1096
- * channel.on('INSERT', (payload) => {
1097
- * console.log('New record inserted:', payload.new_record)
1098
- * })
1099
- * ```
1100
- */
1101
- on(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
1102
- /**
1103
- * Remove a callback
1104
- */
1105
- off(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
1106
- /**
1107
- * Subscribe to the channel
1108
- */
1109
- subscribe(): this;
1110
- /**
1111
- * Unsubscribe from the channel
1112
- */
1113
- unsubscribe(): void;
1114
- /**
1115
- * Internal: Connect to WebSocket
1116
- */
1117
- private connect;
1118
- /**
1119
- * Internal: Disconnect WebSocket
1120
- */
1121
- private disconnect;
1122
- /**
1123
- * Internal: Send a message
1124
- */
1125
- private send;
1126
- /**
1127
- * Internal: Handle incoming message
1128
- */
1129
- private handleMessage;
1130
- /**
1131
- * Internal: Handle broadcast message
1132
- */
1133
- private handleBroadcast;
1134
- /**
1135
- * Internal: Start heartbeat interval
1136
- */
1137
- private startHeartbeat;
1138
- /**
1139
- * Internal: Stop heartbeat interval
1140
- */
1141
- private stopHeartbeat;
1142
- /**
1143
- * Internal: Attempt to reconnect
1144
- */
1145
- private attemptReconnect;
1146
- }
1147
- declare class FluxbaseRealtime {
1148
- private url;
1149
- private token;
1150
- private channels;
1151
- constructor(url: string, token?: string | null);
1152
- /**
1153
- * Create or get a channel
1154
- * @param channelName - Channel name (e.g., 'table:public.products')
1155
- */
1156
- channel(channelName: string): RealtimeChannel;
1157
- /**
1158
- * Remove all channels
1159
- */
1160
- removeAllChannels(): void;
1161
- /**
1162
- * Update auth token for all channels
1163
- */
1164
- setToken(token: string | null): void;
1165
- }
1166
-
1167
1511
  /**
1168
1512
  * Storage client for file operations
1169
1513
  */
@@ -1179,7 +1523,11 @@ declare class StorageBucket {
1179
1523
  * @param options - Upload options
1180
1524
  */
1181
1525
  upload(path: string, file: File | Blob | ArrayBuffer, options?: UploadOptions): Promise<{
1182
- data: StorageObject | null;
1526
+ data: {
1527
+ id: string;
1528
+ path: string;
1529
+ fullPath: string;
1530
+ } | null;
1183
1531
  error: Error | null;
1184
1532
  }>;
1185
1533
  /**
@@ -1192,10 +1540,12 @@ declare class StorageBucket {
1192
1540
  }>;
1193
1541
  /**
1194
1542
  * List files in the bucket
1195
- * @param options - List options (prefix, limit, offset)
1543
+ * Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
1544
+ * @param pathOrOptions - The folder path or list options
1545
+ * @param maybeOptions - List options when first param is a path
1196
1546
  */
1197
- list(options?: ListOptions): Promise<{
1198
- data: StorageObject[] | null;
1547
+ list(pathOrOptions?: string | ListOptions, maybeOptions?: ListOptions): Promise<{
1548
+ data: FileObject[] | null;
1199
1549
  error: Error | null;
1200
1550
  }>;
1201
1551
  /**
@@ -1203,7 +1553,7 @@ declare class StorageBucket {
1203
1553
  * @param paths - Array of file paths to remove
1204
1554
  */
1205
1555
  remove(paths: string[]): Promise<{
1206
- data: null;
1556
+ data: FileObject[] | null;
1207
1557
  error: Error | null;
1208
1558
  }>;
1209
1559
  /**
@@ -1232,7 +1582,9 @@ declare class StorageBucket {
1232
1582
  * @param toPath - New file path
1233
1583
  */
1234
1584
  move(fromPath: string, toPath: string): Promise<{
1235
- data: StorageObject | null;
1585
+ data: {
1586
+ message: string;
1587
+ } | null;
1236
1588
  error: Error | null;
1237
1589
  }>;
1238
1590
  /**
@@ -1241,7 +1593,35 @@ declare class StorageBucket {
1241
1593
  * @param toPath - Destination file path
1242
1594
  */
1243
1595
  copy(fromPath: string, toPath: string): Promise<{
1244
- data: StorageObject | null;
1596
+ data: {
1597
+ path: string;
1598
+ } | null;
1599
+ error: Error | null;
1600
+ }>;
1601
+ /**
1602
+ * Share a file with another user (RLS)
1603
+ * @param path - The file path
1604
+ * @param options - Share options (userId and permission)
1605
+ */
1606
+ share(path: string, options: ShareFileOptions): Promise<{
1607
+ data: null;
1608
+ error: Error | null;
1609
+ }>;
1610
+ /**
1611
+ * Revoke file access from a user (RLS)
1612
+ * @param path - The file path
1613
+ * @param userId - The user ID to revoke access from
1614
+ */
1615
+ revokeShare(path: string, userId: string): Promise<{
1616
+ data: null;
1617
+ error: Error | null;
1618
+ }>;
1619
+ /**
1620
+ * List users a file is shared with (RLS)
1621
+ * @param path - The file path
1622
+ */
1623
+ listShares(path: string): Promise<{
1624
+ data: FileShare[] | null;
1245
1625
  error: Error | null;
1246
1626
  }>;
1247
1627
  }
@@ -1267,24 +1647,220 @@ declare class FluxbaseStorage {
1267
1647
  * Create a new bucket
1268
1648
  * @param bucketName - The name of the bucket to create
1269
1649
  */
1270
- createBucket(bucketName: string): Promise<{
1271
- data: null;
1650
+ createBucket(bucketName: string): Promise<{
1651
+ data: {
1652
+ name: string;
1653
+ } | null;
1654
+ error: Error | null;
1655
+ }>;
1656
+ /**
1657
+ * Delete a bucket
1658
+ * @param bucketName - The name of the bucket to delete
1659
+ */
1660
+ deleteBucket(bucketName: string): Promise<{
1661
+ data: {
1662
+ message: string;
1663
+ } | null;
1664
+ error: Error | null;
1665
+ }>;
1666
+ /**
1667
+ * Empty a bucket (delete all files)
1668
+ * @param bucketName - The name of the bucket to empty
1669
+ */
1670
+ emptyBucket(bucketName: string): Promise<{
1671
+ data: {
1672
+ message: string;
1673
+ } | null;
1674
+ error: Error | null;
1675
+ }>;
1676
+ /**
1677
+ * Update bucket settings (RLS - requires admin or service key)
1678
+ * @param bucketName - The name of the bucket
1679
+ * @param settings - Bucket settings to update
1680
+ */
1681
+ updateBucketSettings(bucketName: string, settings: BucketSettings): Promise<{
1682
+ data: null;
1683
+ error: Error | null;
1684
+ }>;
1685
+ /**
1686
+ * Get bucket details
1687
+ * @param bucketName - The name of the bucket
1688
+ */
1689
+ getBucket(bucketName: string): Promise<{
1690
+ data: Bucket | null;
1691
+ error: Error | null;
1692
+ }>;
1693
+ }
1694
+
1695
+ /**
1696
+ * Edge Functions module for Fluxbase SDK
1697
+ * Compatible with Supabase Functions API
1698
+ *
1699
+ * @example
1700
+ * ```typescript
1701
+ * // Invoke a function
1702
+ * const { data, error } = await client.functions.invoke('hello-world', {
1703
+ * body: { name: 'Alice' }
1704
+ * })
1705
+ *
1706
+ * // With custom headers
1707
+ * const { data, error } = await client.functions.invoke('api-call', {
1708
+ * body: { query: 'data' },
1709
+ * headers: { 'X-Custom-Header': 'value' },
1710
+ * method: 'POST'
1711
+ * })
1712
+ * ```
1713
+ */
1714
+
1715
+ /**
1716
+ * Edge Functions client for invoking and managing serverless functions
1717
+ * API-compatible with Supabase Functions
1718
+ *
1719
+ * @category Functions
1720
+ */
1721
+ declare class FluxbaseFunctions {
1722
+ private fetch;
1723
+ constructor(fetch: FluxbaseFetch);
1724
+ /**
1725
+ * Invoke an edge function
1726
+ *
1727
+ * This method is fully compatible with Supabase's functions.invoke() API.
1728
+ *
1729
+ * @param functionName - The name of the function to invoke
1730
+ * @param options - Invocation options including body, headers, and HTTP method
1731
+ * @returns Promise resolving to { data, error } tuple
1732
+ *
1733
+ * @example
1734
+ * ```typescript
1735
+ * // Simple invocation
1736
+ * const { data, error } = await client.functions.invoke('hello', {
1737
+ * body: { name: 'World' }
1738
+ * })
1739
+ *
1740
+ * // With GET method
1741
+ * const { data, error } = await client.functions.invoke('get-data', {
1742
+ * method: 'GET'
1743
+ * })
1744
+ *
1745
+ * // With custom headers
1746
+ * const { data, error } = await client.functions.invoke('api-proxy', {
1747
+ * body: { query: 'search' },
1748
+ * headers: { 'Authorization': 'Bearer token' },
1749
+ * method: 'POST'
1750
+ * })
1751
+ * ```
1752
+ */
1753
+ invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<{
1754
+ data: T | null;
1755
+ error: Error | null;
1756
+ }>;
1757
+ /**
1758
+ * Create a new edge function
1759
+ *
1760
+ * @param request - Function configuration and code
1761
+ * @returns Promise resolving to { data, error } tuple with created function metadata
1762
+ *
1763
+ * @example
1764
+ * ```typescript
1765
+ * const { data, error } = await client.functions.create({
1766
+ * name: 'my-function',
1767
+ * code: 'export default async function handler(req) { return { hello: "world" } }',
1768
+ * enabled: true
1769
+ * })
1770
+ * ```
1771
+ */
1772
+ create(request: CreateFunctionRequest): Promise<{
1773
+ data: EdgeFunction | null;
1774
+ error: Error | null;
1775
+ }>;
1776
+ /**
1777
+ * List all edge functions
1778
+ *
1779
+ * @returns Promise resolving to { data, error } tuple with array of functions
1780
+ *
1781
+ * @example
1782
+ * ```typescript
1783
+ * const { data, error } = await client.functions.list()
1784
+ * if (data) {
1785
+ * console.log('Functions:', data.map(f => f.name))
1786
+ * }
1787
+ * ```
1788
+ */
1789
+ list(): Promise<{
1790
+ data: EdgeFunction[] | null;
1791
+ error: Error | null;
1792
+ }>;
1793
+ /**
1794
+ * Get details of a specific edge function
1795
+ *
1796
+ * @param name - Function name
1797
+ * @returns Promise resolving to { data, error } tuple with function metadata
1798
+ *
1799
+ * @example
1800
+ * ```typescript
1801
+ * const { data, error } = await client.functions.get('my-function')
1802
+ * if (data) {
1803
+ * console.log('Function version:', data.version)
1804
+ * }
1805
+ * ```
1806
+ */
1807
+ get(name: string): Promise<{
1808
+ data: EdgeFunction | null;
1809
+ error: Error | null;
1810
+ }>;
1811
+ /**
1812
+ * Update an existing edge function
1813
+ *
1814
+ * @param name - Function name
1815
+ * @param updates - Fields to update
1816
+ * @returns Promise resolving to { data, error } tuple with updated function metadata
1817
+ *
1818
+ * @example
1819
+ * ```typescript
1820
+ * const { data, error } = await client.functions.update('my-function', {
1821
+ * enabled: false,
1822
+ * description: 'Updated description'
1823
+ * })
1824
+ * ```
1825
+ */
1826
+ update(name: string, updates: UpdateFunctionRequest): Promise<{
1827
+ data: EdgeFunction | null;
1272
1828
  error: Error | null;
1273
1829
  }>;
1274
1830
  /**
1275
- * Delete a bucket
1276
- * @param bucketName - The name of the bucket to delete
1831
+ * Delete an edge function
1832
+ *
1833
+ * @param name - Function name
1834
+ * @returns Promise resolving to { data, error } tuple
1835
+ *
1836
+ * @example
1837
+ * ```typescript
1838
+ * const { data, error } = await client.functions.delete('my-function')
1839
+ * ```
1277
1840
  */
1278
- deleteBucket(bucketName: string): Promise<{
1841
+ delete(name: string): Promise<{
1279
1842
  data: null;
1280
1843
  error: Error | null;
1281
1844
  }>;
1282
1845
  /**
1283
- * Empty a bucket (delete all files)
1284
- * @param bucketName - The name of the bucket to empty
1846
+ * Get execution history for an edge function
1847
+ *
1848
+ * @param name - Function name
1849
+ * @param limit - Maximum number of executions to return (optional)
1850
+ * @returns Promise resolving to { data, error } tuple with execution records
1851
+ *
1852
+ * @example
1853
+ * ```typescript
1854
+ * const { data, error } = await client.functions.getExecutions('my-function', 10)
1855
+ * if (data) {
1856
+ * data.forEach(exec => {
1857
+ * console.log(`${exec.executed_at}: ${exec.status} (${exec.duration_ms}ms)`)
1858
+ * })
1859
+ * }
1860
+ * ```
1285
1861
  */
1286
- emptyBucket(bucketName: string): Promise<{
1287
- data: null;
1862
+ getExecutions(name: string, limit?: number): Promise<{
1863
+ data: EdgeFunctionExecution[] | null;
1288
1864
  error: Error | null;
1289
1865
  }>;
1290
1866
  }
@@ -1517,7 +2093,7 @@ declare class AppSettingsManager {
1517
2093
  * await client.admin.settings.app.setFeature('storage', false)
1518
2094
  * ```
1519
2095
  */
1520
- setFeature(feature: 'realtime' | 'storage' | 'functions', enabled: boolean): Promise<AppSettings>;
2096
+ setFeature(feature: "realtime" | "storage" | "functions", enabled: boolean): Promise<AppSettings>;
1521
2097
  /**
1522
2098
  * Enable or disable global rate limiting
1523
2099
  *
@@ -1532,11 +2108,410 @@ declare class AppSettingsManager {
1532
2108
  * ```
1533
2109
  */
1534
2110
  setRateLimiting(enabled: boolean): Promise<AppSettings>;
2111
+ /**
2112
+ * Configure SMTP email provider
2113
+ *
2114
+ * Convenience method to set up SMTP email delivery.
2115
+ *
2116
+ * @param config - SMTP configuration
2117
+ * @returns Promise resolving to AppSettings
2118
+ *
2119
+ * @example
2120
+ * ```typescript
2121
+ * await client.admin.settings.app.configureSMTP({
2122
+ * host: 'smtp.gmail.com',
2123
+ * port: 587,
2124
+ * username: 'your-email@gmail.com',
2125
+ * password: 'your-app-password',
2126
+ * use_tls: true,
2127
+ * from_address: 'noreply@yourapp.com',
2128
+ * from_name: 'Your App'
2129
+ * })
2130
+ * ```
2131
+ */
2132
+ configureSMTP(config: {
2133
+ host: string;
2134
+ port: number;
2135
+ username: string;
2136
+ password: string;
2137
+ use_tls: boolean;
2138
+ from_address?: string;
2139
+ from_name?: string;
2140
+ reply_to_address?: string;
2141
+ }): Promise<AppSettings>;
2142
+ /**
2143
+ * Configure SendGrid email provider
2144
+ *
2145
+ * Convenience method to set up SendGrid email delivery.
2146
+ *
2147
+ * @param apiKey - SendGrid API key
2148
+ * @param options - Optional from address, name, and reply-to
2149
+ * @returns Promise resolving to AppSettings
2150
+ *
2151
+ * @example
2152
+ * ```typescript
2153
+ * await client.admin.settings.app.configureSendGrid('SG.xxx', {
2154
+ * from_address: 'noreply@yourapp.com',
2155
+ * from_name: 'Your App'
2156
+ * })
2157
+ * ```
2158
+ */
2159
+ configureSendGrid(apiKey: string, options?: {
2160
+ from_address?: string;
2161
+ from_name?: string;
2162
+ reply_to_address?: string;
2163
+ }): Promise<AppSettings>;
2164
+ /**
2165
+ * Configure Mailgun email provider
2166
+ *
2167
+ * Convenience method to set up Mailgun email delivery.
2168
+ *
2169
+ * @param apiKey - Mailgun API key
2170
+ * @param domain - Mailgun domain
2171
+ * @param options - Optional EU region flag and email addresses
2172
+ * @returns Promise resolving to AppSettings
2173
+ *
2174
+ * @example
2175
+ * ```typescript
2176
+ * await client.admin.settings.app.configureMailgun('key-xxx', 'mg.yourapp.com', {
2177
+ * eu_region: false,
2178
+ * from_address: 'noreply@yourapp.com',
2179
+ * from_name: 'Your App'
2180
+ * })
2181
+ * ```
2182
+ */
2183
+ configureMailgun(apiKey: string, domain: string, options?: {
2184
+ eu_region?: boolean;
2185
+ from_address?: string;
2186
+ from_name?: string;
2187
+ reply_to_address?: string;
2188
+ }): Promise<AppSettings>;
2189
+ /**
2190
+ * Configure AWS SES email provider
2191
+ *
2192
+ * Convenience method to set up AWS SES email delivery.
2193
+ *
2194
+ * @param accessKeyId - AWS access key ID
2195
+ * @param secretAccessKey - AWS secret access key
2196
+ * @param region - AWS region (e.g., 'us-east-1')
2197
+ * @param options - Optional email addresses
2198
+ * @returns Promise resolving to AppSettings
2199
+ *
2200
+ * @example
2201
+ * ```typescript
2202
+ * await client.admin.settings.app.configureSES(
2203
+ * 'AKIAIOSFODNN7EXAMPLE',
2204
+ * 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
2205
+ * 'us-east-1',
2206
+ * {
2207
+ * from_address: 'noreply@yourapp.com',
2208
+ * from_name: 'Your App'
2209
+ * }
2210
+ * )
2211
+ * ```
2212
+ */
2213
+ configureSES(accessKeyId: string, secretAccessKey: string, region: string, options?: {
2214
+ from_address?: string;
2215
+ from_name?: string;
2216
+ reply_to_address?: string;
2217
+ }): Promise<AppSettings>;
2218
+ /**
2219
+ * Enable or disable email functionality
2220
+ *
2221
+ * Convenience method to toggle email system on/off.
2222
+ *
2223
+ * @param enabled - Whether to enable email
2224
+ * @returns Promise resolving to AppSettings
2225
+ *
2226
+ * @example
2227
+ * ```typescript
2228
+ * await client.admin.settings.app.setEmailEnabled(true)
2229
+ * ```
2230
+ */
2231
+ setEmailEnabled(enabled: boolean): Promise<AppSettings>;
2232
+ /**
2233
+ * Configure password complexity requirements
2234
+ *
2235
+ * Convenience method to set password validation rules.
2236
+ *
2237
+ * @param requirements - Password complexity requirements
2238
+ * @returns Promise resolving to AppSettings
2239
+ *
2240
+ * @example
2241
+ * ```typescript
2242
+ * await client.admin.settings.app.setPasswordComplexity({
2243
+ * min_length: 12,
2244
+ * require_uppercase: true,
2245
+ * require_lowercase: true,
2246
+ * require_number: true,
2247
+ * require_special: true
2248
+ * })
2249
+ * ```
2250
+ */
2251
+ setPasswordComplexity(requirements: {
2252
+ min_length?: number;
2253
+ require_uppercase?: boolean;
2254
+ require_lowercase?: boolean;
2255
+ require_number?: boolean;
2256
+ require_special?: boolean;
2257
+ }): Promise<AppSettings>;
2258
+ /**
2259
+ * Configure session settings
2260
+ *
2261
+ * Convenience method to set session timeout and limits.
2262
+ *
2263
+ * @param timeoutMinutes - Session timeout in minutes (0 for no timeout)
2264
+ * @param maxSessionsPerUser - Maximum concurrent sessions per user (0 for unlimited)
2265
+ * @returns Promise resolving to AppSettings
2266
+ *
2267
+ * @example
2268
+ * ```typescript
2269
+ * // 30 minute sessions, max 3 devices per user
2270
+ * await client.admin.settings.app.setSessionSettings(30, 3)
2271
+ * ```
2272
+ */
2273
+ setSessionSettings(timeoutMinutes: number, maxSessionsPerUser: number): Promise<AppSettings>;
2274
+ /**
2275
+ * Enable or disable email verification requirement
2276
+ *
2277
+ * Convenience method to require email verification for new signups.
2278
+ *
2279
+ * @param required - Whether to require email verification
2280
+ * @returns Promise resolving to AppSettings
2281
+ *
2282
+ * @example
2283
+ * ```typescript
2284
+ * await client.admin.settings.app.setEmailVerificationRequired(true)
2285
+ * ```
2286
+ */
2287
+ setEmailVerificationRequired(required: boolean): Promise<AppSettings>;
2288
+ }
2289
+ /**
2290
+ * Custom Settings Manager
2291
+ *
2292
+ * Manages custom admin-created settings with flexible key-value storage.
2293
+ * Unlike system settings, custom settings allow admins to create arbitrary configuration entries
2294
+ * with role-based editing permissions.
2295
+ *
2296
+ * @example
2297
+ * ```typescript
2298
+ * const custom = client.admin.settings.custom
2299
+ *
2300
+ * // Create a custom setting
2301
+ * const setting = await custom.create({
2302
+ * key: 'feature.dark_mode',
2303
+ * value: { enabled: true, theme: 'dark' },
2304
+ * value_type: 'json',
2305
+ * description: 'Dark mode configuration',
2306
+ * editable_by: ['dashboard_admin', 'admin']
2307
+ * })
2308
+ *
2309
+ * // List all custom settings
2310
+ * const { settings } = await custom.list()
2311
+ *
2312
+ * // Get specific setting
2313
+ * const darkMode = await custom.get('feature.dark_mode')
2314
+ *
2315
+ * // Update setting
2316
+ * await custom.update('feature.dark_mode', {
2317
+ * value: { enabled: false, theme: 'light' }
2318
+ * })
2319
+ *
2320
+ * // Delete setting
2321
+ * await custom.delete('feature.dark_mode')
2322
+ * ```
2323
+ */
2324
+ declare class CustomSettingsManager {
2325
+ private fetch;
2326
+ constructor(fetch: FluxbaseFetch);
2327
+ /**
2328
+ * Create a new custom setting
2329
+ *
2330
+ * @param request - Custom setting creation request
2331
+ * @returns Promise resolving to CustomSetting
2332
+ *
2333
+ * @example
2334
+ * ```typescript
2335
+ * const setting = await client.admin.settings.custom.create({
2336
+ * key: 'api.quotas',
2337
+ * value: { free: 1000, pro: 10000, enterprise: 100000 },
2338
+ * value_type: 'json',
2339
+ * description: 'API request quotas by tier',
2340
+ * metadata: { category: 'billing' }
2341
+ * })
2342
+ * ```
2343
+ */
2344
+ create(request: CreateCustomSettingRequest): Promise<CustomSetting>;
2345
+ /**
2346
+ * List all custom settings
2347
+ *
2348
+ * @returns Promise resolving to ListCustomSettingsResponse
2349
+ *
2350
+ * @example
2351
+ * ```typescript
2352
+ * const response = await client.admin.settings.custom.list()
2353
+ * console.log(response.settings)
2354
+ * ```
2355
+ */
2356
+ list(): Promise<ListCustomSettingsResponse>;
2357
+ /**
2358
+ * Get a specific custom setting by key
2359
+ *
2360
+ * @param key - Setting key (e.g., 'feature.dark_mode')
2361
+ * @returns Promise resolving to CustomSetting
2362
+ *
2363
+ * @example
2364
+ * ```typescript
2365
+ * const setting = await client.admin.settings.custom.get('feature.dark_mode')
2366
+ * console.log(setting.value)
2367
+ * ```
2368
+ */
2369
+ get(key: string): Promise<CustomSetting>;
2370
+ /**
2371
+ * Update an existing custom setting
2372
+ *
2373
+ * @param key - Setting key
2374
+ * @param request - Update request with new values
2375
+ * @returns Promise resolving to CustomSetting
2376
+ *
2377
+ * @example
2378
+ * ```typescript
2379
+ * const updated = await client.admin.settings.custom.update('feature.dark_mode', {
2380
+ * value: { enabled: false },
2381
+ * description: 'Updated description'
2382
+ * })
2383
+ * ```
2384
+ */
2385
+ update(key: string, request: UpdateCustomSettingRequest): Promise<CustomSetting>;
2386
+ /**
2387
+ * Delete a custom setting
2388
+ *
2389
+ * @param key - Setting key to delete
2390
+ * @returns Promise<void>
2391
+ *
2392
+ * @example
2393
+ * ```typescript
2394
+ * await client.admin.settings.custom.delete('feature.dark_mode')
2395
+ * ```
2396
+ */
2397
+ delete(key: string): Promise<void>;
2398
+ }
2399
+ /**
2400
+ * Email Template Manager
2401
+ *
2402
+ * Manages email templates for authentication and user communication.
2403
+ * Supports customizing templates for magic links, email verification, password resets, and user invitations.
2404
+ *
2405
+ * @example
2406
+ * ```typescript
2407
+ * const templates = client.admin.emailTemplates
2408
+ *
2409
+ * // List all templates
2410
+ * const { templates: allTemplates } = await templates.list()
2411
+ *
2412
+ * // Get specific template
2413
+ * const magicLink = await templates.get('magic_link')
2414
+ *
2415
+ * // Update template
2416
+ * await templates.update('magic_link', {
2417
+ * subject: 'Sign in to ' + '{{.AppName}}',
2418
+ * html_body: '<html>Custom template with ' + '{{.MagicLink}}' + '</html>',
2419
+ * text_body: 'Click here: ' + '{{.MagicLink}}'
2420
+ * })
2421
+ *
2422
+ * // Test template (sends to specified email)
2423
+ * await templates.test('magic_link', 'test@example.com')
2424
+ *
2425
+ * // Reset to default
2426
+ * await templates.reset('magic_link')
2427
+ * ```
2428
+ */
2429
+ declare class EmailTemplateManager {
2430
+ private fetch;
2431
+ constructor(fetch: FluxbaseFetch);
2432
+ /**
2433
+ * List all email templates
2434
+ *
2435
+ * @returns Promise resolving to ListEmailTemplatesResponse
2436
+ *
2437
+ * @example
2438
+ * ```typescript
2439
+ * const response = await client.admin.emailTemplates.list()
2440
+ * console.log(response.templates)
2441
+ * ```
2442
+ */
2443
+ list(): Promise<ListEmailTemplatesResponse>;
2444
+ /**
2445
+ * Get a specific email template by type
2446
+ *
2447
+ * @param type - Template type (magic_link | verify_email | reset_password | invite_user)
2448
+ * @returns Promise resolving to EmailTemplate
2449
+ *
2450
+ * @example
2451
+ * ```typescript
2452
+ * const template = await client.admin.emailTemplates.get('magic_link')
2453
+ * console.log(template.subject)
2454
+ * console.log(template.html_body)
2455
+ * ```
2456
+ */
2457
+ get(type: EmailTemplateType): Promise<EmailTemplate>;
2458
+ /**
2459
+ * Update an email template
2460
+ *
2461
+ * Available template variables:
2462
+ * - magic_link: `{{.MagicLink}}`, `{{.AppName}}`, `{{.ExpiryMinutes}}`
2463
+ * - verify_email: `{{.VerificationLink}}`, `{{.AppName}}`
2464
+ * - reset_password: `{{.ResetLink}}`, `{{.AppName}}`, `{{.ExpiryMinutes}}`
2465
+ * - invite_user: `{{.InviteLink}}`, `{{.AppName}}`, `{{.InviterName}}`
2466
+ *
2467
+ * @param type - Template type to update
2468
+ * @param request - Update request with subject, html_body, and optional text_body
2469
+ * @returns Promise resolving to EmailTemplate
2470
+ *
2471
+ * @example
2472
+ * ```typescript
2473
+ * const updated = await client.admin.emailTemplates.update('magic_link', {
2474
+ * subject: 'Your Magic Link - Sign in to ' + '{{.AppName}}',
2475
+ * html_body: '<html><body><h1>Welcome!</h1><a href="' + '{{.MagicLink}}' + '">Sign In</a></body></html>',
2476
+ * text_body: 'Click here to sign in: ' + '{{.MagicLink}}'
2477
+ * })
2478
+ * ```
2479
+ */
2480
+ update(type: EmailTemplateType, request: UpdateEmailTemplateRequest): Promise<EmailTemplate>;
2481
+ /**
2482
+ * Reset an email template to default
2483
+ *
2484
+ * Removes any customizations and restores the template to its original state.
2485
+ *
2486
+ * @param type - Template type to reset
2487
+ * @returns Promise resolving to EmailTemplate - The default template
2488
+ *
2489
+ * @example
2490
+ * ```typescript
2491
+ * const defaultTemplate = await client.admin.emailTemplates.reset('magic_link')
2492
+ * ```
2493
+ */
2494
+ reset(type: EmailTemplateType): Promise<EmailTemplate>;
2495
+ /**
2496
+ * Send a test email using the template
2497
+ *
2498
+ * Useful for previewing template changes before deploying to production.
2499
+ *
2500
+ * @param type - Template type to test
2501
+ * @param recipientEmail - Email address to send test to
2502
+ * @returns Promise<void>
2503
+ *
2504
+ * @example
2505
+ * ```typescript
2506
+ * await client.admin.emailTemplates.test('magic_link', 'test@example.com')
2507
+ * ```
2508
+ */
2509
+ test(type: EmailTemplateType, recipientEmail: string): Promise<void>;
1535
2510
  }
1536
2511
  /**
1537
2512
  * Settings Manager
1538
2513
  *
1539
- * Provides access to both system-level and application-level settings.
2514
+ * Provides access to system-level, application-level, and custom settings.
1540
2515
  *
1541
2516
  * @example
1542
2517
  * ```typescript
@@ -1547,11 +2522,15 @@ declare class AppSettingsManager {
1547
2522
  *
1548
2523
  * // Access app settings
1549
2524
  * const appSettings = await settings.app.get()
2525
+ *
2526
+ * // Access custom settings
2527
+ * const customSettings = await settings.custom.list()
1550
2528
  * ```
1551
2529
  */
1552
2530
  declare class FluxbaseSettings {
1553
2531
  system: SystemSettingsManager;
1554
2532
  app: AppSettingsManager;
2533
+ custom: CustomSettingsManager;
1555
2534
  constructor(fetch: FluxbaseFetch);
1556
2535
  }
1557
2536
 
@@ -2672,6 +3651,10 @@ declare class FluxbaseAdmin {
2672
3651
  * Management namespace for API keys, webhooks, and invitations
2673
3652
  */
2674
3653
  management: FluxbaseManagement;
3654
+ /**
3655
+ * Email template manager for customizing authentication and notification emails
3656
+ */
3657
+ emailTemplates: EmailTemplateManager;
2675
3658
  constructor(fetch: FluxbaseFetch);
2676
3659
  /**
2677
3660
  * Set admin authentication token
@@ -2698,7 +3681,7 @@ declare class FluxbaseAdmin {
2698
3681
  * }
2699
3682
  * ```
2700
3683
  */
2701
- getSetupStatus(): Promise<AdminSetupStatusResponse>;
3684
+ getSetupStatus(): Promise<DataResponse<AdminSetupStatusResponse>>;
2702
3685
  /**
2703
3686
  * Perform initial admin setup
2704
3687
  *
@@ -2722,7 +3705,7 @@ declare class FluxbaseAdmin {
2722
3705
  * localStorage.setItem('admin_token', response.access_token);
2723
3706
  * ```
2724
3707
  */
2725
- setup(request: AdminSetupRequest): Promise<AdminAuthResponse>;
3708
+ setup(request: AdminSetupRequest): Promise<DataResponse<AdminAuthResponse>>;
2726
3709
  /**
2727
3710
  * Admin login
2728
3711
  *
@@ -2743,7 +3726,7 @@ declare class FluxbaseAdmin {
2743
3726
  * console.log('Logged in as:', response.user.email);
2744
3727
  * ```
2745
3728
  */
2746
- login(request: AdminLoginRequest): Promise<AdminAuthResponse>;
3729
+ login(request: AdminLoginRequest): Promise<DataResponse<AdminAuthResponse>>;
2747
3730
  /**
2748
3731
  * Refresh admin access token
2749
3732
  *
@@ -2760,7 +3743,7 @@ declare class FluxbaseAdmin {
2760
3743
  * localStorage.setItem('admin_refresh_token', response.refresh_token);
2761
3744
  * ```
2762
3745
  */
2763
- refreshToken(request: AdminRefreshRequest): Promise<AdminRefreshResponse>;
3746
+ refreshToken(request: AdminRefreshRequest): Promise<DataResponse<AdminRefreshResponse>>;
2764
3747
  /**
2765
3748
  * Admin logout
2766
3749
  *
@@ -2772,7 +3755,7 @@ declare class FluxbaseAdmin {
2772
3755
  * localStorage.removeItem('admin_token');
2773
3756
  * ```
2774
3757
  */
2775
- logout(): Promise<void>;
3758
+ logout(): Promise<VoidResponse>;
2776
3759
  /**
2777
3760
  * Get current admin user information
2778
3761
  *
@@ -2785,7 +3768,7 @@ declare class FluxbaseAdmin {
2785
3768
  * console.log('Role:', user.role);
2786
3769
  * ```
2787
3770
  */
2788
- me(): Promise<AdminMeResponse>;
3771
+ me(): Promise<DataResponse<AdminMeResponse>>;
2789
3772
  /**
2790
3773
  * List all users
2791
3774
  *
@@ -2806,7 +3789,7 @@ declare class FluxbaseAdmin {
2806
3789
  * });
2807
3790
  * ```
2808
3791
  */
2809
- listUsers(options?: ListUsersOptions): Promise<ListUsersResponse>;
3792
+ listUsers(options?: ListUsersOptions): Promise<DataResponse<ListUsersResponse>>;
2810
3793
  /**
2811
3794
  * Get a user by ID
2812
3795
  *
@@ -2827,7 +3810,7 @@ declare class FluxbaseAdmin {
2827
3810
  * console.log('Last login:', dashboardUser.last_login_at);
2828
3811
  * ```
2829
3812
  */
2830
- getUserById(userId: string, type?: "app" | "dashboard"): Promise<EnrichedUser>;
3813
+ getUserById(userId: string, type?: "app" | "dashboard"): Promise<DataResponse<EnrichedUser>>;
2831
3814
  /**
2832
3815
  * Invite a new user
2833
3816
  *
@@ -2849,7 +3832,7 @@ declare class FluxbaseAdmin {
2849
3832
  * console.log('Invitation link:', response.invitation_link);
2850
3833
  * ```
2851
3834
  */
2852
- inviteUser(request: InviteUserRequest, type?: "app" | "dashboard"): Promise<InviteUserResponse>;
3835
+ inviteUser(request: InviteUserRequest, type?: "app" | "dashboard"): Promise<DataResponse<InviteUserResponse>>;
2853
3836
  /**
2854
3837
  * Delete a user
2855
3838
  *
@@ -2865,7 +3848,7 @@ declare class FluxbaseAdmin {
2865
3848
  * console.log('User deleted');
2866
3849
  * ```
2867
3850
  */
2868
- deleteUser(userId: string, type?: "app" | "dashboard"): Promise<DeleteUserResponse>;
3851
+ deleteUser(userId: string, type?: "app" | "dashboard"): Promise<DataResponse<DeleteUserResponse>>;
2869
3852
  /**
2870
3853
  * Update user role
2871
3854
  *
@@ -2882,7 +3865,7 @@ declare class FluxbaseAdmin {
2882
3865
  * console.log('User role updated:', user.role);
2883
3866
  * ```
2884
3867
  */
2885
- updateUserRole(userId: string, role: string, type?: "app" | "dashboard"): Promise<EnrichedUser>;
3868
+ updateUserRole(userId: string, role: string, type?: "app" | "dashboard"): Promise<DataResponse<EnrichedUser>>;
2886
3869
  /**
2887
3870
  * Reset user password
2888
3871
  *
@@ -2898,7 +3881,7 @@ declare class FluxbaseAdmin {
2898
3881
  * console.log(response.message);
2899
3882
  * ```
2900
3883
  */
2901
- resetUserPassword(userId: string, type?: "app" | "dashboard"): Promise<ResetUserPasswordResponse>;
3884
+ resetUserPassword(userId: string, type?: "app" | "dashboard"): Promise<DataResponse<ResetUserPasswordResponse>>;
2902
3885
  }
2903
3886
 
2904
3887
  /**
@@ -3247,45 +4230,13 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
3247
4230
  private formatValue;
3248
4231
  }
3249
4232
 
3250
- /**
3251
- * Main Fluxbase client for interacting with the Fluxbase backend.
3252
- *
3253
- * This client provides access to all Fluxbase features including:
3254
- * - Database operations via PostgREST-compatible API
3255
- * - Authentication and user management
3256
- * - Real-time subscriptions via WebSockets
3257
- * - File storage and management
3258
- * - PostgreSQL function calls (RPC)
3259
- *
3260
- * @example
3261
- * ```typescript
3262
- * import { createClient } from '@fluxbase/sdk'
3263
- *
3264
- * const client = createClient({
3265
- * url: 'http://localhost:8080',
3266
- * auth: {
3267
- * token: 'your-jwt-token',
3268
- * autoRefresh: true
3269
- * }
3270
- * })
3271
- *
3272
- * // Query database
3273
- * const { data } = await client.from('users').select('*').execute()
3274
- *
3275
- * // Subscribe to realtime changes
3276
- * client.realtime.subscribe('users', (payload) => {
3277
- * console.log('Change:', payload)
3278
- * })
3279
- * ```
3280
- *
3281
- * @category Client
3282
- */
3283
-
3284
4233
  /**
3285
4234
  * Main Fluxbase client class
3286
4235
  * @category Client
3287
4236
  */
3288
- declare class FluxbaseClient {
4237
+ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof Database = any> {
4238
+ protected fluxbaseUrl: string;
4239
+ protected fluxbaseKey: string;
3289
4240
  /** Internal HTTP client for making requests */
3290
4241
  private fetch;
3291
4242
  /** Authentication module for user management */
@@ -3294,15 +4245,29 @@ declare class FluxbaseClient {
3294
4245
  realtime: FluxbaseRealtime;
3295
4246
  /** Storage module for file operations */
3296
4247
  storage: FluxbaseStorage;
4248
+ /** Functions module for invoking and managing edge functions */
4249
+ functions: FluxbaseFunctions;
3297
4250
  /** Admin module for instance management (requires admin authentication) */
3298
4251
  admin: FluxbaseAdmin;
3299
4252
  /** Management module for API keys, webhooks, and invitations */
3300
4253
  management: FluxbaseManagement;
3301
4254
  /**
3302
4255
  * Create a new Fluxbase client instance
3303
- * @param options - Client configuration options
4256
+ *
4257
+ * @param fluxbaseUrl - The URL of your Fluxbase instance
4258
+ * @param fluxbaseKey - The anon key (JWT token with "anon" role). Generate using scripts/generate-keys.sh
4259
+ * @param options - Additional client configuration options
4260
+ *
4261
+ * @example
4262
+ * ```typescript
4263
+ * const client = new FluxbaseClient(
4264
+ * 'http://localhost:8080',
4265
+ * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', // Anon JWT token
4266
+ * { timeout: 30000 }
4267
+ * )
4268
+ * ```
3304
4269
  */
3305
- constructor(options: FluxbaseClientOptions);
4270
+ constructor(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions);
3306
4271
  /**
3307
4272
  * Create a query builder for a database table
3308
4273
  *
@@ -3376,6 +4341,34 @@ declare class FluxbaseClient {
3376
4341
  * @category Authentication
3377
4342
  */
3378
4343
  setAuthToken(token: string | null): void;
4344
+ /**
4345
+ * Create or get a realtime channel (Supabase-compatible alias)
4346
+ *
4347
+ * This is a convenience method that delegates to client.realtime.channel().
4348
+ * Both patterns work identically:
4349
+ * - client.channel('room-1') - Supabase-style
4350
+ * - client.realtime.channel('room-1') - Fluxbase-style
4351
+ *
4352
+ * @param name - Channel name
4353
+ * @returns RealtimeChannel instance
4354
+ *
4355
+ * @example
4356
+ * ```typescript
4357
+ * // Supabase-compatible usage
4358
+ * const channel = client.channel('room-1')
4359
+ * .on('postgres_changes', {
4360
+ * event: '*',
4361
+ * schema: 'public',
4362
+ * table: 'messages'
4363
+ * }, (payload) => {
4364
+ * console.log('Change:', payload)
4365
+ * })
4366
+ * .subscribe()
4367
+ * ```
4368
+ *
4369
+ * @category Realtime
4370
+ */
4371
+ channel(name: string): RealtimeChannel;
3379
4372
  /**
3380
4373
  * Get the internal HTTP client
3381
4374
  *
@@ -3394,31 +4387,41 @@ declare class FluxbaseClient {
3394
4387
  get http(): FluxbaseFetch;
3395
4388
  }
3396
4389
  /**
3397
- * Create a new Fluxbase client instance
4390
+ * Create a new Fluxbase client instance (Supabase-compatible)
3398
4391
  *
3399
- * This is the recommended way to initialize the Fluxbase SDK.
4392
+ * This function signature is identical to Supabase's createClient, making migration seamless.
3400
4393
  *
3401
- * @param options - Client configuration options
3402
- * @returns A configured Fluxbase client instance
4394
+ * @param fluxbaseUrl - The URL of your Fluxbase instance
4395
+ * @param fluxbaseKey - The anon key (JWT token with "anon" role). Generate using: `./scripts/generate-keys.sh` (option 3)
4396
+ * @param options - Optional client configuration
4397
+ * @returns A configured Fluxbase client instance with full TypeScript support
3403
4398
  *
3404
4399
  * @example
3405
4400
  * ```typescript
3406
4401
  * import { createClient } from '@fluxbase/sdk'
3407
4402
  *
3408
- * const client = createClient({
3409
- * url: 'http://localhost:8080',
3410
- * auth: {
3411
- * token: 'your-jwt-token',
3412
- * autoRefresh: true,
3413
- * persist: true
3414
- * },
3415
- * timeout: 30000,
3416
- * debug: false
3417
- * })
4403
+ * // Initialize with anon key (identical to Supabase)
4404
+ * const client = createClient(
4405
+ * 'http://localhost:8080',
4406
+ * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' // Anon JWT token
4407
+ * )
4408
+ *
4409
+ * // With additional options
4410
+ * const client = createClient(
4411
+ * 'http://localhost:8080',
4412
+ * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
4413
+ * { timeout: 30000, debug: true }
4414
+ * )
4415
+ *
4416
+ * // With TypeScript database types
4417
+ * const client = createClient<Database>(
4418
+ * 'http://localhost:8080',
4419
+ * 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
4420
+ * )
3418
4421
  * ```
3419
4422
  *
3420
4423
  * @category Client
3421
4424
  */
3422
- declare function createClient(options: FluxbaseClientOptions): FluxbaseClient;
4425
+ declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
3423
4426
 
3424
- 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 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 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 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 Schema, type SecuritySettings, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SystemSetting, SystemSettingsManager, type Table, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type ValidateInvitationResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
4427
+ export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };