@mendable/firecrawl-js 4.30.1 → 4.31.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/dist/{chunk-2LUWTM44.js → chunk-PSTSUWZW.js} +3 -3
- package/dist/index.cjs +7 -3
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -2
- package/dist/{package-2VNCXFNY.js → package-Q3WPQZ6Q.js} +1 -1
- package/package.json +2 -2
- package/src/__tests__/unit/v2/audit-metadata.unit.test.ts +79 -0
- package/src/v1/index.ts +2 -0
- package/src/v2/methods/agent.ts +3 -0
- package/src/v2/methods/map.ts +2 -0
- package/src/v2/types.ts +2 -0
|
@@ -12,7 +12,7 @@ var require_package = __commonJS({
|
|
|
12
12
|
"package.json"(exports, module) {
|
|
13
13
|
module.exports = {
|
|
14
14
|
name: "@mendable/firecrawl-js",
|
|
15
|
-
version: "4.
|
|
15
|
+
version: "4.31.0",
|
|
16
16
|
description: "JavaScript SDK for Firecrawl API",
|
|
17
17
|
main: "dist/index.js",
|
|
18
18
|
types: "dist/index.d.ts",
|
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
license: "MIT",
|
|
40
40
|
dependencies: {
|
|
41
41
|
axios: "1.18.0",
|
|
42
|
-
firecrawl: "4.
|
|
42
|
+
firecrawl: "4.30.1",
|
|
43
43
|
"typescript-event-target": "^1.1.1",
|
|
44
44
|
zod: "^3.23.8",
|
|
45
45
|
"zod-to-json-schema": "^3.23.0"
|
|
@@ -81,7 +81,7 @@ var require_package = __commonJS({
|
|
|
81
81
|
"rollup@<4.59.0": ">=4.59.0",
|
|
82
82
|
"picomatch@<4.0.4": ">=4.0.4",
|
|
83
83
|
handlebars: ">=4.7.9",
|
|
84
|
-
"brace-expansion": "
|
|
84
|
+
"brace-expansion@>=5.0.0 <5.0.7": "5.0.7",
|
|
85
85
|
"js-yaml@>=3.0.0 <3.15.0": "3.15.0",
|
|
86
86
|
"axios@>=1.0.0 <1.16.0": "1.16.1",
|
|
87
87
|
"follow-redirects@<1.16.0": ">=1.16.0 <2.0.0",
|
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.
|
|
42
|
+
version: "4.31.0",
|
|
43
43
|
description: "JavaScript SDK for Firecrawl API",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -66,7 +66,7 @@ var require_package = __commonJS({
|
|
|
66
66
|
license: "MIT",
|
|
67
67
|
dependencies: {
|
|
68
68
|
axios: "1.18.0",
|
|
69
|
-
firecrawl: "4.
|
|
69
|
+
firecrawl: "4.30.1",
|
|
70
70
|
"typescript-event-target": "^1.1.1",
|
|
71
71
|
zod: "^3.23.8",
|
|
72
72
|
"zod-to-json-schema": "^3.23.0"
|
|
@@ -108,7 +108,7 @@ var require_package = __commonJS({
|
|
|
108
108
|
"rollup@<4.59.0": ">=4.59.0",
|
|
109
109
|
"picomatch@<4.0.4": ">=4.0.4",
|
|
110
110
|
handlebars: ">=4.7.9",
|
|
111
|
-
"brace-expansion": "
|
|
111
|
+
"brace-expansion@>=5.0.0 <5.0.7": "5.0.7",
|
|
112
112
|
"js-yaml@>=3.0.0 <3.15.0": "3.15.0",
|
|
113
113
|
"axios@>=1.0.0 <1.16.0": "1.16.1",
|
|
114
114
|
"follow-redirects@<1.16.0": ">=1.16.0 <2.0.0",
|
|
@@ -802,6 +802,8 @@ function prepareMapPayload(url, options) {
|
|
|
802
802
|
if (options.location != null) payload.location = options.location;
|
|
803
803
|
if (options.threatProtection != null)
|
|
804
804
|
payload.threatProtection = options.threatProtection;
|
|
805
|
+
if (options.auditMetadata != null)
|
|
806
|
+
payload.auditMetadata = options.auditMetadata;
|
|
805
807
|
}
|
|
806
808
|
return payload;
|
|
807
809
|
}
|
|
@@ -1295,6 +1297,8 @@ function prepareAgentPayload(args) {
|
|
|
1295
1297
|
if (args.webhook != null) body.webhook = args.webhook;
|
|
1296
1298
|
if (args.threatProtection != null)
|
|
1297
1299
|
body.threatProtection = args.threatProtection;
|
|
1300
|
+
if (args.auditMetadata != null)
|
|
1301
|
+
body.auditMetadata = args.auditMetadata;
|
|
1298
1302
|
return body;
|
|
1299
1303
|
}
|
|
1300
1304
|
async function startAgent(http, args) {
|
package/dist/index.d.cts
CHANGED
|
@@ -142,6 +142,7 @@ interface ScrapeOptions {
|
|
|
142
142
|
lockdown?: boolean;
|
|
143
143
|
redactPII?: boolean | RedactPIIOptions;
|
|
144
144
|
threatProtection?: ThreatProtectionOptions;
|
|
145
|
+
auditMetadata?: Record<string, string>;
|
|
145
146
|
profile?: {
|
|
146
147
|
name: string;
|
|
147
148
|
saveChanges?: boolean;
|
|
@@ -635,6 +636,7 @@ interface MapOptions {
|
|
|
635
636
|
origin?: string;
|
|
636
637
|
location?: LocationConfig$1;
|
|
637
638
|
threatProtection?: ThreatProtectionOptions;
|
|
639
|
+
auditMetadata?: Record<string, string>;
|
|
638
640
|
}
|
|
639
641
|
type FeedbackRating = "good" | "partial" | "bad";
|
|
640
642
|
type EndpointFeedbackEndpoint = "search" | "scrape" | "parse" | "map";
|
|
@@ -1294,6 +1296,7 @@ declare function prepareAgentPayload(args: {
|
|
|
1294
1296
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
1295
1297
|
webhook?: string | AgentWebhookConfig;
|
|
1296
1298
|
threatProtection?: ThreatProtectionOptions;
|
|
1299
|
+
auditMetadata?: Record<string, string>;
|
|
1297
1300
|
}): Record<string, unknown>;
|
|
1298
1301
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
1299
1302
|
|
|
@@ -1857,6 +1860,7 @@ interface CrawlScrapeOptions {
|
|
|
1857
1860
|
storeInCache?: boolean;
|
|
1858
1861
|
maxAge?: number;
|
|
1859
1862
|
parsePDF?: boolean;
|
|
1863
|
+
auditMetadata?: Record<string, string>;
|
|
1860
1864
|
}
|
|
1861
1865
|
type Action = {
|
|
1862
1866
|
type: "wait";
|
|
@@ -2022,6 +2026,7 @@ interface MapParams {
|
|
|
2022
2026
|
timeout?: number;
|
|
2023
2027
|
useIndex?: boolean;
|
|
2024
2028
|
location?: LocationConfig;
|
|
2029
|
+
auditMetadata?: Record<string, string>;
|
|
2025
2030
|
}
|
|
2026
2031
|
/**
|
|
2027
2032
|
* Response interface for mapping operations.
|
package/dist/index.d.ts
CHANGED
|
@@ -142,6 +142,7 @@ interface ScrapeOptions {
|
|
|
142
142
|
lockdown?: boolean;
|
|
143
143
|
redactPII?: boolean | RedactPIIOptions;
|
|
144
144
|
threatProtection?: ThreatProtectionOptions;
|
|
145
|
+
auditMetadata?: Record<string, string>;
|
|
145
146
|
profile?: {
|
|
146
147
|
name: string;
|
|
147
148
|
saveChanges?: boolean;
|
|
@@ -635,6 +636,7 @@ interface MapOptions {
|
|
|
635
636
|
origin?: string;
|
|
636
637
|
location?: LocationConfig$1;
|
|
637
638
|
threatProtection?: ThreatProtectionOptions;
|
|
639
|
+
auditMetadata?: Record<string, string>;
|
|
638
640
|
}
|
|
639
641
|
type FeedbackRating = "good" | "partial" | "bad";
|
|
640
642
|
type EndpointFeedbackEndpoint = "search" | "scrape" | "parse" | "map";
|
|
@@ -1294,6 +1296,7 @@ declare function prepareAgentPayload(args: {
|
|
|
1294
1296
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
1295
1297
|
webhook?: string | AgentWebhookConfig;
|
|
1296
1298
|
threatProtection?: ThreatProtectionOptions;
|
|
1299
|
+
auditMetadata?: Record<string, string>;
|
|
1297
1300
|
}): Record<string, unknown>;
|
|
1298
1301
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
1299
1302
|
|
|
@@ -1857,6 +1860,7 @@ interface CrawlScrapeOptions {
|
|
|
1857
1860
|
storeInCache?: boolean;
|
|
1858
1861
|
maxAge?: number;
|
|
1859
1862
|
parsePDF?: boolean;
|
|
1863
|
+
auditMetadata?: Record<string, string>;
|
|
1860
1864
|
}
|
|
1861
1865
|
type Action = {
|
|
1862
1866
|
type: "wait";
|
|
@@ -2022,6 +2026,7 @@ interface MapParams {
|
|
|
2022
2026
|
timeout?: number;
|
|
2023
2027
|
useIndex?: boolean;
|
|
2024
2028
|
location?: LocationConfig;
|
|
2029
|
+
auditMetadata?: Record<string, string>;
|
|
2025
2030
|
}
|
|
2026
2031
|
/**
|
|
2027
2032
|
* Response interface for mapping operations.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PSTSUWZW.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -669,6 +669,8 @@ function prepareMapPayload(url, options) {
|
|
|
669
669
|
if (options.location != null) payload.location = options.location;
|
|
670
670
|
if (options.threatProtection != null)
|
|
671
671
|
payload.threatProtection = options.threatProtection;
|
|
672
|
+
if (options.auditMetadata != null)
|
|
673
|
+
payload.auditMetadata = options.auditMetadata;
|
|
672
674
|
}
|
|
673
675
|
return payload;
|
|
674
676
|
}
|
|
@@ -1162,6 +1164,8 @@ function prepareAgentPayload(args) {
|
|
|
1162
1164
|
if (args.webhook != null) body.webhook = args.webhook;
|
|
1163
1165
|
if (args.threatProtection != null)
|
|
1164
1166
|
body.threatProtection = args.threatProtection;
|
|
1167
|
+
if (args.auditMetadata != null)
|
|
1168
|
+
body.auditMetadata = args.auditMetadata;
|
|
1165
1169
|
return body;
|
|
1166
1170
|
}
|
|
1167
1171
|
async function startAgent(http, args) {
|
|
@@ -2312,7 +2316,7 @@ var FirecrawlApp = class {
|
|
|
2312
2316
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
2313
2317
|
return process.env.npm_package_version;
|
|
2314
2318
|
}
|
|
2315
|
-
const packageJson = await import("./package-
|
|
2319
|
+
const packageJson = await import("./package-Q3WPQZ6Q.js");
|
|
2316
2320
|
return packageJson.default.version;
|
|
2317
2321
|
} catch (error) {
|
|
2318
2322
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mendable/firecrawl-js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.0",
|
|
4
4
|
"description": "JavaScript SDK for Firecrawl API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"axios": "1.18.0",
|
|
23
|
-
"firecrawl": "4.
|
|
23
|
+
"firecrawl": "4.30.1",
|
|
24
24
|
"typescript-event-target": "^1.1.1",
|
|
25
25
|
"zod": "^3.23.8",
|
|
26
26
|
"zod-to-json-schema": "^3.23.0"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { describe, test, expect, jest } from "@jest/globals";
|
|
2
|
+
import { scrape } from "../../../v2/methods/scrape";
|
|
3
|
+
import { startBatchScrape } from "../../../v2/methods/batch";
|
|
4
|
+
import { startCrawl } from "../../../v2/methods/crawl";
|
|
5
|
+
import { search } from "../../../v2/methods/search";
|
|
6
|
+
import { map } from "../../../v2/methods/map";
|
|
7
|
+
import { startExtract } from "../../../v2/methods/extract";
|
|
8
|
+
import { startAgent } from "../../../v2/methods/agent";
|
|
9
|
+
|
|
10
|
+
const auditMetadata = { requestId: "req-123" };
|
|
11
|
+
|
|
12
|
+
function makeHttp(data: Record<string, unknown>) {
|
|
13
|
+
const post = jest.fn(async () => ({ status: 200, data }));
|
|
14
|
+
return {
|
|
15
|
+
post,
|
|
16
|
+
prepareHeaders: jest.fn(() => undefined),
|
|
17
|
+
} as any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("v2 auditMetadata request serialization", () => {
|
|
21
|
+
test("scrape and batch scrape send metadata at the top level", async () => {
|
|
22
|
+
const scrapeHttp = makeHttp({ success: true, data: {} });
|
|
23
|
+
await scrape(scrapeHttp, "https://example.com", { auditMetadata });
|
|
24
|
+
expect(scrapeHttp.post.mock.calls[0][1]).toEqual(
|
|
25
|
+
expect.objectContaining({ auditMetadata }),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const batchHttp = makeHttp({ success: true, id: "job", url: "u" });
|
|
29
|
+
await startBatchScrape(batchHttp, ["https://example.com"], {
|
|
30
|
+
options: { auditMetadata },
|
|
31
|
+
});
|
|
32
|
+
expect(batchHttp.post.mock.calls[0][1]).toEqual(
|
|
33
|
+
expect.objectContaining({ auditMetadata }),
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("crawl, search, and extract send metadata under scrapeOptions", async () => {
|
|
38
|
+
const crawlHttp = makeHttp({ success: true, id: "job", url: "u" });
|
|
39
|
+
await startCrawl(crawlHttp, {
|
|
40
|
+
url: "https://example.com",
|
|
41
|
+
scrapeOptions: { auditMetadata },
|
|
42
|
+
});
|
|
43
|
+
expect(crawlHttp.post.mock.calls[0][1]).toEqual(
|
|
44
|
+
expect.objectContaining({ scrapeOptions: expect.objectContaining({ auditMetadata }) }),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const searchHttp = makeHttp({ success: true, data: {} });
|
|
48
|
+
await search(searchHttp, {
|
|
49
|
+
query: "example",
|
|
50
|
+
scrapeOptions: { auditMetadata },
|
|
51
|
+
});
|
|
52
|
+
expect(searchHttp.post.mock.calls[0][1]).toEqual(
|
|
53
|
+
expect.objectContaining({ scrapeOptions: expect.objectContaining({ auditMetadata }) }),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const extractHttp = makeHttp({ success: true, id: "job" });
|
|
57
|
+
await startExtract(extractHttp, {
|
|
58
|
+
urls: ["https://example.com"],
|
|
59
|
+
scrapeOptions: { auditMetadata },
|
|
60
|
+
});
|
|
61
|
+
expect(extractHttp.post.mock.calls[0][1]).toEqual(
|
|
62
|
+
expect.objectContaining({ scrapeOptions: expect.objectContaining({ auditMetadata }) }),
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("map and agent send metadata at the top level", async () => {
|
|
67
|
+
const mapHttp = makeHttp({ success: true, links: [] });
|
|
68
|
+
await map(mapHttp, "https://example.com", { auditMetadata });
|
|
69
|
+
expect(mapHttp.post.mock.calls[0][1]).toEqual(
|
|
70
|
+
expect.objectContaining({ auditMetadata }),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const agentHttp = makeHttp({ success: true, id: "job" });
|
|
74
|
+
await startAgent(agentHttp, { prompt: "find pricing", auditMetadata });
|
|
75
|
+
expect(agentHttp.post.mock.calls[0][1]).toEqual(
|
|
76
|
+
expect.objectContaining({ auditMetadata }),
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
});
|
package/src/v1/index.ts
CHANGED
|
@@ -135,6 +135,7 @@ export interface CrawlScrapeOptions {
|
|
|
135
135
|
storeInCache?: boolean;
|
|
136
136
|
maxAge?: number;
|
|
137
137
|
parsePDF?: boolean;
|
|
138
|
+
auditMetadata?: Record<string, string>;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
export type Action = {
|
|
@@ -310,6 +311,7 @@ export interface MapParams {
|
|
|
310
311
|
timeout?: number;
|
|
311
312
|
useIndex?: boolean;
|
|
312
313
|
location?: LocationConfig;
|
|
314
|
+
auditMetadata?: Record<string, string>;
|
|
313
315
|
}
|
|
314
316
|
|
|
315
317
|
/**
|
package/src/v2/methods/agent.ts
CHANGED
|
@@ -15,6 +15,7 @@ function prepareAgentPayload(args: {
|
|
|
15
15
|
model?: "spark-1-pro" | "spark-1-mini";
|
|
16
16
|
webhook?: string | AgentWebhookConfig;
|
|
17
17
|
threatProtection?: ThreatProtectionOptions;
|
|
18
|
+
auditMetadata?: Record<string, string>;
|
|
18
19
|
}): Record<string, unknown> {
|
|
19
20
|
const body: Record<string, unknown> = {};
|
|
20
21
|
if (args.urls) body.urls = args.urls;
|
|
@@ -30,6 +31,8 @@ function prepareAgentPayload(args: {
|
|
|
30
31
|
if (args.webhook != null) body.webhook = args.webhook;
|
|
31
32
|
if (args.threatProtection != null)
|
|
32
33
|
body.threatProtection = args.threatProtection;
|
|
34
|
+
if (args.auditMetadata != null)
|
|
35
|
+
body.auditMetadata = args.auditMetadata;
|
|
33
36
|
return body;
|
|
34
37
|
}
|
|
35
38
|
|
package/src/v2/methods/map.ts
CHANGED
|
@@ -26,6 +26,8 @@ function prepareMapPayload(
|
|
|
26
26
|
if (options.location != null) payload.location = options.location;
|
|
27
27
|
if (options.threatProtection != null)
|
|
28
28
|
payload.threatProtection = options.threatProtection;
|
|
29
|
+
if (options.auditMetadata != null)
|
|
30
|
+
payload.auditMetadata = options.auditMetadata;
|
|
29
31
|
}
|
|
30
32
|
return payload;
|
|
31
33
|
}
|
package/src/v2/types.ts
CHANGED
|
@@ -209,6 +209,7 @@ export interface ScrapeOptions {
|
|
|
209
209
|
lockdown?: boolean;
|
|
210
210
|
redactPII?: boolean | RedactPIIOptions;
|
|
211
211
|
threatProtection?: ThreatProtectionOptions;
|
|
212
|
+
auditMetadata?: Record<string, string>;
|
|
212
213
|
profile?: {
|
|
213
214
|
name: string;
|
|
214
215
|
saveChanges?: boolean;
|
|
@@ -796,6 +797,7 @@ export interface MapOptions {
|
|
|
796
797
|
origin?: string;
|
|
797
798
|
location?: LocationConfig;
|
|
798
799
|
threatProtection?: ThreatProtectionOptions;
|
|
800
|
+
auditMetadata?: Record<string, string>;
|
|
799
801
|
}
|
|
800
802
|
|
|
801
803
|
export type FeedbackRating = "good" | "partial" | "bad";
|