@crawlee/core 4.0.0-beta.28 → 4.0.0-beta.280
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 +15 -15
- package/byte-utils.d.ts +17 -0
- package/byte-utils.js +42 -0
- package/configuration.d.ts +75 -167
- package/configuration.js +164 -140
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/errors.d.ts +40 -19
- package/errors.js +52 -30
- package/events/{event_manager.d.ts → event-manager.d.ts} +29 -6
- package/events/{event_manager.js → event-manager.js} +10 -9
- package/events/index.d.ts +3 -3
- package/events/index.js +2 -3
- package/events/{local_event_manager.d.ts → local-event-manager.d.ts} +3 -10
- package/events/local-event-manager.js +101 -0
- package/events/system-info.d.ts +38 -0
- package/events/system-info.js +1 -0
- package/index.d.ts +9 -13
- package/index.js +10 -12
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +77 -1
- package/log.js +134 -1
- package/memory-storage/consts.d.ts +4 -0
- package/memory-storage/consts.js +4 -0
- package/memory-storage/index.d.ts +1 -0
- package/memory-storage/index.js +1 -0
- package/memory-storage/memory-storage.d.ts +43 -0
- package/memory-storage/memory-storage.js +158 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
- package/memory-storage/resource-clients/common/base-client.js +6 -0
- package/memory-storage/resource-clients/dataset.d.ts +35 -0
- package/memory-storage/resource-clients/dataset.js +108 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +54 -0
- package/memory-storage/resource-clients/key-value-store.js +179 -0
- package/memory-storage/resource-clients/request-queue.d.ts +55 -0
- package/memory-storage/resource-clients/request-queue.js +413 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned-or-injected.d.ts +58 -0
- package/owned-or-injected.js +98 -0
- package/package.json +23 -23
- package/proxy-configuration.d.ts +118 -0
- package/proxy-configuration.js +141 -0
- package/recoverable-state.d.ts +177 -0
- package/recoverable-state.js +268 -0
- package/request.d.ts +48 -101
- package/request.js +139 -249
- package/serialization.d.ts +0 -1
- package/serialization.js +18 -18
- package/{service_locator.d.ts → service-locator.d.ts} +66 -37
- package/service-locator.js +255 -0
- package/storages/batched-adds.d.ts +39 -0
- package/storages/batched-adds.js +81 -0
- package/storages/dataset.d.ts +105 -58
- package/storages/dataset.js +292 -151
- package/storages/index.d.ts +11 -12
- package/storages/index.js +7 -12
- package/storages/key-value-store-codec.d.ts +32 -0
- package/storages/key-value-store-codec.js +108 -0
- package/storages/{key_value_store.d.ts → key-value-store.d.ts} +169 -72
- package/storages/key-value-store.js +767 -0
- package/storages/request-dedup-cache.d.ts +20 -0
- package/storages/request-dedup-cache.js +48 -0
- package/storages/{request_list.d.ts → request-list.d.ts} +32 -171
- package/storages/{request_list.js → request-list.js} +276 -253
- package/storages/request-loader.d.ts +127 -0
- package/storages/request-loader.js +34 -0
- package/storages/request-manager-tandem.d.ts +82 -0
- package/storages/request-manager-tandem.js +200 -0
- package/storages/request-manager.d.ts +119 -0
- package/storages/request-manager.js +1 -0
- package/storages/{request_provider.d.ts → request-queue.d.ts} +127 -161
- package/storages/request-queue.js +871 -0
- package/storages/storage-instance-manager.d.ts +86 -0
- package/storages/storage-instance-manager.js +256 -0
- package/storages/storage-stats.d.ts +48 -0
- package/storages/storage-stats.js +29 -0
- package/storages/transaction.d.ts +270 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +59 -11
- package/storages/utils.js +76 -17
- package/system-info/cpu-info.d.ts +67 -0
- package/system-info/cpu-info.js +216 -0
- package/system-info/memory-info.d.ts +31 -0
- package/system-info/memory-info.js +115 -0
- package/system-info/ps-tree.d.ts +17 -0
- package/system-info/ps-tree.js +144 -0
- package/system-info/runtime.d.ts +14 -0
- package/system-info/runtime.js +80 -0
- package/typedefs.d.ts +0 -6
- package/typedefs.js +0 -1
- package/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -18
- package/validators.js +14 -18
- package/autoscaling/autoscaled_pool.d.ts +0 -298
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js +0 -527
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts +0 -4
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js +0 -4
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts +0 -179
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js +0 -279
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts +0 -178
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js +0 -168
- package/autoscaling/system_status.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/cookie_utils.d.ts +0 -43
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js +0 -111
- package/cookie_utils.js.map +0 -1
- package/crawlers/context_pipeline.d.ts +0 -61
- package/crawlers/context_pipeline.d.ts.map +0 -1
- package/crawlers/context_pipeline.js +0 -99
- package/crawlers/context_pipeline.js.map +0 -1
- package/crawlers/crawler_commons.d.ts +0 -191
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js +0 -108
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_utils.d.ts +0 -10
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js +0 -12
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts +0 -60
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js +0 -118
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts +0 -55
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js +0 -309
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts +0 -7
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js +0 -7
- package/crawlers/index.js.map +0 -1
- package/crawlers/internals/types.d.ts +0 -8
- package/crawlers/internals/types.d.ts.map +0 -1
- package/crawlers/internals/types.js +0 -2
- package/crawlers/internals/types.js.map +0 -1
- package/crawlers/statistics.d.ts +0 -204
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js +0 -350
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts +0 -254
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js +0 -268
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts +0 -3
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js +0 -3
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts +0 -84
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js +0 -219
- package/enqueue_links/shared.js.map +0 -1
- package/errors.d.ts.map +0 -1
- package/errors.js.map +0 -1
- package/events/event_manager.d.ts.map +0 -1
- package/events/event_manager.js.map +0 -1
- package/events/index.d.ts.map +0 -1
- package/events/index.js.map +0 -1
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js +0 -93
- package/events/local_event_manager.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/log.d.ts.map +0 -1
- package/log.js.map +0 -1
- package/proxy_configuration.d.ts +0 -169
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js +0 -247
- package/proxy_configuration.js.map +0 -1
- package/recoverable_state.d.ts +0 -122
- package/recoverable_state.d.ts.map +0 -1
- package/recoverable_state.js +0 -138
- package/recoverable_state.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts +0 -134
- package/router.d.ts.map +0 -1
- package/router.js +0 -164
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/service_locator.d.ts.map +0 -1
- package/service_locator.js +0 -252
- package/service_locator.js.map +0 -1
- package/session_pool/consts.d.ts +0 -4
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js +0 -4
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts +0 -8
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js +0 -12
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts +0 -3
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js +0 -3
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts +0 -6
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js +0 -6
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts +0 -186
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js +0 -278
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts +0 -256
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js +0 -386
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts +0 -13
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js +0 -14
- package/storages/access_checking.js.map +0 -1
- package/storages/dataset.d.ts.map +0 -1
- package/storages/dataset.js.map +0 -1
- package/storages/index.d.ts.map +0 -1
- package/storages/index.js.map +0 -1
- package/storages/key_value_store.d.ts.map +0 -1
- package/storages/key_value_store.js +0 -513
- package/storages/key_value_store.js.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_list_adapter.d.ts +0 -58
- package/storages/request_list_adapter.d.ts.map +0 -1
- package/storages/request_list_adapter.js +0 -81
- package/storages/request_list_adapter.js.map +0 -1
- package/storages/request_manager_tandem.d.ts +0 -68
- package/storages/request_manager_tandem.d.ts.map +0 -1
- package/storages/request_manager_tandem.js +0 -124
- package/storages/request_manager_tandem.js.map +0 -1
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -592
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts +0 -128
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js +0 -320
- package/storages/request_queue.js.map +0 -1
- package/storages/request_queue_v2.d.ts +0 -87
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js +0 -437
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts +0 -245
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js +0 -431
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -60
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -95
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/typedefs.d.ts.map +0 -1
- package/typedefs.js.map +0 -1
- package/validators.d.ts.map +0 -1
- package/validators.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<a href="https://crawlee.dev">
|
|
3
3
|
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true"
|
|
5
|
-
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500"
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true" />
|
|
5
|
+
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500" />
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
-
<br
|
|
8
|
+
<br />
|
|
9
9
|
<small>A web scraping and browser automation library</small>
|
|
10
10
|
</h1>
|
|
11
11
|
|
|
12
|
-
<p align=center>
|
|
13
|
-
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift"
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift" width="250" height="55"/></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
<p align=center>
|
|
17
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg"
|
|
18
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg"
|
|
19
|
-
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord"
|
|
20
|
-
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status"
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" /></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" /></a>
|
|
19
|
+
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" /></a>
|
|
20
|
+
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" /></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
|
|
@@ -34,7 +34,7 @@ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) N
|
|
|
34
34
|
|
|
35
35
|
We recommend visiting the [Introduction tutorial](https://crawlee.dev/js/docs/introduction) in Crawlee documentation for more information.
|
|
36
36
|
|
|
37
|
-
> Crawlee requires **Node.js
|
|
37
|
+
> Crawlee requires **Node.js 22.13 or higher**.
|
|
38
38
|
|
|
39
39
|
### With Crawlee CLI
|
|
40
40
|
|
|
@@ -89,7 +89,7 @@ By default, Crawlee stores data to `./storage` in the current working directory.
|
|
|
89
89
|
We provide automated beta builds for every merged code change in Crawlee. You can find them in the npm [list of releases](https://www.npmjs.com/package/crawlee?activeTab=versions). If you want to test new features or bug fixes before we release them, feel free to install a beta build like this:
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
|
-
npm install crawlee@
|
|
92
|
+
npm install crawlee@next
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
If you also use the [Apify SDK](https://github.com/apify/apify-sdk-js), you need to specify dependency overrides in your `package.json` file so that you don't end up with multiple versions of Crawlee installed:
|
|
@@ -98,9 +98,9 @@ If you also use the [Apify SDK](https://github.com/apify/apify-sdk-js), you need
|
|
|
98
98
|
{
|
|
99
99
|
"overrides": {
|
|
100
100
|
"apify": {
|
|
101
|
-
"@crawlee/core": "
|
|
102
|
-
"@crawlee/types": "
|
|
103
|
-
"@crawlee/utils": "
|
|
101
|
+
"@crawlee/core": "$crawlee",
|
|
102
|
+
"@crawlee/types": "$crawlee",
|
|
103
|
+
"@crawlee/utils": "$crawlee"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
package/byte-utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a Node.js Stream or a Web API ReadableStream.
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
export declare function isStream(value: unknown): value is NodeJS.ReadableStream | ReadableStream;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the given value is a Node.js Buffer, ArrayBuffer, or TypedArray.
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export declare function isBuffer(value: unknown): value is Buffer | ArrayBuffer | ArrayBufferView;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a byte-like value (Buffer, ArrayBuffer, or any typed-array / DataView) into a Buffer over
|
|
13
|
+
* the exact same bytes, honoring `byteOffset` / `byteLength` for views. Existing Buffers are returned
|
|
14
|
+
* as-is. Used by storage backends, which persist raw bytes regardless of the input's concrete shape.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export declare function toBuffer(value: Buffer | ArrayBuffer | ArrayBufferView): Buffer;
|
package/byte-utils.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a Node.js Stream or a Web API ReadableStream.
|
|
3
|
+
* @ignore
|
|
4
|
+
*/
|
|
5
|
+
export function isStream(value) {
|
|
6
|
+
if (typeof value !== 'object' || value === null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
// A Node.js Readable is both pipeable and async-iterable; a Web ReadableStream exposes pipeTo.
|
|
10
|
+
// Requiring async-iterability for the `pipe` branch rejects plain `{ pipe }` ducks that would
|
|
11
|
+
// otherwise blow up later in the storage backends' drain loop with a cryptic TypeError.
|
|
12
|
+
const isNodeStream = typeof value.pipe === 'function' && typeof value[Symbol.asyncIterator] === 'function';
|
|
13
|
+
const isWebStream = typeof value.pipeTo === 'function';
|
|
14
|
+
return isNodeStream || isWebStream;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the given value is a Node.js Buffer, ArrayBuffer, or TypedArray.
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export function isBuffer(value) {
|
|
21
|
+
return (value != null &&
|
|
22
|
+
typeof value === 'object' &&
|
|
23
|
+
(Buffer.isBuffer(value) ||
|
|
24
|
+
value instanceof ArrayBuffer ||
|
|
25
|
+
ArrayBuffer.isView(value) ||
|
|
26
|
+
value.constructor?.name === 'Buffer'));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a byte-like value (Buffer, ArrayBuffer, or any typed-array / DataView) into a Buffer over
|
|
30
|
+
* the exact same bytes, honoring `byteOffset` / `byteLength` for views. Existing Buffers are returned
|
|
31
|
+
* as-is. Used by storage backends, which persist raw bytes regardless of the input's concrete shape.
|
|
32
|
+
* @ignore
|
|
33
|
+
*/
|
|
34
|
+
export function toBuffer(value) {
|
|
35
|
+
if (Buffer.isBuffer(value)) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (value instanceof ArrayBuffer) {
|
|
39
|
+
return Buffer.from(value);
|
|
40
|
+
}
|
|
41
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
42
|
+
}
|
package/configuration.d.ts
CHANGED
|
@@ -1,130 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LogLevel } from '
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* Defines the interval of emitting the `persistState` event.
|
|
55
|
-
*
|
|
56
|
-
* Alternative to `CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS` environment variable.
|
|
57
|
-
* @default 60_000
|
|
58
|
-
*/
|
|
59
|
-
persistStateIntervalMillis?: number;
|
|
60
|
-
/**
|
|
61
|
-
Defines the interval of emitting the `systemInfo` event.
|
|
62
|
-
@default 1_000
|
|
63
|
-
*/
|
|
64
|
-
systemInfoIntervalMillis?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Defines the default input key, i.e. the key that is used to get the crawler input value
|
|
67
|
-
* from the default {@link KeyValueStore} associated with the current crawler run.
|
|
68
|
-
*
|
|
69
|
-
* Alternative to `CRAWLEE_INPUT_KEY` environment variable.
|
|
70
|
-
* @default 'INPUT'
|
|
71
|
-
*/
|
|
72
|
-
inputKey?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Defines whether web browsers launched by Crawlee will run in the headless mode.
|
|
75
|
-
*
|
|
76
|
-
* Alternative to `CRAWLEE_HEADLESS` environment variable.
|
|
77
|
-
* @default true
|
|
78
|
-
*/
|
|
79
|
-
headless?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Defines whether to run X virtual framebuffer on the web browsers launched by Crawlee.
|
|
82
|
-
*
|
|
83
|
-
* Alternative to `CRAWLEE_XVFB` environment variable.
|
|
84
|
-
* @default false
|
|
85
|
-
*/
|
|
86
|
-
xvfb?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Defines a path to Chrome executable.
|
|
89
|
-
*
|
|
90
|
-
* Alternative to `CRAWLEE_CHROME_EXECUTABLE_PATH` environment variable.
|
|
91
|
-
*/
|
|
92
|
-
chromeExecutablePath?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Defines a path to default browser executable.
|
|
95
|
-
*
|
|
96
|
-
* Alternative to `CRAWLEE_DEFAULT_BROWSER_PATH` environment variable.
|
|
97
|
-
*/
|
|
98
|
-
defaultBrowserPath?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Defines whether to disable browser sandbox by adding `--no-sandbox` flag to `launchOptions`.
|
|
101
|
-
*
|
|
102
|
-
* Alternative to `CRAWLEE_DISABLE_BROWSER_SANDBOX` environment variable.
|
|
103
|
-
*/
|
|
104
|
-
disableBrowserSandbox?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Sets the log level to the given value.
|
|
107
|
-
*
|
|
108
|
-
* Alternative to `CRAWLEE_LOG_LEVEL` environment variable.
|
|
109
|
-
* @default 'INFO'
|
|
110
|
-
*/
|
|
111
|
-
logLevel?: LogLevel | LogLevel[keyof LogLevel];
|
|
112
|
-
/**
|
|
113
|
-
* Defines whether the storage client used should persist the data it stores.
|
|
114
|
-
*
|
|
115
|
-
* Alternative to `CRAWLEE_PERSIST_STORAGE` environment variable.
|
|
116
|
-
*/
|
|
117
|
-
persistStorage?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Used in place of `isContainerized()` when collecting system metrics.
|
|
120
|
-
*
|
|
121
|
-
* Alternative to `CRAWLEE_CONTAINERIZED` environment variable.
|
|
122
|
-
*/
|
|
123
|
-
containerized?: boolean;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LogLevel } from './log.js';
|
|
3
|
+
export interface ConfigField<T extends z.ZodType = z.ZodType> {
|
|
4
|
+
schema: T;
|
|
5
|
+
envVar?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function field<T extends z.ZodType>(schema: T, envVar?: string | string[]): ConfigField<T>;
|
|
8
|
+
/** Zod preprocessor treating `'0'` and `'false'` as falsy. */
|
|
9
|
+
export declare const coerceBoolean: z.ZodPreprocess<z.ZodBoolean, unknown>;
|
|
10
|
+
export declare const coerceNumber: z.ZodPreprocess<z.ZodNumber, unknown>;
|
|
11
|
+
export declare const crawleeConfigFields: {
|
|
12
|
+
/** @default true */
|
|
13
|
+
purgeOnStart: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
14
|
+
/** @default 0.95 */
|
|
15
|
+
maxUsedCpuRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
16
|
+
/** @default 0.25 */
|
|
17
|
+
availableMemoryRatio: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
18
|
+
memoryMbytes: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
19
|
+
/** @default 60_000 */
|
|
20
|
+
persistStateIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
21
|
+
/**
|
|
22
|
+
* Internal safety-net timeout for a single request, in milliseconds. When unset the crawler derives it from
|
|
23
|
+
* the request handler timeout (twice it, and never below 5 minutes).
|
|
24
|
+
*/
|
|
25
|
+
internalTimeoutMillis: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
26
|
+
/** @default 1_000 */
|
|
27
|
+
systemInfoIntervalMillis: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodNumber, unknown>>>;
|
|
28
|
+
/** @default true */
|
|
29
|
+
headless: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
30
|
+
/** @default false */
|
|
31
|
+
xvfb: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
32
|
+
chromeExecutablePath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
33
|
+
defaultBrowserPath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
34
|
+
/** @default false */
|
|
35
|
+
disableBrowserSandbox: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
36
|
+
logLevel: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodEnum<typeof LogLevel>, unknown>>>;
|
|
37
|
+
/** @default true */
|
|
38
|
+
persistStorage: ConfigField<z.ZodDefault<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
39
|
+
/** @default './storage' */
|
|
40
|
+
storageDir: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
41
|
+
containerized: ConfigField<z.ZodOptional<z.ZodPreprocess<z.ZodBoolean, unknown>>>;
|
|
42
|
+
};
|
|
43
|
+
export type FieldsInput<F extends Record<string, ConfigField>> = {
|
|
44
|
+
[K in keyof F]?: z.output<F[K]['schema']>;
|
|
45
|
+
};
|
|
46
|
+
export type FieldsOutput<F extends Record<string, ConfigField>> = {
|
|
47
|
+
[K in keyof F]: z.output<F[K]['schema']>;
|
|
48
|
+
};
|
|
49
|
+
export type ConfigurationInput = FieldsInput<typeof crawleeConfigFields>;
|
|
50
|
+
export type ResolvedConfigValues = FieldsOutput<typeof crawleeConfigFields>;
|
|
51
|
+
/** @deprecated Use {@link ConfigurationInput} instead. */
|
|
52
|
+
export type ConfigurationOptions = ConfigurationInput;
|
|
53
|
+
export interface Configuration extends ResolvedConfigValues {
|
|
124
54
|
}
|
|
125
55
|
/**
|
|
126
56
|
* `Configuration` is a value object holding Crawlee configuration. By default, there is a
|
|
127
|
-
* global singleton instance of this class available via `Configuration.
|
|
57
|
+
* global singleton instance of this class available via `Configuration.getGlobalConfiguration()`.
|
|
128
58
|
* Places that depend on a configurable behaviour depend on this class, as they have the global
|
|
129
59
|
* instance as the default value.
|
|
130
60
|
*
|
|
@@ -133,14 +63,10 @@ export interface ConfigurationOptions {
|
|
|
133
63
|
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
134
64
|
*
|
|
135
65
|
* // Get the global configuration
|
|
136
|
-
* const config = Configuration.
|
|
137
|
-
* //
|
|
138
|
-
*
|
|
139
|
-
* config.
|
|
140
|
-
*
|
|
141
|
-
* // No need to pass the configuration to the crawler,
|
|
142
|
-
* // as it's using the global configuration by default
|
|
143
|
-
* const crawler = new BasicCrawler();
|
|
66
|
+
* const config = Configuration.getGlobalConfiguration();
|
|
67
|
+
* // Access configuration values directly as properties
|
|
68
|
+
* console.log(config.headless);
|
|
69
|
+
* console.log(config.persistStateIntervalMillis);
|
|
144
70
|
* ```
|
|
145
71
|
*
|
|
146
72
|
* *Using custom configuration:*
|
|
@@ -150,15 +76,14 @@ export interface ConfigurationOptions {
|
|
|
150
76
|
* // Create a new configuration
|
|
151
77
|
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
152
78
|
* // Pass the configuration to the crawler
|
|
153
|
-
* const crawler = new BasicCrawler({ configuration: config
|
|
79
|
+
* const crawler = new BasicCrawler({ configuration: config });
|
|
154
80
|
* ```
|
|
155
81
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* so the options provided in constructor will override those. In other words, the precedence is:
|
|
82
|
+
* Configuration is immutable — values are set via the constructor and cannot be changed afterwards.
|
|
83
|
+
* The priority order for resolving values is (highest to lowest):
|
|
159
84
|
*
|
|
160
85
|
* ```text
|
|
161
|
-
*
|
|
86
|
+
* constructor options > environment variables > crawlee.json > schema defaults
|
|
162
87
|
* ```
|
|
163
88
|
*
|
|
164
89
|
* ## Supported Configuration Options
|
|
@@ -168,57 +93,40 @@ export interface ConfigurationOptions {
|
|
|
168
93
|
* `memoryMbytes` | `CRAWLEE_MEMORY_MBYTES` | -
|
|
169
94
|
* `logLevel` | `CRAWLEE_LOG_LEVEL` | -
|
|
170
95
|
* `headless` | `CRAWLEE_HEADLESS` | `true`
|
|
171
|
-
* `defaultDatasetId` | `CRAWLEE_DEFAULT_DATASET_ID` | `'default'`
|
|
172
|
-
* `defaultKeyValueStoreId` | `CRAWLEE_DEFAULT_KEY_VALUE_STORE_ID` | `'default'`
|
|
173
|
-
* `defaultRequestQueueId` | `CRAWLEE_DEFAULT_REQUEST_QUEUE_ID` | `'default'`
|
|
174
96
|
* `persistStateIntervalMillis` | `CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS` | `60_000`
|
|
97
|
+
* `internalTimeoutMillis` | `CRAWLEE_INTERNAL_TIMEOUT` | -
|
|
175
98
|
* `purgeOnStart` | `CRAWLEE_PURGE_ON_START` | `true`
|
|
176
99
|
* `persistStorage` | `CRAWLEE_PERSIST_STORAGE` | `true`
|
|
100
|
+
* `storageDir` | `CRAWLEE_STORAGE_DIR` | `'./storage'`
|
|
177
101
|
*
|
|
178
102
|
* ## Advanced Configuration Options
|
|
179
103
|
*
|
|
180
104
|
* Key | Environment Variable | Default Value
|
|
181
105
|
* ---|---|---
|
|
182
|
-
* `
|
|
183
|
-
* `xvfb` | `CRAWLEE_XVFB` | -
|
|
106
|
+
* `xvfb` | `CRAWLEE_XVFB` | `false`
|
|
184
107
|
* `chromeExecutablePath` | `CRAWLEE_CHROME_EXECUTABLE_PATH` | -
|
|
185
108
|
* `defaultBrowserPath` | `CRAWLEE_DEFAULT_BROWSER_PATH` | -
|
|
186
109
|
* `disableBrowserSandbox` | `CRAWLEE_DISABLE_BROWSER_SANDBOX` | -
|
|
187
110
|
* `availableMemoryRatio` | `CRAWLEE_AVAILABLE_MEMORY_RATIO` | `0.25`
|
|
188
|
-
* `containerized | `CRAWLEE_CONTAINERIZED | -
|
|
111
|
+
* `containerized` | `CRAWLEE_CONTAINERIZED` | -
|
|
189
112
|
*/
|
|
190
113
|
export declare class Configuration {
|
|
114
|
+
#private;
|
|
191
115
|
/**
|
|
192
|
-
*
|
|
193
|
-
|
|
194
|
-
protected static ENV_MAP: Dictionary;
|
|
195
|
-
protected static BOOLEAN_VARS: string[];
|
|
196
|
-
protected static INTEGER_VARS: string[];
|
|
197
|
-
protected static COMMA_SEPARATED_LIST_VARS: string[];
|
|
198
|
-
protected static DEFAULTS: Dictionary;
|
|
199
|
-
protected options: Map<keyof ConfigurationOptions, ConfigurationOptions[keyof ConfigurationOptions]>;
|
|
200
|
-
/**
|
|
201
|
-
* Creates new `Configuration` instance with provided options. Env vars will have precedence over those.
|
|
202
|
-
*/
|
|
203
|
-
constructor(options?: ConfigurationOptions);
|
|
204
|
-
/**
|
|
205
|
-
* Returns configured value. First checks the environment variables, then provided configuration,
|
|
206
|
-
* fallbacks to the `defaultValue` argument if provided, otherwise uses the default value as described
|
|
207
|
-
* in the above section.
|
|
116
|
+
* Field definitions for this configuration class.
|
|
117
|
+
* Subclasses override this to register additional fields.
|
|
208
118
|
*/
|
|
209
|
-
|
|
210
|
-
protected _castEnvValue(key: keyof ConfigurationOptions, value: number | string | boolean): string | number | boolean | string[];
|
|
119
|
+
protected static fields: Record<string, ConfigField>;
|
|
211
120
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
121
|
+
* Creates new `Configuration` instance with provided options.
|
|
122
|
+
* Constructor options take precedence over environment variables, which take precedence
|
|
123
|
+
* over crawlee.json values, which take precedence over schema defaults.
|
|
214
124
|
*/
|
|
215
|
-
|
|
125
|
+
constructor(options?: ConfigurationInput);
|
|
216
126
|
/**
|
|
217
127
|
* Returns the global configuration instance. It will respect the environment variables.
|
|
218
128
|
*
|
|
219
129
|
* Delegates to the global ServiceLocator, making it the single source of truth for service management.
|
|
220
130
|
*/
|
|
221
|
-
static
|
|
222
|
-
protected buildOptions(options: ConfigurationOptions): void;
|
|
131
|
+
static getGlobalConfiguration(): Configuration;
|
|
223
132
|
}
|
|
224
|
-
//# sourceMappingURL=configuration.d.ts.map
|