@aslaluroba/help-center-react 3.0.20 → 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.
@@ -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
+ }
@@ -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
- onMessageReceived(messageContent, senderType, needsAgent);
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();
@@ -13706,7 +13704,6 @@ function _getValidToken() {
13706
13704
  localStorage.setItem('chatbot-token', storedToken);
13707
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
  }
@@ -13742,7 +13739,6 @@ function _fetchWithAuth() {
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
13743
  headers.set('Authorization', "Bearer ".concat(newToken));
13748
13744
  options.headers = headers;
@@ -13758,7 +13754,6 @@ function _fetchWithAuth() {
13758
13754
  throw error;
13759
13755
  }
13760
13756
  } catch (error) {
13761
- console.error('Fetch error:', error);
13762
13757
  throw error;
13763
13758
  }
13764
13759
  });
@@ -13800,7 +13795,7 @@ function _apiRequest() {
13800
13795
  _apiRequest = _asyncToGenerator(function* (endpoint) {
13801
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
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
13798
+ var options = arguments.length > 3 ? arguments[3] : undefined;
13804
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));
@@ -13820,7 +13815,8 @@ function _apiRequest() {
13820
13815
  method,
13821
13816
  headers: {
13822
13817
  'Content-Type': 'application/json',
13823
- 'Cache-Control': method === 'GET' ? 'max-age=30' : 'no-cache'
13818
+ 'Cache-Control': method === 'GET' ? 'max-age=30' : 'no-cache',
13819
+ 'Accept-Language': options.language
13824
13820
  },
13825
13821
  body: body ? JSON.stringify(body) : null
13826
13822
  };
@@ -13830,24 +13826,35 @@ function _apiRequest() {
13830
13826
  if (!response.ok) {
13831
13827
  var errorMessage = 'API request failed';
13832
13828
  try {
13833
- var errorData = yield response.json();
13834
- errorMessage = errorData.message || errorMessage;
13835
- } catch (_a) {
13836
- errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
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
+ }
13837
13842
  }
13838
13843
  throw new Error(errorMessage);
13839
13844
  }
13840
13845
  // Cache successful GET responses
13846
+ // Note: We clone before caching to avoid consuming the original response body
13841
13847
  if (method === 'GET' && options.cache !== false) {
13842
- var responseData = yield response.clone();
13848
+ var responseData = response.clone();
13843
13849
  var data = yield responseData.json();
13844
13850
  setCachedResponse(requestKey, {
13845
13851
  json: () => Promise.resolve(data)
13846
13852
  });
13847
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)
13848
13856
  return response;
13849
13857
  } catch (error) {
13850
- console.error("API request failed for ".concat(endpoint, ":"), error);
13851
13858
  throw error;
13852
13859
  }
13853
13860
  })();