euparliamentmonitor 0.8.4
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/LICENSE +201 -0
- package/README.md +1005 -0
- package/SECURITY.md +151 -0
- package/package.json +131 -0
- package/scripts/constants/committee-indicator-map.d.ts +199 -0
- package/scripts/constants/committee-indicator-map.d.ts.map +1 -0
- package/scripts/constants/committee-indicator-map.js +1224 -0
- package/scripts/constants/committee-indicator-map.js.map +1 -0
- package/scripts/constants/config.d.ts +38 -0
- package/scripts/constants/config.d.ts.map +1 -0
- package/scripts/constants/config.js +66 -0
- package/scripts/constants/config.js.map +1 -0
- package/scripts/constants/language-articles.d.ts +84 -0
- package/scripts/constants/language-articles.d.ts.map +1 -0
- package/scripts/constants/language-articles.js +6771 -0
- package/scripts/constants/language-articles.js.map +1 -0
- package/scripts/constants/language-core.d.ts +38 -0
- package/scripts/constants/language-core.d.ts.map +1 -0
- package/scripts/constants/language-core.js +90 -0
- package/scripts/constants/language-core.js.map +1 -0
- package/scripts/constants/language-ui.d.ts +82 -0
- package/scripts/constants/language-ui.d.ts.map +1 -0
- package/scripts/constants/language-ui.js +889 -0
- package/scripts/constants/language-ui.js.map +1 -0
- package/scripts/constants/languages.d.ts +14 -0
- package/scripts/constants/languages.d.ts.map +1 -0
- package/scripts/constants/languages.js +15 -0
- package/scripts/constants/languages.js.map +1 -0
- package/scripts/generators/analysis-builders.d.ts +266 -0
- package/scripts/generators/analysis-builders.d.ts.map +1 -0
- package/scripts/generators/analysis-builders.js +2903 -0
- package/scripts/generators/analysis-builders.js.map +1 -0
- package/scripts/generators/breaking-content.d.ts +45 -0
- package/scripts/generators/breaking-content.d.ts.map +1 -0
- package/scripts/generators/breaking-content.js +530 -0
- package/scripts/generators/breaking-content.js.map +1 -0
- package/scripts/generators/committee-helpers.d.ts +54 -0
- package/scripts/generators/committee-helpers.d.ts.map +1 -0
- package/scripts/generators/committee-helpers.js +154 -0
- package/scripts/generators/committee-helpers.js.map +1 -0
- package/scripts/generators/dashboard-content.d.ts +95 -0
- package/scripts/generators/dashboard-content.d.ts.map +1 -0
- package/scripts/generators/dashboard-content.js +630 -0
- package/scripts/generators/dashboard-content.js.map +1 -0
- package/scripts/generators/deep-analysis-content.d.ts +23 -0
- package/scripts/generators/deep-analysis-content.d.ts.map +1 -0
- package/scripts/generators/deep-analysis-content.js +831 -0
- package/scripts/generators/deep-analysis-content.js.map +1 -0
- package/scripts/generators/mindmap-content.d.ts +55 -0
- package/scripts/generators/mindmap-content.d.ts.map +1 -0
- package/scripts/generators/mindmap-content.js +512 -0
- package/scripts/generators/mindmap-content.js.map +1 -0
- package/scripts/generators/motions-content.d.ts +50 -0
- package/scripts/generators/motions-content.d.ts.map +1 -0
- package/scripts/generators/motions-content.js +391 -0
- package/scripts/generators/motions-content.js.map +1 -0
- package/scripts/generators/news-enhanced.d.ts +14 -0
- package/scripts/generators/news-enhanced.d.ts.map +1 -0
- package/scripts/generators/news-enhanced.js +169 -0
- package/scripts/generators/news-enhanced.js.map +1 -0
- package/scripts/generators/news-indexes.d.ts +31 -0
- package/scripts/generators/news-indexes.d.ts.map +1 -0
- package/scripts/generators/news-indexes.js +410 -0
- package/scripts/generators/news-indexes.js.map +1 -0
- package/scripts/generators/pipeline/fetch-stage.d.ts +352 -0
- package/scripts/generators/pipeline/fetch-stage.d.ts.map +1 -0
- package/scripts/generators/pipeline/fetch-stage.js +1522 -0
- package/scripts/generators/pipeline/fetch-stage.js.map +1 -0
- package/scripts/generators/pipeline/generate-stage.d.ts +43 -0
- package/scripts/generators/pipeline/generate-stage.d.ts.map +1 -0
- package/scripts/generators/pipeline/generate-stage.js +204 -0
- package/scripts/generators/pipeline/generate-stage.js.map +1 -0
- package/scripts/generators/pipeline/output-stage.d.ts +48 -0
- package/scripts/generators/pipeline/output-stage.d.ts.map +1 -0
- package/scripts/generators/pipeline/output-stage.js +145 -0
- package/scripts/generators/pipeline/output-stage.js.map +1 -0
- package/scripts/generators/pipeline/transform-stage.d.ts +57 -0
- package/scripts/generators/pipeline/transform-stage.d.ts.map +1 -0
- package/scripts/generators/pipeline/transform-stage.js +111 -0
- package/scripts/generators/pipeline/transform-stage.js.map +1 -0
- package/scripts/generators/propositions-content.d.ts +29 -0
- package/scripts/generators/propositions-content.d.ts.map +1 -0
- package/scripts/generators/propositions-content.js +90 -0
- package/scripts/generators/propositions-content.js.map +1 -0
- package/scripts/generators/sankey-content.d.ts +45 -0
- package/scripts/generators/sankey-content.d.ts.map +1 -0
- package/scripts/generators/sankey-content.js +227 -0
- package/scripts/generators/sankey-content.js.map +1 -0
- package/scripts/generators/sitemap.d.ts +66 -0
- package/scripts/generators/sitemap.d.ts.map +1 -0
- package/scripts/generators/sitemap.js +562 -0
- package/scripts/generators/sitemap.js.map +1 -0
- package/scripts/generators/strategies/article-strategy.d.ts +146 -0
- package/scripts/generators/strategies/article-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/article-strategy.js +4 -0
- package/scripts/generators/strategies/article-strategy.js.map +1 -0
- package/scripts/generators/strategies/breaking-news-strategy.d.ts +64 -0
- package/scripts/generators/strategies/breaking-news-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/breaking-news-strategy.js +246 -0
- package/scripts/generators/strategies/breaking-news-strategy.js.map +1 -0
- package/scripts/generators/strategies/committee-reports-strategy.d.ts +93 -0
- package/scripts/generators/strategies/committee-reports-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/committee-reports-strategy.js +447 -0
- package/scripts/generators/strategies/committee-reports-strategy.js.map +1 -0
- package/scripts/generators/strategies/month-ahead-strategy.d.ts +60 -0
- package/scripts/generators/strategies/month-ahead-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/month-ahead-strategy.js +175 -0
- package/scripts/generators/strategies/month-ahead-strategy.js.map +1 -0
- package/scripts/generators/strategies/monthly-review-strategy.d.ts +66 -0
- package/scripts/generators/strategies/monthly-review-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/monthly-review-strategy.js +204 -0
- package/scripts/generators/strategies/monthly-review-strategy.js.map +1 -0
- package/scripts/generators/strategies/motions-strategy.d.ts +61 -0
- package/scripts/generators/strategies/motions-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/motions-strategy.js +215 -0
- package/scripts/generators/strategies/motions-strategy.js.map +1 -0
- package/scripts/generators/strategies/propositions-strategy.d.ts +60 -0
- package/scripts/generators/strategies/propositions-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/propositions-strategy.js +257 -0
- package/scripts/generators/strategies/propositions-strategy.js.map +1 -0
- package/scripts/generators/strategies/week-ahead-strategy.d.ts +57 -0
- package/scripts/generators/strategies/week-ahead-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/week-ahead-strategy.js +178 -0
- package/scripts/generators/strategies/week-ahead-strategy.js.map +1 -0
- package/scripts/generators/strategies/weekly-review-strategy.d.ts +63 -0
- package/scripts/generators/strategies/weekly-review-strategy.d.ts.map +1 -0
- package/scripts/generators/strategies/weekly-review-strategy.js +211 -0
- package/scripts/generators/strategies/weekly-review-strategy.js.map +1 -0
- package/scripts/generators/swot-content.d.ts +42 -0
- package/scripts/generators/swot-content.d.ts.map +1 -0
- package/scripts/generators/swot-content.js +366 -0
- package/scripts/generators/swot-content.js.map +1 -0
- package/scripts/generators/week-ahead-content.d.ts +103 -0
- package/scripts/generators/week-ahead-content.d.ts.map +1 -0
- package/scripts/generators/week-ahead-content.js +610 -0
- package/scripts/generators/week-ahead-content.js.map +1 -0
- package/scripts/index.d.ts +40 -0
- package/scripts/index.d.ts.map +1 -0
- package/scripts/index.js +53 -0
- package/scripts/index.js.map +1 -0
- package/scripts/mcp/ep-mcp-client.d.ts +471 -0
- package/scripts/mcp/ep-mcp-client.d.ts.map +1 -0
- package/scripts/mcp/ep-mcp-client.js +734 -0
- package/scripts/mcp/ep-mcp-client.js.map +1 -0
- package/scripts/mcp/mcp-connection.d.ts +264 -0
- package/scripts/mcp/mcp-connection.d.ts.map +1 -0
- package/scripts/mcp/mcp-connection.js +790 -0
- package/scripts/mcp/mcp-connection.js.map +1 -0
- package/scripts/mcp/mcp-health.d.ts +75 -0
- package/scripts/mcp/mcp-health.d.ts.map +1 -0
- package/scripts/mcp/mcp-health.js +78 -0
- package/scripts/mcp/mcp-health.js.map +1 -0
- package/scripts/mcp/mcp-retry.d.ts +94 -0
- package/scripts/mcp/mcp-retry.d.ts.map +1 -0
- package/scripts/mcp/mcp-retry.js +127 -0
- package/scripts/mcp/mcp-retry.js.map +1 -0
- package/scripts/mcp/wb-mcp-client.d.ts +38 -0
- package/scripts/mcp/wb-mcp-client.d.ts.map +1 -0
- package/scripts/mcp/wb-mcp-client.js +112 -0
- package/scripts/mcp/wb-mcp-client.js.map +1 -0
- package/scripts/templates/article-template.d.ts +9 -0
- package/scripts/templates/article-template.d.ts.map +1 -0
- package/scripts/templates/article-template.js +378 -0
- package/scripts/templates/article-template.js.map +1 -0
- package/scripts/templates/section-builders.d.ts +28 -0
- package/scripts/templates/section-builders.d.ts.map +1 -0
- package/scripts/templates/section-builders.js +142 -0
- package/scripts/templates/section-builders.js.map +1 -0
- package/scripts/types/analysis.d.ts +115 -0
- package/scripts/types/analysis.d.ts.map +1 -0
- package/scripts/types/analysis.js +4 -0
- package/scripts/types/analysis.js.map +1 -0
- package/scripts/types/common.d.ts +584 -0
- package/scripts/types/common.d.ts.map +1 -0
- package/scripts/types/common.js +96 -0
- package/scripts/types/common.js.map +1 -0
- package/scripts/types/generation.d.ts +104 -0
- package/scripts/types/generation.d.ts.map +1 -0
- package/scripts/types/generation.js +4 -0
- package/scripts/types/generation.js.map +1 -0
- package/scripts/types/index.d.ts +24 -0
- package/scripts/types/index.d.ts.map +1 -0
- package/scripts/types/index.js +16 -0
- package/scripts/types/index.js.map +1 -0
- package/scripts/types/intelligence.d.ts +129 -0
- package/scripts/types/intelligence.d.ts.map +1 -0
- package/scripts/types/intelligence.js +4 -0
- package/scripts/types/intelligence.js.map +1 -0
- package/scripts/types/mcp.d.ts +418 -0
- package/scripts/types/mcp.d.ts.map +1 -0
- package/scripts/types/mcp.js +4 -0
- package/scripts/types/mcp.js.map +1 -0
- package/scripts/types/parliament.d.ts +388 -0
- package/scripts/types/parliament.d.ts.map +1 -0
- package/scripts/types/parliament.js +4 -0
- package/scripts/types/parliament.js.map +1 -0
- package/scripts/types/quality.d.ts +114 -0
- package/scripts/types/quality.d.ts.map +1 -0
- package/scripts/types/quality.js +4 -0
- package/scripts/types/quality.js.map +1 -0
- package/scripts/types/stakeholder.d.ts +88 -0
- package/scripts/types/stakeholder.d.ts.map +1 -0
- package/scripts/types/stakeholder.js +16 -0
- package/scripts/types/stakeholder.js.map +1 -0
- package/scripts/types/visualization.d.ts +708 -0
- package/scripts/types/visualization.d.ts.map +1 -0
- package/scripts/types/visualization.js +4 -0
- package/scripts/types/visualization.js.map +1 -0
- package/scripts/types/world-bank.d.ts +85 -0
- package/scripts/types/world-bank.d.ts.map +1 -0
- package/scripts/types/world-bank.js +4 -0
- package/scripts/types/world-bank.js.map +1 -0
- package/scripts/utils/article-category.d.ts +18 -0
- package/scripts/utils/article-category.d.ts.map +1 -0
- package/scripts/utils/article-category.js +49 -0
- package/scripts/utils/article-category.js.map +1 -0
- package/scripts/utils/article-quality-scorer.d.ts +87 -0
- package/scripts/utils/article-quality-scorer.d.ts.map +1 -0
- package/scripts/utils/article-quality-scorer.js +1048 -0
- package/scripts/utils/article-quality-scorer.js.map +1 -0
- package/scripts/utils/content-metadata.d.ts +34 -0
- package/scripts/utils/content-metadata.d.ts.map +1 -0
- package/scripts/utils/content-metadata.js +249 -0
- package/scripts/utils/content-metadata.js.map +1 -0
- package/scripts/utils/content-validator.d.ts +94 -0
- package/scripts/utils/content-validator.d.ts.map +1 -0
- package/scripts/utils/content-validator.js +489 -0
- package/scripts/utils/content-validator.js.map +1 -0
- package/scripts/utils/copy-test-reports.d.ts +9 -0
- package/scripts/utils/copy-test-reports.d.ts.map +1 -0
- package/scripts/utils/copy-test-reports.js +508 -0
- package/scripts/utils/copy-test-reports.js.map +1 -0
- package/scripts/utils/file-utils.d.ts +144 -0
- package/scripts/utils/file-utils.d.ts.map +1 -0
- package/scripts/utils/file-utils.js +374 -0
- package/scripts/utils/file-utils.js.map +1 -0
- package/scripts/utils/fix-articles.d.ts +27 -0
- package/scripts/utils/fix-articles.d.ts.map +1 -0
- package/scripts/utils/fix-articles.js +510 -0
- package/scripts/utils/fix-articles.js.map +1 -0
- package/scripts/utils/generate-docs-index.d.ts +8 -0
- package/scripts/utils/generate-docs-index.d.ts.map +1 -0
- package/scripts/utils/generate-docs-index.js +275 -0
- package/scripts/utils/generate-docs-index.js.map +1 -0
- package/scripts/utils/html-sanitize.d.ts +18 -0
- package/scripts/utils/html-sanitize.d.ts.map +1 -0
- package/scripts/utils/html-sanitize.js +57 -0
- package/scripts/utils/html-sanitize.js.map +1 -0
- package/scripts/utils/intelligence-analysis.d.ts +173 -0
- package/scripts/utils/intelligence-analysis.d.ts.map +1 -0
- package/scripts/utils/intelligence-analysis.js +936 -0
- package/scripts/utils/intelligence-analysis.js.map +1 -0
- package/scripts/utils/intelligence-index.d.ts +126 -0
- package/scripts/utils/intelligence-index.d.ts.map +1 -0
- package/scripts/utils/intelligence-index.js +731 -0
- package/scripts/utils/intelligence-index.js.map +1 -0
- package/scripts/utils/metadata-utils.d.ts +14 -0
- package/scripts/utils/metadata-utils.d.ts.map +1 -0
- package/scripts/utils/metadata-utils.js +18 -0
- package/scripts/utils/metadata-utils.js.map +1 -0
- package/scripts/utils/news-metadata.d.ts +47 -0
- package/scripts/utils/news-metadata.d.ts.map +1 -0
- package/scripts/utils/news-metadata.js +259 -0
- package/scripts/utils/news-metadata.js.map +1 -0
- package/scripts/utils/validate-articles.d.ts +2 -0
- package/scripts/utils/validate-articles.d.ts.map +1 -0
- package/scripts/utils/validate-articles.js +284 -0
- package/scripts/utils/validate-articles.js.map +1 -0
- package/scripts/utils/validate-ep-api.d.ts +51 -0
- package/scripts/utils/validate-ep-api.d.ts.map +1 -0
- package/scripts/utils/validate-ep-api.js +160 -0
- package/scripts/utils/validate-ep-api.js.map +1 -0
- package/scripts/utils/world-bank-data.d.ts +84 -0
- package/scripts/utils/world-bank-data.d.ts.map +1 -0
- package/scripts/utils/world-bank-data.js +311 -0
- package/scripts/utils/world-bank-data.js.map +1 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* @module Generators/BreakingContent
|
|
5
|
+
* @description Pure functions for building breaking-news article HTML.
|
|
6
|
+
*
|
|
7
|
+
* **Feed-first approach**: EP feed data (adopted texts, events, procedures,
|
|
8
|
+
* MEP updates) is the primary news content. Analytical intelligence sections
|
|
9
|
+
* (voting anomalies, coalition dynamics) are supplementary context only.
|
|
10
|
+
* Precomputed statistics are NEVER the news itself.
|
|
11
|
+
*/
|
|
12
|
+
import { escapeHTML } from '../utils/file-utils.js';
|
|
13
|
+
import { getLocalizedString, EDITORIAL_STRINGS, BREAKING_STRINGS } from '../constants/languages.js';
|
|
14
|
+
/**
|
|
15
|
+
* Minimum significance score for a breaking news item to be considered
|
|
16
|
+
* noteworthy. Items below this threshold may be suppressed from metadata
|
|
17
|
+
* keywords by the strategy layer.
|
|
18
|
+
*/
|
|
19
|
+
export const SIGNIFICANCE_THRESHOLD = 10;
|
|
20
|
+
/** Weight for adopted texts sub-score — sum of all weights MUST equal 1.0 */
|
|
21
|
+
const ADOPTED_TEXTS_WEIGHT = 0.4;
|
|
22
|
+
/** Weight for affected MEPs sub-score */
|
|
23
|
+
const AFFECTED_MEPS_WEIGHT = 0.2;
|
|
24
|
+
/** Weight for legislative stage sub-score */
|
|
25
|
+
const LEGISLATIVE_STAGE_WEIGHT = 0.3;
|
|
26
|
+
/** Weight for committee/event involvement sub-score (0.4 + 0.2 + 0.3 + 0.1 = 1.0) */
|
|
27
|
+
const COMMITTEE_INVOLVEMENT_WEIGHT = 0.1;
|
|
28
|
+
/** Cap for sub-score normalisation */
|
|
29
|
+
const MAX_SUB_SCORE = 100;
|
|
30
|
+
/** Pattern matching final-reading legislative stages for higher scoring */
|
|
31
|
+
const FINAL_STAGE_PATTERN = /final|third|plenary|adopted|trilogue/i;
|
|
32
|
+
/**
|
|
33
|
+
* Compute a political significance score for a breaking news data payload.
|
|
34
|
+
*
|
|
35
|
+
* The score is a weighted composite of four dimensions:
|
|
36
|
+
* - **Adopted texts** (40 %): more adopted texts → higher legislative impact.
|
|
37
|
+
* - **Affected MEPs** (20 %): more MEP updates → wider political scope.
|
|
38
|
+
* - **Legislative stage** (30 %): procedures at final reading score higher.
|
|
39
|
+
* - **Committee involvement** (10 %): more events → broader institutional engagement.
|
|
40
|
+
*
|
|
41
|
+
* All inputs are sanitised: `null`/`undefined` fields default to zero.
|
|
42
|
+
*
|
|
43
|
+
* @param item - Aggregated feed data for the breaking news article
|
|
44
|
+
* @returns Quantified significance score with per-dimension breakdown
|
|
45
|
+
*/
|
|
46
|
+
export function scoreBreakingNewsSignificance(item) {
|
|
47
|
+
// Adopted texts: each text adds 20 pts, capped at 100
|
|
48
|
+
const adoptedTextsScore = Math.min((item.adoptedTexts?.length ?? 0) * 20, MAX_SUB_SCORE);
|
|
49
|
+
// Affected MEPs: each update adds 10 pts, capped at 100. Prefer API-reported total
|
|
50
|
+
// (totalMEPUpdates) when available to avoid under-scoring truncated feeds.
|
|
51
|
+
const totalAffectedMEPs = item.totalMEPUpdates ?? item.mepUpdates?.length ?? 0;
|
|
52
|
+
const affectedMEPsScore = Math.min(totalAffectedMEPs * 10, MAX_SUB_SCORE);
|
|
53
|
+
// Legislative stage: procedures at a "final" stage contribute 25 pts each,
|
|
54
|
+
// procedures with a known non-final stage contribute 10 pts, missing stage → 0.
|
|
55
|
+
const procedures = item.procedures ?? [];
|
|
56
|
+
const stagePoints = procedures.reduce((sum, proc) => {
|
|
57
|
+
const stage = proc.stage ?? '';
|
|
58
|
+
if (!stage)
|
|
59
|
+
return sum;
|
|
60
|
+
return sum + (FINAL_STAGE_PATTERN.test(stage) ? 25 : 10);
|
|
61
|
+
}, 0);
|
|
62
|
+
const legislativeStageScore = Math.min(stagePoints, MAX_SUB_SCORE);
|
|
63
|
+
// Committee / event involvement: each event adds 15 pts, capped at 100
|
|
64
|
+
const committeeInvolvementScore = Math.min((item.events?.length ?? 0) * 15, MAX_SUB_SCORE);
|
|
65
|
+
const overallScore = Math.round(adoptedTextsScore * ADOPTED_TEXTS_WEIGHT +
|
|
66
|
+
affectedMEPsScore * AFFECTED_MEPS_WEIGHT +
|
|
67
|
+
legislativeStageScore * LEGISLATIVE_STAGE_WEIGHT +
|
|
68
|
+
committeeInvolvementScore * COMMITTEE_INVOLVEMENT_WEIGHT);
|
|
69
|
+
return {
|
|
70
|
+
adoptedTextsScore,
|
|
71
|
+
affectedMEPsScore,
|
|
72
|
+
legislativeStageScore,
|
|
73
|
+
committeeInvolvementScore,
|
|
74
|
+
overallScore,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Maximum characters to display from raw MCP intelligence data */
|
|
78
|
+
const MAX_DATA_CHARS = 2000;
|
|
79
|
+
/**
|
|
80
|
+
* Return true when `raw` is a JSON error object (contains an `"error"` key),
|
|
81
|
+
* indicating that the MCP tool call failed rather than returning useful data.
|
|
82
|
+
*
|
|
83
|
+
* @param raw - Raw string from MCP tool call
|
|
84
|
+
* @returns `true` when raw is a tool-error JSON payload
|
|
85
|
+
*/
|
|
86
|
+
function isToolError(raw) {
|
|
87
|
+
try {
|
|
88
|
+
const parsed = JSON.parse(raw.trim());
|
|
89
|
+
return (typeof parsed === 'object' &&
|
|
90
|
+
parsed !== null &&
|
|
91
|
+
'error' in parsed);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Maximum feed items to render per section */
|
|
98
|
+
const MAX_FEED_ITEMS = 10;
|
|
99
|
+
/**
|
|
100
|
+
* Build a feed truncation note paragraph when displayed items are fewer than total items.
|
|
101
|
+
*
|
|
102
|
+
* @param shown - Number of items shown
|
|
103
|
+
* @param total - Total number of items available
|
|
104
|
+
* @param strings - Localized breaking strings containing `showingXofNFn`
|
|
105
|
+
* @returns HTML paragraph string or empty string
|
|
106
|
+
*/
|
|
107
|
+
function buildFeedTruncationNote(shown, total, strings) {
|
|
108
|
+
if (shown >= total)
|
|
109
|
+
return '';
|
|
110
|
+
return `\n <p class="feed-truncation-note">${escapeHTML(strings.showingXofNFn(shown, total))}</p>`;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Regex that matches generic placeholder adopted-text titles generated by the EP feed API.
|
|
114
|
+
* When matched, the label/identifier is preferred as the display title instead.
|
|
115
|
+
*/
|
|
116
|
+
const ADOPTED_TEXT_PLACEHOLDER_PATTERN = /^(Adopted text|European Parliament adopted text)/i;
|
|
117
|
+
// ─── Feed section builders ───────────────────────────────────────────────────
|
|
118
|
+
/**
|
|
119
|
+
* Build adopted texts section HTML from feed items.
|
|
120
|
+
*
|
|
121
|
+
* @param items - Adopted text feed items
|
|
122
|
+
* @param lang - Language code for localized strings
|
|
123
|
+
* @returns HTML section string or empty string
|
|
124
|
+
*/
|
|
125
|
+
function buildAdoptedTextsSection(items, lang) {
|
|
126
|
+
if (items.length === 0)
|
|
127
|
+
return '';
|
|
128
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
129
|
+
const displayItems = items.slice(0, MAX_FEED_ITEMS);
|
|
130
|
+
// EP API provides titles in English only — mark non-English articles accordingly
|
|
131
|
+
const titleLangAttr = lang !== 'en' ? ' lang="en"' : '';
|
|
132
|
+
const listItems = displayItems
|
|
133
|
+
.map((item) => {
|
|
134
|
+
const labelOrId = item.label ?? item.identifier;
|
|
135
|
+
const titleIsPlaceholder = !item.title || ADOPTED_TEXT_PLACEHOLDER_PATTERN.test(item.title);
|
|
136
|
+
const displayTitle = (titleIsPlaceholder
|
|
137
|
+
? labelOrId
|
|
138
|
+
? strings.adoptedTextItemLabelFn(labelOrId)
|
|
139
|
+
: item.title
|
|
140
|
+
: item.title) ?? '';
|
|
141
|
+
const showSecondaryLabel = !titleIsPlaceholder && labelOrId;
|
|
142
|
+
return (`<li class="feed-item adopted-text-item">` +
|
|
143
|
+
`<strong${titleLangAttr}>${escapeHTML(displayTitle)}</strong>` +
|
|
144
|
+
`${showSecondaryLabel && labelOrId ? ` <span class="feed-label">${escapeHTML(labelOrId)}</span>` : ''}` +
|
|
145
|
+
`${item.date ? ` <span class="feed-date">(${escapeHTML(item.date)})</span>` : ''}` +
|
|
146
|
+
`${item.type ? ` <span class="feed-type">${escapeHTML(strings.adoptedTextTypeLabel)}</span>` : ''}` +
|
|
147
|
+
`</li>`);
|
|
148
|
+
})
|
|
149
|
+
.join('\n ');
|
|
150
|
+
const truncationNote = buildFeedTruncationNote(displayItems.length, items.length, strings);
|
|
151
|
+
return `
|
|
152
|
+
<section class="adopted-texts-feed">
|
|
153
|
+
<h2>${escapeHTML(strings.adoptedTextsHeading)}</h2>
|
|
154
|
+
<ul>
|
|
155
|
+
${listItems}
|
|
156
|
+
</ul>${truncationNote}
|
|
157
|
+
</section>`;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Build recent events section HTML from feed items.
|
|
161
|
+
*
|
|
162
|
+
* @param items - Event feed items
|
|
163
|
+
* @param lang - Language code for localized strings
|
|
164
|
+
* @returns HTML section string or empty string
|
|
165
|
+
*/
|
|
166
|
+
function buildRecentEventsSection(items, lang) {
|
|
167
|
+
if (items.length === 0)
|
|
168
|
+
return '';
|
|
169
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
170
|
+
const listItems = items
|
|
171
|
+
.slice(0, MAX_FEED_ITEMS)
|
|
172
|
+
.map((item) => `<li class="feed-item event-item">` +
|
|
173
|
+
`<strong>${escapeHTML(item.title)}</strong>` +
|
|
174
|
+
`${item.date ? ` <span class="feed-date">(${escapeHTML(item.date)})</span>` : ''}` +
|
|
175
|
+
`${item.location ? ` <span class="feed-location">${escapeHTML(item.location)}</span>` : ''}` +
|
|
176
|
+
`</li>`)
|
|
177
|
+
.join('\n ');
|
|
178
|
+
return `
|
|
179
|
+
<section class="events-feed">
|
|
180
|
+
<h2>${escapeHTML(strings.recentEventsHeading)}</h2>
|
|
181
|
+
<ul>
|
|
182
|
+
${listItems}
|
|
183
|
+
</ul>
|
|
184
|
+
</section>`;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Build procedure updates section HTML from feed items.
|
|
188
|
+
*
|
|
189
|
+
* @param items - Procedure feed items
|
|
190
|
+
* @param lang - Language code for localized strings
|
|
191
|
+
* @returns HTML section string or empty string
|
|
192
|
+
*/
|
|
193
|
+
function buildProcedureUpdatesSection(items, lang) {
|
|
194
|
+
if (items.length === 0)
|
|
195
|
+
return '';
|
|
196
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
197
|
+
const listItems = items
|
|
198
|
+
.slice(0, MAX_FEED_ITEMS)
|
|
199
|
+
.map((item) => `<li class="feed-item procedure-item">` +
|
|
200
|
+
`<strong>${escapeHTML(item.title)}</strong>` +
|
|
201
|
+
`${item.stage ? ` <span class="feed-stage">[${escapeHTML(item.stage)}]</span>` : ''}` +
|
|
202
|
+
`${item.date ? ` <span class="feed-date">(${escapeHTML(item.date)})</span>` : ''}` +
|
|
203
|
+
`</li>`)
|
|
204
|
+
.join('\n ');
|
|
205
|
+
return `
|
|
206
|
+
<section class="procedures-feed">
|
|
207
|
+
<h2>${escapeHTML(strings.procedureUpdatesHeading)}</h2>
|
|
208
|
+
<ul>
|
|
209
|
+
${listItems}
|
|
210
|
+
</ul>
|
|
211
|
+
</section>`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Build MEP updates section HTML from feed items.
|
|
215
|
+
*
|
|
216
|
+
* @param items - MEP feed items (up to the fetch limit)
|
|
217
|
+
* @param lang - Language code for localized strings
|
|
218
|
+
* @param totalCount - Optional total MEP updates reported by the feed API (may exceed fetched items)
|
|
219
|
+
* @returns HTML section string or empty string
|
|
220
|
+
*/
|
|
221
|
+
function buildMEPUpdatesSection(items, lang, totalCount) {
|
|
222
|
+
if (items.length === 0)
|
|
223
|
+
return '';
|
|
224
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
225
|
+
const displayItems = items.slice(0, MAX_FEED_ITEMS);
|
|
226
|
+
const listItems = displayItems
|
|
227
|
+
.map((item) => `<li class="feed-item mep-item">` +
|
|
228
|
+
`<strong>${escapeHTML(item.name)}</strong>` +
|
|
229
|
+
`${item.date ? ` <span class="feed-date">(${escapeHTML(item.date)})</span>` : ''}` +
|
|
230
|
+
`${item.country ? ` <span class="feed-country">(${escapeHTML(item.country)})</span>` : ''}` +
|
|
231
|
+
`${item.group ? ` <span class="feed-group">${escapeHTML(item.group)}</span>` : ''}` +
|
|
232
|
+
`</li>`)
|
|
233
|
+
.join('\n ');
|
|
234
|
+
// Use API total count when available and larger than fetched count; otherwise fall back to fetched count
|
|
235
|
+
const reportedTotal = totalCount !== undefined && totalCount > items.length ? totalCount : items.length;
|
|
236
|
+
const truncationNote = buildFeedTruncationNote(displayItems.length, reportedTotal, strings);
|
|
237
|
+
return `
|
|
238
|
+
<section class="mep-updates-feed">
|
|
239
|
+
<h2>${escapeHTML(strings.mepUpdatesHeading)}</h2>
|
|
240
|
+
<ul>
|
|
241
|
+
${listItems}
|
|
242
|
+
</ul>${truncationNote}
|
|
243
|
+
</section>`;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Build the combined feed-based news sections (primary content).
|
|
247
|
+
*
|
|
248
|
+
* @param feedData - Aggregated feed data
|
|
249
|
+
* @param lang - Language code
|
|
250
|
+
* @returns HTML string with all feed sections
|
|
251
|
+
*/
|
|
252
|
+
function buildFeedSections(feedData, lang) {
|
|
253
|
+
if (!feedData)
|
|
254
|
+
return '';
|
|
255
|
+
const sections = [
|
|
256
|
+
buildAdoptedTextsSection(feedData.adoptedTexts, lang),
|
|
257
|
+
buildRecentEventsSection(feedData.events, lang),
|
|
258
|
+
buildProcedureUpdatesSection(feedData.procedures, lang),
|
|
259
|
+
buildMEPUpdatesSection(feedData.mepUpdates, lang, feedData.totalMEPUpdates),
|
|
260
|
+
];
|
|
261
|
+
return sections.filter(Boolean).join('');
|
|
262
|
+
}
|
|
263
|
+
// ─── Private intelligence section builders ───────────────────────────────────
|
|
264
|
+
/**
|
|
265
|
+
* Build intelligence briefing section HTML from structured anomaly data
|
|
266
|
+
*
|
|
267
|
+
* @param anomalies - Structured voting anomaly intelligence items
|
|
268
|
+
* @param lang - Language code for localized strings
|
|
269
|
+
* @returns HTML section string or empty string
|
|
270
|
+
*/
|
|
271
|
+
function buildAnomalyAlertSection(anomalies, lang) {
|
|
272
|
+
if (anomalies.length === 0)
|
|
273
|
+
return '';
|
|
274
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
275
|
+
const items = anomalies
|
|
276
|
+
.map((a) => `<li class="anomaly-${escapeHTML(a.significance)}">` +
|
|
277
|
+
`<strong>${escapeHTML(a.description)}</strong> — ` +
|
|
278
|
+
`${escapeHTML(a.implication)} ` +
|
|
279
|
+
`(deviation: ${escapeHTML(String(a.deviationPercentage))}%)</li>`)
|
|
280
|
+
.join('\n ');
|
|
281
|
+
return `
|
|
282
|
+
<section class="anomaly-alert">
|
|
283
|
+
<h3>${escapeHTML(strings.votingAnomalyAlert)}</h3>
|
|
284
|
+
<ul>
|
|
285
|
+
${items}
|
|
286
|
+
</ul>
|
|
287
|
+
</section>`;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Build coalition dynamics section HTML from structured coalition data
|
|
291
|
+
*
|
|
292
|
+
* @param coalitions - Structured coalition intelligence items
|
|
293
|
+
* @param lang - Language code for localized strings
|
|
294
|
+
* @returns HTML section string or empty string
|
|
295
|
+
*/
|
|
296
|
+
function buildCoalitionDynamicsSection(coalitions, lang) {
|
|
297
|
+
if (coalitions.length === 0)
|
|
298
|
+
return '';
|
|
299
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
300
|
+
const items = coalitions
|
|
301
|
+
.map((c) => `<li class="coalition-${escapeHTML(c.riskLevel)}">` +
|
|
302
|
+
`${escapeHTML(c.groups.join(', '))} — ` +
|
|
303
|
+
`cohesion: ${escapeHTML(String(Math.round(c.cohesionScore * 100)))}% ` +
|
|
304
|
+
`(${escapeHTML(c.alignmentTrend)})</li>`)
|
|
305
|
+
.join('\n ');
|
|
306
|
+
return `
|
|
307
|
+
<section class="coalition-dynamics">
|
|
308
|
+
<h3>${escapeHTML(strings.coalitionDynamicsSection)}</h3>
|
|
309
|
+
<ul>
|
|
310
|
+
${items}
|
|
311
|
+
</ul>
|
|
312
|
+
</section>`;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Build key parliamentary players section HTML from structured MEP influence data
|
|
316
|
+
*
|
|
317
|
+
* @param mepScores - Structured MEP influence score items
|
|
318
|
+
* @param lang - Language code for localized strings
|
|
319
|
+
* @returns HTML section string or empty string
|
|
320
|
+
*/
|
|
321
|
+
function buildKeyPlayersIntelSection(mepScores, lang) {
|
|
322
|
+
if (mepScores.length === 0)
|
|
323
|
+
return '';
|
|
324
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
325
|
+
const items = mepScores
|
|
326
|
+
.map((m) => `<li class="mep-score">` +
|
|
327
|
+
`<strong>${escapeHTML(m.mepName)}</strong> — ` +
|
|
328
|
+
`score: ${escapeHTML(String(Math.round(m.overallScore)))} ` +
|
|
329
|
+
`${m.rank ? `(${escapeHTML(m.rank)})` : ''}</li>`)
|
|
330
|
+
.join('\n ');
|
|
331
|
+
return `
|
|
332
|
+
<section class="key-players-intel">
|
|
333
|
+
<h3>${escapeHTML(strings.keyPlayers)}</h3>
|
|
334
|
+
<ul>
|
|
335
|
+
${items}
|
|
336
|
+
</ul>
|
|
337
|
+
</section>`;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Build intelligence briefing section HTML from all structured sources
|
|
341
|
+
*
|
|
342
|
+
* @param anomalies - Structured voting anomaly intelligence items
|
|
343
|
+
* @param coalitions - Structured coalition intelligence items
|
|
344
|
+
* @param mepScores - Structured MEP influence score items
|
|
345
|
+
* @param lang - Language code for localized strings
|
|
346
|
+
* @returns HTML section string or empty string
|
|
347
|
+
*/
|
|
348
|
+
function buildIntelligenceBriefingSection(anomalies, coalitions, mepScores, lang) {
|
|
349
|
+
const hasIntel = anomalies.length > 0 || coalitions.length > 0 || mepScores.length > 0;
|
|
350
|
+
if (!hasIntel)
|
|
351
|
+
return '';
|
|
352
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
353
|
+
return `
|
|
354
|
+
<section class="intelligence-briefing">
|
|
355
|
+
<h2>${escapeHTML(strings.intelligenceBriefing)}</h2>
|
|
356
|
+
${buildAnomalyAlertSection(anomalies, lang)}
|
|
357
|
+
${buildCoalitionDynamicsSection(coalitions, lang)}
|
|
358
|
+
${buildKeyPlayersIntelSection(mepScores, lang)}
|
|
359
|
+
</section>`;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Build voting anomaly section HTML, showing a localized fallback when the raw
|
|
363
|
+
* data is a tool-error payload rather than useful intelligence.
|
|
364
|
+
*
|
|
365
|
+
* @param raw - Raw anomaly data string from MCP (may be empty or an error JSON)
|
|
366
|
+
* @param strings - Localized breaking-news strings for the target language
|
|
367
|
+
* @param sourceAttribution - Localized source attribution label
|
|
368
|
+
* @returns HTML section string or empty string
|
|
369
|
+
*/
|
|
370
|
+
function buildAnomalyRawSection(raw, strings, sourceAttribution) {
|
|
371
|
+
if (!raw)
|
|
372
|
+
return '';
|
|
373
|
+
const heading = `<h2>${escapeHTML(strings.votingAnomalyIntel)}</h2>`;
|
|
374
|
+
if (isToolError(raw)) {
|
|
375
|
+
return `
|
|
376
|
+
<section class="analysis">
|
|
377
|
+
${heading}
|
|
378
|
+
<p class="data-narrative">${escapeHTML(strings.anomalyUnavailable)}</p>
|
|
379
|
+
</section>`;
|
|
380
|
+
}
|
|
381
|
+
return `
|
|
382
|
+
<section class="analysis">
|
|
383
|
+
${heading}
|
|
384
|
+
<p class="source-attribution">${escapeHTML(sourceAttribution)}:</p>
|
|
385
|
+
<p class="data-narrative">${escapeHTML(raw.slice(0, MAX_DATA_CHARS))}</p>
|
|
386
|
+
</section>`;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Build coalition dynamics section HTML, showing a localized fallback when the
|
|
390
|
+
* raw data is a tool-error payload rather than useful intelligence.
|
|
391
|
+
*
|
|
392
|
+
* @param raw - Raw coalition data string from MCP (may be empty or an error JSON)
|
|
393
|
+
* @param strings - Localized breaking-news strings for the target language
|
|
394
|
+
* @param sourceAttribution - Localized source attribution label
|
|
395
|
+
* @returns HTML section string or empty string
|
|
396
|
+
*/
|
|
397
|
+
function buildCoalitionRawSection(raw, strings, sourceAttribution) {
|
|
398
|
+
if (!raw)
|
|
399
|
+
return '';
|
|
400
|
+
const heading = `<h2>${escapeHTML(strings.coalitionDynamics)}</h2>`;
|
|
401
|
+
if (isToolError(raw)) {
|
|
402
|
+
return `
|
|
403
|
+
<section class="coalition-impact">
|
|
404
|
+
${heading}
|
|
405
|
+
<p class="data-narrative">${escapeHTML(strings.coalitionUnavailable)}</p>
|
|
406
|
+
</section>`;
|
|
407
|
+
}
|
|
408
|
+
return `
|
|
409
|
+
<section class="coalition-impact">
|
|
410
|
+
${heading}
|
|
411
|
+
<p class="source-attribution">${escapeHTML(sourceAttribution)}:</p>
|
|
412
|
+
<p class="data-narrative">${escapeHTML(raw.slice(0, MAX_DATA_CHARS))}</p>
|
|
413
|
+
</section>`;
|
|
414
|
+
}
|
|
415
|
+
// ─── Exported function ────────────────────────────────────────────────────────
|
|
416
|
+
/**
|
|
417
|
+
* Build breaking news article HTML content.
|
|
418
|
+
*
|
|
419
|
+
* **Feed-first**: When `feedData` is provided, feed sections are the primary
|
|
420
|
+
* content and appear first. Raw MCP analytical data and structured intelligence
|
|
421
|
+
* sections are rendered as supplementary context below.
|
|
422
|
+
*
|
|
423
|
+
* When no data is provided at all, returns a placeholder notice.
|
|
424
|
+
*
|
|
425
|
+
* @param date - Current date string for the article
|
|
426
|
+
* @param anomalyRaw - Raw anomaly data from MCP (context only)
|
|
427
|
+
* @param coalitionRaw - Raw coalition dynamics data from MCP (context only)
|
|
428
|
+
* @param reportRaw - Raw analytical report from MCP (context only)
|
|
429
|
+
* @param influenceRaw - Raw MEP influence data from MCP (context only)
|
|
430
|
+
* @param lang - Language code for localized editorial strings (default: 'en')
|
|
431
|
+
* @param anomalies - Optional structured voting anomaly intelligence items
|
|
432
|
+
* @param coalitions - Optional structured coalition intelligence items
|
|
433
|
+
* @param mepScores - Optional structured MEP influence score items
|
|
434
|
+
* @param feedData - Optional EP feed data (adopted texts, events, procedures, MEPs)
|
|
435
|
+
* @returns Full article HTML content string
|
|
436
|
+
*/
|
|
437
|
+
export function buildBreakingNewsContent(date, anomalyRaw, coalitionRaw, reportRaw, influenceRaw, lang = 'en', anomalies = [], coalitions = [], mepScores = [], feedData) {
|
|
438
|
+
const editorial = getLocalizedString(EDITORIAL_STRINGS, lang);
|
|
439
|
+
const strings = getLocalizedString(BREAKING_STRINGS, lang);
|
|
440
|
+
// Feed data is the primary news content
|
|
441
|
+
const hasFeedData = Boolean(feedData &&
|
|
442
|
+
(feedData.adoptedTexts.length > 0 ||
|
|
443
|
+
feedData.events.length > 0 ||
|
|
444
|
+
feedData.procedures.length > 0 ||
|
|
445
|
+
feedData.mepUpdates.length > 0));
|
|
446
|
+
// Analytical data is context only
|
|
447
|
+
const hasAnalyticalData = Boolean(anomalyRaw ||
|
|
448
|
+
coalitionRaw ||
|
|
449
|
+
reportRaw ||
|
|
450
|
+
influenceRaw ||
|
|
451
|
+
anomalies.length ||
|
|
452
|
+
coalitions.length ||
|
|
453
|
+
mepScores.length);
|
|
454
|
+
const hasData = hasFeedData || hasAnalyticalData;
|
|
455
|
+
// MCP is truly unavailable only when feedData is undefined AND no analytical data
|
|
456
|
+
const isMCPUnavailable = !feedData && !hasAnalyticalData;
|
|
457
|
+
const timestamp = new Date().toISOString();
|
|
458
|
+
// ─── Feed sections (PRIMARY news content) ──────────────────────────────
|
|
459
|
+
// When feedData is present but empty AND hasAnalyticalData is false,
|
|
460
|
+
// the lede already conveys noFeedDataNotice — skip the duplicate section.
|
|
461
|
+
const feedSections = feedData && !hasFeedData && hasAnalyticalData
|
|
462
|
+
? `
|
|
463
|
+
<section class="feed-empty-notice">
|
|
464
|
+
<p>${escapeHTML(strings.noFeedDataNotice)}</p>
|
|
465
|
+
</section>`
|
|
466
|
+
: buildFeedSections(feedData, lang);
|
|
467
|
+
// ─── Analytical context sections (SECONDARY) ──────────────────────────
|
|
468
|
+
const anomalySection = buildAnomalyRawSection(anomalyRaw, strings, editorial.sourceAttribution);
|
|
469
|
+
const coalitionSection = buildCoalitionRawSection(coalitionRaw, strings, editorial.sourceAttribution);
|
|
470
|
+
const reportSection = reportRaw
|
|
471
|
+
? `
|
|
472
|
+
<section class="context">
|
|
473
|
+
<h2>${escapeHTML(strings.analyticalReport)}</h2>
|
|
474
|
+
<p class="source-attribution">${escapeHTML(editorial.analysisNote)}:</p>
|
|
475
|
+
<p class="data-narrative">${escapeHTML(reportRaw.slice(0, MAX_DATA_CHARS))}</p>
|
|
476
|
+
</section>`
|
|
477
|
+
: '';
|
|
478
|
+
const keyPlayersSection = influenceRaw
|
|
479
|
+
? `
|
|
480
|
+
<section class="key-players">
|
|
481
|
+
<h2>${escapeHTML(strings.keyMEPInfluence)}</h2>
|
|
482
|
+
<p class="source-attribution">${escapeHTML(editorial.sourceAttribution)}:</p>
|
|
483
|
+
<p class="data-narrative">${escapeHTML(influenceRaw.slice(0, MAX_DATA_CHARS))}</p>
|
|
484
|
+
</section>`
|
|
485
|
+
: '';
|
|
486
|
+
const context = escapeHTML(editorial.parliamentaryContext);
|
|
487
|
+
const finding = escapeHTML(editorial.keyTakeaway);
|
|
488
|
+
const attribution = escapeHTML(editorial.sourceAttribution);
|
|
489
|
+
const whyThisMattersSection = hasData
|
|
490
|
+
? `
|
|
491
|
+
<section class="why-this-matters">
|
|
492
|
+
<h2>${escapeHTML(editorial.whyThisMatters)}</h2>
|
|
493
|
+
<p>${context}: ${finding} — ${attribution}.</p>
|
|
494
|
+
</section>`
|
|
495
|
+
: '';
|
|
496
|
+
const intelligenceBriefing = buildIntelligenceBriefingSection(anomalies, coalitions, mepScores, lang);
|
|
497
|
+
const ledeText = hasAnalyticalData
|
|
498
|
+
? strings.lede
|
|
499
|
+
: hasFeedData
|
|
500
|
+
? strings.feedLede
|
|
501
|
+
: strings.noFeedDataNotice;
|
|
502
|
+
const placeholderNotice = isMCPUnavailable
|
|
503
|
+
? `
|
|
504
|
+
<div class="notice">
|
|
505
|
+
<p><strong>Note:</strong> ${escapeHTML(strings.placeholderNotice)}</p>
|
|
506
|
+
</div>
|
|
507
|
+
<section class="lede">
|
|
508
|
+
<p>${escapeHTML(strings.placeholderLede)}</p>
|
|
509
|
+
</section>`
|
|
510
|
+
: `
|
|
511
|
+
<section class="lede">
|
|
512
|
+
<p>${escapeHTML(ledeText.replace(/[.。]$/, '').trimEnd())} ${escapeHTML(strings.asOf)} ${escapeHTML(date)}.</p>
|
|
513
|
+
</section>`;
|
|
514
|
+
return `
|
|
515
|
+
<div class="article-content">
|
|
516
|
+
<section class="breaking-banner">
|
|
517
|
+
<p class="breaking-timestamp">${escapeHTML(strings.breakingBanner)} — ${escapeHTML(timestamp)}</p>
|
|
518
|
+
</section>
|
|
519
|
+
${placeholderNotice}
|
|
520
|
+
${feedSections}
|
|
521
|
+
${intelligenceBriefing}
|
|
522
|
+
${anomalySection}
|
|
523
|
+
${coalitionSection}
|
|
524
|
+
${reportSection}
|
|
525
|
+
${keyPlayersSection}
|
|
526
|
+
${whyThisMattersSection}
|
|
527
|
+
</div>
|
|
528
|
+
`;
|
|
529
|
+
}
|
|
530
|
+
//# sourceMappingURL=breaking-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breaking-content.js","sourceRoot":"","sources":["../../src/generators/breaking-content.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,sCAAsC;AAEtC;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAcpG;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,6EAA6E;AAC7E,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,yCAAyC;AACzC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,6CAA6C;AAC7C,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,qFAAqF;AACrF,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,sCAAsC;AACtC,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,6BAA6B,CAC3C,IAA0B;IAE1B,sDAAsD;IACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAEzF,mFAAmF;IACnF,2EAA2E;IAC3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC;IAC/E,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAE1E,2EAA2E;IAC3E,gFAAgF;IAChF,MAAM,UAAU,GAAG,IAAI,CAA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CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Generators/CommitteeHelpers
|
|
3
|
+
* @description Pure helpers for applying MCP committee data to a CommitteeData object.
|
|
4
|
+
* Stateless functions — no I/O or MCP calls; only JSON parsing + data assignment.
|
|
5
|
+
*/
|
|
6
|
+
import type { CommitteeData, MCPToolResult } from '../types/index.js';
|
|
7
|
+
/** Featured committees to include in committee reports */
|
|
8
|
+
export declare const FEATURED_COMMITTEES: readonly ["ENVI", "ECON", "AFET", "LIBE", "AGRI"];
|
|
9
|
+
/** Sentinel value used when no real chair data is available from MCP */
|
|
10
|
+
export declare const PLACEHOLDER_CHAIR = "N/A";
|
|
11
|
+
/** Sentinel value used when no real member count data is available from MCP */
|
|
12
|
+
export declare const PLACEHOLDER_MEMBERS = 0;
|
|
13
|
+
/**
|
|
14
|
+
* Apply committee info from MCP result to the data object
|
|
15
|
+
*
|
|
16
|
+
* @param result - MCP tool result
|
|
17
|
+
* @param data - Committee data to populate
|
|
18
|
+
* @param abbreviation - Fallback abbreviation
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyCommitteeInfo(result: MCPToolResult, data: CommitteeData, abbreviation: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Apply documents from MCP result to the data object
|
|
23
|
+
*
|
|
24
|
+
* @param result - MCP tool result
|
|
25
|
+
* @param data - Committee data to populate
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyDocuments(result: MCPToolResult, data: CommitteeData): void;
|
|
28
|
+
/**
|
|
29
|
+
* Detect whether a list of committee data entries are all fallback/default placeholders.
|
|
30
|
+
*
|
|
31
|
+
* A committee entry is considered a placeholder when the MCP fetch produced no real
|
|
32
|
+
* data — i.e. `chair` is still the sentinel `'N/A'`, `members` is 0, and the
|
|
33
|
+
* `documents` list is empty. This typically happens when the MCP server is
|
|
34
|
+
* unavailable and `fetchCommitteeData` returns the `defaultResult` unchanged.
|
|
35
|
+
*
|
|
36
|
+
* Returns `true` only when:
|
|
37
|
+
* - the list is non-empty **and**
|
|
38
|
+
* - every committee entry matches all three placeholder criteria.
|
|
39
|
+
*
|
|
40
|
+
* An empty list returns `false` so that a genuine zero-committee scenario is still
|
|
41
|
+
* rendered (the caller can decide how to handle it).
|
|
42
|
+
*
|
|
43
|
+
* @param committees - Committee data entries to inspect
|
|
44
|
+
* @returns `true` when all entries are default/placeholder data; `false` otherwise
|
|
45
|
+
*/
|
|
46
|
+
export declare function isPlaceholderCommitteeData(committees: readonly CommitteeData[]): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Apply effectiveness metrics from MCP result to the data object
|
|
49
|
+
*
|
|
50
|
+
* @param result - MCP tool result
|
|
51
|
+
* @param data - Committee data to populate
|
|
52
|
+
*/
|
|
53
|
+
export declare function applyEffectiveness(result: MCPToolResult, data: CommitteeData): void;
|
|
54
|
+
//# sourceMappingURL=committee-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"committee-helpers.d.ts","sourceRoot":"","sources":["../../src/generators/committee-helpers.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,mDAAoD,CAAC;AAErF,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AAEvC,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAmDrC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,aAAa,EACnB,YAAY,EAAE,MAAM,GACnB,IAAI,CAkBN;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAkC/E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAUxF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAiBnF"}
|