@chatwillow/widget 0.0.4 → 0.0.6
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 +39 -64
- package/dist/chatwillow-widget.es.js +13063 -2572
- package/dist/chatwillow-widget.umd.js +42 -15
- package/dist/index.d.ts +13 -0
- package/dist/lib/apiClient.d.ts +51 -0
- package/dist/modules/ChatWidget/service/chatWidget.service.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
import { IChatWidgetProps } from './modules/ChatWidget/ChatWidget';
|
|
1
2
|
export { default as ChatWillowWidget } from './App';
|
|
2
3
|
export type { IChatWidgetProps } from './modules/ChatWidget/ChatWidget';
|
|
4
|
+
export declare const init: (config: IChatWidgetProps & {
|
|
5
|
+
containerId?: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
ChatWillow: {
|
|
10
|
+
init: (config: IChatWidgetProps & {
|
|
11
|
+
containerId?: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
import { ErrorInfo } from 'react';
|
|
3
|
+
export interface AppError extends Error {
|
|
4
|
+
code?: string;
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
details?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare class GlobalErrorHandler {
|
|
9
|
+
static handleError: (error: Error, errorInfo?: ErrorInfo) => void;
|
|
10
|
+
static handleApiError: (error: AxiosError) => AppError;
|
|
11
|
+
private static getErrorMessage;
|
|
12
|
+
static isNetworkError: (error: AppError) => boolean;
|
|
13
|
+
static isValidationError: (error: AppError) => boolean;
|
|
14
|
+
static isAuthError: (error: AppError) => boolean;
|
|
15
|
+
static isRateLimitError: (error: AppError) => boolean;
|
|
16
|
+
}
|
|
17
|
+
declare module "axios" {
|
|
18
|
+
interface InternalAxiosRequestConfig {
|
|
19
|
+
metadata?: {
|
|
20
|
+
startTime: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export interface ApiConfig {
|
|
25
|
+
baseURL: string;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
retries?: number;
|
|
28
|
+
retryDelay?: number;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export declare class ApiClient {
|
|
32
|
+
private axios;
|
|
33
|
+
private retries;
|
|
34
|
+
private retryDelay;
|
|
35
|
+
constructor(config: ApiConfig);
|
|
36
|
+
private setupInterceptors;
|
|
37
|
+
private shouldRetry;
|
|
38
|
+
private retryRequest;
|
|
39
|
+
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
40
|
+
getRaw<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
41
|
+
post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
42
|
+
put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
43
|
+
patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
44
|
+
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
45
|
+
uploadFile<T>(url: string, file: File, onUploadProgress?: (progressEvent: any) => void): Promise<T>;
|
|
46
|
+
setAuthHeader(token: string): void;
|
|
47
|
+
removeAuthHeader(): void;
|
|
48
|
+
setCustomHeader(key: string, value: string): void;
|
|
49
|
+
removeCustomHeader(key: string): void;
|
|
50
|
+
setBaseURL(url: string): void;
|
|
51
|
+
}
|
|
@@ -3,7 +3,8 @@ export declare const queryKeyEnumType: {
|
|
|
3
3
|
readonly CHAT_MESSAGES: "chatMessages";
|
|
4
4
|
};
|
|
5
5
|
declare class ChatWidgetService {
|
|
6
|
-
private readonly
|
|
6
|
+
private readonly apiClient;
|
|
7
|
+
constructor();
|
|
7
8
|
sendMessage(message: string): Promise<ISendMessageResponse>;
|
|
8
9
|
}
|
|
9
10
|
export declare const chatWidgetService: ChatWidgetService;
|