@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.
Files changed (263) hide show
  1. package/README.md +17 -13
  2. package/autoscaling/autoscaled_pool.d.ts +66 -153
  3. package/autoscaling/autoscaled_pool.js +95 -251
  4. package/autoscaling/client_load_signal.d.ts +59 -0
  5. package/autoscaling/client_load_signal.js +73 -0
  6. package/autoscaling/concurrency_system.d.ts +283 -0
  7. package/autoscaling/concurrency_system.js +350 -0
  8. package/autoscaling/cpu_load_signal.d.ts +44 -0
  9. package/autoscaling/cpu_load_signal.js +46 -0
  10. package/autoscaling/event_loop_load_signal.d.ts +54 -0
  11. package/autoscaling/event_loop_load_signal.js +60 -0
  12. package/autoscaling/index.d.ts +6 -1
  13. package/autoscaling/index.js +6 -1
  14. package/autoscaling/load_signal.d.ts +99 -0
  15. package/autoscaling/load_signal.js +103 -0
  16. package/autoscaling/memory_load_signal.d.ts +56 -0
  17. package/autoscaling/memory_load_signal.js +106 -0
  18. package/autoscaling/snapshotter.d.ts +61 -163
  19. package/autoscaling/snapshotter.js +45 -263
  20. package/autoscaling/system_status.d.ts +63 -83
  21. package/autoscaling/system_status.js +90 -120
  22. package/configuration.d.ts +90 -223
  23. package/configuration.js +164 -222
  24. package/cookie_utils.d.ts +4 -3
  25. package/cookie_utils.js +20 -13
  26. package/crawlers/context_pipeline.d.ts +70 -0
  27. package/crawlers/context_pipeline.js +122 -0
  28. package/crawlers/crawler_commons.d.ts +76 -33
  29. package/crawlers/crawler_commons.js +15 -24
  30. package/crawlers/crawler_utils.d.ts +2 -3
  31. package/crawlers/crawler_utils.js +1 -2
  32. package/crawlers/error_snapshotter.d.ts +3 -3
  33. package/crawlers/error_snapshotter.js +2 -3
  34. package/crawlers/error_tracker.d.ts +2 -2
  35. package/crawlers/error_tracker.js +0 -1
  36. package/crawlers/index.d.ts +1 -2
  37. package/crawlers/index.js +1 -2
  38. package/crawlers/internals/types.d.ts +7 -0
  39. package/crawlers/internals/types.js +1 -0
  40. package/crawlers/statistics.d.ts +28 -23
  41. package/crawlers/statistics.js +38 -34
  42. package/debug.d.ts +36 -0
  43. package/debug.js +70 -0
  44. package/enqueue_links/enqueue_links.d.ts +44 -22
  45. package/enqueue_links/enqueue_links.js +51 -30
  46. package/enqueue_links/index.d.ts +0 -1
  47. package/enqueue_links/index.js +0 -1
  48. package/enqueue_links/shared.d.ts +25 -9
  49. package/enqueue_links/shared.js +69 -38
  50. package/errors.d.ts +53 -4
  51. package/errors.js +70 -5
  52. package/events/event_manager.d.ts +34 -8
  53. package/events/event_manager.js +8 -10
  54. package/events/index.d.ts +0 -1
  55. package/events/index.js +0 -1
  56. package/events/local_event_manager.d.ts +15 -3
  57. package/events/local_event_manager.js +37 -11
  58. package/index.d.ts +6 -3
  59. package/index.js +5 -2
  60. package/log.d.ts +82 -3
  61. package/log.js +102 -1
  62. package/memory-storage/consts.d.ts +4 -0
  63. package/memory-storage/consts.js +4 -0
  64. package/memory-storage/index.d.ts +1 -0
  65. package/memory-storage/index.js +1 -0
  66. package/memory-storage/memory-storage.d.ts +46 -0
  67. package/memory-storage/memory-storage.js +136 -0
  68. package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
  69. package/memory-storage/resource-clients/common/base-client.js +6 -0
  70. package/memory-storage/resource-clients/dataset.d.ts +40 -0
  71. package/memory-storage/resource-clients/dataset.js +113 -0
  72. package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
  73. package/memory-storage/resource-clients/key-value-store.js +203 -0
  74. package/memory-storage/resource-clients/request-queue.d.ts +96 -0
  75. package/memory-storage/resource-clients/request-queue.js +421 -0
  76. package/memory-storage/utils.d.ts +17 -0
  77. package/memory-storage/utils.js +42 -0
  78. package/owned_or_injected.d.ts +60 -0
  79. package/owned_or_injected.js +98 -0
  80. package/package.json +12 -10
  81. package/proxy_configuration.d.ts +29 -152
  82. package/proxy_configuration.js +21 -173
  83. package/recoverable_state.d.ts +120 -0
  84. package/recoverable_state.js +143 -0
  85. package/request.d.ts +85 -15
  86. package/request.js +107 -28
  87. package/router.d.ts +144 -19
  88. package/router.js +125 -30
  89. package/serialization.d.ts +0 -1
  90. package/serialization.js +1 -2
  91. package/service_locator.d.ts +156 -0
  92. package/service_locator.js +238 -0
  93. package/session_pool/consts.d.ts +1 -2
  94. package/session_pool/consts.js +1 -2
  95. package/session_pool/errors.d.ts +0 -1
  96. package/session_pool/errors.js +0 -1
  97. package/session_pool/fingerprint.d.ts +9 -0
  98. package/session_pool/fingerprint.js +30 -0
  99. package/session_pool/index.d.ts +0 -2
  100. package/session_pool/index.js +0 -2
  101. package/session_pool/session.d.ts +37 -75
  102. package/session_pool/session.js +49 -102
  103. package/session_pool/session_pool.d.ts +85 -90
  104. package/session_pool/session_pool.js +131 -120
  105. package/storages/access_checking.d.ts +1 -2
  106. package/storages/access_checking.js +5 -2
  107. package/storages/dataset.d.ts +103 -54
  108. package/storages/dataset.js +174 -132
  109. package/storages/index.d.ts +8 -7
  110. package/storages/index.js +6 -7
  111. package/storages/key_value_store.d.ts +167 -39
  112. package/storages/key_value_store.js +274 -127
  113. package/storages/key_value_store_codec.d.ts +32 -0
  114. package/storages/key_value_store_codec.js +113 -0
  115. package/storages/request_dedup_cache.d.ts +23 -0
  116. package/storages/request_dedup_cache.js +48 -0
  117. package/storages/request_list.d.ts +54 -98
  118. package/storages/request_list.js +99 -75
  119. package/storages/request_loader.d.ts +96 -0
  120. package/storages/request_loader.js +1 -0
  121. package/storages/request_manager.d.ts +33 -0
  122. package/storages/request_manager.js +1 -0
  123. package/storages/request_manager_tandem.d.ts +106 -0
  124. package/storages/request_manager_tandem.js +197 -0
  125. package/storages/request_queue.d.ts +290 -47
  126. package/storages/request_queue.js +629 -215
  127. package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +28 -24
  128. package/storages/{sitemap_request_list.js → sitemap_request_loader.js} +49 -47
  129. package/storages/storage_instance_manager.d.ts +90 -0
  130. package/storages/storage_instance_manager.js +258 -0
  131. package/storages/storage_stats.d.ts +48 -0
  132. package/storages/storage_stats.js +29 -0
  133. package/storages/utils.d.ts +54 -9
  134. package/storages/utils.js +64 -13
  135. package/system-info/cpu-info.d.ts +67 -0
  136. package/system-info/cpu-info.js +216 -0
  137. package/system-info/memory-info.d.ts +31 -0
  138. package/system-info/memory-info.js +115 -0
  139. package/system-info/ps-tree.d.ts +17 -0
  140. package/system-info/ps-tree.js +144 -0
  141. package/system-info/runtime.d.ts +14 -0
  142. package/system-info/runtime.js +80 -0
  143. package/typedefs.d.ts +0 -6
  144. package/typedefs.js +0 -1
  145. package/validators.d.ts +8 -1
  146. package/validators.js +10 -3
  147. package/autoscaling/autoscaled_pool.d.ts.map +0 -1
  148. package/autoscaling/autoscaled_pool.js.map +0 -1
  149. package/autoscaling/index.d.ts.map +0 -1
  150. package/autoscaling/index.js.map +0 -1
  151. package/autoscaling/snapshotter.d.ts.map +0 -1
  152. package/autoscaling/snapshotter.js.map +0 -1
  153. package/autoscaling/system_status.d.ts.map +0 -1
  154. package/autoscaling/system_status.js.map +0 -1
  155. package/configuration.d.ts.map +0 -1
  156. package/configuration.js.map +0 -1
  157. package/cookie_utils.d.ts.map +0 -1
  158. package/cookie_utils.js.map +0 -1
  159. package/crawlers/crawler_commons.d.ts.map +0 -1
  160. package/crawlers/crawler_commons.js.map +0 -1
  161. package/crawlers/crawler_extension.d.ts +0 -12
  162. package/crawlers/crawler_extension.d.ts.map +0 -1
  163. package/crawlers/crawler_extension.js +0 -14
  164. package/crawlers/crawler_extension.js.map +0 -1
  165. package/crawlers/crawler_utils.d.ts.map +0 -1
  166. package/crawlers/crawler_utils.js.map +0 -1
  167. package/crawlers/error_snapshotter.d.ts.map +0 -1
  168. package/crawlers/error_snapshotter.js.map +0 -1
  169. package/crawlers/error_tracker.d.ts.map +0 -1
  170. package/crawlers/error_tracker.js.map +0 -1
  171. package/crawlers/index.d.ts.map +0 -1
  172. package/crawlers/index.js.map +0 -1
  173. package/crawlers/statistics.d.ts.map +0 -1
  174. package/crawlers/statistics.js.map +0 -1
  175. package/enqueue_links/enqueue_links.d.ts.map +0 -1
  176. package/enqueue_links/enqueue_links.js.map +0 -1
  177. package/enqueue_links/index.d.ts.map +0 -1
  178. package/enqueue_links/index.js.map +0 -1
  179. package/enqueue_links/shared.d.ts.map +0 -1
  180. package/enqueue_links/shared.js.map +0 -1
  181. package/errors.d.ts.map +0 -1
  182. package/errors.js.map +0 -1
  183. package/events/event_manager.d.ts.map +0 -1
  184. package/events/event_manager.js.map +0 -1
  185. package/events/index.d.ts.map +0 -1
  186. package/events/index.js.map +0 -1
  187. package/events/local_event_manager.d.ts.map +0 -1
  188. package/events/local_event_manager.js.map +0 -1
  189. package/http_clients/base-http-client.d.ts +0 -134
  190. package/http_clients/base-http-client.d.ts.map +0 -1
  191. package/http_clients/base-http-client.js +0 -33
  192. package/http_clients/base-http-client.js.map +0 -1
  193. package/http_clients/form-data-like.d.ts +0 -67
  194. package/http_clients/form-data-like.d.ts.map +0 -1
  195. package/http_clients/form-data-like.js +0 -5
  196. package/http_clients/form-data-like.js.map +0 -1
  197. package/http_clients/got-scraping-http-client.d.ts +0 -15
  198. package/http_clients/got-scraping-http-client.d.ts.map +0 -1
  199. package/http_clients/got-scraping-http-client.js +0 -69
  200. package/http_clients/got-scraping-http-client.js.map +0 -1
  201. package/http_clients/index.d.ts +0 -3
  202. package/http_clients/index.d.ts.map +0 -1
  203. package/http_clients/index.js +0 -3
  204. package/http_clients/index.js.map +0 -1
  205. package/index.d.ts.map +0 -1
  206. package/index.js.map +0 -1
  207. package/log.d.ts.map +0 -1
  208. package/log.js.map +0 -1
  209. package/proxy_configuration.d.ts.map +0 -1
  210. package/proxy_configuration.js.map +0 -1
  211. package/request.d.ts.map +0 -1
  212. package/request.js.map +0 -1
  213. package/router.d.ts.map +0 -1
  214. package/router.js.map +0 -1
  215. package/serialization.d.ts.map +0 -1
  216. package/serialization.js.map +0 -1
  217. package/session_pool/consts.d.ts.map +0 -1
  218. package/session_pool/consts.js.map +0 -1
  219. package/session_pool/errors.d.ts.map +0 -1
  220. package/session_pool/errors.js.map +0 -1
  221. package/session_pool/events.d.ts +0 -3
  222. package/session_pool/events.d.ts.map +0 -1
  223. package/session_pool/events.js +0 -3
  224. package/session_pool/events.js.map +0 -1
  225. package/session_pool/index.d.ts.map +0 -1
  226. package/session_pool/index.js.map +0 -1
  227. package/session_pool/session.d.ts.map +0 -1
  228. package/session_pool/session.js.map +0 -1
  229. package/session_pool/session_pool.d.ts.map +0 -1
  230. package/session_pool/session_pool.js.map +0 -1
  231. package/storages/access_checking.d.ts.map +0 -1
  232. package/storages/access_checking.js.map +0 -1
  233. package/storages/dataset.d.ts.map +0 -1
  234. package/storages/dataset.js.map +0 -1
  235. package/storages/index.d.ts.map +0 -1
  236. package/storages/index.js.map +0 -1
  237. package/storages/key_value_store.d.ts.map +0 -1
  238. package/storages/key_value_store.js.map +0 -1
  239. package/storages/request_list.d.ts.map +0 -1
  240. package/storages/request_list.js.map +0 -1
  241. package/storages/request_provider.d.ts +0 -307
  242. package/storages/request_provider.d.ts.map +0 -1
  243. package/storages/request_provider.js +0 -555
  244. package/storages/request_provider.js.map +0 -1
  245. package/storages/request_queue.d.ts.map +0 -1
  246. package/storages/request_queue.js.map +0 -1
  247. package/storages/request_queue_v2.d.ts +0 -87
  248. package/storages/request_queue_v2.d.ts.map +0 -1
  249. package/storages/request_queue_v2.js +0 -438
  250. package/storages/request_queue_v2.js.map +0 -1
  251. package/storages/sitemap_request_list.d.ts.map +0 -1
  252. package/storages/sitemap_request_list.js.map +0 -1
  253. package/storages/storage_manager.d.ts +0 -58
  254. package/storages/storage_manager.d.ts.map +0 -1
  255. package/storages/storage_manager.js +0 -105
  256. package/storages/storage_manager.js.map +0 -1
  257. package/storages/utils.d.ts.map +0 -1
  258. package/storages/utils.js.map +0 -1
  259. package/tsconfig.build.tsbuildinfo +0 -1
  260. package/typedefs.d.ts.map +0 -1
  261. package/typedefs.js.map +0 -1
  262. package/validators.d.ts.map +0 -1
  263. package/validators.js.map +0 -1
@@ -1,15 +1,8 @@
1
- import type { Dictionary, StorageClient } from '@crawlee/types';
1
+ import type { Awaitable, Dictionary, KeyValueStoreBackend, KeyValueStoreInfo } from '@crawlee/types';
2
2
  import { Configuration } from '../configuration.js';
3
- import type { Awaitable } from '../typedefs.js';
4
- import type { StorageManagerOptions } from './storage_manager.js';
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 config: Configuration;
63
+ readonly configuration: Configuration;
71
64
  readonly id: string;
72
65
  readonly name?: string;
73
- readonly storageObject?: Record<string, unknown>;
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, config?: Configuration);
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
- * (regardless of `options.exclusiveStartKey`) and `info` is an object that contains a single property `size`
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
- private _forEachKey;
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 [storeIdOrName]
243
- * ID or name of the key-value store to be opened. If `null` or `undefined`,
244
- * the function returns the default key-value store associated with the crawler run.
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(storeIdOrName?: string | null, options?: StorageManagerOptions): Promise<KeyValueStore>;
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
- * By default, it will try to find root input files (either extension-less, `.json` or `.txt`),
348
- * or alternatively read the input from the default {@link KeyValueStore}.
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
- id: string;
382
- name?: string;
383
- client: StorageClient;
384
- storageObject?: Record<string, unknown>;
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
- * All keys up to this one (including) are skipped from the result.
531
+ * If set, only keys that start with this prefix are returned.
403
532
  */
404
- exclusiveStartKey?: string;
533
+ prefix?: string;
405
534
  }
406
- //# sourceMappingURL=key_value_store.d.ts.map