@sentecacommerce-theme/lib 0.13.21 → 0.14.2

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.
@@ -44,7 +44,7 @@ var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
44
44
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
45
45
  while(1)switch(_ctx.prev = _ctx.next){
46
46
  case 0:
47
- url = '/hub/releva/collect';
47
+ url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
48
48
  return _ctx.abrupt("return", fetch(url, {
49
49
  method: 'POST',
50
50
  headers: {
@@ -53,18 +53,18 @@ var getSDKConfig = function() {
53
53
  exports.getSDKConfig = getSDKConfig;
54
54
  var getOptions = function() {
55
55
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
56
+ var ref;
57
+ var basePath = process.env.NEXT_PUBLIC_PROXY_URL + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/platform');
56
58
  if (!(0, _utils).canUseDOM()) {
57
59
  // eslint-disable-next-line @typescript-eslint/no-var-requires
58
60
  var nodeFetch = require('node-fetch');
59
- var ref;
60
61
  return _objectSpread({}, options, {
61
- basePath: process.env.PLATFORM_HOST + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/api'),
62
+ basePath: basePath,
62
63
  fetchApi: nodeFetch
63
64
  }, process.env.sdkConfig || {});
64
65
  } else {
65
- var ref2;
66
66
  return _objectSpread({}, options, {
67
- basePath: (ref2 = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref2 !== void 0 ? ref2 : '/api',
67
+ basePath: basePath,
68
68
  token: _jsCookie.default.get(_utils.AUTH_TOKEN_KEY) || _jsCookie.default.get(_utils.ANONYMOUS_TOKEN_KEY) || process.env.API_KEY || process.env.apiKey,
69
69
  fetchApi: window.fetch.bind(window)
70
70
  }, process.env.sdkConfig || {});
@@ -33,7 +33,9 @@ var NotificationsApiFactory = function() {
33
33
  queryCache.cancelQueries(cacheKeys.useGet);
34
34
  var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
35
35
  return function() {
36
- return queryCache.setQueryData(cacheKeys.useGet, oldNotifications);
36
+ return queryCache.setQueryData(cacheKeys.useGet, {
37
+ results: oldNotifications
38
+ });
37
39
  };
38
40
  },
39
41
  onError: function(_, __, rollback) {
@@ -44,7 +46,9 @@ var NotificationsApiFactory = function() {
44
46
  var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
45
47
  return n._id !== params.id;
46
48
  });
47
- queryCache.setQueryData(cacheKeys.useGet, optimisticNotifications);
49
+ queryCache.setQueryData(cacheKeys.useGet, {
50
+ results: optimisticNotifications
51
+ });
48
52
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
49
53
  }
50
54
  });
@@ -11,7 +11,8 @@ var getListingPageType = function(router, slug, meta) {
11
11
  '/[slug]/v': _.ListingTypesEnum.View,
12
12
  '/[slug]/ct': _.ListingTypesEnum.Collection,
13
13
  '/[slug]/[cat]/c': _.ListingTypesEnum.Category,
14
- '/[slug]/[cat]/b': _.ListingTypesEnum.Brand
14
+ '/[slug]/[cat]/b': _.ListingTypesEnum.Brand,
15
+ '/search': _.ListingTypesEnum.Search
15
16
  };
16
17
  var slugAliases = {};
17
18
  if (meta) slugAliases = meta.slugAliases;
@@ -62,9 +62,9 @@ var manageFilter = function(pair, query, remove) {
62
62
  };
63
63
  exports.manageFilter = manageFilter;
64
64
  var createAggregateQuery = function(type, slug, aggPair, remove, router, onlyOneAtTime) {
65
- if (type !== 'search') {
65
+ if (type !== 'text') {
66
66
  return "".concat(router.asPath.split('?')[0], "?").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
67
67
  }
68
- return "/search?q=".concat(slug, "&").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
68
+ return "/search?q=".concat(slug !== null && slug !== void 0 ? slug : router.query.q, "&").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
69
69
  };
70
70
  exports.createAggregateQuery = createAggregateQuery;
@@ -35,7 +35,7 @@ export var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
35
35
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
36
36
  while(1)switch(_ctx.prev = _ctx.next){
37
37
  case 0:
38
- url = '/hub/releva/collect';
38
+ url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
39
39
  return _ctx.abrupt("return", fetch(url, {
40
40
  method: 'POST',
41
41
  headers: {
@@ -1,6 +1,6 @@
1
1
  import { Configuration, HttpClient } from '@sentecacommerce/sdk';
2
2
  import Cookies from 'js-cookie';
3
- import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY, getLocaleFromPath, canUseDOM } from '../utils';
3
+ import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY, canUseDOM, getLocaleFromPath } from '../utils';
4
4
  function _defineProperty(obj, key, value) {
5
5
  if (key in obj) {
6
6
  Object.defineProperty(obj, key, {
@@ -43,18 +43,18 @@ export var getSDKConfig = function() {
43
43
  };
44
44
  export var getOptions = function() {
45
45
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
46
+ var ref;
47
+ var basePath = process.env.NEXT_PUBLIC_PROXY_URL + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/platform');
46
48
  if (!canUseDOM()) {
47
49
  // eslint-disable-next-line @typescript-eslint/no-var-requires
48
50
  var nodeFetch = require('node-fetch');
49
- var ref;
50
51
  return _objectSpread({}, options, {
51
- basePath: process.env.PLATFORM_HOST + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/api'),
52
+ basePath: basePath,
52
53
  fetchApi: nodeFetch
53
54
  }, process.env.sdkConfig || {});
54
55
  } else {
55
- var ref2;
56
56
  return _objectSpread({}, options, {
57
- basePath: (ref2 = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref2 !== void 0 ? ref2 : '/api',
57
+ basePath: basePath,
58
58
  token: Cookies.get(AUTH_TOKEN_KEY) || Cookies.get(ANONYMOUS_TOKEN_KEY) || process.env.API_KEY || process.env.apiKey,
59
59
  fetchApi: window.fetch.bind(window)
60
60
  }, process.env.sdkConfig || {});
@@ -27,7 +27,9 @@ export var NotificationsApiFactory = function() {
27
27
  queryCache.cancelQueries(cacheKeys.useGet);
28
28
  var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
29
29
  return function() {
30
- return queryCache.setQueryData(cacheKeys.useGet, oldNotifications);
30
+ return queryCache.setQueryData(cacheKeys.useGet, {
31
+ results: oldNotifications
32
+ });
31
33
  };
32
34
  },
33
35
  onError: function(_, __, rollback) {
@@ -38,7 +40,9 @@ export var NotificationsApiFactory = function() {
38
40
  var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
39
41
  return n._id !== params.id;
40
42
  });
41
- queryCache.setQueryData(cacheKeys.useGet, optimisticNotifications);
43
+ queryCache.setQueryData(cacheKeys.useGet, {
44
+ results: optimisticNotifications
45
+ });
42
46
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
43
47
  }
44
48
  });
@@ -7,7 +7,8 @@ export var getListingPageType = function(router, slug, meta) {
7
7
  '/[slug]/v': ListingTypesEnum.View,
8
8
  '/[slug]/ct': ListingTypesEnum.Collection,
9
9
  '/[slug]/[cat]/c': ListingTypesEnum.Category,
10
- '/[slug]/[cat]/b': ListingTypesEnum.Brand
10
+ '/[slug]/[cat]/b': ListingTypesEnum.Brand,
11
+ '/search': ListingTypesEnum.Search
11
12
  };
12
13
  var slugAliases = {};
13
14
  if (meta) slugAliases = meta.slugAliases;
@@ -57,8 +57,8 @@ export var manageFilter = function(pair, query, remove) {
57
57
  return result;
58
58
  };
59
59
  export var createAggregateQuery = function(type, slug, aggPair, remove, router, onlyOneAtTime) {
60
- if (type !== 'search') {
60
+ if (type !== 'text') {
61
61
  return "".concat(router.asPath.split('?')[0], "?").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
62
62
  }
63
- return "/search?q=".concat(slug, "&").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
63
+ return "/search?q=".concat(slug !== null && slug !== void 0 ? slug : router.query.q, "&").concat(manageFilter(aggPair, router.query, remove, onlyOneAtTime));
64
64
  };
@@ -13,6 +13,7 @@ export declare type getProductBySlugConfig = {
13
13
  merchantKey?: string;
14
14
  expand?: string;
15
15
  project?: string;
16
+ stockLocationKey?: string;
16
17
  };
17
18
  export declare const ProductsApiFactory: {
18
19
  getInstance: () => ProductsApiType;
@@ -8,6 +8,7 @@ declare type Config = {
8
8
  merchantKey?: string;
9
9
  expand?: string;
10
10
  project?: string;
11
+ stockLocationKey?: string;
11
12
  };
12
13
  export declare const prefetchProduct: (queryCache: QueryCache, slug: string, config?: Config) => Promise<import("@sentecacommerce/sdk").ProductDTO | undefined>;
13
14
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.13.21",
4
+ "version": "0.14.2",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "b2055eb08ee6b288207b4745eeb2d632bb2bc872",
34
+ "gitHead": "511ef73d66bf8ee56840205d87d52f0a87ffea80",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.13.21",
40
- "@sentecacommerce-theme/cms": "^0.13.21",
39
+ "@sentecacommerce-theme/base": "^0.14.2",
40
+ "@sentecacommerce-theme/cms": "^0.14.2",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",