@crawlee/core 3.0.0-alpha.0 → 3.0.0-alpha.3
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/dist/LICENSE.md +201 -0
- package/{README.md → dist/README.md} +0 -0
- package/dist/autoscaling/autoscaled_pool.d.ts +286 -0
- package/dist/autoscaling/autoscaled_pool.d.ts.map +1 -0
- package/dist/autoscaling/autoscaled_pool.js +624 -0
- package/dist/autoscaling/autoscaled_pool.js.map +1 -0
- package/dist/autoscaling/index.d.ts +4 -0
- package/dist/autoscaling/index.d.ts.map +1 -0
- package/dist/autoscaling/index.js +7 -0
- package/dist/autoscaling/index.js.map +1 -0
- package/dist/autoscaling/snapshotter.d.ts +193 -0
- package/dist/autoscaling/snapshotter.d.ts.map +1 -0
- package/dist/autoscaling/snapshotter.js +377 -0
- package/dist/autoscaling/snapshotter.js.map +1 -0
- package/dist/autoscaling/system_status.d.ts +181 -0
- package/dist/autoscaling/system_status.d.ts.map +1 -0
- package/dist/autoscaling/system_status.js +194 -0
- package/dist/autoscaling/system_status.js.map +1 -0
- package/dist/cache_container.d.ts +18 -0
- package/dist/cache_container.d.ts.map +1 -0
- package/dist/cache_container.js +42 -0
- package/dist/cache_container.js.map +1 -0
- package/dist/configuration.d.ts +150 -0
- package/dist/configuration.d.ts.map +1 -0
- package/dist/configuration.js +284 -0
- package/dist/configuration.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/crawlers/crawler_commons.d.ts +23 -0
- package/dist/crawlers/crawler_commons.d.ts.map +1 -0
- package/dist/crawlers/crawler_commons.js +3 -0
- package/dist/crawlers/crawler_commons.js.map +1 -0
- package/dist/crawlers/crawler_extension.d.ts +11 -0
- package/dist/crawlers/crawler_extension.d.ts.map +1 -0
- package/dist/crawlers/crawler_extension.js +30 -0
- package/dist/crawlers/crawler_extension.js.map +1 -0
- package/dist/crawlers/crawler_utils.d.ts +25 -0
- package/dist/crawlers/crawler_utils.d.ts.map +1 -0
- package/dist/crawlers/crawler_utils.js +72 -0
- package/dist/crawlers/crawler_utils.js.map +1 -0
- package/dist/crawlers/index.d.ts +5 -0
- package/dist/crawlers/index.d.ts.map +1 -0
- package/dist/crawlers/index.js +8 -0
- package/dist/crawlers/index.js.map +1 -0
- package/dist/crawlers/statistics.d.ts +147 -0
- package/dist/crawlers/statistics.d.ts.map +1 -0
- package/dist/crawlers/statistics.js +360 -0
- package/dist/crawlers/statistics.js.map +1 -0
- package/dist/enqueue_links/enqueue_links.d.ts +138 -0
- package/dist/enqueue_links/enqueue_links.d.ts.map +1 -0
- package/dist/enqueue_links/enqueue_links.js +123 -0
- package/dist/enqueue_links/enqueue_links.js.map +1 -0
- package/dist/enqueue_links/index.d.ts +3 -0
- package/dist/enqueue_links/index.d.ts.map +1 -0
- package/dist/enqueue_links/index.js +6 -0
- package/dist/enqueue_links/index.js.map +1 -0
- package/dist/enqueue_links/shared.d.ts +60 -0
- package/dist/enqueue_links/shared.d.ts.map +1 -0
- package/dist/enqueue_links/shared.js +148 -0
- package/dist/enqueue_links/shared.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/event_manager.d.ts +41 -0
- package/dist/events/event_manager.d.ts.map +1 -0
- package/dist/events/event_manager.js +103 -0
- package/dist/events/event_manager.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +6 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/local_event_manager.d.ts +32 -0
- package/dist/events/local_event_manager.d.ts.map +1 -0
- package/dist/events/local_event_manager.js +114 -0
- package/dist/events/local_event_manager.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +63 -0
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +12 -0
- package/dist/log.js.map +1 -0
- package/dist/package.json +82 -0
- package/dist/proxy_configuration.d.ts +181 -0
- package/dist/proxy_configuration.d.ts.map +1 -0
- package/dist/proxy_configuration.js +209 -0
- package/dist/proxy_configuration.js.map +1 -0
- package/dist/request.d.ts +174 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +270 -0
- package/dist/request.js.map +1 -0
- package/dist/serialization.d.ts +33 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +146 -0
- package/dist/serialization.js.map +1 -0
- package/dist/session_pool/errors.d.ts +8 -0
- package/dist/session_pool/errors.d.ts.map +1 -0
- package/dist/session_pool/errors.js +20 -0
- package/dist/session_pool/errors.js.map +1 -0
- package/dist/session_pool/events.d.ts +3 -0
- package/dist/session_pool/events.d.ts.map +1 -0
- package/dist/session_pool/events.js +6 -0
- package/dist/session_pool/events.js.map +1 -0
- package/dist/session_pool/index.d.ts +6 -0
- package/dist/session_pool/index.d.ts.map +1 -0
- package/dist/session_pool/index.js +9 -0
- package/dist/session_pool/index.js.map +1 -0
- package/dist/session_pool/session.d.ts +212 -0
- package/dist/session_pool/session.d.ts.map +1 -0
- package/dist/session_pool/session.js +360 -0
- package/dist/session_pool/session.js.map +1 -0
- package/dist/session_pool/session_pool.d.ts +222 -0
- package/dist/session_pool/session_pool.d.ts.map +1 -0
- package/dist/session_pool/session_pool.js +389 -0
- package/dist/session_pool/session_pool.js.map +1 -0
- package/dist/session_pool/session_utils.d.ts +9 -0
- package/dist/session_pool/session_utils.d.ts.map +1 -0
- package/dist/session_pool/session_utils.js +19 -0
- package/dist/session_pool/session_utils.js.map +1 -0
- package/dist/storages/dataset.d.ts +358 -0
- package/dist/storages/dataset.d.ts.map +1 -0
- package/dist/storages/dataset.js +415 -0
- package/dist/storages/dataset.js.map +1 -0
- package/dist/storages/index.d.ts +7 -0
- package/dist/storages/index.d.ts.map +1 -0
- package/dist/storages/index.js +11 -0
- package/dist/storages/index.js.map +1 -0
- package/dist/storages/key_value_store.d.ts +242 -0
- package/dist/storages/key_value_store.d.ts.map +1 -0
- package/dist/storages/key_value_store.js +319 -0
- package/dist/storages/key_value_store.js.map +1 -0
- package/dist/storages/request_list.d.ts +461 -0
- package/dist/storages/request_list.d.ts.map +1 -0
- package/dist/storages/request_list.js +715 -0
- package/dist/storages/request_list.js.map +1 -0
- package/dist/storages/request_queue.d.ts +312 -0
- package/dist/storages/request_queue.d.ts.map +1 -0
- package/dist/storages/request_queue.js +708 -0
- package/dist/storages/request_queue.js.map +1 -0
- package/dist/storages/storage.d.ts +260 -0
- package/dist/storages/storage.d.ts.map +1 -0
- package/dist/storages/storage.js +3 -0
- package/dist/storages/storage.js.map +1 -0
- package/dist/storages/storage_manager.d.ts +40 -0
- package/dist/storages/storage_manager.d.ts.map +1 -0
- package/dist/storages/storage_manager.js +119 -0
- package/dist/storages/storage_manager.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/typedefs.d.ts +12 -0
- package/dist/typedefs.d.ts.map +1 -0
- package/dist/typedefs.js +15 -0
- package/dist/typedefs.js.map +1 -0
- package/dist/validators.d.ts +21 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +26 -0
- package/dist/validators.js.map +1 -0
- package/package.json +11 -10
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { Awaitable, Dictionary } from '../typedefs';
|
|
2
|
+
import { StorageManagerOptions } from './storage_manager';
|
|
3
|
+
import { DatasetClient, DatasetInfo, PaginatedList, StorageClient } from './storage';
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const DATASET_ITERATORS_DEFAULT_LIMIT = 10000;
|
|
6
|
+
/**
|
|
7
|
+
* Accepts a JSON serializable object as an input, validates its serializability,
|
|
8
|
+
* and validates its serialized size against limitBytes. Optionally accepts its index
|
|
9
|
+
* in an array to provide better error messages. Returns serialized object.
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkAndSerialize<T>(item: T, limitBytes: number, index?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Takes an array of JSONs (payloads) as input and produces an array of JSON strings
|
|
15
|
+
* where each string is a JSON array of payloads with a maximum size of limitBytes per one
|
|
16
|
+
* JSON array. Fits as many payloads as possible into a single JSON array and then moves
|
|
17
|
+
* on to the next, preserving item order.
|
|
18
|
+
*
|
|
19
|
+
* The function assumes that none of the items is larger than limitBytes and does not validate.
|
|
20
|
+
* @ignore
|
|
21
|
+
*/
|
|
22
|
+
export declare function chunkBySize(items: string[], limitBytes: number): string[];
|
|
23
|
+
export interface DatasetDataOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Number of array elements that should be skipped at the start.
|
|
26
|
+
* @default 0
|
|
27
|
+
*/
|
|
28
|
+
offset?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Maximum number of array elements to return.
|
|
31
|
+
* @default 250000
|
|
32
|
+
*/
|
|
33
|
+
limit?: number;
|
|
34
|
+
/**
|
|
35
|
+
* If `true` then the objects are sorted by `createdAt` in descending order.
|
|
36
|
+
* Otherwise they are sorted in ascending order.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
desc?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* An array of field names that will be included in the result. If omitted, all fields are included in the results.
|
|
42
|
+
*/
|
|
43
|
+
fields?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Specifies a name of the field in the result objects that will be used to unwind the resulting objects.
|
|
46
|
+
* By default, the results are returned as they are.
|
|
47
|
+
*/
|
|
48
|
+
unwind?: string;
|
|
49
|
+
/**
|
|
50
|
+
* If `true` then the function returns only non-empty items and skips hidden fields (i.e. fields starting with `#` character).
|
|
51
|
+
* Note that the `clean` parameter is a shortcut for `skipHidden: true` and `skipEmpty: true` options.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
clean?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If `true` then the function doesn't return hidden fields (fields starting with "#" character).
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
skipHidden?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* If `true` then the function doesn't return empty items.
|
|
62
|
+
* Note that in this case the returned number of items might be lower than limit parameter and pagination must be done using the `limit` value.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
skipEmpty?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface DatasetIteratorOptions extends Omit<DatasetDataOptions, 'offset' | 'limit' | 'clean' | 'skipHidden' | 'skipEmpty'> {
|
|
68
|
+
/** @internal */
|
|
69
|
+
offset?: number;
|
|
70
|
+
/**
|
|
71
|
+
* @default 10000
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
limit?: number;
|
|
75
|
+
/** @internal */
|
|
76
|
+
clean?: boolean;
|
|
77
|
+
/** @internal */
|
|
78
|
+
skipHidden?: boolean;
|
|
79
|
+
/** @internal */
|
|
80
|
+
skipEmpty?: boolean;
|
|
81
|
+
/** @internal */
|
|
82
|
+
format?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The `Dataset` class represents a store for structured data where each object stored has the same attributes,
|
|
86
|
+
* such as online store products or real estate offers. You can imagine it as a table,
|
|
87
|
+
* where each object is a row and its attributes are columns.
|
|
88
|
+
* Dataset is an append-only storage - you can only add new records to it but you cannot modify or remove existing records.
|
|
89
|
+
* Typically it is used to store crawling results.
|
|
90
|
+
*
|
|
91
|
+
* Do not instantiate this class directly, use the
|
|
92
|
+
* {@link Dataset.open} function instead.
|
|
93
|
+
*
|
|
94
|
+
* `Dataset` stores its data either on local disk or in the Apify cloud,
|
|
95
|
+
* depending on whether the `APIFY_LOCAL_STORAGE_DIR` or `APIFY_TOKEN` environment variables are set.
|
|
96
|
+
*
|
|
97
|
+
* If the `APIFY_LOCAL_STORAGE_DIR` environment variable is set, the data is stored in
|
|
98
|
+
* the local directory in the following files:
|
|
99
|
+
* ```
|
|
100
|
+
* {APIFY_LOCAL_STORAGE_DIR}/datasets/{DATASET_ID}/{INDEX}.json
|
|
101
|
+
* ```
|
|
102
|
+
* Note that `{DATASET_ID}` is the name or ID of the dataset. The default dataset has ID: `default`,
|
|
103
|
+
* unless you override it by setting the `APIFY_DEFAULT_DATASET_ID` environment variable.
|
|
104
|
+
* Each dataset item is stored as a separate JSON file, where `{INDEX}` is a zero-based index of the item in the dataset.
|
|
105
|
+
*
|
|
106
|
+
* If the `APIFY_TOKEN` environment variable is set but `APIFY_LOCAL_STORAGE_DIR` not, the data is stored in the
|
|
107
|
+
* [Apify Dataset](https://docs.apify.com/storage/dataset)
|
|
108
|
+
* cloud storage. Note that you can force usage of the cloud storage also by passing the `forceCloud`
|
|
109
|
+
* option to {@link Dataset.open} function,
|
|
110
|
+
* even if the `APIFY_LOCAL_STORAGE_DIR` variable is set.
|
|
111
|
+
*
|
|
112
|
+
* **Example usage:**
|
|
113
|
+
*
|
|
114
|
+
* ```javascript
|
|
115
|
+
* // Write a single row to the default dataset
|
|
116
|
+
* await Actor.pushData({ col1: 123, col2: 'val2' });
|
|
117
|
+
*
|
|
118
|
+
* // Open a named dataset
|
|
119
|
+
* const dataset = await Dataset.open('some-name');
|
|
120
|
+
*
|
|
121
|
+
* // Write a single row
|
|
122
|
+
* await dataset.pushData({ foo: 'bar' });
|
|
123
|
+
*
|
|
124
|
+
* // Write multiple rows
|
|
125
|
+
* await dataset.pushData([
|
|
126
|
+
* { foo: 'bar2', col2: 'val2' },
|
|
127
|
+
* { col3: 123 },
|
|
128
|
+
* ]);
|
|
129
|
+
* ```
|
|
130
|
+
* @category Result Stores
|
|
131
|
+
*/
|
|
132
|
+
export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
133
|
+
id: string;
|
|
134
|
+
name?: string;
|
|
135
|
+
client: DatasetClient<Data>;
|
|
136
|
+
log: import("@apify/log/log").Log;
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
constructor(options: DatasetOptions);
|
|
141
|
+
/**
|
|
142
|
+
* Stores an object or an array of objects to the dataset.
|
|
143
|
+
* The function returns a promise that resolves when the operation finishes.
|
|
144
|
+
* It has no result, but throws on invalid args or other errors.
|
|
145
|
+
*
|
|
146
|
+
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
147
|
+
* otherwise the actor process might finish before the data is stored!
|
|
148
|
+
*
|
|
149
|
+
* The size of the data is limited by the receiving API and therefore `pushData()` will only
|
|
150
|
+
* allow objects whose JSON representation is smaller than 9MB. When an array is passed,
|
|
151
|
+
* none of the included objects
|
|
152
|
+
* may be larger than 9MB, but the array itself may be of any size.
|
|
153
|
+
*
|
|
154
|
+
* The function internally
|
|
155
|
+
* chunks the array into separate items and pushes them sequentially.
|
|
156
|
+
* The chunking process is stable (keeps order of data), but it does not provide a transaction
|
|
157
|
+
* safety mechanism. Therefore, in the event of an uploading error (after several automatic retries),
|
|
158
|
+
* the function's Promise will reject and the dataset will be left in a state where some of
|
|
159
|
+
* the items have already been saved to the dataset while other items from the source array were not.
|
|
160
|
+
* To overcome this limitation, the developer may, for example, read the last item saved in the dataset
|
|
161
|
+
* and re-attempt the save of the data from this item onwards to prevent duplicates.
|
|
162
|
+
* @param data Object or array of objects containing data to be stored in the default dataset.
|
|
163
|
+
* The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
|
|
164
|
+
*/
|
|
165
|
+
pushData(data: Data | Data[]): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
168
|
+
*
|
|
169
|
+
* If you need to get data in an unparsed format, use the {@link Actor.newClient} function to get a new
|
|
170
|
+
* `apify-client` instance and call
|
|
171
|
+
* [`datasetClient.downloadItems()`](https://github.com/apify/apify-client-js#DatasetClient+downloadItems)
|
|
172
|
+
*/
|
|
173
|
+
getData(options?: DatasetDataOptions): Promise<PaginatedList<Data>>;
|
|
174
|
+
/**
|
|
175
|
+
* Returns an object containing general information about the dataset.
|
|
176
|
+
*
|
|
177
|
+
* The function returns the same object as the Apify API Client's
|
|
178
|
+
* [getDataset](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-datasets-getDataset)
|
|
179
|
+
* function, which in turn calls the
|
|
180
|
+
* [Get dataset](https://apify.com/docs/api/v2#/reference/datasets/dataset/get-dataset)
|
|
181
|
+
* API endpoint.
|
|
182
|
+
*
|
|
183
|
+
* **Example:**
|
|
184
|
+
* ```
|
|
185
|
+
* {
|
|
186
|
+
* id: "WkzbQMuFYuamGv3YF",
|
|
187
|
+
* name: "my-dataset",
|
|
188
|
+
* userId: "wRsJZtadYvn4mBZmm",
|
|
189
|
+
* createdAt: new Date("2015-12-12T07:34:14.202Z"),
|
|
190
|
+
* modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
|
|
191
|
+
* accessedAt: new Date("2015-12-14T08:36:13.202Z"),
|
|
192
|
+
* itemCount: 14,
|
|
193
|
+
* cleanItemCount: 10
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
getInfo(): Promise<DatasetInfo | undefined>;
|
|
198
|
+
/**
|
|
199
|
+
* Iterates over dataset items, yielding each in turn to an `iteratee` function.
|
|
200
|
+
* Each invocation of `iteratee` is called with two arguments: `(item, index)`.
|
|
201
|
+
*
|
|
202
|
+
* If the `iteratee` function returns a Promise then it is awaited before the next call.
|
|
203
|
+
* If it throws an error, the iteration is aborted and the `forEach` function throws the error.
|
|
204
|
+
*
|
|
205
|
+
* **Example usage**
|
|
206
|
+
* ```javascript
|
|
207
|
+
* const dataset = await Dataset.open('my-results');
|
|
208
|
+
* await dataset.forEach(async (item, index) => {
|
|
209
|
+
* console.log(`Item at ${index}: ${JSON.stringify(item)}`);
|
|
210
|
+
* });
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param iteratee A function that is called for every item in the dataset.
|
|
214
|
+
* @param [options] All `forEach()` parameters.
|
|
215
|
+
* @param [index] Specifies the initial index number passed to the `iteratee` function.
|
|
216
|
+
* @default 0
|
|
217
|
+
*/
|
|
218
|
+
forEach(iteratee: DatasetConsumer<Data>, options?: DatasetIteratorOptions, index?: number): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Produces a new array of values by mapping each value in list through a transformation function `iteratee()`.
|
|
221
|
+
* Each invocation of `iteratee()` is called with two arguments: `(element, index)`.
|
|
222
|
+
*
|
|
223
|
+
* If `iteratee` returns a `Promise` then it's awaited before a next call.
|
|
224
|
+
*
|
|
225
|
+
* @param iteratee
|
|
226
|
+
* @param [options] All `map()` parameters.
|
|
227
|
+
*/
|
|
228
|
+
map<R>(iteratee: DatasetMapper<Data, R>, options?: DatasetIteratorOptions): Promise<R[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Reduces a list of values down to a single value.
|
|
231
|
+
*
|
|
232
|
+
* Memo is the initial state of the reduction, and each successive step of it should be returned by `iteratee()`.
|
|
233
|
+
* The `iteratee()` is passed three arguments: the `memo`, then the `value` and `index` of the iteration.
|
|
234
|
+
*
|
|
235
|
+
* If no `memo` is passed to the initial invocation of reduce, the `iteratee()` is not invoked on the first element of the list.
|
|
236
|
+
* The first element is instead passed as the memo in the invocation of the `iteratee()` on the next element in the list.
|
|
237
|
+
*
|
|
238
|
+
* If `iteratee()` returns a `Promise` then it's awaited before a next call.
|
|
239
|
+
*
|
|
240
|
+
* @param iteratee
|
|
241
|
+
* @param memo Initial state of the reduction.
|
|
242
|
+
* @param [options] All `reduce()` parameters.
|
|
243
|
+
*/
|
|
244
|
+
reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
|
|
245
|
+
/**
|
|
246
|
+
* Removes the dataset either from the Apify cloud storage or from the local directory,
|
|
247
|
+
* depending on the mode of operation.
|
|
248
|
+
*/
|
|
249
|
+
drop(): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
252
|
+
*
|
|
253
|
+
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
254
|
+
* such as online store products or real estate offers.
|
|
255
|
+
* The actual data is stored either on the local filesystem or in the cloud.
|
|
256
|
+
*
|
|
257
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
258
|
+
*
|
|
259
|
+
* @param [datasetIdOrName]
|
|
260
|
+
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
261
|
+
* the function returns the default dataset associated with the actor run.
|
|
262
|
+
* @param [options] Storage manager options.
|
|
263
|
+
*/
|
|
264
|
+
static open<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: StorageManagerOptions): Promise<Dataset<Data>>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
268
|
+
*
|
|
269
|
+
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
270
|
+
* such as online store products or real estate offers.
|
|
271
|
+
* The actual data is stored either on the local filesystem or in the cloud.
|
|
272
|
+
*
|
|
273
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
274
|
+
*
|
|
275
|
+
* @param [datasetIdOrName]
|
|
276
|
+
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
277
|
+
* the function returns the default dataset associated with the actor run.
|
|
278
|
+
* @param [options] Storage manager options.
|
|
279
|
+
* @deprecated use `Dataset.open()` instead
|
|
280
|
+
*/
|
|
281
|
+
export declare function openDataset<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: StorageManagerOptions): Promise<Dataset<Data>>;
|
|
282
|
+
/**
|
|
283
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current actor run.
|
|
284
|
+
*
|
|
285
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
286
|
+
* For example, calling the following code:
|
|
287
|
+
* ```javascript
|
|
288
|
+
* await Actor.pushData({ myValue: 123 });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* is equivalent to:
|
|
292
|
+
* ```javascript
|
|
293
|
+
* const dataset = await Dataset.open();
|
|
294
|
+
* await dataset.pushData({ myValue: 123 });
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* For more information, see {@link Dataset.open} and {@link Dataset.pushData}
|
|
298
|
+
*
|
|
299
|
+
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
300
|
+
* otherwise the actor process might finish before the data are stored!
|
|
301
|
+
*
|
|
302
|
+
* @param {object} item Object or array of objects containing data to be stored in the default dataset.
|
|
303
|
+
* The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
|
|
304
|
+
* @param [options] Storage manager options.
|
|
305
|
+
*/
|
|
306
|
+
export declare function pushData(item: Dictionary | Dictionary[], options?: StorageManagerOptions): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* User-function used in the `Dataset.forEach()` API.
|
|
309
|
+
*/
|
|
310
|
+
export interface DatasetConsumer<Data> {
|
|
311
|
+
/**
|
|
312
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
313
|
+
* @param index Position of current {Dataset} entry.
|
|
314
|
+
*/
|
|
315
|
+
(item: Data, index: number): Awaitable<void>;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* User-function used in the `Dataset.map()` API.
|
|
319
|
+
*/
|
|
320
|
+
export interface DatasetMapper<Data, R> {
|
|
321
|
+
/**
|
|
322
|
+
* User-function used in the `Dataset.map()` API.
|
|
323
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
324
|
+
* @param index Position of current {Dataset} entry.
|
|
325
|
+
*/
|
|
326
|
+
(item: Data, index: number): Awaitable<R>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* User-function used in the `Dataset.reduce()` API.
|
|
330
|
+
*/
|
|
331
|
+
export interface DatasetReducer<T, Data> {
|
|
332
|
+
/**
|
|
333
|
+
* @param memo Previous state of the reduction.
|
|
334
|
+
* @param item Current {@link Dataset} entry being processed.
|
|
335
|
+
* @param index Position of current {Dataset} entry.
|
|
336
|
+
*/
|
|
337
|
+
(memo: T, item: Data, index: number): Awaitable<T>;
|
|
338
|
+
}
|
|
339
|
+
export interface DatasetOptions {
|
|
340
|
+
id: string;
|
|
341
|
+
name?: string;
|
|
342
|
+
client: StorageClient;
|
|
343
|
+
}
|
|
344
|
+
export interface DatasetContent<Data> {
|
|
345
|
+
/** Total count of entries in the dataset. */
|
|
346
|
+
total: number;
|
|
347
|
+
/** Count of dataset entries returned in this set. */
|
|
348
|
+
count: number;
|
|
349
|
+
/** Position of the first returned entry in the dataset. */
|
|
350
|
+
offset: number;
|
|
351
|
+
/** Maximum number of dataset entries requested. */
|
|
352
|
+
limit: number;
|
|
353
|
+
/** Should the results be in descending order. */
|
|
354
|
+
desc: boolean;
|
|
355
|
+
/** Dataset entries based on chosen format parameter. */
|
|
356
|
+
items: Data[];
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=dataset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset.d.ts","sourceRoot":"","sources":["../../src/storages/dataset.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAkB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAErF,gBAAgB;AAChB,eAAO,MAAM,+BAA+B,QAAQ,CAAC;AAIrD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBxF;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MA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