@elevasis/ui 2.73.0 → 2.75.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.
Files changed (97) hide show
  1. package/dist/api/index.js +3 -3
  2. package/dist/app/index.d.ts +58 -0
  3. package/dist/app/index.js +9 -10
  4. package/dist/auth/index.js +5 -6
  5. package/dist/charts/index.js +5 -6
  6. package/dist/chunk-2GIJBHZT.js +60 -0
  7. package/dist/{chunk-Z4ICFQXG.js → chunk-2ZRY3ARL.js} +1 -1
  8. package/dist/{chunk-5B2ZFO44.js → chunk-3H5DIJN7.js} +1 -1
  9. package/dist/{chunk-LZT2H2MA.js → chunk-47YJVIZE.js} +36 -43
  10. package/dist/{chunk-3TS5U5BL.js → chunk-5RH6NYZH.js} +1 -1
  11. package/dist/chunk-5SLRGUC4.js +224 -0
  12. package/dist/{chunk-JYBJMVNY.js → chunk-5VF5LPYS.js} +1 -1
  13. package/dist/{chunk-SWKAH2YM.js → chunk-6BJ5HMMC.js} +282 -553
  14. package/dist/{chunk-NI37YNRP.js → chunk-7OOFMEX6.js} +11 -5
  15. package/dist/{chunk-IBCEAVB2.js → chunk-A2SB32YV.js} +65 -5
  16. package/dist/{chunk-CJ2232PQ.js → chunk-CRPH5AAB.js} +1 -1
  17. package/dist/chunk-D3XXPCCK.js +69 -0
  18. package/dist/chunk-DMSTDZCJ.js +305 -0
  19. package/dist/chunk-DTEGVSJ6.js +645 -0
  20. package/dist/chunk-DVAOCHIF.js +165 -0
  21. package/dist/chunk-G7O4CBMC.js +231 -0
  22. package/dist/{chunk-IGBPWD6S.js → chunk-GDTK33QT.js} +5 -3
  23. package/dist/chunk-ICHDIVQO.js +54 -0
  24. package/dist/{chunk-U2H3TIHD.js → chunk-IYATYH5I.js} +2 -52
  25. package/dist/chunk-L3NBMLRN.js +49 -0
  26. package/dist/{chunk-LEPYXLJ2.js → chunk-LFLM723H.js} +1 -1
  27. package/dist/chunk-M6VAZAQW.js +45 -0
  28. package/dist/{chunk-AJOVWB47.js → chunk-MLHZUN2X.js} +6 -3
  29. package/dist/chunk-N6K2Q5BM.js +393 -0
  30. package/dist/chunk-NMHQAYZU.js +439 -0
  31. package/dist/chunk-NYIIRZSA.js +286 -0
  32. package/dist/{chunk-ETN3TTRT.js → chunk-OGHTJKBV.js} +115 -8
  33. package/dist/{chunk-M7WWRZ5Z.js → chunk-QFGNRKIE.js} +1 -78
  34. package/dist/chunk-QFS2GZMV.js +515 -0
  35. package/dist/{chunk-OCVSPAKM.js → chunk-SB3IHM5Y.js} +1150 -4346
  36. package/dist/{chunk-4CW2C5BD.js → chunk-SEYOVNS5.js} +1 -1
  37. package/dist/chunk-SN7X5N2A.js +116 -0
  38. package/dist/{chunk-PQ4B62HH.js → chunk-TX3UHDL5.js} +2 -2
  39. package/dist/chunk-VM2OWOXL.js +24 -0
  40. package/dist/{chunk-ZDKPHFTH.js → chunk-VWGCURZF.js} +5 -3
  41. package/dist/chunk-WDBNW44Z.js +49 -0
  42. package/dist/chunk-YQQ5GRUR.js +21 -0
  43. package/dist/{chunk-NHNTX6ZL.js → chunk-ZG6YJUT4.js} +3 -2
  44. package/dist/components/index.d.ts +228 -6
  45. package/dist/components/index.js +321 -35
  46. package/dist/components/navigation/index.js +6 -7
  47. package/dist/features/auth/index.d.ts +78 -2
  48. package/dist/features/auth/index.js +18 -9
  49. package/dist/features/clients/index.js +7 -7
  50. package/dist/features/content/index.d.ts +226 -5
  51. package/dist/features/content/index.js +270 -19
  52. package/dist/features/crm/index.d.ts +58 -0
  53. package/dist/features/crm/index.js +10 -8
  54. package/dist/features/dashboard/index.js +9 -8
  55. package/dist/features/delivery/index.d.ts +58 -0
  56. package/dist/features/delivery/index.js +23 -7
  57. package/dist/features/knowledge/index.js +5 -6
  58. package/dist/features/lead-gen/index.d.ts +9 -15
  59. package/dist/features/lead-gen/index.js +12 -8
  60. package/dist/features/monitoring/index.js +11 -9
  61. package/dist/features/monitoring/requests/index.js +8 -7
  62. package/dist/features/operations/index.js +15 -11
  63. package/dist/features/public-agent-chat/index.js +3 -1
  64. package/dist/features/settings/index.d.ts +66 -3
  65. package/dist/features/settings/index.js +9 -8
  66. package/dist/hooks/access/index.js +5 -6
  67. package/dist/hooks/delivery/index.d.ts +58 -0
  68. package/dist/hooks/delivery/index.js +3 -2
  69. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +1 -1
  70. package/dist/hooks/published.d.ts +181 -5
  71. package/dist/hooks/published.js +22 -6
  72. package/dist/initialization/index.d.ts +58 -0
  73. package/dist/knowledge/index.js +167 -11
  74. package/dist/{knowledge-search-index-RZLIVWPJ.js → knowledge-search-index-6GQK55IQ.js} +1 -1
  75. package/dist/layout/index.js +8 -9
  76. package/dist/profile/index.d.ts +58 -0
  77. package/dist/provider/index.d.ts +77 -1
  78. package/dist/provider/index.js +5 -6
  79. package/dist/provider/published.d.ts +105 -1
  80. package/dist/provider/published.js +5 -6
  81. package/dist/test-utils/index.d.ts +16 -5
  82. package/dist/test-utils/index.js +17 -18
  83. package/dist/types/index.d.ts +73 -1
  84. package/dist/utils/index.d.ts +83 -3
  85. package/dist/utils/index.js +1 -1
  86. package/package.json +10 -5
  87. package/dist/chunk-6M6OLGQY.js +0 -36
  88. package/dist/chunk-MKH2KOAO.js +0 -39
  89. package/dist/hooks/index.css +0 -659
  90. package/dist/hooks/index.d.ts +0 -14073
  91. package/dist/hooks/index.js +0 -27
  92. package/dist/supabase/index.d.ts +0 -7118
  93. package/dist/supabase/index.js +0 -3
  94. package/dist/typeform/index.d.ts +0 -462
  95. package/dist/typeform/index.js +0 -2051
  96. package/dist/typeform/schemas.d.ts +0 -67
  97. package/dist/typeform/schemas.js +0 -2
@@ -0,0 +1,515 @@
1
+ import { useNotificationAdapter } from './chunk-SB3IHM5Y.js';
2
+ import { showApiErrorNotification } from './chunk-ICHDIVQO.js';
3
+ import { OrganizationContext } from './chunk-DD3CCMCZ.js';
4
+ import { STALE_TIME_DEFAULT, GC_TIME_MEDIUM, GC_TIME_SHORT, STALE_TIME_MONITORING } from './chunk-A2SB32YV.js';
5
+ import { useElevasisServices } from './chunk-BI5VDO2K.js';
6
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
7
+ import { z } from 'zod';
8
+ import { notifications } from '@mantine/notifications';
9
+ import { useContext } from 'react';
10
+
11
+ // ../core/src/auth/multi-tenancy/memberships/membership.ts
12
+ function transformMembershipToTableRow(membership) {
13
+ return {
14
+ id: membership.id,
15
+ userId: membership.userId,
16
+ organizationId: membership.organizationId,
17
+ userEmail: membership.user?.email || "Unknown",
18
+ userFullName: membership.user?.firstName && membership.user?.lastName ? `${membership.user.firstName} ${membership.user.lastName}` : membership.user?.email || "Unknown User",
19
+ organizationName: membership.organization?.name || "Unknown Organization",
20
+ role: membership.role.slug,
21
+ status: membership.status,
22
+ statusBadge: membership.status,
23
+ joinedAt: new Date(membership.createdAt),
24
+ updatedAt: new Date(membership.updatedAt),
25
+ canEdit: membership.status === "active",
26
+ canRemove: true
27
+ };
28
+ }
29
+ var MEMBERSHIP_STATUS_COLORS = {
30
+ active: "green",
31
+ inactive: "gray"
32
+ };
33
+ var PROVISIONING_STATE_DISPLAY = {
34
+ pre_provisioned: {
35
+ label: "Invited",
36
+ color: "orange",
37
+ description: "Invited but signup is not complete. The membership exists here; no WorkOS account is linked to it yet."
38
+ },
39
+ accepted_unlinked: {
40
+ label: "Link missing",
41
+ color: "red",
42
+ description: "This person accepted their invitation and has a real account, but our record of the connection was never written. They have access; our database just cannot see the link."
43
+ },
44
+ workos_only: {
45
+ label: "Sync gap",
46
+ color: "red",
47
+ description: "WorkOS has this membership but our database has no row for it, so it is not included in the member count. Remove and re-add the member to restore the record."
48
+ }
49
+ };
50
+ var MembershipRoleSchema = z.string().min(1).max(64);
51
+ var MembershipStatusSchema = z.enum(["active", "inactive"]);
52
+ var MembershipIdParamSchema = z.object({
53
+ id: z.string().min(1)
54
+ // WorkOS membership IDs can be various formats
55
+ }).strict();
56
+ z.object({
57
+ orgId: z.string().uuid()
58
+ }).strict();
59
+ z.object({
60
+ permissions: z.array(z.string())
61
+ });
62
+ var CreateMembershipSchema = z.object({
63
+ userId: z.string().min(1),
64
+ organizationId: z.string().min(1),
65
+ roleSlug: MembershipRoleSchema.default("member")
66
+ }).strict();
67
+ var UpdateMembershipSchema = z.object({
68
+ roleSlug: MembershipRoleSchema
69
+ }).strict();
70
+ var ListMembershipsQuerySchema = z.object({
71
+ userId: z.string().optional(),
72
+ organizationId: z.string().optional(),
73
+ // A querystring repeats keys rather than nesting arrays, so a single value
74
+ // arrives as a bare string. Normalize both shapes to an array.
75
+ statuses: z.union([MembershipStatusSchema, z.array(MembershipStatusSchema)]).transform((value) => Array.isArray(value) ? value : [value]).optional(),
76
+ order: z.enum(["asc", "desc"]).optional(),
77
+ limit: z.coerce.number().int().min(1).max(100).optional(),
78
+ before: z.string().optional(),
79
+ // WorkOS pagination cursor
80
+ after: z.string().optional()
81
+ // WorkOS pagination cursor
82
+ }).strict().refine((data) => data.userId || data.organizationId, {
83
+ message: "Either userId or organizationId must be provided"
84
+ });
85
+
86
+ // src/hooks/settings/roles/usePermissionCatalog.ts
87
+ var STALE_TIME_CATALOG = 60 * 60 * 1e3;
88
+ function usePermissionCatalog() {
89
+ const { apiRequest, isReady } = useElevasisServices();
90
+ return useQuery({
91
+ queryKey: ["permission-catalog"],
92
+ queryFn: () => apiRequest("/permissions/catalog"),
93
+ enabled: isReady,
94
+ staleTime: STALE_TIME_CATALOG
95
+ });
96
+ }
97
+
98
+ // src/hooks/settings/webhooks/webhookEndpointService.ts
99
+ var WebhookEndpointService = class {
100
+ constructor(apiRequest) {
101
+ this.apiRequest = apiRequest;
102
+ }
103
+ /**
104
+ * List webhook endpoints for the current organization
105
+ */
106
+ async listEndpoints() {
107
+ const response = await this.apiRequest("/webhook-endpoints");
108
+ return response.data;
109
+ }
110
+ /**
111
+ * Create a new webhook endpoint
112
+ */
113
+ async createEndpoint(data) {
114
+ return this.apiRequest("/webhook-endpoints", {
115
+ method: "POST",
116
+ body: JSON.stringify(data)
117
+ });
118
+ }
119
+ /**
120
+ * Update an existing webhook endpoint (e.g., toggle status, rename)
121
+ */
122
+ async updateEndpoint(endpointId, data) {
123
+ return this.apiRequest(`/webhook-endpoints/${endpointId}`, {
124
+ method: "PATCH",
125
+ body: JSON.stringify(data)
126
+ });
127
+ }
128
+ /**
129
+ * Delete a webhook endpoint
130
+ */
131
+ async deleteEndpoint(endpointId) {
132
+ await this.apiRequest(`/webhook-endpoints/${endpointId}`, {
133
+ method: "DELETE"
134
+ });
135
+ }
136
+ };
137
+ function useDeleteWebhookEndpoint() {
138
+ const { apiRequest } = useElevasisServices();
139
+ const queryClient = useQueryClient();
140
+ return useMutation({
141
+ mutationFn: async (endpointId) => {
142
+ const service = new WebhookEndpointService(apiRequest);
143
+ return await service.deleteEndpoint(endpointId);
144
+ },
145
+ onSuccess: () => {
146
+ queryClient.invalidateQueries({ queryKey: ["webhook-endpoints"] });
147
+ notifications.show({
148
+ title: "Success",
149
+ message: "Webhook endpoint deleted",
150
+ color: "teal"
151
+ });
152
+ },
153
+ onError: (error) => {
154
+ console.error("Failed to delete webhook endpoint:", error);
155
+ showApiErrorNotification(error);
156
+ }
157
+ });
158
+ }
159
+ function useUpdateWebhookEndpoint() {
160
+ const { apiRequest } = useElevasisServices();
161
+ const queryClient = useQueryClient();
162
+ return useMutation({
163
+ mutationFn: async ({ endpointId, data }) => {
164
+ const service = new WebhookEndpointService(apiRequest);
165
+ return await service.updateEndpoint(endpointId, data);
166
+ },
167
+ onSuccess: () => {
168
+ queryClient.invalidateQueries({ queryKey: ["webhook-endpoints"] });
169
+ notifications.show({
170
+ title: "Success",
171
+ message: "Webhook endpoint updated",
172
+ color: "teal"
173
+ });
174
+ },
175
+ onError: (error) => {
176
+ console.error("Failed to update webhook endpoint:", error);
177
+ showApiErrorNotification(error);
178
+ }
179
+ });
180
+ }
181
+ function useCreateWebhookEndpoint() {
182
+ const { apiRequest } = useElevasisServices();
183
+ const queryClient = useQueryClient();
184
+ return useMutation({
185
+ mutationFn: async (data) => {
186
+ const service = new WebhookEndpointService(apiRequest);
187
+ return await service.createEndpoint(data);
188
+ },
189
+ onSuccess: () => {
190
+ queryClient.invalidateQueries({ queryKey: ["webhook-endpoints"] });
191
+ },
192
+ onError: (error) => {
193
+ console.error("Failed to create webhook endpoint:", error);
194
+ showApiErrorNotification(error);
195
+ }
196
+ });
197
+ }
198
+ function useListWebhookEndpoints() {
199
+ const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
200
+ return useQuery({
201
+ queryKey: ["webhook-endpoints", workOSOrganizationId],
202
+ queryFn: async () => {
203
+ const service = new WebhookEndpointService(apiRequest);
204
+ return await service.listEndpoints();
205
+ },
206
+ enabled: isReady
207
+ });
208
+ }
209
+ function useOrgRoles(orgId) {
210
+ const { apiRequest, isReady } = useElevasisServices();
211
+ const organization = useContext(OrganizationContext);
212
+ const targetOrgId = orgId ?? organization?.currentSupabaseOrganizationId ?? void 0;
213
+ return useQuery({
214
+ queryKey: ["org-roles", targetOrgId],
215
+ queryFn: () => apiRequest(`/organizations/${targetOrgId}/roles`),
216
+ enabled: isReady && !!targetOrgId,
217
+ staleTime: STALE_TIME_DEFAULT
218
+ });
219
+ }
220
+ function useAssignRole() {
221
+ const { apiRequest } = useElevasisServices();
222
+ const organization = useContext(OrganizationContext);
223
+ const orgId = organization?.currentSupabaseOrganizationId ?? null;
224
+ const queryClient = useQueryClient();
225
+ return useMutation({
226
+ mutationFn: ({ membershipId, roleId }) => apiRequest(`/memberships/${membershipId}/roles`, {
227
+ method: "POST",
228
+ body: JSON.stringify({ roleId })
229
+ }),
230
+ onSettled: (_data, _error, { membershipId }) => {
231
+ queryClient.invalidateQueries({ queryKey: ["member-roles", orgId, membershipId] });
232
+ queryClient.invalidateQueries({ queryKey: ["organization-permissions", orgId] });
233
+ queryClient.invalidateQueries({ queryKey: ["org-roles", orgId] });
234
+ }
235
+ });
236
+ }
237
+ function useRevokeRole() {
238
+ const { apiRequest } = useElevasisServices();
239
+ const organization = useContext(OrganizationContext);
240
+ const orgId = organization?.currentSupabaseOrganizationId ?? null;
241
+ const queryClient = useQueryClient();
242
+ return useMutation({
243
+ mutationFn: ({ membershipId, roleId }) => apiRequest(`/memberships/${membershipId}/roles/${roleId}`, {
244
+ method: "DELETE"
245
+ }),
246
+ onSettled: (_data, _error, { membershipId }) => {
247
+ queryClient.invalidateQueries({ queryKey: ["member-roles", orgId, membershipId] });
248
+ queryClient.invalidateQueries({ queryKey: ["organization-permissions", orgId] });
249
+ queryClient.invalidateQueries({ queryKey: ["org-roles", orgId] });
250
+ }
251
+ });
252
+ }
253
+
254
+ // src/hooks/settings/organization/organizationMembershipService.ts
255
+ var OrganizationMembershipService = class {
256
+ constructor(apiRequest) {
257
+ this.apiRequest = apiRequest;
258
+ }
259
+ /**
260
+ * Get user's organization memberships
261
+ */
262
+ async getUserMemberships(userId) {
263
+ const searchParams = new URLSearchParams();
264
+ searchParams.append("userId", userId);
265
+ const url = `/memberships?${searchParams.toString()}`;
266
+ const response = await this.apiRequest(url);
267
+ return response.data.map((membership) => ({
268
+ ...membership,
269
+ createdAt: membership.createdAt,
270
+ updatedAt: membership.updatedAt
271
+ }));
272
+ }
273
+ /**
274
+ * Get organization members
275
+ */
276
+ async getOrganizationMembers(organizationId) {
277
+ const searchParams = new URLSearchParams();
278
+ searchParams.append("organizationId", organizationId);
279
+ const url = `/memberships?${searchParams.toString()}`;
280
+ const response = await this.apiRequest(url);
281
+ return response.data.map((membership) => ({
282
+ ...membership,
283
+ createdAt: membership.createdAt,
284
+ updatedAt: membership.updatedAt
285
+ }));
286
+ }
287
+ /**
288
+ * List memberships with filtering
289
+ */
290
+ async listMemberships(params) {
291
+ if (params) {
292
+ ListMembershipsQuerySchema.parse(params);
293
+ }
294
+ const searchParams = new URLSearchParams();
295
+ if (params?.userId) {
296
+ searchParams.append("userId", params.userId);
297
+ }
298
+ if (params?.organizationId) {
299
+ searchParams.append("organizationId", params.organizationId);
300
+ }
301
+ if (params?.statuses) {
302
+ params.statuses.forEach((status) => searchParams.append("statuses", status));
303
+ }
304
+ if (params?.limit) {
305
+ searchParams.append("limit", params.limit.toString());
306
+ }
307
+ if (params?.before) {
308
+ searchParams.append("before", params.before);
309
+ }
310
+ if (params?.after) {
311
+ searchParams.append("after", params.after);
312
+ }
313
+ if (params?.order) {
314
+ searchParams.append("order", params.order);
315
+ }
316
+ const url = `/memberships${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
317
+ const response = await this.apiRequest(url);
318
+ return {
319
+ ...response,
320
+ data: response.data.map((membership) => ({
321
+ ...membership,
322
+ createdAt: membership.createdAt,
323
+ updatedAt: membership.updatedAt
324
+ }))
325
+ };
326
+ }
327
+ /**
328
+ * Get a single membership by ID
329
+ */
330
+ async getMembership(membershipId) {
331
+ MembershipIdParamSchema.parse({ id: membershipId });
332
+ const membership = await this.apiRequest(`/memberships/${membershipId}`);
333
+ return {
334
+ ...membership,
335
+ createdAt: membership.createdAt,
336
+ updatedAt: membership.updatedAt
337
+ };
338
+ }
339
+ /**
340
+ * Create a new organization membership
341
+ */
342
+ async createMembership(data) {
343
+ const validated = CreateMembershipSchema.parse(data);
344
+ const membership = await this.apiRequest("/memberships", {
345
+ method: "POST",
346
+ body: JSON.stringify(validated)
347
+ });
348
+ return {
349
+ ...membership,
350
+ createdAt: membership.createdAt,
351
+ updatedAt: membership.updatedAt
352
+ };
353
+ }
354
+ /**
355
+ * Update an existing membership
356
+ */
357
+ async updateMembership(membershipId, data) {
358
+ MembershipIdParamSchema.parse({ id: membershipId });
359
+ const validated = UpdateMembershipSchema.parse(data);
360
+ const membership = await this.apiRequest(`/memberships/${membershipId}`, {
361
+ method: "PUT",
362
+ body: JSON.stringify(validated)
363
+ });
364
+ return {
365
+ ...membership,
366
+ createdAt: membership.createdAt,
367
+ updatedAt: membership.updatedAt
368
+ };
369
+ }
370
+ /**
371
+ * Delete a membership
372
+ */
373
+ async deleteMembership(membershipId) {
374
+ MembershipIdParamSchema.parse({ id: membershipId });
375
+ await this.apiRequest(`/memberships/${membershipId}`, {
376
+ method: "DELETE"
377
+ });
378
+ }
379
+ /**
380
+ * Deactivate a membership (soft delete)
381
+ */
382
+ async deactivateMembership(membershipId) {
383
+ MembershipIdParamSchema.parse({ id: membershipId });
384
+ const membership = await this.apiRequest(`/memberships/${membershipId}/deactivate`, {
385
+ method: "POST"
386
+ });
387
+ return {
388
+ ...membership,
389
+ createdAt: membership.createdAt,
390
+ updatedAt: membership.updatedAt
391
+ };
392
+ }
393
+ /**
394
+ * Reactivate a membership
395
+ */
396
+ async reactivateMembership(membershipId) {
397
+ MembershipIdParamSchema.parse({ id: membershipId });
398
+ const membership = await this.apiRequest(`/memberships/${membershipId}/reactivate`, {
399
+ method: "POST"
400
+ });
401
+ return {
402
+ ...membership,
403
+ createdAt: membership.createdAt,
404
+ updatedAt: membership.updatedAt
405
+ };
406
+ }
407
+ /**
408
+ * Write the WorkOS membership link the acceptance path failed to record --
409
+ * the repair for a membership reported as `accepted_unlinked`.
410
+ *
411
+ * Idempotent on the server: an already-linked row returns unchanged. A row in
412
+ * any other state is refused with a 409 rather than guessed at.
413
+ */
414
+ async repairMembershipLink(membershipId) {
415
+ MembershipIdParamSchema.parse({ id: membershipId });
416
+ const membership = await this.apiRequest(`/memberships/${membershipId}/repair-link`, {
417
+ method: "POST"
418
+ });
419
+ return {
420
+ ...membership,
421
+ createdAt: membership.createdAt,
422
+ updatedAt: membership.updatedAt
423
+ };
424
+ }
425
+ };
426
+ function useUserMemberships(userId, params) {
427
+ const { apiRequest, isReady } = useElevasisServices();
428
+ return useQuery({
429
+ queryKey: ["memberships", "user", userId, params],
430
+ queryFn: async () => {
431
+ const membershipService = new OrganizationMembershipService(apiRequest);
432
+ return await membershipService.getUserMemberships(userId);
433
+ },
434
+ enabled: isReady && !!userId,
435
+ refetchOnWindowFocus: false,
436
+ staleTime: STALE_TIME_DEFAULT,
437
+ gcTime: GC_TIME_MEDIUM
438
+ });
439
+ }
440
+ function useDeactivateMembership() {
441
+ const { apiRequest } = useElevasisServices();
442
+ const adapter = useNotificationAdapter();
443
+ const queryClient = useQueryClient();
444
+ return useMutation({
445
+ mutationFn: async ({ membershipId }) => {
446
+ const membershipService = new OrganizationMembershipService(apiRequest);
447
+ return await membershipService.deactivateMembership(membershipId);
448
+ },
449
+ onError: (error) => {
450
+ adapter.apiError(error);
451
+ },
452
+ // Fires on both success and failure. A prior `onSuccess` invalidated the
453
+ // same key redundantly.
454
+ onSettled: () => {
455
+ queryClient.invalidateQueries({ queryKey: ["memberships"] });
456
+ }
457
+ });
458
+ }
459
+ function useReactivateMembership() {
460
+ const { apiRequest } = useElevasisServices();
461
+ const adapter = useNotificationAdapter();
462
+ const queryClient = useQueryClient();
463
+ return useMutation({
464
+ mutationFn: async ({ membershipId }) => {
465
+ const membershipService = new OrganizationMembershipService(apiRequest);
466
+ return await membershipService.reactivateMembership(membershipId);
467
+ },
468
+ onError: (error) => {
469
+ adapter.apiError(error);
470
+ },
471
+ onSettled: () => {
472
+ queryClient.invalidateQueries({ queryKey: ["memberships"] });
473
+ }
474
+ });
475
+ }
476
+ function useOrganizationMembers(organizationId, params) {
477
+ const { apiRequest, isReady } = useElevasisServices();
478
+ return useQuery({
479
+ queryKey: ["organization-members", organizationId, params],
480
+ queryFn: async () => {
481
+ const searchParams = new URLSearchParams();
482
+ searchParams.append("organizationId", organizationId);
483
+ if (params?.userId) {
484
+ searchParams.append("userId", params.userId);
485
+ }
486
+ for (const status of params?.statuses ?? []) {
487
+ searchParams.append("statuses", status);
488
+ }
489
+ if (params?.order) {
490
+ searchParams.append("order", params.order);
491
+ }
492
+ if (params?.limit !== void 0) {
493
+ searchParams.append("limit", String(params.limit));
494
+ }
495
+ if (params?.before) {
496
+ searchParams.append("before", params.before);
497
+ }
498
+ if (params?.after) {
499
+ searchParams.append("after", params.after);
500
+ }
501
+ const response = await apiRequest(`/memberships?${searchParams.toString()}`);
502
+ return response.data.map((membership) => ({
503
+ ...membership,
504
+ createdAt: membership.createdAt,
505
+ updatedAt: membership.updatedAt
506
+ }));
507
+ },
508
+ enabled: isReady && !!organizationId,
509
+ staleTime: STALE_TIME_MONITORING,
510
+ gcTime: GC_TIME_SHORT,
511
+ refetchOnWindowFocus: false
512
+ });
513
+ }
514
+
515
+ export { MEMBERSHIP_STATUS_COLORS, OrganizationMembershipService, PROVISIONING_STATE_DISPLAY, WebhookEndpointService, transformMembershipToTableRow, useAssignRole, useCreateWebhookEndpoint, useDeactivateMembership, useDeleteWebhookEndpoint, useListWebhookEndpoints, useOrgRoles, useOrganizationMembers, usePermissionCatalog, useReactivateMembership, useRevokeRole, useUpdateWebhookEndpoint, useUserMemberships };