apify-client 2.25.1-beta.8 → 3.0.0-beta.1

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 (60) hide show
  1. package/dist/apify_client.js +34 -30
  2. package/dist/argument_validation_error.d.ts +17 -0
  3. package/dist/argument_validation_error.js +157 -0
  4. package/dist/base/api_client.d.ts +2 -2
  5. package/dist/base/api_client.js +13 -10
  6. package/dist/bundle.js +66 -28147
  7. package/dist/bundle.js.LICENSE.txt +33 -0
  8. package/dist/bundle.js.map +1 -1
  9. package/dist/generated/api.d.ts +20522 -0
  10. package/dist/generated/api.js +6 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +1 -0
  13. package/dist/index.mjs +1 -0
  14. package/dist/models.d.ts +1072 -0
  15. package/dist/models.js +89 -0
  16. package/dist/resource_clients/actor.d.ts +2 -448
  17. package/dist/resource_clients/actor.js +60 -55
  18. package/dist/resource_clients/actor_collection.d.ts +2 -7
  19. package/dist/resource_clients/actor_collection.js +13 -11
  20. package/dist/resource_clients/actor_env_var.js +2 -3
  21. package/dist/resource_clients/actor_env_var_collection.js +3 -3
  22. package/dist/resource_clients/actor_version.d.ts +3 -40
  23. package/dist/resource_clients/actor_version.js +8 -12
  24. package/dist/resource_clients/actor_version_collection.js +3 -3
  25. package/dist/resource_clients/build.d.ts +2 -77
  26. package/dist/resource_clients/build.js +7 -10
  27. package/dist/resource_clients/build_collection.d.ts +2 -2
  28. package/dist/resource_clients/build_collection.js +8 -8
  29. package/dist/resource_clients/dataset.d.ts +8 -72
  30. package/dist/resource_clients/dataset.js +66 -57
  31. package/dist/resource_clients/dataset_collection.js +14 -12
  32. package/dist/resource_clients/key_value_store.d.ts +5 -73
  33. package/dist/resource_clients/key_value_store.js +69 -51
  34. package/dist/resource_clients/key_value_store_collection.js +14 -12
  35. package/dist/resource_clients/request_queue.d.ts +15 -174
  36. package/dist/resource_clients/request_queue.js +85 -91
  37. package/dist/resource_clients/request_queue_collection.js +12 -11
  38. package/dist/resource_clients/run.js +39 -40
  39. package/dist/resource_clients/run_collection.js +12 -11
  40. package/dist/resource_clients/schedule.d.ts +3 -81
  41. package/dist/resource_clients/schedule.js +4 -12
  42. package/dist/resource_clients/schedule_collection.js +10 -9
  43. package/dist/resource_clients/store_collection.d.ts +2 -30
  44. package/dist/resource_clients/store_collection.js +13 -13
  45. package/dist/resource_clients/task.d.ts +3 -73
  46. package/dist/resource_clients/task.js +36 -33
  47. package/dist/resource_clients/task_collection.d.ts +2 -1
  48. package/dist/resource_clients/task_collection.js +9 -9
  49. package/dist/resource_clients/user.d.ts +3 -179
  50. package/dist/resource_clients/user.js +3 -11
  51. package/dist/resource_clients/webhook.d.ts +2 -61
  52. package/dist/resource_clients/webhook.js +1 -3
  53. package/dist/resource_clients/webhook_collection.js +10 -9
  54. package/dist/resource_clients/webhook_dispatch.d.ts +3 -36
  55. package/dist/resource_clients/webhook_dispatch.js +3 -7
  56. package/dist/resource_clients/webhook_dispatch_collection.js +8 -8
  57. package/dist/statistics.js +4 -3
  58. package/dist/utils.d.ts +51 -5
  59. package/dist/utils.js +103 -15
  60. package/package.json +22 -7
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
5
  const consts_1 = require("@apify/consts");
7
6
  const log_1 = require("@apify/log");
8
7
  const resource_client_1 = require("../base/resource_client");
@@ -14,6 +13,46 @@ const build_collection_1 = require("./build_collection");
14
13
  const run_1 = require("./run");
15
14
  const run_collection_1 = require("./run_collection");
16
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(),
27
+ });
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(),
40
+ });
41
+ const validateInputOptionsSchema = zod_1.z.strictObject({
42
+ build: zod_1.z.string().optional(),
43
+ contentType: zod_1.z.string().optional(),
44
+ });
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(),
51
+ });
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(),
55
+ });
17
56
  /**
18
57
  * Client for managing a specific Actor.
19
58
  *
@@ -61,7 +100,7 @@ class ActorClient extends resource_client_1.ResourceClient {
61
100
  * @see https://docs.apify.com/api/v2/act-put
62
101
  */
63
102
  async update(newFields) {
64
- (0, ow_1.default)(newFields, ow_1.default.object);
103
+ (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
65
104
  return this._update(newFields);
66
105
  }
67
106
  /**
@@ -109,25 +148,14 @@ class ActorClient extends resource_client_1.ResourceClient {
109
148
  async start(input, options = {}) {
110
149
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
111
150
  // then it will process input as a buffer.
112
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
113
- build: ow_1.default.optional.string,
114
- contentType: ow_1.default.optional.string,
115
- memory: ow_1.default.optional.number,
116
- timeout: ow_1.default.optional.number,
117
- waitForFinish: ow_1.default.optional.number,
118
- webhooks: ow_1.default.optional.array.ofType(ow_1.default.object),
119
- maxItems: ow_1.default.optional.number.not.negative,
120
- maxTotalChargeUsd: ow_1.default.optional.number.not.negative,
121
- restartOnError: ow_1.default.optional.boolean,
122
- forcePermissionLevel: ow_1.default.optional.string.oneOf(Object.values(consts_1.ACTOR_PERMISSION_LEVEL)),
123
- }));
124
- const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = options;
151
+ const parsed = (0, utils_1.parseArgument)(options, startOptionsSchema, 'ActorStartOptions');
152
+ const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError, forcePermissionLevel, } = parsed;
125
153
  const params = {
126
154
  waitForFinish,
127
155
  timeout,
128
156
  memory,
129
157
  build,
130
- webhooks: (0, utils_1.stringifyWebhooksToBase64)(options.webhooks),
158
+ webhooks: (0, utils_1.stringifyWebhooksToBase64)(parsed.webhooks),
131
159
  maxItems,
132
160
  maxTotalChargeUsd,
133
161
  restartOnError,
@@ -142,9 +170,9 @@ class ActorClient extends resource_client_1.ResourceClient {
142
170
  // to stringify functions to JSON, instead of omitting them.
143
171
  stringifyFunctions: true,
144
172
  };
145
- if (options.contentType) {
173
+ if (parsed.contentType) {
146
174
  request.headers = {
147
- 'content-type': options.contentType,
175
+ 'content-type': parsed.contentType,
148
176
  };
149
177
  }
150
178
  const response = await this.httpClient.call(request);
@@ -190,26 +218,14 @@ class ActorClient extends resource_client_1.ResourceClient {
190
218
  async call(input, options = {}) {
191
219
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
192
220
  // then it will process input as a buffer.
193
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
194
- build: ow_1.default.optional.string,
195
- contentType: ow_1.default.optional.string,
196
- memory: ow_1.default.optional.number,
197
- timeout: ow_1.default.optional.number.not.negative,
198
- waitSecs: ow_1.default.optional.number.not.negative,
199
- webhooks: ow_1.default.optional.array.ofType(ow_1.default.object),
200
- maxItems: ow_1.default.optional.number.not.negative,
201
- maxTotalChargeUsd: ow_1.default.optional.number.not.negative,
202
- log: ow_1.default.optional.any(ow_1.default.null, ow_1.default.object.instanceOf(log_1.Log), ow_1.default.string.equals('default')),
203
- restartOnError: ow_1.default.optional.boolean,
204
- forcePermissionLevel: ow_1.default.optional.string.oneOf(Object.values(consts_1.ACTOR_PERMISSION_LEVEL)),
205
- }));
206
- const { waitSecs, log, ...startOptions } = options;
221
+ const parsed = (0, utils_1.parseArgument)(options, callOptionsSchema, 'ActorCallOptions');
222
+ const { waitSecs, log, ...startOptions } = parsed;
207
223
  const { id } = await this.start(input, startOptions);
208
224
  // Calling root client because we need access to top level API.
209
225
  // Creating a new instance of RunClient here would only allow
210
226
  // setting it up as a nested route under actor API.
211
227
  const newRunClient = this.apifyClient.run(id);
212
- const streamedLog = await newRunClient.getStreamedLog({ toLog: options?.log });
228
+ const streamedLog = await newRunClient.getStreamedLog({ toLog: log });
213
229
  streamedLog?.start();
214
230
  return this.apifyClient
215
231
  .run(id)
@@ -252,22 +268,19 @@ class ActorClient extends resource_client_1.ResourceClient {
252
268
  async validateInput(input, options = {}) {
253
269
  // input can be anything, so no point in validating it. E.g. if you set content-type to application/pdf
254
270
  // then it will process input as a buffer.
255
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
256
- build: ow_1.default.optional.string,
257
- contentType: ow_1.default.optional.string,
258
- }));
271
+ const parsed = (0, utils_1.parseArgument)(options, validateInputOptionsSchema, 'ActorValidateInputOptions');
259
272
  const request = {
260
273
  url: this._url('validate-input'),
261
274
  method: 'POST',
262
275
  data: input,
263
- params: this._params({ build: options.build }),
276
+ params: this._params({ build: parsed.build }),
264
277
  // Apify internal property. Tells the request serialization interceptor
265
278
  // to stringify functions to JSON, instead of omitting them.
266
279
  stringifyFunctions: true,
267
280
  };
268
- if (options.contentType) {
281
+ if (parsed.contentType) {
269
282
  request.headers = {
270
- 'content-type': options.contentType,
283
+ 'content-type': parsed.contentType,
271
284
  };
272
285
  }
273
286
  const response = await this.httpClient.call(request);
@@ -303,19 +316,14 @@ class ActorClient extends resource_client_1.ResourceClient {
303
316
  * ```
304
317
  */
305
318
  async build(versionNumber, options = {}) {
306
- (0, ow_1.default)(versionNumber, ow_1.default.string);
307
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
308
- betaPackages: ow_1.default.optional.boolean,
309
- tag: ow_1.default.optional.string,
310
- useCache: ow_1.default.optional.boolean,
311
- waitForFinish: ow_1.default.optional.number,
312
- }));
319
+ (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
320
+ const parsed = (0, utils_1.parseArgument)(options, buildOptionsSchema, 'ActorBuildOptions');
313
321
  const response = await this.httpClient.call({
314
322
  url: this._url('builds'),
315
323
  method: 'POST',
316
324
  params: this._params({
317
325
  version: versionNumber,
318
- ...options,
326
+ ...parsed,
319
327
  }),
320
328
  });
321
329
  return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
@@ -378,13 +386,10 @@ class ActorClient extends resource_client_1.ResourceClient {
378
386
  * ```
379
387
  */
380
388
  lastRun(options = {}) {
381
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
382
- status: ow_1.default.optional.string.oneOf(Object.values(consts_1.ACTOR_JOB_STATUSES)),
383
- origin: ow_1.default.optional.string.oneOf(Object.values(consts_1.META_ORIGINS)),
384
- }));
389
+ const parsed = (0, utils_1.parseArgument)(options, lastRunOptionsSchema, 'ActorLastRunOptions');
385
390
  return new run_1.RunClient(this._subResourceOptions({
386
391
  id: 'last',
387
- params: this._params(options),
392
+ params: this._params(parsed),
388
393
  resourcePath: 'runs',
389
394
  }));
390
395
  }
@@ -418,7 +423,7 @@ class ActorClient extends resource_client_1.ResourceClient {
418
423
  * @see https://docs.apify.com/api/v2/act-version-get
419
424
  */
420
425
  version(versionNumber) {
421
- (0, ow_1.default)(versionNumber, ow_1.default.string);
426
+ (0, utils_1.parseArgument)(versionNumber, versionNumberSchema);
422
427
  return new actor_version_1.ActorVersionClient(this._subResourceOptions({
423
428
  id: versionNumber,
424
429
  }));
@@ -1,9 +1,11 @@
1
1
  import type { ACTOR_PERMISSION_LEVEL } from '@apify/consts';
2
2
  import type { ApiClientSubResourceOptions } from '../base/api_client';
3
3
  import { ResourceCollectionClient } from '../base/resource_collection_client';
4
+ import type { ActorCollectionListItem } from '../models';
4
5
  import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils';
5
6
  import type { Actor, ActorDefaultRunOptions, ActorExampleRunInput, ActorStandby } from './actor';
6
7
  import type { ActorVersion } from './actor_version';
8
+ export type { ActorCollectionListItem } from '../models';
7
9
  /**
8
10
  * Client for managing the collection of Actors in your account.
9
11
  *
@@ -77,13 +79,6 @@ export interface ActorCollectionListOptions extends PaginationOptions {
77
79
  */
78
80
  sortBy?: ActorListSortBy;
79
81
  }
80
- export interface ActorCollectionListItem {
81
- id: string;
82
- createdAt: Date;
83
- modifiedAt: Date;
84
- name: string;
85
- username: string;
86
- }
87
82
  export type ActorCollectionListResult = PaginatedList<ActorCollectionListItem>;
88
83
  export interface ActorCollectionCreateOptions {
89
84
  /**
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorListSortBy = exports.ActorCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
5
  const resource_collection_client_1 = require("../base/resource_collection_client");
6
+ const utils_1 = require("../utils");
7
+ const actorCreateSchema = utils_1.anyObjectSchema.optional();
7
8
  /**
8
9
  * Client for managing the collection of Actors in your account.
9
10
  *
@@ -58,14 +59,8 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
58
59
  * @see https://docs.apify.com/api/v2/acts-get
59
60
  */
60
61
  list(options = {}) {
61
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
62
- my: ow_1.default.optional.boolean,
63
- limit: ow_1.default.optional.number.not.negative,
64
- offset: ow_1.default.optional.number.not.negative,
65
- desc: ow_1.default.optional.boolean,
66
- sortBy: ow_1.default.optional.string.oneOf(Object.values(ActorListSortBy)),
67
- }));
68
- return this._listPaginated(options);
62
+ const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'ActorCollectionListOptions');
63
+ return this._listPaginated(parsed);
69
64
  }
70
65
  /**
71
66
  * Creates a new Actor.
@@ -75,7 +70,7 @@ class ActorCollectionClient extends resource_collection_client_1.ResourceCollect
75
70
  * @see https://docs.apify.com/api/v2/acts-post
76
71
  */
77
72
  async create(actor) {
78
- (0, ow_1.default)(actor, ow_1.default.optional.object);
73
+ (0, utils_1.parseArgument)(actor, actorCreateSchema);
79
74
  return this._create(actor);
80
75
  }
81
76
  }
@@ -88,3 +83,10 @@ var ActorListSortBy;
88
83
  ActorListSortBy["CREATED_AT"] = "createdAt";
89
84
  ActorListSortBy["LAST_RUN_STARTED_AT"] = "stats.lastRunStartedAt";
90
85
  })(ActorListSortBy || (exports.ActorListSortBy = ActorListSortBy = {}));
86
+ // 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(),
92
+ });
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorEnvVarClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
4
  const resource_client_1 = require("../base/resource_client");
5
+ const utils_1 = require("../utils");
7
6
  /**
8
7
  * Client for managing a specific Actor environment variable.
9
8
  *
@@ -54,7 +53,7 @@ class ActorEnvVarClient extends resource_client_1.ResourceClient {
54
53
  * @see https://docs.apify.com/api/v2/act-version-env-var-put
55
54
  */
56
55
  async update(actorEnvVar) {
57
- (0, ow_1.default)(actorEnvVar, ow_1.default.object);
56
+ (0, utils_1.parseArgument)(actorEnvVar, utils_1.anyObjectSchema);
58
57
  return this._update(actorEnvVar);
59
58
  }
60
59
  /**
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorEnvVarCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
4
  const resource_collection_client_1 = require("../base/resource_collection_client");
5
+ const utils_1 = require("../utils");
6
+ const actorEnvVarSchema = utils_1.anyObjectSchema.optional();
7
7
  /**
8
8
  * Client for managing the collection of environment variables for an Actor version.
9
9
  *
@@ -71,7 +71,7 @@ class ActorEnvVarCollectionClient extends resource_collection_client_1.ResourceC
71
71
  * @see https://docs.apify.com/api/v2/act-version-env-vars-post
72
72
  */
73
73
  async create(actorEnvVar) {
74
- (0, ow_1.default)(actorEnvVar, ow_1.default.optional.object);
74
+ (0, utils_1.parseArgument)(actorEnvVar, actorEnvVarSchema);
75
75
  return this._create(actorEnvVar);
76
76
  }
77
77
  }
@@ -1,7 +1,10 @@
1
1
  import type { ApiClientSubResourceOptions } from '../base/api_client';
2
2
  import { ResourceClient } from '../base/resource_client';
3
+ import type { ActorVersion, FinalActorVersion } from '../models';
3
4
  import { ActorEnvVarClient } from './actor_env_var';
4
5
  import { ActorEnvVarCollectionClient } from './actor_env_var_collection';
6
+ export type { ActorEnvironmentVariable, ActorVersion, ActorVersionGitHubGist, ActorVersionGitRepo, ActorVersionSourceCode, ActorVersionSourceFile, ActorVersionSourceFiles, ActorVersionSourceFolder, ActorVersionTarball, BaseActorVersion, FinalActorVersion, } from '../models';
7
+ export { ActorSourceType } from '../models';
5
8
  /**
6
9
  * Client for managing a specific Actor version.
7
10
  *
@@ -67,43 +70,3 @@ 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
- /**
78
- * @since Added in 2.6.1
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'>>;
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorSourceType = exports.ActorVersionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
3
+ exports.ActorVersionClient = exports.ActorSourceType = void 0;
4
+ const zod_1 = require("zod");
6
5
  const resource_client_1 = require("../base/resource_client");
6
+ const utils_1 = require("../utils");
7
7
  const actor_env_var_1 = require("./actor_env_var");
8
8
  const actor_env_var_collection_1 = require("./actor_env_var_collection");
9
+ const envVarNameSchema = zod_1.z.string();
10
+ var models_1 = require("../models");
11
+ Object.defineProperty(exports, "ActorSourceType", { enumerable: true, get: function () { return models_1.ActorSourceType; } });
9
12
  /**
10
13
  * Client for managing a specific Actor version.
11
14
  *
@@ -54,7 +57,7 @@ class ActorVersionClient extends resource_client_1.ResourceClient {
54
57
  * @see https://docs.apify.com/api/v2/act-version-put
55
58
  */
56
59
  async update(newFields) {
57
- (0, ow_1.default)(newFields, ow_1.default.object);
60
+ (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
58
61
  return this._update(newFields);
59
62
  }
60
63
  /**
@@ -74,7 +77,7 @@ class ActorVersionClient extends resource_client_1.ResourceClient {
74
77
  * @since Added in 2.1.0
75
78
  */
76
79
  envVar(envVarName) {
77
- (0, ow_1.default)(envVarName, ow_1.default.string);
80
+ (0, utils_1.parseArgument)(envVarName, envVarNameSchema);
78
81
  return new actor_env_var_1.ActorEnvVarClient(this._subResourceOptions({
79
82
  id: envVarName,
80
83
  }));
@@ -91,10 +94,3 @@ class ActorVersionClient extends resource_client_1.ResourceClient {
91
94
  }
92
95
  }
93
96
  exports.ActorVersionClient = ActorVersionClient;
94
- var ActorSourceType;
95
- (function (ActorSourceType) {
96
- ActorSourceType["SourceFiles"] = "SOURCE_FILES";
97
- ActorSourceType["GitRepo"] = "GIT_REPO";
98
- ActorSourceType["Tarball"] = "TARBALL";
99
- ActorSourceType["GitHubGist"] = "GITHUB_GIST";
100
- })(ActorSourceType || (exports.ActorSourceType = ActorSourceType = {}));
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorVersionCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
4
  const resource_collection_client_1 = require("../base/resource_collection_client");
5
+ const utils_1 = require("../utils");
6
+ const actorVersionSchema = utils_1.anyObjectSchema.optional();
7
7
  /**
8
8
  * Client for managing the collection of Actor versions.
9
9
  *
@@ -68,7 +68,7 @@ class ActorVersionCollectionClient extends resource_collection_client_1.Resource
68
68
  * @see https://docs.apify.com/api/v2/act-versions-post
69
69
  */
70
70
  async create(actorVersion) {
71
- (0, ow_1.default)(actorVersion, ow_1.default.optional.object);
71
+ (0, utils_1.parseArgument)(actorVersion, actorVersionSchema);
72
72
  return this._create(actorVersion);
73
73
  }
74
74
  }
@@ -1,8 +1,8 @@
1
- import type { ACT_JOB_TERMINAL_STATUSES } from '@apify/consts';
2
1
  import type { ApiClientSubResourceOptions } from '../base/api_client';
3
2
  import { ResourceClient } from '../base/resource_client';
4
- import type { ActorDefinition } from './actor';
3
+ import type { Build } from '../models';
5
4
  import { LogClient } from './log';
5
+ export type { Build, BuildMeta, BuildOptions, BuildStats, BuildUsage } from '../models';
6
6
  /**
7
7
  * Client for managing a specific Actor build.
8
8
  *
@@ -143,80 +143,6 @@ export interface BuildClientWaitForFinishOptions {
143
143
  */
144
144
  waitSecs?: number;
145
145
  }
146
- /**
147
- * Metadata about how a Build was initiated.
148
- */
149
- export interface BuildMeta {
150
- origin: string;
151
- clientIp: string;
152
- userAgent: string;
153
- }
154
- /**
155
- * Represents an Actor build.
156
- *
157
- * Builds compile Actor source code and prepare it for execution. Each build has a unique ID
158
- * and can be tagged (e.g., 'latest', 'beta') for easy reference.
159
- */
160
- export interface Build {
161
- id: string;
162
- actId: string;
163
- userId: string;
164
- startedAt: Date;
165
- finishedAt?: Date;
166
- status: (typeof ACT_JOB_TERMINAL_STATUSES)[number];
167
- meta: BuildMeta;
168
- stats?: BuildStats;
169
- options?: BuildOptions;
170
- /**
171
- * @deprecated This property is deprecated in favor of `actorDefinition.input`.
172
- */
173
- inputSchema?: string;
174
- /**
175
- * @deprecated This property is deprecated in favor of `actorDefinition.readme`.
176
- */
177
- readme?: string;
178
- buildNumber: string;
179
- /**
180
- * @since Added in 2.7.2
181
- */
182
- usage?: BuildUsage;
183
- /**
184
- * @since Added in 2.7.2
185
- */
186
- usageTotalUsd?: number;
187
- /**
188
- * @since Added in 2.7.2
189
- */
190
- usageUsd?: BuildUsage;
191
- /**
192
- * @since Added in 2.11.0
193
- */
194
- actorDefinition?: ActorDefinition;
195
- }
196
- /**
197
- * Resource usage for an Actor build.
198
- * @since Added in 2.7.2
199
- */
200
- export interface BuildUsage {
201
- ACTOR_COMPUTE_UNITS?: number;
202
- }
203
- /**
204
- * Runtime statistics for an Actor build.
205
- */
206
- export interface BuildStats {
207
- durationMillis: number;
208
- runTimeSecs: number;
209
- computeUnits: number;
210
- }
211
- /**
212
- * Configuration options used for an Actor build.
213
- */
214
- export interface BuildOptions {
215
- useCache?: boolean;
216
- betaPackages?: boolean;
217
- memoryMbytes?: number;
218
- diskMbytes?: number;
219
- }
220
146
  /**
221
147
  * OpenAPI specification for an Actor.
222
148
  *
@@ -283,4 +209,3 @@ interface OpenApiOperation {
283
209
  };
284
210
  };
285
211
  }
286
- export {};
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
5
  const resource_client_1 = require("../base/resource_client");
7
6
  const utils_1 = require("../utils");
8
7
  const log_1 = require("./log");
8
+ const getOptionsSchema = zod_1.z.strictObject({ waitForFinish: zod_1.z.number().optional() });
9
+ const waitForFinishOptionsSchema = zod_1.z.strictObject({ waitSecs: zod_1.z.number().optional() });
9
10
  /**
10
11
  * Client for managing a specific Actor build.
11
12
  *
@@ -58,10 +59,8 @@ class BuildClient extends resource_client_1.ResourceClient {
58
59
  * ```
59
60
  */
60
61
  async get(options = {}) {
61
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
62
- waitForFinish: ow_1.default.optional.number,
63
- }));
64
- return this._get(options);
62
+ const parsed = (0, utils_1.parseArgument)(options, getOptionsSchema, 'BuildClientGetOptions');
63
+ return this._get(parsed);
65
64
  }
66
65
  /**
67
66
  * Aborts the Actor build.
@@ -139,10 +138,8 @@ class BuildClient extends resource_client_1.ResourceClient {
139
138
  * ```
140
139
  */
141
140
  async waitForFinish(options = {}) {
142
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
143
- waitSecs: ow_1.default.optional.number,
144
- }));
145
- return this._waitForFinish(options);
141
+ const parsed = (0, utils_1.parseArgument)(options, waitForFinishOptionsSchema, 'BuildClientWaitForFinishOptions');
142
+ return this._waitForFinish(parsed);
146
143
  }
147
144
  /**
148
145
  * Returns a client for accessing the log of this Actor build.
@@ -1,7 +1,8 @@
1
1
  import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
2
2
  import { ResourceCollectionClient } from '../base/resource_collection_client';
3
+ import type { BuildCollectionClientListItem } from '../models';
3
4
  import type { PaginatedIterator, PaginatedList, PaginationOptions } from '../utils';
4
- import type { Build } from './build';
5
+ export type { BuildCollectionClientListItem } from '../models';
5
6
  /**
6
7
  * Client for managing the collection of Actor builds.
7
8
  *
@@ -53,5 +54,4 @@ export declare class BuildCollectionClient extends ResourceCollectionClient {
53
54
  export interface BuildCollectionClientListOptions extends PaginationOptions {
54
55
  desc?: boolean;
55
56
  }
56
- export type BuildCollectionClientListItem = Required<Pick<Build, 'id' | 'status' | 'startedAt' | 'finishedAt'>> & Partial<Pick<Build, 'meta' | 'usageTotalUsd'>>;
57
57
  export type BuildCollectionClientListResult = PaginatedList<BuildCollectionClientListItem>;
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildCollectionClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
4
+ const zod_1 = require("zod");
6
5
  const resource_collection_client_1 = require("../base/resource_collection_client");
6
+ const utils_1 = require("../utils");
7
+ const listOptionsSchema = zod_1.z.strictObject({
8
+ ...utils_1.paginationOptionsShape,
9
+ desc: zod_1.z.boolean().optional(),
10
+ });
7
11
  /**
8
12
  * Client for managing the collection of Actor builds.
9
13
  *
@@ -56,12 +60,8 @@ class BuildCollectionClient extends resource_collection_client_1.ResourceCollect
56
60
  * @see https://docs.apify.com/api/v2/actor-builds-get
57
61
  */
58
62
  list(options = {}) {
59
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
60
- limit: ow_1.default.optional.number.not.negative,
61
- offset: ow_1.default.optional.number.not.negative,
62
- desc: ow_1.default.optional.boolean,
63
- }));
64
- return this._listPaginated(options);
63
+ const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'BuildCollectionClientListOptions');
64
+ return this._listPaginated(parsed);
65
65
  }
66
66
  }
67
67
  exports.BuildCollectionClient = BuildCollectionClient;