Initial commit: Pulse RSS feed aggregator with fetcher module and all interfaces

This commit is contained in:
Edo Limburg
2026-05-05 21:07:52 +02:00
commit 84cafa9ecb
16 changed files with 2913 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import type { FeedItem } from './feed.types.js';
export interface DedupError {
code: 'CACHE_ERROR' | 'UNKNOWN';
message: string;
}
export interface IDedup {
/**
* Returns only items that have not been seen before.
* Does NOT mark them as seen - call markSeen() separately.
*/
filter(items: FeedItem[]): Promise<FeedItem[]>;
/**
* Marks items as seen for future deduplication.
*/
markSeen(items: FeedItem[]): Promise<void>;
}
+33
View File
@@ -0,0 +1,33 @@
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;
}
+6
View File
@@ -0,0 +1,6 @@
import type { FetchInput, FetchResult } from './feed.types.js';
export interface IFetcher {
fetch(input: FetchInput): Promise<FetchResult>;
fetchMany(inputs: FetchInput[]): Promise<FetchResult>;
}
+16
View File
@@ -0,0 +1,16 @@
import type { FeedItem } from './feed.types.js';
export type OutputFormat = 'terminal' | 'html' | 'json';
export interface FormatterError {
code: 'SERIALIZE_ERROR' | 'UNKNOWN';
message: string;
}
export interface IFormatter {
/**
* Format items to the specified output format.
* Returns string for terminal/html/json output.
*/
format(items: FeedItem[], format: OutputFormat): Promise<string>;
}
+6
View File
@@ -0,0 +1,6 @@
import type { FeedItem } from './feed.types.js';
export interface IParser {
parse(rawXml: string, source: string): Promise<FeedItem[]>;
supports(contentType: string): boolean;
}
+28
View File
@@ -0,0 +1,28 @@
import type { FeedItem } from './feed.types.js';
export interface StorageError {
code: 'DB_ERROR' | 'CONSTRAINT_ERROR' | 'UNKNOWN';
message: string;
}
export interface IStorage {
/**
* Persist items to storage. Should handle duplicates gracefully (upsert).
*/
save(items: FeedItem[]): Promise<void>;
/**
* Get most recent items across all sources.
*/
getRecent(limit: number): Promise<FeedItem[]>;
/**
* Get recent items from a specific source feed.
*/
getBySource(source: string, limit: number): Promise<FeedItem[]>;
/**
* Search items by title/content keywords.
*/
search(query: string): Promise<FeedItem[]>;
}