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

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 (84) hide show
  1. package/README.md +2 -2
  2. package/dist/apify_api_error.js +5 -9
  3. package/dist/apify_client.d.ts +27 -27
  4. package/dist/apify_client.js +86 -91
  5. package/dist/base/api_client.d.ts +3 -3
  6. package/dist/base/api_client.js +6 -10
  7. package/dist/base/resource_client.d.ts +1 -1
  8. package/dist/base/resource_client.js +14 -18
  9. package/dist/base/resource_collection_client.d.ts +2 -2
  10. package/dist/base/resource_collection_client.js +6 -10
  11. package/dist/body_parser.js +6 -11
  12. package/dist/bundle.js +35 -47
  13. package/dist/bundle.js.map +1 -1
  14. package/dist/generated/api.js +1 -2
  15. package/dist/http_client.d.ts +2 -2
  16. package/dist/http_client.js +23 -28
  17. package/dist/index.d.ts +32 -32
  18. package/dist/index.js +31 -36
  19. package/dist/interceptors.d.ts +1 -1
  20. package/dist/interceptors.js +14 -19
  21. package/dist/models.d.ts +3 -3
  22. package/dist/models.js +8 -11
  23. package/dist/resource_clients/actor.d.ts +13 -13
  24. package/dist/resource_clients/actor.js +67 -71
  25. package/dist/resource_clients/actor_collection.d.ts +7 -7
  26. package/dist/resource_clients/actor_collection.js +14 -18
  27. package/dist/resource_clients/actor_env_var.d.ts +3 -3
  28. package/dist/resource_clients/actor_env_var.js +4 -8
  29. package/dist/resource_clients/actor_env_var_collection.d.ts +4 -4
  30. package/dist/resource_clients/actor_env_var_collection.js +5 -9
  31. package/dist/resource_clients/actor_version.d.ts +7 -7
  32. package/dist/resource_clients/actor_version.js +12 -17
  33. package/dist/resource_clients/actor_version_collection.d.ts +4 -4
  34. package/dist/resource_clients/actor_version_collection.js +5 -9
  35. package/dist/resource_clients/build.d.ts +5 -5
  36. package/dist/resource_clients/build.js +11 -15
  37. package/dist/resource_clients/build_collection.d.ts +5 -5
  38. package/dist/resource_clients/build_collection.js +8 -12
  39. package/dist/resource_clients/dataset.d.ts +5 -5
  40. package/dist/resource_clients/dataset.js +72 -76
  41. package/dist/resource_clients/dataset_collection.d.ts +4 -4
  42. package/dist/resource_clients/dataset_collection.js +15 -19
  43. package/dist/resource_clients/key_value_store.d.ts +4 -4
  44. package/dist/resource_clients/key_value_store.js +57 -62
  45. package/dist/resource_clients/key_value_store_collection.d.ts +4 -4
  46. package/dist/resource_clients/key_value_store_collection.js +15 -19
  47. package/dist/resource_clients/log.d.ts +2 -2
  48. package/dist/resource_clients/log.js +15 -22
  49. package/dist/resource_clients/request_queue.d.ts +4 -4
  50. package/dist/resource_clients/request_queue.js +91 -96
  51. package/dist/resource_clients/request_queue_collection.d.ts +4 -4
  52. package/dist/resource_clients/request_queue_collection.js +13 -17
  53. package/dist/resource_clients/run.d.ts +8 -8
  54. package/dist/resource_clients/run.js +46 -50
  55. package/dist/resource_clients/run_collection.d.ts +4 -4
  56. package/dist/resource_clients/run_collection.js +13 -17
  57. package/dist/resource_clients/schedule.d.ts +6 -6
  58. package/dist/resource_clients/schedule.js +7 -12
  59. package/dist/resource_clients/schedule_collection.d.ts +4 -4
  60. package/dist/resource_clients/schedule_collection.js +10 -14
  61. package/dist/resource_clients/store_collection.d.ts +5 -5
  62. package/dist/resource_clients/store_collection.js +13 -17
  63. package/dist/resource_clients/task.d.ts +9 -9
  64. package/dist/resource_clients/task.js +44 -48
  65. package/dist/resource_clients/task_collection.d.ts +6 -6
  66. package/dist/resource_clients/task_collection.js +9 -13
  67. package/dist/resource_clients/user.d.ts +5 -5
  68. package/dist/resource_clients/user.js +8 -13
  69. package/dist/resource_clients/webhook.d.ts +6 -6
  70. package/dist/resource_clients/webhook.js +8 -12
  71. package/dist/resource_clients/webhook_collection.d.ts +4 -4
  72. package/dist/resource_clients/webhook_collection.js +10 -14
  73. package/dist/resource_clients/webhook_dispatch.d.ts +5 -5
  74. package/dist/resource_clients/webhook_dispatch.js +3 -8
  75. package/dist/resource_clients/webhook_dispatch_collection.d.ts +4 -4
  76. package/dist/resource_clients/webhook_dispatch_collection.js +8 -12
  77. package/dist/statistics.js +5 -9
  78. package/dist/timezones.js +1 -2
  79. package/dist/utils.d.ts +5 -13
  80. package/dist/utils.js +30 -69
  81. package/package.json +10 -12
  82. package/dist/argument_validation_error.d.ts +0 -17
  83. package/dist/argument_validation_error.js +0 -157
  84. package/dist/index.mjs +0 -42
@@ -1,37 +1,34 @@
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 { anyObjectSchema, cast, catchNotFoundOrThrow, parseArgument, parseDateFields, pluckData, stringifyWebhooksToBase64, } from '../utils.js';
5
+ import { RunClient } from './run.js';
6
+ import { RunCollectionClient } from './run_collection.js';
7
+ import { WebhookCollectionClient } from './webhook_collection.js';
8
+ const inputSchema = anyObjectSchema.optional();
9
+ const startOptionsSchema = z.strictObject({
10
+ build: z.string().optional(),
11
+ memory: z.number().optional(),
12
+ timeout: z.number().optional(),
13
+ waitForFinish: z.number().optional(),
14
+ webhooks: z.array(anyObjectSchema).optional(),
15
+ maxItems: z.number().min(0).optional(),
16
+ maxTotalChargeUsd: z.number().min(0).optional(),
17
+ restartOnError: z.boolean().optional(),
21
18
  });
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(),
19
+ const callOptionsSchema = z.strictObject({
20
+ build: z.string().optional(),
21
+ memory: z.number().optional(),
22
+ timeout: z.number().min(0).optional(),
23
+ waitSecs: z.number().min(0).optional(),
24
+ webhooks: z.array(anyObjectSchema).optional(),
25
+ maxItems: z.number().min(0).optional(),
26
+ maxTotalChargeUsd: z.number().min(0).optional(),
27
+ restartOnError: z.boolean().optional(),
31
28
  });
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(),
29
+ const lastRunOptionsSchema = z.strictObject({
30
+ status: z.enum(ACT_JOB_STATUSES).optional(),
31
+ origin: z.enum(META_ORIGINS).optional(),
35
32
  });
36
33
  /**
37
34
  * Client for managing a specific Actor task.
@@ -53,7 +50,7 @@ const lastRunOptionsSchema = zod_1.z.strictObject({
53
50
  *
54
51
  * @see https://docs.apify.com/platform/actors/running/tasks
55
52
  */
56
- class TaskClient extends resource_client_1.ResourceClient {
53
+ export class TaskClient extends ResourceClient {
57
54
  /**
58
55
  * @hidden
59
56
  */
@@ -80,7 +77,7 @@ class TaskClient extends resource_client_1.ResourceClient {
80
77
  * @see https://docs.apify.com/api/v2/actor-task-put
81
78
  */
82
79
  async update(newFields) {
83
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
80
+ parseArgument(newFields, anyObjectSchema);
84
81
  return this._update(newFields);
85
82
  }
86
83
  /**
@@ -138,15 +135,15 @@ class TaskClient extends resource_client_1.ResourceClient {
138
135
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
139
136
  */
140
137
  async start(input, options = {}) {
141
- (0, utils_1.parseArgument)(input, inputSchema);
142
- const parsed = (0, utils_1.parseArgument)(options, startOptionsSchema, 'TaskStartOptions');
138
+ parseArgument(input, inputSchema);
139
+ const parsed = parseArgument(options, startOptionsSchema, 'TaskStartOptions');
143
140
  const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, restartOnError } = parsed;
144
141
  const params = {
145
142
  waitForFinish,
146
143
  timeout,
147
144
  memory,
148
145
  build,
149
- webhooks: (0, utils_1.stringifyWebhooksToBase64)(parsed.webhooks),
146
+ webhooks: stringifyWebhooksToBase64(parsed.webhooks),
150
147
  maxItems,
151
148
  maxTotalChargeUsd,
152
149
  restartOnError,
@@ -164,7 +161,7 @@ class TaskClient extends resource_client_1.ResourceClient {
164
161
  },
165
162
  };
166
163
  const response = await this.httpClient.call(request);
167
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
164
+ return cast(parseDateFields(pluckData(response.data)));
168
165
  }
169
166
  /**
170
167
  * Starts a task and waits for it to finish before returning the Run object.
@@ -184,8 +181,8 @@ class TaskClient extends resource_client_1.ResourceClient {
184
181
  * @see https://docs.apify.com/api/v2/actor-task-runs-post
185
182
  */
186
183
  async call(input, options = {}) {
187
- (0, utils_1.parseArgument)(input, inputSchema);
188
- const parsed = (0, utils_1.parseArgument)(options, callOptionsSchema, 'TaskCallOptions');
184
+ parseArgument(input, inputSchema);
185
+ const parsed = parseArgument(options, callOptionsSchema, 'TaskCallOptions');
189
186
  const { waitSecs, ...startOptions } = parsed;
190
187
  const { id } = await this.start(input, startOptions);
191
188
  // Calling root client because we need access to top level API.
@@ -207,10 +204,10 @@ class TaskClient extends resource_client_1.ResourceClient {
207
204
  };
208
205
  try {
209
206
  const response = await this.httpClient.call(requestOpts);
210
- return (0, utils_1.cast)(response.data);
207
+ return cast(response.data);
211
208
  }
212
209
  catch (err) {
213
- (0, utils_1.catchNotFoundOrThrow)(err);
210
+ catchNotFoundOrThrow(err);
214
211
  }
215
212
  return undefined;
216
213
  }
@@ -228,7 +225,7 @@ class TaskClient extends resource_client_1.ResourceClient {
228
225
  params: this._params(),
229
226
  data: newFields,
230
227
  });
231
- return (0, utils_1.cast)(response.data);
228
+ return cast(response.data);
232
229
  }
233
230
  /**
234
231
  * Returns a client for the last run of this task.
@@ -240,8 +237,8 @@ class TaskClient extends resource_client_1.ResourceClient {
240
237
  * @see https://docs.apify.com/api/v2/actor-task-runs-last-get
241
238
  */
242
239
  lastRun(options = {}) {
243
- const parsed = (0, utils_1.parseArgument)(options, lastRunOptionsSchema, 'TaskLastRunOptions');
244
- return new run_1.RunClient(this._subResourceOptions({
240
+ const parsed = parseArgument(options, lastRunOptionsSchema, 'TaskLastRunOptions');
241
+ return new RunClient(this._subResourceOptions({
245
242
  id: 'last',
246
243
  params: this._params(parsed),
247
244
  resourcePath: 'runs',
@@ -254,7 +251,7 @@ class TaskClient extends resource_client_1.ResourceClient {
254
251
  * @see https://docs.apify.com/api/v2/actor-task-runs-get
255
252
  */
256
253
  runs() {
257
- return new run_collection_1.RunCollectionClient(this._subResourceOptions({
254
+ return new RunCollectionClient(this._subResourceOptions({
258
255
  resourcePath: 'runs',
259
256
  }));
260
257
  }
@@ -265,7 +262,6 @@ class TaskClient extends resource_client_1.ResourceClient {
265
262
  * @see https://docs.apify.com/api/v2/actor-task-webhooks-get
266
263
  */
267
264
  webhooks() {
268
- return new webhook_collection_1.WebhookCollectionClient(this._subResourceOptions());
265
+ return new WebhookCollectionClient(this._subResourceOptions());
269
266
  }
270
267
  }
271
- exports.TaskClient = TaskClient;
@@ -1,9 +1,9 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceCollectionClient } from '../base/resource_collection_client';
3
- import type { TaskList } from '../models';
4
- import type { PaginatedIterator, PaginationOptions } from '../utils';
5
- import type { Task, TaskUpdateData } from './task';
6
- export type { TaskList } from '../models';
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';
7
7
  /**
8
8
  * Client for managing the collection of Actor tasks in your account.
9
9
  *
@@ -1,12 +1,9 @@
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 { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
4
+ const listOptionsSchema = z.strictObject({
5
+ ...paginationOptionsShape,
6
+ desc: z.boolean().optional(),
10
7
  });
11
8
  /**
12
9
  * Client for managing the collection of Actor tasks in your account.
@@ -32,7 +29,7 @@ const listOptionsSchema = zod_1.z.strictObject({
32
29
  *
33
30
  * @see https://docs.apify.com/platform/actors/running/tasks
34
31
  */
35
- class TaskCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
32
+ export class TaskCollectionClient extends ResourceCollectionClient {
36
33
  /**
37
34
  * @hidden
38
35
  */
@@ -63,7 +60,7 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
63
60
  * @see https://docs.apify.com/api/v2/actor-tasks-get
64
61
  */
65
62
  list(options = {}) {
66
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'TaskCollectionListOptions');
63
+ const parsed = parseArgument(options, listOptionsSchema, 'TaskCollectionListOptions');
67
64
  return this._listPaginated(parsed);
68
65
  }
69
66
  /**
@@ -74,8 +71,7 @@ class TaskCollectionClient extends resource_collection_client_1.ResourceCollecti
74
71
  * @see https://docs.apify.com/api/v2/actor-tasks-post
75
72
  */
76
73
  async create(task) {
77
- (0, utils_1.parseArgument)(task, utils_1.anyObjectSchema);
74
+ parseArgument(task, anyObjectSchema);
78
75
  return this._create(task);
79
76
  }
80
77
  }
81
- exports.TaskCollectionClient = TaskCollectionClient;
@@ -1,8 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { AccountAndUsageLimits, MonthlyUsage, User } from '../models';
4
- export type { AccountAndUsageLimits, Current, DailyServiceUsage, EffectivePlatformFeature, EffectivePlatformFeatures, Limits, MonthlyUsage, MonthlyUsageCycle, PriceTier, ProxyGroup, ServiceUsage, UsageCycle, UsageItem, User, UserPlan, UserProfile, UserProxy, } from '../models';
5
- export { PlatformFeature } from '../models';
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';
6
6
  /**
7
7
  * Client for managing user account information.
8
8
  *
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserClient = exports.PlatformFeature = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- const utils_1 = require("../utils");
6
- var models_1 = require("../models");
7
- Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: function () { return models_1.PlatformFeature; } });
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import { cast, catchNotFoundOrThrow, parseDateFields, pluckData } from '../utils.js';
3
+ export { PlatformFeature } from '../models.js';
8
4
  /**
9
5
  * Client for managing user account information.
10
6
  *
@@ -29,7 +25,7 @@ Object.defineProperty(exports, "PlatformFeature", { enumerable: true, get: funct
29
25
  *
30
26
  * @see https://docs.apify.com/platform/actors/running
31
27
  */
32
- class UserClient extends resource_client_1.ResourceClient {
28
+ export class UserClient extends ResourceClient {
33
29
  /**
34
30
  * @hidden
35
31
  */
@@ -66,12 +62,12 @@ class UserClient extends resource_client_1.ResourceClient {
66
62
  };
67
63
  try {
68
64
  const response = await this.httpClient.call(requestOpts);
69
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data),
65
+ return cast(parseDateFields(pluckData(response.data),
70
66
  // Convert monthlyUsage.dailyServiceUsages[].date to Date (by default it's ignored by parseDateFields)
71
67
  /* shouldParseField = */ (key) => key === 'date'));
72
68
  }
73
69
  catch (err) {
74
- (0, utils_1.catchNotFoundOrThrow)(err);
70
+ catchNotFoundOrThrow(err);
75
71
  }
76
72
  return undefined;
77
73
  }
@@ -90,10 +86,10 @@ class UserClient extends resource_client_1.ResourceClient {
90
86
  };
91
87
  try {
92
88
  const response = await this.httpClient.call(requestOpts);
93
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
89
+ return cast(parseDateFields(pluckData(response.data)));
94
90
  }
95
91
  catch (err) {
96
- (0, utils_1.catchNotFoundOrThrow)(err);
92
+ catchNotFoundOrThrow(err);
97
93
  }
98
94
  return undefined;
99
95
  }
@@ -114,4 +110,3 @@ class UserClient extends resource_client_1.ResourceClient {
114
110
  await this.httpClient.call(requestOpts);
115
111
  }
116
112
  }
117
- exports.UserClient = UserClient;
@@ -1,9 +1,9 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { Webhook, WebhookEventType } from '../models';
4
- import type { WebhookDispatch } from './webhook_dispatch';
5
- import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection';
6
- export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { Webhook, WebhookEventType } from '../models.js';
4
+ import type { WebhookDispatch } from './webhook_dispatch.js';
5
+ import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
6
+ export type { Webhook, WebhookAnyRunOfActorCondition, WebhookAnyRunOfActorTaskCondition, WebhookCertainRunCondition, WebhookCondition, WebhookEventType, WebhookLastDispatch, WebhookStats, } from '../models.js';
7
7
  /**
8
8
  * Client for managing a specific webhook.
9
9
  *
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookClient = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- const utils_1 = require("../utils");
6
- const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ import { anyObjectSchema, cast, catchNotFoundOrThrow, parseArgument, parseDateFields, pluckData } from '../utils.js';
3
+ import { WebhookDispatchCollectionClient } from './webhook_dispatch_collection.js';
7
4
  /**
8
5
  * Client for managing a specific webhook.
9
6
  *
@@ -32,7 +29,7 @@ const webhook_dispatch_collection_1 = require("./webhook_dispatch_collection");
32
29
  *
33
30
  * @see https://docs.apify.com/platform/integrations/webhooks
34
31
  */
35
- class WebhookClient extends resource_client_1.ResourceClient {
32
+ export class WebhookClient extends ResourceClient {
36
33
  /**
37
34
  * @hidden
38
35
  */
@@ -59,7 +56,7 @@ class WebhookClient extends resource_client_1.ResourceClient {
59
56
  * @see https://docs.apify.com/api/v2/webhook-put
60
57
  */
61
58
  async update(newFields) {
62
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
59
+ parseArgument(newFields, anyObjectSchema);
63
60
  return this._update(newFields);
64
61
  }
65
62
  /**
@@ -84,10 +81,10 @@ class WebhookClient extends resource_client_1.ResourceClient {
84
81
  };
85
82
  try {
86
83
  const response = await this.httpClient.call(request);
87
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
84
+ return cast(parseDateFields(pluckData(response.data)));
88
85
  }
89
86
  catch (err) {
90
- (0, utils_1.catchNotFoundOrThrow)(err);
87
+ catchNotFoundOrThrow(err);
91
88
  }
92
89
  return undefined;
93
90
  }
@@ -98,9 +95,8 @@ class WebhookClient extends resource_client_1.ResourceClient {
98
95
  * @see https://docs.apify.com/api/v2/webhook-webhook-dispatches-get
99
96
  */
100
97
  dispatches() {
101
- return new webhook_dispatch_collection_1.WebhookDispatchCollectionClient(this._subResourceOptions({
98
+ return new WebhookDispatchCollectionClient(this._subResourceOptions({
102
99
  resourcePath: 'dispatches',
103
100
  }));
104
101
  }
105
102
  }
106
- exports.WebhookClient = WebhookClient;
@@ -1,7 +1,7 @@
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 { Webhook, WebhookUpdateData } from './webhook';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { PaginatedIterator, PaginationOptions } from '../utils.js';
4
+ import type { Webhook, WebhookUpdateData } from './webhook.js';
5
5
  /**
6
6
  * Client for managing the collection of Webhooks.
7
7
  *
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookCollectionClient = 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 { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
4
+ const listOptionsSchema = z.strictObject({
5
+ ...paginationOptionsShape,
6
+ desc: z.boolean().optional(),
10
7
  });
11
- const webhookCreateSchema = utils_1.anyObjectSchema.optional();
8
+ const webhookCreateSchema = anyObjectSchema.optional();
12
9
  /**
13
10
  * Client for managing the collection of Webhooks.
14
11
  *
@@ -32,7 +29,7 @@ const webhookCreateSchema = utils_1.anyObjectSchema.optional();
32
29
  *
33
30
  * @see https://docs.apify.com/platform/integrations/webhooks
34
31
  */
35
- class WebhookCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
32
+ export class WebhookCollectionClient extends ResourceCollectionClient {
36
33
  /**
37
34
  * @hidden
38
35
  */
@@ -63,7 +60,7 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
63
60
  * @see https://docs.apify.com/api/v2/webhooks-get
64
61
  */
65
62
  list(options = {}) {
66
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookCollectionListOptions');
63
+ const parsed = parseArgument(options, listOptionsSchema, 'WebhookCollectionListOptions');
67
64
  return this._listPaginated(parsed);
68
65
  }
69
66
  /**
@@ -74,8 +71,7 @@ class WebhookCollectionClient extends resource_collection_client_1.ResourceColle
74
71
  * @see https://docs.apify.com/api/v2/webhooks-post
75
72
  */
76
73
  async create(webhook) {
77
- (0, utils_1.parseArgument)(webhook, webhookCreateSchema);
74
+ parseArgument(webhook, webhookCreateSchema);
78
75
  return this._create(webhook);
79
76
  }
80
77
  }
81
- exports.WebhookCollectionClient = WebhookCollectionClient;
@@ -1,8 +1,8 @@
1
- import type { ApiClientSubResourceOptions } from '../base/api_client';
2
- import { ResourceClient } from '../base/resource_client';
3
- import type { WebhookDispatch } from '../models';
4
- export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models';
5
- export { WebhookDispatchStatus } from '../models';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceClient } from '../base/resource_client.js';
3
+ import type { WebhookDispatch } from '../models.js';
4
+ export type { WebhookDispatch, WebhookDispatchCall, WebhookDispatchEventData, WebhookDispatchWebhookSummary, } from '../models.js';
5
+ export { WebhookDispatchStatus } from '../models.js';
6
6
  /**
7
7
  * Client for managing a specific webhook dispatch.
8
8
  *
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookDispatchClient = exports.WebhookDispatchStatus = void 0;
4
- const resource_client_1 = require("../base/resource_client");
5
- var models_1 = require("../models");
6
- Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get: function () { return models_1.WebhookDispatchStatus; } });
1
+ import { ResourceClient } from '../base/resource_client.js';
2
+ export { WebhookDispatchStatus } from '../models.js';
7
3
  /**
8
4
  * Client for managing a specific webhook dispatch.
9
5
  *
@@ -22,7 +18,7 @@ Object.defineProperty(exports, "WebhookDispatchStatus", { enumerable: true, get:
22
18
  *
23
19
  * @see https://docs.apify.com/platform/integrations/webhooks
24
20
  */
25
- class WebhookDispatchClient extends resource_client_1.ResourceClient {
21
+ export class WebhookDispatchClient extends ResourceClient {
26
22
  /**
27
23
  * @hidden
28
24
  */
@@ -42,4 +38,3 @@ class WebhookDispatchClient extends resource_client_1.ResourceClient {
42
38
  return this._get();
43
39
  }
44
40
  }
45
- exports.WebhookDispatchClient = WebhookDispatchClient;
@@ -1,7 +1,7 @@
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 { WebhookDispatch } from './webhook_dispatch';
1
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
2
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
3
+ import type { PaginatedIterator, PaginationOptions } from '../utils.js';
4
+ import type { WebhookDispatch } from './webhook_dispatch.js';
5
5
  /**
6
6
  * Client for managing the collection of webhook dispatches.
7
7
  *
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebhookDispatchCollectionClient = 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 { paginationOptionsShape, parseArgument } from '../utils.js';
4
+ const listOptionsSchema = z.strictObject({
5
+ ...paginationOptionsShape,
6
+ desc: z.boolean().optional(),
10
7
  });
11
8
  /**
12
9
  * Client for managing the collection of webhook dispatches.
@@ -26,7 +23,7 @@ const listOptionsSchema = zod_1.z.strictObject({
26
23
  *
27
24
  * @see https://docs.apify.com/platform/integrations/webhooks
28
25
  */
29
- class WebhookDispatchCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
26
+ export class WebhookDispatchCollectionClient extends ResourceCollectionClient {
30
27
  /**
31
28
  * @hidden
32
29
  */
@@ -57,8 +54,7 @@ class WebhookDispatchCollectionClient extends resource_collection_client_1.Resou
57
54
  * @see https://docs.apify.com/api/v2/webhook-dispatches-get
58
55
  */
59
56
  list(options = {}) {
60
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
57
+ const parsed = parseArgument(options, listOptionsSchema, 'WebhookDispatchCollectionListOptions');
61
58
  return this._listPaginated(parsed);
62
59
  }
63
60
  }
64
- exports.WebhookDispatchCollectionClient = WebhookDispatchCollectionClient;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Statistics = void 0;
4
- const zod_1 = require("zod");
5
- const utils_1 = require("./utils");
6
- const attemptSchema = zod_1.z.number().gt(0);
7
- class Statistics {
1
+ import { z } from 'zod';
2
+ import { parseArgument } from './utils.js';
3
+ const attemptSchema = z.number().gt(0);
4
+ export class Statistics {
8
5
  /**
9
6
  * Number of Apify client function calls
10
7
  */
@@ -19,7 +16,7 @@ class Statistics {
19
16
  */
20
17
  rateLimitErrors = [];
21
18
  addRateLimitError(attempt) {
22
- (0, utils_1.parseArgument)(attempt, attemptSchema);
19
+ parseArgument(attempt, attemptSchema);
23
20
  // attempt is never 0,
24
21
  // but we don't want index 0 empty
25
22
  const index = attempt - 1;
@@ -41,4 +38,3 @@ class Statistics {
41
38
  }
42
39
  }
43
40
  }
44
- exports.Statistics = Statistics;
package/dist/timezones.js CHANGED
@@ -1,8 +1,6 @@
1
- "use strict";
2
1
  // This contains exactly the list of timezones supported by 'moment-timezone' package, you can fetch it using:
3
2
  // require('moment-timzone').tz.names()
4
3
  // This should be kept in sync with timezones.js in storage
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
4
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
5
  const timezones = [
8
6
  'Africa/Abidjan',
@@ -599,3 +597,4 @@ const timezones = [
599
597
  'WET',
600
598
  'Zulu',
601
599
  ];
600
+ export {};
package/dist/utils.d.ts CHANGED
@@ -1,18 +1,11 @@
1
1
  import type { Readable } from 'node:stream';
2
2
  import type { JsonValue, TypedArray } from 'type-fest';
3
3
  import { z } from 'zod';
4
- import type { ApifyApiError } from './apify_api_error';
5
- import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue';
6
- import type { WebhookUpdateData } from './resource_clients/webhook';
7
- /**
8
- * Parses `value` with `schema`, returning the typed result (with schema defaults applied).
9
- * Throws {@link ArgumentValidationError} on failure.
10
- *
11
- * The optional `label` names the interface being validated and is appended to every error line
12
- * (e.g. ``... at `memory` in `ActorStartOptions` ``).
13
- * @internal
14
- */
15
- export declare function parseArgument<TValue, TSchema extends z.ZodType>(value: TValue, schema: TSchema, label?: string): TValue & z.output<TSchema>;
4
+ import type { ApifyApiError } from './apify_api_error.js';
5
+ import { parseArgument } from '@apify/validations';
6
+ import type { RequestQueueClientListRequestsOptions, RequestQueueClientListRequestsResult } from './resource_clients/request_queue.js';
7
+ import type { WebhookUpdateData } from './resource_clients/webhook.js';
8
+ export { parseArgument };
16
9
  /**
17
10
  * Accepts any non-null, non-array object as a predicate for `z.custom()`.
18
11
  * @internal
@@ -210,4 +203,3 @@ export declare function toPathSegment(value: string): string;
210
203
  * `requests/batch` keep their separators; an array has each of its segments encoded individually.
211
204
  */
212
205
  export declare function toPath(path: string | string[]): string;
213
- export {};