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.
Files changed (276) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1005 -0
  3. package/SECURITY.md +151 -0
  4. package/package.json +131 -0
  5. package/scripts/constants/committee-indicator-map.d.ts +199 -0
  6. package/scripts/constants/committee-indicator-map.d.ts.map +1 -0
  7. package/scripts/constants/committee-indicator-map.js +1224 -0
  8. package/scripts/constants/committee-indicator-map.js.map +1 -0
  9. package/scripts/constants/config.d.ts +38 -0
  10. package/scripts/constants/config.d.ts.map +1 -0
  11. package/scripts/constants/config.js +66 -0
  12. package/scripts/constants/config.js.map +1 -0
  13. package/scripts/constants/language-articles.d.ts +84 -0
  14. package/scripts/constants/language-articles.d.ts.map +1 -0
  15. package/scripts/constants/language-articles.js +6771 -0
  16. package/scripts/constants/language-articles.js.map +1 -0
  17. package/scripts/constants/language-core.d.ts +38 -0
  18. package/scripts/constants/language-core.d.ts.map +1 -0
  19. package/scripts/constants/language-core.js +90 -0
  20. package/scripts/constants/language-core.js.map +1 -0
  21. package/scripts/constants/language-ui.d.ts +82 -0
  22. package/scripts/constants/language-ui.d.ts.map +1 -0
  23. package/scripts/constants/language-ui.js +889 -0
  24. package/scripts/constants/language-ui.js.map +1 -0
  25. package/scripts/constants/languages.d.ts +14 -0
  26. package/scripts/constants/languages.d.ts.map +1 -0
  27. package/scripts/constants/languages.js +15 -0
  28. package/scripts/constants/languages.js.map +1 -0
  29. package/scripts/generators/analysis-builders.d.ts +266 -0
  30. package/scripts/generators/analysis-builders.d.ts.map +1 -0
  31. package/scripts/generators/analysis-builders.js +2903 -0
  32. package/scripts/generators/analysis-builders.js.map +1 -0
  33. package/scripts/generators/breaking-content.d.ts +45 -0
  34. package/scripts/generators/breaking-content.d.ts.map +1 -0
  35. package/scripts/generators/breaking-content.js +530 -0
  36. package/scripts/generators/breaking-content.js.map +1 -0
  37. package/scripts/generators/committee-helpers.d.ts +54 -0
  38. package/scripts/generators/committee-helpers.d.ts.map +1 -0
  39. package/scripts/generators/committee-helpers.js +154 -0
  40. package/scripts/generators/committee-helpers.js.map +1 -0
  41. package/scripts/generators/dashboard-content.d.ts +95 -0
  42. package/scripts/generators/dashboard-content.d.ts.map +1 -0
  43. package/scripts/generators/dashboard-content.js +630 -0
  44. package/scripts/generators/dashboard-content.js.map +1 -0
  45. package/scripts/generators/deep-analysis-content.d.ts +23 -0
  46. package/scripts/generators/deep-analysis-content.d.ts.map +1 -0
  47. package/scripts/generators/deep-analysis-content.js +831 -0
  48. package/scripts/generators/deep-analysis-content.js.map +1 -0
  49. package/scripts/generators/mindmap-content.d.ts +55 -0
  50. package/scripts/generators/mindmap-content.d.ts.map +1 -0
  51. package/scripts/generators/mindmap-content.js +512 -0
  52. package/scripts/generators/mindmap-content.js.map +1 -0
  53. package/scripts/generators/motions-content.d.ts +50 -0
  54. package/scripts/generators/motions-content.d.ts.map +1 -0
  55. package/scripts/generators/motions-content.js +391 -0
  56. package/scripts/generators/motions-content.js.map +1 -0
  57. package/scripts/generators/news-enhanced.d.ts +14 -0
  58. package/scripts/generators/news-enhanced.d.ts.map +1 -0
  59. package/scripts/generators/news-enhanced.js +169 -0
  60. package/scripts/generators/news-enhanced.js.map +1 -0
  61. package/scripts/generators/news-indexes.d.ts +31 -0
  62. package/scripts/generators/news-indexes.d.ts.map +1 -0
  63. package/scripts/generators/news-indexes.js +410 -0
  64. package/scripts/generators/news-indexes.js.map +1 -0
  65. package/scripts/generators/pipeline/fetch-stage.d.ts +352 -0
  66. package/scripts/generators/pipeline/fetch-stage.d.ts.map +1 -0
  67. package/scripts/generators/pipeline/fetch-stage.js +1522 -0
  68. package/scripts/generators/pipeline/fetch-stage.js.map +1 -0
  69. package/scripts/generators/pipeline/generate-stage.d.ts +43 -0
  70. package/scripts/generators/pipeline/generate-stage.d.ts.map +1 -0
  71. package/scripts/generators/pipeline/generate-stage.js +204 -0
  72. package/scripts/generators/pipeline/generate-stage.js.map +1 -0
  73. package/scripts/generators/pipeline/output-stage.d.ts +48 -0
  74. package/scripts/generators/pipeline/output-stage.d.ts.map +1 -0
  75. package/scripts/generators/pipeline/output-stage.js +145 -0
  76. package/scripts/generators/pipeline/output-stage.js.map +1 -0
  77. package/scripts/generators/pipeline/transform-stage.d.ts +57 -0
  78. package/scripts/generators/pipeline/transform-stage.d.ts.map +1 -0
  79. package/scripts/generators/pipeline/transform-stage.js +111 -0
  80. package/scripts/generators/pipeline/transform-stage.js.map +1 -0
  81. package/scripts/generators/propositions-content.d.ts +29 -0
  82. package/scripts/generators/propositions-content.d.ts.map +1 -0
  83. package/scripts/generators/propositions-content.js +90 -0
  84. package/scripts/generators/propositions-content.js.map +1 -0
  85. package/scripts/generators/sankey-content.d.ts +45 -0
  86. package/scripts/generators/sankey-content.d.ts.map +1 -0
  87. package/scripts/generators/sankey-content.js +227 -0
  88. package/scripts/generators/sankey-content.js.map +1 -0
  89. package/scripts/generators/sitemap.d.ts +66 -0
  90. package/scripts/generators/sitemap.d.ts.map +1 -0
  91. package/scripts/generators/sitemap.js +562 -0
  92. package/scripts/generators/sitemap.js.map +1 -0
  93. package/scripts/generators/strategies/article-strategy.d.ts +146 -0
  94. package/scripts/generators/strategies/article-strategy.d.ts.map +1 -0
  95. package/scripts/generators/strategies/article-strategy.js +4 -0
  96. package/scripts/generators/strategies/article-strategy.js.map +1 -0
  97. package/scripts/generators/strategies/breaking-news-strategy.d.ts +64 -0
  98. package/scripts/generators/strategies/breaking-news-strategy.d.ts.map +1 -0
  99. package/scripts/generators/strategies/breaking-news-strategy.js +246 -0
  100. package/scripts/generators/strategies/breaking-news-strategy.js.map +1 -0
  101. package/scripts/generators/strategies/committee-reports-strategy.d.ts +93 -0
  102. package/scripts/generators/strategies/committee-reports-strategy.d.ts.map +1 -0
  103. package/scripts/generators/strategies/committee-reports-strategy.js +447 -0
  104. package/scripts/generators/strategies/committee-reports-strategy.js.map +1 -0
  105. package/scripts/generators/strategies/month-ahead-strategy.d.ts +60 -0
  106. package/scripts/generators/strategies/month-ahead-strategy.d.ts.map +1 -0
  107. package/scripts/generators/strategies/month-ahead-strategy.js +175 -0
  108. package/scripts/generators/strategies/month-ahead-strategy.js.map +1 -0
  109. package/scripts/generators/strategies/monthly-review-strategy.d.ts +66 -0
  110. package/scripts/generators/strategies/monthly-review-strategy.d.ts.map +1 -0
  111. package/scripts/generators/strategies/monthly-review-strategy.js +204 -0
  112. package/scripts/generators/strategies/monthly-review-strategy.js.map +1 -0
  113. package/scripts/generators/strategies/motions-strategy.d.ts +61 -0
  114. package/scripts/generators/strategies/motions-strategy.d.ts.map +1 -0
  115. package/scripts/generators/strategies/motions-strategy.js +215 -0
  116. package/scripts/generators/strategies/motions-strategy.js.map +1 -0
  117. package/scripts/generators/strategies/propositions-strategy.d.ts +60 -0
  118. package/scripts/generators/strategies/propositions-strategy.d.ts.map +1 -0
  119. package/scripts/generators/strategies/propositions-strategy.js +257 -0
  120. package/scripts/generators/strategies/propositions-strategy.js.map +1 -0
  121. package/scripts/generators/strategies/week-ahead-strategy.d.ts +57 -0
  122. package/scripts/generators/strategies/week-ahead-strategy.d.ts.map +1 -0
  123. package/scripts/generators/strategies/week-ahead-strategy.js +178 -0
  124. package/scripts/generators/strategies/week-ahead-strategy.js.map +1 -0
  125. package/scripts/generators/strategies/weekly-review-strategy.d.ts +63 -0
  126. package/scripts/generators/strategies/weekly-review-strategy.d.ts.map +1 -0
  127. package/scripts/generators/strategies/weekly-review-strategy.js +211 -0
  128. package/scripts/generators/strategies/weekly-review-strategy.js.map +1 -0
  129. package/scripts/generators/swot-content.d.ts +42 -0
  130. package/scripts/generators/swot-content.d.ts.map +1 -0
  131. package/scripts/generators/swot-content.js +366 -0
  132. package/scripts/generators/swot-content.js.map +1 -0
  133. package/scripts/generators/week-ahead-content.d.ts +103 -0
  134. package/scripts/generators/week-ahead-content.d.ts.map +1 -0
  135. package/scripts/generators/week-ahead-content.js +610 -0
  136. package/scripts/generators/week-ahead-content.js.map +1 -0
  137. package/scripts/index.d.ts +40 -0
  138. package/scripts/index.d.ts.map +1 -0
  139. package/scripts/index.js +53 -0
  140. package/scripts/index.js.map +1 -0
  141. package/scripts/mcp/ep-mcp-client.d.ts +471 -0
  142. package/scripts/mcp/ep-mcp-client.d.ts.map +1 -0
  143. package/scripts/mcp/ep-mcp-client.js +734 -0
  144. package/scripts/mcp/ep-mcp-client.js.map +1 -0
  145. package/scripts/mcp/mcp-connection.d.ts +264 -0
  146. package/scripts/mcp/mcp-connection.d.ts.map +1 -0
  147. package/scripts/mcp/mcp-connection.js +790 -0
  148. package/scripts/mcp/mcp-connection.js.map +1 -0
  149. package/scripts/mcp/mcp-health.d.ts +75 -0
  150. package/scripts/mcp/mcp-health.d.ts.map +1 -0
  151. package/scripts/mcp/mcp-health.js +78 -0
  152. package/scripts/mcp/mcp-health.js.map +1 -0
  153. package/scripts/mcp/mcp-retry.d.ts +94 -0
  154. package/scripts/mcp/mcp-retry.d.ts.map +1 -0
  155. package/scripts/mcp/mcp-retry.js +127 -0
  156. package/scripts/mcp/mcp-retry.js.map +1 -0
  157. package/scripts/mcp/wb-mcp-client.d.ts +38 -0
  158. package/scripts/mcp/wb-mcp-client.d.ts.map +1 -0
  159. package/scripts/mcp/wb-mcp-client.js +112 -0
  160. package/scripts/mcp/wb-mcp-client.js.map +1 -0
  161. package/scripts/templates/article-template.d.ts +9 -0
  162. package/scripts/templates/article-template.d.ts.map +1 -0
  163. package/scripts/templates/article-template.js +378 -0
  164. package/scripts/templates/article-template.js.map +1 -0
  165. package/scripts/templates/section-builders.d.ts +28 -0
  166. package/scripts/templates/section-builders.d.ts.map +1 -0
  167. package/scripts/templates/section-builders.js +142 -0
  168. package/scripts/templates/section-builders.js.map +1 -0
  169. package/scripts/types/analysis.d.ts +115 -0
  170. package/scripts/types/analysis.d.ts.map +1 -0
  171. package/scripts/types/analysis.js +4 -0
  172. package/scripts/types/analysis.js.map +1 -0
  173. package/scripts/types/common.d.ts +584 -0
  174. package/scripts/types/common.d.ts.map +1 -0
  175. package/scripts/types/common.js +96 -0
  176. package/scripts/types/common.js.map +1 -0
  177. package/scripts/types/generation.d.ts +104 -0
  178. package/scripts/types/generation.d.ts.map +1 -0
  179. package/scripts/types/generation.js +4 -0
  180. package/scripts/types/generation.js.map +1 -0
  181. package/scripts/types/index.d.ts +24 -0
  182. package/scripts/types/index.d.ts.map +1 -0
  183. package/scripts/types/index.js +16 -0
  184. package/scripts/types/index.js.map +1 -0
  185. package/scripts/types/intelligence.d.ts +129 -0
  186. package/scripts/types/intelligence.d.ts.map +1 -0
  187. package/scripts/types/intelligence.js +4 -0
  188. package/scripts/types/intelligence.js.map +1 -0
  189. package/scripts/types/mcp.d.ts +418 -0
  190. package/scripts/types/mcp.d.ts.map +1 -0
  191. package/scripts/types/mcp.js +4 -0
  192. package/scripts/types/mcp.js.map +1 -0
  193. package/scripts/types/parliament.d.ts +388 -0
  194. package/scripts/types/parliament.d.ts.map +1 -0
  195. package/scripts/types/parliament.js +4 -0
  196. package/scripts/types/parliament.js.map +1 -0
  197. package/scripts/types/quality.d.ts +114 -0
  198. package/scripts/types/quality.d.ts.map +1 -0
  199. package/scripts/types/quality.js +4 -0
  200. package/scripts/types/quality.js.map +1 -0
  201. package/scripts/types/stakeholder.d.ts +88 -0
  202. package/scripts/types/stakeholder.d.ts.map +1 -0
  203. package/scripts/types/stakeholder.js +16 -0
  204. package/scripts/types/stakeholder.js.map +1 -0
  205. package/scripts/types/visualization.d.ts +708 -0
  206. package/scripts/types/visualization.d.ts.map +1 -0
  207. package/scripts/types/visualization.js +4 -0
  208. package/scripts/types/visualization.js.map +1 -0
  209. package/scripts/types/world-bank.d.ts +85 -0
  210. package/scripts/types/world-bank.d.ts.map +1 -0
  211. package/scripts/types/world-bank.js +4 -0
  212. package/scripts/types/world-bank.js.map +1 -0
  213. package/scripts/utils/article-category.d.ts +18 -0
  214. package/scripts/utils/article-category.d.ts.map +1 -0
  215. package/scripts/utils/article-category.js +49 -0
  216. package/scripts/utils/article-category.js.map +1 -0
  217. package/scripts/utils/article-quality-scorer.d.ts +87 -0
  218. package/scripts/utils/article-quality-scorer.d.ts.map +1 -0
  219. package/scripts/utils/article-quality-scorer.js +1048 -0
  220. package/scripts/utils/article-quality-scorer.js.map +1 -0
  221. package/scripts/utils/content-metadata.d.ts +34 -0
  222. package/scripts/utils/content-metadata.d.ts.map +1 -0
  223. package/scripts/utils/content-metadata.js +249 -0
  224. package/scripts/utils/content-metadata.js.map +1 -0
  225. package/scripts/utils/content-validator.d.ts +94 -0
  226. package/scripts/utils/content-validator.d.ts.map +1 -0
  227. package/scripts/utils/content-validator.js +489 -0
  228. package/scripts/utils/content-validator.js.map +1 -0
  229. package/scripts/utils/copy-test-reports.d.ts +9 -0
  230. package/scripts/utils/copy-test-reports.d.ts.map +1 -0
  231. package/scripts/utils/copy-test-reports.js +508 -0
  232. package/scripts/utils/copy-test-reports.js.map +1 -0
  233. package/scripts/utils/file-utils.d.ts +144 -0
  234. package/scripts/utils/file-utils.d.ts.map +1 -0
  235. package/scripts/utils/file-utils.js +374 -0
  236. package/scripts/utils/file-utils.js.map +1 -0
  237. package/scripts/utils/fix-articles.d.ts +27 -0
  238. package/scripts/utils/fix-articles.d.ts.map +1 -0
  239. package/scripts/utils/fix-articles.js +510 -0
  240. package/scripts/utils/fix-articles.js.map +1 -0
  241. package/scripts/utils/generate-docs-index.d.ts +8 -0
  242. package/scripts/utils/generate-docs-index.d.ts.map +1 -0
  243. package/scripts/utils/generate-docs-index.js +275 -0
  244. package/scripts/utils/generate-docs-index.js.map +1 -0
  245. package/scripts/utils/html-sanitize.d.ts +18 -0
  246. package/scripts/utils/html-sanitize.d.ts.map +1 -0
  247. package/scripts/utils/html-sanitize.js +57 -0
  248. package/scripts/utils/html-sanitize.js.map +1 -0
  249. package/scripts/utils/intelligence-analysis.d.ts +173 -0
  250. package/scripts/utils/intelligence-analysis.d.ts.map +1 -0
  251. package/scripts/utils/intelligence-analysis.js +936 -0
  252. package/scripts/utils/intelligence-analysis.js.map +1 -0
  253. package/scripts/utils/intelligence-index.d.ts +126 -0
  254. package/scripts/utils/intelligence-index.d.ts.map +1 -0
  255. package/scripts/utils/intelligence-index.js +731 -0
  256. package/scripts/utils/intelligence-index.js.map +1 -0
  257. package/scripts/utils/metadata-utils.d.ts +14 -0
  258. package/scripts/utils/metadata-utils.d.ts.map +1 -0
  259. package/scripts/utils/metadata-utils.js +18 -0
  260. package/scripts/utils/metadata-utils.js.map +1 -0
  261. package/scripts/utils/news-metadata.d.ts +47 -0
  262. package/scripts/utils/news-metadata.d.ts.map +1 -0
  263. package/scripts/utils/news-metadata.js +259 -0
  264. package/scripts/utils/news-metadata.js.map +1 -0
  265. package/scripts/utils/validate-articles.d.ts +2 -0
  266. package/scripts/utils/validate-articles.d.ts.map +1 -0
  267. package/scripts/utils/validate-articles.js +284 -0
  268. package/scripts/utils/validate-articles.js.map +1 -0
  269. package/scripts/utils/validate-ep-api.d.ts +51 -0
  270. package/scripts/utils/validate-ep-api.d.ts.map +1 -0
  271. package/scripts/utils/validate-ep-api.js +160 -0
  272. package/scripts/utils/validate-ep-api.js.map +1 -0
  273. package/scripts/utils/world-bank-data.d.ts +84 -0
  274. package/scripts/utils/world-bank-data.d.ts.map +1 -0
  275. package/scripts/utils/world-bank-data.js +311 -0
  276. package/scripts/utils/world-bank-data.js.map +1 -0
@@ -0,0 +1,374 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Hack23 AB
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * @module Utils/FileUtils
5
+ * @description Shared file system utilities for news article operations
6
+ */
7
+ import { randomUUID } from 'crypto';
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import { NEWS_DIR, ARTICLE_FILENAME_PATTERN } from '../constants/config.js';
11
+ import { ALL_LANGUAGES } from '../constants/language-core.js';
12
+ /**
13
+ * Get all news article HTML files from the news directory
14
+ *
15
+ * @param newsDir - News directory path (defaults to NEWS_DIR)
16
+ * @returns List of article filenames
17
+ */
18
+ export function getNewsArticles(newsDir = NEWS_DIR) {
19
+ if (!fs.existsSync(newsDir)) {
20
+ console.log('📁 News directory does not exist yet');
21
+ return [];
22
+ }
23
+ const files = fs.readdirSync(newsDir);
24
+ return files.filter((f) => f.endsWith('.html') && !f.startsWith('index-'));
25
+ }
26
+ /**
27
+ * Parse article filename to extract metadata
28
+ *
29
+ * @param filename - Article filename (e.g., "2025-01-15-week-ahead-en.html")
30
+ * @returns Parsed metadata or null if filename doesn't match pattern
31
+ */
32
+ export function parseArticleFilename(filename) {
33
+ const match = filename.match(ARTICLE_FILENAME_PATTERN);
34
+ if (!match) {
35
+ return null;
36
+ }
37
+ const langCandidate = match[3];
38
+ if (!ALL_LANGUAGES.includes(langCandidate)) {
39
+ return null;
40
+ }
41
+ return {
42
+ date: match[1],
43
+ slug: match[2],
44
+ lang: langCandidate,
45
+ filename,
46
+ };
47
+ }
48
+ /**
49
+ * Group articles by language code
50
+ *
51
+ * @param articles - List of article filenames
52
+ * @param languages - Supported language codes
53
+ * @returns Articles grouped by language, sorted newest first
54
+ */
55
+ export function groupArticlesByLanguage(articles, languages) {
56
+ const grouped = {};
57
+ for (const lang of languages) {
58
+ grouped[lang] = [];
59
+ }
60
+ for (const article of articles) {
61
+ const parsed = parseArticleFilename(article);
62
+ if (parsed && grouped[parsed.lang] !== undefined) {
63
+ grouped[parsed.lang].push(parsed);
64
+ }
65
+ }
66
+ // Sort by date (newest first)
67
+ for (const lang in grouped) {
68
+ grouped[lang].sort((a, b) => b.date.localeCompare(a.date));
69
+ }
70
+ return grouped;
71
+ }
72
+ /**
73
+ * Format slug for display (hyphen-separated to Title Case)
74
+ *
75
+ * @param slug - Hyphen-separated slug string
76
+ * @returns Formatted title string
77
+ */
78
+ export function formatSlug(slug) {
79
+ return slug
80
+ .split('-')
81
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
82
+ .join(' ');
83
+ }
84
+ /**
85
+ * Get file modification time as YYYY-MM-DD string
86
+ *
87
+ * @param filepath - Path to file
88
+ * @returns Last modified date in YYYY-MM-DD format
89
+ */
90
+ export function getModifiedDate(filepath) {
91
+ const stats = fs.statSync(filepath);
92
+ // split('T') on an ISO string always produces at least one element
93
+ return stats.mtime.toISOString().split('T')[0];
94
+ }
95
+ /**
96
+ * Format date for article slug
97
+ *
98
+ * @param date - Date to format (defaults to now)
99
+ * @returns Formatted date string (YYYY-MM-DD)
100
+ */
101
+ export function formatDateForSlug(date = new Date()) {
102
+ // split('T') on an ISO string always produces at least one element
103
+ return date.toISOString().split('T')[0];
104
+ }
105
+ /**
106
+ * Calculate read time estimate from content
107
+ *
108
+ * @param content - Article content text
109
+ * @param wordsPerMinute - Reading speed (default 250)
110
+ * @returns Estimated read time in minutes
111
+ */
112
+ export function calculateReadTime(content, wordsPerMinute = 250) {
113
+ const words = content.split(/\s+/).length;
114
+ return Math.ceil(words / wordsPerMinute);
115
+ }
116
+ /**
117
+ * Ensure a directory exists, creating it recursively if needed
118
+ *
119
+ * @param dirPath - Directory path to ensure
120
+ */
121
+ export function ensureDirectoryExists(dirPath) {
122
+ if (!fs.existsSync(dirPath)) {
123
+ fs.mkdirSync(dirPath, { recursive: true });
124
+ }
125
+ }
126
+ /**
127
+ * Write content to a file with UTF-8 encoding
128
+ *
129
+ * @param filepath - Output file path
130
+ * @param content - File content
131
+ */
132
+ export function writeFileContent(filepath, content) {
133
+ const dir = path.dirname(filepath);
134
+ ensureDirectoryExists(dir);
135
+ fs.writeFileSync(filepath, content, 'utf-8');
136
+ }
137
+ /**
138
+ * Remove a file, ignoring ENOENT (file already deleted by another writer).
139
+ *
140
+ * @param filepath - Path to the file to remove
141
+ */
142
+ function unlinkIfExists(filepath) {
143
+ try {
144
+ fs.unlinkSync(filepath);
145
+ }
146
+ catch (err) {
147
+ const code = err instanceof Error ? err.code : '';
148
+ if (code !== 'ENOENT') {
149
+ throw err;
150
+ }
151
+ }
152
+ }
153
+ /**
154
+ * Attempt to rename `src` to `dest` with a bounded retry loop.
155
+ *
156
+ * On each attempt the existing destination is removed first, then
157
+ * `renameSync` is retried. `EEXIST`/`EPERM` failures from concurrent
158
+ * writers are tolerated for up to `maxRetries` attempts.
159
+ *
160
+ * @param src - Source (temp) file path
161
+ * @param dest - Final destination path
162
+ * @param maxRetries - Maximum number of unlink-then-rename attempts
163
+ */
164
+ function renameWithRetry(src, dest, maxRetries) {
165
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
166
+ unlinkIfExists(dest);
167
+ try {
168
+ fs.renameSync(src, dest);
169
+ return;
170
+ }
171
+ catch (retryErr) {
172
+ const retryCode = retryErr instanceof Error ? retryErr.code : '';
173
+ if ((retryCode === 'EEXIST' || retryCode === 'EPERM') && attempt < maxRetries - 1) {
174
+ continue;
175
+ }
176
+ throw retryErr;
177
+ }
178
+ }
179
+ }
180
+ /**
181
+ * Best-effort removal of a temporary file. Ignores ENOENT (the file was
182
+ * already renamed or never created) but logs a warning for other errors
183
+ * (e.g. EBUSY, EACCES) so operators can detect leaked temp files.
184
+ *
185
+ * @param tempPath - Path to the temp file to remove
186
+ */
187
+ function cleanupTempFile(tempPath) {
188
+ try {
189
+ fs.unlinkSync(tempPath);
190
+ }
191
+ catch (unlinkErr) {
192
+ const errno = unlinkErr && typeof unlinkErr === 'object' ? unlinkErr : undefined;
193
+ if (errno?.code !== 'ENOENT') {
194
+ const message = errno && typeof errno.message === 'string' ? errno.message : String(unlinkErr);
195
+ const code = errno?.code ?? 'UNKNOWN';
196
+ console.warn(`atomicWrite: failed to remove temporary file "${tempPath}" (code: ${code}): ${message}`);
197
+ }
198
+ }
199
+ }
200
+ /**
201
+ * Write content to a file atomically.
202
+ *
203
+ * Writes to a uniquely-named temporary file in the same directory first, then
204
+ * renames it to the final path. The temp filename includes the PID and a random
205
+ * UUID so that concurrent callers targeting the same destination never collide
206
+ * on the intermediate file. If the rename fails the temp file is cleaned up in
207
+ * a `finally` block. On platforms where `renameSync` does not overwrite an
208
+ * existing destination (e.g. Windows), the error is caught and the target is
209
+ * removed before retrying the rename.
210
+ *
211
+ * @param filepath - Final output file path
212
+ * @param content - File content to write
213
+ */
214
+ export function atomicWrite(filepath, content) {
215
+ const dir = path.dirname(filepath);
216
+ ensureDirectoryExists(dir);
217
+ const uniqueSuffix = `${process.pid}-${randomUUID()}`;
218
+ const tempPath = `${filepath}.${uniqueSuffix}.tmp`;
219
+ try {
220
+ fs.writeFileSync(tempPath, content, 'utf-8');
221
+ try {
222
+ fs.renameSync(tempPath, filepath);
223
+ }
224
+ catch (err) {
225
+ const code = err instanceof Error ? err.code : '';
226
+ if (code === 'EEXIST' || code === 'EPERM') {
227
+ renameWithRetry(tempPath, filepath, 3);
228
+ }
229
+ else {
230
+ throw err;
231
+ }
232
+ }
233
+ }
234
+ finally {
235
+ cleanupTempFile(tempPath);
236
+ }
237
+ }
238
+ /**
239
+ * Check whether a news article file already exists on disk.
240
+ *
241
+ * This is used by generation pipelines to skip work when a prior workflow run
242
+ * (or the same run) has already produced the article, avoiding unnecessary
243
+ * regeneration and potential merge conflicts.
244
+ *
245
+ * @param slug - Article slug including date prefix (e.g. `"2025-01-15-week-ahead"`)
246
+ * @param lang - Language code (e.g. `"en"`)
247
+ * @param newsDir - Absolute path to the news output directory (defaults to NEWS_DIR)
248
+ * @returns `true` when the article file exists
249
+ */
250
+ export function checkArticleExists(slug, lang, newsDir = NEWS_DIR) {
251
+ const filename = `${slug}-${lang}.html`;
252
+ return fs.existsSync(path.join(newsDir, filename));
253
+ }
254
+ /**
255
+ * Decode the 5 HTML entities produced by escapeHTML() back to plain text.
256
+ * Used when extracting text from our own generated HTML to obtain unescaped values.
257
+ *
258
+ * IMPORTANT: `&amp;` MUST be decoded last. Decoding it first would convert
259
+ * `&amp;lt;` to `&lt;` before the `&lt;` → `<` replacement runs, causing
260
+ * double-decoding. The correct order is: decode all specific entities first,
261
+ * then decode `&amp;` as the final step.
262
+ *
263
+ * @param str - HTML string with entities
264
+ * @returns Plain text with entities decoded
265
+ */
266
+ function decodeHtmlEntities(str) {
267
+ return str
268
+ .replace(/&quot;/g, '"')
269
+ .replace(/&#39;/g, "'")
270
+ .replace(/&lt;/g, '<')
271
+ .replace(/&gt;/g, '>')
272
+ .replace(/&amp;/g, '&');
273
+ }
274
+ /**
275
+ * Extract title and description from a generated article HTML file.
276
+ * Reads the predictable template structure produced by article-template.ts.
277
+ * Falls back to empty strings when the file cannot be read.
278
+ * HTML entities from the template are decoded to produce plain text.
279
+ *
280
+ * NOTE: The meta description regex relies on the template's use of escapeHTML(),
281
+ * which converts `"` to `&quot;`. Because descriptions are always stored with
282
+ * double-quote delimiters and inner quotes are HTML-encoded, the `[^"]+` pattern
283
+ * safely captures the full value. If the template ever changes its quoting
284
+ * convention this regex must be updated accordingly.
285
+ *
286
+ * @param filepath - Path to the article HTML file
287
+ * @returns Object with title (from first h1) and description (from meta description)
288
+ */
289
+ export function extractArticleMeta(filepath) {
290
+ let title = '';
291
+ let description = '';
292
+ try {
293
+ const content = fs.readFileSync(filepath, 'utf-8');
294
+ // Matches h1 with any attributes but only plain-text content (no nested tags).
295
+ // The template always writes plain escaped text in h1, so this is correct.
296
+ const titleMatch = content.match(/<h1[^>]*>([^<]+)<\/h1>/u);
297
+ if (titleMatch?.[1]) {
298
+ title = decodeHtmlEntities(titleMatch[1].trim());
299
+ }
300
+ const descMatch = content.match(/<meta name="description" content="([^"]+)"/u);
301
+ if (descMatch?.[1]) {
302
+ description = decodeHtmlEntities(descMatch[1]);
303
+ }
304
+ }
305
+ catch {
306
+ // File not readable – return empty strings
307
+ }
308
+ return { title, description };
309
+ }
310
+ /**
311
+ * Escape special HTML characters to prevent XSS
312
+ *
313
+ * @param str - Raw string to escape
314
+ * @returns HTML-safe string
315
+ */
316
+ export function escapeHTML(str) {
317
+ return str
318
+ .replace(/&/g, '&amp;')
319
+ .replace(/</g, '&lt;')
320
+ .replace(/>/g, '&gt;')
321
+ .replace(/"/g, '&quot;')
322
+ .replace(/'/g, '&#39;');
323
+ }
324
+ /**
325
+ * Validate that a URL uses a safe scheme (http or https)
326
+ *
327
+ * @param url - URL string to validate
328
+ * @returns true if URL has a safe scheme
329
+ */
330
+ export function isSafeURL(url) {
331
+ try {
332
+ const parsed = new URL(url);
333
+ return parsed.protocol === 'http:' || parsed.protocol === 'https:';
334
+ }
335
+ catch {
336
+ return false;
337
+ }
338
+ }
339
+ /** Required structural elements that every article must contain */
340
+ const REQUIRED_ARTICLE_ELEMENTS = [
341
+ {
342
+ selector: ['class="site-header__langs"', 'class="language-switcher"'],
343
+ label: 'language switcher nav',
344
+ },
345
+ { selector: 'class="article-top-nav"', label: 'article-top-nav (back button)' },
346
+ { selector: 'class="site-header"', label: 'site-header' },
347
+ { selector: 'class="skip-link"', label: 'skip-link' },
348
+ { selector: 'class="reading-progress"', label: 'reading-progress bar' },
349
+ { selector: '<main id="main"', label: 'main content wrapper' },
350
+ { selector: 'class="site-footer"', label: 'site-footer' },
351
+ ];
352
+ /**
353
+ * Validate that generated article HTML includes all required structural elements.
354
+ *
355
+ * This is the primary validation gate — articles must be generated correctly
356
+ * by the template. The fix-articles script is only a fallback for legacy articles.
357
+ *
358
+ * @param html - Complete HTML string of the article
359
+ * @returns Validation result with errors list (empty if valid)
360
+ */
361
+ export function validateArticleHTML(html) {
362
+ const errors = [];
363
+ for (const element of REQUIRED_ARTICLE_ELEMENTS) {
364
+ const sel = element.selector;
365
+ const found = Array.isArray(sel)
366
+ ? sel.some((s) => html.includes(s))
367
+ : html.includes(sel);
368
+ if (!found) {
369
+ errors.push(`Missing required element: ${element.label}`);
370
+ }
371
+ }
372
+ return { valid: errors.length === 0, errors };
373
+ }
374
+ //# sourceMappingURL=file-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,sCAAsC;AAEtC;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ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AM,OAAO,IAAI,yBAAyB,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAC9B,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAa,CAAC,CAAC;QACjC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,6BAA6B,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Fix a single article file by injecting missing structural elements.
3
+ *
4
+ * @param filepath - Absolute path to article HTML file
5
+ * @param dryRun - If true, only report what would change
6
+ * @returns Object with changed flag and description
7
+ */
8
+ export declare function fixArticle(filepath: string, dryRun?: boolean): {
9
+ changed: boolean;
10
+ description: string;
11
+ };
12
+ /**
13
+ * Fix all articles in the news directory.
14
+ *
15
+ * @param dryRun - If true, only report what would change
16
+ * @returns Summary of changes
17
+ */
18
+ export declare function fixAllArticles(dryRun?: boolean): {
19
+ total: number;
20
+ fixed: number;
21
+ skipped: number;
22
+ results: Array<{
23
+ changed: boolean;
24
+ description: string;
25
+ }>;
26
+ };
27
+ //# sourceMappingURL=fix-articles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix-articles.d.ts","sourceRoot":"","sources":["../../src/utils/fix-articles.ts"],"names":[],"mappings":"AA4fA;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,OAAe,GACtB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAoE3C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,OAAe,GAAG;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D,CAcA"}