@fluxbase/sdk 0.0.1-rc.41 → 0.0.1-rc.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1360 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1423 -70
- package/dist/index.d.ts +1423 -70
- package/dist/index.js +1357 -57
- package/dist/index.js.map +1 -1
- package/package.json +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -226,6 +226,7 @@ interface RealtimeMessage {
|
|
|
226
226
|
broadcast?: any;
|
|
227
227
|
messageId?: string;
|
|
228
228
|
status?: string;
|
|
229
|
+
subscription_id?: string;
|
|
229
230
|
}
|
|
230
231
|
interface PostgresChangesConfig {
|
|
231
232
|
event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
@@ -1220,6 +1221,11 @@ interface FunctionInvokeOptions {
|
|
|
1220
1221
|
* @default 'POST'
|
|
1221
1222
|
*/
|
|
1222
1223
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
1224
|
+
/**
|
|
1225
|
+
* Namespace of the function to invoke
|
|
1226
|
+
* If not provided, the first function with the given name is used (alphabetically by namespace)
|
|
1227
|
+
*/
|
|
1228
|
+
namespace?: string;
|
|
1223
1229
|
}
|
|
1224
1230
|
/**
|
|
1225
1231
|
* Edge function metadata
|
|
@@ -1227,6 +1233,7 @@ interface FunctionInvokeOptions {
|
|
|
1227
1233
|
interface EdgeFunction {
|
|
1228
1234
|
id: string;
|
|
1229
1235
|
name: string;
|
|
1236
|
+
namespace: string;
|
|
1230
1237
|
description?: string;
|
|
1231
1238
|
code: string;
|
|
1232
1239
|
version: number;
|
|
@@ -1292,6 +1299,375 @@ interface EdgeFunctionExecution {
|
|
|
1292
1299
|
executed_at: string;
|
|
1293
1300
|
completed_at?: string;
|
|
1294
1301
|
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Function specification for bulk sync operations
|
|
1304
|
+
*/
|
|
1305
|
+
interface FunctionSpec {
|
|
1306
|
+
name: string;
|
|
1307
|
+
description?: string;
|
|
1308
|
+
code: string;
|
|
1309
|
+
enabled?: boolean;
|
|
1310
|
+
timeout_seconds?: number;
|
|
1311
|
+
memory_limit_mb?: number;
|
|
1312
|
+
allow_net?: boolean;
|
|
1313
|
+
allow_env?: boolean;
|
|
1314
|
+
allow_read?: boolean;
|
|
1315
|
+
allow_write?: boolean;
|
|
1316
|
+
allow_unauthenticated?: boolean;
|
|
1317
|
+
is_public?: boolean;
|
|
1318
|
+
cron_schedule?: string;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Options for syncing functions
|
|
1322
|
+
*/
|
|
1323
|
+
interface SyncFunctionsOptions {
|
|
1324
|
+
/** Namespace to sync functions to (defaults to "default") */
|
|
1325
|
+
namespace?: string;
|
|
1326
|
+
/** Functions to sync */
|
|
1327
|
+
functions: FunctionSpec[];
|
|
1328
|
+
/** Options for sync operation */
|
|
1329
|
+
options?: {
|
|
1330
|
+
/** Delete functions in namespace that are not in the sync payload */
|
|
1331
|
+
delete_missing?: boolean;
|
|
1332
|
+
/** Preview changes without applying them */
|
|
1333
|
+
dry_run?: boolean;
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Sync operation error details
|
|
1338
|
+
*/
|
|
1339
|
+
interface SyncError {
|
|
1340
|
+
/** Name of the function that failed */
|
|
1341
|
+
function: string;
|
|
1342
|
+
/** Error message */
|
|
1343
|
+
error: string;
|
|
1344
|
+
/** Operation that failed */
|
|
1345
|
+
action: 'create' | 'update' | 'delete' | 'bundle';
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Result of a function sync operation
|
|
1349
|
+
*/
|
|
1350
|
+
interface SyncFunctionsResult {
|
|
1351
|
+
/** Status message */
|
|
1352
|
+
message: string;
|
|
1353
|
+
/** Namespace that was synced */
|
|
1354
|
+
namespace: string;
|
|
1355
|
+
/** Summary counts */
|
|
1356
|
+
summary: {
|
|
1357
|
+
created: number;
|
|
1358
|
+
updated: number;
|
|
1359
|
+
deleted: number;
|
|
1360
|
+
unchanged: number;
|
|
1361
|
+
errors: number;
|
|
1362
|
+
};
|
|
1363
|
+
/** Detailed results */
|
|
1364
|
+
details: {
|
|
1365
|
+
created: string[];
|
|
1366
|
+
updated: string[];
|
|
1367
|
+
deleted: string[];
|
|
1368
|
+
unchanged: string[];
|
|
1369
|
+
};
|
|
1370
|
+
/** Errors encountered */
|
|
1371
|
+
errors: SyncError[];
|
|
1372
|
+
/** Whether this was a dry run */
|
|
1373
|
+
dry_run: boolean;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Job function metadata
|
|
1377
|
+
*/
|
|
1378
|
+
interface JobFunction {
|
|
1379
|
+
id: string;
|
|
1380
|
+
name: string;
|
|
1381
|
+
namespace: string;
|
|
1382
|
+
description?: string;
|
|
1383
|
+
code?: string;
|
|
1384
|
+
original_code?: string;
|
|
1385
|
+
is_bundled: boolean;
|
|
1386
|
+
bundle_error?: string;
|
|
1387
|
+
enabled: boolean;
|
|
1388
|
+
schedule?: string;
|
|
1389
|
+
timeout_seconds: number;
|
|
1390
|
+
memory_limit_mb: number;
|
|
1391
|
+
max_retries: number;
|
|
1392
|
+
progress_timeout_seconds: number;
|
|
1393
|
+
allow_net: boolean;
|
|
1394
|
+
allow_env: boolean;
|
|
1395
|
+
allow_read: boolean;
|
|
1396
|
+
allow_write: boolean;
|
|
1397
|
+
require_role?: string;
|
|
1398
|
+
version: number;
|
|
1399
|
+
created_by?: string;
|
|
1400
|
+
created_at: string;
|
|
1401
|
+
updated_at: string;
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Request to create a new job function
|
|
1405
|
+
*/
|
|
1406
|
+
interface CreateJobFunctionRequest {
|
|
1407
|
+
name: string;
|
|
1408
|
+
namespace?: string;
|
|
1409
|
+
description?: string;
|
|
1410
|
+
code: string;
|
|
1411
|
+
enabled?: boolean;
|
|
1412
|
+
schedule?: string;
|
|
1413
|
+
timeout_seconds?: number;
|
|
1414
|
+
memory_limit_mb?: number;
|
|
1415
|
+
max_retries?: number;
|
|
1416
|
+
progress_timeout_seconds?: number;
|
|
1417
|
+
allow_net?: boolean;
|
|
1418
|
+
allow_env?: boolean;
|
|
1419
|
+
allow_read?: boolean;
|
|
1420
|
+
allow_write?: boolean;
|
|
1421
|
+
require_role?: string;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Request to update an existing job function
|
|
1425
|
+
*/
|
|
1426
|
+
interface UpdateJobFunctionRequest {
|
|
1427
|
+
description?: string;
|
|
1428
|
+
code?: string;
|
|
1429
|
+
enabled?: boolean;
|
|
1430
|
+
schedule?: string;
|
|
1431
|
+
timeout_seconds?: number;
|
|
1432
|
+
memory_limit_mb?: number;
|
|
1433
|
+
max_retries?: number;
|
|
1434
|
+
progress_timeout_seconds?: number;
|
|
1435
|
+
allow_net?: boolean;
|
|
1436
|
+
allow_env?: boolean;
|
|
1437
|
+
allow_read?: boolean;
|
|
1438
|
+
allow_write?: boolean;
|
|
1439
|
+
require_role?: string;
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Job execution status
|
|
1443
|
+
*/
|
|
1444
|
+
type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timeout';
|
|
1445
|
+
/**
|
|
1446
|
+
* Job execution record
|
|
1447
|
+
*/
|
|
1448
|
+
interface Job {
|
|
1449
|
+
id: string;
|
|
1450
|
+
namespace: string;
|
|
1451
|
+
job_function_id?: string;
|
|
1452
|
+
job_name: string;
|
|
1453
|
+
status: JobStatus;
|
|
1454
|
+
payload?: any;
|
|
1455
|
+
result?: any;
|
|
1456
|
+
error?: string;
|
|
1457
|
+
logs?: string;
|
|
1458
|
+
priority: number;
|
|
1459
|
+
max_duration_seconds?: number;
|
|
1460
|
+
progress_timeout_seconds?: number;
|
|
1461
|
+
progress_percent?: number;
|
|
1462
|
+
progress_message?: string;
|
|
1463
|
+
progress_data?: any;
|
|
1464
|
+
max_retries: number;
|
|
1465
|
+
retry_count: number;
|
|
1466
|
+
worker_id?: string;
|
|
1467
|
+
created_by?: string;
|
|
1468
|
+
user_role?: string;
|
|
1469
|
+
user_email?: string;
|
|
1470
|
+
created_at: string;
|
|
1471
|
+
started_at?: string;
|
|
1472
|
+
completed_at?: string;
|
|
1473
|
+
scheduled_at?: string;
|
|
1474
|
+
last_progress_at?: string;
|
|
1475
|
+
/** Estimated completion time (computed, only for running jobs with progress > 0) */
|
|
1476
|
+
estimated_completion_at?: string;
|
|
1477
|
+
/** Estimated seconds remaining (computed, only for running jobs with progress > 0) */
|
|
1478
|
+
estimated_seconds_left?: number;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Job statistics
|
|
1482
|
+
*/
|
|
1483
|
+
interface JobStats {
|
|
1484
|
+
namespace?: string;
|
|
1485
|
+
pending: number;
|
|
1486
|
+
running: number;
|
|
1487
|
+
completed: number;
|
|
1488
|
+
failed: number;
|
|
1489
|
+
cancelled: number;
|
|
1490
|
+
total: number;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Job worker information
|
|
1494
|
+
*/
|
|
1495
|
+
interface JobWorker {
|
|
1496
|
+
id: string;
|
|
1497
|
+
hostname: string;
|
|
1498
|
+
status: 'active' | 'idle' | 'dead';
|
|
1499
|
+
current_jobs: number;
|
|
1500
|
+
total_completed: number;
|
|
1501
|
+
started_at: string;
|
|
1502
|
+
last_heartbeat_at: string;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Job function specification for sync operations
|
|
1506
|
+
*/
|
|
1507
|
+
interface JobFunctionSpec {
|
|
1508
|
+
name: string;
|
|
1509
|
+
description?: string;
|
|
1510
|
+
code: string;
|
|
1511
|
+
/** If true, code is already bundled and server will skip bundling */
|
|
1512
|
+
is_pre_bundled?: boolean;
|
|
1513
|
+
/** Original source code (for debugging when pre-bundled) */
|
|
1514
|
+
original_code?: string;
|
|
1515
|
+
enabled?: boolean;
|
|
1516
|
+
schedule?: string;
|
|
1517
|
+
timeout_seconds?: number;
|
|
1518
|
+
memory_limit_mb?: number;
|
|
1519
|
+
max_retries?: number;
|
|
1520
|
+
progress_timeout_seconds?: number;
|
|
1521
|
+
allow_net?: boolean;
|
|
1522
|
+
allow_env?: boolean;
|
|
1523
|
+
allow_read?: boolean;
|
|
1524
|
+
allow_write?: boolean;
|
|
1525
|
+
require_role?: string;
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Options for syncing job functions
|
|
1529
|
+
*/
|
|
1530
|
+
interface SyncJobsOptions {
|
|
1531
|
+
namespace: string;
|
|
1532
|
+
functions?: JobFunctionSpec[];
|
|
1533
|
+
options?: {
|
|
1534
|
+
delete_missing?: boolean;
|
|
1535
|
+
dry_run?: boolean;
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Result of a job sync operation
|
|
1540
|
+
*/
|
|
1541
|
+
interface SyncJobsResult {
|
|
1542
|
+
message: string;
|
|
1543
|
+
namespace: string;
|
|
1544
|
+
summary: {
|
|
1545
|
+
created: number;
|
|
1546
|
+
updated: number;
|
|
1547
|
+
deleted: number;
|
|
1548
|
+
unchanged: number;
|
|
1549
|
+
errors: number;
|
|
1550
|
+
};
|
|
1551
|
+
details: {
|
|
1552
|
+
created: string[];
|
|
1553
|
+
updated: string[];
|
|
1554
|
+
deleted: string[];
|
|
1555
|
+
unchanged: string[];
|
|
1556
|
+
};
|
|
1557
|
+
errors: SyncError[];
|
|
1558
|
+
dry_run: boolean;
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Database migration metadata
|
|
1562
|
+
*/
|
|
1563
|
+
interface Migration {
|
|
1564
|
+
id: string;
|
|
1565
|
+
namespace: string;
|
|
1566
|
+
name: string;
|
|
1567
|
+
description?: string;
|
|
1568
|
+
up_sql: string;
|
|
1569
|
+
down_sql?: string;
|
|
1570
|
+
version: number;
|
|
1571
|
+
status: 'pending' | 'applied' | 'failed' | 'rolled_back';
|
|
1572
|
+
created_by?: string;
|
|
1573
|
+
applied_by?: string;
|
|
1574
|
+
created_at: string;
|
|
1575
|
+
updated_at: string;
|
|
1576
|
+
applied_at?: string;
|
|
1577
|
+
rolled_back_at?: string;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Request to create a new migration
|
|
1581
|
+
*/
|
|
1582
|
+
interface CreateMigrationRequest {
|
|
1583
|
+
namespace?: string;
|
|
1584
|
+
name: string;
|
|
1585
|
+
description?: string;
|
|
1586
|
+
up_sql: string;
|
|
1587
|
+
down_sql?: string;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Request to update a migration (only if pending)
|
|
1591
|
+
*/
|
|
1592
|
+
interface UpdateMigrationRequest {
|
|
1593
|
+
description?: string;
|
|
1594
|
+
up_sql?: string;
|
|
1595
|
+
down_sql?: string;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Migration execution record (audit log)
|
|
1599
|
+
*/
|
|
1600
|
+
interface MigrationExecution {
|
|
1601
|
+
id: string;
|
|
1602
|
+
migration_id: string;
|
|
1603
|
+
action: 'apply' | 'rollback';
|
|
1604
|
+
status: 'success' | 'failed';
|
|
1605
|
+
duration_ms?: number;
|
|
1606
|
+
error_message?: string;
|
|
1607
|
+
logs?: string;
|
|
1608
|
+
executed_at: string;
|
|
1609
|
+
executed_by?: string;
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Request to apply a migration
|
|
1613
|
+
*/
|
|
1614
|
+
interface ApplyMigrationRequest {
|
|
1615
|
+
namespace?: string;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Request to rollback a migration
|
|
1619
|
+
*/
|
|
1620
|
+
interface RollbackMigrationRequest {
|
|
1621
|
+
namespace?: string;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Request to apply pending migrations
|
|
1625
|
+
*/
|
|
1626
|
+
interface ApplyPendingRequest {
|
|
1627
|
+
namespace?: string;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Options for syncing migrations
|
|
1631
|
+
*/
|
|
1632
|
+
interface SyncMigrationsOptions {
|
|
1633
|
+
/** Update pending migrations if SQL content changed */
|
|
1634
|
+
update_if_changed?: boolean;
|
|
1635
|
+
/** Automatically apply new migrations after sync */
|
|
1636
|
+
auto_apply?: boolean;
|
|
1637
|
+
/** Preview changes without applying them */
|
|
1638
|
+
dry_run?: boolean;
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Result of a migration sync operation
|
|
1642
|
+
*/
|
|
1643
|
+
interface SyncMigrationsResult {
|
|
1644
|
+
/** Status message */
|
|
1645
|
+
message: string;
|
|
1646
|
+
/** Namespace that was synced */
|
|
1647
|
+
namespace: string;
|
|
1648
|
+
/** Summary counts */
|
|
1649
|
+
summary: {
|
|
1650
|
+
created: number;
|
|
1651
|
+
updated: number;
|
|
1652
|
+
unchanged: number;
|
|
1653
|
+
skipped: number;
|
|
1654
|
+
applied: number;
|
|
1655
|
+
errors: number;
|
|
1656
|
+
};
|
|
1657
|
+
/** Detailed results */
|
|
1658
|
+
details: {
|
|
1659
|
+
created: string[];
|
|
1660
|
+
updated: string[];
|
|
1661
|
+
unchanged: string[];
|
|
1662
|
+
skipped: string[];
|
|
1663
|
+
applied: string[];
|
|
1664
|
+
errors: string[];
|
|
1665
|
+
};
|
|
1666
|
+
/** Whether this was a dry run */
|
|
1667
|
+
dry_run: boolean;
|
|
1668
|
+
/** Warning messages */
|
|
1669
|
+
warnings?: string[];
|
|
1670
|
+
}
|
|
1295
1671
|
/**
|
|
1296
1672
|
* Base Fluxbase response type (Supabase-compatible)
|
|
1297
1673
|
* Returns either `{ data, error: null }` on success or `{ data: null, error }` on failure
|
|
@@ -1365,6 +1741,7 @@ declare class RealtimeChannel {
|
|
|
1365
1741
|
private presenceCallbacks;
|
|
1366
1742
|
private broadcastCallbacks;
|
|
1367
1743
|
private subscriptionConfig;
|
|
1744
|
+
private subscriptionId;
|
|
1368
1745
|
private _presenceState;
|
|
1369
1746
|
private myPresenceKey;
|
|
1370
1747
|
private config;
|
|
@@ -2159,9 +2536,11 @@ declare class FluxbaseStorage {
|
|
|
2159
2536
|
*/
|
|
2160
2537
|
|
|
2161
2538
|
/**
|
|
2162
|
-
* Edge Functions client for invoking
|
|
2539
|
+
* Edge Functions client for invoking serverless functions
|
|
2163
2540
|
* API-compatible with Supabase Functions
|
|
2164
2541
|
*
|
|
2542
|
+
* For admin operations (create, update, delete, sync), use client.admin.functions
|
|
2543
|
+
*
|
|
2165
2544
|
* @category Functions
|
|
2166
2545
|
*/
|
|
2167
2546
|
declare class FluxbaseFunctions {
|
|
@@ -2173,16 +2552,22 @@ declare class FluxbaseFunctions {
|
|
|
2173
2552
|
* This method is fully compatible with Supabase's functions.invoke() API.
|
|
2174
2553
|
*
|
|
2175
2554
|
* @param functionName - The name of the function to invoke
|
|
2176
|
-
* @param options - Invocation options including body, headers,
|
|
2555
|
+
* @param options - Invocation options including body, headers, HTTP method, and namespace
|
|
2177
2556
|
* @returns Promise resolving to { data, error } tuple
|
|
2178
2557
|
*
|
|
2179
2558
|
* @example
|
|
2180
2559
|
* ```typescript
|
|
2181
|
-
* // Simple invocation
|
|
2560
|
+
* // Simple invocation (uses first matching function by namespace alphabetically)
|
|
2182
2561
|
* const { data, error } = await client.functions.invoke('hello', {
|
|
2183
2562
|
* body: { name: 'World' }
|
|
2184
2563
|
* })
|
|
2185
2564
|
*
|
|
2565
|
+
* // Invoke a specific namespace's function
|
|
2566
|
+
* const { data, error } = await client.functions.invoke('hello', {
|
|
2567
|
+
* body: { name: 'World' },
|
|
2568
|
+
* namespace: 'my-app'
|
|
2569
|
+
* })
|
|
2570
|
+
*
|
|
2186
2571
|
* // With GET method
|
|
2187
2572
|
* const { data, error } = await client.functions.invoke('get-data', {
|
|
2188
2573
|
* method: 'GET'
|
|
@@ -2201,28 +2586,9 @@ declare class FluxbaseFunctions {
|
|
|
2201
2586
|
error: Error | null;
|
|
2202
2587
|
}>;
|
|
2203
2588
|
/**
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
* @param request - Function configuration and code
|
|
2207
|
-
* @returns Promise resolving to { data, error } tuple with created function metadata
|
|
2208
|
-
*
|
|
2209
|
-
* @example
|
|
2210
|
-
* ```typescript
|
|
2211
|
-
* const { data, error } = await client.functions.create({
|
|
2212
|
-
* name: 'my-function',
|
|
2213
|
-
* code: 'export default async function handler(req) { return { hello: "world" } }',
|
|
2214
|
-
* enabled: true
|
|
2215
|
-
* })
|
|
2216
|
-
* ```
|
|
2217
|
-
*/
|
|
2218
|
-
create(request: CreateFunctionRequest): Promise<{
|
|
2219
|
-
data: EdgeFunction | null;
|
|
2220
|
-
error: Error | null;
|
|
2221
|
-
}>;
|
|
2222
|
-
/**
|
|
2223
|
-
* List all edge functions
|
|
2589
|
+
* List all public edge functions
|
|
2224
2590
|
*
|
|
2225
|
-
* @returns Promise resolving to { data, error } tuple with array of functions
|
|
2591
|
+
* @returns Promise resolving to { data, error } tuple with array of public functions
|
|
2226
2592
|
*
|
|
2227
2593
|
* @example
|
|
2228
2594
|
* ```typescript
|
|
@@ -2254,65 +2620,178 @@ declare class FluxbaseFunctions {
|
|
|
2254
2620
|
data: EdgeFunction | null;
|
|
2255
2621
|
error: Error | null;
|
|
2256
2622
|
}>;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
/**
|
|
2626
|
+
* Jobs module for Fluxbase SDK
|
|
2627
|
+
* Client-facing API for submitting and monitoring background jobs
|
|
2628
|
+
*
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```typescript
|
|
2631
|
+
* // Submit a job
|
|
2632
|
+
* const { data, error } = await client.jobs.submit('process-data', {
|
|
2633
|
+
* items: [1, 2, 3]
|
|
2634
|
+
* })
|
|
2635
|
+
*
|
|
2636
|
+
* // Get job status
|
|
2637
|
+
* const { data: job, error } = await client.jobs.get(data.id)
|
|
2638
|
+
* console.log('Job status:', job.status)
|
|
2639
|
+
*
|
|
2640
|
+
* // Cancel a running job
|
|
2641
|
+
* await client.jobs.cancel(data.id)
|
|
2642
|
+
* ```
|
|
2643
|
+
*/
|
|
2644
|
+
|
|
2645
|
+
/**
|
|
2646
|
+
* Jobs client for submitting and monitoring background jobs
|
|
2647
|
+
*
|
|
2648
|
+
* For admin operations (create job functions, manage workers, view all jobs),
|
|
2649
|
+
* use client.admin.jobs
|
|
2650
|
+
*
|
|
2651
|
+
* @category Jobs
|
|
2652
|
+
*/
|
|
2653
|
+
declare class FluxbaseJobs {
|
|
2654
|
+
private fetch;
|
|
2655
|
+
constructor(fetch: FluxbaseFetch);
|
|
2257
2656
|
/**
|
|
2258
|
-
*
|
|
2657
|
+
* Submit a new job for execution
|
|
2259
2658
|
*
|
|
2260
|
-
* @param
|
|
2261
|
-
* @param
|
|
2262
|
-
* @
|
|
2659
|
+
* @param jobName - Name of the job function to execute
|
|
2660
|
+
* @param payload - Job input data
|
|
2661
|
+
* @param options - Additional options (priority, namespace, scheduled time)
|
|
2662
|
+
* @returns Promise resolving to { data, error } tuple with submitted job details
|
|
2263
2663
|
*
|
|
2264
2664
|
* @example
|
|
2265
2665
|
* ```typescript
|
|
2266
|
-
*
|
|
2267
|
-
*
|
|
2268
|
-
*
|
|
2666
|
+
* // Submit a simple job
|
|
2667
|
+
* const { data, error } = await client.jobs.submit('send-email', {
|
|
2668
|
+
* to: 'user@example.com',
|
|
2669
|
+
* subject: 'Hello',
|
|
2670
|
+
* body: 'Welcome!'
|
|
2671
|
+
* })
|
|
2672
|
+
*
|
|
2673
|
+
* if (data) {
|
|
2674
|
+
* console.log('Job submitted:', data.id)
|
|
2675
|
+
* console.log('Status:', data.status)
|
|
2676
|
+
* }
|
|
2677
|
+
*
|
|
2678
|
+
* // Submit with priority
|
|
2679
|
+
* const { data } = await client.jobs.submit('high-priority-task', payload, {
|
|
2680
|
+
* priority: 10
|
|
2681
|
+
* })
|
|
2682
|
+
*
|
|
2683
|
+
* // Schedule for later
|
|
2684
|
+
* const { data } = await client.jobs.submit('scheduled-task', payload, {
|
|
2685
|
+
* scheduled: '2025-01-01T00:00:00Z'
|
|
2269
2686
|
* })
|
|
2270
2687
|
* ```
|
|
2271
2688
|
*/
|
|
2272
|
-
|
|
2273
|
-
|
|
2689
|
+
submit(jobName: string, payload?: any, options?: {
|
|
2690
|
+
priority?: number;
|
|
2691
|
+
namespace?: string;
|
|
2692
|
+
scheduled?: string;
|
|
2693
|
+
}): Promise<{
|
|
2694
|
+
data: Job | null;
|
|
2274
2695
|
error: Error | null;
|
|
2275
2696
|
}>;
|
|
2276
2697
|
/**
|
|
2277
|
-
*
|
|
2698
|
+
* Get status and details of a specific job
|
|
2278
2699
|
*
|
|
2279
|
-
* @param
|
|
2280
|
-
* @returns Promise resolving to { data, error } tuple
|
|
2700
|
+
* @param jobId - Job ID
|
|
2701
|
+
* @returns Promise resolving to { data, error } tuple with job details
|
|
2702
|
+
*
|
|
2703
|
+
* @example
|
|
2704
|
+
* ```typescript
|
|
2705
|
+
* const { data: job, error } = await client.jobs.get('550e8400-e29b-41d4-a716-446655440000')
|
|
2706
|
+
*
|
|
2707
|
+
* if (job) {
|
|
2708
|
+
* console.log('Status:', job.status)
|
|
2709
|
+
* console.log('Progress:', job.progress_percent + '%')
|
|
2710
|
+
* console.log('Result:', job.result)
|
|
2711
|
+
* console.log('Logs:', job.logs)
|
|
2712
|
+
* }
|
|
2713
|
+
* ```
|
|
2714
|
+
*/
|
|
2715
|
+
get(jobId: string): Promise<{
|
|
2716
|
+
data: Job | null;
|
|
2717
|
+
error: Error | null;
|
|
2718
|
+
}>;
|
|
2719
|
+
/**
|
|
2720
|
+
* List jobs submitted by the current user
|
|
2721
|
+
*
|
|
2722
|
+
* @param filters - Optional filters (status, namespace, limit, offset)
|
|
2723
|
+
* @returns Promise resolving to { data, error } tuple with array of jobs
|
|
2281
2724
|
*
|
|
2282
2725
|
* @example
|
|
2283
2726
|
* ```typescript
|
|
2284
|
-
*
|
|
2727
|
+
* // List all your jobs
|
|
2728
|
+
* const { data: jobs, error } = await client.jobs.list()
|
|
2729
|
+
*
|
|
2730
|
+
* // Filter by status
|
|
2731
|
+
* const { data: running } = await client.jobs.list({
|
|
2732
|
+
* status: 'running'
|
|
2733
|
+
* })
|
|
2734
|
+
*
|
|
2735
|
+
* // Paginate
|
|
2736
|
+
* const { data: page } = await client.jobs.list({
|
|
2737
|
+
* limit: 20,
|
|
2738
|
+
* offset: 40
|
|
2739
|
+
* })
|
|
2285
2740
|
* ```
|
|
2286
2741
|
*/
|
|
2287
|
-
|
|
2288
|
-
|
|
2742
|
+
list(filters?: {
|
|
2743
|
+
status?: string;
|
|
2744
|
+
namespace?: string;
|
|
2745
|
+
limit?: number;
|
|
2746
|
+
offset?: number;
|
|
2747
|
+
}): Promise<{
|
|
2748
|
+
data: Job[] | null;
|
|
2289
2749
|
error: Error | null;
|
|
2290
2750
|
}>;
|
|
2291
2751
|
/**
|
|
2292
|
-
*
|
|
2752
|
+
* Cancel a pending or running job
|
|
2293
2753
|
*
|
|
2294
|
-
* @param
|
|
2295
|
-
* @
|
|
2296
|
-
* @returns Promise resolving to { data, error } tuple with execution records
|
|
2754
|
+
* @param jobId - Job ID to cancel
|
|
2755
|
+
* @returns Promise resolving to { data, error } tuple
|
|
2297
2756
|
*
|
|
2298
2757
|
* @example
|
|
2299
2758
|
* ```typescript
|
|
2300
|
-
* const {
|
|
2301
|
-
*
|
|
2302
|
-
*
|
|
2303
|
-
*
|
|
2304
|
-
* })
|
|
2759
|
+
* const { error } = await client.jobs.cancel('550e8400-e29b-41d4-a716-446655440000')
|
|
2760
|
+
*
|
|
2761
|
+
* if (!error) {
|
|
2762
|
+
* console.log('Job cancelled successfully')
|
|
2305
2763
|
* }
|
|
2306
2764
|
* ```
|
|
2307
2765
|
*/
|
|
2308
|
-
|
|
2309
|
-
data:
|
|
2766
|
+
cancel(jobId: string): Promise<{
|
|
2767
|
+
data: null;
|
|
2310
2768
|
error: Error | null;
|
|
2311
2769
|
}>;
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2770
|
+
/**
|
|
2771
|
+
* Retry a failed job
|
|
2772
|
+
*
|
|
2773
|
+
* Creates a new job execution with the same parameters
|
|
2774
|
+
*
|
|
2775
|
+
* @param jobId - Job ID to retry
|
|
2776
|
+
* @returns Promise resolving to { data, error } tuple with new job
|
|
2777
|
+
*
|
|
2778
|
+
* @example
|
|
2779
|
+
* ```typescript
|
|
2780
|
+
* const { data: newJob, error } = await client.jobs.retry('550e8400-e29b-41d4-a716-446655440000')
|
|
2781
|
+
*
|
|
2782
|
+
* if (newJob) {
|
|
2783
|
+
* console.log('Job retried, new ID:', newJob.id)
|
|
2784
|
+
* }
|
|
2785
|
+
* ```
|
|
2786
|
+
*/
|
|
2787
|
+
retry(jobId: string): Promise<{
|
|
2788
|
+
data: Job | null;
|
|
2789
|
+
error: Error | null;
|
|
2790
|
+
}>;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/**
|
|
2794
|
+
* System Settings Manager
|
|
2316
2795
|
*
|
|
2317
2796
|
* Manages low-level system settings with key-value storage.
|
|
2318
2797
|
* For application-level settings, use AppSettingsManager instead.
|
|
@@ -4137,35 +4616,907 @@ declare class FluxbaseManagement {
|
|
|
4137
4616
|
}
|
|
4138
4617
|
|
|
4139
4618
|
/**
|
|
4140
|
-
* Admin
|
|
4619
|
+
* Admin Functions module for managing edge functions
|
|
4620
|
+
* Provides administrative operations for function lifecycle management
|
|
4141
4621
|
*/
|
|
4142
|
-
|
|
4622
|
+
|
|
4623
|
+
/**
|
|
4624
|
+
* Admin Functions manager for managing edge functions
|
|
4625
|
+
* Provides create, update, delete, and bulk sync operations
|
|
4626
|
+
*
|
|
4627
|
+
* @category Admin
|
|
4628
|
+
*/
|
|
4629
|
+
declare class FluxbaseAdminFunctions {
|
|
4143
4630
|
private fetch;
|
|
4144
|
-
|
|
4631
|
+
constructor(fetch: FluxbaseFetch);
|
|
4145
4632
|
/**
|
|
4146
|
-
*
|
|
4633
|
+
* Create a new edge function
|
|
4634
|
+
*
|
|
4635
|
+
* @param request - Function configuration and code
|
|
4636
|
+
* @returns Promise resolving to { data, error } tuple with created function metadata
|
|
4637
|
+
*
|
|
4638
|
+
* @example
|
|
4639
|
+
* ```typescript
|
|
4640
|
+
* const { data, error } = await client.admin.functions.create({
|
|
4641
|
+
* name: 'my-function',
|
|
4642
|
+
* code: 'export default async function handler(req) { return { hello: "world" } }',
|
|
4643
|
+
* enabled: true
|
|
4644
|
+
* })
|
|
4645
|
+
* ```
|
|
4147
4646
|
*/
|
|
4148
|
-
|
|
4647
|
+
create(request: CreateFunctionRequest): Promise<{
|
|
4648
|
+
data: EdgeFunction | null;
|
|
4649
|
+
error: Error | null;
|
|
4650
|
+
}>;
|
|
4149
4651
|
/**
|
|
4150
|
-
*
|
|
4652
|
+
* List all namespaces that have edge functions
|
|
4653
|
+
*
|
|
4654
|
+
* @returns Promise resolving to { data, error } tuple with array of namespace strings
|
|
4655
|
+
*
|
|
4656
|
+
* @example
|
|
4657
|
+
* ```typescript
|
|
4658
|
+
* const { data, error } = await client.admin.functions.listNamespaces()
|
|
4659
|
+
* if (data) {
|
|
4660
|
+
* console.log('Available namespaces:', data)
|
|
4661
|
+
* }
|
|
4662
|
+
* ```
|
|
4151
4663
|
*/
|
|
4152
|
-
|
|
4664
|
+
listNamespaces(): Promise<{
|
|
4665
|
+
data: string[] | null;
|
|
4666
|
+
error: Error | null;
|
|
4667
|
+
}>;
|
|
4153
4668
|
/**
|
|
4154
|
-
*
|
|
4669
|
+
* List all edge functions (admin view)
|
|
4670
|
+
*
|
|
4671
|
+
* @param namespace - Optional namespace filter (if not provided, lists all public functions)
|
|
4672
|
+
* @returns Promise resolving to { data, error } tuple with array of functions
|
|
4673
|
+
*
|
|
4674
|
+
* @example
|
|
4675
|
+
* ```typescript
|
|
4676
|
+
* // List all public functions
|
|
4677
|
+
* const { data, error } = await client.admin.functions.list()
|
|
4678
|
+
*
|
|
4679
|
+
* // List functions in a specific namespace
|
|
4680
|
+
* const { data, error } = await client.admin.functions.list('my-namespace')
|
|
4681
|
+
* if (data) {
|
|
4682
|
+
* console.log('Functions:', data.map(f => f.name))
|
|
4683
|
+
* }
|
|
4684
|
+
* ```
|
|
4155
4685
|
*/
|
|
4156
|
-
|
|
4686
|
+
list(namespace?: string): Promise<{
|
|
4687
|
+
data: EdgeFunction[] | null;
|
|
4688
|
+
error: Error | null;
|
|
4689
|
+
}>;
|
|
4157
4690
|
/**
|
|
4158
|
-
*
|
|
4691
|
+
* Get details of a specific edge function
|
|
4692
|
+
*
|
|
4693
|
+
* @param name - Function name
|
|
4694
|
+
* @returns Promise resolving to { data, error } tuple with function metadata
|
|
4695
|
+
*
|
|
4696
|
+
* @example
|
|
4697
|
+
* ```typescript
|
|
4698
|
+
* const { data, error } = await client.admin.functions.get('my-function')
|
|
4699
|
+
* if (data) {
|
|
4700
|
+
* console.log('Function version:', data.version)
|
|
4701
|
+
* }
|
|
4702
|
+
* ```
|
|
4159
4703
|
*/
|
|
4160
|
-
|
|
4704
|
+
get(name: string): Promise<{
|
|
4705
|
+
data: EdgeFunction | null;
|
|
4706
|
+
error: Error | null;
|
|
4707
|
+
}>;
|
|
4161
4708
|
/**
|
|
4162
|
-
*
|
|
4709
|
+
* Update an existing edge function
|
|
4710
|
+
*
|
|
4711
|
+
* @param name - Function name
|
|
4712
|
+
* @param updates - Fields to update
|
|
4713
|
+
* @returns Promise resolving to { data, error } tuple with updated function metadata
|
|
4714
|
+
*
|
|
4715
|
+
* @example
|
|
4716
|
+
* ```typescript
|
|
4717
|
+
* const { data, error } = await client.admin.functions.update('my-function', {
|
|
4718
|
+
* enabled: false,
|
|
4719
|
+
* description: 'Updated description'
|
|
4720
|
+
* })
|
|
4721
|
+
* ```
|
|
4163
4722
|
*/
|
|
4164
|
-
|
|
4723
|
+
update(name: string, updates: UpdateFunctionRequest): Promise<{
|
|
4724
|
+
data: EdgeFunction | null;
|
|
4725
|
+
error: Error | null;
|
|
4726
|
+
}>;
|
|
4165
4727
|
/**
|
|
4166
|
-
*
|
|
4728
|
+
* Delete an edge function
|
|
4729
|
+
*
|
|
4730
|
+
* @param name - Function name
|
|
4731
|
+
* @returns Promise resolving to { data, error } tuple
|
|
4732
|
+
*
|
|
4733
|
+
* @example
|
|
4734
|
+
* ```typescript
|
|
4735
|
+
* const { data, error } = await client.admin.functions.delete('my-function')
|
|
4736
|
+
* ```
|
|
4167
4737
|
*/
|
|
4168
|
-
|
|
4738
|
+
delete(name: string): Promise<{
|
|
4739
|
+
data: null;
|
|
4740
|
+
error: Error | null;
|
|
4741
|
+
}>;
|
|
4742
|
+
/**
|
|
4743
|
+
* Get execution history for an edge function
|
|
4744
|
+
*
|
|
4745
|
+
* @param name - Function name
|
|
4746
|
+
* @param limit - Maximum number of executions to return (optional)
|
|
4747
|
+
* @returns Promise resolving to { data, error } tuple with execution records
|
|
4748
|
+
*
|
|
4749
|
+
* @example
|
|
4750
|
+
* ```typescript
|
|
4751
|
+
* const { data, error } = await client.admin.functions.getExecutions('my-function', 10)
|
|
4752
|
+
* if (data) {
|
|
4753
|
+
* data.forEach(exec => {
|
|
4754
|
+
* console.log(`${exec.executed_at}: ${exec.status} (${exec.duration_ms}ms)`)
|
|
4755
|
+
* })
|
|
4756
|
+
* }
|
|
4757
|
+
* ```
|
|
4758
|
+
*/
|
|
4759
|
+
getExecutions(name: string, limit?: number): Promise<{
|
|
4760
|
+
data: EdgeFunctionExecution[] | null;
|
|
4761
|
+
error: Error | null;
|
|
4762
|
+
}>;
|
|
4763
|
+
/**
|
|
4764
|
+
* Sync multiple functions to a namespace
|
|
4765
|
+
*
|
|
4766
|
+
* Bulk create/update/delete functions in a specific namespace. This is useful for
|
|
4767
|
+
* deploying functions from your application to Fluxbase in Kubernetes or other
|
|
4768
|
+
* container environments.
|
|
4769
|
+
*
|
|
4770
|
+
* Requires service_role or admin authentication.
|
|
4771
|
+
*
|
|
4772
|
+
* @param options - Sync configuration including namespace, functions, and options
|
|
4773
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
4774
|
+
*
|
|
4775
|
+
* @example
|
|
4776
|
+
* ```typescript
|
|
4777
|
+
* // Sync functions to "payment-service" namespace
|
|
4778
|
+
* const { data, error } = await client.admin.functions.sync({
|
|
4779
|
+
* namespace: 'payment-service',
|
|
4780
|
+
* functions: [
|
|
4781
|
+
* {
|
|
4782
|
+
* name: 'process-payment',
|
|
4783
|
+
* code: 'export default async function handler(req) { ... }',
|
|
4784
|
+
* enabled: true,
|
|
4785
|
+
* allow_net: true
|
|
4786
|
+
* },
|
|
4787
|
+
* {
|
|
4788
|
+
* name: 'refund-payment',
|
|
4789
|
+
* code: 'export default async function handler(req) { ... }',
|
|
4790
|
+
* enabled: true
|
|
4791
|
+
* }
|
|
4792
|
+
* ],
|
|
4793
|
+
* options: {
|
|
4794
|
+
* delete_missing: true // Remove functions not in this list
|
|
4795
|
+
* }
|
|
4796
|
+
* })
|
|
4797
|
+
*
|
|
4798
|
+
* if (data) {
|
|
4799
|
+
* console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
|
|
4800
|
+
* }
|
|
4801
|
+
*
|
|
4802
|
+
* // Dry run to preview changes
|
|
4803
|
+
* const { data, error } = await client.admin.functions.sync({
|
|
4804
|
+
* namespace: 'myapp',
|
|
4805
|
+
* functions: [...],
|
|
4806
|
+
* options: { dry_run: true }
|
|
4807
|
+
* })
|
|
4808
|
+
* ```
|
|
4809
|
+
*/
|
|
4810
|
+
sync(options: SyncFunctionsOptions): Promise<{
|
|
4811
|
+
data: SyncFunctionsResult | null;
|
|
4812
|
+
error: Error | null;
|
|
4813
|
+
}>;
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4816
|
+
/**
|
|
4817
|
+
* Admin Migrations module for managing database migrations
|
|
4818
|
+
* Provides API-based migration management without filesystem coupling
|
|
4819
|
+
*/
|
|
4820
|
+
|
|
4821
|
+
/**
|
|
4822
|
+
* Admin Migrations manager for database migration operations
|
|
4823
|
+
* Provides create, update, delete, apply, rollback, and smart sync operations
|
|
4824
|
+
*
|
|
4825
|
+
* @category Admin
|
|
4826
|
+
*/
|
|
4827
|
+
declare class FluxbaseAdminMigrations {
|
|
4828
|
+
private fetch;
|
|
4829
|
+
private localMigrations;
|
|
4830
|
+
constructor(fetch: FluxbaseFetch);
|
|
4831
|
+
/**
|
|
4832
|
+
* Register a migration locally for smart sync
|
|
4833
|
+
*
|
|
4834
|
+
* Call this method to register migrations in your application code.
|
|
4835
|
+
* When you call sync(), only new or changed migrations will be sent to the server.
|
|
4836
|
+
*
|
|
4837
|
+
* @param migration - Migration definition
|
|
4838
|
+
* @returns { error } tuple (always succeeds unless validation fails)
|
|
4839
|
+
*
|
|
4840
|
+
* @example
|
|
4841
|
+
* ```typescript
|
|
4842
|
+
* // In your app initialization
|
|
4843
|
+
* const { error: err1 } = client.admin.migrations.register({
|
|
4844
|
+
* name: '001_create_users_table',
|
|
4845
|
+
* namespace: 'myapp',
|
|
4846
|
+
* up_sql: 'CREATE TABLE app.users (...)',
|
|
4847
|
+
* down_sql: 'DROP TABLE app.users',
|
|
4848
|
+
* description: 'Initial users table'
|
|
4849
|
+
* })
|
|
4850
|
+
*
|
|
4851
|
+
* const { error: err2 } = client.admin.migrations.register({
|
|
4852
|
+
* name: '002_add_posts_table',
|
|
4853
|
+
* namespace: 'myapp',
|
|
4854
|
+
* up_sql: 'CREATE TABLE app.posts (...)',
|
|
4855
|
+
* down_sql: 'DROP TABLE app.posts'
|
|
4856
|
+
* })
|
|
4857
|
+
*
|
|
4858
|
+
* // Sync all registered migrations
|
|
4859
|
+
* await client.admin.migrations.sync()
|
|
4860
|
+
* ```
|
|
4861
|
+
*/
|
|
4862
|
+
register(migration: CreateMigrationRequest): {
|
|
4863
|
+
error: Error | null;
|
|
4864
|
+
};
|
|
4865
|
+
/**
|
|
4866
|
+
* Trigger schema refresh which will restart the server
|
|
4867
|
+
* Handles the restart gracefully by waiting for the server to come back online
|
|
4868
|
+
*
|
|
4869
|
+
* @private
|
|
4870
|
+
*/
|
|
4871
|
+
private triggerSchemaRefreshWithRestart;
|
|
4872
|
+
/**
|
|
4873
|
+
* Helper function to sleep for a given duration
|
|
4874
|
+
* @private
|
|
4875
|
+
*/
|
|
4876
|
+
private sleep;
|
|
4877
|
+
/**
|
|
4878
|
+
* Smart sync all registered migrations
|
|
4879
|
+
*
|
|
4880
|
+
* Automatically determines which migrations need to be created or updated by:
|
|
4881
|
+
* 1. Fetching existing migrations from the server
|
|
4882
|
+
* 2. Comparing content hashes to detect changes
|
|
4883
|
+
* 3. Only sending new or changed migrations
|
|
4884
|
+
*
|
|
4885
|
+
* After successful sync, can optionally auto-apply new migrations and refresh
|
|
4886
|
+
* the server's schema cache.
|
|
4887
|
+
*
|
|
4888
|
+
* @param options - Sync options
|
|
4889
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
4890
|
+
*
|
|
4891
|
+
* @example
|
|
4892
|
+
* ```typescript
|
|
4893
|
+
* // Basic sync (idempotent - safe to call on every app startup)
|
|
4894
|
+
* const { data, error } = await client.admin.migrations.sync()
|
|
4895
|
+
* if (data) {
|
|
4896
|
+
* console.log(`Created: ${data.summary.created}, Updated: ${data.summary.updated}`)
|
|
4897
|
+
* }
|
|
4898
|
+
*
|
|
4899
|
+
* // Sync with auto-apply (applies new migrations automatically)
|
|
4900
|
+
* const { data, error } = await client.admin.migrations.sync({
|
|
4901
|
+
* auto_apply: true
|
|
4902
|
+
* })
|
|
4903
|
+
*
|
|
4904
|
+
* // Dry run to preview changes without applying
|
|
4905
|
+
* const { data, error } = await client.admin.migrations.sync({
|
|
4906
|
+
* dry_run: true
|
|
4907
|
+
* })
|
|
4908
|
+
* ```
|
|
4909
|
+
*/
|
|
4910
|
+
sync(options?: Partial<SyncMigrationsOptions>): Promise<{
|
|
4911
|
+
data: SyncMigrationsResult | null;
|
|
4912
|
+
error: Error | null;
|
|
4913
|
+
}>;
|
|
4914
|
+
/**
|
|
4915
|
+
* Create a new migration
|
|
4916
|
+
*
|
|
4917
|
+
* @param request - Migration configuration
|
|
4918
|
+
* @returns Promise resolving to { data, error } tuple with created migration
|
|
4919
|
+
*
|
|
4920
|
+
* @example
|
|
4921
|
+
* ```typescript
|
|
4922
|
+
* const { data, error } = await client.admin.migrations.create({
|
|
4923
|
+
* namespace: 'myapp',
|
|
4924
|
+
* name: '001_create_users',
|
|
4925
|
+
* up_sql: 'CREATE TABLE app.users (id UUID PRIMARY KEY, email TEXT)',
|
|
4926
|
+
* down_sql: 'DROP TABLE app.users',
|
|
4927
|
+
* description: 'Create users table'
|
|
4928
|
+
* })
|
|
4929
|
+
* ```
|
|
4930
|
+
*/
|
|
4931
|
+
create(request: CreateMigrationRequest): Promise<{
|
|
4932
|
+
data: Migration | null;
|
|
4933
|
+
error: Error | null;
|
|
4934
|
+
}>;
|
|
4935
|
+
/**
|
|
4936
|
+
* List migrations in a namespace
|
|
4937
|
+
*
|
|
4938
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
4939
|
+
* @param status - Filter by status: 'pending', 'applied', 'failed', 'rolled_back'
|
|
4940
|
+
* @returns Promise resolving to { data, error } tuple with migrations array
|
|
4941
|
+
*
|
|
4942
|
+
* @example
|
|
4943
|
+
* ```typescript
|
|
4944
|
+
* // List all migrations
|
|
4945
|
+
* const { data, error } = await client.admin.migrations.list('myapp')
|
|
4946
|
+
*
|
|
4947
|
+
* // List only pending migrations
|
|
4948
|
+
* const { data, error } = await client.admin.migrations.list('myapp', 'pending')
|
|
4949
|
+
* ```
|
|
4950
|
+
*/
|
|
4951
|
+
list(namespace?: string, status?: 'pending' | 'applied' | 'failed' | 'rolled_back'): Promise<{
|
|
4952
|
+
data: Migration[] | null;
|
|
4953
|
+
error: Error | null;
|
|
4954
|
+
}>;
|
|
4955
|
+
/**
|
|
4956
|
+
* Get details of a specific migration
|
|
4957
|
+
*
|
|
4958
|
+
* @param name - Migration name
|
|
4959
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
4960
|
+
* @returns Promise resolving to { data, error } tuple with migration details
|
|
4961
|
+
*
|
|
4962
|
+
* @example
|
|
4963
|
+
* ```typescript
|
|
4964
|
+
* const { data, error } = await client.admin.migrations.get('001_create_users', 'myapp')
|
|
4965
|
+
* ```
|
|
4966
|
+
*/
|
|
4967
|
+
get(name: string, namespace?: string): Promise<{
|
|
4968
|
+
data: Migration | null;
|
|
4969
|
+
error: Error | null;
|
|
4970
|
+
}>;
|
|
4971
|
+
/**
|
|
4972
|
+
* Update a migration (only if status is pending)
|
|
4973
|
+
*
|
|
4974
|
+
* @param name - Migration name
|
|
4975
|
+
* @param updates - Fields to update
|
|
4976
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
4977
|
+
* @returns Promise resolving to { data, error } tuple with updated migration
|
|
4978
|
+
*
|
|
4979
|
+
* @example
|
|
4980
|
+
* ```typescript
|
|
4981
|
+
* const { data, error } = await client.admin.migrations.update(
|
|
4982
|
+
* '001_create_users',
|
|
4983
|
+
* { description: 'Updated description' },
|
|
4984
|
+
* 'myapp'
|
|
4985
|
+
* )
|
|
4986
|
+
* ```
|
|
4987
|
+
*/
|
|
4988
|
+
update(name: string, updates: UpdateMigrationRequest, namespace?: string): Promise<{
|
|
4989
|
+
data: Migration | null;
|
|
4990
|
+
error: Error | null;
|
|
4991
|
+
}>;
|
|
4992
|
+
/**
|
|
4993
|
+
* Delete a migration (only if status is pending)
|
|
4994
|
+
*
|
|
4995
|
+
* @param name - Migration name
|
|
4996
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
4997
|
+
* @returns Promise resolving to { data, error } tuple
|
|
4998
|
+
*
|
|
4999
|
+
* @example
|
|
5000
|
+
* ```typescript
|
|
5001
|
+
* const { data, error } = await client.admin.migrations.delete('001_create_users', 'myapp')
|
|
5002
|
+
* ```
|
|
5003
|
+
*/
|
|
5004
|
+
delete(name: string, namespace?: string): Promise<{
|
|
5005
|
+
data: null;
|
|
5006
|
+
error: Error | null;
|
|
5007
|
+
}>;
|
|
5008
|
+
/**
|
|
5009
|
+
* Apply a specific migration
|
|
5010
|
+
*
|
|
5011
|
+
* @param name - Migration name
|
|
5012
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
5013
|
+
* @returns Promise resolving to { data, error } tuple with result message
|
|
5014
|
+
*
|
|
5015
|
+
* @example
|
|
5016
|
+
* ```typescript
|
|
5017
|
+
* const { data, error } = await client.admin.migrations.apply('001_create_users', 'myapp')
|
|
5018
|
+
* if (data) {
|
|
5019
|
+
* console.log(data.message) // "Migration applied successfully"
|
|
5020
|
+
* }
|
|
5021
|
+
* ```
|
|
5022
|
+
*/
|
|
5023
|
+
apply(name: string, namespace?: string): Promise<{
|
|
5024
|
+
data: {
|
|
5025
|
+
message: string;
|
|
5026
|
+
} | null;
|
|
5027
|
+
error: Error | null;
|
|
5028
|
+
}>;
|
|
5029
|
+
/**
|
|
5030
|
+
* Rollback a specific migration
|
|
5031
|
+
*
|
|
5032
|
+
* @param name - Migration name
|
|
5033
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
5034
|
+
* @returns Promise resolving to { data, error } tuple with result message
|
|
5035
|
+
*
|
|
5036
|
+
* @example
|
|
5037
|
+
* ```typescript
|
|
5038
|
+
* const { data, error } = await client.admin.migrations.rollback('001_create_users', 'myapp')
|
|
5039
|
+
* ```
|
|
5040
|
+
*/
|
|
5041
|
+
rollback(name: string, namespace?: string): Promise<{
|
|
5042
|
+
data: {
|
|
5043
|
+
message: string;
|
|
5044
|
+
} | null;
|
|
5045
|
+
error: Error | null;
|
|
5046
|
+
}>;
|
|
5047
|
+
/**
|
|
5048
|
+
* Apply all pending migrations in order
|
|
5049
|
+
*
|
|
5050
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
5051
|
+
* @returns Promise resolving to { data, error } tuple with applied/failed counts
|
|
5052
|
+
*
|
|
5053
|
+
* @example
|
|
5054
|
+
* ```typescript
|
|
5055
|
+
* const { data, error } = await client.admin.migrations.applyPending('myapp')
|
|
5056
|
+
* if (data) {
|
|
5057
|
+
* console.log(`Applied: ${data.applied.length}, Failed: ${data.failed.length}`)
|
|
5058
|
+
* }
|
|
5059
|
+
* ```
|
|
5060
|
+
*/
|
|
5061
|
+
applyPending(namespace?: string): Promise<{
|
|
5062
|
+
data: {
|
|
5063
|
+
message: string;
|
|
5064
|
+
applied: string[];
|
|
5065
|
+
failed: string[];
|
|
5066
|
+
} | null;
|
|
5067
|
+
error: Error | null;
|
|
5068
|
+
}>;
|
|
5069
|
+
/**
|
|
5070
|
+
* Get execution history for a migration
|
|
5071
|
+
*
|
|
5072
|
+
* @param name - Migration name
|
|
5073
|
+
* @param namespace - Migration namespace (default: 'default')
|
|
5074
|
+
* @param limit - Maximum number of executions to return (default: 50, max: 100)
|
|
5075
|
+
* @returns Promise resolving to { data, error } tuple with execution records
|
|
5076
|
+
*
|
|
5077
|
+
* @example
|
|
5078
|
+
* ```typescript
|
|
5079
|
+
* const { data, error } = await client.admin.migrations.getExecutions(
|
|
5080
|
+
* '001_create_users',
|
|
5081
|
+
* 'myapp',
|
|
5082
|
+
* 10
|
|
5083
|
+
* )
|
|
5084
|
+
* if (data) {
|
|
5085
|
+
* data.forEach(exec => {
|
|
5086
|
+
* console.log(`${exec.executed_at}: ${exec.action} - ${exec.status}`)
|
|
5087
|
+
* })
|
|
5088
|
+
* }
|
|
5089
|
+
* ```
|
|
5090
|
+
*/
|
|
5091
|
+
getExecutions(name: string, namespace?: string, limit?: number): Promise<{
|
|
5092
|
+
data: MigrationExecution[] | null;
|
|
5093
|
+
error: Error | null;
|
|
5094
|
+
}>;
|
|
5095
|
+
}
|
|
5096
|
+
|
|
5097
|
+
/**
|
|
5098
|
+
* Admin Jobs module for managing job functions and executions
|
|
5099
|
+
* Provides administrative operations for job lifecycle management
|
|
5100
|
+
*/
|
|
5101
|
+
|
|
5102
|
+
/**
|
|
5103
|
+
* Options for bundling job code
|
|
5104
|
+
*/
|
|
5105
|
+
interface BundleOptions {
|
|
5106
|
+
/** Entry point code */
|
|
5107
|
+
code: string;
|
|
5108
|
+
/** External modules to exclude from bundle */
|
|
5109
|
+
external?: string[];
|
|
5110
|
+
/** Source map generation */
|
|
5111
|
+
sourcemap?: boolean;
|
|
5112
|
+
/** Minify output */
|
|
5113
|
+
minify?: boolean;
|
|
5114
|
+
}
|
|
5115
|
+
/**
|
|
5116
|
+
* Result of bundling job code
|
|
5117
|
+
*/
|
|
5118
|
+
interface BundleResult {
|
|
5119
|
+
/** Bundled code */
|
|
5120
|
+
code: string;
|
|
5121
|
+
/** Source map (if enabled) */
|
|
5122
|
+
sourceMap?: string;
|
|
5123
|
+
}
|
|
5124
|
+
/**
|
|
5125
|
+
* Admin Jobs manager for managing background job functions
|
|
5126
|
+
* Provides create, update, delete, sync, and monitoring operations
|
|
5127
|
+
*
|
|
5128
|
+
* @category Admin
|
|
5129
|
+
*/
|
|
5130
|
+
declare class FluxbaseAdminJobs {
|
|
5131
|
+
private fetch;
|
|
5132
|
+
constructor(fetch: FluxbaseFetch);
|
|
5133
|
+
/**
|
|
5134
|
+
* Create a new job function
|
|
5135
|
+
*
|
|
5136
|
+
* @param request - Job function configuration and code
|
|
5137
|
+
* @returns Promise resolving to { data, error } tuple with created job function metadata
|
|
5138
|
+
*
|
|
5139
|
+
* @example
|
|
5140
|
+
* ```typescript
|
|
5141
|
+
* const { data, error } = await client.admin.jobs.create({
|
|
5142
|
+
* name: 'process-data',
|
|
5143
|
+
* code: 'export async function handler(req) { return { success: true } }',
|
|
5144
|
+
* enabled: true,
|
|
5145
|
+
* timeout_seconds: 300
|
|
5146
|
+
* })
|
|
5147
|
+
* ```
|
|
5148
|
+
*/
|
|
5149
|
+
create(request: CreateJobFunctionRequest): Promise<{
|
|
5150
|
+
data: JobFunction | null;
|
|
5151
|
+
error: Error | null;
|
|
5152
|
+
}>;
|
|
5153
|
+
/**
|
|
5154
|
+
* List all namespaces that have job functions
|
|
5155
|
+
*
|
|
5156
|
+
* @returns Promise resolving to { data, error } tuple with array of namespace strings
|
|
5157
|
+
*
|
|
5158
|
+
* @example
|
|
5159
|
+
* ```typescript
|
|
5160
|
+
* const { data, error } = await client.admin.jobs.listNamespaces()
|
|
5161
|
+
* if (data) {
|
|
5162
|
+
* console.log('Available namespaces:', data)
|
|
5163
|
+
* }
|
|
5164
|
+
* ```
|
|
5165
|
+
*/
|
|
5166
|
+
listNamespaces(): Promise<{
|
|
5167
|
+
data: string[] | null;
|
|
5168
|
+
error: Error | null;
|
|
5169
|
+
}>;
|
|
5170
|
+
/**
|
|
5171
|
+
* List all job functions (admin view)
|
|
5172
|
+
*
|
|
5173
|
+
* @param namespace - Optional namespace filter
|
|
5174
|
+
* @returns Promise resolving to { data, error } tuple with array of job functions
|
|
5175
|
+
*
|
|
5176
|
+
* @example
|
|
5177
|
+
* ```typescript
|
|
5178
|
+
* const { data, error } = await client.admin.jobs.list('default')
|
|
5179
|
+
* if (data) {
|
|
5180
|
+
* console.log('Job functions:', data.map(f => f.name))
|
|
5181
|
+
* }
|
|
5182
|
+
* ```
|
|
5183
|
+
*/
|
|
5184
|
+
list(namespace?: string): Promise<{
|
|
5185
|
+
data: JobFunction[] | null;
|
|
5186
|
+
error: Error | null;
|
|
5187
|
+
}>;
|
|
5188
|
+
/**
|
|
5189
|
+
* Get details of a specific job function
|
|
5190
|
+
*
|
|
5191
|
+
* @param namespace - Namespace
|
|
5192
|
+
* @param name - Job function name
|
|
5193
|
+
* @returns Promise resolving to { data, error } tuple with job function metadata
|
|
5194
|
+
*
|
|
5195
|
+
* @example
|
|
5196
|
+
* ```typescript
|
|
5197
|
+
* const { data, error } = await client.admin.jobs.get('default', 'process-data')
|
|
5198
|
+
* if (data) {
|
|
5199
|
+
* console.log('Job function version:', data.version)
|
|
5200
|
+
* }
|
|
5201
|
+
* ```
|
|
5202
|
+
*/
|
|
5203
|
+
get(namespace: string, name: string): Promise<{
|
|
5204
|
+
data: JobFunction | null;
|
|
5205
|
+
error: Error | null;
|
|
5206
|
+
}>;
|
|
5207
|
+
/**
|
|
5208
|
+
* Update an existing job function
|
|
5209
|
+
*
|
|
5210
|
+
* @param namespace - Namespace
|
|
5211
|
+
* @param name - Job function name
|
|
5212
|
+
* @param updates - Fields to update
|
|
5213
|
+
* @returns Promise resolving to { data, error } tuple with updated job function metadata
|
|
5214
|
+
*
|
|
5215
|
+
* @example
|
|
5216
|
+
* ```typescript
|
|
5217
|
+
* const { data, error } = await client.admin.jobs.update('default', 'process-data', {
|
|
5218
|
+
* enabled: false,
|
|
5219
|
+
* timeout_seconds: 600
|
|
5220
|
+
* })
|
|
5221
|
+
* ```
|
|
5222
|
+
*/
|
|
5223
|
+
update(namespace: string, name: string, updates: UpdateJobFunctionRequest): Promise<{
|
|
5224
|
+
data: JobFunction | null;
|
|
5225
|
+
error: Error | null;
|
|
5226
|
+
}>;
|
|
5227
|
+
/**
|
|
5228
|
+
* Delete a job function
|
|
5229
|
+
*
|
|
5230
|
+
* @param namespace - Namespace
|
|
5231
|
+
* @param name - Job function name
|
|
5232
|
+
* @returns Promise resolving to { data, error } tuple
|
|
5233
|
+
*
|
|
5234
|
+
* @example
|
|
5235
|
+
* ```typescript
|
|
5236
|
+
* const { data, error } = await client.admin.jobs.delete('default', 'process-data')
|
|
5237
|
+
* ```
|
|
5238
|
+
*/
|
|
5239
|
+
delete(namespace: string, name: string): Promise<{
|
|
5240
|
+
data: null;
|
|
5241
|
+
error: Error | null;
|
|
5242
|
+
}>;
|
|
5243
|
+
/**
|
|
5244
|
+
* List all jobs (executions) across all namespaces (admin view)
|
|
5245
|
+
*
|
|
5246
|
+
* @param filters - Optional filters (status, namespace, limit, offset)
|
|
5247
|
+
* @returns Promise resolving to { data, error } tuple with array of jobs
|
|
5248
|
+
*
|
|
5249
|
+
* @example
|
|
5250
|
+
* ```typescript
|
|
5251
|
+
* const { data, error } = await client.admin.jobs.listJobs({
|
|
5252
|
+
* status: 'running',
|
|
5253
|
+
* namespace: 'default',
|
|
5254
|
+
* limit: 50
|
|
5255
|
+
* })
|
|
5256
|
+
* if (data) {
|
|
5257
|
+
* data.forEach(job => {
|
|
5258
|
+
* console.log(`${job.job_name}: ${job.status}`)
|
|
5259
|
+
* })
|
|
5260
|
+
* }
|
|
5261
|
+
* ```
|
|
5262
|
+
*/
|
|
5263
|
+
listJobs(filters?: {
|
|
5264
|
+
status?: string;
|
|
5265
|
+
namespace?: string;
|
|
5266
|
+
limit?: number;
|
|
5267
|
+
offset?: number;
|
|
5268
|
+
}): Promise<{
|
|
5269
|
+
data: Job[] | null;
|
|
5270
|
+
error: Error | null;
|
|
5271
|
+
}>;
|
|
5272
|
+
/**
|
|
5273
|
+
* Get details of a specific job (execution)
|
|
5274
|
+
*
|
|
5275
|
+
* @param jobId - Job ID
|
|
5276
|
+
* @returns Promise resolving to { data, error } tuple with job details
|
|
5277
|
+
*
|
|
5278
|
+
* @example
|
|
5279
|
+
* ```typescript
|
|
5280
|
+
* const { data, error } = await client.admin.jobs.getJob('550e8400-e29b-41d4-a716-446655440000')
|
|
5281
|
+
* if (data) {
|
|
5282
|
+
* console.log(`Job ${data.job_name}: ${data.status}`)
|
|
5283
|
+
* }
|
|
5284
|
+
* ```
|
|
5285
|
+
*/
|
|
5286
|
+
getJob(jobId: string): Promise<{
|
|
5287
|
+
data: Job | null;
|
|
5288
|
+
error: Error | null;
|
|
5289
|
+
}>;
|
|
5290
|
+
/**
|
|
5291
|
+
* Cancel a running or pending job
|
|
5292
|
+
*
|
|
5293
|
+
* @param jobId - Job ID
|
|
5294
|
+
* @returns Promise resolving to { data, error } tuple
|
|
5295
|
+
*
|
|
5296
|
+
* @example
|
|
5297
|
+
* ```typescript
|
|
5298
|
+
* const { data, error } = await client.admin.jobs.cancel('550e8400-e29b-41d4-a716-446655440000')
|
|
5299
|
+
* ```
|
|
5300
|
+
*/
|
|
5301
|
+
cancel(jobId: string): Promise<{
|
|
5302
|
+
data: null;
|
|
5303
|
+
error: Error | null;
|
|
5304
|
+
}>;
|
|
5305
|
+
/**
|
|
5306
|
+
* Terminate a running job immediately
|
|
5307
|
+
*
|
|
5308
|
+
* @param jobId - Job ID
|
|
5309
|
+
* @returns Promise resolving to { data, error } tuple
|
|
5310
|
+
*
|
|
5311
|
+
* @example
|
|
5312
|
+
* ```typescript
|
|
5313
|
+
* const { data, error } = await client.admin.jobs.terminate('550e8400-e29b-41d4-a716-446655440000')
|
|
5314
|
+
* ```
|
|
5315
|
+
*/
|
|
5316
|
+
terminate(jobId: string): Promise<{
|
|
5317
|
+
data: null;
|
|
5318
|
+
error: Error | null;
|
|
5319
|
+
}>;
|
|
5320
|
+
/**
|
|
5321
|
+
* Retry a failed job
|
|
5322
|
+
*
|
|
5323
|
+
* @param jobId - Job ID
|
|
5324
|
+
* @returns Promise resolving to { data, error } tuple with new job
|
|
5325
|
+
*
|
|
5326
|
+
* @example
|
|
5327
|
+
* ```typescript
|
|
5328
|
+
* const { data, error } = await client.admin.jobs.retry('550e8400-e29b-41d4-a716-446655440000')
|
|
5329
|
+
* ```
|
|
5330
|
+
*/
|
|
5331
|
+
retry(jobId: string): Promise<{
|
|
5332
|
+
data: Job | null;
|
|
5333
|
+
error: Error | null;
|
|
5334
|
+
}>;
|
|
5335
|
+
/**
|
|
5336
|
+
* Get job statistics
|
|
5337
|
+
*
|
|
5338
|
+
* @param namespace - Optional namespace filter
|
|
5339
|
+
* @returns Promise resolving to { data, error } tuple with job stats
|
|
5340
|
+
*
|
|
5341
|
+
* @example
|
|
5342
|
+
* ```typescript
|
|
5343
|
+
* const { data, error } = await client.admin.jobs.getStats('default')
|
|
5344
|
+
* if (data) {
|
|
5345
|
+
* console.log(`Pending: ${data.pending}, Running: ${data.running}`)
|
|
5346
|
+
* }
|
|
5347
|
+
* ```
|
|
5348
|
+
*/
|
|
5349
|
+
getStats(namespace?: string): Promise<{
|
|
5350
|
+
data: JobStats | null;
|
|
5351
|
+
error: Error | null;
|
|
5352
|
+
}>;
|
|
5353
|
+
/**
|
|
5354
|
+
* List active workers
|
|
5355
|
+
*
|
|
5356
|
+
* @returns Promise resolving to { data, error } tuple with array of workers
|
|
5357
|
+
*
|
|
5358
|
+
* @example
|
|
5359
|
+
* ```typescript
|
|
5360
|
+
* const { data, error } = await client.admin.jobs.listWorkers()
|
|
5361
|
+
* if (data) {
|
|
5362
|
+
* data.forEach(worker => {
|
|
5363
|
+
* console.log(`Worker ${worker.id}: ${worker.current_jobs} jobs`)
|
|
5364
|
+
* })
|
|
5365
|
+
* }
|
|
5366
|
+
* ```
|
|
5367
|
+
*/
|
|
5368
|
+
listWorkers(): Promise<{
|
|
5369
|
+
data: JobWorker[] | null;
|
|
5370
|
+
error: Error | null;
|
|
5371
|
+
}>;
|
|
5372
|
+
/**
|
|
5373
|
+
* Sync multiple job functions to a namespace
|
|
5374
|
+
*
|
|
5375
|
+
* Can sync from:
|
|
5376
|
+
* 1. Filesystem (if no jobs provided) - loads from configured jobs directory
|
|
5377
|
+
* 2. API payload (if jobs array provided) - syncs provided job specifications
|
|
5378
|
+
*
|
|
5379
|
+
* Requires service_role or admin authentication.
|
|
5380
|
+
*
|
|
5381
|
+
* @param options - Sync options including namespace and optional jobs array
|
|
5382
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
5383
|
+
*
|
|
5384
|
+
* @example
|
|
5385
|
+
* ```typescript
|
|
5386
|
+
* // Sync from filesystem
|
|
5387
|
+
* const { data, error } = await client.admin.jobs.sync({ namespace: 'default' })
|
|
5388
|
+
*
|
|
5389
|
+
* // Sync with pre-bundled code (client-side bundling)
|
|
5390
|
+
* const bundled = await FluxbaseAdminJobs.bundleCode({ code: myJobCode })
|
|
5391
|
+
* const { data, error } = await client.admin.jobs.sync({
|
|
5392
|
+
* namespace: 'default',
|
|
5393
|
+
* functions: [{
|
|
5394
|
+
* name: 'my-job',
|
|
5395
|
+
* code: bundled.code,
|
|
5396
|
+
* is_pre_bundled: true,
|
|
5397
|
+
* original_code: myJobCode,
|
|
5398
|
+
* }],
|
|
5399
|
+
* options: {
|
|
5400
|
+
* delete_missing: true, // Remove jobs not in this sync
|
|
5401
|
+
* dry_run: false, // Preview changes without applying
|
|
5402
|
+
* }
|
|
5403
|
+
* })
|
|
5404
|
+
*
|
|
5405
|
+
* if (data) {
|
|
5406
|
+
* console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
|
|
5407
|
+
* }
|
|
5408
|
+
* ```
|
|
5409
|
+
*/
|
|
5410
|
+
sync(options: SyncJobsOptions | string): Promise<{
|
|
5411
|
+
data: SyncJobsResult | null;
|
|
5412
|
+
error: Error | null;
|
|
5413
|
+
}>;
|
|
5414
|
+
/**
|
|
5415
|
+
* Sync job functions with automatic client-side bundling
|
|
5416
|
+
*
|
|
5417
|
+
* This is a convenience method that bundles all job code using esbuild
|
|
5418
|
+
* before sending to the server. Requires esbuild as a peer dependency.
|
|
5419
|
+
*
|
|
5420
|
+
* @param options - Sync options including namespace and jobs array
|
|
5421
|
+
* @param bundleOptions - Optional bundling configuration
|
|
5422
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
5423
|
+
*
|
|
5424
|
+
* @example
|
|
5425
|
+
* ```typescript
|
|
5426
|
+
* const { data, error } = await client.admin.jobs.syncWithBundling({
|
|
5427
|
+
* namespace: 'default',
|
|
5428
|
+
* functions: [
|
|
5429
|
+
* { name: 'process-data', code: processDataCode },
|
|
5430
|
+
* { name: 'send-email', code: sendEmailCode },
|
|
5431
|
+
* ],
|
|
5432
|
+
* options: { delete_missing: true }
|
|
5433
|
+
* })
|
|
5434
|
+
* ```
|
|
5435
|
+
*/
|
|
5436
|
+
syncWithBundling(options: SyncJobsOptions, bundleOptions?: Partial<BundleOptions>): Promise<{
|
|
5437
|
+
data: SyncJobsResult | null;
|
|
5438
|
+
error: Error | null;
|
|
5439
|
+
}>;
|
|
5440
|
+
/**
|
|
5441
|
+
* Bundle job code using esbuild (client-side)
|
|
5442
|
+
*
|
|
5443
|
+
* Transforms and bundles TypeScript/JavaScript code into a single file
|
|
5444
|
+
* that can be executed by the Fluxbase jobs runtime.
|
|
5445
|
+
*
|
|
5446
|
+
* Requires esbuild as a peer dependency.
|
|
5447
|
+
*
|
|
5448
|
+
* @param options - Bundle options including source code
|
|
5449
|
+
* @returns Promise resolving to bundled code
|
|
5450
|
+
* @throws Error if esbuild is not available
|
|
5451
|
+
*
|
|
5452
|
+
* @example
|
|
5453
|
+
* ```typescript
|
|
5454
|
+
* const bundled = await FluxbaseAdminJobs.bundleCode({
|
|
5455
|
+
* code: `
|
|
5456
|
+
* import { helper } from './utils'
|
|
5457
|
+
* export async function handler(req) {
|
|
5458
|
+
* return helper(req.payload)
|
|
5459
|
+
* }
|
|
5460
|
+
* `,
|
|
5461
|
+
* minify: true,
|
|
5462
|
+
* })
|
|
5463
|
+
*
|
|
5464
|
+
* // Use bundled code in sync
|
|
5465
|
+
* await client.admin.jobs.sync({
|
|
5466
|
+
* namespace: 'default',
|
|
5467
|
+
* functions: [{
|
|
5468
|
+
* name: 'my-job',
|
|
5469
|
+
* code: bundled.code,
|
|
5470
|
+
* is_pre_bundled: true,
|
|
5471
|
+
* }]
|
|
5472
|
+
* })
|
|
5473
|
+
* ```
|
|
5474
|
+
*/
|
|
5475
|
+
static bundleCode(options: BundleOptions): Promise<BundleResult>;
|
|
5476
|
+
}
|
|
5477
|
+
|
|
5478
|
+
/**
|
|
5479
|
+
* Admin client for managing Fluxbase instance
|
|
5480
|
+
*/
|
|
5481
|
+
declare class FluxbaseAdmin {
|
|
5482
|
+
private fetch;
|
|
5483
|
+
private adminToken;
|
|
5484
|
+
/**
|
|
5485
|
+
* Settings manager for system and application settings
|
|
5486
|
+
*/
|
|
5487
|
+
settings: FluxbaseSettings;
|
|
5488
|
+
/**
|
|
5489
|
+
* DDL manager for database schema and table operations
|
|
5490
|
+
*/
|
|
5491
|
+
ddl: DDLManager;
|
|
5492
|
+
/**
|
|
5493
|
+
* OAuth configuration manager for provider and auth settings
|
|
5494
|
+
*/
|
|
5495
|
+
oauth: FluxbaseOAuth;
|
|
5496
|
+
/**
|
|
5497
|
+
* Impersonation manager for user impersonation and audit trail
|
|
5498
|
+
*/
|
|
5499
|
+
impersonation: ImpersonationManager;
|
|
5500
|
+
/**
|
|
5501
|
+
* Management namespace for API keys, webhooks, and invitations
|
|
5502
|
+
*/
|
|
5503
|
+
management: FluxbaseManagement;
|
|
5504
|
+
/**
|
|
5505
|
+
* Email template manager for customizing authentication and notification emails
|
|
5506
|
+
*/
|
|
5507
|
+
emailTemplates: EmailTemplateManager;
|
|
5508
|
+
/**
|
|
5509
|
+
* Functions manager for edge function management (create, update, delete, sync)
|
|
5510
|
+
*/
|
|
5511
|
+
functions: FluxbaseAdminFunctions;
|
|
5512
|
+
/**
|
|
5513
|
+
* Jobs manager for background job management (create, update, delete, sync, monitoring)
|
|
5514
|
+
*/
|
|
5515
|
+
jobs: FluxbaseAdminJobs;
|
|
5516
|
+
/**
|
|
5517
|
+
* Migrations manager for database migration operations (create, apply, rollback, sync)
|
|
5518
|
+
*/
|
|
5519
|
+
migrations: FluxbaseAdminMigrations;
|
|
4169
5520
|
constructor(fetch: FluxbaseFetch);
|
|
4170
5521
|
/**
|
|
4171
5522
|
* Set admin authentication token
|
|
@@ -4883,6 +6234,8 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
4883
6234
|
storage: FluxbaseStorage;
|
|
4884
6235
|
/** Functions module for invoking and managing edge functions */
|
|
4885
6236
|
functions: FluxbaseFunctions;
|
|
6237
|
+
/** Jobs module for submitting and monitoring background jobs */
|
|
6238
|
+
jobs: FluxbaseJobs;
|
|
4886
6239
|
/** Admin module for instance management (requires admin authentication) */
|
|
4887
6240
|
admin: FluxbaseAdmin;
|
|
4888
6241
|
/** Management module for API keys, webhooks, and invitations */
|
|
@@ -5071,4 +6424,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
5071
6424
|
*/
|
|
5072
6425
|
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
5073
6426
|
|
|
5074
|
-
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
6427
|
+
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|