@azzas/azzas-tracker-web 2.0.0-preview.19 → 2.0.0-preview.20

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/mod.js CHANGED
@@ -1540,8 +1540,108 @@ var decoAdapter = {
1540
1540
  }
1541
1541
  };
1542
1542
 
1543
- // src/params/adapters/headless/utils.ts
1543
+ // src/params/adapters/reserva/utils.ts
1544
1544
  var getItemCategory5 = (item) => {
1545
+ var _a, _b, _c;
1546
+ const categories = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories;
1547
+ if (!(categories == null ? void 0 : categories.length)) return "Cole\xE7\xE3o";
1548
+ const match = (_c = categories.join(" ").match(/outlet|bazar|sale/i)) == null ? void 0 : _c[0].toLowerCase();
1549
+ return match != null ? match : "Cole\xE7\xE3o";
1550
+ };
1551
+ var getItemCategory23 = (item) => {
1552
+ var _a, _b, _c, _d;
1553
+ const AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
1554
+ const categories = (_c = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories) != null ? _c : [];
1555
+ const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES.test(c));
1556
+ const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
1557
+ return capitalize(deepest);
1558
+ };
1559
+
1560
+ // src/params/adapters/reserva/index.ts
1561
+ var reservaAdapter = {
1562
+ ...metaAdapter,
1563
+ // global adapters
1564
+ items: (context) => {
1565
+ if (context == null ? void 0 : context.items) return context.items;
1566
+ if (context == null ? void 0 : context.products) {
1567
+ return context.products.map((item) => {
1568
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
1569
+ const COLOR_REGEX = /^[^_]+_/;
1570
+ const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
1571
+ const refIdValue = (_e = (_d = (_c = item.additionalProperty) == null ? void 0 : _c.find((i) => i.name === "RefId")) == null ? void 0 : _d.value) == null ? void 0 : _e.replace(/_\d+$/, "");
1572
+ return {
1573
+ quantity: 1,
1574
+ index: (_f = item == null ? void 0 : item.index) != null ? _f : 0,
1575
+ item_brand: (_i = (_h = (_g = item.brand) == null ? void 0 : _g.name) == null ? void 0 : _h.toLowerCase()) != null ? _i : null,
1576
+ item_name: (_j = item.name) != null ? _j : null,
1577
+ price: (_l = (_k = item.offers) == null ? void 0 : _k.lowPrice) != null ? _l : null,
1578
+ discount: Math.round((Number(listPrice) - Number((_m = item == null ? void 0 : item.offers) == null ? void 0 : _m.lowPrice)) * 100) / 100,
1579
+ item_variant: ((_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[0]) == null ? void 0 : _o.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
1580
+ // cor
1581
+ item_variant2: (_q = (_p = item == null ? void 0 : item.name) == null ? void 0 : _p.split(" - ")[1]) != null ? _q : null,
1582
+ // tamanho
1583
+ item_shipping_tier: "",
1584
+ item_ref: refIdValue != null ? refIdValue : null,
1585
+ item_category: (_r = getItemCategory5(item)) != null ? _r : null,
1586
+ item_category2: (_s = getItemCategory23(item)) != null ? _s : null,
1587
+ item_id: (_t = item == null ? void 0 : item.id) != null ? _t : null,
1588
+ item_sku: (_u = item == null ? void 0 : item.sku) != null ? _u : null,
1589
+ item_url: (_w = (_v = item == null ? void 0 : item.seo) == null ? void 0 : _v.canonical) != null ? _w : null,
1590
+ image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
1591
+ seller_id: (_D = (_C = (_B = (_A = (_z = item.offers) == null ? void 0 : _z.offers) == null ? void 0 : _A[0]) == null ? void 0 : _B.seller) == null ? void 0 : _C.identifier) != null ? _D : null,
1592
+ item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
1593
+ };
1594
+ });
1595
+ }
1596
+ return null;
1597
+ },
1598
+ brand: (context, config2) => {
1599
+ if (config2 == null ? void 0 : config2.brand) return config2.brand;
1600
+ if (context == null ? void 0 : context.brand) return context.brand;
1601
+ if (context == null ? void 0 : context.products) {
1602
+ return normalizeBrand2(context.products.map((p) => {
1603
+ var _a;
1604
+ return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
1605
+ }));
1606
+ }
1607
+ return null;
1608
+ },
1609
+ line_items: (context) => {
1610
+ if (context == null ? void 0 : context.line_items) return context.line_items;
1611
+ if (context == null ? void 0 : context.products) {
1612
+ return context.products.map((item) => item == null ? void 0 : item.id).filter((id) => Boolean(id)).join();
1613
+ }
1614
+ return null;
1615
+ },
1616
+ value: (context) => {
1617
+ if (context == null ? void 0 : context.value) return context.value;
1618
+ if (context == null ? void 0 : context.products) {
1619
+ return context.products.map((item) => {
1620
+ var _a;
1621
+ return (_a = item.offers) == null ? void 0 : _a.lowPrice;
1622
+ }).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1623
+ }
1624
+ return null;
1625
+ },
1626
+ available_grid: (context) => {
1627
+ if (context == null ? void 0 : context.available_grid) return context.available_grid;
1628
+ if (context == null ? void 0 : context.products) {
1629
+ const sizes = context.products.filter((product) => {
1630
+ var _a, _b;
1631
+ return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
1632
+ }).map((product) => {
1633
+ var _a;
1634
+ return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
1635
+ }).filter((name) => Boolean(name));
1636
+ const result = sortSizes(sizes).join(",").trim();
1637
+ return result || null;
1638
+ }
1639
+ return null;
1640
+ }
1641
+ };
1642
+
1643
+ // src/params/adapters/headless/utils.ts
1644
+ var getItemCategory6 = (item) => {
1545
1645
  const keywords = ["outlet", "bazar", "sale"];
1546
1646
  const regex = new RegExp(keywords.join("|"), "i");
1547
1647
  const value = item == null ? void 0 : item.categories;
@@ -1554,7 +1654,7 @@ var getItemCategory5 = (item) => {
1554
1654
  }
1555
1655
  return "Cole\xE7\xE3o";
1556
1656
  };
1557
- var getItemCategory23 = (item) => {
1657
+ var getItemCategory24 = (item) => {
1558
1658
  var _a, _b, _c;
1559
1659
  const avoidList = /outlet|bazar|sale/i;
1560
1660
  const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
@@ -1584,8 +1684,8 @@ var HeadlessPdpZone = {
1584
1684
  item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
1585
1685
  item_ref: (_l = item.productReference) != null ? _l : null,
1586
1686
  // sem ref no retorno do IS na multi-lib produtos PDC
1587
- item_category: getItemCategory5(item),
1588
- item_category2: (_m = getItemCategory23(item)) != null ? _m : null,
1687
+ item_category: getItemCategory6(item),
1688
+ item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
1589
1689
  item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
1590
1690
  item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
1591
1691
  item_url: (_q = item.link) != null ? _q : null,
@@ -1646,8 +1746,8 @@ var HeadlessPdcZone = {
1646
1746
  item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
1647
1747
  item_ref: null,
1648
1748
  // sem ref no retorno do IS na multi-lib produtos PDC
1649
- item_category: getItemCategory5(item),
1650
- item_category2: (_j = getItemCategory23(item)) != null ? _j : null,
1749
+ item_category: getItemCategory6(item),
1750
+ item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
1651
1751
  item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
1652
1752
  item_sku: (_l = item.sku) != null ? _l : null,
1653
1753
  item_url: null,
@@ -1793,7 +1893,7 @@ var getOrderFormItems = (orderForm) => {
1793
1893
  return { ...i, quantity: 1 };
1794
1894
  }) : orderForm.items;
1795
1895
  };
1796
- var getItemCategory6 = (item) => {
1896
+ var getItemCategory7 = (item) => {
1797
1897
  var _a;
1798
1898
  const categories = item == null ? void 0 : item.productCategories;
1799
1899
  if (!categories) return "Cole\xE7\xE3o";
@@ -1801,7 +1901,7 @@ var getItemCategory6 = (item) => {
1801
1901
  const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
1802
1902
  return match != null ? match : "Cole\xE7\xE3o";
1803
1903
  };
1804
- var getItemCategory24 = (item) => {
1904
+ var getItemCategory25 = (item) => {
1805
1905
  var _a, _b;
1806
1906
  const AVOID_CATEGORIES = /outlet|bazar|sale/i;
1807
1907
  const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
@@ -1854,8 +1954,8 @@ var orderFormAdapter = {
1854
1954
  item_variant2: (_m = (_l = (_k = item == null ? void 0 : item.skuName) == null ? void 0 : _k.split(" - ")[1]) == null ? void 0 : _l.trim()) != null ? _m : null,
1855
1955
  item_shipping_tier: getItemShippingTier2(context.orderForm, item),
1856
1956
  item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
1857
- item_category: (_n = getItemCategory6(item)) != null ? _n : null,
1858
- item_category2: (_o = getItemCategory24(item)) != null ? _o : null,
1957
+ item_category: (_n = getItemCategory7(item)) != null ? _n : null,
1958
+ item_category2: (_o = getItemCategory25(item)) != null ? _o : null,
1859
1959
  item_id: (_p = item == null ? void 0 : item.productId) != null ? _p : null,
1860
1960
  item_sku: (_q = item == null ? void 0 : item.id) != null ? _q : null,
1861
1961
  item_url: (_r = item.detailUrl) != null ? _r : null,
@@ -2005,6 +2105,7 @@ var orderFormAdapter = {
2005
2105
  // src/formatter.ts
2006
2106
  var adapters = {
2007
2107
  DECO: decoAdapter,
2108
+ RESERVA: reservaAdapter,
2008
2109
  HEADLESS: headlessAdapter,
2009
2110
  PICKUP: pickupAdapter,
2010
2111
  ORDERFORM: orderFormAdapter,