apify-client 3.0.0-beta.9 → 3.0.0-rc.0
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 +10 -2
- package/dist/apify_api_error.d.ts +11 -26
- package/dist/apify_api_error.js +31 -22
- package/dist/apify_client.d.ts +125 -10
- package/dist/apify_client.js +133 -48
- package/dist/base/api_client.d.ts +7 -7
- package/dist/base/api_client.js +36 -24
- package/dist/base/resource_client.d.ts +21 -8
- package/dist/base/resource_client.js +67 -33
- 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 +785 -290
- package/dist/generated/schemas.d.ts +720 -747
- package/dist/generated/schemas.js +166 -162
- package/dist/http_clients/axios.d.ts +60 -0
- package/dist/http_clients/axios.js +117 -0
- package/dist/http_clients/base.d.ts +331 -0
- package/dist/http_clients/base.js +563 -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 +6 -0
- package/dist/http_compressors/index.js +2 -0
- package/dist/http_compressors/resolve.d.ts +23 -0
- package/dist/http_compressors/resolve.js +27 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/invalid_response_body_error.d.ts +13 -0
- package/dist/invalid_response_body_error.js +17 -0
- package/dist/models.d.ts +162 -194
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +74 -34
- package/dist/resource_clients/actor.js +87 -56
- package/dist/resource_clients/actor_collection.d.ts +18 -12
- package/dist/resource_clients/actor_collection.js +11 -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_version.d.ts +20 -5
- package/dist/resource_clients/actor_version.js +19 -9
- package/dist/resource_clients/actor_version_collection.d.ts +11 -4
- package/dist/resource_clients/actor_version_collection.js +13 -4
- package/dist/resource_clients/build.d.ts +20 -7
- package/dist/resource_clients/build.js +35 -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 +53 -35
- package/dist/resource_clients/dataset.js +105 -80
- 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 +62 -20
- package/dist/resource_clients/key_value_store.js +78 -40
- 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 +13 -20
- package/dist/resource_clients/log.js +141 -59
- package/dist/resource_clients/request_queue.d.ts +68 -31
- package/dist/resource_clients/request_queue.js +173 -91
- 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 +119 -28
- package/dist/resource_clients/run.js +190 -49
- 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 +16 -7
- package/dist/resource_clients/schedule.js +30 -22
- 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 +36 -13
- package/dist/resource_clients/task.js +79 -46
- 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 +19 -10
- package/dist/resource_clients/user.js +42 -38
- package/dist/resource_clients/webhook.d.ts +17 -8
- package/dist/resource_clients/webhook.js +30 -22
- 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/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +49 -0
- package/dist/runtime/types.d.ts +52 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +18 -0
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- 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 +82 -45
- package/dist/utils.js +197 -146
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +32 -29
- 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
|
@@ -2,7 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
|
|
3
3
|
import { ResourceClient } from '../base/resource_client.js';
|
|
4
4
|
import * as schemas from '../schemas.js';
|
|
5
|
-
import {
|
|
5
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
6
|
+
import { anyObjectSchema, cast, isStream, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
|
|
7
|
+
import { startWaitingForResources } from '../wait_for_resources.js';
|
|
6
8
|
import { RunClient } from './run.js';
|
|
7
9
|
import { RunCollectionClient } from './run_collection.js';
|
|
8
10
|
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
@@ -10,22 +12,26 @@ const inputSchema = anyObjectSchema.optional();
|
|
|
10
12
|
const startOptionsSchema = z.strictObject({
|
|
11
13
|
build: z.string().optional(),
|
|
12
14
|
memory: z.number().optional(),
|
|
13
|
-
|
|
15
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
14
16
|
waitForFinish: z.number().optional(),
|
|
15
17
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
16
18
|
maxItems: z.number().min(0).optional(),
|
|
17
19
|
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
18
20
|
restartOnError: z.boolean().optional(),
|
|
21
|
+
waitForResources: z.union([z.boolean(), z.number().min(0)]).optional(),
|
|
22
|
+
...timeoutOptionsShape,
|
|
19
23
|
});
|
|
20
24
|
const callOptionsSchema = z.strictObject({
|
|
21
25
|
build: z.string().optional(),
|
|
22
26
|
memory: z.number().optional(),
|
|
23
|
-
|
|
27
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
24
28
|
waitSecs: z.number().min(0).optional(),
|
|
25
29
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
26
30
|
maxItems: z.number().min(0).optional(),
|
|
27
31
|
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
28
32
|
restartOnError: z.boolean().optional(),
|
|
33
|
+
waitForResources: z.union([z.boolean(), z.number().min(0)]).optional(),
|
|
34
|
+
...timeoutOptionsShape,
|
|
29
35
|
});
|
|
30
36
|
const lastRunOptionsSchema = z.strictObject({
|
|
31
37
|
status: z.enum(ACT_JOB_STATUSES).optional(),
|
|
@@ -64,22 +70,28 @@ export class TaskClient extends ResourceClient {
|
|
|
64
70
|
/**
|
|
65
71
|
* Retrieves the Actor task.
|
|
66
72
|
*
|
|
73
|
+
* @param options - Request options
|
|
74
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
67
75
|
* @returns The task object, or `undefined` if it does not exist.
|
|
68
76
|
* @see https://docs.apify.com/api/v2/actor-task-get
|
|
69
77
|
*/
|
|
70
|
-
async get() {
|
|
71
|
-
|
|
78
|
+
async get(options = {}) {
|
|
79
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
80
|
+
return this.getResource(schemas.Task(), {}, timeoutSecs, signal);
|
|
72
81
|
}
|
|
73
82
|
/**
|
|
74
83
|
* Updates the task with the specified fields.
|
|
75
84
|
*
|
|
76
85
|
* @param newFields - Fields to update.
|
|
86
|
+
* @param options - Request options
|
|
87
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
77
88
|
* @returns The updated task object.
|
|
78
89
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
79
90
|
*/
|
|
80
|
-
async update(newFields) {
|
|
91
|
+
async update(newFields, options = {}) {
|
|
81
92
|
parseArgument(newFields, anyObjectSchema);
|
|
82
|
-
|
|
93
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
94
|
+
return this.updateResource(schemas.Task(), newFields, timeoutSecs, signal);
|
|
83
95
|
}
|
|
84
96
|
/**
|
|
85
97
|
* Publishes the task on its public landing page, by setting `isPublic` through
|
|
@@ -89,12 +101,14 @@ export class TaskClient extends ResourceClient {
|
|
|
89
101
|
* (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
|
|
90
102
|
* Publishing an already published task does nothing.
|
|
91
103
|
*
|
|
104
|
+
* @param options - Request options
|
|
105
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
92
106
|
* @returns The task object.
|
|
93
107
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
94
108
|
* @since Added in 2.25.0
|
|
95
109
|
*/
|
|
96
|
-
async publish() {
|
|
97
|
-
return this.update({ isPublic: true });
|
|
110
|
+
async publish(options = {}) {
|
|
111
|
+
return this.update({ isPublic: true }, options);
|
|
98
112
|
}
|
|
99
113
|
/**
|
|
100
114
|
* Unpublishes the task from its public landing page, by setting `isPublic` through
|
|
@@ -104,20 +118,25 @@ export class TaskClient extends ResourceClient {
|
|
|
104
118
|
* published again without re-entering it. Requires write permission to both the task and its
|
|
105
119
|
* Actor. Unpublishing a task that is not published does nothing.
|
|
106
120
|
*
|
|
121
|
+
* @param options - Request options
|
|
122
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
107
123
|
* @returns The task object.
|
|
108
124
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
109
125
|
* @since Added in 2.25.0
|
|
110
126
|
*/
|
|
111
|
-
async unpublish() {
|
|
112
|
-
return this.update({ isPublic: false });
|
|
127
|
+
async unpublish(options = {}) {
|
|
128
|
+
return this.update({ isPublic: false }, options);
|
|
113
129
|
}
|
|
114
130
|
/**
|
|
115
131
|
* Deletes the Task.
|
|
116
132
|
*
|
|
133
|
+
* @param options - Request options
|
|
134
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
117
135
|
* @see https://docs.apify.com/api/v2/actor-task-delete
|
|
118
136
|
*/
|
|
119
|
-
async delete() {
|
|
120
|
-
|
|
137
|
+
async delete(options = {}) {
|
|
138
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
139
|
+
return this.deleteResource(timeoutSecs, signal);
|
|
121
140
|
}
|
|
122
141
|
/**
|
|
123
142
|
* Starts an Actor task and immediately returns the Run object.
|
|
@@ -126,22 +145,27 @@ export class TaskClient extends ResourceClient {
|
|
|
126
145
|
* @param options - Run options.
|
|
127
146
|
* @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
|
|
128
147
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
129
|
-
* @param options.
|
|
148
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
|
|
130
149
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
|
|
131
150
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
132
151
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
133
152
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
134
153
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
154
|
+
* @param options.waitForResources - Retry the start while the account lacks the memory or a concurrent-run slot for
|
|
155
|
+
* the run. `true` retries until the run starts, a number stops retrying after that many seconds.
|
|
156
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
|
|
157
|
+
* when the API is asked to hold the response.
|
|
135
158
|
* @returns The Actor Run object.
|
|
136
159
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
137
160
|
*/
|
|
138
161
|
async start(input, options = {}) {
|
|
139
162
|
parseArgument(input, inputSchema);
|
|
140
163
|
const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
|
|
141
|
-
const { waitForFinish,
|
|
164
|
+
const { waitForFinish, runTimeoutSecs, memory, build, maxItems, maxTotalChargeUsd, restartOnError, waitForResources, timeoutSecs, signal, } = parsed;
|
|
165
|
+
// The API's `timeout` parameter bounds the run, not the request.
|
|
142
166
|
const params = {
|
|
143
167
|
waitForFinish,
|
|
144
|
-
timeout,
|
|
168
|
+
timeout: runTimeoutSecs,
|
|
145
169
|
memory,
|
|
146
170
|
build,
|
|
147
171
|
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
@@ -150,18 +174,20 @@ export class TaskClient extends ResourceClient {
|
|
|
150
174
|
restartOnError,
|
|
151
175
|
};
|
|
152
176
|
const request = {
|
|
153
|
-
url: this.
|
|
177
|
+
url: this.buildUrl('runs'),
|
|
154
178
|
method: 'POST',
|
|
155
179
|
data: input,
|
|
156
|
-
params: this.
|
|
157
|
-
//
|
|
158
|
-
// to stringify functions to JSON, instead of omitting them.
|
|
180
|
+
params: this.buildParams(params),
|
|
181
|
+
// Actor input may carry page functions, which plain JSON serialization would drop.
|
|
159
182
|
stringifyFunctions: true,
|
|
160
183
|
headers: {
|
|
161
184
|
'Content-Type': 'application/json',
|
|
162
185
|
},
|
|
186
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', waitForFinish),
|
|
187
|
+
signal,
|
|
163
188
|
};
|
|
164
|
-
|
|
189
|
+
// A `Readable` input is consumed by the first attempt, so a retry would start the run with an empty input.
|
|
190
|
+
const response = await startWaitingForResources(async () => this.httpClient.call(request), isStream(input) ? false : waitForResources, this.httpClient.logger, signal);
|
|
165
191
|
return parseResponse(response, schemas.Run());
|
|
166
192
|
}
|
|
167
193
|
/**
|
|
@@ -172,59 +198,66 @@ export class TaskClient extends ResourceClient {
|
|
|
172
198
|
* @param options - Run and wait options.
|
|
173
199
|
* @param options.build - Tag or number of the Actor build to run.
|
|
174
200
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
175
|
-
* @param options.
|
|
201
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds.
|
|
176
202
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
177
203
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
178
204
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
179
205
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
180
206
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
207
|
+
* @param options.waitForResources - Retry the start while the account lacks the memory or a concurrent-run slot for
|
|
208
|
+
* the run. `true` retries until the run starts, a number stops retrying after that many seconds. The time spent
|
|
209
|
+
* retrying doesn't count toward `waitSecs`.
|
|
210
|
+
* @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
|
|
181
211
|
* @returns The Actor run object.
|
|
182
212
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
183
213
|
*/
|
|
184
214
|
async call(input, options = {}) {
|
|
185
215
|
parseArgument(input, inputSchema);
|
|
186
216
|
const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
|
|
187
|
-
const { waitSecs, ...startOptions } = parsed;
|
|
188
|
-
const { id } = await this.start(input, startOptions);
|
|
217
|
+
const { waitSecs, timeoutSecs = 'noTimeout', signal, ...startOptions } = parsed;
|
|
218
|
+
const { id } = await this.start(input, { ...startOptions, timeoutSecs, signal });
|
|
189
219
|
// Calling root client because we need access to top level API.
|
|
190
220
|
// Creating a new instance of RunClient here would only allow
|
|
191
221
|
// setting it up as a nested route under task API.
|
|
192
|
-
return this.apifyClient.run(id).waitForFinish({ waitSecs });
|
|
222
|
+
return this.apifyClient.run(id).waitForFinish({ waitSecs, timeoutSecs, signal });
|
|
193
223
|
}
|
|
194
224
|
/**
|
|
195
225
|
* Retrieves the Actor task's input object.
|
|
196
226
|
*
|
|
197
|
-
* @
|
|
227
|
+
* @param options - Request options
|
|
228
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
229
|
+
* @returns The Task's input.
|
|
198
230
|
* @see https://docs.apify.com/api/v2/actor-task-input-get
|
|
199
231
|
*/
|
|
200
|
-
async getInput() {
|
|
201
|
-
const
|
|
202
|
-
|
|
232
|
+
async getInput(options = {}) {
|
|
233
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
234
|
+
const response = await this.httpClient.call({
|
|
235
|
+
url: this.buildUrl('input'),
|
|
203
236
|
method: 'GET',
|
|
204
|
-
params: this.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
catchNotFoundOrThrow(err);
|
|
212
|
-
}
|
|
213
|
-
return undefined;
|
|
237
|
+
params: this.buildParams(),
|
|
238
|
+
timeoutSecs,
|
|
239
|
+
signal,
|
|
240
|
+
});
|
|
241
|
+
return cast(response.data);
|
|
214
242
|
}
|
|
215
243
|
/**
|
|
216
244
|
* Updates the Actor task's input object.
|
|
217
245
|
*
|
|
218
246
|
* @param newFields - New input data for the task.
|
|
247
|
+
* @param options - Request options
|
|
248
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
219
249
|
* @returns The updated task input.
|
|
220
250
|
* @see https://docs.apify.com/api/v2/actor-task-input-put
|
|
221
251
|
*/
|
|
222
|
-
async updateInput(newFields) {
|
|
252
|
+
async updateInput(newFields, options = {}) {
|
|
253
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
223
254
|
const response = await this.httpClient.call({
|
|
224
|
-
url: this.
|
|
255
|
+
url: this.buildUrl('input'),
|
|
225
256
|
method: 'PUT',
|
|
226
|
-
params: this.
|
|
257
|
+
params: this.buildParams(),
|
|
227
258
|
data: newFields,
|
|
259
|
+
timeoutSecs,
|
|
260
|
+
signal,
|
|
228
261
|
});
|
|
229
262
|
return cast(response.data);
|
|
230
263
|
}
|
|
@@ -239,9 +272,9 @@ export class TaskClient extends ResourceClient {
|
|
|
239
272
|
*/
|
|
240
273
|
lastRun(options = {}) {
|
|
241
274
|
const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
|
|
242
|
-
return new RunClient(this.
|
|
275
|
+
return new RunClient(this.subResourceOptions({
|
|
243
276
|
id: 'last',
|
|
244
|
-
params: this.
|
|
277
|
+
params: this.buildParams(parsed),
|
|
245
278
|
resourcePath: 'runs',
|
|
246
279
|
}));
|
|
247
280
|
}
|
|
@@ -252,7 +285,7 @@ export class TaskClient extends ResourceClient {
|
|
|
252
285
|
* @see https://docs.apify.com/api/v2/actor-task-runs-get
|
|
253
286
|
*/
|
|
254
287
|
runs() {
|
|
255
|
-
return new RunCollectionClient(this.
|
|
288
|
+
return new RunCollectionClient(this.subResourceOptions({
|
|
256
289
|
resourcePath: 'runs',
|
|
257
290
|
}));
|
|
258
291
|
}
|
|
@@ -263,6 +296,6 @@ export class TaskClient extends ResourceClient {
|
|
|
263
296
|
* @see https://docs.apify.com/api/v2/actor-task-webhooks-get
|
|
264
297
|
*/
|
|
265
298
|
webhooks() {
|
|
266
|
-
return new WebhookCollectionClient(this.
|
|
299
|
+
return new WebhookCollectionClient(this.subResourceOptions());
|
|
267
300
|
}
|
|
268
301
|
}
|
|
@@ -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
|
*
|
|
41
|
-
* @
|
|
42
|
+
* @param options - Request options
|
|
43
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
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
|
*
|
|
48
|
-
* @
|
|
51
|
+
* @param options - Request options
|
|
52
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
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
|
*
|
|
56
|
-
* @
|
|
61
|
+
* @param options - Request options
|
|
62
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
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,70 +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
|
*
|
|
45
|
-
* @
|
|
46
|
+
* @param options - Request options
|
|
47
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
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
|
*
|
|
54
|
-
* @
|
|
58
|
+
* @param options - Request options
|
|
59
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
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() {
|
|
59
|
-
const
|
|
60
|
-
|
|
64
|
+
async monthlyUsage(options = {}) {
|
|
65
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
66
|
+
const response = await this.httpClient.call({
|
|
67
|
+
url: this.buildUrl('usage/monthly'),
|
|
61
68
|
method: 'GET',
|
|
62
|
-
params: this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return parseResponse(response, schemas.MonthlyUsage(), (key) => key === 'date');
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
catchNotFoundOrThrow(err);
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
69
|
+
params: this.buildParams(),
|
|
70
|
+
timeoutSecs,
|
|
71
|
+
signal,
|
|
72
|
+
});
|
|
73
|
+
return parseResponse(response, schemas.MonthlyUsage());
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Retrieves the user's account and usage limits.
|
|
76
77
|
*
|
|
77
|
-
* @
|
|
78
|
+
* @param options - Request options
|
|
79
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
80
|
+
* @returns The account and usage limits object.
|
|
78
81
|
* @see https://docs.apify.com/api/v2/users-me-limits-get
|
|
79
82
|
* @since Added in 2.9.2
|
|
80
83
|
*/
|
|
81
|
-
async limits() {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
+
async limits(options = {}) {
|
|
85
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
86
|
+
const response = await this.httpClient.call({
|
|
87
|
+
url: this.buildUrl('limits'),
|
|
84
88
|
method: 'GET',
|
|
85
|
-
params: this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
catchNotFoundOrThrow(err);
|
|
93
|
-
}
|
|
94
|
-
return undefined;
|
|
89
|
+
params: this.buildParams(),
|
|
90
|
+
timeoutSecs,
|
|
91
|
+
signal,
|
|
92
|
+
});
|
|
93
|
+
return parseResponse(response, schemas.AccountLimits());
|
|
95
94
|
}
|
|
96
95
|
/**
|
|
97
96
|
* Updates the user's account and usage limits.
|
|
98
97
|
*
|
|
99
|
-
* @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'`.
|
|
100
101
|
* @see https://docs.apify.com/api/v2/users-me-limits-put
|
|
101
102
|
* @since Added in 2.10.0
|
|
102
103
|
*/
|
|
103
|
-
async updateLimits(options) {
|
|
104
|
+
async updateLimits(newLimits, options = {}) {
|
|
105
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
104
106
|
const requestOpts = {
|
|
105
|
-
url: this.
|
|
107
|
+
url: this.buildUrl('limits'),
|
|
106
108
|
method: 'PUT',
|
|
107
|
-
params: this.
|
|
108
|
-
data:
|
|
109
|
+
params: this.buildParams(),
|
|
110
|
+
data: newLimits,
|
|
111
|
+
timeoutSecs,
|
|
112
|
+
signal,
|
|
109
113
|
};
|
|
110
114
|
await this.httpClient.call(requestOpts);
|
|
111
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
|
*
|
|
64
|
-
* @
|
|
71
|
+
* @param options - Request options
|
|
72
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
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;
|