@crawlee/core 4.0.0-beta.211 → 4.0.0-beta.212
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/configuration.d.ts +0 -19
- package/configuration.js +8 -8
- package/events/local_event_manager.d.ts +0 -7
- package/events/local_event_manager.js +8 -8
- package/memory-storage/resource-clients/dataset.d.ts +0 -5
- package/memory-storage/resource-clients/dataset.js +15 -16
- package/memory-storage/resource-clients/key-value-store.d.ts +0 -2
- package/memory-storage/resource-clients/key-value-store.js +10 -11
- package/memory-storage/resource-clients/request-queue.d.ts +0 -22
- package/memory-storage/resource-clients/request-queue.js +33 -34
- package/package.json +6 -6
- package/proxy_configuration.d.ts +0 -7
- package/proxy_configuration.js +8 -8
- package/storages/dataset.d.ts +0 -10
- package/storages/dataset.js +13 -13
- package/storages/key_value_store.d.ts +0 -18
- package/storages/key_value_store.js +16 -16
- package/storages/request_dedup_cache.d.ts +0 -2
- package/storages/request_dedup_cache.js +8 -8
- package/storages/request_list.d.ts +0 -57
- package/storages/request_list.js +38 -38
- package/storages/request_manager_tandem.d.ts +0 -12
- package/storages/request_manager_tandem.js +15 -15
- package/storages/request_queue.d.ts +0 -32
- package/storages/request_queue.js +29 -29
- package/storages/storage_instance_manager.js +4 -4
- package/storages/transaction.d.ts +0 -1
- package/storages/transaction.js +2 -2
package/proxy_configuration.js
CHANGED
|
@@ -71,9 +71,9 @@ export class ProxyConfiguration {
|
|
|
71
71
|
}
|
|
72
72
|
const { proxyUrls, newUrlFunction } = parseArgument(rest, proxyConfigurationOptionsSchema);
|
|
73
73
|
if (proxyUrls && newUrlFunction)
|
|
74
|
-
this
|
|
74
|
+
this.#throwCannotCombineCustomMethods();
|
|
75
75
|
if (!proxyUrls && !newUrlFunction && validateRequired)
|
|
76
|
-
this
|
|
76
|
+
this.#throwNoOptionsProvided();
|
|
77
77
|
this.#proxyUrls = proxyUrls;
|
|
78
78
|
this.#newUrlFunction = newUrlFunction;
|
|
79
79
|
}
|
|
@@ -107,17 +107,17 @@ export class ProxyConfiguration {
|
|
|
107
107
|
*/
|
|
108
108
|
async newUrl() {
|
|
109
109
|
if (this.#newUrlFunction) {
|
|
110
|
-
return (await this
|
|
110
|
+
return (await this.#callNewUrlFunction()) ?? undefined;
|
|
111
111
|
}
|
|
112
|
-
return this
|
|
112
|
+
return this.#handleProxyUrlsList() ?? undefined;
|
|
113
113
|
}
|
|
114
|
-
handleProxyUrlsList() {
|
|
114
|
+
#handleProxyUrlsList() {
|
|
115
115
|
return this.#proxyUrls[this.#nextCustomUrlIndex++ % this.#proxyUrls.length];
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Calls the custom newUrlFunction and checks format of its return value
|
|
119
119
|
*/
|
|
120
|
-
async callNewUrlFunction() {
|
|
120
|
+
async #callNewUrlFunction() {
|
|
121
121
|
const proxyUrl = await this.#newUrlFunction();
|
|
122
122
|
try {
|
|
123
123
|
if (proxyUrl) {
|
|
@@ -129,10 +129,10 @@ export class ProxyConfiguration {
|
|
|
129
129
|
throw new Error(`The provided newUrlFunction did not return a valid URL.\nCause: ${err.message}`);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
throwCannotCombineCustomMethods() {
|
|
132
|
+
#throwCannotCombineCustomMethods() {
|
|
133
133
|
throw new Error('Cannot combine custom proxies "options.proxyUrls" with custom generating function "options.newUrlFunction".');
|
|
134
134
|
}
|
|
135
|
-
throwNoOptionsProvided() {
|
|
135
|
+
#throwNoOptionsProvided() {
|
|
136
136
|
throw new Error('One of "options.proxyUrls" or "options.newUrlFunction" needs to be provided.');
|
|
137
137
|
}
|
|
138
138
|
}
|
package/storages/dataset.d.ts
CHANGED
|
@@ -169,14 +169,6 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
169
169
|
* Returns {@link DatasetContent} object holding the items in the dataset based on the provided parameters.
|
|
170
170
|
*/
|
|
171
171
|
getData(options?: DatasetDataOptions): Promise<DatasetContent<Data>>;
|
|
172
|
-
/**
|
|
173
|
-
* The single transaction-aware page read all dataset read paths go through — both `getData()` and
|
|
174
|
-
* the private `fetchPages()`. Returns the real page concatenated with the current transaction's
|
|
175
|
-
* buffered items, with `offset` / `limit` / `desc` windowing applied across the concatenation.
|
|
176
|
-
*/
|
|
177
|
-
private readPage;
|
|
178
|
-
/** The active transaction's buffered writes to this dataset, derived from its journal. */
|
|
179
|
-
private bufferedJournalEntries;
|
|
180
172
|
/** @internal */
|
|
181
173
|
commitJournalEntries(entries: JournalEntry[]): Promise<void>;
|
|
182
174
|
/**
|
|
@@ -321,8 +313,6 @@ export declare class Dataset<Data extends Dictionary = Dictionary> {
|
|
|
321
313
|
* @param [options] An object containing extra options for `reduce()`
|
|
322
314
|
*/
|
|
323
315
|
reduce<T>(iteratee: DatasetReducer<T, Data>, memo: T, options?: DatasetIteratorOptions): Promise<T>;
|
|
324
|
-
private fetchEntryPages;
|
|
325
|
-
private fetchPages;
|
|
326
316
|
/**
|
|
327
317
|
* Returns dataset items.
|
|
328
318
|
*
|
package/storages/dataset.js
CHANGED
|
@@ -91,7 +91,7 @@ export class Dataset {
|
|
|
91
91
|
configuration;
|
|
92
92
|
id;
|
|
93
93
|
name;
|
|
94
|
-
//
|
|
94
|
+
// oxlint-disable-next-line crawlee/prefer-private-fields -- tests spy on the backend directly
|
|
95
95
|
backend;
|
|
96
96
|
#statsTracker = new StorageStatsTracker({
|
|
97
97
|
readCount: 0,
|
|
@@ -152,7 +152,7 @@ export class Dataset {
|
|
|
152
152
|
*/
|
|
153
153
|
async getData(options = {}) {
|
|
154
154
|
try {
|
|
155
|
-
return await this
|
|
155
|
+
return await this.#readPage(options);
|
|
156
156
|
}
|
|
157
157
|
catch (e) {
|
|
158
158
|
const error = e;
|
|
@@ -167,8 +167,8 @@ export class Dataset {
|
|
|
167
167
|
* the private `fetchPages()`. Returns the real page concatenated with the current transaction's
|
|
168
168
|
* buffered items, with `offset` / `limit` / `desc` windowing applied across the concatenation.
|
|
169
169
|
*/
|
|
170
|
-
async readPage(options) {
|
|
171
|
-
const buffered = this
|
|
170
|
+
async #readPage(options) {
|
|
171
|
+
const buffered = this.#bufferedJournalEntries()?.flatMap((entry) => entry.items);
|
|
172
172
|
// Every branch below hits the backend exactly once.
|
|
173
173
|
this.#statsTracker.add('readCount');
|
|
174
174
|
if (!buffered?.length) {
|
|
@@ -224,7 +224,7 @@ export class Dataset {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
/** The active transaction's buffered writes to this dataset, derived from its journal. */
|
|
227
|
-
bufferedJournalEntries() {
|
|
227
|
+
#bufferedJournalEntries() {
|
|
228
228
|
const transaction = activeStorageTransaction();
|
|
229
229
|
return transaction?.journal.filter((entry) => entry.type === 'dataset' && entry.participant === this);
|
|
230
230
|
}
|
|
@@ -250,7 +250,7 @@ export class Dataset {
|
|
|
250
250
|
async export(options = {}) {
|
|
251
251
|
tryCancel();
|
|
252
252
|
const items = [];
|
|
253
|
-
for await (const page of this
|
|
253
|
+
for await (const page of this.#fetchPages(options)) {
|
|
254
254
|
items.push(...page.items);
|
|
255
255
|
}
|
|
256
256
|
return items;
|
|
@@ -348,7 +348,7 @@ export class Dataset {
|
|
|
348
348
|
* @throws If the underlying storage no longer exists (e.g. it was deleted externally).
|
|
349
349
|
*/
|
|
350
350
|
async getInfo() {
|
|
351
|
-
const buffered = this
|
|
351
|
+
const buffered = this.#bufferedJournalEntries();
|
|
352
352
|
const metadata = await this.backend.getMetadata();
|
|
353
353
|
if (buffered?.length) {
|
|
354
354
|
const lastWriteAt = buffered[buffered.length - 1].recordedAt;
|
|
@@ -432,16 +432,16 @@ export class Dataset {
|
|
|
432
432
|
await this.forEach(wrappedFunc, options);
|
|
433
433
|
return currentMemo;
|
|
434
434
|
}
|
|
435
|
-
async
|
|
435
|
+
async *#fetchEntryPages(options) {
|
|
436
436
|
let index = options.offset ?? 0;
|
|
437
|
-
for await (const page of this
|
|
437
|
+
for await (const page of this.#fetchPages(options)) {
|
|
438
438
|
yield {
|
|
439
439
|
...page,
|
|
440
440
|
items: page.items.map((item) => [index++, item]),
|
|
441
441
|
};
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
async
|
|
444
|
+
async *#fetchPages(options, pageSize = DATASET_ITERATORS_DEFAULT_LIMIT) {
|
|
445
445
|
let offset = options.offset ?? 0;
|
|
446
446
|
const totalLimit = options.limit;
|
|
447
447
|
let yielded = 0;
|
|
@@ -449,7 +449,7 @@ export class Dataset {
|
|
|
449
449
|
const fetchLimit = totalLimit !== undefined ? Math.min(pageSize, totalLimit - yielded) : pageSize;
|
|
450
450
|
if (fetchLimit <= 0)
|
|
451
451
|
break;
|
|
452
|
-
const page = await this
|
|
452
|
+
const page = await this.#readPage({ ...options, offset, limit: fetchLimit });
|
|
453
453
|
yield page;
|
|
454
454
|
yielded += page.items.length;
|
|
455
455
|
if (page.items.length < fetchLimit || offset + page.items.length >= page.total)
|
|
@@ -483,7 +483,7 @@ export class Dataset {
|
|
|
483
483
|
values(options = {}) {
|
|
484
484
|
tryCancel();
|
|
485
485
|
return createDualIterable({
|
|
486
|
-
createPages: () => this
|
|
486
|
+
createPages: () => this.#fetchPages(options),
|
|
487
487
|
extractItems: (page) => page.items,
|
|
488
488
|
});
|
|
489
489
|
}
|
|
@@ -513,7 +513,7 @@ export class Dataset {
|
|
|
513
513
|
entries(options = {}) {
|
|
514
514
|
tryCancel();
|
|
515
515
|
return createDualIterable({
|
|
516
|
-
createPages: () => this
|
|
516
|
+
createPages: () => this.#fetchEntryPages(options),
|
|
517
517
|
extractItems: (page) => page.items,
|
|
518
518
|
});
|
|
519
519
|
}
|
|
@@ -136,21 +136,6 @@ export declare class KeyValueStore {
|
|
|
136
136
|
* on the MIME content type of the record, or the default value if the key is missing from the store.
|
|
137
137
|
*/
|
|
138
138
|
getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
139
|
-
/**
|
|
140
|
-
* The active transaction's last buffered write per key for this store, derived from its journal.
|
|
141
|
-
* An entry with a `null` value is a tombstone (an in-transaction deletion).
|
|
142
|
-
*/
|
|
143
|
-
private bufferedJournalEntries;
|
|
144
|
-
/**
|
|
145
|
-
* The single transaction-aware record read shared by `getValue`, `getRecord`, `recordExists` and the
|
|
146
|
-
* listing paths: buffered key → serialized through the standard codec (same fidelity as a real
|
|
147
|
-
* round-trip); tombstoned key → `null`; otherwise the backend.
|
|
148
|
-
*
|
|
149
|
-
* The per-key buffered lookup requires the whole journal to be reduced to a last-write-per-key map,
|
|
150
|
-
* which is O(journal). Single-record callers let it default (rebuilt per call); the listing paths,
|
|
151
|
-
* which read many keys, pass a map built once so the read stays O(1) per key instead of O(journal).
|
|
152
|
-
*/
|
|
153
|
-
private readRecord;
|
|
154
139
|
/**
|
|
155
140
|
* Reads a record from the key-value store without parsing the value.
|
|
156
141
|
*
|
|
@@ -186,9 +171,6 @@ export declare class KeyValueStore {
|
|
|
186
171
|
*/
|
|
187
172
|
recordExists(key: string): Promise<boolean>;
|
|
188
173
|
getAutoSavedValue<T extends Dictionary = Dictionary>(key: string, defaultValue?: T): Promise<T>;
|
|
189
|
-
private ensurePersistStateEvent;
|
|
190
|
-
private fetchKeyValuePages;
|
|
191
|
-
private fetchKeyPages;
|
|
192
174
|
/**
|
|
193
175
|
* Saves or deletes a record in the key-value store.
|
|
194
176
|
* The function returns a promise that resolves once the record has been saved or deleted.
|
|
@@ -144,7 +144,7 @@ export class KeyValueStore {
|
|
|
144
144
|
async getValue(key, defaultValue) {
|
|
145
145
|
tryCancel();
|
|
146
146
|
parseArgument(key, keySchema);
|
|
147
|
-
const record = await this
|
|
147
|
+
const record = await this.#readRecord(key);
|
|
148
148
|
// A missing record falls back to the default; a record that parses to a falsy value (including
|
|
149
149
|
// a stored literal `null`) is returned verbatim, so callers can tell "stored null" from "absent".
|
|
150
150
|
if (!record) {
|
|
@@ -157,7 +157,7 @@ export class KeyValueStore {
|
|
|
157
157
|
* The active transaction's last buffered write per key for this store, derived from its journal.
|
|
158
158
|
* An entry with a `null` value is a tombstone (an in-transaction deletion).
|
|
159
159
|
*/
|
|
160
|
-
bufferedJournalEntries() {
|
|
160
|
+
#bufferedJournalEntries() {
|
|
161
161
|
const transaction = activeStorageTransaction();
|
|
162
162
|
if (!transaction)
|
|
163
163
|
return undefined;
|
|
@@ -178,7 +178,7 @@ export class KeyValueStore {
|
|
|
178
178
|
* which is O(journal). Single-record callers let it default (rebuilt per call); the listing paths,
|
|
179
179
|
* which read many keys, pass a map built once so the read stays O(1) per key instead of O(journal).
|
|
180
180
|
*/
|
|
181
|
-
async readRecord(key, buffered = this
|
|
181
|
+
async #readRecord(key, buffered = this.#bufferedJournalEntries()) {
|
|
182
182
|
const entry = buffered?.get(key);
|
|
183
183
|
if (entry) {
|
|
184
184
|
if (entry.value === null) {
|
|
@@ -228,7 +228,7 @@ export class KeyValueStore {
|
|
|
228
228
|
async getRecord(key) {
|
|
229
229
|
tryCancel();
|
|
230
230
|
parseArgument(key, keySchema);
|
|
231
|
-
return this
|
|
231
|
+
return this.#readRecord(key);
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
234
|
* Tests whether a record with the given key exists in the key-value store without retrieving its value.
|
|
@@ -239,7 +239,7 @@ export class KeyValueStore {
|
|
|
239
239
|
async recordExists(key) {
|
|
240
240
|
tryCancel();
|
|
241
241
|
parseArgument(key, keySchema);
|
|
242
|
-
const entry = this
|
|
242
|
+
const entry = this.#bufferedJournalEntries()?.get(key);
|
|
243
243
|
if (entry) {
|
|
244
244
|
return entry.value !== null;
|
|
245
245
|
}
|
|
@@ -261,10 +261,10 @@ export class KeyValueStore {
|
|
|
261
261
|
return this.#cache.get(key);
|
|
262
262
|
}
|
|
263
263
|
this.#cache.set(key, value);
|
|
264
|
-
this
|
|
264
|
+
this.#ensurePersistStateEvent();
|
|
265
265
|
return value;
|
|
266
266
|
}
|
|
267
|
-
ensurePersistStateEvent() {
|
|
267
|
+
#ensurePersistStateEvent() {
|
|
268
268
|
if (this.#persistStateEventStarted) {
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
@@ -277,15 +277,15 @@ export class KeyValueStore {
|
|
|
277
277
|
});
|
|
278
278
|
this.#persistStateEventStarted = true;
|
|
279
279
|
}
|
|
280
|
-
async
|
|
280
|
+
async *#fetchKeyValuePages(options, mapRecord) {
|
|
281
281
|
// Reduce the journal once for the whole iteration, not once per key inside `readRecord`.
|
|
282
|
-
const buffered = this
|
|
283
|
-
for await (const page of this
|
|
282
|
+
const buffered = this.#bufferedJournalEntries();
|
|
283
|
+
for await (const page of this.#fetchKeyPages(options, buffered)) {
|
|
284
284
|
const results = [];
|
|
285
285
|
for (const item of page) {
|
|
286
286
|
// The shared transaction-aware read, so a key that exists only in the transaction resolves
|
|
287
287
|
// here instead of being dropped (`values()` would disagree with `keys()` on length).
|
|
288
|
-
const record = await this
|
|
288
|
+
const record = await this.#readRecord(item.key, buffered);
|
|
289
289
|
if (record) {
|
|
290
290
|
const parsed = parseValue(record.value, record.contentType ?? null);
|
|
291
291
|
results.push(mapRecord(item.key, parsed));
|
|
@@ -294,7 +294,7 @@ export class KeyValueStore {
|
|
|
294
294
|
yield results;
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
async
|
|
297
|
+
async *#fetchKeyPages(options, buffered = this.#bufferedJournalEntries(), limit = KVS_KEYS_DEFAULT_LIMIT) {
|
|
298
298
|
// Buffered keys are emitted first, then the real pages with any buffered (or tombstoned) key
|
|
299
299
|
// skipped - a merge-join is not an option, since `listKeys` promises no sort order.
|
|
300
300
|
const shadowedKeys = new Set();
|
|
@@ -497,7 +497,7 @@ export class KeyValueStore {
|
|
|
497
497
|
parseArgument(iteratee, schemas.anyFunction);
|
|
498
498
|
const parsedOptions = parseArgument(options, iteratorOptionsSchema);
|
|
499
499
|
let index = 0;
|
|
500
|
-
for await (const page of this
|
|
500
|
+
for await (const page of this.#fetchKeyPages(parsedOptions)) {
|
|
501
501
|
for (const item of page) {
|
|
502
502
|
await iteratee(item.key, index++, { size: item.size });
|
|
503
503
|
}
|
|
@@ -529,7 +529,7 @@ export class KeyValueStore {
|
|
|
529
529
|
keys(options = {}) {
|
|
530
530
|
tryCancel();
|
|
531
531
|
return createDualIterable({
|
|
532
|
-
createPages: () => this
|
|
532
|
+
createPages: () => this.#fetchKeyPages(options),
|
|
533
533
|
extractItems: (page) => page.map((item) => item.key),
|
|
534
534
|
});
|
|
535
535
|
}
|
|
@@ -559,7 +559,7 @@ export class KeyValueStore {
|
|
|
559
559
|
values(options = {}) {
|
|
560
560
|
tryCancel();
|
|
561
561
|
return createDualIterable({
|
|
562
|
-
createPages: () => this
|
|
562
|
+
createPages: () => this.#fetchKeyValuePages(options, (_key, value) => value),
|
|
563
563
|
extractItems: (page) => page,
|
|
564
564
|
});
|
|
565
565
|
}
|
|
@@ -589,7 +589,7 @@ export class KeyValueStore {
|
|
|
589
589
|
entries(options = {}) {
|
|
590
590
|
tryCancel();
|
|
591
591
|
return createDualIterable({
|
|
592
|
-
createPages: () => this
|
|
592
|
+
createPages: () => this.#fetchKeyValuePages(options, (key, value) => [key, value]),
|
|
593
593
|
extractItems: (page) => page,
|
|
594
594
|
});
|
|
595
595
|
}
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class RequestDeduplicationCache {
|
|
15
15
|
#private;
|
|
16
|
-
private readonly size;
|
|
17
16
|
constructor(size?: number);
|
|
18
17
|
get(cacheKey: string): string | null;
|
|
19
18
|
add(cacheKey: string, requestId: string): void;
|
|
20
19
|
clear(): void;
|
|
21
|
-
private indexOf;
|
|
22
20
|
}
|
|
@@ -12,37 +12,37 @@
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export class RequestDeduplicationCache {
|
|
15
|
-
size;
|
|
16
15
|
#keys;
|
|
17
16
|
#ids;
|
|
17
|
+
#size;
|
|
18
18
|
// The slot count is the same for every queue, so it's a fixed default rather than a per-consumer option.
|
|
19
19
|
constructor(size = 1_000_000) {
|
|
20
|
-
this
|
|
20
|
+
this.#size = size;
|
|
21
21
|
this.#keys = new Array(size);
|
|
22
22
|
this.#ids = new Array(size);
|
|
23
23
|
}
|
|
24
24
|
get(cacheKey) {
|
|
25
|
-
const index = this
|
|
25
|
+
const index = this.#indexOf(cacheKey);
|
|
26
26
|
return this.#keys[index] === cacheKey ? this.#ids[index] : null;
|
|
27
27
|
}
|
|
28
28
|
add(cacheKey, requestId) {
|
|
29
|
-
const index = this
|
|
29
|
+
const index = this.#indexOf(cacheKey);
|
|
30
30
|
this.#keys[index] = cacheKey;
|
|
31
31
|
this.#ids[index] = requestId;
|
|
32
32
|
}
|
|
33
33
|
clear() {
|
|
34
|
-
this.#keys = new Array(this
|
|
35
|
-
this.#ids = new Array(this
|
|
34
|
+
this.#keys = new Array(this.#size);
|
|
35
|
+
this.#ids = new Array(this.#size);
|
|
36
36
|
}
|
|
37
37
|
// A cheap FNV-1a hash of the cache key — avoids pulling in a dedicated hashing dependency.
|
|
38
|
-
indexOf(cacheKey) {
|
|
38
|
+
#indexOf(cacheKey) {
|
|
39
39
|
/* eslint-disable no-bitwise */
|
|
40
40
|
let hash = 0x811c9dc5;
|
|
41
41
|
for (let i = 0; i < cacheKey.length; i++) {
|
|
42
42
|
hash ^= cacheKey.charCodeAt(i);
|
|
43
43
|
hash = Math.imul(hash, 0x01000193);
|
|
44
44
|
}
|
|
45
|
-
return (hash >>> 0) % this
|
|
45
|
+
return (hash >>> 0) % this.#size;
|
|
46
46
|
/* eslint-enable no-bitwise */
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -241,24 +241,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
241
241
|
* @internal
|
|
242
242
|
*/
|
|
243
243
|
private constructor();
|
|
244
|
-
/**
|
|
245
|
-
* Loads all remote sources of URLs and potentially starts periodic state persistence.
|
|
246
|
-
* This function must be called before you can start using the instance in a meaningful way.
|
|
247
|
-
*/
|
|
248
|
-
private initialize;
|
|
249
|
-
/**
|
|
250
|
-
* Adds previously persisted Requests, as retrieved from the key-value store.
|
|
251
|
-
* This needs to be done in a memory efficient way. We should update the input
|
|
252
|
-
* to a Stream once apify-client supports streams.
|
|
253
|
-
*/
|
|
254
|
-
private addPersistedRequests;
|
|
255
|
-
/**
|
|
256
|
-
* Add Requests from both options.sources and options.sourcesFunction.
|
|
257
|
-
* This function is called only when persisted sources were not loaded.
|
|
258
|
-
* We need to avoid keeping both sources and requests in memory
|
|
259
|
-
* to reduce memory footprint with very large sources.
|
|
260
|
-
*/
|
|
261
|
-
private addRequestsFromSources;
|
|
262
244
|
/**
|
|
263
245
|
* @inheritDoc
|
|
264
246
|
*/
|
|
@@ -269,12 +251,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
269
251
|
* leaking the listener (and the requests it retains) on the shared event manager.
|
|
270
252
|
*/
|
|
271
253
|
teardown(): Promise<void>;
|
|
272
|
-
/**
|
|
273
|
-
* Unlike persistState(), this is used only internally, since the sources
|
|
274
|
-
* are automatically persisted at RequestList initialization (if the persistRequestsKey is set),
|
|
275
|
-
* but there's no reason to persist it again afterwards, because RequestList is immutable.
|
|
276
|
-
*/
|
|
277
|
-
private persistRequests;
|
|
278
254
|
/**
|
|
279
255
|
* Returns an object representing the internal state of the `RequestList` instance.
|
|
280
256
|
* Note that the object's fields can change in future releases.
|
|
@@ -292,39 +268,10 @@ export declare class RequestList implements IRequestLoader {
|
|
|
292
268
|
* @inheritDoc
|
|
293
269
|
*/
|
|
294
270
|
[Symbol.asyncIterator](): AsyncGenerator<Request<Dictionary>, void, unknown>;
|
|
295
|
-
private ensureRequest;
|
|
296
271
|
/**
|
|
297
272
|
* @inheritDoc
|
|
298
273
|
*/
|
|
299
274
|
markRequestAsHandled(request: Request): Promise<void>;
|
|
300
|
-
/**
|
|
301
|
-
* Adds all fetched requests from a URL from a remote resource.
|
|
302
|
-
*/
|
|
303
|
-
private addFetchedRequests;
|
|
304
|
-
private getPersistedState;
|
|
305
|
-
/**
|
|
306
|
-
* Fetches URLs from requestsFromUrl and returns them in format of list of requests
|
|
307
|
-
*/
|
|
308
|
-
private fetchRequestsFromUrl;
|
|
309
|
-
/**
|
|
310
|
-
* Adds given request.
|
|
311
|
-
* If the `source` parameter is a string or plain object and not an instance
|
|
312
|
-
* of a `Request`, then the function creates a `Request` instance.
|
|
313
|
-
*/
|
|
314
|
-
private addRequest;
|
|
315
|
-
/**
|
|
316
|
-
* Helper function that validates unique key.
|
|
317
|
-
* Throws an error if uniqueKey is not a non-empty string.
|
|
318
|
-
*/
|
|
319
|
-
private ensureUniqueKeyValid;
|
|
320
|
-
/**
|
|
321
|
-
* Checks that a request is currently being processed and throws an error if not.
|
|
322
|
-
*/
|
|
323
|
-
private ensureInProgress;
|
|
324
|
-
/**
|
|
325
|
-
* Throws an error if request list wasn't initialized.
|
|
326
|
-
*/
|
|
327
|
-
private ensureIsInitialized;
|
|
328
275
|
/**
|
|
329
276
|
* Returns the total number of unique requests present in the `RequestList`.
|
|
330
277
|
*/
|
|
@@ -397,10 +344,6 @@ export declare class RequestList implements IRequestLoader {
|
|
|
397
344
|
* options and the `sources` parameter supersedes the {@link RequestListOptions.sources} option.
|
|
398
345
|
*/
|
|
399
346
|
static open(listNameOrOptions: string | null | RequestListOptions, sources?: RequestListSource[], options?: RequestListOptions): Promise<RequestList>;
|
|
400
|
-
/**
|
|
401
|
-
* @internal wraps public utility for mocking purposes
|
|
402
|
-
*/
|
|
403
|
-
private downloadListOfUrls;
|
|
404
347
|
}
|
|
405
348
|
/**
|
|
406
349
|
* Represents state of a {@link RequestList}. It can be used to resume a {@link RequestList} which has been previously processed.
|