@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.cjs +111 -10
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +127 -0
- package/dist/mod.d.ts +127 -0
- package/dist/mod.global.js +111 -10
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +111 -10
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +129 -13
- package/package.json +1 -1
package/dist/mod.cjs
CHANGED
|
@@ -1569,8 +1569,108 @@ var decoAdapter = {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
};
|
|
1571
1571
|
|
|
1572
|
-
// src/params/adapters/
|
|
1572
|
+
// src/params/adapters/reserva/utils.ts
|
|
1573
1573
|
var getItemCategory5 = (item) => {
|
|
1574
|
+
var _a, _b, _c;
|
|
1575
|
+
const categories = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories;
|
|
1576
|
+
if (!(categories == null ? void 0 : categories.length)) return "Cole\xE7\xE3o";
|
|
1577
|
+
const match = (_c = categories.join(" ").match(/outlet|bazar|sale/i)) == null ? void 0 : _c[0].toLowerCase();
|
|
1578
|
+
return match != null ? match : "Cole\xE7\xE3o";
|
|
1579
|
+
};
|
|
1580
|
+
var getItemCategory23 = (item) => {
|
|
1581
|
+
var _a, _b, _c, _d;
|
|
1582
|
+
const AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
|
|
1583
|
+
const categories = (_c = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories) != null ? _c : [];
|
|
1584
|
+
const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1585
|
+
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1586
|
+
return capitalize(deepest);
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
// src/params/adapters/reserva/index.ts
|
|
1590
|
+
var reservaAdapter = {
|
|
1591
|
+
...metaAdapter,
|
|
1592
|
+
// global adapters
|
|
1593
|
+
items: (context) => {
|
|
1594
|
+
if (context == null ? void 0 : context.items) return context.items;
|
|
1595
|
+
if (context == null ? void 0 : context.products) {
|
|
1596
|
+
return context.products.map((item) => {
|
|
1597
|
+
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;
|
|
1598
|
+
const COLOR_REGEX = /^[^_]+_/;
|
|
1599
|
+
const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
|
|
1600
|
+
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+$/, "");
|
|
1601
|
+
return {
|
|
1602
|
+
quantity: 1,
|
|
1603
|
+
index: (_f = item == null ? void 0 : item.index) != null ? _f : 0,
|
|
1604
|
+
item_brand: (_i = (_h = (_g = item.brand) == null ? void 0 : _g.name) == null ? void 0 : _h.toLowerCase()) != null ? _i : null,
|
|
1605
|
+
item_name: (_j = item.name) != null ? _j : null,
|
|
1606
|
+
price: (_l = (_k = item.offers) == null ? void 0 : _k.lowPrice) != null ? _l : null,
|
|
1607
|
+
discount: Math.round((Number(listPrice) - Number((_m = item == null ? void 0 : item.offers) == null ? void 0 : _m.lowPrice)) * 100) / 100,
|
|
1608
|
+
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,
|
|
1609
|
+
// cor
|
|
1610
|
+
item_variant2: (_q = (_p = item == null ? void 0 : item.name) == null ? void 0 : _p.split(" - ")[1]) != null ? _q : null,
|
|
1611
|
+
// tamanho
|
|
1612
|
+
item_shipping_tier: "",
|
|
1613
|
+
item_ref: refIdValue != null ? refIdValue : null,
|
|
1614
|
+
item_category: (_r = getItemCategory5(item)) != null ? _r : null,
|
|
1615
|
+
item_category2: (_s = getItemCategory23(item)) != null ? _s : null,
|
|
1616
|
+
item_id: (_t = item == null ? void 0 : item.id) != null ? _t : null,
|
|
1617
|
+
item_sku: (_u = item == null ? void 0 : item.sku) != null ? _u : null,
|
|
1618
|
+
item_url: (_w = (_v = item == null ? void 0 : item.seo) == null ? void 0 : _v.canonical) != null ? _w : null,
|
|
1619
|
+
image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
|
|
1620
|
+
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,
|
|
1621
|
+
item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
|
|
1622
|
+
};
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
return null;
|
|
1626
|
+
},
|
|
1627
|
+
brand: (context, config2) => {
|
|
1628
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1629
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1630
|
+
if (context == null ? void 0 : context.products) {
|
|
1631
|
+
return normalizeBrand2(context.products.map((p) => {
|
|
1632
|
+
var _a;
|
|
1633
|
+
return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
|
|
1634
|
+
}));
|
|
1635
|
+
}
|
|
1636
|
+
return null;
|
|
1637
|
+
},
|
|
1638
|
+
line_items: (context) => {
|
|
1639
|
+
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1640
|
+
if (context == null ? void 0 : context.products) {
|
|
1641
|
+
return context.products.map((item) => item == null ? void 0 : item.id).filter((id) => Boolean(id)).join();
|
|
1642
|
+
}
|
|
1643
|
+
return null;
|
|
1644
|
+
},
|
|
1645
|
+
value: (context) => {
|
|
1646
|
+
if (context == null ? void 0 : context.value) return context.value;
|
|
1647
|
+
if (context == null ? void 0 : context.products) {
|
|
1648
|
+
return context.products.map((item) => {
|
|
1649
|
+
var _a;
|
|
1650
|
+
return (_a = item.offers) == null ? void 0 : _a.lowPrice;
|
|
1651
|
+
}).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1652
|
+
}
|
|
1653
|
+
return null;
|
|
1654
|
+
},
|
|
1655
|
+
available_grid: (context) => {
|
|
1656
|
+
if (context == null ? void 0 : context.available_grid) return context.available_grid;
|
|
1657
|
+
if (context == null ? void 0 : context.products) {
|
|
1658
|
+
const sizes = context.products.filter((product) => {
|
|
1659
|
+
var _a, _b;
|
|
1660
|
+
return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
|
|
1661
|
+
}).map((product) => {
|
|
1662
|
+
var _a;
|
|
1663
|
+
return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
|
|
1664
|
+
}).filter((name) => Boolean(name));
|
|
1665
|
+
const result = sortSizes(sizes).join(",").trim();
|
|
1666
|
+
return result || null;
|
|
1667
|
+
}
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
// src/params/adapters/headless/utils.ts
|
|
1673
|
+
var getItemCategory6 = (item) => {
|
|
1574
1674
|
const keywords = ["outlet", "bazar", "sale"];
|
|
1575
1675
|
const regex = new RegExp(keywords.join("|"), "i");
|
|
1576
1676
|
const value = item == null ? void 0 : item.categories;
|
|
@@ -1583,7 +1683,7 @@ var getItemCategory5 = (item) => {
|
|
|
1583
1683
|
}
|
|
1584
1684
|
return "Cole\xE7\xE3o";
|
|
1585
1685
|
};
|
|
1586
|
-
var
|
|
1686
|
+
var getItemCategory24 = (item) => {
|
|
1587
1687
|
var _a, _b, _c;
|
|
1588
1688
|
const avoidList = /outlet|bazar|sale/i;
|
|
1589
1689
|
const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
|
|
@@ -1613,8 +1713,8 @@ var HeadlessPdpZone = {
|
|
|
1613
1713
|
item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
|
|
1614
1714
|
item_ref: (_l = item.productReference) != null ? _l : null,
|
|
1615
1715
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1616
|
-
item_category:
|
|
1617
|
-
item_category2: (_m =
|
|
1716
|
+
item_category: getItemCategory6(item),
|
|
1717
|
+
item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
|
|
1618
1718
|
item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
|
|
1619
1719
|
item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
|
|
1620
1720
|
item_url: (_q = item.link) != null ? _q : null,
|
|
@@ -1675,8 +1775,8 @@ var HeadlessPdcZone = {
|
|
|
1675
1775
|
item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
|
|
1676
1776
|
item_ref: null,
|
|
1677
1777
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1678
|
-
item_category:
|
|
1679
|
-
item_category2: (_j =
|
|
1778
|
+
item_category: getItemCategory6(item),
|
|
1779
|
+
item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
|
|
1680
1780
|
item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
|
|
1681
1781
|
item_sku: (_l = item.sku) != null ? _l : null,
|
|
1682
1782
|
item_url: null,
|
|
@@ -1822,7 +1922,7 @@ var getOrderFormItems = (orderForm) => {
|
|
|
1822
1922
|
return { ...i, quantity: 1 };
|
|
1823
1923
|
}) : orderForm.items;
|
|
1824
1924
|
};
|
|
1825
|
-
var
|
|
1925
|
+
var getItemCategory7 = (item) => {
|
|
1826
1926
|
var _a;
|
|
1827
1927
|
const categories = item == null ? void 0 : item.productCategories;
|
|
1828
1928
|
if (!categories) return "Cole\xE7\xE3o";
|
|
@@ -1830,7 +1930,7 @@ var getItemCategory6 = (item) => {
|
|
|
1830
1930
|
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1831
1931
|
return match != null ? match : "Cole\xE7\xE3o";
|
|
1832
1932
|
};
|
|
1833
|
-
var
|
|
1933
|
+
var getItemCategory25 = (item) => {
|
|
1834
1934
|
var _a, _b;
|
|
1835
1935
|
const AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
1836
1936
|
const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
|
|
@@ -1883,8 +1983,8 @@ var orderFormAdapter = {
|
|
|
1883
1983
|
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,
|
|
1884
1984
|
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
1885
1985
|
item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
1886
|
-
item_category: (_n =
|
|
1887
|
-
item_category2: (_o =
|
|
1986
|
+
item_category: (_n = getItemCategory7(item)) != null ? _n : null,
|
|
1987
|
+
item_category2: (_o = getItemCategory25(item)) != null ? _o : null,
|
|
1888
1988
|
item_id: (_p = item == null ? void 0 : item.productId) != null ? _p : null,
|
|
1889
1989
|
item_sku: (_q = item == null ? void 0 : item.id) != null ? _q : null,
|
|
1890
1990
|
item_url: (_r = item.detailUrl) != null ? _r : null,
|
|
@@ -2034,6 +2134,7 @@ var orderFormAdapter = {
|
|
|
2034
2134
|
// src/formatter.ts
|
|
2035
2135
|
var adapters = {
|
|
2036
2136
|
DECO: decoAdapter,
|
|
2137
|
+
RESERVA: reservaAdapter,
|
|
2037
2138
|
HEADLESS: headlessAdapter,
|
|
2038
2139
|
PICKUP: pickupAdapter,
|
|
2039
2140
|
ORDERFORM: orderFormAdapter,
|