@tspvivek/baasix-sdk 0.1.0-alpha.1 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -18
- package/dist/index.cjs +264 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -62
- package/dist/index.d.ts +196 -62
- package/dist/index.js +264 -122
- package/dist/index.js.map +1 -1
- package/dist/modules/files.cjs +34 -1
- package/dist/modules/files.cjs.map +1 -1
- package/dist/modules/files.js +34 -1
- package/dist/modules/files.js.map +1 -1
- package/dist/modules/items.cjs +58 -40
- package/dist/modules/items.cjs.map +1 -1
- package/dist/modules/items.d.cts +11 -18
- package/dist/modules/items.d.ts +11 -18
- package/dist/modules/items.js +58 -40
- package/dist/modules/items.js.map +1 -1
- package/dist/modules/schemas.cjs +55 -2
- package/dist/modules/schemas.cjs.map +1 -1
- package/dist/modules/schemas.d.cts +23 -2
- package/dist/modules/schemas.d.ts +23 -2
- package/dist/modules/schemas.js +55 -2
- package/dist/modules/schemas.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface NotificationsModuleConfig {
|
|
|
22
22
|
* const { data } = await baasix.notifications.find();
|
|
23
23
|
*
|
|
24
24
|
* // Mark as seen
|
|
25
|
-
* await baasix.notifications.markAsSeen('notification-id');
|
|
25
|
+
* await baasix.notifications.markAsSeen(['notification-id']);
|
|
26
26
|
*
|
|
27
27
|
* // Send notification (admin)
|
|
28
28
|
* await baasix.notifications.send({
|
|
@@ -49,57 +49,47 @@ declare class NotificationsModule {
|
|
|
49
49
|
find(params?: {
|
|
50
50
|
limit?: number;
|
|
51
51
|
page?: number;
|
|
52
|
-
|
|
52
|
+
filter?: Record<string, unknown>;
|
|
53
53
|
}): Promise<PaginatedResponse<Notification>>;
|
|
54
54
|
/**
|
|
55
|
-
* Get
|
|
56
|
-
*/
|
|
57
|
-
findOne(id: string): Promise<Notification>;
|
|
58
|
-
/**
|
|
59
|
-
* Mark a notification as seen
|
|
55
|
+
* Get unread notification count
|
|
60
56
|
*
|
|
61
57
|
* @example
|
|
62
58
|
* ```typescript
|
|
63
|
-
* await baasix.notifications.
|
|
59
|
+
* const count = await baasix.notifications.getUnreadCount();
|
|
64
60
|
* ```
|
|
65
61
|
*/
|
|
66
|
-
|
|
62
|
+
getUnreadCount(): Promise<number>;
|
|
67
63
|
/**
|
|
68
|
-
* Mark
|
|
64
|
+
* Mark notifications as seen
|
|
69
65
|
*
|
|
70
66
|
* @example
|
|
71
67
|
* ```typescript
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
markManySeen(ids: string[]): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Mark all notifications as seen
|
|
68
|
+
* // Mark specific notifications as seen
|
|
69
|
+
* await baasix.notifications.markAsSeen(['id1', 'id2']);
|
|
78
70
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* await baasix.notifications.markAllSeen();
|
|
71
|
+
* // Mark all notifications as seen
|
|
72
|
+
* await baasix.notifications.markAsSeen();
|
|
82
73
|
* ```
|
|
83
74
|
*/
|
|
84
|
-
|
|
75
|
+
markAsSeen(notificationIds?: string[]): Promise<{
|
|
76
|
+
count: number;
|
|
77
|
+
}>;
|
|
85
78
|
/**
|
|
86
|
-
*
|
|
79
|
+
* Delete notifications for the current user
|
|
87
80
|
*
|
|
88
81
|
* @example
|
|
89
82
|
* ```typescript
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
getUnreadCount(): Promise<number>;
|
|
94
|
-
/**
|
|
95
|
-
* Delete a notification
|
|
83
|
+
* // Delete specific notifications
|
|
84
|
+
* await baasix.notifications.delete(['id1', 'id2']);
|
|
96
85
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* await baasix.notifications.delete('notification-uuid');
|
|
86
|
+
* // Delete all notifications
|
|
87
|
+
* await baasix.notifications.delete();
|
|
100
88
|
* ```
|
|
101
89
|
*/
|
|
102
|
-
delete(
|
|
90
|
+
delete(notificationIds?: string[]): Promise<{
|
|
91
|
+
count: number;
|
|
92
|
+
}>;
|
|
103
93
|
/**
|
|
104
94
|
* Send a notification to users (requires admin permissions)
|
|
105
95
|
*
|
|
@@ -114,7 +104,24 @@ declare class NotificationsModule {
|
|
|
114
104
|
* });
|
|
115
105
|
* ```
|
|
116
106
|
*/
|
|
117
|
-
send(data: SendNotificationData): Promise<
|
|
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
|
+
}>;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
interface PermissionsModuleConfig {
|
|
@@ -1178,23 +1185,60 @@ interface MigrationStatus {
|
|
|
1178
1185
|
}
|
|
1179
1186
|
interface Migration {
|
|
1180
1187
|
id: string;
|
|
1188
|
+
version: string;
|
|
1181
1189
|
name: string;
|
|
1190
|
+
type: string;
|
|
1191
|
+
status: string;
|
|
1182
1192
|
batch: number;
|
|
1183
1193
|
migratedAt: string;
|
|
1194
|
+
executionTime?: number;
|
|
1184
1195
|
}
|
|
1185
1196
|
interface PendingMigration {
|
|
1197
|
+
version: string;
|
|
1186
1198
|
name: string;
|
|
1199
|
+
type: string;
|
|
1187
1200
|
path?: string;
|
|
1188
1201
|
}
|
|
1189
|
-
interface
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1202
|
+
interface MigrationRunOptions {
|
|
1203
|
+
/** Run only a specific migration version */
|
|
1204
|
+
version?: string;
|
|
1205
|
+
/** Run migrations up to and including this version */
|
|
1206
|
+
toVersion?: string;
|
|
1207
|
+
/** Number of migrations to run */
|
|
1208
|
+
step?: number;
|
|
1209
|
+
/** Preview without executing */
|
|
1210
|
+
dryRun?: boolean;
|
|
1211
|
+
}
|
|
1212
|
+
interface MigrationRunResult {
|
|
1213
|
+
results: Array<{
|
|
1214
|
+
version: string;
|
|
1215
|
+
name: string;
|
|
1216
|
+
status: "completed" | "failed";
|
|
1217
|
+
error?: string;
|
|
1218
|
+
}>;
|
|
1219
|
+
summary: {
|
|
1220
|
+
total: number;
|
|
1221
|
+
completed: number;
|
|
1222
|
+
failed: number;
|
|
1223
|
+
};
|
|
1193
1224
|
}
|
|
1194
1225
|
interface RollbackResult {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1226
|
+
results: Array<{
|
|
1227
|
+
version: string;
|
|
1228
|
+
name: string;
|
|
1229
|
+
status: string;
|
|
1230
|
+
}>;
|
|
1231
|
+
summary: {
|
|
1232
|
+
total: number;
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
interface CreateMigrationOptions {
|
|
1236
|
+
/** Migration type (system, schema, data, custom) */
|
|
1237
|
+
type?: "system" | "schema" | "data" | "custom";
|
|
1238
|
+
/** Migration description */
|
|
1239
|
+
description?: string;
|
|
1240
|
+
/** Custom version (auto-generated if not provided) */
|
|
1241
|
+
version?: string;
|
|
1198
1242
|
}
|
|
1199
1243
|
/**
|
|
1200
1244
|
* Migrations module for managing database schema migrations.
|
|
@@ -1225,14 +1269,21 @@ declare class MigrationsModule {
|
|
|
1225
1269
|
*/
|
|
1226
1270
|
status(): Promise<MigrationStatus>;
|
|
1227
1271
|
/**
|
|
1228
|
-
* Get all
|
|
1272
|
+
* Get all migrations with optional filtering
|
|
1229
1273
|
*
|
|
1230
1274
|
* @example
|
|
1231
1275
|
* ```typescript
|
|
1276
|
+
* // Get all migrations
|
|
1232
1277
|
* const migrations = await baasix.migrations.list();
|
|
1278
|
+
*
|
|
1279
|
+
* // Get completed migrations
|
|
1280
|
+
* const completed = await baasix.migrations.list({ status: 'completed' });
|
|
1233
1281
|
* ```
|
|
1234
1282
|
*/
|
|
1235
|
-
list(
|
|
1283
|
+
list(options?: {
|
|
1284
|
+
status?: "pending" | "completed" | "failed";
|
|
1285
|
+
type?: "system" | "schema" | "data" | "custom";
|
|
1286
|
+
}): Promise<Migration[]>;
|
|
1236
1287
|
/**
|
|
1237
1288
|
* Get pending migrations
|
|
1238
1289
|
*
|
|
@@ -1243,78 +1294,147 @@ declare class MigrationsModule {
|
|
|
1243
1294
|
*/
|
|
1244
1295
|
pending(): Promise<PendingMigration[]>;
|
|
1245
1296
|
/**
|
|
1246
|
-
* Check if
|
|
1297
|
+
* Check if migrations are needed
|
|
1247
1298
|
*
|
|
1248
1299
|
* @example
|
|
1249
1300
|
* ```typescript
|
|
1250
|
-
* const
|
|
1301
|
+
* const check = await baasix.migrations.check();
|
|
1302
|
+
* if (check.hasPending) {
|
|
1303
|
+
* console.log('Migrations needed');
|
|
1304
|
+
* }
|
|
1251
1305
|
* ```
|
|
1252
1306
|
*/
|
|
1253
|
-
|
|
1307
|
+
check(): Promise<{
|
|
1308
|
+
hasPending: boolean;
|
|
1309
|
+
pendingCount: number;
|
|
1310
|
+
}>;
|
|
1254
1311
|
/**
|
|
1255
|
-
* Get a specific migration by
|
|
1312
|
+
* Get a specific migration by version
|
|
1256
1313
|
*
|
|
1257
1314
|
* @example
|
|
1258
1315
|
* ```typescript
|
|
1259
|
-
* const migration = await baasix.migrations.get('
|
|
1316
|
+
* const migration = await baasix.migrations.get('20231201000000');
|
|
1260
1317
|
* ```
|
|
1261
1318
|
*/
|
|
1262
|
-
get(
|
|
1319
|
+
get(version: string): Promise<Migration | null>;
|
|
1263
1320
|
/**
|
|
1264
1321
|
* Run pending migrations
|
|
1265
1322
|
*
|
|
1266
1323
|
* @example
|
|
1267
1324
|
* ```typescript
|
|
1325
|
+
* // Run all pending migrations
|
|
1268
1326
|
* const result = await baasix.migrations.run();
|
|
1269
|
-
*
|
|
1327
|
+
*
|
|
1328
|
+
* // Run with options
|
|
1329
|
+
* const result = await baasix.migrations.run({
|
|
1330
|
+
* step: 1, // Run only 1 migration
|
|
1331
|
+
* dryRun: true // Preview without executing
|
|
1332
|
+
* });
|
|
1270
1333
|
* ```
|
|
1271
1334
|
*/
|
|
1272
|
-
run(): Promise<
|
|
1335
|
+
run(options?: MigrationRunOptions): Promise<MigrationRunResult>;
|
|
1273
1336
|
/**
|
|
1274
1337
|
* Rollback a specific migration
|
|
1275
1338
|
*
|
|
1276
1339
|
* @example
|
|
1277
1340
|
* ```typescript
|
|
1278
|
-
* const result = await baasix.migrations.rollback('
|
|
1341
|
+
* const result = await baasix.migrations.rollback('20231201000000');
|
|
1279
1342
|
* ```
|
|
1280
1343
|
*/
|
|
1281
|
-
rollback(
|
|
1344
|
+
rollback(version: string): Promise<RollbackResult>;
|
|
1282
1345
|
/**
|
|
1283
1346
|
* Rollback the last batch of migrations
|
|
1284
1347
|
*
|
|
1285
1348
|
* @example
|
|
1286
1349
|
* ```typescript
|
|
1287
|
-
* const result = await baasix.migrations.
|
|
1350
|
+
* const result = await baasix.migrations.rollbackBatch();
|
|
1288
1351
|
* ```
|
|
1289
1352
|
*/
|
|
1290
|
-
|
|
1353
|
+
rollbackBatch(): Promise<RollbackResult>;
|
|
1291
1354
|
/**
|
|
1292
1355
|
* Create a new migration file
|
|
1293
1356
|
*
|
|
1294
1357
|
* @example
|
|
1295
1358
|
* ```typescript
|
|
1296
|
-
* const
|
|
1359
|
+
* const { filepath } = await baasix.migrations.create('add_status_column', {
|
|
1360
|
+
* type: 'schema',
|
|
1361
|
+
* description: 'Add status column to orders'
|
|
1362
|
+
* });
|
|
1363
|
+
* ```
|
|
1364
|
+
*/
|
|
1365
|
+
create(name: string, options?: CreateMigrationOptions): Promise<{
|
|
1366
|
+
filepath: string;
|
|
1367
|
+
}>;
|
|
1368
|
+
/**
|
|
1369
|
+
* Mark a specific migration as completed without running it
|
|
1370
|
+
* Useful for existing installations that already have the changes
|
|
1371
|
+
*
|
|
1372
|
+
* @example
|
|
1373
|
+
* ```typescript
|
|
1374
|
+
* await baasix.migrations.markCompleted('20231201000000');
|
|
1375
|
+
* ```
|
|
1376
|
+
*/
|
|
1377
|
+
markCompleted(version: string, metadata?: Record<string, unknown>): Promise<Migration>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Mark all pending migrations as completed
|
|
1380
|
+
* Useful for bringing an existing database up to date without running migrations
|
|
1381
|
+
*
|
|
1382
|
+
* @example
|
|
1383
|
+
* ```typescript
|
|
1384
|
+
* // Mark all pending
|
|
1385
|
+
* await baasix.migrations.markAllCompleted();
|
|
1386
|
+
*
|
|
1387
|
+
* // Mark up to a specific version
|
|
1388
|
+
* await baasix.migrations.markAllCompleted('20231201000000');
|
|
1297
1389
|
* ```
|
|
1298
1390
|
*/
|
|
1299
|
-
|
|
1391
|
+
markAllCompleted(toVersion?: string): Promise<MigrationRunResult>;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
interface ServerInfo {
|
|
1395
|
+
project?: {
|
|
1396
|
+
name?: string;
|
|
1397
|
+
multitenant?: boolean | string;
|
|
1398
|
+
[key: string]: unknown;
|
|
1399
|
+
};
|
|
1400
|
+
version?: string;
|
|
1401
|
+
[key: string]: unknown;
|
|
1402
|
+
}
|
|
1403
|
+
interface ServerModuleConfig {
|
|
1404
|
+
client: HttpClient;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Server module for retrieving server information.
|
|
1408
|
+
*
|
|
1409
|
+
* @example
|
|
1410
|
+
* ```typescript
|
|
1411
|
+
* const info = await baasix.server.info();
|
|
1412
|
+
* console.log(info.project?.name);
|
|
1413
|
+
* ```
|
|
1414
|
+
*/
|
|
1415
|
+
declare class ServerModule {
|
|
1416
|
+
private client;
|
|
1417
|
+
constructor(config: ServerModuleConfig);
|
|
1300
1418
|
/**
|
|
1301
|
-
*
|
|
1419
|
+
* Get server information including project settings
|
|
1302
1420
|
*
|
|
1303
1421
|
* @example
|
|
1304
1422
|
* ```typescript
|
|
1305
|
-
* await baasix.
|
|
1423
|
+
* const info = await baasix.server.info();
|
|
1424
|
+
* console.log('Project:', info.project?.name);
|
|
1425
|
+
* console.log('Version:', info.version);
|
|
1306
1426
|
* ```
|
|
1307
1427
|
*/
|
|
1308
|
-
|
|
1428
|
+
info(): Promise<ServerInfo>;
|
|
1309
1429
|
/**
|
|
1310
|
-
*
|
|
1430
|
+
* Check server health
|
|
1311
1431
|
*
|
|
1312
1432
|
* @example
|
|
1313
1433
|
* ```typescript
|
|
1314
|
-
* await baasix.
|
|
1434
|
+
* const isHealthy = await baasix.server.health();
|
|
1315
1435
|
* ```
|
|
1316
1436
|
*/
|
|
1317
|
-
|
|
1437
|
+
health(): Promise<boolean>;
|
|
1318
1438
|
}
|
|
1319
1439
|
|
|
1320
1440
|
/**
|
|
@@ -1367,6 +1487,7 @@ declare class Baasix {
|
|
|
1367
1487
|
readonly roles: RolesModule;
|
|
1368
1488
|
readonly users: UsersModule;
|
|
1369
1489
|
readonly migrations: MigrationsModule;
|
|
1490
|
+
readonly server: ServerModule;
|
|
1370
1491
|
private itemsModules;
|
|
1371
1492
|
constructor(config: BaasixConfig);
|
|
1372
1493
|
/**
|
|
@@ -1455,6 +1576,19 @@ declare class Baasix {
|
|
|
1455
1576
|
* Clear the tenant
|
|
1456
1577
|
*/
|
|
1457
1578
|
clearTenant(): Promise<void>;
|
|
1579
|
+
/**
|
|
1580
|
+
* Set a static token (convenience method that delegates to auth.setToken)
|
|
1581
|
+
*
|
|
1582
|
+
* @example
|
|
1583
|
+
* ```typescript
|
|
1584
|
+
* baasix.setToken('your-api-token');
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
setToken(token: string): Promise<void>;
|
|
1588
|
+
/**
|
|
1589
|
+
* Get the current auth token
|
|
1590
|
+
*/
|
|
1591
|
+
getToken(): Promise<string | null>;
|
|
1458
1592
|
/**
|
|
1459
1593
|
* Get the base URL
|
|
1460
1594
|
*/
|
|
@@ -1495,4 +1629,4 @@ declare class Baasix {
|
|
|
1495
1629
|
*/
|
|
1496
1630
|
declare function createBaasix(config: BaasixConfig): Baasix;
|
|
1497
1631
|
|
|
1498
|
-
export { Aggregate, AuthMode, AuthModule, Baasix, BaasixConfig, BaseItem, CreatePermissionData, type CreateRoleData, type CreateUserData, FilesModule, Filter, HttpClient, ItemsModule, type Migration, type
|
|
1632
|
+
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, StorageAdapter, type SubscriptionCallback, type SubscriptionEvent, type SubscriptionPayload, type UpdateUserData, type UserQueryOptions, UsersModule, Workflow, WorkflowExecution, type WorkflowExecutionUpdate, WorkflowsModule, createBaasix };
|