@vezlo/assistant-chat 1.4.0 → 1.6.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/PACKAGE_README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  A React component library for integrating AI assistant chat functionality into web applications with realtime updates and human agent support.
6
6
 
7
+ **📋 [Changelog](https://github.com/vezlo/assistant-chat/blob/main/CHANGELOG.md)** | **🐛 [Report Issue](https://github.com/vezlo/assistant-chat/issues)**
8
+
7
9
  > **📦 This is the NPM package documentation**
8
10
  > **🏠 Repository**: [assistant-chat](https://github.com/vezlo/assistant-chat) - Contains both this NPM package and a standalone admin application
9
11
  > **🖥️ Standalone App**: Want to run the admin dashboard? Visit the [main repository](https://github.com/vezlo/assistant-chat) for setup instructions
package/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  A complete chat widget solution with both a React component library and standalone admin application for AI-powered customer support.
6
6
 
7
+ **📋 [Changelog](./CHANGELOG.md)** | **🐛 [Report Issue](https://github.com/vezlo/assistant-chat/issues)**
8
+
7
9
  ## What's Included
8
10
 
9
11
  ### 📦 NPM Package
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Analytics API Service
3
+ * Handles fetching company analytics data
4
+ */
5
+ export interface CompanyAnalyticsResponse {
6
+ conversations: {
7
+ total: number;
8
+ open: number;
9
+ closed: number;
10
+ };
11
+ users: {
12
+ total_active_users: number;
13
+ };
14
+ messages: {
15
+ total: number;
16
+ user_messages_total: number;
17
+ assistant_messages_total: number;
18
+ agent_messages_total: number;
19
+ };
20
+ feedback: {
21
+ total: number;
22
+ likes: number;
23
+ dislikes: number;
24
+ };
25
+ }
26
+ export declare function getCompanyAnalytics(token: string, apiUrl?: string): Promise<CompanyAnalyticsResponse>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Analytics API Service
3
+ * Handles fetching company analytics data
4
+ */
5
+ const DEFAULT_API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
6
+ const parseErrorMessage = async (response) => {
7
+ const data = await response.json().catch(() => ({}));
8
+ return (data.error ||
9
+ data.message ||
10
+ 'Unexpected server error');
11
+ };
12
+ export async function getCompanyAnalytics(token, apiUrl) {
13
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
14
+ const response = await fetch(`${API_BASE_URL}/api/company/analytics`, {
15
+ method: 'GET',
16
+ headers: {
17
+ Accept: 'application/json',
18
+ Authorization: `Bearer ${token}`,
19
+ },
20
+ });
21
+ if (!response.ok) {
22
+ const message = await parseErrorMessage(response);
23
+ throw new Error(message);
24
+ }
25
+ return (await response.json());
26
+ }
@@ -21,6 +21,7 @@ export interface ConversationListItem {
21
21
  last_message_at: string | null;
22
22
  joined_at: string | null;
23
23
  closed_at: string | null;
24
+ archived_at: string | null;
24
25
  created_at: string;
25
26
  updated_at: string;
26
27
  }
@@ -64,7 +65,7 @@ export declare function getConversation(uuid: string, apiUrl?: string): Promise<
64
65
  /**
65
66
  * Get paginated conversations for agent UI
66
67
  */
67
- export declare function getConversations(token: string, page?: number, pageSize?: number, orderBy?: string, apiUrl?: string): Promise<ConversationListResponse>;
68
+ export declare function getConversations(token: string, page?: number, pageSize?: number, orderBy?: string, apiUrl?: string, status?: 'active' | 'archived'): Promise<ConversationListResponse>;
68
69
  /**
69
70
  * Get messages within a conversation
70
71
  */
@@ -77,6 +78,13 @@ export declare function joinConversation(token: string, conversationUuid: string
77
78
  * Close a conversation as an agent
78
79
  */
79
80
  export declare function closeConversation(token: string, conversationUuid: string, apiUrl?: string): Promise<JoinConversationResponse>;
81
+ /**
82
+ * Archive a conversation as an agent
83
+ */
84
+ export declare function archiveConversation(token: string, conversationUuid: string, apiUrl?: string): Promise<{
85
+ success: boolean;
86
+ archived_at: string;
87
+ }>;
80
88
  /**
81
89
  * Send agent-authored message
82
90
  */
@@ -61,9 +61,10 @@ export async function getConversation(uuid, apiUrl) {
61
61
  /**
62
62
  * Get paginated conversations for agent UI
63
63
  */
64
- export async function getConversations(token, page = 1, pageSize = 20, orderBy = 'last_message_at', apiUrl) {
64
+ export async function getConversations(token, page = 1, pageSize = 20, orderBy = 'last_message_at', apiUrl, status) {
65
65
  const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
66
- const response = await fetch(`${API_BASE_URL}/api/conversations?page=${page}&page_size=${pageSize}&order_by=${orderBy}`, {
66
+ const statusParam = status ? `&status=${status}` : '';
67
+ const response = await fetch(`${API_BASE_URL}/api/conversations?page=${page}&page_size=${pageSize}&order_by=${orderBy}${statusParam}`, {
67
68
  method: 'GET',
68
69
  headers: {
69
70
  Accept: 'application/json',
@@ -130,6 +131,24 @@ export async function closeConversation(token, conversationUuid, apiUrl) {
130
131
  }
131
132
  return (await response.json());
132
133
  }
134
+ /**
135
+ * Archive a conversation as an agent
136
+ */
137
+ export async function archiveConversation(token, conversationUuid, apiUrl) {
138
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
139
+ const response = await fetch(`${API_BASE_URL}/api/conversations/${conversationUuid}/archive`, {
140
+ method: 'POST',
141
+ headers: {
142
+ Accept: 'application/json',
143
+ Authorization: `Bearer ${token}`,
144
+ },
145
+ });
146
+ if (!response.ok) {
147
+ const message = await parseErrorMessage(response);
148
+ throw new Error(message);
149
+ }
150
+ return (await response.json());
151
+ }
133
152
  /**
134
153
  * Send agent-authored message
135
154
  */
@@ -5,3 +5,4 @@
5
5
  export * from './auth.js';
6
6
  export * from './conversation.js';
7
7
  export * from './message.js';
8
+ export * from './analytics.js';
package/lib/api/index.js CHANGED
@@ -5,3 +5,4 @@
5
5
  export * from './auth.js';
6
6
  export * from './conversation.js';
7
7
  export * from './message.js';
8
+ export * from './analytics.js';
@@ -13,6 +13,7 @@ export interface MessageCreatedPayload {
13
13
  joined_at?: string;
14
14
  status?: string;
15
15
  closed_at?: string;
16
+ archived_at?: string;
16
17
  };
17
18
  }
18
19
  export interface ConversationCreatedPayload {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vezlo/assistant-chat",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "React component library for AI-powered chat widgets with RAG knowledge base integration, realtime updates, and human agent support",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",