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,51 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyValueStoreClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const zod_1 = require("zod");
6
- const log_1 = tslib_1.__importDefault(require("@apify/log"));
7
- const utilities_1 = require("@apify/utilities");
8
- const resource_client_1 = require("../base/resource_client");
9
- const utils_1 = require("../utils");
10
- const listKeysOptionsSchema = zod_1.z.strictObject({
11
- limit: zod_1.z.number().min(0).optional(),
12
- exclusiveStartKey: zod_1.z.string().optional(),
13
- collection: zod_1.z.string().optional(),
14
- prefix: zod_1.z.string().optional(),
15
- signature: zod_1.z.string().optional(),
1
+ import { z } from 'zod';
2
+ import log from '@apify/log';
3
+ import { createHmacSignatureAsync, createStorageContentSignatureAsync } from '@apify/utilities';
4
+ import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
5
+ import * as schemas from '../schemas.js';
6
+ import { anyObjectSchema, applyQueryParamsToUrl, catchNotFoundOrThrow, isBuffer, isNode, isStream, parseArgument, parseResponse, } from '../utils.js';
7
+ const listKeysOptionsSchema = z.strictObject({
8
+ limit: z.number().min(0).optional(),
9
+ exclusiveStartKey: z.string().optional(),
10
+ collection: z.string().optional(),
11
+ prefix: z.string().optional(),
12
+ signature: z.string().optional(),
16
13
  });
17
- const nonEmptyKeySchema = zod_1.z.string().min(1);
14
+ const nonEmptyKeySchema = z.string().min(1);
18
15
  // `signature` is left out - this method produces one. The options type omits it to match.
19
- const createKeysPublicUrlOptionsSchema = zod_1.z.strictObject({
20
- limit: zod_1.z.number().min(0).optional(),
21
- exclusiveStartKey: zod_1.z.string().optional(),
22
- collection: zod_1.z.string().optional(),
23
- prefix: zod_1.z.string().optional(),
24
- expiresInSecs: zod_1.z.number().optional(),
16
+ const createKeysPublicUrlOptionsSchema = z.strictObject({
17
+ limit: z.number().min(0).optional(),
18
+ exclusiveStartKey: z.string().optional(),
19
+ collection: z.string().optional(),
20
+ prefix: z.string().optional(),
21
+ expiresInSecs: z.number().optional(),
25
22
  });
26
- const keySchema = zod_1.z.string();
27
- const getRecordOptionsSchema = zod_1.z.strictObject({
28
- buffer: zod_1.z.boolean().optional(),
29
- stream: zod_1.z.boolean().optional(),
30
- disableRedirect: zod_1.z.boolean().optional(),
31
- signature: zod_1.z.string().optional(),
23
+ const keySchema = z.string();
24
+ const getRecordOptionsSchema = z.strictObject({
25
+ buffer: z.boolean().optional(),
26
+ stream: z.boolean().optional(),
27
+ disableRedirect: z.boolean().optional(),
28
+ signature: z.string().optional(),
32
29
  });
33
- const recordSchema = zod_1.z.strictObject({
34
- key: zod_1.z.string(),
30
+ const recordSchema = z.strictObject({
31
+ key: z.string(),
35
32
  // Values are arbitrary, and a `z.object()` arm would walk every key of a large buffer.
36
33
  // Symbols, bigints, functions and non-finite numbers are rejected because they cannot be serialized
37
34
  // to JSON - symbols and bigints throw, functions stringify to `undefined` (an empty request body),
38
35
  // and `NaN` / `Infinity` would silently become `null`.
39
- value: zod_1.z.custom((value) => value !== undefined &&
36
+ value: z.custom((value) => value !== undefined &&
40
37
  typeof value !== 'symbol' &&
41
38
  typeof value !== 'bigint' &&
42
39
  typeof value !== 'function' &&
43
- (typeof value !== 'number' || Number.isFinite(value)), 'Expected a defined, JSON-serializable value'),
44
- contentType: zod_1.z.string().min(1).optional(),
40
+ (typeof value !== 'number' || Number.isFinite(value)), 'Expected a JSON-serializable value, binary data, or a stream'),
41
+ contentType: z.string().min(1).optional(),
45
42
  });
46
- const recordOptionsSchema = zod_1.z.strictObject({
47
- timeoutSecs: zod_1.z.number().optional(),
48
- doNotRetryTimeouts: zod_1.z.boolean().optional(),
43
+ const recordOptionsSchema = z.strictObject({
44
+ timeoutSecs: z.number().optional(),
45
+ doNotRetryTimeouts: z.boolean().optional(),
49
46
  });
50
47
  /**
51
48
  * Client for managing a specific key-value store.
@@ -75,7 +72,7 @@ const recordOptionsSchema = zod_1.z.strictObject({
75
72
  *
76
73
  * @see https://docs.apify.com/platform/storage/key-value-store
77
74
  */
78
- class KeyValueStoreClient extends resource_client_1.ResourceClient {
75
+ export class KeyValueStoreClient extends ResourceClient {
79
76
  /**
80
77
  * @hidden
81
78
  */
@@ -92,7 +89,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
92
89
  * @see https://docs.apify.com/api/v2/key-value-store-get
93
90
  */
94
91
  async get() {
95
- return this._get({}, resource_client_1.SMALL_TIMEOUT_MILLIS);
92
+ return this._get(schemas.KeyValueStore(), {}, SMALL_TIMEOUT_MILLIS);
96
93
  }
97
94
  /**
98
95
  * Updates the key-value store with specified fields.
@@ -105,8 +102,8 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
105
102
  * @see https://docs.apify.com/api/v2/key-value-store-put
106
103
  */
107
104
  async update(newFields) {
108
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
109
- return this._update(newFields, resource_client_1.DEFAULT_TIMEOUT_MILLIS);
105
+ parseArgument(newFields, anyObjectSchema);
106
+ return this._update(schemas.KeyValueStore(), newFields, DEFAULT_TIMEOUT_MILLIS);
110
107
  }
111
108
  /**
112
109
  * Deletes the key-value store.
@@ -114,7 +111,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
114
111
  * @see https://docs.apify.com/api/v2/key-value-store-delete
115
112
  */
116
113
  async delete() {
117
- return this._delete(resource_client_1.SMALL_TIMEOUT_MILLIS);
114
+ return this._delete(SMALL_TIMEOUT_MILLIS);
118
115
  }
119
116
  /**
120
117
  * Lists all keys in the key-value store.
@@ -152,15 +149,15 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
152
149
  * ```
153
150
  */
154
151
  listKeys(options = {}) {
155
- const parsed = (0, utils_1.parseArgument)(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
152
+ const parsed = parseArgument(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
156
153
  const getPaginatedList = async (kvsListOptions = {}) => {
157
154
  const response = await this.httpClient.call({
158
155
  url: this._url('keys'),
159
156
  method: 'GET',
160
157
  params: this._params(kvsListOptions),
161
- timeout: resource_client_1.MEDIUM_TIMEOUT_MILLIS,
158
+ timeout: MEDIUM_TIMEOUT_MILLIS,
162
159
  });
163
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
160
+ return parseResponse(response, schemas.ListOfKeys());
164
161
  };
165
162
  const paginatedListPromise = getPaginatedList(parsed);
166
163
  async function* asyncGenerator() {
@@ -168,7 +165,9 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
168
165
  yield* currentPage.items;
169
166
  let remainingItems = parsed.limit ? parsed.limit - currentPage.items.length : undefined;
170
167
  while (currentPage.items.length > 0 && // Continue only if at least some items were returned in the last page.
171
- currentPage.nextExclusiveStartKey !== null && // Continue only if there is some next key.
168
+ // Continue only if there is some next key. The API answers with `null` on the last page and
169
+ // omits the field entirely for a listing that was not truncated.
170
+ currentPage.nextExclusiveStartKey != null &&
172
171
  (remainingItems === undefined || remainingItems > 0) // Continue only if the limit was not exceeded.
173
172
  ) {
174
173
  const newOptions = {
@@ -206,11 +205,11 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
206
205
  * @since Added in 2.14.0
207
206
  */
208
207
  async getRecordPublicUrl(key) {
209
- (0, utils_1.parseArgument)(key, nonEmptyKeySchema);
208
+ parseArgument(key, nonEmptyKeySchema);
210
209
  const store = await this.get();
211
210
  const recordPublicUrl = new URL(this._publicUrl(['records', key]));
212
211
  if (store?.urlSigningSecretKey) {
213
- const signature = await (0, utilities_1.createHmacSignatureAsync)(store.urlSigningSecretKey, key);
212
+ const signature = await createHmacSignatureAsync(store.urlSigningSecretKey, key);
214
213
  recordPublicUrl.searchParams.append('signature', signature);
215
214
  }
216
215
  return recordPublicUrl.toString();
@@ -239,19 +238,19 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
239
238
  * @since Added in 2.13.0
240
239
  */
241
240
  async createKeysPublicUrl(options = {}) {
242
- const parsed = (0, utils_1.parseArgument)(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
241
+ const parsed = parseArgument(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
243
242
  const store = await this.get();
244
243
  const { expiresInSecs, ...queryOptions } = parsed;
245
244
  let createdPublicKeysUrl = new URL(this._publicUrl('keys'));
246
245
  if (store?.urlSigningSecretKey) {
247
- const signature = await (0, utilities_1.createStorageContentSignatureAsync)({
246
+ const signature = await createStorageContentSignatureAsync({
248
247
  resourceId: store.id,
249
248
  urlSigningSecretKey: store.urlSigningSecretKey,
250
249
  expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
251
250
  });
252
251
  createdPublicKeysUrl.searchParams.set('signature', signature);
253
252
  }
254
- createdPublicKeysUrl = (0, utils_1.applyQueryParamsToUrl)(createdPublicKeysUrl, queryOptions);
253
+ createdPublicKeysUrl = applyQueryParamsToUrl(createdPublicKeysUrl, queryOptions);
255
254
  return createdPublicKeysUrl.toString();
256
255
  }
257
256
  /**
@@ -283,18 +282,18 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
283
282
  return true;
284
283
  }
285
284
  catch (err) {
286
- (0, utils_1.catchNotFoundOrThrow)(err);
285
+ catchNotFoundOrThrow(err);
287
286
  }
288
287
  return false;
289
288
  }
290
289
  async getRecord(key, options = {}) {
291
- (0, utils_1.parseArgument)(key, keySchema);
292
- const parsed = (0, utils_1.parseArgument)(options, getRecordOptionsSchema, 'KeyValueClientGetRecordOptions');
293
- if (parsed.stream && !(0, utils_1.isNode)()) {
290
+ parseArgument(key, keySchema);
291
+ const parsed = parseArgument(options, getRecordOptionsSchema, 'KeyValueClientGetRecordOptions');
292
+ if (parsed.stream && !isNode()) {
294
293
  throw new Error('The stream option can only be used in Node.js environment.');
295
294
  }
296
295
  if ('disableRedirect' in parsed) {
297
- log_1.default.deprecated('The disableRedirect option for getRecord() is deprecated. ' +
296
+ log.deprecated('The disableRedirect option for getRecord() is deprecated. ' +
298
297
  'It has no effect and will be removed in the following major release.');
299
298
  }
300
299
  const queryParams = { attachment: 'true' };
@@ -304,7 +303,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
304
303
  url: this._url(['records', key]),
305
304
  method: 'GET',
306
305
  params: this._params(queryParams),
307
- timeout: resource_client_1.DEFAULT_TIMEOUT_MILLIS,
306
+ timeout: DEFAULT_TIMEOUT_MILLIS,
308
307
  };
309
308
  if (parsed.buffer)
310
309
  requestOpts.forceBuffer = true;
@@ -319,7 +318,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
319
318
  };
320
319
  }
321
320
  catch (err) {
322
- (0, utils_1.catchNotFoundOrThrow)(err);
321
+ catchNotFoundOrThrow(err);
323
322
  }
324
323
  return undefined;
325
324
  }
@@ -336,11 +335,11 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
336
335
  *
337
336
  * @param record - The record to store
338
337
  * @param record.key - Record key (unique identifier)
339
- * @param record.value - Record value (object, string, Buffer, or Stream)
338
+ * @param record.value - Record value (a JSON-serializable value, Buffer, ArrayBuffer, typed array, or Readable)
340
339
  * @param record.contentType - Optional MIME type. Auto-detected if not provided:
341
340
  * - Objects: `'application/json; charset=utf-8'`
342
341
  * - Strings: `'text/plain; charset=utf-8'`
343
- * - Buffers/Streams: `'application/octet-stream'`
342
+ * - Binary values and streams: `'application/octet-stream'`
344
343
  * @param options - Storage options
345
344
  * @param options.timeoutSecs - Timeout for the upload in seconds. Default varies by value size.
346
345
  * @param options.doNotRetryTimeouts - If `true`, don't retry on timeout errors. Default is `false`.
@@ -371,12 +370,12 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
371
370
  * ```
372
371
  */
373
372
  async setRecord(record, options = {}) {
374
- (0, utils_1.parseArgument)(record, recordSchema);
375
- const parsed = (0, utils_1.parseArgument)(options, recordOptionsSchema, 'KeyValueStoreRecordOptions');
373
+ parseArgument(record, recordSchema);
374
+ const parsed = parseArgument(options, recordOptionsSchema, 'KeyValueStoreRecordOptions');
376
375
  const { key } = record;
377
376
  let { value, contentType } = record;
378
377
  const { timeoutSecs, doNotRetryTimeouts } = parsed;
379
- const isValueStreamOrBuffer = (0, utils_1.isStream)(value) || (0, utils_1.isBuffer)(value);
378
+ const isValueStreamOrBuffer = isStream(value) || isBuffer(value);
380
379
  // To allow saving Objects to JSON without providing content type
381
380
  if (!contentType) {
382
381
  if (isValueStreamOrBuffer)
@@ -403,7 +402,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
403
402
  data: value,
404
403
  headers: contentType ? { 'content-type': contentType } : undefined,
405
404
  doNotRetryTimeouts,
406
- timeout: timeoutSecs !== undefined ? timeoutSecs * 1000 : resource_client_1.DEFAULT_TIMEOUT_MILLIS,
405
+ timeout: timeoutSecs !== undefined ? timeoutSecs * 1000 : DEFAULT_TIMEOUT_MILLIS,
407
406
  };
408
407
  await this.httpClient.call(uploadOpts);
409
408
  }
@@ -419,13 +418,12 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
419
418
  * ```
420
419
  */
421
420
  async deleteRecord(key) {
422
- (0, utils_1.parseArgument)(key, keySchema);
421
+ parseArgument(key, keySchema);
423
422
  await this.httpClient.call({
424
423
  url: this._url(['records', key]),
425
424
  method: 'DELETE',
426
425
  params: this._params(),
427
- timeout: resource_client_1.SMALL_TIMEOUT_MILLIS,
426
+ timeout: SMALL_TIMEOUT_MILLIS,
428
427
  });
429
428
  }
430
429
  }
431
- exports.KeyValueStoreClient = KeyValueStoreClient;
@@ -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 { KeyValueStore } from './key_value_store';
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 { KeyValueStore } from './key_value_store.js';
6
6
  /**
7
7
  * Client for managing the collection of Key-value stores in your account.
8
8
  *
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyValueStoreCollectionClient = 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 * as schemas from '../schemas.js';
5
+ import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
6
+ const listOptionsSchema = z.strictObject({
7
+ unnamed: z.boolean().optional(),
8
+ ...paginationOptionsShape,
9
+ desc: z.boolean().optional(),
10
+ ownership: z.enum(STORAGE_OWNERSHIP_FILTER).optional(),
13
11
  });
14
- const nameSchema = zod_1.z.string().optional();
15
- const schemaSchema = utils_1.anyObjectSchema.optional();
12
+ const nameSchema = z.string().optional();
13
+ const schemaSchema = anyObjectSchema.optional();
16
14
  /**
17
15
  * Client for managing the collection of Key-value stores in your account.
18
16
  *
@@ -33,7 +31,7 @@ const schemaSchema = utils_1.anyObjectSchema.optional();
33
31
  *
34
32
  * @see https://docs.apify.com/platform/storage/key-value-store
35
33
  */
36
- class KeyValueStoreCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
34
+ export class KeyValueStoreCollectionClient extends ResourceCollectionClient {
37
35
  /**
38
36
  * @hidden
39
37
  */
@@ -64,8 +62,8 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
64
62
  * @see https://docs.apify.com/api/v2/key-value-stores-get
65
63
  */
66
64
  list(options = {}) {
67
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
68
- return this._listPaginated(parsed);
65
+ const parsed = parseArgument(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
66
+ return this._listPaginated(schemas.ListOfKeyValueStores(), parsed);
69
67
  }
70
68
  /**
71
69
  * Gets or creates a key-value store with the specified name.
@@ -76,9 +74,8 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
76
74
  * @see https://docs.apify.com/api/v2/key-value-stores-post
77
75
  */
78
76
  async getOrCreate(name, options) {
79
- (0, utils_1.parseArgument)(name, nameSchema);
80
- (0, utils_1.parseArgument)(options?.schema, schemaSchema); // TODO: Add schema validation
81
- return this._getOrCreate(name, options);
77
+ parseArgument(name, nameSchema);
78
+ parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
79
+ return this._getOrCreate(schemas.KeyValueStore(), name, options);
82
80
  }
83
81
  }
84
- exports.KeyValueStoreCollectionClient = KeyValueStoreCollectionClient;
@@ -1,8 +1,8 @@
1
1
  import type { Readable } from 'node:stream';
2
2
  import type { Log } from '@apify/log';
3
3
  import { Logger, LogLevel } from '@apify/log';
4
- import type { ApiClientSubResourceOptions } from '../base/api_client';
5
- import { ResourceClient } from '../base/resource_client';
4
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
5
+ import { ResourceClient } from '../base/resource_client.js';
6
6
  /**
7
7
  * Client for accessing Actor run or build logs.
8
8
  *
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamedLog = exports.LoggerActorRedirect = exports.LogClient = void 0;
4
- const tslib_1 = require("tslib");
5
- const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
6
- const log_1 = tslib_1.__importStar(require("@apify/log"));
7
- const resource_client_1 = require("../base/resource_client");
8
- const utils_1 = require("../utils");
1
+ import c from 'ansi-colors';
2
+ import log, { Logger, LogLevel } from '@apify/log';
3
+ import { ResourceClient } from '../base/resource_client.js';
4
+ import { cast, catchNotFoundOrThrow } from '../utils.js';
9
5
  /**
10
6
  * Client for accessing Actor run or build logs.
11
7
  *
@@ -28,7 +24,7 @@ const utils_1 = require("../utils");
28
24
  *
29
25
  * @see https://docs.apify.com/platform/actors/running/runs-and-builds#logging
30
26
  */
31
- class LogClient extends resource_client_1.ResourceClient {
27
+ export class LogClient extends ResourceClient {
32
28
  /**
33
29
  * @hidden
34
30
  */
@@ -54,10 +50,10 @@ class LogClient extends resource_client_1.ResourceClient {
54
50
  };
55
51
  try {
56
52
  const response = await this.httpClient.call(requestOpts);
57
- return (0, utils_1.cast)(response.data);
53
+ return cast(response.data);
58
54
  }
59
55
  catch (err) {
60
- (0, utils_1.catchNotFoundOrThrow)(err);
56
+ catchNotFoundOrThrow(err);
61
57
  }
62
58
  return undefined;
63
59
  }
@@ -82,22 +78,21 @@ class LogClient extends resource_client_1.ResourceClient {
82
78
  };
83
79
  try {
84
80
  const response = await this.httpClient.call(requestOpts);
85
- return (0, utils_1.cast)(response.data);
81
+ return cast(response.data);
86
82
  }
87
83
  catch (err) {
88
- (0, utils_1.catchNotFoundOrThrow)(err);
84
+ catchNotFoundOrThrow(err);
89
85
  }
90
86
  return undefined;
91
87
  }
92
88
  }
93
- exports.LogClient = LogClient;
94
89
  /**
95
90
  * Logger for redirected actor logs.
96
91
  * @since Added in 2.20.0
97
92
  */
98
- class LoggerActorRedirect extends log_1.Logger {
93
+ export class LoggerActorRedirect extends Logger {
99
94
  constructor(options = {}) {
100
- super({ skipTime: true, level: log_1.LogLevel.DEBUG, ...options });
95
+ super({ skipTime: true, level: LogLevel.DEBUG, ...options });
101
96
  }
102
97
  _log(level, message, data, exception, opts = {}) {
103
98
  if (level > this.options.level) {
@@ -112,19 +107,18 @@ class LoggerActorRedirect extends log_1.Logger {
112
107
  if (!this.options.skipTime) {
113
108
  maybeDate = `${new Date().toISOString().replace('Z', '').replace('T', ' ')} `;
114
109
  }
115
- const line = `${ansi_colors_1.default.gray(maybeDate)}${ansi_colors_1.default.cyan(prefix)}${message || ''}`;
110
+ const line = `${c.gray(maybeDate)}${c.cyan(prefix)}${message || ''}`;
116
111
  // All redirected logs are logged at info level to avid any console specific formating for non-info levels,
117
112
  // which have already been applied once to the original log. (For example error stack traces etc.)
118
- this._outputWithConsole(log_1.LogLevel.INFO, line);
113
+ this._outputWithConsole(LogLevel.INFO, line);
119
114
  return line;
120
115
  }
121
116
  }
122
- exports.LoggerActorRedirect = LoggerActorRedirect;
123
117
  /**
124
118
  * Helper class for redirecting streamed Actor logs to another log.
125
119
  * @since Added in 2.20.0
126
120
  */
127
- class StreamedLog {
121
+ export class StreamedLog {
128
122
  destinationLog;
129
123
  streamBuffer = [];
130
124
  splitMarker = /(?:\n|^)(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/g;
@@ -185,7 +179,7 @@ class StreamedLog {
185
179
  }
186
180
  }
187
181
  catch (err) {
188
- log_1.default.warning(`Log redirection stopped due to error`, err);
182
+ log.warning(`Log redirection stopped due to error`, err);
189
183
  }
190
184
  }
191
185
  async logStreamChunks(logStream) {
@@ -235,4 +229,3 @@ class StreamedLog {
235
229
  });
236
230
  }
237
231
  }
238
- exports.StreamedLog = StreamedLog;