langchain-stripe-loader 0.2.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.
package/README.md CHANGED
@@ -98,6 +98,29 @@ const specificDocuments = await loader.load({
98
98
  });
99
99
  ```
100
100
 
101
+ ### Loading the Stripe API Changelog
102
+
103
+ ```typescript
104
+ import { StripeChangelogDocumentLoader } from 'langchain-stripe-loader';
105
+
106
+ const loader = new StripeChangelogDocumentLoader();
107
+
108
+ // One document per changelog entry (one request for the whole changelog)
109
+ const entries = await loader.load();
110
+
111
+ // Narrow down, and fetch each entry's detail page (Markdown) as the page content
112
+ const breaking = await loader.load({
113
+ locale: 'ja-JP',
114
+ since: '2026-01-01', // version date on or after (YYYY-MM-DD)
115
+ releases: ['Dahlia', 'Endive'],
116
+ breakingOnly: true,
117
+ limit: 20, // newest first
118
+ includeDetails: true, // one extra request per entry, sent one at a time
119
+ });
120
+ ```
121
+
122
+ Metadata: `source`, `title`, `version` (e.g. `2026-11-18.endive`), `date`, `release` (e.g. `Endive`, or a year such as `2024` for older entries), `category`, `affectedProducts`, `breaking`, `changeType` (`api` / `stripejs`), and `detailsFetched` when `includeDetails` is set. If a detail page cannot be fetched, the entry falls back to the changelog row summary.
123
+
101
124
  ## API Reference
102
125
 
103
126
  ### StripeDocsDocumentLoader
@@ -135,6 +158,23 @@ constructor(options?: boolean | StripeLoaderOptions)
135
158
 
136
159
  - `load(options?: { resource?: string; locale?: string; urls?: string[] }): Promise<Document[]>` - Load documents from Stripe.com with optional filtering. Pages that return HTTP 400 or higher are skipped
137
160
 
161
+ ### StripeChangelogDocumentLoader
162
+
163
+ Document loader for the Stripe API changelog (docs.stripe.com/changelog).
164
+
165
+ **Constructor**
166
+
167
+ ```typescript
168
+ constructor(options?: boolean | StripeLoaderOptions)
169
+ ```
170
+
171
+ - Same options as the other loaders (`debug`, `logger`, `rateLimit`, `fetch`, `sleep`)
172
+
173
+ **Methods**
174
+
175
+ - `load(options?: StripeChangelogLoadOptions): Promise<Document[]>` - `locale`, `since`, `releases`, `breakingOnly`, `limit`, `includeDetails`
176
+ - `fetchEntries(options?): Promise<StripeChangelogEntry[]>` - The filtered entries without building documents
177
+
138
178
  ## How It Works
139
179
 
140
180
  1. The loaders fetch URLs from Stripe's sitemaps
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ StripeChangelogDocumentLoader: () => StripeChangelogDocumentLoader,
23
24
  StripeComDocumentLoader: () => StripeComDocumentLoader,
24
25
  StripeDocsDocumentLoader: () => StripeDocsDocumentLoader
25
26
  });
@@ -474,8 +475,127 @@ var StripeComDocumentLoader = class extends import_base2.BaseDocumentLoader {
474
475
  );
475
476
  }
476
477
  };
478
+
479
+ // src/StripeChangelogLoader.ts
480
+ var import_stripe_loaders_core5 = require("stripe-loaders-core");
481
+ var import_base3 = require("@langchain/core/document_loaders/base");
482
+ var import_documents3 = require("@langchain/core/documents");
483
+ function entryMetadata(entry) {
484
+ return {
485
+ source: entry.link || "https://docs.stripe.com/changelog",
486
+ title: entry.title,
487
+ version: entry.version,
488
+ date: entry.date,
489
+ release: entry.release,
490
+ category: entry.category,
491
+ affectedProducts: entry.affectedProducts,
492
+ breaking: entry.isBreakingChange,
493
+ changeType: entry.changeType
494
+ };
495
+ }
496
+ function entrySummary(entry) {
497
+ return [
498
+ `# ${entry.title}`,
499
+ "",
500
+ `- Version: ${entry.version}`,
501
+ ...entry.release ? [`- Release: ${entry.release}`] : [],
502
+ ...entry.category ? [`- Category: ${entry.category}`] : [],
503
+ `- Affected products: ${entry.affectedProducts.join(", ") || "None"}`,
504
+ `- Breaking change: ${entry.isBreakingChange ? "Yes" : "No"}`,
505
+ ...entry.link ? [`- Details: ${entry.link}`] : []
506
+ ].join("\n");
507
+ }
508
+ var StripeChangelogDocumentLoader = class extends import_base3.BaseDocumentLoader {
509
+ /**
510
+ * @param options Loader options, or a boolean to enable debug logging
511
+ */
512
+ constructor(options) {
513
+ super();
514
+ this.options = resolveLoaderOptions(options);
515
+ }
516
+ /**
517
+ * Fetches the changelog and returns the entries that match the filters (newest first).
518
+ */
519
+ async fetchEntries(options = {}) {
520
+ const locale = options.locale ?? "en-US";
521
+ this.options.logger.log(`Fetching Stripe changelog (${locale})`);
522
+ const versions = await (0, import_stripe_loaders_core5.fetchStripeChangelog)({
523
+ locale,
524
+ rateLimit: this.options.rateLimit,
525
+ fetch: this.options.fetch,
526
+ sleep: this.options.sleep
527
+ });
528
+ const releases = options.releases?.map((release) => release.toLowerCase());
529
+ return versions.flatMap((version) => version.entries).filter(
530
+ (entry) => (!options.since || entry.date >= options.since) && (!releases || entry.release !== void 0 && releases.includes(entry.release.toLowerCase())) && (!options.breakingOnly || entry.isBreakingChange)
531
+ ).slice(0, Math.max(0, options.limit ?? Infinity));
532
+ }
533
+ /**
534
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
535
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
536
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
537
+ */
538
+ async loadAndSplit(splitter) {
539
+ if (splitter === void 0) {
540
+ throw new Error("You must pass a text splitter to use this method.");
541
+ }
542
+ return splitter.invoke(await this.load());
543
+ }
544
+ /**
545
+ * Loads changelog entries as LangChain documents.
546
+ * When `includeDetails` is true and a detail page cannot be fetched, the entry falls back
547
+ * to the changelog row summary (and `metadata.detailsFetched` is false).
548
+ */
549
+ async load(options = {}) {
550
+ const locale = options.locale ?? "en-US";
551
+ const entries = await this.fetchEntries(options);
552
+ if (!options.includeDetails) {
553
+ return entries.map(
554
+ (entry) => new import_documents3.Document({ pageContent: entrySummary(entry), metadata: entryMetadata(entry) })
555
+ );
556
+ }
557
+ const documents = [];
558
+ const { requestDelayMs, requestJitterMs } = this.options.rateLimit;
559
+ for (const entry of entries) {
560
+ let detail = null;
561
+ if (entry.link) {
562
+ await (0, import_stripe_loaders_core5.delayWithJitter)(requestDelayMs, requestJitterMs, this.options.sleep);
563
+ let url = entry.link;
564
+ try {
565
+ url = toMarkdownUrl(entry.link, locale);
566
+ this.options.logger.log(`Fetching ${url}`);
567
+ const response = await (0, import_stripe_loaders_core5.fetchWithRetry)(url, void 0, {
568
+ rateLimit: this.options.rateLimit,
569
+ fetch: this.options.fetch,
570
+ sleep: this.options.sleep,
571
+ onRetry: ({ attempt, waitMs, reason }) => this.options.logger.warn(
572
+ `Retrying ${url} (attempt ${attempt}, ${reason}) in ${waitMs}ms`
573
+ )
574
+ });
575
+ if (response.status >= 400) {
576
+ this.options.logger.warn(
577
+ `Skipping details of ${entry.link} - HTTP status: ${response.status}`
578
+ );
579
+ } else {
580
+ detail = (await response.text()).trim() || null;
581
+ }
582
+ } catch (error) {
583
+ this.options.logger.error(`Error fetching ${url}: ${error}`);
584
+ }
585
+ }
586
+ documents.push(
587
+ new import_documents3.Document({
588
+ pageContent: detail ?? entrySummary(entry),
589
+ metadata: { ...entryMetadata(entry), detailsFetched: detail !== null }
590
+ })
591
+ );
592
+ }
593
+ return documents;
594
+ }
595
+ };
477
596
  // Annotate the CommonJS export names for ESM import in node:
478
597
  0 && (module.exports = {
598
+ StripeChangelogDocumentLoader,
479
599
  StripeComDocumentLoader,
480
600
  StripeDocsDocumentLoader
481
601
  });
@@ -1 +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"],"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';\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 })\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AAA,UAChB,OAAO,QAAQ;AAAA,UACf,aAAa,QAAQ;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AACF;","names":["import_stripe_loaders_core","import_stripe_loaders_core","title","description","import_stripe_loaders_core","import_base","import_documents","import_node_html_markdown"]}
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,8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,gBAAM,WAAW,UAAM,4CAAe,KAAK,QAAW;AAAA,YACpD,WAAW,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"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BaseDocumentLoader } from '@langchain/core/document_loaders/base';
2
2
  import { BaseDocumentTransformer, Document } from '@langchain/core/documents';
3
- import { Logger, RateLimitOptions, FetchLike, SleepFn } from 'stripe-loaders-core';
3
+ import { Logger, RateLimitOptions, FetchLike, SleepFn, StripeChangelogEntry } from 'stripe-loaders-core';
4
4
 
5
5
  /**
6
6
  * Options shared by the Stripe document loaders.
@@ -136,4 +136,50 @@ declare class StripeComDocumentLoader extends BaseDocumentLoader {
136
136
  }): Promise<Document[]>;
137
137
  }
138
138
 
139
- export { StripeComDocumentLoader, type StripeDocsContentFormat, StripeDocsDocumentLoader, type StripeDocsLoadOptions, type StripeDocsLoaderOptions, type StripeLoaderOptions };
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,6 +1,6 @@
1
1
  import { BaseDocumentLoader } from '@langchain/core/document_loaders/base';
2
2
  import { BaseDocumentTransformer, Document } from '@langchain/core/documents';
3
- import { Logger, RateLimitOptions, FetchLike, SleepFn } from 'stripe-loaders-core';
3
+ import { Logger, RateLimitOptions, FetchLike, SleepFn, StripeChangelogEntry } from 'stripe-loaders-core';
4
4
 
5
5
  /**
6
6
  * Options shared by the Stripe document loaders.
@@ -136,4 +136,50 @@ declare class StripeComDocumentLoader extends BaseDocumentLoader {
136
136
  }): Promise<Document[]>;
137
137
  }
138
138
 
139
- export { StripeComDocumentLoader, type StripeDocsContentFormat, StripeDocsDocumentLoader, type StripeDocsLoadOptions, type StripeDocsLoaderOptions, type StripeLoaderOptions };
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.js CHANGED
@@ -450,7 +450,130 @@ var StripeComDocumentLoader = class extends BaseDocumentLoader2 {
450
450
  );
451
451
  }
452
452
  };
453
+
454
+ // src/StripeChangelogLoader.ts
455
+ import {
456
+ delayWithJitter,
457
+ fetchStripeChangelog,
458
+ fetchWithRetry as fetchWithRetry3
459
+ } from "stripe-loaders-core";
460
+ import { BaseDocumentLoader as BaseDocumentLoader3 } from "@langchain/core/document_loaders/base";
461
+ import { Document as Document3 } from "@langchain/core/documents";
462
+ function entryMetadata(entry) {
463
+ return {
464
+ source: entry.link || "https://docs.stripe.com/changelog",
465
+ title: entry.title,
466
+ version: entry.version,
467
+ date: entry.date,
468
+ release: entry.release,
469
+ category: entry.category,
470
+ affectedProducts: entry.affectedProducts,
471
+ breaking: entry.isBreakingChange,
472
+ changeType: entry.changeType
473
+ };
474
+ }
475
+ function entrySummary(entry) {
476
+ return [
477
+ `# ${entry.title}`,
478
+ "",
479
+ `- Version: ${entry.version}`,
480
+ ...entry.release ? [`- Release: ${entry.release}`] : [],
481
+ ...entry.category ? [`- Category: ${entry.category}`] : [],
482
+ `- Affected products: ${entry.affectedProducts.join(", ") || "None"}`,
483
+ `- Breaking change: ${entry.isBreakingChange ? "Yes" : "No"}`,
484
+ ...entry.link ? [`- Details: ${entry.link}`] : []
485
+ ].join("\n");
486
+ }
487
+ var StripeChangelogDocumentLoader = class extends BaseDocumentLoader3 {
488
+ /**
489
+ * @param options Loader options, or a boolean to enable debug logging
490
+ */
491
+ constructor(options) {
492
+ super();
493
+ this.options = resolveLoaderOptions(options);
494
+ }
495
+ /**
496
+ * Fetches the changelog and returns the entries that match the filters (newest first).
497
+ */
498
+ async fetchEntries(options = {}) {
499
+ const locale = options.locale ?? "en-US";
500
+ this.options.logger.log(`Fetching Stripe changelog (${locale})`);
501
+ const versions = await fetchStripeChangelog({
502
+ locale,
503
+ rateLimit: this.options.rateLimit,
504
+ fetch: this.options.fetch,
505
+ sleep: this.options.sleep
506
+ });
507
+ const releases = options.releases?.map((release) => release.toLowerCase());
508
+ return versions.flatMap((version) => version.entries).filter(
509
+ (entry) => (!options.since || entry.date >= options.since) && (!releases || entry.release !== void 0 && releases.includes(entry.release.toLowerCase())) && (!options.breakingOnly || entry.isBreakingChange)
510
+ ).slice(0, Math.max(0, options.limit ?? Infinity));
511
+ }
512
+ /**
513
+ * @deprecated Use `this.load()` and `splitter.splitDocuments()` individually.
514
+ * Kept for compatibility with LangChain's `index()` API, which only treats a
515
+ * source as a document loader when it has both `load()` and `loadAndSplit()`.
516
+ */
517
+ async loadAndSplit(splitter) {
518
+ if (splitter === void 0) {
519
+ throw new Error("You must pass a text splitter to use this method.");
520
+ }
521
+ return splitter.invoke(await this.load());
522
+ }
523
+ /**
524
+ * Loads changelog entries as LangChain documents.
525
+ * When `includeDetails` is true and a detail page cannot be fetched, the entry falls back
526
+ * to the changelog row summary (and `metadata.detailsFetched` is false).
527
+ */
528
+ async load(options = {}) {
529
+ const locale = options.locale ?? "en-US";
530
+ const entries = await this.fetchEntries(options);
531
+ if (!options.includeDetails) {
532
+ return entries.map(
533
+ (entry) => new Document3({ pageContent: entrySummary(entry), metadata: entryMetadata(entry) })
534
+ );
535
+ }
536
+ const documents = [];
537
+ const { requestDelayMs, requestJitterMs } = this.options.rateLimit;
538
+ for (const entry of entries) {
539
+ let detail = null;
540
+ if (entry.link) {
541
+ await delayWithJitter(requestDelayMs, requestJitterMs, this.options.sleep);
542
+ let url = entry.link;
543
+ try {
544
+ url = toMarkdownUrl(entry.link, locale);
545
+ this.options.logger.log(`Fetching ${url}`);
546
+ const response = await fetchWithRetry3(url, void 0, {
547
+ rateLimit: this.options.rateLimit,
548
+ fetch: this.options.fetch,
549
+ sleep: this.options.sleep,
550
+ onRetry: ({ attempt, waitMs, reason }) => this.options.logger.warn(
551
+ `Retrying ${url} (attempt ${attempt}, ${reason}) in ${waitMs}ms`
552
+ )
553
+ });
554
+ if (response.status >= 400) {
555
+ this.options.logger.warn(
556
+ `Skipping details of ${entry.link} - HTTP status: ${response.status}`
557
+ );
558
+ } else {
559
+ detail = (await response.text()).trim() || null;
560
+ }
561
+ } catch (error) {
562
+ this.options.logger.error(`Error fetching ${url}: ${error}`);
563
+ }
564
+ }
565
+ documents.push(
566
+ new Document3({
567
+ pageContent: detail ?? entrySummary(entry),
568
+ metadata: { ...entryMetadata(entry), detailsFetched: detail !== null }
569
+ })
570
+ );
571
+ }
572
+ return documents;
573
+ }
574
+ };
453
575
  export {
576
+ StripeChangelogDocumentLoader,
454
577
  StripeComDocumentLoader,
455
578
  StripeDocsDocumentLoader
456
579
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/StripeDocsLoader.ts","../src/utils.ts","../src/utils/url-filter.ts","../src/options.ts","../src/StripeComLoader.ts"],"sourcesContent":["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),\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AAA,MACd,aACE,IAAIC,UAAS;AAAA,QACX,aAAa,IAAI,UAAU,QAAQ,OAAO;AAAA,QAC1C,UAAU;AAAA,UACR,QAAQ,QAAQ;AAAA,UAChB,OAAO,QAAQ;AAAA,UACf,aAAa,QAAQ;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AACF;","names":["ConsoleLogger","title","description","SitemapProcessor","fetchWithRetry","RequestPacer","BaseDocumentLoader","Document","NodeHtmlMarkdown","BaseDocumentLoader","SitemapProcessor","RequestPacer","fetchWithRetry","NodeHtmlMarkdown","Document"]}
1
+ {"version":3,"sources":["../src/StripeDocsLoader.ts","../src/utils.ts","../src/utils/url-filter.ts","../src/options.ts","../src/StripeComLoader.ts","../src/StripeChangelogLoader.ts"],"sourcesContent":["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,SAAS,kBAAkB,gBAAgB,oBAAoB;AAC/D,SAAS,0BAA0B;AACnC,SAAkC,gBAAgB;AAClD,SAAS,wBAAwB;;;ACHjC,SAAS,qBAAkC;AAE3C,IAAM,gBAAwB,IAAI,cAAc,K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AAQ,OAAO,IAAI,YAAY,GAAG,EAAE;AACzC,gBAAM,WAAW,MAAMC,gBAAe,KAAK,QAAW;AAAA,YACpD,WAAW,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,IAAID,UAAS;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":["ConsoleLogger","title","description","SitemapProcessor","fetchWithRetry","RequestPacer","BaseDocumentLoader","Document","NodeHtmlMarkdown","BaseDocumentLoader","SitemapProcessor","RequestPacer","fetchWithRetry","NodeHtmlMarkdown","Document","fetchWithRetry","BaseDocumentLoader","Document","BaseDocumentLoader","Document","fetchWithRetry"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain-stripe-loader",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@langchain/core": "^1.4.0",
26
26
  "node-html-markdown": "^1.3.0",
27
- "stripe-loaders-core": "^0.2.0"
27
+ "stripe-loaders-core": "^0.3.0"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=20"