@faststore/api 1.12.48 → 1.12.50

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/api.esm.js CHANGED
@@ -18,7 +18,7 @@ import { trace, context, SpanKind } from '@opentelemetry/api';
18
18
  import { SeverityNumber } from '@opentelemetry/api-logs';
19
19
 
20
20
  var name = "@faststore/api";
21
- var version = "1.12.47";
21
+ var version = "1.12.49";
22
22
  var license = "MIT";
23
23
  var main = "dist/index.js";
24
24
  var typings = "dist/index.d.ts";
@@ -54,7 +54,7 @@ var dependencies = {
54
54
  };
55
55
  var devDependencies = {
56
56
  "@envelop/core": "^2.6.0",
57
- "@faststore/shared": "^1.12.43",
57
+ "@faststore/shared": "^1.12.48",
58
58
  "@graphql-codegen/cli": "2.2.0",
59
59
  "@graphql-codegen/typescript": "2.2.2",
60
60
  concurrently: "^6.2.1",
@@ -276,22 +276,23 @@ const IntelligentSearch = ({
276
276
  };
277
277
  };
278
278
 
279
- const getRegionFacet = () => {
279
+ const getRegionFacet = regionIdFromQuery => {
280
280
  const {
281
281
  regionId
282
282
  } = ctx.storage.channel;
283
+ const facet = regionIdFromQuery != null ? regionIdFromQuery : regionId;
283
284
 
284
- if (!regionId) {
285
+ if (!facet) {
285
286
  return null;
286
287
  }
287
288
 
288
289
  return {
289
290
  key: REGION_KEY,
290
- value: regionId
291
+ value: facet
291
292
  };
292
293
  };
293
294
 
294
- const addDefaultFacets = facets => {
295
+ const addDefaultFacets = (facets, regionIdFromQuery) => {
295
296
  var _facets$find, _facets$find2;
296
297
 
297
298
  const withDefaltFacets = facets.filter(({
@@ -302,7 +303,7 @@ const IntelligentSearch = ({
302
303
  }) => key === POLICY_KEY)) != null ? _facets$find : getPolicyFacet();
303
304
  const regionFacet = (_facets$find2 = facets.find(({
304
305
  key
305
- }) => key === REGION_KEY)) != null ? _facets$find2 : getRegionFacet();
306
+ }) => key === REGION_KEY)) != null ? _facets$find2 : getRegionFacet(regionIdFromQuery);
306
307
 
307
308
  if (policyFacet !== null) {
308
309
  withDefaltFacets.push(policyFacet);
@@ -322,7 +323,9 @@ const IntelligentSearch = ({
322
323
  sort = '',
323
324
  selectedFacets = [],
324
325
  type,
325
- fuzzy = 'auto'
326
+ fuzzy = 'auto',
327
+ showInvisibleItems,
328
+ regionId
326
329
  }) => {
327
330
  const params = new URLSearchParams({
328
331
  page: (page + 1).toString(),
@@ -333,11 +336,15 @@ const IntelligentSearch = ({
333
336
  locale: ctx.storage.locale
334
337
  });
335
338
 
339
+ if (showInvisibleItems) {
340
+ params.append('show-invisible-items', 'true');
341
+ }
342
+
336
343
  if (hideUnavailableItems !== undefined) {
337
344
  params.append('hideUnavailableItems', hideUnavailableItems.toString());
338
345
  }
339
346
 
340
- const pathname = addDefaultFacets(selectedFacets).map(({
347
+ const pathname = addDefaultFacets(selectedFacets, regionId).map(({
341
348
  key,
342
349
  value
343
350
  }) => `${key}/${value}`).join('/');
@@ -530,13 +537,16 @@ const isBadRequestError = error => {
530
537
  };
531
538
 
532
539
  const getSkuLoader = (_, clients) => {
533
- const loader = async skuIds => {
540
+ const loader = async keys => {
541
+ const skuIds = keys.map(key => key.split('-')[0]);
542
+ const showInvisibleItems = keys.some(key => key.split('-')[1] === 'invisibleItems');
534
543
  const {
535
544
  products
536
545
  } = await clients.search.products({
537
546
  query: `sku:${skuIds.join(';')}`,
538
547
  page: 0,
539
- count: skuIds.length
548
+ count: skuIds.length,
549
+ showInvisibleItems
540
550
  });
541
551
  const skuBySkuId = products.reduce((acc, product) => {
542
552
  for (const sku of product.items) {
@@ -916,6 +926,11 @@ const findChannel = facets => {
916
926
 
917
927
  return (_facets$find$value4 = facets == null ? void 0 : (_facets$find4 = facets.find(facet => facet.key === 'channel')) == null ? void 0 : _facets$find4.value) != null ? _facets$find$value4 : null;
918
928
  };
929
+ const findRegionId = facets => {
930
+ var _facets$find$value5, _facets$find5;
931
+
932
+ return (_facets$find$value5 = facets == null ? void 0 : (_facets$find5 = facets.find(facet => facet.key === 'regionId')) == null ? void 0 : _facets$find5.value) != null ? _facets$find$value5 : undefined;
933
+ };
919
934
 
920
935
  /**
921
936
  * More info at: https://en.wikipedia.org/wiki/Order_statistic
@@ -1154,7 +1169,7 @@ const orderFormToCart = async (form, skuLoader) => {
1154
1169
  order: {
1155
1170
  orderNumber: form.orderFormId,
1156
1171
  acceptedOffer: form.items.map(async item => ({ ...item,
1157
- product: await skuLoader.load(item.id)
1172
+ product: await skuLoader.load(`${item.id}-invisibleItems`)
1158
1173
  }))
1159
1174
  },
1160
1175
  messages: form.messages.map(({
@@ -1793,6 +1808,7 @@ const Query = {
1793
1808
  // Insert channel in context for later usage
1794
1809
  const channel = findChannel(locator);
1795
1810
  const locale = findLocale(locator);
1811
+ const regionId = findRegionId(locator);
1796
1812
  const id = findSkuId(locator);
1797
1813
  const slug = findSlug(locator);
1798
1814
 
@@ -1853,7 +1869,8 @@ const Query = {
1853
1869
  } = await search.products({
1854
1870
  page: 0,
1855
1871
  count: 1,
1856
- query: `product:${route.id}`
1872
+ query: `product:${route.id}`,
1873
+ regionId
1857
1874
  });
1858
1875
 
1859
1876
  if (!product) {