-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtypes.ts
134 lines (120 loc) · 3.53 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import type { ProxyConfigurationOptions } from 'apify';
import { CheerioCrawlerOptions, PlaywrightCrawlerOptions } from 'crawlee';
import { ContentCrawlerTypes } from './const';
export type OutputFormats = 'text' | 'markdown' | 'html';
export type Input = {
debugMode: boolean;
requestTimeoutSecs: number;
// both
keepAlive: boolean;
// google search parameters
countryCode: string;
languageCode: string;
maxResults: number;
serpProxyGroup: 'GOOGLE_SERP' | 'SHADER';
serpMaxRetries: number;
query: string;
// content crawler parameters
dynamicContentWaitSecs: number;
outputFormats: OutputFormats[];
initialConcurrency: number;
maxConcurrency: number;
maxRequestRetries: number;
minConcurrency: number;
proxyConfiguration: ProxyConfigurationOptions;
readableTextCharThreshold: number;
removeElementsCssSelector: string;
removeCookieWarnings: boolean;
scrapingTool: 'browser-playwright' | 'raw-http';
blockMedia: boolean;
};
export type StandbyInput = Input & {
outputFormats: OutputFormats[] | string
}
export type OrganicResult = {
description?: string;
title?: string;
rank?: number;
url?: string;
};
export interface TimeMeasure {
event:
| 'actor-started'
| 'before-cheerio-queue-add'
| 'before-cheerio-run'
| 'before-playwright-queue-add'
| 'before-playwright-run'
| 'cheerio-request-start'
| 'cheerio-failed-request'
| 'cheerio-process-html'
| 'cheerio-request-end'
| 'cheerio-request-handler-start'
| 'cheerio-before-response-send'
| 'error'
| 'playwright-request-start'
| 'playwright-wait-dynamic-content'
| 'playwright-parse-with-cheerio'
| 'playwright-process-html'
| 'playwright-remove-cookie'
| 'playwright-before-response-send'
| 'playwright-failed-request'
| 'request-received';
timeMs: number;
timeDeltaPrevMs: number;
}
export type SearchCrawlerUserData = {
maxResults: number;
timeMeasures: TimeMeasure[];
query: string;
contentCrawlerKey: string;
responseId: string;
contentScraperSettings: ContentScraperSettings;
};
export type ContentCrawlerUserData = {
query: string;
responseId: string;
timeMeasures: TimeMeasure[];
searchResult?: OrganicResult;
contentCrawlerKey?: string;
contentScraperSettings: ContentScraperSettings;
};
export interface ContentScraperSettings {
debugMode: boolean;
dynamicContentWaitSecs: number;
htmlTransformer?: string
maxHtmlCharsToProcess: number;
outputFormats: OutputFormats[];
readableTextCharThreshold: number;
removeCookieWarnings?: boolean;
removeElementsCssSelector?: string;
}
export type Output = {
text?: string | null;
html?: string | null;
markdown?: string | null;
query?: string;
crawl: {
createdAt?: Date;
httpStatusCode?: number | null;
httpStatusMessage?: string | null;
loadedAt?: Date;
requestStatus: string;
uniqueKey: string;
debug?: unknown;
};
searchResult: OrganicResult;
metadata: {
title?: string | null;
url: string;
description?: string | null;
author?: string | null;
languageCode?: string | null;
};
};
export type ContentCrawlerOptions = {
type: ContentCrawlerTypes.CHEERIO,
crawlerOptions: CheerioCrawlerOptions
} | {
type: ContentCrawlerTypes.PLAYWRIGHT,
crawlerOptions: PlaywrightCrawlerOptions
};