apify-client 3.0.0-beta.14 → 3.0.0-beta.16

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 (73) hide show
  1. package/dist/apify_api_error.js +23 -7
  2. package/dist/apify_client.d.ts +22 -3
  3. package/dist/apify_client.js +35 -29
  4. package/dist/base/api_client.d.ts +6 -6
  5. package/dist/base/api_client.js +24 -16
  6. package/dist/base/resource_client.d.ts +13 -8
  7. package/dist/base/resource_client.js +35 -19
  8. package/dist/base/resource_collection_client.d.ts +6 -4
  9. package/dist/base/resource_collection_client.js +17 -11
  10. package/dist/bundle.js +13 -13
  11. package/dist/bundle.js.map +1 -1
  12. package/dist/http_client.d.ts +34 -13
  13. package/dist/http_client.js +58 -28
  14. package/dist/index.d.ts +1 -0
  15. package/dist/resource_clients/actor.d.ts +26 -11
  16. package/dist/resource_clients/actor.js +62 -33
  17. package/dist/resource_clients/actor_collection.d.ts +6 -2
  18. package/dist/resource_clients/actor_collection.js +9 -3
  19. package/dist/resource_clients/actor_env_var.d.ts +10 -3
  20. package/dist/resource_clients/actor_env_var.js +16 -6
  21. package/dist/resource_clients/actor_env_var_collection.d.ts +7 -2
  22. package/dist/resource_clients/actor_env_var_collection.js +11 -4
  23. package/dist/resource_clients/actor_version.d.ts +10 -3
  24. package/dist/resource_clients/actor_version.js +18 -8
  25. package/dist/resource_clients/actor_version_collection.d.ts +7 -2
  26. package/dist/resource_clients/actor_version_collection.js +11 -4
  27. package/dist/resource_clients/build.d.ts +16 -6
  28. package/dist/resource_clients/build.js +30 -15
  29. package/dist/resource_clients/build_collection.d.ts +3 -1
  30. package/dist/resource_clients/build_collection.js +4 -1
  31. package/dist/resource_clients/dataset.d.ts +21 -7
  32. package/dist/resource_clients/dataset.js +65 -37
  33. package/dist/resource_clients/dataset_collection.d.ts +6 -2
  34. package/dist/resource_clients/dataset_collection.js +12 -2
  35. package/dist/resource_clients/key_value_store.d.ts +31 -11
  36. package/dist/resource_clients/key_value_store.js +58 -34
  37. package/dist/resource_clients/key_value_store_collection.d.ts +6 -2
  38. package/dist/resource_clients/key_value_store_collection.js +12 -2
  39. package/dist/resource_clients/log.d.ts +4 -1
  40. package/dist/resource_clients/log.js +15 -6
  41. package/dist/resource_clients/request_queue.d.ts +52 -18
  42. package/dist/resource_clients/request_queue.js +114 -60
  43. package/dist/resource_clients/request_queue_collection.d.ts +6 -2
  44. package/dist/resource_clients/request_queue_collection.js +9 -3
  45. package/dist/resource_clients/run.d.ts +33 -13
  46. package/dist/resource_clients/run.js +65 -35
  47. package/dist/resource_clients/run_collection.d.ts +3 -1
  48. package/dist/resource_clients/run_collection.js +4 -1
  49. package/dist/resource_clients/schedule.d.ts +13 -4
  50. package/dist/resource_clients/schedule.js +23 -9
  51. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  52. package/dist/resource_clients/schedule_collection.js +9 -3
  53. package/dist/resource_clients/store_collection.d.ts +3 -1
  54. package/dist/resource_clients/store_collection.js +4 -1
  55. package/dist/resource_clients/task.d.ts +27 -9
  56. package/dist/resource_clients/task.js +60 -31
  57. package/dist/resource_clients/task_collection.d.ts +6 -2
  58. package/dist/resource_clients/task_collection.js +9 -3
  59. package/dist/resource_clients/user.d.ts +14 -5
  60. package/dist/resource_clients/user.js +30 -14
  61. package/dist/resource_clients/webhook.d.ts +13 -4
  62. package/dist/resource_clients/webhook.js +24 -10
  63. package/dist/resource_clients/webhook_collection.d.ts +6 -2
  64. package/dist/resource_clients/webhook_collection.js +9 -3
  65. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  66. package/dist/resource_clients/webhook_dispatch.js +7 -2
  67. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  68. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  69. package/dist/timeouts.d.ts +72 -0
  70. package/dist/timeouts.js +31 -0
  71. package/dist/utils.d.ts +10 -0
  72. package/dist/utils.js +10 -0
  73. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import log from '@apify/log';
3
3
  import { createHmacSignatureAsync, createStorageContentSignatureAsync } from '@apify/utilities';
4
- import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
4
+ import { ResourceClient } from '../base/resource_client.js';
5
5
  import * as schemas from '../schemas.js';
6
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
6
7
  import { anyObjectSchema, applyQueryParamsToUrl, catchNotFoundOrThrow, isBuffer, isNode, isStream, parseArgument, parseResponse, } from '../utils.js';
7
8
  const listKeysOptionsSchema = z.strictObject({
8
9
  limit: z.number().min(0).optional(),
@@ -10,6 +11,7 @@ const listKeysOptionsSchema = z.strictObject({
10
11
  collection: z.string().optional(),
11
12
  prefix: z.string().optional(),
12
13
  signature: z.string().optional(),
14
+ ...timeoutOptionsShape,
13
15
  });
14
16
  const nonEmptyKeySchema = z.string().min(1);
15
17
  // `signature` is left out - this method produces one. The options type omits it to match.
@@ -19,6 +21,7 @@ const createKeysPublicUrlOptionsSchema = z.strictObject({
19
21
  collection: z.string().optional(),
20
22
  prefix: z.string().optional(),
21
23
  expiresInSecs: z.number().optional(),
24
+ ...timeoutOptionsShape,
22
25
  });
23
26
  const keySchema = z.string();
24
27
  const getRecordOptionsSchema = z.strictObject({
@@ -26,6 +29,7 @@ const getRecordOptionsSchema = z.strictObject({
26
29
  stream: z.boolean().optional(),
27
30
  disableRedirect: z.boolean().optional(),
28
31
  signature: z.string().optional(),
32
+ ...timeoutOptionsShape,
29
33
  });
30
34
  const recordSchema = z.strictObject({
31
35
  key: z.string(),
@@ -41,7 +45,7 @@ const recordSchema = z.strictObject({
41
45
  contentType: z.string().min(1).optional(),
42
46
  });
43
47
  const recordOptionsSchema = z.strictObject({
44
- timeoutSecs: z.number().optional(),
48
+ ...timeoutOptionsShape,
45
49
  doNotRetryTimeouts: z.boolean().optional(),
46
50
  });
47
51
  /**
@@ -85,11 +89,14 @@ export class KeyValueStoreClient extends ResourceClient {
85
89
  /**
86
90
  * Gets the key-value store object from the Apify API.
87
91
  *
92
+ * @param options - Request options
93
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
88
94
  * @returns The KeyValueStore object, or `undefined` if it does not exist
89
95
  * @see https://docs.apify.com/api/v2/key-value-store-get
90
96
  */
91
- async get() {
92
- return this._get(schemas.KeyValueStore(), {}, SMALL_TIMEOUT_MILLIS);
97
+ async get(options = {}) {
98
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
99
+ return this.getResource(schemas.KeyValueStore(), {}, timeoutSecs);
93
100
  }
94
101
  /**
95
102
  * Updates the key-value store with specified fields.
@@ -98,20 +105,26 @@ export class KeyValueStoreClient extends ResourceClient {
98
105
  * @param newFields.name - New name for the store
99
106
  * @param newFields.title - New title for the store
100
107
  * @param newFields.generalAccess - General resource access level ('FOLLOW_USER_SETTING', 'ANYONE_WITH_ID_CAN_READ' or 'RESTRICTED')
108
+ * @param options - Request options
109
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
101
110
  * @returns The updated KeyValueStore object
102
111
  * @see https://docs.apify.com/api/v2/key-value-store-put
103
112
  */
104
- async update(newFields) {
113
+ async update(newFields, options = {}) {
105
114
  parseArgument(newFields, anyObjectSchema);
106
- return this._update(schemas.KeyValueStore(), newFields, DEFAULT_TIMEOUT_MILLIS);
115
+ const { timeoutSecs = 'long' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
116
+ return this.updateResource(schemas.KeyValueStore(), newFields, timeoutSecs);
107
117
  }
108
118
  /**
109
119
  * Deletes the key-value store.
110
120
  *
121
+ * @param options - Request options
122
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
111
123
  * @see https://docs.apify.com/api/v2/key-value-store-delete
112
124
  */
113
- async delete() {
114
- return this._delete(SMALL_TIMEOUT_MILLIS);
125
+ async delete(options = {}) {
126
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
127
+ return this.deleteResource(timeoutSecs);
115
128
  }
116
129
  /**
117
130
  * Lists all keys in the key-value store.
@@ -124,6 +137,7 @@ export class KeyValueStoreClient extends ResourceClient {
124
137
  * @param options.exclusiveStartKey - Key to start listing from (for pagination). The listing starts with the next key after this one.
125
138
  * @param options.collection - Filter keys by collection name.
126
139
  * @param options.prefix - Filter keys that start with this prefix.
140
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
127
141
  * @returns Object containing `items` array of key metadata, pagination info (`count`, `limit`, `isTruncated`, `nextExclusiveStartKey`)
128
142
  * @see https://docs.apify.com/api/v2/key-value-store-keys-get
129
143
  *
@@ -149,13 +163,13 @@ export class KeyValueStoreClient extends ResourceClient {
149
163
  * ```
150
164
  */
151
165
  listKeys(options = {}) {
152
- const parsed = parseArgument(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
166
+ const { timeoutSecs = 'medium', ...parsed } = parseArgument(options, listKeysOptionsSchema, 'KeyValueClientListKeysOptions');
153
167
  const getPaginatedList = async (kvsListOptions = {}) => {
154
168
  const response = await this.httpClient.call({
155
- url: this._url('keys'),
169
+ url: this.buildUrl('keys'),
156
170
  method: 'GET',
157
- params: this._params(kvsListOptions),
158
- timeout: MEDIUM_TIMEOUT_MILLIS,
171
+ params: this.buildParams(kvsListOptions),
172
+ timeoutSecs,
159
173
  });
160
174
  return parseResponse(response, schemas.ListOfKeys());
161
175
  };
@@ -194,6 +208,8 @@ export class KeyValueStoreClient extends ResourceClient {
194
208
  * requiring an API token.
195
209
  *
196
210
  * @param key - The record key
211
+ * @param options - Request options
212
+ * @param options.timeoutSecs - Timeout for the API request that fetches the store. Default is `'long'`.
197
213
  * @returns A public URL string for accessing the record
198
214
  *
199
215
  * @example
@@ -204,10 +220,11 @@ export class KeyValueStoreClient extends ResourceClient {
204
220
  * ```
205
221
  * @since Added in 2.14.0
206
222
  */
207
- async getRecordPublicUrl(key) {
223
+ async getRecordPublicUrl(key, options = {}) {
208
224
  parseArgument(key, nonEmptyKeySchema);
209
- const store = await this.get();
210
- const recordPublicUrl = new URL(this._publicUrl(['records', key]));
225
+ const { timeoutSecs = 'long' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
226
+ const store = await this.get({ timeoutSecs });
227
+ const recordPublicUrl = new URL(this.buildPublicUrl(['records', key]));
211
228
  if (store?.urlSigningSecretKey) {
212
229
  const signature = await createHmacSignatureAsync(store.urlSigningSecretKey, key);
213
230
  recordPublicUrl.searchParams.append('signature', signature);
@@ -224,6 +241,7 @@ export class KeyValueStoreClient extends ResourceClient {
224
241
  * @param options.expiresInSecs - Number of seconds until the signed URL expires. If omitted, the URL never expires.
225
242
  * @param options.limit - Maximum number of keys to return.
226
243
  * @param options.prefix - Filter keys by prefix.
244
+ * @param options.timeoutSecs - Timeout for the API request that fetches the store. Default is `'long'`.
227
245
  * @returns A public URL string for accessing the keys list
228
246
  *
229
247
  * @example
@@ -238,10 +256,9 @@ export class KeyValueStoreClient extends ResourceClient {
238
256
  * @since Added in 2.13.0
239
257
  */
240
258
  async createKeysPublicUrl(options = {}) {
241
- const parsed = parseArgument(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
242
- const store = await this.get();
243
- const { expiresInSecs, ...queryOptions } = parsed;
244
- let createdPublicKeysUrl = new URL(this._publicUrl('keys'));
259
+ const { timeoutSecs = 'long', expiresInSecs, ...queryOptions } = parseArgument(options, createKeysPublicUrlOptionsSchema, 'KeyValueClientCreateKeysUrlOptions');
260
+ const store = await this.get({ timeoutSecs });
261
+ let createdPublicKeysUrl = new URL(this.buildPublicUrl('keys'));
245
262
  if (store?.urlSigningSecretKey) {
246
263
  const signature = await createStorageContentSignatureAsync({
247
264
  resourceId: store.id,
@@ -259,6 +276,8 @@ export class KeyValueStoreClient extends ResourceClient {
259
276
  * This is more efficient than {@link getRecord} when you only need to check for existence.
260
277
  *
261
278
  * @param key - The record key to check
279
+ * @param options - Request options
280
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
262
281
  * @returns `true` if the record exists, `false` if it does not
263
282
  * @see https://docs.apify.com/api/v2/key-value-store-record-get
264
283
  *
@@ -271,11 +290,13 @@ export class KeyValueStoreClient extends ResourceClient {
271
290
  * ```
272
291
  * @since Added in 2.9.0
273
292
  */
274
- async recordExists(key) {
293
+ async recordExists(key, options = {}) {
294
+ const { timeoutSecs = 'long' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
275
295
  const requestOpts = {
276
- url: this._url(['records', key]),
296
+ url: this.buildUrl(['records', key]),
277
297
  method: 'HEAD',
278
- params: this._params(),
298
+ params: this.buildParams(),
299
+ timeoutSecs,
279
300
  };
280
301
  try {
281
302
  await this.httpClient.call(requestOpts);
@@ -300,10 +321,10 @@ export class KeyValueStoreClient extends ResourceClient {
300
321
  if (parsed.signature)
301
322
  queryParams.signature = parsed.signature;
302
323
  const requestOpts = {
303
- url: this._url(['records', key]),
324
+ url: this.buildUrl(['records', key]),
304
325
  method: 'GET',
305
- params: this._params(queryParams),
306
- timeout: DEFAULT_TIMEOUT_MILLIS,
326
+ params: this.buildParams(queryParams),
327
+ timeoutSecs: parsed.timeoutSecs ?? 'long',
307
328
  };
308
329
  if (parsed.buffer)
309
330
  requestOpts.forceBuffer = true;
@@ -346,7 +367,7 @@ export class KeyValueStoreClient extends ResourceClient {
346
367
  * `'application/octet-stream'` fallback is treated as compressible, because
347
368
  * it could hold any binary data.
348
369
  * @param options - Storage options
349
- * @param options.timeoutSecs - Timeout for the upload in seconds. Default varies by value size.
370
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
350
371
  * @param options.doNotRetryTimeouts - If `true`, don't retry on timeout errors. Default is `false`.
351
372
  * @see https://docs.apify.com/api/v2/key-value-store-record-put
352
373
  *
@@ -379,7 +400,7 @@ export class KeyValueStoreClient extends ResourceClient {
379
400
  const parsed = parseArgument(options, recordOptionsSchema, 'KeyValueStoreRecordOptions');
380
401
  const { key } = record;
381
402
  let { value, contentType } = record;
382
- const { timeoutSecs, doNotRetryTimeouts } = parsed;
403
+ const { timeoutSecs = 'long', doNotRetryTimeouts } = parsed;
383
404
  const isValueStreamOrBuffer = isStream(value) || isBuffer(value);
384
405
  // To allow saving Objects to JSON without providing content type
385
406
  if (!contentType) {
@@ -401,13 +422,13 @@ export class KeyValueStoreClient extends ResourceClient {
401
422
  }
402
423
  }
403
424
  const uploadOpts = {
404
- url: this._url(['records', key]),
425
+ url: this.buildUrl(['records', key]),
405
426
  method: 'PUT',
406
- params: this._params(),
427
+ params: this.buildParams(),
407
428
  data: value,
408
429
  headers: contentType ? { 'content-type': contentType } : undefined,
409
430
  doNotRetryTimeouts,
410
- timeout: timeoutSecs !== undefined ? timeoutSecs * 1000 : DEFAULT_TIMEOUT_MILLIS,
431
+ timeoutSecs,
411
432
  };
412
433
  await this.httpClient.call(uploadOpts);
413
434
  }
@@ -415,6 +436,8 @@ export class KeyValueStoreClient extends ResourceClient {
415
436
  * Deletes a record from the key-value store.
416
437
  *
417
438
  * @param key - The record key to delete
439
+ * @param options - Request options
440
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
418
441
  * @see https://docs.apify.com/api/v2/key-value-store-record-delete
419
442
  *
420
443
  * @example
@@ -422,13 +445,14 @@ export class KeyValueStoreClient extends ResourceClient {
422
445
  * await client.keyValueStore('my-store').deleteRecord('temp-data');
423
446
  * ```
424
447
  */
425
- async deleteRecord(key) {
448
+ async deleteRecord(key, options = {}) {
426
449
  parseArgument(key, keySchema);
450
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
427
451
  await this.httpClient.call({
428
- url: this._url(['records', key]),
452
+ url: this.buildUrl(['records', key]),
429
453
  method: 'DELETE',
430
- params: this._params(),
431
- timeout: SMALL_TIMEOUT_MILLIS,
454
+ params: this.buildParams(),
455
+ timeoutSecs,
432
456
  });
433
457
  }
434
458
  }
@@ -1,6 +1,7 @@
1
1
  import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
2
2
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
3
3
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
4
+ import type { TimeoutOptions } from '../timeouts.js';
4
5
  import type { PaginatedList, PaginationOptions } from '../utils.js';
5
6
  import type { KeyValueStore } from './key_value_store.js';
6
7
  /**
@@ -45,6 +46,7 @@ export declare class KeyValueStoreCollectionClient extends ResourceCollectionCli
45
46
  * ```
46
47
  *
47
48
  * @param options - Pagination options.
49
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
48
50
  * @returns A paginated iterator of Key-value stores.
49
51
  * @see https://docs.apify.com/api/v2/key-value-stores-get
50
52
  */
@@ -54,12 +56,14 @@ export declare class KeyValueStoreCollectionClient extends ResourceCollectionCli
54
56
  *
55
57
  * @param name - Name of the key-value store. If not provided, a default store is used.
56
58
  * @param options - Additional options like schema.
59
+ * @param options.schema - Schema of the key-value store.
60
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
57
61
  * @returns The key-value store object.
58
62
  * @see https://docs.apify.com/api/v2/key-value-stores-post
59
63
  */
60
64
  getOrCreate(name?: string, options?: KeyValueStoreCollectionClientGetOrCreateOptions): Promise<KeyValueStore>;
61
65
  }
62
- export interface KeyValueStoreCollectionClientListOptions extends PaginationOptions {
66
+ export interface KeyValueStoreCollectionClientListOptions extends PaginationOptions, TimeoutOptions {
63
67
  unnamed?: boolean;
64
68
  desc?: boolean;
65
69
  /**
@@ -71,7 +75,7 @@ export interface KeyValueStoreCollectionClientListOptions extends PaginationOpti
71
75
  /**
72
76
  * @since Added in 2.3.0
73
77
  */
74
- export interface KeyValueStoreCollectionClientGetOrCreateOptions {
78
+ export interface KeyValueStoreCollectionClientGetOrCreateOptions extends TimeoutOptions {
75
79
  schema?: Record<string, unknown>;
76
80
  }
77
81
  export type KeyValueStoreCollectionListResult = PaginatedList<KeyValueStore> & {
@@ -2,12 +2,14 @@ import { z } from 'zod';
2
2
  import { STORAGE_OWNERSHIP_FILTER } from '@apify/consts';
3
3
  import { ResourceCollectionClient } from '../base/resource_collection_client.js';
4
4
  import * as schemas from '../schemas.js';
5
+ import { optionalTimeoutSchema, timeoutOptionsShape } from '../timeouts.js';
5
6
  import { anyObjectSchema, paginationOptionsShape, parseArgument } from '../utils.js';
6
7
  const listOptionsSchema = z.strictObject({
7
8
  unnamed: z.boolean().optional(),
8
9
  ...paginationOptionsShape,
9
10
  desc: z.boolean().optional(),
10
11
  ownership: z.enum(STORAGE_OWNERSHIP_FILTER).optional(),
12
+ ...timeoutOptionsShape,
11
13
  });
12
14
  const nameSchema = z.string().optional();
13
15
  const schemaSchema = anyObjectSchema.optional();
@@ -58,24 +60,32 @@ export class KeyValueStoreCollectionClient extends ResourceCollectionClient {
58
60
  * ```
59
61
  *
60
62
  * @param options - Pagination options.
63
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
61
64
  * @returns A paginated iterator of Key-value stores.
62
65
  * @see https://docs.apify.com/api/v2/key-value-stores-get
63
66
  */
64
67
  list(options = {}) {
65
68
  const parsed = parseArgument(options, listOptionsSchema, 'KeyValueStoreCollectionClientListOptions');
66
- return this._listPaginated(schemas.ListOfKeyValueStores(), parsed);
69
+ return this.listResourcesPaginated(schemas.ListOfKeyValueStores(), parsed, 'medium');
67
70
  }
68
71
  /**
69
72
  * Gets or creates a key-value store with the specified name.
70
73
  *
71
74
  * @param name - Name of the key-value store. If not provided, a default store is used.
72
75
  * @param options - Additional options like schema.
76
+ * @param options.schema - Schema of the key-value store.
77
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
73
78
  * @returns The key-value store object.
74
79
  * @see https://docs.apify.com/api/v2/key-value-stores-post
75
80
  */
76
81
  async getOrCreate(name, options) {
77
82
  parseArgument(name, nameSchema);
78
83
  parseArgument(options?.schema, schemaSchema); // TODO: Add schema validation
79
- return this._getOrCreate(schemas.KeyValueStore(), name, options);
84
+ parseArgument(options?.timeoutSecs, optionalTimeoutSchema);
85
+ // `timeoutSecs` is not part of the resource, so the body carries only the rest, and stays absent when
86
+ // there is nothing else to send.
87
+ const { timeoutSecs = 'short', ...resource } = options ?? {};
88
+ const hasResource = Object.keys(resource).length > 0;
89
+ return this.getOrCreateResource(schemas.KeyValueStore(), name, hasResource ? resource : undefined, timeoutSecs);
80
90
  }
81
91
  }
@@ -3,6 +3,7 @@ import type { Log } from '@apify/log';
3
3
  import { Logger, LogLevel } from '@apify/log';
4
4
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
5
5
  import { ResourceClient } from '../base/resource_client.js';
6
+ import type { TimeoutOptions } from '../timeouts.js';
6
7
  /**
7
8
  * Client for accessing Actor run or build logs.
8
9
  *
@@ -35,6 +36,7 @@ export declare class LogClient extends ResourceClient {
35
36
  *
36
37
  * @param options - Log retrieval options.
37
38
  * @param options.raw - If `true`, returns raw log content without any processing. Default is `false`.
39
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
38
40
  * @returns The log content as a string, or `undefined` if it does not exist. A chained client such as
39
41
  * `run.log()` throws an `ApifyApiError` on a 404, since the run itself may be what is missing.
40
42
  * @see https://docs.apify.com/api/v2/log-get
@@ -45,6 +47,7 @@ export declare class LogClient extends ResourceClient {
45
47
  *
46
48
  * @param options - Log retrieval options.
47
49
  * @param options.raw - If `true`, returns raw log content without any processing. Default is `false`.
50
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
48
51
  * @returns The log content as a Readable stream, or `undefined` if it does not exist. A chained client such as
49
52
  * `run.log()` throws an `ApifyApiError` on a 404, since the run itself may be what is missing.
50
53
  * @see https://docs.apify.com/api/v2/log-get
@@ -54,7 +57,7 @@ export declare class LogClient extends ResourceClient {
54
57
  /**
55
58
  * @since Added in 2.20.0
56
59
  */
57
- export interface LogOptions {
60
+ export interface LogOptions extends TimeoutOptions {
58
61
  /** @default false */
59
62
  raw?: boolean;
60
63
  }
@@ -1,7 +1,10 @@
1
1
  import c from 'ansi-colors';
2
+ import { z } from 'zod';
2
3
  import log, { Logger, LogLevel } from '@apify/log';
3
4
  import { ResourceClient } from '../base/resource_client.js';
4
- import { cast, catchNotFoundForResourceOrThrow } from '../utils.js';
5
+ import { timeoutOptionsShape } from '../timeouts.js';
6
+ import { cast, catchNotFoundForResourceOrThrow, parseArgument } from '../utils.js';
7
+ const logOptionsSchema = z.strictObject({ raw: z.boolean().optional(), ...timeoutOptionsShape });
5
8
  /**
6
9
  * Client for accessing Actor run or build logs.
7
10
  *
@@ -39,15 +42,18 @@ export class LogClient extends ResourceClient {
39
42
  *
40
43
  * @param options - Log retrieval options.
41
44
  * @param options.raw - If `true`, returns raw log content without any processing. Default is `false`.
45
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
42
46
  * @returns The log content as a string, or `undefined` if it does not exist. A chained client such as
43
47
  * `run.log()` throws an `ApifyApiError` on a 404, since the run itself may be what is missing.
44
48
  * @see https://docs.apify.com/api/v2/log-get
45
49
  */
46
50
  async get(options = {}) {
51
+ const { timeoutSecs = 'long', ...params } = parseArgument(options, logOptionsSchema, 'LogOptions');
47
52
  const requestOpts = {
48
- url: this._url(),
53
+ url: this.buildUrl(),
49
54
  method: 'GET',
50
- params: this._params(options),
55
+ params: this.buildParams(params),
56
+ timeoutSecs,
51
57
  };
52
58
  try {
53
59
  const response = await this.httpClient.call(requestOpts);
@@ -63,20 +69,23 @@ export class LogClient extends ResourceClient {
63
69
  *
64
70
  * @param options - Log retrieval options.
65
71
  * @param options.raw - If `true`, returns raw log content without any processing. Default is `false`.
72
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
66
73
  * @returns The log content as a Readable stream, or `undefined` if it does not exist. A chained client such as
67
74
  * `run.log()` throws an `ApifyApiError` on a 404, since the run itself may be what is missing.
68
75
  * @see https://docs.apify.com/api/v2/log-get
69
76
  */
70
77
  async stream(options = {}) {
78
+ const { timeoutSecs = 'long', raw } = parseArgument(options, logOptionsSchema, 'LogOptions');
71
79
  const params = {
72
80
  stream: true,
73
- raw: options.raw,
81
+ raw,
74
82
  };
75
83
  const requestOpts = {
76
- url: this._url(),
84
+ url: this.buildUrl(),
77
85
  method: 'GET',
78
- params: this._params(params),
86
+ params: this.buildParams(params),
79
87
  responseType: 'stream',
88
+ timeoutSecs,
80
89
  };
81
90
  try {
82
91
  const response = await this.httpClient.call(requestOpts);