@crawlee/basic 4.0.0-beta.23 → 4.0.0-beta.230

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.
Files changed (86) hide show
  1. package/README.md +15 -15
  2. package/index.d.ts +11 -2
  3. package/index.js +11 -1
  4. package/internals/autoscaling/autoscaled-pool.d.ts +176 -0
  5. package/internals/autoscaling/autoscaled-pool.js +387 -0
  6. package/internals/autoscaling/concurrency-system.d.ts +235 -0
  7. package/internals/autoscaling/concurrency-system.js +357 -0
  8. package/internals/autoscaling/cpu-load-signal.d.ts +43 -0
  9. package/internals/autoscaling/cpu-load-signal.js +46 -0
  10. package/internals/autoscaling/event-loop-load-signal.d.ts +51 -0
  11. package/internals/autoscaling/event-loop-load-signal.js +60 -0
  12. package/internals/autoscaling/index.d.ts +9 -0
  13. package/internals/autoscaling/index.js +9 -0
  14. package/internals/autoscaling/load-signal.d.ts +98 -0
  15. package/internals/autoscaling/load-signal.js +103 -0
  16. package/internals/autoscaling/memory-load-signal.d.ts +45 -0
  17. package/internals/autoscaling/memory-load-signal.js +104 -0
  18. package/internals/autoscaling/snapshotter.d.ts +84 -0
  19. package/internals/autoscaling/snapshotter.js +67 -0
  20. package/internals/autoscaling/storage-backend-load-signal.d.ts +56 -0
  21. package/internals/autoscaling/storage-backend-load-signal.js +73 -0
  22. package/internals/autoscaling/system-status.d.ts +112 -0
  23. package/internals/autoscaling/system-status.js +139 -0
  24. package/internals/autoscaling/weighted-avg.d.ts +5 -0
  25. package/internals/autoscaling/weighted-avg.js +14 -0
  26. package/internals/basic-crawler.d.ts +378 -369
  27. package/internals/basic-crawler.js +1449 -863
  28. package/internals/cookie-utils.d.ts +40 -0
  29. package/internals/cookie-utils.js +122 -0
  30. package/internals/crawler-run.d.ts +76 -0
  31. package/internals/crawler-run.js +142 -0
  32. package/internals/crawlers/context-pipeline.d.ts +75 -0
  33. package/internals/crawlers/context-pipeline.js +109 -0
  34. package/internals/crawlers/crawler-commons.d.ts +216 -0
  35. package/internals/crawlers/crawler-commons.js +1 -0
  36. package/internals/crawlers/error-snapshotter.d.ts +29 -0
  37. package/internals/crawlers/error-snapshotter.js +116 -0
  38. package/internals/crawlers/error-tracker.d.ts +51 -0
  39. package/internals/crawlers/error-tracker.js +316 -0
  40. package/internals/crawlers/index.d.ts +4 -0
  41. package/internals/crawlers/index.js +3 -0
  42. package/internals/crawlers/internals/types.d.ts +7 -0
  43. package/internals/crawlers/internals/types.js +1 -0
  44. package/internals/crawlers/statistics.d.ts +316 -0
  45. package/internals/crawlers/statistics.js +525 -0
  46. package/internals/crawling-request.d.ts +86 -0
  47. package/internals/crawling-request.js +127 -0
  48. package/internals/enqueue-links/enqueue-links.d.ts +152 -0
  49. package/internals/enqueue-links/enqueue-links.js +76 -0
  50. package/internals/enqueue-links/index.d.ts +3 -0
  51. package/internals/enqueue-links/index.js +3 -0
  52. package/internals/enqueue-links/shared.d.ts +106 -0
  53. package/internals/enqueue-links/shared.js +258 -0
  54. package/internals/errors.d.ts +68 -0
  55. package/internals/errors.js +83 -0
  56. package/internals/http.d.ts +9 -0
  57. package/internals/http.js +28 -0
  58. package/internals/request-timeout.d.ts +54 -0
  59. package/internals/request-timeout.js +98 -0
  60. package/internals/router.d.ts +299 -0
  61. package/internals/router.js +312 -0
  62. package/internals/send-request.d.ts +4 -4
  63. package/internals/send-request.js +4 -3
  64. package/internals/session-pool/consts.d.ts +1 -0
  65. package/internals/session-pool/consts.js +1 -0
  66. package/internals/session-pool/errors.d.ts +7 -0
  67. package/internals/session-pool/errors.js +11 -0
  68. package/internals/session-pool/fingerprint.d.ts +9 -0
  69. package/internals/session-pool/fingerprint.js +30 -0
  70. package/internals/session-pool/index.d.ts +4 -0
  71. package/internals/session-pool/index.js +4 -0
  72. package/internals/session-pool/session-pool.d.ts +193 -0
  73. package/internals/session-pool/session-pool.js +453 -0
  74. package/internals/session-pool/session.d.ts +151 -0
  75. package/internals/session-pool/session.js +225 -0
  76. package/internals/sitemap-request-loader.d.ts +158 -0
  77. package/internals/sitemap-request-loader.js +432 -0
  78. package/internals/throttling-request-manager.d.ts +229 -0
  79. package/internals/throttling-request-manager.js +843 -0
  80. package/package.json +20 -14
  81. package/index.d.ts.map +0 -1
  82. package/index.js.map +0 -1
  83. package/internals/basic-crawler.d.ts.map +0 -1
  84. package/internals/basic-crawler.js.map +0 -1
  85. package/internals/send-request.d.ts.map +0 -1
  86. package/internals/send-request.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ import type { CrawleeLogger } from '@crawlee/core';
2
+ import type { Dictionary, ISession, ProxyInfo, SessionFingerprint, SessionState } from '@crawlee/types';
3
+ import { CookieJar } from 'tough-cookie';
4
+ export interface SessionOptions {
5
+ /** Id of session used for generating fingerprints. It is used as proxy session name. */
6
+ id?: string;
7
+ /**
8
+ * Number of seconds after which the session is considered as expired.
9
+ * @default 3000
10
+ */
11
+ maxAgeSecs?: number;
12
+ /** Object where custom user data can be stored. For example custom headers. */
13
+ userData?: Dictionary;
14
+ /**
15
+ * Maximum number of marking session as blocked usage.
16
+ * If the `errorScore` reaches the `maxErrorScore` session is marked as block and it is thrown away.
17
+ * It starts at 0. Calling the `markBad` function increases the `errorScore` by 1.
18
+ * Calling the `markGood` will decrease the `errorScore` by `errorScoreDecrement`
19
+ * @default 3
20
+ */
21
+ maxErrorScore?: number;
22
+ /**
23
+ * It is used for healing the session.
24
+ * For example: if your session is marked bad two times, but it is successful on the third attempt it's errorScore
25
+ * is decremented by this number.
26
+ * @default 0.5
27
+ */
28
+ errorScoreDecrement?: number;
29
+ /** Date of creation. */
30
+ createdAt?: Date;
31
+ /**
32
+ * Date of expiration.
33
+ * @default createdAt + maxAgeSecs
34
+ */
35
+ expiresAt?: Date;
36
+ /**
37
+ * Indicates how many times the session has been used.
38
+ * @default 0
39
+ */
40
+ usageCount?: number;
41
+ /**
42
+ * Session should be used only a limited amount of times.
43
+ * This number indicates how many times the session is going to be used, before it is thrown away.
44
+ * @default 50
45
+ */
46
+ maxUsageCount?: number;
47
+ /**
48
+ * Marks the session as already retired. Used when restoring a previously persisted session
49
+ * so that `isUsable()` reflects the terminal state regardless of error score or usage count.
50
+ * @default false
51
+ */
52
+ retired?: boolean;
53
+ /** @internal */
54
+ log?: CrawleeLogger;
55
+ errorScore?: number;
56
+ cookieJar?: CookieJar;
57
+ proxyInfo?: ProxyInfo;
58
+ /**
59
+ * Browser / HTTP client fingerprint tied to this session. Backends use this to make
60
+ * repeated requests with the same session look consistent (same user-agent, headers,
61
+ * TLS profile). See {@link SessionFingerprint}.
62
+ */
63
+ fingerprint?: SessionFingerprint;
64
+ }
65
+ /**
66
+ * Sessions are used to store information such as cookies and can be used for generating fingerprints and proxy sessions.
67
+ * You can imagine each session as a specific user, with its own cookies, IP (via proxy) and potentially a unique browser fingerprint.
68
+ * Session internal state can be enriched with custom user data for example some authorization tokens and specific headers in general.
69
+ * @category Scaling
70
+ */
71
+ export declare class Session implements ISession {
72
+ #private;
73
+ readonly id: string;
74
+ readonly userData: Dictionary;
75
+ get errorScore(): number;
76
+ get usageCount(): number;
77
+ get maxErrorScore(): number;
78
+ get errorScoreDecrement(): number;
79
+ get expiresAt(): Date;
80
+ get createdAt(): Date;
81
+ get maxUsageCount(): number;
82
+ get cookieJar(): CookieJar;
83
+ get proxyInfo(): ProxyInfo | undefined;
84
+ get fingerprint(): SessionFingerprint | undefined;
85
+ set fingerprint(fingerprint: SessionFingerprint | undefined);
86
+ /**
87
+ * `true` once {@link Session.retire|`retire()`} has been called. Retirement is terminal:
88
+ * a retired session is never picked by the pool and cannot be revived via `markGood()`.
89
+ */
90
+ get retired(): boolean;
91
+ /**
92
+ * Session configuration.
93
+ */
94
+ constructor(options?: SessionOptions);
95
+ /**
96
+ * Indicates whether the session is blocked.
97
+ * Session is blocked once it reaches the `maxErrorScore`.
98
+ */
99
+ isBlocked(): boolean;
100
+ /**
101
+ * Indicates whether the session is expired.
102
+ * Session expiration is determined by the `maxAgeSecs`.
103
+ * Once the session is older than `createdAt + maxAgeSecs` the session is considered expired.
104
+ */
105
+ isExpired(): boolean;
106
+ /**
107
+ * Indicates whether the session is used maximum number of times.
108
+ * Session maximum usage count can be changed by `maxUsageCount` parameter.
109
+ */
110
+ isMaxUsageCountReached(): boolean;
111
+ /**
112
+ * Indicates whether the session can be used for next requests.
113
+ * Session is usable when it is not retired, not expired, not blocked and the maximum usage count has not be reached.
114
+ */
115
+ isUsable(): boolean;
116
+ /**
117
+ * This method should be called after a successful session usage.
118
+ * It increases `usageCount` and potentially lowers the `errorScore` by the `errorScoreDecrement`.
119
+ */
120
+ markGood(): void;
121
+ /**
122
+ * Gets session state for persistence in KeyValueStore.
123
+ *
124
+ * @internal
125
+ */
126
+ getState(): SessionState;
127
+ /**
128
+ * Permanently retires the session — `isUsable()` will return `false` from here on,
129
+ * and no `markGood()` / `markBad()` can revive it. Calling `retire()` again is a no-op.
130
+ *
131
+ * Use this when you're confident the session itself is the problem (e.g. a `403` response).
132
+ * For transient external failures (such as `5XX` responses), use `markBad()` instead.
133
+ */
134
+ retire(): void;
135
+ /**
136
+ * Increases usage and error count.
137
+ * Should be used when the session has been used unsuccessfully. For example because of timeouts.
138
+ */
139
+ markBad(): void;
140
+ /**
141
+ * Returns cookies saved with the session in the typical
142
+ * key1=value1; key2=value2 format, ready to be used in
143
+ * a cookie header or elsewhere.
144
+ * @returns Represents `Cookie` header.
145
+ */
146
+ getCookieString(url: string): Promise<string>;
147
+ /**
148
+ * Sets a cookie within this session for the specific URL.
149
+ */
150
+ setCookie(rawCookie: string, url: string): Promise<void>;
151
+ }
@@ -0,0 +1,225 @@
1
+ import { serviceLocator, validators } from '@crawlee/core';
2
+ import { parseArgument, schemas } from '@crawlee/utils/internal';
3
+ import { CookieJar } from 'tough-cookie';
4
+ import { z } from 'zod';
5
+ import { cryptoRandomObjectId } from '@apify/utilities';
6
+ // `schemas.anyObject` passes values through by reference (object schemas return a pruned plain
7
+ // copy), so class instances like cookie jars and loggers keep their prototype.
8
+ const sessionOptionsSchema = z.strictObject({
9
+ id: z.string().default(() => `session_${cryptoRandomObjectId(10)}`),
10
+ cookieJar: schemas.anyObject.default(() => new CookieJar()),
11
+ proxyInfo: schemas.anyObject.optional(),
12
+ maxAgeSecs: schemas.anyNumber.default(3000),
13
+ userData: schemas.anyObject.default(() => ({})),
14
+ maxErrorScore: schemas.anyNumber.default(3),
15
+ errorScoreDecrement: schemas.anyNumber.default(0.5),
16
+ createdAt: z.date().default(() => new Date()),
17
+ expiresAt: z.date().optional(),
18
+ usageCount: schemas.anyNumber.default(0),
19
+ errorScore: schemas.anyNumber.default(0),
20
+ maxUsageCount: schemas.anyNumber.default(50),
21
+ retired: z.boolean().default(false),
22
+ log: validators.logger.default(() => serviceLocator.getLogger()),
23
+ fingerprint: schemas.anyObject.optional(),
24
+ });
25
+ /**
26
+ * Sessions are used to store information such as cookies and can be used for generating fingerprints and proxy sessions.
27
+ * You can imagine each session as a specific user, with its own cookies, IP (via proxy) and potentially a unique browser fingerprint.
28
+ * Session internal state can be enriched with custom user data for example some authorization tokens and specific headers in general.
29
+ * @category Scaling
30
+ */
31
+ export class Session {
32
+ id;
33
+ userData;
34
+ #maxErrorScore;
35
+ #errorScoreDecrement;
36
+ #createdAt;
37
+ #expiresAt;
38
+ #usageCount;
39
+ #maxUsageCount;
40
+ #errorScore;
41
+ #retired = false;
42
+ #proxyInfo;
43
+ #cookieJar;
44
+ #fingerprint;
45
+ #log;
46
+ get errorScore() {
47
+ return this.#errorScore;
48
+ }
49
+ get usageCount() {
50
+ return this.#usageCount;
51
+ }
52
+ get maxErrorScore() {
53
+ return this.#maxErrorScore;
54
+ }
55
+ get errorScoreDecrement() {
56
+ return this.#errorScoreDecrement;
57
+ }
58
+ get expiresAt() {
59
+ return this.#expiresAt;
60
+ }
61
+ get createdAt() {
62
+ return this.#createdAt;
63
+ }
64
+ get maxUsageCount() {
65
+ return this.#maxUsageCount;
66
+ }
67
+ get cookieJar() {
68
+ return this.#cookieJar;
69
+ }
70
+ get proxyInfo() {
71
+ return this.#proxyInfo;
72
+ }
73
+ get fingerprint() {
74
+ return this.#fingerprint;
75
+ }
76
+ set fingerprint(fingerprint) {
77
+ this.#fingerprint = fingerprint;
78
+ }
79
+ /**
80
+ * `true` once {@link Session.retire|`retire()`} has been called. Retirement is terminal:
81
+ * a retired session is never picked by the pool and cannot be revived via `markGood()`.
82
+ */
83
+ get retired() {
84
+ return this.#retired;
85
+ }
86
+ /**
87
+ * Session configuration.
88
+ */
89
+ constructor(options = {}) {
90
+ const { id, cookieJar, proxyInfo, maxAgeSecs, userData, maxErrorScore, errorScoreDecrement, createdAt, usageCount, errorScore, maxUsageCount, retired, log, fingerprint,
91
+ // Anchored to `createdAt` rather than to "now", so the documented `createdAt + maxAgeSecs` holds.
92
+ expiresAt = new Date(createdAt.getTime() + maxAgeSecs * 1000), } = parseArgument(options, sessionOptionsSchema);
93
+ this.#log = log.child({ prefix: 'Session' });
94
+ this.#cookieJar = cookieJar.setCookie ? cookieJar : CookieJar.fromJSON(JSON.stringify(cookieJar));
95
+ this.#proxyInfo = proxyInfo;
96
+ this.#fingerprint = fingerprint;
97
+ this.id = id;
98
+ this.userData = userData;
99
+ this.#maxErrorScore = maxErrorScore;
100
+ this.#errorScoreDecrement = errorScoreDecrement;
101
+ // Internal
102
+ this.#expiresAt = expiresAt;
103
+ this.#createdAt = createdAt;
104
+ this.#usageCount = usageCount; // indicates how many times the session has been used
105
+ this.#errorScore = errorScore; // indicates number of markBaded request with the session
106
+ this.#maxUsageCount = maxUsageCount;
107
+ this.#retired = retired;
108
+ }
109
+ /**
110
+ * Indicates whether the session is blocked.
111
+ * Session is blocked once it reaches the `maxErrorScore`.
112
+ */
113
+ isBlocked() {
114
+ return this.errorScore >= this.maxErrorScore;
115
+ }
116
+ /**
117
+ * Indicates whether the session is expired.
118
+ * Session expiration is determined by the `maxAgeSecs`.
119
+ * Once the session is older than `createdAt + maxAgeSecs` the session is considered expired.
120
+ */
121
+ isExpired() {
122
+ return this.expiresAt <= new Date();
123
+ }
124
+ /**
125
+ * Indicates whether the session is used maximum number of times.
126
+ * Session maximum usage count can be changed by `maxUsageCount` parameter.
127
+ */
128
+ isMaxUsageCountReached() {
129
+ return this.usageCount >= this.maxUsageCount;
130
+ }
131
+ /**
132
+ * Indicates whether the session can be used for next requests.
133
+ * Session is usable when it is not retired, not expired, not blocked and the maximum usage count has not be reached.
134
+ */
135
+ isUsable() {
136
+ return !this.#retired && !this.isBlocked() && !this.isExpired() && !this.isMaxUsageCountReached();
137
+ }
138
+ /**
139
+ * This method should be called after a successful session usage.
140
+ * It increases `usageCount` and potentially lowers the `errorScore` by the `errorScoreDecrement`.
141
+ */
142
+ markGood() {
143
+ if (this.#retired)
144
+ return;
145
+ this.#usageCount += 1;
146
+ if (this.#errorScore > 0) {
147
+ this.#errorScore -= this.#errorScoreDecrement;
148
+ }
149
+ this.#maybeSelfRetire();
150
+ }
151
+ /**
152
+ * Gets session state for persistence in KeyValueStore.
153
+ *
154
+ * @internal
155
+ */
156
+ getState() {
157
+ return {
158
+ id: this.id,
159
+ cookieJar: this.cookieJar.toJSON(),
160
+ proxyInfo: this.#proxyInfo,
161
+ userData: this.userData,
162
+ fingerprint: this.#fingerprint,
163
+ maxErrorScore: this.maxErrorScore,
164
+ errorScoreDecrement: this.errorScoreDecrement,
165
+ expiresAt: this.expiresAt.toISOString(),
166
+ createdAt: this.createdAt.toISOString(),
167
+ usageCount: this.usageCount,
168
+ maxUsageCount: this.maxUsageCount,
169
+ errorScore: this.errorScore,
170
+ retired: this.#retired,
171
+ };
172
+ }
173
+ /**
174
+ * Permanently retires the session — `isUsable()` will return `false` from here on,
175
+ * and no `markGood()` / `markBad()` can revive it. Calling `retire()` again is a no-op.
176
+ *
177
+ * Use this when you're confident the session itself is the problem (e.g. a `403` response).
178
+ * For transient external failures (such as `5XX` responses), use `markBad()` instead.
179
+ */
180
+ retire() {
181
+ if (this.#retired && this.isBlocked())
182
+ return;
183
+ this.#errorScore += this.#maxErrorScore;
184
+ this.#usageCount += 1;
185
+ this.#retired = true;
186
+ }
187
+ /**
188
+ * Increases usage and error count.
189
+ * Should be used when the session has been used unsuccessfully. For example because of timeouts.
190
+ */
191
+ markBad() {
192
+ this.#errorScore += 1;
193
+ this.#usageCount += 1;
194
+ this.#maybeSelfRetire();
195
+ }
196
+ /**
197
+ * Returns cookies saved with the session in the typical
198
+ * key1=value1; key2=value2 format, ready to be used in
199
+ * a cookie header or elsewhere.
200
+ * @returns Represents `Cookie` header.
201
+ */
202
+ async getCookieString(url) {
203
+ return this.cookieJar.getCookieString(url, {});
204
+ }
205
+ /**
206
+ * Sets a cookie within this session for the specific URL.
207
+ */
208
+ async setCookie(rawCookie, url) {
209
+ try {
210
+ await this.cookieJar.setCookie(rawCookie, url);
211
+ }
212
+ catch (e) {
213
+ this.#log.warning('Could not set cookie.', { url, error: e.message });
214
+ }
215
+ }
216
+ /**
217
+ * Makes an unusable session's state terminal. Unlike `retire()`, this leaves the error score alone so that
218
+ * `isBlocked()` keeps telling a burned identity from one that merely ran out of uses.
219
+ */
220
+ #maybeSelfRetire() {
221
+ if (!this.isUsable()) {
222
+ this.#retired = true;
223
+ }
224
+ }
225
+ }
@@ -0,0 +1,158 @@
1
+ import type { BaseHttpClient } from '@crawlee/http-client';
2
+ import type { ParseSitemapOptions } from '@crawlee/utils';
3
+ import { EnqueueStrategy } from '@crawlee/utils';
4
+ import type { IRequestLoader, IRequestManager, RequestLoaderStatus } from '@crawlee/core';
5
+ import { Request } from '@crawlee/core';
6
+ import type { UrlPatternInput } from './enqueue-links/index.js';
7
+ interface UrlConstraints {
8
+ /**
9
+ * An array of URL patterns that URLs must match to be included.
10
+ *
11
+ * Accepts glob pattern strings, `{ glob: string }` objects, `RegExp` instances, or `{ regexp: RegExp }` objects.
12
+ *
13
+ * Glob matching is always case-insensitive.
14
+ * If you need case-sensitive matching, use a `RegExp`.
15
+ *
16
+ * If `include` is an empty array or `undefined`, then the `SitemapRequestLoader`
17
+ * includes all the URLs from the sitemap.
18
+ */
19
+ include?: readonly UrlPatternInput[];
20
+ /**
21
+ * An array of URL patterns. Matching URLs will **not** be included.
22
+ *
23
+ * Accepts glob pattern strings, `{ glob: string }` objects, `RegExp` instances, or `{ regexp: RegExp }` objects.
24
+ *
25
+ * Glob matching is always case-insensitive.
26
+ * If you need case-sensitive matching, use a `RegExp`.
27
+ */
28
+ exclude?: readonly UrlPatternInput[];
29
+ }
30
+ export interface SitemapRequestLoaderOptions extends UrlConstraints {
31
+ /**
32
+ * List of sitemap URLs to parse.
33
+ */
34
+ sitemapUrls: string[];
35
+ /**
36
+ * Proxy URL to be used for sitemap loading.
37
+ */
38
+ proxyUrl?: string;
39
+ /**
40
+ * Key for persisting the state of the request list in the `KeyValueStore`.
41
+ */
42
+ persistStateKey?: string;
43
+ /**
44
+ * Persistence-related options to control how and when crawler's data gets persisted.
45
+ */
46
+ persistenceOptions?: {
47
+ /**
48
+ * Use this flag to disable or enable periodic persistence to key value store.
49
+ * @default true
50
+ */
51
+ enable?: boolean;
52
+ };
53
+ /**
54
+ * Abort signal to be used for sitemap loading.
55
+ */
56
+ signal?: AbortSignal;
57
+ /**
58
+ * Timeout for sitemap loading in milliseconds. If both `signal` and `timeoutMillis` are provided, either of them can abort the loading.
59
+ */
60
+ timeoutMillis?: number;
61
+ /**
62
+ * Maximum number of buffered URLs for the sitemap loading stream.
63
+ * If the buffer is full, the stream will pause until the buffer is drained.
64
+ *
65
+ * @default 200
66
+ */
67
+ maxBufferSize?: number;
68
+ /**
69
+ * Keep only sitemap-derived URLs matching this strategy relative to the parent sitemap URL; non-`http(s)`
70
+ * schemes are always dropped. The filtering stays enforced after navigation (e.g. across redirects).
71
+ * Pass `'all'` to disable host filtering.
72
+ * @default EnqueueStrategy.SameHostname
73
+ */
74
+ enqueueStrategy?: EnqueueStrategy | `${EnqueueStrategy}`;
75
+ /**
76
+ * Advanced options for the underlying `parseSitemap` call.
77
+ */
78
+ parseSitemapOptions?: Omit<ParseSitemapOptions, 'emitNestedSitemaps' | 'maxDepth'>;
79
+ /**
80
+ * Custom HTTP client to be used for sitemap loading.
81
+ */
82
+ httpClient?: BaseHttpClient;
83
+ }
84
+ /**
85
+ * A list of URLs to crawl parsed from a sitemap.
86
+ *
87
+ * The loading of the sitemap is performed in the background so that crawling can start before the sitemap is fully loaded.
88
+ */
89
+ export declare class SitemapRequestLoader implements IRequestLoader {
90
+ #private;
91
+ /**
92
+ * Set of URLs that were returned by `fetchNextRequest()` and not marked as handled yet.
93
+ * @internal
94
+ */
95
+ inProgress: Set<string>;
96
+ /** @internal */
97
+ private constructor();
98
+ /**
99
+ * Indicates whether the background processing of sitemap contents has successfully finished.
100
+ *
101
+ * If this is `false`, the background processing is either still in progress or was aborted.
102
+ */
103
+ isSitemapFullyLoaded(): boolean;
104
+ /**
105
+ * Open a sitemap and start processing it.
106
+ *
107
+ * Resolves to a new instance of `SitemapRequestLoader`, which **might not be fully loaded yet** - i.e. the sitemap might still be loading in the background.
108
+ *
109
+ * Track the loading progress using the `isSitemapFullyLoaded` property.
110
+ */
111
+ static open(options: SitemapRequestLoaderOptions): Promise<SitemapRequestLoader>;
112
+ /**
113
+ * @inheritDoc
114
+ */
115
+ getTotalCount(): Promise<number>;
116
+ /**
117
+ * @inheritDoc
118
+ */
119
+ getPendingCount(): Promise<number>;
120
+ /**
121
+ * Combines this list with a request manager (a {@link RequestQueue} by default) into a
122
+ * {@link RequestManagerTandem}, allowing requests to be added and reclaimed while still
123
+ * being read from this list first.
124
+ */
125
+ toTandem(requestManager?: IRequestManager): Promise<IRequestManager>;
126
+ /**
127
+ * @inheritDoc
128
+ */
129
+ checkReadiness(): Promise<RequestLoaderStatus>;
130
+ /**
131
+ * @inheritDoc
132
+ */
133
+ getHandledCount(): Promise<number>;
134
+ /**
135
+ * @inheritDoc
136
+ */
137
+ persistState(): Promise<void>;
138
+ /**
139
+ * @inheritDoc
140
+ */
141
+ fetchNextRequest(): Promise<Request | null>;
142
+ /**
143
+ * @inheritDoc
144
+ */
145
+ // @ts-ignore optional peer dependency or compatibility with es2022
146
+ [Symbol.asyncIterator](): AsyncGenerator<Request<import("@crawlee/types").Dictionary>, void, unknown>;
147
+ /**
148
+ * Aborts the internal sitemap loading, stops the processing of the sitemap contents and drops all the pending URLs.
149
+ *
150
+ * Calling `fetchNextRequest()` after this method will always return `null`.
151
+ */
152
+ teardown(): Promise<void>;
153
+ /**
154
+ * @inheritDoc
155
+ */
156
+ markRequestAsHandled(request: Request): Promise<void>;
157
+ }
158
+ export {};