@crawlee/core 4.0.0-beta.8 → 4.0.0-beta.81

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 (257) hide show
  1. package/README.md +17 -13
  2. package/autoscaling/autoscaled_pool.d.ts +14 -15
  3. package/autoscaling/autoscaled_pool.js +37 -36
  4. package/autoscaling/client_load_signal.d.ts +25 -0
  5. package/autoscaling/client_load_signal.js +36 -0
  6. package/autoscaling/cpu_load_signal.d.ts +28 -0
  7. package/autoscaling/cpu_load_signal.js +24 -0
  8. package/autoscaling/event_loop_load_signal.d.ts +23 -0
  9. package/autoscaling/event_loop_load_signal.js +35 -0
  10. package/autoscaling/index.d.ts +5 -1
  11. package/autoscaling/index.js +5 -1
  12. package/autoscaling/load_signal.d.ts +99 -0
  13. package/autoscaling/load_signal.js +135 -0
  14. package/autoscaling/memory_load_signal.d.ts +43 -0
  15. package/autoscaling/memory_load_signal.js +102 -0
  16. package/autoscaling/snapshotter.d.ts +29 -91
  17. package/autoscaling/snapshotter.js +65 -204
  18. package/autoscaling/system_status.d.ts +22 -37
  19. package/autoscaling/system_status.js +49 -87
  20. package/configuration.d.ts +88 -228
  21. package/configuration.js +162 -224
  22. package/cookie_utils.d.ts +4 -3
  23. package/cookie_utils.js +20 -13
  24. package/crawlers/context_pipeline.d.ts +70 -0
  25. package/crawlers/context_pipeline.js +122 -0
  26. package/crawlers/crawler_commons.d.ts +20 -30
  27. package/crawlers/crawler_commons.js +12 -21
  28. package/crawlers/crawler_utils.d.ts +2 -3
  29. package/crawlers/crawler_utils.js +1 -2
  30. package/crawlers/error_snapshotter.d.ts +3 -3
  31. package/crawlers/error_snapshotter.js +2 -3
  32. package/crawlers/error_tracker.d.ts +2 -2
  33. package/crawlers/error_tracker.js +0 -1
  34. package/crawlers/index.d.ts +1 -2
  35. package/crawlers/index.js +1 -2
  36. package/crawlers/internals/types.d.ts +7 -0
  37. package/crawlers/internals/types.js +1 -0
  38. package/crawlers/statistics.d.ts +28 -23
  39. package/crawlers/statistics.js +38 -34
  40. package/enqueue_links/enqueue_links.d.ts +44 -22
  41. package/enqueue_links/enqueue_links.js +51 -30
  42. package/enqueue_links/index.d.ts +0 -1
  43. package/enqueue_links/index.js +0 -1
  44. package/enqueue_links/shared.d.ts +25 -9
  45. package/enqueue_links/shared.js +69 -38
  46. package/errors.d.ts +53 -4
  47. package/errors.js +70 -5
  48. package/events/event_manager.d.ts +34 -8
  49. package/events/event_manager.js +8 -10
  50. package/events/index.d.ts +0 -1
  51. package/events/index.js +0 -1
  52. package/events/local_event_manager.d.ts +15 -5
  53. package/events/local_event_manager.js +37 -40
  54. package/index.d.ts +4 -3
  55. package/index.js +3 -2
  56. package/log.d.ts +82 -3
  57. package/log.js +102 -1
  58. package/memory-storage/consts.d.ts +4 -0
  59. package/memory-storage/consts.js +4 -0
  60. package/memory-storage/index.d.ts +1 -0
  61. package/memory-storage/index.js +1 -0
  62. package/memory-storage/memory-storage.d.ts +46 -0
  63. package/memory-storage/memory-storage.js +136 -0
  64. package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
  65. package/memory-storage/resource-clients/common/base-client.js +6 -0
  66. package/memory-storage/resource-clients/dataset.d.ts +40 -0
  67. package/memory-storage/resource-clients/dataset.js +113 -0
  68. package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
  69. package/memory-storage/resource-clients/key-value-store.js +203 -0
  70. package/memory-storage/resource-clients/request-queue.d.ts +96 -0
  71. package/memory-storage/resource-clients/request-queue.js +421 -0
  72. package/memory-storage/utils.d.ts +17 -0
  73. package/memory-storage/utils.js +42 -0
  74. package/package.json +12 -10
  75. package/proxy_configuration.d.ts +29 -152
  76. package/proxy_configuration.js +21 -173
  77. package/recoverable_state.d.ts +120 -0
  78. package/recoverable_state.js +141 -0
  79. package/request.d.ts +84 -13
  80. package/request.js +107 -28
  81. package/router.d.ts +118 -16
  82. package/router.js +124 -30
  83. package/serialization.d.ts +0 -1
  84. package/serialization.js +1 -2
  85. package/service_locator.d.ts +156 -0
  86. package/service_locator.js +238 -0
  87. package/session_pool/consts.d.ts +1 -2
  88. package/session_pool/consts.js +1 -2
  89. package/session_pool/errors.d.ts +0 -1
  90. package/session_pool/errors.js +0 -1
  91. package/session_pool/fingerprint.d.ts +9 -0
  92. package/session_pool/fingerprint.js +30 -0
  93. package/session_pool/index.d.ts +0 -2
  94. package/session_pool/index.js +0 -2
  95. package/session_pool/session.d.ts +37 -75
  96. package/session_pool/session.js +49 -102
  97. package/session_pool/session_pool.d.ts +85 -90
  98. package/session_pool/session_pool.js +131 -120
  99. package/storages/access_checking.d.ts +0 -1
  100. package/storages/access_checking.js +5 -2
  101. package/storages/dataset.d.ts +101 -51
  102. package/storages/dataset.js +168 -126
  103. package/storages/index.d.ts +8 -7
  104. package/storages/index.js +6 -7
  105. package/storages/key_value_store.d.ts +165 -36
  106. package/storages/key_value_store.js +269 -122
  107. package/storages/key_value_store_codec.d.ts +32 -0
  108. package/storages/key_value_store_codec.js +113 -0
  109. package/storages/request_dedup_cache.d.ts +23 -0
  110. package/storages/request_dedup_cache.js +48 -0
  111. package/storages/request_list.d.ts +53 -97
  112. package/storages/request_list.js +99 -75
  113. package/storages/request_loader.d.ts +96 -0
  114. package/storages/request_loader.js +1 -0
  115. package/storages/request_manager.d.ts +33 -0
  116. package/storages/request_manager.js +1 -0
  117. package/storages/request_manager_tandem.d.ts +106 -0
  118. package/storages/request_manager_tandem.js +197 -0
  119. package/storages/request_queue.d.ts +290 -47
  120. package/storages/request_queue.js +628 -215
  121. package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +28 -24
  122. package/storages/{sitemap_request_list.js → sitemap_request_loader.js} +49 -46
  123. package/storages/storage_instance_manager.d.ts +91 -0
  124. package/storages/storage_instance_manager.js +258 -0
  125. package/storages/storage_stats.d.ts +48 -0
  126. package/storages/storage_stats.js +29 -0
  127. package/storages/utils.d.ts +51 -6
  128. package/storages/utils.js +60 -9
  129. package/system-info/cpu-info.d.ts +67 -0
  130. package/system-info/cpu-info.js +216 -0
  131. package/system-info/memory-info.d.ts +31 -0
  132. package/system-info/memory-info.js +115 -0
  133. package/system-info/ps-tree.d.ts +17 -0
  134. package/system-info/ps-tree.js +144 -0
  135. package/system-info/runtime.d.ts +14 -0
  136. package/system-info/runtime.js +80 -0
  137. package/typedefs.d.ts +1 -2
  138. package/typedefs.js +0 -1
  139. package/validators.d.ts +8 -1
  140. package/validators.js +10 -3
  141. package/autoscaling/autoscaled_pool.d.ts.map +0 -1
  142. package/autoscaling/autoscaled_pool.js.map +0 -1
  143. package/autoscaling/index.d.ts.map +0 -1
  144. package/autoscaling/index.js.map +0 -1
  145. package/autoscaling/snapshotter.d.ts.map +0 -1
  146. package/autoscaling/snapshotter.js.map +0 -1
  147. package/autoscaling/system_status.d.ts.map +0 -1
  148. package/autoscaling/system_status.js.map +0 -1
  149. package/configuration.d.ts.map +0 -1
  150. package/configuration.js.map +0 -1
  151. package/cookie_utils.d.ts.map +0 -1
  152. package/cookie_utils.js.map +0 -1
  153. package/crawlers/crawler_commons.d.ts.map +0 -1
  154. package/crawlers/crawler_commons.js.map +0 -1
  155. package/crawlers/crawler_extension.d.ts +0 -12
  156. package/crawlers/crawler_extension.d.ts.map +0 -1
  157. package/crawlers/crawler_extension.js +0 -14
  158. package/crawlers/crawler_extension.js.map +0 -1
  159. package/crawlers/crawler_utils.d.ts.map +0 -1
  160. package/crawlers/crawler_utils.js.map +0 -1
  161. package/crawlers/error_snapshotter.d.ts.map +0 -1
  162. package/crawlers/error_snapshotter.js.map +0 -1
  163. package/crawlers/error_tracker.d.ts.map +0 -1
  164. package/crawlers/error_tracker.js.map +0 -1
  165. package/crawlers/index.d.ts.map +0 -1
  166. package/crawlers/index.js.map +0 -1
  167. package/crawlers/statistics.d.ts.map +0 -1
  168. package/crawlers/statistics.js.map +0 -1
  169. package/enqueue_links/enqueue_links.d.ts.map +0 -1
  170. package/enqueue_links/enqueue_links.js.map +0 -1
  171. package/enqueue_links/index.d.ts.map +0 -1
  172. package/enqueue_links/index.js.map +0 -1
  173. package/enqueue_links/shared.d.ts.map +0 -1
  174. package/enqueue_links/shared.js.map +0 -1
  175. package/errors.d.ts.map +0 -1
  176. package/errors.js.map +0 -1
  177. package/events/event_manager.d.ts.map +0 -1
  178. package/events/event_manager.js.map +0 -1
  179. package/events/index.d.ts.map +0 -1
  180. package/events/index.js.map +0 -1
  181. package/events/local_event_manager.d.ts.map +0 -1
  182. package/events/local_event_manager.js.map +0 -1
  183. package/http_clients/base-http-client.d.ts +0 -134
  184. package/http_clients/base-http-client.d.ts.map +0 -1
  185. package/http_clients/base-http-client.js +0 -33
  186. package/http_clients/base-http-client.js.map +0 -1
  187. package/http_clients/form-data-like.d.ts +0 -67
  188. package/http_clients/form-data-like.d.ts.map +0 -1
  189. package/http_clients/form-data-like.js +0 -5
  190. package/http_clients/form-data-like.js.map +0 -1
  191. package/http_clients/got-scraping-http-client.d.ts +0 -15
  192. package/http_clients/got-scraping-http-client.d.ts.map +0 -1
  193. package/http_clients/got-scraping-http-client.js +0 -69
  194. package/http_clients/got-scraping-http-client.js.map +0 -1
  195. package/http_clients/index.d.ts +0 -3
  196. package/http_clients/index.d.ts.map +0 -1
  197. package/http_clients/index.js +0 -3
  198. package/http_clients/index.js.map +0 -1
  199. package/index.d.ts.map +0 -1
  200. package/index.js.map +0 -1
  201. package/log.d.ts.map +0 -1
  202. package/log.js.map +0 -1
  203. package/proxy_configuration.d.ts.map +0 -1
  204. package/proxy_configuration.js.map +0 -1
  205. package/request.d.ts.map +0 -1
  206. package/request.js.map +0 -1
  207. package/router.d.ts.map +0 -1
  208. package/router.js.map +0 -1
  209. package/serialization.d.ts.map +0 -1
  210. package/serialization.js.map +0 -1
  211. package/session_pool/consts.d.ts.map +0 -1
  212. package/session_pool/consts.js.map +0 -1
  213. package/session_pool/errors.d.ts.map +0 -1
  214. package/session_pool/errors.js.map +0 -1
  215. package/session_pool/events.d.ts +0 -3
  216. package/session_pool/events.d.ts.map +0 -1
  217. package/session_pool/events.js +0 -3
  218. package/session_pool/events.js.map +0 -1
  219. package/session_pool/index.d.ts.map +0 -1
  220. package/session_pool/index.js.map +0 -1
  221. package/session_pool/session.d.ts.map +0 -1
  222. package/session_pool/session.js.map +0 -1
  223. package/session_pool/session_pool.d.ts.map +0 -1
  224. package/session_pool/session_pool.js.map +0 -1
  225. package/storages/access_checking.d.ts.map +0 -1
  226. package/storages/access_checking.js.map +0 -1
  227. package/storages/dataset.d.ts.map +0 -1
  228. package/storages/dataset.js.map +0 -1
  229. package/storages/index.d.ts.map +0 -1
  230. package/storages/index.js.map +0 -1
  231. package/storages/key_value_store.d.ts.map +0 -1
  232. package/storages/key_value_store.js.map +0 -1
  233. package/storages/request_list.d.ts.map +0 -1
  234. package/storages/request_list.js.map +0 -1
  235. package/storages/request_provider.d.ts +0 -307
  236. package/storages/request_provider.d.ts.map +0 -1
  237. package/storages/request_provider.js +0 -555
  238. package/storages/request_provider.js.map +0 -1
  239. package/storages/request_queue.d.ts.map +0 -1
  240. package/storages/request_queue.js.map +0 -1
  241. package/storages/request_queue_v2.d.ts +0 -87
  242. package/storages/request_queue_v2.d.ts.map +0 -1
  243. package/storages/request_queue_v2.js +0 -438
  244. package/storages/request_queue_v2.js.map +0 -1
  245. package/storages/sitemap_request_list.d.ts.map +0 -1
  246. package/storages/sitemap_request_list.js.map +0 -1
  247. package/storages/storage_manager.d.ts +0 -58
  248. package/storages/storage_manager.d.ts.map +0 -1
  249. package/storages/storage_manager.js +0 -105
  250. package/storages/storage_manager.js.map +0 -1
  251. package/storages/utils.d.ts.map +0 -1
  252. package/storages/utils.js.map +0 -1
  253. package/tsconfig.build.tsbuildinfo +0 -1
  254. package/typedefs.d.ts.map +0 -1
  255. package/typedefs.js.map +0 -1
  256. package/validators.d.ts.map +0 -1
  257. package/validators.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A fixed-size, direct-mapped cache for `uniqueKey`-based request deduplication.
3
+ *
4
+ * `RequestProvider.requestCache` only remembers the first batch of requests, so repeated
5
+ * `addRequestsBatched()` calls with overlapping URLs re-submit already-enqueued requests
6
+ * (https://github.com/apify/crawlee/issues/3120). This is a separate, cheaper cache we can populate on
7
+ * every batch: a fixed number of slots indexed by a hash of the request's cache key, storing the
8
+ * server-assigned `requestId`. Memory is capped by the slot count regardless of the working set size;
9
+ * a hash collision just overwrites a slot, causing an occasional cache miss (a harmless re-submission)
10
+ * but never a false hit — so a genuinely new request is never dropped.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare class RequestDeduplicationCache {
15
+ private readonly size;
16
+ private keys;
17
+ private ids;
18
+ constructor(size?: number);
19
+ get(cacheKey: string): string | null;
20
+ add(cacheKey: string, requestId: string): void;
21
+ clear(): void;
22
+ private indexOf;
23
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A fixed-size, direct-mapped cache for `uniqueKey`-based request deduplication.
3
+ *
4
+ * `RequestProvider.requestCache` only remembers the first batch of requests, so repeated
5
+ * `addRequestsBatched()` calls with overlapping URLs re-submit already-enqueued requests
6
+ * (https://github.com/apify/crawlee/issues/3120). This is a separate, cheaper cache we can populate on
7
+ * every batch: a fixed number of slots indexed by a hash of the request's cache key, storing the
8
+ * server-assigned `requestId`. Memory is capped by the slot count regardless of the working set size;
9
+ * a hash collision just overwrites a slot, causing an occasional cache miss (a harmless re-submission)
10
+ * but never a false hit — so a genuinely new request is never dropped.
11
+ *
12
+ * @internal
13
+ */
14
+ export class RequestDeduplicationCache {
15
+ size;
16
+ keys;
17
+ ids;
18
+ // The slot count is the same for every queue, so it's a fixed default rather than a per-consumer option.
19
+ constructor(size = 1_000_000) {
20
+ this.size = size;
21
+ this.keys = new Array(size);
22
+ this.ids = new Array(size);
23
+ }
24
+ get(cacheKey) {
25
+ const index = this.indexOf(cacheKey);
26
+ return this.keys[index] === cacheKey ? this.ids[index] : null;
27
+ }
28
+ add(cacheKey, requestId) {
29
+ const index = this.indexOf(cacheKey);
30
+ this.keys[index] = cacheKey;
31
+ this.ids[index] = requestId;
32
+ }
33
+ clear() {
34
+ this.keys = new Array(this.size);
35
+ this.ids = new Array(this.size);
36
+ }
37
+ // A cheap FNV-1a hash of the cache key — avoids pulling in a dedicated hashing dependency.
38
+ indexOf(cacheKey) {
39
+ /* eslint-disable no-bitwise */
40
+ let hash = 0x811c9dc5;
41
+ for (let i = 0; i < cacheKey.length; i++) {
42
+ hash ^= cacheKey.charCodeAt(i);
43
+ hash = Math.imul(hash, 0x01000193);
44
+ }
45
+ return (hash >>> 0) % this.size;
46
+ /* eslint-enable no-bitwise */
47
+ }
48
+ }
@@ -1,75 +1,13 @@
1
- import type { Dictionary } from '@crawlee/types';
2
- import { Configuration } from '../configuration.js';
3
- import type { ProxyConfiguration } from '../proxy_configuration.js';
4
- import { type InternalSource, Request, type RequestOptions, type Source } from '../request.js';
1
+ import type { BaseHttpClient, Dictionary } from '@crawlee/types';
2
+ import type { Configuration } from '../configuration.js';
3
+ import type { IProxyConfiguration } from '../proxy_configuration.js';
4
+ import { Request, type RequestOptions, type Source } from '../request.js';
5
+ import type { IRequestLoader } from './request_loader.js';
6
+ import type { IRequestManager } from './request_manager.js';
5
7
  /** @internal */
6
8
  export declare const STATE_PERSISTENCE_KEY = "REQUEST_LIST_STATE";
7
9
  /** @internal */
8
10
  export declare const REQUESTS_PERSISTENCE_KEY = "REQUEST_LIST_REQUESTS";
9
- /**
10
- * Represents a static list of URLs to crawl.
11
- */
12
- export interface IRequestList {
13
- /**
14
- * Returns the total number of unique requests present in the list.
15
- */
16
- length(): number;
17
- /**
18
- * Returns `true` if all requests were already handled and there are no more left.
19
- */
20
- isFinished(): Promise<boolean>;
21
- /**
22
- * Resolves to `true` if the next call to {@link IRequestList.fetchNextRequest} function
23
- * would return `null`, otherwise it resolves to `false`.
24
- * Note that even if the list is empty, there might be some pending requests currently being processed.
25
- */
26
- isEmpty(): Promise<boolean>;
27
- /**
28
- * Returns number of handled requests.
29
- */
30
- handledCount(): number;
31
- /**
32
- * Persists the current state of the `IRequestList` into the default {@link KeyValueStore}.
33
- * The state is persisted automatically in regular intervals, but calling this method manually
34
- * is useful in cases where you want to have the most current state available after you pause
35
- * or stop fetching its requests. For example after you pause or abort a crawl. Or just before
36
- * a server migration.
37
- */
38
- persistState(): Promise<void>;
39
- /**
40
- * Gets the next {@link Request} to process. First, the function gets a request previously reclaimed
41
- * using the {@link RequestList.reclaimRequest} function, if there is any.
42
- * Otherwise it gets the next request from sources.
43
- *
44
- * The function's `Promise` resolves to `null` if there are no more
45
- * requests to process.
46
- */
47
- fetchNextRequest(): Promise<Request | null>;
48
- /**
49
- * Gets the next {@link Request} to process. First, the function gets a request previously reclaimed
50
- * using the {@link RequestList.reclaimRequest} function, if there is any.
51
- * Otherwise it gets the next request from sources.
52
- *
53
- * The function resolves to `null` if there are no more requests to process.
54
- *
55
- * Can be used to iterate over the `RequestList` instance in a `for await .. of` loop.
56
- * Provides an alternative for the repeated use of `fetchNextRequest`.
57
- */
58
- [Symbol.asyncIterator](): AsyncGenerator<Request>;
59
- /**
60
- * Reclaims request to the list if its processing failed.
61
- * The request will become available in the next `this.fetchNextRequest()`.
62
- */
63
- reclaimRequest(request: Request): Promise<void>;
64
- /**
65
- * Marks request as handled after successful processing.
66
- */
67
- markRequestHandled(request: Request): Promise<void>;
68
- /**
69
- * @internal
70
- */
71
- inProgress: Set<string>;
72
- }
73
11
  export interface RequestListOptions {
74
12
  /**
75
13
  * An array of sources of URLs for the {@link RequestList}. It can be either an array of strings,
@@ -149,7 +87,7 @@ export interface RequestListOptions {
149
87
  * Takes advantage of the internal address rotation and authentication process.
150
88
  * If undefined, the `requestsFromUrl` requests will be made without proxy.
151
89
  */
152
- proxyConfiguration?: ProxyConfiguration;
90
+ proxyConfiguration?: IProxyConfiguration;
153
91
  /**
154
92
  * Identifies the key in the default key-value store under which `RequestList` periodically stores its
155
93
  * state (i.e. which URLs were crawled and which not).
@@ -209,6 +147,12 @@ export interface RequestListOptions {
209
147
  keepDuplicateUrls?: boolean;
210
148
  /** @internal */
211
149
  config?: Configuration;
150
+ /**
151
+ * The HTTP client to be used to download `requestsFromUrl` URLs.
152
+ *
153
+ * If not specified the `RequestList` will use the default HTTP client.
154
+ */
155
+ httpClient?: BaseHttpClient;
212
156
  }
213
157
  /**
214
158
  * Represents a static list of URLs to crawl.
@@ -232,8 +176,8 @@ export interface RequestListOptions {
232
176
  * > In practical terms, such a combination can be useful when there is a large number of initial URLs,
233
177
  * > but more URLs would be added dynamically by the crawler.
234
178
  *
235
- * `RequestList` has an internal state where it stores information about which requests were already handled,
236
- * which are in progress and which were reclaimed. The state may be automatically persisted to the default
179
+ * `RequestList` has an internal state where it stores information about which requests were already handled
180
+ * and which are in progress. The state may be automatically persisted to the default
237
181
  * {@link KeyValueStore} by setting the `persistStateKey` option so that if the Node.js process is restarted,
238
182
  * the crawling can continue where it left off. The automated persisting is launched upon receiving the `persistState`
239
183
  * event that is periodically emitted by {@link EventManager}.
@@ -271,14 +215,14 @@ export interface RequestListOptions {
271
215
  * ```
272
216
  * @category Sources
273
217
  */
274
- export declare class RequestList implements IRequestList {
218
+ export declare class RequestList implements IRequestLoader {
275
219
  private log;
276
220
  /**
277
221
  * Array of all requests from all sources, in the order as they appeared in sources.
278
222
  * All requests in the array have distinct uniqueKey!
279
223
  * @internal
280
224
  */
281
- requests: (Request | RequestOptions)[];
225
+ readonly requests: (Request | RequestOptions)[];
282
226
  /** Index to the next item in requests array to fetch. All previous requests are either handled or in progress. */
283
227
  private nextIndex;
284
228
  /** Dictionary, key is Request.uniqueKey, value is corresponding index in the requests array. */
@@ -289,10 +233,11 @@ export declare class RequestList implements IRequestList {
289
233
  */
290
234
  inProgress: Set<string>;
291
235
  /**
292
- * Set of `uniqueKey`s of requests for which reclaimRequest() was called.
236
+ * `uniqueKey`s of requests that were in progress when the state was last persisted and thus need to be
237
+ * re-crawled after a restart. They are served before advancing through the rest of the sources.
293
238
  * @internal
294
239
  */
295
- reclaimed: Set<string>;
240
+ private requestsToRetry;
296
241
  /**
297
242
  * Starts as true because until we handle the first request, the list is effectively persisted by doing nothing.
298
243
  * @internal
@@ -313,7 +258,7 @@ export declare class RequestList implements IRequestList {
313
258
  private sources;
314
259
  private sourcesFunction?;
315
260
  private proxyConfiguration?;
316
- private events;
261
+ private httpClient?;
317
262
  /**
318
263
  * To create new instance of `RequestList` we need to use `RequestList.open()` factory method.
319
264
  * @param options All `RequestList` configuration options
@@ -330,33 +275,39 @@ export declare class RequestList implements IRequestList {
330
275
  * This needs to be done in a memory efficient way. We should update the input
331
276
  * to a Stream once apify-client supports streams.
332
277
  */
333
- protected _addPersistedRequests(persistedRequests: Buffer): Promise<void>;
278
+ private addPersistedRequests;
334
279
  /**
335
280
  * Add Requests from both options.sources and options.sourcesFunction.
336
281
  * This function is called only when persisted sources were not loaded.
337
282
  * We need to avoid keeping both sources and requests in memory
338
283
  * to reduce memory footprint with very large sources.
339
284
  */
340
- protected _addRequestsFromSources(): Promise<void>;
285
+ private addRequestsFromSources;
341
286
  /**
342
287
  * @inheritDoc
343
288
  */
344
289
  persistState(): Promise<void>;
290
+ /**
291
+ * Removes the `PERSIST_STATE` event listener registered during initialization and persists
292
+ * the current state one last time. Call this when you are done with the `RequestList` to avoid
293
+ * leaking the listener (and the requests it retains) on the shared event manager.
294
+ */
295
+ teardown(): Promise<void>;
345
296
  /**
346
297
  * Unlike persistState(), this is used only internally, since the sources
347
298
  * are automatically persisted at RequestList initialization (if the persistRequestsKey is set),
348
299
  * but there's no reason to persist it again afterwards, because RequestList is immutable.
349
300
  */
350
- protected _persistRequests(): Promise<void>;
301
+ private persistRequests;
351
302
  /**
352
303
  * Restores RequestList state from a state object.
353
304
  */
354
- protected _restoreState(state?: RequestListState): void;
305
+ private restoreState;
355
306
  /**
356
307
  * Attempts to load state and requests using the `RequestList` configuration
357
308
  * and returns a tuple of [state, requests] where each may be null if not loaded.
358
309
  */
359
- protected _loadStateAndPersistedRequests(): Promise<[RequestListState, Buffer]>;
310
+ private loadStateAndPersistedRequests;
360
311
  /**
361
312
  * Returns an object representing the internal state of the `RequestList` instance.
362
313
  * Note that the object's fields can change in future releases.
@@ -382,47 +333,53 @@ export declare class RequestList implements IRequestList {
382
333
  /**
383
334
  * @inheritDoc
384
335
  */
385
- markRequestHandled(request: Request): Promise<void>;
386
- /**
387
- * @inheritDoc
388
- */
389
- reclaimRequest(request: Request): Promise<void>;
336
+ markRequestAsHandled(request: Request): Promise<void>;
390
337
  /**
391
338
  * Adds all fetched requests from a URL from a remote resource.
392
339
  */
393
- protected _addFetchedRequests(source: InternalSource, fetchedRequests: RequestOptions[]): Promise<void>;
394
- protected _getPersistedState<T>(key: string): Promise<T>;
340
+ private addFetchedRequests;
341
+ private getPersistedState;
395
342
  /**
396
343
  * Fetches URLs from requestsFromUrl and returns them in format of list of requests
397
344
  */
398
- protected _fetchRequestsFromUrl(source: InternalSource): Promise<RequestOptions[]>;
345
+ private fetchRequestsFromUrl;
399
346
  /**
400
347
  * Adds given request.
401
348
  * If the `source` parameter is a string or plain object and not an instance
402
349
  * of a `Request`, then the function creates a `Request` instance.
403
350
  */
404
- protected _addRequest(source: RequestListSource): void;
351
+ private addRequest;
405
352
  /**
406
353
  * Helper function that validates unique key.
407
354
  * Throws an error if uniqueKey is not a non-empty string.
408
355
  */
409
- protected _ensureUniqueKeyValid(uniqueKey: string): void;
356
+ private ensureUniqueKeyValid;
410
357
  /**
411
- * Checks that request is not reclaimed and throws an error if so.
358
+ * Checks that a request is currently being processed and throws an error if not.
412
359
  */
413
- protected _ensureInProgressAndNotReclaimed(uniqueKey: string): void;
360
+ private ensureInProgress;
414
361
  /**
415
362
  * Throws an error if request list wasn't initialized.
416
363
  */
417
- protected _ensureIsInitialized(): void;
364
+ private ensureIsInitialized;
418
365
  /**
419
366
  * Returns the total number of unique requests present in the `RequestList`.
420
367
  */
421
- length(): number;
368
+ getTotalCount(): Promise<number>;
369
+ /**
370
+ * Returns the number of pending requests in the `RequestList`.
371
+ */
372
+ getPendingCount(): Promise<number>;
373
+ /**
374
+ * Combines this list with a request manager (a {@link RequestQueue} by default) into a
375
+ * {@link RequestManagerTandem}, allowing requests to be added and reclaimed while still
376
+ * being read from this list first.
377
+ */
378
+ toTandem(requestManager?: IRequestManager): Promise<IRequestManager>;
422
379
  /**
423
380
  * @inheritDoc
424
381
  */
425
- handledCount(): number;
382
+ getHandledCount(): Promise<number>;
426
383
  /**
427
384
  * Opens a request list and returns a promise resolving to an instance
428
385
  * of the {@link RequestList} class that is already initialized.
@@ -509,4 +466,3 @@ export interface RequestListState {
509
466
  type RequestListSource = string | Source;
510
467
  export type RequestListSourcesFunction = () => Promise<RequestListSource[]>;
511
468
  export {};
512
- //# sourceMappingURL=request_list.d.ts.map