/**
* @fileoverview HN API service — Firebase and Algolia HTTP clients with HTML stripping utilities.
* @module services/hn/hn-service
*/
import type { Context } from '@cyanheads/mcp-ts-core';
import type { AlgoliaResponse, HnFeedType, HnItem, HnUser } from './types.js';
/** Decode numeric and named HTML entities. */
export declare function decodeHtmlEntities(text: string): string;
/** Strip HN HTML to plain text. Preserves code blocks and link URLs. */
export declare function stripHtml(html: string): string;
/**
* Strip HN HTML but preserve `…` markers — used to clean Algolia
* highlight snippets, which contain the original field HTML with `` tags
* inserted around matched terms. Other tags are removed by `stripHtml`.
*/
export declare function stripHtmlPreservingEm(html: string): string;
/** Normalize empty URL strings to undefined. */
export declare function normalizeUrl(url?: string | null): string | undefined;
/**
* Extract the bare hostname (lowercased, leading `www.` stripped) from a URL.
* Returns undefined for missing or unparseable URLs.
*/
export declare function extractDomain(url: string | undefined): string | undefined;
/** Filter out dead, deleted, and null items. */
export declare function filterLiveItems(items: (HnItem | null)[]): HnItem[];
export declare class HnService {
private readonly concurrencyLimit;
constructor(concurrencyLimit: number);
/**
* GET a JSON document from an upstream, with retries around the full
* fetch-and-parse pipeline and both failure shapes — non-2xx status and
* HTML-instead-of-JSON — classified onto a contract reason.
*/
private getJson;
/** Fetch a single item by ID. Returns null when HN reports the item is missing. */
fetchItem(id: number, ctx: Context): Promise;
/**
* Fetch a user profile by username. Returns null when the user does not exist.
* The username is percent-encoded as a single path segment — an unencoded
* value containing `/` or dot-segments would otherwise escape the `/user/`
* route and resolve to a different Firebase resource.
*/
fetchUser(username: string, ctx: Context): Promise;
/** Fetch a feed's ID array. Throws on upstream failure after retries. */
fetchFeed(type: HnFeedType, ctx: Context): Promise;
/**
* Batch-fetch items with concurrency limiting. Preserves input order.
* Per-item failures after exhausted retries are logged and yield `null`
* so a single bad item does not fail the whole batch. A caller abort is the
* one failure that is not per-item: it rethrows, ending the batch instead of
* spending the rest of the id list on fetches nobody is waiting for.
*/
fetchItems(ids: number[], ctx: Context): Promise<(HnItem | null)[]>;
/** Search HN via Algolia. Throws on upstream failure after retries. */
search(params: {
query: string;
tags?: string | undefined;
author?: string | undefined;
sort: 'relevance' | 'date';
dateRange?: {
start?: string | undefined;
end?: string | undefined;
} | undefined;
minPoints?: number | undefined;
count: number;
page: number;
}, ctx: Context): Promise;
}
export declare function initHnService(): void;
export declare function getHnService(): HnService;
//# sourceMappingURL=hn-service.d.ts.map