apify-client 3.0.0-beta.11 → 3.0.0-beta.110
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.
- package/README.md +16 -2
- package/dist/apify_api_error.d.ts +13 -27
- package/dist/apify_api_error.js +33 -23
- package/dist/apify_client.d.ts +125 -10
- package/dist/apify_client.js +133 -48
- package/dist/apify_client_error.d.ts +10 -0
- package/dist/apify_client_error.js +10 -0
- package/dist/base/api_client.d.ts +7 -7
- package/dist/base/api_client.js +36 -36
- package/dist/base/resource_client.d.ts +13 -8
- package/dist/base/resource_client.js +60 -34
- package/dist/base/resource_collection_client.d.ts +12 -4
- package/dist/base/resource_collection_client.js +34 -11
- package/dist/body_parser.d.ts +3 -4
- package/dist/body_parser.js +19 -26
- package/dist/bundle.js +27 -22
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3109 -987
- package/dist/generated/schemas.d.ts +2563 -957
- package/dist/generated/schemas.js +585 -229
- package/dist/http_clients/axios.d.ts +63 -0
- package/dist/http_clients/axios.js +129 -0
- package/dist/http_clients/base.d.ts +397 -0
- package/dist/http_clients/base.js +656 -0
- package/dist/http_clients/index.d.ts +4 -0
- package/dist/http_clients/index.js +2 -0
- package/dist/http_compressors/base.d.ts +40 -0
- package/dist/http_compressors/base.js +9 -0
- package/dist/http_compressors/brotli.d.ts +33 -0
- package/dist/http_compressors/brotli.js +39 -0
- package/dist/http_compressors/gzip.d.ts +33 -0
- package/dist/http_compressors/gzip.js +39 -0
- package/dist/http_compressors/index.d.ts +8 -0
- package/dist/http_compressors/index.js +3 -0
- package/dist/http_compressors/resolve.d.ts +24 -0
- package/dist/http_compressors/resolve.js +30 -0
- package/dist/http_compressors/zstd.d.ts +34 -0
- package/dist/http_compressors/zstd.js +43 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/invalid_response_body_error.d.ts +14 -0
- package/dist/invalid_response_body_error.js +18 -0
- package/dist/models.d.ts +177 -240
- package/dist/models.js +6 -4
- package/dist/resource_clients/actor.d.ts +104 -34
- package/dist/resource_clients/actor.js +129 -55
- package/dist/resource_clients/actor_collection.d.ts +15 -11
- package/dist/resource_clients/actor_collection.js +9 -3
- package/dist/resource_clients/actor_env_var.d.ts +11 -4
- package/dist/resource_clients/actor_env_var.js +16 -6
- package/dist/resource_clients/actor_env_var_collection.d.ts +9 -4
- package/dist/resource_clients/actor_env_var_collection.js +11 -4
- package/dist/resource_clients/actor_server.d.ts +150 -0
- package/dist/resource_clients/actor_server.js +199 -0
- package/dist/resource_clients/actor_version.d.ts +18 -6
- package/dist/resource_clients/actor_version.js +18 -8
- package/dist/resource_clients/actor_version_collection.d.ts +9 -4
- package/dist/resource_clients/actor_version_collection.js +11 -4
- package/dist/resource_clients/build.d.ts +18 -7
- package/dist/resource_clients/build.js +33 -15
- package/dist/resource_clients/build_collection.d.ts +7 -5
- package/dist/resource_clients/build_collection.js +4 -1
- package/dist/resource_clients/dataset.d.ts +83 -36
- package/dist/resource_clients/dataset.js +103 -109
- package/dist/resource_clients/dataset_collection.d.ts +10 -6
- package/dist/resource_clients/dataset_collection.js +13 -2
- package/dist/resource_clients/key_value_store.d.ts +101 -27
- package/dist/resource_clients/key_value_store.js +132 -50
- package/dist/resource_clients/key_value_store_collection.d.ts +10 -6
- package/dist/resource_clients/key_value_store_collection.js +13 -2
- package/dist/resource_clients/log.d.ts +38 -21
- package/dist/resource_clients/log.js +139 -63
- package/dist/resource_clients/request_queue.d.ts +77 -31
- package/dist/resource_clients/request_queue.js +178 -93
- package/dist/resource_clients/request_queue_collection.d.ts +9 -5
- package/dist/resource_clients/request_queue_collection.js +9 -3
- package/dist/resource_clients/run.d.ts +124 -30
- package/dist/resource_clients/run.js +188 -51
- package/dist/resource_clients/run_collection.d.ts +5 -3
- package/dist/resource_clients/run_collection.js +4 -1
- package/dist/resource_clients/schedule.d.ts +15 -6
- package/dist/resource_clients/schedule.js +25 -10
- package/dist/resource_clients/schedule_collection.d.ts +6 -2
- package/dist/resource_clients/schedule_collection.js +9 -3
- package/dist/resource_clients/store_collection.d.ts +6 -4
- package/dist/resource_clients/store_collection.js +4 -1
- package/dist/resource_clients/task.d.ts +35 -12
- package/dist/resource_clients/task.js +75 -35
- package/dist/resource_clients/task_collection.d.ts +9 -5
- package/dist/resource_clients/task_collection.js +9 -3
- package/dist/resource_clients/user.d.ts +16 -7
- package/dist/resource_clients/user.js +34 -16
- package/dist/resource_clients/webhook.d.ts +16 -7
- package/dist/resource_clients/webhook.js +25 -10
- package/dist/resource_clients/webhook_collection.d.ts +8 -4
- package/dist/resource_clients/webhook_collection.js +9 -3
- package/dist/resource_clients/webhook_dispatch.d.ts +4 -1
- package/dist/resource_clients/webhook_dispatch.js +7 -2
- package/dist/resource_clients/webhook_dispatch_collection.d.ts +3 -1
- package/dist/resource_clients/webhook_dispatch_collection.js +4 -1
- package/dist/response_validation_error.d.ts +2 -1
- package/dist/response_validation_error.js +2 -1
- package/dist/runtime/node.d.ts +6 -0
- package/dist/runtime/node.js +87 -0
- package/dist/runtime/types.d.ts +60 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +21 -0
- package/dist/schemas.d.ts +370 -4
- package/dist/schemas.js +26 -4
- package/dist/statistics.d.ts +1 -6
- package/dist/statistics.js +2 -2
- package/dist/timeouts.d.ts +84 -0
- package/dist/timeouts.js +37 -0
- package/dist/timezones.d.ts +1 -1
- package/dist/utils.d.ts +87 -61
- package/dist/utils.js +208 -162
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +41 -38
- package/dist/http_client.d.ts +0 -88
- package/dist/http_client.js +0 -255
- package/dist/interceptors.d.ts +0 -19
- 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 {
|
|
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<
|
|
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<
|
|
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<
|
|
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.
|
|
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
|
-
|
|
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 '../
|
|
6
|
-
import type {
|
|
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
|
-
* @
|
|
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<
|
|
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
|
-
* @
|
|
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<
|
|
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
|
*
|
|
@@ -87,25 +94,30 @@ export declare class RunClient extends ResourceClient {
|
|
|
87
94
|
* and resource allocation. The run effectively becomes a run of the target Actor with new input.
|
|
88
95
|
* This is useful for chaining Actor executions or implementing complex workflows.
|
|
89
96
|
*
|
|
97
|
+
* Only the run itself can metamorph: the client must use the run's own API token, which the run gets
|
|
98
|
+
* in the `APIFY_TOKEN` environment variable. With any other token, the API rejects the request.
|
|
99
|
+
*
|
|
90
100
|
* @param targetActorId - ID or username/name of the target Actor
|
|
91
|
-
* @param input - Input for the target Actor
|
|
101
|
+
* @param input - Input for the target Actor: an object or array serialized to JSON, or raw bytes sent as they
|
|
102
|
+
* are. Omit it to metamorph without input.
|
|
92
103
|
* @param options - Metamorph options
|
|
93
104
|
* @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.
|
|
95
|
-
* @returns The metamorphed
|
|
105
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
106
|
+
* @returns The metamorphed Run object (same ID, but now running the target Actor)
|
|
96
107
|
* @see https://docs.apify.com/api/v2/actor-run-metamorph-post
|
|
97
108
|
*
|
|
98
109
|
* @example
|
|
99
110
|
* ```javascript
|
|
100
|
-
* //
|
|
101
|
-
* const
|
|
111
|
+
* // Inside the run: transform it into another Actor
|
|
112
|
+
* const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
|
|
113
|
+
* const metamorphedRun = await client.run(process.env.ACTOR_RUN_ID).metamorph(
|
|
102
114
|
* 'target-actor-id',
|
|
103
115
|
* { url: 'https://example.com' }
|
|
104
116
|
* );
|
|
105
117
|
* console.log(`Run ${metamorphedRun.id} is now running ${metamorphedRun.actId}`);
|
|
106
118
|
* ```
|
|
107
119
|
*/
|
|
108
|
-
metamorph(targetActorId: string, input
|
|
120
|
+
metamorph(targetActorId: string, input?: ActorInput, options?: RunMetamorphOptions): Promise<Run>;
|
|
109
121
|
/**
|
|
110
122
|
* Reboots the Actor run.
|
|
111
123
|
*
|
|
@@ -113,7 +125,9 @@ export declare class RunClient extends ResourceClient {
|
|
|
113
125
|
* This can be useful to recover from certain errors or to force the Actor to restart
|
|
114
126
|
* with a fresh environment.
|
|
115
127
|
*
|
|
116
|
-
* @
|
|
128
|
+
* @param options - Request options
|
|
129
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
130
|
+
* @returns The updated Run object
|
|
117
131
|
* @see https://docs.apify.com/api/v2/actor-run-reboot-post
|
|
118
132
|
*
|
|
119
133
|
* @example
|
|
@@ -122,7 +136,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
122
136
|
* ```
|
|
123
137
|
* @since Added in 2.8.0
|
|
124
138
|
*/
|
|
125
|
-
reboot(): Promise<
|
|
139
|
+
reboot(options?: TimeoutOptions): Promise<Run>;
|
|
126
140
|
/**
|
|
127
141
|
* Updates the Actor run with specified fields.
|
|
128
142
|
*
|
|
@@ -130,7 +144,9 @@ export declare class RunClient extends ResourceClient {
|
|
|
130
144
|
* @param newFields.statusMessage - Custom status message to display (e.g., "Processing page 10/100")
|
|
131
145
|
* @param newFields.isStatusMessageTerminal - If `true`, the status message is final and won't be overwritten. Default is `false`.
|
|
132
146
|
* @param newFields.generalAccess - General resource access level ('FOLLOW_USER_SETTING', 'ANYONE_WITH_ID_CAN_READ' or 'RESTRICTED')
|
|
133
|
-
* @
|
|
147
|
+
* @param options - Request options
|
|
148
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
149
|
+
* @returns The updated Run object
|
|
134
150
|
*
|
|
135
151
|
* @example
|
|
136
152
|
* ```javascript
|
|
@@ -141,7 +157,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
141
157
|
* ```
|
|
142
158
|
* @since Added in 2.6.0
|
|
143
159
|
*/
|
|
144
|
-
update(newFields: RunUpdateOptions): Promise<
|
|
160
|
+
update(newFields: RunUpdateOptions, options?: TimeoutOptions): Promise<Run>;
|
|
145
161
|
/**
|
|
146
162
|
* Resurrects a finished Actor run, starting it again with the same settings.
|
|
147
163
|
*
|
|
@@ -151,11 +167,12 @@ export declare class RunClient extends ResourceClient {
|
|
|
151
167
|
* @param options - Resurrection options (override original run settings)
|
|
152
168
|
* @param options.build - Tag or number of the build to use. If not provided, uses the original run's build.
|
|
153
169
|
* @param options.memory - Memory in megabytes. If not provided, uses the original run's memory.
|
|
154
|
-
* @param options.
|
|
170
|
+
* @param options.runTimeoutSecs - Timeout for the resurrected run in seconds. If not provided, uses the original run's timeout.
|
|
155
171
|
* @param options.maxItems - Maximum number of dataset items (pay-per-result Actors).
|
|
156
172
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (pay-per-event Actors).
|
|
157
173
|
* @param options.restartOnError - Whether to restart on error.
|
|
158
|
-
* @
|
|
174
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
175
|
+
* @returns The new (resurrected) Run object
|
|
159
176
|
* @see https://docs.apify.com/api/v2/post-resurrect-run
|
|
160
177
|
*
|
|
161
178
|
* @example
|
|
@@ -165,7 +182,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
165
182
|
* console.log(`New run started: ${newRun.id}`);
|
|
166
183
|
* ```
|
|
167
184
|
*/
|
|
168
|
-
resurrect(options?: RunResurrectOptions): Promise<
|
|
185
|
+
resurrect(options?: RunResurrectOptions): Promise<Run>;
|
|
169
186
|
/**
|
|
170
187
|
* Charges the Actor run for a specific event.
|
|
171
188
|
*
|
|
@@ -173,6 +190,8 @@ export declare class RunClient extends ResourceClient {
|
|
|
173
190
|
* @param options.eventName - **Required.** Name of the event to charge for.
|
|
174
191
|
* @param options.count - Number of times to charge the event. Default is 1.
|
|
175
192
|
* @param options.idempotencyKey - Optional key to ensure the charge is not duplicated. If not provided, one is auto-generated.
|
|
193
|
+
* @param options.requestId - ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs.
|
|
194
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
176
195
|
* @returns Empty response object.
|
|
177
196
|
* @see https://docs.apify.com/api/v2/post-charge-run
|
|
178
197
|
* @since Added in 2.11.0
|
|
@@ -188,10 +207,12 @@ export declare class RunClient extends ResourceClient {
|
|
|
188
207
|
* Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
|
|
189
208
|
* by polling the run status. It uses the `waitForFinish` parameter internally (max 60s per call)
|
|
190
209
|
* and continuously polls until the run finishes or the timeout is reached.
|
|
210
|
+
* Rejects with a {@link NotFoundError} if the run keeps returning 404 for 3 seconds.
|
|
191
211
|
*
|
|
192
212
|
* @param options - Wait options
|
|
193
213
|
* @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
|
-
* @
|
|
214
|
+
* @param options.timeoutSecs - Timeout for each polling API request. Default is `'noTimeout'`.
|
|
215
|
+
* @returns The Run object (finished or still running if the timeout was reached)
|
|
195
216
|
*
|
|
196
217
|
* @example
|
|
197
218
|
* ```javascript
|
|
@@ -206,7 +227,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
206
227
|
* }
|
|
207
228
|
* ```
|
|
208
229
|
*/
|
|
209
|
-
waitForFinish(options?: RunWaitForFinishOptions): Promise<
|
|
230
|
+
waitForFinish(options?: RunWaitForFinishOptions): Promise<Run>;
|
|
210
231
|
/**
|
|
211
232
|
* Returns a client for the default dataset of this Actor run.
|
|
212
233
|
*
|
|
@@ -272,34 +293,79 @@ export declare class RunClient extends ResourceClient {
|
|
|
272
293
|
log(): LogClient;
|
|
273
294
|
/**
|
|
274
295
|
* Get StreamedLog for convenient streaming of the run log and their redirection.
|
|
296
|
+
*
|
|
297
|
+
* @param options - Streaming options
|
|
298
|
+
* @param options.toLog - Log instance to redirect the run log to. Use `'default'` for a preconfigured one, or `null` to disable the redirection.
|
|
299
|
+
* @param options.fromStart - If `true`, the log is streamed from its beginning. Default is `true`.
|
|
300
|
+
* @param options.timeoutSecs - Timeout for the API requests that fetch the run and its Actor. Default is `'long'`.
|
|
275
301
|
* @since Added in 2.20.0
|
|
276
302
|
*/
|
|
277
303
|
getStreamedLog(options?: GetStreamedLogOptions): Promise<StreamedLog | undefined>;
|
|
304
|
+
/**
|
|
305
|
+
* Iterates over the items of the run's default dataset while the run is still producing them.
|
|
306
|
+
*
|
|
307
|
+
* While the run has not finished, each poll yields the rows below the dataset's `itemCount` and then waits up to
|
|
308
|
+
* `pollIntervalSecs` for the run to finish, so the last rows are read as soon as it does. Each page is requested
|
|
309
|
+
* with a `limit` that ends at `itemCount`, so it covers exactly the rows it asks for, whatever the filters or
|
|
310
|
+
* `unwind` do to the items. `itemCount` lags a few seconds behind
|
|
311
|
+
* the pushed items, so once the run reaches a terminal status, the rows past it are read a page at a time until
|
|
312
|
+
* none are left, and the iterator returns. On a `lastRun()` client, the iterator sticks to the run that its first
|
|
313
|
+
* request resolves to.
|
|
314
|
+
*
|
|
315
|
+
* @param options - Iteration options
|
|
316
|
+
* @param options.offset - Number of rows to skip from the beginning. Default is 0.
|
|
317
|
+
* @param options.limit - Maximum number of dataset rows to scan. Fewer items are yielded when filters drop some,
|
|
318
|
+
* more when `unwind` splits a row into several. Default is no limit.
|
|
319
|
+
* @param options.clean - If `true`, returns only non-empty items and skips hidden fields. Default is `false`.
|
|
320
|
+
* @param options.fields - Array of field names to include in the results. Omits all other fields.
|
|
321
|
+
* @param options.omit - Array of field names to exclude from the results.
|
|
322
|
+
* @param options.unwind - Array of field names to unwind. Each array value creates a separate item.
|
|
323
|
+
* @param options.skipEmpty - If `true`, skips empty items. Default is `false`.
|
|
324
|
+
* @param options.skipHidden - If `true`, skips hidden fields (fields starting with `#`). Default is `false`.
|
|
325
|
+
* @param options.chunkSize - Maximum number of dataset rows requested per API call. Default is 1000.
|
|
326
|
+
* @param options.pollIntervalSecs - How long to wait for the run to finish between polls, in seconds. Default is 5.
|
|
327
|
+
* @param options.timeoutSecs - Timeout for each API request. Default is `'long'`.
|
|
328
|
+
* @returns An async iterable of the dataset items
|
|
329
|
+
* @see https://docs.apify.com/api/v2/dataset-items-get
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```javascript
|
|
333
|
+
* for await (const item of client.run('run-id').iterateDatasetItems()) {
|
|
334
|
+
* console.log(item);
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
iterateDatasetItems<Data extends Record<string | number, any> = Record<string | number, unknown>>(options?: RunIterateDatasetItemsOptions): AsyncGenerator<Data, void, undefined>;
|
|
278
339
|
}
|
|
279
340
|
/**
|
|
280
341
|
* Options for getting a streamed log.
|
|
281
342
|
* @since Added in 2.20.0
|
|
282
343
|
*/
|
|
283
|
-
export interface GetStreamedLogOptions {
|
|
344
|
+
export interface GetStreamedLogOptions extends TimeoutOptions {
|
|
284
345
|
toLog?: Log | null | 'default';
|
|
285
346
|
fromStart?: boolean;
|
|
286
347
|
}
|
|
287
348
|
/**
|
|
288
349
|
* Options for getting a Run.
|
|
289
350
|
*/
|
|
290
|
-
export interface RunGetOptions {
|
|
351
|
+
export interface RunGetOptions extends TimeoutOptions {
|
|
291
352
|
waitForFinish?: number;
|
|
292
353
|
}
|
|
293
354
|
/**
|
|
294
355
|
* Options for aborting a Run.
|
|
295
356
|
*/
|
|
296
|
-
export interface RunAbortOptions {
|
|
357
|
+
export interface RunAbortOptions extends TimeoutOptions {
|
|
297
358
|
gracefully?: boolean;
|
|
298
359
|
}
|
|
299
360
|
/**
|
|
300
361
|
* Options for metamorphing a Run into another Actor.
|
|
301
362
|
*/
|
|
302
|
-
export interface RunMetamorphOptions {
|
|
363
|
+
export interface RunMetamorphOptions extends TimeoutOptions {
|
|
364
|
+
/**
|
|
365
|
+
* Content type of the request body, which becomes the content type of the run's `INPUT` record.
|
|
366
|
+
* Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
|
|
367
|
+
* with `application/x-www-form-urlencoded` form-encodes it instead.
|
|
368
|
+
*/
|
|
303
369
|
contentType?: string;
|
|
304
370
|
build?: string;
|
|
305
371
|
}
|
|
@@ -321,10 +387,11 @@ export interface RunUpdateOptions {
|
|
|
321
387
|
/**
|
|
322
388
|
* Options for resurrecting a finished Run.
|
|
323
389
|
*/
|
|
324
|
-
export interface RunResurrectOptions {
|
|
390
|
+
export interface RunResurrectOptions extends TimeoutOptions {
|
|
325
391
|
build?: string;
|
|
326
392
|
memory?: number;
|
|
327
|
-
timeout
|
|
393
|
+
/** Timeout for the resurrected run in seconds. If not provided, the run keeps its original timeout. */
|
|
394
|
+
runTimeoutSecs?: number;
|
|
328
395
|
/**
|
|
329
396
|
* @since Added in 2.12.1
|
|
330
397
|
*/
|
|
@@ -342,18 +409,24 @@ export interface RunResurrectOptions {
|
|
|
342
409
|
* Options for charging events in a pay-per-event Actor run.
|
|
343
410
|
* @since Added in 2.11.0
|
|
344
411
|
*/
|
|
345
|
-
export interface RunChargeOptions {
|
|
412
|
+
export interface RunChargeOptions extends TimeoutOptions {
|
|
346
413
|
/** Name of the event to charge. Must be defined in the Actor's pricing info else the API will throw. */
|
|
347
414
|
eventName: string;
|
|
348
415
|
/** Defaults to 1 */
|
|
349
416
|
count?: number;
|
|
350
417
|
/** Defaults to runId-eventName-timestamp */
|
|
351
418
|
idempotencyKey?: string;
|
|
419
|
+
/**
|
|
420
|
+
* ID of the Server Actor request being charged, taken from the `X-Actor-Request-ID` header of the incoming request.
|
|
421
|
+
* Required for multi-tenant Server Actor runs, where it maps the charge to the caller's account instead of the account that started the run.
|
|
422
|
+
* Ignored elsewhere.
|
|
423
|
+
*/
|
|
424
|
+
requestId?: string;
|
|
352
425
|
}
|
|
353
426
|
/**
|
|
354
427
|
* Options for waiting for a Run to finish.
|
|
355
428
|
*/
|
|
356
|
-
export interface RunWaitForFinishOptions {
|
|
429
|
+
export interface RunWaitForFinishOptions extends TimeoutOptions {
|
|
357
430
|
/**
|
|
358
431
|
* Maximum time to wait for the run to finish, in seconds.
|
|
359
432
|
* If the limit is reached, the returned promise is resolved to a run object that will have
|
|
@@ -361,3 +434,24 @@ export interface RunWaitForFinishOptions {
|
|
|
361
434
|
*/
|
|
362
435
|
waitSecs?: number;
|
|
363
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Options for iterating over the items of a run's default dataset while the run is still producing them.
|
|
439
|
+
*/
|
|
440
|
+
export interface RunIterateDatasetItemsOptions extends PaginationOptions, TimeoutOptions {
|
|
441
|
+
/** Maximum number of dataset rows requested per API call. Default is 1000. */
|
|
442
|
+
chunkSize?: number;
|
|
443
|
+
/** If `true`, returns only non-empty items and skips hidden fields. */
|
|
444
|
+
clean?: boolean;
|
|
445
|
+
/** Field names to include in the items. Omits all other fields. */
|
|
446
|
+
fields?: string[];
|
|
447
|
+
/** Field names to exclude from the items. */
|
|
448
|
+
omit?: string[];
|
|
449
|
+
/** If `true`, skips empty items. */
|
|
450
|
+
skipEmpty?: boolean;
|
|
451
|
+
/** If `true`, skips hidden fields (fields starting with `#`). */
|
|
452
|
+
skipHidden?: boolean;
|
|
453
|
+
/** Field names to unwind. Each array value creates a separate item. */
|
|
454
|
+
unwind?: string[];
|
|
455
|
+
/** How long to wait for the run to finish between polls, in seconds. Default is 5. */
|
|
456
|
+
pollIntervalSecs?: number;
|
|
457
|
+
}
|