apify-client 3.0.0-beta.6 → 3.0.0-beta.60

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.
Files changed (116) hide show
  1. package/README.md +10 -2
  2. package/dist/apify_api_error.d.ts +11 -26
  3. package/dist/apify_api_error.js +31 -22
  4. package/dist/apify_client.d.ts +125 -10
  5. package/dist/apify_client.js +133 -48
  6. package/dist/base/api_client.d.ts +7 -7
  7. package/dist/base/api_client.js +36 -36
  8. package/dist/base/resource_client.d.ts +21 -8
  9. package/dist/base/resource_client.js +67 -33
  10. package/dist/base/resource_collection_client.d.ts +12 -4
  11. package/dist/base/resource_collection_client.js +34 -11
  12. package/dist/body_parser.d.ts +3 -4
  13. package/dist/body_parser.js +19 -26
  14. package/dist/bundle.js +27 -22
  15. package/dist/bundle.js.map +1 -1
  16. package/dist/generated/api.d.ts +785 -290
  17. package/dist/generated/schemas.d.ts +771 -798
  18. package/dist/generated/schemas.js +183 -179
  19. package/dist/http_clients/axios.d.ts +60 -0
  20. package/dist/http_clients/axios.js +117 -0
  21. package/dist/http_clients/base.d.ts +331 -0
  22. package/dist/http_clients/base.js +563 -0
  23. package/dist/http_clients/index.d.ts +4 -0
  24. package/dist/http_clients/index.js +2 -0
  25. package/dist/http_compressors/base.d.ts +40 -0
  26. package/dist/http_compressors/base.js +9 -0
  27. package/dist/http_compressors/brotli.d.ts +33 -0
  28. package/dist/http_compressors/brotli.js +39 -0
  29. package/dist/http_compressors/gzip.d.ts +33 -0
  30. package/dist/http_compressors/gzip.js +39 -0
  31. package/dist/http_compressors/index.d.ts +6 -0
  32. package/dist/http_compressors/index.js +2 -0
  33. package/dist/http_compressors/resolve.d.ts +23 -0
  34. package/dist/http_compressors/resolve.js +27 -0
  35. package/dist/index.d.ts +4 -1
  36. package/dist/index.js +3 -1
  37. package/dist/invalid_response_body_error.d.ts +13 -0
  38. package/dist/invalid_response_body_error.js +17 -0
  39. package/dist/models.d.ts +162 -194
  40. package/dist/models.js +6 -4
  41. package/dist/resource_clients/actor.d.ts +74 -34
  42. package/dist/resource_clients/actor.js +87 -56
  43. package/dist/resource_clients/actor_collection.d.ts +18 -14
  44. package/dist/resource_clients/actor_collection.js +11 -3
  45. package/dist/resource_clients/actor_env_var.d.ts +11 -4
  46. package/dist/resource_clients/actor_env_var.js +16 -6
  47. package/dist/resource_clients/actor_env_var_collection.d.ts +16 -20
  48. package/dist/resource_clients/actor_env_var_collection.js +17 -11
  49. package/dist/resource_clients/actor_version.d.ts +20 -5
  50. package/dist/resource_clients/actor_version.js +19 -9
  51. package/dist/resource_clients/actor_version_collection.d.ts +18 -19
  52. package/dist/resource_clients/actor_version_collection.js +19 -11
  53. package/dist/resource_clients/build.d.ts +20 -7
  54. package/dist/resource_clients/build.js +35 -15
  55. package/dist/resource_clients/build_collection.d.ts +7 -5
  56. package/dist/resource_clients/build_collection.js +4 -1
  57. package/dist/resource_clients/dataset.d.ts +53 -35
  58. package/dist/resource_clients/dataset.js +105 -80
  59. package/dist/resource_clients/dataset_collection.d.ts +10 -6
  60. package/dist/resource_clients/dataset_collection.js +13 -2
  61. package/dist/resource_clients/key_value_store.d.ts +73 -23
  62. package/dist/resource_clients/key_value_store.js +86 -43
  63. package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
  64. package/dist/resource_clients/key_value_store_collection.js +13 -2
  65. package/dist/resource_clients/log.d.ts +13 -20
  66. package/dist/resource_clients/log.js +141 -59
  67. package/dist/resource_clients/request_queue.d.ts +74 -36
  68. package/dist/resource_clients/request_queue.js +182 -106
  69. package/dist/resource_clients/request_queue_collection.d.ts +9 -5
  70. package/dist/resource_clients/request_queue_collection.js +9 -3
  71. package/dist/resource_clients/run.d.ts +119 -28
  72. package/dist/resource_clients/run.js +190 -49
  73. package/dist/resource_clients/run_collection.d.ts +5 -3
  74. package/dist/resource_clients/run_collection.js +4 -1
  75. package/dist/resource_clients/schedule.d.ts +16 -7
  76. package/dist/resource_clients/schedule.js +30 -22
  77. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  78. package/dist/resource_clients/schedule_collection.js +9 -3
  79. package/dist/resource_clients/store_collection.d.ts +6 -4
  80. package/dist/resource_clients/store_collection.js +4 -1
  81. package/dist/resource_clients/task.d.ts +36 -13
  82. package/dist/resource_clients/task.js +79 -46
  83. package/dist/resource_clients/task_collection.d.ts +9 -5
  84. package/dist/resource_clients/task_collection.js +9 -3
  85. package/dist/resource_clients/user.d.ts +19 -10
  86. package/dist/resource_clients/user.js +42 -38
  87. package/dist/resource_clients/webhook.d.ts +17 -8
  88. package/dist/resource_clients/webhook.js +30 -22
  89. package/dist/resource_clients/webhook_collection.d.ts +8 -4
  90. package/dist/resource_clients/webhook_collection.js +9 -3
  91. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  92. package/dist/resource_clients/webhook_dispatch.js +7 -2
  93. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  94. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  95. package/dist/runtime/node.d.ts +6 -0
  96. package/dist/runtime/node.js +49 -0
  97. package/dist/runtime/types.d.ts +52 -0
  98. package/dist/runtime/types.js +1 -0
  99. package/dist/runtime/web.d.ts +5 -0
  100. package/dist/runtime/web.js +18 -0
  101. package/dist/schemas.d.ts +1 -1
  102. package/dist/schemas.js +1 -1
  103. package/dist/statistics.d.ts +1 -6
  104. package/dist/statistics.js +2 -2
  105. package/dist/timeouts.d.ts +84 -0
  106. package/dist/timeouts.js +37 -0
  107. package/dist/timezones.d.ts +1 -1
  108. package/dist/utils.d.ts +89 -53
  109. package/dist/utils.js +214 -161
  110. package/dist/wait_for_resources.d.ts +8 -0
  111. package/dist/wait_for_resources.js +39 -0
  112. package/package.json +32 -29
  113. package/dist/http_client.d.ts +0 -88
  114. package/dist/http_client.js +0 -255
  115. package/dist/interceptors.d.ts +0 -19
  116. package/dist/interceptors.js +0 -105
@@ -1,7 +1,8 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
- import type { PaginatedList, PaginationOptions } from '../utils.js';
4
- import type { ActorEnvironmentVariable } from './actor_version.js';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { PaginatedList } from '../utils.js';
5
+ import type { EnvVar } from './actor_version.js';
5
6
  /**
6
7
  * Client for managing the collection of environment variables for an Actor version.
7
8
  *
@@ -37,41 +38,36 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
37
38
  /**
38
39
  * Lists all environment variables of this Actor version.
39
40
  *
40
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
41
- * items in a single API call is limited.
41
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
42
+ * with a Promise) gets the whole list.
42
43
  * ```javascript
43
- * const paginatedList = await client.list();
44
- *```
44
+ * const { items } = await client.list();
45
+ * ```
45
46
  *
46
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
47
- * retrieved.
47
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
48
48
  *
49
49
  * ```javascript
50
50
  * for await (const singleItem of client.list()) {...}
51
51
  * ```
52
52
  *
53
- * @returns A paginated iterator of environment variables.
53
+ * @param options - Request options
54
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
55
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
54
56
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
55
57
  */
56
- list(_options?: ActorEnvVarCollectionListOptions): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
58
+ list(options?: TimeoutOptions): Promise<ActorEnvVarListResult> & AsyncIterable<EnvVar>;
57
59
  /**
58
60
  * Creates a new environment variable for this Actor version.
59
61
  *
60
62
  * @param actorEnvVar - The environment variable data.
63
+ * @param options - Request options
64
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
61
65
  * @returns The created environment variable object.
62
66
  * @see https://docs.apify.com/api/v2/act-version-env-vars-post
63
67
  */
64
- create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
65
- }
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;
68
+ create(actorEnvVar: EnvVar, options?: TimeoutOptions): Promise<EnvVar>;
73
69
  }
74
70
  /**
75
71
  * @since Added in 2.1.0
76
72
  */
77
- export type ActorEnvVarListResult = Pick<PaginatedList<ActorEnvironmentVariable>, 'total' | 'items'>;
73
+ export type ActorEnvVarListResult = Pick<PaginatedList<EnvVar>, 'total' | 'items'>;
@@ -1,5 +1,6 @@
1
1
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
2
2
  import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
3
4
  import { anyObjectSchema, parseArgument } from '../utils.js';
4
5
  const actorEnvVarSchema = anyObjectSchema.optional();
5
6
  /**
@@ -42,34 +43,39 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
42
43
  /**
43
44
  * Lists all environment variables of this Actor version.
44
45
  *
45
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
46
- * items in a single API call is limited.
46
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
47
+ * with a Promise) gets the whole list.
47
48
  * ```javascript
48
- * const paginatedList = await client.list();
49
- *```
49
+ * const { items } = await client.list();
50
+ * ```
50
51
  *
51
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
52
- * retrieved.
52
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
53
53
  *
54
54
  * ```javascript
55
55
  * for await (const singleItem of client.list()) {...}
56
56
  * ```
57
57
  *
58
- * @returns A paginated iterator of environment variables.
58
+ * @param options - Request options
59
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
60
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
59
61
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
60
62
  */
61
- list(_options = {}) {
62
- return this._listPaginated(schemas.ListOfEnvVars());
63
+ list(options = {}) {
64
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
65
+ return this.listUnpaginatedResources(schemas.ListOfEnvVars(), timeoutSecs, signal);
63
66
  }
64
67
  /**
65
68
  * Creates a new environment variable for this Actor version.
66
69
  *
67
70
  * @param actorEnvVar - The environment variable data.
71
+ * @param options - Request options
72
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
68
73
  * @returns The created environment variable object.
69
74
  * @see https://docs.apify.com/api/v2/act-version-env-vars-post
70
75
  */
71
- async create(actorEnvVar) {
76
+ async create(actorEnvVar, options = {}) {
72
77
  parseArgument(actorEnvVar, actorEnvVarSchema);
73
- return this._create(schemas.EnvVar(), actorEnvVar);
78
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
79
+ return this.createResource(schemas.EnvVar(), actorEnvVar, timeoutSecs, signal);
74
80
  }
75
81
  }
@@ -1,9 +1,10 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
- import type { ActorVersion, FinalActorVersion } from '../models.js';
3
+ import type { FinalVersion, Version } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import { ActorEnvVarClient } from './actor_env_var.js';
5
6
  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 type { BaseVersion, EnvVar, FinalVersion, SourceCodeFile, SourceCodeFolder, Version, VersionGitHubGist, VersionGitRepo, VersionSourceCode, VersionSourceFiles, VersionTarball, } from '../models.js';
7
8
  export { ActorSourceType } from '../models.js';
8
9
  /**
9
10
  * Client for managing a specific Actor version.
@@ -34,24 +35,30 @@ export declare class ActorVersionClient extends ResourceClient {
34
35
  /**
35
36
  * Retrieves the Actor version.
36
37
  *
38
+ * @param options - Request options
39
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
37
40
  * @returns The Actor version object, or `undefined` if it does not exist.
38
41
  * @see https://docs.apify.com/api/v2/act-version-get
39
42
  */
40
- get(): Promise<FinalActorVersion | undefined>;
43
+ get(options?: TimeoutOptions): Promise<FinalVersion | undefined>;
41
44
  /**
42
45
  * Updates the Actor version with the specified fields.
43
46
  *
44
47
  * @param newFields - Fields to update.
48
+ * @param options - Request options
49
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
45
50
  * @returns The updated Actor version object.
46
51
  * @see https://docs.apify.com/api/v2/act-version-put
47
52
  */
48
- update(newFields: ActorVersion): Promise<FinalActorVersion>;
53
+ update(newFields: ActorVersionUpdateData, options?: TimeoutOptions): Promise<FinalVersion>;
49
54
  /**
50
55
  * Deletes the Actor version.
51
56
  *
57
+ * @param options - Request options
58
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
52
59
  * @see https://docs.apify.com/api/v2/act-version-delete
53
60
  */
54
- delete(): Promise<void>;
61
+ delete(options?: TimeoutOptions): Promise<void>;
55
62
  /**
56
63
  * Returns a client for the specified environment variable of this Actor version.
57
64
  *
@@ -70,3 +77,11 @@ export declare class ActorVersionClient extends ResourceClient {
70
77
  */
71
78
  envVars(): ActorEnvVarCollectionClient;
72
79
  }
80
+ /**
81
+ * Fields that can be changed on an existing Actor version.
82
+ *
83
+ * All of them are optional, because the endpoint leaves untouched whatever the payload does not
84
+ * mention. The version union enforces the pairing: a `sourceType` can only be sent next to the
85
+ * source location it implies, never next to one of the other three.
86
+ */
87
+ export type ActorVersionUpdateData = Partial<Version>;
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
5
  import { anyObjectSchema, parseArgument } from '../utils.js';
5
6
  import { ActorEnvVarClient } from './actor_env_var.js';
6
7
  import { ActorEnvVarCollectionClient } from './actor_env_var_collection.js';
7
- const envVarNameSchema = z.string();
8
+ const envVarNameSchema = z.string().min(1);
8
9
  export { ActorSourceType } from '../models.js';
9
10
  /**
10
11
  * Client for managing a specific Actor version.
@@ -40,30 +41,39 @@ export class ActorVersionClient extends ResourceClient {
40
41
  /**
41
42
  * Retrieves the Actor version.
42
43
  *
44
+ * @param options - Request options
45
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
43
46
  * @returns The Actor version object, or `undefined` if it does not exist.
44
47
  * @see https://docs.apify.com/api/v2/act-version-get
45
48
  */
46
- async get() {
47
- return this._get(schemas.Version());
49
+ async get(options = {}) {
50
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
51
+ return this.getResource(schemas.Version(), {}, timeoutSecs, signal);
48
52
  }
49
53
  /**
50
54
  * Updates the Actor version with the specified fields.
51
55
  *
52
56
  * @param newFields - Fields to update.
57
+ * @param options - Request options
58
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
53
59
  * @returns The updated Actor version object.
54
60
  * @see https://docs.apify.com/api/v2/act-version-put
55
61
  */
56
- async update(newFields) {
62
+ async update(newFields, options = {}) {
57
63
  parseArgument(newFields, anyObjectSchema);
58
- return this._update(schemas.Version(), newFields);
64
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
65
+ return this.updateResource(schemas.Version(), newFields, timeoutSecs, signal);
59
66
  }
60
67
  /**
61
68
  * Deletes the Actor version.
62
69
  *
70
+ * @param options - Request options
71
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
63
72
  * @see https://docs.apify.com/api/v2/act-version-delete
64
73
  */
65
- async delete() {
66
- return this._delete();
74
+ async delete(options = {}) {
75
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
76
+ return this.deleteResource(timeoutSecs, signal);
67
77
  }
68
78
  /**
69
79
  * Returns a client for the specified environment variable of this Actor version.
@@ -75,7 +85,7 @@ export class ActorVersionClient extends ResourceClient {
75
85
  */
76
86
  envVar(envVarName) {
77
87
  parseArgument(envVarName, envVarNameSchema);
78
- return new ActorEnvVarClient(this._subResourceOptions({
88
+ return new ActorEnvVarClient(this.subResourceOptions({
79
89
  id: envVarName,
80
90
  }));
81
91
  }
@@ -87,6 +97,6 @@ export class ActorVersionClient extends ResourceClient {
87
97
  * @since Added in 2.1.0
88
98
  */
89
99
  envVars() {
90
- return new ActorEnvVarCollectionClient(this._subResourceOptions());
100
+ return new ActorEnvVarCollectionClient(this.subResourceOptions());
91
101
  }
92
102
  }
@@ -1,7 +1,8 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
- import type { PaginatedList, PaginationOptions } from '../utils.js';
4
- import type { ActorVersion, FinalActorVersion } from './actor_version.js';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { PaginatedList } from '../utils.js';
5
+ import type { FinalVersion, Version } from './actor_version.js';
5
6
  /**
6
7
  * Client for managing the collection of Actor versions.
7
8
  *
@@ -20,6 +21,8 @@ import type { ActorVersion, FinalActorVersion } from './actor_version.js';
20
21
  * // Create a new version
21
22
  * const newVersion = await versionsClient.create({
22
23
  * versionNumber: '0.2',
24
+ * sourceType: 'GIT_REPO',
25
+ * gitRepoUrl: 'https://github.com/my-account/my-actor',
23
26
  * buildTag: 'latest'
24
27
  * });
25
28
  * ```
@@ -34,37 +37,33 @@ export declare class ActorVersionCollectionClient extends ResourceCollectionClie
34
37
  /**
35
38
  * Lists all Actor versions.
36
39
  *
37
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
38
- * items in a single API call is limited.
40
+ * The endpoint returns every version in one response, so awaiting the return value (as you would with a Promise)
41
+ * gets the whole list.
39
42
  * ```javascript
40
- * const paginatedList = await client.list();
41
- *```
43
+ * const { items } = await client.list();
44
+ * ```
42
45
  *
43
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
44
- * retrieved.
46
+ * Asynchronous iteration is also supported, and yields the versions one by one.
45
47
  *
46
48
  * ```javascript
47
49
  * for await (const singleItem of client.list()) {...}
48
50
  * ```
49
51
  *
50
- * @returns A paginated iterator of Actor versions.
52
+ * @param options - Request options
53
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
54
+ * @returns The Actor versions, awaitable as a whole list or iterable one by one.
51
55
  * @see https://docs.apify.com/api/v2/act-versions-get
52
56
  */
53
- list(_options?: ActorVersionCollectionListOptions): Promise<ActorVersionListResult> & AsyncIterable<FinalActorVersion>;
57
+ list(options?: TimeoutOptions): Promise<ActorVersionListResult> & AsyncIterable<FinalVersion>;
54
58
  /**
55
59
  * Creates a new Actor version.
56
60
  *
57
61
  * @param actorVersion - The Actor version data.
62
+ * @param options - Request options
63
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
64
  * @returns The created Actor version object.
59
65
  * @see https://docs.apify.com/api/v2/act-versions-post
60
66
  */
61
- create(actorVersion: ActorVersion): Promise<FinalActorVersion>;
62
- }
63
- /**
64
- * @deprecated No options are used in the current API implementation.
65
- * https://github.com/apify/apify-client-js/issues/799
66
- */
67
- export interface ActorVersionCollectionListOptions extends PaginationOptions {
68
- desc?: boolean;
67
+ create(actorVersion: Version, options?: TimeoutOptions): Promise<FinalVersion>;
69
68
  }
70
- export type ActorVersionListResult = Pick<PaginatedList<FinalActorVersion>, 'total' | 'items'>;
69
+ export type ActorVersionListResult = Pick<PaginatedList<FinalVersion>, 'total' | 'items'>;
@@ -1,5 +1,6 @@
1
1
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
2
2
  import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
3
4
  import { anyObjectSchema, parseArgument } from '../utils.js';
4
5
  const actorVersionSchema = anyObjectSchema.optional();
5
6
  /**
@@ -20,6 +21,8 @@ const actorVersionSchema = anyObjectSchema.optional();
20
21
  * // Create a new version
21
22
  * const newVersion = await versionsClient.create({
22
23
  * versionNumber: '0.2',
24
+ * sourceType: 'GIT_REPO',
25
+ * gitRepoUrl: 'https://github.com/my-account/my-actor',
23
26
  * buildTag: 'latest'
24
27
  * });
25
28
  * ```
@@ -39,34 +42,39 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
39
42
  /**
40
43
  * Lists all Actor versions.
41
44
  *
42
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
43
- * items in a single API call is limited.
45
+ * The endpoint returns every version in one response, so awaiting the return value (as you would with a Promise)
46
+ * gets the whole list.
44
47
  * ```javascript
45
- * const paginatedList = await client.list();
46
- *```
48
+ * const { items } = await client.list();
49
+ * ```
47
50
  *
48
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
49
- * retrieved.
51
+ * Asynchronous iteration is also supported, and yields the versions one by one.
50
52
  *
51
53
  * ```javascript
52
54
  * for await (const singleItem of client.list()) {...}
53
55
  * ```
54
56
  *
55
- * @returns A paginated iterator of Actor versions.
57
+ * @param options - Request options
58
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
59
+ * @returns The Actor versions, awaitable as a whole list or iterable one by one.
56
60
  * @see https://docs.apify.com/api/v2/act-versions-get
57
61
  */
58
- list(_options = {}) {
59
- return this._listPaginated(schemas.ListOfVersions());
62
+ list(options = {}) {
63
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
64
+ return this.listUnpaginatedResources(schemas.ListOfVersions(), timeoutSecs, signal);
60
65
  }
61
66
  /**
62
67
  * Creates a new Actor version.
63
68
  *
64
69
  * @param actorVersion - The Actor version data.
70
+ * @param options - Request options
71
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
65
72
  * @returns The created Actor version object.
66
73
  * @see https://docs.apify.com/api/v2/act-versions-post
67
74
  */
68
- async create(actorVersion) {
75
+ async create(actorVersion, options = {}) {
69
76
  parseArgument(actorVersion, actorVersionSchema);
70
- return this._create(schemas.Version(), actorVersion);
77
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
78
+ return this.createResource(schemas.Version(), actorVersion, timeoutSecs, signal);
71
79
  }
72
80
  }
@@ -1,8 +1,9 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import type { Build } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import { LogClient } from './log.js';
5
- export type { Build, BuildMeta, BuildOptions, BuildStats, BuildUsage } from '../models.js';
6
+ export type { Build, BuildOptions, BuildStats, BuildUsage, BuildMeta } from '../models.js';
6
7
  /**
7
8
  * Client for managing a specific Actor build.
8
9
  *
@@ -36,6 +37,8 @@ export declare class BuildClient extends ResourceClient {
36
37
  *
37
38
  * @param options - Get options
38
39
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the build to finish on the API side before returning. Default is 0 (returns immediately).
40
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
41
+ * when the API is asked to hold the response.
39
42
  * @returns The Build object, or `undefined` if it does not exist
40
43
  * @see https://docs.apify.com/api/v2/actor-build-get
41
44
  *
@@ -55,6 +58,8 @@ export declare class BuildClient extends ResourceClient {
55
58
  *
56
59
  * Stops the build process immediately. The build will have an `ABORTED` status.
57
60
  *
61
+ * @param options - Request options
62
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
58
63
  * @returns The updated Build object with `ABORTED` status
59
64
  * @see https://docs.apify.com/api/v2/actor-build-abort-post
60
65
  *
@@ -63,22 +68,26 @@ export declare class BuildClient extends ResourceClient {
63
68
  * await client.build('build-id').abort();
64
69
  * ```
65
70
  */
66
- abort(): Promise<Build>;
71
+ abort(options?: TimeoutOptions): Promise<Build>;
67
72
  /**
68
73
  * Deletes the Actor build.
69
74
  *
75
+ * @param options - Request options
76
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
70
77
  * @see https://docs.apify.com/api/v2/actor-build-delete
71
78
  * @since Added in 2.8.1
72
79
  */
73
- delete(): Promise<void>;
80
+ delete(options?: TimeoutOptions): Promise<void>;
74
81
  /**
75
82
  * Retrieves the OpenAPI definition for the Actor build.
76
83
  *
84
+ * @param options - Request options
85
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
77
86
  * @returns The OpenAPI definition object.
78
87
  * @see https://docs.apify.com/api/v2/actor-build-openapi-json-get
79
88
  * @since Added in 2.11.2
80
89
  */
81
- getOpenApiDefinition(): Promise<OpenApiDefinition>;
90
+ getOpenApiDefinition(options?: TimeoutOptions): Promise<OpenApiDefinition>;
82
91
  /**
83
92
  * Waits for the Actor build to finish and returns the finished Build object.
84
93
  *
@@ -89,12 +98,14 @@ export declare class BuildClient extends ResourceClient {
89
98
  * Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
90
99
  * by polling the build status. It uses the `waitForFinish` parameter internally (max 60s per call)
91
100
  * and continuously polls until the build finishes or the timeout is reached.
101
+ * Rejects with a {@link NotFoundError} if the build keeps returning 404 for 3 seconds.
92
102
  *
93
103
  * This is useful when you need to immediately start a run after a build finishes.
94
104
  *
95
105
  * @param options - Wait options
96
106
  * @param options.waitSecs - Maximum time to wait for the build to finish, in seconds. If omitted, waits indefinitely.
97
- * @returns The Build object (finished or still building if timeout was reached)
107
+ * @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
108
+ * @returns The Build object (finished or still building if the timeout was reached)
98
109
  *
99
110
  * @example
100
111
  * ```javascript
@@ -113,6 +124,8 @@ export declare class BuildClient extends ResourceClient {
113
124
  /**
114
125
  * Returns a client for accessing the log of this Actor build.
115
126
  *
127
+ * A 404 from this client throws an `ApifyApiError`, since the build itself may be what is missing.
128
+ *
116
129
  * @returns A client for accessing the build's log
117
130
  * @see https://docs.apify.com/api/v2/actor-build-log-get
118
131
  *
@@ -129,13 +142,13 @@ export declare class BuildClient extends ResourceClient {
129
142
  /**
130
143
  * Options for getting a Build.
131
144
  */
132
- export interface BuildClientGetOptions {
145
+ export interface BuildClientGetOptions extends TimeoutOptions {
133
146
  waitForFinish?: number;
134
147
  }
135
148
  /**
136
149
  * Options for waiting for a Build to finish.
137
150
  */
138
- export interface BuildClientWaitForFinishOptions {
151
+ export interface BuildClientWaitForFinishOptions extends TimeoutOptions {
139
152
  /**
140
153
  * Maximum time to wait for the build to finish, in seconds.
141
154
  * If the limit is reached, the returned promise is resolved to a build object that will have
@@ -1,10 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
4
5
  import { parseArgument, parseResponse } from '../utils.js';
5
6
  import { LogClient } from './log.js';
6
- const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional() });
7
- const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional() });
7
+ const getOptionsSchema = z.strictObject({ waitForFinish: z.number().optional(), ...timeoutOptionsShape });
8
+ const waitForFinishOptionsSchema = z.strictObject({ waitSecs: z.number().optional(), ...timeoutOptionsShape });
8
9
  /**
9
10
  * Client for managing a specific Actor build.
10
11
  *
@@ -43,6 +44,8 @@ export class BuildClient extends ResourceClient {
43
44
  *
44
45
  * @param options - Get options
45
46
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the build to finish on the API side before returning. Default is 0 (returns immediately).
47
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
48
+ * when the API is asked to hold the response.
46
49
  * @returns The Build object, or `undefined` if it does not exist
47
50
  * @see https://docs.apify.com/api/v2/actor-build-get
48
51
  *
@@ -57,14 +60,16 @@ export class BuildClient extends ResourceClient {
57
60
  * ```
58
61
  */
59
62
  async get(options = {}) {
60
- const parsed = parseArgument(options, getOptionsSchema, 'BuildClientGetOptions');
61
- return this._get(schemas.Build(), parsed);
63
+ const { timeoutSecs, signal, ...params } = parseArgument(options, getOptionsSchema, 'BuildClientGetOptions');
64
+ return this.getResource(schemas.Build(), params, this.timeoutForWaitForFinish(timeoutSecs, 'short', params.waitForFinish), signal);
62
65
  }
63
66
  /**
64
67
  * Aborts the Actor build.
65
68
  *
66
69
  * Stops the build process immediately. The build will have an `ABORTED` status.
67
70
  *
71
+ * @param options - Request options
72
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
68
73
  * @returns The updated Build object with `ABORTED` status
69
74
  * @see https://docs.apify.com/api/v2/actor-build-abort-post
70
75
  *
@@ -73,35 +78,46 @@ export class BuildClient extends ResourceClient {
73
78
  * await client.build('build-id').abort();
74
79
  * ```
75
80
  */
76
- async abort() {
81
+ async abort(options = {}) {
82
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
77
83
  const response = await this.httpClient.call({
78
- url: this._url('abort'),
84
+ url: this.buildUrl('abort'),
79
85
  method: 'POST',
80
- params: this._params(),
86
+ params: this.buildParams(),
87
+ timeoutSecs,
88
+ signal,
81
89
  });
82
90
  return parseResponse(response, schemas.Build());
83
91
  }
84
92
  /**
85
93
  * Deletes the Actor build.
86
94
  *
95
+ * @param options - Request options
96
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
87
97
  * @see https://docs.apify.com/api/v2/actor-build-delete
88
98
  * @since Added in 2.8.1
89
99
  */
90
- async delete() {
91
- return this._delete();
100
+ async delete(options = {}) {
101
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
102
+ return this.deleteResource(timeoutSecs, signal);
92
103
  }
93
104
  /**
94
105
  * Retrieves the OpenAPI definition for the Actor build.
95
106
  *
107
+ * @param options - Request options
108
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
96
109
  * @returns The OpenAPI definition object.
97
110
  * @see https://docs.apify.com/api/v2/actor-build-openapi-json-get
98
111
  * @since Added in 2.11.2
99
112
  */
100
- async getOpenApiDefinition() {
113
+ async getOpenApiDefinition(options = {}) {
114
+ const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
101
115
  const response = await this.httpClient.call({
102
- url: this._url('openapi.json'),
116
+ url: this.buildUrl('openapi.json'),
103
117
  method: 'GET',
104
- params: this._params(),
118
+ params: this.buildParams(),
119
+ timeoutSecs,
120
+ signal,
105
121
  });
106
122
  return response.data;
107
123
  }
@@ -115,12 +131,14 @@ export class BuildClient extends ResourceClient {
115
131
  * Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
116
132
  * by polling the build status. It uses the `waitForFinish` parameter internally (max 60s per call)
117
133
  * and continuously polls until the build finishes or the timeout is reached.
134
+ * Rejects with a {@link NotFoundError} if the build keeps returning 404 for 3 seconds.
118
135
  *
119
136
  * This is useful when you need to immediately start a run after a build finishes.
120
137
  *
121
138
  * @param options - Wait options
122
139
  * @param options.waitSecs - Maximum time to wait for the build to finish, in seconds. If omitted, waits indefinitely.
123
- * @returns The Build object (finished or still building if timeout was reached)
140
+ * @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
141
+ * @returns The Build object (finished or still building if the timeout was reached)
124
142
  *
125
143
  * @example
126
144
  * ```javascript
@@ -137,11 +155,13 @@ export class BuildClient extends ResourceClient {
137
155
  */
138
156
  async waitForFinish(options = {}) {
139
157
  const parsed = parseArgument(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
140
- return this._waitForFinish(schemas.Build(), parsed);
158
+ return this.waitForJobFinish(schemas.Build(), parsed);
141
159
  }
142
160
  /**
143
161
  * Returns a client for accessing the log of this Actor build.
144
162
  *
163
+ * A 404 from this client throws an `ApifyApiError`, since the build itself may be what is missing.
164
+ *
145
165
  * @returns A client for accessing the build's log
146
166
  * @see https://docs.apify.com/api/v2/actor-build-log-get
147
167
  *
@@ -154,7 +174,7 @@ export class BuildClient extends ResourceClient {
154
174
  * @since Added in 2.9.0
155
175
  */
156
176
  log() {
157
- return new LogClient(this._subResourceOptions({
177
+ return new LogClient(this.subResourceOptions({
158
178
  resourcePath: 'log',
159
179
  }));
160
180
  }