apify-client 3.0.0-beta.11 → 3.0.0-beta.12
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.
|
@@ -67,8 +67,7 @@ export declare class ActorClient extends ResourceClient {
|
|
|
67
67
|
* asynchronously and this method returns immediately without waiting for completion.
|
|
68
68
|
* Use the {@link call} method if you want to wait for the Actor to finish.
|
|
69
69
|
*
|
|
70
|
-
* @param input - Input for the Actor.
|
|
71
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
70
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
72
71
|
* @param options - Run configuration options
|
|
73
72
|
* @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.
|
|
74
73
|
* @param options.memory - Memory in megabytes allocated for the run. If not provided, uses the Actor's default memory setting.
|
|
@@ -77,7 +76,6 @@ export declare class ActorClient extends ResourceClient {
|
|
|
77
76
|
* @param options.webhooks - Webhooks to trigger when the Actor run reaches a specific state (e.g., `SUCCEEDED`, `FAILED`).
|
|
78
77
|
* @param options.maxItems - Maximum number of dataset items that will be charged (only for pay-per-result Actors).
|
|
79
78
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (only for pay-per-event Actors).
|
|
80
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
81
79
|
* @returns The Actor run object with status, usage, and storage IDs
|
|
82
80
|
* @see https://docs.apify.com/api/v2/act-runs-post
|
|
83
81
|
*
|
|
@@ -94,7 +92,7 @@ export declare class ActorClient extends ResourceClient {
|
|
|
94
92
|
* );
|
|
95
93
|
* ```
|
|
96
94
|
*/
|
|
97
|
-
start(input?:
|
|
95
|
+
start(input?: ActorInput, options?: ActorStartOptions): Promise<ActorRun>;
|
|
98
96
|
/**
|
|
99
97
|
* Starts the Actor and waits for it to finish before returning the Run object.
|
|
100
98
|
*
|
|
@@ -102,8 +100,7 @@ export declare class ActorClient extends ResourceClient {
|
|
|
102
100
|
* by polling the run status. It optionally streams logs to the console or a custom Log instance.
|
|
103
101
|
* By default, it waits indefinitely unless the `waitSecs` option is provided.
|
|
104
102
|
*
|
|
105
|
-
* @param input - Input for the Actor.
|
|
106
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
103
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
107
104
|
* @param options - Run configuration options (extends all options from {@link start})
|
|
108
105
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
109
106
|
* @param options.log - Log instance for streaming run logs. Use `'default'` for console output, `null` to disable logging, or provide a custom Log instance.
|
|
@@ -132,7 +129,7 @@ export declare class ActorClient extends ResourceClient {
|
|
|
132
129
|
* const run = await client.actor('my-actor').call({ url: 'https://example.com' }, { log });
|
|
133
130
|
* ```
|
|
134
131
|
*/
|
|
135
|
-
call(input?:
|
|
132
|
+
call(input?: ActorInput, options?: ActorCallOptions): Promise<ActorRun>;
|
|
136
133
|
/**
|
|
137
134
|
* Validates the provided input for the Actor against its input schema.
|
|
138
135
|
*
|
|
@@ -141,13 +138,10 @@ export declare class ActorClient extends ResourceClient {
|
|
|
141
138
|
* invalid, the API responds with an error that is thrown as an `ApifyApiError` describing the
|
|
142
139
|
* validation problem.
|
|
143
140
|
*
|
|
144
|
-
* @param input - Input to validate against the Actor's input schema
|
|
145
|
-
* value (object, array, string, number). If `contentType` is specified in options,
|
|
146
|
-
* input should be a string or Buffer.
|
|
141
|
+
* @param input - Input to validate against the Actor's input schema, serialized to JSON.
|
|
147
142
|
* @param options - Validation options
|
|
148
143
|
* @param options.build - Tag or number of the build whose input schema the input is validated against
|
|
149
144
|
* (e.g., `'latest'` or `'1.2.345'`). If not provided, uses the default build.
|
|
150
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
151
145
|
* @returns `true` if the input is valid. Invalid input causes the underlying API call to throw an `ApifyApiError`.
|
|
152
146
|
* @see https://docs.apify.com/api/v2/act-validate-input-post
|
|
153
147
|
*
|
|
@@ -164,7 +158,7 @@ export declare class ActorClient extends ResourceClient {
|
|
|
164
158
|
* ```
|
|
165
159
|
* @since Added in 2.24.0
|
|
166
160
|
*/
|
|
167
|
-
validateInput(input?:
|
|
161
|
+
validateInput(input?: ActorInput, options?: ActorValidateInputOptions): Promise<boolean>;
|
|
168
162
|
/**
|
|
169
163
|
* Builds the Actor.
|
|
170
164
|
*
|
|
@@ -280,6 +274,14 @@ export declare class ActorClient extends ResourceClient {
|
|
|
280
274
|
* Fields that can be updated when modifying an Actor.
|
|
281
275
|
*/
|
|
282
276
|
export type ActorUpdateOptions = Partial<Pick<Actor, 'name' | 'description' | 'isPublic' | 'isDeprecated' | 'seoTitle' | 'seoDescription' | 'title' | 'restartOnError' | 'versions' | 'categories' | 'defaultRunOptions' | 'actorStandby' | 'actorPermissionLevel' | 'taggedBuilds'>>;
|
|
277
|
+
/**
|
|
278
|
+
* Input for an Actor run, as taken by {@link ActorClient.start}, {@link ActorClient.call},
|
|
279
|
+
* {@link ActorClient.validateInput} and {@link RunClient.metamorph}.
|
|
280
|
+
*
|
|
281
|
+
* An object or an array. Declared as `object` rather than an index-signature type such as
|
|
282
|
+
* `Dictionary`, which would reject a caller's own `interface`.
|
|
283
|
+
*/
|
|
284
|
+
export type ActorInput = object;
|
|
283
285
|
export interface ActorStartOptions {
|
|
284
286
|
/**
|
|
285
287
|
* Tag or number of the Actor build to run (e.g. `beta` or `1.2.345`).
|
|
@@ -287,10 +289,9 @@ export interface ActorStartOptions {
|
|
|
287
289
|
*/
|
|
288
290
|
build?: string;
|
|
289
291
|
/**
|
|
290
|
-
* Content type
|
|
291
|
-
*
|
|
292
|
-
* `application/
|
|
293
|
-
* `String` or `Buffer`.
|
|
292
|
+
* Content type of the request body, which becomes the content type of the run's `INPUT` record.
|
|
293
|
+
* Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
|
|
294
|
+
* with `application/x-www-form-urlencoded` form-encodes it instead.
|
|
294
295
|
*/
|
|
295
296
|
contentType?: string;
|
|
296
297
|
/**
|
|
@@ -376,10 +377,9 @@ export interface ActorValidateInputOptions {
|
|
|
376
377
|
*/
|
|
377
378
|
build?: string;
|
|
378
379
|
/**
|
|
379
|
-
* Content type
|
|
380
|
-
*
|
|
381
|
-
* `application/
|
|
382
|
-
* `String` or `Buffer`.
|
|
380
|
+
* Content type of the request body carrying the input to validate. Without it, the input is
|
|
381
|
+
* serialized to JSON and sent as `application/json`. Pairing an object with
|
|
382
|
+
* `application/x-www-form-urlencoded` form-encodes it instead.
|
|
383
383
|
*/
|
|
384
384
|
contentType?: string;
|
|
385
385
|
}
|
|
@@ -116,8 +116,7 @@ export class ActorClient extends ResourceClient {
|
|
|
116
116
|
* asynchronously and this method returns immediately without waiting for completion.
|
|
117
117
|
* Use the {@link call} method if you want to wait for the Actor to finish.
|
|
118
118
|
*
|
|
119
|
-
* @param input - Input for the Actor.
|
|
120
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
119
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
121
120
|
* @param options - Run configuration options
|
|
122
121
|
* @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.
|
|
123
122
|
* @param options.memory - Memory in megabytes allocated for the run. If not provided, uses the Actor's default memory setting.
|
|
@@ -126,7 +125,6 @@ export class ActorClient extends ResourceClient {
|
|
|
126
125
|
* @param options.webhooks - Webhooks to trigger when the Actor run reaches a specific state (e.g., `SUCCEEDED`, `FAILED`).
|
|
127
126
|
* @param options.maxItems - Maximum number of dataset items that will be charged (only for pay-per-result Actors).
|
|
128
127
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (only for pay-per-event Actors).
|
|
129
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
130
128
|
* @returns The Actor run object with status, usage, and storage IDs
|
|
131
129
|
* @see https://docs.apify.com/api/v2/act-runs-post
|
|
132
130
|
*
|
|
@@ -144,8 +142,6 @@ export class ActorClient extends ResourceClient {
|
|
|
144
142
|
* ```
|
|
145
143
|
*/
|
|
146
144
|
async start(input, options = {}) {
|
|
147
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
148
|
-
// then it will process input as a buffer.
|
|
149
145
|
const parsed = parseArgument(options, startOptionsSchema, 'ActorStartOptions');
|
|
150
146
|
const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = parsed;
|
|
151
147
|
const params = {
|
|
@@ -183,8 +179,7 @@ export class ActorClient extends ResourceClient {
|
|
|
183
179
|
* by polling the run status. It optionally streams logs to the console or a custom Log instance.
|
|
184
180
|
* By default, it waits indefinitely unless the `waitSecs` option is provided.
|
|
185
181
|
*
|
|
186
|
-
* @param input - Input for the Actor.
|
|
187
|
-
* If `contentType` is specified in options, input should be a string or Buffer.
|
|
182
|
+
* @param input - Input for the Actor, serialized to JSON. Omit it to run the Actor without input.
|
|
188
183
|
* @param options - Run configuration options (extends all options from {@link start})
|
|
189
184
|
* @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
|
|
190
185
|
* @param options.log - Log instance for streaming run logs. Use `'default'` for console output, `null` to disable logging, or provide a custom Log instance.
|
|
@@ -214,8 +209,6 @@ export class ActorClient extends ResourceClient {
|
|
|
214
209
|
* ```
|
|
215
210
|
*/
|
|
216
211
|
async call(input, options = {}) {
|
|
217
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
218
|
-
// then it will process input as a buffer.
|
|
219
212
|
const parsed = parseArgument(options, callOptionsSchema, 'ActorCallOptions');
|
|
220
213
|
const { waitSecs, log, ...startOptions } = parsed;
|
|
221
214
|
const { id } = await this.start(input, startOptions);
|
|
@@ -240,13 +233,10 @@ export class ActorClient extends ResourceClient {
|
|
|
240
233
|
* invalid, the API responds with an error that is thrown as an `ApifyApiError` describing the
|
|
241
234
|
* validation problem.
|
|
242
235
|
*
|
|
243
|
-
* @param input - Input to validate against the Actor's input schema
|
|
244
|
-
* value (object, array, string, number). If `contentType` is specified in options,
|
|
245
|
-
* input should be a string or Buffer.
|
|
236
|
+
* @param input - Input to validate against the Actor's input schema, serialized to JSON.
|
|
246
237
|
* @param options - Validation options
|
|
247
238
|
* @param options.build - Tag or number of the build whose input schema the input is validated against
|
|
248
239
|
* (e.g., `'latest'` or `'1.2.345'`). If not provided, uses the default build.
|
|
249
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
250
240
|
* @returns `true` if the input is valid. Invalid input causes the underlying API call to throw an `ApifyApiError`.
|
|
251
241
|
* @see https://docs.apify.com/api/v2/act-validate-input-post
|
|
252
242
|
*
|
|
@@ -264,8 +254,6 @@ export class ActorClient extends ResourceClient {
|
|
|
264
254
|
* @since Added in 2.24.0
|
|
265
255
|
*/
|
|
266
256
|
async validateInput(input, options = {}) {
|
|
267
|
-
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
268
|
-
// then it will process input as a buffer.
|
|
269
257
|
const parsed = parseArgument(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
|
|
270
258
|
const request = {
|
|
271
259
|
url: this._url('validate-input'),
|
|
@@ -3,7 +3,7 @@ import { Log } from '@apify/log';
|
|
|
3
3
|
import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
|
|
4
4
|
import { ResourceClient } from '../base/resource_client.js';
|
|
5
5
|
import type { ApifyResponse } from '../http_client.js';
|
|
6
|
-
import type { ActorRun } from './actor.js';
|
|
6
|
+
import type { ActorInput, ActorRun } from './actor.js';
|
|
7
7
|
import { DatasetClient } from './dataset.js';
|
|
8
8
|
import { KeyValueStoreClient } from './key_value_store.js';
|
|
9
9
|
import { LogClient, StreamedLog } from './log.js';
|
|
@@ -88,10 +88,9 @@ export declare class RunClient extends ResourceClient {
|
|
|
88
88
|
* This is useful for chaining Actor executions or implementing complex workflows.
|
|
89
89
|
*
|
|
90
90
|
* @param targetActorId - ID or username/name of the target Actor
|
|
91
|
-
* @param input - Input for the target Actor.
|
|
91
|
+
* @param input - Input for the target Actor, serialized to JSON. Omit it to metamorph without input.
|
|
92
92
|
* @param options - Metamorph options
|
|
93
93
|
* @param options.build - Tag or number of the target Actor's build to run. Default is the target Actor's default build.
|
|
94
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
95
94
|
* @returns The metamorphed ActorRun object (same ID, but now running the target Actor)
|
|
96
95
|
* @see https://docs.apify.com/api/v2/actor-run-metamorph-post
|
|
97
96
|
*
|
|
@@ -105,7 +104,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
105
104
|
* console.log(`Run ${metamorphedRun.id} is now running ${metamorphedRun.actId}`);
|
|
106
105
|
* ```
|
|
107
106
|
*/
|
|
108
|
-
metamorph(targetActorId: string, input
|
|
107
|
+
metamorph(targetActorId: string, input?: ActorInput, options?: RunMetamorphOptions): Promise<ActorRun>;
|
|
109
108
|
/**
|
|
110
109
|
* Reboots the Actor run.
|
|
111
110
|
*
|
|
@@ -300,6 +299,11 @@ export interface RunAbortOptions {
|
|
|
300
299
|
* Options for metamorphing a Run into another Actor.
|
|
301
300
|
*/
|
|
302
301
|
export interface RunMetamorphOptions {
|
|
302
|
+
/**
|
|
303
|
+
* Content type of the request body, which becomes the content type of the run's `INPUT` record.
|
|
304
|
+
* Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
|
|
305
|
+
* with `application/x-www-form-urlencoded` form-encodes it instead.
|
|
306
|
+
*/
|
|
303
307
|
contentType?: string;
|
|
304
308
|
build?: string;
|
|
305
309
|
}
|
|
@@ -127,10 +127,9 @@ export class RunClient extends ResourceClient {
|
|
|
127
127
|
* This is useful for chaining Actor executions or implementing complex workflows.
|
|
128
128
|
*
|
|
129
129
|
* @param targetActorId - ID or username/name of the target Actor
|
|
130
|
-
* @param input - Input for the target Actor.
|
|
130
|
+
* @param input - Input for the target Actor, serialized to JSON. Omit it to metamorph without input.
|
|
131
131
|
* @param options - Metamorph options
|
|
132
132
|
* @param options.build - Tag or number of the target Actor's build to run. Default is the target Actor's default build.
|
|
133
|
-
* @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
|
|
134
133
|
* @returns The metamorphed ActorRun object (same ID, but now running the target Actor)
|
|
135
134
|
* @see https://docs.apify.com/api/v2/actor-run-metamorph-post
|
|
136
135
|
*
|
|
@@ -146,7 +145,6 @@ export class RunClient extends ResourceClient {
|
|
|
146
145
|
*/
|
|
147
146
|
async metamorph(targetActorId, input, options = {}) {
|
|
148
147
|
parseArgument(targetActorId, targetActorIdSchema);
|
|
149
|
-
// input can be anything, pointless to validate
|
|
150
148
|
const parsed = parseArgument(options, metamorphOptionsSchema, 'RunMetamorphOptions');
|
|
151
149
|
const safeTargetActorId = this._toSafeId(targetActorId);
|
|
152
150
|
const params = {
|