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,59 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestQueueClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const zod_1 = require("zod");
6
- const consts_1 = require("@apify/consts");
7
- const log_1 = tslib_1.__importDefault(require("@apify/log"));
8
- const resource_client_1 = require("../base/resource_client");
9
- const utils_1 = require("../utils");
1
+ import { z } from 'zod';
2
+ import { MAX_PAYLOAD_SIZE_BYTES, REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION } from '@apify/consts';
3
+ import log from '@apify/log';
4
+ import { MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS } from '../base/resource_client.js';
5
+ import { anyObjectSchema, cast, catchNotFoundOrThrow, isNonArrayObject, mutuallyExclusive, parseArgument, parseDateFields, pluckData, RequestQueuePaginationIterator, sliceArrayByByteLength, } from '../utils.js';
10
6
  const DEFAULT_PARALLEL_BATCH_ADD_REQUESTS = 5;
11
7
  const DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS = 3;
12
8
  const DEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES_MILLIS = 500;
13
9
  const DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT = 1000;
14
10
  const SAFETY_BUFFER_PERCENT = 0.01 / 100; // 0.01%
15
- const listHeadOptionsSchema = zod_1.z.strictObject({ limit: zod_1.z.number().min(0).optional() });
16
- const listAndLockHeadOptionsSchema = zod_1.z.strictObject({
17
- lockSecs: zod_1.z.number(),
18
- limit: zod_1.z.number().min(0).optional(),
11
+ const listHeadOptionsSchema = z.strictObject({ limit: z.number().min(0).optional() });
12
+ const listAndLockHeadOptionsSchema = z.strictObject({
13
+ lockSecs: z.number(),
14
+ limit: z.number().min(0).optional(),
19
15
  });
20
16
  // Predicates, not `z.looseObject` arms: these run over a whole batch, and an object arm would copy
21
17
  // every key of every request. `id` is assigned by the API, so a new request must not carry one.
22
- const newRequestSchema = zod_1.z.custom((value) => (0, utils_1.isNonArrayObject)(value) && value.id === undefined, 'Expected a request object without an `id`');
23
- const forefrontOptionsSchema = zod_1.z.strictObject({ forefront: zod_1.z.boolean().optional() });
24
- const batchAddRequestsSchema = zod_1.z.array(newRequestSchema).min(1).max(consts_1.REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
25
- const batchAddRequestsWithRetriesSchema = zod_1.z.array(newRequestSchema).min(1);
26
- const optionalBooleanSchema = zod_1.z.boolean().optional();
27
- const optionalNumberSchema = zod_1.z.number().optional();
28
- const requestToDeleteSchema = zod_1.z.custom((value) => (0, utils_1.isNonArrayObject)(value) && (typeof value.id === 'string' || typeof value.uniqueKey === 'string'), 'Expected a request object with an `id` or a `uniqueKey`');
29
- const batchDeleteRequestsSchema = zod_1.z
18
+ const newRequestSchema = z.custom((value) => isNonArrayObject(value) && value.id === undefined, 'Expected a request object without an `id`');
19
+ const forefrontOptionsSchema = z.strictObject({ forefront: z.boolean().optional() });
20
+ const batchAddRequestsSchema = z.array(newRequestSchema).min(1).max(REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
21
+ const batchAddRequestsWithRetriesSchema = z.array(newRequestSchema).min(1);
22
+ const optionalBooleanSchema = z.boolean().optional();
23
+ const optionalNumberSchema = z.number().optional();
24
+ const requestToDeleteSchema = z.custom((value) => isNonArrayObject(value) && (typeof value.id === 'string' || typeof value.uniqueKey === 'string'), 'Expected a request object with an `id` or a `uniqueKey`');
25
+ const batchDeleteRequestsSchema = z
30
26
  .array(requestToDeleteSchema)
31
27
  .min(1)
32
- .max(consts_1.REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
33
- const requestIdSchema = zod_1.z.string();
34
- const existingRequestSchema = zod_1.z.custom((value) => (0, utils_1.isNonArrayObject)(value) && typeof value.id === 'string', 'Expected a request object with an `id`');
35
- const prolongRequestLockOptionsSchema = zod_1.z.strictObject({
36
- lockSecs: zod_1.z.number(),
37
- forefront: zod_1.z.boolean().optional(),
28
+ .max(REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
29
+ const requestIdSchema = z.string();
30
+ const existingRequestSchema = z.custom((value) => isNonArrayObject(value) && typeof value.id === 'string', 'Expected a request object with an `id`');
31
+ const prolongRequestLockOptionsSchema = z.strictObject({
32
+ lockSecs: z.number(),
33
+ forefront: z.boolean().optional(),
38
34
  });
39
- const requestFilterSchema = zod_1.z.array(zod_1.z.enum(['locked', 'pending'])).min(1);
40
- const listRequestsOptionsSchema = zod_1.z
35
+ const requestFilterSchema = z.array(z.enum(['locked', 'pending'])).min(1);
36
+ const listRequestsOptionsSchema = z
41
37
  .strictObject({
42
- limit: zod_1.z.number().min(0).optional(),
43
- exclusiveStartId: zod_1.z.string().optional(),
44
- cursor: zod_1.z.string().optional(),
38
+ limit: z.number().min(0).optional(),
39
+ exclusiveStartId: z.string().optional(),
40
+ cursor: z.string().optional(),
45
41
  filter: requestFilterSchema.optional(),
46
42
  })
47
- .refine(...(0, utils_1.mutuallyExclusive)('exclusiveStartId', 'cursor'));
48
- const paginateRequestsOptionsSchema = zod_1.z
43
+ .refine(...mutuallyExclusive('exclusiveStartId', 'cursor'));
44
+ const paginateRequestsOptionsSchema = z
49
45
  .strictObject({
50
- limit: zod_1.z.number().min(0).optional(),
51
- maxPageLimit: zod_1.z.number().default(DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT),
52
- exclusiveStartId: zod_1.z.string().optional(),
53
- cursor: zod_1.z.string().optional(),
46
+ limit: z.number().min(0).optional(),
47
+ maxPageLimit: z.number().default(DEFAULT_REQUEST_QUEUE_REQUEST_PAGE_LIMIT),
48
+ exclusiveStartId: z.string().optional(),
49
+ cursor: z.string().optional(),
54
50
  filter: requestFilterSchema.optional(),
55
51
  })
56
- .refine(...(0, utils_1.mutuallyExclusive)('exclusiveStartId', 'cursor'));
52
+ .refine(...mutuallyExclusive('exclusiveStartId', 'cursor'));
57
53
  /**
58
54
  * Client for managing a specific Request queue.
59
55
  *
@@ -84,7 +80,7 @@ const paginateRequestsOptionsSchema = zod_1.z
84
80
  *
85
81
  * @see https://docs.apify.com/platform/storage/request-queue
86
82
  */
87
- class RequestQueueClient extends resource_client_1.ResourceClient {
83
+ export class RequestQueueClient extends ResourceClient {
88
84
  clientKey;
89
85
  timeoutMillis;
90
86
  /**
@@ -105,7 +101,7 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
105
101
  * @see https://docs.apify.com/api/v2/request-queue-get
106
102
  */
107
103
  async get() {
108
- return this._get({}, resource_client_1.SMALL_TIMEOUT_MILLIS);
104
+ return this._get({}, SMALL_TIMEOUT_MILLIS);
109
105
  }
110
106
  /**
111
107
  * Updates the Request queue with specified fields.
@@ -115,8 +111,8 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
115
111
  * @see https://docs.apify.com/api/v2/request-queue-put
116
112
  */
117
113
  async update(newFields) {
118
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
119
- return this._update(newFields, resource_client_1.SMALL_TIMEOUT_MILLIS);
114
+ parseArgument(newFields, anyObjectSchema);
115
+ return this._update(newFields, SMALL_TIMEOUT_MILLIS);
120
116
  }
121
117
  /**
122
118
  * Deletes the Request queue.
@@ -124,7 +120,7 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
124
120
  * @see https://docs.apify.com/api/v2/request-queue-delete
125
121
  */
126
122
  async delete() {
127
- return this._delete(resource_client_1.SMALL_TIMEOUT_MILLIS);
123
+ return this._delete(SMALL_TIMEOUT_MILLIS);
128
124
  }
129
125
  /**
130
126
  * Lists requests from the beginning of the queue (head).
@@ -137,17 +133,17 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
137
133
  * @see https://docs.apify.com/api/v2/request-queue-head-get
138
134
  */
139
135
  async listHead(options = {}) {
140
- const parsed = (0, utils_1.parseArgument)(options, listHeadOptionsSchema, 'RequestQueueClientListHeadOptions');
136
+ const parsed = parseArgument(options, listHeadOptionsSchema, 'RequestQueueClientListHeadOptions');
141
137
  const response = await this.httpClient.call({
142
138
  url: this._url('head'),
143
139
  method: 'GET',
144
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
140
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
145
141
  params: this._params({
146
142
  limit: parsed.limit,
147
143
  clientKey: this.clientKey,
148
144
  }),
149
145
  });
150
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
146
+ return cast(parseDateFields(pluckData(response.data)));
151
147
  }
152
148
  /**
153
149
  * Gets and locks the next requests from the queue head for processing.
@@ -183,18 +179,18 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
183
179
  * @since Added in 2.4.1
184
180
  */
185
181
  async listAndLockHead(options) {
186
- const parsed = (0, utils_1.parseArgument)(options, listAndLockHeadOptionsSchema, 'RequestQueueClientListAndLockHeadOptions');
182
+ const parsed = parseArgument(options, listAndLockHeadOptionsSchema, 'RequestQueueClientListAndLockHeadOptions');
187
183
  const response = await this.httpClient.call({
188
184
  url: this._url('head/lock'),
189
185
  method: 'POST',
190
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
186
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
191
187
  params: this._params({
192
188
  limit: parsed.limit,
193
189
  lockSecs: parsed.lockSecs,
194
190
  clientKey: this.clientKey,
195
191
  }),
196
192
  });
197
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
193
+ return cast(parseDateFields(pluckData(response.data)));
198
194
  }
199
195
  /**
200
196
  * Adds a single request to the queue.
@@ -235,19 +231,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
235
231
  * ```
236
232
  */
237
233
  async addRequest(request, options = {}) {
238
- (0, utils_1.parseArgument)(request, newRequestSchema);
239
- const parsed = (0, utils_1.parseArgument)(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
234
+ parseArgument(request, newRequestSchema);
235
+ const parsed = parseArgument(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
240
236
  const response = await this.httpClient.call({
241
237
  url: this._url('requests'),
242
238
  method: 'POST',
243
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
239
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
244
240
  data: request,
245
241
  params: this._params({
246
242
  forefront: parsed.forefront,
247
243
  clientKey: this.clientKey,
248
244
  }),
249
245
  });
250
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
246
+ return cast(parseDateFields(pluckData(response.data)));
251
247
  }
252
248
  /**
253
249
  * Writes requests to Request queue in batch.
@@ -255,19 +251,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
255
251
  * @private
256
252
  */
257
253
  async _batchAddRequests(requests, options = {}) {
258
- (0, utils_1.parseArgument)(requests, batchAddRequestsSchema);
259
- const parsed = (0, utils_1.parseArgument)(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
254
+ parseArgument(requests, batchAddRequestsSchema);
255
+ const parsed = parseArgument(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
260
256
  const { data } = await this.httpClient.call({
261
257
  url: this._url('requests/batch'),
262
258
  method: 'POST',
263
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
259
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
264
260
  data: requests,
265
261
  params: this._params({
266
262
  forefront: parsed.forefront,
267
263
  clientKey: this.clientKey,
268
264
  }),
269
265
  });
270
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(data)));
266
+ return cast(parseDateFields(pluckData(data)));
271
267
  }
272
268
  async _batchAddRequestsWithRetries(requests, options = {}) {
273
269
  const { forefront, maxUnprocessedRequestsRetries = DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS, minDelayBetweenUnprocessedRequestsRetriesMillis = DEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES_MILLIS, } = options;
@@ -300,7 +296,7 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
300
296
  }
301
297
  }
302
298
  catch (err) {
303
- log_1.default.exception(err, 'Request batch insert failed');
299
+ log.exception(err, 'Request batch insert failed');
304
300
  // When something fails and http client does not retry, the remaining requests are treated as unprocessed.
305
301
  // This ensures that this method does not throw and keeps the signature.
306
302
  const processedRequestsUniqueKeys = processedRequests.map(({ uniqueKey }) => uniqueKey);
@@ -316,7 +312,7 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
316
312
  });
317
313
  }
318
314
  const result = { processedRequests, unprocessedRequests };
319
- return (0, utils_1.cast)((0, utils_1.parseDateFields)(result));
315
+ return cast(parseDateFields(result));
320
316
  }
321
317
  /**
322
318
  * Adds multiple requests to the queue in a single operation.
@@ -358,19 +354,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
358
354
  */
359
355
  async batchAddRequests(requests, options = {}) {
360
356
  const { forefront, maxUnprocessedRequestsRetries = DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS, maxParallel = DEFAULT_PARALLEL_BATCH_ADD_REQUESTS, minDelayBetweenUnprocessedRequestsRetriesMillis = DEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES_MILLIS, } = options;
361
- (0, utils_1.parseArgument)(requests, batchAddRequestsWithRetriesSchema);
362
- (0, utils_1.parseArgument)(forefront, optionalBooleanSchema);
363
- (0, utils_1.parseArgument)(maxUnprocessedRequestsRetries, optionalNumberSchema);
364
- (0, utils_1.parseArgument)(maxParallel, optionalNumberSchema);
365
- (0, utils_1.parseArgument)(minDelayBetweenUnprocessedRequestsRetriesMillis, optionalNumberSchema);
357
+ parseArgument(requests, batchAddRequestsWithRetriesSchema);
358
+ parseArgument(forefront, optionalBooleanSchema);
359
+ parseArgument(maxUnprocessedRequestsRetries, optionalNumberSchema);
360
+ parseArgument(maxParallel, optionalNumberSchema);
361
+ parseArgument(minDelayBetweenUnprocessedRequestsRetriesMillis, optionalNumberSchema);
366
362
  const executingRequests = new Set();
367
363
  const individualResults = [];
368
- const payloadSizeLimitBytes = consts_1.MAX_PAYLOAD_SIZE_BYTES - Math.ceil(consts_1.MAX_PAYLOAD_SIZE_BYTES * SAFETY_BUFFER_PERCENT);
364
+ const payloadSizeLimitBytes = MAX_PAYLOAD_SIZE_BYTES - Math.ceil(MAX_PAYLOAD_SIZE_BYTES * SAFETY_BUFFER_PERCENT);
369
365
  // Keep a pool of up to `maxParallel` requests running at once
370
366
  let i = 0;
371
367
  while (i < requests.length) {
372
- const slicedRequests = requests.slice(i, i + consts_1.REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
373
- const requestsInBatch = (0, utils_1.sliceArrayByByteLength)(slicedRequests, payloadSizeLimitBytes, i);
368
+ const slicedRequests = requests.slice(i, i + REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION);
369
+ const requestsInBatch = sliceArrayByByteLength(slicedRequests, payloadSizeLimitBytes, i);
374
370
  const requestPromise = this._batchAddRequestsWithRetries(requestsInBatch, options);
375
371
  executingRequests.add(requestPromise);
376
372
  void requestPromise.then((batchAddResult) => {
@@ -406,17 +402,17 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
406
402
  * @since Added in 2.3.0
407
403
  */
408
404
  async batchDeleteRequests(requests) {
409
- (0, utils_1.parseArgument)(requests, batchDeleteRequestsSchema);
405
+ parseArgument(requests, batchDeleteRequestsSchema);
410
406
  const { data } = await this.httpClient.call({
411
407
  url: this._url('requests/batch'),
412
408
  method: 'DELETE',
413
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
409
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
414
410
  data: requests,
415
411
  params: this._params({
416
412
  clientKey: this.clientKey,
417
413
  }),
418
414
  });
419
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(data)));
415
+ return cast(parseDateFields(pluckData(data)));
420
416
  }
421
417
  /**
422
418
  * Gets a specific request from the queue by its ID.
@@ -426,19 +422,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
426
422
  * @see https://docs.apify.com/api/v2/request-queue-request-get
427
423
  */
428
424
  async getRequest(id) {
429
- (0, utils_1.parseArgument)(id, requestIdSchema);
425
+ parseArgument(id, requestIdSchema);
430
426
  const requestOpts = {
431
427
  url: this._url(['requests', id]),
432
428
  method: 'GET',
433
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
429
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
434
430
  params: this._params(),
435
431
  };
436
432
  try {
437
433
  const response = await this.httpClient.call(requestOpts);
438
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
434
+ return cast(parseDateFields(pluckData(response.data)));
439
435
  }
440
436
  catch (err) {
441
- (0, utils_1.catchNotFoundOrThrow)(err);
437
+ catchNotFoundOrThrow(err);
442
438
  }
443
439
  return undefined;
444
440
  }
@@ -451,19 +447,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
451
447
  * @see https://docs.apify.com/api/v2/request-queue-request-put
452
448
  */
453
449
  async updateRequest(request, options = {}) {
454
- (0, utils_1.parseArgument)(request, existingRequestSchema);
455
- const parsed = (0, utils_1.parseArgument)(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
450
+ parseArgument(request, existingRequestSchema);
451
+ const parsed = parseArgument(options, forefrontOptionsSchema, 'RequestQueueClientAddRequestOptions');
456
452
  const response = await this.httpClient.call({
457
453
  url: this._url(['requests', request.id]),
458
454
  method: 'PUT',
459
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
455
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
460
456
  data: request,
461
457
  params: this._params({
462
458
  forefront: parsed.forefront,
463
459
  clientKey: this.clientKey,
464
460
  }),
465
461
  });
466
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
462
+ return cast(parseDateFields(pluckData(response.data)));
467
463
  }
468
464
  /**
469
465
  * Deletes a specific request from the queue.
@@ -471,11 +467,11 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
471
467
  * @param id - Request ID
472
468
  */
473
469
  async deleteRequest(id) {
474
- (0, utils_1.parseArgument)(id, requestIdSchema);
470
+ parseArgument(id, requestIdSchema);
475
471
  await this.httpClient.call({
476
472
  url: this._url(['requests', id]),
477
473
  method: 'DELETE',
478
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
474
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
479
475
  params: this._params({
480
476
  clientKey: this.clientKey,
481
477
  }),
@@ -507,19 +503,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
507
503
  * @since Added in 2.4.1
508
504
  */
509
505
  async prolongRequestLock(id, options) {
510
- (0, utils_1.parseArgument)(id, requestIdSchema);
511
- const parsed = (0, utils_1.parseArgument)(options, prolongRequestLockOptionsSchema, 'RequestQueueClientProlongRequestLockOptions');
506
+ parseArgument(id, requestIdSchema);
507
+ const parsed = parseArgument(options, prolongRequestLockOptionsSchema, 'RequestQueueClientProlongRequestLockOptions');
512
508
  const response = await this.httpClient.call({
513
509
  url: this._url(['requests', id, 'lock']),
514
510
  method: 'PUT',
515
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
511
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
516
512
  params: this._params({
517
513
  forefront: parsed.forefront,
518
514
  lockSecs: parsed.lockSecs,
519
515
  clientKey: this.clientKey,
520
516
  }),
521
517
  });
522
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
518
+ return cast(parseDateFields(pluckData(response.data)));
523
519
  }
524
520
  /**
525
521
  * Releases the lock on a request, allowing other clients to process it.
@@ -533,12 +529,12 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
533
529
  * @since Added in 2.4.1
534
530
  */
535
531
  async deleteRequestLock(id, options = {}) {
536
- (0, utils_1.parseArgument)(id, requestIdSchema);
537
- const parsed = (0, utils_1.parseArgument)(options, forefrontOptionsSchema, 'RequestQueueClientDeleteRequestLockOptions');
532
+ parseArgument(id, requestIdSchema);
533
+ const parsed = parseArgument(options, forefrontOptionsSchema, 'RequestQueueClientDeleteRequestLockOptions');
538
534
  await this.httpClient.call({
539
535
  url: this._url(['requests', id, 'lock']),
540
536
  method: 'DELETE',
541
- timeout: Math.min(resource_client_1.SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
537
+ timeout: Math.min(SMALL_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
542
538
  params: this._params({
543
539
  forefront: parsed.forefront,
544
540
  clientKey: this.clientKey,
@@ -557,19 +553,19 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
557
553
  * @since Added in 2.5.1
558
554
  */
559
555
  listRequests(options = {}) {
560
- const parsed = (0, utils_1.parseArgument)(options, listRequestsOptionsSchema, 'RequestQueueClientListRequestsOptions');
556
+ const parsed = parseArgument(options, listRequestsOptionsSchema, 'RequestQueueClientListRequestsOptions');
561
557
  const getPaginatedList = async (rqListOptions = {}) => {
562
558
  const response = await this.httpClient.call({
563
559
  url: this._url('requests'),
564
560
  method: 'GET',
565
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
561
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
566
562
  params: this._params({
567
563
  ...rqListOptions,
568
564
  filter: rqListOptions.filter ? rqListOptions.filter.join(',') : undefined,
569
565
  clientKey: this.clientKey,
570
566
  }),
571
567
  });
572
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
568
+ return cast(parseDateFields(pluckData(response.data)));
573
569
  };
574
570
  const paginatedListPromise = getPaginatedList(parsed);
575
571
  async function* asyncGenerator() {
@@ -614,12 +610,12 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
614
610
  const response = await this.httpClient.call({
615
611
  url: this._url('requests/unlock'),
616
612
  method: 'POST',
617
- timeout: Math.min(resource_client_1.MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
613
+ timeout: Math.min(MEDIUM_TIMEOUT_MILLIS, this.timeoutMillis ?? Infinity),
618
614
  params: this._params({
619
615
  clientKey: this.clientKey,
620
616
  }),
621
617
  });
622
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
618
+ return cast(parseDateFields(pluckData(response.data)));
623
619
  }
624
620
  /**
625
621
  * Returns an async iterable for paginating through all requests in the queue.
@@ -640,8 +636,8 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
640
636
  * @since Added in 2.5.1
641
637
  */
642
638
  paginateRequests(options = {}) {
643
- const { limit, exclusiveStartId, cursor, filter, maxPageLimit } = (0, utils_1.parseArgument)(options, paginateRequestsOptionsSchema, 'RequestQueueClientPaginateRequestsOptions');
644
- return new utils_1.RequestQueuePaginationIterator({
639
+ const { limit, exclusiveStartId, cursor, filter, maxPageLimit } = parseArgument(options, paginateRequestsOptionsSchema, 'RequestQueueClientPaginateRequestsOptions');
640
+ return new RequestQueuePaginationIterator({
645
641
  getPage: async (pageOptions) => this.listRequests({ ...pageOptions, filter }),
646
642
  limit,
647
643
  exclusiveStartId,
@@ -650,4 +646,3 @@ class RequestQueueClient extends resource_client_1.ResourceClient {
650
646
  });
651
647
  }
652
648
  }
653
- exports.RequestQueueClient = RequestQueueClient;
@@ -1,8 +1,8 @@
1
1
  import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
2
- import type { ApiClientSubResourceOptions } from '../base/api_client';
3
- import { ResourceCollectionClient } from '../base/resource_collection_client';
4
- import type { PaginatedList, PaginationOptions } from '../utils';
5
- import type { RequestQueue } from './request_queue';
2
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
3
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
4
+ import type { PaginatedList, PaginationOptions } from '../utils.js';
5
+ import type { RequestQueue } from './request_queue.js';
6
6
  /**
7
7
  * Client for managing the collection of Request queues in your account.
8
8
  *
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestQueueCollectionClient = void 0;
4
- const zod_1 = require("zod");
5
- const consts_1 = require("@apify/consts");
6
- const resource_collection_client_1 = require("../base/resource_collection_client");
7
- const utils_1 = require("../utils");
8
- const listOptionsSchema = zod_1.z.strictObject({
9
- unnamed: zod_1.z.boolean().optional(),
10
- ...utils_1.paginationOptionsShape,
11
- desc: zod_1.z.boolean().optional(),
12
- ownership: zod_1.z.enum(consts_1.STORAGE_OWNERSHIP_FILTER).optional(),
1
+ import { z } from 'zod';
2
+ import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
3
+ import { ResourceCollectionClient } from '../base/resource_collection_client.js';
4
+ import { paginationOptionsShape, parseArgument } from '../utils.js';
5
+ const listOptionsSchema = z.strictObject({
6
+ unnamed: z.boolean().optional(),
7
+ ...paginationOptionsShape,
8
+ desc: z.boolean().optional(),
9
+ ownership: z.enum(STORAGE_OWNERSHIP_FILTER).optional(),
13
10
  });
14
- const nameSchema = zod_1.z.string().optional();
11
+ const nameSchema = z.string().optional();
15
12
  /**
16
13
  * Client for managing the collection of Request queues in your account.
17
14
  *
@@ -32,7 +29,7 @@ const nameSchema = zod_1.z.string().optional();
32
29
  *
33
30
  * @see https://docs.apify.com/platform/storage/request-queue
34
31
  */
35
- class RequestQueueCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
32
+ export class RequestQueueCollectionClient extends ResourceCollectionClient {
36
33
  /**
37
34
  * @hidden
38
35
  */
@@ -63,7 +60,7 @@ class RequestQueueCollectionClient extends resource_collection_client_1.Resource
63
60
  * @see https://docs.apify.com/api/v2/request-queues-get
64
61
  */
65
62
  list(options = {}) {
66
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'RequestQueueCollectionListOptions');
63
+ const parsed = parseArgument(options, listOptionsSchema, 'RequestQueueCollectionListOptions');
67
64
  return this._listPaginated(parsed);
68
65
  }
69
66
  /**
@@ -74,8 +71,7 @@ class RequestQueueCollectionClient extends resource_collection_client_1.Resource
74
71
  * @see https://docs.apify.com/api/v2/request-queues-post
75
72
  */
76
73
  async getOrCreate(name) {
77
- (0, utils_1.parseArgument)(name, nameSchema);
74
+ parseArgument(name, nameSchema);
78
75
  return this._getOrCreate(name);
79
76
  }
80
77
  }
81
- exports.RequestQueueCollectionClient = RequestQueueCollectionClient;
@@ -1,13 +1,13 @@
1
1
  import type { RUN_GENERAL_ACCESS } from '@apify/consts';
2
2
  import { Log } from '@apify/log';
3
- import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
4
- import { ResourceClient } from '../base/resource_client';
5
- import type { ApifyResponse } from '../http_client';
6
- import type { ActorRun } from './actor';
7
- import { DatasetClient } from './dataset';
8
- import { KeyValueStoreClient } from './key_value_store';
9
- import { LogClient, StreamedLog } from './log';
10
- import { RequestQueueClient } from './request_queue';
3
+ import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
4
+ import { ResourceClient } from '../base/resource_client.js';
5
+ import type { ApifyResponse } from '../http_client.js';
6
+ import type { ActorRun } from './actor.js';
7
+ import { DatasetClient } from './dataset.js';
8
+ import { KeyValueStoreClient } from './key_value_store.js';
9
+ import { LogClient, StreamedLog } from './log.js';
10
+ import { RequestQueueClient } from './request_queue.js';
11
11
  /**
12
12
  * Client for managing a specific Actor run.
13
13
  *