@mrscraper/sdk 3.0.0 → 4.0.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![](./mrscraper.jpeg)
4
4
 
5
- Node.js SDK for [MrScraper](https://mrscraper.com) content fetching and Google search results. Requires Node.js 18 or newer and ES modules.
5
+ Node.js SDK for [MrScraper](https://mrscraper.com) HTML, Markdown, screenshots, structured extraction, sitemap discovery, brand scraping, Google search results, and account status. Requires Node.js 18 or newer and ES modules.
6
6
 
7
7
  ## Install and authenticate
8
8
 
@@ -11,60 +11,146 @@ npm install @mrscraper/sdk
11
11
  export MRSCRAPER_API_TOKEN="YOUR_TOKEN"
12
12
  ```
13
13
 
14
- The SDK reads `MRSCRAPER_API_TOKEN` automatically. You can instead pass `token` in either call's options object. Both functions are async and return `{ status_code, data, headers }`. JSON responses are parsed; other responses are returned as text in `data`.
14
+ The SDK reads `MRSCRAPER_API_TOKEN` automatically. You can instead pass `token` in any call's options object. All functions are async and return `{ status_code, data, headers }`. JSON responses are parsed, HTML and other text remain strings, and images and ZIP files are returned as Node.js `Buffer` values in `data`.
15
15
 
16
- ## Version 3 migration
16
+ ## Service functions
17
17
 
18
- Version 3 renames the public functions and their option types. Update your imports and calls:
18
+ These functions match the Python SDK's format-specific services. Each function selects its own output and agent; public options do not include `html`, `markdown`, or `screenshot` flags.
19
19
 
20
- | Version 2 | Version 3 |
21
- |-----------|-----------|
22
- | `fetch_content(url, options)` | `scraper_api(url, options)` |
23
- | `google_serp(queryOrUrl, options)` | `web_search(queryOrUrl, options)` |
24
- | `FetchContentOptions` | `ScraperApiOptions` |
25
- | `GoogleSerpOptions` | `WebSearchOptions` |
20
+ | Function | Request and defaults |
21
+ |----------|----------------------|
22
+ | `scraper_html(url, options)` | POST with `html=true`; Markdown and screenshot flags omitted |
23
+ | `scraper_markdown(url, options)` | POST with `markdown=true`; HTML and screenshot flags omitted |
24
+ | `get_screenshot(url, options)` | GET with `screenshot=full`, `browserRendering=true`, `waitUntil=domcontentloaded`, and `timeout=300` |
25
+ | `scraper_json(url, options)` | POST with `html=true`, `agent=general`, and a prompt |
26
+ | `scraper_multiple_page(url, options)` | POST with `agent=listing`, a prompt, and `maxPages=3`; output flags omitted |
27
+ | `scraper_sitemap(url, options)` | POST with `agent=map`, `maxDepth=2`, `maxPages=3`, and `limit=1000`; output flags omitted |
28
+ | `scrape_brand(url, options)` | POST with `action=brand-scraping` and `bundle=clean`; output flags omitted |
29
+ | `get_brand(job_id, options)` | GET `/neo/brand?id=...`; optional `output` downloads an artifact |
30
+ | `web_search(queryOrUrl, options)` | Fetch Google search results |
31
+ | `account(options)` | Read account identity, subscription, quota, and rate limits |
26
32
 
27
- The version 2 names are no longer exported. Request options, API endpoints, and the `{ status_code, data, headers }` response wrapper are unchanged.
33
+ ### Migrating from v3 to v4
28
34
 
29
- If upgrading from version 1, `fetchHtml`, `googleSerp`, and all AI scraper, manual scraper, and results methods were removed in version 2. Use the version 3 functions above; they return a response wrapper instead of only the API payload.
35
+ Version 4 removes the public `scraper_api` function and `ScraperApiOptions` type. Replace calls with the appropriate service:
30
36
 
31
- ## Fetch content
37
+ ```typescript
38
+ import { scraper_html, scraper_markdown, get_screenshot } from "@mrscraper/sdk";
39
+
40
+ const url = "https://example.com";
41
+ // Previously: scraper_api(url, { html: true })
42
+ const html = await scraper_html(url);
43
+ // Previously: scraper_api(url, { html: false, markdown: true })
44
+ const markdown = await scraper_markdown(url);
45
+ // Previously: scraper_api(url, { screenshot: true })
46
+ const screenshot = await get_screenshot(url);
47
+ ```
48
+
49
+ Import these functions from `@mrscraper/sdk`. Use `ScraperOptions` for shared page controls and the service option types below for specialized controls. To retrieve more than one format, call its service separately. Screenshot requests now use GET and default to full-page capture; set `full_page: false` for a viewport screenshot. Binary data is preserved as a `Buffer`.
50
+
51
+ For older versions, `fetch_content` maps to `scraper_html` and `google_serp` maps to `web_search`. Legacy version 1 names such as `fetchHtml` and `googleSerp` are not exported. The response wrapper remains `{ status_code, data, headers }`.
52
+
53
+ ## HTML and Markdown
32
54
 
33
55
  ```typescript
34
- import { scraper_api } from "@mrscraper/sdk";
56
+ import { scraper_html, scraper_markdown } from "@mrscraper/sdk";
35
57
 
36
- const result = await scraper_api("https://example.com", {
37
- html: true,
38
- markdown: true,
39
- screenshot: true,
40
- super: true,
41
- });
42
- console.log(result.status_code, result.data);
58
+ const html = await scraper_html("https://example.com", { super: true });
59
+ const markdown = await scraper_markdown("https://example.com", { home_page: true });
60
+ console.log(html.data, markdown.data);
43
61
  ```
44
62
 
45
- `scraper_api` sends `POST https://api.mrscraper.com/`. The JSON body contains `url`, `maxRetries`, and optional `tokenCap`. Page settings and the token are URL query parameters. Setting `screenshot: true` also sends `browserRendering=true`, even if `browser_rendering` is false.
63
+ Scraping requests use `https://api.mrscraper.com/`. For HTML, Markdown, JSON extraction, multiple pages, and sitemap, the JSON body contains `url`, `maxRetries`, optional `tokenCap`, and the service's extraction fields. Other page controls are query parameters. Screenshot and brand creation requests put `url`, `maxRetries`, and optional `tokenCap` in the query; the brand creation JSON body contains only `url`.
64
+
65
+ ### Shared scraping options
46
66
 
47
67
  | Option | Default | Description |
48
68
  |--------|---------|-------------|
49
- | `url` | Required first argument | Page URL |
50
69
  | `token` | Environment variable | API token override |
51
- | `html`, `markdown` | `true`, `false` | Request HTML, Markdown, or both |
52
- | `timeout` | `120` | Page timeout in seconds, from 1 to 300; HTTP timeout is 30 seconds longer |
70
+ | `timeout` | `120` (`300` for screenshots) | Page timeout in seconds, from 1 to 300; HTTP timeout is 30 seconds longer |
53
71
  | `geo_code`, `proxy_country` | `"US"`, unset | Geolocation and optional proxy country |
54
- | `browser_rendering` | unset | `true` to force a browser, `false` to disable it, unset for automatic fallback |
55
- | `screenshot` | `false` | Capture a screenshot and force browser rendering |
72
+ | `browser_rendering` | unset | `true` to force a browser, `false` to disable it, unset for automatic fallback; unavailable for screenshots, which always enable rendering |
56
73
  | `super` | `false` | Enable real device routing |
57
74
  | `use_proxy`, `proxy` | `true`, unset | Allow a proxy or supply `username:password@host:port` |
58
75
  | `home_page` | `false` | Visit the site's root first; sends `warmStart=true` |
59
76
  | `wait_for_selector` | unset | Wait for a CSS selector |
77
+ | `wait_until` | unset (`"domcontentloaded"` for screenshots) | Browser navigation wait condition; `null` omits it |
60
78
  | `block_resources`, `bypass_proxy` | `false`, `false` | Block resources or enable proxy bypass behavior |
61
79
  | `cookie_jar`, `headers` | unset | Cookie configuration and target request headers; `headers` accepts an object or JSON string |
62
- | `max_retries`, `token_cap` | `3`, unset | Retry count and optional token budget |
80
+ | `max_retries`, `token_cap` | `3`, unset | Nonnegative integer retry count and optional token budget |
63
81
  | `stream` | unset | Request a streamed response, buffered into the normal return value |
64
82
  | `discard_token_secret` | `""` | Value for the `x-discard-token-secret` API header |
65
83
 
66
84
  Unset optional query parameters are omitted. Explicit `false`, `0`, and empty strings are preserved where the Python client sends them.
67
85
 
86
+ ## Screenshots
87
+
88
+ ```typescript
89
+ import { writeFile } from "node:fs/promises";
90
+ import { get_screenshot } from "@mrscraper/sdk";
91
+
92
+ const result = await get_screenshot("https://example.com", {
93
+ full_page: true, // Default; false sends screenshot=true for the viewport.
94
+ token_cap: 30,
95
+ });
96
+ if (Buffer.isBuffer(result.data)) await writeFile("page.png", result.data);
97
+ else console.log(result.data); // The API may also return JSON metadata.
98
+ ```
99
+
100
+ ## JSON and multiple-page extraction
101
+
102
+ ```typescript
103
+ import { scraper_json, scraper_multiple_page } from "@mrscraper/sdk";
104
+
105
+ const page = await scraper_json("https://mrscraper.com/pricing", {
106
+ prompt: "Extract all plan names and prices.",
107
+ super: true,
108
+ });
109
+ const listings = await scraper_multiple_page("https://books.toscrape.com", {
110
+ prompt: "Extract each book title and price.",
111
+ max_pages: 3,
112
+ });
113
+ console.log(page.data, listings.data);
114
+ ```
115
+
116
+ `ScraperJsonOptions.prompt` defaults to `"Extract all data as complete as possible."`. `ScraperMultiplePageOptions.prompt` defaults to `"Extract all entry data as complete as possible."`, and `max_pages` must be a positive integer. These become `prompt` and `maxPages` in the JSON body.
117
+
118
+ ## Sitemap discovery
119
+
120
+ ```typescript
121
+ import { scraper_sitemap } from "@mrscraper/sdk";
122
+
123
+ const result = await scraper_sitemap("https://docs.mrscraper.com", {
124
+ max_depth: 2,
125
+ max_pages: 3,
126
+ limit: 1000,
127
+ include_patterns: String.raw`/products/.*`,
128
+ exclude_patterns: String.raw`/blog/.*`,
129
+ });
130
+ console.log(result.data);
131
+ ```
132
+
133
+ `ScraperSitemapOptions` maps `max_depth`, `max_pages`, `include_patterns`, and `exclude_patterns` to `maxDepth`, `maxPages`, `includePatterns`, and `excludePatterns` in the JSON body. Pattern strings are forwarded unchanged; unset or `null` patterns are omitted. `max_depth` must be a nonnegative integer; `max_pages` and `limit` must be positive integers.
134
+
135
+ ## Brand scraping and downloads
136
+
137
+ ```typescript
138
+ import { writeFile } from "node:fs/promises";
139
+ import { scrape_brand, get_brand } from "@mrscraper/sdk";
140
+
141
+ const created = await scrape_brand("https://www.brooksrunning.com", { bundle: "clean" });
142
+ console.log(created.data); // Read the job ID from the API response.
143
+
144
+ const jobId = "JOB_ID_FROM_RESPONSE";
145
+ const job = await get_brand(jobId);
146
+ console.log(job.data); // Check job status before downloading.
147
+
148
+ const download = await get_brand(jobId, { output: "bundle" });
149
+ if (Buffer.isBuffer(download.data)) await writeFile("brand.zip", download.data);
150
+ ```
151
+
152
+ `ScrapeBrandOptions.bundle` accepts `"clean"` (default), `"full"`, or `"none"`. `GetBrandOptions` accepts `token`, `timeout` (default `600` seconds), and optional `output`: `"html"`, `"bundle"`, `"screenshot"`, or `"screenshot_full"`. Omit `output` to read the job. HTML is text; ZIP and image downloads are `Buffer` values. The SDK makes one request per call and does not poll for completion.
153
+
68
154
  ## Web search
69
155
 
70
156
  ```typescript
@@ -93,16 +179,35 @@ console.log(result.data);
93
179
  | `render_js` | `false` | Render JavaScript features |
94
180
  | `timeout` | `600` | HTTP request timeout in seconds |
95
181
 
182
+ ## Account status
183
+
184
+ ```typescript
185
+ import { account } from "@mrscraper/sdk";
186
+
187
+ const result = await account(); // Optional: { token: "YOUR_TOKEN", timeout: 30 }
188
+ console.log(result.data.subscription_status);
189
+ console.log(result.data.token_remaining);
190
+ console.log(result.data.user.email);
191
+ ```
192
+
193
+ `account` sends `GET https://api.app.mrscraper.com/api/v1/subscription-accounts`
194
+ with Bearer and `x-api-token` authentication. The timeout defaults to 30 seconds
195
+ and must be positive. `data` is an `AccountSummary` with `subscription_status`,
196
+ `enterprise`, `token_usage`, `token_limit`, `token_remaining`, `usage_percent`,
197
+ `rate_limit`, `rate_ttl`, `auto_renew`, `ends_at`, and `user` (`name`, `email`,
198
+ `verified`). Remaining tokens are clamped to zero when usage exceeds the limit.
199
+ API keys, billing identifiers, and sensitive response headers are excluded.
200
+
96
201
  ## Errors and types
97
202
 
98
- Both functions reject with `MrScraperError` for API, authentication, network, and timeout errors. `status` contains the HTTP status for API errors and is `undefined` for network errors. Invalid options throw `TypeError` or `RangeError`.
203
+ All functions reject with `MrScraperError` for API, authentication, network, and timeout errors. `status` contains the HTTP status for API errors and is `undefined` for network errors. Invalid options throw `TypeError` or `RangeError`.
99
204
 
100
205
  ```typescript
101
- import { scraper_api, MrScraperError } from "@mrscraper/sdk";
102
- import type { ScraperApiOptions, WebSearchOptions, MrScraperResponse } from "@mrscraper/sdk";
206
+ import { scraper_html, MrScraperError } from "@mrscraper/sdk";
207
+ import type { ScraperOptions, ScraperSitemapOptions, MrScraperResponse } from "@mrscraper/sdk";
103
208
 
104
209
  try {
105
- const result: MrScraperResponse = await scraper_api("https://example.com");
210
+ const result: MrScraperResponse = await scraper_html("https://example.com");
106
211
  console.log(result.data);
107
212
  } catch (error) {
108
213
  if (error instanceof MrScraperError) {
@@ -121,31 +226,99 @@ npm test
121
226
  npm run build
122
227
  ```
123
228
 
124
- `npm test` uses mocked HTTP responses and does not require an API token.
229
+ `npm test` builds the SDK, checks TypeScript usage (including rejected output flags), and runs response-mock and local HTTP contract tests. It does not call the live API or require a token.
230
+
231
+ ## Manual tests with a real token
232
+
233
+ Run these commands from a source checkout. Build the SDK and configure your API token:
234
+
235
+ ```bash
236
+ npm run build
237
+ export MRSCRAPER_API_TOKEN="YOUR_TOKEN"
238
+ ```
239
+
240
+ Check account status directly through the built SDK:
241
+
242
+ ```bash
243
+ node --input-type=module <<'NODE'
244
+ import { account } from "./dist/index.js";
245
+
246
+ const result = await account();
247
+ console.log(result.status_code, result.data);
248
+ NODE
249
+ ```
250
+
251
+ Retrieve Markdown:
252
+
253
+ ```bash
254
+ node --input-type=module <<'NODE'
255
+ import { scraper_markdown } from "./dist/index.js";
256
+
257
+ const result = await scraper_markdown("https://example.com");
258
+ console.log(result.status_code, result.data);
259
+ NODE
260
+ ```
261
+
262
+ Start a brand-scraping job:
263
+
264
+ ```bash
265
+ node --input-type=module <<'NODE'
266
+ import { scrape_brand } from "./dist/index.js";
267
+
268
+ const result = await scrape_brand("https://example.com");
269
+ console.log(result.status_code, result.data);
270
+ NODE
271
+ ```
272
+
273
+ Use the job ID from the response with `get_brand` as shown in [Brand scraping and downloads](#brand-scraping-and-downloads). These commands make live API requests, print the HTTP status and response data, and exit with a nonzero status on unhandled errors. They do not depend on the local `file.js` helper. To run the other service examples from a checkout, replace imports from `@mrscraper/sdk` with `./dist/index.js`.
125
274
 
126
275
  ## Publish manually to npm
127
276
 
128
- Version `3.0.0` is a major release because the public API names changed. Both `package.json` and `package-lock.json` already contain this version.
277
+ The removal of `scraper_api` and `ScraperApiOptions` is a breaking change. The first release with these services targets **4.0.0**. Check the registry before preparing the release; the target version must not already be published.
129
278
 
130
- From the repository root, verify the package before publishing:
279
+ Update `package.json` and `package-lock.json` together, run the tests, and preview the package. Run the version command once; skip it if both files already specify `4.0.0`:
131
280
 
132
281
  ```bash
282
+ npm view @mrscraper/sdk versions --json
283
+ npm version 4.0.0 --no-git-tag-version
133
284
  npm ci
134
285
  npm test
135
286
  npm publish --dry-run --access public
136
287
  ```
137
288
 
138
- Review the dry-run file list, then log in with an npm account that has publishing access to `@mrscraper/sdk`:
289
+ Continue only after the tests and dry run succeed. The package should include `dist/`, `README.md`, `LICENSE`, `mrscraper.jpeg`, and `package.json`. The `files` list in `package.json` excludes the local `file.js` helper from the npm package.
290
+
291
+ Stage the release files explicitly to keep changes to `file.js` local:
292
+
293
+ ```bash
294
+ git add README.md package.json package-lock.json \
295
+ src/api.ts src/index.ts \
296
+ tests/api.test.mjs tests/scraping.test.mjs tests/types.test.ts
297
+ git restore --staged -- file.js
298
+ git diff --cached --name-only
299
+ git diff --cached --check
300
+ ```
301
+
302
+ Confirm that `file.js` does not appear in the staged file list, then commit and push the current branch:
303
+
304
+ ```bash
305
+ git commit -m "feat!: add format-specific scraping services"
306
+ git push -u origin HEAD
307
+ ```
308
+
309
+ The uncommitted changes in `file.js` remain on your machine; its previously committed version remains in Git. If the repository uses pull requests, complete its review and merge process before publishing the release.
310
+
311
+ Log in with an npm account that has publishing access to `@mrscraper/sdk`, publish, and verify that `latest` points to `4.0.0`:
139
312
 
140
313
  ```bash
141
314
  npm login
142
315
  npm whoami
143
316
  npm publish --access public
144
- npm view @mrscraper/sdk@3.0.0 version
317
+ npm view @mrscraper/sdk version
145
318
  npm view @mrscraper/sdk dist-tags --json
146
319
  ```
147
320
 
148
- Complete npm's browser login and two-factor authentication prompts. The `prepublishOnly` script cleans and rebuilds `dist` before publishing. A successful publish makes `3.0.0` available under the `latest` tag by default. Each package version can only be published once.
321
+ Complete npm's browser login and two-factor authentication prompts. The `prepublishOnly` script cleans and rebuilds `dist` before publishing. A successful publish uses the `latest` tag by default. Each package version can only be published once. For later releases, select a new unpublished version and update the release commands accordingly.
149
322
 
150
323
  See npm's [scoped package publishing guide](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages/) and [semantic versioning guide](https://docs.npmjs.com/about-semantic-versioning/).
151
324
 
package/dist/api.d.ts CHANGED
@@ -8,11 +8,33 @@ export interface MrScraperResponse<T = unknown> {
8
8
  data: T;
9
9
  headers: Record<string, string>;
10
10
  }
11
- export interface ScraperApiOptions {
11
+ export interface AccountOptions {
12
+ /** Overrides MRSCRAPER_API_TOKEN for this call. */
13
+ token?: string;
14
+ /** HTTP request timeout in seconds. Defaults to 30. */
15
+ timeout?: number;
16
+ }
17
+ export interface AccountSummary {
18
+ subscription_status: string | null;
19
+ enterprise: boolean;
20
+ token_usage: number;
21
+ token_limit: number;
22
+ token_remaining: number;
23
+ usage_percent: number;
24
+ rate_limit: number;
25
+ rate_ttl: number;
26
+ auto_renew: boolean;
27
+ ends_at: string | null;
28
+ user: {
29
+ name: string | null;
30
+ email: string | null;
31
+ verified: boolean;
32
+ };
33
+ }
34
+ /** Shared page, browser, proxy, and retry controls. Output is selected by the function. */
35
+ export interface ScraperOptions {
12
36
  /** Overrides MRSCRAPER_API_TOKEN for this call. */
13
37
  token?: string;
14
- html?: boolean;
15
- markdown?: boolean;
16
38
  /** Page timeout in seconds, from 1 to 300. */
17
39
  timeout?: number;
18
40
  geo_code?: string;
@@ -23,8 +45,8 @@ export interface ScraperApiOptions {
23
45
  use_proxy?: boolean;
24
46
  proxy?: string | null;
25
47
  wait_for_selector?: string | null;
48
+ wait_until?: string | null;
26
49
  home_page?: boolean;
27
- screenshot?: boolean;
28
50
  bypass_proxy?: boolean;
29
51
  cookie_jar?: string | null;
30
52
  /** Headers forwarded to the target site, not the API request. */
@@ -34,6 +56,43 @@ export interface ScraperApiOptions {
34
56
  stream?: boolean | null;
35
57
  discard_token_secret?: string;
36
58
  }
59
+ export interface ScreenshotOptions extends Omit<ScraperOptions, "browser_rendering"> {
60
+ /** Defaults to true (screenshot=full); false captures the viewport. */
61
+ full_page?: boolean;
62
+ }
63
+ export interface ScraperJsonOptions extends ScraperOptions {
64
+ /** Defaults to "Extract all data as complete as possible." */
65
+ prompt?: string;
66
+ }
67
+ export interface ScraperMultiplePageOptions extends ScraperOptions {
68
+ /** Defaults to "Extract all entry data as complete as possible." */
69
+ prompt?: string;
70
+ /** Positive integer, defaults to 3. */
71
+ max_pages?: number;
72
+ }
73
+ export interface ScraperSitemapOptions extends ScraperOptions {
74
+ /** Nonnegative integer, defaults to 2. */
75
+ max_depth?: number;
76
+ /** Positive integer, defaults to 3. */
77
+ max_pages?: number;
78
+ /** Positive integer, defaults to 1000. */
79
+ limit?: number;
80
+ /** Pattern strings are forwarded unchanged; unset patterns are omitted. */
81
+ include_patterns?: string | null;
82
+ exclude_patterns?: string | null;
83
+ }
84
+ export type BrandBundle = "clean" | "full" | "none";
85
+ export type BrandOutput = "html" | "bundle" | "screenshot" | "screenshot_full";
86
+ export interface ScrapeBrandOptions extends ScraperOptions {
87
+ /** Defaults to clean. */
88
+ bundle?: BrandBundle;
89
+ }
90
+ export interface GetBrandOptions {
91
+ token?: string;
92
+ output?: BrandOutput | null;
93
+ /** HTTP timeout in seconds, defaults to 600. */
94
+ timeout?: number;
95
+ }
37
96
  export interface WebSearchOptions {
38
97
  /** Overrides MRSCRAPER_API_TOKEN for this call. */
39
98
  token?: string;
@@ -47,8 +106,24 @@ export interface WebSearchOptions {
47
106
  /** HTTP request timeout in seconds. */
48
107
  timeout?: number;
49
108
  }
50
- /** Fetch a page through the MrScraper API. Options mirror the Python client's page-fetch options. */
51
- export declare function scraper_api<T = unknown>(url: string, options?: ScraperApiOptions): Promise<MrScraperResponse<T>>;
109
+ /** Check account identity, subscription, quota, and rate limits. */
110
+ export declare function account(options?: AccountOptions): Promise<MrScraperResponse<AccountSummary>>;
111
+ /** Fetch HTML. Only html=true is sent; other output flags are omitted. */
112
+ export declare function scraper_html<T = unknown>(url: string, options?: ScraperOptions): Promise<MrScraperResponse<T>>;
113
+ /** Fetch Markdown. Only markdown=true is sent; other output flags are omitted. */
114
+ export declare function scraper_markdown<T = unknown>(url: string, options?: ScraperOptions): Promise<MrScraperResponse<T>>;
115
+ /** Capture a screenshot using GET. Images are returned as Buffer in data. */
116
+ export declare function get_screenshot<T = unknown>(url: string, options?: ScreenshotOptions): Promise<MrScraperResponse<T>>;
117
+ /** Extract structured JSON with the general agent and html=true. */
118
+ export declare function scraper_json<T = unknown>(url: string, options?: ScraperJsonOptions): Promise<MrScraperResponse<T>>;
119
+ /** Extract entries across multiple pages using the listing agent. */
120
+ export declare function scraper_multiple_page<T = unknown>(url: string, options?: ScraperMultiplePageOptions): Promise<MrScraperResponse<T>>;
121
+ /** Discover URLs with the map agent; pattern strings are preserved unchanged. */
122
+ export declare function scraper_sitemap<T = unknown>(url: string, options?: ScraperSitemapOptions): Promise<MrScraperResponse<T>>;
123
+ /** Start a brand-scraping job; use the returned job ID with get_brand. */
124
+ export declare function scrape_brand<T = unknown>(url: string, options?: ScrapeBrandOptions): Promise<MrScraperResponse<T>>;
125
+ /** Read a brand job or download HTML, a ZIP bundle, or a screenshot. */
126
+ export declare function get_brand<T = unknown>(job_id: string, options?: GetBrandOptions): Promise<MrScraperResponse<T>>;
52
127
  /** Fetch Google search results. Accepts query text or a Google search URL. */
53
128
  export declare function web_search<T = unknown>(url: string, options?: WebSearchOptions): Promise<MrScraperResponse<T>>;
54
129
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;I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AAsB,eAAe,CAAC,CAAC,GAAG,OAAO,EAC/C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAC/C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAM/B;AAED,0EAA0E;AAC1E,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAE/B;AAED,wEAAwE;AACxE,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACzC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAY/B;AA0BD,8EAA8E;AAC9E,wBAAsB,UAAU,CAAC,CAAC,GAAG,OAAO,EAC1C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAkC/B"}
package/dist/api.js CHANGED
@@ -27,27 +27,37 @@ function setIfPresent(params, key, value) {
27
27
  params.set(key, typeof value === "boolean" ? String(value) : String(value));
28
28
  }
29
29
  }
30
- async function post(url, body, headers, timeoutSeconds, token) {
30
+ async function request(method, url, body, headers, timeoutSeconds, token) {
31
31
  const controller = new AbortController();
32
32
  const timer = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
33
33
  try {
34
34
  const response = await fetch(url, {
35
- method: "POST",
35
+ method,
36
36
  headers,
37
- body: JSON.stringify(body),
37
+ body: body === undefined ? undefined : JSON.stringify(body),
38
38
  signal: controller.signal,
39
39
  });
40
40
  if (response.status === 401) {
41
41
  throw new MrScraperError("Unauthorized or invalid token. Please go to https://app.mrscraper.com to get your token.", 401);
42
42
  }
43
- const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
44
- const data = contentType.includes("application/json")
45
- ? await response.json()
46
- : await response.text();
47
43
  if (!response.ok) {
48
- const message = typeof data === "string" ? data : JSON.stringify(data);
44
+ let message = `HTTP ${response.status}`;
45
+ try {
46
+ const body = await response.text();
47
+ if (body)
48
+ message = body;
49
+ }
50
+ catch {
51
+ // The HTTP status remains useful even when an error body cannot be read.
52
+ }
49
53
  throw new MrScraperError(message.replaceAll(token, "[REDACTED]"), response.status);
50
54
  }
55
+ const contentType = (response.headers.get("content-type") ?? "").split(";", 1)[0].trim().toLowerCase();
56
+ const isText = !contentType || contentType.startsWith("text/") ||
57
+ ["application/xml", "application/xhtml+xml", "application/javascript"].includes(contentType);
58
+ const data = contentType === "application/json" || contentType.endsWith("+json")
59
+ ? await response.json()
60
+ : isText ? await response.text() : Buffer.from(await response.arrayBuffer());
51
61
  return {
52
62
  status_code: response.status,
53
63
  data: data,
@@ -64,40 +74,97 @@ async function post(url, body, headers, timeoutSeconds, token) {
64
74
  clearTimeout(timer);
65
75
  }
66
76
  }
67
- /** Fetch a page through the MrScraper API. Options mirror the Python client's page-fetch options. */
68
- export async function scraper_api(url, options = {}) {
77
+ /** Check account identity, subscription, quota, and rate limits. */
78
+ export async function account(options = {}) {
79
+ const token = requireToken(options.token);
80
+ const timeout = options.timeout ?? 30;
81
+ if (!Number.isFinite(timeout) || timeout <= 0) {
82
+ throw new RangeError("timeout must be greater than 0 seconds");
83
+ }
84
+ const response = await request("GET", "https://api.app.mrscraper.com/api/v1/subscription-accounts", undefined, authHeaders(token), timeout, token);
85
+ const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
86
+ const body = response.data;
87
+ const details = isRecord(body) && "data" in body ? body.data : body;
88
+ if (!isRecord(details)) {
89
+ throw new MrScraperError("Account response must contain an object", response.status_code);
90
+ }
91
+ const numberOrZero = (value) => {
92
+ const parsed = Number(value);
93
+ return Number.isFinite(parsed) ? parsed : 0;
94
+ };
95
+ const stringOrNull = (value) => typeof value === "string" ? value : null;
96
+ const tokenLimit = numberOrZero(details.tokenLimit);
97
+ const tokenUsage = numberOrZero(details.tokenUsage);
98
+ const user = isRecord(details.user) ? details.user : {};
99
+ return {
100
+ ...response,
101
+ // The raw account includes API tokens and billing identifiers.
102
+ data: {
103
+ subscription_status: stringOrNull(details.stripeStatus),
104
+ enterprise: Boolean(details.isEnterprise),
105
+ token_usage: tokenUsage,
106
+ token_limit: tokenLimit,
107
+ token_remaining: Math.max(0, tokenLimit - tokenUsage),
108
+ usage_percent: tokenLimit > 0 ? Number(((tokenUsage / tokenLimit) * 100).toFixed(2)) : 0,
109
+ rate_limit: numberOrZero(details.rateLimit),
110
+ rate_ttl: numberOrZero(details.rateTtl),
111
+ auto_renew: Boolean(details.isAutoRenew),
112
+ ends_at: stringOrNull(details.endsAt),
113
+ user: {
114
+ name: stringOrNull(user.name),
115
+ email: stringOrNull(user.email),
116
+ verified: Boolean(user.isVerified),
117
+ },
118
+ },
119
+ headers: Object.fromEntries(Object.entries(response.headers).filter(([key]) => !["authorization", "proxy-authorization", "set-cookie", "set-cookie2", "x-api-token"].includes(key.toLowerCase()))),
120
+ };
121
+ }
122
+ function validateInteger(name, value, minimum) {
123
+ if (value !== undefined && (!Number.isInteger(value) || value < minimum)) {
124
+ throw new RangeError(`${name} must be an integer greater than or equal to ${minimum}`);
125
+ }
126
+ }
127
+ // Kept private: public functions select their output and agent independently of user options.
128
+ async function scraper_api(url, options, selected) {
69
129
  const token = requireToken(options.token);
70
130
  const timeout = options.timeout ?? 120;
71
131
  const maxRetries = options.max_retries ?? 3;
72
132
  if (!Number.isFinite(timeout) || timeout < 1 || timeout > 300) {
73
133
  throw new RangeError("timeout must be between 1 and 300 seconds");
74
134
  }
75
- if (!Number.isInteger(maxRetries) || maxRetries < 0) {
76
- throw new RangeError("max_retries must be greater than or equal to 0");
77
- }
78
- if (options.token_cap != null && (!Number.isInteger(options.token_cap) || options.token_cap < 0)) {
79
- throw new RangeError("token_cap must be greater than or equal to 0");
80
- }
81
- if (options.screenshot !== undefined && typeof options.screenshot !== "boolean") {
82
- throw new TypeError("screenshot must be a boolean");
135
+ validateInteger("max_retries", maxRetries, 0);
136
+ if (options.token_cap != null)
137
+ validateInteger("token_cap", options.token_cap, 0);
138
+ validateInteger("max_pages", selected.max_pages, 1);
139
+ validateInteger("max_depth", selected.max_depth, 0);
140
+ validateInteger("limit", selected.limit, 1);
141
+ if (selected.bundle !== undefined && !["clean", "full", "none"].includes(selected.bundle)) {
142
+ throw new TypeError("bundle must be 'clean', 'full', or 'none'");
83
143
  }
84
144
  if (options.super !== undefined && typeof options.super !== "boolean") {
85
145
  throw new TypeError("super must be a boolean");
86
146
  }
147
+ for (const [name, pattern] of [["include_patterns", selected.include_patterns], ["exclude_patterns", selected.exclude_patterns]]) {
148
+ if (pattern != null && typeof pattern !== "string")
149
+ throw new TypeError(`${name} must be a string`);
150
+ }
151
+ const method = selected.method ?? "POST";
152
+ const queryRetries = method === "GET" || selected.action === "brand-scraping";
87
153
  const params = new URLSearchParams();
88
154
  setIfPresent(params, "token", token);
89
155
  setIfPresent(params, "timeout", timeout);
90
156
  setIfPresent(params, "geoCode", options.geo_code ?? "US");
91
157
  setIfPresent(params, "proxyCountry", options.proxy_country);
92
- setIfPresent(params, "browserRendering", options.screenshot ? true : options.browser_rendering);
158
+ setIfPresent(params, "browserRendering", selected.screenshot ? true : options.browser_rendering);
93
159
  setIfPresent(params, "super", options.super ? true : null);
94
160
  setIfPresent(params, "useProxy", options.use_proxy === false ? false : null);
95
161
  setIfPresent(params, "proxy", options.proxy);
96
- setIfPresent(params, "html", options.html ?? true);
97
- setIfPresent(params, "markdown", options.markdown ?? false);
162
+ setIfPresent(params, "html", selected.html);
163
+ setIfPresent(params, "markdown", selected.markdown);
98
164
  setIfPresent(params, "waitForSelector", options.wait_for_selector);
165
+ setIfPresent(params, "waitUntil", options.wait_until);
99
166
  setIfPresent(params, "warmStart", options.home_page ? true : null);
100
- setIfPresent(params, "screenshot", options.screenshot ? true : null);
167
+ setIfPresent(params, "screenshot", selected.screenshot);
101
168
  setIfPresent(params, "blockResources", options.block_resources ? true : null);
102
169
  setIfPresent(params, "bypassProxy", options.bypass_proxy ? true : null);
103
170
  setIfPresent(params, "cookieJar", options.cookie_jar);
@@ -105,14 +172,95 @@ export async function scraper_api(url, options = {}) {
105
172
  ? JSON.stringify(options.headers)
106
173
  : options.headers);
107
174
  setIfPresent(params, "stream", options.stream);
175
+ if (queryRetries) {
176
+ setIfPresent(params, "url", url);
177
+ setIfPresent(params, "maxRetries", maxRetries);
178
+ setIfPresent(params, "tokenCap", options.token_cap);
179
+ }
180
+ setIfPresent(params, "action", selected.action);
181
+ setIfPresent(params, "bundle", selected.bundle);
108
182
  const headers = authHeaders(token);
109
- if (options.discard_token_secret) {
183
+ if (options.discard_token_secret)
110
184
  headers["x-discard-token-secret"] = options.discard_token_secret;
185
+ const body = { url };
186
+ if (!queryRetries) {
187
+ body.maxRetries = maxRetries;
188
+ if (options.token_cap != null)
189
+ body.tokenCap = options.token_cap;
111
190
  }
112
- const body = { url, maxRetries };
113
- if (options.token_cap != null)
114
- body.tokenCap = options.token_cap;
115
- return post(`https://api.mrscraper.com/?${params}`, body, headers, timeout + 30, token);
191
+ const fields = {
192
+ prompt: selected.prompt,
193
+ agent: selected.agent,
194
+ maxPages: selected.max_pages,
195
+ maxDepth: selected.max_depth,
196
+ limit: selected.limit,
197
+ includePatterns: selected.include_patterns,
198
+ excludePatterns: selected.exclude_patterns,
199
+ };
200
+ for (const [name, value] of Object.entries(fields)) {
201
+ if (value != null)
202
+ body[name] = value;
203
+ }
204
+ return request(method, `https://api.mrscraper.com/?${params}`, method === "GET" ? undefined : body, headers, timeout + 30, token);
205
+ }
206
+ /** Fetch HTML. Only html=true is sent; other output flags are omitted. */
207
+ export async function scraper_html(url, options = {}) {
208
+ return scraper_api(url, options, { html: true });
209
+ }
210
+ /** Fetch Markdown. Only markdown=true is sent; other output flags are omitted. */
211
+ export async function scraper_markdown(url, options = {}) {
212
+ return scraper_api(url, options, { markdown: true });
213
+ }
214
+ /** Capture a screenshot using GET. Images are returned as Buffer in data. */
215
+ export async function get_screenshot(url, options = {}) {
216
+ const fullPage = options.full_page === undefined ? true : options.full_page;
217
+ if (typeof fullPage !== "boolean")
218
+ throw new TypeError("full_page must be a boolean");
219
+ return scraper_api(url, {
220
+ ...options,
221
+ timeout: options.timeout ?? 300,
222
+ wait_until: options.wait_until === undefined ? "domcontentloaded" : options.wait_until,
223
+ }, { method: "GET", screenshot: fullPage ? "full" : true });
224
+ }
225
+ /** Extract structured JSON with the general agent and html=true. */
226
+ export async function scraper_json(url, options = {}) {
227
+ return scraper_api(url, options, {
228
+ html: true, agent: "general", prompt: options.prompt ?? "Extract all data as complete as possible.",
229
+ });
230
+ }
231
+ /** Extract entries across multiple pages using the listing agent. */
232
+ export async function scraper_multiple_page(url, options = {}) {
233
+ return scraper_api(url, options, {
234
+ agent: "listing", prompt: options.prompt ?? "Extract all entry data as complete as possible.",
235
+ max_pages: options.max_pages ?? 3,
236
+ });
237
+ }
238
+ /** Discover URLs with the map agent; pattern strings are preserved unchanged. */
239
+ export async function scraper_sitemap(url, options = {}) {
240
+ return scraper_api(url, options, {
241
+ agent: "map", max_depth: options.max_depth ?? 2, max_pages: options.max_pages ?? 3,
242
+ limit: options.limit ?? 1000, include_patterns: options.include_patterns,
243
+ exclude_patterns: options.exclude_patterns,
244
+ });
245
+ }
246
+ /** Start a brand-scraping job; use the returned job ID with get_brand. */
247
+ export async function scrape_brand(url, options = {}) {
248
+ return scraper_api(url, options, { action: "brand-scraping", bundle: options.bundle ?? "clean" });
249
+ }
250
+ /** Read a brand job or download HTML, a ZIP bundle, or a screenshot. */
251
+ export async function get_brand(job_id, options = {}) {
252
+ const token = requireToken(options.token);
253
+ if (typeof job_id !== "string" || !job_id.trim())
254
+ throw new TypeError("job_id must be a non-empty string");
255
+ if (options.output != null && !["html", "bundle", "screenshot", "screenshot_full"].includes(options.output)) {
256
+ throw new TypeError("output must be 'html', 'bundle', 'screenshot', or 'screenshot_full'");
257
+ }
258
+ const timeout = options.timeout ?? 600;
259
+ if (!Number.isFinite(timeout) || timeout <= 0)
260
+ throw new RangeError("timeout must be greater than 0 seconds");
261
+ const params = new URLSearchParams({ id: job_id });
262
+ setIfPresent(params, "output", options.output);
263
+ return request("GET", `https://api.mrscraper.com/neo/brand?${params}`, undefined, authHeaders(token), timeout, token);
116
264
  }
117
265
  function normalizeSerpInput(input) {
118
266
  const value = input.trim();
@@ -163,6 +311,6 @@ export async function web_search(url, options = {}) {
163
311
  body.language = language;
164
312
  if (page != null)
165
313
  body.page = page;
166
- return post("https://sync.scraper.mrscraper.com/api/google/serp/v2/sync", body, authHeaders(token), timeout, token);
314
+ return request("POST", "https://sync.scraper.mrscraper.com/api/google/serp/v2/sync", body, authHeaders(token), timeout, token);
167
315
  }
168
316
  //# sourceMappingURL=api.js.map
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAqB;IAEpC,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAiDD,SAAS,YAAY,CAAC,aAAsB;IAC1C,MAAM,KAAK,GAAG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;IACrE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,cAAc,CACtB,0HAA0H,CAC3H,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO;QACL,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,kBAAkB;QAC1B,aAAa,EAAE,UAAU,KAAK,EAAE;QACh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IAAI;QAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAEnC,OAAO,OAAO,CACZ,MAAM,EACN,4DAA4D,EAC5D,IAAI,EACJ,WAAW,CAAC,KAAK,CAAC,EAClB,OAAO,EACP,KAAK,CACN,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { MrScraperError, scraper_api, web_search } from "./api.js";
2
- export type { ScraperApiOptions, WebSearchOptions, MrScraperResponse } from "./api.js";
1
+ export { MrScraperError, account, scraper_html, scraper_markdown, get_screenshot, scraper_json, scraper_multiple_page, scraper_sitemap, scrape_brand, get_brand, web_search, } from "./api.js";
2
+ export type { AccountOptions, AccountSummary, ScraperOptions, ScreenshotOptions, ScraperJsonOptions, ScraperMultiplePageOptions, ScraperSitemapOptions, BrandBundle, BrandOutput, ScrapeBrandOptions, GetBrandOptions, WebSearchOptions, MrScraperResponse, } from "./api.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EACvE,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,GAC1F,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EACrF,0BAA0B,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAC3E,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,GACzE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { MrScraperError, scraper_api, web_search } from "./api.js";
1
+ export { MrScraperError, account, scraper_html, scraper_markdown, get_screenshot, scraper_json, scraper_multiple_page, scraper_sitemap, scrape_brand, get_brand, web_search, } from "./api.js";
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EACvE,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,GAC1F,MAAM,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mrscraper/sdk",
3
- "version": "3.0.0",
4
- "description": "Official Node.js SDK for the MrScraper scraper API and web search.",
3
+ "version": "4.0.0",
4
+ "description": "Official Node.js SDK for MrScraper HTML, Markdown, screenshots, extraction, sitemap, brand scraping, web search, and account status.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -22,7 +22,8 @@
22
22
  "build": "tsc -p tsconfig.json",
23
23
  "clean": "rm -rf dist",
24
24
  "prepublishOnly": "npm run clean && npm run build",
25
- "test": "npm run build && node --test tests/*.test.mjs"
25
+ "test": "npm run build && npm run test:types && node --test tests/*.test.mjs",
26
+ "test:types": "tsc --noEmit --strict --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck tests/types.test.ts"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/node": "^25.3.3",