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

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 +12 -20
  65. package/dist/resource_clients/log.js +93 -58
  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
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { runtime } from '#runtime';
3
+ import { parseArgument } from '../utils.js';
4
+ /** Lowest valid brotli quality, the fastest with the least compression. */
5
+ const MIN_QUALITY = 0;
6
+ /** Highest valid brotli quality, the slowest with the best compression. */
7
+ const MAX_QUALITY = 11;
8
+ /** Middle of the range, where brotli already beats gzip at a comparable CPU cost. */
9
+ const DEFAULT_QUALITY = 6;
10
+ const optionsSchema = z.strictObject({
11
+ quality: z.int().min(MIN_QUALITY).max(MAX_QUALITY).default(DEFAULT_QUALITY),
12
+ });
13
+ /**
14
+ * Compresses request bodies using brotli.
15
+ *
16
+ * Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * import { ApifyClient, BrotliHttpCompressor } from 'apify-client';
21
+ *
22
+ * const client = new ApifyClient({ token: 'my-token', compression: new BrotliHttpCompressor({ quality: 11 }) });
23
+ * ```
24
+ */
25
+ export class BrotliHttpCompressor {
26
+ contentEncoding = 'br';
27
+ #quality;
28
+ /**
29
+ * @param options - Compressor options.
30
+ * @throws {ArgumentValidationError} If `quality` is out of the valid range.
31
+ */
32
+ constructor(options = {}) {
33
+ const { quality } = parseArgument(options, optionsSchema, 'BrotliHttpCompressorOptions');
34
+ this.#quality = quality;
35
+ }
36
+ async compress(data) {
37
+ return runtime.compress(data, { algorithm: 'br', quality: this.#quality });
38
+ }
39
+ }
@@ -0,0 +1,33 @@
1
+ import type { HttpCompressor } from './base.js';
2
+ /**
3
+ * Compresses request bodies using gzip.
4
+ *
5
+ * Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
6
+ *
7
+ * @example
8
+ * ```javascript
9
+ * import { ApifyClient, GzipHttpCompressor } from 'apify-client';
10
+ *
11
+ * const client = new ApifyClient({ token: 'my-token', compression: new GzipHttpCompressor({ quality: 1 }) });
12
+ * ```
13
+ */
14
+ export declare class GzipHttpCompressor implements HttpCompressor {
15
+ #private;
16
+ readonly contentEncoding = "gzip";
17
+ /**
18
+ * @param options - Compressor options.
19
+ * @throws {ArgumentValidationError} If `quality` is out of the valid range.
20
+ */
21
+ constructor(options?: GzipHttpCompressorOptions);
22
+ compress(data: Buffer): Promise<Buffer>;
23
+ }
24
+ /**
25
+ * Options for {@link GzipHttpCompressor}.
26
+ */
27
+ export interface GzipHttpCompressorOptions {
28
+ /**
29
+ * Compression level, from `1` (the fastest) to `9` (the best compression).
30
+ * @default 6
31
+ */
32
+ quality?: number;
33
+ }
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import { runtime } from '#runtime';
3
+ import { parseArgument } from '../utils.js';
4
+ /** Lowest valid gzip quality, the fastest with the least compression. */
5
+ const MIN_QUALITY = 1;
6
+ /** Highest valid gzip quality, the slowest with the best compression. */
7
+ const MAX_QUALITY = 9;
8
+ /** zlib's own default. The levels above it roughly double the CPU cost for about a percent fewer bytes. */
9
+ const DEFAULT_QUALITY = 6;
10
+ const optionsSchema = z.strictObject({
11
+ quality: z.int().min(MIN_QUALITY).max(MAX_QUALITY).default(DEFAULT_QUALITY),
12
+ });
13
+ /**
14
+ * Compresses request bodies using gzip.
15
+ *
16
+ * Built on the `node:zlib` module, so it works wherever the client runs on Node.js.
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * import { ApifyClient, GzipHttpCompressor } from 'apify-client';
21
+ *
22
+ * const client = new ApifyClient({ token: 'my-token', compression: new GzipHttpCompressor({ quality: 1 }) });
23
+ * ```
24
+ */
25
+ export class GzipHttpCompressor {
26
+ contentEncoding = 'gzip';
27
+ #quality;
28
+ /**
29
+ * @param options - Compressor options.
30
+ * @throws {ArgumentValidationError} If `quality` is out of the valid range.
31
+ */
32
+ constructor(options = {}) {
33
+ const { quality } = parseArgument(options, optionsSchema, 'GzipHttpCompressorOptions');
34
+ this.#quality = quality;
35
+ }
36
+ async compress(data) {
37
+ return runtime.compress(data, { algorithm: 'gzip', quality: this.#quality });
38
+ }
39
+ }
@@ -0,0 +1,6 @@
1
+ export type { HttpCompressor } from './base.js';
2
+ export { BrotliHttpCompressor } from './brotli.js';
3
+ export type { BrotliHttpCompressorOptions } from './brotli.js';
4
+ export { GzipHttpCompressor } from './gzip.js';
5
+ export type { GzipHttpCompressorOptions } from './gzip.js';
6
+ export type { HttpCompressionAlgorithm } from './resolve.js';
@@ -0,0 +1,2 @@
1
+ export { BrotliHttpCompressor } from './brotli.js';
2
+ export { GzipHttpCompressor } from './gzip.js';
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import type { HttpCompressor } from './base.js';
3
+ /**
4
+ * Compression algorithms the `compression` option of {@link ApifyClient} accepts by name. Each name selects the
5
+ * matching built-in compressor with its default quality: `'brotli'` a {@link BrotliHttpCompressor}, `'gzip'` a
6
+ * {@link GzipHttpCompressor}. The Apify API also accepts `deflate` and `identity`, which a custom
7
+ * {@link HttpCompressor} covers.
8
+ */
9
+ export type HttpCompressionAlgorithm = 'brotli' | 'gzip';
10
+ /**
11
+ * Schema of the `compression` option: an algorithm name or an {@link HttpCompressor}.
12
+ * @internal
13
+ */
14
+ export declare const compressionSchema: z.ZodUnion<readonly [z.ZodEnum<{
15
+ brotli: "brotli";
16
+ gzip: "gzip";
17
+ }>, z.ZodCustom<HttpCompressor, HttpCompressor>]>;
18
+ /**
19
+ * Turns the `compression` option into a ready-to-use {@link HttpCompressor}: a name into the matching built-in
20
+ * compressor with its default quality, a compressor into itself.
21
+ * @internal
22
+ */
23
+ export declare function resolveCompressor(compression: HttpCompressionAlgorithm | HttpCompressor): HttpCompressor;
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { httpCompressorSchema } from './base.js';
3
+ import { BrotliHttpCompressor } from './brotli.js';
4
+ import { GzipHttpCompressor } from './gzip.js';
5
+ /**
6
+ * Schema of the `compression` option: an algorithm name or an {@link HttpCompressor}.
7
+ * @internal
8
+ */
9
+ export const compressionSchema = z.union([
10
+ z.enum(['brotli', 'gzip']),
11
+ httpCompressorSchema,
12
+ ]);
13
+ /**
14
+ * Turns the `compression` option into a ready-to-use {@link HttpCompressor}: a name into the matching built-in
15
+ * compressor with its default quality, a compressor into itself.
16
+ * @internal
17
+ */
18
+ export function resolveCompressor(compression) {
19
+ if (typeof compression !== 'string')
20
+ return compression;
21
+ switch (compression) {
22
+ case 'gzip':
23
+ return new GzipHttpCompressor();
24
+ case 'brotli':
25
+ return new BrotliHttpCompressor();
26
+ }
27
+ }
package/dist/index.d.ts CHANGED
@@ -29,5 +29,8 @@ export * from './resource_clients/webhook_dispatch_collection.js';
29
29
  export * from './apify_api_error.js';
30
30
  export { ArgumentValidationError } from '@apify/validations';
31
31
  export * from './response_validation_error.js';
32
- export { InvalidResponseBodyError } from './interceptors.js';
32
+ export * from './invalid_response_body_error.js';
33
+ export * from './http_clients/index.js';
34
+ export * from './http_compressors/index.js';
33
35
  export type { PaginatedList, Dictionary } from './utils.js';
36
+ export type { Timeout, TimeoutOptions, TimeoutTier } from './timeouts.js';
package/dist/index.js CHANGED
@@ -29,4 +29,6 @@ export * from './resource_clients/webhook_dispatch_collection.js';
29
29
  export * from './apify_api_error.js';
30
30
  export { ArgumentValidationError } from '@apify/validations';
31
31
  export * from './response_validation_error.js';
32
- export { InvalidResponseBodyError } from './interceptors.js';
32
+ export * from './invalid_response_body_error.js';
33
+ export * from './http_clients/index.js';
34
+ export * from './http_compressors/index.js';
@@ -0,0 +1,13 @@
1
+ import type { HttpResponse } from './http_clients/base.js';
2
+ /**
3
+ * Thrown when a response body does not parse as its content type claims, typically a JSON document cut short by a
4
+ * connection dropped mid-response. The client retries such requests, so the error surfaces once the retries are
5
+ * exhausted.
6
+ */
7
+ export declare class InvalidResponseBodyError extends Error {
8
+ code: string;
9
+ /** The response whose body did not parse, with the body as the transport returned it. */
10
+ response: HttpResponse;
11
+ cause: Error;
12
+ constructor(response: HttpResponse, cause: Error);
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Thrown when a response body does not parse as its content type claims, typically a JSON document cut short by a
3
+ * connection dropped mid-response. The client retries such requests, so the error surfaces once the retries are
4
+ * exhausted.
5
+ */
6
+ export class InvalidResponseBodyError extends Error {
7
+ code;
8
+ /** The response whose body did not parse, with the body as the transport returned it. */
9
+ response;
10
+ constructor(response, cause) {
11
+ super(`Response body could not be parsed.\nCause:${cause.message}`);
12
+ this.name = this.constructor.name;
13
+ this.code = 'invalid-response-body';
14
+ this.response = response;
15
+ this.cause = cause;
16
+ }
17
+ }
package/dist/models.d.ts CHANGED
@@ -48,6 +48,12 @@ export declare enum WebhookDispatchStatus {
48
48
  Succeeded = "SUCCEEDED",
49
49
  Failed = "FAILED"
50
50
  }
51
+ /**
52
+ * Machine-readable type of an error returned by the Apify API, carried by `ApifyApiError.type`.
53
+ *
54
+ * Declared here, next to the other spec-derived types, and re-exported from `./apify_api_error`.
55
+ */
56
+ export type ApifyApiErrorType = Schemas['ErrorType'];
51
57
  /**
52
58
  * Fields the API returns on a dataset that the OpenAPI spec does not describe yet.
53
59
  *
@@ -213,7 +219,7 @@ export interface ActorVersionRePointed {
213
219
  envVars?: ActorEnvironmentVariable[] | null;
214
220
  }
215
221
  export interface ActorVersionClientNarrowings {
216
- sourceType: ActorSourceType;
222
+ sourceType: `${ActorSourceType}`;
217
223
  }
218
224
  /**
219
225
  * Fields every Actor version carries, whatever its source type.
@@ -222,26 +228,26 @@ export interface ActorVersionClientNarrowings {
222
228
  * keeps a union discriminated on `sourceType` instead, because that narrows the source location down
223
229
  * to the single field which applies -- so the four are dropped here and reinstated per variant.
224
230
  */
225
- export interface BaseActorVersion<SourceType extends ActorSourceType> extends Omit<GeneratedVersion, keyof ActorVersionClientNarrowings | keyof ActorVersionRePointed | ActorVersionSourceLocation>, ActorVersionRePointed {
231
+ export interface BaseActorVersion<SourceType extends `${ActorSourceType}`> extends Omit<GeneratedVersion, keyof ActorVersionClientNarrowings | keyof ActorVersionRePointed | ActorVersionSourceLocation>, ActorVersionRePointed {
226
232
  sourceType: SourceType;
227
233
  }
228
234
  /**
229
235
  * An Actor version whose source code is stored on the Apify platform.
230
236
  * @since Added in 2.6.1
231
237
  */
232
- export interface ActorVersionSourceFiles extends BaseActorVersion<ActorSourceType.SourceFiles> {
238
+ export interface ActorVersionSourceFiles extends BaseActorVersion<`${ActorSourceType.SourceFiles}`> {
233
239
  sourceFiles: (ActorVersionSourceFile | ActorVersionSourceFolder)[];
234
240
  }
235
241
  /** An Actor version built from a Git repository. */
236
- export interface ActorVersionGitRepo extends BaseActorVersion<ActorSourceType.GitRepo> {
242
+ export interface ActorVersionGitRepo extends BaseActorVersion<`${ActorSourceType.GitRepo}`> {
237
243
  gitRepoUrl: NonNullable<GeneratedVersion['gitRepoUrl']>;
238
244
  }
239
245
  /** An Actor version built from a downloadable tarball or ZIP archive. */
240
- export interface ActorVersionTarball extends BaseActorVersion<ActorSourceType.Tarball> {
246
+ export interface ActorVersionTarball extends BaseActorVersion<`${ActorSourceType.Tarball}`> {
241
247
  tarballUrl: NonNullable<GeneratedVersion['tarballUrl']>;
242
248
  }
243
249
  /** An Actor version built from a GitHub Gist. */
244
- export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType.GitHubGist> {
250
+ export interface ActorVersionGitHubGist extends BaseActorVersion<`${ActorSourceType.GitHubGist}`> {
245
251
  gitHubGistUrl: NonNullable<GeneratedVersion['gitHubGistUrl']>;
246
252
  }
247
253
  /**
@@ -250,7 +256,7 @@ export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType
250
256
  * It carries no source location of its own, so it adds nothing to `BaseActorVersion`; the variant
251
257
  * exists so that `SOURCE_CODE`, which both the spec and `@apify/consts` list, is representable.
252
258
  */
253
- export interface ActorVersionSourceCode extends BaseActorVersion<ActorSourceType.SourceCode> {
259
+ export interface ActorVersionSourceCode extends BaseActorVersion<`${ActorSourceType.SourceCode}`> {
254
260
  }
255
261
  /** A version of an Actor, discriminated on where its source code comes from. */
256
262
  export type ActorVersion = ActorVersionSourceFiles | ActorVersionGitRepo | ActorVersionTarball | ActorVersionGitHubGist | ActorVersionSourceCode;
@@ -583,14 +589,6 @@ export interface TaskOptions extends GeneratedTaskOptions {
583
589
  */
584
590
  export interface TaskPublicConfig extends GeneratedTaskPublicConfig {
585
591
  }
586
- /**
587
- * Fields the API returns on a task that the OpenAPI spec does not describe yet.
588
- *
589
- * TODO: Remove once the spec covers it.
590
- */
591
- export interface TaskSpecGaps {
592
- description?: string;
593
- }
594
592
  export interface TaskRePointed {
595
593
  stats?: TaskStats | null;
596
594
  options?: TaskOptions | null;
@@ -604,7 +602,7 @@ export interface TaskRePointed {
604
602
  * Tasks are saved Actor configurations with input and settings that can be executed
605
603
  * repeatedly without having to specify the full input each time.
606
604
  */
607
- export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed>, TaskRePointed, TaskSpecGaps {
605
+ export interface Task extends Omit<Schemas['Task'], keyof TaskRePointed>, TaskRePointed {
608
606
  }
609
607
  export interface TaskListRePointed {
610
608
  stats?: TaskStats | null;
@@ -612,7 +610,7 @@ export interface TaskListRePointed {
612
610
  /**
613
611
  * Fields the API returns on a listed task that the OpenAPI spec does not describe yet.
614
612
  *
615
- * `description` is deliberately not here, although `TaskSpecGaps` claims it on the full resource: the
613
+ * `description` is deliberately not here, although the spec has it on the full `Task` resource: the
616
614
  * list endpoint publishes a smaller set of fields, and that is one of the fields it leaves out.
617
615
  *
618
616
  * TODO: Remove once the spec covers it.
@@ -733,7 +731,7 @@ export interface ScheduledActorRunInput extends GeneratedScheduleActionRunInput
733
731
  export interface ScheduledActorRunOptions extends GeneratedTaskOptions {
734
732
  }
735
733
  export interface ScheduleActionRunActorRePointed {
736
- type: ScheduleActions.RunActor;
734
+ type: `${ScheduleActions.RunActor}`;
737
735
  runInput?: ScheduledActorRunInput | null;
738
736
  runOptions?: ScheduledActorRunOptions | null;
739
737
  }
@@ -741,7 +739,7 @@ export interface ScheduleActionRunActorRePointed {
741
739
  export interface ScheduleActionRunActor extends Omit<Schemas['ScheduleActionRunActor'], keyof ScheduleActionRunActorRePointed>, ScheduleActionRunActorRePointed {
742
740
  }
743
741
  export interface ScheduleActionRunActorTaskRePointed {
744
- type: ScheduleActions.RunActorTask;
742
+ type: `${ScheduleActions.RunActorTask}`;
745
743
  }
746
744
  /** Scheduled action to run an Actor task. */
747
745
  export interface ScheduleActionRunActorTask extends Omit<Schemas['ScheduleActionRunActorTask'], keyof ScheduleActionRunActorTaskRePointed>, ScheduleActionRunActorTaskRePointed {
@@ -929,15 +927,14 @@ export interface RequestQueueStats extends GeneratedRequestQueueStats {
929
927
  /**
930
928
  * Fields the API returns on a request queue that the OpenAPI spec does not describe yet.
931
929
  *
932
- * The spec does carry `username` and `expireAt` on `RequestQueueShort`, the listing shape, and simply
933
- * omits both from the full `RequestQueue` schema. `title` is absent from either.
930
+ * The spec does carry `username` on `RequestQueueShort`, the listing shape, and simply omits it from the
931
+ * full `RequestQueue` schema. `title` is absent from either.
934
932
  *
935
933
  * TODO: Remove once the spec covers them.
936
934
  */
937
935
  export interface RequestQueueSpecGaps {
938
936
  title?: string;
939
937
  username?: string;
940
- expireAt?: Date;
941
938
  }
942
939
  export interface RequestQueueRePointed {
943
940
  stats?: RequestQueueStats;
@@ -3,6 +3,8 @@ import { Log } from '@apify/log';
3
3
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
4
4
  import { ResourceClient } from '../base/resource_client.js';
5
5
  import type { Actor, ActorRun } from '../models.js';
6
+ import type { TimeoutOptions } from '../timeouts.js';
7
+ import type { Dictionary } from '../utils.js';
6
8
  import { ActorVersionClient } from './actor_version.js';
7
9
  import { ActorVersionCollectionClient } from './actor_version_collection.js';
8
10
  import type { Build, BuildClientGetOptions } from './build.js';
@@ -42,24 +44,30 @@ export declare class ActorClient extends ResourceClient {
42
44
  /**
43
45
  * Gets the Actor object from the Apify API.
44
46
  *
47
+ * @param options - Request options
48
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
45
49
  * @returns The Actor object, or `undefined` if it does not exist
46
50
  * @see https://docs.apify.com/api/v2/act-get
47
51
  */
48
- get(): Promise<Actor | undefined>;
52
+ get(options?: TimeoutOptions): Promise<Actor | undefined>;
49
53
  /**
50
54
  * Updates the Actor with specified fields.
51
55
  *
52
56
  * @param newFields - Fields to update in the Actor
57
+ * @param options - Request options
58
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
53
59
  * @returns The updated Actor object
54
60
  * @see https://docs.apify.com/api/v2/act-put
55
61
  */
56
- update(newFields: ActorUpdateOptions): Promise<Actor>;
62
+ update(newFields: ActorUpdateOptions, options?: TimeoutOptions): Promise<Actor>;
57
63
  /**
58
64
  * Deletes the Actor.
59
65
  *
66
+ * @param options - Request options
67
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
60
68
  * @see https://docs.apify.com/api/v2/act-delete
61
69
  */
62
- delete(): Promise<void>;
70
+ delete(options?: TimeoutOptions): Promise<void>;
63
71
  /**
64
72
  * Starts the Actor and immediately returns the Run object.
65
73
  *
@@ -67,17 +75,20 @@ export declare class ActorClient extends ResourceClient {
67
75
  * asynchronously and this method returns immediately without waiting for completion.
68
76
  * Use the {@link call} method if you want to wait for the Actor to finish.
69
77
  *
70
- * @param input - Input for the Actor. Can be any JSON-serializable value (object, array, string, number).
71
- * If `contentType` is specified in options, input should be a string or Buffer.
78
+ * @param input - Input for the Actor: an object or array serialized to JSON, or raw bytes sent as they are.
79
+ * Omit it to run the Actor without input.
72
80
  * @param options - Run configuration options
73
81
  * @param options.build - Tag or number of the build to run (e.g., `'beta'` or `'1.2.345'`). If not provided, uses the default build.
74
82
  * @param options.memory - Memory in megabytes allocated for the run. If not provided, uses the Actor's default memory setting.
75
- * @param options.timeout - Timeout for the run in seconds. Zero means no timeout. If not provided, uses the Actor's default timeout.
83
+ * @param options.runTimeoutSecs - Timeout for the run in seconds. Zero means no timeout. If not provided, uses the Actor's default timeout.
76
84
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish on the API side before returning. Default is 0 (returns immediately).
77
85
  * @param options.webhooks - Webhooks to trigger when the Actor run reaches a specific state (e.g., `SUCCEEDED`, `FAILED`).
78
86
  * @param options.maxItems - Maximum number of dataset items that will be charged (only for pay-per-result Actors).
79
87
  * @param options.maxTotalChargeUsd - Maximum cost in USD (only for pay-per-event Actors).
80
- * @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
88
+ * @param options.waitForResources - Retry the start while the account lacks the memory or a concurrent-run slot for
89
+ * the run. `true` retries until the run starts, a number stops retrying after that many seconds.
90
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
91
+ * when the API is asked to hold the response.
81
92
  * @returns The Actor run object with status, usage, and storage IDs
82
93
  * @see https://docs.apify.com/api/v2/act-runs-post
83
94
  *
@@ -90,11 +101,11 @@ export declare class ActorClient extends ResourceClient {
90
101
  * // Start Actor with specific build and memory
91
102
  * const run = await client.actor('my-actor').start(
92
103
  * { url: 'https://example.com' },
93
- * { build: '0.1.2', memory: 512, timeout: 300 }
104
+ * { build: '0.1.2', memory: 512, runTimeoutSecs: 300 }
94
105
  * );
95
106
  * ```
96
107
  */
97
- start(input?: unknown, options?: ActorStartOptions): Promise<ActorRun>;
108
+ start(input?: ActorInput, options?: ActorStartOptions): Promise<ActorRun>;
98
109
  /**
99
110
  * Starts the Actor and waits for it to finish before returning the Run object.
100
111
  *
@@ -102,14 +113,18 @@ export declare class ActorClient extends ResourceClient {
102
113
  * by polling the run status. It optionally streams logs to the console or a custom Log instance.
103
114
  * By default, it waits indefinitely unless the `waitSecs` option is provided.
104
115
  *
105
- * @param input - Input for the Actor. Can be any JSON-serializable value (object, array, string, number).
106
- * If `contentType` is specified in options, input should be a string or Buffer.
116
+ * @param input - Input for the Actor: an object or array serialized to JSON, or raw bytes sent as they are.
117
+ * Omit it to run the Actor without input.
107
118
  * @param options - Run configuration options (extends all options from {@link start})
108
119
  * @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If omitted, waits indefinitely.
109
120
  * @param options.log - Log instance for streaming run logs. Use `'default'` for console output, `null` to disable logging, or provide a custom Log instance.
110
121
  * @param options.build - Tag or number of the build to run (e.g., `'beta'` or `'1.2.345'`).
111
122
  * @param options.memory - Memory in megabytes allocated for the run.
112
- * @param options.timeout - Maximum run duration in seconds.
123
+ * @param options.runTimeoutSecs - Maximum run duration in seconds.
124
+ * @param options.waitForResources - Retry the start while the account lacks the memory or a concurrent-run slot for
125
+ * the run. `true` retries until the run starts, a number stops retrying after that many seconds. The time spent
126
+ * retrying doesn't count toward `waitSecs`.
127
+ * @param options.timeoutSecs - Timeout for each API request, the start and every poll alike. Default is `'noTimeout'`.
113
128
  * @returns The finished Actor run object with final status (`SUCCEEDED`, `FAILED`, `ABORTED`, or `TIMED-OUT`)
114
129
  * @see https://docs.apify.com/api/v2/act-runs-post
115
130
  *
@@ -132,7 +147,7 @@ export declare class ActorClient extends ResourceClient {
132
147
  * const run = await client.actor('my-actor').call({ url: 'https://example.com' }, { log });
133
148
  * ```
134
149
  */
135
- call(input?: unknown, options?: ActorCallOptions): Promise<ActorRun>;
150
+ call(input?: ActorInput, options?: ActorCallOptions): Promise<ActorRun>;
136
151
  /**
137
152
  * Validates the provided input for the Actor against its input schema.
138
153
  *
@@ -141,13 +156,12 @@ export declare class ActorClient extends ResourceClient {
141
156
  * invalid, the API responds with an error that is thrown as an `ApifyApiError` describing the
142
157
  * validation problem.
143
158
  *
144
- * @param input - Input to validate against the Actor's input schema. Can be any JSON-serializable
145
- * value (object, array, string, number). If `contentType` is specified in options,
146
- * input should be a string or Buffer.
159
+ * @param input - Input to validate against the Actor's input schema: an object or array serialized to JSON, or
160
+ * raw bytes sent as they are.
147
161
  * @param options - Validation options
148
162
  * @param options.build - Tag or number of the build whose input schema the input is validated against
149
163
  * (e.g., `'latest'` or `'1.2.345'`). If not provided, uses the default build.
150
- * @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
164
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
151
165
  * @returns `true` if the input is valid. Invalid input causes the underlying API call to throw an `ApifyApiError`.
152
166
  * @see https://docs.apify.com/api/v2/act-validate-input-post
153
167
  *
@@ -164,7 +178,7 @@ export declare class ActorClient extends ResourceClient {
164
178
  * ```
165
179
  * @since Added in 2.24.0
166
180
  */
167
- validateInput(input?: unknown, options?: ActorValidateInputOptions): Promise<boolean>;
181
+ validateInput(input?: ActorInput, options?: ActorValidateInputOptions): Promise<boolean>;
168
182
  /**
169
183
  * Builds the Actor.
170
184
  *
@@ -177,6 +191,8 @@ export declare class ActorClient extends ResourceClient {
177
191
  * @param options.tag - Tag to be applied to the build (e.g., `'latest'`, `'beta'`). Existing tag with the same name will be replaced.
178
192
  * @param options.useCache - If `false`, Docker build cache will be ignored. Default is `true`.
179
193
  * @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).
194
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`, extended to cover `waitForFinish`
195
+ * when the API is asked to hold the response.
180
196
  * @returns The Build object with status and build details
181
197
  * @see https://docs.apify.com/api/v2/act-builds-post
182
198
  *
@@ -204,6 +220,8 @@ export declare class ActorClient extends ResourceClient {
204
220
  *
205
221
  * @param options - Options for getting the default build
206
222
  * @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).
223
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
224
+ * when the API is asked to hold the response.
207
225
  * @returns A client for the default build
208
226
  * @see https://docs.apify.com/api/v2/act-build-default-get
209
227
  *
@@ -279,18 +297,27 @@ export declare class ActorClient extends ResourceClient {
279
297
  /**
280
298
  * Fields that can be updated when modifying an Actor.
281
299
  */
282
- export type ActorUpdateOptions = Partial<Pick<Actor, 'name' | 'description' | 'isPublic' | 'isDeprecated' | 'seoTitle' | 'seoDescription' | 'title' | 'restartOnError' | 'versions' | 'categories' | 'defaultRunOptions' | 'actorStandby' | 'actorPermissionLevel' | 'taggedBuilds'>>;
283
- export interface ActorStartOptions {
300
+ export type ActorUpdateOptions = Partial<Pick<Actor, 'name' | 'description' | 'isPublic' | 'isDeprecated' | 'seoTitle' | 'seoDescription' | 'title' | 'versions' | 'categories' | 'defaultRunOptions' | 'actorStandby' | 'actorPermissionLevel' | 'taggedBuilds'>>;
301
+ /**
302
+ * Input for an Actor run, as taken by {@link ActorClient.start}, {@link ActorClient.call},
303
+ * {@link ActorClient.validateInput} and {@link RunClient.metamorph}.
304
+ *
305
+ * A plain object or an array of plain objects, serialized into the request body, or raw bytes
306
+ * (a `Uint8Array` such as a `Buffer`, or an `ArrayBuffer`) sent as they are, typically with a
307
+ * `contentType`. An input typed as an `interface` or a class needs a spread (`{ ...input }`), or for
308
+ * an interface a `type` alias, to compile.
309
+ */
310
+ export type ActorInput = Dictionary | readonly Dictionary[] | Uint8Array | ArrayBuffer;
311
+ export interface ActorStartOptions extends TimeoutOptions {
284
312
  /**
285
313
  * Tag or number of the Actor build to run (e.g. `beta` or `1.2.345`).
286
314
  * If not provided, the run uses build tag or number from the default Actor run configuration (typically `latest`).
287
315
  */
288
316
  build?: string;
289
317
  /**
290
- * Content type for the `input`. If not specified,
291
- * `input` is expected to be an object that will be stringified to JSON and content type set to
292
- * `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
293
- * `String` or `Buffer`.
318
+ * Content type of the request body, which becomes the content type of the run's `INPUT` record.
319
+ * Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
320
+ * with `application/x-www-form-urlencoded` form-encodes it instead.
294
321
  */
295
322
  contentType?: string;
296
323
  /**
@@ -300,9 +327,9 @@ export interface ActorStartOptions {
300
327
  memory?: number;
301
328
  /**
302
329
  * Timeout for the Actor run in seconds. Zero value means there is no timeout.
303
- * If not provided, the run uses timeout of the default Actor run configuration.
330
+ * If not provided, the run uses the timeout of the default Actor run configuration.
304
331
  */
305
- timeout?: number;
332
+ runTimeoutSecs?: number;
306
333
  /**
307
334
  * Maximum time to wait for the Actor run to finish, in seconds.
308
335
  * If the limit is reached, the returned promise is resolved to a run object that will have
@@ -345,6 +372,20 @@ export interface ActorStartOptions {
345
372
  * @since Added in 2.17.0
346
373
  */
347
374
  forcePermissionLevel?: ACTOR_PERMISSION_LEVEL;
375
+ /**
376
+ * Retry the start while the account lacks the resources for the run, that is while the API rejects it with an
377
+ * `ApifyApiError` of type `actor-memory-limit-exceeded` or `concurrent-runs-limit-exceeded`. Both clear as
378
+ * other runs or builds finish. The start is retried every 10 seconds, and any other error is thrown right away.
379
+ *
380
+ * `true` retries until the run starts. A number stops retrying after that many seconds and throws the last
381
+ * error. Omitted or `false`, the first rejection is thrown.
382
+ *
383
+ * A run that requests more memory than the whole memory limit of the account is rejected with
384
+ * `actor-memory-limit-exceeded` as well and never starts, so `true` retries it forever.
385
+ *
386
+ * A `Readable` input can't be sent twice, so its start is never retried and the first rejection is thrown.
387
+ */
388
+ waitForResources?: boolean | number;
348
389
  }
349
390
  /**
350
391
  * Options for calling an Actor and waiting for it to finish.
@@ -369,24 +410,23 @@ export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish
369
410
  * Options for validating an Actor input.
370
411
  * @since Added in 2.24.0
371
412
  */
372
- export interface ActorValidateInputOptions {
413
+ export interface ActorValidateInputOptions extends TimeoutOptions {
373
414
  /**
374
415
  * Tag or number of the Actor build whose input schema the input is validated against
375
416
  * (e.g. `beta` or `1.2.345`). If not provided, the default build is used.
376
417
  */
377
418
  build?: string;
378
419
  /**
379
- * Content type for the `input`. If not specified,
380
- * `input` is expected to be an object that will be stringified to JSON and content type set to
381
- * `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
382
- * `String` or `Buffer`.
420
+ * Content type of the request body carrying the input to validate. Without it, the input is
421
+ * serialized to JSON and sent as `application/json`. Pairing an object with
422
+ * `application/x-www-form-urlencoded` form-encodes it instead.
383
423
  */
384
424
  contentType?: string;
385
425
  }
386
426
  /**
387
427
  * Options for building an Actor.
388
428
  */
389
- export interface ActorBuildOptions {
429
+ export interface ActorBuildOptions extends TimeoutOptions {
390
430
  betaPackages?: boolean;
391
431
  tag?: string;
392
432
  useCache?: boolean;