All files / src/aggregator/manifest types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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                                                                                                                                                                             
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Aggregator/Manifest/Types
 * @description Canonical manifest schema for analysis runs and the narrower
 * projection consumed by the editorial-metadata resolver. Centralises every
 * historic schema variant (canonical `articleType`, legacy plural
 * `articleTypes[]`, very-legacy `runType`) into one type that downstream
 * modules can read against.
 */
 
import type { LanguageCode } from '../../types/index.js';
 
/** `manifest.files` can be nested category → paths or flat path → description. */
export type ManifestFiles = Record<string, readonly string[] | Record<string, string>>;
 
/** One entry in `manifest.history[]`; only fields we read are typed. */
export interface ManifestHistoryEntry {
  readonly stage?: string;
  readonly completedAt?: string;
  readonly startedAt?: string;
  readonly finishedAt?: string;
  readonly runId?: string;
  readonly gateResult?: string;
  readonly summary?: string;
  readonly filesWritten?: readonly string[];
}
 
/**
 * Optional editorial-metadata override. `string` is applied to every
 * language; an object allows explicit per-language overrides.
 */
export type ManifestMetadataOverride = string | Partial<Record<LanguageCode, string>>;
 
/**
 * Raw manifest shape as committed by the analysis pipeline. Matches every
 * schema variant the pipeline has ever emitted; readers consult
 * {@link resolveArticleType} rather than `articleType` directly so legacy
 * runs stay readable.
 */
export interface Manifest {
  /** Canonical singular form (current pipeline). */
  readonly articleType?: string;
  /**
   * Legacy plural form emitted by some pre-aggregator-pipeline workflows.
   * When present, `articleTypes[0]` is treated as the article type.
   */
  readonly articleTypes?: readonly string[];
  /**
   * Very-legacy field on older breaking-run manifests. Used as the last
   * fallback when neither `articleType` nor `articleTypes` is present.
   */
  readonly runType?: string;
  /** Stable run identifier; falls back to the run-dir basename. */
  readonly runId?: string | number;
  /** ISO date (`YYYY-MM-DD`); falls back to the run-dir path. */
  readonly date?: string;
  /** Repo-relative analysis directory hint emitted by some workflows. */
  readonly analysisDir?: string;
  /** Manifest-declared file inventory (nested or flat). */
  readonly files?: ManifestFiles;
  /** Stage-history audit log used to read the latest gate result. */
  readonly history?: readonly ManifestHistoryEntry[];
  /** Optional editorial title override. */
  readonly title?: ManifestMetadataOverride;
  /** Optional editorial description override. */
  readonly description?: ManifestMetadataOverride;
  /** Committee code (e.g. `ENVI`) used by committee-reports templates. */
  readonly committee?: string;
}
 
/**
 * Narrower manifest projection consumed by {@link resolveArticleMetadata}
 * in `aggregator/article-metadata.ts`. The metadata resolver only needs a
 * subset; keeping this projection separate means string-only callers
 * (backport, legacy curators) don't have to construct a full {@link Manifest}.
 */
export interface MetadataManifest {
  readonly articleType?: string;
  readonly date?: string;
  readonly runId?: string;
  readonly title?: ManifestMetadataOverride;
  readonly description?: ManifestMetadataOverride;
  readonly committee?: string;
}