firecrawl 4.21.1 → 4.22.1

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.ts CHANGED
@@ -40,17 +40,26 @@ interface AttributesFormat extends Format {
40
40
  attribute: string;
41
41
  }>;
42
42
  }
43
+ interface QuestionFormat {
44
+ type: 'question';
45
+ question: string;
46
+ }
47
+ interface HighlightsFormat {
48
+ type: 'highlights';
49
+ query: string;
50
+ }
51
+ /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
43
52
  interface QueryFormat {
44
53
  type: 'query';
45
54
  prompt: string;
46
55
  mode?: 'freeform' | 'directQuote';
47
56
  }
48
- type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QueryFormat;
57
+ type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
49
58
  type ParseFormatString = Exclude<FormatString, 'screenshot' | 'changeTracking' | 'branding'>;
50
59
  interface ParseFormat {
51
60
  type: ParseFormatString;
52
61
  }
53
- type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QueryFormat;
62
+ type ParseFormatOption = ParseFormatString | ParseFormat | JsonFormat | AttributesFormat | QuestionFormat | HighlightsFormat | QueryFormat;
54
63
  interface LocationConfig$1 {
55
64
  country?: string;
56
65
  languages?: string[];
@@ -345,6 +354,7 @@ interface Document {
345
354
  }>;
346
355
  actions?: Record<string, unknown>;
347
356
  answer?: string;
357
+ highlights?: string;
348
358
  warning?: string;
349
359
  changeTracking?: Record<string, unknown>;
350
360
  branding?: BrandingProfile;
@@ -484,6 +494,126 @@ interface MapOptions {
484
494
  origin?: string;
485
495
  location?: LocationConfig$1;
486
496
  }
497
+ interface MonitorSchedule {
498
+ cron: string;
499
+ timezone?: string;
500
+ }
501
+ interface MonitorEmailNotification {
502
+ enabled?: boolean;
503
+ recipients?: string[];
504
+ includeDiffs?: boolean;
505
+ }
506
+ interface MonitorNotification {
507
+ email?: MonitorEmailNotification;
508
+ }
509
+ interface MonitorWebhookConfig {
510
+ url: string;
511
+ headers?: Record<string, string>;
512
+ metadata?: Record<string, string>;
513
+ events?: string[];
514
+ }
515
+ interface MonitorScrapeTarget {
516
+ id?: string;
517
+ type: 'scrape';
518
+ urls: string[];
519
+ scrapeOptions?: ScrapeOptions;
520
+ }
521
+ interface MonitorCrawlTarget {
522
+ id?: string;
523
+ type: 'crawl';
524
+ url: string;
525
+ crawlOptions?: CrawlOptions;
526
+ scrapeOptions?: ScrapeOptions;
527
+ }
528
+ type MonitorTarget = MonitorScrapeTarget | MonitorCrawlTarget;
529
+ interface CreateMonitorRequest {
530
+ name: string;
531
+ schedule: MonitorSchedule;
532
+ webhook?: MonitorWebhookConfig;
533
+ notification?: MonitorNotification;
534
+ targets: MonitorTarget[];
535
+ retentionDays?: number;
536
+ }
537
+ interface UpdateMonitorRequest {
538
+ name?: string;
539
+ status?: 'active' | 'paused';
540
+ schedule?: MonitorSchedule;
541
+ webhook?: MonitorWebhookConfig | null;
542
+ notification?: MonitorNotification | null;
543
+ targets?: MonitorTarget[];
544
+ retentionDays?: number;
545
+ }
546
+ interface MonitorSummary {
547
+ totalPages: number;
548
+ same: number;
549
+ changed: number;
550
+ new: number;
551
+ removed: number;
552
+ error: number;
553
+ }
554
+ interface Monitor {
555
+ id: string;
556
+ name: string;
557
+ status: 'active' | 'paused' | 'deleted';
558
+ schedule: MonitorSchedule;
559
+ nextRunAt?: string | null;
560
+ lastRunAt?: string | null;
561
+ currentCheckId?: string | null;
562
+ targets: MonitorTarget[];
563
+ webhook?: MonitorWebhookConfig | null;
564
+ notification?: MonitorNotification | null;
565
+ retentionDays: number;
566
+ estimatedCreditsPerMonth?: number | null;
567
+ lastCheckSummary?: MonitorSummary | null;
568
+ createdAt: string;
569
+ updatedAt: string;
570
+ }
571
+ interface MonitorCheck {
572
+ id: string;
573
+ monitorId: string;
574
+ status: 'queued' | 'running' | 'completed' | 'failed' | 'partial' | 'skipped_overlap';
575
+ trigger: 'scheduled' | 'manual';
576
+ scheduledFor?: string | null;
577
+ startedAt?: string | null;
578
+ finishedAt?: string | null;
579
+ estimatedCredits?: number | null;
580
+ reservedCredits?: number | null;
581
+ actualCredits?: number | null;
582
+ billingStatus: 'not_applicable' | 'reserved' | 'confirmed' | 'released' | 'failed';
583
+ summary: MonitorSummary;
584
+ targetResults?: unknown;
585
+ notificationStatus?: unknown;
586
+ error?: string | null;
587
+ createdAt: string;
588
+ updatedAt: string;
589
+ }
590
+ interface MonitorCheckPage {
591
+ id: string;
592
+ targetId: string;
593
+ url: string;
594
+ status: 'same' | 'new' | 'changed' | 'removed' | 'error';
595
+ previousScrapeId?: string | null;
596
+ currentScrapeId?: string | null;
597
+ statusCode?: number | null;
598
+ error?: string | null;
599
+ metadata?: unknown;
600
+ diff?: unknown;
601
+ createdAt: string;
602
+ }
603
+ interface MonitorCheckDetail extends MonitorCheck {
604
+ pages: MonitorCheckPage[];
605
+ next?: string | null;
606
+ }
607
+ interface ListMonitorsOptions {
608
+ limit?: number;
609
+ offset?: number;
610
+ }
611
+ type ListMonitorChecksOptions = ListMonitorsOptions;
612
+ type GetMonitorCheckOptions = PaginationConfig & {
613
+ limit?: number;
614
+ skip?: number;
615
+ status?: MonitorCheckPage["status"];
616
+ };
487
617
  interface ExtractResponse$1 {
488
618
  success?: boolean;
489
619
  id?: string;
@@ -671,6 +801,7 @@ declare class HttpClient {
671
801
  postMultipart<T = any>(endpoint: string, formData: FormData, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
672
802
  get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
673
803
  delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
804
+ patch<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
674
805
  prepareHeaders(idempotencyKey?: string): Record<string, string>;
675
806
  }
676
807
 
@@ -889,6 +1020,38 @@ declare class FirecrawlClient {
889
1020
  * @param prompt Natural-language instruction.
890
1021
  */
891
1022
  crawlParamsPreview(url: string, prompt: string): Promise<Record<string, unknown>>;
1023
+ /**
1024
+ * Create a scheduled monitor.
1025
+ */
1026
+ createMonitor(request: CreateMonitorRequest): Promise<Monitor>;
1027
+ /**
1028
+ * List monitors for the authenticated team.
1029
+ */
1030
+ listMonitors(options?: ListMonitorsOptions): Promise<Monitor[]>;
1031
+ /**
1032
+ * Get a monitor by id.
1033
+ */
1034
+ getMonitor(monitorId: string): Promise<Monitor>;
1035
+ /**
1036
+ * Update a monitor.
1037
+ */
1038
+ updateMonitor(monitorId: string, request: UpdateMonitorRequest): Promise<Monitor>;
1039
+ /**
1040
+ * Delete a monitor.
1041
+ */
1042
+ deleteMonitor(monitorId: string): Promise<boolean>;
1043
+ /**
1044
+ * Trigger a manual monitor check.
1045
+ */
1046
+ runMonitor(monitorId: string): Promise<MonitorCheck>;
1047
+ /**
1048
+ * List checks for a monitor.
1049
+ */
1050
+ listMonitorChecks(monitorId: string, options?: ListMonitorChecksOptions): Promise<MonitorCheck[]>;
1051
+ /**
1052
+ * Get a monitor check with paginated page results and inline diffs.
1053
+ */
1054
+ getMonitorCheck(monitorId: string, checkId: string, options?: GetMonitorCheckOptions): Promise<MonitorCheckDetail>;
892
1055
  /**
893
1056
  * Start a batch scrape job for multiple URLs (async).
894
1057
  * @param urls URLs to scrape.
@@ -1928,4 +2091,4 @@ declare class Firecrawl extends FirecrawlClient {
1928
2091
  get v1(): FirecrawlApp;
1929
2092
  }
1930
2093
 
1931
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
2094
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type HighlightsFormat, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorEmailNotification, type MonitorNotification, type MonitorSchedule, type MonitorScrapeTarget, type MonitorSummary, type MonitorTarget, type MonitorWebhookConfig, type PDFAction, type PaginationConfig, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type PressAction, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-EH7NHUN5.js";
3
+ } from "./chunk-WTZQ5IMF.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -113,6 +113,15 @@ var HttpClient = class {
113
113
  delete(endpoint, headers) {
114
114
  return this.request({ method: "delete", url: endpoint, headers });
115
115
  }
116
+ patch(endpoint, body, options) {
117
+ return this.request({
118
+ method: "patch",
119
+ url: endpoint,
120
+ data: body,
121
+ headers: options?.headers,
122
+ timeout: options?.timeoutMs
123
+ });
124
+ }
116
125
  prepareHeaders(idempotencyKey) {
117
126
  const headers = {};
118
127
  if (idempotencyKey) headers["x-idempotency-key"] = idempotencyKey;
@@ -235,6 +244,30 @@ function ensureValidFormats(formats) {
235
244
  }
236
245
  continue;
237
246
  }
247
+ if (fmt.type === "question") {
248
+ const q = fmt;
249
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
250
+ throw new Error("question format requires a non-empty 'question' string");
251
+ }
252
+ continue;
253
+ }
254
+ if (fmt.type === "highlights") {
255
+ const h = fmt;
256
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
257
+ throw new Error("highlights format requires a non-empty 'query' string");
258
+ }
259
+ continue;
260
+ }
261
+ if (fmt.type === "query") {
262
+ const q = fmt;
263
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
264
+ throw new Error("query format requires a non-empty 'prompt' string");
265
+ }
266
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
267
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
268
+ }
269
+ continue;
270
+ }
238
271
  if (fmt.type === "screenshot") {
239
272
  const s = fmt;
240
273
  if (s.quality != null && (typeof s.quality !== "number" || s.quality < 0)) {
@@ -294,6 +327,30 @@ function ensureValidParseFormats(formats) {
294
327
  "json format schema appears to be a Zod schema's .shape property. Pass the Zod schema directly (e.g., `schema: MySchema`) instead of `schema: MySchema.shape`. The SDK will automatically convert Zod schemas to JSON Schema format."
295
328
  );
296
329
  }
330
+ continue;
331
+ }
332
+ if (fmt.type === "question") {
333
+ const q = fmt;
334
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
335
+ throw new Error("question format requires a non-empty 'question' string");
336
+ }
337
+ continue;
338
+ }
339
+ if (fmt.type === "highlights") {
340
+ const h = fmt;
341
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
342
+ throw new Error("highlights format requires a non-empty 'query' string");
343
+ }
344
+ continue;
345
+ }
346
+ if (fmt.type === "query") {
347
+ const q = fmt;
348
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
349
+ throw new Error("query format requires a non-empty 'prompt' string");
350
+ }
351
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
352
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
353
+ }
297
354
  }
298
355
  }
299
356
  }
@@ -635,12 +692,13 @@ async function fetchAllPages(http, nextUrl, initial, pagination) {
635
692
  break;
636
693
  }
637
694
  if (!payload?.success) break;
638
- for (const d of payload.data || []) {
695
+ const pageData = Array.isArray(payload.data) ? payload.data : payload.data?.pages || [];
696
+ for (const d of pageData) {
639
697
  if (maxResults != null && docs.length >= maxResults) break;
640
698
  docs.push(d);
641
699
  }
642
700
  if (maxResults != null && docs.length >= maxResults) break;
643
- current = payload.next ?? null;
701
+ current = payload.next ?? (Array.isArray(payload.data) ? null : payload.data?.next) ?? null;
644
702
  pageCount += 1;
645
703
  }
646
704
  return docs;
@@ -1223,6 +1281,126 @@ async function getTokenUsageHistorical(http, byApiKey) {
1223
1281
  }
1224
1282
  }
1225
1283
 
1284
+ // src/v2/methods/monitor.ts
1285
+ function queryString(params) {
1286
+ if (!params) return "";
1287
+ const query = new URLSearchParams();
1288
+ for (const [key, value] of Object.entries(params)) {
1289
+ if (value !== void 0 && value !== null) query.set(key, String(value));
1290
+ }
1291
+ const str = query.toString();
1292
+ return str ? `?${str}` : "";
1293
+ }
1294
+ function dataOrThrow(res, action) {
1295
+ if (res.status !== 200 || !res.data?.success || res.data.data == null) {
1296
+ throwForBadResponse(res, action);
1297
+ }
1298
+ return res.data.data;
1299
+ }
1300
+ async function createMonitor(http, request) {
1301
+ try {
1302
+ const res = await http.post("/v2/monitor", request);
1303
+ return dataOrThrow(res, "create monitor");
1304
+ } catch (err) {
1305
+ if (err?.isAxiosError) return normalizeAxiosError(err, "create monitor");
1306
+ throw err;
1307
+ }
1308
+ }
1309
+ async function listMonitors(http, options) {
1310
+ try {
1311
+ const res = await http.get(
1312
+ `/v2/monitor${queryString(options)}`
1313
+ );
1314
+ return dataOrThrow(res, "list monitors");
1315
+ } catch (err) {
1316
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list monitors");
1317
+ throw err;
1318
+ }
1319
+ }
1320
+ async function getMonitor(http, monitorId) {
1321
+ try {
1322
+ const res = await http.get(`/v2/monitor/${monitorId}`);
1323
+ return dataOrThrow(res, "get monitor");
1324
+ } catch (err) {
1325
+ if (err?.isAxiosError) return normalizeAxiosError(err, "get monitor");
1326
+ throw err;
1327
+ }
1328
+ }
1329
+ async function updateMonitor(http, monitorId, request) {
1330
+ try {
1331
+ const res = await http.patch(
1332
+ `/v2/monitor/${monitorId}`,
1333
+ request
1334
+ );
1335
+ return dataOrThrow(res, "update monitor");
1336
+ } catch (err) {
1337
+ if (err?.isAxiosError) return normalizeAxiosError(err, "update monitor");
1338
+ throw err;
1339
+ }
1340
+ }
1341
+ async function deleteMonitor(http, monitorId) {
1342
+ try {
1343
+ const res = await http.delete(`/v2/monitor/${monitorId}`);
1344
+ if (res.status !== 200 || !res.data?.success) {
1345
+ throwForBadResponse(res, "delete monitor");
1346
+ }
1347
+ return true;
1348
+ } catch (err) {
1349
+ if (err?.isAxiosError) return normalizeAxiosError(err, "delete monitor");
1350
+ throw err;
1351
+ }
1352
+ }
1353
+ async function runMonitor(http, monitorId) {
1354
+ try {
1355
+ const res = await http.post(
1356
+ `/v2/monitor/${monitorId}/run`,
1357
+ {}
1358
+ );
1359
+ return dataOrThrow(res, "run monitor");
1360
+ } catch (err) {
1361
+ if (err?.isAxiosError) return normalizeAxiosError(err, "run monitor");
1362
+ throw err;
1363
+ }
1364
+ }
1365
+ async function listMonitorChecks(http, monitorId, options) {
1366
+ try {
1367
+ const res = await http.get(
1368
+ `/v2/monitor/${monitorId}/checks${queryString(options)}`
1369
+ );
1370
+ return dataOrThrow(res, "list monitor checks");
1371
+ } catch (err) {
1372
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list monitor checks");
1373
+ throw err;
1374
+ }
1375
+ }
1376
+ async function getMonitorCheck(http, monitorId, checkId, options) {
1377
+ try {
1378
+ const { autoPaginate: _autoPaginate, maxPages: _maxPages, maxResults: _maxResults, maxWaitTime: _maxWaitTime, ...query } = options ?? {};
1379
+ const res = await http.get(
1380
+ `/v2/monitor/${monitorId}/checks/${checkId}${queryString(query)}`
1381
+ );
1382
+ const detail = dataOrThrow(res, "get monitor check");
1383
+ const next = res.data?.next ?? detail.next ?? null;
1384
+ const auto = options?.autoPaginate ?? true;
1385
+ if (!auto || !next) {
1386
+ return { ...detail, next };
1387
+ }
1388
+ return {
1389
+ ...detail,
1390
+ pages: await fetchAllPages(
1391
+ http,
1392
+ next,
1393
+ detail.pages || [],
1394
+ options
1395
+ ),
1396
+ next: null
1397
+ };
1398
+ } catch (err) {
1399
+ if (err?.isAxiosError) return normalizeAxiosError(err, "get monitor check");
1400
+ throw err;
1401
+ }
1402
+ }
1403
+
1226
1404
  // src/v2/watcher.ts
1227
1405
  import { EventEmitter } from "events";
1228
1406
  var hasGlobalWebSocket = () => {
@@ -1604,6 +1782,55 @@ var FirecrawlClient = class {
1604
1782
  async crawlParamsPreview(url, prompt) {
1605
1783
  return crawlParamsPreview(this.http, url, prompt);
1606
1784
  }
1785
+ // Monitor
1786
+ /**
1787
+ * Create a scheduled monitor.
1788
+ */
1789
+ async createMonitor(request) {
1790
+ return createMonitor(this.http, request);
1791
+ }
1792
+ /**
1793
+ * List monitors for the authenticated team.
1794
+ */
1795
+ async listMonitors(options) {
1796
+ return listMonitors(this.http, options);
1797
+ }
1798
+ /**
1799
+ * Get a monitor by id.
1800
+ */
1801
+ async getMonitor(monitorId) {
1802
+ return getMonitor(this.http, monitorId);
1803
+ }
1804
+ /**
1805
+ * Update a monitor.
1806
+ */
1807
+ async updateMonitor(monitorId, request) {
1808
+ return updateMonitor(this.http, monitorId, request);
1809
+ }
1810
+ /**
1811
+ * Delete a monitor.
1812
+ */
1813
+ async deleteMonitor(monitorId) {
1814
+ return deleteMonitor(this.http, monitorId);
1815
+ }
1816
+ /**
1817
+ * Trigger a manual monitor check.
1818
+ */
1819
+ async runMonitor(monitorId) {
1820
+ return runMonitor(this.http, monitorId);
1821
+ }
1822
+ /**
1823
+ * List checks for a monitor.
1824
+ */
1825
+ async listMonitorChecks(monitorId, options) {
1826
+ return listMonitorChecks(this.http, monitorId, options);
1827
+ }
1828
+ /**
1829
+ * Get a monitor check with paginated page results and inline diffs.
1830
+ */
1831
+ async getMonitorCheck(monitorId, checkId, options) {
1832
+ return getMonitorCheck(this.http, monitorId, checkId, options);
1833
+ }
1607
1834
  // Batch
1608
1835
  /**
1609
1836
  * Start a batch scrape job for multiple URLs (async).
@@ -1809,7 +2036,7 @@ var FirecrawlApp = class {
1809
2036
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1810
2037
  return process.env.npm_package_version;
1811
2038
  }
1812
- const packageJson = await import("./package-7423KYJY.js");
2039
+ const packageJson = await import("./package-YDTOLYXI.js");
1813
2040
  return packageJson.default.version;
1814
2041
  } catch (error) {
1815
2042
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-EH7NHUN5.js";
3
+ } from "./chunk-WTZQ5IMF.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "4.21.1",
3
+ "version": "4.22.1",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "author": "Mendable.ai",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "axios": "1.15.0",
22
+ "axios": "1.15.2",
23
23
  "typescript-event-target": "^1.1.1",
24
24
  "zod": "^3.23.8",
25
25
  "zod-to-json-schema": "^3.23.0"
@@ -1,6 +1,7 @@
1
1
  import { describe, test, expect, jest } from "@jest/globals";
2
2
  import { getCrawlStatus } from "../../../v2/methods/crawl";
3
3
  import { getBatchScrapeStatus } from "../../../v2/methods/batch";
4
+ import { getMonitorCheck } from "../../../v2/methods/monitor";
4
5
 
5
6
  describe("JS SDK v2 pagination", () => {
6
7
  function makeHttp(getImpl: (url: string) => any) {
@@ -64,6 +65,26 @@ describe("JS SDK v2 pagination", () => {
64
65
  expect(res.next).toBe("https://api/nextBatch");
65
66
  });
66
67
 
68
+ test("monitor check: default autoPaginate aggregates pages and nulls next", async () => {
69
+ const first = { status: 200, data: { success: true, next: "https://api/m1", data: { id: "check1", monitorId: "mon1", status: "completed", trigger: "manual", billingStatus: "confirmed", summary: {}, createdAt: "now", updatedAt: "now", pages: [{ url: "a", status: "changed" }], next: "https://api/m1" } } };
70
+ const second = { status: 200, data: { success: true, next: null, data: { pages: [{ url: "b", status: "same" }], next: null } } };
71
+ const http = makeHttp((url) => {
72
+ if (url.includes("/v2/monitor/")) return first;
73
+ return second;
74
+ });
75
+ const res = await getMonitorCheck(http, "mon1", "check1");
76
+ expect(res.pages.length).toBe(2);
77
+ expect(res.next).toBeNull();
78
+ });
79
+
80
+ test("monitor check: autoPaginate=false returns next", async () => {
81
+ const first = { status: 200, data: { success: true, next: "https://api/m1", data: { id: "check1", monitorId: "mon1", status: "completed", trigger: "manual", billingStatus: "confirmed", summary: {}, createdAt: "now", updatedAt: "now", pages: [{ url: "a", status: "changed" }], next: "https://api/m1" } } };
82
+ const http = makeHttp(() => first);
83
+ const res = await getMonitorCheck(http, "mon1", "check1", { autoPaginate: false });
84
+ expect(res.pages.length).toBe(1);
85
+ expect(res.next).toBe("https://api/m1");
86
+ });
87
+
67
88
  test("crawl: maxWaitTime stops pagination after first page", async () => {
68
89
  const first = { status: 200, data: { success: true, status: "completed", completed: 1, total: 5, next: "https://api/n1", data: [{ markdown: "a" }] } };
69
90
  const p1 = { status: 200, data: { success: true, next: "https://api/n2", data: [{ markdown: "b" }] } };
@@ -56,6 +56,27 @@ describe("v2 utils: validation", () => {
56
56
  expect((formats[0] as any).viewport).toEqual({ width: 800, height: 600 });
57
57
  });
58
58
 
59
+ test("ensureValidFormats: accepts question, highlights, and deprecated query formats", () => {
60
+ const formats: FormatOption[] = [
61
+ { type: "question", question: "What is Firecrawl?" },
62
+ { type: "highlights", query: "What is Firecrawl?" },
63
+ { type: "query", prompt: "What is Firecrawl?", mode: "directQuote" },
64
+ ];
65
+ expect(() => ensureValidFormats(formats)).not.toThrow();
66
+ });
67
+
68
+ test("ensureValidFormats: validates question, highlights, and deprecated query fields", () => {
69
+ expect(() =>
70
+ ensureValidFormats([{ type: "question", question: "" } as any]),
71
+ ).toThrow(/question format requires/i);
72
+ expect(() =>
73
+ ensureValidFormats([{ type: "highlights", query: "" } as any]),
74
+ ).toThrow(/highlights format requires/i);
75
+ expect(() =>
76
+ ensureValidFormats([{ type: "query", prompt: "p", mode: "quoted" } as any]),
77
+ ).toThrow(/query format mode/i);
78
+ });
79
+
59
80
  test("ensureValidScrapeOptions: leaves parsers untouched", () => {
60
81
  const options = { parsers: ["pdf", "images"] as string[] } as any;
61
82
  const before = [...options.parsers];