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,10 +1,12 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { Dictionary } from '../utils';
4
- import type { ActorLastRunOptions, ActorRun, ActorStandby, ActorStartOptions } from './actor';
5
- import { RunClient } from './run';
6
- import { RunCollectionClient } from './run_collection';
7
- import { WebhookCollectionClient } from './webhook_collection';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { Task, TaskPublicConfig } from '../models.js';
4
+ import type { Dictionary } from '../utils.js';
5
+ import type { ActorLastRunOptions, ActorRun, ActorStartOptions } from './actor.js';
6
+ import { RunClient } from './run.js';
7
+ import { RunCollectionClient } from './run_collection.js';
8
+ import { WebhookCollectionClient } from './webhook_collection.js';
9
+ export type { Task, TaskOptions, TaskPublicConfig, TaskStats } from '../models.js';
8
10
  /**
9
11
  * Client for managing a specific Actor task.
10
12
  *
@@ -152,78 +154,6 @@ export declare class TaskClient extends ResourceClient {
152
154
  */
153
155
  webhooks(): WebhookCollectionClient;
154
156
  }
155
- /**
156
- * Represents an Actor task.
157
- *
158
- * Tasks are saved Actor configurations with input and settings that can be executed
159
- * repeatedly without having to specify the full input each time.
160
- */
161
- export interface Task {
162
- id: string;
163
- userId: string;
164
- actId: string;
165
- name: string;
166
- /**
167
- * @since Added in 2.6.1
168
- */
169
- title?: string;
170
- description?: string;
171
- username?: string;
172
- createdAt: Date;
173
- modifiedAt: Date;
174
- stats: TaskStats;
175
- options?: TaskOptions;
176
- input?: Dictionary | Dictionary[];
177
- /**
178
- * @since Added in 2.9.5
179
- */
180
- actorStandby?: Partial<ActorStandby>;
181
- /**
182
- * Whether the task is published on its public landing page. Derived from
183
- * `publicConfig.publishedAt` — set it on update to publish or unpublish the task.
184
- * @since Added in 2.25.0
185
- */
186
- isPublic?: boolean;
187
- /**
188
- * @since Added in 2.25.0
189
- */
190
- publicConfig?: TaskPublicConfig | null;
191
- }
192
- /**
193
- * Public-facing display configuration of a task's public landing page.
194
- *
195
- * The task is published when `publishedAt` is set and unpublished when it is `null`. The
196
- * `publishedAt` field is read-only - use {@apilink TaskClient.publish} and
197
- * {@apilink TaskClient.unpublish} to change the publication state.
198
- * @since Added in 2.25.0
199
- */
200
- export interface TaskPublicConfig {
201
- publishedAt: Date | null;
202
- seoTitle?: string | null;
203
- seoDescription?: string | null;
204
- categorization?: string | null;
205
- inputSchemaFields?: string[] | null;
206
- datasetName?: string | null;
207
- datasetView?: string | null;
208
- }
209
- /**
210
- * Statistics about Actor task usage.
211
- */
212
- export interface TaskStats {
213
- totalRuns: number;
214
- }
215
- /**
216
- * Configuration options for an Actor task.
217
- */
218
- export interface TaskOptions {
219
- build?: string;
220
- timeoutSecs?: number;
221
- memoryMbytes?: number;
222
- /**
223
- * @since Added in 2.19.0
224
- */
225
- restartOnError?: boolean;
226
- }
227
157
  /**
228
158
  * Fields that can be updated when modifying a Task.
229
159
  */
@@ -1,37 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskClient = void 0;
4
- const zod_1 = require("zod");
5
- const consts_1 = require("@apify/consts");
6
- const resource_client_1 = require("../base/resource_client");
7
- const utils_1 = require("../utils");
8
- const run_1 = require("./run");
9
- const run_collection_1 = require("./run_collection");
10
- const webhook_collection_1 = require("./webhook_collection");
11
- const inputSchema = utils_1.anyObjectSchema.optional();
12
- const startOptionsSchema = zod_1.z.strictObject({
13
- build: zod_1.z.string().optional(),
14
- memory: zod_1.z.number().optional(),
15
- timeout: zod_1.z.number().optional(),
16
- waitForFinish: zod_1.z.number().optional(),
17
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
18
- maxItems: zod_1.z.number().min(0).optional(),
19
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
20
- restartOnError: zod_1.z.boolean().optional(),
1
+ import { z } from 'zod';
2
+ import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
3
+ import { ResourceClient } from '../base/resource_client.js';
4
+ import * as schemas from '../schemas.js';
5
+ import { anyObjectSchema, cast, catchNotFoundOrThrow, parseArgument, parseResponse, stringifyWebhooksToBase64, } from '../utils.js';
6
+ import { RunClient } from './run.js';
7
+ import { RunCollectionClient } from './run_collection.js';
8
+ import { WebhookCollectionClient } from './webhook_collection.js';
9
+ const inputSchema = anyObjectSchema.optional();
10
+ const startOptionsSchema = z.strictObject({
11
+ build: z.string().optional(),
12
+ memory: z.number().optional(),
13
+ timeout: z.number().optional(),
14
+ waitForFinish: z.number().optional(),
15
+ webhooks: z.array(anyObjectSchema).optional(),
16
+ maxItems: z.number().min(0).optional(),
17
+ maxTotalChargeUsd: z.number().min(0).optional(),
18
+ restartOnError: z.boolean().optional(),
21
19
  });
22
- const callOptionsSchema = zod_1.z.strictObject({
23
- build: zod_1.z.string().optional(),
24
- memory: zod_1.z.number().optional(),
25
- timeout: zod_1.z.number().min(0).optional(),
26
- waitSecs: zod_1.z.number().min(0).optional(),
27
- webhooks: zod_1.z.array(utils_1.anyObjectSchema).optional(),
28
- maxItems: zod_1.z.number().min(0).optional(),
29
- maxTotalChargeUsd: zod_1.z.number().min(0).optional(),
30
- restartOnError: zod_1.z.boolean().optional(),
20
+ const callOptionsSchema = z.strictObject({
21
+ build: z.string().optional(),
22
+ memory: z.number().optional(),
23
+ timeout: z.number().min(0).optional(),
24
+ waitSecs: z.number().min(0).optional(),
25
+ webhooks: z.array(anyObjectSchema).optional(),
26
+ maxItems: z.number().min(0).optional(),
27
+ maxTotalChargeUsd: z.number().min(0).optional(),
28
+ restartOnError: z.boolean().optional(),
31
29
  });
32
- const lastRunOptionsSchema = zod_1.z.strictObject({
33
- status: zod_1.z.enum(consts_1.ACT_JOB_STATUSES).optional(),
34
- origin: zod_1.z.enum(consts_1.META_ORIGINS).optional(),
30
+ const lastRunOptionsSchema = z.strictObject({
31
+ status: z.enum(ACT_JOB_STATUSES).optional(),
32
+ origin: z.enum(META_ORIGINS).optional(),
35
33
  });
36
34
  /**
37
35
  * Client for managing a specific Actor task.
@@ -53,7 +51,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
53
51
  *
54
52
  * @see https://docs.apify.com/platform/actors/running/tasks
55
53
  */
56
- class TaskClient extends resource_client_1.ResourceClient {
54
+ export class TaskClient extends ResourceClient {
57
55
  /**
58
56
  * @hidden
59
57
  */
@@ -70,7 +68,7 @@ class TaskClient extends resource_client_1.ResourceClient {
70
68
  * @see https://docs.apify.com/api/v2/actor-task-get
71
69
  */
72
70
  async get() {
73
- return this._get();
71
+ return this._get(schemas.Task());
74
72
  }
75
73
  /**
76
74
  * Updates the task with the specified fields.
@@ -80,8 +78,8 @@ class TaskClient extends resource_client_1.ResourceClient {
80
78
  * @see https://docs.apify.com/api/v2/actor-task-put
81
79
  */
82
80
  async update(newFields) {
83
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
84
- return this._update(newFields);
81
+ parseArgument(newFields, anyObjectSchema);
82
+ return this._update(schemas.Task(), newFields);
85
83
  }
86
84
  /**
87
85
  * Publishes the task on its public landing page, by setting `isPublic` through
@@ -138,15 +136,15 @@ class TaskClient extends resource_client_1.ResourceClient {
138
136
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
139
137
  */
140
138
  async start(input, options = {}) {
141
- (0, utils_1.parseArgument)(input, inputSchema);
142
- const parsed = (0, utils_1.parseArgument)(options, startOptionsSchema, 'TaskStartOptions');
139
+ parseArgument(input, inputSchema);
140
+ const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
143
141
  const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError } = parsed;
144
142
  const params = {
145
143
  waitForFinish,
146
144
  timeout,
147
145
  memory,
148
146
  build,
149
- webhooks: (0, utils_1.stringifyWebhooksToBase64)(parsed.webhooks),
147
+ webhooks: stringifyWebhooksToBase64(parsed.webhooks),
150
148
  maxItems,
151
149
  maxTotalChargeUsd,
152
150
  restartOnError,
@@ -164,7 +162,7 @@ class TaskClient extends resource_client_1.ResourceClient {
164
162
  },
165
163
  };
166
164
  const response = await this.httpClient.call(request);
167
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
165
+ return parseResponse(response, schemas.Run());
168
166
  }
169
167
  /**
170
168
  * Starts a task and waits for it to finish before returning the Run object.
@@ -184,8 +182,8 @@ class TaskClient extends resource_client_1.ResourceClient {
184
182
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
185
183
  */
186
184
  async call(input, options = {}) {
187
- (0, utils_1.parseArgument)(input, inputSchema);
188
- const parsed = (0, utils_1.parseArgument)(options, callOptionsSchema, 'TaskCallOptions');
185
+ parseArgument(input, inputSchema);
186
+ const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
189
187
  const { waitSecs, ...startOptions } = parsed;
190
188
  const { id } = await this.start(input, startOptions);
191
189
  // Calling root client because we need access to top level API.
@@ -207,10 +205,10 @@ class TaskClient extends resource_client_1.ResourceClient {
207
205
  };
208
206
  try {
209
207
  const response = await this.httpClient.call(requestOpts);
210
- return (0, utils_1.cast)(response.data);
208
+ return cast(response.data);
211
209
  }
212
210
  catch (err) {
213
- (0, utils_1.catchNotFoundOrThrow)(err);
211
+ catchNotFoundOrThrow(err);
214
212
  }
215
213
  return undefined;
216
214
  }
@@ -228,7 +226,7 @@ class TaskClient extends resource_client_1.ResourceClient {
228
226
  params: this._params(),
229
227
  data: newFields,
230
228
  });
231
- return (0, utils_1.cast)(response.data);
229
+ return cast(response.data);
232
230
  }
233
231
  /**
234
232
  * Returns a client for the last run of this task.
@@ -240,8 +238,8 @@ class TaskClient extends resource_client_1.ResourceClient {
240
238
  * @see https://docs.apify.com/api/v2/actor-task-runs-last-get
241
239
  */
242
240
  lastRun(options = {}) {
243
- const parsed = (0, utils_1.parseArgument)(options, lastRunOptionsSchema, 'TaskLastRunOptions');
244
- return new run_1.RunClient(this._subResourceOptions({
241
+ const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
242
+ return new RunClient(this._subResourceOptions({
245
243
  id: 'last',
246
244
  params: this._params(parsed),
247
245
  resourcePath: 'runs',
@@ -254,7 +252,7 @@ class TaskClient extends resource_client_1.ResourceClient {
254
252
  * @see https://docs.apify.com/api/v2/actor-task-runs-get
255
253
  */
256
254
  runs() {
257
- return new run_collection_1.RunCollectionClient(this._subResourceOptions({
255
+ return new RunCollectionClient(this._subResourceOptions({
258
256
  resourcePath: 'runs',
259
257
  }));
260
258
  }
@@ -265,7 +263,6 @@ class TaskClient extends resource_client_1.ResourceClient {
265
263
  * @see https://docs.apify.com/api/v2/actor-task-webhooks-get
266
264
  */
267
265
  webhooks() {
268
- return new webhook_collection_1.WebhookCollectionClient(this._subResourceOptions());
266
+ return new WebhookCollectionClient(this._subResourceOptions());
269
267
  }
270
268
  }
271
- exports.TaskClient = TaskClient;
@@ -1,7 +1,9 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceCollectionClient } from '../base/resource_collection_client';
3
- import type { PaginatedIterator, PaginationOptions } from '../utils';
4
- import type { Task, TaskUpdateData } from './task';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { TaskList } from '../models.js';
4
+ import type { PaginatedIterator, PaginationOptions } from '../utils.js';
5
+ import type { Task, TaskUpdateData } from './task.js';
6
+ export type { TaskList } from '../models.js';
5
7
  /**
6
8
  * Client for managing the collection of Actor tasks in your account.
7
9
  *
@@ -64,7 +66,6 @@ export declare class TaskCollectionClient extends ResourceCollectionClient {
64
66
  export interface TaskCollectionListOptions extends PaginationOptions {
65
67
  desc?: boolean;
66
68
  }
67
- export type TaskList = Omit<Task, 'options' | 'input'>;
68
69
  /**
69
70
  * @since Added in 2.3.0
70
71
  */
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskCollectionClient = 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 listOptionsSchema = zod_1.z.strictObject({
8
- ...utils_1.paginationOptionsShape,
9
- desc: zod_1.z.boolean().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 listOptionsSchema = z.strictObject({
6
+ ...paginationOptionsShape,
7
+ desc: z.boolean().optional(),
10
8
  });
11
9
  /**
12
10
  * Client for managing the collection of Actor tasks in your account.
@@ -32,7 +30,7 @@ const listOptionsSchema = zod_1.z.strictObject({
32
30
  *
33
31
  * @see https://docs.apify.com/platform/actors/running/tasks
34
32
  */
35
- class TaskCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
33
+ export class TaskCollectionClient extends ResourceCollectionClient {
36
34
  /**
37
35
  * @hidden
38
36
  */
@@ -63,8 +61,8 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
63
61
  * @see https://docs.apify.com/api/v2/actor-tasks-get
64
62
  */
65
63
  list(options = {}) {
66
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'TaskCollectionListOptions');
67
- return this._listPaginated(parsed);
64
+ const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
65
+ return this._listPaginated(schemas.ListOfTasks(), parsed);
68
66
  }
69
67
  /**
70
68
  * Creates a new task.
@@ -74,8 +72,7 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
74
72
  * @see https://docs.apify.com/api/v2/actor-tasks-post
75
73
  */
76
74
  async create(task) {
77
- (0, utils_1.parseArgument)(task, utils_1.anyObjectSchema);
78
- return this._create(task);
75
+ parseArgument(task, anyObjectSchema);
76
+ return this._create(schemas.Task(), task);
79
77
  }
80
78
  }
81
- exports.TaskCollectionClient = TaskCollectionClient;
@@ -1,5 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { AccountAndUsageLimits, MonthlyUsage, User } from '../models.js';
4
+ export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models.js';
5
+ export { PlatformFeature } from '../models.js';
3
6
  /**
4
7
  * Client for managing user account information.
5
8
  *
@@ -64,169 +67,6 @@ export declare class UserClient extends ResourceClient {
64
67
  */
65
68
  updateLimits(options: LimitsUpdateOptions): Promise<void>;
66
69
  }
67
- export interface User {
68
- username: string;
69
- profile: {
70
- bio?: string;
71
- name?: string;
72
- pictureUrl?: string;
73
- githubUsername?: string;
74
- websiteUrl?: string;
75
- twitterUsername?: string;
76
- };
77
- id?: string;
78
- email?: string;
79
- proxy?: UserProxy;
80
- plan?: UserPlan;
81
- /**
82
- * @since Added in 2.12.5
83
- */
84
- effectivePlatformFeatures?: EffectivePlatformFeatures;
85
- /**
86
- * @since Added in 2.12.5
87
- */
88
- createdAt?: Date;
89
- /**
90
- * @since Added in 2.12.5
91
- */
92
- isPaying?: boolean;
93
- }
94
- export interface UserProxy {
95
- password: string;
96
- groups: ProxyGroup[];
97
- }
98
- export interface ProxyGroup {
99
- name: string;
100
- description: string;
101
- availableCount: number;
102
- }
103
- export interface UserPlan {
104
- id: string;
105
- description: string;
106
- isEnabled: boolean;
107
- monthlyBasePriceUsd: number;
108
- monthlyUsageCreditsUsd: number;
109
- usageDiscountPercent: number;
110
- enabledPlatformFeatures: PlatformFeature[];
111
- maxMonthlyUsageUsd: number;
112
- maxActorMemoryGbytes: number;
113
- maxMonthlyActorComputeUnits: number;
114
- maxMonthlyResidentialProxyGbytes: number;
115
- maxMonthlyProxySerps: number;
116
- maxMonthlyExternalDataTransferGbytes: number;
117
- maxActorCount: number;
118
- maxActorTaskCount: number;
119
- dataRetentionDays: number;
120
- availableProxyGroups: Record<string, number>;
121
- teamAccountSeatCount: number;
122
- supportLevel: string;
123
- availableAddOns: unknown[];
124
- }
125
- export declare enum PlatformFeature {
126
- Actors = "ACTORS",
127
- Storage = "STORAGE",
128
- ProxySERPS = "PROXY_SERPS",
129
- Scheduler = "SCHEDULER",
130
- Webhooks = "WEBHOOKS",
131
- Proxy = "PROXY",
132
- ProxyExternalAccess = "PROXY_EXTERNAL_ACCESS"
133
- }
134
- interface EffectivePlatformFeature {
135
- isEnabled: boolean;
136
- disabledReason: string | null;
137
- disabledReasonType: string | null;
138
- isTrial: boolean;
139
- trialExpirationAt: Date | null;
140
- }
141
- interface EffectivePlatformFeatures {
142
- ACTORS: EffectivePlatformFeature;
143
- STORAGE: EffectivePlatformFeature;
144
- SCHEDULER: EffectivePlatformFeature;
145
- PROXY: EffectivePlatformFeature;
146
- PROXY_EXTERNAL_ACCESS: EffectivePlatformFeature;
147
- PROXY_RESIDENTIAL: EffectivePlatformFeature;
148
- PROXY_SERPS: EffectivePlatformFeature;
149
- WEBHOOKS: EffectivePlatformFeature;
150
- ACTORS_PUBLIC_ALL: EffectivePlatformFeature;
151
- ACTORS_PUBLIC_DEVELOPER: EffectivePlatformFeature;
152
- }
153
- /**
154
- * @since Added in 2.9.2
155
- */
156
- export interface MonthlyUsage {
157
- usageCycle: UsageCycle;
158
- monthlyServiceUsage: {
159
- [key: string]: MonthlyServiceUsageData;
160
- };
161
- dailyServiceUsages: DailyServiceUsage[];
162
- totalUsageCreditsUsdBeforeVolumeDiscount: number;
163
- totalUsageCreditsUsdAfterVolumeDiscount: number;
164
- }
165
- /**
166
- * @since Added in 2.9.2
167
- */
168
- export interface UsageCycle {
169
- startAt: Date;
170
- endAt: Date;
171
- }
172
- /** Monthly usage of a single service */
173
- interface MonthlyServiceUsageData {
174
- quantity: number;
175
- baseAmountUsd: number;
176
- baseUnitPriceUsd: number;
177
- amountAfterVolumeDiscountUsd: number;
178
- priceTiers: PriceTier[];
179
- }
180
- interface PriceTier {
181
- quantityAbove: number;
182
- discountPercent: number;
183
- tierQuantity: number;
184
- unitPriceUsd: number;
185
- priceUsd: number;
186
- }
187
- interface DailyServiceUsage {
188
- date: Date;
189
- serviceUsage: {
190
- [key: string]: DailyServiceUsageData;
191
- };
192
- totalUsageCreditsUsd: number;
193
- }
194
- /** Daily usage of a single service */
195
- interface DailyServiceUsageData {
196
- quantity: number;
197
- baseAmountUsd: number;
198
- }
199
- /**
200
- * @since Added in 2.9.2
201
- */
202
- export interface AccountAndUsageLimits {
203
- monthlyUsageCycle: MonthlyUsageCycle;
204
- limits: Limits;
205
- current: Current;
206
- }
207
- /**
208
- * @since Added in 2.9.2
209
- */
210
- export interface MonthlyUsageCycle {
211
- startAt: Date;
212
- endAt: Date;
213
- }
214
- /**
215
- * @since Added in 2.9.2
216
- */
217
- export interface Limits {
218
- maxMonthlyUsageUsd: number;
219
- maxMonthlyActorComputeUnits: number;
220
- maxMonthlyExternalDataTransferGbytes: number;
221
- maxMonthlyProxySerps: number;
222
- maxMonthlyResidentialProxyGbytes: number;
223
- maxActorMemoryGbytes: number;
224
- maxActorCount: number;
225
- maxActorTaskCount: number;
226
- maxConcurrentActorJobs: number;
227
- maxTeamAccountSeatCount: number;
228
- dataRetentionDays: number;
229
- }
230
70
  /**
231
71
  * @since Added in 2.10.0
232
72
  */
@@ -235,19 +75,3 @@ export type LimitsUpdateOptions = {
235
75
  } | {
236
76
  dataRetentionDays: number;
237
77
  };
238
- /**
239
- * @since Added in 2.9.2
240
- */
241
- export interface Current {
242
- monthlyUsageUsd: number;
243
- monthlyActorComputeUnits: number;
244
- monthlyExternalDataTransferGbytes: number;
245
- monthlyProxySerps: number;
246
- monthlyResidentialProxyGbytes: number;
247
- actorMemoryGbytes: number;
248
- actorCount: number;
249
- actorTaskCount: number;
250
- activeActorJobCount: number;
251
- teamAccountSeatCount: number;
252
- }
253
- export {};
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformFeature = exports.UserClient = 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 { catchNotFoundOrThrow, parseResponse } from '../utils.js';
4
+ export { PlatformFeature } from '../models.js';
6
5
  /**
7
6
  * Client for managing user account information.
8
7
  *
@@ -27,7 +26,7 @@ const utils_1 = require("../utils");
27
26
  *
28
27
  * @see https://docs.apify.com/platform/actors/running
29
28
  */
30
- class UserClient extends resource_client_1.ResourceClient {
29
+ export class UserClient extends ResourceClient {
31
30
  /**
32
31
  * @hidden
33
32
  */
@@ -47,7 +46,7 @@ class UserClient extends resource_client_1.ResourceClient {
47
46
  * @see https://docs.apify.com/api/v2/user-get
48
47
  */
49
48
  async get() {
50
- return this._get();
49
+ return this._get(schemas.UserPrivateInfo());
51
50
  }
52
51
  /**
53
52
  * Retrieves the user's monthly usage data.
@@ -64,12 +63,11 @@ class UserClient extends resource_client_1.ResourceClient {
64
63
  };
65
64
  try {
66
65
  const response = await this.httpClient.call(requestOpts);
67
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data),
68
- // Convert monthlyUsage.dailyServiceUsages[].date to Date (by default it's ignored by parseDateFields)
69
- /* shouldParseField = */ (key) => key === 'date'));
66
+ // `dailyServiceUsages[].date` does not end in `At`, so it has to be named for `parseDateFields`.
67
+ return parseResponse(response, schemas.MonthlyUsage(), (key) => key === 'date');
70
68
  }
71
69
  catch (err) {
72
- (0, utils_1.catchNotFoundOrThrow)(err);
70
+ catchNotFoundOrThrow(err);
73
71
  }
74
72
  return undefined;
75
73
  }
@@ -88,10 +86,10 @@ class UserClient extends resource_client_1.ResourceClient {
88
86
  };
89
87
  try {
90
88
  const response = await this.httpClient.call(requestOpts);
91
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
89
+ return parseResponse(response, schemas.AccountLimits());
92
90
  }
93
91
  catch (err) {
94
- (0, utils_1.catchNotFoundOrThrow)(err);
92
+ catchNotFoundOrThrow(err);
95
93
  }
96
94
  return undefined;
97
95
  }
@@ -112,14 +110,3 @@ class UserClient extends resource_client_1.ResourceClient {
112
110
  await this.httpClient.call(requestOpts);
113
111
  }
114
112
  }
115
- exports.UserClient = UserClient;
116
- var PlatformFeature;
117
- (function (PlatformFeature) {
118
- PlatformFeature["Actors"] = "ACTORS";
119
- PlatformFeature["Storage"] = "STORAGE";
120
- PlatformFeature["ProxySERPS"] = "PROXY_SERPS";
121
- PlatformFeature["Scheduler"] = "SCHEDULER";
122
- PlatformFeature["Webhooks"] = "WEBHOOKS";
123
- PlatformFeature["Proxy"] = "PROXY";
124
- PlatformFeature["ProxyExternalAccess"] = "PROXY_EXTERNAL_ACCESS";
125
- })(PlatformFeature || (exports.PlatformFeature = PlatformFeature = {}));