pulse/interfaces/feed.types.ts
Edo Limburg 78a2b27f6d feat: implement orchestrator module with feed source management
Add FeedOrchestrator that coordinates fetch→parse→dedup→store pipeline:
- FeedSource type for managing RSS/Atom feed configurations
- Feed source CRUD operations in IStorage interface
- Database schema migration for feed_sources table
- Exponential backoff retry with configurable delays
- Per-feed poll intervals with health tracking
- Concurrency-limited parallel feed processing
- ProcessResult and FeedHealth interfaces for status monitoring

Files added:
- orchestrator/orchestrator.ts - main orchestrator class
- orchestrator/scheduler.ts - backoff calculation utilities
- orchestrator/index.ts - module exports
- orchestrator/orchestrator.test.ts - comprehensive test suite

Files modified:
- interfaces/feed.types.ts - add FeedSource type
- interfaces/storage.interface.ts - extend with feed source methods
- infrastructure/db/database.ts - add FeedSourceTable interface
- infrastructure/db/schema.ts - add feed_sources table migration
- modules/storage/storage.ts - implement feed source CRUD
- modules/storage/storage.test.ts - add feed source tests
2026-05-05 22:17:16 +02:00

48 lines
1.1 KiB
TypeScript

export interface FeedItem {
id: string;
source: string;
title: string;
url: string;
publishedAt: Date;
content?: string;
summary?: string;
}
export interface FetchInput {
url: string;
expectedFormat: "rss" | "atom";
}
export interface FetchError {
source: string;
reason: string;
code: "NETWORK" | "TIMEOUT" | "PARSE" | "UNKNOWN";
}
export interface FeedResponse {
source: string;
body: string;
contentType: string;
statusCode: number;
}
export interface FetchResult {
responses: FeedResponse[];
errors: FetchError[];
fetchedAt: Date;
}
export interface FeedSource {
id: string; // Hash of URL
url: string; // Feed URL
name: string | null; // Display name
format: 'rss' | 'atom'; // Expected format
pollIntervalMs: number; // How often to check
isActive: boolean; // Whether to poll
lastFetchedAt: Date | null; // Last attempt timestamp
lastSuccessAt: Date | null; // Last successful fetch
consecutiveFailures: number; // Error streak counter
createdAt: Date;
updatedAt: Date;
}