@crystaldesign/product-handler 26.4.0-beta.29 → 26.4.0-beta.30

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.
@@ -42,6 +42,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
42
42
  _defineProperty(this, "_mediaService", '');
43
43
  _defineProperty(this, "_basketService", '');
44
44
  _defineProperty(this, "_api2", '');
45
+ _defineProperty(this, "_enricherService", '');
45
46
  _defineProperty(this, "_sessionGuid", '');
46
47
  _defineProperty(this, "_organization", {});
47
48
  }
@@ -85,6 +86,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
85
86
  set: function set(val) {
86
87
  this._api2 = val;
87
88
  }
89
+ }, {
90
+ key: "enricherService",
91
+ get: function get() {
92
+ return this._enricherService;
93
+ },
94
+ set: function set(val) {
95
+ this._enricherService = val;
96
+ }
88
97
  }, {
89
98
  key: "sessionGuid",
90
99
  get: function get() {
@@ -295,7 +304,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
295
304
  }
296
305
  _context2.next = 18;
297
306
  return Promise.all((_baseProduct$configur3 = (_baseProduct$configur4 = baseProduct.configuration) === null || _baseProduct$configur4 === void 0 ? void 0 : _baseProduct$configur4.OrderSets.map(function (os) {
298
- return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
307
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID, os.IsIDMFormat);
299
308
  })) !== null && _baseProduct$configur3 !== void 0 ? _baseProduct$configur3 : []);
300
309
  case 18:
301
310
  catalogData = _context2.sent;
@@ -304,7 +313,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
304
313
  case 21:
305
314
  _context2.next = 23;
306
315
  return Promise.all((_basket$OrderSets$map2 = basket === null || basket === void 0 ? void 0 : basket.OrderSets.map(function (os) {
307
- return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID);
316
+ return _this.apiGetCatalogData(os.CatalogCodex, os.CatalogGUID, currentLang, os.AccountGUID, os.IsIDMFormat);
308
317
  })) !== null && _basket$OrderSets$map2 !== void 0 ? _basket$OrderSets$map2 : []);
309
318
  case 23:
310
319
  catalogData = _context2.sent;
@@ -1692,24 +1701,30 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1692
1701
  }, {
1693
1702
  key: "apiGetCatalogData",
1694
1703
  value: function () {
1695
- var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, catalogId, language, accountId) {
1704
+ var _apiGetCatalogData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(catalogCodex, catalogId, language, accountId, isIDMFormat) {
1696
1705
  var _response$CollectionG, _response$Properties, _response$Properties2;
1697
1706
  var currentAccountSessionId, fullUrl, response, actCatalogInfoData;
1698
1707
  return _regeneratorRuntime.wrap(function _callee7$(_context9) {
1699
1708
  while (1) switch (_context9.prev = _context9.next) {
1700
1709
  case 0:
1701
- _context9.next = 2;
1702
- return this.apiAccountLogin(accountId, catalogId);
1710
+ if (!isIDMFormat) {
1711
+ _context9.next = 2;
1712
+ break;
1713
+ }
1714
+ return _context9.abrupt("return", this.apiGetCatalogDataIDM(catalogCodex, language, accountId));
1703
1715
  case 2:
1716
+ _context9.next = 4;
1717
+ return this.apiAccountLogin(accountId, catalogId);
1718
+ case 4:
1704
1719
  currentAccountSessionId = _context9.sent;
1705
1720
  if (currentAccountSessionId) {
1706
- _context9.next = 5;
1721
+ _context9.next = 7;
1707
1722
  break;
1708
1723
  }
1709
1724
  return _context9.abrupt("return");
1710
- case 5:
1725
+ case 7:
1711
1726
  fullUrl = this.api2 + '?function=GetJsonCatalogData' + '&catalogCodex=' + catalogCodex + '&IncludeVariantValues=True&lang=' + language.toLocaleUpperCase();
1712
- _context9.next = 8;
1727
+ _context9.next = 10;
1713
1728
  return fetch(fullUrl, {
1714
1729
  headers: {
1715
1730
  sessionGuid: currentAccountSessionId
@@ -1720,14 +1735,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1720
1735
  }
1721
1736
  return res.json();
1722
1737
  });
1723
- case 8:
1738
+ case 10:
1724
1739
  response = _context9.sent;
1725
1740
  if (!response.Error) {
1726
- _context9.next = 11;
1741
+ _context9.next = 13;
1727
1742
  break;
1728
1743
  }
1729
1744
  throw new Error(response.Error);
1730
- case 11:
1745
+ case 13:
1731
1746
  actCatalogInfoData = {
1732
1747
  lang: language,
1733
1748
  guid: response.GUID,
@@ -1757,83 +1772,158 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1757
1772
  })) !== null && _response$Properties2 !== void 0 && _response$Properties2.Value)
1758
1773
  };
1759
1774
  return _context9.abrupt("return", actCatalogInfoData);
1760
- case 13:
1775
+ case 15:
1761
1776
  case "end":
1762
1777
  return _context9.stop();
1763
1778
  }
1764
1779
  }, _callee7, this);
1765
1780
  }));
1766
- function apiGetCatalogData(_x9, _x10, _x11, _x12) {
1781
+ function apiGetCatalogData(_x9, _x10, _x11, _x12, _x13) {
1767
1782
  return _apiGetCatalogData.apply(this, arguments);
1768
1783
  }
1769
1784
  return apiGetCatalogData;
1770
1785
  }()
1771
1786
  }, {
1772
- key: "apiAccountLogin",
1787
+ key: "apiGetCatalogDataIDM",
1773
1788
  value: function () {
1774
- var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(accountId, catalogId) {
1775
- var fullUrl, response, fallbackUrl, fallbackResponse;
1789
+ var _apiGetCatalogDataIDM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(serieNo, language, catalogId) {
1790
+ var _cat$Properties, _cat$detailInfos$filt, _cat$detailInfos;
1791
+ var fullUrl, response, cat, actCatalogInfoData;
1776
1792
  return _regeneratorRuntime.wrap(function _callee8$(_context10) {
1777
1793
  while (1) switch (_context10.prev = _context10.next) {
1794
+ case 0:
1795
+ fullUrl = this.enricherService + '/live/v3.0/catalogs/' + catalogId + '/series/' + serieNo;
1796
+ _context10.next = 3;
1797
+ return fetch(fullUrl, {
1798
+ headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1799
+ 'Content-Type': 'application/json'
1800
+ })
1801
+ }).then(function (res) {
1802
+ if (res.status !== 200) {
1803
+ throw new Error('IDM catalog data not loaded.');
1804
+ }
1805
+ return res.json();
1806
+ });
1807
+ case 3:
1808
+ response = _context10.sent;
1809
+ if (!response.Error) {
1810
+ _context10.next = 6;
1811
+ break;
1812
+ }
1813
+ throw new Error(response.Error);
1814
+ case 6:
1815
+ cat = response;
1816
+ if (cat) {
1817
+ _context10.next = 9;
1818
+ break;
1819
+ }
1820
+ throw new Error('serieNo: ' + serieNo + ' not found');
1821
+ case 9:
1822
+ actCatalogInfoData = {
1823
+ lang: language,
1824
+ guid: cat._id,
1825
+ name: DivaUtils.getLocals(cat.seriesName, language),
1826
+ name_locales: cat.seriesName,
1827
+ codex: serieNo,
1828
+ description: DivaUtils.getLocals(cat.seriesFullText, language),
1829
+ description_locales: cat.seriesFullText,
1830
+ hasPlanner: true,
1831
+ accountGuid: catalogId,
1832
+ supplierGuid: catalogId,
1833
+ options: cat.Options,
1834
+ optionValues: cat.Optionvalues,
1835
+ has3D: !!((_cat$Properties = cat.Properties) !== null && _cat$Properties !== void 0 && (_cat$Properties = _cat$Properties.find(function (p) {
1836
+ return p.Codex == 'DIVA3D_RENDERING';
1837
+ })) !== null && _cat$Properties !== void 0 && _cat$Properties.Value),
1838
+ images: (_cat$detailInfos$filt = (_cat$detailInfos = cat.detailInfos) === null || _cat$detailInfos === void 0 || (_cat$detailInfos = _cat$detailInfos.filter(function (d) {
1839
+ return d.functionType == 'CAT_SHO';
1840
+ })) === null || _cat$detailInfos === void 0 ? void 0 : _cat$detailInfos.map(function (d) {
1841
+ return {
1842
+ name: d.name,
1843
+ thumbUrl: d.url,
1844
+ url: d.url
1845
+ };
1846
+ })) !== null && _cat$detailInfos$filt !== void 0 ? _cat$detailInfos$filt : [],
1847
+ documents: []
1848
+ };
1849
+ return _context10.abrupt("return", actCatalogInfoData);
1850
+ case 11:
1851
+ case "end":
1852
+ return _context10.stop();
1853
+ }
1854
+ }, _callee8, this);
1855
+ }));
1856
+ function apiGetCatalogDataIDM(_x14, _x15, _x16) {
1857
+ return _apiGetCatalogDataIDM.apply(this, arguments);
1858
+ }
1859
+ return apiGetCatalogDataIDM;
1860
+ }()
1861
+ }, {
1862
+ key: "apiAccountLogin",
1863
+ value: function () {
1864
+ var _apiAccountLogin = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(accountId, catalogId) {
1865
+ var fullUrl, response, fallbackUrl, fallbackResponse;
1866
+ return _regeneratorRuntime.wrap(function _callee9$(_context11) {
1867
+ while (1) switch (_context11.prev = _context11.next) {
1778
1868
  case 0:
1779
1869
  fullUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&accountGuid=' + accountId;
1780
- _context10.t0 = fetch;
1781
- _context10.t1 = fullUrl;
1782
- _context10.next = 5;
1870
+ _context11.t0 = fetch;
1871
+ _context11.t1 = fullUrl;
1872
+ _context11.next = 5;
1783
1873
  return this.sessionGuid;
1784
1874
  case 5:
1785
- _context10.t2 = _context10.sent;
1786
- _context10.t3 = {
1787
- sessionGuid: _context10.t2
1875
+ _context11.t2 = _context11.sent;
1876
+ _context11.t3 = {
1877
+ sessionGuid: _context11.t2
1788
1878
  };
1789
- _context10.t4 = {
1790
- headers: _context10.t3
1879
+ _context11.t4 = {
1880
+ headers: _context11.t3
1791
1881
  };
1792
- _context10.next = 10;
1793
- return (0, _context10.t0)(_context10.t1, _context10.t4).then(function (res) {
1882
+ _context11.next = 10;
1883
+ return (0, _context11.t0)(_context11.t1, _context11.t4).then(function (res) {
1794
1884
  if (res.status !== 200) {
1795
1885
  throw new Error('Collections not loaded.');
1796
1886
  }
1797
1887
  return res.json();
1798
1888
  });
1799
1889
  case 10:
1800
- response = _context10.sent;
1890
+ response = _context11.sent;
1801
1891
  if (!response.SessionGUID) {
1802
- _context10.next = 13;
1892
+ _context11.next = 13;
1803
1893
  break;
1804
1894
  }
1805
- return _context10.abrupt("return", response.SessionGUID);
1895
+ return _context11.abrupt("return", response.SessionGUID);
1806
1896
  case 13:
1807
1897
  fallbackUrl = this.api2 + '?function=JsonAccountLogin&UserRole=v&catalogGuid=' + catalogId;
1808
- _context10.t5 = fetch;
1809
- _context10.t6 = fallbackUrl;
1810
- _context10.next = 18;
1898
+ _context11.t5 = fetch;
1899
+ _context11.t6 = fallbackUrl;
1900
+ _context11.next = 18;
1811
1901
  return this.sessionGuid;
1812
1902
  case 18:
1813
- _context10.t7 = _context10.sent;
1814
- _context10.t8 = {
1815
- sessionGuid: _context10.t7
1903
+ _context11.t7 = _context11.sent;
1904
+ _context11.t8 = {
1905
+ sessionGuid: _context11.t7
1816
1906
  };
1817
- _context10.t9 = {
1818
- headers: _context10.t8
1907
+ _context11.t9 = {
1908
+ headers: _context11.t8
1819
1909
  };
1820
- _context10.next = 23;
1821
- return (0, _context10.t5)(_context10.t6, _context10.t9).then(function (res) {
1910
+ _context11.next = 23;
1911
+ return (0, _context11.t5)(_context11.t6, _context11.t9).then(function (res) {
1822
1912
  if (res.status !== 200) {
1823
1913
  throw new Error('Collections not loaded.');
1824
1914
  }
1825
1915
  return res.json();
1826
1916
  });
1827
1917
  case 23:
1828
- fallbackResponse = _context10.sent;
1829
- return _context10.abrupt("return", fallbackResponse.SessionGUID);
1918
+ fallbackResponse = _context11.sent;
1919
+ return _context11.abrupt("return", fallbackResponse.SessionGUID);
1830
1920
  case 25:
1831
1921
  case "end":
1832
- return _context10.stop();
1922
+ return _context11.stop();
1833
1923
  }
1834
- }, _callee8, this);
1924
+ }, _callee9, this);
1835
1925
  }));
1836
- function apiAccountLogin(_x13, _x14) {
1926
+ function apiAccountLogin(_x17, _x18) {
1837
1927
  return _apiAccountLogin.apply(this, arguments);
1838
1928
  }
1839
1929
  return apiAccountLogin;
@@ -1841,49 +1931,49 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1841
1931
  }, {
1842
1932
  key: "apiGetProductVariants",
1843
1933
  value: function () {
1844
- var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, full) {
1934
+ var _apiGetProductVariants = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id, full) {
1845
1935
  var _res2;
1846
1936
  var fullUrl, res, resData;
1847
- return _regeneratorRuntime.wrap(function _callee9$(_context11) {
1848
- while (1) switch (_context11.prev = _context11.next) {
1937
+ return _regeneratorRuntime.wrap(function _callee10$(_context12) {
1938
+ while (1) switch (_context12.prev = _context12.next) {
1849
1939
  case 0:
1850
1940
  fullUrl = this.catalogService + '/v1/products/' + id + '/variants' + (full ? '?full=true' : '');
1851
- _context11.prev = 1;
1852
- _context11.next = 4;
1941
+ _context12.prev = 1;
1942
+ _context12.next = 4;
1853
1943
  return axios.get(fullUrl, {
1854
1944
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1855
1945
  'Content-Type': 'application/json'
1856
1946
  })
1857
1947
  });
1858
1948
  case 4:
1859
- res = _context11.sent;
1860
- _context11.next = 7;
1949
+ res = _context12.sent;
1950
+ _context12.next = 7;
1861
1951
  return res.data;
1862
1952
  case 7:
1863
- resData = _context11.sent;
1864
- _context11.next = 13;
1953
+ resData = _context12.sent;
1954
+ _context12.next = 13;
1865
1955
  break;
1866
1956
  case 10:
1867
- _context11.prev = 10;
1868
- _context11.t0 = _context11["catch"](1);
1957
+ _context12.prev = 10;
1958
+ _context12.t0 = _context12["catch"](1);
1869
1959
  throw new Error('Could not get existing products', {
1870
- cause: _context11.t0
1960
+ cause: _context12.t0
1871
1961
  });
1872
1962
  case 13:
1873
1963
  if (!(((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.status) == 200)) {
1874
- _context11.next = 15;
1964
+ _context12.next = 15;
1875
1965
  break;
1876
1966
  }
1877
- return _context11.abrupt("return", resData);
1967
+ return _context12.abrupt("return", resData);
1878
1968
  case 15:
1879
1969
  throw new Error(resData.error);
1880
1970
  case 16:
1881
1971
  case "end":
1882
- return _context11.stop();
1972
+ return _context12.stop();
1883
1973
  }
1884
- }, _callee9, this, [[1, 10]]);
1974
+ }, _callee10, this, [[1, 10]]);
1885
1975
  }));
1886
- function apiGetProductVariants(_x15, _x16) {
1976
+ function apiGetProductVariants(_x19, _x20) {
1887
1977
  return _apiGetProductVariants.apply(this, arguments);
1888
1978
  }
1889
1979
  return apiGetProductVariants;
@@ -1891,7 +1981,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1891
1981
  }, {
1892
1982
  key: "apiGetProductByFilter",
1893
1983
  value: function () {
1894
- var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10(filter) {
1984
+ var _apiGetProductByFilter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(filter) {
1895
1985
  var _res3;
1896
1986
  var limit,
1897
1987
  useFilter,
@@ -1900,39 +1990,39 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1900
1990
  res,
1901
1991
  resData,
1902
1992
  filterParam,
1903
- _args12 = arguments;
1904
- return _regeneratorRuntime.wrap(function _callee10$(_context12) {
1905
- while (1) switch (_context12.prev = _context12.next) {
1993
+ _args13 = arguments;
1994
+ return _regeneratorRuntime.wrap(function _callee11$(_context13) {
1995
+ while (1) switch (_context13.prev = _context13.next) {
1906
1996
  case 0:
1907
- limit = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 1;
1908
- useFilter = _args12.length > 2 ? _args12[2] : undefined;
1909
- hierarchy = _args12.length > 3 ? _args12[3] : undefined;
1997
+ limit = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : 1;
1998
+ useFilter = _args13.length > 2 ? _args13[2] : undefined;
1999
+ hierarchy = _args13.length > 3 ? _args13[3] : undefined;
1910
2000
  fullUrl = this.catalogService + '/v1/products';
1911
- _context12.prev = 4;
2001
+ _context13.prev = 4;
1912
2002
  filterParam = useFilter ? 'filter' : 'search';
1913
- _context12.next = 8;
2003
+ _context13.next = 8;
1914
2004
  return axios.get("".concat(fullUrl, "?organizationIds=").concat(this.organization._id, "&").concat(filterParam, "=").concat(encodeURIComponent(this.parseFilter(filter)), "&limit=").concat(limit, "&hierarchy=").concat(hierarchy !== null && hierarchy !== void 0 ? hierarchy : false), {
1915
2005
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1916
2006
  'Content-Type': 'application/json'
1917
2007
  })
1918
2008
  });
1919
2009
  case 8:
1920
- res = _context12.sent;
1921
- _context12.next = 11;
2010
+ res = _context13.sent;
2011
+ _context13.next = 11;
1922
2012
  return res.data;
1923
2013
  case 11:
1924
- resData = _context12.sent;
1925
- _context12.next = 17;
2014
+ resData = _context13.sent;
2015
+ _context13.next = 17;
1926
2016
  break;
1927
2017
  case 14:
1928
- _context12.prev = 14;
1929
- _context12.t0 = _context12["catch"](4);
2018
+ _context13.prev = 14;
2019
+ _context13.t0 = _context13["catch"](4);
1930
2020
  throw new Error('Could not get existing products', {
1931
- cause: _context12.t0
2021
+ cause: _context13.t0
1932
2022
  });
1933
2023
  case 17:
1934
2024
  if (!(((_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.status) == 200)) {
1935
- _context12.next = 20;
2025
+ _context13.next = 20;
1936
2026
  break;
1937
2027
  }
1938
2028
  //in order to be backwardscompatible we must transform old products here
@@ -1945,16 +2035,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1945
2035
  }
1946
2036
  return d;
1947
2037
  });
1948
- return _context12.abrupt("return", resData);
2038
+ return _context13.abrupt("return", resData);
1949
2039
  case 20:
1950
2040
  throw new Error(resData.error);
1951
2041
  case 21:
1952
2042
  case "end":
1953
- return _context12.stop();
2043
+ return _context13.stop();
1954
2044
  }
1955
- }, _callee10, this, [[4, 14]]);
2045
+ }, _callee11, this, [[4, 14]]);
1956
2046
  }));
1957
- function apiGetProductByFilter(_x17) {
2047
+ function apiGetProductByFilter(_x21) {
1958
2048
  return _apiGetProductByFilter.apply(this, arguments);
1959
2049
  }
1960
2050
  return apiGetProductByFilter;
@@ -1962,7 +2052,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1962
2052
  }, {
1963
2053
  key: "apiGetProductByQuery",
1964
2054
  value: function () {
1965
- var _apiGetProductByQuery = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11(filter) {
2055
+ var _apiGetProductByQuery = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(filter) {
1966
2056
  var _res4;
1967
2057
  var limit,
1968
2058
  useFilter,
@@ -1971,12 +2061,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1971
2061
  queryString,
1972
2062
  res,
1973
2063
  resData,
1974
- _args13 = arguments;
1975
- return _regeneratorRuntime.wrap(function _callee11$(_context13) {
1976
- while (1) switch (_context13.prev = _context13.next) {
2064
+ _args14 = arguments;
2065
+ return _regeneratorRuntime.wrap(function _callee12$(_context14) {
2066
+ while (1) switch (_context14.prev = _context14.next) {
1977
2067
  case 0:
1978
- limit = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : 1;
1979
- useFilter = _args13.length > 2 ? _args13[2] : undefined;
2068
+ limit = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : 1;
2069
+ useFilter = _args14.length > 2 ? _args14[2] : undefined;
1980
2070
  filterParam = useFilter ? 'filter' : 'search';
1981
2071
  fullUrl = new URL(this.catalogService + '/v1/products/query');
1982
2072
  queryString = new URLSearchParams();
@@ -1984,42 +2074,42 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
1984
2074
  queryString.append('sort', encodeURIComponent('{-created}'));
1985
2075
  queryString.append('limit', limit.toString());
1986
2076
  fullUrl.search = queryString.toString();
1987
- _context13.prev = 9;
1988
- _context13.next = 12;
2077
+ _context14.prev = 9;
2078
+ _context14.next = 12;
1989
2079
  return axios.get(fullUrl.toString(), {
1990
2080
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
1991
2081
  'Content-Type': 'application/json'
1992
2082
  })
1993
2083
  });
1994
2084
  case 12:
1995
- res = _context13.sent;
1996
- _context13.next = 15;
2085
+ res = _context14.sent;
2086
+ _context14.next = 15;
1997
2087
  return res.data;
1998
2088
  case 15:
1999
- resData = _context13.sent;
2000
- _context13.next = 21;
2089
+ resData = _context14.sent;
2090
+ _context14.next = 21;
2001
2091
  break;
2002
2092
  case 18:
2003
- _context13.prev = 18;
2004
- _context13.t0 = _context13["catch"](9);
2093
+ _context14.prev = 18;
2094
+ _context14.t0 = _context14["catch"](9);
2005
2095
  throw new Error('Could not get existing products', {
2006
- cause: _context13.t0
2096
+ cause: _context14.t0
2007
2097
  });
2008
2098
  case 21:
2009
2099
  if (!(((_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.status) == 200)) {
2010
- _context13.next = 23;
2100
+ _context14.next = 23;
2011
2101
  break;
2012
2102
  }
2013
- return _context13.abrupt("return", resData);
2103
+ return _context14.abrupt("return", resData);
2014
2104
  case 23:
2015
2105
  throw new Error(resData.error);
2016
2106
  case 24:
2017
2107
  case "end":
2018
- return _context13.stop();
2108
+ return _context14.stop();
2019
2109
  }
2020
- }, _callee11, this, [[9, 18]]);
2110
+ }, _callee12, this, [[9, 18]]);
2021
2111
  }));
2022
- function apiGetProductByQuery(_x18) {
2112
+ function apiGetProductByQuery(_x22) {
2023
2113
  return _apiGetProductByQuery.apply(this, arguments);
2024
2114
  }
2025
2115
  return apiGetProductByQuery;
@@ -2027,50 +2117,50 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2027
2117
  }, {
2028
2118
  key: "apiMarkAsFavorite",
2029
2119
  value: function () {
2030
- var _apiMarkAsFavorite = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, organizationId) {
2120
+ var _apiMarkAsFavorite = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, organizationId) {
2031
2121
  var _res5;
2032
2122
  var fullUrl, res, resData;
2033
- return _regeneratorRuntime.wrap(function _callee12$(_context14) {
2034
- while (1) switch (_context14.prev = _context14.next) {
2123
+ return _regeneratorRuntime.wrap(function _callee13$(_context15) {
2124
+ while (1) switch (_context15.prev = _context15.next) {
2035
2125
  case 0:
2036
2126
  fullUrl = new URL(this.catalogService + '/v1/products/' + id + '/favorite');
2037
2127
  fullUrl.searchParams.append('organizationId', organizationId);
2038
- _context14.prev = 2;
2039
- _context14.next = 5;
2128
+ _context15.prev = 2;
2129
+ _context15.next = 5;
2040
2130
  return axios.post(fullUrl.toString(), undefined, {
2041
2131
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
2042
2132
  'Content-Type': 'application/json'
2043
2133
  })
2044
2134
  });
2045
2135
  case 5:
2046
- res = _context14.sent;
2047
- _context14.next = 8;
2136
+ res = _context15.sent;
2137
+ _context15.next = 8;
2048
2138
  return res.data;
2049
2139
  case 8:
2050
- resData = _context14.sent;
2051
- _context14.next = 14;
2140
+ resData = _context15.sent;
2141
+ _context15.next = 14;
2052
2142
  break;
2053
2143
  case 11:
2054
- _context14.prev = 11;
2055
- _context14.t0 = _context14["catch"](2);
2144
+ _context15.prev = 11;
2145
+ _context15.t0 = _context15["catch"](2);
2056
2146
  throw new Error('Error on activate product', {
2057
- cause: _context14.t0
2147
+ cause: _context15.t0
2058
2148
  });
2059
2149
  case 14:
2060
2150
  if (!(((_res5 = res) === null || _res5 === void 0 ? void 0 : _res5.status) == 204)) {
2061
- _context14.next = 16;
2151
+ _context15.next = 16;
2062
2152
  break;
2063
2153
  }
2064
- return _context14.abrupt("return");
2154
+ return _context15.abrupt("return");
2065
2155
  case 16:
2066
2156
  throw new Error(resData.error);
2067
2157
  case 17:
2068
2158
  case "end":
2069
- return _context14.stop();
2159
+ return _context15.stop();
2070
2160
  }
2071
- }, _callee12, this, [[2, 11]]);
2161
+ }, _callee13, this, [[2, 11]]);
2072
2162
  }));
2073
- function apiMarkAsFavorite(_x19, _x20) {
2163
+ function apiMarkAsFavorite(_x23, _x24) {
2074
2164
  return _apiMarkAsFavorite.apply(this, arguments);
2075
2165
  }
2076
2166
  return apiMarkAsFavorite;
@@ -2078,47 +2168,47 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2078
2168
  }, {
2079
2169
  key: "apiGetUniqueDivaNr",
2080
2170
  value: function () {
2081
- var _apiGetUniqueDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
2171
+ var _apiGetUniqueDivaNr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
2082
2172
  var _res6;
2083
2173
  var fullUrl, res, resData;
2084
- return _regeneratorRuntime.wrap(function _callee13$(_context15) {
2085
- while (1) switch (_context15.prev = _context15.next) {
2174
+ return _regeneratorRuntime.wrap(function _callee14$(_context16) {
2175
+ while (1) switch (_context16.prev = _context16.next) {
2086
2176
  case 0:
2087
2177
  fullUrl = new URL(this.basketService + '/baskets/uniqueDivaNr');
2088
- _context15.prev = 1;
2089
- _context15.next = 4;
2178
+ _context16.prev = 1;
2179
+ _context16.next = 4;
2090
2180
  return axios.get(fullUrl.toString(), {
2091
2181
  headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
2092
2182
  'Content-Type': 'application/json'
2093
2183
  })
2094
2184
  });
2095
2185
  case 4:
2096
- res = _context15.sent;
2097
- _context15.next = 7;
2186
+ res = _context16.sent;
2187
+ _context16.next = 7;
2098
2188
  return res.data;
2099
2189
  case 7:
2100
- resData = _context15.sent;
2101
- _context15.next = 13;
2190
+ resData = _context16.sent;
2191
+ _context16.next = 13;
2102
2192
  break;
2103
2193
  case 10:
2104
- _context15.prev = 10;
2105
- _context15.t0 = _context15["catch"](1);
2194
+ _context16.prev = 10;
2195
+ _context16.t0 = _context16["catch"](1);
2106
2196
  throw new Error('Error on activate product', {
2107
- cause: _context15.t0
2197
+ cause: _context16.t0
2108
2198
  });
2109
2199
  case 13:
2110
2200
  if (!(((_res6 = res) === null || _res6 === void 0 ? void 0 : _res6.status) == 200)) {
2111
- _context15.next = 15;
2201
+ _context16.next = 15;
2112
2202
  break;
2113
2203
  }
2114
- return _context15.abrupt("return", resData.divaNr);
2204
+ return _context16.abrupt("return", resData.divaNr);
2115
2205
  case 15:
2116
2206
  throw new Error(resData.error);
2117
2207
  case 16:
2118
2208
  case "end":
2119
- return _context15.stop();
2209
+ return _context16.stop();
2120
2210
  }
2121
- }, _callee13, this, [[1, 10]]);
2211
+ }, _callee14, this, [[1, 10]]);
2122
2212
  }));
2123
2213
  function apiGetUniqueDivaNr() {
2124
2214
  return _apiGetUniqueDivaNr.apply(this, arguments);
@@ -2128,10 +2218,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2128
2218
  }, {
2129
2219
  key: "apiLoadProductVariantsGrouped",
2130
2220
  value: function () {
2131
- var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref45) {
2221
+ var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref45) {
2132
2222
  var limit, skip, fields, _ref45$search, search, sort, favorites, abortController, fullUrl, headers, promise;
2133
- return _regeneratorRuntime.wrap(function _callee14$(_context16) {
2134
- while (1) switch (_context16.prev = _context16.next) {
2223
+ return _regeneratorRuntime.wrap(function _callee15$(_context17) {
2224
+ while (1) switch (_context17.prev = _context17.next) {
2135
2225
  case 0:
2136
2226
  limit = _ref45.limit, skip = _ref45.skip, fields = _ref45.fields, _ref45$search = _ref45.search, search = _ref45$search === void 0 ? [] : _ref45$search, sort = _ref45.sort, favorites = _ref45.favorites, abortController = _ref45.abortController;
2137
2227
  fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search.length ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
@@ -2155,17 +2245,17 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2155
2245
  reject('Error loading products grouped by variants: ' + error.message);
2156
2246
  });
2157
2247
  });
2158
- _context16.next = 7;
2248
+ _context17.next = 7;
2159
2249
  return promise;
2160
2250
  case 7:
2161
- return _context16.abrupt("return", _context16.sent);
2251
+ return _context17.abrupt("return", _context17.sent);
2162
2252
  case 8:
2163
2253
  case "end":
2164
- return _context16.stop();
2254
+ return _context17.stop();
2165
2255
  }
2166
- }, _callee14, this);
2256
+ }, _callee15, this);
2167
2257
  }));
2168
- function apiLoadProductVariantsGrouped(_x21) {
2258
+ function apiLoadProductVariantsGrouped(_x25) {
2169
2259
  return _apiLoadProductVariantsGrouped.apply(this, arguments);
2170
2260
  }
2171
2261
  return apiLoadProductVariantsGrouped;
@@ -2173,11 +2263,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2173
2263
  }, {
2174
2264
  key: "apiSaveProducts",
2175
2265
  value: function () {
2176
- var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2266
+ var _apiSaveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(serverUrl, jwt, products, awaitPDF, removedProductIds) {
2177
2267
  var _this$openModal3, _this$t3;
2178
2268
  var fullUrl, response, status, BATCH_SIZE, productsPackages, groupIndex, baseProduct, i, _productsPackages$gro, _productsPackages$gro2, responseProducts, timeItTook, _i2, _this$openModal4, _this$t4, startTime, endTime, estTime, _loop3, j;
2179
- return _regeneratorRuntime.wrap(function _callee15$(_context18) {
2180
- while (1) switch (_context18.prev = _context18.next) {
2269
+ return _regeneratorRuntime.wrap(function _callee16$(_context19) {
2270
+ while (1) switch (_context19.prev = _context19.next) {
2181
2271
  case 0:
2182
2272
  fullUrl = serverUrl + '/v1/products/groups';
2183
2273
  BATCH_SIZE = 10;
@@ -2186,22 +2276,22 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2186
2276
  i = 0;
2187
2277
  case 5:
2188
2278
  if (!(i < products.length)) {
2189
- _context18.next = 15;
2279
+ _context19.next = 15;
2190
2280
  break;
2191
2281
  }
2192
2282
  if (!products[i].baseProduct) {
2193
- _context18.next = 9;
2283
+ _context19.next = 9;
2194
2284
  break;
2195
2285
  }
2196
2286
  baseProduct = products[i];
2197
- return _context18.abrupt("continue", 12);
2287
+ return _context19.abrupt("continue", 12);
2198
2288
  case 9:
2199
2289
  if (BATCH_SIZE < ((_productsPackages$gro = (_productsPackages$gro2 = productsPackages[groupIndex]) === null || _productsPackages$gro2 === void 0 ? void 0 : _productsPackages$gro2.length) !== null && _productsPackages$gro !== void 0 ? _productsPackages$gro : 0)) groupIndex++;
2200
2290
  if (!productsPackages[groupIndex]) productsPackages[groupIndex] = [];
2201
2291
  productsPackages[groupIndex].push(products[i]);
2202
2292
  case 12:
2203
2293
  i++;
2204
- _context18.next = 5;
2294
+ _context19.next = 5;
2205
2295
  break;
2206
2296
  case 15:
2207
2297
  responseProducts = [];
@@ -2214,13 +2304,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2214
2304
  _i2 = 0;
2215
2305
  case 19:
2216
2306
  if (!(_i2 < productsPackages.length)) {
2217
- _context18.next = 47;
2307
+ _context19.next = 47;
2218
2308
  break;
2219
2309
  }
2220
2310
  if (baseProduct && _i2 == 0) productsPackages[_i2].unshift(baseProduct);
2221
2311
  startTime = Date.now();
2222
- _context18.prev = 22;
2223
- _context18.next = 25;
2312
+ _context19.prev = 22;
2313
+ _context19.next = 25;
2224
2314
  return fetch(fullUrl, {
2225
2315
  method: 'PUT',
2226
2316
  headers: {
@@ -2240,18 +2330,18 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2240
2330
  return res.json();
2241
2331
  });
2242
2332
  case 25:
2243
- response = _context18.sent;
2333
+ response = _context19.sent;
2244
2334
  if (!response.Error) {
2245
- _context18.next = 28;
2335
+ _context19.next = 28;
2246
2336
  break;
2247
2337
  }
2248
2338
  throw new Error('Error saving Basket and Products. serverError: ' + response.Error);
2249
2339
  case 28:
2250
- _context18.next = 33;
2340
+ _context19.next = 33;
2251
2341
  break;
2252
2342
  case 30:
2253
- _context18.prev = 30;
2254
- _context18.t0 = _context18["catch"](22);
2343
+ _context19.prev = 30;
2344
+ _context19.t0 = _context19["catch"](22);
2255
2345
  throw Error(status);
2256
2346
  case 33:
2257
2347
  endTime = Date.now();
@@ -2265,8 +2355,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2265
2355
  dontRenderForm: true
2266
2356
  });
2267
2357
  _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3(j) {
2268
- return _regeneratorRuntime.wrap(function _loop3$(_context17) {
2269
- while (1) switch (_context17.prev = _context17.next) {
2358
+ return _regeneratorRuntime.wrap(function _loop3$(_context18) {
2359
+ while (1) switch (_context18.prev = _context18.next) {
2270
2360
  case 0:
2271
2361
  if (response.products[j].baseProduct) baseProduct = response.products[j];
2272
2362
  if (!responseProducts.find(function (p) {
@@ -2276,34 +2366,34 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2276
2366
  }
2277
2367
  case 2:
2278
2368
  case "end":
2279
- return _context17.stop();
2369
+ return _context18.stop();
2280
2370
  }
2281
2371
  }, _loop3);
2282
2372
  });
2283
2373
  j = 0;
2284
2374
  case 39:
2285
2375
  if (!(j < response.products.length)) {
2286
- _context18.next = 44;
2376
+ _context19.next = 44;
2287
2377
  break;
2288
2378
  }
2289
- return _context18.delegateYield(_loop3(j), "t1", 41);
2379
+ return _context19.delegateYield(_loop3(j), "t1", 41);
2290
2380
  case 41:
2291
2381
  j++;
2292
- _context18.next = 39;
2382
+ _context19.next = 39;
2293
2383
  break;
2294
2384
  case 44:
2295
2385
  _i2++;
2296
- _context18.next = 19;
2386
+ _context19.next = 19;
2297
2387
  break;
2298
2388
  case 47:
2299
- return _context18.abrupt("return", responseProducts);
2389
+ return _context19.abrupt("return", responseProducts);
2300
2390
  case 48:
2301
2391
  case "end":
2302
- return _context18.stop();
2392
+ return _context19.stop();
2303
2393
  }
2304
- }, _callee15, this, [[22, 30]]);
2394
+ }, _callee16, this, [[22, 30]]);
2305
2395
  }));
2306
- function apiSaveProducts(_x22, _x23, _x24, _x25, _x26) {
2396
+ function apiSaveProducts(_x26, _x27, _x28, _x29, _x30) {
2307
2397
  return _apiSaveProducts.apply(this, arguments);
2308
2398
  }
2309
2399
  return apiSaveProducts;
@@ -2528,10 +2618,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2528
2618
  }, {
2529
2619
  key: "loadSelectOptions",
2530
2620
  value: function () {
2531
- var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee16(sessionGuid, dataSource, additionalFilter) {
2621
+ var _loadSelectOptions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee17(sessionGuid, dataSource, additionalFilter) {
2532
2622
  var values, apiUrl, i, apiResult, _i3, value, text;
2533
- return _regeneratorRuntime.wrap(function _callee16$(_context19) {
2534
- while (1) switch (_context19.prev = _context19.next) {
2623
+ return _regeneratorRuntime.wrap(function _callee17$(_context20) {
2624
+ while (1) switch (_context20.prev = _context20.next) {
2535
2625
  case 0:
2536
2626
  values = [];
2537
2627
  apiUrl = dataSource.url;
@@ -2540,7 +2630,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2540
2630
  apiUrl += '&' + additionalFilter[i].key + '=' + additionalFilter[i].value;
2541
2631
  }
2542
2632
  }
2543
- _context19.next = 5;
2633
+ _context20.next = 5;
2544
2634
  return fetch(apiUrl, {
2545
2635
  headers: {
2546
2636
  sessionGuid: sessionGuid
@@ -2552,7 +2642,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2552
2642
  return res.json();
2553
2643
  });
2554
2644
  case 5:
2555
- apiResult = _context19.sent;
2645
+ apiResult = _context20.sent;
2556
2646
  if (dataSource.useKey) {
2557
2647
  apiResult = apiResult[dataSource.useKey];
2558
2648
  }
@@ -2564,14 +2654,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
2564
2654
  text: text
2565
2655
  });
2566
2656
  }
2567
- return _context19.abrupt("return", values);
2657
+ return _context20.abrupt("return", values);
2568
2658
  case 9:
2569
2659
  case "end":
2570
- return _context19.stop();
2660
+ return _context20.stop();
2571
2661
  }
2572
- }, _callee16);
2662
+ }, _callee17);
2573
2663
  }));
2574
- function loadSelectOptions(_x27, _x28, _x29) {
2664
+ function loadSelectOptions(_x31, _x32, _x33) {
2575
2665
  return _loadSelectOptions.apply(this, arguments);
2576
2666
  }
2577
2667
  return loadSelectOptions;