@getlupa/vue 0.3.4 → 0.3.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.
@@ -16079,6 +16079,7 @@ const defaultConfig = {
16079
16079
  method: "POST",
16080
16080
  headers: { "Content-Type": "application/json" }
16081
16081
  };
16082
+ const headers = defaultConfig.headers;
16082
16083
  const getApiUrl = (environment, customBaseUrl) => {
16083
16084
  if (customBaseUrl) {
16084
16085
  return customBaseUrl;
@@ -16086,66 +16087,88 @@ const getApiUrl = (environment, customBaseUrl) => {
16086
16087
  return Env[environment] || Env["production"];
16087
16088
  };
16088
16089
  const suggestSearchChatPhrases = (options, request) => __async(exports, null, function* () {
16089
- var _a;
16090
+ var _a, _b, _c;
16090
16091
  const { environment, customBaseUrl } = options;
16091
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
16092
- body: JSON.stringify(request),
16093
- headers: (_a = options.customHeaders) != null ? _a : {}
16094
- }));
16095
- if (res.status < 400) {
16096
- const data = yield res.json();
16097
- return __spreadProps(__spreadValues({}, data), { success: true });
16092
+ try {
16093
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
16094
+ body: JSON.stringify(request),
16095
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16096
+ }));
16097
+ if (res.status < 400) {
16098
+ const data = yield res.json();
16099
+ return __spreadProps(__spreadValues({}, data), { success: true });
16100
+ }
16101
+ const errors = yield res.json();
16102
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16103
+ return { success: false, errors };
16104
+ } catch (e) {
16105
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16106
+ return { success: false, errors: [e] };
16098
16107
  }
16099
- const errors = yield res.json();
16100
- return { success: false, errors };
16101
16108
  });
16102
16109
  const suggestPhraseAlternatives = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
16103
- var _a;
16110
+ var _a, _b, _c;
16104
16111
  const { environment, customBaseUrl } = options;
16105
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
16106
- body: JSON.stringify({ phrases }),
16107
- headers: (_a = options.customHeaders) != null ? _a : {}
16108
- }));
16109
- if (res.status < 400) {
16110
- const data = yield res.json();
16111
- return __spreadProps(__spreadValues({}, data), { success: true });
16112
+ try {
16113
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
16114
+ body: JSON.stringify({ phrases }),
16115
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16116
+ }));
16117
+ if (res.status < 400) {
16118
+ const data = yield res.json();
16119
+ return __spreadProps(__spreadValues({}, data), { success: true });
16120
+ }
16121
+ const errors = yield res.json();
16122
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16123
+ return { success: false, errors };
16124
+ } catch (e) {
16125
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16126
+ return { success: false, errors: [e] };
16112
16127
  }
16113
- const errors = yield res.json();
16114
- return { success: false, errors };
16115
16128
  });
16116
16129
  const suggestSimplifiedPhrases = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
16117
- var _a;
16130
+ var _a, _b, _c;
16118
16131
  const { environment, customBaseUrl } = options;
16119
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
16120
- body: JSON.stringify({ phrases }),
16121
- headers: (_a = options.customHeaders) != null ? _a : {}
16122
- }));
16123
- if (res.status < 400) {
16124
- const data = yield res.json();
16125
- console.log(data);
16126
- return __spreadProps(__spreadValues({}, data), { success: true });
16132
+ try {
16133
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
16134
+ body: JSON.stringify({ phrases }),
16135
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16136
+ }));
16137
+ if (res.status < 400) {
16138
+ const data = yield res.json();
16139
+ return __spreadProps(__spreadValues({}, data), { success: true });
16140
+ }
16141
+ const errors = yield res.json();
16142
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16143
+ return { success: false, errors };
16144
+ } catch (e) {
16145
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16146
+ return { success: false, errors: [e] };
16127
16147
  }
16128
- const errors = yield res.json();
16129
- return { success: false, errors };
16130
16148
  });
16131
16149
  const suggestBestProductMatches = (_0, _1) => __async(exports, [_0, _1], function* (options, {
16132
16150
  initialQuery,
16133
16151
  productStrings,
16134
16152
  messageHistory
16135
16153
  }) {
16136
- var _a;
16154
+ var _a, _b, _c;
16137
16155
  const { environment, customBaseUrl } = options;
16138
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
16139
- body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
16140
- headers: (_a = options.customHeaders) != null ? _a : {}
16141
- }));
16142
- if (res.status < 400) {
16143
- const data = yield res.json();
16144
- console.log(data);
16145
- return __spreadProps(__spreadValues({}, data), { success: true });
16156
+ try {
16157
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
16158
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
16159
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16160
+ }));
16161
+ if (res.status < 400) {
16162
+ const data = yield res.json();
16163
+ return __spreadProps(__spreadValues({}, data), { success: true });
16164
+ }
16165
+ const errors = yield res.json();
16166
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16167
+ return { success: false, errors };
16168
+ } catch (e) {
16169
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16170
+ return { success: false, errors: [e] };
16146
16171
  }
16147
- const errors = yield res.json();
16148
- return { success: false, errors };
16149
16172
  });
16150
16173
  const prepareChatHistory = (chatLog) => {
16151
16174
  var _a, _b;
@@ -16077,6 +16077,7 @@ const defaultConfig = {
16077
16077
  method: "POST",
16078
16078
  headers: { "Content-Type": "application/json" }
16079
16079
  };
16080
+ const headers = defaultConfig.headers;
16080
16081
  const getApiUrl = (environment, customBaseUrl) => {
16081
16082
  if (customBaseUrl) {
16082
16083
  return customBaseUrl;
@@ -16084,66 +16085,88 @@ const getApiUrl = (environment, customBaseUrl) => {
16084
16085
  return Env[environment] || Env["production"];
16085
16086
  };
16086
16087
  const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
16087
- var _a;
16088
+ var _a, _b, _c;
16088
16089
  const { environment, customBaseUrl } = options;
16089
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
16090
- body: JSON.stringify(request),
16091
- headers: (_a = options.customHeaders) != null ? _a : {}
16092
- }));
16093
- if (res.status < 400) {
16094
- const data = yield res.json();
16095
- return __spreadProps(__spreadValues({}, data), { success: true });
16090
+ try {
16091
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/`, __spreadProps(__spreadValues({}, defaultConfig), {
16092
+ body: JSON.stringify(request),
16093
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16094
+ }));
16095
+ if (res.status < 400) {
16096
+ const data = yield res.json();
16097
+ return __spreadProps(__spreadValues({}, data), { success: true });
16098
+ }
16099
+ const errors = yield res.json();
16100
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16101
+ return { success: false, errors };
16102
+ } catch (e) {
16103
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16104
+ return { success: false, errors: [e] };
16096
16105
  }
16097
- const errors = yield res.json();
16098
- return { success: false, errors };
16099
16106
  });
16100
16107
  const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
16101
- var _a;
16108
+ var _a, _b, _c;
16102
16109
  const { environment, customBaseUrl } = options;
16103
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
16104
- body: JSON.stringify({ phrases }),
16105
- headers: (_a = options.customHeaders) != null ? _a : {}
16106
- }));
16107
- if (res.status < 400) {
16108
- const data = yield res.json();
16109
- return __spreadProps(__spreadValues({}, data), { success: true });
16110
+ try {
16111
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives`, __spreadProps(__spreadValues({}, defaultConfig), {
16112
+ body: JSON.stringify({ phrases }),
16113
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16114
+ }));
16115
+ if (res.status < 400) {
16116
+ const data = yield res.json();
16117
+ return __spreadProps(__spreadValues({}, data), { success: true });
16118
+ }
16119
+ const errors = yield res.json();
16120
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16121
+ return { success: false, errors };
16122
+ } catch (e) {
16123
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16124
+ return { success: false, errors: [e] };
16110
16125
  }
16111
- const errors = yield res.json();
16112
- return { success: false, errors };
16113
16126
  });
16114
16127
  const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
16115
- var _a;
16128
+ var _a, _b, _c;
16116
16129
  const { environment, customBaseUrl } = options;
16117
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
16118
- body: JSON.stringify({ phrases }),
16119
- headers: (_a = options.customHeaders) != null ? _a : {}
16120
- }));
16121
- if (res.status < 400) {
16122
- const data = yield res.json();
16123
- console.log(data);
16124
- return __spreadProps(__spreadValues({}, data), { success: true });
16130
+ try {
16131
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
16132
+ body: JSON.stringify({ phrases }),
16133
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16134
+ }));
16135
+ if (res.status < 400) {
16136
+ const data = yield res.json();
16137
+ return __spreadProps(__spreadValues({}, data), { success: true });
16138
+ }
16139
+ const errors = yield res.json();
16140
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16141
+ return { success: false, errors };
16142
+ } catch (e) {
16143
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16144
+ return { success: false, errors: [e] };
16125
16145
  }
16126
- const errors = yield res.json();
16127
- return { success: false, errors };
16128
16146
  });
16129
16147
  const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
16130
16148
  initialQuery,
16131
16149
  productStrings,
16132
16150
  messageHistory
16133
16151
  }) {
16134
- var _a;
16152
+ var _a, _b, _c;
16135
16153
  const { environment, customBaseUrl } = options;
16136
- const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
16137
- body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
16138
- headers: (_a = options.customHeaders) != null ? _a : {}
16139
- }));
16140
- if (res.status < 400) {
16141
- const data = yield res.json();
16142
- console.log(data);
16143
- return __spreadProps(__spreadValues({}, data), { success: true });
16154
+ try {
16155
+ const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
16156
+ body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
16157
+ headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
16158
+ }));
16159
+ if (res.status < 400) {
16160
+ const data = yield res.json();
16161
+ return __spreadProps(__spreadValues({}, data), { success: true });
16162
+ }
16163
+ const errors = yield res.json();
16164
+ (_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
16165
+ return { success: false, errors };
16166
+ } catch (e) {
16167
+ (_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
16168
+ return { success: false, errors: [e] };
16144
16169
  }
16145
- const errors = yield res.json();
16146
- return { success: false, errors };
16147
16170
  });
16148
16171
  const prepareChatHistory = (chatLog) => {
16149
16172
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "main": "dist/lupaSearch.js",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",