@crawlee/core 4.0.0-beta.20 → 4.0.0-beta.201

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