@elqnt/admin 2.1.0 → 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.
@@ -1,5 +1,6 @@
1
1
  import { ApiClientOptions } from '@elqnt/api-client';
2
- import { ab as Org, ac as OrgInfo, bj as User, bo as UserSettingsResponse, bn as UserSettings, Z as NotificationPreferences, I as Invite, F as InviteInput, R as InvitesResult } from '../admin-Dlsd5IZ0.js';
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';
3
4
  import { OrgSettings } from '@elqnt/agents/models';
4
5
  import '@elqnt/types';
5
6
 
@@ -23,10 +24,11 @@ type UseOrgAdminOptions = ApiClientOptions;
23
24
  declare function useOrgAdmin(options: UseOrgAdminOptions): {
24
25
  loading: boolean;
25
26
  error: string | null;
26
- listOrgs: () => Promise<Org[]>;
27
+ listOrgs: (filter?: ListOrgsFilter) => Promise<Org[]>;
27
28
  getOrg: (orgId: string) => Promise<Org | null>;
28
29
  getOrgInfo: (orgId: string) => Promise<OrgInfo | null>;
29
30
  createOrg: (org: Partial<Org>) => Promise<Org | null>;
31
+ createOrgWithSchemas: (org: Partial<Org>, schemas: OrgSchemaTypeTS[]) => Promise<CreateOrgWithSchemasResponse | null>;
30
32
  updateOrg: (orgId: string, updates: Partial<Org>) => Promise<Org | null>;
31
33
  deleteOrg: (orgId: string) => Promise<boolean>;
32
34
  };
@@ -54,6 +56,7 @@ declare function useUsersAdmin(options: UseUsersAdminOptions): {
54
56
  listUsers: () => Promise<User[]>;
55
57
  getUser: (userId: string) => Promise<User | null>;
56
58
  getUserByEmail: (email: string) => Promise<User | null>;
59
+ getUserByPhone: (phone: string) => Promise<User | null>;
57
60
  createUser: (user: Partial<User>) => Promise<User | null>;
58
61
  updateUser: (userId: string, updates: Partial<User>) => Promise<User | null>;
59
62
  deleteUser: (userId: string) => Promise<boolean>;
@@ -116,4 +119,131 @@ declare function useOrgSettings(options: UseOrgSettingsOptions): {
116
119
  updateSettings: (settings: Partial<OrgSettings>) => Promise<OrgSettings | null>;
117
120
  };
118
121
 
119
- export { type UseInvitesAdminOptions, type UseOrgAdminOptions, type UseOrgSettingsOptions, type UseUsersAdminOptions, useInvitesAdmin, useOrgAdmin, useOrgSettings, useUsersAdmin };
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 };