@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.d.cts CHANGED
@@ -1397,6 +1397,130 @@ interface OrderForm {
1397
1397
  itemsOrdination: null;
1398
1398
  }
1399
1399
 
1400
+ interface SimilarItemSize {
1401
+ skuId: string;
1402
+ size: string;
1403
+ isAvailable: boolean;
1404
+ }
1405
+ interface SimilarItemMedia {
1406
+ src: string;
1407
+ type: string;
1408
+ }
1409
+ interface SimilarItemColor {
1410
+ colorId: string;
1411
+ colorLabel?: string | null;
1412
+ colorHex?: string | null;
1413
+ thumbUrl?: string | null;
1414
+ }
1415
+ interface SimilarItem {
1416
+ productId: string;
1417
+ categories: string[];
1418
+ color: SimilarItemColor;
1419
+ linkText?: string | null;
1420
+ tags?: string[] | null;
1421
+ sizes: SimilarItemSize[];
1422
+ media: SimilarItemMedia[];
1423
+ }
1424
+ type BestInstallment = {
1425
+ count: number;
1426
+ value: number;
1427
+ hasInterestRate: boolean;
1428
+ total: number;
1429
+ };
1430
+ type OfferWithInstallment = {
1431
+ availability?: string;
1432
+ price: number;
1433
+ listPrice: number;
1434
+ listPriceWithTaxes?: number;
1435
+ priceWithTaxes?: number;
1436
+ quantity?: number;
1437
+ seller?: {
1438
+ identifier: string;
1439
+ };
1440
+ bestInstallment?: BestInstallment | null;
1441
+ };
1442
+ type ProductOffers = {
1443
+ lowPrice?: number;
1444
+ lowPriceWithTaxes?: number;
1445
+ highPrice?: number;
1446
+ offers: OfferWithInstallment[];
1447
+ };
1448
+ type ProductAdditionalProperty = {
1449
+ propertyID?: string | null;
1450
+ name?: string | null;
1451
+ value?: unknown;
1452
+ valueReference?: string | null;
1453
+ };
1454
+ /** skuVariants fields shared by PLP (ProductSummary) and PDP (ProductDetails) fragments */
1455
+ type ProductSkuVariants = {
1456
+ activeVariations?: unknown | null;
1457
+ slugsMap?: unknown | null;
1458
+ availableVariations?: unknown | null;
1459
+ allVariantProducts?: Array<{
1460
+ name: string;
1461
+ productID: string;
1462
+ }> | null;
1463
+ /** PLP/search only (ProductSummary fragment) */
1464
+ allVariantsByName?: unknown | null;
1465
+ };
1466
+ /**
1467
+ * Shared product shape for PLP cards (ProductSummary) and PDP (ProductDetails).
1468
+ * Manual superset — both native GraphQL fragment types are assignable to it.
1469
+ */
1470
+ type ReservaProduct = {
1471
+ index?: number;
1472
+ item_list_name?: string;
1473
+ id: string;
1474
+ sku: string;
1475
+ name: string;
1476
+ isVariantOf: {
1477
+ productGroupID: string;
1478
+ name: string;
1479
+ skuVariants?: ProductSkuVariants | null;
1480
+ additionalProperty?: ProductAdditionalProperty[];
1481
+ };
1482
+ offers: ProductOffers;
1483
+ gtin?: string | null;
1484
+ unitMultiplier?: number | null;
1485
+ image?: Array<{
1486
+ url: string;
1487
+ alternateName?: string | null;
1488
+ }>;
1489
+ brand?: {
1490
+ name: string;
1491
+ brandName?: string;
1492
+ };
1493
+ additionalProperty?: ProductAdditionalProperty[];
1494
+ description?: string | null;
1495
+ slug?: string;
1496
+ hasSpecifications?: boolean | null;
1497
+ advertisement?: {
1498
+ adId: string;
1499
+ adResponseId: string;
1500
+ } | null;
1501
+ deliveryPromiseBadges?: Array<{
1502
+ typeName?: string | null;
1503
+ } | null> | null;
1504
+ breadcrumbList?: {
1505
+ itemListElement: Array<{
1506
+ name: string;
1507
+ position: number;
1508
+ item: string;
1509
+ }> | null;
1510
+ };
1511
+ mpn?: string | null;
1512
+ releaseDate?: string | null;
1513
+ seo?: {
1514
+ title?: string | null;
1515
+ description?: string | null;
1516
+ canonical?: string | null;
1517
+ };
1518
+ groupRefId?: string | null;
1519
+ similarItems?: SimilarItem[];
1520
+ otherLookProducts?: string | null;
1521
+ otherLookProductItems?: ReservaProduct[];
1522
+ };
1523
+
1400
1524
  declare const PROD_DOMAINS: Record<string, Record<string, string>>;
1401
1525
 
1402
1526
  declare global {
@@ -1459,6 +1583,9 @@ type AdapterPayload = ({
1459
1583
  } | {
1460
1584
  adapter: 'DECO';
1461
1585
  products: (Product & ProductMeta)[];
1586
+ } | {
1587
+ adapter: 'RESERVA';
1588
+ products: (ReservaProduct & ProductMeta)[];
1462
1589
  } | {
1463
1590
  adapter: 'ORDERFORM';
1464
1591
  orderForm: (OrderForm & ProductMeta)[];
package/dist/mod.d.ts CHANGED
@@ -1397,6 +1397,130 @@ interface OrderForm {
1397
1397
  itemsOrdination: null;
1398
1398
  }
1399
1399
 
1400
+ interface SimilarItemSize {
1401
+ skuId: string;
1402
+ size: string;
1403
+ isAvailable: boolean;
1404
+ }
1405
+ interface SimilarItemMedia {
1406
+ src: string;
1407
+ type: string;
1408
+ }
1409
+ interface SimilarItemColor {
1410
+ colorId: string;
1411
+ colorLabel?: string | null;
1412
+ colorHex?: string | null;
1413
+ thumbUrl?: string | null;
1414
+ }
1415
+ interface SimilarItem {
1416
+ productId: string;
1417
+ categories: string[];
1418
+ color: SimilarItemColor;
1419
+ linkText?: string | null;
1420
+ tags?: string[] | null;
1421
+ sizes: SimilarItemSize[];
1422
+ media: SimilarItemMedia[];
1423
+ }
1424
+ type BestInstallment = {
1425
+ count: number;
1426
+ value: number;
1427
+ hasInterestRate: boolean;
1428
+ total: number;
1429
+ };
1430
+ type OfferWithInstallment = {
1431
+ availability?: string;
1432
+ price: number;
1433
+ listPrice: number;
1434
+ listPriceWithTaxes?: number;
1435
+ priceWithTaxes?: number;
1436
+ quantity?: number;
1437
+ seller?: {
1438
+ identifier: string;
1439
+ };
1440
+ bestInstallment?: BestInstallment | null;
1441
+ };
1442
+ type ProductOffers = {
1443
+ lowPrice?: number;
1444
+ lowPriceWithTaxes?: number;
1445
+ highPrice?: number;
1446
+ offers: OfferWithInstallment[];
1447
+ };
1448
+ type ProductAdditionalProperty = {
1449
+ propertyID?: string | null;
1450
+ name?: string | null;
1451
+ value?: unknown;
1452
+ valueReference?: string | null;
1453
+ };
1454
+ /** skuVariants fields shared by PLP (ProductSummary) and PDP (ProductDetails) fragments */
1455
+ type ProductSkuVariants = {
1456
+ activeVariations?: unknown | null;
1457
+ slugsMap?: unknown | null;
1458
+ availableVariations?: unknown | null;
1459
+ allVariantProducts?: Array<{
1460
+ name: string;
1461
+ productID: string;
1462
+ }> | null;
1463
+ /** PLP/search only (ProductSummary fragment) */
1464
+ allVariantsByName?: unknown | null;
1465
+ };
1466
+ /**
1467
+ * Shared product shape for PLP cards (ProductSummary) and PDP (ProductDetails).
1468
+ * Manual superset — both native GraphQL fragment types are assignable to it.
1469
+ */
1470
+ type ReservaProduct = {
1471
+ index?: number;
1472
+ item_list_name?: string;
1473
+ id: string;
1474
+ sku: string;
1475
+ name: string;
1476
+ isVariantOf: {
1477
+ productGroupID: string;
1478
+ name: string;
1479
+ skuVariants?: ProductSkuVariants | null;
1480
+ additionalProperty?: ProductAdditionalProperty[];
1481
+ };
1482
+ offers: ProductOffers;
1483
+ gtin?: string | null;
1484
+ unitMultiplier?: number | null;
1485
+ image?: Array<{
1486
+ url: string;
1487
+ alternateName?: string | null;
1488
+ }>;
1489
+ brand?: {
1490
+ name: string;
1491
+ brandName?: string;
1492
+ };
1493
+ additionalProperty?: ProductAdditionalProperty[];
1494
+ description?: string | null;
1495
+ slug?: string;
1496
+ hasSpecifications?: boolean | null;
1497
+ advertisement?: {
1498
+ adId: string;
1499
+ adResponseId: string;
1500
+ } | null;
1501
+ deliveryPromiseBadges?: Array<{
1502
+ typeName?: string | null;
1503
+ } | null> | null;
1504
+ breadcrumbList?: {
1505
+ itemListElement: Array<{
1506
+ name: string;
1507
+ position: number;
1508
+ item: string;
1509
+ }> | null;
1510
+ };
1511
+ mpn?: string | null;
1512
+ releaseDate?: string | null;
1513
+ seo?: {
1514
+ title?: string | null;
1515
+ description?: string | null;
1516
+ canonical?: string | null;
1517
+ };
1518
+ groupRefId?: string | null;
1519
+ similarItems?: SimilarItem[];
1520
+ otherLookProducts?: string | null;
1521
+ otherLookProductItems?: ReservaProduct[];
1522
+ };
1523
+
1400
1524
  declare const PROD_DOMAINS: Record<string, Record<string, string>>;
1401
1525
 
1402
1526
  declare global {
@@ -1459,6 +1583,9 @@ type AdapterPayload = ({
1459
1583
  } | {
1460
1584
  adapter: 'DECO';
1461
1585
  products: (Product & ProductMeta)[];
1586
+ } | {
1587
+ adapter: 'RESERVA';
1588
+ products: (ReservaProduct & ProductMeta)[];
1462
1589
  } | {
1463
1590
  adapter: 'ORDERFORM';
1464
1591
  orderForm: (OrderForm & ProductMeta)[];
@@ -1569,8 +1569,108 @@ var AzzasTracker = (() => {
1569
1569
  }
1570
1570
  };
1571
1571
 
1572
- // src/params/adapters/headless/utils.ts
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 AzzasTracker = (() => {
1583
1683
  }
1584
1684
  return "Cole\xE7\xE3o";
1585
1685
  };
1586
- var getItemCategory23 = (item) => {
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 AzzasTracker = (() => {
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: getItemCategory5(item),
1617
- item_category2: (_m = getItemCategory23(item)) != null ? _m : null,
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 AzzasTracker = (() => {
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: getItemCategory5(item),
1679
- item_category2: (_j = getItemCategory23(item)) != null ? _j : null,
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 AzzasTracker = (() => {
1822
1922
  return { ...i, quantity: 1 };
1823
1923
  }) : orderForm.items;
1824
1924
  };
1825
- var getItemCategory6 = (item) => {
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 AzzasTracker = (() => {
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 getItemCategory24 = (item) => {
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 AzzasTracker = (() => {
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 = getItemCategory6(item)) != null ? _n : null,
1887
- item_category2: (_o = getItemCategory24(item)) != null ? _o : null,
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 AzzasTracker = (() => {
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,