@crawlee/core 4.0.0-beta.25 → 4.0.0-beta.250
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 +15 -15
- package/byte-utils.d.ts +17 -0
- package/byte-utils.js +42 -0
- package/configuration.d.ts +77 -235
- package/configuration.js +159 -227
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/errors.d.ts +45 -18
- package/errors.js +58 -27
- package/events/event-manager.d.ts +78 -0
- package/events/{event_manager.js → event-manager.js} +12 -13
- package/events/index.d.ts +3 -3
- package/events/index.js +2 -3
- package/events/local-event-manager.d.ts +32 -0
- package/events/local-event-manager.js +101 -0
- package/events/system-info.d.ts +38 -0
- package/events/system-info.js +1 -0
- package/index.d.ts +9 -12
- package/index.js +10 -11
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +77 -1
- package/log.js +134 -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 +43 -0
- package/memory-storage/memory-storage.js +158 -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 +35 -0
- package/memory-storage/resource-clients/dataset.js +108 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +54 -0
- package/memory-storage/resource-clients/key-value-store.js +179 -0
- package/memory-storage/resource-clients/request-queue.d.ts +55 -0
- package/memory-storage/resource-clients/request-queue.js +413 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned-or-injected.d.ts +58 -0
- package/owned-or-injected.js +98 -0
- package/package.json +23 -23
- package/proxy-configuration.d.ts +118 -0
- package/proxy-configuration.js +141 -0
- package/recoverable-state.d.ts +177 -0
- package/recoverable-state.js +268 -0
- package/request.d.ts +48 -93
- package/request.js +133 -230
- package/serialization.d.ts +0 -1
- package/serialization.js +18 -18
- package/service-locator.d.ts +168 -0
- package/service-locator.js +255 -0
- package/storages/batched-adds.d.ts +37 -0
- package/storages/batched-adds.js +73 -0
- package/storages/dataset.d.ts +105 -58
- package/storages/dataset.js +292 -150
- package/storages/index.d.ts +11 -12
- package/storages/index.js +7 -12
- package/storages/key-value-store-codec.d.ts +32 -0
- package/storages/key-value-store-codec.js +108 -0
- package/storages/{key_value_store.d.ts → key-value-store.d.ts} +169 -72
- package/storages/key-value-store.js +767 -0
- package/storages/request-dedup-cache.d.ts +20 -0
- package/storages/request-dedup-cache.js +48 -0
- package/storages/{request_list.d.ts → request-list.d.ts} +33 -173
- package/storages/{request_list.js → request-list.js} +276 -255
- package/storages/request-loader.d.ts +127 -0
- package/storages/request-loader.js +36 -0
- package/storages/request-manager-tandem.d.ts +82 -0
- package/storages/request-manager-tandem.js +200 -0
- package/storages/request-manager.d.ts +119 -0
- package/storages/request-manager.js +1 -0
- package/storages/{request_provider.d.ts → request-queue.d.ts} +128 -159
- package/storages/request-queue.js +870 -0
- package/storages/storage-instance-manager.d.ts +86 -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/transaction.d.ts +270 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +59 -11
- package/storages/utils.js +76 -16
- 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/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -18
- package/validators.js +14 -18
- package/autoscaling/autoscaled_pool.d.ts +0 -300
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js +0 -533
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts +0 -4
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js +0 -4
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts +0 -189
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js +0 -285
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts +0 -181
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js +0 -169
- 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 +0 -43
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js +0 -111
- package/cookie_utils.js.map +0 -1
- package/crawlers/context_pipeline.d.ts +0 -61
- package/crawlers/context_pipeline.d.ts.map +0 -1
- package/crawlers/context_pipeline.js +0 -99
- package/crawlers/context_pipeline.js.map +0 -1
- package/crawlers/crawler_commons.d.ts +0 -191
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js +0 -108
- package/crawlers/crawler_commons.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 +0 -60
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js +0 -118
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts +0 -55
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js +0 -309
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts +0 -7
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js +0 -7
- package/crawlers/index.js.map +0 -1
- package/crawlers/internals/types.d.ts +0 -8
- package/crawlers/internals/types.d.ts.map +0 -1
- package/crawlers/internals/types.js +0 -2
- package/crawlers/internals/types.js.map +0 -1
- package/crawlers/statistics.d.ts +0 -213
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js +0 -349
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts +0 -249
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js +0 -269
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts +0 -3
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js +0 -3
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts +0 -73
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js +0 -212
- 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 +0 -52
- 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 +0 -27
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js +0 -75
- package/events/local_event_manager.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 +0 -169
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js +0 -247
- package/proxy_configuration.js.map +0 -1
- package/recoverable_state.d.ts +0 -123
- package/recoverable_state.d.ts.map +0 -1
- package/recoverable_state.js +0 -140
- package/recoverable_state.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts +0 -134
- package/router.d.ts.map +0 -1
- package/router.js +0 -164
- 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 +0 -4
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js +0 -4
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts +0 -8
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js +0 -12
- 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 +0 -6
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js +0 -6
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts +0 -186
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js +0 -278
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts +0 -258
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js +0 -387
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts +0 -13
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js +0 -14
- 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 +0 -512
- 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_list_adapter.d.ts +0 -58
- package/storages/request_list_adapter.d.ts.map +0 -1
- package/storages/request_list_adapter.js +0 -81
- package/storages/request_list_adapter.js.map +0 -1
- package/storages/request_manager_tandem.d.ts +0 -68
- package/storages/request_manager_tandem.d.ts.map +0 -1
- package/storages/request_manager_tandem.js +0 -124
- package/storages/request_manager_tandem.js.map +0 -1
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -591
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts +0 -128
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js +0 -320
- 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 +0 -250
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js +0 -431
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -62
- 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/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 { 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
|
-
*
|
|
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.
|
|
@@ -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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
readonly
|
|
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,
|
|
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,16 @@ 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
|
|
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
|
+
/** @internal */
|
|
173
|
+
commitJournalEntries(entries: JournalEntry[]): Promise<void>;
|
|
188
174
|
/**
|
|
189
175
|
* Returns all the data from the dataset. This will iterate through the whole dataset
|
|
190
176
|
* via the `listItems()` client method, which gives you only paginated results.
|
|
@@ -229,26 +215,21 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
229
215
|
/**
|
|
230
216
|
* Returns an object containing general information about the dataset.
|
|
231
217
|
*
|
|
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
218
|
* **Example:**
|
|
239
219
|
* ```
|
|
240
220
|
* {
|
|
241
221
|
* id: "WkzbQMuFYuamGv3YF",
|
|
242
222
|
* name: "my-dataset",
|
|
243
|
-
* userId: "wRsJZtadYvn4mBZmm",
|
|
244
223
|
* createdAt: new Date("2015-12-12T07:34:14.202Z"),
|
|
245
224
|
* modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
|
|
246
225
|
* accessedAt: new Date("2015-12-14T08:36:13.202Z"),
|
|
247
226
|
* itemCount: 14,
|
|
248
227
|
* }
|
|
249
228
|
* ```
|
|
229
|
+
*
|
|
230
|
+
* @throws If the underlying storage no longer exists (e.g. it was deleted externally).
|
|
250
231
|
*/
|
|
251
|
-
getInfo(): Promise<DatasetInfo
|
|
232
|
+
getInfo(): Promise<DatasetInfo>;
|
|
252
233
|
/**
|
|
253
234
|
* Iterates over dataset items, yielding each in turn to an `iteratee` function.
|
|
254
235
|
* Each invocation of `iteratee` is called with two arguments: `(item, index)`.
|
|
@@ -314,7 +295,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
314
295
|
* If the dataset is empty, reduce will return undefined.
|
|
315
296
|
*
|
|
316
297
|
* @param iteratee
|
|
317
|
-
* @param memo Unset parameter,
|
|
298
|
+
* @param memo Unset parameter, necessary to be able to pass options
|
|
318
299
|
* @param [options] An object containing extra options for `reduce()`
|
|
319
300
|
*/
|
|
320
301
|
reduce(iteratee: DatasetReducer<Data, Data>, memo: undefined, options: DatasetIteratorOptions): Promise<Data | undefined>;
|
|
@@ -332,11 +313,77 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
332
313
|
* @param [options] An object containing extra options for `reduce()`
|
|
333
314
|
*/
|
|
334
315
|
reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
|
|
316
|
+
/**
|
|
317
|
+
* Returns dataset items.
|
|
318
|
+
*
|
|
319
|
+
* When awaited (`await dataset.values()`), returns all items as a flat `Data[]` array.
|
|
320
|
+
* When used as an async iterable (`for await...of`), iterates over all items across pages
|
|
321
|
+
* without loading everything into memory at once.
|
|
322
|
+
*
|
|
323
|
+
* **Example usage:**
|
|
324
|
+
* ```javascript
|
|
325
|
+
* const dataset = await Dataset.open('my-results');
|
|
326
|
+
*
|
|
327
|
+
* // Iterate over all items (memory-efficient for large datasets)
|
|
328
|
+
* for await (const item of dataset.values()) {
|
|
329
|
+
* console.log(item);
|
|
330
|
+
* }
|
|
331
|
+
*
|
|
332
|
+
* // Or fetch all items at once
|
|
333
|
+
* const items = await dataset.values();
|
|
334
|
+
* console.log(items);
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @param options Options for the iteration.
|
|
338
|
+
*/
|
|
339
|
+
values(options?: DatasetIteratorOptions): AsyncIterable<Data> & Promise<Data[]>;
|
|
340
|
+
/**
|
|
341
|
+
* Returns dataset entries (index-value pairs).
|
|
342
|
+
*
|
|
343
|
+
* When awaited (`await dataset.entries()`), returns all entries as a flat `[index, item][]` array.
|
|
344
|
+
* When used as an async iterable (`for await...of`), iterates over all entries across pages
|
|
345
|
+
* without loading everything into memory at once.
|
|
346
|
+
*
|
|
347
|
+
* **Example usage:**
|
|
348
|
+
* ```javascript
|
|
349
|
+
* const dataset = await Dataset.open('my-results');
|
|
350
|
+
*
|
|
351
|
+
* // Iterate over all entries
|
|
352
|
+
* for await (const [index, item] of dataset.entries()) {
|
|
353
|
+
* console.log(`Item at ${index}: ${JSON.stringify(item)}`);
|
|
354
|
+
* }
|
|
355
|
+
*
|
|
356
|
+
* // Or fetch all at once
|
|
357
|
+
* const entries = await dataset.entries();
|
|
358
|
+
* console.log(entries);
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @param options Options for the iteration.
|
|
362
|
+
*/
|
|
363
|
+
entries(options?: DatasetIteratorOptions): AsyncIterable<[number, Data]> & Promise<[number, Data][]>;
|
|
364
|
+
/**
|
|
365
|
+
* Default async iterator for the dataset, iterating over items.
|
|
366
|
+
* Allows using the dataset directly in a `for await...of` loop.
|
|
367
|
+
*
|
|
368
|
+
* **Example usage:**
|
|
369
|
+
* ```javascript
|
|
370
|
+
* const dataset = await Dataset.open('my-results');
|
|
371
|
+
* for await (const item of dataset) {
|
|
372
|
+
* console.log(item);
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
[Symbol.asyncIterator](): AsyncGenerator<Data, void, undefined>;
|
|
335
377
|
/**
|
|
336
378
|
* Removes the dataset either from the Apify cloud storage or from the local directory,
|
|
337
379
|
* depending on the mode of operation.
|
|
338
380
|
*/
|
|
339
381
|
drop(): Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Removes all items from the dataset but keeps the dataset itself, along with its
|
|
384
|
+
* {@link Dataset.id|`id`} and {@link Dataset.name|`name`}.
|
|
385
|
+
*/
|
|
386
|
+
purge(): Promise<void>;
|
|
340
387
|
/**
|
|
341
388
|
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
342
389
|
*
|
|
@@ -346,12 +393,13 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
346
393
|
*
|
|
347
394
|
* For more details and code examples, see the {@link Dataset} class.
|
|
348
395
|
*
|
|
349
|
-
* @param [
|
|
350
|
-
* ID or name of the dataset to be opened. If
|
|
351
|
-
*
|
|
396
|
+
* @param [identifier]
|
|
397
|
+
* ID or name of the dataset to be opened. If a string is provided, it will first be
|
|
398
|
+
* looked up as an ID; if no such storage exists, it will be treated as a name.
|
|
399
|
+
* If `null` or `undefined`, the function returns the default dataset associated with the crawler run.
|
|
352
400
|
* @param [options] Storage manager options.
|
|
353
401
|
*/
|
|
354
|
-
static open<Data extends Dictionary = Dictionary>(
|
|
402
|
+
static open<Data extends Dictionary = Dictionary>(identifier?: string | StorageIdentifier | null, options?: StorageOpenOptions): Promise<Dataset<Data>>;
|
|
355
403
|
/**
|
|
356
404
|
* Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
|
|
357
405
|
*
|
|
@@ -414,11 +462,11 @@ export interface DatasetReducer<T, Data> {
|
|
|
414
462
|
*/
|
|
415
463
|
(memo: T, item: Data, index: number): Awaitable<T>;
|
|
416
464
|
}
|
|
465
|
+
/** @internal */
|
|
417
466
|
export interface DatasetOptions {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
storageObject?: Record<string, unknown>;
|
|
467
|
+
/** Resolved metadata for the dataset, as returned by the backend's `getMetadata()`. */
|
|
468
|
+
metadata: DatasetInfo;
|
|
469
|
+
backend: DatasetBackend;
|
|
422
470
|
}
|
|
423
471
|
export interface DatasetContent<Data> {
|
|
424
472
|
/** Total count of entries in the dataset. */
|
|
@@ -434,4 +482,3 @@ export interface DatasetContent<Data> {
|
|
|
434
482
|
/** Should the results be in descending order. */
|
|
435
483
|
desc?: boolean;
|
|
436
484
|
}
|
|
437
|
-
//# sourceMappingURL=dataset.d.ts.map
|