@crawlee/core 4.0.0-beta.14 → 4.0.0-beta.140

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 (287) hide show
  1. package/README.md +14 -14
  2. package/autoscaling/autoscaled_pool.d.ts +67 -172
  3. package/autoscaling/autoscaled_pool.js +182 -329
  4. package/autoscaling/concurrency_system.d.ts +269 -0
  5. package/autoscaling/concurrency_system.js +365 -0
  6. package/autoscaling/cpu_load_signal.d.ts +43 -0
  7. package/autoscaling/cpu_load_signal.js +47 -0
  8. package/autoscaling/event_loop_load_signal.d.ts +51 -0
  9. package/autoscaling/event_loop_load_signal.js +60 -0
  10. package/autoscaling/index.d.ts +6 -1
  11. package/autoscaling/index.js +6 -1
  12. package/autoscaling/load_signal.d.ts +100 -0
  13. package/autoscaling/load_signal.js +105 -0
  14. package/autoscaling/memory_load_signal.d.ts +47 -0
  15. package/autoscaling/memory_load_signal.js +106 -0
  16. package/autoscaling/snapshotter.d.ts +58 -163
  17. package/autoscaling/snapshotter.js +45 -263
  18. package/autoscaling/storage_backend_load_signal.d.ts +56 -0
  19. package/autoscaling/storage_backend_load_signal.js +73 -0
  20. package/autoscaling/system_status.d.ts +67 -89
  21. package/autoscaling/system_status.js +92 -122
  22. package/autoscaling/weighted_avg.d.ts +5 -0
  23. package/autoscaling/weighted_avg.js +14 -0
  24. package/byte_utils.d.ts +17 -0
  25. package/byte_utils.js +42 -0
  26. package/configuration.d.ts +96 -223
  27. package/configuration.js +170 -222
  28. package/cookie_utils.d.ts +3 -2
  29. package/cookie_utils.js +18 -7
  30. package/crawlers/context_pipeline.d.ts +10 -1
  31. package/crawlers/context_pipeline.js +31 -8
  32. package/crawlers/crawler_commons.d.ts +90 -126
  33. package/crawlers/crawler_commons.js +1 -108
  34. package/crawlers/error_snapshotter.d.ts +2 -5
  35. package/crawlers/error_snapshotter.js +7 -8
  36. package/crawlers/error_tracker.d.ts +0 -1
  37. package/crawlers/error_tracker.js +0 -1
  38. package/crawlers/index.d.ts +1 -3
  39. package/crawlers/index.js +0 -3
  40. package/crawlers/internals/types.d.ts +0 -1
  41. package/crawlers/internals/types.js +0 -1
  42. package/crawlers/statistics.d.ts +187 -63
  43. package/crawlers/statistics.js +354 -164
  44. package/debug.d.ts +36 -0
  45. package/debug.js +70 -0
  46. package/enqueue_links/enqueue_links.d.ts +60 -153
  47. package/enqueue_links/enqueue_links.js +38 -229
  48. package/enqueue_links/index.d.ts +0 -1
  49. package/enqueue_links/index.js +0 -1
  50. package/enqueue_links/shared.d.ts +49 -30
  51. package/enqueue_links/shared.js +94 -68
  52. package/errors.d.ts +72 -4
  53. package/errors.js +89 -5
  54. package/events/event_manager.d.ts +35 -9
  55. package/events/event_manager.js +12 -13
  56. package/events/index.d.ts +0 -1
  57. package/events/index.js +0 -1
  58. package/events/local_event_manager.d.ts +15 -3
  59. package/events/local_event_manager.js +39 -13
  60. package/http.d.ts +9 -0
  61. package/http.js +28 -0
  62. package/index.d.ts +7 -5
  63. package/index.js +8 -4
  64. package/iterables.d.ts +79 -0
  65. package/iterables.js +134 -0
  66. package/log.d.ts +78 -1
  67. package/log.js +106 -1
  68. package/memory-storage/consts.d.ts +4 -0
  69. package/memory-storage/consts.js +4 -0
  70. package/memory-storage/index.d.ts +1 -0
  71. package/memory-storage/index.js +1 -0
  72. package/memory-storage/memory-storage.d.ts +44 -0
  73. package/memory-storage/memory-storage.js +160 -0
  74. package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
  75. package/memory-storage/resource-clients/common/base-client.js +6 -0
  76. package/memory-storage/resource-clients/dataset.d.ts +40 -0
  77. package/memory-storage/resource-clients/dataset.js +106 -0
  78. package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
  79. package/memory-storage/resource-clients/key-value-store.js +199 -0
  80. package/memory-storage/resource-clients/request-queue.d.ts +77 -0
  81. package/memory-storage/resource-clients/request-queue.js +407 -0
  82. package/memory-storage/utils.d.ts +16 -0
  83. package/memory-storage/utils.js +41 -0
  84. package/owned_or_injected.d.ts +58 -0
  85. package/owned_or_injected.js +98 -0
  86. package/package.json +13 -12
  87. package/proxy_configuration.d.ts +22 -128
  88. package/proxy_configuration.js +32 -144
  89. package/recoverable_state.d.ts +83 -51
  90. package/recoverable_state.js +163 -72
  91. package/request.d.ts +57 -16
  92. package/request.js +130 -69
  93. package/router.d.ts +193 -21
  94. package/router.js +188 -43
  95. package/serialization.d.ts +0 -1
  96. package/serialization.js +15 -15
  97. package/service_locator.d.ts +165 -0
  98. package/service_locator.js +253 -0
  99. package/session_pool/consts.d.ts +1 -2
  100. package/session_pool/consts.js +1 -2
  101. package/session_pool/errors.d.ts +0 -1
  102. package/session_pool/errors.js +0 -1
  103. package/session_pool/fingerprint.d.ts +9 -0
  104. package/session_pool/fingerprint.js +30 -0
  105. package/session_pool/index.d.ts +0 -2
  106. package/session_pool/index.js +0 -2
  107. package/session_pool/session.d.ts +35 -88
  108. package/session_pool/session.js +101 -159
  109. package/session_pool/session_pool.d.ts +74 -91
  110. package/session_pool/session_pool.js +175 -165
  111. package/storages/batched_adds.d.ts +37 -0
  112. package/storages/batched_adds.js +73 -0
  113. package/storages/dataset.d.ts +109 -56
  114. package/storages/dataset.js +283 -149
  115. package/storages/index.d.ts +9 -9
  116. package/storages/index.js +7 -9
  117. package/storages/key_value_store.d.ts +183 -48
  118. package/storages/key_value_store.js +445 -171
  119. package/storages/key_value_store_codec.d.ts +32 -0
  120. package/storages/key_value_store_codec.js +113 -0
  121. package/storages/request_dedup_cache.d.ts +22 -0
  122. package/storages/request_dedup_cache.js +48 -0
  123. package/storages/request_list.d.ts +52 -109
  124. package/storages/request_list.js +183 -152
  125. package/storages/request_loader.d.ts +101 -0
  126. package/storages/request_loader.js +1 -0
  127. package/storages/request_manager.d.ts +33 -0
  128. package/storages/request_manager.js +1 -0
  129. package/storages/request_manager_tandem.d.ts +48 -19
  130. package/storages/request_manager_tandem.js +118 -45
  131. package/storages/request_queue.d.ts +290 -47
  132. package/storages/request_queue.js +762 -216
  133. package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +45 -89
  134. package/storages/sitemap_request_loader.js +438 -0
  135. package/storages/storage_instance_manager.d.ts +87 -0
  136. package/storages/storage_instance_manager.js +256 -0
  137. package/storages/storage_stats.d.ts +48 -0
  138. package/storages/storage_stats.js +29 -0
  139. package/storages/throttling_request_manager.d.ts +239 -0
  140. package/storages/throttling_request_manager.js +646 -0
  141. package/storages/transaction.d.ts +252 -0
  142. package/storages/transaction.js +251 -0
  143. package/storages/utils.d.ts +59 -11
  144. package/storages/utils.js +75 -15
  145. package/system-info/cpu-info.d.ts +67 -0
  146. package/system-info/cpu-info.js +216 -0
  147. package/system-info/memory-info.d.ts +31 -0
  148. package/system-info/memory-info.js +115 -0
  149. package/system-info/ps-tree.d.ts +17 -0
  150. package/system-info/ps-tree.js +144 -0
  151. package/system-info/runtime.d.ts +14 -0
  152. package/system-info/runtime.js +80 -0
  153. package/typedefs.d.ts +0 -6
  154. package/typedefs.js +0 -1
  155. package/url.d.ts +9 -0
  156. package/url.js +11 -0
  157. package/validators.d.ts +22 -18
  158. package/validators.js +13 -18
  159. package/autoscaling/autoscaled_pool.d.ts.map +0 -1
  160. package/autoscaling/autoscaled_pool.js.map +0 -1
  161. package/autoscaling/index.d.ts.map +0 -1
  162. package/autoscaling/index.js.map +0 -1
  163. package/autoscaling/snapshotter.d.ts.map +0 -1
  164. package/autoscaling/snapshotter.js.map +0 -1
  165. package/autoscaling/system_status.d.ts.map +0 -1
  166. package/autoscaling/system_status.js.map +0 -1
  167. package/configuration.d.ts.map +0 -1
  168. package/configuration.js.map +0 -1
  169. package/cookie_utils.d.ts.map +0 -1
  170. package/cookie_utils.js.map +0 -1
  171. package/crawlers/context_pipeline.d.ts.map +0 -1
  172. package/crawlers/context_pipeline.js.map +0 -1
  173. package/crawlers/crawler_commons.d.ts.map +0 -1
  174. package/crawlers/crawler_commons.js.map +0 -1
  175. package/crawlers/crawler_utils.d.ts +0 -10
  176. package/crawlers/crawler_utils.d.ts.map +0 -1
  177. package/crawlers/crawler_utils.js +0 -12
  178. package/crawlers/crawler_utils.js.map +0 -1
  179. package/crawlers/error_snapshotter.d.ts.map +0 -1
  180. package/crawlers/error_snapshotter.js.map +0 -1
  181. package/crawlers/error_tracker.d.ts.map +0 -1
  182. package/crawlers/error_tracker.js.map +0 -1
  183. package/crawlers/index.d.ts.map +0 -1
  184. package/crawlers/index.js.map +0 -1
  185. package/crawlers/internals/types.d.ts.map +0 -1
  186. package/crawlers/internals/types.js.map +0 -1
  187. package/crawlers/statistics.d.ts.map +0 -1
  188. package/crawlers/statistics.js.map +0 -1
  189. package/enqueue_links/enqueue_links.d.ts.map +0 -1
  190. package/enqueue_links/enqueue_links.js.map +0 -1
  191. package/enqueue_links/index.d.ts.map +0 -1
  192. package/enqueue_links/index.js.map +0 -1
  193. package/enqueue_links/shared.d.ts.map +0 -1
  194. package/enqueue_links/shared.js.map +0 -1
  195. package/errors.d.ts.map +0 -1
  196. package/errors.js.map +0 -1
  197. package/events/event_manager.d.ts.map +0 -1
  198. package/events/event_manager.js.map +0 -1
  199. package/events/index.d.ts.map +0 -1
  200. package/events/index.js.map +0 -1
  201. package/events/local_event_manager.d.ts.map +0 -1
  202. package/events/local_event_manager.js.map +0 -1
  203. package/http_clients/base-http-client.d.ts +0 -140
  204. package/http_clients/base-http-client.d.ts.map +0 -1
  205. package/http_clients/base-http-client.js +0 -40
  206. package/http_clients/base-http-client.js.map +0 -1
  207. package/http_clients/form-data-like.d.ts +0 -67
  208. package/http_clients/form-data-like.d.ts.map +0 -1
  209. package/http_clients/form-data-like.js +0 -5
  210. package/http_clients/form-data-like.js.map +0 -1
  211. package/http_clients/got-scraping-http-client.d.ts +0 -20
  212. package/http_clients/got-scraping-http-client.d.ts.map +0 -1
  213. package/http_clients/got-scraping-http-client.js +0 -85
  214. package/http_clients/got-scraping-http-client.js.map +0 -1
  215. package/http_clients/index.d.ts +0 -3
  216. package/http_clients/index.d.ts.map +0 -1
  217. package/http_clients/index.js +0 -3
  218. package/http_clients/index.js.map +0 -1
  219. package/index.d.ts.map +0 -1
  220. package/index.js.map +0 -1
  221. package/log.d.ts.map +0 -1
  222. package/log.js.map +0 -1
  223. package/proxy_configuration.d.ts.map +0 -1
  224. package/proxy_configuration.js.map +0 -1
  225. package/recoverable_state.d.ts.map +0 -1
  226. package/recoverable_state.js.map +0 -1
  227. package/request.d.ts.map +0 -1
  228. package/request.js.map +0 -1
  229. package/router.d.ts.map +0 -1
  230. package/router.js.map +0 -1
  231. package/serialization.d.ts.map +0 -1
  232. package/serialization.js.map +0 -1
  233. package/session_pool/consts.d.ts.map +0 -1
  234. package/session_pool/consts.js.map +0 -1
  235. package/session_pool/errors.d.ts.map +0 -1
  236. package/session_pool/errors.js.map +0 -1
  237. package/session_pool/events.d.ts +0 -3
  238. package/session_pool/events.d.ts.map +0 -1
  239. package/session_pool/events.js +0 -3
  240. package/session_pool/events.js.map +0 -1
  241. package/session_pool/index.d.ts.map +0 -1
  242. package/session_pool/index.js.map +0 -1
  243. package/session_pool/session.d.ts.map +0 -1
  244. package/session_pool/session.js.map +0 -1
  245. package/session_pool/session_pool.d.ts.map +0 -1
  246. package/session_pool/session_pool.js.map +0 -1
  247. package/storages/access_checking.d.ts +0 -13
  248. package/storages/access_checking.d.ts.map +0 -1
  249. package/storages/access_checking.js +0 -14
  250. package/storages/access_checking.js.map +0 -1
  251. package/storages/dataset.d.ts.map +0 -1
  252. package/storages/dataset.js.map +0 -1
  253. package/storages/index.d.ts.map +0 -1
  254. package/storages/index.js.map +0 -1
  255. package/storages/key_value_store.d.ts.map +0 -1
  256. package/storages/key_value_store.js.map +0 -1
  257. package/storages/request_list.d.ts.map +0 -1
  258. package/storages/request_list.js.map +0 -1
  259. package/storages/request_list_adapter.d.ts +0 -58
  260. package/storages/request_list_adapter.d.ts.map +0 -1
  261. package/storages/request_list_adapter.js +0 -81
  262. package/storages/request_list_adapter.js.map +0 -1
  263. package/storages/request_manager_tandem.d.ts.map +0 -1
  264. package/storages/request_manager_tandem.js.map +0 -1
  265. package/storages/request_provider.d.ts +0 -371
  266. package/storages/request_provider.d.ts.map +0 -1
  267. package/storages/request_provider.js +0 -585
  268. package/storages/request_provider.js.map +0 -1
  269. package/storages/request_queue.d.ts.map +0 -1
  270. package/storages/request_queue.js.map +0 -1
  271. package/storages/request_queue_v2.d.ts +0 -87
  272. package/storages/request_queue_v2.d.ts.map +0 -1
  273. package/storages/request_queue_v2.js +0 -438
  274. package/storages/request_queue_v2.js.map +0 -1
  275. package/storages/sitemap_request_list.d.ts.map +0 -1
  276. package/storages/sitemap_request_list.js +0 -430
  277. package/storages/sitemap_request_list.js.map +0 -1
  278. package/storages/storage_manager.d.ts +0 -58
  279. package/storages/storage_manager.d.ts.map +0 -1
  280. package/storages/storage_manager.js +0 -105
  281. package/storages/storage_manager.js.map +0 -1
  282. package/storages/utils.d.ts.map +0 -1
  283. package/storages/utils.js.map +0 -1
  284. package/typedefs.d.ts.map +0 -1
  285. package/typedefs.js.map +0 -1
  286. package/validators.d.ts.map +0 -1
  287. package/validators.js.map +0 -1
@@ -1,27 +1,21 @@
1
- import type { DatasetClient, DatasetInfo, Dictionary, StorageClient } from '@crawlee/types';
1
+ import type { Awaitable, DatasetBackend, DatasetInfo, Dictionary } from '@crawlee/types';
2
2
  import { Configuration } from '../configuration.js';
3
- import { type Log } from '../log.js';
4
- import type { Awaitable } from '../typedefs.js';
5
- import type { StorageManagerOptions } from './storage_manager.js';
3
+ import type { CrawleeLogger } from '../log.js';
4
+ import type { JournalEntry } from './transaction.js';
5
+ import type { DatasetStats } from './storage_stats.js';
6
+ import type { StorageOpenOptions } from './utils.js';
7
+ import type { StorageIdentifier } from './storage_instance_manager.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.
@@ -91,8 +85,8 @@ export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset
91
85
  format?: string;
92
86
  }
93
87
  export interface DatasetExportToOptions extends DatasetExportOptions {
94
- fromDataset?: string;
95
- toKVS?: string;
88
+ fromDataset?: string | StorageIdentifier;
89
+ toKVS?: string | StorageIdentifier;
96
90
  }
97
91
  /**
98
92
  * The `Dataset` class represents a store for structured data where each object stored has the same attributes,
@@ -146,16 +140,21 @@ export interface DatasetExportToOptions extends DatasetExportOptions {
146
140
  * @category Result Stores
147
141
  */
148
142
  export declare class Dataset<Data extends Dictionary = Dictionary> {
149
- readonly config: Configuration;
143
+ #private;
144
+ readonly configuration: Configuration;
150
145
  id: string;
151
146
  name?: string;
152
- client: DatasetClient<Data>;
153
- readonly storageObject?: Record<string, unknown>;
154
- log: Log;
147
+ backend: DatasetBackend<Data>;
148
+ log: CrawleeLogger;
155
149
  /**
156
150
  * @internal
157
151
  */
158
- 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;
159
158
  /**
160
159
  * Stores an object or an array of objects to the dataset.
161
160
  * The function returns a promise that resolves when the operation finishes.
@@ -164,27 +163,24 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
164
163
  * **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
165
164
  * otherwise the crawler process might finish before the data is stored!
166
165
  *
167
- * The size of the data is limited by the receiving API and therefore `pushData()` will only
168
- * allow objects whose JSON representation is smaller than 9MB. When an array is passed,
169
- * none of the included objects
170
- * may be larger than 9MB, but the array itself may be of any size.
171
- *
172
- * The function internally
173
- * chunks the array into separate items and pushes them sequentially.
174
- * The chunking process is stable (keeps order of data), but it does not provide a transaction
175
- * safety mechanism. Therefore, in the event of an uploading error (after several automatic retries),
176
- * the function's Promise will reject and the dataset will be left in a state where some of
177
- * the items have already been saved to the dataset while other items from the source array were not.
178
- * To overcome this limitation, the developer may, for example, read the last item saved in the dataset
179
- * and re-attempt the save of the data from this item onwards to prevent duplicates.
180
166
  * @param data Object or array of objects containing data to be stored in the default dataset.
181
- * 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.
182
168
  */
183
169
  pushData(data: Data | Data[]): Promise<void>;
184
170
  /**
185
171
  * Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
186
172
  */
187
173
  getData(options?: DatasetDataOptions): Promise<DatasetContent<Data>>;
174
+ /**
175
+ * The single transaction-aware page read all dataset read paths go through — both `getData()` and
176
+ * the private `fetchPages()`. Returns the real page concatenated with the current transaction's
177
+ * buffered items, with `offset` / `limit` / `desc` windowing applied across the concatenation.
178
+ */
179
+ private readPage;
180
+ /** The active transaction's buffered writes to this dataset, derived from its journal. */
181
+ private bufferedJournalEntries;
182
+ /** @internal */
183
+ commitJournalEntries(entries: JournalEntry[]): Promise<void>;
188
184
  /**
189
185
  * Returns all the data from the dataset. This will iterate through the whole dataset
190
186
  * via the `listItems()` client method, which gives you only paginated results.
@@ -229,26 +225,21 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
229
225
  /**
230
226
  * Returns an object containing general information about the dataset.
231
227
  *
232
- * The function returns the same object as the Apify API Client's
233
- * [getDataset](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-datasets-getDataset)
234
- * function, which in turn calls the
235
- * [Get dataset](https://apify.com/docs/api/v2#/reference/datasets/dataset/get-dataset)
236
- * API endpoint.
237
- *
238
228
  * **Example:**
239
229
  * ```
240
230
  * {
241
231
  * id: "WkzbQMuFYuamGv3YF",
242
232
  * name: "my-dataset",
243
- * userId: "wRsJZtadYvn4mBZmm",
244
233
  * createdAt: new Date("2015-12-12T07:34:14.202Z"),
245
234
  * modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
246
235
  * accessedAt: new Date("2015-12-14T08:36:13.202Z"),
247
236
  * itemCount: 14,
248
237
  * }
249
238
  * ```
239
+ *
240
+ * @throws If the underlying storage no longer exists (e.g. it was deleted externally).
250
241
  */
251
- getInfo(): Promise<DatasetInfo | undefined>;
242
+ getInfo(): Promise<DatasetInfo>;
252
243
  /**
253
244
  * Iterates over dataset items, yielding each in turn to an `iteratee` function.
254
245
  * Each invocation of `iteratee` is called with two arguments: `(item, index)`.
@@ -314,7 +305,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
314
305
  * If the dataset is empty, reduce will return undefined.
315
306
  *
316
307
  * @param iteratee
317
- * @param memo Unset parameter, neccesary to be able to pass options
308
+ * @param memo Unset parameter, necessary to be able to pass options
318
309
  * @param [options] An object containing extra options for `reduce()`
319
310
  */
320
311
  reduce(iteratee: DatasetReducer<Data, Data>, memo: undefined, options: DatasetIteratorOptions): Promise<Data | undefined>;
@@ -332,6 +323,69 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
332
323
  * @param [options] An object containing extra options for `reduce()`
333
324
  */
334
325
  reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
326
+ private fetchEntryPages;
327
+ private fetchPages;
328
+ /**
329
+ * Returns dataset items.
330
+ *
331
+ * When awaited (`await dataset.values()`), returns all items as a flat `Data[]` array.
332
+ * When used as an async iterable (`for await...of`), iterates over all items across pages
333
+ * without loading everything into memory at once.
334
+ *
335
+ * **Example usage:**
336
+ * ```javascript
337
+ * const dataset = await Dataset.open('my-results');
338
+ *
339
+ * // Iterate over all items (memory-efficient for large datasets)
340
+ * for await (const item of dataset.values()) {
341
+ * console.log(item);
342
+ * }
343
+ *
344
+ * // Or fetch all items at once
345
+ * const items = await dataset.values();
346
+ * console.log(items);
347
+ * ```
348
+ *
349
+ * @param options Options for the iteration.
350
+ */
351
+ values(options?: DatasetIteratorOptions): AsyncIterable<Data> & Promise<Data[]>;
352
+ /**
353
+ * Returns dataset entries (index-value pairs).
354
+ *
355
+ * When awaited (`await dataset.entries()`), returns all entries as a flat `[index, item][]` array.
356
+ * When used as an async iterable (`for await...of`), iterates over all entries across pages
357
+ * without loading everything into memory at once.
358
+ *
359
+ * **Example usage:**
360
+ * ```javascript
361
+ * const dataset = await Dataset.open('my-results');
362
+ *
363
+ * // Iterate over all entries
364
+ * for await (const [index, item] of dataset.entries()) {
365
+ * console.log(`Item at ${index}: ${JSON.stringify(item)}`);
366
+ * }
367
+ *
368
+ * // Or fetch all at once
369
+ * const entries = await dataset.entries();
370
+ * console.log(entries);
371
+ * ```
372
+ *
373
+ * @param options Options for the iteration.
374
+ */
375
+ entries(options?: DatasetIteratorOptions): AsyncIterable<[number, Data]> & Promise<[number, Data][]>;
376
+ /**
377
+ * Default async iterator for the dataset, iterating over items.
378
+ * Allows using the dataset directly in a `for await...of` loop.
379
+ *
380
+ * **Example usage:**
381
+ * ```javascript
382
+ * const dataset = await Dataset.open('my-results');
383
+ * for await (const item of dataset) {
384
+ * console.log(item);
385
+ * }
386
+ * ```
387
+ */
388
+ [Symbol.asyncIterator](): AsyncGenerator<Data, void, undefined>;
335
389
  /**
336
390
  * Removes the dataset either from the Apify cloud storage or from the local directory,
337
391
  * depending on the mode of operation.
@@ -346,12 +400,13 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
346
400
  *
347
401
  * For more details and code examples, see the {@link Dataset} class.
348
402
  *
349
- * @param [datasetIdOrName]
350
- * ID or name of the dataset to be opened. If `null` or `undefined`,
351
- * the function returns the default dataset associated with the crawler run.
403
+ * @param [identifier]
404
+ * ID or name of the dataset to be opened. If a string is provided, it will first be
405
+ * looked up as an ID; if no such storage exists, it will be treated as a name.
406
+ * If `null` or `undefined`, the function returns the default dataset associated with the crawler run.
352
407
  * @param [options] Storage manager options.
353
408
  */
354
- static open<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: StorageManagerOptions): Promise<Dataset<Data>>;
409
+ static open<Data extends Dictionary = Dictionary>(identifier?: string | StorageIdentifier | null, options?: StorageOpenOptions): Promise<Dataset<Data>>;
355
410
  /**
356
411
  * Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
357
412
  *
@@ -415,10 +470,9 @@ export interface DatasetReducer<T, Data> {
415
470
  (memo: T, item: Data, index: number): Awaitable<T>;
416
471
  }
417
472
  export interface DatasetOptions {
418
- id: string;
419
- name?: string;
420
- client: StorageClient;
421
- storageObject?: Record<string, unknown>;
473
+ /** Resolved metadata for the dataset, as returned by the backend's `getMetadata()`. */
474
+ metadata: DatasetInfo;
475
+ backend: DatasetBackend;
422
476
  }
423
477
  export interface DatasetContent<Data> {
424
478
  /** Total count of entries in the dataset. */
@@ -434,4 +488,3 @@ export interface DatasetContent<Data> {
434
488
  /** Should the results be in descending order. */
435
489
  desc?: boolean;
436
490
  }
437
- //# sourceMappingURL=dataset.d.ts.map