@crawlee/core 4.0.0-beta.10 → 4.0.0-beta.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -13
- package/autoscaling/autoscaled_pool.d.ts +69 -156
- package/autoscaling/autoscaled_pool.js +97 -252
- package/autoscaling/client_load_signal.d.ts +59 -0
- package/autoscaling/client_load_signal.js +73 -0
- package/autoscaling/concurrency_system.d.ts +283 -0
- package/autoscaling/concurrency_system.js +350 -0
- package/autoscaling/cpu_load_signal.d.ts +44 -0
- package/autoscaling/cpu_load_signal.js +46 -0
- package/autoscaling/event_loop_load_signal.d.ts +54 -0
- package/autoscaling/event_loop_load_signal.js +60 -0
- package/autoscaling/index.d.ts +6 -1
- package/autoscaling/index.js +6 -1
- package/autoscaling/load_signal.d.ts +99 -0
- package/autoscaling/load_signal.js +103 -0
- package/autoscaling/memory_load_signal.d.ts +56 -0
- package/autoscaling/memory_load_signal.js +106 -0
- package/autoscaling/snapshotter.d.ts +61 -163
- package/autoscaling/snapshotter.js +45 -263
- package/autoscaling/system_status.d.ts +63 -83
- package/autoscaling/system_status.js +90 -120
- package/autoscaling/weighted_avg.d.ts +5 -0
- package/autoscaling/weighted_avg.js +14 -0
- package/byte_utils.d.ts +17 -0
- package/byte_utils.js +42 -0
- package/configuration.d.ts +96 -223
- package/configuration.js +170 -222
- package/cookie_utils.d.ts +4 -3
- package/cookie_utils.js +22 -13
- package/crawlers/context_pipeline.d.ts +70 -0
- package/crawlers/context_pipeline.js +122 -0
- package/crawlers/crawler_commons.d.ts +96 -40
- package/crawlers/crawler_commons.js +15 -24
- package/crawlers/error_snapshotter.d.ts +3 -3
- package/crawlers/error_snapshotter.js +2 -3
- package/crawlers/error_tracker.d.ts +2 -2
- package/crawlers/error_tracker.js +0 -1
- package/crawlers/index.d.ts +1 -3
- package/crawlers/index.js +1 -3
- package/crawlers/internals/types.d.ts +7 -0
- package/crawlers/internals/types.js +1 -0
- package/crawlers/statistics.d.ts +28 -23
- package/crawlers/statistics.js +38 -34
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/enqueue_links/enqueue_links.d.ts +59 -68
- package/enqueue_links/enqueue_links.js +57 -62
- package/enqueue_links/index.d.ts +0 -1
- package/enqueue_links/index.js +0 -1
- package/enqueue_links/shared.d.ts +39 -26
- package/enqueue_links/shared.js +89 -67
- package/errors.d.ts +53 -4
- package/errors.js +70 -5
- package/events/event_manager.d.ts +34 -8
- package/events/event_manager.js +8 -10
- package/events/index.d.ts +0 -1
- package/events/index.js +0 -1
- package/events/local_event_manager.d.ts +15 -3
- package/events/local_event_manager.js +37 -11
- package/index.d.ts +6 -4
- package/index.js +5 -3
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +82 -3
- package/log.js +102 -1
- package/memory-storage/consts.d.ts +4 -0
- package/memory-storage/consts.js +4 -0
- package/memory-storage/index.d.ts +1 -0
- package/memory-storage/index.js +1 -0
- package/memory-storage/memory-storage.d.ts +46 -0
- package/memory-storage/memory-storage.js +136 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
- package/memory-storage/resource-clients/common/base-client.js +6 -0
- package/memory-storage/resource-clients/dataset.d.ts +40 -0
- package/memory-storage/resource-clients/dataset.js +113 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +63 -0
- package/memory-storage/resource-clients/key-value-store.js +203 -0
- package/memory-storage/resource-clients/request-queue.d.ts +96 -0
- package/memory-storage/resource-clients/request-queue.js +421 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned_or_injected.d.ts +60 -0
- package/owned_or_injected.js +98 -0
- package/package.json +13 -12
- package/proxy_configuration.d.ts +29 -152
- package/proxy_configuration.js +21 -173
- package/recoverable_state.d.ts +120 -0
- package/recoverable_state.js +143 -0
- package/request.d.ts +85 -15
- package/request.js +107 -28
- package/router.d.ts +194 -19
- package/router.js +177 -32
- package/serialization.d.ts +0 -1
- package/serialization.js +1 -2
- package/service_locator.d.ts +156 -0
- package/service_locator.js +244 -0
- package/session_pool/consts.d.ts +1 -2
- package/session_pool/consts.js +1 -2
- package/session_pool/errors.d.ts +0 -1
- package/session_pool/errors.js +0 -1
- package/session_pool/fingerprint.d.ts +9 -0
- package/session_pool/fingerprint.js +30 -0
- package/session_pool/index.d.ts +0 -2
- package/session_pool/index.js +0 -2
- package/session_pool/session.d.ts +37 -75
- package/session_pool/session.js +49 -102
- package/session_pool/session_pool.d.ts +85 -90
- package/session_pool/session_pool.js +131 -120
- package/storages/access_checking.d.ts +1 -2
- package/storages/access_checking.js +5 -2
- package/storages/dataset.d.ts +103 -54
- package/storages/dataset.js +174 -132
- package/storages/index.d.ts +8 -7
- package/storages/index.js +6 -7
- package/storages/key_value_store.d.ts +167 -39
- package/storages/key_value_store.js +274 -127
- package/storages/key_value_store_codec.d.ts +32 -0
- package/storages/key_value_store_codec.js +113 -0
- package/storages/request_dedup_cache.d.ts +23 -0
- package/storages/request_dedup_cache.js +48 -0
- package/storages/request_list.d.ts +54 -98
- package/storages/request_list.js +99 -75
- package/storages/request_loader.d.ts +96 -0
- package/storages/request_loader.js +1 -0
- package/storages/request_manager.d.ts +33 -0
- package/storages/request_manager.js +1 -0
- package/storages/request_manager_tandem.d.ts +106 -0
- package/storages/request_manager_tandem.js +197 -0
- package/storages/request_queue.d.ts +287 -47
- package/storages/request_queue.js +620 -215
- package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +38 -46
- package/storages/{sitemap_request_list.js → sitemap_request_loader.js} +58 -65
- package/storages/storage_instance_manager.d.ts +88 -0
- package/storages/storage_instance_manager.js +256 -0
- package/storages/storage_stats.d.ts +48 -0
- package/storages/storage_stats.js +29 -0
- package/storages/utils.d.ts +54 -9
- package/storages/utils.js +64 -13
- package/system-info/cpu-info.d.ts +67 -0
- package/system-info/cpu-info.js +216 -0
- package/system-info/memory-info.d.ts +31 -0
- package/system-info/memory-info.js +115 -0
- package/system-info/ps-tree.d.ts +17 -0
- package/system-info/ps-tree.js +144 -0
- package/system-info/runtime.d.ts +14 -0
- package/system-info/runtime.js +80 -0
- package/typedefs.d.ts +0 -6
- package/typedefs.js +0 -1
- package/validators.d.ts +8 -1
- package/validators.js +10 -3
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js.map +0 -1
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_extension.d.ts +0 -12
- package/crawlers/crawler_extension.d.ts.map +0 -1
- package/crawlers/crawler_extension.js +0 -14
- package/crawlers/crawler_extension.js.map +0 -1
- package/crawlers/crawler_utils.d.ts +0 -10
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js +0 -12
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js.map +0 -1
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js.map +0 -1
- package/errors.d.ts.map +0 -1
- package/errors.js.map +0 -1
- package/events/event_manager.d.ts.map +0 -1
- package/events/event_manager.js.map +0 -1
- package/events/index.d.ts.map +0 -1
- package/events/index.js.map +0 -1
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js.map +0 -1
- package/http_clients/base-http-client.d.ts +0 -134
- package/http_clients/base-http-client.d.ts.map +0 -1
- package/http_clients/base-http-client.js +0 -33
- package/http_clients/base-http-client.js.map +0 -1
- package/http_clients/form-data-like.d.ts +0 -67
- package/http_clients/form-data-like.d.ts.map +0 -1
- package/http_clients/form-data-like.js +0 -5
- package/http_clients/form-data-like.js.map +0 -1
- package/http_clients/got-scraping-http-client.d.ts +0 -15
- package/http_clients/got-scraping-http-client.d.ts.map +0 -1
- package/http_clients/got-scraping-http-client.js +0 -69
- package/http_clients/got-scraping-http-client.js.map +0 -1
- package/http_clients/index.d.ts +0 -3
- package/http_clients/index.d.ts.map +0 -1
- package/http_clients/index.js +0 -3
- package/http_clients/index.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/log.d.ts.map +0 -1
- package/log.js.map +0 -1
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts.map +0 -1
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts +0 -3
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js +0 -3
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js.map +0 -1
- package/storages/dataset.d.ts.map +0 -1
- package/storages/dataset.js.map +0 -1
- package/storages/index.d.ts.map +0 -1
- package/storages/index.js.map +0 -1
- package/storages/key_value_store.d.ts.map +0 -1
- package/storages/key_value_store.js.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_provider.d.ts +0 -307
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -555
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js.map +0 -1
- package/storages/request_queue_v2.d.ts +0 -87
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js +0 -438
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -58
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -105
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/typedefs.d.ts.map +0 -1
- package/typedefs.js.map +0 -1
- package/validators.d.ts.map +0 -1
- package/validators.js.map +0 -1
package/storages/dataset.d.ts
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Awaitable, DatasetBackend, DatasetInfo, Dictionary } from '@crawlee/types';
|
|
2
2
|
import { Configuration } from '../configuration.js';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { CrawleeLogger } from '../log.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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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.
|
|
@@ -67,6 +60,11 @@ export interface DatasetDataOptions {
|
|
|
67
60
|
skipEmpty?: boolean;
|
|
68
61
|
}
|
|
69
62
|
export interface DatasetExportOptions extends Omit<DatasetDataOptions, 'offset' | 'limit'> {
|
|
63
|
+
/**
|
|
64
|
+
* If true, includes all unique keys from all dataset items in the CSV export header.
|
|
65
|
+
* If omitted or false, only keys from the first item are used.
|
|
66
|
+
*/
|
|
67
|
+
collectAllKeys?: boolean;
|
|
70
68
|
}
|
|
71
69
|
export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset' | 'limit' | 'clean' | 'skipHidden' | 'skipEmpty'> {
|
|
72
70
|
/** @internal */
|
|
@@ -86,8 +84,8 @@ export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset
|
|
|
86
84
|
format?: string;
|
|
87
85
|
}
|
|
88
86
|
export interface DatasetExportToOptions extends DatasetExportOptions {
|
|
89
|
-
fromDataset?: string;
|
|
90
|
-
toKVS?: string;
|
|
87
|
+
fromDataset?: string | StorageIdentifier;
|
|
88
|
+
toKVS?: string | StorageIdentifier;
|
|
91
89
|
}
|
|
92
90
|
/**
|
|
93
91
|
* The `Dataset` class represents a store for structured data where each object stored has the same attributes,
|
|
@@ -141,15 +139,21 @@ export interface DatasetExportToOptions extends DatasetExportOptions {
|
|
|
141
139
|
* @category Result Stores
|
|
142
140
|
*/
|
|
143
141
|
export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
144
|
-
readonly
|
|
142
|
+
readonly configuration: Configuration;
|
|
145
143
|
id: string;
|
|
146
144
|
name?: string;
|
|
147
|
-
|
|
148
|
-
log:
|
|
145
|
+
backend: DatasetBackend<Data>;
|
|
146
|
+
log: CrawleeLogger;
|
|
147
|
+
private readonly statsTracker;
|
|
149
148
|
/**
|
|
150
149
|
* @internal
|
|
151
150
|
*/
|
|
152
|
-
constructor(options: DatasetOptions,
|
|
151
|
+
constructor(options: DatasetOptions, configuration?: Configuration);
|
|
152
|
+
/**
|
|
153
|
+
* Backend-independent usage counters tracked for this dataset (read / write operations issued to
|
|
154
|
+
* the underlying storage backend). Counted per backend call.
|
|
155
|
+
*/
|
|
156
|
+
get stats(): DatasetStats;
|
|
153
157
|
/**
|
|
154
158
|
* Stores an object or an array of objects to the dataset.
|
|
155
159
|
* The function returns a promise that resolves when the operation finishes.
|
|
@@ -158,21 +162,8 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
158
162
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
159
163
|
* otherwise the crawler process might finish before the data is stored!
|
|
160
164
|
*
|
|
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
165
|
* @param data Object or array of objects containing data to be stored in the default dataset.
|
|
175
|
-
* The objects must be serializable to JSON
|
|
166
|
+
* The objects must be serializable to JSON.
|
|
176
167
|
*/
|
|
177
168
|
pushData(data: Data | Data[]): Promise<void>;
|
|
178
169
|
/**
|
|
@@ -223,26 +214,21 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
223
214
|
/**
|
|
224
215
|
* Returns an object containing general information about the dataset.
|
|
225
216
|
*
|
|
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
217
|
* **Example:**
|
|
233
218
|
* ```
|
|
234
219
|
* {
|
|
235
220
|
* id: "WkzbQMuFYuamGv3YF",
|
|
236
221
|
* name: "my-dataset",
|
|
237
|
-
* userId: "wRsJZtadYvn4mBZmm",
|
|
238
222
|
* createdAt: new Date("2015-12-12T07:34:14.202Z"),
|
|
239
223
|
* modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
|
|
240
224
|
* accessedAt: new Date("2015-12-14T08:36:13.202Z"),
|
|
241
225
|
* itemCount: 14,
|
|
242
226
|
* }
|
|
243
227
|
* ```
|
|
228
|
+
*
|
|
229
|
+
* @throws If the underlying storage no longer exists (e.g. it was deleted externally).
|
|
244
230
|
*/
|
|
245
|
-
getInfo(): Promise<DatasetInfo
|
|
231
|
+
getInfo(): Promise<DatasetInfo>;
|
|
246
232
|
/**
|
|
247
233
|
* Iterates over dataset items, yielding each in turn to an `iteratee` function.
|
|
248
234
|
* Each invocation of `iteratee` is called with two arguments: `(item, index)`.
|
|
@@ -308,7 +294,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
308
294
|
* If the dataset is empty, reduce will return undefined.
|
|
309
295
|
*
|
|
310
296
|
* @param iteratee
|
|
311
|
-
* @param memo Unset parameter,
|
|
297
|
+
* @param memo Unset parameter, necessary to be able to pass options
|
|
312
298
|
* @param [options] An object containing extra options for `reduce()`
|
|
313
299
|
*/
|
|
314
300
|
reduce(iteratee: DatasetReducer<Data, Data>, memo: undefined, options: DatasetIteratorOptions): Promise<Data | undefined>;
|
|
@@ -326,6 +312,69 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
326
312
|
* @param [options] An object containing extra options for `reduce()`
|
|
327
313
|
*/
|
|
328
314
|
reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
|
|
315
|
+
private fetchEntryPages;
|
|
316
|
+
private fetchPages;
|
|
317
|
+
/**
|
|
318
|
+
* Returns dataset items.
|
|
319
|
+
*
|
|
320
|
+
* When awaited (`await dataset.values()`), returns all items as a flat `Data[]` array.
|
|
321
|
+
* When used as an async iterable (`for await...of`), iterates over all items across pages
|
|
322
|
+
* without loading everything into memory at once.
|
|
323
|
+
*
|
|
324
|
+
* **Example usage:**
|
|
325
|
+
* ```javascript
|
|
326
|
+
* const dataset = await Dataset.open('my-results');
|
|
327
|
+
*
|
|
328
|
+
* // Iterate over all items (memory-efficient for large datasets)
|
|
329
|
+
* for await (const item of dataset.values()) {
|
|
330
|
+
* console.log(item);
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
333
|
+
* // Or fetch all items at once
|
|
334
|
+
* const items = await dataset.values();
|
|
335
|
+
* console.log(items);
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @param options Options for the iteration.
|
|
339
|
+
*/
|
|
340
|
+
values(options?: DatasetIteratorOptions): AsyncIterable<Data> & Promise<Data[]>;
|
|
341
|
+
/**
|
|
342
|
+
* Returns dataset entries (index-value pairs).
|
|
343
|
+
*
|
|
344
|
+
* When awaited (`await dataset.entries()`), returns all entries as a flat `[index, item][]` array.
|
|
345
|
+
* When used as an async iterable (`for await...of`), iterates over all entries across pages
|
|
346
|
+
* without loading everything into memory at once.
|
|
347
|
+
*
|
|
348
|
+
* **Example usage:**
|
|
349
|
+
* ```javascript
|
|
350
|
+
* const dataset = await Dataset.open('my-results');
|
|
351
|
+
*
|
|
352
|
+
* // Iterate over all entries
|
|
353
|
+
* for await (const [index, item] of dataset.entries()) {
|
|
354
|
+
* console.log(`Item at ${index}: ${JSON.stringify(item)}`);
|
|
355
|
+
* }
|
|
356
|
+
*
|
|
357
|
+
* // Or fetch all at once
|
|
358
|
+
* const entries = await dataset.entries();
|
|
359
|
+
* console.log(entries);
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @param options Options for the iteration.
|
|
363
|
+
*/
|
|
364
|
+
entries(options?: DatasetIteratorOptions): AsyncIterable<[number, Data]> & Promise<[number, Data][]>;
|
|
365
|
+
/**
|
|
366
|
+
* Default async iterator for the dataset, iterating over items.
|
|
367
|
+
* Allows using the dataset directly in a `for await...of` loop.
|
|
368
|
+
*
|
|
369
|
+
* **Example usage:**
|
|
370
|
+
* ```javascript
|
|
371
|
+
* const dataset = await Dataset.open('my-results');
|
|
372
|
+
* for await (const item of dataset) {
|
|
373
|
+
* console.log(item);
|
|
374
|
+
* }
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
[Symbol.asyncIterator](): AsyncGenerator<Data, void, undefined>;
|
|
329
378
|
/**
|
|
330
379
|
* Removes the dataset either from the Apify cloud storage or from the local directory,
|
|
331
380
|
* depending on the mode of operation.
|
|
@@ -340,12 +389,13 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
340
389
|
*
|
|
341
390
|
* For more details and code examples, see the {@link Dataset} class.
|
|
342
391
|
*
|
|
343
|
-
* @param [
|
|
344
|
-
* ID or name of the dataset to be opened. If
|
|
345
|
-
*
|
|
392
|
+
* @param [identifier]
|
|
393
|
+
* ID or name of the dataset to be opened. If a string is provided, it will first be
|
|
394
|
+
* looked up as an ID; if no such storage exists, it will be treated as a name.
|
|
395
|
+
* If `null` or `undefined`, the function returns the default dataset associated with the crawler run.
|
|
346
396
|
* @param [options] Storage manager options.
|
|
347
397
|
*/
|
|
348
|
-
static open<Data extends Dictionary = Dictionary>(
|
|
398
|
+
static open<Data extends Dictionary = Dictionary>(identifier?: string | StorageIdentifier | null, options?: StorageOpenOptions): Promise<Dataset<Data>>;
|
|
349
399
|
/**
|
|
350
400
|
* Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
|
|
351
401
|
*
|
|
@@ -409,9 +459,9 @@ export interface DatasetReducer<T, Data> {
|
|
|
409
459
|
(memo: T, item: Data, index: number): Awaitable<T>;
|
|
410
460
|
}
|
|
411
461
|
export interface DatasetOptions {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
462
|
+
/** Resolved metadata for the dataset, as returned by the backend's `getMetadata()`. */
|
|
463
|
+
metadata: DatasetInfo;
|
|
464
|
+
backend: DatasetBackend;
|
|
415
465
|
}
|
|
416
466
|
export interface DatasetContent<Data> {
|
|
417
467
|
/** Total count of entries in the dataset. */
|
|
@@ -427,4 +477,3 @@ export interface DatasetContent<Data> {
|
|
|
427
477
|
/** Should the results be in descending order. */
|
|
428
478
|
desc?: boolean;
|
|
429
479
|
}
|
|
430
|
-
//# sourceMappingURL=dataset.d.ts.map
|