@crawlee/types 4.0.0-beta.105 → 4.0.0-beta.107
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 +1 -1
- package/index.d.ts +1 -0
- package/package.json +2 -3
- package/session.d.ts +1 -1
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>;
|
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-beta.
|
|
3
|
+
"version": "4.0.0-beta.107",
|
|
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": "5a3cb6242d0ae261df93c5e03cfebbb9b736e6b7"
|
|
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.
|