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