@crawlee/core 3.13.3-beta.11 → 3.13.3-beta.13
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/autoscaling/autoscaled_pool.d.ts +16 -16
- package/autoscaling/autoscaled_pool.js +13 -13
- package/autoscaling/snapshotter.d.ts +1 -1
- package/autoscaling/snapshotter.js +1 -1
- package/autoscaling/system_status.d.ts +12 -12
- package/autoscaling/system_status.js +11 -11
- package/configuration.d.ts +10 -10
- package/configuration.js +4 -4
- package/crawlers/crawler_commons.d.ts +12 -12
- package/crawlers/crawler_commons.js +4 -4
- package/crawlers/statistics.d.ts +2 -2
- package/crawlers/statistics.js +1 -1
- package/enqueue_links/enqueue_links.d.ts +14 -14
- package/enqueue_links/enqueue_links.js +5 -5
- package/enqueue_links/shared.d.ts +2 -2
- package/http_clients/base-http-client.d.ts +7 -7
- package/http_clients/base-http-client.js +1 -1
- package/package.json +5 -5
- package/proxy_configuration.d.ts +11 -11
- package/proxy_configuration.js +8 -8
- package/request.d.ts +3 -3
- package/request.js +2 -2
- package/session_pool/session.d.ts +1 -1
- package/session_pool/session_pool.d.ts +12 -12
- package/session_pool/session_pool.js +10 -10
- package/storages/dataset.d.ts +15 -15
- package/storages/dataset.js +9 -9
- package/storages/key_value_store.d.ts +32 -32
- package/storages/key_value_store.js +22 -22
- package/storages/request_list.d.ts +35 -35
- package/storages/request_list.js +19 -19
- package/storages/request_provider.d.ts +19 -19
- package/storages/request_provider.js +12 -12
- package/storages/request_queue.d.ts +16 -16
- package/storages/request_queue.js +16 -16
- package/storages/request_queue_v2.d.ts +7 -7
- package/storages/request_queue_v2.js +7 -7
- package/storages/utils.d.ts +2 -2
package/storages/dataset.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface DatasetExportToOptions extends DatasetExportOptions {
|
|
|
97
97
|
* Typically it is used to store crawling results.
|
|
98
98
|
*
|
|
99
99
|
* Do not instantiate this class directly, use the
|
|
100
|
-
* {@
|
|
100
|
+
* {@link Dataset.open} function instead.
|
|
101
101
|
*
|
|
102
102
|
* `Dataset` stores its data either on local disk or in the Apify cloud,
|
|
103
103
|
* depending on whether the `APIFY_LOCAL_STORAGE_DIR` or `APIFY_TOKEN` environment variables are set.
|
|
@@ -114,7 +114,7 @@ export interface DatasetExportToOptions extends DatasetExportOptions {
|
|
|
114
114
|
* If the `APIFY_TOKEN` environment variable is set but `APIFY_LOCAL_STORAGE_DIR` not, the data is stored in the
|
|
115
115
|
* [Apify Dataset](https://docs.apify.com/storage/dataset)
|
|
116
116
|
* cloud storage. Note that you can force usage of the cloud storage also by passing the `forceCloud`
|
|
117
|
-
* option to {@
|
|
117
|
+
* option to {@link Dataset.open} function,
|
|
118
118
|
* even if the `APIFY_LOCAL_STORAGE_DIR` variable is set.
|
|
119
119
|
*
|
|
120
120
|
* **Example usage:**
|
|
@@ -176,7 +176,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
176
176
|
*/
|
|
177
177
|
pushData(data: Data | Data[]): Promise<void>;
|
|
178
178
|
/**
|
|
179
|
-
* Returns {@
|
|
179
|
+
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
180
180
|
*/
|
|
181
181
|
getData(options?: DatasetDataOptions): Promise<DatasetContent<Data>>;
|
|
182
182
|
/**
|
|
@@ -332,13 +332,13 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
332
332
|
*/
|
|
333
333
|
drop(): Promise<void>;
|
|
334
334
|
/**
|
|
335
|
-
* Opens a dataset and returns a promise resolving to an instance of the {@
|
|
335
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
336
336
|
*
|
|
337
337
|
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
338
338
|
* such as online store products or real estate offers.
|
|
339
339
|
* The actual data is stored either on the local filesystem or in the cloud.
|
|
340
340
|
*
|
|
341
|
-
* For more details and code examples, see the {@
|
|
341
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
342
342
|
*
|
|
343
343
|
* @param [datasetIdOrName]
|
|
344
344
|
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
@@ -347,9 +347,9 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
347
347
|
*/
|
|
348
348
|
static open<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: StorageManagerOptions): Promise<Dataset<Data>>;
|
|
349
349
|
/**
|
|
350
|
-
* Stores an object or an array of objects to the default {@
|
|
350
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
|
|
351
351
|
*
|
|
352
|
-
* This is just a convenient shortcut for {@
|
|
352
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
353
353
|
* For example, calling the following code:
|
|
354
354
|
* ```javascript
|
|
355
355
|
* await Dataset.pushData({ myValue: 123 });
|
|
@@ -361,7 +361,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
361
361
|
* await dataset.pushData({ myValue: 123 });
|
|
362
362
|
* ```
|
|
363
363
|
*
|
|
364
|
-
* For more information, see {@
|
|
364
|
+
* For more information, see {@link Dataset.open} and {@link Dataset.pushData}
|
|
365
365
|
*
|
|
366
366
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
367
367
|
* otherwise the crawler process might finish before the data are stored!
|
|
@@ -372,7 +372,7 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
372
372
|
*/
|
|
373
373
|
static pushData<Data extends Dictionary = Dictionary>(item: Data | Data[]): Promise<void>;
|
|
374
374
|
/**
|
|
375
|
-
* Returns {@
|
|
375
|
+
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
376
376
|
*/
|
|
377
377
|
static getData<Data extends Dictionary = Dictionary>(options?: DatasetDataOptions): Promise<DatasetContent<Data>>;
|
|
378
378
|
}
|
|
@@ -381,8 +381,8 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
381
381
|
*/
|
|
382
382
|
export interface DatasetConsumer<Data> {
|
|
383
383
|
/**
|
|
384
|
-
* @param item Current {@
|
|
385
|
-
* @param index Position of current {@
|
|
384
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
385
|
+
* @param index Position of current {@link Dataset} entry.
|
|
386
386
|
*/
|
|
387
387
|
(item: Data, index: number): Awaitable<void>;
|
|
388
388
|
}
|
|
@@ -392,8 +392,8 @@ export interface DatasetConsumer<Data> {
|
|
|
392
392
|
export interface DatasetMapper<Data, R> {
|
|
393
393
|
/**
|
|
394
394
|
* User-function used in the `Dataset.map()` API.
|
|
395
|
-
* @param item Current {@
|
|
396
|
-
* @param index Position of current {@
|
|
395
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
396
|
+
* @param index Position of current {@link Dataset} entry.
|
|
397
397
|
*/
|
|
398
398
|
(item: Data, index: number): Awaitable<R>;
|
|
399
399
|
}
|
|
@@ -403,8 +403,8 @@ export interface DatasetMapper<Data, R> {
|
|
|
403
403
|
export interface DatasetReducer<T, Data> {
|
|
404
404
|
/**
|
|
405
405
|
* @param memo Previous state of the reduction.
|
|
406
|
-
* @param item Current {@
|
|
407
|
-
* @param index Position of current {@
|
|
406
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
407
|
+
* @param index Position of current {@link Dataset} entry.
|
|
408
408
|
*/
|
|
409
409
|
(memo: T, item: Data, index: number): Awaitable<T>;
|
|
410
410
|
}
|
package/storages/dataset.js
CHANGED
|
@@ -90,7 +90,7 @@ function chunkBySize(items, limitBytes) {
|
|
|
90
90
|
* Typically it is used to store crawling results.
|
|
91
91
|
*
|
|
92
92
|
* Do not instantiate this class directly, use the
|
|
93
|
-
* {@
|
|
93
|
+
* {@link Dataset.open} function instead.
|
|
94
94
|
*
|
|
95
95
|
* `Dataset` stores its data either on local disk or in the Apify cloud,
|
|
96
96
|
* depending on whether the `APIFY_LOCAL_STORAGE_DIR` or `APIFY_TOKEN` environment variables are set.
|
|
@@ -107,7 +107,7 @@ function chunkBySize(items, limitBytes) {
|
|
|
107
107
|
* If the `APIFY_TOKEN` environment variable is set but `APIFY_LOCAL_STORAGE_DIR` not, the data is stored in the
|
|
108
108
|
* [Apify Dataset](https://docs.apify.com/storage/dataset)
|
|
109
109
|
* cloud storage. Note that you can force usage of the cloud storage also by passing the `forceCloud`
|
|
110
|
-
* option to {@
|
|
110
|
+
* option to {@link Dataset.open} function,
|
|
111
111
|
* even if the `APIFY_LOCAL_STORAGE_DIR` variable is set.
|
|
112
112
|
*
|
|
113
113
|
* **Example usage:**
|
|
@@ -216,7 +216,7 @@ class Dataset {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
|
-
* Returns {@
|
|
219
|
+
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
220
220
|
*/
|
|
221
221
|
async getData(options = {}) {
|
|
222
222
|
(0, access_checking_1.checkStorageAccess)();
|
|
@@ -429,13 +429,13 @@ class Dataset {
|
|
|
429
429
|
manager.closeStorage(this);
|
|
430
430
|
}
|
|
431
431
|
/**
|
|
432
|
-
* Opens a dataset and returns a promise resolving to an instance of the {@
|
|
432
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
433
433
|
*
|
|
434
434
|
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
435
435
|
* such as online store products or real estate offers.
|
|
436
436
|
* The actual data is stored either on the local filesystem or in the cloud.
|
|
437
437
|
*
|
|
438
|
-
* For more details and code examples, see the {@
|
|
438
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
439
439
|
*
|
|
440
440
|
* @param [datasetIdOrName]
|
|
441
441
|
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
@@ -456,9 +456,9 @@ class Dataset {
|
|
|
456
456
|
return manager.openStorage(datasetIdOrName, options.storageClient);
|
|
457
457
|
}
|
|
458
458
|
/**
|
|
459
|
-
* Stores an object or an array of objects to the default {@
|
|
459
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current crawler run.
|
|
460
460
|
*
|
|
461
|
-
* This is just a convenient shortcut for {@
|
|
461
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
462
462
|
* For example, calling the following code:
|
|
463
463
|
* ```javascript
|
|
464
464
|
* await Dataset.pushData({ myValue: 123 });
|
|
@@ -470,7 +470,7 @@ class Dataset {
|
|
|
470
470
|
* await dataset.pushData({ myValue: 123 });
|
|
471
471
|
* ```
|
|
472
472
|
*
|
|
473
|
-
* For more information, see {@
|
|
473
|
+
* For more information, see {@link Dataset.open} and {@link Dataset.pushData}
|
|
474
474
|
*
|
|
475
475
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
476
476
|
* otherwise the crawler process might finish before the data are stored!
|
|
@@ -484,7 +484,7 @@ class Dataset {
|
|
|
484
484
|
return dataset.pushData(item);
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
|
-
* Returns {@
|
|
487
|
+
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
488
488
|
*/
|
|
489
489
|
static async getData(options = {}) {
|
|
490
490
|
const dataset = await this.open();
|
|
@@ -17,16 +17,16 @@ export declare const maybeStringify: <T>(value: T, options: {
|
|
|
17
17
|
* for saving screenshots, crawler inputs and outputs, web pages, PDFs or to persist the state of crawlers.
|
|
18
18
|
*
|
|
19
19
|
* Do not instantiate this class directly, use the
|
|
20
|
-
* {@
|
|
20
|
+
* {@link KeyValueStore.open} function instead.
|
|
21
21
|
*
|
|
22
22
|
* Each crawler run is associated with a default key-value store, which is created exclusively
|
|
23
23
|
* for the run. By convention, the crawler input and output are stored into the
|
|
24
24
|
* default key-value store under the `INPUT` and `OUTPUT` key, respectively.
|
|
25
25
|
* Typically, input and output are JSON files, although it can be any other format.
|
|
26
26
|
* To access the default key-value store directly, you can use the
|
|
27
|
-
* {@
|
|
27
|
+
* {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
|
|
28
28
|
*
|
|
29
|
-
* To access the input, you can also use the {@
|
|
29
|
+
* To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
|
|
30
30
|
*
|
|
31
31
|
* `KeyValueStore` stores its data on a local disk.
|
|
32
32
|
*
|
|
@@ -93,7 +93,7 @@ export declare class KeyValueStore {
|
|
|
93
93
|
* If the record does not exist, the function resolves to `null`.
|
|
94
94
|
*
|
|
95
95
|
* To save or delete a value in the key-value store, use the
|
|
96
|
-
* {@
|
|
96
|
+
* {@link KeyValueStore.setValue} function.
|
|
97
97
|
*
|
|
98
98
|
* **Example usage:**
|
|
99
99
|
*
|
|
@@ -124,7 +124,7 @@ export declare class KeyValueStore {
|
|
|
124
124
|
* If the record does not exist, the function resolves to `null`.
|
|
125
125
|
*
|
|
126
126
|
* To save or delete a value in the key-value store, use the
|
|
127
|
-
* {@
|
|
127
|
+
* {@link KeyValueStore.setValue} function.
|
|
128
128
|
*
|
|
129
129
|
* **Example usage:**
|
|
130
130
|
*
|
|
@@ -179,7 +179,7 @@ export declare class KeyValueStore {
|
|
|
179
179
|
* regardless whether the record existed or not.
|
|
180
180
|
*
|
|
181
181
|
* To retrieve a value from the key-value store, use the
|
|
182
|
-
* {@
|
|
182
|
+
* {@link KeyValueStore.getValue} function.
|
|
183
183
|
*
|
|
184
184
|
* **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
|
|
185
185
|
* otherwise the crawler process might finish before the value is stored!
|
|
@@ -231,13 +231,13 @@ export declare class KeyValueStore {
|
|
|
231
231
|
*/
|
|
232
232
|
getPublicUrl(key: string): string;
|
|
233
233
|
/**
|
|
234
|
-
* Opens a key-value store and returns a promise resolving to an instance of the {@
|
|
234
|
+
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
235
235
|
*
|
|
236
236
|
* Key-value stores are used to store records or files, along with their MIME content type.
|
|
237
237
|
* The records are stored and retrieved using a unique key.
|
|
238
238
|
* The actual data is stored either on a local filesystem or in the Apify cloud.
|
|
239
239
|
*
|
|
240
|
-
* For more details and code examples, see the {@
|
|
240
|
+
* For more details and code examples, see the {@link KeyValueStore} class.
|
|
241
241
|
*
|
|
242
242
|
* @param [storeIdOrName]
|
|
243
243
|
* ID or name of the key-value store to be opened. If `null` or `undefined`,
|
|
@@ -246,9 +246,9 @@ export declare class KeyValueStore {
|
|
|
246
246
|
*/
|
|
247
247
|
static open(storeIdOrName?: string | null, options?: StorageManagerOptions): Promise<KeyValueStore>;
|
|
248
248
|
/**
|
|
249
|
-
* Gets a value from the default {@
|
|
249
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
250
250
|
*
|
|
251
|
-
* This is just a convenient shortcut for {@
|
|
251
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
252
252
|
* For example, calling the following code:
|
|
253
253
|
* ```javascript
|
|
254
254
|
* const value = await KeyValueStore.getValue('my-key');
|
|
@@ -260,10 +260,10 @@ export declare class KeyValueStore {
|
|
|
260
260
|
* const value = await store.getValue('my-key');
|
|
261
261
|
* ```
|
|
262
262
|
*
|
|
263
|
-
* To store the value to the default key-value store, you can use the {@
|
|
263
|
+
* To store the value to the default key-value store, you can use the {@link KeyValueStore.setValue} function.
|
|
264
264
|
*
|
|
265
|
-
* For more information, see {@
|
|
266
|
-
* and {@
|
|
265
|
+
* For more information, see {@link KeyValueStore.open}
|
|
266
|
+
* and {@link KeyValueStore.getValue}.
|
|
267
267
|
*
|
|
268
268
|
* @param key Unique record key.
|
|
269
269
|
* @returns
|
|
@@ -275,9 +275,9 @@ export declare class KeyValueStore {
|
|
|
275
275
|
*/
|
|
276
276
|
static getValue<T = unknown>(key: string): Promise<T | null>;
|
|
277
277
|
/**
|
|
278
|
-
* Gets a value from the default {@
|
|
278
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
279
279
|
*
|
|
280
|
-
* This is just a convenient shortcut for {@
|
|
280
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
281
281
|
* For example, calling the following code:
|
|
282
282
|
* ```javascript
|
|
283
283
|
* const value = await KeyValueStore.getValue('my-key');
|
|
@@ -289,10 +289,10 @@ export declare class KeyValueStore {
|
|
|
289
289
|
* const value = await store.getValue('my-key');
|
|
290
290
|
* ```
|
|
291
291
|
*
|
|
292
|
-
* To store the value to the default key-value store, you can use the {@
|
|
292
|
+
* To store the value to the default key-value store, you can use the {@link KeyValueStore.setValue} function.
|
|
293
293
|
*
|
|
294
|
-
* For more information, see {@
|
|
295
|
-
* and {@
|
|
294
|
+
* For more information, see {@link KeyValueStore.open}
|
|
295
|
+
* and {@link KeyValueStore.getValue}.
|
|
296
296
|
*
|
|
297
297
|
* @param key Unique record key.
|
|
298
298
|
* @param defaultValue Fallback that will be returned if no value if present in the storage.
|
|
@@ -304,16 +304,16 @@ export declare class KeyValueStore {
|
|
|
304
304
|
*/
|
|
305
305
|
static getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
306
306
|
/**
|
|
307
|
-
* Tests whether a record with the given key exists in the default {@
|
|
307
|
+
* Tests whether a record with the given key exists in the default {@link KeyValueStore} associated with the current crawler run.
|
|
308
308
|
* @param key The queried record key.
|
|
309
309
|
* @returns `true` if the record exists, `false` if it does not.
|
|
310
310
|
*/
|
|
311
311
|
static recordExists(key: string): Promise<boolean>;
|
|
312
312
|
static getAutoSavedValue<T extends Dictionary = Dictionary>(key: string, defaultValue?: T): Promise<T>;
|
|
313
313
|
/**
|
|
314
|
-
* Stores or deletes a value in the default {@
|
|
314
|
+
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current crawler run.
|
|
315
315
|
*
|
|
316
|
-
* This is just a convenient shortcut for {@
|
|
316
|
+
* This is just a convenient shortcut for {@link KeyValueStore.setValue}.
|
|
317
317
|
* For example, calling the following code:
|
|
318
318
|
* ```javascript
|
|
319
319
|
* await KeyValueStore.setValue('OUTPUT', { foo: "bar" });
|
|
@@ -325,10 +325,10 @@ export declare class KeyValueStore {
|
|
|
325
325
|
* await store.setValue('OUTPUT', { foo: "bar" });
|
|
326
326
|
* ```
|
|
327
327
|
*
|
|
328
|
-
* To get a value from the default key-value store, you can use the {@
|
|
328
|
+
* To get a value from the default key-value store, you can use the {@link KeyValueStore.getValue} function.
|
|
329
329
|
*
|
|
330
|
-
* For more information, see {@
|
|
331
|
-
* and {@
|
|
330
|
+
* For more information, see {@link KeyValueStore.open}
|
|
331
|
+
* and {@link KeyValueStore.getValue}.
|
|
332
332
|
*
|
|
333
333
|
* @param key
|
|
334
334
|
* Unique record key.
|
|
@@ -343,16 +343,16 @@ export declare class KeyValueStore {
|
|
|
343
343
|
*/
|
|
344
344
|
static setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
|
|
345
345
|
/**
|
|
346
|
-
* Gets the crawler input value from the default {@
|
|
346
|
+
* Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
347
347
|
* By default, it will try to find root input files (either extension-less, `.json` or `.txt`),
|
|
348
|
-
* or alternatively read the input from the default {@
|
|
348
|
+
* or alternatively read the input from the default {@link KeyValueStore}.
|
|
349
349
|
*
|
|
350
350
|
* Note that the `getInput()` function does not cache the value read from the key-value store.
|
|
351
351
|
* If you need to use the input multiple times in your crawler,
|
|
352
352
|
* it is far more efficient to read it once and store it locally.
|
|
353
353
|
*
|
|
354
|
-
* For more information, see {@
|
|
355
|
-
* and {@
|
|
354
|
+
* For more information, see {@link KeyValueStore.open}
|
|
355
|
+
* and {@link KeyValueStore.getValue}.
|
|
356
356
|
*
|
|
357
357
|
* @returns
|
|
358
358
|
* Returns a promise that resolves to an object, string
|
|
@@ -364,13 +364,13 @@ export declare class KeyValueStore {
|
|
|
364
364
|
static getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
|
-
* User-function used in the {@
|
|
367
|
+
* User-function used in the {@link KeyValueStore.forEachKey} method.
|
|
368
368
|
*/
|
|
369
369
|
export interface KeyConsumer {
|
|
370
370
|
/**
|
|
371
|
-
* @param key Current {@
|
|
372
|
-
* @param index Position of the current key in {@
|
|
373
|
-
* @param info Information about the current {@
|
|
371
|
+
* @param key Current {@link KeyValueStore} key being processed.
|
|
372
|
+
* @param index Position of the current key in {@link KeyValueStore}.
|
|
373
|
+
* @param info Information about the current {@link KeyValueStore} entry.
|
|
374
374
|
* @param info.size Size of the value associated with the current key in bytes.
|
|
375
375
|
*/
|
|
376
376
|
(key: string, index: number, info: {
|
|
@@ -48,16 +48,16 @@ exports.maybeStringify = maybeStringify;
|
|
|
48
48
|
* for saving screenshots, crawler inputs and outputs, web pages, PDFs or to persist the state of crawlers.
|
|
49
49
|
*
|
|
50
50
|
* Do not instantiate this class directly, use the
|
|
51
|
-
* {@
|
|
51
|
+
* {@link KeyValueStore.open} function instead.
|
|
52
52
|
*
|
|
53
53
|
* Each crawler run is associated with a default key-value store, which is created exclusively
|
|
54
54
|
* for the run. By convention, the crawler input and output are stored into the
|
|
55
55
|
* default key-value store under the `INPUT` and `OUTPUT` key, respectively.
|
|
56
56
|
* Typically, input and output are JSON files, although it can be any other format.
|
|
57
57
|
* To access the default key-value store directly, you can use the
|
|
58
|
-
* {@
|
|
58
|
+
* {@link KeyValueStore.getValue} and {@link KeyValueStore.setValue} convenience functions.
|
|
59
59
|
*
|
|
60
|
-
* To access the input, you can also use the {@
|
|
60
|
+
* To access the input, you can also use the {@link KeyValueStore.getInput} convenience function.
|
|
61
61
|
*
|
|
62
62
|
* `KeyValueStore` stores its data on a local disk.
|
|
63
63
|
*
|
|
@@ -164,7 +164,7 @@ class KeyValueStore {
|
|
|
164
164
|
* If the record does not exist, the function resolves to `null`.
|
|
165
165
|
*
|
|
166
166
|
* To save or delete a value in the key-value store, use the
|
|
167
|
-
* {@
|
|
167
|
+
* {@link KeyValueStore.setValue} function.
|
|
168
168
|
*
|
|
169
169
|
* **Example usage:**
|
|
170
170
|
*
|
|
@@ -254,7 +254,7 @@ class KeyValueStore {
|
|
|
254
254
|
* regardless whether the record existed or not.
|
|
255
255
|
*
|
|
256
256
|
* To retrieve a value from the key-value store, use the
|
|
257
|
-
* {@
|
|
257
|
+
* {@link KeyValueStore.getValue} function.
|
|
258
258
|
*
|
|
259
259
|
* **IMPORTANT:** Always make sure to use the `await` keyword when calling `setValue()`,
|
|
260
260
|
* otherwise the crawler process might finish before the value is stored!
|
|
@@ -376,13 +376,13 @@ class KeyValueStore {
|
|
|
376
376
|
return `file://${process.cwd()}/storage/key_value_stores/${name}/${key}`;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
|
-
* Opens a key-value store and returns a promise resolving to an instance of the {@
|
|
379
|
+
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
380
380
|
*
|
|
381
381
|
* Key-value stores are used to store records or files, along with their MIME content type.
|
|
382
382
|
* The records are stored and retrieved using a unique key.
|
|
383
383
|
* The actual data is stored either on a local filesystem or in the Apify cloud.
|
|
384
384
|
*
|
|
385
|
-
* For more details and code examples, see the {@
|
|
385
|
+
* For more details and code examples, see the {@link KeyValueStore} class.
|
|
386
386
|
*
|
|
387
387
|
* @param [storeIdOrName]
|
|
388
388
|
* ID or name of the key-value store to be opened. If `null` or `undefined`,
|
|
@@ -403,9 +403,9 @@ class KeyValueStore {
|
|
|
403
403
|
return manager.openStorage(storeIdOrName, options.storageClient);
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
406
|
-
* Gets a value from the default {@
|
|
406
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
407
407
|
*
|
|
408
|
-
* This is just a convenient shortcut for {@
|
|
408
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
409
409
|
* For example, calling the following code:
|
|
410
410
|
* ```javascript
|
|
411
411
|
* const value = await KeyValueStore.getValue('my-key');
|
|
@@ -417,10 +417,10 @@ class KeyValueStore {
|
|
|
417
417
|
* const value = await store.getValue('my-key');
|
|
418
418
|
* ```
|
|
419
419
|
*
|
|
420
|
-
* To store the value to the default key-value store, you can use the {@
|
|
420
|
+
* To store the value to the default key-value store, you can use the {@link KeyValueStore.setValue} function.
|
|
421
421
|
*
|
|
422
|
-
* For more information, see {@
|
|
423
|
-
* and {@
|
|
422
|
+
* For more information, see {@link KeyValueStore.open}
|
|
423
|
+
* and {@link KeyValueStore.getValue}.
|
|
424
424
|
*
|
|
425
425
|
* @param key Unique record key.
|
|
426
426
|
* @param defaultValue Fallback that will be returned if no value if present in the storage.
|
|
@@ -436,7 +436,7 @@ class KeyValueStore {
|
|
|
436
436
|
return store.getValue(key, defaultValue);
|
|
437
437
|
}
|
|
438
438
|
/**
|
|
439
|
-
* Tests whether a record with the given key exists in the default {@
|
|
439
|
+
* Tests whether a record with the given key exists in the default {@link KeyValueStore} associated with the current crawler run.
|
|
440
440
|
* @param key The queried record key.
|
|
441
441
|
* @returns `true` if the record exists, `false` if it does not.
|
|
442
442
|
*/
|
|
@@ -449,9 +449,9 @@ class KeyValueStore {
|
|
|
449
449
|
return store.getAutoSavedValue(key, defaultValue);
|
|
450
450
|
}
|
|
451
451
|
/**
|
|
452
|
-
* Stores or deletes a value in the default {@
|
|
452
|
+
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current crawler run.
|
|
453
453
|
*
|
|
454
|
-
* This is just a convenient shortcut for {@
|
|
454
|
+
* This is just a convenient shortcut for {@link KeyValueStore.setValue}.
|
|
455
455
|
* For example, calling the following code:
|
|
456
456
|
* ```javascript
|
|
457
457
|
* await KeyValueStore.setValue('OUTPUT', { foo: "bar" });
|
|
@@ -463,10 +463,10 @@ class KeyValueStore {
|
|
|
463
463
|
* await store.setValue('OUTPUT', { foo: "bar" });
|
|
464
464
|
* ```
|
|
465
465
|
*
|
|
466
|
-
* To get a value from the default key-value store, you can use the {@
|
|
466
|
+
* To get a value from the default key-value store, you can use the {@link KeyValueStore.getValue} function.
|
|
467
467
|
*
|
|
468
|
-
* For more information, see {@
|
|
469
|
-
* and {@
|
|
468
|
+
* For more information, see {@link KeyValueStore.open}
|
|
469
|
+
* and {@link KeyValueStore.getValue}.
|
|
470
470
|
*
|
|
471
471
|
* @param key
|
|
472
472
|
* Unique record key.
|
|
@@ -484,16 +484,16 @@ class KeyValueStore {
|
|
|
484
484
|
return store.setValue(key, value, options);
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
|
-
* Gets the crawler input value from the default {@
|
|
487
|
+
* Gets the crawler input value from the default {@link KeyValueStore} associated with the current crawler run.
|
|
488
488
|
* By default, it will try to find root input files (either extension-less, `.json` or `.txt`),
|
|
489
|
-
* or alternatively read the input from the default {@
|
|
489
|
+
* or alternatively read the input from the default {@link KeyValueStore}.
|
|
490
490
|
*
|
|
491
491
|
* Note that the `getInput()` function does not cache the value read from the key-value store.
|
|
492
492
|
* If you need to use the input multiple times in your crawler,
|
|
493
493
|
* it is far more efficient to read it once and store it locally.
|
|
494
494
|
*
|
|
495
|
-
* For more information, see {@
|
|
496
|
-
* and {@
|
|
495
|
+
* For more information, see {@link KeyValueStore.open}
|
|
496
|
+
* and {@link KeyValueStore.getValue}.
|
|
497
497
|
*
|
|
498
498
|
* @returns
|
|
499
499
|
* Returns a promise that resolves to an object, string
|