@getlupa/vue 0.12.3 → 0.12.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.
@@ -1611,8 +1611,18 @@ const queryByIds = (queryKey, ids, environment, customBaseUrl) => __awaiter(void
1611
1611
  const errors = yield res.json();
1612
1612
  return { success: false, errors };
1613
1613
  });
1614
- const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1615
- const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/document/${recommendForId}?queryKey=${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1614
+ const recommendForSingleId = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1615
+ const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/document/${recommendForId}?recommendationQueryKey=${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1616
+ if (res.status < 400) {
1617
+ const data = yield res.json();
1618
+ return Object.assign(Object.assign({}, data), { success: true });
1619
+ }
1620
+ const errors = yield res.json();
1621
+ return { success: false, errors };
1622
+ });
1623
+ const recommendForMultipleIds = (queryKey, recommendForIds, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1624
+ const limitedRecommendForIds = recommendForIds.slice(0, 20);
1625
+ const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/documentsByMultipleIds?recommendationQueryKey=${queryKey}&itemId[]=${limitedRecommendForIds.join("&itemId[]=")}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1616
1626
  if (res.status < 400) {
1617
1627
  const data = yield res.json();
1618
1628
  return Object.assign(Object.assign({}, data), { success: true });
@@ -1620,6 +1630,9 @@ const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __aw
1620
1630
  const errors = yield res.json();
1621
1631
  return { success: false, errors };
1622
1632
  });
1633
+ const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1634
+ return Array.isArray(recommendForId) ? yield recommendForMultipleIds(queryKey, recommendForId, environment, customBaseUrl) : yield recommendForSingleId(queryKey, recommendForId, environment, customBaseUrl);
1635
+ });
1623
1636
  const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1624
1637
  const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { body: JSON.stringify(query) }));
1625
1638
  if (res.status < 400) {
@@ -1609,8 +1609,18 @@ const queryByIds = (queryKey, ids, environment, customBaseUrl) => __awaiter(void
1609
1609
  const errors = yield res.json();
1610
1610
  return { success: false, errors };
1611
1611
  });
1612
- const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1613
- const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/document/${recommendForId}?queryKey=${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1612
+ const recommendForSingleId = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1613
+ const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/document/${recommendForId}?recommendationQueryKey=${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1614
+ if (res.status < 400) {
1615
+ const data = yield res.json();
1616
+ return Object.assign(Object.assign({}, data), { success: true });
1617
+ }
1618
+ const errors = yield res.json();
1619
+ return { success: false, errors };
1620
+ });
1621
+ const recommendForMultipleIds = (queryKey, recommendForIds, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1622
+ const limitedRecommendForIds = recommendForIds.slice(0, 20);
1623
+ const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}recommendations/documentsByMultipleIds?recommendationQueryKey=${queryKey}&itemId[]=${limitedRecommendForIds.join("&itemId[]=")}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
1614
1624
  if (res.status < 400) {
1615
1625
  const data = yield res.json();
1616
1626
  return Object.assign(Object.assign({}, data), { success: true });
@@ -1618,6 +1628,9 @@ const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __aw
1618
1628
  const errors = yield res.json();
1619
1629
  return { success: false, errors };
1620
1630
  });
1631
+ const recommend = (queryKey, recommendForId, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1632
+ return Array.isArray(recommendForId) ? yield recommendForMultipleIds(queryKey, recommendForId, environment, customBaseUrl) : yield recommendForSingleId(queryKey, recommendForId, environment, customBaseUrl);
1633
+ });
1621
1634
  const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
1622
1635
  const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}query/${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { body: JSON.stringify(query) }));
1623
1636
  if (res.status < 400) {
@@ -11,7 +11,7 @@ export type ProductRecommendationOptions = SearchResultsProductCardOptions & {
11
11
  } & {
12
12
  containerSelector: string;
13
13
  queryKey: string;
14
- itemId: string;
14
+ itemId: string[] | string;
15
15
  abTesting?: RecommendationABTestingOptions;
16
16
  carousel?: RecommenderCarouselOptions;
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getlupa/vue",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "main": "dist/lupaSearch.mjs",
5
5
  "module": "dist/lupaSearch.mjs",
6
6
  "types": "dist/src/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "vue": "^3.0.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@getlupa/client-sdk": "^1.4.2",
26
+ "@getlupa/client-sdk": "^1.5.1",
27
27
  "@pinia/testing": "^0.1.2",
28
28
  "@rollup/plugin-babel": "5.3.0",
29
29
  "@rollup/plugin-commonjs": "^21.0.1",