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
|
@@ -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
3
|
import type { ActorStoreList } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
5
6
|
export type { ActorStoreList, PricingInfo } from '../models.js';
|
|
6
7
|
/**
|
|
@@ -46,6 +47,7 @@ export declare class StoreCollectionClient extends ResourceCollectionClient {
|
|
|
46
47
|
* ```
|
|
47
48
|
*
|
|
48
49
|
* @param options - Search and pagination options.
|
|
50
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
49
51
|
* @returns A paginated iterator of store Actors.
|
|
50
52
|
* @see https://docs.apify.com/api/v2/store-get
|
|
51
53
|
*/
|
|
@@ -54,7 +56,7 @@ export declare class StoreCollectionClient extends ResourceCollectionClient {
|
|
|
54
56
|
/**
|
|
55
57
|
* @since Added in 2.7.2
|
|
56
58
|
*/
|
|
57
|
-
export interface StoreCollectionListOptions extends PaginationOptions {
|
|
59
|
+
export interface StoreCollectionListOptions extends PaginationOptions, TimeoutOptions {
|
|
58
60
|
search?: string;
|
|
59
61
|
sortBy?: string;
|
|
60
62
|
category?: string;
|
|
@@ -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 { timeoutOptionsShape } from '../timeouts.js';
|
|
3
5
|
import { paginationOptionsShape, parseArgument } from '../utils.js';
|
|
4
6
|
const listOptionsSchema = z.strictObject({
|
|
5
7
|
...paginationOptionsShape,
|
|
@@ -9,6 +11,7 @@ const listOptionsSchema = z.strictObject({
|
|
|
9
11
|
username: z.string().optional(),
|
|
10
12
|
pricingModel: z.string().optional(),
|
|
11
13
|
includeUnrunnableActors: z.boolean().optional(),
|
|
14
|
+
...timeoutOptionsShape,
|
|
12
15
|
});
|
|
13
16
|
/**
|
|
14
17
|
* Client for browsing Actors in the Apify Store.
|
|
@@ -58,11 +61,12 @@ export class StoreCollectionClient extends ResourceCollectionClient {
|
|
|
58
61
|
* ```
|
|
59
62
|
*
|
|
60
63
|
* @param options - Search and pagination options.
|
|
64
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
61
65
|
* @returns A paginated iterator of store Actors.
|
|
62
66
|
* @see https://docs.apify.com/api/v2/store-get
|
|
63
67
|
*/
|
|
64
68
|
list(options = {}) {
|
|
65
69
|
const parsed = parseArgument(options, listOptionsSchema, 'StoreCollectionListOptions');
|
|
66
|
-
return this.
|
|
70
|
+
return this.listResourcesPaginated(schemas.ListOfStoreActors(), parsed, 'medium');
|
|
67
71
|
}
|
|
68
72
|
}
|
|
@@ -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 { Task, TaskPublicConfig } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
import type { Dictionary } from '../utils.js';
|
|
5
6
|
import type { ActorLastRunOptions, ActorRun, ActorStartOptions } from './actor.js';
|
|
6
7
|
import { RunClient } from './run.js';
|
|
@@ -35,18 +36,22 @@ export declare class TaskClient extends ResourceClient {
|
|
|
35
36
|
/**
|
|
36
37
|
* Retrieves the Actor task.
|
|
37
38
|
*
|
|
39
|
+
* @param options - Request options
|
|
40
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
38
41
|
* @returns The task object, or `undefined` if it does not exist.
|
|
39
42
|
* @see https://docs.apify.com/api/v2/actor-task-get
|
|
40
43
|
*/
|
|
41
|
-
get(): Promise<Task | undefined>;
|
|
44
|
+
get(options?: TimeoutOptions): Promise<Task | undefined>;
|
|
42
45
|
/**
|
|
43
46
|
* Updates the task with the specified fields.
|
|
44
47
|
*
|
|
45
48
|
* @param newFields - Fields to update.
|
|
49
|
+
* @param options - Request options
|
|
50
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
46
51
|
* @returns The updated task object.
|
|
47
52
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
48
53
|
*/
|
|
49
|
-
update(newFields: TaskUpdateData): Promise<Task>;
|
|
54
|
+
update(newFields: TaskUpdateData, options?: TimeoutOptions): Promise<Task>;
|
|
50
55
|
/**
|
|
51
56
|
* Publishes the task on its public landing page, by setting `isPublic` through
|
|
52
57
|
* {@apilink TaskClient.update}.
|
|
@@ -55,11 +60,13 @@ export declare class TaskClient extends ResourceClient {
|
|
|
55
60
|
* (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
|
|
56
61
|
* Publishing an already published task does nothing.
|
|
57
62
|
*
|
|
63
|
+
* @param options - Request options
|
|
64
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
58
65
|
* @returns The task object.
|
|
59
66
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
60
67
|
* @since Added in 2.25.0
|
|
61
68
|
*/
|
|
62
|
-
publish(): Promise<Task>;
|
|
69
|
+
publish(options?: TimeoutOptions): Promise<Task>;
|
|
63
70
|
/**
|
|
64
71
|
* Unpublishes the task from its public landing page, by setting `isPublic` through
|
|
65
72
|
* {@apilink TaskClient.update}.
|
|
@@ -68,17 +75,21 @@ export declare class TaskClient extends ResourceClient {
|
|
|
68
75
|
* published again without re-entering it. Requires write permission to both the task and its
|
|
69
76
|
* Actor. Unpublishing a task that is not published does nothing.
|
|
70
77
|
*
|
|
78
|
+
* @param options - Request options
|
|
79
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
71
80
|
* @returns The task object.
|
|
72
81
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
73
82
|
* @since Added in 2.25.0
|
|
74
83
|
*/
|
|
75
|
-
unpublish(): Promise<Task>;
|
|
84
|
+
unpublish(options?: TimeoutOptions): Promise<Task>;
|
|
76
85
|
/**
|
|
77
86
|
* Deletes the Task.
|
|
78
87
|
*
|
|
88
|
+
* @param options - Request options
|
|
89
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
79
90
|
* @see https://docs.apify.com/api/v2/actor-task-delete
|
|
80
91
|
*/
|
|
81
|
-
delete(): Promise<void>;
|
|
92
|
+
delete(options?: TimeoutOptions): Promise<void>;
|
|
82
93
|
/**
|
|
83
94
|
* Starts an Actor task and immediately returns the Run object.
|
|
84
95
|
*
|
|
@@ -86,12 +97,14 @@ export declare class TaskClient extends ResourceClient {
|
|
|
86
97
|
* @param options - Run options.
|
|
87
98
|
* @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
|
|
88
99
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
89
|
-
* @param options.
|
|
100
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
|
|
90
101
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
|
|
91
102
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
92
103
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
93
104
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
94
105
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
106
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
|
|
107
|
+
* when the API is asked to hold the response.
|
|
95
108
|
* @returns The Actor Run object.
|
|
96
109
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
97
110
|
*/
|
|
@@ -104,12 +117,13 @@ export declare class TaskClient extends ResourceClient {
|
|
|
104
117
|
* @param options - Run and wait options.
|
|
105
118
|
* @param options.build - Tag or number of the Actor build to run.
|
|
106
119
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
107
|
-
* @param options.
|
|
120
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds.
|
|
108
121
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
109
122
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
110
123
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
111
124
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
112
125
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
126
|
+
* @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
|
|
113
127
|
* @returns The Actor run object.
|
|
114
128
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
115
129
|
*/
|
|
@@ -117,18 +131,22 @@ export declare class TaskClient extends ResourceClient {
|
|
|
117
131
|
/**
|
|
118
132
|
* Retrieves the Actor task's input object.
|
|
119
133
|
*
|
|
120
|
-
* @
|
|
134
|
+
* @param options - Request options
|
|
135
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
136
|
+
* @returns The Task's input.
|
|
121
137
|
* @see https://docs.apify.com/api/v2/actor-task-input-get
|
|
122
138
|
*/
|
|
123
|
-
getInput(): Promise<Dictionary | Dictionary[]
|
|
139
|
+
getInput(options?: TimeoutOptions): Promise<Dictionary | Dictionary[]>;
|
|
124
140
|
/**
|
|
125
141
|
* Updates the Actor task's input object.
|
|
126
142
|
*
|
|
127
143
|
* @param newFields - New input data for the task.
|
|
144
|
+
* @param options - Request options
|
|
145
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
128
146
|
* @returns The updated task input.
|
|
129
147
|
* @see https://docs.apify.com/api/v2/actor-task-input-put
|
|
130
148
|
*/
|
|
131
|
-
updateInput(newFields: Dictionary | Dictionary[]): Promise<Dictionary | Dictionary[]>;
|
|
149
|
+
updateInput(newFields: Dictionary | Dictionary[], options?: TimeoutOptions): Promise<Dictionary | Dictionary[]>;
|
|
132
150
|
/**
|
|
133
151
|
* Returns a client for the last run of this task.
|
|
134
152
|
*
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
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
|
-
import
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
5
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
6
|
+
import { anyObjectSchema, cast, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
|
|
5
7
|
import { RunClient } from './run.js';
|
|
6
8
|
import { RunCollectionClient } from './run_collection.js';
|
|
7
9
|
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
@@ -9,22 +11,24 @@ const inputSchema = anyObjectSchema.optional();
|
|
|
9
11
|
const startOptionsSchema = z.strictObject({
|
|
10
12
|
build: z.string().optional(),
|
|
11
13
|
memory: z.number().optional(),
|
|
12
|
-
|
|
14
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
13
15
|
waitForFinish: z.number().optional(),
|
|
14
16
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
15
17
|
maxItems: z.number().min(0).optional(),
|
|
16
18
|
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
17
19
|
restartOnError: z.boolean().optional(),
|
|
20
|
+
...timeoutOptionsShape,
|
|
18
21
|
});
|
|
19
22
|
const callOptionsSchema = z.strictObject({
|
|
20
23
|
build: z.string().optional(),
|
|
21
24
|
memory: z.number().optional(),
|
|
22
|
-
|
|
25
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
23
26
|
waitSecs: z.number().min(0).optional(),
|
|
24
27
|
webhooks: z.array(anyObjectSchema).optional(),
|
|
25
28
|
maxItems: z.number().min(0).optional(),
|
|
26
29
|
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
27
30
|
restartOnError: z.boolean().optional(),
|
|
31
|
+
...timeoutOptionsShape,
|
|
28
32
|
});
|
|
29
33
|
const lastRunOptionsSchema = z.strictObject({
|
|
30
34
|
status: z.enum(ACT_JOB_STATUSES).optional(),
|
|
@@ -63,22 +67,28 @@ export class TaskClient extends ResourceClient {
|
|
|
63
67
|
/**
|
|
64
68
|
* Retrieves the Actor task.
|
|
65
69
|
*
|
|
70
|
+
* @param options - Request options
|
|
71
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
66
72
|
* @returns The task object, or `undefined` if it does not exist.
|
|
67
73
|
* @see https://docs.apify.com/api/v2/actor-task-get
|
|
68
74
|
*/
|
|
69
|
-
async get() {
|
|
70
|
-
|
|
75
|
+
async get(options = {}) {
|
|
76
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
77
|
+
return this.getResource(schemas.Task(), {}, timeoutSecs);
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
80
|
* Updates the task with the specified fields.
|
|
74
81
|
*
|
|
75
82
|
* @param newFields - Fields to update.
|
|
83
|
+
* @param options - Request options
|
|
84
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
76
85
|
* @returns The updated task object.
|
|
77
86
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
78
87
|
*/
|
|
79
|
-
async update(newFields) {
|
|
88
|
+
async update(newFields, options = {}) {
|
|
80
89
|
parseArgument(newFields, anyObjectSchema);
|
|
81
|
-
|
|
90
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
91
|
+
return this.updateResource(schemas.Task(), newFields, timeoutSecs);
|
|
82
92
|
}
|
|
83
93
|
/**
|
|
84
94
|
* Publishes the task on its public landing page, by setting `isPublic` through
|
|
@@ -88,12 +98,14 @@ export class TaskClient extends ResourceClient {
|
|
|
88
98
|
* (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
|
|
89
99
|
* Publishing an already published task does nothing.
|
|
90
100
|
*
|
|
101
|
+
* @param options - Request options
|
|
102
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
91
103
|
* @returns The task object.
|
|
92
104
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
93
105
|
* @since Added in 2.25.0
|
|
94
106
|
*/
|
|
95
|
-
async publish() {
|
|
96
|
-
return this.update({ isPublic: true });
|
|
107
|
+
async publish(options = {}) {
|
|
108
|
+
return this.update({ isPublic: true }, options);
|
|
97
109
|
}
|
|
98
110
|
/**
|
|
99
111
|
* Unpublishes the task from its public landing page, by setting `isPublic` through
|
|
@@ -103,20 +115,25 @@ export class TaskClient extends ResourceClient {
|
|
|
103
115
|
* published again without re-entering it. Requires write permission to both the task and its
|
|
104
116
|
* Actor. Unpublishing a task that is not published does nothing.
|
|
105
117
|
*
|
|
118
|
+
* @param options - Request options
|
|
119
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
106
120
|
* @returns The task object.
|
|
107
121
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
108
122
|
* @since Added in 2.25.0
|
|
109
123
|
*/
|
|
110
|
-
async unpublish() {
|
|
111
|
-
return this.update({ isPublic: false });
|
|
124
|
+
async unpublish(options = {}) {
|
|
125
|
+
return this.update({ isPublic: false }, options);
|
|
112
126
|
}
|
|
113
127
|
/**
|
|
114
128
|
* Deletes the Task.
|
|
115
129
|
*
|
|
130
|
+
* @param options - Request options
|
|
131
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
116
132
|
* @see https://docs.apify.com/api/v2/actor-task-delete
|
|
117
133
|
*/
|
|
118
|
-
async delete() {
|
|
119
|
-
|
|
134
|
+
async delete(options = {}) {
|
|
135
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
136
|
+
return this.deleteResource(timeoutSecs);
|
|
120
137
|
}
|
|
121
138
|
/**
|
|
122
139
|
* Starts an Actor task and immediately returns the Run object.
|
|
@@ -125,22 +142,25 @@ export class TaskClient extends ResourceClient {
|
|
|
125
142
|
* @param options - Run options.
|
|
126
143
|
* @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
|
|
127
144
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
128
|
-
* @param options.
|
|
145
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
|
|
129
146
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
|
|
130
147
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
131
148
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
132
149
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
133
150
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
151
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
|
|
152
|
+
* when the API is asked to hold the response.
|
|
134
153
|
* @returns The Actor Run object.
|
|
135
154
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
136
155
|
*/
|
|
137
156
|
async start(input, options = {}) {
|
|
138
157
|
parseArgument(input, inputSchema);
|
|
139
158
|
const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
|
|
140
|
-
const { waitForFinish,
|
|
159
|
+
const { waitForFinish, runTimeoutSecs, memory, build, maxItems, maxTotalChargeUsd, restartOnError, timeoutSecs, } = parsed;
|
|
160
|
+
// The API's `timeout` parameter bounds the run, not the request.
|
|
141
161
|
const params = {
|
|
142
162
|
waitForFinish,
|
|
143
|
-
timeout,
|
|
163
|
+
timeout: runTimeoutSecs,
|
|
144
164
|
memory,
|
|
145
165
|
build,
|
|
146
166
|
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
@@ -149,19 +169,20 @@ export class TaskClient extends ResourceClient {
|
|
|
149
169
|
restartOnError,
|
|
150
170
|
};
|
|
151
171
|
const request = {
|
|
152
|
-
url: this.
|
|
172
|
+
url: this.buildUrl('runs'),
|
|
153
173
|
method: 'POST',
|
|
154
174
|
data: input,
|
|
155
|
-
params: this.
|
|
175
|
+
params: this.buildParams(params),
|
|
156
176
|
// Apify internal property. Tells the request serialization interceptor
|
|
157
177
|
// to stringify functions to JSON, instead of omitting them.
|
|
158
178
|
stringifyFunctions: true,
|
|
159
179
|
headers: {
|
|
160
180
|
'Content-Type': 'application/json',
|
|
161
181
|
},
|
|
182
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', waitForFinish),
|
|
162
183
|
};
|
|
163
184
|
const response = await this.httpClient.call(request);
|
|
164
|
-
return
|
|
185
|
+
return parseResponse(response, schemas.Run());
|
|
165
186
|
}
|
|
166
187
|
/**
|
|
167
188
|
* Starts a task and waits for it to finish before returning the Run object.
|
|
@@ -171,59 +192,61 @@ export class TaskClient extends ResourceClient {
|
|
|
171
192
|
* @param options - Run and wait options.
|
|
172
193
|
* @param options.build - Tag or number of the Actor build to run.
|
|
173
194
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
174
|
-
* @param options.
|
|
195
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds.
|
|
175
196
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
176
197
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
177
198
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
178
199
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
179
200
|
* @param options.restartOnError - Whether to restart the run on error.
|
|
201
|
+
* @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
|
|
180
202
|
* @returns The Actor run object.
|
|
181
203
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
182
204
|
*/
|
|
183
205
|
async call(input, options = {}) {
|
|
184
206
|
parseArgument(input, inputSchema);
|
|
185
207
|
const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
|
|
186
|
-
const { waitSecs, ...startOptions } = parsed;
|
|
187
|
-
const { id } = await this.start(input, startOptions);
|
|
208
|
+
const { waitSecs, timeoutSecs = 'noTimeout', ...startOptions } = parsed;
|
|
209
|
+
const { id } = await this.start(input, { ...startOptions, timeoutSecs });
|
|
188
210
|
// Calling root client because we need access to top level API.
|
|
189
211
|
// Creating a new instance of RunClient here would only allow
|
|
190
212
|
// setting it up as a nested route under task API.
|
|
191
|
-
return this.apifyClient.run(id).waitForFinish({ waitSecs });
|
|
213
|
+
return this.apifyClient.run(id).waitForFinish({ waitSecs, timeoutSecs });
|
|
192
214
|
}
|
|
193
215
|
/**
|
|
194
216
|
* Retrieves the Actor task's input object.
|
|
195
217
|
*
|
|
196
|
-
* @
|
|
218
|
+
* @param options - Request options
|
|
219
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
220
|
+
* @returns The Task's input.
|
|
197
221
|
* @see https://docs.apify.com/api/v2/actor-task-input-get
|
|
198
222
|
*/
|
|
199
|
-
async getInput() {
|
|
200
|
-
const
|
|
201
|
-
|
|
223
|
+
async getInput(options = {}) {
|
|
224
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
225
|
+
const response = await this.httpClient.call({
|
|
226
|
+
url: this.buildUrl('input'),
|
|
202
227
|
method: 'GET',
|
|
203
|
-
params: this.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return cast(response.data);
|
|
208
|
-
}
|
|
209
|
-
catch (err) {
|
|
210
|
-
catchNotFoundOrThrow(err);
|
|
211
|
-
}
|
|
212
|
-
return undefined;
|
|
228
|
+
params: this.buildParams(),
|
|
229
|
+
timeoutSecs,
|
|
230
|
+
});
|
|
231
|
+
return cast(response.data);
|
|
213
232
|
}
|
|
214
233
|
/**
|
|
215
234
|
* Updates the Actor task's input object.
|
|
216
235
|
*
|
|
217
236
|
* @param newFields - New input data for the task.
|
|
237
|
+
* @param options - Request options
|
|
238
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
218
239
|
* @returns The updated task input.
|
|
219
240
|
* @see https://docs.apify.com/api/v2/actor-task-input-put
|
|
220
241
|
*/
|
|
221
|
-
async updateInput(newFields) {
|
|
242
|
+
async updateInput(newFields, options = {}) {
|
|
243
|
+
const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
222
244
|
const response = await this.httpClient.call({
|
|
223
|
-
url: this.
|
|
245
|
+
url: this.buildUrl('input'),
|
|
224
246
|
method: 'PUT',
|
|
225
|
-
params: this.
|
|
247
|
+
params: this.buildParams(),
|
|
226
248
|
data: newFields,
|
|
249
|
+
timeoutSecs,
|
|
227
250
|
});
|
|
228
251
|
return cast(response.data);
|
|
229
252
|
}
|
|
@@ -238,9 +261,9 @@ export class TaskClient extends ResourceClient {
|
|
|
238
261
|
*/
|
|
239
262
|
lastRun(options = {}) {
|
|
240
263
|
const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
|
|
241
|
-
return new RunClient(this.
|
|
264
|
+
return new RunClient(this.subResourceOptions({
|
|
242
265
|
id: 'last',
|
|
243
|
-
params: this.
|
|
266
|
+
params: this.buildParams(parsed),
|
|
244
267
|
resourcePath: 'runs',
|
|
245
268
|
}));
|
|
246
269
|
}
|
|
@@ -251,7 +274,7 @@ export class TaskClient extends ResourceClient {
|
|
|
251
274
|
* @see https://docs.apify.com/api/v2/actor-task-runs-get
|
|
252
275
|
*/
|
|
253
276
|
runs() {
|
|
254
|
-
return new RunCollectionClient(this.
|
|
277
|
+
return new RunCollectionClient(this.subResourceOptions({
|
|
255
278
|
resourcePath: 'runs',
|
|
256
279
|
}));
|
|
257
280
|
}
|
|
@@ -262,6 +285,6 @@ export class TaskClient extends ResourceClient {
|
|
|
262
285
|
* @see https://docs.apify.com/api/v2/actor-task-webhooks-get
|
|
263
286
|
*/
|
|
264
287
|
webhooks() {
|
|
265
|
-
return new WebhookCollectionClient(this.
|
|
288
|
+
return new WebhookCollectionClient(this.subResourceOptions());
|
|
266
289
|
}
|
|
267
290
|
}
|
|
@@ -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
3
|
import type { TaskList } 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
7
|
export type { TaskList } from '../models.js';
|
|
@@ -50,6 +51,7 @@ 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
|
*/
|
|
@@ -58,12 +60,14 @@ export declare class TaskCollectionClient extends ResourceCollectionClient {
|
|
|
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,9 +1,12 @@
|
|
|
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 listOptionsSchema = z.strictObject({
|
|
5
7
|
...paginationOptionsShape,
|
|
6
8
|
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
7
10
|
});
|
|
8
11
|
/**
|
|
9
12
|
* Client for managing the collection of Actor tasks in your account.
|
|
@@ -56,22 +59,26 @@ export class TaskCollectionClient extends ResourceCollectionClient {
|
|
|
56
59
|
* ```
|
|
57
60
|
*
|
|
58
61
|
* @param options - Pagination and sorting options.
|
|
62
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
59
63
|
* @returns A paginated iterator of tasks.
|
|
60
64
|
* @see https://docs.apify.com/api/v2/actor-tasks-get
|
|
61
65
|
*/
|
|
62
66
|
list(options = {}) {
|
|
63
67
|
const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
|
|
64
|
-
return this.
|
|
68
|
+
return this.listResourcesPaginated(schemas.ListOfTasks(), parsed, 'medium');
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Creates a new task.
|
|
68
72
|
*
|
|
69
73
|
* @param task - The task data.
|
|
74
|
+
* @param options - Request options
|
|
75
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
70
76
|
* @returns The created task object.
|
|
71
77
|
* @see https://docs.apify.com/api/v2/actor-tasks-post
|
|
72
78
|
*/
|
|
73
|
-
async create(task) {
|
|
79
|
+
async create(task, options = {}) {
|
|
74
80
|
parseArgument(task, anyObjectSchema);
|
|
75
|
-
|
|
81
|
+
const { timeoutSecs = 'medium' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
82
|
+
return this.createResource(schemas.Task(), task, timeoutSecs);
|
|
76
83
|
}
|
|
77
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 { AccountAndUsageLimits, MonthlyUsage, User } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
4
5
|
export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models.js';
|
|
5
6
|
export { PlatformFeature } from '../models.js';
|
|
6
7
|
/**
|
|
@@ -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<User>;
|
|
47
|
+
get(options?: TimeoutOptions): Promise<User | 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<AccountAndUsageLimits
|
|
67
|
+
limits(options?: TimeoutOptions): Promise<AccountAndUsageLimits>;
|
|
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
|