All files / scripts/statskontoret source-registry.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5

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                                  4x   4x                                                                       26x 9x 7x    
/**
 * @module scripts/statskontoret/source-registry
 * @description Frozen catalogue of Statskontoret open-data sources.
 *
 * Pure data — kept in its own module so test fixtures can swap or extend
 * the registry without dragging in the HTTP client.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { StatskontoretError } from './errors.js';
import type {
  StatskontoretSourceDefinition,
  StatskontoretSourceKey,
} from './types.js';
 
export const STATSKONTORET_BASE_URL = 'https://www.statskontoret.se';
 
export const STATSKONTORET_SOURCES: readonly StatskontoretSourceDefinition[] = Object.freeze([
  {
    key: 'myndighetsforteckning',
    title: 'Myndighetsförteckning – öppna data',
    url: '/analys-och-statistik/oppna-data/myndighetsforteckning/',
    cadence: 'Annual snapshot; Statskontoret page metadata currently indicates 2026-02-06 update for the 2025 workbook.',
    coverage: 'Summary statistics, 2007–2025 time series, latest authority list and full 2007–2025 authority register.',
    primaryUse: 'Government-body headcount, authority count, leadership form and department grouping over time.',
  },
  {
    key: 'budget-time-series',
    title: 'Tidsserier, statens budget m.m.',
    url: '/analys-och-statistik/officiell-statistik/tidsserier-statens-budget-m.m',
    cadence: 'Annual official statistics release.',
    coverage: 'Final outcomes for central-government revenue, expenditure, balance and related public-finance tables, generally from 1995.',
    primaryUse: 'Long-run fiscal context for committee and budget-cycle analysis.',
  },
  {
    key: 'arsutfall',
    title: 'Årsutfall för statens budget – öppna data',
    url: '/analys-och-statistik/oppna-data/arsutfall/',
    cadence: 'Annual, with preliminary and definitive releases.',
    coverage: 'Annual central-government revenue and expenditure outturns based on Hermes reporting and Riksdag/government budget decisions.',
    primaryUse: 'Yearly budget execution context by appropriation, income title and agency.',
  },
  {
    key: 'manadsutfall',
    title: 'Månadsutfall för statens budget – öppna data',
    url: '/analys-och-statistik/oppna-data/manadsutfall/',
    cadence: 'Monthly.',
    coverage: 'Monthly central-government revenue and expenditure outcomes from January 2006 onward at low-level agency/account granularity.',
    primaryUse: 'High-frequency budget execution context and agency-level fiscal monitoring.',
  },
]);
 
export function getStatskontoretSource(key: StatskontoretSourceKey): StatskontoretSourceDefinition {
  const source = STATSKONTORET_SOURCES.find((candidate) => candidate.key === key);
  if (!source) throw new StatskontoretError(`Unknown Statskontoret source: ${key}`);
  return source;
}