firecrawl 4.22.0 → 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.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "4.22.0",
11
+ version: "4.22.1",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "4.22.0",
38
+ version: "4.22.1",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -368,6 +368,30 @@ function ensureValidFormats(formats) {
368
368
  }
369
369
  continue;
370
370
  }
371
+ if (fmt.type === "question") {
372
+ const q = fmt;
373
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
374
+ throw new Error("question format requires a non-empty 'question' string");
375
+ }
376
+ continue;
377
+ }
378
+ if (fmt.type === "highlights") {
379
+ const h = fmt;
380
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
381
+ throw new Error("highlights format requires a non-empty 'query' string");
382
+ }
383
+ continue;
384
+ }
385
+ if (fmt.type === "query") {
386
+ const q = fmt;
387
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
388
+ throw new Error("query format requires a non-empty 'prompt' string");
389
+ }
390
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
391
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
392
+ }
393
+ continue;
394
+ }
371
395
  if (fmt.type === "screenshot") {
372
396
  const s = fmt;
373
397
  if (s.quality != null && (typeof s.quality !== "number" || s.quality < 0)) {
@@ -427,6 +451,30 @@ function ensureValidParseFormats(formats) {
427
451
  "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."
428
452
  );
429
453
  }
454
+ continue;
455
+ }
456
+ if (fmt.type === "question") {
457
+ const q = fmt;
458
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
459
+ throw new Error("question format requires a non-empty 'question' string");
460
+ }
461
+ continue;
462
+ }
463
+ if (fmt.type === "highlights") {
464
+ const h = fmt;
465
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
466
+ throw new Error("highlights format requires a non-empty 'query' string");
467
+ }
468
+ continue;
469
+ }
470
+ if (fmt.type === "query") {
471
+ const q = fmt;
472
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
473
+ throw new Error("query format requires a non-empty 'prompt' string");
474
+ }
475
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
476
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
477
+ }
430
478
  }
431
479
  }
432
480
  }
package/dist/index.d.cts 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;
@@ -2081,4 +2091,4 @@ declare class Firecrawl extends FirecrawlClient {
2081
2091
  get v1(): FirecrawlApp;
2082
2092
  }
2083
2093
 
2084
- 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, 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 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 };
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.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;
@@ -2081,4 +2091,4 @@ declare class Firecrawl extends FirecrawlClient {
2081
2091
  get v1(): FirecrawlApp;
2082
2092
  }
2083
2093
 
2084
- 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, 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 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 };
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-XWPH5FOQ.js";
3
+ } from "./chunk-WTZQ5IMF.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -244,6 +244,30 @@ function ensureValidFormats(formats) {
244
244
  }
245
245
  continue;
246
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
+ }
247
271
  if (fmt.type === "screenshot") {
248
272
  const s = fmt;
249
273
  if (s.quality != null && (typeof s.quality !== "number" || s.quality < 0)) {
@@ -303,6 +327,30 @@ function ensureValidParseFormats(formats) {
303
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."
304
328
  );
305
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
+ }
306
354
  }
307
355
  }
308
356
  }
@@ -1988,7 +2036,7 @@ var FirecrawlApp = class {
1988
2036
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1989
2037
  return process.env.npm_package_version;
1990
2038
  }
1991
- const packageJson = await import("./package-VALCXP74.js");
2039
+ const packageJson = await import("./package-YDTOLYXI.js");
1992
2040
  return packageJson.default.version;
1993
2041
  } catch (error) {
1994
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-XWPH5FOQ.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.22.0",
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",
@@ -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];
package/src/v2/types.ts CHANGED
@@ -52,6 +52,17 @@ export interface AttributesFormat extends Format {
52
52
  }>;
53
53
  }
54
54
 
55
+ export interface QuestionFormat {
56
+ type: 'question';
57
+ question: string;
58
+ }
59
+
60
+ export interface HighlightsFormat {
61
+ type: 'highlights';
62
+ query: string;
63
+ }
64
+
65
+ /** @deprecated Use QuestionFormat or HighlightsFormat instead. */
55
66
  export interface QueryFormat {
56
67
  type: 'query';
57
68
  prompt: string;
@@ -65,6 +76,8 @@ export type FormatOption =
65
76
  | ChangeTrackingFormat
66
77
  | ScreenshotFormat
67
78
  | AttributesFormat
79
+ | QuestionFormat
80
+ | HighlightsFormat
68
81
  | QueryFormat;
69
82
 
70
83
  export type ParseFormatString = Exclude<
@@ -81,6 +94,8 @@ export type ParseFormatOption =
81
94
  | ParseFormat
82
95
  | JsonFormat
83
96
  | AttributesFormat
97
+ | QuestionFormat
98
+ | HighlightsFormat
84
99
  | QueryFormat;
85
100
 
86
101
  export interface LocationConfig {
@@ -450,6 +465,7 @@ export interface Document {
450
465
  }>;
451
466
  actions?: Record<string, unknown>;
452
467
  answer?: string;
468
+ highlights?: string;
453
469
  warning?: string;
454
470
  changeTracking?: Record<string, unknown>;
455
471
  branding?: BrandingProfile;
@@ -4,6 +4,9 @@ import {
4
4
  type JsonFormat,
5
5
  type ParseFormatOption,
6
6
  type ParseOptions,
7
+ type QuestionFormat,
8
+ type HighlightsFormat,
9
+ type QueryFormat,
7
10
  type ScrapeOptions,
8
11
  type ScreenshotFormat,
9
12
  } from "../types";
@@ -49,6 +52,30 @@ export function ensureValidFormats(formats?: FormatOption[]): void {
49
52
  }
50
53
  continue;
51
54
  }
55
+ if ((fmt as QuestionFormat).type === "question") {
56
+ const q = fmt as QuestionFormat;
57
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
58
+ throw new Error("question format requires a non-empty 'question' string");
59
+ }
60
+ continue;
61
+ }
62
+ if ((fmt as HighlightsFormat).type === "highlights") {
63
+ const h = fmt as HighlightsFormat;
64
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
65
+ throw new Error("highlights format requires a non-empty 'query' string");
66
+ }
67
+ continue;
68
+ }
69
+ if ((fmt as QueryFormat).type === "query") {
70
+ const q = fmt as QueryFormat;
71
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
72
+ throw new Error("query format requires a non-empty 'prompt' string");
73
+ }
74
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
75
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
76
+ }
77
+ continue;
78
+ }
52
79
  if ((fmt as ScreenshotFormat).type === "screenshot") {
53
80
  // no-op; already camelCase; validate numeric fields if present
54
81
  const s = fmt as ScreenshotFormat;
@@ -116,6 +143,31 @@ export function ensureValidParseFormats(formats?: ParseFormatOption[]): void {
116
143
  "The SDK will automatically convert Zod schemas to JSON Schema format."
117
144
  );
118
145
  }
146
+ continue;
147
+ }
148
+
149
+ if ((fmt as QuestionFormat).type === "question") {
150
+ const q = fmt as QuestionFormat;
151
+ if (typeof q.question !== "string" || q.question.trim().length === 0) {
152
+ throw new Error("question format requires a non-empty 'question' string");
153
+ }
154
+ continue;
155
+ }
156
+ if ((fmt as HighlightsFormat).type === "highlights") {
157
+ const h = fmt as HighlightsFormat;
158
+ if (typeof h.query !== "string" || h.query.trim().length === 0) {
159
+ throw new Error("highlights format requires a non-empty 'query' string");
160
+ }
161
+ continue;
162
+ }
163
+ if ((fmt as QueryFormat).type === "query") {
164
+ const q = fmt as QueryFormat;
165
+ if (typeof q.prompt !== "string" || q.prompt.trim().length === 0) {
166
+ throw new Error("query format requires a non-empty 'prompt' string");
167
+ }
168
+ if (q.mode != null && q.mode !== "freeform" && q.mode !== "directQuote") {
169
+ throw new Error("query format mode must be 'freeform' or 'directQuote'");
170
+ }
119
171
  }
120
172
  }
121
173
  }