firecrawl 4.23.0 → 4.24.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/src/v2/types.ts CHANGED
@@ -1,20 +1,20 @@
1
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodTypeAny } from "zod";
2
2
  // Public types for Firecrawl JS/TS SDK v2 (camelCase only)
3
3
 
4
4
  export type FormatString =
5
- | 'markdown'
6
- | 'html'
7
- | 'rawHtml'
8
- | 'links'
9
- | 'images'
10
- | 'screenshot'
11
- | 'summary'
12
- | 'changeTracking'
13
- | 'json'
14
- | 'attributes'
15
- | 'branding'
16
- | 'audio'
17
- | 'video';
5
+ | "markdown"
6
+ | "html"
7
+ | "rawHtml"
8
+ | "links"
9
+ | "images"
10
+ | "screenshot"
11
+ | "summary"
12
+ | "changeTracking"
13
+ | "json"
14
+ | "attributes"
15
+ | "branding"
16
+ | "audio"
17
+ | "video";
18
18
 
19
19
  export interface Viewport {
20
20
  width: number;
@@ -26,27 +26,27 @@ export interface Format {
26
26
  }
27
27
 
28
28
  export interface JsonFormat extends Format {
29
- type: 'json';
29
+ type: "json";
30
30
  prompt?: string;
31
31
  schema?: Record<string, unknown> | ZodTypeAny;
32
32
  }
33
33
 
34
34
  export interface ScreenshotFormat {
35
- type: 'screenshot';
35
+ type: "screenshot";
36
36
  fullPage?: boolean;
37
37
  quality?: number;
38
38
  viewport?: Viewport | { width: number; height: number };
39
39
  }
40
40
 
41
41
  export interface ChangeTrackingFormat extends Format {
42
- type: 'changeTracking';
43
- modes: ('git-diff' | 'json')[];
42
+ type: "changeTracking";
43
+ modes: ("git-diff" | "json")[];
44
44
  schema?: Record<string, unknown>;
45
45
  prompt?: string;
46
46
  tag?: string;
47
47
  }
48
48
  export interface AttributesFormat extends Format {
49
- type: 'attributes';
49
+ type: "attributes";
50
50
  selectors: Array<{
51
51
  selector: string;
52
52
  attribute: string;
@@ -54,20 +54,20 @@ export interface AttributesFormat extends Format {
54
54
  }
55
55
 
56
56
  export interface QuestionFormat {
57
- type: 'question';
57
+ type: "question";
58
58
  question: string;
59
59
  }
60
60
 
61
61
  export interface HighlightsFormat {
62
- type: 'highlights';
62
+ type: "highlights";
63
63
  query: string;
64
64
  }
65
65
 
66
66
  /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
67
67
  export interface QueryFormat {
68
- type: 'query';
68
+ type: "query";
69
69
  prompt: string;
70
- mode?: 'freeform' | 'directQuote';
70
+ mode?: "freeform" | "directQuote";
71
71
  }
72
72
 
73
73
  export type FormatOption =
@@ -83,7 +83,7 @@ export type FormatOption =
83
83
 
84
84
  export type ParseFormatString = Exclude<
85
85
  FormatString,
86
- 'screenshot' | 'changeTracking' | 'branding' | 'audio' | 'video'
86
+ "screenshot" | "changeTracking" | "branding" | "audio" | "video"
87
87
  >;
88
88
 
89
89
  export interface ParseFormat {
@@ -105,62 +105,62 @@ export interface LocationConfig {
105
105
  }
106
106
 
107
107
  export interface WaitAction {
108
- type: 'wait';
108
+ type: "wait";
109
109
  milliseconds?: number;
110
110
  selector?: string;
111
111
  }
112
112
 
113
113
  export interface ScreenshotAction {
114
- type: 'screenshot';
114
+ type: "screenshot";
115
115
  fullPage?: boolean;
116
116
  quality?: number;
117
117
  viewport?: Viewport | { width: number; height: number };
118
118
  }
119
119
 
120
120
  export interface ClickAction {
121
- type: 'click';
121
+ type: "click";
122
122
  selector: string;
123
123
  }
124
124
 
125
125
  export interface WriteAction {
126
- type: 'write';
126
+ type: "write";
127
127
  text: string;
128
128
  }
129
129
 
130
130
  export interface PressAction {
131
- type: 'press';
131
+ type: "press";
132
132
  key: string;
133
133
  }
134
134
 
135
135
  export interface ScrollAction {
136
- type: 'scroll';
137
- direction: 'up' | 'down';
136
+ type: "scroll";
137
+ direction: "up" | "down";
138
138
  selector?: string;
139
139
  }
140
140
 
141
141
  export interface ScrapeAction {
142
- type: 'scrape';
142
+ type: "scrape";
143
143
  }
144
144
 
145
145
  export interface ExecuteJavascriptAction {
146
- type: 'executeJavascript';
146
+ type: "executeJavascript";
147
147
  script: string;
148
148
  }
149
149
 
150
150
  export interface PDFAction {
151
- type: 'pdf';
151
+ type: "pdf";
152
152
  format?:
153
- | 'A0'
154
- | 'A1'
155
- | 'A2'
156
- | 'A3'
157
- | 'A4'
158
- | 'A5'
159
- | 'A6'
160
- | 'Letter'
161
- | 'Legal'
162
- | 'Tabloid'
163
- | 'Ledger';
153
+ | "A0"
154
+ | "A1"
155
+ | "A2"
156
+ | "A3"
157
+ | "A4"
158
+ | "A5"
159
+ | "A6"
160
+ | "Letter"
161
+ | "Legal"
162
+ | "Tabloid"
163
+ | "Ledger";
164
164
  landscape?: boolean;
165
165
  scale?: number;
166
166
  }
@@ -185,7 +185,9 @@ export interface ScrapeOptions {
185
185
  timeout?: number;
186
186
  waitFor?: number;
187
187
  mobile?: boolean;
188
- parsers?: Array<string | { type: 'pdf'; mode?: 'fast' | 'auto' | 'ocr'; maxPages?: number }>;
188
+ parsers?: Array<
189
+ string | { type: "pdf"; mode?: "fast" | "auto" | "ocr"; maxPages?: number }
190
+ >;
189
191
  actions?: ActionOption[];
190
192
  location?: LocationConfig;
191
193
  skipTlsVerification?: boolean;
@@ -193,7 +195,7 @@ export interface ScrapeOptions {
193
195
  fastMode?: boolean;
194
196
  useMock?: string;
195
197
  blockAds?: boolean;
196
- proxy?: 'basic' | 'stealth' | 'enhanced' | 'auto' | string;
198
+ proxy?: "basic" | "stealth" | "enhanced" | "auto" | string;
197
199
  maxAge?: number;
198
200
  minAge?: number;
199
201
  storeInCache?: boolean;
@@ -222,30 +224,35 @@ export interface ParseFile {
222
224
 
223
225
  export type ParseOptions = Omit<
224
226
  ScrapeOptions,
225
- | 'formats'
226
- | 'waitFor'
227
- | 'mobile'
228
- | 'actions'
229
- | 'location'
230
- | 'maxAge'
231
- | 'minAge'
232
- | 'storeInCache'
233
- | 'lockdown'
234
- | 'proxy'
227
+ | "formats"
228
+ | "waitFor"
229
+ | "mobile"
230
+ | "actions"
231
+ | "location"
232
+ | "maxAge"
233
+ | "minAge"
234
+ | "storeInCache"
235
+ | "lockdown"
236
+ | "proxy"
235
237
  > & {
236
238
  formats?: ParseFormatOption[];
237
- proxy?: 'basic' | 'auto';
239
+ proxy?: "basic" | "auto";
238
240
  };
239
241
 
240
242
  export interface WebhookConfig {
241
243
  url: string;
242
244
  headers?: Record<string, string>;
243
245
  metadata?: Record<string, string>;
244
- events?: Array<'completed' | 'failed' | 'page' | 'started'>;
246
+ events?: Array<"completed" | "failed" | "page" | "started">;
245
247
  }
246
248
 
247
249
  // Agent webhook events differ from crawl: has 'action' and 'cancelled', no 'page'
248
- export type AgentWebhookEvent = 'started' | 'action' | 'completed' | 'failed' | 'cancelled';
250
+ export type AgentWebhookEvent =
251
+ | "started"
252
+ | "action"
253
+ | "completed"
254
+ | "failed"
255
+ | "cancelled";
249
256
 
250
257
  export interface AgentWebhookConfig {
251
258
  url: string;
@@ -255,7 +262,7 @@ export interface AgentWebhookConfig {
255
262
  }
256
263
 
257
264
  export interface BrandingProfile {
258
- colorScheme?: 'light' | 'dark';
265
+ colorScheme?: "light" | "dark";
259
266
  logo?: string | null;
260
267
  fonts?: Array<{
261
268
  family: string;
@@ -377,13 +384,13 @@ export interface BrandingProfile {
377
384
  };
378
385
  personality?: {
379
386
  tone:
380
- | 'professional'
381
- | 'playful'
382
- | 'modern'
383
- | 'traditional'
384
- | 'minimalist'
385
- | 'bold';
386
- energy: 'low' | 'medium' | 'high';
387
+ | "professional"
388
+ | "playful"
389
+ | "modern"
390
+ | "traditional"
391
+ | "minimalist"
392
+ | "bold";
393
+ energy: "low" | "medium" | "high";
387
394
  targetAudience: string;
388
395
  };
389
396
  [key: string]: unknown;
@@ -435,8 +442,8 @@ export interface DocumentMetadata {
435
442
  numPages?: number;
436
443
  contentType?: string;
437
444
  timezone?: string;
438
- proxyUsed?: 'basic' | 'stealth';
439
- cacheState?: 'hit' | 'miss';
445
+ proxyUsed?: "basic" | "stealth";
446
+ cacheState?: "hit" | "miss";
440
447
  cachedAt?: string;
441
448
  creditsUsed?: number;
442
449
  concurrencyLimited?: boolean;
@@ -518,15 +525,15 @@ export interface SearchData {
518
525
  }
519
526
 
520
527
  export interface CategoryOption {
521
- type: 'github' | 'research' | 'pdf';
528
+ type: "github" | "research" | "pdf";
522
529
  }
523
530
 
524
531
  export interface SearchRequest {
525
532
  query: string;
526
533
  sources?: Array<
527
- 'web' | 'news' | 'images' | { type: 'web' | 'news' | 'images' }
534
+ "web" | "news" | "images" | { type: "web" | "news" | "images" }
528
535
  >;
529
- categories?: Array<'github' | 'research' | 'pdf' | CategoryOption>;
536
+ categories?: Array<"github" | "research" | "pdf" | CategoryOption>;
530
537
  includeDomains?: string[];
531
538
  excludeDomains?: string[];
532
539
  limit?: number;
@@ -544,7 +551,7 @@ export interface CrawlOptions {
544
551
  excludePaths?: string[] | null;
545
552
  includePaths?: string[] | null;
546
553
  maxDiscoveryDepth?: number | null;
547
- sitemap?: 'skip' | 'include' | 'only';
554
+ sitemap?: "skip" | "include" | "only";
548
555
  ignoreQueryParameters?: boolean;
549
556
  deduplicateSimilarURLs?: boolean;
550
557
  limit?: number | null;
@@ -570,7 +577,7 @@ export interface CrawlResponse {
570
577
 
571
578
  export interface CrawlJob {
572
579
  id: string;
573
- status: 'scraping' | 'completed' | 'failed' | 'cancelled';
580
+ status: "scraping" | "completed" | "failed" | "cancelled";
574
581
  total: number;
575
582
  completed: number;
576
583
  creditsUsed?: number;
@@ -599,7 +606,7 @@ export interface BatchScrapeResponse {
599
606
 
600
607
  export interface BatchScrapeJob {
601
608
  id: string;
602
- status: 'scraping' | 'completed' | 'failed' | 'cancelled';
609
+ status: "scraping" | "completed" | "failed" | "cancelled";
603
610
  completed: number;
604
611
  total: number;
605
612
  creditsUsed?: number;
@@ -614,7 +621,7 @@ export interface MapData {
614
621
 
615
622
  export interface MapOptions {
616
623
  search?: string;
617
- sitemap?: 'only' | 'include' | 'skip';
624
+ sitemap?: "only" | "include" | "skip";
618
625
  includeSubdomains?: boolean;
619
626
  ignoreQueryParameters?: boolean;
620
627
  limit?: number;
@@ -648,14 +655,14 @@ export interface MonitorWebhookConfig {
648
655
 
649
656
  export interface MonitorScrapeTarget {
650
657
  id?: string;
651
- type: 'scrape';
658
+ type: "scrape";
652
659
  urls: string[];
653
660
  scrapeOptions?: ScrapeOptions;
654
661
  }
655
662
 
656
663
  export interface MonitorCrawlTarget {
657
664
  id?: string;
658
- type: 'crawl';
665
+ type: "crawl";
659
666
  url: string;
660
667
  crawlOptions?: CrawlOptions;
661
668
  scrapeOptions?: ScrapeOptions;
@@ -674,7 +681,7 @@ export interface CreateMonitorRequest {
674
681
 
675
682
  export interface UpdateMonitorRequest {
676
683
  name?: string;
677
- status?: 'active' | 'paused';
684
+ status?: "active" | "paused";
678
685
  schedule?: MonitorSchedule;
679
686
  webhook?: MonitorWebhookConfig | null;
680
687
  notification?: MonitorNotification | null;
@@ -694,7 +701,7 @@ export interface MonitorSummary {
694
701
  export interface Monitor {
695
702
  id: string;
696
703
  name: string;
697
- status: 'active' | 'paused' | 'deleted';
704
+ status: "active" | "paused" | "deleted";
698
705
  schedule: MonitorSchedule;
699
706
  nextRunAt?: string | null;
700
707
  lastRunAt?: string | null;
@@ -713,13 +720,13 @@ export interface MonitorCheck {
713
720
  id: string;
714
721
  monitorId: string;
715
722
  status:
716
- | 'queued'
717
- | 'running'
718
- | 'completed'
719
- | 'failed'
720
- | 'partial'
721
- | 'skipped_overlap';
722
- trigger: 'scheduled' | 'manual';
723
+ | "queued"
724
+ | "running"
725
+ | "completed"
726
+ | "failed"
727
+ | "partial"
728
+ | "skipped_overlap";
729
+ trigger: "scheduled" | "manual";
723
730
  scheduledFor?: string | null;
724
731
  startedAt?: string | null;
725
732
  finishedAt?: string | null;
@@ -727,11 +734,11 @@ export interface MonitorCheck {
727
734
  reservedCredits?: number | null;
728
735
  actualCredits?: number | null;
729
736
  billingStatus:
730
- | 'not_applicable'
731
- | 'reserved'
732
- | 'confirmed'
733
- | 'released'
734
- | 'failed';
737
+ | "not_applicable"
738
+ | "reserved"
739
+ | "confirmed"
740
+ | "released"
741
+ | "failed";
735
742
  summary: MonitorSummary;
736
743
  targetResults?: unknown;
737
744
  notificationStatus?: unknown;
@@ -740,17 +747,48 @@ export interface MonitorCheck {
740
747
  updatedAt: string;
741
748
  }
742
749
 
750
+ /** Per-field diff for monitors that requested JSON extraction. */
751
+ export interface MonitorJsonFieldDiff {
752
+ [field: string]: { previous: unknown; current: unknown };
753
+ }
754
+
755
+ /**
756
+ * Diff payload returned alongside a monitor page when its scrape produced
757
+ * a change. The shape depends on what the monitor's formats asked for:
758
+ *
759
+ * - markdown-only monitors → `{ text, json }` where `json` is the
760
+ * `parseDiff` AST (a `{ files: [...] }` object).
761
+ * - JSON-extraction monitors → `{ json }` where `json` is the per-field
762
+ * `{ previous, current }` map.
763
+ * - Mixed (JSON + git-diff) monitors → both `text` (markdown sidecar)
764
+ * and `json` (field-level diff) are present.
765
+ */
766
+ export interface MonitorPageDiff {
767
+ text?: string;
768
+ /** Markdown variants: parseDiff AST. JSON variants: per-field diff. */
769
+ json?: MonitorJsonFieldDiff | { files: unknown[] };
770
+ }
771
+
772
+ /**
773
+ * Snapshot of the current JSON extraction at this run. Present on JSON
774
+ * and mixed-mode monitors; absent for markdown-only.
775
+ */
776
+ export interface MonitorPageSnapshot {
777
+ json?: Record<string, unknown>;
778
+ }
779
+
743
780
  export interface MonitorCheckPage {
744
781
  id: string;
745
782
  targetId: string;
746
783
  url: string;
747
- status: 'same' | 'new' | 'changed' | 'removed' | 'error';
784
+ status: "same" | "new" | "changed" | "removed" | "error";
748
785
  previousScrapeId?: string | null;
749
786
  currentScrapeId?: string | null;
750
787
  statusCode?: number | null;
751
788
  error?: string | null;
752
789
  metadata?: unknown;
753
- diff?: unknown;
790
+ diff?: MonitorPageDiff | null;
791
+ snapshot?: MonitorPageSnapshot | null;
754
792
  createdAt: string;
755
793
  }
756
794
 
@@ -775,7 +813,7 @@ export type GetMonitorCheckOptions = PaginationConfig & {
775
813
  export interface ExtractResponse {
776
814
  success?: boolean;
777
815
  id?: string;
778
- status?: 'processing' | 'completed' | 'failed' | 'cancelled';
816
+ status?: "processing" | "completed" | "failed" | "cancelled";
779
817
  data?: unknown;
780
818
  error?: string;
781
819
  warning?: string;
@@ -794,16 +832,16 @@ export interface AgentResponse {
794
832
 
795
833
  export interface AgentStatusResponse {
796
834
  success: boolean;
797
- status: 'processing' | 'completed' | 'failed';
835
+ status: "processing" | "completed" | "failed";
798
836
  error?: string;
799
837
  data?: unknown;
800
- model?: 'spark-1-pro' | 'spark-1-mini';
838
+ model?: "spark-1-pro" | "spark-1-mini";
801
839
  expiresAt: string;
802
840
  creditsUsed?: number;
803
841
  }
804
842
 
805
843
  export interface AgentOptions {
806
- model: 'FIRE-1' | 'v3-beta';
844
+ model: "FIRE-1" | "v3-beta";
807
845
  }
808
846
 
809
847
  export interface ConcurrencyCheck {
@@ -889,10 +927,10 @@ export class SdkError extends Error {
889
927
  status?: number,
890
928
  code?: string,
891
929
  details?: unknown,
892
- jobId?: string
930
+ jobId?: string,
893
931
  ) {
894
932
  super(message);
895
- this.name = 'FirecrawlSdkError';
933
+ this.name = "FirecrawlSdkError";
896
934
  this.status = status;
897
935
  this.code = code;
898
936
  this.details = details;
@@ -902,16 +940,20 @@ export class SdkError extends Error {
902
940
 
903
941
  export class JobTimeoutError extends SdkError {
904
942
  timeoutSeconds: number;
905
- constructor(jobId: string, timeoutSeconds: number, jobType: 'batch' | 'crawl' = 'batch') {
906
- const jobTypeLabel = jobType === 'batch' ? 'batch scrape' : 'crawl';
943
+ constructor(
944
+ jobId: string,
945
+ timeoutSeconds: number,
946
+ jobType: "batch" | "crawl" = "batch",
947
+ ) {
948
+ const jobTypeLabel = jobType === "batch" ? "batch scrape" : "crawl";
907
949
  super(
908
950
  `${jobTypeLabel.charAt(0).toUpperCase() + jobTypeLabel.slice(1)} job ${jobId} did not complete within ${timeoutSeconds} seconds`,
909
951
  undefined,
910
- 'JOB_TIMEOUT',
952
+ "JOB_TIMEOUT",
911
953
  undefined,
912
- jobId
954
+ jobId,
913
955
  );
914
- this.name = 'JobTimeoutError';
956
+ this.name = "JobTimeoutError";
915
957
  this.timeoutSeconds = timeoutSeconds;
916
958
  }
917
959
  }