apify-client 2.25.1-beta.8 → 3.0.0-beta.1
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/apify_client.js +34 -30
- package/dist/argument_validation_error.d.ts +17 -0
- package/dist/argument_validation_error.js +157 -0
- package/dist/base/api_client.d.ts +2 -2
- package/dist/base/api_client.js +13 -10
- package/dist/bundle.js +66 -28147
- package/dist/bundle.js.LICENSE.txt +33 -0
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +20522 -0
- package/dist/generated/api.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/models.d.ts +1072 -0
- package/dist/models.js +89 -0
- package/dist/resource_clients/actor.d.ts +2 -448
- package/dist/resource_clients/actor.js +60 -55
- package/dist/resource_clients/actor_collection.d.ts +2 -7
- package/dist/resource_clients/actor_collection.js +13 -11
- package/dist/resource_clients/actor_env_var.js +2 -3
- package/dist/resource_clients/actor_env_var_collection.js +3 -3
- package/dist/resource_clients/actor_version.d.ts +3 -40
- package/dist/resource_clients/actor_version.js +8 -12
- package/dist/resource_clients/actor_version_collection.js +3 -3
- package/dist/resource_clients/build.d.ts +2 -77
- package/dist/resource_clients/build.js +7 -10
- package/dist/resource_clients/build_collection.d.ts +2 -2
- package/dist/resource_clients/build_collection.js +8 -8
- package/dist/resource_clients/dataset.d.ts +8 -72
- package/dist/resource_clients/dataset.js +66 -57
- package/dist/resource_clients/dataset_collection.js +14 -12
- package/dist/resource_clients/key_value_store.d.ts +5 -73
- package/dist/resource_clients/key_value_store.js +69 -51
- package/dist/resource_clients/key_value_store_collection.js +14 -12
- package/dist/resource_clients/request_queue.d.ts +15 -174
- package/dist/resource_clients/request_queue.js +85 -91
- package/dist/resource_clients/request_queue_collection.js +12 -11
- package/dist/resource_clients/run.js +39 -40
- package/dist/resource_clients/run_collection.js +12 -11
- package/dist/resource_clients/schedule.d.ts +3 -81
- package/dist/resource_clients/schedule.js +4 -12
- package/dist/resource_clients/schedule_collection.js +10 -9
- package/dist/resource_clients/store_collection.d.ts +2 -30
- package/dist/resource_clients/store_collection.js +13 -13
- package/dist/resource_clients/task.d.ts +3 -73
- package/dist/resource_clients/task.js +36 -33
- package/dist/resource_clients/task_collection.d.ts +2 -1
- package/dist/resource_clients/task_collection.js +9 -9
- package/dist/resource_clients/user.d.ts +3 -179
- package/dist/resource_clients/user.js +3 -11
- package/dist/resource_clients/webhook.d.ts +2 -61
- package/dist/resource_clients/webhook.js +1 -3
- package/dist/resource_clients/webhook_collection.js +10 -9
- package/dist/resource_clients/webhook_dispatch.d.ts +3 -36
- package/dist/resource_clients/webhook_dispatch.js +3 -7
- package/dist/resource_clients/webhook_dispatch_collection.js +8 -8
- package/dist/statistics.js +4 -3
- package/dist/utils.d.ts +51 -5
- package/dist/utils.js +103 -15
- package/package.json +22 -7
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KeyValueStoreCollectionClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
4
|
+
const zod_1 = require("zod");
|
|
6
5
|
const consts_1 = require("@apify/consts");
|
|
7
6
|
const resource_collection_client_1 = require("../base/resource_collection_client");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const listOptionsSchema = zod_1.z.strictObject({
|
|
9
|
+
unnamed: zod_1.z.boolean().optional(),
|
|
10
|
+
...utils_1.paginationOptionsShape,
|
|
11
|
+
desc: zod_1.z.boolean().optional(),
|
|
12
|
+
ownership: zod_1.z.enum(consts_1.STORAGE_OWNERSHIP_FILTER).optional(),
|
|
13
|
+
});
|
|
14
|
+
const nameSchema = zod_1.z.string().optional();
|
|
15
|
+
const schemaSchema = utils_1.anyObjectSchema.optional();
|
|
8
16
|
/**
|
|
9
17
|
* Client for managing the collection of Key-value stores in your account.
|
|
10
18
|
*
|
|
@@ -56,14 +64,8 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
|
|
|
56
64
|
* @see https://docs.apify.com/api/v2/key-value-stores-get
|
|
57
65
|
*/
|
|
58
66
|
list(options = {}) {
|
|
59
|
-
(0,
|
|
60
|
-
|
|
61
|
-
limit: ow_1.default.optional.number.not.negative,
|
|
62
|
-
offset: ow_1.default.optional.number.not.negative,
|
|
63
|
-
desc: ow_1.default.optional.boolean,
|
|
64
|
-
ownership: ow_1.default.optional.string.oneOf(Object.values(consts_1.STORAGE_OWNERSHIP_FILTER)),
|
|
65
|
-
}));
|
|
66
|
-
return this._listPaginated(options);
|
|
67
|
+
const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
|
|
68
|
+
return this._listPaginated(parsed);
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Gets or creates a key-value store with the specified name.
|
|
@@ -74,8 +76,8 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
|
|
|
74
76
|
* @see https://docs.apify.com/api/v2/key-value-stores-post
|
|
75
77
|
*/
|
|
76
78
|
async getOrCreate(name, options) {
|
|
77
|
-
(0,
|
|
78
|
-
(0,
|
|
79
|
+
(0, utils_1.parseArgument)(name, nameSchema);
|
|
80
|
+
(0, utils_1.parseArgument)(options?.schema, schemaSchema); // TODO: Add schema validation
|
|
79
81
|
return this._getOrCreate(name, options);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
|
|
2
2
|
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
3
3
|
import { ResourceClient } from '../base/resource_client';
|
|
4
|
+
import type { RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListRequestsResult, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult } from '../models';
|
|
5
|
+
export type { AllowedHttpMethods, RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListItem, RequestQueueClientListRequestsResult, RequestQueueClientLockedListItem, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult, RequestQueueStats, } from '../models';
|
|
4
6
|
/**
|
|
5
7
|
* Client for managing a specific Request queue.
|
|
6
8
|
*
|
|
@@ -20,12 +22,12 @@ import { ResourceClient } from '../base/resource_client';
|
|
|
20
22
|
* });
|
|
21
23
|
*
|
|
22
24
|
* // Get the next request from the queue
|
|
23
|
-
* const request = await queueClient.listHead();
|
|
25
|
+
* const { items: [request] } = await queueClient.listHead({ limit: 1 });
|
|
24
26
|
*
|
|
25
27
|
* // Mark request as handled
|
|
26
28
|
* await queueClient.updateRequest({
|
|
27
29
|
* id: request.id,
|
|
28
|
-
* handledAt: new Date()
|
|
30
|
+
* handledAt: new Date()
|
|
29
31
|
* });
|
|
30
32
|
* ```
|
|
31
33
|
*
|
|
@@ -142,14 +144,14 @@ export declare class RequestQueueClient extends ResourceClient {
|
|
|
142
144
|
* );
|
|
143
145
|
* ```
|
|
144
146
|
*/
|
|
145
|
-
addRequest(request:
|
|
147
|
+
addRequest(request: RequestQueueClientRequestToAdd, options?: RequestQueueClientAddRequestOptions): Promise<RequestQueueClientAddRequestResult>;
|
|
146
148
|
/**
|
|
147
149
|
* Writes requests to Request queue in batch.
|
|
148
150
|
*
|
|
149
151
|
* @private
|
|
150
152
|
*/
|
|
151
|
-
protected _batchAddRequests(requests:
|
|
152
|
-
protected _batchAddRequestsWithRetries(requests:
|
|
153
|
+
protected _batchAddRequests(requests: RequestQueueClientRequestToAdd[], options?: RequestQueueClientAddRequestOptions): Promise<RequestQueueClientBatchRequestsOperationResult>;
|
|
154
|
+
protected _batchAddRequestsWithRetries(requests: RequestQueueClientRequestToAdd[], options?: RequestQueueClientBatchAddRequestWithRetriesOptions): Promise<RequestQueueClientBatchRequestsOperationResult>;
|
|
153
155
|
/**
|
|
154
156
|
* Adds multiple requests to the queue in a single operation.
|
|
155
157
|
*
|
|
@@ -188,7 +190,7 @@ export declare class RequestQueueClient extends ResourceClient {
|
|
|
188
190
|
* ```
|
|
189
191
|
* @since Added in 2.1.0
|
|
190
192
|
*/
|
|
191
|
-
batchAddRequests(requests:
|
|
193
|
+
batchAddRequests(requests: RequestQueueClientRequestToAdd[], options?: RequestQueueClientBatchAddRequestWithRetriesOptions): Promise<RequestQueueClientBatchRequestsOperationResult>;
|
|
192
194
|
/**
|
|
193
195
|
* Deletes multiple requests from the queue in a single operation.
|
|
194
196
|
*
|
|
@@ -199,7 +201,7 @@ export declare class RequestQueueClient extends ResourceClient {
|
|
|
199
201
|
* @see https://docs.apify.com/api/v2/request-queue-requests-batch-delete
|
|
200
202
|
* @since Added in 2.3.0
|
|
201
203
|
*/
|
|
202
|
-
batchDeleteRequests(requests: RequestQueueClientRequestToDelete[]): Promise<
|
|
204
|
+
batchDeleteRequests(requests: RequestQueueClientRequestToDelete[]): Promise<RequestQueueClientBatchDeleteRequestsResult>;
|
|
203
205
|
/**
|
|
204
206
|
* Gets a specific request from the queue by its ID.
|
|
205
207
|
*
|
|
@@ -216,7 +218,7 @@ export declare class RequestQueueClient extends ResourceClient {
|
|
|
216
218
|
* @returns Information about the updated request
|
|
217
219
|
* @see https://docs.apify.com/api/v2/request-queue-request-put
|
|
218
220
|
*/
|
|
219
|
-
updateRequest(request:
|
|
221
|
+
updateRequest(request: RequestQueueClientRequestToUpdate, options?: RequestQueueClientAddRequestOptions): Promise<RequestQueueClientAddRequestResult>;
|
|
220
222
|
/**
|
|
221
223
|
* Deletes a specific request from the queue.
|
|
222
224
|
*
|
|
@@ -314,50 +316,6 @@ export interface RequestQueueUserOptions {
|
|
|
314
316
|
*/
|
|
315
317
|
timeoutSecs?: number;
|
|
316
318
|
}
|
|
317
|
-
/**
|
|
318
|
-
* Represents a Request Queue storage on the Apify platform.
|
|
319
|
-
*
|
|
320
|
-
* Request queues store URLs (requests) to be processed by web crawlers. They provide
|
|
321
|
-
* automatic deduplication, request locking for parallel processing, and persistence.
|
|
322
|
-
*/
|
|
323
|
-
export interface RequestQueue {
|
|
324
|
-
id: string;
|
|
325
|
-
name?: string;
|
|
326
|
-
/**
|
|
327
|
-
* @since Added in 2.6.1
|
|
328
|
-
*/
|
|
329
|
-
title?: string;
|
|
330
|
-
userId: string;
|
|
331
|
-
/**
|
|
332
|
-
* @since Added in 2.21.0
|
|
333
|
-
*/
|
|
334
|
-
username?: string;
|
|
335
|
-
createdAt: Date;
|
|
336
|
-
modifiedAt: Date;
|
|
337
|
-
accessedAt: Date;
|
|
338
|
-
expireAt?: string;
|
|
339
|
-
totalRequestCount: number;
|
|
340
|
-
handledRequestCount: number;
|
|
341
|
-
pendingRequestCount: number;
|
|
342
|
-
actId?: string;
|
|
343
|
-
actRunId?: string;
|
|
344
|
-
hadMultipleClients: boolean;
|
|
345
|
-
stats: RequestQueueStats;
|
|
346
|
-
/**
|
|
347
|
-
* @since Added in 2.12.2
|
|
348
|
-
*/
|
|
349
|
-
generalAccess?: STORAGE_GENERAL_ACCESS | null;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Statistics about Request Queue usage and storage.
|
|
353
|
-
*/
|
|
354
|
-
export interface RequestQueueStats {
|
|
355
|
-
readCount?: number;
|
|
356
|
-
writeCount?: number;
|
|
357
|
-
deleteCount?: number;
|
|
358
|
-
headItemReadCount?: number;
|
|
359
|
-
storageBytes?: number;
|
|
360
|
-
}
|
|
361
319
|
/**
|
|
362
320
|
* Options for updating a Request Queue.
|
|
363
321
|
*/
|
|
@@ -378,15 +336,6 @@ export interface RequestQueueClientUpdateOptions {
|
|
|
378
336
|
export interface RequestQueueClientListHeadOptions {
|
|
379
337
|
limit?: number;
|
|
380
338
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Result of listing requests from the queue head.
|
|
383
|
-
*/
|
|
384
|
-
export interface RequestQueueClientListHeadResult {
|
|
385
|
-
limit: number;
|
|
386
|
-
queueModifiedAt: Date;
|
|
387
|
-
hadMultipleClients: boolean;
|
|
388
|
-
items: RequestQueueClientListItem[];
|
|
389
|
-
}
|
|
390
339
|
/**
|
|
391
340
|
* @since Added in 2.23.2
|
|
392
341
|
*/
|
|
@@ -429,24 +378,6 @@ export interface RequestQueueClientPaginateRequestsOptions {
|
|
|
429
378
|
*/
|
|
430
379
|
filter?: readonly RequestQueueListRequestsFilter[];
|
|
431
380
|
}
|
|
432
|
-
/**
|
|
433
|
-
* Result of listing all requests in the queue.
|
|
434
|
-
* @since Added in 2.5.1
|
|
435
|
-
*/
|
|
436
|
-
export interface RequestQueueClientListRequestsResult {
|
|
437
|
-
limit: number;
|
|
438
|
-
/** @deprecated Use `cursor` for pagination instead. */
|
|
439
|
-
exclusiveStartId?: string;
|
|
440
|
-
/**
|
|
441
|
-
* @since Added in 2.23.2
|
|
442
|
-
*/
|
|
443
|
-
cursor?: string;
|
|
444
|
-
/**
|
|
445
|
-
* @since Added in 2.23.2
|
|
446
|
-
*/
|
|
447
|
-
nextCursor?: string;
|
|
448
|
-
items: RequestQueueClientRequestSchema[];
|
|
449
|
-
}
|
|
450
381
|
/**
|
|
451
382
|
* Options for listing and locking requests from the queue head.
|
|
452
383
|
* @since Added in 2.4.1
|
|
@@ -455,37 +386,6 @@ export interface RequestQueueClientListAndLockHeadOptions {
|
|
|
455
386
|
lockSecs: number;
|
|
456
387
|
limit?: number;
|
|
457
388
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Result of listing and locking requests from the queue head.
|
|
460
|
-
*
|
|
461
|
-
* Extends {@link RequestQueueClientListHeadResult} with lock information.
|
|
462
|
-
* @since Added in 2.4.1
|
|
463
|
-
*/
|
|
464
|
-
export interface RequestQueueClientListAndLockHeadResult extends RequestQueueClientListHeadResult {
|
|
465
|
-
lockSecs: number;
|
|
466
|
-
/**
|
|
467
|
-
* @since Added in 2.11.0
|
|
468
|
-
*/
|
|
469
|
-
queueHasLockedRequests: boolean;
|
|
470
|
-
/**
|
|
471
|
-
* @since Added in 2.11.0
|
|
472
|
-
*/
|
|
473
|
-
clientKey: string;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Simplified request information used in list results.
|
|
477
|
-
*/
|
|
478
|
-
export interface RequestQueueClientListItem {
|
|
479
|
-
id: string;
|
|
480
|
-
retryCount: number;
|
|
481
|
-
uniqueKey: string;
|
|
482
|
-
url: string;
|
|
483
|
-
method: AllowedHttpMethods;
|
|
484
|
-
/**
|
|
485
|
-
* @since Added in 2.4.1
|
|
486
|
-
*/
|
|
487
|
-
lockExpiresAt?: Date;
|
|
488
|
-
}
|
|
489
389
|
export interface RequestQueueClientAddRequestOptions {
|
|
490
390
|
forefront?: boolean;
|
|
491
391
|
}
|
|
@@ -502,12 +402,6 @@ export interface RequestQueueClientProlongRequestLockOptions {
|
|
|
502
402
|
export interface RequestQueueClientDeleteRequestLockOptions {
|
|
503
403
|
forefront?: boolean;
|
|
504
404
|
}
|
|
505
|
-
/**
|
|
506
|
-
* @since Added in 2.4.1
|
|
507
|
-
*/
|
|
508
|
-
export interface RequestQueueClientProlongRequestLockResult {
|
|
509
|
-
lockExpiresAt: Date;
|
|
510
|
-
}
|
|
511
405
|
/**
|
|
512
406
|
* @since Added in 2.3.0
|
|
513
407
|
*/
|
|
@@ -520,71 +414,18 @@ export interface RequestQueueClientBatchAddRequestWithRetriesOptions {
|
|
|
520
414
|
*/
|
|
521
415
|
minDelayBetweenUnprocessedRequestsRetriesMillis?: number;
|
|
522
416
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Complete schema for a request in the queue.
|
|
525
|
-
*
|
|
526
|
-
* Represents a URL to be crawled along with its metadata, retry information, and custom data.
|
|
527
|
-
*/
|
|
528
|
-
export interface RequestQueueClientRequestSchema {
|
|
529
|
-
id: string;
|
|
530
|
-
uniqueKey: string;
|
|
531
|
-
url: string;
|
|
532
|
-
method?: AllowedHttpMethods;
|
|
533
|
-
payload?: string;
|
|
534
|
-
retryCount?: number;
|
|
535
|
-
errorMessages?: string[];
|
|
536
|
-
headers?: Record<string, string>;
|
|
537
|
-
userData?: Record<string, unknown>;
|
|
538
|
-
handledAt?: string;
|
|
539
|
-
noRetry?: boolean;
|
|
540
|
-
loadedUrl?: string;
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Result of adding a request to the queue.
|
|
544
|
-
*/
|
|
545
|
-
export interface RequestQueueClientAddRequestResult {
|
|
546
|
-
requestId: string;
|
|
547
|
-
wasAlreadyPresent: boolean;
|
|
548
|
-
wasAlreadyHandled: boolean;
|
|
549
|
-
}
|
|
550
|
-
interface ProcessedRequest {
|
|
551
|
-
uniqueKey: string;
|
|
552
|
-
requestId: string;
|
|
553
|
-
wasAlreadyPresent: boolean;
|
|
554
|
-
wasAlreadyHandled: boolean;
|
|
555
|
-
}
|
|
556
|
-
interface UnprocessedRequest {
|
|
557
|
-
uniqueKey: string;
|
|
558
|
-
url: string;
|
|
559
|
-
method?: AllowedHttpMethods;
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* @since Added in 2.12.5
|
|
563
|
-
*/
|
|
564
|
-
export interface RequestQueueClientUnlockRequestsResult {
|
|
565
|
-
unlockedCount: number;
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Result of a batch operation on requests.
|
|
569
|
-
*
|
|
570
|
-
* Contains lists of successfully processed and unprocessed requests.
|
|
571
|
-
* @since Added in 2.3.0
|
|
572
|
-
*/
|
|
573
|
-
export interface RequestQueueClientBatchRequestsOperationResult {
|
|
574
|
-
processedRequests: ProcessedRequest[];
|
|
575
|
-
unprocessedRequests: UnprocessedRequest[];
|
|
576
|
-
}
|
|
577
417
|
/**
|
|
578
418
|
* @since Added in 2.3.0
|
|
579
419
|
*/
|
|
580
420
|
export type RequestQueueClientRequestToDelete = Pick<RequestQueueClientRequestSchema, 'id'> | Pick<RequestQueueClientRequestSchema, 'uniqueKey'>;
|
|
581
|
-
export type RequestQueueClientGetRequestResult = Omit<RequestQueueClientListItem, 'retryCount'>;
|
|
582
421
|
/**
|
|
583
|
-
*
|
|
422
|
+
* Result of getting a single request from the queue.
|
|
423
|
+
*
|
|
424
|
+
* `GET /v2/request-queues/{queueId}/requests/{requestId}` answers with the whole request rather than
|
|
425
|
+
* a queue-head projection.
|
|
584
426
|
*/
|
|
585
|
-
export type
|
|
427
|
+
export type RequestQueueClientGetRequestResult = RequestQueueClientRequestSchema;
|
|
586
428
|
/**
|
|
587
429
|
* @since Added in 2.5.1
|
|
588
430
|
*/
|
|
589
431
|
export type RequestQueueRequestsAsyncIterable<T> = AsyncIterable<T>;
|
|
590
|
-
export {};
|