apify-client 3.0.0-beta.0 → 3.0.0-beta.10

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 (94) hide show
  1. package/README.md +5 -3
  2. package/dist/apify_api_error.d.ts +59 -3
  3. package/dist/apify_api_error.js +71 -11
  4. package/dist/apify_client.d.ts +27 -27
  5. package/dist/apify_client.js +86 -91
  6. package/dist/base/api_client.d.ts +3 -3
  7. package/dist/base/api_client.js +6 -10
  8. package/dist/base/resource_client.d.ts +5 -4
  9. package/dist/base/resource_client.js +17 -21
  10. package/dist/base/resource_collection_client.d.ts +7 -6
  11. package/dist/base/resource_collection_client.js +11 -15
  12. package/dist/body_parser.js +6 -11
  13. package/dist/bundle.js +38 -48
  14. package/dist/bundle.js.map +1 -1
  15. package/dist/generated/api.d.ts +20595 -0
  16. package/dist/generated/api.js +5 -0
  17. package/dist/generated/schemas.d.ts +6699 -0
  18. package/dist/generated/schemas.js +1521 -0
  19. package/dist/http_client.d.ts +2 -2
  20. package/dist/http_client.js +23 -28
  21. package/dist/index.d.ts +33 -32
  22. package/dist/index.js +32 -36
  23. package/dist/interceptors.d.ts +1 -1
  24. package/dist/interceptors.js +14 -19
  25. package/dist/lazy_schema.d.ts +8 -0
  26. package/dist/lazy_schema.js +11 -0
  27. package/dist/models.d.ts +1053 -0
  28. package/dist/models.js +86 -0
  29. package/dist/resource_clients/actor.d.ts +13 -459
  30. package/dist/resource_clients/actor.js +70 -73
  31. package/dist/resource_clients/actor_collection.d.ts +10 -15
  32. package/dist/resource_clients/actor_collection.js +19 -20
  33. package/dist/resource_clients/actor_env_var.d.ts +3 -3
  34. package/dist/resource_clients/actor_env_var.js +7 -10
  35. package/dist/resource_clients/actor_env_var_collection.d.ts +11 -20
  36. package/dist/resource_clients/actor_env_var_collection.js +15 -19
  37. package/dist/resource_clients/actor_version.d.ts +14 -43
  38. package/dist/resource_clients/actor_version.js +15 -24
  39. package/dist/resource_clients/actor_version_collection.d.ts +13 -19
  40. package/dist/resource_clients/actor_version_collection.js +17 -19
  41. package/dist/resource_clients/build.d.ts +5 -80
  42. package/dist/resource_clients/build.js +14 -17
  43. package/dist/resource_clients/build_collection.d.ts +5 -5
  44. package/dist/resource_clients/build_collection.js +10 -13
  45. package/dist/resource_clients/dataset.d.ts +6 -72
  46. package/dist/resource_clients/dataset.js +73 -76
  47. package/dist/resource_clients/dataset_collection.d.ts +4 -4
  48. package/dist/resource_clients/dataset_collection.js +18 -21
  49. package/dist/resource_clients/key_value_store.d.ts +16 -77
  50. package/dist/resource_clients/key_value_store.js +64 -66
  51. package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
  52. package/dist/resource_clients/key_value_store_collection.js +18 -21
  53. package/dist/resource_clients/log.d.ts +2 -2
  54. package/dist/resource_clients/log.js +15 -22
  55. package/dist/resource_clients/request_queue.d.ts +17 -183
  56. package/dist/resource_clients/request_queue.js +102 -108
  57. package/dist/resource_clients/request_queue_collection.d.ts +4 -4
  58. package/dist/resource_clients/request_queue_collection.js +16 -19
  59. package/dist/resource_clients/run.d.ts +8 -8
  60. package/dist/resource_clients/run.js +50 -53
  61. package/dist/resource_clients/run_collection.d.ts +4 -4
  62. package/dist/resource_clients/run_collection.js +15 -18
  63. package/dist/resource_clients/schedule.d.ts +8 -86
  64. package/dist/resource_clients/schedule.js +13 -21
  65. package/dist/resource_clients/schedule_collection.d.ts +4 -4
  66. package/dist/resource_clients/schedule_collection.js +13 -16
  67. package/dist/resource_clients/store_collection.d.ts +5 -33
  68. package/dist/resource_clients/store_collection.js +15 -18
  69. package/dist/resource_clients/task.d.ts +9 -79
  70. package/dist/resource_clients/task.js +47 -50
  71. package/dist/resource_clients/task_collection.d.ts +6 -5
  72. package/dist/resource_clients/task_collection.js +12 -15
  73. package/dist/resource_clients/user.d.ts +5 -181
  74. package/dist/resource_clients/user.js +11 -24
  75. package/dist/resource_clients/webhook.d.ts +6 -65
  76. package/dist/resource_clients/webhook.js +11 -14
  77. package/dist/resource_clients/webhook_collection.d.ts +4 -4
  78. package/dist/resource_clients/webhook_collection.js +13 -16
  79. package/dist/resource_clients/webhook_dispatch.d.ts +5 -38
  80. package/dist/resource_clients/webhook_dispatch.js +5 -13
  81. package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
  82. package/dist/resource_clients/webhook_dispatch_collection.js +10 -13
  83. package/dist/response_validation_error.d.ts +26 -0
  84. package/dist/response_validation_error.js +37 -0
  85. package/dist/schemas.d.ts +15 -0
  86. package/dist/schemas.js +15 -0
  87. package/dist/statistics.js +5 -9
  88. package/dist/timezones.js +1 -2
  89. package/dist/utils.d.ts +19 -24
  90. package/dist/utils.js +66 -96
  91. package/package.json +48 -40
  92. package/dist/argument_validation_error.d.ts +0 -17
  93. package/dist/argument_validation_error.js +0 -157
  94. package/dist/index.mjs +0 -42
@@ -1,57 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorClient = void 0;
4
- const zod_1 = require("zod");
5
- const consts_1 = require("@apify/consts");
6
- const log_1 = require("@apify/log");
7
- const resource_client_1 = require("../base/resource_client");
8
- const utils_1 = require("../utils");
9
- const actor_version_1 = require("./actor_version");
10
- const actor_version_collection_1 = require("./actor_version_collection");
11
- const build_1 = require("./build");
12
- const build_collection_1 = require("./build_collection");
13
- const run_1 = require("./run");
14
- const run_collection_1 = require("./run_collection");
15
- const webhook_collection_1 = require("./webhook_collection");
16
- const startOptionsSchema = zod_1.z.strictObject({
17
- build: zod_1.z.string().optional(),
18
- contentType: zod_1.z.string().optional(),
19
- memory: zod_1.z.number().optional(),
20
- timeout: zod_1.z.number().optional(),
21
- waitForFinish: zod_1.z.number().optional(),
22
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
23
- maxItems: zod_1.z.number().min(0).optional(),
24
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
25
- restartOnError: zod_1.z.boolean().optional(),
26
- forcePermissionLevel: zod_1.z.enum(consts_1.ACTOR_PERMISSION_LEVEL).optional(),
1
+ import { z } from 'zod';
2
+ import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
3
+ import { Log } from '@apify/log';
4
+ import { ResourceClient } from '../base/resource_client.js';
5
+ import * as schemas from '../schemas.js';
6
+ import { anyObjectSchema, parseArgument, parseResponse, stringifyWebhooksToBase64 } from '../utils.js';
7
+ import { ActorVersionClient } from './actor_version.js';
8
+ import { ActorVersionCollectionClient } from './actor_version_collection.js';
9
+ import { BuildClient } from './build.js';
10
+ import { BuildCollectionClient } from './build_collection.js';
11
+ import { RunClient } from './run.js';
12
+ import { RunCollectionClient } from './run_collection.js';
13
+ import { WebhookCollectionClient } from './webhook_collection.js';
14
+ const startOptionsSchema = z.strictObject({
15
+ build: z.string().optional(),
16
+ contentType: z.string().optional(),
17
+ memory: z.number().optional(),
18
+ timeout: z.number().optional(),
19
+ waitForFinish: z.number().optional(),
20
+ webhooks: z.array(anyObjectSchema).optional(),
21
+ maxItems: z.number().min(0).optional(),
22
+ maxTotalChargeUsd: z.number().min(0).optional(),
23
+ restartOnError: z.boolean().optional(),
24
+ forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
27
25
  });
28
- const callOptionsSchema = zod_1.z.strictObject({
29
- build: zod_1.z.string().optional(),
30
- contentType: zod_1.z.string().optional(),
31
- memory: zod_1.z.number().optional(),
32
- timeout: zod_1.z.number().min(0).optional(),
33
- waitSecs: zod_1.z.number().min(0).optional(),
34
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
35
- maxItems: zod_1.z.number().min(0).optional(),
36
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
37
- log: zod_1.z.union([zod_1.z.null(), zod_1.z.instanceof(log_1.Log), zod_1.z.literal('default')]).optional(),
38
- restartOnError: zod_1.z.boolean().optional(),
39
- forcePermissionLevel: zod_1.z.enum(consts_1.ACTOR_PERMISSION_LEVEL).optional(),
26
+ const callOptionsSchema = z.strictObject({
27
+ build: z.string().optional(),
28
+ contentType: z.string().optional(),
29
+ memory: z.number().optional(),
30
+ timeout: z.number().min(0).optional(),
31
+ waitSecs: z.number().min(0).optional(),
32
+ webhooks: z.array(anyObjectSchema).optional(),
33
+ maxItems: z.number().min(0).optional(),
34
+ maxTotalChargeUsd: z.number().min(0).optional(),
35
+ log: z.union([z.null(), z.instanceof(Log), z.literal('default')]).optional(),
36
+ restartOnError: z.boolean().optional(),
37
+ forcePermissionLevel: z.enum(ACTOR_PERMISSION_LEVEL).optional(),
40
38
  });
41
- const validateInputOptionsSchema = zod_1.z.strictObject({
42
- build: zod_1.z.string().optional(),
43
- contentType: zod_1.z.string().optional(),
39
+ const validateInputOptionsSchema = z.strictObject({
40
+ build: z.string().optional(),
41
+ contentType: z.string().optional(),
44
42
  });
45
- const versionNumberSchema = zod_1.z.string();
46
- const buildOptionsSchema = zod_1.z.strictObject({
47
- betaPackages: zod_1.z.boolean().optional(),
48
- tag: zod_1.z.string().optional(),
49
- useCache: zod_1.z.boolean().optional(),
50
- waitForFinish: zod_1.z.number().optional(),
43
+ const versionNumberSchema = z.string();
44
+ const buildOptionsSchema = z.strictObject({
45
+ betaPackages: z.boolean().optional(),
46
+ tag: z.string().optional(),
47
+ useCache: z.boolean().optional(),
48
+ waitForFinish: z.number().optional(),
51
49
  });
52
- const lastRunOptionsSchema = zod_1.z.strictObject({
53
- status: zod_1.z.enum(consts_1.ACTOR_JOB_STATUSES).optional(),
54
- origin: zod_1.z.enum(consts_1.META_ORIGINS).optional(),
50
+ const lastRunOptionsSchema = z.strictObject({
51
+ status: z.enum(ACTOR_JOB_STATUSES).optional(),
52
+ origin: z.enum(META_ORIGINS).optional(),
55
53
  });
56
54
  /**
57
55
  * Client for managing a specific Actor.
@@ -73,7 +71,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
73
71
  *
74
72
  * @see https://docs.apify.com/platform/actors
75
73
  */
76
- class ActorClient extends resource_client_1.ResourceClient {
74
+ export class ActorClient extends ResourceClient {
77
75
  /**
78
76
  * @hidden
79
77
  */
@@ -90,7 +88,7 @@ class ActorClient extends resource_client_1.ResourceClient {
90
88
  * @see https://docs.apify.com/api/v2/act-get
91
89
  */
92
90
  async get() {
93
- return this._get();
91
+ return this._get(schemas.Actor());
94
92
  }
95
93
  /**
96
94
  * Updates the Actor with specified fields.
@@ -100,8 +98,8 @@ class ActorClient extends resource_client_1.ResourceClient {
100
98
  * @see https://docs.apify.com/api/v2/act-put
101
99
  */
102
100
  async update(newFields) {
103
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
104
- return this._update(newFields);
101
+ parseArgument(newFields, anyObjectSchema);
102
+ return this._update(schemas.Actor(), newFields);
105
103
  }
106
104
  /**
107
105
  * Deletes the Actor.
@@ -148,14 +146,14 @@ class ActorClient extends resource_client_1.ResourceClient {
148
146
  async start(input, options = {}) {
149
147
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
150
148
  // then it will process input as a buffer.
151
- const parsed = (0, utils_1.parseArgument)(options, startOptionsSchema, 'ActorStartOptions');
149
+ const parsed = parseArgument(options, startOptionsSchema, 'ActorStartOptions');
152
150
  const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = parsed;
153
151
  const params = {
154
152
  waitForFinish,
155
153
  timeout,
156
154
  memory,
157
155
  build,
158
- webhooks: (0, utils_1.stringifyWebhooksToBase64)(parsed.webhooks),
156
+ webhooks: stringifyWebhooksToBase64(parsed.webhooks),
159
157
  maxItems,
160
158
  maxTotalChargeUsd,
161
159
  restartOnError,
@@ -176,7 +174,7 @@ class ActorClient extends resource_client_1.ResourceClient {
176
174
  };
177
175
  }
178
176
  const response = await this.httpClient.call(request);
179
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
177
+ return parseResponse(response, schemas.Run());
180
178
  }
181
179
  /**
182
180
  * Starts the Actor and waits for it to finish before returning the Run object.
@@ -218,7 +216,7 @@ class ActorClient extends resource_client_1.ResourceClient {
218
216
  async call(input, options = {}) {
219
217
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
220
218
  // then it will process input as a buffer.
221
- const parsed = (0, utils_1.parseArgument)(options, callOptionsSchema, 'ActorCallOptions');
219
+ const parsed = parseArgument(options, callOptionsSchema, 'ActorCallOptions');
222
220
  const { waitSecs, log, ...startOptions } = parsed;
223
221
  const { id } = await this.start(input, startOptions);
224
222
  // Calling root client because we need access to top level API.
@@ -268,7 +266,7 @@ class ActorClient extends resource_client_1.ResourceClient {
268
266
  async validateInput(input, options = {}) {
269
267
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
270
268
  // then it will process input as a buffer.
271
- const parsed = (0, utils_1.parseArgument)(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
269
+ const parsed = parseArgument(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
272
270
  const request = {
273
271
  url: this._url('validate-input'),
274
272
  method: 'POST',
@@ -316,8 +314,8 @@ class ActorClient extends resource_client_1.ResourceClient {
316
314
  * ```
317
315
  */
318
316
  async build(versionNumber, options = {}) {
319
- (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
320
- const parsed = (0, utils_1.parseArgument)(options, buildOptionsSchema, 'ActorBuildOptions');
317
+ parseArgument(versionNumber, versionNumberSchema);
318
+ const parsed = parseArgument(options, buildOptionsSchema, 'ActorBuildOptions');
321
319
  const response = await this.httpClient.call({
322
320
  url: this._url('builds'),
323
321
  method: 'POST',
@@ -326,7 +324,7 @@ class ActorClient extends resource_client_1.ResourceClient {
326
324
  ...parsed,
327
325
  }),
328
326
  });
329
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
327
+ return parseResponse(response, schemas.Build());
330
328
  }
331
329
  /**
332
330
  * Returns a client for the default build of this Actor.
@@ -359,8 +357,8 @@ class ActorClient extends resource_client_1.ResourceClient {
359
357
  method: 'GET',
360
358
  params: this._params(options),
361
359
  });
362
- const { id } = (0, utils_1.pluckData)(response.data);
363
- return new build_1.BuildClient({
360
+ const { id } = parseResponse(response, schemas.Build());
361
+ return new BuildClient({
364
362
  baseUrl: this.apifyClient.baseUrl,
365
363
  publicBaseUrl: this.apifyClient.publicBaseUrl,
366
364
  httpClient: this.httpClient,
@@ -386,8 +384,8 @@ class ActorClient extends resource_client_1.ResourceClient {
386
384
  * ```
387
385
  */
388
386
  lastRun(options = {}) {
389
- const parsed = (0, utils_1.parseArgument)(options, lastRunOptionsSchema, 'ActorLastRunOptions');
390
- return new run_1.RunClient(this._subResourceOptions({
387
+ const parsed = parseArgument(options, lastRunOptionsSchema, 'ActorLastRunOptions');
388
+ return new RunClient(this._subResourceOptions({
391
389
  id: 'last',
392
390
  params: this._params(parsed),
393
391
  resourcePath: 'runs',
@@ -400,7 +398,7 @@ class ActorClient extends resource_client_1.ResourceClient {
400
398
  * @see https://docs.apify.com/api/v2/act-builds-get
401
399
  */
402
400
  builds() {
403
- return new build_collection_1.BuildCollectionClient(this._subResourceOptions({
401
+ return new BuildCollectionClient(this._subResourceOptions({
404
402
  resourcePath: 'builds',
405
403
  }));
406
404
  }
@@ -411,7 +409,7 @@ class ActorClient extends resource_client_1.ResourceClient {
411
409
  * @see https://docs.apify.com/api/v2/act-runs-get
412
410
  */
413
411
  runs() {
414
- return new run_collection_1.RunCollectionClient(this._subResourceOptions({
412
+ return new RunCollectionClient(this._subResourceOptions({
415
413
  resourcePath: 'runs',
416
414
  }));
417
415
  }
@@ -423,8 +421,8 @@ class ActorClient extends resource_client_1.ResourceClient {
423
421
  * @see https://docs.apify.com/api/v2/act-version-get
424
422
  */
425
423
  version(versionNumber) {
426
- (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
427
- return new actor_version_1.ActorVersionClient(this._subResourceOptions({
424
+ parseArgument(versionNumber, versionNumberSchema);
425
+ return new ActorVersionClient(this._subResourceOptions({
428
426
  id: versionNumber,
429
427
  }));
430
428
  }
@@ -435,7 +433,7 @@ class ActorClient extends resource_client_1.ResourceClient {
435
433
  * @see https://docs.apify.com/api/v2/act-versions-get
436
434
  */
437
435
  versions() {
438
- return new actor_version_collection_1.ActorVersionCollectionClient(this._subResourceOptions());
436
+ return new ActorVersionCollectionClient(this._subResourceOptions());
439
437
  }
440
438
  /**
441
439
  * Returns a client for managing webhooks associated with this Actor.
@@ -444,7 +442,6 @@ class ActorClient extends resource_client_1.ResourceClient {
444
442
  * @see https://docs.apify.com/api/v2/act-webhooks-get
445
443
  */
446
444
  webhooks() {
447
- return new webhook_collection_1.WebhookCollectionClient(this._subResourceOptions());
445
+ return new WebhookCollectionClient(this._subResourceOptions());
448
446
  }
449
447
  }
450
- exports.ActorClient = ActorClient;
@@ -1,9 +1,11 @@
1
1
  import type { ACTOR_PERMISSION_LEVEL } from '@apify/consts';
2
- import type { ApiClientSubResourceOptions } from '../base/api_client';
3
- import { ResourceCollectionClient } from '../base/resource_collection_client';
4
- import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils';
5
- import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor';
6
- import type { ActorVersion } from './actor_version';
2
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
3
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
4
+ import type { ActorCollectionListItem } from '../models.js';
5
+ import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils.js';
6
+ import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor.js';
7
+ import type { ActorVersion } from './actor_version.js';
8
+ export type { ActorCollectionListItem } from '../models.js';
7
9
  /**
8
10
  * Client for managing the collection of Actors in your account.
9
11
  *
@@ -63,6 +65,8 @@ export declare class ActorCollectionClient extends ResourceCollectionClient {
63
65
  create(actor: ActorCollectionCreateOptions): Promise<Actor>;
64
66
  }
65
67
  /**
68
+ * Field to order a list of Actors by.
69
+ *
66
70
  * @since Added in 2.12.6
67
71
  */
68
72
  export declare enum ActorListSortBy {
@@ -75,14 +79,7 @@ export interface ActorCollectionListOptions extends PaginationOptions {
75
79
  /**
76
80
  * @since Added in 2.12.6
77
81
  */
78
- sortBy?: ActorListSortBy;
79
- }
80
- export interface ActorCollectionListItem {
81
- id: string;
82
- createdAt: Date;
83
- modifiedAt: Date;
84
- name: string;
85
- username: string;
82
+ sortBy?: `${ActorListSortBy}`;
86
83
  }
87
84
  export type ActorCollectionListResult = PaginatedList<ActorCollectionListItem>;
88
85
  export interface ActorCollectionCreateOptions {
@@ -105,8 +102,6 @@ export interface ActorCollectionCreateOptions {
105
102
  isDeprecated?: boolean;
106
103
  isPublic?: boolean;
107
104
  name?: string;
108
- /** @deprecated Use defaultRunOptions.restartOnError instead */
109
- restartOnError?: boolean;
110
105
  /**
111
106
  * @since Added in 2.8.6
112
107
  */
@@ -1,10 +1,8 @@
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 { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
5
+ const actorCreateSchema = anyObjectSchema.optional();
8
6
  /**
9
7
  * Client for managing the collection of Actors in your account.
10
8
  *
@@ -28,7 +26,7 @@ const actorCreateSchema = utils_1.anyObjectSchema.optional();
28
26
  *
29
27
  * @see https://docs.apify.com/platform/actors
30
28
  */
31
- class ActorCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
29
+ export class ActorCollectionClient extends ResourceCollectionClient {
32
30
  /**
33
31
  * @hidden
34
32
  */
@@ -59,8 +57,8 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
59
57
  * @see https://docs.apify.com/api/v2/acts-get
60
58
  */
61
59
  list(options = {}) {
62
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'ActorCollectionListOptions');
63
- return this._listPaginated(parsed);
60
+ const parsed = parseArgument(options, listOptionsSchema, 'ActorCollectionListOptions');
61
+ return this._listPaginated(schemas.ListOfActors(), parsed);
64
62
  }
65
63
  /**
66
64
  * Creates a new Actor.
@@ -70,23 +68,24 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
70
68
  * @see https://docs.apify.com/api/v2/acts-post
71
69
  */
72
70
  async create(actor) {
73
- (0, utils_1.parseArgument)(actor, actorCreateSchema);
74
- return this._create(actor);
71
+ parseArgument(actor, actorCreateSchema);
72
+ return this._create(schemas.Actor(), actor);
75
73
  }
76
74
  }
77
- exports.ActorCollectionClient = ActorCollectionClient;
78
75
  /**
76
+ * Field to order a list of Actors by.
77
+ *
79
78
  * @since Added in 2.12.6
80
79
  */
81
- var ActorListSortBy;
80
+ export var ActorListSortBy;
82
81
  (function (ActorListSortBy) {
83
82
  ActorListSortBy["CREATED_AT"] = "createdAt";
84
83
  ActorListSortBy["LAST_RUN_STARTED_AT"] = "stats.lastRunStartedAt";
85
- })(ActorListSortBy || (exports.ActorListSortBy = ActorListSortBy = {}));
84
+ })(ActorListSortBy || (ActorListSortBy = {}));
86
85
  // 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(),
86
+ const listOptionsSchema = z.strictObject({
87
+ my: z.boolean().optional(),
88
+ ...paginationOptionsShape,
89
+ desc: z.boolean().optional(),
90
+ sortBy: z.enum(ActorListSortBy).optional(),
92
91
  });
@@ -1,6 +1,6 @@
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 { ActorEnvironmentVariable } from './actor_version.js';
4
4
  /**
5
5
  * Client for managing a specific Actor environment variable.
6
6
  *
@@ -1,8 +1,6 @@
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 { anyObjectSchema, parseArgument } from '../utils.js';
6
4
  /**
7
5
  * Client for managing a specific Actor environment variable.
8
6
  *
@@ -26,7 +24,7 @@ const utils_1 = require("../utils");
26
24
  * @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
27
25
  * @since Added in 2.1.0
28
26
  */
29
- class ActorEnvVarClient extends resource_client_1.ResourceClient {
27
+ export class ActorEnvVarClient extends ResourceClient {
30
28
  /**
31
29
  * @hidden
32
30
  */
@@ -43,7 +41,7 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
43
41
  * @see https://docs.apify.com/api/v2/act-version-env-var-get
44
42
  */
45
43
  async get() {
46
- return this._get();
44
+ return this._get(schemas.EnvVar());
47
45
  }
48
46
  /**
49
47
  * Updates the environment variable.
@@ -53,8 +51,8 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
53
51
  * @see https://docs.apify.com/api/v2/act-version-env-var-put
54
52
  */
55
53
  async update(actorEnvVar) {
56
- (0, utils_1.parseArgument)(actorEnvVar, utils_1.anyObjectSchema);
57
- return this._update(actorEnvVar);
54
+ parseArgument(actorEnvVar, anyObjectSchema);
55
+ return this._update(schemas.EnvVar(), actorEnvVar);
58
56
  }
59
57
  /**
60
58
  * Deletes the environment variable.
@@ -65,4 +63,3 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
65
63
  return this._delete();
66
64
  }
67
65
  }
68
- exports.ActorEnvVarClient = ActorEnvVarClient;
@@ -1,7 +1,7 @@
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 { PaginatedList } from '../utils.js';
4
+ import type { ActorEnvironmentVariable } from './actor_version.js';
5
5
  /**
6
6
  * Client for managing the collection of environment variables for an Actor version.
7
7
  *
@@ -37,23 +37,22 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
37
37
  /**
38
38
  * Lists all environment variables of this Actor version.
39
39
  *
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.
40
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
41
+ * with a Promise) gets the whole list.
42
42
  * ```javascript
43
- * const paginatedList = await client.list();
44
- *```
43
+ * const { items } = await client.list();
44
+ * ```
45
45
  *
46
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
47
- * retrieved.
46
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
48
47
  *
49
48
  * ```javascript
50
49
  * for await (const singleItem of client.list()) {...}
51
50
  * ```
52
51
  *
53
- * @returns A paginated iterator of environment variables.
52
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
54
53
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
55
54
  */
56
- list(_options?: ActorEnvVarCollectionListOptions): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
55
+ list(): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable>;
57
56
  /**
58
57
  * Creates a new environment variable for this Actor version.
59
58
  *
@@ -63,14 +62,6 @@ export declare class ActorEnvVarCollectionClient extends ResourceCollectionClien
63
62
  */
64
63
  create(actorEnvVar: ActorEnvironmentVariable): Promise<ActorEnvironmentVariable>;
65
64
  }
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;
73
- }
74
65
  /**
75
66
  * @since Added in 2.1.0
76
67
  */
@@ -1,9 +1,7 @@
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 { anyObjectSchema, parseArgument } from '../utils.js';
4
+ const actorEnvVarSchema = anyObjectSchema.optional();
7
5
  /**
8
6
  * Client for managing the collection of environment variables for an Actor version.
9
7
  *
@@ -31,7 +29,7 @@ const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
31
29
  * @see https://docs.apify.com/platform/actors/development/programming-interface/environment-variables
32
30
  * @since Added in 2.1.0
33
31
  */
34
- class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
32
+ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
35
33
  /**
36
34
  * @hidden
37
35
  */
@@ -44,24 +42,23 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
44
42
  /**
45
43
  * Lists all environment variables of this Actor version.
46
44
  *
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.
45
+ * The endpoint returns every environment variable in one response, so awaiting the return value (as you would
46
+ * with a Promise) gets the whole list.
49
47
  * ```javascript
50
- * const paginatedList = await client.list();
51
- *```
48
+ * const { items } = await client.list();
49
+ * ```
52
50
  *
53
- * Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
54
- * retrieved.
51
+ * Asynchronous iteration is also supported, and yields the environment variables one by one.
55
52
  *
56
53
  * ```javascript
57
54
  * for await (const singleItem of client.list()) {...}
58
55
  * ```
59
56
  *
60
- * @returns A paginated iterator of environment variables.
57
+ * @returns The environment variables, awaitable as a whole list or iterable one by one.
61
58
  * @see https://docs.apify.com/api/v2/act-version-env-vars-get
62
59
  */
63
- list(_options = {}) {
64
- return this._listPaginated();
60
+ list() {
61
+ return this._listPaginated(schemas.ListOfEnvVars());
65
62
  }
66
63
  /**
67
64
  * Creates a new environment variable for this Actor version.
@@ -71,8 +68,7 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
71
68
  * @see https://docs.apify.com/api/v2/act-version-env-vars-post
72
69
  */
73
70
  async create(actorEnvVar) {
74
- (0, utils_1.parseArgument)(actorEnvVar, actorEnvVarSchema);
75
- return this._create(actorEnvVar);
71
+ parseArgument(actorEnvVar, actorEnvVarSchema);
72
+ return this._create(schemas.EnvVar(), actorEnvVar);
76
73
  }
77
74
  }
78
- exports.ActorEnvVarCollectionClient = ActorEnvVarCollectionClient;
@@ -1,7 +1,10 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import { ActorEnvVarClient } from './actor_env_var';
4
- import { ActorEnvVarCollectionClient } from './actor_env_var_collection';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { ActorVersion, FinalActorVersion } from '../models.js';
4
+ import { ActorEnvVarClient } from './actor_env_var.js';
5
+ import { ActorEnvVarCollectionClient } from './actor_env_var_collection.js';
6
+ export type { ActorEnvironmentVariable, ActorVersion, ActorVersionGitHubGist, ActorVersionGitRepo, ActorVersionSourceCode, ActorVersionSourceFile, ActorVersionSourceFiles, ActorVersionSourceFolder, ActorVersionTarball, BaseActorVersion, FinalActorVersion, } from '../models.js';
7
+ export { ActorSourceType } from '../models.js';
5
8
  /**
6
9
  * Client for managing a specific Actor version.
7
10
  *
@@ -42,7 +45,7 @@ export declare class ActorVersionClient extends ResourceClient {
42
45
  * @returns The updated Actor version object.
43
46
  * @see https://docs.apify.com/api/v2/act-version-put
44
47
  */
45
- update(newFields: ActorVersion): Promise<FinalActorVersion>;
48
+ update(newFields: ActorVersionUpdateData): Promise<FinalActorVersion>;
46
49
  /**
47
50
  * Deletes the Actor version.
48
51
  *
@@ -67,43 +70,11 @@ export declare class ActorVersionClient extends ResourceClient {
67
70
  */
68
71
  envVars(): ActorEnvVarCollectionClient;
69
72
  }
70
- export interface BaseActorVersion<SourceType extends ActorSourceType> {
71
- versionNumber?: string;
72
- sourceType: SourceType;
73
- envVars?: ActorEnvironmentVariable[];
74
- applyEnvVarsToBuild?: boolean;
75
- buildTag?: string;
76
- }
77
73
  /**
78
- * @since Added in 2.6.1
74
+ * Fields that can be changed on an existing Actor version.
75
+ *
76
+ * All of them are optional, because the endpoint leaves untouched whatever the payload does not
77
+ * mention. The version union enforces the pairing: a `sourceType` can only be sent next to the
78
+ * source location it implies, never next to one of the other three.
79
79
  */
80
- export interface ActorVersionSourceFiles extends BaseActorVersion<ActorSourceType.SourceFiles> {
81
- sourceFiles: ActorVersionSourceFile[];
82
- }
83
- export interface ActorVersionSourceFile {
84
- name: string;
85
- format: 'TEXT' | 'BASE64';
86
- content: string;
87
- }
88
- export interface ActorVersionGitRepo extends BaseActorVersion<ActorSourceType.GitRepo> {
89
- gitRepoUrl: string;
90
- }
91
- export interface ActorVersionTarball extends BaseActorVersion<ActorSourceType.Tarball> {
92
- tarballUrl: string;
93
- }
94
- export interface ActorVersionGitHubGist extends BaseActorVersion<ActorSourceType.GitHubGist> {
95
- gitHubGistUrl: string;
96
- }
97
- export declare enum ActorSourceType {
98
- SourceFiles = "SOURCE_FILES",
99
- GitRepo = "GIT_REPO",
100
- Tarball = "TARBALL",
101
- GitHubGist = "GITHUB_GIST"
102
- }
103
- export interface ActorEnvironmentVariable {
104
- name?: string;
105
- value?: string;
106
- isSecret?: boolean;
107
- }
108
- export type ActorVersion = ActorVersionSourceFiles | ActorVersionGitRepo | ActorVersionTarball | ActorVersionGitHubGist;
109
- export type FinalActorVersion = ActorVersion & Required<Pick<ActorVersion, 'versionNumber' | 'buildTag'>>;
80
+ export type ActorVersionUpdateData = Partial<ActorVersion>;