@aslaluroba/help-center-react 3.0.21 → 3.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/dist/components/ui/image-attachment.d.ts +9 -0
- package/dist/components/ui/image-preview-dialog.d.ts +10 -0
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/core/api.d.ts +3 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.js +4964 -600
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4964 -600
- package/dist/index.js.map +1 -1
- package/dist/lib/types.d.ts +23 -0
- package/dist/services.esm.js +41 -35
- package/dist/services.esm.js.map +1 -1
- package/dist/services.js +41 -35
- package/dist/services.js.map +1 -1
- package/dist/ui/chatbot-popup/chat-window-screen/footer.d.ts +3 -2
- package/dist/ui/chatbot-popup/chat-window-screen/index.d.ts +3 -2
- package/dist/ui/help-center.d.ts +1 -1
- package/dist/ui/help-popup.d.ts +3 -2
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/assets/icons/paperclip.svg +3 -0
- package/src/assets/icons/x.svg +4 -0
- package/src/components/ui/image-attachment.tsx +107 -0
- package/src/components/ui/image-preview-dialog.tsx +354 -0
- package/src/components/ui/index.ts +4 -0
- package/src/core/AblyService.ts +2 -2
- package/src/core/ApiService.ts +0 -2
- package/src/core/api.ts +106 -58
- package/src/lib/types.ts +110 -84
- package/src/ui/chatbot-popup/chat-window-screen/footer.tsx +259 -22
- package/src/ui/chatbot-popup/chat-window-screen/index.tsx +206 -101
- package/src/ui/help-center.tsx +88 -92
- package/src/ui/help-popup.tsx +11 -9
- package/src/ui/powered-by.tsx +10 -9
package/dist/lib/types.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface Message {
|
|
|
24
24
|
messageContent: string;
|
|
25
25
|
sentAt: Date;
|
|
26
26
|
isSeen: boolean;
|
|
27
|
+
attachmentIds?: string[];
|
|
27
28
|
}
|
|
28
29
|
export interface ChatSession {
|
|
29
30
|
id: string;
|
|
@@ -116,3 +117,25 @@ export interface ReviewProps {
|
|
|
116
117
|
comment: string;
|
|
117
118
|
rating: number;
|
|
118
119
|
}
|
|
120
|
+
export interface PresignUploadRequestDto {
|
|
121
|
+
name: string;
|
|
122
|
+
contentType: string;
|
|
123
|
+
sizeBytes: number;
|
|
124
|
+
pathData: {
|
|
125
|
+
type: number;
|
|
126
|
+
chatSessionId: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface PresignUploadResponse {
|
|
130
|
+
id: string;
|
|
131
|
+
uploadUrl: string;
|
|
132
|
+
path: string;
|
|
133
|
+
expiresAt: string;
|
|
134
|
+
}
|
|
135
|
+
export interface PresignDownloadResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
downloadUrl: string;
|
|
139
|
+
contentType: string;
|
|
140
|
+
expiresAt: string;
|
|
141
|
+
}
|
package/dist/services.esm.js
CHANGED
|
@@ -3682,7 +3682,6 @@ class ApiService {
|
|
|
3682
3682
|
_this2.tokenExpiryTime = currentTime + response.expiresIn;
|
|
3683
3683
|
return _this2.currentToken;
|
|
3684
3684
|
} catch (error) {
|
|
3685
|
-
console.error('Error getting token:', error);
|
|
3686
3685
|
throw error;
|
|
3687
3686
|
}
|
|
3688
3687
|
}
|
|
@@ -3741,7 +3740,6 @@ class ApiService {
|
|
|
3741
3740
|
if (this.config.onError) {
|
|
3742
3741
|
this.config.onError(error instanceof Error ? error : new Error('Unknown error occurred'));
|
|
3743
3742
|
}
|
|
3744
|
-
console.error('API Error:', error);
|
|
3745
3743
|
}
|
|
3746
3744
|
}
|
|
3747
3745
|
|
|
@@ -13558,15 +13556,15 @@ class ClientAblyService {
|
|
|
13558
13556
|
_this2.channel = _this2.client.channels.get(roomName);
|
|
13559
13557
|
// Subscribe to assistant/system responses
|
|
13560
13558
|
_this2.channel.subscribe('ReceiveMessage', message => {
|
|
13561
|
-
var _a, _b, _c, _d;
|
|
13559
|
+
var _a, _b, _c, _d, _e;
|
|
13562
13560
|
try {
|
|
13563
13561
|
var messageContent = typeof message.data === 'string' ? message.data : ((_a = message.data) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.data) === null || _b === void 0 ? void 0 : _b.message);
|
|
13564
13562
|
var senderType = ((_c = message.data) === null || _c === void 0 ? void 0 : _c.senderType) || 3; // Assistant
|
|
13565
13563
|
var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || false;
|
|
13566
|
-
|
|
13564
|
+
var attachments = ((_e = message.data) === null || _e === void 0 ? void 0 : _e.attachments) || [];
|
|
13565
|
+
onMessageReceived(messageContent, senderType, needsAgent, attachments);
|
|
13567
13566
|
} catch (error) {
|
|
13568
13567
|
// Handle error silently
|
|
13569
|
-
console.error('[AblyService] Error processing ReceiveMessage:', error);
|
|
13570
13568
|
}
|
|
13571
13569
|
});
|
|
13572
13570
|
yield _this2.channel.attach();
|
|
@@ -13690,10 +13688,10 @@ function _getValidToken() {
|
|
|
13690
13688
|
var forceRefresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
13691
13689
|
var _a;
|
|
13692
13690
|
if (!getTokenFunction) {
|
|
13693
|
-
throw new Error(
|
|
13691
|
+
throw new Error('API module not initialized. Call initializeAPI(getToken) first.');
|
|
13694
13692
|
}
|
|
13695
|
-
var storedToken = localStorage.getItem(
|
|
13696
|
-
var storedExpiry = localStorage.getItem(
|
|
13693
|
+
var storedToken = localStorage.getItem('chatbot-token');
|
|
13694
|
+
var storedExpiry = localStorage.getItem('chatbot-token-expiry');
|
|
13697
13695
|
var currentTime = Math.floor(Date.now() / 1000);
|
|
13698
13696
|
// Add buffer time to prevent token expiry during request
|
|
13699
13697
|
var bufferTime = 60; // 1 minute buffer
|
|
@@ -13703,10 +13701,9 @@ function _getValidToken() {
|
|
|
13703
13701
|
var tokenResponse = yield getTokenFunction();
|
|
13704
13702
|
storedToken = tokenResponse.token;
|
|
13705
13703
|
storedExpiry = String(currentTime + ((_a = tokenResponse.expiresIn) !== null && _a !== void 0 ? _a : 900));
|
|
13706
|
-
localStorage.setItem(
|
|
13707
|
-
localStorage.setItem(
|
|
13704
|
+
localStorage.setItem('chatbot-token', storedToken);
|
|
13705
|
+
localStorage.setItem('chatbot-token-expiry', storedExpiry);
|
|
13708
13706
|
} catch (error) {
|
|
13709
|
-
console.error("Failed to refresh token:", error);
|
|
13710
13707
|
throw error;
|
|
13711
13708
|
}
|
|
13712
13709
|
}
|
|
@@ -13723,11 +13720,11 @@ function _fetchWithAuth() {
|
|
|
13723
13720
|
var headers = new Headers(options.headers);
|
|
13724
13721
|
try {
|
|
13725
13722
|
var token = yield getValidToken();
|
|
13726
|
-
headers.set(
|
|
13723
|
+
headers.set('Authorization', "Bearer ".concat(token));
|
|
13727
13724
|
// Add performance optimizations
|
|
13728
|
-
headers.set(
|
|
13729
|
-
headers.set(
|
|
13730
|
-
headers.set(
|
|
13725
|
+
headers.set('Accept', 'application/json');
|
|
13726
|
+
headers.set('Accept-Encoding', 'gzip, deflate, br');
|
|
13727
|
+
headers.set('Connection', 'keep-alive');
|
|
13731
13728
|
options.headers = headers;
|
|
13732
13729
|
// Add timeout to prevent hanging requests
|
|
13733
13730
|
var controller = new AbortController();
|
|
@@ -13736,15 +13733,14 @@ function _fetchWithAuth() {
|
|
|
13736
13733
|
var response = yield fetch(url, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
13737
13734
|
signal: controller.signal,
|
|
13738
13735
|
// Add HTTP/2 optimization hints
|
|
13739
|
-
cache:
|
|
13740
|
-
mode:
|
|
13736
|
+
cache: 'no-cache',
|
|
13737
|
+
mode: 'cors'
|
|
13741
13738
|
}));
|
|
13742
13739
|
clearTimeout(timeoutId);
|
|
13743
13740
|
// Handle 401/403 with token refresh
|
|
13744
13741
|
if ((response.status === 401 || response.status === 403) && retry) {
|
|
13745
|
-
console.warn("Token expired, refreshing...");
|
|
13746
13742
|
var newToken = yield getValidToken(true);
|
|
13747
|
-
headers.set(
|
|
13743
|
+
headers.set('Authorization', "Bearer ".concat(newToken));
|
|
13748
13744
|
options.headers = headers;
|
|
13749
13745
|
// Retry the request with new token
|
|
13750
13746
|
return fetchWithAuth(url, options, false);
|
|
@@ -13752,13 +13748,12 @@ function _fetchWithAuth() {
|
|
|
13752
13748
|
return response;
|
|
13753
13749
|
} catch (error) {
|
|
13754
13750
|
clearTimeout(timeoutId);
|
|
13755
|
-
if (error instanceof Error && error.name ===
|
|
13756
|
-
throw new Error(
|
|
13751
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
13752
|
+
throw new Error('Request timeout - please try again');
|
|
13757
13753
|
}
|
|
13758
13754
|
throw error;
|
|
13759
13755
|
}
|
|
13760
13756
|
} catch (error) {
|
|
13761
|
-
console.error("Fetch error:", error);
|
|
13762
13757
|
throw error;
|
|
13763
13758
|
}
|
|
13764
13759
|
});
|
|
@@ -13798,10 +13793,10 @@ function apiRequest(_x3) {
|
|
|
13798
13793
|
}
|
|
13799
13794
|
function _apiRequest() {
|
|
13800
13795
|
_apiRequest = _asyncToGenerator(function* (endpoint) {
|
|
13801
|
-
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
13796
|
+
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET';
|
|
13802
13797
|
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
13803
13798
|
var options = arguments.length > 3 ? arguments[3] : undefined;
|
|
13804
|
-
if (!baseUrl) throw new Error(
|
|
13799
|
+
if (!baseUrl) throw new Error('API not initialized');
|
|
13805
13800
|
var url = "".concat(baseUrl, "/").concat(endpoint);
|
|
13806
13801
|
var requestKey = "".concat(method, ":").concat(endpoint, ":").concat(JSON.stringify(body));
|
|
13807
13802
|
// Check for duplicate in-flight requests
|
|
@@ -13810,7 +13805,7 @@ function _apiRequest() {
|
|
|
13810
13805
|
return duplicateRequest;
|
|
13811
13806
|
}
|
|
13812
13807
|
// Check cache for GET requests (except real-time endpoints)
|
|
13813
|
-
if (method ===
|
|
13808
|
+
if (method === 'GET' && options.cache !== false && !endpoint.includes('/send-message')) {
|
|
13814
13809
|
var cached = getCachedResponse(requestKey);
|
|
13815
13810
|
if (cached) {
|
|
13816
13811
|
return Promise.resolve(cached);
|
|
@@ -13819,9 +13814,9 @@ function _apiRequest() {
|
|
|
13819
13814
|
var requestOptions = {
|
|
13820
13815
|
method,
|
|
13821
13816
|
headers: {
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13817
|
+
'Content-Type': 'application/json',
|
|
13818
|
+
'Cache-Control': method === 'GET' ? 'max-age=30' : 'no-cache',
|
|
13819
|
+
'Accept-Language': options.language
|
|
13825
13820
|
},
|
|
13826
13821
|
body: body ? JSON.stringify(body) : null
|
|
13827
13822
|
};
|
|
@@ -13829,26 +13824,37 @@ function _apiRequest() {
|
|
|
13829
13824
|
try {
|
|
13830
13825
|
var response = yield fetchWithAuth(url, requestOptions);
|
|
13831
13826
|
if (!response.ok) {
|
|
13832
|
-
var errorMessage =
|
|
13827
|
+
var errorMessage = 'API request failed';
|
|
13833
13828
|
try {
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
errorMessage =
|
|
13829
|
+
// Clone response before reading to avoid consuming the body
|
|
13830
|
+
var errorResponse = response.clone();
|
|
13831
|
+
var errorData = yield errorResponse.json();
|
|
13832
|
+
errorMessage = errorData.message || errorData.error || errorMessage;
|
|
13833
|
+
} catch (parseError) {
|
|
13834
|
+
// If JSON parsing fails, try to get text
|
|
13835
|
+
try {
|
|
13836
|
+
var _errorResponse = response.clone();
|
|
13837
|
+
var errorText = yield _errorResponse.text();
|
|
13838
|
+
errorMessage = errorText || "HTTP ".concat(response.status, ": ").concat(response.statusText);
|
|
13839
|
+
} catch (_a) {
|
|
13840
|
+
errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
|
|
13841
|
+
}
|
|
13838
13842
|
}
|
|
13839
13843
|
throw new Error(errorMessage);
|
|
13840
13844
|
}
|
|
13841
13845
|
// Cache successful GET responses
|
|
13842
|
-
|
|
13846
|
+
// Note: We clone before caching to avoid consuming the original response body
|
|
13847
|
+
if (method === 'GET' && options.cache !== false) {
|
|
13843
13848
|
var responseData = response.clone();
|
|
13844
13849
|
var data = yield responseData.json();
|
|
13845
13850
|
setCachedResponse(requestKey, {
|
|
13846
13851
|
json: () => Promise.resolve(data)
|
|
13847
13852
|
});
|
|
13848
13853
|
}
|
|
13854
|
+
// Return the original response - it's body hasn't been consumed yet
|
|
13855
|
+
// (we only cloned for caching, and the clone was consumed)
|
|
13849
13856
|
return response;
|
|
13850
13857
|
} catch (error) {
|
|
13851
|
-
console.error("API request failed for ".concat(endpoint, ":"), error);
|
|
13852
13858
|
throw error;
|
|
13853
13859
|
}
|
|
13854
13860
|
})();
|