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,51 +1,47 @@
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 { anyObjectSchema, applyQueryParamsToUrl, cast, catchNotFoundOrThrow, isBuffer, isNode, isStream, parseArgument, parseDateFields, pluckData, } from '../utils.js';
6
+ const listKeysOptionsSchema = z.strictObject({
7
+ limit: z.number().min(0).optional(),
8
+ exclusiveStartKey: z.string().optional(),
9
+ collection: z.string().optional(),
10
+ prefix: z.string().optional(),
11
+ signature: z.string().optional(),
16
12
  });
17
- const nonEmptyKeySchema = zod_1.z.string().min(1);
13
+ const nonEmptyKeySchema = z.string().min(1);
18
14
  // `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(),
15
+ const createKeysPublicUrlOptionsSchema = z.strictObject({
16
+ limit: z.number().min(0).optional(),
17
+ exclusiveStartKey: z.string().optional(),
18
+ collection: z.string().optional(),
19
+ prefix: z.string().optional(),
20
+ expiresInSecs: z.number().optional(),
25
21
  });
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(),
22
+ const keySchema = z.string();
23
+ const getRecordOptionsSchema = z.strictObject({
24
+ buffer: z.boolean().optional(),
25
+ stream: z.boolean().optional(),
26
+ disableRedirect: z.boolean().optional(),
27
+ signature: z.string().optional(),
32
28
  });
33
- const recordSchema = zod_1.z.strictObject({
34
- key: zod_1.z.string(),
29
+ const recordSchema = z.strictObject({
30
+ key: z.string(),
35
31
  // Values are arbitrary, and a `z.object()` arm would walk every key of a large buffer.
36
32
  // Symbols, bigints, functions and non-finite numbers are rejected because they cannot be serialized
37
33
  // to JSON - symbols and bigints throw, functions stringify to `undefined` (an empty request body),
38
34
  // and `NaN` / `Infinity` would silently become `null`.
39
- value: zod_1.z.custom((value) => value !== undefined &&
35
+ value: z.custom((value) => value !== undefined &&
40
36
  typeof value !== 'symbol' &&
41
37
  typeof value !== 'bigint' &&
42
38
  typeof value !== 'function' &&
43
39
  (typeof value !== 'number' || Number.isFinite(value)), 'Expected a defined, JSON-serializable value'),
44
- contentType: zod_1.z.string().min(1).optional(),
40
+ contentType: z.string().min(1).optional(),
45
41
  });
46
- const recordOptionsSchema = zod_1.z.strictObject({
47
- timeoutSecs: zod_1.z.number().optional(),
48
- doNotRetryTimeouts: zod_1.z.boolean().optional(),
42
+ const recordOptionsSchema = z.strictObject({
43
+ timeoutSecs: z.number().optional(),
44
+ doNotRetryTimeouts: z.boolean().optional(),
49
45
  });
50
46
  /**
51
47
  * Client for managing a specific key-value store.
@@ -75,7 +71,7 @@ const recordOptionsSchema = zod_1.z.strictObject({
75
71
  *
76
72
  * @see https://docs.apify.com/platform/storage/key-value-store
77
73
  */
78
- class KeyValueStoreClient extends resource_client_1.ResourceClient {
74
+ export class KeyValueStoreClient extends ResourceClient {
79
75
  /**
80
76
  * @hidden
81
77
  */
@@ -92,7 +88,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
92
88
  * @see https://docs.apify.com/api/v2/key-value-store-get
93
89
  */
94
90
  async get() {
95
- return this._get({}, resource_client_1.SMALL_TIMEOUT_MILLIS);
91
+ return this._get({}, SMALL_TIMEOUT_MILLIS);
96
92
  }
97
93
  /**
98
94
  * Updates the key-value store with specified fields.
@@ -105,8 +101,8 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
105
101
  * @see https://docs.apify.com/api/v2/key-value-store-put
106
102
  */
107
103
  async update(newFields) {
108
- (0, utils_1.parseArgument)(newFields, utils_1.anyObjectSchema);
109
- return this._update(newFields, resource_client_1.DEFAULT_TIMEOUT_MILLIS);
104
+ parseArgument(newFields, anyObjectSchema);
105
+ return this._update(newFields, DEFAULT_TIMEOUT_MILLIS);
110
106
  }
111
107
  /**
112
108
  * Deletes the key-value store.
@@ -114,7 +110,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
114
110
  * @see https://docs.apify.com/api/v2/key-value-store-delete
115
111
  */
116
112
  async delete() {
117
- return this._delete(resource_client_1.SMALL_TIMEOUT_MILLIS);
113
+ return this._delete(SMALL_TIMEOUT_MILLIS);
118
114
  }
119
115
  /**
120
116
  * Lists all keys in the key-value store.
@@ -152,15 +148,15 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
152
148
  * ```
153
149
  */
154
150
  listKeys(options = {}) {
155
- const parsed = (0, utils_1.parseArgument)(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
151
+ const parsed = parseArgument(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
156
152
  const getPaginatedList = async (kvsListOptions = {}) => {
157
153
  const response = await this.httpClient.call({
158
154
  url: this._url('keys'),
159
155
  method: 'GET',
160
156
  params: this._params(kvsListOptions),
161
- timeout: resource_client_1.MEDIUM_TIMEOUT_MILLIS,
157
+ timeout: MEDIUM_TIMEOUT_MILLIS,
162
158
  });
163
- return (0, utils_1.cast)((0, utils_1.parseDateFields)((0, utils_1.pluckData)(response.data)));
159
+ return cast(parseDateFields(pluckData(response.data)));
164
160
  };
165
161
  const paginatedListPromise = getPaginatedList(parsed);
166
162
  async function* asyncGenerator() {
@@ -208,11 +204,11 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
208
204
  * @since Added in 2.14.0
209
205
  */
210
206
  async getRecordPublicUrl(key) {
211
- (0, utils_1.parseArgument)(key, nonEmptyKeySchema);
207
+ parseArgument(key, nonEmptyKeySchema);
212
208
  const store = await this.get();
213
209
  const recordPublicUrl = new URL(this._publicUrl(['records', key]));
214
210
  if (store?.urlSigningSecretKey) {
215
- const signature = await (0, utilities_1.createHmacSignatureAsync)(store.urlSigningSecretKey, key);
211
+ const signature = await createHmacSignatureAsync(store.urlSigningSecretKey, key);
216
212
  recordPublicUrl.searchParams.append('signature', signature);
217
213
  }
218
214
  return recordPublicUrl.toString();
@@ -241,19 +237,19 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
241
237
  * @since Added in 2.13.0
242
238
  */
243
239
  async createKeysPublicUrl(options = {}) {
244
- const parsed = (0, utils_1.parseArgument)(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
240
+ const parsed = parseArgument(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
245
241
  const store = await this.get();
246
242
  const { expiresInSecs, ...queryOptions } = parsed;
247
243
  let createdPublicKeysUrl = new URL(this._publicUrl('keys'));
248
244
  if (store?.urlSigningSecretKey) {
249
- const signature = await (0, utilities_1.createStorageContentSignatureAsync)({
245
+ const signature = await createStorageContentSignatureAsync({
250
246
  resourceId: store.id,
251
247
  urlSigningSecretKey: store.urlSigningSecretKey,
252
248
  expiresInMillis: expiresInSecs ? expiresInSecs * 1000 : undefined,
253
249
  });
254
250
  createdPublicKeysUrl.searchParams.set('signature', signature);
255
251
  }
256
- createdPublicKeysUrl = (0, utils_1.applyQueryParamsToUrl)(createdPublicKeysUrl, queryOptions);
252
+ createdPublicKeysUrl = applyQueryParamsToUrl(createdPublicKeysUrl, queryOptions);
257
253
  return createdPublicKeysUrl.toString();
258
254
  }
259
255
  /**
@@ -285,18 +281,18 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
285
281
  return true;
286
282
  }
287
283
  catch (err) {
288
- (0, utils_1.catchNotFoundOrThrow)(err);
284
+ catchNotFoundOrThrow(err);
289
285
  }
290
286
  return false;
291
287
  }
292
288
  async getRecord(key, options = {}) {
293
- (0, utils_1.parseArgument)(key, keySchema);
294
- const parsed = (0, utils_1.parseArgument)(options, getRecordOptionsSchema, 'KeyValueClientGetRecordOptions');
295
- if (parsed.stream && !(0, utils_1.isNode)()) {
289
+ parseArgument(key, keySchema);
290
+ const parsed = parseArgument(options, getRecordOptionsSchema, 'KeyValueClientGetRecordOptions');
291
+ if (parsed.stream && !isNode()) {
296
292
  throw new Error('The stream option can only be used in Node.js environment.');
297
293
  }
298
294
  if ('disableRedirect' in parsed) {
299
- log_1.default.deprecated('The disableRedirect option for getRecord() is deprecated. ' +
295
+ log.deprecated('The disableRedirect option for getRecord() is deprecated. ' +
300
296
  'It has no effect and will be removed in the following major release.');
301
297
  }
302
298
  const queryParams = { attachment: 'true' };
@@ -306,7 +302,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
306
302
  url: this._url(['records', key]),
307
303
  method: 'GET',
308
304
  params: this._params(queryParams),
309
- timeout: resource_client_1.DEFAULT_TIMEOUT_MILLIS,
305
+ timeout: DEFAULT_TIMEOUT_MILLIS,
310
306
  };
311
307
  if (parsed.buffer)
312
308
  requestOpts.forceBuffer = true;
@@ -321,7 +317,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
321
317
  };
322
318
  }
323
319
  catch (err) {
324
- (0, utils_1.catchNotFoundOrThrow)(err);
320
+ catchNotFoundOrThrow(err);
325
321
  }
326
322
  return undefined;
327
323
  }
@@ -373,12 +369,12 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
373
369
  * ```
374
370
  */
375
371
  async setRecord(record, options = {}) {
376
- (0, utils_1.parseArgument)(record, recordSchema);
377
- const parsed = (0, utils_1.parseArgument)(options, recordOptionsSchema, 'KeyValueStoreRecordOptions');
372
+ parseArgument(record, recordSchema);
373
+ const parsed = parseArgument(options, recordOptionsSchema, 'KeyValueStoreRecordOptions');
378
374
  const { key } = record;
379
375
  let { value, contentType } = record;
380
376
  const { timeoutSecs, doNotRetryTimeouts } = parsed;
381
- const isValueStreamOrBuffer = (0, utils_1.isStream)(value) || (0, utils_1.isBuffer)(value);
377
+ const isValueStreamOrBuffer = isStream(value) || isBuffer(value);
382
378
  // To allow saving Objects to JSON without providing content type
383
379
  if (!contentType) {
384
380
  if (isValueStreamOrBuffer)
@@ -405,7 +401,7 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
405
401
  data: value,
406
402
  headers: contentType ? { 'content-type': contentType } : undefined,
407
403
  doNotRetryTimeouts,
408
- timeout: timeoutSecs !== undefined ? timeoutSecs * 1000 : resource_client_1.DEFAULT_TIMEOUT_MILLIS,
404
+ timeout: timeoutSecs !== undefined ? timeoutSecs * 1000 : DEFAULT_TIMEOUT_MILLIS,
409
405
  };
410
406
  await this.httpClient.call(uploadOpts);
411
407
  }
@@ -421,13 +417,12 @@ class KeyValueStoreClient extends resource_client_1.ResourceClient {
421
417
  * ```
422
418
  */
423
419
  async deleteRecord(key) {
424
- (0, utils_1.parseArgument)(key, keySchema);
420
+ parseArgument(key, keySchema);
425
421
  await this.httpClient.call({
426
422
  url: this._url(['records', key]),
427
423
  method: 'DELETE',
428
424
  params: this._params(),
429
- timeout: resource_client_1.SMALL_TIMEOUT_MILLIS,
425
+ timeout: SMALL_TIMEOUT_MILLIS,
430
426
  });
431
427
  }
432
428
  }
433
- 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,15 @@
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 { anyObjectSchema, 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();
15
- const schemaSchema = utils_1.anyObjectSchema.optional();
11
+ const nameSchema = z.string().optional();
12
+ const schemaSchema = anyObjectSchema.optional();
16
13
  /**
17
14
  * Client for managing the collection of Key-value stores in your account.
18
15
  *
@@ -33,7 +30,7 @@ const schemaSchema = utils_1.anyObjectSchema.optional();
33
30
  *
34
31
  * @see https://docs.apify.com/platform/storage/key-value-store
35
32
  */
36
- class KeyValueStoreCollectionClient extends resource_collection_client_1.ResourceCollectionClient {
33
+ export class KeyValueStoreCollectionClient extends ResourceCollectionClient {
37
34
  /**
38
35
  * @hidden
39
36
  */
@@ -64,7 +61,7 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
64
61
  * @see https://docs.apify.com/api/v2/key-value-stores-get
65
62
  */
66
63
  list(options = {}) {
67
- const parsed = (0, utils_1.parseArgument)(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
64
+ const parsed = parseArgument(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
68
65
  return this._listPaginated(parsed);
69
66
  }
70
67
  /**
@@ -76,9 +73,8 @@ class KeyValueStoreCollectionClient extends resource_collection_client_1.Resourc
76
73
  * @see https://docs.apify.com/api/v2/key-value-stores-post
77
74
  */
78
75
  async getOrCreate(name, options) {
79
- (0, utils_1.parseArgument)(name, nameSchema);
80
- (0, utils_1.parseArgument)(options?.schema, schemaSchema); // TODO: Add schema validation
76
+ parseArgument(name, nameSchema);
77
+ parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
81
78
  return this._getOrCreate(name, options);
82
79
  }
83
80
  }
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;
@@ -1,8 +1,8 @@
1
1
  import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
2
- import type { ApiClientSubResourceOptions } from '../base/api_client';
3
- import { ResourceClient } from '../base/resource_client';
4
- import type { RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListRequestsResult, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult } from '../models';
5
- export type { AllowedHttpMethods, RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListItem, RequestQueueClientListRequestsResult, RequestQueueClientLockedListItem, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult, RequestQueueStats, } from '../models';
2
+ import type { ApiClientSubResourceOptions } from '../base/api_client.js';
3
+ import { ResourceClient } from '../base/resource_client.js';
4
+ import type { RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListRequestsResult, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult } from '../models.js';
5
+ export type { AllowedHttpMethods, RequestQueue, RequestQueueClientAddRequestResult, RequestQueueClientBatchDeleteRequestsResult, RequestQueueClientBatchRequestsOperationResult, RequestQueueClientListAndLockHeadResult, RequestQueueClientListHeadResult, RequestQueueClientListItem, RequestQueueClientListRequestsResult, RequestQueueClientLockedListItem, RequestQueueClientProlongRequestLockResult, RequestQueueClientRequestSchema, RequestQueueClientRequestToAdd, RequestQueueClientRequestToUpdate, RequestQueueClientUnlockRequestsResult, RequestQueueStats, } from '../models.js';
6
6
  /**
7
7
  * Client for managing a specific Request queue.
8
8
  *