apify-client 3.0.0-beta.1 → 3.0.0-beta.100
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 +21 -5
- package/dist/apify_api_error.d.ts +64 -22
- package/dist/apify_api_error.js +100 -30
- package/dist/apify_client.d.ts +150 -35
- package/dist/apify_client.js +198 -118
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/base/api_client.d.ts +9 -9
- package/dist/base/api_client.js +41 -45
- package/dist/base/resource_client.d.ts +24 -10
- package/dist/base/resource_client.js +78 -48
- package/dist/base/resource_collection_client.d.ts +15 -6
- package/dist/base/resource_collection_client.js +40 -21
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +20 -32
- package/dist/bundle.js +47 -52
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3363 -1185
- package/dist/generated/api.js +1 -2
- package/dist/generated/schemas.d.ts +8146 -0
- package/dist/generated/schemas.js +1866 -0
- package/dist/http_clients/axios.d.ts +61 -0
- package/dist/http_clients/axios.js +119 -0
- package/dist/http_clients/base.d.ts +391 -0
- package/dist/http_clients/base.js +650 -0
- package/dist/http_clients/index.d.ts +4 -0
- package/dist/http_clients/index.js +2 -0
- package/dist/http_compressors/base.d.ts +40 -0
- package/dist/http_compressors/base.js +9 -0
- package/dist/http_compressors/brotli.d.ts +33 -0
- package/dist/http_compressors/brotli.js +39 -0
- package/dist/http_compressors/gzip.d.ts +33 -0
- package/dist/http_compressors/gzip.js +39 -0
- package/dist/http_compressors/index.d.ts +8 -0
- package/dist/http_compressors/index.js +3 -0
- package/dist/http_compressors/resolve.d.ts +24 -0
- package/dist/http_compressors/resolve.js +30 -0
- package/dist/http_compressors/zstd.d.ts +34 -0
- package/dist/http_compressors/zstd.js +43 -0
- package/dist/index.d.ts +38 -32
- package/dist/index.js +36 -36
- package/dist/invalid_response_body_error.d.ts +14 -0
- package/dist/invalid_response_body_error.js +18 -0
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +196 -278
- package/dist/models.js +14 -15
- package/dist/resource_clients/actor.d.ts +115 -45
- package/dist/resource_clients/actor.js +187 -116
- package/dist/resource_clients/actor_collection.d.ts +21 -17
- package/dist/resource_clients/actor_collection.js +26 -21
- package/dist/resource_clients/actor_env_var.d.ts +13 -6
- package/dist/resource_clients/actor_env_var.js +21 -14
- package/dist/resource_clients/actor_env_var_collection.d.ts +18 -22
- package/dist/resource_clients/actor_env_var_collection.js +23 -20
- package/dist/resource_clients/actor_server.d.ts +149 -0
- package/dist/resource_clients/actor_server.js +199 -0
- package/dist/resource_clients/actor_version.d.ts +30 -10
- package/dist/resource_clients/actor_version.js +29 -23
- package/dist/resource_clients/actor_version_collection.d.ts +20 -21
- package/dist/resource_clients/actor_version_collection.js +25 -20
- package/dist/resource_clients/build.d.ts +24 -11
- package/dist/resource_clients/build.js +43 -26
- package/dist/resource_clients/build_collection.d.ts +10 -8
- package/dist/resource_clients/build_collection.js +13 -13
- package/dist/resource_clients/dataset.d.ts +87 -40
- package/dist/resource_clients/dataset.js +159 -175
- package/dist/resource_clients/dataset_collection.d.ts +13 -9
- package/dist/resource_clients/dataset_collection.js +29 -21
- package/dist/resource_clients/key_value_store.d.ts +110 -28
- package/dist/resource_clients/key_value_store.js +177 -99
- package/dist/resource_clients/key_value_store_collection.d.ts +13 -9
- package/dist/resource_clients/key_value_store_collection.js +29 -21
- package/dist/resource_clients/log.d.ts +42 -23
- package/dist/resource_clients/log.js +156 -85
- package/dist/resource_clients/request_queue.d.ts +77 -38
- package/dist/resource_clients/request_queue.js +251 -172
- package/dist/resource_clients/request_queue_collection.d.ts +12 -8
- package/dist/resource_clients/request_queue_collection.js +23 -20
- package/dist/resource_clients/run.d.ts +134 -34
- package/dist/resource_clients/run.js +225 -84
- package/dist/resource_clients/run_collection.d.ts +8 -6
- package/dist/resource_clients/run_collection.js +18 -18
- package/dist/resource_clients/schedule.d.ts +20 -11
- package/dist/resource_clients/schedule.js +36 -30
- package/dist/resource_clients/schedule_collection.d.ts +10 -6
- package/dist/resource_clients/schedule_collection.js +20 -17
- package/dist/resource_clients/store_collection.d.ts +9 -7
- package/dist/resource_clients/store_collection.js +18 -18
- package/dist/resource_clients/task.d.ts +44 -21
- package/dist/resource_clients/task.js +116 -86
- package/dist/resource_clients/task_collection.d.ts +13 -9
- package/dist/resource_clients/task_collection.js +19 -16
- package/dist/resource_clients/user.d.ts +22 -13
- package/dist/resource_clients/user.js +46 -47
- package/dist/resource_clients/webhook.d.ts +21 -12
- package/dist/resource_clients/webhook.js +35 -30
- package/dist/resource_clients/webhook_collection.d.ts +11 -7
- package/dist/resource_clients/webhook_collection.js +20 -17
- package/dist/resource_clients/webhook_dispatch.d.ts +9 -6
- package/dist/resource_clients/webhook_dispatch.js +11 -10
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +7 -5
- package/dist/resource_clients/webhook_dispatch_collection.js +13 -13
- package/dist/response_validation_error.d.ts +27 -0
- package/dist/response_validation_error.js +38 -0
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +87 -0
- package/dist/runtime/types.d.ts +60 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +21 -0
- package/dist/schemas.d.ts +381 -0
- package/dist/schemas.js +37 -0
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +7 -11
- package/dist/timeouts.d.ts +84 -0
- package/dist/timeouts.js +37 -0
- package/dist/timezones.d.ts +1 -1
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +99 -70
- package/dist/utils.js +251 -229
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +48 -47
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/http_client.d.ts +0 -88
- package/dist/http_client.js +0 -260
- package/dist/index.mjs +0 -42
- package/dist/interceptors.d.ts +0 -19
- package/dist/interceptors.js +0 -110
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const inputSchema =
|
|
12
|
-
const startOptionsSchema =
|
|
13
|
-
build:
|
|
14
|
-
memory:
|
|
15
|
-
|
|
16
|
-
waitForFinish:
|
|
17
|
-
webhooks:
|
|
18
|
-
maxItems:
|
|
19
|
-
maxTotalChargeUsd:
|
|
20
|
-
restartOnError:
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
|
|
3
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
4
|
+
import * as schemas from '../schemas.js';
|
|
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';
|
|
8
|
+
import { RunClient } from './run.js';
|
|
9
|
+
import { RunCollectionClient } from './run_collection.js';
|
|
10
|
+
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
11
|
+
const inputSchema = anyObjectSchema.optional();
|
|
12
|
+
const startOptionsSchema = z.strictObject({
|
|
13
|
+
build: z.string().optional(),
|
|
14
|
+
memory: z.number().optional(),
|
|
15
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
16
|
+
waitForFinish: z.number().optional(),
|
|
17
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
18
|
+
maxItems: z.number().min(0).optional(),
|
|
19
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
20
|
+
restartOnError: z.boolean().optional(),
|
|
21
|
+
waitForResources: z.union([z.boolean(), z.number().min(0)]).optional(),
|
|
22
|
+
...timeoutOptionsShape,
|
|
21
23
|
});
|
|
22
|
-
const callOptionsSchema =
|
|
23
|
-
build:
|
|
24
|
-
memory:
|
|
25
|
-
|
|
26
|
-
waitSecs:
|
|
27
|
-
webhooks:
|
|
28
|
-
maxItems:
|
|
29
|
-
maxTotalChargeUsd:
|
|
30
|
-
restartOnError:
|
|
24
|
+
const callOptionsSchema = z.strictObject({
|
|
25
|
+
build: z.string().optional(),
|
|
26
|
+
memory: z.number().optional(),
|
|
27
|
+
runTimeoutSecs: z.number().min(0).optional(),
|
|
28
|
+
waitSecs: z.number().min(0).optional(),
|
|
29
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
30
|
+
maxItems: z.number().min(0).optional(),
|
|
31
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
32
|
+
restartOnError: z.boolean().optional(),
|
|
33
|
+
waitForResources: z.union([z.boolean(), z.number().min(0)]).optional(),
|
|
34
|
+
...timeoutOptionsShape,
|
|
31
35
|
});
|
|
32
|
-
const lastRunOptionsSchema =
|
|
33
|
-
status:
|
|
34
|
-
origin:
|
|
36
|
+
const lastRunOptionsSchema = z.strictObject({
|
|
37
|
+
status: z.enum(ACT_JOB_STATUSES).optional(),
|
|
38
|
+
origin: z.enum(META_ORIGINS).optional(),
|
|
35
39
|
});
|
|
36
40
|
/**
|
|
37
41
|
* Client for managing a specific Actor task.
|
|
@@ -53,7 +57,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
|
|
|
53
57
|
*
|
|
54
58
|
* @see https://docs.apify.com/platform/actors/running/tasks
|
|
55
59
|
*/
|
|
56
|
-
class TaskClient extends
|
|
60
|
+
export class TaskClient extends ResourceClient {
|
|
57
61
|
/**
|
|
58
62
|
* @hidden
|
|
59
63
|
*/
|
|
@@ -66,22 +70,28 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
66
70
|
/**
|
|
67
71
|
* Retrieves the Actor task.
|
|
68
72
|
*
|
|
73
|
+
* @param options - Request options
|
|
74
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
69
75
|
* @returns The task object, or `undefined` if it does not exist.
|
|
70
76
|
* @see https://docs.apify.com/api/v2/actor-task-get
|
|
71
77
|
*/
|
|
72
|
-
async get() {
|
|
73
|
-
|
|
78
|
+
async get(options = {}) {
|
|
79
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
80
|
+
return this.getResource(schemas.Task(), {}, timeoutSecs, signal);
|
|
74
81
|
}
|
|
75
82
|
/**
|
|
76
83
|
* Updates the task with the specified fields.
|
|
77
84
|
*
|
|
78
85
|
* @param newFields - Fields to update.
|
|
86
|
+
* @param options - Request options
|
|
87
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
79
88
|
* @returns The updated task object.
|
|
80
89
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
81
90
|
*/
|
|
82
|
-
async update(newFields) {
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
async update(newFields, options = {}) {
|
|
92
|
+
parseArgument(newFields, anyObjectSchema);
|
|
93
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
94
|
+
return this.updateResource(schemas.Task(), newFields, timeoutSecs, signal);
|
|
85
95
|
}
|
|
86
96
|
/**
|
|
87
97
|
* Publishes the task on its public landing page, by setting `isPublic` through
|
|
@@ -91,12 +101,14 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
91
101
|
* (`publicConfig`) set up first. Requires write permission to both the task and its Actor.
|
|
92
102
|
* Publishing an already published task does nothing.
|
|
93
103
|
*
|
|
104
|
+
* @param options - Request options
|
|
105
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
94
106
|
* @returns The task object.
|
|
95
107
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
96
108
|
* @since Added in 2.25.0
|
|
97
109
|
*/
|
|
98
|
-
async publish() {
|
|
99
|
-
return this.update({ isPublic: true });
|
|
110
|
+
async publish(options = {}) {
|
|
111
|
+
return this.update({ isPublic: true }, options);
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
114
|
* Unpublishes the task from its public landing page, by setting `isPublic` through
|
|
@@ -106,20 +118,25 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
106
118
|
* published again without re-entering it. Requires write permission to both the task and its
|
|
107
119
|
* Actor. Unpublishing a task that is not published does nothing.
|
|
108
120
|
*
|
|
121
|
+
* @param options - Request options
|
|
122
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
109
123
|
* @returns The task object.
|
|
110
124
|
* @see https://docs.apify.com/api/v2/actor-task-put
|
|
111
125
|
* @since Added in 2.25.0
|
|
112
126
|
*/
|
|
113
|
-
async unpublish() {
|
|
114
|
-
return this.update({ isPublic: false });
|
|
127
|
+
async unpublish(options = {}) {
|
|
128
|
+
return this.update({ isPublic: false }, options);
|
|
115
129
|
}
|
|
116
130
|
/**
|
|
117
131
|
* Deletes the Task.
|
|
118
132
|
*
|
|
133
|
+
* @param options - Request options
|
|
134
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
119
135
|
* @see https://docs.apify.com/api/v2/actor-task-delete
|
|
120
136
|
*/
|
|
121
|
-
async delete() {
|
|
122
|
-
|
|
137
|
+
async delete(options = {}) {
|
|
138
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
139
|
+
return this.deleteResource(timeoutSecs, signal);
|
|
123
140
|
}
|
|
124
141
|
/**
|
|
125
142
|
* Starts an Actor task and immediately returns the Run object.
|
|
@@ -128,43 +145,50 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
128
145
|
* @param options - Run options.
|
|
129
146
|
* @param options.build - Tag or number of the Actor build to run (e.g., `'beta'` or `'1.2.345'`).
|
|
130
147
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
131
|
-
* @param options.
|
|
148
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout.
|
|
132
149
|
* @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish before returning.
|
|
133
150
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
134
151
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
135
152
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
136
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.
|
|
137
158
|
* @returns The Actor Run object.
|
|
138
159
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
139
160
|
*/
|
|
140
161
|
async start(input, options = {}) {
|
|
141
|
-
|
|
142
|
-
const parsed =
|
|
143
|
-
const { waitForFinish,
|
|
162
|
+
parseArgument(input, inputSchema);
|
|
163
|
+
const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
|
|
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.
|
|
144
166
|
const params = {
|
|
145
167
|
waitForFinish,
|
|
146
|
-
timeout,
|
|
168
|
+
timeout: runTimeoutSecs,
|
|
147
169
|
memory,
|
|
148
170
|
build,
|
|
149
|
-
webhooks:
|
|
171
|
+
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
150
172
|
maxItems,
|
|
151
173
|
maxTotalChargeUsd,
|
|
152
174
|
restartOnError,
|
|
153
175
|
};
|
|
154
176
|
const request = {
|
|
155
|
-
url: this.
|
|
177
|
+
url: this.buildUrl('runs'),
|
|
156
178
|
method: 'POST',
|
|
157
179
|
data: input,
|
|
158
|
-
params: this.
|
|
159
|
-
//
|
|
160
|
-
// 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.
|
|
161
182
|
stringifyFunctions: true,
|
|
162
183
|
headers: {
|
|
163
184
|
'Content-Type': 'application/json',
|
|
164
185
|
},
|
|
186
|
+
timeoutSecs: this.timeoutForWaitForFinish(timeoutSecs, 'medium', waitForFinish),
|
|
187
|
+
signal,
|
|
165
188
|
};
|
|
166
|
-
|
|
167
|
-
|
|
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);
|
|
191
|
+
return parseResponse(response, schemas.Run());
|
|
168
192
|
}
|
|
169
193
|
/**
|
|
170
194
|
* Starts a task and waits for it to finish before returning the Run object.
|
|
@@ -174,61 +198,68 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
174
198
|
* @param options - Run and wait options.
|
|
175
199
|
* @param options.build - Tag or number of the Actor build to run.
|
|
176
200
|
* @param options.memory - Memory in megabytes allocated for the run.
|
|
177
|
-
* @param options.
|
|
201
|
+
* @param options.runTimeoutSecs - Timeout for the run in seconds.
|
|
178
202
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
179
203
|
* @param options.webhooks - Webhooks to trigger for specific Actor run events.
|
|
180
204
|
* @param options.maxItems - Maximum number of dataset items (for pay-per-result Actors).
|
|
181
205
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (for pay-per-event Actors).
|
|
182
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'`.
|
|
183
211
|
* @returns The Actor run object.
|
|
184
212
|
* @see https://docs.apify.com/api/v2/actor-task-runs-post
|
|
185
213
|
*/
|
|
186
214
|
async call(input, options = {}) {
|
|
187
|
-
|
|
188
|
-
const parsed =
|
|
189
|
-
const { waitSecs, ...startOptions } = parsed;
|
|
190
|
-
const { id } = await this.start(input, startOptions);
|
|
215
|
+
parseArgument(input, inputSchema);
|
|
216
|
+
const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
|
|
217
|
+
const { waitSecs, timeoutSecs = 'noTimeout', signal, ...startOptions } = parsed;
|
|
218
|
+
const { id } = await this.start(input, { ...startOptions, timeoutSecs, signal });
|
|
191
219
|
// Calling root client because we need access to top level API.
|
|
192
220
|
// Creating a new instance of RunClient here would only allow
|
|
193
221
|
// setting it up as a nested route under task API.
|
|
194
|
-
return this.apifyClient.run(id).waitForFinish({ waitSecs });
|
|
222
|
+
return this.apifyClient.run(id).waitForFinish({ waitSecs, timeoutSecs, signal });
|
|
195
223
|
}
|
|
196
224
|
/**
|
|
197
225
|
* Retrieves the Actor task's input object.
|
|
198
226
|
*
|
|
199
|
-
* @
|
|
227
|
+
* @param options - Request options
|
|
228
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
229
|
+
* @returns The Task's input.
|
|
200
230
|
* @see https://docs.apify.com/api/v2/actor-task-input-get
|
|
201
231
|
*/
|
|
202
|
-
async getInput() {
|
|
203
|
-
const
|
|
204
|
-
|
|
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'),
|
|
205
236
|
method: 'GET',
|
|
206
|
-
params: this.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
catch (err) {
|
|
213
|
-
(0, utils_1.catchNotFoundOrThrow)(err);
|
|
214
|
-
}
|
|
215
|
-
return undefined;
|
|
237
|
+
params: this.buildParams(),
|
|
238
|
+
timeoutSecs,
|
|
239
|
+
signal,
|
|
240
|
+
});
|
|
241
|
+
return cast(response.data);
|
|
216
242
|
}
|
|
217
243
|
/**
|
|
218
244
|
* Updates the Actor task's input object.
|
|
219
245
|
*
|
|
220
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'`.
|
|
221
249
|
* @returns The updated task input.
|
|
222
250
|
* @see https://docs.apify.com/api/v2/actor-task-input-put
|
|
223
251
|
*/
|
|
224
|
-
async updateInput(newFields) {
|
|
252
|
+
async updateInput(newFields, options = {}) {
|
|
253
|
+
const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
225
254
|
const response = await this.httpClient.call({
|
|
226
|
-
url: this.
|
|
255
|
+
url: this.buildUrl('input'),
|
|
227
256
|
method: 'PUT',
|
|
228
|
-
params: this.
|
|
257
|
+
params: this.buildParams(),
|
|
229
258
|
data: newFields,
|
|
259
|
+
timeoutSecs,
|
|
260
|
+
signal,
|
|
230
261
|
});
|
|
231
|
-
return
|
|
262
|
+
return cast(response.data);
|
|
232
263
|
}
|
|
233
264
|
/**
|
|
234
265
|
* Returns a client for the last run of this task.
|
|
@@ -240,10 +271,10 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
240
271
|
* @see https://docs.apify.com/api/v2/actor-task-runs-last-get
|
|
241
272
|
*/
|
|
242
273
|
lastRun(options = {}) {
|
|
243
|
-
const parsed =
|
|
244
|
-
return new
|
|
274
|
+
const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
|
|
275
|
+
return new RunClient(this.subResourceOptions({
|
|
245
276
|
id: 'last',
|
|
246
|
-
params: this.
|
|
277
|
+
params: this.buildParams(parsed),
|
|
247
278
|
resourcePath: 'runs',
|
|
248
279
|
}));
|
|
249
280
|
}
|
|
@@ -254,7 +285,7 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
254
285
|
* @see https://docs.apify.com/api/v2/actor-task-runs-get
|
|
255
286
|
*/
|
|
256
287
|
runs() {
|
|
257
|
-
return new
|
|
288
|
+
return new RunCollectionClient(this.subResourceOptions({
|
|
258
289
|
resourcePath: 'runs',
|
|
259
290
|
}));
|
|
260
291
|
}
|
|
@@ -265,7 +296,6 @@ class TaskClient extends resource_client_1.ResourceClient {
|
|
|
265
296
|
* @see https://docs.apify.com/api/v2/actor-task-webhooks-get
|
|
266
297
|
*/
|
|
267
298
|
webhooks() {
|
|
268
|
-
return new
|
|
299
|
+
return new WebhookCollectionClient(this.subResourceOptions());
|
|
269
300
|
}
|
|
270
301
|
}
|
|
271
|
-
exports.TaskClient = TaskClient;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { TaskListItem } from '../models.js';
|
|
4
|
+
import type { TimeoutOptions } from '../timeouts.js';
|
|
5
|
+
import type { PaginatedIterator, PaginationOptions } from '../utils.js';
|
|
6
|
+
import type { Task, TaskUpdateData } from './task.js';
|
|
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,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
|
|
5
|
+
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
6
|
+
const listOptionsSchema = z.strictObject({
|
|
7
|
+
...paginationOptionsShape,
|
|
8
|
+
desc: z.boolean().optional(),
|
|
9
|
+
...timeoutOptionsShape,
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
12
|
* Client for managing the collection of Actor tasks in your account.
|
|
@@ -32,7 +32,7 @@ const listOptionsSchema = zod_1.z.strictObject({
|
|
|
32
32
|
*
|
|
33
33
|
* @see https://docs.apify.com/platform/actors/running/tasks
|
|
34
34
|
*/
|
|
35
|
-
class TaskCollectionClient extends
|
|
35
|
+
export class TaskCollectionClient extends ResourceCollectionClient {
|
|
36
36
|
/**
|
|
37
37
|
* @hidden
|
|
38
38
|
*/
|
|
@@ -59,23 +59,26 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
|
|
|
59
59
|
* ```
|
|
60
60
|
*
|
|
61
61
|
* @param options - Pagination and sorting options.
|
|
62
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
|
|
62
63
|
* @returns A paginated iterator of tasks.
|
|
63
64
|
* @see https://docs.apify.com/api/v2/actor-tasks-get
|
|
64
65
|
*/
|
|
65
66
|
list(options = {}) {
|
|
66
|
-
const parsed =
|
|
67
|
-
return this.
|
|
67
|
+
const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
|
|
68
|
+
return this.listResourcesPaginated(schemas.ListOfTasks(), parsed, 'medium');
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* Creates a new task.
|
|
71
72
|
*
|
|
72
73
|
* @param task - The task data.
|
|
74
|
+
* @param options - Request options
|
|
75
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
73
76
|
* @returns The created task object.
|
|
74
77
|
* @see https://docs.apify.com/api/v2/actor-tasks-post
|
|
75
78
|
*/
|
|
76
|
-
async create(task) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
async create(task, options = {}) {
|
|
80
|
+
parseArgument(task, anyObjectSchema);
|
|
81
|
+
const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
|
|
82
|
+
return this.createResource(schemas.Task(), task, timeoutSecs, signal);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
exports.TaskCollectionClient = TaskCollectionClient;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export {
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
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';
|
|
6
|
+
export { PlatformFeature } from '../models.js';
|
|
6
7
|
/**
|
|
7
8
|
* Client for managing user account information.
|
|
8
9
|
*
|
|
@@ -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
|