@crawlee/core 4.0.0-beta.9 → 4.0.0-beta.90
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 +17 -13
- package/autoscaling/autoscaled_pool.d.ts +66 -153
- package/autoscaling/autoscaled_pool.js +95 -251
- package/autoscaling/client_load_signal.d.ts +59 -0
- package/autoscaling/client_load_signal.js +73 -0
- package/autoscaling/concurrency_system.d.ts +283 -0
- package/autoscaling/concurrency_system.js +350 -0
- package/autoscaling/cpu_load_signal.d.ts +44 -0
- package/autoscaling/cpu_load_signal.js +46 -0
- package/autoscaling/event_loop_load_signal.d.ts +54 -0
- package/autoscaling/event_loop_load_signal.js +60 -0
- package/autoscaling/index.d.ts +6 -1
- package/autoscaling/index.js +6 -1
- package/autoscaling/load_signal.d.ts +99 -0
- package/autoscaling/load_signal.js +103 -0
- package/autoscaling/memory_load_signal.d.ts +56 -0
- package/autoscaling/memory_load_signal.js +106 -0
- package/autoscaling/snapshotter.d.ts +61 -163
- package/autoscaling/snapshotter.js +45 -263
- package/autoscaling/system_status.d.ts +63 -83
- package/autoscaling/system_status.js +90 -120
- package/configuration.d.ts +90 -223
- package/configuration.js +164 -222
- package/cookie_utils.d.ts +4 -3
- package/cookie_utils.js +20 -13
- package/crawlers/context_pipeline.d.ts +70 -0
- package/crawlers/context_pipeline.js +122 -0
- package/crawlers/crawler_commons.d.ts +76 -33
- package/crawlers/crawler_commons.js +15 -24
- package/crawlers/crawler_utils.d.ts +2 -3
- package/crawlers/crawler_utils.js +1 -2
- package/crawlers/error_snapshotter.d.ts +3 -3
- package/crawlers/error_snapshotter.js +2 -3
- package/crawlers/error_tracker.d.ts +2 -2
- package/crawlers/error_tracker.js +0 -1
- package/crawlers/index.d.ts +1 -2
- package/crawlers/index.js +1 -2
- package/crawlers/internals/types.d.ts +7 -0
- package/crawlers/internals/types.js +1 -0
- package/crawlers/statistics.d.ts +28 -23
- package/crawlers/statistics.js +38 -34
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/enqueue_links/enqueue_links.d.ts +44 -22
- package/enqueue_links/enqueue_links.js +51 -30
- package/enqueue_links/index.d.ts +0 -1
- package/enqueue_links/index.js +0 -1
- package/enqueue_links/shared.d.ts +25 -9
- package/enqueue_links/shared.js +69 -38
- package/errors.d.ts +53 -4
- package/errors.js +70 -5
- package/events/event_manager.d.ts +34 -8
- package/events/event_manager.js +8 -10
- package/events/index.d.ts +0 -1
- package/events/index.js +0 -1
- package/events/local_event_manager.d.ts +15 -3
- package/events/local_event_manager.js +37 -11
- package/index.d.ts +6 -3
- package/index.js +5 -2
- package/log.d.ts +82 -3
- package/log.js +102 -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 +46 -0
- package/memory-storage/memory-storage.js +136 -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 +40 -0
- package/memory-storage/resource-clients/dataset.js +113 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
- package/memory-storage/resource-clients/key-value-store.js +203 -0
- package/memory-storage/resource-clients/request-queue.d.ts +96 -0
- package/memory-storage/resource-clients/request-queue.js +421 -0
- package/memory-storage/utils.d.ts +17 -0
- package/memory-storage/utils.js +42 -0
- package/owned_or_injected.d.ts +60 -0
- package/owned_or_injected.js +98 -0
- package/package.json +12 -10
- package/proxy_configuration.d.ts +29 -152
- package/proxy_configuration.js +21 -173
- package/recoverable_state.d.ts +120 -0
- package/recoverable_state.js +143 -0
- package/request.d.ts +84 -13
- package/request.js +107 -28
- package/router.d.ts +143 -17
- package/router.js +125 -30
- package/serialization.d.ts +0 -1
- package/serialization.js +1 -2
- package/service_locator.d.ts +156 -0
- package/service_locator.js +238 -0
- package/session_pool/consts.d.ts +1 -2
- package/session_pool/consts.js +1 -2
- package/session_pool/errors.d.ts +0 -1
- package/session_pool/errors.js +0 -1
- package/session_pool/fingerprint.d.ts +9 -0
- package/session_pool/fingerprint.js +30 -0
- package/session_pool/index.d.ts +0 -2
- package/session_pool/index.js +0 -2
- package/session_pool/session.d.ts +37 -75
- package/session_pool/session.js +49 -102
- package/session_pool/session_pool.d.ts +85 -90
- package/session_pool/session_pool.js +131 -120
- package/storages/access_checking.d.ts +0 -1
- package/storages/access_checking.js +5 -2
- package/storages/dataset.d.ts +103 -53
- package/storages/dataset.js +174 -132
- package/storages/index.d.ts +8 -7
- package/storages/index.js +6 -7
- package/storages/key_value_store.d.ts +167 -38
- package/storages/key_value_store.js +274 -127
- package/storages/key_value_store_codec.d.ts +32 -0
- package/storages/key_value_store_codec.js +113 -0
- package/storages/request_dedup_cache.d.ts +23 -0
- package/storages/request_dedup_cache.js +48 -0
- package/storages/request_list.d.ts +54 -98
- package/storages/request_list.js +99 -75
- package/storages/request_loader.d.ts +96 -0
- package/storages/request_loader.js +1 -0
- package/storages/request_manager.d.ts +33 -0
- package/storages/request_manager.js +1 -0
- package/storages/request_manager_tandem.d.ts +106 -0
- package/storages/request_manager_tandem.js +197 -0
- package/storages/request_queue.d.ts +290 -47
- package/storages/request_queue.js +629 -215
- package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +28 -24
- package/storages/{sitemap_request_list.js → sitemap_request_loader.js} +49 -47
- package/storages/storage_instance_manager.d.ts +91 -0
- package/storages/storage_instance_manager.js +258 -0
- package/storages/storage_stats.d.ts +48 -0
- package/storages/storage_stats.js +29 -0
- package/storages/utils.d.ts +54 -9
- package/storages/utils.js +64 -13
- 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 +1 -2
- package/typedefs.js +0 -1
- package/validators.d.ts +8 -1
- package/validators.js +10 -3
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts.map +0 -1
- 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.map +0 -1
- package/cookie_utils.js.map +0 -1
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_extension.d.ts +0 -12
- package/crawlers/crawler_extension.d.ts.map +0 -1
- package/crawlers/crawler_extension.js +0 -14
- package/crawlers/crawler_extension.js.map +0 -1
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js.map +0 -1
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts.map +0 -1
- 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.map +0 -1
- package/http_clients/base-http-client.d.ts +0 -134
- package/http_clients/base-http-client.d.ts.map +0 -1
- package/http_clients/base-http-client.js +0 -33
- package/http_clients/base-http-client.js.map +0 -1
- package/http_clients/form-data-like.d.ts +0 -67
- package/http_clients/form-data-like.d.ts.map +0 -1
- package/http_clients/form-data-like.js +0 -5
- package/http_clients/form-data-like.js.map +0 -1
- package/http_clients/got-scraping-http-client.d.ts +0 -15
- package/http_clients/got-scraping-http-client.d.ts.map +0 -1
- package/http_clients/got-scraping-http-client.js +0 -69
- package/http_clients/got-scraping-http-client.js.map +0 -1
- package/http_clients/index.d.ts +0 -3
- package/http_clients/index.d.ts.map +0 -1
- package/http_clients/index.js +0 -3
- package/http_clients/index.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.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts.map +0 -1
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts.map +0 -1
- 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.map +0 -1
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts.map +0 -1
- 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.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_provider.d.ts +0 -307
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -555
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts.map +0 -1
- 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 -438
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -58
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -105
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +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/configuration.d.ts
CHANGED
|
@@ -1,151 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
maxUsedCpuRatio?: number;
|
|
59
|
-
/**
|
|
60
|
-
* Sets the ratio, defining the amount of system memory that could be used by the {@link AutoscaledPool}.
|
|
61
|
-
* When the memory usage is more than the provided ratio, the memory is considered overloaded.
|
|
62
|
-
*
|
|
63
|
-
* Alternative to `CRAWLEE_AVAILABLE_MEMORY_RATIO` environment variable.
|
|
64
|
-
* @default 0.25
|
|
65
|
-
*/
|
|
66
|
-
availableMemoryRatio?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Sets the amount of system memory in megabytes to be used by the {@link AutoscaledPool}.
|
|
69
|
-
* By default, the maximum memory is set to one quarter of total system memory.
|
|
70
|
-
*
|
|
71
|
-
* Alternative to `CRAWLEE_MEMORY_MBYTES` environment variable.
|
|
72
|
-
*/
|
|
73
|
-
memoryMbytes?: number;
|
|
74
|
-
/**
|
|
75
|
-
* Defines the interval of emitting the `persistState` event.
|
|
76
|
-
*
|
|
77
|
-
* Alternative to `CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS` environment variable.
|
|
78
|
-
* @default 60_000
|
|
79
|
-
*/
|
|
80
|
-
persistStateIntervalMillis?: number;
|
|
81
|
-
/**
|
|
82
|
-
Defines the interval of emitting the `systemInfo` event.
|
|
83
|
-
@default 1_000
|
|
84
|
-
*/
|
|
85
|
-
systemInfoIntervalMillis?: number;
|
|
86
|
-
/**
|
|
87
|
-
* Defines the default input key, i.e. the key that is used to get the crawler input value
|
|
88
|
-
* from the default {@link KeyValueStore} associated with the current crawler run.
|
|
89
|
-
*
|
|
90
|
-
* Alternative to `CRAWLEE_INPUT_KEY` environment variable.
|
|
91
|
-
* @default 'INPUT'
|
|
92
|
-
*/
|
|
93
|
-
inputKey?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Defines whether web browsers launched by Crawlee will run in the headless mode.
|
|
96
|
-
*
|
|
97
|
-
* Alternative to `CRAWLEE_HEADLESS` environment variable.
|
|
98
|
-
* @default true
|
|
99
|
-
*/
|
|
100
|
-
headless?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Defines whether to run X virtual framebuffer on the web browsers launched by Crawlee.
|
|
103
|
-
*
|
|
104
|
-
* Alternative to `CRAWLEE_XVFB` environment variable.
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
xvfb?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Defines a path to Chrome executable.
|
|
110
|
-
*
|
|
111
|
-
* Alternative to `CRAWLEE_CHROME_EXECUTABLE_PATH` environment variable.
|
|
112
|
-
*/
|
|
113
|
-
chromeExecutablePath?: string;
|
|
114
|
-
/**
|
|
115
|
-
* Defines a path to default browser executable.
|
|
116
|
-
*
|
|
117
|
-
* Alternative to `CRAWLEE_DEFAULT_BROWSER_PATH` environment variable.
|
|
118
|
-
*/
|
|
119
|
-
defaultBrowserPath?: string;
|
|
120
|
-
/**
|
|
121
|
-
* Defines whether to disable browser sandbox by adding `--no-sandbox` flag to `launchOptions`.
|
|
122
|
-
*
|
|
123
|
-
* Alternative to `CRAWLEE_DISABLE_BROWSER_SANDBOX` environment variable.
|
|
124
|
-
*/
|
|
125
|
-
disableBrowserSandbox?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Sets the log level to the given value.
|
|
128
|
-
*
|
|
129
|
-
* Alternative to `CRAWLEE_LOG_LEVEL` environment variable.
|
|
130
|
-
* @default 'INFO'
|
|
131
|
-
*/
|
|
132
|
-
logLevel?: LogLevel | LogLevel[keyof LogLevel];
|
|
133
|
-
/**
|
|
134
|
-
* Defines whether the storage client used should persist the data it stores.
|
|
135
|
-
*
|
|
136
|
-
* Alternative to `CRAWLEE_PERSIST_STORAGE` environment variable.
|
|
137
|
-
*/
|
|
138
|
-
persistStorage?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Used in place of `isContainerized()` when collecting system metrics.
|
|
141
|
-
*
|
|
142
|
-
* Alternative to `CRAWLEE_CONTAINERIZED` environment variable.
|
|
143
|
-
*/
|
|
144
|
-
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.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>;
|
|
10
|
+
export declare const coerceNumber: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>;
|
|
11
|
+
export declare const crawleeConfigFields: {
|
|
12
|
+
/** @default 'default' */
|
|
13
|
+
defaultDatasetId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
14
|
+
/** @default true */
|
|
15
|
+
purgeOnStart: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
16
|
+
/** @default 'default' */
|
|
17
|
+
defaultKeyValueStoreId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
18
|
+
/** @default 'default' */
|
|
19
|
+
defaultRequestQueueId: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
20
|
+
/** @default 0.95 */
|
|
21
|
+
maxUsedCpuRatio: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>>;
|
|
22
|
+
/** @default 0.25 */
|
|
23
|
+
availableMemoryRatio: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>>;
|
|
24
|
+
memoryMbytes: ConfigField<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>>;
|
|
25
|
+
/** @default 60_000 */
|
|
26
|
+
persistStateIntervalMillis: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>>;
|
|
27
|
+
/** @default 1_000 */
|
|
28
|
+
systemInfoIntervalMillis: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNumber>>>;
|
|
29
|
+
/** @default 'INPUT' */
|
|
30
|
+
inputKey: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
31
|
+
/** @default true */
|
|
32
|
+
headless: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
33
|
+
/** @default false */
|
|
34
|
+
xvfb: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
35
|
+
chromeExecutablePath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
36
|
+
defaultBrowserPath: ConfigField<z.ZodOptional<z.ZodString>>;
|
|
37
|
+
/** @default false */
|
|
38
|
+
disableBrowserSandbox: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
39
|
+
logLevel: ConfigField<z.ZodOptional<z.ZodPipe<z.ZodTransform<{} | null | undefined, unknown>, z.ZodEnum<typeof LogLevel>>>>;
|
|
40
|
+
/** @default true */
|
|
41
|
+
persistStorage: ConfigField<z.ZodDefault<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
42
|
+
/** @default './storage' */
|
|
43
|
+
storageDir: ConfigField<z.ZodDefault<z.ZodString>>;
|
|
44
|
+
containerized: ConfigField<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodBoolean>>>;
|
|
45
|
+
};
|
|
46
|
+
export type FieldsInput<F extends Record<string, ConfigField>> = {
|
|
47
|
+
[K in keyof F]?: z.output<F[K]['schema']>;
|
|
48
|
+
};
|
|
49
|
+
export type FieldsOutput<F extends Record<string, ConfigField>> = {
|
|
50
|
+
[K in keyof F]: z.output<F[K]['schema']>;
|
|
51
|
+
};
|
|
52
|
+
export type ConfigurationInput = FieldsInput<typeof crawleeConfigFields>;
|
|
53
|
+
export type ResolvedConfigValues = FieldsOutput<typeof crawleeConfigFields>;
|
|
54
|
+
/** @deprecated Use {@link ConfigurationInput} instead. */
|
|
55
|
+
export type ConfigurationOptions = ConfigurationInput;
|
|
56
|
+
export interface Configuration extends ResolvedConfigValues {
|
|
145
57
|
}
|
|
146
58
|
/**
|
|
147
59
|
* `Configuration` is a value object holding Crawlee configuration. By default, there is a
|
|
148
|
-
* global singleton instance of this class available via `Configuration.
|
|
60
|
+
* global singleton instance of this class available via `Configuration.getGlobalConfiguration()`.
|
|
149
61
|
* Places that depend on a configurable behaviour depend on this class, as they have the global
|
|
150
62
|
* instance as the default value.
|
|
151
63
|
*
|
|
@@ -154,14 +66,10 @@ export interface ConfigurationOptions {
|
|
|
154
66
|
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
155
67
|
*
|
|
156
68
|
* // Get the global configuration
|
|
157
|
-
* const config = Configuration.
|
|
158
|
-
* //
|
|
159
|
-
*
|
|
160
|
-
* config.
|
|
161
|
-
*
|
|
162
|
-
* // No need to pass the configuration to the crawler,
|
|
163
|
-
* // as it's using the global configuration by default
|
|
164
|
-
* const crawler = new BasicCrawler();
|
|
69
|
+
* const config = Configuration.getGlobalConfiguration();
|
|
70
|
+
* // Access configuration values directly as properties
|
|
71
|
+
* console.log(config.headless);
|
|
72
|
+
* console.log(config.persistStateIntervalMillis);
|
|
165
73
|
* ```
|
|
166
74
|
*
|
|
167
75
|
* *Using custom configuration:*
|
|
@@ -171,15 +79,14 @@ export interface ConfigurationOptions {
|
|
|
171
79
|
* // Create a new configuration
|
|
172
80
|
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
173
81
|
* // Pass the configuration to the crawler
|
|
174
|
-
* const crawler = new BasicCrawler({
|
|
82
|
+
* const crawler = new BasicCrawler({ configuration: config });
|
|
175
83
|
* ```
|
|
176
84
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* so the options provided in constructor will override those. In other words, the precedence is:
|
|
85
|
+
* Configuration is immutable — values are set via the constructor and cannot be changed afterwards.
|
|
86
|
+
* The priority order for resolving values is (highest to lowest):
|
|
180
87
|
*
|
|
181
88
|
* ```text
|
|
182
|
-
*
|
|
89
|
+
* constructor options > environment variables > crawlee.json > schema defaults
|
|
183
90
|
* ```
|
|
184
91
|
*
|
|
185
92
|
* ## Supported Configuration Options
|
|
@@ -195,96 +102,56 @@ export interface ConfigurationOptions {
|
|
|
195
102
|
* `persistStateIntervalMillis` | `CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS` | `60_000`
|
|
196
103
|
* `purgeOnStart` | `CRAWLEE_PURGE_ON_START` | `true`
|
|
197
104
|
* `persistStorage` | `CRAWLEE_PERSIST_STORAGE` | `true`
|
|
105
|
+
* `storageDir` | `CRAWLEE_STORAGE_DIR` | `'./storage'`
|
|
198
106
|
*
|
|
199
107
|
* ## Advanced Configuration Options
|
|
200
108
|
*
|
|
201
109
|
* Key | Environment Variable | Default Value
|
|
202
110
|
* ---|---|---
|
|
203
111
|
* `inputKey` | `CRAWLEE_INPUT_KEY` | `'INPUT'`
|
|
204
|
-
* `xvfb` | `CRAWLEE_XVFB` |
|
|
112
|
+
* `xvfb` | `CRAWLEE_XVFB` | `false`
|
|
205
113
|
* `chromeExecutablePath` | `CRAWLEE_CHROME_EXECUTABLE_PATH` | -
|
|
206
114
|
* `defaultBrowserPath` | `CRAWLEE_DEFAULT_BROWSER_PATH` | -
|
|
207
115
|
* `disableBrowserSandbox` | `CRAWLEE_DISABLE_BROWSER_SANDBOX` | -
|
|
208
116
|
* `availableMemoryRatio` | `CRAWLEE_AVAILABLE_MEMORY_RATIO` | `0.25`
|
|
209
|
-
* `containerized | `CRAWLEE_CONTAINERIZED | -
|
|
117
|
+
* `containerized` | `CRAWLEE_CONTAINERIZED` | -
|
|
210
118
|
*/
|
|
211
119
|
export declare class Configuration {
|
|
212
120
|
/**
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
protected static ENV_MAP: Dictionary;
|
|
216
|
-
protected static BOOLEAN_VARS: string[];
|
|
217
|
-
protected static INTEGER_VARS: string[];
|
|
218
|
-
protected static COMMA_SEPARATED_LIST_VARS: string[];
|
|
219
|
-
protected static DEFAULTS: Dictionary;
|
|
220
|
-
/**
|
|
221
|
-
* Provides access to the current-instance-scoped Configuration without passing it around in parameters.
|
|
222
|
-
* @internal
|
|
223
|
-
*/
|
|
224
|
-
static storage: AsyncLocalStorage<Configuration>;
|
|
225
|
-
protected options: Map<keyof ConfigurationOptions, ConfigurationOptions[keyof ConfigurationOptions]>;
|
|
226
|
-
protected services: Map<string, unknown>;
|
|
227
|
-
/** @internal */
|
|
228
|
-
static globalConfig?: Configuration;
|
|
229
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
230
|
-
readonly storageManagers: Map<Constructor, StorageManager<import("./storages/storage_manager.js").IStorage>>;
|
|
231
|
-
/**
|
|
232
|
-
* Creates new `Configuration` instance with provided options. Env vars will have precedence over those.
|
|
233
|
-
*/
|
|
234
|
-
constructor(options?: ConfigurationOptions);
|
|
235
|
-
/**
|
|
236
|
-
* Returns configured value. First checks the environment variables, then provided configuration,
|
|
237
|
-
* fallbacks to the `defaultValue` argument if provided, otherwise uses the default value as described
|
|
238
|
-
* in the above section.
|
|
239
|
-
*/
|
|
240
|
-
get<T extends keyof ConfigurationOptions, U extends ConfigurationOptions[T]>(key: T, defaultValue?: U): U;
|
|
241
|
-
protected _castEnvValue(key: keyof ConfigurationOptions, value: number | string | boolean): string | number | boolean | string[];
|
|
242
|
-
/**
|
|
243
|
-
* Sets value for given option. Only affects this `Configuration` instance, the value will not be propagated down to the env var.
|
|
244
|
-
* To reset a value, we can omit the `value` argument or pass `undefined` there.
|
|
121
|
+
* Field definitions for this configuration class.
|
|
122
|
+
* Subclasses override this to register additional fields.
|
|
245
123
|
*/
|
|
246
|
-
|
|
124
|
+
protected static fields: Record<string, ConfigField>;
|
|
125
|
+
private resolvedValues;
|
|
247
126
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
127
|
+
* Creates new `Configuration` instance with provided options.
|
|
128
|
+
* Constructor options take precedence over environment variables, which take precedence
|
|
129
|
+
* over crawlee.json values, which take precedence over schema defaults.
|
|
250
130
|
*/
|
|
251
|
-
|
|
131
|
+
constructor(options?: ConfigurationInput);
|
|
252
132
|
/**
|
|
253
|
-
* Returns
|
|
254
|
-
* this {@link Configuration} instance. Only first call of this method will create the client, following calls will
|
|
255
|
-
* return the same client instance.
|
|
133
|
+
* Returns the global configuration instance. It will respect the environment variables.
|
|
256
134
|
*
|
|
257
|
-
*
|
|
258
|
-
* multiple instances, one for each variant of the options.
|
|
259
|
-
* @internal
|
|
260
|
-
*/
|
|
261
|
-
getStorageClient(): StorageClient;
|
|
262
|
-
getEventManager(): EventManager;
|
|
263
|
-
/**
|
|
264
|
-
* Creates an instance of MemoryStorage using options as defined in the environment variables or in this `Configuration` instance.
|
|
265
|
-
* @internal
|
|
135
|
+
* Delegates to the global ServiceLocator, making it the single source of truth for service management.
|
|
266
136
|
*/
|
|
267
|
-
|
|
268
|
-
useStorageClient(client: StorageClient): void;
|
|
269
|
-
static useStorageClient(client: StorageClient): void;
|
|
270
|
-
useEventManager(events: EventManager): void;
|
|
137
|
+
static getGlobalConfiguration(): Configuration;
|
|
271
138
|
/**
|
|
272
|
-
*
|
|
139
|
+
* Resolves all field values once using the priority chain:
|
|
140
|
+
* constructor options > env vars > crawlee.json > schema defaults.
|
|
273
141
|
*/
|
|
274
|
-
static
|
|
142
|
+
private static resolveAll;
|
|
275
143
|
/**
|
|
276
|
-
*
|
|
144
|
+
* Registers getters (and throwing setters) on the instance for each field.
|
|
277
145
|
*/
|
|
278
|
-
|
|
146
|
+
private registerAccessors;
|
|
279
147
|
/**
|
|
280
|
-
*
|
|
148
|
+
* Reads the first defined env var value for a field definition.
|
|
149
|
+
* Empty strings are treated as unset, falling through to crawlee.json or schema defaults.
|
|
150
|
+
* (Crawlee v3 coerced `''` to `false`/`0`/`''` per type — v4 drops that for consistency.)
|
|
281
151
|
*/
|
|
282
|
-
static
|
|
152
|
+
private static readEnvVar;
|
|
283
153
|
/**
|
|
284
|
-
*
|
|
285
|
-
* if we want to change them, we need to first reset the global state. Used mainly for testing purposes.
|
|
154
|
+
* Loads config options from crawlee.json in the current working directory.
|
|
286
155
|
*/
|
|
287
|
-
static
|
|
288
|
-
protected buildOptions(options: ConfigurationOptions): void;
|
|
156
|
+
private static loadFileOptions;
|
|
289
157
|
}
|
|
290
|
-
//# sourceMappingURL=configuration.d.ts.map
|