@devmehq/open-graph-extractor
Version:
Fast, lightweight Open Graph, Twitter Card, and structured data extractor for Node.js with caching and validation
88 lines (87 loc) • 2.76 kB
TypeScript
import { type IOgObjectMedia } from "./media";
import type { IExtractOpenGraphOptions as IAsyncExtractOptions, IExtractionResult } from "./types";
export * from "./bulk";
export * from "./cache";
export * from "./media";
export * from "./security";
export * from "./structured-data";
export * from "./types";
export * from "./validation";
export interface IOGResult extends IOgObjectMedia {
ogLocale?: string;
favicon?: string;
ogDate?: string;
alAndroidAppName?: string;
alAndroidPackage?: string;
alAndroidUrl?: string;
alIosAppName?: string;
alIosAppStoreId?: string;
alIosUrl?: string;
alWebShouldFallback?: string;
twitterCard?: string;
twitterSite?: string;
twitterTitle?: string;
twitterDescription?: string;
twitterAppNameiPhone?: string;
twitterAppIdiPhone?: string;
twitterAppUrliPhone?: string;
twitterAppNameiPad?: string;
twitterAppIdiPad?: string;
twitterAppUrliPad?: string;
twitterAppNameGooglePlay?: string;
twitterAppIdGooglePlay?: string;
twitterAppUrlGooglePlay?: string;
ogImageSecureURL?: string;
ogImageURL?: string;
ogSiteName?: string;
charset?: string;
error?: string;
errorDetails?: string;
[key: string]: unknown;
}
export interface IExtractOpenGraphOptions {
customMetaTags?: Array<{
multiple: boolean;
property: string;
fieldName: string;
}>;
allMedia?: boolean;
onlyGetOpenGraphInfo?: boolean;
ogImageFallback?: boolean;
cache?: {
enabled: boolean;
ttl?: number;
storage?: string;
maxSize?: number;
keyGenerator?: (url: string) => string;
};
security?: {
sanitizeHtml?: boolean;
detectPII?: boolean;
maskPII?: boolean;
validateUrls?: boolean;
maxRedirects?: number;
timeout?: number;
allowedDomains?: string[];
blockedDomains?: string[];
};
extractStructuredData?: boolean;
validateData?: boolean;
generateScore?: boolean;
extractArticleContent?: boolean;
detectLanguage?: boolean;
normalizeUrls?: boolean;
returnEnhanced?: boolean;
}
/**
* Extract Open Graph data from HTML with optional enhanced features
* @param input - HTML string or Buffer
* @param options - extraction options
*/
export declare function extractOpenGraph(input: string | Buffer, options?: IExtractOpenGraphOptions): IOGResult;
/**
* Extract Open Graph data with all features (async version)
* @param input - HTML string, Buffer, or URL (URL fetching not implemented)
* @param options - extraction options
*/
export declare function extractOpenGraphAsync(input: string | Buffer, options?: IAsyncExtractOptions): Promise<IExtractionResult>;