@infrab4a/connect 5.5.6-beta.1 → 5.5.6-beta.3

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.
Files changed (3) hide show
  1. package/index.cjs.js +19 -13
  2. package/index.esm.js +19 -13
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -2435,9 +2435,9 @@ class ShopSettings extends BaseModel {
2435
2435
  if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2436
2436
  const filteredBanners = section.banners.filter((banner) => {
2437
2437
  // Filtra por displayRules
2438
- const rulesMatch = banner.displayRules
2439
- ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2440
- : false;
2438
+ const rulesMatch = banner.displayRules.length
2439
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2440
+ : true;
2441
2441
  // Filtra por publishDate e expirationDate
2442
2442
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2443
2443
  const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
@@ -2449,27 +2449,30 @@ class ShopSettings extends BaseModel {
2449
2449
  if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2450
2450
  const filteredHighlights = section.highlights.filter((highlight) => {
2451
2451
  // Filtra por displayRules
2452
- const rulesMatch = highlight.displayRules
2453
- ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2454
- : false;
2452
+ const rulesMatch = highlight.displayRules.length
2453
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2454
+ : true;
2455
2455
  return rulesMatch;
2456
2456
  });
2457
- return { ...section, highlights: filteredHighlights };
2457
+ const sortedHighlights = !displayRules.beautyProfile
2458
+ ? filteredHighlights.sort((a, b) => (a.starred === b.starred ? 0 : a.starred ? -1 : 1))
2459
+ : filteredHighlights;
2460
+ return { ...section, highlights: sortedHighlights };
2458
2461
  }
2459
2462
  // Filtra collections
2460
2463
  if (section.type === ShopPageSectionType.COLLECTION) {
2461
- const rulesMatch = section.displayRules
2462
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2463
- : false;
2464
+ const rulesMatch = section.displayRules.length
2465
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2466
+ : true;
2464
2467
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2465
2468
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2466
2469
  return rulesMatch && publishOk && expireOk ? section : null;
2467
2470
  }
2468
2471
  // Filtra banners
2469
2472
  if (section.type === ShopPageSectionType.BANNER) {
2470
- const rulesMatch = section.displayRules
2471
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2472
- : false;
2473
+ const rulesMatch = section.displayRules.length
2474
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2475
+ : true;
2473
2476
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2474
2477
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2475
2478
  return rulesMatch && publishOk && expireOk ? section : null;
@@ -2477,6 +2480,9 @@ class ShopSettings extends BaseModel {
2477
2480
  if (section.type === ShopPageSectionType.LIVE) {
2478
2481
  return section.active ? section : null;
2479
2482
  }
2483
+ if (section.type === ShopPageSectionType.PLANS || section.type === ShopPageSectionType.SINGLE_PLAN) {
2484
+ return displayRules.notSubscriber ? section : null;
2485
+ }
2480
2486
  // Demais seções retornam normalmente
2481
2487
  return section;
2482
2488
  })
package/index.esm.js CHANGED
@@ -2411,9 +2411,9 @@ class ShopSettings extends BaseModel {
2411
2411
  if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2412
2412
  const filteredBanners = section.banners.filter((banner) => {
2413
2413
  // Filtra por displayRules
2414
- const rulesMatch = banner.displayRules
2415
- ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2416
- : false;
2414
+ const rulesMatch = banner.displayRules.length
2415
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2416
+ : true;
2417
2417
  // Filtra por publishDate e expirationDate
2418
2418
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2419
2419
  const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
@@ -2425,27 +2425,30 @@ class ShopSettings extends BaseModel {
2425
2425
  if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2426
2426
  const filteredHighlights = section.highlights.filter((highlight) => {
2427
2427
  // Filtra por displayRules
2428
- const rulesMatch = highlight.displayRules
2429
- ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2430
- : false;
2428
+ const rulesMatch = highlight.displayRules.length
2429
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2430
+ : true;
2431
2431
  return rulesMatch;
2432
2432
  });
2433
- return { ...section, highlights: filteredHighlights };
2433
+ const sortedHighlights = !displayRules.beautyProfile
2434
+ ? filteredHighlights.sort((a, b) => (a.starred === b.starred ? 0 : a.starred ? -1 : 1))
2435
+ : filteredHighlights;
2436
+ return { ...section, highlights: sortedHighlights };
2434
2437
  }
2435
2438
  // Filtra collections
2436
2439
  if (section.type === ShopPageSectionType.COLLECTION) {
2437
- const rulesMatch = section.displayRules
2438
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2439
- : false;
2440
+ const rulesMatch = section.displayRules.length
2441
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2442
+ : true;
2440
2443
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2441
2444
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2442
2445
  return rulesMatch && publishOk && expireOk ? section : null;
2443
2446
  }
2444
2447
  // Filtra banners
2445
2448
  if (section.type === ShopPageSectionType.BANNER) {
2446
- const rulesMatch = section.displayRules
2447
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2448
- : false;
2449
+ const rulesMatch = section.displayRules.length
2450
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2451
+ : true;
2449
2452
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2450
2453
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2451
2454
  return rulesMatch && publishOk && expireOk ? section : null;
@@ -2453,6 +2456,9 @@ class ShopSettings extends BaseModel {
2453
2456
  if (section.type === ShopPageSectionType.LIVE) {
2454
2457
  return section.active ? section : null;
2455
2458
  }
2459
+ if (section.type === ShopPageSectionType.PLANS || section.type === ShopPageSectionType.SINGLE_PLAN) {
2460
+ return displayRules.notSubscriber ? section : null;
2461
+ }
2456
2462
  // Demais seções retornam normalmente
2457
2463
  return section;
2458
2464
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.6-beta.1",
3
+ "version": "5.5.6-beta.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },