@crawlee/types 4.0.0-beta.99 → 4.0.0-rc.0
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/cookies.d.ts +82 -0
- package/cookies.js +1 -0
- package/http-client.d.ts +7 -1
- package/index.d.ts +1 -0
- package/package.json +2 -3
- package/session.d.ts +3 -1
- package/storages.d.ts +8 -2
package/cookies.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie shape used by {@link CookieJar}. Structurally compatible with `tough-cookie`'s
|
|
3
|
+
* `Cookie` class, so a `tough-cookie` cookie satisfies it without `@crawlee/types` depending
|
|
4
|
+
* on `tough-cookie` itself.
|
|
5
|
+
*/
|
|
6
|
+
export interface SessionCookie {
|
|
7
|
+
key: string;
|
|
8
|
+
value: string;
|
|
9
|
+
expires: Date | 'Infinity' | null;
|
|
10
|
+
maxAge: number | 'Infinity' | '-Infinity' | null;
|
|
11
|
+
domain: string | null;
|
|
12
|
+
path: string | null;
|
|
13
|
+
secure: boolean;
|
|
14
|
+
httpOnly: boolean;
|
|
15
|
+
extensions: string[] | null;
|
|
16
|
+
creation: Date | 'Infinity' | null;
|
|
17
|
+
creationIndex: number;
|
|
18
|
+
hostOnly: boolean | null;
|
|
19
|
+
pathIsDefault: boolean | null;
|
|
20
|
+
lastAccessed: Date | 'Infinity' | null;
|
|
21
|
+
sameSite: string | undefined;
|
|
22
|
+
toJSON(): Record<string, unknown>;
|
|
23
|
+
clone(): SessionCookie | undefined;
|
|
24
|
+
validate(): boolean;
|
|
25
|
+
setExpires(exp: string | Date): void;
|
|
26
|
+
setMaxAge(age: number): void;
|
|
27
|
+
cookieString(): string;
|
|
28
|
+
toString(): string;
|
|
29
|
+
TTL(now?: number): number;
|
|
30
|
+
expiryTime(now?: Date): number | undefined;
|
|
31
|
+
expiryDate(now?: Date): Date | undefined;
|
|
32
|
+
isPersistent(): boolean;
|
|
33
|
+
canonicalizedDomain(): string | undefined;
|
|
34
|
+
cdomain(): string | undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for {@link CookieJar.setCookie}. Structurally compatible with `tough-cookie`'s
|
|
38
|
+
* `SetCookieOptions`.
|
|
39
|
+
*/
|
|
40
|
+
export interface CookieJarSetCookieOptions {
|
|
41
|
+
loose?: boolean;
|
|
42
|
+
sameSiteContext?: 'strict' | 'lax' | 'none';
|
|
43
|
+
ignoreError?: boolean;
|
|
44
|
+
http?: boolean;
|
|
45
|
+
now?: Date;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for {@link CookieJar}'s cookie-reading methods. Structurally compatible with
|
|
49
|
+
* `tough-cookie`'s `GetCookiesOptions`.
|
|
50
|
+
*/
|
|
51
|
+
export interface CookieJarGetCookiesOptions {
|
|
52
|
+
http?: boolean;
|
|
53
|
+
expire?: boolean;
|
|
54
|
+
allPaths?: boolean;
|
|
55
|
+
sameSiteContext?: 'none' | 'lax' | 'strict';
|
|
56
|
+
sort?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Cookie jar contract, structurally compatible with `tough-cookie`'s `CookieJar` — which is
|
|
60
|
+
* what backs {@link Session} by default — so `@crawlee/types` does not have to depend on
|
|
61
|
+
* `tough-cookie` for it.
|
|
62
|
+
*/
|
|
63
|
+
export interface CookieJar {
|
|
64
|
+
setCookie(cookie: string | SessionCookie, url: string | URL, options?: CookieJarSetCookieOptions): Promise<SessionCookie | undefined>;
|
|
65
|
+
getCookies(url: string | URL, options?: CookieJarGetCookiesOptions): Promise<SessionCookie[]>;
|
|
66
|
+
getCookieString(url: string | URL, options?: CookieJarGetCookiesOptions): Promise<string>;
|
|
67
|
+
getSetCookieStrings(url: string | URL, options?: CookieJarGetCookiesOptions): Promise<string[] | undefined>;
|
|
68
|
+
serialize(): Promise<SerializedCookieJar>;
|
|
69
|
+
toJSON(): SerializedCookieJar | undefined;
|
|
70
|
+
clone(): Promise<CookieJar>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* JSON representation of a {@link CookieJar}. Structurally compatible with `tough-cookie`'s
|
|
74
|
+
* `SerializedCookieJar`.
|
|
75
|
+
*/
|
|
76
|
+
export interface SerializedCookieJar {
|
|
77
|
+
version: string;
|
|
78
|
+
storeType: string | null;
|
|
79
|
+
rejectPublicSuffixes: boolean;
|
|
80
|
+
cookies: Record<string, unknown>[];
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
package/cookies.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/http-client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { CookieJar } from '
|
|
2
|
+
import type { CookieJar } from './cookies.js';
|
|
3
3
|
import type { ISession } from './session.js';
|
|
4
4
|
import type { AllowedHttpMethods } from './utility-types.js';
|
|
5
5
|
export type SearchParams = string | URLSearchParams | Record<string, string | number | boolean | null | undefined>;
|
|
@@ -62,6 +62,12 @@ export interface SendRequestOptions {
|
|
|
62
62
|
* Note that setting this manually can interfere with session proxy rotation.
|
|
63
63
|
*/
|
|
64
64
|
proxyUrl?: string;
|
|
65
|
+
/**
|
|
66
|
+
* When `true`, TLS certificate errors are ignored for this request. Also enabled by
|
|
67
|
+
* `session.proxyInfo.ignoreTlsErrors` (MITM proxies). Best-effort: clients that cannot
|
|
68
|
+
* disable TLS verification (e.g. the native fetch fallback) ignore it.
|
|
69
|
+
*/
|
|
70
|
+
ignoreTlsErrors?: boolean;
|
|
65
71
|
}
|
|
66
72
|
export interface StreamOptions extends SendRequestOptions {
|
|
67
73
|
onRedirect?: RedirectHandler;
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type * from './status-message.js';
|
|
|
2
2
|
export type * from './storages.js';
|
|
3
3
|
export type * from './utility-types.js';
|
|
4
4
|
export type * from './browser.js';
|
|
5
|
+
export type * from './cookies.js';
|
|
5
6
|
export type * from './http-client.js';
|
|
6
7
|
export type * from './session.js';
|
|
7
8
|
export type * from './logger.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/types",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
4
4
|
"description": "Shared types for the crawlee projects",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"tough-cookie": "^6.0.0",
|
|
47
46
|
"tslib": "^2.8.1"
|
|
48
47
|
},
|
|
49
48
|
"lerna": {
|
|
@@ -53,5 +52,5 @@
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "79ab33dacdacb83e0197e6516d145f3aceef80c7"
|
|
57
56
|
}
|
package/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CookieJar, SerializedCookieJar } from '
|
|
1
|
+
import type { CookieJar, SerializedCookieJar } from './cookies.js';
|
|
2
2
|
/**
|
|
3
3
|
* The main purpose of the ProxyInfo object is to provide information
|
|
4
4
|
* about the current proxy connection used by the crawler for the request.
|
|
@@ -49,6 +49,8 @@ export interface ProxyInfo {
|
|
|
49
49
|
port: number | string;
|
|
50
50
|
/**
|
|
51
51
|
* When `true`, the proxy is likely intercepting HTTPS traffic and is able to view and modify its content.
|
|
52
|
+
* The built-in HTTP clients and the browser pool disable TLS certificate verification for the session's
|
|
53
|
+
* requests when this is set.
|
|
52
54
|
*
|
|
53
55
|
* @default false
|
|
54
56
|
*/
|
package/storages.d.ts
CHANGED
|
@@ -334,10 +334,12 @@ export interface RequestQueueBackend {
|
|
|
334
334
|
* Identifies a storage by its ID, name, or alias. At most one may be provided.
|
|
335
335
|
*
|
|
336
336
|
* - `{ id }` — open a pre-existing storage by its unique ID.
|
|
337
|
-
* - `{ name }` — open or create a globally named storage (persists across runs).
|
|
337
|
+
* - `{ name }` — open or create a globally named storage (persists across runs). The name `default`
|
|
338
|
+
* is reserved: it resolves to the default storage, and is emptied on start along with it.
|
|
338
339
|
* - `{ alias }` — open or create a run-scoped unnamed storage identified by this alias.
|
|
339
340
|
* The alias is used locally (e.g. as a directory name or cache key) but the storage
|
|
340
|
-
* itself has no persistent name. Use this for non-default unnamed storages.
|
|
341
|
+
* itself has no persistent name. Use this for non-default unnamed storages. Like the
|
|
342
|
+
* default storage, an aliased one is emptied on start unless `purgeOnStart` is disabled.
|
|
341
343
|
* - `{}` / omitted — open the default storage.
|
|
342
344
|
*/
|
|
343
345
|
export type StorageIdentifier = {
|
|
@@ -409,6 +411,10 @@ export interface StorageBackend {
|
|
|
409
411
|
* `StorageBackend` implementations automatically get separate cache partitions.
|
|
410
412
|
*/
|
|
411
413
|
getStorageBackendCacheKey?(): string;
|
|
414
|
+
/**
|
|
415
|
+
* 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, as does the default store's `INPUT`.
|
|
417
|
+
*/
|
|
412
418
|
purge?(): Promise<void>;
|
|
413
419
|
teardown?(): Promise<void>;
|
|
414
420
|
stats?: {
|