@getlupa/client 1.6.2 → 1.6.4
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/lupaSearch.iife.js +140 -146
- package/dist/lupaSearch.js +140 -146
- package/dist/lupaSearch.mjs +140 -146
- package/dist/lupaSearch.umd.js +140 -146
- package/package.json +2 -2
package/dist/lupaSearch.js
CHANGED
|
@@ -6572,21 +6572,21 @@ const sendUaAnalyticsEvent = (data, options) => {
|
|
|
6572
6572
|
);
|
|
6573
6573
|
};
|
|
6574
6574
|
const sendGa4AnalyticsEvent = (data, options) => {
|
|
6575
|
-
var _a, _b, _c, _d, _e;
|
|
6575
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6576
6576
|
if (!window || !window.dataLayer) {
|
|
6577
6577
|
console.error("dataLayer object not found.");
|
|
6578
6578
|
return;
|
|
6579
6579
|
}
|
|
6580
6580
|
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
6581
6581
|
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
6582
|
-
const params = {
|
|
6582
|
+
const params = __spreadValues2({
|
|
6583
6583
|
search_text: data.searchQuery,
|
|
6584
6584
|
item_title: title,
|
|
6585
6585
|
item_id: data.itemId,
|
|
6586
6586
|
ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
|
|
6587
|
-
};
|
|
6587
|
+
}, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
|
|
6588
6588
|
window.dataLayer.push(__spreadValues2({
|
|
6589
|
-
event: (
|
|
6589
|
+
event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
|
|
6590
6590
|
}, params));
|
|
6591
6591
|
};
|
|
6592
6592
|
const processDebugEvent = (data) => {
|
|
@@ -7429,6 +7429,10 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7429
7429
|
const searchString = ref("");
|
|
7430
7430
|
const optionsStore = useOptionsStore();
|
|
7431
7431
|
const redirectionStore = useRedirectionStore();
|
|
7432
|
+
const sortParams = ref({
|
|
7433
|
+
selectedSortKey: "",
|
|
7434
|
+
previousSortKey: ""
|
|
7435
|
+
});
|
|
7432
7436
|
const query = computed(() => params.value[QUERY_PARAMS_PARSED.QUERY]);
|
|
7433
7437
|
const page = computed(() => {
|
|
7434
7438
|
const page2 = Number(params.value[QUERY_PARAMS_PARSED.PAGE]) || 1;
|
|
@@ -7563,6 +7567,12 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7563
7567
|
}
|
|
7564
7568
|
searchResultsLink.value = newSearchResultsLink;
|
|
7565
7569
|
};
|
|
7570
|
+
const setSortSettings = ({ selectedSortKey, previousSortKey }) => {
|
|
7571
|
+
sortParams.value = {
|
|
7572
|
+
selectedSortKey,
|
|
7573
|
+
previousSortKey
|
|
7574
|
+
};
|
|
7575
|
+
};
|
|
7566
7576
|
return {
|
|
7567
7577
|
params,
|
|
7568
7578
|
defaultLimit,
|
|
@@ -7573,6 +7583,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7573
7583
|
limit,
|
|
7574
7584
|
sort,
|
|
7575
7585
|
filters,
|
|
7586
|
+
sortParams,
|
|
7576
7587
|
add: add2,
|
|
7577
7588
|
removeAllFilters,
|
|
7578
7589
|
removeParameters,
|
|
@@ -7580,7 +7591,8 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7580
7591
|
goToResults,
|
|
7581
7592
|
appendParams,
|
|
7582
7593
|
setDefaultLimit,
|
|
7583
|
-
setSearchResultsLink
|
|
7594
|
+
setSearchResultsLink,
|
|
7595
|
+
setSortSettings
|
|
7584
7596
|
};
|
|
7585
7597
|
});
|
|
7586
7598
|
const flattenFacet = (key, facets, suggestion, inputValue) => {
|
|
@@ -8889,61 +8901,6 @@ const _sfc_main$13 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
|
|
|
8889
8901
|
};
|
|
8890
8902
|
}
|
|
8891
8903
|
}));
|
|
8892
|
-
const getSearchTrackingData = (searchText, type) => {
|
|
8893
|
-
return {
|
|
8894
|
-
searchQuery: searchText,
|
|
8895
|
-
analytics: {
|
|
8896
|
-
type,
|
|
8897
|
-
label: searchText
|
|
8898
|
-
}
|
|
8899
|
-
};
|
|
8900
|
-
};
|
|
8901
|
-
const useTrackingStore = defineStore("tracking", () => {
|
|
8902
|
-
const optionsStore = useOptionsStore();
|
|
8903
|
-
const trackSearch = ({
|
|
8904
|
-
queryKey,
|
|
8905
|
-
query,
|
|
8906
|
-
type = "search_query"
|
|
8907
|
-
}) => {
|
|
8908
|
-
var _a, _b;
|
|
8909
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8910
|
-
const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
|
|
8911
|
-
if (hasFilters) {
|
|
8912
|
-
const data2 = getSearchTrackingData(query.searchText, "search_filters");
|
|
8913
|
-
track(queryKey, data2, options);
|
|
8914
|
-
return;
|
|
8915
|
-
}
|
|
8916
|
-
const data = getSearchTrackingData(query.searchText, type);
|
|
8917
|
-
track(queryKey, data, options);
|
|
8918
|
-
};
|
|
8919
|
-
const trackResults = ({
|
|
8920
|
-
queryKey,
|
|
8921
|
-
results
|
|
8922
|
-
}) => {
|
|
8923
|
-
var _a;
|
|
8924
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8925
|
-
if (results.total > 0) {
|
|
8926
|
-
return;
|
|
8927
|
-
}
|
|
8928
|
-
const data = getSearchTrackingData(results.searchText, "search_zero_results");
|
|
8929
|
-
track(queryKey, data, options);
|
|
8930
|
-
};
|
|
8931
|
-
const trackEvent = ({ queryKey, data }) => {
|
|
8932
|
-
var _a, _b, _c, _d, _e;
|
|
8933
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8934
|
-
const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
|
|
8935
|
-
const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
|
|
8936
|
-
const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
|
|
8937
|
-
track(
|
|
8938
|
-
queryKey,
|
|
8939
|
-
__spreadProps2(__spreadValues2({}, data), {
|
|
8940
|
-
analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
|
|
8941
|
-
}),
|
|
8942
|
-
options
|
|
8943
|
-
);
|
|
8944
|
-
};
|
|
8945
|
-
return { trackSearch, trackResults, trackEvent };
|
|
8946
|
-
});
|
|
8947
8904
|
const _hoisted_1$_ = ["href"];
|
|
8948
8905
|
const _hoisted_2$I = { class: "lupa-search-box-product-image-section" };
|
|
8949
8906
|
const _hoisted_3$x = { class: "lupa-search-box-product-details-section" };
|
|
@@ -8963,11 +8920,7 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
|
|
|
8963
8920
|
emits: ["product-click"],
|
|
8964
8921
|
setup(__props, { emit: emit2 }) {
|
|
8965
8922
|
const props = __props;
|
|
8966
|
-
const historyStore = useHistoryStore();
|
|
8967
|
-
const trackingStore = useTrackingStore();
|
|
8968
|
-
const optionsStore = useOptionsStore();
|
|
8969
8923
|
const isInStock = ref(true);
|
|
8970
|
-
const { boxRoutingBehavior } = storeToRefs(optionsStore);
|
|
8971
8924
|
const link = computed(() => {
|
|
8972
8925
|
var _a, _b;
|
|
8973
8926
|
return generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", props.item);
|
|
@@ -8982,54 +8935,16 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
|
|
|
8982
8935
|
(e) => e.type !== DocumentElementType.IMAGE && e.type !== DocumentElementType.ADDTOCART
|
|
8983
8936
|
)) != null ? _b : [];
|
|
8984
8937
|
});
|
|
8985
|
-
const id = computed(() => {
|
|
8986
|
-
if (props.panelOptions.idKey) {
|
|
8987
|
-
return props.item[props.panelOptions.idKey];
|
|
8988
|
-
}
|
|
8989
|
-
return "";
|
|
8990
|
-
});
|
|
8991
|
-
const title = computed(() => {
|
|
8992
|
-
if (!props.panelOptions.titleKey) {
|
|
8993
|
-
return "";
|
|
8994
|
-
}
|
|
8995
|
-
const title2 = props.item[props.panelOptions.titleKey] || "";
|
|
8996
|
-
historyStore.add({
|
|
8997
|
-
item: title2
|
|
8998
|
-
});
|
|
8999
|
-
return title2;
|
|
9000
|
-
});
|
|
9001
8938
|
const addToCartElement = computed(() => {
|
|
9002
8939
|
var _a;
|
|
9003
8940
|
return (_a = props.panelOptions.elements) == null ? void 0 : _a.find((e) => e.type === DocumentElementType.ADDTOCART);
|
|
9004
8941
|
});
|
|
9005
8942
|
const handleClick = (event) => {
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
});
|
|
9011
|
-
}
|
|
9012
|
-
if (!props.panelOptions.idKey) {
|
|
9013
|
-
return;
|
|
9014
|
-
}
|
|
9015
|
-
trackingStore.trackEvent({
|
|
9016
|
-
queryKey: props.panelOptions.queryKey,
|
|
9017
|
-
data: {
|
|
9018
|
-
itemId: id.value,
|
|
9019
|
-
searchQuery: props.inputValue,
|
|
9020
|
-
type: "itemClick",
|
|
9021
|
-
analytics: {
|
|
9022
|
-
type: "autocomplete_product_click",
|
|
9023
|
-
label: (_a = title.value) != null ? _a : link.value,
|
|
9024
|
-
items: [props.item]
|
|
9025
|
-
}
|
|
9026
|
-
}
|
|
8943
|
+
emit2("product-click", {
|
|
8944
|
+
item: props.item,
|
|
8945
|
+
eventType: "itemClick",
|
|
8946
|
+
event
|
|
9027
8947
|
});
|
|
9028
|
-
if (!link.value) {
|
|
9029
|
-
return;
|
|
9030
|
-
}
|
|
9031
|
-
emit2("product-click");
|
|
9032
|
-
handleRoutingEvent(link.value, event, boxRoutingBehavior.value === "event");
|
|
9033
8948
|
};
|
|
9034
8949
|
onMounted(() => {
|
|
9035
8950
|
checkIfIsInStock();
|
|
@@ -9082,6 +8997,61 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
|
|
|
9082
8997
|
};
|
|
9083
8998
|
}
|
|
9084
8999
|
});
|
|
9000
|
+
const getSearchTrackingData = (searchText, type) => {
|
|
9001
|
+
return {
|
|
9002
|
+
searchQuery: searchText,
|
|
9003
|
+
analytics: {
|
|
9004
|
+
type,
|
|
9005
|
+
label: searchText
|
|
9006
|
+
}
|
|
9007
|
+
};
|
|
9008
|
+
};
|
|
9009
|
+
const useTrackingStore = defineStore("tracking", () => {
|
|
9010
|
+
const optionsStore = useOptionsStore();
|
|
9011
|
+
const trackSearch = ({
|
|
9012
|
+
queryKey,
|
|
9013
|
+
query,
|
|
9014
|
+
type = "search_query"
|
|
9015
|
+
}) => {
|
|
9016
|
+
var _a, _b;
|
|
9017
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9018
|
+
const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
|
|
9019
|
+
if (hasFilters) {
|
|
9020
|
+
const data2 = getSearchTrackingData(query.searchText, "search_filters");
|
|
9021
|
+
track(queryKey, data2, options);
|
|
9022
|
+
return;
|
|
9023
|
+
}
|
|
9024
|
+
const data = getSearchTrackingData(query.searchText, type);
|
|
9025
|
+
track(queryKey, data, options);
|
|
9026
|
+
};
|
|
9027
|
+
const trackResults = ({
|
|
9028
|
+
queryKey,
|
|
9029
|
+
results
|
|
9030
|
+
}) => {
|
|
9031
|
+
var _a;
|
|
9032
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9033
|
+
if (results.total > 0) {
|
|
9034
|
+
return;
|
|
9035
|
+
}
|
|
9036
|
+
const data = getSearchTrackingData(results.searchText, "search_zero_results");
|
|
9037
|
+
track(queryKey, data, options);
|
|
9038
|
+
};
|
|
9039
|
+
const trackEvent = ({ queryKey, data }) => {
|
|
9040
|
+
var _a, _b, _c, _d, _e;
|
|
9041
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9042
|
+
const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
|
|
9043
|
+
const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
|
|
9044
|
+
const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
|
|
9045
|
+
track(
|
|
9046
|
+
queryKey,
|
|
9047
|
+
__spreadProps2(__spreadValues2({}, data), {
|
|
9048
|
+
analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
|
|
9049
|
+
}),
|
|
9050
|
+
options
|
|
9051
|
+
);
|
|
9052
|
+
};
|
|
9053
|
+
return { trackSearch, trackResults, trackEvent };
|
|
9054
|
+
});
|
|
9085
9055
|
const _hoisted_1$Z = { id: "lupa-search-box-products" };
|
|
9086
9056
|
const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
9087
9057
|
__name: "SearchBoxProducts",
|
|
@@ -9091,9 +9061,14 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
9091
9061
|
panelOptions: {},
|
|
9092
9062
|
labels: {}
|
|
9093
9063
|
},
|
|
9094
|
-
|
|
9064
|
+
emits: ["product-click"],
|
|
9065
|
+
setup(__props, { emit: emit2 }) {
|
|
9095
9066
|
const props = __props;
|
|
9096
9067
|
const searchBoxStore = useSearchBoxStore();
|
|
9068
|
+
const historyStore = useHistoryStore();
|
|
9069
|
+
const trackingStore = useTrackingStore();
|
|
9070
|
+
const optionsStore = useOptionsStore();
|
|
9071
|
+
const { boxRoutingBehavior } = storeToRefs(optionsStore);
|
|
9097
9072
|
const { highlightedItem } = storeToRefs(searchBoxStore);
|
|
9098
9073
|
const highlightedIndex = computed(() => {
|
|
9099
9074
|
var _a, _b, _c;
|
|
@@ -9102,6 +9077,42 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
9102
9077
|
}
|
|
9103
9078
|
return (_c = (_b = highlightedItem.value) == null ? void 0 : _b.index) != null ? _c : -1;
|
|
9104
9079
|
});
|
|
9080
|
+
const handleProductClick = ({
|
|
9081
|
+
item,
|
|
9082
|
+
eventType,
|
|
9083
|
+
event
|
|
9084
|
+
}) => {
|
|
9085
|
+
var _a, _b;
|
|
9086
|
+
const link = generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", item);
|
|
9087
|
+
const title = props.panelOptions.titleKey ? item[props.panelOptions.titleKey] || "" : "";
|
|
9088
|
+
const id = props.panelOptions.idKey ? item[props.panelOptions.idKey] : "";
|
|
9089
|
+
if (props.panelOptions.titleKey) {
|
|
9090
|
+
historyStore.add({
|
|
9091
|
+
item: item[props.panelOptions.titleKey] || ""
|
|
9092
|
+
});
|
|
9093
|
+
}
|
|
9094
|
+
if (!props.panelOptions.idKey) {
|
|
9095
|
+
return;
|
|
9096
|
+
}
|
|
9097
|
+
trackingStore.trackEvent({
|
|
9098
|
+
queryKey: props.panelOptions.queryKey,
|
|
9099
|
+
data: {
|
|
9100
|
+
itemId: id,
|
|
9101
|
+
searchQuery: props.inputValue,
|
|
9102
|
+
type: eventType || "itemClick",
|
|
9103
|
+
analytics: {
|
|
9104
|
+
type: "autocomplete_product_click",
|
|
9105
|
+
label: title != null ? title : link,
|
|
9106
|
+
items: [item]
|
|
9107
|
+
}
|
|
9108
|
+
}
|
|
9109
|
+
});
|
|
9110
|
+
if (!link) {
|
|
9111
|
+
return;
|
|
9112
|
+
}
|
|
9113
|
+
emit2("product-click");
|
|
9114
|
+
handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
|
|
9115
|
+
};
|
|
9105
9116
|
return (_ctx, _cache) => {
|
|
9106
9117
|
return openBlock(), createElementBlock("div", _hoisted_1$Z, [
|
|
9107
9118
|
_ctx.$slots.productCard ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.items, (item, index) => {
|
|
@@ -9112,7 +9123,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
9112
9123
|
labels: _ctx.labels,
|
|
9113
9124
|
highlighted: index === highlightedIndex.value,
|
|
9114
9125
|
inputValue: _ctx.inputValue,
|
|
9115
|
-
|
|
9126
|
+
itemClicked: handleProductClick
|
|
9116
9127
|
});
|
|
9117
9128
|
}), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.items, (item, index) => {
|
|
9118
9129
|
return openBlock(), createBlock(_sfc_main$12, {
|
|
@@ -9122,7 +9133,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
9122
9133
|
labels: _ctx.labels,
|
|
9123
9134
|
highlighted: index === highlightedIndex.value,
|
|
9124
9135
|
inputValue: _ctx.inputValue,
|
|
9125
|
-
onProductClick:
|
|
9136
|
+
onProductClick: handleProductClick
|
|
9126
9137
|
}, null, 8, ["item", "panelOptions", "labels", "highlighted", "inputValue"]);
|
|
9127
9138
|
}), 128))
|
|
9128
9139
|
]);
|
|
@@ -12458,6 +12469,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
12458
12469
|
if (!value) {
|
|
12459
12470
|
return;
|
|
12460
12471
|
}
|
|
12472
|
+
paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12461
12473
|
(_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12462
12474
|
paramStore.appendParams({
|
|
12463
12475
|
params: [{ name: QUERY_PARAMS$1.SORT, value }],
|
|
@@ -14164,7 +14176,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14164
14176
|
return (_a = props.initialFilters) != null ? _a : {};
|
|
14165
14177
|
});
|
|
14166
14178
|
const { currentQueryText, hasResults, currentFilterCount } = storeToRefs(searchResultStore);
|
|
14167
|
-
const { searchString } = storeToRefs(paramStore);
|
|
14179
|
+
const { searchString, sortParams } = storeToRefs(paramStore);
|
|
14168
14180
|
const { defaultSearchResultPageSize } = storeToRefs(optionStore);
|
|
14169
14181
|
const searchResultsFilters = ref(null);
|
|
14170
14182
|
const mounted = ref(false);
|
|
@@ -14201,6 +14213,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14201
14213
|
window.removeEventListener("popstate", handlePopState);
|
|
14202
14214
|
});
|
|
14203
14215
|
const trackItemListView = (title, items = []) => {
|
|
14216
|
+
var _a, _b;
|
|
14204
14217
|
trackingStore.trackEvent({
|
|
14205
14218
|
queryKey: props.options.queryKey,
|
|
14206
14219
|
data: {
|
|
@@ -14208,7 +14221,11 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14208
14221
|
type: "view_item_list",
|
|
14209
14222
|
label: title,
|
|
14210
14223
|
listLabel: title,
|
|
14211
|
-
items
|
|
14224
|
+
items,
|
|
14225
|
+
additionalParams: {
|
|
14226
|
+
previousSortKey: (_a = sortParams.value) == null ? void 0 : _a.previousSortKey,
|
|
14227
|
+
newSortKey: (_b = sortParams.value) == null ? void 0 : _b.selectedSortKey
|
|
14228
|
+
}
|
|
14212
14229
|
},
|
|
14213
14230
|
options: { allowEmptySearchQuery: true }
|
|
14214
14231
|
}
|
|
@@ -20974,7 +20991,7 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(voi
|
|
|
20974
20991
|
return { success: false, errors: [e] };
|
|
20975
20992
|
}
|
|
20976
20993
|
});
|
|
20977
|
-
const suggestPhraseAlternatives = (
|
|
20994
|
+
const suggestPhraseAlternatives = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
20978
20995
|
var _a, _b, _c;
|
|
20979
20996
|
const { environment, customBaseUrl } = options;
|
|
20980
20997
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
@@ -20982,7 +20999,7 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20982
20999
|
const res = yield fetch(
|
|
20983
21000
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
20984
21001
|
__spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
20985
|
-
body: JSON.stringify(
|
|
21002
|
+
body: JSON.stringify(request),
|
|
20986
21003
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
20987
21004
|
})
|
|
20988
21005
|
);
|
|
@@ -20998,38 +21015,13 @@ const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2],
|
|
|
20998
21015
|
return { success: false, errors: [e] };
|
|
20999
21016
|
}
|
|
21000
21017
|
});
|
|
21001
|
-
const
|
|
21002
|
-
var _a, _b, _c;
|
|
21003
|
-
const { environment, customBaseUrl } = options;
|
|
21004
|
-
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21005
|
-
try {
|
|
21006
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21007
|
-
body: JSON.stringify({ phrases }),
|
|
21008
|
-
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21009
|
-
}));
|
|
21010
|
-
if (res.status < 400) {
|
|
21011
|
-
const data = yield res.json();
|
|
21012
|
-
return __spreadProps2(__spreadValues2({}, data), { success: true });
|
|
21013
|
-
}
|
|
21014
|
-
const errors = yield res.json();
|
|
21015
|
-
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
21016
|
-
return { success: false, errors };
|
|
21017
|
-
} catch (e) {
|
|
21018
|
-
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e);
|
|
21019
|
-
return { success: false, errors: [e] };
|
|
21020
|
-
}
|
|
21021
|
-
});
|
|
21022
|
-
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
21023
|
-
initialQuery,
|
|
21024
|
-
productStrings,
|
|
21025
|
-
messageHistory
|
|
21026
|
-
}, chatSettings) {
|
|
21018
|
+
const suggestBestProductMatches = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
21027
21019
|
var _a, _b, _c;
|
|
21028
21020
|
const { environment, customBaseUrl } = options;
|
|
21029
21021
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21030
21022
|
try {
|
|
21031
21023
|
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21032
|
-
body: JSON.stringify(
|
|
21024
|
+
body: JSON.stringify(request),
|
|
21033
21025
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21034
21026
|
}));
|
|
21035
21027
|
if (res.status < 400) {
|
|
@@ -21065,11 +21057,11 @@ const prepareChatHistory = (chatLog) => {
|
|
|
21065
21057
|
}
|
|
21066
21058
|
return history;
|
|
21067
21059
|
};
|
|
21068
|
-
const getTextResponseChunkStream = (options,
|
|
21060
|
+
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
21069
21061
|
var _a;
|
|
21070
21062
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
21071
21063
|
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps2(__spreadValues2({}, defaultConfig), {
|
|
21072
|
-
body: JSON.stringify(
|
|
21064
|
+
body: JSON.stringify(request),
|
|
21073
21065
|
headers: __spreadValues2(__spreadValues2({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
21074
21066
|
})).then((response) => {
|
|
21075
21067
|
const reader = response.body.getReader();
|
|
@@ -21089,7 +21081,6 @@ const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, o
|
|
|
21089
21081
|
const ChatService = {
|
|
21090
21082
|
suggestSearchChatPhrases,
|
|
21091
21083
|
suggestPhraseAlternatives,
|
|
21092
|
-
suggestSimplifiedPhrases,
|
|
21093
21084
|
suggestBestProductMatches,
|
|
21094
21085
|
prepareChatHistory,
|
|
21095
21086
|
getTextResponseChunkStream
|
|
@@ -21211,7 +21202,8 @@ const _sfc_main$4$1 = /* @__PURE__ */ defineComponent({
|
|
|
21211
21202
|
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
21212
21203
|
props.options.sdkOptions,
|
|
21213
21204
|
{
|
|
21214
|
-
phrases: [props.phrase]
|
|
21205
|
+
phrases: [props.phrase],
|
|
21206
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21215
21207
|
},
|
|
21216
21208
|
props.options.chatSettings
|
|
21217
21209
|
);
|
|
@@ -21284,7 +21276,8 @@ const _sfc_main$3$1 = /* @__PURE__ */ defineComponent({
|
|
|
21284
21276
|
{
|
|
21285
21277
|
initialQuery: props.entry.userInput,
|
|
21286
21278
|
productStrings: productResultStrings,
|
|
21287
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21279
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21280
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21288
21281
|
},
|
|
21289
21282
|
props.options.chatSettings
|
|
21290
21283
|
);
|
|
@@ -21358,7 +21351,8 @@ const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
|
|
|
21358
21351
|
props.options.sdkOptions,
|
|
21359
21352
|
{
|
|
21360
21353
|
initialQuery: props.content,
|
|
21361
|
-
messageHistory: (_a = props.history) != null ? _a : []
|
|
21354
|
+
messageHistory: (_a = props.history) != null ? _a : [],
|
|
21355
|
+
queryKey: props.options.displayOptions.queryKey
|
|
21362
21356
|
},
|
|
21363
21357
|
processChunk,
|
|
21364
21358
|
props.options.chatSettings
|