feedsmith
Version:
Fast, all‑in‑one parser and generator for RSS, Atom, RDF, and JSON Feed, with support for Podcast, iTunes, Dublin Core, and OPML files.
1,016 lines • 23 kB
TypeScript
//#region src/common/types.d.ts
type DateLike = Date | string;
type ExtraFields<F extends ReadonlyArray<string>, V = unknown> = { [K in F[number]]?: V };
type IsPlainObject<T> = T extends Array<unknown> ? false : T extends ((...args: Array<unknown>) => unknown) ? false : T extends Date ? false : T extends object ? T extends null ? false : true : false;
type RemoveUndefined<T> = T extends undefined ? never : T;
type DeepPartial<T> = IsPlainObject<T> extends true ? { [P in keyof T]?: DeepPartial<RemoveUndefined<T[P]>> } : T extends Array<infer U> ? Array<DeepPartial<U>> : T;
type XmlStylesheet = {
type: string;
href: string;
title?: string;
media?: string;
charset?: string;
alternate?: boolean;
};
type XmlGenerateOptions<O, F extends boolean = false> = O & {
lenient?: F;
stylesheets?: Array<XmlStylesheet>;
};
type JsonGenerateOptions<O, F extends boolean = false> = O & {
lenient?: F;
};
type XmlGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: XmlGenerateOptions<O, F>) => string;
type JsonGenerateMain<S, L, O = Record<string, unknown>> = <F extends boolean = false>(value: F extends true ? L : S, options?: JsonGenerateOptions<O, F>) => unknown;
//#endregion
//#region src/namespaces/dc/common/types.d.ts
type ItemOrFeed<TDate extends DateLike> = {
title?: string;
creator?: string;
subject?: string;
description?: string;
publisher?: string;
contributor?: string;
date?: TDate;
type?: string;
format?: string;
identifier?: string;
source?: string;
language?: string;
relation?: string;
coverage?: string;
rights?: string;
};
//#endregion
//#region src/namespaces/dcterms/common/types.d.ts
type ItemOrFeed$1<TDate extends DateLike> = {
abstract?: string;
accessRights?: string;
accrualMethod?: string;
accrualPeriodicity?: string;
accrualPolicy?: string;
alternative?: string;
audience?: string;
available?: TDate;
bibliographicCitation?: string;
conformsTo?: string;
contributor?: string;
coverage?: string;
created?: TDate;
creator?: string;
date?: TDate;
dateAccepted?: TDate;
dateCopyrighted?: TDate;
dateSubmitted?: TDate;
description?: string;
educationLevel?: string;
extent?: string;
format?: string;
hasFormat?: string;
hasPart?: string;
hasVersion?: string;
identifier?: string;
instructionalMethod?: string;
isFormatOf?: string;
isPartOf?: string;
isReferencedBy?: string;
isReplacedBy?: string;
isRequiredBy?: string;
issued?: TDate;
isVersionOf?: string;
language?: string;
license?: string;
mediator?: string;
medium?: string;
modified?: TDate;
provenance?: string;
publisher?: string;
references?: string;
relation?: string;
replaces?: string;
requires?: string;
rights?: string;
rightsHolder?: string;
source?: string;
spatial?: string;
subject?: string;
tableOfContents?: string;
temporal?: string;
title?: string;
type?: string;
valid?: TDate;
};
//#endregion
//#region src/namespaces/georss/common/types.d.ts
type Point = {
lat: number;
lng: number;
};
type Line = {
points: Array<Point>;
};
type Polygon = {
points: Array<Point>;
};
type Box = {
lowerCorner: Point;
upperCorner: Point;
};
type ItemOrFeed$2 = {
point?: Point;
line?: Line;
polygon?: Polygon;
box?: Box;
featureTypeTag?: string;
relationshipTag?: string;
featureName?: string;
elev?: number;
floor?: number;
radius?: number;
};
//#endregion
//#region src/namespaces/itunes/common/types.d.ts
type Category$3 = {
text: string;
categories?: Array<Category$3>;
};
type Owner = {
name?: string;
email?: string;
};
type Item$1 = {
duration?: number;
image?: string;
explicit?: boolean;
title?: string;
episode?: number;
season?: number;
episodeType?: string;
block?: boolean;
/** @deprecated Use standard RSS description instead. No longer used by Apple Podcasts. */
summary?: string;
/** @deprecated No longer used by Apple Podcasts. */
subtitle?: string;
/** @deprecated No longer used for search in Apple Podcasts. */
keywords?: Array<string>;
};
type Feed$6 = {
image?: string;
categories?: Array<Category$3>;
explicit?: boolean;
author?: string;
title?: string;
type?: string;
newFeedUrl?: string;
block?: boolean;
complete?: boolean;
applePodcastsVerify?: string;
/** @deprecated Use standard RSS description instead. No longer used by Apple Podcasts. */
summary?: string;
/** @deprecated No longer used by Apple Podcasts. */
subtitle?: string;
/** @deprecated No longer used for search in Apple Podcasts. */
keywords?: Array<string>;
/** @deprecated No longer required for submission to Apple Podcasts. */
owner?: Owner;
};
//#endregion
//#region src/namespaces/media/common/types.d.ts
type Rating = {
value: string;
scheme?: string;
};
type TitleOrDescription = {
value: string;
type?: string;
};
type Thumbnail = {
url: string;
height?: number;
width?: number;
time?: string;
};
type Category$2 = {
name: string;
scheme?: string;
label?: string;
};
type Hash = {
value: string;
algo?: string;
};
type Player = {
url: string;
height?: number;
width?: number;
};
type Credit = {
value: string;
role?: string;
scheme?: string;
};
type Copyright = {
value: string;
url?: string;
};
type Text$1 = {
value: string;
type?: string;
lang?: string;
start?: string;
end?: string;
};
type Restriction = {
value: string;
relationship: string;
type?: string;
};
type Community = {
starRating?: StarRating;
statistics?: Statistics;
tags?: Array<Tag>;
};
type StarRating = {
average?: number;
count?: number;
min?: number;
max?: number;
};
type Statistics = {
views?: number;
favorites?: number;
};
type Tag = {
name: string;
weight: number;
};
type Embed = {
url: string;
width?: number;
height?: number;
params?: Array<Param>;
};
type Param = {
name: string;
value: string;
};
type Status = {
state: string;
reason?: string;
};
type Price = {
type?: string;
info?: string;
price?: number;
currency?: string;
};
type License$1 = {
name?: string;
type?: string;
href?: string;
} & ({
name: string;
} | {
href: string;
});
type SubTitle = {
type?: string;
lang?: string;
href: string;
};
type PeerLink = {
type?: string;
href: string;
};
type Rights = {
status?: string;
};
type Scene = {
title?: string;
description?: string;
startTime?: string;
endTime?: string;
};
type Location$1 = {
description?: string;
start?: string;
end?: string;
lat?: number;
lng?: number;
};
type CommonElements = {
ratings?: Array<Rating>;
title?: TitleOrDescription;
description?: TitleOrDescription;
keywords?: Array<string>;
thumbnails?: Array<Thumbnail>;
categories?: Array<Category$2>;
hashes?: Array<Hash>;
player?: Player;
credits?: Array<Credit>;
copyright?: Copyright;
texts?: Array<Text$1>;
restrictions?: Array<Restriction>;
community?: Community;
comments?: Array<string>;
embed?: Embed;
responses?: Array<string>;
backLinks?: Array<string>;
status?: Status;
prices?: Array<Price>;
licenses?: Array<License$1>;
subTitles?: Array<SubTitle>;
peerLinks?: Array<PeerLink>;
locations?: Array<Location$1>;
rights?: Rights;
scenes?: Array<Scene>;
};
type Content = {
url: string;
fileSize?: number;
type?: string;
medium?: string;
isDefault?: boolean;
expression?: string;
bitrate?: number;
framerate?: number;
samplingrate?: number;
channels?: number;
duration?: number;
height?: number;
width?: number;
lang?: string;
} & CommonElements;
type Group = {
contents?: Array<Content>;
} & CommonElements;
type ItemOrFeed$3 = {
group?: Group;
contents?: Array<Content>;
} & CommonElements;
//#endregion
//#region src/namespaces/psc/common/types.d.ts
type Chapter = {
start: string;
title?: string;
href?: string;
image?: string;
};
type Item$3 = {
chapters?: Array<Chapter>;
};
//#endregion
//#region src/namespaces/slash/common/types.d.ts
type HitParade = Array<number>;
type Item$4 = {
section?: string;
department?: string;
comments?: number;
hitParade?: HitParade;
};
//#endregion
//#region src/namespaces/sy/common/types.d.ts
type Feed$9<TDate extends DateLike> = {
updatePeriod?: string;
updateFrequency?: number;
updateBase?: TDate;
};
//#endregion
//#region src/namespaces/thr/common/types.d.ts
type InReplyTo = {
ref: string;
href?: string;
type?: string;
source?: string;
};
type Link<TDate extends DateLike> = {
count?: number;
updated?: TDate;
};
type Item$6 = {
total?: number;
inReplyTos?: Array<InReplyTo>;
};
//#endregion
//#region src/namespaces/wfw/common/types.d.ts
type Item$7 = {
comment?: string;
commentRss?: string;
};
//#endregion
//#region src/namespaces/yt/common/types.d.ts
type Item$11 = {
videoId?: string;
channelId?: string;
};
type Feed$10 = {
channelId?: string;
playlistId?: string;
};
//#endregion
//#region src/feeds/atom/common/types.d.ts
type Text = string;
type Link$1<TDate extends DateLike> = {
href: string;
rel?: string;
type?: string;
hreflang?: string;
title?: string;
length?: number;
thr?: Link<TDate>;
};
type Person$2 = {
name: string;
uri?: string;
email?: string;
};
type Category$1 = {
term: string;
scheme?: string;
label?: string;
};
type Generator = {
text: string;
uri?: string;
version?: string;
};
type Source$2<TDate extends DateLike> = {
authors?: Array<Person$2>;
categories?: Array<Category$1>;
contributors?: Array<Person$2>;
generator?: Generator;
icon?: string;
id?: string;
links?: Array<Link$1<TDate>>;
logo?: string;
rights?: Text;
subtitle?: Text;
title?: Text;
updated?: TDate;
};
type Entry$1<TDate extends DateLike> = {
authors?: Array<Person$2>;
categories?: Array<Category$1>;
content?: Text;
contributors?: Array<Person$2>;
id: string;
links?: Array<Link$1<TDate>>;
published?: TDate;
rights?: Text;
source?: Source$2<TDate>;
summary?: Text;
title: Text;
updated: TDate;
dc?: ItemOrFeed<TDate>;
slash?: Item$4;
itunes?: Item$1;
psc?: Item$3;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
thr?: Item$6;
dcterms?: ItemOrFeed$1<TDate>;
wfw?: Item$7;
yt?: Item$11;
};
type Feed<TDate extends DateLike> = {
authors?: Array<Person$2>;
categories?: Array<Category$1>;
contributors?: Array<Person$2>;
generator?: Generator;
icon?: string;
id: string;
links?: Array<Link$1<TDate>>;
logo?: string;
rights?: Text;
subtitle?: Text;
title: Text;
updated: TDate;
entries?: Array<Entry$1<TDate>>;
dc?: ItemOrFeed<TDate>;
sy?: Feed$9<TDate>;
itunes?: Feed$6;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
dcterms?: ItemOrFeed$1<TDate>;
yt?: Feed$10;
};
//#endregion
//#region src/feeds/json/common/types.d.ts
type Author = {
name?: string;
url?: string;
avatar?: string;
};
type Attachment = {
url: string;
mime_type: string;
title?: string;
size_in_bytes?: number;
duration_in_seconds?: number;
};
type Item$10<TDate extends DateLike> = {
id: string;
url?: string;
external_url?: string;
title?: string;
content_html?: string;
content_text?: string;
summary?: string;
image?: string;
banner_image?: string;
date_published?: TDate;
date_modified?: TDate;
tags?: Array<string>;
authors?: Array<Author>;
language?: string;
attachments?: Array<Attachment>;
} & ({
content_html: string;
} | {
content_text: string;
});
type Hub = {
type: string;
url: string;
};
type Feed$1<TDate extends DateLike> = {
title: string;
home_page_url?: string;
feed_url?: string;
description?: string;
user_comment?: string;
next_url?: string;
icon?: string;
favicon?: string;
language?: string;
expired?: boolean;
hubs?: Array<Hub>;
authors?: Array<Author>;
items: Array<Item$10<TDate>>;
};
//#endregion
//#region src/namespaces/atom/common/types.d.ts
type Entry<TDate extends DateLike> = Partial<Entry$1<TDate>>;
type Feed$5<TDate extends DateLike> = Partial<Feed<TDate>>;
//#endregion
//#region src/namespaces/content/common/types.d.ts
type Item = {
encoded?: string;
};
//#endregion
//#region src/feeds/rdf/common/types.d.ts
type Image$1 = {
title: string;
link: string;
url?: string;
};
type TextInput$1 = {
title: string;
description: string;
name: string;
link: string;
};
type Item$9<TDate extends DateLike> = {
title: string;
link: string;
description?: string;
atom?: Entry<TDate>;
dc?: ItemOrFeed<TDate>;
content?: Item;
slash?: Item$4;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
dcterms?: ItemOrFeed$1<TDate>;
wfw?: Item$7;
};
type Feed$2<TDate extends DateLike> = {
title: string;
link: string;
description: string;
image?: Image$1;
items?: Array<Item$9<TDate>>;
textInput?: TextInput$1;
atom?: Feed$5<TDate>;
dc?: ItemOrFeed<TDate>;
sy?: Feed$9<TDate>;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
dcterms?: ItemOrFeed$1<TDate>;
};
//#endregion
//#region src/namespaces/podcast/common/types.d.ts
type BaseItem = {
transcripts?: Array<Transcript>;
chapters?: Chapters;
soundbites?: Array<Soundbite>;
persons?: Array<Person$1>;
location?: Location;
season?: Season;
episode?: Episode;
license?: License;
alternateEnclosures?: Array<AlternateEnclosure>;
value?: Value;
images?: Images;
socialInteracts?: Array<SocialInteract>;
txts?: Array<Txt>;
};
type Transcript = {
url: string;
type: string;
language?: string;
rel?: string;
};
type Locked = {
value: boolean;
owner?: string;
};
type Funding = {
url: string;
display?: string;
};
type Chapters = {
url: string;
type: string;
};
type Soundbite = {
startTime: number;
duration: number;
display?: string;
};
type Person$1 = {
display: string;
role?: string;
group?: string;
img?: string;
href?: string;
};
type Location = {
display: string;
geo?: string;
osm?: string;
};
type Season = {
number: number;
name?: string;
};
type Episode = {
number: number;
display?: string;
};
type Trailer<TDate extends DateLike> = {
display: string;
url: string;
pubDate: TDate;
length?: number;
type?: string;
season?: number;
};
type License = {
display: string;
url?: string;
};
type AlternateEnclosure = {
type: string;
length?: number;
bitrate?: number;
height?: number;
lang?: string;
title?: string;
rel?: string;
codecs?: string;
default?: boolean;
sources?: Array<Source$1>;
integrity?: Integrity;
};
type Source$1 = {
uri: string;
contentType?: string;
};
type Integrity = {
type: string;
value: string;
};
type Value = {
type: string;
method: string;
suggested?: number;
valueRecipients?: Array<ValueRecipient>;
valueTimeSplits?: Array<ValueTimeSplit>;
};
type ValueRecipient = {
name?: string;
customKey?: string;
customValue?: string;
type: string;
address: string;
split: number;
fee?: boolean;
};
type Images = {
srcset?: string;
};
type LiveItem<TDate extends DateLike> = BaseItem & {
status: string;
start: TDate;
end?: TDate;
contentLinks?: Array<ContentLink>;
};
type ContentLink = {
href: string;
display?: string;
};
type SocialInteract = {
uri?: string;
protocol: string;
accountId?: string;
accountUrl?: string;
priority?: number;
};
type Block = {
value: boolean;
id?: string;
};
type Txt = {
display: string;
purpose?: string;
};
type RemoteItem = {
feedGuid: string;
feedUrl?: string;
itemGuid?: string;
medium?: string;
};
type Podroll = {
remoteItems?: Array<RemoteItem>;
};
type UpdateFrequency<TDate extends DateLike> = {
display: string;
complete?: boolean;
dtstart?: TDate;
rrule?: string;
};
type Podping = {
usesPodping?: boolean;
};
type ValueTimeSplit = {
startTime: number;
duration: number;
remoteStartTime?: number;
remotePercentage?: number;
remoteItem?: RemoteItem;
valueRecipients?: Array<ValueRecipient>;
};
type Item$2 = BaseItem;
type Feed$7<TDate extends DateLike> = {
locked?: Locked;
fundings?: Array<Funding>;
persons?: Array<Person$1>;
location?: Location;
trailers?: Array<Trailer<TDate>>;
license?: License;
guid?: string;
value?: Value;
medium?: string;
images?: Images;
liveItems?: Array<LiveItem<TDate>>;
blocks?: Array<Block>;
txts?: Array<Txt>;
remoteItems?: Array<RemoteItem>;
podroll?: Podroll;
updateFrequency?: UpdateFrequency<TDate>;
podping?: Podping;
};
//#endregion
//#region src/namespaces/source/common/types.d.ts
type Account = {
service: string;
value?: string;
};
type Likes = {
server: string;
};
type Archive = {
url: string;
startDay: string;
endDay?: string;
filename?: string;
};
type SubscriptionList = {
url: string;
value?: string;
};
type Feed$8 = {
accounts?: Array<Account>;
likes?: Likes;
archive?: Archive;
subscriptionLists?: Array<SubscriptionList>;
cloud?: string;
blogroll?: string;
self?: string;
};
type Item$5 = {
markdown?: string;
outlines?: Array<string>;
localTime?: string;
linkFull?: string;
};
//#endregion
//#region src/feeds/rss/common/types.d.ts
type Person = string;
type Category = {
name: string;
domain?: string;
};
type Cloud = {
domain: string;
port: number;
path: string;
registerProcedure: string;
protocol: string;
};
type Image = {
url: string;
title: string;
link: string;
description?: string;
height?: number;
width?: number;
};
type TextInput = {
title: string;
description: string;
name: string;
link: string;
};
type Enclosure = {
url: string;
length: number;
type: string;
};
type Guid = {
value: string;
isPermaLink?: boolean;
};
type Source = {
title: string;
url?: string;
};
type Item$8<TDate extends DateLike> = {
title?: string;
link?: string;
description?: string;
authors?: Array<Person>;
categories?: Array<Category>;
comments?: string;
enclosures?: Array<Enclosure>;
guid?: Guid;
pubDate?: TDate;
source?: Source;
atom?: Entry<TDate>;
dc?: ItemOrFeed<TDate>;
content?: Item;
slash?: Item$4;
itunes?: Item$1;
podcast?: Item$2;
psc?: Item$3;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
thr?: Item$6;
dcterms?: ItemOrFeed$1<TDate>;
wfw?: Item$7;
src?: Item$5;
} & ({
title: string;
} | {
description: string;
});
type Feed$3<TDate extends DateLike> = {
title: string;
link?: string;
description: string;
language?: string;
copyright?: string;
managingEditor?: Person;
webMaster?: Person;
pubDate?: TDate;
lastBuildDate?: TDate;
categories?: Array<Category>;
generator?: string;
docs?: string;
cloud?: Cloud;
ttl?: number;
image?: Image;
rating?: string;
textInput?: TextInput;
skipHours?: Array<number>;
skipDays?: Array<string>;
items?: Array<Item$8<TDate>>;
atom?: Feed$5<TDate>;
dc?: ItemOrFeed<TDate>;
sy?: Feed$9<TDate>;
itunes?: Feed$6;
podcast?: Feed$7<TDate>;
media?: ItemOrFeed$3;
georss?: ItemOrFeed$2;
dcterms?: ItemOrFeed$1<TDate>;
src?: Feed$8;
};
//#endregion
//#region src/common/parse.d.ts
type Feed$4 = {
format: 'rss';
feed: DeepPartial<Feed$3<string>>;
} | {
format: 'atom';
feed: DeepPartial<Feed<string>>;
} | {
format: 'rdf';
feed: DeepPartial<Feed$2<string>>;
} | {
format: 'json';
feed: DeepPartial<Feed$1<string>>;
};
declare const parse$1: (value: unknown) => Feed$4;
//#endregion
//#region src/feeds/atom/detect/index.d.ts
declare const detect: (value: unknown) => value is string;
//#endregion
//#region src/feeds/atom/generate/index.d.ts
declare const generate: XmlGenerateMain<Feed<Date>, DeepPartial<Feed<DateLike>>>;
//#endregion
//#region src/feeds/atom/parse/index.d.ts
declare const parse: (value: unknown) => DeepPartial<Feed<string>>;
//#endregion
//#region src/feeds/json/detect/index.d.ts
declare const detect$1: (value: unknown) => value is object;
//#endregion
//#region src/feeds/json/generate/index.d.ts
declare const generate$1: JsonGenerateMain<Feed$1<Date>, DeepPartial<Feed$1<DateLike>>>;
//#endregion
//#region src/feeds/json/parse/index.d.ts
declare const parse$2: (value: unknown) => DeepPartial<Feed$1<string>>;
//#endregion
//#region src/feeds/rdf/detect/index.d.ts
declare const detect$2: (value: unknown) => value is string;
//#endregion
//#region src/feeds/rdf/parse/index.d.ts
declare const parse$4: (value: unknown) => DeepPartial<Feed$2<string>>;
//#endregion
//#region src/feeds/rss/detect/index.d.ts
declare const detect$3: (value: unknown) => value is string;
//#endregion
//#region src/feeds/rss/generate/index.d.ts
declare const generate$3: XmlGenerateMain<Feed$3<Date>, DeepPartial<Feed$3<DateLike>>>;
//#endregion
//#region src/feeds/rss/parse/index.d.ts
declare const parse$5: (value: unknown) => DeepPartial<Feed$3<string>>;
//#endregion
//#region src/opml/common/types.d.ts
type MainOptions<A extends ReadonlyArray<string> = ReadonlyArray<string>> = {
extraOutlineAttributes?: A;
};
type Outline<TDate extends DateLike, A extends ReadonlyArray<string> = ReadonlyArray<string>> = {
text: string;
type?: string;
isComment?: boolean;
isBreakpoint?: boolean;
created?: TDate;
category?: string;
description?: string;
xmlUrl?: string;
htmlUrl?: string;
language?: string;
title?: string;
version?: string;
url?: string;
outlines?: Array<Outline<TDate, A>>;
} & ExtraFields<A>;
type Head<TDate extends DateLike> = {
title?: string;
dateCreated?: TDate;
dateModified?: TDate;
ownerName?: string;
ownerEmail?: string;
ownerId?: string;
docs?: string;
expansionState?: Array<number>;
vertScrollState?: number;
windowTop?: number;
windowLeft?: number;
windowBottom?: number;
windowRight?: number;
};
type Body<TDate extends DateLike, A extends ReadonlyArray<string> = ReadonlyArray<string>> = {
outlines?: Array<Outline<TDate, A>>;
};
type Opml<TDate extends DateLike, A extends ReadonlyArray<string> = ReadonlyArray<string>> = {
head?: Head<TDate>;
body?: Body<TDate, A>;
};
//#endregion
//#region src/opml/generate/index.d.ts
declare const generate$2: <A extends ReadonlyArray<string> = [], F extends boolean = false>(value: F extends true ? DeepPartial<Opml<DateLike, A>> : Opml<Date, A>, options?: XmlGenerateOptions<MainOptions<A>, F>) => string;
//#endregion
//#region src/opml/parse/index.d.ts
declare const parse$3: <const A extends ReadonlyArray<string> = []>(value: string, options?: MainOptions<A>) => DeepPartial<Opml<string, A>>;
//#endregion
export { type Feed as AtomFeed, type Feed$1 as JsonFeed, type Opml, type Feed$2 as RdfFeed, type Feed$3 as RssFeed, detect as detectAtomFeed, detect$1 as detectJsonFeed, detect$2 as detectRdfFeed, detect$3 as detectRssFeed, generate as generateAtomFeed, generate$1 as generateJsonFeed, generate$2 as generateOpml, generate$3 as generateRssFeed, parse as parseAtomFeed, parse$1 as parseFeed, parse$2 as parseJsonFeed, parse$3 as parseOpml, parse$4 as parseRdfFeed, parse$5 as parseRssFeed };