apify-client 3.0.0-beta.2 → 3.0.0-beta.21
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 +7 -3
- package/dist/apify_api_error.d.ts +60 -19
- package/dist/apify_api_error.js +88 -22
- package/dist/apify_client.d.ts +22 -3
- package/dist/apify_client.js +37 -31
- package/dist/base/api_client.d.ts +6 -6
- package/dist/base/api_client.js +24 -16
- package/dist/base/resource_client.d.ts +23 -9
- package/dist/base/resource_client.js +49 -25
- package/dist/base/resource_collection_client.d.ts +7 -4
- package/dist/base/resource_collection_client.js +21 -15
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +17 -24
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +287 -214
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +18 -51
- package/dist/http_client.js +90 -85
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/interceptors.js +24 -6
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +32 -52
- package/dist/resource_clients/actor.d.ts +46 -31
- package/dist/resource_clients/actor.js +71 -53
- package/dist/resource_clients/actor_collection.d.ts +9 -5
- package/dist/resource_clients/actor_collection.js +12 -3
- package/dist/resource_clients/actor_env_var.d.ts +10 -3
- package/dist/resource_clients/actor_env_var.js +17 -6
- package/dist/resource_clients/actor_env_var_collection.d.ts +14 -18
- package/dist/resource_clients/actor_env_var_collection.js +18 -11
- package/dist/resource_clients/actor_version.d.ts +18 -3
- package/dist/resource_clients/actor_version.js +20 -9
- package/dist/resource_clients/actor_version_collection.d.ts +16 -17
- package/dist/resource_clients/actor_version_collection.js +20 -11
- package/dist/resource_clients/build.d.ts +18 -6
- package/dist/resource_clients/build.js +35 -17
- package/dist/resource_clients/build_collection.d.ts +3 -1
- package/dist/resource_clients/build_collection.js +5 -1
- package/dist/resource_clients/dataset.d.ts +23 -9
- package/dist/resource_clients/dataset.js +70 -48
- package/dist/resource_clients/dataset_collection.d.ts +6 -2
- package/dist/resource_clients/dataset_collection.js +13 -2
- package/dist/resource_clients/key_value_store.d.ts +48 -15
- package/dist/resource_clients/key_value_store.js +71 -40
- package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
- package/dist/resource_clients/key_value_store_collection.js +13 -2
- package/dist/resource_clients/log.d.ts +9 -19
- package/dist/resource_clients/log.js +57 -45
- package/dist/resource_clients/request_queue.d.ts +56 -26
- package/dist/resource_clients/request_queue.js +178 -113
- package/dist/resource_clients/request_queue_collection.d.ts +6 -2
- package/dist/resource_clients/request_queue_collection.js +10 -3
- package/dist/resource_clients/run.d.ts +51 -17
- package/dist/resource_clients/run.js +85 -44
- package/dist/resource_clients/run_collection.d.ts +3 -1
- package/dist/resource_clients/run_collection.js +5 -1
- package/dist/resource_clients/schedule.d.ts +16 -7
- package/dist/resource_clients/schedule.js +31 -21
- package/dist/resource_clients/schedule_collection.d.ts +6 -2
- package/dist/resource_clients/schedule_collection.js +10 -3
- package/dist/resource_clients/store_collection.d.ts +3 -1
- package/dist/resource_clients/store_collection.js +5 -1
- package/dist/resource_clients/task.d.ts +28 -10
- package/dist/resource_clients/task.js +67 -44
- package/dist/resource_clients/task_collection.d.ts +6 -2
- package/dist/resource_clients/task_collection.js +10 -3
- package/dist/resource_clients/user.d.ts +17 -8
- package/dist/resource_clients/user.js +40 -39
- package/dist/resource_clients/webhook.d.ts +14 -5
- package/dist/resource_clients/webhook.js +30 -22
- package/dist/resource_clients/webhook_collection.d.ts +6 -2
- package/dist/resource_clients/webhook_collection.js +10 -3
- package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
- package/dist/resource_clients/webhook_dispatch.js +8 -2
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +5 -1
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +58 -0
- package/dist/runtime/types.d.ts +50 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +17 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +2 -2
- package/dist/timeouts.d.ts +72 -0
- package/dist/timeouts.js +31 -0
- package/dist/utils.d.ts +75 -55
- package/dist/utils.js +201 -180
- package/package.json +42 -35
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -153
|
@@ -2,7 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
|
|
3
3
|
import { Log } from '@apify/log';
|
|
4
4
|
import { ResourceClient } from '../base/resource_client.js';
|
|
5
|
-
import
|
|
5
|
+
import * as schemas from '../schemas.js';
|
|
6
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
7
|
+
import { anyObjectSchema, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
|
|
6
8
|
import { ActorVersionClient } from './actor_version.js';
|
|
7
9
|
import { ActorVersionCollectionClient } from './actor_version_collection.js';
|
|
8
10
|
import { BuildClient } from './build.js';
|
|
@@ -14,19 +16,20 @@ const startOptionsSchema = z.strictObject({
|
|
|
14
16
|
build: z.string().optional(),
|
|
15
17
|
contentType: z.string().optional(),
|
|
16
18
|
memory: z.number().optional(),
|
|
17
|
-
|
|
19
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
18
20
|
waitForFinish: z.number().optional(),
|
|
19
21
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
20
22
|
maxItems: z.number().min(0).optional(),
|
|
21
23
|
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
22
24
|
restartOnError: z.boolean().optional(),
|
|
23
25
|
forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
|
|
26
|
+
...timeoutOptionsShape,
|
|
24
27
|
});
|
|
25
28
|
const callOptionsSchema = z.strictObject({
|
|
26
29
|
build: z.string().optional(),
|
|
27
30
|
contentType: z.string().optional(),
|
|
28
31
|
memory: z.number().optional(),
|
|
29
|
-
|
|
32
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
30
33
|
waitSecs: z.number().min(0).optional(),
|
|
31
34
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
32
35
|
maxItems: z.number().min(0).optional(),
|
|
@@ -34,18 +37,22 @@ const callOptionsSchema = z.strictObject({
|
|
|
34
37
|
log: z.union([z.null(), z.instanceof(Log), z.literal('default')]).optional(),
|
|
35
38
|
restartOnError: z.boolean().optional(),
|
|
36
39
|
forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
|
|
40
|
+
...timeoutOptionsShape,
|
|
37
41
|
});
|
|
38
42
|
const validateInputOptionsSchema = z.strictObject({
|
|
39
43
|
build: z.string().optional(),
|
|
40
44
|
contentType: z.string().optional(),
|
|
45
|
+
...timeoutOptionsShape,
|
|
41
46
|
});
|
|
42
|
-
const versionNumberSchema = z.string();
|
|
47
|
+
const versionNumberSchema = z.string().min(1);
|
|
43
48
|
const buildOptionsSchema = z.strictObject({
|
|
44
49
|
betaPackages: z.boolean().optional(),
|
|
45
50
|
tag: z.string().optional(),
|
|
46
51
|
useCache: z.boolean().optional(),
|
|
47
52
|
waitForFinish: z.number().optional(),
|
|
53
|
+
...timeoutOptionsShape,
|
|
48
54
|
});
|
|
55
|
+
const defaultBuildOptionsSchema = z.strictObject({ waitForFinish: z.number().optional(), ...timeoutOptionsShape });
|
|
49
56
|
const lastRunOptionsSchema = z.strictObject({
|
|
50
57
|
status: z.enum(ACTOR_JOB_STATUSES).optional(),
|
|
51
58
|
origin: z.enum(META_ORIGINS).optional(),
|
|
@@ -83,30 +90,39 @@ export class ActorClient extends ResourceClient {
|
|
|
83
90
|
/**
|
|
84
91
|
* Gets the Actor object from the Apify API.
|
|
85
92
|
*
|
|
93
|
+
* @param options - Request options
|
|
94
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
86
95
|
* @returns The Actor object, or `undefined` if it does not exist
|
|
87
96
|
* @see https://docs.apify.com/api/v2/act-get
|
|
88
97
|
*/
|
|
89
|
-
async get() {
|
|
90
|
-
|
|
98
|
+
async get(options = {}) {
|
|
99
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
100
|
+
return this.getResource(schemas.Actor(), {}, timeoutSecs);
|
|
91
101
|
}
|
|
92
102
|
/**
|
|
93
103
|
* Updates the Actor with specified fields.
|
|
94
104
|
*
|
|
95
105
|
* @param newFields - Fields to update in the Actor
|
|
106
|
+
* @param options - Request options
|
|
107
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
96
108
|
* @returns The updated Actor object
|
|
97
109
|
* @see https://docs.apify.com/api/v2/act-put
|
|
98
110
|
*/
|
|
99
|
-
async update(newFields) {
|
|
111
|
+
async update(newFields, options = {}) {
|
|
100
112
|
parseArgument(newFields, anyObjectSchema);
|
|
101
|
-
|
|
113
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
114
|
+
return this.updateResource(schemas.Actor(), newFields, timeoutSecs);
|
|
102
115
|
}
|
|
103
116
|
/**
|
|
104
117
|
* Deletes the Actor.
|
|
105
118
|
*
|
|
119
|
+
* @param options - Request options
|
|
120
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
106
121
|
* @see https://docs.apify.com/api/v2/act-delete
|
|
107
122
|
*/
|
|
108
|
-
async delete() {
|
|
109
|
-
|
|
123
|
+
async delete(options = {}) {
|
|
124
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
125
|
+
return this.deleteResource(timeoutSecs);
|
|
110
126
|
}
|
|
111
127
|
/**
|
|
112
128
|
* Starts the Actor and immediately returns the Run object.
|
|
@@ -115,17 +131,17 @@ export class ActorClient extends ResourceClient {
|
|
|
115
131
|
* asynchronously and this method returns immediately without waiting for completion.
|
|
116
132
|
* Use the {@link call} method if you want to wait for the Actor to finish.
|
|
117
133
|
*
|
|
118
|
-
* @param input - Input for the Actor.
|
|
119
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
134
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
120
135
|
* @param options - Run configuration options
|
|
121
136
|
* @param options.build - Tag or number of the build to run (e.g., `'beta'` or `'1.2.345'`). If not provided, uses the default build.
|
|
122
137
|
* @param options.memory - Memory in megabytes allocated for the run. If not provided, uses the Actor's default memory setting.
|
|
123
|
-
* @param options.
|
|
138
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout. If not provided, uses the Actor's default timeout.
|
|
124
139
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish on the API side before returning. Default is 0 (returns immediately).
|
|
125
140
|
* @param options.webhooks - Webhooks to trigger when the Actor run reaches a specific state (e.g., `SUCCEEDED`, `FAILED`).
|
|
126
141
|
* @param options.maxItems - Maximum number of dataset items that will be charged (only for pay-per-result Actors).
|
|
127
142
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (only for pay-per-event Actors).
|
|
128
|
-
* @param options.
|
|
143
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
|
|
144
|
+
* when the API is asked to hold the response.
|
|
129
145
|
* @returns The Actor run object with status, usage, and storage IDs
|
|
130
146
|
* @see https://docs.apify.com/api/v2/act-runs-post
|
|
131
147
|
*
|
|
@@ -138,18 +154,17 @@ export class ActorClient extends ResourceClient {
|
|
|
138
154
|
* // Start Actor with specific build and memory
|
|
139
155
|
* const run = await client.actor('my-actor').start(
|
|
140
156
|
* { url: 'https://example.com' },
|
|
141
|
-
* { build: '0.1.2', memory: 512,
|
|
157
|
+
* { build: '0.1.2', memory: 512, runTimeoutSecs: 300 }
|
|
142
158
|
* );
|
|
143
159
|
* ```
|
|
144
160
|
*/
|
|
145
161
|
async start(input, options = {}) {
|
|
146
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
147
|
-
// then it will process input as a buffer.
|
|
148
162
|
const parsed = parseArgument(options, startOptionsSchema, 'ActorStartOptions');
|
|
149
|
-
const { waitForFinish,
|
|
163
|
+
const { waitForFinish, runTimeoutSecs, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, timeoutSecs, } = parsed;
|
|
164
|
+
// The API's `timeout` parameter bounds the run, not the request.
|
|
150
165
|
const params = {
|
|
151
166
|
waitForFinish,
|
|
152
|
-
timeout,
|
|
167
|
+
timeout: runTimeoutSecs,
|
|
153
168
|
memory,
|
|
154
169
|
build,
|
|
155
170
|
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
@@ -159,13 +174,14 @@ export class ActorClient extends ResourceClient {
|
|
|
159
174
|
forcePermissionLevel,
|
|
160
175
|
};
|
|
161
176
|
const request = {
|
|
162
|
-
url: this.
|
|
177
|
+
url: this.buildUrl('runs'),
|
|
163
178
|
method: 'POST',
|
|
164
179
|
data: input,
|
|
165
|
-
params: this.
|
|
180
|
+
params: this.buildParams(params),
|
|
166
181
|
// Apify internal property. Tells the request serialization interceptor
|
|
167
182
|
// to stringify functions to JSON, instead of omitting them.
|
|
168
183
|
stringifyFunctions: true,
|
|
184
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', waitForFinish),
|
|
169
185
|
};
|
|
170
186
|
if (parsed.contentType) {
|
|
171
187
|
request.headers = {
|
|
@@ -173,7 +189,7 @@ export class ActorClient extends ResourceClient {
|
|
|
173
189
|
};
|
|
174
190
|
}
|
|
175
191
|
const response = await this.httpClient.call(request);
|
|
176
|
-
return
|
|
192
|
+
return parseResponse(response, schemas.Run());
|
|
177
193
|
}
|
|
178
194
|
/**
|
|
179
195
|
* Starts the Actor and waits for it to finish before returning the Run object.
|
|
@@ -182,14 +198,14 @@ export class ActorClient extends ResourceClient {
|
|
|
182
198
|
* by polling the run status. It optionally streams logs to the console or a custom Log instance.
|
|
183
199
|
* By default, it waits indefinitely unless the `waitSecs` option is provided.
|
|
184
200
|
*
|
|
185
|
-
* @param input - Input for the Actor.
|
|
186
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
201
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
187
202
|
* @param options - Run configuration options (extends all options from {@link start})
|
|
188
203
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
189
204
|
* @param options.log - Log instance for streaming run logs. Use `'default'` for console output, `null` to disable logging, or provide a custom Log instance.
|
|
190
205
|
* @param options.build - Tag or number of the build to run (e.g., `'beta'` or `'1.2.345'`).
|
|
191
206
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
192
|
-
* @param options.
|
|
207
|
+
* @param options.runTimeoutSecs - Maximum run duration in seconds.
|
|
208
|
+
* @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
|
|
193
209
|
* @returns The finished Actor run object with final status (`SUCCEEDED`, `FAILED`, `ABORTED`, or `TIMED-OUT`)
|
|
194
210
|
* @see https://docs.apify.com/api/v2/act-runs-post
|
|
195
211
|
*
|
|
@@ -213,11 +229,9 @@ export class ActorClient extends ResourceClient {
|
|
|
213
229
|
* ```
|
|
214
230
|
*/
|
|
215
231
|
async call(input, options = {}) {
|
|
216
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
217
|
-
// then it will process input as a buffer.
|
|
218
232
|
const parsed = parseArgument(options, callOptionsSchema, 'ActorCallOptions');
|
|
219
|
-
const { waitSecs, log, ...startOptions } = parsed;
|
|
220
|
-
const { id } = await this.start(input, startOptions);
|
|
233
|
+
const { waitSecs, log, timeoutSecs = 'noTimeout', ...startOptions } = parsed;
|
|
234
|
+
const { id } = await this.start(input, { ...startOptions, timeoutSecs });
|
|
221
235
|
// Calling root client because we need access to top level API.
|
|
222
236
|
// Creating a new instance of RunClient here would only allow
|
|
223
237
|
// setting it up as a nested route under actor API.
|
|
@@ -226,7 +240,7 @@ export class ActorClient extends ResourceClient {
|
|
|
226
240
|
streamedLog?.start();
|
|
227
241
|
return this.apifyClient
|
|
228
242
|
.run(id)
|
|
229
|
-
.waitForFinish({ waitSecs })
|
|
243
|
+
.waitForFinish({ waitSecs, timeoutSecs })
|
|
230
244
|
.finally(async () => {
|
|
231
245
|
await streamedLog?.stop();
|
|
232
246
|
});
|
|
@@ -239,13 +253,11 @@ export class ActorClient extends ResourceClient {
|
|
|
239
253
|
* invalid, the API responds with an error that is thrown as an `ApifyApiError` describing the
|
|
240
254
|
* validation problem.
|
|
241
255
|
*
|
|
242
|
-
* @param input - Input to validate against the Actor's input schema
|
|
243
|
-
* value (object, array, string, number). If `contentType` is specified in options,
|
|
244
|
-
* input should be a string or Buffer.
|
|
256
|
+
* @param input - Input to validate against the Actor's input schema, serialized to JSON.
|
|
245
257
|
* @param options - Validation options
|
|
246
258
|
* @param options.build - Tag or number of the build whose input schema the input is validated against
|
|
247
259
|
* (e.g., `'latest'` or `'1.2.345'`). If not provided, uses the default build.
|
|
248
|
-
* @param options.
|
|
260
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
249
261
|
* @returns `true` if the input is valid. Invalid input causes the underlying API call to throw an `ApifyApiError`.
|
|
250
262
|
* @see https://docs.apify.com/api/v2/act-validate-input-post
|
|
251
263
|
*
|
|
@@ -263,17 +275,16 @@ export class ActorClient extends ResourceClient {
|
|
|
263
275
|
* @since Added in 2.24.0
|
|
264
276
|
*/
|
|
265
277
|
async validateInput(input, options = {}) {
|
|
266
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
267
|
-
// then it will process input as a buffer.
|
|
268
278
|
const parsed = parseArgument(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
|
|
269
279
|
const request = {
|
|
270
|
-
url: this.
|
|
280
|
+
url: this.buildUrl('validate-input'),
|
|
271
281
|
method: 'POST',
|
|
272
282
|
data: input,
|
|
273
|
-
params: this.
|
|
283
|
+
params: this.buildParams({ build: parsed.build }),
|
|
274
284
|
// Apify internal property. Tells the request serialization interceptor
|
|
275
285
|
// to stringify functions to JSON, instead of omitting them.
|
|
276
286
|
stringifyFunctions: true,
|
|
287
|
+
timeoutSecs: parsed.timeoutSecs ?? 'short',
|
|
277
288
|
};
|
|
278
289
|
if (parsed.contentType) {
|
|
279
290
|
request.headers = {
|
|
@@ -295,6 +306,8 @@ export class ActorClient extends ResourceClient {
|
|
|
295
306
|
* @param options.tag - Tag to be applied to the build (e.g., `'latest'`, `'beta'`). Existing tag with the same name will be replaced.
|
|
296
307
|
* @param options.useCache - If `false`, Docker build cache will be ignored. Default is `true`.
|
|
297
308
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the build to finish on the API side before returning. Default is 0 (returns immediately).
|
|
309
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
|
|
310
|
+
* when the API is asked to hold the response.
|
|
298
311
|
* @returns The Build object with status and build details
|
|
299
312
|
* @see https://docs.apify.com/api/v2/act-builds-post
|
|
300
313
|
*
|
|
@@ -314,16 +327,17 @@ export class ActorClient extends ResourceClient {
|
|
|
314
327
|
*/
|
|
315
328
|
async build(versionNumber, options = {}) {
|
|
316
329
|
parseArgument(versionNumber, versionNumberSchema);
|
|
317
|
-
const
|
|
330
|
+
const { timeoutSecs, ...params } = parseArgument(options, buildOptionsSchema, 'ActorBuildOptions');
|
|
318
331
|
const response = await this.httpClient.call({
|
|
319
|
-
url: this.
|
|
332
|
+
url: this.buildUrl('builds'),
|
|
320
333
|
method: 'POST',
|
|
321
|
-
params: this.
|
|
334
|
+
params: this.buildParams({
|
|
322
335
|
version: versionNumber,
|
|
323
|
-
...
|
|
336
|
+
...params,
|
|
324
337
|
}),
|
|
338
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', params.waitForFinish),
|
|
325
339
|
});
|
|
326
|
-
return
|
|
340
|
+
return parseResponse(response, schemas.Build());
|
|
327
341
|
}
|
|
328
342
|
/**
|
|
329
343
|
* Returns a client for the default build of this Actor.
|
|
@@ -334,6 +348,8 @@ export class ActorClient extends ResourceClient {
|
|
|
334
348
|
*
|
|
335
349
|
* @param options - Options for getting the default build
|
|
336
350
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the build to finish on the API side before returning. Default is 0 (returns immediately).
|
|
351
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
|
|
352
|
+
* when the API is asked to hold the response.
|
|
337
353
|
* @returns A client for the default build
|
|
338
354
|
* @see https://docs.apify.com/api/v2/act-build-default-get
|
|
339
355
|
*
|
|
@@ -351,12 +367,14 @@ export class ActorClient extends ResourceClient {
|
|
|
351
367
|
* @since Added in 2.12.2
|
|
352
368
|
*/
|
|
353
369
|
async defaultBuild(options = {}) {
|
|
370
|
+
const { timeoutSecs, ...params } = parseArgument(options, defaultBuildOptionsSchema, 'BuildClientGetOptions');
|
|
354
371
|
const response = await this.httpClient.call({
|
|
355
|
-
url: this.
|
|
372
|
+
url: this.buildUrl('builds/default'),
|
|
356
373
|
method: 'GET',
|
|
357
|
-
params: this.
|
|
374
|
+
params: this.buildParams(params),
|
|
375
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'short', params.waitForFinish),
|
|
358
376
|
});
|
|
359
|
-
const { id } =
|
|
377
|
+
const { id } = parseResponse(response, schemas.Build());
|
|
360
378
|
return new BuildClient({
|
|
361
379
|
baseUrl: this.apifyClient.baseUrl,
|
|
362
380
|
publicBaseUrl: this.apifyClient.publicBaseUrl,
|
|
@@ -384,9 +402,9 @@ export class ActorClient extends ResourceClient {
|
|
|
384
402
|
*/
|
|
385
403
|
lastRun(options = {}) {
|
|
386
404
|
const parsed = parseArgument(options, lastRunOptionsSchema, 'ActorLastRunOptions');
|
|
387
|
-
return new RunClient(this.
|
|
405
|
+
return new RunClient(this.subResourceOptions({
|
|
388
406
|
id: 'last',
|
|
389
|
-
params: this.
|
|
407
|
+
params: this.buildParams(parsed),
|
|
390
408
|
resourcePath: 'runs',
|
|
391
409
|
}));
|
|
392
410
|
}
|
|
@@ -397,7 +415,7 @@ export class ActorClient extends ResourceClient {
|
|
|
397
415
|
* @see https://docs.apify.com/api/v2/act-builds-get
|
|
398
416
|
*/
|
|
399
417
|
builds() {
|
|
400
|
-
return new BuildCollectionClient(this.
|
|
418
|
+
return new BuildCollectionClient(this.subResourceOptions({
|
|
401
419
|
resourcePath: 'builds',
|
|
402
420
|
}));
|
|
403
421
|
}
|
|
@@ -408,7 +426,7 @@ export class ActorClient extends ResourceClient {
|
|
|
408
426
|
* @see https://docs.apify.com/api/v2/act-runs-get
|
|
409
427
|
*/
|
|
410
428
|
runs() {
|
|
411
|
-
return new RunCollectionClient(this.
|
|
429
|
+
return new RunCollectionClient(this.subResourceOptions({
|
|
412
430
|
resourcePath: 'runs',
|
|
413
431
|
}));
|
|
414
432
|
}
|
|
@@ -421,7 +439,7 @@ export class ActorClient extends ResourceClient {
|
|
|
421
439
|
*/
|
|
422
440
|
version(versionNumber) {
|
|
423
441
|
parseArgument(versionNumber, versionNumberSchema);
|
|
424
|
-
return new ActorVersionClient(this.
|
|
442
|
+
return new ActorVersionClient(this.subResourceOptions({
|
|
425
443
|
id: versionNumber,
|
|
426
444
|
}));
|
|
427
445
|
}
|
|
@@ -432,7 +450,7 @@ export class ActorClient extends ResourceClient {
|
|
|
432
450
|
* @see https://docs.apify.com/api/v2/act-versions-get
|
|
433
451
|
*/
|
|
434
452
|
versions() {
|
|
435
|
-
return new ActorVersionCollectionClient(this.
|
|
453
|
+
return new ActorVersionCollectionClient(this.subResourceOptions());
|
|
436
454
|
}
|
|
437
455
|
/**
|
|
438
456
|
* Returns a client for managing webhooks associated with this Actor.
|
|
@@ -441,6 +459,6 @@ export class ActorClient extends ResourceClient {
|
|
|
441
459
|
* @see https://docs.apify.com/api/v2/act-webhooks-get
|
|
442
460
|
*/
|
|
443
461
|
webhooks() {
|
|
444
|
-
return new WebhookCollectionClient(this.
|
|
462
|
+
return new WebhookCollectionClient(this.subResourceOptions());
|
|
445
463
|
}
|
|
446
464
|
}
|
|
@@ -2,6 +2,7 @@ import type { ACTOR_PERMISSION_LEVEL } from '@apify/consts';
|
|
|
2
2
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
3
3
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
4
|
import type { ActorCollectionListItem } from '../models.js';
|
|
5
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
5
6
|
import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
|
|
6
7
|
import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor.js';
|
|
7
8
|
import type { ActorVersion } from './actor_version.js';
|
|
@@ -51,6 +52,7 @@ export declare class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
51
52
|
* ```
|
|
52
53
|
*
|
|
53
54
|
* @param options - Pagination options.
|
|
55
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
54
56
|
* @returns A paginated iterator of Actors.
|
|
55
57
|
* @see https://docs.apify.com/api/v2/acts-get
|
|
56
58
|
*/
|
|
@@ -59,25 +61,29 @@ export declare class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
59
61
|
* Creates a new Actor.
|
|
60
62
|
*
|
|
61
63
|
* @param actor - The Actor data.
|
|
64
|
+
* @param options - Request options
|
|
65
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
62
66
|
* @returns The created Actor object.
|
|
63
67
|
* @see https://docs.apify.com/api/v2/acts-post
|
|
64
68
|
*/
|
|
65
|
-
create(actor: ActorCollectionCreateOptions): Promise<Actor>;
|
|
69
|
+
create(actor: ActorCollectionCreateOptions, options?: TimeoutOptions): Promise<Actor>;
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
72
|
+
* Field to order a list of Actors by.
|
|
73
|
+
*
|
|
68
74
|
* @since Added in 2.12.6
|
|
69
75
|
*/
|
|
70
76
|
export declare enum ActorListSortBy {
|
|
71
77
|
CREATED_AT = "createdAt",
|
|
72
78
|
LAST_RUN_STARTED_AT = "stats.lastRunStartedAt"
|
|
73
79
|
}
|
|
74
|
-
export interface ActorCollectionListOptions extends PaginationOptions {
|
|
80
|
+
export interface ActorCollectionListOptions extends PaginationOptions, TimeoutOptions {
|
|
75
81
|
my?: boolean;
|
|
76
82
|
desc?: boolean;
|
|
77
83
|
/**
|
|
78
84
|
* @since Added in 2.12.6
|
|
79
85
|
*/
|
|
80
|
-
sortBy?: ActorListSortBy
|
|
86
|
+
sortBy?: `${ActorListSortBy}`;
|
|
81
87
|
}
|
|
82
88
|
export type ActorCollectionListResult = PaginatedList<ActorCollectionListItem>;
|
|
83
89
|
export interface ActorCollectionCreateOptions {
|
|
@@ -100,8 +106,6 @@ export interface ActorCollectionCreateOptions {
|
|
|
100
106
|
isDeprecated?: boolean;
|
|
101
107
|
isPublic?: boolean;
|
|
102
108
|
name?: string;
|
|
103
|
-
/** @deprecated Use defaultRunOptions.restartOnError instead */
|
|
104
|
-
restartOnError?: boolean;
|
|
105
109
|
/**
|
|
106
110
|
* @since Added in 2.8.6
|
|
107
111
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
3
5
|
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
4
6
|
const actorCreateSchema = anyObjectSchema.optional();
|
|
5
7
|
/**
|
|
@@ -52,26 +54,32 @@ export class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
52
54
|
* ```
|
|
53
55
|
*
|
|
54
56
|
* @param options - Pagination options.
|
|
57
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
55
58
|
* @returns A paginated iterator of Actors.
|
|
56
59
|
* @see https://docs.apify.com/api/v2/acts-get
|
|
57
60
|
*/
|
|
58
61
|
list(options = {}) {
|
|
59
62
|
const parsed = parseArgument(options, listOptionsSchema, 'ActorCollectionListOptions');
|
|
60
|
-
return this.
|
|
63
|
+
return this.listResourcesPaginated(schemas.ListOfActors(), parsed, 'medium');
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Creates a new Actor.
|
|
64
67
|
*
|
|
65
68
|
* @param actor - The Actor data.
|
|
69
|
+
* @param options - Request options
|
|
70
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
66
71
|
* @returns The created Actor object.
|
|
67
72
|
* @see https://docs.apify.com/api/v2/acts-post
|
|
68
73
|
*/
|
|
69
|
-
async create(actor) {
|
|
74
|
+
async create(actor, options = {}) {
|
|
70
75
|
parseArgument(actor, actorCreateSchema);
|
|
71
|
-
|
|
76
|
+
const { timeoutSecs = 'medium' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
77
|
+
return this.createResource(schemas.Actor(), actor, timeoutSecs);
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
81
|
+
* Field to order a list of Actors by.
|
|
82
|
+
*
|
|
75
83
|
* @since Added in 2.12.6
|
|
76
84
|
*/
|
|
77
85
|
export var ActorListSortBy;
|
|
@@ -85,4 +93,5 @@ const listOptionsSchema = z.strictObject({
|
|
|
85
93
|
...paginationOptionsShape,
|
|
86
94
|
desc: z.boolean().optional(),
|
|
87
95
|
sortBy: z.enum(ActorListSortBy).optional(),
|
|
96
|
+
...timeoutOptionsShape,
|
|
88
97
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
2
|
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
3
4
|
import type { ActorEnvironmentVariable } from './actor_version.js';
|
|
4
5
|
/**
|
|
5
6
|
* Client for managing a specific Actor environment variable.
|
|
@@ -32,22 +33,28 @@ export declare class ActorEnvVarClient extends ResourceClient {
|
|
|
32
33
|
/**
|
|
33
34
|
* Retrieves the environment variable.
|
|
34
35
|
*
|
|
36
|
+
* @param options - Request options
|
|
37
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
35
38
|
* @returns The environment variable object, or `undefined` if it does not exist.
|
|
36
39
|
* @see https://docs.apify.com/api/v2/act-version-env-var-get
|
|
37
40
|
*/
|
|
38
|
-
get(): Promise<ActorEnvironmentVariable | undefined>;
|
|
41
|
+
get(options?: TimeoutOptions): Promise<ActorEnvironmentVariable | undefined>;
|
|
39
42
|
/**
|
|
40
43
|
* Updates the environment variable.
|
|
41
44
|
*
|
|
42
45
|
* @param actorEnvVar - The updated environment variable data.
|
|
46
|
+
* @param options - Request options
|
|
47
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
43
48
|
* @returns The updated environment variable object.
|
|
44
49
|
* @see https://docs.apify.com/api/v2/act-version-env-var-put
|
|
45
50
|
*/
|
|
46
|
-
update(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
|
|
51
|
+
update(actorEnvVar: ActorEnvironmentVariable, options?: TimeoutOptions): Promise<ActorEnvironmentVariable>;
|
|
47
52
|
/**
|
|
48
53
|
* Deletes the environment variable.
|
|
49
54
|
*
|
|
55
|
+
* @param options - Request options
|
|
56
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
50
57
|
* @see https://docs.apify.com/api/v2/act-version-env-var-delete
|
|
51
58
|
*/
|
|
52
|
-
delete(): Promise<void>;
|
|
59
|
+
delete(options?: TimeoutOptions): Promise<void>;
|
|
53
60
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import { timeoutOptionsSchema } from '../timeouts.js';
|
|
2
4
|
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
3
5
|
/**
|
|
4
6
|
* Client for managing a specific Actor environment variable.
|
|
@@ -36,29 +38,38 @@ export class ActorEnvVarClient extends ResourceClient {
|
|
|
36
38
|
/**
|
|
37
39
|
* Retrieves the environment variable.
|
|
38
40
|
*
|
|
41
|
+
* @param options - Request options
|
|
42
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
39
43
|
* @returns The environment variable object, or `undefined` if it does not exist.
|
|
40
44
|
* @see https://docs.apify.com/api/v2/act-version-env-var-get
|
|
41
45
|
*/
|
|
42
|
-
async get() {
|
|
43
|
-
|
|
46
|
+
async get(options = {}) {
|
|
47
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
48
|
+
return this.getResource(schemas.EnvVar(), {}, timeoutSecs);
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* Updates the environment variable.
|
|
47
52
|
*
|
|
48
53
|
* @param actorEnvVar - The updated environment variable data.
|
|
54
|
+
* @param options - Request options
|
|
55
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
49
56
|
* @returns The updated environment variable object.
|
|
50
57
|
* @see https://docs.apify.com/api/v2/act-version-env-var-put
|
|
51
58
|
*/
|
|
52
|
-
async update(actorEnvVar) {
|
|
59
|
+
async update(actorEnvVar, options = {}) {
|
|
53
60
|
parseArgument(actorEnvVar, anyObjectSchema);
|
|
54
|
-
|
|
61
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
62
|
+
return this.updateResource(schemas.EnvVar(), actorEnvVar, timeoutSecs);
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* Deletes the environment variable.
|
|
58
66
|
*
|
|
67
|
+
* @param options - Request options
|
|
68
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
59
69
|
* @see https://docs.apify.com/api/v2/act-version-env-var-delete
|
|
60
70
|
*/
|
|
61
|
-
async delete() {
|
|
62
|
-
|
|
71
|
+
async delete(options = {}) {
|
|
72
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
73
|
+
return this.deleteResource(timeoutSecs);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { TimeoutOptions } from '../timeouts.js';
|
|
4
|
+
import type { PaginatedList } from '../utils.js';
|
|
4
5
|
import type { ActorEnvironmentVariable } from './actor_version.js';
|
|
5
6
|
/**
|
|
6
7
|
* Client for managing the collection of environment variables for an Actor version.
|
|
@@ -37,39 +38,34 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
|
|
|
37
38
|
/**
|
|
38
39
|
* Lists all environment variables of this Actor version.
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* The endpoint returns every environment variable in one response, so awaiting the return value (as you would
|
|
42
|
+
* with a Promise) gets the whole list.
|
|
42
43
|
* ```javascript
|
|
43
|
-
* const
|
|
44
|
-
|
|
44
|
+
* const { items } = await client.list();
|
|
45
|
+
* ```
|
|
45
46
|
*
|
|
46
|
-
* Asynchronous iteration is also supported
|
|
47
|
-
* retrieved.
|
|
47
|
+
* Asynchronous iteration is also supported, and yields the environment variables one by one.
|
|
48
48
|
*
|
|
49
49
|
* ```javascript
|
|
50
50
|
* for await (const singleItem of client.list()) {...}
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
|
-
* @
|
|
53
|
+
* @param options - Request options
|
|
54
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
55
|
+
* @returns The environment variables, awaitable as a whole list or iterable one by one.
|
|
54
56
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
|
|
55
57
|
*/
|
|
56
|
-
list(
|
|
58
|
+
list(options?: TimeoutOptions): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
|
|
57
59
|
/**
|
|
58
60
|
* Creates a new environment variable for this Actor version.
|
|
59
61
|
*
|
|
60
62
|
* @param actorEnvVar - The environment variable data.
|
|
63
|
+
* @param options - Request options
|
|
64
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
61
65
|
* @returns The created environment variable object.
|
|
62
66
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-post
|
|
63
67
|
*/
|
|
64
|
-
create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated No options are used in the current API implementation.
|
|
68
|
-
* https://github.com/apify/apify-client-js/issues/799
|
|
69
|
-
* @since Added in 2.1.0
|
|
70
|
-
*/
|
|
71
|
-
export interface ActorEnvVarCollectionListOptions extends PaginationOptions {
|
|
72
|
-
desc?: boolean;
|
|
68
|
+
create(actorEnvVar: ActorEnvironmentVariable, options?: TimeoutOptions): Promise<ActorEnvironmentVariable>;
|
|
73
69
|
}
|
|
74
70
|
/**
|
|
75
71
|
* @since Added in 2.1.0
|