@crawlee/core 4.0.0-beta.9 → 4.0.0-beta.91
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 +85 -15
- package/request.js +107 -28
- package/router.d.ts +144 -19
- 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 +1 -2
- package/storages/access_checking.js +5 -2
- package/storages/dataset.d.ts +103 -54
- 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 -39
- 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 +90 -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 +0 -6
- 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
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import type { Dictionary,
|
|
1
|
+
import type { Awaitable, Dictionary, KeyValueStoreBackend, KeyValueStoreInfo } from '@crawlee/types';
|
|
2
2
|
import { Configuration } from '../configuration.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
* Helper function to possibly stringify value if options.contentType is not set.
|
|
7
|
-
*
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
export declare const maybeStringify: <T>(value: T, options: {
|
|
11
|
-
contentType?: string;
|
|
12
|
-
}) => T;
|
|
3
|
+
import type { KeyValueStoreStats } from './storage_stats.js';
|
|
4
|
+
import type { StorageOpenOptions } from './utils.js';
|
|
5
|
+
import type { StorageIdentifier } from './storage_instance_manager.js';
|
|
13
6
|
/**
|
|
14
7
|
* The `KeyValueStore` class represents a key-value store, a simple data storage that is used
|
|
15
8
|
* for saving and reading data records or files. Each data record is
|
|
@@ -67,18 +60,23 @@ export declare const maybeStringify: <T>(value: T, options: {
|
|
|
67
60
|
* @category Result Stores
|
|
68
61
|
*/
|
|
69
62
|
export declare class KeyValueStore {
|
|
70
|
-
readonly
|
|
63
|
+
readonly configuration: Configuration;
|
|
71
64
|
readonly id: string;
|
|
72
65
|
readonly name?: string;
|
|
73
|
-
readonly
|
|
74
|
-
private readonly client;
|
|
66
|
+
private readonly backend;
|
|
75
67
|
private persistStateEventStarted;
|
|
76
68
|
/** Cache for persistent (auto-saved) values. When we try to set such value, the cache will be updated automatically. */
|
|
77
69
|
private readonly cache;
|
|
70
|
+
private readonly statsTracker;
|
|
78
71
|
/**
|
|
79
72
|
* @internal
|
|
80
73
|
*/
|
|
81
|
-
constructor(options: KeyValueStoreOptions,
|
|
74
|
+
constructor(options: KeyValueStoreOptions, configuration?: Configuration);
|
|
75
|
+
/**
|
|
76
|
+
* Backend-independent usage counters tracked for this key-value store (read / write / delete /
|
|
77
|
+
* list operations issued to the underlying storage backend). Counted per backend call.
|
|
78
|
+
*/
|
|
79
|
+
get stats(): KeyValueStoreStats;
|
|
82
80
|
/**
|
|
83
81
|
* Gets a value from the key-value store.
|
|
84
82
|
*
|
|
@@ -143,6 +141,33 @@ export declare class KeyValueStore {
|
|
|
143
141
|
* on the MIME content type of the record, or the default value if the key is missing from the store.
|
|
144
142
|
*/
|
|
145
143
|
getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Reads a record from the key-value store without parsing the value.
|
|
146
|
+
*
|
|
147
|
+
* Use this when you need the raw bytes and the content type — for example, to run your own
|
|
148
|
+
* parser (`simdjson`, a custom XML library, etc.) or to forward the bytes verbatim.
|
|
149
|
+
*
|
|
150
|
+
* There is no symmetric `setRecord` method, because {@link KeyValueStore.setValue} already
|
|
151
|
+
* passes a `Buffer` (or `string` / `Stream`) through unchanged when an explicit `contentType`
|
|
152
|
+
* is provided. To write pre-serialized bytes, call
|
|
153
|
+
* `setValue(key, buffer, { contentType: 'application/json; charset=utf-8' })`.
|
|
154
|
+
*
|
|
155
|
+
* Returns `null` if the record does not exist.
|
|
156
|
+
*
|
|
157
|
+
* **Example usage:**
|
|
158
|
+
* ```javascript
|
|
159
|
+
* const store = await KeyValueStore.open();
|
|
160
|
+
* const record = await store.getRecord('huge.json');
|
|
161
|
+
* if (record) {
|
|
162
|
+
* const data = simdjson.parse(record.value);
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param key
|
|
167
|
+
* Unique key of the record. It can be at most 256 characters long and only consist
|
|
168
|
+
* of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
|
|
169
|
+
*/
|
|
170
|
+
getRecord(key: string): Promise<KeyValueStoreRawRecord | null>;
|
|
146
171
|
/**
|
|
147
172
|
* Tests whether a record with the given key exists in the key-value store without retrieving its value.
|
|
148
173
|
*
|
|
@@ -152,6 +177,8 @@ export declare class KeyValueStore {
|
|
|
152
177
|
recordExists(key: string): Promise<boolean>;
|
|
153
178
|
getAutoSavedValue<T extends Dictionary = Dictionary>(key: string, defaultValue?: T): Promise<T>;
|
|
154
179
|
private ensurePersistStateEvent;
|
|
180
|
+
private fetchKeyValuePages;
|
|
181
|
+
private fetchKeyPages;
|
|
155
182
|
/**
|
|
156
183
|
* Saves or deletes a record in the key-value store.
|
|
157
184
|
* The function returns a promise that resolves once the record has been saved or deleted.
|
|
@@ -207,7 +234,7 @@ export declare class KeyValueStore {
|
|
|
207
234
|
* Iterates over key-value store keys, yielding each in turn to an `iteratee` function.
|
|
208
235
|
* Each invocation of `iteratee` is called with three arguments: `(key, index, info)`, where `key`
|
|
209
236
|
* is the record key, `index` is a zero-based index of the key in the current iteration
|
|
210
|
-
*
|
|
237
|
+
* and `info` is an object that contains a single property `size`
|
|
211
238
|
* indicating size of the record in bytes.
|
|
212
239
|
*
|
|
213
240
|
* If the `iteratee` function returns a Promise then it is awaited before the next call.
|
|
@@ -225,11 +252,99 @@ export declare class KeyValueStore {
|
|
|
225
252
|
* @param [options] All `forEachKey()` parameters.
|
|
226
253
|
*/
|
|
227
254
|
forEachKey(iteratee: KeyConsumer, options?: KeyValueStoreIteratorOptions): Promise<void>;
|
|
228
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Returns key-value store keys.
|
|
257
|
+
*
|
|
258
|
+
* When awaited (`await store.keys()`), returns all keys as a flat `string[]` array.
|
|
259
|
+
* When used as an async iterable (`for await...of`), iterates over all keys across pages
|
|
260
|
+
* without loading everything into memory at once.
|
|
261
|
+
*
|
|
262
|
+
* **Example usage:**
|
|
263
|
+
* ```javascript
|
|
264
|
+
* const keyValueStore = await KeyValueStore.open();
|
|
265
|
+
*
|
|
266
|
+
* // Iterate over all keys (memory-efficient for large stores)
|
|
267
|
+
* for await (const key of keyValueStore.keys()) {
|
|
268
|
+
* console.log(key);
|
|
269
|
+
* }
|
|
270
|
+
*
|
|
271
|
+
* // Or fetch all keys at once
|
|
272
|
+
* const allKeys = await keyValueStore.keys();
|
|
273
|
+
* console.log(allKeys);
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @param options Options for the iteration.
|
|
277
|
+
*/
|
|
278
|
+
keys(options?: KeyValueStoreIteratorOptions): AsyncIterable<string> & Promise<string[]>;
|
|
279
|
+
/**
|
|
280
|
+
* Returns key-value store values.
|
|
281
|
+
*
|
|
282
|
+
* When awaited (`await store.values()`), returns all values as a flat `T[]` array.
|
|
283
|
+
* When used as an async iterable (`for await...of`), iterates over all values across pages
|
|
284
|
+
* without loading everything into memory at once.
|
|
285
|
+
*
|
|
286
|
+
* **Example usage:**
|
|
287
|
+
* ```javascript
|
|
288
|
+
* const keyValueStore = await KeyValueStore.open();
|
|
289
|
+
*
|
|
290
|
+
* // Iterate over all values (memory-efficient for large stores)
|
|
291
|
+
* for await (const value of keyValueStore.values()) {
|
|
292
|
+
* console.log(value);
|
|
293
|
+
* }
|
|
294
|
+
*
|
|
295
|
+
* // Or fetch all values at once
|
|
296
|
+
* const allValues = await keyValueStore.values();
|
|
297
|
+
* console.log(allValues);
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* @param options Options for the iteration.
|
|
301
|
+
*/
|
|
302
|
+
values<T = unknown>(options?: KeyValueStoreIteratorOptions): AsyncIterable<T> & Promise<T[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Returns key-value store entries (key-value pairs).
|
|
305
|
+
*
|
|
306
|
+
* When awaited (`await store.entries()`), returns all entries as a flat `[key, value][]` array.
|
|
307
|
+
* When used as an async iterable (`for await...of`), iterates over all entries across pages
|
|
308
|
+
* without loading everything into memory at once.
|
|
309
|
+
*
|
|
310
|
+
* **Example usage:**
|
|
311
|
+
* ```javascript
|
|
312
|
+
* const keyValueStore = await KeyValueStore.open();
|
|
313
|
+
*
|
|
314
|
+
* // Iterate over all entries (memory-efficient for large stores)
|
|
315
|
+
* for await (const [key, value] of keyValueStore.entries()) {
|
|
316
|
+
* console.log(`${key}: ${value}`);
|
|
317
|
+
* }
|
|
318
|
+
*
|
|
319
|
+
* // Or fetch all entries at once
|
|
320
|
+
* const allEntries = await keyValueStore.entries();
|
|
321
|
+
* console.log(allEntries);
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @param options Options for the iteration.
|
|
325
|
+
*/
|
|
326
|
+
entries<T = unknown>(options?: KeyValueStoreIteratorOptions): AsyncIterable<[string, T]> & Promise<[string, T][]>;
|
|
327
|
+
/**
|
|
328
|
+
* Default async iterator for the key-value store, iterating over entries (key-value pairs).
|
|
329
|
+
* Allows using the store directly in a `for await...of` loop.
|
|
330
|
+
*
|
|
331
|
+
* **Example usage:**
|
|
332
|
+
* ```javascript
|
|
333
|
+
* const keyValueStore = await KeyValueStore.open();
|
|
334
|
+
* for await (const [key, value] of keyValueStore) {
|
|
335
|
+
* console.log(`${key}: ${value}`);
|
|
336
|
+
* }
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
[Symbol.asyncIterator]<T = unknown>(): AsyncGenerator<[string, T], void, undefined>;
|
|
229
340
|
/**
|
|
230
341
|
* Returns a file URL for the given key.
|
|
342
|
+
*
|
|
343
|
+
* If the record does not exist or has no associated file path (i.e., it is not stored as a file), returns `undefined`.
|
|
344
|
+
*
|
|
345
|
+
* @param key The key of the record to generate the public URL for.
|
|
231
346
|
*/
|
|
232
|
-
getPublicUrl(key: string): string
|
|
347
|
+
getPublicUrl(key: string): Promise<string | undefined>;
|
|
233
348
|
/**
|
|
234
349
|
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
235
350
|
*
|
|
@@ -239,12 +354,13 @@ export declare class KeyValueStore {
|
|
|
239
354
|
*
|
|
240
355
|
* For more details and code examples, see the {@link KeyValueStore} class.
|
|
241
356
|
*
|
|
242
|
-
* @param [
|
|
243
|
-
* ID or name of the key-value store to be opened. If
|
|
244
|
-
*
|
|
357
|
+
* @param [identifier]
|
|
358
|
+
* ID or name of the key-value store to be opened. If a string is provided, it will first be
|
|
359
|
+
* looked up as an ID; if no such storage exists, it will be treated as a name.
|
|
360
|
+
* If `null` or `undefined`, the function returns the default key-value store associated with the crawler run.
|
|
245
361
|
* @param [options] Storage manager options.
|
|
246
362
|
*/
|
|
247
|
-
static open(
|
|
363
|
+
static open(identifier?: string | StorageIdentifier | null, options?: StorageOpenOptions): Promise<KeyValueStore>;
|
|
248
364
|
/**
|
|
249
365
|
* Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
250
366
|
*
|
|
@@ -303,6 +419,19 @@ export declare class KeyValueStore {
|
|
|
303
419
|
* @ignore
|
|
304
420
|
*/
|
|
305
421
|
static getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
422
|
+
/**
|
|
423
|
+
* Reads a record from the default {@link KeyValueStore} associated with the current crawler run
|
|
424
|
+
* without parsing the value.
|
|
425
|
+
*
|
|
426
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getRecord}. Returns `null` if the
|
|
427
|
+
* record does not exist.
|
|
428
|
+
*
|
|
429
|
+
* @param key
|
|
430
|
+
* Unique key of the record. It can be at most 256 characters long and only consist
|
|
431
|
+
* of the following characters: `a`-`z`, `A`-`Z`, `0`-`9` and `!-_.'()`
|
|
432
|
+
* @ignore
|
|
433
|
+
*/
|
|
434
|
+
static getRecord(key: string): Promise<KeyValueStoreRawRecord | null>;
|
|
306
435
|
/**
|
|
307
436
|
* Tests whether a record with the given key exists in the default {@link KeyValueStore} associated with the current crawler run.
|
|
308
437
|
* @param key The queried record key.
|
|
@@ -344,8 +473,9 @@ export declare class KeyValueStore {
|
|
|
344
473
|
static setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
|
|
345
474
|
/**
|
|
346
475
|
* Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
347
|
-
*
|
|
348
|
-
*
|
|
476
|
+
*
|
|
477
|
+
* The input is read from the default {@link KeyValueStore} under the configured input key
|
|
478
|
+
* (`CRAWLEE_INPUT_KEY`, default `INPUT`).
|
|
349
479
|
*
|
|
350
480
|
* Note that the `getInput()` function does not cache the value read from the key-value store.
|
|
351
481
|
* If you need to use the input multiple times in your crawler,
|
|
@@ -378,29 +508,27 @@ export interface KeyConsumer {
|
|
|
378
508
|
}): Awaitable<void>;
|
|
379
509
|
}
|
|
380
510
|
export interface KeyValueStoreOptions {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
511
|
+
/** Resolved metadata for the key-value store, as returned by the backend's `getMetadata()`. */
|
|
512
|
+
metadata: KeyValueStoreInfo;
|
|
513
|
+
backend: KeyValueStoreBackend;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* A raw, unparsed key-value store record as returned by {@link KeyValueStore.getRecord}: the
|
|
517
|
+
* verbatim bytes plus the content type, with parsing left to the caller.
|
|
518
|
+
*/
|
|
519
|
+
export interface KeyValueStoreRawRecord {
|
|
520
|
+
value: Buffer | ArrayBuffer;
|
|
521
|
+
contentType: string | null;
|
|
385
522
|
}
|
|
386
523
|
export interface RecordOptions {
|
|
387
524
|
/**
|
|
388
525
|
* Specifies a custom MIME content type of the record.
|
|
389
526
|
*/
|
|
390
527
|
contentType?: string;
|
|
391
|
-
/**
|
|
392
|
-
* Specifies a custom timeout for the `set-record` API call, in seconds.
|
|
393
|
-
*/
|
|
394
|
-
timeoutSecs?: number;
|
|
395
|
-
/**
|
|
396
|
-
* If set to `true`, the `set-record` API call will not be retried if it times out.
|
|
397
|
-
*/
|
|
398
|
-
doNotRetryTimeouts?: boolean;
|
|
399
528
|
}
|
|
400
529
|
export interface KeyValueStoreIteratorOptions {
|
|
401
530
|
/**
|
|
402
|
-
*
|
|
531
|
+
* If set, only keys that start with this prefix are returned.
|
|
403
532
|
*/
|
|
404
|
-
|
|
533
|
+
prefix?: string;
|
|
405
534
|
}
|
|
406
|
-
//# sourceMappingURL=key_value_store.d.ts.map
|