apify 4.0.0-beta.14 → 4.0.0-beta.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +28 -2
  2. package/dist/actor.d.ts +393 -281
  3. package/dist/actor.js +734 -417
  4. package/dist/apify_dataset_backend.d.ts +22 -0
  5. package/dist/apify_dataset_backend.js +77 -0
  6. package/dist/apify_file_system_storage_backend.d.ts +34 -0
  7. package/dist/apify_file_system_storage_backend.js +41 -0
  8. package/dist/apify_key_value_store_backend.d.ts +26 -0
  9. package/dist/apify_key_value_store_backend.js +57 -0
  10. package/dist/apify_request_queue_backend.d.ts +81 -0
  11. package/dist/apify_request_queue_backend.js +110 -0
  12. package/dist/apify_request_queue_shared_backend.d.ts +31 -0
  13. package/dist/apify_request_queue_shared_backend.js +193 -0
  14. package/dist/apify_request_queue_single_backend.d.ts +43 -0
  15. package/dist/apify_request_queue_single_backend.js +256 -0
  16. package/dist/apify_storage_backend.d.ts +90 -0
  17. package/dist/apify_storage_backend.js +210 -0
  18. package/dist/charging.d.ts +69 -47
  19. package/dist/charging.js +321 -223
  20. package/dist/charging_storage_backend.d.ts +53 -0
  21. package/dist/charging_storage_backend.js +109 -0
  22. package/dist/child_run_tracker.d.ts +88 -0
  23. package/dist/child_run_tracker.js +239 -0
  24. package/dist/configuration.d.ts +48 -28
  25. package/dist/configuration.js +67 -13
  26. package/dist/enqueue_links_filters.d.ts +29 -0
  27. package/dist/enqueue_links_filters.js +52 -0
  28. package/dist/errors.d.ts +31 -0
  29. package/dist/errors.js +22 -0
  30. package/dist/google_sheets.d.ts +12 -0
  31. package/dist/google_sheets.js +26 -0
  32. package/dist/index.d.ts +13 -4
  33. package/dist/index.js +8 -3
  34. package/dist/input-schemas.d.ts +1 -1
  35. package/dist/platform_event_manager.d.ts +24 -9
  36. package/dist/platform_event_manager.js +213 -43
  37. package/dist/proxy_configuration.d.ts +31 -21
  38. package/dist/proxy_configuration.js +136 -79
  39. package/dist/smart_apify_storage_backend.d.ts +52 -0
  40. package/dist/smart_apify_storage_backend.js +73 -0
  41. package/dist/storage.d.ts +6 -26
  42. package/dist/storage.js +1 -79
  43. package/dist/utils.d.ts +28 -3
  44. package/dist/utils.js +59 -17
  45. package/package.json +38 -44
  46. package/dist/apify_storage_client.d.ts +0 -54
  47. package/dist/apify_storage_client.js +0 -152
  48. package/dist/key_value_store.d.ts +0 -21
  49. package/dist/key_value_store.js +0 -41
package/dist/actor.d.ts CHANGED
@@ -1,19 +1,40 @@
1
1
  import type { EventManager, EventTypeName, RecordOptions, UseStateOptions } from '@crawlee/core';
2
- import { Dataset, RequestQueue } from '@crawlee/core';
3
- import type { Awaitable, Dictionary, SetStatusMessageOptions, StorageClient } from '@crawlee/types';
4
- import type { ActorCallOptions, ActorStartOptions, ApifyClientOptions, RunAbortOptions, TaskCallOptions, Webhook, WebhookEventType } from 'apify-client';
5
- import { ActorRun as ClientActorRun, ApifyClient } from 'apify-client';
6
- import { type ACTOR_PERMISSION_LEVEL } from '@apify/consts';
2
+ import { Dataset, KeyValueStore, RequestQueue } from '@crawlee/core';
3
+ import type { Awaitable, Dictionary, StorageBackend } from '@crawlee/types';
4
+ import type { ActorCallOptions, ActorInput, ActorStartOptions, ApifyClientOptions, RunAbortOptions, RunClient, RunResurrectOptions, TaskCallOptions, TaskStartOptions, WebhookResource, WebhookEventType } from 'apify-client';
5
+ import { ApifyClient, Run as ClientActorRun } from 'apify-client';
6
+ import type { RequestQueueAccessMode } from './apify_request_queue_backend.js';
7
7
  import type { ChargeOptions, ChargeResult } from './charging.js';
8
8
  import { ChargingManager } from './charging.js';
9
9
  import type { ConfigurationOptions } from './configuration.js';
10
10
  import { Configuration } from './configuration.js';
11
- import { KeyValueStore } from './key_value_store.js';
12
11
  import type { ProxyConfigurationOptions } from './proxy_configuration.js';
13
12
  import { ProxyConfiguration } from './proxy_configuration.js';
14
- import type { OpenStorageOptions, StorageIdentifier, StorageIdentifierWithoutAlias } from './storage.js';
13
+ import type { OpenStorageOptions, StorageIdentifier } from './storage.js';
15
14
  export interface InitOptions {
16
- storage?: StorageClient;
15
+ /**
16
+ * Storage backend to use, in place of the Apify platform storage (on the platform) or crawlee's
17
+ * local storage (outside of it).
18
+ *
19
+ * Items pushed to the default dataset are then not charged for under the pay-per-event pricing
20
+ * model: the platform counts an `apify-default-dataset-item` per item it stores itself, and a
21
+ * backend of your own stores them elsewhere.
22
+ */
23
+ storage?: StorageBackend;
24
+ /**
25
+ * Determines how request queues opened on the Apify platform are consumed.
26
+ *
27
+ * - `'single'` (default) assumes this run is the only consumer of its request queues. Requests
28
+ * are not locked server-side and the queue head is estimated locally, which means fewer
29
+ * (paid) API calls and better performance.
30
+ * - `'shared'` locks every fetched request server-side, so any number of concurrent consumers
31
+ * (e.g. several Actor runs) can safely process the same queue, at the cost of roughly one
32
+ * extra API call per processed request.
33
+ *
34
+ * Only applies on the Apify platform (or with `forceCloud`); local storage ignores it.
35
+ * @default 'single'
36
+ */
37
+ requestQueueAccess?: RequestQueueAccessMode;
17
38
  /**
18
39
  * Whether to automatically handle platform shutdown signals.
19
40
  * When enabled, `Actor.exit()` is called on `aborting` events and `Actor.reboot()` on `migrating` events.
@@ -56,127 +77,11 @@ export interface ExitOptions {
56
77
  }
57
78
  export interface MainOptions extends ExitOptions, InitOptions {
58
79
  }
59
- /**
60
- * Parsed representation of the Apify environment variables.
61
- * This object is returned by the {@link Actor.getEnv} function.
62
- */
63
- export interface ApifyEnv {
64
- /**
65
- * ID of the Actor (ACTOR_ID)
66
- */
67
- actorId: string | null;
68
- /**
69
- * ID of the Actor run (ACTOR_RUN_ID)
70
- */
71
- actorRunId: string | null;
72
- /**
73
- * ID of the Actor task (ACTOR_TASK_ID)
74
- */
75
- actorTaskId: string | null;
76
- /**
77
- * ID of the Actor build used in the run. (ACTOR_BUILD_ID)
78
- */
79
- actorBuildId: string | null;
80
- /**
81
- * [Permission level](https://docs.apify.com/platform/actors/development/permissions) the Actor is run under. (ACTOR_PERMISSION_LEVEL)
82
- */
83
- actorPermissionLevel: ACTOR_PERMISSION_LEVEL | null;
84
- /**
85
- * ID of the user who started the Actor - note that it might be
86
- * different than the owner of the Actor (APIFY_USER_ID)
87
- */
88
- userId: string | null;
89
- /**
90
- * If it is `1`, it means that the user who started the Actor is a paying user. (APIFY_USER_IS_PAYING)
91
- */
92
- userIsPaying: string | null;
93
- /**
94
- * Authentication token representing privileges given to the Actor run,
95
- * it can be passed to various Apify APIs (APIFY_TOKEN)
96
- */
97
- token: string | null;
98
- /**
99
- * Date when the Actor was started (ACTOR_STARTED_AT)
100
- */
101
- startedAt: Date | null;
102
- /**
103
- * Date when the Actor will time out (ACTOR_TIMEOUT_AT)
104
- */
105
- timeoutAt: Date | null;
106
- /**
107
- * ID of the key-value store where input and output data of this
108
- * Actor is stored (ACTOR_DEFAULT_KEY_VALUE_STORE_ID)
109
- */
110
- defaultKeyValueStoreId: string | null;
111
- /**
112
- * ID of the dataset where input and output data of this
113
- * Actor is stored (ACTOR_DEFAULT_DATASET_ID)
114
- */
115
- defaultDatasetId: string | null;
116
- /**
117
- * Amount of memory allocated for the Actor,
118
- * in megabytes (ACTOR_MEMORY_MBYTES)
119
- */
120
- memoryMbytes: number | null;
121
- /**
122
- * If set to "1", the web browsers inside the Actor should run in headless
123
- * mode because there is no windowing system available. (APIFY_HEADLESS)
124
- */
125
- headless: string | null;
126
- /**
127
- * Is set to "1" if the Actor is running on Apify servers.
128
- * (APIFY_IS_AT_HOME)
129
- */
130
- isAtHome: string | null;
131
- /**
132
- * The Apify Proxy password of the user who started the Actor. (APIFY_PROXY_PASSWORD)
133
- */
134
- proxyPassword: string | null;
135
- proxyHostname: string | null;
136
- proxyPort: string | null;
137
- /**
138
- * You can visit this page to troubleshoot your proxy connection. (APIFY_PROXY_STATUS_URL)
139
- */
140
- proxyStatusUrl: string | null;
141
- apiBaseUrl: string | null;
142
- apiPublicBaseUrl: string | null;
143
- chromeExecutablePath: string | null;
144
- dedicatedCpus: string | null;
145
- disableOutdatedWarning: 1 | null;
146
- fact: string | null;
147
- inputSecretsPrivateKeyFile: string | null;
148
- inputSecretsPrivateKeyPassphrase: string | null;
149
- /**
150
- * Defines the path to a local directory where KeyValueStore, Dataset, and RequestQueue
151
- * store their data. Typically, it is set to ./storage. If omitted, you should define the
152
- * APIFY_TOKEN environment variable instead. See more info on combination of this and
153
- * APIFY_TOKEN [here](https://docs.apify.com/sdk/js/docs/concepts/environment-variables#combinations-of-apify_local_storage_dir-and-apify_token)(CRAWLEE_STORAGE_DIR)
154
- */
155
- localStorageDir: string | null;
156
- /**
157
- * Specifies the minimum log level, which can be one of the following values (in order of severity): DEBUG, INFO, WARNING and ERROR
158
- * (APIFY_LOG_LEVEL)
159
- */
160
- logLevel: string | null;
161
- logFormat: string | null;
162
- /**
163
- * Origin for the Actor run, i.e. how it was started. See [here](https://docs.apify.com/sdk/python/reference/enum/MetaOrigin)
164
- * for more details. (APIFY_META_ORIGIN)
165
- */
166
- metaOrigin: string | null;
167
- /**
168
- * The key of the input record in the Actor’s default key-value store (ACTOR_INPUT_KEY)
169
- */
170
- inputKey: string | null;
171
- sdkLatestVersion: string | null;
172
- systemInfoIntervalMillis: string | null;
173
- workflowKey: string | null;
174
- actorBuildNumber: string | null;
175
- actorEventsWsUrl: string | null;
176
- actorMaxPaidDatasetItems: number | null;
177
- containerPort: number | null;
178
- containerUrl: string | null;
179
- defaultRequestQueueId: string | null;
80
+ export interface SetStatusMessageOptions {
81
+ /** If `true`, the status message is treated as final and won't be overwritten by the platform. */
82
+ isStatusMessageTerminal?: boolean;
83
+ /** Log level used when the status message is also logged locally. Defaults to `INFO`. */
84
+ level?: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR';
180
85
  }
181
86
  export type UserFunc<T = unknown> = () => Awaitable<T>;
182
87
  export interface Token {
@@ -194,11 +99,38 @@ export interface Timeout {
194
99
  */
195
100
  timeout?: number | 'inherit';
196
101
  }
197
- export interface CallOptions extends Omit<ActorCallOptions, 'timeout'>, Token, Timeout {
102
+ export interface ChildRunOptions {
103
+ /**
104
+ * Local name for the child run, unique across all Actors and tasks started by this run.
105
+ *
106
+ * If a `READY`, `RUNNING` or `SUCCEEDED` run is already tracked under this name, it is returned instead of
107
+ * starting a new one, including after a migration or resurrection of this run. A run that was aborted or timed out
108
+ * is resurrected with the given options, once it finishes aborting or timing out. A run that failed is replaced
109
+ * by a new one. Reusing the name for a different Actor, task or input throws, unless the tracked run is replaced.
110
+ */
111
+ runName?: string;
112
+ /**
113
+ * Gracefully abort the child run when this run is gracefully aborted. Requires `runName`.
114
+ *
115
+ * The latest call under the same `runName` sets the value. Once this run is being aborted, a call with this option
116
+ * throws instead of starting, resurrecting or returning a run. A hard abort, timeout or crash of this run leaves
117
+ * the child run running.
118
+ *
119
+ * A run started with a custom `token` is aborted with that token, except for a run started before a migration or
120
+ * resurrection of this run, which is aborted with the default client.
121
+ * @default false
122
+ */
123
+ abortWithParent?: boolean;
124
+ }
125
+ export interface CallOptions extends Omit<ActorCallOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
198
126
  }
199
- export interface StartOptions extends Omit<ActorStartOptions, 'waitForFinish' | 'timeout'>, Token, Timeout {
127
+ export interface StartOptions extends Omit<ActorStartOptions, 'waitForFinish' | 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
200
128
  }
201
- export interface CallTaskOptions extends Omit<TaskCallOptions, 'timeout'>, Token, Timeout {
129
+ export interface CallTaskOptions extends Omit<TaskCallOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
130
+ }
131
+ export interface ResurrectOptions extends Omit<RunResurrectOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout {
132
+ }
133
+ export interface StartTaskOptions extends Omit<TaskStartOptions, 'waitForFinish' | 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
202
134
  }
203
135
  export interface AbortOptions extends RunAbortOptions, Token {
204
136
  /** Exit with given status message */
@@ -226,8 +158,7 @@ export interface WebhookOptions {
226
158
  /**
227
159
  * Idempotency key enables you to ensure that a webhook will not be added multiple times in case of
228
160
  * an Actor restart or other situation that would cause the `addWebhook()` function to be called again.
229
- * We suggest using the Actor run ID as the idempotency key. You can get the run ID by calling
230
- * {@link Actor.getEnv} function.
161
+ * We suggest using the Actor run ID as the idempotency key, available as `Actor.configuration.actorRunId`.
231
162
  */
232
163
  idempotencyKey?: string;
233
164
  /**
@@ -265,7 +196,7 @@ export interface MetamorphOptions {
265
196
  * Content type for the `input`. If not specified,
266
197
  * `input` is expected to be an object that will be stringified to JSON and content type set to
267
198
  * `application/json; charset=utf-8`. If `options.contentType` is specified, then `input` must be a
268
- * `String` or `Buffer`.
199
+ * `Buffer`.
269
200
  */
270
201
  contentType?: string;
271
202
  /**
@@ -277,6 +208,11 @@ export interface MetamorphOptions {
277
208
  customAfterSleepMillis?: number;
278
209
  }
279
210
  export interface RebootOptions {
211
+ /**
212
+ * Amount of time, in seconds, to wait for the `persistState` and `migrating` event handlers before rebooting.
213
+ * @default 30
214
+ */
215
+ timeoutSecs?: number;
280
216
  /** @internal */
281
217
  customAfterSleepMillis?: number;
282
218
  }
@@ -298,13 +234,12 @@ export declare const EXIT_CODES: {
298
234
  * See {@link Configuration} for details about what can be configured and what are the default values.
299
235
  */
300
236
  export declare class Actor<Data extends Dictionary = Dictionary> {
301
- /** @internal */
302
- static _instance: Actor;
237
+ #private;
303
238
  /**
304
239
  * Configuration of this SDK instance (provided to its constructor). See {@link Configuration} for details.
305
240
  * @internal
306
241
  */
307
- readonly config: Configuration;
242
+ readonly configuration: Configuration;
308
243
  /**
309
244
  * Default {@link ApifyClient} instance.
310
245
  * @internal
@@ -319,30 +254,6 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
319
254
  * Whether the Actor instance was initialized. This is set by calling {@link Actor.init}.
320
255
  */
321
256
  initialized: boolean;
322
- /**
323
- * Set if the Actor called a method that requires the instance to be initialized, but did not do so.
324
- * A call to `init` after this warning is emitted is considered an invalid state and will throw an error.
325
- */
326
- private warnedAboutMissingInitCall;
327
- /**
328
- * Set if the Actor is currently rebooting.
329
- */
330
- private isRebooting;
331
- /**
332
- * Set if the Actor is currently exiting. Prevents double-exit from graceful shutdown handlers.
333
- */
334
- private isExiting;
335
- /**
336
- * References to graceful shutdown handlers so they can be removed during cleanup.
337
- */
338
- private gracefulShutdownHandlers;
339
- private chargingManager;
340
- /**
341
- * Tracks which aliased storages have been purged during this session,
342
- * so we only purge them once (on first open) when running locally.
343
- * @internal
344
- */
345
- purgedStorageAliases: Set<string>;
346
257
  constructor(options?: ActorOptions);
347
258
  /**
348
259
  * Runs the main user function that performs the job of the Actor
@@ -379,24 +290,22 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
379
290
  *
380
291
  * If the user function returns a promise, it is considered asynchronous:
381
292
  * ```js
382
- * import { gotScraping } from 'got-scraping';
383
- *
384
293
  * await Actor.main(() => {
385
294
  * // My asynchronous function that returns a promise
386
- * return gotScraping('http://www.example.com').then((html) => {
387
- * console.log(html);
388
- * });
295
+ * return fetch('http://www.example.com')
296
+ * .then((response) => response.text())
297
+ * .then((html) => {
298
+ * console.log(html);
299
+ * });
389
300
  * });
390
301
  * ```
391
302
  *
392
303
  * To simplify your code, you can take advantage of the `async`/`await` keywords:
393
304
  *
394
305
  * ```js
395
- * import { gotScraping } from 'got-scraping';
396
- *
397
306
  * await Actor.main(async () => {
398
307
  * // My asynchronous function
399
- * const html = await request('http://www.example.com');
308
+ * const html = await fetch('http://www.example.com').then((response) => response.text());
400
309
  * console.log(html);
401
310
  * });
402
311
  * ```
@@ -445,13 +354,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
445
354
  * @param actorId
446
355
  * Allowed formats are `username/actor-name`, `userId/actor-name` or Actor ID.
447
356
  * @param [input]
448
- * Input for the Actor. If it is an object, it will be stringified to
449
- * JSON and its content type set to `application/json; charset=utf-8`.
450
- * Otherwise the `options.contentType` parameter must be provided.
357
+ * Input for the Actor. A plain object is stringified to JSON with content type
358
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
451
359
  * @param [options]
452
360
  * @ignore
453
361
  */
454
- call(actorId: string, input?: unknown, options?: CallOptions): Promise<ClientActorRun>;
362
+ call(actorId: string, input?: ActorInput, options?: CallOptions): Promise<ClientActorRun>;
455
363
  /**
456
364
  * Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
457
365
  * unlike `Actor.call`, this method just starts the run without waiting for finish.
@@ -470,13 +378,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
470
378
  * @param actorId
471
379
  * Allowed formats are `username/actor-name`, `userId/actor-name` or Actor ID.
472
380
  * @param [input]
473
- * Input for the Actor. If it is an object, it will be stringified to
474
- * JSON and its content type set to `application/json; charset=utf-8`.
475
- * Otherwise the `options.contentType` parameter must be provided.
381
+ * Input for the Actor. A plain object is stringified to JSON with content type
382
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
476
383
  * @param [options]
477
384
  * @ignore
478
385
  */
479
- start(actorId: string, input?: unknown, options?: StartOptions): Promise<ClientActorRun>;
386
+ start(actorId: string, input?: ActorInput, options?: StartOptions): Promise<ClientActorRun>;
480
387
  /**
481
388
  * Aborts given Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
482
389
  *
@@ -493,6 +400,25 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
493
400
  * @ignore
494
401
  */
495
402
  abort(runId: string, options?: AbortOptions): Promise<ClientActorRun>;
403
+ /**
404
+ * Resurrects a finished Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
405
+ *
406
+ * Only finished runs (SUCCEEDED, FAILED, ABORTED or TIMED-OUT) can be resurrected. The run goes back to the RUNNING
407
+ * status and keeps its default storages. Options you leave out keep the values of the original run.
408
+ *
409
+ * The result of the function is an {@link ActorRun} object that contains details about the Actor run.
410
+ *
411
+ * For more information about Actors, read the
412
+ * [documentation](https://docs.apify.com/actor).
413
+ *
414
+ * **Example usage:**
415
+ *
416
+ * ```js
417
+ * const run = await Actor.resurrect(runId);
418
+ * ```
419
+ * @ignore
420
+ */
421
+ resurrect(runId: string, options?: ResurrectOptions): Promise<ClientActorRun>;
496
422
  /**
497
423
  * Runs an actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
498
424
  *
@@ -520,6 +446,43 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
520
446
  * @ignore
521
447
  */
522
448
  callTask(taskId: string, input?: Dictionary, options?: CallTaskOptions): Promise<ClientActorRun>;
449
+ /**
450
+ * Clients for the child runs started with the `runName` option, keyed by that name, including the runs started
451
+ * before a migration or resurrection of this run. Each client points to the current run under its name.
452
+ *
453
+ * ```js
454
+ * await Actor.childRuns['my-child'].waitForFinish();
455
+ * ```
456
+ *
457
+ * A run started with a custom `token` uses that token, except for a run started before a migration or
458
+ * resurrection, which uses the default client. The tracked runs, including the earlier runs replaced
459
+ * under the same name, are stored in the default key-value store under the `APIFY_ACTOR_CHILD_RUNS` key.
460
+ */
461
+ get childRuns(): Record<string, RunClient>;
462
+ /**
463
+ * Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
464
+ * unlike `Actor.callTask`, this method just starts the run without waiting for finish.
465
+ *
466
+ * The result of the function is an {@link ActorRun} object that contains details about the Actor run.
467
+ *
468
+ * For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
469
+ *
470
+ * **Example usage:**
471
+ *
472
+ * ```js
473
+ * const run = await Actor.startTask('bob/some-task');
474
+ * ```
475
+ *
476
+ * @param taskId
477
+ * Allowed formats are `username/task-name`, `userId/task-name` or task ID.
478
+ * @param [input]
479
+ * Input overrides for the Actor task. If it is an object, it will be stringified to
480
+ * JSON and its content type set to `application/json; charset=utf-8`.
481
+ * Provided input will be merged with Actor task input.
482
+ * @param [options]
483
+ * @ignore
484
+ */
485
+ startTask(taskId: string, input?: Dictionary, options?: StartTaskOptions): Promise<ClientActorRun>;
523
486
  /**
524
487
  * Transforms this Actor run to an Actor run of a given Actor. The system stops the current container and starts
525
488
  * the new container instead. All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key
@@ -528,13 +491,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
528
491
  * @param targetActorId
529
492
  * Either `username/actor-name` or Actor ID of an Actor to which we want to metamorph.
530
493
  * @param [input]
531
- * Input for the Actor. If it is an object, it will be stringified to
532
- * JSON and its content type set to `application/json; charset=utf-8`.
533
- * Otherwise, the `options.contentType` parameter must be provided.
494
+ * Input for the Actor. A plain object is stringified to JSON with content type
495
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
534
496
  * @param [options]
535
497
  * @ignore
536
498
  */
537
- metamorph(targetActorId: string, input?: unknown, options?: MetamorphOptions): Promise<void>;
499
+ metamorph(targetActorId: string, input?: ActorInput, options?: MetamorphOptions): Promise<void>;
538
500
  /**
539
501
  * Internally reboots this Actor. The system stops the current container and starts
540
502
  * a new container with the same run ID.
@@ -555,15 +517,16 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
555
517
  * For more information, see the [Get webhook](https://apify.com/docs/api/v2#/reference/webhooks/webhook-object/get-webhook) API endpoint.
556
518
  * @ignore
557
519
  */
558
- addWebhook(options: WebhookOptions): Promise<Webhook | undefined>;
520
+ addWebhook(options: WebhookOptions): Promise<WebhookResource | undefined>;
559
521
  /**
560
522
  * Sets the status message for the current Actor run.
561
523
  *
562
- * @returns The return value is the Run object.
524
+ * @returns The updated Run object, or `undefined` when no run was updated: when run locally,
525
+ * or when the update failed or timed out (a warning is logged in that case).
563
526
  * For more information, see the [Actor Runs](https://docs.apify.com/api/v2#/reference/actor-runs/) API endpoints.
564
527
  * @ignore
565
528
  */
566
- setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
529
+ setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun | undefined>;
567
530
  /**
568
531
  * Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
569
532
  *
@@ -584,9 +547,13 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
584
547
  * **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
585
548
  * otherwise the Actor process might finish before the data are stored!
586
549
  *
550
+ * Inside a crawlee storage transaction, the items are stored - and charged for - at commit time,
551
+ * so the returned counts are zero and charging for an explicit `eventName` is rejected outright.
552
+ *
587
553
  * @param item Object or array of objects containing data to be stored in the default dataset.
588
554
  * The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
589
555
  * @param eventName If provided, the method will attempt to charge for the event for each pushed item.
556
+ * Not supported in multi-tenant Server Actor runs, which charge per request with `Actor.charge()`.
590
557
  * @ignore
591
558
  */
592
559
  pushData(item: Data | Data[], eventName?: string | undefined): Promise<ChargeResult>;
@@ -602,8 +569,8 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
602
569
  * @param [datasetIdOrName]
603
570
  * ID, name, or alias of the dataset to be opened. If `null` or `undefined`,
604
571
  * the function returns the default dataset associated with the Actor run.
605
- * You can also pass `{ alias: 'name' }` to open a dataset defined in the Actor's schema storages,
606
- * `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
572
+ * You can also pass `{ alias: 'abc' }` to open a run-scoped storage, `{ id: 'abc' }` to open by
573
+ * explicit ID, or `{ name: 'abc' }` to open by explicit name.
607
574
  * @param [options]
608
575
  * @ignore
609
576
  */
@@ -637,6 +604,35 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
637
604
  * @ignore
638
605
  */
639
606
  getValue<T = unknown>(key: string): Promise<T | null>;
607
+ /**
608
+ * Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
609
+ *
610
+ * This is just a convenient shortcut for {@link KeyValueStore.getValue}.
611
+ * For example, calling the following code:
612
+ * ```js
613
+ * const value = await Actor.getValue('my-key');
614
+ * ```
615
+ *
616
+ * is equivalent to:
617
+ * ```js
618
+ * const store = await Actor.openKeyValueStore();
619
+ * const value = await store.getValue('my-key');
620
+ * ```
621
+ *
622
+ * To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
623
+ *
624
+ * For more information, see {@link Actor.openKeyValueStore}
625
+ * and {@link KeyValueStore.getValue}.
626
+ *
627
+ * @param key Unique record key.
628
+ * @param defaultValue Fallback that will be returned if no value if present in the storage.
629
+ * @returns
630
+ * Returns a promise that resolves to an object, string
631
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
632
+ * on the MIME content type of the record, or the provided default value.
633
+ * @ignore
634
+ */
635
+ getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
640
636
  /**
641
637
  * Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
642
638
  *
@@ -672,17 +668,21 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
672
668
  /**
673
669
  * Gets the Actor input value from the default {@link KeyValueStore} associated with the current Actor run.
674
670
  *
675
- * This is just a convenient shortcut for [`keyValueStore.getValue('INPUT')`](core/class/KeyValueStore#getValue).
676
- * For example, calling the following code:
677
- * ```js
678
- * const input = await Actor.getInput();
679
- * ```
671
+ * The input is the record stored under the configured input key (`ACTOR_INPUT_KEY`, default `INPUT`).
672
+ * A record stored as `application/octet-stream` — which is what a local input file without an
673
+ * extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
680
674
  *
681
- * is equivalent to:
682
- * ```js
683
- * const store = await Actor.openKeyValueStore();
684
- * await store.getValue('INPUT');
685
- * ```
675
+ * When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
676
+ * working directory. A storage backend that doesn't read the default key-value store's directory under
677
+ * the storage directory (e.g. in-memory storage) also gets the file `apify run` writes there.
678
+ *
679
+ * Google Sheets sharing links in `requestsFromUrl` entries (from the "Link remote text file" option) are
680
+ * replaced with the links of their CSV exports.
681
+ *
682
+ * Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
683
+ * found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
684
+ * (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
685
+ * Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
686
686
  *
687
687
  * Note that the `getInput()` function does not cache the value read from the key-value store.
688
688
  * If you need to use the input multiple times in your Actor,
@@ -694,16 +694,20 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
694
694
  * @returns
695
695
  * Returns a promise that resolves to an object, string
696
696
  * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
697
- * on the MIME content type of the record, or `null`
698
- * if the record is missing.
697
+ * on the MIME content type of the record.
698
+ * @throws {ActorInputError} When the input cannot be produced; see `code`.
699
699
  * @ignore
700
700
  */
701
- getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
701
+ getInput<T = Dictionary | string | Buffer>(): Promise<T>;
702
702
  /**
703
- * Gets the Actor input value just like the {@link Actor.getInput} method,
704
- * but throws if it is not found.
703
+ * Reads the input from a `<inputKey>` or `<inputKey>.json` file in the given directory, for local runs
704
+ * whose default key-value store holds no input record. Mirrors how `ApifyFileSystemStorageBackend` adopts
705
+ * such files inside the store directory: the `.json` file is JSON, the bare one is bytes that
706
+ * {@link parseInputValue} tries as JSON5. Both files present is an error rather than a guess.
707
+ *
708
+ * @returns `undefined` when running on the platform or when neither file exists.
705
709
  */
706
- getInputOrThrow<T = Dictionary | string | Buffer>(): Promise<T>;
710
+ private readInputFromDirectory;
707
711
  /**
708
712
  * Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
709
713
  *
@@ -714,13 +718,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
714
718
  * For more details and code examples, see the {@link KeyValueStore} class.
715
719
  *
716
720
  * @param [storeIdOrName]
717
- * ID or name of the key-value store to be opened. If `null` or `undefined`,
721
+ * ID, name, or alias of the key-value store to be opened. If `null` or `undefined`,
718
722
  * the function returns the default key-value store associated with the Actor run.
719
- * You can also pass `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
723
+ * You can also pass `{ alias: 'abc' }` to open a run-scoped storage, `{ id: 'abc' }` to open by
724
+ * explicit ID, or `{ name: 'abc' }` to open by explicit name.
720
725
  * @param [options]
721
726
  * @ignore
722
727
  */
723
- openKeyValueStore(storeIdOrName?: StorageIdentifierWithoutAlias | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
728
+ openKeyValueStore(storeIdOrName?: StorageIdentifier | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
724
729
  /**
725
730
  * Opens a request queue and returns a promise resolving to an instance
726
731
  * of the {@link RequestQueue} class.
@@ -733,13 +738,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
733
738
  * For more details and code examples, see the {@link RequestQueue} class.
734
739
  *
735
740
  * @param [queueIdOrName]
736
- * ID or name of the request queue to be opened. If `null` or `undefined`,
741
+ * ID, name, or alias of the request queue to be opened. If `null` or `undefined`,
737
742
  * the function returns the default request queue associated with the Actor run.
738
- * You can also pass `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
743
+ * You can also pass `{ alias: 'abc' }` to open a run-scoped storage, `{ id: 'abc' }` to open by
744
+ * explicit ID, or `{ name: 'abc' }` to open by explicit name.
739
745
  * @param [options]
740
746
  * @ignore
741
747
  */
742
- openRequestQueue(queueIdOrName?: StorageIdentifierWithoutAlias | null, options?: OpenStorageOptions): Promise<RequestQueue>;
748
+ openRequestQueue(queueIdOrName?: StorageIdentifier | null, options?: OpenStorageOptions): Promise<RequestQueue>;
743
749
  /**
744
750
  * Creates a proxy configuration and returns a promise resolving to an instance
745
751
  * of the {@link ProxyConfiguration} class that is already initialized.
@@ -797,6 +803,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
797
803
  * rather than batching via `count` — this gives finer control over budget consumption
798
804
  * and avoids situations where more work is requested than the budget allows.
799
805
  *
806
+ * **Note:** `idempotencyKey` is scoped to the whole run, not to `requestId`. In a multi-tenant
807
+ * Server Actor run, a key reused across requests charges only the first caller, so it must
808
+ * be globally unique (e.g. derived from `requestId`).
809
+ *
800
810
  * @param options The name of the event to charge for and the number of events to be charged.
801
811
  * @ignore
802
812
  */
@@ -807,18 +817,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
807
817
  */
808
818
  getChargingManager(): ChargingManager;
809
819
  /**
810
- * Modifies Actor env vars so parsing respects the structure of {@link ApifyEnv} interface.
820
+ * Fetches the current Actor run from the Apify API. The result is cached for the lifetime of the Actor,
821
+ * so use `Actor.apifyClient.run(runId).get()` instead when you need fresh data such as the run status.
822
+ * Resolves to `undefined` when not running on the Apify platform.
811
823
  */
812
- private getModifiedActorEnvVars;
813
- /**
814
- * Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
815
- *
816
- * For the list of the Apify environment variables, see
817
- * [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
818
- * If some variables are not defined or are invalid, the corresponding value in the resulting object will be null.
819
- * @ignore
820
- */
821
- getEnv(): ApifyEnv;
824
+ getCurrentRun(): Promise<ClientActorRun | undefined>;
822
825
  /**
823
826
  * Returns a new instance of the Apify API client. The `ApifyClient` class is provided
824
827
  * by the [apify-client](https://www.npmjs.com/package/apify-client)
@@ -838,7 +841,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
838
841
  *
839
842
  * Values can be modified by simply using the assignment operator.
840
843
  *
841
- * @param name The name of the store to use.
844
+ * @param name The key of the record that holds the state. Defaults to `APIFY_GLOBAL_STATE`.
842
845
  * @param defaultValue If the store does not yet have a value in it, the value will be initialized with the `defaultValue` you provide.
843
846
  * @param options An optional object parameter where a custom `keyValueStoreName` and `config` can be passed in.
844
847
  */
@@ -848,7 +851,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
848
851
  *
849
852
  * Values can be modified by simply using the assignment operator.
850
853
  *
851
- * @param name The name of the store to use.
854
+ * @param name The key of the record that holds the state. Defaults to `APIFY_GLOBAL_STATE`.
852
855
  * @param defaultValue If the store does not yet have a value in it, the value will be initialized with the `defaultValue` you provide.
853
856
  * @param options An optional object parameter where a custom `keyValueStoreName` and `config` can be passed in.
854
857
  */
@@ -888,24 +891,22 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
888
891
  *
889
892
  * If the user function returns a promise, it is considered asynchronous:
890
893
  * ```js
891
- * import { gotScraping } from 'got-scraping';
892
- *
893
894
  * await Actor.main(() => {
894
895
  * // My asynchronous function that returns a promise
895
- * return gotScraping('http://www.example.com').then((html) => {
896
- * console.log(html);
897
- * });
896
+ * return fetch('http://www.example.com')
897
+ * .then((response) => response.text())
898
+ * .then((html) => {
899
+ * console.log(html);
900
+ * });
898
901
  * });
899
902
  * ```
900
903
  *
901
904
  * To simplify your code, you can take advantage of the `async`/`await` keywords:
902
905
  *
903
906
  * ```js
904
- * import { gotScraping } from 'got-scraping';
905
- *
906
907
  * await Actor.main(async () => {
907
908
  * // My asynchronous function
908
- * const html = await gotScraping('http://www.example.com');
909
+ * const html = await fetch('http://www.example.com').then((response) => response.text());
909
910
  * console.log(html);
910
911
  * });
911
912
  * ```
@@ -931,11 +932,9 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
931
932
  * behavior by setting `options.gracefulShutdown` to `false`.
932
933
  *
933
934
  * ```js
934
- * import { gotScraping } from 'got-scraping';
935
- *
936
935
  * await Actor.init();
937
936
  *
938
- * const html = await gotScraping('http://www.example.com');
937
+ * const html = await fetch('http://www.example.com').then((response) => response.text());
939
938
  * console.log(html);
940
939
  *
941
940
  * await Actor.exit();
@@ -976,12 +975,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
976
975
  * @param actorId
977
976
  * Allowed formats are `username/actor-name`, `userId/actor-name` or Actor ID.
978
977
  * @param [input]
979
- * Input for the Actor. If it is an object, it will be stringified to
980
- * JSON and its content type set to `application/json; charset=utf-8`.
981
- * Otherwise the `options.contentType` parameter must be provided.
978
+ * Input for the Actor. A plain object is stringified to JSON with content type
979
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
982
980
  * @param [options]
983
981
  */
984
- static call(actorId: string, input?: unknown, options?: CallOptions): Promise<ClientActorRun>;
982
+ static call(actorId: string, input?: ActorInput, options?: CallOptions): Promise<ClientActorRun>;
985
983
  /**
986
984
  * Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
987
985
  *
@@ -1008,6 +1006,29 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1008
1006
  * @param [options]
1009
1007
  */
1010
1008
  static callTask(taskId: string, input?: Dictionary, options?: CallTaskOptions): Promise<ClientActorRun>;
1009
+ /**
1010
+ * Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
1011
+ * unlike `Actor.callTask`, this method just starts the run without waiting for finish.
1012
+ *
1013
+ * The result of the function is an {@link ActorRun} object that contains details about the Actor run.
1014
+ *
1015
+ * For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
1016
+ *
1017
+ * **Example usage:**
1018
+ *
1019
+ * ```js
1020
+ * const run = await Actor.startTask('bob/some-task');
1021
+ * ```
1022
+ *
1023
+ * @param taskId
1024
+ * Allowed formats are `username/task-name`, `userId/task-name` or task ID.
1025
+ * @param [input]
1026
+ * Input overrides for the Actor task. If it is an object, it will be stringified to
1027
+ * JSON and its content type set to `application/json; charset=utf-8`.
1028
+ * Provided input will be merged with Actor task input.
1029
+ * @param [options]
1030
+ */
1031
+ static startTask(taskId: string, input?: Dictionary, options?: StartTaskOptions): Promise<ClientActorRun>;
1011
1032
  /**
1012
1033
  * Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
1013
1034
  * unlike `Actor.call`, this method just starts the run without waiting for finish.
@@ -1026,12 +1047,24 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1026
1047
  * @param actorId
1027
1048
  * Allowed formats are `username/actor-name`, `userId/actor-name` or Actor ID.
1028
1049
  * @param [input]
1029
- * Input for the Actor. If it is an object, it will be stringified to
1030
- * JSON and its content type set to `application/json; charset=utf-8`.
1031
- * Otherwise the `options.contentType` parameter must be provided.
1050
+ * Input for the Actor. A plain object is stringified to JSON with content type
1051
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
1032
1052
  * @param [options]
1033
1053
  */
1034
1054
  static start(actorId: string, input?: Dictionary, options?: StartOptions): Promise<ClientActorRun>;
1055
+ /**
1056
+ * Clients for the child runs started with the `runName` option, keyed by that name, including the runs started
1057
+ * before a migration or resurrection of this run. Each client points to the current run under its name.
1058
+ *
1059
+ * ```js
1060
+ * await Actor.childRuns['my-child'].waitForFinish();
1061
+ * ```
1062
+ *
1063
+ * A run started with a custom `token` uses that token, except for a run started before a migration or
1064
+ * resurrection, which uses the default client. The tracked runs, including the earlier runs replaced
1065
+ * under the same name, are stored in the default key-value store under the `APIFY_ACTOR_CHILD_RUNS` key.
1066
+ */
1067
+ static get childRuns(): Record<string, RunClient>;
1035
1068
  /**
1036
1069
  * Aborts given Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
1037
1070
  *
@@ -1047,6 +1080,24 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1047
1080
  * ```
1048
1081
  */
1049
1082
  static abort(runId: string, options?: AbortOptions): Promise<ClientActorRun>;
1083
+ /**
1084
+ * Resurrects a finished Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
1085
+ *
1086
+ * Only finished runs (SUCCEEDED, FAILED, ABORTED or TIMED-OUT) can be resurrected. The run goes back to the RUNNING
1087
+ * status and keeps its default storages. Options you leave out keep the values of the original run.
1088
+ *
1089
+ * The result of the function is an {@link ActorRun} object that contains details about the Actor run.
1090
+ *
1091
+ * For more information about Actors, read the
1092
+ * [documentation](https://docs.apify.com/actor).
1093
+ *
1094
+ * **Example usage:**
1095
+ *
1096
+ * ```js
1097
+ * const run = await Actor.resurrect(runId);
1098
+ * ```
1099
+ */
1100
+ static resurrect(runId: string, options?: ResurrectOptions): Promise<ClientActorRun>;
1050
1101
  /**
1051
1102
  * Transforms this Actor run to an Actor run of a given Actor. The system stops the current container and starts
1052
1103
  * the new container instead. All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key
@@ -1055,12 +1106,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1055
1106
  * @param targetActorId
1056
1107
  * Either `username/actor-name` or Actor ID of an Actor to which we want to metamorph.
1057
1108
  * @param [input]
1058
- * Input for the Actor. If it is an object, it will be stringified to
1059
- * JSON and its content type set to `application/json; charset=utf-8`.
1060
- * Otherwise, the `options.contentType` parameter must be provided.
1109
+ * Input for the Actor. A plain object is stringified to JSON with content type
1110
+ * `application/json; charset=utf-8`. A `Buffer` is sent as-is and needs `options.contentType`.
1061
1111
  * @param [options]
1062
1112
  */
1063
- static metamorph(targetActorId: string, input?: unknown, options?: MetamorphOptions): Promise<void>;
1113
+ static metamorph(targetActorId: string, input?: ActorInput, options?: MetamorphOptions): Promise<void>;
1064
1114
  /**
1065
1115
  * Internally reboots this Actor run. The system stops the current container and starts
1066
1116
  * a new container with the same run id.
@@ -1078,7 +1128,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1078
1128
  * @returns The return value is the Webhook object.
1079
1129
  * For more information, see the [Get webhook](https://apify.com/docs/api/v2#/reference/webhooks/webhook-object/get-webhook) API endpoint.
1080
1130
  */
1081
- static addWebhook(options: WebhookOptions): Promise<Webhook | undefined>;
1131
+ static addWebhook(options: WebhookOptions): Promise<WebhookResource | undefined>;
1082
1132
  /**
1083
1133
  * Sets the status message for the current Actor run.
1084
1134
  *
@@ -1086,10 +1136,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1086
1136
  * @param [options]
1087
1137
  * @param [options.isStatusMessageTerminal] If `true`, the status message will be marked as terminal.
1088
1138
  * This is required for the last status message of the run. Default value is `false`.
1089
- * @returns The return value is the Run object. When run locally, this method returns empty object (`{}`).
1139
+ * @returns The updated Run object, or `undefined` when no run was updated: when run locally,
1140
+ * or when the update failed or timed out (a warning is logged in that case).
1090
1141
  * For more information, see the [Actor Runs](https://docs.apify.com/api/v2#/reference/actor-runs/) API endpoints.
1091
1142
  */
1092
- static setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
1143
+ static setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun | undefined>;
1093
1144
  /**
1094
1145
  * Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
1095
1146
  *
@@ -1134,9 +1185,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1134
1185
  * **IMPORTANT**: Make sure to use the `await` keyword when calling `pushData()`,
1135
1186
  * otherwise the Actor process might finish before the data are stored!
1136
1187
  *
1188
+ * Charging is rejected inside a crawlee storage transaction, where the items would only be stored
1189
+ * at commit while the charge happens immediately - use `withDirectStorageAccess()` to opt out of
1190
+ * the transaction, or push without an event name and charge separately.
1191
+ *
1137
1192
  * @param item Object or array of objects containing data to be stored in the default dataset.
1138
1193
  * The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
1139
1194
  * @param eventName If provided, the method will attempt to charge for the event for each pushed item.
1195
+ * Not supported in multi-tenant Server Actor runs, which charge per request with `Actor.charge()`.
1140
1196
  */
1141
1197
  static pushData<Data extends Dictionary = Dictionary>(item: Data | Data[], eventName: string): Promise<ChargeResult>;
1142
1198
  /**
@@ -1151,8 +1207,8 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1151
1207
  * @param [datasetIdOrName]
1152
1208
  * ID, name, or alias of the dataset to be opened. If `null` or `undefined`,
1153
1209
  * the function returns the default dataset associated with the Actor run.
1154
- * You can also pass `{ alias: 'name' }` to open a dataset defined in the Actor's schema storages,
1155
- * `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
1210
+ * You can also pass `{ alias: 'abc' }` to open a run-scoped storage, `{ id: 'abc' }` to open by
1211
+ * explicit ID, or `{ name: 'abc' }` to open by explicit name.
1156
1212
  * @param [options]
1157
1213
  */
1158
1214
  static openDataset<Data extends Dictionary = Dictionary>(datasetIdOrName?: StorageIdentifier | null, options?: OpenStorageOptions): Promise<Dataset<Data>>;
@@ -1184,6 +1240,34 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1184
1240
  * if the record is missing.
1185
1241
  */
1186
1242
  static getValue<T = unknown>(key: string): Promise<T | null>;
1243
+ /**
1244
+ * Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
1245
+ *
1246
+ * This is just a convenient shortcut for {@link KeyValueStore.getValue}.
1247
+ * For example, calling the following code:
1248
+ * ```js
1249
+ * const value = await Actor.getValue('my-key');
1250
+ * ```
1251
+ *
1252
+ * is equivalent to:
1253
+ * ```js
1254
+ * const store = await Actor.openKeyValueStore();
1255
+ * const value = await store.getValue('my-key');
1256
+ * ```
1257
+ *
1258
+ * To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
1259
+ *
1260
+ * For more information, see {@link Actor.openKeyValueStore}
1261
+ * and {@link KeyValueStore.getValue}.
1262
+ *
1263
+ * @param key Unique record key.
1264
+ * @param defaultValue Fallback that will be returned if no value if present in the storage.
1265
+ * @returns
1266
+ * Returns a promise that resolves to an object, string
1267
+ * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
1268
+ * on the MIME content type of the record, or the provided default value.
1269
+ */
1270
+ static getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
1187
1271
  /**
1188
1272
  * Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
1189
1273
  *
@@ -1218,16 +1302,31 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1218
1302
  /**
1219
1303
  * Gets the Actor input value from the default {@link KeyValueStore} associated with the current Actor run.
1220
1304
  *
1221
- * This is just a convenient shortcut for {@link KeyValueStore.getValue | `keyValueStore.getValue('INPUT')`}.
1222
- * For example, calling the following code:
1305
+ * The input is the record stored under the configured input key (`ACTOR_INPUT_KEY`, default `INPUT`):
1223
1306
  * ```js
1224
1307
  * const input = await Actor.getInput();
1225
1308
  * ```
1226
1309
  *
1227
- * is equivalent to:
1310
+ * A record stored as `application/octet-stream` — which is what a local input file without an
1311
+ * extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
1312
+ *
1313
+ * When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
1314
+ * working directory.
1315
+ *
1316
+ * Google Sheets sharing links in `requestsFromUrl` entries (from the "Link remote text file" option) are
1317
+ * replaced with the links of their CSV exports.
1318
+ *
1319
+ * Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
1320
+ * found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
1321
+ * (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
1322
+ * Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest:
1228
1323
  * ```js
1229
- * const store = await Actor.openKeyValueStore();
1230
- * await store.getValue('INPUT');
1324
+ * let input = {};
1325
+ * try {
1326
+ * input = await Actor.getInput();
1327
+ * } catch (error) {
1328
+ * if (!(error instanceof ActorInputError) || error.code !== 'NOT_FOUND') throw error;
1329
+ * }
1231
1330
  * ```
1232
1331
  *
1233
1332
  * Note that the `getInput()` function does not cache the value read from the key-value store.
@@ -1239,15 +1338,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1239
1338
  * @returns
1240
1339
  * Returns a promise that resolves to an object, string
1241
1340
  * or [`Buffer`](https://nodejs.org/api/buffer.html), depending
1242
- * on the MIME content type of the record, or `null`
1243
- * if the record is missing.
1341
+ * on the MIME content type of the record.
1342
+ * @throws {ActorInputError} When the input cannot be produced; see `code`.
1244
1343
  */
1245
- static getInput<T = Dictionary | string | Buffer>(): Promise<T | null>;
1246
- /**
1247
- * Gets the Actor input value just like the {@link Actor.getInput} method,
1248
- * but throws if it is not found.
1249
- */
1250
- static getInputOrThrow<T = Dictionary | string | Buffer>(): Promise<T>;
1344
+ static getInput<T = Dictionary | string | Buffer>(): Promise<T>;
1251
1345
  /**
1252
1346
  * Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
1253
1347
  *
@@ -1263,7 +1357,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1263
1357
  * You can also pass `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
1264
1358
  * @param [options]
1265
1359
  */
1266
- static openKeyValueStore(storeIdOrName?: StorageIdentifierWithoutAlias | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
1360
+ static openKeyValueStore(storeIdOrName?: StorageIdentifier | null, options?: OpenStorageOptions): Promise<KeyValueStore>;
1267
1361
  /**
1268
1362
  * Opens a request queue and returns a promise resolving to an instance
1269
1363
  * of the {@link RequestQueue} class.
@@ -1281,7 +1375,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1281
1375
  * You can also pass `{ id: 'abc' }` to open by explicit ID, or `{ name: 'abc' }` to open by explicit name.
1282
1376
  * @param [options]
1283
1377
  */
1284
- static openRequestQueue(queueIdOrName?: StorageIdentifierWithoutAlias | null, options?: OpenStorageOptions): Promise<RequestQueue>;
1378
+ static openRequestQueue(queueIdOrName?: StorageIdentifier | null, options?: OpenStorageOptions): Promise<RequestQueue>;
1285
1379
  /**
1286
1380
  * Creates a proxy configuration and returns a promise resolving to an instance
1287
1381
  * of the {@link ProxyConfiguration} class that is already initialized.
@@ -1337,6 +1431,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1337
1431
  * rather than batching via `count` — this gives finer control over budget consumption
1338
1432
  * and avoids situations where more work is requested than the budget allows.
1339
1433
  *
1434
+ * **Note:** `idempotencyKey` is scoped to the whole run, not to `requestId`. In a multi-tenant
1435
+ * Server Actor run, a key reused across requests charges only the first caller, so it must
1436
+ * be globally unique (e.g. derived from `requestId`).
1437
+ *
1340
1438
  * @param options The name of the event to charge for and the number of events to be charged.
1341
1439
  */
1342
1440
  static charge(options: ChargeOptions): Promise<ChargeResult>;
@@ -1344,14 +1442,6 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1344
1442
  * Retrieve the charging manager to access granular pricing information.
1345
1443
  */
1346
1444
  static getChargingManager(): ChargingManager;
1347
- /**
1348
- * Returns a new {@link ApifyEnv} object which contains information parsed from all the Apify environment variables.
1349
- *
1350
- * For the list of the Apify environment variables, see
1351
- * [Actor documentation](https://docs.apify.com/platform/actors/development/programming-interface/environment-variables).
1352
- * If some of the variables are not defined or are invalid, the corresponding value in the resulting object will be null.
1353
- */
1354
- static getEnv(): ApifyEnv;
1355
1445
  /**
1356
1446
  * Returns a new instance of the Apify API client. The `ApifyClient` class is provided
1357
1447
  * by the [apify-client](https://www.npmjs.com/package/apify-client)
@@ -1364,21 +1454,43 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
1364
1454
  * Returns `true` when code is running on Apify platform and `false` otherwise (for example locally).
1365
1455
  */
1366
1456
  static isAtHome(): boolean;
1457
+ /**
1458
+ * Fetches the current Actor run from the Apify API. The result is cached for the lifetime of the Actor,
1459
+ * so use `Actor.apifyClient.run(runId).get()` instead when you need fresh data such as the run status.
1460
+ * Resolves to `undefined` when not running on the Apify platform.
1461
+ */
1462
+ static getCurrentRun(): Promise<ClientActorRun | undefined>;
1367
1463
  /** Default {@link ApifyClient} instance. */
1368
1464
  static get apifyClient(): ApifyClient;
1369
1465
  /** Default {@link Configuration} instance. */
1370
- static get config(): Configuration;
1466
+ static get configuration(): Configuration;
1371
1467
  /** @internal */
1372
1468
  static getDefaultInstance(): Actor;
1373
- private usesPushDataInterception;
1374
- private pushDataViaInterceptedClient;
1375
- private pushDataWithExplicitCharging;
1376
- private _openStorage;
1377
- private _ensureActorInit;
1378
1469
  /**
1379
- * Get time remaining from the Actor run timeout. Returns `undefined` if not on an Apify platform or the current
1380
- * run was started without a timeout.
1470
+ * Replaces or clears the cached default instance returned by {@link Actor.getDefaultInstance}.
1471
+ * @internal
1472
+ */
1473
+ static setDefaultInstance(instance?: Actor): void;
1474
+ /**
1475
+ * The same choice crawlee's `ServiceLocator` makes for its implicit default backend, with the
1476
+ * input-aware {@link ApifyFileSystemStorageBackend} in place of crawlee's — crawlee has no
1477
+ * notion of a run input.
1478
+ */
1479
+ private createLocalStorageBackend;
1480
+ /**
1481
+ * crawlee's service locator is set-once, so a backend registered before `init()` wins and the
1482
+ * Actor cannot install its own over it. Replaces the resulting `ServiceConflictError` with the
1483
+ * way out.
1484
+ */
1485
+ private installStorageBackend;
1486
+ private ensureActorInit;
1487
+ /**
1488
+ * Get time remaining from the Actor run timeout in seconds, rounded up to whole seconds with minimum value of 1 second.
1489
+ *
1490
+ * The API treats a 0 second timeout as no timeout, the minimum acceptable timeout is 1 second.
1491
+ *
1492
+ * Returns `undefined` if not on the Apify platform or the current run was started without a timeout.
1381
1493
  */
1382
- private getRemainingTime;
1494
+ private getRemainingTimeSecs;
1383
1495
  private inferDefaultsFromInputSchema;
1384
1496
  }