@infrab4a/connect 5.6.0-beta.4 → 5.6.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
@@ -2340,6 +2340,7 @@ exports.ShopPageName = void 0;
2340
2340
  ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
2341
2341
  ShopPageName["LP_INVITE"] = "LP_INVITE";
2342
2342
  ShopPageName["LP_LIVELO"] = "LP_LIVELO";
2343
+ ShopPageName["GLAM_NEW_HOME"] = "GLAM_NEW_HOME";
2343
2344
  })(exports.ShopPageName || (exports.ShopPageName = {}));
2344
2345
 
2345
2346
  class BeautyQuestionsHelper {
@@ -2417,10 +2418,88 @@ class ShopMenu extends BaseModel {
2417
2418
  }
2418
2419
  }
2419
2420
 
2421
+ var ShopPageSectionType;
2422
+ (function (ShopPageSectionType) {
2423
+ ShopPageSectionType["LIVE"] = "LIVE";
2424
+ ShopPageSectionType["CAROUSEL"] = "CAROUSEL";
2425
+ ShopPageSectionType["BANNER"] = "BANNER";
2426
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2427
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2428
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2429
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2430
+ ShopPageSectionType["BEAUTY_PROFILE_COLLECTION"] = "BEAUTY_PROFILE_COLLECTION";
2431
+ ShopPageSectionType["PLANS"] = "PLANS";
2432
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2433
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2434
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2435
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2436
+
2437
+ /* eslint-disable max-lines-per-function */
2420
2438
  class ShopSettings extends BaseModel {
2421
2439
  static get identifiersFields() {
2422
2440
  return ['id'];
2423
2441
  }
2442
+ getPageSections(displayRules) {
2443
+ const now = new Date();
2444
+ return (Array.isArray(this.sections) ? this.sections : [])
2445
+ .map((section) => {
2446
+ // Filtra banners dentro de carrousel
2447
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2448
+ const filteredBanners = section.banners.filter((banner) => {
2449
+ // Filtra por displayRules
2450
+ const rulesMatch = banner.displayRules.length
2451
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2452
+ : true;
2453
+ // Filtra por publishDate e expirationDate
2454
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2455
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2456
+ return rulesMatch && publishOk && expireOk;
2457
+ });
2458
+ return { ...section, banners: filteredBanners };
2459
+ }
2460
+ // Filtra highlights
2461
+ if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2462
+ const filteredHighlights = section.highlights.filter((highlight) => {
2463
+ // Filtra por displayRules
2464
+ const rulesMatch = highlight.displayRules.length
2465
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2466
+ : true;
2467
+ return rulesMatch;
2468
+ });
2469
+ const sortedHighlights = !displayRules.beautyProfile
2470
+ ? filteredHighlights.sort((a, b) => (a.starred === b.starred ? 0 : a.starred ? -1 : 1))
2471
+ : filteredHighlights;
2472
+ return { ...section, highlights: sortedHighlights };
2473
+ }
2474
+ // Filtra collections
2475
+ if (section.type === ShopPageSectionType.COLLECTION) {
2476
+ const rulesMatch = section.displayRules.length
2477
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2478
+ : true;
2479
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2480
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2481
+ return rulesMatch && publishOk && expireOk ? section : null;
2482
+ }
2483
+ // Filtra banners
2484
+ if (section.type === ShopPageSectionType.BANNER) {
2485
+ const rulesMatch = section.displayRules.length
2486
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2487
+ : true;
2488
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2489
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2490
+ return rulesMatch && publishOk && expireOk ? section : null;
2491
+ }
2492
+ if (section.type === ShopPageSectionType.LIVE) {
2493
+ return section.active ? section : null;
2494
+ }
2495
+ if (section.type === ShopPageSectionType.PLANS || section.type === ShopPageSectionType.SINGLE_PLAN) {
2496
+ return displayRules.notSubscriber ? section : null;
2497
+ }
2498
+ // Demais seções retornam normalmente
2499
+ return section;
2500
+ })
2501
+ .filter(Boolean);
2502
+ }
2424
2503
  }
2425
2504
 
2426
2505
  class AdyenBlockedOrderHelper {
package/index.esm.js CHANGED
@@ -2316,6 +2316,7 @@ var ShopPageName;
2316
2316
  ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
2317
2317
  ShopPageName["LP_INVITE"] = "LP_INVITE";
2318
2318
  ShopPageName["LP_LIVELO"] = "LP_LIVELO";
2319
+ ShopPageName["GLAM_NEW_HOME"] = "GLAM_NEW_HOME";
2319
2320
  })(ShopPageName || (ShopPageName = {}));
2320
2321
 
2321
2322
  class BeautyQuestionsHelper {
@@ -2393,10 +2394,88 @@ class ShopMenu extends BaseModel {
2393
2394
  }
2394
2395
  }
2395
2396
 
2397
+ var ShopPageSectionType;
2398
+ (function (ShopPageSectionType) {
2399
+ ShopPageSectionType["LIVE"] = "LIVE";
2400
+ ShopPageSectionType["CAROUSEL"] = "CAROUSEL";
2401
+ ShopPageSectionType["BANNER"] = "BANNER";
2402
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2403
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2404
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2405
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2406
+ ShopPageSectionType["BEAUTY_PROFILE_COLLECTION"] = "BEAUTY_PROFILE_COLLECTION";
2407
+ ShopPageSectionType["PLANS"] = "PLANS";
2408
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2409
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2410
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2411
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2412
+
2413
+ /* eslint-disable max-lines-per-function */
2396
2414
  class ShopSettings extends BaseModel {
2397
2415
  static get identifiersFields() {
2398
2416
  return ['id'];
2399
2417
  }
2418
+ getPageSections(displayRules) {
2419
+ const now = new Date();
2420
+ return (Array.isArray(this.sections) ? this.sections : [])
2421
+ .map((section) => {
2422
+ // Filtra banners dentro de carrousel
2423
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2424
+ const filteredBanners = section.banners.filter((banner) => {
2425
+ // Filtra por displayRules
2426
+ const rulesMatch = banner.displayRules.length
2427
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2428
+ : true;
2429
+ // Filtra por publishDate e expirationDate
2430
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2431
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2432
+ return rulesMatch && publishOk && expireOk;
2433
+ });
2434
+ return { ...section, banners: filteredBanners };
2435
+ }
2436
+ // Filtra highlights
2437
+ if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2438
+ const filteredHighlights = section.highlights.filter((highlight) => {
2439
+ // Filtra por displayRules
2440
+ const rulesMatch = highlight.displayRules.length
2441
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2442
+ : true;
2443
+ return rulesMatch;
2444
+ });
2445
+ const sortedHighlights = !displayRules.beautyProfile
2446
+ ? filteredHighlights.sort((a, b) => (a.starred === b.starred ? 0 : a.starred ? -1 : 1))
2447
+ : filteredHighlights;
2448
+ return { ...section, highlights: sortedHighlights };
2449
+ }
2450
+ // Filtra collections
2451
+ if (section.type === ShopPageSectionType.COLLECTION) {
2452
+ const rulesMatch = section.displayRules.length
2453
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2454
+ : true;
2455
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2456
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2457
+ return rulesMatch && publishOk && expireOk ? section : null;
2458
+ }
2459
+ // Filtra banners
2460
+ if (section.type === ShopPageSectionType.BANNER) {
2461
+ const rulesMatch = section.displayRules.length
2462
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2463
+ : true;
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
+ if (section.type === ShopPageSectionType.LIVE) {
2469
+ return section.active ? section : null;
2470
+ }
2471
+ if (section.type === ShopPageSectionType.PLANS || section.type === ShopPageSectionType.SINGLE_PLAN) {
2472
+ return displayRules.notSubscriber ? section : null;
2473
+ }
2474
+ // Demais seções retornam normalmente
2475
+ return section;
2476
+ })
2477
+ .filter(Boolean);
2478
+ }
2400
2479
  }
2401
2480
 
2402
2481
  class AdyenBlockedOrderHelper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.6.0-beta.4",
3
+ "version": "5.6.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -18,8 +18,8 @@ export declare class ProductPriceLog extends BaseModel<ProductPriceLog> {
18
18
  groupId?: string;
19
19
  competitorsAndPrices?: ProductCompetitorsPrice[];
20
20
  competitorsPrices?: number[];
21
- competitorsSellerMinPrice?: string;
22
21
  competitorsMinPrice?: number;
22
+ competitorsSellerMinPrice?: string;
23
23
  statusPrecificacao: string;
24
24
  static get identifiersFields(): GenericIdentifier[];
25
25
  }
@@ -1,5 +1,6 @@
1
1
  export type ProductCompetitorsPrice = {
2
2
  competitorId: string;
3
- price: number;
4
- offerPrice: number;
3
+ competitorUrl?: string;
4
+ price?: number;
5
+ offerPrice?: number;
5
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
+ };
@@ -12,6 +12,7 @@ export declare class Order extends Checkout {
12
12
  trackingEvents?: OrderTrackingEvent[];
13
13
  payment: PaymentTransaction;
14
14
  pedidov?: number;
15
+ isEditionOrder?: boolean;
15
16
  reshipmentOrderId?: string;
16
17
  isChange?: boolean;
17
18
  isReshipment?: boolean;