Skip to content

Commit 85653a1

Browse files
jancurnCopilotdanpoletaevB4nan
authored
feat: Generated JSDocs based on the API reference (#797)
See https://apify.slack.com/archives/CQ96RHG2U/p1764257199836629 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: jancurn <[email protected]> Co-authored-by: Daniil Poletaev <[email protected]> Co-authored-by: B4nan <[email protected]>
1 parent 8345218 commit 85653a1

29 files changed

+2501
-230
lines changed

src/apify_client.ts

Lines changed: 237 additions & 25 deletions
Large diffs are not rendered by default.

src/resource_clients/actor.ts

Lines changed: 322 additions & 31 deletions
Large diffs are not rendered by default.

src/resource_clients/actor_collection.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../uti
66
import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor';
77
import type { ActorVersion } from './actor_version';
88

9+
/**
10+
* Client for managing the collection of Actors in your account.
11+
*
12+
* Provides methods to list and create Actors. To access an individual Actor,
13+
* use the `actor()` method on the main ApifyClient.
14+
*
15+
* @example
16+
* ```javascript
17+
* const client = new ApifyClient({ token: 'my-token' });
18+
* const actorsClient = client.actors();
19+
*
20+
* // List all Actors
21+
* const { items } = await actorsClient.list();
22+
*
23+
* // Create a new Actor
24+
* const newActor = await actorsClient.create({
25+
* name: 'my-actor',
26+
* title: 'My Actor'
27+
* });
28+
* ```
29+
*
30+
* @see https://docs.apify.com/platform/actors
31+
*/
932
export class ActorCollectionClient extends ResourceCollectionClient {
1033
/**
1134
* @hidden
@@ -18,20 +41,24 @@ export class ActorCollectionClient extends ResourceCollectionClient {
1841
}
1942

2043
/**
21-
* https://docs.apify.com/api/v2#/reference/actors/actor-collection/get-list-of-actors
44+
* Lists all Actors.
2245
*
2346
* Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
2447
* items in a single API call is limited.
2548
* ```javascript
2649
* const paginatedList = await client.list(options);
27-
*```
50+
* ```
2851
*
2952
* Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
3053
* retrieved.
3154
*
3255
* ```javascript
3356
* for await (const singleItem of client.list(options)) {...}
3457
* ```
58+
*
59+
* @param options - Pagination options.
60+
* @returns A paginated iterator of Actors.
61+
* @see https://docs.apify.com/api/v2/acts-get
3562
*/
3663
list(options: ActorCollectionListOptions = {}): PaginatedIterator<ActorCollectionListItem> {
3764
ow(
@@ -49,7 +76,11 @@ export class ActorCollectionClient extends ResourceCollectionClient {
4976
}
5077

5178
/**
52-
* https://docs.apify.com/api/v2#/reference/actors/actor-collection/create-actor
79+
* Creates a new Actor.
80+
*
81+
* @param actor - The Actor data.
82+
* @returns The created Actor object.
83+
* @see https://docs.apify.com/api/v2/acts-post
5384
*/
5485
async create(actor: ActorCollectionCreateOptions): Promise<Actor> {
5586
ow(actor, ow.optional.object);

src/resource_clients/actor_env_var.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ import type { ApiClientSubResourceOptions } from '../base/api_client';
44
import { ResourceClient } from '../base/resource_client';
55
import type { ActorEnvironmentVariable } from './actor_version';
66

7+
/**
8+
* Client for managing a specific Actor environment variable.
9+
*
10+
* Environment variables are key-value pairs that are available to the Actor during execution.
11+
* This client provides methods to get, update, and delete environment variables.
12+
*
13+
* @example
14+
* ```javascript
15+
* const client = new ApifyClient({ token: 'my-token' });
16+
* const actorClient = client.actor('my-actor-id');
17+
* const versionClient = actorClient.version('0.1');
18+
*
19+
* // Get an environment variable
20+
* const envVarClient = versionClient.envVar('MY_VAR');
21+
* const envVar = await envVarClient.get();
22+
*
23+
* // Update environment variable
24+
* await envVarClient.update({ value: 'new-value' });
25+
* ```
26+
*
27+
* @see https://docs.apify.com/platform/actors/development/actor-definition/environment-variables
28+
*/
729
export class ActorEnvVarClient extends ResourceClient {
830
/**
931
* @hidden
@@ -16,22 +38,31 @@ export class ActorEnvVarClient extends ResourceClient {
1638
}
1739

1840
/**
19-
* https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/get-environment-variable
41+
* Retrieves the environment variable.
42+
*
43+
* @returns The environment variable object, or `undefined` if it does not exist.
44+
* @see https://docs.apify.com/api/v2/act-version-env-var-get
2045
*/
2146
async get(): Promise<ActorEnvironmentVariable | undefined> {
2247
return this._get();
2348
}
2449

2550
/**
26-
* https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/update-environment-variable
51+
* Updates the environment variable.
52+
*
53+
* @param actorEnvVar - The updated environment variable data.
54+
* @returns The updated environment variable object.
55+
* @see https://docs.apify.com/api/v2/act-version-env-var-put
2756
*/
2857
async update(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable> {
2958
ow(actorEnvVar, ow.object);
3059
return this._update(actorEnvVar);
3160
}
3261

3362
/**
34-
* https://docs.apify.com/api/v2#/reference/actors/environment-variable-object/delete-environment-variable
63+
* Deletes the environment variable.
64+
*
65+
* @see https://docs.apify.com/api/v2/act-version-env-var-delete
3566
*/
3667
async delete(): Promise<void> {
3768
return this._delete();

src/resource_clients/actor_env_var_collection.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ import { ResourceCollectionClient } from '../base/resource_collection_client';
55
import type { PaginatedList, PaginationOptions } from '../utils';
66
import type { ActorEnvironmentVariable } from './actor_version';
77

8+
/**
9+
* Client for managing the collection of environment variables for an Actor version.
10+
*
11+
* Environment variables are key-value pairs that are available to the Actor during execution.
12+
* This client provides methods to list and create environment variables.
13+
*
14+
* @example
15+
* ```javascript
16+
* const client = new ApifyClient({ token: 'my-token' });
17+
* const actorClient = client.actor('my-actor-id');
18+
* const versionClient = actorClient.version('0.1');
19+
*
20+
* // List all environment variables
21+
* const envVarsClient = versionClient.envVars();
22+
* const { items } = await envVarsClient.list();
23+
*
24+
* // Create a new environment variable
25+
* const newEnvVar = await envVarsClient.create({
26+
* name: 'MY_VAR',
27+
* value: 'my-value',
28+
* isSecret: false
29+
* });
30+
* ```
31+
*
32+
* @see https://docs.apify.com/platform/actors/development/actor-definition/environment-variables
33+
*/
834
export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
935
/**
1036
* @hidden
@@ -17,20 +43,24 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
1743
}
1844

1945
/**
20-
* https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/get-list-of-environment-variables
46+
* Lists all environment variables of this Actor version.
2147
*
2248
* Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
2349
* items in a single API call is limited.
2450
* ```javascript
2551
* const paginatedList = await client.list(options);
26-
*```
52+
* ```
2753
*
2854
* Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
2955
* retrieved.
3056
*
3157
* ```javascript
3258
* for await (const singleItem of client.list(options)) {...}
3359
* ```
60+
*
61+
* @param options - Pagination options.
62+
* @returns A paginated iterator of environment variables.
63+
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
3464
*/
3565
list(
3666
options: ActorEnvVarCollectionListOptions = {},
@@ -47,7 +77,11 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
4777
}
4878

4979
/**
50-
* https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/create-environment-variable
80+
* Creates a new environment variable for this Actor version.
81+
*
82+
* @param actorEnvVar - The environment variable data.
83+
* @returns The created environment variable object.
84+
* @see https://docs.apify.com/api/v2/act-version-env-vars-post
5185
*/
5286
async create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable> {
5387
ow(actorEnvVar, ow.optional.object);

src/resource_clients/actor_version.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ import { ResourceClient } from '../base/resource_client';
55
import { ActorEnvVarClient } from './actor_env_var';
66
import { ActorEnvVarCollectionClient } from './actor_env_var_collection';
77

8+
/**
9+
* Client for managing a specific Actor version.
10+
*
11+
* Actor versions represent specific builds or snapshots of an Actor's code. This client provides
12+
* methods to get, update, and delete versions, as well as manage their environment variables.
13+
*
14+
* @example
15+
* ```javascript
16+
* const client = new ApifyClient({ token: 'my-token' });
17+
* const actorClient = client.actor('my-actor-id');
18+
*
19+
* // Get a specific version
20+
* const versionClient = actorClient.version('0.1');
21+
* const version = await versionClient.get();
22+
*
23+
* // Update version
24+
* await versionClient.update({ buildTag: 'latest' });
25+
* ```
26+
*
27+
* @see https://docs.apify.com/platform/actors/development/actor-definition/versions
28+
*/
829
export class ActorVersionClient extends ResourceClient {
930
/**
1031
* @hidden
@@ -17,14 +38,21 @@ export class ActorVersionClient extends ResourceClient {
1738
}
1839

1940
/**
20-
* https://docs.apify.com/api/v2#/reference/actors/version-object/get-version
41+
* Retrieves the Actor version.
42+
*
43+
* @returns The Actor version object, or `undefined` if it does not exist.
44+
* @see https://docs.apify.com/api/v2/act-version-get
2145
*/
2246
async get(): Promise<FinalActorVersion | undefined> {
2347
return this._get();
2448
}
2549

2650
/**
27-
* https://docs.apify.com/api/v2#/reference/actors/version-object/update-version
51+
* Updates the Actor version with the specified fields.
52+
*
53+
* @param newFields - Fields to update.
54+
* @returns The updated Actor version object.
55+
* @see https://docs.apify.com/api/v2/act-version-put
2856
*/
2957
async update(newFields: ActorVersion): Promise<FinalActorVersion> {
3058
ow(newFields, ow.object);
@@ -33,14 +61,20 @@ export class ActorVersionClient extends ResourceClient {
3361
}
3462

3563
/**
36-
* https://docs.apify.com/api/v2#/reference/actors/version-object/delete-version
64+
* Deletes the Actor version.
65+
*
66+
* @see https://docs.apify.com/api/v2/act-version-delete
3767
*/
3868
async delete(): Promise<void> {
3969
return this._delete();
4070
}
4171

4272
/**
43-
* TODO: https://docs.apify.com/api/v2#/reference/actors/env-var-object
73+
* Returns a client for the specified environment variable of this Actor version.
74+
*
75+
* @param envVarName - Name of the environment variable.
76+
* @returns A client for the environment variable.
77+
* @see https://docs.apify.com/api/v2/act-version-env-var-get
4478
*/
4579
envVar(envVarName: string): ActorEnvVarClient {
4680
ow(envVarName, ow.string);
@@ -52,8 +86,10 @@ export class ActorVersionClient extends ResourceClient {
5286
}
5387

5488
/**
55-
* TODO: https://docs.apify.com/api/v2#/reference/actors/env-var-collection
56-
* @return {ActorVersionCollectionClient}
89+
* Returns a client for the environment variables of this Actor version.
90+
*
91+
* @returns A client for the Actor version's environment variables.
92+
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
5793
*/
5894
envVars(): ActorEnvVarCollectionClient {
5995
return new ActorEnvVarCollectionClient(this._subResourceOptions());

src/resource_clients/actor_version_collection.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ import { ResourceCollectionClient } from '../base/resource_collection_client';
55
import type { PaginatedList, PaginationOptions } from '../utils';
66
import type { ActorVersion, FinalActorVersion } from './actor_version';
77

8+
/**
9+
* Client for managing the collection of Actor versions.
10+
*
11+
* Actor versions represent specific builds or snapshots of an Actor's code. This client provides
12+
* methods to list and create versions for a specific Actor.
13+
*
14+
* @example
15+
* ```javascript
16+
* const client = new ApifyClient({ token: 'my-token' });
17+
* const actorClient = client.actor('my-actor-id');
18+
*
19+
* // List all versions
20+
* const versionsClient = actorClient.versions();
21+
* const { items } = await versionsClient.list();
22+
*
23+
* // Create a new version
24+
* const newVersion = await versionsClient.create({
25+
* versionNumber: '0.2',
26+
* buildTag: 'latest'
27+
* });
28+
* ```
29+
*
30+
* @see https://docs.apify.com/platform/actors/development/actor-definition/versions
31+
*/
832
export class ActorVersionCollectionClient extends ResourceCollectionClient {
933
/**
1034
* @hidden
@@ -17,20 +41,24 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
1741
}
1842

1943
/**
20-
* https://docs.apify.com/api/v2#/reference/actors/version-collection/get-list-of-versions
44+
* Lists all Actor versions.
2145
*
2246
* Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
2347
* items in a single API call is limited.
2448
* ```javascript
2549
* const paginatedList = await client.list(options);
26-
*```
50+
* ```
2751
*
2852
* Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
2953
* retrieved.
3054
*
3155
* ```javascript
3256
* for await (const singleItem of client.list(options)) {...}
3357
* ```
58+
*
59+
* @param options - Pagination options.
60+
* @returns A paginated iterator of Actor versions.
61+
* @see https://docs.apify.com/api/v2/act-versions-get
3462
*/
3563
list(
3664
options: ActorVersionCollectionListOptions = {},
@@ -48,7 +76,11 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
4876
}
4977

5078
/**
51-
* https://docs.apify.com/api/v2#/reference/actors/version-collection/create-version
79+
* Creates a new Actor version.
80+
*
81+
* @param actorVersion - The Actor version data.
82+
* @returns The created Actor version object.
83+
* @see https://docs.apify.com/api/v2/act-versions-post
5284
*/
5385
async create(actorVersion: ActorVersion): Promise<FinalActorVersion> {
5486
ow(actorVersion, ow.optional.object);

0 commit comments

Comments
 (0)