@fluxbase/sdk-react 0.0.1-rc.2
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/CHANGELOG.md +67 -0
- package/README-ADMIN.md +1076 -0
- package/README.md +178 -0
- package/dist/index.d.mts +606 -0
- package/dist/index.d.ts +606 -0
- package/dist/index.js +992 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +926 -0
- package/dist/index.mjs.map +1 -0
- package/examples/AdminDashboard.tsx +513 -0
- package/examples/README.md +163 -0
- package/package.json +52 -0
- package/src/context.tsx +33 -0
- package/src/index.ts +113 -0
- package/src/use-admin-auth.ts +168 -0
- package/src/use-admin-hooks.ts +309 -0
- package/src/use-api-keys.ts +174 -0
- package/src/use-auth.ts +146 -0
- package/src/use-query.ts +165 -0
- package/src/use-realtime.ts +161 -0
- package/src/use-rpc.ts +109 -0
- package/src/use-storage.ts +257 -0
- package/src/use-users.ts +191 -0
- package/tsconfig.json +24 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +11 -0
- package/typedoc.json +35 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FluxbaseProvider: () => FluxbaseProvider,
|
|
24
|
+
useAPIKeys: () => useAPIKeys,
|
|
25
|
+
useAdminAuth: () => useAdminAuth,
|
|
26
|
+
useAppSettings: () => useAppSettings,
|
|
27
|
+
useAuth: () => useAuth,
|
|
28
|
+
useCreateBucket: () => useCreateBucket,
|
|
29
|
+
useDelete: () => useDelete,
|
|
30
|
+
useDeleteBucket: () => useDeleteBucket,
|
|
31
|
+
useFluxbaseClient: () => useFluxbaseClient,
|
|
32
|
+
useFluxbaseQuery: () => useFluxbaseQuery,
|
|
33
|
+
useInsert: () => useInsert,
|
|
34
|
+
useRPC: () => useRPC,
|
|
35
|
+
useRPCBatch: () => useRPCBatch,
|
|
36
|
+
useRPCMutation: () => useRPCMutation,
|
|
37
|
+
useRealtime: () => useRealtime,
|
|
38
|
+
useSession: () => useSession,
|
|
39
|
+
useSignIn: () => useSignIn,
|
|
40
|
+
useSignOut: () => useSignOut,
|
|
41
|
+
useSignUp: () => useSignUp,
|
|
42
|
+
useStorageBuckets: () => useStorageBuckets,
|
|
43
|
+
useStorageCopy: () => useStorageCopy,
|
|
44
|
+
useStorageDelete: () => useStorageDelete,
|
|
45
|
+
useStorageDownload: () => useStorageDownload,
|
|
46
|
+
useStorageList: () => useStorageList,
|
|
47
|
+
useStorageMove: () => useStorageMove,
|
|
48
|
+
useStoragePublicUrl: () => useStoragePublicUrl,
|
|
49
|
+
useStorageSignedUrl: () => useStorageSignedUrl,
|
|
50
|
+
useStorageUpload: () => useStorageUpload,
|
|
51
|
+
useSystemSettings: () => useSystemSettings,
|
|
52
|
+
useTable: () => useTable,
|
|
53
|
+
useTableDeletes: () => useTableDeletes,
|
|
54
|
+
useTableInserts: () => useTableInserts,
|
|
55
|
+
useTableSubscription: () => useTableSubscription,
|
|
56
|
+
useTableUpdates: () => useTableUpdates,
|
|
57
|
+
useUpdate: () => useUpdate,
|
|
58
|
+
useUpdateUser: () => useUpdateUser,
|
|
59
|
+
useUpsert: () => useUpsert,
|
|
60
|
+
useUser: () => useUser,
|
|
61
|
+
useUsers: () => useUsers,
|
|
62
|
+
useWebhooks: () => useWebhooks
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(index_exports);
|
|
65
|
+
|
|
66
|
+
// src/context.tsx
|
|
67
|
+
var import_react = require("react");
|
|
68
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
69
|
+
var FluxbaseContext = (0, import_react.createContext)(null);
|
|
70
|
+
function FluxbaseProvider({ client, children }) {
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FluxbaseContext.Provider, { value: client, children });
|
|
72
|
+
}
|
|
73
|
+
function useFluxbaseClient() {
|
|
74
|
+
const client = (0, import_react.useContext)(FluxbaseContext);
|
|
75
|
+
if (!client) {
|
|
76
|
+
throw new Error("useFluxbaseClient must be used within a FluxbaseProvider");
|
|
77
|
+
}
|
|
78
|
+
return client;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/use-auth.ts
|
|
82
|
+
var import_react_query = require("@tanstack/react-query");
|
|
83
|
+
function useUser() {
|
|
84
|
+
const client = useFluxbaseClient();
|
|
85
|
+
return (0, import_react_query.useQuery)({
|
|
86
|
+
queryKey: ["fluxbase", "auth", "user"],
|
|
87
|
+
queryFn: async () => {
|
|
88
|
+
const session = client.auth.getSession();
|
|
89
|
+
if (!session) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
return await client.auth.getCurrentUser();
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
staleTime: 1e3 * 60 * 5
|
|
99
|
+
// 5 minutes
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function useSession() {
|
|
103
|
+
const client = useFluxbaseClient();
|
|
104
|
+
return (0, import_react_query.useQuery)({
|
|
105
|
+
queryKey: ["fluxbase", "auth", "session"],
|
|
106
|
+
queryFn: () => client.auth.getSession(),
|
|
107
|
+
staleTime: 1e3 * 60 * 5
|
|
108
|
+
// 5 minutes
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function useSignIn() {
|
|
112
|
+
const client = useFluxbaseClient();
|
|
113
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
114
|
+
return (0, import_react_query.useMutation)({
|
|
115
|
+
mutationFn: async (credentials) => {
|
|
116
|
+
return await client.auth.signIn(credentials);
|
|
117
|
+
},
|
|
118
|
+
onSuccess: (session) => {
|
|
119
|
+
queryClient.setQueryData(["fluxbase", "auth", "session"], session);
|
|
120
|
+
if ("user" in session) {
|
|
121
|
+
queryClient.setQueryData(["fluxbase", "auth", "user"], session.user);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function useSignUp() {
|
|
127
|
+
const client = useFluxbaseClient();
|
|
128
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
129
|
+
return (0, import_react_query.useMutation)({
|
|
130
|
+
mutationFn: async (credentials) => {
|
|
131
|
+
return await client.auth.signUp(credentials);
|
|
132
|
+
},
|
|
133
|
+
onSuccess: (session) => {
|
|
134
|
+
queryClient.setQueryData(["fluxbase", "auth", "session"], session);
|
|
135
|
+
queryClient.setQueryData(["fluxbase", "auth", "user"], session.user);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function useSignOut() {
|
|
140
|
+
const client = useFluxbaseClient();
|
|
141
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
142
|
+
return (0, import_react_query.useMutation)({
|
|
143
|
+
mutationFn: async () => {
|
|
144
|
+
await client.auth.signOut();
|
|
145
|
+
},
|
|
146
|
+
onSuccess: () => {
|
|
147
|
+
queryClient.setQueryData(["fluxbase", "auth", "session"], null);
|
|
148
|
+
queryClient.setQueryData(["fluxbase", "auth", "user"], null);
|
|
149
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase"] });
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function useUpdateUser() {
|
|
154
|
+
const client = useFluxbaseClient();
|
|
155
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
156
|
+
return (0, import_react_query.useMutation)({
|
|
157
|
+
mutationFn: async (data) => {
|
|
158
|
+
return await client.auth.updateUser(data);
|
|
159
|
+
},
|
|
160
|
+
onSuccess: (user) => {
|
|
161
|
+
queryClient.setQueryData(["fluxbase", "auth", "user"], user);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function useAuth() {
|
|
166
|
+
const { data: user, isLoading: isLoadingUser } = useUser();
|
|
167
|
+
const { data: session, isLoading: isLoadingSession } = useSession();
|
|
168
|
+
const signIn = useSignIn();
|
|
169
|
+
const signUp = useSignUp();
|
|
170
|
+
const signOut = useSignOut();
|
|
171
|
+
const updateUser = useUpdateUser();
|
|
172
|
+
return {
|
|
173
|
+
user,
|
|
174
|
+
session,
|
|
175
|
+
isLoading: isLoadingUser || isLoadingSession,
|
|
176
|
+
isAuthenticated: !!session,
|
|
177
|
+
signIn: signIn.mutateAsync,
|
|
178
|
+
signUp: signUp.mutateAsync,
|
|
179
|
+
signOut: signOut.mutateAsync,
|
|
180
|
+
updateUser: updateUser.mutateAsync,
|
|
181
|
+
isSigningIn: signIn.isPending,
|
|
182
|
+
isSigningUp: signUp.isPending,
|
|
183
|
+
isSigningOut: signOut.isPending,
|
|
184
|
+
isUpdating: updateUser.isPending
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/use-query.ts
|
|
189
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
190
|
+
function useFluxbaseQuery(buildQuery, options) {
|
|
191
|
+
const client = useFluxbaseClient();
|
|
192
|
+
const queryKey = options?.queryKey || ["fluxbase", "query", buildQuery.toString()];
|
|
193
|
+
return (0, import_react_query2.useQuery)({
|
|
194
|
+
queryKey,
|
|
195
|
+
queryFn: async () => {
|
|
196
|
+
const query = buildQuery(client);
|
|
197
|
+
const { data, error } = await query.execute();
|
|
198
|
+
if (error) {
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
return Array.isArray(data) ? data : data ? [data] : [];
|
|
202
|
+
},
|
|
203
|
+
...options
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function useTable(table, buildQuery, options) {
|
|
207
|
+
const client = useFluxbaseClient();
|
|
208
|
+
return useFluxbaseQuery(
|
|
209
|
+
(client2) => {
|
|
210
|
+
const query = client2.from(table);
|
|
211
|
+
return buildQuery ? buildQuery(query) : query;
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
...options,
|
|
215
|
+
queryKey: options?.queryKey || ["fluxbase", "table", table, buildQuery?.toString()]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
function useInsert(table) {
|
|
220
|
+
const client = useFluxbaseClient();
|
|
221
|
+
const queryClient = (0, import_react_query2.useQueryClient)();
|
|
222
|
+
return (0, import_react_query2.useMutation)({
|
|
223
|
+
mutationFn: async (data) => {
|
|
224
|
+
const query = client.from(table);
|
|
225
|
+
const { data: result, error } = await query.insert(data);
|
|
226
|
+
if (error) {
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
},
|
|
231
|
+
onSuccess: () => {
|
|
232
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "table", table] });
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function useUpdate(table) {
|
|
237
|
+
const client = useFluxbaseClient();
|
|
238
|
+
const queryClient = (0, import_react_query2.useQueryClient)();
|
|
239
|
+
return (0, import_react_query2.useMutation)({
|
|
240
|
+
mutationFn: async (params) => {
|
|
241
|
+
const query = client.from(table);
|
|
242
|
+
const builtQuery = params.buildQuery(query);
|
|
243
|
+
const { data: result, error } = await builtQuery.update(params.data);
|
|
244
|
+
if (error) {
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
},
|
|
249
|
+
onSuccess: () => {
|
|
250
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "table", table] });
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function useUpsert(table) {
|
|
255
|
+
const client = useFluxbaseClient();
|
|
256
|
+
const queryClient = (0, import_react_query2.useQueryClient)();
|
|
257
|
+
return (0, import_react_query2.useMutation)({
|
|
258
|
+
mutationFn: async (data) => {
|
|
259
|
+
const query = client.from(table);
|
|
260
|
+
const { data: result, error } = await query.upsert(data);
|
|
261
|
+
if (error) {
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
},
|
|
266
|
+
onSuccess: () => {
|
|
267
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "table", table] });
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function useDelete(table) {
|
|
272
|
+
const client = useFluxbaseClient();
|
|
273
|
+
const queryClient = (0, import_react_query2.useQueryClient)();
|
|
274
|
+
return (0, import_react_query2.useMutation)({
|
|
275
|
+
mutationFn: async (buildQuery) => {
|
|
276
|
+
const query = client.from(table);
|
|
277
|
+
const builtQuery = buildQuery(query);
|
|
278
|
+
const { error } = await builtQuery.delete();
|
|
279
|
+
if (error) {
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
onSuccess: () => {
|
|
284
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "table", table] });
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/use-realtime.ts
|
|
290
|
+
var import_react2 = require("react");
|
|
291
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
292
|
+
function useRealtime(options) {
|
|
293
|
+
const client = useFluxbaseClient();
|
|
294
|
+
const queryClient = (0, import_react_query3.useQueryClient)();
|
|
295
|
+
const channelRef = (0, import_react2.useRef)(null);
|
|
296
|
+
const {
|
|
297
|
+
channel: channelName,
|
|
298
|
+
event = "*",
|
|
299
|
+
callback,
|
|
300
|
+
autoInvalidate = true,
|
|
301
|
+
invalidateKey,
|
|
302
|
+
enabled = true
|
|
303
|
+
} = options;
|
|
304
|
+
(0, import_react2.useEffect)(() => {
|
|
305
|
+
if (!enabled) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const channel = client.realtime.channel(channelName);
|
|
309
|
+
channelRef.current = channel;
|
|
310
|
+
const handleChange = (payload) => {
|
|
311
|
+
if (callback) {
|
|
312
|
+
callback(payload);
|
|
313
|
+
}
|
|
314
|
+
if (autoInvalidate) {
|
|
315
|
+
const tableName = channelName.replace(/^table:/, "");
|
|
316
|
+
const key = invalidateKey || ["fluxbase", "table", tableName];
|
|
317
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
channel.on(event, handleChange).subscribe();
|
|
321
|
+
return () => {
|
|
322
|
+
channel.unsubscribe();
|
|
323
|
+
channelRef.current = null;
|
|
324
|
+
};
|
|
325
|
+
}, [client, channelName, event, callback, autoInvalidate, invalidateKey, queryClient, enabled]);
|
|
326
|
+
return {
|
|
327
|
+
channel: channelRef.current
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function useTableSubscription(table, options) {
|
|
331
|
+
return useRealtime({
|
|
332
|
+
...options,
|
|
333
|
+
channel: `table:${table}`
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function useTableInserts(table, callback, options) {
|
|
337
|
+
return useRealtime({
|
|
338
|
+
...options,
|
|
339
|
+
channel: `table:${table}`,
|
|
340
|
+
event: "INSERT",
|
|
341
|
+
callback
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function useTableUpdates(table, callback, options) {
|
|
345
|
+
return useRealtime({
|
|
346
|
+
...options,
|
|
347
|
+
channel: `table:${table}`,
|
|
348
|
+
event: "UPDATE",
|
|
349
|
+
callback
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function useTableDeletes(table, callback, options) {
|
|
353
|
+
return useRealtime({
|
|
354
|
+
...options,
|
|
355
|
+
channel: `table:${table}`,
|
|
356
|
+
event: "DELETE",
|
|
357
|
+
callback
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/use-storage.ts
|
|
362
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
363
|
+
function useStorageList(bucket, options) {
|
|
364
|
+
const client = useFluxbaseClient();
|
|
365
|
+
const { prefix, limit, offset, ...queryOptions } = options || {};
|
|
366
|
+
return (0, import_react_query4.useQuery)({
|
|
367
|
+
queryKey: ["fluxbase", "storage", bucket, "list", { prefix, limit, offset }],
|
|
368
|
+
queryFn: async () => {
|
|
369
|
+
const { data, error } = await client.storage.from(bucket).list({ prefix, limit, offset });
|
|
370
|
+
if (error) {
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
return data || [];
|
|
374
|
+
},
|
|
375
|
+
...queryOptions
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function useStorageUpload(bucket) {
|
|
379
|
+
const client = useFluxbaseClient();
|
|
380
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
381
|
+
return (0, import_react_query4.useMutation)({
|
|
382
|
+
mutationFn: async (params) => {
|
|
383
|
+
const { path, file, options } = params;
|
|
384
|
+
const { data, error } = await client.storage.from(bucket).upload(path, file, options);
|
|
385
|
+
if (error) {
|
|
386
|
+
throw error;
|
|
387
|
+
}
|
|
388
|
+
return data;
|
|
389
|
+
},
|
|
390
|
+
onSuccess: () => {
|
|
391
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function useStorageDownload(bucket, path, enabled = true) {
|
|
396
|
+
const client = useFluxbaseClient();
|
|
397
|
+
return (0, import_react_query4.useQuery)({
|
|
398
|
+
queryKey: ["fluxbase", "storage", bucket, "download", path],
|
|
399
|
+
queryFn: async () => {
|
|
400
|
+
if (!path) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
const { data, error } = await client.storage.from(bucket).download(path);
|
|
404
|
+
if (error) {
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
return data;
|
|
408
|
+
},
|
|
409
|
+
enabled: enabled && !!path
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function useStorageDelete(bucket) {
|
|
413
|
+
const client = useFluxbaseClient();
|
|
414
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
415
|
+
return (0, import_react_query4.useMutation)({
|
|
416
|
+
mutationFn: async (paths) => {
|
|
417
|
+
const { error } = await client.storage.from(bucket).remove(paths);
|
|
418
|
+
if (error) {
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
onSuccess: () => {
|
|
423
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
function useStoragePublicUrl(bucket, path) {
|
|
428
|
+
const client = useFluxbaseClient();
|
|
429
|
+
if (!path) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
const { data } = client.storage.from(bucket).getPublicUrl(path);
|
|
433
|
+
return data.publicUrl;
|
|
434
|
+
}
|
|
435
|
+
function useStorageSignedUrl(bucket, path, expiresIn) {
|
|
436
|
+
const client = useFluxbaseClient();
|
|
437
|
+
return (0, import_react_query4.useQuery)({
|
|
438
|
+
queryKey: ["fluxbase", "storage", bucket, "signed-url", path, expiresIn],
|
|
439
|
+
queryFn: async () => {
|
|
440
|
+
if (!path) {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
const { data, error } = await client.storage.from(bucket).createSignedUrl(path, { expiresIn });
|
|
444
|
+
if (error) {
|
|
445
|
+
throw error;
|
|
446
|
+
}
|
|
447
|
+
return data?.signedUrl || null;
|
|
448
|
+
},
|
|
449
|
+
enabled: !!path,
|
|
450
|
+
staleTime: expiresIn ? expiresIn * 1e3 - 6e4 : 1e3 * 60 * 50
|
|
451
|
+
// Refresh 1 minute before expiry
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function useStorageMove(bucket) {
|
|
455
|
+
const client = useFluxbaseClient();
|
|
456
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
457
|
+
return (0, import_react_query4.useMutation)({
|
|
458
|
+
mutationFn: async (params) => {
|
|
459
|
+
const { fromPath, toPath } = params;
|
|
460
|
+
const { data, error } = await client.storage.from(bucket).move(fromPath, toPath);
|
|
461
|
+
if (error) {
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
464
|
+
return data;
|
|
465
|
+
},
|
|
466
|
+
onSuccess: () => {
|
|
467
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function useStorageCopy(bucket) {
|
|
472
|
+
const client = useFluxbaseClient();
|
|
473
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
474
|
+
return (0, import_react_query4.useMutation)({
|
|
475
|
+
mutationFn: async (params) => {
|
|
476
|
+
const { fromPath, toPath } = params;
|
|
477
|
+
const { data, error } = await client.storage.from(bucket).copy(fromPath, toPath);
|
|
478
|
+
if (error) {
|
|
479
|
+
throw error;
|
|
480
|
+
}
|
|
481
|
+
return data;
|
|
482
|
+
},
|
|
483
|
+
onSuccess: () => {
|
|
484
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", bucket, "list"] });
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
function useStorageBuckets() {
|
|
489
|
+
const client = useFluxbaseClient();
|
|
490
|
+
return (0, import_react_query4.useQuery)({
|
|
491
|
+
queryKey: ["fluxbase", "storage", "buckets"],
|
|
492
|
+
queryFn: async () => {
|
|
493
|
+
const { data, error } = await client.storage.listBuckets();
|
|
494
|
+
if (error) {
|
|
495
|
+
throw error;
|
|
496
|
+
}
|
|
497
|
+
return data || [];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function useCreateBucket() {
|
|
502
|
+
const client = useFluxbaseClient();
|
|
503
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
504
|
+
return (0, import_react_query4.useMutation)({
|
|
505
|
+
mutationFn: async (bucketName) => {
|
|
506
|
+
const { error } = await client.storage.createBucket(bucketName);
|
|
507
|
+
if (error) {
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
onSuccess: () => {
|
|
512
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", "buckets"] });
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
function useDeleteBucket() {
|
|
517
|
+
const client = useFluxbaseClient();
|
|
518
|
+
const queryClient = (0, import_react_query4.useQueryClient)();
|
|
519
|
+
return (0, import_react_query4.useMutation)({
|
|
520
|
+
mutationFn: async (bucketName) => {
|
|
521
|
+
const { error } = await client.storage.deleteBucket(bucketName);
|
|
522
|
+
if (error) {
|
|
523
|
+
throw error;
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
onSuccess: () => {
|
|
527
|
+
queryClient.invalidateQueries({ queryKey: ["fluxbase", "storage", "buckets"] });
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/use-rpc.ts
|
|
533
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
534
|
+
function useRPC(functionName, params, options) {
|
|
535
|
+
const client = useFluxbaseClient();
|
|
536
|
+
return (0, import_react_query5.useQuery)({
|
|
537
|
+
queryKey: ["rpc", functionName, params],
|
|
538
|
+
queryFn: async () => {
|
|
539
|
+
const { data, error } = await client.rpc(functionName, params);
|
|
540
|
+
if (error) {
|
|
541
|
+
throw new Error(error.message);
|
|
542
|
+
}
|
|
543
|
+
return data;
|
|
544
|
+
},
|
|
545
|
+
...options
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
function useRPCMutation(functionName, options) {
|
|
549
|
+
const client = useFluxbaseClient();
|
|
550
|
+
return (0, import_react_query5.useMutation)({
|
|
551
|
+
mutationFn: async (params) => {
|
|
552
|
+
const { data, error } = await client.rpc(functionName, params);
|
|
553
|
+
if (error) {
|
|
554
|
+
throw new Error(error.message);
|
|
555
|
+
}
|
|
556
|
+
return data;
|
|
557
|
+
},
|
|
558
|
+
...options
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function useRPCBatch(calls, options) {
|
|
562
|
+
const client = useFluxbaseClient();
|
|
563
|
+
return (0, import_react_query5.useQuery)({
|
|
564
|
+
queryKey: ["rpc-batch", calls],
|
|
565
|
+
queryFn: async () => {
|
|
566
|
+
const results = await Promise.all(
|
|
567
|
+
calls.map(async ({ name, params }) => {
|
|
568
|
+
const { data, error } = await client.rpc(name, params);
|
|
569
|
+
if (error) {
|
|
570
|
+
throw new Error(`${name}: ${error.message}`);
|
|
571
|
+
}
|
|
572
|
+
return data;
|
|
573
|
+
})
|
|
574
|
+
);
|
|
575
|
+
return results;
|
|
576
|
+
},
|
|
577
|
+
...options
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// src/use-admin-auth.ts
|
|
582
|
+
var import_react3 = require("react");
|
|
583
|
+
function useAdminAuth(options = {}) {
|
|
584
|
+
const { autoCheck = true } = options;
|
|
585
|
+
const client = useFluxbaseClient();
|
|
586
|
+
const [user, setUser] = (0, import_react3.useState)(null);
|
|
587
|
+
const [isLoading, setIsLoading] = (0, import_react3.useState)(autoCheck);
|
|
588
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
589
|
+
const checkAuth = (0, import_react3.useCallback)(async () => {
|
|
590
|
+
try {
|
|
591
|
+
setIsLoading(true);
|
|
592
|
+
setError(null);
|
|
593
|
+
const { user: user2 } = await client.admin.me();
|
|
594
|
+
setUser(user2);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
setUser(null);
|
|
597
|
+
setError(err);
|
|
598
|
+
} finally {
|
|
599
|
+
setIsLoading(false);
|
|
600
|
+
}
|
|
601
|
+
}, [client]);
|
|
602
|
+
const login = (0, import_react3.useCallback)(
|
|
603
|
+
async (email, password) => {
|
|
604
|
+
try {
|
|
605
|
+
setIsLoading(true);
|
|
606
|
+
setError(null);
|
|
607
|
+
const response = await client.admin.login({ email, password });
|
|
608
|
+
setUser(response.user);
|
|
609
|
+
return response;
|
|
610
|
+
} catch (err) {
|
|
611
|
+
setError(err);
|
|
612
|
+
throw err;
|
|
613
|
+
} finally {
|
|
614
|
+
setIsLoading(false);
|
|
615
|
+
}
|
|
616
|
+
},
|
|
617
|
+
[client]
|
|
618
|
+
);
|
|
619
|
+
const logout = (0, import_react3.useCallback)(async () => {
|
|
620
|
+
try {
|
|
621
|
+
setIsLoading(true);
|
|
622
|
+
setError(null);
|
|
623
|
+
setUser(null);
|
|
624
|
+
} catch (err) {
|
|
625
|
+
setError(err);
|
|
626
|
+
throw err;
|
|
627
|
+
} finally {
|
|
628
|
+
setIsLoading(false);
|
|
629
|
+
}
|
|
630
|
+
}, []);
|
|
631
|
+
const refresh = (0, import_react3.useCallback)(async () => {
|
|
632
|
+
await checkAuth();
|
|
633
|
+
}, [checkAuth]);
|
|
634
|
+
(0, import_react3.useEffect)(() => {
|
|
635
|
+
if (autoCheck) {
|
|
636
|
+
checkAuth();
|
|
637
|
+
}
|
|
638
|
+
}, [autoCheck, checkAuth]);
|
|
639
|
+
return {
|
|
640
|
+
user,
|
|
641
|
+
isAuthenticated: user !== null,
|
|
642
|
+
isLoading,
|
|
643
|
+
error,
|
|
644
|
+
login,
|
|
645
|
+
logout,
|
|
646
|
+
refresh
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/use-users.ts
|
|
651
|
+
var import_react4 = require("react");
|
|
652
|
+
function useUsers(options = {}) {
|
|
653
|
+
const { autoFetch = true, refetchInterval = 0, ...listOptions } = options;
|
|
654
|
+
const client = useFluxbaseClient();
|
|
655
|
+
const [users, setUsers] = (0, import_react4.useState)([]);
|
|
656
|
+
const [total, setTotal] = (0, import_react4.useState)(0);
|
|
657
|
+
const [isLoading, setIsLoading] = (0, import_react4.useState)(autoFetch);
|
|
658
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
659
|
+
const fetchUsers = (0, import_react4.useCallback)(async () => {
|
|
660
|
+
try {
|
|
661
|
+
setIsLoading(true);
|
|
662
|
+
setError(null);
|
|
663
|
+
const response = await client.admin.listUsers(listOptions);
|
|
664
|
+
setUsers(response.users);
|
|
665
|
+
setTotal(response.total);
|
|
666
|
+
} catch (err) {
|
|
667
|
+
setError(err);
|
|
668
|
+
} finally {
|
|
669
|
+
setIsLoading(false);
|
|
670
|
+
}
|
|
671
|
+
}, [client, JSON.stringify(listOptions)]);
|
|
672
|
+
const inviteUser = (0, import_react4.useCallback)(
|
|
673
|
+
async (email, role) => {
|
|
674
|
+
await client.admin.inviteUser({ email, role });
|
|
675
|
+
await fetchUsers();
|
|
676
|
+
},
|
|
677
|
+
[client, fetchUsers]
|
|
678
|
+
);
|
|
679
|
+
const updateUserRole = (0, import_react4.useCallback)(
|
|
680
|
+
async (userId, role) => {
|
|
681
|
+
await client.admin.updateUserRole(userId, role);
|
|
682
|
+
await fetchUsers();
|
|
683
|
+
},
|
|
684
|
+
[client, fetchUsers]
|
|
685
|
+
);
|
|
686
|
+
const deleteUser = (0, import_react4.useCallback)(
|
|
687
|
+
async (userId) => {
|
|
688
|
+
await client.admin.deleteUser(userId);
|
|
689
|
+
await fetchUsers();
|
|
690
|
+
},
|
|
691
|
+
[client, fetchUsers]
|
|
692
|
+
);
|
|
693
|
+
const resetPassword = (0, import_react4.useCallback)(
|
|
694
|
+
async (userId) => {
|
|
695
|
+
return await client.admin.resetUserPassword(userId);
|
|
696
|
+
},
|
|
697
|
+
[client]
|
|
698
|
+
);
|
|
699
|
+
(0, import_react4.useEffect)(() => {
|
|
700
|
+
if (autoFetch) {
|
|
701
|
+
fetchUsers();
|
|
702
|
+
}
|
|
703
|
+
}, [autoFetch, fetchUsers]);
|
|
704
|
+
(0, import_react4.useEffect)(() => {
|
|
705
|
+
if (refetchInterval > 0) {
|
|
706
|
+
const interval = setInterval(fetchUsers, refetchInterval);
|
|
707
|
+
return () => clearInterval(interval);
|
|
708
|
+
}
|
|
709
|
+
}, [refetchInterval, fetchUsers]);
|
|
710
|
+
return {
|
|
711
|
+
users,
|
|
712
|
+
total,
|
|
713
|
+
isLoading,
|
|
714
|
+
error,
|
|
715
|
+
refetch: fetchUsers,
|
|
716
|
+
inviteUser,
|
|
717
|
+
updateUserRole,
|
|
718
|
+
deleteUser,
|
|
719
|
+
resetPassword
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// src/use-api-keys.ts
|
|
724
|
+
var import_react5 = require("react");
|
|
725
|
+
function useAPIKeys(options = {}) {
|
|
726
|
+
const { autoFetch = true } = options;
|
|
727
|
+
const client = useFluxbaseClient();
|
|
728
|
+
const [keys, setKeys] = (0, import_react5.useState)([]);
|
|
729
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(autoFetch);
|
|
730
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
731
|
+
const fetchKeys = (0, import_react5.useCallback)(async () => {
|
|
732
|
+
try {
|
|
733
|
+
setIsLoading(true);
|
|
734
|
+
setError(null);
|
|
735
|
+
const response = await client.admin.management.apiKeys.list();
|
|
736
|
+
setKeys(response.api_keys);
|
|
737
|
+
} catch (err) {
|
|
738
|
+
setError(err);
|
|
739
|
+
} finally {
|
|
740
|
+
setIsLoading(false);
|
|
741
|
+
}
|
|
742
|
+
}, [client]);
|
|
743
|
+
const createKey = (0, import_react5.useCallback)(
|
|
744
|
+
async (request) => {
|
|
745
|
+
const response = await client.admin.management.apiKeys.create(request);
|
|
746
|
+
await fetchKeys();
|
|
747
|
+
return { key: response.key, keyData: response.api_key };
|
|
748
|
+
},
|
|
749
|
+
[client, fetchKeys]
|
|
750
|
+
);
|
|
751
|
+
const updateKey = (0, import_react5.useCallback)(
|
|
752
|
+
async (keyId, update) => {
|
|
753
|
+
await client.admin.management.apiKeys.update(keyId, update);
|
|
754
|
+
await fetchKeys();
|
|
755
|
+
},
|
|
756
|
+
[client, fetchKeys]
|
|
757
|
+
);
|
|
758
|
+
const revokeKey = (0, import_react5.useCallback)(
|
|
759
|
+
async (keyId) => {
|
|
760
|
+
await client.admin.management.apiKeys.revoke(keyId);
|
|
761
|
+
await fetchKeys();
|
|
762
|
+
},
|
|
763
|
+
[client, fetchKeys]
|
|
764
|
+
);
|
|
765
|
+
const deleteKey = (0, import_react5.useCallback)(
|
|
766
|
+
async (keyId) => {
|
|
767
|
+
await client.admin.management.apiKeys.delete(keyId);
|
|
768
|
+
await fetchKeys();
|
|
769
|
+
},
|
|
770
|
+
[client, fetchKeys]
|
|
771
|
+
);
|
|
772
|
+
(0, import_react5.useEffect)(() => {
|
|
773
|
+
if (autoFetch) {
|
|
774
|
+
fetchKeys();
|
|
775
|
+
}
|
|
776
|
+
}, [autoFetch, fetchKeys]);
|
|
777
|
+
return {
|
|
778
|
+
keys,
|
|
779
|
+
isLoading,
|
|
780
|
+
error,
|
|
781
|
+
refetch: fetchKeys,
|
|
782
|
+
createKey,
|
|
783
|
+
updateKey,
|
|
784
|
+
revokeKey,
|
|
785
|
+
deleteKey
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// src/use-admin-hooks.ts
|
|
790
|
+
var import_react6 = require("react");
|
|
791
|
+
function useAppSettings(options = {}) {
|
|
792
|
+
const { autoFetch = true } = options;
|
|
793
|
+
const client = useFluxbaseClient();
|
|
794
|
+
const [settings, setSettings] = (0, import_react6.useState)(null);
|
|
795
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(autoFetch);
|
|
796
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
797
|
+
const fetchSettings = (0, import_react6.useCallback)(async () => {
|
|
798
|
+
try {
|
|
799
|
+
setIsLoading(true);
|
|
800
|
+
setError(null);
|
|
801
|
+
const appSettings = await client.admin.settings.app.get();
|
|
802
|
+
setSettings(appSettings);
|
|
803
|
+
} catch (err) {
|
|
804
|
+
setError(err);
|
|
805
|
+
} finally {
|
|
806
|
+
setIsLoading(false);
|
|
807
|
+
}
|
|
808
|
+
}, [client]);
|
|
809
|
+
const updateSettings = (0, import_react6.useCallback)(
|
|
810
|
+
async (update) => {
|
|
811
|
+
await client.admin.settings.app.update(update);
|
|
812
|
+
await fetchSettings();
|
|
813
|
+
},
|
|
814
|
+
[client, fetchSettings]
|
|
815
|
+
);
|
|
816
|
+
(0, import_react6.useEffect)(() => {
|
|
817
|
+
if (autoFetch) {
|
|
818
|
+
fetchSettings();
|
|
819
|
+
}
|
|
820
|
+
}, [autoFetch, fetchSettings]);
|
|
821
|
+
return {
|
|
822
|
+
settings,
|
|
823
|
+
isLoading,
|
|
824
|
+
error,
|
|
825
|
+
refetch: fetchSettings,
|
|
826
|
+
updateSettings
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function useSystemSettings(options = {}) {
|
|
830
|
+
const { autoFetch = true } = options;
|
|
831
|
+
const client = useFluxbaseClient();
|
|
832
|
+
const [settings, setSettings] = (0, import_react6.useState)([]);
|
|
833
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(autoFetch);
|
|
834
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
835
|
+
const fetchSettings = (0, import_react6.useCallback)(async () => {
|
|
836
|
+
try {
|
|
837
|
+
setIsLoading(true);
|
|
838
|
+
setError(null);
|
|
839
|
+
const response = await client.admin.settings.system.list();
|
|
840
|
+
setSettings(response.settings);
|
|
841
|
+
} catch (err) {
|
|
842
|
+
setError(err);
|
|
843
|
+
} finally {
|
|
844
|
+
setIsLoading(false);
|
|
845
|
+
}
|
|
846
|
+
}, [client]);
|
|
847
|
+
const getSetting = (0, import_react6.useCallback)(
|
|
848
|
+
(key) => {
|
|
849
|
+
return settings.find((s) => s.key === key);
|
|
850
|
+
},
|
|
851
|
+
[settings]
|
|
852
|
+
);
|
|
853
|
+
const updateSetting = (0, import_react6.useCallback)(
|
|
854
|
+
async (key, update) => {
|
|
855
|
+
await client.admin.settings.system.update(key, update);
|
|
856
|
+
await fetchSettings();
|
|
857
|
+
},
|
|
858
|
+
[client, fetchSettings]
|
|
859
|
+
);
|
|
860
|
+
const deleteSetting = (0, import_react6.useCallback)(
|
|
861
|
+
async (key) => {
|
|
862
|
+
await client.admin.settings.system.delete(key);
|
|
863
|
+
await fetchSettings();
|
|
864
|
+
},
|
|
865
|
+
[client, fetchSettings]
|
|
866
|
+
);
|
|
867
|
+
(0, import_react6.useEffect)(() => {
|
|
868
|
+
if (autoFetch) {
|
|
869
|
+
fetchSettings();
|
|
870
|
+
}
|
|
871
|
+
}, [autoFetch, fetchSettings]);
|
|
872
|
+
return {
|
|
873
|
+
settings,
|
|
874
|
+
isLoading,
|
|
875
|
+
error,
|
|
876
|
+
refetch: fetchSettings,
|
|
877
|
+
getSetting,
|
|
878
|
+
updateSetting,
|
|
879
|
+
deleteSetting
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
function useWebhooks(options = {}) {
|
|
883
|
+
const { autoFetch = true, refetchInterval = 0 } = options;
|
|
884
|
+
const client = useFluxbaseClient();
|
|
885
|
+
const [webhooks, setWebhooks] = (0, import_react6.useState)([]);
|
|
886
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(autoFetch);
|
|
887
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
888
|
+
const fetchWebhooks = (0, import_react6.useCallback)(async () => {
|
|
889
|
+
try {
|
|
890
|
+
setIsLoading(true);
|
|
891
|
+
setError(null);
|
|
892
|
+
const response = await client.admin.management.webhooks.list();
|
|
893
|
+
setWebhooks(response.webhooks);
|
|
894
|
+
} catch (err) {
|
|
895
|
+
setError(err);
|
|
896
|
+
} finally {
|
|
897
|
+
setIsLoading(false);
|
|
898
|
+
}
|
|
899
|
+
}, [client]);
|
|
900
|
+
const createWebhook = (0, import_react6.useCallback)(
|
|
901
|
+
async (webhook) => {
|
|
902
|
+
const created = await client.admin.management.webhooks.create(webhook);
|
|
903
|
+
await fetchWebhooks();
|
|
904
|
+
return created;
|
|
905
|
+
},
|
|
906
|
+
[client, fetchWebhooks]
|
|
907
|
+
);
|
|
908
|
+
const updateWebhook = (0, import_react6.useCallback)(
|
|
909
|
+
async (id, update) => {
|
|
910
|
+
const updated = await client.admin.management.webhooks.update(id, update);
|
|
911
|
+
await fetchWebhooks();
|
|
912
|
+
return updated;
|
|
913
|
+
},
|
|
914
|
+
[client, fetchWebhooks]
|
|
915
|
+
);
|
|
916
|
+
const deleteWebhook = (0, import_react6.useCallback)(
|
|
917
|
+
async (id) => {
|
|
918
|
+
await client.admin.management.webhooks.delete(id);
|
|
919
|
+
await fetchWebhooks();
|
|
920
|
+
},
|
|
921
|
+
[client, fetchWebhooks]
|
|
922
|
+
);
|
|
923
|
+
const testWebhook = (0, import_react6.useCallback)(
|
|
924
|
+
async (id) => {
|
|
925
|
+
await client.admin.management.webhooks.test(id);
|
|
926
|
+
},
|
|
927
|
+
[client]
|
|
928
|
+
);
|
|
929
|
+
(0, import_react6.useEffect)(() => {
|
|
930
|
+
if (autoFetch) {
|
|
931
|
+
fetchWebhooks();
|
|
932
|
+
}
|
|
933
|
+
if (refetchInterval > 0) {
|
|
934
|
+
const interval = setInterval(fetchWebhooks, refetchInterval);
|
|
935
|
+
return () => clearInterval(interval);
|
|
936
|
+
}
|
|
937
|
+
}, [autoFetch, refetchInterval, fetchWebhooks]);
|
|
938
|
+
return {
|
|
939
|
+
webhooks,
|
|
940
|
+
isLoading,
|
|
941
|
+
error,
|
|
942
|
+
refetch: fetchWebhooks,
|
|
943
|
+
createWebhook,
|
|
944
|
+
updateWebhook,
|
|
945
|
+
deleteWebhook,
|
|
946
|
+
testWebhook
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
950
|
+
0 && (module.exports = {
|
|
951
|
+
FluxbaseProvider,
|
|
952
|
+
useAPIKeys,
|
|
953
|
+
useAdminAuth,
|
|
954
|
+
useAppSettings,
|
|
955
|
+
useAuth,
|
|
956
|
+
useCreateBucket,
|
|
957
|
+
useDelete,
|
|
958
|
+
useDeleteBucket,
|
|
959
|
+
useFluxbaseClient,
|
|
960
|
+
useFluxbaseQuery,
|
|
961
|
+
useInsert,
|
|
962
|
+
useRPC,
|
|
963
|
+
useRPCBatch,
|
|
964
|
+
useRPCMutation,
|
|
965
|
+
useRealtime,
|
|
966
|
+
useSession,
|
|
967
|
+
useSignIn,
|
|
968
|
+
useSignOut,
|
|
969
|
+
useSignUp,
|
|
970
|
+
useStorageBuckets,
|
|
971
|
+
useStorageCopy,
|
|
972
|
+
useStorageDelete,
|
|
973
|
+
useStorageDownload,
|
|
974
|
+
useStorageList,
|
|
975
|
+
useStorageMove,
|
|
976
|
+
useStoragePublicUrl,
|
|
977
|
+
useStorageSignedUrl,
|
|
978
|
+
useStorageUpload,
|
|
979
|
+
useSystemSettings,
|
|
980
|
+
useTable,
|
|
981
|
+
useTableDeletes,
|
|
982
|
+
useTableInserts,
|
|
983
|
+
useTableSubscription,
|
|
984
|
+
useTableUpdates,
|
|
985
|
+
useUpdate,
|
|
986
|
+
useUpdateUser,
|
|
987
|
+
useUpsert,
|
|
988
|
+
useUser,
|
|
989
|
+
useUsers,
|
|
990
|
+
useWebhooks
|
|
991
|
+
});
|
|
992
|
+
//# sourceMappingURL=index.js.map
|