Initial commit: Pulse RSS feed aggregator with fetcher module and all interfaces
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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>;
|
||||
}
|
||||
@@ -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>;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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[]>;
|
||||
}
|
||||
Reference in New Issue
Block a user