firecrawl 4.45.0 → 4.46.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.
Files changed (63) hide show
  1. package/audit-ci.jsonc +1 -15
  2. package/dist/{chunk-LKCOCWYW.js → chunk-R4XT7PME.js} +5 -9
  3. package/dist/index.cjs +6 -10
  4. package/dist/index.d.cts +8 -0
  5. package/dist/index.d.ts +8 -0
  6. package/dist/index.js +3 -3
  7. package/dist/{package-C6PK3CK7.js → package-EI4Q33HD.js} +1 -1
  8. package/package.json +5 -9
  9. package/pnpm-workspace.yaml +0 -6
  10. package/src/__tests__/e2e/v1/index.test.ts +1 -1
  11. package/src/__tests__/e2e/v2/batch.test.ts +1 -1
  12. package/src/__tests__/e2e/v2/crawl.test.ts +1 -1
  13. package/src/__tests__/e2e/v2/extract.test.ts +1 -1
  14. package/src/__tests__/e2e/v2/map.test.ts +1 -1
  15. package/src/__tests__/e2e/v2/parse.test.ts +1 -1
  16. package/src/__tests__/e2e/v2/scrape.test.ts +1 -1
  17. package/src/__tests__/e2e/v2/search.test.ts +1 -1
  18. package/src/__tests__/e2e/v2/usage.test.ts +1 -1
  19. package/src/__tests__/e2e/v2/utils/rateLimit.ts +2 -2
  20. package/src/__tests__/e2e/v2/watcher.test.ts +1 -1
  21. package/src/__tests__/unit/v1/batch-scrape-poll.test.ts +7 -7
  22. package/src/__tests__/unit/v1/monitor-job-status-retry.test.ts +6 -6
  23. package/src/__tests__/unit/v1/next-url-pinning.test.ts +3 -3
  24. package/src/__tests__/unit/v1/optional-params.test.ts +4 -4
  25. package/src/__tests__/unit/v2/agent-effort-trace.unit.test.ts +6 -6
  26. package/src/__tests__/unit/v2/agent-hints.test.ts +3 -3
  27. package/src/__tests__/unit/v2/agent-list.unit.test.ts +4 -4
  28. package/src/__tests__/unit/v2/agent-thread.unit.test.ts +7 -7
  29. package/src/__tests__/unit/v2/agent.test.ts +1 -1
  30. package/src/__tests__/unit/v2/audit-metadata.unit.test.ts +3 -3
  31. package/src/__tests__/unit/v2/branding.test.ts +2 -2
  32. package/src/__tests__/unit/v2/clientOptions.test.ts +1 -0
  33. package/src/__tests__/unit/v2/crawl-cancel-abort.unit.test.ts +1 -1
  34. package/src/__tests__/unit/v2/developer.test.ts +4 -4
  35. package/src/__tests__/unit/v2/e2eRateLimitRetry.test.ts +16 -16
  36. package/src/__tests__/unit/v2/errorHandler.test.ts +1 -1
  37. package/src/__tests__/unit/v2/extract.unit.test.ts +4 -4
  38. package/src/__tests__/unit/v2/gov.test.ts +4 -4
  39. package/src/__tests__/unit/v2/menu.test.ts +2 -2
  40. package/src/__tests__/unit/v2/monitor-search-target.test.ts +1 -0
  41. package/src/__tests__/unit/v2/next-url-pinning.test.ts +1 -1
  42. package/src/__tests__/unit/v2/pagination.test.ts +6 -6
  43. package/src/__tests__/unit/v2/parse-formats.unit.test.ts +1 -1
  44. package/src/__tests__/unit/v2/parse.unit.test.ts +1 -1
  45. package/src/__tests__/unit/v2/product.test.ts +2 -2
  46. package/src/__tests__/unit/v2/prototype-discoverability.test.ts +1 -0
  47. package/src/__tests__/unit/v2/research.test.ts +1 -1
  48. package/src/__tests__/unit/v2/scrape-browser.unit.test.ts +8 -8
  49. package/src/__tests__/unit/v2/scrape.unit.test.ts +1 -1
  50. package/src/__tests__/unit/v2/scrapeAutoResume.test.ts +13 -13
  51. package/src/__tests__/unit/v2/search-country.unit.test.ts +2 -2
  52. package/src/__tests__/unit/v2/search-data-property.test.ts +3 -3
  53. package/src/__tests__/unit/v2/search-developer.unit.test.ts +2 -2
  54. package/src/__tests__/unit/v2/search-highlights.unit.test.ts +2 -2
  55. package/src/__tests__/unit/v2/threat-protection.unit.test.ts +3 -3
  56. package/src/__tests__/unit/v2/tools.unit.test.ts +3 -3
  57. package/src/__tests__/unit/v2/v1-aliases.test.ts +2 -2
  58. package/src/__tests__/unit/v2/validation.test.ts +1 -1
  59. package/src/__tests__/unit/v2/zodSchemaToJson.test.ts +1 -1
  60. package/src/v1/index.ts +1 -3
  61. package/src/v2/types.ts +8 -0
  62. package/vitest.config.ts +7 -0
  63. package/jest.config.js +0 -16
@@ -1,4 +1,4 @@
1
- import { describe, expect, jest, test } from "@jest/globals";
1
+ import { describe, expect, vi, test } from "vitest";
2
2
  import { search } from "../../../v2/methods/search";
3
3
  import type { SearchResultWeb } from "../../../v2/types";
4
4
 
@@ -13,7 +13,7 @@ const developerResult: SearchResultWeb = {
13
13
 
14
14
  function httpWith(data: Record<string, unknown>) {
15
15
  return {
16
- post: jest.fn(async () => ({ status: 200, data: { success: true, data } })),
16
+ post: vi.fn(async () => ({ status: 200, data: { success: true, data } })),
17
17
  } as any;
18
18
  }
19
19
 
@@ -1,10 +1,10 @@
1
- import { describe, expect, jest, test } from "@jest/globals";
1
+ import { describe, expect, vi, test } from "vitest";
2
2
  import { search } from "../../../v2/methods/search";
3
3
 
4
4
  describe("v2 search highlights", () => {
5
5
  test("forwards the highlights option", async () => {
6
6
  const http = {
7
- post: jest.fn(async () => ({ status: 200, data: { success: true } })),
7
+ post: vi.fn(async () => ({ status: 200, data: { success: true } })),
8
8
  } as any;
9
9
 
10
10
  await search(http, { query: "firecrawl", highlights: false });
@@ -1,4 +1,4 @@
1
- import { describe, test, expect, jest } from "@jest/globals";
1
+ import { describe, test, expect, vi } from "vitest";
2
2
  import { scrape } from "../../../v2/methods/scrape";
3
3
  import { startBatchScrape } from "../../../v2/methods/batch";
4
4
  import { startCrawl } from "../../../v2/methods/crawl";
@@ -18,10 +18,10 @@ const threatProtection: ThreatProtectionOptions = {
18
18
  };
19
19
 
20
20
  function makeHttp(data: Record<string, unknown>) {
21
- const post = jest.fn(async () => ({ status: 200, data }));
21
+ const post = vi.fn(async () => ({ status: 200, data }));
22
22
  return {
23
23
  post,
24
- prepareHeaders: jest.fn(() => undefined),
24
+ prepareHeaders: vi.fn(() => undefined),
25
25
  } as any;
26
26
  }
27
27
 
@@ -4,9 +4,9 @@ import {
4
4
  beforeEach,
5
5
  describe,
6
6
  expect,
7
- jest,
8
7
  test,
9
- } from "@jest/globals";
8
+ vi,
9
+ } from "vitest";
10
10
  import { createServer, type Server } from "node:http";
11
11
  import { FirecrawlClient } from "../../../v2/client";
12
12
 
@@ -281,7 +281,7 @@ test.each([
281
281
  "Alexandria timeout %s allows response delivery (%s ms)",
282
282
  async (timeout, timeoutMs) => {
283
283
  const http = {
284
- post: jest.fn(async () => ({
284
+ post: vi.fn(async () => ({
285
285
  status: 200,
286
286
  data: {
287
287
  success: true,
@@ -1,4 +1,4 @@
1
- import { jest } from "@jest/globals";
1
+ import { describe, expect, it, vi } from "vitest";
2
2
  import { FirecrawlClient } from "../../../v2/client";
3
3
 
4
4
  const ALIAS_MAP: Record<string, string> = {
@@ -22,7 +22,7 @@ describe("V1 deprecated aliases", () => {
22
22
 
23
23
  for (const [alias, target] of Object.entries(ALIAS_MAP)) {
24
24
  it(`${alias} delegates to ${target}`, async () => {
25
- const spy = jest
25
+ const spy = vi
26
26
  .spyOn(app, target as any)
27
27
  .mockResolvedValue({ ok: true } as any);
28
28
  await (app as any)[alias]("https://example.com");
@@ -1,4 +1,4 @@
1
- import { describe, test, expect } from "@jest/globals";
1
+ import { describe, test, expect } from "vitest";
2
2
  import { ensureValidFormats, ensureValidScrapeOptions } from "../../../v2/utils/validation";
3
3
  import type { FormatOption } from "../../../v2/types";
4
4
  import { z } from "zod";
@@ -1,4 +1,4 @@
1
- import { describe, test, expect } from "@jest/globals";
1
+ import { describe, test, expect } from "vitest";
2
2
  import { z } from "zod";
3
3
  import {
4
4
  isZodSchema,
package/src/v1/index.ts CHANGED
@@ -681,9 +681,7 @@ export default class FirecrawlApp {
681
681
  return packageJson.default.version;
682
682
  } catch (error) {
683
683
  // Suppress noisy logs under test environments
684
- const isTest = typeof process !== 'undefined' && (
685
- process.env.JEST_WORKER_ID != null || process.env.NODE_ENV === 'test'
686
- );
684
+ const isTest = typeof process !== 'undefined' && process.env.NODE_ENV === 'test';
687
685
  if (!isTest) {
688
686
  // eslint-disable-next-line no-console
689
687
  console.error("Error getting version:", error);
package/src/v2/types.ts CHANGED
@@ -31,6 +31,7 @@ export interface JsonFormat extends Format {
31
31
  type: "json";
32
32
  prompt?: string;
33
33
  schema?: Record<string, unknown> | ZodTypeAny;
34
+ /** @deprecated Use the top-level `checkPromptInjection` scrape option. */
34
35
  checkPromptInjection?: boolean;
35
36
  }
36
37
 
@@ -276,6 +277,13 @@ export interface ScrapeOptions {
276
277
  minAge?: number;
277
278
  storeInCache?: boolean;
278
279
  lockdown?: boolean;
280
+ /**
281
+ * Scans the page content for prompt injection with any format except
282
+ * rawBase64, before LLM-backed formats run. A detection fails the scrape
283
+ * with SCRAPE_PROMPT_INJECTION_DETECTED.
284
+ * Adds 4 credits when the check scans the whole page.
285
+ */
286
+ checkPromptInjection?: boolean;
279
287
  redactPII?: boolean | RedactPIIOptions;
280
288
  threatProtection?: ThreatProtectionOptions;
281
289
  auditMetadata?: AuditMetadata;
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ["src/**/*.test.ts"],
6
+ },
7
+ });
package/jest.config.js DELETED
@@ -1,16 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} **/
2
- export default {
3
- testEnvironment: "node",
4
- "moduleNameMapper": {
5
- "^(\\.{1,2}/.*)\\.js$": "$1",
6
- },
7
- "extensionsToTreatAsEsm": [".ts"],
8
- "transform": {
9
- "^.+\\.(mt|t|cj|j)s$": [
10
- "ts-jest",
11
- {
12
- "useESM": true
13
- }
14
- ]
15
- },
16
- };