@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.
@@ -2633,8 +2633,123 @@ var AzzasTracker = function() {
2633
2633
  return null;
2634
2634
  }
2635
2635
  });
2636
- // src/params/adapters/headless/utils.ts
2636
+ // src/params/adapters/reserva/utils.ts
2637
2637
  var getItemCategory5 = function(item) {
2638
+ var _item_similarItems_, _item_similarItems, _categories_join_match;
2639
+ var categories = item === null || item === void 0 ? void 0 : (_item_similarItems = item.similarItems) === null || _item_similarItems === void 0 ? void 0 : (_item_similarItems_ = _item_similarItems[0]) === null || _item_similarItems_ === void 0 ? void 0 : _item_similarItems_.categories;
2640
+ if (!(categories === null || categories === void 0 ? void 0 : categories.length)) return "Cole\xE7\xE3o";
2641
+ var match = (_categories_join_match = categories.join(" ").match(/outlet|bazar|sale/i)) === null || _categories_join_match === void 0 ? void 0 : _categories_join_match[0].toLowerCase();
2642
+ return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
2643
+ };
2644
+ var getItemCategory23 = function(item) {
2645
+ var _ref, _validHierarchy_;
2646
+ var _item_similarItems_, _item_similarItems;
2647
+ var AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
2648
+ var categories = (_ref = item === null || item === void 0 ? void 0 : (_item_similarItems = item.similarItems) === null || _item_similarItems === void 0 ? void 0 : (_item_similarItems_ = _item_similarItems[0]) === null || _item_similarItems_ === void 0 ? void 0 : _item_similarItems_.categories) !== null && _ref !== void 0 ? _ref : [];
2649
+ var validHierarchy = categories.filter(function(c) {
2650
+ return c && !AVOID_CATEGORIES.test(c);
2651
+ });
2652
+ var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
2653
+ return capitalize(deepest);
2654
+ };
2655
+ // src/params/adapters/reserva/index.ts
2656
+ var reservaAdapter = _object_spread_props(_object_spread({}, metaAdapter), {
2657
+ // global adapters
2658
+ items: function(context) {
2659
+ if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2660
+ if (context === null || context === void 0 ? void 0 : context.products) {
2661
+ return context.products.map(function(item) {
2662
+ var _ref, _ref1, _item_name, _ref2, _ref3, _getItemCategory5, _getItemCategory23, _ref4, _ref5, _ref6, _resizeVtexImage2, _ref7, _ref8;
2663
+ var _item_offers_offers, _item_offers, _item_additionalProperty_find_value, _item_additionalProperty_find, _item_additionalProperty, _item_brand_name, _item_brand, _item_offers1, _item_offers2, _item_name_split_, _item_name1, _item_name2, _item_seo, _item_image, _item_offers_offers__seller, _item_offers_offers_, _item_offers_offers1, _item_offers3;
2664
+ var COLOR_REGEX = /^[^_]+_/;
2665
+ var listPrice = item === null || item === void 0 ? void 0 : (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : (_item_offers_offers = _item_offers.offers) === null || _item_offers_offers === void 0 ? void 0 : _item_offers_offers[0].listPrice;
2666
+ var refIdValue = (_item_additionalProperty = item.additionalProperty) === null || _item_additionalProperty === void 0 ? void 0 : (_item_additionalProperty_find = _item_additionalProperty.find(function(i) {
2667
+ return i.name === "RefId";
2668
+ })) === null || _item_additionalProperty_find === void 0 ? void 0 : (_item_additionalProperty_find_value = _item_additionalProperty_find.value) === null || _item_additionalProperty_find_value === void 0 ? void 0 : _item_additionalProperty_find_value.replace(/_\d+$/, "");
2669
+ return {
2670
+ quantity: 1,
2671
+ index: (_ref = item === null || item === void 0 ? void 0 : item.index) !== null && _ref !== void 0 ? _ref : 0,
2672
+ item_brand: (_ref1 = (_item_brand = item.brand) === null || _item_brand === void 0 ? void 0 : (_item_brand_name = _item_brand.name) === null || _item_brand_name === void 0 ? void 0 : _item_brand_name.toLowerCase()) !== null && _ref1 !== void 0 ? _ref1 : null,
2673
+ item_name: (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : null,
2674
+ price: (_ref2 = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : _item_offers1.lowPrice) !== null && _ref2 !== void 0 ? _ref2 : null,
2675
+ discount: Math.round((Number(listPrice) - Number(item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : _item_offers2.lowPrice)) * 100) / 100,
2676
+ item_variant: (item === null || item === void 0 ? void 0 : (_item_name1 = item.name) === null || _item_name1 === void 0 ? void 0 : (_item_name_split_ = _item_name1.split(" - ")[0]) === null || _item_name_split_ === void 0 ? void 0 : _item_name_split_.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
2677
+ // cor
2678
+ item_variant2: (_ref3 = item === null || item === void 0 ? void 0 : (_item_name2 = item.name) === null || _item_name2 === void 0 ? void 0 : _item_name2.split(" - ")[1]) !== null && _ref3 !== void 0 ? _ref3 : null,
2679
+ // tamanho
2680
+ item_shipping_tier: "",
2681
+ item_ref: refIdValue !== null && refIdValue !== void 0 ? refIdValue : null,
2682
+ item_category: (_getItemCategory5 = getItemCategory5(item)) !== null && _getItemCategory5 !== void 0 ? _getItemCategory5 : null,
2683
+ item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
2684
+ item_id: (_ref4 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref4 !== void 0 ? _ref4 : null,
2685
+ item_sku: (_ref5 = item === null || item === void 0 ? void 0 : item.sku) !== null && _ref5 !== void 0 ? _ref5 : null,
2686
+ item_url: (_ref6 = item === null || item === void 0 ? void 0 : (_item_seo = item.seo) === null || _item_seo === void 0 ? void 0 : _item_seo.canonical) !== null && _ref6 !== void 0 ? _ref6 : null,
2687
+ image_url: (_resizeVtexImage2 = resizeVtexImage2(item === null || item === void 0 ? void 0 : (_item_image = item.image) === null || _item_image === void 0 ? void 0 : _item_image[0].url)) !== null && _resizeVtexImage2 !== void 0 ? _resizeVtexImage2 : null,
2688
+ seller_id: (_ref7 = (_item_offers3 = item.offers) === null || _item_offers3 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers3.offers) === null || _item_offers_offers1 === void 0 ? void 0 : (_item_offers_offers_ = _item_offers_offers1[0]) === null || _item_offers_offers_ === void 0 ? void 0 : (_item_offers_offers__seller = _item_offers_offers_.seller) === null || _item_offers_offers__seller === void 0 ? void 0 : _item_offers_offers__seller.identifier) !== null && _ref7 !== void 0 ? _ref7 : null,
2689
+ item_list_name: (_ref8 = item === null || item === void 0 ? void 0 : item.item_list_name) !== null && _ref8 !== void 0 ? _ref8 : null
2690
+ };
2691
+ });
2692
+ }
2693
+ return null;
2694
+ },
2695
+ brand: function(context, config2) {
2696
+ if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
2697
+ if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
2698
+ if (context === null || context === void 0 ? void 0 : context.products) {
2699
+ return normalizeBrand2(context.products.map(function(p) {
2700
+ var _p_brand;
2701
+ return p === null || p === void 0 ? void 0 : (_p_brand = p.brand) === null || _p_brand === void 0 ? void 0 : _p_brand.name;
2702
+ }));
2703
+ }
2704
+ return null;
2705
+ },
2706
+ line_items: function(context) {
2707
+ if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
2708
+ if (context === null || context === void 0 ? void 0 : context.products) {
2709
+ return context.products.map(function(item) {
2710
+ return item === null || item === void 0 ? void 0 : item.id;
2711
+ }).filter(function(id) {
2712
+ return Boolean(id);
2713
+ }).join();
2714
+ }
2715
+ return null;
2716
+ },
2717
+ value: function(context) {
2718
+ if (context === null || context === void 0 ? void 0 : context.value) return context.value;
2719
+ if (context === null || context === void 0 ? void 0 : context.products) {
2720
+ return context.products.map(function(item) {
2721
+ var _item_offers;
2722
+ return (_item_offers = item.offers) === null || _item_offers === void 0 ? void 0 : _item_offers.lowPrice;
2723
+ }).filter(function(price) {
2724
+ return price !== void 0;
2725
+ }).reduce(function(sum, price) {
2726
+ return sum + price;
2727
+ }, 0);
2728
+ }
2729
+ return null;
2730
+ },
2731
+ available_grid: function(context) {
2732
+ if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
2733
+ if (context === null || context === void 0 ? void 0 : context.products) {
2734
+ var sizes = context.products.filter(function(product) {
2735
+ var _product_offers_offers, _product_offers;
2736
+ return (_product_offers = product.offers) === null || _product_offers === void 0 ? void 0 : (_product_offers_offers = _product_offers.offers) === null || _product_offers_offers === void 0 ? void 0 : _product_offers_offers.some(function(o) {
2737
+ return o.availability === "https://schema.org/InStock";
2738
+ });
2739
+ }).map(function(product) {
2740
+ var _product_name;
2741
+ return (_product_name = product.name) === null || _product_name === void 0 ? void 0 : _product_name.split(" - ")[1];
2742
+ }).filter(function(name) {
2743
+ return Boolean(name);
2744
+ });
2745
+ var result = sortSizes(sizes).join(",").trim();
2746
+ return result || null;
2747
+ }
2748
+ return null;
2749
+ }
2750
+ });
2751
+ // src/params/adapters/headless/utils.ts
2752
+ var getItemCategory6 = function(item) {
2638
2753
  var keywords = [
2639
2754
  "outlet",
2640
2755
  "bazar",
@@ -2651,7 +2766,7 @@ var AzzasTracker = function() {
2651
2766
  }
2652
2767
  return "Cole\xE7\xE3o";
2653
2768
  };
2654
- var getItemCategory23 = function(item) {
2769
+ var getItemCategory24 = function(item) {
2655
2770
  var _ref, _reverse_find;
2656
2771
  var _item_categories;
2657
2772
  var avoidList = /outlet|bazar|sale/i;
@@ -2668,7 +2783,7 @@ var AzzasTracker = function() {
2668
2783
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2669
2784
  if (context === null || context === void 0 ? void 0 : context.products) {
2670
2785
  return context.products.map(function(item) {
2671
- var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory23, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
2786
+ var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory24, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
2672
2787
  var _item_items__sellers, _item_items__sellers1, _item_items__name, _item_items_, _item_items__name1, _item_items_1, _item_items, _item_items__images, _item_items1, _item_items__sellers2, _item_items_2, _item_items2;
2673
2788
  var listPrice = item === null || item === void 0 ? void 0 : (_item_items__sellers = item.items[0].sellers) === null || _item_items__sellers === void 0 ? void 0 : _item_items__sellers[0].commertialOffer.ListPrice;
2674
2789
  var price = item === null || item === void 0 ? void 0 : (_item_items__sellers1 = item.items[0].sellers) === null || _item_items__sellers1 === void 0 ? void 0 : _item_items__sellers1[0].commertialOffer.Price;
@@ -2684,8 +2799,8 @@ var AzzasTracker = function() {
2684
2799
  item_variant2: (_ref2 = (_item_items_1 = item.items[0]) === null || _item_items_1 === void 0 ? void 0 : (_item_items__name1 = _item_items_1.name) === null || _item_items__name1 === void 0 ? void 0 : _item_items__name1.split(" - ")[1]) !== null && _ref2 !== void 0 ? _ref2 : null,
2685
2800
  item_ref: (_item_productReference = item.productReference) !== null && _item_productReference !== void 0 ? _item_productReference : null,
2686
2801
  // sem ref no retorno do IS na multi-lib produtos PDC
2687
- item_category: getItemCategory5(item),
2688
- item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
2802
+ item_category: getItemCategory6(item),
2803
+ item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
2689
2804
  item_id: (_ref3 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : null,
2690
2805
  item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
2691
2806
  item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
@@ -2740,7 +2855,7 @@ var AzzasTracker = function() {
2740
2855
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2741
2856
  if (context === null || context === void 0 ? void 0 : context.products) {
2742
2857
  return context.products.map(function(item) {
2743
- var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory23, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
2858
+ var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory24, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
2744
2859
  var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
2745
2860
  var listPrice = item.offers.highPrice;
2746
2861
  var price = item.offers.lowPrice;
@@ -2758,8 +2873,8 @@ var AzzasTracker = function() {
2758
2873
  })) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
2759
2874
  item_ref: null,
2760
2875
  // sem ref no retorno do IS na multi-lib produtos PDC
2761
- item_category: getItemCategory5(item),
2762
- item_category2: (_getItemCategory23 = getItemCategory23(item)) !== null && _getItemCategory23 !== void 0 ? _getItemCategory23 : null,
2876
+ item_category: getItemCategory6(item),
2877
+ item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
2763
2878
  item_id: (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
2764
2879
  item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
2765
2880
  item_url: null,
@@ -2921,7 +3036,7 @@ var AzzasTracker = function() {
2921
3036
  });
2922
3037
  }) : orderForm.items;
2923
3038
  };
2924
- var getItemCategory6 = function(item) {
3039
+ var getItemCategory7 = function(item) {
2925
3040
  var _text_match;
2926
3041
  var categories = item === null || item === void 0 ? void 0 : item.productCategories;
2927
3042
  if (!categories) return "Cole\xE7\xE3o";
@@ -2929,7 +3044,7 @@ var AzzasTracker = function() {
2929
3044
  var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
2930
3045
  return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
2931
3046
  };
2932
- var getItemCategory24 = function(item) {
3047
+ var getItemCategory25 = function(item) {
2933
3048
  var _ref, _validHierarchy_;
2934
3049
  var AVOID_CATEGORIES = /outlet|bazar|sale/i;
2935
3050
  var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
@@ -2973,7 +3088,7 @@ var AzzasTracker = function() {
2973
3088
  if (context === null || context === void 0 ? void 0 : context.items) return context.items;
2974
3089
  if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
2975
3090
  return getOrderFormItems(context.orderForm).map(function(item, index) {
2976
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _getItemCategory6, _getItemCategory24, _ref6, _ref7, _item_detailUrl, _resizeVtexImage2, _ref8, _ref9;
3091
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _getItemCategory7, _getItemCategory25, _ref6, _ref7, _item_detailUrl, _resizeVtexImage2, _ref8, _ref9;
2977
3092
  var _context_orderForm, _item_additionalInfo, _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm1;
2978
3093
  return {
2979
3094
  quantity: (_ref = item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1,
@@ -2986,8 +3101,8 @@ var AzzasTracker = function() {
2986
3101
  item_variant2: (_ref5 = item === null || item === void 0 ? void 0 : (_item_skuName1 = item.skuName) === null || _item_skuName1 === void 0 ? void 0 : (_item_skuName_split_1 = _item_skuName1.split(" - ")[1]) === null || _item_skuName_split_1 === void 0 ? void 0 : _item_skuName_split_1.trim()) !== null && _ref5 !== void 0 ? _ref5 : null,
2987
3102
  item_shipping_tier: getItemShippingTier2(context.orderForm, item),
2988
3103
  item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
2989
- item_category: (_getItemCategory6 = getItemCategory6(item)) !== null && _getItemCategory6 !== void 0 ? _getItemCategory6 : null,
2990
- item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
3104
+ item_category: (_getItemCategory7 = getItemCategory7(item)) !== null && _getItemCategory7 !== void 0 ? _getItemCategory7 : null,
3105
+ item_category2: (_getItemCategory25 = getItemCategory25(item)) !== null && _getItemCategory25 !== void 0 ? _getItemCategory25 : null,
2991
3106
  item_id: (_ref6 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref6 !== void 0 ? _ref6 : null,
2992
3107
  item_sku: (_ref7 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref7 !== void 0 ? _ref7 : null,
2993
3108
  item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
@@ -3169,6 +3284,7 @@ var AzzasTracker = function() {
3169
3284
  // src/formatter.ts
3170
3285
  var adapters = {
3171
3286
  DECO: decoAdapter,
3287
+ RESERVA: reservaAdapter,
3172
3288
  HEADLESS: headlessAdapter,
3173
3289
  PICKUP: pickupAdapter,
3174
3290
  ORDERFORM: orderFormAdapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azzas/azzas-tracker-web",
3
- "version": "2.0.0-preview.19",
3
+ "version": "2.0.0-preview.20",
4
4
  "type": "module",
5
5
  "main": "./dist/mod.cjs",
6
6
  "module": "./dist/mod.js",