@elqnt/admin 2.0.5 → 2.1.0
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 +47 -192
- package/dist/admin-Dlsd5IZ0.d.cts +767 -0
- package/dist/admin-Dlsd5IZ0.d.ts +767 -0
- package/dist/api/index.cjs +213 -27
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +121 -3
- package/dist/api/index.d.ts +121 -3
- package/dist/api/index.js +192 -27
- package/dist/api/index.js.map +1 -1
- package/dist/hooks/index.cjs +765 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +119 -0
- package/dist/hooks/index.d.ts +119 -0
- package/dist/hooks/index.js +735 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +695 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +532 -27
- package/dist/index.js.map +1 -1
- package/dist/models/index.cjs +491 -0
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +1095 -29
- package/dist/models/index.d.ts +1095 -29
- package/dist/models/index.js +341 -0
- package/dist/models/index.js.map +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,765 @@
|
|
|
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
|
+
// hooks/index.ts
|
|
21
|
+
var hooks_exports = {};
|
|
22
|
+
__export(hooks_exports, {
|
|
23
|
+
useInvitesAdmin: () => useInvitesAdmin,
|
|
24
|
+
useOrgAdmin: () => useOrgAdmin,
|
|
25
|
+
useOrgSettings: () => useOrgSettings,
|
|
26
|
+
useUsersAdmin: () => useUsersAdmin
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
29
|
+
|
|
30
|
+
// hooks/use-org-admin.ts
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
|
|
33
|
+
// api/index.ts
|
|
34
|
+
var import_browser4 = require("@elqnt/api-client/browser");
|
|
35
|
+
|
|
36
|
+
// api/orgs.ts
|
|
37
|
+
var import_browser = require("@elqnt/api-client/browser");
|
|
38
|
+
async function listOrgsApi(options) {
|
|
39
|
+
return (0, import_browser.browserApiRequest)("/api/v1/admin/orgs", {
|
|
40
|
+
method: "GET",
|
|
41
|
+
...options
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async function createOrgApi(org, options) {
|
|
45
|
+
return (0, import_browser.browserApiRequest)("/api/v1/admin/orgs", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
body: org,
|
|
48
|
+
...options
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function getOrgApi(orgId, options) {
|
|
52
|
+
return (0, import_browser.browserApiRequest)(`/api/v1/admin/orgs/${orgId}`, {
|
|
53
|
+
method: "GET",
|
|
54
|
+
...options
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function updateOrgApi(orgId, updates, options) {
|
|
58
|
+
return (0, import_browser.browserApiRequest)(`/api/v1/admin/orgs/${orgId}`, {
|
|
59
|
+
method: "PUT",
|
|
60
|
+
body: updates,
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function deleteOrgApi(orgId, options) {
|
|
65
|
+
return (0, import_browser.browserApiRequest)(`/api/v1/admin/orgs/${orgId}`, {
|
|
66
|
+
method: "DELETE",
|
|
67
|
+
...options
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function getOrgInfoApi(orgId, options) {
|
|
71
|
+
return (0, import_browser.browserApiRequest)(`/api/v1/admin/orgs/${orgId}/info`, {
|
|
72
|
+
method: "GET",
|
|
73
|
+
...options
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// api/users.ts
|
|
78
|
+
var import_browser2 = require("@elqnt/api-client/browser");
|
|
79
|
+
async function listUsersApi(options) {
|
|
80
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/admin/users", {
|
|
81
|
+
method: "GET",
|
|
82
|
+
...options
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function createUserApi(user, options) {
|
|
86
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/admin/users", {
|
|
87
|
+
method: "POST",
|
|
88
|
+
body: user,
|
|
89
|
+
...options
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async function getUserApi(userId, options) {
|
|
93
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/${userId}`, {
|
|
94
|
+
method: "GET",
|
|
95
|
+
...options
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async function getUserByEmailApi(email, options) {
|
|
99
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/by-email?email=${encodeURIComponent(email)}`, {
|
|
100
|
+
method: "GET",
|
|
101
|
+
...options
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function updateUserApi(userId, updates, options) {
|
|
105
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/${userId}`, {
|
|
106
|
+
method: "PUT",
|
|
107
|
+
body: updates,
|
|
108
|
+
...options
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async function deleteUserApi(userId, options) {
|
|
112
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/${userId}`, {
|
|
113
|
+
method: "DELETE",
|
|
114
|
+
...options
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function getUserSettingsApi(userId, options) {
|
|
118
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/${userId}/settings`, {
|
|
119
|
+
method: "GET",
|
|
120
|
+
...options
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function updateUserSettingsApi(userId, settings, options) {
|
|
124
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/admin/users/${userId}/settings`, {
|
|
125
|
+
method: "PUT",
|
|
126
|
+
body: settings,
|
|
127
|
+
...options
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// api/invites.ts
|
|
132
|
+
var import_browser3 = require("@elqnt/api-client/browser");
|
|
133
|
+
async function listInvitesApi(options) {
|
|
134
|
+
return (0, import_browser3.browserApiRequest)("/api/v1/admin/invites", {
|
|
135
|
+
method: "GET",
|
|
136
|
+
...options
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async function sendInvitesApi(invites, options) {
|
|
140
|
+
return (0, import_browser3.browserApiRequest)("/api/v1/admin/invites", {
|
|
141
|
+
method: "POST",
|
|
142
|
+
body: { invites },
|
|
143
|
+
...options
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async function sendInviteApi(invite, options) {
|
|
147
|
+
return (0, import_browser3.browserApiRequest)("/api/v1/admin/invites/single", {
|
|
148
|
+
method: "POST",
|
|
149
|
+
body: invite,
|
|
150
|
+
...options
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async function getInviteApi(inviteId, options) {
|
|
154
|
+
return (0, import_browser3.browserApiRequest)(`/api/v1/admin/invites/${inviteId}`, {
|
|
155
|
+
method: "GET",
|
|
156
|
+
...options
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async function resendInviteApi(inviteId, options) {
|
|
160
|
+
return (0, import_browser3.browserApiRequest)(`/api/v1/admin/invites/${inviteId}/resend`, {
|
|
161
|
+
method: "POST",
|
|
162
|
+
...options
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async function revokeInviteApi(inviteId, options) {
|
|
166
|
+
return (0, import_browser3.browserApiRequest)(`/api/v1/admin/invites/${inviteId}`, {
|
|
167
|
+
method: "DELETE",
|
|
168
|
+
...options
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async function acceptInviteApi(inviteId, options) {
|
|
172
|
+
return (0, import_browser3.browserApiRequest)(`/api/v1/admin/invites/${inviteId}/accept`, {
|
|
173
|
+
method: "POST",
|
|
174
|
+
...options
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// api/index.ts
|
|
179
|
+
async function getOrgSettingsApi(options) {
|
|
180
|
+
return (0, import_browser4.browserApiRequest)("/api/v1/org/settings", {
|
|
181
|
+
method: "GET",
|
|
182
|
+
...options
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
async function createOrgSettingsApi(settings, options) {
|
|
186
|
+
return (0, import_browser4.browserApiRequest)("/api/v1/org/settings", {
|
|
187
|
+
method: "POST",
|
|
188
|
+
body: settings,
|
|
189
|
+
...options
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async function updateOrgSettingsApi(settings, options) {
|
|
193
|
+
return (0, import_browser4.browserApiRequest)("/api/v1/org/settings", {
|
|
194
|
+
method: "PUT",
|
|
195
|
+
body: settings,
|
|
196
|
+
...options
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// hooks/use-org-admin.ts
|
|
201
|
+
function useOrgAdmin(options) {
|
|
202
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
203
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
204
|
+
const listOrgs = (0, import_react.useCallback)(async () => {
|
|
205
|
+
setLoading(true);
|
|
206
|
+
setError(null);
|
|
207
|
+
try {
|
|
208
|
+
const response = await listOrgsApi(options);
|
|
209
|
+
if (response.error) {
|
|
210
|
+
setError(response.error);
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
return response.data?.orgs || [];
|
|
214
|
+
} catch (err) {
|
|
215
|
+
const message = err instanceof Error ? err.message : "Failed to list organizations";
|
|
216
|
+
setError(message);
|
|
217
|
+
return [];
|
|
218
|
+
} finally {
|
|
219
|
+
setLoading(false);
|
|
220
|
+
}
|
|
221
|
+
}, [options]);
|
|
222
|
+
const getOrg = (0, import_react.useCallback)(
|
|
223
|
+
async (orgId) => {
|
|
224
|
+
setLoading(true);
|
|
225
|
+
setError(null);
|
|
226
|
+
try {
|
|
227
|
+
const response = await getOrgApi(orgId, options);
|
|
228
|
+
if (response.error) {
|
|
229
|
+
setError(response.error);
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
return response.data?.org || null;
|
|
233
|
+
} catch (err) {
|
|
234
|
+
const message = err instanceof Error ? err.message : "Failed to get organization";
|
|
235
|
+
setError(message);
|
|
236
|
+
return null;
|
|
237
|
+
} finally {
|
|
238
|
+
setLoading(false);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
[options]
|
|
242
|
+
);
|
|
243
|
+
const getOrgInfo = (0, import_react.useCallback)(
|
|
244
|
+
async (orgId) => {
|
|
245
|
+
setLoading(true);
|
|
246
|
+
setError(null);
|
|
247
|
+
try {
|
|
248
|
+
const response = await getOrgInfoApi(orgId, options);
|
|
249
|
+
if (response.error) {
|
|
250
|
+
setError(response.error);
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
return response.data?.orgInfo || null;
|
|
254
|
+
} catch (err) {
|
|
255
|
+
const message = err instanceof Error ? err.message : "Failed to get organization info";
|
|
256
|
+
setError(message);
|
|
257
|
+
return null;
|
|
258
|
+
} finally {
|
|
259
|
+
setLoading(false);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
[options]
|
|
263
|
+
);
|
|
264
|
+
const createOrg = (0, import_react.useCallback)(
|
|
265
|
+
async (org) => {
|
|
266
|
+
setLoading(true);
|
|
267
|
+
setError(null);
|
|
268
|
+
try {
|
|
269
|
+
const response = await createOrgApi(org, options);
|
|
270
|
+
if (response.error) {
|
|
271
|
+
setError(response.error);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
return response.data?.org || null;
|
|
275
|
+
} catch (err) {
|
|
276
|
+
const message = err instanceof Error ? err.message : "Failed to create organization";
|
|
277
|
+
setError(message);
|
|
278
|
+
return null;
|
|
279
|
+
} finally {
|
|
280
|
+
setLoading(false);
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
[options]
|
|
284
|
+
);
|
|
285
|
+
const updateOrg = (0, import_react.useCallback)(
|
|
286
|
+
async (orgId, updates) => {
|
|
287
|
+
setLoading(true);
|
|
288
|
+
setError(null);
|
|
289
|
+
try {
|
|
290
|
+
const response = await updateOrgApi(orgId, updates, options);
|
|
291
|
+
if (response.error) {
|
|
292
|
+
setError(response.error);
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
return response.data?.org || null;
|
|
296
|
+
} catch (err) {
|
|
297
|
+
const message = err instanceof Error ? err.message : "Failed to update organization";
|
|
298
|
+
setError(message);
|
|
299
|
+
return null;
|
|
300
|
+
} finally {
|
|
301
|
+
setLoading(false);
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
[options]
|
|
305
|
+
);
|
|
306
|
+
const deleteOrg = (0, import_react.useCallback)(
|
|
307
|
+
async (orgId) => {
|
|
308
|
+
setLoading(true);
|
|
309
|
+
setError(null);
|
|
310
|
+
try {
|
|
311
|
+
const response = await deleteOrgApi(orgId, options);
|
|
312
|
+
if (response.error) {
|
|
313
|
+
setError(response.error);
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
return response.data?.success || false;
|
|
317
|
+
} catch (err) {
|
|
318
|
+
const message = err instanceof Error ? err.message : "Failed to delete organization";
|
|
319
|
+
setError(message);
|
|
320
|
+
return false;
|
|
321
|
+
} finally {
|
|
322
|
+
setLoading(false);
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
[options]
|
|
326
|
+
);
|
|
327
|
+
return {
|
|
328
|
+
loading,
|
|
329
|
+
error,
|
|
330
|
+
listOrgs,
|
|
331
|
+
getOrg,
|
|
332
|
+
getOrgInfo,
|
|
333
|
+
createOrg,
|
|
334
|
+
updateOrg,
|
|
335
|
+
deleteOrg
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// hooks/use-users-admin.ts
|
|
340
|
+
var import_react2 = require("react");
|
|
341
|
+
function useUsersAdmin(options) {
|
|
342
|
+
const [loading, setLoading] = (0, import_react2.useState)(false);
|
|
343
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
344
|
+
const listUsers = (0, import_react2.useCallback)(async () => {
|
|
345
|
+
setLoading(true);
|
|
346
|
+
setError(null);
|
|
347
|
+
try {
|
|
348
|
+
const response = await listUsersApi(options);
|
|
349
|
+
if (response.error) {
|
|
350
|
+
setError(response.error);
|
|
351
|
+
return [];
|
|
352
|
+
}
|
|
353
|
+
return response.data?.users || [];
|
|
354
|
+
} catch (err) {
|
|
355
|
+
const message = err instanceof Error ? err.message : "Failed to list users";
|
|
356
|
+
setError(message);
|
|
357
|
+
return [];
|
|
358
|
+
} finally {
|
|
359
|
+
setLoading(false);
|
|
360
|
+
}
|
|
361
|
+
}, [options]);
|
|
362
|
+
const getUser = (0, import_react2.useCallback)(
|
|
363
|
+
async (userId) => {
|
|
364
|
+
setLoading(true);
|
|
365
|
+
setError(null);
|
|
366
|
+
try {
|
|
367
|
+
const response = await getUserApi(userId, options);
|
|
368
|
+
if (response.error) {
|
|
369
|
+
setError(response.error);
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
return response.data?.user || null;
|
|
373
|
+
} catch (err) {
|
|
374
|
+
const message = err instanceof Error ? err.message : "Failed to get user";
|
|
375
|
+
setError(message);
|
|
376
|
+
return null;
|
|
377
|
+
} finally {
|
|
378
|
+
setLoading(false);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
[options]
|
|
382
|
+
);
|
|
383
|
+
const getUserByEmail = (0, import_react2.useCallback)(
|
|
384
|
+
async (email) => {
|
|
385
|
+
setLoading(true);
|
|
386
|
+
setError(null);
|
|
387
|
+
try {
|
|
388
|
+
const response = await getUserByEmailApi(email, options);
|
|
389
|
+
if (response.error) {
|
|
390
|
+
setError(response.error);
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
return response.data?.user || null;
|
|
394
|
+
} catch (err) {
|
|
395
|
+
const message = err instanceof Error ? err.message : "Failed to get user by email";
|
|
396
|
+
setError(message);
|
|
397
|
+
return null;
|
|
398
|
+
} finally {
|
|
399
|
+
setLoading(false);
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
[options]
|
|
403
|
+
);
|
|
404
|
+
const createUser = (0, import_react2.useCallback)(
|
|
405
|
+
async (user) => {
|
|
406
|
+
setLoading(true);
|
|
407
|
+
setError(null);
|
|
408
|
+
try {
|
|
409
|
+
const response = await createUserApi(user, options);
|
|
410
|
+
if (response.error) {
|
|
411
|
+
setError(response.error);
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
return response.data?.user || null;
|
|
415
|
+
} catch (err) {
|
|
416
|
+
const message = err instanceof Error ? err.message : "Failed to create user";
|
|
417
|
+
setError(message);
|
|
418
|
+
return null;
|
|
419
|
+
} finally {
|
|
420
|
+
setLoading(false);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
[options]
|
|
424
|
+
);
|
|
425
|
+
const updateUser = (0, import_react2.useCallback)(
|
|
426
|
+
async (userId, updates) => {
|
|
427
|
+
setLoading(true);
|
|
428
|
+
setError(null);
|
|
429
|
+
try {
|
|
430
|
+
const response = await updateUserApi(userId, updates, options);
|
|
431
|
+
if (response.error) {
|
|
432
|
+
setError(response.error);
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return response.data?.user || null;
|
|
436
|
+
} catch (err) {
|
|
437
|
+
const message = err instanceof Error ? err.message : "Failed to update user";
|
|
438
|
+
setError(message);
|
|
439
|
+
return null;
|
|
440
|
+
} finally {
|
|
441
|
+
setLoading(false);
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
[options]
|
|
445
|
+
);
|
|
446
|
+
const deleteUser = (0, import_react2.useCallback)(
|
|
447
|
+
async (userId) => {
|
|
448
|
+
setLoading(true);
|
|
449
|
+
setError(null);
|
|
450
|
+
try {
|
|
451
|
+
const response = await deleteUserApi(userId, options);
|
|
452
|
+
if (response.error) {
|
|
453
|
+
setError(response.error);
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
return response.data?.success || false;
|
|
457
|
+
} catch (err) {
|
|
458
|
+
const message = err instanceof Error ? err.message : "Failed to delete user";
|
|
459
|
+
setError(message);
|
|
460
|
+
return false;
|
|
461
|
+
} finally {
|
|
462
|
+
setLoading(false);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
[options]
|
|
466
|
+
);
|
|
467
|
+
const getUserSettings = (0, import_react2.useCallback)(
|
|
468
|
+
async (userId) => {
|
|
469
|
+
setLoading(true);
|
|
470
|
+
setError(null);
|
|
471
|
+
try {
|
|
472
|
+
const response = await getUserSettingsApi(userId, options);
|
|
473
|
+
if (response.error) {
|
|
474
|
+
setError(response.error);
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
return response.data || null;
|
|
478
|
+
} catch (err) {
|
|
479
|
+
const message = err instanceof Error ? err.message : "Failed to get user settings";
|
|
480
|
+
setError(message);
|
|
481
|
+
return null;
|
|
482
|
+
} finally {
|
|
483
|
+
setLoading(false);
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
[options]
|
|
487
|
+
);
|
|
488
|
+
const updateUserSettings = (0, import_react2.useCallback)(
|
|
489
|
+
async (userId, settings) => {
|
|
490
|
+
setLoading(true);
|
|
491
|
+
setError(null);
|
|
492
|
+
try {
|
|
493
|
+
const response = await updateUserSettingsApi(userId, settings, options);
|
|
494
|
+
if (response.error) {
|
|
495
|
+
setError(response.error);
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
return response.data || null;
|
|
499
|
+
} catch (err) {
|
|
500
|
+
const message = err instanceof Error ? err.message : "Failed to update user settings";
|
|
501
|
+
setError(message);
|
|
502
|
+
return null;
|
|
503
|
+
} finally {
|
|
504
|
+
setLoading(false);
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
[options]
|
|
508
|
+
);
|
|
509
|
+
return {
|
|
510
|
+
loading,
|
|
511
|
+
error,
|
|
512
|
+
listUsers,
|
|
513
|
+
getUser,
|
|
514
|
+
getUserByEmail,
|
|
515
|
+
createUser,
|
|
516
|
+
updateUser,
|
|
517
|
+
deleteUser,
|
|
518
|
+
getUserSettings,
|
|
519
|
+
updateUserSettings
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// hooks/use-invites-admin.ts
|
|
524
|
+
var import_react3 = require("react");
|
|
525
|
+
function useInvitesAdmin(options) {
|
|
526
|
+
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
527
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
528
|
+
const listInvites = (0, import_react3.useCallback)(async () => {
|
|
529
|
+
setLoading(true);
|
|
530
|
+
setError(null);
|
|
531
|
+
try {
|
|
532
|
+
const response = await listInvitesApi(options);
|
|
533
|
+
if (response.error) {
|
|
534
|
+
setError(response.error);
|
|
535
|
+
return [];
|
|
536
|
+
}
|
|
537
|
+
return response.data?.invites || [];
|
|
538
|
+
} catch (err) {
|
|
539
|
+
const message = err instanceof Error ? err.message : "Failed to list invites";
|
|
540
|
+
setError(message);
|
|
541
|
+
return [];
|
|
542
|
+
} finally {
|
|
543
|
+
setLoading(false);
|
|
544
|
+
}
|
|
545
|
+
}, [options]);
|
|
546
|
+
const getInvite = (0, import_react3.useCallback)(
|
|
547
|
+
async (inviteId) => {
|
|
548
|
+
setLoading(true);
|
|
549
|
+
setError(null);
|
|
550
|
+
try {
|
|
551
|
+
const response = await getInviteApi(inviteId, options);
|
|
552
|
+
if (response.error) {
|
|
553
|
+
setError(response.error);
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
return response.data?.invite || null;
|
|
557
|
+
} catch (err) {
|
|
558
|
+
const message = err instanceof Error ? err.message : "Failed to get invite";
|
|
559
|
+
setError(message);
|
|
560
|
+
return null;
|
|
561
|
+
} finally {
|
|
562
|
+
setLoading(false);
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
[options]
|
|
566
|
+
);
|
|
567
|
+
const sendInvite = (0, import_react3.useCallback)(
|
|
568
|
+
async (invite) => {
|
|
569
|
+
setLoading(true);
|
|
570
|
+
setError(null);
|
|
571
|
+
try {
|
|
572
|
+
const response = await sendInviteApi(invite, options);
|
|
573
|
+
if (response.error) {
|
|
574
|
+
setError(response.error);
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
return response.data?.invite || null;
|
|
578
|
+
} catch (err) {
|
|
579
|
+
const message = err instanceof Error ? err.message : "Failed to send invite";
|
|
580
|
+
setError(message);
|
|
581
|
+
return null;
|
|
582
|
+
} finally {
|
|
583
|
+
setLoading(false);
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
[options]
|
|
587
|
+
);
|
|
588
|
+
const sendInvites = (0, import_react3.useCallback)(
|
|
589
|
+
async (invites) => {
|
|
590
|
+
setLoading(true);
|
|
591
|
+
setError(null);
|
|
592
|
+
try {
|
|
593
|
+
const response = await sendInvitesApi(invites, options);
|
|
594
|
+
if (response.error) {
|
|
595
|
+
setError(response.error);
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
return response.data || null;
|
|
599
|
+
} catch (err) {
|
|
600
|
+
const message = err instanceof Error ? err.message : "Failed to send invites";
|
|
601
|
+
setError(message);
|
|
602
|
+
return null;
|
|
603
|
+
} finally {
|
|
604
|
+
setLoading(false);
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
[options]
|
|
608
|
+
);
|
|
609
|
+
const resendInvite = (0, import_react3.useCallback)(
|
|
610
|
+
async (inviteId) => {
|
|
611
|
+
setLoading(true);
|
|
612
|
+
setError(null);
|
|
613
|
+
try {
|
|
614
|
+
const response = await resendInviteApi(inviteId, options);
|
|
615
|
+
if (response.error) {
|
|
616
|
+
setError(response.error);
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
return response.data?.invite || null;
|
|
620
|
+
} catch (err) {
|
|
621
|
+
const message = err instanceof Error ? err.message : "Failed to resend invite";
|
|
622
|
+
setError(message);
|
|
623
|
+
return null;
|
|
624
|
+
} finally {
|
|
625
|
+
setLoading(false);
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
[options]
|
|
629
|
+
);
|
|
630
|
+
const revokeInvite = (0, import_react3.useCallback)(
|
|
631
|
+
async (inviteId) => {
|
|
632
|
+
setLoading(true);
|
|
633
|
+
setError(null);
|
|
634
|
+
try {
|
|
635
|
+
const response = await revokeInviteApi(inviteId, options);
|
|
636
|
+
if (response.error) {
|
|
637
|
+
setError(response.error);
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
return response.data?.success || false;
|
|
641
|
+
} catch (err) {
|
|
642
|
+
const message = err instanceof Error ? err.message : "Failed to revoke invite";
|
|
643
|
+
setError(message);
|
|
644
|
+
return false;
|
|
645
|
+
} finally {
|
|
646
|
+
setLoading(false);
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
[options]
|
|
650
|
+
);
|
|
651
|
+
const acceptInvite = (0, import_react3.useCallback)(
|
|
652
|
+
async (inviteId) => {
|
|
653
|
+
setLoading(true);
|
|
654
|
+
setError(null);
|
|
655
|
+
try {
|
|
656
|
+
const response = await acceptInviteApi(inviteId, options);
|
|
657
|
+
if (response.error) {
|
|
658
|
+
setError(response.error);
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
return response.data?.invite || null;
|
|
662
|
+
} catch (err) {
|
|
663
|
+
const message = err instanceof Error ? err.message : "Failed to accept invite";
|
|
664
|
+
setError(message);
|
|
665
|
+
return null;
|
|
666
|
+
} finally {
|
|
667
|
+
setLoading(false);
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
[options]
|
|
671
|
+
);
|
|
672
|
+
return {
|
|
673
|
+
loading,
|
|
674
|
+
error,
|
|
675
|
+
listInvites,
|
|
676
|
+
getInvite,
|
|
677
|
+
sendInvite,
|
|
678
|
+
sendInvites,
|
|
679
|
+
resendInvite,
|
|
680
|
+
revokeInvite,
|
|
681
|
+
acceptInvite
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// hooks/use-org-settings.ts
|
|
686
|
+
var import_react4 = require("react");
|
|
687
|
+
function useOrgSettings(options) {
|
|
688
|
+
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
689
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
690
|
+
const getSettings = (0, import_react4.useCallback)(async () => {
|
|
691
|
+
setLoading(true);
|
|
692
|
+
setError(null);
|
|
693
|
+
try {
|
|
694
|
+
const response = await getOrgSettingsApi(options);
|
|
695
|
+
if (response.error) {
|
|
696
|
+
setError(response.error);
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
return response.data?.settings || null;
|
|
700
|
+
} catch (err) {
|
|
701
|
+
const message = err instanceof Error ? err.message : "Failed to get organization settings";
|
|
702
|
+
setError(message);
|
|
703
|
+
return null;
|
|
704
|
+
} finally {
|
|
705
|
+
setLoading(false);
|
|
706
|
+
}
|
|
707
|
+
}, [options]);
|
|
708
|
+
const createSettings = (0, import_react4.useCallback)(
|
|
709
|
+
async (settings) => {
|
|
710
|
+
setLoading(true);
|
|
711
|
+
setError(null);
|
|
712
|
+
try {
|
|
713
|
+
const response = await createOrgSettingsApi(settings, options);
|
|
714
|
+
if (response.error) {
|
|
715
|
+
setError(response.error);
|
|
716
|
+
return null;
|
|
717
|
+
}
|
|
718
|
+
return response.data?.settings || null;
|
|
719
|
+
} catch (err) {
|
|
720
|
+
const message = err instanceof Error ? err.message : "Failed to create organization settings";
|
|
721
|
+
setError(message);
|
|
722
|
+
return null;
|
|
723
|
+
} finally {
|
|
724
|
+
setLoading(false);
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
[options]
|
|
728
|
+
);
|
|
729
|
+
const updateSettings = (0, import_react4.useCallback)(
|
|
730
|
+
async (settings) => {
|
|
731
|
+
setLoading(true);
|
|
732
|
+
setError(null);
|
|
733
|
+
try {
|
|
734
|
+
const response = await updateOrgSettingsApi(settings, options);
|
|
735
|
+
if (response.error) {
|
|
736
|
+
setError(response.error);
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
return response.data?.settings || null;
|
|
740
|
+
} catch (err) {
|
|
741
|
+
const message = err instanceof Error ? err.message : "Failed to update organization settings";
|
|
742
|
+
setError(message);
|
|
743
|
+
return null;
|
|
744
|
+
} finally {
|
|
745
|
+
setLoading(false);
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
[options]
|
|
749
|
+
);
|
|
750
|
+
return {
|
|
751
|
+
loading,
|
|
752
|
+
error,
|
|
753
|
+
getSettings,
|
|
754
|
+
createSettings,
|
|
755
|
+
updateSettings
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
759
|
+
0 && (module.exports = {
|
|
760
|
+
useInvitesAdmin,
|
|
761
|
+
useOrgAdmin,
|
|
762
|
+
useOrgSettings,
|
|
763
|
+
useUsersAdmin
|
|
764
|
+
});
|
|
765
|
+
//# sourceMappingURL=index.cjs.map
|