apify-client 3.0.0-beta.6 → 3.0.0-beta.60

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 (116) hide show
  1. package/README.md +10 -2
  2. package/dist/apify_api_error.d.ts +11 -26
  3. package/dist/apify_api_error.js +31 -22
  4. package/dist/apify_client.d.ts +125 -10
  5. package/dist/apify_client.js +133 -48
  6. package/dist/base/api_client.d.ts +7 -7
  7. package/dist/base/api_client.js +36 -36
  8. package/dist/base/resource_client.d.ts +21 -8
  9. package/dist/base/resource_client.js +67 -33
  10. package/dist/base/resource_collection_client.d.ts +12 -4
  11. package/dist/base/resource_collection_client.js +34 -11
  12. package/dist/body_parser.d.ts +3 -4
  13. package/dist/body_parser.js +19 -26
  14. package/dist/bundle.js +27 -22
  15. package/dist/bundle.js.map +1 -1
  16. package/dist/generated/api.d.ts +785 -290
  17. package/dist/generated/schemas.d.ts +771 -798
  18. package/dist/generated/schemas.js +183 -179
  19. package/dist/http_clients/axios.d.ts +60 -0
  20. package/dist/http_clients/axios.js +117 -0
  21. package/dist/http_clients/base.d.ts +331 -0
  22. package/dist/http_clients/base.js +563 -0
  23. package/dist/http_clients/index.d.ts +4 -0
  24. package/dist/http_clients/index.js +2 -0
  25. package/dist/http_compressors/base.d.ts +40 -0
  26. package/dist/http_compressors/base.js +9 -0
  27. package/dist/http_compressors/brotli.d.ts +33 -0
  28. package/dist/http_compressors/brotli.js +39 -0
  29. package/dist/http_compressors/gzip.d.ts +33 -0
  30. package/dist/http_compressors/gzip.js +39 -0
  31. package/dist/http_compressors/index.d.ts +6 -0
  32. package/dist/http_compressors/index.js +2 -0
  33. package/dist/http_compressors/resolve.d.ts +23 -0
  34. package/dist/http_compressors/resolve.js +27 -0
  35. package/dist/index.d.ts +4 -1
  36. package/dist/index.js +3 -1
  37. package/dist/invalid_response_body_error.d.ts +13 -0
  38. package/dist/invalid_response_body_error.js +17 -0
  39. package/dist/models.d.ts +162 -194
  40. package/dist/models.js +6 -4
  41. package/dist/resource_clients/actor.d.ts +74 -34
  42. package/dist/resource_clients/actor.js +87 -56
  43. package/dist/resource_clients/actor_collection.d.ts +18 -14
  44. package/dist/resource_clients/actor_collection.js +11 -3
  45. package/dist/resource_clients/actor_env_var.d.ts +11 -4
  46. package/dist/resource_clients/actor_env_var.js +16 -6
  47. package/dist/resource_clients/actor_env_var_collection.d.ts +16 -20
  48. package/dist/resource_clients/actor_env_var_collection.js +17 -11
  49. package/dist/resource_clients/actor_version.d.ts +20 -5
  50. package/dist/resource_clients/actor_version.js +19 -9
  51. package/dist/resource_clients/actor_version_collection.d.ts +18 -19
  52. package/dist/resource_clients/actor_version_collection.js +19 -11
  53. package/dist/resource_clients/build.d.ts +20 -7
  54. package/dist/resource_clients/build.js +35 -15
  55. package/dist/resource_clients/build_collection.d.ts +7 -5
  56. package/dist/resource_clients/build_collection.js +4 -1
  57. package/dist/resource_clients/dataset.d.ts +53 -35
  58. package/dist/resource_clients/dataset.js +105 -80
  59. package/dist/resource_clients/dataset_collection.d.ts +10 -6
  60. package/dist/resource_clients/dataset_collection.js +13 -2
  61. package/dist/resource_clients/key_value_store.d.ts +73 -23
  62. package/dist/resource_clients/key_value_store.js +86 -43
  63. package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
  64. package/dist/resource_clients/key_value_store_collection.js +13 -2
  65. package/dist/resource_clients/log.d.ts +13 -20
  66. package/dist/resource_clients/log.js +141 -59
  67. package/dist/resource_clients/request_queue.d.ts +74 -36
  68. package/dist/resource_clients/request_queue.js +182 -106
  69. package/dist/resource_clients/request_queue_collection.d.ts +9 -5
  70. package/dist/resource_clients/request_queue_collection.js +9 -3
  71. package/dist/resource_clients/run.d.ts +119 -28
  72. package/dist/resource_clients/run.js +190 -49
  73. package/dist/resource_clients/run_collection.d.ts +5 -3
  74. package/dist/resource_clients/run_collection.js +4 -1
  75. package/dist/resource_clients/schedule.d.ts +16 -7
  76. package/dist/resource_clients/schedule.js +30 -22
  77. package/dist/resource_clients/schedule_collection.d.ts +6 -2
  78. package/dist/resource_clients/schedule_collection.js +9 -3
  79. package/dist/resource_clients/store_collection.d.ts +6 -4
  80. package/dist/resource_clients/store_collection.js +4 -1
  81. package/dist/resource_clients/task.d.ts +36 -13
  82. package/dist/resource_clients/task.js +79 -46
  83. package/dist/resource_clients/task_collection.d.ts +9 -5
  84. package/dist/resource_clients/task_collection.js +9 -3
  85. package/dist/resource_clients/user.d.ts +19 -10
  86. package/dist/resource_clients/user.js +42 -38
  87. package/dist/resource_clients/webhook.d.ts +17 -8
  88. package/dist/resource_clients/webhook.js +30 -22
  89. package/dist/resource_clients/webhook_collection.d.ts +8 -4
  90. package/dist/resource_clients/webhook_collection.js +9 -3
  91. package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
  92. package/dist/resource_clients/webhook_dispatch.js +7 -2
  93. package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
  94. package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
  95. package/dist/runtime/node.d.ts +6 -0
  96. package/dist/runtime/node.js +49 -0
  97. package/dist/runtime/types.d.ts +52 -0
  98. package/dist/runtime/types.js +1 -0
  99. package/dist/runtime/web.d.ts +5 -0
  100. package/dist/runtime/web.js +18 -0
  101. package/dist/schemas.d.ts +1 -1
  102. package/dist/schemas.js +1 -1
  103. package/dist/statistics.d.ts +1 -6
  104. package/dist/statistics.js +2 -2
  105. package/dist/timeouts.d.ts +84 -0
  106. package/dist/timeouts.js +37 -0
  107. package/dist/timezones.d.ts +1 -1
  108. package/dist/utils.d.ts +89 -53
  109. package/dist/utils.js +214 -161
  110. package/dist/wait_for_resources.d.ts +8 -0
  111. package/dist/wait_for_resources.js +39 -0
  112. package/package.json +32 -29
  113. package/dist/http_client.d.ts +0 -88
  114. package/dist/http_client.js +0 -255
  115. package/dist/interceptors.d.ts +0 -19
  116. package/dist/interceptors.js +0 -105
@@ -1,8 +1,9 @@
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
- import type { RequestQueue } from './request_queue.js';
6
+ import type { RequestQueueResource } from './request_queue.js';
6
7
  /**
7
8
  * Client for managing the collection of Request queues in your account.
8
9
  *
@@ -45,20 +46,23 @@ export declare class RequestQueueCollectionClient extends ResourceCollectionClie
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 Request queues.
49
51
  * @see https://docs.apify.com/api/v2/request-queues-get
50
52
  */
51
- list(options?: RequestQueueCollectionListOptions): Promise<RequestQueueCollectionListResult> & AsyncIterable<RequestQueue>;
53
+ list(options?: RequestQueueCollectionListOptions): Promise<RequestQueueCollectionListResult> & AsyncIterable<RequestQueueResource>;
52
54
  /**
53
55
  * Gets or creates a Request queue with the specified name.
54
56
  *
55
57
  * @param name - Name of the Request queue. If not provided, a default queue is used.
58
+ * @param options - Request options
59
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
56
60
  * @returns The Request queue object.
57
61
  * @see https://docs.apify.com/api/v2/request-queues-post
58
62
  */
59
- getOrCreate(name?: string): Promise<RequestQueue>;
63
+ getOrCreate(name?: string, options?: TimeoutOptions): Promise<RequestQueueResource>;
60
64
  }
61
- export interface RequestQueueCollectionListOptions extends PaginationOptions {
65
+ export interface RequestQueueCollectionListOptions extends PaginationOptions, TimeoutOptions {
62
66
  unnamed?: boolean;
63
67
  desc?: boolean;
64
68
  /**
@@ -67,6 +71,6 @@ export interface RequestQueueCollectionListOptions extends PaginationOptions {
67
71
  */
68
72
  ownership?: STORAGE_OWNERSHIP_FILTER;
69
73
  }
70
- export type RequestQueueCollectionListResult = PaginatedList<RequestQueue> & {
74
+ export type RequestQueueCollectionListResult = PaginatedList<RequestQueueResource> & {
71
75
  unnamed: boolean;
72
76
  };
@@ -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 { timeoutOptionsSchema, timeoutOptionsShape } from '../timeouts.js';
5
6
  import { 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
  /**
@@ -57,22 +59,26 @@ export class RequestQueueCollectionClient extends ResourceCollectionClient {
57
59
  * ```
58
60
  *
59
61
  * @param options - Pagination options.
62
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'medium'`.
60
63
  * @returns A paginated iterator of Request queues.
61
64
  * @see https://docs.apify.com/api/v2/request-queues-get
62
65
  */
63
66
  list(options = {}) {
64
67
  const parsed = parseArgument(options, listOptionsSchema, 'RequestQueueCollectionListOptions');
65
- return this._listPaginated(schemas.ListOfRequestQueues(), parsed);
68
+ return this.listResourcesPaginated(schemas.ListOfRequestQueues(), parsed, 'medium');
66
69
  }
67
70
  /**
68
71
  * Gets or creates a Request queue with the specified name.
69
72
  *
70
73
  * @param name - Name of the Request queue. If not provided, a default queue is used.
74
+ * @param options - Request options
75
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
71
76
  * @returns The Request queue object.
72
77
  * @see https://docs.apify.com/api/v2/request-queues-post
73
78
  */
74
- async getOrCreate(name) {
79
+ async getOrCreate(name, options = {}) {
75
80
  parseArgument(name, nameSchema);
76
- return this._getOrCreate(schemas.RequestQueue(), name);
81
+ const { timeoutSecs = 'short', signal } = parseArgument(options, timeoutOptionsSchema, 'TimeoutOptions');
82
+ return this.getOrCreateResource(schemas.RequestQueueResource(), name, undefined, timeoutSecs, signal);
77
83
  }
78
84
  }
@@ -2,8 +2,10 @@ import type { RUN_GENERAL_ACCESS } from '@apify/consts';
2
2
  import { Log } from '@apify/log';
3
3
  import type { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client.js';
4
4
  import { ResourceClient } from '../base/resource_client.js';
5
- import type { ApifyResponse } from '../http_client.js';
6
- import type { ActorRun } from './actor.js';
5
+ import type { ApifyResponse } from '../http_clients/index.js';
6
+ import type { TimeoutOptions } from '../timeouts.js';
7
+ import type { PaginationOptions } from '../utils.js';
8
+ import type { ActorInput, Run } from './actor.js';
7
9
  import { DatasetClient } from './dataset.js';
8
10
  import { KeyValueStoreClient } from './key_value_store.js';
9
11
  import { LogClient, StreamedLog } from './log.js';
@@ -41,7 +43,9 @@ export declare class RunClient extends ResourceClient {
41
43
  *
42
44
  * @param options - Get options
43
45
  * @param options.waitForFinish - Maximum time to wait (in seconds, max 60s) for the run to finish on the API side before returning. Default is 0 (returns immediately).
44
- * @returns The ActorRun object, or `undefined` if it does not exist
46
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`, extended to cover `waitForFinish`
47
+ * when the API is asked to hold the response.
48
+ * @returns The Run object, or `undefined` if it does not exist
45
49
  * @see https://docs.apify.com/api/v2/actor-run-get
46
50
  *
47
51
  * @example
@@ -54,13 +58,14 @@ export declare class RunClient extends ResourceClient {
54
58
  * const run = await client.run('run-id').get({ waitForFinish: 60 });
55
59
  * ```
56
60
  */
57
- get(options?: RunGetOptions): Promise<ActorRun | undefined>;
61
+ get(options?: RunGetOptions): Promise<Run | undefined>;
58
62
  /**
59
63
  * Aborts the Actor run.
60
64
  *
61
65
  * @param options - Abort options
62
66
  * @param options.gracefully - If `true`, the Actor run will abort gracefully - it can send status messages and perform cleanup. Default is `false` (immediate abort).
63
- * @returns The updated ActorRun object with `ABORTING` or `ABORTED` status
67
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
68
+ * @returns The updated Run object with `ABORTING` or `ABORTED` status
64
69
  * @see https://docs.apify.com/api/v2/actor-run-abort-post
65
70
  *
66
71
  * @example
@@ -72,14 +77,16 @@ export declare class RunClient extends ResourceClient {
72
77
  * await client.run('run-id').abort({ gracefully: true });
73
78
  * ```
74
79
  */
75
- abort(options?: RunAbortOptions): Promise<ActorRun>;
80
+ abort(options?: RunAbortOptions): Promise<Run>;
76
81
  /**
77
82
  * Deletes the Actor run.
78
83
  *
84
+ * @param options - Request options
85
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
79
86
  * @see https://docs.apify.com/api/v2/actor-run-delete
80
87
  * @since Added in 2.8.1
81
88
  */
82
- delete(): Promise<void>;
89
+ delete(options?: TimeoutOptions): Promise<void>;
83
90
  /**
84
91
  * Transforms the Actor run into a run of another Actor (metamorph).
85
92
  *
@@ -88,11 +95,12 @@ export declare class RunClient extends ResourceClient {
88
95
  * This is useful for chaining Actor executions or implementing complex workflows.
89
96
  *
90
97
  * @param targetActorId - ID or username/name of the target Actor
91
- * @param input - Input for the target Actor. Can be any JSON-serializable value.
98
+ * @param input - Input for the target Actor: an object or array serialized to JSON, or raw bytes sent as they
99
+ * are. Omit it to metamorph without input.
92
100
  * @param options - Metamorph options
93
101
  * @param options.build - Tag or number of the target Actor's build to run. Default is the target Actor's default build.
94
- * @param options.contentType - Content type of the input. If specified, input must be a string or Buffer.
95
- * @returns The metamorphed ActorRun object (same ID, but now running the target Actor)
102
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
103
+ * @returns The metamorphed Run object (same ID, but now running the target Actor)
96
104
  * @see https://docs.apify.com/api/v2/actor-run-metamorph-post
97
105
  *
98
106
  * @example
@@ -105,7 +113,7 @@ export declare class RunClient extends ResourceClient {
105
113
  * console.log(`Run ${metamorphedRun.id} is now running ${metamorphedRun.actId}`);
106
114
  * ```
107
115
  */
108
- metamorph(targetActorId: string, input: unknown, options?: RunMetamorphOptions): Promise<ActorRun>;
116
+ metamorph(targetActorId: string, input?: ActorInput, options?: RunMetamorphOptions): Promise<Run>;
109
117
  /**
110
118
  * Reboots the Actor run.
111
119
  *
@@ -113,7 +121,9 @@ export declare class RunClient extends ResourceClient {
113
121
  * This can be useful to recover from certain errors or to force the Actor to restart
114
122
  * with a fresh environment.
115
123
  *
116
- * @returns The updated ActorRun object
124
+ * @param options - Request options
125
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
126
+ * @returns The updated Run object
117
127
  * @see https://docs.apify.com/api/v2/actor-run-reboot-post
118
128
  *
119
129
  * @example
@@ -122,7 +132,7 @@ export declare class RunClient extends ResourceClient {
122
132
  * ```
123
133
  * @since Added in 2.8.0
124
134
  */
125
- reboot(): Promise<ActorRun>;
135
+ reboot(options?: TimeoutOptions): Promise<Run>;
126
136
  /**
127
137
  * Updates the Actor run with specified fields.
128
138
  *
@@ -130,7 +140,9 @@ export declare class RunClient extends ResourceClient {
130
140
  * @param newFields.statusMessage - Custom status message to display (e.g., "Processing page 10/100")
131
141
  * @param newFields.isStatusMessageTerminal - If `true`, the status message is final and won't be overwritten. Default is `false`.
132
142
  * @param newFields.generalAccess - General resource access level ('FOLLOW_USER_SETTING', 'ANYONE_WITH_ID_CAN_READ' or 'RESTRICTED')
133
- * @returns The updated ActorRun object
143
+ * @param options - Request options
144
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
145
+ * @returns The updated Run object
134
146
  *
135
147
  * @example
136
148
  * ```javascript
@@ -141,7 +153,7 @@ export declare class RunClient extends ResourceClient {
141
153
  * ```
142
154
  * @since Added in 2.6.0
143
155
  */
144
- update(newFields: RunUpdateOptions): Promise<ActorRun>;
156
+ update(newFields: RunUpdateOptions, options?: TimeoutOptions): Promise<Run>;
145
157
  /**
146
158
  * Resurrects a finished Actor run, starting it again with the same settings.
147
159
  *
@@ -151,11 +163,12 @@ export declare class RunClient extends ResourceClient {
151
163
  * @param options - Resurrection options (override original run settings)
152
164
  * @param options.build - Tag or number of the build to use. If not provided, uses the original run's build.
153
165
  * @param options.memory - Memory in megabytes. If not provided, uses the original run's memory.
154
- * @param options.timeout - Timeout in seconds. If not provided, uses the original run's timeout.
166
+ * @param options.runTimeoutSecs - Timeout for the resurrected run in seconds. If not provided, uses the original run's timeout.
155
167
  * @param options.maxItems - Maximum number of dataset items (pay-per-result Actors).
156
168
  * @param options.maxTotalChargeUsd - Maximum cost in USD (pay-per-event Actors).
157
169
  * @param options.restartOnError - Whether to restart on error.
158
- * @returns The new (resurrected) ActorRun object
170
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
171
+ * @returns The new (resurrected) Run object
159
172
  * @see https://docs.apify.com/api/v2/post-resurrect-run
160
173
  *
161
174
  * @example
@@ -165,7 +178,7 @@ export declare class RunClient extends ResourceClient {
165
178
  * console.log(`New run started: ${newRun.id}`);
166
179
  * ```
167
180
  */
168
- resurrect(options?: RunResurrectOptions): Promise<ActorRun>;
181
+ resurrect(options?: RunResurrectOptions): Promise<Run>;
169
182
  /**
170
183
  * Charges the Actor run for a specific event.
171
184
  *
@@ -173,6 +186,7 @@ export declare class RunClient extends ResourceClient {
173
186
  * @param options.eventName - **Required.** Name of the event to charge for.
174
187
  * @param options.count - Number of times to charge the event. Default is 1.
175
188
  * @param options.idempotencyKey - Optional key to ensure the charge is not duplicated. If not provided, one is auto-generated.
189
+ * @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
176
190
  * @returns Empty response object.
177
191
  * @see https://docs.apify.com/api/v2/post-charge-run
178
192
  * @since Added in 2.11.0
@@ -188,10 +202,12 @@ export declare class RunClient extends ResourceClient {
188
202
  * Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
189
203
  * by polling the run status. It uses the `waitForFinish` parameter internally (max 60s per call)
190
204
  * and continuously polls until the run finishes or the timeout is reached.
205
+ * Rejects with a {@link NotFoundError} if the run keeps returning 404 for 3 seconds.
191
206
  *
192
207
  * @param options - Wait options
193
208
  * @param options.waitSecs - Maximum time to wait for the run to finish, in seconds. If the limit is reached, the returned promise resolves to a run object that will have status `READY` or `RUNNING`. If omitted, waits indefinitely.
194
- * @returns The ActorRun object (finished or still running if timeout was reached)
209
+ * @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
210
+ * @returns The Run object (finished or still running if the timeout was reached)
195
211
  *
196
212
  * @example
197
213
  * ```javascript
@@ -206,10 +222,12 @@ export declare class RunClient extends ResourceClient {
206
222
  * }
207
223
  * ```
208
224
  */
209
- waitForFinish(options?: RunWaitForFinishOptions): Promise<ActorRun>;
225
+ waitForFinish(options?: RunWaitForFinishOptions): Promise<Run>;
210
226
  /**
211
227
  * Returns a client for the default dataset of this Actor run.
212
228
  *
229
+ * A 404 from this client throws an `ApifyApiError`, since the run itself may be what is missing.
230
+ *
213
231
  * @returns A client for accessing the run's default dataset
214
232
  * @see https://docs.apify.com/api/v2/actor-run-get
215
233
  *
@@ -223,6 +241,9 @@ export declare class RunClient extends ResourceClient {
223
241
  /**
224
242
  * Returns a client for the default key-value store of this Actor run.
225
243
  *
244
+ * `get()` and `delete()` throw an `ApifyApiError` on a 404, since the run itself may be what is missing. Record
245
+ * lookups such as `getRecord()` read a 404 as a missing record.
246
+ *
226
247
  * @returns A client for accessing the run's default key-value store
227
248
  * @see https://docs.apify.com/api/v2/actor-run-get
228
249
  *
@@ -236,6 +257,9 @@ export declare class RunClient extends ResourceClient {
236
257
  /**
237
258
  * Returns a client for the default Request queue of this Actor run.
238
259
  *
260
+ * `get()` and `delete()` throw an `ApifyApiError` on a 404, since the run itself may be what is missing.
261
+ * `getRequest()` reads a 404 as a missing request.
262
+ *
239
263
  * @returns A client for accessing the run's default Request queue
240
264
  * @see https://docs.apify.com/api/v2/actor-run-get
241
265
  *
@@ -249,6 +273,8 @@ export declare class RunClient extends ResourceClient {
249
273
  /**
250
274
  * Returns a client for accessing the log of this Actor run.
251
275
  *
276
+ * A 404 from this client throws an `ApifyApiError`, since the run itself may be what is missing.
277
+ *
252
278
  * @returns A client for accessing the run's log
253
279
  * @see https://docs.apify.com/api/v2/actor-run-get
254
280
  *
@@ -262,34 +288,79 @@ export declare class RunClient extends ResourceClient {
262
288
  log(): LogClient;
263
289
  /**
264
290
  * Get StreamedLog for convenient streaming of the run log and their redirection.
291
+ *
292
+ * @param options - Streaming options
293
+ * @param options.toLog - Log instance to redirect the run log to. Use `'default'` for a preconfigured one, or `null` to disable the redirection.
294
+ * @param options.fromStart - If `true`, the log is streamed from its beginning. Default is `true`.
295
+ * @param options.timeoutSecs - Timeout for the API requests that fetch the run and its Actor. Default is `'long'`.
265
296
  * @since Added in 2.20.0
266
297
  */
267
298
  getStreamedLog(options?: GetStreamedLogOptions): Promise<StreamedLog | undefined>;
299
+ /**
300
+ * Iterates over the items of the run's default dataset while the run is still producing them.
301
+ *
302
+ * While the run has not finished, each poll yields the rows below the dataset's `itemCount` and then waits up to
303
+ * `pollIntervalSecs` for the run to finish, so the last rows are read as soon as it does. Each page is requested
304
+ * with a `limit` that ends at `itemCount`, so it covers exactly the rows it asks for, whatever the filters or
305
+ * `unwind` do to the items. `itemCount` lags a few seconds behind
306
+ * the pushed items, so once the run reaches a terminal status, the rows past it are read a page at a time until
307
+ * none are left, and the iterator returns. On a `lastRun()` client, the iterator sticks to the run that its first
308
+ * request resolves to.
309
+ *
310
+ * @param options - Iteration options
311
+ * @param options.offset - Number of rows to skip from the beginning. Default is 0.
312
+ * @param options.limit - Maximum number of dataset rows to scan. Fewer items are yielded when filters drop some,
313
+ * more when `unwind` splits a row into several. Default is no limit.
314
+ * @param options.clean - If `true`, returns only non-empty items and skips hidden fields. Default is `false`.
315
+ * @param options.fields - Array of field names to include in the results. Omits all other fields.
316
+ * @param options.omit - Array of field names to exclude from the results.
317
+ * @param options.unwind - Array of field names to unwind. Each array value creates a separate item.
318
+ * @param options.skipEmpty - If `true`, skips empty items. Default is `false`.
319
+ * @param options.skipHidden - If `true`, skips hidden fields (fields starting with `#`). Default is `false`.
320
+ * @param options.chunkSize - Maximum number of dataset rows requested per API call. Default is 1000.
321
+ * @param options.pollIntervalSecs - How long to wait for the run to finish between polls, in seconds. Default is 5.
322
+ * @param options.timeoutSecs - Timeout for each API request. Default is `'long'`.
323
+ * @returns An async iterable of the dataset items
324
+ * @see https://docs.apify.com/api/v2/dataset-items-get
325
+ *
326
+ * @example
327
+ * ```javascript
328
+ * for await (const item of client.run('run-id').iterateDatasetItems()) {
329
+ * console.log(item);
330
+ * }
331
+ * ```
332
+ */
333
+ iterateDatasetItems<Data extends Record<string | number, any> = Record<string | number, unknown>>(options?: RunIterateDatasetItemsOptions): AsyncGenerator<Data, void, undefined>;
268
334
  }
269
335
  /**
270
336
  * Options for getting a streamed log.
271
337
  * @since Added in 2.20.0
272
338
  */
273
- export interface GetStreamedLogOptions {
339
+ export interface GetStreamedLogOptions extends TimeoutOptions {
274
340
  toLog?: Log | null | 'default';
275
341
  fromStart?: boolean;
276
342
  }
277
343
  /**
278
344
  * Options for getting a Run.
279
345
  */
280
- export interface RunGetOptions {
346
+ export interface RunGetOptions extends TimeoutOptions {
281
347
  waitForFinish?: number;
282
348
  }
283
349
  /**
284
350
  * Options for aborting a Run.
285
351
  */
286
- export interface RunAbortOptions {
352
+ export interface RunAbortOptions extends TimeoutOptions {
287
353
  gracefully?: boolean;
288
354
  }
289
355
  /**
290
356
  * Options for metamorphing a Run into another Actor.
291
357
  */
292
- export interface RunMetamorphOptions {
358
+ export interface RunMetamorphOptions extends TimeoutOptions {
359
+ /**
360
+ * Content type of the request body, which becomes the content type of the run's `INPUT` record.
361
+ * Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
362
+ * with `application/x-www-form-urlencoded` form-encodes it instead.
363
+ */
293
364
  contentType?: string;
294
365
  build?: string;
295
366
  }
@@ -311,10 +382,11 @@ export interface RunUpdateOptions {
311
382
  /**
312
383
  * Options for resurrecting a finished Run.
313
384
  */
314
- export interface RunResurrectOptions {
385
+ export interface RunResurrectOptions extends TimeoutOptions {
315
386
  build?: string;
316
387
  memory?: number;
317
- timeout?: number;
388
+ /** Timeout for the resurrected run in seconds. If not provided, the run keeps its original timeout. */
389
+ runTimeoutSecs?: number;
318
390
  /**
319
391
  * @since Added in 2.12.1
320
392
  */
@@ -332,7 +404,7 @@ export interface RunResurrectOptions {
332
404
  * Options for charging events in a pay-per-event Actor run.
333
405
  * @since Added in 2.11.0
334
406
  */
335
- export interface RunChargeOptions {
407
+ export interface RunChargeOptions extends TimeoutOptions {
336
408
  /** Name of the event to charge. Must be defined in the Actor's pricing info else the API will throw. */
337
409
  eventName: string;
338
410
  /** Defaults to 1 */
@@ -343,7 +415,7 @@ export interface RunChargeOptions {
343
415
  /**
344
416
  * Options for waiting for a Run to finish.
345
417
  */
346
- export interface RunWaitForFinishOptions {
418
+ export interface RunWaitForFinishOptions extends TimeoutOptions {
347
419
  /**
348
420
  * Maximum time to wait for the run to finish, in seconds.
349
421
  * If the limit is reached, the returned promise is resolved to a run object that will have
@@ -351,3 +423,22 @@ export interface RunWaitForFinishOptions {
351
423
  */
352
424
  waitSecs?: number;
353
425
  }
426
+ /**
427
+ * Options for iterating over the items of a run's default dataset while the run is still producing them.
428
+ */
429
+ export interface RunIterateDatasetItemsOptions extends PaginationOptions, TimeoutOptions {
430
+ /** If `true`, returns only non-empty items and skips hidden fields. */
431
+ clean?: boolean;
432
+ /** Field names to include in the items. Omits all other fields. */
433
+ fields?: string[];
434
+ /** Field names to exclude from the items. */
435
+ omit?: string[];
436
+ /** If `true`, skips empty items. */
437
+ skipEmpty?: boolean;
438
+ /** If `true`, skips hidden fields (fields starting with `#`). */
439
+ skipHidden?: boolean;
440
+ /** Field names to unwind. Each array value creates a separate item. */
441
+ unwind?: string[];
442
+ /** How long to wait for the run to finish between polls, in seconds. Default is 5. */
443
+ pollIntervalSecs?: number;
444
+ }