apify-client 3.0.0-beta.12 → 3.0.0-beta.120
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 +23 -2
- package/dist/apify_api_error.d.ts +14 -28
- 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/axios.d.ts +2 -0
- package/dist/axios.js +1 -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 +4 -5
- package/dist/body_parser.js +19 -26
- package/dist/bundle.js +41 -35
- package/dist/bundle.js.map +1 -1
- package/dist/generated/api.d.ts +3259 -1060
- package/dist/generated/schemas.d.ts +2608 -1028
- package/dist/generated/schemas.js +600 -238
- package/dist/http_clients/axios.d.ts +80 -0
- package/dist/http_clients/axios.js +165 -0
- package/dist/http_clients/base.d.ts +402 -0
- package/dist/http_clients/base.js +680 -0
- package/dist/http_clients/fetch.d.ts +53 -0
- package/dist/http_clients/fetch.js +219 -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 +7 -2
- 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 +94 -23
- package/dist/resource_clients/actor.js +129 -43
- 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 +149 -0
- package/dist/resource_clients/actor_server.js +195 -0
- package/dist/resource_clients/actor_version.d.ts +19 -6
- package/dist/resource_clients/actor_version.js +19 -8
- package/dist/resource_clients/actor_version_collection.d.ts +10 -4
- package/dist/resource_clients/actor_version_collection.js +12 -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 -37
- package/dist/resource_clients/dataset.js +99 -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 +108 -33
- package/dist/resource_clients/key_value_store.js +134 -53
- 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 +41 -25
- package/dist/resource_clients/log.js +142 -65
- 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 +119 -29
- package/dist/resource_clients/run.js +188 -49
- 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 +10 -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 +111 -0
- package/dist/runtime/types.d.ts +82 -0
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/web.d.ts +5 -0
- package/dist/runtime/web.js +60 -0
- package/dist/schemas.d.ts +372 -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 +115 -61
- package/dist/utils.js +220 -161
- package/dist/wait_for_resources.d.ts +8 -0
- package/dist/wait_for_resources.js +39 -0
- package/package.json +53 -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,24 +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
|
-
* @
|
|
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)
|
|
95
107
|
* @see https://docs.apify.com/api/v2/actor-run-metamorph-post
|
|
96
108
|
*
|
|
97
109
|
* @example
|
|
98
110
|
* ```javascript
|
|
99
|
-
* //
|
|
100
|
-
* 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(
|
|
101
114
|
* 'target-actor-id',
|
|
102
115
|
* { url: 'https://example.com' }
|
|
103
116
|
* );
|
|
104
117
|
* console.log(`Run ${metamorphedRun.id} is now running ${metamorphedRun.actId}`);
|
|
105
118
|
* ```
|
|
106
119
|
*/
|
|
107
|
-
metamorph(targetActorId: string, input?: ActorInput, options?: RunMetamorphOptions): Promise<
|
|
120
|
+
metamorph(targetActorId: string, input?: ActorInput, options?: RunMetamorphOptions): Promise<Run>;
|
|
108
121
|
/**
|
|
109
122
|
* Reboots the Actor run.
|
|
110
123
|
*
|
|
@@ -112,7 +125,9 @@ export declare class RunClient extends ResourceClient {
|
|
|
112
125
|
* This can be useful to recover from certain errors or to force the Actor to restart
|
|
113
126
|
* with a fresh environment.
|
|
114
127
|
*
|
|
115
|
-
* @
|
|
128
|
+
* @param options - Request options
|
|
129
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
130
|
+
* @returns The updated Run object
|
|
116
131
|
* @see https://docs.apify.com/api/v2/actor-run-reboot-post
|
|
117
132
|
*
|
|
118
133
|
* @example
|
|
@@ -121,7 +136,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
121
136
|
* ```
|
|
122
137
|
* @since Added in 2.8.0
|
|
123
138
|
*/
|
|
124
|
-
reboot(): Promise<
|
|
139
|
+
reboot(options?: TimeoutOptions): Promise<Run>;
|
|
125
140
|
/**
|
|
126
141
|
* Updates the Actor run with specified fields.
|
|
127
142
|
*
|
|
@@ -129,7 +144,9 @@ export declare class RunClient extends ResourceClient {
|
|
|
129
144
|
* @param newFields.statusMessage - Custom status message to display (e.g., "Processing page 10/100")
|
|
130
145
|
* @param newFields.isStatusMessageTerminal - If `true`, the status message is final and won't be overwritten. Default is `false`.
|
|
131
146
|
* @param newFields.generalAccess - General resource access level ('FOLLOW_USER_SETTING', 'ANYONE_WITH_ID_CAN_READ' or 'RESTRICTED')
|
|
132
|
-
* @
|
|
147
|
+
* @param options - Request options
|
|
148
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'short'`.
|
|
149
|
+
* @returns The updated Run object
|
|
133
150
|
*
|
|
134
151
|
* @example
|
|
135
152
|
* ```javascript
|
|
@@ -140,7 +157,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
140
157
|
* ```
|
|
141
158
|
* @since Added in 2.6.0
|
|
142
159
|
*/
|
|
143
|
-
update(newFields: RunUpdateOptions): Promise<
|
|
160
|
+
update(newFields: RunUpdateOptions, options?: TimeoutOptions): Promise<Run>;
|
|
144
161
|
/**
|
|
145
162
|
* Resurrects a finished Actor run, starting it again with the same settings.
|
|
146
163
|
*
|
|
@@ -150,11 +167,12 @@ export declare class RunClient extends ResourceClient {
|
|
|
150
167
|
* @param options - Resurrection options (override original run settings)
|
|
151
168
|
* @param options.build - Tag or number of the build to use. If not provided, uses the original run's build.
|
|
152
169
|
* @param options.memory - Memory in megabytes. If not provided, uses the original run's memory.
|
|
153
|
-
* @param options.
|
|
170
|
+
* @param options.runTimeoutSecs - Timeout for the resurrected run in seconds. If not provided, uses the original run's timeout.
|
|
154
171
|
* @param options.maxItems - Maximum number of dataset items (pay-per-result Actors).
|
|
155
172
|
* @param options.maxTotalChargeUsd - Maximum cost in USD (pay-per-event Actors).
|
|
156
173
|
* @param options.restartOnError - Whether to restart on error.
|
|
157
|
-
* @
|
|
174
|
+
* @param options.timeoutSecs - Timeout for the API request. Default is `'medium'`.
|
|
175
|
+
* @returns The new (resurrected) Run object
|
|
158
176
|
* @see https://docs.apify.com/api/v2/post-resurrect-run
|
|
159
177
|
*
|
|
160
178
|
* @example
|
|
@@ -164,7 +182,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
164
182
|
* console.log(`New run started: ${newRun.id}`);
|
|
165
183
|
* ```
|
|
166
184
|
*/
|
|
167
|
-
resurrect(options?: RunResurrectOptions): Promise<
|
|
185
|
+
resurrect(options?: RunResurrectOptions): Promise<Run>;
|
|
168
186
|
/**
|
|
169
187
|
* Charges the Actor run for a specific event.
|
|
170
188
|
*
|
|
@@ -172,6 +190,8 @@ export declare class RunClient extends ResourceClient {
|
|
|
172
190
|
* @param options.eventName - **Required.** Name of the event to charge for.
|
|
173
191
|
* @param options.count - Number of times to charge the event. Default is 1.
|
|
174
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'`.
|
|
175
195
|
* @returns Empty response object.
|
|
176
196
|
* @see https://docs.apify.com/api/v2/post-charge-run
|
|
177
197
|
* @since Added in 2.11.0
|
|
@@ -187,10 +207,12 @@ export declare class RunClient extends ResourceClient {
|
|
|
187
207
|
* Unlike the `waitForFinish` parameter in {@link get}, this method can wait indefinitely
|
|
188
208
|
* by polling the run status. It uses the `waitForFinish` parameter internally (max 60s per call)
|
|
189
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.
|
|
190
211
|
*
|
|
191
212
|
* @param options - Wait options
|
|
192
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.
|
|
193
|
-
* @
|
|
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)
|
|
194
216
|
*
|
|
195
217
|
* @example
|
|
196
218
|
* ```javascript
|
|
@@ -205,7 +227,7 @@ export declare class RunClient extends ResourceClient {
|
|
|
205
227
|
* }
|
|
206
228
|
* ```
|
|
207
229
|
*/
|
|
208
|
-
waitForFinish(options?: RunWaitForFinishOptions): Promise<
|
|
230
|
+
waitForFinish(options?: RunWaitForFinishOptions): Promise<Run>;
|
|
209
231
|
/**
|
|
210
232
|
* Returns a client for the default dataset of this Actor run.
|
|
211
233
|
*
|
|
@@ -271,34 +293,74 @@ export declare class RunClient extends ResourceClient {
|
|
|
271
293
|
log(): LogClient;
|
|
272
294
|
/**
|
|
273
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'`.
|
|
274
301
|
* @since Added in 2.20.0
|
|
275
302
|
*/
|
|
276
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>;
|
|
277
339
|
}
|
|
278
340
|
/**
|
|
279
341
|
* Options for getting a streamed log.
|
|
280
342
|
* @since Added in 2.20.0
|
|
281
343
|
*/
|
|
282
|
-
export interface GetStreamedLogOptions {
|
|
344
|
+
export interface GetStreamedLogOptions extends TimeoutOptions {
|
|
283
345
|
toLog?: Log | null | 'default';
|
|
284
346
|
fromStart?: boolean;
|
|
285
347
|
}
|
|
286
348
|
/**
|
|
287
349
|
* Options for getting a Run.
|
|
288
350
|
*/
|
|
289
|
-
export interface RunGetOptions {
|
|
351
|
+
export interface RunGetOptions extends TimeoutOptions {
|
|
290
352
|
waitForFinish?: number;
|
|
291
353
|
}
|
|
292
354
|
/**
|
|
293
355
|
* Options for aborting a Run.
|
|
294
356
|
*/
|
|
295
|
-
export interface RunAbortOptions {
|
|
357
|
+
export interface RunAbortOptions extends TimeoutOptions {
|
|
296
358
|
gracefully?: boolean;
|
|
297
359
|
}
|
|
298
360
|
/**
|
|
299
361
|
* Options for metamorphing a Run into another Actor.
|
|
300
362
|
*/
|
|
301
|
-
export interface RunMetamorphOptions {
|
|
363
|
+
export interface RunMetamorphOptions extends TimeoutOptions {
|
|
302
364
|
/**
|
|
303
365
|
* Content type of the request body, which becomes the content type of the run's `INPUT` record.
|
|
304
366
|
* Without it, an input is serialized to JSON and sent as `application/json`. Pairing an object
|
|
@@ -325,10 +387,11 @@ export interface RunUpdateOptions {
|
|
|
325
387
|
/**
|
|
326
388
|
* Options for resurrecting a finished Run.
|
|
327
389
|
*/
|
|
328
|
-
export interface RunResurrectOptions {
|
|
390
|
+
export interface RunResurrectOptions extends TimeoutOptions {
|
|
329
391
|
build?: string;
|
|
330
392
|
memory?: number;
|
|
331
|
-
timeout
|
|
393
|
+
/** Timeout for the resurrected run in seconds. If not provided, the run keeps its original timeout. */
|
|
394
|
+
runTimeoutSecs?: number;
|
|
332
395
|
/**
|
|
333
396
|
* @since Added in 2.12.1
|
|
334
397
|
*/
|
|
@@ -346,18 +409,24 @@ export interface RunResurrectOptions {
|
|
|
346
409
|
* Options for charging events in a pay-per-event Actor run.
|
|
347
410
|
* @since Added in 2.11.0
|
|
348
411
|
*/
|
|
349
|
-
export interface RunChargeOptions {
|
|
412
|
+
export interface RunChargeOptions extends TimeoutOptions {
|
|
350
413
|
/** Name of the event to charge. Must be defined in the Actor's pricing info else the API will throw. */
|
|
351
414
|
eventName: string;
|
|
352
415
|
/** Defaults to 1 */
|
|
353
416
|
count?: number;
|
|
354
417
|
/** Defaults to runId-eventName-timestamp */
|
|
355
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;
|
|
356
425
|
}
|
|
357
426
|
/**
|
|
358
427
|
* Options for waiting for a Run to finish.
|
|
359
428
|
*/
|
|
360
|
-
export interface RunWaitForFinishOptions {
|
|
429
|
+
export interface RunWaitForFinishOptions extends TimeoutOptions {
|
|
361
430
|
/**
|
|
362
431
|
* Maximum time to wait for the run to finish, in seconds.
|
|
363
432
|
* If the limit is reached, the returned promise is resolved to a run object that will have
|
|
@@ -365,3 +434,24 @@ export interface RunWaitForFinishOptions {
|
|
|
365
434
|
*/
|
|
366
435
|
waitSecs?: number;
|
|
367
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
|
+
}
|