@infrab4a/connect 5.5.6-beta.0 → 5.5.6-beta.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/index.cjs.js CHANGED
@@ -2435,8 +2435,8 @@ 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])
2438
+ const rulesMatch = banner.displayRules.length
2439
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2440
2440
  : true;
2441
2441
  // Filtra por publishDate e expirationDate
2442
2442
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
@@ -2449,8 +2449,8 @@ 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])
2452
+ const rulesMatch = highlight.displayRules.length
2453
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2454
2454
  : true;
2455
2455
  return rulesMatch;
2456
2456
  });
@@ -2458,17 +2458,20 @@ class ShopSettings extends BaseModel {
2458
2458
  }
2459
2459
  // Filtra collections
2460
2460
  if (section.type === ShopPageSectionType.COLLECTION) {
2461
- const rulesMatch = section.displayRules
2462
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2461
+ console.warn('SECTION', section.title, section.slug, displayRules);
2462
+ const rulesMatch = section.displayRules.length
2463
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2463
2464
  : true;
2465
+ console.warn('RULES MATCH', rulesMatch);
2464
2466
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2465
2467
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2468
+ console.warn('PUBLISH OK', publishOk, 'EXPIRE OK', expireOk);
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])
2473
+ const rulesMatch = section.displayRules.length
2474
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2472
2475
  : true;
2473
2476
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2474
2477
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
package/index.esm.js CHANGED
@@ -2411,8 +2411,8 @@ 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])
2414
+ const rulesMatch = banner.displayRules.length
2415
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2416
2416
  : true;
2417
2417
  // Filtra por publishDate e expirationDate
2418
2418
  const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
@@ -2425,8 +2425,8 @@ 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])
2428
+ const rulesMatch = highlight.displayRules.length
2429
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2430
2430
  : true;
2431
2431
  return rulesMatch;
2432
2432
  });
@@ -2434,17 +2434,20 @@ class ShopSettings extends BaseModel {
2434
2434
  }
2435
2435
  // Filtra collections
2436
2436
  if (section.type === ShopPageSectionType.COLLECTION) {
2437
- const rulesMatch = section.displayRules
2438
- ? Object.keys(displayRules).some((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2437
+ console.warn('SECTION', section.title, section.slug, displayRules);
2438
+ const rulesMatch = section.displayRules.length
2439
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2439
2440
  : true;
2441
+ console.warn('RULES MATCH', rulesMatch);
2440
2442
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2441
2443
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2444
+ console.warn('PUBLISH OK', publishOk, 'EXPIRE OK', expireOk);
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])
2449
+ const rulesMatch = section.displayRules.length
2450
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2448
2451
  : true;
2449
2452
  const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2450
2453
  const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.6-beta.0",
3
+ "version": "5.5.6-beta.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -59,7 +59,7 @@ export type Highlight = {
59
59
  altText: string;
60
60
  highlighted: boolean;
61
61
  starred: boolean;
62
- displayRules?: DisplayRules;
62
+ displayRules?: Array<Partial<DisplayRules>>;
63
63
  };
64
64
  export type SectionSubscriberInfo = {
65
65
  id: string;
@@ -74,7 +74,7 @@ export type Banner = {
74
74
  link: string;
75
75
  altText: string;
76
76
  countdown?: string;
77
- displayRules?: DisplayRules;
77
+ displayRules?: Array<Partial<DisplayRules>>;
78
78
  publishDate?: Date;
79
79
  expirationDate?: Date;
80
80
  };
@@ -91,7 +91,7 @@ export type SectionCollection = {
91
91
  slug: string;
92
92
  title: string;
93
93
  categoryId: number;
94
- displayRules?: DisplayRules;
94
+ displayRules?: Array<Partial<DisplayRules>>;
95
95
  publishDate?: Date;
96
96
  expirationDate?: Date;
97
97
  };
@@ -120,18 +120,17 @@ export type SectionSinglePlan = {
120
120
  fixed: boolean;
121
121
  editable: boolean;
122
122
  };
123
+ export type Brand = {
124
+ slug: string;
125
+ image: string;
126
+ brandName: string;
127
+ };
123
128
  export type SectionBrands = {
124
129
  id: string;
125
130
  type: ShopPageSectionType.BRANDS;
126
131
  fixed: boolean;
127
132
  editable: boolean;
128
- brands: [
129
- {
130
- slug: string;
131
- image: string;
132
- brandName: string;
133
- }
134
- ];
133
+ brands: Brand[];
135
134
  };
136
135
  export type SectionNewsletter = {
137
136
  id: string;