/** Shapes produced by server/src/feeds/parser.ts and consumed by the normalizer. */

export type FeedType = 'rss' | 'atom' | 'json';

/** One entry as parsed straight from a feed, before canonicalisation. */
export interface RawFeedItem {
  title: string;
  link: string;
  guid: string | null;
  published: string;
  contentHtml: string;
  contentText: string | null;
  author: string | null;
}

export interface ParsedFeed {
  type: FeedType;
  title: string;
  description: string;
  siteUrl: string;
  items: RawFeedItem[];
}

/**
 * Dedup keys are namespaced so a feed GUID can never collide with a
 * content hash: `guid:<id>` or `hash:<sha256>`.
 */
export type DedupKey = `guid:${string}` | `hash:${string}`;

/** One entry after URL canonicalisation, sanitisation, and date clamping. */
export interface NormalizedItem {
  title: string;
  link: string;
  guid: string | null;
  publishedAt: string;
  contentHtml: string;
  contentText: string | null;
  author: string | null;
  dedupKey: DedupKey;
}

export interface NormalizedFeed {
  title: string;
  description: string;
  siteUrl: string;
  items: NormalizedItem[];
}
