@nimbleflux/fluxbase-sdk-react 2026.3.6 → 2026.3.7-rc.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbleflux/fluxbase-sdk-react",
3
- "version": "2026.3.6",
3
+ "version": "2026.3.7-rc.1",
4
4
  "description": "React hooks for Fluxbase SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "peerDependencies": {
42
- "@nimbleflux/fluxbase-sdk": "^2026.3.6",
42
+ "@nimbleflux/fluxbase-sdk": "^2026.3.7-rc.1",
43
43
  "@tanstack/react-query": "^5.90.21",
44
44
  "react": "^18.0.0 || ^19.0.0"
45
45
  },
package/src/index.ts CHANGED
@@ -120,6 +120,16 @@ export {
120
120
  useSystemSettings,
121
121
  } from "./use-admin-hooks";
122
122
 
123
+ // Multi-tenancy hooks
124
+ export {
125
+ useTenants,
126
+ useTenant,
127
+ type UseTenantsOptions,
128
+ type UseTenantsReturn,
129
+ type UseTenantOptions,
130
+ type UseTenantReturn,
131
+ } from "./use-tenant";
132
+
123
133
  // Table export hooks
124
134
  export {
125
135
  useTableDetails,
@@ -172,4 +182,9 @@ export type {
172
182
  GraphQLError,
173
183
  GraphQLErrorLocation,
174
184
  GraphQLRequestOptions,
185
+ // Multi-tenancy types
186
+ Tenant,
187
+ TenantWithRole,
188
+ CreateTenantOptions,
189
+ UpdateTenantOptions,
175
190
  } from "@nimbleflux/fluxbase-sdk";
@@ -1,6 +1,6 @@
1
1
  import { useState, useEffect, useCallback } from "react";
2
2
  import { useFluxbaseClient } from "./context";
3
- import type { AdminAuthResponse, DataResponse } from "@fluxbase/sdk";
3
+ import type { AdminAuthResponse } from "@nimbleflux/fluxbase-sdk";
4
4
 
5
5
  /**
6
6
  * Simplified admin user type returned by authentication
@@ -4,8 +4,8 @@
4
4
  * Hooks for managing application settings, system settings, and webhooks.
5
5
  */
6
6
 
7
- import { useState, useEffect, useCallback } from 'react'
8
- import { useFluxbaseClient } from './context'
7
+ import { useState, useEffect, useCallback } from "react";
8
+ import { useFluxbaseClient } from "./context";
9
9
  import type {
10
10
  AppSettings,
11
11
  UpdateAppSettingsRequest,
@@ -13,23 +13,23 @@ import type {
13
13
  UpdateSystemSettingRequest,
14
14
  Webhook,
15
15
  CreateWebhookRequest,
16
- UpdateWebhookRequest
17
- } from '@fluxbase/sdk'
16
+ UpdateWebhookRequest,
17
+ } from "@nimbleflux/fluxbase-sdk";
18
18
 
19
19
  // ============================================================================
20
20
  // useAppSettings Hook
21
21
  // ============================================================================
22
22
 
23
23
  export interface UseAppSettingsOptions {
24
- autoFetch?: boolean
24
+ autoFetch?: boolean;
25
25
  }
26
26
 
27
27
  export interface UseAppSettingsReturn {
28
- settings: AppSettings | null
29
- isLoading: boolean
30
- error: Error | null
31
- refetch: () => Promise<void>
32
- updateSettings: (update: UpdateAppSettingsRequest) => Promise<void>
28
+ settings: AppSettings | null;
29
+ isLoading: boolean;
30
+ error: Error | null;
31
+ refetch: () => Promise<void>;
32
+ updateSettings: (update: UpdateAppSettingsRequest) => Promise<void>;
33
33
  }
34
34
 
35
35
  /**
@@ -50,48 +50,50 @@ export interface UseAppSettingsReturn {
50
50
  * }
51
51
  * ```
52
52
  */
53
- export function useAppSettings(options: UseAppSettingsOptions = {}): UseAppSettingsReturn {
54
- const { autoFetch = true } = options
55
- const client = useFluxbaseClient()
53
+ export function useAppSettings(
54
+ options: UseAppSettingsOptions = {},
55
+ ): UseAppSettingsReturn {
56
+ const { autoFetch = true } = options;
57
+ const client = useFluxbaseClient();
56
58
 
57
- const [settings, setSettings] = useState<AppSettings | null>(null)
58
- const [isLoading, setIsLoading] = useState(autoFetch)
59
- const [error, setError] = useState<Error | null>(null)
59
+ const [settings, setSettings] = useState<AppSettings | null>(null);
60
+ const [isLoading, setIsLoading] = useState(autoFetch);
61
+ const [error, setError] = useState<Error | null>(null);
60
62
 
61
63
  const fetchSettings = useCallback(async () => {
62
64
  try {
63
- setIsLoading(true)
64
- setError(null)
65
- const appSettings = await client.admin.settings.app.get()
66
- setSettings(appSettings)
65
+ setIsLoading(true);
66
+ setError(null);
67
+ const appSettings = await client.admin.settings.app.get();
68
+ setSettings(appSettings);
67
69
  } catch (err) {
68
- setError(err as Error)
70
+ setError(err as Error);
69
71
  } finally {
70
- setIsLoading(false)
72
+ setIsLoading(false);
71
73
  }
72
- }, [client])
74
+ }, [client]);
73
75
 
74
76
  const updateSettings = useCallback(
75
77
  async (update: UpdateAppSettingsRequest): Promise<void> => {
76
- await client.admin.settings.app.update(update)
77
- await fetchSettings()
78
+ await client.admin.settings.app.update(update);
79
+ await fetchSettings();
78
80
  },
79
- [client, fetchSettings]
80
- )
81
+ [client, fetchSettings],
82
+ );
81
83
 
82
84
  useEffect(() => {
83
85
  if (autoFetch) {
84
- fetchSettings()
86
+ fetchSettings();
85
87
  }
86
- }, [autoFetch, fetchSettings])
88
+ }, [autoFetch, fetchSettings]);
87
89
 
88
90
  return {
89
91
  settings,
90
92
  isLoading,
91
93
  error,
92
94
  refetch: fetchSettings,
93
- updateSettings
94
- }
95
+ updateSettings,
96
+ };
95
97
  }
96
98
 
97
99
  // ============================================================================
@@ -99,17 +101,20 @@ export function useAppSettings(options: UseAppSettingsOptions = {}): UseAppSetti
99
101
  // ============================================================================
100
102
 
101
103
  export interface UseSystemSettingsOptions {
102
- autoFetch?: boolean
104
+ autoFetch?: boolean;
103
105
  }
104
106
 
105
107
  export interface UseSystemSettingsReturn {
106
- settings: SystemSetting[]
107
- isLoading: boolean
108
- error: Error | null
109
- refetch: () => Promise<void>
110
- getSetting: (key: string) => SystemSetting | undefined
111
- updateSetting: (key: string, update: UpdateSystemSettingRequest) => Promise<void>
112
- deleteSetting: (key: string) => Promise<void>
108
+ settings: SystemSetting[];
109
+ isLoading: boolean;
110
+ error: Error | null;
111
+ refetch: () => Promise<void>;
112
+ getSetting: (key: string) => SystemSetting | undefined;
113
+ updateSetting: (
114
+ key: string,
115
+ update: UpdateSystemSettingRequest,
116
+ ) => Promise<void>;
117
+ deleteSetting: (key: string) => Promise<void>;
113
118
  }
114
119
 
115
120
  /**
@@ -128,55 +133,57 @@ export interface UseSystemSettingsReturn {
128
133
  * }
129
134
  * ```
130
135
  */
131
- export function useSystemSettings(options: UseSystemSettingsOptions = {}): UseSystemSettingsReturn {
132
- const { autoFetch = true } = options
133
- const client = useFluxbaseClient()
136
+ export function useSystemSettings(
137
+ options: UseSystemSettingsOptions = {},
138
+ ): UseSystemSettingsReturn {
139
+ const { autoFetch = true } = options;
140
+ const client = useFluxbaseClient();
134
141
 
135
- const [settings, setSettings] = useState<SystemSetting[]>([])
136
- const [isLoading, setIsLoading] = useState(autoFetch)
137
- const [error, setError] = useState<Error | null>(null)
142
+ const [settings, setSettings] = useState<SystemSetting[]>([]);
143
+ const [isLoading, setIsLoading] = useState(autoFetch);
144
+ const [error, setError] = useState<Error | null>(null);
138
145
 
139
146
  const fetchSettings = useCallback(async () => {
140
147
  try {
141
- setIsLoading(true)
142
- setError(null)
143
- const response = await client.admin.settings.system.list()
144
- setSettings(response.settings)
148
+ setIsLoading(true);
149
+ setError(null);
150
+ const response = await client.admin.settings.system.list();
151
+ setSettings(response.settings);
145
152
  } catch (err) {
146
- setError(err as Error)
153
+ setError(err as Error);
147
154
  } finally {
148
- setIsLoading(false)
155
+ setIsLoading(false);
149
156
  }
150
- }, [client])
157
+ }, [client]);
151
158
 
152
159
  const getSetting = useCallback(
153
160
  (key: string): SystemSetting | undefined => {
154
- return settings.find((s) => s.key === key)
161
+ return settings.find((s) => s.key === key);
155
162
  },
156
- [settings]
157
- )
163
+ [settings],
164
+ );
158
165
 
159
166
  const updateSetting = useCallback(
160
167
  async (key: string, update: UpdateSystemSettingRequest): Promise<void> => {
161
- await client.admin.settings.system.update(key, update)
162
- await fetchSettings()
168
+ await client.admin.settings.system.update(key, update);
169
+ await fetchSettings();
163
170
  },
164
- [client, fetchSettings]
165
- )
171
+ [client, fetchSettings],
172
+ );
166
173
 
167
174
  const deleteSetting = useCallback(
168
175
  async (key: string): Promise<void> => {
169
- await client.admin.settings.system.delete(key)
170
- await fetchSettings()
176
+ await client.admin.settings.system.delete(key);
177
+ await fetchSettings();
171
178
  },
172
- [client, fetchSettings]
173
- )
179
+ [client, fetchSettings],
180
+ );
174
181
 
175
182
  useEffect(() => {
176
183
  if (autoFetch) {
177
- fetchSettings()
184
+ fetchSettings();
178
185
  }
179
- }, [autoFetch, fetchSettings])
186
+ }, [autoFetch, fetchSettings]);
180
187
 
181
188
  return {
182
189
  settings,
@@ -185,8 +192,8 @@ export function useSystemSettings(options: UseSystemSettingsOptions = {}): UseSy
185
192
  refetch: fetchSettings,
186
193
  getSetting,
187
194
  updateSetting,
188
- deleteSetting
189
- }
195
+ deleteSetting,
196
+ };
190
197
  }
191
198
 
192
199
  // ============================================================================
@@ -194,19 +201,19 @@ export function useSystemSettings(options: UseSystemSettingsOptions = {}): UseSy
194
201
  // ============================================================================
195
202
 
196
203
  export interface UseWebhooksOptions {
197
- autoFetch?: boolean
198
- refetchInterval?: number
204
+ autoFetch?: boolean;
205
+ refetchInterval?: number;
199
206
  }
200
207
 
201
208
  export interface UseWebhooksReturn {
202
- webhooks: Webhook[]
203
- isLoading: boolean
204
- error: Error | null
205
- refetch: () => Promise<void>
206
- createWebhook: (webhook: CreateWebhookRequest) => Promise<Webhook>
207
- updateWebhook: (id: string, update: UpdateWebhookRequest) => Promise<Webhook>
208
- deleteWebhook: (id: string) => Promise<void>
209
- testWebhook: (id: string) => Promise<void>
209
+ webhooks: Webhook[];
210
+ isLoading: boolean;
211
+ error: Error | null;
212
+ refetch: () => Promise<void>;
213
+ createWebhook: (webhook: CreateWebhookRequest) => Promise<Webhook>;
214
+ updateWebhook: (id: string, update: UpdateWebhookRequest) => Promise<Webhook>;
215
+ deleteWebhook: (id: string) => Promise<void>;
216
+ testWebhook: (id: string) => Promise<void>;
210
217
  }
211
218
 
212
219
  /**
@@ -231,70 +238,72 @@ export interface UseWebhooksReturn {
231
238
  * }
232
239
  * ```
233
240
  */
234
- export function useWebhooks(options: UseWebhooksOptions = {}): UseWebhooksReturn {
235
- const { autoFetch = true, refetchInterval = 0 } = options
236
- const client = useFluxbaseClient()
241
+ export function useWebhooks(
242
+ options: UseWebhooksOptions = {},
243
+ ): UseWebhooksReturn {
244
+ const { autoFetch = true, refetchInterval = 0 } = options;
245
+ const client = useFluxbaseClient();
237
246
 
238
- const [webhooks, setWebhooks] = useState<Webhook[]>([])
239
- const [isLoading, setIsLoading] = useState(autoFetch)
240
- const [error, setError] = useState<Error | null>(null)
247
+ const [webhooks, setWebhooks] = useState<Webhook[]>([]);
248
+ const [isLoading, setIsLoading] = useState(autoFetch);
249
+ const [error, setError] = useState<Error | null>(null);
241
250
 
242
251
  const fetchWebhooks = useCallback(async () => {
243
252
  try {
244
- setIsLoading(true)
245
- setError(null)
246
- const response = await client.admin.management.webhooks.list()
247
- setWebhooks(response.webhooks)
253
+ setIsLoading(true);
254
+ setError(null);
255
+ const response = await client.admin.management.webhooks.list();
256
+ setWebhooks(response.webhooks);
248
257
  } catch (err) {
249
- setError(err as Error)
258
+ setError(err as Error);
250
259
  } finally {
251
- setIsLoading(false)
260
+ setIsLoading(false);
252
261
  }
253
- }, [client])
262
+ }, [client]);
254
263
 
255
264
  const createWebhook = useCallback(
256
265
  async (webhook: CreateWebhookRequest): Promise<Webhook> => {
257
- const created = await client.admin.management.webhooks.create(webhook)
258
- await fetchWebhooks()
259
- return created
266
+ const created = await client.admin.management.webhooks.create(webhook);
267
+ await fetchWebhooks();
268
+ return created;
260
269
  },
261
- [client, fetchWebhooks]
262
- )
270
+ [client, fetchWebhooks],
271
+ );
263
272
 
264
273
  const updateWebhook = useCallback(
265
274
  async (id: string, update: UpdateWebhookRequest): Promise<Webhook> => {
266
- const updated = await client.admin.management.webhooks.update(id, update)
267
- await fetchWebhooks()
268
- return updated
275
+ const updated = await client.admin.management.webhooks.update(id, update);
276
+ await fetchWebhooks();
277
+ return updated;
269
278
  },
270
- [client, fetchWebhooks]
271
- )
279
+ [client, fetchWebhooks],
280
+ );
272
281
 
273
282
  const deleteWebhook = useCallback(
274
283
  async (id: string): Promise<void> => {
275
- await client.admin.management.webhooks.delete(id)
276
- await fetchWebhooks()
284
+ await client.admin.management.webhooks.delete(id);
285
+ await fetchWebhooks();
277
286
  },
278
- [client, fetchWebhooks]
279
- )
287
+ [client, fetchWebhooks],
288
+ );
280
289
 
281
290
  const testWebhook = useCallback(
282
291
  async (id: string): Promise<void> => {
283
- await client.admin.management.webhooks.test(id)
292
+ await client.admin.management.webhooks.test(id);
284
293
  },
285
- [client]
286
- )
294
+ [client],
295
+ );
287
296
 
288
297
  useEffect(() => {
289
298
  if (autoFetch) {
290
- fetchWebhooks()
299
+ fetchWebhooks();
291
300
  }
292
301
 
293
302
  if (refetchInterval > 0) {
294
- const interval = setInterval(fetchWebhooks, refetchInterval)
295
- return () => clearInterval(interval)
303
+ const interval = setInterval(fetchWebhooks, refetchInterval);
304
+ return () => clearInterval(interval);
296
305
  }
297
- }, [autoFetch, refetchInterval, fetchWebhooks])
306
+ }, [autoFetch, refetchInterval, fetchWebhooks]);
298
307
 
299
308
  return {
300
309
  webhooks,
@@ -304,6 +313,6 @@ export function useWebhooks(options: UseWebhooksOptions = {}): UseWebhooksReturn
304
313
  createWebhook,
305
314
  updateWebhook,
306
315
  deleteWebhook,
307
- testWebhook
308
- }
316
+ testWebhook,
317
+ };
309
318
  }
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { useQuery } from "@tanstack/react-query";
10
10
  import { useFluxbaseClient } from "./context";
11
- import type { AuthConfig } from "@fluxbase/sdk";
11
+ import type { AuthConfig } from "@nimbleflux/fluxbase-sdk";
12
12
 
13
13
  /**
14
14
  * Hook to get the complete authentication configuration from the server
package/src/use-auth.ts CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  SignUpCredentials,
10
10
  User,
11
11
  AuthSession,
12
- } from "@fluxbase/sdk";
12
+ } from "@nimbleflux/fluxbase-sdk";
13
13
 
14
14
  /**
15
15
  * Hook to get the current user
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { useQuery } from "@tanstack/react-query";
10
10
  import { useFluxbaseClient } from "./context";
11
- import type { CaptchaConfig, CaptchaProvider } from "@fluxbase/sdk";
11
+ import type { CaptchaConfig, CaptchaProvider } from "@nimbleflux/fluxbase-sdk";
12
12
  import { useCallback, useEffect, useRef, useState } from "react";
13
13
 
14
14
  /**
@@ -241,7 +241,7 @@ export function useCaptcha(provider?: CaptchaProvider): CaptchaState {
241
241
  */
242
242
  export function isCaptchaRequiredForEndpoint(
243
243
  config: CaptchaConfig | undefined,
244
- endpoint: string
244
+ endpoint: string,
245
245
  ): boolean {
246
246
  if (!config?.enabled) {
247
247
  return false;