@crawlee/core 4.0.0-beta.99 → 4.0.0-rc.1
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/README.md +1 -1
- package/configuration.d.ts +16 -47
- package/configuration.js +13 -25
- package/debug.js +4 -4
- package/errors.d.ts +28 -38
- package/errors.js +33 -47
- package/events/event_manager.d.ts +2 -2
- package/events/event_manager.js +7 -6
- package/events/index.d.ts +1 -0
- package/events/local_event_manager.d.ts +1 -8
- package/events/local_event_manager.js +13 -13
- package/events/system_info.d.ts +38 -0
- package/index.d.ts +2 -8
- package/index.js +4 -8
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/log.d.ts +10 -11
- package/log.js +52 -20
- package/memory-storage/memory-storage.d.ts +15 -18
- package/memory-storage/memory-storage.js +80 -58
- package/memory-storage/resource-clients/dataset.d.ts +1 -6
- package/memory-storage/resource-clients/dataset.js +23 -31
- package/memory-storage/resource-clients/key-value-store.d.ts +1 -10
- package/memory-storage/resource-clients/key-value-store.js +43 -67
- package/memory-storage/resource-clients/request-queue.d.ts +1 -42
- package/memory-storage/resource-clients/request-queue.js +109 -117
- package/owned_or_injected.d.ts +1 -3
- package/owned_or_injected.js +17 -17
- package/package.json +17 -20
- package/proxy_configuration.d.ts +21 -26
- package/proxy_configuration.js +35 -25
- package/recoverable_state.d.ts +104 -47
- package/recoverable_state.js +199 -74
- package/request.d.ts +20 -107
- package/request.js +78 -244
- package/serialization.js +17 -16
- package/service_locator.d.ts +22 -10
- package/service_locator.js +59 -48
- package/storages/batched_adds.d.ts +37 -0
- package/storages/batched_adds.js +73 -0
- package/storages/dataset.d.ts +13 -8
- package/storages/dataset.js +149 -40
- package/storages/index.d.ts +4 -4
- package/storages/index.js +2 -4
- package/storages/key_value_store.d.ts +16 -35
- package/storages/key_value_store.js +223 -110
- package/storages/key_value_store_codec.js +6 -11
- package/storages/request_dedup_cache.d.ts +1 -4
- package/storages/request_dedup_cache.js +15 -15
- package/storages/request_list.d.ts +9 -104
- package/storages/request_list.js +236 -233
- package/storages/request_loader.d.ts +49 -18
- package/storages/request_loader.js +36 -1
- package/storages/request_manager.d.ts +86 -0
- package/storages/request_manager_tandem.d.ts +14 -38
- package/storages/request_manager_tandem.js +67 -64
- package/storages/request_queue.d.ts +23 -50
- package/storages/request_queue.js +371 -226
- package/storages/storage_instance_manager.d.ts +2 -4
- package/storages/storage_instance_manager.js +21 -21
- package/storages/storage_stats.d.ts +1 -1
- package/storages/storage_stats.js +4 -4
- package/storages/transaction.d.ts +270 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +6 -3
- package/storages/utils.js +11 -2
- package/system-info/runtime.js +7 -7
- package/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -25
- package/validators.js +14 -25
- package/autoscaling/autoscaled_pool.d.ts +0 -213
- package/autoscaling/autoscaled_pool.js +0 -378
- package/autoscaling/client_load_signal.d.ts +0 -59
- package/autoscaling/client_load_signal.js +0 -73
- package/autoscaling/concurrency_system.d.ts +0 -283
- package/autoscaling/concurrency_system.js +0 -350
- package/autoscaling/cpu_load_signal.d.ts +0 -44
- package/autoscaling/cpu_load_signal.js +0 -46
- package/autoscaling/event_loop_load_signal.d.ts +0 -54
- package/autoscaling/event_loop_load_signal.js +0 -60
- package/autoscaling/index.d.ts +0 -9
- package/autoscaling/index.js +0 -9
- package/autoscaling/load_signal.d.ts +0 -99
- package/autoscaling/load_signal.js +0 -103
- package/autoscaling/memory_load_signal.d.ts +0 -56
- package/autoscaling/memory_load_signal.js +0 -106
- package/autoscaling/snapshotter.d.ts +0 -87
- package/autoscaling/snapshotter.js +0 -67
- package/autoscaling/system_status.d.ts +0 -161
- package/autoscaling/system_status.js +0 -139
- package/autoscaling/weighted_avg.d.ts +0 -5
- package/autoscaling/weighted_avg.js +0 -14
- package/cookie_utils.d.ts +0 -44
- package/cookie_utils.js +0 -122
- package/crawlers/context_pipeline.d.ts +0 -70
- package/crawlers/context_pipeline.js +0 -122
- package/crawlers/crawler_commons.d.ts +0 -257
- package/crawlers/crawler_commons.js +0 -107
- package/crawlers/error_snapshotter.d.ts +0 -59
- package/crawlers/error_snapshotter.js +0 -117
- package/crawlers/error_tracker.d.ts +0 -54
- package/crawlers/error_tracker.js +0 -308
- package/crawlers/index.d.ts +0 -5
- package/crawlers/index.js +0 -5
- package/crawlers/internals/types.d.ts +0 -7
- package/crawlers/statistics.d.ts +0 -209
- package/crawlers/statistics.js +0 -350
- package/enqueue_links/enqueue_links.d.ts +0 -264
- package/enqueue_links/enqueue_links.js +0 -271
- package/enqueue_links/index.d.ts +0 -2
- package/enqueue_links/index.js +0 -2
- package/enqueue_links/shared.d.ts +0 -83
- package/enqueue_links/shared.js +0 -221
- package/router.d.ts +0 -309
- package/router.js +0 -309
- package/session_pool/consts.d.ts +0 -3
- package/session_pool/consts.js +0 -3
- package/session_pool/errors.d.ts +0 -7
- package/session_pool/errors.js +0 -11
- package/session_pool/fingerprint.d.ts +0 -9
- package/session_pool/fingerprint.js +0 -30
- package/session_pool/index.d.ts +0 -4
- package/session_pool/index.js +0 -4
- package/session_pool/session.d.ts +0 -161
- package/session_pool/session.js +0 -218
- package/session_pool/session_pool.d.ts +0 -246
- package/session_pool/session_pool.js +0 -386
- package/storages/access_checking.d.ts +0 -12
- package/storages/access_checking.js +0 -17
- package/storages/sitemap_request_loader.d.ts +0 -249
- package/storages/sitemap_request_loader.js +0 -432
- /package/{crawlers/internals/types.js → events/system_info.js} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { BaseHttpClient
|
|
1
|
+
import type { BaseHttpClient } from '@crawlee/http-client';
|
|
2
|
+
import type { Dictionary } from '@crawlee/types';
|
|
2
3
|
import type { Configuration } from '../configuration.js';
|
|
3
4
|
import type { IProxyConfiguration } from '../proxy_configuration.js';
|
|
4
5
|
import { Request, type RequestOptions, type Source } from '../request.js';
|
|
5
|
-
import type { IRequestLoader } from './request_loader.js';
|
|
6
|
+
import type { IRequestLoader, RequestLoaderStatus } from './request_loader.js';
|
|
6
7
|
import type { IRequestManager } from './request_manager.js';
|
|
7
8
|
/** @internal */
|
|
8
9
|
export declare const STATE_PERSISTENCE_KEY = "REQUEST_LIST_STATE";
|
|
@@ -126,7 +127,8 @@ export interface RequestListOptions {
|
|
|
126
127
|
* ```
|
|
127
128
|
*
|
|
128
129
|
* Note that the preferred (and simpler) way to persist the state of crawling of the `RequestList`
|
|
129
|
-
* is to use the `stateKeyPrefix` parameter instead.
|
|
130
|
+
* is to use the `stateKeyPrefix` parameter instead. When both are set, a record persisted under
|
|
131
|
+
* {@link RequestListOptions.persistStateKey} takes precedence over this option.
|
|
130
132
|
*/
|
|
131
133
|
state?: RequestListState;
|
|
132
134
|
/**
|
|
@@ -216,73 +218,29 @@ export interface RequestListOptions {
|
|
|
216
218
|
* @category Sources
|
|
217
219
|
*/
|
|
218
220
|
export declare class RequestList implements IRequestLoader {
|
|
219
|
-
private
|
|
221
|
+
#private;
|
|
220
222
|
/**
|
|
221
223
|
* Array of all requests from all sources, in the order as they appeared in sources.
|
|
222
224
|
* All requests in the array have distinct uniqueKey!
|
|
223
225
|
* @internal
|
|
224
226
|
*/
|
|
225
227
|
readonly requests: (Request | RequestOptions)[];
|
|
226
|
-
/** Index to the next item in requests array to fetch. All previous requests are either handled or in progress. */
|
|
227
|
-
private nextIndex;
|
|
228
|
-
/** Dictionary, key is Request.uniqueKey, value is corresponding index in the requests array. */
|
|
229
|
-
private uniqueKeyToIndex;
|
|
230
228
|
/**
|
|
231
229
|
* Set of `uniqueKey`s of requests that were returned by fetchNextRequest().
|
|
232
230
|
* @internal
|
|
233
231
|
*/
|
|
234
|
-
inProgress: Set<string>;
|
|
235
|
-
/**
|
|
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.
|
|
238
|
-
* @internal
|
|
239
|
-
*/
|
|
240
|
-
private requestsToRetry;
|
|
241
|
-
/**
|
|
242
|
-
* Starts as true because until we handle the first request, the list is effectively persisted by doing nothing.
|
|
243
|
-
* @internal
|
|
244
|
-
*/
|
|
245
|
-
isStatePersisted: boolean;
|
|
232
|
+
get inProgress(): Set<string>;
|
|
246
233
|
/**
|
|
247
234
|
* Starts as false because we don't know yet and sources might change in the meantime (eg. download from live list).
|
|
248
235
|
* @internal
|
|
249
236
|
*/
|
|
250
237
|
areRequestsPersisted: boolean;
|
|
251
|
-
private isLoading;
|
|
252
|
-
private isInitialized;
|
|
253
|
-
private persistStateKey?;
|
|
254
|
-
private persistRequestsKey?;
|
|
255
|
-
private initialState?;
|
|
256
|
-
private store?;
|
|
257
|
-
private keepDuplicateUrls;
|
|
258
|
-
private sources;
|
|
259
|
-
private sourcesFunction?;
|
|
260
|
-
private proxyConfiguration?;
|
|
261
|
-
private httpClient?;
|
|
262
238
|
/**
|
|
263
239
|
* To create new instance of `RequestList` we need to use `RequestList.open()` factory method.
|
|
264
240
|
* @param options All `RequestList` configuration options
|
|
265
241
|
* @internal
|
|
266
242
|
*/
|
|
267
243
|
private constructor();
|
|
268
|
-
/**
|
|
269
|
-
* Loads all remote sources of URLs and potentially starts periodic state persistence.
|
|
270
|
-
* This function must be called before you can start using the instance in a meaningful way.
|
|
271
|
-
*/
|
|
272
|
-
private initialize;
|
|
273
|
-
/**
|
|
274
|
-
* Adds previously persisted Requests, as retrieved from the key-value store.
|
|
275
|
-
* This needs to be done in a memory efficient way. We should update the input
|
|
276
|
-
* to a Stream once apify-client supports streams.
|
|
277
|
-
*/
|
|
278
|
-
private addPersistedRequests;
|
|
279
|
-
/**
|
|
280
|
-
* Add Requests from both options.sources and options.sourcesFunction.
|
|
281
|
-
* This function is called only when persisted sources were not loaded.
|
|
282
|
-
* We need to avoid keeping both sources and requests in memory
|
|
283
|
-
* to reduce memory footprint with very large sources.
|
|
284
|
-
*/
|
|
285
|
-
private addRequestsFromSources;
|
|
286
244
|
/**
|
|
287
245
|
* @inheritDoc
|
|
288
246
|
*/
|
|
@@ -293,21 +251,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
293
251
|
* leaking the listener (and the requests it retains) on the shared event manager.
|
|
294
252
|
*/
|
|
295
253
|
teardown(): Promise<void>;
|
|
296
|
-
/**
|
|
297
|
-
* Unlike persistState(), this is used only internally, since the sources
|
|
298
|
-
* are automatically persisted at RequestList initialization (if the persistRequestsKey is set),
|
|
299
|
-
* but there's no reason to persist it again afterwards, because RequestList is immutable.
|
|
300
|
-
*/
|
|
301
|
-
private persistRequests;
|
|
302
|
-
/**
|
|
303
|
-
* Restores RequestList state from a state object.
|
|
304
|
-
*/
|
|
305
|
-
private restoreState;
|
|
306
|
-
/**
|
|
307
|
-
* Attempts to load state and requests using the `RequestList` configuration
|
|
308
|
-
* and returns a tuple of [state, requests] where each may be null if not loaded.
|
|
309
|
-
*/
|
|
310
|
-
private loadStateAndPersistedRequests;
|
|
311
254
|
/**
|
|
312
255
|
* Returns an object representing the internal state of the `RequestList` instance.
|
|
313
256
|
* Note that the object's fields can change in future releases.
|
|
@@ -316,11 +259,7 @@ export declare class RequestList implements IRequestLoader {
|
|
|
316
259
|
/**
|
|
317
260
|
* @inheritDoc
|
|
318
261
|
*/
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* @inheritDoc
|
|
322
|
-
*/
|
|
323
|
-
isFinished(): Promise<boolean>;
|
|
262
|
+
checkReadiness(): Promise<RequestLoaderStatus>;
|
|
324
263
|
/**
|
|
325
264
|
* @inheritDoc
|
|
326
265
|
*/
|
|
@@ -329,39 +268,10 @@ export declare class RequestList implements IRequestLoader {
|
|
|
329
268
|
* @inheritDoc
|
|
330
269
|
*/
|
|
331
270
|
[Symbol.asyncIterator](): AsyncGenerator<Request<Dictionary>, void, unknown>;
|
|
332
|
-
private ensureRequest;
|
|
333
271
|
/**
|
|
334
272
|
* @inheritDoc
|
|
335
273
|
*/
|
|
336
274
|
markRequestAsHandled(request: Request): Promise<void>;
|
|
337
|
-
/**
|
|
338
|
-
* Adds all fetched requests from a URL from a remote resource.
|
|
339
|
-
*/
|
|
340
|
-
private addFetchedRequests;
|
|
341
|
-
private getPersistedState;
|
|
342
|
-
/**
|
|
343
|
-
* Fetches URLs from requestsFromUrl and returns them in format of list of requests
|
|
344
|
-
*/
|
|
345
|
-
private fetchRequestsFromUrl;
|
|
346
|
-
/**
|
|
347
|
-
* Adds given request.
|
|
348
|
-
* If the `source` parameter is a string or plain object and not an instance
|
|
349
|
-
* of a `Request`, then the function creates a `Request` instance.
|
|
350
|
-
*/
|
|
351
|
-
private addRequest;
|
|
352
|
-
/**
|
|
353
|
-
* Helper function that validates unique key.
|
|
354
|
-
* Throws an error if uniqueKey is not a non-empty string.
|
|
355
|
-
*/
|
|
356
|
-
private ensureUniqueKeyValid;
|
|
357
|
-
/**
|
|
358
|
-
* Checks that a request is currently being processed and throws an error if not.
|
|
359
|
-
*/
|
|
360
|
-
private ensureInProgress;
|
|
361
|
-
/**
|
|
362
|
-
* Throws an error if request list wasn't initialized.
|
|
363
|
-
*/
|
|
364
|
-
private ensureIsInitialized;
|
|
365
275
|
/**
|
|
366
276
|
* Returns the total number of unique requests present in the `RequestList`.
|
|
367
277
|
*/
|
|
@@ -434,10 +344,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
434
344
|
* options and the `sources` parameter supersedes the {@link RequestListOptions.sources} option.
|
|
435
345
|
*/
|
|
436
346
|
static open(listNameOrOptions: string | null | RequestListOptions, sources?: RequestListSource[], options?: RequestListOptions): Promise<RequestList>;
|
|
437
|
-
/**
|
|
438
|
-
* @internal wraps public utility for mocking purposes
|
|
439
|
-
*/
|
|
440
|
-
private _downloadListOfUrls;
|
|
441
347
|
}
|
|
442
348
|
/**
|
|
443
349
|
* Represents state of a {@link RequestList}. It can be used to resume a {@link RequestList} which has been previously processed.
|
|
@@ -463,6 +369,5 @@ export interface RequestListState {
|
|
|
463
369
|
/** Array of request keys representing those that being processed at the moment. */
|
|
464
370
|
inProgress: string[];
|
|
465
371
|
}
|
|
466
|
-
type RequestListSource = string | Source;
|
|
372
|
+
export type RequestListSource = string | Source;
|
|
467
373
|
export type RequestListSourcesFunction = () => Promise<RequestListSource[]>;
|
|
468
|
-
export {};
|