UNPKG

link-enricher

Version:

Fetch oEmbed, Opeh Graph, etc info for links

78 lines (77 loc) 1.91 kB
import { CheerioAPI } from 'cheerio'; export type FileResult = { name?: string; size?: number; type?: string; ext?: string; }; type WebpageIcon = { rel: 'icon' | 'apple-touch-icon' | 'manifest'; url: string; width?: number; height?: number; type?: string; }; type WebpageMedia = { url: string; type?: string; width?: number; height?: number; }; export type WebpageResult = { type?: string; url?: string; name?: string; title?: string; description?: string; icons: WebpageIcon[]; images: WebpageMedia[]; videos: WebpageMedia[]; audios: WebpageMedia[]; }; type OEmbedAuthor = { name: string; url?: string; }; type OEmbedJSON = { type: string; version: string; title?: string; author_name?: string; author_url?: string; provider_name?: string; provider_url?: string; cache_age?: string | number; thumbnail_url?: string; thumbnail_width?: string | number; thumbnail_height?: string | number; url?: string; html?: string; width?: string | number; height?: string | number; }; export type OEmbedResult = { type: string; title?: string; thumbnail?: WebpageMedia; author?: OEmbedAuthor; provider?: OEmbedAuthor & { id: string; }; width?: number; height?: number; href?: string; html?: string; }; export declare const file: (link: string, contentType: string, rawDisposition?: string, rawLength?: string) => FileResult; export declare const webpage: (link: string, $: CheerioAPI) => WebpageResult; export declare const oembedJSON: (body: OEmbedJSON) => OEmbedResult | null; export declare const oembedXML: (xml: string) => OEmbedResult | null; export declare const html: (link: string, body: string) => { 'webpage'?: WebpageResult; 'oembed': { json?: string; xml?: string; }; }; export {};