firecrawl 3.0.3 → 3.1.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.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "3.0.3",
11
+ version: "3.1.0",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "3.0.3",
38
+ version: "3.1.0",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -327,6 +327,21 @@ function prepareSearchPayload(req) {
327
327
  }
328
328
  return payload;
329
329
  }
330
+ function transformArray(arr) {
331
+ const results = [];
332
+ for (const item of arr) {
333
+ if (item && typeof item === "object") {
334
+ if ("markdown" in item || "html" in item || "rawHtml" in item || "links" in item || "screenshot" in item || "changeTracking" in item || "summary" in item || "json" in item) {
335
+ results.push(item);
336
+ } else {
337
+ results.push(item);
338
+ }
339
+ } else {
340
+ results.push({ url: item });
341
+ }
342
+ }
343
+ return results;
344
+ }
330
345
  async function search(http, request) {
331
346
  const payload = prepareSearchPayload(request);
332
347
  try {
@@ -336,24 +351,9 @@ async function search(http, request) {
336
351
  }
337
352
  const data = res.data.data || {};
338
353
  const out = {};
339
- for (const key of Object.keys(data)) {
340
- const arr = data[key];
341
- if (Array.isArray(arr)) {
342
- const results = [];
343
- for (const item of arr) {
344
- if (item && typeof item === "object") {
345
- if ("markdown" in item || "html" in item || "rawHtml" in item || "links" in item || "screenshot" in item || "changeTracking" in item || "summary" in item || "json" in item) {
346
- results.push(item);
347
- } else {
348
- results.push({ url: item.url, title: item.title, description: item.description });
349
- }
350
- } else if (typeof item === "string") {
351
- results.push({ url: item });
352
- }
353
- }
354
- out[key] = results;
355
- }
356
- }
354
+ if (data.web) out.web = transformArray(data.web);
355
+ if (data.news) out.news = transformArray(data.news);
356
+ if (data.images) out.images = transformArray(data.images);
357
357
  return out;
358
358
  } catch (err) {
359
359
  if (err?.isAxiosError) return normalizeAxiosError(err, "search");
package/dist/index.d.cts CHANGED
@@ -138,15 +138,31 @@ interface Document {
138
138
  warning?: string;
139
139
  changeTracking?: Record<string, unknown>;
140
140
  }
141
- interface SearchResult {
141
+ interface SearchResultWeb {
142
142
  url: string;
143
143
  title?: string;
144
144
  description?: string;
145
145
  }
146
+ interface SearchResultNews {
147
+ title?: string;
148
+ url?: string;
149
+ snippet?: string;
150
+ date?: string;
151
+ imageUrl?: string;
152
+ position?: number;
153
+ }
154
+ interface SearchResultImages {
155
+ title?: string;
156
+ imageUrl?: string;
157
+ imageWidth?: number;
158
+ imageHeight?: number;
159
+ url?: string;
160
+ position?: number;
161
+ }
146
162
  interface SearchData {
147
- web?: Array<SearchResult | Document>;
148
- news?: Array<SearchResult | Document>;
149
- images?: Array<SearchResult | Document>;
163
+ web?: Array<SearchResultWeb | Document>;
164
+ news?: Array<SearchResultNews | Document>;
165
+ images?: Array<SearchResultImages | Document>;
150
166
  }
151
167
  interface SearchRequest {
152
168
  query: string;
@@ -215,7 +231,7 @@ interface BatchScrapeJob {
215
231
  data: Document[];
216
232
  }
217
233
  interface MapData {
218
- links: SearchResult[];
234
+ links: SearchResultWeb[];
219
235
  }
220
236
  interface MapOptions {
221
237
  search?: string;
@@ -1326,4 +1342,4 @@ declare class Firecrawl extends FirecrawlClient {
1326
1342
  get v1(): FirecrawlApp;
1327
1343
  }
1328
1344
 
1329
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type Format, type FormatOption, type FormatString, type JsonFormat, type LocationConfig, type MapData, type MapOptions, type PDFAction, type PressAction, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResult, type TokenUsage, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
1345
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type Format, type FormatOption, type FormatString, type JsonFormat, type LocationConfig, type MapData, type MapOptions, type PDFAction, type PressAction, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.d.ts CHANGED
@@ -138,15 +138,31 @@ interface Document {
138
138
  warning?: string;
139
139
  changeTracking?: Record<string, unknown>;
140
140
  }
141
- interface SearchResult {
141
+ interface SearchResultWeb {
142
142
  url: string;
143
143
  title?: string;
144
144
  description?: string;
145
145
  }
146
+ interface SearchResultNews {
147
+ title?: string;
148
+ url?: string;
149
+ snippet?: string;
150
+ date?: string;
151
+ imageUrl?: string;
152
+ position?: number;
153
+ }
154
+ interface SearchResultImages {
155
+ title?: string;
156
+ imageUrl?: string;
157
+ imageWidth?: number;
158
+ imageHeight?: number;
159
+ url?: string;
160
+ position?: number;
161
+ }
146
162
  interface SearchData {
147
- web?: Array<SearchResult | Document>;
148
- news?: Array<SearchResult | Document>;
149
- images?: Array<SearchResult | Document>;
163
+ web?: Array<SearchResultWeb | Document>;
164
+ news?: Array<SearchResultNews | Document>;
165
+ images?: Array<SearchResultImages | Document>;
150
166
  }
151
167
  interface SearchRequest {
152
168
  query: string;
@@ -215,7 +231,7 @@ interface BatchScrapeJob {
215
231
  data: Document[];
216
232
  }
217
233
  interface MapData {
218
- links: SearchResult[];
234
+ links: SearchResultWeb[];
219
235
  }
220
236
  interface MapOptions {
221
237
  search?: string;
@@ -1326,4 +1342,4 @@ declare class Firecrawl extends FirecrawlClient {
1326
1342
  get v1(): FirecrawlApp;
1327
1343
  }
1328
1344
 
1329
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type Format, type FormatOption, type FormatString, type JsonFormat, type LocationConfig, type MapData, type MapOptions, type PDFAction, type PressAction, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResult, type TokenUsage, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
1345
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type Format, type FormatOption, type FormatString, type JsonFormat, type LocationConfig, type MapData, type MapOptions, type PDFAction, type PressAction, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-OIZ6OKY4.js";
3
+ } from "./chunk-WNGXI3ZW.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -211,6 +211,21 @@ function prepareSearchPayload(req) {
211
211
  }
212
212
  return payload;
213
213
  }
214
+ function transformArray(arr) {
215
+ const results = [];
216
+ for (const item of arr) {
217
+ if (item && typeof item === "object") {
218
+ if ("markdown" in item || "html" in item || "rawHtml" in item || "links" in item || "screenshot" in item || "changeTracking" in item || "summary" in item || "json" in item) {
219
+ results.push(item);
220
+ } else {
221
+ results.push(item);
222
+ }
223
+ } else {
224
+ results.push({ url: item });
225
+ }
226
+ }
227
+ return results;
228
+ }
214
229
  async function search(http, request) {
215
230
  const payload = prepareSearchPayload(request);
216
231
  try {
@@ -220,24 +235,9 @@ async function search(http, request) {
220
235
  }
221
236
  const data = res.data.data || {};
222
237
  const out = {};
223
- for (const key of Object.keys(data)) {
224
- const arr = data[key];
225
- if (Array.isArray(arr)) {
226
- const results = [];
227
- for (const item of arr) {
228
- if (item && typeof item === "object") {
229
- if ("markdown" in item || "html" in item || "rawHtml" in item || "links" in item || "screenshot" in item || "changeTracking" in item || "summary" in item || "json" in item) {
230
- results.push(item);
231
- } else {
232
- results.push({ url: item.url, title: item.title, description: item.description });
233
- }
234
- } else if (typeof item === "string") {
235
- results.push({ url: item });
236
- }
237
- }
238
- out[key] = results;
239
- }
240
- }
238
+ if (data.web) out.web = transformArray(data.web);
239
+ if (data.news) out.news = transformArray(data.news);
240
+ if (data.images) out.images = transformArray(data.images);
241
241
  return out;
242
242
  } catch (err) {
243
243
  if (err?.isAxiosError) return normalizeAxiosError(err, "search");
@@ -932,7 +932,7 @@ var FirecrawlApp = class {
932
932
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
933
933
  return process.env.npm_package_version;
934
934
  }
935
- const packageJson = await import("./package-V5IPFKBE.js");
935
+ const packageJson = await import("./package-KMFB7KZD.js");
936
936
  return packageJson.default.version;
937
937
  } catch (error) {
938
938
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-OIZ6OKY4.js";
3
+ } from "./chunk-WNGXI3ZW.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { type Document, type SearchData, type SearchRequest, type SearchResult, type ScrapeOptions } from "../types";
1
+ import { type Document, type SearchData, type SearchRequest, type SearchResultWeb, type ScrapeOptions, type SearchResultNews, type SearchResultImages } from "../types";
2
2
  import { HttpClient } from "../utils/httpClient";
3
3
  import { ensureValidScrapeOptions } from "../utils/validation";
4
4
  import { throwForBadResponse, normalizeAxiosError } from "../utils/errorHandler";
@@ -23,6 +23,31 @@ function prepareSearchPayload(req: SearchRequest): Record<string, unknown> {
23
23
  return payload;
24
24
  }
25
25
 
26
+ function transformArray<ResultType>(arr: any[]): Array<ResultType | Document> {
27
+ const results: Array<ResultType | Document> = [] as any;
28
+ for (const item of arr) {
29
+ if (item && typeof item === "object") {
30
+ if (
31
+ "markdown" in item ||
32
+ "html" in item ||
33
+ "rawHtml" in item ||
34
+ "links" in item ||
35
+ "screenshot" in item ||
36
+ "changeTracking" in item ||
37
+ "summary" in item ||
38
+ "json" in item
39
+ ) {
40
+ results.push(item as Document);
41
+ } else {
42
+ results.push(item as ResultType);
43
+ }
44
+ } else {
45
+ results.push({ url: item } as ResultType);
46
+ }
47
+ }
48
+ return results;
49
+ }
50
+
26
51
  export async function search(http: HttpClient, request: SearchRequest): Promise<SearchData> {
27
52
  const payload = prepareSearchPayload(request);
28
53
  try {
@@ -32,34 +57,9 @@ export async function search(http: HttpClient, request: SearchRequest): Promise<
32
57
  }
33
58
  const data = (res.data.data || {}) as Record<string, any>;
34
59
  const out: SearchData = {};
35
- for (const key of Object.keys(data)) {
36
- const arr = data[key];
37
- if (Array.isArray(arr)) {
38
- const results: Array<SearchResult | Document> = [] as any;
39
- for (const item of arr) {
40
- if (item && typeof item === "object") {
41
- // If scraped page fields present, treat as Document; otherwise SearchResult
42
- if (
43
- "markdown" in item ||
44
- "html" in item ||
45
- "rawHtml" in item ||
46
- "links" in item ||
47
- "screenshot" in item ||
48
- "changeTracking" in item ||
49
- "summary" in item ||
50
- "json" in item
51
- ) {
52
- results.push(item as Document);
53
- } else {
54
- results.push({ url: item.url, title: item.title, description: item.description } as SearchResult);
55
- }
56
- } else if (typeof item === "string") {
57
- results.push({ url: item } as SearchResult);
58
- }
59
- }
60
- (out as any)[key] = results;
61
- }
62
- }
60
+ if (data.web) out.web = transformArray<SearchResultWeb>(data.web);
61
+ if (data.news) out.news = transformArray<SearchResultNews>(data.news);
62
+ if (data.images) out.images = transformArray<SearchResultImages>(data.images);
63
63
  return out;
64
64
  } catch (err: any) {
65
65
  if (err?.isAxiosError) return normalizeAxiosError(err, "search");
package/src/v2/types.ts CHANGED
@@ -173,16 +173,34 @@ export interface Document {
173
173
  changeTracking?: Record<string, unknown>;
174
174
  }
175
175
 
176
- export interface SearchResult {
176
+ export interface SearchResultWeb {
177
177
  url: string;
178
178
  title?: string;
179
179
  description?: string;
180
180
  }
181
181
 
182
+ export interface SearchResultNews {
183
+ title?: string;
184
+ url?: string;
185
+ snippet?: string;
186
+ date?: string;
187
+ imageUrl?: string;
188
+ position?: number;
189
+ }
190
+
191
+ export interface SearchResultImages {
192
+ title?: string;
193
+ imageUrl?: string;
194
+ imageWidth?: number;
195
+ imageHeight?: number;
196
+ url?: string;
197
+ position?: number;
198
+ }
199
+
182
200
  export interface SearchData {
183
- web?: Array<SearchResult | Document>;
184
- news?: Array<SearchResult | Document>;
185
- images?: Array<SearchResult | Document>;
201
+ web?: Array<SearchResultWeb | Document>;
202
+ news?: Array<SearchResultNews | Document>;
203
+ images?: Array<SearchResultImages | Document>;
186
204
  }
187
205
 
188
206
  export interface SearchRequest {
@@ -257,7 +275,7 @@ export interface BatchScrapeJob {
257
275
  }
258
276
 
259
277
  export interface MapData {
260
- links: SearchResult[];
278
+ links: SearchResultWeb[];
261
279
  }
262
280
 
263
281
  export interface MapOptions {