@getlupa/vue 0.12.9 → 0.13.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/lupaSearch.js +53 -23
- package/dist/lupaSearch.mjs +53 -23
- package/dist/src/index.d.ts +4 -2
- package/dist/src/manager/PluginConfigurationManagerService.d.ts +3 -0
- package/dist/src/types/configurations/PluginConfiguration.d.ts +19 -0
- package/dist/src/utils/api.utils.d.ts +11 -0
- package/package.json +1 -1
package/dist/lupaSearch.js
CHANGED
|
@@ -1589,14 +1589,14 @@ var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _argumen
|
|
|
1589
1589
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1590
1590
|
});
|
|
1591
1591
|
};
|
|
1592
|
-
const defaultConfig
|
|
1592
|
+
const defaultConfig = {
|
|
1593
1593
|
method: "POST",
|
|
1594
1594
|
headers: { "Content-Type": "application/json" }
|
|
1595
1595
|
};
|
|
1596
1596
|
const customRequestConfig = ({ customHeaders }) => {
|
|
1597
1597
|
return {
|
|
1598
|
-
method: defaultConfig
|
|
1599
|
-
headers: Object.assign(Object.assign({}, defaultConfig
|
|
1598
|
+
method: defaultConfig.method,
|
|
1599
|
+
headers: Object.assign(Object.assign({}, defaultConfig.headers), customHeaders !== null && customHeaders !== void 0 ? customHeaders : {})
|
|
1600
1600
|
};
|
|
1601
1601
|
};
|
|
1602
1602
|
const searchCustom = (query, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1620,7 +1620,7 @@ const suggestCustom = (query, options) => __awaiter(void 0, void 0, void 0, func
|
|
|
1620
1620
|
return { success: false, errors };
|
|
1621
1621
|
});
|
|
1622
1622
|
const search = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1623
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1623
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(query) }));
|
|
1624
1624
|
if (res.status < 400) {
|
|
1625
1625
|
const data = yield res.json();
|
|
1626
1626
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1630,7 +1630,7 @@ const search = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0
|
|
|
1630
1630
|
});
|
|
1631
1631
|
const queryByIds = (queryKey, ids, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1632
1632
|
const idParam = ids.map((id) => `ids=${id}`).join("&");
|
|
1633
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`, Object.assign(Object.assign({}, defaultConfig
|
|
1633
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1634
1634
|
if (res.status < 400) {
|
|
1635
1635
|
const data = yield res.json();
|
|
1636
1636
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1643,7 +1643,7 @@ const recommendForSingleId = (queryKey, recommendForId, filters, environment, cu
|
|
|
1643
1643
|
if (filters) {
|
|
1644
1644
|
url += `&${e({ filters })}`;
|
|
1645
1645
|
}
|
|
1646
|
-
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig
|
|
1646
|
+
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1647
1647
|
if (res.status < 400) {
|
|
1648
1648
|
const data = yield res.json();
|
|
1649
1649
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1657,7 +1657,7 @@ const recommendForMultipleIds = (queryKey, recommendForIds, filters, environment
|
|
|
1657
1657
|
if (filters) {
|
|
1658
1658
|
url += `&${e({ filters })}`;
|
|
1659
1659
|
}
|
|
1660
|
-
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig
|
|
1660
|
+
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1661
1661
|
if (res.status < 400) {
|
|
1662
1662
|
const data = yield res.json();
|
|
1663
1663
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1669,7 +1669,7 @@ const recommend = (queryKey, recommendForId, filters, environment, customBaseUrl
|
|
|
1669
1669
|
return Array.isArray(recommendForId) ? yield recommendForMultipleIds(queryKey, recommendForId, filters, environment, customBaseUrl) : yield recommendForSingleId(queryKey, recommendForId, filters, environment, customBaseUrl);
|
|
1670
1670
|
});
|
|
1671
1671
|
const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1672
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1672
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(query) }));
|
|
1673
1673
|
if (res.status < 400) {
|
|
1674
1674
|
const items = yield res.json();
|
|
1675
1675
|
return { items, success: true };
|
|
@@ -1679,7 +1679,7 @@ const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void
|
|
|
1679
1679
|
});
|
|
1680
1680
|
const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1681
1681
|
try {
|
|
1682
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig
|
|
1682
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(Object.assign({ queryKey }, event)) }));
|
|
1683
1683
|
if (res.status < 400) {
|
|
1684
1684
|
return { success: false };
|
|
1685
1685
|
}
|
|
@@ -1689,7 +1689,7 @@ const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void
|
|
|
1689
1689
|
}
|
|
1690
1690
|
});
|
|
1691
1691
|
const loadRedirectionRules = (queryKey, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1692
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1692
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1693
1693
|
if (res.status < 400) {
|
|
1694
1694
|
return res.json();
|
|
1695
1695
|
}
|
|
@@ -16902,7 +16902,10 @@ var Slide = vue.defineComponent({
|
|
|
16902
16902
|
};
|
|
16903
16903
|
}
|
|
16904
16904
|
});
|
|
16905
|
-
const _hoisted_1$8 = {
|
|
16905
|
+
const _hoisted_1$8 = {
|
|
16906
|
+
key: 0,
|
|
16907
|
+
class: "lupa-search-product-recommendations-wrapper"
|
|
16908
|
+
};
|
|
16906
16909
|
const _hoisted_2$6 = {
|
|
16907
16910
|
key: 0,
|
|
16908
16911
|
class: "lupa-recommendation-section-title"
|
|
@@ -16953,6 +16956,9 @@ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
|
16953
16956
|
var _a, _b;
|
|
16954
16957
|
return (_b = (_a = props.options.recommendationLabels) == null ? void 0 : _a.title) != null ? _b : "";
|
|
16955
16958
|
});
|
|
16959
|
+
const hasRecommendations = vue.computed(() => {
|
|
16960
|
+
return recommendations.value.length > 0;
|
|
16961
|
+
});
|
|
16956
16962
|
vue.onMounted(() => {
|
|
16957
16963
|
loadRecommendations();
|
|
16958
16964
|
window.addEventListener("resize", handleResize);
|
|
@@ -17027,7 +17033,7 @@ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
|
17027
17033
|
});
|
|
17028
17034
|
__expose({ fetch: fetch2 });
|
|
17029
17035
|
return (_ctx, _cache) => {
|
|
17030
|
-
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
17036
|
+
return hasRecommendations.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
17031
17037
|
title.value ? (vue.openBlock(), vue.createElementBlock("h2", _hoisted_2$6, vue.toDisplayString(title.value), 1)) : vue.createCommentVNode("", true),
|
|
17032
17038
|
!loading.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$4, [
|
|
17033
17039
|
layoutType.value === "carousel" ? (vue.openBlock(), vue.createBlock(vue.unref(Carousel), vue.mergeProps({ key: 0 }, carouselOptions.value, { "wrap-around": true }), {
|
|
@@ -17063,7 +17069,7 @@ const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
|
17063
17069
|
}), 128))
|
|
17064
17070
|
]))
|
|
17065
17071
|
])) : vue.createCommentVNode("", true)
|
|
17066
|
-
]);
|
|
17072
|
+
])) : vue.createCommentVNode("", true);
|
|
17067
17073
|
};
|
|
17068
17074
|
}
|
|
17069
17075
|
});
|
|
@@ -17147,11 +17153,11 @@ const Env = {
|
|
|
17147
17153
|
production: "https://api.lupasearch.com/v1/",
|
|
17148
17154
|
staging: "https://api.staging.lupasearch.com/v1/"
|
|
17149
17155
|
};
|
|
17150
|
-
const
|
|
17156
|
+
const DEFAULT_REQUEST_CONFIG = {
|
|
17151
17157
|
method: "POST",
|
|
17152
17158
|
headers: { "Content-Type": "application/json" }
|
|
17153
17159
|
};
|
|
17154
|
-
const
|
|
17160
|
+
const DEFAULT_HEADERS = DEFAULT_REQUEST_CONFIG.headers;
|
|
17155
17161
|
const getApiUrl = (environment, customBaseUrl) => {
|
|
17156
17162
|
if (customBaseUrl) {
|
|
17157
17163
|
return customBaseUrl;
|
|
@@ -17163,9 +17169,9 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(exp
|
|
|
17163
17169
|
const { environment, customBaseUrl } = options;
|
|
17164
17170
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17165
17171
|
try {
|
|
17166
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({},
|
|
17172
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17167
17173
|
body: JSON.stringify(request),
|
|
17168
|
-
headers: __spreadValues(__spreadValues({},
|
|
17174
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17169
17175
|
}));
|
|
17170
17176
|
if (res.status < 400) {
|
|
17171
17177
|
const data = yield res.json();
|
|
@@ -17186,9 +17192,9 @@ const suggestPhraseAlternatives = (options, request, chatSettings) => __async(ex
|
|
|
17186
17192
|
try {
|
|
17187
17193
|
const res = yield fetch(
|
|
17188
17194
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
17189
|
-
__spreadProps(__spreadValues({},
|
|
17195
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17190
17196
|
body: JSON.stringify(request),
|
|
17191
|
-
headers: __spreadValues(__spreadValues({},
|
|
17197
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17192
17198
|
})
|
|
17193
17199
|
);
|
|
17194
17200
|
if (res.status < 400) {
|
|
@@ -17208,9 +17214,9 @@ const suggestBestProductMatches = (options, request, chatSettings) => __async(ex
|
|
|
17208
17214
|
const { environment, customBaseUrl } = options;
|
|
17209
17215
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17210
17216
|
try {
|
|
17211
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({},
|
|
17217
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17212
17218
|
body: JSON.stringify(request),
|
|
17213
|
-
headers: __spreadValues(__spreadValues({},
|
|
17219
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17214
17220
|
}));
|
|
17215
17221
|
if (res.status < 400) {
|
|
17216
17222
|
const data = yield res.json();
|
|
@@ -17248,9 +17254,9 @@ const prepareChatHistory = (chatLog) => {
|
|
|
17248
17254
|
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
17249
17255
|
var _a;
|
|
17250
17256
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17251
|
-
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({},
|
|
17257
|
+
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17252
17258
|
body: JSON.stringify(request),
|
|
17253
|
-
headers: __spreadValues(__spreadValues({},
|
|
17259
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17254
17260
|
})).then((response) => {
|
|
17255
17261
|
const reader = response.body.getReader();
|
|
17256
17262
|
return reader.read().then(function processStream({ done, value }) {
|
|
@@ -17679,6 +17685,29 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
17679
17685
|
};
|
|
17680
17686
|
}
|
|
17681
17687
|
});
|
|
17688
|
+
const fetchPluginConfiguration = (options, configurationKey) => __async(exports, null, function* () {
|
|
17689
|
+
var _a, _b, _c;
|
|
17690
|
+
const { environment, customBaseUrl } = options;
|
|
17691
|
+
try {
|
|
17692
|
+
const res = yield fetch(
|
|
17693
|
+
`${getApiUrl(environment, customBaseUrl)}plugin/configurations/${configurationKey}`,
|
|
17694
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17695
|
+
method: "GET",
|
|
17696
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17697
|
+
})
|
|
17698
|
+
);
|
|
17699
|
+
if (res.status < 400) {
|
|
17700
|
+
const data = yield res.json();
|
|
17701
|
+
return __spreadValues({}, data);
|
|
17702
|
+
}
|
|
17703
|
+
const errors = yield res.json();
|
|
17704
|
+
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
17705
|
+
return null;
|
|
17706
|
+
} catch (e2) {
|
|
17707
|
+
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e2);
|
|
17708
|
+
return null;
|
|
17709
|
+
}
|
|
17710
|
+
});
|
|
17682
17711
|
let piniaInstance = null;
|
|
17683
17712
|
const initPinia = () => {
|
|
17684
17713
|
if (piniaInstance) {
|
|
@@ -17710,6 +17739,7 @@ exports.SearchBox = _sfc_main$V;
|
|
|
17710
17739
|
exports.SearchBoxPanelType = SearchBoxPanelType;
|
|
17711
17740
|
exports.SearchContainer = _sfc_main$9;
|
|
17712
17741
|
exports.SearchResults = _sfc_main$c;
|
|
17742
|
+
exports.fetchPluginConfiguration = fetchPluginConfiguration;
|
|
17713
17743
|
exports.getInitialSearchResults = getInitialSearchResults;
|
|
17714
17744
|
exports.initPinia = initPinia;
|
|
17715
17745
|
exports.setupTracking = setupTracking;
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -1587,14 +1587,14 @@ var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _argumen
|
|
|
1587
1587
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1588
1588
|
});
|
|
1589
1589
|
};
|
|
1590
|
-
const defaultConfig
|
|
1590
|
+
const defaultConfig = {
|
|
1591
1591
|
method: "POST",
|
|
1592
1592
|
headers: { "Content-Type": "application/json" }
|
|
1593
1593
|
};
|
|
1594
1594
|
const customRequestConfig = ({ customHeaders }) => {
|
|
1595
1595
|
return {
|
|
1596
|
-
method: defaultConfig
|
|
1597
|
-
headers: Object.assign(Object.assign({}, defaultConfig
|
|
1596
|
+
method: defaultConfig.method,
|
|
1597
|
+
headers: Object.assign(Object.assign({}, defaultConfig.headers), customHeaders !== null && customHeaders !== void 0 ? customHeaders : {})
|
|
1598
1598
|
};
|
|
1599
1599
|
};
|
|
1600
1600
|
const searchCustom = (query, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1618,7 +1618,7 @@ const suggestCustom = (query, options) => __awaiter(void 0, void 0, void 0, func
|
|
|
1618
1618
|
return { success: false, errors };
|
|
1619
1619
|
});
|
|
1620
1620
|
const search = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1621
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1621
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(query) }));
|
|
1622
1622
|
if (res.status < 400) {
|
|
1623
1623
|
const data = yield res.json();
|
|
1624
1624
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1628,7 +1628,7 @@ const search = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0
|
|
|
1628
1628
|
});
|
|
1629
1629
|
const queryByIds = (queryKey, ids, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1630
1630
|
const idParam = ids.map((id) => `ids=${id}`).join("&");
|
|
1631
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`, Object.assign(Object.assign({}, defaultConfig
|
|
1631
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}/ids?${idParam}`, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1632
1632
|
if (res.status < 400) {
|
|
1633
1633
|
const data = yield res.json();
|
|
1634
1634
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1641,7 +1641,7 @@ const recommendForSingleId = (queryKey, recommendForId, filters, environment, cu
|
|
|
1641
1641
|
if (filters) {
|
|
1642
1642
|
url += `&${e({ filters })}`;
|
|
1643
1643
|
}
|
|
1644
|
-
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig
|
|
1644
|
+
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1645
1645
|
if (res.status < 400) {
|
|
1646
1646
|
const data = yield res.json();
|
|
1647
1647
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1655,7 +1655,7 @@ const recommendForMultipleIds = (queryKey, recommendForIds, filters, environment
|
|
|
1655
1655
|
if (filters) {
|
|
1656
1656
|
url += `&${e({ filters })}`;
|
|
1657
1657
|
}
|
|
1658
|
-
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig
|
|
1658
|
+
const res = yield fetch(url, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1659
1659
|
if (res.status < 400) {
|
|
1660
1660
|
const data = yield res.json();
|
|
1661
1661
|
return Object.assign(Object.assign({}, data), { success: true });
|
|
@@ -1667,7 +1667,7 @@ const recommend = (queryKey, recommendForId, filters, environment, customBaseUrl
|
|
|
1667
1667
|
return Array.isArray(recommendForId) ? yield recommendForMultipleIds(queryKey, recommendForId, filters, environment, customBaseUrl) : yield recommendForSingleId(queryKey, recommendForId, filters, environment, customBaseUrl);
|
|
1668
1668
|
});
|
|
1669
1669
|
const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1670
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1670
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(query) }));
|
|
1671
1671
|
if (res.status < 400) {
|
|
1672
1672
|
const items = yield res.json();
|
|
1673
1673
|
return { items, success: true };
|
|
@@ -1677,7 +1677,7 @@ const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void
|
|
|
1677
1677
|
});
|
|
1678
1678
|
const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1679
1679
|
try {
|
|
1680
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig
|
|
1680
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig), { body: JSON.stringify(Object.assign({ queryKey }, event)) }));
|
|
1681
1681
|
if (res.status < 400) {
|
|
1682
1682
|
return { success: false };
|
|
1683
1683
|
}
|
|
@@ -1687,7 +1687,7 @@ const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void
|
|
|
1687
1687
|
}
|
|
1688
1688
|
});
|
|
1689
1689
|
const loadRedirectionRules = (queryKey, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1690
|
-
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig
|
|
1690
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig), { method: "GET" }));
|
|
1691
1691
|
if (res.status < 400) {
|
|
1692
1692
|
return res.json();
|
|
1693
1693
|
}
|
|
@@ -16900,7 +16900,10 @@ var Slide = defineComponent({
|
|
|
16900
16900
|
};
|
|
16901
16901
|
}
|
|
16902
16902
|
});
|
|
16903
|
-
const _hoisted_1$8 = {
|
|
16903
|
+
const _hoisted_1$8 = {
|
|
16904
|
+
key: 0,
|
|
16905
|
+
class: "lupa-search-product-recommendations-wrapper"
|
|
16906
|
+
};
|
|
16904
16907
|
const _hoisted_2$6 = {
|
|
16905
16908
|
key: 0,
|
|
16906
16909
|
class: "lupa-recommendation-section-title"
|
|
@@ -16951,6 +16954,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
16951
16954
|
var _a, _b;
|
|
16952
16955
|
return (_b = (_a = props.options.recommendationLabels) == null ? void 0 : _a.title) != null ? _b : "";
|
|
16953
16956
|
});
|
|
16957
|
+
const hasRecommendations = computed(() => {
|
|
16958
|
+
return recommendations.value.length > 0;
|
|
16959
|
+
});
|
|
16954
16960
|
onMounted(() => {
|
|
16955
16961
|
loadRecommendations();
|
|
16956
16962
|
window.addEventListener("resize", handleResize);
|
|
@@ -17025,7 +17031,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
17025
17031
|
});
|
|
17026
17032
|
__expose({ fetch: fetch2 });
|
|
17027
17033
|
return (_ctx, _cache) => {
|
|
17028
|
-
return openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
17034
|
+
return hasRecommendations.value ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
17029
17035
|
title.value ? (openBlock(), createElementBlock("h2", _hoisted_2$6, toDisplayString(title.value), 1)) : createCommentVNode("", true),
|
|
17030
17036
|
!loading.value ? (openBlock(), createElementBlock("div", _hoisted_3$4, [
|
|
17031
17037
|
layoutType.value === "carousel" ? (openBlock(), createBlock(unref(Carousel), mergeProps({ key: 0 }, carouselOptions.value, { "wrap-around": true }), {
|
|
@@ -17061,7 +17067,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
17061
17067
|
}), 128))
|
|
17062
17068
|
]))
|
|
17063
17069
|
])) : createCommentVNode("", true)
|
|
17064
|
-
]);
|
|
17070
|
+
])) : createCommentVNode("", true);
|
|
17065
17071
|
};
|
|
17066
17072
|
}
|
|
17067
17073
|
});
|
|
@@ -17145,11 +17151,11 @@ const Env = {
|
|
|
17145
17151
|
production: "https://api.lupasearch.com/v1/",
|
|
17146
17152
|
staging: "https://api.staging.lupasearch.com/v1/"
|
|
17147
17153
|
};
|
|
17148
|
-
const
|
|
17154
|
+
const DEFAULT_REQUEST_CONFIG = {
|
|
17149
17155
|
method: "POST",
|
|
17150
17156
|
headers: { "Content-Type": "application/json" }
|
|
17151
17157
|
};
|
|
17152
|
-
const
|
|
17158
|
+
const DEFAULT_HEADERS = DEFAULT_REQUEST_CONFIG.headers;
|
|
17153
17159
|
const getApiUrl = (environment, customBaseUrl) => {
|
|
17154
17160
|
if (customBaseUrl) {
|
|
17155
17161
|
return customBaseUrl;
|
|
@@ -17161,9 +17167,9 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(voi
|
|
|
17161
17167
|
const { environment, customBaseUrl } = options;
|
|
17162
17168
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17163
17169
|
try {
|
|
17164
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({},
|
|
17170
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17165
17171
|
body: JSON.stringify(request),
|
|
17166
|
-
headers: __spreadValues(__spreadValues({},
|
|
17172
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17167
17173
|
}));
|
|
17168
17174
|
if (res.status < 400) {
|
|
17169
17175
|
const data = yield res.json();
|
|
@@ -17184,9 +17190,9 @@ const suggestPhraseAlternatives = (options, request, chatSettings) => __async(vo
|
|
|
17184
17190
|
try {
|
|
17185
17191
|
const res = yield fetch(
|
|
17186
17192
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
17187
|
-
__spreadProps(__spreadValues({},
|
|
17193
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17188
17194
|
body: JSON.stringify(request),
|
|
17189
|
-
headers: __spreadValues(__spreadValues({},
|
|
17195
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17190
17196
|
})
|
|
17191
17197
|
);
|
|
17192
17198
|
if (res.status < 400) {
|
|
@@ -17206,9 +17212,9 @@ const suggestBestProductMatches = (options, request, chatSettings) => __async(vo
|
|
|
17206
17212
|
const { environment, customBaseUrl } = options;
|
|
17207
17213
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17208
17214
|
try {
|
|
17209
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({},
|
|
17215
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17210
17216
|
body: JSON.stringify(request),
|
|
17211
|
-
headers: __spreadValues(__spreadValues({},
|
|
17217
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17212
17218
|
}));
|
|
17213
17219
|
if (res.status < 400) {
|
|
17214
17220
|
const data = yield res.json();
|
|
@@ -17246,9 +17252,9 @@ const prepareChatHistory = (chatLog) => {
|
|
|
17246
17252
|
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
17247
17253
|
var _a;
|
|
17248
17254
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17249
|
-
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({},
|
|
17255
|
+
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17250
17256
|
body: JSON.stringify(request),
|
|
17251
|
-
headers: __spreadValues(__spreadValues({},
|
|
17257
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17252
17258
|
})).then((response) => {
|
|
17253
17259
|
const reader = response.body.getReader();
|
|
17254
17260
|
return reader.read().then(function processStream({ done, value }) {
|
|
@@ -17677,6 +17683,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17677
17683
|
};
|
|
17678
17684
|
}
|
|
17679
17685
|
});
|
|
17686
|
+
const fetchPluginConfiguration = (options, configurationKey) => __async(void 0, null, function* () {
|
|
17687
|
+
var _a, _b, _c;
|
|
17688
|
+
const { environment, customBaseUrl } = options;
|
|
17689
|
+
try {
|
|
17690
|
+
const res = yield fetch(
|
|
17691
|
+
`${getApiUrl(environment, customBaseUrl)}plugin/configurations/${configurationKey}`,
|
|
17692
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17693
|
+
method: "GET",
|
|
17694
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17695
|
+
})
|
|
17696
|
+
);
|
|
17697
|
+
if (res.status < 400) {
|
|
17698
|
+
const data = yield res.json();
|
|
17699
|
+
return __spreadValues({}, data);
|
|
17700
|
+
}
|
|
17701
|
+
const errors = yield res.json();
|
|
17702
|
+
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, errors);
|
|
17703
|
+
return null;
|
|
17704
|
+
} catch (e2) {
|
|
17705
|
+
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, e2);
|
|
17706
|
+
return null;
|
|
17707
|
+
}
|
|
17708
|
+
});
|
|
17680
17709
|
let piniaInstance = null;
|
|
17681
17710
|
const initPinia = () => {
|
|
17682
17711
|
if (piniaInstance) {
|
|
@@ -17709,6 +17738,7 @@ export {
|
|
|
17709
17738
|
SearchBoxPanelType,
|
|
17710
17739
|
_sfc_main$9 as SearchContainer,
|
|
17711
17740
|
_sfc_main$c as SearchResults,
|
|
17741
|
+
fetchPluginConfiguration,
|
|
17712
17742
|
getInitialSearchResults,
|
|
17713
17743
|
initPinia,
|
|
17714
17744
|
setupTracking
|
package/dist/src/index.d.ts
CHANGED
|
@@ -23,10 +23,12 @@ import { getInitialSearchResults } from './utils/ssr.utils';
|
|
|
23
23
|
import { ChatOptions, ChatSettings } from './types/chat/ChatOptions';
|
|
24
24
|
import { QueryParams } from './types/search-results/QueryParams';
|
|
25
25
|
import { RedirectionOptions } from './types/redirections/RedirectionOptions';
|
|
26
|
+
import { PluginConfiguration, PluginElementsConfiguration } from './types/configurations/PluginConfiguration';
|
|
27
|
+
import { fetchPluginConfiguration } from './manager/PluginConfigurationManagerService';
|
|
26
28
|
declare const initPinia: () => Pinia;
|
|
27
29
|
declare const setupTracking: (options: TrackingOptions) => void;
|
|
28
30
|
declare const LupaSearch: {
|
|
29
31
|
install: (app: any) => void;
|
|
30
32
|
};
|
|
31
|
-
export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults };
|
|
32
|
-
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext, RedirectionOptions, ScrollToResultsOptions, FilterBehavior };
|
|
33
|
+
export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults, fetchPluginConfiguration };
|
|
34
|
+
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext, QueryParams, SearchBoxResultsNavigateContext, RedirectionOptions, ScrollToResultsOptions, FilterBehavior, PluginElementsConfiguration, PluginConfiguration };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type PluginElementsConfiguration = {
|
|
2
|
+
cssVariables?: string;
|
|
3
|
+
customStyles?: string;
|
|
4
|
+
searchBox?: string;
|
|
5
|
+
searchResults?: string;
|
|
6
|
+
recommendations?: string;
|
|
7
|
+
productList?: string;
|
|
8
|
+
genAiChat?: string;
|
|
9
|
+
};
|
|
10
|
+
export type PluginConfiguration = {
|
|
11
|
+
id: string;
|
|
12
|
+
configurationKey: string;
|
|
13
|
+
deploymentUrl?: string | null;
|
|
14
|
+
name?: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
configuration: PluginElementsConfiguration;
|
|
18
|
+
previewConfiguration?: PluginElementsConfiguration;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Environment } from '@getlupa/client-sdk/Types';
|
|
2
|
+
export declare const DEFAULT_REQUEST_CONFIG: {
|
|
3
|
+
method: string;
|
|
4
|
+
headers: {
|
|
5
|
+
'Content-Type': string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_HEADERS: {
|
|
9
|
+
'Content-Type': string;
|
|
10
|
+
};
|
|
11
|
+
export declare const getApiUrl: (environment: Environment, customBaseUrl?: string) => string;
|