Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | /**
* @module Types/Article
* @description Core article and content generation types.
*/
import type { Language } from './language.js';
/** Category label shown in article headers */
export type ArticleCategory = 'prospective' | 'retrospective' | 'analysis' | 'breaking';
/** Internal article type identifiers for content routing */
export type ArticleType =
| 'week-ahead'
| 'month-ahead'
| 'weekly-review'
| 'monthly-review'
| 'committee-reports'
| 'propositions'
| 'motions'
| 'interpellations'
| 'breaking'
| 'deep-inspection';
/** A single calendar event in the event grid */
export interface EventGridItem {
date: string;
dayName: string;
dayNumber: string;
dayLabel: string;
isToday: boolean;
items: Array<{ time: string; title: string }>;
}
/** A single watch point (key development to monitor) */
export interface WatchPoint {
title: string;
description: string;
}
/** SEO and taxonomy metadata for an article */
export interface ArticleMetadata {
keywords: string[];
topics: string[];
tags: string[];
}
// ---------------------------------------------------------------------------
// Extensible template sections
// ---------------------------------------------------------------------------
/**
* A pluggable HTML section inserted into the article body.
*
* New content types (risk indicators, trend charts, pull quotes, etc.) can be
* added without modifying the core template — just append a `TemplateSection`
* to the `sections` array in `ArticleData`.
*/
export interface TemplateSection {
/** Unique identifier used as the HTML element `id`. */
id: string;
/**
* Pre-rendered HTML string for this section.
* Must be safe to embed directly (callers are responsible for escaping).
*/
html: string;
/**
* Optional CSS class name(s) added to the wrapper `<div>`.
* Defaults to `'article-section'` when omitted.
*/
className?: string;
}
/** Full data payload passed to the article HTML template */
export interface ArticleData {
slug: string;
title: string;
subtitle: string;
date: string;
type: ArticleCategory;
/**
* Optional routing article type used for CSS theming and template registry
* lookup (e.g. `'week-ahead'`, `'motions'`, `'interpellations'`).
* When provided, `generateArticleHTML` will apply the matching
* `article-type-*` CSS class to the `<article>` element.
* When omitted, no per-type class is applied — the article keeps base
* `.news-article` styling. (`type: ArticleCategory` values like
* `'analysis'` are **not** valid `ArticleType` keys.)
*/
articleType?: ArticleType;
readTime?: string;
lang?: Language;
locale?: string;
content: string;
events?: EventGridItem[];
watchPoints?: WatchPoint[];
sources?: string[];
keywords?: string[];
topics?: string[];
tags?: string[];
/**
* Optional extensible sections appended after the main article content.
* Each entry is rendered as an isolated `<div>` block, allowing new content
* types to be injected without changing the template core.
*/
sections?: TemplateSection[];
}
/** A single generated article (language variant) */
export interface GeneratedArticle {
lang: Language;
html: string;
filename: string;
slug: string;
}
/** Date range used for week-ahead article fetching */
export interface DateRange {
start: string;
end: string;
}
/** Quality metrics for a single generated article */
export interface ArticleQualityScore {
/** Filename of the article (e.g. "2026-02-23-motions-en.html") */
filename: string;
/** Language code of the article */
lang: string;
/** Article type (e.g. "motions") */
articleType: string;
/** Approximate word count based on text content after stripping HTML tags */
wordCount: number;
/** Number of "Unknown (Unknown)" occurrences */
unknownAuthors: number;
/** Number of data-translate="true" spans (should be 0 for non-Swedish) */
untranslatedSpans: number;
/** Number of analytical <h2> sections found */
analyticalSections: number;
/** Final 0–100 quality score */
score: number;
/** Whether the article passed the quality threshold */
passed: boolean;
}
/** Aggregate statistics for a full news generation run */
export interface GenerationStats {
generated: number;
errors: number;
articles: string[];
timestamp: string;
/** Per-article quality scores collected during the run */
qualityScores: ArticleQualityScore[];
}
/** MCP tool call record for cross-reference validation */
export interface MCPCallRecord {
tool: string;
result?: unknown;
}
/** Result returned from a single article-type generation function */
export interface GenerationResult {
success: boolean;
files?: number;
slug?: string;
error?: string;
articles?: GeneratedArticle[];
mcpCalls?: MCPCallRecord[];
crossReferences?: Record<string, unknown>;
}
// ---------------------------------------------------------------------------
// Breaking news types
// ---------------------------------------------------------------------------
/** Event data passed into the breaking news generator */
export interface BreakingEventData {
voteId?: string;
topic?: string;
slug?: string;
[key: string]: unknown;
}
/** Options for breaking news article generation */
export interface BreakingNewsOptions {
languages?: Language[];
eventContext?: string;
eventData?: BreakingEventData | null;
writeArticle?: ((html: string, filename: string) => Promise<void | boolean>) | null;
}
/** Validation result for a breaking news article */
export interface BreakingNewsValidation {
hasBreakingEvent: boolean;
hasMinimumSources: boolean;
hasTimeliness: boolean;
hasImpactAnalysis: boolean;
passed: boolean;
}
// ---------------------------------------------------------------------------
// SWOT analysis types
// ---------------------------------------------------------------------------
/** Impact level for a SWOT entry */
export type SwotImpact = 'high' | 'medium' | 'low';
/** A single item in one of the four SWOT quadrants */
export interface SwotEntry {
/** Description text for this factor */
text: string;
/** Relative impact or significance */
impact?: SwotImpact;
}
/** Data for generating an embeddable SWOT analysis section */
export interface SwotData {
/** Internal factors: capabilities and advantages */
strengths: SwotEntry[];
/** Internal factors: limitations and gaps */
weaknesses: SwotEntry[];
/** External factors: favourable conditions */
opportunities: SwotEntry[];
/** External factors: risks and challenges */
threats: SwotEntry[];
/** Subject being analysed (party, policy, institution, …) */
subject?: string;
/** Additional contextual note rendered below the matrix */
context?: string;
}
// ---------------------------------------------------------------------------
// Dashboard / chart types for article embedding
// ---------------------------------------------------------------------------
/** Chart type supported by Chart.js */
export type DashboardChartType = 'bar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'scatter';
/** A point object for scatter charts */
export interface DashboardPoint {
x: number;
y: number;
}
/** A single dataset within a chart */
export interface DashboardDataset {
label: string;
/** Numeric values for bar/line/pie/etc., or {x,y} points for scatter */
data: number[] | DashboardPoint[];
backgroundColor?: string | string[];
borderColor?: string | string[];
borderWidth?: number;
}
/** Annotation overlay for a Chart.js chart */
export interface DashboardAnnotation {
type: 'line' | 'label';
/** Value on the scale where the annotation is placed (required) */
value: number;
label?: string;
borderColor?: string;
backgroundColor?: string;
}
/** Configuration for a single chart in the dashboard */
export interface DashboardChartConfig {
/** Unique id used as the canvas element id */
id: string;
/** Chart.js chart type */
type: DashboardChartType;
/** Chart title rendered above the canvas */
title: string;
/** Category labels (x-axis for bar/line), optional for scatter charts */
labels?: string[];
/** One or more data series */
datasets: DashboardDataset[];
/** Optional annotation overlays (chartjs-plugin-annotation) */
annotations?: DashboardAnnotation[];
}
/** A simple data table rendered alongside charts */
export interface DashboardTableConfig {
/** Optional caption/title for the table */
caption?: string;
headers: string[];
rows: string[][];
}
/** Data for generating an embeddable dashboard section */
export interface DashboardData {
/** Dashboard section title */
title: string;
/** One or more Chart.js chart configurations */
charts: DashboardChartConfig[];
/** Optional data tables */
tables?: DashboardTableConfig[];
/** Optional narrative summary displayed above the charts */
summary?: string;
}
// ---------------------------------------------------------------------------
// Multi-panel dashboard types
// ---------------------------------------------------------------------------
/** Layout variant for multi-panel dashboards */
export type DashboardPanelLayout = 'grid-2x2' | 'grid-3x2' | 'full-width' | 'sidebar';
/** A single cell in a heat-map grid */
export interface HeatMapCell {
/** Numeric intensity value (any scale; the renderer normalises to 0–1 using the dataset min/max) */
value: number;
/** Optional text label rendered inside the cell */
label?: string;
}
/** CSS-only heat-map configuration */
export interface HeatMapConfig {
/** Unique identifier used as the container element id */
id: string;
/** Chart title */
title: string;
/** Row labels (left axis) */
rowLabels: string[];
/** Column labels (top axis) */
columnLabels: string[];
/** Row-major matrix of cells (rows.length × columns.length) */
cells: HeatMapCell[][];
/** Label for the low-intensity end of the scale */
minLabel?: string;
/** Label for the high-intensity end of the scale */
maxLabel?: string;
}
/** CSS-only gauge/dial configuration */
export interface GaugeConfig {
/** Unique identifier used as the container element id */
id: string;
/** Chart title */
title: string;
/** Current value (0–100) */
value: number;
/** Optional descriptive label rendered below the value */
label?: string;
/** Label for the low end (default: "0") */
minLabel?: string;
/** Label for the high end (default: "100") */
maxLabel?: string;
}
/** A cross-panel AI-generated insight */
export interface AIInsight {
/** Unique identifier */
id: string;
/** Insight text */
text: string;
/** Relative importance (always required for consistent styling/filtering) */
relevance: 'high' | 'medium' | 'low';
}
/** A single panel within a multi-panel dashboard */
export interface DashboardPanel {
/** Unique panel identifier */
id: string;
/** Panel heading */
title: string;
/** Chart.js chart configuration (mutually exclusive with heatMap / gauge) */
chart?: DashboardChartConfig;
/** CSS-only heat map (mutually exclusive with chart / gauge) */
heatMap?: HeatMapConfig;
/** CSS-only gauge (mutually exclusive with chart / heatMap) */
gauge?: GaugeConfig;
/** AI-generated interpretation paragraph for this panel */
interpretation?: string;
/** Which stakeholder perspective this panel represents */
stakeholderView?: string;
/** Data confidence level (0–100) */
confidenceLevel?: number;
/** Optional accessible data table fallback */
table?: DashboardTableConfig;
}
/** Configuration for a multi-panel dashboard section */
export interface MultiPanelDashboard {
/** Dashboard section title */
title: string;
/** AI-generated executive summary displayed above all panels (omitted when absent) */
summary?: string;
/** Individual dashboard panels */
panels: DashboardPanel[];
/** Responsive grid layout variant (default: "grid-2x2") */
layout?: DashboardPanelLayout;
/** Cross-panel AI insights listed at the bottom */
aiInsights?: AIInsight[];
}
|