@crawlee/core 4.0.0-beta.13 → 4.0.0-beta.130

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 (280) hide show
  1. package/README.md +17 -13
  2. package/autoscaling/autoscaled_pool.d.ts +67 -172
  3. package/autoscaling/autoscaled_pool.js +182 -329
  4. package/autoscaling/concurrency_system.d.ts +268 -0
  5. package/autoscaling/concurrency_system.js +362 -0
  6. package/autoscaling/cpu_load_signal.d.ts +43 -0
  7. package/autoscaling/cpu_load_signal.js +47 -0
  8. package/autoscaling/event_loop_load_signal.d.ts +51 -0
  9. package/autoscaling/event_loop_load_signal.js +60 -0
  10. package/autoscaling/index.d.ts +6 -1
  11. package/autoscaling/index.js +6 -1
  12. package/autoscaling/load_signal.d.ts +100 -0
  13. package/autoscaling/load_signal.js +105 -0
  14. package/autoscaling/memory_load_signal.d.ts +47 -0
  15. package/autoscaling/memory_load_signal.js +106 -0
  16. package/autoscaling/snapshotter.d.ts +58 -163
  17. package/autoscaling/snapshotter.js +45 -263
  18. package/autoscaling/storage_backend_load_signal.d.ts +56 -0
  19. package/autoscaling/storage_backend_load_signal.js +73 -0
  20. package/autoscaling/system_status.d.ts +67 -89
  21. package/autoscaling/system_status.js +92 -122
  22. package/autoscaling/weighted_avg.d.ts +5 -0
  23. package/autoscaling/weighted_avg.js +14 -0
  24. package/byte_utils.d.ts +17 -0
  25. package/byte_utils.js +42 -0
  26. package/configuration.d.ts +96 -223
  27. package/configuration.js +170 -222
  28. package/cookie_utils.d.ts +3 -2
  29. package/cookie_utils.js +18 -7
  30. package/crawlers/context_pipeline.d.ts +10 -1
  31. package/crawlers/context_pipeline.js +31 -8
  32. package/crawlers/crawler_commons.d.ts +90 -129
  33. package/crawlers/crawler_commons.js +1 -116
  34. package/crawlers/error_snapshotter.d.ts +2 -5
  35. package/crawlers/error_snapshotter.js +7 -8
  36. package/crawlers/error_tracker.d.ts +0 -1
  37. package/crawlers/error_tracker.js +0 -1
  38. package/crawlers/index.d.ts +1 -3
  39. package/crawlers/index.js +0 -3
  40. package/crawlers/internals/types.d.ts +0 -1
  41. package/crawlers/internals/types.js +0 -1
  42. package/crawlers/statistics.d.ts +187 -63
  43. package/crawlers/statistics.js +354 -164
  44. package/debug.d.ts +36 -0
  45. package/debug.js +70 -0
  46. package/enqueue_links/enqueue_links.d.ts +68 -154
  47. package/enqueue_links/enqueue_links.js +38 -210
  48. package/enqueue_links/index.d.ts +0 -1
  49. package/enqueue_links/index.js +0 -1
  50. package/enqueue_links/shared.d.ts +52 -26
  51. package/enqueue_links/shared.js +115 -66
  52. package/errors.d.ts +72 -4
  53. package/errors.js +89 -5
  54. package/events/event_manager.d.ts +35 -9
  55. package/events/event_manager.js +12 -13
  56. package/events/index.d.ts +0 -1
  57. package/events/index.js +0 -1
  58. package/events/local_event_manager.d.ts +15 -3
  59. package/events/local_event_manager.js +39 -13
  60. package/http.d.ts +9 -0
  61. package/http.js +28 -0
  62. package/index.d.ts +7 -4
  63. package/index.js +6 -3
  64. package/iterables.d.ts +79 -0
  65. package/iterables.js +134 -0
  66. package/log.d.ts +82 -3
  67. package/log.js +106 -1
  68. package/memory-storage/consts.d.ts +4 -0
  69. package/memory-storage/consts.js +4 -0
  70. package/memory-storage/index.d.ts +1 -0
  71. package/memory-storage/index.js +1 -0
  72. package/memory-storage/memory-storage.d.ts +38 -0
  73. package/memory-storage/memory-storage.js +130 -0
  74. package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
  75. package/memory-storage/resource-clients/common/base-client.js +6 -0
  76. package/memory-storage/resource-clients/dataset.d.ts +40 -0
  77. package/memory-storage/resource-clients/dataset.js +108 -0
  78. package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
  79. package/memory-storage/resource-clients/key-value-store.js +201 -0
  80. package/memory-storage/resource-clients/request-queue.d.ts +77 -0
  81. package/memory-storage/resource-clients/request-queue.js +409 -0
  82. package/memory-storage/utils.d.ts +16 -0
  83. package/memory-storage/utils.js +41 -0
  84. package/owned_or_injected.d.ts +58 -0
  85. package/owned_or_injected.js +98 -0
  86. package/package.json +14 -13
  87. package/proxy_configuration.d.ts +24 -132
  88. package/proxy_configuration.js +32 -147
  89. package/recoverable_state.d.ts +155 -0
  90. package/recoverable_state.js +231 -0
  91. package/request.d.ts +80 -16
  92. package/request.js +147 -68
  93. package/router.d.ts +193 -21
  94. package/router.js +188 -43
  95. package/serialization.d.ts +0 -1
  96. package/serialization.js +15 -15
  97. package/service_locator.d.ts +165 -0
  98. package/service_locator.js +253 -0
  99. package/session_pool/consts.d.ts +1 -2
  100. package/session_pool/consts.js +1 -2
  101. package/session_pool/errors.d.ts +0 -1
  102. package/session_pool/errors.js +0 -1
  103. package/session_pool/fingerprint.d.ts +9 -0
  104. package/session_pool/fingerprint.js +30 -0
  105. package/session_pool/index.d.ts +0 -2
  106. package/session_pool/index.js +0 -2
  107. package/session_pool/session.d.ts +35 -88
  108. package/session_pool/session.js +101 -159
  109. package/session_pool/session_pool.d.ts +73 -91
  110. package/session_pool/session_pool.js +172 -165
  111. package/storages/batched_adds.d.ts +37 -0
  112. package/storages/batched_adds.js +73 -0
  113. package/storages/dataset.d.ts +114 -54
  114. package/storages/dataset.js +291 -148
  115. package/storages/index.d.ts +10 -8
  116. package/storages/index.js +8 -8
  117. package/storages/key_value_store.d.ts +185 -42
  118. package/storages/key_value_store.js +445 -169
  119. package/storages/key_value_store_codec.d.ts +32 -0
  120. package/storages/key_value_store_codec.js +113 -0
  121. package/storages/request_dedup_cache.d.ts +22 -0
  122. package/storages/request_dedup_cache.js +48 -0
  123. package/storages/request_list.d.ts +52 -115
  124. package/storages/request_list.js +183 -152
  125. package/storages/request_loader.d.ts +101 -0
  126. package/storages/request_loader.js +1 -0
  127. package/storages/request_manager.d.ts +33 -0
  128. package/storages/request_manager.js +1 -0
  129. package/storages/request_manager_tandem.d.ts +97 -0
  130. package/storages/request_manager_tandem.js +197 -0
  131. package/storages/request_queue.d.ts +290 -47
  132. package/storages/request_queue.js +762 -216
  133. package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +45 -89
  134. package/storages/sitemap_request_loader.js +438 -0
  135. package/storages/storage_instance_manager.d.ts +87 -0
  136. package/storages/storage_instance_manager.js +256 -0
  137. package/storages/storage_stats.d.ts +48 -0
  138. package/storages/storage_stats.js +29 -0
  139. package/storages/throttling_request_manager.d.ts +239 -0
  140. package/storages/throttling_request_manager.js +646 -0
  141. package/storages/transaction.d.ts +252 -0
  142. package/storages/transaction.js +251 -0
  143. package/storages/utils.d.ts +59 -11
  144. package/storages/utils.js +75 -15
  145. package/system-info/cpu-info.d.ts +67 -0
  146. package/system-info/cpu-info.js +216 -0
  147. package/system-info/memory-info.d.ts +31 -0
  148. package/system-info/memory-info.js +115 -0
  149. package/system-info/ps-tree.d.ts +17 -0
  150. package/system-info/ps-tree.js +144 -0
  151. package/system-info/runtime.d.ts +14 -0
  152. package/system-info/runtime.js +80 -0
  153. package/typedefs.d.ts +0 -6
  154. package/typedefs.js +0 -1
  155. package/url.d.ts +9 -0
  156. package/url.js +11 -0
  157. package/validators.d.ts +22 -18
  158. package/validators.js +13 -18
  159. package/autoscaling/autoscaled_pool.d.ts.map +0 -1
  160. package/autoscaling/autoscaled_pool.js.map +0 -1
  161. package/autoscaling/index.d.ts.map +0 -1
  162. package/autoscaling/index.js.map +0 -1
  163. package/autoscaling/snapshotter.d.ts.map +0 -1
  164. package/autoscaling/snapshotter.js.map +0 -1
  165. package/autoscaling/system_status.d.ts.map +0 -1
  166. package/autoscaling/system_status.js.map +0 -1
  167. package/configuration.d.ts.map +0 -1
  168. package/configuration.js.map +0 -1
  169. package/cookie_utils.d.ts.map +0 -1
  170. package/cookie_utils.js.map +0 -1
  171. package/crawlers/context_pipeline.d.ts.map +0 -1
  172. package/crawlers/context_pipeline.js.map +0 -1
  173. package/crawlers/crawler_commons.d.ts.map +0 -1
  174. package/crawlers/crawler_commons.js.map +0 -1
  175. package/crawlers/crawler_utils.d.ts +0 -10
  176. package/crawlers/crawler_utils.d.ts.map +0 -1
  177. package/crawlers/crawler_utils.js +0 -12
  178. package/crawlers/crawler_utils.js.map +0 -1
  179. package/crawlers/error_snapshotter.d.ts.map +0 -1
  180. package/crawlers/error_snapshotter.js.map +0 -1
  181. package/crawlers/error_tracker.d.ts.map +0 -1
  182. package/crawlers/error_tracker.js.map +0 -1
  183. package/crawlers/index.d.ts.map +0 -1
  184. package/crawlers/index.js.map +0 -1
  185. package/crawlers/internals/types.d.ts.map +0 -1
  186. package/crawlers/internals/types.js.map +0 -1
  187. package/crawlers/statistics.d.ts.map +0 -1
  188. package/crawlers/statistics.js.map +0 -1
  189. package/enqueue_links/enqueue_links.d.ts.map +0 -1
  190. package/enqueue_links/enqueue_links.js.map +0 -1
  191. package/enqueue_links/index.d.ts.map +0 -1
  192. package/enqueue_links/index.js.map +0 -1
  193. package/enqueue_links/shared.d.ts.map +0 -1
  194. package/enqueue_links/shared.js.map +0 -1
  195. package/errors.d.ts.map +0 -1
  196. package/errors.js.map +0 -1
  197. package/events/event_manager.d.ts.map +0 -1
  198. package/events/event_manager.js.map +0 -1
  199. package/events/index.d.ts.map +0 -1
  200. package/events/index.js.map +0 -1
  201. package/events/local_event_manager.d.ts.map +0 -1
  202. package/events/local_event_manager.js.map +0 -1
  203. package/http_clients/base-http-client.d.ts +0 -140
  204. package/http_clients/base-http-client.d.ts.map +0 -1
  205. package/http_clients/base-http-client.js +0 -40
  206. package/http_clients/base-http-client.js.map +0 -1
  207. package/http_clients/form-data-like.d.ts +0 -67
  208. package/http_clients/form-data-like.d.ts.map +0 -1
  209. package/http_clients/form-data-like.js +0 -5
  210. package/http_clients/form-data-like.js.map +0 -1
  211. package/http_clients/got-scraping-http-client.d.ts +0 -20
  212. package/http_clients/got-scraping-http-client.d.ts.map +0 -1
  213. package/http_clients/got-scraping-http-client.js +0 -82
  214. package/http_clients/got-scraping-http-client.js.map +0 -1
  215. package/http_clients/index.d.ts +0 -3
  216. package/http_clients/index.d.ts.map +0 -1
  217. package/http_clients/index.js +0 -3
  218. package/http_clients/index.js.map +0 -1
  219. package/index.d.ts.map +0 -1
  220. package/index.js.map +0 -1
  221. package/log.d.ts.map +0 -1
  222. package/log.js.map +0 -1
  223. package/proxy_configuration.d.ts.map +0 -1
  224. package/proxy_configuration.js.map +0 -1
  225. package/request.d.ts.map +0 -1
  226. package/request.js.map +0 -1
  227. package/router.d.ts.map +0 -1
  228. package/router.js.map +0 -1
  229. package/serialization.d.ts.map +0 -1
  230. package/serialization.js.map +0 -1
  231. package/session_pool/consts.d.ts.map +0 -1
  232. package/session_pool/consts.js.map +0 -1
  233. package/session_pool/errors.d.ts.map +0 -1
  234. package/session_pool/errors.js.map +0 -1
  235. package/session_pool/events.d.ts +0 -3
  236. package/session_pool/events.d.ts.map +0 -1
  237. package/session_pool/events.js +0 -3
  238. package/session_pool/events.js.map +0 -1
  239. package/session_pool/index.d.ts.map +0 -1
  240. package/session_pool/index.js.map +0 -1
  241. package/session_pool/session.d.ts.map +0 -1
  242. package/session_pool/session.js.map +0 -1
  243. package/session_pool/session_pool.d.ts.map +0 -1
  244. package/session_pool/session_pool.js.map +0 -1
  245. package/storages/access_checking.d.ts +0 -13
  246. package/storages/access_checking.d.ts.map +0 -1
  247. package/storages/access_checking.js +0 -14
  248. package/storages/access_checking.js.map +0 -1
  249. package/storages/dataset.d.ts.map +0 -1
  250. package/storages/dataset.js.map +0 -1
  251. package/storages/index.d.ts.map +0 -1
  252. package/storages/index.js.map +0 -1
  253. package/storages/key_value_store.d.ts.map +0 -1
  254. package/storages/key_value_store.js.map +0 -1
  255. package/storages/request_list.d.ts.map +0 -1
  256. package/storages/request_list.js.map +0 -1
  257. package/storages/request_provider.d.ts +0 -308
  258. package/storages/request_provider.d.ts.map +0 -1
  259. package/storages/request_provider.js +0 -555
  260. package/storages/request_provider.js.map +0 -1
  261. package/storages/request_queue.d.ts.map +0 -1
  262. package/storages/request_queue.js.map +0 -1
  263. package/storages/request_queue_v2.d.ts +0 -87
  264. package/storages/request_queue_v2.d.ts.map +0 -1
  265. package/storages/request_queue_v2.js +0 -438
  266. package/storages/request_queue_v2.js.map +0 -1
  267. package/storages/sitemap_request_list.d.ts.map +0 -1
  268. package/storages/sitemap_request_list.js +0 -430
  269. package/storages/sitemap_request_list.js.map +0 -1
  270. package/storages/storage_manager.d.ts +0 -58
  271. package/storages/storage_manager.d.ts.map +0 -1
  272. package/storages/storage_manager.js +0 -105
  273. package/storages/storage_manager.js.map +0 -1
  274. package/storages/utils.d.ts.map +0 -1
  275. package/storages/utils.js.map +0 -1
  276. package/tsconfig.build.tsbuildinfo +0 -1
  277. package/typedefs.d.ts.map +0 -1
  278. package/typedefs.js.map +0 -1
  279. package/validators.d.ts.map +0 -1
  280. package/validators.js.map +0 -1
@@ -1,308 +0,0 @@
1
- import type { BatchAddRequestsResult, Dictionary, ProcessedRequest, QueueOperationInfo, RequestQueueClient, RequestQueueInfo, StorageClient } from '@crawlee/types';
2
- import type { ReadonlyDeep } from 'type-fest';
3
- import { ListDictionary, LruCache } from '@apify/datastructures';
4
- import type { Log } from '@apify/log';
5
- import { Configuration } from '../configuration.js';
6
- import type { ProxyConfiguration } from '../proxy_configuration.js';
7
- import type { InternalSource, RequestOptions, Source } from '../request.js';
8
- import { Request } from '../request.js';
9
- import type { IStorage, StorageManagerOptions } from './storage_manager.js';
10
- export declare abstract class RequestProvider implements IStorage {
11
- readonly config: Configuration;
12
- id: string;
13
- name?: string;
14
- timeoutSecs: number;
15
- clientKey: string;
16
- client: RequestQueueClient;
17
- protected proxyConfiguration?: ProxyConfiguration;
18
- log: Log;
19
- internalTimeoutMillis: number;
20
- requestLockSecs: number;
21
- assumedTotalCount: number;
22
- assumedHandledCount: number;
23
- private initialCount;
24
- protected queueHeadIds: ListDictionary<string>;
25
- protected requestCache: LruCache<RequestLruItem>;
26
- protected recentlyHandledRequestsCache: LruCache<boolean>;
27
- protected queuePausedForMigration: boolean;
28
- protected lastActivity: Date;
29
- protected isFinishedCalledWhileHeadWasNotEmpty: number;
30
- protected inProgressRequestBatchCount: number;
31
- constructor(options: InternalRequestProviderOptions, config?: Configuration);
32
- /**
33
- * Returns an offline approximation of the total number of requests in the queue (i.e. pending + handled).
34
- *
35
- * Survives restarts and actor migrations.
36
- */
37
- getTotalCount(): number;
38
- /**
39
- * Adds a request to the queue.
40
- *
41
- * If a request with the same `uniqueKey` property is already present in the queue,
42
- * it will not be updated. You can find out whether this happened from the resulting
43
- * {@link QueueOperationInfo} object.
44
- *
45
- * To add multiple requests to the queue by extracting links from a webpage,
46
- * see the {@link enqueueLinks} helper function.
47
- *
48
- * @param requestLike {@link Request} object or vanilla object with request data.
49
- * Note that the function sets the `uniqueKey` and `id` fields to the passed Request.
50
- * @param [options] Request queue operation options.
51
- */
52
- addRequest(requestLike: Source, options?: RequestQueueOperationOptions): Promise<RequestQueueOperationInfo>;
53
- /**
54
- * Adds requests to the queue in batches of 25. This method will wait till all the requests are added
55
- * to the queue before resolving. You should prefer using `queue.addRequestsBatched()` or `crawler.addRequests()`
56
- * if you don't want to block the processing, as those methods will only wait for the initial 1000 requests,
57
- * start processing right after that happens, and continue adding more in the background.
58
- *
59
- * If a request passed in is already present due to its `uniqueKey` property being the same,
60
- * it will not be updated. You can find out whether this happened by finding the request in the resulting
61
- * {@link BatchAddRequestsResult} object.
62
- *
63
- * @param requestsLike {@link Request} objects or vanilla objects with request data.
64
- * Note that the function sets the `uniqueKey` and `id` fields to the passed requests if missing.
65
- * @param [options] Request queue operation options.
66
- */
67
- addRequests(requestsLike: Source[], options?: RequestQueueOperationOptions): Promise<BatchAddRequestsResult>;
68
- /**
69
- * Adds requests to the queue in batches. By default, it will resolve after the initial batch is added, and continue
70
- * adding the rest in the background. You can configure the batch size via `batchSize` option and the sleep time in between
71
- * the batches via `waitBetweenBatchesMillis`. If you want to wait for all batches to be added to the queue, you can use
72
- * the `waitForAllRequestsToBeAdded` promise you get in the response object.
73
- *
74
- * @param requests The requests to add
75
- * @param options Options for the request queue
76
- */
77
- addRequestsBatched(requests: ReadonlyDeep<(string | Source)[]>, options?: AddRequestsBatchedOptions): Promise<AddRequestsBatchedResult>;
78
- /**
79
- * Gets the request from the queue specified by ID.
80
- *
81
- * @param id ID of the request.
82
- * @returns Returns the request object, or `null` if it was not found.
83
- */
84
- getRequest<T extends Dictionary = Dictionary>(id: string): Promise<Request<T> | null>;
85
- /**
86
- * Returns a next request in the queue to be processed, or `null` if there are no more pending requests.
87
- *
88
- * Once you successfully finish processing of the request, you need to call
89
- * {@link RequestQueue.markRequestHandled}
90
- * to mark the request as handled in the queue. If there was some error in processing the request,
91
- * call {@link RequestQueue.reclaimRequest} instead,
92
- * so that the queue will give the request to some other consumer in another call to the `fetchNextRequest` function.
93
- *
94
- * Note that the `null` return value doesn't mean the queue processing finished,
95
- * it means there are currently no pending requests.
96
- * To check whether all requests in queue were finished,
97
- * use {@link RequestQueue.isFinished} instead.
98
- *
99
- * @returns
100
- * Returns the request object or `null` if there are no more pending requests.
101
- */
102
- abstract fetchNextRequest<T extends Dictionary = Dictionary>(options?: RequestOptions): Promise<Request<T> | null>;
103
- /**
104
- * Marks a request that was previously returned by the
105
- * {@link RequestQueue.fetchNextRequest}
106
- * function as handled after successful processing.
107
- * Handled requests will never again be returned by the `fetchNextRequest` function.
108
- */
109
- markRequestHandled(request: Request): Promise<RequestQueueOperationInfo | null>;
110
- /**
111
- * Reclaims a failed request back to the queue, so that it can be returned for processing later again
112
- * by another call to {@link RequestQueue.fetchNextRequest}.
113
- * The request record in the queue is updated using the provided `request` parameter.
114
- * For example, this lets you store the number of retries or error messages for the request.
115
- */
116
- reclaimRequest(request: Request, options?: RequestQueueOperationOptions): Promise<RequestQueueOperationInfo | null>;
117
- protected abstract ensureHeadIsNonEmpty(): Promise<void>;
118
- /**
119
- * Resolves to `true` if the next call to {@link RequestQueue.fetchNextRequest}
120
- * would return `null`, otherwise it resolves to `false`.
121
- * Note that even if the queue is empty, there might be some pending requests currently being processed.
122
- * If you need to ensure that there is no activity in the queue, use {@link RequestQueue.isFinished}.
123
- */
124
- isEmpty(): Promise<boolean>;
125
- /**
126
- * Resolves to `true` if all requests were already handled and there are no more left.
127
- * Due to the nature of distributed storage used by the queue,
128
- * the function may occasionally return a false negative,
129
- * but it shall never return a false positive.
130
- */
131
- abstract isFinished(): Promise<boolean>;
132
- protected _reset(): void;
133
- /**
134
- * Caches information about request to beware of unneeded addRequest() calls.
135
- */
136
- protected _cacheRequest(cacheKey: string, queueOperationInfo: RequestQueueOperationInfo): void;
137
- /**
138
- * Adds a request straight to the queueHeadDict, to improve performance.
139
- */
140
- protected _maybeAddRequestToQueueHead(requestId: string, forefront: boolean): void;
141
- /**
142
- * Removes the queue either from the Apify Cloud storage or from the local database,
143
- * depending on the mode of operation.
144
- */
145
- drop(): Promise<void>;
146
- /**
147
- * Returns the number of handled requests.
148
- *
149
- * This function is just a convenient shortcut for:
150
- *
151
- * ```javascript
152
- * const { handledRequestCount } = await queue.getInfo();
153
- * ```
154
- */
155
- handledCount(): Promise<number>;
156
- /**
157
- * Returns an object containing general information about the request queue.
158
- *
159
- * The function returns the same object as the Apify API Client's
160
- * [getQueue](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-requestQueues)
161
- * function, which in turn calls the
162
- * [Get request queue](https://apify.com/docs/api/v2#/reference/request-queues/queue/get-request-queue)
163
- * API endpoint.
164
- *
165
- * **Example:**
166
- * ```
167
- * {
168
- * id: "WkzbQMuFYuamGv3YF",
169
- * name: "my-queue",
170
- * userId: "wRsJZtadYvn4mBZmm",
171
- * createdAt: new Date("2015-12-12T07:34:14.202Z"),
172
- * modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
173
- * accessedAt: new Date("2015-12-14T08:36:13.202Z"),
174
- * totalRequestCount: 25,
175
- * handledRequestCount: 5,
176
- * pendingRequestCount: 20,
177
- * }
178
- * ```
179
- */
180
- getInfo(): Promise<RequestQueueInfo | undefined>;
181
- /**
182
- * Fetches URLs from requestsFromUrl and returns them in format of list of requests
183
- */
184
- protected _fetchRequestsFromUrl(source: InternalSource): Promise<RequestOptions[]>;
185
- /**
186
- * Adds all fetched requests from a URL from a remote resource.
187
- */
188
- protected _addFetchedRequests(source: InternalSource, fetchedRequests: RequestOptions[], options: RequestQueueOperationOptions): Promise<ProcessedRequest[]>;
189
- /**
190
- * @internal wraps public utility for mocking purposes
191
- */
192
- private _downloadListOfUrls;
193
- /**
194
- * Opens a request queue and returns a promise resolving to an instance
195
- * of the {@link RequestQueue} class.
196
- *
197
- * {@link RequestQueue} represents a queue of URLs to crawl, which is stored either on local filesystem or in the cloud.
198
- * The queue is used for deep crawling of websites, where you start with several URLs and then
199
- * recursively follow links to other pages. The data structure supports both breadth-first
200
- * and depth-first crawling orders.
201
- *
202
- * For more details and code examples, see the {@link RequestQueue} class.
203
- *
204
- * @param [queueIdOrName]
205
- * ID or name of the request queue to be opened. If `null` or `undefined`,
206
- * the function returns the default request queue associated with the crawler run.
207
- * @param [options] Open Request Queue options.
208
- */
209
- static open(queueIdOrName?: string | null, options?: StorageManagerOptions): Promise<RequestProvider>;
210
- }
211
- interface RequestLruItem {
212
- uniqueKey: string;
213
- isHandled: boolean;
214
- id: string;
215
- hydrated: Request | null;
216
- lockExpiresAt: number | null;
217
- forefront: boolean;
218
- }
219
- export interface RequestProviderOptions {
220
- id: string;
221
- name?: string;
222
- client: StorageClient;
223
- /**
224
- * Used to pass the proxy configuration for the `requestsFromUrl` objects.
225
- * Takes advantage of the internal address rotation and authentication process.
226
- * If undefined, the `requestsFromUrl` requests will be made without proxy.
227
- */
228
- proxyConfiguration?: ProxyConfiguration;
229
- }
230
- /**
231
- * @deprecated Use {@link RequestProviderOptions} instead.
232
- */
233
- export interface RequestQueueOptions extends RequestProviderOptions {
234
- }
235
- /**
236
- * @internal
237
- */
238
- export interface InternalRequestProviderOptions extends RequestProviderOptions {
239
- logPrefix: string;
240
- requestCacheMaxSize: number;
241
- recentlyHandledRequestsMaxSize: number;
242
- }
243
- export interface RequestQueueOperationOptions {
244
- /**
245
- * If set to `true`:
246
- * - while adding the request to the queue: the request will be added to the foremost position in the queue.
247
- * - while reclaiming the request: the request will be placed to the beginning of the queue, so that it's returned
248
- * in the next call to {@link RequestQueue.fetchNextRequest}.
249
- * By default, it's put to the end of the queue.
250
- *
251
- * In case the request is already present in the queue, this option has no effect.
252
- *
253
- * If more requests are added with this option at once, their order in the following `fetchNextRequest` call
254
- * is arbitrary.
255
- * @default false
256
- */
257
- forefront?: boolean;
258
- /**
259
- * Should the requests be added to the local LRU cache?
260
- * @default false
261
- * @internal
262
- */
263
- cache?: boolean;
264
- }
265
- /**
266
- * @internal
267
- */
268
- export interface RequestQueueOperationInfo extends QueueOperationInfo {
269
- uniqueKey: string;
270
- forefront: boolean;
271
- }
272
- export interface AddRequestsBatchedOptions extends RequestQueueOperationOptions {
273
- /**
274
- * Whether to wait for all the provided requests to be added, instead of waiting just for the initial batch of up to `batchSize`.
275
- * @default false
276
- */
277
- waitForAllRequestsToBeAdded?: boolean;
278
- /**
279
- * @default 1000
280
- */
281
- batchSize?: number;
282
- /**
283
- * @default 1000
284
- */
285
- waitBetweenBatchesMillis?: number;
286
- }
287
- export interface AddRequestsBatchedResult {
288
- addedRequests: ProcessedRequest[];
289
- /**
290
- * A promise which will resolve with the rest of the requests that were added to the queue.
291
- *
292
- * Alternatively, we can set {@link AddRequestsBatchedOptions.waitForAllRequestsToBeAdded|`waitForAllRequestsToBeAdded`} to `true`
293
- * in the {@link BasicCrawler.addRequests|`crawler.addRequests()`} options.
294
- *
295
- * **Example:**
296
- *
297
- * ```ts
298
- * // Assuming `requests` is a list of requests.
299
- * const result = await crawler.addRequests(requests);
300
- *
301
- * // If we want to wait for the rest of the requests to be added to the queue:
302
- * await result.waitForAllRequestsToBeAdded;
303
- * ```
304
- */
305
- waitForAllRequestsToBeAdded: Promise<ProcessedRequest[]>;
306
- }
307
- export {};
308
- //# sourceMappingURL=request_provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request_provider.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