@elqnt/admin 2.0.5 → 2.2.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/api/index.cjs +486 -29
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +197 -4
- package/dist/api/index.d.ts +197 -4
- package/dist/api/index.js +439 -28
- package/dist/api/index.js.map +1 -1
- package/dist/hooks/index.cjs +1526 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +249 -0
- package/dist/hooks/index.d.ts +249 -0
- package/dist/hooks/index.js +1493 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +1107 -29
- 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 +883 -28
- package/dist/index.js.map +1 -1
- package/dist/models/index.cjs +630 -0
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +2347 -35
- package/dist/models/index.d.ts +2347 -35
- package/dist/models/index.js +445 -0
- package/dist/models/index.js.map +1 -1
- package/dist/provisioning-Cfl6wbmV.d.cts +168 -0
- package/dist/provisioning-Il9t2jnH.d.ts +168 -0
- package/package.json +9 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { ApiClientOptions } from '@elqnt/api-client';
|
|
2
|
+
import { Org, OrgInfo, OrgSchemaTypeTS, CreateOrgWithSchemasResponse, User, UserSettingsResponse, UserSettings, NotificationPreferences, Invite, InviteInput, InvitesResult, AnalyticsSummary, ChatAnalytics, AgentAnalytics, UsageAnalytics, DailyAnalytics, AnalyticsEvent, DateFilter, GlobalAnalyticsSummary, OrgAnalytics, CreateOrgRequest, OrgArtifactTypeTS } from '../models/index.js';
|
|
3
|
+
import { L as ListOrgsFilter, P as ProvisioningProgress, V as ValidationResult } from '../provisioning-Il9t2jnH.js';
|
|
4
|
+
import { OrgSettings } from '@elqnt/agents/models';
|
|
5
|
+
import '@elqnt/types';
|
|
6
|
+
|
|
7
|
+
type UseOrgAdminOptions = ApiClientOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Hook for organization CRUD operations
|
|
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
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const orgs = await listOrgs();
|
|
21
|
+
* const newOrg = await createOrg({ name: "Acme Corp" });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare function useOrgAdmin(options: UseOrgAdminOptions): {
|
|
25
|
+
loading: boolean;
|
|
26
|
+
error: string | null;
|
|
27
|
+
listOrgs: (filter?: ListOrgsFilter) => Promise<Org[]>;
|
|
28
|
+
getOrg: (orgId: string) => Promise<Org | null>;
|
|
29
|
+
getOrgInfo: (orgId: string) => Promise<OrgInfo | null>;
|
|
30
|
+
createOrg: (org: Partial<Org>) => Promise<Org | null>;
|
|
31
|
+
createOrgWithSchemas: (org: Partial<Org>, schemas: OrgSchemaTypeTS[]) => Promise<CreateOrgWithSchemasResponse | null>;
|
|
32
|
+
updateOrg: (orgId: string, updates: Partial<Org>) => Promise<Org | null>;
|
|
33
|
+
deleteOrg: (orgId: string) => Promise<boolean>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type UseUsersAdminOptions = ApiClientOptions;
|
|
37
|
+
/**
|
|
38
|
+
* Hook for user CRUD operations
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const { loading, error, listUsers, createUser, updateUser } = useUsersAdmin({
|
|
43
|
+
* baseUrl: apiGatewayUrl,
|
|
44
|
+
* orgId: selectedOrgId,
|
|
45
|
+
* userId: user?.id,
|
|
46
|
+
* userEmail: user?.email,
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* const users = await listUsers();
|
|
50
|
+
* const user = await getUserByEmail("user@example.com");
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function useUsersAdmin(options: UseUsersAdminOptions): {
|
|
54
|
+
loading: boolean;
|
|
55
|
+
error: string | null;
|
|
56
|
+
listUsers: () => Promise<User[]>;
|
|
57
|
+
getUser: (userId: string) => Promise<User | null>;
|
|
58
|
+
getUserByEmail: (email: string) => Promise<User | null>;
|
|
59
|
+
getUserByPhone: (phone: string) => Promise<User | null>;
|
|
60
|
+
createUser: (user: Partial<User>) => Promise<User | null>;
|
|
61
|
+
updateUser: (userId: string, updates: Partial<User>) => Promise<User | null>;
|
|
62
|
+
deleteUser: (userId: string) => Promise<boolean>;
|
|
63
|
+
getUserSettings: (userId: string) => Promise<UserSettingsResponse | null>;
|
|
64
|
+
updateUserSettings: (userId: string, settings: {
|
|
65
|
+
settings?: UserSettings;
|
|
66
|
+
notificationPreferences?: NotificationPreferences;
|
|
67
|
+
}) => Promise<UserSettingsResponse | null>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type UseInvitesAdminOptions = ApiClientOptions;
|
|
71
|
+
/**
|
|
72
|
+
* Hook for invitation CRUD operations
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```tsx
|
|
76
|
+
* const { loading, error, listInvites, sendInvite, revokeInvite } = useInvitesAdmin({
|
|
77
|
+
* baseUrl: apiGatewayUrl,
|
|
78
|
+
* orgId: selectedOrgId,
|
|
79
|
+
* userId: user?.id,
|
|
80
|
+
* userEmail: user?.email,
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* const invites = await listInvites();
|
|
84
|
+
* await sendInvite({ email: "user@example.com", role: "member" });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare function useInvitesAdmin(options: UseInvitesAdminOptions): {
|
|
88
|
+
loading: boolean;
|
|
89
|
+
error: string | null;
|
|
90
|
+
listInvites: () => Promise<Invite[]>;
|
|
91
|
+
getInvite: (inviteId: string) => Promise<Invite | null>;
|
|
92
|
+
sendInvite: (invite: InviteInput) => Promise<Invite | null>;
|
|
93
|
+
sendInvites: (invites: InviteInput[]) => Promise<InvitesResult | null>;
|
|
94
|
+
resendInvite: (inviteId: string) => Promise<Invite | null>;
|
|
95
|
+
revokeInvite: (inviteId: string) => Promise<boolean>;
|
|
96
|
+
acceptInvite: (inviteId: string) => Promise<Invite | null>;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type UseOrgSettingsOptions = ApiClientOptions;
|
|
100
|
+
/**
|
|
101
|
+
* Hook for organization settings CRUD operations
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* const { loading, error, getSettings, createSettings, updateSettings } = useOrgSettings({
|
|
106
|
+
* baseUrl: apiGatewayUrl,
|
|
107
|
+
* orgId: selectedOrgId,
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* const settings = await getSettings();
|
|
111
|
+
* await updateSettings({ timezone: "America/New_York" });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function useOrgSettings(options: UseOrgSettingsOptions): {
|
|
115
|
+
loading: boolean;
|
|
116
|
+
error: string | null;
|
|
117
|
+
getSettings: () => Promise<OrgSettings | null>;
|
|
118
|
+
createSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
119
|
+
updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type UseProductAnalyticsOptions = ApiClientOptions;
|
|
123
|
+
interface ProductAnalyticsState {
|
|
124
|
+
summary: AnalyticsSummary | null;
|
|
125
|
+
chats: ChatAnalytics[];
|
|
126
|
+
agents: AgentAnalytics[];
|
|
127
|
+
usage: UsageAnalytics[];
|
|
128
|
+
daily: DailyAnalytics[];
|
|
129
|
+
events: AnalyticsEvent[];
|
|
130
|
+
loading: boolean;
|
|
131
|
+
error: string | null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Hook for product analytics queries and event tracking
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* const {
|
|
139
|
+
* loading,
|
|
140
|
+
* error,
|
|
141
|
+
* summary,
|
|
142
|
+
* getSummary,
|
|
143
|
+
* trackEvent,
|
|
144
|
+
* } = useProductAnalytics({
|
|
145
|
+
* baseUrl: apiGatewayUrl,
|
|
146
|
+
* orgId: user?.orgId,
|
|
147
|
+
* userId: user?.id,
|
|
148
|
+
* userEmail: user?.email,
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* // Fetch analytics
|
|
152
|
+
* await getSummary({ from: "2024-01-01", to: "2024-12-31" });
|
|
153
|
+
*
|
|
154
|
+
* // Track events
|
|
155
|
+
* trackEvent("button_click", "ui", { buttonId: "submit" });
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function useProductAnalytics(options: UseProductAnalyticsOptions): {
|
|
159
|
+
getSummary: (filter?: DateFilter) => Promise<AnalyticsSummary | null>;
|
|
160
|
+
getChats: (filter?: DateFilter, agentId?: string) => Promise<ChatAnalytics[]>;
|
|
161
|
+
getAgents: (filter?: DateFilter) => Promise<AgentAnalytics[]>;
|
|
162
|
+
getUsage: (filter?: DateFilter) => Promise<UsageAnalytics[]>;
|
|
163
|
+
getDaily: (filter?: DateFilter) => Promise<DailyAnalytics[]>;
|
|
164
|
+
getEvents: (filter?: DateFilter) => Promise<AnalyticsEvent[]>;
|
|
165
|
+
trackEvent: (eventType: string, eventCategory: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
166
|
+
trackPageView: (pageName?: string) => Promise<void>;
|
|
167
|
+
getGlobalSummary: (filter?: DateFilter) => Promise<GlobalAnalyticsSummary | null>;
|
|
168
|
+
getGlobalOrgs: (filter?: DateFilter) => Promise<OrgAnalytics[]>;
|
|
169
|
+
summary: AnalyticsSummary | null;
|
|
170
|
+
chats: ChatAnalytics[];
|
|
171
|
+
agents: AgentAnalytics[];
|
|
172
|
+
usage: UsageAnalytics[];
|
|
173
|
+
daily: DailyAnalytics[];
|
|
174
|
+
events: AnalyticsEvent[];
|
|
175
|
+
loading: boolean;
|
|
176
|
+
error: string | null;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Hook to use analytics context (for event tracking throughout the app)
|
|
180
|
+
*
|
|
181
|
+
* This is an alias for useProductAnalytics that makes the intent clearer
|
|
182
|
+
* when used primarily for event tracking.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* const { trackEvent } = useAnalyticsContext(options);
|
|
187
|
+
* trackEvent("form_submit", "ui", { formId: "contact" });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
declare const useAnalyticsContext: typeof useProductAnalytics;
|
|
191
|
+
|
|
192
|
+
type UseOrgProvisioningOptions = ApiClientOptions;
|
|
193
|
+
interface ProvisioningState {
|
|
194
|
+
status: "idle" | "creating" | "provisioning" | "completed" | "failed" | "partial";
|
|
195
|
+
progress: ProvisioningProgress | null;
|
|
196
|
+
org: Org | null;
|
|
197
|
+
error: string | null;
|
|
198
|
+
percentage: number;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Hook for organization provisioning with real-time progress
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```tsx
|
|
205
|
+
* const {
|
|
206
|
+
* state,
|
|
207
|
+
* createOrgWithProvisioning,
|
|
208
|
+
* retryProvisioning,
|
|
209
|
+
* cancelProvisioning,
|
|
210
|
+
* } = useOrgProvisioning({
|
|
211
|
+
* baseUrl: apiGatewayUrl,
|
|
212
|
+
* orgId: selectedOrgId,
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* // Create org and track progress
|
|
216
|
+
* await createOrgWithProvisioning({
|
|
217
|
+
* title: "Acme Corp",
|
|
218
|
+
* product: "eloquent",
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* // state.progress will update in real-time
|
|
222
|
+
* console.log(state.percentage); // 0-100
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare function useOrgProvisioning(options: UseOrgProvisioningOptions): {
|
|
226
|
+
state: ProvisioningState;
|
|
227
|
+
createOrgWithProvisioning: (request: CreateOrgRequest) => Promise<Org | null>;
|
|
228
|
+
getProvisioningStatus: (orgId: string) => Promise<ProvisioningProgress | null>;
|
|
229
|
+
retryProvisioning: (orgId: string, artifacts?: OrgArtifactTypeTS[]) => Promise<boolean>;
|
|
230
|
+
validateProvisioning: (orgId: string) => Promise<ValidationResult | null>;
|
|
231
|
+
cancelProvisioning: (orgId: string) => Promise<boolean>;
|
|
232
|
+
cleanupOrg: (orgId: string) => Promise<boolean>;
|
|
233
|
+
reset: () => void;
|
|
234
|
+
isComplete: boolean;
|
|
235
|
+
isFailed: boolean;
|
|
236
|
+
isPartial: boolean;
|
|
237
|
+
isProvisioning: boolean;
|
|
238
|
+
failedArtifacts: {
|
|
239
|
+
type: OrgArtifactTypeTS;
|
|
240
|
+
status: string;
|
|
241
|
+
critical: boolean;
|
|
242
|
+
error?: string;
|
|
243
|
+
duration?: number;
|
|
244
|
+
estimatedDuration?: number;
|
|
245
|
+
}[];
|
|
246
|
+
hasCriticalFailures: boolean;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export { type ProductAnalyticsState, type ProvisioningState, type UseInvitesAdminOptions, type UseOrgAdminOptions, type UseOrgProvisioningOptions, type UseOrgSettingsOptions, type UseProductAnalyticsOptions, type UseUsersAdminOptions, useAnalyticsContext, useInvitesAdmin, useOrgAdmin, useOrgProvisioning, useOrgSettings, useProductAnalytics, useUsersAdmin };
|