sass-template-common 0.9.241 → 0.10.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/README.md CHANGED
@@ -1,36 +1,36 @@
1
- # sass-template-common
2
-
3
- Librería web, maqueta de configuración y componentes para proyectos sass.
4
-
5
- ## Publicar nueva versión
6
-
7
- Para que los cambios se reflejen al publicar:
8
-
9
- 1. **Subir versión** (obligatorio; si no, npm rechaza o se usa la misma versión):
10
- ```bash
11
- pnpm version:patch # 0.3.21 → 0.3.22
12
- # o
13
- pnpm version:minor # 0.3.21 → 0.4.0
14
- pnpm version:major # 0.3.21 → 1.0.0
15
- ```
16
-
17
- 2. **Build limpio + publicar**:
18
- ```bash
19
- pnpm run clean && pnpm run build && pnpm publish
20
- ```
21
- O en un solo paso (patch):
22
- ```bash
23
- pnpm release:patch
24
- ```
25
-
26
- 3. **`prepublishOnly`**: Antes de cada `pnpm publish` se ejecuta `clean` + `build`, así siempre se publica un build nuevo.
27
-
28
- 4. **En proyectos que consumen la lib**: Actualizar la dependencia y reinstalar:
29
- ```bash
30
- pnpm update sass-template-common
31
- # o cambiar la versión en package.json y luego
32
- pnpm install
33
- ```
34
- Si usan versión fija (`"0.3.21"`), hay que actualizarla a la nueva (p. ej. `"0.3.22"`).
35
-
36
- **Si no ves los cambios:** comprueba que subiste la versión (`version:patch` o similar), que hiciste `clean` + `build` antes de publicar, y que el proyecto consumidor tiene actualizada la dependencia (o `^0.3.21` y ha ejecutado `pnpm update`).
1
+ # sass-template-common
2
+
3
+ Librería web, maqueta de configuración y componentes para proyectos sass.
4
+
5
+ ## Publicar nueva versión
6
+
7
+ Para que los cambios se reflejen al publicar:
8
+
9
+ 1. **Subir versión** (obligatorio; si no, npm rechaza o se usa la misma versión):
10
+ ```bash
11
+ pnpm version:patch # 0.3.21 → 0.3.22
12
+ # o
13
+ pnpm version:minor # 0.3.21 → 0.4.0
14
+ pnpm version:major # 0.3.21 → 1.0.0
15
+ ```
16
+
17
+ 2. **Build limpio + publicar**:
18
+ ```bash
19
+ pnpm run clean && pnpm run build && pnpm publish
20
+ ```
21
+ O en un solo paso (patch):
22
+ ```bash
23
+ pnpm release:patch
24
+ ```
25
+
26
+ 3. **`prepublishOnly`**: Antes de cada `pnpm publish` se ejecuta `clean` + `build`, así siempre se publica un build nuevo.
27
+
28
+ 4. **En proyectos que consumen la lib**: Actualizar la dependencia y reinstalar:
29
+ ```bash
30
+ pnpm update sass-template-common
31
+ # o cambiar la versión en package.json y luego
32
+ pnpm install
33
+ ```
34
+ Si usan versión fija (`"0.3.21"`), hay que actualizarla a la nueva (p. ej. `"0.3.22"`).
35
+
36
+ **Si no ves los cambios:** comprueba que subiste la versión (`version:patch` o similar), que hiciste `clean` + `build` antes de publicar, y que el proyecto consumidor tiene actualizada la dependencia (o `^0.3.21` y ha ejecutado `pnpm update`).
@@ -53,6 +53,8 @@ export declare type Analytics = {
53
53
 
54
54
  export declare const AssetsPreconnect: () => false | "" | JSX.Element | undefined;
55
55
 
56
+ export declare function auditConfigOrigin(entry: ConfigOriginAuditEntry): void;
57
+
56
58
  export declare interface Author {
57
59
  firstname: string;
58
60
  lastname: string;
@@ -227,6 +229,11 @@ export declare interface BlockSaasResponseData {
227
229
  export declare type BucketOriginConfig = {
228
230
  /** Base URL pública del bucket (sin slash final). Ej: `https://debate-site-configs.s3.us-west-2.amazonaws.com` */
229
231
  url: string;
232
+ /**
233
+ * Base URL alternativa (CloudFront u otro proxy cacheado). Si está definida,
234
+ * reemplaza `url` al armar las rutas de menú/banners en bucket.
235
+ */
236
+ proxyUrl?: string;
230
237
  /** Prefijo raíz del cliente dentro del bucket (ej. `'debate'`). */
231
238
  clientName: string;
232
239
  /** Sirve el menú (sidebar/menu/footer/freeZone/cintillo + equipos/sites) desde el bucket. */
@@ -246,8 +253,15 @@ export declare type BucketOriginConfig = {
246
253
  * (ej. `debate/debate/menu/...` en vez de `debate//menu/...`).
247
254
  */
248
255
  forceSite?: string;
256
+ /**
257
+ * TTL (ms) del cache in-memory SSR para menú/banners (bucket o API). Default 45000.
258
+ * `0` desactiva. Prioridad sobre `CONFIG_configCacheTtlMs`.
259
+ */
260
+ cacheTtlMs?: number;
249
261
  };
250
262
 
263
+ export declare function buildConfigMenuApiPath(servicePrefix: string, configVersion: string, fileName: string): string;
264
+
251
265
  export declare const buildTagUrl: (tag: Tag, paths: RoutePathConfig) => string;
252
266
 
253
267
  declare interface ButtonCSS {
@@ -302,6 +316,13 @@ export declare const CarruselOpinion: FC<SectionCardCarouselProps>;
302
316
  */
303
317
  export declare const cleanSchema: <T>(value: T) => T;
304
318
 
319
+ export declare function clearConfigOriginAudit(): void;
320
+
321
+ /** Limpia el cache (útil en tests o tras invalidación manual). */
322
+ export declare function clearConfigOriginCache(cacheKey?: string): void;
323
+
324
+ export declare function clearConfigOriginComparisonCache(): void;
325
+
305
326
  export declare const coloringByStrokeSVGs: string[];
306
327
 
307
328
  /** Textos del popup anónimo (AnonimusPopUp.tsx) */
@@ -497,13 +518,11 @@ export declare class CommonServices {
497
518
  }, any, {}>> | undefined;
498
519
  getMainMenu: (params: Params) => Promise<AxiosResponse<{
499
520
  data: Array<MenuResponse>;
500
- }, any, {}> | AxiosResponse<{
501
- data: Array<MenuResponse>;
502
521
  }, any, {}> | {
503
522
  data: {
504
523
  data: Array<MenuResponse>;
505
524
  };
506
- } | undefined> | undefined;
525
+ }>;
507
526
  getNewsListZone: (params: Params) => Promise<AxiosResponse<NewListResponse, any, {}>> | undefined;
508
527
  getNewsListZoneSection: (params: Params) => Promise<AxiosResponse<NewListResponse, any, {}>> | undefined;
509
528
  getNewsList: (params: Params) => Promise<AxiosResponse<NewListResponse, any, {}>> | undefined;
@@ -527,20 +546,22 @@ export declare class CommonServices {
527
546
  getVideosList: (params: Params) => Promise<AxiosResponse<{
528
547
  data: Array<VideoResponseData>;
529
548
  }, any, {}>> | undefined;
530
- getBanners: (params: Params) => Promise<{
549
+ getBanners: (params: Params) => Promise<AxiosResponse<{
550
+ data: Array<BannerResponse>;
551
+ }, any, {}> | {
531
552
  data: {
532
553
  data: Array<BannerResponse>;
533
554
  };
534
- } | undefined>;
555
+ }>;
535
556
  getPages: (params: Params) => Promise<AxiosResponse<{
536
557
  data: Array<FreeZoneResponse>;
537
558
  }, any, {}>> | undefined;
538
559
  getRankingS3: (url: string, headers?: {
539
560
  Referer: string;
540
- }) => Promise<void | AxiosResponse<{
561
+ }) => Promise<AxiosResponse<{
541
562
  data: Array<NewListResponseData>;
542
563
  }, any, {}> | {
543
- data: never[];
564
+ data: Array<NewListResponseData>;
544
565
  }>;
545
566
  getNews: (params: Params) => Promise<AxiosResponse<{
546
567
  data: Array<NewListResponseData>;
@@ -561,9 +582,7 @@ export declare class CommonServices {
561
582
  data: Array<NewListResponseData>;
562
583
  }, any, {}>> | undefined;
563
584
  getNewsItemsRelated: (path: string, params?: Params) => Promise<AxiosResponse<NewListResponse, any, {}> | {
564
- data: {
565
- data: never[];
566
- };
585
+ data: NewListResponse;
567
586
  }> | undefined;
568
587
  sendEmail: (data: EmailParams) => Promise<AxiosResponse<{
569
588
  data: Array<ItemList>;
@@ -699,6 +718,60 @@ export declare type ConfigMain = {
699
718
  };
700
719
  };
701
720
 
721
+ export declare type ConfigOriginAuditEntry = {
722
+ kind: 'menu' | 'banners';
723
+ origin: 'api' | 'bucket';
724
+ outcome: ConfigOriginOutcome;
725
+ target: string;
726
+ durationMs: number;
727
+ ok?: boolean;
728
+ };
729
+
730
+ export declare type ConfigOriginAuditReport = {
731
+ entries: ConfigOriginAuditEntry[];
732
+ totals: {
733
+ network: number;
734
+ cacheHit: number;
735
+ dedup: number;
736
+ api: number;
737
+ bucket: number;
738
+ networkMs: number;
739
+ };
740
+ comparison?: ConfigOriginComparisonReport | null;
741
+ };
742
+
743
+ export declare type ConfigOriginComparisonReport = {
744
+ runs: number;
745
+ rows: ConfigOriginComparisonRow[];
746
+ homeParallel: {
747
+ api: number;
748
+ bucket: number;
749
+ };
750
+ generatedAt: string;
751
+ cached: boolean;
752
+ };
753
+
754
+ export declare type ConfigOriginComparisonRow = {
755
+ name: string;
756
+ api: ConfigOriginTimingStats;
757
+ bucket: ConfigOriginTimingStats;
758
+ winner: 'api' | 'bucket';
759
+ advantagePct: number;
760
+ deltaMs: number;
761
+ };
762
+
763
+ export declare type ConfigOriginOutcome = 'network' | 'cache-hit' | 'dedup';
764
+
765
+ export declare type ConfigOriginTimingStats = {
766
+ ok: boolean;
767
+ status: number;
768
+ size: number;
769
+ avg: number;
770
+ p50: number;
771
+ min: number;
772
+ max: number;
773
+ };
774
+
702
775
  export declare const ContactInfoServer: FC<Props_9>;
703
776
 
704
777
  export declare const ContactInput: FC<Props_40>;
@@ -826,6 +899,8 @@ export declare function decodeApiEnv<T = any>(encoded: Record<string, any>): T;
826
899
  */
827
900
  export declare const DEFAULT_HEAD_CONFIG: headConfig;
828
901
 
902
+ export declare const DEFAULT_S3_REFERER = "https://goamg.amplifyapp.com/vndomv";
903
+
829
904
  declare type DestacadoDiario = {
830
905
  customSectionCardStyles: SectionCardCSS;
831
906
  customNewsDescriptionStyles: NewsDescriptionBlockCSS;
@@ -916,6 +991,12 @@ export declare type EmailParams = {
916
991
  body: string;
917
992
  };
918
993
 
994
+ /**
995
+ * Fallback completo (no solo `{data: []}`) para endpoints tipados `NewListResponse`:
996
+ * algunos consumidores leen `response.data.entity`/`site`/`publication`, no solo `.data.data`.
997
+ */
998
+ export declare function emptyNewListResponse(): NewListResponse;
999
+
919
1000
  export declare function encodeApiEnv<T extends Record<string, any>>(env: T): Record<string, any>;
920
1001
 
921
1002
  export declare interface Entity {
@@ -975,6 +1056,12 @@ export declare type FetchConfig = {
975
1056
  newsType: string;
976
1057
  };
977
1058
 
1059
+ /**
1060
+ * Cache in-memory + deduplicación de requests en vuelo (misma clave → misma promesa).
1061
+ * TTL corto pensado para SSR: evita 4–5 GETs repetidos de menú/banners por instancia.
1062
+ */
1063
+ export declare function fetchWithConfigCache<T>(cacheKey: string, fetchFn: () => Promise<T>, ttlMs?: number): Promise<T>;
1064
+
978
1065
  export declare const Font: ({ config }: {
979
1066
  config: Config;
980
1067
  }) => JSX.Element | null;
@@ -983,6 +1070,8 @@ export declare const Footer: FC<Props_33>;
983
1070
 
984
1071
  export declare const FormatAfterScripts: (props: ScriptProps) => JSX.Element | null;
985
1072
 
1073
+ export declare function formatConfigOriginComparisonTable(report: ConfigOriginComparisonReport): string;
1074
+
986
1075
  export declare const formatDate: (date: number, DATE_CONFIG?: {
987
1076
  PUBLIC_LNG: string;
988
1077
  DATE_TIMEZONE: string;
@@ -1131,7 +1220,10 @@ export declare const generalGetData: (promiseArray: PromiseArray) => Promise<{
1131
1220
 
1132
1221
  export declare const GenerateBody: ({ children, defaultRouteName, banners, pathname, slug, config, internalPath, currentNew, tagsParsed, scriptReplaces, body_custom_elements, }: Props_5) => JSX.Element;
1133
1222
 
1134
- export declare function GenerateHead({ axiosApi, headConfig: headConfigInput, meta, imgSizes, defaultMetadataName, pathname, slug, texts, query, autor, listAutor, currentNew, banners, schemasImages, internalPath, meta_info, config, socials, speculationType, preloadImageUrl, custom_Speculation, custom_metadata, custom_scriptReplaces, head_custom_elements, schemasCustomEndpoints, }: Props_4): Promise<ReactNode>;
1223
+ export declare function GenerateHead({ axiosApi, headConfig: headConfigInput, meta, imgSizes, defaultMetadataName, pathname, slug, texts, query, autor, listAutor, currentNew, banners, schemasImages, internalPath, meta_info, config, socials, speculationType, preloadImageUrl, custom_Speculation, custom_metadata, custom_scriptReplaces, head_custom_elements, schemasCustomEndpoints, configOriginAuditReport, }: Props_4): Promise<ReactNode>;
1224
+
1225
+ /** Cliente axios compartido por origen de bucket (keep-alive en Node SSR). */
1226
+ export declare function getBucketHttpClient(baseUrl: string, referer: string): AxiosInstance;
1135
1227
 
1136
1228
  /**
1137
1229
  * Helper para conseguir el recaptcha token usando grecaptcha.enterprise
@@ -1159,6 +1251,10 @@ export declare interface GetCommentsParams {
1159
1251
 
1160
1252
  export declare function getConfig(): LibraryConfig;
1161
1253
 
1254
+ export declare function getConfigCacheTtlMs(): number;
1255
+
1256
+ export declare function getConfigOriginAuditReport(comparison?: ConfigOriginComparisonReport | null): ConfigOriginAuditReport;
1257
+
1162
1258
  export declare const getDynamicSlots: (axiosApi: AxiosInstance, config: Config, imgSizes: {
1163
1259
  [key: string]: any;
1164
1260
  }, imgSizesVideo: {
@@ -1447,6 +1543,8 @@ export declare interface Info {
1447
1543
 
1448
1544
  export declare function initLibrary(userConfig?: LibraryConfig): void;
1449
1545
 
1546
+ export declare function isConfigOriginAuditEnabled(): boolean;
1547
+
1450
1548
  export declare interface ISection {
1451
1549
  name: string;
1452
1550
  slug: string;
@@ -1579,6 +1677,12 @@ export declare type LibraryConfig = {
1579
1677
  middle?: boolean;
1580
1678
  innote?: boolean;
1581
1679
  };
1680
+ /**
1681
+ * TTL (ms) del cache in-memory SSR para `getMainMenu` / `getBanners` vía API CMS.
1682
+ * Default 45000. `0` desactiva el cache. También configurable en
1683
+ * `BUCKET_ORIGIN.cacheTtlMs` (tiene prioridad si está definido).
1684
+ */
1685
+ CONFIG_configCacheTtlMs?: number;
1582
1686
  PAGE_SWIPER?: {
1583
1687
  home: boolean;
1584
1688
  autor: boolean;
@@ -2331,6 +2435,12 @@ export declare type Params = {
2331
2435
  related?: number;
2332
2436
  };
2333
2437
 
2438
+ export declare function parseConfigOriginCacheKey(cacheKey: string): {
2439
+ kind: 'menu' | 'banners';
2440
+ origin: 'api' | 'bucket';
2441
+ target: string;
2442
+ };
2443
+
2334
2444
  export declare const parseTags: (keywords: any) => string;
2335
2445
 
2336
2446
  export declare const pathnameSplit: (pathname: string) => {
@@ -2741,6 +2851,8 @@ declare type Props_4 = {
2741
2851
  headConfig?: Partial<headConfig>;
2742
2852
  head_custom_elements?: any;
2743
2853
  schemasCustomEndpoints?: string[];
2854
+ /** Reporte SSR de menú/banners (cache/dedup/network). Solo con HTML_AUDIT. */
2855
+ configOriginAuditReport?: ConfigOriginAuditReport | null;
2744
2856
  };
2745
2857
 
2746
2858
  declare type Props_40 = {
@@ -2982,6 +3094,29 @@ export declare interface ReportCommentParams {
2982
3094
 
2983
3095
  export declare type ReportReasonKey = keyof typeof REPORT_REASONS;
2984
3096
 
3097
+ /**
3098
+ * Reintenta `fn` con backoff exponencial, acotando cada intento con `timeoutMs`
3099
+ * (un fetch a un bucket S3 colgado no debe bloquear el request indefinidamente).
3100
+ * Si se agotan los reintentos (o el error no es reintentable, ej. 404), registra el
3101
+ * fallo en DebugStore y devuelve `fallback` en vez de rechazar: una falla del bucket
3102
+ * no debe tumbar el render del sitio consumidor.
3103
+ */
3104
+ export declare function resilientFetch<T, F>(fn: () => Promise<T> | T, fallback: F, { label, endpoint, params, retries, timeoutMs, baseDelayMs, }: ResilientFetchOptions): Promise<T | F>;
3105
+
3106
+ export declare interface ResilientFetchOptions {
3107
+ /** Identifica el fetch en logs y en el DebugStore (ej. '/news-list-zone', 'bucket:menu'). */
3108
+ label: string;
3109
+ endpoint?: string;
3110
+ params?: Record<string, any>;
3111
+ retries?: number;
3112
+ timeoutMs?: number;
3113
+ baseDelayMs?: number;
3114
+ }
3115
+
3116
+ export declare function resolveBucketMenuSubtype(path?: string): string;
3117
+
3118
+ export declare function resolveBucketOriginUrl(bucket: BucketOriginConfig, servicePrefix: string | undefined, type: 'menu' | 'banners', subtype: string): string;
3119
+
2985
3120
  export declare interface RoutePathConfig {
2986
3121
  autor: string | 'autor';
2987
3122
  tema: string | 'tema';
@@ -2992,6 +3127,13 @@ export declare interface RoutePathConfig {
2992
3127
  'ultimas-noticias': string | 'ultimas-noticias';
2993
3128
  }
2994
3129
 
3130
+ export declare function runConfigOriginComparison(params: {
3131
+ axiosApi: AxiosInstance;
3132
+ servicePrefix: string;
3133
+ configVersion: string;
3134
+ runs?: number;
3135
+ }): Promise<ConfigOriginComparisonReport | null>;
3136
+
2995
3137
  export declare function ScriptHydrator({ containerId, containerId2 }: Props_17): null;
2996
3138
 
2997
3139
  declare type ScriptProps = {
@@ -3286,6 +3428,9 @@ declare interface TagSectionProps {
3286
3428
  paths: RoutePathConfig;
3287
3429
  }
3288
3430
 
3431
+ /** Loguea el resumen en consola, limpia el buffer y devuelve el reporte (SSR). */
3432
+ export declare function takeConfigOriginAuditReport(comparison?: ConfigOriginComparisonReport | null): ConfigOriginAuditReport | null;
3433
+
3289
3434
  /** Cabecera / edición (barra superior) */
3290
3435
  export declare type TextsHeader = {
3291
3436
  menuText: string;