mcpscraper-sdk 0.34.0 → 0.35.1

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/dist/index.js CHANGED
@@ -182,19 +182,38 @@ var Requester = class {
182
182
  throw error;
183
183
  }
184
184
  }
185
- async call(method, path, body, extraHeaders = {}) {
186
- return (await this.callWithReceipt(method, path, body, extraHeaders)).data;
187
- }
188
- async callWithReceipt(method, path, body, extraHeaders = {}) {
189
- const res = await this.request(`${this.baseUrl}${path}`, {
190
- method,
191
- headers: {
192
- "x-api-key": this.apiKey,
193
- ...body !== void 0 ? { "content-type": "application/json" } : {},
194
- ...extraHeaders
195
- },
196
- body: body !== void 0 ? JSON.stringify(body) : void 0
197
- });
185
+ async call(method, path, body, extraHeaders = {}, options = {}) {
186
+ return (await this.callWithReceipt(method, path, body, extraHeaders, options)).data;
187
+ }
188
+ async callWithReceipt(method, path, body, extraHeaders = {}, options = {}) {
189
+ const requestTimeoutMs = options.timeoutMs ?? this.timeoutMs;
190
+ const timeoutSignal = AbortSignal.timeout(requestTimeoutMs);
191
+ const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
192
+ let res;
193
+ try {
194
+ res = await this.fetchImpl(`${this.baseUrl}${path}`, {
195
+ method,
196
+ headers: {
197
+ "x-api-key": this.apiKey,
198
+ ...body !== void 0 ? { "content-type": "application/json" } : {},
199
+ ...extraHeaders
200
+ },
201
+ body: body !== void 0 ? JSON.stringify(body) : void 0,
202
+ signal
203
+ });
204
+ } catch (error) {
205
+ if (error instanceof DOMException && (error.name === "TimeoutError" || error.name === "AbortError")) {
206
+ if (options.signal?.aborted && !timeoutSignal.aborted) throw error;
207
+ throw new ScraperApiError(408, {
208
+ error: "mcp_request_timeout",
209
+ error_code: "mcp_request_timeout",
210
+ error_type: "timeout",
211
+ message: `The client stopped waiting after ${Math.round(requestTimeoutMs / 1e3)}s. This does not prove server-side work stopped; use the same Idempotency-Key or poll a returned job before starting a new paid run.`,
212
+ retryable: true
213
+ });
214
+ }
215
+ throw error;
216
+ }
198
217
  const data = await res.json().catch(() => void 0);
199
218
  if (!res.ok) throw new ScraperApiError(res.status, data);
200
219
  return { data, headers: res.headers };
@@ -306,8 +325,8 @@ var MapsNamespace = class {
306
325
  this.r = r;
307
326
  }
308
327
  r;
309
- search(params) {
310
- return this.r.call("POST", "/maps/search", params);
328
+ search(params, options = {}) {
329
+ return this.r.call("POST", "/maps/search", params, {}, options);
311
330
  }
312
331
  place(params) {
313
332
  return this.r.call("POST", "/maps/place", params);
@@ -516,26 +535,45 @@ var ScraperClient = class {
516
535
  }
517
536
  return result;
518
537
  }
519
- searchSerp(params) {
520
- return this.r.call("POST", "/harvest/sync", { ...params, serpOnly: true });
538
+ startHarvest(params, options = {}) {
539
+ return this.r.call(
540
+ "POST",
541
+ "/harvest",
542
+ params,
543
+ {},
544
+ options
545
+ );
546
+ }
547
+ searchSerp(params, options = {}) {
548
+ return this.r.call("POST", "/harvest/sync", { ...params, serpOnly: true }, {}, options);
521
549
  }
522
- harvestPaa(params) {
523
- return this.r.call("POST", "/harvest/sync", params);
550
+ harvestPaa(params, options = {}) {
551
+ return this.r.call("POST", "/harvest/sync", params, {}, options);
524
552
  }
525
553
  extractUrl(params, options = {}) {
526
- return this.r.call("POST", "/extract-url", params, options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {});
554
+ return this.r.call("POST", "/extract-url", params, {}, options);
527
555
  }
528
- mapSiteUrls(params) {
529
- return this.r.call("POST", "/map-urls", params);
556
+ mapSiteUrls(params, options = {}) {
557
+ return this.r.call("POST", "/map-urls", params, {}, options);
530
558
  }
531
559
  extractSite(params, options = {}) {
532
- return this.r.call("POST", "/extract-site", params, options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {});
560
+ const headers = options.idempotencyKey === void 0 ? {} : { "Idempotency-Key": options.idempotencyKey };
561
+ return this.r.call("POST", "/extract-site", params, headers, options);
533
562
  }
534
563
  auditSite(params, options = {}) {
535
564
  return this.extractSite(params, options);
536
565
  }
537
- getExtractSiteStatus(id) {
538
- return this.r.call("GET", `/extract-site/status/${encodeURIComponent(id)}`);
566
+ getExtractSiteStatus(id, options = {}) {
567
+ return this.r.call("GET", `/extract-site/status/${encodeURIComponent(id)}`, void 0, {}, options);
568
+ }
569
+ archiveRead(params, options = {}) {
570
+ return this.r.call(
571
+ "POST",
572
+ "/archive/read",
573
+ params,
574
+ {},
575
+ options
576
+ );
539
577
  }
540
578
  readExtractSiteExport(params) {
541
579
  return this.r.call("POST", "/extract-site/read", params);
@@ -546,8 +584,8 @@ var ScraperClient = class {
546
584
  listJobs() {
547
585
  return this.r.call("GET", "/jobs");
548
586
  }
549
- getJob(id) {
550
- return this.r.call("GET", `/jobs/${encodeURIComponent(id)}`);
587
+ getJob(id, options = {}) {
588
+ return this.r.call("GET", `/jobs/${encodeURIComponent(id)}`, void 0, {}, options);
551
589
  }
552
590
  getHistory() {
553
591
  return this.r.call("GET", "/history");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcpscraper-sdk",
3
- "version": "0.34.0",
4
- "description": "Official Node.js client for all 339 mcpscraper.dev MCP tools and the REST API",
3
+ "version": "0.35.1",
4
+ "description": "Official Node.js client for all 354 mcpscraper.dev MCP tools and the REST API",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "prepack": "npm run build",
23
- "generate": "openapi-typescript ../../contracts/scraper.openapi.yaml -o src/schema.ts",
23
+ "generate": "openapi-typescript ../../contracts/assistant.openapi.yaml -o src/assistant-schema.ts",
24
24
  "build": "tsup src/index.ts --format esm,cjs --dts",
25
25
  "typecheck": "tsc --noEmit",
26
26
  "test": "node --import tsx --test test/*.test.ts"
@@ -32,7 +32,7 @@
32
32
  "seo-api"
33
33
  ],
34
34
  "dependencies": {
35
- "mcpscraper-memory-sdk": "^0.34.0"
35
+ "mcpscraper-memory-sdk": "^0.35.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "openapi-typescript": "^7.13.0"