langchain-stripe-loader 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -9
- package/dist/index.cjs +602 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +185 -0
- package/dist/index.d.ts +185 -3
- package/dist/index.js +580 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -19
- package/dist/StripeComLoader.d.ts +0 -44
- package/dist/StripeComLoader.d.ts.map +0 -1
- package/dist/StripeDocsLoader.d.ts +0 -34
- package/dist/StripeDocsLoader.d.ts.map +0 -1
- package/dist/StripeDocsLoader.spec.d.ts +0 -2
- package/dist/StripeDocsLoader.spec.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.spec.d.ts +0 -2
- package/dist/index.spec.d.ts.map +0 -1
- package/dist/langchain-stripe-loader.cjs +0 -30
- package/dist/langchain-stripe-loader.cjs.map +0 -1
- package/dist/langchain-stripe-loader.js +0 -6922
- package/dist/langchain-stripe-loader.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/url-filter.d.ts +0 -26
- package/dist/utils/url-filter.d.ts.map +0 -1
- package/dist/utils/url-filter.spec.d.ts +0 -2
- package/dist/utils/url-filter.spec.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -13
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.spec.d.ts +0 -2
- package/dist/utils.spec.d.ts.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 wpkyoto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -40,10 +40,41 @@ const customDocuments = await loader.load({
|
|
|
40
40
|
excludeResources: ['connect/account-balances'],
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
// Fetch the Markdown version that docs.stripe.com serves at `<page>.md`
|
|
44
|
+
// (no HTML extraction; titles come without the " | Stripe Documentation" suffix)
|
|
45
|
+
const markdownDocuments = await loader.load({
|
|
46
|
+
locale: 'ja-JP',
|
|
47
|
+
resource: 'payments',
|
|
48
|
+
format: 'markdown',
|
|
49
|
+
});
|
|
50
|
+
|
|
43
51
|
// Use the documents with your LangChain application
|
|
44
52
|
console.log(`Loaded ${documents.length} documents`);
|
|
45
53
|
```
|
|
46
54
|
|
|
55
|
+
### Options: rate limiting, logging, and format
|
|
56
|
+
|
|
57
|
+
Requests are sent one at a time with a delay between them, and HTTP 429 / 5xx responses are
|
|
58
|
+
retried with exponential backoff (honouring `Retry-After`). A full sitemap contains thousands of
|
|
59
|
+
pages, so narrow it down with `resource` or `urls` where you can.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const loader = new StripeDocsDocumentLoader({
|
|
63
|
+
format: 'markdown', // default format for load(); 'html' when omitted
|
|
64
|
+
debug: true, // print log / warn messages with the default console logger
|
|
65
|
+
logger: myLogger, // any object with log / warn / error; defaults to console
|
|
66
|
+
rateLimit: {
|
|
67
|
+
requestDelayMs: 1000, // delay between requests (default 1000)
|
|
68
|
+
requestJitterMs: 500, // random variation, ±half of this value (default 500)
|
|
69
|
+
maxRetries: 3, // retries for 429 / 5xx and network errors (default 3)
|
|
70
|
+
backoffBaseMs: 1000, // exponential backoff base (default 1000)
|
|
71
|
+
backoffMaxMs: 30000, // upper bound for a single wait (default 30000)
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`new StripeDocsDocumentLoader(true)` (debug only) is still supported.
|
|
77
|
+
|
|
47
78
|
### Loading Content from Stripe.com Website
|
|
48
79
|
|
|
49
80
|
```typescript
|
|
@@ -67,6 +98,29 @@ const specificDocuments = await loader.load({
|
|
|
67
98
|
});
|
|
68
99
|
```
|
|
69
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
|
+
|
|
70
124
|
## API Reference
|
|
71
125
|
|
|
72
126
|
### StripeDocsDocumentLoader
|
|
@@ -76,14 +130,16 @@ Document loader for Stripe's official documentation (docs.stripe.com).
|
|
|
76
130
|
**Constructor**
|
|
77
131
|
|
|
78
132
|
```typescript
|
|
79
|
-
constructor(
|
|
133
|
+
constructor(options?: boolean | StripeDocsLoaderOptions)
|
|
80
134
|
```
|
|
81
135
|
|
|
82
|
-
- `
|
|
136
|
+
- `options.format`: `'html'` (default) or `'markdown'`
|
|
137
|
+
- `options.debug`, `options.logger`, `options.rateLimit`, `options.fetch`, `options.sleep`: see "Options" above
|
|
138
|
+
- Passing a boolean sets `debug` (legacy signature)
|
|
83
139
|
|
|
84
140
|
**Methods**
|
|
85
141
|
|
|
86
|
-
- `load(locale
|
|
142
|
+
- `load(options?: { locale?: string; urls?: string[]; resource?: string; excludeResources?: string[]; format?: 'html' | 'markdown' }): Promise<Document[]>` - Load documents from Stripe Docs. `locale` defaults to `en-US`
|
|
87
143
|
|
|
88
144
|
### StripeComDocumentLoader
|
|
89
145
|
|
|
@@ -92,21 +148,39 @@ Document loader for Stripe's main website (stripe.com).
|
|
|
92
148
|
**Constructor**
|
|
93
149
|
|
|
94
150
|
```typescript
|
|
95
|
-
constructor(
|
|
151
|
+
constructor(options?: boolean | StripeLoaderOptions)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- `options.debug`, `options.logger`, `options.rateLimit`, `options.fetch`, `options.sleep`: see "Options" above
|
|
155
|
+
- Passing a boolean sets `debug` (legacy signature)
|
|
156
|
+
|
|
157
|
+
**Methods**
|
|
158
|
+
|
|
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
|
|
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)
|
|
96
169
|
```
|
|
97
170
|
|
|
98
|
-
- `debug
|
|
171
|
+
- Same options as the other loaders (`debug`, `logger`, `rateLimit`, `fetch`, `sleep`)
|
|
99
172
|
|
|
100
173
|
**Methods**
|
|
101
174
|
|
|
102
|
-
- `load(options?:
|
|
175
|
+
- `load(options?: StripeChangelogLoadOptions): Promise<Document[]>` - `locale`, `since`, `releases`, `breakingOnly`, `limit`, `includeDetails`
|
|
176
|
+
- `fetchEntries(options?): Promise<StripeChangelogEntry[]>` - The filtered entries without building documents
|
|
103
177
|
|
|
104
178
|
## How It Works
|
|
105
179
|
|
|
106
180
|
1. The loaders fetch URLs from Stripe's sitemaps
|
|
107
|
-
2.
|
|
108
|
-
3.
|
|
109
|
-
4.
|
|
181
|
+
2. Each page is downloaded one at a time, with a delay between requests and retries on 429 / 5xx
|
|
182
|
+
3. With `format: 'html'`, relevant content is extracted using regex patterns and converted to Markdown using node-html-markdown
|
|
183
|
+
4. With `format: 'markdown'` (docs.stripe.com only), the `<page>.md` Markdown is used as-is
|
|
110
184
|
5. Content is wrapped in LangChain Document objects with metadata
|
|
111
185
|
|
|
112
186
|
## Dependencies
|