@azzas/azzas-tracker-web 2.0.3-preview.3 → 2.0.3-preview.4
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 +235 -23
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +278 -2
- package/dist/mod.d.ts +278 -2
- package/dist/mod.global.js +235 -23
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +235 -23
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +307 -24
- package/package.json +1 -1
package/dist/mod.vtex.global.js
CHANGED
|
@@ -1569,7 +1569,7 @@ var AzzasTracker = function() {
|
|
|
1569
1569
|
});
|
|
1570
1570
|
}
|
|
1571
1571
|
if (isDebugMode()) {
|
|
1572
|
-
console.log("%c [DT v2] %c ".concat(event, " "), "background: #6366f1; color: #fff; font-weight: bold; padding: 2px 6px; border-radius: 4px 0 0 4px;", "background: #1e1e2e; color: #a5b4fc; font-weight: bold; padding: 2px 6px; border-radius: 0 4px 4px 0;", {
|
|
1572
|
+
console.log("%c [DT v2 - Animale Preview] %c ".concat(event, " "), "background: #6366f1; color: #fff; font-weight: bold; padding: 2px 6px; border-radius: 4px 0 0 4px;", "background: #1e1e2e; color: #a5b4fc; font-weight: bold; padding: 2px 6px; border-radius: 0 4px 4px 0;", {
|
|
1573
1573
|
context: context,
|
|
1574
1574
|
parameters: parameters
|
|
1575
1575
|
});
|
|
@@ -1826,7 +1826,6 @@ var AzzasTracker = function() {
|
|
|
1826
1826
|
"region",
|
|
1827
1827
|
"currency",
|
|
1828
1828
|
"promotion_name",
|
|
1829
|
-
"promotion_url",
|
|
1830
1829
|
"creative_slot",
|
|
1831
1830
|
"creative_name"
|
|
1832
1831
|
]
|
|
@@ -2295,8 +2294,8 @@ var AzzasTracker = function() {
|
|
|
2295
2294
|
};
|
|
2296
2295
|
// src/params/userInfo.ts
|
|
2297
2296
|
var PROD_DOMAINS = {
|
|
2298
|
-
"
|
|
2299
|
-
"store": "https://
|
|
2297
|
+
"lojaanimale": {
|
|
2298
|
+
"store": "https://lojaanimale.myvtex.com",
|
|
2300
2299
|
"checkout": "https://secure.animale.com.br"
|
|
2301
2300
|
},
|
|
2302
2301
|
"lojafarm": {
|
|
@@ -2677,11 +2676,11 @@ var AzzasTracker = function() {
|
|
|
2677
2676
|
var getItemCategory22 = function(item) {
|
|
2678
2677
|
var _ref, _categories_, _validHierarchy_;
|
|
2679
2678
|
var _item_category;
|
|
2680
|
-
var
|
|
2679
|
+
var AVOID_CATEGORIES2 = /^(outlet|bazar|sale)$/i;
|
|
2681
2680
|
var categories = (_ref = (_item_category = item.category) === null || _item_category === void 0 ? void 0 : _item_category.split(">")) !== null && _ref !== void 0 ? _ref : [];
|
|
2682
2681
|
var last = (_categories_ = categories[categories.length - 1]) !== null && _categories_ !== void 0 ? _categories_ : "";
|
|
2683
2682
|
var validHierarchy = last.split("/").filter(function(c) {
|
|
2684
|
-
return c && !
|
|
2683
|
+
return c && !AVOID_CATEGORIES2.test(c);
|
|
2685
2684
|
});
|
|
2686
2685
|
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2687
2686
|
return capitalize(deepest);
|
|
@@ -2800,10 +2799,10 @@ var AzzasTracker = function() {
|
|
|
2800
2799
|
var getItemCategory23 = function(item) {
|
|
2801
2800
|
var _ref, _validHierarchy_;
|
|
2802
2801
|
var _item_similarItems_, _item_similarItems;
|
|
2803
|
-
var
|
|
2802
|
+
var AVOID_CATEGORIES2 = /^(outlet|bazar|sale|coleção|promoção)$/i;
|
|
2804
2803
|
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 : [];
|
|
2805
2804
|
var validHierarchy = categories.filter(function(c) {
|
|
2806
|
-
return c && !
|
|
2805
|
+
return c && !AVOID_CATEGORIES2.test(c);
|
|
2807
2806
|
});
|
|
2808
2807
|
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
2809
2808
|
return capitalize(deepest);
|
|
@@ -2903,8 +2902,291 @@ var AzzasTracker = function() {
|
|
|
2903
2902
|
return sortSizes(sizes).join(",").trim() || null;
|
|
2904
2903
|
}
|
|
2905
2904
|
});
|
|
2906
|
-
// src/params/adapters/
|
|
2905
|
+
// src/params/adapters/animale/utils.ts
|
|
2906
|
+
var SALE_CATEGORIES = /outlet|bazar|sale/i;
|
|
2907
|
+
var AVOID_CATEGORIES = /^(outlet|bazar|sale|cole(ç|c)(ã|a)o)$/i;
|
|
2908
|
+
var getLevels = function(path) {
|
|
2909
|
+
return path.split("/").filter(Boolean);
|
|
2910
|
+
};
|
|
2911
|
+
var isProductCrumb = function(path) {
|
|
2912
|
+
return /\/p\/?$/.test(path !== null && path !== void 0 ? path : "");
|
|
2913
|
+
};
|
|
2914
|
+
var getCategoryPaths = function(item) {
|
|
2915
|
+
var _ref;
|
|
2916
|
+
var _item_categories, _item_breadcrumbList;
|
|
2917
|
+
if (item && "categories" in item && ((_item_categories = item.categories) === null || _item_categories === void 0 ? void 0 : _item_categories.length)) return item.categories;
|
|
2918
|
+
var names = _to_consumable_array((_ref = item === null || item === void 0 ? void 0 : (_item_breadcrumbList = item.breadcrumbList) === null || _item_breadcrumbList === void 0 ? void 0 : _item_breadcrumbList.itemListElement) !== null && _ref !== void 0 ? _ref : []).sort(function(a, b) {
|
|
2919
|
+
var _ref, _ref1;
|
|
2920
|
+
return ((_ref = a === null || a === void 0 ? void 0 : a.position) !== null && _ref !== void 0 ? _ref : 0) - ((_ref1 = b === null || b === void 0 ? void 0 : b.position) !== null && _ref1 !== void 0 ? _ref1 : 0);
|
|
2921
|
+
}).filter(function(crumb) {
|
|
2922
|
+
return (crumb === null || crumb === void 0 ? void 0 : crumb.name) && !isProductCrumb(crumb === null || crumb === void 0 ? void 0 : crumb.item);
|
|
2923
|
+
}).map(function(crumb) {
|
|
2924
|
+
return crumb.name.trim();
|
|
2925
|
+
});
|
|
2926
|
+
return names.length ? [
|
|
2927
|
+
"/".concat(names.join("/"), "/")
|
|
2928
|
+
] : [];
|
|
2929
|
+
};
|
|
2907
2930
|
var getItemCategory6 = function(item) {
|
|
2931
|
+
var _categories_join_match;
|
|
2932
|
+
var categories = getCategoryPaths(item);
|
|
2933
|
+
if (!categories.length) return "Cole\xE7\xE3o";
|
|
2934
|
+
var match = (_categories_join_match = categories.join(" ").match(SALE_CATEGORIES)) === null || _categories_join_match === void 0 ? void 0 : _categories_join_match[0].toLowerCase();
|
|
2935
|
+
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
2936
|
+
};
|
|
2937
|
+
var getItemCategory24 = function(item) {
|
|
2938
|
+
var categories = getCategoryPaths(item);
|
|
2939
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2940
|
+
try {
|
|
2941
|
+
for(var _iterator = _to_consumable_array(categories).reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2942
|
+
var path = _step.value;
|
|
2943
|
+
var deepest = getLevels(path).reverse().find(function(level) {
|
|
2944
|
+
return !AVOID_CATEGORIES.test(level.trim());
|
|
2945
|
+
});
|
|
2946
|
+
if (deepest) return capitalize(deepest.trim());
|
|
2947
|
+
}
|
|
2948
|
+
} catch (err) {
|
|
2949
|
+
_didIteratorError = true;
|
|
2950
|
+
_iteratorError = err;
|
|
2951
|
+
} finally{
|
|
2952
|
+
try {
|
|
2953
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2954
|
+
_iterator.return();
|
|
2955
|
+
}
|
|
2956
|
+
} finally{
|
|
2957
|
+
if (_didIteratorError) {
|
|
2958
|
+
throw _iteratorError;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return "";
|
|
2963
|
+
};
|
|
2964
|
+
var isInStock = function(availability) {
|
|
2965
|
+
return /InStock/i.test(availability !== null && availability !== void 0 ? availability : "");
|
|
2966
|
+
};
|
|
2967
|
+
// src/params/adapters/animale/zones/PDC.ts
|
|
2968
|
+
var AnimalePdcZone = {
|
|
2969
|
+
items: function(context) {
|
|
2970
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2971
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2972
|
+
return context.products.map(function(item) {
|
|
2973
|
+
var _ref, _item_brand_name_toLowerCase, _ref1, _ref2, _ref3, _item_additionalProperty, _ref4, _getItemCategory24, _ref5, _ref6, _ref7, _resizeVtexImage2, _item_item_list_name;
|
|
2974
|
+
var _item_offers_offers, _item_offers, _item_offers_offers1, _item_offers1, _item_isVariantOf_hasVariant_find_offers_offers_, _item_isVariantOf_hasVariant_find, _item_isVariantOf_hasVariant, _item_isVariantOf, _item_isVariantOf1, _item_isVariantOf_hasVariant1, _item_isVariantOf2, _find, _item_isVariantOf3, _item_image;
|
|
2975
|
+
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;
|
|
2976
|
+
var price = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers1.offers) === null || _item_offers_offers1 === void 0 ? void 0 : _item_offers_offers1[0].price;
|
|
2977
|
+
var sellerId = item === null || item === void 0 ? void 0 : (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : (_item_isVariantOf_hasVariant = _item_isVariantOf.hasVariant) === null || _item_isVariantOf_hasVariant === void 0 ? void 0 : (_item_isVariantOf_hasVariant_find = _item_isVariantOf_hasVariant.find(function(v) {
|
|
2978
|
+
return v.offers.offers.find(function(o) {
|
|
2979
|
+
return o.availability;
|
|
2980
|
+
});
|
|
2981
|
+
})) === null || _item_isVariantOf_hasVariant_find === void 0 ? void 0 : (_item_isVariantOf_hasVariant_find_offers_offers_ = _item_isVariantOf_hasVariant_find.offers.offers[0]) === null || _item_isVariantOf_hasVariant_find_offers_offers_ === void 0 ? void 0 : _item_isVariantOf_hasVariant_find_offers_offers_.seller.identifier;
|
|
2982
|
+
return {
|
|
2983
|
+
quantity: 1,
|
|
2984
|
+
index: (_ref = item === null || item === void 0 ? void 0 : item.index) !== null && _ref !== void 0 ? _ref : 0,
|
|
2985
|
+
item_brand: (_item_brand_name_toLowerCase = item.brand.name.toLowerCase()) !== null && _item_brand_name_toLowerCase !== void 0 ? _item_brand_name_toLowerCase : null,
|
|
2986
|
+
item_name: (_ref1 = item === null || item === void 0 ? void 0 : (_item_isVariantOf1 = item.isVariantOf) === null || _item_isVariantOf1 === void 0 ? void 0 : _item_isVariantOf1.name) !== null && _ref1 !== void 0 ? _ref1 : null,
|
|
2987
|
+
price: price !== null && price !== void 0 ? price : null,
|
|
2988
|
+
item_shipping_tier: null,
|
|
2989
|
+
discount: Number(listPrice) - Number(price),
|
|
2990
|
+
item_variant: (_ref2 = (_item_isVariantOf2 = item.isVariantOf) === null || _item_isVariantOf2 === void 0 ? void 0 : (_item_isVariantOf_hasVariant1 = _item_isVariantOf2.hasVariant) === null || _item_isVariantOf_hasVariant1 === void 0 ? void 0 : _item_isVariantOf_hasVariant1[0].name.split(" - ")[0]) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
2991
|
+
item_variant2: (_ref3 = (_find = ((_item_additionalProperty = item.additionalProperty) !== null && _item_additionalProperty !== void 0 ? _item_additionalProperty : []).find(function(p) {
|
|
2992
|
+
return p.name === "Tamanho";
|
|
2993
|
+
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2994
|
+
item_ref: (_ref4 = item === null || item === void 0 ? void 0 : item.gtin) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2995
|
+
item_category: getItemCategory6(item),
|
|
2996
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
2997
|
+
item_id: (_ref5 = item === null || item === void 0 ? void 0 : (_item_isVariantOf3 = item.isVariantOf) === null || _item_isVariantOf3 === void 0 ? void 0 : _item_isVariantOf3.productGroupID) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2998
|
+
item_sku: (_ref6 = item === null || item === void 0 ? void 0 : item.sku) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
2999
|
+
item_url: (_ref7 = item === null || item === void 0 ? void 0 : item.slug) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
3000
|
+
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
3001
|
+
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,
|
|
3002
|
+
seller_id: sellerId !== null && sellerId !== void 0 ? sellerId : null,
|
|
3003
|
+
item_list_name: (_item_item_list_name = item.item_list_name) !== null && _item_item_list_name !== void 0 ? _item_item_list_name : null
|
|
3004
|
+
};
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
return null;
|
|
3008
|
+
},
|
|
3009
|
+
value: function(context) {
|
|
3010
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
3011
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3012
|
+
return context.products.map(function(item) {
|
|
3013
|
+
return item.offers.lowPrice;
|
|
3014
|
+
}).filter(function(price) {
|
|
3015
|
+
return price !== void 0;
|
|
3016
|
+
}).reduce(function(sum, price) {
|
|
3017
|
+
return sum + price;
|
|
3018
|
+
}, 0);
|
|
3019
|
+
}
|
|
3020
|
+
return null;
|
|
3021
|
+
},
|
|
3022
|
+
line_items: function(context) {
|
|
3023
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
3024
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3025
|
+
return context.products.map(function(item) {
|
|
3026
|
+
return item.id;
|
|
3027
|
+
}).filter(function(id) {
|
|
3028
|
+
return Boolean(id);
|
|
3029
|
+
}).join();
|
|
3030
|
+
}
|
|
3031
|
+
return null;
|
|
3032
|
+
},
|
|
3033
|
+
brand: function(context, config2) {
|
|
3034
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
3035
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
3036
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3037
|
+
return context.products.map(function(p) {
|
|
3038
|
+
return p.brand.name;
|
|
3039
|
+
}).join().trim();
|
|
3040
|
+
}
|
|
3041
|
+
return null;
|
|
3042
|
+
}
|
|
3043
|
+
};
|
|
3044
|
+
// src/params/adapters/animale/zones/PDP.ts
|
|
3045
|
+
var AnimalePdpZone = {
|
|
3046
|
+
items: function(context) {
|
|
3047
|
+
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
3048
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3049
|
+
return context.products.map(function(item) {
|
|
3050
|
+
var _ref, _ref1, _item_brand_name_toLowerCase, _ref2, _ref3, _ref4, _item_additionalProperty, _ref5, _getItemCategory24, _ref6, _ref7, _ref8, _resizeVtexImage2, _item_item_list_name;
|
|
3051
|
+
var _item_offers_offers, _item_offers, _item_offers_offers1, _item_offers1, _item_isVariantOf_hasVariant_flatMap, _item_isVariantOf_hasVariant, _item_isVariantOf, _availableOffer_seller, _item_offers_offers__seller, _item_offers_offers_, _item_offers_offers2, _item_offers2, _item_isVariantOf1, _item_isVariantOf_hasVariant1, _item_isVariantOf2, _find, _item_isVariantOf3, _item_image;
|
|
3052
|
+
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;
|
|
3053
|
+
var price = (_item_offers1 = item.offers) === null || _item_offers1 === void 0 ? void 0 : (_item_offers_offers1 = _item_offers1.offers) === null || _item_offers_offers1 === void 0 ? void 0 : _item_offers_offers1[0].price;
|
|
3054
|
+
var availableOffer = item === null || item === void 0 ? void 0 : (_item_isVariantOf = item.isVariantOf) === null || _item_isVariantOf === void 0 ? void 0 : (_item_isVariantOf_hasVariant = _item_isVariantOf.hasVariant) === null || _item_isVariantOf_hasVariant === void 0 ? void 0 : (_item_isVariantOf_hasVariant_flatMap = _item_isVariantOf_hasVariant.flatMap(function(v) {
|
|
3055
|
+
var _ref;
|
|
3056
|
+
var _v_offers;
|
|
3057
|
+
return (_ref = v === null || v === void 0 ? void 0 : (_v_offers = v.offers) === null || _v_offers === void 0 ? void 0 : _v_offers.offers) !== null && _ref !== void 0 ? _ref : [];
|
|
3058
|
+
})) === null || _item_isVariantOf_hasVariant_flatMap === void 0 ? void 0 : _item_isVariantOf_hasVariant_flatMap.find(function(o) {
|
|
3059
|
+
return isInStock(o === null || o === void 0 ? void 0 : o.availability);
|
|
3060
|
+
});
|
|
3061
|
+
var sellerId = (_ref = availableOffer === null || availableOffer === void 0 ? void 0 : (_availableOffer_seller = availableOffer.seller) === null || _availableOffer_seller === void 0 ? void 0 : _availableOffer_seller.identifier) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : (_item_offers2 = item.offers) === null || _item_offers2 === void 0 ? void 0 : (_item_offers_offers2 = _item_offers2.offers) === null || _item_offers_offers2 === void 0 ? void 0 : (_item_offers_offers_ = _item_offers_offers2[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;
|
|
3062
|
+
return {
|
|
3063
|
+
quantity: 1,
|
|
3064
|
+
index: (_ref1 = item === null || item === void 0 ? void 0 : item.index) !== null && _ref1 !== void 0 ? _ref1 : 0,
|
|
3065
|
+
item_brand: (_item_brand_name_toLowerCase = item.brand.name.toLowerCase()) !== null && _item_brand_name_toLowerCase !== void 0 ? _item_brand_name_toLowerCase : null,
|
|
3066
|
+
item_name: (_ref2 = item === null || item === void 0 ? void 0 : (_item_isVariantOf1 = item.isVariantOf) === null || _item_isVariantOf1 === void 0 ? void 0 : _item_isVariantOf1.name) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
3067
|
+
price: price !== null && price !== void 0 ? price : null,
|
|
3068
|
+
item_shipping_tier: null,
|
|
3069
|
+
discount: Number(listPrice) - Number(price),
|
|
3070
|
+
item_variant: (_ref3 = (_item_isVariantOf2 = item.isVariantOf) === null || _item_isVariantOf2 === void 0 ? void 0 : (_item_isVariantOf_hasVariant1 = _item_isVariantOf2.hasVariant) === null || _item_isVariantOf_hasVariant1 === void 0 ? void 0 : _item_isVariantOf_hasVariant1[0].name.split(" - ")[0]) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
3071
|
+
item_variant2: (_ref4 = (_find = ((_item_additionalProperty = item.additionalProperty) !== null && _item_additionalProperty !== void 0 ? _item_additionalProperty : []).find(function(p) {
|
|
3072
|
+
return p.name === "Tamanho";
|
|
3073
|
+
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
3074
|
+
item_ref: (_ref5 = item === null || item === void 0 ? void 0 : item.gtin) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
3075
|
+
item_category: getItemCategory6(item),
|
|
3076
|
+
item_category2: (_getItemCategory24 = getItemCategory24(item)) !== null && _getItemCategory24 !== void 0 ? _getItemCategory24 : null,
|
|
3077
|
+
item_id: (_ref6 = item === null || item === void 0 ? void 0 : (_item_isVariantOf3 = item.isVariantOf) === null || _item_isVariantOf3 === void 0 ? void 0 : _item_isVariantOf3.productGroupID) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
3078
|
+
item_sku: (_ref7 = item === null || item === void 0 ? void 0 : item.sku) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
3079
|
+
item_url: (_ref8 = item === null || item === void 0 ? void 0 : item.slug) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
3080
|
+
// sem link/url no retorno do IS na multi-lib produtos PDC
|
|
3081
|
+
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,
|
|
3082
|
+
seller_id: sellerId !== null && sellerId !== void 0 ? sellerId : null,
|
|
3083
|
+
item_list_name: (_item_item_list_name = item.item_list_name) !== null && _item_item_list_name !== void 0 ? _item_item_list_name : null
|
|
3084
|
+
};
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
return null;
|
|
3088
|
+
},
|
|
3089
|
+
value: function(context) {
|
|
3090
|
+
if (context === null || context === void 0 ? void 0 : context.value) return context.value;
|
|
3091
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3092
|
+
return context.products.map(function(item) {
|
|
3093
|
+
return item.offers.lowPrice;
|
|
3094
|
+
}).filter(function(price) {
|
|
3095
|
+
return price !== void 0;
|
|
3096
|
+
}).reduce(function(sum, price) {
|
|
3097
|
+
return sum + price;
|
|
3098
|
+
}, 0);
|
|
3099
|
+
}
|
|
3100
|
+
return null;
|
|
3101
|
+
},
|
|
3102
|
+
line_items: function(context) {
|
|
3103
|
+
if (context === null || context === void 0 ? void 0 : context.line_items) return context.line_items;
|
|
3104
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3105
|
+
return context.products.map(function(item) {
|
|
3106
|
+
return item.id;
|
|
3107
|
+
}).filter(function(id) {
|
|
3108
|
+
return Boolean(id);
|
|
3109
|
+
}).join();
|
|
3110
|
+
}
|
|
3111
|
+
return null;
|
|
3112
|
+
},
|
|
3113
|
+
brand: function(context, config2) {
|
|
3114
|
+
if (config2 === null || config2 === void 0 ? void 0 : config2.brand) return config2.brand;
|
|
3115
|
+
if (context === null || context === void 0 ? void 0 : context.brand) return context.brand;
|
|
3116
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3117
|
+
return context.products.map(function(p) {
|
|
3118
|
+
return p.brand.name;
|
|
3119
|
+
}).join().trim();
|
|
3120
|
+
}
|
|
3121
|
+
return null;
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
// src/params/adapters/animale/index.ts
|
|
3125
|
+
var animaleAdapter = _object_spread_props(_object_spread({}, metaAdapter), {
|
|
3126
|
+
// global adapters
|
|
3127
|
+
brand: function(context, config2) {
|
|
3128
|
+
if (context.zone === "PDP") {
|
|
3129
|
+
return AnimalePdpZone.brand(context, config2);
|
|
3130
|
+
}
|
|
3131
|
+
if (context.zone === "PDC") {
|
|
3132
|
+
return AnimalePdcZone.brand(context, config2);
|
|
3133
|
+
}
|
|
3134
|
+
return null;
|
|
3135
|
+
},
|
|
3136
|
+
line_items: function(context) {
|
|
3137
|
+
if (context.zone === "PDP") {
|
|
3138
|
+
return AnimalePdpZone.line_items(context);
|
|
3139
|
+
}
|
|
3140
|
+
if (context.zone === "PDC") {
|
|
3141
|
+
return AnimalePdcZone.line_items(context);
|
|
3142
|
+
}
|
|
3143
|
+
return null;
|
|
3144
|
+
},
|
|
3145
|
+
value: function(context) {
|
|
3146
|
+
if (context.zone === "PDP") {
|
|
3147
|
+
return AnimalePdpZone.value(context);
|
|
3148
|
+
}
|
|
3149
|
+
if (context.zone === "PDC") {
|
|
3150
|
+
return AnimalePdcZone.value(context);
|
|
3151
|
+
}
|
|
3152
|
+
return null;
|
|
3153
|
+
},
|
|
3154
|
+
items: function(context) {
|
|
3155
|
+
if (context.zone === "PDP") {
|
|
3156
|
+
return AnimalePdpZone.items(context);
|
|
3157
|
+
}
|
|
3158
|
+
if (context.zone === "PDC") {
|
|
3159
|
+
return AnimalePdcZone.items(context);
|
|
3160
|
+
}
|
|
3161
|
+
},
|
|
3162
|
+
// param used only in one Zone, the PDP; no need condition
|
|
3163
|
+
available_grid: function(context) {
|
|
3164
|
+
if (context === null || context === void 0 ? void 0 : context.available_grid) return context.available_grid;
|
|
3165
|
+
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3166
|
+
var sizes = context.products.flatMap(function(p) {
|
|
3167
|
+
var _ref;
|
|
3168
|
+
var _p_isVariantOf;
|
|
3169
|
+
return ((_ref = p === null || p === void 0 ? void 0 : (_p_isVariantOf = p.isVariantOf) === null || _p_isVariantOf === void 0 ? void 0 : _p_isVariantOf.hasVariant) !== null && _ref !== void 0 ? _ref : []).flatMap(function(variant) {
|
|
3170
|
+
var _variant_offers_offers, _variant_offers, _variant_additionalProperty_find, _variant_additionalProperty;
|
|
3171
|
+
var available = variant === null || variant === void 0 ? void 0 : (_variant_offers = variant.offers) === null || _variant_offers === void 0 ? void 0 : (_variant_offers_offers = _variant_offers.offers) === null || _variant_offers_offers === void 0 ? void 0 : _variant_offers_offers.some(function(o) {
|
|
3172
|
+
return isInStock(o === null || o === void 0 ? void 0 : o.availability);
|
|
3173
|
+
});
|
|
3174
|
+
var size = variant === null || variant === void 0 ? void 0 : (_variant_additionalProperty = variant.additionalProperty) === null || _variant_additionalProperty === void 0 ? void 0 : (_variant_additionalProperty_find = _variant_additionalProperty.find(function(prop) {
|
|
3175
|
+
return (prop === null || prop === void 0 ? void 0 : prop.name) === "Tamanho";
|
|
3176
|
+
})) === null || _variant_additionalProperty_find === void 0 ? void 0 : _variant_additionalProperty_find.value;
|
|
3177
|
+
return available && size ? [
|
|
3178
|
+
size
|
|
3179
|
+
] : [];
|
|
3180
|
+
});
|
|
3181
|
+
});
|
|
3182
|
+
var result = sortSizes(sizes).join(",");
|
|
3183
|
+
return result || null;
|
|
3184
|
+
}
|
|
3185
|
+
return null;
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
// src/params/adapters/headless/utils.ts
|
|
3189
|
+
var getItemCategory7 = function(item) {
|
|
2908
3190
|
var keywords = [
|
|
2909
3191
|
"outlet",
|
|
2910
3192
|
"bazar",
|
|
@@ -2921,7 +3203,7 @@ var AzzasTracker = function() {
|
|
|
2921
3203
|
}
|
|
2922
3204
|
return "Cole\xE7\xE3o";
|
|
2923
3205
|
};
|
|
2924
|
-
var
|
|
3206
|
+
var getItemCategory25 = function(item) {
|
|
2925
3207
|
var _ref, _reverse_find;
|
|
2926
3208
|
var _item_categories;
|
|
2927
3209
|
var avoidList = /outlet|bazar|sale/i;
|
|
@@ -2938,7 +3220,7 @@ var AzzasTracker = function() {
|
|
|
2938
3220
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
2939
3221
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
2940
3222
|
return context.products.map(function(item) {
|
|
2941
|
-
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference,
|
|
3223
|
+
var _ref, _item_brand, _item_productName, _ref1, _ref2, _item_productReference, _getItemCategory25, _ref3, _ref4, _item_link, _resizeVtexImage2, _ref5, _item_item_list_name;
|
|
2942
3224
|
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;
|
|
2943
3225
|
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;
|
|
2944
3226
|
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;
|
|
@@ -2954,8 +3236,8 @@ var AzzasTracker = function() {
|
|
|
2954
3236
|
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,
|
|
2955
3237
|
item_ref: (_item_productReference = item.productReference) !== null && _item_productReference !== void 0 ? _item_productReference : null,
|
|
2956
3238
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
2957
|
-
item_category:
|
|
2958
|
-
item_category2: (
|
|
3239
|
+
item_category: getItemCategory7(item),
|
|
3240
|
+
item_category2: (_getItemCategory25 = getItemCategory25(item)) !== null && _getItemCategory25 !== void 0 ? _getItemCategory25 : null,
|
|
2959
3241
|
item_id: (_ref3 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
2960
3242
|
item_sku: (_ref4 = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items[0].itemId) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
2961
3243
|
item_url: (_item_link = item.link) !== null && _item_link !== void 0 ? _item_link : null,
|
|
@@ -3010,7 +3292,7 @@ var AzzasTracker = function() {
|
|
|
3010
3292
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
3011
3293
|
if (context === null || context === void 0 ? void 0 : context.products) {
|
|
3012
3294
|
return context.products.map(function(item) {
|
|
3013
|
-
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty,
|
|
3295
|
+
var _ref, _item_brand_name, _item_name, _ref1, _ref2, _item_additionalProperty, _getItemCategory25, _item_isVariantOf_productGroupID, _item_sku, _resizeVtexImage2, _ref3, _item_item_list_name;
|
|
3014
3296
|
var _item_isVariantOf_hasVariant, _item_isVariantOf, _find, _item_image, _item_offers_offers_find_seller, _item_offers_offers_find, _item_offers_offers, _item_offers;
|
|
3015
3297
|
var listPrice = item.offers.highPrice;
|
|
3016
3298
|
var price = item.offers.lowPrice;
|
|
@@ -3028,8 +3310,8 @@ var AzzasTracker = function() {
|
|
|
3028
3310
|
})) === null || _find === void 0 ? void 0 : _find.value) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
3029
3311
|
item_ref: null,
|
|
3030
3312
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
3031
|
-
item_category:
|
|
3032
|
-
item_category2: (
|
|
3313
|
+
item_category: getItemCategory7(item),
|
|
3314
|
+
item_category2: (_getItemCategory25 = getItemCategory25(item)) !== null && _getItemCategory25 !== void 0 ? _getItemCategory25 : null,
|
|
3033
3315
|
item_id: (_item_isVariantOf_productGroupID = item.isVariantOf.productGroupID) !== null && _item_isVariantOf_productGroupID !== void 0 ? _item_isVariantOf_productGroupID : null,
|
|
3034
3316
|
item_sku: (_item_sku = item.sku) !== null && _item_sku !== void 0 ? _item_sku : null,
|
|
3035
3317
|
item_url: null,
|
|
@@ -3191,7 +3473,7 @@ var AzzasTracker = function() {
|
|
|
3191
3473
|
});
|
|
3192
3474
|
}) : orderForm.items;
|
|
3193
3475
|
};
|
|
3194
|
-
var
|
|
3476
|
+
var getItemCategory8 = function(item) {
|
|
3195
3477
|
var _text_match;
|
|
3196
3478
|
var categories = item === null || item === void 0 ? void 0 : item.productCategories;
|
|
3197
3479
|
if (!categories) return "Cole\xE7\xE3o";
|
|
@@ -3199,14 +3481,14 @@ var AzzasTracker = function() {
|
|
|
3199
3481
|
var match = (_text_match = text.match(/outlet|bazar|sale/i)) === null || _text_match === void 0 ? void 0 : _text_match[0].toLowerCase();
|
|
3200
3482
|
return match !== null && match !== void 0 ? match : "Cole\xE7\xE3o";
|
|
3201
3483
|
};
|
|
3202
|
-
var
|
|
3484
|
+
var getItemCategory26 = function(item) {
|
|
3203
3485
|
var _ref, _validHierarchy_;
|
|
3204
|
-
var
|
|
3486
|
+
var AVOID_CATEGORIES2 = /outlet|bazar|sale|coleção|promoção/i;
|
|
3205
3487
|
var categories = Object.values((_ref = item === null || item === void 0 ? void 0 : item.productCategories) !== null && _ref !== void 0 ? _ref : {});
|
|
3206
3488
|
var validHierarchy = categories.map(function(c) {
|
|
3207
3489
|
return c.trim();
|
|
3208
3490
|
}).filter(function(c) {
|
|
3209
|
-
return c && !
|
|
3491
|
+
return c && !AVOID_CATEGORIES2.test(c);
|
|
3210
3492
|
});
|
|
3211
3493
|
var deepest = (_validHierarchy_ = validHierarchy[validHierarchy.length - 1]) !== null && _validHierarchy_ !== void 0 ? _validHierarchy_ : "";
|
|
3212
3494
|
return capitalize(deepest);
|
|
@@ -3243,7 +3525,7 @@ var AzzasTracker = function() {
|
|
|
3243
3525
|
if (context === null || context === void 0 ? void 0 : context.items) return context.items;
|
|
3244
3526
|
if ((context === null || context === void 0 ? void 0 : context.orderForm) && (context === null || context === void 0 ? void 0 : context.orderForm.items)) {
|
|
3245
3527
|
return getOrderFormItems(context.orderForm).map(function(item, index) {
|
|
3246
|
-
var _ref, _ref1, _ref2, _ref3, _ref4,
|
|
3528
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _getItemCategory8, _getItemCategory26, _ref5, _ref6, _item_detailUrl, _resizeVtexImage2, _ref7, _ref8;
|
|
3247
3529
|
var _item_skuName_split__split_pop, _item_skuName_split_, _item_skuName, _item_skuName_split_1, _item_skuName1, _context_orderForm, _item_additionalInfo_brandName, _item_additionalInfo, _context_orderForm1;
|
|
3248
3530
|
var color = context.brand === "carolbassi" ? null : item === null || item === void 0 ? void 0 : (_item_skuName = item.skuName) === null || _item_skuName === void 0 ? void 0 : (_item_skuName_split_ = _item_skuName.split(" - ")[0]) === null || _item_skuName_split_ === void 0 ? void 0 : (_item_skuName_split__split_pop = _item_skuName_split_.split("_").pop()) === null || _item_skuName_split__split_pop === void 0 ? void 0 : _item_skuName_split__split_pop.trim();
|
|
3249
3531
|
var size = context.brand === "carolbassi" ? item === null || item === void 0 ? void 0 : item.skuName : 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();
|
|
@@ -3258,8 +3540,8 @@ var AzzasTracker = function() {
|
|
|
3258
3540
|
item_variant2: (_ref4 = size === null || size === void 0 ? void 0 : size.toUpperCase()) !== null && _ref4 !== void 0 ? _ref4 : null,
|
|
3259
3541
|
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
3260
3542
|
item_ref: (item === null || item === void 0 ? void 0 : item.productRefId) || (item === null || item === void 0 ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
3261
|
-
item_category: (
|
|
3262
|
-
item_category2: (
|
|
3543
|
+
item_category: (_getItemCategory8 = getItemCategory8(item)) !== null && _getItemCategory8 !== void 0 ? _getItemCategory8 : null,
|
|
3544
|
+
item_category2: (_getItemCategory26 = getItemCategory26(item)) !== null && _getItemCategory26 !== void 0 ? _getItemCategory26 : null,
|
|
3263
3545
|
item_id: (_ref5 = item === null || item === void 0 ? void 0 : item.productId) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
3264
3546
|
item_sku: (_ref6 = item === null || item === void 0 ? void 0 : item.id) !== null && _ref6 !== void 0 ? _ref6 : null,
|
|
3265
3547
|
item_url: (_item_detailUrl = item.detailUrl) !== null && _item_detailUrl !== void 0 ? _item_detailUrl : null,
|
|
@@ -3455,7 +3737,8 @@ var AzzasTracker = function() {
|
|
|
3455
3737
|
HEADLESS: headlessAdapter,
|
|
3456
3738
|
PICKUP: pickupAdapter,
|
|
3457
3739
|
ORDERFORM: orderFormAdapter,
|
|
3458
|
-
META: metaAdapter
|
|
3740
|
+
META: metaAdapter,
|
|
3741
|
+
ANIMALE: animaleAdapter
|
|
3459
3742
|
};
|
|
3460
3743
|
// src/index.ts
|
|
3461
3744
|
var config = {
|