All files / types common.ts

100% Statements 31/31
100% Branches 8/8
100% Functions 4/4
100% Lines 31/31

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                                                                          16x   16x 16x 16x     16x 16x 16x     16x     16x 16x 16x     16x             16x   16x   16x   16x   16x           16x 16x 16x 16x               16x   16x   16x   16x   16x   16x   16x   16x       16x                             16x                                                                                                                                                                                                      
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Types/Common
 * @description Core shared types — language codes, article enums, and category mappings.
 * These foundational types are used across all bounded contexts.
 */
 
/** Supported language codes */
export type LanguageCode =
  | 'en'
  | 'sv'
  | 'da'
  | 'no'
  | 'fi'
  | 'de'
  | 'fr'
  | 'es'
  | 'nl'
  | 'ar'
  | 'he'
  | 'ja'
  | 'ko'
  | 'zh';
 
/** RTL language codes */
export type RTLLanguageCode = 'ar' | 'he';
 
/** All possible language codes (including RTL) */
export type AnyLanguageCode = LanguageCode;
 
/**
 * Article category — the primary classifier for content generation.
 * Each value represents a distinct article type with its own data pipeline,
 * template structure, and editorial voice.
 */
export enum ArticleCategory {
  // Prospective — looking ahead
  WEEK_AHEAD = 'week-ahead',
  MONTH_AHEAD = 'month-ahead',
  YEAR_AHEAD = 'year-ahead',
 
  // Retrospective — looking back
  WEEK_IN_REVIEW = 'week-in-review',
  MONTH_IN_REVIEW = 'month-in-review',
  YEAR_IN_REVIEW = 'year-in-review',
 
  // Real-time
  BREAKING_NEWS = 'breaking',
 
  // Domain-specific
  COMMITTEE_REPORTS = 'committee-reports',
  MOTIONS = 'motions',
  PROPOSITIONS = 'propositions',
 
  // Analytical
  DEEP_ANALYSIS = 'deep-analysis',
}
 
/**
 * Temporal perspective of an article — derived from its category.
 * Determines the editorial framing and verb tense.
 */
export enum ArticlePerspective {
  /** Forward-looking: previews, agendas, upcoming events */
  PROSPECTIVE = 'prospective',
  /** Backward-looking: reviews, summaries, retrospectives */
  RETROSPECTIVE = 'retrospective',
  /** Live/current: breaking news, urgent developments */
  REAL_TIME = 'real-time',
  /** Deep dive: multi-perspective analysis, root cause */
  ANALYTICAL = 'analytical',
}
 
/**
 * Time period scope for periodic articles (look-ahead or in-review).
 */
export enum TimePeriod {
  WEEK = 'week',
  MONTH = 'month',
  YEAR = 'year',
}
 
/**
 * Analysis perspective for "5 Whys" deep analysis articles.
 * Each perspective frames the same events through a different lens,
 * asking "why" iteratively to uncover root causes.
 */
export enum AnalysisPerspective {
  /** Party dynamics, power shifts, political strategy */
  POLITICAL = 'political',
  /** Budget impact, market effects, fiscal policy */
  ECONOMIC = 'economic',
  /** Citizen impact, public opinion, social equity */
  SOCIAL = 'social',
  /** Treaty basis, legal competence, compliance */
  LEGAL = 'legal',
  /** Climate, sustainability, green transition */
  ENVIRONMENTAL = 'environmental',
  /** EU external relations, global positioning */
  GEOPOLITICAL = 'geopolitical',
  /** EU institutional mechanics, inter-institutional balance */
  INSTITUTIONAL = 'institutional',
}
 
/** Mapping from ArticleCategory to its inherent ArticlePerspective */
export const CATEGORY_PERSPECTIVE: Record<ArticleCategory, ArticlePerspective> = {
  [ArticleCategory.WEEK_AHEAD]: ArticlePerspective.PROSPECTIVE,
  [ArticleCategory.MONTH_AHEAD]: ArticlePerspective.PROSPECTIVE,
  [ArticleCategory.YEAR_AHEAD]: ArticlePerspective.PROSPECTIVE,
  [ArticleCategory.WEEK_IN_REVIEW]: ArticlePerspective.RETROSPECTIVE,
  [ArticleCategory.MONTH_IN_REVIEW]: ArticlePerspective.RETROSPECTIVE,
  [ArticleCategory.YEAR_IN_REVIEW]: ArticlePerspective.RETROSPECTIVE,
  [ArticleCategory.BREAKING_NEWS]: ArticlePerspective.REAL_TIME,
  [ArticleCategory.COMMITTEE_REPORTS]: ArticlePerspective.RETROSPECTIVE,
  [ArticleCategory.MOTIONS]: ArticlePerspective.RETROSPECTIVE,
  [ArticleCategory.PROPOSITIONS]: ArticlePerspective.PROSPECTIVE,
  [ArticleCategory.DEEP_ANALYSIS]: ArticlePerspective.ANALYTICAL,
};
 
/** Mapping from periodic categories to their time period scope */
export const CATEGORY_TIME_PERIOD: Partial<Record<ArticleCategory, TimePeriod>> = {
  [ArticleCategory.WEEK_AHEAD]: TimePeriod.WEEK,
  [ArticleCategory.MONTH_AHEAD]: TimePeriod.MONTH,
  [ArticleCategory.YEAR_AHEAD]: TimePeriod.YEAR,
  [ArticleCategory.WEEK_IN_REVIEW]: TimePeriod.WEEK,
  [ArticleCategory.MONTH_IN_REVIEW]: TimePeriod.MONTH,
  [ArticleCategory.YEAR_IN_REVIEW]: TimePeriod.YEAR,
};
 
/** Language preset names */
export type LanguagePreset = 'all' | 'eu-core' | 'nordic';
 
/** Map from language code to translated string */
export type LanguageMap<T = string> = Record<LanguageCode, T>;
 
/** Article category labels for a single language — one entry per ArticleCategory */
export type ArticleCategoryLabels = Record<ArticleCategory, string>;
 
/** Language-specific title and subtitle */
export interface LangTitleSubtitle {
  title: string;
  subtitle: string;
}
 
/** Localized strings for propositions articles */
export interface PropositionsStrings {
  lede: string;
  proposalsHeading: string;
  pipelineHeading: string;
  procedureHeading: string;
  analysisHeading: string;
  analysis: string;
  pipelineHealthLabel: string;
  throughputRateLabel: string;
  whyThisMatters: string;
}
 
/** Localized editorial strings shared across article types */
export interface EditorialStrings {
  /** Heading for "Why This Matters" citizen-impact section */
  whyThisMatters: string;
  /** Heading for key analytical finding */
  keyTakeaway: string;
  /** Heading for parliamentary context section */
  parliamentaryContext: string;
  /** Source attribution phrase (e.g. "According to European Parliament records") */
  sourceAttribution: string;
  /** Analytical note label */
  analysisNote: string;
}
 
/** Localized section heading strings for motions articles */
export interface MotionsStrings {
  lede: string;
  votingRecordsHeading: string;
  partyCohesionHeading: string;
  anomaliesHeading: string;
  questionsHeading: string;
  dateLabel: string;
  resultLabel: string;
  forLabel: string;
  againstLabel: string;
  abstainLabel: string;
  cohesionLabel: string;
  participationLabel: string;
  severityLabel: string;
  statusLabel: string;
  keyTakeawayText: string;
  politicalAlignmentHeading: string;
}
 
/** Localized section heading strings for week-ahead articles */
export interface WeekAheadStrings {
  lede: string;
  plenarySessions: string;
  committeeMeetings: string;
  legislativeDocuments: string;
  legislativePipeline: string;
  parliamentaryQuestions: string;
  noPlenary: string;
  bottleneckIndicator: string;
  whatToWatch: string;
}
 
/** Localized section heading strings for breaking news articles */
export interface BreakingStrings {
  breakingBanner: string;
  votingAnomalyIntel: string;
  coalitionDynamics: string;
  analyticalReport: string;
  keyMEPInfluence: string;
  intelligenceBriefing: string;
  votingAnomalyAlert: string;
  coalitionDynamicsSection: string;
  keyPlayers: string;
  placeholderNotice: string;
  placeholderLede: string;
  lede: string;
}