langchain-stripe-loader 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/StripeDocsLoader.ts","../src/utils.ts","../src/utils/url-filter.ts","../src/options.ts","../src/StripeComLoader.ts","../src/StripeChangelogLoader.ts"],"sourcesContent":["export { StripeDocsDocumentLoader } from './StripeDocsLoader';\nexport type {\n StripeDocsContentFormat,\n StripeDocsLoaderOptions,\n StripeDocsLoadOptions,\n} from './StripeDocsLoader';\nexport { StripeComDocumentLoader } from './StripeComLoader';\nexport type { StripeLoaderOptions } from './options';\nexport { StripeChangelogDocumentLoader } from './StripeChangelogLoader';\nexport type { StripeChangelogLoadOptions } from './StripeChangelogLoader';\n","import { SitemapProcessor, fetchWithRetry, RequestPacer } from 'stripe-loaders-core';\nimport { BaseDocumentLoader } from '@langchain/core/document_loaders/base';\nimport { BaseDocumentTransformer, Document } from '@langchain/core/documents';\nimport { NodeHtmlMarkdown } from 'node-html-markdown';\nimport { extractArticleFromHTML, parseMarkdownDocument, toMarkdownUrl } from './utils';\nimport { filterUrls } from './utils/url-filter';\nimport {\n resolveLoaderOptions,\n type ResolvedLoaderOptions,\n type StripeLoaderOptions,\n} from './options';\n\n/**\n * How page content is fetched from docs.stripe.com.\n * - `html`: fetch the HTML page and convert the extracted article to Markdown (default).\n * - `markdown`: fetch the Markdown version that docs.stripe.com serves at `<page>.md`.\n */\nexport type StripeDocsContentFormat = 'html' | 'markdown';\n\nexport interface StripeDocsLoaderOptions extends StripeLoaderOptions {\n /** Default content format for `load()`. Defaults to `html`. */\n format?: StripeDocsContentFormat;\n}\n\nexport interface StripeDocsLoadOptions {\n /** Locale for the content. Defaults to `en-US`. */\n locale?: string;\n /** Load only these URLs instead of the sitemap. */\n urls?: string[];\n /** Resource path to include (e.g. `connect`). */\n resource?: string;\n /** Resource paths to exclude. */\n excludeResources?: string[];\n /** Content format. Overrides the constructor option. */\n format?: StripeDocsContentFormat;\n}\n\n/**\n * Interface representing a Stripe documentation article\n */\ntype StripeDocsArticle = {\n url: string;\n content: string;\n title: string;\n description: string;\n format: StripeDocsContentFormat;\n};\n\n/**\n * Document loader for Stripe Docs website content\n * Extracts content from docs.stripe.com pages and converts it to LangChain documents\n */\nexport class StripeDocsDocumentLoader extends BaseDocumentLoader {\n private readonly options: ResolvedLoaderOptions;\n private readonly format: StripeDocsContentFormat;\n\n /**\n * @param options Loader options, or a boolean to enable debug logging (legacy signature)\n */\n constructor(options?: boolean | StripeDocsLoaderOptions) {\n super();\n this.options = resolveLoaderOptions(options);\n this.format = (typeof options === 'object' && options.format) || 'html';\n }\n\n /**\n * Fetches URLs from the Stripe Docs sitemap\n * @returns {Promise<string[]>} Array of URLs from the sitemap\n */\n protected async fetchURLsFromSitemap() {\n const documentUrls = await new SitemapProcessor({\n debug: this.options.debug,\n logger: this.options.logger,\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n }).fetchAndProcessSitemap('https://docs.stripe.com/sitemap.xml');\n return documentUrls;\n }\n\n /**\n * Fetches articles from the sitemap\n */\n private async fetchArticlesFromSitemap({\n locale,\n resource,\n excludeResources,\n format,\n }: {\n locale: string;\n resource?: string;\n excludeResources?: string[];\n format: StripeDocsContentFormat;\n }): Promise<StripeDocsArticle[]> {\n const documentUrls = await this.fetchURLsFromSitemap();\n const filteredDocumentUrls = filterUrls(documentUrls, resource, excludeResources);\n return this.fetchArticlesFromURLs(filteredDocumentUrls, locale, format);\n }\n\n private async fetchArticlesFromURLs(\n documentUrls: string[],\n locale: string,\n format: StripeDocsContentFormat = this.format\n ): Promise<StripeDocsArticle[]> {\n const { logger } = this.options;\n const pacer = new RequestPacer(this.options.rateLimit, this.options.sleep);\n const articles: StripeDocsArticle[] = [];\n\n for (const docsUrl of documentUrls) {\n const requestUrl =\n format === 'markdown' ? toMarkdownUrl(docsUrl, locale) : `${docsUrl}?locale=${locale}`;\n try {\n await pacer.wait();\n logger.log(`Fetching ${requestUrl}`);\n const response = await fetchWithRetry(requestUrl, undefined, {\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n onRetry: ({ attempt, waitMs, reason }) =>\n logger.warn(`Retrying ${requestUrl} (attempt ${attempt}, ${reason}) in ${waitMs}ms`),\n });\n\n // Skip if HTTP status code is 400 or higher\n if (response.status >= 400) {\n logger.warn(`Skipping ${docsUrl} - HTTP status: ${response.status}`);\n continue;\n }\n\n const body = await response.text();\n\n if (format === 'markdown') {\n const { title, description } = parseMarkdownDocument(body);\n articles.push({ url: docsUrl, content: body.trim(), title, description, format });\n continue;\n }\n\n const extracted = extractArticleFromHTML(body, logger);\n const titleMatch = body.match(/<title[^>]*>([^<]+)<\\/title>/);\n const descMatch = body.match(/<meta[^>]*name=\"description\"[^>]*content=\"([^\"]+)\"[^>]*>/);\n\n const title = titleMatch ? titleMatch[1].trim() : 'Unknown';\n const description = descMatch ? descMatch[1].trim() : 'No description';\n articles.push(\n ...extracted.map(content => ({ url: docsUrl, content, title, description, format }))\n );\n } catch (error) {\n logger.error(`Error fetching ${docsUrl}: ${error}`);\n // Skip to the next URL if an error occurs\n continue;\n }\n }\n return articles;\n }\n\n /**\n * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.\n * Loads the documents and splits them using the given document transformer.\n * Kept for compatibility with LangChain's `index()` API, which only treats a\n * source as a document loader when it has both `load()` and `loadAndSplit()`.\n * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.\n * @param splitter The document transformer (e.g. a text splitter) to apply\n * @returns {Promise<Document[]>} The loaded and split documents\n */\n async loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]> {\n if (splitter === undefined) {\n throw new Error('You must pass a text splitter to use this method.');\n }\n const docs = await this.load();\n return splitter.invoke(docs);\n }\n\n /**\n * Loads documents from Stripe Docs\n * @returns {Promise<Document[]>} Array of LangChain documents\n */\n async load(options?: StripeDocsLoadOptions): Promise<Document[]> {\n const { urls, resource, excludeResources } = options ?? {};\n const locale = options?.locale ?? 'en-US';\n const format = options?.format ?? this.format;\n const articles = urls\n ? await this.fetchArticlesFromURLs(urls, locale, format)\n : await this.fetchArticlesFromSitemap({ locale, resource, excludeResources, format });\n\n // HTML content is converted to Markdown; Markdown content is used as-is\n const nhm = new NodeHtmlMarkdown();\n\n return articles.map(\n article =>\n new Document({\n pageContent:\n article.format === 'markdown' ? article.content : nhm.translate(article.content),\n metadata: {\n source: article.url,\n title: article.title,\n description: article.description,\n },\n })\n );\n }\n}\n","import { ConsoleLogger, type Logger } from 'stripe-loaders-core';\n\nconst defaultLogger: Logger = new ConsoleLogger(false);\n\n/**\n * Extracts the body tag and its contents from an HTML string\n * @param {string} htmlString - The HTML string to extract from\n * @param {Logger} logger - Logger for diagnostic messages\n * @returns {string[]} Array of extracted body contents\n */\nexport function extractBodyFromHTML(htmlString: string, logger: Logger = defaultLogger) {\n try {\n if (!htmlString) {\n logger.log('Input HTML is null or undefined');\n return [];\n }\n\n // Use safe regular expression to extract body tags\n // Use non-greedy matching and consider nested tags\n const bodyRegex = /<body[^>]*>([\\s\\S]*?)<\\/body>/gi;\n const matches = [];\n let match;\n\n while ((match = bodyRegex.exec(htmlString)) !== null) {\n if (match[1]) {\n matches.push(match[1].trim());\n }\n }\n\n if (matches.length === 0) {\n logger.log('No body tags found');\n return [];\n }\n\n return matches;\n } catch (error) {\n logger.error(`An error occurred: ${error}`);\n return [];\n }\n}\n\n/**\n * Extracts article tags and their contents from an HTML string\n * @param {string} htmlString - The HTML string to extract from\n * @param {Logger} logger - Logger for diagnostic messages\n * @returns {string[]} Array of extracted article contents\n */\nexport function extractArticleFromHTML(htmlString: string, logger: Logger = defaultLogger) {\n try {\n // Return empty array if input is null or undefined\n if (!htmlString) {\n logger.log('Input HTML is null or undefined');\n return [];\n }\n\n const articles: string[] = [];\n\n // 1. First, look for article tags - changed to more specific regex\n // Create a function to process one article tag\n const processArticleTags = () => {\n // Modified to match only article tags\n const articleRegex = /<article(?:\\s+[^>]*)?>(.*?)<\\/article>/gis;\n let articleMatch;\n let foundArticles = false;\n\n while ((articleMatch = articleRegex.exec(htmlString)) !== null) {\n if (articleMatch[1]) {\n articles.push(articleMatch[1].trim());\n foundArticles = true;\n }\n }\n\n return foundArticles;\n };\n\n // 2. Function to find elements with main-content\n const processMainContent = () => {\n // Limited to specific tags and more specific pattern\n const mainContentRegex =\n /<(div|section|main|article)(?:\\s+[^>]*?)id=[\"']main-content[\"'](?:[^>]*?)>(.*?)<\\/\\1>/is;\n const mainContentMatch = mainContentRegex.exec(htmlString);\n\n if (mainContentMatch && mainContentMatch[2]) {\n logger.log('Found element with main-content ID');\n\n // Look for div tags with Content-article class\n const contentArticleRegex =\n /<div(?:\\s+[^>]*?)class=[\"'][^\"']*Content-article[^\"']*[\"'](?:[^>]*?)>(.*?)<\\/div>/is;\n const contentArticleMatch = contentArticleRegex.exec(mainContentMatch[2]);\n\n if (contentArticleMatch && contentArticleMatch[1]) {\n logger.log('Found content with Content-article class');\n articles.push(contentArticleMatch[1].trim());\n return true;\n }\n\n // Look for div tags with Document class\n const documentRegex =\n /<div(?:\\s+[^>]*?)class=[\"'][^\"']*Document[^\"']*[\"'](?:[^>]*?)>(.*?)<\\/div>/is;\n const documentMatch = documentRegex.exec(mainContentMatch[2]);\n\n if (documentMatch && documentMatch[1]) {\n logger.log('Found content with Document class');\n articles.push(documentMatch[1].trim());\n return true;\n }\n\n // Use all content within main-content\n logger.log('Using all content within main-content');\n articles.push(mainContentMatch[2].trim());\n return true;\n }\n\n return false;\n };\n\n // 3. Function to find content in body tag\n const processBody = () => {\n // Look for body tag - specific pattern\n const bodyRegex = /<body(?:\\s+[^>]*?)>(.*?)<\\/body>/is;\n const bodyMatch = bodyRegex.exec(htmlString);\n\n if (bodyMatch && bodyMatch[1]) {\n // Look for div tags with Content-article class\n const contentArticleRegex =\n /<div(?:\\s+[^>]*?)class=[\"'][^\"']*Content-article[^\"']*[\"'](?:[^>]*?)>(.*?)<\\/div>/is;\n const contentArticleMatch = contentArticleRegex.exec(bodyMatch[1]);\n\n if (contentArticleMatch && contentArticleMatch[1]) {\n logger.log('Found content with Content-article class in body');\n articles.push(contentArticleMatch[1].trim());\n return true;\n }\n\n // Look for div tags with Document class\n const documentRegex =\n /<div(?:\\s+[^>]*?)class=[\"'][^\"']*Document[^\"']*[\"'](?:[^>]*?)>(.*?)<\\/div>/is;\n const documentMatch = documentRegex.exec(bodyMatch[1]);\n\n if (documentMatch && documentMatch[1]) {\n logger.log('Found content with Document class in body');\n articles.push(documentMatch[1].trim());\n return true;\n }\n }\n\n logger.log('No specific content container found');\n return false;\n };\n\n // Try processing in sequence\n if (!processArticleTags()) {\n logger.log('No article tags found, trying to find main-content');\n if (!processMainContent()) {\n logger.log('No main-content found, trying to find body content');\n processBody();\n }\n }\n\n return articles;\n } catch (error) {\n logger.error(`Error extracting article from HTML: ${error}`);\n return [];\n }\n}\n\n/**\n * Builds the URL of the Markdown version of a docs.stripe.com page\n * (e.g. `https://docs.stripe.com/payments/checkout` -> `https://docs.stripe.com/payments/checkout.md?locale=ja-JP`).\n * @param {string} pageUrl - The page URL from the sitemap\n * @param {string} locale - Locale for the content\n * @returns {string} The Markdown URL\n */\nexport function toMarkdownUrl(pageUrl: string, locale: string): string {\n const url = new URL(pageUrl);\n const path = url.pathname.replace(/\\/+$/, '');\n url.pathname = path.endsWith('.md') ? path : `${path || ''}.md`;\n url.hash = '';\n url.searchParams.set('locale', locale);\n return url.toString();\n}\n\n/**\n * Extracts the title (first level-1 heading) and description (first paragraph after it)\n * from a Markdown document.\n * @param {string} markdown - The Markdown content\n * @returns {{ title: string; description: string }} Title and description\n */\nexport function parseMarkdownDocument(markdown: string): { title: string; description: string } {\n const lines = (markdown ?? '').replace(/\\r\\n?/g, '\\n').split('\\n');\n let title = 'Unknown';\n let description = 'No description';\n let index = lines.findIndex(line => /^#\\s+\\S/.test(line));\n\n if (index === -1) {\n return { title, description };\n }\n title = lines[index].replace(/^#\\s+/, '').trim();\n\n const paragraph: string[] = [];\n for (index += 1; index < lines.length; index++) {\n const line = lines[index].trim();\n if (line === '') {\n if (paragraph.length > 0) break;\n continue;\n }\n if (/^(#|```|[-*+]\\s|\\d+\\.\\s|>|\\||<)/.test(line)) {\n if (paragraph.length > 0) break;\n continue;\n }\n paragraph.push(line);\n }\n if (paragraph.length > 0) {\n description = paragraph.join(' ');\n }\n return { title, description };\n}\n","/**\n * Utility functions for URL filtering\n */\n\n/**\n * Checks if a URL matches the specified resource path\n * @param url URL to check\n * @param resource Resource path (single or multiple path segments)\n * @returns true if matches, false otherwise\n */\nexport function matchesResource(url: string, resource: string): boolean {\n // Remove hostname from URL and get only the path\n const urlPath = new URL(url).pathname;\n // Remove leading slash and get the first path segment\n const pathSegments = urlPath.split('/').filter(Boolean);\n\n if (resource.includes('/')) {\n // If resource contains multiple path segments (e.g., 'get-started/account')\n const resourceSegments = resource.split('/').filter(Boolean);\n // Check if the specified resource path starts from the beginning of the URL\n return resourceSegments.every((segment, index) => pathSegments[index] === segment);\n } else {\n // If resource is a single path segment (e.g., 'connect')\n return pathSegments[0] === resource;\n }\n}\n\n/**\n * Checks if a URL matches any of the excluded resources\n * @param url URL to check\n * @param excludeResources Array of excluded resource paths\n * @returns true if excluded, false otherwise\n */\nexport function matchesExcludeResources(url: string, excludeResources: string[]): boolean {\n if (!excludeResources || excludeResources.length === 0) {\n return false;\n }\n\n // Remove hostname from URL and get only the path\n const urlPath = new URL(url).pathname;\n // Remove leading slash and get path segments\n const pathSegments = urlPath.split('/').filter(Boolean);\n\n for (const excludeResource of excludeResources) {\n if (excludeResource.includes('/')) {\n // If excludeResource contains multiple path segments (e.g., 'get-started/account')\n const excludeSegments = excludeResource.split('/').filter(Boolean);\n // Check if the specified exclude path starts from the beginning of the URL\n const matchesExclude = excludeSegments.every(\n (segment, index) => pathSegments[index] === segment\n );\n if (matchesExclude) {\n return true;\n }\n } else {\n // If excludeResource is a single path segment (e.g., 'connect')\n if (pathSegments[0] === excludeResource) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * Function to filter URLs\n * @param urls Array of URLs to filter\n * @param resource Resource path to include (optional)\n * @param excludeResources Array of resource paths to exclude (optional)\n * @returns Filtered array of URLs\n */\nexport function filterUrls(\n urls: string[],\n resource?: string,\n excludeResources?: string[]\n): string[] {\n if (!resource && (!excludeResources || excludeResources.length === 0)) {\n return urls;\n }\n\n return urls.filter(url => {\n // If resource is specified and URL doesn't match that resource\n if (resource && !matchesResource(url, resource)) {\n return false;\n }\n\n // If exclude resources are specified and URL matches any of the excluded resources\n if (excludeResources && matchesExcludeResources(url, excludeResources)) {\n return false;\n }\n\n return true;\n });\n}\n","import {\n ConsoleLogger,\n resolveRateLimit,\n type FetchLike,\n type Logger,\n type RateLimitOptions,\n type SleepFn,\n} from 'stripe-loaders-core';\n\n/**\n * Options shared by the Stripe document loaders.\n */\nexport interface StripeLoaderOptions {\n /** Enables debug logging on the default logger. */\n debug?: boolean;\n /** Custom logger. Defaults to a console logger (`log` / `warn` only when `debug` is true). */\n logger?: Logger;\n /**\n * Rate limiting and retry settings. Requests are always sent one at a time;\n * defaults to a 1s (±250ms) delay between requests and 3 retries on 429 / 5xx.\n */\n rateLimit?: Partial<RateLimitOptions>;\n /** Custom fetch implementation (defaults to the global fetch). */\n fetch?: FetchLike;\n /** Custom sleep implementation, mainly for tests. */\n sleep?: SleepFn;\n}\n\nexport interface ResolvedLoaderOptions {\n debug: boolean;\n logger: Logger;\n rateLimit: RateLimitOptions;\n fetch?: FetchLike;\n sleep?: SleepFn;\n}\n\n/**\n * Accepts the legacy `debug` boolean or an options object.\n */\nexport function resolveLoaderOptions(\n options?: boolean | StripeLoaderOptions\n): ResolvedLoaderOptions {\n const opts: StripeLoaderOptions =\n typeof options === 'boolean' ? { debug: options } : (options ?? {});\n const debug = opts.debug ?? false;\n return {\n debug,\n logger: opts.logger ?? new ConsoleLogger(debug),\n rateLimit: resolveRateLimit(opts.rateLimit),\n fetch: opts.fetch,\n sleep: opts.sleep,\n };\n}\n","import { SitemapProcessor, fetchWithRetry, RequestPacer } from 'stripe-loaders-core';\nimport { BaseDocumentLoader } from '@langchain/core/document_loaders/base';\nimport { BaseDocumentTransformer, Document } from '@langchain/core/documents';\nimport { NodeHtmlMarkdown } from 'node-html-markdown';\nimport { extractBodyFromHTML } from './utils';\nimport {\n resolveLoaderOptions,\n type ResolvedLoaderOptions,\n type StripeLoaderOptions,\n} from './options';\n\n/**\n * Interface representing a Stripe documentation article\n */\ntype StripeDocsArticle = {\n url: string;\n content: string;\n title: string;\n description: string;\n};\n\n/**\n * Document loader for Stripe.com website content\n * Extracts content from Stripe.com pages and converts it to LangChain documents\n */\nexport class StripeComDocumentLoader extends BaseDocumentLoader {\n private readonly options: ResolvedLoaderOptions;\n\n /**\n * @param options Loader options, or a boolean to enable debug logging (legacy signature)\n */\n constructor(options?: boolean | StripeLoaderOptions) {\n super();\n this.options = resolveLoaderOptions(options);\n }\n\n /**\n * Fetches URLs from the Stripe.com sitemap\n * @param {string} resource Optional resource path to filter URLs\n * @returns {Promise<string[]>} Array of URLs from the sitemap\n */\n protected async fetchURLsFromSitemap(resource?: string) {\n return new SitemapProcessor({\n debug: this.options.debug,\n logger: this.options.logger,\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n }).fetchAndProcessSitemapIndex(\n 'https://stripe.com/sitemap/sitemap.xml',\n ['https://stripe.com/', resource].filter(Boolean).join('')\n );\n }\n\n /**\n * Fetches article content from a list of URLs\n * @param {string[]} urls Array of URLs to fetch content from\n * @param {string} locale Locale for the content\n * @returns {Promise<StripeDocsArticle[]>} Array of article objects\n */\n private async fetchArticlesFromURLs(\n urls: string[],\n locale: string\n ): Promise<StripeDocsArticle[]> {\n const { logger } = this.options;\n const pacer = new RequestPacer(this.options.rateLimit, this.options.sleep);\n const articles: StripeDocsArticle[] = [];\n\n for (const pageUrl of urls) {\n const requestUrl = `${pageUrl}?locale=${locale}`;\n try {\n await pacer.wait();\n logger.log(`Fetching ${requestUrl}`);\n const response = await fetchWithRetry(requestUrl, undefined, {\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n onRetry: ({ attempt, waitMs, reason }) =>\n logger.warn(`Retrying ${requestUrl} (attempt ${attempt}, ${reason}) in ${waitMs}ms`),\n });\n\n // Skip if HTTP status code is 400 or higher\n if (response.status >= 400) {\n logger.warn(`Skipping ${pageUrl} - HTTP status: ${response.status}`);\n continue;\n }\n\n const html = await response.text();\n const rawArticles = extractBodyFromHTML(html, logger);\n const titleMatch = html.match(/<title[^>]*>([^<]+)<\\/title>/);\n const descMatch = html.match(/<meta[^>]*name=\"description\"[^>]*content=\"([^\"]+)\"[^>]*>/);\n\n const title = titleMatch ? titleMatch[1].trim() : 'Unknown';\n const description = descMatch ? descMatch[1].trim() : 'No description';\n articles.push(\n ...rawArticles.map(content => ({ url: pageUrl, content, title, description }))\n );\n } catch (error) {\n logger.error(`Error fetching ${pageUrl}: ${error}`);\n continue;\n }\n }\n return articles;\n }\n\n /**\n * Fetches articles from the sitemap\n * @param {string} resource Optional resource path to filter URLs\n * @param {string} locale Locale for the content\n * @returns {Promise<StripeDocsArticle[]>} Array of article objects\n */\n private async fetchArticlesFromSitemap(\n resource: string | undefined,\n locale: string\n ): Promise<StripeDocsArticle[]> {\n const documentUrls = await this.fetchURLsFromSitemap(resource);\n return this.fetchArticlesFromURLs(documentUrls, locale);\n }\n\n /**\n * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.\n * Loads the documents and splits them using the given document transformer.\n * Kept for compatibility with LangChain's `index()` API, which only treats a\n * source as a document loader when it has both `load()` and `loadAndSplit()`.\n * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.\n * @param splitter The document transformer (e.g. a text splitter) to apply\n * @returns {Promise<Document[]>} The loaded and split documents\n */\n async loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]> {\n if (splitter === undefined) {\n throw new Error('You must pass a text splitter to use this method.');\n }\n const docs = await this.load();\n return splitter.invoke(docs);\n }\n\n /**\n * Loads documents from Stripe.com\n * @param {Object} options Loading options\n * @param {string} options.resource Optional resource path to filter URLs\n * @param {string} options.locale Optional locale for the content (defaults to 'en-US')\n * @param {string[]} options.urls Optional list of specific URLs to load\n * @returns {Promise<Document[]>} Array of LangChain documents\n */\n async load(options?: {\n resource?: string;\n locale?: string;\n urls?: string[];\n }): Promise<Document[]> {\n const { resource, urls } = options ?? {};\n const locale = options?.locale ?? 'en-US';\n const articles = urls\n ? await this.fetchArticlesFromURLs(urls, locale)\n : await this.fetchArticlesFromSitemap(resource, locale);\n\n // Use NodeHtmlMarkdown to convert HTML to Markdown\n const nhm = new NodeHtmlMarkdown();\n\n return articles.map(\n article =>\n new Document({\n pageContent: nhm.translate(article.content),\n metadata: {\n source: article.url,\n title: article.title,\n description: article.description,\n },\n })\n );\n }\n}\n","import {\n delayWithJitter,\n fetchStripeChangelog,\n fetchWithRetry,\n type StripeChangelogEntry,\n} from 'stripe-loaders-core';\nimport { BaseDocumentLoader } from '@langchain/core/document_loaders/base';\nimport { BaseDocumentTransformer, Document } from '@langchain/core/documents';\nimport { toMarkdownUrl } from './utils';\nimport {\n resolveLoaderOptions,\n type ResolvedLoaderOptions,\n type StripeLoaderOptions,\n} from './options';\n\nexport interface StripeChangelogLoadOptions {\n /** Locale for the changelog and detail pages (e.g. `ja-JP`). Defaults to `en-US`. */\n locale?: string;\n /** Only entries whose version date is on or after this `YYYY-MM-DD` date. */\n since?: string;\n /** Only entries from these releases (e.g. `['Endive', 'Dahlia']`). */\n releases?: string[];\n /** Only breaking changes. */\n breakingOnly?: boolean;\n /** Maximum number of entries (newest first), applied after the other filters. */\n limit?: number;\n /**\n * Fetch each entry's detail page (Markdown) and use it as the page content.\n * One request per entry, sent one at a time with the configured delay.\n * Defaults to false (the content is the changelog row only).\n */\n includeDetails?: boolean;\n}\n\nfunction entryMetadata(entry: StripeChangelogEntry) {\n return {\n source: entry.link || 'https://docs.stripe.com/changelog',\n title: entry.title,\n version: entry.version,\n date: entry.date,\n release: entry.release,\n category: entry.category,\n affectedProducts: entry.affectedProducts,\n breaking: entry.isBreakingChange,\n changeType: entry.changeType,\n };\n}\n\nfunction entrySummary(entry: StripeChangelogEntry): string {\n return [\n `# ${entry.title}`,\n '',\n `- Version: ${entry.version}`,\n ...(entry.release ? [`- Release: ${entry.release}`] : []),\n ...(entry.category ? [`- Category: ${entry.category}`] : []),\n `- Affected products: ${entry.affectedProducts.join(', ') || 'None'}`,\n `- Breaking change: ${entry.isBreakingChange ? 'Yes' : 'No'}`,\n ...(entry.link ? [`- Details: ${entry.link}`] : []),\n ].join('\\n');\n}\n\n/**\n * Document loader for the Stripe API changelog (docs.stripe.com/changelog).\n * Each changelog entry becomes one LangChain document.\n */\nexport class StripeChangelogDocumentLoader extends BaseDocumentLoader {\n private readonly options: ResolvedLoaderOptions;\n\n /**\n * @param options Loader options, or a boolean to enable debug logging\n */\n constructor(options?: boolean | StripeLoaderOptions) {\n super();\n this.options = resolveLoaderOptions(options);\n }\n\n /**\n * Fetches the changelog and returns the entries that match the filters (newest first).\n */\n async fetchEntries(options: StripeChangelogLoadOptions = {}): Promise<StripeChangelogEntry[]> {\n const locale = options.locale ?? 'en-US';\n this.options.logger.log(`Fetching Stripe changelog (${locale})`);\n const versions = await fetchStripeChangelog({\n locale,\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n });\n const releases = options.releases?.map(release => release.toLowerCase());\n return versions\n .flatMap(version => version.entries)\n .filter(\n entry =>\n (!options.since || entry.date >= options.since) &&\n (!releases ||\n (entry.release !== undefined && releases.includes(entry.release.toLowerCase()))) &&\n (!options.breakingOnly || entry.isBreakingChange)\n )\n .slice(0, Math.max(0, options.limit ?? Infinity));\n }\n\n /**\n * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.\n * Kept for compatibility with LangChain's `index()` API, which only treats a\n * source as a document loader when it has both `load()` and `loadAndSplit()`.\n */\n async loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]> {\n if (splitter === undefined) {\n throw new Error('You must pass a text splitter to use this method.');\n }\n return splitter.invoke(await this.load());\n }\n\n /**\n * Loads changelog entries as LangChain documents.\n * When `includeDetails` is true and a detail page cannot be fetched, the entry falls back\n * to the changelog row summary (and `metadata.detailsFetched` is false).\n */\n async load(options: StripeChangelogLoadOptions = {}): Promise<Document[]> {\n const locale = options.locale ?? 'en-US';\n const entries = await this.fetchEntries(options);\n\n if (!options.includeDetails) {\n return entries.map(\n entry => new Document({ pageContent: entrySummary(entry), metadata: entryMetadata(entry) })\n );\n }\n\n const documents: Document[] = [];\n const { requestDelayMs, requestJitterMs } = this.options.rateLimit;\n for (const entry of entries) {\n let detail: string | null = null;\n if (entry.link) {\n await delayWithJitter(requestDelayMs, requestJitterMs, this.options.sleep);\n let url = entry.link;\n try {\n url = toMarkdownUrl(entry.link, locale);\n this.options.logger.log(`Fetching ${url}`);\n const response = await fetchWithRetry(url, undefined, {\n rateLimit: this.options.rateLimit,\n fetch: this.options.fetch,\n sleep: this.options.sleep,\n onRetry: ({ attempt, waitMs, reason }) =>\n this.options.logger.warn(\n `Retrying ${url} (attempt ${attempt}, ${reason}) in ${waitMs}ms`\n ),\n });\n if (response.status >= 400) {\n this.options.logger.warn(\n `Skipping details of ${entry.link} - HTTP status: ${response.status}`\n );\n } else {\n detail = (await response.text()).trim() || null;\n }\n } catch (error) {\n this.options.logger.error(`Error fetching ${url}: ${error}`);\n }\n }\n documents.push(\n new Document({\n pageContent: detail ?? entrySummary(entry),\n metadata: { ...entryMetadata(entry), detailsFetched: detail !== null },\n })\n );\n }\n return documents;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,8BAA+D;AAC/D,kBAAmC;AACnC,uBAAkD;AAClD,gCAAiC;;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AAW,KAAK,QAAQ;AAAA,YACxB,OAAO,KAAK,QAAQ;AAAA,YACpB,OAAO,KAAK,QAAQ;AAAA,YACpB,SAAS,CAAC,EAAE,SAAS,QAAQ,OAAO,MAClC,KAAK,QAAQ,OAAO;AAAA,cAClB,YAAY,GAAG,aAAa,OAAO,KAAK,MAAM,QAAQ,MAAM;AAAA,YAC9D;AAAA,UACJ,CAAC;AACD,cAAI,SAAS,UAAU,KAAK;AAC1B,iBAAK,QAAQ,OAAO;AAAA,cAClB,uBAAuB,MAAM,IAAI,mBAAmB,SAAS,MAAM;AAAA,YACrE;AAAA,UACF,OAAO;AACL,sBAAU,MAAM,SAAS,KAAK,GAAG,KAAK,KAAK;AAAA,UAC7C;AAAA,QACF,SAAS,OAAO;AACd,eAAK,QAAQ,OAAO,MAAM,kBAAkB,GAAG,KAAK,KAAK,EAAE;AAAA,QAC7D;AAAA,MACF;AACA,gBAAU;AAAA,QACR,IAAI,2BAAS;AAAA,UACX,aAAa,UAAU,aAAa,KAAK;AAAA,UACzC,UAAU,EAAE,GAAG,cAAc,KAAK,GAAG,gBAAgB,WAAW,KAAK;AAAA,QACvE,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["import_stripe_loaders_core","import_stripe_loaders_core","title","description","import_stripe_loaders_core","import_base","import_documents","import_node_html_markdown","import_stripe_loaders_core","import_base","import_documents"]}
@@ -0,0 +1,185 @@
1
+ import { BaseDocumentLoader } from '@langchain/core/document_loaders/base';
2
+ import { BaseDocumentTransformer, Document } from '@langchain/core/documents';
3
+ import { Logger, RateLimitOptions, FetchLike, SleepFn, StripeChangelogEntry } from 'stripe-loaders-core';
4
+
5
+ /**
6
+ * Options shared by the Stripe document loaders.
7
+ */
8
+ interface StripeLoaderOptions {
9
+ /** Enables debug logging on the default logger. */
10
+ debug?: boolean;
11
+ /** Custom logger. Defaults to a console logger (`log` / `warn` only when `debug` is true). */
12
+ logger?: Logger;
13
+ /**
14
+ * Rate limiting and retry settings. Requests are always sent one at a time;
15
+ * defaults to a 1s (±250ms) delay between requests and 3 retries on 429 / 5xx.
16
+ */
17
+ rateLimit?: Partial<RateLimitOptions>;
18
+ /** Custom fetch implementation (defaults to the global fetch). */
19
+ fetch?: FetchLike;
20
+ /** Custom sleep implementation, mainly for tests. */
21
+ sleep?: SleepFn;
22
+ }
23
+
24
+ /**
25
+ * How page content is fetched from docs.stripe.com.
26
+ * - `html`: fetch the HTML page and convert the extracted article to Markdown (default).
27
+ * - `markdown`: fetch the Markdown version that docs.stripe.com serves at `<page>.md`.
28
+ */
29
+ type StripeDocsContentFormat = 'html' | 'markdown';
30
+ interface StripeDocsLoaderOptions extends StripeLoaderOptions {
31
+ /** Default content format for `load()`. Defaults to `html`. */
32
+ format?: StripeDocsContentFormat;
33
+ }
34
+ interface StripeDocsLoadOptions {
35
+ /** Locale for the content. Defaults to `en-US`. */
36
+ locale?: string;
37
+ /** Load only these URLs instead of the sitemap. */
38
+ urls?: string[];
39
+ /** Resource path to include (e.g. `connect`). */
40
+ resource?: string;
41
+ /** Resource paths to exclude. */
42
+ excludeResources?: string[];
43
+ /** Content format. Overrides the constructor option. */
44
+ format?: StripeDocsContentFormat;
45
+ }
46
+ /**
47
+ * Document loader for Stripe Docs website content
48
+ * Extracts content from docs.stripe.com pages and converts it to LangChain documents
49
+ */
50
+ declare class StripeDocsDocumentLoader extends BaseDocumentLoader {
51
+ private readonly options;
52
+ private readonly format;
53
+ /**
54
+ * @param options Loader options, or a boolean to enable debug logging (legacy signature)
55
+ */
56
+ constructor(options?: boolean | StripeDocsLoaderOptions);
57
+ /**
58
+ * Fetches URLs from the Stripe Docs sitemap
59
+ * @returns {Promise<string[]>} Array of URLs from the sitemap
60
+ */
61
+ protected fetchURLsFromSitemap(): Promise<string[]>;
62
+ /**
63
+ * Fetches articles from the sitemap
64
+ */
65
+ private fetchArticlesFromSitemap;
66
+ private fetchArticlesFromURLs;
67
+ /**
68
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
69
+ * Loads the documents and splits them using the given document transformer.
70
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
71
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
72
+ * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.
73
+ * @param splitter The document transformer (e.g. a text splitter) to apply
74
+ * @returns {Promise<Document[]>} The loaded and split documents
75
+ */
76
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
77
+ /**
78
+ * Loads documents from Stripe Docs
79
+ * @returns {Promise<Document[]>} Array of LangChain documents
80
+ */
81
+ load(options?: StripeDocsLoadOptions): Promise<Document[]>;
82
+ }
83
+
84
+ /**
85
+ * Document loader for Stripe.com website content
86
+ * Extracts content from Stripe.com pages and converts it to LangChain documents
87
+ */
88
+ declare class StripeComDocumentLoader extends BaseDocumentLoader {
89
+ private readonly options;
90
+ /**
91
+ * @param options Loader options, or a boolean to enable debug logging (legacy signature)
92
+ */
93
+ constructor(options?: boolean | StripeLoaderOptions);
94
+ /**
95
+ * Fetches URLs from the Stripe.com sitemap
96
+ * @param {string} resource Optional resource path to filter URLs
97
+ * @returns {Promise<string[]>} Array of URLs from the sitemap
98
+ */
99
+ protected fetchURLsFromSitemap(resource?: string): Promise<string[]>;
100
+ /**
101
+ * Fetches article content from a list of URLs
102
+ * @param {string[]} urls Array of URLs to fetch content from
103
+ * @param {string} locale Locale for the content
104
+ * @returns {Promise<StripeDocsArticle[]>} Array of article objects
105
+ */
106
+ private fetchArticlesFromURLs;
107
+ /**
108
+ * Fetches articles from the sitemap
109
+ * @param {string} resource Optional resource path to filter URLs
110
+ * @param {string} locale Locale for the content
111
+ * @returns {Promise<StripeDocsArticle[]>} Array of article objects
112
+ */
113
+ private fetchArticlesFromSitemap;
114
+ /**
115
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
116
+ * Loads the documents and splits them using the given document transformer.
117
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
118
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
119
+ * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.
120
+ * @param splitter The document transformer (e.g. a text splitter) to apply
121
+ * @returns {Promise<Document[]>} The loaded and split documents
122
+ */
123
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
124
+ /**
125
+ * Loads documents from Stripe.com
126
+ * @param {Object} options Loading options
127
+ * @param {string} options.resource Optional resource path to filter URLs
128
+ * @param {string} options.locale Optional locale for the content (defaults to 'en-US')
129
+ * @param {string[]} options.urls Optional list of specific URLs to load
130
+ * @returns {Promise<Document[]>} Array of LangChain documents
131
+ */
132
+ load(options?: {
133
+ resource?: string;
134
+ locale?: string;
135
+ urls?: string[];
136
+ }): Promise<Document[]>;
137
+ }
138
+
139
+ interface StripeChangelogLoadOptions {
140
+ /** Locale for the changelog and detail pages (e.g. `ja-JP`). Defaults to `en-US`. */
141
+ locale?: string;
142
+ /** Only entries whose version date is on or after this `YYYY-MM-DD` date. */
143
+ since?: string;
144
+ /** Only entries from these releases (e.g. `['Endive', 'Dahlia']`). */
145
+ releases?: string[];
146
+ /** Only breaking changes. */
147
+ breakingOnly?: boolean;
148
+ /** Maximum number of entries (newest first), applied after the other filters. */
149
+ limit?: number;
150
+ /**
151
+ * Fetch each entry's detail page (Markdown) and use it as the page content.
152
+ * One request per entry, sent one at a time with the configured delay.
153
+ * Defaults to false (the content is the changelog row only).
154
+ */
155
+ includeDetails?: boolean;
156
+ }
157
+ /**
158
+ * Document loader for the Stripe API changelog (docs.stripe.com/changelog).
159
+ * Each changelog entry becomes one LangChain document.
160
+ */
161
+ declare class StripeChangelogDocumentLoader extends BaseDocumentLoader {
162
+ private readonly options;
163
+ /**
164
+ * @param options Loader options, or a boolean to enable debug logging
165
+ */
166
+ constructor(options?: boolean | StripeLoaderOptions);
167
+ /**
168
+ * Fetches the changelog and returns the entries that match the filters (newest first).
169
+ */
170
+ fetchEntries(options?: StripeChangelogLoadOptions): Promise<StripeChangelogEntry[]>;
171
+ /**
172
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
173
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
174
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
175
+ */
176
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
177
+ /**
178
+ * Loads changelog entries as LangChain documents.
179
+ * When `includeDetails` is true and a detail page cannot be fetched, the entry falls back
180
+ * to the changelog row summary (and `metadata.detailsFetched` is false).
181
+ */
182
+ load(options?: StripeChangelogLoadOptions): Promise<Document[]>;
183
+ }
184
+
185
+ export { StripeChangelogDocumentLoader, type StripeChangelogLoadOptions, StripeComDocumentLoader, type StripeDocsContentFormat, StripeDocsDocumentLoader, type StripeDocsLoadOptions, type StripeDocsLoaderOptions, type StripeLoaderOptions };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,185 @@
1
- export { StripeDocsDocumentLoader } from './StripeDocsLoader';
2
- export { StripeComDocumentLoader } from './StripeComLoader';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { BaseDocumentLoader } from '@langchain/core/document_loaders/base';
2
+ import { BaseDocumentTransformer, Document } from '@langchain/core/documents';
3
+ import { Logger, RateLimitOptions, FetchLike, SleepFn, StripeChangelogEntry } from 'stripe-loaders-core';
4
+
5
+ /**
6
+ * Options shared by the Stripe document loaders.
7
+ */
8
+ interface StripeLoaderOptions {
9
+ /** Enables debug logging on the default logger. */
10
+ debug?: boolean;
11
+ /** Custom logger. Defaults to a console logger (`log` / `warn` only when `debug` is true). */
12
+ logger?: Logger;
13
+ /**
14
+ * Rate limiting and retry settings. Requests are always sent one at a time;
15
+ * defaults to a 1s (±250ms) delay between requests and 3 retries on 429 / 5xx.
16
+ */
17
+ rateLimit?: Partial<RateLimitOptions>;
18
+ /** Custom fetch implementation (defaults to the global fetch). */
19
+ fetch?: FetchLike;
20
+ /** Custom sleep implementation, mainly for tests. */
21
+ sleep?: SleepFn;
22
+ }
23
+
24
+ /**
25
+ * How page content is fetched from docs.stripe.com.
26
+ * - `html`: fetch the HTML page and convert the extracted article to Markdown (default).
27
+ * - `markdown`: fetch the Markdown version that docs.stripe.com serves at `<page>.md`.
28
+ */
29
+ type StripeDocsContentFormat = 'html' | 'markdown';
30
+ interface StripeDocsLoaderOptions extends StripeLoaderOptions {
31
+ /** Default content format for `load()`. Defaults to `html`. */
32
+ format?: StripeDocsContentFormat;
33
+ }
34
+ interface StripeDocsLoadOptions {
35
+ /** Locale for the content. Defaults to `en-US`. */
36
+ locale?: string;
37
+ /** Load only these URLs instead of the sitemap. */
38
+ urls?: string[];
39
+ /** Resource path to include (e.g. `connect`). */
40
+ resource?: string;
41
+ /** Resource paths to exclude. */
42
+ excludeResources?: string[];
43
+ /** Content format. Overrides the constructor option. */
44
+ format?: StripeDocsContentFormat;
45
+ }
46
+ /**
47
+ * Document loader for Stripe Docs website content
48
+ * Extracts content from docs.stripe.com pages and converts it to LangChain documents
49
+ */
50
+ declare class StripeDocsDocumentLoader extends BaseDocumentLoader {
51
+ private readonly options;
52
+ private readonly format;
53
+ /**
54
+ * @param options Loader options, or a boolean to enable debug logging (legacy signature)
55
+ */
56
+ constructor(options?: boolean | StripeDocsLoaderOptions);
57
+ /**
58
+ * Fetches URLs from the Stripe Docs sitemap
59
+ * @returns {Promise<string[]>} Array of URLs from the sitemap
60
+ */
61
+ protected fetchURLsFromSitemap(): Promise<string[]>;
62
+ /**
63
+ * Fetches articles from the sitemap
64
+ */
65
+ private fetchArticlesFromSitemap;
66
+ private fetchArticlesFromURLs;
67
+ /**
68
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
69
+ * Loads the documents and splits them using the given document transformer.
70
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
71
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
72
+ * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.
73
+ * @param splitter The document transformer (e.g. a text splitter) to apply
74
+ * @returns {Promise<Document[]>} The loaded and split documents
75
+ */
76
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
77
+ /**
78
+ * Loads documents from Stripe Docs
79
+ * @returns {Promise<Document[]>} Array of LangChain documents
80
+ */
81
+ load(options?: StripeDocsLoadOptions): Promise<Document[]>;
82
+ }
83
+
84
+ /**
85
+ * Document loader for Stripe.com website content
86
+ * Extracts content from Stripe.com pages and converts it to LangChain documents
87
+ */
88
+ declare class StripeComDocumentLoader extends BaseDocumentLoader {
89
+ private readonly options;
90
+ /**
91
+ * @param options Loader options, or a boolean to enable debug logging (legacy signature)
92
+ */
93
+ constructor(options?: boolean | StripeLoaderOptions);
94
+ /**
95
+ * Fetches URLs from the Stripe.com sitemap
96
+ * @param {string} resource Optional resource path to filter URLs
97
+ * @returns {Promise<string[]>} Array of URLs from the sitemap
98
+ */
99
+ protected fetchURLsFromSitemap(resource?: string): Promise<string[]>;
100
+ /**
101
+ * Fetches article content from a list of URLs
102
+ * @param {string[]} urls Array of URLs to fetch content from
103
+ * @param {string} locale Locale for the content
104
+ * @returns {Promise<StripeDocsArticle[]>} Array of article objects
105
+ */
106
+ private fetchArticlesFromURLs;
107
+ /**
108
+ * Fetches articles from the sitemap
109
+ * @param {string} resource Optional resource path to filter URLs
110
+ * @param {string} locale Locale for the content
111
+ * @returns {Promise<StripeDocsArticle[]>} Array of article objects
112
+ */
113
+ private fetchArticlesFromSitemap;
114
+ /**
115
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
116
+ * Loads the documents and splits them using the given document transformer.
117
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
118
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
119
+ * `@langchain/core` 1.x no longer provides this method on BaseDocumentLoader.
120
+ * @param splitter The document transformer (e.g. a text splitter) to apply
121
+ * @returns {Promise<Document[]>} The loaded and split documents
122
+ */
123
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
124
+ /**
125
+ * Loads documents from Stripe.com
126
+ * @param {Object} options Loading options
127
+ * @param {string} options.resource Optional resource path to filter URLs
128
+ * @param {string} options.locale Optional locale for the content (defaults to 'en-US')
129
+ * @param {string[]} options.urls Optional list of specific URLs to load
130
+ * @returns {Promise<Document[]>} Array of LangChain documents
131
+ */
132
+ load(options?: {
133
+ resource?: string;
134
+ locale?: string;
135
+ urls?: string[];
136
+ }): Promise<Document[]>;
137
+ }
138
+
139
+ interface StripeChangelogLoadOptions {
140
+ /** Locale for the changelog and detail pages (e.g. `ja-JP`). Defaults to `en-US`. */
141
+ locale?: string;
142
+ /** Only entries whose version date is on or after this `YYYY-MM-DD` date. */
143
+ since?: string;
144
+ /** Only entries from these releases (e.g. `['Endive', 'Dahlia']`). */
145
+ releases?: string[];
146
+ /** Only breaking changes. */
147
+ breakingOnly?: boolean;
148
+ /** Maximum number of entries (newest first), applied after the other filters. */
149
+ limit?: number;
150
+ /**
151
+ * Fetch each entry's detail page (Markdown) and use it as the page content.
152
+ * One request per entry, sent one at a time with the configured delay.
153
+ * Defaults to false (the content is the changelog row only).
154
+ */
155
+ includeDetails?: boolean;
156
+ }
157
+ /**
158
+ * Document loader for the Stripe API changelog (docs.stripe.com/changelog).
159
+ * Each changelog entry becomes one LangChain document.
160
+ */
161
+ declare class StripeChangelogDocumentLoader extends BaseDocumentLoader {
162
+ private readonly options;
163
+ /**
164
+ * @param options Loader options, or a boolean to enable debug logging
165
+ */
166
+ constructor(options?: boolean | StripeLoaderOptions);
167
+ /**
168
+ * Fetches the changelog and returns the entries that match the filters (newest first).
169
+ */
170
+ fetchEntries(options?: StripeChangelogLoadOptions): Promise<StripeChangelogEntry[]>;
171
+ /**
172
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
173
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
174
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
175
+ */
176
+ loadAndSplit(splitter?: BaseDocumentTransformer): Promise<Document[]>;
177
+ /**
178
+ * Loads changelog entries as LangChain documents.
179
+ * When `includeDetails` is true and a detail page cannot be fetched, the entry falls back
180
+ * to the changelog row summary (and `metadata.detailsFetched` is false).
181
+ */
182
+ load(options?: StripeChangelogLoadOptions): Promise<Document[]>;
183
+ }
184
+
185
+ export { StripeChangelogDocumentLoader, type StripeChangelogLoadOptions, StripeComDocumentLoader, type StripeDocsContentFormat, StripeDocsDocumentLoader, type StripeDocsLoadOptions, type StripeDocsLoaderOptions, type StripeLoaderOptions };