@giaeulate/baas-sdk 1.1.1 → 1.2.0

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,892 @@
1
+ /**
2
+ * SDK Shared Types
3
+ */
4
+ /** HTTP method types */
5
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
6
+ /** Request options for the HTTP client */
7
+ interface RequestOptions {
8
+ method?: HttpMethod;
9
+ body?: unknown;
10
+ headers?: Record<string, string>;
11
+ skipAuth?: boolean;
12
+ }
13
+ /** Query filter for data operations */
14
+ type QueryFilter = {
15
+ column: string;
16
+ operator: string;
17
+ value: any;
18
+ };
19
+ /** Pagination options */
20
+ interface PaginationOptions {
21
+ limit?: number;
22
+ offset?: number;
23
+ }
24
+ /** Generic API response with error */
25
+ interface ApiResponse<T = any> {
26
+ data?: T;
27
+ error?: string;
28
+ success?: boolean;
29
+ }
30
+ /** Realtime Event types */
31
+ type RealtimeAction = 'INSERT' | 'UPDATE' | 'DELETE' | '*';
32
+ /** Structure of a Realtime event payload */
33
+ interface RealtimePayload<T = any> {
34
+ table: string;
35
+ action: 'insert' | 'update' | 'delete';
36
+ record: T;
37
+ old_record?: T;
38
+ timestamp: string;
39
+ }
40
+ /** Callback function for realtime subscriptions */
41
+ type RealtimeCallback<T = any> = (payload: RealtimePayload<T>) => void;
42
+
43
+ /**
44
+ * Core HTTP Client
45
+ * Base class providing HTTP request infrastructure for all SDK modules
46
+ */
47
+
48
+ declare class HttpClient {
49
+ url: string;
50
+ apiKey: string;
51
+ token: string | null;
52
+ private environment;
53
+ private _onForceLogout;
54
+ constructor(url?: string, apiKey?: string);
55
+ /**
56
+ * Set the auth token manually (e.g. restoring from SecureStore in React Native).
57
+ * Persists to both the in-memory property and localStorage so getDynamicToken() works.
58
+ */
59
+ setToken(token: string | null): void;
60
+ /**
61
+ * Register a callback invoked on forced logout (401).
62
+ * Use this in React Native instead of the default window.location redirect.
63
+ */
64
+ onForceLogout(callback: () => void): void;
65
+ protected cleanValue(val: string | null): string | null;
66
+ /**
67
+ * Public header generator for adapters
68
+ */
69
+ getHeaders(contentType?: string): Record<string, string>;
70
+ getDynamicToken(): string | null;
71
+ /**
72
+ * Core HTTP request method - DRY principle
73
+ */
74
+ protected request<T = any>(endpoint: string, options?: RequestOptions): Promise<T>;
75
+ protected get<T = any>(endpoint: string): Promise<T>;
76
+ protected post<T = any>(endpoint: string, body?: unknown): Promise<T>;
77
+ protected put<T = any>(endpoint: string, body?: unknown): Promise<T>;
78
+ protected patch<T = any>(endpoint: string, body?: unknown): Promise<T>;
79
+ protected delete<T = any>(endpoint: string): Promise<T>;
80
+ private getCSRFToken;
81
+ setEnvironment(env: string): void;
82
+ getEnvironment(): string;
83
+ logout(): void;
84
+ forceLogout(): void;
85
+ handleIPBlocked(ip?: string): void;
86
+ }
87
+
88
+ /**
89
+ * Environments Module - Test/Prod environment management
90
+ */
91
+
92
+ interface EnvironmentStatus {
93
+ test_exists: boolean;
94
+ test_status?: string;
95
+ test_created_at?: string;
96
+ test_schema_name?: string;
97
+ prod_schema_name: string;
98
+ table_count: number;
99
+ }
100
+ interface PromoteResult {
101
+ tables_promoted: number;
102
+ status: string;
103
+ }
104
+ interface EnvironmentsModule {
105
+ status(): Promise<EnvironmentStatus>;
106
+ init(): Promise<any>;
107
+ promote(): Promise<PromoteResult>;
108
+ revert(): Promise<any>;
109
+ setActive(env: 'test' | 'prod'): void;
110
+ getActive(): string;
111
+ }
112
+
113
+ /**
114
+ * QueryBuilder - Fluent API for data queries
115
+ */
116
+
117
+ declare class QueryBuilder {
118
+ private table;
119
+ private url;
120
+ private client;
121
+ private queryParams;
122
+ private filters;
123
+ constructor(table: string, url: string, client: HttpClient);
124
+ select(columns?: string): this;
125
+ eq(column: string, value: any): this;
126
+ neq(column: string, value: any): this;
127
+ gt(column: string, value: any): this;
128
+ gte(column: string, value: any): this;
129
+ lt(column: string, value: any): this;
130
+ lte(column: string, value: any): this;
131
+ like(column: string, value: any): this;
132
+ ilike(column: string, value: any): this;
133
+ is(column: string, value: any): this;
134
+ in(column: string, values: any[]): this;
135
+ not(column: string, operator: string, value: any): this;
136
+ or(filters: string): this;
137
+ order(column: string, { ascending }?: {
138
+ ascending?: boolean | undefined;
139
+ }): this;
140
+ limit(count: number): this;
141
+ offset(count: number): this;
142
+ get(): Promise<{
143
+ data: null;
144
+ error: any;
145
+ status: number;
146
+ } | {
147
+ data: any;
148
+ error: null;
149
+ status: number;
150
+ }>;
151
+ insert(data: any): Promise<{
152
+ data: null;
153
+ error: any;
154
+ status: number;
155
+ } | {
156
+ data: any;
157
+ error: null;
158
+ status: number;
159
+ }>;
160
+ update(id: string | number, data: any): Promise<{
161
+ data: null;
162
+ error: any;
163
+ status: number;
164
+ } | {
165
+ data: any;
166
+ error: null;
167
+ status: number;
168
+ }>;
169
+ delete(id: string | number): Promise<{
170
+ data: null;
171
+ error: any;
172
+ status: number;
173
+ } | {
174
+ data: any;
175
+ error: null;
176
+ status: number;
177
+ } | {
178
+ success: boolean;
179
+ }>;
180
+ private getHeaders;
181
+ private handleResponse;
182
+ }
183
+
184
+ /**
185
+ * Auth Module - Authentication operations
186
+ */
187
+
188
+ interface MFASetupResponse {
189
+ secret: string;
190
+ qr_code_url: string;
191
+ recovery_codes: string[];
192
+ }
193
+ interface AuthModule {
194
+ login(email: string, password: string): Promise<any>;
195
+ logout(): Promise<void>;
196
+ verifyMFA(mfaToken: string, code: string): Promise<any>;
197
+ verifyMFAWithRecoveryCode(mfaToken: string, recoveryCode: string): Promise<any>;
198
+ setupMFA(): Promise<MFASetupResponse>;
199
+ enableMFA(secret: string, code: string, recoveryCodes?: string[]): Promise<any>;
200
+ disableMFA(code: string): Promise<any>;
201
+ getProfile(): Promise<any>;
202
+ register(email: string, password: string): Promise<any>;
203
+ forgotPassword(email: string): Promise<any>;
204
+ resetPassword(token: string, newPassword: string): Promise<any>;
205
+ validateResetToken(token: string): Promise<any>;
206
+ verifyEmail(token: string): Promise<any>;
207
+ requestEmailVerification(): Promise<any>;
208
+ getAuthProviders(): Promise<any>;
209
+ getAuthProvider(provider: string): Promise<any>;
210
+ configureAuthProvider(provider: string, clientID: string, clientSecret: string, enabled: boolean): Promise<any>;
211
+ }
212
+
213
+ /**
214
+ * Users Module - User management operations
215
+ */
216
+
217
+ interface UsersModule {
218
+ list(limit?: number, offset?: number): Promise<any>;
219
+ update(id: string, updates: {
220
+ email?: string;
221
+ role?: string;
222
+ email_verified?: boolean;
223
+ }): Promise<any>;
224
+ delete(id: string): Promise<any>;
225
+ }
226
+
227
+ /**
228
+ * Database Module - Schema, table, and column operations
229
+ */
230
+
231
+ interface DatabaseModule {
232
+ getSchemas(options?: {
233
+ search?: string;
234
+ limit?: number;
235
+ offset?: number;
236
+ }): Promise<any>;
237
+ getSchema(name: string): Promise<any>;
238
+ saveSchemas(data: {
239
+ table_name: string;
240
+ definition: any;
241
+ }): Promise<any>;
242
+ createTable(tableName: string, definition: Record<string, string | {
243
+ type: string;
244
+ nullable?: boolean;
245
+ unique?: boolean;
246
+ default?: string;
247
+ }>): Promise<any>;
248
+ dropTable(tableName: string): Promise<any>;
249
+ renameTable(tableName: string, newName: string): Promise<any>;
250
+ addColumn(tableName: string, column: {
251
+ name: string;
252
+ type: string;
253
+ nullable?: boolean;
254
+ default_value?: string;
255
+ }): Promise<any>;
256
+ dropColumn(tableName: string, columnName: string): Promise<any>;
257
+ modifyColumn(tableName: string, columnName: string, changes: {
258
+ type: string;
259
+ nullable?: boolean;
260
+ }): Promise<any>;
261
+ renameColumn(tableName: string, columnName: string, newName: string): Promise<any>;
262
+ setColumnDefault(tableName: string, columnName: string, defaultValue: string | null): Promise<any>;
263
+ addForeignKey(tableName: string, fk: {
264
+ column: string;
265
+ ref_table: string;
266
+ ref_column: string;
267
+ on_delete?: string;
268
+ on_update?: string;
269
+ }): Promise<any>;
270
+ listForeignKeys(tableName: string): Promise<any>;
271
+ dropForeignKey(tableName: string, constraintName: string): Promise<any>;
272
+ addUniqueConstraint(tableName: string, columnName: string): Promise<any>;
273
+ dropConstraint(tableName: string, constraintName: string): Promise<any>;
274
+ raw(query: string): Promise<any>;
275
+ queryData(tableName: string, options: {
276
+ page?: number;
277
+ limit?: number;
278
+ filters?: any[];
279
+ }): Promise<any>;
280
+ downloadExport(tableName: string, format: 'sql' | 'csv' | 'backup', filters?: any[]): Promise<any>;
281
+ }
282
+
283
+ /**
284
+ * Storage Module - File & bucket operations (MinIO-backed)
285
+ *
286
+ * Files: upload, list, get (metadata + presigned URL), delete
287
+ * Buckets: create, list, get, delete, listFiles
288
+ */
289
+
290
+ interface StorageFile {
291
+ id: string;
292
+ bucket_id: string;
293
+ name: string;
294
+ mime_type: string;
295
+ size: number;
296
+ created_at: string;
297
+ }
298
+ interface StorageFileWithUrl {
299
+ metadata: StorageFile;
300
+ url: string;
301
+ }
302
+ interface StorageBucket {
303
+ id: string;
304
+ name: string;
305
+ is_public: boolean;
306
+ created_at: string;
307
+ }
308
+ interface StorageModule {
309
+ /** Upload a file. Optionally target a specific bucket by ID. */
310
+ upload(file: File, bucketId?: string): Promise<StorageFile>;
311
+ /** List all files across buckets. */
312
+ listFiles(): Promise<StorageFile[]>;
313
+ /** Get file metadata + a 15-min presigned download URL. */
314
+ getFile(fileId: string): Promise<StorageFileWithUrl>;
315
+ /** Delete a file by ID. */
316
+ deleteFile(fileId: string): Promise<void>;
317
+ /** Create a new bucket. */
318
+ createBucket(name: string, isPublic?: boolean): Promise<StorageBucket>;
319
+ /** List all buckets. */
320
+ listBuckets(): Promise<StorageBucket[]>;
321
+ /** Get bucket info by ID. */
322
+ getBucket(bucketId: string): Promise<StorageBucket>;
323
+ /** Delete an empty bucket. */
324
+ deleteBucket(bucketId: string): Promise<void>;
325
+ /** List files inside a specific bucket. */
326
+ listBucketFiles(bucketId: string): Promise<StorageFile[]>;
327
+ /** @deprecated Use upload(file, bucketId?) instead. */
328
+ upload(table: string, file: File): Promise<any>;
329
+ }
330
+
331
+ /**
332
+ * Backups Module - Database backup operations
333
+ */
334
+
335
+ interface BackupsModule {
336
+ create(options?: {
337
+ name?: string;
338
+ tables?: string[];
339
+ }): Promise<any>;
340
+ list(): Promise<any>;
341
+ get(backupId: string): Promise<any>;
342
+ restore(backupId: string): Promise<any>;
343
+ delete(backupId: string): Promise<any>;
344
+ getDownloadUrl(backupId: string): string;
345
+ listTables(): Promise<any>;
346
+ importFile(formData: FormData): Promise<any>;
347
+ }
348
+
349
+ /**
350
+ * Migrations Module - Database migration operations
351
+ */
352
+
353
+ interface MigrationsModule {
354
+ create(input: {
355
+ name: string;
356
+ description?: string;
357
+ up_sql: string;
358
+ down_sql?: string;
359
+ }): Promise<any>;
360
+ list(): Promise<any>;
361
+ get(id: string): Promise<any>;
362
+ apply(id: string): Promise<any>;
363
+ rollback(id: string): Promise<any>;
364
+ delete(id: string): Promise<any>;
365
+ generate(tableName: string, changes: any[]): Promise<any>;
366
+ }
367
+
368
+ /**
369
+ * Functions Module - Edge function operations
370
+ */
371
+
372
+ interface FunctionsModule {
373
+ invoke(id: string, data?: any): Promise<any>;
374
+ get(id: string): Promise<any>;
375
+ list(): Promise<any>;
376
+ create(name: string, code: string, options?: {
377
+ runtime?: 'wazero' | 'deno';
378
+ timeout_ms?: number;
379
+ }): Promise<any>;
380
+ delete(id: string): Promise<any>;
381
+ update(id: string, code: string, options?: {
382
+ runtime?: 'wazero' | 'deno';
383
+ timeout_ms?: number;
384
+ }): Promise<any>;
385
+ executeCode(code: string, options?: {
386
+ data?: any;
387
+ runtime?: 'wazero' | 'deno';
388
+ timeout_ms?: number;
389
+ }): Promise<any>;
390
+ listHooks(): Promise<any>;
391
+ createHook(data: {
392
+ event_type: string;
393
+ function_id: string;
394
+ table_name?: string;
395
+ config?: any;
396
+ }): Promise<any>;
397
+ deleteHook(id: string): Promise<any>;
398
+ }
399
+
400
+ /**
401
+ * Jobs Module - Scheduled jobs (CRON) operations
402
+ */
403
+
404
+ interface JobInput {
405
+ name: string;
406
+ schedule: string;
407
+ function_id: string;
408
+ description?: string;
409
+ payload?: Record<string, any>;
410
+ timezone?: string;
411
+ }
412
+ interface JobUpdateInput {
413
+ name?: string;
414
+ schedule?: string;
415
+ function_id?: string;
416
+ description?: string;
417
+ payload?: Record<string, any>;
418
+ timezone?: string;
419
+ enabled?: boolean;
420
+ }
421
+ interface JobsModule {
422
+ create(input: JobInput): Promise<any>;
423
+ list(): Promise<any>;
424
+ get(id: string): Promise<any>;
425
+ update(id: string, input: JobUpdateInput): Promise<any>;
426
+ delete(id: string): Promise<any>;
427
+ toggle(id: string, enabled: boolean): Promise<any>;
428
+ runNow(id: string): Promise<any>;
429
+ getExecutions(id: string, limit?: number): Promise<any>;
430
+ }
431
+
432
+ /**
433
+ * Environment Variables Module
434
+ */
435
+
436
+ interface EnvVarsModule {
437
+ create(input: {
438
+ key: string;
439
+ value: string;
440
+ is_secret?: boolean;
441
+ }): Promise<any>;
442
+ list(): Promise<any>;
443
+ get(id: string): Promise<any>;
444
+ update(id: string, value: string): Promise<any>;
445
+ delete(id: string): Promise<any>;
446
+ }
447
+
448
+ /**
449
+ * Email Module - Email service operations
450
+ */
451
+
452
+ interface EmailConfig {
453
+ provider: string;
454
+ smtp_host?: string;
455
+ smtp_port?: number;
456
+ smtp_user?: string;
457
+ smtp_password?: string;
458
+ sendgrid_api_key?: string;
459
+ resend_api_key?: string;
460
+ from_email: string;
461
+ from_name?: string;
462
+ }
463
+ interface EmailTemplate {
464
+ name: string;
465
+ subject: string;
466
+ text_body?: string;
467
+ html_body?: string;
468
+ }
469
+ interface SendEmailInput {
470
+ to: string[];
471
+ subject: string;
472
+ text_body?: string;
473
+ html_body?: string;
474
+ template_id?: string;
475
+ template_data?: Record<string, any>;
476
+ }
477
+ interface EmailModule {
478
+ send(input: SendEmailInput): Promise<any>;
479
+ getConfig(): Promise<any>;
480
+ saveConfig(config: EmailConfig): Promise<any>;
481
+ createTemplate(template: EmailTemplate): Promise<any>;
482
+ listTemplates(): Promise<any>;
483
+ getTemplate(id: string): Promise<any>;
484
+ updateTemplate(id: string, template: Partial<EmailTemplate>): Promise<any>;
485
+ deleteTemplate(id: string): Promise<any>;
486
+ getLogs(options?: {
487
+ limit?: number;
488
+ offset?: number;
489
+ }): Promise<any>;
490
+ }
491
+
492
+ /**
493
+ * Search Module - Full-text search operations
494
+ */
495
+
496
+ interface SearchOptions {
497
+ tables?: string[];
498
+ columns?: string[];
499
+ limit?: number;
500
+ offset?: number;
501
+ }
502
+ interface SearchModule {
503
+ search(query: string, options?: SearchOptions): Promise<any>;
504
+ createIndex(table: string, columns: string[]): Promise<any>;
505
+ }
506
+
507
+ /**
508
+ * GraphQL Module
509
+ */
510
+
511
+ interface GraphQLModule {
512
+ query(query: string, variables?: Record<string, any>): Promise<any>;
513
+ getSchema(): Promise<any>;
514
+ getPlaygroundUrl(): string;
515
+ }
516
+
517
+ /**
518
+ * Metrics Module - Monitoring and metrics operations
519
+ */
520
+
521
+ interface RequestLogsOptions {
522
+ limit?: number;
523
+ offset?: number;
524
+ method?: string;
525
+ status?: string;
526
+ path?: string;
527
+ }
528
+ interface ApplicationLogsOptions {
529
+ limit?: number;
530
+ offset?: number;
531
+ level?: string;
532
+ source?: string;
533
+ search?: string;
534
+ }
535
+ interface TimeseriesOptions {
536
+ interval?: string;
537
+ start?: string;
538
+ end?: string;
539
+ }
540
+ interface MetricsModule {
541
+ getDashboardStats(): Promise<any>;
542
+ getRequestLogs(options?: RequestLogsOptions): Promise<any>;
543
+ getApplicationLogs(options?: ApplicationLogsOptions): Promise<any>;
544
+ getTimeseries(metric: string, options?: TimeseriesOptions): Promise<any>;
545
+ }
546
+
547
+ /**
548
+ * Audit Module - Audit log operations
549
+ */
550
+
551
+ interface AuditLogsOptions {
552
+ limit?: number;
553
+ offset?: number;
554
+ action?: string;
555
+ user_id?: string;
556
+ method?: string;
557
+ path?: string;
558
+ status_code?: number;
559
+ start_date?: string;
560
+ end_date?: string;
561
+ }
562
+ interface AuditModule {
563
+ list(options?: AuditLogsOptions): Promise<any>;
564
+ getActions(): Promise<any>;
565
+ }
566
+
567
+ /**
568
+ * Webhooks Module
569
+ */
570
+
571
+ interface WebhookInput {
572
+ url: string;
573
+ event_types: string[];
574
+ }
575
+ interface WebhookUpdateInput {
576
+ url: string;
577
+ event_types: string[];
578
+ is_active: boolean;
579
+ }
580
+ interface WebhooksModule {
581
+ list(): Promise<any>;
582
+ get(id: string): Promise<any>;
583
+ create(input: WebhookInput): Promise<any>;
584
+ update(id: string, input: WebhookUpdateInput): Promise<any>;
585
+ delete(id: string): Promise<any>;
586
+ test(id: string): Promise<any>;
587
+ }
588
+
589
+ /**
590
+ * Log Drains Module
591
+ */
592
+
593
+ interface LogDrainInput {
594
+ name: string;
595
+ type: string;
596
+ url: string;
597
+ token?: string;
598
+ headers?: Record<string, string>;
599
+ filters?: {
600
+ levels?: string[];
601
+ sources?: string[];
602
+ };
603
+ }
604
+ interface LogDrainUpdateInput {
605
+ name?: string;
606
+ url?: string;
607
+ token?: string;
608
+ headers?: Record<string, string>;
609
+ filters?: {
610
+ levels?: string[];
611
+ sources?: string[];
612
+ };
613
+ enabled?: boolean;
614
+ }
615
+ interface LogDrainsModule {
616
+ create(input: LogDrainInput): Promise<any>;
617
+ list(): Promise<any>;
618
+ get(id: string): Promise<any>;
619
+ update(id: string, input: LogDrainUpdateInput): Promise<any>;
620
+ delete(id: string): Promise<any>;
621
+ toggle(id: string, enabled: boolean): Promise<any>;
622
+ test(id: string): Promise<any>;
623
+ }
624
+
625
+ /**
626
+ * Branches Module - Database branches operations
627
+ */
628
+
629
+ interface BranchesModule {
630
+ create(input: {
631
+ name: string;
632
+ source_branch?: string;
633
+ }): Promise<any>;
634
+ list(): Promise<any>;
635
+ get(id: string): Promise<any>;
636
+ delete(id: string): Promise<any>;
637
+ merge(id: string, targetBranchId: string): Promise<any>;
638
+ reset(id: string): Promise<any>;
639
+ }
640
+
641
+ /**
642
+ * Realtime Module - WebSocket subscriptions
643
+ */
644
+
645
+ interface Subscription {
646
+ unsubscribe: () => void;
647
+ }
648
+ interface RealtimeModule {
649
+ subscribe<T = any>(table: string, action: RealtimeAction, callback: RealtimeCallback<T>): Promise<Subscription>;
650
+ }
651
+
652
+ /**
653
+ * API Keys Module
654
+ */
655
+
656
+ interface ApiKeysModule {
657
+ create(name: string, permissions?: string[], expiresAt?: string): Promise<any>;
658
+ list(): Promise<any>;
659
+ revoke(keyId: string): Promise<any>;
660
+ delete(keyId: string): Promise<any>;
661
+ getInstanceToken(): Promise<any>;
662
+ regenerateInstanceToken(): Promise<any>;
663
+ }
664
+
665
+ /**
666
+ * CORS Origins Module
667
+ */
668
+
669
+ interface CorsOriginsModule {
670
+ list(): Promise<any>;
671
+ create(origin: string, description?: string): Promise<any>;
672
+ delete(id: string): Promise<any>;
673
+ }
674
+
675
+ /**
676
+ * Policies Module - Row-Level Security policy management
677
+ */
678
+
679
+ interface Policy {
680
+ id: string;
681
+ table_name: string;
682
+ action: 'select' | 'insert' | 'update' | 'delete';
683
+ role: string;
684
+ condition: string;
685
+ created_at?: string;
686
+ }
687
+ interface CreatePolicyInput {
688
+ table_name: string;
689
+ action: 'select' | 'insert' | 'update' | 'delete';
690
+ role: string;
691
+ condition: string;
692
+ }
693
+ interface PoliciesModule {
694
+ create(input: CreatePolicyInput): Promise<Policy>;
695
+ list(): Promise<Policy[]>;
696
+ delete(id: string): Promise<any>;
697
+ }
698
+
699
+ /**
700
+ * IP Whitelist Module - IP-based access control
701
+ */
702
+
703
+ interface IPWhitelistEntry {
704
+ id: string;
705
+ ip_address: string;
706
+ description: string;
707
+ created_at?: string;
708
+ }
709
+ interface IPWhitelistModule {
710
+ list(): Promise<IPWhitelistEntry[]>;
711
+ create(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
712
+ delete(id: string): Promise<any>;
713
+ }
714
+
715
+ /**
716
+ * Main BaaS Client - Composes all feature modules
717
+ *
718
+ * Usage:
719
+ * ```ts
720
+ * const client = new BaasClient();
721
+ *
722
+ * // Authentication
723
+ * await client.auth.login('user@example.com', 'password');
724
+ *
725
+ * // Database operations
726
+ * const schemas = await client.database.getSchemas();
727
+ *
728
+ * // Query builder (fluent API)
729
+ * const users = await client.from('users').select('*').limit(10).get();
730
+ * ```
731
+ */
732
+ declare class BaasClient extends HttpClient {
733
+ readonly auth: AuthModule;
734
+ readonly users: UsersModule;
735
+ readonly database: DatabaseModule;
736
+ readonly storage: StorageModule;
737
+ readonly backups: BackupsModule;
738
+ readonly migrations: MigrationsModule;
739
+ readonly functions: FunctionsModule;
740
+ readonly jobs: JobsModule;
741
+ readonly envVars: EnvVarsModule;
742
+ readonly email: EmailModule;
743
+ readonly searchService: SearchModule;
744
+ readonly graphqlService: GraphQLModule;
745
+ readonly metrics: MetricsModule;
746
+ readonly audit: AuditModule;
747
+ readonly webhooks: WebhooksModule;
748
+ readonly logDrains: LogDrainsModule;
749
+ readonly branches: BranchesModule;
750
+ readonly realtime: RealtimeModule;
751
+ readonly apiKeys: ApiKeysModule;
752
+ readonly environments: EnvironmentsModule;
753
+ readonly corsOrigins: CorsOriginsModule;
754
+ readonly policies: PoliciesModule;
755
+ readonly ipWhitelist: IPWhitelistModule;
756
+ constructor(url?: string, apiKey?: string);
757
+ /**
758
+ * Create a query builder for fluent data queries
759
+ */
760
+ from(table: string): QueryBuilder;
761
+ login(email: string, password: string): Promise<any>;
762
+ verifyMFA(mfaToken: string, code: string): Promise<any>;
763
+ getProfile(): Promise<any>;
764
+ register(email: string, password: string): Promise<any>;
765
+ forgotPassword(email: string): Promise<any>;
766
+ resetPassword(token: string, newPassword: string): Promise<any>;
767
+ validateResetToken(token: string): Promise<any>;
768
+ verifyEmail(token: string): Promise<any>;
769
+ requestEmailVerification(): Promise<any>;
770
+ getAuthProviders(): Promise<any>;
771
+ getAuthProvider(provider: string): Promise<any>;
772
+ configureAuthProvider(provider: string, clientID: string, clientSecret: string, enabled: boolean): Promise<any>;
773
+ listUsers(limit?: number, offset?: number): Promise<any>;
774
+ updateUser(id: string, updates: any): Promise<any>;
775
+ deleteUser(id: string): Promise<any>;
776
+ raw(query: string): Promise<any>;
777
+ getSchemas(options?: any): Promise<any>;
778
+ getSchema(name: string): Promise<any>;
779
+ createTable(tableName: string, definition: any): Promise<any>;
780
+ dropTable(tableName: string): Promise<any>;
781
+ renameTable(tableName: string, newName: string): Promise<any>;
782
+ addColumn(tableName: string, column: any): Promise<any>;
783
+ dropColumn(tableName: string, columnName: string): Promise<any>;
784
+ modifyColumn(tableName: string, columnName: string, changes: any): Promise<any>;
785
+ renameColumn(tableName: string, columnName: string, newName: string): Promise<any>;
786
+ setColumnDefault(tableName: string, columnName: string, defaultValue: string | null): Promise<any>;
787
+ addForeignKey(tableName: string, fk: any): Promise<any>;
788
+ listForeignKeys(tableName: string): Promise<any>;
789
+ dropForeignKey(tableName: string, constraintName: string): Promise<any>;
790
+ addUniqueConstraint(tableName: string, columnName: string): Promise<any>;
791
+ dropConstraint(tableName: string, constraintName: string): Promise<any>;
792
+ queryData(tableName: string, options: any): Promise<any>;
793
+ downloadExport(tableName: string, format: 'sql' | 'csv' | 'backup', filters?: any[]): Promise<any>;
794
+ upload(file: File, bucketId?: string): Promise<StorageFile>;
795
+ listStorageFiles(): Promise<StorageFile[]>;
796
+ getStorageFile(fileId: string): Promise<StorageFileWithUrl>;
797
+ deleteStorageFile(fileId: string): Promise<void>;
798
+ createStorageBucket(name: string, isPublic?: boolean): Promise<StorageBucket>;
799
+ listStorageBuckets(): Promise<StorageBucket[]>;
800
+ getStorageBucket(bucketId: string): Promise<StorageBucket>;
801
+ deleteStorageBucket(bucketId: string): Promise<void>;
802
+ listStorageBucketFiles(bucketId: string): Promise<StorageFile[]>;
803
+ invokeFunction(id: string, data?: any): Promise<any>;
804
+ createApiKey(name: string, permissions?: string[], expiresAt?: string): Promise<any>;
805
+ listApiKeys(): Promise<any>;
806
+ revokeApiKey(keyId: string): Promise<any>;
807
+ deleteApiKey(keyId: string): Promise<any>;
808
+ getInstanceToken(): Promise<any>;
809
+ regenerateInstanceToken(): Promise<any>;
810
+ createBackup(options?: any): Promise<any>;
811
+ listBackups(): Promise<any>;
812
+ getBackup(backupId: string): Promise<any>;
813
+ restoreBackup(backupId: string): Promise<any>;
814
+ deleteBackup(backupId: string): Promise<any>;
815
+ getBackupDownloadUrl(backupId: string): string;
816
+ listBackupTables(): Promise<any>;
817
+ importFile(formData: FormData): Promise<any>;
818
+ search(query: string, options?: any): Promise<any>;
819
+ createSearchIndex(table: string, columns: string[]): Promise<any>;
820
+ graphql(query: string, variables?: Record<string, any>): Promise<any>;
821
+ getGraphQLPlaygroundUrl(): string;
822
+ createMigration(input: any): Promise<any>;
823
+ listMigrations(): Promise<any>;
824
+ getMigration(id: string): Promise<any>;
825
+ applyMigration(id: string): Promise<any>;
826
+ rollbackMigration(id: string): Promise<any>;
827
+ deleteMigration(id: string): Promise<any>;
828
+ generateMigration(tableName: string, changes: any[]): Promise<any>;
829
+ sendEmail(input: any): Promise<any>;
830
+ getEmailConfig(): Promise<any>;
831
+ saveEmailConfig(config: any): Promise<any>;
832
+ createEmailTemplate(template: any): Promise<any>;
833
+ listEmailTemplates(): Promise<any>;
834
+ getEmailTemplate(id: string): Promise<any>;
835
+ updateEmailTemplate(id: string, template: any): Promise<any>;
836
+ deleteEmailTemplate(id: string): Promise<any>;
837
+ getEmailLogs(options?: any): Promise<any>;
838
+ getDashboardStats(): Promise<any>;
839
+ getRequestLogs(options?: any): Promise<any>;
840
+ getApplicationLogs(options?: any): Promise<any>;
841
+ getMetricTimeseries(metric: string, options?: any): Promise<any>;
842
+ createJob(input: any): Promise<any>;
843
+ listJobs(): Promise<any>;
844
+ getJob(id: string): Promise<any>;
845
+ updateJob(id: string, input: any): Promise<any>;
846
+ deleteJob(id: string): Promise<any>;
847
+ toggleJob(id: string, enabled: boolean): Promise<any>;
848
+ runJobNow(id: string): Promise<any>;
849
+ getJobExecutions(id: string, limit?: number): Promise<any>;
850
+ createEnvVar(input: any): Promise<any>;
851
+ listEnvVars(): Promise<any>;
852
+ getEnvVar(id: string): Promise<any>;
853
+ updateEnvVar(id: string, value: string): Promise<any>;
854
+ deleteEnvVar(id: string): Promise<any>;
855
+ createBranch(input: any): Promise<any>;
856
+ listBranches(): Promise<any>;
857
+ getBranch(id: string): Promise<any>;
858
+ deleteBranch(id: string): Promise<any>;
859
+ mergeBranch(id: string, targetBranchId: string): Promise<any>;
860
+ resetBranch(id: string): Promise<any>;
861
+ createLogDrain(input: any): Promise<any>;
862
+ listLogDrains(): Promise<any>;
863
+ getLogDrain(id: string): Promise<any>;
864
+ updateLogDrain(id: string, input: any): Promise<any>;
865
+ deleteLogDrain(id: string): Promise<any>;
866
+ toggleLogDrain(id: string, enabled: boolean): Promise<any>;
867
+ testLogDrain(id: string): Promise<any>;
868
+ listWebhooks(): Promise<any>;
869
+ getWebhook(id: string): Promise<any>;
870
+ createWebhook(input: any): Promise<any>;
871
+ updateWebhook(id: string, input: any): Promise<any>;
872
+ deleteWebhook(id: string): Promise<any>;
873
+ testWebhook(id: string): Promise<any>;
874
+ listAuditLogs(options?: any): Promise<any>;
875
+ getAuditActions(): Promise<any>;
876
+ subscribe<T = any>(table: string, action: RealtimeAction, callback: RealtimeCallback<T>): Promise<Subscription>;
877
+ getEnvironmentStatus(): Promise<EnvironmentStatus>;
878
+ initTestEnvironment(): Promise<any>;
879
+ promoteTestToProd(): Promise<PromoteResult>;
880
+ revertTestEnvironment(): Promise<any>;
881
+ listCorsOrigins(): Promise<any>;
882
+ addCorsOrigin(origin: string, description?: string): Promise<any>;
883
+ deleteCorsOrigin(id: string): Promise<any>;
884
+ listPolicies(): Promise<Policy[]>;
885
+ createPolicy(input: any): Promise<Policy>;
886
+ deletePolicy(id: string): Promise<any>;
887
+ listIPWhitelist(): Promise<IPWhitelistEntry[]>;
888
+ addIPWhitelistEntry(ipAddress: string, description?: string): Promise<IPWhitelistEntry>;
889
+ deleteIPWhitelistEntry(id: string): Promise<any>;
890
+ }
891
+
892
+ export { type ApiKeysModule, type ApiResponse, type ApplicationLogsOptions, type AuditLogsOptions, type AuditModule, type AuthModule, BaasClient, type BackupsModule, type BranchesModule, type CorsOriginsModule, type CreatePolicyInput, type DatabaseModule, type EmailConfig, type EmailModule, type EmailTemplate, type EnvVarsModule, type EnvironmentsModule, type FunctionsModule, type GraphQLModule, HttpClient, type HttpMethod, type IPWhitelistEntry, type IPWhitelistModule, type JobInput, type JobUpdateInput, type JobsModule, type LogDrainInput, type LogDrainUpdateInput, type LogDrainsModule, type MetricsModule, type MigrationsModule, type PaginationOptions, type PoliciesModule, type Policy, QueryBuilder, type QueryFilter, type RealtimeModule, type RequestLogsOptions, type RequestOptions, type SearchModule, type SearchOptions, type SendEmailInput, type StorageBucket, type StorageFile, type StorageFileWithUrl, type StorageModule, type Subscription, type TimeseriesOptions, type UsersModule, type WebhookInput, type WebhookUpdateInput, type WebhooksModule };