apify-client 3.0.0-beta.0 → 3.0.0-beta.10
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 +5 -3
- package/dist/apify_api_error.d.ts +59 -3
- package/dist/apify_api_error.js +71 -11
- package/dist/apify_client.d.ts +27 -27
- package/dist/apify_client.js +86 -91
- package/dist/base/api_client.d.ts +3 -3
- package/dist/base/api_client.js +6 -10
- package/dist/base/resource_client.d.ts +5 -4
- package/dist/base/resource_client.js +17 -21
- package/dist/base/resource_collection_client.d.ts +7 -6
- package/dist/base/resource_collection_client.js +11 -15
- package/dist/body_parser.js +6 -11
- package/dist/bundle.js +38 -48
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +20595 -0
- package/dist/generated/api.js +5 -0
- package/dist/generated/schemas.d.ts +6699 -0
- package/dist/generated/schemas.js +1521 -0
- package/dist/http_client.d.ts +2 -2
- package/dist/http_client.js +23 -28
- package/dist/index.d.ts +33 -32
- package/dist/index.js +32 -36
- package/dist/interceptors.d.ts +1 -1
- package/dist/interceptors.js +14 -19
- package/dist/lazy_schema.d.ts +8 -0
- package/dist/lazy_schema.js +11 -0
- package/dist/models.d.ts +1053 -0
- package/dist/models.js +86 -0
- package/dist/resource_clients/actor.d.ts +13 -459
- package/dist/resource_clients/actor.js +70 -73
- package/dist/resource_clients/actor_collection.d.ts +10 -15
- package/dist/resource_clients/actor_collection.js +19 -20
- package/dist/resource_clients/actor_env_var.d.ts +3 -3
- package/dist/resource_clients/actor_env_var.js +7 -10
- package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
- package/dist/resource_clients/actor_env_var_collection.js +15 -19
- package/dist/resource_clients/actor_version.d.ts +14 -43
- package/dist/resource_clients/actor_version.js +15 -24
- package/dist/resource_clients/actor_version_collection.d.ts +13 -19
- package/dist/resource_clients/actor_version_collection.js +17 -19
- package/dist/resource_clients/build.d.ts +5 -80
- package/dist/resource_clients/build.js +14 -17
- package/dist/resource_clients/build_collection.d.ts +5 -5
- package/dist/resource_clients/build_collection.js +10 -13
- package/dist/resource_clients/dataset.d.ts +6 -72
- package/dist/resource_clients/dataset.js +73 -76
- package/dist/resource_clients/dataset_collection.d.ts +4 -4
- package/dist/resource_clients/dataset_collection.js +18 -21
- package/dist/resource_clients/key_value_store.d.ts +16 -77
- package/dist/resource_clients/key_value_store.js +64 -66
- package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
- package/dist/resource_clients/key_value_store_collection.js +18 -21
- package/dist/resource_clients/log.d.ts +2 -2
- package/dist/resource_clients/log.js +15 -22
- package/dist/resource_clients/request_queue.d.ts +17 -183
- package/dist/resource_clients/request_queue.js +102 -108
- package/dist/resource_clients/request_queue_collection.d.ts +4 -4
- package/dist/resource_clients/request_queue_collection.js +16 -19
- package/dist/resource_clients/run.d.ts +8 -8
- package/dist/resource_clients/run.js +50 -53
- package/dist/resource_clients/run_collection.d.ts +4 -4
- package/dist/resource_clients/run_collection.js +15 -18
- package/dist/resource_clients/schedule.d.ts +8 -86
- package/dist/resource_clients/schedule.js +13 -21
- package/dist/resource_clients/schedule_collection.d.ts +4 -4
- package/dist/resource_clients/schedule_collection.js +13 -16
- package/dist/resource_clients/store_collection.d.ts +5 -33
- package/dist/resource_clients/store_collection.js +15 -18
- package/dist/resource_clients/task.d.ts +9 -79
- package/dist/resource_clients/task.js +47 -50
- package/dist/resource_clients/task_collection.d.ts +6 -5
- package/dist/resource_clients/task_collection.js +12 -15
- package/dist/resource_clients/user.d.ts +5 -181
- package/dist/resource_clients/user.js +11 -24
- package/dist/resource_clients/webhook.d.ts +6 -65
- package/dist/resource_clients/webhook.js +11 -14
- package/dist/resource_clients/webhook_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_collection.js +13 -16
- package/dist/resource_clients/webhook_dispatch.d.ts +5 -38
- package/dist/resource_clients/webhook_dispatch.js +5 -13
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
- package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
- package/dist/response_validation_error.d.ts +26 -0
- package/dist/response_validation_error.js +37 -0
- package/dist/schemas.d.ts +15 -0
- package/dist/schemas.js +15 -0
- package/dist/statistics.js +5 -9
- package/dist/timezones.js +1 -2
- package/dist/utils.d.ts +19 -24
- package/dist/utils.js +66 -96
- package/package.json +48 -40
- package/dist/argument_validation_error.d.ts +0 -17
- package/dist/argument_validation_error.js +0 -157
- package/dist/index.mjs +0 -42
|
@@ -1,57 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
restartOnError: zod_1.z.boolean().optional(),
|
|
26
|
-
forcePermissionLevel: zod_1.z.enum(consts_1.ACTOR_PERMISSION_LEVEL).optional(),
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
|
|
3
|
+
import { Log } from '@apify/log';
|
|
4
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
5
|
+
import * as schemas from '../schemas.js';
|
|
6
|
+
import { anyObjectSchema, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
|
|
7
|
+
import { ActorVersionClient } from './actor_version.js';
|
|
8
|
+
import { ActorVersionCollectionClient } from './actor_version_collection.js';
|
|
9
|
+
import { BuildClient } from './build.js';
|
|
10
|
+
import { BuildCollectionClient } from './build_collection.js';
|
|
11
|
+
import { RunClient } from './run.js';
|
|
12
|
+
import { RunCollectionClient } from './run_collection.js';
|
|
13
|
+
import { WebhookCollectionClient } from './webhook_collection.js';
|
|
14
|
+
const startOptionsSchema = z.strictObject({
|
|
15
|
+
build: z.string().optional(),
|
|
16
|
+
contentType: z.string().optional(),
|
|
17
|
+
memory: z.number().optional(),
|
|
18
|
+
timeout: z.number().optional(),
|
|
19
|
+
waitForFinish: z.number().optional(),
|
|
20
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
21
|
+
maxItems: z.number().min(0).optional(),
|
|
22
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
23
|
+
restartOnError: z.boolean().optional(),
|
|
24
|
+
forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
|
|
27
25
|
});
|
|
28
|
-
const callOptionsSchema =
|
|
29
|
-
build:
|
|
30
|
-
contentType:
|
|
31
|
-
memory:
|
|
32
|
-
timeout:
|
|
33
|
-
waitSecs:
|
|
34
|
-
webhooks:
|
|
35
|
-
maxItems:
|
|
36
|
-
maxTotalChargeUsd:
|
|
37
|
-
log:
|
|
38
|
-
restartOnError:
|
|
39
|
-
forcePermissionLevel:
|
|
26
|
+
const callOptionsSchema = z.strictObject({
|
|
27
|
+
build: z.string().optional(),
|
|
28
|
+
contentType: z.string().optional(),
|
|
29
|
+
memory: z.number().optional(),
|
|
30
|
+
timeout: z.number().min(0).optional(),
|
|
31
|
+
waitSecs: z.number().min(0).optional(),
|
|
32
|
+
webhooks: z.array(anyObjectSchema).optional(),
|
|
33
|
+
maxItems: z.number().min(0).optional(),
|
|
34
|
+
maxTotalChargeUsd: z.number().min(0).optional(),
|
|
35
|
+
log: z.union([z.null(), z.instanceof(Log), z.literal('default')]).optional(),
|
|
36
|
+
restartOnError: z.boolean().optional(),
|
|
37
|
+
forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
|
|
40
38
|
});
|
|
41
|
-
const validateInputOptionsSchema =
|
|
42
|
-
build:
|
|
43
|
-
contentType:
|
|
39
|
+
const validateInputOptionsSchema = z.strictObject({
|
|
40
|
+
build: z.string().optional(),
|
|
41
|
+
contentType: z.string().optional(),
|
|
44
42
|
});
|
|
45
|
-
const versionNumberSchema =
|
|
46
|
-
const buildOptionsSchema =
|
|
47
|
-
betaPackages:
|
|
48
|
-
tag:
|
|
49
|
-
useCache:
|
|
50
|
-
waitForFinish:
|
|
43
|
+
const versionNumberSchema = z.string();
|
|
44
|
+
const buildOptionsSchema = z.strictObject({
|
|
45
|
+
betaPackages: z.boolean().optional(),
|
|
46
|
+
tag: z.string().optional(),
|
|
47
|
+
useCache: z.boolean().optional(),
|
|
48
|
+
waitForFinish: z.number().optional(),
|
|
51
49
|
});
|
|
52
|
-
const lastRunOptionsSchema =
|
|
53
|
-
status:
|
|
54
|
-
origin:
|
|
50
|
+
const lastRunOptionsSchema = z.strictObject({
|
|
51
|
+
status: z.enum(ACTOR_JOB_STATUSES).optional(),
|
|
52
|
+
origin: z.enum(META_ORIGINS).optional(),
|
|
55
53
|
});
|
|
56
54
|
/**
|
|
57
55
|
* Client for managing a specific Actor.
|
|
@@ -73,7 +71,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
|
|
|
73
71
|
*
|
|
74
72
|
* @see https://docs.apify.com/platform/actors
|
|
75
73
|
*/
|
|
76
|
-
class ActorClient extends
|
|
74
|
+
export class ActorClient extends ResourceClient {
|
|
77
75
|
/**
|
|
78
76
|
* @hidden
|
|
79
77
|
*/
|
|
@@ -90,7 +88,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
90
88
|
* @see https://docs.apify.com/api/v2/act-get
|
|
91
89
|
*/
|
|
92
90
|
async get() {
|
|
93
|
-
return this._get();
|
|
91
|
+
return this._get(schemas.Actor());
|
|
94
92
|
}
|
|
95
93
|
/**
|
|
96
94
|
* Updates the Actor with specified fields.
|
|
@@ -100,8 +98,8 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
100
98
|
* @see https://docs.apify.com/api/v2/act-put
|
|
101
99
|
*/
|
|
102
100
|
async update(newFields) {
|
|
103
|
-
|
|
104
|
-
return this._update(newFields);
|
|
101
|
+
parseArgument(newFields, anyObjectSchema);
|
|
102
|
+
return this._update(schemas.Actor(), newFields);
|
|
105
103
|
}
|
|
106
104
|
/**
|
|
107
105
|
* Deletes the Actor.
|
|
@@ -148,14 +146,14 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
148
146
|
async start(input, options = {}) {
|
|
149
147
|
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
150
148
|
// then it will process input as a buffer.
|
|
151
|
-
const parsed =
|
|
149
|
+
const parsed = parseArgument(options, startOptionsSchema, 'ActorStartOptions');
|
|
152
150
|
const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = parsed;
|
|
153
151
|
const params = {
|
|
154
152
|
waitForFinish,
|
|
155
153
|
timeout,
|
|
156
154
|
memory,
|
|
157
155
|
build,
|
|
158
|
-
webhooks:
|
|
156
|
+
webhooks: stringifyWebhooksToBase64(parsed.webhooks),
|
|
159
157
|
maxItems,
|
|
160
158
|
maxTotalChargeUsd,
|
|
161
159
|
restartOnError,
|
|
@@ -176,7 +174,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
176
174
|
};
|
|
177
175
|
}
|
|
178
176
|
const response = await this.httpClient.call(request);
|
|
179
|
-
return (
|
|
177
|
+
return parseResponse(response, schemas.Run());
|
|
180
178
|
}
|
|
181
179
|
/**
|
|
182
180
|
* Starts the Actor and waits for it to finish before returning the Run object.
|
|
@@ -218,7 +216,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
218
216
|
async call(input, options = {}) {
|
|
219
217
|
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
220
218
|
// then it will process input as a buffer.
|
|
221
|
-
const parsed =
|
|
219
|
+
const parsed = parseArgument(options, callOptionsSchema, 'ActorCallOptions');
|
|
222
220
|
const { waitSecs, log, ...startOptions } = parsed;
|
|
223
221
|
const { id } = await this.start(input, startOptions);
|
|
224
222
|
// Calling root client because we need access to top level API.
|
|
@@ -268,7 +266,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
268
266
|
async validateInput(input, options = {}) {
|
|
269
267
|
// input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
|
|
270
268
|
// then it will process input as a buffer.
|
|
271
|
-
const parsed =
|
|
269
|
+
const parsed = parseArgument(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
|
|
272
270
|
const request = {
|
|
273
271
|
url: this._url('validate-input'),
|
|
274
272
|
method: 'POST',
|
|
@@ -316,8 +314,8 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
316
314
|
* ```
|
|
317
315
|
*/
|
|
318
316
|
async build(versionNumber, options = {}) {
|
|
319
|
-
|
|
320
|
-
const parsed =
|
|
317
|
+
parseArgument(versionNumber, versionNumberSchema);
|
|
318
|
+
const parsed = parseArgument(options, buildOptionsSchema, 'ActorBuildOptions');
|
|
321
319
|
const response = await this.httpClient.call({
|
|
322
320
|
url: this._url('builds'),
|
|
323
321
|
method: 'POST',
|
|
@@ -326,7 +324,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
326
324
|
...parsed,
|
|
327
325
|
}),
|
|
328
326
|
});
|
|
329
|
-
return (
|
|
327
|
+
return parseResponse(response, schemas.Build());
|
|
330
328
|
}
|
|
331
329
|
/**
|
|
332
330
|
* Returns a client for the default build of this Actor.
|
|
@@ -359,8 +357,8 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
359
357
|
method: 'GET',
|
|
360
358
|
params: this._params(options),
|
|
361
359
|
});
|
|
362
|
-
const { id } = (
|
|
363
|
-
return new
|
|
360
|
+
const { id } = parseResponse(response, schemas.Build());
|
|
361
|
+
return new BuildClient({
|
|
364
362
|
baseUrl: this.apifyClient.baseUrl,
|
|
365
363
|
publicBaseUrl: this.apifyClient.publicBaseUrl,
|
|
366
364
|
httpClient: this.httpClient,
|
|
@@ -386,8 +384,8 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
386
384
|
* ```
|
|
387
385
|
*/
|
|
388
386
|
lastRun(options = {}) {
|
|
389
|
-
const parsed =
|
|
390
|
-
return new
|
|
387
|
+
const parsed = parseArgument(options, lastRunOptionsSchema, 'ActorLastRunOptions');
|
|
388
|
+
return new RunClient(this._subResourceOptions({
|
|
391
389
|
id: 'last',
|
|
392
390
|
params: this._params(parsed),
|
|
393
391
|
resourcePath: 'runs',
|
|
@@ -400,7 +398,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
400
398
|
* @see https://docs.apify.com/api/v2/act-builds-get
|
|
401
399
|
*/
|
|
402
400
|
builds() {
|
|
403
|
-
return new
|
|
401
|
+
return new BuildCollectionClient(this._subResourceOptions({
|
|
404
402
|
resourcePath: 'builds',
|
|
405
403
|
}));
|
|
406
404
|
}
|
|
@@ -411,7 +409,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
411
409
|
* @see https://docs.apify.com/api/v2/act-runs-get
|
|
412
410
|
*/
|
|
413
411
|
runs() {
|
|
414
|
-
return new
|
|
412
|
+
return new RunCollectionClient(this._subResourceOptions({
|
|
415
413
|
resourcePath: 'runs',
|
|
416
414
|
}));
|
|
417
415
|
}
|
|
@@ -423,8 +421,8 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
423
421
|
* @see https://docs.apify.com/api/v2/act-version-get
|
|
424
422
|
*/
|
|
425
423
|
version(versionNumber) {
|
|
426
|
-
|
|
427
|
-
return new
|
|
424
|
+
parseArgument(versionNumber, versionNumberSchema);
|
|
425
|
+
return new ActorVersionClient(this._subResourceOptions({
|
|
428
426
|
id: versionNumber,
|
|
429
427
|
}));
|
|
430
428
|
}
|
|
@@ -435,7 +433,7 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
435
433
|
* @see https://docs.apify.com/api/v2/act-versions-get
|
|
436
434
|
*/
|
|
437
435
|
versions() {
|
|
438
|
-
return new
|
|
436
|
+
return new ActorVersionCollectionClient(this._subResourceOptions());
|
|
439
437
|
}
|
|
440
438
|
/**
|
|
441
439
|
* Returns a client for managing webhooks associated with this Actor.
|
|
@@ -444,7 +442,6 @@ class ActorClient extends resource_client_1.ResourceClient {
|
|
|
444
442
|
* @see https://docs.apify.com/api/v2/act-webhooks-get
|
|
445
443
|
*/
|
|
446
444
|
webhooks() {
|
|
447
|
-
return new
|
|
445
|
+
return new WebhookCollectionClient(this._subResourceOptions());
|
|
448
446
|
}
|
|
449
447
|
}
|
|
450
|
-
exports.ActorClient = ActorClient;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ACTOR_PERMISSION_LEVEL } from '@apify/consts';
|
|
2
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
3
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
2
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
3
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
4
|
+
import type { ActorCollectionListItem } from '../models.js';
|
|
5
|
+
import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
|
|
6
|
+
import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor.js';
|
|
7
|
+
import type { ActorVersion } from './actor_version.js';
|
|
8
|
+
export type { ActorCollectionListItem } from '../models.js';
|
|
7
9
|
/**
|
|
8
10
|
* Client for managing the collection of Actors in your account.
|
|
9
11
|
*
|
|
@@ -63,6 +65,8 @@ export declare class ActorCollectionClient extends ResourceCollectionClient {
|
|
|
63
65
|
create(actor: ActorCollectionCreateOptions): Promise<Actor>;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
68
|
+
* Field to order a list of Actors by.
|
|
69
|
+
*
|
|
66
70
|
* @since Added in 2.12.6
|
|
67
71
|
*/
|
|
68
72
|
export declare enum ActorListSortBy {
|
|
@@ -75,14 +79,7 @@ export interface ActorCollectionListOptions extends PaginationOptions {
|
|
|
75
79
|
/**
|
|
76
80
|
* @since Added in 2.12.6
|
|
77
81
|
*/
|
|
78
|
-
sortBy?: ActorListSortBy
|
|
79
|
-
}
|
|
80
|
-
export interface ActorCollectionListItem {
|
|
81
|
-
id: string;
|
|
82
|
-
createdAt: Date;
|
|
83
|
-
modifiedAt: Date;
|
|
84
|
-
name: string;
|
|
85
|
-
username: string;
|
|
82
|
+
sortBy?: `${ActorListSortBy}`;
|
|
86
83
|
}
|
|
87
84
|
export type ActorCollectionListResult = PaginatedList<ActorCollectionListItem>;
|
|
88
85
|
export interface ActorCollectionCreateOptions {
|
|
@@ -105,8 +102,6 @@ export interface ActorCollectionCreateOptions {
|
|
|
105
102
|
isDeprecated?: boolean;
|
|
106
103
|
isPublic?: boolean;
|
|
107
104
|
name?: string;
|
|
108
|
-
/** @deprecated Use defaultRunOptions.restartOnError instead */
|
|
109
|
-
restartOnError?: boolean;
|
|
110
105
|
/**
|
|
111
106
|
* @since Added in 2.8.6
|
|
112
107
|
*/
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const actorCreateSchema = utils_1.anyObjectSchema.optional();
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import * as schemas from '../schemas.js';
|
|
4
|
+
import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
|
|
5
|
+
const actorCreateSchema = anyObjectSchema.optional();
|
|
8
6
|
/**
|
|
9
7
|
* Client for managing the collection of Actors in your account.
|
|
10
8
|
*
|
|
@@ -28,7 +26,7 @@ const actorCreateSchema = utils_1.anyObjectSchema.optional();
|
|
|
28
26
|
*
|
|
29
27
|
* @see https://docs.apify.com/platform/actors
|
|
30
28
|
*/
|
|
31
|
-
class ActorCollectionClient extends
|
|
29
|
+
export class ActorCollectionClient extends ResourceCollectionClient {
|
|
32
30
|
/**
|
|
33
31
|
* @hidden
|
|
34
32
|
*/
|
|
@@ -59,8 +57,8 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
59
57
|
* @see https://docs.apify.com/api/v2/acts-get
|
|
60
58
|
*/
|
|
61
59
|
list(options = {}) {
|
|
62
|
-
const parsed =
|
|
63
|
-
return this._listPaginated(parsed);
|
|
60
|
+
const parsed = parseArgument(options, listOptionsSchema, 'ActorCollectionListOptions');
|
|
61
|
+
return this._listPaginated(schemas.ListOfActors(), parsed);
|
|
64
62
|
}
|
|
65
63
|
/**
|
|
66
64
|
* Creates a new Actor.
|
|
@@ -70,23 +68,24 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
|
|
|
70
68
|
* @see https://docs.apify.com/api/v2/acts-post
|
|
71
69
|
*/
|
|
72
70
|
async create(actor) {
|
|
73
|
-
|
|
74
|
-
return this._create(actor);
|
|
71
|
+
parseArgument(actor, actorCreateSchema);
|
|
72
|
+
return this._create(schemas.Actor(), actor);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
|
-
exports.ActorCollectionClient = ActorCollectionClient;
|
|
78
75
|
/**
|
|
76
|
+
* Field to order a list of Actors by.
|
|
77
|
+
*
|
|
79
78
|
* @since Added in 2.12.6
|
|
80
79
|
*/
|
|
81
|
-
var ActorListSortBy;
|
|
80
|
+
export var ActorListSortBy;
|
|
82
81
|
(function (ActorListSortBy) {
|
|
83
82
|
ActorListSortBy["CREATED_AT"] = "createdAt";
|
|
84
83
|
ActorListSortBy["LAST_RUN_STARTED_AT"] = "stats.lastRunStartedAt";
|
|
85
|
-
})(ActorListSortBy || (
|
|
84
|
+
})(ActorListSortBy || (ActorListSortBy = {}));
|
|
86
85
|
// Declared below `ActorListSortBy` because it references it at module load time.
|
|
87
|
-
const listOptionsSchema =
|
|
88
|
-
my:
|
|
89
|
-
...
|
|
90
|
-
desc:
|
|
91
|
-
sortBy:
|
|
86
|
+
const listOptionsSchema = z.strictObject({
|
|
87
|
+
my: z.boolean().optional(),
|
|
88
|
+
...paginationOptionsShape,
|
|
89
|
+
desc: z.boolean().optional(),
|
|
90
|
+
sortBy: z.enum(ActorListSortBy).optional(),
|
|
92
91
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import type { ActorEnvironmentVariable } from './actor_version';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { ActorEnvironmentVariable } from './actor_version.js';
|
|
4
4
|
/**
|
|
5
5
|
* Client for managing a specific Actor environment variable.
|
|
6
6
|
*
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const resource_client_1 = require("../base/resource_client");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
6
4
|
/**
|
|
7
5
|
* Client for managing a specific Actor environment variable.
|
|
8
6
|
*
|
|
@@ -26,7 +24,7 @@ const utils_1 = require("../utils");
|
|
|
26
24
|
* @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
|
|
27
25
|
* @since Added in 2.1.0
|
|
28
26
|
*/
|
|
29
|
-
class ActorEnvVarClient extends
|
|
27
|
+
export class ActorEnvVarClient extends ResourceClient {
|
|
30
28
|
/**
|
|
31
29
|
* @hidden
|
|
32
30
|
*/
|
|
@@ -43,7 +41,7 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
|
|
|
43
41
|
* @see https://docs.apify.com/api/v2/act-version-env-var-get
|
|
44
42
|
*/
|
|
45
43
|
async get() {
|
|
46
|
-
return this._get();
|
|
44
|
+
return this._get(schemas.EnvVar());
|
|
47
45
|
}
|
|
48
46
|
/**
|
|
49
47
|
* Updates the environment variable.
|
|
@@ -53,8 +51,8 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
|
|
|
53
51
|
* @see https://docs.apify.com/api/v2/act-version-env-var-put
|
|
54
52
|
*/
|
|
55
53
|
async update(actorEnvVar) {
|
|
56
|
-
|
|
57
|
-
return this._update(actorEnvVar);
|
|
54
|
+
parseArgument(actorEnvVar, anyObjectSchema);
|
|
55
|
+
return this._update(schemas.EnvVar(), actorEnvVar);
|
|
58
56
|
}
|
|
59
57
|
/**
|
|
60
58
|
* Deletes the environment variable.
|
|
@@ -65,4 +63,3 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
|
|
|
65
63
|
return this._delete();
|
|
66
64
|
}
|
|
67
65
|
}
|
|
68
|
-
exports.ActorEnvVarClient = ActorEnvVarClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceCollectionClient } from '../base/resource_collection_client';
|
|
3
|
-
import type { PaginatedList
|
|
4
|
-
import type { ActorEnvironmentVariable } from './actor_version';
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
3
|
+
import type { PaginatedList } from '../utils.js';
|
|
4
|
+
import type { ActorEnvironmentVariable } from './actor_version.js';
|
|
5
5
|
/**
|
|
6
6
|
* Client for managing the collection of environment variables for an Actor version.
|
|
7
7
|
*
|
|
@@ -37,23 +37,22 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
|
|
|
37
37
|
/**
|
|
38
38
|
* Lists all environment variables of this Actor version.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* The endpoint returns every environment variable in one response, so awaiting the return value (as you would
|
|
41
|
+
* with a Promise) gets the whole list.
|
|
42
42
|
* ```javascript
|
|
43
|
-
* const
|
|
44
|
-
|
|
43
|
+
* const { items } = await client.list();
|
|
44
|
+
* ```
|
|
45
45
|
*
|
|
46
|
-
* Asynchronous iteration is also supported
|
|
47
|
-
* retrieved.
|
|
46
|
+
* Asynchronous iteration is also supported, and yields the environment variables one by one.
|
|
48
47
|
*
|
|
49
48
|
* ```javascript
|
|
50
49
|
* for await (const singleItem of client.list()) {...}
|
|
51
50
|
* ```
|
|
52
51
|
*
|
|
53
|
-
* @returns
|
|
52
|
+
* @returns The environment variables, awaitable as a whole list or iterable one by one.
|
|
54
53
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
|
|
55
54
|
*/
|
|
56
|
-
list(
|
|
55
|
+
list(): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
|
|
57
56
|
/**
|
|
58
57
|
* Creates a new environment variable for this Actor version.
|
|
59
58
|
*
|
|
@@ -63,14 +62,6 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
|
|
|
63
62
|
*/
|
|
64
63
|
create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
|
|
65
64
|
}
|
|
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;
|
|
73
|
-
}
|
|
74
65
|
/**
|
|
75
66
|
* @since Added in 2.1.0
|
|
76
67
|
*/
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
|
|
1
|
+
import { ResourceCollectionClient } from '../base/resource_collection_client.js';
|
|
2
|
+
import * as schemas from '../schemas.js';
|
|
3
|
+
import { anyObjectSchema, parseArgument } from '../utils.js';
|
|
4
|
+
const actorEnvVarSchema = anyObjectSchema.optional();
|
|
7
5
|
/**
|
|
8
6
|
* Client for managing the collection of environment variables for an Actor version.
|
|
9
7
|
*
|
|
@@ -31,7 +29,7 @@ const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
|
|
|
31
29
|
* @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
|
|
32
30
|
* @since Added in 2.1.0
|
|
33
31
|
*/
|
|
34
|
-
class ActorEnvVarCollectionClient extends
|
|
32
|
+
export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
|
|
35
33
|
/**
|
|
36
34
|
* @hidden
|
|
37
35
|
*/
|
|
@@ -44,24 +42,23 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
|
|
|
44
42
|
/**
|
|
45
43
|
* Lists all environment variables of this Actor version.
|
|
46
44
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
45
|
+
* The endpoint returns every environment variable in one response, so awaiting the return value (as you would
|
|
46
|
+
* with a Promise) gets the whole list.
|
|
49
47
|
* ```javascript
|
|
50
|
-
* const
|
|
51
|
-
|
|
48
|
+
* const { items } = await client.list();
|
|
49
|
+
* ```
|
|
52
50
|
*
|
|
53
|
-
* Asynchronous iteration is also supported
|
|
54
|
-
* retrieved.
|
|
51
|
+
* Asynchronous iteration is also supported, and yields the environment variables one by one.
|
|
55
52
|
*
|
|
56
53
|
* ```javascript
|
|
57
54
|
* for await (const singleItem of client.list()) {...}
|
|
58
55
|
* ```
|
|
59
56
|
*
|
|
60
|
-
* @returns
|
|
57
|
+
* @returns The environment variables, awaitable as a whole list or iterable one by one.
|
|
61
58
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
|
|
62
59
|
*/
|
|
63
|
-
list(
|
|
64
|
-
return this._listPaginated();
|
|
60
|
+
list() {
|
|
61
|
+
return this._listPaginated(schemas.ListOfEnvVars());
|
|
65
62
|
}
|
|
66
63
|
/**
|
|
67
64
|
* Creates a new environment variable for this Actor version.
|
|
@@ -71,8 +68,7 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
|
|
|
71
68
|
* @see https://docs.apify.com/api/v2/act-version-env-vars-post
|
|
72
69
|
*/
|
|
73
70
|
async create(actorEnvVar) {
|
|
74
|
-
|
|
75
|
-
return this._create(actorEnvVar);
|
|
71
|
+
parseArgument(actorEnvVar, actorEnvVarSchema);
|
|
72
|
+
return this._create(schemas.EnvVar(), actorEnvVar);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
exports.ActorEnvVarCollectionClient = ActorEnvVarCollectionClient;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { ApiClientSubResourceOptions } from '../base/api_client';
|
|
2
|
-
import { ResourceClient } from '../base/resource_client';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { ApiClientSubResourceOptions } from '../base/api_client.js';
|
|
2
|
+
import { ResourceClient } from '../base/resource_client.js';
|
|
3
|
+
import type { ActorVersion, FinalActorVersion } from '../models.js';
|
|
4
|
+
import { ActorEnvVarClient } from './actor_env_var.js';
|
|
5
|
+
import { ActorEnvVarCollectionClient } from './actor_env_var_collection.js';
|
|
6
|
+
export type { ActorEnvironmentVariable, ActorVersion, ActorVersionGitHubGist, ActorVersionGitRepo, ActorVersionSourceCode, ActorVersionSourceFile, ActorVersionSourceFiles, ActorVersionSourceFolder, ActorVersionTarball, BaseActorVersion, FinalActorVersion, } from '../models.js';
|
|
7
|
+
export { ActorSourceType } from '../models.js';
|
|
5
8
|
/**
|
|
6
9
|
* Client for managing a specific Actor version.
|
|
7
10
|
*
|
|
@@ -42,7 +45,7 @@ export declare class ActorVersionClient extends ResourceClient {
|
|
|
42
45
|
* @returns The updated Actor version object.
|
|
43
46
|
* @see https://docs.apify.com/api/v2/act-version-put
|
|
44
47
|
*/
|
|
45
|
-
update(newFields:
|
|
48
|
+
update(newFields: ActorVersionUpdateData): Promise<FinalActorVersion>;
|
|
46
49
|
/**
|
|
47
50
|
* Deletes the Actor version.
|
|
48
51
|
*
|
|
@@ -67,43 +70,11 @@ export declare class ActorVersionClient extends ResourceClient {
|
|
|
67
70
|
*/
|
|
68
71
|
envVars(): ActorEnvVarCollectionClient;
|
|
69
72
|
}
|
|
70
|
-
export interface BaseActorVersion<SourceType extends ActorSourceType> {
|
|
71
|
-
versionNumber?: string;
|
|
72
|
-
sourceType: SourceType;
|
|
73
|
-
envVars?: ActorEnvironmentVariable[];
|
|
74
|
-
applyEnvVarsToBuild?: boolean;
|
|
75
|
-
buildTag?: string;
|
|
76
|
-
}
|
|
77
73
|
/**
|
|
78
|
-
*
|
|
74
|
+
* Fields that can be changed on an existing Actor version.
|
|
75
|
+
*
|
|
76
|
+
* All of them are optional, because the endpoint leaves untouched whatever the payload does not
|
|
77
|
+
* mention. The version union enforces the pairing: a `sourceType` can only be sent next to the
|
|
78
|
+
* source location it implies, never next to one of the other three.
|
|
79
79
|
*/
|
|
80
|
-
export
|
|
81
|
-
sourceFiles: ActorVersionSourceFile[];
|
|
82
|
-
}
|
|
83
|
-
export interface ActorVersionSourceFile {
|
|
84
|
-
name: string;
|
|
85
|
-
format: 'TEXT' | 'BASE64';
|
|
86
|
-
content: string;
|
|
87
|
-
}
|
|
88
|
-
export interface ActorVersionGitRepo extends BaseActorVersion<ActorSourceType.GitRepo> {
|
|
89
|
-
gitRepoUrl: string;
|
|
90
|
-
}
|
|
91
|
-
export interface ActorVersionTarball extends BaseActorVersion<ActorSourceType.Tarball> {
|
|
92
|
-
tarballUrl: string;
|
|
93
|
-
}
|
|
94
|
-
export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType.GitHubGist> {
|
|
95
|
-
gitHubGistUrl: string;
|
|
96
|
-
}
|
|
97
|
-
export declare enum ActorSourceType {
|
|
98
|
-
SourceFiles = "SOURCE_FILES",
|
|
99
|
-
GitRepo = "GIT_REPO",
|
|
100
|
-
Tarball = "TARBALL",
|
|
101
|
-
GitHubGist = "GITHUB_GIST"
|
|
102
|
-
}
|
|
103
|
-
export interface ActorEnvironmentVariable {
|
|
104
|
-
name?: string;
|
|
105
|
-
value?: string;
|
|
106
|
-
isSecret?: boolean;
|
|
107
|
-
}
|
|
108
|
-
export type ActorVersion = ActorVersionSourceFiles | ActorVersionGitRepo | ActorVersionTarball | ActorVersionGitHubGist;
|
|
109
|
-
export type FinalActorVersion = ActorVersion & Required<Pick<ActorVersion, 'versionNumber' | 'buildTag'>>;
|
|
80
|
+
export type ActorVersionUpdateData = Partial<ActorVersion>;
|