@elqnt/admin 2.3.0 → 2.3.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/README.md +24 -14
- package/SKILL.md +570 -0
- package/dist/{analytics-CZ0LmSlf.d.cts → admin-C1iVQe2d.d.cts} +6 -168
- package/dist/{analytics-CZ0LmSlf.d.ts → admin-C1iVQe2d.d.ts} +6 -168
- package/dist/api/index.cjs +29 -125
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +4 -50
- package/dist/api/index.d.ts +4 -50
- package/dist/api/index.js +28 -115
- package/dist/api/index.js.map +1 -1
- package/dist/hooks/index.cjs +85 -419
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +66 -129
- package/dist/hooks/index.d.ts +66 -129
- package/dist/hooks/index.js +85 -415
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +32 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +30 -115
- package/dist/index.js.map +1 -1
- package/dist/models/index.cjs +3 -0
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -1
- package/dist/{orgs-BOVRgr8L.d.ts → orgs-BSHeYVe-.d.ts} +1 -1
- package/dist/{orgs-IvppiqI8.d.cts → orgs-Buu2Re0N.d.cts} +1 -1
- package/package.json +5 -4
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,193 +1,130 @@
|
|
|
1
1
|
import { ApiClientOptions } from '@elqnt/api-client';
|
|
2
|
-
import { b as Org,
|
|
3
|
-
import { L as ListOrgsFilter } from '../orgs-IvppiqI8.cjs';
|
|
2
|
+
import { b as Org, as as OrgInfo, ba as User, bf as UserSettingsResponse, be as UserSettings, a9 as NotificationPreferences, S as Invite, T as InviteInput, a2 as InvitesResult } from '../admin-C1iVQe2d.cjs';
|
|
4
3
|
import { OrgSettings } from '@elqnt/agents/models';
|
|
4
|
+
import { L as ListOrgsFilter } from '../orgs-Buu2Re0N.cjs';
|
|
5
5
|
import '@elqnt/types';
|
|
6
6
|
|
|
7
7
|
type UseOrgAdminOptions = ApiClientOptions;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* const { loading, error, listOrgs, createOrg, updateOrg } = useOrgAdmin({
|
|
14
|
-
* baseUrl: apiGatewayUrl,
|
|
15
|
-
* orgId: selectedOrgId,
|
|
16
|
-
* userId: user?.id,
|
|
17
|
-
* userEmail: user?.email,
|
|
18
|
-
* });
|
|
9
|
+
* The exact, stable return surface of `useOrgAdmin`.
|
|
19
10
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
11
|
+
* This is the agent/consumer **contract**: the only members that exist on the
|
|
12
|
+
* org-admin hook (org CRUD + the settings methods folded in from the former
|
|
13
|
+
* `useOrgSettings`). Every method is imperative and DOES NOT throw — on failure
|
|
14
|
+
* it resolves to the documented default (`[]`, `null`, `false`) and sets
|
|
15
|
+
* `error`. See `SKILL.md`.
|
|
23
16
|
*/
|
|
24
|
-
|
|
17
|
+
interface UseOrgAdminReturn {
|
|
18
|
+
/** True while any in-flight call runs. */
|
|
25
19
|
loading: boolean;
|
|
20
|
+
/** Last error message, else null. */
|
|
26
21
|
error: string | null;
|
|
22
|
+
/** GET /api/v1/admin/orgs (optional ?status&type&product) — default []. */
|
|
27
23
|
listOrgs: (filter?: ListOrgsFilter) => Promise<Org[]>;
|
|
24
|
+
/** GET /api/v1/admin/orgs/{orgId} — default null. */
|
|
28
25
|
getOrg: (orgId: string) => Promise<Org | null>;
|
|
26
|
+
/** GET /api/v1/admin/orgs/{orgId}/info (lightweight) — default null. */
|
|
29
27
|
getOrgInfo: (orgId: string) => Promise<OrgInfo | null>;
|
|
28
|
+
/** POST /api/v1/admin/orgs — created org, or null on error. `product` is transient routing metadata. */
|
|
30
29
|
createOrg: (org: Partial<Org> & {
|
|
31
30
|
product?: string;
|
|
32
31
|
}) => Promise<Org | null>;
|
|
32
|
+
/** PUT /api/v1/admin/orgs/{orgId} — updated org, or null on error. */
|
|
33
33
|
updateOrg: (orgId: string, updates: Partial<Org>) => Promise<Org | null>;
|
|
34
|
+
/** DELETE /api/v1/admin/orgs/{orgId} — true on success. */
|
|
34
35
|
deleteOrg: (orgId: string) => Promise<boolean>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/** GET /api/v1/admin/orgs/{orgId} → OrgSettings — default null. */
|
|
37
|
+
getSettings: () => Promise<OrgSettings | null>;
|
|
38
|
+
/** Alias for updateSettings (settings rows always exist). PUT /api/v1/admin/orgs/{orgId}. */
|
|
39
|
+
createSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
40
|
+
/** PUT /api/v1/admin/orgs/{orgId} then re-GET — updated OrgSettings, or null on error. */
|
|
41
|
+
updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
42
|
+
}
|
|
38
43
|
/**
|
|
39
|
-
* Hook for
|
|
44
|
+
* Hook for organization CRUD operations
|
|
40
45
|
*
|
|
41
46
|
* @example
|
|
42
47
|
* ```tsx
|
|
43
|
-
* const { loading, error,
|
|
48
|
+
* const { loading, error, listOrgs, createOrg, updateOrg } = useOrgAdmin({
|
|
44
49
|
* baseUrl: apiGatewayUrl,
|
|
45
50
|
* orgId: selectedOrgId,
|
|
46
51
|
* userId: user?.id,
|
|
47
52
|
* userEmail: user?.email,
|
|
48
53
|
* });
|
|
49
54
|
*
|
|
50
|
-
* const
|
|
51
|
-
* const
|
|
55
|
+
* const orgs = await listOrgs();
|
|
56
|
+
* const newOrg = await createOrg({ name: "Acme Corp" });
|
|
52
57
|
* ```
|
|
53
58
|
*/
|
|
54
|
-
declare function
|
|
59
|
+
declare function useOrgAdmin(options: UseOrgAdminOptions): UseOrgAdminReturn;
|
|
60
|
+
|
|
61
|
+
type UseUsersAdminOptions = ApiClientOptions;
|
|
62
|
+
/**
|
|
63
|
+
* The exact, stable return surface of `useUsersAdmin`.
|
|
64
|
+
*
|
|
65
|
+
* Agent/consumer **contract**: the only members on the users-admin hook (user
|
|
66
|
+
* CRUD + the invitation methods folded in from the former `useInvitesAdmin`).
|
|
67
|
+
* Every method is imperative and DOES NOT throw — on failure it resolves to its
|
|
68
|
+
* default (`[]`, `null`, `false`) and sets `error`. See `SKILL.md`.
|
|
69
|
+
*/
|
|
70
|
+
interface UseUsersAdminReturn {
|
|
71
|
+
/** True while any in-flight call runs. */
|
|
55
72
|
loading: boolean;
|
|
73
|
+
/** Last error message, else null. */
|
|
56
74
|
error: string | null;
|
|
75
|
+
/** GET /api/v1/admin/users — default []. */
|
|
57
76
|
listUsers: () => Promise<User[]>;
|
|
77
|
+
/** GET /api/v1/admin/users/{userId} — default null. */
|
|
58
78
|
getUser: (userId: string) => Promise<User | null>;
|
|
79
|
+
/** GET /api/v1/admin/users/by-email?email= — default null. */
|
|
59
80
|
getUserByEmail: (email: string) => Promise<User | null>;
|
|
81
|
+
/** GET /api/v1/admin/users/by-phone?phone= — default null. */
|
|
60
82
|
getUserByPhone: (phone: string) => Promise<User | null>;
|
|
83
|
+
/** POST /api/v1/admin/users — created user, or null on error. */
|
|
61
84
|
createUser: (user: Partial<User>) => Promise<User | null>;
|
|
85
|
+
/** PUT /api/v1/admin/users/{userId} — updated user, or null on error. */
|
|
62
86
|
updateUser: (userId: string, updates: Partial<User>) => Promise<User | null>;
|
|
87
|
+
/** DELETE /api/v1/admin/users/{userId} — true on success. */
|
|
63
88
|
deleteUser: (userId: string) => Promise<boolean>;
|
|
89
|
+
/** GET /api/v1/admin/users/{userId}/settings — default null. */
|
|
64
90
|
getUserSettings: (userId: string) => Promise<UserSettingsResponse | null>;
|
|
91
|
+
/** PUT /api/v1/admin/users/{userId}/settings — updated settings, or null on error. */
|
|
65
92
|
updateUserSettings: (userId: string, settings: {
|
|
66
93
|
settings?: UserSettings;
|
|
67
94
|
notificationPreferences?: NotificationPreferences;
|
|
68
95
|
}) => Promise<UserSettingsResponse | null>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
type UseInvitesAdminOptions = ApiClientOptions;
|
|
72
|
-
/**
|
|
73
|
-
* Hook for invitation CRUD operations
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```tsx
|
|
77
|
-
* const { loading, error, listInvites, sendInvite, revokeInvite } = useInvitesAdmin({
|
|
78
|
-
* baseUrl: apiGatewayUrl,
|
|
79
|
-
* orgId: selectedOrgId,
|
|
80
|
-
* userId: user?.id,
|
|
81
|
-
* userEmail: user?.email,
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* const invites = await listInvites();
|
|
85
|
-
* await sendInvite({ email: "user@example.com", role: "member" });
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
declare function useInvitesAdmin(options: UseInvitesAdminOptions): {
|
|
89
|
-
loading: boolean;
|
|
90
|
-
error: string | null;
|
|
96
|
+
/** GET /api/v1/admin/invites — default []. */
|
|
91
97
|
listInvites: () => Promise<Invite[]>;
|
|
98
|
+
/** GET /api/v1/admin/invites/{inviteId} — default null. */
|
|
92
99
|
getInvite: (inviteId: string) => Promise<Invite | null>;
|
|
100
|
+
/** POST /api/v1/admin/invites/single — created invite, or null on error. */
|
|
93
101
|
sendInvite: (invite: InviteInput) => Promise<Invite | null>;
|
|
102
|
+
/** POST /api/v1/admin/invites, body { invites } — batch result, or null on error. */
|
|
94
103
|
sendInvites: (invites: InviteInput[]) => Promise<InvitesResult | null>;
|
|
104
|
+
/** POST /api/v1/admin/invites/{inviteId}/resend — invite, or null on error. */
|
|
95
105
|
resendInvite: (inviteId: string) => Promise<Invite | null>;
|
|
106
|
+
/** DELETE /api/v1/admin/invites/{inviteId} — true on success. */
|
|
96
107
|
revokeInvite: (inviteId: string) => Promise<boolean>;
|
|
108
|
+
/** POST /api/v1/admin/invites/{inviteId}/accept — invite, or null on error. */
|
|
97
109
|
acceptInvite: (inviteId: string) => Promise<Invite | null>;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
type UseOrgSettingsOptions = ApiClientOptions;
|
|
101
|
-
/**
|
|
102
|
-
* Hook for organization settings CRUD operations
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```tsx
|
|
106
|
-
* const { loading, error, getSettings, createSettings, updateSettings } = useOrgSettings({
|
|
107
|
-
* baseUrl: apiGatewayUrl,
|
|
108
|
-
* orgId: selectedOrgId,
|
|
109
|
-
* });
|
|
110
|
-
*
|
|
111
|
-
* const settings = await getSettings();
|
|
112
|
-
* await updateSettings({ timezone: "America/New_York" });
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function useOrgSettings(options: UseOrgSettingsOptions): {
|
|
116
|
-
loading: boolean;
|
|
117
|
-
error: string | null;
|
|
118
|
-
getSettings: () => Promise<OrgSettings | null>;
|
|
119
|
-
createSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
120
|
-
updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
type UseProductAnalyticsOptions = ApiClientOptions;
|
|
124
|
-
interface ProductAnalyticsState {
|
|
125
|
-
summary: AnalyticsSummary | null;
|
|
126
|
-
chats: ChatAnalytics[];
|
|
127
|
-
agents: AgentAnalytics[];
|
|
128
|
-
usage: UsageAnalytics[];
|
|
129
|
-
daily: DailyAnalytics[];
|
|
130
|
-
events: AnalyticsEvent[];
|
|
131
|
-
loading: boolean;
|
|
132
|
-
error: string | null;
|
|
133
110
|
}
|
|
134
111
|
/**
|
|
135
|
-
* Hook for
|
|
112
|
+
* Hook for user + invitation CRUD operations
|
|
136
113
|
*
|
|
137
114
|
* @example
|
|
138
115
|
* ```tsx
|
|
139
|
-
* const {
|
|
140
|
-
* loading,
|
|
141
|
-
* error,
|
|
142
|
-
* summary,
|
|
143
|
-
* getSummary,
|
|
144
|
-
* trackEvent,
|
|
145
|
-
* } = useProductAnalytics({
|
|
116
|
+
* const { loading, error, listUsers, createUser, updateUser, listInvites, sendInvite } = useUsersAdmin({
|
|
146
117
|
* baseUrl: apiGatewayUrl,
|
|
147
|
-
* orgId:
|
|
118
|
+
* orgId: selectedOrgId,
|
|
148
119
|
* userId: user?.id,
|
|
149
120
|
* userEmail: user?.email,
|
|
150
121
|
* });
|
|
151
122
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* // Track events
|
|
156
|
-
* trackEvent("button_click", "ui", { buttonId: "submit" });
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
declare function useProductAnalytics(options: UseProductAnalyticsOptions): {
|
|
160
|
-
getSummary: (filter?: DateFilter) => Promise<AnalyticsSummary | null>;
|
|
161
|
-
getChats: (filter?: DateFilter, agentId?: string) => Promise<ChatAnalytics[]>;
|
|
162
|
-
getAgents: (filter?: DateFilter) => Promise<AgentAnalytics[]>;
|
|
163
|
-
getUsage: (filter?: DateFilter) => Promise<UsageAnalytics[]>;
|
|
164
|
-
getDaily: (filter?: DateFilter) => Promise<DailyAnalytics[]>;
|
|
165
|
-
getEvents: (filter?: DateFilter) => Promise<AnalyticsEvent[]>;
|
|
166
|
-
trackEvent: (eventType: string, eventCategory: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
167
|
-
trackPageView: (pageName?: string) => Promise<void>;
|
|
168
|
-
getGlobalSummary: (filter?: DateFilter) => Promise<GlobalAnalyticsSummary | null>;
|
|
169
|
-
getGlobalOrgs: (filter?: DateFilter) => Promise<OrgAnalytics[]>;
|
|
170
|
-
summary: AnalyticsSummary | null;
|
|
171
|
-
chats: ChatAnalytics[];
|
|
172
|
-
agents: AgentAnalytics[];
|
|
173
|
-
usage: UsageAnalytics[];
|
|
174
|
-
daily: DailyAnalytics[];
|
|
175
|
-
events: AnalyticsEvent[];
|
|
176
|
-
loading: boolean;
|
|
177
|
-
error: string | null;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Hook to use analytics context (for event tracking throughout the app)
|
|
181
|
-
*
|
|
182
|
-
* This is an alias for useProductAnalytics that makes the intent clearer
|
|
183
|
-
* when used primarily for event tracking.
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```tsx
|
|
187
|
-
* const { trackEvent } = useAnalyticsContext(options);
|
|
188
|
-
* trackEvent("form_submit", "ui", { formId: "contact" });
|
|
123
|
+
* const users = await listUsers();
|
|
124
|
+
* const user = await getUserByEmail("user@example.com");
|
|
125
|
+
* await sendInvite({ email: "user@example.com", role: "member" });
|
|
189
126
|
* ```
|
|
190
127
|
*/
|
|
191
|
-
declare
|
|
128
|
+
declare function useUsersAdmin(options: UseUsersAdminOptions): UseUsersAdminReturn;
|
|
192
129
|
|
|
193
|
-
export { type
|
|
130
|
+
export { type UseOrgAdminOptions, type UseOrgAdminReturn, type UseUsersAdminOptions, type UseUsersAdminReturn, useOrgAdmin, useUsersAdmin };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,193 +1,130 @@
|
|
|
1
1
|
import { ApiClientOptions } from '@elqnt/api-client';
|
|
2
|
-
import { b as Org,
|
|
3
|
-
import { L as ListOrgsFilter } from '../orgs-BOVRgr8L.js';
|
|
2
|
+
import { b as Org, as as OrgInfo, ba as User, bf as UserSettingsResponse, be as UserSettings, a9 as NotificationPreferences, S as Invite, T as InviteInput, a2 as InvitesResult } from '../admin-C1iVQe2d.js';
|
|
4
3
|
import { OrgSettings } from '@elqnt/agents/models';
|
|
4
|
+
import { L as ListOrgsFilter } from '../orgs-BSHeYVe-.js';
|
|
5
5
|
import '@elqnt/types';
|
|
6
6
|
|
|
7
7
|
type UseOrgAdminOptions = ApiClientOptions;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* const { loading, error, listOrgs, createOrg, updateOrg } = useOrgAdmin({
|
|
14
|
-
* baseUrl: apiGatewayUrl,
|
|
15
|
-
* orgId: selectedOrgId,
|
|
16
|
-
* userId: user?.id,
|
|
17
|
-
* userEmail: user?.email,
|
|
18
|
-
* });
|
|
9
|
+
* The exact, stable return surface of `useOrgAdmin`.
|
|
19
10
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
11
|
+
* This is the agent/consumer **contract**: the only members that exist on the
|
|
12
|
+
* org-admin hook (org CRUD + the settings methods folded in from the former
|
|
13
|
+
* `useOrgSettings`). Every method is imperative and DOES NOT throw — on failure
|
|
14
|
+
* it resolves to the documented default (`[]`, `null`, `false`) and sets
|
|
15
|
+
* `error`. See `SKILL.md`.
|
|
23
16
|
*/
|
|
24
|
-
|
|
17
|
+
interface UseOrgAdminReturn {
|
|
18
|
+
/** True while any in-flight call runs. */
|
|
25
19
|
loading: boolean;
|
|
20
|
+
/** Last error message, else null. */
|
|
26
21
|
error: string | null;
|
|
22
|
+
/** GET /api/v1/admin/orgs (optional ?status&type&product) — default []. */
|
|
27
23
|
listOrgs: (filter?: ListOrgsFilter) => Promise<Org[]>;
|
|
24
|
+
/** GET /api/v1/admin/orgs/{orgId} — default null. */
|
|
28
25
|
getOrg: (orgId: string) => Promise<Org | null>;
|
|
26
|
+
/** GET /api/v1/admin/orgs/{orgId}/info (lightweight) — default null. */
|
|
29
27
|
getOrgInfo: (orgId: string) => Promise<OrgInfo | null>;
|
|
28
|
+
/** POST /api/v1/admin/orgs — created org, or null on error. `product` is transient routing metadata. */
|
|
30
29
|
createOrg: (org: Partial<Org> & {
|
|
31
30
|
product?: string;
|
|
32
31
|
}) => Promise<Org | null>;
|
|
32
|
+
/** PUT /api/v1/admin/orgs/{orgId} — updated org, or null on error. */
|
|
33
33
|
updateOrg: (orgId: string, updates: Partial<Org>) => Promise<Org | null>;
|
|
34
|
+
/** DELETE /api/v1/admin/orgs/{orgId} — true on success. */
|
|
34
35
|
deleteOrg: (orgId: string) => Promise<boolean>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/** GET /api/v1/admin/orgs/{orgId} → OrgSettings — default null. */
|
|
37
|
+
getSettings: () => Promise<OrgSettings | null>;
|
|
38
|
+
/** Alias for updateSettings (settings rows always exist). PUT /api/v1/admin/orgs/{orgId}. */
|
|
39
|
+
createSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
40
|
+
/** PUT /api/v1/admin/orgs/{orgId} then re-GET — updated OrgSettings, or null on error. */
|
|
41
|
+
updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
42
|
+
}
|
|
38
43
|
/**
|
|
39
|
-
* Hook for
|
|
44
|
+
* Hook for organization CRUD operations
|
|
40
45
|
*
|
|
41
46
|
* @example
|
|
42
47
|
* ```tsx
|
|
43
|
-
* const { loading, error,
|
|
48
|
+
* const { loading, error, listOrgs, createOrg, updateOrg } = useOrgAdmin({
|
|
44
49
|
* baseUrl: apiGatewayUrl,
|
|
45
50
|
* orgId: selectedOrgId,
|
|
46
51
|
* userId: user?.id,
|
|
47
52
|
* userEmail: user?.email,
|
|
48
53
|
* });
|
|
49
54
|
*
|
|
50
|
-
* const
|
|
51
|
-
* const
|
|
55
|
+
* const orgs = await listOrgs();
|
|
56
|
+
* const newOrg = await createOrg({ name: "Acme Corp" });
|
|
52
57
|
* ```
|
|
53
58
|
*/
|
|
54
|
-
declare function
|
|
59
|
+
declare function useOrgAdmin(options: UseOrgAdminOptions): UseOrgAdminReturn;
|
|
60
|
+
|
|
61
|
+
type UseUsersAdminOptions = ApiClientOptions;
|
|
62
|
+
/**
|
|
63
|
+
* The exact, stable return surface of `useUsersAdmin`.
|
|
64
|
+
*
|
|
65
|
+
* Agent/consumer **contract**: the only members on the users-admin hook (user
|
|
66
|
+
* CRUD + the invitation methods folded in from the former `useInvitesAdmin`).
|
|
67
|
+
* Every method is imperative and DOES NOT throw — on failure it resolves to its
|
|
68
|
+
* default (`[]`, `null`, `false`) and sets `error`. See `SKILL.md`.
|
|
69
|
+
*/
|
|
70
|
+
interface UseUsersAdminReturn {
|
|
71
|
+
/** True while any in-flight call runs. */
|
|
55
72
|
loading: boolean;
|
|
73
|
+
/** Last error message, else null. */
|
|
56
74
|
error: string | null;
|
|
75
|
+
/** GET /api/v1/admin/users — default []. */
|
|
57
76
|
listUsers: () => Promise<User[]>;
|
|
77
|
+
/** GET /api/v1/admin/users/{userId} — default null. */
|
|
58
78
|
getUser: (userId: string) => Promise<User | null>;
|
|
79
|
+
/** GET /api/v1/admin/users/by-email?email= — default null. */
|
|
59
80
|
getUserByEmail: (email: string) => Promise<User | null>;
|
|
81
|
+
/** GET /api/v1/admin/users/by-phone?phone= — default null. */
|
|
60
82
|
getUserByPhone: (phone: string) => Promise<User | null>;
|
|
83
|
+
/** POST /api/v1/admin/users — created user, or null on error. */
|
|
61
84
|
createUser: (user: Partial<User>) => Promise<User | null>;
|
|
85
|
+
/** PUT /api/v1/admin/users/{userId} — updated user, or null on error. */
|
|
62
86
|
updateUser: (userId: string, updates: Partial<User>) => Promise<User | null>;
|
|
87
|
+
/** DELETE /api/v1/admin/users/{userId} — true on success. */
|
|
63
88
|
deleteUser: (userId: string) => Promise<boolean>;
|
|
89
|
+
/** GET /api/v1/admin/users/{userId}/settings — default null. */
|
|
64
90
|
getUserSettings: (userId: string) => Promise<UserSettingsResponse | null>;
|
|
91
|
+
/** PUT /api/v1/admin/users/{userId}/settings — updated settings, or null on error. */
|
|
65
92
|
updateUserSettings: (userId: string, settings: {
|
|
66
93
|
settings?: UserSettings;
|
|
67
94
|
notificationPreferences?: NotificationPreferences;
|
|
68
95
|
}) => Promise<UserSettingsResponse | null>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
type UseInvitesAdminOptions = ApiClientOptions;
|
|
72
|
-
/**
|
|
73
|
-
* Hook for invitation CRUD operations
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```tsx
|
|
77
|
-
* const { loading, error, listInvites, sendInvite, revokeInvite } = useInvitesAdmin({
|
|
78
|
-
* baseUrl: apiGatewayUrl,
|
|
79
|
-
* orgId: selectedOrgId,
|
|
80
|
-
* userId: user?.id,
|
|
81
|
-
* userEmail: user?.email,
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* const invites = await listInvites();
|
|
85
|
-
* await sendInvite({ email: "user@example.com", role: "member" });
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
declare function useInvitesAdmin(options: UseInvitesAdminOptions): {
|
|
89
|
-
loading: boolean;
|
|
90
|
-
error: string | null;
|
|
96
|
+
/** GET /api/v1/admin/invites — default []. */
|
|
91
97
|
listInvites: () => Promise<Invite[]>;
|
|
98
|
+
/** GET /api/v1/admin/invites/{inviteId} — default null. */
|
|
92
99
|
getInvite: (inviteId: string) => Promise<Invite | null>;
|
|
100
|
+
/** POST /api/v1/admin/invites/single — created invite, or null on error. */
|
|
93
101
|
sendInvite: (invite: InviteInput) => Promise<Invite | null>;
|
|
102
|
+
/** POST /api/v1/admin/invites, body { invites } — batch result, or null on error. */
|
|
94
103
|
sendInvites: (invites: InviteInput[]) => Promise<InvitesResult | null>;
|
|
104
|
+
/** POST /api/v1/admin/invites/{inviteId}/resend — invite, or null on error. */
|
|
95
105
|
resendInvite: (inviteId: string) => Promise<Invite | null>;
|
|
106
|
+
/** DELETE /api/v1/admin/invites/{inviteId} — true on success. */
|
|
96
107
|
revokeInvite: (inviteId: string) => Promise<boolean>;
|
|
108
|
+
/** POST /api/v1/admin/invites/{inviteId}/accept — invite, or null on error. */
|
|
97
109
|
acceptInvite: (inviteId: string) => Promise<Invite | null>;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
type UseOrgSettingsOptions = ApiClientOptions;
|
|
101
|
-
/**
|
|
102
|
-
* Hook for organization settings CRUD operations
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```tsx
|
|
106
|
-
* const { loading, error, getSettings, createSettings, updateSettings } = useOrgSettings({
|
|
107
|
-
* baseUrl: apiGatewayUrl,
|
|
108
|
-
* orgId: selectedOrgId,
|
|
109
|
-
* });
|
|
110
|
-
*
|
|
111
|
-
* const settings = await getSettings();
|
|
112
|
-
* await updateSettings({ timezone: "America/New_York" });
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function useOrgSettings(options: UseOrgSettingsOptions): {
|
|
116
|
-
loading: boolean;
|
|
117
|
-
error: string | null;
|
|
118
|
-
getSettings: () => Promise<OrgSettings | null>;
|
|
119
|
-
createSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
120
|
-
updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
type UseProductAnalyticsOptions = ApiClientOptions;
|
|
124
|
-
interface ProductAnalyticsState {
|
|
125
|
-
summary: AnalyticsSummary | null;
|
|
126
|
-
chats: ChatAnalytics[];
|
|
127
|
-
agents: AgentAnalytics[];
|
|
128
|
-
usage: UsageAnalytics[];
|
|
129
|
-
daily: DailyAnalytics[];
|
|
130
|
-
events: AnalyticsEvent[];
|
|
131
|
-
loading: boolean;
|
|
132
|
-
error: string | null;
|
|
133
110
|
}
|
|
134
111
|
/**
|
|
135
|
-
* Hook for
|
|
112
|
+
* Hook for user + invitation CRUD operations
|
|
136
113
|
*
|
|
137
114
|
* @example
|
|
138
115
|
* ```tsx
|
|
139
|
-
* const {
|
|
140
|
-
* loading,
|
|
141
|
-
* error,
|
|
142
|
-
* summary,
|
|
143
|
-
* getSummary,
|
|
144
|
-
* trackEvent,
|
|
145
|
-
* } = useProductAnalytics({
|
|
116
|
+
* const { loading, error, listUsers, createUser, updateUser, listInvites, sendInvite } = useUsersAdmin({
|
|
146
117
|
* baseUrl: apiGatewayUrl,
|
|
147
|
-
* orgId:
|
|
118
|
+
* orgId: selectedOrgId,
|
|
148
119
|
* userId: user?.id,
|
|
149
120
|
* userEmail: user?.email,
|
|
150
121
|
* });
|
|
151
122
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* // Track events
|
|
156
|
-
* trackEvent("button_click", "ui", { buttonId: "submit" });
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
declare function useProductAnalytics(options: UseProductAnalyticsOptions): {
|
|
160
|
-
getSummary: (filter?: DateFilter) => Promise<AnalyticsSummary | null>;
|
|
161
|
-
getChats: (filter?: DateFilter, agentId?: string) => Promise<ChatAnalytics[]>;
|
|
162
|
-
getAgents: (filter?: DateFilter) => Promise<AgentAnalytics[]>;
|
|
163
|
-
getUsage: (filter?: DateFilter) => Promise<UsageAnalytics[]>;
|
|
164
|
-
getDaily: (filter?: DateFilter) => Promise<DailyAnalytics[]>;
|
|
165
|
-
getEvents: (filter?: DateFilter) => Promise<AnalyticsEvent[]>;
|
|
166
|
-
trackEvent: (eventType: string, eventCategory: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
167
|
-
trackPageView: (pageName?: string) => Promise<void>;
|
|
168
|
-
getGlobalSummary: (filter?: DateFilter) => Promise<GlobalAnalyticsSummary | null>;
|
|
169
|
-
getGlobalOrgs: (filter?: DateFilter) => Promise<OrgAnalytics[]>;
|
|
170
|
-
summary: AnalyticsSummary | null;
|
|
171
|
-
chats: ChatAnalytics[];
|
|
172
|
-
agents: AgentAnalytics[];
|
|
173
|
-
usage: UsageAnalytics[];
|
|
174
|
-
daily: DailyAnalytics[];
|
|
175
|
-
events: AnalyticsEvent[];
|
|
176
|
-
loading: boolean;
|
|
177
|
-
error: string | null;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Hook to use analytics context (for event tracking throughout the app)
|
|
181
|
-
*
|
|
182
|
-
* This is an alias for useProductAnalytics that makes the intent clearer
|
|
183
|
-
* when used primarily for event tracking.
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```tsx
|
|
187
|
-
* const { trackEvent } = useAnalyticsContext(options);
|
|
188
|
-
* trackEvent("form_submit", "ui", { formId: "contact" });
|
|
123
|
+
* const users = await listUsers();
|
|
124
|
+
* const user = await getUserByEmail("user@example.com");
|
|
125
|
+
* await sendInvite({ email: "user@example.com", role: "member" });
|
|
189
126
|
* ```
|
|
190
127
|
*/
|
|
191
|
-
declare
|
|
128
|
+
declare function useUsersAdmin(options: UseUsersAdminOptions): UseUsersAdminReturn;
|
|
192
129
|
|
|
193
|
-
export { type
|
|
130
|
+
export { type UseOrgAdminOptions, type UseOrgAdminReturn, type UseUsersAdminOptions, type UseUsersAdminReturn, useOrgAdmin, useUsersAdmin };
|