Files
kill-the-news/src/types/index.ts
T
Julien Herr 1789870f27 fix(feed): use permalink URL as Atom entry id, strip mso-* inline styles
- Entry <id> was a non-URL string (timestamp + base64 snippet), which
  is invalid per the Atom spec; now uses the entry permalink URL which
  is both valid and stable across feed regeneration
- Strip mso-* properties from inline style attributes in extracted body
  content to eliminate the feed validator DangerousStyleAttr warning
  caused by Microsoft Office HTML in newsletter emails

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:12:22 +02:00

107 lines
2.4 KiB
TypeScript

// Global environment interface for Cloudflare Workers
export interface Env {
EMAIL_STORAGE: KVNamespace;
ADMIN_PASSWORD: string;
DOMAIN: string;
ATTACHMENT_BUCKET?: R2Bucket;
FEED_MAX_SIZE_BYTES?: string;
PROXY_TRUSTED_IPS?: string;
PROXY_AUTH_SECRET?: string;
}
// Stored attachment metadata (bytes live in R2, keyed by id)
export interface AttachmentData {
id: string;
filename: string;
contentType: string;
size: number;
}
// Email interface for stored emails
export interface EmailData {
subject: string;
from: string;
content: string;
receivedAt: number;
headers: Record<string, string>;
attachments?: AttachmentData[];
}
// Feed configuration interface
export interface FeedConfig {
title: string;
description?: string;
allowed_senders?: string[];
language: string;
site_url: string;
feed_url: string;
author?: string;
created_at: number;
updated_at?: number;
}
// Feed metadata interface
export interface FeedMetadata {
emails: EmailMetadata[];
}
// Email metadata interface (summary info for listing)
export interface EmailMetadata {
key: string;
subject: string;
receivedAt: number;
size?: number;
attachmentIds?: string[];
}
// Feed list interface
export interface FeedList {
feeds: FeedListItem[];
}
// Feed summary interface (for the global feed list)
export interface FeedListItem {
id: string;
title: string;
description?: string;
}
// WebSub (PubSubHubbub) subscription configuration
export interface WebSubSubscription {
callbackUrl: string;
secret?: string;
expiresAt: number; // Unix timestamp ms
format?: "rss" | "atom";
}
// Declare KVNamespace for TypeScript
declare global {
// This is not an ideal solution but works for our example
interface KVNamespace {
get(key: string, options?: { type: "text" }): Promise<string | null>;
get(key: string, options: { type: "json" }): Promise<unknown | null>;
get(
key: string,
options: { type: "arrayBuffer" },
): Promise<ArrayBuffer | null>;
get(
key: string,
options: { type: "stream" },
): Promise<ReadableStream | null>;
put(
key: string,
value: string | ArrayBuffer | ReadableStream | FormData,
): Promise<void>;
delete(key: string): Promise<void>;
list(options?: {
prefix?: string;
limit?: number;
cursor?: string;
}): Promise<{
keys: { name: string; expiration?: number }[];
list_complete: boolean;
cursor?: string;
}>;
}
}