Merge pull request #830 from mendableai/nsc/geo-to-location

Geo-location rename to location
This commit is contained in:
Nicolas 2024-10-28 20:28:30 -03:00 committed by GitHub
commit c96b36d045
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 3 deletions

View File

@ -109,13 +109,26 @@ export const scrapeOptions = z.object({
extract: extractOptions.optional(), extract: extractOptions.optional(),
parsePDF: z.boolean().default(true), parsePDF: z.boolean().default(true),
actions: actionsSchema.optional(), actions: actionsSchema.optional(),
// New
location: z.object({
country: z.string().optional().refine(
(val) => !val || Object.keys(countries).includes(val.toUpperCase()),
{
message: "Invalid country code. Please use a valid ISO 3166-1 alpha-2 country code.",
}
).transform(val => val ? val.toUpperCase() : 'US'),
languages: z.string().array().optional(),
}).optional(),
// Deprecated
geolocation: z.object({ geolocation: z.object({
country: z.string().optional().refine( country: z.string().optional().refine(
(val) => !val || Object.keys(countries).includes(val.toUpperCase()), (val) => !val || Object.keys(countries).includes(val.toUpperCase()),
{ {
message: "Invalid country code. Please use a valid ISO 3166-1 alpha-2 country code.", message: "Invalid country code. Please use a valid ISO 3166-1 alpha-2 country code.",
} }
).transform(val => val ? val.toUpperCase() : 'US') ).transform(val => val ? val.toUpperCase() : 'US'),
languages: z.string().array().optional(),
}).optional(), }).optional(),
skipTlsVerification: z.boolean().default(false), skipTlsVerification: z.boolean().default(false),
}).strict(strictMessage) }).strict(strictMessage)
@ -445,7 +458,7 @@ export function legacyScrapeOptions(x: ScrapeOptions): PageOptions {
fullPageScreenshot: x.formats.includes("screenshot@fullPage"), fullPageScreenshot: x.formats.includes("screenshot@fullPage"),
parsePDF: x.parsePDF, parsePDF: x.parsePDF,
actions: x.actions as Action[], // no strict null checking grrrr - mogery actions: x.actions as Action[], // no strict null checking grrrr - mogery
geolocation: x.geolocation, geolocation: x.location ?? x.geolocation,
skipTlsVerification: x.skipTlsVerification skipTlsVerification: x.skipTlsVerification
}; };
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@mendable/firecrawl-js", "name": "@mendable/firecrawl-js",
"version": "1.7.1", "version": "1.7.2",
"description": "JavaScript SDK for Firecrawl API", "description": "JavaScript SDK for Firecrawl API",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -82,6 +82,10 @@ export interface CrawlScrapeOptions {
onlyMainContent?: boolean; onlyMainContent?: boolean;
waitFor?: number; waitFor?: number;
timeout?: number; timeout?: number;
location?: {
country?: string;
languages?: string[];
};
} }
export type Action = { export type Action = {