@tspvivek/baasix-sdk 0.1.0-alpha.1

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +942 -0
  3. package/dist/client-CzF9B60b.d.ts +614 -0
  4. package/dist/client-aXK_gEyr.d.cts +614 -0
  5. package/dist/index.cjs +4159 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.cts +1498 -0
  8. package/dist/index.d.ts +1498 -0
  9. package/dist/index.js +4135 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/modules/auth.cjs +651 -0
  12. package/dist/modules/auth.cjs.map +1 -0
  13. package/dist/modules/auth.d.cts +384 -0
  14. package/dist/modules/auth.d.ts +384 -0
  15. package/dist/modules/auth.js +649 -0
  16. package/dist/modules/auth.js.map +1 -0
  17. package/dist/modules/files.cjs +266 -0
  18. package/dist/modules/files.cjs.map +1 -0
  19. package/dist/modules/files.d.cts +187 -0
  20. package/dist/modules/files.d.ts +187 -0
  21. package/dist/modules/files.js +264 -0
  22. package/dist/modules/files.js.map +1 -0
  23. package/dist/modules/items.cjs +654 -0
  24. package/dist/modules/items.cjs.map +1 -0
  25. package/dist/modules/items.d.cts +472 -0
  26. package/dist/modules/items.d.ts +472 -0
  27. package/dist/modules/items.js +651 -0
  28. package/dist/modules/items.js.map +1 -0
  29. package/dist/modules/schemas.cjs +269 -0
  30. package/dist/modules/schemas.cjs.map +1 -0
  31. package/dist/modules/schemas.d.cts +239 -0
  32. package/dist/modules/schemas.d.ts +239 -0
  33. package/dist/modules/schemas.js +267 -0
  34. package/dist/modules/schemas.js.map +1 -0
  35. package/dist/storage/index.cjs +162 -0
  36. package/dist/storage/index.cjs.map +1 -0
  37. package/dist/storage/index.d.cts +96 -0
  38. package/dist/storage/index.d.ts +96 -0
  39. package/dist/storage/index.js +157 -0
  40. package/dist/storage/index.js.map +1 -0
  41. package/dist/types-BdjsGANq.d.cts +40 -0
  42. package/dist/types-BdjsGANq.d.ts +40 -0
  43. package/package.json +107 -0
@@ -0,0 +1,1498 @@
1
+ import { H as HttpClient, e as PaginatedResponse, N as Notification, o as SendNotificationData, p as Permission, C as CreatePermissionData, q as Role$1, r as Settings, s as ReportConfig, t as ReportResult, u as Aggregate, F as Filter, W as Workflow, v as WorkflowExecution, B as BaseItem, w as BaasixConfig, A as AuthMode } from './client-CzF9B60b.js';
2
+ export { V as AggregateConfig, O as AggregateFunction, k as AssetTransformOptions, b as AuthResponse, d as AuthState, a as AuthStateEvent, c as AuthTokens, a3 as BaasixError, a2 as BaasixErrorDetails, f as BulkResponse, a5 as CollectionItem, a4 as DeepPartial, D as DeleteResponse, Y as FieldDefinition, X as FieldType, j as FileMetadata, G as FilterCondition, z as FilterOperator, E as FilterValue, y as HttpClientConfig, I as IndexDefinition, J as LogicalFilter, L as LoginCredentials, M as MagicLinkOptions, g as MutationResponse, P as PasswordResetOptions, _ as PermissionAction, Q as QueryParams, R as RegisterData, n as RelationshipDefinition, Z as RelationshipType, x as RequestOptions, m as SchemaDefinition, l as SchemaInfo, h as SingleResponse, S as Sort, K as SortDirection, T as Tenant, i as UploadOptions, U as User, a1 as WorkflowEdge, a0 as WorkflowNode, $ as WorkflowTrigger } from './client-CzF9B60b.js';
3
+ import { S as StorageAdapter } from './types-BdjsGANq.js';
4
+ export { a as STORAGE_KEYS, b as StorageKey } from './types-BdjsGANq.js';
5
+ import { AuthModule } from './modules/auth.js';
6
+ export { InviteOptions, OAuthOptions, OAuthProvider, VerifyInviteResult } from './modules/auth.js';
7
+ import { ItemsModule } from './modules/items.js';
8
+ export { ImportResult, QueryBuilder } from './modules/items.js';
9
+ import { FilesModule } from './modules/files.js';
10
+ import { SchemasModule } from './modules/schemas.js';
11
+ export { AsyncStorageAdapter, LocalStorageAdapter, MemoryStorageAdapter } from './storage/index.js';
12
+
13
+ interface NotificationsModuleConfig {
14
+ client: HttpClient;
15
+ }
16
+ /**
17
+ * Notifications module for managing user notifications.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Get user notifications
22
+ * const { data } = await baasix.notifications.find();
23
+ *
24
+ * // Mark as seen
25
+ * await baasix.notifications.markAsSeen('notification-id');
26
+ *
27
+ * // Send notification (admin)
28
+ * await baasix.notifications.send({
29
+ * title: 'New Message',
30
+ * message: 'You have a new message',
31
+ * userIds: ['user-uuid']
32
+ * });
33
+ * ```
34
+ */
35
+ declare class NotificationsModule {
36
+ private client;
37
+ constructor(config: NotificationsModuleConfig);
38
+ /**
39
+ * List notifications for the current user
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const { data } = await baasix.notifications.find({
44
+ * limit: 20,
45
+ * filter: { seen: { eq: false } }
46
+ * });
47
+ * ```
48
+ */
49
+ find(params?: {
50
+ limit?: number;
51
+ page?: number;
52
+ seen?: boolean;
53
+ }): Promise<PaginatedResponse<Notification>>;
54
+ /**
55
+ * Get a single notification by ID
56
+ */
57
+ findOne(id: string): Promise<Notification>;
58
+ /**
59
+ * Mark a notification as seen
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * await baasix.notifications.markAsSeen('notification-uuid');
64
+ * ```
65
+ */
66
+ markAsSeen(id: string): Promise<void>;
67
+ /**
68
+ * Mark multiple notifications as seen
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * await baasix.notifications.markManySeen(['id1', 'id2', 'id3']);
73
+ * ```
74
+ */
75
+ markManySeen(ids: string[]): Promise<void>;
76
+ /**
77
+ * Mark all notifications as seen
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * await baasix.notifications.markAllSeen();
82
+ * ```
83
+ */
84
+ markAllSeen(): Promise<void>;
85
+ /**
86
+ * Get unread notification count
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const count = await baasix.notifications.getUnreadCount();
91
+ * ```
92
+ */
93
+ getUnreadCount(): Promise<number>;
94
+ /**
95
+ * Delete a notification
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * await baasix.notifications.delete('notification-uuid');
100
+ * ```
101
+ */
102
+ delete(id: string): Promise<void>;
103
+ /**
104
+ * Send a notification to users (requires admin permissions)
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * await baasix.notifications.send({
109
+ * type: 'alert',
110
+ * title: 'System Update',
111
+ * message: 'The system will be down for maintenance',
112
+ * data: { link: '/updates' },
113
+ * userIds: ['user1-uuid', 'user2-uuid']
114
+ * });
115
+ * ```
116
+ */
117
+ send(data: SendNotificationData): Promise<void>;
118
+ }
119
+
120
+ interface PermissionsModuleConfig {
121
+ client: HttpClient;
122
+ }
123
+ /**
124
+ * Permissions module for managing role-based access control.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Create a permission
129
+ * await baasix.permissions.create({
130
+ * role_Id: 'role-uuid',
131
+ * collection: 'products',
132
+ * action: 'read',
133
+ * fields: ['*'],
134
+ * conditions: { published: { eq: true } }
135
+ * });
136
+ *
137
+ * // Get permissions for a role
138
+ * const { data } = await baasix.permissions.findByRole('role-uuid');
139
+ * ```
140
+ */
141
+ declare class PermissionsModule {
142
+ private client;
143
+ constructor(config: PermissionsModuleConfig);
144
+ /**
145
+ * List all permissions
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const { data } = await baasix.permissions.find();
150
+ * ```
151
+ */
152
+ find(params?: {
153
+ limit?: number;
154
+ page?: number;
155
+ filter?: Record<string, unknown>;
156
+ }): Promise<PaginatedResponse<Permission>>;
157
+ /**
158
+ * Get a permission by ID
159
+ */
160
+ findOne(id: string): Promise<Permission>;
161
+ /**
162
+ * Get permissions for a specific role
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const { data } = await baasix.permissions.findByRole('role-uuid');
167
+ * ```
168
+ */
169
+ findByRole(roleId: string): Promise<PaginatedResponse<Permission>>;
170
+ /**
171
+ * Get permissions for a specific collection
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const { data } = await baasix.permissions.findByCollection('products');
176
+ * ```
177
+ */
178
+ findByCollection(collection: string): Promise<PaginatedResponse<Permission>>;
179
+ /**
180
+ * Create a new permission
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * await baasix.permissions.create({
185
+ * role_Id: 'editor-role-uuid',
186
+ * collection: 'posts',
187
+ * action: 'update',
188
+ * fields: ['title', 'content', 'status'],
189
+ * conditions: {
190
+ * author_Id: { eq: '$CURRENT_USER' }
191
+ * }
192
+ * });
193
+ * ```
194
+ */
195
+ create(data: CreatePermissionData): Promise<Permission>;
196
+ /**
197
+ * Update a permission
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * await baasix.permissions.update('permission-uuid', {
202
+ * fields: ['*'],
203
+ * conditions: null
204
+ * });
205
+ * ```
206
+ */
207
+ update(id: string, data: Partial<CreatePermissionData>): Promise<Permission>;
208
+ /**
209
+ * Delete a permission
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * await baasix.permissions.delete('permission-uuid');
214
+ * ```
215
+ */
216
+ delete(id: string): Promise<void>;
217
+ /**
218
+ * List all roles
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * const { data } = await baasix.permissions.getRoles();
223
+ * ```
224
+ */
225
+ getRoles(): Promise<PaginatedResponse<Role$1>>;
226
+ /**
227
+ * Create CRUD permissions for a collection
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * await baasix.permissions.createCrudPermissions('role-uuid', 'products', {
232
+ * create: { fields: ['name', 'price', 'description'] },
233
+ * read: { fields: ['*'] },
234
+ * update: { fields: ['name', 'price', 'description'] },
235
+ * delete: false
236
+ * });
237
+ * ```
238
+ */
239
+ createCrudPermissions(roleId: string, collection: string, config: {
240
+ create?: {
241
+ fields?: string[];
242
+ conditions?: Permission["conditions"];
243
+ } | false;
244
+ read?: {
245
+ fields?: string[];
246
+ conditions?: Permission["conditions"];
247
+ } | false;
248
+ update?: {
249
+ fields?: string[];
250
+ conditions?: Permission["conditions"];
251
+ } | false;
252
+ delete?: {
253
+ conditions?: Permission["conditions"];
254
+ } | false;
255
+ }): Promise<Permission[]>;
256
+ /**
257
+ * Reload permissions cache (admin only)
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * await baasix.permissions.reloadCache();
262
+ * ```
263
+ */
264
+ reloadCache(): Promise<void>;
265
+ }
266
+
267
+ interface SettingsModuleConfig {
268
+ client: HttpClient;
269
+ }
270
+ /**
271
+ * Settings module for managing application settings.
272
+ *
273
+ * @example
274
+ * ```typescript
275
+ * // Get all settings
276
+ * const settings = await baasix.settings.get();
277
+ *
278
+ * // Update settings
279
+ * await baasix.settings.update({
280
+ * appName: 'My App',
281
+ * theme: 'dark'
282
+ * });
283
+ * ```
284
+ */
285
+ declare class SettingsModule {
286
+ private client;
287
+ constructor(config: SettingsModuleConfig);
288
+ /**
289
+ * Get all settings
290
+ *
291
+ * @example
292
+ * ```typescript
293
+ * const settings = await baasix.settings.get();
294
+ * console.log(settings.appName);
295
+ * ```
296
+ */
297
+ get(): Promise<Settings>;
298
+ /**
299
+ * Get a specific setting by key
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const appName = await baasix.settings.getKey('appName');
304
+ * ```
305
+ */
306
+ getKey<T = unknown>(key: string): Promise<T | null>;
307
+ /**
308
+ * Update settings
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * await baasix.settings.update({
313
+ * appName: 'Updated App Name',
314
+ * logo: 'file-uuid',
315
+ * customConfig: {
316
+ * feature1: true,
317
+ * feature2: false
318
+ * }
319
+ * });
320
+ * ```
321
+ */
322
+ update(settings: Partial<Settings>): Promise<Settings>;
323
+ /**
324
+ * Set a specific setting
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * await baasix.settings.set('appName', 'My New App Name');
329
+ * ```
330
+ */
331
+ set<T>(key: string, value: T): Promise<Settings>;
332
+ }
333
+
334
+ interface ReportsModuleConfig {
335
+ client: HttpClient;
336
+ }
337
+ /**
338
+ * Reports module for generating analytics and reports.
339
+ *
340
+ * @example
341
+ * ```typescript
342
+ * // Generate sales report grouped by category
343
+ * const report = await baasix.reports.generate('orders', {
344
+ * aggregate: {
345
+ * totalSales: { function: 'sum', field: 'total' },
346
+ * orderCount: { function: 'count', field: 'id' },
347
+ * avgOrderValue: { function: 'avg', field: 'total' }
348
+ * },
349
+ * groupBy: 'category',
350
+ * filter: { status: { eq: 'completed' } },
351
+ * dateRange: {
352
+ * start: '2025-01-01',
353
+ * end: '2025-12-31',
354
+ * field: 'createdAt'
355
+ * }
356
+ * });
357
+ * ```
358
+ */
359
+ declare class ReportsModule {
360
+ private client;
361
+ constructor(config: ReportsModuleConfig);
362
+ /**
363
+ * Generate a report for a collection
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * // Sales by month
368
+ * const report = await baasix.reports.generate('orders', {
369
+ * aggregate: {
370
+ * revenue: { function: 'sum', field: 'total' },
371
+ * orders: { function: 'count', field: 'id' }
372
+ * },
373
+ * groupBy: 'month',
374
+ * dateRange: {
375
+ * start: '2025-01-01',
376
+ * end: '2025-12-31'
377
+ * }
378
+ * });
379
+ * ```
380
+ */
381
+ generate(collection: string, config: Omit<ReportConfig, "collection">): Promise<ReportResult>;
382
+ /**
383
+ * Get collection statistics
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const stats = await baasix.reports.getStats('products');
388
+ * console.log(stats.totalCount, stats.recentCount);
389
+ * ```
390
+ */
391
+ getStats(collection: string, options?: {
392
+ timeframe?: "24h" | "7d" | "30d" | "90d" | "1y";
393
+ }): Promise<{
394
+ totalCount: number;
395
+ recentCount: number;
396
+ deletedCount?: number;
397
+ byDate?: Record<string, number>;
398
+ }>;
399
+ /**
400
+ * Generate an aggregation query
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * const results = await baasix.reports.aggregate('orders', {
405
+ * aggregate: {
406
+ * total: { function: 'sum', field: 'amount' },
407
+ * count: { function: 'count', field: 'id' },
408
+ * min: { function: 'min', field: 'amount' },
409
+ * max: { function: 'max', field: 'amount' },
410
+ * avg: { function: 'avg', field: 'amount' }
411
+ * },
412
+ * groupBy: ['status', 'paymentMethod'],
413
+ * filter: { createdAt: { gte: '$NOW-DAYS_30' } }
414
+ * });
415
+ * ```
416
+ */
417
+ aggregate(collection: string, options: {
418
+ aggregate: Aggregate;
419
+ groupBy?: string[];
420
+ filter?: Filter;
421
+ }): Promise<Record<string, unknown>[]>;
422
+ /**
423
+ * Count items matching a filter
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * const activeUsers = await baasix.reports.count('users', {
428
+ * status: { eq: 'active' }
429
+ * });
430
+ * ```
431
+ */
432
+ count(collection: string, filter?: Filter): Promise<number>;
433
+ /**
434
+ * Get distinct values for a field
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const categories = await baasix.reports.distinct('products', 'category');
439
+ * ```
440
+ */
441
+ distinct(collection: string, field: string, filter?: Filter): Promise<unknown[]>;
442
+ }
443
+
444
+ interface WorkflowsModuleConfig {
445
+ client: HttpClient;
446
+ }
447
+ /**
448
+ * Workflows module for managing visual workflow automation.
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * // Execute a workflow
453
+ * const result = await baasix.workflows.execute('workflow-uuid', {
454
+ * orderId: 'order-123'
455
+ * });
456
+ *
457
+ * // Get workflow executions
458
+ * const { data } = await baasix.workflows.getExecutions('workflow-uuid');
459
+ * ```
460
+ */
461
+ declare class WorkflowsModule {
462
+ private client;
463
+ constructor(config: WorkflowsModuleConfig);
464
+ /**
465
+ * List all workflows
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * const { data } = await baasix.workflows.find();
470
+ * ```
471
+ */
472
+ find(params?: {
473
+ limit?: number;
474
+ page?: number;
475
+ filter?: Record<string, unknown>;
476
+ }): Promise<PaginatedResponse<Workflow>>;
477
+ /**
478
+ * Get a workflow by ID
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * const workflow = await baasix.workflows.findOne('workflow-uuid');
483
+ * ```
484
+ */
485
+ findOne(id: string): Promise<Workflow>;
486
+ /**
487
+ * Create a new workflow
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * const workflow = await baasix.workflows.create({
492
+ * name: 'Order Processing',
493
+ * description: 'Process new orders',
494
+ * trigger: {
495
+ * type: 'hook',
496
+ * config: {
497
+ * collection: 'orders',
498
+ * event: 'items.create.after'
499
+ * }
500
+ * },
501
+ * nodes: [...],
502
+ * edges: [...],
503
+ * isActive: true
504
+ * });
505
+ * ```
506
+ */
507
+ create(data: Omit<Workflow, "id" | "createdAt" | "updatedAt">): Promise<Workflow>;
508
+ /**
509
+ * Update a workflow
510
+ *
511
+ * @example
512
+ * ```typescript
513
+ * await baasix.workflows.update('workflow-uuid', {
514
+ * name: 'Updated Workflow Name',
515
+ * isActive: false
516
+ * });
517
+ * ```
518
+ */
519
+ update(id: string, data: Partial<Omit<Workflow, "id" | "createdAt" | "updatedAt">>): Promise<Workflow>;
520
+ /**
521
+ * Delete a workflow
522
+ *
523
+ * @example
524
+ * ```typescript
525
+ * await baasix.workflows.delete('workflow-uuid');
526
+ * ```
527
+ */
528
+ delete(id: string): Promise<void>;
529
+ /**
530
+ * Execute a workflow manually
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * const result = await baasix.workflows.execute('workflow-uuid', {
535
+ * // Trigger data
536
+ * customerId: 'customer-123',
537
+ * action: 'sendEmail'
538
+ * });
539
+ * ```
540
+ */
541
+ execute(id: string, triggerData?: Record<string, unknown>): Promise<WorkflowExecution>;
542
+ /**
543
+ * Test a workflow without persisting execution
544
+ *
545
+ * @example
546
+ * ```typescript
547
+ * const result = await baasix.workflows.test('workflow-uuid', {
548
+ * testData: { value: 123 }
549
+ * });
550
+ * ```
551
+ */
552
+ test(id: string, triggerData?: Record<string, unknown>): Promise<WorkflowExecution>;
553
+ /**
554
+ * Get workflow execution history
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * const { data } = await baasix.workflows.getExecutions('workflow-uuid', {
559
+ * limit: 50
560
+ * });
561
+ * ```
562
+ */
563
+ getExecutions(id: string, params?: {
564
+ limit?: number;
565
+ page?: number;
566
+ status?: "pending" | "running" | "completed" | "failed";
567
+ }): Promise<PaginatedResponse<WorkflowExecution>>;
568
+ /**
569
+ * Get a specific execution
570
+ *
571
+ * @example
572
+ * ```typescript
573
+ * const execution = await baasix.workflows.getExecution(
574
+ * 'workflow-uuid',
575
+ * 'execution-uuid'
576
+ * );
577
+ * ```
578
+ */
579
+ getExecution(workflowId: string, executionId: string): Promise<WorkflowExecution>;
580
+ /**
581
+ * Cancel a running execution
582
+ *
583
+ * @example
584
+ * ```typescript
585
+ * await baasix.workflows.cancelExecution('workflow-uuid', 'execution-uuid');
586
+ * ```
587
+ */
588
+ cancelExecution(workflowId: string, executionId: string): Promise<void>;
589
+ /**
590
+ * Enable a workflow
591
+ *
592
+ * @example
593
+ * ```typescript
594
+ * await baasix.workflows.enable('workflow-uuid');
595
+ * ```
596
+ */
597
+ enable(id: string): Promise<Workflow>;
598
+ /**
599
+ * Disable a workflow
600
+ *
601
+ * @example
602
+ * ```typescript
603
+ * await baasix.workflows.disable('workflow-uuid');
604
+ * ```
605
+ */
606
+ disable(id: string): Promise<Workflow>;
607
+ /**
608
+ * Duplicate a workflow
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * const newWorkflow = await baasix.workflows.duplicate('workflow-uuid', {
613
+ * name: 'Copy of My Workflow'
614
+ * });
615
+ * ```
616
+ */
617
+ duplicate(id: string, overrides?: Partial<Omit<Workflow, "id" | "createdAt" | "updatedAt">>): Promise<Workflow>;
618
+ }
619
+
620
+ interface SocketOptions {
621
+ auth?: {
622
+ token?: string;
623
+ };
624
+ query?: Record<string, string>;
625
+ path?: string;
626
+ transports?: string[];
627
+ reconnection?: boolean;
628
+ reconnectionAttempts?: number;
629
+ reconnectionDelay?: number;
630
+ timeout?: number;
631
+ }
632
+ interface Socket {
633
+ connected: boolean;
634
+ id?: string;
635
+ on(event: string, callback: (...args: any[]) => void): void;
636
+ off(event: string, callback?: (...args: any[]) => void): void;
637
+ emit(event: string, ...args: any[]): void;
638
+ connect(): void;
639
+ disconnect(): void;
640
+ }
641
+ type SocketIOClient = (url: string, options?: SocketOptions) => Socket;
642
+ interface RealtimeConfig {
643
+ client: HttpClient;
644
+ storage: StorageAdapter;
645
+ socketUrl?: string;
646
+ socketPath?: string;
647
+ }
648
+ type SubscriptionEvent = "create" | "update" | "delete";
649
+ interface SubscriptionPayload<T = any> {
650
+ action: SubscriptionEvent;
651
+ collection: string;
652
+ data: T;
653
+ timestamp: string;
654
+ }
655
+ interface WorkflowExecutionUpdate {
656
+ executionId: string | number;
657
+ status?: string;
658
+ nodeId?: string;
659
+ nodeName?: string;
660
+ message?: string;
661
+ progress?: number;
662
+ result?: any;
663
+ error?: string;
664
+ timestamp: string;
665
+ }
666
+ interface SubscriptionCallback<T = any> {
667
+ (payload: SubscriptionPayload<T>): void;
668
+ }
669
+ /**
670
+ * Realtime module for WebSocket-based real-time subscriptions.
671
+ *
672
+ * Requires socket.io-client to be installed separately:
673
+ * ```bash
674
+ * npm install socket.io-client
675
+ * ```
676
+ *
677
+ * @example
678
+ * ```typescript
679
+ * import { io } from 'socket.io-client';
680
+ *
681
+ * // Initialize realtime with socket.io client
682
+ * baasix.realtime.setSocketClient(io);
683
+ *
684
+ * // Connect to realtime server
685
+ * await baasix.realtime.connect();
686
+ *
687
+ * // Subscribe to collection changes
688
+ * const unsubscribe = baasix.realtime.subscribe('products', (payload) => {
689
+ * console.log(`Product ${payload.action}:`, payload.data);
690
+ * });
691
+ *
692
+ * // Disconnect when done
693
+ * baasix.realtime.disconnect();
694
+ * ```
695
+ */
696
+ declare class RealtimeModule {
697
+ private client;
698
+ private storage;
699
+ private socket;
700
+ private socketClient;
701
+ private socketUrl;
702
+ private socketPath;
703
+ private subscriptions;
704
+ private workflowCallbacks;
705
+ private connectionCallbacks;
706
+ private reconnecting;
707
+ private connectionPromise;
708
+ constructor(config: RealtimeConfig);
709
+ /**
710
+ * Set the socket.io client instance
711
+ * This allows the SDK to work without bundling socket.io-client
712
+ *
713
+ * @example
714
+ * ```typescript
715
+ * import { io } from 'socket.io-client';
716
+ * baasix.realtime.setSocketClient(io);
717
+ * ```
718
+ */
719
+ setSocketClient(socketIO: SocketIOClient): void;
720
+ /**
721
+ * Set the WebSocket server URL
722
+ * By default, uses the same URL as the API
723
+ */
724
+ setSocketUrl(url: string): void;
725
+ /**
726
+ * Check if socket.io client is available
727
+ */
728
+ private ensureSocketClient;
729
+ /**
730
+ * Get the authentication token for socket connection
731
+ */
732
+ private getAuthToken;
733
+ /**
734
+ * Connect to the realtime server
735
+ *
736
+ * @example
737
+ * ```typescript
738
+ * await baasix.realtime.connect();
739
+ * console.log('Connected to realtime server');
740
+ * ```
741
+ */
742
+ connect(): Promise<void>;
743
+ /**
744
+ * Disconnect from the realtime server
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * baasix.realtime.disconnect();
749
+ * ```
750
+ */
751
+ disconnect(): void;
752
+ /**
753
+ * Check if connected to the realtime server
754
+ */
755
+ get isConnected(): boolean;
756
+ /**
757
+ * Subscribe to connection state changes
758
+ *
759
+ * @example
760
+ * ```typescript
761
+ * const unsubscribe = baasix.realtime.onConnectionChange((connected) => {
762
+ * console.log('Connection state:', connected ? 'online' : 'offline');
763
+ * });
764
+ * ```
765
+ */
766
+ onConnectionChange(callback: (connected: boolean) => void): () => void;
767
+ private notifyConnectionChange;
768
+ /**
769
+ * Subscribe to a collection for real-time updates
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * // Subscribe to all changes
774
+ * const unsubscribe = baasix.realtime.subscribe('products', (payload) => {
775
+ * console.log(`${payload.action}:`, payload.data);
776
+ * });
777
+ *
778
+ * // Subscribe to specific events
779
+ * const unsubscribe = baasix.realtime.subscribe('orders', (payload) => {
780
+ * if (payload.action === 'create') {
781
+ * console.log('New order:', payload.data);
782
+ * }
783
+ * });
784
+ *
785
+ * // Unsubscribe when done
786
+ * unsubscribe();
787
+ * ```
788
+ */
789
+ subscribe<T extends BaseItem = BaseItem>(collection: string, callback: SubscriptionCallback<T>): () => void;
790
+ /**
791
+ * Subscribe to specific events on a collection
792
+ *
793
+ * @example
794
+ * ```typescript
795
+ * // Only listen for creates
796
+ * const unsubscribe = baasix.realtime.on('products', 'create', (data) => {
797
+ * console.log('New product:', data);
798
+ * });
799
+ * ```
800
+ */
801
+ on<T extends BaseItem = BaseItem>(collection: string, event: SubscriptionEvent, callback: (data: T) => void): () => void;
802
+ /**
803
+ * Listen to all changes across all subscribed collections
804
+ *
805
+ * @example
806
+ * ```typescript
807
+ * const unsubscribe = baasix.realtime.onAny((collection, payload) => {
808
+ * console.log(`${collection}:${payload.action}`, payload.data);
809
+ * });
810
+ * ```
811
+ */
812
+ onAny(callback: (collection: string, payload: SubscriptionPayload) => void): () => void;
813
+ private subscribeOnServer;
814
+ private unsubscribeOnServer;
815
+ private setupCollectionListeners;
816
+ private removeCollectionListeners;
817
+ private handleCollectionEvent;
818
+ private resubscribeAll;
819
+ /**
820
+ * Join a workflow execution room to receive real-time updates
821
+ *
822
+ * @example
823
+ * ```typescript
824
+ * const unsubscribe = baasix.realtime.subscribeToExecution(executionId, (update) => {
825
+ * console.log('Execution update:', update);
826
+ * if (update.status === 'complete') {
827
+ * console.log('Workflow finished!');
828
+ * }
829
+ * });
830
+ * ```
831
+ */
832
+ subscribeToExecution(executionId: string | number, callback: (data: WorkflowExecutionUpdate) => void): () => void;
833
+ private handleWorkflowUpdate;
834
+ /**
835
+ * Create a channel for a collection (Supabase-style API)
836
+ *
837
+ * @example
838
+ * ```typescript
839
+ * const channel = baasix.realtime
840
+ * .channel('products')
841
+ * .on('INSERT', (payload) => console.log('New:', payload))
842
+ * .on('UPDATE', (payload) => console.log('Updated:', payload))
843
+ * .on('DELETE', (payload) => console.log('Deleted:', payload))
844
+ * .subscribe();
845
+ *
846
+ * // Later
847
+ * channel.unsubscribe();
848
+ * ```
849
+ */
850
+ channel(collection: string): RealtimeChannel;
851
+ }
852
+ /**
853
+ * Chainable channel for Supabase-style subscription API
854
+ */
855
+ declare class RealtimeChannel {
856
+ private realtime;
857
+ private collection;
858
+ private handlers;
859
+ private unsubscribeFn;
860
+ constructor(realtime: RealtimeModule, collection: string);
861
+ /**
862
+ * Add an event handler (chainable)
863
+ *
864
+ * @param event - 'INSERT', 'UPDATE', 'DELETE', or '*' for all
865
+ * @param callback - Handler function
866
+ */
867
+ on(event: "INSERT" | "UPDATE" | "DELETE" | "*", callback: (payload: any) => void): this;
868
+ private mapEvent;
869
+ private addHandler;
870
+ /**
871
+ * Start the subscription
872
+ */
873
+ subscribe(): this;
874
+ /**
875
+ * Stop the subscription
876
+ */
877
+ unsubscribe(): void;
878
+ }
879
+
880
+ interface RolesModuleConfig {
881
+ client: HttpClient;
882
+ }
883
+ interface Role extends BaseItem {
884
+ name: string;
885
+ description?: string;
886
+ icon?: string;
887
+ ipWhitelist?: string;
888
+ enforceTotp?: boolean;
889
+ adminAccess?: boolean;
890
+ appAccess?: boolean;
891
+ }
892
+ interface CreateRoleData {
893
+ name: string;
894
+ description?: string;
895
+ icon?: string;
896
+ ipWhitelist?: string;
897
+ enforceTotp?: boolean;
898
+ adminAccess?: boolean;
899
+ appAccess?: boolean;
900
+ }
901
+ /**
902
+ * Roles module for managing user roles.
903
+ *
904
+ * @example
905
+ * ```typescript
906
+ * // List all roles
907
+ * const roles = await baasix.roles.find();
908
+ *
909
+ * // Create a new role
910
+ * const role = await baasix.roles.create({
911
+ * name: 'Editor',
912
+ * description: 'Can edit content'
913
+ * });
914
+ * ```
915
+ */
916
+ declare class RolesModule {
917
+ private client;
918
+ private collection;
919
+ constructor(config: RolesModuleConfig);
920
+ /**
921
+ * Get all roles
922
+ *
923
+ * @example
924
+ * ```typescript
925
+ * const { data: roles } = await baasix.roles.find();
926
+ * ```
927
+ */
928
+ find(): Promise<{
929
+ data: Role[];
930
+ totalCount: number;
931
+ }>;
932
+ /**
933
+ * Get a role by ID
934
+ *
935
+ * @example
936
+ * ```typescript
937
+ * const role = await baasix.roles.findOne('role-uuid');
938
+ * ```
939
+ */
940
+ findOne(id: string): Promise<Role>;
941
+ /**
942
+ * Get a role by name
943
+ *
944
+ * @example
945
+ * ```typescript
946
+ * const role = await baasix.roles.findByName('Administrator');
947
+ * ```
948
+ */
949
+ findByName(name: string): Promise<Role | null>;
950
+ /**
951
+ * Create a new role
952
+ *
953
+ * @example
954
+ * ```typescript
955
+ * const id = await baasix.roles.create({
956
+ * name: 'Editor',
957
+ * description: 'Content editor role',
958
+ * appAccess: true
959
+ * });
960
+ * ```
961
+ */
962
+ create(data: CreateRoleData): Promise<string>;
963
+ /**
964
+ * Update a role
965
+ *
966
+ * @example
967
+ * ```typescript
968
+ * await baasix.roles.update('role-uuid', {
969
+ * description: 'Updated description'
970
+ * });
971
+ * ```
972
+ */
973
+ update(id: string, data: Partial<CreateRoleData>): Promise<void>;
974
+ /**
975
+ * Delete a role
976
+ *
977
+ * @example
978
+ * ```typescript
979
+ * await baasix.roles.delete('role-uuid');
980
+ * ```
981
+ */
982
+ delete(id: string): Promise<void>;
983
+ }
984
+
985
+ interface UsersModuleConfig {
986
+ client: HttpClient;
987
+ }
988
+ interface User {
989
+ id: string;
990
+ email: string;
991
+ firstName?: string;
992
+ lastName?: string;
993
+ avatar?: string;
994
+ status?: "active" | "suspended" | "invited";
995
+ role_Id?: string;
996
+ role?: {
997
+ id: string;
998
+ name: string;
999
+ };
1000
+ emailVerified?: boolean;
1001
+ totpEnabled?: boolean;
1002
+ lastAccess?: string;
1003
+ createdAt?: string;
1004
+ updatedAt?: string;
1005
+ }
1006
+ interface CreateUserData {
1007
+ email: string;
1008
+ password?: string;
1009
+ firstName?: string;
1010
+ lastName?: string;
1011
+ avatar?: string;
1012
+ status?: "active" | "suspended" | "invited";
1013
+ role_Id?: string;
1014
+ }
1015
+ interface UpdateUserData {
1016
+ email?: string;
1017
+ firstName?: string;
1018
+ lastName?: string;
1019
+ avatar?: string;
1020
+ status?: "active" | "suspended" | "invited";
1021
+ role_Id?: string;
1022
+ }
1023
+ interface UserQueryOptions {
1024
+ filter?: Record<string, any>;
1025
+ sort?: string;
1026
+ limit?: number;
1027
+ page?: number;
1028
+ fields?: string[];
1029
+ }
1030
+ /**
1031
+ * Users module for managing users (admin operations).
1032
+ *
1033
+ * @example
1034
+ * ```typescript
1035
+ * // List all users
1036
+ * const users = await baasix.users.find();
1037
+ *
1038
+ * // Create a new user
1039
+ * const user = await baasix.users.create({
1040
+ * email: 'user@example.com',
1041
+ * firstName: 'John',
1042
+ * lastName: 'Doe',
1043
+ * role_Id: 'role-uuid'
1044
+ * });
1045
+ * ```
1046
+ */
1047
+ declare class UsersModule {
1048
+ private client;
1049
+ private collection;
1050
+ constructor(config: UsersModuleConfig);
1051
+ /**
1052
+ * Get all users with optional filtering
1053
+ *
1054
+ * @example
1055
+ * ```typescript
1056
+ * const { data: users } = await baasix.users.find({
1057
+ * filter: { status: { eq: 'active' } },
1058
+ * limit: 20
1059
+ * });
1060
+ * ```
1061
+ */
1062
+ find(options?: UserQueryOptions): Promise<{
1063
+ data: User[];
1064
+ totalCount: number;
1065
+ }>;
1066
+ /**
1067
+ * Get a user by ID
1068
+ *
1069
+ * @example
1070
+ * ```typescript
1071
+ * const user = await baasix.users.findOne('user-uuid');
1072
+ * ```
1073
+ */
1074
+ findOne(id: string, fields?: string[]): Promise<User>;
1075
+ /**
1076
+ * Get a user by email
1077
+ *
1078
+ * @example
1079
+ * ```typescript
1080
+ * const user = await baasix.users.findByEmail('user@example.com');
1081
+ * ```
1082
+ */
1083
+ findByEmail(email: string): Promise<User | null>;
1084
+ /**
1085
+ * Create a new user
1086
+ *
1087
+ * @example
1088
+ * ```typescript
1089
+ * const id = await baasix.users.create({
1090
+ * email: 'user@example.com',
1091
+ * password: 'securepassword',
1092
+ * firstName: 'John',
1093
+ * lastName: 'Doe',
1094
+ * role_Id: 'role-uuid'
1095
+ * });
1096
+ * ```
1097
+ */
1098
+ create(data: CreateUserData): Promise<string>;
1099
+ /**
1100
+ * Update a user
1101
+ *
1102
+ * @example
1103
+ * ```typescript
1104
+ * await baasix.users.update('user-uuid', {
1105
+ * firstName: 'Jane'
1106
+ * });
1107
+ * ```
1108
+ */
1109
+ update(id: string, data: UpdateUserData): Promise<void>;
1110
+ /**
1111
+ * Delete a user
1112
+ *
1113
+ * @example
1114
+ * ```typescript
1115
+ * await baasix.users.delete('user-uuid');
1116
+ * ```
1117
+ */
1118
+ delete(id: string): Promise<void>;
1119
+ /**
1120
+ * Change a user's password (admin operation)
1121
+ *
1122
+ * @example
1123
+ * ```typescript
1124
+ * await baasix.users.changePassword('user-uuid', 'newpassword');
1125
+ * ```
1126
+ */
1127
+ changePassword(userId: string, newPassword: string): Promise<void>;
1128
+ /**
1129
+ * Suspend a user
1130
+ *
1131
+ * @example
1132
+ * ```typescript
1133
+ * await baasix.users.suspend('user-uuid');
1134
+ * ```
1135
+ */
1136
+ suspend(id: string): Promise<void>;
1137
+ /**
1138
+ * Activate a user
1139
+ *
1140
+ * @example
1141
+ * ```typescript
1142
+ * await baasix.users.activate('user-uuid');
1143
+ * ```
1144
+ */
1145
+ activate(id: string): Promise<void>;
1146
+ /**
1147
+ * Bulk create users
1148
+ *
1149
+ * @example
1150
+ * ```typescript
1151
+ * const ids = await baasix.users.createMany([
1152
+ * { email: 'user1@example.com', firstName: 'User 1' },
1153
+ * { email: 'user2@example.com', firstName: 'User 2' }
1154
+ * ]);
1155
+ * ```
1156
+ */
1157
+ createMany(users: CreateUserData[]): Promise<string[]>;
1158
+ /**
1159
+ * Bulk delete users
1160
+ *
1161
+ * @example
1162
+ * ```typescript
1163
+ * await baasix.users.deleteMany(['user-uuid-1', 'user-uuid-2']);
1164
+ * ```
1165
+ */
1166
+ deleteMany(ids: string[]): Promise<void>;
1167
+ }
1168
+
1169
+ interface MigrationsModuleConfig {
1170
+ client: HttpClient;
1171
+ }
1172
+ interface MigrationStatus {
1173
+ lastBatch: number;
1174
+ totalMigrations: number;
1175
+ pendingCount: number;
1176
+ completedCount: number;
1177
+ hasPending: boolean;
1178
+ }
1179
+ interface Migration {
1180
+ id: string;
1181
+ name: string;
1182
+ batch: number;
1183
+ migratedAt: string;
1184
+ }
1185
+ interface PendingMigration {
1186
+ name: string;
1187
+ path?: string;
1188
+ }
1189
+ interface MigrationResult {
1190
+ success: boolean;
1191
+ migrationsRun: string[];
1192
+ errors?: string[];
1193
+ }
1194
+ interface RollbackResult {
1195
+ success: boolean;
1196
+ migrationsRolledBack: string[];
1197
+ errors?: string[];
1198
+ }
1199
+ /**
1200
+ * Migrations module for managing database schema migrations.
1201
+ * Admin access required for all operations.
1202
+ *
1203
+ * @example
1204
+ * ```typescript
1205
+ * // Check migration status
1206
+ * const status = await baasix.migrations.status();
1207
+ *
1208
+ * // Run pending migrations
1209
+ * if (status.hasPending) {
1210
+ * await baasix.migrations.run();
1211
+ * }
1212
+ * ```
1213
+ */
1214
+ declare class MigrationsModule {
1215
+ private client;
1216
+ constructor(config: MigrationsModuleConfig);
1217
+ /**
1218
+ * Get migration status
1219
+ *
1220
+ * @example
1221
+ * ```typescript
1222
+ * const status = await baasix.migrations.status();
1223
+ * console.log(`Pending migrations: ${status.pendingCount}`);
1224
+ * ```
1225
+ */
1226
+ status(): Promise<MigrationStatus>;
1227
+ /**
1228
+ * Get all completed migrations
1229
+ *
1230
+ * @example
1231
+ * ```typescript
1232
+ * const migrations = await baasix.migrations.list();
1233
+ * ```
1234
+ */
1235
+ list(): Promise<Migration[]>;
1236
+ /**
1237
+ * Get pending migrations
1238
+ *
1239
+ * @example
1240
+ * ```typescript
1241
+ * const pending = await baasix.migrations.pending();
1242
+ * ```
1243
+ */
1244
+ pending(): Promise<PendingMigration[]>;
1245
+ /**
1246
+ * Check if there are pending migrations
1247
+ *
1248
+ * @example
1249
+ * ```typescript
1250
+ * const needsMigration = await baasix.migrations.hasPending();
1251
+ * ```
1252
+ */
1253
+ hasPending(): Promise<boolean>;
1254
+ /**
1255
+ * Get a specific migration by name
1256
+ *
1257
+ * @example
1258
+ * ```typescript
1259
+ * const migration = await baasix.migrations.get('20231201_create_users');
1260
+ * ```
1261
+ */
1262
+ get(name: string): Promise<Migration | null>;
1263
+ /**
1264
+ * Run pending migrations
1265
+ *
1266
+ * @example
1267
+ * ```typescript
1268
+ * const result = await baasix.migrations.run();
1269
+ * console.log(`Ran ${result.migrationsRun.length} migrations`);
1270
+ * ```
1271
+ */
1272
+ run(): Promise<MigrationResult>;
1273
+ /**
1274
+ * Rollback a specific migration
1275
+ *
1276
+ * @example
1277
+ * ```typescript
1278
+ * const result = await baasix.migrations.rollback('20231201_create_users');
1279
+ * ```
1280
+ */
1281
+ rollback(name: string): Promise<RollbackResult>;
1282
+ /**
1283
+ * Rollback the last batch of migrations
1284
+ *
1285
+ * @example
1286
+ * ```typescript
1287
+ * const result = await baasix.migrations.rollbackLast();
1288
+ * ```
1289
+ */
1290
+ rollbackLast(): Promise<RollbackResult>;
1291
+ /**
1292
+ * Create a new migration file
1293
+ *
1294
+ * @example
1295
+ * ```typescript
1296
+ * const migrationName = await baasix.migrations.create('add_status_column');
1297
+ * ```
1298
+ */
1299
+ create(name: string): Promise<string>;
1300
+ /**
1301
+ * Mark a migration as complete (without running it)
1302
+ *
1303
+ * @example
1304
+ * ```typescript
1305
+ * await baasix.migrations.markComplete('20231201_create_users');
1306
+ * ```
1307
+ */
1308
+ markComplete(name: string): Promise<void>;
1309
+ /**
1310
+ * Mark all pending migrations as complete
1311
+ *
1312
+ * @example
1313
+ * ```typescript
1314
+ * await baasix.migrations.markAllComplete();
1315
+ * ```
1316
+ */
1317
+ markAllComplete(): Promise<void>;
1318
+ }
1319
+
1320
+ /**
1321
+ * The main Baasix SDK client.
1322
+ *
1323
+ * @example
1324
+ * ```typescript
1325
+ * import { createBaasix } from '@baasix/sdk';
1326
+ *
1327
+ * // Basic setup
1328
+ * const baasix = createBaasix({
1329
+ * url: 'https://api.example.com'
1330
+ * });
1331
+ *
1332
+ * // With custom storage (React Native)
1333
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
1334
+ * import { AsyncStorageAdapter } from '@baasix/sdk';
1335
+ *
1336
+ * const baasix = createBaasix({
1337
+ * url: 'https://api.example.com',
1338
+ * storage: new AsyncStorageAdapter(AsyncStorage)
1339
+ * });
1340
+ *
1341
+ * // Cookie mode (for web apps with HTTP-only cookies)
1342
+ * const baasix = createBaasix({
1343
+ * url: 'https://api.example.com',
1344
+ * authMode: 'cookie'
1345
+ * });
1346
+ *
1347
+ * // Server-side with static token
1348
+ * const baasix = createBaasix({
1349
+ * url: 'https://api.example.com',
1350
+ * token: 'your-api-token'
1351
+ * });
1352
+ * ```
1353
+ */
1354
+ declare class Baasix {
1355
+ private config;
1356
+ private httpClient;
1357
+ private storage;
1358
+ readonly auth: AuthModule;
1359
+ readonly files: FilesModule;
1360
+ readonly schemas: SchemasModule;
1361
+ readonly notifications: NotificationsModule;
1362
+ readonly permissions: PermissionsModule;
1363
+ readonly settings: SettingsModule;
1364
+ readonly reports: ReportsModule;
1365
+ readonly workflows: WorkflowsModule;
1366
+ readonly realtime: RealtimeModule;
1367
+ readonly roles: RolesModule;
1368
+ readonly users: UsersModule;
1369
+ readonly migrations: MigrationsModule;
1370
+ private itemsModules;
1371
+ constructor(config: BaasixConfig);
1372
+ /**
1373
+ * Get an Items module for a specific collection.
1374
+ * Returns a cached instance for repeated calls with the same collection.
1375
+ *
1376
+ * @example
1377
+ * ```typescript
1378
+ * // Get items module
1379
+ * const products = baasix.items('products');
1380
+ *
1381
+ * // CRUD operations
1382
+ * const { data } = await products.find({ filter: { status: { eq: 'active' } } });
1383
+ * const product = await products.findOne('product-uuid');
1384
+ * const id = await products.create({ name: 'New Product', price: 29.99 });
1385
+ * await products.update('product-uuid', { price: 24.99 });
1386
+ * await products.delete('product-uuid');
1387
+ *
1388
+ * // Query builder
1389
+ * const results = await baasix.items('posts')
1390
+ * .query()
1391
+ * .select('*', 'author.*')
1392
+ * .filter({ status: { eq: 'published' } })
1393
+ * .sort({ createdAt: 'desc' })
1394
+ * .limit(10)
1395
+ * .get();
1396
+ * ```
1397
+ */
1398
+ items<T extends BaseItem = BaseItem>(collection: string): ItemsModule<T>;
1399
+ /**
1400
+ * Alias for items() - get a collection
1401
+ *
1402
+ * @example
1403
+ * ```typescript
1404
+ * const products = baasix.collection('products');
1405
+ * ```
1406
+ */
1407
+ collection<T extends BaseItem = BaseItem>(collection: string): ItemsModule<T>;
1408
+ /**
1409
+ * Alias for items() - from a collection (Supabase-style)
1410
+ *
1411
+ * @example
1412
+ * ```typescript
1413
+ * const products = baasix.from('products');
1414
+ * ```
1415
+ */
1416
+ from<T extends BaseItem = BaseItem>(collection: string): ItemsModule<T>;
1417
+ /**
1418
+ * Get the underlying HTTP client for custom requests
1419
+ *
1420
+ * @example
1421
+ * ```typescript
1422
+ * // Custom GET request
1423
+ * const data = await baasix.request.get('/custom-endpoint');
1424
+ *
1425
+ * // Custom POST request
1426
+ * const result = await baasix.request.post('/custom-endpoint', { data: 'value' });
1427
+ * ```
1428
+ */
1429
+ get request(): HttpClient;
1430
+ /**
1431
+ * Update SDK configuration
1432
+ *
1433
+ * @example
1434
+ * ```typescript
1435
+ * baasix.configure({
1436
+ * headers: { 'X-Custom-Header': 'value' }
1437
+ * });
1438
+ * ```
1439
+ */
1440
+ configure(config: Partial<BaasixConfig>): void;
1441
+ /**
1442
+ * Set the tenant for multi-tenant mode
1443
+ *
1444
+ * @example
1445
+ * ```typescript
1446
+ * baasix.setTenant('tenant-uuid');
1447
+ * ```
1448
+ */
1449
+ setTenant(tenantId: string): Promise<void>;
1450
+ /**
1451
+ * Get the current tenant ID
1452
+ */
1453
+ getTenant(): Promise<string | null>;
1454
+ /**
1455
+ * Clear the tenant
1456
+ */
1457
+ clearTenant(): Promise<void>;
1458
+ /**
1459
+ * Get the base URL
1460
+ */
1461
+ getUrl(): string;
1462
+ /**
1463
+ * Get the current auth mode
1464
+ */
1465
+ getAuthMode(): AuthMode;
1466
+ /**
1467
+ * Get the storage adapter
1468
+ */
1469
+ getStorage(): StorageAdapter;
1470
+ }
1471
+ /**
1472
+ * Create a new Baasix SDK instance.
1473
+ *
1474
+ * @example
1475
+ * ```typescript
1476
+ * import { createBaasix } from '@baasix/sdk';
1477
+ *
1478
+ * const baasix = createBaasix({
1479
+ * url: 'https://api.example.com',
1480
+ * authMode: 'jwt', // or 'cookie'
1481
+ * onAuthStateChange: (event, user) => {
1482
+ * console.log('Auth state changed:', event, user);
1483
+ * }
1484
+ * });
1485
+ *
1486
+ * // Initialize on app startup
1487
+ * await baasix.auth.initialize();
1488
+ *
1489
+ * // Check if user is authenticated
1490
+ * if (await baasix.auth.isAuthenticated()) {
1491
+ * const user = await baasix.auth.getUser();
1492
+ * console.log('Logged in as:', user?.email);
1493
+ * }
1494
+ * ```
1495
+ */
1496
+ declare function createBaasix(config: BaasixConfig): Baasix;
1497
+
1498
+ export { Aggregate, AuthMode, AuthModule, Baasix, BaasixConfig, BaseItem, CreatePermissionData, type CreateRoleData, type CreateUserData, FilesModule, Filter, HttpClient, ItemsModule, type Migration, type MigrationResult, type MigrationStatus, MigrationsModule, Notification, NotificationsModule, PaginatedResponse, type PendingMigration, Permission, PermissionsModule, RealtimeChannel, type RealtimeConfig, RealtimeModule, ReportConfig, ReportResult, ReportsModule, type Role, RolesModule, type RollbackResult, SchemasModule, SendNotificationData, Settings, SettingsModule, StorageAdapter, type SubscriptionCallback, type SubscriptionEvent, type SubscriptionPayload, type UpdateUserData, type UserQueryOptions, UsersModule, Workflow, WorkflowExecution, type WorkflowExecutionUpdate, WorkflowsModule, createBaasix };