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

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