@fluxbase/sdk 2026.3.1 → 2026.3.2-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,7 +121,11 @@ Check out working examples in the [`/example`](../example/) directory:
121
121
  For React applications, use [`@fluxbase/sdk-react`](../sdk-react/) for hooks and automatic state management:
122
122
 
123
123
  ```bash
124
+ # npm
124
125
  npm install @fluxbase/sdk @fluxbase/sdk-react @tanstack/react-query
126
+
127
+ # pnpm
128
+ pnpm add @fluxbase/sdk @fluxbase/sdk-react @tanstack/react-query
125
129
  ```
126
130
 
127
131
  See the **[React Hooks Guide](../../docs/docs/sdks/react-hooks.md)** for details.
package/dist/index.cjs CHANGED
@@ -5593,7 +5593,9 @@ var OAuthProviderManager = class {
5593
5593
  * ```
5594
5594
  */
5595
5595
  async listProviders() {
5596
- const providers = await this.fetch.get("/api/v1/admin/oauth/providers");
5596
+ const providers = await this.fetch.get(
5597
+ "/api/v1/admin/oauth/providers"
5598
+ );
5597
5599
  return Array.isArray(providers) ? providers : [];
5598
5600
  }
5599
5601
  /**
@@ -5615,7 +5617,9 @@ var OAuthProviderManager = class {
5615
5617
  * ```
5616
5618
  */
5617
5619
  async getProvider(providerId) {
5618
- return await this.fetch.get(`/api/v1/admin/oauth/providers/${providerId}`);
5620
+ return await this.fetch.get(
5621
+ `/api/v1/admin/oauth/providers/${providerId}`
5622
+ );
5619
5623
  }
5620
5624
  /**
5621
5625
  * Create a new OAuth provider
@@ -5654,7 +5658,7 @@ var OAuthProviderManager = class {
5654
5658
  * client_id: 'client-id',
5655
5659
  * client_secret: 'client-secret',
5656
5660
  * redirect_url: 'https://yourapp.com/auth/callback',
5657
- * scopes: ['openid', 'profile', 'email'],
5661
+ * scopes: ['openid', 'profile', 'email', 'offline_access'],
5658
5662
  * is_custom: true,
5659
5663
  * authorization_url: 'https://sso.example.com/oauth/authorize',
5660
5664
  * token_url: 'https://sso.example.com/oauth/token',
@@ -5663,7 +5667,10 @@ var OAuthProviderManager = class {
5663
5667
  * ```
5664
5668
  */
5665
5669
  async createProvider(request) {
5666
- return await this.fetch.post("/api/v1/admin/oauth/providers", request);
5670
+ return await this.fetch.post(
5671
+ "/api/v1/admin/oauth/providers",
5672
+ request
5673
+ );
5667
5674
  }
5668
5675
  /**
5669
5676
  * Update an existing OAuth provider
@@ -5833,7 +5840,10 @@ var AuthSettingsManager = class {
5833
5840
  * ```
5834
5841
  */
5835
5842
  async update(request) {
5836
- return await this.fetch.put("/api/v1/admin/auth/settings", request);
5843
+ return await this.fetch.put(
5844
+ "/api/v1/admin/auth/settings",
5845
+ request
5846
+ );
5837
5847
  }
5838
5848
  };
5839
5849
  var FluxbaseOAuth = class {
@@ -10107,6 +10117,312 @@ var FluxbaseAdmin = class {
10107
10117
  }
10108
10118
  };
10109
10119
 
10120
+ // src/secrets.ts
10121
+ var SecretsManager = class {
10122
+ constructor(fetch2) {
10123
+ this.fetch = fetch2;
10124
+ }
10125
+ /**
10126
+ * Create a new secret
10127
+ *
10128
+ * Creates a new secret with the specified name, value, and scope.
10129
+ * The value is encrypted at rest and never returned by the API.
10130
+ *
10131
+ * @param request - Secret creation request
10132
+ * @returns Promise resolving to the created secret (metadata only)
10133
+ *
10134
+ * @example
10135
+ * ```typescript
10136
+ * // Create a global secret
10137
+ * const secret = await client.secrets.create({
10138
+ * name: 'SENDGRID_API_KEY',
10139
+ * value: 'SG.xxx',
10140
+ * description: 'SendGrid API key for transactional emails'
10141
+ * })
10142
+ *
10143
+ * // Create a namespace-scoped secret
10144
+ * const secret = await client.secrets.create({
10145
+ * name: 'DATABASE_URL',
10146
+ * value: 'postgres://user:pass@host:5432/db',
10147
+ * scope: 'namespace',
10148
+ * namespace: 'production',
10149
+ * description: 'Production database URL'
10150
+ * })
10151
+ *
10152
+ * // Create a secret with expiration
10153
+ * const secret = await client.secrets.create({
10154
+ * name: 'TEMP_TOKEN',
10155
+ * value: 'xyz123',
10156
+ * expires_at: '2025-12-31T23:59:59Z'
10157
+ * })
10158
+ * ```
10159
+ */
10160
+ async create(request) {
10161
+ return await this.fetch.post("/api/v1/secrets", request);
10162
+ }
10163
+ /**
10164
+ * Get a secret by name (metadata only, never includes value)
10165
+ *
10166
+ * @param name - Secret name
10167
+ * @param options - Optional namespace for namespace-scoped secrets
10168
+ * @returns Promise resolving to the secret
10169
+ *
10170
+ * @example
10171
+ * ```typescript
10172
+ * // Get a global secret
10173
+ * const secret = await client.secrets.get('API_KEY')
10174
+ *
10175
+ * // Get a namespace-scoped secret
10176
+ * const secret = await client.secrets.get('DATABASE_URL', { namespace: 'production' })
10177
+ * ```
10178
+ */
10179
+ async get(name, options) {
10180
+ const params = new URLSearchParams();
10181
+ if (options?.namespace) {
10182
+ params.set("namespace", options.namespace);
10183
+ }
10184
+ const query = params.toString() ? `?${params.toString()}` : "";
10185
+ return await this.fetch.get(`/api/v1/secrets/by-name/${encodeURIComponent(name)}${query}`);
10186
+ }
10187
+ /**
10188
+ * Update a secret by name
10189
+ *
10190
+ * Updates the secret's value, description, or expiration.
10191
+ * Only provided fields will be updated.
10192
+ *
10193
+ * @param name - Secret name
10194
+ * @param request - Update request
10195
+ * @param options - Optional namespace for namespace-scoped secrets
10196
+ * @returns Promise resolving to the updated secret
10197
+ *
10198
+ * @example
10199
+ * ```typescript
10200
+ * // Update secret value
10201
+ * const secret = await client.secrets.update('API_KEY', { value: 'new-value' })
10202
+ *
10203
+ * // Update description
10204
+ * const secret = await client.secrets.update('API_KEY', { description: 'Updated description' })
10205
+ *
10206
+ * // Update namespace-scoped secret
10207
+ * const secret = await client.secrets.update('DATABASE_URL',
10208
+ * { value: 'postgres://new-host:5432/db' },
10209
+ * { namespace: 'production' }
10210
+ * )
10211
+ * ```
10212
+ */
10213
+ async update(name, request, options) {
10214
+ const params = new URLSearchParams();
10215
+ if (options?.namespace) {
10216
+ params.set("namespace", options.namespace);
10217
+ }
10218
+ const query = params.toString() ? `?${params.toString()}` : "";
10219
+ return await this.fetch.put(`/api/v1/secrets/by-name/${encodeURIComponent(name)}${query}`, request);
10220
+ }
10221
+ /**
10222
+ * Delete a secret by name
10223
+ *
10224
+ * Permanently deletes the secret and all its versions.
10225
+ *
10226
+ * @param name - Secret name
10227
+ * @param options - Optional namespace for namespace-scoped secrets
10228
+ * @returns Promise resolving when deletion is complete
10229
+ *
10230
+ * @example
10231
+ * ```typescript
10232
+ * // Delete a global secret
10233
+ * await client.secrets.delete('OLD_API_KEY')
10234
+ *
10235
+ * // Delete a namespace-scoped secret
10236
+ * await client.secrets.delete('DATABASE_URL', { namespace: 'staging' })
10237
+ * ```
10238
+ */
10239
+ async delete(name, options) {
10240
+ const params = new URLSearchParams();
10241
+ if (options?.namespace) {
10242
+ params.set("namespace", options.namespace);
10243
+ }
10244
+ const query = params.toString() ? `?${params.toString()}` : "";
10245
+ await this.fetch.delete(`/api/v1/secrets/by-name/${encodeURIComponent(name)}${query}`);
10246
+ }
10247
+ /**
10248
+ * Get version history for a secret by name
10249
+ *
10250
+ * Returns all historical versions of the secret (values are never included).
10251
+ *
10252
+ * @param name - Secret name
10253
+ * @param options - Optional namespace for namespace-scoped secrets
10254
+ * @returns Promise resolving to array of secret versions
10255
+ *
10256
+ * @example
10257
+ * ```typescript
10258
+ * const versions = await client.secrets.getVersions('API_KEY')
10259
+ *
10260
+ * versions.forEach(v => {
10261
+ * console.log(`Version ${v.version} created at ${v.created_at}`)
10262
+ * })
10263
+ * ```
10264
+ */
10265
+ async getVersions(name, options) {
10266
+ const params = new URLSearchParams();
10267
+ if (options?.namespace) {
10268
+ params.set("namespace", options.namespace);
10269
+ }
10270
+ const query = params.toString() ? `?${params.toString()}` : "";
10271
+ return await this.fetch.get(`/api/v1/secrets/by-name/${encodeURIComponent(name)}/versions${query}`);
10272
+ }
10273
+ /**
10274
+ * Rollback a secret to a previous version by name
10275
+ *
10276
+ * Restores the secret to a previous version's value.
10277
+ * This creates a new version with the old value.
10278
+ *
10279
+ * @param name - Secret name
10280
+ * @param version - Version number to rollback to
10281
+ * @param options - Optional namespace for namespace-scoped secrets
10282
+ * @returns Promise resolving to the updated secret
10283
+ *
10284
+ * @example
10285
+ * ```typescript
10286
+ * // Rollback to version 2
10287
+ * const secret = await client.secrets.rollback('API_KEY', 2)
10288
+ * console.log(`Secret now at version ${secret.version}`)
10289
+ * ```
10290
+ */
10291
+ async rollback(name, version, options) {
10292
+ const params = new URLSearchParams();
10293
+ if (options?.namespace) {
10294
+ params.set("namespace", options.namespace);
10295
+ }
10296
+ const query = params.toString() ? `?${params.toString()}` : "";
10297
+ return await this.fetch.post(
10298
+ `/api/v1/secrets/by-name/${encodeURIComponent(name)}/rollback/${version}${query}`,
10299
+ {}
10300
+ );
10301
+ }
10302
+ /**
10303
+ * List all secrets (metadata only, never includes values)
10304
+ *
10305
+ * @param options - Filter options for scope and namespace
10306
+ * @returns Promise resolving to array of secret summaries
10307
+ *
10308
+ * @example
10309
+ * ```typescript
10310
+ * // List all secrets
10311
+ * const secrets = await client.secrets.list()
10312
+ *
10313
+ * // List only global secrets
10314
+ * const secrets = await client.secrets.list({ scope: 'global' })
10315
+ *
10316
+ * // List secrets for a specific namespace
10317
+ * const secrets = await client.secrets.list({ namespace: 'production' })
10318
+ *
10319
+ * secrets.forEach(s => {
10320
+ * console.log(`${s.name}: version ${s.version}, expired: ${s.is_expired}`)
10321
+ * })
10322
+ * ```
10323
+ */
10324
+ async list(options) {
10325
+ const params = new URLSearchParams();
10326
+ if (options?.scope) {
10327
+ params.set("scope", options.scope);
10328
+ }
10329
+ if (options?.namespace) {
10330
+ params.set("namespace", options.namespace);
10331
+ }
10332
+ const query = params.toString() ? `?${params.toString()}` : "";
10333
+ return await this.fetch.get(`/api/v1/secrets${query}`);
10334
+ }
10335
+ /**
10336
+ * Get statistics about secrets
10337
+ *
10338
+ * @returns Promise resolving to secret statistics
10339
+ *
10340
+ * @example
10341
+ * ```typescript
10342
+ * const stats = await client.secrets.stats()
10343
+ * console.log(`Total: ${stats.total}, Expiring soon: ${stats.expiring_soon}, Expired: ${stats.expired}`)
10344
+ * ```
10345
+ */
10346
+ async stats() {
10347
+ return await this.fetch.get("/api/v1/secrets/stats");
10348
+ }
10349
+ // UUID-based methods for backward compatibility
10350
+ /**
10351
+ * Get a secret by ID (metadata only)
10352
+ *
10353
+ * @param id - Secret UUID
10354
+ * @returns Promise resolving to the secret
10355
+ *
10356
+ * @example
10357
+ * ```typescript
10358
+ * const secret = await client.secrets.getById('550e8400-e29b-41d4-a716-446655440000')
10359
+ * ```
10360
+ */
10361
+ async getById(id) {
10362
+ return await this.fetch.get(`/api/v1/secrets/${encodeURIComponent(id)}`);
10363
+ }
10364
+ /**
10365
+ * Update a secret by ID
10366
+ *
10367
+ * @param id - Secret UUID
10368
+ * @param request - Update request
10369
+ * @returns Promise resolving to the updated secret
10370
+ *
10371
+ * @example
10372
+ * ```typescript
10373
+ * const secret = await client.secrets.updateById('550e8400-e29b-41d4-a716-446655440000', {
10374
+ * value: 'new-value'
10375
+ * })
10376
+ * ```
10377
+ */
10378
+ async updateById(id, request) {
10379
+ return await this.fetch.put(`/api/v1/secrets/${encodeURIComponent(id)}`, request);
10380
+ }
10381
+ /**
10382
+ * Delete a secret by ID
10383
+ *
10384
+ * @param id - Secret UUID
10385
+ * @returns Promise resolving when deletion is complete
10386
+ *
10387
+ * @example
10388
+ * ```typescript
10389
+ * await client.secrets.deleteById('550e8400-e29b-41d4-a716-446655440000')
10390
+ * ```
10391
+ */
10392
+ async deleteById(id) {
10393
+ await this.fetch.delete(`/api/v1/secrets/${encodeURIComponent(id)}`);
10394
+ }
10395
+ /**
10396
+ * Get version history for a secret by ID
10397
+ *
10398
+ * @param id - Secret UUID
10399
+ * @returns Promise resolving to array of secret versions
10400
+ *
10401
+ * @example
10402
+ * ```typescript
10403
+ * const versions = await client.secrets.getVersionsById('550e8400-e29b-41d4-a716-446655440000')
10404
+ * ```
10405
+ */
10406
+ async getVersionsById(id) {
10407
+ return await this.fetch.get(`/api/v1/secrets/${encodeURIComponent(id)}/versions`);
10408
+ }
10409
+ /**
10410
+ * Rollback a secret to a previous version by ID
10411
+ *
10412
+ * @param id - Secret UUID
10413
+ * @param version - Version number to rollback to
10414
+ * @returns Promise resolving to the updated secret
10415
+ *
10416
+ * @example
10417
+ * ```typescript
10418
+ * const secret = await client.secrets.rollbackById('550e8400-e29b-41d4-a716-446655440000', 2)
10419
+ * ```
10420
+ */
10421
+ async rollbackById(id, version) {
10422
+ return await this.fetch.post(`/api/v1/secrets/${encodeURIComponent(id)}/rollback/${version}`, {});
10423
+ }
10424
+ };
10425
+
10110
10426
  // src/ai.ts
10111
10427
  var FluxbaseAIChat = class {
10112
10428
  constructor(options) {
@@ -12591,6 +12907,7 @@ var FluxbaseClient = class {
12591
12907
  this.admin = new FluxbaseAdmin(this.fetch);
12592
12908
  this.management = new FluxbaseManagement(this.fetch);
12593
12909
  this.settings = new SettingsClient(this.fetch);
12910
+ this.secrets = new SecretsManager(this.fetch);
12594
12911
  const wsProtocol = fluxbaseUrl.startsWith("https") ? "wss" : "ws";
12595
12912
  const wsBaseUrl = fluxbaseUrl.replace(/^https?:/, wsProtocol + ":");
12596
12913
  this.ai = new FluxbaseAI(this.fetch, wsBaseUrl);
@@ -12891,6 +13208,7 @@ exports.OAuthProviderManager = OAuthProviderManager;
12891
13208
  exports.QueryBuilder = QueryBuilder;
12892
13209
  exports.RealtimeChannel = RealtimeChannel;
12893
13210
  exports.SchemaQueryBuilder = SchemaQueryBuilder;
13211
+ exports.SecretsManager = SecretsManager;
12894
13212
  exports.SettingsClient = SettingsClient;
12895
13213
  exports.StorageBucket = StorageBucket;
12896
13214
  exports.SystemSettingsManager = SystemSettingsManager;