apify-client 3.0.0-beta.15 → 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 (71) 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 +11 -10
  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 +56 -34
  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/package.json +1 -1
@@ -1,7 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { createStorageContentSignatureAsync } from '@apify/utilities';
3
- import { DEFAULT_TIMEOUT_MILLIS, MEDIUM_TIMEOUT_MILLIS, ResourceClient, SMALL_TIMEOUT_MILLIS, } from '../base/resource_client.js';
3
+ import { ResourceClient } from '../base/resource_client.js';
4
4
  import * as schemas from '../schemas.js';
5
+ import { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
5
6
  import { anyObjectSchema, applyQueryParamsToUrl, cast, isNonArrayObject, paginationOptionsShape, parseArgument, parseResponse, SCANNED_COUNT, } from '../utils.js';
6
7
  // A predicate, not a `z.object()` arm, which would walk and copy every key of every pushed item.
7
8
  const itemSchema = z.custom(isNonArrayObject, 'Expected an object');
@@ -17,6 +18,7 @@ const listItemsOptionsSchema = z.strictObject({
17
18
  unwind: z.union([z.string(), z.array(z.string())]).optional(),
18
19
  view: z.string().optional(),
19
20
  signature: z.string().optional(),
21
+ ...timeoutOptionsShape,
20
22
  });
21
23
  // Spells out `limit` / `offset` instead of spreading `paginationOptionsShape`: a download is one
22
24
  // request, so `chunkSize` has nothing to size. The options type omits it to match.
@@ -39,10 +41,12 @@ const downloadItemsOptionsSchema = z.strictObject({
39
41
  xmlRoot: z.string().optional(),
40
42
  xmlRow: z.string().optional(),
41
43
  signature: z.string().optional(),
44
+ ...timeoutOptionsShape,
42
45
  });
43
46
  const pushItemsSchema = z.union([itemSchema, z.string(), z.array(z.union([itemSchema, z.string()]))]);
44
- // Every option becomes a query parameter of the generated URL, so `chunkSize` (client-side only) and
45
- // `signature` (which this method produces) are left out. The options type omits both to match.
47
+ // Apart from `timeoutSecs` and `expiresInSecs`, every option becomes a query parameter of the generated URL, so
48
+ // `chunkSize` (client-side only) and `signature` (which this method produces) are left out. The options type
49
+ // omits both to match.
46
50
  const createItemsPublicUrlOptionsSchema = z.strictObject({
47
51
  clean: z.boolean().optional(),
48
52
  desc: z.boolean().optional(),
@@ -56,6 +60,7 @@ const createItemsPublicUrlOptionsSchema = z.strictObject({
56
60
  unwind: z.union([z.string(), z.array(z.string())]).optional(),
57
61
  view: z.string().optional(),
58
62
  expiresInSecs: z.number().optional(),
63
+ ...timeoutOptionsShape,
59
64
  });
60
65
  /**
61
66
  * Client for managing a specific Dataset.
@@ -99,30 +104,39 @@ export class DatasetClient extends ResourceClient {
99
104
  /**
100
105
  * Gets the dataset object from the Apify API.
101
106
  *
107
+ * @param options - Request options
108
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
102
109
  * @returns The Dataset object, or `undefined` if it does not exist
103
110
  * @see https://docs.apify.com/api/v2/dataset-get
104
111
  */
105
- async get() {
106
- return this._get(schemas.Dataset(), {}, SMALL_TIMEOUT_MILLIS);
112
+ async get(options = {}) {
113
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
114
+ return this.getResource(schemas.Dataset(), {}, timeoutSecs);
107
115
  }
108
116
  /**
109
117
  * Updates the dataset with specified fields.
110
118
  *
111
119
  * @param newFields - Fields to update in the dataset
120
+ * @param options - Request options
121
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
112
122
  * @returns The updated Dataset object
113
123
  * @see https://docs.apify.com/api/v2/dataset-put
114
124
  */
115
- async update(newFields) {
125
+ async update(newFields, options = {}) {
116
126
  parseArgument(newFields, anyObjectSchema);
117
- return this._update(schemas.Dataset(), newFields, SMALL_TIMEOUT_MILLIS);
127
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
128
+ return this.updateResource(schemas.Dataset(), newFields, timeoutSecs);
118
129
  }
119
130
  /**
120
131
  * Deletes the dataset.
121
132
  *
133
+ * @param options - Request options
134
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
122
135
  * @see https://docs.apify.com/api/v2/dataset-delete
123
136
  */
124
- async delete() {
125
- return this._delete(SMALL_TIMEOUT_MILLIS);
137
+ async delete(options = {}) {
138
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
139
+ return this.deleteResource(timeoutSecs);
126
140
  }
127
141
  /**
128
142
  * Lists items in the dataset.
@@ -144,6 +158,7 @@ export class DatasetClient extends ResourceClient {
144
158
  * @param options.flatten - Array of field names to flatten. Nested objects are converted to dot notation (e.g., `obj.field`).
145
159
  * @param options.unwind - Field name or array of field names to unwind. Each array value creates a separate item.
146
160
  * @param options.view - Name of a predefined view to use for field selection.
161
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'long'`.
147
162
  * @returns A paginated list with `items`, `total` count, `offset`, `count`, and `limit`
148
163
  * @see https://docs.apify.com/api/v2/dataset-items-get
149
164
  *
@@ -169,17 +184,17 @@ export class DatasetClient extends ResourceClient {
169
184
  * ```
170
185
  */
171
186
  listItems(options = {}) {
172
- const parsed = parseArgument(options, listItemsOptionsSchema, 'DatasetClientListItemOptions');
187
+ const { timeoutSecs = 'long', ...listOptions } = parseArgument(options, listItemsOptionsSchema, 'DatasetClientListItemOptions');
173
188
  const fetchItems = async (datasetListOptions = {}) => {
174
189
  const response = await this.httpClient.call({
175
- url: this._url('items'),
190
+ url: this.buildUrl('items'),
176
191
  method: 'GET',
177
- params: this._params(datasetListOptions),
178
- timeout: DEFAULT_TIMEOUT_MILLIS,
192
+ params: this.buildParams(datasetListOptions),
193
+ timeoutSecs,
179
194
  });
180
- return this._createPaginationList(response, datasetListOptions.desc ?? false);
195
+ return this.createPaginationList(response, datasetListOptions.desc ?? false);
181
196
  };
182
- return this._listPaginatedFromCallback(fetchItems, parsed);
197
+ return this.listPaginatedFromCallback(fetchItems, listOptions);
183
198
  }
184
199
  /**
185
200
  * Downloads dataset items in a specific format.
@@ -198,6 +213,7 @@ export class DatasetClient extends ResourceClient {
198
213
  * @param options.xmlRow - Name of the XML element for each item. Default is `'item'`.
199
214
  * @param options.fields - Array of field names to include in the export.
200
215
  * @param options.omit - Array of field names to exclude from the export.
216
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
201
217
  * @returns Buffer containing the serialized data in the specified format
202
218
  * @see https://docs.apify.com/api/v2/dataset-items-get
203
219
  *
@@ -223,16 +239,16 @@ export class DatasetClient extends ResourceClient {
223
239
  */
224
240
  async downloadItems(format, options = {}) {
225
241
  parseArgument(format, itemFormatSchema);
226
- const parsed = parseArgument(options, downloadItemsOptionsSchema, 'DatasetClientDownloadItemsOptions');
242
+ const { timeoutSecs = 'long', ...query } = parseArgument(options, downloadItemsOptionsSchema, 'DatasetClientDownloadItemsOptions');
227
243
  const { data } = await this.httpClient.call({
228
- url: this._url('items'),
244
+ url: this.buildUrl('items'),
229
245
  method: 'GET',
230
- params: this._params({
246
+ params: this.buildParams({
231
247
  format,
232
- ...parsed,
248
+ ...query,
233
249
  }),
234
250
  forceBuffer: true,
235
- timeout: DEFAULT_TIMEOUT_MILLIS,
251
+ timeoutSecs,
236
252
  });
237
253
  return cast(data);
238
254
  }
@@ -246,6 +262,8 @@ export class DatasetClient extends ResourceClient {
246
262
  *
247
263
  * @param items - A single item (object or string) or an array of items to store.
248
264
  * Objects are automatically stringified to JSON. Strings are stored as-is.
265
+ * @param options - Request options
266
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
249
267
  * @see https://docs.apify.com/api/v2/dataset-items-post
250
268
  *
251
269
  * @example
@@ -268,18 +286,19 @@ export class DatasetClient extends ResourceClient {
268
286
  * await client.dataset('my-dataset').pushItems(['item1', 'item2', 'item3']);
269
287
  * ```
270
288
  */
271
- async pushItems(items) {
289
+ async pushItems(items, options = {}) {
272
290
  parseArgument(items, pushItemsSchema);
291
+ const { timeoutSecs = 'medium' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
273
292
  await this.httpClient.call({
274
- url: this._url('items'),
293
+ url: this.buildUrl('items'),
275
294
  method: 'POST',
276
295
  headers: {
277
296
  'content-type': 'application/json; charset=utf-8',
278
297
  },
279
298
  data: items,
280
- params: this._params(),
281
- doNotRetryTimeouts: true, // see timeout handling in http-client
282
- timeout: MEDIUM_TIMEOUT_MILLIS,
299
+ params: this.buildParams(),
300
+ doNotRetryTimeouts: true, // see timeoutSecs handling in http-client
301
+ timeoutSecs,
283
302
  });
284
303
  }
285
304
  /**
@@ -288,16 +307,19 @@ export class DatasetClient extends ResourceClient {
288
307
  * Returns statistics for each field in the dataset, including information about
289
308
  * data types, null counts, and value ranges.
290
309
  *
310
+ * @param options - Request options
311
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
291
312
  * @returns Dataset statistics
292
313
  * @see https://docs.apify.com/api/v2/dataset-statistics-get
293
314
  * @since Added in 2.11.2
294
315
  */
295
- async getStatistics() {
316
+ async getStatistics(options = {}) {
317
+ const { timeoutSecs = 'short' } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
296
318
  const response = await this.httpClient.call({
297
- url: this._url('statistics'),
319
+ url: this.buildUrl('statistics'),
298
320
  method: 'GET',
299
- params: this._params(),
300
- timeout: SMALL_TIMEOUT_MILLIS,
321
+ params: this.buildParams(),
322
+ timeoutSecs,
301
323
  });
302
324
  return parseResponse(response, schemas.DatasetStatistics());
303
325
  }
@@ -313,6 +335,7 @@ export class DatasetClient extends ResourceClient {
313
335
  * @param options.fields - Array of field names to include in the response.
314
336
  * @param options.limit - Maximum number of items to return.
315
337
  * @param options.offset - Number of items to skip.
338
+ * @param options.timeoutSecs - Timeout for the API request that fetches the dataset. Default is `'long'`.
316
339
  * @returns A public URL string for accessing the dataset items
317
340
  *
318
341
  * @example
@@ -334,10 +357,9 @@ export class DatasetClient extends ResourceClient {
334
357
  * @since Added in 2.13.0
335
358
  */
336
359
  async createItemsPublicUrl(options = {}) {
337
- const parsed = parseArgument(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
338
- const dataset = await this.get();
339
- const { expiresInSecs, ...queryOptions } = parsed;
340
- let createdItemsPublicUrl = new URL(this._publicUrl('items'));
360
+ const { timeoutSecs = 'long', expiresInSecs, ...queryOptions } = parseArgument(options, createItemsPublicUrlOptionsSchema, 'DatasetClientCreateItemsUrlOptions');
361
+ const dataset = await this.get({ timeoutSecs });
362
+ let createdItemsPublicUrl = new URL(this.buildPublicUrl('items'));
341
363
  if (dataset?.urlSigningSecretKey) {
342
364
  const signature = await createStorageContentSignatureAsync({
343
365
  resourceId: dataset.id,
@@ -349,7 +371,7 @@ export class DatasetClient extends ResourceClient {
349
371
  createdItemsPublicUrl = applyQueryParamsToUrl(createdItemsPublicUrl, queryOptions);
350
372
  return createdItemsPublicUrl.toString();
351
373
  }
352
- _createPaginationList(response, userProvidedDesc) {
374
+ createPaginationList(response, userProvidedDesc) {
353
375
  const page = {
354
376
  items: response.data,
355
377
  total: Number(response.headers['x-apify-pagination-total']),
@@ -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 { Dataset } from './dataset.js';
6
7
  /**
@@ -45,6 +46,7 @@ export declare class DatasetCollectionClient extends ResourceCollectionClient {
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 Datasets.
49
51
  * @see https://docs.apify.com/api/v2/datasets-get
50
52
  */
@@ -54,12 +56,14 @@ export declare class DatasetCollectionClient extends ResourceCollectionClient {
54
56
  *
55
57
  * @param name - Name of the dataset. If not provided, a default dataset is used.
56
58
  * @param options - Additional options like schema.
59
+ * @param options.schema - Schema of the dataset.
60
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
57
61
  * @returns The dataset object.
58
62
  * @see https://docs.apify.com/api/v2/datasets-post
59
63
  */
60
64
  getOrCreate(name?: string, options?: DatasetCollectionClientGetOrCreateOptions): Promise<Dataset>;
61
65
  }
62
- export interface DatasetCollectionClientListOptions extends PaginationOptions {
66
+ export interface DatasetCollectionClientListOptions extends PaginationOptions, TimeoutOptions {
63
67
  unnamed?: boolean;
64
68
  desc?: boolean;
65
69
  /**
@@ -71,7 +75,7 @@ export interface DatasetCollectionClientListOptions extends PaginationOptions {
71
75
  /**
72
76
  * @since Added in 2.3.0
73
77
  */
74
- export interface DatasetCollectionClientGetOrCreateOptions {
78
+ export interface DatasetCollectionClientGetOrCreateOptions extends TimeoutOptions {
75
79
  schema?: Record<string, unknown>;
76
80
  }
77
81
  export type DatasetCollectionClientListResult = PaginatedList<Dataset> & {
@@ -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 DatasetCollectionClient 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 Datasets.
62
65
  * @see https://docs.apify.com/api/v2/datasets-get
63
66
  */
64
67
  list(options = {}) {
65
68
  const parsed = parseArgument(options, listOptionsSchema, 'DatasetCollectionClientListOptions');
66
- return this._listPaginated(schemas.ListOfDatasets(), parsed);
69
+ return this.listResourcesPaginated(schemas.ListOfDatasets(), parsed, 'medium');
67
70
  }
68
71
  /**
69
72
  * Gets or creates a dataset with the specified name.
70
73
  *
71
74
  * @param name - Name of the dataset. If not provided, a default dataset is used.
72
75
  * @param options - Additional options like schema.
76
+ * @param options.schema - Schema of the dataset.
77
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
73
78
  * @returns The dataset object.
74
79
  * @see https://docs.apify.com/api/v2/datasets-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.Dataset(), 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.Dataset(), name, hasResource ? resource : undefined, timeoutSecs);
80
90
  }
81
91
  }
@@ -4,6 +4,7 @@ import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
4
4
  import type { ApiClientSubResourceOptions } from '../base/api_client.js';
5
5
  import { ResourceClient } from '../base/resource_client.js';
6
6
  import type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore } from '../models.js';
7
+ import type { TimeoutOptions } from '../timeouts.js';
7
8
  export type { KeyValueClientListKeysResult, KeyValueListItem, KeyValueStore, KeyValueStoreStats } from '../models.js';
8
9
  /**
9
10
  * Client for managing a specific key-value store.
@@ -41,10 +42,12 @@ export declare class KeyValueStoreClient extends ResourceClient {
41
42
  /**
42
43
  * Gets the key-value store object from the Apify API.
43
44
  *
45
+ * @param options - Request options
46
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
44
47
  * @returns The KeyValueStore object, or `undefined` if it does not exist
45
48
  * @see https://docs.apify.com/api/v2/key-value-store-get
46
49
  */
47
- get(): Promise<KeyValueStore | undefined>;
50
+ get(options?: TimeoutOptions): Promise<KeyValueStore | undefined>;
48
51
  /**
49
52
  * Updates the key-value store with specified fields.
50
53
  *
@@ -52,16 +55,20 @@ export declare class KeyValueStoreClient extends ResourceClient {
52
55
  * @param newFields.name - New name for the store
53
56
  * @param newFields.title - New title for the store
54
57
  * @param newFields.generalAccess - General resource access level ('FOLLOW_USER_SETTING', 'ANYONE_WITH_ID_CAN_READ' or 'RESTRICTED')
58
+ * @param options - Request options
59
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
55
60
  * @returns The updated KeyValueStore object
56
61
  * @see https://docs.apify.com/api/v2/key-value-store-put
57
62
  */
58
- update(newFields: KeyValueClientUpdateOptions): Promise<KeyValueStore>;
63
+ update(newFields: KeyValueClientUpdateOptions, options?: TimeoutOptions): Promise<KeyValueStore>;
59
64
  /**
60
65
  * Deletes the key-value store.
61
66
  *
67
+ * @param options - Request options
68
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
62
69
  * @see https://docs.apify.com/api/v2/key-value-store-delete
63
70
  */
64
- delete(): Promise<void>;
71
+ delete(options?: TimeoutOptions): Promise<void>;
65
72
  /**
66
73
  * Lists all keys in the key-value store.
67
74
  *
@@ -73,6 +80,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
73
80
  * @param options.exclusiveStartKey - Key to start listing from (for pagination). The listing starts with the next key after this one.
74
81
  * @param options.collection - Filter keys by collection name.
75
82
  * @param options.prefix - Filter keys that start with this prefix.
83
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
76
84
  * @returns Object containing `items` array of key metadata, pagination info (`count`, `limit`, `isTruncated`, `nextExclusiveStartKey`)
77
85
  * @see https://docs.apify.com/api/v2/key-value-store-keys-get
78
86
  *
@@ -106,6 +114,8 @@ export declare class KeyValueStoreClient extends ResourceClient {
106
114
  * requiring an API token.
107
115
  *
108
116
  * @param key - The record key
117
+ * @param options - Request options
118
+ * @param options.timeoutSecs - Timeout for the API request that fetches the store. Default is `'long'`.
109
119
  * @returns A public URL string for accessing the record
110
120
  *
111
121
  * @example
@@ -116,7 +126,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
116
126
  * ```
117
127
  * @since Added in 2.14.0
118
128
  */
119
- getRecordPublicUrl(key: string): Promise<string>;
129
+ getRecordPublicUrl(key: string, options?: TimeoutOptions): Promise<string>;
120
130
  /**
121
131
  * Generates a public URL for accessing the list of keys in the key-value store.
122
132
  *
@@ -127,6 +137,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
127
137
  * @param options.expiresInSecs - Number of seconds until the signed URL expires. If omitted, the URL never expires.
128
138
  * @param options.limit - Maximum number of keys to return.
129
139
  * @param options.prefix - Filter keys by prefix.
140
+ * @param options.timeoutSecs - Timeout for the API request that fetches the store. Default is `'long'`.
130
141
  * @returns A public URL string for accessing the keys list
131
142
  *
132
143
  * @example
@@ -147,6 +158,8 @@ export declare class KeyValueStoreClient extends ResourceClient {
147
158
  * This is more efficient than {@link getRecord} when you only need to check for existence.
148
159
  *
149
160
  * @param key - The record key to check
161
+ * @param options - Request options
162
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
150
163
  * @returns `true` if the record exists, `false` if it does not
151
164
  * @see https://docs.apify.com/api/v2/key-value-store-record-get
152
165
  *
@@ -159,7 +172,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
159
172
  * ```
160
173
  * @since Added in 2.9.0
161
174
  */
162
- recordExists(key: string): Promise<boolean>;
175
+ recordExists(key: string, options?: TimeoutOptions): Promise<boolean>;
163
176
  /**
164
177
  * You can use the `buffer` option to get the value in a Buffer (Node.js)
165
178
  * or ArrayBuffer (browser) format. In Node.js (not in browser) you can also
@@ -168,6 +181,12 @@ export declare class KeyValueStoreClient extends ResourceClient {
168
181
  * When the record does not exist, the function resolves to `undefined`. It does
169
182
  * NOT resolve to a `KeyValueStore` record with an `undefined` value.
170
183
  *
184
+ * @param key - The record key
185
+ * @param options - Retrieval options
186
+ * @param options.buffer - If `true`, the value is returned as a Buffer (Node.js) or ArrayBuffer (browser).
187
+ * @param options.stream - If `true`, the value is returned as a Readable stream. Node.js only.
188
+ * @param options.signature - Signature of a public URL, for reading a record without a token.
189
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
171
190
  * @see https://docs.apify.com/api/v2/key-value-store-record-get
172
191
  */
173
192
  getRecord(key: string): Promise<KeyValueStoreRecord<JsonValue> | undefined>;
@@ -196,7 +215,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
196
215
  * `'application/octet-stream'` fallback is treated as compressible, because
197
216
  * it could hold any binary data.
198
217
  * @param options - Storage options
199
- * @param options.timeoutSecs - Timeout for the upload in seconds. Default varies by value size.
218
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'long'`.
200
219
  * @param options.doNotRetryTimeouts - If `true`, don't retry on timeout errors. Default is `false`.
201
220
  * @see https://docs.apify.com/api/v2/key-value-store-record-put
202
221
  *
@@ -229,6 +248,8 @@ export declare class KeyValueStoreClient extends ResourceClient {
229
248
  * Deletes a record from the key-value store.
230
249
  *
231
250
  * @param key - The record key to delete
251
+ * @param options - Request options
252
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
232
253
  * @see https://docs.apify.com/api/v2/key-value-store-record-delete
233
254
  *
234
255
  * @example
@@ -236,7 +257,7 @@ export declare class KeyValueStoreClient extends ResourceClient {
236
257
  * await client.keyValueStore('my-store').deleteRecord('temp-data');
237
258
  * ```
238
259
  */
239
- deleteRecord(key: string): Promise<void>;
260
+ deleteRecord(key: string, options?: TimeoutOptions): Promise<void>;
240
261
  }
241
262
  /**
242
263
  * Options for updating a Key-Value Store.
@@ -255,7 +276,7 @@ export interface KeyValueClientUpdateOptions {
255
276
  /**
256
277
  * Options for listing keys in a Key-Value Store.
257
278
  */
258
- export interface KeyValueClientListKeysOptions {
279
+ export interface KeyValueClientListKeysOptions extends TimeoutOptions {
259
280
  limit?: number;
260
281
  exclusiveStartKey?: string;
261
282
  collection?: string;
@@ -281,7 +302,7 @@ export interface KeyValueClientCreateKeysUrlOptions extends Omit<KeyValueClientL
281
302
  /**
282
303
  * Options for retrieving a record from a Key-Value Store.
283
304
  */
284
- export interface KeyValueClientGetRecordOptions {
305
+ export interface KeyValueClientGetRecordOptions extends TimeoutOptions {
285
306
  buffer?: boolean;
286
307
  stream?: boolean;
287
308
  /**
@@ -311,8 +332,7 @@ export interface KeyValueStoreRecord<T> {
311
332
  * Options for storing a record in a Key-Value Store.
312
333
  * @since Added in 2.12.4
313
334
  */
314
- export interface KeyValueStoreRecordOptions {
315
- timeoutSecs?: number;
335
+ export interface KeyValueStoreRecordOptions extends TimeoutOptions {
316
336
  doNotRetryTimeouts?: boolean;
317
337
  }
318
338
  /**