@llml-browser/types
Version:
TypeScript types and schemas for the @llml-browser API
145 lines (142 loc) • 4.84 kB
TypeScript
import { h as ScrapedData } from '../index-4Wnppylh.js';
import z from 'zod';
import '../index-ChkdX0Va.js';
import '../index-CJbaIceM.js';
declare const readOptionsSchema: z.ZodObject<{
/**
* The URL to scrape.
* Must be a valid URL string.
*/
url: z.ZodString;
/**
* Whether to extract metadata from the page.
* Default: true
*/
metadata: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
/**
* Whether to extract markdown from the page.
* Default: true
*/
markdown: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
/**
* Whether to return cleaned HTML.
* Default: true
*/
cleanedHtml: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
/**
* Whether to fetch and parse robots.txt.
* Default: false
*/
robots: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
/**
* Whether to return raw HTML.
* Default: false
*/
rawHtml: z.ZodEffects<z.ZodOptional<z.ZodBoolean>, boolean | undefined, unknown>;
/**
* Options for metadata extraction.
* Controls how metadata like title, description, etc. are extracted.
*/
metadataOptions: z.ZodOptional<z.ZodObject<{
title: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
description: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
language: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
canonical: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
robots: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
author: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
keywords: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
favicon: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
openGraph: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
twitter: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
isIframeAllowed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
title: boolean;
description: boolean;
language: boolean;
canonical: boolean;
robots: boolean;
author: boolean;
keywords: boolean;
favicon: boolean;
openGraph: boolean;
twitter: boolean;
isIframeAllowed: boolean;
}, {
title?: boolean | undefined;
description?: boolean | undefined;
language?: boolean | undefined;
canonical?: boolean | undefined;
robots?: boolean | undefined;
author?: boolean | undefined;
keywords?: boolean | undefined;
favicon?: boolean | undefined;
openGraph?: boolean | undefined;
twitter?: boolean | undefined;
isIframeAllowed?: boolean | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
url: string;
cleanedHtml?: boolean | undefined;
robots?: boolean | undefined;
metadataOptions?: {
title: boolean;
description: boolean;
language: boolean;
canonical: boolean;
robots: boolean;
author: boolean;
keywords: boolean;
favicon: boolean;
openGraph: boolean;
twitter: boolean;
isIframeAllowed: boolean;
} | undefined;
metadata?: boolean | undefined;
rawHtml?: boolean | undefined;
markdown?: boolean | undefined;
}, {
url: string;
cleanedHtml?: unknown;
robots?: unknown;
metadataOptions?: {
title?: boolean | undefined;
description?: boolean | undefined;
language?: boolean | undefined;
canonical?: boolean | undefined;
robots?: boolean | undefined;
author?: boolean | undefined;
keywords?: boolean | undefined;
favicon?: boolean | undefined;
openGraph?: boolean | undefined;
twitter?: boolean | undefined;
isIframeAllowed?: boolean | undefined;
} | undefined;
metadata?: unknown;
rawHtml?: unknown;
markdown?: unknown;
}>;
type ReadOptions = z.infer<typeof readOptionsSchema>;
type ReadResponseBase = {
success: boolean;
targetUrl: string;
};
type ReadErrorResponse = ReadResponseBase & {
success: false;
error: string;
};
type ReadSuccessResponse = ReadResponseBase & Omit<ScrapedData, 'rawHtml'> & {
success: true;
cached: boolean;
markdown?: string;
rawHtml?: string;
metrics?: {
readableDuration: string;
duration: number;
startTime: number;
endTime: number;
};
};
type ReadStringResponse = string;
type ReadPostResponse = ReadSuccessResponse | ReadErrorResponse;
type ReadResponse = ReadStringResponse | ReadPostResponse;
export { type ReadErrorResponse, type ReadOptions, type ReadPostResponse, type ReadResponse, type ReadResponseBase, type ReadStringResponse, type ReadSuccessResponse, readOptionsSchema };