@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.
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 +84 -13
  86. package/request.js +107 -28
  87. package/router.d.ts +143 -17
  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 +0 -1
  106. package/storages/access_checking.js +5 -2
  107. package/storages/dataset.d.ts +103 -53
  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 -38
  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 +91 -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 +1 -2
  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,27 +1,21 @@
1
- import type { DatasetClient, DatasetInfo, Dictionary, StorageClient } from '@crawlee/types';
1
+ import type { DatasetBackend, DatasetInfo, Dictionary } from '@crawlee/types';
2
2
  import { Configuration } from '../configuration.js';
3
- import { type Log } from '../log.js';
3
+ import type { CrawleeLogger } from '../log.js';
4
4
  import type { Awaitable } from '../typedefs.js';
5
- import type { StorageManagerOptions } from './storage_manager.js';
5
+ import type { DatasetStats } from './storage_stats.js';
6
+ import type { StorageIdentifier } from './storage_instance_manager.js';
7
+ import type { StorageOpenOptions } from './utils.js';
6
8
  /** @internal */
7
9
  export declare const DATASET_ITERATORS_DEFAULT_LIMIT = 10000;
8
10
  /**
9
- * Accepts a JSON serializable object as an input, validates its serializability,
10
- * and validates its serialized size against limitBytes. Optionally accepts its index
11
- * in an array to provide better error messages. Returns serialized object.
12
- * @ignore
13
- */
14
- export declare function checkAndSerialize<T>(item: T, limitBytes: number, index?: number): string;
15
- /**
16
- * Takes an array of JSONs (payloads) as input and produces an array of JSON strings
17
- * where each string is a JSON array of payloads with a maximum size of limitBytes per one
18
- * JSON array. Fits as many payloads as possible into a single JSON array and then moves
19
- * on to the next, preserving item order.
11
+ * Validates that the given value is a plain JSON-serializable object
12
+ * (not an array, not a primitive, not circular).
20
13
  *
21
- * The function assumes that none of the items is larger than limitBytes and does not validate.
14
+ * @param item The value to validate.
15
+ * @param index Optional index for error messages when validating inside an array.
22
16
  * @ignore
23
17
  */
24
- export declare function chunkBySize(items: string[], limitBytes: number): string[];
18
+ export declare function assertJsonSerializable<T>(item: T, index?: number): void;
25
19
  export interface DatasetDataOptions {
26
20
  /**
27
21
  * Number of array elements that should be skipped at the start.
@@ -67,6 +61,11 @@ export interface DatasetDataOptions {
67
61
  skipEmpty?: boolean;
68
62
  }
69
63
  export interface DatasetExportOptions extends Omit<DatasetDataOptions, 'offset' | 'limit'> {
64
+ /**
65
+ * If true, includes all unique keys from all dataset items in the CSV export header.
66
+ * If omitted or false, only keys from the first item are used.
67
+ */
68
+ collectAllKeys?: boolean;
70
69
  }
71
70
  export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset' | 'limit' | 'clean' | 'skipHidden' | 'skipEmpty'> {
72
71
  /** @internal */
@@ -86,8 +85,8 @@ export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset
86
85
  format?: string;
87
86
  }
88
87
  export interface DatasetExportToOptions extends DatasetExportOptions {
89
- fromDataset?: string;
90
- toKVS?: string;
88
+ fromDataset?: string | StorageIdentifier;
89
+ toKVS?: string | StorageIdentifier;
91
90
  }
92
91
  /**
93
92
  * The `Dataset` class represents a store for structured data where each object stored has the same attributes,
@@ -141,15 +140,21 @@ export interface DatasetExportToOptions extends DatasetExportOptions {
141
140
  * @category Result Stores
142
141
  */
143
142
  export declare class Dataset<Data extends Dictionary = Dictionary> {
144
- readonly config: Configuration;
143
+ readonly configuration: Configuration;
145
144
  id: string;
146
145
  name?: string;
147
- client: DatasetClient<Data>;
148
- log: Log;
146
+ backend: DatasetBackend<Data>;
147
+ log: CrawleeLogger;
148
+ private readonly statsTracker;
149
149
  /**
150
150
  * @internal
151
151
  */
152
- constructor(options: DatasetOptions, config?: Configuration);
152
+ constructor(options: DatasetOptions, configuration?: Configuration);
153
+ /**
154
+ * Backend-independent usage counters tracked for this dataset (read / write operations issued to
155
+ * the underlying storage backend). Counted per backend call.
156
+ */
157
+ get stats(): DatasetStats;
153
158
  /**
154
159
  * Stores an object or an array of objects to the dataset.
155
160
  * The function returns a promise that resolves when the operation finishes.
@@ -158,21 +163,8 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
158
163
  * **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
159
164
  * otherwise the crawler process might finish before the data is stored!
160
165
  *
161
- * The size of the data is limited by the receiving API and therefore `pushData()` will only
162
- * allow objects whose JSON representation is smaller than 9MB. When an array is passed,
163
- * none of the included objects
164
- * may be larger than 9MB, but the array itself may be of any size.
165
- *
166
- * The function internally
167
- * chunks the array into separate items and pushes them sequentially.
168
- * The chunking process is stable (keeps order of data), but it does not provide a transaction
169
- * safety mechanism. Therefore, in the event of an uploading error (after several automatic retries),
170
- * the function's Promise will reject and the dataset will be left in a state where some of
171
- * the items have already been saved to the dataset while other items from the source array were not.
172
- * To overcome this limitation, the developer may, for example, read the last item saved in the dataset
173
- * and re-attempt the save of the data from this item onwards to prevent duplicates.
174
166
  * @param data Object or array of objects containing data to be stored in the default dataset.
175
- * The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
167
+ * The objects must be serializable to JSON.
176
168
  */
177
169
  pushData(data: Data | Data[]): Promise<void>;
178
170
  /**
@@ -223,26 +215,21 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
223
215
  /**
224
216
  * Returns an object containing general information about the dataset.
225
217
  *
226
- * The function returns the same object as the Apify API Client's
227
- * [getDataset](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-datasets-getDataset)
228
- * function, which in turn calls the
229
- * [Get dataset](https://apify.com/docs/api/v2#/reference/datasets/dataset/get-dataset)
230
- * API endpoint.
231
- *
232
218
  * **Example:**
233
219
  * ```
234
220
  * {
235
221
  * id: "WkzbQMuFYuamGv3YF",
236
222
  * name: "my-dataset",
237
- * userId: "wRsJZtadYvn4mBZmm",
238
223
  * createdAt: new Date("2015-12-12T07:34:14.202Z"),
239
224
  * modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
240
225
  * accessedAt: new Date("2015-12-14T08:36:13.202Z"),
241
226
  * itemCount: 14,
242
227
  * }
243
228
  * ```
229
+ *
230
+ * @throws If the underlying storage no longer exists (e.g. it was deleted externally).
244
231
  */
245
- getInfo(): Promise<DatasetInfo | undefined>;
232
+ getInfo(): Promise<DatasetInfo>;
246
233
  /**
247
234
  * Iterates over dataset items, yielding each in turn to an `iteratee` function.
248
235
  * Each invocation of `iteratee` is called with two arguments: `(item, index)`.
@@ -308,7 +295,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
308
295
  * If the dataset is empty, reduce will return undefined.
309
296
  *
310
297
  * @param iteratee
311
- * @param memo Unset parameter, neccesary to be able to pass options
298
+ * @param memo Unset parameter, necessary to be able to pass options
312
299
  * @param [options] An object containing extra options for `reduce()`
313
300
  */
314
301
  reduce(iteratee: DatasetReducer<Data, Data>, memo: undefined, options: DatasetIteratorOptions): Promise<Data | undefined>;
@@ -326,6 +313,69 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
326
313
  * @param [options] An object containing extra options for `reduce()`
327
314
  */
328
315
  reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
316
+ private fetchEntryPages;
317
+ private fetchPages;
318
+ /**
319
+ * Returns dataset items.
320
+ *
321
+ * When awaited (`await dataset.values()`), returns all items as a flat `Data[]` array.
322
+ * When used as an async iterable (`for await...of`), iterates over all items across pages
323
+ * without loading everything into memory at once.
324
+ *
325
+ * **Example usage:**
326
+ * ```javascript
327
+ * const dataset = await Dataset.open('my-results');
328
+ *
329
+ * // Iterate over all items (memory-efficient for large datasets)
330
+ * for await (const item of dataset.values()) {
331
+ * console.log(item);
332
+ * }
333
+ *
334
+ * // Or fetch all items at once
335
+ * const items = await dataset.values();
336
+ * console.log(items);
337
+ * ```
338
+ *
339
+ * @param options Options for the iteration.
340
+ */
341
+ values(options?: DatasetIteratorOptions): AsyncIterable<Data> & Promise<Data[]>;
342
+ /**
343
+ * Returns dataset entries (index-value pairs).
344
+ *
345
+ * When awaited (`await dataset.entries()`), returns all entries as a flat `[index, item][]` array.
346
+ * When used as an async iterable (`for await...of`), iterates over all entries across pages
347
+ * without loading everything into memory at once.
348
+ *
349
+ * **Example usage:**
350
+ * ```javascript
351
+ * const dataset = await Dataset.open('my-results');
352
+ *
353
+ * // Iterate over all entries
354
+ * for await (const [index, item] of dataset.entries()) {
355
+ * console.log(`Item at ${index}: ${JSON.stringify(item)}`);
356
+ * }
357
+ *
358
+ * // Or fetch all at once
359
+ * const entries = await dataset.entries();
360
+ * console.log(entries);
361
+ * ```
362
+ *
363
+ * @param options Options for the iteration.
364
+ */
365
+ entries(options?: DatasetIteratorOptions): AsyncIterable<[number, Data]> & Promise<[number, Data][]>;
366
+ /**
367
+ * Default async iterator for the dataset, iterating over items.
368
+ * Allows using the dataset directly in a `for await...of` loop.
369
+ *
370
+ * **Example usage:**
371
+ * ```javascript
372
+ * const dataset = await Dataset.open('my-results');
373
+ * for await (const item of dataset) {
374
+ * console.log(item);
375
+ * }
376
+ * ```
377
+ */
378
+ [Symbol.asyncIterator](): AsyncGenerator<Data, void, undefined>;
329
379
  /**
330
380
  * Removes the dataset either from the Apify cloud storage or from the local directory,
331
381
  * depending on the mode of operation.
@@ -340,12 +390,13 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
340
390
  *
341
391
  * For more details and code examples, see the {@link Dataset} class.
342
392
  *
343
- * @param [datasetIdOrName]
344
- * ID or name of the dataset to be opened. If `null` or `undefined`,
345
- * the function returns the default dataset associated with the crawler run.
393
+ * @param [identifier]
394
+ * ID or name of the dataset to be opened. If a string is provided, it will first be
395
+ * looked up as an ID; if no such storage exists, it will be treated as a name.
396
+ * If `null` or `undefined`, the function returns the default dataset associated with the crawler run.
346
397
  * @param [options] Storage manager options.
347
398
  */
348
- static open<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: StorageManagerOptions): Promise<Dataset<Data>>;
399
+ static open<Data extends Dictionary = Dictionary>(identifier?: string | StorageIdentifier | null, options?: StorageOpenOptions): Promise<Dataset<Data>>;
349
400
  /**
350
401
  * Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
351
402
  *
@@ -409,9 +460,9 @@ export interface DatasetReducer<T, Data> {
409
460
  (memo: T, item: Data, index: number): Awaitable<T>;
410
461
  }
411
462
  export interface DatasetOptions {
412
- id: string;
413
- name?: string;
414
- client: StorageClient;
463
+ /** Resolved metadata for the dataset, as returned by the backend's `getMetadata()`. */
464
+ metadata: DatasetInfo;
465
+ backend: DatasetBackend;
415
466
  }
416
467
  export interface DatasetContent<Data> {
417
468
  /** Total count of entries in the dataset. */
@@ -427,4 +478,3 @@ export interface DatasetContent<Data> {
427
478
  /** Should the results be in descending order. */
428
479
  desc?: boolean;
429
480
  }
430
- //# sourceMappingURL=dataset.d.ts.map