@infrab4a/connect 5.5.4 → 5.5.5-beta.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/index.cjs.js CHANGED
@@ -2328,6 +2328,7 @@ exports.ShopPageName = void 0;
2328
2328
  ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
2329
2329
  ShopPageName["LP_INVITE"] = "LP_INVITE";
2330
2330
  ShopPageName["LP_LIVELO"] = "LP_LIVELO";
2331
+ ShopPageName["GLAM_NEW_HOME"] = "GLAM_NEW_HOME";
2331
2332
  })(exports.ShopPageName || (exports.ShopPageName = {}));
2332
2333
 
2333
2334
  class BeautyQuestionsHelper {
@@ -2405,10 +2406,56 @@ class ShopMenu extends BaseModel {
2405
2406
  }
2406
2407
  }
2407
2408
 
2409
+ var ShopPageSectionType;
2410
+ (function (ShopPageSectionType) {
2411
+ ShopPageSectionType["LIVE"] = "LIVE";
2412
+ ShopPageSectionType["CAROUSEL"] = "CAROUSEL";
2413
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2414
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2415
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2416
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2417
+ ShopPageSectionType["PLANS"] = "PLANS";
2418
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2419
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2420
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2421
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2422
+
2408
2423
  class ShopSettings extends BaseModel {
2409
2424
  static get identifiersFields() {
2410
2425
  return ['id'];
2411
2426
  }
2427
+ pageSections(displayRules) {
2428
+ const now = new Date();
2429
+ return (Array.isArray(this.sections) ? this.sections : [])
2430
+ .map((section) => {
2431
+ // Filtra banners dentro de carrousel
2432
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2433
+ const filteredBanners = section.banners.filter((banner) => {
2434
+ // Filtra por displayRules
2435
+ const rulesMatch = banner.displayRules
2436
+ ? Object.keys(displayRules).every((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2437
+ : true;
2438
+ // Filtra por publishDate e expirationDate
2439
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2440
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2441
+ return rulesMatch && publishOk && expireOk;
2442
+ });
2443
+ return { ...section, banners: filteredBanners };
2444
+ }
2445
+ // Filtra collections
2446
+ if (section.type === ShopPageSectionType.COLLECTION) {
2447
+ const rulesMatch = section.displayRules
2448
+ ? Object.keys(displayRules).every((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2449
+ : true;
2450
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2451
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2452
+ return rulesMatch && publishOk && expireOk ? section : null;
2453
+ }
2454
+ // Demais seções retornam normalmente
2455
+ return section;
2456
+ })
2457
+ .filter(Boolean);
2458
+ }
2412
2459
  }
2413
2460
 
2414
2461
  class AdyenBlockedOrderHelper {
package/index.esm.js CHANGED
@@ -2304,6 +2304,7 @@ var ShopPageName;
2304
2304
  ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
2305
2305
  ShopPageName["LP_INVITE"] = "LP_INVITE";
2306
2306
  ShopPageName["LP_LIVELO"] = "LP_LIVELO";
2307
+ ShopPageName["GLAM_NEW_HOME"] = "GLAM_NEW_HOME";
2307
2308
  })(ShopPageName || (ShopPageName = {}));
2308
2309
 
2309
2310
  class BeautyQuestionsHelper {
@@ -2381,10 +2382,56 @@ class ShopMenu extends BaseModel {
2381
2382
  }
2382
2383
  }
2383
2384
 
2385
+ var ShopPageSectionType;
2386
+ (function (ShopPageSectionType) {
2387
+ ShopPageSectionType["LIVE"] = "LIVE";
2388
+ ShopPageSectionType["CAROUSEL"] = "CAROUSEL";
2389
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2390
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2391
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2392
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2393
+ ShopPageSectionType["PLANS"] = "PLANS";
2394
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2395
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2396
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2397
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2398
+
2384
2399
  class ShopSettings extends BaseModel {
2385
2400
  static get identifiersFields() {
2386
2401
  return ['id'];
2387
2402
  }
2403
+ pageSections(displayRules) {
2404
+ const now = new Date();
2405
+ return (Array.isArray(this.sections) ? this.sections : [])
2406
+ .map((section) => {
2407
+ // Filtra banners dentro de carrousel
2408
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2409
+ const filteredBanners = section.banners.filter((banner) => {
2410
+ // Filtra por displayRules
2411
+ const rulesMatch = banner.displayRules
2412
+ ? Object.keys(displayRules).every((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2413
+ : true;
2414
+ // Filtra por publishDate e expirationDate
2415
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2416
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2417
+ return rulesMatch && publishOk && expireOk;
2418
+ });
2419
+ return { ...section, banners: filteredBanners };
2420
+ }
2421
+ // Filtra collections
2422
+ if (section.type === ShopPageSectionType.COLLECTION) {
2423
+ const rulesMatch = section.displayRules
2424
+ ? Object.keys(displayRules).every((key) => section.displayRules && section.displayRules[key] === displayRules[key])
2425
+ : true;
2426
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2427
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2428
+ return rulesMatch && publishOk && expireOk ? section : null;
2429
+ }
2430
+ // Demais seções retornam normalmente
2431
+ return section;
2432
+ })
2433
+ .filter(Boolean);
2434
+ }
2388
2435
  }
2389
2436
 
2390
2437
  class AdyenBlockedOrderHelper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.4",
3
+ "version": "5.5.5-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -15,5 +15,6 @@ export declare enum ShopPageName {
15
15
  LP_GLAMPARTNER_PROMOTION = "LP_GLAMPARTNER_PROMOTION",
16
16
  LP_GLAMQUEENS = "LP_GLAMQUEENS",
17
17
  LP_INVITE = "LP_INVITE",
18
- LP_LIVELO = "LP_LIVELO"
18
+ LP_LIVELO = "LP_LIVELO",
19
+ GLAM_NEW_HOME = "GLAM_NEW_HOME"
19
20
  }
@@ -1,15 +1,18 @@
1
1
  import { BaseModel, GenericIdentifier } from '../../generic/model';
2
2
  import { ShopPageName } from '../enums';
3
3
  import { Section } from './types';
4
+ import { DisplayRules, SectionUnion, ShopPageSection } from './types/shop-page-section.type';
4
5
  export declare class ShopSettings extends BaseModel<ShopSettings> {
5
6
  id: string | ShopPageName;
6
7
  name: string;
7
8
  shop: string;
8
- sections: Section<any>;
9
+ preview?: string;
10
+ sections: Section<any> | ShopPageSection[];
9
11
  descriptionMeta?: string;
10
12
  titleMeta?: string;
11
13
  imageMeta?: string;
12
14
  hasMultiples?: boolean;
13
15
  pagePath?: string;
14
16
  static get identifiersFields(): GenericIdentifier[];
17
+ pageSections(displayRules: DisplayRules): SectionUnion[];
15
18
  }
@@ -0,0 +1,111 @@
1
+ export type ShopPageSection = Array<SectionUnion>;
2
+ export type SectionUnion = SectionLive | SectionCarousel | SectionInfobars | SectionHighlights | SectionSubscriberInfo | SectionCollection | SectionPlans | SectionSinglePlan | SectionBrands | SectionNewsletter;
3
+ export declare enum ShopPageSectionType {
4
+ LIVE = "LIVE",
5
+ CAROUSEL = "CAROUSEL",
6
+ INFOBARS = "INFOBARS",
7
+ HIGHLIGHTS = "HIGHLIGHTS",
8
+ SUBSCRIBER_INFO = "SUBSCRIBER_INFO",
9
+ COLLECTION = "COLLECTION",
10
+ PLANS = "PLANS",
11
+ SINGLE_PLAN = "SINGLE_PLAN",
12
+ BRANDS = "BRANDS",
13
+ NEWSLETTER = "NEWSLETTER"
14
+ }
15
+ export type SectionLive = {
16
+ type: ShopPageSectionType.LIVE;
17
+ fixed: boolean;
18
+ editable: boolean;
19
+ title: string;
20
+ link: string;
21
+ active: boolean;
22
+ };
23
+ export type SectionCarousel = {
24
+ type: ShopPageSectionType.CAROUSEL;
25
+ fixed: boolean;
26
+ editable: boolean;
27
+ banners: Banner[];
28
+ };
29
+ export type SectionInfobars = {
30
+ type: ShopPageSectionType.INFOBARS;
31
+ fixed: boolean;
32
+ editable: boolean;
33
+ infobars: Infobar[];
34
+ };
35
+ export type Infobar = {
36
+ link: string;
37
+ text: string;
38
+ active: boolean;
39
+ };
40
+ export type SectionHighlights = {
41
+ type: ShopPageSectionType.HIGHLIGHTS;
42
+ fixed: boolean;
43
+ editable: boolean;
44
+ highlights: Highlight[];
45
+ };
46
+ export type Highlight = {
47
+ title: string;
48
+ link: string;
49
+ image: string;
50
+ altText: string;
51
+ highlighted: boolean;
52
+ };
53
+ export type SectionSubscriberInfo = {
54
+ type: ShopPageSectionType.SUBSCRIBER_INFO;
55
+ fixed: boolean;
56
+ editable: boolean;
57
+ };
58
+ export type Banner = {
59
+ mobileImage: string;
60
+ desktopImage: string;
61
+ link: string;
62
+ altText: string;
63
+ countdown?: string;
64
+ displayRules?: DisplayRules;
65
+ publishDate?: Date;
66
+ expirationDate?: Date;
67
+ };
68
+ export type SectionCollection = {
69
+ type: ShopPageSectionType.COLLECTION;
70
+ fixed: boolean;
71
+ editable: boolean;
72
+ slug: string;
73
+ title: string;
74
+ categoryId: number;
75
+ displayRules?: DisplayRules;
76
+ publishDate?: Date;
77
+ expirationDate?: Date;
78
+ };
79
+ export type DisplayRules = {
80
+ subscriberBuyer: boolean;
81
+ notSubscriber: boolean;
82
+ subscriberNotBuyer: boolean;
83
+ topBadgeSubscriber: boolean;
84
+ };
85
+ export type SectionPlans = {
86
+ type: ShopPageSectionType.PLANS;
87
+ fixed: boolean;
88
+ editable: boolean;
89
+ };
90
+ export type SectionSinglePlan = {
91
+ type: ShopPageSectionType.SINGLE_PLAN;
92
+ fixed: boolean;
93
+ editable: boolean;
94
+ };
95
+ export type SectionBrands = {
96
+ type: ShopPageSectionType.BRANDS;
97
+ fixed: boolean;
98
+ editable: boolean;
99
+ brands: [
100
+ {
101
+ slug: string;
102
+ image: string;
103
+ brandName: string;
104
+ }
105
+ ];
106
+ };
107
+ export type SectionNewsletter = {
108
+ type: ShopPageSectionType.NEWSLETTER;
109
+ fixed: boolean;
110
+ editable: boolean;
111
+ };