From 877d5e4383bde79f5aab4b2bbaa804c2497a0bdd Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 27 Oct 2024 23:17:20 -0300 Subject: [PATCH] Update types.ts --- apps/api/src/controllers/v1/types.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/api/src/controllers/v1/types.ts b/apps/api/src/controllers/v1/types.ts index 22ac6294..8c60c0fb 100644 --- a/apps/api/src/controllers/v1/types.ts +++ b/apps/api/src/controllers/v1/types.ts @@ -109,6 +109,16 @@ export const scrapeOptions = z.object({ extract: extractOptions.optional(), parsePDF: z.boolean().default(true), 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') + }).optional(), + // Deprecated geolocation: z.object({ country: z.string().optional().refine( (val) => !val || Object.keys(countries).includes(val.toUpperCase()), @@ -445,7 +455,7 @@ export function legacyScrapeOptions(x: ScrapeOptions): PageOptions { fullPageScreenshot: x.formats.includes("screenshot@fullPage"), parsePDF: x.parsePDF, actions: x.actions as Action[], // no strict null checking grrrr - mogery - geolocation: x.geolocation, + geolocation: x.location ?? x.geolocation, skipTlsVerification: x.skipTlsVerification }; }