@getlupa/client 1.3.5 → 1.3.7

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.
@@ -20706,6 +20706,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20706
20706
  method: "POST",
20707
20707
  headers: { "Content-Type": "application/json" }
20708
20708
  };
20709
+ const headers = defaultConfig.headers;
20709
20710
  const getApiUrl = (environment, customBaseUrl) => {
20710
20711
  if (customBaseUrl) {
20711
20712
  return customBaseUrl;
@@ -20713,58 +20714,84 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20713
20714
  return Env[environment] || Env["production"];
20714
20715
  };
20715
20716
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20717
+ var _a, _b;
20716
20718
  const { environment, customBaseUrl } = options;
20717
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20718
- body: JSON.stringify(request)
20719
- }));
20720
- if (res.status < 400) {
20721
- const data = yield res.json();
20722
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20719
+ try {
20720
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20721
+ body: JSON.stringify(request),
20722
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20723
+ }));
20724
+ if (res.status < 400) {
20725
+ const data = yield res.json();
20726
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20727
+ }
20728
+ const errors = yield res.json();
20729
+ return { success: false, errors };
20730
+ } catch (e) {
20731
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20732
+ return { success: false, errors: [e] };
20723
20733
  }
20724
- const errors = yield res.json();
20725
- return { success: false, errors };
20726
20734
  });
20727
20735
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20736
+ var _a, _b;
20728
20737
  const { environment, customBaseUrl } = options;
20729
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20730
- body: JSON.stringify({ phrases })
20731
- }));
20732
- if (res.status < 400) {
20733
- const data = yield res.json();
20734
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20738
+ try {
20739
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20740
+ body: JSON.stringify({ phrases }),
20741
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20742
+ }));
20743
+ if (res.status < 400) {
20744
+ const data = yield res.json();
20745
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20746
+ }
20747
+ const errors = yield res.json();
20748
+ return { success: false, errors };
20749
+ } catch (e) {
20750
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20751
+ return { success: false, errors: [e] };
20735
20752
  }
20736
- const errors = yield res.json();
20737
- return { success: false, errors };
20738
20753
  });
20739
20754
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20755
+ var _a, _b;
20740
20756
  const { environment, customBaseUrl } = options;
20741
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20742
- body: JSON.stringify({ phrases })
20743
- }));
20744
- if (res.status < 400) {
20745
- const data = yield res.json();
20746
- console.log(data);
20747
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20757
+ try {
20758
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20759
+ body: JSON.stringify({ phrases }),
20760
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20761
+ }));
20762
+ if (res.status < 400) {
20763
+ const data = yield res.json();
20764
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20765
+ }
20766
+ const errors = yield res.json();
20767
+ return { success: false, errors };
20768
+ } catch (e) {
20769
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20770
+ return { success: false, errors: [e] };
20748
20771
  }
20749
- const errors = yield res.json();
20750
- return { success: false, errors };
20751
20772
  });
20752
20773
  const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20753
20774
  initialQuery,
20754
20775
  productStrings,
20755
20776
  messageHistory
20756
20777
  }) {
20778
+ var _a, _b;
20757
20779
  const { environment, customBaseUrl } = options;
20758
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20759
- body: JSON.stringify({ initialQuery, messageHistory, productStrings })
20760
- }));
20761
- if (res.status < 400) {
20762
- const data = yield res.json();
20763
- console.log(data);
20764
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20780
+ try {
20781
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20782
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20783
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20784
+ }));
20785
+ if (res.status < 400) {
20786
+ const data = yield res.json();
20787
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20788
+ }
20789
+ const errors = yield res.json();
20790
+ return { success: false, errors };
20791
+ } catch (e) {
20792
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20793
+ return { success: false, errors: [e] };
20765
20794
  }
20766
- const errors = yield res.json();
20767
- return { success: false, errors };
20768
20795
  });
20769
20796
  const prepareChatHistory = (chatLog) => {
20770
20797
  var _a, _b;
@@ -20706,6 +20706,7 @@ const defaultConfig = {
20706
20706
  method: "POST",
20707
20707
  headers: { "Content-Type": "application/json" }
20708
20708
  };
20709
+ const headers = defaultConfig.headers;
20709
20710
  const getApiUrl = (environment, customBaseUrl) => {
20710
20711
  if (customBaseUrl) {
20711
20712
  return customBaseUrl;
@@ -20713,58 +20714,84 @@ const getApiUrl = (environment, customBaseUrl) => {
20713
20714
  return Env[environment] || Env["production"];
20714
20715
  };
20715
20716
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20717
+ var _a, _b;
20716
20718
  const { environment, customBaseUrl } = options;
20717
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20718
- body: JSON.stringify(request)
20719
- }));
20720
- if (res.status < 400) {
20721
- const data = yield res.json();
20722
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20719
+ try {
20720
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20721
+ body: JSON.stringify(request),
20722
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20723
+ }));
20724
+ if (res.status < 400) {
20725
+ const data = yield res.json();
20726
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20727
+ }
20728
+ const errors = yield res.json();
20729
+ return { success: false, errors };
20730
+ } catch (e) {
20731
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20732
+ return { success: false, errors: [e] };
20723
20733
  }
20724
- const errors = yield res.json();
20725
- return { success: false, errors };
20726
20734
  });
20727
20735
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20736
+ var _a, _b;
20728
20737
  const { environment, customBaseUrl } = options;
20729
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20730
- body: JSON.stringify({ phrases })
20731
- }));
20732
- if (res.status < 400) {
20733
- const data = yield res.json();
20734
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20738
+ try {
20739
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20740
+ body: JSON.stringify({ phrases }),
20741
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20742
+ }));
20743
+ if (res.status < 400) {
20744
+ const data = yield res.json();
20745
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20746
+ }
20747
+ const errors = yield res.json();
20748
+ return { success: false, errors };
20749
+ } catch (e) {
20750
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20751
+ return { success: false, errors: [e] };
20735
20752
  }
20736
- const errors = yield res.json();
20737
- return { success: false, errors };
20738
20753
  });
20739
20754
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20755
+ var _a, _b;
20740
20756
  const { environment, customBaseUrl } = options;
20741
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20742
- body: JSON.stringify({ phrases })
20743
- }));
20744
- if (res.status < 400) {
20745
- const data = yield res.json();
20746
- console.log(data);
20747
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20757
+ try {
20758
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20759
+ body: JSON.stringify({ phrases }),
20760
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20761
+ }));
20762
+ if (res.status < 400) {
20763
+ const data = yield res.json();
20764
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20765
+ }
20766
+ const errors = yield res.json();
20767
+ return { success: false, errors };
20768
+ } catch (e) {
20769
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20770
+ return { success: false, errors: [e] };
20748
20771
  }
20749
- const errors = yield res.json();
20750
- return { success: false, errors };
20751
20772
  });
20752
20773
  const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20753
20774
  initialQuery,
20754
20775
  productStrings,
20755
20776
  messageHistory
20756
20777
  }) {
20778
+ var _a, _b;
20757
20779
  const { environment, customBaseUrl } = options;
20758
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20759
- body: JSON.stringify({ initialQuery, messageHistory, productStrings })
20760
- }));
20761
- if (res.status < 400) {
20762
- const data = yield res.json();
20763
- console.log(data);
20764
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20780
+ try {
20781
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20782
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20783
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20784
+ }));
20785
+ if (res.status < 400) {
20786
+ const data = yield res.json();
20787
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20788
+ }
20789
+ const errors = yield res.json();
20790
+ return { success: false, errors };
20791
+ } catch (e) {
20792
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20793
+ return { success: false, errors: [e] };
20765
20794
  }
20766
- const errors = yield res.json();
20767
- return { success: false, errors };
20768
20795
  });
20769
20796
  const prepareChatHistory = (chatLog) => {
20770
20797
  var _a, _b;
@@ -20704,6 +20704,7 @@ const defaultConfig = {
20704
20704
  method: "POST",
20705
20705
  headers: { "Content-Type": "application/json" }
20706
20706
  };
20707
+ const headers = defaultConfig.headers;
20707
20708
  const getApiUrl = (environment, customBaseUrl) => {
20708
20709
  if (customBaseUrl) {
20709
20710
  return customBaseUrl;
@@ -20711,58 +20712,84 @@ const getApiUrl = (environment, customBaseUrl) => {
20711
20712
  return Env[environment] || Env["production"];
20712
20713
  };
20713
20714
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20715
+ var _a, _b;
20714
20716
  const { environment, customBaseUrl } = options;
20715
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20716
- body: JSON.stringify(request)
20717
- }));
20718
- if (res.status < 400) {
20719
- const data = yield res.json();
20720
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20717
+ try {
20718
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20719
+ body: JSON.stringify(request),
20720
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20721
+ }));
20722
+ if (res.status < 400) {
20723
+ const data = yield res.json();
20724
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20725
+ }
20726
+ const errors = yield res.json();
20727
+ return { success: false, errors };
20728
+ } catch (e) {
20729
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20730
+ return { success: false, errors: [e] };
20721
20731
  }
20722
- const errors = yield res.json();
20723
- return { success: false, errors };
20724
20732
  });
20725
20733
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20734
+ var _a, _b;
20726
20735
  const { environment, customBaseUrl } = options;
20727
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20728
- body: JSON.stringify({ phrases })
20729
- }));
20730
- if (res.status < 400) {
20731
- const data = yield res.json();
20732
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20736
+ try {
20737
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20738
+ body: JSON.stringify({ phrases }),
20739
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20740
+ }));
20741
+ if (res.status < 400) {
20742
+ const data = yield res.json();
20743
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20744
+ }
20745
+ const errors = yield res.json();
20746
+ return { success: false, errors };
20747
+ } catch (e) {
20748
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20749
+ return { success: false, errors: [e] };
20733
20750
  }
20734
- const errors = yield res.json();
20735
- return { success: false, errors };
20736
20751
  });
20737
20752
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20753
+ var _a, _b;
20738
20754
  const { environment, customBaseUrl } = options;
20739
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20740
- body: JSON.stringify({ phrases })
20741
- }));
20742
- if (res.status < 400) {
20743
- const data = yield res.json();
20744
- console.log(data);
20745
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20755
+ try {
20756
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20757
+ body: JSON.stringify({ phrases }),
20758
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20759
+ }));
20760
+ if (res.status < 400) {
20761
+ const data = yield res.json();
20762
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20763
+ }
20764
+ const errors = yield res.json();
20765
+ return { success: false, errors };
20766
+ } catch (e) {
20767
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20768
+ return { success: false, errors: [e] };
20746
20769
  }
20747
- const errors = yield res.json();
20748
- return { success: false, errors };
20749
20770
  });
20750
20771
  const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20751
20772
  initialQuery,
20752
20773
  productStrings,
20753
20774
  messageHistory
20754
20775
  }) {
20776
+ var _a, _b;
20755
20777
  const { environment, customBaseUrl } = options;
20756
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20757
- body: JSON.stringify({ initialQuery, messageHistory, productStrings })
20758
- }));
20759
- if (res.status < 400) {
20760
- const data = yield res.json();
20761
- console.log(data);
20762
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20778
+ try {
20779
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20780
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20781
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20782
+ }));
20783
+ if (res.status < 400) {
20784
+ const data = yield res.json();
20785
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20786
+ }
20787
+ const errors = yield res.json();
20788
+ return { success: false, errors };
20789
+ } catch (e) {
20790
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20791
+ return { success: false, errors: [e] };
20763
20792
  }
20764
- const errors = yield res.json();
20765
- return { success: false, errors };
20766
20793
  });
20767
20794
  const prepareChatHistory = (chatLog) => {
20768
20795
  var _a, _b;
@@ -20708,6 +20708,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20708
20708
  method: "POST",
20709
20709
  headers: { "Content-Type": "application/json" }
20710
20710
  };
20711
+ const headers = defaultConfig.headers;
20711
20712
  const getApiUrl = (environment, customBaseUrl) => {
20712
20713
  if (customBaseUrl) {
20713
20714
  return customBaseUrl;
@@ -20715,58 +20716,84 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20715
20716
  return Env[environment] || Env["production"];
20716
20717
  };
20717
20718
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
20719
+ var _a, _b;
20718
20720
  const { environment, customBaseUrl } = options;
20719
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20720
- body: JSON.stringify(request)
20721
- }));
20722
- if (res.status < 400) {
20723
- const data = yield res.json();
20724
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20721
+ try {
20722
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20723
+ body: JSON.stringify(request),
20724
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20725
+ }));
20726
+ if (res.status < 400) {
20727
+ const data = yield res.json();
20728
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20729
+ }
20730
+ const errors = yield res.json();
20731
+ return { success: false, errors };
20732
+ } catch (e) {
20733
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20734
+ return { success: false, errors: [e] };
20725
20735
  }
20726
- const errors = yield res.json();
20727
- return { success: false, errors };
20728
20736
  });
20729
20737
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20738
+ var _a, _b;
20730
20739
  const { environment, customBaseUrl } = options;
20731
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20732
- body: JSON.stringify({ phrases })
20733
- }));
20734
- if (res.status < 400) {
20735
- const data = yield res.json();
20736
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20740
+ try {
20741
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20742
+ body: JSON.stringify({ phrases }),
20743
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20744
+ }));
20745
+ if (res.status < 400) {
20746
+ const data = yield res.json();
20747
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20748
+ }
20749
+ const errors = yield res.json();
20750
+ return { success: false, errors };
20751
+ } catch (e) {
20752
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20753
+ return { success: false, errors: [e] };
20737
20754
  }
20738
- const errors = yield res.json();
20739
- return { success: false, errors };
20740
20755
  });
20741
20756
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
20757
+ var _a, _b;
20742
20758
  const { environment, customBaseUrl } = options;
20743
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20744
- body: JSON.stringify({ phrases })
20745
- }));
20746
- if (res.status < 400) {
20747
- const data = yield res.json();
20748
- console.log(data);
20749
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20759
+ try {
20760
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20761
+ body: JSON.stringify({ phrases }),
20762
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20763
+ }));
20764
+ if (res.status < 400) {
20765
+ const data = yield res.json();
20766
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20767
+ }
20768
+ const errors = yield res.json();
20769
+ return { success: false, errors };
20770
+ } catch (e) {
20771
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20772
+ return { success: false, errors: [e] };
20750
20773
  }
20751
- const errors = yield res.json();
20752
- return { success: false, errors };
20753
20774
  });
20754
20775
  const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
20755
20776
  initialQuery,
20756
20777
  productStrings,
20757
20778
  messageHistory
20758
20779
  }) {
20780
+ var _a, _b;
20759
20781
  const { environment, customBaseUrl } = options;
20760
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20761
- body: JSON.stringify({ initialQuery, messageHistory, productStrings })
20762
- }));
20763
- if (res.status < 400) {
20764
- const data = yield res.json();
20765
- console.log(data);
20766
- return __spreadProps2(__spreadValues2({}, data), { success: true });
20782
+ try {
20783
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps2(__spreadValues2({}, defaultConfig), {
20784
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
20785
+ headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
20786
+ }));
20787
+ if (res.status < 400) {
20788
+ const data = yield res.json();
20789
+ return __spreadProps2(__spreadValues2({}, data), { success: true });
20790
+ }
20791
+ const errors = yield res.json();
20792
+ return { success: false, errors };
20793
+ } catch (e) {
20794
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, e);
20795
+ return { success: false, errors: [e] };
20767
20796
  }
20768
- const errors = yield res.json();
20769
- return { success: false, errors };
20770
20797
  });
20771
20798
  const prepareChatHistory = (chatLog) => {
20772
20799
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/client",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/src/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@getlupa/client-sdk": "^1.3.4",
23
- "@getlupa/vue": "0.3.3",
23
+ "@getlupa/vue": "0.3.5",
24
24
  "@rushstack/eslint-patch": "^1.3.2",
25
25
  "@tsconfig/node18": "^2.0.1",
26
26
  "@types/jsdom": "^21.1.1",