apify 3.4.0 → 3.4.1-beta.29
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/.turbo/turbo-build.log +26 -0
- package/.turbo/turbo-copy.log +4 -0
- package/LICENSE.md +183 -183
- package/README.md +1 -1
- package/dist/LICENSE.md +201 -0
- package/dist/README.md +98 -0
- package/{actor.d.ts → dist/actor.d.ts} +309 -309
- package/dist/actor.d.ts.map +1 -0
- package/{actor.js → dist/actor.js} +168 -127
- package/dist/actor.js.map +1 -0
- package/{charging.d.ts → dist/charging.d.ts} +18 -18
- package/dist/charging.d.ts.map +1 -0
- package/{charging.js → dist/charging.js} +26 -14
- package/dist/charging.js.map +1 -0
- package/{configuration.d.ts → dist/configuration.d.ts} +4 -4
- package/dist/configuration.d.ts.map +1 -0
- package/{configuration.js → dist/configuration.js} +14 -3
- package/dist/configuration.js.map +1 -0
- package/{index.d.ts → dist/index.d.ts} +6 -6
- package/dist/index.d.ts.map +1 -0
- package/{index.js → dist/index.js} +6 -6
- package/dist/index.js.map +1 -0
- package/dist/key_value_store.d.ts.map +1 -0
- package/{key_value_store.js → dist/key_value_store.js} +1 -1
- package/dist/key_value_store.js.map +1 -0
- package/dist/package.json +80 -0
- package/{platform_event_manager.d.ts → dist/platform_event_manager.d.ts} +4 -4
- package/{platform_event_manager.d.ts.map → dist/platform_event_manager.d.ts.map} +1 -1
- package/{platform_event_manager.js → dist/platform_event_manager.js} +13 -10
- package/dist/platform_event_manager.js.map +1 -0
- package/{proxy_configuration.d.ts → dist/proxy_configuration.d.ts} +10 -10
- package/dist/proxy_configuration.d.ts.map +1 -0
- package/{proxy_configuration.js → dist/proxy_configuration.js} +52 -40
- package/dist/proxy_configuration.js.map +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/{utils.js → dist/utils.js} +5 -6
- package/dist/utils.js.map +1 -0
- package/package.json +10 -10
- package/actor.d.ts.map +0 -1
- package/actor.js.map +0 -1
- package/charging.d.ts.map +0 -1
- package/charging.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/key_value_store.d.ts.map +0 -1
- package/key_value_store.js.map +0 -1
- package/platform_event_manager.js.map +0 -1
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils.d.ts.map +0 -1
- package/utils.js.map +0 -1
- /package/{index.mjs → dist/index.mjs} +0 -0
- /package/{key_value_store.d.ts → dist/key_value_store.d.ts} +0 -0
- /package/{utils.d.ts → dist/utils.d.ts} +0 -0
|
@@ -3,37 +3,257 @@ import { Dataset, RequestQueue } from '@crawlee/core';
|
|
|
3
3
|
import type { Awaitable, Dictionary, SetStatusMessageOptions, StorageClient } from '@crawlee/types';
|
|
4
4
|
import type { ActorCallOptions, ApifyClientOptions, RunAbortOptions, TaskCallOptions, Webhook, WebhookEventType } from 'apify-client';
|
|
5
5
|
import { ActorRun as ClientActorRun, ApifyClient } from 'apify-client';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { Configuration } from './configuration';
|
|
9
|
-
import { KeyValueStore } from './key_value_store';
|
|
10
|
-
import type { ProxyConfigurationOptions } from './proxy_configuration';
|
|
11
|
-
import { ProxyConfiguration } from './proxy_configuration';
|
|
6
|
+
import type { ChargeOptions, ChargeResult } from './charging.js';
|
|
7
|
+
import { ChargingManager } from './charging.js';
|
|
8
|
+
import { Configuration } from './configuration.js';
|
|
9
|
+
import { KeyValueStore } from './key_value_store.js';
|
|
10
|
+
import type { ProxyConfigurationOptions } from './proxy_configuration.js';
|
|
11
|
+
import { ProxyConfiguration } from './proxy_configuration.js';
|
|
12
|
+
export interface InitOptions {
|
|
13
|
+
storage?: StorageClient;
|
|
14
|
+
}
|
|
15
|
+
export interface ExitOptions {
|
|
16
|
+
/** Exit with given status message */
|
|
17
|
+
statusMessage?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Amount of time, in seconds, to wait for all event handlers to finish before exiting the process.
|
|
20
|
+
* @default 30
|
|
21
|
+
*/
|
|
22
|
+
timeoutSecs?: number;
|
|
23
|
+
/** Exit code, defaults to 0 */
|
|
24
|
+
exitCode?: number;
|
|
25
|
+
/** Call `process.exit()`? Defaults to true */
|
|
26
|
+
exit?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface MainOptions extends ExitOptions, InitOptions {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parsed representation of the Apify environment variables.
|
|
32
|
+
* This object is returned by the {@link Actor.getEnv} function.
|
|
33
|
+
*/
|
|
34
|
+
export interface ApifyEnv {
|
|
35
|
+
/**
|
|
36
|
+
* ID of the Actor (ACTOR_ID)
|
|
37
|
+
*/
|
|
38
|
+
actorId: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* ID of the Actor run (ACTOR_RUN_ID)
|
|
41
|
+
*/
|
|
42
|
+
actorRunId: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* ID of the Actor task (ACTOR_TASK_ID)
|
|
45
|
+
*/
|
|
46
|
+
actorTaskId: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* ID of the Actor build used in the run. (ACTOR_BUILD_ID)
|
|
49
|
+
*/
|
|
50
|
+
actorBuildId: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* ID of the user who started the Actor - note that it might be
|
|
53
|
+
* different than the owner of the Actor (APIFY_USER_ID)
|
|
54
|
+
*/
|
|
55
|
+
userId: string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Authentication token representing privileges given to the Actor run,
|
|
58
|
+
* it can be passed to various Apify APIs (APIFY_TOKEN)
|
|
59
|
+
*/
|
|
60
|
+
token: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Date when the Actor was started (ACTOR_STARTED_AT)
|
|
63
|
+
*/
|
|
64
|
+
startedAt: Date | null;
|
|
65
|
+
/**
|
|
66
|
+
* Date when the Actor will time out (ACTOR_TIMEOUT_AT)
|
|
67
|
+
*/
|
|
68
|
+
timeoutAt: Date | null;
|
|
69
|
+
/**
|
|
70
|
+
* ID of the key-value store where input and output data of this
|
|
71
|
+
* Actor is stored (ACTOR_DEFAULT_KEY_VALUE_STORE_ID)
|
|
72
|
+
*/
|
|
73
|
+
defaultKeyValueStoreId: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* ID of the dataset where input and output data of this
|
|
76
|
+
* Actor is stored (ACTOR_DEFAULT_DATASET_ID)
|
|
77
|
+
*/
|
|
78
|
+
defaultDatasetId: string | null;
|
|
79
|
+
/**
|
|
80
|
+
* Amount of memory allocated for the Actor,
|
|
81
|
+
* in megabytes (ACTOR_MEMORY_MBYTES)
|
|
82
|
+
*/
|
|
83
|
+
memoryMbytes: number | null;
|
|
84
|
+
/**
|
|
85
|
+
* If set to "1", the web browsers inside the Actor should run in headless
|
|
86
|
+
* mode because there is no windowing system available. (APIFY_HEADLESS)
|
|
87
|
+
*/
|
|
88
|
+
headless: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* Is set to "1" if the Actor is running on Apify servers.
|
|
91
|
+
* (APIFY_IS_AT_HOME)
|
|
92
|
+
*/
|
|
93
|
+
isAtHome: string | null;
|
|
94
|
+
/**
|
|
95
|
+
* The Apify Proxy password of the user who started the Actor. (APIFY_PROXY_PASSWORD)
|
|
96
|
+
*/
|
|
97
|
+
proxyPassword: string | null;
|
|
98
|
+
proxyHostname: string | null;
|
|
99
|
+
proxyPort: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* You can visit this page to troubleshoot your proxy connection. (APIFY_PROXY_STATUS_URL)
|
|
102
|
+
*/
|
|
103
|
+
proxyStatusUrl: string | null;
|
|
104
|
+
apiBaseUrl: string | null;
|
|
105
|
+
apiPublicBaseUrl: string | null;
|
|
106
|
+
chromeExecutablePath: string | null;
|
|
107
|
+
dedicatedCpus: string | null;
|
|
108
|
+
disableOutdatedWarning: 1 | null;
|
|
109
|
+
fact: string | null;
|
|
110
|
+
inputSecretsPrivateKeyFile: string | null;
|
|
111
|
+
inputSecretsPrivateKeyPassphrase: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* Defines the path to a local directory where KeyValueStore, Dataset, and RequestQueue
|
|
114
|
+
* store their data. Typically, it is set to ./storage. If omitted, you should define the
|
|
115
|
+
* APIFY_TOKEN environment variable instead. See more info on combination of this and
|
|
116
|
+
* APIFY_TOKEN [here](https://docs.apify.com/sdk/js/docs/guides/environment-variables#combinations-of-apify_local_storage_dir-and-apify_token)(CRAWLEE_STORAGE_DIR)
|
|
117
|
+
*/
|
|
118
|
+
localStorageDir: string | null;
|
|
119
|
+
/**
|
|
120
|
+
* Specifies the minimum log level, which can be one of the following values (in order of severity): DEBUG, INFO, WARNING and ERROR
|
|
121
|
+
* (APIFY_LOG_LEVEL)
|
|
122
|
+
*/
|
|
123
|
+
logLevel: string | null;
|
|
124
|
+
logFormat: string | null;
|
|
125
|
+
/**
|
|
126
|
+
* Origin for the Actor run, i.e. how it was started. See [here](https://docs.apify.com/sdk/python/reference/enum/MetaOrigin)
|
|
127
|
+
* for more details. (APIFY_META_ORIGIN)
|
|
128
|
+
*/
|
|
129
|
+
metaOrigin: string | null;
|
|
130
|
+
/**
|
|
131
|
+
* The key of the input record in the Actor’s default key-value store (ACTOR_INPUT_KEY)
|
|
132
|
+
*/
|
|
133
|
+
inputKey: string | null;
|
|
134
|
+
sdkLatestVersion: string | null;
|
|
135
|
+
systemInfoIntervalMillis: string | null;
|
|
136
|
+
workflowKey: string | null;
|
|
137
|
+
actorBuildNumber: string | null;
|
|
138
|
+
actorEventsWsUrl: string | null;
|
|
139
|
+
actorMaxPaidDatasetItems: number | null;
|
|
140
|
+
containerPort: number | null;
|
|
141
|
+
containerUrl: string | null;
|
|
142
|
+
defaultRequestQueueId: string | null;
|
|
143
|
+
}
|
|
144
|
+
export type UserFunc<T = unknown> = () => Awaitable<T>;
|
|
145
|
+
export interface CallOptions extends ActorCallOptions {
|
|
146
|
+
/**
|
|
147
|
+
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
148
|
+
*/
|
|
149
|
+
token?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface CallTaskOptions extends TaskCallOptions {
|
|
152
|
+
/**
|
|
153
|
+
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
154
|
+
*/
|
|
155
|
+
token?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface AbortOptions extends RunAbortOptions {
|
|
158
|
+
/**
|
|
159
|
+
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
160
|
+
*/
|
|
161
|
+
token?: string;
|
|
162
|
+
/** Exit with given status message */
|
|
163
|
+
statusMessage?: string;
|
|
164
|
+
}
|
|
165
|
+
export interface WebhookOptions {
|
|
166
|
+
/**
|
|
167
|
+
* Array of event types, which you can set for Actor run, see
|
|
168
|
+
* the [Actor run events](https://docs.apify.com/webhooks/events#actor-run) in the Apify doc.
|
|
169
|
+
*/
|
|
170
|
+
eventTypes: readonly WebhookEventType[];
|
|
171
|
+
/**
|
|
172
|
+
* URL which will be requested using HTTP POST request, when Actor run will reach the set event type.
|
|
173
|
+
*/
|
|
174
|
+
requestUrl: string;
|
|
175
|
+
/**
|
|
176
|
+
* Payload template is a JSON-like string that describes the structure of the webhook POST request payload.
|
|
177
|
+
* It uses JSON syntax, extended with a double curly braces syntax for injecting variables `{{variable}}`.
|
|
178
|
+
* Those variables are resolved at the time of the webhook's dispatch, and a list of available variables with their descriptions
|
|
179
|
+
* is available in the [Apify webhook documentation](https://docs.apify.com/webhooks).
|
|
180
|
+
* If `payloadTemplate` is omitted, the default payload template is used
|
|
181
|
+
* ([view docs](https://docs.apify.com/webhooks/actions#payload-template)).
|
|
182
|
+
*/
|
|
183
|
+
payloadTemplate?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Idempotency key enables you to ensure that a webhook will not be added multiple times in case of
|
|
186
|
+
* an Actor restart or other situation that would cause the `addWebhook()` function to be called again.
|
|
187
|
+
* We suggest using the Actor run ID as the idempotency key. You can get the run ID by calling
|
|
188
|
+
* {@link Actor.getEnv} function.
|
|
189
|
+
*/
|
|
190
|
+
idempotencyKey?: string;
|
|
191
|
+
}
|
|
192
|
+
export interface MetamorphOptions {
|
|
193
|
+
/**
|
|
194
|
+
* Content type for the `input`. If not specified,
|
|
195
|
+
* `input` is expected to be an object that will be stringified to JSON and content type set to
|
|
196
|
+
* `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
|
|
197
|
+
* `String` or `Buffer`.
|
|
198
|
+
*/
|
|
199
|
+
contentType?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Tag or number of the target Actor build to metamorph into (e.g. `beta` or `1.2.345`).
|
|
202
|
+
* If not provided, the run uses build tag or number from the default Actor run configuration (typically `latest`).
|
|
203
|
+
*/
|
|
204
|
+
build?: string;
|
|
205
|
+
/** @internal */
|
|
206
|
+
customAfterSleepMillis?: number;
|
|
207
|
+
}
|
|
208
|
+
export interface RebootOptions {
|
|
209
|
+
/** @internal */
|
|
210
|
+
customAfterSleepMillis?: number;
|
|
211
|
+
}
|
|
212
|
+
export interface OpenStorageOptions {
|
|
213
|
+
/**
|
|
214
|
+
* If set to `true` then the cloud storage is used even if the `CRAWLEE_STORAGE_DIR`
|
|
215
|
+
* environment variable is set. This way it is possible to combine local and cloud storage.
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
forceCloud?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export { ClientActorRun as ActorRun };
|
|
221
|
+
/**
|
|
222
|
+
* Exit codes for the Actor process.
|
|
223
|
+
* The error codes must be in the range 1-128, to avoid collision with signal exits
|
|
224
|
+
* and to ensure Docker will handle them correctly!
|
|
225
|
+
* @internal should be removed if we decide to remove `Actor.main()`
|
|
226
|
+
*/
|
|
227
|
+
export declare const EXIT_CODES: {
|
|
228
|
+
SUCCESS: number;
|
|
229
|
+
ERROR_USER_FUNCTION_THREW: number;
|
|
230
|
+
ERROR_UNKNOWN: number;
|
|
231
|
+
};
|
|
12
232
|
/**
|
|
13
233
|
* `Actor` class serves as an alternative approach to the static helpers exported from the package. It allows to pass configuration
|
|
14
234
|
* that will be used on the instance methods. Environment variables will have precedence over this configuration.
|
|
15
|
-
* See {@
|
|
235
|
+
* See {@link Configuration} for details about what can be configured and what are the default values.
|
|
16
236
|
*/
|
|
17
237
|
export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
18
238
|
/** @internal */
|
|
19
239
|
static _instance: Actor;
|
|
20
240
|
/**
|
|
21
|
-
* Configuration of this SDK instance (provided to its constructor). See {@
|
|
241
|
+
* Configuration of this SDK instance (provided to its constructor). See {@link Configuration} for details.
|
|
22
242
|
* @internal
|
|
23
243
|
*/
|
|
24
244
|
readonly config: Configuration;
|
|
25
245
|
/**
|
|
26
|
-
* Default {@
|
|
246
|
+
* Default {@link ApifyClient} instance.
|
|
27
247
|
* @internal
|
|
28
248
|
*/
|
|
29
249
|
readonly apifyClient: ApifyClient;
|
|
30
250
|
/**
|
|
31
|
-
* Default {@
|
|
251
|
+
* Default {@link EventManager} instance.
|
|
32
252
|
* @internal
|
|
33
253
|
*/
|
|
34
254
|
readonly eventManager: EventManager;
|
|
35
255
|
/**
|
|
36
|
-
* Whether the Actor instance was initialized. This is set by calling {@
|
|
256
|
+
* Whether the Actor instance was initialized. This is set by calling {@link Actor.init}.
|
|
37
257
|
*/
|
|
38
258
|
initialized: boolean;
|
|
39
259
|
/**
|
|
@@ -64,7 +284,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
64
284
|
* - When running on the Apify platform (i.e. `APIFY_IS_AT_HOME` environment variable is set),
|
|
65
285
|
* it sets up a connection to listen for platform events.
|
|
66
286
|
* For example, to get a notification about an imminent migration to another server.
|
|
67
|
-
* See {@
|
|
287
|
+
* See {@link Actor.events} for details.
|
|
68
288
|
* - It invokes the user function passed as the `userFunc` parameter.
|
|
69
289
|
* - If the user function returned a promise, waits for it to resolve.
|
|
70
290
|
* - If the user function throws an exception or some other error is encountered,
|
|
@@ -133,9 +353,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
133
353
|
/**
|
|
134
354
|
* Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
135
355
|
*
|
|
136
|
-
* The result of the function is an {@
|
|
356
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
137
357
|
*
|
|
138
|
-
* If you want to run an Actor task rather than an Actor, please use the {@
|
|
358
|
+
* If you want to run an Actor task rather than an Actor, please use the {@link Actor.callTask} function instead.
|
|
139
359
|
*
|
|
140
360
|
* For more information about Actors, read the [documentation](https://docs.apify.com/actor).
|
|
141
361
|
*
|
|
@@ -159,7 +379,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
159
379
|
* Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
|
|
160
380
|
* unlike `Actor.call`, this method just starts the run without waiting for finish.
|
|
161
381
|
*
|
|
162
|
-
* The result of the function is an {@
|
|
382
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
163
383
|
*
|
|
164
384
|
* For more information about Actors, read the
|
|
165
385
|
* [documentation](https://docs.apify.com/actor).
|
|
@@ -183,7 +403,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
183
403
|
/**
|
|
184
404
|
* Aborts given Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
185
405
|
*
|
|
186
|
-
* The result of the function is an {@
|
|
406
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
187
407
|
*
|
|
188
408
|
* For more information about Actors, read the
|
|
189
409
|
* [documentation](https://docs.apify.com/actor).
|
|
@@ -199,11 +419,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
199
419
|
/**
|
|
200
420
|
* Runs an actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
201
421
|
*
|
|
202
|
-
* The result of the function is an {@
|
|
422
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
203
423
|
*
|
|
204
424
|
* Note that an Actor task is a saved input configuration and options for an Actor.
|
|
205
425
|
* If you want to run an Actor directly rather than an Actor task, please use the
|
|
206
|
-
* {@
|
|
426
|
+
* {@link Actor.call} function instead.
|
|
207
427
|
*
|
|
208
428
|
* For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
|
|
209
429
|
*
|
|
@@ -268,9 +488,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
268
488
|
*/
|
|
269
489
|
setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
|
|
270
490
|
/**
|
|
271
|
-
* Stores an object or an array of objects to the default {@
|
|
491
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
272
492
|
*
|
|
273
|
-
* This is just a convenient shortcut for {@
|
|
493
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
274
494
|
* For example, calling the following code:
|
|
275
495
|
* ```js
|
|
276
496
|
* await Actor.pushData({ myValue: 123 });
|
|
@@ -282,7 +502,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
282
502
|
* await dataset.pushData({ myValue: 123 });
|
|
283
503
|
* ```
|
|
284
504
|
*
|
|
285
|
-
* For more information, see {@
|
|
505
|
+
* For more information, see {@link Actor.openDataset} and {@link Dataset.pushData}
|
|
286
506
|
*
|
|
287
507
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
288
508
|
* otherwise the Actor process might finish before the data are stored!
|
|
@@ -293,9 +513,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
293
513
|
*/
|
|
294
514
|
pushData(item: Data | Data[]): Promise<void>;
|
|
295
515
|
/**
|
|
296
|
-
* Stores an object or an array of objects to the default {@
|
|
516
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
297
517
|
*
|
|
298
|
-
* This is just a convenient shortcut for {@
|
|
518
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
299
519
|
* For example, calling the following code:
|
|
300
520
|
* ```js
|
|
301
521
|
* await Actor.pushData({ myValue: 123 });
|
|
@@ -307,7 +527,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
307
527
|
* await dataset.pushData({ myValue: 123 });
|
|
308
528
|
* ```
|
|
309
529
|
*
|
|
310
|
-
* For more information, see {@
|
|
530
|
+
* For more information, see {@link Actor.openDataset} and {@link Dataset.pushData}
|
|
311
531
|
*
|
|
312
532
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
313
533
|
* otherwise the Actor process might finish before the data are stored!
|
|
@@ -319,13 +539,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
319
539
|
*/
|
|
320
540
|
pushData(item: Data | Data[], eventName: string): Promise<ChargeResult>;
|
|
321
541
|
/**
|
|
322
|
-
* Opens a dataset and returns a promise resolving to an instance of the {@
|
|
542
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
323
543
|
*
|
|
324
544
|
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
325
545
|
* such as online store products or real estate offers.
|
|
326
546
|
* The actual data is stored either on the local filesystem or in the cloud.
|
|
327
547
|
*
|
|
328
|
-
* For more details and code examples, see the {@
|
|
548
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
329
549
|
*
|
|
330
550
|
* @param [datasetIdOrName]
|
|
331
551
|
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
@@ -335,9 +555,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
335
555
|
*/
|
|
336
556
|
openDataset(datasetIdOrName?: string | null, options?: OpenStorageOptions): Promise<Dataset<Data>>;
|
|
337
557
|
/**
|
|
338
|
-
* Gets a value from the default {@
|
|
558
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
339
559
|
*
|
|
340
|
-
* This is just a convenient shortcut for {@
|
|
560
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
341
561
|
* For example, calling the following code:
|
|
342
562
|
* ```js
|
|
343
563
|
* const value = await Actor.getValue('my-key');
|
|
@@ -349,10 +569,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
349
569
|
* const value = await store.getValue('my-key');
|
|
350
570
|
* ```
|
|
351
571
|
*
|
|
352
|
-
* To store the value to the default key-value store, you can use the {@
|
|
572
|
+
* To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
|
|
353
573
|
*
|
|
354
|
-
* For more information, see {@
|
|
355
|
-
* and {@
|
|
574
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
575
|
+
* and {@link KeyValueStore.getValue}.
|
|
356
576
|
*
|
|
357
577
|
* @param key Unique record key.
|
|
358
578
|
* @returns
|
|
@@ -364,9 +584,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
364
584
|
*/
|
|
365
585
|
getValue<T = unknown>(key: string): Promise<T | null>;
|
|
366
586
|
/**
|
|
367
|
-
* Stores or deletes a value in the default {@
|
|
587
|
+
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
|
|
368
588
|
*
|
|
369
|
-
* This is just a convenient shortcut for {@
|
|
589
|
+
* This is just a convenient shortcut for {@link KeyValueStore.setValue}.
|
|
370
590
|
* For example, calling the following code:
|
|
371
591
|
* ```js
|
|
372
592
|
* await Actor.setValue('OUTPUT', { foo: "bar" });
|
|
@@ -378,10 +598,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
378
598
|
* await store.setValue('OUTPUT', { foo: "bar" });
|
|
379
599
|
* ```
|
|
380
600
|
*
|
|
381
|
-
* To get a value from the default key-value store, you can use the {@
|
|
601
|
+
* To get a value from the default key-value store, you can use the {@link Actor.getValue} function.
|
|
382
602
|
*
|
|
383
|
-
* For more information, see {@
|
|
384
|
-
* and {@
|
|
603
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
604
|
+
* and {@link KeyValueStore.getValue}.
|
|
385
605
|
*
|
|
386
606
|
* @param key
|
|
387
607
|
* Unique record key.
|
|
@@ -396,7 +616,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
396
616
|
*/
|
|
397
617
|
setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
|
|
398
618
|
/**
|
|
399
|
-
* Gets the Actor input value from the default {@
|
|
619
|
+
* Gets the Actor input value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
400
620
|
*
|
|
401
621
|
* This is just a convenient shortcut for [`keyValueStore.getValue('INPUT')`](core/class/KeyValueStore#getValue).
|
|
402
622
|
* For example, calling the following code:
|
|
@@ -414,8 +634,8 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
414
634
|
* If you need to use the input multiple times in your Actor,
|
|
415
635
|
* it is far more efficient to read it once and store it locally.
|
|
416
636
|
*
|
|
417
|
-
* For more information, see {@
|
|
418
|
-
* and {@
|
|
637
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
638
|
+
* and {@link KeyValueStore.getValue}.
|
|
419
639
|
*
|
|
420
640
|
* @returns
|
|
421
641
|
* Returns a promise that resolves to an object, string
|
|
@@ -426,18 +646,18 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
426
646
|
*/
|
|
427
647
|
getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
|
|
428
648
|
/**
|
|
429
|
-
* Gets the Actor input value just like the {@
|
|
649
|
+
* Gets the Actor input value just like the {@link Actor.getInput} method,
|
|
430
650
|
* but throws if it is not found.
|
|
431
651
|
*/
|
|
432
652
|
getInputOrThrow<T = Dictionary | string | Buffer>(): Promise<T>;
|
|
433
653
|
/**
|
|
434
|
-
* Opens a key-value store and returns a promise resolving to an instance of the {@
|
|
654
|
+
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
435
655
|
*
|
|
436
656
|
* Key-value stores are used to store records or files, along with their MIME content type.
|
|
437
657
|
* The records are stored and retrieved using a unique key.
|
|
438
658
|
* The actual data is stored either on a local filesystem or in the Apify cloud.
|
|
439
659
|
*
|
|
440
|
-
* For more details and code examples, see the {@
|
|
660
|
+
* For more details and code examples, see the {@link KeyValueStore} class.
|
|
441
661
|
*
|
|
442
662
|
* @param [storeIdOrName]
|
|
443
663
|
* ID or name of the key-value store to be opened. If `null` or `undefined`,
|
|
@@ -448,14 +668,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
448
668
|
openKeyValueStore(storeIdOrName?: string | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
|
|
449
669
|
/**
|
|
450
670
|
* Opens a request queue and returns a promise resolving to an instance
|
|
451
|
-
* of the {@
|
|
671
|
+
* of the {@link RequestQueue} class.
|
|
452
672
|
*
|
|
453
|
-
* {@
|
|
673
|
+
* {@link RequestQueue} represents a queue of URLs to crawl, which is stored either on local filesystem or in the cloud.
|
|
454
674
|
* The queue is used for deep crawling of websites, where you start with several URLs and then
|
|
455
675
|
* recursively follow links to other pages. The data structure supports both breadth-first
|
|
456
676
|
* and depth-first crawling orders.
|
|
457
677
|
*
|
|
458
|
-
* For more details and code examples, see the {@
|
|
678
|
+
* For more details and code examples, see the {@link RequestQueue} class.
|
|
459
679
|
*
|
|
460
680
|
* @param [queueIdOrName]
|
|
461
681
|
* ID or name of the request queue to be opened. If `null` or `undefined`,
|
|
@@ -466,13 +686,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
466
686
|
openRequestQueue(queueIdOrName?: string | null, options?: OpenStorageOptions): Promise<RequestQueue>;
|
|
467
687
|
/**
|
|
468
688
|
* Creates a proxy configuration and returns a promise resolving to an instance
|
|
469
|
-
* of the {@
|
|
689
|
+
* of the {@link ProxyConfiguration} class that is already initialized.
|
|
470
690
|
*
|
|
471
691
|
* Configures connection to a proxy server with the provided options. Proxy servers are used to prevent target websites from blocking
|
|
472
692
|
* your crawlers based on IP address rate limits or blacklists. Setting proxy configuration in your crawlers automatically configures
|
|
473
693
|
* them to use the selected proxies for all connections.
|
|
474
694
|
*
|
|
475
|
-
* For more details and code examples, see the {@
|
|
695
|
+
* For more details and code examples, see the {@link ProxyConfiguration} class.
|
|
476
696
|
*
|
|
477
697
|
* ```js
|
|
478
698
|
*
|
|
@@ -516,11 +736,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
516
736
|
*/
|
|
517
737
|
getChargingManager(): ChargingManager;
|
|
518
738
|
/**
|
|
519
|
-
* Modifies Actor env vars so parsing respects the structure of {@
|
|
739
|
+
* Modifies Actor env vars so parsing respects the structure of {@link ApifyEnv} interface.
|
|
520
740
|
*/
|
|
521
741
|
private getModifiedActorEnvVars;
|
|
522
742
|
/**
|
|
523
|
-
* Returns a new {@
|
|
743
|
+
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
524
744
|
*
|
|
525
745
|
* For the list of the Apify environment variables, see
|
|
526
746
|
* [Actor documentation](https://docs.apify.com/actor/run#environment-variables).
|
|
@@ -579,7 +799,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
579
799
|
* - When running on the Apify platform (i.e. `APIFY_IS_AT_HOME` environment variable is set),
|
|
580
800
|
* it sets up a connection to listen for platform events.
|
|
581
801
|
* For example, to get a notification about an imminent migration to another server.
|
|
582
|
-
* See {@
|
|
802
|
+
* See {@link Actor.events} for details.
|
|
583
803
|
* - It invokes the user function passed as the `userFunc` parameter.
|
|
584
804
|
* - If the user function returned a promise, waits for it to resolve.
|
|
585
805
|
* - If the user function throws an exception or some other error is encountered,
|
|
@@ -632,7 +852,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
632
852
|
* from 25% to 100% on the platform.
|
|
633
853
|
*
|
|
634
854
|
* Calling `Actor.exit()` is required if you use the `Actor.init()` method, since it opens websocket connection
|
|
635
|
-
* (see {@
|
|
855
|
+
* (see {@link Actor.events} for details), which needs to be terminated for the code to finish.
|
|
636
856
|
*
|
|
637
857
|
* ```js
|
|
638
858
|
* import { gotScraping } from 'got-scraping';
|
|
@@ -665,9 +885,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
665
885
|
/**
|
|
666
886
|
* Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
667
887
|
*
|
|
668
|
-
* The result of the function is an {@
|
|
888
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
669
889
|
*
|
|
670
|
-
* If you want to run an Actor task rather than an Actor, please use the {@
|
|
890
|
+
* If you want to run an Actor task rather than an Actor, please use the {@link Actor.callTask} function instead.
|
|
671
891
|
*
|
|
672
892
|
* For more information about Actors, read the [documentation](https://docs.apify.com/actor).
|
|
673
893
|
*
|
|
@@ -689,11 +909,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
689
909
|
/**
|
|
690
910
|
* Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
691
911
|
*
|
|
692
|
-
* The result of the function is an {@
|
|
912
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
693
913
|
*
|
|
694
914
|
* Note that an Actor task is a saved input configuration and options for an Actor.
|
|
695
915
|
* If you want to run an Actor directly rather than an Actor task, please use the
|
|
696
|
-
* {@
|
|
916
|
+
* {@link Actor.call} function instead.
|
|
697
917
|
*
|
|
698
918
|
* For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
|
|
699
919
|
*
|
|
@@ -716,7 +936,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
716
936
|
* Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
|
|
717
937
|
* unlike `Actor.call`, this method just starts the run without waiting for finish.
|
|
718
938
|
*
|
|
719
|
-
* The result of the function is an {@
|
|
939
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
720
940
|
*
|
|
721
941
|
* For more information about Actors, read the
|
|
722
942
|
* [documentation](https://docs.apify.com/actor).
|
|
@@ -739,7 +959,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
739
959
|
/**
|
|
740
960
|
* Aborts given Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
741
961
|
*
|
|
742
|
-
* The result of the function is an {@
|
|
962
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
743
963
|
*
|
|
744
964
|
* For more information about Actors, read the
|
|
745
965
|
* [documentation](https://docs.apify.com/actor).
|
|
@@ -795,9 +1015,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
795
1015
|
*/
|
|
796
1016
|
static setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
|
|
797
1017
|
/**
|
|
798
|
-
* Stores an object or an array of objects to the default {@
|
|
1018
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
799
1019
|
*
|
|
800
|
-
* This is just a convenient shortcut for {@
|
|
1020
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
801
1021
|
* For example, calling the following code:
|
|
802
1022
|
* ```js
|
|
803
1023
|
* await Actor.pushData({ myValue: 123 });
|
|
@@ -809,7 +1029,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
809
1029
|
* await dataset.pushData({ myValue: 123 });
|
|
810
1030
|
* ```
|
|
811
1031
|
*
|
|
812
|
-
* For more information, see {@
|
|
1032
|
+
* For more information, see {@link Actor.openDataset} and {@link Dataset.pushData}
|
|
813
1033
|
*
|
|
814
1034
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
815
1035
|
* otherwise the Actor process might finish before the data are stored!
|
|
@@ -819,9 +1039,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
819
1039
|
*/
|
|
820
1040
|
static pushData<Data extends Dictionary = Dictionary>(item: Data | Data[]): Promise<void>;
|
|
821
1041
|
/**
|
|
822
|
-
* Stores an object or an array of objects to the default {@
|
|
1042
|
+
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
823
1043
|
*
|
|
824
|
-
* This is just a convenient shortcut for {@
|
|
1044
|
+
* This is just a convenient shortcut for {@link Dataset.pushData}.
|
|
825
1045
|
* For example, calling the following code:
|
|
826
1046
|
* ```js
|
|
827
1047
|
* await Actor.pushData({ myValue: 123 });
|
|
@@ -833,7 +1053,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
833
1053
|
* await dataset.pushData({ myValue: 123 });
|
|
834
1054
|
* ```
|
|
835
1055
|
*
|
|
836
|
-
* For more information, see {@
|
|
1056
|
+
* For more information, see {@link Actor.openDataset} and {@link Dataset.pushData}
|
|
837
1057
|
*
|
|
838
1058
|
* **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
|
|
839
1059
|
* otherwise the Actor process might finish before the data are stored!
|
|
@@ -844,13 +1064,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
844
1064
|
*/
|
|
845
1065
|
static pushData<Data extends Dictionary = Dictionary>(item: Data | Data[], eventName: string): Promise<ChargeResult>;
|
|
846
1066
|
/**
|
|
847
|
-
* Opens a dataset and returns a promise resolving to an instance of the {@
|
|
1067
|
+
* Opens a dataset and returns a promise resolving to an instance of the {@link Dataset} class.
|
|
848
1068
|
*
|
|
849
1069
|
* Datasets are used to store structured data where each object stored has the same attributes,
|
|
850
1070
|
* such as online store products or real estate offers.
|
|
851
1071
|
* The actual data is stored either on the local filesystem or in the cloud.
|
|
852
1072
|
*
|
|
853
|
-
* For more details and code examples, see the {@
|
|
1073
|
+
* For more details and code examples, see the {@link Dataset} class.
|
|
854
1074
|
*
|
|
855
1075
|
* @param [datasetIdOrName]
|
|
856
1076
|
* ID or name of the dataset to be opened. If `null` or `undefined`,
|
|
@@ -859,9 +1079,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
859
1079
|
*/
|
|
860
1080
|
static openDataset<Data extends Dictionary = Dictionary>(datasetIdOrName?: string | null, options?: OpenStorageOptions): Promise<Dataset<Data>>;
|
|
861
1081
|
/**
|
|
862
|
-
* Gets a value from the default {@
|
|
1082
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
863
1083
|
*
|
|
864
|
-
* This is just a convenient shortcut for {@
|
|
1084
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
865
1085
|
* For example, calling the following code:
|
|
866
1086
|
* ```js
|
|
867
1087
|
* const value = await Actor.getValue('my-key');
|
|
@@ -873,10 +1093,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
873
1093
|
* const value = await store.getValue('my-key');
|
|
874
1094
|
* ```
|
|
875
1095
|
*
|
|
876
|
-
* To store the value to the default key-value store, you can use the {@
|
|
1096
|
+
* To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
|
|
877
1097
|
*
|
|
878
|
-
* For more information, see {@
|
|
879
|
-
* and {@
|
|
1098
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
1099
|
+
* and {@link KeyValueStore.getValue}.
|
|
880
1100
|
*
|
|
881
1101
|
* @param key Unique record key.
|
|
882
1102
|
* @returns
|
|
@@ -887,9 +1107,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
887
1107
|
*/
|
|
888
1108
|
static getValue<T = unknown>(key: string): Promise<T | null>;
|
|
889
1109
|
/**
|
|
890
|
-
* Stores or deletes a value in the default {@
|
|
1110
|
+
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
|
|
891
1111
|
*
|
|
892
|
-
* This is just a convenient shortcut for {@
|
|
1112
|
+
* This is just a convenient shortcut for {@link KeyValueStore.setValue}.
|
|
893
1113
|
* For example, calling the following code:
|
|
894
1114
|
* ```js
|
|
895
1115
|
* await Actor.setValue('OUTPUT', { foo: "bar" });
|
|
@@ -901,10 +1121,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
901
1121
|
* await store.setValue('OUTPUT', { foo: "bar" });
|
|
902
1122
|
* ```
|
|
903
1123
|
*
|
|
904
|
-
* To get a value from the default key-value store, you can use the {@
|
|
1124
|
+
* To get a value from the default key-value store, you can use the {@link Actor.getValue} function.
|
|
905
1125
|
*
|
|
906
|
-
* For more information, see {@
|
|
907
|
-
* and {@
|
|
1126
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
1127
|
+
* and {@link KeyValueStore.getValue}.
|
|
908
1128
|
*
|
|
909
1129
|
* @param key
|
|
910
1130
|
* Unique record key.
|
|
@@ -918,9 +1138,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
918
1138
|
*/
|
|
919
1139
|
static setValue<T>(key: string, value: T | null, options?: RecordOptions): Promise<void>;
|
|
920
1140
|
/**
|
|
921
|
-
* Gets the Actor input value from the default {@
|
|
1141
|
+
* Gets the Actor input value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
922
1142
|
*
|
|
923
|
-
* This is just a convenient shortcut for {@
|
|
1143
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue | `keyValueStore.getValue('INPUT')`}.
|
|
924
1144
|
* For example, calling the following code:
|
|
925
1145
|
* ```js
|
|
926
1146
|
* const input = await Actor.getInput();
|
|
@@ -936,7 +1156,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
936
1156
|
* If you need to use the input multiple times in your Actor,
|
|
937
1157
|
* it is far more efficient to read it once and store it locally.
|
|
938
1158
|
*
|
|
939
|
-
* For more information, see {@
|
|
1159
|
+
* For more information, see {@link Actor.openKeyValueStore} and {@link KeyValueStore.getValue}.
|
|
940
1160
|
*
|
|
941
1161
|
* @returns
|
|
942
1162
|
* Returns a promise that resolves to an object, string
|
|
@@ -946,18 +1166,18 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
946
1166
|
*/
|
|
947
1167
|
static getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
|
|
948
1168
|
/**
|
|
949
|
-
* Gets the Actor input value just like the {@
|
|
1169
|
+
* Gets the Actor input value just like the {@link Actor.getInput} method,
|
|
950
1170
|
* but throws if it is not found.
|
|
951
1171
|
*/
|
|
952
1172
|
static getInputOrThrow<T = Dictionary | string | Buffer>(): Promise<T>;
|
|
953
1173
|
/**
|
|
954
|
-
* Opens a key-value store and returns a promise resolving to an instance of the {@
|
|
1174
|
+
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
955
1175
|
*
|
|
956
1176
|
* Key-value stores are used to store records or files, along with their MIME content type.
|
|
957
1177
|
* The records are stored and retrieved using a unique key.
|
|
958
1178
|
* The actual data is stored either on a local filesystem or in the Apify cloud.
|
|
959
1179
|
*
|
|
960
|
-
* For more details and code examples, see the {@
|
|
1180
|
+
* For more details and code examples, see the {@link KeyValueStore} class.
|
|
961
1181
|
*
|
|
962
1182
|
* @param [storeIdOrName]
|
|
963
1183
|
* ID or name of the key-value store to be opened. If `null` or `undefined`,
|
|
@@ -967,14 +1187,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
967
1187
|
static openKeyValueStore(storeIdOrName?: string | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
|
|
968
1188
|
/**
|
|
969
1189
|
* Opens a request queue and returns a promise resolving to an instance
|
|
970
|
-
* of the {@
|
|
1190
|
+
* of the {@link RequestQueue} class.
|
|
971
1191
|
*
|
|
972
|
-
* {@
|
|
1192
|
+
* {@link RequestQueue} represents a queue of URLs to crawl, which is stored either on local filesystem or in the cloud.
|
|
973
1193
|
* The queue is used for deep crawling of websites, where you start with several URLs and then
|
|
974
1194
|
* recursively follow links to other pages. The data structure supports both breadth-first
|
|
975
1195
|
* and depth-first crawling orders.
|
|
976
1196
|
*
|
|
977
|
-
* For more details and code examples, see the {@
|
|
1197
|
+
* For more details and code examples, see the {@link RequestQueue} class.
|
|
978
1198
|
*
|
|
979
1199
|
* @param [queueIdOrName]
|
|
980
1200
|
* ID or name of the request queue to be opened. If `null` or `undefined`,
|
|
@@ -984,13 +1204,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
984
1204
|
static openRequestQueue(queueIdOrName?: string | null, options?: OpenStorageOptions): Promise<RequestQueue>;
|
|
985
1205
|
/**
|
|
986
1206
|
* Creates a proxy configuration and returns a promise resolving to an instance
|
|
987
|
-
* of the {@
|
|
1207
|
+
* of the {@link ProxyConfiguration} class that is already initialized.
|
|
988
1208
|
*
|
|
989
1209
|
* Configures connection to a proxy server with the provided options. Proxy servers are used to prevent target websites from blocking
|
|
990
1210
|
* your crawlers based on IP address rate limits or blacklists. Setting proxy configuration in your crawlers automatically configures
|
|
991
1211
|
* them to use the selected proxies for all connections.
|
|
992
1212
|
*
|
|
993
|
-
* For more details and code examples, see the {@
|
|
1213
|
+
* For more details and code examples, see the {@link ProxyConfiguration} class.
|
|
994
1214
|
*
|
|
995
1215
|
* ```js
|
|
996
1216
|
*
|
|
@@ -1031,7 +1251,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1031
1251
|
*/
|
|
1032
1252
|
static getChargingManager(): ChargingManager;
|
|
1033
1253
|
/**
|
|
1034
|
-
* Returns a new {@
|
|
1254
|
+
* Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
|
|
1035
1255
|
*
|
|
1036
1256
|
* For the list of the Apify environment variables, see
|
|
1037
1257
|
* [Actor documentation](https://docs.apify.com/actor/run#environment-variables).
|
|
@@ -1050,233 +1270,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1050
1270
|
* Returns `true` when code is running on Apify platform and `false` otherwise (for example locally).
|
|
1051
1271
|
*/
|
|
1052
1272
|
static isAtHome(): boolean;
|
|
1053
|
-
/** Default {@
|
|
1273
|
+
/** Default {@link ApifyClient} instance. */
|
|
1054
1274
|
static get apifyClient(): ApifyClient;
|
|
1055
|
-
/** Default {@
|
|
1275
|
+
/** Default {@link Configuration} instance. */
|
|
1056
1276
|
static get config(): Configuration;
|
|
1057
1277
|
/** @internal */
|
|
1058
1278
|
static getDefaultInstance(): Actor;
|
|
1059
1279
|
private _openStorage;
|
|
1060
1280
|
private _ensureActorInit;
|
|
1061
1281
|
}
|
|
1062
|
-
export interface InitOptions {
|
|
1063
|
-
storage?: StorageClient;
|
|
1064
|
-
}
|
|
1065
|
-
export interface MainOptions extends ExitOptions, InitOptions {
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* Parsed representation of the Apify environment variables.
|
|
1069
|
-
* This object is returned by the {@apilink Actor.getEnv} function.
|
|
1070
|
-
*/
|
|
1071
|
-
export interface ApifyEnv {
|
|
1072
|
-
/**
|
|
1073
|
-
* ID of the Actor (ACTOR_ID)
|
|
1074
|
-
*/
|
|
1075
|
-
actorId: string | null;
|
|
1076
|
-
/**
|
|
1077
|
-
* ID of the Actor run (ACTOR_RUN_ID)
|
|
1078
|
-
*/
|
|
1079
|
-
actorRunId: string | null;
|
|
1080
|
-
/**
|
|
1081
|
-
* ID of the Actor task (ACTOR_TASK_ID)
|
|
1082
|
-
*/
|
|
1083
|
-
actorTaskId: string | null;
|
|
1084
|
-
/**
|
|
1085
|
-
* ID of the Actor build used in the run. (ACTOR_BUILD_ID)
|
|
1086
|
-
*/
|
|
1087
|
-
actorBuildId: string | null;
|
|
1088
|
-
/**
|
|
1089
|
-
* ID of the user who started the Actor - note that it might be
|
|
1090
|
-
* different than the owner of the Actor (APIFY_USER_ID)
|
|
1091
|
-
*/
|
|
1092
|
-
userId: string | null;
|
|
1093
|
-
/**
|
|
1094
|
-
* Authentication token representing privileges given to the Actor run,
|
|
1095
|
-
* it can be passed to various Apify APIs (APIFY_TOKEN)
|
|
1096
|
-
*/
|
|
1097
|
-
token: string | null;
|
|
1098
|
-
/**
|
|
1099
|
-
* Date when the Actor was started (ACTOR_STARTED_AT)
|
|
1100
|
-
*/
|
|
1101
|
-
startedAt: Date | null;
|
|
1102
|
-
/**
|
|
1103
|
-
* Date when the Actor will time out (ACTOR_TIMEOUT_AT)
|
|
1104
|
-
*/
|
|
1105
|
-
timeoutAt: Date | null;
|
|
1106
|
-
/**
|
|
1107
|
-
* ID of the key-value store where input and output data of this
|
|
1108
|
-
* Actor is stored (ACTOR_DEFAULT_KEY_VALUE_STORE_ID)
|
|
1109
|
-
*/
|
|
1110
|
-
defaultKeyValueStoreId: string | null;
|
|
1111
|
-
/**
|
|
1112
|
-
* ID of the dataset where input and output data of this
|
|
1113
|
-
* Actor is stored (ACTOR_DEFAULT_DATASET_ID)
|
|
1114
|
-
*/
|
|
1115
|
-
defaultDatasetId: string | null;
|
|
1116
|
-
/**
|
|
1117
|
-
* Amount of memory allocated for the Actor,
|
|
1118
|
-
* in megabytes (ACTOR_MEMORY_MBYTES)
|
|
1119
|
-
*/
|
|
1120
|
-
memoryMbytes: number | null;
|
|
1121
|
-
/**
|
|
1122
|
-
* If set to "1", the web browsers inside the Actor should run in headless
|
|
1123
|
-
* mode because there is no windowing system available. (APIFY_HEADLESS)
|
|
1124
|
-
*/
|
|
1125
|
-
headless: string | null;
|
|
1126
|
-
/**
|
|
1127
|
-
* Is set to "1" if the Actor is running on Apify servers.
|
|
1128
|
-
* (APIFY_IS_AT_HOME)
|
|
1129
|
-
*/
|
|
1130
|
-
isAtHome: string | null;
|
|
1131
|
-
/**
|
|
1132
|
-
* The Apify Proxy password of the user who started the Actor. (APIFY_PROXY_PASSWORD)
|
|
1133
|
-
*/
|
|
1134
|
-
proxyPassword: string | null;
|
|
1135
|
-
proxyHostname: string | null;
|
|
1136
|
-
proxyPort: string | null;
|
|
1137
|
-
/**
|
|
1138
|
-
* You can visit this page to troubleshoot your proxy connection. (APIFY_PROXY_STATUS_URL)
|
|
1139
|
-
*/
|
|
1140
|
-
proxyStatusUrl: string | null;
|
|
1141
|
-
apiBaseUrl: string | null;
|
|
1142
|
-
apiPublicBaseUrl: string | null;
|
|
1143
|
-
chromeExecutablePath: string | null;
|
|
1144
|
-
dedicatedCpus: string | null;
|
|
1145
|
-
disableOutdatedWarning: 1 | null;
|
|
1146
|
-
fact: string | null;
|
|
1147
|
-
inputSecretsPrivateKeyFile: string | null;
|
|
1148
|
-
inputSecretsPrivateKeyPassphrase: string | null;
|
|
1149
|
-
/**
|
|
1150
|
-
* Defines the path to a local directory where KeyValueStore, Dataset, and RequestQueue
|
|
1151
|
-
* store their data. Typically, it is set to ./storage. If omitted, you should define the
|
|
1152
|
-
* APIFY_TOKEN environment variable instead. See more info on combination of this and
|
|
1153
|
-
* APIFY_TOKEN [here](https://docs.apify.com/sdk/js/docs/guides/environment-variables#combinations-of-apify_local_storage_dir-and-apify_token)(CRAWLEE_STORAGE_DIR)
|
|
1154
|
-
*/
|
|
1155
|
-
localStorageDir: string | null;
|
|
1156
|
-
/**
|
|
1157
|
-
* Specifies the minimum log level, which can be one of the following values (in order of severity): DEBUG, INFO, WARNING and ERROR
|
|
1158
|
-
* (APIFY_LOG_LEVEL)
|
|
1159
|
-
*/
|
|
1160
|
-
logLevel: string | null;
|
|
1161
|
-
logFormat: string | null;
|
|
1162
|
-
/**
|
|
1163
|
-
* Origin for the Actor run, i.e. how it was started. See [here](https://docs.apify.com/sdk/python/reference/enum/MetaOrigin)
|
|
1164
|
-
* for more details. (APIFY_META_ORIGIN)
|
|
1165
|
-
*/
|
|
1166
|
-
metaOrigin: string | null;
|
|
1167
|
-
/**
|
|
1168
|
-
* The key of the input record in the Actor’s default key-value store (ACTOR_INPUT_KEY)
|
|
1169
|
-
*/
|
|
1170
|
-
inputKey: string | null;
|
|
1171
|
-
sdkLatestVersion: string | null;
|
|
1172
|
-
systemInfoIntervalMillis: string | null;
|
|
1173
|
-
workflowKey: string | null;
|
|
1174
|
-
actorBuildNumber: string | null;
|
|
1175
|
-
actorEventsWsUrl: string | null;
|
|
1176
|
-
actorMaxPaidDatasetItems: number | null;
|
|
1177
|
-
containerPort: number | null;
|
|
1178
|
-
containerUrl: string | null;
|
|
1179
|
-
defaultRequestQueueId: string | null;
|
|
1180
|
-
}
|
|
1181
|
-
export type UserFunc<T = unknown> = () => Awaitable<T>;
|
|
1182
|
-
export interface CallOptions extends ActorCallOptions {
|
|
1183
|
-
/**
|
|
1184
|
-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
1185
|
-
*/
|
|
1186
|
-
token?: string;
|
|
1187
|
-
}
|
|
1188
|
-
export interface CallTaskOptions extends TaskCallOptions {
|
|
1189
|
-
/**
|
|
1190
|
-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
1191
|
-
*/
|
|
1192
|
-
token?: string;
|
|
1193
|
-
}
|
|
1194
|
-
export interface AbortOptions extends RunAbortOptions {
|
|
1195
|
-
/**
|
|
1196
|
-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
|
|
1197
|
-
*/
|
|
1198
|
-
token?: string;
|
|
1199
|
-
/** Exit with given status message */
|
|
1200
|
-
statusMessage?: string;
|
|
1201
|
-
}
|
|
1202
|
-
export interface WebhookOptions {
|
|
1203
|
-
/**
|
|
1204
|
-
* Array of event types, which you can set for Actor run, see
|
|
1205
|
-
* the [Actor run events](https://docs.apify.com/webhooks/events#actor-run) in the Apify doc.
|
|
1206
|
-
*/
|
|
1207
|
-
eventTypes: readonly WebhookEventType[];
|
|
1208
|
-
/**
|
|
1209
|
-
* URL which will be requested using HTTP POST request, when Actor run will reach the set event type.
|
|
1210
|
-
*/
|
|
1211
|
-
requestUrl: string;
|
|
1212
|
-
/**
|
|
1213
|
-
* Payload template is a JSON-like string that describes the structure of the webhook POST request payload.
|
|
1214
|
-
* It uses JSON syntax, extended with a double curly braces syntax for injecting variables `{{variable}}`.
|
|
1215
|
-
* Those variables are resolved at the time of the webhook's dispatch, and a list of available variables with their descriptions
|
|
1216
|
-
* is available in the [Apify webhook documentation](https://docs.apify.com/webhooks).
|
|
1217
|
-
* If `payloadTemplate` is omitted, the default payload template is used
|
|
1218
|
-
* ([view docs](https://docs.apify.com/webhooks/actions#payload-template)).
|
|
1219
|
-
*/
|
|
1220
|
-
payloadTemplate?: string;
|
|
1221
|
-
/**
|
|
1222
|
-
* Idempotency key enables you to ensure that a webhook will not be added multiple times in case of
|
|
1223
|
-
* an Actor restart or other situation that would cause the `addWebhook()` function to be called again.
|
|
1224
|
-
* We suggest using the Actor run ID as the idempotency key. You can get the run ID by calling
|
|
1225
|
-
* {@apilink Actor.getEnv} function.
|
|
1226
|
-
*/
|
|
1227
|
-
idempotencyKey?: string;
|
|
1228
|
-
}
|
|
1229
|
-
export interface MetamorphOptions {
|
|
1230
|
-
/**
|
|
1231
|
-
* Content type for the `input`. If not specified,
|
|
1232
|
-
* `input` is expected to be an object that will be stringified to JSON and content type set to
|
|
1233
|
-
* `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
|
|
1234
|
-
* `String` or `Buffer`.
|
|
1235
|
-
*/
|
|
1236
|
-
contentType?: string;
|
|
1237
|
-
/**
|
|
1238
|
-
* Tag or number of the target Actor build to metamorph into (e.g. `beta` or `1.2.345`).
|
|
1239
|
-
* If not provided, the run uses build tag or number from the default Actor run configuration (typically `latest`).
|
|
1240
|
-
*/
|
|
1241
|
-
build?: string;
|
|
1242
|
-
/** @internal */
|
|
1243
|
-
customAfterSleepMillis?: number;
|
|
1244
|
-
}
|
|
1245
|
-
export interface RebootOptions {
|
|
1246
|
-
/** @internal */
|
|
1247
|
-
customAfterSleepMillis?: number;
|
|
1248
|
-
}
|
|
1249
|
-
export interface ExitOptions {
|
|
1250
|
-
/** Exit with given status message */
|
|
1251
|
-
statusMessage?: string;
|
|
1252
|
-
/**
|
|
1253
|
-
* Amount of time, in seconds, to wait for all event handlers to finish before exiting the process.
|
|
1254
|
-
* @default 30
|
|
1255
|
-
*/
|
|
1256
|
-
timeoutSecs?: number;
|
|
1257
|
-
/** Exit code, defaults to 0 */
|
|
1258
|
-
exitCode?: number;
|
|
1259
|
-
/** Call `process.exit()`? Defaults to true */
|
|
1260
|
-
exit?: boolean;
|
|
1261
|
-
}
|
|
1262
|
-
export interface OpenStorageOptions {
|
|
1263
|
-
/**
|
|
1264
|
-
* If set to `true` then the cloud storage is used even if the `CRAWLEE_STORAGE_DIR`
|
|
1265
|
-
* environment variable is set. This way it is possible to combine local and cloud storage.
|
|
1266
|
-
* @default false
|
|
1267
|
-
*/
|
|
1268
|
-
forceCloud?: boolean;
|
|
1269
|
-
}
|
|
1270
|
-
export { ClientActorRun as ActorRun };
|
|
1271
|
-
/**
|
|
1272
|
-
* Exit codes for the Actor process.
|
|
1273
|
-
* The error codes must be in the range 1-128, to avoid collision with signal exits
|
|
1274
|
-
* and to ensure Docker will handle them correctly!
|
|
1275
|
-
* @internal should be removed if we decide to remove `Actor.main()`
|
|
1276
|
-
*/
|
|
1277
|
-
export declare const EXIT_CODES: {
|
|
1278
|
-
SUCCESS: number;
|
|
1279
|
-
ERROR_USER_FUNCTION_THREW: number;
|
|
1280
|
-
ERROR_UNKNOWN: number;
|
|
1281
|
-
};
|
|
1282
1282
|
//# sourceMappingURL=actor.d.ts.map
|