apify-client 3.0.0-beta.5 → 3.0.0-beta.50

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 (115) hide show
  1. package/README.md +13 -3
  2. package/dist/apify_api_error.d.ts +62 -21
  3. package/dist/apify_api_error.js +96 -23
  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 -24
  8. package/dist/base/resource_client.d.ts +21 -8
  9. package/dist/base/resource_client.js +54 -26
  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 +610 -112
  17. package/dist/generated/schemas.d.ts +726 -703
  18. package/dist/generated/schemas.js +92 -85
  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 +333 -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 +19 -22
  40. package/dist/resource_clients/actor.d.ts +72 -32
  41. package/dist/resource_clients/actor.js +87 -56
  42. package/dist/resource_clients/actor_collection.d.ts +9 -5
  43. package/dist/resource_clients/actor_collection.js +11 -3
  44. package/dist/resource_clients/actor_env_var.d.ts +10 -3
  45. package/dist/resource_clients/actor_env_var.js +16 -6
  46. package/dist/resource_clients/actor_env_var_collection.d.ts +14 -18
  47. package/dist/resource_clients/actor_env_var_collection.js +17 -11
  48. package/dist/resource_clients/actor_version.d.ts +18 -3
  49. package/dist/resource_clients/actor_version.js +19 -9
  50. package/dist/resource_clients/actor_version_collection.d.ts +16 -17
  51. package/dist/resource_clients/actor_version_collection.js +19 -11
  52. package/dist/resource_clients/build.d.ts +18 -6
  53. package/dist/resource_clients/build.js +34 -15
  54. package/dist/resource_clients/build_collection.d.ts +3 -1
  55. package/dist/resource_clients/build_collection.js +4 -1
  56. package/dist/resource_clients/dataset.d.ts +51 -33
  57. package/dist/resource_clients/dataset.js +105 -80
  58. package/dist/resource_clients/dataset_collection.d.ts +6 -2
  59. package/dist/resource_clients/dataset_collection.js +13 -2
  60. package/dist/resource_clients/key_value_store.d.ts +58 -16
  61. package/dist/resource_clients/key_value_store.js +78 -40
  62. package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
  63. package/dist/resource_clients/key_value_store_collection.js +13 -2
  64. package/dist/resource_clients/log.d.ts +11 -19
  65. package/dist/resource_clients/log.js +64 -46
  66. package/dist/resource_clients/request_queue.d.ts +56 -26
  67. package/dist/resource_clients/request_queue.js +176 -103
  68. package/dist/resource_clients/request_queue_collection.d.ts +6 -2
  69. package/dist/resource_clients/request_queue_collection.js +9 -3
  70. package/dist/resource_clients/run.d.ts +108 -18
  71. package/dist/resource_clients/run.js +183 -43
  72. package/dist/resource_clients/run_collection.d.ts +3 -1
  73. package/dist/resource_clients/run_collection.js +4 -1
  74. package/dist/resource_clients/schedule.d.ts +14 -5
  75. package/dist/resource_clients/schedule.js +29 -21
  76. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  77. package/dist/resource_clients/schedule_collection.js +9 -3
  78. package/dist/resource_clients/store_collection.d.ts +3 -1
  79. package/dist/resource_clients/store_collection.js +4 -1
  80. package/dist/resource_clients/task.d.ts +33 -10
  81. package/dist/resource_clients/task.js +79 -46
  82. package/dist/resource_clients/task_collection.d.ts +6 -2
  83. package/dist/resource_clients/task_collection.js +9 -3
  84. package/dist/resource_clients/user.d.ts +17 -8
  85. package/dist/resource_clients/user.js +42 -38
  86. package/dist/resource_clients/webhook.d.ts +14 -5
  87. package/dist/resource_clients/webhook.js +30 -22
  88. package/dist/resource_clients/webhook_collection.d.ts +6 -2
  89. package/dist/resource_clients/webhook_collection.js +9 -3
  90. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  91. package/dist/resource_clients/webhook_dispatch.js +7 -2
  92. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  93. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  94. package/dist/runtime/node.d.ts +6 -0
  95. package/dist/runtime/node.js +49 -0
  96. package/dist/runtime/types.d.ts +52 -0
  97. package/dist/runtime/types.js +1 -0
  98. package/dist/runtime/web.d.ts +5 -0
  99. package/dist/runtime/web.js +18 -0
  100. package/dist/schemas.d.ts +1 -1
  101. package/dist/schemas.js +1 -1
  102. package/dist/statistics.d.ts +1 -6
  103. package/dist/statistics.js +2 -2
  104. package/dist/timeouts.d.ts +84 -0
  105. package/dist/timeouts.js +37 -0
  106. package/dist/timezones.d.ts +1 -1
  107. package/dist/utils.d.ts +81 -52
  108. package/dist/utils.js +201 -170
  109. package/dist/wait_for_resources.d.ts +8 -0
  110. package/dist/wait_for_resources.js +39 -0
  111. package/package.json +32 -29
  112. package/dist/http_client.d.ts +0 -88
  113. package/dist/http_client.js +0 -255
  114. package/dist/interceptors.d.ts +0 -19
  115. package/dist/interceptors.js +0 -105
@@ -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,6 +1,7 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
2
  import { ResourceClient } from '../base/resource_client.js';
3
3
  import type { ActorVersion, FinalActorVersion } 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
7
  export type { ActorEnvironmentVariable, ActorVersion, ActorVersionGitHubGist, ActorVersionGitRepo, ActorVersionSourceCode, ActorVersionSourceFile, ActorVersionSourceFiles, ActorVersionSourceFolder, ActorVersionTarball, BaseActorVersion, FinalActorVersion, } from '../models.js';
@@ -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<FinalActorVersion | 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<FinalActorVersion>;
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<ActorVersion>;
@@ -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,6 +1,7 @@
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';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { PaginatedList } from '../utils.js';
4
5
  import type { ActorVersion, FinalActorVersion } from './actor_version.js';
5
6
  /**
6
7
  * Client for managing the collection of Actor versions.
@@ -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<FinalActorVersion>;
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: ActorVersion, options?: TimeoutOptions): Promise<FinalActorVersion>;
69
68
  }
70
69
  export type ActorVersionListResult = Pick<PaginatedList<FinalActorVersion>, '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,6 +1,7 @@
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
6
  export type { Build, BuildMeta, BuildOptions, BuildStats, BuildUsage } from '../models.js';
6
7
  /**
@@ -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
  *
@@ -94,7 +103,8 @@ export declare class BuildClient extends ResourceClient {
94
103
  *
95
104
  * @param options - Wait options
96
105
  * @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)
106
+ * @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
107
+ * @returns The Build object (finished or still building if the timeout was reached)
98
108
  *
99
109
  * @example
100
110
  * ```javascript
@@ -113,6 +123,8 @@ export declare class BuildClient extends ResourceClient {
113
123
  /**
114
124
  * Returns a client for accessing the log of this Actor build.
115
125
  *
126
+ * A 404 from this client throws an `ApifyApiError`, since the build itself may be what is missing.
127
+ *
116
128
  * @returns A client for accessing the build's log
117
129
  * @see https://docs.apify.com/api/v2/actor-build-log-get
118
130
  *
@@ -129,13 +141,13 @@ export declare class BuildClient extends ResourceClient {
129
141
  /**
130
142
  * Options for getting a Build.
131
143
  */
132
- export interface BuildClientGetOptions {
144
+ export interface BuildClientGetOptions extends TimeoutOptions {
133
145
  waitForFinish?: number;
134
146
  }
135
147
  /**
136
148
  * Options for waiting for a Build to finish.
137
149
  */
138
- export interface BuildClientWaitForFinishOptions {
150
+ export interface BuildClientWaitForFinishOptions extends TimeoutOptions {
139
151
  /**
140
152
  * Maximum time to wait for the build to finish, in seconds.
141
153
  * 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
  }
@@ -120,7 +136,8 @@ export class BuildClient extends ResourceClient {
120
136
  *
121
137
  * @param options - Wait options
122
138
  * @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)
139
+ * @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
140
+ * @returns The Build object (finished or still building if the timeout was reached)
124
141
  *
125
142
  * @example
126
143
  * ```javascript
@@ -137,11 +154,13 @@ export class BuildClient extends ResourceClient {
137
154
  */
138
155
  async waitForFinish(options = {}) {
139
156
  const parsed = parseArgument(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
140
- return this._waitForFinish(schemas.Build(), parsed);
157
+ return this.waitForJobFinish(schemas.Build(), parsed);
141
158
  }
142
159
  /**
143
160
  * Returns a client for accessing the log of this Actor build.
144
161
  *
162
+ * A 404 from this client throws an `ApifyApiError`, since the build itself may be what is missing.
163
+ *
145
164
  * @returns A client for accessing the build's log
146
165
  * @see https://docs.apify.com/api/v2/actor-build-log-get
147
166
  *
@@ -154,7 +173,7 @@ export class BuildClient extends ResourceClient {
154
173
  * @since Added in 2.9.0
155
174
  */
156
175
  log() {
157
- return new LogClient(this._subResourceOptions({
176
+ return new LogClient(this.subResourceOptions({
158
177
  resourcePath: 'log',
159
178
  }));
160
179
  }
@@ -1,6 +1,7 @@
1
1
  import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import type { BuildCollectionClientListItem } from '../models.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
5
6
  export type { BuildCollectionClientListItem } from '../models.js';
6
7
  /**
@@ -46,12 +47,13 @@ export declare class BuildCollectionClient extends ResourceCollectionClient {
46
47
  * ```
47
48
  *
48
49
  * @param options - Pagination and sorting options.
50
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
49
51
  * @returns A paginated iterator of Actor builds.
50
52
  * @see https://docs.apify.com/api/v2/actor-builds-get
51
53
  */
52
54
  list(options?: BuildCollectionClientListOptions): PaginatedIterator<BuildCollectionClientListItem>;
53
55
  }
54
- export interface BuildCollectionClientListOptions extends PaginationOptions {
56
+ export interface BuildCollectionClientListOptions extends PaginationOptions, TimeoutOptions {
55
57
  desc?: boolean;
56
58
  }
57
59
  export type BuildCollectionClientListResult = PaginatedList<BuildCollectionClientListItem>;
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
3
  import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsShape } from '../timeouts.js';
4
5
  import { paginationOptionsShape, parseArgument } from '../utils.js';
5
6
  const listOptionsSchema = z.strictObject({
6
7
  ...paginationOptionsShape,
7
8
  desc: z.boolean().optional(),
9
+ ...timeoutOptionsShape,
8
10
  });
9
11
  /**
10
12
  * Client for managing the collection of Actor builds.
@@ -54,11 +56,12 @@ export class BuildCollectionClient extends ResourceCollectionClient {
54
56
  * ```
55
57
  *
56
58
  * @param options - Pagination and sorting options.
59
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
57
60
  * @returns A paginated iterator of Actor builds.
58
61
  * @see https://docs.apify.com/api/v2/actor-builds-get
59
62
  */
60
63
  list(options = {}) {
61
64
  const parsed = parseArgument(options, listOptionsSchema, 'BuildCollectionClientListOptions');
62
- return this._listPaginated(schemas.ListOfBuilds(), parsed);
65
+ return this.listResourcesPaginated(schemas.ListOfBuilds(), parsed, 'medium');
63
66
  }
64
67
  }