@crawlee/types 4.0.0-rc.0 → 4.0.0-rc.1
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/README.md +1 -1
- package/browser.d.ts +6 -11
- package/http-client.d.ts +0 -19
- package/logger.d.ts +14 -7
- package/package.json +3 -3
- package/session.d.ts +6 -0
- package/storages.d.ts +18 -2
- package/utility-types.d.ts +0 -2
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) N
|
|
|
34
34
|
|
|
35
35
|
We recommend visiting the [Introduction tutorial](https://crawlee.dev/js/docs/introduction) in Crawlee documentation for more information.
|
|
36
36
|
|
|
37
|
-
> Crawlee requires **Node.js
|
|
37
|
+
> Crawlee requires **Node.js 22.13 or higher**.
|
|
38
38
|
|
|
39
39
|
### With Crawlee CLI
|
|
40
40
|
|
package/browser.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ISession } from './session.js';
|
|
2
|
-
import type { Dictionary } from './utility-types.js';
|
|
3
2
|
export interface Cookie {
|
|
4
3
|
/**
|
|
5
4
|
* Cookie name.
|
|
@@ -57,10 +56,6 @@ export interface Cookie {
|
|
|
57
56
|
*/
|
|
58
57
|
sourcePort?: number;
|
|
59
58
|
}
|
|
60
|
-
export interface BrowserLikeResponse {
|
|
61
|
-
url(): string;
|
|
62
|
-
headers(): Dictionary<string | string[]>;
|
|
63
|
-
}
|
|
64
59
|
/**
|
|
65
60
|
* A snapshot of the relevant state of a page, as extracted by
|
|
66
61
|
* {@link IBrowserPool.extractPageState}.
|
|
@@ -125,14 +120,14 @@ export interface IBrowserPool<Page = unknown> {
|
|
|
125
120
|
/**
|
|
126
121
|
* Signals the pool that the caller is done with the page. The pool is
|
|
127
122
|
* responsible for closing the page and performing any necessary cleanup
|
|
128
|
-
* (e.g. retiring the underlying browser
|
|
123
|
+
* (e.g. retiring the underlying browser once the page's session is finished).
|
|
129
124
|
*
|
|
130
125
|
* @param page The page to release back to the pool.
|
|
131
|
-
* @param options.error If the
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
126
|
+
* @param options.error If the error is a {@link SessionError}, the
|
|
127
|
+
* session that served the page is finished. A plain `SessionError`
|
|
128
|
+
* means it was blocked: discard any browser state tied to it. A
|
|
129
|
+
* {@link SessionRetiredError} means it merely reached its usage or
|
|
130
|
+
* age limit, so a pool may keep a warm page instead.
|
|
136
131
|
*/
|
|
137
132
|
closePage(page: Page, options?: {
|
|
138
133
|
error?: Error;
|
package/http-client.d.ts
CHANGED
|
@@ -15,17 +15,8 @@ export interface HttpRequest {
|
|
|
15
15
|
timeout?: number;
|
|
16
16
|
cookieJar?: CookieJar;
|
|
17
17
|
followRedirect?: boolean | ((response: any) => boolean);
|
|
18
|
-
maxRedirects?: number;
|
|
19
18
|
encoding?: BufferEncoding;
|
|
20
|
-
throwHttpErrors?: boolean;
|
|
21
19
|
proxyUrl?: string;
|
|
22
|
-
headerGeneratorOptions?: Record<string, unknown>;
|
|
23
|
-
useHeaderGenerator?: boolean;
|
|
24
|
-
headerGenerator?: {
|
|
25
|
-
getHeaders: (options: Record<string, unknown>) => Record<string, string>;
|
|
26
|
-
};
|
|
27
|
-
insecureHTTPParser?: boolean;
|
|
28
|
-
sessionToken?: object;
|
|
29
20
|
}
|
|
30
21
|
/**
|
|
31
22
|
* Additional options for HTTP requests that need to be handled separately before passing to {@link BaseHttpClient}.
|
|
@@ -42,13 +33,6 @@ export interface HttpRequestOptions extends HttpRequest {
|
|
|
42
33
|
/** Basic HTTP Auth password */
|
|
43
34
|
password?: string;
|
|
44
35
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Type of a function called when an HTTP redirect takes place. It is allowed to mutate the `updatedRequest` argument.
|
|
47
|
-
*/
|
|
48
|
-
export type RedirectHandler = (redirectResponse: Response, updatedRequest: {
|
|
49
|
-
url?: string | URL;
|
|
50
|
-
headers: Headers;
|
|
51
|
-
}) => void;
|
|
52
36
|
export interface SendRequestOptions {
|
|
53
37
|
session?: ISession;
|
|
54
38
|
cookieJar?: CookieJar;
|
|
@@ -69,9 +53,6 @@ export interface SendRequestOptions {
|
|
|
69
53
|
*/
|
|
70
54
|
ignoreTlsErrors?: boolean;
|
|
71
55
|
}
|
|
72
|
-
export interface StreamOptions extends SendRequestOptions {
|
|
73
|
-
onRedirect?: RedirectHandler;
|
|
74
|
-
}
|
|
75
56
|
/**
|
|
76
57
|
* Interface for user-defined HTTP clients to be used for plain HTTP crawling and for sending additional requests during a crawl.
|
|
77
58
|
*/
|
package/logger.d.ts
CHANGED
|
@@ -5,6 +5,13 @@ export interface CrawleeLoggerOptions {
|
|
|
5
5
|
/** Prefix to be prepended to each logged line. */
|
|
6
6
|
prefix?: string | null;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for a single log call.
|
|
10
|
+
*/
|
|
11
|
+
export interface LogOptions {
|
|
12
|
+
/** Log the message only the first time this logger sees that text, ignoring later calls with it. */
|
|
13
|
+
once?: boolean;
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* Interface for Crawlee logger implementations.
|
|
10
17
|
* This allows users to inject custom loggers (e.g., Winston, Pino) while maintaining
|
|
@@ -26,7 +33,7 @@ export interface CrawleeLogger {
|
|
|
26
33
|
/**
|
|
27
34
|
* Logs an `ERROR` message.
|
|
28
35
|
*/
|
|
29
|
-
error(message: string, data?: Record<string, unknown
|
|
36
|
+
error(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
30
37
|
/**
|
|
31
38
|
* Logs an `ERROR` level message with a nicely formatted exception.
|
|
32
39
|
*/
|
|
@@ -34,27 +41,27 @@ export interface CrawleeLogger {
|
|
|
34
41
|
/**
|
|
35
42
|
* Logs a `SOFT_FAIL` level message.
|
|
36
43
|
*/
|
|
37
|
-
softFail(message: string, data?: Record<string, unknown
|
|
44
|
+
softFail(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
38
45
|
/**
|
|
39
46
|
* Logs a `WARNING` level message.
|
|
40
47
|
*/
|
|
41
|
-
warning(message: string, data?: Record<string, unknown
|
|
48
|
+
warning(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
42
49
|
/**
|
|
43
|
-
* Logs a `WARNING` level message only once.
|
|
50
|
+
* Logs a `WARNING` level message only once. Shorthand for `warning(message, undefined, { once: true })`.
|
|
44
51
|
*/
|
|
45
52
|
warningOnce(message: string): void;
|
|
46
53
|
/**
|
|
47
54
|
* Logs an `INFO` message.
|
|
48
55
|
*/
|
|
49
|
-
info(message: string, data?: Record<string, unknown
|
|
56
|
+
info(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
50
57
|
/**
|
|
51
58
|
* Logs a `DEBUG` message.
|
|
52
59
|
*/
|
|
53
|
-
debug(message: string, data?: Record<string, unknown
|
|
60
|
+
debug(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
54
61
|
/**
|
|
55
62
|
* Logs a `PERF` level message for performance tracking.
|
|
56
63
|
*/
|
|
57
|
-
perf(message: string, data?: Record<string, unknown
|
|
64
|
+
perf(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
58
65
|
/**
|
|
59
66
|
* Logs given message only once as WARNING for deprecated features.
|
|
60
67
|
*/
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/types",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "Shared types for the crawlee projects",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=22.
|
|
6
|
+
"node": ">=22.13.0"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "f354ca5e943bed1a5c657a1fce1974c053f9fff0"
|
|
56
56
|
}
|
package/session.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export interface SessionFingerprint {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Persistable {@link Session} state.
|
|
78
|
+
* @internal
|
|
78
79
|
*/
|
|
79
80
|
export interface SessionState {
|
|
80
81
|
id: string;
|
|
@@ -107,6 +108,11 @@ export interface ISession {
|
|
|
107
108
|
* Session is usable when it is not expired, not blocked and the maximum usage count has not been reached.
|
|
108
109
|
*/
|
|
109
110
|
isUsable(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Indicates whether the session is blocked, i.e. its error score reached the maximum or it was retired via `retire()`.
|
|
113
|
+
* Unlike other reasons for not being usable, this means the identity itself is burned.
|
|
114
|
+
*/
|
|
115
|
+
isBlocked(): boolean;
|
|
110
116
|
/**
|
|
111
117
|
* This method should be called after a successful session usage.
|
|
112
118
|
*/
|
package/storages.d.ts
CHANGED
|
@@ -174,7 +174,14 @@ export interface KeyValueStoreBackend {
|
|
|
174
174
|
* instead of inferring the end from `items.length < limit`.
|
|
175
175
|
*/
|
|
176
176
|
listKeys(options?: KeyValueStoreListKeysOptions): Promise<KeyValueStoreListKeysResult>;
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Get the public URL a record with this key has, or `undefined` if the backend exposes no public
|
|
179
|
+
* URLs at all.
|
|
180
|
+
*
|
|
181
|
+
* The URL is derived from the key; implementations MUST NOT check that the record exists. Callers
|
|
182
|
+
* legitimately ask for the URL of a record that is not on the backend yet — most notably one
|
|
183
|
+
* buffered in an uncommitted storage transaction — and existence is `recordExists`'s job.
|
|
184
|
+
*/
|
|
178
185
|
getPublicUrl(key: string): Promise<string | undefined>;
|
|
179
186
|
/** Check whether a record with the given key exists. */
|
|
180
187
|
recordExists(key: string): Promise<boolean>;
|
|
@@ -329,6 +336,15 @@ export interface RequestQueueBackend {
|
|
|
329
336
|
* still being processed. Clients that do not lock may ignore it.
|
|
330
337
|
*/
|
|
331
338
|
setExpectedRequestProcessingTimeSecs?(secs: number): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Extends the lock on a request previously handed out by {@link fetchNextRequest}, for a consumer
|
|
341
|
+
* that needs more time than the sizing hint reserved.
|
|
342
|
+
*
|
|
343
|
+
* @returns `true` when prolonged, `false` when this client does not hold the request locked (or
|
|
344
|
+
* does not lock at all). `false` is information, not an error: the request may be processed twice.
|
|
345
|
+
* Non-locking backends leave this unimplemented.
|
|
346
|
+
*/
|
|
347
|
+
extendRequestProcessingTimeSecs?(requestId: string, secs: number): Promise<boolean>;
|
|
332
348
|
}
|
|
333
349
|
/**
|
|
334
350
|
* Identifies a storage by its ID, name, or alias. At most one may be provided.
|
|
@@ -413,7 +429,7 @@ export interface StorageBackend {
|
|
|
413
429
|
getStorageBackendCacheKey?(): string;
|
|
414
430
|
/**
|
|
415
431
|
* Empty the run-scoped storages — the default one and every alias-keyed one, including any left
|
|
416
|
-
* behind by a previous run. Named storages persist across runs
|
|
432
|
+
* behind by a previous run. Named storages persist across runs.
|
|
417
433
|
*/
|
|
418
434
|
purge?(): Promise<void>;
|
|
419
435
|
teardown?(): Promise<void>;
|
package/utility-types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export type Dictionary<T = any> = Record<PropertyKey, T>;
|
|
2
|
-
/** @ignore */
|
|
3
2
|
export type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
4
|
-
/** @ignore */
|
|
5
3
|
export type Awaitable<T> = T | PromiseLike<T>;
|
|
6
4
|
export type AllowedHttpMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'CONNECT' | 'PATCH' | 'get' | 'head' | 'post' | 'put' | 'delete' | 'trace' | 'options' | 'connect' | 'patch';
|