File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ import type { CheerioCrawlerOptions, PlaywrightCrawlerOptions } from 'crawlee';
33
44import type { ContentCrawlerTypes } from './const' ;
55
6+ /**
7+ * Utility type to make specific properties of T optional.
8+ * @template T - The type to make properties optional
9+ * @template K - The keys of T to make optional
10+ */
11+ type Optional < T , K extends keyof T > = Omit < T , K > & Partial < Pick < T , K > > ;
12+
613export type OutputFormats = 'text' | 'markdown' | 'html' ;
714export type SERPProxyGroup = 'GOOGLE_SERP' | 'SHADER' ;
815export type ScrapingTool = 'browser-playwright' | 'raw-http' ;
@@ -95,6 +102,12 @@ export type SearchCrawlerUserData = {
95102 totalPages : number ;
96103} ;
97104
105+ /**
106+ * Type for createSearchRequest function parameters.
107+ * Makes pagination fields optional while keeping required fields mandatory.
108+ */
109+ export type CreateSearchRequestUserData = Optional < SearchCrawlerUserData , 'timeMeasures' | 'collectedResults' | 'currentPage' | 'totalPages' > ;
110+
98111export type ContentCrawlerUserData = {
99112 query : string ;
100113 responseId : string ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { log } from 'crawlee';
77import inputSchema from '../.actor/input_schema.json' with { type : 'json' } ;
88import type { ContentCrawlerUserData ,
99 ContentScraperSettings ,
10+ CreateSearchRequestUserData ,
1011 Input ,
1112 OrganicResult , OutputFormats ,
1213 SearchCrawlerUserData ,
@@ -87,13 +88,7 @@ export function randomId() {
8788 * We add +1 to the calculated totalPages to account for pages that return fewer than 10 results.
8889 */
8990export function createSearchRequest (
90- userData : Partial < SearchCrawlerUserData > & {
91- query : string ;
92- responseId : string ;
93- maxResults : number ;
94- contentCrawlerKey : string ;
95- contentScraperSettings : ContentScraperSettings ;
96- } ,
91+ userData : CreateSearchRequestUserData ,
9792 proxyConfiguration : ProxyConfiguration | undefined ,
9893 startOffset = 0 ,
9994) : RequestOptions < SearchCrawlerUserData > {
You can’t perform that action at this time.
0 commit comments