firecrawl 4.48.0 → 4.49.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
@@ -1,6 +1,6 @@
1
1
  # Firecrawl Node SDK
2
2
 
3
- The Firecrawl Node SDK is the JavaScript client for the Firecrawl API, the context API for AI agents. Search, scrape, parse, crawl, map, and interact with the web, and get back clean Markdown or structured data your agents can ship with.
3
+ The Firecrawl Node SDK is the JavaScript client for the Firecrawl API, the context API for AI agents. Search, scrape, parse, crawl, map, and interact with the web, run Agent and Monitor jobs, and get back clean Markdown or structured data your agents can ship with.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@mendable/firecrawl-js";
3
- var version = "4.48.0";
3
+ var version = "4.49.0";
4
4
  var description = "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts";
5
5
  var main = "dist/index.js";
6
6
  var types = "dist/index.d.ts";
package/dist/index.cjs CHANGED
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  "package.json"(exports2, module2) {
40
40
  module2.exports = {
41
41
  name: "@mendable/firecrawl-js",
42
- version: "4.48.0",
42
+ version: "4.49.0",
43
43
  description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
44
44
  main: "dist/index.js",
45
45
  types: "dist/index.d.ts",
@@ -2486,6 +2486,32 @@ var Watcher = class extends import_events.EventEmitter {
2486
2486
  }
2487
2487
  };
2488
2488
 
2489
+ // src/v2/utils/v1Compat.ts
2490
+ var warned = false;
2491
+ function warnV1Usage() {
2492
+ if (warned) return;
2493
+ warned = true;
2494
+ const message = "firecrawl: v1-style methods (scrapeUrl, crawlUrl, batchScrapeUrls, ...) are deprecated and mapped to the v2 API. Use scrape(), crawl(), batchScrape() and the other v2 methods instead.";
2495
+ if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
2496
+ process.emitWarning(message, { type: "DeprecationWarning", code: "FIRECRAWL_V1_METHOD" });
2497
+ } else {
2498
+ console.warn(message);
2499
+ }
2500
+ }
2501
+ function toV2CrawlOptions(req) {
2502
+ const { maxDepth, allowBackwardLinks, ignoreSitemap, ...rest } = req;
2503
+ return {
2504
+ ...maxDepth != null && { maxDiscoveryDepth: maxDepth },
2505
+ ...allowBackwardLinks != null && { crawlEntireDomain: allowBackwardLinks },
2506
+ ...ignoreSitemap != null && { sitemap: ignoreSitemap ? "skip" : "include" },
2507
+ ...rest
2508
+ };
2509
+ }
2510
+ async function callV1(call) {
2511
+ warnV1Usage();
2512
+ return { ...await call(), success: true };
2513
+ }
2514
+
2489
2515
  // src/v2/client.ts
2490
2516
  var zt = require("zod");
2491
2517
  var FirecrawlClient = class {
@@ -2967,45 +2993,45 @@ var FirecrawlClient = class {
2967
2993
  watcher(jobId, opts = {}) {
2968
2994
  return new Watcher(this.http, jobId, opts);
2969
2995
  }
2970
- /** @deprecated V1 compatibility alias for agent recovery. Prefer scrape(). */
2996
+ /** @deprecated v1 alias for scrape(); its result also carries v1's `success: true`. */
2971
2997
  async scrapeUrl(url, options) {
2972
- return this.scrape(url, options);
2998
+ return callV1(() => this.scrape(url, options));
2973
2999
  }
2974
- /** @deprecated V1 compatibility alias for agent recovery. Prefer crawl(). */
3000
+ /** @deprecated v1 alias for crawl(); its result also carries v1's `success: true`. */
2975
3001
  async crawlUrl(url, req = {}) {
2976
- return this.crawl(url, req);
3002
+ return callV1(() => this.crawl(url, toV2CrawlOptions(req)));
2977
3003
  }
2978
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startCrawl(). */
3004
+ /** @deprecated v1 alias for startCrawl(); its result also carries v1's `success: true`. */
2979
3005
  async asyncCrawlUrl(url, req = {}) {
2980
- return this.startCrawl(url, req);
3006
+ return callV1(() => this.startCrawl(url, toV2CrawlOptions(req)));
2981
3007
  }
2982
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlStatus(). */
3008
+ /** @deprecated v1 alias for getCrawlStatus(); its result also carries v1's `success: true`. */
2983
3009
  async checkCrawlStatus(jobId, pagination) {
2984
- return this.getCrawlStatus(jobId, pagination);
3010
+ return callV1(() => this.getCrawlStatus(jobId, pagination));
2985
3011
  }
2986
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlErrors(). */
3012
+ /** @deprecated v1 alias for getCrawlErrors(); its result also carries v1's `success: true`. */
2987
3013
  async checkCrawlErrors(crawlId) {
2988
- return this.getCrawlErrors(crawlId);
3014
+ return callV1(() => this.getCrawlErrors(crawlId));
2989
3015
  }
2990
- /** @deprecated V1 compatibility alias for agent recovery. Prefer map(). */
3016
+ /** @deprecated v1 alias for map(); its result also carries v1's `success: true`. */
2991
3017
  async mapUrl(url, options) {
2992
- return this.map(url, options);
3018
+ return callV1(() => this.map(url, options));
2993
3019
  }
2994
- /** @deprecated V1 compatibility alias for agent recovery. Prefer batchScrape(). */
3020
+ /** @deprecated v1 alias for batchScrape(); its result also carries v1's `success: true`. */
2995
3021
  async batchScrapeUrls(urls, opts) {
2996
- return this.batchScrape(urls, opts);
3022
+ return callV1(() => this.batchScrape(urls, opts));
2997
3023
  }
2998
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startBatchScrape(). */
3024
+ /** @deprecated v1 alias for startBatchScrape(); its result also carries v1's `success: true`. */
2999
3025
  async asyncBatchScrapeUrls(urls, opts) {
3000
- return this.startBatchScrape(urls, opts);
3026
+ return callV1(() => this.startBatchScrape(urls, opts));
3001
3027
  }
3002
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeStatus(). */
3028
+ /** @deprecated v1 alias for getBatchScrapeStatus(); its result also carries v1's `success: true`. */
3003
3029
  async checkBatchScrapeStatus(jobId, pagination) {
3004
- return this.getBatchScrapeStatus(jobId, pagination);
3030
+ return callV1(() => this.getBatchScrapeStatus(jobId, pagination));
3005
3031
  }
3006
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeErrors(). */
3032
+ /** @deprecated v1 alias for getBatchScrapeErrors(); its result also carries v1's `success: true`. */
3007
3033
  async checkBatchScrapeErrors(jobId) {
3008
- return this.getBatchScrapeErrors(jobId);
3034
+ return callV1(() => this.getBatchScrapeErrors(jobId));
3009
3035
  }
3010
3036
  };
3011
3037
 
package/dist/index.d.cts CHANGED
@@ -2248,6 +2248,17 @@ declare class Watcher extends EventEmitter {
2248
2248
  close(): void;
2249
2249
  }
2250
2250
 
2251
+ /** v1 crawl options that have a v2 equivalent. */
2252
+ type V1CrawlOptions = {
2253
+ maxDepth?: number;
2254
+ allowBackwardLinks?: boolean;
2255
+ ignoreSitemap?: boolean;
2256
+ };
2257
+ /** A v2 result with the `success` flag v1 results carried. */
2258
+ type V1Result<T> = T & {
2259
+ success: true;
2260
+ };
2261
+
2251
2262
  type ExtractJsonSchemaFromFormats<Formats> = Formats extends readonly any[] ? Extract<Formats[number], {
2252
2263
  type: "json";
2253
2264
  schema?: unknown;
@@ -2639,33 +2650,33 @@ declare class FirecrawlClient {
2639
2650
  * @param opts Watcher options (kind, pollInterval, timeout seconds).
2640
2651
  */
2641
2652
  watcher(jobId: string, opts?: WatcherOptions): Watcher;
2642
- /** @deprecated V1 compatibility alias for agent recovery. Prefer scrape(). */
2643
- scrapeUrl(url: string, options?: ScrapeOptions): Promise<Document>;
2644
- /** @deprecated V1 compatibility alias for agent recovery. Prefer crawl(). */
2645
- crawlUrl(url: string, req?: CrawlOptions & {
2653
+ /** @deprecated v1 alias for scrape(); its result also carries v1's `success: true`. */
2654
+ scrapeUrl(url: string, options?: ScrapeOptions): Promise<V1Result<Document>>;
2655
+ /** @deprecated v1 alias for crawl(); its result also carries v1's `success: true`. */
2656
+ crawlUrl(url: string, req?: CrawlOptions & V1CrawlOptions & {
2646
2657
  pollInterval?: number;
2647
2658
  timeout?: number;
2648
2659
  signal?: AbortSignal;
2649
- }): Promise<CrawlJob>;
2650
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startCrawl(). */
2651
- asyncCrawlUrl(url: string, req?: CrawlOptions): Promise<CrawlResponse$1>;
2652
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlStatus(). */
2653
- checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<CrawlJob>;
2654
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlErrors(). */
2655
- checkCrawlErrors(crawlId: string): Promise<CrawlErrorsResponse$1>;
2656
- /** @deprecated V1 compatibility alias for agent recovery. Prefer map(). */
2657
- mapUrl(url: string, options?: MapOptions): Promise<MapData>;
2658
- /** @deprecated V1 compatibility alias for agent recovery. Prefer batchScrape(). */
2660
+ }): Promise<V1Result<CrawlJob>>;
2661
+ /** @deprecated v1 alias for startCrawl(); its result also carries v1's `success: true`. */
2662
+ asyncCrawlUrl(url: string, req?: CrawlOptions & V1CrawlOptions): Promise<V1Result<CrawlResponse$1>>;
2663
+ /** @deprecated v1 alias for getCrawlStatus(); its result also carries v1's `success: true`. */
2664
+ checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<CrawlJob>>;
2665
+ /** @deprecated v1 alias for getCrawlErrors(); its result also carries v1's `success: true`. */
2666
+ checkCrawlErrors(crawlId: string): Promise<V1Result<CrawlErrorsResponse$1>>;
2667
+ /** @deprecated v1 alias for map(); its result also carries v1's `success: true`. */
2668
+ mapUrl(url: string, options?: MapOptions): Promise<V1Result<MapData>>;
2669
+ /** @deprecated v1 alias for batchScrape(); its result also carries v1's `success: true`. */
2659
2670
  batchScrapeUrls(urls: string[], opts?: BatchScrapeOptions & {
2660
2671
  pollInterval?: number;
2661
2672
  timeout?: number;
2662
- }): Promise<BatchScrapeJob>;
2663
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startBatchScrape(). */
2664
- asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<BatchScrapeResponse$1>;
2665
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeStatus(). */
2666
- checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<BatchScrapeJob>;
2667
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeErrors(). */
2668
- checkBatchScrapeErrors(jobId: string): Promise<CrawlErrorsResponse$1>;
2673
+ }): Promise<V1Result<BatchScrapeJob>>;
2674
+ /** @deprecated v1 alias for startBatchScrape(); its result also carries v1's `success: true`. */
2675
+ asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<V1Result<BatchScrapeResponse$1>>;
2676
+ /** @deprecated v1 alias for getBatchScrapeStatus(); its result also carries v1's `success: true`. */
2677
+ checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<BatchScrapeJob>>;
2678
+ /** @deprecated v1 alias for getBatchScrapeErrors(); its result also carries v1's `success: true`. */
2679
+ checkBatchScrapeErrors(jobId: string): Promise<V1Result<CrawlErrorsResponse$1>>;
2669
2680
  }
2670
2681
 
2671
2682
  /**
package/dist/index.d.ts CHANGED
@@ -2248,6 +2248,17 @@ declare class Watcher extends EventEmitter {
2248
2248
  close(): void;
2249
2249
  }
2250
2250
 
2251
+ /** v1 crawl options that have a v2 equivalent. */
2252
+ type V1CrawlOptions = {
2253
+ maxDepth?: number;
2254
+ allowBackwardLinks?: boolean;
2255
+ ignoreSitemap?: boolean;
2256
+ };
2257
+ /** A v2 result with the `success` flag v1 results carried. */
2258
+ type V1Result<T> = T & {
2259
+ success: true;
2260
+ };
2261
+
2251
2262
  type ExtractJsonSchemaFromFormats<Formats> = Formats extends readonly any[] ? Extract<Formats[number], {
2252
2263
  type: "json";
2253
2264
  schema?: unknown;
@@ -2639,33 +2650,33 @@ declare class FirecrawlClient {
2639
2650
  * @param opts Watcher options (kind, pollInterval, timeout seconds).
2640
2651
  */
2641
2652
  watcher(jobId: string, opts?: WatcherOptions): Watcher;
2642
- /** @deprecated V1 compatibility alias for agent recovery. Prefer scrape(). */
2643
- scrapeUrl(url: string, options?: ScrapeOptions): Promise<Document>;
2644
- /** @deprecated V1 compatibility alias for agent recovery. Prefer crawl(). */
2645
- crawlUrl(url: string, req?: CrawlOptions & {
2653
+ /** @deprecated v1 alias for scrape(); its result also carries v1's `success: true`. */
2654
+ scrapeUrl(url: string, options?: ScrapeOptions): Promise<V1Result<Document>>;
2655
+ /** @deprecated v1 alias for crawl(); its result also carries v1's `success: true`. */
2656
+ crawlUrl(url: string, req?: CrawlOptions & V1CrawlOptions & {
2646
2657
  pollInterval?: number;
2647
2658
  timeout?: number;
2648
2659
  signal?: AbortSignal;
2649
- }): Promise<CrawlJob>;
2650
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startCrawl(). */
2651
- asyncCrawlUrl(url: string, req?: CrawlOptions): Promise<CrawlResponse$1>;
2652
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlStatus(). */
2653
- checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<CrawlJob>;
2654
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlErrors(). */
2655
- checkCrawlErrors(crawlId: string): Promise<CrawlErrorsResponse$1>;
2656
- /** @deprecated V1 compatibility alias for agent recovery. Prefer map(). */
2657
- mapUrl(url: string, options?: MapOptions): Promise<MapData>;
2658
- /** @deprecated V1 compatibility alias for agent recovery. Prefer batchScrape(). */
2660
+ }): Promise<V1Result<CrawlJob>>;
2661
+ /** @deprecated v1 alias for startCrawl(); its result also carries v1's `success: true`. */
2662
+ asyncCrawlUrl(url: string, req?: CrawlOptions & V1CrawlOptions): Promise<V1Result<CrawlResponse$1>>;
2663
+ /** @deprecated v1 alias for getCrawlStatus(); its result also carries v1's `success: true`. */
2664
+ checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<CrawlJob>>;
2665
+ /** @deprecated v1 alias for getCrawlErrors(); its result also carries v1's `success: true`. */
2666
+ checkCrawlErrors(crawlId: string): Promise<V1Result<CrawlErrorsResponse$1>>;
2667
+ /** @deprecated v1 alias for map(); its result also carries v1's `success: true`. */
2668
+ mapUrl(url: string, options?: MapOptions): Promise<V1Result<MapData>>;
2669
+ /** @deprecated v1 alias for batchScrape(); its result also carries v1's `success: true`. */
2659
2670
  batchScrapeUrls(urls: string[], opts?: BatchScrapeOptions & {
2660
2671
  pollInterval?: number;
2661
2672
  timeout?: number;
2662
- }): Promise<BatchScrapeJob>;
2663
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startBatchScrape(). */
2664
- asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<BatchScrapeResponse$1>;
2665
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeStatus(). */
2666
- checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<BatchScrapeJob>;
2667
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeErrors(). */
2668
- checkBatchScrapeErrors(jobId: string): Promise<CrawlErrorsResponse$1>;
2673
+ }): Promise<V1Result<BatchScrapeJob>>;
2674
+ /** @deprecated v1 alias for startBatchScrape(); its result also carries v1's `success: true`. */
2675
+ asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<V1Result<BatchScrapeResponse$1>>;
2676
+ /** @deprecated v1 alias for getBatchScrapeStatus(); its result also carries v1's `success: true`. */
2677
+ checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<BatchScrapeJob>>;
2678
+ /** @deprecated v1 alias for getBatchScrapeErrors(); its result also carries v1's `success: true`. */
2679
+ checkBatchScrapeErrors(jobId: string): Promise<V1Result<CrawlErrorsResponse$1>>;
2669
2680
  }
2670
2681
 
2671
2682
  /**
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./chunk-GD463K4D.js";
3
+ } from "./chunk-JNLB66PW.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -2357,6 +2357,32 @@ var Watcher = class extends EventEmitter {
2357
2357
  }
2358
2358
  };
2359
2359
 
2360
+ // src/v2/utils/v1Compat.ts
2361
+ var warned = false;
2362
+ function warnV1Usage() {
2363
+ if (warned) return;
2364
+ warned = true;
2365
+ const message = "firecrawl: v1-style methods (scrapeUrl, crawlUrl, batchScrapeUrls, ...) are deprecated and mapped to the v2 API. Use scrape(), crawl(), batchScrape() and the other v2 methods instead.";
2366
+ if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
2367
+ process.emitWarning(message, { type: "DeprecationWarning", code: "FIRECRAWL_V1_METHOD" });
2368
+ } else {
2369
+ console.warn(message);
2370
+ }
2371
+ }
2372
+ function toV2CrawlOptions(req) {
2373
+ const { maxDepth, allowBackwardLinks, ignoreSitemap, ...rest } = req;
2374
+ return {
2375
+ ...maxDepth != null && { maxDiscoveryDepth: maxDepth },
2376
+ ...allowBackwardLinks != null && { crawlEntireDomain: allowBackwardLinks },
2377
+ ...ignoreSitemap != null && { sitemap: ignoreSitemap ? "skip" : "include" },
2378
+ ...rest
2379
+ };
2380
+ }
2381
+ async function callV1(call) {
2382
+ warnV1Usage();
2383
+ return { ...await call(), success: true };
2384
+ }
2385
+
2360
2386
  // src/v2/client.ts
2361
2387
  import "zod";
2362
2388
  var FirecrawlClient = class {
@@ -2838,45 +2864,45 @@ var FirecrawlClient = class {
2838
2864
  watcher(jobId, opts = {}) {
2839
2865
  return new Watcher(this.http, jobId, opts);
2840
2866
  }
2841
- /** @deprecated V1 compatibility alias for agent recovery. Prefer scrape(). */
2867
+ /** @deprecated v1 alias for scrape(); its result also carries v1's `success: true`. */
2842
2868
  async scrapeUrl(url, options) {
2843
- return this.scrape(url, options);
2869
+ return callV1(() => this.scrape(url, options));
2844
2870
  }
2845
- /** @deprecated V1 compatibility alias for agent recovery. Prefer crawl(). */
2871
+ /** @deprecated v1 alias for crawl(); its result also carries v1's `success: true`. */
2846
2872
  async crawlUrl(url, req = {}) {
2847
- return this.crawl(url, req);
2873
+ return callV1(() => this.crawl(url, toV2CrawlOptions(req)));
2848
2874
  }
2849
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startCrawl(). */
2875
+ /** @deprecated v1 alias for startCrawl(); its result also carries v1's `success: true`. */
2850
2876
  async asyncCrawlUrl(url, req = {}) {
2851
- return this.startCrawl(url, req);
2877
+ return callV1(() => this.startCrawl(url, toV2CrawlOptions(req)));
2852
2878
  }
2853
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlStatus(). */
2879
+ /** @deprecated v1 alias for getCrawlStatus(); its result also carries v1's `success: true`. */
2854
2880
  async checkCrawlStatus(jobId, pagination) {
2855
- return this.getCrawlStatus(jobId, pagination);
2881
+ return callV1(() => this.getCrawlStatus(jobId, pagination));
2856
2882
  }
2857
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlErrors(). */
2883
+ /** @deprecated v1 alias for getCrawlErrors(); its result also carries v1's `success: true`. */
2858
2884
  async checkCrawlErrors(crawlId) {
2859
- return this.getCrawlErrors(crawlId);
2885
+ return callV1(() => this.getCrawlErrors(crawlId));
2860
2886
  }
2861
- /** @deprecated V1 compatibility alias for agent recovery. Prefer map(). */
2887
+ /** @deprecated v1 alias for map(); its result also carries v1's `success: true`. */
2862
2888
  async mapUrl(url, options) {
2863
- return this.map(url, options);
2889
+ return callV1(() => this.map(url, options));
2864
2890
  }
2865
- /** @deprecated V1 compatibility alias for agent recovery. Prefer batchScrape(). */
2891
+ /** @deprecated v1 alias for batchScrape(); its result also carries v1's `success: true`. */
2866
2892
  async batchScrapeUrls(urls, opts) {
2867
- return this.batchScrape(urls, opts);
2893
+ return callV1(() => this.batchScrape(urls, opts));
2868
2894
  }
2869
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startBatchScrape(). */
2895
+ /** @deprecated v1 alias for startBatchScrape(); its result also carries v1's `success: true`. */
2870
2896
  async asyncBatchScrapeUrls(urls, opts) {
2871
- return this.startBatchScrape(urls, opts);
2897
+ return callV1(() => this.startBatchScrape(urls, opts));
2872
2898
  }
2873
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeStatus(). */
2899
+ /** @deprecated v1 alias for getBatchScrapeStatus(); its result also carries v1's `success: true`. */
2874
2900
  async checkBatchScrapeStatus(jobId, pagination) {
2875
- return this.getBatchScrapeStatus(jobId, pagination);
2901
+ return callV1(() => this.getBatchScrapeStatus(jobId, pagination));
2876
2902
  }
2877
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeErrors(). */
2903
+ /** @deprecated v1 alias for getBatchScrapeErrors(); its result also carries v1's `success: true`. */
2878
2904
  async checkBatchScrapeErrors(jobId) {
2879
- return this.getBatchScrapeErrors(jobId);
2905
+ return callV1(() => this.getBatchScrapeErrors(jobId));
2880
2906
  }
2881
2907
  };
2882
2908
 
@@ -2915,7 +2941,7 @@ var FirecrawlApp = class {
2915
2941
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
2916
2942
  return process.env.npm_package_version;
2917
2943
  }
2918
- const packageJson = await import("./package-WONXBIJS.js");
2944
+ const packageJson = await import("./package-7E5DZETG.js");
2919
2945
  return packageJson.default.version;
2920
2946
  } catch (error) {
2921
2947
  const isTest = typeof process !== "undefined" && false;
@@ -17,7 +17,7 @@ import {
17
17
  type,
18
18
  types,
19
19
  version
20
- } from "./chunk-GD463K4D.js";
20
+ } from "./chunk-JNLB66PW.js";
21
21
  export {
22
22
  author,
23
23
  bugs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "4.48.0",
3
+ "version": "4.49.0",
4
4
  "description": "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,5 @@
1
- import { describe, expect, it, vi } from "vitest";
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import type { AxiosAdapter } from "axios";
2
3
  import { FirecrawlClient } from "../../../v2/client";
3
4
 
4
5
  const ALIAS_MAP: Record<string, string> = {
@@ -20,14 +21,98 @@ describe("V1 deprecated aliases", () => {
20
21
  apiUrl: "http://localhost:9",
21
22
  });
22
23
 
24
+ afterEach(() => {
25
+ vi.restoreAllMocks();
26
+ });
27
+
23
28
  for (const [alias, target] of Object.entries(ALIAS_MAP)) {
24
- it(`${alias} delegates to ${target}`, async () => {
29
+ it(`${alias} delegates to ${target} and adds success: true`, async () => {
25
30
  const spy = vi
26
31
  .spyOn(app, target as any)
27
32
  .mockResolvedValue({ ok: true } as any);
28
- await (app as any)[alias]("https://example.com");
33
+ const result = await (app as any)[alias]("https://example.com");
29
34
  expect(spy).toHaveBeenCalled();
30
- spy.mockRestore();
35
+ expect(result).toEqual({ ok: true, success: true });
31
36
  });
32
37
  }
38
+
39
+ it("scrapeUrl keeps the document fields beside success, as v1 did", async () => {
40
+ vi.spyOn(app, "scrape").mockResolvedValue({ markdown: "# hi", metadata: { sourceURL: "https://example.com" } } as any);
41
+ const result = await app.scrapeUrl("https://example.com", { formats: ["markdown"] });
42
+ expect(app.scrape).toHaveBeenCalledWith("https://example.com", { formats: ["markdown"] });
43
+ expect(result.success).toBe(true);
44
+ expect(result.markdown).toBe("# hi");
45
+ });
46
+
47
+ it("crawlUrl and asyncCrawlUrl rename v1 crawl options to their v2 names", async () => {
48
+ vi.spyOn(app, "crawl").mockResolvedValue({ status: "completed", data: [] } as any);
49
+ vi.spyOn(app, "startCrawl").mockResolvedValue({ id: "job-1", url: "u" } as any);
50
+ const v1Options = { limit: 2, maxDepth: 3, allowBackwardLinks: true, ignoreSitemap: true, scrapeOptions: { formats: ["markdown" as const] } };
51
+ const expected = { limit: 2, maxDiscoveryDepth: 3, crawlEntireDomain: true, sitemap: "skip", scrapeOptions: { formats: ["markdown"] } };
52
+
53
+ await app.crawlUrl("https://example.com", v1Options);
54
+ await app.asyncCrawlUrl("https://example.com", v1Options);
55
+
56
+ expect(app.crawl).toHaveBeenCalledWith("https://example.com", expected);
57
+ expect(app.startCrawl).toHaveBeenCalledWith("https://example.com", expected);
58
+ });
59
+
60
+ it("v2 methods return results without success", async () => {
61
+ const client = new FirecrawlClient({ apiKey: "fc-test", apiUrl: "http://localhost:9" });
62
+ const adapter: AxiosAdapter = async config => ({
63
+ data: { success: true, data: { markdown: "# hi" } },
64
+ status: 200,
65
+ statusText: "OK",
66
+ headers: {},
67
+ config,
68
+ });
69
+ (client as any).http.instance.defaults.adapter = adapter;
70
+ const result = await client.scrape("https://example.com", { formats: ["markdown"] });
71
+ expect(result).toEqual({ markdown: "# hi" });
72
+ expect("success" in result).toBe(false);
73
+ });
74
+ });
75
+
76
+ describe("V1 deprecation warning", () => {
77
+ afterEach(() => {
78
+ vi.restoreAllMocks();
79
+ });
80
+
81
+ async function freshClient() {
82
+ vi.resetModules();
83
+ const emitWarning = vi.spyOn(process, "emitWarning").mockImplementation(() => {});
84
+ const { FirecrawlClient: FreshClient } = await import("../../../v2/client");
85
+ const app = new FreshClient({ apiKey: "fc-test", apiUrl: "http://localhost:9" });
86
+ const v1Warnings = () => emitWarning.mock.calls.filter(([, opts]) => (opts as any)?.code === "FIRECRAWL_V1_METHOD");
87
+ return { app, v1Warnings };
88
+ }
89
+
90
+ it("is emitted once per process", async () => {
91
+ const { app, v1Warnings } = await freshClient();
92
+ vi.spyOn(app, "scrape").mockResolvedValue({ markdown: "# hi" } as any);
93
+ vi.spyOn(app, "map").mockResolvedValue({ links: [] } as any);
94
+
95
+ await app.scrapeUrl("https://example.com");
96
+ await app.scrapeUrl("https://example.com");
97
+ await app.mapUrl("https://example.com");
98
+
99
+ expect(v1Warnings()).toHaveLength(1);
100
+ expect((v1Warnings()[0]![1] as any).type).toBe("DeprecationWarning");
101
+ });
102
+
103
+ it("is not emitted by v2 methods", async () => {
104
+ const { app, v1Warnings } = await freshClient();
105
+ const adapter: AxiosAdapter = async config => ({
106
+ data: { success: true, data: { markdown: "# hi" } },
107
+ status: 200,
108
+ statusText: "OK",
109
+ headers: {},
110
+ config,
111
+ });
112
+ (app as any).http.instance.defaults.adapter = adapter;
113
+
114
+ await app.scrape("https://example.com", { formats: ["markdown"] });
115
+
116
+ expect(v1Warnings()).toHaveLength(0);
117
+ });
33
118
  });
package/src/v2/client.ts CHANGED
@@ -104,6 +104,7 @@ import type {
104
104
  import { defaultOrigin } from "../utils/callerOrigin";
105
105
  import { getVersion } from "./utils/getVersion";
106
106
  import { Watcher } from "./watcher";
107
+ import { callV1, toV2CrawlOptions, type V1CrawlOptions, type V1Result } from "./utils/v1Compat";
107
108
  import type { WatcherOptions } from "./watcher";
108
109
  import * as zt from "zod";
109
110
 
@@ -730,54 +731,54 @@ export class FirecrawlClient {
730
731
  return new Watcher(this.http, jobId, opts);
731
732
  }
732
733
 
733
- /** @deprecated V1 compatibility alias for agent recovery. Prefer scrape(). */
734
- async scrapeUrl(url: string, options?: ScrapeOptions): Promise<Document> {
735
- return this.scrape(url, options);
734
+ /** @deprecated v1 alias for scrape(); its result also carries v1's `success: true`. */
735
+ async scrapeUrl(url: string, options?: ScrapeOptions): Promise<V1Result<Document>> {
736
+ return callV1(() => this.scrape(url, options));
736
737
  }
737
738
 
738
- /** @deprecated V1 compatibility alias for agent recovery. Prefer crawl(). */
739
- async crawlUrl(url: string, req: CrawlOptions & { pollInterval?: number; timeout?: number; signal?: AbortSignal } = {}): Promise<CrawlJob> {
740
- return this.crawl(url, req);
739
+ /** @deprecated v1 alias for crawl(); its result also carries v1's `success: true`. */
740
+ async crawlUrl(url: string, req: CrawlOptions & V1CrawlOptions & { pollInterval?: number; timeout?: number; signal?: AbortSignal } = {}): Promise<V1Result<CrawlJob>> {
741
+ return callV1(() => this.crawl(url, toV2CrawlOptions(req)));
741
742
  }
742
743
 
743
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startCrawl(). */
744
- async asyncCrawlUrl(url: string, req: CrawlOptions = {}): Promise<CrawlResponse> {
745
- return this.startCrawl(url, req);
744
+ /** @deprecated v1 alias for startCrawl(); its result also carries v1's `success: true`. */
745
+ async asyncCrawlUrl(url: string, req: CrawlOptions & V1CrawlOptions = {}): Promise<V1Result<CrawlResponse>> {
746
+ return callV1(() => this.startCrawl(url, toV2CrawlOptions(req)));
746
747
  }
747
748
 
748
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlStatus(). */
749
- async checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<CrawlJob> {
750
- return this.getCrawlStatus(jobId, pagination);
749
+ /** @deprecated v1 alias for getCrawlStatus(); its result also carries v1's `success: true`. */
750
+ async checkCrawlStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<CrawlJob>> {
751
+ return callV1(() => this.getCrawlStatus(jobId, pagination));
751
752
  }
752
753
 
753
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getCrawlErrors(). */
754
- async checkCrawlErrors(crawlId: string): Promise<CrawlErrorsResponse> {
755
- return this.getCrawlErrors(crawlId);
754
+ /** @deprecated v1 alias for getCrawlErrors(); its result also carries v1's `success: true`. */
755
+ async checkCrawlErrors(crawlId: string): Promise<V1Result<CrawlErrorsResponse>> {
756
+ return callV1(() => this.getCrawlErrors(crawlId));
756
757
  }
757
758
 
758
- /** @deprecated V1 compatibility alias for agent recovery. Prefer map(). */
759
- async mapUrl(url: string, options?: MapOptions): Promise<MapData> {
760
- return this.map(url, options);
759
+ /** @deprecated v1 alias for map(); its result also carries v1's `success: true`. */
760
+ async mapUrl(url: string, options?: MapOptions): Promise<V1Result<MapData>> {
761
+ return callV1(() => this.map(url, options));
761
762
  }
762
763
 
763
- /** @deprecated V1 compatibility alias for agent recovery. Prefer batchScrape(). */
764
- async batchScrapeUrls(urls: string[], opts?: BatchScrapeOptions & { pollInterval?: number; timeout?: number }): Promise<BatchScrapeJob> {
765
- return this.batchScrape(urls, opts);
764
+ /** @deprecated v1 alias for batchScrape(); its result also carries v1's `success: true`. */
765
+ async batchScrapeUrls(urls: string[], opts?: BatchScrapeOptions & { pollInterval?: number; timeout?: number }): Promise<V1Result<BatchScrapeJob>> {
766
+ return callV1(() => this.batchScrape(urls, opts));
766
767
  }
767
768
 
768
- /** @deprecated V1 compatibility alias for agent recovery. Prefer startBatchScrape(). */
769
- async asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<BatchScrapeResponse> {
770
- return this.startBatchScrape(urls, opts);
769
+ /** @deprecated v1 alias for startBatchScrape(); its result also carries v1's `success: true`. */
770
+ async asyncBatchScrapeUrls(urls: string[], opts?: BatchScrapeOptions): Promise<V1Result<BatchScrapeResponse>> {
771
+ return callV1(() => this.startBatchScrape(urls, opts));
771
772
  }
772
773
 
773
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeStatus(). */
774
- async checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<BatchScrapeJob> {
775
- return this.getBatchScrapeStatus(jobId, pagination);
774
+ /** @deprecated v1 alias for getBatchScrapeStatus(); its result also carries v1's `success: true`. */
775
+ async checkBatchScrapeStatus(jobId: string, pagination?: PaginationConfig): Promise<V1Result<BatchScrapeJob>> {
776
+ return callV1(() => this.getBatchScrapeStatus(jobId, pagination));
776
777
  }
777
778
 
778
- /** @deprecated V1 compatibility alias for agent recovery. Prefer getBatchScrapeErrors(). */
779
- async checkBatchScrapeErrors(jobId: string): Promise<CrawlErrorsResponse> {
780
- return this.getBatchScrapeErrors(jobId);
779
+ /** @deprecated v1 alias for getBatchScrapeErrors(); its result also carries v1's `success: true`. */
780
+ async checkBatchScrapeErrors(jobId: string): Promise<V1Result<CrawlErrorsResponse>> {
781
+ return callV1(() => this.getBatchScrapeErrors(jobId));
781
782
  }
782
783
  }
783
784
 
@@ -0,0 +1,38 @@
1
+ let warned = false;
2
+
3
+ /** Emits the deprecation warning for v1-style method calls, once per process. */
4
+ export function warnV1Usage(): void {
5
+ if (warned) return;
6
+ warned = true;
7
+ const message =
8
+ "firecrawl: v1-style methods (scrapeUrl, crawlUrl, batchScrapeUrls, ...) are deprecated and mapped to the v2 API. " +
9
+ "Use scrape(), crawl(), batchScrape() and the other v2 methods instead.";
10
+ if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
11
+ process.emitWarning(message, { type: "DeprecationWarning", code: "FIRECRAWL_V1_METHOD" });
12
+ } else {
13
+ console.warn(message);
14
+ }
15
+ }
16
+
17
+ /** v1 crawl options that have a v2 equivalent. */
18
+ export type V1CrawlOptions = { maxDepth?: number; allowBackwardLinks?: boolean; ignoreSitemap?: boolean };
19
+
20
+ /** Renames v1 crawl options to their v2 names; v2 options given alongside win. */
21
+ export function toV2CrawlOptions<T extends object>(req: T & V1CrawlOptions): T {
22
+ const { maxDepth, allowBackwardLinks, ignoreSitemap, ...rest } = req;
23
+ return {
24
+ ...(maxDepth != null && { maxDiscoveryDepth: maxDepth }),
25
+ ...(allowBackwardLinks != null && { crawlEntireDomain: allowBackwardLinks }),
26
+ ...(ignoreSitemap != null && { sitemap: ignoreSitemap ? "skip" : "include" }),
27
+ ...rest,
28
+ } as T;
29
+ }
30
+
31
+ /** A v2 result with the `success` flag v1 results carried. */
32
+ export type V1Result<T> = T & { success: true };
33
+
34
+ /** Warns once, then runs the v2 call and adds the v1 `success` flag to its result. */
35
+ export async function callV1<T extends object>(call: () => Promise<T>): Promise<V1Result<T>> {
36
+ warnV1Usage();
37
+ return { ...(await call()), success: true };
38
+ }