@getlupa/vue 0.12.10 → 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 +44 -20
- package/dist/lupaSearch.mjs +44 -20
- 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
|
}
|
|
@@ -17153,11 +17153,11 @@ const Env = {
|
|
|
17153
17153
|
production: "https://api.lupasearch.com/v1/",
|
|
17154
17154
|
staging: "https://api.staging.lupasearch.com/v1/"
|
|
17155
17155
|
};
|
|
17156
|
-
const
|
|
17156
|
+
const DEFAULT_REQUEST_CONFIG = {
|
|
17157
17157
|
method: "POST",
|
|
17158
17158
|
headers: { "Content-Type": "application/json" }
|
|
17159
17159
|
};
|
|
17160
|
-
const
|
|
17160
|
+
const DEFAULT_HEADERS = DEFAULT_REQUEST_CONFIG.headers;
|
|
17161
17161
|
const getApiUrl = (environment, customBaseUrl) => {
|
|
17162
17162
|
if (customBaseUrl) {
|
|
17163
17163
|
return customBaseUrl;
|
|
@@ -17169,9 +17169,9 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(exp
|
|
|
17169
17169
|
const { environment, customBaseUrl } = options;
|
|
17170
17170
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17171
17171
|
try {
|
|
17172
|
-
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), {
|
|
17173
17173
|
body: JSON.stringify(request),
|
|
17174
|
-
headers: __spreadValues(__spreadValues({},
|
|
17174
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17175
17175
|
}));
|
|
17176
17176
|
if (res.status < 400) {
|
|
17177
17177
|
const data = yield res.json();
|
|
@@ -17192,9 +17192,9 @@ const suggestPhraseAlternatives = (options, request, chatSettings) => __async(ex
|
|
|
17192
17192
|
try {
|
|
17193
17193
|
const res = yield fetch(
|
|
17194
17194
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
17195
|
-
__spreadProps(__spreadValues({},
|
|
17195
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17196
17196
|
body: JSON.stringify(request),
|
|
17197
|
-
headers: __spreadValues(__spreadValues({},
|
|
17197
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17198
17198
|
})
|
|
17199
17199
|
);
|
|
17200
17200
|
if (res.status < 400) {
|
|
@@ -17214,9 +17214,9 @@ const suggestBestProductMatches = (options, request, chatSettings) => __async(ex
|
|
|
17214
17214
|
const { environment, customBaseUrl } = options;
|
|
17215
17215
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17216
17216
|
try {
|
|
17217
|
-
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), {
|
|
17218
17218
|
body: JSON.stringify(request),
|
|
17219
|
-
headers: __spreadValues(__spreadValues({},
|
|
17219
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17220
17220
|
}));
|
|
17221
17221
|
if (res.status < 400) {
|
|
17222
17222
|
const data = yield res.json();
|
|
@@ -17254,9 +17254,9 @@ const prepareChatHistory = (chatLog) => {
|
|
|
17254
17254
|
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
17255
17255
|
var _a;
|
|
17256
17256
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17257
|
-
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), {
|
|
17258
17258
|
body: JSON.stringify(request),
|
|
17259
|
-
headers: __spreadValues(__spreadValues({},
|
|
17259
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17260
17260
|
})).then((response) => {
|
|
17261
17261
|
const reader = response.body.getReader();
|
|
17262
17262
|
return reader.read().then(function processStream({ done, value }) {
|
|
@@ -17685,6 +17685,29 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
17685
17685
|
};
|
|
17686
17686
|
}
|
|
17687
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
|
+
});
|
|
17688
17711
|
let piniaInstance = null;
|
|
17689
17712
|
const initPinia = () => {
|
|
17690
17713
|
if (piniaInstance) {
|
|
@@ -17716,6 +17739,7 @@ exports.SearchBox = _sfc_main$V;
|
|
|
17716
17739
|
exports.SearchBoxPanelType = SearchBoxPanelType;
|
|
17717
17740
|
exports.SearchContainer = _sfc_main$9;
|
|
17718
17741
|
exports.SearchResults = _sfc_main$c;
|
|
17742
|
+
exports.fetchPluginConfiguration = fetchPluginConfiguration;
|
|
17719
17743
|
exports.getInitialSearchResults = getInitialSearchResults;
|
|
17720
17744
|
exports.initPinia = initPinia;
|
|
17721
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
|
}
|
|
@@ -17151,11 +17151,11 @@ const Env = {
|
|
|
17151
17151
|
production: "https://api.lupasearch.com/v1/",
|
|
17152
17152
|
staging: "https://api.staging.lupasearch.com/v1/"
|
|
17153
17153
|
};
|
|
17154
|
-
const
|
|
17154
|
+
const DEFAULT_REQUEST_CONFIG = {
|
|
17155
17155
|
method: "POST",
|
|
17156
17156
|
headers: { "Content-Type": "application/json" }
|
|
17157
17157
|
};
|
|
17158
|
-
const
|
|
17158
|
+
const DEFAULT_HEADERS = DEFAULT_REQUEST_CONFIG.headers;
|
|
17159
17159
|
const getApiUrl = (environment, customBaseUrl) => {
|
|
17160
17160
|
if (customBaseUrl) {
|
|
17161
17161
|
return customBaseUrl;
|
|
@@ -17167,9 +17167,9 @@ const suggestSearchChatPhrases = (options, request, chatSettings) => __async(voi
|
|
|
17167
17167
|
const { environment, customBaseUrl } = options;
|
|
17168
17168
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17169
17169
|
try {
|
|
17170
|
-
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), {
|
|
17171
17171
|
body: JSON.stringify(request),
|
|
17172
|
-
headers: __spreadValues(__spreadValues({},
|
|
17172
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17173
17173
|
}));
|
|
17174
17174
|
if (res.status < 400) {
|
|
17175
17175
|
const data = yield res.json();
|
|
@@ -17190,9 +17190,9 @@ const suggestPhraseAlternatives = (options, request, chatSettings) => __async(vo
|
|
|
17190
17190
|
try {
|
|
17191
17191
|
const res = yield fetch(
|
|
17192
17192
|
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
17193
|
-
__spreadProps(__spreadValues({},
|
|
17193
|
+
__spreadProps(__spreadValues({}, DEFAULT_REQUEST_CONFIG), {
|
|
17194
17194
|
body: JSON.stringify(request),
|
|
17195
|
-
headers: __spreadValues(__spreadValues({},
|
|
17195
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17196
17196
|
})
|
|
17197
17197
|
);
|
|
17198
17198
|
if (res.status < 400) {
|
|
@@ -17212,9 +17212,9 @@ const suggestBestProductMatches = (options, request, chatSettings) => __async(vo
|
|
|
17212
17212
|
const { environment, customBaseUrl } = options;
|
|
17213
17213
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17214
17214
|
try {
|
|
17215
|
-
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), {
|
|
17216
17216
|
body: JSON.stringify(request),
|
|
17217
|
-
headers: __spreadValues(__spreadValues({},
|
|
17217
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17218
17218
|
}));
|
|
17219
17219
|
if (res.status < 400) {
|
|
17220
17220
|
const data = yield res.json();
|
|
@@ -17252,9 +17252,9 @@ const prepareChatHistory = (chatLog) => {
|
|
|
17252
17252
|
const getTextResponseChunkStream = (options, request, onChunkReceived, chatSettings) => {
|
|
17253
17253
|
var _a;
|
|
17254
17254
|
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
17255
|
-
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), {
|
|
17256
17256
|
body: JSON.stringify(request),
|
|
17257
|
-
headers: __spreadValues(__spreadValues({},
|
|
17257
|
+
headers: __spreadValues(__spreadValues({}, DEFAULT_HEADERS), (_a = options.customHeaders) != null ? _a : {})
|
|
17258
17258
|
})).then((response) => {
|
|
17259
17259
|
const reader = response.body.getReader();
|
|
17260
17260
|
return reader.read().then(function processStream({ done, value }) {
|
|
@@ -17683,6 +17683,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17683
17683
|
};
|
|
17684
17684
|
}
|
|
17685
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
|
+
});
|
|
17686
17709
|
let piniaInstance = null;
|
|
17687
17710
|
const initPinia = () => {
|
|
17688
17711
|
if (piniaInstance) {
|
|
@@ -17715,6 +17738,7 @@ export {
|
|
|
17715
17738
|
SearchBoxPanelType,
|
|
17716
17739
|
_sfc_main$9 as SearchContainer,
|
|
17717
17740
|
_sfc_main$c as SearchResults,
|
|
17741
|
+
fetchPluginConfiguration,
|
|
17718
17742
|
getInitialSearchResults,
|
|
17719
17743
|
initPinia,
|
|
17720
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;
|