firecrawl 1.4.3 → 1.4.5

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.d.cts CHANGED
@@ -54,7 +54,7 @@ interface FirecrawlDocumentMetadata {
54
54
  * Document interface for Firecrawl.
55
55
  * Represents a document retrieved or processed by Firecrawl.
56
56
  */
57
- interface FirecrawlDocument<T> {
57
+ interface FirecrawlDocument<T = any> {
58
58
  url?: string;
59
59
  markdown?: string;
60
60
  html?: string;
@@ -69,7 +69,7 @@ interface FirecrawlDocument<T> {
69
69
  * Defines the options and configurations available for scraping web content.
70
70
  */
71
71
  interface CrawlScrapeOptions {
72
- formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
72
+ formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "screenshot@fullPage" | "extract")[];
73
73
  headers?: Record<string, string>;
74
74
  includeTags?: string[];
75
75
  excludeTags?: string[];
@@ -77,7 +77,7 @@ interface CrawlScrapeOptions {
77
77
  waitFor?: number;
78
78
  timeout?: number;
79
79
  }
80
- interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
80
+ interface ScrapeParams<LLMSchema extends zt.ZodSchema = any> extends CrawlScrapeOptions {
81
81
  extract?: {
82
82
  prompt?: string;
83
83
  schema?: LLMSchema;
@@ -88,7 +88,7 @@ interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOption
88
88
  * Response interface for scraping operations.
89
89
  * Defines the structure of the response received after a scraping operation.
90
90
  */
91
- interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
91
+ interface ScrapeResponse<LLMResult = any> extends FirecrawlDocument<LLMResult> {
92
92
  success: true;
93
93
  warning?: string;
94
94
  error?: string;
package/dist/index.d.ts CHANGED
@@ -54,7 +54,7 @@ interface FirecrawlDocumentMetadata {
54
54
  * Document interface for Firecrawl.
55
55
  * Represents a document retrieved or processed by Firecrawl.
56
56
  */
57
- interface FirecrawlDocument<T> {
57
+ interface FirecrawlDocument<T = any> {
58
58
  url?: string;
59
59
  markdown?: string;
60
60
  html?: string;
@@ -69,7 +69,7 @@ interface FirecrawlDocument<T> {
69
69
  * Defines the options and configurations available for scraping web content.
70
70
  */
71
71
  interface CrawlScrapeOptions {
72
- formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
72
+ formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "screenshot@fullPage" | "extract")[];
73
73
  headers?: Record<string, string>;
74
74
  includeTags?: string[];
75
75
  excludeTags?: string[];
@@ -77,7 +77,7 @@ interface CrawlScrapeOptions {
77
77
  waitFor?: number;
78
78
  timeout?: number;
79
79
  }
80
- interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
80
+ interface ScrapeParams<LLMSchema extends zt.ZodSchema = any> extends CrawlScrapeOptions {
81
81
  extract?: {
82
82
  prompt?: string;
83
83
  schema?: LLMSchema;
@@ -88,7 +88,7 @@ interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOption
88
88
  * Response interface for scraping operations.
89
89
  * Defines the structure of the response received after a scraping operation.
90
90
  */
91
- interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
91
+ interface ScrapeResponse<LLMResult = any> extends FirecrawlDocument<LLMResult> {
92
92
  success: true;
93
93
  warning?: string;
94
94
  error?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,14 +28,22 @@ describe('FirecrawlApp E2E Tests', () => {
28
28
 
29
29
  test.concurrent('should return successful response with valid preview token', async () => {
30
30
  const app = new FirecrawlApp({ apiKey: "this_is_just_a_preview_token", apiUrl: API_URL });
31
- const response = await app.scrapeUrl('https://roastmywebsite.ai') as ScrapeResponse;
31
+ const response = await app.scrapeUrl('https://roastmywebsite.ai');
32
+ if (!response.success) {
33
+ throw new Error(response.error);
34
+ }
35
+
32
36
  expect(response).not.toBeNull();
33
37
  expect(response?.markdown).toContain("_Roast_");
34
38
  }, 30000); // 30 seconds timeout
35
39
 
36
40
  test.concurrent('should return successful response for valid scrape', async () => {
37
41
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
38
- const response = await app.scrapeUrl('https://roastmywebsite.ai') as ScrapeResponse;
42
+ const response = await app.scrapeUrl('https://roastmywebsite.ai');
43
+ if (!response.success) {
44
+ throw new Error(response.error);
45
+ }
46
+
39
47
  expect(response).not.toBeNull();
40
48
  expect(response).not.toHaveProperty('content'); // v0
41
49
  expect(response).not.toHaveProperty('html');
@@ -58,7 +66,11 @@ describe('FirecrawlApp E2E Tests', () => {
58
66
  onlyMainContent: true,
59
67
  timeout: 30000,
60
68
  waitFor: 1000
61
- }) as ScrapeResponse;
69
+ });
70
+ if (!response.success) {
71
+ throw new Error(response.error);
72
+ }
73
+
62
74
  expect(response).not.toBeNull();
63
75
  expect(response).not.toHaveProperty('content'); // v0
64
76
  expect(response.markdown).toContain("_Roast_");
@@ -86,6 +98,7 @@ describe('FirecrawlApp E2E Tests', () => {
86
98
  expect(response.metadata).not.toHaveProperty("pageStatusCode");
87
99
  expect(response.metadata).toHaveProperty("statusCode");
88
100
  expect(response.metadata).not.toHaveProperty("pageError");
101
+
89
102
  if (response.metadata !== undefined) {
90
103
  expect(response.metadata.error).toBeUndefined();
91
104
  expect(response.metadata.title).toBe("Roast My Website");
@@ -103,16 +116,40 @@ describe('FirecrawlApp E2E Tests', () => {
103
116
  }
104
117
  }, 30000); // 30 seconds timeout
105
118
 
119
+ test.concurrent('should return successful response with valid API key and screenshot fullPage', async () => {
120
+ const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
121
+ const response = await app.scrapeUrl(
122
+ 'https://roastmywebsite.ai', {
123
+ formats: ['screenshot@fullPage'],
124
+ });
125
+ if (!response.success) {
126
+ throw new Error(response.error);
127
+ }
128
+
129
+ expect(response).not.toBeNull();
130
+ expect(response.screenshot).not.toBeUndefined();
131
+ expect(response.screenshot).not.toBeNull();
132
+ expect(response.screenshot).toContain("https://");
133
+ }, 30000); // 30 seconds timeout
134
+
106
135
  test.concurrent('should return successful response for valid scrape with PDF file', async () => {
107
136
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
108
- const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001.pdf') as ScrapeResponse;
137
+ const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001.pdf');
138
+ if (!response.success) {
139
+ throw new Error(response.error);
140
+ }
141
+
109
142
  expect(response).not.toBeNull();
110
143
  expect(response?.markdown).toContain('We present spectrophotometric observations of the Broad Line Radio Galaxy');
111
144
  }, 30000); // 30 seconds timeout
112
145
 
113
146
  test.concurrent('should return successful response for valid scrape with PDF file without explicit extension', async () => {
114
147
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
115
- const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001') as ScrapeResponse;
148
+ const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001');
149
+ if (!response.success) {
150
+ throw new Error(response.error);
151
+ }
152
+
116
153
  expect(response).not.toBeNull();
117
154
  expect(response?.markdown).toContain('We present spectrophotometric observations of the Broad Line Radio Galaxy');
118
155
  }, 30000); // 30 seconds timeout
package/src/index.ts CHANGED
@@ -58,7 +58,7 @@ export interface FirecrawlDocumentMetadata {
58
58
  * Document interface for Firecrawl.
59
59
  * Represents a document retrieved or processed by Firecrawl.
60
60
  */
61
- export interface FirecrawlDocument<T> {
61
+ export interface FirecrawlDocument<T = any> {
62
62
  url?: string;
63
63
  markdown?: string;
64
64
  html?: string;
@@ -74,7 +74,7 @@ export interface FirecrawlDocument<T> {
74
74
  * Defines the options and configurations available for scraping web content.
75
75
  */
76
76
  export interface CrawlScrapeOptions {
77
- formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
77
+ formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "screenshot@fullPage" | "extract")[];
78
78
  headers?: Record<string, string>;
79
79
  includeTags?: string[];
80
80
  excludeTags?: string[];
@@ -83,7 +83,7 @@ export interface CrawlScrapeOptions {
83
83
  timeout?: number;
84
84
  }
85
85
 
86
- export interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
86
+ export interface ScrapeParams<LLMSchema extends zt.ZodSchema = any> extends CrawlScrapeOptions {
87
87
  extract?: {
88
88
  prompt?: string;
89
89
  schema?: LLMSchema;
@@ -95,7 +95,7 @@ export interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrap
95
95
  * Response interface for scraping operations.
96
96
  * Defines the structure of the response received after a scraping operation.
97
97
  */
98
- export interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
98
+ export interface ScrapeResponse<LLMResult = any> extends FirecrawlDocument<LLMResult> {
99
99
  success: true;
100
100
  warning?: string;
101
101
  error?: string;