All files / src/aggregator/generator discovery.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 2/2
100% Lines 2/2

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                                                                        27x                               7x    
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Aggregator/Generator/Discovery
 * @description Discovery + collision-grouping for analysis runs. Thin
 * re-exports of the canonical implementations in
 * `aggregator/runs/index.js`, kept here so the article-generator
 * library API remains stable for downstream importers.
 */
 
import {
  discoverAnalysisRuns as _discoverAnalysisRuns,
  groupRunsForCollision as _groupRunsForCollision,
  type DiscoveredRun as _DiscoveredRun,
} from '../runs/index.js';
 
/**
 * One run discovered by {@link discoverAnalysisRuns}.
 *
 * Thin re-export of {@link _DiscoveredRun} from `aggregator/runs/index.js`,
 * preserved here as the public type for `article-generator` consumers.
 */
export type DiscoveredRun = _DiscoveredRun;
 
/**
 * Walk `analysis/daily/` recursively and return every subdirectory that
 * contains a `manifest.json` with a non-empty, non-`unknown` `articleType`.
 *
 * Thin re-export of {@link _discoverAnalysisRuns} from
 * `aggregator/runs/index.js`.
 *
 * @param repoRoot - Absolute repository root
 * @returns Sorted list of discovered runs (oldest date first, then lexical)
 */
export function discoverAnalysisRuns(repoRoot: string): DiscoveredRun[] {
  return _discoverAnalysisRuns(repoRoot);
}
 
/**
 * Group discovered runs by `(date, articleType)` so callers can decide
 * whether a collision-suffix is needed when writing articles.
 *
 * Thin re-export of {@link _groupRunsForCollision} from
 * `aggregator/runs/index.js`.
 *
 * @param runs - Discovered runs
 * @returns Map from `"<date>|<articleType>"` to the runs in that group
 */
export function groupRunsForCollision(
  runs: readonly DiscoveredRun[]
): Map<string, DiscoveredRun[]> {
  return _groupRunsForCollision(runs);
}