apify-client 3.0.0-beta.1 → 3.0.0-beta.100

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 (131) hide show
  1. package/README.md +21 -5
  2. package/dist/apify_api_error.d.ts +64 -22
  3. package/dist/apify_api_error.js +100 -30
  4. package/dist/apify_client.d.ts +150 -35
  5. package/dist/apify_client.js +198 -118
  6. package/dist/apify_client_error.d.ts +10 -0
  7. package/dist/apify_client_error.js +10 -0
  8. package/dist/base/api_client.d.ts +9 -9
  9. package/dist/base/api_client.js +41 -45
  10. package/dist/base/resource_client.d.ts +24 -10
  11. package/dist/base/resource_client.js +78 -48
  12. package/dist/base/resource_collection_client.d.ts +15 -6
  13. package/dist/base/resource_collection_client.js +40 -21
  14. package/dist/body_parser.d.ts +3 -4
  15. package/dist/body_parser.js +20 -32
  16. package/dist/bundle.js +47 -52
  17. package/dist/bundle.js.map +1 -1
  18. package/dist/generated/api.d.ts +3363 -1185
  19. package/dist/generated/api.js +1 -2
  20. package/dist/generated/schemas.d.ts +8146 -0
  21. package/dist/generated/schemas.js +1866 -0
  22. package/dist/http_clients/axios.d.ts +61 -0
  23. package/dist/http_clients/axios.js +119 -0
  24. package/dist/http_clients/base.d.ts +391 -0
  25. package/dist/http_clients/base.js +650 -0
  26. package/dist/http_clients/index.d.ts +4 -0
  27. package/dist/http_clients/index.js +2 -0
  28. package/dist/http_compressors/base.d.ts +40 -0
  29. package/dist/http_compressors/base.js +9 -0
  30. package/dist/http_compressors/brotli.d.ts +33 -0
  31. package/dist/http_compressors/brotli.js +39 -0
  32. package/dist/http_compressors/gzip.d.ts +33 -0
  33. package/dist/http_compressors/gzip.js +39 -0
  34. package/dist/http_compressors/index.d.ts +8 -0
  35. package/dist/http_compressors/index.js +3 -0
  36. package/dist/http_compressors/resolve.d.ts +24 -0
  37. package/dist/http_compressors/resolve.js +30 -0
  38. package/dist/http_compressors/zstd.d.ts +34 -0
  39. package/dist/http_compressors/zstd.js +43 -0
  40. package/dist/index.d.ts +38 -32
  41. package/dist/index.js +36 -36
  42. package/dist/invalid_response_body_error.d.ts +14 -0
  43. package/dist/invalid_response_body_error.js +18 -0
  44. package/dist/lazy_schema.d.ts +8 -0
  45. package/dist/lazy_schema.js +11 -0
  46. package/dist/models.d.ts +196 -278
  47. package/dist/models.js +14 -15
  48. package/dist/resource_clients/actor.d.ts +115 -45
  49. package/dist/resource_clients/actor.js +187 -116
  50. package/dist/resource_clients/actor_collection.d.ts +21 -17
  51. package/dist/resource_clients/actor_collection.js +26 -21
  52. package/dist/resource_clients/actor_env_var.d.ts +13 -6
  53. package/dist/resource_clients/actor_env_var.js +21 -14
  54. package/dist/resource_clients/actor_env_var_collection.d.ts +18 -22
  55. package/dist/resource_clients/actor_env_var_collection.js +23 -20
  56. package/dist/resource_clients/actor_server.d.ts +149 -0
  57. package/dist/resource_clients/actor_server.js +199 -0
  58. package/dist/resource_clients/actor_version.d.ts +30 -10
  59. package/dist/resource_clients/actor_version.js +29 -23
  60. package/dist/resource_clients/actor_version_collection.d.ts +20 -21
  61. package/dist/resource_clients/actor_version_collection.js +25 -20
  62. package/dist/resource_clients/build.d.ts +24 -11
  63. package/dist/resource_clients/build.js +43 -26
  64. package/dist/resource_clients/build_collection.d.ts +10 -8
  65. package/dist/resource_clients/build_collection.js +13 -13
  66. package/dist/resource_clients/dataset.d.ts +87 -40
  67. package/dist/resource_clients/dataset.js +159 -175
  68. package/dist/resource_clients/dataset_collection.d.ts +13 -9
  69. package/dist/resource_clients/dataset_collection.js +29 -21
  70. package/dist/resource_clients/key_value_store.d.ts +110 -28
  71. package/dist/resource_clients/key_value_store.js +177 -99
  72. package/dist/resource_clients/key_value_store_collection.d.ts +13 -9
  73. package/dist/resource_clients/key_value_store_collection.js +29 -21
  74. package/dist/resource_clients/log.d.ts +42 -23
  75. package/dist/resource_clients/log.js +156 -85
  76. package/dist/resource_clients/request_queue.d.ts +77 -38
  77. package/dist/resource_clients/request_queue.js +251 -172
  78. package/dist/resource_clients/request_queue_collection.d.ts +12 -8
  79. package/dist/resource_clients/request_queue_collection.js +23 -20
  80. package/dist/resource_clients/run.d.ts +134 -34
  81. package/dist/resource_clients/run.js +225 -84
  82. package/dist/resource_clients/run_collection.d.ts +8 -6
  83. package/dist/resource_clients/run_collection.js +18 -18
  84. package/dist/resource_clients/schedule.d.ts +20 -11
  85. package/dist/resource_clients/schedule.js +36 -30
  86. package/dist/resource_clients/schedule_collection.d.ts +10 -6
  87. package/dist/resource_clients/schedule_collection.js +20 -17
  88. package/dist/resource_clients/store_collection.d.ts +9 -7
  89. package/dist/resource_clients/store_collection.js +18 -18
  90. package/dist/resource_clients/task.d.ts +44 -21
  91. package/dist/resource_clients/task.js +116 -86
  92. package/dist/resource_clients/task_collection.d.ts +13 -9
  93. package/dist/resource_clients/task_collection.js +19 -16
  94. package/dist/resource_clients/user.d.ts +22 -13
  95. package/dist/resource_clients/user.js +46 -47
  96. package/dist/resource_clients/webhook.d.ts +21 -12
  97. package/dist/resource_clients/webhook.js +35 -30
  98. package/dist/resource_clients/webhook_collection.d.ts +11 -7
  99. package/dist/resource_clients/webhook_collection.js +20 -17
  100. package/dist/resource_clients/webhook_dispatch.d.ts +9 -6
  101. package/dist/resource_clients/webhook_dispatch.js +11 -10
  102. package/dist/resource_clients/webhook_dispatch_collection.d.ts +7 -5
  103. package/dist/resource_clients/webhook_dispatch_collection.js +13 -13
  104. package/dist/response_validation_error.d.ts +27 -0
  105. package/dist/response_validation_error.js +38 -0
  106. package/dist/runtime/node.d.ts +6 -0
  107. package/dist/runtime/node.js +87 -0
  108. package/dist/runtime/types.d.ts +60 -0
  109. package/dist/runtime/types.js +1 -0
  110. package/dist/runtime/web.d.ts +5 -0
  111. package/dist/runtime/web.js +21 -0
  112. package/dist/schemas.d.ts +381 -0
  113. package/dist/schemas.js +37 -0
  114. package/dist/statistics.d.ts +1 -6
  115. package/dist/statistics.js +7 -11
  116. package/dist/timeouts.d.ts +84 -0
  117. package/dist/timeouts.js +37 -0
  118. package/dist/timezones.d.ts +1 -1
  119. package/dist/timezones.js +1 -2
  120. package/dist/utils.d.ts +99 -70
  121. package/dist/utils.js +251 -229
  122. package/dist/wait_for_resources.d.ts +8 -0
  123. package/dist/wait_for_resources.js +39 -0
  124. package/package.json +48 -47
  125. package/dist/argument_validation_error.d.ts +0 -17
  126. package/dist/argument_validation_error.js +0 -157
  127. package/dist/http_client.d.ts +0 -88
  128. package/dist/http_client.js +0 -260
  129. package/dist/index.mjs +0 -42
  130. package/dist/interceptors.d.ts +0 -19
  131. package/dist/interceptors.js +0 -110
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorListSortBy = exports.ActorCollectionClient = void 0;
4
- const zod_1 = require("zod");
5
- const resource_collection_client_1 = require("../base/resource_collection_client");
6
- const utils_1 = require("../utils");
7
- const actorCreateSchema = utils_1.anyObjectSchema.optional();
1
+ import { z } from 'zod';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import * as schemas from '../schemas.js';
4
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
5
+ import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
6
+ const actorCreateSchema = anyObjectSchema.optional();
8
7
  /**
9
8
  * Client for managing the collection of Actors in your account.
10
9
  *
@@ -28,7 +27,7 @@ const actorCreateSchema = utils_1.anyObjectSchema.optional();
28
27
  *
29
28
  * @see https://docs.apify.com/platform/actors
30
29
  */
31
- class ActorCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
30
+ export class ActorCollectionClient extends ResourceCollectionClient {
32
31
  /**
33
32
  * @hidden
34
33
  */
@@ -55,38 +54,44 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
55
54
  * ```
56
55
  *
57
56
  * @param options - Pagination options.
57
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
58
58
  * @returns A paginated iterator of Actors.
59
59
  * @see https://docs.apify.com/api/v2/acts-get
60
60
  */
61
61
  list(options = {}) {
62
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'ActorCollectionListOptions');
63
- return this._listPaginated(parsed);
62
+ const parsed = parseArgument(options, listOptionsSchema, 'ActorCollectionListOptions');
63
+ return this.listResourcesPaginated(schemas.ListOfActors(), parsed, 'medium');
64
64
  }
65
65
  /**
66
66
  * Creates a new Actor.
67
67
  *
68
68
  * @param actor - The Actor data.
69
+ * @param options - Request options
70
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
69
71
  * @returns The created Actor object.
70
72
  * @see https://docs.apify.com/api/v2/acts-post
71
73
  */
72
- async create(actor) {
73
- (0, utils_1.parseArgument)(actor, actorCreateSchema);
74
- return this._create(actor);
74
+ async create(actor, options = {}) {
75
+ parseArgument(actor, actorCreateSchema);
76
+ const { timeoutSecs = 'medium', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
77
+ return this.createResource(schemas.ActorResource(), actor, timeoutSecs, signal);
75
78
  }
76
79
  }
77
- exports.ActorCollectionClient = ActorCollectionClient;
78
80
  /**
81
+ * Field to order a list of Actors by.
82
+ *
79
83
  * @since Added in 2.12.6
80
84
  */
81
- var ActorListSortBy;
85
+ export var ActorListSortBy;
82
86
  (function (ActorListSortBy) {
83
87
  ActorListSortBy["CREATED_AT"] = "createdAt";
84
88
  ActorListSortBy["LAST_RUN_STARTED_AT"] = "stats.lastRunStartedAt";
85
- })(ActorListSortBy || (exports.ActorListSortBy = ActorListSortBy = {}));
89
+ })(ActorListSortBy || (ActorListSortBy = {}));
86
90
  // Declared below `ActorListSortBy` because it references it at module load time.
87
- const listOptionsSchema = zod_1.z.strictObject({
88
- my: zod_1.z.boolean().optional(),
89
- ...utils_1.paginationOptionsShape,
90
- desc: zod_1.z.boolean().optional(),
91
- sortBy: zod_1.z.enum(ActorListSortBy).optional(),
91
+ const listOptionsSchema = z.strictObject({
92
+ my: z.boolean().optional(),
93
+ ...paginationOptionsShape,
94
+ desc: z.boolean().optional(),
95
+ sortBy: z.enum(ActorListSortBy).optional(),
96
+ ...timeoutOptionsShape,
92
97
  });
@@ -1,6 +1,7 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { ActorEnvironmentVariable } from './actor_version';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { TimeoutOptions } from '../timeouts.js';
4
+ import type { EnvVar } from './actor_version.js';
4
5
  /**
5
6
  * Client for managing a specific Actor environment variable.
6
7
  *
@@ -32,22 +33,28 @@ export declare class ActorEnvVarClient extends ResourceClient {
32
33
  /**
33
34
  * Retrieves the environment variable.
34
35
  *
36
+ * @param options - Request options
37
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
35
38
  * @returns The environment variable object, or `undefined` if it does not exist.
36
39
  * @see https://docs.apify.com/api/v2/act-version-env-var-get
37
40
  */
38
- get(): Promise<ActorEnvironmentVariable | undefined>;
41
+ get(options?: TimeoutOptions): Promise<EnvVar | undefined>;
39
42
  /**
40
43
  * Updates the environment variable.
41
44
  *
42
45
  * @param actorEnvVar - The updated environment variable data.
46
+ * @param options - Request options
47
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
43
48
  * @returns The updated environment variable object.
44
49
  * @see https://docs.apify.com/api/v2/act-version-env-var-put
45
50
  */
46
- update(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
51
+ update(actorEnvVar: EnvVar, options?: TimeoutOptions): Promise<EnvVar>;
47
52
  /**
48
53
  * Deletes the environment variable.
49
54
  *
55
+ * @param options - Request options
56
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
50
57
  * @see https://docs.apify.com/api/v2/act-version-env-var-delete
51
58
  */
52
- delete(): Promise<void>;
59
+ delete(options?: TimeoutOptions): Promise<void>;
53
60
  }
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorEnvVarClient = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- const utils_1 = require("../utils");
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
+ import { anyObjectSchema, parseArgument } from '../utils.js';
6
5
  /**
7
6
  * Client for managing a specific Actor environment variable.
8
7
  *
@@ -26,7 +25,7 @@ const utils_1 = require("../utils");
26
25
  * @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
27
26
  * @since Added in 2.1.0
28
27
  */
29
- class ActorEnvVarClient extends resource_client_1.ResourceClient {
28
+ export class ActorEnvVarClient extends ResourceClient {
30
29
  /**
31
30
  * @hidden
32
31
  */
@@ -39,30 +38,38 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
39
38
  /**
40
39
  * Retrieves the environment variable.
41
40
  *
41
+ * @param options - Request options
42
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
42
43
  * @returns The environment variable object, or `undefined` if it does not exist.
43
44
  * @see https://docs.apify.com/api/v2/act-version-env-var-get
44
45
  */
45
- async get() {
46
- return this._get();
46
+ async get(options = {}) {
47
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
48
+ return this.getResource(schemas.EnvVar(), {}, timeoutSecs, signal);
47
49
  }
48
50
  /**
49
51
  * Updates the environment variable.
50
52
  *
51
53
  * @param actorEnvVar - The updated environment variable data.
54
+ * @param options - Request options
55
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
52
56
  * @returns The updated environment variable object.
53
57
  * @see https://docs.apify.com/api/v2/act-version-env-var-put
54
58
  */
55
- async update(actorEnvVar) {
56
- (0, utils_1.parseArgument)(actorEnvVar, utils_1.anyObjectSchema);
57
- return this._update(actorEnvVar);
59
+ async update(actorEnvVar, options = {}) {
60
+ parseArgument(actorEnvVar, anyObjectSchema);
61
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
62
+ return this.updateResource(schemas.EnvVar(), actorEnvVar, timeoutSecs, signal);
58
63
  }
59
64
  /**
60
65
  * Deletes the environment variable.
61
66
  *
67
+ * @param options - Request options
68
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
62
69
  * @see https://docs.apify.com/api/v2/act-version-env-var-delete
63
70
  */
64
- async delete() {
65
- return this._delete();
71
+ async delete(options = {}) {
72
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
73
+ return this.deleteResource(timeoutSecs, signal);
66
74
  }
67
75
  }
68
- exports.ActorEnvVarClient = ActorEnvVarClient;
@@ -1,7 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceCollectionClient } from '../base/resource_collection_client';
3
- import type { PaginatedList, PaginationOptions } from '../utils';
4
- import type { ActorEnvironmentVariable } from './actor_version';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { 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,9 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorEnvVarCollectionClient = void 0;
4
- const resource_collection_client_1 = require("../base/resource_collection_client");
5
- const utils_1 = require("../utils");
6
- const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
1
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
2
+ import * as schemas from '../schemas.js';
3
+ import { timeoutOptionsSchema } from '../timeouts.js';
4
+ import { anyObjectSchema, parseArgument } from '../utils.js';
5
+ const actorEnvVarSchema = anyObjectSchema.optional();
7
6
  /**
8
7
  * Client for managing the collection of environment variables for an Actor version.
9
8
  *
@@ -31,7 +30,7 @@ const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
31
30
  * @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
32
31
  * @since Added in 2.1.0
33
32
  */
34
- class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
33
+ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
35
34
  /**
36
35
  * @hidden
37
36
  */
@@ -44,35 +43,39 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
44
43
  /**
45
44
  * Lists all environment variables of this Actor version.
46
45
  *
47
- * Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
48
- * 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.
49
48
  * ```javascript
50
- * const paginatedList = await client.list();
51
- *```
49
+ * const { items } = await client.list();
50
+ * ```
52
51
  *
53
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
54
- * retrieved.
52
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
55
53
  *
56
54
  * ```javascript
57
55
  * for await (const singleItem of client.list()) {...}
58
56
  * ```
59
57
  *
60
- * @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.
61
61
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
62
62
  */
63
- list(_options = {}) {
64
- return this._listPaginated();
63
+ list(options = {}) {
64
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
65
+ return this.listUnpaginatedResources(schemas.ListOfEnvVars(), timeoutSecs, signal);
65
66
  }
66
67
  /**
67
68
  * Creates a new environment variable for this Actor version.
68
69
  *
69
70
  * @param actorEnvVar - The environment variable data.
71
+ * @param options - Request options
72
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
70
73
  * @returns The created environment variable object.
71
74
  * @see https://docs.apify.com/api/v2/act-version-env-vars-post
72
75
  */
73
- async create(actorEnvVar) {
74
- (0, utils_1.parseArgument)(actorEnvVar, actorEnvVarSchema);
75
- return this._create(actorEnvVar);
76
+ async create(actorEnvVar, options = {}) {
77
+ parseArgument(actorEnvVar, actorEnvVarSchema);
78
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
79
+ return this.createResource(schemas.EnvVar(), actorEnvVar, timeoutSecs, signal);
76
80
  }
77
81
  }
78
- exports.ActorEnvVarCollectionClient = ActorEnvVarCollectionClient;
@@ -0,0 +1,149 @@
1
+ import type { Readable } from 'node:stream';
2
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
3
+ import { ResourceClient } from '../base/resource_client.js';
4
+ import type { ApifyResponse, ApifyResponseType, HttpMethod } from '../http_clients/index.js';
5
+ import type { HttpCompressor } from '../http_compressors/base.js';
6
+ import type { HttpCompressionAlgorithm } from '../http_compressors/resolve.js';
7
+ import type { TimeoutOptions } from '../timeouts.js';
8
+ /**
9
+ * Client for the server interface of a specific Actor.
10
+ *
11
+ * Provides methods to work with the web server of a Server Actor, such as sending it requests or getting its OpenAPI
12
+ * specification. Get an instance with {@link ActorClient.server}.
13
+ *
14
+ * @example
15
+ * ```javascript
16
+ * const client = new ApifyClient({ token: 'my-token' });
17
+ * const actorServerClient = client.actor('username/actor-name').server();
18
+ *
19
+ * const response = await actorServerClient.request('/search', { params: { q: 'apify' } });
20
+ * console.log(response.data);
21
+ * ```
22
+ *
23
+ * @see https://docs.apify.com/platform/actors/running/standby
24
+ */
25
+ export declare class ActorServerClient extends ResourceClient {
26
+ #private;
27
+ /**
28
+ * @hidden
29
+ */
30
+ constructor(options: ApiClientSubResourceOptions);
31
+ /**
32
+ * Returns the URL of the Actor's server.
33
+ *
34
+ * The URL is the Actor's `standbyUrl`, fetched from the API by the first call of this method or
35
+ * {@link getOpenApiSpec} and reused by later calls on this client. Use it to call the server with another HTTP
36
+ * client, for example one generated from the server's OpenAPI specification.
37
+ *
38
+ * @param options - Request options
39
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
40
+ * @returns The URL of the Actor's server
41
+ * @throws {ApifyClientError} When the Actor is not a Server Actor.
42
+ * @throws {NotFoundError} When the Actor does not exist.
43
+ * @see https://docs.apify.com/platform/actors/running/standby
44
+ */
45
+ getUrl(options?: TimeoutOptions): Promise<string>;
46
+ /**
47
+ * Returns the OpenAPI specification of the Actor's server.
48
+ *
49
+ * The specification is the web server schema from the Actor's definition, taken from the build that serves the
50
+ * server interface: the build set in `actorStandby.build`, or `latest` if none is set. Use it to generate an HTTP
51
+ * client for the server, and point that client at the URL returned by {@link getUrl}.
52
+ *
53
+ * @param options - Request options
54
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'short'`.
55
+ * @returns The OpenAPI specification of the Actor's server, or `undefined` if the Actor's definition doesn't
56
+ * include one
57
+ * @throws {ApifyClientError} When the Actor is not a Server Actor, or the build that serves its server interface
58
+ * doesn't exist.
59
+ * @throws {NotFoundError} When the Actor does not exist.
60
+ * @see https://docs.apify.com/platform/actors/development/actor-definition/web-server-schema
61
+ */
62
+ getOpenApiSpec(options?: TimeoutOptions): Promise<Record<string, unknown> | undefined>;
63
+ /**
64
+ * Sends an HTTP request to the Actor's server.
65
+ *
66
+ * The request goes to the URL returned by {@link getUrl} and carries the client's token in the
67
+ * `X-Apify-Authorization` header, which the platform consumes, so it never reaches the Actor's code. Headers you
68
+ * pass, `Authorization` included, reach the Actor's server as they are. The first request to an idle Actor waits
69
+ * for the platform to start a server run, which is why the timeout defaults to `'long'`.
70
+ *
71
+ * The method resolves to any response of the server, error statuses included. A rate-limit (429) or Service
72
+ * Unavailable (503) response is retried with the client's retry settings, and the last one is returned once the
73
+ * retries run out. The Actor's code can return these statuses too, and then it gets the request again. A redirect
74
+ * is returned as it is, since following it would send the token to a host the Actor's code picked. A browser
75
+ * follows redirects itself, though, so there the token goes with a redirect. Request bodies are sent uncompressed
76
+ * unless `compression` is set, since the Actor's server may not decode a compressed body.
77
+ *
78
+ * @template T - Type of the parsed response body.
79
+ * @param path - The path on the Actor's server, for example `/search`. It is always resolved against the server
80
+ * URL, so the request, and the token with it, can't be sent to another host. Pass the query in `params`. A
81
+ * fragment (`#...`) is dropped, since it's never sent to the server.
82
+ * @param options - Request options
83
+ * @param options.method - HTTP method of the request. Default is `'GET'`.
84
+ * @param options.params - Query parameters of the request, converted the same way as for API calls.
85
+ * @param options.headers - Additional headers of the request.
86
+ * @param options.data - Request body, serialized the same way as for API calls: a plain object or array is sent
87
+ * as JSON, and a string or binary value as it is.
88
+ * @param options.parentRequestId - The `X-Actor-Request-ID` header of the request your Server Actor is handling,
89
+ * sent on as the same header so the called Actor charges at that request's pricing tier.
90
+ * @param options.compression - Compression algorithm for the request body, as a name or an {@link HttpCompressor}.
91
+ * The body is compressed under the same conditions as for API calls. Set it only if the Actor's server decodes
92
+ * the resulting `Content-Encoding`.
93
+ * @param options.responseType - How to return the response body: `'parsed'` by its content type, `'buffer'` as
94
+ * raw bytes, or `'stream'` as a Readable stream with the body unread. A stream holds its connection open until
95
+ * you consume it to the end or destroy it. Node.js only. Default is `'parsed'`.
96
+ * @param options.timeoutSecs - Timeout for the HTTP request. Default is `'long'`. With `'stream'`, it bounds the
97
+ * wait for the server to start responding.
98
+ * @returns The response of the Actor's server, with the body in the form `responseType` asks for. An error
99
+ * response whose body doesn't parse as its content type comes with the raw bytes in `data`.
100
+ * @throws {ApifyClientError} When the Actor is not a Server Actor.
101
+ * @throws {InvalidResponseBodyError} When a success response's body doesn't parse as its content type, with
102
+ * `responseType: 'parsed'`.
103
+ * @throws {NotFoundError} When the Actor does not exist.
104
+ * @see https://docs.apify.com/platform/actors/running/standby
105
+ */
106
+ request<T = any>(path?: string, options?: ActorServerRequestOptions & {
107
+ responseType?: 'parsed';
108
+ }): Promise<ApifyResponse<T>>;
109
+ request(path: string, options: ActorServerRequestOptions & {
110
+ responseType: 'buffer';
111
+ }): Promise<ApifyResponse<Buffer>>;
112
+ request(path: string, options: ActorServerRequestOptions & {
113
+ responseType: 'stream';
114
+ }): Promise<ApifyResponse<Readable>>;
115
+ request(path?: string, options?: ActorServerRequestOptions): Promise<ApifyResponse>;
116
+ }
117
+ /**
118
+ * Options of {@link ActorServerClient.request}.
119
+ */
120
+ export interface ActorServerRequestOptions extends TimeoutOptions {
121
+ /** HTTP method of the request. @default 'GET' */
122
+ method?: HttpMethod;
123
+ /** Query parameters of the request, converted the same way as for API calls. */
124
+ params?: Record<string, unknown>;
125
+ /** Additional headers of the request. */
126
+ headers?: Record<string, string>;
127
+ /**
128
+ * Request body, serialized the same way as for API calls: a plain object or array is sent as JSON, and a string
129
+ * or binary value as it is.
130
+ */
131
+ data?: unknown;
132
+ /**
133
+ * The `X-Actor-Request-ID` header of the request your Server Actor is handling. It's sent on as the same header,
134
+ * so the called Actor charges at that request's pricing tier.
135
+ * @see https://docs.apify.com/platform/actors/development/programming-interface/standby#compose-server-actors
136
+ */
137
+ parentRequestId?: string;
138
+ /**
139
+ * Compression algorithm for the request body, as a name or an {@link HttpCompressor}. The body is sent
140
+ * uncompressed when it's not set, since the Actor's server may not decode a compressed body.
141
+ */
142
+ compression?: HttpCompressionAlgorithm | HttpCompressor;
143
+ /**
144
+ * How to return the response body: `'parsed'` by its content type, `'buffer'` as raw bytes, or `'stream'` as a
145
+ * Readable stream with the body unread. Node.js only.
146
+ * @default 'parsed'
147
+ */
148
+ responseType?: ApifyResponseType;
149
+ }