@crawlee/core 4.0.0-rc.0 → 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 +15 -46
- package/configuration.js +8 -20
- package/errors.d.ts +12 -53
- package/errors.js +13 -66
- package/events/index.d.ts +1 -0
- package/events/local_event_manager.d.ts +0 -7
- package/events/local_event_manager.js +8 -8
- 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 +53 -25
- package/memory-storage/memory-storage.d.ts +12 -7
- package/memory-storage/memory-storage.js +45 -17
- package/memory-storage/resource-clients/dataset.d.ts +0 -5
- package/memory-storage/resource-clients/dataset.js +17 -20
- package/memory-storage/resource-clients/key-value-store.d.ts +0 -9
- package/memory-storage/resource-clients/key-value-store.js +11 -33
- package/memory-storage/resource-clients/request-queue.d.ts +0 -22
- package/memory-storage/resource-clients/request-queue.js +57 -53
- package/package.json +16 -18
- package/proxy_configuration.d.ts +20 -23
- package/proxy_configuration.js +18 -12
- package/recoverable_state.d.ts +28 -6
- package/recoverable_state.js +51 -14
- package/request.d.ts +18 -104
- package/request.js +41 -220
- package/serialization.js +3 -3
- package/service_locator.d.ts +3 -0
- package/service_locator.js +2 -0
- package/storages/dataset.d.ts +9 -15
- package/storages/dataset.js +22 -14
- package/storages/index.d.ts +3 -4
- package/storages/index.js +1 -4
- package/storages/key_value_store.d.ts +12 -46
- package/storages/key_value_store.js +31 -47
- package/storages/key_value_store_codec.js +6 -11
- package/storages/request_dedup_cache.d.ts +0 -2
- package/storages/request_dedup_cache.js +8 -8
- package/storages/request_list.d.ts +6 -82
- package/storages/request_list.js +175 -179
- package/storages/request_loader.d.ts +48 -22
- package/storages/request_loader.js +36 -1
- package/storages/request_manager.d.ts +86 -0
- package/storages/request_manager_tandem.d.ts +13 -28
- package/storages/request_manager_tandem.js +46 -43
- package/storages/request_queue.d.ts +19 -49
- package/storages/request_queue.js +92 -88
- package/storages/storage_instance_manager.d.ts +1 -2
- package/storages/storage_instance_manager.js +4 -4
- package/storages/transaction.d.ts +27 -9
- package/storages/transaction.js +56 -11
- package/storages/utils.d.ts +2 -2
- package/validators.d.ts +3 -2
- package/validators.js +3 -2
- package/autoscaling/autoscaled_pool.d.ts +0 -195
- package/autoscaling/autoscaled_pool.js +0 -386
- package/autoscaling/concurrency_system.d.ts +0 -268
- package/autoscaling/concurrency_system.js +0 -362
- package/autoscaling/cpu_load_signal.d.ts +0 -43
- package/autoscaling/cpu_load_signal.js +0 -47
- package/autoscaling/event_loop_load_signal.d.ts +0 -51
- 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 -100
- package/autoscaling/load_signal.js +0 -105
- package/autoscaling/memory_load_signal.d.ts +0 -47
- package/autoscaling/memory_load_signal.js +0 -106
- package/autoscaling/snapshotter.d.ts +0 -84
- package/autoscaling/snapshotter.js +0 -67
- package/autoscaling/storage_backend_load_signal.d.ts +0 -56
- package/autoscaling/storage_backend_load_signal.js +0 -73
- package/autoscaling/system_status.d.ts +0 -159
- 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 -159
- package/crawlers/error_snapshotter.d.ts +0 -57
- 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 -4
- package/crawlers/internals/types.d.ts +0 -7
- package/crawlers/internals/types.js +0 -1
- package/crawlers/statistics.d.ts +0 -328
- package/crawlers/statistics.js +0 -536
- package/enqueue_links/enqueue_links.d.ts +0 -156
- package/enqueue_links/enqueue_links.js +0 -78
- package/enqueue_links/index.d.ts +0 -2
- package/enqueue_links/index.js +0 -2
- package/enqueue_links/shared.d.ts +0 -93
- package/enqueue_links/shared.js +0 -239
- package/http.d.ts +0 -9
- package/http.js +0 -28
- package/router.d.ts +0 -306
- 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 -150
- package/session_pool/session.js +0 -220
- package/session_pool/session_pool.d.ts +0 -240
- package/session_pool/session_pool.js +0 -394
- package/storages/sitemap_request_loader.d.ts +0 -201
- package/storages/sitemap_request_loader.js +0 -438
- package/storages/throttling_request_manager.d.ts +0 -239
- package/storages/throttling_request_manager.js +0 -646
- /package/{crawlers/crawler_commons.js → events/system_info.js} +0 -0
|
@@ -12,37 +12,37 @@
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export class RequestDeduplicationCache {
|
|
15
|
-
size;
|
|
16
15
|
#keys;
|
|
17
16
|
#ids;
|
|
17
|
+
#size;
|
|
18
18
|
// The slot count is the same for every queue, so it's a fixed default rather than a per-consumer option.
|
|
19
19
|
constructor(size = 1_000_000) {
|
|
20
|
-
this
|
|
20
|
+
this.#size = size;
|
|
21
21
|
this.#keys = new Array(size);
|
|
22
22
|
this.#ids = new Array(size);
|
|
23
23
|
}
|
|
24
24
|
get(cacheKey) {
|
|
25
|
-
const index = this
|
|
25
|
+
const index = this.#indexOf(cacheKey);
|
|
26
26
|
return this.#keys[index] === cacheKey ? this.#ids[index] : null;
|
|
27
27
|
}
|
|
28
28
|
add(cacheKey, requestId) {
|
|
29
|
-
const index = this
|
|
29
|
+
const index = this.#indexOf(cacheKey);
|
|
30
30
|
this.#keys[index] = cacheKey;
|
|
31
31
|
this.#ids[index] = requestId;
|
|
32
32
|
}
|
|
33
33
|
clear() {
|
|
34
|
-
this.#keys = new Array(this
|
|
35
|
-
this.#ids = new Array(this
|
|
34
|
+
this.#keys = new Array(this.#size);
|
|
35
|
+
this.#ids = new Array(this.#size);
|
|
36
36
|
}
|
|
37
37
|
// A cheap FNV-1a hash of the cache key — avoids pulling in a dedicated hashing dependency.
|
|
38
|
-
indexOf(cacheKey) {
|
|
38
|
+
#indexOf(cacheKey) {
|
|
39
39
|
/* eslint-disable no-bitwise */
|
|
40
40
|
let hash = 0x811c9dc5;
|
|
41
41
|
for (let i = 0; i < cacheKey.length; i++) {
|
|
42
42
|
hash ^= cacheKey.charCodeAt(i);
|
|
43
43
|
hash = Math.imul(hash, 0x01000193);
|
|
44
44
|
}
|
|
45
|
-
return (hash >>> 0) % this
|
|
45
|
+
return (hash >>> 0) % this.#size;
|
|
46
46
|
/* eslint-enable no-bitwise */
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -3,7 +3,7 @@ import type { Dictionary } from '@crawlee/types';
|
|
|
3
3
|
import type { Configuration } from '../configuration.js';
|
|
4
4
|
import type { IProxyConfiguration } from '../proxy_configuration.js';
|
|
5
5
|
import { Request, type RequestOptions, type Source } from '../request.js';
|
|
6
|
-
import type { IRequestLoader } from './request_loader.js';
|
|
6
|
+
import type { IRequestLoader, RequestLoaderStatus } from './request_loader.js';
|
|
7
7
|
import type { IRequestManager } from './request_manager.js';
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare const STATE_PERSISTENCE_KEY = "REQUEST_LIST_STATE";
|
|
@@ -127,7 +127,8 @@ export interface RequestListOptions {
|
|
|
127
127
|
* ```
|
|
128
128
|
*
|
|
129
129
|
* Note that the preferred (and simpler) way to persist the state of crawling of the `RequestList`
|
|
130
|
-
* 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.
|
|
131
132
|
*/
|
|
132
133
|
state?: RequestListState;
|
|
133
134
|
/**
|
|
@@ -228,42 +229,18 @@ export declare class RequestList implements IRequestLoader {
|
|
|
228
229
|
* Set of `uniqueKey`s of requests that were returned by fetchNextRequest().
|
|
229
230
|
* @internal
|
|
230
231
|
*/
|
|
231
|
-
inProgress: Set<string>;
|
|
232
|
-
/**
|
|
233
|
-
* Starts as true because until we handle the first request, the list is effectively persisted by doing nothing.
|
|
234
|
-
* @internal
|
|
235
|
-
*/
|
|
236
|
-
isStatePersisted: boolean;
|
|
232
|
+
get inProgress(): Set<string>;
|
|
237
233
|
/**
|
|
238
234
|
* Starts as false because we don't know yet and sources might change in the meantime (eg. download from live list).
|
|
239
235
|
* @internal
|
|
240
236
|
*/
|
|
241
237
|
areRequestsPersisted: boolean;
|
|
242
|
-
private sources;
|
|
243
238
|
/**
|
|
244
239
|
* To create new instance of `RequestList` we need to use `RequestList.open()` factory method.
|
|
245
240
|
* @param options All `RequestList` configuration options
|
|
246
241
|
* @internal
|
|
247
242
|
*/
|
|
248
243
|
private constructor();
|
|
249
|
-
/**
|
|
250
|
-
* Loads all remote sources of URLs and potentially starts periodic state persistence.
|
|
251
|
-
* This function must be called before you can start using the instance in a meaningful way.
|
|
252
|
-
*/
|
|
253
|
-
private initialize;
|
|
254
|
-
/**
|
|
255
|
-
* Adds previously persisted Requests, as retrieved from the key-value store.
|
|
256
|
-
* This needs to be done in a memory efficient way. We should update the input
|
|
257
|
-
* to a Stream once apify-client supports streams.
|
|
258
|
-
*/
|
|
259
|
-
private addPersistedRequests;
|
|
260
|
-
/**
|
|
261
|
-
* Add Requests from both options.sources and options.sourcesFunction.
|
|
262
|
-
* This function is called only when persisted sources were not loaded.
|
|
263
|
-
* We need to avoid keeping both sources and requests in memory
|
|
264
|
-
* to reduce memory footprint with very large sources.
|
|
265
|
-
*/
|
|
266
|
-
private addRequestsFromSources;
|
|
267
244
|
/**
|
|
268
245
|
* @inheritDoc
|
|
269
246
|
*/
|
|
@@ -274,21 +251,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
274
251
|
* leaking the listener (and the requests it retains) on the shared event manager.
|
|
275
252
|
*/
|
|
276
253
|
teardown(): Promise<void>;
|
|
277
|
-
/**
|
|
278
|
-
* Unlike persistState(), this is used only internally, since the sources
|
|
279
|
-
* are automatically persisted at RequestList initialization (if the persistRequestsKey is set),
|
|
280
|
-
* but there's no reason to persist it again afterwards, because RequestList is immutable.
|
|
281
|
-
*/
|
|
282
|
-
private persistRequests;
|
|
283
|
-
/**
|
|
284
|
-
* Restores RequestList state from a state object.
|
|
285
|
-
*/
|
|
286
|
-
private restoreState;
|
|
287
|
-
/**
|
|
288
|
-
* Attempts to load state and requests using the `RequestList` configuration
|
|
289
|
-
* and returns a tuple of [state, requests] where each may be null if not loaded.
|
|
290
|
-
*/
|
|
291
|
-
private loadStateAndPersistedRequests;
|
|
292
254
|
/**
|
|
293
255
|
* Returns an object representing the internal state of the `RequestList` instance.
|
|
294
256
|
* Note that the object's fields can change in future releases.
|
|
@@ -297,11 +259,7 @@ export declare class RequestList implements IRequestLoader {
|
|
|
297
259
|
/**
|
|
298
260
|
* @inheritDoc
|
|
299
261
|
*/
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* @inheritDoc
|
|
303
|
-
*/
|
|
304
|
-
isFinished(): Promise<boolean>;
|
|
262
|
+
checkReadiness(): Promise<RequestLoaderStatus>;
|
|
305
263
|
/**
|
|
306
264
|
* @inheritDoc
|
|
307
265
|
*/
|
|
@@ -310,39 +268,10 @@ export declare class RequestList implements IRequestLoader {
|
|
|
310
268
|
* @inheritDoc
|
|
311
269
|
*/
|
|
312
270
|
[Symbol.asyncIterator](): AsyncGenerator<Request<Dictionary>, void, unknown>;
|
|
313
|
-
private ensureRequest;
|
|
314
271
|
/**
|
|
315
272
|
* @inheritDoc
|
|
316
273
|
*/
|
|
317
274
|
markRequestAsHandled(request: Request): Promise<void>;
|
|
318
|
-
/**
|
|
319
|
-
* Adds all fetched requests from a URL from a remote resource.
|
|
320
|
-
*/
|
|
321
|
-
private addFetchedRequests;
|
|
322
|
-
private getPersistedState;
|
|
323
|
-
/**
|
|
324
|
-
* Fetches URLs from requestsFromUrl and returns them in format of list of requests
|
|
325
|
-
*/
|
|
326
|
-
private fetchRequestsFromUrl;
|
|
327
|
-
/**
|
|
328
|
-
* Adds given request.
|
|
329
|
-
* If the `source` parameter is a string or plain object and not an instance
|
|
330
|
-
* of a `Request`, then the function creates a `Request` instance.
|
|
331
|
-
*/
|
|
332
|
-
private addRequest;
|
|
333
|
-
/**
|
|
334
|
-
* Helper function that validates unique key.
|
|
335
|
-
* Throws an error if uniqueKey is not a non-empty string.
|
|
336
|
-
*/
|
|
337
|
-
private ensureUniqueKeyValid;
|
|
338
|
-
/**
|
|
339
|
-
* Checks that a request is currently being processed and throws an error if not.
|
|
340
|
-
*/
|
|
341
|
-
private ensureInProgress;
|
|
342
|
-
/**
|
|
343
|
-
* Throws an error if request list wasn't initialized.
|
|
344
|
-
*/
|
|
345
|
-
private ensureIsInitialized;
|
|
346
275
|
/**
|
|
347
276
|
* Returns the total number of unique requests present in the `RequestList`.
|
|
348
277
|
*/
|
|
@@ -415,10 +344,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
415
344
|
* options and the `sources` parameter supersedes the {@link RequestListOptions.sources} option.
|
|
416
345
|
*/
|
|
417
346
|
static open(listNameOrOptions: string | null | RequestListOptions, sources?: RequestListSource[], options?: RequestListOptions): Promise<RequestList>;
|
|
418
|
-
/**
|
|
419
|
-
* @internal wraps public utility for mocking purposes
|
|
420
|
-
*/
|
|
421
|
-
private downloadListOfUrls;
|
|
422
347
|
}
|
|
423
348
|
/**
|
|
424
349
|
* Represents state of a {@link RequestList}. It can be used to resume a {@link RequestList} which has been previously processed.
|
|
@@ -444,6 +369,5 @@ export interface RequestListState {
|
|
|
444
369
|
/** Array of request keys representing those that being processed at the moment. */
|
|
445
370
|
inProgress: string[];
|
|
446
371
|
}
|
|
447
|
-
type RequestListSource = string | Source;
|
|
372
|
+
export type RequestListSource = string | Source;
|
|
448
373
|
export type RequestListSourcesFunction = () => Promise<RequestListSource[]>;
|
|
449
|
-
export {};
|