@llml-browser/types
Version:
TypeScript types and schemas for the @llml-browser API
1 lines • 3.76 kB
Source Map (JSON)
{"version":3,"sources":["../src/services/link/types.ts"],"sourcesContent":["import { z } from 'zod';\n\n/**\n * Schema for configuring link extraction behavior.\n * Defines validation rules for controlling how links are extracted from HTML.\n */\nexport const LinkExtractionOptionsSchema = z\n .object({\n includeExternal: z.boolean().optional(), // Include links from other domains\n includeMedia: z.boolean().optional(), // Include media files (images, videos, docs)\n excludePatterns: z.array(z.string()).optional(), // Regex patterns to exclude URLs\n removeQueryParams: z.boolean().optional(), // Remove query parameters from URLs\n })\n .strict();\n\n/**\n * Schema for storing extracted links by category.\n * Defines the structure for organizing links extracted from a webpage.\n */\nexport const ExtractedLinksSchema = z.object({\n internal: z.array(z.string()).optional(),\n external: z.array(z.string()).optional(),\n media: z\n .object({\n images: z.array(z.string()).optional(),\n videos: z.array(z.string()).optional(),\n documents: z.array(z.string()).optional(),\n })\n .optional(),\n});\n\n/**\n * Configuration options for link extraction behavior.\n * Controls which types of links are extracted and how they are processed.\n *\n * @property includeExternal - Whether to include links from other domains\n * @property includeMedia - Whether to include media files (images, videos, docs)\n * @property excludePatterns - List of regex patterns to exclude URLs\n * @property removeQueryParams - Whether to remove query parameters from URLs\n *\n * @example\n * ```typescript\n * const options: LinkExtractionOptions = {\n * includeExternal: false,\n * includeMedia: true,\n * excludePatterns: ['^/admin/', '\\\\.pdf$'],\n * removeQueryParams: true\n * };\n * ```\n */\nexport type LinkExtractionOptions = z.infer<typeof LinkExtractionOptionsSchema>;\n\n/**\n * Structure containing extracted links categorized by type.\n * Organizes links extracted from a webpage into logical groups.\n *\n * @property internal - Array of links from the same domain\n * @property external - Array of links from other domains\n * @property media - Object containing arrays of media links categorized by type\n * @property media.images - Array of image file URLs\n * @property media.videos - Array of video file URLs\n * @property media.documents - Array of document file URLs\n *\n * @example\n * ```typescript\n * const links: ExtractedLinks = {\n * internal: [\n * 'https://example.com/about',\n * 'https://example.com/contact'\n * ],\n * external: [\n * 'https://othersite.com/reference',\n * 'https://api.example.org/data'\n * ],\n * media: {\n * images: [\n * 'https://example.com/images/logo.png',\n * 'https://example.com/images/banner.jpg'\n * ],\n * videos: [\n * 'https://example.com/videos/intro.mp4'\n * ],\n * documents: [\n * 'https://example.com/docs/whitepaper.pdf'\n * ]\n * }\n * };\n * ```\n */\nexport type ExtractedLinks = z.infer<typeof ExtractedLinksSchema>;\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,SAAS;AAMX,IAAM,8BAA8B,EACxC,OAAO;AAAA,EACN,iBAAiB,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EACtC,cAAc,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EACnC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA,EAC9C,mBAAmB,EAAE,QAAQ,EAAE,SAAS;AAAA;AAC1C,CAAC,EACA,OAAO;AAMH,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACvC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACvC,OAAO,EACJ,OAAO;AAAA,IACN,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IACrC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IACrC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EAC1C,CAAC,EACA,SAAS;AACd,CAAC;","names":[]}