@fluxbase/sdk 0.0.1-rc.2 → 0.0.1-rc.6

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.js CHANGED
@@ -1211,11 +1211,429 @@ var AppSettingsManager = class {
1211
1211
  security: { enable_global_rate_limit: enabled }
1212
1212
  });
1213
1213
  }
1214
+ /**
1215
+ * Configure SMTP email provider
1216
+ *
1217
+ * Convenience method to set up SMTP email delivery.
1218
+ *
1219
+ * @param config - SMTP configuration
1220
+ * @returns Promise resolving to AppSettings
1221
+ *
1222
+ * @example
1223
+ * ```typescript
1224
+ * await client.admin.settings.app.configureSMTP({
1225
+ * host: 'smtp.gmail.com',
1226
+ * port: 587,
1227
+ * username: 'your-email@gmail.com',
1228
+ * password: 'your-app-password',
1229
+ * use_tls: true,
1230
+ * from_address: 'noreply@yourapp.com',
1231
+ * from_name: 'Your App'
1232
+ * })
1233
+ * ```
1234
+ */
1235
+ async configureSMTP(config) {
1236
+ return await this.update({
1237
+ email: {
1238
+ enabled: true,
1239
+ provider: "smtp",
1240
+ from_address: config.from_address,
1241
+ from_name: config.from_name,
1242
+ reply_to_address: config.reply_to_address,
1243
+ smtp: {
1244
+ host: config.host,
1245
+ port: config.port,
1246
+ username: config.username,
1247
+ password: config.password,
1248
+ use_tls: config.use_tls
1249
+ }
1250
+ }
1251
+ });
1252
+ }
1253
+ /**
1254
+ * Configure SendGrid email provider
1255
+ *
1256
+ * Convenience method to set up SendGrid email delivery.
1257
+ *
1258
+ * @param apiKey - SendGrid API key
1259
+ * @param options - Optional from address, name, and reply-to
1260
+ * @returns Promise resolving to AppSettings
1261
+ *
1262
+ * @example
1263
+ * ```typescript
1264
+ * await client.admin.settings.app.configureSendGrid('SG.xxx', {
1265
+ * from_address: 'noreply@yourapp.com',
1266
+ * from_name: 'Your App'
1267
+ * })
1268
+ * ```
1269
+ */
1270
+ async configureSendGrid(apiKey, options) {
1271
+ return await this.update({
1272
+ email: {
1273
+ enabled: true,
1274
+ provider: "sendgrid",
1275
+ from_address: options?.from_address,
1276
+ from_name: options?.from_name,
1277
+ reply_to_address: options?.reply_to_address,
1278
+ sendgrid: {
1279
+ api_key: apiKey
1280
+ }
1281
+ }
1282
+ });
1283
+ }
1284
+ /**
1285
+ * Configure Mailgun email provider
1286
+ *
1287
+ * Convenience method to set up Mailgun email delivery.
1288
+ *
1289
+ * @param apiKey - Mailgun API key
1290
+ * @param domain - Mailgun domain
1291
+ * @param options - Optional EU region flag and email addresses
1292
+ * @returns Promise resolving to AppSettings
1293
+ *
1294
+ * @example
1295
+ * ```typescript
1296
+ * await client.admin.settings.app.configureMailgun('key-xxx', 'mg.yourapp.com', {
1297
+ * eu_region: false,
1298
+ * from_address: 'noreply@yourapp.com',
1299
+ * from_name: 'Your App'
1300
+ * })
1301
+ * ```
1302
+ */
1303
+ async configureMailgun(apiKey, domain, options) {
1304
+ return await this.update({
1305
+ email: {
1306
+ enabled: true,
1307
+ provider: "mailgun",
1308
+ from_address: options?.from_address,
1309
+ from_name: options?.from_name,
1310
+ reply_to_address: options?.reply_to_address,
1311
+ mailgun: {
1312
+ api_key: apiKey,
1313
+ domain,
1314
+ eu_region: options?.eu_region ?? false
1315
+ }
1316
+ }
1317
+ });
1318
+ }
1319
+ /**
1320
+ * Configure AWS SES email provider
1321
+ *
1322
+ * Convenience method to set up AWS SES email delivery.
1323
+ *
1324
+ * @param accessKeyId - AWS access key ID
1325
+ * @param secretAccessKey - AWS secret access key
1326
+ * @param region - AWS region (e.g., 'us-east-1')
1327
+ * @param options - Optional email addresses
1328
+ * @returns Promise resolving to AppSettings
1329
+ *
1330
+ * @example
1331
+ * ```typescript
1332
+ * await client.admin.settings.app.configureSES(
1333
+ * 'AKIAIOSFODNN7EXAMPLE',
1334
+ * 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
1335
+ * 'us-east-1',
1336
+ * {
1337
+ * from_address: 'noreply@yourapp.com',
1338
+ * from_name: 'Your App'
1339
+ * }
1340
+ * )
1341
+ * ```
1342
+ */
1343
+ async configureSES(accessKeyId, secretAccessKey, region, options) {
1344
+ return await this.update({
1345
+ email: {
1346
+ enabled: true,
1347
+ provider: "ses",
1348
+ from_address: options?.from_address,
1349
+ from_name: options?.from_name,
1350
+ reply_to_address: options?.reply_to_address,
1351
+ ses: {
1352
+ access_key_id: accessKeyId,
1353
+ secret_access_key: secretAccessKey,
1354
+ region
1355
+ }
1356
+ }
1357
+ });
1358
+ }
1359
+ /**
1360
+ * Enable or disable email functionality
1361
+ *
1362
+ * Convenience method to toggle email system on/off.
1363
+ *
1364
+ * @param enabled - Whether to enable email
1365
+ * @returns Promise resolving to AppSettings
1366
+ *
1367
+ * @example
1368
+ * ```typescript
1369
+ * await client.admin.settings.app.setEmailEnabled(true)
1370
+ * ```
1371
+ */
1372
+ async setEmailEnabled(enabled) {
1373
+ return await this.update({
1374
+ email: { enabled }
1375
+ });
1376
+ }
1377
+ /**
1378
+ * Configure password complexity requirements
1379
+ *
1380
+ * Convenience method to set password validation rules.
1381
+ *
1382
+ * @param requirements - Password complexity requirements
1383
+ * @returns Promise resolving to AppSettings
1384
+ *
1385
+ * @example
1386
+ * ```typescript
1387
+ * await client.admin.settings.app.setPasswordComplexity({
1388
+ * min_length: 12,
1389
+ * require_uppercase: true,
1390
+ * require_lowercase: true,
1391
+ * require_number: true,
1392
+ * require_special: true
1393
+ * })
1394
+ * ```
1395
+ */
1396
+ async setPasswordComplexity(requirements) {
1397
+ return await this.update({
1398
+ authentication: {
1399
+ password_min_length: requirements.min_length,
1400
+ password_require_uppercase: requirements.require_uppercase,
1401
+ password_require_lowercase: requirements.require_lowercase,
1402
+ password_require_number: requirements.require_number,
1403
+ password_require_special: requirements.require_special
1404
+ }
1405
+ });
1406
+ }
1407
+ /**
1408
+ * Configure session settings
1409
+ *
1410
+ * Convenience method to set session timeout and limits.
1411
+ *
1412
+ * @param timeoutMinutes - Session timeout in minutes (0 for no timeout)
1413
+ * @param maxSessionsPerUser - Maximum concurrent sessions per user (0 for unlimited)
1414
+ * @returns Promise resolving to AppSettings
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * // 30 minute sessions, max 3 devices per user
1419
+ * await client.admin.settings.app.setSessionSettings(30, 3)
1420
+ * ```
1421
+ */
1422
+ async setSessionSettings(timeoutMinutes, maxSessionsPerUser) {
1423
+ return await this.update({
1424
+ authentication: {
1425
+ session_timeout_minutes: timeoutMinutes,
1426
+ max_sessions_per_user: maxSessionsPerUser
1427
+ }
1428
+ });
1429
+ }
1430
+ /**
1431
+ * Enable or disable email verification requirement
1432
+ *
1433
+ * Convenience method to require email verification for new signups.
1434
+ *
1435
+ * @param required - Whether to require email verification
1436
+ * @returns Promise resolving to AppSettings
1437
+ *
1438
+ * @example
1439
+ * ```typescript
1440
+ * await client.admin.settings.app.setEmailVerificationRequired(true)
1441
+ * ```
1442
+ */
1443
+ async setEmailVerificationRequired(required) {
1444
+ return await this.update({
1445
+ authentication: { require_email_verification: required }
1446
+ });
1447
+ }
1448
+ };
1449
+ var CustomSettingsManager = class {
1450
+ constructor(fetch2) {
1451
+ this.fetch = fetch2;
1452
+ }
1453
+ /**
1454
+ * Create a new custom setting
1455
+ *
1456
+ * @param request - Custom setting creation request
1457
+ * @returns Promise resolving to CustomSetting
1458
+ *
1459
+ * @example
1460
+ * ```typescript
1461
+ * const setting = await client.admin.settings.custom.create({
1462
+ * key: 'api.quotas',
1463
+ * value: { free: 1000, pro: 10000, enterprise: 100000 },
1464
+ * value_type: 'json',
1465
+ * description: 'API request quotas by tier',
1466
+ * metadata: { category: 'billing' }
1467
+ * })
1468
+ * ```
1469
+ */
1470
+ async create(request) {
1471
+ return await this.fetch.post("/api/v1/admin/settings/custom", request);
1472
+ }
1473
+ /**
1474
+ * List all custom settings
1475
+ *
1476
+ * @returns Promise resolving to ListCustomSettingsResponse
1477
+ *
1478
+ * @example
1479
+ * ```typescript
1480
+ * const response = await client.admin.settings.custom.list()
1481
+ * console.log(response.settings)
1482
+ * ```
1483
+ */
1484
+ async list() {
1485
+ const settings = await this.fetch.get("/api/v1/admin/settings/custom");
1486
+ return { settings: Array.isArray(settings) ? settings : [] };
1487
+ }
1488
+ /**
1489
+ * Get a specific custom setting by key
1490
+ *
1491
+ * @param key - Setting key (e.g., 'feature.dark_mode')
1492
+ * @returns Promise resolving to CustomSetting
1493
+ *
1494
+ * @example
1495
+ * ```typescript
1496
+ * const setting = await client.admin.settings.custom.get('feature.dark_mode')
1497
+ * console.log(setting.value)
1498
+ * ```
1499
+ */
1500
+ async get(key) {
1501
+ return await this.fetch.get(`/api/v1/admin/settings/custom/${key}`);
1502
+ }
1503
+ /**
1504
+ * Update an existing custom setting
1505
+ *
1506
+ * @param key - Setting key
1507
+ * @param request - Update request with new values
1508
+ * @returns Promise resolving to CustomSetting
1509
+ *
1510
+ * @example
1511
+ * ```typescript
1512
+ * const updated = await client.admin.settings.custom.update('feature.dark_mode', {
1513
+ * value: { enabled: false },
1514
+ * description: 'Updated description'
1515
+ * })
1516
+ * ```
1517
+ */
1518
+ async update(key, request) {
1519
+ return await this.fetch.put(`/api/v1/admin/settings/custom/${key}`, request);
1520
+ }
1521
+ /**
1522
+ * Delete a custom setting
1523
+ *
1524
+ * @param key - Setting key to delete
1525
+ * @returns Promise<void>
1526
+ *
1527
+ * @example
1528
+ * ```typescript
1529
+ * await client.admin.settings.custom.delete('feature.dark_mode')
1530
+ * ```
1531
+ */
1532
+ async delete(key) {
1533
+ await this.fetch.delete(`/api/v1/admin/settings/custom/${key}`);
1534
+ }
1535
+ };
1536
+ var EmailTemplateManager = class {
1537
+ constructor(fetch2) {
1538
+ this.fetch = fetch2;
1539
+ }
1540
+ /**
1541
+ * List all email templates
1542
+ *
1543
+ * @returns Promise resolving to ListEmailTemplatesResponse
1544
+ *
1545
+ * @example
1546
+ * ```typescript
1547
+ * const response = await client.admin.emailTemplates.list()
1548
+ * console.log(response.templates)
1549
+ * ```
1550
+ */
1551
+ async list() {
1552
+ const templates = await this.fetch.get("/api/v1/admin/email/templates");
1553
+ return { templates: Array.isArray(templates) ? templates : [] };
1554
+ }
1555
+ /**
1556
+ * Get a specific email template by type
1557
+ *
1558
+ * @param type - Template type (magic_link | verify_email | reset_password | invite_user)
1559
+ * @returns Promise resolving to EmailTemplate
1560
+ *
1561
+ * @example
1562
+ * ```typescript
1563
+ * const template = await client.admin.emailTemplates.get('magic_link')
1564
+ * console.log(template.subject)
1565
+ * console.log(template.html_body)
1566
+ * ```
1567
+ */
1568
+ async get(type) {
1569
+ return await this.fetch.get(`/api/v1/admin/email/templates/${type}`);
1570
+ }
1571
+ /**
1572
+ * Update an email template
1573
+ *
1574
+ * Available template variables:
1575
+ * - magic_link: {{.MagicLink}}, {{.AppName}}, {{.ExpiryMinutes}}
1576
+ * - verify_email: {{.VerificationLink}}, {{.AppName}}
1577
+ * - reset_password: {{.ResetLink}}, {{.AppName}}, {{.ExpiryMinutes}}
1578
+ * - invite_user: {{.InviteLink}}, {{.AppName}}, {{.InviterName}}
1579
+ *
1580
+ * @param type - Template type to update
1581
+ * @param request - Update request with subject, html_body, and optional text_body
1582
+ * @returns Promise resolving to EmailTemplate
1583
+ *
1584
+ * @example
1585
+ * ```typescript
1586
+ * const updated = await client.admin.emailTemplates.update('magic_link', {
1587
+ * subject: 'Your Magic Link - Sign in to {{.AppName}}',
1588
+ * html_body: '<html><body><h1>Welcome!</h1><a href="{{.MagicLink}}">Sign In</a></body></html>',
1589
+ * text_body: 'Click here to sign in: {{.MagicLink}}'
1590
+ * })
1591
+ * ```
1592
+ */
1593
+ async update(type, request) {
1594
+ return await this.fetch.put(`/api/v1/admin/email/templates/${type}`, request);
1595
+ }
1596
+ /**
1597
+ * Reset an email template to default
1598
+ *
1599
+ * Removes any customizations and restores the template to its original state.
1600
+ *
1601
+ * @param type - Template type to reset
1602
+ * @returns Promise resolving to EmailTemplate - The default template
1603
+ *
1604
+ * @example
1605
+ * ```typescript
1606
+ * const defaultTemplate = await client.admin.emailTemplates.reset('magic_link')
1607
+ * ```
1608
+ */
1609
+ async reset(type) {
1610
+ return await this.fetch.post(`/api/v1/admin/email/templates/${type}/reset`, {});
1611
+ }
1612
+ /**
1613
+ * Send a test email using the template
1614
+ *
1615
+ * Useful for previewing template changes before deploying to production.
1616
+ *
1617
+ * @param type - Template type to test
1618
+ * @param recipientEmail - Email address to send test to
1619
+ * @returns Promise<void>
1620
+ *
1621
+ * @example
1622
+ * ```typescript
1623
+ * await client.admin.emailTemplates.test('magic_link', 'test@example.com')
1624
+ * ```
1625
+ */
1626
+ async test(type, recipientEmail) {
1627
+ await this.fetch.post(`/api/v1/admin/email/templates/${type}/test`, {
1628
+ recipient_email: recipientEmail
1629
+ });
1630
+ }
1214
1631
  };
1215
1632
  var FluxbaseSettings = class {
1216
1633
  constructor(fetch2) {
1217
1634
  this.system = new SystemSettingsManager(fetch2);
1218
1635
  this.app = new AppSettingsManager(fetch2);
1636
+ this.custom = new CustomSettingsManager(fetch2);
1219
1637
  }
1220
1638
  };
1221
1639
 
@@ -2238,6 +2656,7 @@ var FluxbaseAdmin = class {
2238
2656
  this.oauth = new FluxbaseOAuth(fetch2);
2239
2657
  this.impersonation = new ImpersonationManager(fetch2);
2240
2658
  this.management = new FluxbaseManagement(fetch2);
2659
+ this.emailTemplates = new EmailTemplateManager(fetch2);
2241
2660
  }
2242
2661
  /**
2243
2662
  * Set admin authentication token
@@ -3232,6 +3651,6 @@ function createClient(options) {
3232
3651
  return new FluxbaseClient(options);
3233
3652
  }
3234
3653
 
3235
- export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, StorageBucket, SystemSettingsManager, WebhooksManager, createClient };
3654
+ export { APIKeysManager, AppSettingsManager, AuthSettingsManager, DDLManager, EmailTemplateManager, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, FluxbaseFetch, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, ImpersonationManager, InvitationsManager, OAuthProviderManager, QueryBuilder, RealtimeChannel, StorageBucket, SystemSettingsManager, WebhooksManager, createClient };
3236
3655
  //# sourceMappingURL=index.js.map
3237
3656
  //# sourceMappingURL=index.js.map