@azzas/azzas-tracker-web 2.0.0-preview.0 → 2.0.0-preview.1
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 +198 -131
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +24 -0
- package/dist/mod.d.ts +24 -0
- package/dist/mod.global.js +198 -131
- package/dist/mod.global.js.map +1 -1
- package/dist/mod.js +198 -131
- package/dist/mod.js.map +1 -1
- package/dist/mod.vtex.global.js +217 -136
- package/package.json +1 -1
package/dist/mod.cjs
CHANGED
|
@@ -319,6 +319,18 @@ var EVENTS = {
|
|
|
319
319
|
hasEcommerce: false,
|
|
320
320
|
destinations: ["DataLayer"],
|
|
321
321
|
requiredParams: ["brand", "line_items", "size", "item_ref"]
|
|
322
|
+
},
|
|
323
|
+
REFINE_RESULTS: {
|
|
324
|
+
name: "refine_results",
|
|
325
|
+
hasEcommerce: false,
|
|
326
|
+
destinations: ["DataLayer"],
|
|
327
|
+
requiredParams: ["brand", "region", "color", "price_range", "size", "category", "ordering"]
|
|
328
|
+
},
|
|
329
|
+
GRID_SIZE: {
|
|
330
|
+
name: "grid_size",
|
|
331
|
+
hasEcommerce: false,
|
|
332
|
+
destinations: ["DataLayer"],
|
|
333
|
+
requiredParams: ["brand", "slot_per_line"]
|
|
322
334
|
}
|
|
323
335
|
};
|
|
324
336
|
|
|
@@ -1135,7 +1147,7 @@ async function getUserInfo(context) {
|
|
|
1135
1147
|
}
|
|
1136
1148
|
|
|
1137
1149
|
// src/params/legacy/index.ts
|
|
1138
|
-
var
|
|
1150
|
+
var legacyGetters = {
|
|
1139
1151
|
brand: getBrand,
|
|
1140
1152
|
items: getItems,
|
|
1141
1153
|
payment_type: getPaymentType,
|
|
@@ -1343,8 +1355,7 @@ var metaAdapters = {
|
|
|
1343
1355
|
return context.meta.brand || null;
|
|
1344
1356
|
},
|
|
1345
1357
|
content_type: (context) => {
|
|
1346
|
-
|
|
1347
|
-
return `regiao`.concat(":" + context.category).concat(context.subcategory ? ":" + context.subcategory : "").concat(":" + context.componentName) || null;
|
|
1358
|
+
return context.meta.content_type || null;
|
|
1348
1359
|
},
|
|
1349
1360
|
region: (context) => {
|
|
1350
1361
|
return context.meta.region || null;
|
|
@@ -1356,14 +1367,18 @@ var metaAdapters = {
|
|
|
1356
1367
|
if (context == null ? void 0 : context.currency) return context.currency;
|
|
1357
1368
|
return "BRL";
|
|
1358
1369
|
},
|
|
1370
|
+
slot_per_line: (context) => {
|
|
1371
|
+
var _a;
|
|
1372
|
+
return (_a = context.meta.slot_per_line) != null ? _a : null;
|
|
1373
|
+
},
|
|
1359
1374
|
search_term: (context) => {
|
|
1360
|
-
return context.
|
|
1375
|
+
return context.meta.search_term || null;
|
|
1361
1376
|
},
|
|
1362
1377
|
search_found: (context) => {
|
|
1363
|
-
return
|
|
1378
|
+
return context.meta.search_found || null;
|
|
1364
1379
|
},
|
|
1365
1380
|
search_quantity: (context) => {
|
|
1366
|
-
return context.
|
|
1381
|
+
return context.meta.search_quantity || 0;
|
|
1367
1382
|
},
|
|
1368
1383
|
promotion_name: (context) => {
|
|
1369
1384
|
return context.meta.promotion_name || null;
|
|
@@ -1374,9 +1389,6 @@ var metaAdapters = {
|
|
|
1374
1389
|
creative_slot: (context) => {
|
|
1375
1390
|
return context.meta.creative_slot || null;
|
|
1376
1391
|
},
|
|
1377
|
-
zipcode: (context) => {
|
|
1378
|
-
return context.zipCode || null;
|
|
1379
|
-
},
|
|
1380
1392
|
size: (context) => {
|
|
1381
1393
|
return context.size || null;
|
|
1382
1394
|
},
|
|
@@ -1388,6 +1400,135 @@ var metaAdapters = {
|
|
|
1388
1400
|
},
|
|
1389
1401
|
type: (context) => {
|
|
1390
1402
|
return context.type || null;
|
|
1403
|
+
},
|
|
1404
|
+
color: (context) => {
|
|
1405
|
+
return context.meta.color || null;
|
|
1406
|
+
},
|
|
1407
|
+
price_range: (context) => {
|
|
1408
|
+
return context.meta.price_range || null;
|
|
1409
|
+
},
|
|
1410
|
+
category: (context) => {
|
|
1411
|
+
return context.meta.category || null;
|
|
1412
|
+
},
|
|
1413
|
+
ordering: (context) => {
|
|
1414
|
+
return context.meta.ordering || null;
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// src/params/adapters/deco/utils.ts
|
|
1419
|
+
var getItemCategory3 = (item) => {
|
|
1420
|
+
var _a;
|
|
1421
|
+
const value = item == null ? void 0 : item.category;
|
|
1422
|
+
if (!value) return "Cole\xE7\xE3o";
|
|
1423
|
+
const text = Array.isArray(value) ? value.join(" ") : String(value);
|
|
1424
|
+
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1425
|
+
return match != null ? match : "Cole\xE7\xE3o";
|
|
1426
|
+
};
|
|
1427
|
+
var getItemCategory22 = (item) => {
|
|
1428
|
+
var _a, _b, _c, _d;
|
|
1429
|
+
const AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
|
|
1430
|
+
const categories = (_b = (_a = item.category) == null ? void 0 : _a.split(">")) != null ? _b : [];
|
|
1431
|
+
const last = (_c = categories[categories.length - 1]) != null ? _c : "";
|
|
1432
|
+
const validHierarchy = last.split("/").filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1433
|
+
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1434
|
+
return capitalize(deepest);
|
|
1435
|
+
};
|
|
1436
|
+
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
1437
|
+
return url == null ? void 0 : url.replace(
|
|
1438
|
+
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1439
|
+
`$1-${width}-${height}/`
|
|
1440
|
+
);
|
|
1441
|
+
};
|
|
1442
|
+
function getItemShippingTier2() {
|
|
1443
|
+
return null;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// src/params/adapters/deco/index.ts
|
|
1447
|
+
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
1448
|
+
var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
1449
|
+
var decoAdapter = {
|
|
1450
|
+
...metaAdapters,
|
|
1451
|
+
// global adapters
|
|
1452
|
+
items: (context) => {
|
|
1453
|
+
if (context == null ? void 0 : context.items) return context.items;
|
|
1454
|
+
if (context == null ? void 0 : context.products) {
|
|
1455
|
+
return context.products.map((item) => {
|
|
1456
|
+
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;
|
|
1457
|
+
const COLOR_REGEX = /^[^_]+_/;
|
|
1458
|
+
const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
|
|
1459
|
+
(s) => s.priceType === LIST_PRICE_SCHEMA
|
|
1460
|
+
)) == null ? void 0 : _c.price;
|
|
1461
|
+
return {
|
|
1462
|
+
quantity: 1,
|
|
1463
|
+
index: (_d = item == null ? void 0 : item.index) != null ? _d : 0,
|
|
1464
|
+
item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
|
|
1465
|
+
item_name: (_h = item.alternateName) != null ? _h : null,
|
|
1466
|
+
price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
|
|
1467
|
+
discount: Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice),
|
|
1468
|
+
item_variant: ((_m = (_l = item == null ? void 0 : item.name) == null ? void 0 : _l.split(" - ")[0]) == null ? void 0 : _m.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
|
|
1469
|
+
// cor
|
|
1470
|
+
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1471
|
+
// tamanho
|
|
1472
|
+
item_shipping_tier: getItemShippingTier2(),
|
|
1473
|
+
item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find(((i) => i.name === "RefId"))) == null ? void 0 : _q.value) != null ? _r : null,
|
|
1474
|
+
item_category: (_s = getItemCategory3(item)) != null ? _s : null,
|
|
1475
|
+
item_category2: (_t = getItemCategory22(item)) != null ? _t : null,
|
|
1476
|
+
item_id: (_u = item == null ? void 0 : item.inProductGroupWithID) != null ? _u : null,
|
|
1477
|
+
item_sku: (_v = item.sku) != null ? _v : null,
|
|
1478
|
+
item_url: (_w = item.url) != null ? _w : null,
|
|
1479
|
+
image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
|
|
1480
|
+
seller_id: (_C = (_B = (_A = (_z = item.offers) == null ? void 0 : _z.offers) == null ? void 0 : _A[0]) == null ? void 0 : _B.seller) != null ? _C : null,
|
|
1481
|
+
item_list_name: (_D = item == null ? void 0 : item.item_list_name) != null ? _D : null
|
|
1482
|
+
};
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
return null;
|
|
1486
|
+
},
|
|
1487
|
+
// brand: (context: DecoBrandContext) => {
|
|
1488
|
+
// if (context?.brand) return context.brand
|
|
1489
|
+
// if (context?.products) {
|
|
1490
|
+
// return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
|
|
1491
|
+
// }
|
|
1492
|
+
// return null
|
|
1493
|
+
// },
|
|
1494
|
+
line_items: (context) => {
|
|
1495
|
+
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1496
|
+
if (context == null ? void 0 : context.products) {
|
|
1497
|
+
return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id));
|
|
1498
|
+
}
|
|
1499
|
+
return null;
|
|
1500
|
+
},
|
|
1501
|
+
value: (context) => {
|
|
1502
|
+
if (context == null ? void 0 : context.value) return context.value;
|
|
1503
|
+
if (context == null ? void 0 : context.products) {
|
|
1504
|
+
return context.products.map((item) => {
|
|
1505
|
+
var _a;
|
|
1506
|
+
return (_a = item.offers) == null ? void 0 : _a.lowPrice;
|
|
1507
|
+
}).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1508
|
+
}
|
|
1509
|
+
return null;
|
|
1510
|
+
},
|
|
1511
|
+
available_grid: (context) => {
|
|
1512
|
+
if (context == null ? void 0 : context.available_grid) return context.available_grid;
|
|
1513
|
+
if (context == null ? void 0 : context.products) {
|
|
1514
|
+
const sizes = context.products.flatMap(
|
|
1515
|
+
(product) => {
|
|
1516
|
+
var _a, _b, _c;
|
|
1517
|
+
return (_c = (_b = (_a = product.isVariantOf) == null ? void 0 : _a.hasVariant) == null ? void 0 : _b.filter(
|
|
1518
|
+
(variant) => {
|
|
1519
|
+
var _a2, _b2;
|
|
1520
|
+
return (_b2 = (_a2 = variant.offers) == null ? void 0 : _a2.offers) == null ? void 0 : _b2.some((o) => o.availability === IN_STOCK_SCHEMA);
|
|
1521
|
+
}
|
|
1522
|
+
).map((variant) => {
|
|
1523
|
+
var _a2;
|
|
1524
|
+
return (_a2 = variant.name) == null ? void 0 : _a2.split(" - ")[1];
|
|
1525
|
+
}).filter((name) => Boolean(name))) != null ? _c : [];
|
|
1526
|
+
}
|
|
1527
|
+
);
|
|
1528
|
+
const result = sortSizes(sizes).join(",").trim();
|
|
1529
|
+
return result || null;
|
|
1530
|
+
}
|
|
1531
|
+
return null;
|
|
1391
1532
|
}
|
|
1392
1533
|
};
|
|
1393
1534
|
|
|
@@ -1520,126 +1661,7 @@ var orderFormAdapters = {
|
|
|
1520
1661
|
}
|
|
1521
1662
|
};
|
|
1522
1663
|
|
|
1523
|
-
// src/params/adapters/
|
|
1524
|
-
var getItemCategory3 = (item) => {
|
|
1525
|
-
var _a;
|
|
1526
|
-
const value = item == null ? void 0 : item.category;
|
|
1527
|
-
if (!value) return "Cole\xE7\xE3o";
|
|
1528
|
-
const text = Array.isArray(value) ? value.join(" ") : String(value);
|
|
1529
|
-
const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
|
|
1530
|
-
return match != null ? match : "Cole\xE7\xE3o";
|
|
1531
|
-
};
|
|
1532
|
-
var getItemCategory22 = (item) => {
|
|
1533
|
-
var _a, _b, _c, _d;
|
|
1534
|
-
const AVOID_CATEGORIES = /^(outlet|bazar|sale)$/i;
|
|
1535
|
-
const categories = (_b = (_a = item.category) == null ? void 0 : _a.split(">")) != null ? _b : [];
|
|
1536
|
-
const last = (_c = categories[categories.length - 1]) != null ? _c : "";
|
|
1537
|
-
const validHierarchy = last.split("/").filter((c) => c && !AVOID_CATEGORIES.test(c));
|
|
1538
|
-
const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
|
|
1539
|
-
return capitalize(deepest);
|
|
1540
|
-
};
|
|
1541
|
-
var resizeVtexImage2 = (url, width = 500, height = 500) => {
|
|
1542
|
-
return url == null ? void 0 : url.replace(
|
|
1543
|
-
/(\/arquivos\/ids\/\d+)-\d+-\d+\//,
|
|
1544
|
-
`$1-${width}-${height}/`
|
|
1545
|
-
);
|
|
1546
|
-
};
|
|
1547
|
-
function getItemShippingTier2() {
|
|
1548
|
-
return null;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
// src/params/adapters/deco/index.ts
|
|
1552
|
-
var IN_STOCK_SCHEMA = "https://schema.org/InStock";
|
|
1553
|
-
var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
|
|
1554
|
-
var decoAdapter = {
|
|
1555
|
-
...metaAdapters,
|
|
1556
|
-
// global adapters
|
|
1557
|
-
...orderFormAdapters,
|
|
1558
|
-
// orderform adapters
|
|
1559
|
-
items: (context) => {
|
|
1560
|
-
if (context == null ? void 0 : context.items) return context.items;
|
|
1561
|
-
if (context == null ? void 0 : context.products) {
|
|
1562
|
-
return context.products.map((item) => {
|
|
1563
|
-
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;
|
|
1564
|
-
const COLOR_REGEX = /^[^_]+_/;
|
|
1565
|
-
const listPrice = (_c = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].priceSpecification.find(
|
|
1566
|
-
(s) => s.priceType === LIST_PRICE_SCHEMA
|
|
1567
|
-
)) == null ? void 0 : _c.price;
|
|
1568
|
-
return {
|
|
1569
|
-
quantity: 1,
|
|
1570
|
-
index: (_d = item == null ? void 0 : item.index) != null ? _d : 0,
|
|
1571
|
-
item_brand: (_g = (_f = (_e = item.brand) == null ? void 0 : _e.name) == null ? void 0 : _f.toLowerCase()) != null ? _g : null,
|
|
1572
|
-
item_name: (_h = item.alternateName) != null ? _h : null,
|
|
1573
|
-
price: (_j = (_i = item.offers) == null ? void 0 : _i.lowPrice) != null ? _j : null,
|
|
1574
|
-
discount: Number(listPrice) - Number((_k = item == null ? void 0 : item.offers) == null ? void 0 : _k.lowPrice),
|
|
1575
|
-
item_variant: ((_m = (_l = item == null ? void 0 : item.name) == null ? void 0 : _l.split(" - ")[0]) == null ? void 0 : _m.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
|
|
1576
|
-
// cor
|
|
1577
|
-
item_variant2: (_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[1]) != null ? _o : null,
|
|
1578
|
-
// tamanho
|
|
1579
|
-
item_shipping_tier: getItemShippingTier2(),
|
|
1580
|
-
item_ref: (_r = (_q = (_p = item.additionalProperty) == null ? void 0 : _p.find(((i) => i.name === "RefId"))) == null ? void 0 : _q.value) != null ? _r : null,
|
|
1581
|
-
item_category: (_s = getItemCategory3(item)) != null ? _s : null,
|
|
1582
|
-
item_category2: (_t = getItemCategory22(item)) != null ? _t : null,
|
|
1583
|
-
item_id: (_u = item == null ? void 0 : item.inProductGroupWithID) != null ? _u : null,
|
|
1584
|
-
item_sku: (_v = item.sku) != null ? _v : null,
|
|
1585
|
-
item_url: (_w = item.url) != null ? _w : null,
|
|
1586
|
-
image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
|
|
1587
|
-
seller_id: (_C = (_B = (_A = (_z = item.offers) == null ? void 0 : _z.offers) == null ? void 0 : _A[0]) == null ? void 0 : _B.seller) != null ? _C : null,
|
|
1588
|
-
item_list_name: (_D = item == null ? void 0 : item.item_list_name) != null ? _D : null
|
|
1589
|
-
};
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
return null;
|
|
1593
|
-
},
|
|
1594
|
-
// brand: (context: DecoBrandContext) => {
|
|
1595
|
-
// if (context?.brand) return context.brand
|
|
1596
|
-
// if (context?.products) {
|
|
1597
|
-
// return context.products[0].brand?.name // tem que ajustar FARM por conta de FARM_ETC
|
|
1598
|
-
// }
|
|
1599
|
-
// return null
|
|
1600
|
-
// },
|
|
1601
|
-
line_items: (context) => {
|
|
1602
|
-
if (context == null ? void 0 : context.line_items) return context.line_items;
|
|
1603
|
-
if (context == null ? void 0 : context.products) {
|
|
1604
|
-
return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id));
|
|
1605
|
-
}
|
|
1606
|
-
return null;
|
|
1607
|
-
},
|
|
1608
|
-
value: (context) => {
|
|
1609
|
-
if (context == null ? void 0 : context.value) return context.value;
|
|
1610
|
-
if (context == null ? void 0 : context.products) {
|
|
1611
|
-
return context.products.map((item) => {
|
|
1612
|
-
var _a;
|
|
1613
|
-
return (_a = item.offers) == null ? void 0 : _a.lowPrice;
|
|
1614
|
-
}).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
|
|
1615
|
-
}
|
|
1616
|
-
return null;
|
|
1617
|
-
},
|
|
1618
|
-
available_grid: (context) => {
|
|
1619
|
-
if (context == null ? void 0 : context.available_grid) return context.available_grid;
|
|
1620
|
-
if (context == null ? void 0 : context.products) {
|
|
1621
|
-
const sizes = context.products.flatMap(
|
|
1622
|
-
(product) => {
|
|
1623
|
-
var _a, _b, _c;
|
|
1624
|
-
return (_c = (_b = (_a = product.isVariantOf) == null ? void 0 : _a.hasVariant) == null ? void 0 : _b.filter(
|
|
1625
|
-
(variant) => {
|
|
1626
|
-
var _a2, _b2;
|
|
1627
|
-
return (_b2 = (_a2 = variant.offers) == null ? void 0 : _a2.offers) == null ? void 0 : _b2.some((o) => o.availability === IN_STOCK_SCHEMA);
|
|
1628
|
-
}
|
|
1629
|
-
).map((variant) => {
|
|
1630
|
-
var _a2;
|
|
1631
|
-
return (_a2 = variant.name) == null ? void 0 : _a2.split(" - ")[1];
|
|
1632
|
-
}).filter((name) => Boolean(name))) != null ? _c : [];
|
|
1633
|
-
}
|
|
1634
|
-
);
|
|
1635
|
-
const result = sortSizes(sizes).join(",").trim();
|
|
1636
|
-
return result || null;
|
|
1637
|
-
}
|
|
1638
|
-
return null;
|
|
1639
|
-
}
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
|
-
// src/params/adapters/headless/utils/index.ts
|
|
1664
|
+
// src/params/adapters/headless/utils.ts
|
|
1643
1665
|
var getItemCategory5 = (item) => {
|
|
1644
1666
|
const keywords = ["outlet", "bazar", "sale"];
|
|
1645
1667
|
const regex = new RegExp(keywords.join("|"), "i");
|
|
@@ -1838,17 +1860,62 @@ var headlessAdapter = {
|
|
|
1838
1860
|
}
|
|
1839
1861
|
};
|
|
1840
1862
|
|
|
1863
|
+
// src/params/adapters/pickup/utils.ts
|
|
1864
|
+
var getShippingTier = (sla) => {
|
|
1865
|
+
var _a, _b;
|
|
1866
|
+
const isPickup = sla.deliveryChannel === "pickup-in-point" /* PickupInPoint */;
|
|
1867
|
+
if (isPickup) {
|
|
1868
|
+
const storeName = (_b = (_a = sla.pickupStoreInfo) == null ? void 0 : _a.friendlyName) == null ? void 0 : _b.trim();
|
|
1869
|
+
return storeName ? `retirada em loja: ${storeName}` : "retirada em loja";
|
|
1870
|
+
}
|
|
1871
|
+
return sla.name ? `receba em casa: ${sla.name.toLowerCase()}` : "receba em casa";
|
|
1872
|
+
};
|
|
1873
|
+
var getDeliveryTime = (sla) => {
|
|
1874
|
+
const estimate = sla.shippingEstimate;
|
|
1875
|
+
if (!estimate) return 0;
|
|
1876
|
+
const days = parseInt(estimate, 10);
|
|
1877
|
+
return isNaN(days) ? 0 : days;
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
// src/params/adapters/pickup/index.ts
|
|
1881
|
+
var pickupAdapter = {
|
|
1882
|
+
...metaAdapters,
|
|
1883
|
+
flag_pickup: (context) => {
|
|
1884
|
+
var _a;
|
|
1885
|
+
return (_a = context == null ? void 0 : context.flag_pickup) != null ? _a : null;
|
|
1886
|
+
},
|
|
1887
|
+
shippings: (context) => {
|
|
1888
|
+
if (context.shippings) {
|
|
1889
|
+
return context.shippings.map((s) => {
|
|
1890
|
+
var _a, _b;
|
|
1891
|
+
return {
|
|
1892
|
+
line_items: (_a = s.line_items) != null ? _a : "",
|
|
1893
|
+
shipping: (_b = s.price) != null ? _b : 0,
|
|
1894
|
+
shipping_tier: getShippingTier(s),
|
|
1895
|
+
delivery_time: getDeliveryTime(s)
|
|
1896
|
+
};
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
return null;
|
|
1900
|
+
},
|
|
1901
|
+
zipcode: (context) => {
|
|
1902
|
+
var _a;
|
|
1903
|
+
return (_a = context.zipcode) != null ? _a : null;
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1841
1907
|
// src/formatter.ts
|
|
1842
1908
|
var adapters = {
|
|
1843
1909
|
DECO: decoAdapter,
|
|
1844
|
-
HEADLESS: headlessAdapter
|
|
1910
|
+
HEADLESS: headlessAdapter,
|
|
1911
|
+
PICKUP: pickupAdapter
|
|
1845
1912
|
};
|
|
1846
1913
|
async function getParameters(context, eventName) {
|
|
1847
1914
|
var _a;
|
|
1848
1915
|
const eventConfig = EVENTS[eventName];
|
|
1849
1916
|
if (!eventConfig) return;
|
|
1850
1917
|
const currentAdapter = context.adapter;
|
|
1851
|
-
const getters = (_a = adapters[currentAdapter]) != null ? _a :
|
|
1918
|
+
const getters = (_a = adapters[currentAdapter]) != null ? _a : legacyGetters;
|
|
1852
1919
|
const entries = await Promise.all(
|
|
1853
1920
|
eventConfig.requiredParams.map(async (param) => {
|
|
1854
1921
|
const getter = getters[param];
|