@crawlee/core 3.5.5-beta.8 → 3.5.5

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.
@@ -0,0 +1,602 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestProvider = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const datastructures_1 = require("@apify/datastructures");
6
+ const utilities_1 = require("@apify/utilities");
7
+ const utils_1 = require("@crawlee/utils");
8
+ const ow_1 = tslib_1.__importDefault(require("ow"));
9
+ const storage_manager_1 = require("./storage_manager");
10
+ const utils_2 = require("./utils");
11
+ const configuration_1 = require("../configuration");
12
+ const log_1 = require("../log");
13
+ const request_1 = require("../request");
14
+ class RequestProvider {
15
+ constructor(options, config = configuration_1.Configuration.getGlobalConfig()) {
16
+ Object.defineProperty(this, "config", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: config
21
+ });
22
+ Object.defineProperty(this, "id", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ Object.defineProperty(this, "name", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "timeoutSecs", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: 30
39
+ });
40
+ Object.defineProperty(this, "clientKey", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: (0, utilities_1.cryptoRandomObjectId)()
45
+ });
46
+ Object.defineProperty(this, "client", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "proxyConfiguration", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "log", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "internalTimeoutMillis", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: 5 * 60000
69
+ }); // defaults to 5 minutes, will be overridden by BasicCrawler
70
+ Object.defineProperty(this, "requestLockSecs", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: 3 * 60
75
+ }); // defaults to 3 minutes, will be overridden by BasicCrawler
76
+ // We can trust these numbers only in a case that queue is used by a single client.
77
+ // This information is returned by getHead() under the hadMultipleClients property.
78
+ Object.defineProperty(this, "assumedTotalCount", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: 0
83
+ });
84
+ Object.defineProperty(this, "assumedHandledCount", {
85
+ enumerable: true,
86
+ configurable: true,
87
+ writable: true,
88
+ value: 0
89
+ });
90
+ Object.defineProperty(this, "queueHeadIds", {
91
+ enumerable: true,
92
+ configurable: true,
93
+ writable: true,
94
+ value: new datastructures_1.ListDictionary()
95
+ });
96
+ Object.defineProperty(this, "requestCache", {
97
+ enumerable: true,
98
+ configurable: true,
99
+ writable: true,
100
+ value: void 0
101
+ });
102
+ /** @internal */
103
+ Object.defineProperty(this, "inProgress", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: new Set()
108
+ });
109
+ Object.defineProperty(this, "recentlyHandledRequestsCache", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: void 0
114
+ });
115
+ Object.defineProperty(this, "queuePausedForMigration", {
116
+ enumerable: true,
117
+ configurable: true,
118
+ writable: true,
119
+ value: false
120
+ });
121
+ this.id = options.id;
122
+ this.name = options.name;
123
+ this.client = options.client.requestQueue(this.id, {
124
+ clientKey: this.clientKey,
125
+ timeoutSecs: this.timeoutSecs,
126
+ });
127
+ this.proxyConfiguration = options.proxyConfiguration;
128
+ this.requestCache = new datastructures_1.LruCache({ maxLength: options.requestCacheMaxSize });
129
+ this.recentlyHandledRequestsCache = new datastructures_1.LruCache({ maxLength: options.recentlyHandledRequestsMaxSize });
130
+ this.log = log_1.log.child({ prefix: options.logPrefix });
131
+ const eventManager = config.getEventManager();
132
+ eventManager.on("migrating" /* EventType.MIGRATING */, async () => {
133
+ this.queuePausedForMigration = true;
134
+ });
135
+ }
136
+ /**
137
+ * @ignore
138
+ */
139
+ inProgressCount() {
140
+ return this.inProgress.size;
141
+ }
142
+ /**
143
+ * Adds a request to the queue.
144
+ *
145
+ * If a request with the same `uniqueKey` property is already present in the queue,
146
+ * it will not be updated. You can find out whether this happened from the resulting
147
+ * {@apilink QueueOperationInfo} object.
148
+ *
149
+ * To add multiple requests to the queue by extracting links from a webpage,
150
+ * see the {@apilink enqueueLinks} helper function.
151
+ *
152
+ * @param requestLike {@apilink Request} object or vanilla object with request data.
153
+ * Note that the function sets the `uniqueKey` and `id` fields to the passed Request.
154
+ * @param [options] Request queue operation options.
155
+ */
156
+ async addRequest(requestLike, options = {}) {
157
+ (0, ow_1.default)(requestLike, ow_1.default.object);
158
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
159
+ forefront: ow_1.default.optional.boolean,
160
+ }));
161
+ const { forefront = false } = options;
162
+ if ('requestsFromUrl' in requestLike) {
163
+ const requests = await this._fetchRequestsFromUrl(requestLike);
164
+ const processedRequests = await this._addFetchedRequests(requestLike, requests, options);
165
+ return processedRequests[0];
166
+ }
167
+ (0, ow_1.default)(requestLike, ow_1.default.object.partialShape({
168
+ url: ow_1.default.string,
169
+ id: ow_1.default.undefined,
170
+ }));
171
+ const request = requestLike instanceof request_1.Request
172
+ ? requestLike
173
+ : new request_1.Request(requestLike);
174
+ const cacheKey = (0, utils_2.getRequestId)(request.uniqueKey);
175
+ const cachedInfo = this.requestCache.get(cacheKey);
176
+ if (cachedInfo) {
177
+ request.id = cachedInfo.id;
178
+ return {
179
+ wasAlreadyPresent: true,
180
+ // We may assume that if request is in local cache then also the information if the
181
+ // request was already handled is there because just one client should be using one queue.
182
+ wasAlreadyHandled: cachedInfo.isHandled,
183
+ requestId: cachedInfo.id,
184
+ uniqueKey: cachedInfo.uniqueKey,
185
+ };
186
+ }
187
+ const queueOperationInfo = await this.client.addRequest(request, { forefront });
188
+ queueOperationInfo.uniqueKey = request.uniqueKey;
189
+ const { requestId, wasAlreadyPresent } = queueOperationInfo;
190
+ this._cacheRequest(cacheKey, queueOperationInfo);
191
+ if (!wasAlreadyPresent && !this.inProgress.has(requestId) && !this.recentlyHandledRequestsCache.get(requestId)) {
192
+ this.assumedTotalCount++;
193
+ // Performance optimization: add request straight to head if possible
194
+ this._maybeAddRequestToQueueHead(requestId, forefront);
195
+ }
196
+ return queueOperationInfo;
197
+ }
198
+ /**
199
+ * Adds requests to the queue in batches of 25.
200
+ *
201
+ * If a request that is passed in is already present due to its `uniqueKey` property being the same,
202
+ * it will not be updated. You can find out whether this happened by finding the request in the resulting
203
+ * {@apilink BatchAddRequestsResult} object.
204
+ *
205
+ * @param requestsLike {@apilink Request} objects or vanilla objects with request data.
206
+ * Note that the function sets the `uniqueKey` and `id` fields to the passed requests if missing.
207
+ * @param [options] Request queue operation options.
208
+ */
209
+ async addRequests(requestsLike, options = {}) {
210
+ (0, ow_1.default)(requestsLike, ow_1.default.array);
211
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
212
+ forefront: ow_1.default.optional.boolean,
213
+ }));
214
+ const { forefront = false } = options;
215
+ const uniqueKeyToCacheKey = new Map();
216
+ const getCachedRequestId = (uniqueKey) => {
217
+ const cached = uniqueKeyToCacheKey.get(uniqueKey);
218
+ if (cached)
219
+ return cached;
220
+ const newCacheKey = (0, utils_2.getRequestId)(uniqueKey);
221
+ uniqueKeyToCacheKey.set(uniqueKey, newCacheKey);
222
+ return newCacheKey;
223
+ };
224
+ const results = {
225
+ processedRequests: [],
226
+ unprocessedRequests: [],
227
+ };
228
+ for (const requestLike of requestsLike) {
229
+ if ('requestsFromUrl' in requestLike) {
230
+ const requests = await this._fetchRequestsFromUrl(requestLike);
231
+ await this._addFetchedRequests(requestLike, requests, options);
232
+ }
233
+ }
234
+ const requests = requestsLike
235
+ .filter((requestLike) => !('requestsFromUrl' in requestLike))
236
+ .map((requestLike) => {
237
+ return requestLike instanceof request_1.Request ? requestLike : new request_1.Request(requestLike);
238
+ });
239
+ const requestsToAdd = new Map();
240
+ for (const request of requests) {
241
+ const cacheKey = getCachedRequestId(request.uniqueKey);
242
+ const cachedInfo = this.requestCache.get(cacheKey);
243
+ if (cachedInfo) {
244
+ request.id = cachedInfo.id;
245
+ results.processedRequests.push({
246
+ wasAlreadyPresent: true,
247
+ // We may assume that if request is in local cache then also the information if the
248
+ // request was already handled is there because just one client should be using one queue.
249
+ wasAlreadyHandled: cachedInfo.isHandled,
250
+ requestId: cachedInfo.id,
251
+ uniqueKey: cachedInfo.uniqueKey,
252
+ });
253
+ }
254
+ else if (!requestsToAdd.has(request.uniqueKey)) {
255
+ requestsToAdd.set(request.uniqueKey, request);
256
+ }
257
+ }
258
+ // Early exit if all provided requests were already added
259
+ if (!requestsToAdd.size) {
260
+ return results;
261
+ }
262
+ const apiResults = await this.client.batchAddRequests([...requestsToAdd.values()], { forefront });
263
+ // Report unprocessed requests
264
+ results.unprocessedRequests = apiResults.unprocessedRequests;
265
+ // Add all new requests to the queue head
266
+ for (const newRequest of apiResults.processedRequests) {
267
+ // Add the new request to the processed list
268
+ results.processedRequests.push(newRequest);
269
+ const cacheKey = getCachedRequestId(newRequest.uniqueKey);
270
+ const { requestId, wasAlreadyPresent } = newRequest;
271
+ this._cacheRequest(cacheKey, newRequest);
272
+ if (!wasAlreadyPresent && !this.inProgress.has(requestId) && !this.recentlyHandledRequestsCache.get(requestId)) {
273
+ this.assumedTotalCount++;
274
+ // Performance optimization: add request straight to head if possible
275
+ this._maybeAddRequestToQueueHead(requestId, forefront);
276
+ }
277
+ }
278
+ return results;
279
+ }
280
+ /**
281
+ * Adds requests to the queue in batches. By default, it will resolve after the initial batch is added, and continue
282
+ * adding the rest in background. You can configure the batch size via `batchSize` option and the sleep time in between
283
+ * the batches via `waitBetweenBatchesMillis`. If you want to wait for all batches to be added to the queue, you can use
284
+ * the `waitForAllRequestsToBeAdded` promise you get in the response object.
285
+ *
286
+ * @param requests The requests to add
287
+ * @param options Options for the request queue
288
+ */
289
+ async addRequestsBatched(requests, options = {}) {
290
+ (0, ow_1.default)(requests, ow_1.default.array.ofType(ow_1.default.any(ow_1.default.string, ow_1.default.object.partialShape({ url: ow_1.default.string, id: ow_1.default.undefined }), ow_1.default.object.partialShape({ requestsFromUrl: ow_1.default.string, regex: ow_1.default.optional.regExp }))));
291
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
292
+ forefront: ow_1.default.optional.boolean,
293
+ waitForAllRequestsToBeAdded: ow_1.default.optional.boolean,
294
+ batchSize: ow_1.default.optional.number,
295
+ waitBetweenBatchesMillis: ow_1.default.optional.number,
296
+ }));
297
+ const { batchSize = 1000, waitBetweenBatchesMillis = 1000, } = options;
298
+ const builtRequests = [];
299
+ for (const opts of requests) {
300
+ if (opts && typeof opts === 'object' && 'requestsFromUrl' in opts) {
301
+ await this.addRequest(opts, { forefront: options.forefront });
302
+ }
303
+ else {
304
+ builtRequests.push(new request_1.Request(typeof opts === 'string' ? { url: opts } : opts));
305
+ }
306
+ }
307
+ const attemptToAddToQueueAndAddAnyUnprocessed = async (providedRequests) => {
308
+ const resultsToReturn = [];
309
+ const apiResult = await this.addRequests(providedRequests, { forefront: options.forefront });
310
+ resultsToReturn.push(...apiResult.processedRequests);
311
+ if (apiResult.unprocessedRequests.length) {
312
+ await (0, utils_1.sleep)(waitBetweenBatchesMillis);
313
+ resultsToReturn.push(...await attemptToAddToQueueAndAddAnyUnprocessed(providedRequests.filter((r) => !apiResult.processedRequests.some((pr) => pr.uniqueKey === r.uniqueKey))));
314
+ }
315
+ return resultsToReturn;
316
+ };
317
+ const initialChunk = builtRequests.splice(0, batchSize);
318
+ // Add initial batch of `batchSize` to process them right away
319
+ const addedRequests = await attemptToAddToQueueAndAddAnyUnprocessed(initialChunk);
320
+ // If we have no more requests to add, return early
321
+ if (!builtRequests.length) {
322
+ return {
323
+ addedRequests,
324
+ waitForAllRequestsToBeAdded: Promise.resolve([]),
325
+ };
326
+ }
327
+ // eslint-disable-next-line no-async-promise-executor
328
+ const promise = new Promise(async (resolve) => {
329
+ const chunks = (0, utils_1.chunk)(builtRequests, batchSize);
330
+ const finalAddedRequests = [];
331
+ for (const requestChunk of chunks) {
332
+ finalAddedRequests.push(...await attemptToAddToQueueAndAddAnyUnprocessed(requestChunk));
333
+ await (0, utils_1.sleep)(waitBetweenBatchesMillis);
334
+ }
335
+ resolve(finalAddedRequests);
336
+ });
337
+ // If the user wants to wait for all the requests to be added, we wait for the promise to resolve for them
338
+ if (options.waitForAllRequestsToBeAdded) {
339
+ addedRequests.push(...await promise);
340
+ }
341
+ return {
342
+ addedRequests,
343
+ waitForAllRequestsToBeAdded: promise,
344
+ };
345
+ }
346
+ /**
347
+ * Gets the request from the queue specified by ID.
348
+ *
349
+ * @param id ID of the request.
350
+ * @returns Returns the request object, or `null` if it was not found.
351
+ */
352
+ async getRequest(id) {
353
+ (0, ow_1.default)(id, ow_1.default.string);
354
+ const requestOptions = await this.client.getRequest(id);
355
+ if (!requestOptions)
356
+ return null;
357
+ return new request_1.Request(requestOptions);
358
+ }
359
+ /**
360
+ * Marks a request that was previously returned by the
361
+ * {@apilink RequestQueue.fetchNextRequest}
362
+ * function as handled after successful processing.
363
+ * Handled requests will never again be returned by the `fetchNextRequest` function.
364
+ */
365
+ async markRequestHandled(request) {
366
+ (0, ow_1.default)(request, ow_1.default.object.partialShape({
367
+ id: ow_1.default.string,
368
+ uniqueKey: ow_1.default.string,
369
+ handledAt: ow_1.default.optional.string,
370
+ }));
371
+ if (!this.inProgress.has(request.id)) {
372
+ this.log.debug(`Cannot mark request ${request.id} as handled, because it is not in progress!`, { requestId: request.id });
373
+ return null;
374
+ }
375
+ const handledAt = request.handledAt ?? new Date().toISOString();
376
+ const queueOperationInfo = await this.client.updateRequest({ ...request, handledAt });
377
+ request.handledAt = handledAt;
378
+ queueOperationInfo.uniqueKey = request.uniqueKey;
379
+ this.inProgress.delete(request.id);
380
+ this.recentlyHandledRequestsCache.add(request.id, true);
381
+ if (!queueOperationInfo.wasAlreadyHandled) {
382
+ this.assumedHandledCount++;
383
+ }
384
+ this._cacheRequest((0, utils_2.getRequestId)(request.uniqueKey), queueOperationInfo);
385
+ return queueOperationInfo;
386
+ }
387
+ /**
388
+ * Reclaims a failed request back to the queue, so that it can be returned for processing later again
389
+ * by another call to {@apilink RequestQueue.fetchNextRequest}.
390
+ * The request record in the queue is updated using the provided `request` parameter.
391
+ * For example, this lets you store the number of retries or error messages for the request.
392
+ */
393
+ async reclaimRequest(request, options = {}) {
394
+ (0, ow_1.default)(request, ow_1.default.object.partialShape({
395
+ id: ow_1.default.string,
396
+ uniqueKey: ow_1.default.string,
397
+ }));
398
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
399
+ forefront: ow_1.default.optional.boolean,
400
+ }));
401
+ const { forefront = false } = options;
402
+ if (!this.inProgress.has(request.id)) {
403
+ this.log.debug(`Cannot reclaim request ${request.id}, because it is not in progress!`, { requestId: request.id });
404
+ return null;
405
+ }
406
+ // TODO: If request hasn't been changed since the last getRequest(),
407
+ // we don't need to call updateRequest() and thus improve performance.
408
+ const queueOperationInfo = await this.client.updateRequest(request, { forefront });
409
+ queueOperationInfo.uniqueKey = request.uniqueKey;
410
+ this._cacheRequest((0, utils_2.getRequestId)(request.uniqueKey), queueOperationInfo);
411
+ // Wait a little to increase a chance that the next call to fetchNextRequest() will return the request with updated data.
412
+ // This is to compensate for the limitation of DynamoDB, where writes might not be immediately visible to subsequent reads.
413
+ setTimeout(() => {
414
+ if (!this.inProgress.has(request.id)) {
415
+ this.log.debug('The request is no longer marked as in progress in the queue?!', { requestId: request.id });
416
+ return;
417
+ }
418
+ this.inProgress.delete(request.id);
419
+ // Performance optimization: add request straight to head if possible
420
+ this._maybeAddRequestToQueueHead(request.id, forefront);
421
+ }, utils_2.STORAGE_CONSISTENCY_DELAY_MILLIS);
422
+ return queueOperationInfo;
423
+ }
424
+ /**
425
+ * Resolves to `true` if the next call to {@apilink RequestQueue.fetchNextRequest}
426
+ * would return `null`, otherwise it resolves to `false`.
427
+ * Note that even if the queue is empty, there might be some pending requests currently being processed.
428
+ * If you need to ensure that there is no activity in the queue, use {@apilink RequestQueue.isFinished}.
429
+ */
430
+ async isEmpty() {
431
+ await this.ensureHeadIsNonEmpty();
432
+ return this.queueHeadIds.length() === 0;
433
+ }
434
+ /**
435
+ * Resolves to `true` if all requests were already handled and there are no more left.
436
+ * Due to the nature of distributed storage used by the queue,
437
+ * the function might occasionally return a false negative,
438
+ * but it will never return a false positive.
439
+ */
440
+ async isFinished() {
441
+ if (this.queueHeadIds.length() > 0 || this.inProgressCount() > 0)
442
+ return false;
443
+ const currentHead = await this.client.listHead({ limit: 2 });
444
+ return currentHead.items.length === 0 && this.inProgressCount() === 0;
445
+ }
446
+ _reset() {
447
+ this.queueHeadIds.clear();
448
+ this.inProgress.clear();
449
+ this.recentlyHandledRequestsCache.clear();
450
+ this.assumedTotalCount = 0;
451
+ this.assumedHandledCount = 0;
452
+ this.requestCache.clear();
453
+ }
454
+ /**
455
+ * Caches information about request to beware of unneeded addRequest() calls.
456
+ */
457
+ _cacheRequest(cacheKey, queueOperationInfo) {
458
+ this.requestCache.add(cacheKey, {
459
+ id: queueOperationInfo.requestId,
460
+ isHandled: queueOperationInfo.wasAlreadyHandled,
461
+ uniqueKey: queueOperationInfo.uniqueKey,
462
+ hydrated: null,
463
+ lockExpiresAt: null,
464
+ });
465
+ }
466
+ /**
467
+ * Adds a request straight to the queueHeadDict, to improve performance.
468
+ */
469
+ _maybeAddRequestToQueueHead(requestId, forefront) {
470
+ if (forefront) {
471
+ this.queueHeadIds.add(requestId, requestId, true);
472
+ }
473
+ else if (this.assumedTotalCount < utils_2.QUERY_HEAD_MIN_LENGTH) {
474
+ this.queueHeadIds.add(requestId, requestId, false);
475
+ }
476
+ }
477
+ /**
478
+ * Removes the queue either from the Apify Cloud storage or from the local database,
479
+ * depending on the mode of operation.
480
+ */
481
+ async drop() {
482
+ await this.client.delete();
483
+ const manager = storage_manager_1.StorageManager.getManager(this.constructor, this.config);
484
+ manager.closeStorage(this);
485
+ }
486
+ /**
487
+ * Returns the number of handled requests.
488
+ *
489
+ * This function is just a convenient shortcut for:
490
+ *
491
+ * ```javascript
492
+ * const { handledRequestCount } = await queue.getInfo();
493
+ * ```
494
+ */
495
+ async handledCount() {
496
+ // NOTE: We keep this function for compatibility with RequestList.handledCount()
497
+ const { handledRequestCount } = await this.getInfo() ?? {};
498
+ return handledRequestCount ?? 0;
499
+ }
500
+ /**
501
+ * Returns an object containing general information about the request queue.
502
+ *
503
+ * The function returns the same object as the Apify API Client's
504
+ * [getQueue](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-requestQueues)
505
+ * function, which in turn calls the
506
+ * [Get request queue](https://apify.com/docs/api/v2#/reference/request-queues/queue/get-request-queue)
507
+ * API endpoint.
508
+ *
509
+ * **Example:**
510
+ * ```
511
+ * {
512
+ * id: "WkzbQMuFYuamGv3YF",
513
+ * name: "my-queue",
514
+ * userId: "wRsJZtadYvn4mBZmm",
515
+ * createdAt: new Date("2015-12-12T07:34:14.202Z"),
516
+ * modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
517
+ * accessedAt: new Date("2015-12-14T08:36:13.202Z"),
518
+ * totalRequestCount: 25,
519
+ * handledRequestCount: 5,
520
+ * pendingRequestCount: 20,
521
+ * }
522
+ * ```
523
+ */
524
+ async getInfo() {
525
+ return this.client.get();
526
+ }
527
+ /**
528
+ * Fetches URLs from requestsFromUrl and returns them in format of list of requests
529
+ */
530
+ async _fetchRequestsFromUrl(source) {
531
+ const { requestsFromUrl, regex, ...sharedOpts } = source;
532
+ // Download remote resource and parse URLs.
533
+ let urlsArr;
534
+ try {
535
+ urlsArr = await this._downloadListOfUrls({ url: requestsFromUrl, urlRegExp: regex, proxyUrl: await this.proxyConfiguration?.newUrl() });
536
+ }
537
+ catch (err) {
538
+ throw new Error(`Cannot fetch a request list from ${requestsFromUrl}: ${err}`);
539
+ }
540
+ // Skip if resource contained no URLs.
541
+ if (!urlsArr.length) {
542
+ this.log.warning('list fetched, but it is empty.', { requestsFromUrl, regex });
543
+ return [];
544
+ }
545
+ return urlsArr.map((url) => ({ url, ...sharedOpts }));
546
+ }
547
+ /**
548
+ * Adds all fetched requests from a URL from a remote resource.
549
+ */
550
+ async _addFetchedRequests(source, fetchedRequests, options) {
551
+ const { requestsFromUrl, regex } = source;
552
+ const { addedRequests } = await this.addRequestsBatched(fetchedRequests, options);
553
+ this.log.info('Fetched and loaded Requests from a remote resource.', {
554
+ requestsFromUrl,
555
+ regex,
556
+ fetchedCount: fetchedRequests.length,
557
+ importedCount: addedRequests.length,
558
+ duplicateCount: fetchedRequests.length - addedRequests.length,
559
+ sample: JSON.stringify(fetchedRequests.slice(0, 5)),
560
+ });
561
+ return addedRequests;
562
+ }
563
+ /**
564
+ * @internal wraps public utility for mocking purposes
565
+ */
566
+ async _downloadListOfUrls(options) {
567
+ return (0, utils_1.downloadListOfUrls)(options);
568
+ }
569
+ /**
570
+ * Opens a request queue and returns a promise resolving to an instance
571
+ * of the {@apilink RequestQueue} class.
572
+ *
573
+ * {@apilink RequestQueue} represents a queue of URLs to crawl, which is stored either on local filesystem or in the cloud.
574
+ * The queue is used for deep crawling of websites, where you start with several URLs and then
575
+ * recursively follow links to other pages. The data structure supports both breadth-first
576
+ * and depth-first crawling orders.
577
+ *
578
+ * For more details and code examples, see the {@apilink RequestQueue} class.
579
+ *
580
+ * @param [queueIdOrName]
581
+ * ID or name of the request queue to be opened. If `null` or `undefined`,
582
+ * the function returns the default request queue associated with the crawler run.
583
+ * @param [options] Open Request Queue options.
584
+ */
585
+ static async open(queueIdOrName, options = {}) {
586
+ (0, ow_1.default)(queueIdOrName, ow_1.default.optional.any(ow_1.default.string, ow_1.default.null));
587
+ (0, ow_1.default)(options, ow_1.default.object.exactShape({
588
+ config: ow_1.default.optional.object.instanceOf(configuration_1.Configuration),
589
+ storageClient: ow_1.default.optional.object,
590
+ proxyConfiguration: ow_1.default.optional.object,
591
+ }));
592
+ options.config ?? (options.config = configuration_1.Configuration.getGlobalConfig());
593
+ options.storageClient ?? (options.storageClient = options.config.getStorageClient());
594
+ await (0, utils_2.purgeDefaultStorages)({ onlyPurgeOnce: true, client: options.storageClient, config: options.config });
595
+ const manager = storage_manager_1.StorageManager.getManager(this, options.config);
596
+ const queue = await manager.openStorage(queueIdOrName, options.storageClient);
597
+ queue.proxyConfiguration = options.proxyConfiguration;
598
+ return queue;
599
+ }
600
+ }
601
+ exports.RequestProvider = RequestProvider;
602
+ //# sourceMappingURL=request_provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request_provider.js","sourceRoot":"","sources":["../../src/storages/request_provider.ts"],"names":[],"mappings":";;;;AAAA,0DAAiE;AAEjE,gDAAwD;AAUxD,0CAAkE;AAClE,oDAAoB;AAGpB,uDAAmD;AACnD,mCAAsH;AACtH,oDAAiD;AAEjD,gCAA6B;AAE7B,wCAAqC;AAIrC,MAAsB,eAAe;IAyBjC,YAAY,OAAuC,EAAW,SAAS,6BAAa,CAAC,eAAe,EAAE;QAAjD;;;;mBAAS,MAAM;WAAkC;QAxBtG;;;;;WAAW;QACX;;;;;WAAc;QACd;;;;mBAAc,EAAE;WAAC;QACjB;;;;mBAAY,IAAA,gCAAoB,GAAE;WAAC;QACnC;;;;;WAA2B;QACjB;;;;;WAAwC;QAElD;;;;;WAAS;QACT;;;;mBAAwB,CAAC,GAAG,KAAM;WAAC,CAAC,4DAA4D;QAChG;;;;mBAAkB,CAAC,GAAG,EAAE;WAAC,CAAC,4DAA4D;QAEtF,mFAAmF;QACnF,mFAAmF;QACnF;;;;mBAAoB,CAAC;WAAC;QACtB;;;;mBAAsB,CAAC;WAAC;QAEd;;;;mBAAe,IAAI,+BAAc,EAAU;WAAC;QAC5C;;;;;WAAuC;QACjD,gBAAgB;QA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