@azzas/azzas-tracker-web 2.0.0-preview.8 → 2.0.0
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 +204 -80
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +151 -14
- package/dist/mod.d.ts +151 -14
- package/dist/mod.global.js +204 -80
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +204 -80
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +238 -87
- package/package.json +1 -1
package/dist/mod.js
CHANGED
|
@@ -290,7 +290,7 @@ var EVENTS = {
|
|
|
290
290
|
name: "notify_me",
|
|
291
291
|
hasEcommerce: false,
|
|
292
292
|
destinations: ["DataLayer"],
|
|
293
|
-
requiredParams: ["brand", "
|
|
293
|
+
requiredParams: ["brand", "size", "item_ref"]
|
|
294
294
|
},
|
|
295
295
|
REFINE_RESULTS: {
|
|
296
296
|
name: "refine_results",
|
|
@@ -1042,7 +1042,7 @@ var PROD_DOMAINS = {
|
|
|
1042
1042
|
"store": "https://www.animale.com.br",
|
|
1043
1043
|
"checkout": "https://secure.animale.com.br"
|
|
1044
1044
|
},
|
|
1045
|
-
"
|
|
1045
|
+
"lojafarm": {
|
|
1046
1046
|
"store": "https://lojafarm.myvtex.com"
|
|
1047
1047
|
},
|
|
1048
1048
|
"mariafilo": {
|
|
@@ -1060,23 +1060,23 @@ var PROD_DOMAINS = {
|
|
|
1060
1060
|
"bynv": {
|
|
1061
1061
|
"store": "https://bynv.myvtex.com"
|
|
1062
1062
|
},
|
|
1063
|
-
"
|
|
1063
|
+
"lojafabula": {
|
|
1064
1064
|
"store": "https://lojafabula.myvtex.com"
|
|
1065
1065
|
}
|
|
1066
1066
|
};
|
|
1067
1067
|
async function getUserInfo(context) {
|
|
1068
|
-
var _a, _b, _c, _d, _e;
|
|
1069
|
-
const domain = (
|
|
1070
|
-
if (!domain) return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1068
|
+
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, _F, _G, _H, _I;
|
|
1069
|
+
const domain = (_e = PROD_DOMAINS[(_b = (_a = context == null ? void 0 : context.meta) == null ? void 0 : _a.user_info) == null ? void 0 : _b.account]) == null ? void 0 : _e[(_d = (_c = context == null ? void 0 : context.meta) == null ? void 0 : _c.user_info) == null ? void 0 : _d.platform];
|
|
1070
|
+
if (!domain) return { customer: { email: (_g = (_f = context == null ? void 0 : context.meta) == null ? void 0 : _f.user_info) == null ? void 0 : _g.userEmail, id: (_i = (_h = context == null ? void 0 : context.meta) == null ? void 0 : _h.user_info) == null ? void 0 : _i.userId }, address: null };
|
|
1071
1071
|
try {
|
|
1072
1072
|
const api = `${domain}/_v/user-info`;
|
|
1073
1073
|
const response = await fetch(api, {
|
|
1074
1074
|
method: "POST",
|
|
1075
|
-
body: JSON.stringify({ email: context.userEmail })
|
|
1075
|
+
body: JSON.stringify({ email: (_k = (_j = context == null ? void 0 : context.meta) == null ? void 0 : _j.user_info) == null ? void 0 : _k.userEmail })
|
|
1076
1076
|
});
|
|
1077
1077
|
if (response.status !== 200) {
|
|
1078
|
-
if ((context == null ? void 0 : context.manuallyInfo) && ((
|
|
1079
|
-
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
|
|
1078
|
+
if (((_m = (_l = context == null ? void 0 : context.meta) == null ? void 0 : _l.user_info) == null ? void 0 : _m.manuallyInfo) && ((_p = (_o = (_n = context == null ? void 0 : context.meta) == null ? void 0 : _n.user_info) == null ? void 0 : _o.manuallyInfo) == null ? void 0 : _p.cpf)) {
|
|
1079
|
+
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = (_r = (_q = context == null ? void 0 : context.meta) == null ? void 0 : _q.user_info) == null ? void 0 : _r.manuallyInfo;
|
|
1080
1080
|
const document3 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
|
|
1081
1081
|
const hashedDocument2 = await documentToHash(document3);
|
|
1082
1082
|
return {
|
|
@@ -1094,15 +1094,15 @@ async function getUserInfo(context) {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
1097
|
-
return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1097
|
+
return { customer: { email: (_t = (_s = context == null ? void 0 : context.meta) == null ? void 0 : _s.user_info) == null ? void 0 : _t.userEmail, id: (_v = (_u = context == null ? void 0 : context.meta) == null ? void 0 : _u.user_info) == null ? void 0 : _v.userId }, address: null };
|
|
1098
1098
|
}
|
|
1099
1099
|
const res = await response.json();
|
|
1100
|
-
const document2 = (
|
|
1100
|
+
const document2 = (_x = (_w = res == null ? void 0 : res.customer) == null ? void 0 : _w.document) == null ? void 0 : _x.replace(/\D/g, "");
|
|
1101
1101
|
const hashedDocument = await documentToHash(document2);
|
|
1102
1102
|
return { ...res, customer: { ...res.customer, cpf: hashedDocument, document: document2 } };
|
|
1103
1103
|
} catch (_) {
|
|
1104
|
-
if ((context == null ? void 0 : context.manuallyInfo) && ((
|
|
1105
|
-
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
|
|
1104
|
+
if (((_z = (_y = context == null ? void 0 : context.meta) == null ? void 0 : _y.user_info) == null ? void 0 : _z.manuallyInfo) && ((_C = (_B = (_A = context == null ? void 0 : context.meta) == null ? void 0 : _A.user_info) == null ? void 0 : _B.manuallyInfo) == null ? void 0 : _C.cpf)) {
|
|
1105
|
+
const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = (_E = (_D = context == null ? void 0 : context.meta) == null ? void 0 : _D.user_info) == null ? void 0 : _E.manuallyInfo;
|
|
1106
1106
|
const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
|
|
1107
1107
|
const hashedDocument = await documentToHash(document2);
|
|
1108
1108
|
return {
|
|
@@ -1120,7 +1120,7 @@ async function getUserInfo(context) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
};
|
|
1122
1122
|
}
|
|
1123
|
-
return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
|
|
1123
|
+
return { customer: { email: (_G = (_F = context == null ? void 0 : context.meta) == null ? void 0 : _F.user_info) == null ? void 0 : _G.userEmail, id: (_I = (_H = context == null ? void 0 : context.meta) == null ? void 0 : _H.user_info) == null ? void 0 : _I.userId }, address: null };
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
@@ -1327,8 +1327,13 @@ var legacyGetters = {
|
|
|
1327
1327
|
};
|
|
1328
1328
|
|
|
1329
1329
|
// src/params/adapters/meta/index.ts
|
|
1330
|
-
var
|
|
1330
|
+
var metaAdapter = {
|
|
1331
1331
|
user_info: getUserInfo,
|
|
1332
|
+
brand: (context, config2) => {
|
|
1333
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1334
|
+
if (context == null ? void 0 : context.meta.brand) return context.meta.brand;
|
|
1335
|
+
return null;
|
|
1336
|
+
},
|
|
1332
1337
|
content_type: (context) => {
|
|
1333
1338
|
return context.meta.content_type || null;
|
|
1334
1339
|
},
|
|
@@ -1350,7 +1355,7 @@ var metaAdapters = {
|
|
|
1350
1355
|
return context.meta.search_term || null;
|
|
1351
1356
|
},
|
|
1352
1357
|
search_found: (context) => {
|
|
1353
|
-
return context.meta.search_found ||
|
|
1358
|
+
return context.meta.search_found || false;
|
|
1354
1359
|
},
|
|
1355
1360
|
search_quantity: (context) => {
|
|
1356
1361
|
return context.meta.search_quantity || 0;
|
|
@@ -1364,17 +1369,14 @@ var metaAdapters = {
|
|
|
1364
1369
|
creative_slot: (context) => {
|
|
1365
1370
|
return context.meta.creative_slot || null;
|
|
1366
1371
|
},
|
|
1367
|
-
size: (context) => {
|
|
1368
|
-
return context.size || null;
|
|
1369
|
-
},
|
|
1370
1372
|
item_ref: (context) => {
|
|
1371
|
-
return context.
|
|
1373
|
+
return context.meta.item_ref || null;
|
|
1372
1374
|
},
|
|
1373
1375
|
method: (context) => {
|
|
1374
|
-
return context.method || null;
|
|
1376
|
+
return context.meta.method || null;
|
|
1375
1377
|
},
|
|
1376
1378
|
type: (context) => {
|
|
1377
|
-
return context.type || null;
|
|
1379
|
+
return context.meta.type || null;
|
|
1378
1380
|
},
|
|
1379
1381
|
color: (context) => {
|
|
1380
1382
|
return context.meta.color || null;
|
|
@@ -1387,6 +1389,9 @@ var metaAdapters = {
|
|
|
1387
1389
|
},
|
|
1388
1390
|
ordering: (context) => {
|
|
1389
1391
|
return context.meta.ordering || null;
|
|
1392
|
+
},
|
|
1393
|
+
size: (context) => {
|
|
1394
|
+
return context.meta.size || null;
|
|
1390
1395
|
}
|
|
1391
1396
|
};
|
|
1392
1397
|
|
|
@@ -1446,7 +1451,7 @@ var getItemCategory22 = (item) => {
|
|
|
1446
1451
|
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
1447
1452
|
var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
1448
1453
|
var decoAdapter = {
|
|
1449
|
-
...
|
|
1454
|
+
...metaAdapter,
|
|
1450
1455
|
// global adapters
|
|
1451
1456
|
items: (context) => {
|
|
1452
1457
|
if (context == null ? void 0 : context.items) return context.items;
|
|
@@ -1497,7 +1502,7 @@ var decoAdapter = {
|
|
|
1497
1502
|
line_items: (context) => {
|
|
1498
1503
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1499
1504
|
if (context == null ? void 0 : context.products) {
|
|
1500
|
-
return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id));
|
|
1505
|
+
return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id)).join();
|
|
1501
1506
|
}
|
|
1502
1507
|
return null;
|
|
1503
1508
|
},
|
|
@@ -1535,8 +1540,108 @@ var decoAdapter = {
|
|
|
1535
1540
|
}
|
|
1536
1541
|
};
|
|
1537
1542
|
|
|
1538
|
-
// src/params/adapters/
|
|
1543
|
+
// src/params/adapters/reserva/utils.ts
|
|
1539
1544
|
var getItemCategory5 = (item) => {
|
|
1545
|
+
var _a, _b, _c;
|
|
1546
|
+
const categories = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories;
|
|
1547
|
+
if (!(categories == null ? void 0 : categories.length)) return "Cole\xE7\xE3o";
|
|
1548
|
+
const match = (_c = categories.join(" ").match(/outlet|bazar|sale/i)) == null ? void 0 : _c[0].toLowerCase();
|
|
1549
|
+
return match != null ? match : "Cole\xE7\xE3o";
|
|
1550
|
+
};
|
|
1551
|
+
var getItemCategory23 = (item) => {
|
|
1552
|
+
var _a, _b, _c, _d;
|
|
1553
|
+
const AVOID_CATEGORIES = /^(outlet|bazar|sale|coleção)$/i;
|
|
1554
|
+
const categories = (_c = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories) != null ? _c : [];
|
|
1555
|
+
const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1556
|
+
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1557
|
+
return capitalize(deepest);
|
|
1558
|
+
};
|
|
1559
|
+
|
|
1560
|
+
// src/params/adapters/reserva/index.ts
|
|
1561
|
+
var reservaAdapter = {
|
|
1562
|
+
...metaAdapter,
|
|
1563
|
+
// global adapters
|
|
1564
|
+
items: (context) => {
|
|
1565
|
+
if (context == null ? void 0 : context.items) return context.items;
|
|
1566
|
+
if (context == null ? void 0 : context.products) {
|
|
1567
|
+
return context.products.map((item) => {
|
|
1568
|
+
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;
|
|
1569
|
+
const COLOR_REGEX = /^[^_]+_/;
|
|
1570
|
+
const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
|
|
1571
|
+
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+$/, "");
|
|
1572
|
+
return {
|
|
1573
|
+
quantity: 1,
|
|
1574
|
+
index: (_f = item == null ? void 0 : item.index) != null ? _f : 0,
|
|
1575
|
+
item_brand: (_i = (_h = (_g = item.brand) == null ? void 0 : _g.name) == null ? void 0 : _h.toLowerCase()) != null ? _i : null,
|
|
1576
|
+
item_name: (_j = item.isVariantOf.name) != null ? _j : null,
|
|
1577
|
+
price: (_l = (_k = item.offers) == null ? void 0 : _k.lowPrice) != null ? _l : null,
|
|
1578
|
+
discount: Math.round((Number(listPrice) - Number((_m = item == null ? void 0 : item.offers) == null ? void 0 : _m.lowPrice)) * 100) / 100,
|
|
1579
|
+
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,
|
|
1580
|
+
// cor
|
|
1581
|
+
item_variant2: (_q = (_p = item == null ? void 0 : item.name) == null ? void 0 : _p.split(" - ")[1]) != null ? _q : null,
|
|
1582
|
+
// tamanho
|
|
1583
|
+
item_shipping_tier: "",
|
|
1584
|
+
item_ref: refIdValue != null ? refIdValue : null,
|
|
1585
|
+
item_category: (_r = getItemCategory5(item)) != null ? _r : null,
|
|
1586
|
+
item_category2: (_s = getItemCategory23(item)) != null ? _s : null,
|
|
1587
|
+
item_id: (_t = item == null ? void 0 : item.id) != null ? _t : null,
|
|
1588
|
+
item_sku: (_u = item == null ? void 0 : item.sku) != null ? _u : null,
|
|
1589
|
+
item_url: (_w = (_v = item == null ? void 0 : item.seo) == null ? void 0 : _v.canonical) != null ? _w : null,
|
|
1590
|
+
image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
|
|
1591
|
+
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,
|
|
1592
|
+
item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
|
|
1593
|
+
};
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
return null;
|
|
1597
|
+
},
|
|
1598
|
+
brand: (context, config2) => {
|
|
1599
|
+
if (config2 == null ? void 0 : config2.brand) return config2.brand;
|
|
1600
|
+
if (context == null ? void 0 : context.brand) return context.brand;
|
|
1601
|
+
if (context == null ? void 0 : context.products) {
|
|
1602
|
+
return normalizeBrand2(context.products.map((p) => {
|
|
1603
|
+
var _a;
|
|
1604
|
+
return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
|
|
1605
|
+
}));
|
|
1606
|
+
}
|
|
1607
|
+
return null;
|
|
1608
|
+
},
|
|
1609
|
+
line_items: (context) => {
|
|
1610
|
+
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1611
|
+
if (context == null ? void 0 : context.products) {
|
|
1612
|
+
return context.products.map((item) => item == null ? void 0 : item.id).filter((id) => Boolean(id)).join();
|
|
1613
|
+
}
|
|
1614
|
+
return null;
|
|
1615
|
+
},
|
|
1616
|
+
value: (context) => {
|
|
1617
|
+
if (context == null ? void 0 : context.value) return context.value;
|
|
1618
|
+
if (context == null ? void 0 : context.products) {
|
|
1619
|
+
return context.products.map((item) => {
|
|
1620
|
+
var _a;
|
|
1621
|
+
return (_a = item.offers) == null ? void 0 : _a.lowPrice;
|
|
1622
|
+
}).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1623
|
+
}
|
|
1624
|
+
return null;
|
|
1625
|
+
},
|
|
1626
|
+
available_grid: (context) => {
|
|
1627
|
+
if (context == null ? void 0 : context.available_grid) return context.available_grid;
|
|
1628
|
+
if (context == null ? void 0 : context.products) {
|
|
1629
|
+
const sizes = context.products.filter((product) => {
|
|
1630
|
+
var _a, _b;
|
|
1631
|
+
return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
|
|
1632
|
+
}).map((product) => {
|
|
1633
|
+
var _a;
|
|
1634
|
+
return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
|
|
1635
|
+
}).filter((name) => Boolean(name));
|
|
1636
|
+
const result = sortSizes(sizes).join(",").trim();
|
|
1637
|
+
return result || null;
|
|
1638
|
+
}
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
// src/params/adapters/headless/utils.ts
|
|
1644
|
+
var getItemCategory6 = (item) => {
|
|
1540
1645
|
const keywords = ["outlet", "bazar", "sale"];
|
|
1541
1646
|
const regex = new RegExp(keywords.join("|"), "i");
|
|
1542
1647
|
const value = item == null ? void 0 : item.categories;
|
|
@@ -1549,7 +1654,7 @@ var getItemCategory5 = (item) => {
|
|
|
1549
1654
|
}
|
|
1550
1655
|
return "Cole\xE7\xE3o";
|
|
1551
1656
|
};
|
|
1552
|
-
var
|
|
1657
|
+
var getItemCategory24 = (item) => {
|
|
1553
1658
|
var _a, _b, _c;
|
|
1554
1659
|
const avoidList = /outlet|bazar|sale/i;
|
|
1555
1660
|
const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
|
|
@@ -1579,8 +1684,8 @@ var HeadlessPdpZone = {
|
|
|
1579
1684
|
item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
|
|
1580
1685
|
item_ref: (_l = item.productReference) != null ? _l : null,
|
|
1581
1686
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1582
|
-
item_category:
|
|
1583
|
-
item_category2: (_m =
|
|
1687
|
+
item_category: getItemCategory6(item),
|
|
1688
|
+
item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
|
|
1584
1689
|
item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
|
|
1585
1690
|
item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
|
|
1586
1691
|
item_url: (_q = item.link) != null ? _q : null,
|
|
@@ -1606,7 +1711,7 @@ var HeadlessPdpZone = {
|
|
|
1606
1711
|
line_items: (context) => {
|
|
1607
1712
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1608
1713
|
if (context == null ? void 0 : context.products) {
|
|
1609
|
-
return context.products.map((item) => item.productId).filter((id) => Boolean(id));
|
|
1714
|
+
return context.products.map((item) => item.productId).filter((id) => Boolean(id)).join();
|
|
1610
1715
|
}
|
|
1611
1716
|
return null;
|
|
1612
1717
|
},
|
|
@@ -1641,8 +1746,8 @@ var HeadlessPdcZone = {
|
|
|
1641
1746
|
item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
|
|
1642
1747
|
item_ref: null,
|
|
1643
1748
|
// sem ref no retorno do IS na multi-lib produtos PDC
|
|
1644
|
-
item_category:
|
|
1645
|
-
item_category2: (_j =
|
|
1749
|
+
item_category: getItemCategory6(item),
|
|
1750
|
+
item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
|
|
1646
1751
|
item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
|
|
1647
1752
|
item_sku: (_l = item.sku) != null ? _l : null,
|
|
1648
1753
|
item_url: null,
|
|
@@ -1665,7 +1770,7 @@ var HeadlessPdcZone = {
|
|
|
1665
1770
|
line_items: (context) => {
|
|
1666
1771
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1667
1772
|
if (context == null ? void 0 : context.products) {
|
|
1668
|
-
return context.products.map((item) => item.id).filter((id) => Boolean(id));
|
|
1773
|
+
return context.products.map((item) => item.id).filter((id) => Boolean(id)).join();
|
|
1669
1774
|
}
|
|
1670
1775
|
return null;
|
|
1671
1776
|
},
|
|
@@ -1681,7 +1786,7 @@ var HeadlessPdcZone = {
|
|
|
1681
1786
|
|
|
1682
1787
|
// src/params/adapters/headless/index.ts
|
|
1683
1788
|
var headlessAdapter = {
|
|
1684
|
-
...
|
|
1789
|
+
...metaAdapter,
|
|
1685
1790
|
// global adapters
|
|
1686
1791
|
brand: (context, config2) => {
|
|
1687
1792
|
if (context.zone === "PDP") {
|
|
@@ -1749,7 +1854,7 @@ var getDeliveryTime = (sla) => {
|
|
|
1749
1854
|
|
|
1750
1855
|
// src/params/adapters/pickup/index.ts
|
|
1751
1856
|
var pickupAdapter = {
|
|
1752
|
-
...
|
|
1857
|
+
...metaAdapter,
|
|
1753
1858
|
flag_pickup: (context) => {
|
|
1754
1859
|
var _a;
|
|
1755
1860
|
return (_a = context == null ? void 0 : context.flag_pickup) != null ? _a : null;
|
|
@@ -1780,7 +1885,15 @@ var pickupAdapter = {
|
|
|
1780
1885
|
};
|
|
1781
1886
|
|
|
1782
1887
|
// src/params/adapters/orderForm/utils.ts
|
|
1783
|
-
var
|
|
1888
|
+
var getOrderFormItems = (orderForm) => {
|
|
1889
|
+
const idSelected = orderForm == null ? void 0 : orderForm.selected;
|
|
1890
|
+
const isMultipleRemove = orderForm == null ? void 0 : orderForm.multipleRemove;
|
|
1891
|
+
return idSelected ? orderForm.items.filter((item) => item.id === idSelected).map((i) => {
|
|
1892
|
+
if (isMultipleRemove) return i;
|
|
1893
|
+
return { ...i, quantity: 1 };
|
|
1894
|
+
}) : orderForm.items;
|
|
1895
|
+
};
|
|
1896
|
+
var getItemCategory7 = (item) => {
|
|
1784
1897
|
var _a;
|
|
1785
1898
|
const categories = item == null ? void 0 : item.productCategories;
|
|
1786
1899
|
if (!categories) return "Cole\xE7\xE3o";
|
|
@@ -1788,7 +1901,7 @@ var getItemCategory6 = (item) => {
|
|
|
1788
1901
|
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1789
1902
|
return match != null ? match : "Cole\xE7\xE3o";
|
|
1790
1903
|
};
|
|
1791
|
-
var
|
|
1904
|
+
var getItemCategory25 = (item) => {
|
|
1792
1905
|
var _a, _b;
|
|
1793
1906
|
const AVOID_CATEGORIES = /outlet|bazar|sale/i;
|
|
1794
1907
|
const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
|
|
@@ -1804,38 +1917,53 @@ function getItemShippingTier2(orderForm, item) {
|
|
|
1804
1917
|
const selectedSla = (_c = info == null ? void 0 : info.slas) == null ? void 0 : _c.find((sla) => sla.id === info.selectedSla);
|
|
1805
1918
|
return ((_d = selectedSla == null ? void 0 : selectedSla.pickupStoreInfo) == null ? void 0 : _d.friendlyName) ? `retirada em loja: ${selectedSla.pickupStoreInfo.friendlyName}` : (selectedSla == null ? void 0 : selectedSla.name) ? `Receba em casa: ${selectedSla.name}` : null;
|
|
1806
1919
|
}
|
|
1807
|
-
var
|
|
1808
|
-
|
|
1809
|
-
|
|
1920
|
+
var getPaymentType2 = (context) => {
|
|
1921
|
+
var _a, _b, _c, _d;
|
|
1922
|
+
if (context.payment_type) return context.payment_type;
|
|
1923
|
+
if (!context.orderForm) return null;
|
|
1924
|
+
const giftCards = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.giftCards) || [];
|
|
1925
|
+
if (giftCards.some((g) => g == null ? void 0 : g.inUse)) return "vale";
|
|
1926
|
+
const payments = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.payments) || [];
|
|
1927
|
+
const systems = ((_c = context.orderForm.paymentData) == null ? void 0 : _c.paymentSystems) || [];
|
|
1928
|
+
if (!payments.length || !systems.length) return null;
|
|
1929
|
+
const selectedPayment = payments.find((p) => p == null ? void 0 : p.paymentSystem) || payments[0];
|
|
1930
|
+
const id = String((selectedPayment == null ? void 0 : selectedPayment.paymentSystem) || "").trim();
|
|
1931
|
+
if (!id) return null;
|
|
1932
|
+
const system = systems.find((s) => String(s.id) === id);
|
|
1933
|
+
const name = ((_d = system == null ? void 0 : system.name) == null ? void 0 : _d.toLowerCase()) || "";
|
|
1934
|
+
const match = paymentTypeMap.find(([key]) => name.includes(key));
|
|
1935
|
+
return match ? match[1] : null;
|
|
1810
1936
|
};
|
|
1811
1937
|
|
|
1812
1938
|
// src/params/adapters/orderForm/index.ts
|
|
1813
1939
|
var orderFormAdapter = {
|
|
1814
|
-
...
|
|
1940
|
+
...metaAdapter,
|
|
1815
1941
|
items: (context) => {
|
|
1816
1942
|
if (context == null ? void 0 : context.items) return context.items;
|
|
1817
1943
|
if ((context == null ? void 0 : context.orderForm) && (context == null ? void 0 : context.orderForm.items)) {
|
|
1818
1944
|
return getOrderFormItems(context.orderForm).map((item, index) => {
|
|
1819
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t
|
|
1945
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1946
|
+
const color = context.brand === "carolbassi" ? null : (_c = (_b = (_a = item == null ? void 0 : item.skuName) == null ? void 0 : _a.split(" - ")[0]) == null ? void 0 : _b.split("_").pop()) == null ? void 0 : _c.trim();
|
|
1947
|
+
const size = context.brand === "carolbassi" ? item == null ? void 0 : item.skuName : (_e = (_d = item == null ? void 0 : item.skuName) == null ? void 0 : _d.split(" - ")[1]) == null ? void 0 : _e.trim();
|
|
1820
1948
|
return {
|
|
1821
|
-
quantity: (
|
|
1822
|
-
index: (
|
|
1823
|
-
item_brand: (
|
|
1824
|
-
item_name: (
|
|
1825
|
-
price: (item == null ? void 0 : item.
|
|
1949
|
+
quantity: (_f = item == null ? void 0 : item.quantity) != null ? _f : 1,
|
|
1950
|
+
index: (_h = (_g = context == null ? void 0 : context.orderForm) == null ? void 0 : _g.index) != null ? _h : index + 1,
|
|
1951
|
+
item_brand: (_j = (_i = item.additionalInfo) == null ? void 0 : _i.brandName) != null ? _j : null,
|
|
1952
|
+
item_name: (_k = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _k : null,
|
|
1953
|
+
price: (item == null ? void 0 : item.sellingPrice) / 100,
|
|
1826
1954
|
discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
|
|
1827
|
-
item_variant:
|
|
1828
|
-
item_variant2:
|
|
1955
|
+
item_variant: color != null ? color : null,
|
|
1956
|
+
item_variant2: size != null ? size : null,
|
|
1829
1957
|
item_shipping_tier: getItemShippingTier2(context.orderForm, item),
|
|
1830
1958
|
item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
|
|
1831
|
-
item_category: (
|
|
1832
|
-
item_category2: (
|
|
1833
|
-
item_id: (
|
|
1834
|
-
item_sku: (
|
|
1835
|
-
item_url: (
|
|
1836
|
-
image_url: (
|
|
1837
|
-
seller_id: (
|
|
1838
|
-
item_list_name: (
|
|
1959
|
+
item_category: (_l = getItemCategory7(item)) != null ? _l : null,
|
|
1960
|
+
item_category2: (_m = getItemCategory25(item)) != null ? _m : null,
|
|
1961
|
+
item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
|
|
1962
|
+
item_sku: (_o = item == null ? void 0 : item.id) != null ? _o : null,
|
|
1963
|
+
item_url: (_p = item.detailUrl) != null ? _p : null,
|
|
1964
|
+
image_url: (_q = resizeVtexImage2(item.imageUrl)) != null ? _q : null,
|
|
1965
|
+
seller_id: (_r = item == null ? void 0 : item.seller) != null ? _r : null,
|
|
1966
|
+
item_list_name: (_t = (_s = context == null ? void 0 : context.orderForm) == null ? void 0 : _s.item_list_name) != null ? _t : null
|
|
1839
1967
|
};
|
|
1840
1968
|
});
|
|
1841
1969
|
}
|
|
@@ -1853,26 +1981,22 @@ var orderFormAdapter = {
|
|
|
1853
1981
|
var _a;
|
|
1854
1982
|
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1855
1983
|
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1856
|
-
return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id));
|
|
1984
|
+
return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id)).join();
|
|
1857
1985
|
},
|
|
1858
1986
|
value: (context) => {
|
|
1859
1987
|
var _a;
|
|
1860
1988
|
if (context == null ? void 0 : context.value) return context.value;
|
|
1861
1989
|
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1862
|
-
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.
|
|
1990
|
+
return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.sellingPrice) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1863
1991
|
},
|
|
1864
|
-
payment_type:
|
|
1992
|
+
payment_type: getPaymentType2,
|
|
1865
1993
|
total_discount: (context) => {
|
|
1866
|
-
var _a, _b;
|
|
1994
|
+
var _a, _b, _c;
|
|
1867
1995
|
if (context == null ? void 0 : context.total_discount) return context.total_discount;
|
|
1868
1996
|
if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
|
|
1869
|
-
const
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
return acc + unitDiscount * item.quantity;
|
|
1873
|
-
}, 0);
|
|
1874
|
-
const discounts = totalsList.find((t) => t.id === "Discounts");
|
|
1875
|
-
return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
|
|
1997
|
+
const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
|
|
1998
|
+
const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
|
|
1999
|
+
return Math.abs(productDiscount) / 100 || null;
|
|
1876
2000
|
},
|
|
1877
2001
|
subtotal: (context) => {
|
|
1878
2002
|
var _a, _b;
|
|
@@ -1880,17 +2004,6 @@ var orderFormAdapter = {
|
|
|
1880
2004
|
const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
|
|
1881
2005
|
return subtotal;
|
|
1882
2006
|
},
|
|
1883
|
-
coupon_message: (context) => {
|
|
1884
|
-
var _a;
|
|
1885
|
-
if (context.couponMessage) return context.couponMessage;
|
|
1886
|
-
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
1887
|
-
if (messages.length === 0) return null;
|
|
1888
|
-
const couponMessages = messages.filter(
|
|
1889
|
-
(msg) => msg.text.toLowerCase().includes("cupom")
|
|
1890
|
-
);
|
|
1891
|
-
if (couponMessages.length === 0) return null;
|
|
1892
|
-
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
1893
|
-
},
|
|
1894
2007
|
zipcode: (context) => {
|
|
1895
2008
|
var _a;
|
|
1896
2009
|
return (_a = context.meta.zipcode) != null ? _a : null;
|
|
@@ -1934,7 +2047,7 @@ var orderFormAdapter = {
|
|
|
1934
2047
|
var _a2, _b2;
|
|
1935
2048
|
const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
|
|
1936
2049
|
return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
|
|
1937
|
-
}, 0);
|
|
2050
|
+
}, 0) / 100;
|
|
1938
2051
|
},
|
|
1939
2052
|
shipping_tier: (context) => {
|
|
1940
2053
|
var _a, _b, _c;
|
|
@@ -1973,6 +2086,15 @@ var orderFormAdapter = {
|
|
|
1973
2086
|
var _a, _b;
|
|
1974
2087
|
return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
|
|
1975
2088
|
},
|
|
2089
|
+
coupon_message: (context) => {
|
|
2090
|
+
var _a;
|
|
2091
|
+
if (context.couponMessage) return context.couponMessage;
|
|
2092
|
+
const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
|
|
2093
|
+
if (messages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
2094
|
+
const couponMessages = messages.filter((msg) => msg.text.toLowerCase().includes("cupom"));
|
|
2095
|
+
if (couponMessages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
|
|
2096
|
+
return couponMessages.map((msg) => msg.text).join(" | ");
|
|
2097
|
+
},
|
|
1976
2098
|
coupon: (context) => {
|
|
1977
2099
|
var _a, _b;
|
|
1978
2100
|
return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
|
|
@@ -1985,9 +2107,11 @@ var orderFormAdapter = {
|
|
|
1985
2107
|
// src/formatter.ts
|
|
1986
2108
|
var adapters = {
|
|
1987
2109
|
DECO: decoAdapter,
|
|
2110
|
+
RESERVA: reservaAdapter,
|
|
1988
2111
|
HEADLESS: headlessAdapter,
|
|
1989
2112
|
PICKUP: pickupAdapter,
|
|
1990
|
-
ORDERFORM: orderFormAdapter
|
|
2113
|
+
ORDERFORM: orderFormAdapter,
|
|
2114
|
+
META: metaAdapter
|
|
1991
2115
|
};
|
|
1992
2116
|
async function getParameters(context, eventName, config2) {
|
|
1993
2117
|
var _a;
|