@crawlee/types 4.0.0-beta.20 → 4.0.0-beta.21
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.
- package/http-client.d.ts +90 -0
- package/http-client.d.ts.map +1 -0
- package/http-client.js +2 -0
- package/http-client.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +3 -2
- package/session.d.ts +178 -0
- package/session.d.ts.map +1 -0
- package/session.js +2 -0
- package/session.js.map +1 -0
package/http-client.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { ISession } from './session.js';
|
|
3
|
+
import type { AllowedHttpMethods } from './utility-types.js';
|
|
4
|
+
export type SearchParams = string | URLSearchParams | Record<string, string | number | boolean | null | undefined>;
|
|
5
|
+
interface ToughCookieJar {
|
|
6
|
+
getCookieString: ((currentUrl: string, options: Record<string, unknown>, callback: (error: Error | null, cookies: string) => void) => string) & ((url: string, callback: (error: Error | null, cookieHeader: string) => void) => string);
|
|
7
|
+
setCookie: ((cookieOrString: unknown, currentUrl: string, options: Record<string, unknown>, callback: (error: Error | null, cookie: unknown) => void) => void) & ((rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void) => void);
|
|
8
|
+
}
|
|
9
|
+
interface PromiseCookieJar {
|
|
10
|
+
getCookieString: (url: string) => Promise<string>;
|
|
11
|
+
setCookie: (rawCookie: string, url: string) => Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* HTTP Request as accepted by {@link BaseHttpClient} methods.
|
|
15
|
+
*/
|
|
16
|
+
export interface HttpRequest {
|
|
17
|
+
url: string | URL;
|
|
18
|
+
method?: AllowedHttpMethods;
|
|
19
|
+
headers?: Headers;
|
|
20
|
+
body?: Readable;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
cookieJar?: ToughCookieJar | PromiseCookieJar;
|
|
24
|
+
followRedirect?: boolean | ((response: any) => boolean);
|
|
25
|
+
maxRedirects?: number;
|
|
26
|
+
encoding?: BufferEncoding;
|
|
27
|
+
throwHttpErrors?: boolean;
|
|
28
|
+
proxyUrl?: string;
|
|
29
|
+
headerGeneratorOptions?: Record<string, unknown>;
|
|
30
|
+
useHeaderGenerator?: boolean;
|
|
31
|
+
headerGenerator?: {
|
|
32
|
+
getHeaders: (options: Record<string, unknown>) => Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
insecureHTTPParser?: boolean;
|
|
35
|
+
sessionToken?: object;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Additional options for HTTP requests that need to be handled separately before passing to {@link BaseHttpClient}.
|
|
39
|
+
*/
|
|
40
|
+
export interface HttpRequestOptions extends HttpRequest {
|
|
41
|
+
/** Search (query string) parameters to be appended to the request URL */
|
|
42
|
+
searchParams?: SearchParams;
|
|
43
|
+
/** A form to be sent in the HTTP request body (URL encoding will be used) */
|
|
44
|
+
form?: Record<string, string>;
|
|
45
|
+
/** Arbitrary object to be JSON-serialized and sent as the HTTP request body */
|
|
46
|
+
json?: unknown;
|
|
47
|
+
/** Basic HTTP Auth username */
|
|
48
|
+
username?: string;
|
|
49
|
+
/** Basic HTTP Auth password */
|
|
50
|
+
password?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface IResponseWithUrl extends Response {
|
|
53
|
+
url: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Type of a function called when an HTTP redirect takes place. It is allowed to mutate the `updatedRequest` argument.
|
|
57
|
+
*/
|
|
58
|
+
export type RedirectHandler = (redirectResponse: Response, updatedRequest: {
|
|
59
|
+
url?: string | URL;
|
|
60
|
+
headers: Headers;
|
|
61
|
+
}) => void;
|
|
62
|
+
export interface SendRequestOptions {
|
|
63
|
+
session?: ISession;
|
|
64
|
+
cookieJar?: ToughCookieJar;
|
|
65
|
+
timeout?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Overrides the proxy URL set in the `session` for this request.
|
|
68
|
+
*
|
|
69
|
+
* Note that setting this manually can interfere with session proxy rotation.
|
|
70
|
+
*/
|
|
71
|
+
proxyUrl?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface StreamOptions extends SendRequestOptions {
|
|
74
|
+
onRedirect?: RedirectHandler;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Interface for user-defined HTTP clients to be used for plain HTTP crawling and for sending additional requests during a crawl.
|
|
78
|
+
*/
|
|
79
|
+
export interface BaseHttpClient {
|
|
80
|
+
/**
|
|
81
|
+
* Perform an HTTP Request and return the complete response.
|
|
82
|
+
*/
|
|
83
|
+
sendRequest(request: Request, options?: SendRequestOptions): Promise<Response>;
|
|
84
|
+
/**
|
|
85
|
+
* Perform an HTTP Request and return after the response headers are received. The body may be read from a stream contained in the response.
|
|
86
|
+
*/
|
|
87
|
+
stream(request: Request, options?: StreamOptions): Promise<Response>;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAGnH,UAAU,cAAc;IACpB,eAAe,EAAE,CAAC,CACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACh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IACnB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACrD,UAAU,CAAC,EAAE,eAAe,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE/E;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxE"}
|
package/http-client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":""}
|
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
package/index.js
CHANGED
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/types",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.21",
|
|
4
4
|
"description": "Shared types for the crawlee projects",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"tough-cookie": "^6.0.0",
|
|
46
47
|
"tslib": "^2.8.1"
|
|
47
48
|
},
|
|
48
49
|
"lerna": {
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e370ab2f4ffcf4f63b52a61c9b6e97081d525e64"
|
|
56
57
|
}
|
package/session.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { CookieJar, SerializedCookieJar } from 'tough-cookie';
|
|
2
|
+
import type { Cookie } from './browser.js';
|
|
3
|
+
import type { Dictionary } from './utility-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The main purpose of the ProxyInfo object is to provide information
|
|
6
|
+
* about the current proxy connection used by the crawler for the request.
|
|
7
|
+
* Outside of crawlers, you can get this object by calling {@link ProxyConfiguration.newProxyInfo}.
|
|
8
|
+
*
|
|
9
|
+
* **Example usage:**
|
|
10
|
+
*
|
|
11
|
+
* ```javascript
|
|
12
|
+
* const proxyConfiguration = new ProxyConfiguration({
|
|
13
|
+
* proxyUrls: ['...', '...'] // List of Proxy URLs to rotate
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Getting proxyInfo object by calling class method directly
|
|
17
|
+
* const proxyInfo = await proxyConfiguration.newProxyInfo();
|
|
18
|
+
*
|
|
19
|
+
* // In crawler
|
|
20
|
+
* const crawler = new CheerioCrawler({
|
|
21
|
+
* // ...
|
|
22
|
+
* proxyConfiguration,
|
|
23
|
+
* requestHandler({ proxyInfo }) {
|
|
24
|
+
* // Getting used proxy URL
|
|
25
|
+
* const proxyUrl = proxyInfo.url;
|
|
26
|
+
* }
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export interface ProxyInfo {
|
|
32
|
+
/**
|
|
33
|
+
* The URL of the proxy.
|
|
34
|
+
*/
|
|
35
|
+
url: string;
|
|
36
|
+
/**
|
|
37
|
+
* Username for the proxy.
|
|
38
|
+
*/
|
|
39
|
+
username?: string;
|
|
40
|
+
/**
|
|
41
|
+
* User's password for the proxy.
|
|
42
|
+
*/
|
|
43
|
+
password: string;
|
|
44
|
+
/**
|
|
45
|
+
* Hostname of your proxy.
|
|
46
|
+
*/
|
|
47
|
+
hostname: string;
|
|
48
|
+
/**
|
|
49
|
+
* Proxy port.
|
|
50
|
+
*/
|
|
51
|
+
port: number | string;
|
|
52
|
+
/**
|
|
53
|
+
* Proxy tier for the current proxy, if applicable (only for `tieredProxyUrls`).
|
|
54
|
+
*/
|
|
55
|
+
proxyTier?: number;
|
|
56
|
+
/**
|
|
57
|
+
* When `true`, the proxy is likely intercepting HTTPS traffic and is able to view and modify its content.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
ignoreTlsErrors?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Persistable {@link Session} state.
|
|
65
|
+
*/
|
|
66
|
+
export interface SessionState {
|
|
67
|
+
id: string;
|
|
68
|
+
cookieJar: SerializedCookieJar;
|
|
69
|
+
proxyInfo?: ProxyInfo;
|
|
70
|
+
userData: object;
|
|
71
|
+
errorScore: number;
|
|
72
|
+
maxErrorScore: number;
|
|
73
|
+
errorScoreDecrement: number;
|
|
74
|
+
usageCount: number;
|
|
75
|
+
maxUsageCount: number;
|
|
76
|
+
expiresAt: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sessions are used to store information such as cookies and can be used for generating fingerprints and proxy sessions.
|
|
81
|
+
* You can imagine each session as a specific user, with its own cookies, IP (via proxy) and potentially a unique browser fingerprint.
|
|
82
|
+
* Session internal state can be enriched with custom user data for example some authorization tokens and specific headers in general.
|
|
83
|
+
* @category Scaling
|
|
84
|
+
*/
|
|
85
|
+
export interface ISession {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
userData: Dictionary;
|
|
88
|
+
errorScore: number;
|
|
89
|
+
usageCount: number;
|
|
90
|
+
maxErrorScore: number;
|
|
91
|
+
errorScoreDecrement: number;
|
|
92
|
+
expiresAt: Date;
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
maxUsageCount: number;
|
|
95
|
+
cookieJar: CookieJar;
|
|
96
|
+
proxyInfo?: ProxyInfo;
|
|
97
|
+
/**
|
|
98
|
+
* Indicates whether the session is blocked.
|
|
99
|
+
* Session is blocked once it reaches the `maxErrorScore`.
|
|
100
|
+
*/
|
|
101
|
+
isBlocked(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Indicates whether the session is expired.
|
|
104
|
+
* Session expiration is determined by the `maxAgeSecs`.
|
|
105
|
+
* Once the session is older than `createdAt + maxAgeSecs` the session is considered expired.
|
|
106
|
+
*/
|
|
107
|
+
isExpired(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Indicates whether the session is used maximum number of times.
|
|
110
|
+
* Session maximum usage count can be changed by `maxUsageCount` parameter.
|
|
111
|
+
*/
|
|
112
|
+
isMaxUsageCountReached(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Indicates whether the session can be used for next requests.
|
|
115
|
+
* Session is usable when it is not expired, not blocked and the maximum usage count has not be reached.
|
|
116
|
+
*/
|
|
117
|
+
isUsable(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* This method should be called after a successful session usage.
|
|
120
|
+
* It increases `usageCount` and potentially lowers the `errorScore` by the `errorScoreDecrement`.
|
|
121
|
+
*/
|
|
122
|
+
markGood(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Gets session state for persistence in KeyValueStore.
|
|
125
|
+
* @returns Represents session internal state.
|
|
126
|
+
*/
|
|
127
|
+
getState(): SessionState;
|
|
128
|
+
/**
|
|
129
|
+
* Marks session as blocked and emits event on the `SessionPool`
|
|
130
|
+
* This method should be used if the session usage was unsuccessful
|
|
131
|
+
* and you are sure that it is because of the session configuration and not any external matters.
|
|
132
|
+
* For example when server returns 403 status code.
|
|
133
|
+
* If the session does not work due to some external factors as server error such as 5XX you probably want to use `markBad` method.
|
|
134
|
+
*/
|
|
135
|
+
retire(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Increases usage and error count.
|
|
138
|
+
* Should be used when the session has been used unsuccessfully. For example because of timeouts.
|
|
139
|
+
*/
|
|
140
|
+
markBad(): void;
|
|
141
|
+
/**
|
|
142
|
+
* With certain status codes: `401`, `403` or `429` we can be certain
|
|
143
|
+
* that the target website is blocking us. This function helps to do this conveniently
|
|
144
|
+
* by retiring the session when such code is received. Optionally, the default status
|
|
145
|
+
* codes can be extended in the second parameter.
|
|
146
|
+
* @param statusCode HTTP status code.
|
|
147
|
+
* @returns Whether the session was retired.
|
|
148
|
+
*/
|
|
149
|
+
retireOnBlockedStatusCodes(statusCode: number): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Saves cookies from an HTTP response to be used with the session.
|
|
152
|
+
* It expects an object with a `headers` property that's either an `Object`
|
|
153
|
+
* (typical Node.js responses) or a `Function` (Puppeteer Response).
|
|
154
|
+
*
|
|
155
|
+
* It then parses and saves the cookies from the `set-cookie` header, if available.
|
|
156
|
+
*/
|
|
157
|
+
setCookiesFromResponse(response: Response): void;
|
|
158
|
+
/**
|
|
159
|
+
* Saves an array with cookie objects to be used with the session.
|
|
160
|
+
* The objects should be in the format that
|
|
161
|
+
* [Puppeteer uses](https://pptr.dev/#?product=Puppeteer&version=v2.0.0&show=api-pagecookiesurls),
|
|
162
|
+
* but you can also use this function to set cookies manually:
|
|
163
|
+
*
|
|
164
|
+
* ```
|
|
165
|
+
* [
|
|
166
|
+
* { name: 'cookie1', value: 'my-cookie' },
|
|
167
|
+
* { name: 'cookie2', value: 'your-cookie' }
|
|
168
|
+
* ]
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
setCookies(cookies: Cookie[], url: string): void;
|
|
172
|
+
/**
|
|
173
|
+
* Returns cookies in a format compatible with puppeteer/playwright and ready to be used with `page.setCookie`.
|
|
174
|
+
* @param url website url. Only cookies stored for this url will be returned
|
|
175
|
+
*/
|
|
176
|
+
getCookies(url: string): Cookie[];
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=session.d.ts.map
|
package/session.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,SAAS;IACtB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IA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AI,IAAI,CAAC;IAEhB;;;;;;;OAOG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAExD;;;;;;OAMG;IACH,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACrC"}
|
package/session.js
ADDED
package/session.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":""}
|