@mendable/firecrawl-js 4.31.1 → 4.32.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-BEF2NAMB.js → chunk-DBXKWZGC.js} +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -2
- package/dist/{package-GIVYQAT4.js → package-L37ZVTF4.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/search-developer.unit.test.ts +65 -0
- package/src/v2/methods/search.ts +4 -0
- package/src/v2/types.ts +6 -2
|
@@ -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.32.0",
|
|
16
16
|
description: "JavaScript SDK for Firecrawl API",
|
|
17
17
|
main: "dist/index.js",
|
|
18
18
|
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.
|
|
42
|
+
version: "4.32.0",
|
|
43
43
|
description: "JavaScript SDK for Firecrawl API",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -746,12 +746,16 @@ async function search(http, request) {
|
|
|
746
746
|
if (data.news) out.news = transformArray(data.news);
|
|
747
747
|
if (data.images)
|
|
748
748
|
out.images = transformArray(data.images);
|
|
749
|
+
if (data.developer)
|
|
750
|
+
out.developer = transformArray(data.developer);
|
|
749
751
|
Object.defineProperty(out, "data", {
|
|
750
752
|
get() {
|
|
751
753
|
const parts = [];
|
|
752
754
|
if (out.web?.length) parts.push(`.web (${out.web.length} results)`);
|
|
753
755
|
if (out.news?.length) parts.push(`.news (${out.news.length} results)`);
|
|
754
756
|
if (out.images?.length) parts.push(`.images (${out.images.length} results)`);
|
|
757
|
+
if (out.developer?.length)
|
|
758
|
+
parts.push(`.developer (${out.developer.length} results)`);
|
|
755
759
|
const available = parts.length ? parts.join(", ") : ".web, .news, or .images";
|
|
756
760
|
throw new Error(
|
|
757
761
|
`SearchData has no '.data'. Results are grouped by source: ${available}`
|
package/dist/index.d.cts
CHANGED
|
@@ -508,6 +508,7 @@ interface SearchResultWeb {
|
|
|
508
508
|
url: string;
|
|
509
509
|
title?: string;
|
|
510
510
|
description?: string;
|
|
511
|
+
position?: number;
|
|
511
512
|
category?: string;
|
|
512
513
|
}
|
|
513
514
|
interface SearchResultNews {
|
|
@@ -531,16 +532,17 @@ interface SearchData {
|
|
|
531
532
|
web?: Array<SearchResultWeb | Document>;
|
|
532
533
|
news?: Array<SearchResultNews | Document>;
|
|
533
534
|
images?: Array<SearchResultImages | Document>;
|
|
535
|
+
developer?: Array<SearchResultWeb | Document>;
|
|
534
536
|
}
|
|
535
537
|
interface CategoryOption {
|
|
536
|
-
type: "github" | "research" | "pdf";
|
|
538
|
+
type: "github" | "research" | "pdf" | "developer";
|
|
537
539
|
}
|
|
538
540
|
interface SearchRequest {
|
|
539
541
|
query: string;
|
|
540
542
|
sources?: Array<"web" | "news" | "images" | {
|
|
541
543
|
type: "web" | "news" | "images";
|
|
542
544
|
}>;
|
|
543
|
-
categories?: Array<"github" | "research" | "pdf" | CategoryOption>;
|
|
545
|
+
categories?: Array<"github" | "research" | "pdf" | "developer" | CategoryOption>;
|
|
544
546
|
includeDomains?: string[];
|
|
545
547
|
excludeDomains?: string[];
|
|
546
548
|
limit?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -508,6 +508,7 @@ interface SearchResultWeb {
|
|
|
508
508
|
url: string;
|
|
509
509
|
title?: string;
|
|
510
510
|
description?: string;
|
|
511
|
+
position?: number;
|
|
511
512
|
category?: string;
|
|
512
513
|
}
|
|
513
514
|
interface SearchResultNews {
|
|
@@ -531,16 +532,17 @@ interface SearchData {
|
|
|
531
532
|
web?: Array<SearchResultWeb | Document>;
|
|
532
533
|
news?: Array<SearchResultNews | Document>;
|
|
533
534
|
images?: Array<SearchResultImages | Document>;
|
|
535
|
+
developer?: Array<SearchResultWeb | Document>;
|
|
534
536
|
}
|
|
535
537
|
interface CategoryOption {
|
|
536
|
-
type: "github" | "research" | "pdf";
|
|
538
|
+
type: "github" | "research" | "pdf" | "developer";
|
|
537
539
|
}
|
|
538
540
|
interface SearchRequest {
|
|
539
541
|
query: string;
|
|
540
542
|
sources?: Array<"web" | "news" | "images" | {
|
|
541
543
|
type: "web" | "news" | "images";
|
|
542
544
|
}>;
|
|
543
|
-
categories?: Array<"github" | "research" | "pdf" | CategoryOption>;
|
|
545
|
+
categories?: Array<"github" | "research" | "pdf" | "developer" | CategoryOption>;
|
|
544
546
|
includeDomains?: string[];
|
|
545
547
|
excludeDomains?: string[];
|
|
546
548
|
limit?: number;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DBXKWZGC.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -629,12 +629,16 @@ async function search(http, request) {
|
|
|
629
629
|
if (data.news) out.news = transformArray(data.news);
|
|
630
630
|
if (data.images)
|
|
631
631
|
out.images = transformArray(data.images);
|
|
632
|
+
if (data.developer)
|
|
633
|
+
out.developer = transformArray(data.developer);
|
|
632
634
|
Object.defineProperty(out, "data", {
|
|
633
635
|
get() {
|
|
634
636
|
const parts = [];
|
|
635
637
|
if (out.web?.length) parts.push(`.web (${out.web.length} results)`);
|
|
636
638
|
if (out.news?.length) parts.push(`.news (${out.news.length} results)`);
|
|
637
639
|
if (out.images?.length) parts.push(`.images (${out.images.length} results)`);
|
|
640
|
+
if (out.developer?.length)
|
|
641
|
+
parts.push(`.developer (${out.developer.length} results)`);
|
|
638
642
|
const available = parts.length ? parts.join(", ") : ".web, .news, or .images";
|
|
639
643
|
throw new Error(
|
|
640
644
|
`SearchData has no '.data'. Results are grouped by source: ${available}`
|
|
@@ -2316,7 +2320,7 @@ var FirecrawlApp = class {
|
|
|
2316
2320
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
2317
2321
|
return process.env.npm_package_version;
|
|
2318
2322
|
}
|
|
2319
|
-
const packageJson = await import("./package-
|
|
2323
|
+
const packageJson = await import("./package-L37ZVTF4.js");
|
|
2320
2324
|
return packageJson.default.version;
|
|
2321
2325
|
} catch (error) {
|
|
2322
2326
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
package/package.json
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { search } from "../../../v2/methods/search";
|
|
3
|
+
|
|
4
|
+
const developerResult = {
|
|
5
|
+
title: "https://github.com/firecrawl/firecrawl/issues/1",
|
|
6
|
+
url: "https://github.com/firecrawl/firecrawl/issues/1",
|
|
7
|
+
description: "passage",
|
|
8
|
+
position: 1,
|
|
9
|
+
category: "developer",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function httpWith(data: Record<string, unknown>) {
|
|
13
|
+
return {
|
|
14
|
+
post: jest.fn(async () => ({ status: 200, data: { success: true, data } })),
|
|
15
|
+
} as any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("v2 search developer category", () => {
|
|
19
|
+
test("forwards the developer category", async () => {
|
|
20
|
+
const http = httpWith({});
|
|
21
|
+
|
|
22
|
+
await search(http, { query: "firecrawl", categories: ["developer"] });
|
|
23
|
+
|
|
24
|
+
expect(http.post).toHaveBeenCalledWith(
|
|
25
|
+
"/v2/search",
|
|
26
|
+
{ query: "firecrawl", categories: ["developer"] },
|
|
27
|
+
{},
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("returns developer results", async () => {
|
|
32
|
+
const http = httpWith({
|
|
33
|
+
web: [{ title: "W", url: "http://a.com" }],
|
|
34
|
+
developer: [developerResult],
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const result = await search(http, {
|
|
38
|
+
query: "firecrawl",
|
|
39
|
+
categories: [{ type: "developer" }],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(result.web).toHaveLength(1);
|
|
43
|
+
expect(result.developer).toHaveLength(1);
|
|
44
|
+
expect(result.developer?.[0]).toEqual(developerResult);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("omits developer when the response has none", async () => {
|
|
48
|
+
const http = httpWith({ web: [] });
|
|
49
|
+
|
|
50
|
+
const result = await search(http, { query: "firecrawl" });
|
|
51
|
+
|
|
52
|
+
expect(result.developer).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("lists developer in the .data error", async () => {
|
|
56
|
+
const http = httpWith({ developer: [developerResult] });
|
|
57
|
+
|
|
58
|
+
const result = await search(http, {
|
|
59
|
+
query: "firecrawl",
|
|
60
|
+
categories: ["developer"],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(() => (result as any).data).toThrow(/\.developer \(1 results\)/);
|
|
64
|
+
});
|
|
65
|
+
});
|
package/src/v2/methods/search.ts
CHANGED
|
@@ -102,12 +102,16 @@ export async function search(
|
|
|
102
102
|
if (data.news) out.news = transformArray<SearchResultNews>(data.news);
|
|
103
103
|
if (data.images)
|
|
104
104
|
out.images = transformArray<SearchResultImages>(data.images);
|
|
105
|
+
if (data.developer)
|
|
106
|
+
out.developer = transformArray<SearchResultWeb>(data.developer);
|
|
105
107
|
Object.defineProperty(out, "data", {
|
|
106
108
|
get() {
|
|
107
109
|
const parts: string[] = [];
|
|
108
110
|
if (out.web?.length) parts.push(`.web (${out.web.length} results)`);
|
|
109
111
|
if (out.news?.length) parts.push(`.news (${out.news.length} results)`);
|
|
110
112
|
if (out.images?.length) parts.push(`.images (${out.images.length} results)`);
|
|
113
|
+
if (out.developer?.length)
|
|
114
|
+
parts.push(`.developer (${out.developer.length} results)`);
|
|
111
115
|
const available = parts.length ? parts.join(", ") : ".web, .news, or .images";
|
|
112
116
|
throw new Error(
|
|
113
117
|
`SearchData has no '.data'. Results are grouped by source: ${available}`,
|
package/src/v2/types.ts
CHANGED
|
@@ -657,6 +657,7 @@ export interface SearchResultWeb {
|
|
|
657
657
|
url: string;
|
|
658
658
|
title?: string;
|
|
659
659
|
description?: string;
|
|
660
|
+
position?: number;
|
|
660
661
|
category?: string;
|
|
661
662
|
}
|
|
662
663
|
|
|
@@ -683,10 +684,11 @@ export interface SearchData {
|
|
|
683
684
|
web?: Array<SearchResultWeb | Document>;
|
|
684
685
|
news?: Array<SearchResultNews | Document>;
|
|
685
686
|
images?: Array<SearchResultImages | Document>;
|
|
687
|
+
developer?: Array<SearchResultWeb | Document>;
|
|
686
688
|
}
|
|
687
689
|
|
|
688
690
|
export interface CategoryOption {
|
|
689
|
-
type: "github" | "research" | "pdf";
|
|
691
|
+
type: "github" | "research" | "pdf" | "developer";
|
|
690
692
|
}
|
|
691
693
|
|
|
692
694
|
export interface SearchRequest {
|
|
@@ -694,7 +696,9 @@ export interface SearchRequest {
|
|
|
694
696
|
sources?: Array<
|
|
695
697
|
"web" | "news" | "images" | { type: "web" | "news" | "images" }
|
|
696
698
|
>;
|
|
697
|
-
categories?: Array<
|
|
699
|
+
categories?: Array<
|
|
700
|
+
"github" | "research" | "pdf" | "developer" | CategoryOption
|
|
701
|
+
>;
|
|
698
702
|
includeDomains?: string[];
|
|
699
703
|
excludeDomains?: string[];
|
|
700
704
|
limit?: number;
|