@infrab4a/connect 5.5.5 → 5.5.6-beta.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/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,82 @@ 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["BANNER"] = "BANNER";
2414
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2415
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2416
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2417
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2418
+ ShopPageSectionType["BEAUTY_PROFILE_COLLECTION"] = "BEAUTY_PROFILE_COLLECTION";
2419
+ ShopPageSectionType["PLANS"] = "PLANS";
2420
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2421
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2422
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2423
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2424
+
2425
+ /* eslint-disable max-lines-per-function */
2408
2426
  class ShopSettings extends BaseModel {
2409
2427
  static get identifiersFields() {
2410
2428
  return ['id'];
2411
2429
  }
2430
+ getPageSections(displayRules) {
2431
+ const now = new Date();
2432
+ return (Array.isArray(this.sections) ? this.sections : [])
2433
+ .map((section) => {
2434
+ // Filtra banners dentro de carrousel
2435
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2436
+ const filteredBanners = section.banners.filter((banner) => {
2437
+ // Filtra por displayRules
2438
+ const rulesMatch = banner.displayRules
2439
+ ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2440
+ : false;
2441
+ // Filtra por publishDate e expirationDate
2442
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2443
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2444
+ return rulesMatch && publishOk && expireOk;
2445
+ });
2446
+ return { ...section, banners: filteredBanners };
2447
+ }
2448
+ // Filtra highlights
2449
+ if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2450
+ const filteredHighlights = section.highlights.filter((highlight) => {
2451
+ // Filtra por displayRules
2452
+ const rulesMatch = highlight.displayRules
2453
+ ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2454
+ : false;
2455
+ return rulesMatch;
2456
+ });
2457
+ return { ...section, highlights: filteredHighlights };
2458
+ }
2459
+ // Filtra collections
2460
+ 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 publishOk = !section.publishDate || now >= new Date(section.publishDate);
2465
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2466
+ return rulesMatch && publishOk && expireOk ? section : null;
2467
+ }
2468
+ // Filtra banners
2469
+ 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 publishOk = !section.publishDate || now >= new Date(section.publishDate);
2474
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2475
+ return rulesMatch && publishOk && expireOk ? section : null;
2476
+ }
2477
+ if (section.type === ShopPageSectionType.LIVE) {
2478
+ return section.active ? section : null;
2479
+ }
2480
+ // Demais seções retornam normalmente
2481
+ return section;
2482
+ })
2483
+ .filter(Boolean);
2484
+ }
2412
2485
  }
2413
2486
 
2414
2487
  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,82 @@ 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["BANNER"] = "BANNER";
2390
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2391
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2392
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2393
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2394
+ ShopPageSectionType["BEAUTY_PROFILE_COLLECTION"] = "BEAUTY_PROFILE_COLLECTION";
2395
+ ShopPageSectionType["PLANS"] = "PLANS";
2396
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2397
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2398
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2399
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2400
+
2401
+ /* eslint-disable max-lines-per-function */
2384
2402
  class ShopSettings extends BaseModel {
2385
2403
  static get identifiersFields() {
2386
2404
  return ['id'];
2387
2405
  }
2406
+ getPageSections(displayRules) {
2407
+ const now = new Date();
2408
+ return (Array.isArray(this.sections) ? this.sections : [])
2409
+ .map((section) => {
2410
+ // Filtra banners dentro de carrousel
2411
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2412
+ const filteredBanners = section.banners.filter((banner) => {
2413
+ // Filtra por displayRules
2414
+ const rulesMatch = banner.displayRules
2415
+ ? Object.keys(displayRules).some((key) => banner.displayRules && banner.displayRules[key] === displayRules[key])
2416
+ : false;
2417
+ // Filtra por publishDate e expirationDate
2418
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2419
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2420
+ return rulesMatch && publishOk && expireOk;
2421
+ });
2422
+ return { ...section, banners: filteredBanners };
2423
+ }
2424
+ // Filtra highlights
2425
+ if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2426
+ const filteredHighlights = section.highlights.filter((highlight) => {
2427
+ // Filtra por displayRules
2428
+ const rulesMatch = highlight.displayRules
2429
+ ? Object.keys(displayRules).some((key) => highlight.displayRules && highlight.displayRules[key] === displayRules[key])
2430
+ : false;
2431
+ return rulesMatch;
2432
+ });
2433
+ return { ...section, highlights: filteredHighlights };
2434
+ }
2435
+ // Filtra collections
2436
+ 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 publishOk = !section.publishDate || now >= new Date(section.publishDate);
2441
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2442
+ return rulesMatch && publishOk && expireOk ? section : null;
2443
+ }
2444
+ // Filtra banners
2445
+ 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 publishOk = !section.publishDate || now >= new Date(section.publishDate);
2450
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2451
+ return rulesMatch && publishOk && expireOk ? section : null;
2452
+ }
2453
+ if (section.type === ShopPageSectionType.LIVE) {
2454
+ return section.active ? section : null;
2455
+ }
2456
+ // Demais seções retornam normalmente
2457
+ return section;
2458
+ })
2459
+ .filter(Boolean);
2460
+ }
2388
2461
  }
2389
2462
 
2390
2463
  class AdyenBlockedOrderHelper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.5",
3
+ "version": "5.5.6-beta.1",
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
+ getPageSections(displayRules: DisplayRules): SectionUnion[];
15
18
  }
@@ -0,0 +1,140 @@
1
+ export type ShopPageSection = Array<SectionUnion>;
2
+ export type SectionUnion = SectionLive | SectionCarousel | SectionBanner | SectionInfobars | SectionHighlights | SectionSubscriberInfo | SectionCollection | SectionBeautyProfileCollection | SectionPlans | SectionSinglePlan | SectionBrands | SectionNewsletter;
3
+ export declare enum ShopPageSectionType {
4
+ LIVE = "LIVE",
5
+ CAROUSEL = "CAROUSEL",
6
+ BANNER = "BANNER",
7
+ INFOBARS = "INFOBARS",
8
+ HIGHLIGHTS = "HIGHLIGHTS",
9
+ SUBSCRIBER_INFO = "SUBSCRIBER_INFO",
10
+ COLLECTION = "COLLECTION",
11
+ BEAUTY_PROFILE_COLLECTION = "BEAUTY_PROFILE_COLLECTION",
12
+ PLANS = "PLANS",
13
+ SINGLE_PLAN = "SINGLE_PLAN",
14
+ BRANDS = "BRANDS",
15
+ NEWSLETTER = "NEWSLETTER"
16
+ }
17
+ export type SectionLive = {
18
+ id: string;
19
+ type: ShopPageSectionType.LIVE;
20
+ fixed: boolean;
21
+ editable: boolean;
22
+ title: string;
23
+ link: string;
24
+ active: boolean;
25
+ };
26
+ export type SectionCarousel = {
27
+ id: string;
28
+ type: ShopPageSectionType.CAROUSEL;
29
+ fixed: boolean;
30
+ editable: boolean;
31
+ banners: Banner[];
32
+ };
33
+ export type SectionInfobars = {
34
+ id: string;
35
+ type: ShopPageSectionType.INFOBARS;
36
+ fixed: boolean;
37
+ editable: boolean;
38
+ infobars: Infobar[];
39
+ };
40
+ export type Infobar = {
41
+ id: string;
42
+ link: string;
43
+ text: string;
44
+ active: boolean;
45
+ };
46
+ export type SectionHighlights = {
47
+ id: string;
48
+ type: ShopPageSectionType.HIGHLIGHTS;
49
+ fixed: boolean;
50
+ editable: boolean;
51
+ highlights: Highlight[];
52
+ };
53
+ export type Highlight = {
54
+ id: string;
55
+ title: string;
56
+ subtitle: string;
57
+ link: string;
58
+ image: string;
59
+ altText: string;
60
+ highlighted: boolean;
61
+ starred: boolean;
62
+ displayRules?: Array<Partial<DisplayRules>>;
63
+ };
64
+ export type SectionSubscriberInfo = {
65
+ id: string;
66
+ type: ShopPageSectionType.SUBSCRIBER_INFO;
67
+ fixed: boolean;
68
+ editable: boolean;
69
+ };
70
+ export type Banner = {
71
+ id: string;
72
+ mobileImage: string;
73
+ desktopImage: string;
74
+ link: string;
75
+ altText: string;
76
+ countdown?: string;
77
+ displayRules?: Array<Partial<DisplayRules>>;
78
+ publishDate?: Date;
79
+ expirationDate?: Date;
80
+ };
81
+ export type SectionBanner = Banner & {
82
+ type: ShopPageSectionType.BANNER;
83
+ fixed: boolean;
84
+ editable: boolean;
85
+ };
86
+ export type SectionCollection = {
87
+ id: string;
88
+ type: ShopPageSectionType.COLLECTION;
89
+ fixed: boolean;
90
+ editable: boolean;
91
+ slug: string;
92
+ title: string;
93
+ categoryId: number;
94
+ displayRules?: Array<Partial<DisplayRules>>;
95
+ publishDate?: Date;
96
+ expirationDate?: Date;
97
+ };
98
+ export type SectionBeautyProfileCollection = {
99
+ id: string;
100
+ type: ShopPageSectionType.BEAUTY_PROFILE_COLLECTION;
101
+ fixed: boolean;
102
+ editable: boolean;
103
+ };
104
+ export type DisplayRules = {
105
+ subscriberBuyer: boolean;
106
+ notSubscriber: boolean;
107
+ subscriberNotBuyer: boolean;
108
+ topBadgeSubscriber: boolean;
109
+ beautyProfile?: boolean;
110
+ };
111
+ export type SectionPlans = {
112
+ id: string;
113
+ type: ShopPageSectionType.PLANS;
114
+ fixed: boolean;
115
+ editable: boolean;
116
+ };
117
+ export type SectionSinglePlan = {
118
+ id: string;
119
+ type: ShopPageSectionType.SINGLE_PLAN;
120
+ fixed: boolean;
121
+ editable: boolean;
122
+ };
123
+ export type Brand = {
124
+ slug: string;
125
+ image: string;
126
+ brandName: string;
127
+ };
128
+ export type SectionBrands = {
129
+ id: string;
130
+ type: ShopPageSectionType.BRANDS;
131
+ fixed: boolean;
132
+ editable: boolean;
133
+ brands: Brand[];
134
+ };
135
+ export type SectionNewsletter = {
136
+ id: string;
137
+ type: ShopPageSectionType.NEWSLETTER;
138
+ fixed: boolean;
139
+ editable: boolean;
140
+ };