Types
All types are exported from the main feedscout package.
import type {
DiscoverInput,
DiscoverMethod,
DiscoverOptions,
DiscoverResult,
DiscoverProgress,
DiscoverFetchFn,
DiscoverNormalizeUrlFn,
DiscoverUriEntry,
DiscoverUriHint,
UriEntry,
} from 'feedscout'
import type { HubResult, DiscoverHubsOptions } from 'feedscout/hubs'Input Types
DiscoverInput
Input for discovery functions. Can be a URL string or an object:
type DiscoverInput = string | DiscoverInputObject
type DiscoverInputObject = {
url: string
content?: string // HTML content
headers?: Headers // HTTP headers
}Options Types
DiscoverOptions
Options for discoverFeeds and discoverBlogrolls. All fields are optional for simple usage:
type DiscoverOptions<TValid> = {
methods?: DiscoverMethodsConfig
fetchFn?: DiscoverFetchFn
extractFn?: DiscoverExtractFn<TValid>
normalizeUrlFn?: DiscoverNormalizeUrlFn
stopOnFirstMethod?: boolean
stopOnFirstResult?: boolean
concurrency?: number
includeInvalid?: boolean
onProgress?: DiscoverOnProgressFn
}DiscoverMethod
Union type of available discovery method names:
type DiscoverMethod = 'platform' | 'html' | 'headers' | 'guess'DiscoverMethodsConfig
Configuration for discovery methods:
type DiscoverMethodsConfig =
| Array<'html' | 'headers' | 'guess'>
| {
html?: true | Partial<Omit<HtmlMethodOptions, 'baseUrl'>>
headers?: true | Partial<Omit<HeadersMethodOptions, 'baseUrl'>>
guess?: true | Partial<Omit<GuessMethodOptions, 'baseUrl'>>
}The baseUrl is omitted because it's automatically derived from the input URL.
DiscoverHubsOptions
Options for discoverHubs:
type DiscoverHubsOptions = {
methods?: DiscoverHubsMethodsConfig
fetchFn?: DiscoverFetchFn
}
type DiscoverHubsMethodsConfig = Array<'headers' | 'html' | 'feed'>Result Types
DiscoverResult
Result from discovery functions:
type DiscoverResult<TValid> =
| ({
url: string
isValid: true
method?: DiscoverMethod
hint?: DiscoverUriHint
} & TValid)
| {
url: string
isValid: false
method?: DiscoverMethod
hint?: DiscoverUriHint
error?: unknown
}The method field indicates which discovery method produced the result ('platform', 'html', 'headers', or 'guess'). See Platform method hints for details on the hint property.
FeedResult
Valid feed result properties:
type FeedResult = {
format: 'rss' | 'atom' | 'json' | 'rdf'
title?: string
description?: string
siteUrl?: string
}BlogrollResult
Valid blogroll result properties:
type BlogrollResult = {
title?: string
}HubResult
Result from discoverHubs:
type HubResult = {
hub: string // Hub URL to subscribe to
topic: string // Feed URL the hub serves updates for
}DiscoverUriHint
A hint describing the type of feed a URI represents. See Platform method hints for details:
type DiscoverUriHint = {
key: string
label: string
}UriEntry
A URI or array of alternative URIs. When an array, alternatives are tried in order until one validates successfully:
type UriEntry = string | Array<string>DiscoverUriEntry
A URI entry with an optional hint. Used by platform handlers to return feed URIs with metadata:
type DiscoverUriEntry = {
uri: UriEntry
hint?: DiscoverUriHint
}Progress Types
DiscoverProgress
Progress information passed to onProgress callback:
type DiscoverProgress = {
tested: number // Number of URLs tested
total: number // Total URLs to test
found: number // Valid results found
current: string // Current URL being tested
}DiscoverOnProgressFn
Progress callback function type:
type DiscoverOnProgressFn = (progress: DiscoverProgress) => voidFetch Types
DiscoverFetchFn
Custom fetch function type:
type DiscoverFetchFn = (
url: string,
options?: DiscoverFetchFnOptions,
) => Promise<DiscoverFetchFnResponse>
type DiscoverFetchFnOptions = {
method?: 'GET' | 'HEAD'
headers?: Record<string, string>
}
type DiscoverFetchFnResponse = {
headers: Headers
body: string | ReadableStream<Uint8Array>
url: string
status: number
statusText: string
}Extractor Types
DiscoverExtractFn
Custom extractor function type:
type DiscoverExtractFn<TValid> = (
input: DiscoverExtractFnInput,
) => Promise<DiscoverResult<TValid>>
type DiscoverExtractFnInput = {
url: string
content: string
headers?: Headers
}Method Option Types
HtmlMethodOptions
Options for HTML discovery method:
type HtmlMethodOptions = {
baseUrl?: string
linkSelectors: Array<LinkSelector>
anchorUris: Array<string>
anchorIgnoredUris: Array<string>
anchorLabels: Array<string>
}
type LinkSelector = {
rel: string
types?: Array<string>
}HeadersMethodOptions
Options for Headers discovery method:
type HeadersMethodOptions = {
baseUrl?: string
linkSelectors: Array<LinkSelector>
}GuessMethodOptions
Options for Guess discovery method:
type GuessMethodOptions = {
baseUrl: string
uris: Array<string>
additionalBaseUrls?: Array<string>
}