@azzas/azzas-tracker-web 2.0.0-preview.1 → 2.0.0-preview.3
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 +123 -61
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +446 -0
- package/dist/mod.d.ts +446 -0
- package/dist/mod.global.js +123 -61
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +123 -61
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +134 -86
- package/package.json +1 -1
package/dist/mod.js
CHANGED
|
@@ -984,6 +984,12 @@ var sortSizes = (sizes) => {
|
|
|
984
984
|
return unique;
|
|
985
985
|
};
|
|
986
986
|
var capitalize = (str) => str ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
|
|
987
|
+
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
988
|
+
return url == null ? void 0 : url.replace(
|
|
989
|
+
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
990
|
+
`$1-${width}-${height}/`
|
|
991
|
+
);
|
|
992
|
+
};
|
|
987
993
|
|
|
988
994
|
// src/params/legacy/resolvers/paymentType/fromOrderForm.ts
|
|
989
995
|
function paymentTypeFromOrderForm(context) {
|
|
@@ -1405,12 +1411,6 @@ var getItemCategory22 = (item) => {
|
|
|
1405
1411
|
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1406
1412
|
return capitalize(deepest);
|
|
1407
1413
|
};
|
|
1408
|
-
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
1409
|
-
return url == null ? void 0 : url.replace(
|
|
1410
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1411
|
-
`$1-${width}-${height}/`
|
|
1412
|
-
);
|
|
1413
|
-
};
|
|
1414
1414
|
function getItemShippingTier2() {
|
|
1415
1415
|
return null;
|
|
1416
1416
|
}
|
|
@@ -1425,7 +1425,7 @@ var decoAdapter = {
|
|
|
1425
1425
|
if (context == null ? void 0 : context.items) return context.items;
|
|
1426
1426
|
if (context == null ? void 0 : context.products) {
|
|
1427
1427
|
return context.products.map((item) => {
|
|
1428
|
-
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;
|
|
1428
|
+
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;
|
|
1429
1429
|
const COLOR_REGEX = /^[^_]+_/;
|
|
1430
1430
|
const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
|
|
1431
1431
|
(s) => s.priceType === LIST_PRICE_SCHEMA
|
|
@@ -1436,21 +1436,21 @@ var decoAdapter = {
|
|
|
1436
1436
|
item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
|
|
1437
1437
|
item_name: (_h = item.alternateName) != null ? _h : null,
|
|
1438
1438
|
price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
|
|
1439
|
-
discount: Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice),
|
|
1439
|
+
discount: Math.round((Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice)) * 100) / 100,
|
|
1440
1440
|
item_variant: ((_m = (_l = item == null ? void 0 : item.name) == null ? void 0 : _l.split(" - ")[0]) == null ? void 0 : _m.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
|
|
1441
1441
|
// cor
|
|
1442
1442
|
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1443
1443
|
// tamanho
|
|
1444
1444
|
item_shipping_tier: getItemShippingTier2(),
|
|
1445
|
-
item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((
|
|
1446
|
-
item_category: (
|
|
1447
|
-
item_category2: (
|
|
1448
|
-
item_id: (
|
|
1449
|
-
item_sku: (
|
|
1450
|
-
item_url: (
|
|
1451
|
-
image_url: (
|
|
1452
|
-
seller_id: (
|
|
1453
|
-
item_list_name: (
|
|
1445
|
+
item_ref: (_s = (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find((i) => i.name === "RefId")) == null ? void 0 : _q.value) == null ? void 0 : _r.replace(/_\d+$/, "")) != null ? _s : null,
|
|
1446
|
+
item_category: (_t = getItemCategory3(item)) != null ? _t : null,
|
|
1447
|
+
item_category2: (_u = getItemCategory22(item)) != null ? _u : null,
|
|
1448
|
+
item_id: (_v = item == null ? void 0 : item.inProductGroupWithID) != null ? _v : null,
|
|
1449
|
+
item_sku: (_w = item.sku) != null ? _w : null,
|
|
1450
|
+
item_url: (_x = item.url) != null ? _x : null,
|
|
1451
|
+
image_url: (_z = resizeVtexImage2((_y = item == null ? void 0 : item.image) == null ? void 0 : _y[0].url)) != null ? _z : null,
|
|
1452
|
+
seller_id: (_D = (_C = (_B = (_A = item.offers) == null ? void 0 : _A.offers) == null ? void 0 : _B[0]) == null ? void 0 : _C.seller) != null ? _D : null,
|
|
1453
|
+
item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
|
|
1454
1454
|
};
|
|
1455
1455
|
});
|
|
1456
1456
|
}
|
|
@@ -1504,9 +1504,79 @@ var decoAdapter = {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
};
|
|
1506
1506
|
|
|
1507
|
+
// src/params/adapters/orderForm/utils.ts
|
|
1508
|
+
var getItemCategory5 = (item) => {
|
|
1509
|
+
var _a;
|
|
1510
|
+
const categories = item == null ? void 0 : item.productCategories;
|
|
1511
|
+
if (!categories) return "Cole\xE7\xE3o";
|
|
1512
|
+
const text = Object.values(categories).join(" ");
|
|
1513
|
+
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1514
|
+
return match != null ? match : "Cole\xE7\xE3o";
|
|
1515
|
+
};
|
|
1516
|
+
var getItemCategory23 = (item) => {
|
|
1517
|
+
var _a, _b;
|
|
1518
|
+
const AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
1519
|
+
const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
|
|
1520
|
+
const validHierarchy = categories.map((c) => c.trim()).filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1521
|
+
const deepest = (_b = validHierarchy[validHierarchy.length - 1]) != null ? _b : "";
|
|
1522
|
+
return capitalize(deepest);
|
|
1523
|
+
};
|
|
1524
|
+
var getOrderFormItems = (orderForm) => {
|
|
1525
|
+
const idSelected = orderForm == null ? void 0 : orderForm.selected;
|
|
1526
|
+
return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1507
1529
|
// src/params/adapters/orderForm/index.ts
|
|
1508
|
-
var
|
|
1509
|
-
|
|
1530
|
+
var orderFormAdapter = {
|
|
1531
|
+
...metaAdapters,
|
|
1532
|
+
items: (context) => {
|
|
1533
|
+
if (context == null ? void 0 : context.items) return context.items;
|
|
1534
|
+
if ((context == null ? void 0 : context.orderForm) && (context == null ? void 0 : context.orderForm.items)) {
|
|
1535
|
+
return getOrderFormItems(context.orderForm).map((item, index) => {
|
|
1536
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
1537
|
+
return {
|
|
1538
|
+
quantity: (_a = item == null ? void 0 : item.quantity) != null ? _a : 1,
|
|
1539
|
+
index: (_d = (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index) != null ? _d : null,
|
|
1540
|
+
item_brand: (_f = (_e = item.additionalInfo) == null ? void 0 : _e.brandName) != null ? _f : null,
|
|
1541
|
+
item_name: (_g = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _g : null,
|
|
1542
|
+
price: (item == null ? void 0 : item.price) / 100,
|
|
1543
|
+
discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
|
|
1544
|
+
item_variant: (_k = (_j = (_i = (_h = item == null ? void 0 : item.skuName) == null ? void 0 : _h.split(" - ")[0]) == null ? void 0 : _i.split("_").pop()) == null ? void 0 : _j.trim()) != null ? _k : null,
|
|
1545
|
+
item_variant2: (_n = (_m = (_l = item == null ? void 0 : item.skuName) == null ? void 0 : _l.split(" - ")[1]) == null ? void 0 : _m.trim()) != null ? _n : null,
|
|
1546
|
+
item_shipping_tier: "",
|
|
1547
|
+
item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
1548
|
+
item_category: (_o = getItemCategory5(item)) != null ? _o : null,
|
|
1549
|
+
item_category2: (_p = getItemCategory23(item)) != null ? _p : null,
|
|
1550
|
+
item_id: (_q = item == null ? void 0 : item.productId) != null ? _q : null,
|
|
1551
|
+
item_sku: (_r = item == null ? void 0 : item.id) != null ? _r : null,
|
|
1552
|
+
item_url: (_s = item.detailUrl) != null ? _s : null,
|
|
1553
|
+
image_url: (_t = resizeVtexImage2(item.imageUrl)) != null ? _t : null,
|
|
1554
|
+
seller_id: (_u = item == null ? void 0 : item.seller) != null ? _u : null,
|
|
1555
|
+
item_list_name: (_w = (_v = context == null ? void 0 : context.orderForm) == null ? void 0 : _v.item_list_name) != null ? _w : null
|
|
1556
|
+
};
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
return null;
|
|
1560
|
+
},
|
|
1561
|
+
// brand: (context: any) => {
|
|
1562
|
+
// if (context?.brand) return context.brand
|
|
1563
|
+
// if (context?.products) {
|
|
1564
|
+
// return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
|
|
1565
|
+
// }
|
|
1566
|
+
// return null
|
|
1567
|
+
// },
|
|
1568
|
+
line_items: (context) => {
|
|
1569
|
+
var _a;
|
|
1570
|
+
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1571
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1572
|
+
return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id));
|
|
1573
|
+
},
|
|
1574
|
+
value: (context) => {
|
|
1575
|
+
var _a;
|
|
1576
|
+
if (context == null ? void 0 : context.value) return context.value;
|
|
1577
|
+
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1578
|
+
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.price) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1579
|
+
},
|
|
1510
1580
|
payment_type: getPaymentType,
|
|
1511
1581
|
total_discount: (context) => {
|
|
1512
1582
|
var _a, _b;
|
|
@@ -1537,6 +1607,10 @@ var orderFormAdapters = {
|
|
|
1537
1607
|
if (couponMessages.length === 0) return null;
|
|
1538
1608
|
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1539
1609
|
},
|
|
1610
|
+
zipcode: (context) => {
|
|
1611
|
+
var _a;
|
|
1612
|
+
return (_a = context.zipcode) != null ? _a : null;
|
|
1613
|
+
},
|
|
1540
1614
|
flag_pickup: (context) => {
|
|
1541
1615
|
var _a;
|
|
1542
1616
|
const orderForm = context.orderForm;
|
|
@@ -1551,32 +1625,23 @@ var orderFormAdapters = {
|
|
|
1551
1625
|
return hasPickup;
|
|
1552
1626
|
},
|
|
1553
1627
|
shippings: (context) => {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
const item =
|
|
1559
|
-
if (!item)
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
const shippings = Object.values(groupShipping).map((s) => ({
|
|
1574
|
-
shipping: s.shipping,
|
|
1575
|
-
shipping_tier: s.shipping_tier,
|
|
1576
|
-
delivery_time: s.delivery_time,
|
|
1577
|
-
line_items: s.line_items.join(",")
|
|
1578
|
-
}));
|
|
1579
|
-
return shippings || null;
|
|
1628
|
+
if (!context.orderForm) return null;
|
|
1629
|
+
const { items, shippingData } = context.orderForm;
|
|
1630
|
+
const acc = {};
|
|
1631
|
+
shippingData.logisticsInfo.forEach(({ itemIndex, slas }) => {
|
|
1632
|
+
const item = items[itemIndex];
|
|
1633
|
+
if (!item) return;
|
|
1634
|
+
slas.forEach((sla) => {
|
|
1635
|
+
if (!acc[sla.name]) acc[sla.name] = {
|
|
1636
|
+
shipping_tier: sla.name,
|
|
1637
|
+
delivery_time: parseInt(sla.shippingEstimate),
|
|
1638
|
+
shipping: parseFloat((sla.price / 100).toFixed(1)),
|
|
1639
|
+
line_items: []
|
|
1640
|
+
};
|
|
1641
|
+
acc[sla.name].line_items.push(item.id);
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
return Object.values(acc).map((s) => ({ ...s, line_items: s.line_items.join(",") }));
|
|
1580
1645
|
},
|
|
1581
1646
|
shipping: (context) => {
|
|
1582
1647
|
var _a, _b, _c;
|
|
@@ -1634,7 +1699,7 @@ var orderFormAdapters = {
|
|
|
1634
1699
|
};
|
|
1635
1700
|
|
|
1636
1701
|
// src/params/adapters/headless/utils.ts
|
|
1637
|
-
var
|
|
1702
|
+
var getItemCategory6 = (item) => {
|
|
1638
1703
|
const keywords = ["outlet", "bazar", "sale"];
|
|
1639
1704
|
const regex = new RegExp(keywords.join("|"), "i");
|
|
1640
1705
|
const value = item == null ? void 0 : item.categories;
|
|
@@ -1647,7 +1712,7 @@ var getItemCategory5 = (item) => {
|
|
|
1647
1712
|
}
|
|
1648
1713
|
return "Cole\xE7\xE3o";
|
|
1649
1714
|
};
|
|
1650
|
-
var
|
|
1715
|
+
var getItemCategory24 = (item) => {
|
|
1651
1716
|
var _a, _b, _c;
|
|
1652
1717
|
const avoidList = /outlet|bazar|sale/i;
|
|
1653
1718
|
const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
|
|
@@ -1655,12 +1720,6 @@ var getItemCategory23 = (item) => {
|
|
|
1655
1720
|
const deepestCategory = (_c = [...categoryHierarchy].reverse().find((c) => !avoidList.test(c))) != null ? _c : "";
|
|
1656
1721
|
return deepestCategory && deepestCategory[0].toUpperCase() + deepestCategory.slice(1).toLowerCase();
|
|
1657
1722
|
};
|
|
1658
|
-
function resizeVtexImage3(url, width = 500, height = 500) {
|
|
1659
|
-
return url == null ? void 0 : url.replace(
|
|
1660
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1661
|
-
`$1-${width}-${height}/`
|
|
1662
|
-
);
|
|
1663
|
-
}
|
|
1664
1723
|
|
|
1665
1724
|
// src/params/adapters/headless/zones/PDP.ts
|
|
1666
1725
|
var HeadlessPdpZone = {
|
|
@@ -1677,18 +1736,19 @@ var HeadlessPdpZone = {
|
|
|
1677
1736
|
item_brand: (_d = item.brand) != null ? _d : null,
|
|
1678
1737
|
item_name: (_e = item.productName) != null ? _e : null,
|
|
1679
1738
|
price: price != null ? price : null,
|
|
1739
|
+
item_shipping_tier: null,
|
|
1680
1740
|
discount: Number(listPrice) - Number(price),
|
|
1681
1741
|
item_variant: (_h = (_g = (_f = item.items[0]) == null ? void 0 : _f.name) == null ? void 0 : _g.split(" - ")[0]) != null ? _h : null,
|
|
1682
1742
|
item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
|
|
1683
1743
|
item_ref: (_l = item.productReference) != null ? _l : null,
|
|
1684
1744
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1685
|
-
item_category:
|
|
1686
|
-
item_category2: (_m =
|
|
1745
|
+
item_category: getItemCategory6(item),
|
|
1746
|
+
item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
|
|
1687
1747
|
item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
|
|
1688
1748
|
item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
|
|
1689
1749
|
item_url: (_q = item.link) != null ? _q : null,
|
|
1690
1750
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1691
|
-
image_url: (_t =
|
|
1751
|
+
image_url: (_t = resizeVtexImage2((_s = (_r = item == null ? void 0 : item.items) == null ? void 0 : _r[0].images) == null ? void 0 : _s[0].imageUrl)) != null ? _t : null,
|
|
1692
1752
|
seller_id: (_x = (_w = (_v = (_u = item.items) == null ? void 0 : _u[0]) == null ? void 0 : _v.sellers) == null ? void 0 : _w[0].sellerId) != null ? _x : null,
|
|
1693
1753
|
item_list_name: (_y = item.item_list_name) != null ? _y : null
|
|
1694
1754
|
};
|
|
@@ -1737,18 +1797,19 @@ var HeadlessPdcZone = {
|
|
|
1737
1797
|
item_brand: (_b = item.brand.name) != null ? _b : null,
|
|
1738
1798
|
item_name: (_c = item.name) != null ? _c : null,
|
|
1739
1799
|
price: price != null ? price : null,
|
|
1800
|
+
item_shipping_tier: null,
|
|
1740
1801
|
discount: Number(listPrice) - Number(price),
|
|
1741
1802
|
item_variant: (_f = (_e = (_d = item.isVariantOf) == null ? void 0 : _d.hasVariant) == null ? void 0 : _e[0].name.split(" - ")[0]) != null ? _f : null,
|
|
1742
1803
|
item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
|
|
1743
1804
|
item_ref: null,
|
|
1744
1805
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1745
|
-
item_category:
|
|
1746
|
-
item_category2: (_j =
|
|
1806
|
+
item_category: getItemCategory6(item),
|
|
1807
|
+
item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
|
|
1747
1808
|
item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
|
|
1748
1809
|
item_sku: (_l = item.sku) != null ? _l : null,
|
|
1749
1810
|
item_url: null,
|
|
1750
1811
|
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
1751
|
-
image_url: (_n =
|
|
1812
|
+
image_url: (_n = resizeVtexImage2((_m = item == null ? void 0 : item.image) == null ? void 0 : _m[0].url)) != null ? _n : null,
|
|
1752
1813
|
seller_id: (_s = (_r = (_q = (_p = (_o = item.offers) == null ? void 0 : _o.offers) == null ? void 0 : _p.find((o) => o.availability)) == null ? void 0 : _q.seller) == null ? void 0 : _r.identifier) != null ? _s : null,
|
|
1753
1814
|
item_list_name: (_t = item.item_list_name) != null ? _t : null
|
|
1754
1815
|
};
|
|
@@ -1783,7 +1844,7 @@ var HeadlessPdcZone = {
|
|
|
1783
1844
|
var headlessAdapter = {
|
|
1784
1845
|
...metaAdapters,
|
|
1785
1846
|
// global adapters
|
|
1786
|
-
...
|
|
1847
|
+
...orderFormAdapter,
|
|
1787
1848
|
// orderForm adapters, confirmar se no storefront tem evento que usa essses params
|
|
1788
1849
|
brand: (context) => {
|
|
1789
1850
|
if (context.zone === "PDP") {
|
|
@@ -1880,7 +1941,8 @@ var pickupAdapter = {
|
|
|
1880
1941
|
var adapters = {
|
|
1881
1942
|
DECO: decoAdapter,
|
|
1882
1943
|
HEADLESS: headlessAdapter,
|
|
1883
|
-
PICKUP: pickupAdapter
|
|
1944
|
+
PICKUP: pickupAdapter,
|
|
1945
|
+
ORDERFORM: orderFormAdapter
|
|
1884
1946
|
};
|
|
1885
1947
|
async function getParameters(context, eventName) {
|
|
1886
1948
|
var _a;
|