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