apify-client 3.0.0-beta.11 → 3.0.0-beta.111
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/README.md +16 -2
- package/dist/apify_api_error.d.ts +13 -27
- package/dist/apify_api_error.js +33 -23
- package/dist/apify_client.d.ts +125 -10
- package/dist/apify_client.js +133 -48
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/base/api_client.d.ts +7 -7
- package/dist/base/api_client.js +36 -36
- package/dist/base/resource_client.d.ts +13 -8
- package/dist/base/resource_client.js +60 -34
- package/dist/base/resource_collection_client.d.ts +12 -4
- package/dist/base/resource_collection_client.js +34 -11
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +19 -26
- package/dist/bundle.js +27 -22
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3109 -987
- package/dist/generated/schemas.d.ts +2563 -957
- package/dist/generated/schemas.js +585 -229
- package/dist/http_clients/axios.d.ts +63 -0
- package/dist/http_clients/axios.js +129 -0
- package/dist/http_clients/base.d.ts +397 -0
- package/dist/http_clients/base.js +656 -0
- package/dist/http_clients/index.d.ts +4 -0
- package/dist/http_clients/index.js +2 -0
- package/dist/http_compressors/base.d.ts +40 -0
- package/dist/http_compressors/base.js +9 -0
- package/dist/http_compressors/brotli.d.ts +33 -0
- package/dist/http_compressors/brotli.js +39 -0
- package/dist/http_compressors/gzip.d.ts +33 -0
- package/dist/http_compressors/gzip.js +39 -0
- package/dist/http_compressors/index.d.ts +8 -0
- package/dist/http_compressors/index.js +3 -0
- package/dist/http_compressors/resolve.d.ts +24 -0
- package/dist/http_compressors/resolve.js +30 -0
- package/dist/http_compressors/zstd.d.ts +34 -0
- package/dist/http_compressors/zstd.js +43 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/invalid_response_body_error.d.ts +14 -0
- package/dist/invalid_response_body_error.js +18 -0
- package/dist/models.d.ts +177 -240
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +104 -34
- package/dist/resource_clients/actor.js +129 -55
- package/dist/resource_clients/actor_collection.d.ts +15 -11
- package/dist/resource_clients/actor_collection.js +9 -3
- package/dist/resource_clients/actor_env_var.d.ts +11 -4
- package/dist/resource_clients/actor_env_var.js +16 -6
- package/dist/resource_clients/actor_env_var_collection.d.ts +9 -4
- package/dist/resource_clients/actor_env_var_collection.js +11 -4
- package/dist/resource_clients/actor_server.d.ts +150 -0
- package/dist/resource_clients/actor_server.js +199 -0
- package/dist/resource_clients/actor_version.d.ts +18 -6
- package/dist/resource_clients/actor_version.js +18 -8
- package/dist/resource_clients/actor_version_collection.d.ts +9 -4
- package/dist/resource_clients/actor_version_collection.js +11 -4
- package/dist/resource_clients/build.d.ts +18 -7
- package/dist/resource_clients/build.js +33 -15
- package/dist/resource_clients/build_collection.d.ts +7 -5
- package/dist/resource_clients/build_collection.js +4 -1
- package/dist/resource_clients/dataset.d.ts +83 -36
- package/dist/resource_clients/dataset.js +103 -109
- package/dist/resource_clients/dataset_collection.d.ts +10 -6
- package/dist/resource_clients/dataset_collection.js +13 -2
- package/dist/resource_clients/key_value_store.d.ts +101 -27
- package/dist/resource_clients/key_value_store.js +132 -50
- package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
- package/dist/resource_clients/key_value_store_collection.js +13 -2
- package/dist/resource_clients/log.d.ts +38 -21
- package/dist/resource_clients/log.js +139 -63
- package/dist/resource_clients/request_queue.d.ts +77 -31
- package/dist/resource_clients/request_queue.js +178 -93
- package/dist/resource_clients/request_queue_collection.d.ts +9 -5
- package/dist/resource_clients/request_queue_collection.js +9 -3
- package/dist/resource_clients/run.d.ts +124 -30
- package/dist/resource_clients/run.js +188 -51
- package/dist/resource_clients/run_collection.d.ts +5 -3
- package/dist/resource_clients/run_collection.js +4 -1
- package/dist/resource_clients/schedule.d.ts +15 -6
- package/dist/resource_clients/schedule.js +25 -10
- package/dist/resource_clients/schedule_collection.d.ts +6 -2
- package/dist/resource_clients/schedule_collection.js +9 -3
- package/dist/resource_clients/store_collection.d.ts +6 -4
- package/dist/resource_clients/store_collection.js +4 -1
- package/dist/resource_clients/task.d.ts +35 -12
- package/dist/resource_clients/task.js +75 -35
- package/dist/resource_clients/task_collection.d.ts +9 -5
- package/dist/resource_clients/task_collection.js +9 -3
- package/dist/resource_clients/user.d.ts +16 -7
- package/dist/resource_clients/user.js +34 -16
- package/dist/resource_clients/webhook.d.ts +16 -7
- package/dist/resource_clients/webhook.js +25 -10
- package/dist/resource_clients/webhook_collection.d.ts +8 -4
- package/dist/resource_clients/webhook_collection.js +9 -3
- package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
- package/dist/resource_clients/webhook_dispatch.js +7 -2
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
- package/dist/response_validation_error.d.ts +2 -1
- package/dist/response_validation_error.js +2 -1
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +87 -0
- package/dist/runtime/types.d.ts +60 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +21 -0
- package/dist/schemas.d.ts +370 -4
- package/dist/schemas.js +26 -4
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +2 -2
- package/dist/timeouts.d.ts +84 -0
- package/dist/timeouts.js +37 -0
- package/dist/timezones.d.ts +1 -1
- package/dist/utils.d.ts +87 -61
- package/dist/utils.js +208 -162
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +41 -38
- package/dist/http_client.d.ts +0 -88
- package/dist/http_client.js +0 -255
- package/dist/interceptors.d.ts +0 -19
- package/dist/interceptors.js +0 -105
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TaskListItem } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
5
6
|
import type { Task, TaskUpdateData } from './task.js';
|
|
6
|
-
export type {
|
|
7
|
+
export type { TaskListItem } from '../models.js';
|
|
7
8
|
/**
|
|
8
9
|
* Client for managing the collection of Actor tasks in your account.
|
|
9
10
|
*
|
|
@@ -50,20 +51,23 @@ export declare class TaskCollectionClient extends ResourceCollectionClient {
|
|
|
50
51
|
* ```
|
|
51
52
|
*
|
|
52
53
|
* @param options - Pagination and sorting options.
|
|
54
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
53
55
|
* @returns A paginated iterator of tasks.
|
|
54
56
|
* @see https://docs.apify.com/api/v2/actor-tasks-get
|
|
55
57
|
*/
|
|
56
|
-
list(options?: TaskCollectionListOptions): PaginatedIterator<
|
|
58
|
+
list(options?: TaskCollectionListOptions): PaginatedIterator<TaskListItem>;
|
|
57
59
|
/**
|
|
58
60
|
* Creates a new task.
|
|
59
61
|
*
|
|
60
62
|
* @param task - The task data.
|
|
63
|
+
* @param options - Request options
|
|
64
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
61
65
|
* @returns The created task object.
|
|
62
66
|
* @see https://docs.apify.com/api/v2/actor-tasks-post
|
|
63
67
|
*/
|
|
64
|
-
create(task: TaskCreateData): Promise<Task>;
|
|
68
|
+
create(task: TaskCreateData, options?: TimeoutOptions): Promise<Task>;
|
|
65
69
|
}
|
|
66
|
-
export interface TaskCollectionListOptions extends PaginationOptions {
|
|
70
|
+
export interface TaskCollectionListOptions extends PaginationOptions, TimeoutOptions {
|
|
67
71
|
desc?: boolean;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
3
|
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
4
5
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
6
|
const listOptionsSchema = z.strictObject({
|
|
6
7
|
...paginationOptionsShape,
|
|
7
8
|
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
8
10
|
});
|
|
9
11
|
/**
|
|
10
12
|
* Client for managing the collection of Actor tasks in your account.
|
|
@@ -57,22 +59,26 @@ export class TaskCollectionClient extends ResourceCollectionClient {
|
|
|
57
59
|
* ```
|
|
58
60
|
*
|
|
59
61
|
* @param options - Pagination and sorting options.
|
|
62
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
60
63
|
* @returns A paginated iterator of tasks.
|
|
61
64
|
* @see https://docs.apify.com/api/v2/actor-tasks-get
|
|
62
65
|
*/
|
|
63
66
|
list(options = {}) {
|
|
64
67
|
const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
|
|
65
|
-
return this.
|
|
68
|
+
return this.listResourcesPaginated(schemas.ListOfTasks(), parsed, 'medium');
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* Creates a new task.
|
|
69
72
|
*
|
|
70
73
|
* @param task - The task data.
|
|
74
|
+
* @param options - Request options
|
|
75
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
71
76
|
* @returns The created task object.
|
|
72
77
|
* @see https://docs.apify.com/api/v2/actor-tasks-post
|
|
73
78
|
*/
|
|
74
|
-
async create(task) {
|
|
79
|
+
async create(task, options = {}) {
|
|
75
80
|
parseArgument(task, anyObjectSchema);
|
|
76
|
-
|
|
81
|
+
const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
82
|
+
return this.createResource(schemas.Task(), task, timeoutSecs, signal);
|
|
77
83
|
}
|
|
78
84
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { AccountLimits, MonthlyUsage, UserPrivateInfo } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
5
|
+
export type { AccountLimits, CurrentUsage, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, UserPlan, PriceTier, UserProfile, ProxyResource, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, UserPrivateInfo, } from '../models.js';
|
|
5
6
|
export { PlatformFeature } from '../models.js';
|
|
6
7
|
/**
|
|
7
8
|
* Client for managing user account information.
|
|
@@ -38,34 +39,42 @@ export declare class UserClient extends ResourceClient {
|
|
|
38
39
|
* Depending on whether ApifyClient was created with a token,
|
|
39
40
|
* the method will either return public or private user data.
|
|
40
41
|
*
|
|
42
|
+
* @param options - Request options
|
|
43
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
41
44
|
* @returns The user object, or `undefined` if it does not exist.
|
|
42
45
|
* @see https://docs.apify.com/api/v2/user-get
|
|
43
46
|
*/
|
|
44
|
-
get(): Promise<
|
|
47
|
+
get(options?: TimeoutOptions): Promise<UserPrivateInfo | undefined>;
|
|
45
48
|
/**
|
|
46
49
|
* Retrieves the user's monthly usage data.
|
|
47
50
|
*
|
|
51
|
+
* @param options - Request options
|
|
52
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
48
53
|
* @returns The monthly usage object.
|
|
49
54
|
* @see https://docs.apify.com/api/v2/users-me-usage-monthly-get
|
|
50
55
|
* @since Added in 2.9.2
|
|
51
56
|
*/
|
|
52
|
-
monthlyUsage(): Promise<MonthlyUsage>;
|
|
57
|
+
monthlyUsage(options?: TimeoutOptions): Promise<MonthlyUsage>;
|
|
53
58
|
/**
|
|
54
59
|
* Retrieves the user's account and usage limits.
|
|
55
60
|
*
|
|
61
|
+
* @param options - Request options
|
|
62
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
56
63
|
* @returns The account and usage limits object.
|
|
57
64
|
* @see https://docs.apify.com/api/v2/users-me-limits-get
|
|
58
65
|
* @since Added in 2.9.2
|
|
59
66
|
*/
|
|
60
|
-
limits(): Promise<
|
|
67
|
+
limits(options?: TimeoutOptions): Promise<AccountLimits>;
|
|
61
68
|
/**
|
|
62
69
|
* Updates the user's account and usage limits.
|
|
63
70
|
*
|
|
64
|
-
* @param
|
|
71
|
+
* @param newLimits - The new limits to set.
|
|
72
|
+
* @param options - Request options
|
|
73
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
65
74
|
* @see https://docs.apify.com/api/v2/users-me-limits-put
|
|
66
75
|
* @since Added in 2.10.0
|
|
67
76
|
*/
|
|
68
|
-
updateLimits(
|
|
77
|
+
updateLimits(newLimits: LimitsUpdateOptions, options?: TimeoutOptions): Promise<void>;
|
|
69
78
|
}
|
|
70
79
|
/**
|
|
71
80
|
* @since Added in 2.10.0
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourceClient } from '../base/resource_client.js';
|
|
2
2
|
import * as schemas from '../schemas.js';
|
|
3
|
-
import {
|
|
3
|
+
import { timeoutOptionsSchema } from '../timeouts.js';
|
|
4
|
+
import { parseArgument, parseResponse } from '../utils.js';
|
|
4
5
|
export { PlatformFeature } from '../models.js';
|
|
5
6
|
/**
|
|
6
7
|
* Client for managing user account information.
|
|
@@ -42,56 +43,73 @@ export class UserClient extends ResourceClient {
|
|
|
42
43
|
* Depending on whether ApifyClient was created with a token,
|
|
43
44
|
* the method will either return public or private user data.
|
|
44
45
|
*
|
|
46
|
+
* @param options - Request options
|
|
47
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
45
48
|
* @returns The user object, or `undefined` if it does not exist.
|
|
46
49
|
* @see https://docs.apify.com/api/v2/user-get
|
|
47
50
|
*/
|
|
48
|
-
async get() {
|
|
49
|
-
|
|
51
|
+
async get(options = {}) {
|
|
52
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
53
|
+
return this.getResource(schemas.UserPrivateInfo(), {}, timeoutSecs, signal);
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
52
56
|
* Retrieves the user's monthly usage data.
|
|
53
57
|
*
|
|
58
|
+
* @param options - Request options
|
|
59
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
54
60
|
* @returns The monthly usage object.
|
|
55
61
|
* @see https://docs.apify.com/api/v2/users-me-usage-monthly-get
|
|
56
62
|
* @since Added in 2.9.2
|
|
57
63
|
*/
|
|
58
|
-
async monthlyUsage() {
|
|
64
|
+
async monthlyUsage(options = {}) {
|
|
65
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
59
66
|
const response = await this.httpClient.call({
|
|
60
|
-
url: this.
|
|
67
|
+
url: this.buildUrl('usage/monthly'),
|
|
61
68
|
method: 'GET',
|
|
62
|
-
params: this.
|
|
69
|
+
params: this.buildParams(),
|
|
70
|
+
timeoutSecs,
|
|
71
|
+
signal,
|
|
63
72
|
});
|
|
64
|
-
|
|
65
|
-
return parseResponse(response, schemas.MonthlyUsage(), (key) => key === 'date');
|
|
73
|
+
return parseResponse(response, schemas.MonthlyUsage());
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* Retrieves the user's account and usage limits.
|
|
69
77
|
*
|
|
78
|
+
* @param options - Request options
|
|
79
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
70
80
|
* @returns The account and usage limits object.
|
|
71
81
|
* @see https://docs.apify.com/api/v2/users-me-limits-get
|
|
72
82
|
* @since Added in 2.9.2
|
|
73
83
|
*/
|
|
74
|
-
async limits() {
|
|
84
|
+
async limits(options = {}) {
|
|
85
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
75
86
|
const response = await this.httpClient.call({
|
|
76
|
-
url: this.
|
|
87
|
+
url: this.buildUrl('limits'),
|
|
77
88
|
method: 'GET',
|
|
78
|
-
params: this.
|
|
89
|
+
params: this.buildParams(),
|
|
90
|
+
timeoutSecs,
|
|
91
|
+
signal,
|
|
79
92
|
});
|
|
80
93
|
return parseResponse(response, schemas.AccountLimits());
|
|
81
94
|
}
|
|
82
95
|
/**
|
|
83
96
|
* Updates the user's account and usage limits.
|
|
84
97
|
*
|
|
85
|
-
* @param
|
|
98
|
+
* @param newLimits - The new limits to set.
|
|
99
|
+
* @param options - Request options
|
|
100
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
86
101
|
* @see https://docs.apify.com/api/v2/users-me-limits-put
|
|
87
102
|
* @since Added in 2.10.0
|
|
88
103
|
*/
|
|
89
|
-
async updateLimits(options) {
|
|
104
|
+
async updateLimits(newLimits, options = {}) {
|
|
105
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
90
106
|
const requestOpts = {
|
|
91
|
-
url: this.
|
|
107
|
+
url: this.buildUrl('limits'),
|
|
92
108
|
method: 'PUT',
|
|
93
|
-
params: this.
|
|
94
|
-
data:
|
|
109
|
+
params: this.buildParams(),
|
|
110
|
+
data: newLimits,
|
|
111
|
+
timeoutSecs,
|
|
112
|
+
signal,
|
|
95
113
|
};
|
|
96
114
|
await this.httpClient.call(requestOpts);
|
|
97
115
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { WebhookResource, WebhookEventType } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
import type { WebhookDispatch } from './webhook_dispatch.js';
|
|
5
6
|
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
|
|
6
|
-
export type {
|
|
7
|
+
export type { WebhookLastDispatch, WebhookResource, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookStats, } from '../models.js';
|
|
7
8
|
/**
|
|
8
9
|
* Client for managing a specific webhook.
|
|
9
10
|
*
|
|
@@ -40,31 +41,39 @@ export declare class WebhookClient extends ResourceClient {
|
|
|
40
41
|
/**
|
|
41
42
|
* Retrieves the webhook.
|
|
42
43
|
*
|
|
44
|
+
* @param options - Request options
|
|
45
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
43
46
|
* @returns The webhook object, or `undefined` if it does not exist.
|
|
44
47
|
* @see https://docs.apify.com/api/v2/webhook-get
|
|
45
48
|
*/
|
|
46
|
-
get(): Promise<
|
|
49
|
+
get(options?: TimeoutOptions): Promise<WebhookResource | undefined>;
|
|
47
50
|
/**
|
|
48
51
|
* Updates the webhook with the specified fields.
|
|
49
52
|
*
|
|
50
53
|
* @param newFields - Fields to update.
|
|
54
|
+
* @param options - Request options
|
|
55
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
51
56
|
* @returns The updated webhook object.
|
|
52
57
|
* @see https://docs.apify.com/api/v2/webhook-put
|
|
53
58
|
*/
|
|
54
|
-
update(newFields: WebhookUpdateData): Promise<
|
|
59
|
+
update(newFields: WebhookUpdateData, options?: TimeoutOptions): Promise<WebhookResource>;
|
|
55
60
|
/**
|
|
56
61
|
* Deletes the webhook.
|
|
57
62
|
*
|
|
63
|
+
* @param options - Request options
|
|
64
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
58
65
|
* @see https://docs.apify.com/api/v2/webhook-delete
|
|
59
66
|
*/
|
|
60
|
-
delete(): Promise<void>;
|
|
67
|
+
delete(options?: TimeoutOptions): Promise<void>;
|
|
61
68
|
/**
|
|
62
69
|
* Tests the webhook by dispatching a test event.
|
|
63
70
|
*
|
|
71
|
+
* @param options - Request options
|
|
72
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
64
73
|
* @returns The webhook dispatch object.
|
|
65
74
|
* @see https://docs.apify.com/api/v2/webhook-test-post
|
|
66
75
|
*/
|
|
67
|
-
test(): Promise<WebhookDispatch>;
|
|
76
|
+
test(options?: TimeoutOptions): Promise<WebhookDispatch>;
|
|
68
77
|
/**
|
|
69
78
|
* Returns a client for the dispatches of this webhook.
|
|
70
79
|
*
|
|
@@ -79,6 +88,6 @@ export interface WebhookIdempotencyKey {
|
|
|
79
88
|
/**
|
|
80
89
|
* Data for updating a webhook.
|
|
81
90
|
*/
|
|
82
|
-
export type WebhookUpdateData = Partial<Pick<
|
|
91
|
+
export type WebhookUpdateData = Partial<Pick<WebhookResource, 'isAdHoc' | 'condition' | 'ignoreSslErrors' | 'doNotRetry' | 'requestUrl' | 'payloadTemplate' | 'shouldInterpolateStrings' | 'isApifyIntegration' | 'headersTemplate' | 'description'> & {
|
|
83
92
|
eventTypes: readonly WebhookEventType[];
|
|
84
93
|
}> & WebhookIdempotencyKey;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ResourceClient } from '../base/resource_client.js';
|
|
2
2
|
import * as schemas from '../schemas.js';
|
|
3
|
+
import { timeoutOptionsSchema } from '../timeouts.js';
|
|
3
4
|
import { anyObjectSchema, parseArgument, parseResponse } from '../utils.js';
|
|
4
5
|
import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
|
|
5
6
|
/**
|
|
@@ -43,42 +44,56 @@ export class WebhookClient extends ResourceClient {
|
|
|
43
44
|
/**
|
|
44
45
|
* Retrieves the webhook.
|
|
45
46
|
*
|
|
47
|
+
* @param options - Request options
|
|
48
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
46
49
|
* @returns The webhook object, or `undefined` if it does not exist.
|
|
47
50
|
* @see https://docs.apify.com/api/v2/webhook-get
|
|
48
51
|
*/
|
|
49
|
-
async get() {
|
|
50
|
-
|
|
52
|
+
async get(options = {}) {
|
|
53
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
54
|
+
return this.getResource(schemas.WebhookResource(), {}, timeoutSecs, signal);
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Updates the webhook with the specified fields.
|
|
54
58
|
*
|
|
55
59
|
* @param newFields - Fields to update.
|
|
60
|
+
* @param options - Request options
|
|
61
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
56
62
|
* @returns The updated webhook object.
|
|
57
63
|
* @see https://docs.apify.com/api/v2/webhook-put
|
|
58
64
|
*/
|
|
59
|
-
async update(newFields) {
|
|
65
|
+
async update(newFields, options = {}) {
|
|
60
66
|
parseArgument(newFields, anyObjectSchema);
|
|
61
|
-
|
|
67
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
68
|
+
return this.updateResource(schemas.WebhookResource(), newFields, timeoutSecs, signal);
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* Deletes the webhook.
|
|
65
72
|
*
|
|
73
|
+
* @param options - Request options
|
|
74
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
66
75
|
* @see https://docs.apify.com/api/v2/webhook-delete
|
|
67
76
|
*/
|
|
68
|
-
async delete() {
|
|
69
|
-
|
|
77
|
+
async delete(options = {}) {
|
|
78
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
79
|
+
return this.deleteResource(timeoutSecs, signal);
|
|
70
80
|
}
|
|
71
81
|
/**
|
|
72
82
|
* Tests the webhook by dispatching a test event.
|
|
73
83
|
*
|
|
84
|
+
* @param options - Request options
|
|
85
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
74
86
|
* @returns The webhook dispatch object.
|
|
75
87
|
* @see https://docs.apify.com/api/v2/webhook-test-post
|
|
76
88
|
*/
|
|
77
|
-
async test() {
|
|
89
|
+
async test(options = {}) {
|
|
90
|
+
const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
78
91
|
const response = await this.httpClient.call({
|
|
79
|
-
url: this.
|
|
92
|
+
url: this.buildUrl('test'),
|
|
80
93
|
method: 'POST',
|
|
81
|
-
params: this.
|
|
94
|
+
params: this.buildParams(),
|
|
95
|
+
timeoutSecs,
|
|
96
|
+
signal,
|
|
82
97
|
});
|
|
83
98
|
return parseResponse(response, schemas.WebhookDispatch());
|
|
84
99
|
}
|
|
@@ -89,7 +104,7 @@ export class WebhookClient extends ResourceClient {
|
|
|
89
104
|
* @see https://docs.apify.com/api/v2/webhook-webhook-dispatches-get
|
|
90
105
|
*/
|
|
91
106
|
dispatches() {
|
|
92
|
-
return new WebhookDispatchCollectionClient(this.
|
|
107
|
+
return new WebhookDispatchCollectionClient(this.subResourceOptions({
|
|
93
108
|
resourcePath: 'dispatches',
|
|
94
109
|
}));
|
|
95
110
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
3
4
|
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
4
|
-
import type {
|
|
5
|
+
import type { WebhookResource, WebhookUpdateData } from './webhook.js';
|
|
5
6
|
/**
|
|
6
7
|
* Client for managing the collection of Webhooks.
|
|
7
8
|
*
|
|
@@ -47,19 +48,22 @@ export declare class WebhookCollectionClient extends ResourceCollectionClient {
|
|
|
47
48
|
* ```
|
|
48
49
|
*
|
|
49
50
|
* @param options - Pagination and sorting options.
|
|
51
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
50
52
|
* @returns A paginated iterator of webhooks.
|
|
51
53
|
* @see https://docs.apify.com/api/v2/webhooks-get
|
|
52
54
|
*/
|
|
53
|
-
list(options?: WebhookCollectionListOptions): PaginatedIterator<Omit<
|
|
55
|
+
list(options?: WebhookCollectionListOptions): PaginatedIterator<Omit<WebhookResource, 'payloadTemplate' | 'headersTemplate'>>;
|
|
54
56
|
/**
|
|
55
57
|
* Creates a new webhook.
|
|
56
58
|
*
|
|
57
59
|
* @param webhook - The webhook data.
|
|
60
|
+
* @param options - Request options
|
|
61
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
58
62
|
* @returns The created webhook object.
|
|
59
63
|
* @see https://docs.apify.com/api/v2/webhooks-post
|
|
60
64
|
*/
|
|
61
|
-
create(webhook?: WebhookUpdateData): Promise<
|
|
65
|
+
create(webhook?: WebhookUpdateData, options?: TimeoutOptions): Promise<WebhookResource>;
|
|
62
66
|
}
|
|
63
|
-
export interface WebhookCollectionListOptions extends PaginationOptions {
|
|
67
|
+
export interface WebhookCollectionListOptions extends PaginationOptions, TimeoutOptions {
|
|
64
68
|
desc?: boolean;
|
|
65
69
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
3
|
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
4
5
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
6
|
const listOptionsSchema = z.strictObject({
|
|
6
7
|
...paginationOptionsShape,
|
|
7
8
|
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
8
10
|
});
|
|
9
11
|
const webhookCreateSchema = anyObjectSchema.optional();
|
|
10
12
|
/**
|
|
@@ -57,22 +59,26 @@ export class WebhookCollectionClient extends ResourceCollectionClient {
|
|
|
57
59
|
* ```
|
|
58
60
|
*
|
|
59
61
|
* @param options - Pagination and sorting options.
|
|
62
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
60
63
|
* @returns A paginated iterator of webhooks.
|
|
61
64
|
* @see https://docs.apify.com/api/v2/webhooks-get
|
|
62
65
|
*/
|
|
63
66
|
list(options = {}) {
|
|
64
67
|
const parsed = parseArgument(options, listOptionsSchema, 'WebhookCollectionListOptions');
|
|
65
|
-
return this.
|
|
68
|
+
return this.listResourcesPaginated(schemas.ListOfWebhooks(), parsed, 'medium');
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* Creates a new webhook.
|
|
69
72
|
*
|
|
70
73
|
* @param webhook - The webhook data.
|
|
74
|
+
* @param options - Request options
|
|
75
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
71
76
|
* @returns The created webhook object.
|
|
72
77
|
* @see https://docs.apify.com/api/v2/webhooks-post
|
|
73
78
|
*/
|
|
74
|
-
async create(webhook) {
|
|
79
|
+
async create(webhook, options = {}) {
|
|
75
80
|
parseArgument(webhook, webhookCreateSchema);
|
|
76
|
-
|
|
81
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
82
|
+
return this.createResource(schemas.WebhookResource(), webhook, timeoutSecs, signal);
|
|
77
83
|
}
|
|
78
84
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
3
|
import type { WebhookDispatch } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models.js';
|
|
5
6
|
export { WebhookDispatchStatus } from '../models.js';
|
|
6
7
|
/**
|
|
@@ -29,8 +30,10 @@ export declare class WebhookDispatchClient extends ResourceClient {
|
|
|
29
30
|
/**
|
|
30
31
|
* Retrieves the webhook dispatch.
|
|
31
32
|
*
|
|
33
|
+
* @param options - Request options
|
|
34
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
32
35
|
* @returns The webhook dispatch object, or `undefined` if it does not exist.
|
|
33
36
|
* @see https://docs.apify.com/api/v2/webhook-dispatch-get
|
|
34
37
|
*/
|
|
35
|
-
get(): Promise<WebhookDispatch | undefined>;
|
|
38
|
+
get(options?: TimeoutOptions): Promise<WebhookDispatch | undefined>;
|
|
36
39
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ResourceClient } from '../base/resource_client.js';
|
|
2
2
|
import * as schemas from '../schemas.js';
|
|
3
|
+
import { timeoutOptionsSchema } from '../timeouts.js';
|
|
4
|
+
import { parseArgument } from '../utils.js';
|
|
3
5
|
export { WebhookDispatchStatus } from '../models.js';
|
|
4
6
|
/**
|
|
5
7
|
* Client for managing a specific webhook dispatch.
|
|
@@ -32,10 +34,13 @@ export class WebhookDispatchClient extends ResourceClient {
|
|
|
32
34
|
/**
|
|
33
35
|
* Retrieves the webhook dispatch.
|
|
34
36
|
*
|
|
37
|
+
* @param options - Request options
|
|
38
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
35
39
|
* @returns The webhook dispatch object, or `undefined` if it does not exist.
|
|
36
40
|
* @see https://docs.apify.com/api/v2/webhook-dispatch-get
|
|
37
41
|
*/
|
|
38
|
-
async get() {
|
|
39
|
-
|
|
42
|
+
async get(options = {}) {
|
|
43
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
44
|
+
return this.getResource(schemas.WebhookDispatch(), {}, timeoutSecs, signal);
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
3
4
|
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
4
5
|
import type { WebhookDispatch } from './webhook_dispatch.js';
|
|
5
6
|
/**
|
|
@@ -42,11 +43,12 @@ export declare class WebhookDispatchCollectionClient extends ResourceCollectionC
|
|
|
42
43
|
* ```
|
|
43
44
|
*
|
|
44
45
|
* @param options - Pagination and sorting options.
|
|
46
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
45
47
|
* @returns A paginated iterator of webhook dispatches.
|
|
46
48
|
* @see https://docs.apify.com/api/v2/webhook-dispatches-get
|
|
47
49
|
*/
|
|
48
50
|
list(options?: WebhookDispatchCollectionListOptions): PaginatedIterator<WebhookDispatch>;
|
|
49
51
|
}
|
|
50
|
-
export interface WebhookDispatchCollectionListOptions extends PaginationOptions {
|
|
52
|
+
export interface WebhookDispatchCollectionListOptions extends PaginationOptions, TimeoutOptions {
|
|
51
53
|
desc?: boolean;
|
|
52
54
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
3
|
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsShape } from '../timeouts.js';
|
|
4
5
|
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
6
|
const listOptionsSchema = z.strictObject({
|
|
6
7
|
...paginationOptionsShape,
|
|
7
8
|
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
8
10
|
});
|
|
9
11
|
/**
|
|
10
12
|
* Client for managing the collection of webhook dispatches.
|
|
@@ -51,11 +53,12 @@ export class WebhookDispatchCollectionClient extends ResourceCollectionClient {
|
|
|
51
53
|
* ```
|
|
52
54
|
*
|
|
53
55
|
* @param options - Pagination and sorting options.
|
|
56
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
54
57
|
* @returns A paginated iterator of webhook dispatches.
|
|
55
58
|
* @see https://docs.apify.com/api/v2/webhook-dispatches-get
|
|
56
59
|
*/
|
|
57
60
|
list(options = {}) {
|
|
58
61
|
const parsed = parseArgument(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
|
|
59
|
-
return this.
|
|
62
|
+
return this.listResourcesPaginated(schemas.ListOfWebhookDispatches(), parsed, 'medium');
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
+
import { ApifyClientError } from './apify_client_error.js';
|
|
2
3
|
/**
|
|
3
4
|
* Thrown when an API response does not match the schema the client expects for it.
|
|
4
5
|
*
|
|
@@ -12,7 +13,7 @@ import type { z } from 'zod';
|
|
|
12
13
|
* {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
|
|
13
14
|
* for programmatic inspection.
|
|
14
15
|
*/
|
|
15
|
-
export declare class ResponseValidationError extends
|
|
16
|
+
export declare class ResponseValidationError extends ApifyClientError {
|
|
16
17
|
/** Structured issues from the underlying schema check. */
|
|
17
18
|
readonly issues: z.ZodError['issues'];
|
|
18
19
|
/** HTTP method of the request whose response failed validation, upper-cased. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ArgumentValidationError } from '@apify/validations';
|
|
2
|
+
import { ApifyClientError } from './apify_client_error.js';
|
|
2
3
|
const REPORT_HINT = 'The API returned something its OpenAPI specification does not describe. ' +
|
|
3
4
|
'Please report this at https://github.com/apify/apify-client-js/issues.';
|
|
4
5
|
/**
|
|
@@ -14,7 +15,7 @@ const REPORT_HINT = 'The API returned something its OpenAPI specification does n
|
|
|
14
15
|
* {@link https://zod.dev | zod} issues are available on `issues`, and the original `ZodError` on `cause`,
|
|
15
16
|
* for programmatic inspection.
|
|
16
17
|
*/
|
|
17
|
-
export class ResponseValidationError extends
|
|
18
|
+
export class ResponseValidationError extends ApifyClientError {
|
|
18
19
|
/** Structured issues from the underlying schema check. */
|
|
19
20
|
issues;
|
|
20
21
|
/** HTTP method of the request whose response failed validation, upper-cased. */
|